tostring issues

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

tostring issues

Alexander Gladysh
Hi, all!

As far as I understand, to be able to do tostring() operation in Lua
on Luabind user-type, one have to write std::ostream&
operator<<(std::ostream&, type&);
 for that type in C++. But what if I already have that operator (as
legacy and unchangeable code), and want to get completely different
text representation for Lua (say, to convert to Lua code on tostring()
to allow deserialization)? I'd like to be able to specify custom
function to .tostring() binding function. Is it possible?

There is one more issue. If I call tostring() in Lua on any of Luabind
objects, which do not have bound tostring operator in C++, I get a
crash like "no such operator defined". This is inconsistent with
behaviour of tostring() for other types and leads to writing extra
type checks. It would be *MUCH* more convenient to have something like
"luabind: HEXADRESS" as a result, like for tables and functions.

Thanks in advance,
Alexander.

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: tostring issues

Alexander Gladysh
> I'd like to be able to specify custom function to .tostring() binding function. Is it possible?

Sorry, I meant "to .def(luabind::tostring(luabind::self))".

Alexander.

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: tostring issues

Korval
In reply to this post by Alexander Gladysh
I have to wonder why you're trying to bind legacy objects directly to Lua
without some kind of wrapper class. If you don't have direct control over a
piece of code, it's better to operate through a layer than to talk directly
to something you may need to mutate.

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]]On Behalf Of
Alexander Gladysh
Sent: Monday, June 26, 2006 8:52 AM
To: [hidden email]
Subject: [luabind] tostring issues


Hi, all!

As far as I understand, to be able to do tostring() operation in Lua
on Luabind user-type, one have to write std::ostream&
operator<<(std::ostream&, type&);
 for that type in C++. But what if I already have that operator (as
legacy and unchangeable code), and want to get completely different
text representation for Lua (say, to convert to Lua code on tostring()
to allow deserialization)? I'd like to be able to specify custom
function to .tostring() binding function. Is it possible?

There is one more issue. If I call tostring() in Lua on any of Luabind
objects, which do not have bound tostring operator in C++, I get a
crash like "no such operator defined". This is inconsistent with
behaviour of tostring() for other types and leads to writing extra
type checks. It would be *MUCH* more convenient to have something like
"luabind: HEXADRESS" as a result, like for tables and functions.

Thanks in advance,
Alexander.

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user