aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-03-16 10:27:51 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-03-16 10:27:51 -0700
commiteb3a262803919851a8079895c0add11628c760b0 (patch)
tree4026c68ad681a057e852e0bd4eaa60e096bb14e9
parent9b64a956949247cb838f03723aa2cde1598e65fc (diff)
get bindings generator to work in asm.js (except for customizeVTable)
-rwxr-xr-xemscripten.py4
-rw-r--r--src/settings.js4
-rwxr-xr-xtests/runner.py9
-rwxr-xr-xtools/bindings_generator.py5
4 files changed, 17 insertions, 5 deletions
diff --git a/emscripten.py b/emscripten.py
index 0698c783..c9d8505d 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -269,8 +269,10 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
for key in curr_forwarded_json['Functions']['indexedFunctions'].iterkeys():
indexed_functions.add(key)
if settings.get('ASM_JS'):
+ export_bindings = settings['EXPORT_BINDINGS']
for key in curr_forwarded_json['Functions']['implementedFunctions'].iterkeys():
- if key in all_exported_functions: exported_implemented_functions.add(key)
+ if key in all_exported_functions or (export_bindings and key.startswith('_emscripten_bind')):
+ exported_implemented_functions.add(key)
for key, value in curr_forwarded_json['Functions']['unimplementedFunctions'].iteritems():
forwarded_json['Functions']['unimplementedFunctions'][key] = value
diff --git a/src/settings.js b/src/settings.js
index 36f53c3c..37c594ac 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -226,11 +226,13 @@ var NAMED_GLOBALS = 0; // If 1, we use global variables for globals. Otherwise
// they are referred to by a base plus an offset (called an indexed global),
// saving global variables but adding runtime overhead.
-var EXPORT_ALL = 0; // If true, we export all the symbols
var EXPORTED_FUNCTIONS = ['_main']; // Functions that are explicitly exported. These functions are kept alive
// through LLVM dead code elimination, and also made accessible outside of
// the generated code even after running closure compiler (on "Module").
// Note the necessary prefix of "_".
+var EXPORT_ALL = 0; // If true, we export all the symbols
+var EXPORT_BINDINGS = 0; // Export all bindings generator functions (prefixed with emscripten_bind_). This
+ // is necessary to use the bindings generator with asm.js
// JS library functions (C functions implemented in JS)
// that we include by default. If you want to make sure
diff --git a/tests/runner.py b/tests/runner.py
index ff44e388..32bc4503 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -7924,7 +7924,8 @@ def process(filename):
def test_scriptaclass(self):
if self.emcc_args is None: return self.skip('requires emcc')
- if Settings.ASM_JS: return self.skip('asm does not bindings generator yet')
+
+ Settings.EXPORT_BINDINGS = 1
header_filename = os.path.join(self.get_dir(), 'header.h')
header = '''
@@ -8099,6 +8100,7 @@ def process(filename):
Module.Child2.prototype.runVirtualFunc(c2);
c2.virtualFunc2();
+''' + ('' if Settings.ASM_JS else '''
// extend the class from JS
var c3 = new Module.Child2;
Module.customizeVTable(c3, [{
@@ -8119,6 +8121,7 @@ def process(filename):
c2.virtualFunc(); // original should remain the same
Module.Child2.prototype.runVirtualFunc(c2);
c2.virtualFunc2();
+''') + '''
Module.print('*ok*');
\'\'\'
@@ -8157,7 +8160,7 @@ Child2:9
*static*
*virtualf*
*virtualf*
-*virtualf2*
+*virtualf2*''' + ('' if Settings.ASM_JS else '''
Parent:9
Child2:9
*js virtualf replacement*
@@ -8165,7 +8168,7 @@ Child2:9
*js virtualf2 replacement*
*virtualf*
*virtualf*
-*virtualf2*
+*virtualf2*''') + '''
*ok*
''', post_build=[post2, post3])
diff --git a/tools/bindings_generator.py b/tools/bindings_generator.py
index d2c165a2..d610ab54 100755
--- a/tools/bindings_generator.py
+++ b/tools/bindings_generator.py
@@ -62,6 +62,10 @@ Notes:
string on the *stack*. The C string will live for the current
function call. If you need it for longer, you need to create a copy
in your C++ code.
+
+ * You should compile with -s EXPORT_BINDINGS=1 in order for the
+ autogenerated bindings functions to be exported. This is necessary
+ when compiling in asm.js mode.
'''
import os, sys, glob, re
@@ -464,6 +468,7 @@ Module['getClass'] = getClass;
function customizeVTable(object, replacementPairs) {
// Does not handle multiple inheritance
+ // Does not work with asm.js
// Find out vtable size
var vTable = getValue(object.ptr, 'void*');