default_converter and luabind assignment

<[email protected]> Wed, 8 Jan 2014 17:36:41 +0000
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
--===============0486970010114043489==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_968F113960C5EC44950119195F8CB50C207A32A4HIGH5EXCH1High5_"

--_000_968F113960C5EC44950119195F8CB50C207A32A4HIGH5EXCH1High5_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi,
I want to add support to a user type in luabind, so that I can assign c++ v=
ariables of the type to lua variables like so:

struct UserType{..};

//and then do

UserType u;
luabind::globals(L)["UserTypeList"]["a"] =3D u; //equivalent to saying User=
TypeList.a =3D u  in Lua.


I registered the class type via luabind::class_ and specialized the default=
_converter for the type :

module(L)[ class_< UserType>("_ UserType")];

namespace luabind{
     template<>
struct  default_converter< UserType> : native_converter_base< UserType> {
     //define compute_score, to and from functions.
};
}


But when I actually do the assignment, the converter code doesn't get calle=
d. I'm expecting the 'to' function in the converter to get called, since I'=
m assigning a custom  type to a lua object, which doesn't happen.
Is this the correct way to do this. Please let me know if you find any issu=
es with this setup.

Thanks arun.

--_000_968F113960C5EC44950119195F8CB50C207A32A4HIGH5EXCH1High5_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"blue" vlink=3D"purple">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Hi, <o:p></o:p></p>
<p class=3D"MsoNormal">I want to add support to a user type in luabind, so =
that I can assign c&#43;&#43; variables of the type to lua variables like s=
o:<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;">struct UserType{..};
<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;">//and then do
<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;">UserType u;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;">luabind::globals(L)[&#8220;UserTypeList&#8221;][=
&#8220;a&#8221;] =3D u; //equivalent to saying UserTypeList.a =3D u &nbsp;i=
n Lua.<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal">I registered the class type via luabind::class_ and =
specialized the default_converter for the type :<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;">module(L)[ class_&lt; UserType&gt;(&#8220;_ User=
Type&#8221;)];<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;">namespace luabind{<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; template&lt;&gt;<o:p></=
o:p></span></p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in"><span st=
yle=3D"font-family:&quot;Courier New&quot;">struct&nbsp; default_converter&=
lt; UserType&gt; : native_converter_base&lt; UserType&gt; {<o:p></o:p></spa=
n></p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in"><span st=
yle=3D"font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp; //defi=
ne compute_score, to and from functions.<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-indent:.5in"><span st=
yle=3D"font-family:&quot;Courier New&quot;">};<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;">}<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-indent:.5in"><span style=3D"font-famil=
y:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal">But when I actually do the assignment, the converter=
 code doesn&#8217;t get called. I&#8217;m expecting the &#8216;to&#8217; fu=
nction in the converter to get called, since I&#8217;m assigning a custom&n=
bsp; type to a lua object, which doesn&#8217;t happen.
<o:p></o:p></p>
<p class=3D"MsoNormal">Is this the correct way to do this. Please let me kn=
ow if you find any issues with this setup.
<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Thanks arun.<o:p></o:p></p>
</div>
</body>
</html>

--_000_968F113960C5EC44950119195F8CB50C207A32A4HIGH5EXCH1High5_--


--===============0486970010114043489==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
--===============0486970010114043489==
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

--===============0486970010114043489==--