handle `"tmap:in" == NULL`

Even if this can't really happen in practice
This commit is contained in:
Momtchil Momtchev 2023-08-08 12:26:29 +02:00 committed by Olly Betts
parent df22fad547
commit 55207d5e52
1 changed files with 10 additions and 15 deletions

View File

@ -1406,13 +1406,19 @@ String *JSEmitter::emitInputTypemap(Node *n, Parm *p, Wrapper *wrapper, String *
}
} 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));
return NULL;
}
if (is_optional) {
Printf(code, "}\n");
}
Append(wrapper->code, code);
// numinputs=0 typemaps are emitted by the legacy code in
// emit_attach_parmmaps() in emit.cxx, check the comment there
// All generators work around this
if (!checkAttribute(p, "tmap:in:numinputs", "0")) {
Append(wrapper->code, code);
}
return code;
}
@ -1700,10 +1706,7 @@ void JSCEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Ma
Exit(EXIT_FAILURE);
}
// numinputs=0 typemaps are emitted by the legacy code in
// emit_attach_parmmaps() in emit.cxx, check the comment there
if (!checkAttribute(p, "tmap:in:numinputs", "0"))
tm = emitInputTypemap(n, p, wrapper, arg);
tm = emitInputTypemap(n, p, wrapper, arg);
Delete(arg);
if (tm) {
@ -2368,11 +2371,7 @@ void V8Emitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Mar
Exit(EXIT_FAILURE);
}
// numinputs=0 typemaps are emitted by the legacy code in
// emit_attach_parmmaps() in emit.cxx, check the comment there
// All language backends work around this
if (!checkAttribute(p, "tmap:in:numinputs", "0"))
tm = emitInputTypemap(n, p, wrapper, arg);
tm = emitInputTypemap(n, p, wrapper, arg);
Delete(arg);
if (tm) {
@ -2938,11 +2937,7 @@ void NAPIEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, M
Exit(EXIT_FAILURE);
}
if (GetInt(p, "tmap:in:numinputs") != 0) {
// in typemaps with numinputs=0 are a special case
// and are handled in emit.cxx:emit_attach_parmmaps()
tm = emitInputTypemap(n, p, wrapper, arg);
}
tm = emitInputTypemap(n, p, wrapper, arg);
Delete(arg);
if (tm) {