problem binding a simple function

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

problem binding a simple function

Charles Darwin
Hello,
 
I'm having trouble binding this simple function does uppercase conversion.
 
 
void STools::UCase(char *txt)
{
for (;;)
{
u_int32 t = *reinterpret_cast(txt);
...
txt++;
}
}
 
 
Here's the luabind code
 
luabind::module(myLuaState) [
    luabind::def("convert_upper", STools::UCase)
  ]; 
 
  
Here's the compiler error:
  
error C2664: 'void (char *)' : cannot convert parameter 1 from 'const char *' to 'char *'
 
 
I've tried adding "out_value(_1)" but got nowhere
 
error C2352: 'luabind::native_converter_base<T>::match' : illegal call of non-static member function
 
 
 
Any help is appreciated.
 
Best regards
 
Charles

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: problem binding a simple function

Tony Kostanjsek
You are trying to modify a string in place. That won't work since Lua strings are immutable. Make txt a const char* and return a new string.

On 06.05.2013, at 02:24, "Charles Darwin" <[hidden email]> wrote:

Hello,
 
I'm having trouble binding this simple function does uppercase conversion.
 
 
void STools::UCase(char *txt)
{
for (;;)
{
u_int32 t = *reinterpret_cast(txt);
...
txt++;
}
}
 
 
Here's the luabind code
 
luabind::module(myLuaState) [
    luabind::def("convert_upper", STools::UCase)
  ]; 
 
  
Here's the compiler error:
  
error C2664: 'void (char *)' : cannot convert parameter 1 from 'const char *' to 'char *'
 
 
I've tried adding "out_value(_1)" but got nowhere
 
error C2352: 'luabind::native_converter_base<T>::match' : illegal call of non-static member function
 
 
 
Any help is appreciated.
 
Best regards
 
Charles
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: problem binding a simple function

Charles Darwin
In reply to this post by Charles Darwin
Thanks a lot Tony. That fixed the problem.

 

----- Original Message -----

From: Tony Kostanjsek

Sent: 05/06/13 11:03 AM

To: [hidden email]

Subject: Re: [luabind] problem binding a simple function

 
You are trying to modify a string in place. That won't work since Lua strings are immutable. Make txt a const char* and return a new string.

On 06.05.2013, at 02:24, "Charles Darwin" <[hidden email]> wrote:
 
Hello,
 
I'm having trouble binding this simple function does uppercase conversion.
 
 
void STools::UCase(char *txt)
{
for (;;)
{
u_int32 t = *reinterpret_cast(txt);
...
txt++;
}
}
 
 
Here's the luabind code
 
luabind::module(myLuaState) [
    luabind::def("convert_upper", STools::UCase)
  ]; 
 
  
Here's the compiler error:
  
error C2664: 'void (char *)' : cannot convert parameter 1 from 'const char *' to 'char *'
 
 
I've tried adding "out_value(_1)" but got nowhere
 
error C2352: 'luabind::native_converter_base<T>::match' : illegal call of non-static member function
 
 
 
Any help is appreciated.
 
Best regards
 
Charles
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user

 


------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user