Remove use of addAtMain is webidl_binder.py (#14585)
Support for `addAtMain` in application without a main function was removed in #13901 but I missed that fact that webidl_binder.py was doing this. This change replaces `addAtMain` with `addOnInit` and also makes the use of `addAtMain` in applications without a `main` into an error so that the problem (and solution) should be clear. Update webidl binder test to only use sync compilation when needed, so that code in question actually gets tested. This change also reduces code size by not including `addAtMain` at all in applications without a `main`. Fixes: #14583.
This commit is contained in:
Родитель
ad135eb08d
Коммит
e6f4d49566
|
@ -1083,6 +1083,7 @@ function addAtInit(code) {
|
|||
global.ATMAINS = [];
|
||||
|
||||
function addAtMain(code) {
|
||||
assert(HAS_MAIN, 'addAtMain called but program has no main function');
|
||||
ATMAINS.push(code);
|
||||
}
|
||||
|
||||
|
|
|
@ -350,7 +350,9 @@ assert(INITIAL_MEMORY == {{{INITIAL_MEMORY}}}, 'Detected runtime INITIAL_MEMORY
|
|||
|
||||
var __ATPRERUN__ = []; // functions called before the runtime is initialized
|
||||
var __ATINIT__ = []; // functions called during startup
|
||||
#if HAS_MAIN
|
||||
var __ATMAIN__ = []; // functions called when main() is to be run
|
||||
#endif
|
||||
var __ATEXIT__ = []; // functions called during shutdown
|
||||
var __ATPOSTRUN__ = []; // functions called after the main() is called
|
||||
|
||||
|
@ -464,9 +466,11 @@ function addOnInit(cb) {
|
|||
__ATINIT__.unshift(cb);
|
||||
}
|
||||
|
||||
#if HAS_MAIN
|
||||
function addOnPreMain(cb) {
|
||||
__ATMAIN__.unshift(cb);
|
||||
}
|
||||
#endif
|
||||
|
||||
function addOnExit(cb) {
|
||||
#if EXIT_RUNTIME
|
||||
|
|
|
@ -6944,6 +6944,7 @@ someweirdtext
|
|||
self.do_run(src, '418\ndotest returned: 42\n')
|
||||
|
||||
@parameterized({
|
||||
'': (None, False),
|
||||
'all': ('ALL', False),
|
||||
'fast': ('FAST', False),
|
||||
'default': ('DEFAULT', False),
|
||||
|
@ -6955,6 +6956,8 @@ someweirdtext
|
|||
if self.maybe_closure():
|
||||
# avoid closure minified names competing with our test code in the global name space
|
||||
self.set_setting('MODULARIZE')
|
||||
else:
|
||||
self.set_setting('WASM_ASYNC_COMPILATION', 0)
|
||||
|
||||
# Force IDL checks mode
|
||||
with env_modify({'IDL_CHECKS': mode}):
|
||||
|
@ -6982,8 +6985,10 @@ someweirdtext
|
|||
if allow_memory_growth:
|
||||
self.set_setting('ALLOW_MEMORY_GROWTH')
|
||||
|
||||
output = test_file('webidl/output_%s.txt' % mode)
|
||||
self.do_run_from_file(test_file('webidl/test.cpp'), output)
|
||||
if not mode:
|
||||
mode = 'DEFAULT'
|
||||
expected = test_file('webidl/output_%s.txt' % mode)
|
||||
self.do_run_from_file(test_file('webidl/test.cpp'), expected)
|
||||
|
||||
### Tests for tools
|
||||
|
||||
|
|
|
@ -149,14 +149,14 @@ console.log(TheModule.enum_value1);
|
|||
console.log(TheModule.enum_value2);
|
||||
|
||||
// Enums from classes are accessed via the class.
|
||||
enumClassInstance = new TheModule.EnumClass();
|
||||
var enumClassInstance = new TheModule.EnumClass();
|
||||
console.log([enumClassInstance.GetEnum(), TheModule.EnumClass.e_val].join(','));
|
||||
|
||||
// Enums from namespaces are accessed via the top-level module, as with classes defined
|
||||
// in namespaces, see `Inner` above.
|
||||
console.log(TheModule.e_namespace_val);
|
||||
|
||||
typeTester = new TheModule.TypeTestClass();
|
||||
var typeTester = new TheModule.TypeTestClass();
|
||||
|
||||
console.log('return char ' + (typeTester.ReturnCharMethod() & 255));
|
||||
typeTester.AcceptCharMethod((2<<6)-1);
|
||||
|
@ -288,4 +288,4 @@ if (isMemoryGrowthAllowed) {
|
|||
//
|
||||
|
||||
console.log('\ndone.')
|
||||
})();
|
||||
})();
|
||||
|
|
|
@ -807,7 +807,7 @@ if len(deferred_js):
|
|||
%s
|
||||
}
|
||||
if (runtimeInitialized) setupEnums();
|
||||
else addOnPreMain(setupEnums);
|
||||
else addOnInit(setupEnums);
|
||||
})();
|
||||
''' % '\n '.join(deferred_js)]
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче