summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorMomtchil Momtchev <momtchil@momtchev.com>2023-04-27 18:03:35 +0200
committerErez Geva <ErezGeva2@gmail.com>2023-05-11 23:09:19 +0200
commit2dfa6d6b84eddd81f9c166a033a80b3224cf6127 (patch)
treef82a6776701ddee0744ef59d3d4ace4493459211 /Source
parent1a31e9dc0cbcc458b241293a479123954f55f28c (diff)
downloadswig-2dfa6d6b84eddd81f9c166a033a80b3224cf6127.tar.gz
support check typemaps in JS
Diffstat (limited to 'Source')
-rw-r--r--Source/Modules/javascript.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx
index fbc7ab455..d39868cc0 100644
--- a/Source/Modules/javascript.cxx
+++ b/Source/Modules/javascript.cxx
@@ -255,6 +255,8 @@ protected:
virtual String *emitInputTypemap(Node *n, Parm *params, Wrapper *wrapper, String *arg);
+ virtual String *emitCheckTypemap(Node *n, Parm *params, Wrapper *wrapper, String *arg);
+
virtual void marshalOutput(Node *n, ParmList *params, Wrapper *wrapper, String *actioncode, const String *cresult = 0, bool emitReturnVariable = true);
virtual void emitCleanupCode(Node *n, Wrapper *wrapper, ParmList *params);
@@ -1289,6 +1291,18 @@ String *JSEmitter::emitInputTypemap(Node *n, Parm *p, Wrapper *wrapper, String *
return tm;
}
+String *JSEmitter::emitCheckTypemap(Node *, Parm *p, Wrapper *wrapper, String *arg) {
+ String *tm = Getattr(p, "tmap:check");
+
+ if (tm != nullptr) {
+ Replaceall(tm, "$input", arg);
+ Setattr(p, "emit:input", arg);
+ Printf(wrapper->code, "%s\n", tm);
+ }
+
+ return tm;
+}
+
void JSEmitter::marshalOutput(Node *n, ParmList *params, Wrapper *wrapper, String *actioncode, const String *cresult, bool emitReturnVariable) {
SwigType *type = Getattr(n, "type");
String *tm;
@@ -1568,6 +1582,15 @@ void JSCEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Ma
p = nextSibling(p);
}
}
+
+ for (p = parms; p;) {
+ tm = emitCheckTypemap(n, p, wrapper, Getattr(p, "emit:input"));
+ if (tm) {
+ p = Getattr(p, "tmap:in:next");
+ } else {
+ p = nextSibling(p);
+ }
+ }
}
int JSCEmitter::initialize(Node *n) {
@@ -2219,6 +2242,15 @@ void V8Emitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Mar
p = nextSibling(p);
}
}
+
+ for (p = parms; p;) {
+ tm = emitCheckTypemap(n, p, wrapper, Getattr(p, "emit:input"));
+ if (tm) {
+ p = Getattr(p, "tmap:in:next");
+ } else {
+ p = nextSibling(p);
+ }
+ }
}
int V8Emitter::emitNamespaces() {