diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-07-21 23:23:04 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-21 23:23:04 -0700 |
commit | 2fa66559a20ce74d7cc8a301a389778b79ca80a7 (patch) | |
tree | 6e448290c076f5e0f8e4fe4315517c38860a130c | |
parent | eca3f4f9fe135f29f70be8f42c82fa3ef8b192b3 (diff) |
notice varargs when creating library function wrappers
-rw-r--r-- | src/jsifier.js | 2 | ||||
-rw-r--r-- | src/parseTools.js | 2 | ||||
-rwxr-xr-x | tests/runner.py | 16 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 30cea99b..7e67fa75 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -50,7 +50,7 @@ function JSify(data, functionsOnly, givenFunctions) { print(pre); data.unparsedFunctions.forEach(function(func) { - Functions.implementedFunctions[func.ident] = Functions.getSignature(func.returnType, func.params.map(function(param) { return param.type })); + Functions.implementedFunctions[func.ident] = Functions.getSignature(func.returnType, func.params.map(function(param) { return param.type }), func.hasVarArgs); }); } } diff --git a/src/parseTools.js b/src/parseTools.js index eb200c65..a5785e27 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1231,7 +1231,7 @@ function indexizeFunctions(value, type) { // add signature to library functions that we now know need indexing var sig = Functions.implementedFunctions[value] || Functions.unimplementedFunctions[value]; if (!sig) { - sig = Functions.unimplementedFunctions[value] = Functions.getSignature(out.returnType, out.segments ? out.segments.map(function(segment) { return segment[0].text }) : []); + sig = Functions.unimplementedFunctions[value] = Functions.getSignature(out.returnType, out.segments ? out.segments.map(function(segment) { return segment[0].text }) : [], isVarArgsFunctionType(type)); } return Functions.getIndex(value, undefined, sig); } diff --git a/tests/runner.py b/tests/runner.py index 8a2274ea..717d8914 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4522,6 +4522,22 @@ The current address of a is: 0x12345678 The current type of b is: 9 ''') + def test_functionpointer_libfunc_varargs(self): + src = r''' + #include <stdio.h> + #include <fcntl.h> + typedef int (*fp_t)(int, int, ...); + int main(int argc, char **argv) { + fp_t fp = &fcntl; + if (argc == 1337) fp = (fp_t)&main; + (*fp)(0, 10); + (*fp)(0, 10, 5); + printf("waka\n"); + return 0; + } + ''' + self.do_run(src, '''waka''') + def test_structbyval(self): Settings.INLINING_LIMIT = 50 |