diff options
author | Chad Austin <caustin@gmail.com> | 2014-03-07 00:38:05 -0800 |
---|---|---|
committer | Chad Austin <chad@chadaustin.me> | 2014-03-28 23:56:39 -0700 |
commit | 61849992b28d205eca211a2530ed752839f1c60f (patch) | |
tree | dbdec24061da4a098d736736facd659a6c8f8cb5 /tests/embind/embind_test.cpp | |
parent | 13e7b4cf2453c7332ed41297e4a7343747f2274f (diff) |
Add some unit tests that verify we can pass all kinds of primitive types through val::as
Diffstat (limited to 'tests/embind/embind_test.cpp')
-rw-r--r-- | tests/embind/embind_test.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp index 4efc4bd8..af8b2e8d 100644 --- a/tests/embind/embind_test.cpp +++ b/tests/embind/embind_test.cpp @@ -2304,3 +2304,18 @@ EMSCRIPTEN_BINDINGS(mixins) { .constructor<>() ); } + +template<typename T> +T val_as(const val& v) { + return v.as<T>(); +} + +EMSCRIPTEN_BINDINGS(val_as) { + function("val_as_bool", &val_as<bool>); + function("val_as_char", &val_as<char>); + function("val_as_short", &val_as<short>); + function("val_as_int", &val_as<int>); + function("val_as_long", &val_as<long>); + function("val_as_float", &val_as<float>); + function("val_as_double", &val_as<double>); +} |