Ejemplo n.º 1
0
        /// <summary>
        /// 创建表格
        /// </summary>
        /// <param name="connection">SQL连接</param>
        /// <param name="table">表格信息</param>
        internal unsafe override bool createTable(DbConnection connection, table table)
        {
            string name = table.Columns.Name;

            if (connection != null && name != null && name.Length != 0 && table.Columns != null && table.Columns.Columns.Length != 0)
            {
                pointer buffer = fastCSharp.sql.client.SqlBuffers.Get();
                try
                {
                    using (charStream sqlStream = new charStream(buffer.Char, fastCSharp.sql.client.SqlBufferSize))
                    {
                        sqlStream.SimpleWriteNotNull("create table ");
                        sqlStream.SimpleWriteNotNull(name);
                        sqlStream.SimpleWriteNotNull(" (");
                        bool isNext = false;
                        foreach (column column in table.Columns.Columns)
                        {
                            if (isNext)
                            {
                                sqlStream.Write(',');
                            }
                            sqlStream.SimpleWriteNotNull(column.SqlName);
                            sqlStream.Write(' ');
                            sqlStream.Write(column.DbType.getSqlTypeName());
                            isNext = true;
                        }
                        sqlStream.Write(')');
                        return(executeNonQuery(connection, sqlStream.ToString()) >= 0);
                    }
                }
                finally { fastCSharp.sql.client.SqlBuffers.Push(ref buffer); }
            }
            return(false);
        }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     point += Demo1;
     point += Demo2;
     point.Invoke();
     Console.Read();
 }
Ejemplo n.º 3
0
            private static unsafe void toJson(fastCSharp.emit.jsonSerializer toJsoner, cardMessage value)
            {
                if (value.card_ext.signature == null)
                {
                    log.Default.Add("卡券扩展 签名为空", new System.Diagnostics.StackFrame(), true);
                    fastCSharp.web.ajax.WriteObject(toJsoner.UnsafeCharStream);
                }
                else
                {
                    toJsoner.UnsafeWriteFirstName("card_id");
                    toJsoner.UnsafeToJson(value.card_id);
                    toJsoner.UnsafeWriteNextName("card_ext");
                    fastCSharp.emit.jsonSerializer cardToJsoner = typePool <fastCSharp.emit.jsonSerializer> .Pop() ?? new fastCSharp.emit.jsonSerializer();

                    pointer buffer = fastCSharp.unmanagedPool.StreamBuffers.Get();
                    try
                    {
                        using (charStream cardJsonStream = cardToJsoner.UnsafeCharStream)
                        {
                            cardJsonStream.UnsafeReset((byte *)buffer.Char, fastCSharp.unmanagedPool.StreamBuffers.Size);
                            cardToJsoner.UnsafeToJsonNotNull(value.card_ext, toJsoner.UnsafeConfig);
                            fastCSharp.web.ajax.UnsafeFormatJavascript(cardJsonStream, toJsoner.UnsafeCharStream);
                        }
                    }
                    finally
                    {
                        fastCSharp.unmanagedPool.StreamBuffers.Push(ref buffer);
                        toJsoner.UnsafeFree();
                    }
                    toJsoner.UnsafeCharStream.Write('}');
                }
            }
