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)
    
    
    Run
    
    
    ### 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) =
    
    
    Run

So the thing is that I can see 
    
    
    _storagefast
    
    Run

and 
    
    
    _storagecompact
    
    Run

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
    
    Run

.

I made It impossible to work with them ( ? ) by some hacks like this 
    
    
    type #@ecs
        EcsBase = object
        EcsInstance = object
            base   : EcsBase
    ecs* = EcsInstance()
    
    
    Run

So while I can see an ECS object from the game and hit 
    
    
     macro
    
    Run

I can't get myself touching directly 
    
    
    _storagecompact, internal_storagefast
    
    Run

But It looks and feels bad :)

The templates make some boilerplate code and stuff needed to work with 
components and storage. Any thoughts? : )

Reply via email to