Index: compiled/bindings/generator.cpp |
=================================================================== |
--- a/compiled/bindings/generator.cpp |
+++ b/compiled/bindings/generator.cpp |
@@ -64,16 +64,17 @@ namespace bindings_internal |
break; |
case TypeCategory::DOUBLE: |
signature += 'd'; |
break; |
case TypeCategory::INT: |
case TypeCategory::INT64: |
case TypeCategory::STRING_REF: |
case TypeCategory::CLASS_PTR: |
+ case TypeCategory::CLASS_REF: |
signature += 'i'; |
break; |
default: |
throw std::runtime_error("Unexpected function return type"); |
} |
// `this` pointer is an implicit parameter with clang and should be added |
// to the signature. |
@@ -84,16 +85,17 @@ namespace bindings_internal |
// https://github.com/kripken/emscripten/blob/1.37.3/src/modules.js#L67 |
for (const auto& type : argTypes) |
{ |
switch (type) |
{ |
case TypeCategory::INT: |
case TypeCategory::STRING_REF: |
case TypeCategory::CLASS_PTR: |
+ case TypeCategory::CLASS_REF: |
signature += 'i'; |
break; |
case TypeCategory::INT64: |
// See https://github.com/kripken/emscripten/blob/1.37.3/src/modules.js#L73, |
// numerical types larger than 32-bit are split into multiple |
// 32-bit parameters. |
signature += "ii"; |
break; |
@@ -240,16 +242,17 @@ namespace bindings_internal |
result += " " + call_str + ";\n"; |
result += " var result = readString(string);\n"; |
result += " Module._DestroyString(string);\n"; |
return result; |
} |
case TypeCategory::STRING_REF: |
return " var result = readString(" + call_str + ");\n"; |
case TypeCategory::CLASS_PTR: |
+ case TypeCategory::CLASS_REF: |
{ |
std::string result; |
result += " var result = " + call_str + ";\n"; |
result += " if (result)\n"; |
const ClassInfo* cls = find_class(call.pointerType); |
if (!cls) |
throw std::runtime_error("Function " + call.name + " returns pointer to unknown class"); |
@@ -288,16 +291,18 @@ namespace bindings_internal |
if (call.args[i] == TypeCategory::STRING_REF) |
{ |
hasStringArgs = true; |
params.push_back(std::string("createString(") + argName + ")"); |
} |
else if (call.args[i] == TypeCategory::CLASS_PTR) |
params.push_back(argName + " ? " + argName + "._pointer : 0"); |
+ else if (call.args[i] == TypeCategory::CLASS_REF) |
+ params.push_back(argName + "._pointer"); |
Wladimir Palant
2017/08/31 12:37:39
This is an implicit null check, should be good eno
sergei
2017/08/31 12:59:20
LGTM, though not tested.
|
else if (call.args[i] == TypeCategory::INT64) |
{ |
// 64-bit integers are passed as two integer parameters |
params.push_back(argName + " >>> 0"); |
params.push_back(argName + " / 0x100000000 >>> 0"); |
} |
else |
params.push_back(argName); |