Murga-Projects Forums
Callback typecast removal - Printable Version

+- Murga-Projects Forums (http://www.murga-projects.com/forum)
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: Callback typecast removal (/showthread.php?tid=16)


Callback typecast removal - Tobi - 05-06-2007 07:35 PM

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


RE: Callback typecast removal - Tobi - 05-08-2007 03:37 AM

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*%*%)", "")




RE: Callback typecast removal - JohnMurga - 05-08-2007 03:43 AM

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