Skip to content
This repository was archived by the owner on Jun 13, 2018. It is now read-only.
This repository was archived by the owner on Jun 13, 2018. It is now read-only.

Wrong context variable taken by gsl #145

@MaxSagebaum

Description

@MaxSagebaum

If have the setup that I create an additional attribute 'primalCall' on my nodes in the statup of the script:

for context.function as curFunction

  curFunction.primalCall2 = "$(curFunction.name)"
  curFunction.primalCall = "$(curFunction.name)"
endfor

In the function that I call to generate the code, I have the same value as an local variable:

function generateExpression(curFunction)
  primalCall = "this.getValue()"
> return $(my.curFunction.primalCall2)($(primalCall));
> return $(my.curFunction.primalCall)($(primalCall));
endfunction

The output of gsl is now:

 return doSomething(this.getValue());
 return this.getValue()(this.getValue());

So the xml attribute 'primalCall' is not taken. Instead gls takes the value of the lokal variable 'primalCall'.

It is probably just an return error because if 'curFunction' does not have the attribute 'primalCall' then an error is generated, that such attribute does not exist.

I have attached the xml and gls file. The generation is done with:

gsl -script:contextError.gsl -a def.xml error.hpp

I could not upload the files so here they are in plain text:

contextError.gsl

.ignorecase = 0 
.template 0

for context.function as curFunction

  curFunction.primalCall2 = "$(curFunction.name)"
  curFunction.primalCall = "$(curFunction.name)"
endfor

function generateExpression(curFunction)
  primalCall = "this.getValue()"
> return $(my.curFunction.primalCall2)($(primalCall));
> return $(my.curFunction.primalCall)($(primalCall));
endfunction

.endtemplate
.output "$(switches.arg1)"
.for context.function as curFunction
.  generateExpression(curFunction)
.endfor

def.xml

<context>
  <function name="doSomething" rType="Vector">
    <arg type="Vector" name="v1"/>
    <arg type="Vector" name="v2"/>
  </function>
</context>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions