Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Clean way to call out to external methods?
Clean way to call out to external methods? [message #1387092] Tue, 24 June 2014 05:58 Go to next message
Gary Worsham is currently offline Gary WorshamFriend
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

Re: Clean way to call out to external methods? [message #1387094 is a reply to message #1387092] Tue, 24 June 2014 06:13 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 248
Registered: June 2013
Senior Member
Hi Gary, you can customise the ProposalProvider to list the available options and the Validator (plus a quickfix) to check that only available options are entered.

See Lorenzos Book for some nice commented examples how to do this.
Re: Clean way to call out to external methods? [message #1387150 is a reply to message #1387094] Tue, 24 June 2014 13:00 Go to previous message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
Thanks for the info Uli! Guess I better buy the book. Very Happy
Previous Topic:How to start
Next Topic:Xtext reference does work when importing a file
Goto Forum:
  


Current Time: Sun Jan 26 07:54:57 GMT 2020

Powered by FUDForum. Page generated in 0.01559 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top