design-automation / mobius-parametric-modeller

Möbius for parametric modelling.
https://design-automation.github.io/mobius-parametric-modeller/
MIT License
10 stars 6 forks source link

Local Functions #609

Closed phtj closed 5 years ago

phtj commented 5 years ago

Add the ability to define local functions inside nodes.

This will result in a number of changes

1) In start node, make two sections, Test Model and Parameters, both collapsible, text left-aligned, with an arrow on the right

2) In normal node, make two sections, Local Funcs and Main Code, both collapsible, text left-aligned, with an arrow on the right

For the left menu

3) Rename Functions to Main Funcs

4) Rename Inline to Inline Funcs

5) Move User to its own section, below Inline Funcs, and call it User Funcs

6) Inside User Funcs make three sections:

7) In Create Local, add the following

8) If the section Local Funcs is collapsed, then Create Local should be disabled.

9) When you click a Def Func ..., it inserts the function into the Local Funcs section. If one of the lines if selected, then it inserts under that line. If not, it inserts at the bottom of that section.

10) When inserted, the Def Func should look like this Def [funcname] Func [arg0] [arg1] # code # code

11) Once a function has been inserted into the Local Funcs section, its name will appear in User Funcs > Local. The order of the names should match the order of the Local Funcs.

12) When you click one of the names in User Funcs > Local, it will insert the function into the code.

13) If the function contains a Return, then it will add: [var] = userlocal.name [arg0] [arg1] [arg2]

14) If the function contains no Return, then it will add: userlocal.name [arg0] [arg1] [arg2]

15) The parser should check the function body and should check if the functions that are called actually exist

15) Global functions work as before but should now look like this [var] = userglobal.name [arg0] [arg1] [arg2] userglobal.name [arg0] [arg1] [arg2]

phtj commented 5 years ago

done