Getting and setting properties

JavaScript allows objects to have named properties. When JavaScript code gets a property of a PODS object, M-Business Client calls the object's getMethod() method and passes a special method name consisting of the prefix "get_", plus the property name. For example, if p is a PODS object and JavaScript calls

var x = p.color;

then M-Business Client calls p's getMethod() method and asks for a method named "get_color". Any method returned as a property getter must take no parameters, other than the PODS object, and must return a value. For example, the get_color method could have type "_s" or "_I".

Similarly, when JavaScript code sets a property of a PODS object, M-Business Client asks the object for a method whose name is "set_", plus the property name. Any method returned as a property setter must take a single parameter and must return no value. For example, a set_color method could have type "s" or "I". If you execute the JavaScript code

p.color = "blue";

and the set_color method has type "s", then M-Business Client passes the string "blue" as the method's first parameter. If the set_color method has type I, then M-Business Client reports an error because the string "blue" cannot be converted to an integer.

The pods.h file contains the macros PODS_GETTER_PREFIX and PODS_SETTER_PREFIX, which expand to the strings "get_" and "set_", respectively. In your code you should use these macros rather than the hard-coded strings "get_" and "set_". The pods.h file also contains the macros PODS_GETTER and PODS_SETTER that expand a property name to the name of its getter or setter method.