47 if(!lua_isnumber(L, index))
48 UG_THROW(
"ReturnValueToNumber: Data passed from Lua: "
49 "Can't convert return value to number!");
50 number a = lua_tonumber(L, index);
59 if(!lua_isboolean(L, index))
60 UG_THROW(
"ReturnValueToBool: Data passed from Lua: "
61 "Can't convert return value to boolean!");
63 return lua_toboolean(L, index);
69 if(!lua_isnumber(L, index))
70 UG_THROW(
"ReturnValueToBool: Data passed from Lua: "
71 "Can't convert return value to integer!");
73 return lua_tointeger(L, index);
78 template <
typename TData>
84 static const int size = 0;
108 static const int size = 1;
112 lua_pushboolean(L, b);
122 return lua_isboolean(L, index);
141 static const int size = 1;
145 lua_pushinteger(L, c);
155 return lua_isnumber(L, index);
172 static const int size = 1;
176 lua_pushnumber(L, c);
195 return lua_isnumber(L, index);
209 template <std::
size_t dim>
212 static const int size =
dim;
216 for(
size_t i = 0; i <
dim; ++i)
217 lua_pushnumber(L, x[i]);
222 for(
size_t i = 0; i <
dim; ++i){
229 for(
size_t i=0; i<
dim; i++)
235 for(
size_t i=0; i<
dim; i++)
241 for(
size_t i = 0; i <
dim; ++i){
242 if(!lua_isnumber(L, index--))
return false;
249 static char cmp[] = {
'x',
'y',
'z'};
250 std::stringstream ss;
251 for(
size_t i = 0; i <
dim; ++i){
252 if(i != 0) ss <<
", ";
260 std::stringstream ss;
267 template <std::
size_t dim>
274 for(
size_t i = 0; i <
dim; ++i){
275 for(
size_t j = 0; j <
dim; ++j){
276 lua_pushnumber(L, D[i][j]);
284 for(
size_t i = 0; i <
dim; ++i){
285 for(
size_t j = 0; j <
dim; ++j){
293 for(
size_t i = 0; i <
dim; ++i){
294 for(
size_t j = 0; j <
dim; ++j){
295 D[i][j] = ret[i*
dim+j+1];
301 for(
size_t i = 0; i <
dim; ++i){
302 for(
size_t j = 0; j <
dim; ++j){
303 D[i][j] = ret[i*
dim+j];
310 for(
size_t i = 0; i <
dim; ++i){
311 for(
size_t j = 0; j <
dim; ++j){
312 if(!lua_isnumber(L, index--))
return false;
320 static char cmp[] = {
'x',
'y',
'z'};
321 std::stringstream ss;
322 for(
size_t i = 0; i <
dim; ++i){
323 for(
size_t j = 0; j <
dim; ++j){
324 if(i != 0 || j != 0) ss <<
", ";
325 ss <<
"D" << cmp[i] << cmp[j];
333 std::stringstream ss;
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
a mathematical Vector with N entries.
Definition: math_vector.h:97
#define UG_THROW(msg)
Definition: error.h:57
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
double number
Definition: types.h:124
struct lua_State lua_State
Definition: lua_table_handle.h:40
int ReturnValueToInteger(lua_State *L, int index)
Helper to access a return value on the stack.
Definition: lua_traits.h:68
number ReturnValueToBool(lua_State *L, int index)
Helper to access a return value on the stack.
Definition: lua_traits.h:58
bool IsFiniteAndNotTooBig(double d)
Definition: number_util.h:39
number ReturnValueToNumber(lua_State *L, int index)
Helper to access a return value on the stack.
Definition: lua_traits.h:46
static void read(MathMatrix< dim, dim > &D, const double ret[size], bool *dummy)
Definition: lua_traits.h:291
static bool check(lua_State *L, int index=-1)
Definition: lua_traits.h:308
static void push(lua_State *L, const MathMatrix< dim, dim > &D)
Definition: lua_traits.h:272
static std::string signature()
Definition: lua_traits.h:318
static std::string name()
Definition: lua_traits.h:331
static void read(MathMatrix< dim, dim > &D, const double ret[size], void *dummy)
Definition: lua_traits.h:299
static void read(lua_State *L, MathMatrix< dim, dim > &D, int index=-1)
Definition: lua_traits.h:282
static std::string signature()
Definition: lua_traits.h:127
static bool check(lua_State *L, int index=-1)
Definition: lua_traits.h:120
static std::string name()
Definition: lua_traits.h:132
static void push(lua_State *L, const bool &b)
Definition: lua_traits.h:110
static void read(lua_State *L, bool &b, int index=-1)
Definition: lua_traits.h:115
static bool do_return(const bool &b)
Definition: lua_traits.h:125
static bool check(lua_State *L, int index=-1)
Definition: lua_traits.h:153
static std::string signature()
Definition: lua_traits.h:158
static void read(lua_State *L, int &c, int index=-1)
Definition: lua_traits.h:148
static std::string name()
Definition: lua_traits.h:163
static void push(lua_State *L, const int &c)
Definition: lua_traits.h:143
static void read(number &c, double ret[1], bool *dummy)
Definition: lua_traits.h:184
static void push(lua_State *L, const number &c)
Definition: lua_traits.h:174
static bool check(lua_State *L, int index=-1)
Definition: lua_traits.h:193
static void read(number &c, double ret[1], void *dummy)
Definition: lua_traits.h:188
static std::string name()
Definition: lua_traits.h:203
static std::string signature()
Definition: lua_traits.h:198
static void read(lua_State *L, number &c, int index=-1)
Definition: lua_traits.h:179
static void read(MathVector< dim > &x, const double ret[dim], void *dummy)
Definition: lua_traits.h:233
static void push(lua_State *L, const MathVector< dim > &x)
Definition: lua_traits.h:214
static void read(lua_State *L, MathVector< dim > &x, int index=-1)
Definition: lua_traits.h:220
static void read(MathVector< dim > &x, const double ret[dim], bool *dummy)
Definition: lua_traits.h:227
static std::string name()
Definition: lua_traits.h:258
static std::string signature()
Definition: lua_traits.h:247
static bool check(lua_State *L, int index=-1)
Definition: lua_traits.h:239
static std::string signature()
Definition: lua_traits.h:94
static bool check(lua_State *L, int index=-1)
Definition: lua_traits.h:92
static void push(lua_State *L, const bool &)
Definition: lua_traits.h:86
static void do_return(const bool &)
Definition: lua_traits.h:90
static void read(lua_State *L, bool &, int index=-1)
Definition: lua_traits.h:88
static std::string name()
Definition: lua_traits.h:99
Lua Traits to push/pop on lua stack.
Definition: lua_traits.h:79