Ejemplo n.º 4
0
        // context menu clicked
        private void edit_item_clicked(object sender, EventArgs e)
        {
            // current position in [][]
            int rowindex    = gridView.CurrentCell.RowIndex;
            int columnindex = gridView.CurrentCell.ColumnIndex;

            List <string> data = new List <string>();

            for (int i = 0; i < gridView.ColumnCount; i++)
            {
                string val = null;
                if (gridView.Rows[rowindex].Cells[i].Value != null)
                {
                    val = gridView.Rows[rowindex].Cells[i].Value.ToString();
                }
                data.Add(val);
            }

            // using delegate send data to another form
            frmDeleteDetail frm = new frmDeleteDetail(this);

            sendDataSelected += new pointer(frm.getDataSender);
            sendDataSelected(data);

            frm.ShowDialog();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 获取类型名称
 /// </summary>
 /// <param name="type">类型</param>
 /// <returns>类型名称</returns>
 public unsafe string GetName(Type type)
 {
     if (type.IsArray)
     {
         pointer buffer = fastCSharp.unmanagedPool.TinyBuffers.Get();
         try
         {
             using (NameStream = new charStream(buffer.Char, fastCSharp.unmanagedPool.TinyBuffers.Size >> 1))
             {
                 array(type, false);
                 return(NameStream.ToString());
             }
         }
         finally { fastCSharp.unmanagedPool.TinyBuffers.Push(ref buffer); }
     }
     if (type.IsGenericType)
     {
         pointer buffer = fastCSharp.unmanagedPool.TinyBuffers.Get();
         try
         {
             using (NameStream = new charStream(buffer.Char, fastCSharp.unmanagedPool.TinyBuffers.Size >> 1))
             {
                 genericName(type);
                 return(NameStream.ToString());
             }
         }
         finally { fastCSharp.unmanagedPool.TinyBuffers.Push(ref buffer); }
     }
     return(type.Name);
 }
Ejemplo n.º 6
0
        unsafe static http()
        {
            uniqueTypes = unmanaged.GetStatic(1 << 4, true);
            uint  code;
            byte *methodBufferFixed = (byte *)&code;

            foreach (methodType method in System.Enum.GetValues(typeof(fastCSharp.web.http.methodType)))
            {
                if (method != methodType.Unknown)
                {
                    string methodString = method.ToString();
                    fixed(char *methodFixed = methodString)
                    {
                        byte *write = methodBufferFixed, end = methodBufferFixed;

                        if (methodString.Length >= sizeof(int))
                        {
                            end += sizeof(int);
                        }
                        else
                        {
                            code = 0x20202020U;
                            end += methodString.Length;
                        }
                        for (char *read = methodFixed; write != end; *write++ = (byte)*read++)
                        {
                            ;
                        }
                        uniqueTypes.Byte[((code >> 12) ^ code) & ((1U << 4) - 1)] = (byte)method;
                    }
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取Excel客户端
        /// </summary>
        /// <returns>Excel客户端</returns>
        public unsafe client GetClient()
        {
            provider provider = Enum <providerType, provider> .Array((byte)Provider);

            pointer buffer = fastCSharp.sql.client.SqlBuffers.Get();

            try
            {
                using (charStream connectionStream = new charStream(buffer.Char, fastCSharp.sql.client.SqlBufferSize))
                {
                    connectionStream.SimpleWriteNotNull("Provider=");
                    connectionStream.Write(provider.Name);
                    connectionStream.SimpleWriteNotNull(";Data Source=");
                    connectionStream.Write(DataSource);
                    if (Password != null)
                    {
                        connectionStream.WriteNotNull(";Database Password="******";Extended Properties='");
                    connectionStream.Write(provider.Excel);
                    connectionStream.WriteNotNull(IsTitleColumn ? ";HDR=YES;IMEX=" : ";HDR=NO;IMEX=");
                    number.ToString((byte)Intermixed, connectionStream);
                    connectionStream.Write('\'');
                    return((client) new sql.connection {
                        Type = type.Excel, Connection = connectionStream.ToString()
                    }.Client);
                }
            }
            finally { fastCSharp.sql.client.SqlBuffers.Push(ref buffer); }
        }
Ejemplo n.º 8
0
		public udp_hdr(byte[] buffer, int offset)
			: base(buffer, offset)
		{
			_src = new pointer(data, offset + 0); /* ushort */
			_dest = new pointer(data, offset + 2); /* ushort */
			_len = new pointer(data, offset + 4); /* ushort */
			_chksum = new pointer(data, offset + 6); /* ushort */
		}
Ejemplo n.º 9
0
 /* Build a timestamp option (12 bytes long) at the specified options pointer)
  *
  * @param pcb tcp_pcb
  * @param opts option pointer where to store the timestamp option
  */
 private void tcp_build_timestamp_option(tcp_pcb pcb, pointer opts)
 {
     /* Pad with two NOP options to make everything nicely aligned */
     opts.SetValue((uint)lwip.PP_HTONL(0x0101080A));
     opts += sizeof(uint);
     opts.SetValue((uint)lwip.lwip_htonl(lwip.sys.sys_now()));
     opts += sizeof(uint);
     opts.SetValue((uint)lwip.lwip_htonl(pcb.ts_recent));
 }
Ejemplo n.º 10
0
 public TMemNode(pointer data, int size)
     : base(data)
 {
     #if DEBUG
     m_Header = new _CrtMemBlockHeader(this, 0, null, null, "", 0, size,
         _CrtMemBlockHeader._NORMAL_BLOCK, 0);
     #endif
     Previous = null;
     Next = null;
     Size = size;
 }
Ejemplo n.º 11
0
 static connection()
 {
     if (config.sql.Default.CheckConnection.Length != 0)
     {
         checkConnectionAssemblyNameMap        = new String.asciiMap(unmanaged.Get(String.asciiMap.mapBytes), ".,-").Pointer;
         AppDomain.CurrentDomain.AssemblyLoad += checkConnection;
         foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
         {
             checkConnection(assembly);
         }
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 查询对象集合
        /// </summary>
        /// <typeparam name="valueType">对象类型</typeparam>
        /// <typeparam name="modelType">成员位图类型</typeparam>
        /// <param name="sqlTool">SQL操作工具</param>
        /// <param name="query">查询信息</param>
        /// <param name="keyName">关键之名称</param>
        /// <param name="memberMap">成员位图</param>
        /// <param name="sqlStream"></param>
        /// <returns></returns>
        private unsafe string selectKeys <valueType, modelType>
            (fastCSharp.emit.sqlTable.sqlTool <valueType, modelType> sqlTool, selectQuery <modelType> query, string keyName, fastCSharp.code.memberMap <modelType> memberMap, charStream sqlStream)
            where valueType : class, modelType
            where modelType : class
        {
            pointer buffer = fastCSharp.sql.client.SqlBuffers.Get();

            try
            {
                using (sqlStream)
                {
                    sqlStream.UnsafeReset(buffer.Byte, SqlBufferSize << 1);
                    sqlStream.SimpleWriteNotNull("select ");
                    sqlModel <modelType> .GetNames(sqlStream, memberMap);

                    sqlStream.SimpleWriteNotNull(" from[");
                    sqlStream.SimpleWriteNotNull(sqlTool.TableName);
                    sqlStream.WriteNotNull("]with(nolock)where ");
                    sqlStream.SimpleWriteNotNull(keyName);
                    sqlStream.SimpleWriteNotNull(" in(select ");
                    sqlStream.SimpleWriteNotNull(keyName);
                    sqlStream.SimpleWriteNotNull(" from(select ");
                    sqlStream.SimpleWriteNotNull(keyName);
                    sqlStream.WriteNotNull(",row_number()over(");
                    int startIndex = sqlStream.Length;
                    query.WriteOrder(sqlTool, sqlStream);
                    int count = sqlStream.Length - startIndex;
                    sqlStream.SimpleWriteNotNull(")as ");
                    sqlStream.SimpleWriteNotNull(orderOverName);
                    sqlStream.SimpleWriteNotNull(" from[");
                    sqlStream.SimpleWriteNotNull(sqlTool.TableName);
                    sqlStream.SimpleWriteNotNull("]with(nolock)");
                    if (query.WriteWhereOnly(sqlTool, sqlStream))
                    {
                        sqlStream.SimpleWriteNotNull(")as T where ");
                        sqlStream.SimpleWriteNotNull(orderOverName);
                        sqlStream.SimpleWriteNotNull(" between ");
                        number.ToString(query.SkipCount, sqlStream);
                        sqlStream.SimpleWriteNotNull(" and ");
                        number.ToString(query.SkipCount + query.GetCount - 1, sqlStream);
                        sqlStream.Write(')');
                        if (count != 0)
                        {
                            sqlStream.Write(sqlStream.Char + startIndex, count);
                        }
                        return(sqlStream.ToString());
                    }
                }
            }
            finally { fastCSharp.sql.client.SqlBuffers.Push(ref buffer); }
            return(null);
        }
Ejemplo n.º 13
0
        public _CrtMemBlockHeader(pointer src, int offset,
			_CrtMemBlockHeader pBlockHeaderNext, _CrtMemBlockHeader pBlockHeaderPrev,
			string szFileName, int nLine, int nDataSize, int nBlockUse, int lRequest)
            : base(src, offset)
        {
            this.pBlockHeaderNext = pBlockHeaderNext;
            this.pBlockHeaderPrev = pBlockHeaderPrev;
            this.szFileName = szFileName;
            this.nLine = nLine;
            this.nDataSize = nDataSize;
            this.nBlockUse = nBlockUse;
            this.lRequest = lRequest;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 创建SQL
        /// </summary>
        /// <param name="expression">委托关联表达式</param>
        /// <returns>SQL表达式</returns>
        internal unsafe string Create(LambdaExpression expression)
        {
            pointer buffer = fastCSharp.sql.client.SqlBuffers.Get();

            try
            {
                using (stream = new charStream(buffer.Char, fastCSharp.sql.client.SqlBufferSize))
                {
                    create(expression, stream);
                    return(stream.ToString());
                }
            }
            finally { fastCSharp.sql.client.SqlBuffers.Push(ref buffer); }
        }
Ejemplo n.º 15
0
        public MemoryPoolFixedsize(ID mpfid, ref T_CMPF pk_cmpf, Nucleus pNucleus)
        {
            pointer Block;

            m_MpfID = mpfid;
            m_cmpf = pk_cmpf;
            m_Nucleus = pNucleus;

            for (int i = 0; i < pk_cmpf.blkcnt; i++) {
                Block = new pointer(pk_cmpf.addr, i * pk_cmpf.blksz);
                pointer.memset(Block, 0, pk_cmpf.blksz);
                m_MpfQueue.AddLast(Block);
            }
        }
Ejemplo n.º 16
0
            /// <summary>
            /// 获取类型名称
            /// </summary>
            /// <param name="type">类型</param>
            /// <returns>类型名称</returns>
            public unsafe string GetFullName(Type type)
            {
                if (type.IsArray)
                {
                    pointer buffer = fastCSharp.unmanagedPool.TinyBuffers.Get();
                    try
                    {
                        using (NameStream = new charStream(buffer.Char, fastCSharp.unmanagedPool.TinyBuffers.Size >> 1))
                        {
                            array(type, true);
                            return(NameStream.ToString());
                        }
                    }
                    finally { fastCSharp.unmanagedPool.TinyBuffers.Push(ref buffer); }
                }
                if (type.IsGenericType)
                {
                    pointer buffer = fastCSharp.unmanagedPool.TinyBuffers.Get();
                    try
                    {
                        using (NameStream = new charStream(buffer.Char, fastCSharp.unmanagedPool.TinyBuffers.Size >> 1))
                        {
                            genericFullName(type);
                            return(NameStream.ToString());
                        }
                    }
                    finally { fastCSharp.unmanagedPool.TinyBuffers.Push(ref buffer); }
                }
                Type reflectedType = type.ReflectedType;

                if (reflectedType == null)
                {
                    return(type.Namespace + "." + type.Name);
                }
                else
                {
                    pointer buffer = fastCSharp.unmanagedPool.TinyBuffers.Get();
                    try
                    {
                        using (NameStream = new charStream(buffer.Char, fastCSharp.unmanagedPool.TinyBuffers.Size >> 1))
                        {
                            this.reflectedType(type, reflectedType);
                            return(NameStream.ToString());
                        }
                    }
                    finally { fastCSharp.unmanagedPool.TinyBuffers.Push(ref buffer); }
                }
            }
Ejemplo n.º 17
0
        public ER GetMemoryBlock(out pointer p_blk, int blksz, TMO tmout)
        {
            ER ret;

            p_blk = null;

            //if (p_blk == null)
            //	return ER.E_PAR;

            for (; ; ) {
                LinkedListNode<pointer> Node = m_MpfQueue.First;

                if (Node != null) {
                    p_blk = Node.Value;
                    m_MpfQueue.RemoveFirst();
                    break;
                }

                if (tmout == 0)
                    return ER.E_TMOUT;

                Task task = m_Nucleus.GetTask(ID.TSK_SELF);

                if (task == null)
                    return ER.E_CTX;

                ret = task.Wait(m_TskQueue, TSKWAIT.TTW_MPF, m_MpfID, tmout);

                switch (ret) {
                case ER.E_OK:
                    continue;
                case ER.E_TMOUT:
                    return ER.E_TMOUT;
                default:
                    return ER.E_RLWAI;
                }
            }

            return ER.E_OK;
        }
Ejemplo n.º 18
0
    private void pointerAddHandler(object sender, PointerEventArgs e)
    {
        Pointer p;

        p = e.Pointers[0];
        GameObject  audioObject = new GameObject();
        AudioSource source      = audioObject.AddComponent <AudioSource>();

        //set audio source params
        source.clip        = popClip;
        source.playOnAwake = false;
        source.pitch       = .9f;
        source.volume      = 1;
        source.loop        = false;
        source.Play();
        //add pointer to list
        pointer newPointer = new pointer(p, audioObject, p.Position);

        //Debug.Log("pop");
        pointerList.Add(newPointer);
        numPointers++;
    }
Ejemplo n.º 19
0
 /// <summary>
 /// 获取字段信息
 /// </summary>
 /// <param name="field"></param>
 /// <returns></returns>
 private xmlNode get(FieldInfo field)
 {
     if (field != null)
     {
         xmlNode node;
         if (fieldLock.TryGetValue(field, out node))
         {
             return(node);
         }
         try
         {
             hashString fieldName;
             pointer    buffer = unmanagedPool.StreamBuffers.Get();
             try
             {
                 using (fieldNameStream)
                 {
                     fieldNameStream.UnsafeReset(buffer.Byte, unmanagedPool.StreamBuffers.Size);
                     type.nameBuilder nameBuilder = new type.nameBuilder {
                         NameStream = fieldNameStream, IsXml = true
                     };
                     nameBuilder.Xml(field.DeclaringType);
                     fieldNameStream.Write('.');
                     fieldNameStream.SimpleWriteNotNull(field.Name);
                     fieldName = fieldNameStream.ToString();
                 }
             }
             finally { unmanagedPool.StreamBuffers.Push(ref buffer); }
             if (fields.TryGetValue(fieldName, out node))
             {
                 fields.Remove(fieldName);
             }
             fieldLock.Set(field, node);
         }
         finally { fieldLock.Exit(); }
         return(node);
     }
     return(default(xmlNode));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// 获取属性信息
 /// </summary>
 /// <param name="property"></param>
 /// <returns></returns>
 private xmlNode get(PropertyInfo property)
 {
     if (property != null)
     {
         xmlNode node;
         if (propertyLock.TryGetValue(property, out node))
         {
             return(node);
         }
         try
         {
             hashString propertyName;
             pointer    buffer = unmanagedPool.StreamBuffers.Get();
             try
             {
                 using (propertyNameStream)
                 {
                     propertyNameStream.UnsafeReset(buffer.Byte, unmanagedPool.StreamBuffers.Size);
                     type.nameBuilder nameBuilder = new type.nameBuilder {
                         NameStream = propertyNameStream, IsXml = true
                     };
                     nameBuilder.Xml(property.DeclaringType);
                     propertyNameStream.Write('.');
                     propertyNameStream.SimpleWriteNotNull(property.Name);
                     propertyName = propertyNameStream.ToString();
                 }
             }
             finally { unmanagedPool.StreamBuffers.Push(ref buffer); }
             if (properties.TryGetValue(propertyName, out node))
             {
                 properties.Remove(propertyName);
             }
             propertyLock.Set(property, node);
         }
         finally { propertyLock.Exit(); }
         return(node);
     }
     return(default(xmlNode));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// 获取解压数据
 /// </summary>
 /// <returns>解压数据</returns>
 public unsafe subArray <byte> Get(memoryPool memoryPool)
 {
     if (memoryPool == null)
     {
         pointer data = fastCSharp.unmanagedPool.StreamBuffers.Get();
         try
         {
             using (dataStream = new unmanagedStream(data.Byte, fastCSharp.unmanagedPool.StreamBuffers.Size))
             {
                 get();
                 return(new subArray <byte>(dataStream.GetArray()));
             }
         }
         finally { fastCSharp.unmanagedPool.StreamBuffers.Push(ref data); }
     }
     else
     {
         byte[] data = memoryPool.Get();
         try
         {
             fixed(byte *dataFixed = data)
             {
                 using (dataStream = new unmanagedStream(dataFixed, data.Length))
                 {
                     get();
                     if (dataStream.data.data == dataFixed)
                     {
                         byte[] buffer = data;
                         data = null;
                         return(subArray <byte> .Unsafe(buffer, 0, dataStream.Length));
                     }
                     return(new subArray <byte>(dataStream.GetArray()));
                 }
             }
         }
         finally { memoryPool.PushOnly(data); }
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 获取类型信息
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 private xmlNode get(Type type)
 {
     if (type != null)
     {
         xmlNode node;
         if (typeLock.TryGetValue(type, out node))
         {
             return(node);
         }
         try
         {
             hashString typeName;
             pointer    buffer = unmanagedPool.StreamBuffers.Get();
             try
             {
                 using (typeNameStream)
                 {
                     typeNameStream.UnsafeReset(buffer.Byte, unmanagedPool.StreamBuffers.Size);
                     type.nameBuilder nameBuilder = new type.nameBuilder {
                         NameStream = typeNameStream, IsXml = true
                     };
                     nameBuilder.Xml(type);
                     typeName = typeNameStream.ToString();
                 }
             }
             finally { unmanagedPool.StreamBuffers.Push(ref buffer); }
             if (types.TryGetValue(typeName, out node))
             {
                 types.Remove(typeName);
             }
             typeLock.Set(type, node);
         }
         finally { typeLock.Exit(); }
         return(node);
     }
     return(default(xmlNode));
 }
Ejemplo n.º 23
0
            /// <summary>
            /// 数组处理
            /// </summary>
            /// <param name="type">类型</param>
            /// <param name="isFullName">是否全称</param>
            private unsafe void array(Type type, bool isFullName)
            {
                pointer buffer = fastCSharp.unmanagedPool.TinyBuffers.Get();

                try
                {
                    int *currentRank = buffer.Int, endRank = (int *)(buffer.Byte + fastCSharp.unmanagedPool.TinyBuffers.Size);
                    do
                    {
                        if (currentRank == endRank)
                        {
                            log.Error.Throw(log.exceptionType.IndexOutOfRange);
                        }
                        *currentRank++ = type.GetArrayRank();
                    }while ((type = type.GetElementType()).IsArray);
                    if (isFullName)
                    {
                        getFullName(type);
                    }
                    else
                    {
                        getNameNoArray(type);
                    }
                    while (currentRank != buffer.Int)
                    {
                        NameStream.Write('[');
                        int rank = *--currentRank;
                        if (--rank != 0)
                        {
                            number.ToString(rank, NameStream);
                        }
                        NameStream.Write(']');
                    }
                }
                finally { fastCSharp.unmanagedPool.TinyBuffers.Push(ref buffer); }
            }
Ejemplo n.º 24
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (pointerMode != pointer.normal)
        {
            if (pointer.normal != pointerMode)
            {
                Vector3    pos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);
                GameObject newField;
                if (pointer.Text == pointerMode)
                {
                    //Debug.Log(pos);
                    newField = Instantiate(text, pos, Quaternion.identity, transform);
                    newField.GetComponent <FieldManager>().initialize(sheet, "text");
                }
                else if (pointer.Label == pointerMode)
                {
                    newField = Instantiate(label, pos, Quaternion.identity, transform);
                    newField.GetComponent <FieldManager>().initialize(sheet, "label");
                }
                else if (pointer.Static == pointerMode)
                {
                    newField = Instantiate(staticNum, pos, Quaternion.identity, transform);
                    newField.GetComponent <FieldManager>().initialize(sheet, "static");
                }
                else
                {
                    newField = Instantiate(dynamicNum, pos, Quaternion.identity, transform);
                    newField.GetComponent <FieldManager>().initialize(sheet, "dynamic");
                }

                DragHandler DH = newField.GetComponent <DragHandler>();
                DH.dropLocation = thisObject;
                pointerMode     = pointer.normal;
            }
        }
    }
Ejemplo n.º 25
0
        unsafe static sqlDbType()
        {
            #region C#类型转SQL数据类型集合
            list <keyValue <hashCode <Type>, SqlDbType> > formCSharpType = new list <keyValue <hashCode <Type>, SqlDbType> >();
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(bool), SqlDbType.Bit));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(byte), SqlDbType.TinyInt));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(sbyte), SqlDbType.TinyInt));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(short), SqlDbType.SmallInt));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(ushort), SqlDbType.SmallInt));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(int), SqlDbType.Int));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(uint), SqlDbType.Int));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(long), SqlDbType.BigInt));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(ulong), SqlDbType.BigInt));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(decimal), SqlDbType.Decimal));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(float), SqlDbType.Real));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(double), SqlDbType.Float));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(string), SqlDbType.NVarChar));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(DateTime), SqlDbType.DateTime));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(Guid), SqlDbType.UniqueIdentifier));
            formCSharpType.Add(new keyValue <hashCode <Type>, SqlDbType>(typeof(byte[]), SqlDbType.VarBinary));
            formCSharpTypes = new staticDictionary <hashCode <Type>, SqlDbType>(formCSharpType);
            #endregion

            MaxEnumValue = fastCSharp.Enum.GetMaxValue <SqlDbType>(-1) + 1;
            int       dataIndex = 0, mapSize = ((MaxEnumValue + 31) >> 5) << 2;
            pointer[] datas = unmanaged.Get(true, mapSize, mapSize, MaxEnumValue * sizeof(int));
            stringTypeMap    = new fixedMap(datas[dataIndex++]).Unsafer;
            textImageTypeMap = new fixedMap(datas[dataIndex++]).Unsafer;
            sizes            = datas[dataIndex++];

            #region 字符串类型占位集合
            stringTypeMap.Set((int)SqlDbType.Char);
            stringTypeMap.Set((int)SqlDbType.NChar);
            stringTypeMap.Set((int)SqlDbType.VarChar);
            stringTypeMap.Set((int)SqlDbType.NVarChar);
            stringTypeMap.Set((int)SqlDbType.Text);
            stringTypeMap.Set((int)SqlDbType.NText);
            #endregion

            #region 文本类型占位集合
            textImageTypeMap.Set((int)SqlDbType.Text);
            textImageTypeMap.Set((int)SqlDbType.NText);
            textImageTypeMap.Set((int)SqlDbType.Image);
            #endregion

            #region 类型默认长度
            int *sizeData = sizes.Int;
            for (int i = 0; i != MaxEnumValue; i++)
            {
                sizeData[i] = UnknownSize;
            }
            sizeData[(int)SqlDbType.BigInt] = sizeof(long);
            sizeData[(int)SqlDbType.Binary] = 8000;
            sizeData[(int)SqlDbType.Bit]    = sizeof(bool);
            sizeData[(int)SqlDbType.Char]   = 8000;
            //TypeSize[(int)SqlDbType.Date] = sizeof(long);
            sizeData[(int)SqlDbType.DateTime] = sizeof(long);
            //TypeSize[(int)SqlDbType.DateTime2] = sizeof(long);
            //TypeSize[(int)SqlDbType.DateTimeOffset] = sizeof(long);
            sizeData[(int)SqlDbType.Decimal] = sizeof(decimal);
            sizeData[(int)SqlDbType.Float]   = sizeof(double);
            sizeData[(int)SqlDbType.Image]   = int.MaxValue;
            sizeData[(int)SqlDbType.Int]     = sizeof(int);
            sizeData[(int)SqlDbType.Money]   = sizeof(decimal);
            //TypeSize[(int)SqlDbType.NChar] = MaxStringSize;
            sizeData[(int)SqlDbType.NText] = int.MaxValue;
            //TypeSize[(int)SqlDbType.NVarChar] = MaxStringSize;
            sizeData[(int)SqlDbType.Real]             = sizeof(float);
            sizeData[(int)SqlDbType.UniqueIdentifier] = 8;
            sizeData[(int)SqlDbType.SmallDateTime]    = sizeof(long);
            sizeData[(int)SqlDbType.SmallInt]         = sizeof(short);
            sizeData[(int)SqlDbType.SmallMoney]       = sizeof(decimal);
            sizeData[(int)SqlDbType.Text]             = int.MaxValue;
            //TypeSize[(int)SqlDbType.Time] = 8;
            sizeData[(int)SqlDbType.Timestamp] = 8;
            sizeData[(int)SqlDbType.TinyInt]   = sizeof(byte);
            sizeData[(int)SqlDbType.VarBinary] = 8000;
            sizeData[(int)SqlDbType.VarChar]   = 8000;
            //TypeSize[(int)SqlDbType.Xml] = -1;
            #endregion
        }
Ejemplo n.º 26
0
Archivo: ip.cs Proyecto: h7ga40/uITron3
        internal void input(pointer packet, int length, ip_addr srcn, ip_addr destn, byte proto)
        {
            ip_addr src = new ip_addr(lwip.lwip_htonl(srcn.addr));
            ip_addr dest = new ip_addr(lwip.lwip_htonl(destn.addr));
            pbuf p = pbuf_alloc(pbuf_layer.PBUF_RAW, (ushort)length, pbuf_type.PBUF_POOL);
            int pos = 0, rest = length;

            for (pbuf q = p; q != null; q = q.next) {
                int len = rest;
                if (len > q.len)
                    len = q.len;

                pointer.memcpy(q.payload, new pointer(packet, pos), len);
                pos += len;
                rest -= len;
            }

            if (ip_input(p, src, dest, proto) != err_t.ERR_OK)
                pbuf_free(p);
        }
Ejemplo n.º 27
0
 internal unsafe UnmanagedMemoryStream(byte *pointer, int length, FileAccess access = FileAccess.Read) => Initialize(pointer, length, access);
Ejemplo n.º 28
0
 public T_MSG(pointer blk, int offset)
     : base(blk, offset)
 {
 }
Ejemplo n.º 29
0
 set => WriteAt(pointer + i, value);
Ejemplo n.º 30
0
 internal static void AddBlock(_CrtMemBlockHeader _pFirstBlock, _CrtMemBlockHeader _pLastBlock, pointer p_blk, int blksz, string lpszFileName, int nLine)
 {
 }
Ejemplo n.º 31
0
 public static TMemNode GetNode(pointer Data)
 {
     return new TMemNode(Data, -Fields.Previous.offset);
 }
Ejemplo n.º 32
0
 public tcp_hdr(pointer buffer)
     : this(buffer.data, buffer.offset)
 {
 }
Ejemplo n.º 33
0
 internal void memp_free(mempb_t type, pointer pcb)
 {
 }
Ejemplo n.º 34
0
 public ip6_addr(pointer data)
     : base(data)
 {
 }
Ejemplo n.º 35
0
 static connection()
 {
     if (config.sql.Default.CheckConnection.Length != 0)
     {
         checkConnectionAssemblyNameMap = new String.asciiMap(unmanaged.Get(String.asciiMap.mapBytes), ".,-").Pointer;
         AppDomain.CurrentDomain.AssemblyLoad += checkConnection;
         foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) checkConnection(assembly);
     }
 }
Ejemplo n.º 36
0
 public void setDynamic()
 {
     pointerMode = pointer.Dynamic;
     //print("Switching mode to dynamic");
 }
Ejemplo n.º 37
0
 public void setStatic()
 {
     pointerMode = pointer.Static;
     //print("Switching mode to static");
 }
Ejemplo n.º 38
0
 public void setLabel()
 {
     pointerMode = pointer.Label;
     //print("Switching mode to Label");
 }
Ejemplo n.º 39
0
 public ip_addr(pointer buffer, int offset)
     : base(buffer.data, buffer.offset + offset)
 {
 }
