|
First a summary. We have an interface IFoo. We want to be able to create implementations of this interface from lua code through LuaInterface and then return this implementation created in lua back to the .net code.
Now the example code.
In the C# file… in an assembly called bar.dll
Namespace bar
{
public interface IFoo
{
long get_id();
}
}
In the lua file…
luanet.load_assembly("bar")
impl = {}
function impl:get_id()
return 1.0
end
function get_instance()
return make_object(impl, 'bar.IFoo')
end
To summarize, we have an interface IFoo that exists in the .net app domain. We want to be able to create new implementations 'on the fly' by evaling the lua file. A few notes on the lua code. Originally I followed the luainterface paper and tried to call make_object(impl, IFoo) (no quotes) but the LuaInterface could not find the function. Once I added the quotes as I read in the LuaInterfaceTest project it stopped bombing out in the lua interpreter.
Now for the use of LuaInterface that is giving me trouble.
Lua l = new Lua();
l.DoFile(<the above lua code file>);
IFoo f = l.GetFunction("get_instance").Call();
Instead of getting a new instance of type IFoo f is just null. Based on what I read in the LuaInterface paper this should work however I have not seen this done in any example code so I am still unsure.
--
time makes fools of us all,
ben siemon
The information contained in this e-mail and any accompanying documents is intended solely for the person and/or entity to whom it is addressed (i.e. those identified in the "To" and "cc" box) and may contain confidential and/or legally privileged information. Unauthorized disclosure, dissemination, copying or other use of this communication, or any attachment, is strictly prohibited and may be unlawful. If you have received this e-mail in error, please return the e-mail and attachments to the sender and delete the e-mail and attachments and any copy from your system. redbox thanks you for your cooperation.