Murga-Projects Forums

Full Version: Callback typecast removal
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

It's possible to set the callbacks of the GUI elements already in fluid, however when the resulting .cxx file is converted to .lua, the C++ typecast (Fl_Callback*) is also copied to the lua file. See this:

Code:
Fl_Button* o = new Fl_Button(145, 5, 70, 25, "Quit");
o->callback((Fl_Callback*)quitter);


becomes

Code:
do local object = fltk:Fl_Button(145, 5, 70, 25, "Quit");
object:callback((Fl_Callback*)quitter);


I've looked at the converter script and it claims to remove the typecasts, for some reason it doesn't work though. Line 100 in convertFluidToMurgaLua.lua:

Code:
-- Remove casts as they are not required in LUA
currentLine = string.gsub(currentLine, "%(Fl_%w*%)", "")


Keep up the good work! Smile

Tobi

OK, this is the solution:

In the convertFluidToMurgaLua.lua file in line 101 the pattern in the gsub method has an error.
Here's the corrected version:

Code:
currentLine = string.gsub(currentLine, "%(Fl_%w*%*%)", "")

Tobi Wrote:
OK, this is the solution:

In the convertFluidToMurgaLua.lua file in line 101 the pattern in the gsub method has an error.
Here's the corrected version:

Code:
currentLine = string.gsub(currentLine, "%(Fl_%w*%*%)", "")


Thanks, I'll test it and put it in the next build ...

I have been traveling for a few days, so I have to catch up on a few things.

Cheers
JohnM

Reference URL's