Ejemplo n.º 40
0
        /**
         * Write data for sending (but does not send it immediately).
         *
         * It waits in the expectation of more data being sent soon (as
         * it can send them more efficiently by combining them together).
         * To prompt the system to send data now, call tcp.tcp_output() after
         * calling tcp_write().
         *
         * @param pcb Protocol control block for the TCP connection to enqueue data for.
         * @param arg Pointer to the data to be enqueued for sending.
         * @param len Data length in bytes
         * @param apiflags combination of following flags :
         * - TCP_WRITE_FLAG_COPY (0x01) data will be copied into memory belonging to the stack
         * - TCP_WRITE_FLAG_MORE (0x02) for TCP connection, PSH flag will be set on last segment sent,
         * @return err_t.ERR_OK if enqueued, another err_t on error
         */
        public err_t tcp_write(tcp_pcb pcb, pointer arg, ushort len, byte apiflags)
        {
            pbuf concat_p = null;
            tcp_seg last_unsent = null, seg = null, prev_seg = null, queue = null;
            ushort pos = 0; /* position in 'arg' data */
            ushort queuelen;
            byte optlen = 0;
            byte optflags = 0;
            #if TCP_OVERSIZE
            ushort oversize = 0;
            ushort oversize_used = 0;
            #endif // TCP_OVERSIZE
            #if TCP_CHECKSUM_ON_COPY
            ushort concat_chksum = 0;
            bool concat_chksum_swapped = false;
            ushort concat_chksummed = 0;
            #endif // TCP_CHECKSUM_ON_COPY
            err_t err;
            /* don't allocate segments bigger than half the maximum window we ever received */
            ushort mss_local = Math.Min(pcb.mss, (ushort)(pcb.snd_wnd_max / 2));

            #if LWIP_NETIF_TX_SINGLE_PBUF
            /* Always copy to try to create single pbufs for TX */
            apiflags |= tcp.TCP_WRITE_FLAG_COPY;
            #endif // LWIP_NETIF_TX_SINGLE_PBUF

            lwip.LWIP_DEBUGF(opt.TCP_OUTPUT_DEBUG, "tcp_write(pcb={0}, data={1}, len={2}, apiflags={3})\n",
              pcb, arg, len, (ushort)apiflags);
            if (lwip.LWIP_ERROR("tcp_write: arg == null (programmer violates API)",
                       arg != null))
                return err_t.ERR_ARG;

            err = tcp_write_checks(pcb, len);
            if (err != err_t.ERR_OK) {
                return err;
            }
            queuelen = pcb.snd_queuelen;

            #if LWIP_TCP_TIMESTAMPS
            if ((pcb.flags & tcp_pcb.TF_TIMESTAMP) != 0) {
                optflags = tcp_seg.TF_SEG_OPTS_TS;
                optlen = (byte)tcp_seg.LWIP_TCP_OPT_LENGTH(tcp_seg.TF_SEG_OPTS_TS);
            }
            #endif // LWIP_TCP_TIMESTAMPS

            /*
             * TCP segmentation is done in three phases with increasing complexity:
             *
             * 1. Copy data directly into an oversized pbuf.
             * 2. Chain a new pbuf to the end of pcb.unsent.
             * 3. Create new segments.
             *
             * We may run out of memory at any point. In that case we must
             * return err_t.ERR_MEM and not change anything in pcb. Therefore, all
             * changes are recorded in local variables and committed at the end
             * of the function. Some pcb fields are maintained in local copies:
             *
             * queuelen = pcb.snd_queuelen
             * oversize = pcb.unsent_oversize
             *
             * These variables are set consistently by the phases:
             *
             * seg points to the last segment tampered with.
             *
             * pos records progress as data is segmented.
             */

            /* Find the tail of the unsent queue. */
            if (pcb.unsent != null) {
                ushort space;
                ushort unsent_optlen;

                /* @todo: this could be sped up by keeping last_unsent in the pcb */
                for (last_unsent = pcb.unsent; last_unsent.next != null;
                     last_unsent = last_unsent.next)
                    ;

                /* Usable space at the end of the last unsent segment */
                unsent_optlen = (ushort)tcp_seg.LWIP_TCP_OPT_LENGTH(last_unsent.flags);
                space = (ushort)(mss_local - (last_unsent.len + unsent_optlen));

                /*
                 * Phase 1: Copy data directly into an oversized pbuf.
                 *
                 * The number of bytes copied is recorded in the oversize_used
                 * variable. The actual copying is done at the bottom of the
                 * function.
                 */
            #if TCP_OVERSIZE
            #if TCP_OVERSIZE_DBGCHECK
                /* check that pcb.unsent_oversize matches last_unsent.unsent_oversize */
                lwip.LWIP_ASSERT("unsent_oversize mismatch (pcb vs. last_unsent)",
                            pcb.unsent_oversize == last_unsent.oversize_left);
            #endif // TCP_OVERSIZE_DBGCHECK
                oversize = pcb.unsent_oversize;
                if (oversize > 0) {
                    lwip.LWIP_ASSERT("inconsistent oversize vs. space", oversize_used <= space);
                    seg = last_unsent;
                    oversize_used = oversize < len ? oversize : len;
                    pos += oversize_used;
                    oversize -= oversize_used;
                    space -= oversize_used;
                }
                /* now we are either finished or oversize is zero */
                lwip.LWIP_ASSERT("inconsistend oversize vs. len", (oversize == 0) || (pos == len));
            #endif // TCP_OVERSIZE

                /*
                 * Phase 2: Chain a new pbuf to the end of pcb.unsent.
                 *
                 * We don't extend segments containing SYN/FIN flags or options
                 * (len==0). The new pbuf is kept in concat_p and pbuf_cat'ed at
                 * the end.
                 */
                if ((pos < len) && (space > 0) && (last_unsent.len > 0)) {
                    ushort seglen = (ushort)(space < len - pos ? space : len - pos);
                    //ushort oversize;
                    //ushort concat_chksum = 0;
                    //bool concat_chksum_swapped = false;
                    seg = last_unsent;

                    /* Create a pbuf with a copy or reference to seglen bytes. We
                     * can use pbuf_layer.PBUF_RAW here since the data appears in the middle of
                     * a segment. A header will never be prepended. */
                    if ((apiflags & tcp.TCP_WRITE_FLAG_COPY) != 0) {
                        /* Data is copied */
                        if ((concat_p = tcp_pbuf_prealloc(pbuf_layer.PBUF_RAW, seglen, space, ref oversize, pcb, apiflags, 1)) == null) {
                            lwip.LWIP_DEBUGF(opt.TCP_OUTPUT_DEBUG | 2,
                                        "tcp_write : could not allocate memory for pbuf copy size {0}\n",
                                         seglen);
                            goto memerr;
                        }
            #if TCP_OVERSIZE_DBGCHECK
                        last_unsent.oversize_left += oversize;
            #endif // TCP_OVERSIZE_DBGCHECK
                        TCP_DATA_COPY2(concat_p.payload, arg + pos, seglen, ref concat_chksum, ref concat_chksum_swapped);
            #if TCP_CHECKSUM_ON_COPY
                        concat_chksummed += seglen;
            #endif // TCP_CHECKSUM_ON_COPY
                    }
                    else {
                        /* Data is not copied */
                        if ((concat_p = lwip.pbuf_alloc(pbuf_layer.PBUF_RAW, seglen, pbuf_type.PBUF_ROM)) == null) {
                            lwip.LWIP_DEBUGF(opt.TCP_OUTPUT_DEBUG | 2,
                                        ("tcp_write: could not allocate memory for zero-copy pbuf\n"));
                            goto memerr;
                        }
            #if TCP_CHECKSUM_ON_COPY
                        /* calculate the checksum of nocopy-data */
                        tcp_seg_add_chksum((ushort)~lwip.inet_chksum(arg + pos, seglen), seglen,
                            ref concat_chksum, ref concat_chksum_swapped);
                        concat_chksummed += seglen;
            #endif // TCP_CHECKSUM_ON_COPY
                        /* reference the non-volatile payload data */
                        concat_p.payload = arg + pos;
                    }

                    pos += seglen;
                    queuelen += lwip.pbuf_clen(concat_p);
                }
            }
            else {
            #if TCP_OVERSIZE
                lwip.LWIP_ASSERT("unsent_oversize mismatch (pcb.unsent is null)",
                            pcb.unsent_oversize == 0);
            #endif // TCP_OVERSIZE
            }

            /*
             * Phase 3: Create new segments.
             *
             * The new segments are chained together in the local 'queue'
             * variable, ready to be appended to pcb.unsent.
             */
            while (pos < len) {
                pbuf p;
                ushort left = (ushort)(len - pos);
                ushort max_len = (ushort)(mss_local - optlen);
                ushort seglen = left > max_len ? max_len : left;
                //ushort oversize;
                ushort chksum = 0;
                bool chksum_swapped = false;

                if ((apiflags & tcp.TCP_WRITE_FLAG_COPY) != 0) {
                    /* If copy is set, memory should be allocated and data copied
                     * into pbuf */
                    if ((p = tcp_pbuf_prealloc(pbuf_layer.PBUF_TRANSPORT, (ushort)(seglen + optlen), mss_local, ref oversize, pcb, apiflags, (byte)(queue == null ? 1 : 0))) == null) {
                        lwip.LWIP_DEBUGF(opt.TCP_OUTPUT_DEBUG | 2, "tcp_write : could not allocate memory for pbuf copy size {0}\n", seglen);
                        goto memerr;
                    }
                    lwip.LWIP_ASSERT("tcp_write: check that first pbuf can hold the complete seglen",
                                (p.len >= seglen));
                    TCP_DATA_COPY2(p.payload + optlen, arg + pos, seglen, ref chksum, ref chksum_swapped);
                }
                else {
                    /* Copy is not set: First allocate a pbuf for holding the data.
                     * Since the referenced data is available at least until it is
                     * sent out on the link (as it has to be ACKed by the remote
                     * party) we can safely use pbuf_type.PBUF_ROM instead of pbuf_type.PBUF_REF here.
                     */
                    pbuf p2;
            #if TCP_OVERSIZE
                    lwip.LWIP_ASSERT("oversize == 0", oversize == 0);
            #endif // TCP_OVERSIZE
                    if ((p2 = lwip.pbuf_alloc(pbuf_layer.PBUF_TRANSPORT, seglen, pbuf_type.PBUF_ROM)) == null) {
                        lwip.LWIP_DEBUGF(opt.TCP_OUTPUT_DEBUG | 2, "tcp_write: could not allocate memory for zero-copy pbuf\n");
                        goto memerr;
                    }
            #if TCP_CHECKSUM_ON_COPY
                    /* calculate the checksum of nocopy-data */
                    chksum = (ushort)~lwip.inet_chksum(arg + pos, seglen);
            #endif // TCP_CHECKSUM_ON_COPY
                    /* reference the non-volatile payload data */
                    p2.payload = arg + pos;

                    /* Second, allocate a pbuf for the headers. */
                    if ((p = lwip.pbuf_alloc(pbuf_layer.PBUF_TRANSPORT, optlen, pbuf_type.PBUF_RAM)) == null) {
                        /* If allocation fails, we have to deallocate the data pbuf as
                         * well. */
                        lwip.pbuf_free(p2);
                        lwip.LWIP_DEBUGF(opt.TCP_OUTPUT_DEBUG | 2, "tcp_write: could not allocate memory for header pbuf\n");
                        goto memerr;
                    }
                    /* Concatenate the headers and data pbufs together. */
                    lwip.pbuf_cat(p/*header*/, p2/*data*/);
                }

                queuelen += lwip.pbuf_clen(p);

                /* Now that there are more segments queued, we check again if the
                 * length of the queue exceeds the configured maximum or
                 * overflows. */
                if ((queuelen > opt.TCP_SND_QUEUELEN) || (queuelen > tcp_pcb.TCP_SNDQUEUELEN_OVERFLOW)) {
                    lwip.LWIP_DEBUGF(opt.TCP_OUTPUT_DEBUG | 2, "tcp_write: queue too long {0} ({1})\n", queuelen, opt.TCP_SND_QUEUELEN);
                    lwip.pbuf_free(p);
                    goto memerr;
                }

                if ((seg = tcp_create_segment(pcb, p, 0, pcb.snd_lbb + pos, optflags)) == null) {
                    goto memerr;
                }
            #if TCP_OVERSIZE_DBGCHECK
                seg.oversize_left = oversize;
            #endif // TCP_OVERSIZE_DBGCHECK
            #if TCP_CHECKSUM_ON_COPY
                seg.chksum = chksum;
                seg.chksum_swapped = chksum_swapped;
                seg.flags |= tcp_seg.TF_SEG_DATA_CHECKSUMMED;
            #endif // TCP_CHECKSUM_ON_COPY

                /* first segment of to-be-queued data? */
                if (queue == null) {
                    queue = seg;
                }
                else {
                    /* Attach the segment to the end of the queued segments */
                    lwip.LWIP_ASSERT("prev_seg != null", prev_seg != null);
                    prev_seg.next = seg;
                }
                /* remember last segment of to-be-queued data for next iteration */
                prev_seg = seg;

                lwip.LWIP_DEBUGF(opt.TCP_OUTPUT_DEBUG | lwip.LWIP_DBG_TRACE, "tcp_write: queueing {0}:{1}\n",
                  lwip.lwip_ntohl(seg.tcphdr.seqno),
                  lwip.lwip_ntohl(seg.tcphdr.seqno) + tcp_hdr.TCP_TCPLEN(seg));

                pos += seglen;
            }

            /*
             * All three segmentation phases were successful. We can commit the
             * transaction.
             */

            /*
             * Phase 1: If data has been added to the preallocated tail of
             * last_unsent, we update the length fields of the pbuf chain.
             */
            #if TCP_OVERSIZE
            if (oversize_used > 0) {
                pbuf p;
                /* Bump tot_len of whole chain, len of tail */
                for (p = last_unsent.p; p != null; p = p.next) {
                    p.tot_len += oversize_used;
                    if (p.next == null) {
                        TCP_DATA_COPY(new pointer(p.payload.data, p.payload.offset + p.len), arg, oversize_used, last_unsent);
                        p.len += oversize_used;
                    }
                }
                last_unsent.len += oversize_used;
            #if TCP_OVERSIZE_DBGCHECK
                lwip.LWIP_ASSERT("last_unsent.oversize_left >= oversize_used",
                            last_unsent.oversize_left >= oversize_used);
                last_unsent.oversize_left -= oversize_used;
            #endif // TCP_OVERSIZE_DBGCHECK
            }
            pcb.unsent_oversize = oversize;
            #endif // TCP_OVERSIZE

            /*
             * Phase 2: concat_p can be concatenated onto last_unsent.p
             */
            if (concat_p != null) {
                lwip.LWIP_ASSERT("tcp_write: cannot concatenate when pcb.unsent is empty",
                  (last_unsent != null));
                lwip.pbuf_cat(last_unsent.p, concat_p);
                last_unsent.len += concat_p.tot_len;
            #if TCP_CHECKSUM_ON_COPY
                if (concat_chksummed != 0) {
                    tcp_seg_add_chksum(concat_chksum, concat_chksummed, ref last_unsent.chksum,
                      ref last_unsent.chksum_swapped);
                    last_unsent.flags |= tcp_seg.TF_SEG_DATA_CHECKSUMMED;
                }
            #endif // TCP_CHECKSUM_ON_COPY
            }

            /*
             * Phase 3: Append queue to pcb.unsent. Queue may be null, but that
             * is harmless
             */
            if (last_unsent == null) {
                pcb.unsent = queue;
            }
            else {
                last_unsent.next = queue;
            }

            /*
             * Finally update the pcb state.
             */
            pcb.snd_lbb += len;
            pcb.snd_buf -= len;
            pcb.snd_queuelen = queuelen;

            lwip.LWIP_DEBUGF(opt.TCP_QLEN_DEBUG, "tcp_write: {0} (after enqueued)\n",
              pcb.snd_queuelen);
            if (pcb.snd_queuelen != 0) {
                lwip.LWIP_ASSERT("tcp_write: valid queue length",
                            pcb.unacked != null || pcb.unsent != null);
            }

            /* Set the PSH flag in the last segment that we enqueued. */
            if (seg != null && seg.tcphdr != null && ((apiflags & tcp.TCP_WRITE_FLAG_MORE) == 0)) {
                tcp_hdr.TCPH_SET_FLAG(seg.tcphdr, tcp.TCP_PSH);
            }

            return err_t.ERR_OK;
            memerr:
            pcb.flags |= tcp_pcb.TF_NAGLEMEMERR;
            ++lwip.lwip_stats.tcp.memerr;

            if (concat_p != null) {
                lwip.pbuf_free(concat_p);
            }
            if (queue != null) {
                tcp_segs_free(queue);
            }
            if (pcb.snd_queuelen != 0) {
                lwip.LWIP_ASSERT("tcp_write: valid queue length", pcb.unacked != null ||
                  pcb.unsent != null);
            }
            lwip.LWIP_DEBUGF(opt.TCP_QLEN_DEBUG | lwip.LWIP_DBG_STATE, "tcp_write: {0} (with mem err)\n", pcb.snd_queuelen);
            return err_t.ERR_MEM;
        }
