|
@@ -140,38 +140,38 @@ lua_shared_exchange(struct lua_State *L)
|
|
static int
|
|
static int
|
|
lua_shared_push(struct lua_State *L)
|
|
lua_shared_push(struct lua_State *L)
|
|
{
|
|
{
|
|
- int val_type = lua_type(L, 1);
|
|
|
|
|
|
+ int val_type = lua_type(L, 1);
|
|
|
|
|
|
- if ((val_type != LUA_TNUMBER) && (val_type != LUA_TSTRING)
|
|
|
|
- && (val_type != LUA_TBOOLEAN)) {
|
|
|
|
- return luaL_error(L, "shared value must be string, number or boolean");
|
|
|
|
- }
|
|
|
|
|
|
+ if ((val_type != LUA_TNUMBER) && (val_type != LUA_TSTRING)
|
|
|
|
+ && (val_type != LUA_TBOOLEAN)) {
|
|
|
|
+ return luaL_error(L, "shared value must be string, number or boolean");
|
|
|
|
+ }
|
|
|
|
|
|
- pthread_mutex_lock(&lua_shared_lock);
|
|
|
|
|
|
+ pthread_mutex_lock(&lua_shared_lock);
|
|
|
|
|
|
- lua_getglobal(L_shared, "shared");
|
|
|
|
- lua_pushnumber(L_shared, num);
|
|
|
|
|
|
+ lua_getglobal(L_shared, "shared");
|
|
|
|
+ lua_pushnumber(L_shared, num);
|
|
|
|
|
|
- if (val_type == LUA_TNUMBER) {
|
|
|
|
- double num = lua_tonumber(L, 3);
|
|
|
|
- lua_pushnumber(L_shared, num);
|
|
|
|
|
|
+ if (val_type == LUA_TNUMBER) {
|
|
|
|
+ double num = lua_tonumber(L, 3);
|
|
|
|
+ lua_pushnumber(L_shared, num);
|
|
|
|
|
|
- } else if (val_type == LUA_TBOOLEAN) {
|
|
|
|
- int i = lua_toboolean(L, 3);
|
|
|
|
- lua_pushboolean(L_shared, i);
|
|
|
|
|
|
+ } else if (val_type == LUA_TBOOLEAN) {
|
|
|
|
+ int i = lua_toboolean(L, 3);
|
|
|
|
+ lua_pushboolean(L_shared, i);
|
|
|
|
|
|
- } else {
|
|
|
|
- size_t len = 0;
|
|
|
|
- const char *str = lua_tolstring(L, 3, &len);
|
|
|
|
- lua_pushlstring(L_shared, str, len);
|
|
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ size_t len = 0;
|
|
|
|
+ const char *str = lua_tolstring(L, 3, &len);
|
|
|
|
+ lua_pushlstring(L_shared, str, len);
|
|
|
|
+ }
|
|
|
|
|
|
- lua_rawset(L_shared, -3);
|
|
|
|
- lua_pop(L_shared, 1);
|
|
|
|
|
|
+ lua_rawset(L_shared, -3);
|
|
|
|
+ lua_pop(L_shared, 1);
|
|
|
|
|
|
- pthread_mutex_unlock(&lua_shared_lock);
|
|
|
|
|
|
+ pthread_mutex_unlock(&lua_shared_lock);
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
*/
|
|
*/
|
|
#endif
|
|
#endif
|
|
@@ -219,12 +219,12 @@ lua_shared_index(struct lua_State *L)
|
|
lua_pushcclosure(L, lua_shared_dec, 0);
|
|
lua_pushcclosure(L, lua_shared_dec, 0);
|
|
} else if (0 == strcmp(str, "__exchange")) {
|
|
} else if (0 == strcmp(str, "__exchange")) {
|
|
lua_pushcclosure(L, lua_shared_exchange, 0);
|
|
lua_pushcclosure(L, lua_shared_exchange, 0);
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
} else if (0 == strcmp(str, "__push")) {
|
|
} else if (0 == strcmp(str, "__push")) {
|
|
lua_pushcclosure(L, lua_shared_push, 0);
|
|
lua_pushcclosure(L, lua_shared_push, 0);
|
|
} else if (0 == strcmp(str, "__pop")) {
|
|
} else if (0 == strcmp(str, "__pop")) {
|
|
lua_pushcclosure(L, lua_shared_pop, 0);
|
|
lua_pushcclosure(L, lua_shared_pop, 0);
|
|
- */
|
|
|
|
|
|
+ */
|
|
} else
|
|
} else
|
|
#endif
|
|
#endif
|
|
{
|
|
{
|