Skip to content

Commit

Permalink
Bugfix in argument marshalling.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver7654 committed Sep 16, 2013
1 parent dd4ed7f commit b99e861
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions Source/Modules/javascript.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class JSEmitter {

virtual void marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, MarshallingMode mode, bool is_member, bool is_static) = 0;

virtual void emitInputTypemap(Node *n, Parm *params, Wrapper *wrapper, String *arg);
virtual String *emitInputTypemap(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);

Expand Down Expand Up @@ -1179,7 +1179,7 @@ int JSEmitter::emitFunctionDispatcher(Node *n, bool /*is_member */ ) {
return SWIG_OK;
}

void JSEmitter::emitInputTypemap(Node *n, Parm *p, Wrapper *wrapper, String *arg) {
String *JSEmitter::emitInputTypemap(Node *n, Parm *p, Wrapper *wrapper, String *arg) {
// Get input typemap for current param
String *tm = Getattr(p, "tmap:in");
SwigType *type = Getattr(p, "type");
Expand All @@ -1197,7 +1197,10 @@ void JSEmitter::emitInputTypemap(Node *n, Parm *p, Wrapper *wrapper, String *arg
Printf(wrapper->code, "%s\n", tm);
} else {
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(type, 0));
Swig_print(p);
}

return tm;
}

void JSEmitter::marshalOutput(Node *n, ParmList *params, Wrapper *wrapper, String *actioncode, const String *cresult, bool emitReturnVariable) {
Expand Down Expand Up @@ -1413,6 +1416,7 @@ JSCEmitter::~JSCEmitter() {

void JSCEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, MarshallingMode mode, bool is_member, bool is_static) {
Parm *p;
String *tm;

// determine an offset index, as members have an extra 'this' argument
// except: static members and ctors.
Expand All @@ -1429,7 +1433,7 @@ void JSCEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Ma

// process arguments
int i = 0;
for (p = parms; p; p = nextSibling(p), i++) {
for (p = parms; p; i++) {
String *arg = NewString("");
switch (mode) {
case Getter:
Expand All @@ -1453,8 +1457,13 @@ void JSCEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Ma
default:
throw "Illegal state.";
}
emitInputTypemap(n, p, wrapper, arg);
tm = emitInputTypemap(n, p, wrapper, arg);
Delete(arg);
if (tm) {
p = Getattr(p, "tmap:in:next");
} else {
p = nextSibling(p);
}
}
}

Expand Down Expand Up @@ -2066,6 +2075,7 @@ int V8Emitter::exitFunction(Node* n)

void V8Emitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, MarshallingMode mode, bool is_member, bool is_static) {
Parm *p;
String *tm;

int startIdx = 0;
if (is_member && !is_static && mode!=Ctor) {
Expand Down Expand Up @@ -2109,8 +2119,14 @@ void V8Emitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Mar
default:
throw "Illegal state.";
}
emitInputTypemap(n, p, wrapper, arg);

tm = emitInputTypemap(n, p, wrapper, arg);
Delete(arg);
if (tm) {
p = Getattr(p, "tmap:in:next");
} else {
p = nextSibling(p);
}
}
}

Expand Down

0 comments on commit b99e861

Please sign in to comment.