🐳chore(库): 调整submodule

develop
xiaojin 5 years ago
parent 7f57515820
commit b582805df0

3
.gitmodules vendored

@ -1,9 +1,6 @@
[submodule "code/framework/3rd/ffi-lua"] [submodule "code/framework/3rd/ffi-lua"]
path = code/framework/3rd/ffi-lua path = code/framework/3rd/ffi-lua
url = git@github.com:cloudfreexiao/cffi-lua.git url = git@github.com:cloudfreexiao/cffi-lua.git
[submodule "code/framework/3rd/goscon"]
path = code/framework/3rd/goscon
url = git@github.com:cloudfreexiao/goscon.git
[submodule "code/framework/3rd/glm"] [submodule "code/framework/3rd/glm"]
path = code/framework/3rd/glm path = code/framework/3rd/glm
url = git@github.com:g-truc/glm.git url = git@github.com:g-truc/glm.git

@ -1 +0,0 @@
Subproject commit 2d6546b99b7f42b53824fdd89a62780e94252a46

@ -10,6 +10,7 @@
#include "aoi.h" #include "aoi.h"
// https://github.com/ssnobin/c_lua_aoi // https://github.com/ssnobin/c_lua_aoi
// 非实时抛出事件lua层定时aoi_update获得aoi事件
#define GET_INTEGER(L, index, isnum) \ #define GET_INTEGER(L, index, isnum) \
(int)lua_tointegerx(L, index, &isnum); \ (int)lua_tointegerx(L, index, &isnum); \

File diff suppressed because it is too large Load Diff

