bindings generator fix +fixes for use of |this| instead of Module
This commit is contained in:
Родитель
a70b811afc
Коммит
534cc7f058
|
@ -320,7 +320,7 @@ function setValue(ptr, value, type) {
|
|||
default: abort('invalid type for setValue: ' + type);
|
||||
}
|
||||
}
|
||||
this['setValue'] = setValue;
|
||||
Module['setValue'] = setValue;
|
||||
|
||||
// Parallel to setValue.
|
||||
|
||||
|
@ -338,7 +338,7 @@ function getValue(ptr, type) {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
this['getValue'] = getValue;
|
||||
Module['getValue'] = getValue;
|
||||
|
||||
// Allocates memory for some data and initializes it properly.
|
||||
|
||||
|
|
|
@ -442,8 +442,17 @@ function customizeVTable(object, replacementPairs) {
|
|||
FUNCTION_TABLE.push(0);
|
||||
setValue(vTable2 + Runtime.QUANTUM_SIZE*i, index, 'void*');
|
||||
}
|
||||
var args = [{ptr: 0}];
|
||||
replacementPairs.forEach(function(pair) {
|
||||
pair.original.call(object);
|
||||
// We need the wrapper function that converts arguments to not fail. Keep adding arguments til it works.
|
||||
while(1) {
|
||||
try {
|
||||
pair['original'].apply(object, args);
|
||||
break;
|
||||
} catch(e) {
|
||||
args.push(args[0]);
|
||||
}
|
||||
}
|
||||
pair.originalIndex = getValue(vTable + canaryValue*Runtime.QUANTUM_SIZE, 'void*');
|
||||
});
|
||||
FUNCTION_TABLE = FUNCTION_TABLE.slice(0, functions);
|
||||
|
@ -453,7 +462,7 @@ function customizeVTable(object, replacementPairs) {
|
|||
var replacements = {};
|
||||
replacementPairs.forEach(function(pair) {
|
||||
var replacementIndex = FUNCTION_TABLE.length;
|
||||
FUNCTION_TABLE.push(pair.replacement);
|
||||
FUNCTION_TABLE.push(pair['replacement']);
|
||||
FUNCTION_TABLE.push(0);
|
||||
replacements[pair.originalIndex] = replacementIndex;
|
||||
});
|
||||
|
@ -485,7 +494,7 @@ def generate_class(generating_classname, classname, clazz): # TODO: deprecate ge
|
|||
# For abstract base classes, add a function definition on top. There is no constructor
|
||||
gen_js.write('\nfunction ' + generating_classname_head + ('(){ throw "%s is abstract!" }\n' % generating_classname_head) + generate_wrapping_code(generating_classname_head))
|
||||
if export:
|
||||
gen_js.write('''this['%s'] = %s;
|
||||
gen_js.write('''Module['%s'] = %s;
|
||||
''' % (generating_classname_head, generating_classname_head))
|
||||
|
||||
for method in clazz['final_methods'].itervalues():
|
||||
|
@ -658,7 +667,7 @@ function %s(%s) {
|
|||
|
||||
if export:
|
||||
js_text += '''
|
||||
this['%s'] = %s;
|
||||
Module['%s'] = %s;
|
||||
''' % (mname_suffixed, mname_suffixed)
|
||||
|
||||
else:
|
||||
|
|
Загрузка…
Ссылка в новой задаче