Book a Demo

Author Topic: Is it possible to set the code gen destination from javascript?  (Read 5063 times)

Thomas Arnbjerg

  • EA User
  • **
  • Posts: 88
  • Karma: +0/-0
    • View Profile
Hi all,
Is it possible to set the code generation destination for a C++ class created in javascript? - i.e. the contents of the 'Path' field in 'Generate code'

Thomas Arnbjerg

  • EA User
  • **
  • Posts: 88
  • Karma: +0/-0
    • View Profile
Re: Is it possible to set the code gen destination from javascript?
« Reply #1 on: June 16, 2023, 11:29:32 pm »
Found it. It's attribute GenFile.

Thomas Arnbjerg

  • EA User
  • **
  • Posts: 88
  • Karma: +0/-0
    • View Profile
Re: Is it possible to set the code gen destination from javascript?
« Reply #2 on: June 17, 2023, 12:06:34 am »
Well  not so ideal.
In the generated cpp file the first line says '#include ""', where it should say '#include "<header file name>". If I set the path from the UI and re-generate (override ) the first include statement is correct.

Any other suggestions?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Is it possible to set the code gen destination from javascript?
« Reply #3 on: June 17, 2023, 06:36:01 pm »
Maybe not what you want to hear, but write your own code generator. That's pretty easy to pick a class definition and spit out a few lines of a filled in scaffold when your target C-like languages.

q.

Thomas Arnbjerg

  • EA User
  • **
  • Posts: 88
  • Karma: +0/-0
    • View Profile
Re: Is it possible to set the code gen destination from javascript?
« Reply #4 on: June 19, 2023, 07:30:52 pm »
Ok - fixed it by adding a tagged value "implIncludes" with the needed includes as part of my script. I then modified the template "Import Section Impl" to contain the following fragment:

..
%if classTag:"implIncludes" != ""%
#include %qt%%className%.hpp%qt%
%classTag:"implIncludes"%
%else%
%fileHeaders%
%endIf%
..