1
0

Added plugin name to deprecation messages

Removed duplicate inheritance of m_Name in cPlugin_NewLua by making cWebPlugin interface-only

git-svn-id: http://mc-server.googlecode.com/svn/trunk@782 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-08-23 20:49:21 +00:00
parent a39adadd0f
commit 263ce31bd6
6 changed files with 45 additions and 241 deletions

View File

@ -1,6 +1,6 @@
/* /*
** Lua binding: AllToLua ** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 08/22/12 16:11:06. ** Generated automatically by tolua++-1.0.92 on 08/23/12 22:41:28.
*/ */
#ifndef __cplusplus #ifndef __cplusplus
@ -60,13 +60,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
/* function to release collected object via destructor */ /* function to release collected object via destructor */
#ifdef __cplusplus #ifdef __cplusplus
static int tolua_collect_cMCLogger (lua_State* tolua_S)
{
cMCLogger* self = (cMCLogger*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self);
return 0;
}
static int tolua_collect_cItem (lua_State* tolua_S) static int tolua_collect_cItem (lua_State* tolua_S)
{ {
cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0); cItem* self = (cItem*) tolua_tousertype(tolua_S,1,0);
@ -95,16 +88,16 @@ static int tolua_collect_cPickup (lua_State* tolua_S)
return 0; return 0;
} }
static int tolua_collect_cBlockArea (lua_State* tolua_S) static int tolua_collect_cTracer (lua_State* tolua_S)
{ {
cBlockArea* self = (cBlockArea*) tolua_tousertype(tolua_S,1,0); cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self); Mtolua_delete(self);
return 0; return 0;
} }
static int tolua_collect_cTracer (lua_State* tolua_S) static int tolua_collect_cBlockArea (lua_State* tolua_S)
{ {
cTracer* self = (cTracer*) tolua_tousertype(tolua_S,1,0); cBlockArea* self = (cBlockArea*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self); Mtolua_delete(self);
return 0; return 0;
} }
@ -130,9 +123,9 @@ static int tolua_collect_cCuboid (lua_State* tolua_S)
return 0; return 0;
} }
static int tolua_collect_cWebPlugin (lua_State* tolua_S) static int tolua_collect_cMCLogger (lua_State* tolua_S)
{ {
cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0); cMCLogger* self = (cMCLogger*) tolua_tousertype(tolua_S,1,0);
Mtolua_delete(self); Mtolua_delete(self);
return 0; return 0;
} }
@ -13439,100 +13432,6 @@ static int tolua_set_HTTPRequest_Username(lua_State* tolua_S)
} }
#endif //#ifndef TOLUA_DISABLE #endif //#ifndef TOLUA_DISABLE
/* method: delete of class cWebPlugin */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_delete00
static int tolua_AllToLua_cWebPlugin_delete00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cWebPlugin",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
#endif
Mtolua_delete(self);
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: SetName of class cWebPlugin */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_SetName00
static int tolua_AllToLua_cWebPlugin_SetName00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cWebPlugin",0,&tolua_err) ||
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0);
std::string a_Name = ((std::string) tolua_tocppstring(tolua_S,2,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetName'", NULL);
#endif
{
self->SetName(a_Name);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'SetName'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetName of class cWebPlugin */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_GetName00
static int tolua_AllToLua_cWebPlugin_GetName00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cWebPlugin",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetName'", NULL);
#endif
{
std::string tolua_ret = (std::string) self->GetName();
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'GetName'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: HandleWebRequest of class cWebPlugin */ /* method: HandleWebRequest of class cWebPlugin */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_HandleWebRequest00 #ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_HandleWebRequest00
static int tolua_AllToLua_cWebPlugin_HandleWebRequest00(lua_State* tolua_S) static int tolua_AllToLua_cWebPlugin_HandleWebRequest00(lua_State* tolua_S)
@ -13554,7 +13453,7 @@ static int tolua_AllToLua_cWebPlugin_HandleWebRequest00(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'HandleWebRequest'", NULL); if (!self) tolua_error(tolua_S,"invalid 'self' in function 'HandleWebRequest'", NULL);
#endif #endif
{ {
std::string tolua_ret = (std::string) self->HandleWebRequest(a_Request); AString tolua_ret = (AString) self->HandleWebRequest(a_Request);
tolua_pushcppstring(tolua_S,(const char*)tolua_ret); tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
} }
} }
@ -13600,11 +13499,11 @@ static int tolua_AllToLua_cWebPlugin_SafeString00(lua_State* tolua_S)
class Lua__cWebPlugin : public cWebPlugin, public ToluaBase { class Lua__cWebPlugin : public cWebPlugin, public ToluaBase {
public: public:
std::string HandleWebRequest( HTTPRequest* a_Request) { AString HandleWebRequest( HTTPRequest* a_Request) {
if (push_method("HandleWebRequest", tolua_AllToLua_cWebPlugin_HandleWebRequest00)) { if (push_method("HandleWebRequest", tolua_AllToLua_cWebPlugin_HandleWebRequest00)) {
tolua_pushusertype(lua_state, (void*)a_Request, "HTTPRequest"); tolua_pushusertype(lua_state, (void*)a_Request, "HTTPRequest");
ToluaBase::dbcall(lua_state, 2, 1); ToluaBase::dbcall(lua_state, 2, 1);
std::string tolua_ret = ( std::string )tolua_tocppstring(lua_state, -1, 0); AString tolua_ret = ( AString )tolua_tocppstring(lua_state, -1, 0);
lua_pop(lua_state, 1); lua_pop(lua_state, 1);
return tolua_ret; return tolua_ret;
} else { } else {
@ -13614,11 +13513,10 @@ public:
LOG("pure-virtual method cWebPlugin::HandleWebRequest called with no lua_state. Aborting"); LOG("pure-virtual method cWebPlugin::HandleWebRequest called with no lua_state. Aborting");
::abort(); ::abort();
}; };
return ""; return ( AString )0;
}; };
}; };
Lua__cWebPlugin( void ): cWebPlugin(){};
}; };
/* method: tolua__set_instance of class Lua__cWebPlugin */ /* method: tolua__set_instance of class Lua__cWebPlugin */
@ -13654,104 +13552,6 @@ static int tolua_AllToLua_Lua__cWebPlugin_tolua__set_instance00(lua_State* tolua
} }
#endif //#ifndef TOLUA_DISABLE #endif //#ifndef TOLUA_DISABLE
/* method: new of class Lua__cWebPlugin */
#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cWebPlugin_new00
static int tolua_AllToLua_Lua__cWebPlugin_new00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"Lua__cWebPlugin",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
{
Lua__cWebPlugin* tolua_ret = (Lua__cWebPlugin*) Mtolua_new((Lua__cWebPlugin)());
tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cWebPlugin");
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: new_local of class Lua__cWebPlugin */
#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cWebPlugin_new00_local
static int tolua_AllToLua_Lua__cWebPlugin_new00_local(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"Lua__cWebPlugin",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
{
Lua__cWebPlugin* tolua_ret = (Lua__cWebPlugin*) Mtolua_new((Lua__cWebPlugin)());
tolua_pushusertype(tolua_S,(void*)tolua_ret,"Lua__cWebPlugin");
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: delete of class Lua__cWebPlugin */
#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cWebPlugin_delete00
static int tolua_AllToLua_Lua__cWebPlugin_delete00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"Lua__cWebPlugin",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
Lua__cWebPlugin* self = (Lua__cWebPlugin*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL);
#endif
Mtolua_delete(self);
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* function to release collected object via destructor */
#ifdef __cplusplus
static int tolua_collect_Lua__cWebPlugin (lua_State* tolua_S)
{
Lua__cWebPlugin* self = (Lua__cWebPlugin*) tolua_tousertype(tolua_S,1,0);
delete self;
return 0;
}
#endif
/* method: new of class cPickup */ /* method: new of class cPickup */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_new00 #ifndef TOLUA_DISABLE_tolua_AllToLua_cPickup_new00
static int tolua_AllToLua_cPickup_new00(lua_State* tolua_S) static int tolua_AllToLua_cPickup_new00(lua_State* tolua_S)
@ -21846,29 +21646,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_variable(tolua_S,"Path",tolua_get_HTTPRequest_Path,tolua_set_HTTPRequest_Path); tolua_variable(tolua_S,"Path",tolua_get_HTTPRequest_Path,tolua_set_HTTPRequest_Path);
tolua_variable(tolua_S,"Username",tolua_get_HTTPRequest_Username,tolua_set_HTTPRequest_Username); tolua_variable(tolua_S,"Username",tolua_get_HTTPRequest_Username,tolua_set_HTTPRequest_Username);
tolua_endmodule(tolua_S); tolua_endmodule(tolua_S);
#ifdef __cplusplus
tolua_cclass(tolua_S,"cWebPlugin","cWebPlugin","",tolua_collect_cWebPlugin);
#else
tolua_cclass(tolua_S,"cWebPlugin","cWebPlugin","",NULL); tolua_cclass(tolua_S,"cWebPlugin","cWebPlugin","",NULL);
#endif
tolua_beginmodule(tolua_S,"cWebPlugin"); tolua_beginmodule(tolua_S,"cWebPlugin");
tolua_function(tolua_S,"delete",tolua_AllToLua_cWebPlugin_delete00);
tolua_function(tolua_S,"SetName",tolua_AllToLua_cWebPlugin_SetName00);
tolua_function(tolua_S,"GetName",tolua_AllToLua_cWebPlugin_GetName00);
tolua_function(tolua_S,"HandleWebRequest",tolua_AllToLua_cWebPlugin_HandleWebRequest00); tolua_function(tolua_S,"HandleWebRequest",tolua_AllToLua_cWebPlugin_HandleWebRequest00);
tolua_function(tolua_S,"SafeString",tolua_AllToLua_cWebPlugin_SafeString00); tolua_function(tolua_S,"SafeString",tolua_AllToLua_cWebPlugin_SafeString00);
tolua_endmodule(tolua_S); tolua_endmodule(tolua_S);
#ifdef __cplusplus
tolua_cclass(tolua_S,"Lua__cWebPlugin","Lua__cWebPlugin","cWebPlugin",tolua_collect_Lua__cWebPlugin);
#else
tolua_cclass(tolua_S,"Lua__cWebPlugin","Lua__cWebPlugin","cWebPlugin",NULL); tolua_cclass(tolua_S,"Lua__cWebPlugin","Lua__cWebPlugin","cWebPlugin",NULL);
#endif
tolua_beginmodule(tolua_S,"Lua__cWebPlugin"); tolua_beginmodule(tolua_S,"Lua__cWebPlugin");
tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cWebPlugin_tolua__set_instance00); tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cWebPlugin_tolua__set_instance00);
tolua_function(tolua_S,"new",tolua_AllToLua_Lua__cWebPlugin_new00);
tolua_function(tolua_S,"new_local",tolua_AllToLua_Lua__cWebPlugin_new00_local);
tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cWebPlugin_new00_local);
tolua_function(tolua_S,"delete",tolua_AllToLua_Lua__cWebPlugin_delete00);
tolua_endmodule(tolua_S); tolua_endmodule(tolua_S);
#ifdef __cplusplus #ifdef __cplusplus
tolua_cclass(tolua_S,"cPickup","cPickup","cEntity",tolua_collect_cPickup); tolua_cclass(tolua_S,"cPickup","cPickup","cEntity",tolua_collect_cPickup);

