Fixed a struct related bug. Reported by Frank Buss and Kilian.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8384 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Surendra Singhi 2006-01-12 05:42:24 +00:00
commit 695b448cd4

View file

@ -440,6 +440,12 @@ int CFFI :: enumDeclaration(Node *n) {
// Includes structs // Includes structs
void CFFI :: emit_struct_union(Node *n, bool un=false) { void CFFI :: emit_struct_union(Node *n, bool un=false) {
#ifdef CFFI_DEBUG
Printf(stderr, "struct/union %s\n", Getattr(n, "name"));
Printf(stderr, "struct/union %s\n and %s",
Getattr(n,"kind"),Getattr(n,"sym:name"));
#endif
String *name=Getattr(n, "sym:name"); String *name=Getattr(n, "sym:name");
String *kind = Getattr(n,"kind"); String *kind = Getattr(n,"kind");
@ -454,19 +460,24 @@ void CFFI :: emit_struct_union(Node *n, bool un=false) {
Printf(f_cl,"\n(defcunion %s",name); Printf(f_cl,"\n(defcunion %s",name);
else else
Printf(f_cl,"\n(defcstruct %s",name); Printf(f_cl,"\n(defcstruct %s",name);
for (Node *c=firstChild(n); c; c=nextSibling(c)) { for (Node *c=firstChild(n); c; c=nextSibling(c)) {
#ifdef CFFI_DEBUG
Printf(stderr, "%d struct/union %s\n", Getattr(c, "name"));
Printf(stderr, "%d struct/union %s and %s \n",
Getattr(c,"kind"),Getattr(c,"sym:name"));
#endif
if (Strcmp(nodeType(c), "cdecl")) { if (Strcmp(nodeType(c), "cdecl")) {
Printf(stderr, "Structure %s has a slot that we can't deal with.\n", //C declaration ignore
name); // Printf(stderr, "Structure %s has a slot that we can't deal with.\n",
Printf(stderr, "nodeType: %s, name: %s, type: %s\n", // name);
nodeType(c), // Printf(stderr, "nodeType: %s, name: %s, type: %s\n",
Getattr(c, "name"), // nodeType(c),
Getattr(c, "type")); // Getattr(c, "name"),
SWIG_exit(EXIT_FAILURE); // Getattr(c, "type"));
} // SWIG_exit(EXIT_FAILURE);
}
else{
String *temp=Copy(Getattr(c,"decl")); String *temp=Copy(Getattr(c,"decl"));
Append(temp,Getattr(c,"type")); //appending type to the end, otherwise wrong type Append(temp,Getattr(c,"type")); //appending type to the end, otherwise wrong type
String *lisp_type=Swig_typemap_lookup_new("cin",c, "",0); String *lisp_type=Swig_typemap_lookup_new("cin",c, "",0);
@ -479,6 +490,7 @@ void CFFI :: emit_struct_union(Node *n, bool un=false) {
lisp_type); lisp_type);
Delete(lisp_type); Delete(lisp_type);
}
} }
Printf(f_cl, ")\n"); Printf(f_cl, ")\n");