You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix regression that broke calls to makeDynCall in JS library code. (#12732)
* Fix regression that broke calls to makeDynCall in JS library code. Old syntax is {{{ makeDynCall('sig') }}}(funcPtr, arg1, arg2);. New syntax is {{{ makeDynCall('sig', 'funcPtr') }}}(arg1, arg2). With this change, both old and new syntax work, with a compile time warning issued for old syntax to migrate to new one. Add ChangeLog entry about broken static dynCall invocation outside JS library files.
* Address review
warn('warning: use of #ifdef in js library. Use #if instead.');
56
+
if(!inStyle){
57
+
vartrimmed=line.trim()
58
+
if(trimmed[0]==='#'){
59
+
varfirst=trimmed.split(' ',1)[0]
60
+
if(first=='#if'||first=='#ifdef'){
61
+
if(first=='#ifdef'){
62
+
warn('warning: use of #ifdef in js library. Use #if instead.');
63
+
}
64
+
varafter=trimmed.substring(trimmed.indexOf(' '));
65
+
vartruthy=!!eval(after);
66
+
showStack.push(truthy);
67
+
}elseif(first==='#include'){
68
+
if(showStack.indexOf(false)===-1){
69
+
varfilename=line.substr(line.indexOf(' ')+1);
70
+
if(filename.indexOf('"')===0){
71
+
filename=filename.substr(1,filename.length-2);
72
+
}
73
+
varincluded=read(filename);
74
+
varresult=preprocess(included,filename);
75
+
if(result){
76
+
ret+="// include: "+filename+"\n";
77
+
ret+=result;
78
+
ret+="// end include: "+filename+"\n";
79
+
}
80
+
}
81
+
}elseif(first==='#else'){
82
+
assert(showStack.length>0);
83
+
showStack.push(!showStack.pop());
84
+
}elseif(first==='#endif'){
85
+
assert(showStack.length>0);
86
+
showStack.pop();
87
+
}else{
88
+
throw"Unknown preprocessor directive on line "+i+': `'+line+'`';
59
89
}
60
-
varafter=trimmed.substring(trimmed.indexOf(' '));
61
-
vartruthy=!!eval(after);
62
-
showStack.push(truthy);
63
-
}elseif(first==='#include'){
90
+
}else{
64
91
if(showStack.indexOf(false)===-1){
65
-
varfilename=line.substr(line.indexOf(' ')+1);
66
-
if(filename.indexOf('"')===0){
67
-
filename=filename.substr(1,filename.length-2);
92
+
// Never emit more than one empty line at a time.
93
+
if(emptyLine&&!line){
94
+
continue;
68
95
}
69
-
varincluded=read(filename);
70
-
varresult=preprocess(included,filename);
71
-
if(result){
72
-
ret+="// include: "+filename+"\n";
73
-
ret+=result;
74
-
ret+="// end include: "+filename+"\n";
96
+
ret+=line+'\n';
97
+
if(!line){
98
+
emptyLine=true;
99
+
}else{
100
+
emptyLine=false;
75
101
}
76
102
}
77
-
}elseif(first==='#else'){
78
-
assert(showStack.length>0);
79
-
showStack.push(!showStack.pop());
80
-
}elseif(first==='#endif'){
81
-
assert(showStack.length>0);
82
-
showStack.pop();
83
-
}else{
84
-
throw"Unknown preprocessor directive on line "+i+': `'+line+'`';
85
103
}
86
-
}else{
104
+
}else{// !inStyle
87
105
if(showStack.indexOf(false)===-1){
88
-
// Never emit more than one empty line at a time.
89
-
if(emptyLine&&!line){
90
-
continue;
91
-
}
92
106
ret+=line+'\n';
93
-
if(!line){
94
-
emptyLine=true;
95
-
}else{
96
-
emptyLine=false;
97
-
}
98
107
}
99
108
}
100
-
}else{// !inStyle
101
-
if(showStack.indexOf(false)===-1){
102
-
ret+=line+'\n';
103
-
}
109
+
}catch(e){
110
+
printErr('parseTools.js preprocessor error in '+filenameHint+':'+(i+1)+': \"'+line+'\"!');
111
+
throwe;
104
112
}
105
-
}catch(e){
106
-
printErr('parseTools.js preprocessor error in '+filenameHint+':'+(i+1)+': \"'+line+'\"!');
107
-
throwe;
108
113
}
114
+
assert(showStack.length==0,'preprocessing error in file '+filenameHint+', no matching #endif found ('+showStack.length+' unmatched preprocessing directives on stack)');
115
+
returnret;
116
+
}finally{
117
+
currentlyParsedFilename=null;
109
118
}
110
-
assert(showStack.length==0,'preprocessing error in file '+filenameHint+', no matching #endif found ('+showStack.length+' unmatched preprocessing directives on stack)');
111
-
returnret;
112
119
}
113
120
114
121
functionremovePointing(type,num){
@@ -978,6 +985,21 @@ function asmFFICoercion(value, type) {
978
985
979
986
functionmakeDynCall(sig,funcPtr){
980
987
assert(sig.indexOf('j')==-1);
988
+
if(funcPtr===undefined){
989
+
printErr(`warning: ${currentlyParsedFilename}: Legacy use of {{{ makeDynCall("${sig}") }}}(funcPtr, arg1, arg2, ...). Starting from Emscripten 2.0.2 (Aug 31st 2020), syntax for makeDynCall has changed. New syntax is {{{ makeDynCall("${sig}", "funcPtr") }}}(arg1, arg2, ...). Please update to new syntax.`);
0 commit comments