Skip to content
Snippets Groups Projects
Commit 3eb7a332 authored by Nicolas Marsic's avatar Nicolas Marsic
Browse files

LuaFunctionSpace: add __tostring function

parent 78931fd9
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,7 @@ const struct luaL_Reg libsf_FunctionSpace_f[] = { ...@@ -20,6 +20,7 @@ const struct luaL_Reg libsf_FunctionSpace_f[] = {
}; };
const struct luaL_Reg libsf_FunctionSpace_m[] = { const struct luaL_Reg libsf_FunctionSpace_m[] = {
{"__tostring", lua_FunctionSpace_toString},
{"__gc", lua_FunctionSpace_delete}, {"__gc", lua_FunctionSpace_delete},
{NULL, NULL} {NULL, NULL}
}; };
...@@ -136,4 +137,19 @@ int lua_FunctionSpace_delete(lua_State *L){ ...@@ -136,4 +137,19 @@ int lua_FunctionSpace_delete(lua_State *L){
return 0; return 0;
} }
int lua_FunctionSpace_toString(lua_State *L){
FunctionSpace **lua =
(FunctionSpace**)luaL_checkudata(L, 1, "sf.FunctionSpace");
lua_pushstring(L, lua_FunctionSpace_toString(*lua).c_str());
return 1;
}
string lua_FunctionSpace_toString(FunctionSpace *fs){
stringstream str;
str << "Function space: " << fs;
return str.str();
}
#endif #endif
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "SmallFemConfig.h" #include "SmallFemConfig.h"
#ifdef HAVE_LUA #ifdef HAVE_LUA
#include "FunctionSpace.h"
extern "C"{ extern "C"{
#include "lua.h" #include "lua.h"
} }
...@@ -13,5 +14,8 @@ extern "C" int luaopen_libsf_functionspace(lua_State *L); ...@@ -13,5 +14,8 @@ extern "C" int luaopen_libsf_functionspace(lua_State *L);
int lua_FunctionSpace_new(lua_State *L); int lua_FunctionSpace_new(lua_State *L);
int lua_FunctionSpace_delete(lua_State *L); int lua_FunctionSpace_delete(lua_State *L);
int lua_FunctionSpace_toString(lua_State *L);
std::string lua_FunctionSpace_toString(sf::FunctionSpace *fs);
#endif #endif
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment