Re: Assigning the "this" pointer

liam mail <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
On 28 May 2011 17:55, Ben Ashley <[email protected]> wrote:

> Hi All,
>
> Newbie Luabind user here!  I've been having great success implementing
> luabind in to my project, but have come across a snag.
>
> I have the following code:
>
>  void LogManager::luaBindImpl() const
> {
>  using namespace luabind;
> lua_State* state(Supervisor::get<LuaManager>()->state());
>  // LogManager
>  module(state)
> [
>  class_<LogManager>("LogManager")
> .enum_("constants")
>  [
>  value("Info", 1)
>  ,value("Warning", 2)
> ,value("Critical", 3)
>  ,value("Debug", 4)
> ]
>  .def("log", &LogManager::log)
> .def("registerSource", &LogManager::registerSource)
>  ];
>
>  // Add to globals
> globals(state)["LM"] = this;
>  }; // eo luaBindImpl
>
> The problem is the line which sets the global "LM" to "this".  Whenever I
> call a function in my LUA script on "LM", I get the following error
> (reported in my log file):
>
> 00:00:01:0060- lua:Exception - No matching overload found, candidates:
> void registerSource(LogManager&,std::string const&)
>
> The lua code is this:
>
>
> LM:registerSource("test");
>
>
>
> Interestingly, when I do:
>
> globals(state)["LM"] = new LogManager();
>
>
> ... everything works as intended.
>
> Am I doing something obviously wrong?
>
>
>
> Many thanks in advance!
>
>
> ------------------------------------------------------------------------------
> vRanger cuts backup time in half-while increasing security.
> With the market-leading solution for virtual backup and recovery,
> you get blazing-fast, flexible, and affordable data protection.
> Download your free trial now.
> http://p.sf.net/sfu/quest-d2dcopy1
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>
The function is constant which effects the type of the "this" pointer and
therefore effects the function signature which Luabind is looking for, hence
the error message.

For more detailed information see for example msdn docs[1]

[1] http://msdn.microsoft.com/en-us/library/ytk2ae82.aspx

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1

_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user
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.