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 */
|
/* please leave 740-759 free for Python */
|
||||||
|
|
||||||
#define WARN_C_TYPEMAP_CTYPE_UNDEF 760
|
#define WARN_C_TYPEMAP_CTYPE_UNDEF 760
|
||||||
|
#define WARN_C_UNSUPPORTTED 779
|
||||||
|
|
||||||
/* please leave 760-779 free for C */
|
/* please leave 760-779 free for C */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1273,9 +1273,16 @@ ready:
|
||||||
for ( Node* node = firstChild(n); node; node = nextSibling(node)) {
|
for ( Node* node = firstChild(n); node; node = nextSibling(node)) {
|
||||||
String* const ntype = nodeType(node);
|
String* const ntype = nodeType(node);
|
||||||
if (Cmp(ntype, "cdecl") == 0) {
|
if (Cmp(ntype, "cdecl") == 0) {
|
||||||
String* const var_decl = make_c_var_decl(node);
|
SwigType* t = NewString(Getattr(node, "type"));
|
||||||
Printv(out, cindent, var_decl, ";\n", NIL);
|
SwigType_push(t, Getattr(node, "decl"));
|
||||||
Delete(var_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) {
|
} else if (Cmp(ntype, "enum") == 0) {
|
||||||
// This goes directly into f_wrappers_types, before this struct declaration.
|
// This goes directly into f_wrappers_types, before this struct declaration.
|
||||||
emit_one(node);
|
emit_one(node);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue