Implicitly redirect cmdhelp includes to corresponding JSON files
[lsnes.git] / src / library / lua-framebuffer.cpp
blobb00490789624d7cd4a37ba34ddf0791be7259fc6
1 #include "lua-base.hpp"
2 #include "framebuffer.hpp"
3 #include "lua-framebuffer.hpp"
5 namespace lua
7 framebuffer::color get_fb_color(lua::state& L, int index, const std::string& fname) throw(std::bad_alloc,
8 std::runtime_error)
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()));
14 else
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);
29 else
30 (stringfmt() << "Expected argument #" << index << " to " << fname
31 << " be string, number or nil").throwex();
32 return 0; //NOTREACHED