Skip to content

Commit edfbab3

Browse files
wffurrkripken
authored andcommitted
Change use of NO_DYNAMIC_EXECUTION in embind to DYNAMIC_EXECUTION. (#7653)
This was not handled properly by the preprocessor, so we didn't actually reach the NO_ paths.
1 parent 4cf04ea commit edfbab3

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

src/embind/embind.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ var LibraryEmbind = {
5050
Module['flushPendingDeletes'] = flushPendingDeletes;
5151
Module['setDelayFunction'] = setDelayFunction;
5252
#if IN_TEST_HARNESS
53-
#if NO_DYNAMIC_EXECUTION
53+
#if DYNAMIC_EXECUTION
5454
// Without dynamic execution, dynamically created functions will have no
5555
// names. This lets the test suite know that.
56-
Module['NO_DYNAMIC_EXECUTION'] = true;
56+
Module['DYNAMIC_EXECUTION'] = true;
5757
#endif
5858
#if EMBIND_STD_STRING_IS_UTF8
5959
Module['EMBIND_STD_STRING_IS_UTF8'] = true;
@@ -194,7 +194,7 @@ var LibraryEmbind = {
194194
$createNamedFunction__deps: ['$makeLegalFunctionName'],
195195
$createNamedFunction: function(name, body) {
196196
name = makeLegalFunctionName(name);
197-
#if NO_DYNAMIC_EXECUTION
197+
#if DYNAMIC_EXECUTION == 0
198198
return function() {
199199
"use strict";
200200
return body.apply(this, arguments);
@@ -847,9 +847,9 @@ var LibraryEmbind = {
847847
if (!(constructor instanceof Function)) {
848848
throw new TypeError('new_ called with constructor type ' + typeof(constructor) + " which is not a function");
849849
}
850-
#if NO_DYNAMIC_EXECUTION
850+
#if DYNAMIC_EXECUTION == 0
851851
if (constructor === Function) {
852-
throw new Error('new_ cannot create a new Function with NO_DYNAMIC_EXECUTION.');
852+
throw new Error('new_ cannot create a new Function with DYNAMIC_EXECUTION == 0.');
853853
}
854854
#endif
855855

@@ -913,7 +913,7 @@ var LibraryEmbind = {
913913

914914
var returns = (argTypes[0].name !== "void");
915915

916-
#if NO_DYNAMIC_EXECUTION
916+
#if DYNAMIC_EXECUTION == 0
917917
var argsWired = new Array(argCount - 2);
918918
return function() {
919919
if (arguments.length !== argCount - 2) {
@@ -1042,7 +1042,7 @@ var LibraryEmbind = {
10421042
signature = readLatin1String(signature);
10431043

10441044
function makeDynCaller(dynCall) {
1045-
#if NO_DYNAMIC_EXECUTION
1045+
#if DYNAMIC_EXECUTION == 0
10461046
return function() {
10471047
var args = new Array(arguments.length + 1);
10481048
args[0] = rawFunction;

src/embind/emval.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ var LibraryEmVal = {
151151
var obj = new constructor(arg0, arg1, arg2);
152152
return __emval_register(obj);
153153
} */
154-
#if NO_DYNAMIC_EXECUTION
154+
#if DYNAMIC_EXECUTION == 0
155155
var argsList = new Array(argCount + 1);
156156
return function(constructor, argTypes, args) {
157157
argsList[0] = constructor;
@@ -202,7 +202,7 @@ var LibraryEmVal = {
202202
return newer(handle, argTypes, args);
203203
},
204204

205-
#if NO_DYNAMIC_EXECUTION
205+
#if DYNAMIC_EXECUTION == 0
206206
$emval_get_global: function() {
207207
function testGlobal(obj) {
208208
obj['$$$embind_global$$$'] = obj;
@@ -354,7 +354,7 @@ var LibraryEmVal = {
354354
var types = __emval_lookupTypes(argCount, argTypes);
355355

356356
var retType = types[0];
357-
#if NO_DYNAMIC_EXECUTION
357+
#if DYNAMIC_EXECUTION == 0
358358
var argN = new Array(argCount - 1);
359359
var invokerFunction = function(handle, name, destructors, args) {
360360
var offset = 0;

tests/embind/embind.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ module({
162162
});
163163

164164
test("setting and getting property on unrelated class throws error", function() {
165-
var className = cm['NO_DYNAMIC_EXECUTION'] ? '' : 'HasTwoBases';
165+
var className = cm['DYNAMIC_EXECUTION'] ? 'HasTwoBases' : '';
166166
var a = new cm.HasTwoBases;
167167
var e = assert.throws(cm.BindingError, function() {
168168
Object.getOwnPropertyDescriptor(cm.HeldBySmartPtr.prototype, 'i').set.call(a, 10);
@@ -1598,7 +1598,7 @@ module({
15981598

15991599
test("smart pointer object has correct constructor name", function() {
16001600
var e = new cm.HeldBySmartPtr(10, "foo");
1601-
var expectedName = cm['NO_DYNAMIC_EXECUTION'] ? "" : "HeldBySmartPtr";
1601+
var expectedName = cm['DYNAMIC_EXECUTION'] ? "HeldBySmartPtr" : "";
16021602
assert.equal(expectedName, e.constructor.name);
16031603
e.delete();
16041604
});
@@ -2342,7 +2342,7 @@ module({
23422342
});
23432343

23442344
BaseFixture.extend("function names", function() {
2345-
if (cm['NO_DYNAMIC_EXECUTION']) {
2345+
if (!cm['DYNAMIC_EXECUTION']) {
23462346
assert.equal('', cm.ValHolder.name);
23472347
assert.equal('', cm.ValHolder.prototype.setVal.name);
23482348
assert.equal('', cm.ValHolder.makeConst.name);

tests/test_other.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2399,6 +2399,12 @@ def test_embind(self):
23992399
if fail:
24002400
self.assertNotEqual(proc.returncode, 0)
24012401
else:
2402+
if 'DYNAMIC_EXECUTION=0' in args:
2403+
with open(self.in_dir('a.out.js'), 'r') as js_binary_file:
2404+
js_binary_str = js_binary_file.read()
2405+
self.assertNotIn('new Function(', js_binary_str, 'Found "new Function(" with DYNAMIC_EXECUTION=0')
2406+
self.assertNotIn('eval(', js_binary_str, 'Found "eval(" with DYNAMIC_EXECUTION=0')
2407+
24022408
with open(self.in_dir('a.out.js'), 'ab') as f:
24032409
for tf in testFiles:
24042410
f.write(open(tf, 'rb').read())

0 commit comments

Comments
 (0)