From 35fad48fafe5a8c90ae0992833a94db2c919995d Mon Sep 17 00:00:00 2001 From: Dave Beazley Date: Fri, 14 Jan 2000 04:29:03 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@96 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DOH/README | 75 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 6 deletions(-) diff --git a/Source/DOH/README b/Source/DOH/README index 282e74bc3..53ac4b705 100644 --- a/Source/DOH/README +++ b/Source/DOH/README @@ -3,31 +3,49 @@ DOH (Dave's Object Hack) Overview: --------- DOH is a small C library that provides a number of simple yet powerful -data structures for building flexible applications. The data -structures are built around a dynamic typing model in which any given -object is allowed to support one or more classes of operations. +data structures. The data structures are built around a dynamic typing +model in which any given object is allowed to support one or more +classes of operations. Furthermore, a simple garbage collection +scheme and a variety of interesting library methods are available. +All and all, the operation of DOH makes massive abuse of the C type +system and would probably make the language purists scream and +performance addicts run away in horror. However, I really don't +care--so there! However, for the rest of us, DOH is actually kind of +fun to use. This is only a short description of the methods and is no +way meant to be exhaustive. Common Operations (for all types) --------------------------------- Delete(obj) Decrease the reference count and destroy if zero Copy(obj) Make a copy of an object. Clear(obj) Clear an object. +Setscope(obj) Set scope of an object (guru's only) Str(obj) Create a string representation of obj. Data(obj) Return pointer to raw data in an object +Char(obj) Convert to a char * Len(obj) Length of an object Hash(obj) Hash value (used for mapping) Cmp(obj1,obj2) Compare two objects. Name(obj) Return the object name First(obj) Return first object (iterator) Next(obj) Return next object +Dump(obj,out) Serialize on out +Load(in) Unserialize from in Mapping Operations (for hash table behavior) -------------------------------------------- Getattr(hash,key) Get an attribute Setattr(hash,key,value) Set an attribute Delattr(hash,key) Delete an attribute -Firstkey(hash,key) Get first key -Nextkey(hash,key) Get next key +Firstkey(hash) Get first key +Nextkey(hash) Get next key +First(hash) Get first object +Next(hash) Get next object +GetInt(hash,key) Get attribute as an 'int' +SetInt(hash,key,ivalue) Set attribute as an 'int' +GetDouble(hash,key) Get attribute as a 'double' +SetDouble(hash,key,dvalue) Set Attribute as a 'double' +GetChar(hash,key) Get attribute as a 'char *' Sequence Operations ------------------- @@ -36,6 +54,7 @@ Setitem(list,index,val) Set an item Delitem(list,index,val) Delete an item Insert(list,index,val) Insert an item Append(list,val) Append to end +Push(list,val) Insert at beginning File Operations --------------- @@ -46,9 +65,53 @@ Putc(ch,obj) Put a character Ungetc(ch,obj) Put character back on input stream Seek(obj,offset,whence) Seek Tell(obj) Return file pointer -Printf(obj,format,...) Printf Close(obj) Close +String Operations +----------------- +Replace(obj, orig, rep, flags) Replace occurences of orig with rep. +Chop(obj) Remove trailing whitespace + +flags is one of the following: + DOH_REPLACE_ANY + DOH_REPLACE_NOQUOTE + DOH_REPLACE_ID + DOH_REPLACE_FIRST + +Callable Operations +------------------- +Call(obj, args) Perform a function call with arguments args. + +Miscellaneous library functions +------------------------------- +NewScope() Create a new scope +DelScope(s) Delete scope s +Readline(in) Read a line of input from in +Printf(out,fmt,...) Formatted output +DohEncoding(name, fn) Register a format encoding for Printf + +Currently Available datatypes +------------------------------ +NewString(char *initial) Strings +NewHash() Hash +NewList() List +NewVoid(void *ptr, void (*del)(void *)) Void +NewFile(char *file, char *mode) File +NewCallable(DOH *(*func)(DOH *, DOH *)) Callable object + + +Odds and ends: + + 1. All objects are of type 'DOH *' + 2. When in doubt, see rule (1) + 3. In certain cases, DOH performs implicit conversions + of 'char *' to an appropriate DOH string representation. + For operations involving files, DOH works with many + kinds of objects including FILE *, DOH File objects, + and DOH strings. Don't even ask how this works. + + 4. More complete documentation is forthcoming. +