Re: Pass int64

Tom McCubbin <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <1243350055.22852.19.camel@macquad>
Hmmm....that's ugly.  Honestly, since lua uses ptrdiff_t for its integer
type, depending on platform you may have data loss.  If you are on a 64
bit version of windows ( I assume windows as __int64 is a MS thing...and
not ANSI, and not on linux, unix ) you should be ok.

However, it means you need to derive from the class RawData and overload
the members to call the parent and use a variadic return
type...something like:

class MyRawData : public RawData
{
   typedef RawData    parent;

MyRawData( ptrdiff_t v ) : parent(v) { }
 //..
 ptrdiff_t getSize() { return this->parent::getSize(); }

};

I'm sure there is a better/slicker way to achieve it, but this would be
the long typed, least thought out approach ;)

-tom

On Tue, 2009-05-26 at 16:51 +0300, Valery wrote:

>  
> 
> Tom, Thanks, 
>  
> Yes, your variant works. But what should I do if my class has get
> method like:
> __int64 getSize();
>  
> .cpp
> luabind::class_<RawData, boost::shared_ptr<RawData> >("RawData" )
>     .def( luabind::constructor<int>() )
>     .def("getSize", &RawData::getSize) 
>  
> .lua
> RawData(10):getSize()
>  
> I get "you are trying to use an unregistered type".
>  
> I tryed something like the next, but I cannot use 'type'. 
> luabind::class_< __int64 > ("Int64")
>  
> Thanks,
> Valery.
>  
> ----- Original Message ----- 
> 
> From: Tom McCubbin 
> To: [email protected] 
> Sent: Tuesday, May 26, 2009 3:51 PM
> Subject: Re: [luabind] Pass int64
> 
> 
> 
> If the constructor is not explicit (not marked as so below), why not
> try and change your luabind::constructor<>()  to take an int, and let
> the compiler do its 1 allowed conversion step.  At runtime luabind
> doesn't have the smarts to map a number to __int64 in looking up the
> constructor would be my guess as to why you have the problem.
> 
> luabind::class_<RawData, boost::shared_ptr<RawData> >("RawData" )
>     .def( luabind::constructor<int>() ); //...
> 
> That or derive and add a new signature for int.
> 
> 
> On Tue, 2009-05-26 at 14:32 +0300, Valery wrote: 
> 
> > Hello,
> > 
> > I have a class that gets __int64 as a parameter in the constructor. I am 
> > trying to create it from lua, but get the error "FAIL: Test: no constructor 
> > of 'RawData' matched the arguments (number)
> >  candidates are:
> > RawData(custom [__int64])"
> > 
> > Could anybody help?
> > 
> > .cpp
> > class RawData {
> >  public: RawData(__int64) {}
> > };
> > luabind::class_<RawData, boost::shared_ptr<RawData> >("RawData")
> >  .def(luabind::constructor<__int64>())
> > 
> > .lua
> > x=RawData(10)
> > 
> > Thanks,
> > Valery. 
> > 
> > 
> > ------------------------------------------------------------------------------
> > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> > is a gathering of tech-side developers & brand creativity professionals. Meet
> > the minds behind Google Creative Lab, Visual Complexity, Processing, & 
> > iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
> > Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
> > _______________________________________________
> > luabind-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/luabind-user
> 
> 
> 
> ______________________________________________________________________
> 
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity
> professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing,
> & 
> iPhoneDevCamp asthey present alongside digital heavyweights like
> Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
> 
> 
> ______________________________________________________________________
> 
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
> 
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, & 
> iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
> _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com

_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user
stock_smiley-3.png (image/png, 876 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.