Re: Pass int64

Daniel Wallin <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Tom McCubbin wrote:
> 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.

You can customize the native converters by providing a specialization of
luabind::default_converter<>. See:

  test/test_user_defined_converter.cpp

Something like:

  namespace luabind {

  template <>
  struct default_converter<__int64>
    : native_converter_base<__int64>
  {
      static int compute_score(lua_State* L, int index)
      {
          return default_converter<int>::compute_score(L, index);
      }

      __int64 from(lua_State* L, int index)
      {
          return (__int64)lua_tonumber(L, index);
      }

      void to(lua_State* L, __int64 value)
      {
          lua_pushnumber(L, value);
      }
  };

  } // namespace luabind

Should do it.

-- 
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
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 as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
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.