summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMomtchil Momtchev <momtchil@momtchev.com>2023-04-26 18:23:53 +0200
committerMomtchil Momtchev <momtchil@momtchev.com>2023-04-26 18:23:53 +0200
commitedd55210bb2d4212aeae0876372dd99c867f0071 (patch)
tree8a80abd8556ae425becbf3bab14169a51db54cdc
parent1657a0a1ec8dbdded01ab0a225bf290b44ef4a18 (diff)
downloadswig-edd55210bb2d4212aeae0876372dd99c867f0071.tar.gz
take into account numinputs when counting arguments
-rw-r--r--Examples/test-suite/javascript/ignore_parameter_runme.js24
-rw-r--r--Source/Modules/javascript.cxx24
2 files changed, 33 insertions, 15 deletions
diff --git a/Examples/test-suite/javascript/ignore_parameter_runme.js b/Examples/test-suite/javascript/ignore_parameter_runme.js
new file mode 100644
index 000000000..07dcf2f7d
--- /dev/null
+++ b/Examples/test-suite/javascript/ignore_parameter_runme.js
@@ -0,0 +1,24 @@
+const ignore_parameter = require('ignore_parameter');
+
+function check(a, b) {
+ if (a !== b) throw new Error(`'${a}' != '${b}`);
+}
+
+check(ignore_parameter.jaguar(200, 0), "hello");
+check(ignore_parameter.lotus("foo", 1), 101);
+check(ignore_parameter.tvr("bar", 2), 8.8);
+check(ignore_parameter.ferrari(), 101);
+check(ignore_parameter.fiat(17), 17);
+
+car = new ignore_parameter.SportsCars();
+check(car.daimler(200, 0), "hello");
+check(car.astonmartin("foo", 1), 101);
+check(car.bugatti("bar", 2), 8.8);
+check(car.lamborghini(), 101);
+check(car.maseratti(289), 289);
+check(car.audi(), 8.8);
+
+new ignore_parameter.MiniCooper(200, 0);
+new ignore_parameter.MorrisMinor("baz", 0);
+new ignore_parameter.FordAnglia("quux", 200);
+new ignore_parameter.AustinAllegro();
diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx
index 2fbc5505c..a837f6275 100644
--- a/Source/Modules/javascript.cxx
+++ b/Source/Modules/javascript.cxx
@@ -264,8 +264,6 @@ protected:
*/
Node *getBaseClass(Node *n);
- Parm *skipIgnoredArgs(Parm *p);
-
virtual int createNamespace(String *scope);
virtual Hash *createNamespaceEntry(const char *name, const char *parent, const char *parent_mangled);
@@ -689,17 +687,6 @@ int JSEmitter::initialize(Node * /*n */ ) {
return SWIG_OK;
}
-/* ---------------------------------------------------------------------
- * skipIgnoredArgs()
- * --------------------------------------------------------------------- */
-
-Parm *JSEmitter::skipIgnoredArgs(Parm *p) {
- while (checkAttribute(p, "tmap:in:numinputs", "0")) {
- p = Getattr(p, "tmap:in:next");
- }
- return p;
-}
-
/* -----------------------------------------------------------------------------
* JSEmitter::getBaseClass() : the node of the base class or NULL
*
@@ -2173,7 +2160,7 @@ void V8Emitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Mar
Setattr(n, ARGCOUNT, argcount);
int i = 0;
- for (p = parms; p; i++) {
+ for (p = parms; p;) {
String *arg = NewString("");
String *type = Getattr(p, "type");
@@ -2185,26 +2172,33 @@ void V8Emitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Mar
case Getter:
if (is_member && !is_static && i == 0) {
Printv(arg, "info.Holder()", 0);
+ i++;
} else {
- Printf(arg, "args[%d]", i - startIdx);
+ Printf(arg, "args[%d]", i - startIdx);
+ i += GetInt(p, "tmap:in:numinputs");
}
break;
case Function:
if (is_member && !is_static && i == 0) {
Printv(arg, "args.Holder()", 0);
+ i++;
} else {
Printf(arg, "args[%d]", i - startIdx);
+ i += GetInt(p, "tmap:in:numinputs");
}
break;
case Setter:
if (is_member && !is_static && i == 0) {
Printv(arg, "info.Holder()", 0);
+ i++;
} else {
Printv(arg, "value", 0);
+ i++;
}
break;
case Ctor:
Printf(arg, "args[%d]", i);
+ i += GetInt(p, "tmap:in:numinputs");
break;
default:
Printf(stderr, "Illegal MarshallingMode.");