@ -5,7 +5,8 @@
struct entity_world; struct entity_world;
struct ecs_capi { struct ecs_capi
{
void *(*iter)(struct entity_world *w, int cid, int index); void *(*iter)(struct entity_world *w, int cid, int index);
void (*clear_type)(struct entity_world *w, int cid); void (*clear_type)(struct entity_world *w, int cid);
int (*sibling_id)(struct entity_world *w, int cid, int index, int slibling_id); int (*sibling_id)(struct entity_world *w, int cid, int index, int slibling_id);
@ -18,7 +19,8 @@ struct ecs_capi {
int (*assign_lua)(struct entity_world *w, int cid, int index, void *L, int world_index); int (*assign_lua)(struct entity_world *w, int cid, int index, void *L, int world_index);
}; };
struct ecs_context { struct ecs_context
{
struct ecs_capi *api; struct ecs_capi *api;
struct entity_world *world; struct entity_world *world;
void *L; // for memory allocator void *L; // for memory allocator
@ -27,18 +29,21 @@ struct ecs_context {
}; };
static inline void static inline void
check_id_(struct ecs_context *ctx, int cid) { check_id_(struct ecs_context *ctx, int cid)
{
assert(cid >= 0 && cid <= ctx->max_id); assert(cid >= 0 && cid <= ctx->max_id);
} }
static inline void * static inline void *
entity_iter(struct ecs_context *ctx, int cid, int index) { entity_iter(struct ecs_context *ctx, int cid, int index)
{
check_id_(ctx, cid); check_id_(ctx, cid);
return ctx->api->iter(ctx->world, ctx->cid[cid], index); return ctx->api->iter(ctx->world, ctx->cid[cid], index);
} }
static inline void * static inline void *
entity_ref_object(struct ecs_context *ctx, int cid, int index) { entity_ref_object(struct ecs_context *ctx, int cid, int index)
{
if (index <= 0) if (index <= 0)
return NULL; return NULL;
check_id_(ctx, cid); check_id_(ctx, cid);
@ -46,90 +51,107 @@ entity_ref_object(struct ecs_context *ctx, int cid, int index) {
} }
static inline void static inline void
entity_clear_type(struct ecs_context *ctx, int cid) { entity_clear_type(struct ecs_context *ctx, int cid)
{
check_id_(ctx, cid); check_id_(ctx, cid);
ctx->api->clear_type(ctx->world, ctx->cid[cid]); ctx->api->clear_type(ctx->world, ctx->cid[cid]);
} }
static inline int static inline int
entity_sibling_id(struct ecs_context *ctx, int cid, int index, int sibling_id) { entity_sibling_id(struct ecs_context *ctx, int cid, int index, int sibling_id)
{
check_id_(ctx, cid); check_id_(ctx, cid);
check_id_(ctx, sibling_id); check_id_(ctx, sibling_id);
return ctx->api->sibling_id(ctx->world, ctx->cid[cid], index, ctx->cid[sibling_id]); return ctx->api->sibling_id(ctx->world, ctx->cid[cid], index, ctx->cid[sibling_id]);
} }
static inline void * static inline void *
entity_sibling(struct ecs_context *ctx, int cid, int index, int sibling_id) { entity_sibling(struct ecs_context *ctx, int cid, int index, int sibling_id)
{
check_id_(ctx, cid); check_id_(ctx, cid);
check_id_(ctx, sibling_id); check_id_(ctx, sibling_id);
int id = ctx->api->sibling_id(ctx->world, ctx->cid[cid], index, ctx->cid[sibling_id]); int id = ctx->api->sibling_id(ctx->world, ctx->cid[cid], index, ctx->cid[sibling_id]);
if (id == 0) { if (id == 0)
{
return NULL; return NULL;
} else { }
else
{
return ctx->api->iter(ctx->world, ctx->cid[sibling_id], id - 1); return ctx->api->iter(ctx->world, ctx->cid[sibling_id], id - 1);
} }
} }
static inline void * static inline void *
entity_add_sibling(struct ecs_context *ctx, int cid, int index, int sibling_id, const void *buffer) { entity_add_sibling(struct ecs_context *ctx, int cid, int index, int sibling_id, const void *buffer)
{
check_id_(ctx, cid); check_id_(ctx, cid);
check_id_(ctx, sibling_id); check_id_(ctx, sibling_id);
return ctx->api->add_sibling(ctx->world, ctx->cid[cid], index, ctx->cid[sibling_id], buffer, ctx->L, 1); return ctx->api->add_sibling(ctx->world, ctx->cid[cid], index, ctx->cid[sibling_id], buffer, ctx->L, 1);
} }
static inline int static inline int
entity_new(struct ecs_context *ctx, int cid, const void *buffer) { entity_new(struct ecs_context *ctx, int cid, const void *buffer)
{
check_id_(ctx, cid); check_id_(ctx, cid);
return ctx->api->new_entity(ctx->world, ctx->cid[cid], buffer, ctx->L, 1); return ctx->api->new_entity(ctx->world, ctx->cid[cid], buffer, ctx->L, 1);
} }
static inline void static inline void
entity_remove(struct ecs_context *ctx, int cid, int index) { entity_remove(struct ecs_context *ctx, int cid, int index)
{
check_id_(ctx, cid); check_id_(ctx, cid);
ctx->api->remove(ctx->world, ctx->cid[cid], index, ctx->L, 1); ctx->api->remove(ctx->world, ctx->cid[cid], index, ctx->L, 1);
} }
static inline void static inline void
entity_enable_tag(struct ecs_context *ctx, int cid, int index, int tag_id) { entity_enable_tag(struct ecs_context *ctx, int cid, int index, int tag_id)
{
check_id_(ctx, cid); check_id_(ctx, cid);
check_id_(ctx, tag_id); check_id_(ctx, tag_id);
ctx->api->enable_tag(ctx->world, ctx->cid[cid], index, ctx->cid[tag_id], ctx->L, 1); ctx->api->enable_tag(ctx->world, ctx->cid[cid], index, ctx->cid[tag_id], ctx->L, 1);
} }
static inline void static inline void
entity_disable_tag(struct ecs_context *ctx, int cid, int index, int tag_id) { entity_disable_tag(struct ecs_context *ctx, int cid, int index, int tag_id)
{
check_id_(ctx, cid); check_id_(ctx, cid);
check_id_(ctx, tag_id); check_id_(ctx, tag_id);
ctx->api->disable_tag(ctx->world, ctx->cid[cid], index, ctx->cid[tag_id]); ctx->api->disable_tag(ctx->world, ctx->cid[cid], index, ctx->cid[tag_id]);
} }
static inline int static inline int
entity_assign_lua(struct ecs_context *ctx, int cid, int index) { entity_assign_lua(struct ecs_context *ctx, int cid, int index)
{
check_id_(ctx, cid); check_id_(ctx, cid);
assert(index > 0); assert(index > 0);
return ctx->api->assign_lua(ctx->world, ctx->cid[cid], index - 1, ctx->L, 1); return ctx->api->assign_lua(ctx->world, ctx->cid[cid], index - 1, ctx->L, 1);
} }
static inline int static inline int
entity_new_ref(struct ecs_context *ctx, int cid) { entity_new_ref(struct ecs_context *ctx, int cid)
{
check_id_(ctx, cid); check_id_(ctx, cid);
int object_id = ctx->cid[cid]; int object_id = ctx->cid[cid];
int dead_tag = object_id + 1; int dead_tag = object_id + 1;
int id; int id;
if (ctx->api->iter(ctx->world, dead_tag, 0)) { if (ctx->api->iter(ctx->world, dead_tag, 0))
{
// reuse // reuse
id = ctx->api->sibling_id(ctx->world, dead_tag, 0, object_id); id = ctx->api->sibling_id(ctx->world, dead_tag, 0, object_id);
assert(id > 0); assert(id > 0);
--id; --id;
ctx->api->disable_tag(ctx->world, dead_tag, 0, dead_tag); ctx->api->disable_tag(ctx->world, dead_tag, 0, dead_tag);
} else { }
else
{
id = ctx->api->new_entity(ctx->world, object_id, NULL, ctx->L, 1); id = ctx->api->new_entity(ctx->world, object_id, NULL, ctx->L, 1);
} }
return id + 1; return id + 1;
} }
static inline void static inline void
entity_release_ref(struct ecs_context *ctx, int cid, int id) { entity_release_ref(struct ecs_context *ctx, int cid, int id)
{
if (id == 0) if (id == 0)
return; return;
check_id_(ctx, cid); check_id_(ctx, cid);

@ -218,7 +218,7 @@ w:register {
type = "float", type = "float",
} }
for v in w:select "vector:in sum:temp" do for v in w:select "vector:in sum:new" do
print(v.vector.x, "+", v.vector.y) print(v.vector.x, "+", v.vector.y)
v.sum = v.vector.x + v.vector.y v.sum = v.vector.x + v.vector.y
end end

@ -17,7 +17,7 @@ for i = 1, 10 do
end end
local function add_temp(i) local function add_temp(i)
for v in w:select "key:in temp?temp" do for v in w:select "key:in temp?new" do
if v.key == i then if v.key == i then
v.temp = "Temp" v.temp = "Temp"
end end

@ -18,11 +18,28 @@ w:new {
order = true, order = true,
} }
w:new {
node = { id = 2, parent = 0 },
order = true,
}
w:new { w:new {
node = { id = 0, parent = -1 }, node = { id = 0, parent = -1 },
}
w:new {
node = { id = 3, parent = 0 },
order = true, order = true,
} }
for v in w:select "node:in order?new" do
assert(v.order == nil)
if v.node.parent < 0 then
-- add order
v.order = true
end
end
local cache = {} local cache = {}
for v in w:select "order node:update" do for v in w:select "order node:update" do

@ -1,51 +1,31 @@
-- test sort
local ecs = require "ecs" local ecs = require "ecs"
local w = ecs.world() local w = ecs.world()
w:register { w:register {
name = "data", name = "value",
type = "float", type = "int",
} }
w:register { w:register {
name = "index", name = "mark"
type = "int",
} }
local tmp = { 10,9,8,7,6,5,4,3,2,1 } w:new {
value = 1,
for i = 1, 10, 2 do mark = true,
w:new { data = tmp[i], index = tmp[i] } }
w:new { index = tmp[i+1] }
end
w:update()
for v in w:select "index data?in" do
print(v.data)
end
w:sort("sort", "index")
print "sorted"
for v in w:select "sort data:in index:in" do
print(v.data, v.index)
end
w:register { w:new {
name = "sorted_index", mark = true,
type = "int",
} }
for i = 1, 10 do
w:new { data = i * 0.5 , sorted_index = i * 2 }
end
for v in w:select "sorted_index:in data?in" do for v in w:select "mark" do
print(v.sorted_index, "=>", v.data) w:sync("value?in", v)
print(v.value)
end end
--w:remove(iter) for v in w:select "mark" do
print(pcall(w.sync, w, "value:in", v))
end

@ -53,74 +53,3 @@ for v in w:select "index:in" do
print(v.index) print(v.index)
end end
print "Index refobject"
for v in w:select "refobject(index):in" do
print(v.refobject)
end
w:register {
name = "name",
type = "lua",
}
w:new {
name = "Hello"
}
for v in w:select "index:in" do
print(v.index)
end
for v in w:select "name refobject(index):temp" do
v.refobject = 42
end
for v in w:select "refobject:in" do
print(v.refobject)
end
for v in w:select "refobject(index):update" do
v.refobject = v.refobject + 1
end
for v in w:select "refobject:in" do
print(v.refobject)
end
w:register {
name = "mark"
}
local ref = w:object_ref("refobject", id4)
ref.mark = true
w:sync("mark?out", ref)
w:ref ("refobject", {
refobject = 42,
mark = true
})
print "Marked refobject"
for v in w:select "mark refobject?in" do
print(v.refobject)
end
w:register {
name = "refobject2",
type = "int",
ref = true,
}
w:register {
name = "mark2"
}
w:ref ("refobject2", {
refobject2 = 42,
mark = true,
mark2 = false,
})

@ -20,7 +20,7 @@ for v in w:select "a:in" do
if v.a %2 == 0 then if v.a %2 == 0 then
v.a = -v.a v.a = -v.a
v.temp = 42 v.temp = 42
w:sync("a:out temp:temp", v) w:sync("a:out temp:new", v)
end end
end end

@ -8,6 +8,10 @@ w:register {
"b:userdata", "b:userdata",
} }
w:register {
name = "flag",
}
w:new { w:new {
t = { t = {
a = false, a = false,
@ -36,3 +40,23 @@ print_v()
test.testuserdata(ctx) test.testuserdata(ctx)
print_v() print_v()
local v = w:singleton("t", "flag t:in")
assert(v == nil)
-- remove singleton of t
local v = w:singleton "t"
w:remove(v)
w:update()
w:new {
t = {
a = true,
b = ecs.NULL,
},
flag = true,
}
local v = w:singleton("t", "flag t:in")
assert(v.t.a == true)

File diff suppressed because it is too large Load Diff

@ -2,9 +2,36 @@ local ecs = require "ecs.core"
local REFERENCE_ID<const> = 1 local REFERENCE_ID<const> = 1
local rawerror = error
local selfsource<const> = debug.getinfo(1, "S").source
local function error(errmsg)
local level = 2
while true do
local info = debug.getinfo(level, "S")
if not info then
rawerror(errmsg, 2)
return
end
if selfsource ~= info.source then
rawerror(errmsg, level)
return
end
level = level + 1
end
end
local function assert(cond, errmsg)
if not cond then
error(errmsg or "assertion failed!")
end
return cond
end
local function get_attrib(opt, inout) local function get_attrib(opt, inout)
if opt == nil then if opt == nil then
return { exist = true } return {
exist = true,
}
end end
local desc = {} local desc = {}
if opt == "?" then if opt == "?" then
@ -26,7 +53,7 @@ local function get_attrib(opt, inout)
desc.absent = true desc.absent = true
assert(not desc.opt) assert(not desc.opt)
else else
assert(inout == "temp") assert(inout == "new")
end end
return desc return desc
end end
@ -80,20 +107,22 @@ local function cache_world(obj, k)
return desc return desc
end end
setmetatable(c, { __index = function(_, key) setmetatable(c, {
__index = function(_, key)
if key == "all" then if key == "all" then
local all = k:_groupiter(gen_all_pat()) local all = k:_groupiter(gen_all_pat())
c.all = all c.all = all
return all return all
end end
end }) end,
})
local function gen_select_pat(pat) local function gen_select_pat(pat)
local typenames = c.typenames local typenames = c.typenames
local desc = {} local desc = {}
local idx = 1 local idx = 1
for token in pat:gmatch "[^ ]+" do for token in pat:gmatch "[^ ]+" do
local key, index, padding = token:match "^([_%w]+)%(?([_%w]*)%)?(.*)" local key, padding = token:match "^([_%w]+)(.*)"
assert(key, "Invalid pattern") assert(key, "Invalid pattern")
local opt, inout local opt, inout
if padding ~= "" then if padding ~= "" then
@ -104,19 +133,6 @@ local function cache_world(obj, k)
if tc == nil then if tc == nil then
error("Unknown type " .. key) error("Unknown type " .. key)
end end
if index ~= "" then
local indexc = typenames[index]
if indexc == nil then
error("Unknown index type "..index)
end
local a = get_attrib(opt, inout == "temp" and "temp" or "in")
a.name = index
a.id = indexc.id
a.type = indexc.type
a.ref = true
desc[idx] = a
idx = idx + 1
end
local a = get_attrib(opt, inout) local a = get_attrib(opt, inout)
a.name = tc.name a.name = tc.name
a.id = tc.id a.id = tc.id
@ -127,7 +143,7 @@ local function cache_world(obj, k)
end end
desc[idx] = a desc[idx] = a
idx = idx + 1 idx = idx + 1
if tc.ref and index == "" then if tc.ref then
local dead = typenames[key .. "_dead"] local dead = typenames[key .. "_dead"]
local a = { local a = {
absent = true, absent = true,
@ -167,7 +183,9 @@ local function cache_world(obj, k)
return c return c
end end
local context = setmetatable({}, { __index = cache_world }) local context = setmetatable({}, {
__index = cache_world,
})
local typeid = { local typeid = {
int = assert(ecs._TYPEINT), int = assert(ecs._TYPEINT),
float = assert(ecs._TYPEFLOAT), float = assert(ecs._TYPEFLOAT),
@ -239,7 +257,7 @@ do -- newtype
c.size = ecs._LUAOBJECT c.size = ecs._LUAOBJECT
assert(c[1] == nil) assert(c[1] == nil)
elseif c.size > 0 then elseif c.size > 0 then
align_struct(c, typeclass[1][1]) align_struct(c, c[1][1])
else else
-- size == 0, one value -- size == 0, one value
if ttype then if ttype then
@ -258,7 +276,9 @@ do -- newtype
self:_newtype(id, c.size) self:_newtype(id, c.size)
if typeclass.ref then if typeclass.ref then
c.ref = true c.ref = true
self:register { name = name .. "_dead" } self:register{
name = name .. "_dead",
}
end end
end end
end end
@ -402,9 +422,10 @@ do
iter = {1, typenames[name].id} iter = {1, typenames[name].id}
if pattern then if pattern then
local p = context[self].select[pattern] local p = context[self].select[pattern]
self:_sync(p, iter) return self:_read(p, iter)
end else
return iter return iter
end
else else
iter[1] = 1 iter[1] = 1
iter[2] = typenames[name].id iter[2] = typenames[name].id

@ -0,0 +1,15 @@
https://www.cnblogs.com/lucky9322/p/14922842.html
NoSQLBooster for MongoDB 基于 Electro 编写 asar 打包,所以我们能够解包修改代码并重新打包
1.安装工具
npm install asar -g
2.解包
进入 /Applications/NoSQLBooster for MongoDB.app/Contents/Resources
3.修改 app\shared\lmCore.js 里的 MAX_TRIAL_DAYS 和 TRIAL_DAYS 值
MAX_TRIAL_DAYS=999999,TRIAL_DAYS=999999
4.打包,打包完之后删除 app 文件夹
asar pack app app.asar
Loading…
Cancel
Save