View File

@ -1,6 +1,6 @@
/* /*
** Lua binding: AllToLua ** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 08/22/12 16:11:06. ** Generated automatically by tolua++-1.0.92 on 08/23/12 22:41:28.
*/ */
/* Exported function */ /* Exported function */

View File

@ -607,7 +607,10 @@ static int tolua_cPlugin_NewLua_AddWebTab(lua_State* tolua_S)
static int tolua_cPlugin_NewLua_AddTab(lua_State* tolua_S) static int tolua_cPlugin_NewLua_AddTab(lua_State* tolua_S)
{ {
LOGWARN("WARNING: Using deprecated function AddTab()! Use AddWebTab() instead."); cPlugin_NewLua * self = (cPlugin_NewLua *) tolua_tousertype(tolua_S, 1, 0);
LOGWARN("WARNING: Using deprecated function AddTab()! Use AddWebTab() instead. (plugin \"%s\" in folder \"%s\")",
self->GetName().c_str(), self->GetDirectory().c_str()
);
return tolua_cPlugin_NewLua_AddWebTab( tolua_S ); return tolua_cPlugin_NewLua_AddWebTab( tolua_S );
} }

View File

@ -633,9 +633,11 @@ bool cPlugin_NewLua::OnUpdatedSign(
cPlugin_NewLua* cPlugin_NewLua::CreateWebPlugin(lua_State* a_LuaState) cPlugin_NewLua * cPlugin_NewLua::CreateWebPlugin(lua_State * a_LuaState)
{ {
LOGWARN("WARNING: Using deprecated function CreateWebPlugin()! A Lua plugin is a WebPlugin by itself now."); LOGWARN("WARNING: Using deprecated function CreateWebPlugin()! A Lua plugin is a WebPlugin by itself now. (plugin \"%s\" in folder \"%s\")",
cPlugin::GetName().c_str(), m_Directory.c_str()
);
return this; return this;
} }

View File

@ -46,18 +46,23 @@ public: //tolua_export
virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4) override; virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4) override;
virtual bool OnWeatherChanged (cWorld * a_World) override; virtual bool OnWeatherChanged (cWorld * a_World) override;
virtual void SetName( const AString & a_Name ) override { cPlugin::SetName(a_Name); cWebPlugin::SetName(a_Name); } const AString & GetDirectory(void) const {return m_Directory; }
virtual void SetName( const AString & a_Name ) override { cPlugin::SetName(a_Name); }
// cWebPlugin override
virtual const AString & GetName(void) const {return cPlugin::GetName(); }
// cWebPlugin and WebAdmin stuff // cWebPlugin and WebAdmin stuff
virtual AString HandleWebRequest( HTTPRequest * a_Request ) override; virtual AString HandleWebRequest( HTTPRequest * a_Request ) override;
bool AddWebTab( const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference ); // >> EXPORTED IN MANUALBINDINGS << bool AddWebTab( const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference ); // >> EXPORTED IN MANUALBINDINGS <<
OBSOLETE bool AddTab( const AString & a_Title, lua_State * a_LuaState, int a_FunctionReference ); // >> EXPORTED IN MANUALBINDINGS <<
lua_State* GetLuaState() { return m_LuaState; } lua_State* GetLuaState() { return m_LuaState; }
OBSOLETE cPlugin_NewLua * CreateWebPlugin(lua_State* a_LuaState); //tolua_export OBSOLETE cPlugin_NewLua * CreateWebPlugin(lua_State * a_LuaState); //tolua_export
cCriticalSection & GetCriticalSection() { return m_CriticalSection; } cCriticalSection & GetCriticalSection() { return m_CriticalSection; }
private: private:
bool PushFunction( const char* a_FunctionName, bool a_bLogError = true ); bool PushFunction( const char* a_FunctionName, bool a_bLogError = true );
bool CallFunction( int a_NumArgs, int a_NumResults, const char* a_FunctionName ); // a_FunctionName is only used for error messages, nothing else bool CallFunction( int a_NumArgs, int a_NumResults, const char* a_FunctionName ); // a_FunctionName is only used for error messages, nothing else
@ -65,5 +70,5 @@ private:
cCriticalSection m_CriticalSection; cCriticalSection m_CriticalSection;
std::string m_Directory; std::string m_Directory;
lua_State* m_LuaState; lua_State * m_LuaState;
};//tolua_export };//tolua_export

View File

@ -3,17 +3,23 @@
struct lua_State; struct lua_State;
struct HTTPRequest; struct HTTPRequest;
//tolua_begin
// tolua_begin
class cWebPlugin class cWebPlugin
{ {
public: public:
// tolua_end
cWebPlugin(); cWebPlugin();
virtual ~cWebPlugin(); virtual ~cWebPlugin();
void SetName( std::string a_Name ) { m_Name = a_Name; }
AString GetName() { return m_Name; }
virtual AString HandleWebRequest( HTTPRequest* a_Request ) = 0; virtual const AString & GetName(void) const = 0;
// tolua_begin
virtual AString HandleWebRequest( HTTPRequest * a_Request ) = 0;
static AString SafeString( const AString & a_String ); static AString SafeString( const AString & a_String );
//tolua_end //tolua_end
@ -34,5 +40,8 @@ public:
private: private:
TabList m_Tabs; TabList m_Tabs;
AString m_Name; }; // tolua_export
}; //tolua_export