Ejemplo n.º 41
0
 public void setText()
 {
     pointerMode = pointer.Text;
     //print("Switching mode to text");
 }
Ejemplo n.º 42
0
 public static void TCP_DATA_COPY(pointer dst, pointer src, int len, tcp_seg seg)
 {
     opt.MEMCPY(dst, src, len);
 }
Ejemplo n.º 43
0
 /// <summary>
 /// 获取方法信息
 /// </summary>
 /// <param name="method"></param>
 /// <returns></returns>
 private xmlNode get(MethodInfo method)
 {
     if (method != null)
     {
         xmlNode node;
         if (methodLock.TryGetValue(method, out node))
         {
             return(node);
         }
         try
         {
             hashString methodName;
             pointer    buffer = unmanagedPool.StreamBuffers.Get();
             try
             {
                 using (methodNameStream)
                 {
                     methodNameStream.UnsafeReset(buffer.Byte, unmanagedPool.StreamBuffers.Size);
                     type.nameBuilder nameBuilder = new type.nameBuilder {
                         NameStream = methodNameStream, IsXml = true
                     };
                     nameBuilder.Xml(method.DeclaringType);
                     methodNameStream.Write('.');
                     string name = method.Name;
                     if (name[0] == '.')
                     {
                         methodNameStream.Write('#');
                         methodNameStream.Write(subString.Unsafe(name, 1, name.Length - 1));
                     }
                     else
                     {
                         methodNameStream.SimpleWriteNotNull(name);
                     }
                     ParameterInfo[] parameters = method.GetParameters();
                     if (parameters.Length != 0)
                     {
                         bool isFirst = true;
                         methodNameStream.Write('(');
                         foreach (ParameterInfo parameter in parameters)
                         {
                             if (isFirst)
                             {
                                 isFirst = false;
                             }
                             else
                             {
                                 methodNameStream.Write(',');
                             }
                             nameBuilder.Xml(parameter.ParameterType);
                         }
                         methodNameStream.Write(')');
                     }
                     formatName(methodNameStream.Char, methodNameStream.CurrentChar);
                     methodName = methodNameStream.ToString();
                 }
             }
             finally { unmanagedPool.StreamBuffers.Push(ref buffer); }
             if (methods.TryGetValue(methodName, out node))
             {
                 methods.Remove(methodName);
             }
             methodLock.Set(method, node);
         }
         finally { methodLock.Exit(); }
         return(node);
     }
     return(default(xmlNode));
 }
Ejemplo n.º 44
0
 public static void TCP_DATA_COPY2(pointer dst, pointer src, int len, ushort chksum, bool chksum_swapped)
 {
     opt.MEMCPY(dst, src, len);
 }
Ejemplo n.º 45
0
 public T_MSG(pointer blk)
     : base(blk)
 {
 }
Ejemplo n.º 46
0
        /**
         * Called by tcp.tcp_output() to actually send a TCP segment over IP.
         *
         * @param seg the tcp_seg to send
         * @param pcb the tcp_pcb for the TCP connection used to send the segment
         */
        private void tcp_output_segment(tcp_seg seg, tcp_pcb pcb)
        {
            ushort len;
            pointer opts;

            /** @bug Exclude retransmitted segments from this count. */
            //snmp.snmp_inc_tcpoutsegs();

            /* The TCP header has already been constructed, but the ackno and
             wnd fields remain. */
            seg.tcphdr.ackno = lwip.lwip_htonl(pcb.rcv_nxt);

            /* advertise our receive window size in this TCP segment */
            seg.tcphdr.wnd = lwip.lwip_htons(pcb.rcv_ann_wnd);

            pcb.rcv_ann_right_edge = pcb.rcv_nxt + pcb.rcv_ann_wnd;

            /* Add any requested options.  NB MSS option is only set on SYN
               packets, so ignore it here */
            opts = new pointer(seg.tcphdr.data, seg.tcphdr.offset + tcp_hdr.length);
            if ((seg.flags & tcp_seg.TF_SEG_OPTS_MSS) != 0) {
                ushort mss;
            #if TCP_CALCULATE_EFF_SEND_MSS
                mss = tcp_eff_send_mss(opt.TCP_MSS, pcb.remote_ip);
            #else // TCP_CALCULATE_EFF_SEND_MSS
                mss = opt.TCP_MSS;
            #endif // TCP_CALCULATE_EFF_SEND_MSS
                opts.SetValue(tcp_seg.TCP_BUILD_MSS_OPTION(mss));
                opts += 1;
            }
            #if LWIP_TCP_TIMESTAMPS
            pcb.ts_lastacksent = pcb.rcv_nxt;

            if ((seg.flags & tcp_seg.TF_SEG_OPTS_TS) != 0) {
                tcp_build_timestamp_option(pcb, /*opts*/new pointer(seg.tcphdr.data, seg.tcphdr.offset + 1));
                opts += 3;
            }
            #endif

            /* Set retransmission timer running if it is not currently enabled
               This must be set before checking the route. */
            if (pcb.rtime == -1) {
                pcb.rtime = 0;
            }

            /* If we don't have a local IP address, we get one by
               calling ip.ip_route(). */
            if (ip_addr.ip_addr_isany(pcb.local_ip)) {
                ip_addr.ip_addr_copy(pcb.local_ip, lwip.ip_addr);
            }

            if (pcb.rttest == 0) {
                pcb.rttest = tcp_ticks;
                pcb.rtseq = lwip.lwip_ntohl(seg.tcphdr.seqno);

                lwip.LWIP_DEBUGF(opt.TCP_RTO_DEBUG, "tcp_output_segment: rtseq {0}\n", pcb.rtseq);
            }
            lwip.LWIP_DEBUGF(opt.TCP_OUTPUT_DEBUG, "tcp_output_segment: {0}:{1}\n",
                    lwip.lwip_htonl(seg.tcphdr.seqno), lwip.lwip_htonl(seg.tcphdr.seqno) +
                    seg.len);

            len = (ushort)(seg.tcphdr - seg.p.payload);

            seg.p.len -= len;
            seg.p.tot_len -= len;

            seg.p.payload = seg.tcphdr;

            seg.tcphdr.chksum = 0;
            #if CHECKSUM_GEN_TCP
            #if TCP_CHECKSUM_ON_COPY
            {
                uint acc;
            #if TCP_CHECKSUM_ON_COPY_SANITY_CHECK
                ushort chksum_slow = lwip.inet_chksum_pseudo(seg.p, pcb.local_ip,
                       pcb.remote_ip, lwip.IP_PROTO_TCP, seg.p.tot_len);
            #endif // TCP_CHECKSUM_ON_COPY_SANITY_CHECK
                if ((seg.flags & tcp_seg.TF_SEG_DATA_CHECKSUMMED) == 0) {
                    lwip.LWIP_ASSERT("data included but not checksummed",
                      seg.p.tot_len == (tcp_hdr.TCPH_HDRLEN(seg.tcphdr) * 4));
                }

                /* rebuild TCP header checksum (TCP header changes for retransmissions!) */
                acc = lwip.inet_chksum_pseudo_partial(seg.p, pcb.local_ip,
                         pcb.remote_ip,
                         lwip.IP_PROTO_TCP, seg.p.tot_len, (ushort)(tcp_hdr.TCPH_HDRLEN(seg.tcphdr) * 4));
                /* add payload checksum */
                if (seg.chksum_swapped) {
                    seg.chksum = lwip.SWAP_BYTES_IN_WORD(seg.chksum);
                    seg.chksum_swapped = false;
                }
                acc += (ushort)~(seg.chksum);
                seg.tcphdr.chksum = (ushort)lwip.FOLD_U32T(acc);
            #if TCP_CHECKSUM_ON_COPY_SANITY_CHECK
                if (chksum_slow != seg.tcphdr.chksum) {
                    lwip.LWIP_DEBUGF(opt.TCP_DEBUG | lwip.LWIP_DBG_LEVEL_WARNING,
                                "tcp_output_segment: calculated checksum is {0} instead of {1:X}\n",
                                seg.tcphdr.chksum, chksum_slow);
                    seg.tcphdr.chksum = chksum_slow;
                }
            #endif // TCP_CHECKSUM_ON_COPY_SANITY_CHECK
            }
            #else // TCP_CHECKSUM_ON_COPY
            seg.tcphdr.chksum = lwip.inet_chksum_pseudo(seg.p, pcb.local_ip,
                pcb.remote_ip,
                lwip.IP_PROTO_TCP, seg.p.tot_len);
            #endif // TCP_CHECKSUM_ON_COPY
            #endif // CHECKSUM_GEN_TCP
            ++lwip.lwip_stats.tcp.xmit;

            #if LWIP_NETIF_HWADDRHINT
            lwip.ip_output_hinted(seg.p, pcb.local_ip, pcb.remote_ip, pcb.ttl, pcb.tos,
                lwip.IP_PROTO_TCP, pcb.addr_hint);
            #else // LWIP_NETIF_HWADDRHINT
            lwip.ip_output(seg.p, pcb.local_ip, pcb.remote_ip, pcb.ttl, pcb.tos,
                lwip.IP_PROTO_TCP);
            #endif // LWIP_NETIF_HWADDRHINT
        }
