Re: problem binding a simple function

Tony Kostanjsek <[email protected]> Mon, 6 May 2013 10:03:23 +0200
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
--===============4690792967740691872==
Content-Type: multipart/alternative;
	boundary=Apple-Mail-851EABE8-3B1D-4882-9E51-E8FED3647E24
Content-Transfer-Encoding: 7bit


--Apple-Mail-851EABE8-3B1D-4882-9E51-E8FED3647E24
Content-Type: text/plain;
	charset=us-ascii
Content-Transfer-Encoding: quoted-printable

You are trying to modify a string in place. That won't work since Lua string=
s 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,
> =20
> I'm having trouble binding this simple function does uppercase conversion.=

> =20
> =20
> void STools::UCase(char *txt)
> {
> for (;;)
> {
> u_int32 t =3D *reinterpret_cast(txt);
> ...
> txt++;
> }
> }
> =20
> =20
> Here's the luabind code
> =20
> luabind::module(myLuaState) [
>     luabind::def("convert_upper", STools::UCase)
>   ];=20
> =20
>  =20
> Here's the compiler error:
>  =20
> error C2664: 'void (char *)' : cannot convert parameter 1 from 'const char=
 *' to 'char *'
> =20
> =20
> I've tried adding "out_value(_1)" but got nowhere
> =20
> error C2352: 'luabind::native_converter_base<T>::match' : illegal call of n=
on-static member function
> =20
> =20
> =20
> Any help is appreciated.
> =20
> Best regards
> =20
> 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

--Apple-Mail-851EABE8-3B1D-4882-9E51-E8FED3647E24
Content-Type: text/html;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D=
utf-8"></head><body dir=3D"auto"><div>You are trying to modify a string in p=
lace. That won't work since Lua strings are immutable. Make txt a const char=
* and return a new string.</div><div><br>On 06.05.2013, at 02:24, "Charles D=
arwin" &lt;<a href=3D"mailto:[email protected]">[email protected]</a>&gt; wr=
ote:<br><br></div><blockquote type=3D"cite"><div><span style=3D"font-family:=
Verdana"><span style=3D"font-size:12px"><div>Hello,</div><div>&nbsp;</div><d=
iv>I'm having trouble binding this simple function does uppercase conversion=
.</div><div>&nbsp;</div><div>&nbsp;</div><div>void STools::UCase(char *txt)<=
/div><div>{</div><div>for (;;)</div><div>{</div><div>u_int32 t =3D *reinterp=
ret_cast(txt);</div><div>...</div><div>txt++;</div><div>}</div><div>}</div><=
div>&nbsp;</div><div>&nbsp;</div><div>Here's the luabind code</div><div>&nbs=
p;</div><div>luabind::module(myLuaState) [</div><div>&nbsp; &nbsp; luabind::=
def("convert_upper", STools::UCase)</div><div>&nbsp; ];&nbsp;</div><div>&nbs=
p;</div><div>&nbsp;&nbsp;</div><div>Here's the compiler error:</div><div>&nb=
sp;&nbsp;</div><div>error C2664: 'void (char *)' : cannot convert parameter 1=
 from 'const char *' to 'char *'</div><div>&nbsp;</div><div>&nbsp;</div><div=
>I've tried adding "out_value(_1)" but got nowhere</div><div>&nbsp;</div><di=
v>error C2352: 'luabind::native_converter_base&lt;T&gt;::match' : illegal ca=
ll of non-static member function</div><div>&nbsp;</div><div>&nbsp;</div><div=
>&nbsp;</div><div>Any help is appreciated.</div><div>&nbsp;</div><div>Best r=
egards</div><div>&nbsp;</div><div>Charles</div></span></span>
</div></blockquote><blockquote type=3D"cite"><div><span>--------------------=
----------------------------------------------------------</span><br><span>I=
ntroducing AppDynamics Lite, a free troubleshooting tool for Java/.NET</span=
><br><span>Get 100% visibility into your production application - at no cost=
.</span><br><span>Code-level diagnostics for performance bottlenecks with &l=
t;2% overhead</span><br><span>Download for free and get started troubleshoot=
ing in minutes.</span><br><span><a href=3D"http://p.sf.net/sfu/appdyn_d2d_ap=
1">http://p.sf.net/sfu/appdyn_d2d_ap1</a></span></div></blockquote><blockquo=
te type=3D"cite"><div><span>_______________________________________________<=
/span><br><span>luabind-user mailing list</span><br><span><a href=3D"mailto:=
[email protected]">[email protected]</a></=
span><br><span><a href=3D"https://lists.sourceforge.net/lists/listinfo/luabi=
nd-user">https://lists.sourceforge.net/lists/listinfo/luabind-user</a></span=
><br></div></blockquote></body></html>=

--Apple-Mail-851EABE8-3B1D-4882-9E51-E8FED3647E24--


--===============4690792967740691872==
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
--===============4690792967740691872==
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

--===============4690792967740691872==--