Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: JumpNotZero/NLua
base: 35f94b7407
...
head fork: JumpNotZero/NLua
compare: 936d5a73b6
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jan 23, 2012
@JumpNotZero Added support for translation of LuaCFunction.
Changed the LuaHelper API a bit.
Adapted LuaTable to the new LuaHelper API.
3710411
@JumpNotZero Added more targets for LuaExportAttribute. 936d5a7
View
4 NLua/CommonObjectTranslator.cs
@@ -55,6 +55,10 @@ public static void Push(IntPtr state, object value)
{
LuaCore.PushString(state, value as string);
}
+ else if (type == typeof(LuaCFunction))
+ {
+ LuaCore.PushClosure(state, value as LuaCFunction, 0);
+ }
else
{
throw new LuaException("The object could not be translated.");
View
2  NLua/LuaExportAttribute.cs
@@ -2,7 +2,7 @@
namespace NLua
{
- [AttributeUsage(AttributeTargets.Method)]
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)]
public sealed class LuaExportAttribute : Attribute
{
public string Name
View
19 NLua/LuaHelper.cs
@@ -64,14 +64,16 @@ public static bool DoString(IntPtr state, string chunk)
return true;
}
- public static void GetGlobal(IntPtr state, string name)
+ public static object GetGlobal(IntPtr state, string name)
{
LuaCore.GetField(state, (int)LuaPseudoIndex.Globals, name);
+ return LuaObjectTranslator.Pop(state);
}
- public static void GetRegistryEntry(IntPtr state, string name)
+ public static object GetRegistry(IntPtr state, string name)
{
LuaCore.GetField(state, (int)LuaPseudoIndex.Registry, name);
+ return LuaObjectTranslator.Pop(state);
}
public static void Discard(IntPtr state)
@@ -89,24 +91,15 @@ public static void PushFunction(IntPtr state, LuaCFunction function)
LuaCore.PushClosure(state, function, 0);
}
- public static void RemoveRegistryEntry(IntPtr state, string name)
- {
- LuaHelper.SetRegistryEntry(state, name);
- }
-
- public static void RegisterFunction(IntPtr state, string name, LuaCFunction function)
- {
- LuaHelper.SetGlobal(state, name, function);
- }
-
public static void SetGlobal(IntPtr state, string name, object value)
{
CommonObjectTranslator.Push(state, value);
LuaCore.SetField(state, (int)LuaPseudoIndex.Globals, name);
}
- public static void SetRegistryEntry(IntPtr state, string name)
+ public static void SetRegistry(IntPtr state, string name, object value)
{
+ CommonObjectTranslator.Push(state, value);
LuaCore.SetField(state, (int)LuaPseudoIndex.Registry, name);
}
View
6 NLua/LuaTable.cs
@@ -18,7 +18,7 @@ internal LuaTable(IntPtr state)
this.identifier = "NLua:" + Guid.NewGuid().ToString();
this.disposed = false;
- LuaHelper.SetRegistryEntry(this.state, this.identifier);
+ LuaHelper.SetRegistry(this.state, this.identifier, this.identifier);
}
public override bool TryGetMember(GetMemberBinder binder, out object result)
@@ -29,7 +29,7 @@ public override bool TryGetMember(GetMemberBinder binder, out object result)
public object GetValue(string name)
{
- LuaHelper.GetRegistryEntry(this.state, this.identifier);
+ LuaHelper.GetRegistry(this.state, this.identifier);
LuaCore.GetField(this.state, LuaCore.GetTop(this.state), name);
return LuaObjectTranslator.Pop(this.state);
}
@@ -41,7 +41,7 @@ public void Dispose()
return;
}
- LuaHelper.SetRegistryEntry(this.state, this.identifier);
+ LuaHelper.SetRegistry(this.state, this.identifier, null);
this.disposed = true;
}

No commit comments for this range

Something went wrong with that request. Please try again.