Ejemplo n.º 47
0
 get => ReadAt(pointer + i);
Ejemplo n.º 48
0
 static htmlNode()
 {
     int dataIndex = 0;
     pointer[] datas = unmanaged.Get(true
         , String.asciiMap.mapBytes, String.asciiMap.mapBytes, String.asciiMap.mapBytes
         , String.asciiMap.mapBytes, String.asciiMap.mapBytes, String.asciiMap.mapBytes);
     spaceMap = new String.asciiMap(datas[dataIndex++], "\t\r\n ", true);
     spaceSplitMap = new String.asciiMap(datas[dataIndex++], "\t\r\n >", true).Pointer;
     tagNameSplitMap = new String.asciiMap(datas[dataIndex++], "\t\r\n \"'/=>", true).Pointer;
     attributeSplitMap = new String.asciiMap(datas[dataIndex++], "\t\r\n \"'/=", true).Pointer;
     attributeNameSplitMap = new String.asciiMap(datas[dataIndex++], "\"'/>", true).Pointer;
     String.asciiMap tagNameAsciiMap = new String.asciiMap(tagNameMap = datas[dataIndex++], "!/", true);
     tagNameAsciiMap.Unsafer.Set('a', 26);
     tagNameAsciiMap.Unsafer.Set('A', 26);
     noLowerAttributeNames = new staticDictionary<string, string>(new string[] { "readOnly", "className" }, value => value.ToLower());
 }
Ejemplo n.º 49
0
        public ER pget_blf(out pointer p_blf, ID mpfid, int blfsz)
        {
            ER Result = ER.E_NOEXS;
            MemoryPoolFixedsize MemoryPoolFixedsize;

            p_blf = null;

            if (g_Kernel == null)
                return ER.E_DLT;

            g_Kernel.LockCPU();
            try {
                MemoryPoolFixedsize = g_Kernel.Nucleus.GetMemoryPoolFixedsize(mpfid);
                if (MemoryPoolFixedsize == null)
                    Result = ER.E_NOEXS;
                else
                    Result = MemoryPoolFixedsize.GetMemoryBlock(out p_blf, blfsz, TMO.TMO_POL);
            }
            finally {
                g_Kernel.UnlockCPU();
            }

            return Result;
        }
Ejemplo n.º 50
0
 /* Define some copy-macros for checksum-on-copy so that the code looks
    nicer by preventing too many ifdef's. */
 public static void TCP_DATA_COPY(pointer dst, pointer src, ushort len, tcp_seg seg)
 {
     do {
         tcp_seg_add_chksum(lwip.LWIP_CHKSUM_COPY(dst, src, len),
             len, ref seg.chksum, ref seg.chksum_swapped);
         seg.flags |= tcp_seg.TF_SEG_DATA_CHECKSUMMED;
     } while (false);
 }
Ejemplo n.º 51
0
 /**
  * SMEMCPY: override this with care! Some compilers (e.g. gcc) can inline a
  * call to memcpy() if the length is known at compile time and is small.
  */
 public static void SMEMCPY(pointer dst, pointer src, int len)
 {
     pointer.memcpy(dst, src, len);
 }
Ejemplo n.º 52
0
 public static void TCP_DATA_COPY2(pointer dst, pointer src, ushort len, ref ushort chksum, ref bool chksum_swapped)
 {
     tcp_seg_add_chksum(lwip.LWIP_CHKSUM_COPY(dst, src, len), len, ref chksum, ref chksum_swapped);
 }
Ejemplo n.º 53
0
        public ER get_blk(out pointer p_blk, ID mplid, int blksz)
        {
            ER Result = ER.E_NOEXS;
            MemoryPool MemoryPool;

            p_blk = null;

            if (g_Kernel == null)
                return ER.E_DLT;

            g_Kernel.LockCPU();
            try {
                MemoryPool = g_Kernel.Nucleus.GetMemoryPool(mplid);
                if (MemoryPool == null)
                    Result = ER.E_NOEXS;
                else
                    Result = MemoryPool.GetMemoryBlock(out p_blk, blksz, TMO.TMO_FEVR);
            }
            finally {
                g_Kernel.UnlockCPU();
            }

            return Result;
        }
Ejemplo n.º 54
0
 private void frmAddDetail_FormClosing(object sender, FormClosingEventArgs e)
 {
     closeEvent += new pointer(frmParent.LoadDataGridView);
     closeEvent();
 }
