Chapter 9 Generation Reference Guide (GTL)


Object members

An object member can be a volatile attribute, a standard property, a template or an extended attribute. There can be three types of standard property: boolean, string or object. The value of a standard property can be:

The value of a template is the result of its translation (note that a template may be defined in terms of itself, that is to say recursively).

The value of an extended attribute may itself be a template, in which case it is translated. This allows for the definition of templates on a per object (instance) basis instead of a per metaclass basis.

To avoid name collisions when a template evaluation spans multiple targets, one may prefix both extended attributes and templates by their parent target code. For example: %Java::strictfp% or %C++::definition%

Template names may also be prefixed by their parent metaclass name. This allows for the invocation of an overridden template, actually bypassing the standard dynamic template resolution mechanism. For example : %Classifier::definition%

A parameter list can optionally be specified. Parameter values should not contain any % characters and should be separated by commas. Parameters are passed as local variables @1, @2, @3... defined in the translation scope of the template.

If the template MyTemplate is defined as:

Parameter1 = %@1%

Parameter2 = %@2%

Then the evaluation of %MyTemplate(MyParam1, MyParam2)% will yield:

Parameter1 = MyParam1

Parameter2 = MyParam2

Volatile attributes

Volatile attributes may be defined through the .set_object and .set_value macros.

If the scope is an object scope, a volatile attribute is defined. This attribute will be available on the corresponding object regardless of the scope hierarchy. Volatile attributes shadow standard attributes. Once defined, they remain available until the end of the current generation process.

The "this" keyword returns an object scope and allows you to define volatile attributes on the object which is active in the current scope.

If the scope is a template scope , a standard local variable is defined.

Examples:

.set_value(this.key, %Code%-%ObjectID%)

defines the key volatile attribute on the current object

eg. .set_object(this.baseClass, ChildGeneralizations.First.ParentObject)

defines the baseClass object-type volatile attribute on the current object.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.