本文整理汇总了C#中ILuaState.RawSetI方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.RawSetI方法的具体用法?C# ILuaState.RawSetI怎么用?C# ILuaState.RawSetI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.RawSetI方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TBL_Insert
private static int TBL_Insert( ILuaState lua )
{
int e = AuxGetN(lua, 1) + 1; // first empty element
int pos; // where to insert new element
switch( lua.GetTop() )
{
case 2: // called with only 2 arguments
{
pos = e; // insert new element at the end
break;
}
case 3:
{
pos = lua.L_CheckInteger(2); // 2nd argument is the position
if( pos > e ) e = pos; // `grow' array if necessary
for( int i=e; i>pos; --i ) // move up elements
{
lua.RawGetI( 1, i-1 );
lua.RawSetI( 1, i ); // t[i] = t[i-1]
}
break;
}
default:
{
return lua.L_Error( "wrong number of arguments to 'insert'" );
}
}
lua.RawSetI( 1, pos ); // t[pos] = v
return 0;
}
示例2: FFI_ParseSignature
// return `ReturnType', `FuncName', `ParameterTypes'
private static int FFI_ParseSignature( ILuaState lua )
{
var signature = lua.ToString(1);
var result = FuncSignatureParser.Parse( lua, signature );
if( result.ReturnType != null )
lua.PushString( result.ReturnType );
else
lua.PushNil();
lua.PushString( result.FuncName );
if( result.ParameterTypes != null ) {
lua.NewTable();
for( int i=0; i<result.ParameterTypes.Length; ++i ) {
lua.PushString( result.ParameterTypes[i] );
lua.RawSetI( -2, i+1 );
}
}
else {
lua.PushNil();
}
return 3;
}
示例3: Set2
// quick sort ////////////////////////////////////////////////////////
private static void Set2( ILuaState lua, int i, int j )
{
lua.RawSetI( 1, i );
lua.RawSetI( 1, j );
}
示例4: TBL_Pack
private static int TBL_Pack( ILuaState lua )
{
int n = lua.GetTop(); // number of elements to pack
lua.CreateTable( n, 1 ); // create result table
lua.PushInteger( n );
lua.SetField( -2, "n" ); // t.n = number of elements
if( n > 0 ) // at least one element?
{
lua.PushValue( 1 );
lua.RawSetI( -2, 1 ); // insert first element
lua.Replace( 1 ); // move table into index 1
for( int i=n; i>=2; --i ) // assign other elements
lua.RawSetI( 1, i );
}
return 1; // return table
}
示例5: TBL_Remove
private static int TBL_Remove( ILuaState lua )
{
int e = AuxGetN(lua, 1);
int pos = lua.L_OptInt( 2, e );
if( !(1 <= pos && pos <= e) ) // position is outside bounds?
return 0; // nothing to remove
lua.RawGetI(1, pos); /* result = t[pos] */
for( ; pos<e; ++pos )
{
lua.RawGetI( 1, pos+1 );
lua.RawSetI( 1, pos ); // t[pos] = t[pos+1]
}
lua.PushNil();
lua.RawSetI( 1, e ); // t[2] = nil
return 1;
}
示例6: CreateSearchersTable
private static void CreateSearchersTable( ILuaState lua )
{
CSharpFunctionDelegate[] searchers = new CSharpFunctionDelegate[]
{
SearcherPreload,
SearcherLua,
};
lua.CreateTable( searchers.Length, 0 );
for( int i=0; i<searchers.Length; ++i )
{
lua.PushValue( -2 ); // set `package' as upvalue for all searchers
lua.PushCSharpClosure( searchers[i], 1 );
lua.RawSetI( -2, i+1 );
}
}
示例7: createargtable
/// <summary>
/// Create the 'arg' table, which stores all arguments from the
/// command line ('argv'). It should be aligned so that, at index 0,
/// it has 'argv[script]', which is the script name. The arguments
/// to the script (everything after 'script') go to positive indices;
/// other arguments (before the script name) go to negative indices.
/// If there is no script name, assume interpreter's name as base.
/// </summary>
static void createargtable(ILuaState L, String[] argv, int argc, int script)
{
int i, narg;
if (script == argc) script = 0; /* no script name? */
narg = argc - (script + 1); /* number of positive indices */
L.CreateTable(narg, script + 1);
for (i = 0; i < argc; i++)
{
L.PushString(argv[i]);
L.RawSetI(-2, i - script);
}
L.SetGlobal("arg");
}