[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is there an equivelent of 'require' for C modules ?
- From: "Timm S. Mueller" <tmueller@...>
- Date: Sat, 25 Jul 2009 10:36:12 +0200
On Sat, 25 Jul 2009 09:30:50 +0100
Lawrie Nichols <lawrien@gmail.com> wrote:
> I need to be able to load an existing lua C module from within a new C
> module (from within it's luaopen_xxx function). The obvious parallel is
> doing a 'require' in a lua script, but there doesn't (as far as I can
> find) appear to be an equivelent C API.
> I guess I could just do a lua_dostring(L,"require 'mymodule'"), but that
> doesn't smell quite right.
I'm using
lua_getglobal(L, "require");
lua_pushliteral(L, "mymodule");
lua_call(L, 1, 1);
which seemed like the direct equivalent to me.
- Timm
--
Timm S. Mueller <tmueller@schulze-mueller.de>
Schulze & Mueller GbR, Gryphiusstr. 2, 10245 Berlin,
Gesellschafter: Franciska Schulze, Timm S. Mueller,
Tel. +49 30 93624410, http://www.schulze-mueller.de/