2010-12-13 09:00:02 +00:00
|
|
|
#include "../StdAfx.h"
|
2010-12-12 17:08:36 +00:00
|
|
|
#include "LuaPush.h"
|
|
|
|
|
|
|
|
#include "../Litestep.h"
|
|
|
|
|
2011-07-05 13:41:05 +00:00
|
|
|
void push_wstring(lua_State* L, const std::wstring& value)
|
2011-02-15 13:22:19 +00:00
|
|
|
{
|
2011-07-05 13:41:05 +00:00
|
|
|
push_wchar(L, value.c_str());
|
2010-12-12 17:08:36 +00:00
|
|
|
}
|
|
|
|
|
2011-07-05 13:41:05 +00:00
|
|
|
void push_wchar(lua_State* L, const WCHAR* value)
|
2010-12-12 17:08:36 +00:00
|
|
|
{
|
2011-07-05 13:41:05 +00:00
|
|
|
std::string str = ConvertToAscii(value);
|
|
|
|
lua_pushstring(L, str.c_str());
|
2010-12-12 17:08:36 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 13:04:17 +00:00
|
|
|
std::wstring to_wstring(lua_State* L, int arg, void* type)
|
2010-12-12 17:08:36 +00:00
|
|
|
{
|
2011-02-15 13:22:19 +00:00
|
|
|
return ConvertToWide(lua_tostring(L,arg));
|
2010-12-12 17:08:36 +00:00
|
|
|
}
|
|
|
|
|
2011-07-05 13:41:05 +00:00
|
|
|
const WCHAR* to_wchar(lua_State* L, int arg, void* type)
|
2010-12-12 17:08:36 +00:00
|
|
|
{
|
2011-03-29 19:21:57 +00:00
|
|
|
// We have a static wstring here so we can keep a copy of the string
|
2010-12-12 17:08:36 +00:00
|
|
|
// passed in alive while its being passed around.
|
|
|
|
// This isn't exactly safe, but we shouldn't really have to worry as
|
|
|
|
// Rainmeter isn't threaded.
|
2011-02-15 13:22:19 +00:00
|
|
|
static std::wstring str;
|
2011-01-30 13:04:17 +00:00
|
|
|
str = ConvertToWide(lua_tostring(L,arg));
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2010-12-12 17:08:36 +00:00
|
|
|
return str.c_str();
|
|
|
|
}
|
|
|
|
|
2011-01-30 13:04:17 +00:00
|
|
|
int is_wstring(lua_State* L, int lo, const char* type, int def, tolua_Error* err)
|
2010-12-12 17:08:36 +00:00
|
|
|
{
|
|
|
|
return is_wchar(L,lo,type,def,err);
|
|
|
|
}
|
|
|
|
|
2011-01-30 13:04:17 +00:00
|
|
|
int is_wchar(lua_State* L, int lo, const char* type, int def, tolua_Error* err)
|
2010-12-12 17:08:36 +00:00
|
|
|
{
|
|
|
|
if (def && lua_gettop(L)<abs(lo))
|
|
|
|
return 1;
|
|
|
|
if (lua_isnil(L,lo) || lua_isstring(L,lo))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
err->index = lo;
|
|
|
|
err->array = 0;
|
|
|
|
err->type = type;
|
|
|
|
return 0;
|
2011-07-05 13:41:05 +00:00
|
|
|
}
|