Treat a nested class definition as a forward declaration rather

than ignoring it completely, so that we generate correct code for
passing opaque pointers to the nested class (fixes SF bug #909387).


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9306 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2006-09-20 08:04:24 +00:00
commit fe4a39819c
2 changed files with 30 additions and 19 deletions

View file

@ -1,6 +1,11 @@
Version 1.3.30 (in progress) Version 1.3.30 (in progress)
============================ ============================
09/20/2006: olly
[ALL] Treat a nested class definition as a forward declaration rather
than ignoring it completely, so that we generate correct code for
passing opaque pointers to the nested class (fixes SF bug #909387).
09/20/2006: olly 09/20/2006: olly
*** POTENTIAL INCOMPATIBILITY *** *** POTENTIAL INCOMPATIBILITY ***
[php] Overload resolution now works. However to allow this, SWIG [php] Overload resolution now works. However to allow this, SWIG

View file

@ -4148,27 +4148,33 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line
} nested_decl SEMI { } nested_decl SEMI {
$$ = 0; $$ = 0;
if (cplus_mode == CPLUS_PUBLIC) { if (cplus_mode == CPLUS_PUBLIC) {
if ($6.id) { if ($6.id && strcmp($2, "class") != 0) {
if (strcmp($2,"class") == 0) { Nested *n = (Nested *) malloc(sizeof(Nested));
Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested classes not currently supported (ignored).\n"); n->code = NewStringEmpty();
/* Generate some code for a new class */ Printv(n->code, "typedef ", $2, " ",
} else { Char(scanner_ccode), " $classname_", $6.id, ";\n", NIL);
Nested *n = (Nested *) malloc(sizeof(Nested));
n->code = NewStringEmpty();
Printv(n->code, "typedef ", $2, " ",
Char(scanner_ccode), " $classname_", $6.id, ";\n", NIL);
n->name = Swig_copy_string($6.id); n->name = Swig_copy_string($6.id);
n->line = cparse_start_line; n->line = cparse_start_line;
n->type = NewStringEmpty(); n->type = NewStringEmpty();
n->kind = $2; n->kind = $2;
n->unnamed = 0; n->unnamed = 0;
SwigType_push(n->type, $6.type); SwigType_push(n->type, $6.type);
n->next = 0; n->next = 0;
add_nested(n); add_nested(n);
}
} else { } else {
Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", $2); Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", $2);
if (strcmp($2, "class") == 0) {
/* For now, just treat the nested class as a forward
* declaration (SF bug #909387). */
$$ = new_node("classforward");
Setfile($$,cparse_file);
Setline($$,cparse_line);
Setattr($$,k_kind,$2);
Setattr($$,k_name,$3);
Setattr($$,k_symweak, "1");
add_symbols($$);
}
} }
} }
} }