Re: Problem when passing a pointer to call_function.

Teto <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
On Tue, Aug 4, 2009 at 6:15 AM, Thomas Nelson <[email protected]> wrote:
>
> This is just a guess based on what you've sent, but have you exported an
> ILoader<> of the appropriate type to Lua?

I thought I did but in fact I was registering a derived type . I have
been confused by the writing. I was registering CTextureLoader instead
of registering into lua ILoader<Ctexture> and - stupidity of mine -
thought they were the same whereas I define CTextureLoader by doing:
class CTextureLoader : public ILoader<Ctexture> { ... }

 I've solved the matter thx to your advice and thought of a new design
which works.

>
>  Remember that after the template
> compiler finishes there is no relation between template expansions of
> different types.
>
> If you have two types, say:
> class Foo {}
>
> class Bar {}
>
> You would need something along the lines of:
> module(pLState)
> [
>    class_<ILoader<Foo> >("LoaderFoo"),
>    class_<ILoader<Bar> >("LoaderBar")
> ];
>
> Alternately you could:
> class ILoaderBase {}
> template <T> class ILoader: public ILoaderBase {}
>
> module(pLState)
> [
>    class_<ILoaderBase>("Loader")
> ];
>
> > -----Original Message-----
> > From: Teto
> >
> > Hello,
> >
> > I'm facing a "assertion failed: crep && your are trying to use an
> > unregistered type" policy.hpp line 192" when I tried to call a Lua
> > function from C++. I've done many tests and the matter happens when I
> > try to pass "loader" as a parameter of the lua function.
> >
> > ================================
> > template<class T>
> > bool
> > AddLoader(ILoader<T>* loader,std::string extensions)
> > {
> >     luabind::object obj = luabind::globals(
> >         CGameEngine::GetInstance()->mScript.mLuaState)["AddLoader"];
> >     if(!(obj && luabind::type(obj) == LUA_TFUNCTION))
> >     {
> >         return false;
> >     }
> >
> >     bool ok = luabind::call_function<bool>(obj,loader,extensions);
> > }
> > ================================
> >
> > i'm using luabind 8.* .
> >
>
> --
> Thomas Nelson  [email protected]
> --------------------------------------------------------------
> "If you still have gas, you're not lost".
> - French explorer Pierre Frontage.
> (M.Frontage was so influential in the exploration of North America many
> roads are still named after him.)
>
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
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.