No matching overload found

View: New views
3 Messages — Rating Filter:   Alert me  

No matching overload found

by Phlox Icon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I can't understand why luabind is giving me this error. I have a function bound with:
luabind::module( GetLua() ) [
luabind::class_<CGlobalEntityList>( "CGlobalEntityList" )  
.def( "FindEntityByName", ( CBaseEntity *( CGlobalEntityList::* )( CBaseEntity *, const char *, CBaseEntity *, CBaseEntity *, CBaseEntity *, IEntityFindFilter * )) &CGlobalEntityList::FindEntityByName )
];


to the function:
// uses default arguments
CBaseEntity *CGlobalEntityList::FindEntityByName( CBaseEntity *pStartEntity, const char *szName, CBaseEntity *pSearchingEntity, CBaseEntity *pActivator, CBaseEntity *pCaller, IEntityFindFilter *pFilter )


I have a CGlobalEntityList object called gEntList. I set NULL = 0 at the top of the file and made sure that it does equal 0. When I call the bound function using with the code:
gEntList:FindEntityByName( NULL, szName, NULL, NULL, NULL, NULL )


When I run the code, I get the following error:
[Lua-ERR] No matching overload found, candidates:
CBaseEntity* FindEntityByName(CGlobalEntityList&,CBaseEntity*,char const*,CBaseEntity*,CBaseEntity*,CBaseEntity*,IEntityFindFilter*)

This is really confusing because the first parameter in the message's function is CGlobalEntityList&. This was not what I defined with LuaBind earlier and no such function exists to match this definition. Is my binding code wrong somewhere? Thanks in advance.

------------------------------------------------------------------------------
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
luabind-user@...
https://lists.sourceforge.net/lists/listinfo/luabind-user

Re: No matching overload found

by James Porter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Phlox Icon wrote:
> gEntList:FindEntityByName( NULL, szName, NULL, NULL, NULL, NULL )

Pointers don't exist in Lua (at least not the way you're doing it), and
this wouldn't work in C++ either (try defining "int null = 0;" and
passing that to your method - it'll fail). It would work if you bound
NULL to be a CBaseEntity* via Luabind.

> This is really confusing because the first parameter in the message's
> function is CGlobalEntityList&. This was not what I defined with LuaBind
> earlier and no such function exists to match this definition. Is my
> binding code wrong somewhere? Thanks in advance.

You may want to look into C++ calling conventions, since at the
implementation level, most compilers will pass an object as the first
parameter to its class's methods.

- Jim


------------------------------------------------------------------------------
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
luabind-user@...
https://lists.sourceforge.net/lists/listinfo/luabind-user

Re: No matching overload found

by Phlox Icon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you for your response, James. I did what you said and it worked immediately. I'll just paste the code here for Googlers in future:

//C++
//Global scope
CBaseEntity *NULL_CBaseEntity = NULL;

//in a function somewhere else
luabind::globals( GetLuaHandle()->GetLua() )["NULL_CBaseEntity"] = NULL_CBaseEntity;

-- in the Lua function
if( pStartEntity and szName ) then
if ( pStartEntity == NULL ) then
pStartEntity = NULL_CBaseEntity
end
-- call function
gEntList:FindEntityByName( pStartEntity, szName, NULL_CBaseEntity, NULL_CBaseEntity, NULL_CBaseEntity, NULL_CBaseEntity )
end



Sorry, but I have just one more question regarding this piece of code. This function returns a base class type. I'm wondering how to cast this another type. The Lua reference manual and PIL don't seem to mention casting of this type and Google hasn't been helpful. I basically want:
// in C++
DerivedType d = (DerivedType)g.getObject('objectName') ; // returned base object is cast to derived type
... // perform derivedType specific functions

but code to the same effect in Lua. Is there an easy LuaBind way of doing this? I've been at this for over a day so I'd also gladly settle for any way of doing this casting in Lua.

All input is appreciated :)

------------------------------------------------------------------------------
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
luabind-user@...
https://lists.sourceforge.net/lists/listinfo/luabind-user