-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to create a struct instance by its name? #34
Comments
Unfortunately it cannot as of now |
@wickwirew but is it theoretically possible? |
Potentially. You need to be able to get the type's metadata record from it's name. I do remember seeing a PR go into the compiler that allowed you to get it from the mangled name a while back. Other than that, as far as I know it's not. Would love to add it if it is though |
That will be just awesome if you add it! |
Hi @wickwirew. Have you got a chance to add this feature? :) |
Sorry but its just not possible. You can create a struct type from it's mangled name, but not just simply the name. |
if you can create struct Metadata,so you can create struct instance by the name,this is struct Metadata: struct StructTypeDescriptor: TypeDescriptor {
var flags: ContextDescriptorFlags
var parent: Int32
var mangledName: RelativePointer<Int32, CChar>
var accessFunctionPtr: RelativePointer<Int32, UnsafeRawPointer>
var fieldDescriptor: RelativePointer<Int32, FieldDescriptor>
var numberOfFields: Int32
var offsetToTheFieldOffsetVector: RelativeVectorPointer<Int32, Int32>
var genericContextHeader: TargetTypeGenericContextDescriptorHeader
} |
I'm looking some alternative to NSClassFromString but for structs :)
The text was updated successfully, but these errors were encountered: