Skip to content

How to create dynamic userdata types? #695

@dubrowgn

Description

@dubrowgn

I have struct definitions coming from a DSL interpreted at runtime, and want to create lua userdata types with a custom __index implementation for field accessors. However, I don't see any userdata APIs that don't take a compile-time rust type, so how can I create userdata types at runtime?

Conceptually, I would imagine this is something like lua_newuserdata followed by lua_setmetatable. It would be nice to be able to reference mlua types like Table, but I don't see a way to access the index field for these.

Am I forced to re-implement the high-level mlua API's on top of ffi to implement dynamic lua types at runtime? Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions