本文整理汇总了C#中LuaInterface.ObjectTranslator类的典型用法代码示例。如果您正苦于以下问题:C# ObjectTranslator类的具体用法?C# ObjectTranslator怎么用?C# ObjectTranslator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectTranslator类属于LuaInterface命名空间,在下文中一共展示了ObjectTranslator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckType
public CheckType(ObjectTranslator translator)
{
this.translator = translator;
extractValues.Add(typeof(object).TypeHandle.Value.ToInt64(), new ExtractValue(getAsObject));
extractValues.Add(typeof(sbyte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsSbyte));
extractValues.Add(typeof(byte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsByte));
extractValues.Add(typeof(short).TypeHandle.Value.ToInt64(), new ExtractValue(getAsShort));
extractValues.Add(typeof(ushort).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUshort));
extractValues.Add(typeof(int).TypeHandle.Value.ToInt64(), new ExtractValue(getAsInt));
extractValues.Add(typeof(uint).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUint));
extractValues.Add(typeof(long).TypeHandle.Value.ToInt64(), new ExtractValue(getAsLong));
extractValues.Add(typeof(ulong).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUlong));
extractValues.Add(typeof(double).TypeHandle.Value.ToInt64(), new ExtractValue(getAsDouble));
extractValues.Add(typeof(char).TypeHandle.Value.ToInt64(), new ExtractValue(getAsChar));
extractValues.Add(typeof(float).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFloat));
extractValues.Add(typeof(decimal).TypeHandle.Value.ToInt64(), new ExtractValue(getAsDecimal));
extractValues.Add(typeof(bool).TypeHandle.Value.ToInt64(), new ExtractValue(getAsBoolean));
extractValues.Add(typeof(string).TypeHandle.Value.ToInt64(), new ExtractValue(getAsString));
extractValues.Add(typeof(LuaFunction).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFunction));
extractValues.Add(typeof(LuaTable).TypeHandle.Value.ToInt64(), new ExtractValue(getAsTable));
extractValues.Add(typeof(Vector3).TypeHandle.Value.ToInt64(), new ExtractValue(getAsVector3));
extractValues.Add(typeof(Vector2).TypeHandle.Value.ToInt64(), new ExtractValue(getAsVector2));
extractValues.Add(typeof(Quaternion).TypeHandle.Value.ToInt64(), new ExtractValue(getAsQuaternion));
extractValues.Add(typeof(Color).TypeHandle.Value.ToInt64(), new ExtractValue(getAsColor));
extractValues.Add(typeof(Vector4).TypeHandle.Value.ToInt64(), new ExtractValue(getAsVector4));
extractValues.Add(typeof(Ray).TypeHandle.Value.ToInt64(), new ExtractValue(getAsRay));
extractValues.Add(typeof(Bounds).TypeHandle.Value.ToInt64(), new ExtractValue(getAsBounds));
extractNetObject = new ExtractValue(getAsNetObject);
}
示例2: CheckType
public CheckType(ObjectTranslator translator)
{
this.translator = translator;
extractValues.Add(typeof(object).TypeHandle.Value.ToInt64(), new ExtractValue(getAsObject));
extractValues.Add(typeof(sbyte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsSbyte));
extractValues.Add(typeof(byte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsByte));
extractValues.Add(typeof(short).TypeHandle.Value.ToInt64(), new ExtractValue(getAsShort));
extractValues.Add(typeof(ushort).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUshort));
extractValues.Add(typeof(int).TypeHandle.Value.ToInt64(), new ExtractValue(getAsInt));
extractValues.Add(typeof(uint).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUint));
extractValues.Add(typeof(long).TypeHandle.Value.ToInt64(), new ExtractValue(getAsLong));
extractValues.Add(typeof(ulong).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUlong));
extractValues.Add(typeof(double).TypeHandle.Value.ToInt64(), new ExtractValue(getAsDouble));
extractValues.Add(typeof(char).TypeHandle.Value.ToInt64(), new ExtractValue(getAsChar));
extractValues.Add(typeof(float).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFloat));
extractValues.Add(typeof(decimal).TypeHandle.Value.ToInt64(), new ExtractValue(getAsDecimal));
extractValues.Add(typeof(bool).TypeHandle.Value.ToInt64(), new ExtractValue(getAsBoolean));
extractValues.Add(typeof(string).TypeHandle.Value.ToInt64(), new ExtractValue(getAsString));
extractValues.Add(typeof(LuaFunction).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFunction));
extractValues.Add(typeof(LuaTable).TypeHandle.Value.ToInt64(), new ExtractValue(getAsTable));
extractValues.Add(typeof(LuaUserData).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUserdata));
extractNetObject = new ExtractValue(getAsNetObject);
}
示例3: Lua
public Lua()
{
luaState = LuaDLL.luaL_newstate(); // steffenj: Lua 5.1.1 API change (lua_open is gone)
//LuaDLL.luaopen_base(luaState); // steffenj: luaopen_* no longer used
LuaDLL.luaL_openlibs(luaState); // steffenj: Lua 5.1.1 API change (luaopen_base is gone, just open all libs right here)
LuaDLL.lua_pushstring(luaState, "LUAINTERFACE LOADED");
LuaDLL.lua_pushboolean(luaState, true);
LuaDLL.lua_settable(luaState, (int) LuaIndexes.LUA_REGISTRYINDEX);
LuaDLL.lua_newtable(luaState);
LuaDLL.lua_setglobal(luaState, "luanet");
LuaDLL.lua_pushvalue(luaState, (int)LuaIndexes.LUA_GLOBALSINDEX);
LuaDLL.lua_getglobal(luaState, "luanet");
LuaDLL.lua_pushstring(luaState, "getmetatable");
LuaDLL.lua_getglobal(luaState, "getmetatable");
LuaDLL.lua_settable(luaState, -3);
LuaDLL.lua_replace(luaState, (int)LuaIndexes.LUA_GLOBALSINDEX);
translator=new ObjectTranslator(this,luaState);
LuaDLL.lua_replace(luaState, (int)LuaIndexes.LUA_GLOBALSINDEX);
LuaDLL.luaL_dostring(luaState, Lua.init_luanet); // steffenj: lua_dostring renamed to luaL_dostring
// We need to keep this in a managed reference so the delegate doesn't get garbage collected
panicCallback = new LuaFunctionCallback(PanicCallback);
LuaDLL.lua_atpanic(luaState, panicCallback);
// LuaDLL.lua_atlock(luaState, lockCallback = new LuaCSFunction(LockCallback));
// LuaDLL.lua_atunlock(luaState, unlockCallback = new LuaCSFunction(UnlockCallback));
}
示例4: Lua
public Lua(long luaState)
{
this.luaLock = new object();
IntPtr ptr = new IntPtr(luaState);
LuaJIT.lua_pushstring(ptr, "LUAINTERFACE LOADED");
LuaJIT.lua_gettable(ptr, -10000);
if ((LuaJIT.lua_toboolean(ptr, -1) == 0 ? false : true))
{
LuaJIT.lua_settop(ptr, -2);
throw new LuaException("There is already a LuaInterface.Lua instance associated with this Lua state");
}
LuaJIT.lua_settop(ptr, -2);
LuaJIT.lua_pushstring(ptr, "LUAINTERFACE LOADED");
LuaJIT.lua_pushboolean(ptr, 1);
LuaJIT.lua_settable(ptr, -10000);
this.luaState = ptr;
LuaJIT.lua_pushvalue(ptr, -10002);
LuaJIT.lua_getglobal(ptr, "luanet");
LuaJIT.lua_pushstring(ptr, "getmetatable");
LuaJIT.lua_getglobal(ptr, "getmetatable");
LuaJIT.lua_settable(ptr, -3);
LuaJIT.lua_replace(ptr, -10002);
this.translator = new ObjectTranslator(this, this.luaState);
LuaJIT.lua_replace(ptr, -10002);
LuaJIT.luaL_dostring(ptr, init_luanet);
this._StatePassed = true;
}
示例5: LuaMethodWrapper
/*
* Constructs the wrapper for a known method name
*/
public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType)
{
this.translator=translator;
this.methodName=methodName;
this.targetType=targetType;
if(targetType!=null)
extractTarget=translator.typeChecker.getExtractor(targetType);
this.bindingType=bindingType;
members=targetType.UnderlyingSystemType.GetMember(methodName,MemberTypes.Method,bindingType|BindingFlags.Public|BindingFlags.NonPublic);
}
示例6: LuaMethodWrapper
public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType)
{
this._LastCalledMethod = new MethodCache();
this._Translator = translator;
this._MethodName = methodName;
this._TargetType = targetType;
if (targetType != null)
{
this._ExtractTarget = translator.typeChecker.getExtractor(targetType);
}
this._BindingType = bindingType;
this._Members = targetType.UnderlyingSystemType.GetMember(methodName, MemberTypes.Method, (bindingType | BindingFlags.Public) | BindingFlags.IgnoreCase);
}
示例7: MetaFunctions
public MetaFunctions(ObjectTranslator translator)
{
this.translator = translator;
gcFunction = new LuaCSFunction(this.collectObject);
toStringFunction = new LuaCSFunction(this.toString);
indexFunction = new LuaCSFunction(this.getMethod);
newindexFunction = new LuaCSFunction(this.setFieldOrProperty);
baseIndexFunction = new LuaCSFunction(this.getBaseMethod);
callConstructorFunction = new LuaCSFunction(this.callConstructor);
classIndexFunction = new LuaCSFunction(this.getClassMethod);
classNewindexFunction = new LuaCSFunction(this.setClassFieldOrProperty);
execDelegateFunction = new LuaCSFunction(this.runFunctionDelegate);
}
示例8: dumpStack
public static void dumpStack(ObjectTranslator translator, IntPtr luaState)
{
int num = LuaDLL.lua_gettop(luaState);
for (int i = 1; i <= num; i++)
{
LuaTypes type = LuaDLL.lua_type(luaState, i);
if (type != LuaTypes.LUA_TTABLE)
{
LuaDLL.lua_typename(luaState, type);
}
LuaDLL.lua_tostring(luaState, i);
if (type == LuaTypes.LUA_TUSERDATA)
{
translator.getRawNetObject(luaState, i).ToString();
}
}
}
示例9: dumpStack
/// <summary>
/// Debug tool to dump the lua stack
/// </summary>
/// FIXME, move somewhere else
public static void dumpStack(ObjectTranslator translator, IntPtr luaState)
{
int depth = LuaDLL.lua_gettop(luaState);
Debug.WriteLine("lua stack depth: " + depth);
for (int i = 1; i <= depth; i++)
{
LuaTypes type = LuaDLL.lua_type(luaState, i);
// we dump stacks when deep in calls, calling typename while the stack is in flux can fail sometimes, so manually check for key types
string typestr = (type == LuaTypes.LUA_TTABLE) ? "table" : LuaDLL.lua_typename(luaState, type);
string strrep = LuaDLL.lua_tostring(luaState, i);
if (type == LuaTypes.LUA_TUSERDATA)
{
object obj = translator.getRawNetObject(luaState, i);
strrep = obj.ToString();
}
Debug.Print("{0}: ({1}) {2}", i, typestr, strrep);
}
}
示例10: CheckType
public CheckType(ObjectTranslator translator)
{
this.translator=translator;
extractSbyte=new ExtractValue(this.getAsSbyte);
extractByte=new ExtractValue(this.getAsByte);
extractShort=new ExtractValue(this.getAsShort);
extractUshort=new ExtractValue(this.getAsUshort);
extractInt=new ExtractValue(this.getAsInt);
extractUint=new ExtractValue(this.getAsUint);
extractLong=new ExtractValue(this.getAsLong);
extractUlong=new ExtractValue(this.getAsUlong);
extractDouble=new ExtractValue(this.getAsDouble);
extractChar=new ExtractValue(this.getAsChar);
extractFloat=new ExtractValue(this.getAsFloat);
extractDecimal=new ExtractValue(this.getAsDecimal);
extractBoolean=new ExtractValue(this.getAsBoolean);
extractString=new ExtractValue(this.getAsString);
extractFunction=new ExtractValue(this.getAsFunction);
extractTable=new ExtractValue(this.getAsTable);
extractUserdata=new ExtractValue(this.getAsUserdata);
extractObject=new ExtractValue(this.getAsObject);
}
示例11: LuaState
public LuaState()
{
// Create State
//Creates a new Lua state.
//It calls lua_newstate with an allocator based on the standard C realloc function and then sets a panic function (see §4.6) that prints an error message to the standard error output in case of fatal errors.
//Returns the new state, or NULL if there is a memory allocation error.
L = LuaDLL.luaL_newstate();
// Create LuaInterface library
//Opens all standard Lua libraries into the given state.
LuaDLL.luaL_openlibs(L);
LuaDLL.lua_pushstring(L, "LUAINTERFACE LOADED");
LuaDLL.lua_pushboolean(L, true);
//Does the equivalent to t[k] = v, where t is the value at the given index, v is the value at the top of the stack, and k is the value just below the top.
//This function pops both the key and the value from the stack. As in Lua, this function may trigger a metamethod for the "newindex" event (see §2.4).
LuaDLL.lua_settable(L, (int)LuaIndexes.LUA_REGISTRYINDEX);
LuaDLL.lua_newtable(L);
LuaDLL.lua_setglobal(L, "luanet");
LuaDLL.lua_pushvalue(L, (int)LuaIndexes.LUA_GLOBALSINDEX); //压入了_G表
LuaDLL.lua_getglobal(L, "luanet");
LuaDLL.lua_pushstring(L, "getmetatable");
LuaDLL.lua_getglobal(L, "getmetatable");
LuaDLL.lua_settable(L, -3);
LuaDLL.lua_pushstring(L, "rawget");
LuaDLL.lua_getglobal(L, "rawget");
LuaDLL.lua_settable(L, -3);
LuaDLL.lua_pushstring(L, "rawset");
LuaDLL.lua_getglobal(L, "rawset");
LuaDLL.lua_settable(L, -3);
// Set luanet as global for object translator
LuaDLL.lua_replace(L, (int)LuaIndexes.LUA_GLOBALSINDEX); //用luanet替换_G表
translator = new ObjectTranslator(this, L);
LuaDLL.lua_replace(L, (int)LuaIndexes.LUA_GLOBALSINDEX); //恢复_G表
translator.PushTranslator(L);
// We need to keep this in a managed reference so the delegate doesn't get garbage collected
panicCallback = new LuaCSFunction(LuaStatic.panic);
LuaDLL.lua_atpanic(L, panicCallback);
printFunction = new LuaCSFunction(LuaStatic.print);
LuaDLL.lua_pushstdcallcfunction(L, printFunction);
LuaDLL.lua_setfield(L, LuaIndexes.LUA_GLOBALSINDEX, "print");
loadfileFunction = new LuaCSFunction(LuaStatic.loadfile);
LuaDLL.lua_pushstdcallcfunction(L, loadfileFunction);
LuaDLL.lua_setfield(L, LuaIndexes.LUA_GLOBALSINDEX, "loadfile");
dofileFunction = new LuaCSFunction(LuaStatic.dofile);
LuaDLL.lua_pushstdcallcfunction(L, dofileFunction);
LuaDLL.lua_setfield(L, LuaIndexes.LUA_GLOBALSINDEX, "dofile");
// Insert our loader FIRST
loaderFunction = new LuaCSFunction(LuaStatic.loader);
LuaDLL.lua_pushstdcallcfunction(L, loaderFunction);
int loaderFunc = LuaDLL.lua_gettop(L);
LuaDLL.lua_getfield(L, LuaIndexes.LUA_GLOBALSINDEX, "package");
LuaDLL.lua_getfield(L, -1, "loaders");
int loaderTable = LuaDLL.lua_gettop(L);
// Shift table elements right
for (int e = LuaDLL.luaL_getn(L, loaderTable) + 1; e > 1; e--)
{
LuaDLL.lua_rawgeti(L, loaderTable, e - 1);
LuaDLL.lua_rawseti(L, loaderTable, e);
}
LuaDLL.lua_pushvalue(L, loaderFunc);
LuaDLL.lua_rawseti(L, loaderTable, 1);
LuaDLL.lua_settop(L, 0);
DoString(LuaStatic.init_luanet);
tracebackFunction = new LuaCSFunction(LuaStatic.traceback);
}
示例12: LuaMethodWrapper
/*
* Constructs the wrapper for a known MethodBase instance
*/
public LuaMethodWrapper(ObjectTranslator translator, object target, Type targetType, MethodBase method)
{
this.translator=translator;
this.target=target;
this.targetType=targetType;
this.method=method;
this.methodName=method.Name;
if(method.IsStatic) { bindingType=BindingFlags.Static; }
else { bindingType=BindingFlags.Instance; }
}
示例13: Lua
public Lua(IntPtr _luaState)
{
luaState = _luaState;
translator=new ObjectTranslator(this,luaState);
}
示例14: DelegateGenerator
public DelegateGenerator(ObjectTranslator translator,Type delegateType)
{
this.translator=translator;
this.delegateType=delegateType;
}
示例15: ClassGenerator
public ClassGenerator(ObjectTranslator translator,Type klass)
{
this.translator=translator;
this.klass=klass;
}