*** empty log message ***
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@25 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
762c41903d
commit
d3c2185d00
9 changed files with 107 additions and 112 deletions
|
|
@ -21,7 +21,7 @@
|
||||||
* Methods for base objects
|
* Methods for base objects
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include "doh.h"
|
#include "dohint.h"
|
||||||
|
|
||||||
int doh_debug_level = 0;
|
int doh_debug_level = 0;
|
||||||
|
|
||||||
|
|
@ -48,14 +48,15 @@ static DohObjInfo DohBaseType = {
|
||||||
0, /* doh_str */
|
0, /* doh_str */
|
||||||
0, /* doh_data */
|
0, /* doh_data */
|
||||||
0, /* doh_dump */
|
0, /* doh_dump */
|
||||||
|
0, /* doh_load */
|
||||||
0, /* doh_len */
|
0, /* doh_len */
|
||||||
0, /* doh_hash */
|
0, /* doh_hash */
|
||||||
0, /* doh_cmp */
|
0, /* doh_cmp */
|
||||||
0, /* doh_mapping */
|
0, /* doh_mapping */
|
||||||
0, /* doh_sequence */
|
0, /* doh_sequence */
|
||||||
0, /* doh_file */
|
0, /* doh_file */
|
||||||
0, /* reserved2 */
|
0, /* doh_string */
|
||||||
0, /* reserved3 */
|
0, /* doh_callable */
|
||||||
0, /* reserved4 */
|
0, /* reserved4 */
|
||||||
0, /* reserved5 */
|
0, /* reserved5 */
|
||||||
0, /* reserved6 */
|
0, /* reserved6 */
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* can be used and distributed.
|
* can be used and distributed.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "doh.h"
|
#include "dohint.h"
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------
|
/* ---------------------------------------------------------------------------
|
||||||
* $Header$
|
* $Header$
|
||||||
|
|
@ -53,24 +53,23 @@ static DohFileMethods FileFileMethods = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static DohObjInfo FileType = {
|
static DohObjInfo FileType = {
|
||||||
"File", /* objname */
|
"File", /* objname */
|
||||||
sizeof(File), /* objsize */
|
sizeof(File), /* objsize */
|
||||||
DelFile, /* sm_del */
|
DelFile, /* doh_del */
|
||||||
0, /* sm_copy */
|
0, /* doh_copy */
|
||||||
0, /* sm_clear */
|
0, /* doh_clear */
|
||||||
0, /* sm_str */
|
0, /* doh_str */
|
||||||
0, /* doh_data */
|
0, /* doh_data */
|
||||||
0, /* doh_dump */
|
0, /* doh_dump */
|
||||||
0, /* sm_len */
|
0, /* doh_load */
|
||||||
0, /* sm_hash */
|
0, /* doh_len */
|
||||||
0, /* doh_cmp */
|
0, /* doh_hash */
|
||||||
0, /* doh_mapping */
|
0, /* doh_cmp */
|
||||||
0, /* doh_sequence */
|
0, /* doh_mapping */
|
||||||
&FileFileMethods,/* doh_file */
|
0, /* doh_sequence */
|
||||||
0,
|
&FileFileMethods,/* doh_file */
|
||||||
0,
|
0, /* doh_string */
|
||||||
0,
|
0, /* doh_callable */
|
||||||
0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DohObjInfo *File_type() {
|
DohObjInfo *File_type() {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* can be used and distributed.
|
* can be used and distributed.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "doh.h"
|
#include "dohint.h"
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* fio.c
|
* fio.c
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* can be used and distributed.
|
* can be used and distributed.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "doh.h"
|
#include "dohint.h"
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* $Header$
|
* $Header$
|
||||||
|
|
@ -84,22 +84,21 @@ static DohMappingMethods HashMappingMethods = {
|
||||||
static DohObjInfo HashType = {
|
static DohObjInfo HashType = {
|
||||||
"Hash", /* objname */
|
"Hash", /* objname */
|
||||||
sizeof(Hash), /* size */
|
sizeof(Hash), /* size */
|
||||||
DelHash, /* sm_del */
|
DelHash, /* doh_del */
|
||||||
CopyHash, /* sm_copy */
|
CopyHash, /* doh_copy */
|
||||||
Hash_clear, /* sm_clear */
|
Hash_clear, /* doh_clear */
|
||||||
Hash_str, /* sm_str */
|
Hash_str, /* doh_str */
|
||||||
0, /* doh_data */
|
0, /* doh_data */
|
||||||
0, /* doh_dump */
|
0, /* doh_dump */
|
||||||
Hash_len, /* sm_len */
|
0, /* doh_load */
|
||||||
0, /* sm_hash */
|
Hash_len, /* doh_len */
|
||||||
|
0, /* doh_hash */
|
||||||
0, /* doh_cmp */
|
0, /* doh_cmp */
|
||||||
&HashMappingMethods, /* doh_mapping */
|
&HashMappingMethods, /* doh_mapping */
|
||||||
0, /* doh_sequence */
|
0, /* doh_sequence */
|
||||||
0,
|
0, /* doh_file */
|
||||||
0,
|
0, /* doh_string */
|
||||||
0,
|
0, /* doh_callable */
|
||||||
0,
|
|
||||||
0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DohObjInfo *Hash_type() {
|
DohObjInfo *Hash_type() {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
* General purpose structure for keeping a list of reference counted Swig objects.
|
* General purpose structure for keeping a list of reference counted Swig objects.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include "doh.h"
|
#include "dohint.h"
|
||||||
|
|
||||||
typedef struct List {
|
typedef struct List {
|
||||||
DOHCOMMON;
|
DOHCOMMON;
|
||||||
|
|
@ -60,22 +60,20 @@ static DohSequenceMethods ListSeqMethods = {
|
||||||
static DohObjInfo ListType = {
|
static DohObjInfo ListType = {
|
||||||
"List", /* objname */
|
"List", /* objname */
|
||||||
sizeof(List), /* List size */
|
sizeof(List), /* List size */
|
||||||
DelList, /* sm_del */
|
DelList, /* doh_del */
|
||||||
CopyList, /* sm_copy */
|
CopyList, /* doh_copy */
|
||||||
List_clear, /* sm_clear */
|
List_clear, /* doh_clear */
|
||||||
List_str, /* sm_str */
|
List_str, /* doh_str */
|
||||||
0, /* doh_data */
|
0, /* doh_data */
|
||||||
List_dump, /* doh_dump */
|
List_dump, /* doh_dump */
|
||||||
List_len, /* sm_len */
|
0, /* doh_load */
|
||||||
0, /* sm_hash */
|
List_len, /* doh_len */
|
||||||
|
0, /* doh_hash */
|
||||||
0, /* doh_cmp */
|
0, /* doh_cmp */
|
||||||
0, /* doh_mapping */
|
0, /* doh_mapping */
|
||||||
&ListSeqMethods, /* doh_sequence */
|
&ListSeqMethods, /* doh_sequence */
|
||||||
0,
|
0, /* doh_string */
|
||||||
0,
|
0, /* doh_callable */
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DohObjInfo *List_type() {
|
DohObjInfo *List_type() {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* can be used and distributed.
|
* can be used and distributed.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "doh.h"
|
#include "dohint.h"
|
||||||
|
|
||||||
#ifndef DOH_POOL_SIZE
|
#ifndef DOH_POOL_SIZE
|
||||||
#define DOH_POOL_SIZE 65536
|
#define DOH_POOL_SIZE 65536
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* can be used and distributed.
|
* can be used and distributed.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "doh.h"
|
#include "dohint.h"
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------
|
/* ---------------------------------------------------------------------------
|
||||||
* $Header$
|
* $Header$
|
||||||
|
|
@ -80,22 +80,21 @@ static DohFileMethods StringFileMethods = {
|
||||||
static DohObjInfo StringType = {
|
static DohObjInfo StringType = {
|
||||||
"String", /* objname */
|
"String", /* objname */
|
||||||
sizeof(String), /* objsize */
|
sizeof(String), /* objsize */
|
||||||
DelString, /* sm_del */
|
DelString, /* doh_del */
|
||||||
CopyString, /* sm_copy */
|
CopyString, /* doh_copy */
|
||||||
String_clear, /* sm_clear */
|
String_clear, /* doh_clear */
|
||||||
String_str, /* sm_str */
|
String_str, /* doh_str */
|
||||||
String_data, /* doh_data */
|
String_data, /* doh_data */
|
||||||
String_dump, /* doh_dump */
|
String_dump, /* doh_dump */
|
||||||
String_len, /* sm_len */
|
0, /* doh_load */
|
||||||
String_hash, /* sm_hash */
|
String_len, /* doh_len */
|
||||||
|
String_hash, /* doh_hash */
|
||||||
String_cmp, /* doh_cmp */
|
String_cmp, /* doh_cmp */
|
||||||
0, /* doh_mapping */
|
0, /* doh_mapping */
|
||||||
&StringSeqMethods, /* doh_sequence */
|
&StringSeqMethods, /* doh_sequence */
|
||||||
&StringFileMethods,/* doh_file */
|
&StringFileMethods,/* doh_file */
|
||||||
0,
|
0, /* doh_string */
|
||||||
0,
|
0, /* doh_callable */
|
||||||
0,
|
|
||||||
0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define INIT_MAXSIZE 16
|
#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;
|
if (flags & DOH_REPLACE_FIRST) count = 1;
|
||||||
replace_internal(str,Char(token),Char(rep),flags,str->str,count);
|
replace_internal(str,Char(token),Char(rep),flags,str->str,count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* void String_trim(DOH *str, char *front, char *back)
|
|
||||||
*
|
|
||||||
* Trim a string.
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* can be used and distributed.
|
* can be used and distributed.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "doh.h"
|
#include "dohint.h"
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* void.c
|
* void.c
|
||||||
|
|
@ -40,14 +40,15 @@ static DohObjInfo DohVoidType = {
|
||||||
0, /* doh_str */
|
0, /* doh_str */
|
||||||
Void_data, /* doh_data */
|
Void_data, /* doh_data */
|
||||||
0, /* doh_dump */
|
0, /* doh_dump */
|
||||||
|
0, /* doh_load */
|
||||||
0, /* doh_len */
|
0, /* doh_len */
|
||||||
0, /* doh_hash */
|
0, /* doh_hash */
|
||||||
0, /* doh_cmp */
|
0, /* doh_cmp */
|
||||||
0, /* doh_mapping */
|
0, /* doh_mapping */
|
||||||
0, /* doh_sequence */
|
0, /* doh_sequence */
|
||||||
0, /* doh_file */
|
0, /* doh_file */
|
||||||
0, /* reserved2 */
|
0, /* doh_string */
|
||||||
0, /* reserved3 */
|
0, /* doh_callable */
|
||||||
0, /* reserved4 */
|
0, /* reserved4 */
|
||||||
0, /* reserved5 */
|
0, /* reserved5 */
|
||||||
0, /* reserved6 */
|
0, /* reserved6 */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* DOH (Dynamic Object Hack)
|
* DOH (Dave's Object Hack)
|
||||||
*
|
*
|
||||||
* Author : David Beazley
|
* Author : David Beazley
|
||||||
*
|
*
|
||||||
|
|
@ -17,51 +17,48 @@
|
||||||
* $Header$
|
* $Header$
|
||||||
*
|
*
|
||||||
* doh.h
|
* doh.h
|
||||||
|
*
|
||||||
|
* DOH is really not much more than an interface. This file describes
|
||||||
|
* the interface.
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#ifndef _DOH_H
|
||||||
#include <stdio.h>
|
#define _DOH_H
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#ifndef DOH_H
|
|
||||||
#define DOH_H
|
|
||||||
|
|
||||||
#define DOH_MAJOR_VERSION 0
|
|
||||||
#define DOH_MINOR_VERSION 1
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DOH_MAJOR_VERSION 0
|
||||||
|
#define DOH_MINOR_VERSION 1
|
||||||
|
|
||||||
typedef void DOH;
|
typedef void DOH;
|
||||||
|
|
||||||
#define DOH_BEGIN -1
|
#define DOH_BEGIN -1
|
||||||
#define DOH_END -2
|
#define DOH_END -2
|
||||||
#define DOH_CUR -3
|
#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 {
|
typedef struct {
|
||||||
DOH *(*doh_getattr)(DOH *obj, DOH *name); /* Get attribute */
|
DOH *(*doh_getattr)(DOH *obj, DOH *name); /* Get attribute */
|
||||||
int (*doh_setattr)(DOH *obj, DOH *name, DOH *value); /* Set attribute */
|
int (*doh_setattr)(DOH *obj, DOH *name, DOH *value); /* Set attribute */
|
||||||
int (*doh_delattr)(DOH *obj, DOH *name); /* Del attribute */
|
int (*doh_delattr)(DOH *obj, DOH *name); /* Del attribute */
|
||||||
DOH *(*doh_firstkey)(DOH *obj); /* First key */
|
DOH *(*doh_firstkey)(DOH *obj); /* First key */
|
||||||
DOH *(*doh_nextkey)(DOH *obj); /* Next key */
|
DOH *(*doh_nextkey)(DOH *obj); /* Next key */
|
||||||
} DohMappingMethods;
|
} DohMappingMethods;
|
||||||
|
|
||||||
/* Sequence methods */
|
/* Sequence methods (i.e., lists) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DOH *(*doh_getitem)(DOH *obj, int index);
|
DOH *(*doh_getitem)(DOH *obj, int index); /* Get item */
|
||||||
int (*doh_setitem)(DOH *obj, int index, DOH *value);
|
int (*doh_setitem)(DOH *obj, int index, DOH *value); /* Set item */
|
||||||
int (*doh_delitem)(DOH *obj, int index);
|
int (*doh_delitem)(DOH *obj, int index); /* Delete item */
|
||||||
int (*doh_insitem)(DOH *obj, int index, DOH *value);
|
int (*doh_insitem)(DOH *obj, int index, DOH *value); /* Insert item */
|
||||||
DOH *(*doh_firstitem)(DOH *obj);
|
DOH *(*doh_firstitem)(DOH *obj); /* Iterators */
|
||||||
DOH *(*doh_nextitem)(DOH *obj);
|
DOH *(*doh_nextitem)(DOH *obj);
|
||||||
} DohSequenceMethods;
|
} DohSequenceMethods;
|
||||||
|
|
||||||
|
|
@ -77,25 +74,38 @@ typedef struct {
|
||||||
int (*doh_close)(DOH *obj);
|
int (*doh_close)(DOH *obj);
|
||||||
} DohFileMethods;
|
} 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
|
* 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 {
|
typedef struct DohObjInfo {
|
||||||
char *objname; /* Object name */
|
char *objname; /* Object name */
|
||||||
int objsize; /* Object size */
|
int objsize; /* Object size */
|
||||||
|
|
||||||
/* Basic object methods */
|
/* Basic object methods */
|
||||||
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 */
|
||||||
|
|
||||||
/* Output methods */
|
/* Output methods */
|
||||||
DOH *(*doh_str)(DOH *obj); /* Make a full string */
|
DOH *(*doh_str)(DOH *obj); /* Make a full string */
|
||||||
void *(*doh_data)(DOH *obj); /* Return raw data */
|
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 */
|
/* Length and hash values */
|
||||||
int (*doh_len)(DOH *obj);
|
int (*doh_len)(DOH *obj);
|
||||||
|
|
@ -104,11 +114,11 @@ typedef struct DohObjInfo {
|
||||||
/* Compare */
|
/* Compare */
|
||||||
int (*doh_cmp)(DOH *obj1, DOH *obj2);
|
int (*doh_cmp)(DOH *obj1, DOH *obj2);
|
||||||
|
|
||||||
DohMappingMethods *doh_mapping; /* Mapping methods */
|
DohMappingMethods *doh_mapping; /* Mapping methods */
|
||||||
DohSequenceMethods *doh_sequence; /* Sequence methods */
|
DohSequenceMethods *doh_sequence; /* Sequence methods */
|
||||||
DohFileMethods *doh_file; /* File methods */
|
DohFileMethods *doh_file; /* File methods */
|
||||||
void *reserved2; /* Number methods */
|
DohStringMethods *doh_string; /* String methods */
|
||||||
void *reserved3;
|
DohCallableMethods *doh_callable; /* Callable methods */
|
||||||
void *reserved4;
|
void *reserved4;
|
||||||
void *reserved5;
|
void *reserved5;
|
||||||
void *reserved6;
|
void *reserved6;
|
||||||
|
|
@ -237,9 +247,6 @@ extern DOH *DohReadline(DOH *in);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* #define Scanf DohScanf
|
|
||||||
#define vScanf DohvScanf*/
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* DohBase
|
* DohBase
|
||||||
*
|
*
|
||||||
|
|
@ -309,7 +316,6 @@ extern DOH *Hash_keys(DOH *);
|
||||||
|
|
||||||
extern DOH *NewVoid(void *ptr, void (*del)(void *));
|
extern DOH *NewVoid(void *ptr, void (*del)(void *));
|
||||||
|
|
||||||
|
|
||||||
extern DOH *DohSplit(DOH *input, char *chs, int nsplits);
|
extern DOH *DohSplit(DOH *input, char *chs, int nsplits);
|
||||||
#define Split DohSplit
|
#define Split DohSplit
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue