aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-08-16 12:58:13 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-08-16 12:58:13 -0700
commit1d89260748bcf2ba5965ffa67126f3edaef31f07 (patch)
treed319cf61b7fdbf858e40869d0dff14ca8ccc000f /src
parentf46ea8746cd469b8ba664e52a63b6112fcd48b9e (diff)
allow overriding a gl function with the same name, and keep the original accessible through getProcAddress
Diffstat (limited to 'src')
-rw-r--r--src/library_gl.js27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index dc1c1fc6..c134ad97 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -4319,15 +4319,28 @@ LibraryGL.emscripten_GetProcAddress__deps = [function() {
// ProcAddress is used, so include everything in GL. This runs before we go to the $ProcAddressTable object,
// and we fill its deps just in time, and create the lookup table
var table = {};
- LibraryManager.library.emscripten_procAddressTable__deps = keys(LibraryGL).filter(function(x) {
- if (x.substr(-6) == '__deps' || x.substr(-9) == '__postset' || x.substr(-5) == '__sig' || x.substr(0, 2) != 'gl') return false;
- var sig = LibraryGL[x + '__sig'] || functionStubSigs['_' + x];
+ LibraryManager.library.emscripten_procAddressTable__deps = keys(LibraryGL).map(function(x) {
+ if (x.substr(-6) == '__deps' || x.substr(-9) == '__postset' || x.substr(-5) == '__sig' || x.substr(-5) == '__asm' || x.substr(0, 2) != 'gl') return null;
+ var original = x;
+ if (('_' + x) in Functions.implementedFunctions) {
+ // a user-implemented function aliases this one, but we still want it to be accessible by name, so rename it
+ var y = x + '__procTable';
+ LibraryManager.library[y] = LibraryManager.library[x];
+ LibraryManager.library[y + '__deps'] = LibraryManager.library[x + '__deps'];
+ LibraryManager.library[y + '__postset'] = LibraryManager.library[x + '__postset'];
+ LibraryManager.library[y + '__sig'] = LibraryManager.library[x + '__sig'];//|| Functions.implementedFunctions['_' + x];
+ LibraryManager.library[y + '__asm'] = LibraryManager.library[x + '__asm'];
+ x = y;
+ assert(!(y in Functions.implementedFunctions) && !Functions.unimplementedFunctions['_' + y]);
+ }
+ var longX = '_' + x;
+ var sig = LibraryManager.library[x + '__sig'] || functionStubSigs[longX];
if (sig) {
- table[x] = Functions.getIndex('_' + x, sig);
- if (!(('_' + x) in Functions.implementedFunctions)) Functions.unimplementedFunctions[('_' + x)] = sig;
+ table[original] = Functions.getIndex(longX, sig);
+ if (!(longX in Functions.implementedFunctions)) Functions.unimplementedFunctions[longX] = sig;
}
- return true;
- });
+ return x;
+ }).filter(function(x) { return x !== null });
// convert table into function with switch, to not confuse closure compiler
var tableImpl = 'switch(name) {\n';
for (var x in table) tableImpl += 'case "' + x + '": return ' + table[x] + '; break;\n';