From RTSC-Pedia

Jump to: navigation, search
revision tip
—— LANDSCAPE orientation
[printable version]  [offline version]offline version generated on 04-Aug-2010 21:08 UTC

XDCscript - Module-Object.Function-Name

Module method

Contents

Synopsis

 
«Mod».«methodName»

where «Mod» is an module object and «methodName» is the name of a method whose type signature is specified in a function-declaration.

Description

Methods of a module object are module-specific properties declared in the module's .xdc specification file. Only methods declared to be metaonly (directly or indirectly) can invoked from scripts; all other method name simply represent the type signature of a function that can be invoked on the target.

Meta-only methods are functions that can be directly invoked from scripts. For example, a module method getName of the module pkg.Mod can be run from a script as shown below.

 
 
var Mod = xdc.module("pkg.Mod"); /* get the module */
print(Mod.getName());            /* run a module method and print result */

Meta-only methods have a distinguished function property named $apply that allows them to be invoked with a user specified this pointer. This can be useful when a method needs to invoke the meta-only method associated with an inherited interface. Suppose for example that the pkg1.Mod module inherits from the interface pkg2.IMod. If pkg2.IMod declares and implements a method, say getName, the module pkg1.Mod can both override the implementation provided by pkg2.IMod and invoke the overridden method.

Mod.xs
 
 
 
 
function getName() {
    var sup = this.$super.getName.$apply(this, []); /* get inherited name */
    return (sup+  ":Mod");                          /* return "super_name:my_name" */
}

The $apply() function has the same signature and semantics as the JavaScript apply() method of Functions.

See also

XDCscript - Module-Object Object containing per-module-features of a module
XDCscript - Module-Object.$super The interface from which this module inherits

[printable version]  [offline version]offline version generated on 04-Aug-2010 21:08 UTC
Copyright © 2008 The Eclipse Foundation. All Rights Reserved


Views
Personal tools
package reference