Nested struct pretty print rewrite and fix. The wrappers for C nested structs are now generated in the same order as declared in the parsed code.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11755 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
aa6712e3f2
commit
43b6292681
2 changed files with 20 additions and 31 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
Version 1.3.41 (in progress)
|
Version 1.3.41 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2009-11-18: wsfulton
|
||||||
|
The wrappers for C nested structs are now generated in the same order as declared
|
||||||
|
in the parsed code.
|
||||||
|
|
||||||
2009-11-18: wsfulton
|
2009-11-18: wsfulton
|
||||||
Fix #491476 - multiple declarations of nested structs, for example:
|
Fix #491476 - multiple declarations of nested structs, for example:
|
||||||
struct Outer {
|
struct Outer {
|
||||||
|
|
|
||||||
|
|
@ -1021,7 +1021,6 @@ static void add_nested(Nested *n) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, String *struct_code) {
|
static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, String *struct_code) {
|
||||||
String *new_struct_decl;
|
|
||||||
String *name;
|
String *name;
|
||||||
String *decl;
|
String *decl;
|
||||||
|
|
||||||
|
|
@ -1033,11 +1032,7 @@ static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, Strin
|
||||||
decl = Getattr(cpp_opt_declarators, "decl");
|
decl = Getattr(cpp_opt_declarators, "decl");
|
||||||
|
|
||||||
n->code = NewStringEmpty();
|
n->code = NewStringEmpty();
|
||||||
new_struct_decl = NewStringEmpty();
|
Printv(n->code, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL);
|
||||||
Printv(new_struct_decl, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL);
|
|
||||||
Wrapper_pretty_print(new_struct_decl, n->code);
|
|
||||||
Delete(new_struct_decl);
|
|
||||||
|
|
||||||
n->name = Swig_copy_string(Char(name));
|
n->name = Swig_copy_string(Char(name));
|
||||||
n->line = cparse_start_line;
|
n->line = cparse_start_line;
|
||||||
n->type = NewStringEmpty();
|
n->type = NewStringEmpty();
|
||||||
|
|
@ -1056,12 +1051,8 @@ static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, Strin
|
||||||
name = Getattr(p, "name");
|
name = Getattr(p, "name");
|
||||||
decl = Getattr(p, "decl");
|
decl = Getattr(p, "decl");
|
||||||
|
|
||||||
new_struct_decl = NewStringEmpty();
|
|
||||||
nn->code = NewStringEmpty();
|
nn->code = NewStringEmpty();
|
||||||
Printv(new_struct_decl, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL);
|
Printv(nn->code, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL);
|
||||||
Wrapper_pretty_print(new_struct_decl, n->code);
|
|
||||||
Delete(new_struct_decl);
|
|
||||||
|
|
||||||
nn->name = Swig_copy_string(Char(name));
|
nn->name = Swig_copy_string(Char(name));
|
||||||
nn->line = cparse_start_line;
|
nn->line = cparse_start_line;
|
||||||
nn->type = NewStringEmpty();
|
nn->type = NewStringEmpty();
|
||||||
|
|
@ -1176,6 +1167,7 @@ static void strip_comments(char *string) {
|
||||||
static Node *dump_nested(const char *parent) {
|
static Node *dump_nested(const char *parent) {
|
||||||
Nested *n,*n1;
|
Nested *n,*n1;
|
||||||
Node *ret = 0;
|
Node *ret = 0;
|
||||||
|
Node *last = 0;
|
||||||
n = nested_list;
|
n = nested_list;
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
nested_list = 0;
|
nested_list = 0;
|
||||||
|
|
@ -1205,20 +1197,12 @@ static Node *dump_nested(const char *parent) {
|
||||||
|
|
||||||
add_symbols(retx);
|
add_symbols(retx);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
set_nextSibling(retx,ret);
|
set_nextSibling(last, retx);
|
||||||
Delete(ret);
|
Delete(retx);
|
||||||
|
} else {
|
||||||
|
ret = retx;
|
||||||
}
|
}
|
||||||
ret = retx;
|
last = retx;
|
||||||
|
|
||||||
/* Insert a forward class declaration */
|
|
||||||
/* Disabled: [ 597599 ] union in class: incorrect scope
|
|
||||||
retx = new_node("classforward");
|
|
||||||
Setattr(retx,"kind",n->kind);
|
|
||||||
Setattr(retx,"name",Copy(n->type));
|
|
||||||
Setattr(retx,"sym:name", make_name(n->type,0));
|
|
||||||
set_nextSibling(retx,ret);
|
|
||||||
ret = retx;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Strip comments - further code may break in presence of comments. */
|
/* Strip comments - further code may break in presence of comments. */
|
||||||
strip_comments(Char(n->code));
|
strip_comments(Char(n->code));
|
||||||
|
|
@ -1267,17 +1251,18 @@ static Node *dump_nested(const char *parent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Node *head = new_node("insert");
|
Node *newnode = new_node("insert");
|
||||||
String *code = NewStringf("\n%s\n",n->code);
|
String *code = NewStringEmpty();
|
||||||
Setattr(head,"code", code);
|
Wrapper_pretty_print(n->code, code);
|
||||||
|
Setattr(newnode,"code", code);
|
||||||
Delete(code);
|
Delete(code);
|
||||||
set_nextSibling(head,ret);
|
set_nextSibling(last, newnode);
|
||||||
Delete(ret);
|
Delete(newnode);
|
||||||
ret = head;
|
last = newnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dump the code to the scanner */
|
/* Dump the code to the scanner */
|
||||||
start_inline(Char(n->code),n->line);
|
start_inline(Char(Getattr(last, "code")),n->line);
|
||||||
|
|
||||||
n1 = n->next;
|
n1 = n->next;
|
||||||
Delete(n->code);
|
Delete(n->code);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue