passing a reference to a primitive?

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

passing a reference to a primitive?

Cory Riddell
I've been working through some of the examples and I can't figure out
what's wrong.

I have a function that takes a reference to a double:

  void fn(double& value) {
    value += 3.4;
  }

I bind it with code that looks something like:

  module(L) [
    def("fn", fn)
  ]:

Then try to run it:
 
  luaL_dostring(
    L,
    "fval = 3.2\n"
    "fn(fval)\n"
  );

I get back an error that says something like:

  No matching overload found, candidates:
  void fn(custom [double]&)

I've tried being super-specific by binding fn like this:

  def("fn", (void(*)(double&)fn)

but I get the same result. I'm really trying to use the out_value
policy, but I can't even get this to compile:

  def("fn", fn, out_value(_1))

FWIW, I'm using VS2010.

I'm starting to wonder if I should just stick to the Lua's C api and try
to keep my dependencies to a minimum. Frankly, when I try to figure out
how luabind is working, it pretty much looks like magic.

The canonical version of luabind doesn't appear to be maintained any
more. I know some people on this list are maintaining forks and I'm
wondering if their version of luabind works for what I'm trying to do?
I've started to play with boost-python. It seems much heavier and more
complicated, but also more active.

Advice and suggestions welcomed!

Thanks,
Cory



------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: passing a reference to a primitive?

Nigel Atkinson-2
I've struck the same problem with floats although typedef'ed as
Ogre::Real.

The 'canonical' version does not have this problem, however at least
Ryan Pavlik's version does have this problem (at least when I last
checked) - due to an improved (in most ways) way of doing the
double/float/int to Lua conversion.

Which luabind are you using?

Nigel

On Tue, 2012-11-06 at 13:57 -0600, Cory Riddell wrote:

> I've been working through some of the examples and I can't figure out
> what's wrong.
>
> I have a function that takes a reference to a double:
>
>   void fn(double& value) {
>     value += 3.4;
>   }
>
> I bind it with code that looks something like:
>
>   module(L) [
>     def("fn", fn)
>   ]:
>
> Then try to run it:
>  
>   luaL_dostring(
>     L,
>     "fval = 3.2\n"
>     "fn(fval)\n"
>   );
>
> I get back an error that says something like:
>
>   No matching overload found, candidates:
>   void fn(custom [double]&)
>
> I've tried being super-specific by binding fn like this:
>
>   def("fn", (void(*)(double&)fn)
>
> but I get the same result. I'm really trying to use the out_value
> policy, but I can't even get this to compile:
>
>   def("fn", fn, out_value(_1))
>
> FWIW, I'm using VS2010.
>
> I'm starting to wonder if I should just stick to the Lua's C api and try
> to keep my dependencies to a minimum. Frankly, when I try to figure out
> how luabind is working, it pretty much looks like magic.
>
> The canonical version of luabind doesn't appear to be maintained any
> more. I know some people on this list are maintaining forks and I'm
> wondering if their version of luabind works for what I'm trying to do?
> I've started to play with boost-python. It seems much heavier and more
> complicated, but also more active.
>
> Advice and suggestions welcomed!
>
> Thanks,
> Cory
>
>
>
> ------------------------------------------------------------------------------
> LogMeIn Central: Instant, anywhere, Remote PC access and management.
> Stay in control, update software, and manage PCs from one command center
> Diagnose problems and improve visibility into emerging IT issues
> Automate, monitor and manage. Do more in less time with Central
> http://p.sf.net/sfu/logmein12331_d2d
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user



------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: passing a reference to a primitive?

Nigel Atkinson-2
In reply to this post by Cory Riddell
I've just installed the default luabind package on Fedora 17, and I can
confirm it has the same issue. :-/

Doh!

Nigel

On Tue, 2012-11-06 at 13:57 -0600, Cory Riddell wrote:

> I've been working through some of the examples and I can't figure out
> what's wrong.
>
> I have a function that takes a reference to a double:
>
>   void fn(double& value) {
>     value += 3.4;
>   }
>
> I bind it with code that looks something like:
>
>   module(L) [
>     def("fn", fn)
>   ]:
>
> Then try to run it:
>  
>   luaL_dostring(
>     L,
>     "fval = 3.2\n"
>     "fn(fval)\n"
>   );
>
> I get back an error that says something like:
>
>   No matching overload found, candidates:
>   void fn(custom [double]&)
>
> I've tried being super-specific by binding fn like this:
>
>   def("fn", (void(*)(double&)fn)
>
> but I get the same result. I'm really trying to use the out_value
> policy, but I can't even get this to compile:
>
>   def("fn", fn, out_value(_1))
>
> FWIW, I'm using VS2010.
>
> I'm starting to wonder if I should just stick to the Lua's C api and try
> to keep my dependencies to a minimum. Frankly, when I try to figure out
> how luabind is working, it pretty much looks like magic.
>
> The canonical version of luabind doesn't appear to be maintained any
> more. I know some people on this list are maintaining forks and I'm
> wondering if their version of luabind works for what I'm trying to do?
> I've started to play with boost-python. It seems much heavier and more
> complicated, but also more active.
>
> Advice and suggestions welcomed!
>
> Thanks,
> Cory
>
>
>
> ------------------------------------------------------------------------------
> LogMeIn Central: Instant, anywhere, Remote PC access and management.
> Stay in control, update software, and manage PCs from one command center
> Diagnose problems and improve visibility into emerging IT issues
> Automate, monitor and manage. Do more in less time with Central
> http://p.sf.net/sfu/logmein12331_d2d
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user



------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: passing a reference to a primitive?

Cory Riddell
I'm using luabind 0.9.1 from
http://www.rasterbar.com/products/luabind.html.

I've been playing with boost-python for most of today and it's similar,
but soooo much bigger. It would also require me to write a lot more
adapter code.

I'm hoping a fork-maintainer shows up with good news. If Rasterbar isn't
interested in the project any more, it would be fantastic for one of the
forks to be named the official successor.

Anyways, thanks for testing this out on Fedora. For some reason I just
assumed it would work with gcc.

Cory


On 11/6/2012 10:30 PM, Nigel Atkinson wrote:

> I've just installed the default luabind package on Fedora 17, and I can
> confirm it has the same issue. :-/
>
> Doh!
>
> Nigel
>
> On Tue, 2012-11-06 at 13:57 -0600, Cory Riddell wrote:
>> I've been working through some of the examples and I can't figure out
>> what's wrong.
>>
>> I have a function that takes a reference to a double:
>>
>>   void fn(double& value) {
>>     value += 3.4;
>>   }
>>
>> I bind it with code that looks something like:
>>
>>   module(L) [
>>     def("fn", fn)
>>   ]:
>>
>> Then try to run it:
>>  
>>   luaL_dostring(
>>     L,
>>     "fval = 3.2\n"
>>     "fn(fval)\n"
>>   );
>>
>> I get back an error that says something like:
>>
>>   No matching overload found, candidates:
>>   void fn(custom [double]&)
>>
>> I've tried being super-specific by binding fn like this:
>>
>>   def("fn", (void(*)(double&)fn)
>>
>> but I get the same result. I'm really trying to use the out_value
>> policy, but I can't even get this to compile:
>>
>>   def("fn", fn, out_value(_1))
>>
>> FWIW, I'm using VS2010.
>>
>> I'm starting to wonder if I should just stick to the Lua's C api and try
>> to keep my dependencies to a minimum. Frankly, when I try to figure out
>> how luabind is working, it pretty much looks like magic.
>>
>> The canonical version of luabind doesn't appear to be maintained any
>> more. I know some people on this list are maintaining forks and I'm
>> wondering if their version of luabind works for what I'm trying to do?
>> I've started to play with boost-python. It seems much heavier and more
>> complicated, but also more active.
>>
>> Advice and suggestions welcomed!
>>
>> Thanks,
>> Cory
>>
>>
>>
>> ------------------------------------------------------------------------------
>> LogMeIn Central: Instant, anywhere, Remote PC access and management.
>> Stay in control, update software, and manage PCs from one command center
>> Diagnose problems and improve visibility into emerging IT issues
>> Automate, monitor and manage. Do more in less time with Central
>> http://p.sf.net/sfu/logmein12331_d2d
>> _______________________________________________
>> luabind-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>
> ------------------------------------------------------------------------------
> LogMeIn Central: Instant, anywhere, Remote PC access and management.
> Stay in control, update software, and manage PCs from one command center
> Diagnose problems and improve visibility into emerging IT issues
> Automate, monitor and manage. Do more in less time with Central
> http://p.sf.net/sfu/logmein12331_d2d
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>


------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user