Generate C++ wrappers for the global functions too
This ensures that global functions can also use C++ classes, enums etc for their parameters and return types. C++ wrappers for a couple of tests had to be disabled, but this is not really a regression as wrapping global functions just made apparent problems that were not visible before because the corresponding wrappers were not created at all.
This commit is contained in:
parent
1fd4c647b8
commit
86dbf6bcb5
2 changed files with 27 additions and 0 deletions
|
|
@ -112,6 +112,8 @@ director_frob.cpptest: SWIG_NOCXX = -nocxx # Conversion operator return type.
|
||||||
extend_template_method.cpptest: SWIG_NOCXX = -nocxx # Wrong form of template function name.
|
extend_template_method.cpptest: SWIG_NOCXX = -nocxx # Wrong form of template function name.
|
||||||
features.cpptest: SWIG_NOCXX = -nocxx # Conversion operator return type not handled specially.
|
features.cpptest: SWIG_NOCXX = -nocxx # Conversion operator return type not handled specially.
|
||||||
global_namespace.cpptest: SWIG_NOCXX = -nocxx # Const const reference type.
|
global_namespace.cpptest: SWIG_NOCXX = -nocxx # Const const reference type.
|
||||||
|
li_carrays_cpp.cpptest: SWIG_NOCXX = -nocxx # Arrays not really supported currently.
|
||||||
|
li_cdata_cpp.cpptest: SWIG_NOCXX = -nocxx # No support for multiarg typemaps required here.
|
||||||
member_template.cpptest: SWIG_NOCXX = -nocxx # Wrong form of template function name.
|
member_template.cpptest: SWIG_NOCXX = -nocxx # Wrong form of template function name.
|
||||||
multiple_inheritance_abstract.cpptest: SWIG_NOCXX = -nocxx # Multiple inheritance not supported.
|
multiple_inheritance_abstract.cpptest: SWIG_NOCXX = -nocxx # Multiple inheritance not supported.
|
||||||
multiple_inheritance_interfaces.cpptest: SWIG_NOCXX = -nocxx
|
multiple_inheritance_interfaces.cpptest: SWIG_NOCXX = -nocxx
|
||||||
|
|
@ -133,6 +135,7 @@ return_const_value.cpptest: SWIG_NOCXX = -nocxx
|
||||||
smart_pointer_member.cpptest: SWIG_NOCXX = -nocxx
|
smart_pointer_member.cpptest: SWIG_NOCXX = -nocxx
|
||||||
smart_pointer_template_const_overload.cpptest: SWIG_NOCXX = -nocxx
|
smart_pointer_template_const_overload.cpptest: SWIG_NOCXX = -nocxx
|
||||||
smart_pointer_templatemethods.cpptest: SWIG_NOCXX = -nocxx # Wrong form of template function name.
|
smart_pointer_templatemethods.cpptest: SWIG_NOCXX = -nocxx # Wrong form of template function name.
|
||||||
|
struct_initialization_cpp.cpptest: SWIG_NOCXX = -nocxx # Arrays in initialization not supported.
|
||||||
template_const_ref.cpptest: SWIG_NOCXX = -nocxx
|
template_const_ref.cpptest: SWIG_NOCXX = -nocxx
|
||||||
template_default_arg_overloaded.cpptest: SWIG_NOCXX = -nocxx
|
template_default_arg_overloaded.cpptest: SWIG_NOCXX = -nocxx
|
||||||
template_inherit_abstract.cpptest: SWIG_NOCXX = -nocxx
|
template_inherit_abstract.cpptest: SWIG_NOCXX = -nocxx
|
||||||
|
|
@ -141,6 +144,7 @@ template_nested.cpptest: SWIG_NOCXX = -nocxx
|
||||||
template_nested_flat.cpptest: SWIG_NOCXX = -nocxx
|
template_nested_flat.cpptest: SWIG_NOCXX = -nocxx
|
||||||
template_qualifier.cpptest: SWIG_NOCXX = -nocxx
|
template_qualifier.cpptest: SWIG_NOCXX = -nocxx
|
||||||
template_static.cpptest: SWIG_NOCXX = -nocxx
|
template_static.cpptest: SWIG_NOCXX = -nocxx
|
||||||
|
typemap_array_qualifiers.cpptest: SWIG_NOCXX = -nocxx # Arrays not supported.
|
||||||
valuewrapper_const.cpptest: SWIG_NOCXX = -nocxx # Misplaced const.
|
valuewrapper_const.cpptest: SWIG_NOCXX = -nocxx # Misplaced const.
|
||||||
|
|
||||||
# Avoid conflict with the C++ keyword for some tests.
|
# Avoid conflict with the C++ keyword for some tests.
|
||||||
|
|
|
||||||
|
|
@ -920,6 +920,8 @@ public:
|
||||||
bool can_wrap() const { return func_node != NULL; }
|
bool can_wrap() const { return func_node != NULL; }
|
||||||
|
|
||||||
// Emit just the function body, including the braces around it.
|
// Emit just the function body, including the braces around it.
|
||||||
|
//
|
||||||
|
// This helper is used both by our emit() and emit_member_function().
|
||||||
void emit_body(String* wparms) {
|
void emit_body(String* wparms) {
|
||||||
String* const wname = Getattr(func_node, "wrap:name");
|
String* const wname = Getattr(func_node, "wrap:name");
|
||||||
|
|
||||||
|
|
@ -947,6 +949,23 @@ public:
|
||||||
Append(cxx_wrappers_.sect_impls, "}\n");
|
Append(cxx_wrappers_.sect_impls, "}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do emit the function wrapper.
|
||||||
|
void emit() {
|
||||||
|
// The wrapper function name should be sym:name, but we change it to include the namespace prefix in our own globalvariableHandler(), so now we have to undo
|
||||||
|
// this by using the value saved there, if available. This is definitely clumsy and it would be better to avoid it, but this would probably need to be done
|
||||||
|
// by separating C and C++ wrapper generation in two different passes and so would require significantly more changes than this hack.
|
||||||
|
String* name = Getattr(func_node, "c:globalvariableHandler:sym:name");
|
||||||
|
if (!name)
|
||||||
|
name = Getattr(func_node, "sym:name");
|
||||||
|
|
||||||
|
Printv(cxx_wrappers_.sect_impls,
|
||||||
|
"inline ", rtype_desc.type(), " ", name, "(", parms_cxx.get(), ") ",
|
||||||
|
NIL
|
||||||
|
);
|
||||||
|
|
||||||
|
emit_body(parms_call);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cxx_wrappers& cxx_wrappers_;
|
cxx_wrappers& cxx_wrappers_;
|
||||||
Node* func_node;
|
Node* func_node;
|
||||||
|
|
@ -2496,6 +2515,10 @@ public:
|
||||||
|
|
||||||
if (cxx_class_wrapper_) {
|
if (cxx_class_wrapper_) {
|
||||||
cxx_class_wrapper_->emit_member_function(n);
|
cxx_class_wrapper_->emit_member_function(n);
|
||||||
|
} else {
|
||||||
|
cxx_function_wrapper w(cxx_wrappers_, n, Getattr(n, "parms"));
|
||||||
|
if (w.can_wrap())
|
||||||
|
w.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue