Major refactoring of DOH List/Hash iterators. See CHANGES

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5101 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2003-09-11 20:26:57 +00:00
commit 4cf4dad108
35 changed files with 657 additions and 636 deletions

View file

@ -41,8 +41,10 @@ class Browser : public Dispatcher {
if (!Getmeta(obj,"visible")) return;
String *os = NewString("");
String *k;
k = Firstkey(obj);
while (k) {
Iterator ki;
ki = First(obj);
while (ki.key) {
k = ki.key;
if ((Cmp(k,"nodeType") == 0) || (Cmp(k,"firstChild") == 0) || (Cmp(k,"lastChild") == 0) ||
(Cmp(k,"parentNode") == 0) || (Cmp(k,"nextSibling") == 0) ||
(Cmp(k,"previousSibling") == 0) || (*(Char(k)) == '$')) {
@ -71,7 +73,7 @@ class Browser : public Dispatcher {
Printf(os,"<a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj,k), k, Getattr(obj,k));
}
}
k = Nextkey(obj);
ki = Next(ki);
}
Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));
Delete(os);
@ -241,10 +243,12 @@ void raw_data(FILE *out, Node *obj) {
if (!obj) return;
if (DohIsMapping(obj)) {
String *k;
Iterator ki;
String *os = NewString("");
Printf(os,"Hash {\n");
k = Firstkey(obj);
while (k) {
ki = First(obj);
while (ki.key) {
k = ki.key;
DOH *o;
const char *trunc = "";
if (DohIsString(Getattr(obj,k))) {
@ -258,7 +262,7 @@ void raw_data(FILE *out, Node *obj) {
} else {
Printf(os," <a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj,k), k, Getattr(obj,k));
}
k = Nextkey(obj);
ki = Next(ki);
}
Printf(os,"}\n");
Printf(out,"<FONT color=\"#660000\"><pre>\n%s</pre></FONT>\n", Char(os));

View file

@ -1369,18 +1369,18 @@ CHICKEN::classHandler(Node *n)
String *base_class = NewString("<");
List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist);
while (base) {
String *bname = Copy(Getattr(base, "chicken:proxy"));
Iterator base = First(baselist);
while (base.item) {
String *bname = Copy(Getattr(base.item, "chicken:proxy"));
if (!bname) {
base = Nextitem(baselist);
base = Next(base);
continue;
}
namify(bname);
Printv(base_class,bname,NIL);
Delete(bname);
base = Nextitem(baselist);
if (base) {
base = Next(base);
if (base.item) {
Printf(base_class, "> <");
}
}
@ -1879,12 +1879,12 @@ CHICKEN::chickenCode(String *code, const String *indent) {
List *clist = DohSplit(temp,'\n',-1);
Delete(temp);
int initial = 0;
String *s;
Iterator s;
/* Get the initial indentation */
for (s = Firstitem(clist); s; s = Nextitem(clist)) {
if (Len(s)) {
char *c = Char(s);
for (s = First(clist); s.item; s = Next(s)) {
if (Len(s.item)) {
char *c = Char(s.item);
while (*c) {
if (!isspace(*c)) break;
initial++;
@ -1896,15 +1896,15 @@ CHICKEN::chickenCode(String *code, const String *indent) {
}
}
}
while (s) {
if (Len(s) > initial) {
char *c = Char(s);
while (s.item) {
if (Len(s.item) > initial) {
char *c = Char(s.item);
c += initial;
Printv(out,indent,c,"\n",NIL);
} else {
Printv(out,"\n",NIL);
}
s = Nextitem(clist);
s = Next(s);
}
Delete(clist);
return out;
@ -1939,11 +1939,11 @@ CHICKEN::recurseSearch(const char *typemap, char *argname, Node *n)
/* recurse through base classes */
List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist);
while (base) {
tm = recurseSearch(typemap, argname, base);
Iterator base = First(baselist);
while (base.item) {
tm = recurseSearch(typemap, argname, base.item);
if (tm) break;
base = Nextitem(baselist);
base = Next(base);
}
}
return tm;

View file

@ -261,7 +261,7 @@ int Contracts::InheritAssertAppend(Node *n, Node *bases) {
}
int Contracts::AssertModify(Node *n, int flag) {
String *str_assert, *expr, *tag_sync;
String *str_assert, *expr = 0, *tag_sync;
List *list_assert;
if (flag == 1) { /* preassert */
@ -286,7 +286,10 @@ int Contracts::AssertModify(Node *n, int flag) {
/* build up new assertion */
str_assert = NewString("");
for (expr = Firstitem(list_assert); expr; expr = Nextitem(list_assert)) {
Iterator ei;
for (ei = First(list_assert); ei.item; ei = Next(ei)) {
expr = ei.item;
if (Len(expr)) {
/* All sync staff are not complete and only experimental */
if (Strstr(expr, SWIG_BEFORE)) { /* before sync assertion */
@ -324,7 +327,6 @@ int Contracts::AssertModify(Node *n, int flag) {
Delete(str_assert);
Delete(list_assert);
Delete(expr);
return SWIG_OK;
}

View file

@ -338,8 +338,8 @@ class CSHARP : public Language {
Printf(f_wrappers,"#endif\n");
// Output a C# type wrapper class for each SWIG type
for (String *swig_type = Firstkey(swig_types_hash); swig_type; swig_type = Nextkey(swig_types_hash)) {
emitTypeWrapperClass(swig_type, Getattr(swig_types_hash, swig_type));
for (Iterator swig_type = First(swig_types_hash); swig_type.key; swig_type = Next(swig_type)) {
emitTypeWrapperClass(swig_type.key, swig_type.item);
}
Delete(swig_types_hash); swig_types_hash = NULL;
@ -948,16 +948,16 @@ class CSHARP : public Language {
/* Deal with inheritance */
List *baselist = Getattr(n,"bases");
if (baselist) {
Node *base = Firstitem(baselist);
c_baseclassname = Getattr(base,"name");
Iterator base = First(baselist);
c_baseclassname = Getattr(base.item,"name");
baseclass = Copy(getProxyName(c_baseclassname));
if (baseclass){
c_baseclass = SwigType_namestr(Getattr(base,"name"));
c_baseclass = SwigType_namestr(Getattr(base.item,"name"));
}
base = Nextitem(baselist);
if (base) {
base = Next(base);
if (base.item) {
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number,
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#.\n", classDeclarationName, Getattr(base,"name"));
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#.\n", classDeclarationName, Getattr(base.item,"name"));
}
}
@ -1951,8 +1951,8 @@ class CSHARP : public Language {
// Add the exception classes to the node throws list, but don't duplicate if already in list
if (temp_classes_list && Len(temp_classes_list) > 0) {
for (String *cls = Firstitem(temp_classes_list); cls; cls = Nextitem(temp_classes_list)) {
String *exception_class = NewString(cls);
for (Iterator cls = First(temp_classes_list); cls.item; cls = Next(cls)) {
String *exception_class = NewString(cls.item);
Replaceall(exception_class," ",""); // remove spaces
Replaceall(exception_class,"\t",""); // remove tabs
if (Len(exception_class) > 0) {
@ -1962,8 +1962,8 @@ class CSHARP : public Language {
// Don't duplicate the C# exception class in the throws clause
bool found_flag = false;
for (String *item = Firstitem(throws_list); item; item = Nextitem(throws_list)) {
if (Strcmp(item, exception_class) == 0)
for (Iterator item = First(throws_list); item.item; item = Next(item)) {
if (Strcmp(item.item, exception_class) == 0)
found_flag = true;
}
if (!found_flag)
@ -1985,10 +1985,10 @@ class CSHARP : public Language {
// Add the throws clause into code
List *throws_list = Getattr(n,"csharp:throwslist");
if (throws_list) {
String *cls = Firstitem(throws_list);
Printf(code, " throws %s", cls);
while ( (cls = Nextitem(throws_list)) )
Printf(code, ", %s", cls);
Iterator cls = First(throws_list);
Printf(code, " throws %s", cls.item);
while ( (cls = Next(cls)).item)
Printf(code, ", %s", cls.item);
}
}

View file

@ -518,8 +518,8 @@ class JAVA : public Language {
Printf(f_wrappers,"#endif\n");
// Output a Java type wrapper class for each SWIG type
for (String *swig_type = Firstkey(swig_types_hash); swig_type; swig_type = Nextkey(swig_types_hash)) {
emitTypeWrapperClass(swig_type, Getattr(swig_types_hash, swig_type));
for (Iterator swig_type = First(swig_types_hash); swig_type.key; swig_type = Next(swig_type)) {
emitTypeWrapperClass(swig_type.key, swig_type.item);
}
/* Close all of the files */
@ -602,17 +602,18 @@ class JAVA : public Language {
UpcallData *udata;
String *methodno;
Hash *new_udata;
Iterator ui;
/* Do we know about this director class already? */
if ((udata = Getattr(dmethods_table, director_class)) != NULL)
return Getattr(udata, "methodoff");
/* Clearly not, so make sure we don't already know about the Java
method and field descriptor signature */
for (udata = Firstitem(dmethods_seq); udata != NULL; udata = Nextitem(dmethods_seq)) {
if (!Cmp(Getattr(udata, "method"), method) && !Cmp(Getattr(udata, "fdesc"), signature)) {
Setattr(dmethods_table, director_class, udata);
return Getattr(udata, "methodoff");
for (ui = First(dmethods_seq); ui.item; ui = Next(ui)) {
if (!Cmp(Getattr(ui.item, "method"), method) && !Cmp(Getattr(ui.item, "fdesc"), signature)) {
Setattr(dmethods_table, director_class, ui.item);
return Getattr(ui.item, "methodoff");
}
}
@ -1472,16 +1473,16 @@ class JAVA : public Language {
/* Deal with inheritance */
List *baselist = Getattr(n,"bases");
if (baselist) {
Node *base = Firstitem(baselist);
c_baseclassname = Getattr(base,"name");
Iterator base = First(baselist);
c_baseclassname = Getattr(base.item,"name");
baseclass = Copy(getProxyName(c_baseclassname));
if (baseclass){
c_baseclass = SwigType_namestr(Getattr(base,"name"));
c_baseclass = SwigType_namestr(Getattr(base.item,"name"));
}
base = Nextitem(baselist);
if (base) {
base = Next(base);
if (base.item) {
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number,
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", classDeclarationName, Getattr(base,"name"));
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", classDeclarationName, Getattr(base.item,"name"));
}
}
@ -2422,8 +2423,8 @@ class JAVA : public Language {
// Add the exception classes to the node throws list, but don't duplicate if already in list
if (temp_classes_list && Len(temp_classes_list) > 0) {
for (String *cls = Firstitem(temp_classes_list); cls; cls = Nextitem(temp_classes_list)) {
String *exception_class = NewString(cls);
for (Iterator cls = First(temp_classes_list); cls.item; cls = Next(cls)) {
String *exception_class = NewString(cls.item);
Replaceall(exception_class," ",""); // remove spaces
Replaceall(exception_class,"\t",""); // remove tabs
if (Len(exception_class) > 0) {
@ -2433,8 +2434,8 @@ class JAVA : public Language {
// Don't duplicate the Java exception class in the throws clause
bool found_flag = false;
for (String *item = Firstitem(throws_list); item; item = Nextitem(throws_list)) {
if (Strcmp(item, exception_class) == 0)
for (Iterator item = First(throws_list); item.item; item = Next(item)) {
if (Strcmp(item.item, exception_class) == 0)
found_flag = true;
}
if (!found_flag)
@ -2456,10 +2457,10 @@ class JAVA : public Language {
// Add the throws clause into code
List *throws_list = Getattr(n,"java:throwslist");
if (throws_list) {
String *cls = Firstitem(throws_list);
Printf(code, " throws %s", cls);
while ( (cls = Nextitem(throws_list)) )
Printf(code, ", %s", cls);
Iterator cls = First(throws_list);
Printf(code, " throws %s", cls.item);
while ( (cls = Next(cls)).item)
Printf(code, ", %s", cls.item);
}
}
@ -2506,6 +2507,7 @@ class JAVA : public Language {
Wrapper *w = NewWrapper();
String *jni_imclass_name = makeValidJniName(imclass_name);
UpcallData *udata;
Iterator ui;
Printf(f_runtime, "static jclass __SWIG_jclass_%s = NULL;\n", imclass_name);
Printf(f_runtime, "static jmethodID __SWIG_director_methids[%d];\n", n_dmethods);
@ -2517,11 +2519,11 @@ class JAVA : public Language {
Printf(w->code, " const char *signature;\n");
Printf(w->code, "} methods[%d] = {\n", n_dmethods);
udata = Firstitem(dmethods_seq);
while ( udata) {
Printf(w->code, " { \"%s\", \"%s\" }", Getattr(udata, "method"), Getattr(udata, "fdesc"));
udata = Nextitem(dmethods_seq);
if (udata)
ui = First(dmethods_seq);
while ( ui.item) {
Printf(w->code, " { \"%s\", \"%s\" }", Getattr(ui.item, "method"), Getattr(ui.item, "fdesc"));
ui = Next(ui);
if (ui.item)
Putc(',', w->code);
Putc('\n', w->code);
}

View file

@ -1392,9 +1392,9 @@ int Language::unrollVirtualMethods(Node *n,
// recurse through all base classes to build the vtable
List* bl = Getattr(n, "bases");
if (bl) {
Node* bi;
for (bi = Firstitem(bl); bi; bi = Nextitem(bl)) {
unrollVirtualMethods(bi, parent, vm, default_director, virtual_destructor);
Iterator bi;
for (bi = First(bl); bi.item; bi = Next(bi)) {
unrollVirtualMethods(bi.item, parent, vm, default_director, virtual_destructor);
}
}
// find the methods that need directors
@ -1503,9 +1503,10 @@ int Language::classDirectorConstructors(Node *n) {
int Language::classDirectorMethods(Node *n) {
Node *vtable = Getattr(n, "vtable");
Node *item;
String *key;
for (key = Firstkey(vtable); key != 0; key = Nextkey(vtable)) {
item = Getattr(vtable, key);
Iterator k;
for (k = First(vtable); k.key; k = Next(k)) {
item = k.item;
String *method = Getattr(item, "methodNode");
String *fqname = Getattr(item, "fqName");
if (classDirectorMethod(method, n, fqname) == SWIG_OK) {
@ -1656,9 +1657,9 @@ int Language::classHandler(Node *n) {
List *methods = Getattr(n,"allocate:smartpointer");
cplus_mode = CPLUS_PUBLIC;
SmartPointer = CWRAP_SMART_POINTER;
Node *c;
for (c = Firstitem(methods); c; c= Nextitem(methods)) {
emit_one(c);
Iterator c;
for (c = First(methods); c.item; c= Next(c)) {
emit_one(c.item);
}
SmartPointer = 0;
}

View file

@ -517,9 +517,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (Verbose) {
printf ("LibDir: %s\n", LibDir);
List *sp = Swig_search_path();
String *s;
for (s = Firstitem(sp); s; s = Nextitem(sp)) {
Printf(stdout," %s\n", s);
Iterator s;
for (s = First(sp); s.item; s = Next(s)) {
Printf(stdout," %s\n", s.item);
}
}
@ -648,9 +648,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (classes) {
Printf(stdout,"Classes\n");
Printf(stdout,"------------\n");
String *key;
for (key = Firstkey(classes); key; key = Nextkey(classes)) {
Printf(stdout,"%s\n", key);
Iterator ki;
for (ki = First(classes); ki.key; ki = Next(ki)) {
Printf(stdout,"%s\n", ki.key);
}
}
}

View file

@ -1338,19 +1338,19 @@ public:
/* Handle up-casts in a nice way */
List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist);
while (base) {
String *bname = Getattr(base, "ocaml:ctor");
if (bname) {
Printv(f_class_ctors,
" \"::",bname,"\", (fun args -> "
"create_",bname,"_from_ptr raw_ptr) ;\n",NIL);
Printv( base_classes, "create_", bname, "_from_ptr ;\n",
NIL );
}
base = Nextitem(baselist);
Iterator b;
b = First(baselist);
while (b.item) {
String *bname = Getattr(b.item, "ocaml:ctor");
if (bname) {
Printv(f_class_ctors,
" \"::",bname,"\", (fun args -> "
"create_",bname,"_from_ptr raw_ptr) ;\n",NIL);
Printv( base_classes, "create_", bname, "_from_ptr ;\n",
NIL );
}
b = Next(b);
}
}
Replaceall(this_class_def,"$classname",classname);

View file

@ -315,16 +315,16 @@ public:
/* Patch the type table to reflect the names used by shadow classes */
if (blessed) {
Node *cls;
for (cls = Firstitem(classlist); cls; cls = Nextitem(classlist)) {
if (Getattr(cls,"perl5:proxy")) {
SwigType *type = Copy(Getattr(cls,"classtype"));
Iterator cls;
for (cls = First(classlist); cls.item; cls = Next(cls)) {
if (Getattr(cls.item,"perl5:proxy")) {
SwigType *type = Copy(Getattr(cls.item,"classtype"));
if (!type) continue; /* If unnamed class, no type will be found */
SwigType_add_pointer(type);
String *mangle = NewStringf("\"%s\"", SwigType_manglestr(type));
String *rep = NewStringf("\"%s\"", Getattr(cls,"perl5:proxy"));
String *rep = NewStringf("\"%s\"", Getattr(cls.item,"perl5:proxy"));
Replaceall(type_table,mangle,rep);
Delete(mangle);
Delete(rep);
@ -1139,9 +1139,9 @@ public:
if (have_operators) {
Printf(pm, "use overload\n");
DOH *key;
for (key = Firstkey(operators); key; key = Nextkey(operators)) {
char *name = Char(key);
Iterator ki;
for (ki = First(operators); ki.key; ki = Next(ki)) {
char *name = Char(ki.key);
// fprintf(stderr,"found name: <%s>\n", name);
if (strstr(name, "operator_equal_to")) {
Printv(pm, tab4, "\"==\" => sub { $_[0]->operator_equal_to($_[1])},\n",NIL);
@ -1162,15 +1162,16 @@ public:
/* Handle inheritance */
List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist);
while (base) {
String *bname = Getattr(base, "perl5:proxy");
Iterator b;
b = First(baselist);
while (b.item) {
String *bname = Getattr(b.item, "perl5:proxy");
if (!bname) {
base = Nextitem(baselist);
b = Next(b);
continue;
}
Printv(pm," ", bname, NIL);
base = Nextitem(baselist);
b = Next(b);
}
}
Printf(pm, " );\n");

View file

@ -143,15 +143,17 @@ static const char *php_header =
void
SwigPHP_emit_resource_registrations() {
DOH *key;
Iterator ki;
String *destructor=0;
String *classname=0;
String *shadow_classname=0;
if (!zend_types) return;
key = Firstkey(zend_types);
if (key) Printf(s_oinit,"\n/* Register resource destructors for pointer types */\n");
while (key) if (1 /* is pointer type*/) {
ki = First(zend_types);
if (ki.key) Printf(s_oinit,"\n/* Register resource destructors for pointer types */\n");
while (ki.key) if (1 /* is pointer type*/) {
key = ki.key;
Node *class_node;
if ((class_node=Getattr(zend_types,key))) {
// Write out destructor function header
@ -187,7 +189,7 @@ SwigPHP_emit_resource_registrations() {
Printf(s_oinit,"SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n",
key,key);
}
key = Nextkey(zend_types);
ki = Next(ki);
}
}
@ -1458,24 +1460,23 @@ public:
if(baselist) {
int class_count = 0;
Node *base = Firstitem(baselist);
Iterator base = First(baselist);
while(base.item && Getattr(base.item,"feature:ignore")) base = Next(base);
while(base && Getattr(base,"feature:ignore")) base = Nextitem(baselist);
if (base && is_shadow(Getattr(base, "name"))) {
if (base.item && is_shadow(Getattr(base.item, "name"))) {
class_count++;
Printf(this_shadow_baseclass, "%s", Getattr(base, "name"));
Printf(this_shadow_baseclass, "%s", Getattr(base.item, "name"));
}
if (base) for(base = Nextitem(baselist); base; base = Nextitem(baselist)) {
if (Getattr(base,"feature:ignore")) continue;
if(is_shadow(Getattr(base, "name"))) {
if (base.item) for(base = Next(base); base.item; base = Next(base)) {
if (Getattr(base.item,"feature:ignore")) continue;
if(is_shadow(Getattr(base.item, "name"))) {
class_count++;
Printf(this_shadow_multinherit, "%s ", Getattr(base, "name"));
Printf(this_shadow_multinherit, "%s ", Getattr(base.item, "name"));
}
}
if(class_count > 1) Printf(stderr, "Error: %s inherits from multiple base classes(%s %s). Multiple inheritance is not directly supported by PHP4, SWIG may support it at some point in the future.\n", shadow_classname, base, this_shadow_multinherit);
if(class_count > 1) Printf(stderr, "Error: %s inherits from multiple base classes(%s %s). Multiple inheritance is not directly supported by PHP4, SWIG may support it at some point in the future.\n", shadow_classname, base.item, this_shadow_multinherit);
}
/* Write out class init code */
@ -1493,7 +1494,8 @@ public:
String *s_propget=NewString("");
String *s_propset=NewString("");
List *baselist = Getattr(n, "bases");
Node *base = NULL;
Iterator ki, base;
// If no constructor was generated (abstract class) we had better
// generate a constructor that raises an error about instantiating
@ -1526,20 +1528,22 @@ public:
Printf(s_header,"static int _propset_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname);
Printf(s_propset,"static int _propset_%s(zend_property_reference *property_reference, pval *value) {\n", shadow_classname);
if (baselist) base=Firstitem(baselist);
else base=NULL;
while(base && Getattr(base,"feature:ignore")) base = Nextitem(baselist);
key = Firstkey(shadow_set_vars);
if (baselist) base=First(baselist);
else base.item = NULL;
while(base.item && Getattr(base.item,"feature:ignore")) base = Next(base);
ki = First(shadow_set_vars);
key = ki.key;
// Print function header; we only need to find property name if there
// are properties for this class to look up...
if (key || ! base) { // or if we are base class and set it ourselves
if (key || ! base.item) { // or if we are base class and set it ourselves
Printf(s_propset," /* get the property name */\n"
" zend_llist_element *element = property_reference->elements_list->head;\n"
" zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"
" char *propname=Z_STRVAL_P(&(property->element));\n");
} else {
if (base) {
if (base.item) {
Printf(s_propset," /* No extra properties for subclass %s */\n",shadow_classname);
} else {
Printf(s_propset," /* No properties for base class %s */\n",shadow_classname);
@ -1547,27 +1551,28 @@ public:
}
scount=0;
while (key) {
while (ki.key) {
key = ki.key;
if (scount++) Printf(s_propset," else");
Printf(s_propset," if (strcmp(propname,\"%s\")==0) {\n"
" return _wrap_%s(property_reference, value);\n"
" }",Getattr(shadow_set_vars,key),key);
key=Nextkey(shadow_set_vars);
ki=Next(ki);
}
if (scount) Printf(s_propset," else");
// If there is a base class then chain it's handler else set directly
// try each base class handler, else set directly...
if (base) {
if (base.item) {
Printf(s_propset, " {\n /* chain to base class */\n");
while(base) {
while(base.item) {
Printf(s_propset," if (_propset_%s(property_reference, value)==SUCCESS) return SUCCESS;\n",
GetChar(base, "sym:name"));
GetChar(base.item, "sym:name"));
base=Nextitem(baselist);
while (base && Getattr(base,"feature:ignore")) base=Nextitem(baselist);
base=Next(base);
while (base.item && Getattr(base.item,"feature:ignore")) base=Next(base);
}
Printf(s_propset," }\n");
}
@ -1597,20 +1602,22 @@ public:
Printf(s_header,"static int _propget_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname);
Printf(s_propget,"static int _propget_%s(zend_property_reference *property_reference, pval *value) {\n", shadow_classname);
if (baselist) base=Firstitem(baselist);
else base=NULL;
while(base && Getattr(base,"feature:ignore")) base = Nextitem(baselist);
key = Firstkey(shadow_get_vars);
if (baselist) base=First(baselist);
else base.item=NULL;
while(base.item && Getattr(base.item,"feature:ignore")) base = Next(base);
ki = First(shadow_get_vars);
key = ki.key;
// Print function header; we only need to find property name if there
// are properties for this class to look up...
if (key || !base ) { // or if we are base class...
if (key || !base.item ) { // or if we are base class...
Printf(s_propget," /* get the property name */\n"
" zend_llist_element *element = property_reference->elements_list->head;\n"
" zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"
" char *propname=Z_STRVAL_P(&(property->element));\n");
} else {
if (base) {
if (base.item) {
Printf(s_propget," /* No extra properties for subclass %s */\n",shadow_classname);
} else {
Printf(s_propget," /* No properties for base class %s */\n",shadow_classname);
@ -1618,27 +1625,28 @@ public:
}
gcount=0;
while (key) {
while (ki.key) {
key = ki.key;
if (gcount++) Printf(s_propget," else");
Printf(s_propget," if (strcmp(propname,\"%s\")==0) {\n"
" *value=_wrap_%s(property_reference);\n"
" return SUCCESS;\n"
" }",Getattr(shadow_get_vars,key),key);
key=Nextkey(shadow_get_vars);
ki=Next(ki);
}
if (gcount) Printf(s_propget," else");
// If there is a base class then chain it's handler else return null
if (base) {
if (base.item) {
Printf(s_propget, " {\n /* chain to base class */\n");
while(base) {
while(base.item) {
Printf(s_propget," if (_propget_%s(property_reference, value)==SUCCESS) return SUCCESS;\n",
GetChar(base, "sym:name"));
GetChar(base.item, "sym:name"));
base=Nextitem(baselist);
while (base && Getattr(base,"feature:ignore")) base=Nextitem(baselist);
base=Next(base);
while (base.item && Getattr(base.item,"feature:ignore")) base=Next(base);
}
Printf(s_propget," }\n");
}
@ -1651,13 +1659,13 @@ public:
Printv(s_wrappers,s_propget,s_propset,NIL);
// Save class in class table
if (baselist) base=Firstitem(baselist);
else base=NULL;
while(base && Getattr(base,"feature:ignore")) base = Nextitem(baselist);
if (baselist) base=First(baselist);
else base.item=NULL;
while(base.item && Getattr(base.item,"feature:ignore")) base = Next(base);
if (base) {
if (base.item) {
Printf(s_oinit,"if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,&ce_swig_%s,NULL))) zend_error(E_ERROR,\"Error registering wrapper for class %s\");\n",
shadow_classname,shadow_classname,GetChar(base, "sym:name"), shadow_classname);
shadow_classname,shadow_classname,GetChar(base.item, "sym:name"), shadow_classname);
} else {
Printf(s_oinit,"if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,NULL,NULL))) zend_error(E_ERROR,\"Error registering wrapper for class %s\");\n",
shadow_classname,shadow_classname, shadow_classname);

View file

@ -642,9 +642,9 @@ public:
/* Handle inheritance */
List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist) > 0) {
Node *base = Firstitem(baselist);
while (base) {
String *basename = Getattr(base,"name");
Iterator base = First(baselist);
while (base.item) {
String *basename = Getattr(base.item,"name");
SwigType *basetype = NewString(basename);
SwigType_add_pointer(basetype);
SwigType_remember(basetype);
@ -652,7 +652,7 @@ public:
Printf(f_classInit, "low_inherit((struct program *) SWIGTYPE%s->clientdata, 0, 0, 0, 0, 0);\n", basemangle);
Delete(basemangle);
Delete(basetype);
base = Nextitem(baselist);
base = Next(base);
}
} else {
Printf(f_classInit, "ADD_STORAGE(swig_object_wrapper);\n");
@ -729,19 +729,19 @@ public:
void membervariableAccessors(List *membervariables) {
String *name;
Node *n;
Iterator i;
bool need_setter;
String *funcname;
/* If at least one of them is mutable, we need a setter */
need_setter = false;
n = Firstitem(membervariables);
while (n) {
if (!Getattr(n, "feature:immutable")) {
i = First(membervariables);
while (i.item) {
if (!Getattr(i.item, "feature:immutable")) {
need_setter = true;
break;
}
n = Nextitem(membervariables);
i = Next(i);
}
/* Create a function to set the values of the (mutable) variables */
@ -752,10 +752,10 @@ public:
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
n = Firstitem(membervariables);
while (n) {
if (!Getattr(n, "feature:immutable")) {
name = Getattr(n, "name");
i = First(membervariables);
while (i.item) {
if (!Getattr(i.item, "feature:immutable")) {
name = Getattr(i.item, "name");
funcname = Swig_name_wrapper(Swig_name_set(Swig_name_member(getClassPrefix(), name)));
Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name);
Printf(wrapper->code, "%s(args);\n", funcname);
@ -763,7 +763,7 @@ public:
Printf(wrapper->code, "}\n");
Delete(funcname);
}
n = Nextitem(membervariables);
i = Next(i);
}
/* Close the function */
@ -775,7 +775,7 @@ public:
/* Register it with Pike */
String *description = NewString("tStr tFloat, tVoid");
add_method(Firstitem(membervariables), "`->=", wname, description);
add_method(First(membervariables).item, "`->=", wname, description);
Delete(description);
/* Clean up */
@ -791,16 +791,16 @@ public:
Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL);
Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n");
n = Firstitem(membervariables);
while (n) {
name = Getattr(n, "name");
i = First(membervariables);
while (i.item) {
name = Getattr(i.item, "name");
funcname = Swig_name_wrapper(Swig_name_get(Swig_name_member(getClassPrefix(), name)));
Printf(wrapper->code, "if (!strcmp(name, \"%s\")) {\n", name);
Printf(wrapper->code, "%s(args);\n", funcname);
Printf(wrapper->code, "return;\n");
Printf(wrapper->code, "}\n");
Delete(funcname);
n = Nextitem(membervariables);
i = Next(i);
}
/* Close the function */
@ -812,7 +812,7 @@ public:
/* Register it with Pike */
String *description = NewString("tStr, tMix");
add_method(Firstitem(membervariables), "`->", wname, description);
add_method(First(membervariables).item, "`->", wname, description);
Delete(description);
/* Clean up */

View file

@ -1781,16 +1781,17 @@ public:
String *base_class = NewString("");
List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist);
while (base) {
String *bname = Getattr(base, "python:proxy");
Iterator b;
b = First(baselist);
while (b.item) {
String *bname = Getattr(b.item, "python:proxy");
if (!bname) {
base = Nextitem(baselist);
b = Next(b);
continue;
}
Printv(base_class,bname,NIL);
base = Nextitem(baselist);
if (base) {
b = Next(b);
if (b.item) {
Putc(',',base_class);
}
}
@ -2149,10 +2150,12 @@ public:
List *clist = DohSplit(temp,'\n',-1);
Delete(temp);
int initial = 0;
String *s;
/* Get the initial indentation */
for (s = Firstitem(clist); s; s = Nextitem(clist)) {
String *s = 0;
Iterator si;
/* Get the initial indentation */
for (si = First(clist); si.item; si = Next(si)) {
s = si.item;
if (Len(s)) {
char *c = Char(s);
while (*c) {
@ -2166,7 +2169,8 @@ public:
}
}
}
while (s) {
while (si.item) {
s = si.item;
if (Len(s) > initial) {
char *c = Char(s);
c += initial;
@ -2174,7 +2178,7 @@ public:
} else {
Printv(out,"\n",NIL);
}
s = Nextitem(clist);
si = Next(si);
}
Delete(clist);
return out;

View file

@ -511,19 +511,20 @@ public:
List *modules = Split(module,':',INT_MAX);
if (modules != 0 && Len(modules) > 0) {
String *mv = 0;
String *m = Firstitem(modules);
while (m != 0) {
if (Len(m) > 0) {
Iterator m;
m = First(modules);
while (m.item) {
if (Len(m.item) > 0) {
if (mv != 0) {
Printv(f_init, tab4, modvar,
" = rb_define_module_under(", modvar, ", \"", m, "\");\n", NIL);
" = rb_define_module_under(", modvar, ", \"", m.item, "\");\n", NIL);
} else {
Printv(f_init, tab4, modvar,
" = rb_define_module(\"", m, "\");\n", NIL);
" = rb_define_module(\"", m.item, "\");\n", NIL);
mv = NewString(modvar);
}
}
m = Nextitem(modules);
m = Next(m);
}
Delete(mv);
Delete(modules);
@ -767,18 +768,18 @@ public:
List *modules = Split(mod_name,':',INT_MAX);
if (modules != 0 && Len(modules) > 0) {
String *last = 0;
String *m = Firstitem(modules);
while (m != 0) {
if (Len(m) > 0) {
String *cap = NewString(m);
Iterator m = First(modules);
while (m.item) {
if (Len(m.item) > 0) {
String *cap = NewString(m.item);
(Char(cap))[0] = toupper((Char(cap))[0]);
if (last != 0) {
Append(module, "::");
}
Append(module, cap);
last = m;
last = m.item;
}
m = Nextitem(modules);
m = Next(m);
}
if (feature == 0) {
feature = Copy(last);
@ -809,12 +810,12 @@ public:
if (aliasv) {
List *aliases = Split(aliasv,',',INT_MAX);
if (aliases && Len(aliases) > 0) {
String *alias = Firstitem(aliases);
while (alias) {
if (Len(alias) > 0) {
Printv(klass->init, tab4, "rb_define_alias(", klass->vname, ", \"", alias, "\", \"", iname, "\");\n", NIL);
Iterator alias = First(aliases);
while (alias.item) {
if (Len(alias.item) > 0) {
Printv(klass->init, tab4, "rb_define_alias(", klass->vname, ", \"", alias.item, "\", \"", iname, "\");\n", NIL);
}
alias = Nextitem(aliases);
alias = Next(alias);
}
}
Delete(aliases);
@ -1707,12 +1708,12 @@ public:
if (mixin) {
List *modules = Split(mixin,',',INT_MAX);
if (modules && Len(modules) > 0) {
String *mod = Firstitem(modules);
while (mod) {
if (Len(mod) > 0) {
Printf(klass->init, "rb_include_module(%s, rb_eval_string(\"%s\"));\n", klass->vname, mod);
Iterator mod = First(modules);
while (mod.item) {
if (Len(mod.item) > 0) {
Printf(klass->init, "rb_include_module(%s, rb_eval_string(\"%s\"));\n", klass->vname, mod.item);
}
mod = Nextitem(modules);
mod = Next(mod);
}
}
Delete(modules);
@ -1722,9 +1723,9 @@ public:
void handleBaseClasses(Node *n) {
List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist);
while (base) {
String *basename = Getattr(base,"name");
Iterator base = First(baselist);
while (base.item) {
String *basename = Getattr(base.item,"name");
String *basenamestr = SwigType_namestr(basename);
RClass *super = RCLASS(classes, Char(basenamestr));
Delete(basenamestr);
@ -1747,14 +1748,14 @@ public:
}
Delete(btype);
}
base = Nextitem(baselist);
base = Next(base);
if (!multipleInheritance) {
/* Warn about multiple inheritance for additional base class(es) listed */
while (base) {
while (base.item) {
basename = Getattr(n,"name");
Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, input_file, line_number,
"Warning for %s: Base %s ignored. Multiple inheritance is not supported in Ruby.\n", basename, basename);
base = Nextitem(baselist);
base = Next(base);
}
}
}

View file

@ -258,13 +258,13 @@ public:
open_paren(NIL);
for (; obj; obj = nextSibling(obj)) {
if (DohIsMapping(obj)) {
DOH *k;
Iterator k;
open_paren(NIL);
for (k = Firstkey(obj); k; k = Nextkey(obj)) {
if (!internal_key_p(k)) {
DOH *value = Getattr(obj, k);
Sexp_print_as_keyword(k);
Sexp_print_value_of_key(value, k);
for (k = First(obj); k.key; k = Next(k)) {
if (!internal_key_p(k.key)) {
DOH *value = Getattr(obj, k.key);
Sexp_print_as_keyword(k.key);
Sexp_print_value_of_key(value, k.key);
print_lazy_whitespace();
}
}
@ -295,16 +295,16 @@ public:
}
else if (DohIsMapping(obj)) {
DOH *k;
Iterator k;
open_paren(NIL);
for (k = Firstkey(obj); k; k = Nextkey(obj)) {
if (!internal_key_p(k)) {
DOH *value = Getattr(obj, k);
for (k = First(obj); k.key; k = Next(k)) {
if (!internal_key_p(k.key)) {
DOH *value = Getattr(obj, k.key);
flush_parens();
open_paren(NIL);
Sexp_print_doh(k);
Sexp_print_doh(k.key);
Printf(out, " . ");
Sexp_print_value_of_key(value, k);
Sexp_print_value_of_key(value, k.key);
close_paren();
}
}
@ -341,18 +341,18 @@ public:
void Sexp_print_plist_noparens(DOH *obj)
{
/* attributes map names to objects */
String *k;
Iterator k;
bool first;
for (k = Firstkey(obj), first = true; k; k = Nextkey(obj), first=false) {
if (!internal_key_p(k)) {
DOH *value = Getattr(obj, k);
for (k = First(obj), first = true; k.key; k = Next(k), first=false) {
if (!internal_key_p(k.key)) {
DOH *value = Getattr(obj, k.key);
flush_parens();
if (!first) {
Printf(out, " ");
}
Sexp_print_as_keyword(k);
Sexp_print_as_keyword(k.key);
/* Print value */
Sexp_print_value_of_key(value, k);
Sexp_print_value_of_key(value, k.key);
}
}
}

View file

@ -661,17 +661,18 @@ public:
String *base_class = NewString("");
List *baselist = Getattr(n,"bases");
if (baselist && Len(baselist)) {
Node *base = Firstitem(baselist);
while (base) {
String *bname = Getattr(base, "name");
if ((!bname) || Getattr(base,"feature:ignore") || (!Getattr(base,"module"))) {
base = Nextitem(baselist);
Iterator b;
b = First(baselist);
while (b.item) {
String *bname = Getattr(b.item, "name");
if ((!bname) || Getattr(b.item,"feature:ignore") || (!Getattr(b.item,"module"))) {
b = Next(b);
continue;
}
String *bmangle = Swig_name_mangle(bname);
Printv(f_wrappers,"extern swig_class _wrap_class_", bmangle, ";\n", NIL);
Printf(base_class,"&_wrap_class_%s",bmangle);
base = Nextitem(baselist);
b = Next(b);
Putc(',',base_class);
Delete(bmangle);
}

View file

@ -121,9 +121,9 @@ class TypePass : public Dispatcher {
while (nn) {
Swig_symbol_setscope(nn->symtab);
SwigType_set_scope(nn->typescope);
SwigType *t;
for (t = Firstitem(nn->normallist); t; t = Nextitem(nn->normallist)) {
normalize_type(t);
Iterator t;
for (t = First(nn->normallist); t.item; t = Next(t)) {
normalize_type(t.item);
}
Delete(nn->normallist);
np = nn->next;

View file

@ -137,10 +137,10 @@ public:
print_indent(0);
Printf( out, "<attributelist id=\"%ld\" addr=\"%x\" >\n", ++id, obj );
indent_level += 4;
k = Firstkey(obj);
while (k)
{
Iterator ki;
ki = First(obj);
while (ki.key) {
k = ki.key;
if ((Cmp(k,"nodeType") == 0)
|| (Cmp(k,"firstChild") == 0)
|| (Cmp(k,"lastChild") == 0)
@ -202,7 +202,7 @@ public:
Delete(ck);
}
}
k = Nextkey(obj);
ki = Next(ki);
}
indent_level -= 4;
print_indent(0);
@ -261,11 +261,11 @@ public:
print_indent(0);
Printf( out, "<baselist id=\"%ld\" addr=\"%x\" >\n", ++id, p );
indent_level += 4;
String *s;
for (s = Firstitem(p); s; s = Nextitem(p))
Iterator s;
for (s = First(p); s.item; s = Next(s))
{
print_indent(0);
Printf( out, "<base name=\"%s\" id=\"%ld\" addr=\"%x\" />\n", s, ++id, s );
Printf( out, "<base name=\"%s\" id=\"%ld\" addr=\"%x\" />\n", s.item, ++id, s.item );
}
indent_level -= 4;
print_indent(0);
@ -304,16 +304,16 @@ public:
Printf( out, "<%s id=\"%ld\" addr=\"%x\" >\n", markup, ++id, p );
Xml_print_attributes( p );
indent_level += 4;
Node * n = Firstitem( p );
while(n)
Iterator n = First(p);
while(n.key)
{
print_indent(0);
Printf( out, "<%ssitem id=\"%ld\" addr=\"%x\" >\n", markup, ++id, n );
Xml_print_attributes( n );
Printf( out, "<%ssitem id=\"%ld\" addr=\"%x\" >\n", markup, ++id, n.item );
Xml_print_attributes( n.item );
Printf( out, "</%ssitem >\n", markup );
print_indent(0);
Printf( out, " />\n" );
n = Nextkey(p);
n = Next(n);
}
indent_level -= 4;
print_indent(0);