Cleanup
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@452 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
3daac96b9b
commit
7b03566fdd
10 changed files with 67 additions and 357 deletions
|
|
@ -22,14 +22,14 @@ AR = @AR@
|
||||||
# Normally, you shouldn't have to change anything below this point #
|
# Normally, you shouldn't have to change anything below this point #
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
LIBOBJS = callable.o void.o fio.o memory.o base.o file.o list.o hash.o string.o
|
LIBOBJS = void.o fio.o memory.o base.o file.o list.o hash.o string.o
|
||||||
|
|
||||||
LIBSRCS = callable.c void.c fio.c memory.c base.c file.c list.c hash.c string.c
|
LIBSRCS = void.c fio.c memory.c base.c file.c list.c hash.c string.c
|
||||||
|
|
||||||
LIBHEADERS = $(srcdir)/../Include/doh.h
|
LIBHEADERS = $(srcdir)/../Include/doh.h
|
||||||
LIB = libdoh.a
|
LIB = libdoh.a
|
||||||
INCLUDE = -I$(srcdir)/../Include
|
INCLUDE = -I$(srcdir)/../Include
|
||||||
CFLAGS = @CFLAGS@ -DDOH_STRING_UPDATE_LINES
|
CFLAGS = @CFLAGS@
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ static DohObjInfo DohBaseType = {
|
||||||
0, /* doh_del */
|
0, /* doh_del */
|
||||||
0, /* doh_copy */
|
0, /* doh_copy */
|
||||||
0, /* doh_clear */
|
0, /* doh_clear */
|
||||||
0, /* doh_scope */
|
|
||||||
0, /* doh_str */
|
0, /* doh_str */
|
||||||
0, /* doh_data */
|
0, /* doh_data */
|
||||||
0, /* doh_dump */
|
0, /* doh_dump */
|
||||||
|
|
@ -262,91 +261,6 @@ DohData(const DOH *obj) {
|
||||||
return (char *) obj;
|
return (char *) obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* DohGetLine()
|
|
||||||
*
|
|
||||||
* Return the line number associated with an object or -1 if unspecified.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
int
|
|
||||||
DohGetline(DOH *obj) {
|
|
||||||
DohBase *b = (DohBase *) obj;
|
|
||||||
DohTrace(DOH_CALLS,"DohGetline %x\n",obj);
|
|
||||||
if (DohCheck(obj)) {
|
|
||||||
if (b->objinfo->doh_position && b->objinfo->doh_position->doh_getline) {
|
|
||||||
return (b->objinfo->doh_position->doh_getline)(b);
|
|
||||||
} else {
|
|
||||||
DohTrace(DOH_UNSUPPORTED,"No getline method defined for type '%s'\n", b->objinfo->objname);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DohTrace(DOH_UNKNOWN, "Unknown object %x passed to Getline.\n", obj);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* DohSetLine()
|
|
||||||
*
|
|
||||||
* Set the line number associated with an object.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void
|
|
||||||
DohSetline(DOH *obj, int line) {
|
|
||||||
DohBase *b = (DohBase *) obj;
|
|
||||||
DohTrace(DOH_CALLS,"DohSetline %x, %d\n",obj, line);
|
|
||||||
if (DohCheck(obj)) {
|
|
||||||
if (b->objinfo->doh_position && b->objinfo->doh_position->doh_setline) {
|
|
||||||
(b->objinfo->doh_position->doh_setline)(obj, line);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DohTrace(DOH_UNSUPPORTED,"No setline method defined for type '%s'\n", b->objinfo->objname);
|
|
||||||
} else {
|
|
||||||
DohTrace(DOH_UNKNOWN, "Unknown object %x passed to Setline.\n", obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* DohGetfile()
|
|
||||||
*
|
|
||||||
* Get the file associated with an object.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
DOH *
|
|
||||||
DohGetfile(DOH *obj) {
|
|
||||||
DohBase *b = (DohBase *) obj;
|
|
||||||
DohTrace(DOH_CALLS,"DohGetfile %x\n",obj);
|
|
||||||
if (DohCheck(obj)) {
|
|
||||||
if (b->objinfo->doh_position && b->objinfo->doh_position->doh_getfile) {
|
|
||||||
return (b->objinfo->doh_position->doh_getfile)(b);
|
|
||||||
}
|
|
||||||
DohTrace(DOH_UNSUPPORTED,"No getfile method defined for type '%s'\n", b->objinfo->objname);
|
|
||||||
} else {
|
|
||||||
DohTrace(DOH_UNKNOWN, "Unknown object %x passed to Getfile.\n", obj);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* DohSetfile()
|
|
||||||
*
|
|
||||||
* Set the file associated with an object.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void
|
|
||||||
DohSetfile(DOH *obj, DOH *file) {
|
|
||||||
DohBase *b = (DohBase *) obj;
|
|
||||||
DohTrace(DOH_CALLS,"DohSetfile %x, %x\n",obj,file);
|
|
||||||
if (DohCheck(obj)) {
|
|
||||||
if (b->objinfo->doh_position && b->objinfo->doh_position->doh_setfile) {
|
|
||||||
(b->objinfo->doh_position->doh_setfile)(obj,file);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DohTrace(DOH_UNSUPPORTED,"No setfile method defined for type '%s'\n", b->objinfo->objname);
|
|
||||||
} else {
|
|
||||||
DohTrace(DOH_UNKNOWN, "Unknown object %x passed to Setfile.\n", obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DohCmp()
|
* DohCmp()
|
||||||
*
|
*
|
||||||
|
|
@ -1050,43 +964,6 @@ DohChop(DOH *src) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* Callable methods
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* DohIsCallable()
|
|
||||||
*
|
|
||||||
* Return 1 if an object supports callable methods.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
int
|
|
||||||
DohIsCallable(const DOH *obj) {
|
|
||||||
DohBase *b = (DohBase *) obj;
|
|
||||||
if (!DohCheck(b)) return 0;
|
|
||||||
if (b->objinfo->doh_callable) return 1;
|
|
||||||
else return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* DohCall()
|
|
||||||
*
|
|
||||||
* Perform a function call on an object.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
DOH *
|
|
||||||
DohCall(DOH *obj, DOH *args) {
|
|
||||||
DohBase *b = (DohBase *) obj;
|
|
||||||
DohTrace(DOH_CALLS,"DohCall %x\n",obj);
|
|
||||||
if (DohCheck(b)) {
|
|
||||||
if ((b->objinfo->doh_callable) && (b->objinfo->doh_callable->doh_call)) {
|
|
||||||
return (b->objinfo->doh_callable->doh_call)(b,args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DohInit()
|
* DohInit()
|
||||||
*
|
*
|
||||||
|
|
@ -1099,67 +976,67 @@ DohInit(DOH *b) {
|
||||||
bs->refcount = 1;
|
bs->refcount = 1;
|
||||||
bs->objinfo = &DohBaseType;
|
bs->objinfo = &DohBaseType;
|
||||||
bs->flags = 0;
|
bs->flags = 0;
|
||||||
|
bs->file = 0;
|
||||||
|
bs->line = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DohXBase_setfile()
|
* DohSetFile()
|
||||||
*
|
*
|
||||||
* Set file location (default method).
|
* Set file location (default method).
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
void
|
void
|
||||||
DohXBase_setfile(DOH *ho, DOH *file) {
|
DohSetFile(DOH *ho, DOH *file) {
|
||||||
DohXBase *h = (DohXBase *) ho;
|
DohBase *h = (DohBase *) ho;
|
||||||
|
if (DohCheck(h)) {
|
||||||
if (!DohCheck(file)) file = NewString(file);
|
if (!DohCheck(file)) file = NewString(file);
|
||||||
h->file = file;
|
h->file = file;
|
||||||
Incref(h->file);
|
Incref(h->file);
|
||||||
|
} else {
|
||||||
|
DohTrace(DOH_UNKNOWN,"Unknown object %x passed to Setfile.\n",h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DohXBase_getfile()
|
* DohGetFile()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
DOH *
|
DOH *
|
||||||
DohXBase_getfile(DOH *ho) {
|
DohGetfile(DOH *ho) {
|
||||||
DohXBase *h = (DohXBase *) ho;
|
DohBase *h = (DohBase *) ho;
|
||||||
|
if (DohCheck(h)) {
|
||||||
return h->file;
|
return h->file;
|
||||||
|
} else {
|
||||||
|
DohTrace(DOH_UNKNOWN,"Unknown object %x passed to Getfile.\n", h);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DohXBase_setline()
|
* DohSetLine()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
void
|
void
|
||||||
DohXBase_setline(DOH *ho, int l) {
|
DohSetline(DOH *ho, int l) {
|
||||||
DohXBase *h = (DohXBase *) ho;
|
DohBase *h = (DohBase *) ho;
|
||||||
|
if (DohCheck(h)) {
|
||||||
h->line = l;
|
h->line = l;
|
||||||
|
} else {
|
||||||
|
DohTrace(DOH_UNKNOWN, "Unknown object %x passed to Setline.\n", h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DohXBase_getline()
|
* DohGetLine()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
int
|
int
|
||||||
DohXBase_getline(DOH *ho) {
|
DohGetline(DOH *ho) {
|
||||||
DohXBase *h = (DohXBase *) ho;
|
DohBase *h = (DohBase *) ho;
|
||||||
|
if (DohCheck(h)) {
|
||||||
return h->line;
|
return h->line;
|
||||||
}
|
} else {
|
||||||
|
DohTrace(DOH_UNKNOWN, "Unknown object %x passed to GetLine.\n", h);
|
||||||
static DohPositionalMethods XBasePositionalMethods = {
|
}
|
||||||
DohXBase_setfile,
|
return -1;
|
||||||
DohXBase_getfile,
|
|
||||||
DohXBase_setline,
|
|
||||||
DohXBase_getline
|
|
||||||
};
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* DohXInit()
|
|
||||||
*
|
|
||||||
* Initialize an extended object.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
void
|
|
||||||
DohXInit(DOH *b) {
|
|
||||||
DohXBase *bs = (DohXBase *) b;
|
|
||||||
bs->file = 0;
|
|
||||||
bs->line = 0;
|
|
||||||
bs->objinfo->doh_position = &XBasePositionalMethods;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,105 +0,0 @@
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* callable.c
|
|
||||||
*
|
|
||||||
* This file implements a simple callable object supporting a function call
|
|
||||||
* operation.
|
|
||||||
*
|
|
||||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999-2000. The University of Chicago
|
|
||||||
* See the file LICENSE for information on usage and redistribution.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static char cvsroot[] = "$Header$";
|
|
||||||
|
|
||||||
#include "dohint.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
DOHCOMMON;
|
|
||||||
DOH *(*func)(DOH *, DOH *);
|
|
||||||
} CallableObj;
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* Callable_delete()
|
|
||||||
*
|
|
||||||
* Destroy a callable object.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static void
|
|
||||||
Callable_delete(DOH *co) {
|
|
||||||
DohObjFree(co);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* Callable_copy()
|
|
||||||
*
|
|
||||||
* Copy a callable object.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static DOH *
|
|
||||||
Callable_copy(DOH *co) {
|
|
||||||
CallableObj *c = (CallableObj *) co;
|
|
||||||
return NewCallable(c->func);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* Callable_call()
|
|
||||||
*
|
|
||||||
* Call an object. The object itself is passed as the first argument and remaining
|
|
||||||
* arguments are passed as a second argument.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static DOH *
|
|
||||||
Callable_call(DOH *co, DOH *args) {
|
|
||||||
CallableObj *c = (CallableObj *) co;
|
|
||||||
return (*c->func)(c,args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Method tables */
|
|
||||||
|
|
||||||
static DohCallableMethods doh_callable_methods = {
|
|
||||||
Callable_call
|
|
||||||
};
|
|
||||||
|
|
||||||
static DohObjInfo DohCallableType = {
|
|
||||||
"CallableObj", /* objname */
|
|
||||||
sizeof(CallableObj), /* objsize */
|
|
||||||
Callable_delete, /* doh_del */
|
|
||||||
Callable_copy, /* doh_copy */
|
|
||||||
0, /* doh_clear */
|
|
||||||
0, /* doh_scope */
|
|
||||||
0, /* doh_str */
|
|
||||||
0, /* doh_data */
|
|
||||||
0, /* doh_dump */
|
|
||||||
0, /* doh_load */
|
|
||||||
0, /* doh_len */
|
|
||||||
0, /* doh_hash */
|
|
||||||
0, /* doh_cmp */
|
|
||||||
0, /* doh_mapping */
|
|
||||||
0, /* doh_sequence */
|
|
||||||
0, /* doh_file */
|
|
||||||
0, /* doh_string */
|
|
||||||
&doh_callable_methods, /* doh_callable */
|
|
||||||
0, /* doh_position */
|
|
||||||
0, /* reserved5 */
|
|
||||||
0, /* reserved6 */
|
|
||||||
0, /* user1 */
|
|
||||||
0, /* user2 */
|
|
||||||
0, /* user3 */
|
|
||||||
0, /* user4 */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* NewCallable()
|
|
||||||
*
|
|
||||||
* Create a new callable object.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
DOH *
|
|
||||||
NewCallable(DOH *(*func)(DOH *, DOH *)) {
|
|
||||||
CallableObj *c;
|
|
||||||
c = (CallableObj *) DohObjMalloc(sizeof(CallableObj));
|
|
||||||
c->objinfo = &DohCallableType;
|
|
||||||
c->func = func;
|
|
||||||
return (DOH *) c;
|
|
||||||
}
|
|
||||||
|
|
@ -156,7 +156,6 @@ static DohObjInfo DohFileType = {
|
||||||
DelFile, /* doh_del */
|
DelFile, /* doh_del */
|
||||||
0, /* doh_copy */
|
0, /* doh_copy */
|
||||||
0, /* doh_clear */
|
0, /* doh_clear */
|
||||||
0, /* doh_scope */
|
|
||||||
0, /* doh_str */
|
0, /* doh_str */
|
||||||
0, /* doh_data */
|
0, /* doh_data */
|
||||||
0, /* doh_dump */
|
0, /* doh_dump */
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ typedef struct HashNode {
|
||||||
|
|
||||||
/* Hash object */
|
/* Hash object */
|
||||||
typedef struct Hash {
|
typedef struct Hash {
|
||||||
DOHXCOMMON;
|
DOHCOMMON;
|
||||||
HashNode **hashtable;
|
HashNode **hashtable;
|
||||||
int hashsize;
|
int hashsize;
|
||||||
int currentindex;
|
int currentindex;
|
||||||
|
|
@ -115,7 +115,6 @@ DelHash(DOH *ho) {
|
||||||
DohFree(h->hashtable);
|
DohFree(h->hashtable);
|
||||||
h->hashtable = 0;
|
h->hashtable = 0;
|
||||||
h->hashsize = 0;
|
h->hashsize = 0;
|
||||||
Delete(h->file);
|
|
||||||
DohObjFree(h);
|
DohObjFree(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -433,7 +432,6 @@ CopyHash(DOH *ho) {
|
||||||
h = (Hash *) ho;
|
h = (Hash *) ho;
|
||||||
nh = (Hash *) DohObjMalloc(sizeof(Hash));
|
nh = (Hash *) DohObjMalloc(sizeof(Hash));
|
||||||
nh->objinfo = h->objinfo;
|
nh->objinfo = h->objinfo;
|
||||||
DohXInit(h);
|
|
||||||
nh->hashsize = h->hashsize;
|
nh->hashsize = h->hashsize;
|
||||||
nh->hashtable = (HashNode **) DohMalloc(nh->hashsize*sizeof(HashNode *));
|
nh->hashtable = (HashNode **) DohMalloc(nh->hashsize*sizeof(HashNode *));
|
||||||
for (i = 0; i < nh->hashsize; i++) {
|
for (i = 0; i < nh->hashsize; i++) {
|
||||||
|
|
@ -475,7 +473,6 @@ static DohObjInfo HashType = {
|
||||||
DelHash, /* doh_del */
|
DelHash, /* doh_del */
|
||||||
CopyHash, /* doh_copy */
|
CopyHash, /* doh_copy */
|
||||||
Hash_clear, /* doh_clear */
|
Hash_clear, /* doh_clear */
|
||||||
0, /* doh_scope */
|
|
||||||
Hash_str, /* doh_str */
|
Hash_str, /* doh_str */
|
||||||
0, /* doh_data */
|
0, /* doh_data */
|
||||||
0, /* doh_dump */
|
0, /* doh_dump */
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ static char cvsroot[] = "$Header$";
|
||||||
#include "dohint.h"
|
#include "dohint.h"
|
||||||
|
|
||||||
typedef struct List {
|
typedef struct List {
|
||||||
DOHXCOMMON;
|
DOHCOMMON;
|
||||||
int maxitems; /* Max size */
|
int maxitems; /* Max size */
|
||||||
int nitems; /* Num items */
|
int nitems; /* Num items */
|
||||||
int iter; /* Iterator */
|
int iter; /* Iterator */
|
||||||
|
|
@ -52,7 +52,6 @@ CopyList(DOH *lo) {
|
||||||
l = (List *) lo;
|
l = (List *) lo;
|
||||||
nl = (List *) DohObjMalloc(sizeof(List));
|
nl = (List *) DohObjMalloc(sizeof(List));
|
||||||
nl->objinfo = l->objinfo;
|
nl->objinfo = l->objinfo;
|
||||||
DohXInit(nl);
|
|
||||||
nl->nitems = l->nitems;
|
nl->nitems = l->nitems;
|
||||||
nl->maxitems = l->maxitems;
|
nl->maxitems = l->maxitems;
|
||||||
nl->items = (void **) DohMalloc(l->maxitems*sizeof(void *));
|
nl->items = (void **) DohMalloc(l->maxitems*sizeof(void *));
|
||||||
|
|
@ -86,7 +85,6 @@ DelList(DOH *lo) {
|
||||||
}
|
}
|
||||||
DohFree(l->items);
|
DohFree(l->items);
|
||||||
l->items = 0;
|
l->items = 0;
|
||||||
Delete(l->file);
|
|
||||||
DohObjFree(l);
|
DohObjFree(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -318,7 +316,6 @@ static DohObjInfo ListType = {
|
||||||
DelList, /* doh_del */
|
DelList, /* doh_del */
|
||||||
CopyList, /* doh_copy */
|
CopyList, /* doh_copy */
|
||||||
List_clear, /* doh_clear */
|
List_clear, /* doh_clear */
|
||||||
0, /* doh_scope */
|
|
||||||
List_str, /* doh_str */
|
List_str, /* doh_str */
|
||||||
0, /* doh_data */
|
0, /* doh_data */
|
||||||
List_dump, /* doh_dump */
|
List_dump, /* doh_dump */
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,7 @@ DohObjFree(DOH *ptr) {
|
||||||
DohTrace(DOH_MEMORY,"DohObjFree. %x not properly defined. No objinfo structure.\n", ptr);
|
DohTrace(DOH_MEMORY,"DohObjFree. %x not properly defined. No objinfo structure.\n", ptr);
|
||||||
return; /* Improperly initialized object. leak some more */
|
return; /* Improperly initialized object. leak some more */
|
||||||
}
|
}
|
||||||
|
if (b->file) DohDelete(b->file);
|
||||||
f = (Fragment *) DohMalloc(sizeof(Fragment));
|
f = (Fragment *) DohMalloc(sizeof(Fragment));
|
||||||
f->ptr = (char *) ptr;
|
f->ptr = (char *) ptr;
|
||||||
f->len = (b->objinfo->objsize + 7) & ~0x07;
|
f->len = (b->objinfo->objsize + 7) & ~0x07;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ static char cvsroot[] = "$Header$";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct String {
|
typedef struct String {
|
||||||
DOHXCOMMON;
|
DOHCOMMON;
|
||||||
int maxsize; /* Max size allocated */
|
int maxsize; /* Max size allocated */
|
||||||
int len; /* Current length */
|
int len; /* Current length */
|
||||||
int hashkey; /* Hash key value */
|
int hashkey; /* Hash key value */
|
||||||
|
|
@ -83,7 +83,6 @@ static DohObjInfo StringType = {
|
||||||
DelString, /* doh_del */
|
DelString, /* doh_del */
|
||||||
CopyString, /* doh_copy */
|
CopyString, /* doh_copy */
|
||||||
String_clear, /* doh_clear */
|
String_clear, /* doh_clear */
|
||||||
0, /* doh_scope */
|
|
||||||
String_str, /* doh_str */
|
String_str, /* doh_str */
|
||||||
String_data, /* doh_data */
|
String_data, /* doh_data */
|
||||||
String_dump, /* doh_dump */
|
String_dump, /* doh_dump */
|
||||||
|
|
@ -148,7 +147,6 @@ NewString(const DOH *so)
|
||||||
else s = (char *) so;
|
else s = (char *) so;
|
||||||
str = (String *) DohObjMalloc(sizeof(String));
|
str = (String *) DohObjMalloc(sizeof(String));
|
||||||
str->objinfo = &StringType;
|
str->objinfo = &StringType;
|
||||||
DohXInit(str);
|
|
||||||
str->hashkey = -1;
|
str->hashkey = -1;
|
||||||
str->sp = 0;
|
str->sp = 0;
|
||||||
str->line = 1;
|
str->line = 1;
|
||||||
|
|
@ -226,7 +224,6 @@ DelString(DOH *so) {
|
||||||
if (s->str)
|
if (s->str)
|
||||||
DohFree(s->str);
|
DohFree(s->str);
|
||||||
s->str = 0;
|
s->str = 0;
|
||||||
Delete(s->file);
|
|
||||||
DohObjFree(s);
|
DohObjFree(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,11 +321,9 @@ add(String *s, const char *newstr) {
|
||||||
}
|
}
|
||||||
strcpy(s->str+s->len,newstr);
|
strcpy(s->str+s->len,newstr);
|
||||||
if (s->sp >= s->len) {
|
if (s->sp >= s->len) {
|
||||||
#ifdef DOH_STRING_UPDATE_LINES
|
|
||||||
for (i = s->sp; i < s->len+l; i++) {
|
for (i = s->sp; i < s->len+l; i++) {
|
||||||
if (s->str[i] == '\n') s->line++;
|
if (s->str[i] == '\n') s->line++;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
s->sp = s->len+l;
|
s->sp = s->len+l;
|
||||||
}
|
}
|
||||||
s->len += l;
|
s->len += l;
|
||||||
|
|
@ -348,9 +343,7 @@ String_addchar(DOH *so, char c) {
|
||||||
if (s->sp >= s->len) {
|
if (s->sp >= s->len) {
|
||||||
s->sp = s->len+1;
|
s->sp = s->len+1;
|
||||||
s->str[s->len+1] = 0;
|
s->str[s->len+1] = 0;
|
||||||
#ifdef DOH_STRING_UPDATE_LINES
|
|
||||||
if (c == '\n') s->line++;
|
if (c == '\n') s->line++;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
s->len++;
|
s->len++;
|
||||||
}
|
}
|
||||||
|
|
@ -406,11 +399,9 @@ raw_insert(String *s, int pos, char *data, int len)
|
||||||
if (s->sp >= pos) {
|
if (s->sp >= pos) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef DOH_STRING_UPDATE_LINES
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
if (data[i] == '\n') s->line++;
|
if (data[i] == '\n') s->line++;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
s->sp+=len;
|
s->sp+=len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -458,9 +449,7 @@ int String_delitem(DOH *so, int pos)
|
||||||
if (s->sp > pos) {
|
if (s->sp > pos) {
|
||||||
s->sp--;
|
s->sp--;
|
||||||
assert (s->sp >= 0);
|
assert (s->sp >= 0);
|
||||||
#ifdef DOH_STRING_UPDATE_LINES
|
|
||||||
if (s->str[pos] == '\n') s->line--;
|
if (s->str[pos] == '\n') s->line--;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
memmove(s->str+pos, s->str+pos+1, ((s->len-1) - pos));
|
memmove(s->str+pos, s->str+pos+1, ((s->len-1) - pos));
|
||||||
s->len--;
|
s->len--;
|
||||||
|
|
@ -534,9 +523,7 @@ String_write(DOH *so, void *buffer, int len) {
|
||||||
int
|
int
|
||||||
String_seek(DOH *so, long offset, int whence) {
|
String_seek(DOH *so, long offset, int whence) {
|
||||||
int pos, nsp, inc;
|
int pos, nsp, inc;
|
||||||
#ifdef DOH_STRING_UPDATE_LINES
|
|
||||||
int prev;
|
int prev;
|
||||||
#endif
|
|
||||||
String *s = (String *) so;
|
String *s = (String *) so;
|
||||||
if (whence == SEEK_SET) pos = 0;
|
if (whence == SEEK_SET) pos = 0;
|
||||||
else if (whence == SEEK_CUR) pos = s->sp;
|
else if (whence == SEEK_CUR) pos = s->sp;
|
||||||
|
|
@ -554,16 +541,12 @@ String_seek(DOH *so, long offset, int whence) {
|
||||||
|
|
||||||
inc = (nsp > s->sp) ? 1 : -1;
|
inc = (nsp > s->sp) ? 1 : -1;
|
||||||
|
|
||||||
#ifdef DOH_STRING_UPDATE_LINES
|
|
||||||
while (s->sp != nsp) {
|
while (s->sp != nsp) {
|
||||||
prev = s->sp + inc;
|
prev = s->sp + inc;
|
||||||
if (prev>=0 && prev<=s->len && s->str[prev] == '\n')
|
if (prev>=0 && prev<=s->len && s->str[prev] == '\n')
|
||||||
s->line += inc;
|
s->line += inc;
|
||||||
s->sp += inc;
|
s->sp += inc;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
s->sp = nsp;
|
|
||||||
#endif
|
|
||||||
assert (s->sp >= 0);
|
assert (s->sp >= 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -594,9 +577,7 @@ String_putc(DOH *so, int ch) {
|
||||||
} else {
|
} else {
|
||||||
s->str[s->sp] = (char) ch;
|
s->str[s->sp] = (char) ch;
|
||||||
s->sp++;
|
s->sp++;
|
||||||
#ifdef DOH_STRING_UPDATE_LINES
|
|
||||||
if (ch == '\n') s->line++;
|
if (ch == '\n') s->line++;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
@ -615,9 +596,7 @@ int String_getc(DOH *so) {
|
||||||
c = EOF;
|
c = EOF;
|
||||||
else
|
else
|
||||||
c = (int) s->str[s->sp++];
|
c = (int) s->str[s->sp++];
|
||||||
#ifdef DOH_STRING_UPDATE_LINES
|
|
||||||
if (c == '\n') s->line++;
|
if (c == '\n') s->line++;
|
||||||
#endif
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -631,9 +610,7 @@ int String_ungetc(DOH *so, int ch) {
|
||||||
if (ch == EOF) return ch;
|
if (ch == EOF) return ch;
|
||||||
if (s->sp <= 0) return EOF;
|
if (s->sp <= 0) return EOF;
|
||||||
s->sp--;
|
s->sp--;
|
||||||
#ifdef DOH_STRING_UPDATE_LINES
|
|
||||||
if (ch == '\n') s->line--;
|
if (ch == '\n') s->line--;
|
||||||
#endif
|
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -795,9 +772,7 @@ String_chop(DOH *s) {
|
||||||
while ((str->len > 0) && (isspace(*c))) {
|
while ((str->len > 0) && (isspace(*c))) {
|
||||||
if (str->sp >= str->len) {
|
if (str->sp >= str->len) {
|
||||||
str->sp--;
|
str->sp--;
|
||||||
#ifdef DOH_STRING_UPDATE_LINES
|
|
||||||
if (*c == '\n') str->line--;
|
if (*c == '\n') str->line--;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
str->len--;
|
str->len--;
|
||||||
c--;
|
c--;
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ static DohObjInfo DohVoidType = {
|
||||||
Void_delete, /* doh_del */
|
Void_delete, /* doh_del */
|
||||||
Void_copy, /* doh_copy */
|
Void_copy, /* doh_copy */
|
||||||
0, /* doh_clear */
|
0, /* doh_clear */
|
||||||
0, /* doh_scope */
|
|
||||||
0, /* doh_str */
|
0, /* doh_str */
|
||||||
Void_data, /* doh_data */
|
Void_data, /* doh_data */
|
||||||
0, /* doh_dump */
|
0, /* doh_dump */
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,16 @@ extern "C" {
|
||||||
|
|
||||||
typedef void DOH;
|
typedef void DOH;
|
||||||
|
|
||||||
/* Symbolic names used to clarify the reading of code using DOH objects */
|
/*
|
||||||
|
* With dynamic typing, all DOH objects are technically of type 'void *'.
|
||||||
|
* However, to clarify the reading of source code, the following symbolic
|
||||||
|
* names are used.
|
||||||
|
*/
|
||||||
|
|
||||||
#define DOHString DOH
|
#define DOHString DOH
|
||||||
#define DOHList DOH
|
#define DOHList DOH
|
||||||
#define DOHHash DOH
|
#define DOHHash DOH
|
||||||
#define DOHFile DOH
|
#define DOHFile DOH
|
||||||
#define DOHFunction DOH
|
|
||||||
#define DOHVoid DOH
|
#define DOHVoid DOH
|
||||||
#define DOHString_or_char DOH
|
#define DOHString_or_char DOH
|
||||||
#define DOHObj_or_char DOH
|
#define DOHObj_or_char DOH
|
||||||
|
|
@ -67,14 +70,14 @@ typedef struct {
|
||||||
|
|
||||||
/* File methods */
|
/* File methods */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int (*doh_read)(DOH *obj, void *buffer, int nbytes);
|
int (*doh_read)(DOH *obj, void *buffer, int nbytes); /* Read bytes */
|
||||||
int (*doh_write)(DOH *obj, void *buffer, int nbytes);
|
int (*doh_write)(DOH *obj, void *buffer, int nbytes); /* Write bytes */
|
||||||
int (*doh_putc)(DOH *obj, int ch);
|
int (*doh_putc)(DOH *obj, int ch); /* Put character */
|
||||||
int (*doh_getc)(DOH *obj);
|
int (*doh_getc)(DOH *obj); /* Get character */
|
||||||
int (*doh_ungetc)(DOH *obj, int ch);
|
int (*doh_ungetc)(DOH *obj, int ch); /* Unget character */
|
||||||
int (*doh_seek)(DOH *obj, long offset, int whence);
|
int (*doh_seek)(DOH *obj, long offset, int whence); /* Seek */
|
||||||
long (*doh_tell)(DOH *obj);
|
long (*doh_tell)(DOH *obj); /* Tell */
|
||||||
int (*doh_close)(DOH *obj);
|
int (*doh_close)(DOH *obj); /* Close */
|
||||||
} DohFileMethods;
|
} DohFileMethods;
|
||||||
|
|
||||||
/* String methods */
|
/* String methods */
|
||||||
|
|
@ -83,19 +86,6 @@ typedef struct {
|
||||||
void (*doh_chop)(DOH *obj);
|
void (*doh_chop)(DOH *obj);
|
||||||
} DohStringMethods;
|
} DohStringMethods;
|
||||||
|
|
||||||
/* Callable */
|
|
||||||
typedef struct {
|
|
||||||
DOH *(*doh_call)(DOH *obj, DOH *args); /* Callable */
|
|
||||||
} DohCallableMethods;
|
|
||||||
|
|
||||||
/* Positional */
|
|
||||||
typedef struct {
|
|
||||||
void (*doh_setfile)(DOH *obj, DOH *file);
|
|
||||||
DOH *(*doh_getfile)(DOH *obj);
|
|
||||||
void (*doh_setline)(DOH *obj, int line);
|
|
||||||
int (*doh_getline)(DOH *obj);
|
|
||||||
} DohPositionalMethods;
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DohObjInfo
|
* DohObjInfo
|
||||||
*
|
*
|
||||||
|
|
@ -111,7 +101,6 @@ typedef struct DohObjInfo {
|
||||||
void (*doh_del)(DOH *obj); /* Delete object */
|
void (*doh_del)(DOH *obj); /* Delete object */
|
||||||
DOH *(*doh_copy)(DOH *obj); /* Copy and object */
|
DOH *(*doh_copy)(DOH *obj); /* Copy and object */
|
||||||
void (*doh_clear)(DOH *obj); /* Clear an object */
|
void (*doh_clear)(DOH *obj); /* Clear an object */
|
||||||
void (*doh_scope)(DOH *obj, int sc); /* Scope */
|
|
||||||
|
|
||||||
/* Output methods */
|
/* Output methods */
|
||||||
DOH *(*doh_str)(DOH *obj); /* Make a full string */
|
DOH *(*doh_str)(DOH *obj); /* Make a full string */
|
||||||
|
|
@ -130,8 +119,8 @@ typedef struct DohObjInfo {
|
||||||
DohSequenceMethods *doh_sequence; /* Sequence methods */
|
DohSequenceMethods *doh_sequence; /* Sequence methods */
|
||||||
DohFileMethods *doh_file; /* File methods */
|
DohFileMethods *doh_file; /* File methods */
|
||||||
DohStringMethods *doh_string; /* String methods */
|
DohStringMethods *doh_string; /* String methods */
|
||||||
DohCallableMethods *doh_callable; /* Callable methods */
|
void *reserved2;
|
||||||
DohPositionalMethods *doh_position; /* Positional methods */
|
void *reserved3;
|
||||||
void *reserved4;
|
void *reserved4;
|
||||||
void *reserved5;
|
void *reserved5;
|
||||||
void *reserved6;
|
void *reserved6;
|
||||||
|
|
@ -142,6 +131,7 @@ typedef struct DohObjInfo {
|
||||||
} DohObjInfo;
|
} DohObjInfo;
|
||||||
|
|
||||||
/* Memory management */
|
/* Memory management */
|
||||||
|
|
||||||
extern void *DohMalloc(size_t size); /* Allocate memory */
|
extern void *DohMalloc(size_t size); /* Allocate memory */
|
||||||
extern void *DohRealloc(void *, size_t size); /* Reallocate memory */
|
extern void *DohRealloc(void *, size_t size); /* Reallocate memory */
|
||||||
extern void DohFree(DOH *ptr); /* Free memory */
|
extern void DohFree(DOH *ptr); /* Free memory */
|
||||||
|
|
@ -149,7 +139,6 @@ typedef struct DohObjInfo {
|
||||||
extern void DohObjFree(DOH *ptr); /* Free a DOH object */
|
extern void DohObjFree(DOH *ptr); /* Free a DOH object */
|
||||||
extern int DohObjFreeCheck(DOH *ptr); /* Check if already free */
|
extern int DohObjFreeCheck(DOH *ptr); /* Check if already free */
|
||||||
extern void DohInit(DOH *obj); /* Initialize an object */
|
extern void DohInit(DOH *obj); /* Initialize an object */
|
||||||
extern void DohXInit(DOH *obj); /* Initialize extended object */
|
|
||||||
extern int DohCheck(const DOH *ptr); /* Check if a DOH object */
|
extern int DohCheck(const DOH *ptr); /* Check if a DOH object */
|
||||||
extern int DohPoolSize(int); /* Set memory alloc size */
|
extern int DohPoolSize(int); /* Set memory alloc size */
|
||||||
extern void DohIntern(DOH *); /* Intern an object */
|
extern void DohIntern(DOH *); /* Intern an object */
|
||||||
|
|
@ -201,11 +190,7 @@ typedef struct DohObjInfo {
|
||||||
extern int DohPutc(int ch, DOHFile *obj);
|
extern int DohPutc(int ch, DOHFile *obj);
|
||||||
extern int DohUngetc(int ch, DOHFile *obj);
|
extern int DohUngetc(int ch, DOHFile *obj);
|
||||||
|
|
||||||
/* Callable Methods */
|
/* Positional */
|
||||||
|
|
||||||
extern DOH *DohCall(DOHFunction *obj, DOH *args);
|
|
||||||
|
|
||||||
/* Position Methods */
|
|
||||||
|
|
||||||
extern int DohGetline(DOH *obj);
|
extern int DohGetline(DOH *obj);
|
||||||
extern void DohSetline(DOH *obj, int line);
|
extern void DohSetline(DOH *obj, int line);
|
||||||
|
|
@ -233,7 +218,6 @@ typedef struct DohObjInfo {
|
||||||
extern int DohIsSequence(const DOH *obj);
|
extern int DohIsSequence(const DOH *obj);
|
||||||
extern int DohIsString(const DOH *obj);
|
extern int DohIsString(const DOH *obj);
|
||||||
extern int DohIsFile(const DOH *obj);
|
extern int DohIsFile(const DOH *obj);
|
||||||
extern int DohIsCallable(const DOH *obj);
|
|
||||||
|
|
||||||
#ifndef DOH_LONG_NAMES
|
#ifndef DOH_LONG_NAMES
|
||||||
/* Macros to invoke the above functions. Includes the location of
|
/* Macros to invoke the above functions. Includes the location of
|
||||||
|
|
@ -286,7 +270,6 @@ typedef struct DohObjInfo {
|
||||||
#define Readline DohReadline
|
#define Readline DohReadline
|
||||||
#define Replace DohReplace
|
#define Replace DohReplace
|
||||||
#define Chop DohChop
|
#define Chop DohChop
|
||||||
#define Call DohCall
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -299,21 +282,14 @@ typedef struct DohObjInfo {
|
||||||
DohObjInfo *objinfo; \
|
DohObjInfo *objinfo; \
|
||||||
DOH *nextptr; \
|
DOH *nextptr; \
|
||||||
int refcount; \
|
int refcount; \
|
||||||
|
DOH *file; \
|
||||||
|
int line; \
|
||||||
unsigned char flags
|
unsigned char flags
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DOHCOMMON;
|
DOHCOMMON;
|
||||||
} DohBase;
|
} DohBase;
|
||||||
|
|
||||||
#define DOHXCOMMON \
|
|
||||||
DOHCOMMON; \
|
|
||||||
DOH *file; \
|
|
||||||
int line
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
DOHXCOMMON;
|
|
||||||
} DohXBase;
|
|
||||||
|
|
||||||
/* Macros for decrefing and increfing (safe for null objects). */
|
/* Macros for decrefing and increfing (safe for null objects). */
|
||||||
#define Decref(a) if (a) ((DohBase *) a)->refcount--
|
#define Decref(a) if (a) ((DohBase *) a)->refcount--
|
||||||
#define Incref(a) if (a) ((DohBase *) a)->refcount++
|
#define Incref(a) if (a) ((DohBase *) a)->refcount++
|
||||||
|
|
@ -379,12 +355,6 @@ extern DOHList *DohSplit(DOHFile *input, char *chs, int nsplits);
|
||||||
|
|
||||||
extern DOH *DohNone;
|
extern DOH *DohNone;
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* Callable
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
extern DOHFunction *NewCallable(DOH *(*func)(DOH *, DOH *));
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Error handling levels.
|
* Error handling levels.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue