mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-06 19:00:27 +08:00
AP_Scripting: Boxed numerics and maunal bindings use generated arg checker
This commit is contained in:
committed by
Andrew Tridgell
parent
63db93c6d7
commit
2c8a11885f
@@ -50,12 +50,7 @@ int lua_new_uint32_t(lua_State *L) {
|
||||
|
||||
#define UINT32_T_BOX_OP(name, sym) \
|
||||
int uint32_t___##name(lua_State *L) { \
|
||||
const int args = lua_gettop(L); \
|
||||
if (args > 2) { \
|
||||
return luaL_argerror(L, args, "too many arguments"); \
|
||||
} else if (args < 2) { \
|
||||
return luaL_argerror(L, args, "too few arguments"); \
|
||||
} \
|
||||
binding_argcheck(L, 2); \
|
||||
\
|
||||
uint32_t v1 = coerce_to_uint32_t(L, 1); \
|
||||
uint32_t v2 = coerce_to_uint32_t(L, 2); \
|
||||
@@ -79,13 +74,7 @@ UINT32_T_BOX_OP(shr, >>)
|
||||
|
||||
#define UINT32_T_BOX_OP_BOOL(name, sym) \
|
||||
int uint32_t___##name(lua_State *L) { \
|
||||
const int args = lua_gettop(L); \
|
||||
luaL_checkstack(L, 1, "Out of stack"); \
|
||||
if (args > 2) { \
|
||||
return luaL_argerror(L, args, "too many arguments"); \
|
||||
} else if (args < 2) { \
|
||||
return luaL_argerror(L, args, "too few arguments"); \
|
||||
} \
|
||||
binding_argcheck(L, 2); \
|
||||
\
|
||||
uint32_t v1 = coerce_to_uint32_t(L, 1); \
|
||||
uint32_t v2 = coerce_to_uint32_t(L, 2); \
|
||||
@@ -100,11 +89,7 @@ UINT32_T_BOX_OP_BOOL(le, <=)
|
||||
|
||||
#define UINT32_T_BOX_OP_UNARY(name, sym) \
|
||||
int uint32_t___##name(lua_State *L) { \
|
||||
const int args = lua_gettop(L); \
|
||||
luaL_checkstack(L, 1, "Out of stack"); \
|
||||
if (args != 1) { \
|
||||
return luaL_argerror(L, args, "Expected 1 argument"); \
|
||||
} \
|
||||
binding_argcheck(L, 1); \
|
||||
\
|
||||
uint32_t v1 = coerce_to_uint32_t(L, 1); \
|
||||
\
|
||||
@@ -117,10 +102,7 @@ UINT32_T_BOX_OP_BOOL(le, <=)
|
||||
UINT32_T_BOX_OP_UNARY(bnot, ~)
|
||||
|
||||
int uint32_t_toint(lua_State *L) {
|
||||
const int args = lua_gettop(L);
|
||||
if (args != 1) {
|
||||
return luaL_argerror(L, args, "Expected 1 argument");
|
||||
}
|
||||
binding_argcheck(L, 1);
|
||||
|
||||
uint32_t v = *static_cast<uint32_t *>(luaL_checkudata(L, 1, "uint32_t"));
|
||||
|
||||
@@ -130,10 +112,7 @@ int uint32_t_toint(lua_State *L) {
|
||||
}
|
||||
|
||||
int uint32_t_tofloat(lua_State *L) {
|
||||
const int args = lua_gettop(L);
|
||||
if (args != 1) {
|
||||
return luaL_argerror(L, args, "Expected 1 argument");
|
||||
}
|
||||
binding_argcheck(L, 1);
|
||||
|
||||
uint32_t v = *static_cast<uint32_t *>(luaL_checkudata(L, 1, "uint32_t"));
|
||||
|
||||
@@ -143,10 +122,7 @@ int uint32_t_tofloat(lua_State *L) {
|
||||
}
|
||||
|
||||
int uint32_t___tostring(lua_State *L) {
|
||||
const int args = lua_gettop(L);
|
||||
if (args != 1) {
|
||||
return luaL_argerror(L, args, "Expected 1 argument");
|
||||
}
|
||||
binding_argcheck(L, 1);
|
||||
|
||||
uint32_t v = *static_cast<uint32_t *>(luaL_checkudata(L, 1, "uint32_t"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user