Clean way to call out to external methods? [message #1387092] |
Tue, 24 June 2014 05:58 |
Gary Worsham Messages: 176 Registered: September 2013 |
Senior Member |
|
|
I've developed my DSL to create little blocks that represent DSP (digital signal processing) functions that you link together on screen to create a larger algorithm. I just added features to my language that create Swing control panels (slider, checkboxes, etc.) that allow the adjustment of certain variables within my blocks. These ultimately become constants in the DSP code (e.g. filter coefficients).
In the simplest cases, the Slider value and the internal variable value scale to each other by a multiplier. For example, the internal variable goes from 0.0 to 1.0 linearly as the Slider (more accurately the label over the slider telling us its value) goes linearly from 0 to 25.
In other cases, the internal variables are more complicated, and may actually be the result of combining the values of several Swing controls in polynomial functions using sin(), cos(), square root, etc.
I don't want to write support for math functions in my DSL. I'd rather create a group of Java functions that I could reference somehow from my generated Java code per functional block. One way I can think of to do this is have a value scanned in from my DSL file which references a List of functions or perhaps forms part of a method name that then gets called. I implemented a few simple ones by having DSL elements which spit out specific chunks of template code. But this approach seems inflexible.
It seems possible but somehow unsatisfying as the relationship between the different parts is tenuous. It would be cooler if, for example, the system knew what the possible methods WERE and then when you were at that point in editing your DSL file, you could just pick one from the list.
Does this make sense and is there a good solution for it in Xtend?
[Updated on: Tue, 24 June 2014 13:01] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02199 seconds