aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Jylanki <jjylanki@imvu.com>2013-03-27 08:58:35 +0200
committerJukka Jylänki <jujjyl@gmail.com>2013-04-12 14:26:50 +0300
commit0c11a28ccfa3716962c7424fe227c82edc04de16 (patch)
tree4dcf8973afb7b193f32211fd38b0659e272cb15b
parent113721e6c6ca4cbde2bb39c4460269424ef3d81d (diff)
Fix passing of UINT_MAX and ULONG_MAX from C++ to JS function. LLVM doesn't have u32 type, so UINT_MAX literal comes out as 'i32 -1' literal to JS, which whould treat it as a negative -1.0 double.
-rwxr-xr-xsrc/embind/embind.js5
-rwxr-xr-xsystem/include/emscripten/bind.h4
2 files changed, 6 insertions, 3 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index ccce9f19..1a2cec44 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -225,7 +225,10 @@ function __embind_register_bool(rawType, name, trueValue, falseValue) {
// [minRange, maxRange], inclusive.
function __embind_register_integer(primitiveType, name, minRange, maxRange) {
name = Pointer_stringify(name);
- registerType(rawType, {
+ if (maxRange == -1) { // LLVM doesn't have signed and unsigned 32-bit types, so u32 literals come out as 'i32 -1'. Always treat those as max u32.
+ maxRange = 4294967295;
+ }
+ registerType(primitiveType, {
name: name,
minRange: minRange,
maxRange: maxRange,
diff --git a/system/include/emscripten/bind.h b/system/include/emscripten/bind.h
index b30cf54b..211c67c0 100755
--- a/system/include/emscripten/bind.h
+++ b/system/include/emscripten/bind.h
@@ -40,8 +40,8 @@ namespace emscripten {
void _embind_register_integer(
TYPEID integerType,
const char* name,
- int minRange,
- int maxRange);
+ long minRange,
+ unsigned long maxRange);
void _embind_register_float(
TYPEID floatType,