当前位置: 首页>>代码示例>>C#>>正文


C# Thread.SetReturnValues方法代码示例

本文整理汇总了C#中System.Thread.SetReturnValues方法的典型用法代码示例。如果您正苦于以下问题:C# Thread.SetReturnValues方法的具体用法?C# Thread.SetReturnValues怎么用?C# Thread.SetReturnValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Thread的用法示例。


在下文中一共展示了Thread.SetReturnValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BGetMetatable

        private static int BGetMetatable( Thread l )
        {
            var mt = GetMetatableImp( l[1] );

            Value vmt;

            if( mt != null )
            {
                int loc = mt.FindValue( Literals.TagInfo_Metatable );
                if( loc != 0 )
                    mt.ReadValue( loc, out vmt );
                else
                    vmt = mt;
            }
            else
            {
                vmt = new Value();
            }

            return l.SetReturnValues( vmt );
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:21,代码来源:BaseLib.cs

示例2: MRandom

            public int MRandom( Thread l )
            {
                if( rng == null )
                    rng = new Random();

                double max, min, n = rng.NextDouble();

                switch( l.StackTop )
                {
                case 0:
                    break;

                case 1:
                    max = (double)l[1];
                    if( max < 1 )
                        throw new ArgumentException( "interval is empty" );

                    n = Math.Floor( n * max ) + 1;
                    break;

                case 2:
                    min = (double)l[1];
                    max = (double)l[2];

                    if( min > max )
                        throw new ArgumentException( "interval is empty" );

                    n = Math.Floor( n * (max - min + 1) ) + min;
                    break;

                default:
                    throw new ArgumentException( "wrong number of arguments" );
                }

                return l.SetReturnValues( n );
            }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:36,代码来源:MathLib.cs

示例3: BCollectGarbage_Nop

        private static int BCollectGarbage_Nop( Thread l )
        {
            switch( (GcOpt)Helpers.CheckOpt( l[1], (int)GcOpt.Collect, GcOptNames ) )
            {
            case GcOpt.Count:
                return l.SetReturnValues( 0, 0 );

            default:
                break;
            }

            return l.SetReturnValues( 0 );
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:13,代码来源:BaseLib.cs

示例4: BToString

 private static int BToString( Thread l )
 {
     var ret = ToStringCore( l[1], l );
     return l.SetReturnValues( ret );
 }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:5,代码来源:BaseLib.cs

示例5: SChar

 private static int SChar( Thread l )
 {
     var buf = LString.InternalAllocBuffer( l.StackTop );
     for( int i = LString.BufferDataOffset; i < buf.Length; i++ )
     {
         var cch = (int)l[i - LString.BufferDataOffset + 1];
         if( cch < 0 || cch > 0xFF )
             throw new ArgumentException( "value out of range" );
         buf[i] = (byte)cch;
     }
     return l.SetReturnValues( LString.InternalFinishBuffer( buf ) );
 }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:12,代码来源:StringLib.cs

示例6: BNext

        private static int BNext( Thread l )
        {
            var tbl = (Table)l[1];
            if( tbl == null )
                throw new ArgumentNullException();

            Value key = l[2];
            Value val;

            if( tbl.GetNext( ref key, out val ) )
                return l.SetReturnValues( key, val );
            else
                return l.SetNilReturnValue();
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:14,代码来源:BaseLib.cs

示例7: BSelect

        private static int BSelect( Thread l )
        {
            var selector = l[1];

            if( selector == Literals.Symbol_Hash )
                return l.SetReturnValues( l.StackTop - 1 );

            var sel = (int)selector;
            var top = l.StackTop;

            if( sel < 0 )
                sel = top + sel;
            else if( sel > top )
                sel = top;

            if( sel <= 1 )
                throw new ArgumentOutOfRangeException( "index", "index out of range" );

            return top - sel;
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:20,代码来源:BaseLib.cs

示例8: SUpper

        private static int SUpper( Thread l )
        {
            var str = (LString)l[1];
            var strDat = str.InternalData;

            var ret = LString.InternalAllocBuffer( str.Length );

            for( int i = LString.BufferDataOffset; i < ret.Length; i++ )
            {
                var ch = strDat[i];
                if( ch >= (byte)'a' && ch <= (byte)'z' )
                    ch = (byte)((byte)'A' + (ch - (byte)'a'));
                ret[i] = ch;
            }

            return l.SetReturnValues( LString.InternalFinishBuffer( ret ) );
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:17,代码来源:StringLib.cs

示例9: TRemove

        private static int TRemove( Thread l )
        {
            var t = (Table)l[1];

            int pos, n = t.GetLen();

            switch( l.StackTop )
            {
            case 1:
                pos = n;
                break;

            case 2:
                pos = (int)l[2];
                break;

            default:
                throw new ArgumentException( "Incorrect number of args for table.remove." );
            }

            var ret = t[pos];

            for( int i = pos; i < n; i++ )
                t[i] = t[i + 1];
            t[n] = new Value();

            return l.SetReturnValues( ret );
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:28,代码来源:TableLib.cs

示例10: SRep

        private static int SRep( Thread l )
        {
            var str = (LString)l[1];
            int n = (int)l[2];

            if( n == 0 )
                return l.SetReturnValues( LString.Empty );

            if( n < 0 )
                throw new ArgumentOutOfRangeException( "negative repeat count" );

            var sep = l.StackTop >= 3 ? (LString)l[3] : LString.Empty;

            if( n == 1 )
                return l.SetReturnValues( str );

            int strOfs, strLen, sepOfs, sepLen;
            byte[] strBuf, sepBuf;

            str.UnsafeGetDataBuffer( out strBuf, out strOfs, out strLen );
            sep.UnsafeGetDataBuffer( out sepBuf, out sepOfs, out sepLen );

            var retLen = strLen * n + sepLen * (n - 1);

            var retBuf = LString.InternalAllocBuffer( retLen );
            int retOfs = LString.BufferDataOffset;

            Buffer.BlockCopy( strBuf, strOfs, retBuf, retOfs, strLen );

            if( sepLen == 0 )
            {
                for( int i = 1; i < n; i++ )
                    Buffer.BlockCopy( strBuf, strOfs, retBuf, retOfs += strLen, strLen );
            }
            else
            {
                for( int i = 1; i < n; i++ )
                {
                    Buffer.BlockCopy( sepBuf, sepOfs, retBuf, retOfs += strLen, sepLen );
                    Buffer.BlockCopy( strBuf, strOfs, retBuf, retOfs += sepLen, strLen );
                }
            }

            Debug.Assert( retOfs + strLen == retBuf.Length );

            return l.SetReturnValues( LString.InternalFinishBuffer( retBuf ) );
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:47,代码来源:StringLib.cs

示例11: SSub

        private static int SSub( Thread l )
        {
            var str = (LString)l[1];

            var beg = StrIdxArg( str, (int)l[2] );
            var end = l.StackTop >= 3 ? StrIdxArg( str, (int)l[3] ) : str.Length - 1;

            if( beg <= end )
                return l.SetReturnValues( str.Substring( beg, end - beg + 1 ) );
            else
                return l.SetReturnValues( LString.Empty );
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:12,代码来源:StringLib.cs

示例12: SLen

 private static int SLen( Thread l )
 {
     var str = (LString)l[1];
     return l.SetReturnValues( str.Length );
 }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:5,代码来源:StringLib.cs

示例13: SGsub


//.........这里部分代码省略.........
                        break;

                    case LValueType.String:
                        //need to handle escape sequences
                        {
                            var sb = (byte[])subst.RefVal;
                            for( int i = LString.BufferDataOffset; i < sb.Length; i++ )
                            {
                                var ch = sb[i];

                                if( ch != (byte)'%' )
                                {
                                    strBuilder.Append( ch );
                                    continue;
                                }

                                if( ++i == sb.Length )
                                    throw new ArgumentException( "Invalid use of % in replacement string" );

                                ch = sb[i];

                                if( ch == (byte)'%' )
                                {
                                    strBuilder.Append( ch );
                                    continue;
                                }

                                switch( ch )
                                {
                                case (byte)'0':
                                    strBuilder.Append( ms.Str, sPos, e - sPos );
                                    break;

                                case (byte)'1':
                                case (byte)'2':
                                case (byte)'3':
                                case (byte)'4':
                                case (byte)'5':
                                case (byte)'6':
                                case (byte)'7':
                                case (byte)'8':
                                case (byte)'9':
                                    {
                                        int idx = ch - (byte)'1';
                                        PushCapture( ref ms, idx, sPos, e );
                                        substVal = l.PopValue();
                                        l.ConvertToString( ref substVal );
                                        strBuilder.Append( (LString)substVal );
                                    }
                                    break;

                                default:
                                    throw new ArgumentException( "Invalid use o f% in replacement string" );
                                }
                            }
                        }

                        substVal = new Value(); //hush, little compiler
                        break;

                    default:
                        substVal = new Value();
                        break;
                    }

                    if( subTy != LValueType.String )
                    {
                        //strings already appended, need to handle this case now

                        if( !substVal.ToBool() )
                        {
                            strBuilder.Append( ms.Str, sPos, e - sPos );
                        }
                        else
                        {
                            l.ConvertToString( ref substVal );
                            strBuilder.Append( (LString)substVal );
                        }
                    }
                }

                if( e != -1 && e > sPos )
                    sPos = e;
                else if( sPos < ms.Str.Length )
                    strBuilder.Append( ms.Str[sPos++] );
                else
                    break;

                if( anchor )
                    break;
            }

            strBuilder.Append( ms.Str, sPos, ms.Str.Length - sPos );
            var ret = strBuilder.ToLString();

            l.RetireStrBuilder( strBuilder );
            RetireMatchState( ref ms );

            return l.SetReturnValues( ret, n );
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:101,代码来源:StringLib.cs

示例14: SGMatch

        private static int SGMatch( Thread l )
        {
            var str = (LString)l[1];
            var pat = (LString)l[2];

            return l.SetReturnValues( (Callable)new GMatcher( str, pat ) );
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:7,代码来源:StringLib.cs

示例15: BINext

        private static int BINext( Thread l )
        {
            l.StackTop = 2;

            var tbl = (Table)l[1];
            if( tbl == null )
                throw new InvalidCastException();

            var key = (int)(double)l[2] + 1;
            Value val;

            if( tbl.TryGetValue( key, out val ) )
                return l.SetReturnValues( key, val );
            else
                return l.SetNilReturnValue();
        }
开发者ID:henchmeninteractive,项目名称:HenchLua,代码行数:16,代码来源:BaseLib.cs


注:本文中的System.Thread.SetReturnValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。