Add @nogc UDA, fix some small issues, xmake changes
-add @nogc to some functions where it was missing -fix compilation issue in mallocator -fix Meson build -some work on xmake build
This commit is contained in:
parent
5e123d96b3
commit
3a3a9e0341
6 changed files with 39 additions and 26 deletions
16
dub.json
16
dub.json
|
|
@ -7,9 +7,9 @@
|
||||||
"description": "Dynamic Entity Component System",
|
"description": "Dynamic Entity Component System",
|
||||||
"copyright": "Copyright © 2018-2023, Michał Masiukiewicz, Dawid Masiukiewicz",
|
"copyright": "Copyright © 2018-2023, Michał Masiukiewicz, Dawid Masiukiewicz",
|
||||||
"license": "BSD 3-clause",
|
"license": "BSD 3-clause",
|
||||||
"sourcePaths" : ["source\/"],
|
"sourcePaths" : ["source/"],
|
||||||
"excludedSourceFiles":[
|
"excludedSourceFiles":[
|
||||||
"source\/ecs\/traits.d"
|
"source/ecs/traits.d"
|
||||||
],
|
],
|
||||||
"configurations" : [
|
"configurations" : [
|
||||||
{
|
{
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
"sourceFiles" : ["tests/tests.d"],
|
"sourceFiles" : ["tests/tests.d"],
|
||||||
"targetType" : "executable",
|
"targetType" : "executable",
|
||||||
"excludedSourceFiles":[
|
"excludedSourceFiles":[
|
||||||
"source\/win_dll.d"
|
"source/win_dll.d"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
"sourcePaths": ["source/","tests/"],
|
"sourcePaths": ["source/","tests/"],
|
||||||
"mainSourceFile":"tests/runner.d",
|
"mainSourceFile":"tests/runner.d",
|
||||||
"excludedSourceFiles":[
|
"excludedSourceFiles":[
|
||||||
"source\/win_dll.d",
|
"source/win_dll.d",
|
||||||
"tests/tests.d"
|
"tests/tests.d"
|
||||||
],
|
],
|
||||||
"dflags": [
|
"dflags": [
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
"sourcePaths": ["source/","tests/"],
|
"sourcePaths": ["source/","tests/"],
|
||||||
"mainSourceFile":"tests/runner.d",
|
"mainSourceFile":"tests/runner.d",
|
||||||
"excludedSourceFiles":[
|
"excludedSourceFiles":[
|
||||||
"source\/win_dll.d",
|
"source/win_dll.d",
|
||||||
"tests/tests.d"
|
"tests/tests.d"
|
||||||
],
|
],
|
||||||
"dflags": [
|
"dflags": [
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
"name" : "library-betterC",
|
"name" : "library-betterC",
|
||||||
"targetType" : "library",
|
"targetType" : "library",
|
||||||
"excludedSourceFiles":[
|
"excludedSourceFiles":[
|
||||||
"source\/win_dll.d"
|
"source/win_dll.d"
|
||||||
],
|
],
|
||||||
"dflags": [
|
"dflags": [
|
||||||
"-betterC",
|
"-betterC",
|
||||||
|
|
@ -101,7 +101,7 @@
|
||||||
"targetType" : "executable",
|
"targetType" : "executable",
|
||||||
"sourceFiles" : ["tests/tests.d"],
|
"sourceFiles" : ["tests/tests.d"],
|
||||||
"excludedSourceFiles":[
|
"excludedSourceFiles":[
|
||||||
"source\/win_dll.d"
|
"source/win_dll.d"
|
||||||
],
|
],
|
||||||
"dflags": [
|
"dflags": [
|
||||||
"-betterC"
|
"-betterC"
|
||||||
|
|
@ -125,7 +125,7 @@
|
||||||
"sourcePaths": ["source/","tests/"],
|
"sourcePaths": ["source/","tests/"],
|
||||||
"mainSourceFile":"tests/runner.d",
|
"mainSourceFile":"tests/runner.d",
|
||||||
"excludedSourceFiles":[
|
"excludedSourceFiles":[
|
||||||
"source\/win_dll.d",
|
"source/win_dll.d",
|
||||||
"tests/tests.d"
|
"tests/tests.d"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ struct Entity
|
||||||
return cast(T*)getComponent(becsID!T);
|
return cast(T*)getComponent(becsID!T);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* getComponent(ushort component_id) const
|
void* getComponent(ushort component_id) const nothrow @nogc
|
||||||
{
|
{
|
||||||
EntityManager.EntitiesBlock* block = gEntityManager.getMetaData(&this);
|
EntityManager.EntitiesBlock* block = gEntityManager.getMetaData(&this);
|
||||||
EntityManager.EntityInfo* info = block.type_info;
|
EntityManager.EntityInfo* info = block.type_info;
|
||||||
|
|
@ -54,7 +54,7 @@ struct Entity
|
||||||
return (cast(void*)block + info.deltas[component_id] + block.entityIndex(&this) * gEntityManager.components[component_id].size);
|
return (cast(void*)block + info.deltas[component_id] + block.entityIndex(&this) * gEntityManager.components[component_id].size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasComponent(ushort component_id) const
|
bool hasComponent(ushort component_id) const nothrow @nogc
|
||||||
{
|
{
|
||||||
EntityManager.EntitiesBlock* block = gEntityManager.getMetaData(&this);
|
EntityManager.EntitiesBlock* block = gEntityManager.getMetaData(&this);
|
||||||
EntityManager.EntityInfo* info = block.type_info;
|
EntityManager.EntityInfo* info = block.type_info;
|
||||||
|
|
@ -62,7 +62,7 @@ struct Entity
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityMeta getMeta() const
|
EntityMeta getMeta() const nothrow @nogc
|
||||||
{
|
{
|
||||||
EntityMeta meta;
|
EntityMeta meta;
|
||||||
meta.block = gEntityManager.getMetaData(&this);
|
meta.block = gEntityManager.getMetaData(&this);
|
||||||
|
|
@ -85,7 +85,7 @@ struct EntityMeta
|
||||||
return cast(T*)getComponent(becsID!T);
|
return cast(T*)getComponent(becsID!T);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* getComponent(ushort component_id) const
|
void* getComponent(ushort component_id) const nothrow @nogc
|
||||||
{
|
{
|
||||||
const (EntityManager.EntityInfo)* info = block.type_info;
|
const (EntityManager.EntityInfo)* info = block.type_info;
|
||||||
|
|
||||||
|
|
@ -95,7 +95,7 @@ struct EntityMeta
|
||||||
return (cast(void*)block + info.deltas[component_id] + index * gEntityManager.components[component_id].size);
|
return (cast(void*)block + info.deltas[component_id] + index * gEntityManager.components[component_id].size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasComponent(ushort component_id) const
|
bool hasComponent(ushort component_id) const nothrow @nogc
|
||||||
{
|
{
|
||||||
const EntityManager.EntityInfo* info = block.type_info;
|
const EntityManager.EntityInfo* info = block.type_info;
|
||||||
if (component_id >= info.deltas.length || info.deltas[component_id] == 0)return false;
|
if (component_id >= info.deltas.length || info.deltas[component_id] == 0)return false;
|
||||||
|
|
@ -124,7 +124,7 @@ export struct EntityTemplate
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
Get specified component. If component doesn't exist function return null. Returned pointer is valid during EntityTemplate lifetime.
|
Get specified component. If component doesn't exist function return null. Returned pointer is valid during EntityTemplate lifetime.
|
||||||
*/
|
*/
|
||||||
T* getComponent(T)() nothrow @nogc
|
T* getComponent(T)()
|
||||||
{
|
{
|
||||||
if(becsID!T >= info.tmpl_deltas.length || info.tmpl_deltas[becsID!T] == ushort.max)return null;
|
if(becsID!T >= info.tmpl_deltas.length || info.tmpl_deltas[becsID!T] == ushort.max)return null;
|
||||||
return cast(T*)(entity_data.ptr + info.tmpl_deltas[becsID!T]);
|
return cast(T*)(entity_data.ptr + info.tmpl_deltas[becsID!T]);
|
||||||
|
|
|
||||||
|
|
@ -2502,7 +2502,7 @@ export struct EntityManager
|
||||||
*Params:
|
*Params:
|
||||||
*id = ID of entity to be copyied.
|
*id = ID of entity to be copyied.
|
||||||
*/
|
*/
|
||||||
export Entity* addEntityCopy(EntityID id)
|
export Entity* addEntityCopy(EntityID id) nothrow @nogc
|
||||||
{
|
{
|
||||||
Entity* entity = getEntity(id);
|
Entity* entity = getEntity(id);
|
||||||
EntitiesBlock* block = getMetaData(entity);
|
EntitiesBlock* block = getMetaData(entity);
|
||||||
|
|
@ -2554,7 +2554,7 @@ export struct EntityManager
|
||||||
Params:
|
Params:
|
||||||
tmpl = pointer entity template allocated by EntityManager.
|
tmpl = pointer entity template allocated by EntityManager.
|
||||||
*/
|
*/
|
||||||
export Entity* addEntity(EntityTemplate* tmpl)
|
export Entity* addEntity(EntityTemplate* tmpl) nothrow @nogc
|
||||||
{
|
{
|
||||||
return addEntity(tmpl, null);
|
return addEntity(tmpl, null);
|
||||||
}
|
}
|
||||||
|
|
@ -2567,7 +2567,7 @@ export struct EntityManager
|
||||||
tmpl = pointer entity template allocated by EntityManager.
|
tmpl = pointer entity template allocated by EntityManager.
|
||||||
replacement = list of components references to used. Memory form list replace data from template inside new entity. Should be used only for data which vary between most entities (like 3D position etc.)
|
replacement = list of components references to used. Memory form list replace data from template inside new entity. Should be used only for data which vary between most entities (like 3D position etc.)
|
||||||
*/
|
*/
|
||||||
export Entity* addEntity(EntityTemplate* tmpl, ComponentRef[] replacement)
|
export Entity* addEntity(EntityTemplate* tmpl, ComponentRef[] replacement) nothrow @nogc
|
||||||
{
|
{
|
||||||
EntityInfo* info = tmpl.info;
|
EntityInfo* info = tmpl.info;
|
||||||
|
|
||||||
|
|
@ -2664,7 +2664,7 @@ export struct EntityManager
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
Return block with free space for selected EntityInfo. Additional this function is multithread safe.
|
Return block with free space for selected EntityInfo. Additional this function is multithread safe.
|
||||||
*/
|
*/
|
||||||
private EntitiesBlock* findBlockWithFreeSpaceMT(EntityInfo* info)
|
private EntitiesBlock* findBlockWithFreeSpaceMT(EntityInfo* info) nothrow @nogc
|
||||||
{
|
{
|
||||||
EntitiesBlock* block = info.last_block;
|
EntitiesBlock* block = info.last_block;
|
||||||
|
|
||||||
|
|
@ -2718,7 +2718,7 @@ export struct EntityManager
|
||||||
Params:
|
Params:
|
||||||
id = id of entity to remove
|
id = id of entity to remove
|
||||||
*/
|
*/
|
||||||
export void removeEntity(EntityID id)
|
export void removeEntity(EntityID id) nothrow @nogc
|
||||||
{
|
{
|
||||||
threads[threadID].entitesToRemove.add(id);
|
threads[threadID].entitesToRemove.add(id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ static struct Mallocator
|
||||||
|
|
||||||
static if (__traits(isPOD, T))
|
static if (__traits(isPOD, T))
|
||||||
{
|
{
|
||||||
__gshared immutable T init = T.init;
|
__gshared T init = T.init;
|
||||||
memcpy(ret, &init, T.sizeof);
|
memcpy(ret, &init, T.sizeof);
|
||||||
}
|
}
|
||||||
else static if (is(T == struct))
|
else static if (is(T == struct))
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ tests_src = files(
|
||||||
exe = executable('BubelECSTests',
|
exe = executable('BubelECSTests',
|
||||||
tests_src,
|
tests_src,
|
||||||
include_directories : [inc, include_directories('..')],
|
include_directories : [inc, include_directories('..')],
|
||||||
d_args : args,
|
# d_args : args,
|
||||||
link_args : link_args,
|
# link_args : link_args,
|
||||||
dependencies : decs_dep,
|
dependencies : bubel_ecs_dep,
|
||||||
)
|
)
|
||||||
|
|
||||||
test('basic-tests', exe)
|
test('basic-tests', exe)
|
||||||
|
|
|
||||||
19
xmake.lua
19
xmake.lua
|
|
@ -1,15 +1,25 @@
|
||||||
add_rules("mode.debug", "mode.release")
|
add_rules("mode.debug", "mode.release")
|
||||||
|
|
||||||
|
if get_config("toolchain") == "ldc" then
|
||||||
|
add_ldflags("-linker=lld", {force = true})
|
||||||
|
end
|
||||||
|
|
||||||
option("betterC")
|
option("betterC")
|
||||||
set_default(false)
|
set_default(false)
|
||||||
if get_config("dc") == "gcc" then
|
if get_config("toolchain") == "gdc" then
|
||||||
add_dcflags("-fno-druntime")
|
add_dcflags("-fno-druntime")
|
||||||
|
elseif get_config("toolchain") == "dmd" then
|
||||||
|
add_dcflags("-betterC") -- DMD doesn't need -betterC flag during linking!?
|
||||||
|
add_ldflags("-betterC", {force = true})
|
||||||
|
add_shflags("-betterC", {force = true})
|
||||||
else
|
else
|
||||||
add_dcflags("-betterC")
|
add_ldflags("-betterC", {force = true}) -- -betterC flag isn't accepted for LDC for some reason
|
||||||
|
add_dcflags("-betterC", {force = true})
|
||||||
|
add_shflags("-betterC", {force = true})
|
||||||
end
|
end
|
||||||
|
|
||||||
target("bubel-ecs")
|
target("bubel-ecs")
|
||||||
set_kind("static")
|
set_kind("shared")
|
||||||
set_basename("BubelECS")
|
set_basename("BubelECS")
|
||||||
add_files("source/bubel/**.d")
|
add_files("source/bubel/**.d")
|
||||||
add_includedirs("source", {public = true})
|
add_includedirs("source", {public = true})
|
||||||
|
|
@ -18,6 +28,7 @@ target("bubel-ecs")
|
||||||
target("tests")
|
target("tests")
|
||||||
set_kind("binary")
|
set_kind("binary")
|
||||||
set_basename("BubelECSTests")
|
set_basename("BubelECSTests")
|
||||||
|
add_ldflags("-L-rpath=.", {force = true})
|
||||||
add_files("tests/*.d|tests.d")
|
add_files("tests/*.d|tests.d")
|
||||||
add_includedirs(".", {public = true})
|
add_includedirs(".", {public = true})
|
||||||
set_options("betterC")
|
set_options("betterC")
|
||||||
|
|
@ -27,6 +38,8 @@ target("tests")
|
||||||
target("test")
|
target("test")
|
||||||
set_kind("binary")
|
set_kind("binary")
|
||||||
set_basename("BubelECSTest")
|
set_basename("BubelECSTest")
|
||||||
|
-- add_rpathdirs(".") -- this doesn't work completely
|
||||||
|
add_ldflags("-L-rpath=.", {force = true})
|
||||||
add_files("tests/tests.d")
|
add_files("tests/tests.d")
|
||||||
add_includedirs(".", {public = true})
|
add_includedirs(".", {public = true})
|
||||||
set_options("betterC")
|
set_options("betterC")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue