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:
Mergul 2023-03-23 22:31:20 +01:00
parent 5e123d96b3
commit 3a3a9e0341
6 changed files with 39 additions and 26 deletions

View file

@ -44,7 +44,7 @@ struct Entity
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.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);
}
bool hasComponent(ushort component_id) const
bool hasComponent(ushort component_id) const nothrow @nogc
{
EntityManager.EntitiesBlock* block = gEntityManager.getMetaData(&this);
EntityManager.EntityInfo* info = block.type_info;
@ -62,7 +62,7 @@ struct Entity
return true;
}
EntityMeta getMeta() const
EntityMeta getMeta() const nothrow @nogc
{
EntityMeta meta;
meta.block = gEntityManager.getMetaData(&this);
@ -85,7 +85,7 @@ struct EntityMeta
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;
@ -95,7 +95,7 @@ struct EntityMeta
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;
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.
*/
T* getComponent(T)() nothrow @nogc
T* getComponent(T)()
{
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]);

View file

@ -2502,7 +2502,7 @@ export struct EntityManager
*Params:
*id = ID of entity to be copyied.
*/
export Entity* addEntityCopy(EntityID id)
export Entity* addEntityCopy(EntityID id) nothrow @nogc
{
Entity* entity = getEntity(id);
EntitiesBlock* block = getMetaData(entity);
@ -2554,7 +2554,7 @@ export struct EntityManager
Params:
tmpl = pointer entity template allocated by EntityManager.
*/
export Entity* addEntity(EntityTemplate* tmpl)
export Entity* addEntity(EntityTemplate* tmpl) nothrow @nogc
{
return addEntity(tmpl, null);
}
@ -2567,7 +2567,7 @@ export struct 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.)
*/
export Entity* addEntity(EntityTemplate* tmpl, ComponentRef[] replacement)
export Entity* addEntity(EntityTemplate* tmpl, ComponentRef[] replacement) nothrow @nogc
{
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.
*/
private EntitiesBlock* findBlockWithFreeSpaceMT(EntityInfo* info)
private EntitiesBlock* findBlockWithFreeSpaceMT(EntityInfo* info) nothrow @nogc
{
EntitiesBlock* block = info.last_block;
@ -2718,7 +2718,7 @@ export struct EntityManager
Params:
id = id of entity to remove
*/
export void removeEntity(EntityID id)
export void removeEntity(EntityID id) nothrow @nogc
{
threads[threadID].entitesToRemove.add(id);
}

View file

@ -279,7 +279,7 @@ static struct Mallocator
static if (__traits(isPOD, T))
{
__gshared immutable T init = T.init;
__gshared T init = T.init;
memcpy(ret, &init, T.sizeof);
}
else static if (is(T == struct))