Don't try to export variables in namespace scope directly
The generated code, which used C++ scope operator "::" in a C header, didn't compile and couldn't work anyhow. Just use the accessor functions for not really global variables.
This commit is contained in:
parent
e39265ba13
commit
2ec9d9da6e
2 changed files with 11 additions and 6 deletions
|
|
@ -57,7 +57,6 @@ FAILING_CPP_TESTS := \
|
||||||
class_ignore \
|
class_ignore \
|
||||||
class_scope_weird \
|
class_scope_weird \
|
||||||
constant_pointers \
|
constant_pointers \
|
||||||
cpp_namespace \
|
|
||||||
cpp_typedef \
|
cpp_typedef \
|
||||||
c_backend_cpp_natural_std_string \
|
c_backend_cpp_natural_std_string \
|
||||||
c_backend_cpp_exception \
|
c_backend_cpp_exception \
|
||||||
|
|
|
||||||
|
|
@ -458,11 +458,17 @@ public:
|
||||||
* ------------------------------------------------------------------------ */
|
* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
virtual int globalvariableHandler(Node *n) {
|
virtual int globalvariableHandler(Node *n) {
|
||||||
// If we can export the variable directly, do it, this will be more convenient to use from C code than accessor functions.
|
// We can't export variables defined inside namespaces to C directly, whatever their type.
|
||||||
if (String* const var_decl = make_c_var_decl(n)) {
|
String* const scope = Swig_scopename_prefix(Getattr(n, "name"));
|
||||||
Printv(f_wrappers_decl, "SWIGIMPORT ", var_decl, ";\n\n", NIL);
|
if (!scope) {
|
||||||
Delete(var_decl);
|
// If we can export the variable directly, do it, this will be more convenient to use from C code than accessor functions.
|
||||||
return SWIG_OK;
|
if (String* const var_decl = make_c_var_decl(n)) {
|
||||||
|
Printv(f_wrappers_decl, "SWIGIMPORT ", var_decl, ";\n\n", NIL);
|
||||||
|
Delete(var_decl);
|
||||||
|
return SWIG_OK;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Delete(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, e.g. if it's of a C++-only type, or a reference, generate accessor functions for it.
|
// Otherwise, e.g. if it's of a C++-only type, or a reference, generate accessor functions for it.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue