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

FAQ-080923-1

How do I set a function configuration parameter

Function configuration parameters can be set by directly referencing a function (with the right type) declared in any module. For example, suppose you have a module named MyMod that defines a function named output ad you want to use this function as the value of the SysMin.outputFxn configuration parameter.

app.cfg
 
 
1
var MyMod = xdc.useModule("«somepkg».MyMod");
var SysMin = xdc.useModule("xdc.runtime.SysMin");
SysMin.outputFxn = MyMod.output;
MyMod.xdc
 
 
 
 
module MyMod {
        :
     Void output(Char *buffer, UInt len);
}

Line 1 above binds the output function provided by MyMod to the SysMin module's outputFxn configuration parameter. Note that this assignment will fail if the type of MyMod.output does not exactly match the type of SysMin.outputFxn.

To reference functions that are not in any module, you can define a new module that simply declares "legacy" functions. For example, suppose you already have a function named output that has a type signature that matches the SysMin.outputFxn configuration parameter. If you declare this in a module named MyMod as shown below, the configuration script above will work as before.

MyMod.xdc
 
 
 
module MyMod {
     extern Void output(Char *, UInt) = output;
}

Whether you use a module that provides an output function or you simply declare the existence of such an external function in your existing C code, the assignment to SysMin.outputFxn is "type safe"; i.e., the configuration engine checks the type of both the left and right hand sides of the assignment and fails if the types do not match exactly. If you don't care about type safety, the configuration engine also allows you to reference an external function without this check.

To reference a function that is not declared in any module but is guaranteed to exist in the final application, the configuration engine allows you to assign a string that begins with "&" to function type configuration parameters. The characters following "&" simply name the external function being referenced. Suppose you have a function named output that you know is compatible with SysMin.outputFxn, the configuration script below can be used to bind output to SysMin.outputFxn.

app.cfg
 
 
SysMin = xdc.useModule("xdc.runtime.SysMin");
SysMin.outputFxn = "&output";

In this case, the configuration engine does no type checking and assumes that the application will contain an external function named output that has the right type signature.

[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