public override int OnCall( Context ctx )
{
NI.FuncName( ctx.ctx, name );
bool gotthis = ctx.Method();
if( !gotthis && !thisMethodInfo.IsStatic )
{
// if 'this' was not passed but the method is not static, error
ctx.Msg( MsgLevel.ERROR, "Expected 'this' for non-static method" );
return RC.EINVAL;
}
object thisvar = null;
if( gotthis )
{
parseVarParams[ 0 ] = null;
parseVarParams[ 1 ] = ctx.StackItem( 0 );
parseVarThis.Invoke( ctx, parseVarParams );
thisvar = parseVarParams[ 0 ];
}
int outArg = 0;
int inArg = gotthis ? 1 : 0;
foreach( MethodInfo pva in parseVarArgs )
{
if( pva.Name == "_ParseVar_CallingThread" )
{
callArgs[ outArg ] = ctx;
}
else
{
parseVarParams[ 0 ] = null;
parseVarParams[ 1 ] = ctx.StackItem( inArg++ );
pva.Invoke( ctx, parseVarParams );
callArgs[ outArg ] = parseVarParams[ 0 ];
}
outArg++;
}
ctx.PushObj( thisMethodInfo.Invoke( thisvar, callArgs ) );
// pooled resource cleanup
parseVarParams[0] = null;
parseVarParams[1] = null;
for( int i = 0; i < parseVarArgs.Length; ++i )
callArgs[ i ] = null;
return 1;
}