| 110 | } |
| 111 | |
| 112 | int |
| 113 | ts_lua_create_vm(ts_lua_main_ctx *arr, int n) |
| 114 | { |
| 115 | int i; |
| 116 | lua_State *L; |
| 117 | |
| 118 | for (i = 0; i < n; i++) { |
| 119 | L = ts_lua_new_state(); |
| 120 | |
| 121 | if (L == nullptr) |
| 122 | return -1; |
| 123 | |
| 124 | lua_pushvalue(L, LUA_GLOBALSINDEX); |
| 125 | |
| 126 | arr[i].gref = luaL_ref(L, LUA_REGISTRYINDEX); /* L[REG][gref] = L[GLOBAL] */ |
| 127 | arr[i].lua = L; |
| 128 | arr[i].mutexp = TSMutexCreate(); |
| 129 | arr[i].stats = ts_lua_create_ctx_stats(); |
| 130 | } |
| 131 | |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | void |
| 136 | ts_lua_destroy_vm(ts_lua_main_ctx *arr, int n) |
no test coverage detected