Esempio n. 1
0
        public static tAsyncCall *Write(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            byte * /*HEAP_PTR*/ _string;
            char *wStr;
            uint  strLen;

            _string = *(byte **)pParams;
            if (_string != null)
            {
                #if VS_TESTING || !(UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_WEBGL || UNITY_STANDALONE)
                wStr = System_String.GetString(pCallNative, _string, &strLen);
                string netStr = System.Runtime.InteropServices.Marshal.PtrToStringUni((System.IntPtr)wStr, (int)strLen);
                System.Console.Write(netStr);
                #else
                wStr = System_String.GetString(pCallNative, _string, &strLen);
                if (wStr != null && strLen > 0 && !(strLen == 1 && wStr[0] == '\n') && !(strLen == 2 && wStr[0] == '\r' && wStr[1] == '\n'))
                {
                    string netStr = System.Runtime.InteropServices.Marshal.PtrToStringUni((System.IntPtr)wStr, (int)strLen);
                    UnityEngine.Debug.Log(netStr);
                }
                #endif
            }

            return(null);
        }
Esempio n. 2
0
        // Get the size of a heap entry, NOT including the header
        // This works by returning the size of the type, unless the type is an array or a string,
        // which are the only two type that can have variable sizes
        static uint GetSize(tHeapEntry *pHeapEntry)
        {
            tMD_TypeDef *pType = pHeapEntry->pTypeDef;

            if (pType == Type.types[Type.TYPE_SYSTEM_STRING])
            {
                // If it's a string, return the string length in bytes
                return(System_String.GetNumBytes((/*HEAP_PTR*/ byte *)(pHeapEntry + 1)));
            }
            if (MetaData.TYPE_ISARRAY(pType))
            {
                // If it's an array, return the array length * array element size
                return(System_Array.GetNumBytes(null /* This is ok */, (/*HEAP_PTR*/ byte *)(pHeapEntry + 1), pType->pArrayElementType));
            }
            // If it's not string or array, just return the instance memory size
            return(pType->instanceMemSize);
        }
Esempio n. 3
0
        public static tAsyncCall *Write(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            tSystemString * /*HEAP_PTR*/ _string;
            string monoStr;

            _string = *(tSystemString **)(pParams + 0);
            monoStr = System_String.ToMonoString(_string);
            if (_string != null)
            {
                #if VS_TESTING || !(UNITY_5 || UNITY_2017 || UNITY_2018)
                System.Console.Write(monoStr);
                #else
                int len = monoStr.Length;
                if (monoStr != null && len > 0 && !(len == 1 && monoStr[0] == '\n') && !(len == 2 && monoStr[0] == '\r' && monoStr[1] == '\n'))
                {
                    UnityEngine.Debug.Log(monoStr);
                }
                #endif
            }

            return(null);
        }
Esempio n. 4
0
        public static int Execute(tCLIFile *pThis, string[] args)
        {
            tThread *          pThread;
            /*HEAP_PTR*/ byte *pArgs;
            int i;

            // Create a string array for the program arguments
            // Don't include the argument that is the program name.
            pArgs = System_Array.NewVector(Type.types[Type.TYPE_SYSTEM_ARRAY_STRING], (uint)(args.Length - 1));
            Heap.MakeUndeletable(pArgs);
            for (i = 1; i < args.Length; i++)
            {
                tSystemString *pArgStr = System_String.FromMonoString(args[i]);
                System_Array.StoreElement(pArgs, (uint)(i - 1), (byte *)&pArgStr);
            }

            // Create the main application thread
            pThread = Thread.New();
            Thread.SetEntryPoint(pThread, pThis->pMetaData, pThis->entryPoint, (byte *)&pArgs, (uint)sizeof(void *));

            return(Thread.Execute());
        }
Esempio n. 5
0
        private static tAsyncCall *ToString_Internal(byte *pThis, byte *pParams, byte *pReturnValue, System.TypeCode typecode)
        {
            tSystemString *pFormat;
//            byte* pFormatProvider;
            string         format, s;
            tSystemString *pResult;

            pFormat = (*((tSystemString **)(pParams + 0)));
            format  = ToMonoString(pFormat);

            // Ignore IFormatProvider for now!
            //pFormatProvider = (*((tSystemString**)(pParams + Sys.S_PTR)));

            switch (typecode)
            {
            case System.TypeCode.Byte:
                s = (*(byte *)pThis).ToString(format);
                break;

            case System.TypeCode.SByte:
                s = (*(sbyte *)pThis).ToString(format);
                break;

            case System.TypeCode.UInt16:
                s = (*(ushort *)pThis).ToString(format);
                break;

            case System.TypeCode.Int16:
                s = (*(short *)pThis).ToString(format);
                break;

            case System.TypeCode.UInt32:
                s = (*(uint *)pThis).ToString(format);
                break;

            case System.TypeCode.Int32:
                s = (*(int *)pThis).ToString(format);
                break;

            case System.TypeCode.UInt64:
                s = (*(ulong *)pThis).ToString(format);
                break;

            case System.TypeCode.Int64:
                s = (*(long *)pThis).ToString(format);
                break;

            case System.TypeCode.Single:
                s = (*(float *)pThis).ToString(format);
                break;

            case System.TypeCode.Double:
                s = (*(double *)pThis).ToString(format);
                break;

            default:
                throw new System.NotImplementedException();
            }

            pResult = System_String.FromMonoString(s);

            Sys.INTERNALCALL_RESULT_PTR(pReturnValue, pResult);

            return(null);
        }