Ejemplo n.º 55
0
        private static void InitializeContent()
        {
            Action __WoodsXmasByRobert_loaded = null;

            Console.WriteLine(
                new { Native.window.opener, Native.window.parent }
            );


            Native.window.parent.With(
                parent =>
                {
                    parent.postMessage("WoodsXmasByRobert.preparing");
                    Console.WriteLine("WoodsXmasByRobert.preparing");

                    __WoodsXmasByRobert_loaded = delegate
                    {
                        Console.WriteLine("will post WoodsXmasByRobert.loaded");

                        __WoodsXmasByRobert_loaded = null;

                        parent.postMessage("WoodsXmasByRobert.loaded");
                    };
                }
            );


            //<!-- Snow flakes -->

            new IHTMLScript { type = "x-shader/x-vertex", id = "vertexshader", innerText = new Shaders.particlesVertexShader().ToString() }.AttachToDocument();
            new IHTMLScript { type = "x-shader/x-fragment", id = "fragmentshader", innerText = new Shaders.particlesFragmentShader().ToString() }.AttachToDocument();

            var w = Native.window;

            dynamic window = w;



            // http://stackoverflow.com/questions/4923136/why-doesnt-firefox-support-mp3-file-format-in-audio
            //            Timestamp: 12/28/2012 1:22:05 PM
            //Warning: HTTP "Content-Type" of "audio/mpeg3" is not supported. Load of media resource http://192.168.1.100:27248/assets/WoodsXmasByRobert/unfiltered_mix.mp3 failed.
            //Source File: http://192.168.1.100:27248/
            //Line: 0




            #region snd
            var snd = new HTML.Audio.FromAssets.unfiltered_mix { volume = 0.9 };

            window.snd = snd;


            Native.window.onfocus +=
                delegate
                {
                    Console.WriteLine("WoodsXmasByRobert onfocus");
                    snd.volume = 0.9;
                };


            Native.window.onblur +=
                delegate
                {
                    Console.WriteLine("WoodsXmasByRobert onblur");
                    snd.volume = 0.1;

                    // if we are also not visible anymore
                    // and animations frame stop
                    // we should stop all sound
                };

            #endregion




            var canvas = new IHTMLCanvas();

            object webglRenderer_args = new object().With(
                 (dynamic a) =>
                 {
                     a.clearColor = 0x000000;
                     a.clearAlpha = 1.0;
                     a.preserveDrawingBuffer = true;
                     a.canvas = canvas;
                 }
             );

            var webglRenderer = new THREE.WebGLRenderer(
                webglRenderer_args
            );



            webglRenderer.autoClear = false;

            //var canvas = (IHTMLCanvas)webglRenderer.domElement;



            canvas.AttachToDocument();

            webglRenderer.setSize(Native.window.Width, Native.window.Height);

            var camera = new THREE.PerspectiveCamera(75, Native.window.Width / Native.window.Height, 1, 100000);

            camera.position.z = 0;
            camera.position.x = 0;
            camera.position.y = 0;

            window.camera = camera;

            var cameraTarget = new THREE.Vector3();
            cameraTarget.z = -400;
            camera.lookAt(cameraTarget);

            window.cameraTarget = cameraTarget;

            var loadingImage = THREE.ImageUtils.loadTexture(new loading().src);
            var map = THREE.ImageUtils.loadTexture(new snowflake().src);
            var starImage = THREE.ImageUtils.loadTexture(new flare().src);

            window.loadingImage = loadingImage;
            window.map = map;
            window.starImage = starImage;

            #region cursor
            var cursor = new pointer();

            cursor.style.zIndex = 0x1000;
            cursor.Hide();
            cursor.AttachToDocument();

            dynamic style = Native.Document.body.style;
            //http://stackoverflow.com/questions/7849002/how-can-i-set-the-hotspot-to-the-center-of-a-custom-cursor
            // http://stackoverflow.com/questions/5649608/custom-css-cursors
            style.cursor = "url(" + cursor.src + ") 16 16,pointer";
            #endregion




            var mouseXpercent = 0.5;
            var mouseYpercent = 0.5;

            #region onmousemove

            var CursorX = 0;
            var CursorY = 0;

            Native.Document.onmousemove +=
                e =>
                {
                    if (Native.Document.pointerLockElement == Native.Document.body)
                    {
                        cursor.Show();
                        CursorX += e.movementX;
                        CursorY += e.movementY;
                    }
                    else
                    {
                        cursor.Hide();
                        CursorX = e.CursorX;
                        CursorY = e.CursorY;
                    }

                    // keep cursor in view
                    CursorX = CursorX.Max(0).Min(Native.window.Width);
                    CursorY = CursorY.Max(0).Min(Native.window.Height);

                    if (Native.document.pointerLockElement == Native.document.body)
                    {
                        cursor.style.SetLocation(CursorX - 16, CursorY - 16);
                    }

                    var windowHalfX = Native.window.Width >> 1;
                    var windowHalfY = Native.window.Height >> 1;

                    var mouseX = (CursorX - windowHalfX);
                    var mouseY = (CursorY - windowHalfY);

                    mouseXpercent = mouseX / windowHalfX;
                    mouseYpercent = mouseY / windowHalfY;

                    window.mouseXpercent = mouseXpercent;
                    window.mouseYpercent = mouseYpercent;
                };
            #endregion

            Native.Document.onmousedown +=
                e =>
                {
                    if (e.MouseButton == IEvent.MouseButtonEnum.Right)
                        Native.Document.body.requestPointerLock();
                };


            new AppCode().Content.AttachToDocument().onload +=
                delegate
                {
                    // ScriptCoreLib should define this event!
                    snd.addEventListener(
                        "loadeddata",
                        new Action(
                            delegate
                            {
                                new IFunction("window.checkLoadingDone();").apply(Native.window);
                            }
                        )
                    );


                    var scene = (THREE.Scene)(object)window.scene;

                    scene.add(camera);


                    #region Cloud
                    {
                        object args = new object().With(
                            (dynamic a) =>
                            {
                                a.map = THREE.ImageUtils.loadTexture(new cloud().src);
                                a.transparent = true;
                                a.opacity = 0.17;
                                a.fog = false;
                            }
                        );

                        var cloudPlane = new THREE.PlaneGeometry(12500, 1880);
                        var cloud = new THREE.Mesh(cloudPlane, new THREE.MeshBasicMaterial(args));
                        cloud.position.set(300, 5350, -4450);
                        cloud.lookAt(camera.position);
                        scene.add(cloud);
                        window.cloud = cloud;
                    }
                    #endregion

                    #region Sky
                    {
                        object args = new object().With(
                            (dynamic a) =>
                            {
                                a.map = THREE.ImageUtils.loadTexture(new sky().src);
                                a.opacity = 0.57;
                                a.fog = false;
                            }
                        );

                        var skyPlane = new THREE.PlaneGeometry(9000, 6000);
                        var sky = new THREE.Mesh(skyPlane, new THREE.MeshBasicMaterial(args));

                        sky.scale.set(4, 2.5, 2.5);
                        sky.position.set(0, 7500, -6000);
                        sky.lookAt(camera.position);
                        scene.add(sky);
                        window.sky = sky;
                    }
                    #endregion

                    #region moon
                    {
                        dynamic moon_material_args = new object();

                        moon_material_args.map = THREE.ImageUtils.loadTexture(new moon().src);
                        moon_material_args.transparent = true;
                        moon_material_args.opacity = 0.3;
                        moon_material_args.fog = false;
                        moon_material_args.blending = THREE.AdditiveBlending;

                        var moonPlane = new THREE.PlaneGeometry(1000, 1000);
                        var moon = new THREE.Mesh(moonPlane,
                            new THREE.MeshBasicMaterial(
                                (object)moon_material_args
                            )
                        );




                        moon.position.set(300, 4300, -4600);
                        moon.lookAt(camera.position);
                        scene.add(moon);
                        window.moon = moon;
                    }
                    #endregion






                    #region subtitleArray
                    var subtitleArray = (IArray<THREE.Mesh>)(object)window.subtitleArray;

                    var textPlane = new THREE.PlaneGeometry(512, 80);

                    new SubtitlesImages().Images.WithEach(
                        i =>
                        {

                            object args = new object().With(
                              (dynamic a) =>
                              {
                                  a.map = THREE.ImageUtils.loadTexture(i.src);
                                  a.transparent = true;
                                  a.depthTest = false;
                              }
                          );


                            var sub = new THREE.Mesh(textPlane, new THREE.MeshBasicMaterial(args));
                            sub.position.z = -800;
                            sub.position.y = -550;
                            sub.visible = false;
                            camera.add(sub);
                            subtitleArray.push(sub);
                        }
                     );

                    {
                        var endPlane = new THREE.PlaneGeometry(500, 100);

                        object args = new object().With(
                            (dynamic a) =>
                            {
                                a.map = THREE.ImageUtils.loadTexture(new xmas().src);
                                a.transparent = true;
                                a.opacity = 1.0;
                                a.depthTest = false;
                            }
                        );


                        var end = new THREE.Mesh(endPlane, new THREE.MeshBasicMaterial(args));
                        end.position.z = -400;
                        end.position.y = 100;
                        end.visible = false;
                        camera.add(end);
                        subtitleArray.push(end);

                        window.end = end;
                    }


                    new IFunction("window.setupSubtitles();").apply(Native.window);
                    #endregion

                    var particles = (THREE.ParticleSystem)(object)window.particles;
                    var bgSprite = (THREE.Sprite)(object)window.bgSprite;
                    var loadingSprite = (THREE.Sprite)(object)window.loadingSprite;
                    var pointLight = (THREE.PointLight)(object)window.pointLight;
                    var treeArray = (IArray<THREE.Mesh>)(object)window.treeArray;
                    var rockArray = (IArray<THREE.Mesh>)(object)window.rockArray;
                    var flowerArray = (IArray<THREE.Mesh>)(object)window.flowerArray;


                    var groundMesh1 = (THREE.Mesh)(object)window.groundMesh1;
                    var groundMesh2 = (THREE.Mesh)(object)window.groundMesh2;


                    var renderModel = (object)window.renderModel;
                    var effectFilm = (object)window.effectFilm;
                    var effectVignette = (object)window.effectVignette;
                    var effectCopy = (object)window.effectCopy;


                    var composer = new THREE.EffectComposer(webglRenderer);
                    composer.addPass(renderModel);
                    composer.addPass(effectFilm);
                    composer.addPass(effectVignette);
                    composer.addPass(effectCopy);





                    var speedEffector_value = (int)new IFunction("return window.speedEffector.value;").apply(Native.window);

                    #region load
                    Action<string, Action<object>> load =
                        (src, yield) =>
                        {
                            new THREE.JSONLoader().load(
                               src,
                               IFunction.OfDelegate(yield)
                           );
                        };
                    #endregion

                    #region sled
                    load(
                        new WoodsXmasByRobert.Design.models.sleigh().Content.src,
                        geometry =>
                        {
                            Console.WriteLine("got sled!");

                            var sled = new THREE.Mesh(
                                geometry,
                                new THREE.MeshFaceMaterial()
                            );

                            var scale = 4;
                            sled.scale.set(scale, scale, scale);

                            sled.rotation.y = -Math.PI / 2;
                            sled.position.y = -290;
                            sled.position.z = -80;

                            scene.add(sled);

                            window.sled = sled;

                            new IFunction("window.checkLoadingDone();").apply(Native.window);
                        }
                    );
                    #endregion


                    var random = new Random();

                    #region treeDead
                    load(
                        new WoodsXmasByRobert.Design.models.treeDead().Content.src,
                        tree1Geo =>
                        {
                            Console.WriteLine("got treeDead!");

                            load(
                                 new WoodsXmasByRobert.Design.models.treeEvergreenHigh().Content.src,
                                 tree2Geo =>
                                 {
                                     Console.WriteLine("got treeEvergreenHigh!");

                                     var gridSize = 500;

                                     for (var x = 0; x < 8; x++)
                                     {
                                         for (var z = 0; z < 12; z++)
                                         {
                                             var geo = tree2Geo;
                                             if (random.NextDouble() < 0.25)
                                                 if (x != 0 && x != 7)
                                                 {
                                                     geo = tree1Geo;
                                                 }

                                             var mesh = new THREE.Mesh(geo, new THREE.MeshFaceMaterial());
                                             var scale = 1.2 + random.NextDouble();
                                             mesh.scale.set(scale, scale * 2, scale);

                                             var posx = 0.0;

                                             if (x < 4)
                                             {
                                                 posx = (x * gridSize) - (gridSize * 4) - 100 + random.NextDouble() * 100 - 50;
                                             }
                                             else
                                             {
                                                 posx = (x * gridSize) - 1400 + random.NextDouble() * 100 - 50;
                                             };

                                             var posz = -(z * gridSize) + random.NextDouble() * 100 - 50;

                                             mesh.position.set(posx, -400 - (random.NextDouble() * 80), posz);

                                             mesh.rotation.set((random.NextDouble() * 0.2) - 0.1, random.NextDouble() * Math.PI, (random.NextDouble() * 0.2) - 0.1);

                                             scene.add(mesh);

                                             treeArray.push(mesh);

                                         }
                                     }

                                     new IFunction("window.checkLoadingDone();").apply(Native.window);
                                 }
                             );
                        }
                    );
                    #endregion


                    #region bird
                    load(
                        new WoodsXmasByRobert.Design.models.eagle().Content.src,
                        geometry =>
                        {
                            Console.WriteLine("got bird!");

                            dynamic args = new object();

                            args.color = 0x000000;
                            args.morphTargets = true;
                            args.fog = false;

                            var bird = new THREE.MorphAnimMesh(
                                geometry,
                                new THREE.MeshBasicMaterial(
                                    (object)args
                                )
                            );

                            bird.duration = 1000;

                            bird.scale.set(4, 4, 4);
                            bird.rotation.y = Math.PI;
                            bird.position.set(0, 3000, -1500);

                            scene.add(bird);


                            window.bird = bird;

                            new IFunction("window.checkLoadingDone();").apply(Native.window);
                        }
                    );
                    #endregion


                    #region rock
                    load(
                        new WoodsXmasByRobert.Design.models.rock().Content.src,
                        geometry =>
                        {
                            Console.WriteLine("got rock!");

                            var numOfRocks = 25;
                            for (var i = 0; i < numOfRocks; ++i)
                            {
                                dynamic args = new object();

                                args.color = 0x444444;

                                var mesh = new THREE.Mesh(geometry, new THREE.MeshLambertMaterial((object)args));

                                var scale = 1 + (random.NextDouble() * 0.5);

                                mesh.scale.set(scale, scale, scale);
                                mesh.rotation.set(0, random.NextDouble() * Math.PI, 0);
                                mesh.position.set((random.NextDouble() * 4000) - 2000, -400, (random.NextDouble() * 6000) - 6000);

                                if (mesh.position.x < 45)
                                    if (mesh.position.x > 0)
                                    {
                                        mesh.position.x += 450;
                                    }

                                if (mesh.position.x > -450)
                                    if (mesh.position.x < 0)
                                    {
                                        mesh.position.x -= 450;
                                    }

                                scene.add(mesh);

                                rockArray.push(mesh);
                            }


                            new IFunction("window.checkLoadingDone();").apply(Native.window);
                        }
                    );
                    #endregion

                    #region horse
                    load(
                        new WoodsXmasByRobert.Design.models.horse().Content.src,
                        geometry =>
                        {
                            Console.WriteLine("got horse!");

                            dynamic horse_material_args = new object();

                            horse_material_args.color = 0x090601;
                            horse_material_args.morphTargets = true;

                            var horse = new THREE.MorphAnimMesh(geometry,
                                new THREE.MeshLambertMaterial(
                                    (object)horse_material_args
                                )
                            );

                            horse.duration = 1000;

                            horse.scale.set(2.5, 1.8, 2);
                            horse.rotation.y = Math.PI;
                            horse.position.set(0, -350, -700);

                            scene.add(horse);
                            window.horse = horse;

                            //checkLoadingDone();

                            // Handles
                            var plane = new THREE.PlaneGeometry(700, 10, 40, 1);

                            var l = Math.Floor(plane.vertices.Length / 2.0);

                            for (var i = 0; i < l; i++)
                            {

                                var offset = Math.Sin(i / 14) * 100;

                                plane.vertices[i].y -= offset;
                                plane.vertices[i + 41].y -= offset;


                                plane.vertices[i].z -= (i / 5) + (offset * -1) / 8;
                                plane.vertices[i + 41].z += (i / 5) - (offset * -1) / 8;

                            }

                            dynamic material_args = new object();

                            material_args.color = 0x090601;
                            material_args.side = THREE.DoubleSide;

                            var material = new THREE.MeshBasicMaterial(
                                (object)material_args
                            );

                            var leftHandle = new THREE.Mesh(plane, material);
                            leftHandle.position.y = -120;
                            leftHandle.position.z = -350;
                            leftHandle.position.x = -30;
                            leftHandle.rotation.y = -(Math.PI / 2) + 0.075;
                            leftHandle.rotation.x = Math.PI * 2 - 0.075;

                            scene.add(leftHandle);
                            window.leftHandle = leftHandle;

                            var rightHandle = new THREE.Mesh(plane, material);
                            rightHandle.position.y = -120;
                            rightHandle.position.z = -350;
                            rightHandle.position.x = 30;
                            rightHandle.rotation.y = -(Math.PI / 2) - 0.075;
                            rightHandle.scale.z = -1;
                            rightHandle.rotation.x = Math.PI * 2 - 0.075;
                            scene.add(rightHandle);
                            window.rightHandle = rightHandle;

                            new IFunction("window.checkLoadingDone();").apply(Native.window);
                        }
                    );
                    #endregion


                    #region flowerLoaded
                    Action<object, bool> flowerLoaded = (geometry, halfScale) =>
                    {

                        var numOfFlowers = 20;

                        var half = Math.Floor(numOfFlowers / 2.0);

                        dynamic args = new object();

                        args.color = 0x444444;


                        for (var i = 0; i < half; ++i)
                        {
                            var mesh = new THREE.Mesh(geometry,
                                new THREE.MeshLambertMaterial(
                                    (object)args
                                )
                            );

                            var scale = 1 + (random.NextDouble() * 1);
                            if (halfScale)
                            {
                                scale *= 0.6;
                            }
                            mesh.scale.set(scale, scale, scale);
                            mesh.rotation.set((random.NextDouble() * 0.6) - 0.3, random.NextDouble() * Math.PI, (random.NextDouble() * 0.6) - 0.3);
                            mesh.position.set((random.NextDouble() * 1000) - 500, -310, (random.NextDouble() * 6000) - 6000);

                            if (mesh.position.x < 100)
                                if (mesh.position.x > 0)
                                {
                                    mesh.position.x += 100;
                                }

                            if (mesh.position.x > -100)
                                if (mesh.position.x < 0)
                                {
                                    mesh.position.x -= 100;
                                }

                            scene.add(mesh);

                            flowerArray.push(mesh);
                        }

                        new IFunction("window.checkLoadingDone();").apply(Native.window);
                    };
                    #endregion


                    #region weeds01
                    load(
                        new WoodsXmasByRobert.Design.models.weeds01().Content.src,
                        geometry =>
                        {
                            Console.WriteLine("got weeds01!");

                            flowerLoaded(geometry, false);
                        }
                    );
                    #endregion

                    #region glowbulb
                    load(
                        new WoodsXmasByRobert.Design.models.glowbulb().Content.src,
                        geometry =>
                        {
                            Console.WriteLine("got glowbulb!");

                            flowerLoaded(geometry, true);
                        }
                    );
                    #endregion


                    #region run
                    Action<double> run =
                        delta =>
                        {
                            // trees
                            var mesh = default(THREE.Mesh);

                            for (var i = 0; i < treeArray.length; ++i)
                            {

                                mesh = treeArray[i];

                                // respawn
                                if (mesh.position.z > camera.position.z + 700)
                                {
                                    mesh.position.z -= 6000;

                                    var scale = 1.2 + random.NextDouble();
                                    mesh.scale.set(scale, scale * 2, scale);
                                }

                            }

                            // rocks
                            for (var i = 0; i < rockArray.length; ++i)
                            {

                                mesh = rockArray[i];

                                // respawn
                                if (mesh.position.z > camera.position.z + 400)
                                {
                                    mesh.position.z -= 6000;
                                }

                            }

                            // flowers
                            for (var i = 0; i < flowerArray.length; ++i)
                            {

                                mesh = flowerArray[i];

                                // respawn
                                if (mesh.position.z > camera.position.z + 400)
                                {
                                    mesh.position.z -= 6000;
                                }

                            }

                            // ground respawn
                            if (groundMesh1.position.z - 10000 > camera.position.z)
                            {
                                groundMesh1.position.z -= 40000;
                            }
                            if (groundMesh2.position.z - 10000 > camera.position.z)
                            {
                                groundMesh2.position.z -= 40000;
                            }
                        };
                    #endregion

                    var oldTime = new IDate().getTime();

                    var r = 0.0;

                    bool disableNextFrame = false;

                    #region loop
                    Action loop = delegate
                    {
                        var allLoaded = (bool)(object)window.allLoaded;

                        var horse = (THREE.MorphAnimMesh)(object)window.horse;
                        var bird = (THREE.MorphAnimMesh)(object)window.bird;

                        var leftHandle = (THREE.Mesh)(object)window.leftHandle;
                        var rightHandle = (THREE.Mesh)(object)window.rightHandle;

                        var moon = (THREE.Mesh)(object)window.moon;
                        var cloud = (THREE.Mesh)(object)window.cloud;
                        var sky = (THREE.Mesh)(object)window.sky;
                        var sled = (THREE.Mesh)(object)window.sled;

                        //new IFunction("this.loop();").apply(Native.Window);

                        var time = new IDate().getTime();
                        var delta = time - oldTime;
                        oldTime = time;

                        if (double.IsNaN(delta))
                        {
                            delta = 1000 / 60;
                        }

                        var maxSpeed = delta / 2;

                        if (allLoaded)
                        {

                            r += delta / 2000;
                            run(delta);

                            var noise = random.NextDouble() * 2;

                            camera.position.x = (50 * Math.Cos(r * 2)) * speedEffector_value;
                            camera.position.y = (2 * Math.Sin(r * 12) - 100) * speedEffector_value;

                            camera.up.x = (Math.Sin(r * 12) / 50) * speedEffector_value;

                            cameraTarget.y += (((camera.position.y + 80) + noise - mouseYpercent * 120) - cameraTarget.y) / 20;
                            cameraTarget.x += (mouseXpercent * 400 - cameraTarget.x) / 20;

                            var speed = (delta / 2) * speedEffector_value;

                            camera.position.z -= speed;
                            cameraTarget.z -= speed;
                            camera.lookAt(cameraTarget);

                            pointLight.position.z -= speed;

                            if (moon != null)
                            {
                                moon.position.z -= speed;
                            }

                            if (cloud != null)
                            {
                                cloud.position.z -= speed;
                            }

                            if (sky != null)
                            {
                                sky.position.z -= speed;
                            }

                            #region sled
                            if (sled != null)
                            {
                                sled.position.z -= speed;
                                sled.position.x = camera.position.x;
                            }
                            #endregion


                            #region bird
                            if (bird != null)
                            {
                                bird.position.x = 200 * Math.Cos(r) + ((bird.position.z - camera.position.z) / 10);
                                bird.position.y = 4000 + (Math.Sin(r) * 300);
                                bird.position.z -= maxSpeed * 1.25;

                                if (bird.position.z < camera.position.z - 10000)
                                {
                                    bird.position.z = camera.position.z - 500;
                                }

                                bird.updateAnimation(delta);
                            }
                            #endregion


                            #region horse
                            if (horse != null)
                            {
                                horse.position.z -= speed;
                                horse.position.x = camera.position.x;

                                horse.updateAnimation(speed * 2);

                                leftHandle.position.z -= speed;
                                leftHandle.position.x = camera.position.x - 37;

                                rightHandle.position.z -= speed;
                                rightHandle.position.x = camera.position.x + 40;

                                leftHandle.scale.y = 1 - Math.Abs(Math.Sin(camera.position.z / 150)) / 4;
                                rightHandle.scale.y = leftHandle.scale.y;
                            }
                            #endregion

                            particles.position.z -= speed;

                            new IFunction("e", "window.uniforms.globalTime.value += e;").apply(Native.window, delta * 0.00015);
                            new IFunction("e", "window.uniforms.speed.value = e;").apply(Native.window, speed / maxSpeed);

                            new IFunction("window.runSubtitles();").apply(Native.window);


                            //disableNextFrame = true;

                            if (__WoodsXmasByRobert_loaded != null)
                                __WoodsXmasByRobert_loaded();
                        }
                        else
                        {
                            if (loadingSprite != null)
                            {
                                loadingSprite.position.set(Native.window.Width >> 1, Native.window.Height >> 1, 0);
                                loadingSprite.rotation -= 0.08;
                            }
                        }

                        if (bgSprite != null)
                        {
                            bgSprite.position.set(Native.window.Width >> 1, Native.window.Height >> 1, 0);
                        }


                        new IFunction("window.TWEEN.update();").apply(Native.window);

                        //if (has_gl)
                        {
                            webglRenderer.clear();
                            composer.render(0.01);
                        }
                    };
                    #endregion


                    #region animate
                    Native.window.onframe += delegate
                    {
                        if (disableNextFrame)
                            return;

                        loop();
                    };

                    #endregion




                    Action AtResize = delegate
                    {

                        // notify the renderer of the size change
                        webglRenderer.setSize(Native.window.Width, Native.window.Height);

                        // update the camera
                        camera.aspect = Native.window.Width / Native.window.Height;
                        camera.updateProjectionMatrix();
                    };


                    #region onresize
                    Native.window.onresize +=
                        delegate
                        {
                            AtResize();
                        };
                    #endregion

                    AtResize();


                };



            Native.Document.body.ondblclick +=
                delegate
                {
                    Native.Document.body.requestFullscreen();
                };


            Native.Document.body.onmousedown +=
                 e =>
                 {
                     if (e.MouseButton == IEvent.MouseButtonEnum.Middle)
                     {
                         if (Native.Document.pointerLockElement == Native.Document.body)
                         {
                             // cant requestFullscreen while pointerLockElement
                             Console.WriteLine("exitPointerLock");
                             Native.Document.exitPointerLock();
                             Native.Document.exitFullscreen();
                             return;
                         }

                         Native.Document.body.requestFullscreen();
                         Native.Document.body.requestPointerLock();
                     }
                 };

            Native.Document.oncontextmenu +=
                e =>
                {
                    e.preventDefault();
                };


        }
