Bull DPX/20 Guia do Utilizador Página 93

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 424
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 92
SOM Kernel Reference 1-81
Parameters
receiver A pointer to the class object whose method is desired.
methodId An ID that represents the name of the desired method. The
somIdFromString function can used to obtain an ID from the method’s
name.
m A pointer to the location in memory where a pointer to the specified
method’s procedure should be stored. Both methods store a NULL pointer
in this location (if the method does not exist) or a value that can be called.
Return Value
The somFindMethod and somFindMethodOk methods return TRUE when the method
procedure can be called directly and FALSE when the method procedure is a dispatch
function.
C Example
Assuming that the Animal class introduces the method setSound, the type name for the
setSound method procedure type will be somTD_Animal_setSound, as illustrated in the
following example:
#include <animal.h>
void main()
{
Animal myAnimal;
somId somId_setSound;
somTD_Animal_setSound methodPtr;
Environment *ev = somGetGlobalEnvironment();
myAnimal = AnimalNew();
/* ----------------------------------------
: Next three lines are equivalent to
_setSound(myAnimal, ev, ”Roar!!!”);
---------------------------------------- */
somId_setSound = somIdFromString(”setSound”);
_somFindMethod (_somGetClass(myAnimal),
somId_setSound, &methodPtr);
methodPtr(myAnimal, ev, ”Roar!!!”);
/* ---------------------------------------- */
_display(myAnimal, ev);
_somFree(myAnimal);
}
/*
Program Output:
This Animal says
Roar!!!
*/
Original Class
SOMClass
Related Information
Methods: somFindSMethod, somFindSMethodOk, somSupportsMethod,
somDispatch, somClassDispatch
Functions: somApply, somResolve, somClassResolve, somResolveByName,
somParentNumResolve
Macros: SOM_Resolve, SOM_ResolveNoCheck, SOM_ParentNumResolve
Vista de página 92
1 2 ... 88 89 90 91 92 93 94 95 96 97 98 ... 423 424

Comentários a estes Manuais

Sem comentários