Don't emit functions added by %extend into C structs
This is never going to work and just results in generating uncompilable code. In principle, we could either generate wrappers for these functions while still handling the struct as a plain C struct, or switch to generating class-like wrappers for it if it's %extended with any functions, but for now just ignore them as this is the simplest thing to do. Incidentally, this makes the default_args_c test pass again now, after the last merge with master pulled in such %extend directives into it.
This commit is contained in:
parent
690bf8e020
commit
b0d99a1cc3
2 changed files with 11 additions and 3 deletions
|
|
@ -256,6 +256,7 @@
|
|||
/* please leave 740-759 free for Python */
|
||||
|
||||
#define WARN_C_TYPEMAP_CTYPE_UNDEF 760
|
||||
#define WARN_C_UNSUPPORTTED 779
|
||||
|
||||
/* please leave 760-779 free for C */
|
||||
|
||||
|
|
|
|||
|
|
@ -1273,9 +1273,16 @@ ready:
|
|||
for ( Node* node = firstChild(n); node; node = nextSibling(node)) {
|
||||
String* const ntype = nodeType(node);
|
||||
if (Cmp(ntype, "cdecl") == 0) {
|
||||
String* const var_decl = make_c_var_decl(node);
|
||||
Printv(out, cindent, var_decl, ";\n", NIL);
|
||||
Delete(var_decl);
|
||||
SwigType* t = NewString(Getattr(node, "type"));
|
||||
SwigType_push(t, Getattr(node, "decl"));
|
||||
t = SwigType_typedef_resolve_all(t);
|
||||
if (SwigType_isfunction(t)) {
|
||||
Swig_warning(WARN_C_UNSUPPORTTED, input_file, line_number, "Extending C struct with %s is not currently supported, ignored.\n", SwigType_str(t, 0));
|
||||
} else {
|
||||
String* const var_decl = make_c_var_decl(node);
|
||||
Printv(out, cindent, var_decl, ";\n", NIL);
|
||||
Delete(var_decl);
|
||||
}
|
||||
} else if (Cmp(ntype, "enum") == 0) {
|
||||
// This goes directly into f_wrappers_types, before this struct declaration.
|
||||
emit_one(node);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue