Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/test/core/EXPORTED_RUNTIME_METHODS.c
4150 views
1
/*
2
* Copyright 2017 The Emscripten Authors. All rights reserved.
3
* Emscripten is available under two separate licenses, the MIT license and the
4
* University of Illinois/NCSA Open Source License. Both these licenses can be
5
* found in the LICENSE file.
6
*/
7
8
#include <emscripten.h>
9
10
void waka(int x, int y, int z) {
11
EM_ASM({
12
out('received ' + [$0, $1, $2] + '.');
13
}, x, y, z);
14
}
15
16
int main() {
17
EM_ASM({
18
#if EXPORTED
19
// test for additional things being exported
20
assert(Module['addFunction'], 'missing addFunction export');
21
assert(Module['lengthBytesUTF8'], 'missing lengthBytesUTF8 export');
22
Module['setTempRet0'](42);
23
assert(Module['getTempRet0']() == 42);
24
// the main test here
25
Module['dynCall']('viii', $0, [1, 4, 9]);
26
#else
27
// If 'ASSERTIONS' is enabled, these properties all exist, but with
28
// stubs that show a useful error if called. So it is only meaningful
29
// to check they don't exist when assertions are disabled.
30
if (!ASSERTIONS) {
31
assert(!Module['addFunction'], 'missing addFunction export');
32
assert(!Module['lengthBytesUTF8'], 'missing lengthBytesUTF8 export');
33
assert(!Module['dynCall'], 'missing dynCall export');
34
}
35
dynCall('viii', $0, [1, 4, 9]);
36
#endif
37
}, &waka);
38
}
39
40
41