lua-users home
lua-l archive

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/11/2010 2:42 PM, Anders Backman wrote:

> I would have to say, no. Not without some additional work.
> I have a modified tolua++ which supports our reference counting.
> I had to add a few macros:
> 
> template <typename T>
> void Mtolua_reference( T *p )
> {
>   x::Referenced *r = dynamic_cast<x::Referenced *>(p);
>   r->reference();
> }
> 
> template <typename T>
> void Mtolua_unreference( T *p )
> {
>   x::Referenced *r = dynamic_cast<x::Referenced *>(p);
>   if (r && r->getReferenceCount())
>     r->unreference();
> }







Not sure if you're familiar with boost::shared_ptr<>, but explicit
reference counting never happens; it's implicit in the construction and
destruction of the boost::shared_ptr<> containers. Once you're using a
shared_ptr<>, you would NEVER pass the object around outside of the
shared_ptr<>; then it will simply always work correctly.

And as far as that goes, it DOES look to me that toLua++ would support
at least the reference counted part, since it supports returning objects
by value, and you could tell it (as I said in my example) that the
shared_ptr<> "derived" from the class itself. It holds an object as a
pointer, but if it's a pointer to an allocated shared_ptr<>, then that
should work correctly, yes? Though maybe not; object.foo() in Lua might
try to dispatch to (*object).foo() instead of object->foo()
(operator->()).

So unless anyone has any direct experience using boost smart pointers
with toLua++, I may have to do the experiment myself.

> Still to this day, I'm waiting for something that has the generality of
> tolua++, the scalability of tolua++, but the languesupport of luabind.
> Exporting a large C++ API with Luabind...that would be an enormous
> effort, same as for SWIG.






Sigh. LuaBind seems nice, but it's SO heavy that it almost negates the
reason one would use Lua. I hear MLuaBind might be a good alternative,
though the project seems rather...dormant.

> With tolua++, just copy the headers, clean them (semiautomatic) and run
> tolua on them.






OK, I'll check it out.


> I was working with LQT for a while. But it was hard to get all the way.
> As it was using a C++toXML parser, something that is close to impossible
> to get through all our code. It chokes on quite a few things.






I've considered using SWIG; I understand it does a good job of parsing,
at least. Not sure how well the Lua/SWIG wrappers map to what I want to
do, though. And if something doesn't work the way you want, well, SWIG
is a monster to try to fix.

Tim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNBn/iAAoJENSbqLBCyKKsuCUIAJekwUuWwUKfLYlb6pARk9hk
nEcOhdqdCEBXHhYaCtwn1CERjJZ/ADe8GXOs/gbZ+VuRFUZWYg7sKzDhJN7mr35/
/LCpuESSc8Curz29IirdVGh745aH7EjXGjHRablY4roM3xJjxED9rs1V9OtL4R3X
I9t5xryyzsDFS0zrZOZbTxZs1Tqkf5gqAWnOinInK9CSFFFMyLWJH8jhlrDFsfUH
RKArzRnhUaRxLlhksTmKHKZZQqyUDQm0kErvUzMT7oE4NruVgazi4zZGxia6v7Fg
Oudx+64hsijYHr8fZwUjsMk2919R5kVZnibRC272IhHxO2znnPEf8+8B/OGxtkc=
=hW2p
-----END PGP SIGNATURE-----