Added the getString method to all Data objects (issue #608)

This commit is contained in:
Alex Szpakowski
2013-04-26 22:35:01 -07:00
parent 16f3a93f28
commit fb9f8d2962
8 changed files with 73 additions and 12 deletions
+8
View File
@@ -28,6 +28,13 @@ Data *luax_checkdata(lua_State *L, int idx)
return luax_checktype<Data>(L, idx, "Data", DATA_T);
}
int w_Data_getString(lua_State *L)
{
Data *t = luax_checkdata(L, 1);
lua_pushlstring(L, (const char *) t->getData(), (size_t) t->getSize());
return 1;
}
int w_Data_getSize(lua_State *L)
{
Data *t = luax_checkdata(L, 1);
@@ -37,6 +44,7 @@ int w_Data_getSize(lua_State *L)
const luaL_Reg w_Data_functions[] =
{
{ "getString", w_Data_getString },
{ "getSize", w_Data_getSize },
{ 0, 0 }
};