"Fossies" - the Fresh Open Source Software Archive

Member "swig-4.1.1/Source/DOH/README" (30 Nov 2022, 4833 Bytes) of package /linux/misc/swig-4.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "README": 4.0.1_vs_4.0.2.

    1 DOH  (Dave's Object Hack)
    2 
    3 Overview:
    4 ---------
    5 DOH is a small C library that provides a number of simple yet powerful
    6 data structures. The data structures are built around a dynamic typing
    7 model in which any given object is allowed to support one or more
    8 classes of operations.  Furthermore, a simple garbage collection
    9 scheme and a variety of interesting library methods are available.
   10 All and all, the operation of DOH makes massive abuse of the C type
   11 system and would probably make the language purists scream and
   12 performance addicts run away in horror.  However, I really don't
   13 care--so there! However, for the rest of us, DOH is actually kind of
   14 fun to use. This is only a short description of the methods and is no
   15 way meant to be exhaustive.
   16 
   17 Common Operations (for all types)
   18 ---------------------------------
   19 Delete(obj)             Decrease the reference count and destroy if zero
   20 Copy(obj)               Make a copy of an object.
   21 Clear(obj)              Clear an object.
   22 Setscope(obj)           Set scope of an object (guru's only)
   23 Str(obj)                Create a string representation of obj.
   24 Data(obj)               Return pointer to raw data in an object
   25 Char(obj)               Convert to a char *
   26 Len(obj)                Length of an object
   27 Hash(obj)               Hash value (used for mapping)
   28 Cmp(obj1,obj2)          Compare two objects.
   29 Name(obj)               Return the object name
   30 First(obj)              Return first object (iterator)
   31 Next(obj)               Return next object
   32 Dump(obj,out)           Serialize on out
   33 Load(in)                Unserialize from in
   34 First(obj)              Iterator
   35 Next(iter)              Next iterator
   36 
   37 Mapping Operations (for hash table behavior)
   38 --------------------------------------------
   39 Getattr(hash,key)              Get an attribute
   40 Setattr(hash,key,value)        Set an attribute
   41 Delattr(hash,key)              Delete an attribute
   42 First(hash)                    Get first object (iterator)
   43 Next(hash)                     Get next object
   44 GetInt(hash,key)               Get attribute as an 'int'
   45 SetInt(hash,key,ivalue)        Set attribute as an 'int'
   46 GetDouble(hash,key)            Get attribute as a 'double'
   47 SetDouble(hash,key,dvalue)     Set Attribute as a 'double'
   48 GetChar(hash,key)              Get attribute as a 'char *'
   49 
   50 Sequence Operations
   51 -------------------
   52 Getitem(list,index)             Get an item
   53 Setitem(list,index,val)         Set an item
   54 Delitem(list,index)             Delete an item
   55 Insert(list,index,val)          Insert an item
   56 Append(list,val)                Append to end
   57 Push(list,val)                  Insert at beginning
   58 
   59 File Operations
   60 ---------------
   61 Read(obj,buffer,len)            Read data
   62 Write(obj,buffer,len)           Write data
   63 Getc(obj)                       Get a character
   64 Putc(ch,obj)                    Put a character
   65 Ungetc(ch,obj)                  Put character back on input stream
   66 Seek(obj,offset,whence)         Seek
   67 Tell(obj)                       Return file pointer
   68 Delete(obj)                     Decrease the reference count, close file if zero
   69 
   70 String Operations
   71 -----------------
   72 Replace(obj, orig, rep, flags)  Replace occurrences of orig with rep.
   73 Chop(obj)                       Remove trailing whitespace
   74 
   75 flags is one of the following:
   76     DOH_REPLACE_ID
   77     DOH_REPLACE_ID_BEGIN
   78     DOH_REPLACE_ID_END
   79     DOH_REPLACE_NUMBER_END
   80 
   81 and can be combined with one or more of the following:
   82     DOH_REPLACE_ANY
   83     DOH_REPLACE_NOQUOTE
   84     DOH_REPLACE_NOCOMMENT
   85     DOH_REPLACE_FIRST
   86 
   87 Callable Operations
   88 -------------------
   89 Call(obj, args)                 Perform a function call with arguments args.
   90 
   91 Miscellaneous library functions
   92 -------------------------------
   93 NewScope()                      Create a new scope
   94 DelScope(s)                     Delete scope s
   95 Readline(in)                    Read a line of input from in
   96 Printf(out,fmt,...)             Formatted output
   97 DohEncoding(name, fn)           Register a format encoding for Printf
   98 
   99 Currently Available datatypes
  100 ------------------------------
  101 NewString(char *initial)                            Strings
  102 NewHash()                                           Hash
  103 NewList()                                           List
  104 NewVoid(void *ptr, void (*del)(void *))             Void
  105 NewFile(char *filename, char *mode, List *newfiles) File
  106 NewCallable(DOH *(*func)(DOH *, DOH *))             Callable object
  107 
  108 
  109 Odds and ends:
  110 
  111   1.   All objects are of type 'DOH *'
  112   2.   When in doubt, see rule (1)
  113   3.   In certain cases, DOH performs implicit conversions
  114        of 'char *' to an appropriate DOH string representation. 
  115        For operations involving files, DOH works with many
  116        kinds of objects including FILE *, DOH File objects,
  117        and DOH strings.  Don't even ask how this works.
  118 
  119   4.   More complete documentation is forthcoming.
  120 
  121 
  122 
  123 
  124