本文整理汇总了C#中ILuaState.PushLightUserData方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.PushLightUserData方法的具体用法?C# ILuaState.PushLightUserData怎么用?C# ILuaState.PushLightUserData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.PushLightUserData方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getEventVO
public static int getEventVO(ILuaState luaState)
{
BattleEventBase evt = (BattleEventBase)luaState.ToUserData(-1);
if ( evt == null )
{
luaState.PushNil();
}
else
{
luaState.PushLightUserData(evt.getEventVO());
}
return 1;
}
示例2: PushRawValue
public static int PushRawValue( ILuaState lua, object o, Type t )
{
switch( t.FullName )
{
case "System.Boolean": {
lua.PushBoolean( (bool)o );
return 1;
}
case "System.Char": {
lua.PushString( ((char)o).ToString() );
return 1;
}
case "System.Byte": {
lua.PushNumber( (byte)o );
return 1;
}
case "System.SByte": {
lua.PushNumber( (sbyte)o );
return 1;
}
case "System.Int16": {
lua.PushNumber( (short)o );
return 1;
}
case "System.UInt16": {
lua.PushNumber( (ushort)o );
return 1;
}
case "System.Int32": {
lua.PushNumber( (int)o );
return 1;
}
case "System.UInt32": {
lua.PushNumber( (uint)o );
return 1;
}
case "System.Int64": {
throw new NotImplementedException();
}
case "System.UInt64": {
lua.PushUInt64( (ulong)o );
return 1;
}
case "System.Single": {
lua.PushNumber( (float)o );
return 1;
}
case "System.Double": {
lua.PushNumber( (double) o );
return 1;
}
case "System.Decimal": {
lua.PushLightUserData( (decimal)o );
return 1;
}
case "System.String": {
lua.PushString( o as string );
return 1;
}
case "System.Object": {
lua.PushLightUserData( (object)o );
return 1;
}
default: {
// UnityEngine.Debug.Log( "==========" +
// " Name:" + t.Name +
// " FullName:" + t.FullName );
lua.PushLightUserData( o );
return 1;
}
}
}
示例3: PushReturnValue
protected override int PushReturnValue( ILuaState lua, object o )
{
lua.PushLightUserData( o );
return 1;
}
示例4: GetMethodAux
private static int GetMethodAux( ILuaState lua, BindingFlags flags )
{
var t = (Type)lua.ToUserData(1);
var mname = lua.ToString(2);
var n = lua.RawLen(3);
var types = new Type[n];
for( int i=0; i<n; ++i )
{
lua.RawGetI( 3, i+1 );
types[i] = (Type)lua.ToUserData(-1);
lua.Pop(1);
}
var minfo = t.GetMethod( mname,
flags,
null,
CallingConventions.Any,
types,
null
);
if( minfo == null )
{
return 0;
}
else
{
var ffiMethod = new FFIMethodInfo(minfo);
lua.PushLightUserData( ffiMethod );
return 1;
}
}
示例5: FFI_GetType
private static int FFI_GetType( ILuaState lua )
{
string typename = lua.ToString(1);
var t = GetType(typename);
// UnityEngine.Debug.Log("GET TYPE:" + typename + " => " + t );
if( t != null )
lua.PushLightUserData(t);
else
lua.PushNil();
return 1;
}
示例6: FFI_GetStaticProp
private static int FFI_GetStaticProp( ILuaState lua )
{
var t = (Type)lua.ToUserData(1);
var name = lua.ToString(2);
var pinfo = t.GetProperty( name,
BindingFlags.Static |
BindingFlags.Public );
// UnityEngine.Debug.Log("FFI_GetStaticProp t:"+t+" name:"+name+" pinfo:"+pinfo);
if( pinfo == null )
throw new Exception("GetProperty failed:"+name);
lua.PushLightUserData(pinfo);
return 1;
}
示例7: FFI_GetField
private static int FFI_GetField( ILuaState lua )
{
var t = (Type)lua.ToUserData(1);
var name = lua.ToString(2);
var finfo = t.GetField( name,
BindingFlags.Instance |
BindingFlags.Public );
if( finfo == null )
throw new Exception("GetField failed:"+name);
// UnityEngine.Debug.Log("FFI_GetField t:"+t+" name:"+name+" finfo:"+finfo);
lua.PushLightUserData(finfo);
return 1;
}
示例8: FFI_GetConstructor
private static int FFI_GetConstructor( ILuaState lua )
{
var t = (Type)lua.ToUserData(1);
var n = lua.RawLen(2);
var types = new Type[n];
for( int i=0; i<n; ++i )
{
lua.RawGetI( 2, i+1 );
types[i] = (Type)lua.ToUserData(-1);
lua.Pop( 1 );
}
var cinfo = t.GetConstructor( types );
var ffiMethod = new FFIConstructorInfo(cinfo);
lua.PushLightUserData( ffiMethod );
return 1;
}
示例9: getEventVOProperty
public static int getEventVOProperty(ILuaState luaState)
{
BattleEventBase evt = (BattleEventBase)luaState.ToUserData(-2);
if (evt == null)
{
luaState.PushNil();
}
else
{
BattleConsts.Property propId = (BattleConsts.Property)luaState.ToInteger(-1);
object prop = evt.getEventVOProperty(propId);
if ( prop == null )
{
luaState.PushNil();
}
else
{
luaState.PushLightUserData(prop);
}
}
return 1;
}
示例10: getVOProperty
/// <summary>
/// 获取IBattleVO接口中的属性
/// </summary>
/// <param name="luaState"></param>
/// <returns></returns>
public static int getVOProperty(ILuaState luaState)
{
IBattleVO vo = (IBattleVO)luaState.ToUserData(-2);
if (vo == null)
{
luaState.PushNil();
}
else
{
BattleConsts.Property propId = (BattleConsts.Property)luaState.ToInteger(-1);
object prop = vo.getProperty(propId);
if (prop == null)
{
luaState.PushNil();
}
else
{
// todo 暂时使用is来判断
// 以后可能会加入全局hash
if ( prop is int )
{
luaState.PushInteger((int)prop);
}
else if ( prop is bool )
{
luaState.PushBoolean((bool)prop);
}
else if ( prop is string )
{
luaState.PushString((string)prop);
}
else
{
luaState.PushLightUserData(prop);
}
}
}
return 1;
}
示例11: FFI_GetProp
private static int FFI_GetProp( ILuaState lua )
{
var t = (Type)lua.ToUserData(1);
var name = lua.ToString(2);
var pinfo = t.GetProperty( name,
BindingFlags.Instance |
BindingFlags.Public );
if( pinfo == null )
throw new Exception("GetProperty failed:"+name);
lua.PushLightUserData(pinfo);
return 1;
}
示例12: FFI_GetType
private static int FFI_GetType( ILuaState lua )
{
string typename = lua.ToString(1);
var t = GetType(typename);
if( t != null )
lua.PushLightUserData(t);
else
lua.PushNil();
return 1;
}