From 15a5e3976f8636f55dc8b71e41f6ad200ff8361e Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Sun, 26 Sep 2004 01:14:49 +0000 Subject: [PATCH] CHANGES.current git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6269 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 49 +++++++++++++++++++ Examples/test-suite/arrays_global.i | 2 +- Examples/test-suite/friends.i | 2 +- Examples/test-suite/name_warnings.i | 2 +- .../test-suite/namespace_virtual_method.i | 3 ++ Examples/test-suite/primitive_types.i | 6 +-- Examples/test-suite/redefined.i | 2 +- Examples/test-suite/refcount.i | 3 +- Examples/test-suite/template_base_template.i | 2 +- Examples/test-suite/template_explicit.i | 2 +- Examples/test-suite/template_tbase_template.i | 2 +- Source/DOH/base.c | 24 +++++++-- Source/DOH/hash.c | 7 ++- Source/DOH/memory.c | 10 ++-- Source/DOH/string.c | 32 ++++++------ 15 files changed, 113 insertions(+), 35 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ed66ded26..58b7c7c01 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,55 @@ Version 1.3.23 (in progress) ================================== +09/26/2004: mmatus + + - add %feature("exceptionclass") to identify a class used + as exception. Before swig identified and marked a class + using the "cplus:exceptionclass" attribute. However, the + class needed to appear on an throw() statement. Now + swig keeps trying to identify the exception classes, as + before, but it also allows the user to mark a class by + using the %feature explicitly. (mostly relevant for + python and chicken) + + [Python] + + - fix -modern option + exceptions, which mix old class + style with the new one. So, we always need to emit + the "nonmodern" python code. + + - add the "python:nondynamic" feature and its handler + + now if you have + + %pythonnondynamic(1) A; + + struct A { + int a; + int b; + }; + + then, in the python side + + aa = A() + + aa.a = 1 # ok + aa.b = 2 # ok + aa.c = 3 # error, the class can not be extended dynamically. + + + Since this is a feature, you can use + + %pythonnondynamic(1); + + or + + %pythondynamic(0); + + to force all the wrapped classes to be "nondynamic" ones. + + The default, as in regular python, is that all the wrapped + classes are dynamics. So, careful with your spelling. 09/14/2004: mmatus - Support the -I- option. diff --git a/Examples/test-suite/arrays_global.i b/Examples/test-suite/arrays_global.i index e6f9fd7ce..f63d4df67 100644 --- a/Examples/test-suite/arrays_global.i +++ b/Examples/test-suite/arrays_global.i @@ -2,7 +2,7 @@ This test case tests that various types of arrays are working. */ -#pragma SWIG nowarn=451,462 +%warnfilter(451,462); %module arrays_global diff --git a/Examples/test-suite/friends.i b/Examples/test-suite/friends.i index 8542c5004..4085e6fd4 100644 --- a/Examples/test-suite/friends.i +++ b/Examples/test-suite/friends.i @@ -3,7 +3,7 @@ #include %} -#pragma SWIG nowarn=-503 +%warnfilter(503); %inline diff --git a/Examples/test-suite/name_warnings.i b/Examples/test-suite/name_warnings.i index d30be419d..586fd1f52 100644 --- a/Examples/test-suite/name_warnings.i +++ b/Examples/test-suite/name_warnings.i @@ -10,7 +10,7 @@ */ /* activate all the name warnings */ -#pragma SWIG nowarn=+315,+321,-403 +%warnfilter(+315,+321,-403); %inline { diff --git a/Examples/test-suite/namespace_virtual_method.i b/Examples/test-suite/namespace_virtual_method.i index 2eac3c53b..05c8f9795 100644 --- a/Examples/test-suite/namespace_virtual_method.i +++ b/Examples/test-suite/namespace_virtual_method.i @@ -1,5 +1,8 @@ %module namespace_virtual_method +%warnfilter(515); + + %inline %{ namespace A { diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i index 31e150803..5aeb60f6a 100644 --- a/Examples/test-suite/primitive_types.i +++ b/Examples/test-suite/primitive_types.i @@ -82,9 +82,9 @@ // Try your language module with and without // these nowarn flags. // -#pragma SWIG nowarn=451 - //#pragma SWIG nowarn=515 - //#pragma SWIG nowarn=509 +%warnfilter(451); +//%warnfilter(515); +//%warnfilter(509); %{ #include diff --git a/Examples/test-suite/redefined.i b/Examples/test-suite/redefined.i index 67e38da45..7d78dd98b 100644 --- a/Examples/test-suite/redefined.i +++ b/Examples/test-suite/redefined.i @@ -3,7 +3,7 @@ %warnfilter(801) agua; /* no redundant warnings */ -#pragma SWIG nowarn=-322 +%warnfilter(322); #if 1 // diff --git a/Examples/test-suite/refcount.i b/Examples/test-suite/refcount.i index 15ecad032..f43e9f4f9 100644 --- a/Examples/test-suite/refcount.i +++ b/Examples/test-suite/refcount.i @@ -1,6 +1,7 @@ %module refcount -#pragma SWIG nowarn=362 +#warnfilter(362); + %{ #include #include "refcount.h" diff --git a/Examples/test-suite/template_base_template.i b/Examples/test-suite/template_base_template.i index d21814add..7344263c1 100644 --- a/Examples/test-suite/template_base_template.i +++ b/Examples/test-suite/template_base_template.i @@ -2,7 +2,7 @@ %warnfilter(801) traits; /* Ruby, wrong class name */ -#pragma SWIG nowarn=320 +%warnfilter(320); %inline %{ template diff --git a/Examples/test-suite/template_explicit.i b/Examples/test-suite/template_explicit.i index 0ef7cea53..252aae012 100644 --- a/Examples/test-suite/template_explicit.i +++ b/Examples/test-suite/template_explicit.i @@ -4,7 +4,7 @@ %warnfilter(801) vector; /* Ruby, wrong class name */ %warnfilter(801) vector; /* Ruby, wrong class name */ %warnfilter(801) vector; /* Ruby, wrong class name */ -#pragma SWIG nowarn=320 +%warnfilter(320); /* Let's just grab the original header file here */ diff --git a/Examples/test-suite/template_tbase_template.i b/Examples/test-suite/template_tbase_template.i index b890dc378..db241b52c 100644 --- a/Examples/test-suite/template_tbase_template.i +++ b/Examples/test-suite/template_tbase_template.i @@ -2,7 +2,7 @@ %warnfilter(801) traits; /* Ruby, wrong class name */ -#pragma SWIG nowarn=320 +%warnfilter(320); %inline %{ typedef double Double; diff --git a/Source/DOH/base.c b/Source/DOH/base.c index 3317f2e4b..464afcd70 100644 --- a/Source/DOH/base.c +++ b/Source/DOH/base.c @@ -142,7 +142,9 @@ int DohHashval(const DOH *obj) { DohBase *b = (DohBase *) obj; DohObjInfo *objinfo; - if (DohCheck(b)) { + /* obj is already checked and/or converted into DohBase* */ + /* if (DohCheck(b)) */ + { objinfo = b->type; if (objinfo->doh_hashval) { return (objinfo->doh_hashval)(b); @@ -173,17 +175,33 @@ DohData(const DOH *obj) { * DohCmp() * ----------------------------------------------------------------------------- */ +#define RawData(b) ((b->type->doh_data) ? (b->type->doh_data)(b) : 0) + +/* +static void * +RawData(DohBase *b) { + DohObjInfo *objinfo = b->type; + return (objinfo->doh_data) ? (objinfo->doh_data)(b) : 0; +} +*/ + + int DohCmp(const DOH *obj1, const DOH *obj2) { DohBase *b1, *b2; DohObjInfo *b1info, *b2info; + int c1, c2; b1 = (DohBase *) obj1; b2 = (DohBase *) obj2; - if ((!DohCheck(b1)) || (!DohCheck(b2))) { + c1 = DohCheck(b1); + c2 = DohCheck(b2); + /* most of the times, obj2 is a plain c string */ + if (!c1 || !c2) { if ((b1 == 0) && (b2 == 0)) return 0; if (b1 && !b2) return 1; if (!b1 && b2) return -1; - return strcmp((char *) DohData(b1),(char *) DohData(b2)); + return strcmp((char *) (c1 ? RawData(b1) : (void*) obj1), + (char *) (c2 ? RawData(b2) : (void*) obj2)); } b1info = b1->type; b2info = b2->type; diff --git a/Source/DOH/hash.c b/Source/DOH/hash.c index 7647f363a..e5783841f 100644 --- a/Source/DOH/hash.c +++ b/Source/DOH/hash.c @@ -249,13 +249,18 @@ static DOH * Hash_getattr(DOH *ho, DOH *k) { int hv; HashNode *n; + DohObjInfo *k_type; + DohBase *nk; + Hash *h = (Hash *) ObjData(ho); if (!DohCheck(k)) k = find_key(k); hv = Hashval(k) % h->hashsize; n = h->hashtable[hv]; + k_type = ((DohBase*)k)->type; while (n) { - if (Cmp(n->key, k) == 0) return n->object; + nk = n->key; + if ((k_type == nk->type) && ((k_type->doh_cmp)(k, nk) == 0)) return n->object; n = n->next; } return 0; diff --git a/Source/DOH/memory.c b/Source/DOH/memory.c index 8e207075d..b5717b297 100644 --- a/Source/DOH/memory.c +++ b/Source/DOH/memory.c @@ -27,6 +27,8 @@ typedef struct pool { int len; /* Length of pool */ int blen; /* Byte length of pool */ int current; /* Current position for next allocation */ + char* pbeg; /* Beg of pool */ + char* pend; /* End of pool */ struct pool *next; /* Next pool */ } Pool; @@ -49,6 +51,8 @@ CreatePool() { p->len = PoolSize; p->blen = PoolSize*sizeof(DohBase); p->current = 0; + p->pbeg = ((char *)p->ptr); + p->pend = p->pbeg + p->blen; p->next = Pools; Pools = p; } @@ -74,12 +78,10 @@ InitPools() { int DohCheck(const DOH *ptr) { - Pool *p = Pools; + register Pool *p = Pools; register char *cptr = (char *) ptr; - register char *pptr; while (p) { - pptr = (char *) p->ptr; - if ((cptr >= pptr) && (cptr < (pptr + p->blen))) return 1; + if ((cptr >= p->pbeg) && (cptr < p->pend)) return 1; /* pptr = (char *) p->ptr; if ((cptr >= pptr) && (cptr < (pptr+(p->current*sizeof(DohBase))))) return 1; */ diff --git a/Source/DOH/string.c b/Source/DOH/string.c index a965f53d7..082ce1c8d 100644 --- a/Source/DOH/string.c +++ b/Source/DOH/string.c @@ -111,25 +111,25 @@ String_len(DOH *so) { static int String_cmp(DOH *so1, DOH *so2) { - String *s1, *s2; - char *c1, *c2; - int maxlen,i; - s1 = (String *) ObjData(so1); - s2 = (String *) ObjData(so2); - maxlen = s1->len; - if (s2->len < maxlen) maxlen = s2->len; + String * s1 = (String *) ObjData(so1); + String * s2 = (String *) ObjData(so2); + register char *c1; + register char *c2; + register int len = s1->len; + if (len != s2->len) return (len < s2->len ) ? -1 : 1; c1 = s1->str; c2 = s2->str; - for (i = 0; i < maxlen; i++,c1++,c2++) { - if (*c1 != *c2) break; +#if 1 + /* this is better, but it could be not present in all the + systems ? */ + return memcmp(c1, c2, len); +#else + /* faster loop with nonzero predicates */ + for (; len ; --len,++c1,++c2) { + if (*c1 != *c2) return ((*c1 < *c2) ? -1 : 1); } - if (i < maxlen) { - if (*c1 < *c2) return -1; - else return 1; - } - if (s1->len == s2->len) return 0; - if (s1->len > s2->len) return 1; - return -1; + return 0; +#endif } /* -----------------------------------------------------------------------------