aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2013-04-11 14:51:54 +0300
committerJukka Jylänki <jujjyl@gmail.com>2013-04-18 20:08:22 +0300
commitc643f6469fc2db1a4aa49e404e7ccf5d412d2838 (patch)
tree6d3637c6b7aab2f76656b085a9e87d88ef303469 /src
parentd9886ee985f8c2f5fd3f3ac8d88867d3895e3366 (diff)
Restore missing argument count check into the embind invoker function generated with makeInvoker.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/embind/embind.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js
index 00d56bc8..7d186ba5 100755
--- a/src/embind/embind.js
+++ b/src/embind/embind.js
@@ -478,18 +478,23 @@ function makeInvoker(name, argCount, argTypes, invoker, fn) {
if (!FUNCTION_TABLE[fn]) {
throwBindingError('function '+name+' is not defined');
}
+
// Functions with signature "void function()" do not need an invoker that marshalls between wire types.
- if (argCount == 1 && argTypes[0].name == "void") {
- return FUNCTION_TABLE[fn];
- }
+// TODO: This omits argument count check - enable only at -O3 or similar.
+// if (ENABLE_UNSAFE_OPTS && argCount == 1 && argTypes[0].name == "void") {
+// return FUNCTION_TABLE[fn];
+// }
var invokerFnBody =
"return function "+makeLegalFunctionName(name)+"() { " +
+ "if (arguments.length !== "+(argCount - 1)+") {" +
+ "throwBindingError('function "+name+" called with ' + arguments.length + ' arguments, expected "+(argCount - 1)+" args!');" +
+ "}" +
"var destructors = [];";
var argsList = "";
- var args1 = ["invoker", "fn", "runDestructors", "retType" ];
- var args2 = [invoker, fn, runDestructors, argTypes[0] ];
+ var args1 = ["throwBindingError", "invoker", "fn", "runDestructors", "retType" ];
+ var args2 = [throwBindingError, invoker, fn, runDestructors, argTypes[0] ];
for(i = 0; i < argCount-1; ++i) {
invokerFnBody += "var arg"+i+" = argType"+i+".toWireType(destructors, arguments["+i+"]);";