A JavaScript object may be an array, accessed using array index notation ([...]
), for example, p[4]
. PODS supports arrays by providing get_element
and set_element
methods, accessed through PODS_ARRAY_GETTER
and PODS_ARRAY_SETTER
macros. When a JavaScript object is referenced with an array index subscript, M-Business Client calls the object's getMethod()
method and passes the special method name, "get_element"
.
A PODS object may also use arrays as arguments or return values of methods. This requires an implementation of the PODSArray
data type. M-Business Client provides an implementation called PODSStdArray
, which satisfies this need, but it is not as efficient as an implementation as a POD could supply to itself with knowledge
of the data that the array would contain.
For example, suppose that p
is a PODSObject
and JavaScript code executes:
var x = p[7]; |
M-Business Client calls p
's getMethod()
method and passes the method name "get_element"
. The getMethod()
method might return the type string "i_s"
and a pointer to the C function:
PODSString getElement(PODSObject* o, PODSInt32 index) { MyObject* m = (MyObject*) o; return m->strings[index]; } |
Then M-Business Client would call the function, passing the integer 7 as the value of the index
parameter.
Similarly, when M-Business Client sets an indexed property of a PODS object, M-Business Client calls the object's getMethod()
method and passes the special method name "set_element"
. The getMethod()
method should return a pointer to a method that takes two parameters: an integer index and a value. The second parameter
may be of any PODS type.
Send feedback about this page using email. | Copyright © 2008, iAnywhere Solutions, Inc. |