SomAddDynamicMethod

This method adds a new dynamic instance method to a class. Dynamic methods are not part of the declared interface to a class of objects, and are therefore not supported by implementation and usage bindings. Instead, dynamic methods provide a way to dynamically add new methods to a class of objects during execution. SOM provides no standard protocol for informing a user of the existence of dynamic methods and the arguments they take. Dynamic methods must be invoked using name-lookup or dispatch resolution.

Note: For backward compatibility, this method does not take an Environment parameter.


 * Original Class: SOMClass

Syntax
 SOMClass       receiver; somId          methodId; somId          methodDescriptor; somMethodPtr   method; somMethodPtr   applyStub;

somAddDynamicMethod(receiver, methodId, methodDescriptor, method, applyStub); 

Parameters

 * receiver (SOMClass) : A pointer to a SOM class object.


 * methodId (somId) : A somId that names the method.


 * methodDescriptor (somId) : A somId appropriate for requesting information concerning the method from the SOM IR. This is currently of the form : :.


 * method (somMethodPtr) : A pointer to the procedure that will implement the new method. The first argument of this procedure is the address of the object on which it is being invoked.


 * applyStub (somMethodPtr) : A pointer to a procedure that returns nothing and receives as arguments: a method receiver; an address where the return value from the method call is to be stored; a pointer to a method procedure; and a va_list containing the arguments to the method. The applyStub procedure (which is usually called by somDispatch must unload its va_list argument into separate variables of the correct type for the method, invoke its procedure argument on these variables, and then copy the result of the procedure invocation to the address specified by the return value argument.

Return Code
rc

Remarks
The somAddDynamicMethod method adds a new dynamic instance method to the receiving class. This involves recording the method's ID, descriptor, method procedure (specified by method), and apply stub in the receiving class's method data.

The arguments to this method should be non-null and obey the requirements expressed below. This is the responsibility of the implementor of a class, who in general has no knowledge of whether clients of this class will require use of the applyStub argument.

Example Code
 /* New dynamic method "newMethod1" for class "XXX" */ static char *somMN_newMethod1 = "newMethod1"; static somId somId_newMethod1 = &somMN_newMethod1; static char *somDS_newMethod1 = odq.XXX::newMethod1"; static somId somDI_newMethod1 = &somDS_newMethod1;

static void SOMLINK somAP_newMethod1(SOMObject somSelf,                                    void *__retVal,                                     somMethodProc *__methodPtr,                                     va_list __ap) { void* __somSelf = va_arg(__ap, SOMObject);

int arg1 = va_arg(__ap, int); SOM_IgnoreWarning(__retVal); ((somTD_SOMObject_newMethod1) __methodPtr) (__somSelf, arg1); } main { _somAddDynamicMethod (  XXXClassData.classObject,           /* Receiver (class object) */   somId_newMethod1,                   /* method name somId */   somDI_newMethod1,                   /* method descriptor somId */   (somMethodProc%rbl.*) newMethod1,       /* method procedure */   (somMethodProc *) somAP&newMethod1); /* method apply stub */ } 

Methods

 * somGetMethodDescriptor