Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: compiled/bindings/generator.cpp

Issue 29532626: Issue 5603 - Support references in parameters of exported functions (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created Aug. 31, 2017, 12:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « compiled/bindings/generator.h ('k') | compiled/filter/ActiveFilter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « compiled/bindings/generator.h ('k') | compiled/filter/ActiveFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld