From a12b8f43ac57964ef5bb61da50845aabee7ae02c Mon Sep 17 00:00:00 2001 From: Dave Beazley Date: Fri, 19 Nov 1999 16:26:26 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@25 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DOH/Doh/base.c | 7 ++-- Source/DOH/Doh/file.c | 37 ++++++++--------- Source/DOH/Doh/fio.c | 2 +- Source/DOH/Doh/hash.c | 23 +++++----- Source/DOH/Doh/list.c | 22 +++++----- Source/DOH/Doh/memory.c | 2 +- Source/DOH/Doh/string.c | 29 +++++-------- Source/DOH/Doh/void.c | 7 ++-- Source/DOH/Include/doh.h | 90 +++++++++++++++++++++------------------- 9 files changed, 107 insertions(+), 112 deletions(-) diff --git a/Source/DOH/Doh/base.c b/Source/DOH/Doh/base.c index cf2053c7a..48a895ee2 100644 --- a/Source/DOH/Doh/base.c +++ b/Source/DOH/Doh/base.c @@ -21,7 +21,7 @@ * Methods for base objects *******************************************************************************/ -#include "doh.h" +#include "dohint.h" int doh_debug_level = 0; @@ -48,14 +48,15 @@ static DohObjInfo DohBaseType = { 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, /* reserved2 */ - 0, /* reserved3 */ + 0, /* doh_string */ + 0, /* doh_callable */ 0, /* reserved4 */ 0, /* reserved5 */ 0, /* reserved6 */ diff --git a/Source/DOH/Doh/file.c b/Source/DOH/Doh/file.c index b18570047..3a5b37131 100644 --- a/Source/DOH/Doh/file.c +++ b/Source/DOH/Doh/file.c @@ -13,7 +13,7 @@ * can be used and distributed. ****************************************************************************/ -#include "doh.h" +#include "dohint.h" /* --------------------------------------------------------------------------- * $Header$ @@ -53,24 +53,23 @@ static DohFileMethods FileFileMethods = { }; static DohObjInfo FileType = { - "File", /* objname */ - sizeof(File), /* objsize */ - DelFile, /* sm_del */ - 0, /* sm_copy */ - 0, /* sm_clear */ - 0, /* sm_str */ - 0, /* doh_data */ - 0, /* doh_dump */ - 0, /* sm_len */ - 0, /* sm_hash */ - 0, /* doh_cmp */ - 0, /* doh_mapping */ - 0, /* doh_sequence */ - &FileFileMethods,/* doh_file */ - 0, - 0, - 0, - 0, + "File", /* objname */ + sizeof(File), /* objsize */ + DelFile, /* doh_del */ + 0, /* doh_copy */ + 0, /* doh_clear */ + 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 */ + &FileFileMethods,/* doh_file */ + 0, /* doh_string */ + 0, /* doh_callable */ }; DohObjInfo *File_type() { diff --git a/Source/DOH/Doh/fio.c b/Source/DOH/Doh/fio.c index 41248f27b..bdcf6f030 100644 --- a/Source/DOH/Doh/fio.c +++ b/Source/DOH/Doh/fio.c @@ -13,7 +13,7 @@ * can be used and distributed. ****************************************************************************/ -#include "doh.h" +#include "dohint.h" /* ----------------------------------------------------------------------------- * fio.c diff --git a/Source/DOH/Doh/hash.c b/Source/DOH/Doh/hash.c index 4f621d1a0..8c86c4b23 100644 --- a/Source/DOH/Doh/hash.c +++ b/Source/DOH/Doh/hash.c @@ -13,7 +13,7 @@ * can be used and distributed. ****************************************************************************/ -#include "doh.h" +#include "dohint.h" /*********************************************************************** * $Header$ @@ -84,22 +84,21 @@ static DohMappingMethods HashMappingMethods = { static DohObjInfo HashType = { "Hash", /* objname */ sizeof(Hash), /* size */ - DelHash, /* sm_del */ - CopyHash, /* sm_copy */ - Hash_clear, /* sm_clear */ - Hash_str, /* sm_str */ + DelHash, /* doh_del */ + CopyHash, /* doh_copy */ + Hash_clear, /* doh_clear */ + Hash_str, /* doh_str */ 0, /* doh_data */ 0, /* doh_dump */ - Hash_len, /* sm_len */ - 0, /* sm_hash */ + 0, /* doh_load */ + Hash_len, /* doh_len */ + 0, /* doh_hash */ 0, /* doh_cmp */ &HashMappingMethods, /* doh_mapping */ 0, /* doh_sequence */ - 0, - 0, - 0, - 0, - 0, + 0, /* doh_file */ + 0, /* doh_string */ + 0, /* doh_callable */ }; DohObjInfo *Hash_type() { diff --git a/Source/DOH/Doh/list.c b/Source/DOH/Doh/list.c index 69eaece73..31d164264 100644 --- a/Source/DOH/Doh/list.c +++ b/Source/DOH/Doh/list.c @@ -21,7 +21,7 @@ * General purpose structure for keeping a list of reference counted Swig objects. *******************************************************************************/ -#include "doh.h" +#include "dohint.h" typedef struct List { DOHCOMMON; @@ -60,22 +60,20 @@ static DohSequenceMethods ListSeqMethods = { static DohObjInfo ListType = { "List", /* objname */ sizeof(List), /* List size */ - DelList, /* sm_del */ - CopyList, /* sm_copy */ - List_clear, /* sm_clear */ - List_str, /* sm_str */ + DelList, /* doh_del */ + CopyList, /* doh_copy */ + List_clear, /* doh_clear */ + List_str, /* doh_str */ 0, /* doh_data */ List_dump, /* doh_dump */ - List_len, /* sm_len */ - 0, /* sm_hash */ + 0, /* doh_load */ + List_len, /* doh_len */ + 0, /* doh_hash */ 0, /* doh_cmp */ 0, /* doh_mapping */ &ListSeqMethods, /* doh_sequence */ - 0, - 0, - 0, - 0, - 0, + 0, /* doh_string */ + 0, /* doh_callable */ }; DohObjInfo *List_type() { diff --git a/Source/DOH/Doh/memory.c b/Source/DOH/Doh/memory.c index 9164bcf46..c5a32cc16 100644 --- a/Source/DOH/Doh/memory.c +++ b/Source/DOH/Doh/memory.c @@ -13,7 +13,7 @@ * can be used and distributed. ****************************************************************************/ -#include "doh.h" +#include "dohint.h" #ifndef DOH_POOL_SIZE #define DOH_POOL_SIZE 65536 diff --git a/Source/DOH/Doh/string.c b/Source/DOH/Doh/string.c index e93a480bf..38ec03337 100644 --- a/Source/DOH/Doh/string.c +++ b/Source/DOH/Doh/string.c @@ -13,7 +13,7 @@ * can be used and distributed. ****************************************************************************/ -#include "doh.h" +#include "dohint.h" /* --------------------------------------------------------------------------- * $Header$ @@ -80,22 +80,21 @@ static DohFileMethods StringFileMethods = { static DohObjInfo StringType = { "String", /* objname */ sizeof(String), /* objsize */ - DelString, /* sm_del */ - CopyString, /* sm_copy */ - String_clear, /* sm_clear */ - String_str, /* sm_str */ + DelString, /* doh_del */ + CopyString, /* doh_copy */ + String_clear, /* doh_clear */ + String_str, /* doh_str */ String_data, /* doh_data */ String_dump, /* doh_dump */ - String_len, /* sm_len */ - String_hash, /* sm_hash */ + 0, /* doh_load */ + String_len, /* doh_len */ + String_hash, /* doh_hash */ String_cmp, /* doh_cmp */ 0, /* doh_mapping */ &StringSeqMethods, /* doh_sequence */ &StringFileMethods,/* doh_file */ - 0, - 0, - 0, - 0, + 0, /* doh_string */ + 0, /* doh_callable */ }; #define INIT_MAXSIZE 16 @@ -716,11 +715,3 @@ String_replace(DOH *stro, DOH *token, DOH *rep, int flags) if (flags & DOH_REPLACE_FIRST) count = 1; replace_internal(str,Char(token),Char(rep),flags,str->str,count); } - -/* ----------------------------------------------------------------------------- - * void String_trim(DOH *str, char *front, char *back) - * - * Trim a string. - * ----------------------------------------------------------------------------- */ - - diff --git a/Source/DOH/Doh/void.c b/Source/DOH/Doh/void.c index 14c324f29..82ee1052d 100644 --- a/Source/DOH/Doh/void.c +++ b/Source/DOH/Doh/void.c @@ -13,7 +13,7 @@ * can be used and distributed. ****************************************************************************/ -#include "doh.h" +#include "dohint.h" /* ----------------------------------------------------------------------------- * void.c @@ -40,14 +40,15 @@ static DohObjInfo DohVoidType = { 0, /* doh_str */ Void_data, /* 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, /* reserved2 */ - 0, /* reserved3 */ + 0, /* doh_string */ + 0, /* doh_callable */ 0, /* reserved4 */ 0, /* reserved5 */ 0, /* reserved6 */ diff --git a/Source/DOH/Include/doh.h b/Source/DOH/Include/doh.h index 0199cd13d..372519541 100644 --- a/Source/DOH/Include/doh.h +++ b/Source/DOH/Include/doh.h @@ -1,5 +1,5 @@ /******************************************************************************* - * DOH (Dynamic Object Hack) + * DOH (Dave's Object Hack) * * Author : David Beazley * @@ -17,51 +17,48 @@ * $Header$ * * doh.h + * + * DOH is really not much more than an interface. This file describes + * the interface. ***********************************************************************/ -#include -#include -#include -#include -#include -#include - -#ifndef DOH_H -#define DOH_H - -#define DOH_MAJOR_VERSION 0 -#define DOH_MINOR_VERSION 1 +#ifndef _DOH_H +#define _DOH_H #ifdef __cplusplus extern "C" { #endif +#define DOH_MAJOR_VERSION 0 +#define DOH_MINOR_VERSION 1 + typedef void DOH; #define DOH_BEGIN -1 #define DOH_END -2 #define DOH_CUR -3 +#define DOH_CURRENT -3 /* ----------------------------------------------------------------------------- - * Object classes + * These structures define the interface to various categories of objects. * ----------------------------------------------------------------------------- */ -/* Mapping Objects */ +/* Mapping Objects (i.e., hash tables) */ typedef struct { - DOH *(*doh_getattr)(DOH *obj, DOH *name); /* Get attribute */ - int (*doh_setattr)(DOH *obj, DOH *name, DOH *value); /* Set attribute */ - int (*doh_delattr)(DOH *obj, DOH *name); /* Del attribute */ - DOH *(*doh_firstkey)(DOH *obj); /* First key */ - DOH *(*doh_nextkey)(DOH *obj); /* Next key */ + DOH *(*doh_getattr)(DOH *obj, DOH *name); /* Get attribute */ + int (*doh_setattr)(DOH *obj, DOH *name, DOH *value); /* Set attribute */ + int (*doh_delattr)(DOH *obj, DOH *name); /* Del attribute */ + DOH *(*doh_firstkey)(DOH *obj); /* First key */ + DOH *(*doh_nextkey)(DOH *obj); /* Next key */ } DohMappingMethods; -/* Sequence methods */ +/* Sequence methods (i.e., lists) */ typedef struct { - DOH *(*doh_getitem)(DOH *obj, int index); - int (*doh_setitem)(DOH *obj, int index, DOH *value); - int (*doh_delitem)(DOH *obj, int index); - int (*doh_insitem)(DOH *obj, int index, DOH *value); - DOH *(*doh_firstitem)(DOH *obj); + DOH *(*doh_getitem)(DOH *obj, int index); /* Get item */ + int (*doh_setitem)(DOH *obj, int index, DOH *value); /* Set item */ + int (*doh_delitem)(DOH *obj, int index); /* Delete item */ + int (*doh_insitem)(DOH *obj, int index, DOH *value); /* Insert item */ + DOH *(*doh_firstitem)(DOH *obj); /* Iterators */ DOH *(*doh_nextitem)(DOH *obj); } DohSequenceMethods; @@ -77,25 +74,38 @@ typedef struct { int (*doh_close)(DOH *obj); } DohFileMethods; +/* String methods */ +typedef struct { + int (*doh_replace)(DOH *obj, DOH *old, DOH *rep, int flags); +} DohStringMethods; + +/* Callable */ +typedef struct { + DOH (*doh_call)(DOH *obj, DOH *args); /* Callable */ +} DohCallableMethods; + + /* ----------------------------------------------------------------------------- * DohObjInfo * - * Included in all DOH types. + * A pointer to this structure is included in all DOH types and is used to + * describe the properties of various objects. * ----------------------------------------------------------------------------- */ typedef struct DohObjInfo { - char *objname; /* Object name */ - int objsize; /* Object size */ + char *objname; /* Object name */ + int objsize; /* Object size */ /* Basic object methods */ - void (*doh_del)(DOH *obj); /* Delete object */ - DOH *(*doh_copy)(DOH *obj); /* Copy and object */ - void (*doh_clear)(DOH *obj); /* Clear an object */ + void (*doh_del)(DOH *obj); /* Delete object */ + DOH *(*doh_copy)(DOH *obj); /* Copy and object */ + void (*doh_clear)(DOH *obj); /* Clear an object */ /* Output methods */ DOH *(*doh_str)(DOH *obj); /* Make a full string */ void *(*doh_data)(DOH *obj); /* Return raw data */ - int (*doh_dump)(DOH *obj, DOH *out); /* Serialize on out */ + int (*doh_dump)(DOH *obj, DOH *out); /* Serialize on out */ + DOH *(*doh_load)(DOH *in); /* Unserialize from in */ /* Length and hash values */ int (*doh_len)(DOH *obj); @@ -104,11 +114,11 @@ typedef struct DohObjInfo { /* Compare */ int (*doh_cmp)(DOH *obj1, DOH *obj2); - DohMappingMethods *doh_mapping; /* Mapping methods */ - DohSequenceMethods *doh_sequence; /* Sequence methods */ - DohFileMethods *doh_file; /* File methods */ - void *reserved2; /* Number methods */ - void *reserved3; + DohMappingMethods *doh_mapping; /* Mapping methods */ + DohSequenceMethods *doh_sequence; /* Sequence methods */ + DohFileMethods *doh_file; /* File methods */ + DohStringMethods *doh_string; /* String methods */ + DohCallableMethods *doh_callable; /* Callable methods */ void *reserved4; void *reserved5; void *reserved6; @@ -237,9 +247,6 @@ extern DOH *DohReadline(DOH *in); #endif -/* #define Scanf DohScanf - #define vScanf DohvScanf*/ - /* ----------------------------------------------------------------------------- * DohBase * @@ -309,7 +316,6 @@ extern DOH *Hash_keys(DOH *); extern DOH *NewVoid(void *ptr, void (*del)(void *)); - extern DOH *DohSplit(DOH *input, char *chs, int nsplits); #define Split DohSplit