[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Alternative C++ binding
- From: virgil@... (Virgil Smith)
- Date: Fri, 15 Aug 2003 14:27:47 -0500
Looks like a great small start for a binding system.
I have to admit that I'm just now taking some time to look into Lua5 and
convert some personal tools from Lua4 to Lua5, and your "new" trick occurred
to me yesterday.
As for the GC template I have an answer to your problem.
The problem is that it is illegal to directly call destructors.
You have to go through delete.
So, how do you keep delete from deallocating any memory, simple, you just
write a new delete the same way that you wrote a new new.
The trick is that your delete operator will have to take some arguments
(just like your new operator did). In fact it is at least good form (if not
required by the language, I'm not sure) that your delete operator accepts
the same argument list as your new operator. This "balances" them, which in
general is a good idea since whatever your "new" new operator did will have
to be undone by your "new" delete operator. In this case there is nothing
to do.
This may seem weird (as your delete operator will do absolutely nothing in
this case), but it means that you can put...
delete(L, "") Instance; //OK, I'm not sure if the "size"
return 0; // argument should be repeated
in your GC method.
----
One last thing!
You have to get the value of Instance so that you can delete it!
This just means that you have to retrieve the userdata and it cast to T*.
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of benjamin
sunshine-hill
Sent: Friday, August 15, 2003 1:48 PM
To: lua@bazar2.conectiva.com.br
Subject: Alternative C++ binding
I've posted a page on the Wiki with code snippets describing a method of
easily and flexibly gluing Lua and C++ together without a binding generator,
that is conducive to space and execution efficiency. Comments, criticisms,
and additions are requested.
http://lua-users.org/wiki/DoItYourselfCppBinding
Ben
P.S. there's a bug in the templated gc, which I wasn't able to edit out;
some error when I tried to save the changes.