I got myself in a problem with dividing visibility of my lib, I don't want users to see any boilerplate, procs and methods they should not see.
### USER GAME MODULE
import actors # engine module
ComponentObject* = object
x*,y*: int
ComponentHealth* = object
arg1*, arg2*: int
ComponentPlayer* = object
damage* : int
# ecs.add is a macro
ecs.add ComponentObject, Compact
ecs.add ComponentPlayer, Compact
ecs.add ComponentHealth, Compact
# makes a group
ecs.group players:
scope: public
comps: (ComponentPlayer, ComponentObject, ComponentHealth)
### ENGINE MODULE
# decide what template to use for generating storage for a component
macro add*(this: EcsInstance, component: untyped, component_kind: static[RegKind] = RegKind.Fast): untyped =
# generating a storage for a component
template internal_storagefast*(this: EcsBase, t: typedesc) =
template internal_storagecompact*(this: EcsBase, t: typedesc) =
So the thing is that I can see
_storagefast
and _storagecompact
from the game scope. I can't make them private, cause then I can't make them work in the game module from the macro add
.
I made It impossible to work with them ( ? ) by some hacks like this
type #@ecs
EcsBase = object
EcsInstance = object
base : EcsBase
ecs* = EcsInstance()
So while I can see an ECS object from the game and hit
macro
I can't get myself touching directly _storagecompact, internal_storagefast
But It looks and feels bad :)
The templates make some boilerplate code and stuff needed to work with components and storage. Any thoughts? : )
thanks a lot :)
bindSym("internal_storagecompact", brForceOpen)
helped!