Re: problem binding a simple function
"Charles Darwin" <[email protected]> Mon, 06 May 2013 07:44:18 -0400
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
--===============8445806918267736652== Content-Type: multipart/alternative; boundary="========GMXBoundary212051367840658634435" --========GMXBoundary212051367840658634435 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Thanks a lot Tony. That fixed the problem. ----- Original Message ----- From: Tony Kostanjsek Sent: 05/06/13 11:03 AM To: [email protected] 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" < [email protected] > 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 [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user --========GMXBoundary212051367840658634435 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable <span style=3D'font-family:Verdana'><span style=3D'font-size:12px'>Thanks a= lot Tony. That fixed the problem.<p style=3D"margin:0px; padding:0px;" >= =C2=A0</p><blockquote style=3D"border-left: 1px solid #CCC; padding-left: 5= px; margin-left: 5px; margin-bottom: 0px; margin-top: 0px; margin-right: 0p= x;" type=3D"cite"><p style=3D"margin:0px; padding:0px;" ><span style=3D"fon= t-family:Verdana"><span style=3D"font-size:12px">----- Original Message ---= --</span></span></p><p style=3D"margin:0px; padding:0px;" ><span style=3D"f= ont-family:Verdana"><span style=3D"font-size:12px">From: Tony Kostanjsek</s= pan></span></p><p style=3D"margin:0px; padding:0px;" ><span style=3D"font-f= amily:Verdana"><span style=3D"font-size:12px">Sent: 05/06/13 11:03 AM</span= ></span></p><p style=3D"margin:0px; padding:0px;" ><span style=3D"font-fami= ly:Verdana"><span style=3D"font-size:12px">To: [email protected]= ge.net</span></span></p><p style=3D"margin:0px; padding:0px;" ><span style= =3D"font-family:Verdana"><span style=3D"font-size:12px">Subject: Re: [luabi= nd] problem binding a simple function</span></span></p>=C2=A0<div><div>You = are trying to modify a string in place. That won't work since Lua strings a= re immutable. Make txt a const char* and return a new string.</div><div><br= />On 06.05.2013, at 02:24, "Charles Darwin" <<a href=3D"mailto:c.darwin= @mail.com">[email protected]</a>> wrote:<br />=C2=A0</div><blockquote ty= pe=3D"cite"><div><div><span style=3D"font-family:Verdana"><span style=3D"fo= nt-size:12px">Hello,</span></span></div><div><span style=3D"font-family:Ver= dana"><span style=3D"font-size:12px"> </span></span></div><div><span s= tyle=3D"font-family:Verdana"><span style=3D"font-size:12px">I'm having trou= ble binding this simple function does uppercase conversion.</span></span></= div><div><span style=3D"font-family:Verdana"><span style=3D"font-size:12px"= > </span></span></div><div><span style=3D"font-family:Verdana"><span s= tyle=3D"font-size:12px"> </span></span></div><div><span style=3D"font-= family:Verdana"><span style=3D"font-size:12px">void STools::UCase(char *txt= )</span></span></div><div><span style=3D"font-family:Verdana"><span style= =3D"font-size:12px">{</span></span></div><div><span style=3D"font-family:Ve= rdana"><span style=3D"font-size:12px">for (;;)</span></span></div><div><spa= n style=3D"font-family:Verdana"><span style=3D"font-size:12px">{</span></sp= an></div><div><span style=3D"font-family:Verdana"><span style=3D"font-size:= 12px">u_int32 t =3D *reinterpret_cast(txt);</span></span></div><div><span s= tyle=3D"font-family:Verdana"><span style=3D"font-size:12px">...</span></spa= n></div><div><span style=3D"font-family:Verdana"><span style=3D"font-size:1= 2px">txt++;</span></span></div><div><span style=3D"font-family:Verdana"><sp= an style=3D"font-size:12px">}</span></span></div><div><span style=3D"font-f= amily:Verdana"><span style=3D"font-size:12px">}</span></span></div><div><sp= an style=3D"font-family:Verdana"><span style=3D"font-size:12px"> </spa= n></span></div><div><span style=3D"font-family:Verdana"><span style=3D"font= -size:12px"> </span></span></div><div><span style=3D"font-family:Verda= na"><span style=3D"font-size:12px">Here's the luabind code</span></span></d= iv><div><span style=3D"font-family:Verdana"><span style=3D"font-size:12px">= </span></span></div><div><span style=3D"font-family:Verdana"><span st= yle=3D"font-size:12px">luabind::module(myLuaState) [</span></span></div><di= v><span style=3D"font-family:Verdana"><span style=3D"font-size:12px"> = luabind::def("convert_upper", STools::UCase)</span></span></div><di= v><span style=3D"font-family:Verdana"><span style=3D"font-size:12px"> = ]; </span></span></div><div><span style=3D"font-family:Verdana"><span= style=3D"font-size:12px"> </span></span></div><div><span style=3D"fon= t-family:Verdana"><span style=3D"font-size:12px"> </span></span>= </div><div><span style=3D"font-family:Verdana"><span style=3D"font-size:12p= x">Here's the compiler error:</span></span></div><div><span style=3D"font-f= amily:Verdana"><span style=3D"font-size:12px"> </span></span></d= iv><div><span style=3D"font-family:Verdana"><span style=3D"font-size:12px">= error C2664: 'void (char *)' : cannot convert parameter 1 from 'const char = *' to 'char *'</span></span></div><div><span style=3D"font-family:Verdana">= <span style=3D"font-size:12px"> </span></span></div><div><span style= =3D"font-family:Verdana"><span style=3D"font-size:12px"> </span></span= ></div><div><span style=3D"font-family:Verdana"><span style=3D"font-size:12= px">I've tried adding "out_value(_1)" but got nowhere</span></span></div><d= iv><span style=3D"font-family:Verdana"><span style=3D"font-size:12px"> = ;</span></span></div><div><span style=3D"font-family:Verdana"><span style= =3D"font-size:12px">error C2352: 'luabind::native_converter_base<T>::= match' : illegal call of non-static member function</span></span></div><div= ><span style=3D"font-family:Verdana"><span style=3D"font-size:12px"> <= /span></span></div><div><span style=3D"font-family:Verdana"><span style=3D"= font-size:12px"> </span></span></div><div><span style=3D"font-family:V= erdana"><span style=3D"font-size:12px"> </span></span></div><div><span= style=3D"font-family:Verdana"><span style=3D"font-size:12px">Any help is a= ppreciated.</span></span></div><div><span style=3D"font-family:Verdana"><sp= an style=3D"font-size:12px"> </span></span></div><div><span style=3D"f= ont-family:Verdana"><span style=3D"font-size:12px">Best regards</span></spa= n></div><div><span style=3D"font-family:Verdana"><span style=3D"font-size:1= 2px"> </span></span></div><div><span style=3D"font-family:Verdana"><sp= an style=3D"font-size:12px">Charles</span></span></div></div></blockquote><= blockquote type=3D"cite"><div><span>---------------------------------------= ---------------------------------------</span><br /><span>Introducing AppDy= namics Lite, a free troubleshooting tool for Java/.NET</span><br /><span>Ge= t 100% visibility into your production application - at no cost.</span><br = /><span>Code-level diagnostics for performance bottlenecks with <2% over= head</span><br /><span>Download for free and get started troubleshooting in= minutes.</span><br /><span><a href=3D"http://p.sf.net/sfu/appdyn_d2d_ap1">= http://p.sf.net/sfu/appdyn_d2d_ap1</a></span></div></blockquote><blockquote= type=3D"cite"><div><span>_______________________________________________</= span><br /><span>luabind-user mailing list</span><br /><span><a href=3D"mai= lto:[email protected]">[email protected]<= /a></span><br /><span><a href=3D"https://lists.sourceforge.net/lists/listin= fo/luabind-user">https://lists.sourceforge.net/lists/listinfo/luabind-user<= /a></span></div></blockquote></div></blockquote><p style=3D"margin:0px; pad= ding:0px;" >=C2=A0</p></span></span> --========GMXBoundary212051367840658634435-- --===============8445806918267736652== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ 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 --===============8445806918267736652== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user --===============8445806918267736652==--