Change lookup_cxx_parm_type() to return bool too

This is more consistent with lookup_cxx_ret_type() and makes using it
simpler.

Also move error reporting into this function itself as it could fail for
other reasons than missing "ctype" typemap too.

No real changes.
This commit is contained in:
Vadim Zeitlin 2021-12-07 16:16:36 +01:00
commit a40b7b6d1c

View file

@ -504,9 +504,7 @@ struct cxx_wrappers
} }
// Return the type description for the given parameter of the function. // Return the type description for the given parameter of the function.
cxx_ptype_desc lookup_cxx_parm_type(Node* n, Parm* p) { bool lookup_cxx_parm_type(cxx_ptype_desc& ptype_desc, Node* n, Parm* p) {
cxx_ptype_desc ptype_desc;
// Ensure our own replaceSpecialVariables() is used for $typemap() expansion. // Ensure our own replaceSpecialVariables() is used for $typemap() expansion.
temp_ptr_setter<cxx_ptype_desc*> set(&ptype_desc_, &ptype_desc); temp_ptr_setter<cxx_ptype_desc*> set(&ptype_desc_, &ptype_desc);
@ -517,17 +515,24 @@ struct cxx_wrappers
type = Swig_typemap_lookup("ctype", p, "", NULL); type = Swig_typemap_lookup("ctype", p, "", NULL);
} }
if (type) { if (!type) {
ptype_desc.set_type(type); Swig_warning(WARN_C_TYPEMAP_CTYPE_UNDEF, Getfile(p), Getline(p),
do_resolve_type(n, Getattr(p, "type"), ptype_desc.type(), &ptype_desc, NULL); "No ctype typemap defined for the parameter \"%s\" of %s\n",
Getattr(p, "name"),
Getattr(n, "sym:name")
);
return false;
} }
ptype_desc.set_type(type);
do_resolve_type(n, Getattr(p, "type"), ptype_desc.type(), &ptype_desc, NULL);
if (use_cxxin) { if (use_cxxin) {
if (String* in_tm = Getattr(p, "tmap:cxxin")) if (String* in_tm = Getattr(p, "tmap:cxxin"))
ptype_desc.apply_in_typemap(Copy(in_tm)); ptype_desc.apply_in_typemap(Copy(in_tm));
} }
return ptype_desc; return true;
} }
@ -969,15 +974,9 @@ public:
for (; p; p = nextSibling(p)) { for (; p; p = nextSibling(p)) {
String* const name = Getattr(p, "lname"); String* const name = Getattr(p, "lname");
const cxx_ptype_desc ptype_desc = cxx_wrappers_.lookup_cxx_parm_type(n, p); cxx_ptype_desc ptype_desc;
if (!ptype_desc.type()) { if (!cxx_wrappers_.lookup_cxx_parm_type(ptype_desc, n, p))
Swig_warning(WARN_C_TYPEMAP_CTYPE_UNDEF, Getfile(p), Getline(p),
"No ctype typemap defined for the parameter \"%s\" of %s\n",
name,
Getattr(n, "sym:name")
);
return; return;
}
if (Len(parms_cxx)) if (Len(parms_cxx))
Append(parms_cxx, ", "); Append(parms_cxx, ", ");