Skip to content

Commit

Permalink
[embind] Add #if ASSERTIONS guard around assert calls
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Nov 2, 2023
1 parent 31e6d0a commit e6e1896
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/embind/embind_shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ var LibraryEmbindShared = {
signature = signature.trim();
const argsIndex = signature.indexOf("(");
if (argsIndex !== -1) {
#if ASSERTIONS
assert(signature[signature.length - 1] == ")", "Parentheses for argument names should match.");
#endif
return signature.substr(0, argsIndex);
} else {
return signature;
Expand All @@ -140,7 +142,9 @@ var LibraryEmbindShared = {
signature = signature.trim();
const argsIndex = signature.indexOf("(") + 1;
if (argsIndex !== 0) {
#if ASSERTIONS
assert(signature[signature.length - 1] == ")", "Parentheses for argument names should match.");
#endif
return signature.substr(argsIndex, signature.length - argsIndex - 1).replaceAll(" ", "").split(",").filter(n => n.length);
} else {
return [];
Expand Down
6 changes: 4 additions & 2 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -2900,9 +2900,11 @@ def test_embind_closure_no_dynamic_execution(self):
emscripten::function("bar", &bar);
}
''')
self.emcc_args.remove('-Wclosure')
self.set_setting('INCOMING_MODULE_JS_API', 'onRuntimeInitialized')
self.set_setting('STRICT')
self.set_setting('NO_DYNAMIC_EXECUTION')
self.do_runf('main.cpp', '10\nok\n',
emcc_args=['-lembind', '-O2', '--closure', '1', '-sNO_DYNAMIC_EXECUTION', '--post-js', 'post.js'])
emcc_args=['--no-entry', '-lembind', '-O2', '--closure=1', '--minify=0', '--post-js=post.js'])

@is_slow_test
@parameterized({
Expand Down

0 comments on commit e6e1896

Please sign in to comment.