*** empty log message ***

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@96 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-01-14 04:29:03 +00:00
commit 35fad48faf

View file

@ -3,31 +3,49 @@ DOH (Dave's Object Hack)
Overview: Overview:
--------- ---------
DOH is a small C library that provides a number of simple yet powerful DOH is a small C library that provides a number of simple yet powerful
data structures for building flexible applications. The data data structures. The data structures are built around a dynamic typing
structures are built around a dynamic typing model in which any given model in which any given object is allowed to support one or more
object is allowed to support one or more classes of operations. 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) Common Operations (for all types)
--------------------------------- ---------------------------------
Delete(obj) Decrease the reference count and destroy if zero Delete(obj) Decrease the reference count and destroy if zero
Copy(obj) Make a copy of an object. Copy(obj) Make a copy of an object.
Clear(obj) Clear 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. Str(obj) Create a string representation of obj.
Data(obj) Return pointer to raw data in an object Data(obj) Return pointer to raw data in an object
Char(obj) Convert to a char *
Len(obj) Length of an object Len(obj) Length of an object
Hash(obj) Hash value (used for mapping) Hash(obj) Hash value (used for mapping)
Cmp(obj1,obj2) Compare two objects. Cmp(obj1,obj2) Compare two objects.
Name(obj) Return the object name Name(obj) Return the object name
First(obj) Return first object (iterator) First(obj) Return first object (iterator)
Next(obj) Return next object Next(obj) Return next object
Dump(obj,out) Serialize on out
Load(in) Unserialize from in
Mapping Operations (for hash table behavior) Mapping Operations (for hash table behavior)
-------------------------------------------- --------------------------------------------
Getattr(hash,key) Get an attribute Getattr(hash,key) Get an attribute
Setattr(hash,key,value) Set an attribute Setattr(hash,key,value) Set an attribute
Delattr(hash,key) Delete an attribute Delattr(hash,key) Delete an attribute
Firstkey(hash,key) Get first key Firstkey(hash) Get first key
Nextkey(hash,key) Get next 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 Sequence Operations
------------------- -------------------
@ -36,6 +54,7 @@ Setitem(list,index,val) Set an item
Delitem(list,index,val) Delete an item Delitem(list,index,val) Delete an item
Insert(list,index,val) Insert an item Insert(list,index,val) Insert an item
Append(list,val) Append to end Append(list,val) Append to end
Push(list,val) Insert at beginning
File Operations File Operations
--------------- ---------------
@ -46,9 +65,53 @@ Putc(ch,obj) Put a character
Ungetc(ch,obj) Put character back on input stream Ungetc(ch,obj) Put character back on input stream
Seek(obj,offset,whence) Seek Seek(obj,offset,whence) Seek
Tell(obj) Return file pointer Tell(obj) Return file pointer
Printf(obj,format,...) Printf
Close(obj) Close 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.