diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-16 17:33:52 +0300 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-04-18 20:08:31 +0300 |
commit | 8892232a7174008595c82fda7a64e5995cc4e3e0 (patch) | |
tree | 85fba7678c2a76450a74a9c29d03d222ccd7fd69 /src/embind | |
parent | 63df46540d7ba78dca88fd83ec0def3bd203b638 (diff) |
Fix test runner - preserve validateThis and convert class this to wire type before parameters to catch invalid this type before invalid parameters.
Diffstat (limited to 'src/embind')
-rwxr-xr-x | src/embind/embind.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/embind/embind.js b/src/embind/embind.js index bf493bf9..5ae258cd 100755 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -520,8 +520,11 @@ function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cp "return function "+makeLegalFunctionName(humanName)+"("+argsList+") {\n" + "if (arguments.length !== "+(argCount - 2)+") {\n" + "throwBindingError('function "+humanName+" called with ' + arguments.length + ' arguments, expected "+(argCount - 2)+" args!');\n" + - "}\n";// + - //"validateThis(this, classType, '"+humanName+"');\n"; + "}\n"; + + if (isClassMethodFunc) { + invokerFnBody += "validateThis(this, classType, '"+humanName+"');\n"; + } // Determine if we need to use a dynamic stack to store the destructors for the function parameters. // TODO: Remove this completely once all function invokers are being dynamically generated. @@ -543,6 +546,10 @@ function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cp var args1 = ["throwBindingError", "validateThis", "classType", "invoker", "fn", "runDestructors", "retType", "classParam"]; var args2 = [throwBindingError, validateThis, classType, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]]; + if (isClassMethodFunc) { + invokerFnBody += "var thisWired = classParam.toWireType("+dtorStack+", this);\n"; + } + for(var i = 0; i < argCount-2; ++i) { invokerFnBody += "var arg"+i+" = argType"+i+".toWireType("+dtorStack+", arg"+i+"); // "+argTypes[i+2].name+"\n"; // argsList += ", arg"+i; @@ -551,7 +558,6 @@ function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cp } if (isClassMethodFunc) { - invokerFnBody += "var thisWired = classParam.toWireType("+dtorStack+", this);\n"; argsList = "thisWired" + (argsList.length > 0 ? ", " : "") + argsList; } @@ -932,7 +938,7 @@ function RegisteredPointer( this.rawConstructor = rawConstructor; this.rawShare = rawShare; this.rawDestructor = rawDestructor; - +/* if (!isSmartPointer && registeredClass.baseClass === undefined) { if (isConst) { this.toWireType = constNoSmartPtrRawPointerToWireType; @@ -941,9 +947,9 @@ function RegisteredPointer( this.toWireType = nonConstNoSmartPtrRawPointerToWireType; this.destructorFunction = null; } - } else { + } else {*/ this.toWireType = genericPointerToWireType; - } + //} } RegisteredPointer.prototype.getPointee = function(ptr) { |