How M-Business Client uses getMethod( )

Note

If you do not know the names of methods within a PODS object, no method currently is provided to query the object for a list of its methods.

When JavaScript code invokes a method on a PODS object, M-Business Client calls the object's getMethod() method, which is one of the methods in the PODSObject interface. The getMethod() method has the following prototype:

PODSMethod getMethod(PODSString name, PODSString* type)

PODSMethod is defined as follows in pods.h:

typedef void (*PODSMethod)(PODSObject* self,...);

M-Business Client passes the method's name as the first argument to getMethod(). If the object has no method with the given name, getMethod() returns NULL and a JavaScript error results. Otherwise, getMethod() returns a non-null PODSMethod(), which is a pointer to a function that implements the method.

As detailed in Objects, interfaces, and methods, as with any PODS method, this function's first argument is a pointer to the object whose method is being called; the function may take additional method arguments as well. The getMethod() method also returns a string that defines the types of the method's parameters and return value. For information on this type string, see Type strings returned by getMethod( ).

As an example, suppose that JavaScript code is calling a method compute of a PODS object:

var p = CreateObject("Acme.Computer"); 
var s = p.compute("hello", "world");

M-Business Client calls the PODS object's getMethod() method, passing the string "compute" as the name argument. Suppose that the object implements the method using the following C function:

PODSInt32 compute(PODSObject* *self, PODSString s, PODSString t)
{ 
    return (PODSInt32) (strlen(s) + strlen(t)); 
}

Then the getMethod() method returns a pointer to the compute function. The getMethod() method also returns the type string "ss_i", which indicates that the method takes two string arguments and returns an integer. For a complete description of type strings returned by getMethod(), see Type strings returned by getMethod( ).

When JavaScript engine calls this function, it passes a pointer to the object p as the first parameter (self), then passes the strings "hello" and "world" as the second and third parameters.


Getting and setting properties
Indexed properties