1 #include "lua-base.hpp"
2 #include "framebuffer.hpp"
3 #include "lua-framebuffer.hpp"
7 framebuffer::color
get_fb_color(lua::state
& L
, int index
, const std::string
& fname
) throw(std::bad_alloc
,
10 if(L
.type(index
) == LUA_TSTRING
)
11 return framebuffer::color(L
.get_string(index
, fname
.c_str()));
12 else if(L
.type(index
) == LUA_TNUMBER
)
13 return framebuffer::color(L
.get_numeric_argument
<int64_t>(index
, fname
.c_str()));
15 (stringfmt() << "Expected argument #" << index
<< " to " << fname
16 << " be string or number").throwex();
17 return 0; //NOTREACHED
20 framebuffer::color
get_fb_color(lua::state
& L
, int index
, const std::string
& fname
, int64_t dflt
)
21 throw(std::bad_alloc
, std::runtime_error
)
23 if(L
.type(index
) == LUA_TSTRING
)
24 return framebuffer::color(L
.get_string(index
, fname
.c_str()));
25 else if(L
.type(index
) == LUA_TNUMBER
)
26 return framebuffer::color(L
.get_numeric_argument
<int64_t>(index
, fname
.c_str()));
27 else if(L
.type(index
) == LUA_TNIL
|| L
.type(index
) == LUA_TNONE
)
28 return framebuffer::color(dflt
);
30 (stringfmt() << "Expected argument #" << index
<< " to " << fname
31 << " be string, number or nil").throwex();
32 return 0; //NOTREACHED