18
18
/*global simpleReadValueFromPointer, floatReadValueFromPointer, integerReadValueFromPointer, enumReadValueFromPointer, replacePublicSymbol, craftInvokerFunction, tupleRegistrations*/
19
19
/*global finalizationRegistry, attachFinalizer, detachFinalizer, releaseClassHandle, runDestructor*/
20
20
/*global ClassHandle, makeClassHandle, structRegistrations, whenDependentTypesAreResolved, BindingError, deletionQueue, delayFunction:true, upcastPointer*/
21
- /*global exposePublicSymbol, heap32VectorToArray, new_ , RegisteredPointer_getPointee, RegisteredPointer_destructor, RegisteredPointer_deleteObject, char_0, char_9*/
21
+ /*global exposePublicSymbol, heap32VectorToArray, newFunc , RegisteredPointer_getPointee, RegisteredPointer_destructor, RegisteredPointer_deleteObject, char_0, char_9*/
22
22
/*global getInheritedInstanceCount, getLiveInheritedInstances, setDelayFunction, InternalError, runDestructors*/
23
23
/*global requireRegisteredType, unregisterInheritedInstance, registerInheritedInstance, PureVirtualError, throwUnboundTypeError*/
24
24
/*global assert, validateThis, downcastPointer, registeredPointers, RegisteredClass, getInheritedInstance, ClassHandle_isAliasOf, ClassHandle_clone, ClassHandle_isDeleted, ClassHandle_deleteLater*/
@@ -906,20 +906,12 @@ var LibraryEmbind = {
906
906
}
907
907
} ,
908
908
909
- // Function implementation of operator new, per
910
- // http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
911
- // 13.2.2
912
- // ES3
913
- $new___deps : [ '$createNamedFunction' ] ,
914
- $new_ : function ( constructor , argumentList ) {
909
+ #if DYNAMIC_EXECUTION
910
+ $newFunc__deps : [ '$createNamedFunction' ] ,
911
+ $newFunc : function ( constructor , argumentList ) {
915
912
if ( ! ( constructor instanceof Function ) ) {
916
913
throw new TypeError ( 'new_ called with constructor type ' + typeof ( constructor ) + " which is not a function" ) ;
917
914
}
918
- #if DYNAMIC_EXECUTION == 0
919
- if ( constructor === Function ) {
920
- throw new Error ( 'new_ cannot create a new Function with DYNAMIC_EXECUTION == 0.' ) ;
921
- }
922
- #endif
923
915
/*
924
916
* Previously, the following line was just:
925
917
* function dummy() {};
@@ -937,15 +929,19 @@ var LibraryEmbind = {
937
929
var r = constructor . apply ( obj , argumentList ) ;
938
930
return ( r instanceof Object ) ? r : obj ;
939
931
} ,
932
+ #endif
940
933
941
934
// The path to interop from JS code to C++ code:
942
935
// (hand-written JS code) -> (autogenerated JS invoker) -> (template-generated C++ invoker) -> (target C++ function)
943
936
// craftInvokerFunction generates the JS invoker function for each function exposed to JS through embind.
944
937
$craftInvokerFunction__deps : [
945
- '$makeLegalFunctionName' , '$new_' , '$runDestructors' , '$throwBindingError' ,
946
- #if ASYNCIFY
938
+ '$makeLegalFunctionName' , '$runDestructors' , '$throwBindingError' ,
939
+ #if DYNAMIC_EXECUTION
940
+ '$newFunc' ,
941
+ #endif
942
+ #if ASYNCIFY
947
943
'$Asyncify' ,
948
- #endif
944
+ #endif
949
945
] ,
950
946
$craftInvokerFunction : function ( humanName , argTypes , classType , cppInvokerFunc , cppTargetFunc , isAsync ) {
951
947
// humanName: a human-readable string name for the function to be generated.
@@ -1149,8 +1145,7 @@ var LibraryEmbind = {
1149
1145
1150
1146
args1 . push ( invokerFnBody ) ;
1151
1147
1152
- var invokerFunction = new_ ( Function , args1 ) . apply ( null , args2 ) ;
1153
- return invokerFunction ;
1148
+ return newFunc ( Function , args1 ) . apply ( null , args2 ) ;
1154
1149
#endif
1155
1150
} ,
1156
1151
0 commit comments