flconvert for lua-fltk, v0.1

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

flconvert for lua-fltk, v0.1

Jay Carlson
I've made a slightly modified version of "flconvert" from the pyfltk
package.

flconvert reads the UI specification files generated with fltk's graphical
UI builder, fluid.  Normally it generates Python code; this version spits
out lua code suitable for use with my fltk binding from yesterday.

http://www.place.org/~nop/lua-flconvert-0.1.tar.gz

Figured somebody might be interested...

Jay


Reply | Threaded
Open this post in threaded view
|

Re: flconvert for lua-fltk, v0.1

Kenneth Rochel de Camargo Jr.
On 9 Jul 2001, at 23:50, Jay Carlson wrote:
> I've made a slightly modified version of "flconvert" from the pyfltk
> package.
> (...)
> Figured somebody might be interested...
> 
I certainly am. Where's the fltk binding?

Ken
Kenneth Rochel de Camargo, Jr. MD PhD
Associate Professor - Social Medicine Institute
Rio de Janeiro State U. - Brazil
e-mail: [hidden email]
http://members.xoom.com/kencamargo/
PGP Public key available in the homepage

Reply | Threaded
Open this post in threaded view
|

Re: flconvert for lua-fltk, v0.1

Jay Carlson-2
"Kenneth Rochel de Camargo Jr." <[hidden email]> writes:

> On 9 Jul 2001, at 23:50, Jay Carlson wrote:
> > I've made a slightly modified version of "flconvert" from the pyfltk
> > package.
> > (...)
> > Figured somebody might be interested...
> >
> I certainly am. Where's the fltk binding?

http://www.place.org/~nop/lua-fltk-0.1.tar.gz ; read the README for
disclaimers.

w = Fl_Window:new(300,180,"Hi there!")
box = Fl_Button:new(20,40,260,100, "hello, world!")
box:labelfont(FL_BOLD + FL_ITALIC)
box:labelsize(36)
box:labeltype(FL_SHADOW_LABEL)
w:end_layout()
w:show()
function fltk_dispatch(n) if n.callback then n:callback() end end
function box:callback() fl_alert("hello, world") end
fl_cb(box) -- register box for callbacks

The two errors I've found so far are:

1) widget:label(s) doesn't stash a copy of s anywhere, so if s ever gets
garbage collected, the label will break.  I believe constant strings in
functions won't be collected, so this is hidden in common use.

2) Fl_Box:new(boxtype, x,y,w,h, [label]) was the wrong constructor to pick;
it was ambiguous with Fl_Box:new(x,y,w,h, label) as far as toLua was
concerned.  flconvert prefers the second.

I've been working on a more Lua-flavored API on top of the toLua fltk API;
I'll post when I get it functional.

Jay


Reply | Threaded
Open this post in threaded view
|

Re: flconvert for lua-fltk, v0.1

Kenneth Rochel de Camargo Jr.
On 10 Jul 2001, at 16:52, Jay Carlson wrote:
> http://www.place.org/~nop/lua-fltk-0.1.tar.gz ; read the README for
> disclaimers.
> 
Thanx a lot.

> I've been working on a more Lua-flavored API on top of the toLua fltk
> API; I'll post when I get it functional.
> 
That sounds great too.

Ken
Kenneth Rochel de Camargo, Jr. MD PhD
Associate Professor - Social Medicine Institute
Rio de Janeiro State U. - Brazil
e-mail: [hidden email]
http://members.xoom.com/kencamargo/
PGP Public key available in the homepage

Reply | Threaded
Open this post in threaded view
|

Re: flconvert for lua-fltk, v0.1

Luiz Henrique de Figueiredo
In reply to this post by Jay Carlson
>I believe constant strings in functions won't be collected

When a function is collected, everything in it is collected as well,
including string literals.
--lhf

Reply | Threaded
Open this post in threaded view
|

RE: flconvert for lua-fltk, v0.1

Jay Carlson
Luiz Henrique de Figueiredo writes:

> >I believe constant strings in functions won't be collected
>
> When a function is collected, everything in it is collected as well,
> including string literals.

Yeah.  I figured that out on the drive home.  Apparently I've been spending
too much time away from languages with closures.  So I'll restate:

Constant strings in functions stored in the global environment, like those
created by flconvert, won't be collected.

It's still a correctness problem.  I'm probably going to solve it for now by
way of a layer of Lua code, since there doesn't appear to be any good way to
insert code into toLua-generated constructors.  (By the way, code insertion
into constructors would let me stuff the widget class tag into the
Fl_Widget->user_data() and let me reconstitute arbitrary Fl_Widget * into
the appropriately tagged toLua subclasses.)

Jay