blob: 55fd89c784365707bf6a15bec087ff18c8717055 (
plain) (
tree)
|
|
# Get a unique pointer for each type.
proc getTypePtr*[T](x: T): pointer =
when T is RootRef:
# I'm so sorry.
# (This dereferences the object's first member, m_type. Probably.)
return cast[ptr pointer](x)[]
elif T is RootObj:
return cast[pointer](x)
else:
return getTypeInfo(x)
func getTypePtr*(t: typedesc[ref object]): pointer =
var x = t()
return getTypePtr(x)
func getTypePtr*(t: type): pointer =
var x: t
return getTypePtr(x)
|