1、. _modifying-arguments:Modifying Arguments-. _conversionrule:conversion-rule The conversion-rule node allows you to write customized code to convert the given argument between the target language and C+, and it is a child of the modify-argument node: . code-block: xml / the code This node is typical
2、ly used in combination with the replace-type and remove-argument nodes. The given code is used instead of the generators conversion code. Writing %N in the code (where N is a number), will insert the name of the nth argument. Alternatively, %in and %out which will be replaced with the name of the co
3、nversions input and output variable, respectively. Note the output variable must be declared explicitly, for example: . code-block: xml bool %out = (bool) %in; . note: You can also use the conversion-rule node to specify :ref:a conversion code which will be used instead of the generators conversion
4、code everywhere for a given type . _remove-argument:remove-argument The remove-argument node removes the given argument from the functions signature, and it is a child of the modify-argument node. . code-block: xml . _rename-to:rename to The rename to node is used to rename a argument and use this n
5、ew name in the generated code. . code-block: xml . _remove-default-expression:remove-default-expression The remove-default-expression node disables the use of the default expression for the given argument, and it is a child of the modify-argument node. . code-block: xml . _replace-default-expression
6、:replace-default-expression The replace-default-expression node replaces the specified argument with the expression specified by the with attribute, and it is a child of the modify-argument node. . code-block: xml . _replace-type:replace-type The replace-type node replaces the type of the given argu
7、ment to the one specified by the modified-type attribute, and it is a child of the modify-argument node. . code-block: xml If the new type is a class, the modified-type attribute must be set to the fully qualified name (including name of the package as well as the class name). _define-ownership:defi
8、ne-ownership The define-ownership tag indicates that the function changes the ownership rules of the argument object. The class attribute specifies the class of function where to inject the ownership altering code. The owner attribute specifies the new ownership of the object. It accepts the followi
9、ng values: * target: the target language will assume full ownership of the object. The native resources will be deleted when the target language object is finalized. * c+: The native code assumes full ownership of the object. The target language object will not be garbage collected. * default: The o
10、bject will get default ownership, depending on how it was created. . code-block: xml . _reference-count:reference-count The reference-count tag dictates how an argument should be handled by the target language reference counting system (if there is any), it also indicates the kind of relationship th
11、e class owning the function being modified has with the argument. For instance, in a model/view relation a view receiving a model as argument for a *setModel* method should increment the models reference counting, since the model should be kept alive as much as the view lives. Remember that out hypo
12、thetical view could not become parent of the model, since the said model could be used by other views as well. The action attribute specifies what should be done to the argument reference counting when the modified method is called. It accepts the following values: * add: increments the argument ref
13、erence counter. * add-all: increments the reference counter for each item in a collection. * remove: decrements the argument reference counter. * set: will assign the argument to the variable containing the reference. * ignore: does nothing with the argument reference counter (sounds worthless, but
14、could be used in situations where the reference counter increase is mandatory by default). . code-block: xml The variable-name attribute specifies the name used for the variable that holds the reference(s). _replace-value:replace-value The replace-value attribute lets you replace the return statemen
15、t of a function with a fixed string. This attribute can only be used for the argument at index 0, which is always the functions return value. . code-block: xml . _parent:parent The parent node lets you define the argument parent which will take ownership of argument and will destroy the C+ child object when the parent is destroyed. . code-block: xml In the index argument you must specify the parent argument. The action *add* creates a parent link between objects, while *remove* will undo the parentage relationship.