Some tweaks to Lua docs
[lsnes.git] / src / library / lua-framebuffer.cpp
blobca00f37066ed4dbc3e69754f359f28c33759bfd9
1 #include "lua-base.hpp"
2 #include "framebuffer.hpp"
3 #include "lua-framebuffer.hpp"
5 framebuffer::color lua_get_fb_color(lua::state& L, int index, const std::string& fname) throw(std::bad_alloc,
6 std::runtime_error)
8 if(L.type(index) == LUA_TSTRING)
9 return framebuffer::color(L.get_string(index, fname.c_str()));
10 else if(L.type(index) == LUA_TNUMBER)
11 return framebuffer::color(L.get_numeric_argument<int64_t>(index, fname.c_str()));
12 else
13 (stringfmt() << "Expected argument #" << index << " to " << fname
14 << " be string or number").throwex();
17 framebuffer::color lua_get_fb_color(lua::state& L, int index, const std::string& fname, int64_t dflt)
18 throw(std::bad_alloc, std::runtime_error)
20 if(L.type(index) == LUA_TSTRING)
21 return framebuffer::color(L.get_string(index, fname.c_str()));
22 else if(L.type(index) == LUA_TNUMBER)
23 return framebuffer::color(L.get_numeric_argument<int64_t>(index, fname.c_str()));
24 else if(L.type(index) == LUA_TNIL || L.type(index) == LUA_TNONE)
25 return framebuffer::color(dflt);
26 else
27 (stringfmt() << "Expected argument #" << index << " to " << fname
28 << " be string, number or nil").throwex();