I need to convert a type section with object definitions that utilize custom 
attribute pragmas into a type section with the same object definitions, but 
with the pragmas stripped out and converted to setter procedures.

So, this:
    
    
    dbSchema:
      type
        Person* = ref object
          name {.required, maxLength: 10}: string
    

should become this:
    
    
    type
      Person* = ref object
        name: string
    
    proc `name=`*(self: var Person, value: string) {.maxLength: 10,
                                                     required.} =
      name = value
    
    proc name*(self: Person): string = name
    
    

It can be done with brute force, by breaking the original type section into 
primitives and constructing the new section from them.

My question is, is there an easier way to do that? In other words, how would a 
seasoned Nim developer approach such task?

Reply via email to