Overriding __concat behavior

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

Overriding __concat behavior

Teto
Hi there,

I'm doing everything I can to ease lua side debugging and for this purpose, I need to override __tostring and __concat from C++.

I've succeeded in overriding tostring (followed the manual + looked on the ml to see that if it didn't work with luabind::self, I could use const_self, maybe that tip could go to the online tutorial)
.def( luabind::tostring(luabind::const_self) )

For __concat, I do that with a wrong prototype I guess ( std::string CStaticBattery::concat() ):
        .def( "__concat",&CStaticBattery::concat )

Would the prototype : std::string CStaticBattery::concat(const std::string & str1,const std::string& str2 ) work ?
What would be str1 and str2 ? Left and right ? like in print( str1..myBatteryConcat..str2) ?

I will appreciate any example.


Thx

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Overriding __concat behavior

Ryan Pavlik-4
__concat would be a method in the metatable, not in the table itself, so I think that would keep your current approach from working.  My hunch is that you'd need to look at the header for luabind::tostring and do something similar for concat.  If you do, fork Luabind on GitHub so that the improvement can be re-integrated.

On Tue, Mar 22, 2011 at 11:20 PM, Teto <[hidden email]> wrote:
Hi there,

I'm doing everything I can to ease lua side debugging and for this purpose, I need to override __tostring and __concat from C++.

I've succeeded in overriding tostring (followed the manual + looked on the ml to see that if it didn't work with luabind::self, I could use const_self, maybe that tip could go to the online tutorial)
.def( luabind::tostring(luabind::const_self) )

For __concat, I do that with a wrong prototype I guess ( std::string CStaticBattery::concat() ):
        .def( "__concat",&CStaticBattery::concat )

Would the prototype : std::string CStaticBattery::concat(const std::string & str1,const std::string& str2 ) work ?
What would be str1 and str2 ? Left and right ? like in print( str1..myBatteryConcat..str2) ?

I will appreciate any example.


Thx

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user




--
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

[hidden email]
http://academic.cleardefinition.com
Internal VRAC/HCI Site: http://tinyurl.com/rpavlik

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Overriding __concat behavior

Teto
I don't know if it's relevant but the member function "__concat" I
bind is called, luabind just tells me that it has the wrong prototype:
"No matching overload found, candidates:
std::string __concat(CBattery&,std::string,std::string);"

Is there any way to have an acceptable prototype (like void*,void*). I
will have a look on luabind::tostring implementation but I'm not very
confident about my abilities to do concat equivalent sadly :(

Thx for your answer

On Wed, Mar 23, 2011 at 2:30 AM, Ryan Pavlik <[hidden email]> wrote:

>
> __concat would be a method in the metatable, not in the table itself, so I think that would keep your current approach from working.  My hunch is that you'd need to look at the header for luabind::tostring and do something similar for concat.  If you do, fork Luabind on GitHub so that the improvement can be re-integrated.
>
> On Tue, Mar 22, 2011 at 11:20 PM, Teto <[hidden email]> wrote:
>>
>> Hi there,
>>
>> I'm doing everything I can to ease lua side debugging and for this purpose, I need to override __tostring and __concat from C++.
>>
>> I've succeeded in overriding tostring (followed the manual + looked on the ml to see that if it didn't work with luabind::self, I could use const_self, maybe that tip could go to the online tutorial)
>> .def( luabind::tostring(luabind::const_self) )
>>
>> For __concat, I do that with a wrong prototype I guess ( std::string CStaticBattery::concat() ):
>>         .def( "__concat",&CStaticBattery::concat )
>>
>> Would the prototype : std::string CStaticBattery::concat(const std::string & str1,const std::string& str2 ) work ?
>> What would be str1 and str2 ? Left and right ? like in print( str1..myBatteryConcat..str2) ?
>>
>> I will appreciate any example.
>>
>>
>> Thx
>>
>> ------------------------------------------------------------------------------
>> Enable your software for Intel(R) Active Management Technology to meet the
>> growing manageability and security demands of your customers. Businesses
>> are taking advantage of Intel(R) vPro (TM) technology - will your software
>> be a part of the solution? Download the Intel(R) Manageability Checker
>> today! http://p.sf.net/sfu/intel-dev2devmar
>> _______________________________________________
>> luabind-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>>
>
>
>
> --
> Ryan Pavlik
> HCI Graduate Student
> Virtual Reality Applications Center
> Iowa State University
>
> [hidden email]
> http://academic.cleardefinition.com
> Internal VRAC/HCI Site: http://tinyurl.com/rpavlik

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Overriding __concat behavior

Teto
I succeeded in implenting the behavior. See the enclosed file.
It basically works like tostring except there are 2 arguments:

I define them like this:
.def( luabind::concat_operator(luabind::const_self,luabind::other<std::string>() ) )
.def( luabind::concat_operator(luabind::const_self,int() ) )

What would be cool would be to register automatically the 2nd type so that we could write
.def( luabind::concat_operator(luabind::const_self)) only.

I hope concat operator will be added to next release even if it's not my code.

Matt

On Wed, Mar 23, 2011 at 7:48 PM, Teto <[hidden email]> wrote:
I don't know if it's relevant but the member function "__concat" I
bind is called, luabind just tells me that it has the wrong prototype:
"No matching overload found, candidates:
std::string __concat(CBattery&,std::string,std::string);"

Is there any way to have an acceptable prototype (like void*,void*). I
will have a look on luabind::tostring implementation but I'm not very
confident about my abilities to do concat equivalent sadly :(

Thx for your answer

On Wed, Mar 23, 2011 at 2:30 AM, Ryan Pavlik <[hidden email]> wrote:
>
> __concat would be a method in the metatable, not in the table itself, so I think that would keep your current approach from working.  My hunch is that you'd need to look at the header for luabind::tostring and do something similar for concat.  If you do, fork Luabind on GitHub so that the improvement can be re-integrated.
>
> On Tue, Mar 22, 2011 at 11:20 PM, Teto <[hidden email]> wrote:
>>
>> Hi there,
>>
>> I'm doing everything I can to ease lua side debugging and for this purpose, I need to override __tostring and __concat from C++.
>>
>> I've succeeded in overriding tostring (followed the manual + looked on the ml to see that if it didn't work with luabind::self, I could use const_self, maybe that tip could go to the online tutorial)
>> .def( luabind::tostring(luabind::const_self) )
>>
>> For __concat, I do that with a wrong prototype I guess ( std::string CStaticBattery::concat() ):
>>         .def( "__concat",&CStaticBattery::concat )
>>
>> Would the prototype : std::string CStaticBattery::concat(const std::string & str1,const std::string& str2 ) work ?
>> What would be str1 and str2 ? Left and right ? like in print( str1..myBatteryConcat..str2) ?
>>
>> I will appreciate any example.
>>
>>
>> Thx
>>
>> ------------------------------------------------------------------------------
>> Enable your software for Intel(R) Active Management Technology to meet the
>> growing manageability and security demands of your customers. Businesses
>> are taking advantage of Intel(R) vPro (TM) technology - will your software
>> be a part of the solution? Download the Intel(R) Manageability Checker
>> today! http://p.sf.net/sfu/intel-dev2devmar
>> _______________________________________________
>> luabind-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>>
>
>
>
> --
> Ryan Pavlik
> HCI Graduate Student
> Virtual Reality Applications Center
> Iowa State University
>
> [hidden email]
> http://academic.cleardefinition.com
> Internal VRAC/HCI Site: http://tinyurl.com/rpavlik


------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software
be a part of the solution? Download the Intel(R) Manageability Checker
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user

concat.hpp (3K) Download Attachment