🐳chore(库): 调整submodule

develop
xiaojin 5 years ago
parent 7f57515820
commit b582805df0

3
.gitmodules vendored

@ -1,9 +1,6 @@
[submodule "code/framework/3rd/ffi-lua"]
path = code/framework/3rd/ffi-lua
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"]
path = code/framework/3rd/glm
url = git@github.com:g-truc/glm.git

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

@ -10,6 +10,7 @@
#include "aoi.h"
// https://github.com/ssnobin/c_lua_aoi
// 非实时抛出事件lua层定时aoi_update获得aoi事件
#define GET_INTEGER(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 ecs_capi {
struct ecs_capi
{
void *(*iter)(struct entity_world *w, int cid, int index);
void (*clear_type)(struct entity_world *w, int cid);
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);
};
struct ecs_context {
struct ecs_context
{
struct ecs_capi *api;
struct entity_world *world;
void *L; // for memory allocator
@ -27,18 +29,21 @@ struct ecs_context {
};
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);
}
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);
return ctx->api->iter(ctx->world, ctx->cid[cid], index);
}
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)
return NULL;
check_id_(ctx, cid);
@ -46,90 +51,107 @@ entity_ref_object(struct ecs_context *ctx, int cid, int index) {
}
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);
ctx->api->clear_type(ctx->world, ctx->cid[cid]);
}
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, sibling_id);
return ctx->api->sibling_id(ctx->world, ctx->cid[cid], index, ctx->cid[sibling_id]);
}
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, 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;
} else {
}
else
{
return ctx->api->iter(ctx->world, ctx->cid[sibling_id], id - 1);
}
}
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, sibling_id);
return ctx->api->add_sibling(ctx->world, ctx->cid[cid], index, ctx->cid[sibling_id], buffer, ctx->L, 1);
}
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);
return ctx->api->new_entity(ctx->world, ctx->cid[cid], buffer, ctx->L, 1);
}
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);
ctx->api->remove(ctx->world, ctx->cid[cid], index, ctx->L, 1);
}
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, tag_id);
ctx->api->enable_tag(ctx->world, ctx->cid[cid], index, ctx->cid[tag_id], ctx->L, 1);
}
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, tag_id);
ctx->api->disable_tag(ctx->world, ctx->cid[cid], index, ctx->cid[tag_id]);
}
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);
assert(index > 0);
return ctx->api->assign_lua(ctx->world, ctx->cid[cid], index - 1, ctx->L, 1);
}
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);
int object_id = ctx->cid[cid];
int dead_tag = object_id + 1;
int id;
if (ctx->api->iter(ctx->world, dead_tag, 0)) {
if (ctx->api->iter(ctx->world, dead_tag, 0))
{
// reuse
id = ctx->api->sibling_id(ctx->world, dead_tag, 0, object_id);
assert(id > 0);
--id;
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);
}
return id + 1;
}
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)
return;
check_id_(ctx, cid);

@ -218,7 +218,7 @@ w:register {
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)
v.sum = v.vector.x + v.vector.y
end

@ -17,7 +17,7 @@ for i = 1, 10 do
end
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
v.temp = "Temp"
end

@ -18,11 +18,28 @@ w:new {
order = true,
}
w:new {
node = { id = 2, parent = 0 },
order = true,
}
w:new {
node = { id = 0, parent = -1 },
}
w:new {
node = { id = 3, parent = 0 },
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 = {}
for v in w:select "order node:update" do

@ -1,51 +1,31 @@
-- test sort
local ecs = require "ecs"
local w = ecs.world()
w:register {
name = "data",
type = "float",
name = "value",
type = "int",
}
w:register {
name = "index",
type = "int",
name = "mark"
}
local tmp = { 10,9,8,7,6,5,4,3,2,1 }
for i = 1, 10, 2 do
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:new {
value = 1,
mark = true,
}
w:register {
name = "sorted_index",
type = "int",
w:new {
mark = true,
}
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
print(v.sorted_index, "=>", v.data)
for v in w:select "mark" do
w:sync("value?in", v)
print(v.value)
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)
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
v.a = -v.a
v.temp = 42
w:sync("a:out temp:temp", v)
w:sync("a:out temp:new", v)
end
end

@ -8,6 +8,10 @@ w:register {
"b:userdata",
}
w:register {
name = "flag",
}
w:new {
t = {
a = false,
@ -36,3 +40,23 @@ print_v()
test.testuserdata(ctx)
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 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)
if opt == nil then
return { exist = true }
return {
exist = true,
}
end
local desc = {}
if opt == "?" then
@ -26,7 +53,7 @@ local function get_attrib(opt, inout)
desc.absent = true
assert(not desc.opt)
else
assert(inout == "temp")
assert(inout == "new")
end
return desc
end
@ -80,20 +107,22 @@ local function cache_world(obj, k)
return desc
end
setmetatable(c, { __index = function(_, key)
setmetatable(c, {
__index = function(_, key)
if key == "all" then
local all = k:_groupiter(gen_all_pat())
c.all = all
return all
end
end })
end,
})
local function gen_select_pat(pat)
local typenames = c.typenames
local desc = {}
local idx = 1
for token in pat:gmatch "[^ ]+" do
local key, index, padding = token:match "^([_%w]+)%(?([_%w]*)%)?(.*)"
local key, padding = token:match "^([_%w]+)(.*)"
assert(key, "Invalid pattern")
local opt, inout
if padding ~= "" then
@ -104,19 +133,6 @@ local function cache_world(obj, k)
if tc == nil then
error("Unknown type " .. key)
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)
a.name = tc.name
a.id = tc.id
@ -127,7 +143,7 @@ local function cache_world(obj, k)
end
desc[idx] = a
idx = idx + 1
if tc.ref and index == "" then
if tc.ref then
local dead = typenames[key .. "_dead"]
local a = {
absent = true,
@ -167,7 +183,9 @@ local function cache_world(obj, k)
return c
end
local context = setmetatable({}, { __index = cache_world })
local context = setmetatable({}, {
__index = cache_world,
})
local typeid = {
int = assert(ecs._TYPEINT),
float = assert(ecs._TYPEFLOAT),
@ -239,7 +257,7 @@ do -- newtype
c.size = ecs._LUAOBJECT
assert(c[1] == nil)
elseif c.size > 0 then
align_struct(c, typeclass[1][1])
align_struct(c, c[1][1])
else
-- size == 0, one value
if ttype then
@ -258,7 +276,9 @@ do -- newtype
self:_newtype(id, c.size)
if typeclass.ref then
c.ref = true
self:register { name = name .. "_dead" }
self:register{
name = name .. "_dead",
}
end
end
end
@ -402,9 +422,10 @@ do
iter = {1, typenames[name].id}
if pattern then
local p = context[self].select[pattern]
self:_sync(p, iter)
end
return self:_read(p, iter)
else
return iter
end
else
iter[1] = 1
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