fix bug in closure messing up cwrap (my fault)
This commit is contained in:
Родитель
1bbd1ba0b3
Коммит
4f420ed35d
|
@ -341,6 +341,15 @@ function getCFunc(ident) {
|
|||
var cwrap, ccall;
|
||||
(function(){
|
||||
var JSfuncs = {
|
||||
// Helpers for cwrap -- it can't refer to Runtime directly because it might
|
||||
// be renamed by closure, instead it calls JSfuncs['stackSave'].body to find
|
||||
// out what the minified function name is.
|
||||
'stackSave': function() {
|
||||
Runtime.stackSave()
|
||||
},
|
||||
'stackRestore': function() {
|
||||
Runtime.stackRestore()
|
||||
},
|
||||
// type conversion from js to c
|
||||
'arrayToC' : function(arr) {
|
||||
var ret = Runtime.stackAlloc(arr.length);
|
||||
|
@ -419,7 +428,7 @@ var cwrap, ccall;
|
|||
if (!numericArgs) {
|
||||
// Generate the code needed to convert the arguments from javascript
|
||||
// values to pointers
|
||||
funcstr += 'var stack = Runtime.stackSave();';
|
||||
funcstr += 'var stack = ' + JSsource['stackSave'].body + ';';
|
||||
for (var i = 0; i < nargs; i++) {
|
||||
var arg = argNames[i], type = argTypes[i];
|
||||
if (type === 'number') continue;
|
||||
|
@ -441,7 +450,7 @@ var cwrap, ccall;
|
|||
}
|
||||
if (!numericArgs) {
|
||||
// If we had a stack, restore it
|
||||
funcstr += 'Runtime.stackRestore(stack);';
|
||||
funcstr += JSsource['stackRestore'].body.replace('()', '(stack)') + ';';
|
||||
}
|
||||
funcstr += 'return ret})';
|
||||
return eval(funcstr);
|
||||
|
|
|
@ -26,7 +26,7 @@ struct test_struct {
|
|||
int arg1, arg2, arg3;
|
||||
};
|
||||
static int* stackChecker = 0;
|
||||
int get_stack() { return EM_ASM_INT_V({ return Runtime.stackSave(); }); }
|
||||
int get_stack() { int i; return (int)&i; }
|
||||
int uses_stack(test_struct* t1) {
|
||||
if (stackChecker == 0) stackChecker = (int*)malloc(sizeof(int));
|
||||
*stackChecker = get_stack();
|
||||
|
|
Загрузка…
Ссылка в новой задаче