Ejemplo n.º 56
0
 internal static void DelBlock(_CrtMemBlockHeader _pFirstBlock, _CrtMemBlockHeader _pLastBlock, pointer blk)
 {
 }
Ejemplo n.º 57
0
 public ip6_addr(pointer data, int offset)
     : base(data, offset)
 {
 }
Ejemplo n.º 58
0
 GetPointer(pointer, start, start + length, out startPointer, out endPointer);
Ejemplo n.º 59
0
#pragma warning disable CA2214 // Do not call overridable methods in constructors
        public ComMemory(IntPtr pointer, int size) => Replace(pointer, size);
Ejemplo n.º 60
0
 public tcp_hdr(byte[] buffer, int offset)
     : base(buffer, offset)
 {
     _src = new pointer(data, offset + 0); /* ushort */
     _dest = new pointer(data, offset + 2); /* ushort */
     _seqno = new pointer(data, offset + 4); /* uint */
     _ackno = new pointer(data, offset + 8); /* uint */
     __hdrlen_rsvd_flags = new pointer(data, offset + 12); /* ushort */
     _wnd = new pointer(data, offset + 14); /* ushort */
     _chksum = new pointer(data, offset + 16); /* ushort */
     _urgp = new pointer(data, offset + 18); /* ushort */
 }