Removed a bug which was not allowing code for unions to be generated.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8553 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Surendra Singhi 2006-01-25 15:04:24 +00:00
commit c09e55e409

View file

@ -449,7 +449,7 @@ void CFFI :: emit_struct_union(Node *n, bool un=false) {
String *name=Getattr(n, "sym:name"); String *name=Getattr(n, "sym:name");
String *kind = Getattr(n,"kind"); String *kind = Getattr(n,"kind");
if (Strcmp(kind, "struct")) { if (Strcmp(kind, "struct")!=0 && Strcmp(kind, "union")!=0) {
Printf(stderr, "Don't know how to deal with %s kind of class yet.\n", Printf(stderr, "Don't know how to deal with %s kind of class yet.\n",
kind); kind);
Printf(stderr, " (name: %s)\n", name); Printf(stderr, " (name: %s)\n", name);
@ -460,10 +460,11 @@ 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 #ifdef CFFI_DEBUG
Printf(stderr, "%d struct/union %s\n", Getattr(c, "name")); Printf(stderr, "struct/union %s\n", Getattr(c, "name"));
Printf(stderr, "%d struct/union %s and %s \n", Printf(stderr, "struct/union %s and %s \n",
Getattr(c,"kind"),Getattr(c,"sym:name")); Getattr(c,"kind"),Getattr(c,"sym:name"));
#endif #endif
@ -478,23 +479,18 @@ void CFFI :: emit_struct_union(Node *n, bool un=false) {
// SWIG_exit(EXIT_FAILURE); // SWIG_exit(EXIT_FAILURE);
} }
else{ else{
// String *temp=Copy(Getattr(c,"decl"));
// Append(temp,Getattr(c,"type")); //appending type to the end, otherwise wrong type
// String *lisp_type=Swig_typemap_lookup_new("cin",c, "",0);
// Delete(temp);
SwigType *childType=NewStringf("%s%s", Getattr(c,"decl"), SwigType *childType=NewStringf("%s%s", Getattr(c,"decl"),
Getattr(c,"type")); Getattr(c,"type"));
Hash *typemap = Swig_typemap_search("cin", childType,"", 0); Hash *typemap = Swig_typemap_search("cin", childType,"", 0);
String *typespec = NewString(""); String *typespec = NewString("");
if (typemap) { if (typemap) {
typespec=Getattr(typemap, "code"); typespec = NewString(Getattr(typemap, "code"));
} }
String *slot_name = Getattr(c, "sym:name"); String *slot_name = Getattr(c, "sym:name");
Printf(f_cl, "\n\t(%s %s)", slot_name, typespec); Printf(f_cl, "\n\t(%s %s)", slot_name, typespec);
Delete(slot_name);
Delete(typespec); Delete(typespec);
} }
} }