On Mon, Feb 4, 2013 at 8:46 AM, Jens Ohlig <jens.oh...@wikimedia.de> wrote:
>
> Here are my questions:
> 1. Is there an easy way to add your own Lua functions (that call PHP Api 
> functions) to Scribunto other than writing them into LuaCommon.php?

Yes. Probably the best example to look at right now is gerrit change
47109.[1] You could also look at 42050, 38013, or 46478. Keep in mind
that any functions you provide have the at least same sorts of
security and performance concerns as parser function hooks.

The major issue right now is that there's no way to add something to
Scribunto_LuaEngine::$libraryClasses from another extension. There's
also the issue of easily adding unit tests from another extension,
since ideally the unit tests should be run against both the
LuaStandalone and LuaSandbox engines. I'll probably have a look at
this today.

 [1]: https://gerrit.wikimedia.org/r/#/c/47109/

> 2. Is using your own namespace the way to go?

You'd add your library object in Lua as a child of the "mw" object.

> 3. Are there some kind of examples how to wrap PHP functions into the Lua 
> environment (using the frame etc)?

See #1. Although I can't think of a case where a PHP function would
need to use the frame instead of being passed whatever parameters it
needs explicitly by the Lua caller.

> 4. Is there any way to introspect or debug such wrapped functions?

I'm not sure what you mean here.


-- 
Brad Jorsch
Software Engineer
Wikimedia Foundation

_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to