home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / SOMINF.ZIP / SOMSOM.INF (.txt) < prev    next >
OS/2 Help File  |  1992-05-13  |  34KB  |  1,189 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Background ΓòÉΓòÉΓòÉ
  3.  
  4. o OOP is increasingly recognized as an important new programming technology 
  5.  
  6.    - It offers expanded opportunities for software reuse and extensibility. 
  7.    - Improved programmer productivity when compared to conventional software 
  8.      development paradigms. 
  9.  
  10. o Different languages emphasize different aspects of OOP 
  11.  
  12.    - Objects from one language may not be usable in another 
  13.    - Language boundaries become barriers to interoperability 
  14.  
  15. o Benefits of OOP can be appealing, but commitment to a single language can 
  16.   cause a closed system. 
  17. o System Object Model (SOM) is IBM's answer to this set of problems 
  18.  
  19.  
  20. ΓòÉΓòÉΓòÉ 2. Introduction to SOM ΓòÉΓòÉΓòÉ
  21.  
  22. o SOM is an object oriented programming interface for building and manipulating 
  23.   software objects. 
  24.  
  25.    - SOM is language neutral 
  26.    - Users of a SOM class can create a subclass that may or may not be written 
  27.      in the same language as the base class 
  28.  
  29. o With SOM the only details available to the clients are those published by the 
  30.   implementer. 
  31. o SOM permits changes to implementation details without causing the client to 
  32.   be re-compiled 
  33.  
  34.    - Add new methods 
  35.    - Add, change or delete unpublished instance variables 
  36.    - Insert new classes into the class hierarchy 
  37.    - Relocate methods upward in the class hierarchy. 
  38.  
  39. o SOM provides method resolution designed to co-exist with current OOP 
  40.   languages 
  41.  
  42.    - Offset resolution 
  43.  
  44.       o Roughly equivalent to the C++ virtual function concept. 
  45.       o Implies a static scheme for typing objects with polymorphism based 
  46.         strictly on class inheritance. 
  47.  
  48.    - Name resolution 
  49.  
  50.       o Similar to that employed by Smalltalk and Objective-C 
  51.       o Supports untyped (dynamically typed) access to objects, with 
  52.         polymorphism based on the actual protocols that objects honor. 
  53.  
  54.    - Dispatch function resolution 
  55.  
  56.       o Unique feature to SOM that permits method resolution to be based on 
  57.         arbitrary rules known only in the domain of the receiving object 
  58.       o Languages that require special entry or exit sequences are good 
  59.         candidates for using this feature 
  60.  
  61. o The implementer decides whether to support offset or name resolution for 
  62.   methods in a SOM class 
  63. o Clients of SOM classes may also make choices about method resolution 
  64.  
  65.    - If the implementer has selected offset resolution, the client may make use 
  66.      of any of the three method resolution techniques. 
  67.    - If the implementer has selected name resolution, clients may use name or 
  68.      dispatch function resolution. 
  69.    - If the implementer supports only dispatch function resolution, the clients 
  70.      are confined to use this as well. 
  71.  
  72. o Programmers may use SOM in two ways 
  73.  
  74.    - If using a native OOP language (eg. C++ or Smalltalk), SOM may be used to 
  75.      front end the native language. 
  76.    - If using a language with no object model (eg. C), SOM can be used to 
  77.      create a full object oriented language. 
  78.  
  79.  
  80. ΓòÉΓòÉΓòÉ 3. The SOM development process ΓòÉΓòÉΓòÉ
  81.  
  82. o Development begins with a class definition 
  83. o Public definition of a SOM class is given in a formal specification language 
  84.   that is independent of the language to be used for implementation. 
  85. o The more complete specification would be provided in a language specific 
  86.   form. 
  87. o The development process begins with development of a <filename>.CSC file that 
  88.   defines the class with its data and methods. 
  89. o The SOM compiler creates a more public file, the <filename>.SC file that 
  90.   contains all class definitions except any methods, data or implementation 
  91.   details that are declared to be private. 
  92. o The SOM compiler processes the class specification and provides the binding 
  93.   files that allow SOM to be used with the implementation language (currently 
  94.   only 'C'). 
  95. o The bindings for 'C' come in the form of macros and functions that are 
  96.   included in the source program and subsequently compiled by the 'C' compiler. 
  97.  
  98.  
  99. ΓòÉΓòÉΓòÉ 4. SOM Object Interface Definition Language (OIDL) ΓòÉΓòÉΓòÉ
  100.  
  101. o Provides the basis for generating the bindings files that enable programming 
  102.   languages to provide and use SOM objects. 
  103. o OIDL extensions for the 'C' language 
  104.  
  105.    - Public header file for programs that use a class. Use of a class includes 
  106.      instantiating objects, calling object methods and sub-classing to create 
  107.      new classes. 
  108.    - Private header file that provides bindings to private methods (if any). 
  109.    - An implementation header file for use by the class implementer. 
  110.    - An implementation template which is the source code framework. 
  111.    - A language neutral public definition file. 
  112.    - A language neutral definition file that contains the private parts of the 
  113.      class interface. 
  114.    - An OS/2 .DEF file that can be used to package the object as a DLL. 
  115.  
  116. o OIDL files may contain the following sections 
  117.  
  118.    - Include section (R) 
  119.    - Class section (R) 
  120.    - Release Order section (O) 
  121.    - Metaclass section (O) 
  122.    - Parent Class section (R) 
  123.    - Passthru section (O) 
  124.    - Data section (O) 
  125.    - Method section (O) 
  126.  
  127.  
  128. ΓòÉΓòÉΓòÉ 5. Notes on SOM usage ΓòÉΓòÉΓòÉ
  129.  
  130. o Environment variables needed by the SOM compiler 
  131.  
  132.    - SMINCLUDE tells the compiler where to find included class definitions (eg. 
  133.      .SC files). This is similar to the INCLUDE environment variable. 
  134.    - SMEMIT indicates to the compiler which emitter programs should be 
  135.      executed. Each item designates a file type to be created by the compiler: 
  136.  
  137.                       SET SMEMIT=H;IH;SC;DEF
  138.      This item may be overridden by the -s "string" compiler switch. 
  139.    - SMTMP specifies the path where the compiler is to create intermediate 
  140.      files. If no value is specified, the SOM compiler will default to the root 
  141.      of the current drive; 
  142.  
  143. o SOM bindings for 'C' 
  144.  
  145.    - Three of the files created by the SOM compiler can be considered as 'C' 
  146.      language binding files 
  147.  
  148.       o <class stem>.H is the public usage header file that must be included by 
  149.         a 'C' program in order to make use of the class object. 
  150.       o <class stem>.PH is the private usage binding file. This file must be 
  151.         included in a source module in order to reference the private parts of 
  152.         the class. 
  153.       o <class stem>.IH is the implementation header file. This file must be 
  154.         included in the source file that implements the class. This file will 
  155.         include the .PH file if one exists, or will include the .H file. 
  156.  
  157.    - In addition the SOM compiler can create or update the <class stem>.C file 
  158.      that contains the class implementation. 
  159.  
  160. o Using a class and its objects 
  161.  
  162.    - Declaring object variables - sizes of SOM objects are NOT known at compile 
  163.      time. Therefore it is NEVER correct to create an object like: 
  164.  
  165.                       <class> obj;
  166.  
  167.      instead, always create a pointer to the object: 
  168.  
  169.                       <class> *obj;
  170.  
  171.    - Instances are usually created by the <class>New() macro: 
  172.  
  173.                       <class> *obj = <class>New();
  174.  
  175.      However, there may be times when it is necessary to pre-allocate space, 
  176.      then create objects in that space. This may be accomplished by using the 
  177.      <class>Renew() macro: 
  178.  
  179.                       <class> *obj = <class>Renew( buffer );
  180.      where buffer is a pointer to the allocated space. 
  181.  
  182. o Methods and private instance data are reference by: 
  183.  
  184.           _<method>( <targetObject> )
  185.                or
  186.           _<variable>
  187.  
  188. o Public instance variables can be referenced by: 
  189.  
  190.           get_<variable>( <targetObject> );
  191.  
  192. o Parent methods may be accessed by: 
  193.  
  194.           parent_<method>( <targetObject> );
  195.  
  196. o Debugging Facilities 
  197.  
  198.    - <class name>MethodDebug() is a macro generated as part of the method stubs 
  199.      created by the SOM compiler. It takes as arguments, a class name and a 
  200.      method name and is actuated by setting the SOM_TraceLevel variable to 1 or 
  201.      2. 
  202.    - SOM_Test() takes an arbitrary Boolean expression as an argument. If the 
  203.      expression evaluates to TRUE, execution continues; otherwise SOM_Error is 
  204.      invoked with a warning-level error code. This macro is actuated by setting 
  205.      the SOM_WarnLevel variable to 1 or 2. 
  206.    - SOM_WarnMsg() takes a string as input and writes the string if 
  207.      SOM_WarnLevel is set to a 1 or 2. 
  208.    - SOM_Assert() allows assertions to be placed in the code. It takes as input 
  209.      a Boolean expression and an error code. If the expression evaluates to 
  210.      FALSE, SOM_Error is called with the error code. 
  211.    - SOM_Expect() is similar to SOM_Assert, except that it takes only a Boolean 
  212.      expression as input. If the expression evaluates to false, SOM_WarnMsg is 
  213.      invoked to produce a warning message. 
  214.    - In addition to the above SOM automatically performs basic validity 
  215.      checking at runtime for SOM method invocations. Once the code has been 
  216.      tested thoroughly, this checking may be removed by placing 
  217.  
  218.                       #define SOM_NoTest
  219.      in the source file prior to the include of the .IH file. 
  220.  
  221.      Note: On any of the above where a value may be set to 1 or 2, setting the 
  222.      value to 2 will cause any methods provided by SOM to produce error or 
  223.      tracing messages. 
  224.  
  225. o Customization features 
  226.  
  227.    - Memory management functions - SOM provides a subset of the ANSI 'C' memory 
  228.      functions: 
  229.  
  230.                       SOMCalloc, SOMFree, SOMMalloc, SOMRealloc
  231.      These methods may be overridden for specialized processing. It is 
  232.      recommended that, if any of these methods are overridden, they are ALL 
  233.      replaced. 
  234.    - SOM provides three DLL management functions: 
  235.  
  236.                       SOMLoadModule
  237.                       SOMClassInitFuncName
  238.                       SOMDeleteModule
  239.      These methods may need to be overridden if it is intended to package more 
  240.      than one class in a single DLL. 
  241.    - The default SOM character output function simply takes a character as 
  242.      input, and writes the character to STDOUT. This can be replaced if it is 
  243.      wished to record the output in a log file, display a messagebox, etc. This 
  244.      is accomplished by writing the output function, then setting the 
  245.      SOMOutCharRoutine variable to the address of your function. 
  246.    - SOMError is the default error handling function. This function may be 
  247.      overridden in order to record errors in a way more approriate to your 
  248.      application, attempt application level recovery by restarting at a known 
  249.      point, etc. 
  250.  
  251.  
  252. ΓòÉΓòÉΓòÉ 6. SOM Classes ΓòÉΓòÉΓòÉ
  253.  
  254.  
  255. ΓòÉΓòÉΓòÉ 6.1. SOMObject: base class to all SOM objects ΓòÉΓòÉΓòÉ
  256.  
  257.  Class:        SOMObject
  258.  
  259.  Parent:       <none>
  260.  
  261.  Metaclass:    SOMClass
  262.  
  263.  File stem     SOMOBJ
  264.  
  265.  Definition:   SOMOBJ.SC
  266.  
  267.  Header file:  SOMOBJ.H (always included from SOM.H)
  268.  
  269.  Description:  SOMObject is the root class for all SOM classes. It defines
  270.                the essential behavior common to all SOM objects. As
  271.                SOMObject has no instance data, it contributes nothing to
  272.                the size of derived classes.
  273.  
  274.  Notes on subclassing:
  275.                All SOM classes are expected to derive from SOMObject. Three
  276.                methods would typically be overridden by any subclass that
  277.                has instance data-somInit, somUninit, and somDumpSelfInt.
  278.                See the descriptions of these methods for further information.
  279.  
  280.  New methods:
  281.                [Initialization/Termination Group]
  282.                somFree
  283.                somInit
  284.                somUninit
  285.  
  286.                [Access Group]
  287.                somGetClass
  288.                somGetClassName
  289.                somGetSize
  290.  
  291.                [Testing Group]
  292.                somIsA
  293.                somIsInstanceOf
  294.                somRespondsTo
  295.  
  296.                [Dynamic Group]
  297.                somDispatchA
  298.                somDispatchD
  299.                somDispatchL
  300.                somDispatchV
  301.  
  302.                [Development Support Group]
  303.                somDumpSelf
  304.                somDumpSelfInt
  305.                somPrintSelf
  306.  
  307.  Inherited methods:
  308.                None
  309.  
  310.  Overridden methods:
  311.                None
  312.  
  313.  
  314. ΓòÉΓòÉΓòÉ 6.2. SOMClass: root class for all SOM metaclasses. ΓòÉΓòÉΓòÉ
  315.  
  316.  Class:        SOMClass
  317.  
  318.  Parent:       SOMObject
  319.  
  320.  Metaclass:    SOMClass (only class with itself as metaclass)
  321.  
  322.  File stem     SOMCLS
  323.  
  324.  Definition:   SOMCLS.SC
  325.  
  326.  Header file:  SOMCLS.H (always included from SOM.H)
  327.  
  328.  Description:  SOMClass is the root class for all SOM metaclasses. It
  329.                defines the essential behavior common to all SOM classes,
  330.                In particular, it has two generic methods for manufacturing
  331.                object instances (somNew and somRenew), and a suite of
  332.                methods for constructing classes. It also has methods that
  333.                can be used to dynamically obtain (or augment) information
  334.                about a class and its methods at run time.
  335.  
  336.  Notes on subclassing:
  337.                All SOM classes are expected to have SOMClass or a class
  338.                derived from SOMClass as their metaclass.  Metaclasses
  339.                define "class" methods (sometimes called "factory" methods
  340.                or "constructors") that can be used to manufacture objects
  341.                of any class for which they are the metaclass.  If you wish
  342.                to define your own class methods for your objects, or impart
  343.                specialized behavior to the generic class methods supplied
  344.                in SOMClass, you will need to define your own metaclass by
  345.                subclassing SOMClass or one of its other subclasses.  Three
  346.                methods that SOMClass inherits and overrides from SOMObject
  347.                would typically be overridden by any metaclass that has
  348.                instance data - somInit, somUninit, and somDumpSelfInt.  See
  349.                the descriptions of these methods in SOMObject for further
  350.                information.  The new methods introduced in SOMClass that
  351.                might frequently be overridden are somNew, somNewNoInit,
  352.                somRenew, somRenewNoInit, and somClassReady.
  353.  
  354.                Other reasons that you may want to create your own metaclass
  355.                include tracking object instances, automatic garbage
  356.                collection, interfacing to a persistent object store, or
  357.                providing/managing information that is global to a set of
  358.                object instances.
  359.  
  360.  New methods:
  361.  
  362.                [Initialization/Termination Group]
  363.                somAddStaticMethod
  364.                somClassReady
  365.                somInitClass
  366.                somOverrideSMethod
  367.  
  368.                [Instance Creation (Factory) Group]
  369.                somNew
  370.                somNewNoInit
  371.                somRenew
  372.                somRenewNoInit
  373.  
  374.                [Access Group]
  375.                somGetApplyStub
  376.                somGetClassData
  377.                somGetClassMtab
  378.                somGetInstanceOffset
  379.                somGetInstancePartSize
  380.                somGetInstanceSize
  381.                somGetName
  382.                somGetNumMethods
  383.                somGetNumStaticMethods
  384.                somGetParent
  385.                somGetPClsMtab
  386.                somSetClassData
  387.  
  388.                [Testing Group]
  389.                somCheckVersion
  390.                somDescendedFrom
  391.                somSupportsMethod
  392.  
  393.                [Dynamic Group]
  394.                somFindMethod
  395.                somFindMethodOk
  396.  
  397.  Inherited methods:
  398.                somDispatchA
  399.                somDispatchD
  400.                somDispatchL
  401.                somDispatchV
  402.                somDumpSelf
  403.                somFree
  404.                somGetClassName
  405.                somGetClass
  406.                somGetSize
  407.                somIsA
  408.                somIsInstanceOf
  409.                somPrintSelf
  410.                somRespondsTo
  411.  
  412.  Overridden methods:
  413.                somDumpSelfInt
  414.                somInit
  415.                somUninit
  416.  
  417.  
  418. ΓòÉΓòÉΓòÉ 6.3. SOMClassMgr: runtime registry for all SOM class objects. ΓòÉΓòÉΓòÉ
  419.  
  420.  Class:        SOMClassMgr
  421.  
  422.  Parent:       SOMObject
  423.  
  424.  Metaclass:    SOMClass
  425.  
  426.  File stem     SOMCM
  427.  
  428.  Definition:   SOMCM.SC
  429.  
  430.  Header file:  SOMCM.H (always included from SOM.H)
  431.  
  432.  Description:  One instance of SOMClassMgr is created during SOM
  433.                initialization. It acts as a run-time registry for all SOM
  434.                class objects that have been created or dynamically loaded
  435.                by the current process. Each SOM class automatically
  436.                registers itself with the SOMClassMgr instance (pointed to
  437.                by the global variable, SOMClassMgrObject) during the final
  438.                stage of its initialization.
  439.  
  440.  Notes on subclassing:
  441.                You can subclass SOMClassMgr to augment the functionality of
  442.                its registry (to make it persistent, for example, or to
  443.                coordinate the name of a class with the location of its code
  444.                in the file system).  If you want your subclass to replace
  445.                the SOM-supplied SOMClassMgrObject, you can use the
  446.                somMergeInto method to place the existing registry
  447.                information from SOMClassMgrObject into your new
  448.                class-manager object as a final step in the creation of an
  449.                instance of your subclass. The former SOMClassMgrObject is
  450.                then freed, and the address of your new class manager is
  451.                placed in this global variable.
  452.  
  453.  New methods:
  454.                [Basic Functions Group]
  455.  
  456.                somLoadClassFile
  457.                somLocateClassFile
  458.                somRegisterClass
  459.                somUnloadClassFile
  460.                somUnregisterClass
  461.  
  462.                [Access Group]
  463.  
  464.                somGetInitFunction
  465.  
  466.                [Dynamic Group]
  467.  
  468.                somClassFromId
  469.                somFindClass
  470.                somFindClsInFile
  471.                somMergeInto
  472.  
  473.  Inherited methods:
  474.  
  475.                somDispatchA
  476.                somDispatchD
  477.                somDispatchL
  478.                somDispatchV
  479.                somDumpSelf
  480.                somFree
  481.                somGetClass
  482.                somGetClassName
  483.                somGetSize
  484.                somIsA
  485.                somIsInstanceOf
  486.                somPrintSelf
  487.                somRespondsTo
  488.  
  489.  Overridden methods:
  490.  
  491.                somDumpSelfInt
  492.                somInit
  493.                somUninit
  494.  
  495.  
  496. ΓòÉΓòÉΓòÉ <hidden> Include Section ΓòÉΓòÉΓòÉ
  497.  
  498. This section contains an include statement that is a directive to the OIDL 
  499. preprocessor telling the compiler where to find the class interface definition 
  500. for this class' parent class, the class' metaclass if the class specifies one, 
  501. and the private interface files for any ancestor class for which this class 
  502. overrides one or more of its private methods. 
  503.  
  504. Note:  The include statements must appear in the order shown below. In 
  505. addition, the ancestor include statements must be in inheritance order (from 
  506. the root down). 
  507.  
  508.  The syntax for an include statement is:
  509.  
  510.  [#include ( <ancestor> | "ancestor" )]*
  511.  #include ( <parent> | "parent" )
  512.  [#include ( <metaclass> | "metaclass" )]
  513.  
  514.  Example:
  515.  
  516.  #include "barfile.sc"
  517.  #include "foofile.sc"
  518.  #include <metafile.sc>
  519.  
  520.  where:
  521.  
  522.  <ancestor>  [optional]
  523.       is the name of the OIDL file containing the private
  524.       part of an ancestor class' interface needed in the definition of
  525.       this class.
  526.  
  527.  <parent>    [required]
  528.  
  529.            is the name of the OIDL file containing the parent class of
  530.            the class for which the include statement is provided.
  531.  
  532.  <metaclass> [optional]
  533.  
  534.            is the OIDL file containing the metaclass of the class for
  535.            which the include statement is provided.
  536.  
  537.  
  538. ΓòÉΓòÉΓòÉ <hidden> Class Section ΓòÉΓòÉΓòÉ
  539.  
  540. This required section introduces the class, giving its name, attributes, and 
  541. optionally a description of the class as a whole. 
  542.  
  543.  
  544. The syntax for a class statement is:
  545.  
  546. class: name
  547.     [, file stem = stem]
  548.     [, external stem = stem]
  549.     [, function prefix = prefix |
  550.      , external prefix = prefix]
  551.      , classprefix = prefix]
  552.     [, major version = number]
  553.     [, minor version = number]
  554.     [, global | local];
  555.     [, classinit = function];
  556. [description]
  557.  
  558. Example:
  559.  
  560. class: Foo,
  561.        local,
  562.        file stem = foofile,
  563.        external prefix = xx_,
  564.        major version = 1,
  565.        minor version = 3;
  566. -- This is the Foo class. It does nothing.
  567.  
  568. where:
  569.  
  570. <name>   [required]
  571.    is the name for this class.
  572.  
  573. file stem = stem   [optional]
  574.  
  575.    is an attribute that specifies how the compiler is to construct
  576.    file names for various generated files. The constructed file names
  577.    will all begin with stem.
  578.  
  579.    Note:  This value is also used as the class library name in any
  580.           generated .DEF file.
  581.  
  582.    This attribute defaults to the name of the file containing the
  583.    class-interface definition.
  584.  
  585. external stem = stem   [optional]
  586.  
  587.    is an attribute that governs the formation of external names that
  588.    appear in the text of the generated output files. On some systems,
  589.    external names are limited in length to a small number of
  590.    characters. The SOM Compiler uses the value stem as the basis for
  591.    generating short external names. A suffix is appended to stem for
  592.    each external name. Because OS/2 2.0 external names may be up to
  593.    255 characters in length, short external names are generally not
  594.    used.
  595.  
  596.    This attribute defaults to the same value given (or defaulted) by
  597.    file stem.
  598.  
  599. function prefix = prefix   [optional]
  600.  
  601.    is an attribute that directs the compiler to construct method
  602.    function names by prefixing method names with prefix. For example,
  603.    function prefix = xx_ would result in a function name of xx_foo for
  604.    a method called foo.
  605.  
  606.    Note:  It is an error to specify both function prefix and external
  607.    prefix as attributes of the same class.
  608.  
  609.    This attribute has no default.
  610.  
  611. external prefix = prefix   [optional]
  612.  
  613.    is an attribute that is similar to function prefix except this
  614.    attribute will also cause each method function to be an external
  615.    name, whereas  method functions usually are local to the module in
  616.    which they are defined. Making method functions external can be
  617.    useful in development environments whose debuggers have difficulty
  618.    dealing with local procedures.
  619.  
  620.    Note:  It is an error to specify both external prefix and
  621.           function prefix as attributes of the same class.
  622.  
  623.    This attribute has no default.
  624.  
  625. classprefix = prefix   [optional]
  626.  
  627.    is similar to the function prefix attribute, but applies only to
  628.    methods that have the class attribute. If you use the class
  629.    attribute (for any methods in the current class definition), you
  630.    are required to supply a classprefix value within the class
  631.    statement.
  632.  
  633.    This attribute has no default.
  634.  
  635. major version = number   [optional]
  636.  
  637.    is an attribute that specifies the major version number of this
  638.    class definition. Number must be in the range of 0 to (2**31)-1.
  639.    This will produce bindings that will verify that any code that
  640.    purports to implement this class has the same major version number,
  641.    unless number is 0, in which case no test is made.
  642.  
  643.    This attribute defaults to major version = 0.
  644.  
  645. minor version = number   [optional]
  646.  
  647.    is an attribute that specifies the minor version number of this
  648.    class definition. Number must be in the range of 0 to (2**31)-1.
  649.    This will produce bindings that will verify that any code that
  650.    purports to implement this class has the same or higher minor
  651.    version number, unless number is 0, in which case no test is made.
  652.  
  653.    This attribute defaults to minor version = 0.
  654.  
  655. global | local [optional]
  656.  
  657.    is an attribute that indicates how binding files are to be linked
  658.    together. Local means link to other files in the local context
  659.    first. Global means bypass the local context. For example, local
  660.    will result in C-language statements like:
  661.  
  662.        #include "file.h"
  663.  
  664.    Global will result in statements like:
  665.  
  666.        #include <file.h>
  667.  
  668.    This attribute defaults to global.
  669.  
  670. classinit = function   [optional]
  671.  
  672.    allows you to provide user-written code that participates in the
  673.    construction of your class. function designates a function you
  674.    supply that is called when your class is created. This function
  675.    receives one argument; a pointer to your newly created class object.
  676.    You can use this function to perform any supplemental processing
  677.    that you need. If you specify this attribute in your class
  678.    definition, a template for this function will be provided
  679.    automatically in the generated .C file.
  680.  
  681.    By default, your class will not have a user-written classinit
  682.    function.
  683.  
  684. description  [optional]
  685.  
  686.    is a description of the class as a whole and must be in the form
  687.    of a comment. Several comment styles are supported including:
  688.  
  689.       /*
  690.        * line1
  691.        * line2
  692.        */
  693.  
  694.       -- line 1 (starts with 2 consecutive dashes)
  695.       -- line 2
  696.  
  697.       // line 1
  698.       // line 2
  699.  
  700.    Because OIDL files are used to generate language bindings, comments
  701.    must be strictly associated with particular syntactic elements, so
  702.    they will appear at the appropriate points in the output files.
  703.    Therefore, comments must be placed in OIDL files with more care than
  704.    in some programming languages. If you do not place your comments
  705.    with strict adherence to the OIDL section syntax, the comments
  706.    probably will not appear where you expect to see them.
  707.  
  708.    A fourth style for OIDL comments is referred to as throw-away
  709.    comments. They may be placed anywhere in an OIDL file, because they
  710.    are not intended to appear in any binding files.  Throw-away
  711.    comments start with the character (#) and end at the end of the
  712.    line. You can use throw-away comments to "comment-out" sections of
  713.    an OIDL file.
  714.  
  715.       #
  716.       # This is an example of a throw-away comment
  717.       #
  718.  
  719.    Note:  Comments will appear in files produced by the SOM Compiler in
  720.           various forms appropriate to the intended use of the file.
  721.           Sometimes these files are intended as input to a programming-
  722.           language compiler. Therefore, it is best to avoid using
  723.           characters in the body of comments that are not generally
  724.           allowed in most programming-language comments. For example,
  725.           the C language does not allow "*/" to occur in a comment, so
  726.           its use is to be avoided.
  727.  
  728.    Refer to SOM Compiler Command Syntax for information about the
  729.    effect of global attributes on OIDL comments.
  730.  
  731.  
  732. ΓòÉΓòÉΓòÉ <hidden> Release Order Section ΓòÉΓòÉΓòÉ
  733.  
  734. This optional section contains a release order statement that forces the 
  735. compiler to build certain critical data structures with their items arranged in 
  736. the order specified. This allows the class interface and implementation to be 
  737. evolved without requiring programs that use this class be recompiled.  Release 
  738. order applies to all method names and public or private (that is, non-internal) 
  739. data items. If the release order of some method or non-internal data item is 
  740. not specified, it will default to an implementation-specific order based on its 
  741. occurrence in the OIDL file. The introduction of new public or private data 
  742. items or methods might cause the default ordering of other public or private 
  743. data items or methods to change; programs using the class would then need to be 
  744. recompiled. The SOM Compiler has a "pretty print" mode in which it will 
  745. reproduce a class definition in a nicely formatted manner with release order 
  746. specified for all relevant items. Programmers are advised to use this facility 
  747. to update the release order statement whenever they make significant additions 
  748. to a class. 
  749.  
  750. The syntax for a release order statement is: 
  751.  
  752. release order: name [, name ]* ;
  753.  
  754. Example:
  755.  
  756. release order: m1, m2, pd1, m3;
  757.  
  758. where:
  759.  
  760. name [, name ]*  [optional]
  761.  
  762.    contains all method names introduced by this class (whether public
  763.    or private), and the names of any non-internal instance variables.
  764.    It must not contain the names of any inherited methods (even if
  765.    they are to be overridden), except as noted below. As the class
  766.    evolves, new names can be added to the end of this list, but once a
  767.    name is on this list, it must not be reordered or removed. Doing
  768.    either will require the recompilation of programs that use this
  769.    class. If a method named on the list is to be moved up in the class
  770.    hierarchy (for example, to the parent class of this class), its name
  771.    should remain just as it is on the current list, but it also must be
  772.    added to the release-order list for the class that will now
  773.    introduce it.
  774.  
  775.  
  776. ΓòÉΓòÉΓòÉ <hidden> Metaclass Section ΓòÉΓòÉΓòÉ
  777.  
  778. This optional section specifies the class' metaclass, giving its name and, 
  779. optionally, a description of the reason for the metaclass, or other comments 
  780. about its role in this class' interface. If a metaclass is specified, its 
  781. definition must be included in the include section. If no metaclass is 
  782. specified, the metaclass of this class' parent class will be used. Therefore, 
  783. if you intend the metaclass of this class' parent class to be used, it is 
  784. generally best not to specify the metaclass.  A class' metaclass can also be 
  785. implicitly defined through the use of the class attribute in the data section 
  786. or the class attribute in the method section. If you use either of these 
  787. attributes you must bypass (that is, omit) the metaclass section altogether. In 
  788. this case, your implied metaclass will be a subclass of the metaclass of your 
  789. parent class. 
  790.  
  791. The syntax for a metaclass description statement is: 
  792.  
  793. metaclass: name;
  794. [description]
  795.  
  796. Example:
  797.  
  798. metaclass: FooMeta;
  799. /*
  800.  * This is the metaclass for the Foo class.
  801.  * Note that several forms of comment are allowed.
  802.  */
  803.  
  804. where:
  805.  
  806. name     [optional]
  807.    is the name of the metaclass to be used to create the class object
  808.    for this class.
  809.  
  810.    This attribute defaults to the parent's metaclass.
  811.  
  812. description   [optional]
  813.  
  814.    is a description of the metaclass and must be in the form of a
  815.    comment (see Class Section for the discussion about comment styles).
  816.  
  817. Note:  You can add the attributes major version, minor version, file
  818.        stem, and global | local to the metaclass statement. If you
  819.        include at least file stem, you do not have to include the
  820.        metaclass definition in the include section.
  821.  
  822.  
  823. ΓòÉΓòÉΓòÉ <hidden> Parent Section ΓòÉΓòÉΓòÉ
  824.  
  825.          This required section specifies the class' parent class, giving its
  826.          name and, optionally, a description of the role of the parent class in
  827.          this class' interface.
  828.  
  829.          The syntax for a parent class description statement is:
  830.  
  831.          parent [class]: name;
  832.          description
  833.  
  834.          Example:
  835.  
  836.          parent: SOMObject;
  837.  
  838.          // Foo will be directly descended from the SOM root class, SOMObject.
  839.          // Note, this is yet another style of comment.
  840.  
  841.          where:
  842.  
  843.          name     [required]
  844.             is the name of the class of which this class is a subclass.
  845.  
  846.          description  [optional]
  847.  
  848.             is a description of the parent class and must be in the form of a
  849.             comment (see Class Section for the discussion about comment styles).
  850.  
  851.          Note:  You may add the attributes major version, minor version, file
  852.                 stem, and global | local to the parent class statement.
  853.  
  854.  
  855. ΓòÉΓòÉΓòÉ <hidden> Passthru Section ΓòÉΓòÉΓòÉ
  856.  
  857. This optional section provides blocks of code to be passed by the compiler into 
  858. various binding files. The contents of the passed lines are essentially ignored 
  859. by the compiler and can contain anything that needs to be placed near the 
  860. beginning of a binding file. 
  861.  
  862. Note:  Even comments contained in passthru lines are processed without 
  863. modification. 
  864.  
  865. The syntax for the passthru section is: 
  866.  
  867. [passthru: language.suffix, [ before | after ];
  868. line 1
  869. line 2
  870.  ..
  871. line n
  872. endpassthru; [description]]*
  873.  
  874. Example:
  875.  
  876. passthru: C.h:
  877. typedef int *foobar;
  878. #define SIZE 89
  879. endpassthru;
  880. -- The two lines above will be placed in the public binding file for
  881. -- all C language users of this class. Note: the next passthru clause
  882. -- has no comment.
  883.  
  884. passthru: C.ih;
  885. static char *name;
  886. endpassthru;
  887.  
  888. where:
  889.  
  890. language   [required]
  891.  
  892.    is the programming language whose binding files are to be affected.
  893.    Currently only the C language is supported. In the future other
  894.    languages might be supported.
  895.  
  896. suffix   [required]
  897.    specifies which binding file is to be affected. For C, the currently
  898.    supported binding files are:
  899.  
  900.    .H       The binding file for all users of the class
  901.  
  902.    .PH      The binding file for users with access to private methods
  903.             of the class
  904.  
  905.    .IH      The binding file for implementers of the class
  906.  
  907.    .C       The program template file used in implementing the class
  908.  
  909.    .SC      The language-neutral core version of the OIDL file
  910.  
  911.    .PSC     Additional language-neutral information about the private
  912.             methods in the class
  913.  
  914.    .CS2     A "pretty printed" version of the OIDL file
  915.  
  916.    Note:  In general, you would not normally place passthru lines into
  917.           a .C file, because a .C file is usually generated only once
  918.           and then filled in with source code by a programmer.
  919.           Subsequent updates to a .C file by the SOM Compiler consist
  920.           only of the addition of new method templates at the end of
  921.           the file. Place passthru lines needed by the class'
  922.           implementation code in the .IH file instead. Because the .IH
  923.           file can be completely regenerated each time the OIDL class
  924.           definition is compiled, changes to your passthru lines will
  925.           be automatically included.
  926.  
  927. before | after  [optional]
  928.  
  929.    is the attribute that indicates whether passthru lines should
  930.    precede or follow any include statements at the beginning of the
  931.    binding file. This attribute defaults to before.
  932.  
  933. line     [optional]
  934.    is a line to be placed near the beginning of the binding file
  935.    exactly as written.
  936.  
  937. description   [optional]
  938.    is a description of the purpose of the passthru lines.
  939.  
  940.  
  941. ΓòÉΓòÉΓòÉ <hidden> Data Section ΓòÉΓòÉΓòÉ
  942.  
  943. This optional section lists the instance variables for this class. This section 
  944. is generally present only in the language-specific version of the class 
  945. interface definition (a .CSC file). However, it must be present in the public 
  946. form of the class interface definition if the class contains public instance 
  947. variables. ANSI C syntax is used to describe these variables. 
  948.  
  949. The syntax for the data section is: 
  950.  
  951. data:
  952. [description1]
  953. [declaration [, private | , public | , internal] [, class];
  954. [description2]]*
  955.  
  956. Example:
  957.  
  958. data:
  959. -- This is the instance data for the Foo class.
  960. int FooSize, public;
  961. -- FooSize is a public instance variable.  This means that all users of
  962. -- the Foo class will have access to FooSize.
  963. char *fooName;
  964. -- fooName is a private instance variable; therefore, only the
  965. -- implementer of the Foo class will have access to it.
  966.  
  967. where:
  968.  
  969. description1  [optional]
  970.  
  971.    is a description of the instance data as a whole and must be in
  972.    the form of a comment (see Class Section for the discussion about
  973.    comment styles).
  974.  
  975. declaration   [optional]
  976.  
  977.    is an ANSI C declaration for an instance variable.
  978.  
  979. private | public | internal
  980.  
  981.    is the attribute that controls the type of binding (if any) to be
  982.    exported for the instance data item. Internal prevents any binding
  983.    from being exported. Private causes the binding to be part of
  984.    private-usage binding files, and public causes the binding to be
  985.    placed in public-usage binding files. For C, the exported binding
  986.    is a macro of the form get_name(obj), where name is the name of the
  987.    instance data item, and obj is an object containing the item. The
  988.    macro returns an expression representing the item, which may be used
  989.    on the left- or right-hand side of assignment statements.
  990.  
  991.    This attribute defaults to internal.
  992.  
  993. class
  994.    is an attribute that designates that the data item belongs to an
  995.    implicitly defined metaclass. Data items having this attribute do
  996.    not appear in instances of the class, but instead appear in the
  997.    class itself. Methods defined in the methods section to have the
  998.    class attribute can be created to manipulate class items. If you
  999.    use this attribute your class definition cannot also contain an
  1000.    explicit metaclass section.
  1001.  
  1002.    By default, data items are not considered as class data.
  1003.  
  1004. description2
  1005.  
  1006.    is an optional description of the instance variable and must be in
  1007.    the form of a comment (see Class Section for the discussion about
  1008.    comment styles).
  1009.  
  1010.  
  1011. ΓòÉΓòÉΓòÉ <hidden> Methods Section ΓòÉΓòÉΓòÉ
  1012.  
  1013. This optional section lists the methods to be supported by this class. ANSI C 
  1014. function-prototype syntax is used to define the calling sequence to each 
  1015. method. 
  1016.  
  1017. The syntax for the methods section is: 
  1018.  
  1019. methods:
  1020. [description1]
  1021. [[group: name;
  1022.     [description2]]
  1023. [method prototype
  1024.     [, public | , private]
  1025.     [, method | , procedure]
  1026.     [, class]
  1027.     [, offset | , name lookup]
  1028.     [, local | , external]
  1029.     [, use = name];
  1030.     [description3]]*
  1031. [override: method name
  1032.     [, public | , private]
  1033.     [, class]
  1034.     [, local | , external]
  1035.     [, use = name];
  1036.     [description4]]*
  1037.  
  1038. Example:
  1039.  
  1040. methods:
  1041. -- This section lists all the methods that are to be
  1042. -- introduced by the Foo class, as well as all the
  1043. -- methods that Foo inherits and wants to override.
  1044. void m1 (int parm1, char parm2);
  1045. -- m1 is a public method with a fixed calling sequence.
  1046. -- It does not return a value.
  1047. int m2 (), private;
  1048. -- m2 is a private method with no arguments (except
  1049. -- for its target object) that returns an int.
  1050. long m3 (int parm1), procedure;
  1051. -- m3 will be a simple procedure.  It cannot be overridden.
  1052. -- It will still have a "somSelf" argument like any other method.
  1053. group: g2;
  1054. -- The rest of the methods listed in this section are
  1055. -- in group "g2".
  1056. int m4 (int numargs, ...);
  1057. -- m4 is a public method that has one required argument
  1058. -- and any number of additional arguments that can be
  1059. -- of any types.
  1060. override: somInit;
  1061. -- This class will override the implementation of
  1062. -- somInit that it inherits from one of its ancestor
  1063. -- classes.
  1064. override: m6, private;
  1065. int m5 (int p1, /* first parameter */
  1066.         int p2, /* second parameter */
  1067.         char *p3 /* last parameter */);
  1068. -- Note how comments can be embedded in the method
  1069. -- prototype.
  1070.  
  1071. where:
  1072.  
  1073. description1   [optional]
  1074.    is a description of this class' methods as a whole and must be in
  1075.    the form of a comment (see Class Section for the discussion about
  1076.    comment styles).
  1077.  
  1078. name     [required in each group statement]
  1079.    is the name of this group. Currently, groups serve no purpose except
  1080.    to improve the readability of the object interface definition.
  1081.  
  1082. description2    [optional]
  1083.    is a description of this group of methods as a whole and must be
  1084.    in the form of a comment (see Class Section for the discussion about
  1085.    comment styles).
  1086.  
  1087. <method prototype>    [required in each method specification]
  1088.    is the ANSI C function prototype that defines the calling sequence
  1089.    to this new method with the two exceptions below:
  1090.  
  1091.    1. Even though the first parameter to each method is the target
  1092.       object, this object is not mentioned in the method prototype.
  1093.  
  1094.    2. Each parameter can be preceded by one of, IN, INOUT, or OUT,
  1095.       indicating whether it is an input, input/output, or output
  1096.       parameter.
  1097.  
  1098.       Comments can occur after the separating comma between parameter
  1099.       specifications and after the last parameter, but before the
  1100.       closing parenthesis (see the declaration of m5 in the example
  1101.       above).
  1102.  
  1103. public | private   [optional]
  1104.    is an attribute that indicates to the compiler whether or not this
  1105.    method is part of the public interface to this class. There is no
  1106.    real difference between public and private methods, but the compiler
  1107.    will separate the bindings to these two classes of methods so that
  1108.    bindings for public methods can be distributed without distributing
  1109.    bindings for private methods.
  1110.  
  1111.    This attribute defaults to public.
  1112.  
  1113. local | external    [optional]
  1114.    is an attribute that directs the compiler to declare the method
  1115.    function for this method as an external name or as a local name
  1116.    (directly accessible only to the compilation unit in which it
  1117.    occurs). When specified, this attribute overrides the class default
  1118.    for method functions (see the descriptions for function prefix and
  1119.    external prefix under Class Section).
  1120.  
  1121.    This attribute defaults to the class default.
  1122.  
  1123.    This attribute has not been implemented at this time.
  1124.  
  1125. use = name    [optional]
  1126.    is an attribute that tells the compiler that the method function
  1127.    for this method is to have the name name. This overrides any class
  1128.    prefix specification.
  1129.  
  1130.    This attribute has no default.
  1131.  
  1132.    This attribute has not been implemented at this time.
  1133.  
  1134. method | procedure   [optional]
  1135.    is an attribute that indicates whether or not this method can be
  1136.    overridden by a subclass.
  1137.  
  1138.    If method is specified, the method will operate on instances of the
  1139.    class and can be overridden by a method in a subclass.
  1140.  
  1141.    If procedure is specified, the method will be a simple procedure.
  1142.    None of the normal method resolution mechanisms will be used in
  1143.    invoking the method procedure; it will be called directly.
  1144.  
  1145.    This attribute defaults to method.
  1146.  
  1147. class
  1148.    is an attribute that specifies whether the method operates on
  1149.    instances or the class itself.
  1150.  
  1151.    If class is specified the method is considered to be associated with
  1152.    an implicit metaclass. In this case the method will operate directly
  1153.    on the class itself and not on its instances. This is a convenient
  1154.    way of defining constructors or factory methods that can be invoked
  1155.    when no object instances exist. The implicit metaclass is considered
  1156.    to be a subclass of the parent class' metaclass. If you use the
  1157.    class attribute you cannot also define an explicit metaclass
  1158.    section. In addition, you must also supply a classprefix value in
  1159.    the class statement (see Class Section).
  1160.  
  1161.    If this attribute is omitted, the method is assumed to operate on
  1162.    object instances rather than the class.
  1163.  
  1164. offset | name lookup   [optional]
  1165.    is an attribute that indicates the preferred invocation binding to
  1166.    be used for this method. Generally, methods are invoked on the basis
  1167.    of information provided by the class that introduces the method
  1168.    definition (called offset resolution). However, this requires that
  1169.    the class of the method's target object be known at compile time.
  1170.    Sometimes a method definition is introduced by several classes. For
  1171.    such methods, name lookup (which invokes the method using the
  1172.    method's name as a key) is a more appropriate choice.
  1173.  
  1174.    This attribute defaults to offset.
  1175.  
  1176. description3   [optional]
  1177. is a description of the method and must be in the form of a comment
  1178. (see Class Section for the discussion about comment styles).
  1179.  
  1180. method name   [optional]
  1181.    is the name of a method introduced by an ancestor class that this
  1182.    class will re-implement. Attributes on an override method have the
  1183.    same meaning as previously stated for new methods.
  1184.  
  1185. description4   [optional]
  1186.    is a description of the override method or of your reason for
  1187.    overriding it, or both, and must be in the form of a comment (see
  1188.    Class Section for the discussion about comment styles).
  1189.