Skip to content

Any way to preload a library written in Rust? #131

Closed
@lbrowne

Description

@lbrowne

I'm looking for a way to preload libraries so they can be included in a script via require. This comment in linit.c describes what I'm trying to do:

** You can also *preload* libraries, so that a later 'require' can
** open the library, which is already linked to the application.
** For that, do the following code:
**
**  luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);
**  lua_pushcfunction(L, luaopen_modname);
**  lua_setfield(L, -2, modname);
**  lua_pop(L, 1);  // remove PRELOAD table

I thought about writing in the functionality myself but after reading this issue (#105), it looks like it might be a little trickier than I thought. I'm not well-versed in the internals of Lua, I'm hoping someone might have some insight on how to go about this.

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