static int increment_by(lua_State* L);
static int IndexClosure(lua_State* L) {
- const auto map = reinterpret_cast<BackgroundMap*>(lua_touserdata(L, lua_upvalueindex(1)));
- auto& mtx = *reinterpret_cast<std::mutex*>(lua_touserdata(L, lua_upvalueindex(2)));
+ const auto map = reinterpret_cast<BackgroundMap*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
+ auto& mtx = *reinterpret_cast<std::mutex*>(lua_touserdata(L, lua_upvalueindex(SECOND_UPVAL)));
const char* index = luaL_checkstring(L, 2);
if (strcasecmp(index, INCREMENT) == 0) {
}
static int LenClosure(lua_State* L) {
- auto& mtx = *reinterpret_cast<std::mutex*>(lua_touserdata(L, lua_upvalueindex(2)));
- const auto map = reinterpret_cast<BackgroundMap*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto map = reinterpret_cast<BackgroundMap*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
+ auto& mtx = *reinterpret_cast<std::mutex*>(lua_touserdata(L, lua_upvalueindex(SECOND_UPVAL)));
std::lock_guard l(mtx);
}
static int NewIndexClosure(lua_State* L) {
- auto& mtx = *reinterpret_cast<std::mutex*>(lua_touserdata(L, lua_upvalueindex(2)));
- const auto map = reinterpret_cast<BackgroundMap*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto map = reinterpret_cast<BackgroundMap*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
+ auto& mtx = *reinterpret_cast<std::mutex*>(lua_touserdata(L, lua_upvalueindex(SECOND_UPVAL)));
const auto index = luaL_checkstring(L, 2);
if (strcasecmp(index, INCREMENT) == 0 || strcasecmp(index, DECREMENT) == 0) {
}
static int PairsClosure(lua_State* L) {
- auto map = reinterpret_cast<BackgroundMap*>(lua_touserdata(L, lua_upvalueindex(1)));
+ auto map = reinterpret_cast<BackgroundMap*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
ceph_assert(map);
lua_pushlightuserdata(L, map);
lua_pushcclosure(L, stateless_iter, ONE_UPVAL); // push the stateless iterator function
static int stateless_iter(lua_State* L) {
// based on: http://lua-users.org/wiki/GeneralizedPairsAndIpairs
- auto map = reinterpret_cast<BackgroundMap*>(lua_touserdata(L, lua_upvalueindex(1)));
+ auto map = reinterpret_cast<BackgroundMap*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
typename BackgroundMap::const_iterator next_it;
if (lua_isnil(L, -1)) {
next_it = map->begin();
int RequestLog(lua_State* L)
{
- const auto rest = reinterpret_cast<RGWREST*>(lua_touserdata(L, lua_upvalueindex(1)));
- const auto olog = reinterpret_cast<OpsLogSink*>(lua_touserdata(L, lua_upvalueindex(2)));
- const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(3)));
- const std::string op_name(reinterpret_cast<const char*>(lua_touserdata(L, lua_upvalueindex(4))));
+ const auto rest = reinterpret_cast<RGWREST*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
+ const auto olog = reinterpret_cast<OpsLogSink*>(lua_touserdata(L, lua_upvalueindex(SECOND_UPVAL)));
+ const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(THIRD_UPVAL)));
+ const std::string op_name(reinterpret_cast<const char*>(lua_touserdata(L, lua_upvalueindex(FOURTH_UPVAL))));
if (s) {
const auto rc = rgw_log_op(rest, s, op_name, olog);
lua_pushinteger(L, rc);
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto err = reinterpret_cast<const rgw_err*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto err = reinterpret_cast<const rgw_err*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
}
static int NewIndexClosure(lua_State* L) {
- auto err = reinterpret_cast<rgw_err*>(lua_touserdata(L, lua_upvalueindex(1)));
+ auto err = reinterpret_cast<rgw_err*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto info = reinterpret_cast<RGWQuotaInfo*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto info = reinterpret_cast<RGWQuotaInfo*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto rule = reinterpret_cast<rgw_placement_rule*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto rule = reinterpret_cast<rgw_placement_rule*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto user = reinterpret_cast<const rgw_user*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto user = reinterpret_cast<const rgw_user*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
}
static int NewIndexClosure(lua_State* L) {
- const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto owner = reinterpret_cast<ACLOwner*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto owner = reinterpret_cast<ACLOwner*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const auto bucket = s->bucket.get();
const char* index = luaL_checkstring(L, 2);
using Type = rgw::sal::Object;
static int IndexClosure(lua_State* L) {
- const auto obj = reinterpret_cast<const Type*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto obj = reinterpret_cast<const Type*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto grant = reinterpret_cast<ACLGrant*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto grant = reinterpret_cast<ACLGrant*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto map = reinterpret_cast<ACLGrantMap*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto map = reinterpret_cast<ACLGrantMap*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
}
static int PairsClosure(lua_State* L) {
- auto map = reinterpret_cast<ACLGrantMap*>(lua_touserdata(L, lua_upvalueindex(1)));
+ auto map = reinterpret_cast<ACLGrantMap*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
ceph_assert(map);
lua_pushlightuserdata(L, map);
lua_pushcclosure(L, stateless_iter, ONE_UPVAL); // push the stateless iterator function
static int stateless_iter(lua_State* L) {
// based on: http://lua-users.org/wiki/GeneralizedPairsAndIpairs
- auto map = reinterpret_cast<ACLGrantMap*>(lua_touserdata(L, lua_upvalueindex(1)));
+ auto map = reinterpret_cast<ACLGrantMap*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
ACLGrantMap::iterator next_it;
if (lua_isnil(L, -1)) {
next_it = map->begin();
}
static int LenClosure(lua_State* L) {
- const auto map = reinterpret_cast<ACLGrantMap*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto map = reinterpret_cast<ACLGrantMap*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
lua_pushinteger(L, map->size());
using Type = RGWAccessControlPolicy;
static int IndexClosure(lua_State* L) {
- const auto acl = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto acl = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
}
static int IndexClosure(lua_State* L) {
- const auto statements = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto statements = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const auto index = luaL_checkinteger(L, 2);
}
static int PairsClosure(lua_State* L) {
- auto statements = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(1)));
+ auto statements = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
ceph_assert(statements);
lua_pushlightuserdata(L, statements);
lua_pushcclosure(L, stateless_iter, ONE_UPVAL); // push the stateless iterator function
}
static int stateless_iter(lua_State* L) {
- auto statements = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(1)));
+ auto statements = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
size_t next_it;
if (lua_isnil(L, -1)) {
next_it = 0;
}
static int LenClosure(lua_State* L) {
- const auto statements = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto statements = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
lua_pushinteger(L, statements->size());
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto policy = reinterpret_cast<rgw::IAM::Policy*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto policy = reinterpret_cast<rgw::IAM::Policy*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
using Type = std::vector<rgw::IAM::Policy>;
static int IndexClosure(lua_State* L) {
- const auto policies = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto policies = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const auto index = luaL_checkinteger(L, 2);
}
static int PairsClosure(lua_State* L) {
- auto policies = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(1)));
+ auto policies = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
ceph_assert(policies);
lua_pushlightuserdata(L, policies);
lua_pushcclosure(L, stateless_iter, ONE_UPVAL); // push the stateless iterator function
}
static int stateless_iter(lua_State* L) {
- auto policies = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(1)));
+ auto policies = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
size_t next_it;
if (lua_isnil(L, -1)) {
next_it = 0;
}
static int LenClosure(lua_State* L) {
- const auto policies = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto policies = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
lua_pushinteger(L, policies->size());
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto info = reinterpret_cast<req_info*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto info = reinterpret_cast<req_info*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
}
static int NewIndexClosure(lua_State* L) {
- auto info = reinterpret_cast<req_info*>(lua_touserdata(L, lua_upvalueindex(1)));
+ auto info = reinterpret_cast<req_info*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
// __index closure that expect req_state to be captured
static int IndexClosure(lua_State* L) {
- const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(1)));
- const auto op_name = reinterpret_cast<const char*>(lua_touserdata(L, lua_upvalueindex(2)));
+ const auto s = reinterpret_cast<req_state*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
+ const auto op_name = reinterpret_cast<const char*>(lua_touserdata(L, lua_upvalueindex(SECOND_UPVAL)));
const char* index = luaL_checkstring(L, 2);
constexpr auto FOUR_UPVALS = 4;
constexpr auto FIVE_UPVALS = 5;
+constexpr auto FIRST_UPVAL = 1;
+constexpr auto SECOND_UPVAL = 2;
+constexpr auto THIRD_UPVAL = 3;
+constexpr auto FOURTH_UPVAL = 4;
+constexpr auto FIFTH_UPVAL = 5;
+
constexpr auto NO_RETURNVAL = 0;
constexpr auto ONE_RETURNVAL = 1;
constexpr auto TWO_RETURNVALS = 2;
// using Type = MyStruct;
//
// static int IndexClosure(lua_State* L) {
-// const auto value = reinterpret_cast<const Type*>(lua_touserdata(L, lua_upvalueindex(1)));
+// const auto value = reinterpret_cast<const Type*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
// ...
// }
// static int NewIndexClosure(lua_State* L) {
-// auto value = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(1)));
+// auto value = reinterpret_cast<Type*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
// ...
// }
// };
template<typename MapType=std::map<std::string, std::string>>
int StringMapWriteableNewIndex(lua_State* L) {
- const auto map = reinterpret_cast<MapType*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto map = reinterpret_cast<MapType*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
static std::string Name() {return TableName() + "Meta";}
static int IndexClosure(lua_State* L) {
- const auto map = reinterpret_cast<MapType*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto map = reinterpret_cast<MapType*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
const char* index = luaL_checkstring(L, 2);
}
static int PairsClosure(lua_State* L) {
- auto map = reinterpret_cast<MapType*>(lua_touserdata(L, lua_upvalueindex(1)));
+ auto map = reinterpret_cast<MapType*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
ceph_assert(map);
lua_pushlightuserdata(L, map);
lua_pushcclosure(L, stateless_iter, ONE_UPVAL); // push the stateless iterator function
static int stateless_iter(lua_State* L) {
// based on: http://lua-users.org/wiki/GeneralizedPairsAndIpairs
- auto map = reinterpret_cast<MapType*>(lua_touserdata(L, lua_upvalueindex(1)));
+ auto map = reinterpret_cast<MapType*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
typename MapType::const_iterator next_it;
if (lua_isnil(L, -1)) {
next_it = map->begin();
}
static int LenClosure(lua_State* L) {
- const auto map = reinterpret_cast<MapType*>(lua_touserdata(L, lua_upvalueindex(1)));
+ const auto map = reinterpret_cast<MapType*>(lua_touserdata(L, lua_upvalueindex(FIRST_UPVAL)));
lua_pushinteger(L, map->size());