Hi,

I am writing a nim wrapper for a c library and would like to construct a 
sequence of nim items from a generic proc.

I can construct std library types with a call to a constructor like construct 
but this does not work for tuples or objects if i got this right
    
    
    proc get_item_from_pointer*[T](p: pointer, l_type : MyTypeEnum ; item : var 
T) =
      case l_type
      of  MyTypeEnum.f32 :
          var typed_target = cast[ptr float32](p)
          item=T(typed_target[])
    
    [...]
    

The item construction works for int, float.. but not for custom enum types.

In this example the l_type is the type of the c source pointer, item has the 
type I want to construct and f32 encodes float32

But I do need a "constructor" for a self defined tuple type which is not 
available by the type name - only by ()

Is there a way to construct a tuple or object based on the type information in 
a generic function like T() above? Maybe a way to identify tuple/object types?

Kind Regards, b

Reply via email to