home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * This file was generated by the SOM Compiler.
- * FileName: somcls.xh.
- * Generated using:
- * SOM Precompiler spc: 1.22
- * SOM Emitter emitxh: 1.11
- */
-
- /*
- * SOMClass: System Object Model base metaclass
- * Copyright (c) International Business Machines Corporation
- * 1991, 1992
- */
-
- #ifndef somcls_xh
- #define somcls_xh
- class SOMClass;
-
- /*
- * This is the SOM metaclass. That is, the instances of this class
- * are class objects. When the SOM environment is created one
- * instance of this class with the external name
- * <SOMClassClassData.classObject> is created. This class object is
- * unique in that it is its own class object. That is,
- * _SOMClass == _somGetClass(SOMClassClassData.classObject).
- * SOMClass can be subclassed just like any SOM class. The subclasses
- * of SOMClass are new metaclasses and can generate class objects with
- * different implementations than those produced by _SOMClass.
- */
-
- #define SOMClass_MajorVersion 1
- #define SOMClass_MinorVersion 1
-
- /* C++ som defs */
- #include <som.xh>
-
- /* C++ parent def */
- #ifndef somobj_xh
- #include <somobj.xh>
- #endif
-
- #ifndef SOMClass_API
- #define SOMClass_API
- /*
- * The Class API
- */
-
- /* A procedure to create the SOMClass Class */
- SOMEXTERN SOMClass * SOMLINK SOMClassNewClass(
- integer4 majorVersion,
- integer4 minorVersion);
-
- /* A macro to return the SOMClass class object */
- #define _SOMClass ((SOMClass*)SOMClassClassData.classObject)
-
- /* The static interface to SOMClass and its instances */
- SOMEXTERN struct SOMClassClassDataStructure {
- SOMClass *classObject;
- somMToken somNew;
- somMToken somRenew;
- somMToken somInitClass;
- somMToken somClassReady;
- somMToken somGetName;
- somMToken somGetParent;
- somMToken somDescendedFrom;
- somMToken somCheckVersion;
- somMToken somFindMethod;
- somMToken somFindMethodOk;
- somMToken somSupportsMethod;
- somMToken somGetNumMethods;
- somMToken somGetInstanceSize;
- somMToken somGetInstanceOffset;
- somMToken somGetInstancePartSize;
- somMToken somGetMethodIndex;
- somMToken somGetNumStaticMethods;
- somMToken somGetPClsMtab;
- somMToken somGetClassMtab;
- somMToken somAddStaticMethod;
- somMToken somOverrideSMethod;
- somMToken somAddDynamicMethod;
- somMToken somGetMethodOffset;
- somMToken somGetApplyStub;
- somMToken somFindSMethod;
- somMToken somFindSMethodOk;
- somMToken somGetMethodDescriptor;
- somMToken somGetNthMethodInfo;
- somMToken somSetClassData;
- somMToken somGetClassData;
- somMToken somNewNoInit;
- somMToken somRenewNoInit;
- somMToken somGetInstanceToken;
- somMToken somGetMemberToken;
- somMToken somSetMethodDescriptor;
- somMToken somGetMethodData;
- } SOMClassClassData;
-
- /*
- * -- Typedefs for Procedures that support SOMClass Methods
- */
- extern "C" {
- typedef somMToken (SOMLINK *somTD_SOMClass_somAddStaticMethod)(SOMClass *somSelf,INOUT somId methodId,INOUT somId methodDescriptor,IN somMethodProc *method,IN somMethodProc *redispatchStub,IN somMethodProc *applyStub);
- typedef void (SOMLINK *somTD_SOMClass_somClassReady)(SOMClass *somSelf);
- typedef void (SOMLINK *somTD_SOMClass_somInitClass)(SOMClass *somSelf,IN zString className,IN SOMObject *parentClass,IN integer4 instanceSize,IN int maxStaticMethods,IN integer4 majorVersion,IN integer4 minorVersion);
- typedef void (SOMLINK *somTD_SOMClass_somOverrideSMethod)(SOMClass *somSelf,INOUT somId methodId,IN somMethodProc *method);
- typedef SOMObject * (SOMLINK *somTD_SOMClass_somNew)(SOMClass *somSelf);
- typedef SOMObject * (SOMLINK *somTD_SOMClass_somNewNoInit)(SOMClass *somSelf);
- typedef SOMObject * (SOMLINK *somTD_SOMClass_somRenew)(SOMClass *somSelf,IN void *obj);
- typedef SOMObject * (SOMLINK *somTD_SOMClass_somRenewNoInit)(SOMClass *somSelf,IN void *obj);
- typedef somMethodProc * (SOMLINK *somTD_SOMClass_somGetApplyStub)(SOMClass *somSelf,INOUT somId methodId);
- typedef somClassDataStructure * (SOMLINK *somTD_SOMClass_somGetClassData)(SOMClass *somSelf);
- typedef somMethodTab * (SOMLINK *somTD_SOMClass_somGetClassMtab)(SOMClass *somSelf);
- typedef somDToken (SOMLINK *somTD_SOMClass_somGetInstanceToken)(SOMClass *somSelf);
- typedef somDToken (SOMLINK *somTD_SOMClass_somGetMemberToken)(SOMClass *somSelf,integer4 memberOffset,somDToken instanceToken);
- typedef integer4 (SOMLINK *somTD_SOMClass_somGetInstanceOffset)(SOMClass *somSelf);
- typedef integer4 (SOMLINK *somTD_SOMClass_somGetInstancePartSize)(SOMClass *somSelf);
- typedef integer4 (SOMLINK *somTD_SOMClass_somGetInstanceSize)(SOMClass *somSelf);
- typedef somId (SOMLINK *somTD_SOMClass_somGetMethodDescriptor)(SOMClass *somSelf,IN somId methodId);
- typedef zString (SOMLINK *somTD_SOMClass_somGetName)(SOMClass *somSelf);
- typedef int (SOMLINK *somTD_SOMClass_somGetNumMethods)(SOMClass *somSelf);
- typedef int (SOMLINK *somTD_SOMClass_somGetNumStaticMethods)(SOMClass *somSelf);
- typedef SOMClass * (SOMLINK *somTD_SOMClass_somGetParent)(SOMClass *somSelf);
- typedef somMethodTab * (SOMLINK *somTD_SOMClass_somGetPClsMtab)(SOMClass *somSelf);
- typedef void (SOMLINK *somTD_SOMClass_somSetClassData)(SOMClass *somSelf,IN somClassDataStructure *cds);
- typedef int (SOMLINK *somTD_SOMClass_somCheckVersion)(SOMClass *somSelf,IN integer4 majorVersion,IN integer4 minorVersion);
- typedef int (SOMLINK *somTD_SOMClass_somDescendedFrom)(SOMClass *somSelf,IN SOMClass *aClassObj);
- typedef int (SOMLINK *somTD_SOMClass_somSupportsMethod)(SOMClass *somSelf,INOUT somId mId);
- typedef int (SOMLINK *somTD_SOMClass_somFindMethod)(SOMClass *somSelf,INOUT somId methodId,OUT somMethodProc **m);
- typedef int (SOMLINK *somTD_SOMClass_somFindMethodOk)(SOMClass *somSelf,INOUT somId methodId,OUT somMethodProc **m);
- typedef somMethodProc * (SOMLINK *somTD_SOMClass_somFindSMethod)(SOMClass *somSelf,INOUT somId methodId);
- typedef somMethodProc * (SOMLINK *somTD_SOMClass_somFindSMethodOk)(SOMClass *somSelf,INOUT somId methodId);
- }
-
-
- #endif /* SOMClass_API */
-
-
- /*
- * -- The C++ Wrapper Class for SOMClass
- */
- class SOMClass : public SOMObject
- {
- public:
-
- void *operator new(size_t size)
- {
- (void) size;
- if (!SOMClassClassData.classObject)
- SOMClassNewClass(SOMClass_MajorVersion,SOMClass_MinorVersion);
- return (void *)
- ((somTD_SOMClass_somNew)
- somResolve(SOM_TestCls((SOMAny *)(SOMClassClassData.classObject),
- SOMClassClassData.classObject),
- SOMClassClassData.somNew))
- ((SOMClass*)(SOMClassClassData.classObject));
- }
-
- void operator delete(void * obj)
- {
- ((SOMObject *)obj)->somFree();
- }
-
- /*
- * Initialization / Termination / Class construction group
- */
-
- /* public method: somAddStaticMethod */
-
- /*
- * Adds/overrides the indicated method, returns the value that
- * should be used to set the method slot in the class data structure
- * for this method name.
- *
- * <methodDescriptor> is a somId for a string describing the calling
- * sequence to this method as described in <somcGetNthMethodInfo>
- * defined in the SOMObject class definition.
- *
- * <method> is the actual method procedure for this method
- *
- * <redispatchStub> is a procedure with the same calling sequence as
- * <method> that re-dispatches the method to one of this class's
- * dispatch functions.
- *
- * <applyStub> is a procedure that takes a standard variable argument
- * list data structure applies it to its target object by calling
- * <method> with arguments derived from the data structure. Its
- * calling sequence is the same as the calling sequence of the
- * dispatch methods defined in SOMObject. This stub is used in the
- * support of the dispatch methods used in some classes. In classes
- * where the dispatch functions do not need such a function this
- * parameter may be null.
- */
- somMToken somAddStaticMethod(INOUT somId methodId,
- INOUT somId methodDescriptor,
- IN somMethodProc *method,
- IN somMethodProc *redispatchStub,
- IN somMethodProc *applyStub)
- {
- return (somMToken) SOM_Resolve((SOMAny *)this,SOMClass,somAddStaticMethod)
- (this,methodId,methodDescriptor,method,redispatchStub,applyStub);
- }
-
-
- /* public method: somClassReady */
-
- /*
- * This method is invoked when all of the static initialization for
- * the class has been finished. The default implementation simply
- * registers the newly constructed class with the SOMClassMgr.
- * Metaclasses may override this method to augment the class construction
- * sequence in any way that they wish.
- */
- void somClassReady()
- {
- SOM_Resolve((SOMAny *)this,SOMClass,somClassReady)
- (this);
- }
-
-
- /* public method: somInitClass */
-
- /*
- * Initializes <self>.
- * <parentClass> is the parent (or parent class) of this class, it may
- * be NULL in which case it defaults to SOMObject (actually
- * SOMObjectClassData.classObject the class object for SOMObject).
- * If a parent class is specifed then it must have already been created
- * as a pointer to its class object is required.
- *
- * <instanceSize> should be just the space needed for this class, it
- * is not necessary to consider the parent class's (if any) space
- * requirements.
- *
- * <maxStaticMethods> should be just the static methods defined by
- * this class, it is not necessary to consider the parent class's
- * methods (if any), even if they are overriden in this class.
- *
- * <majorVersion> indicates the major version number for this
- * implementation of the class definition, and <minorVersion>
- * indicates the minor version number.
- */
- void somInitClass(IN zString className,
- IN SOMObject *parentClass,
- IN integer4 instanceSize,
- IN int maxStaticMethods,
- IN integer4 majorVersion,
- IN integer4 minorVersion)
- {
- SOM_Resolve((SOMAny *)this,SOMClass,somInitClass)
- (this,className,parentClass,instanceSize,maxStaticMethods,majorVersion,minorVersion);
- }
-
-
- /* public method: somOverrideSMethod */
-
- /*
- * This method can be used instead of <somAddStaticMethod> or
- * <somAddDynamicMethod> when it is known that the class' parent
- * class already supports this method. This call does not require the
- * method descriptor and stub methods that the others do.
- */
- void somOverrideSMethod(INOUT somId methodId,
- IN somMethodProc *method)
- {
- SOM_Resolve((SOMAny *)this,SOMClass,somOverrideSMethod)
- (this,methodId,method);
- }
-
-
- /*
- * Instance creation / Constructor group
- */
-
- /* public method: somNew */
-
- /*
- * Make an instance of this class. When applied to _SOMClass, or any
- * other metaclass object, this will produce a new class object;
- * when applied to a regular class object, this will produce an
- * instance of that class. The somInit method of the newly created
- * object is then invoked automatically.
- */
- SOMObject * somNew()
- {
- return (SOMObject*) SOM_Resolve((SOMAny *)this,SOMClass,somNew)
- (this);
- }
-
-
- /* public method: somNewNoInit */
-
- /*
- * Equivalent to somNew except that somInit is not automatically invoked.
- */
- SOMObject * somNewNoInit()
- {
- return (SOMObject*) SOM_Resolve((SOMAny *)this,SOMClass,somNewNoInit)
- (this);
- }
-
-
- /* public method: somRenew */
-
- /*
- * Make an instance of this class, but use the space pointed to by
- * <obj> rather than allocating new space for the object. Note: no
- * test is made to insure that <obj> points to enough space. <obj>
- * is returned, but it is now a pointer to a valid, initialized,
- * object (the somInit method of the "renewed" object is invoked
- * automatically).
- */
- SOMObject * somRenew(IN void *obj)
- {
- return (SOMObject*) SOM_Resolve((SOMAny *)this,SOMClass,somRenew)
- (this,obj);
- }
-
-
- /* public method: somRenewNoInit */
-
- /*
- * Equivalent to somRenew except that somInit is not automatically invoked.
- */
- SOMObject * somRenewNoInit(IN void *obj)
- {
- return (SOMObject*) SOM_Resolve((SOMAny *)this,SOMClass,somRenewNoInit)
- (this,obj);
- }
-
-
- /* public method: somGetApplyStub */
-
- /*
- * Returns the apply stub associated with the specified method. NULL
- * is returned if the method is not supported by this class. An apply
- * stub is a procedure that is called with a fixed calling sequence,
- * namely (SOMObject *self, somId methodId, somId descriptor, ap_list
- * ap) where <ap> is a varargs data structure that contains the actual
- * argument list to be passed to the method. The apply stub fowards
- * the call to its associated method and then returns any result
- * produced by the method.
- */
- somMethodProc * somGetApplyStub(INOUT somId methodId)
- {
- return (somMethodProc*) SOM_Resolve((SOMAny *)this,SOMClass,somGetApplyStub)
- (this,methodId);
- }
-
-
- /* public method: somGetClassData */
-
- /*
- * Returns a pointer to the static <className>ClassData structure.
- */
- somClassDataStructure * somGetClassData()
- {
- return (somClassDataStructure*) SOM_Resolve((SOMAny *)this,SOMClass,somGetClassData)
- (this);
- }
-
-
- /* public method: somGetClassMtab */
-
- /*
- * Returns a pointer to the method table of this class.
- */
- somMethodTab * somGetClassMtab()
- {
- return (somMethodTab*) SOM_Resolve((SOMAny *)this,SOMClass,somGetClassMtab)
- (this);
- }
-
-
- /* public method: somGetInstanceToken */
-
- /*
- * Returns a token that identifies the introduced portion of this class
- * within itself or any derived class. This token can be subsequently
- * passed to the run-time somDataResolve function to locate the instance
- * data introduced by this class.
- */
- somDToken somGetInstanceToken()
- {
- return (somDToken) SOM_Resolve((SOMAny *)this,SOMClass,somGetInstanceToken)
- (this);
- }
-
-
- /* public method: somGetMemberToken */
-
- /*
- * Returns a token that represents the data member at offset
- * "memberOffset" within the introduced portion of the class identified
- * by instanceToken. The instance token must have been obtained from a
- * previous invocation of somGetInstanceToken. The returned member
- * token can be subsequently passed to the run-time somDataResolve
- * function to locate the data member.
- */
- somDToken somGetMemberToken(integer4 memberOffset,
- somDToken instanceToken)
- {
- return (somDToken) SOM_Resolve((SOMAny *)this,SOMClass,somGetMemberToken)
- (this,memberOffset,instanceToken);
- }
-
-
- /* public method: somGetInstanceOffset */
-
- /*
- * Returns the offset in the body part of this [class] object for the
- * instance data introduced by this class, as the distance in bytes along
- * the class' "left-hand" derivation path.
- */
- integer4 somGetInstanceOffset()
- {
- return (integer4) SOM_Resolve((SOMAny *)this,SOMClass,somGetInstanceOffset)
- (this);
- }
-
-
- /* public method: somGetInstancePartSize */
-
- /*
- * Returns the size in bytes of the instance data introduced by this
- * class. This does not include the instance data space required for
- * this class' ancestor or descendent classes.
- */
- integer4 somGetInstancePartSize()
- {
- return (integer4) SOM_Resolve((SOMAny *)this,SOMClass,somGetInstancePartSize)
- (this);
- }
-
-
- /* public method: somGetInstanceSize */
-
- /*
- * Returns the total size of an instance of <self>.
- * All instances of <self> have the same size.
- */
- integer4 somGetInstanceSize()
- {
- return (integer4) SOM_Resolve((SOMAny *)this,SOMClass,somGetInstanceSize)
- (this);
- }
-
-
- /* public method: somGetMethodDescriptor */
-
- /*
- * Returns the method descriptor for the indicated method. If
- * this object does not support the indicated method then NULL is
- * returned.
- */
- somId somGetMethodDescriptor(IN somId methodId)
- {
- return (somId) SOM_Resolve((SOMAny *)this,SOMClass,somGetMethodDescriptor)
- (this,methodId);
- }
-
-
- /* public method: somGetName */
-
- /*
- * Returns this object's class name as a NULL terminated string.
- */
- zString somGetName()
- {
- return (zString) SOM_Resolve((SOMAny *)this,SOMClass,somGetName)
- (this);
- }
-
-
- /* public method: somGetNumMethods */
-
- /*
- * Returns the number of methods currently supported by this class,
- * including inherited methods (both static and dynamic).
- */
- int somGetNumMethods()
- {
- return (int) SOM_Resolve((SOMAny *)this,SOMClass,somGetNumMethods)
- (this);
- }
-
-
- /* public method: somGetNumStaticMethods */
-
- /*
- * Returns the number of static methods that this class has. This is
- * used by a child class in initializing its method table.
- */
- int somGetNumStaticMethods()
- {
- return (int) SOM_Resolve((SOMAny *)this,SOMClass,somGetNumStaticMethods)
- (this);
- }
-
-
- /* public method: somGetParent */
-
- /*
- * Returns the parent class of self (along its "left-hand" derivation
- * path), if one exists and NULL otherwise.
- */
- SOMClass * somGetParent()
- {
- return (SOMClass*) SOM_Resolve((SOMAny *)this,SOMClass,somGetParent)
- (this);
- }
-
-
- /* public method: somGetPClsMtab */
-
- /*
- * Returns a pointer to the method table of this class's parent class
- * (along its "left-hand" derivation path). If this class is a root
- * class (SOMObject), NULL is returned.
- */
- somMethodTab * somGetPClsMtab()
- {
- return (somMethodTab*) SOM_Resolve((SOMAny *)this,SOMClass,somGetPClsMtab)
- (this);
- }
-
-
- /* public method: somSetClassData */
-
- /*
- * Sets the class' pointer to the static <className>ClassData structure.
- */
- void somSetClassData(IN somClassDataStructure *cds)
- {
- SOM_Resolve((SOMAny *)this,SOMClass,somSetClassData)
- (this,cds);
- }
-
-
- /* public method: somCheckVersion */
-
- /*
- * Returns 1 (true) if the implementation of this class is
- * compatible with the specified major and minor version number and
- * false (0) otherwise. An implementation is compatible with the
- * specified version numbers if it has the same major version number
- * and a minor version number that is equal to or greater than
- * <minorVersion>. The major, minor version number pair (0,0) is
- * considered to match any version. This method is usually called
- * immediately after creating the class object to verify that a
- * dynamically loaded class definition is compatible with a using
- * application.
- */
- int somCheckVersion(IN integer4 majorVersion,
- IN integer4 minorVersion)
- {
- return (int) SOM_Resolve((SOMAny *)this,SOMClass,somCheckVersion)
- (this,majorVersion,minorVersion);
- }
-
-
- /* public method: somDescendedFrom */
-
- /*
- * Returns 1 (true) if <self> is a descendent class of <aClassObj> and
- * 0 (false) otherwise. Note: a class object is considered to be
- * descended itself for the purposes of this method.
- */
- int somDescendedFrom(IN SOMClass *aClassObj)
- {
- return (int) SOM_Resolve((SOMAny *)this,SOMClass,somDescendedFrom)
- (this,aClassObj);
- }
-
-
- /* public method: somSupportsMethod */
-
- /*
- * Returns 1 (true) if the indicated method is supported by this
- * class and 0 (false) otherwise.
- */
- int somSupportsMethod(INOUT somId mId)
- {
- return (int) SOM_Resolve((SOMAny *)this,SOMClass,somSupportsMethod)
- (this,mId);
- }
-
-
- /* public method: somFindMethod */
-
- /*
- * Finds the method procedure associated with <methodId> for this
- * class and sets <m> to it. 1 (true) is returned when the
- * method procedure is directly callable and 0 (false) is returned
- * when the method procedure is a dispatch function.
- *
- * If the class does not support the specified method then
- * <m> is set to NULL and the return value is meaningless.
- *
- * Returning a dispatch function does not guarantee that a
- * class supports the specified method; the dispatch may fail.
- */
- int somFindMethod(INOUT somId methodId,
- OUT somMethodProc **m)
- {
- return (int) SOM_Resolve((SOMAny *)this,SOMClass,somFindMethod)
- (this,methodId,m);
- }
-
-
- /* public method: somFindMethodOk */
-
- /*
- * Just like <somFindMethod> except that if the method is not
- * supported then an error is raised and execution is halted.
- */
- int somFindMethodOk(INOUT somId methodId,
- OUT somMethodProc **m)
- {
- return (int) SOM_Resolve((SOMAny *)this,SOMClass,somFindMethodOk)
- (this,methodId,m);
- }
-
-
- /* public method: somFindSMethod */
-
- /*
- * Finds the indicated method, which must be a static method defined
- * for this class, and returns a pointer to its method procedure.
- *
- * If the method is not defined (as a static method or at all) for
- * this class then a NULL pointer is returned.
- */
- somMethodProc * somFindSMethod(INOUT somId methodId)
- {
- return (somMethodProc*) SOM_Resolve((SOMAny *)this,SOMClass,somFindSMethod)
- (this,methodId);
- }
-
-
- /* public method: somFindSMethodOk */
-
- /*
- * Just like <somFindSMethod> except that an error is raised if the
- * method is not defined for this class.
- */
- somMethodProc * somFindSMethodOk(INOUT somId methodId)
- {
- return (somMethodProc*) SOM_Resolve((SOMAny *)this,SOMClass,somFindSMethodOk)
- (this,methodId);
- }
-
-
-
- }; /* SOMClass */
-
-
-
- #endif /* somcls_xh */
-