Keep it civil please. Here is a [macro tutorial](https://nim-lang.org/docs/tut3.html) and here is [documentation of the macros module](https://nim-lang.org/docs/macros.html). You should never have to use a code generator. As far as I can tell, no one understands your question, so I am going to pitch in with an answer to how much I personally understood.
Routine (proc etc) definitions inside templates are dirty by default, types and variables are gensym'd. [Relevant documentation](https://nim-lang.org/docs/manual.html#templates-hygiene-in-templates). You can opt in or out with {.inject.} or {.gensym.}. Unfortunately there is no way to pass object/enum AST to a macro/template, you have to pass your own type section definition (which you can only do with colon/indent syntax) and extract the AST from there or generate an object/enum node from some other kind of AST (for example `(name: string, age, ssn: int)`). I still don't know if that's relevant to your case though, no one's answers in this post has implied that they are not experienced with macros, the way you're wording your problem just does not narrow down possibilities. I don't even expect this post that I'm making to help you, it's just the next person who Googles some related problem and finds this post might want something decipherable.