lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi again.

> I don't think it would be so useful. There is no way to implement a general 
> constructor.
If by definition the constructor should set values to a valid default,
then you are right.

> It would be possible to export a kind of "malloc" function, returning the 
> appropriate pointer to Lua.
That was what I initially thought of.

> I think it would be too low level...
It's better than nothing :-) And one could wrap it in lua, adding some
code to munch a table and calling appropriate setter methods, like:
--given obj = the newly created object, attr = obj's attributes
	for k, v in table.pairs(attr) do
		obj[k] = v
	end

to set the attributes (Or maybe even do that in C?). I would probably
not use it in production code, but for prototyping, I'd really
appreciate it.

> tolua 5.0 should handle union just fine.
In normal circumstances, yes. But if I have a C function, called
with a union pointer, and the C function changes its argument (see
below), the type of the argument may change, which causes me trouble.

> is it buggy or are you using a older version?
I use tolua 5.0 alpha (fresh from the tolua page). The problem I have is
that a C function (SDL_Poll_event(event), fed with a new SDL_Event,
makes a SDL_Keyboard_Event of event, but only for the second event (e.g.
on second key press). 

I first had this problem when I ported Thatcher Ullrich's sample game to 
vanilla lua 5 (with loadlib support). The problem leads to much
debugging, ugly workarounds, and migraine :-)

By the way, I don't mean to badmouth tolua. It's a great piece of
software.

> -- waldemar
Yours,
Andre 
-- 
Tolerance rulez, everything else sux! -- Andre Kloss