From acd720e249885d0a27092195165bece01c166e27 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Fri, 6 Jan 2012 18:42:28 -0200 Subject: [PATCH] add missing lua casts --- src/framework/luascript/luavaluecasts.cpp | 29 ----------------------- src/framework/luascript/luavaluecasts.h | 28 ++++++++++++++++------ 2 files changed, 21 insertions(+), 36 deletions(-) diff --git a/src/framework/luascript/luavaluecasts.cpp b/src/framework/luascript/luavaluecasts.cpp index caefde52..a23083cd 100644 --- a/src/framework/luascript/luavaluecasts.cpp +++ b/src/framework/luascript/luavaluecasts.cpp @@ -50,21 +50,6 @@ bool luavalue_cast(int index, int& i) return true; } -// uint -void push_luavalue(uint v) -{ - push_luavalue((double)v); -} - -bool luavalue_cast(int index, uint& v) -{ - double d; - bool ret = luavalue_cast(index, d); - v = (uint32)d; - return ret; -} - - // double void push_luavalue(double d) { @@ -79,20 +64,6 @@ bool luavalue_cast(int index, double& d) return true; } -// size_t -void push_luavalue(std::size_t s) -{ - push_luavalue((double)s); -} - -bool luavalue_cast(int index, std::size_t& s) -{ - double d; - bool ret = luavalue_cast(index, d); - s = d; - return ret; -} - // string void push_luavalue(const char* cstr) { diff --git a/src/framework/luascript/luavaluecasts.h b/src/framework/luascript/luavaluecasts.h index 320b3f1b..f933d441 100644 --- a/src/framework/luascript/luavaluecasts.h +++ b/src/framework/luascript/luavaluecasts.h @@ -36,17 +36,31 @@ bool luavalue_cast(int index, bool& b); void push_luavalue(int i); bool luavalue_cast(int index, int& i); -// uint -void push_luavalue(uint v); -bool luavalue_cast(int index, uint& v); - // double void push_luavalue(double d); bool luavalue_cast(int index, double& d); -// size_t -void push_luavalue(std::size_t s); -bool luavalue_cast(int index, std::size_t& s); +// int8 +inline void push_luavalue(int8 v) { push_luavalue((int)v); } +inline bool luavalue_cast(int index, int8& v) { int i; bool r = luavalue_cast(index, i); v = i; return r; } +// uint8 +inline void push_luavalue(uint8 v) { push_luavalue((int)v); } +inline bool luavalue_cast(int index, uint8& v){ int i; bool r = luavalue_cast(index, i); v = i; return r; } +// int16 +inline void push_luavalue(int16 v) { push_luavalue((int)v); } +inline bool luavalue_cast(int index, int16& v){ int i; bool r = luavalue_cast(index, i); v = i; return r; } +// uint16 +inline void push_luavalue(uint16 v) { push_luavalue((int)v); } +inline bool luavalue_cast(int index, uint16& v){ int i; bool r = luavalue_cast(index, i); v = i; return r; } +// uint32 +inline void push_luavalue(uint32 v) { push_luavalue((double)v); } +inline bool luavalue_cast(int index, uint32& v) { double d; bool r = luavalue_cast(index, d); v = d; return r; } +// int64 +inline void push_luavalue(int64 v) { push_luavalue((double)v); } +inline bool luavalue_cast(int index, int64& v) { double d; bool r = luavalue_cast(index, d); v = d; return r; } +// uint64 +inline void push_luavalue(uint64 v) { push_luavalue((double)v); } +inline bool luavalue_cast(int index, uint64& v) { double d; bool r = luavalue_cast(index, d); v = d; return r; } // string void push_luavalue(const char* cstr);