Question
Stefan Cronje · Jan 25

Generating Method Arguments with objectgenerator

Hi *,

I want to dynamically generate the arguments of a method during compile time.

'For example, I want the following method

ClassMethod DoCleverStuf() As %Status [ CodeMode = objectgenerator ]
{
    do %code.WriteLine("    Set tSC = $$$OK")
    ...
}

to look like this in the .int code.

ClassMethod DoCleverStuf(pValue1 As %Integer, pValue2 As %String) As %Status [ CodeMode = objectgenerator ]
{
    // some generated code will be here
}

Is this possible? Or alternativel;y, can I generate a whole method at compile time?

Thanks.

Product version: IRIS 2022.3
0
0 84
Discussion (2)2
Log in or sign up to continue

Use args... to supply a variable number of parameters:

ClassMethod DoCleverStuf(args...) As %Status [ CodeMode = objectgenerator ]
{
    do %code.WriteLine("    For i=1:1:args {")
    do %code.WriteLine("        Write args(i)")
    do %code.WriteLine("    }")
    do %code.WriteLine("    Set tSC = $$$OK")
    ...
}

can I generate a whole method at compile time?

You can use projections to do that. Here's an example.