Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/libccall.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ addToLibrary({
// When the function takes numbers and returns a number, we can just return
// the original function
var numericArgs = !argTypes || argTypes.every((type) => type === 'number' || type === 'boolean');
var numericRet = returnType !== 'string';
var numericRet = returnType !== 'string' && returnType !== 'boolean';
if (numericRet && numericArgs && !opts) {
return getCFunc(ident);
}
Expand Down
8 changes: 6 additions & 2 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7097,10 +7097,14 @@ def test_ccall_cwrap_fast_path(self):
create_file('post.js', '''
var printBool = Module['cwrap']('print_bool', null, ['boolean']);
out(Module['_print_bool'] === printBool); // the function should be the exact raw function in the module rather than a wrapped one
var getBool = Module['cwrap']('get_bool', 'boolean');
out(Module['_get_bool'] !== getBool); // boolean return must not use the fast path so the result is coerced to a JS boolean
var ret = getBool();
out([typeof ret, ret].join(','));
''')

self.set_setting('EXPORTED_FUNCTIONS', ['_print_bool'])
self.do_runf('core/test_ccall.cpp', 'true', cflags=['--post-js=post.js', '-Wno-return-stack-address'])
self.set_setting('EXPORTED_FUNCTIONS', ['_print_bool', '_get_bool'])
self.do_runf('core/test_ccall.cpp', 'true\ntrue\nboolean,true\n', cflags=['--post-js=post.js', '-Wno-return-stack-address'])

@no_modularize_instance('ccall is not yet compatible with MODULARIZE=instance')
def test_ccall_return_pointer(self):
Expand Down