API cleanup. Documentation.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9629 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2006-12-30 18:27:47 +00:00
commit 264b7dff90
26 changed files with 712 additions and 373 deletions

View file

@ -353,6 +353,16 @@ int DohDelattr(DOH *obj, const DOH *name) {
return 0;
}
/* -----------------------------------------------------------------------------
* DohCheckattr()
* ----------------------------------------------------------------------------- */
int DohCheckattr(DOH *obj, const DOH *name, const DOH *value) {
DOH *attr = Getattr(obj,name);
if (!attr) return 0;
return DohEqual(attr,value);
}
/* -----------------------------------------------------------------------------
* DohKeys()
* ----------------------------------------------------------------------------- */

View file

@ -118,8 +118,6 @@
#define DohCopyto DOH_NAMESPACE(Copyto)
#define DohNewList DOH_NAMESPACE(NewList)
#define DohNewHash DOH_NAMESPACE(NewHash)
#define DohHashGetAttr DOH_NAMESPACE(HashGetAttr)
#define DohHashCheckAttr DOH_NAMESPACE(HashCheckAttr)
#define DohNewVoid DOH_NAMESPACE(NewVoid)
#define DohSplit DOH_NAMESPACE(Split)
#define DohSplitLines DOH_NAMESPACE(SplitLines)
@ -206,6 +204,7 @@ extern void DohIncref(DOH *obj);
extern DOH *DohGetattr(DOH *obj, const DOHString_or_char *name);
extern int DohSetattr(DOH *obj, const DOHString_or_char *name, const DOHObj_or_char * value);
extern int DohDelattr(DOH *obj, const DOHString_or_char *name);
extern int DohCheckattr(DOH *obj, const DOHString_or_char *name, const DOHString_or_char *value);
extern DOH *DohKeys(DOH *obj);
extern int DohGetInt(DOH *obj, const DOHString_or_char *name);
extern void DohSetInt(DOH *obj, const DOHString_or_char *name, int);
@ -346,8 +345,6 @@ extern void DohSortList(DOH *lo, int (*cmp) (const DOH *, const DOH *));
* ----------------------------------------------------------------------------- */
extern DOHHash *DohNewHash();
extern DOH *DohHashGetAttr(DOH *hash, const DOH *key);
extern int DohHashCheckAttr(DOH *hash, DOH *key, DOH *value);
/* -----------------------------------------------------------------------------
* Void
@ -372,6 +369,7 @@ extern void DohMemoryDebug(void);
#define Getattr DohGetattr
#define Setattr DohSetattr
#define Delattr DohDelattr
#define Checkattr DohCheckattr
#define Hashval DohHashval
#define Getitem DohGetitem
#define Setitem DohSetitem
@ -434,8 +432,6 @@ extern void DohMemoryDebug(void);
#define NewStringWithSize DohNewStringWithSize
#define NewStringf DohNewStringf
#define NewHash DohNewHash
#define HashGetAttr DohHashGetAttr
#define HashCheckAttr DohHashCheckAttr
#define NewList DohNewList
#define NewFile DohNewFile
#define NewFileFromFile DohNewFileFromFile

View file

@ -253,61 +253,30 @@ static int Hash_setattr(DOH *ho, DOH *k, DOH *obj) {
* ----------------------------------------------------------------------------- */
typedef int (*binop) (DOH *obj1, DOH *obj2);
#define _Hash_getattr(h, k, o) \
int hv = Hashval(k) % h->hashsize; \
DohObjInfo *k_type = ((DohBase*)k)->type; \
HashNode *n = h->hashtable[hv]; \
if (k_type->doh_equal) { \
binop equal = k_type->doh_equal; \
while (n) { \
DohBase *nk = (DohBase *)n->key; \
if ((k_type == nk->type) && equal(k, nk)) o = n->object; \
n = n->next; \
} \
} else { \
binop cmp = k_type->doh_cmp; \
while (n) { \
DohBase *nk = (DohBase *)n->key; \
if ((k_type == nk->type) && (cmp(k, nk) == 0)) o = n->object; \
n = n->next; \
} \
}
static DOH *Hash_getattr(DOH *h, DOH *k) {
DOH *obj = 0;
Hash *ho = (Hash *) ObjData(h);
DOH *ko = DohCheck(k) ? k : find_key(k);
_Hash_getattr(ho, ko, obj);
return obj;
}
DOH *DohHashGetAttr(DOH *h, const DOH *k) {
DOH *obj = 0;
Hash *ho = (Hash *) ObjData(h);
_Hash_getattr(ho, (DOH *) k, obj);
return obj;
}
/* -----------------------------------------------------------------------------
* HashCheckAttr()
*
* Check an attribute from the hash table.
* ----------------------------------------------------------------------------- */
int DohHashCheckAttr(DOH *h, DOH *k, DOH *v) {
DOH *obj = 0;
Hash *ho = (Hash *) ObjData(h);
_Hash_getattr(ho, k, obj);
if (obj) {
DohObjInfo *o_type = ((DohBase *) obj)->type;
if (o_type == ((DohBase *) v)->type) {
binop equal = o_type->doh_equal;
return equal ? equal(obj, v) : (o_type->doh_cmp(obj, v) == 0);
int hv = Hashval(ko) % ho->hashsize;
DohObjInfo *k_type = ((DohBase*)ko)->type;
HashNode *n = ho->hashtable[hv];
if (k_type->doh_equal) {
binop equal = k_type->doh_equal;
while (n) {
DohBase *nk = (DohBase *)n->key;
if ((k_type == nk->type) && equal(ko, nk)) obj = n->object;
n = n->next;
}
} else {
binop cmp = k_type->doh_cmp;
while (n) {
DohBase *nk = (DohBase *)n->key;
if ((k_type == nk->type) && (cmp(ko, nk) == 0)) obj = n->object;
n = n->next;
}
}
return 0;
return obj;
}
/* -----------------------------------------------------------------------------