Skip to content

Commit 641b0b1

Browse files
authored
[embind] Add #if ASSERTIONS guard around assert calls (#20606)
Supersedes #20504
1 parent 74fdcac commit 641b0b1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/embind/embind_shared.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ var LibraryEmbindShared = {
129129
signature = signature.trim();
130130
const argsIndex = signature.indexOf("(");
131131
if (argsIndex !== -1) {
132+
#if ASSERTIONS
132133
assert(signature[signature.length - 1] == ")", "Parentheses for argument names should match.");
134+
#endif
133135
return signature.substr(0, argsIndex);
134136
} else {
135137
return signature;
@@ -140,7 +142,9 @@ var LibraryEmbindShared = {
140142
signature = signature.trim();
141143
const argsIndex = signature.indexOf("(") + 1;
142144
if (argsIndex !== 0) {
145+
#if ASSERTIONS
143146
assert(signature[signature.length - 1] == ")", "Parentheses for argument names should match.");
147+
#endif
144148
return signature.substr(argsIndex, signature.length - argsIndex - 1).replaceAll(" ", "").split(",").filter(n => n.length);
145149
} else {
146150
return [];

test/test_other.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,9 +2900,11 @@ def test_embind_closure_no_dynamic_execution(self):
29002900
emscripten::function("bar", &bar);
29012901
}
29022902
''')
2903-
self.emcc_args.remove('-Wclosure')
2903+
self.set_setting('INCOMING_MODULE_JS_API', 'onRuntimeInitialized')
2904+
self.set_setting('STRICT')
2905+
self.set_setting('NO_DYNAMIC_EXECUTION')
29042906
self.do_runf('main.cpp', '10\nok\n',
2905-
emcc_args=['-lembind', '-O2', '--closure', '1', '-sNO_DYNAMIC_EXECUTION', '--post-js', 'post.js'])
2907+
emcc_args=['--no-entry', '-lembind', '-O2', '--closure=1', '--minify=0', '--post-js=post.js'])
29062908

29072909
@is_slow_test
29082910
@parameterized({

0 commit comments

Comments
 (0)