25.01.2015 Views

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Method Generator Context<br />

6. It copies the results of each method generator (lines of code plus any changes to other<br />

method keywords) into the compiled class structure (used to generate the actual code for<br />

the class).<br />

Note that the original method signature (arguments and return type), as well as any method<br />

keyword values, are used for the generated method. If you specify a method generator<br />

as having a return type of %Integer, then the actual method will have a return type of<br />

%Integer.<br />

7. It generates the executable code for the class by combining the code generated by the<br />

method generators along with the code from all the non-method generator methods.<br />

18.3 Method Generator Context<br />

The key to implementing method generators is understanding the context in which method<br />

generator code is executed. As described in the previous section, the class compiler invokes<br />

the method generator code at the point after it has resolved class inheritance but before it has<br />

generated code for the class. When it invokes method generator code, the class compiler<br />

creates the following object instances and makes them available to the method generator<br />

code:<br />

<strong>Objects</strong> Available to Method Generators<br />

Object<br />

%code<br />

%class<br />

%method<br />

%compiledclass<br />

%compiledmethod<br />

Description<br />

An instance of the %Stream.MethodGenerator class. This is a<br />

stream into which you write the code for method.<br />

An instance of the %Dictionary.ClassDefinition class. It contains<br />

the original definition of the class being compiled.<br />

An instance of the %Dictionary.MethodDefinition class. It contains<br />

the original definition of the method being compiled.<br />

An instance of the %Dictionary.CompiledClass class. It contains<br />

the compiled definition of the class being compiled. It contains<br />

information about the class after inheritance has been resolved<br />

(such as the list of all properties and methods, including those<br />

inherited from superclasses).<br />

An instance of the %Dictionary.CompiledMethod class. It contains<br />

the compiled definition of the method being generated.<br />

<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 157

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!