previous commit incomplete, this one really fix derive_nested.i

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6515 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-10-26 01:15:10 +00:00
commit a61421ac2b

View file

@ -3558,26 +3558,53 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line;
}
}
}
/* An unnamed nested structure definition */
| storage_class cpptype idcolon inherit LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}');
/*****
This fix derived_nested.i, but it introduces an extra shift/reduce,
should we keep it?
*****/
| storage_class cpptype ID COLON base_list LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}');
} nested_decl SEMI {
$$ = 0;
if (cplus_mode == CPLUS_PUBLIC) {
if (strcmp($2,"class") == 0) {
Swig_warning(WARN_PARSE_NESTED_CLASS,cparse_file, cparse_line,"Nested class not currently supported (ignored)\n");
/* Generate some code for a new class */
} else if ($7.id) {
} else if ($8.id) {
/* Generate some code for a new class */
Nested *n = (Nested *) malloc(sizeof(Nested));
n->code = NewString("");
Printv(n->code, "typedef ", $2, " " ,
Char(scanner_ccode), " $classname_", $7.id, ";\n",NIL);
n->name = Swig_copy_string($7.id);
Char(scanner_ccode), " $classname_", $8.id, ";\n",NIL);
n->name = Swig_copy_string($8.id);
n->line = cparse_start_line;
n->type = NewString("");
n->kind = $2;
SwigType_push(n->type,$7.type);
SwigType_push(n->type,$8.type);
n->next = 0;
add_nested(n);
} else {
Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", $2);
}
}
}
| storage_class cpptype LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}');
} nested_decl SEMI {
$$ = 0;
if (cplus_mode == CPLUS_PUBLIC) {
if (strcmp($2,"class") == 0) {
Swig_warning(WARN_PARSE_NESTED_CLASS,cparse_file, cparse_line,"Nested class not currently supported (ignored)\n");
/* Generate some code for a new class */
} else if ($5.id) {
/* Generate some code for a new class */
Nested *n = (Nested *) malloc(sizeof(Nested));
n->code = NewString("");
Printv(n->code, "typedef ", $2, " " ,
Char(scanner_ccode), " $classname_", $5.id, ";\n",NIL);
n->name = Swig_copy_string($5.id);
n->line = cparse_start_line;
n->type = NewString("");
n->kind = $2;
SwigType_push(n->type,$5.type);
n->next = 0;
add_nested(n);
} else {