1
0

WebAdmin: Manually exported string conversion functions.

ToLua generated an extra return value for GetHTMLEscapedString() and GetURLEncodedString(), making them difficult to use.
This commit is contained in:
madmaxoft 2014-08-09 22:54:43 +02:00
parent 2ab8e76392
commit 50359ce656
2 changed files with 64 additions and 6 deletions

View File

@ -2128,6 +2128,62 @@ static int tolua_cWebAdmin_GetPlugins(lua_State * tolua_S)
/** Binding for cWebAdmin::GetHTMLEscapedString.
Manual code required because ToLua generates an extra return value */
static int tolua_AllToLua_cWebAdmin_GetHTMLEscapedString(lua_State * tolua_S)
{
// Check the param types:
cLuaState S(tolua_S);
if (
!S.CheckParamUserTable(1, "cWebAdmin") ||
!S.CheckParamString(2) ||
!S.CheckParamEnd(3)
)
{
return 0;
}
// Get the parameters:
AString Input;
S.GetStackValue(2, Input);
// Convert and return:
S.Push(cWebAdmin::GetHTMLEscapedString(Input));
return 1;
}
/** Binding for cWebAdmin::GetURLEncodedString.
Manual code required because ToLua generates an extra return value */
static int tolua_AllToLua_cWebAdmin_GetURLEncodedString(lua_State * tolua_S)
{
// Check the param types:
cLuaState S(tolua_S);
if (
!S.CheckParamUserTable(1, "cWebAdmin") ||
!S.CheckParamString(2) ||
!S.CheckParamEnd(3)
)
{
return 0;
}
// Get the parameters:
AString Input;
S.GetStackValue(2, Input);
// Convert and return:
S.Push(cWebAdmin::GetURLEncodedString(Input));
return 1;
}
static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S)
{
cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S, 1, NULL);
@ -3264,7 +3320,9 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cWebAdmin");
tolua_function(tolua_S, "GetPlugins", tolua_cWebAdmin_GetPlugins);
tolua_function(tolua_S, "GetHTMLEscapedString", tolua_AllToLua_cWebAdmin_GetHTMLEscapedString);
tolua_function(tolua_S, "GetPlugins", tolua_cWebAdmin_GetPlugins);
tolua_function(tolua_S, "GetURLEncodedString", tolua_AllToLua_cWebAdmin_GetURLEncodedString);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cWebPlugin");

View File

@ -132,17 +132,17 @@ public:
/** Returns the prefix needed for making a link point to the webadmin root from the given URL ("../../../webadmin"-style) */
AString GetBaseURL(const AString & a_URL);
AString GetIPv4Ports(void) const { return m_PortsIPv4; }
AString GetIPv6Ports(void) const { return m_PortsIPv6; }
// tolua_end
/** Escapes text passed into it, so it can be embedded into html. */
static AString GetHTMLEscapedString(const AString & a_Input);
/** Escapes the string for use in an URL */
static AString GetURLEncodedString(const AString & a_Input);
AString GetIPv4Ports(void) const { return m_PortsIPv4; }
AString GetIPv6Ports(void) const { return m_PortsIPv6; }
// tolua_end
/** Returns the prefix needed for making a link point to the webadmin root from the given URL ("../../../webadmin"-style) */
static AString GetBaseURL(const AStringVector & a_URLSplit);