コード例 #1
0
        public static tAsyncCall *Internal_GetInfo(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            tMD_TypeDef *      pEnumType = System_RuntimeType.DeRef((byte *)((tMD_TypeDef **)pParams)[0]);
            uint               i, retIndex;
            /*HEAP_PTR*/ byte *names, values;

            // An enum type always has just one non-literal field, with all other fields being the values.
            names  = System_Array.NewVector(Type.types[Type.TYPE_SYSTEM_ARRAY_STRING], pEnumType->numFields - 1);
            values = System_Array.NewVector(Type.types[Type.TYPE_SYSTEM_ARRAY_INT32], pEnumType->numFields - 1);

            for (i = 0, retIndex = 0; i < pEnumType->numFields; i++)
            {
                tMD_FieldDef * pField = pEnumType->ppFields[i];
                tSystemString *name;
                int            value;

                if (!MetaData.FIELD_ISLITERAL(pField))
                {
                    continue;
                }

                name = System_String.FromCharPtrASCII(pField->name);
                System_Array.StoreElement(names, retIndex, (byte *)&name);
                MetaData.GetConstant(pField->pMetaData, pField->tableIndex, (byte *)&value);
                System_Array.StoreElement(values, retIndex, (byte *)&value);
                retIndex++;
            }

            *(((/*HEAP_PTR*/ byte ***)pParams)[1]) = names;
            *(((/*HEAP_PTR*/ byte ***)pParams)[2]) = values;

            return(null);
        }
コード例 #2
0
        public static tAsyncCall *get_Namespace(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            tRuntimeType * pRuntimeType = (tRuntimeType *)pThis_;
            tSystemString *strResult;

            strResult = System_String.FromCharPtrASCII(pRuntimeType->pTypeDef->nameSpace);
            *(tSystemString **)pReturnValue = strResult;

            return(null);
        }
コード例 #3
0
ファイル: System.Type.cs プロジェクト: pandyer/dnaunity
        public static void DotNetStringToCString(byte *buf, uint bufLength, tSystemString *dotnetString)
        {
            uint   stringLen;
            string monoStr;
            int    i;

            monoStr   = System_String.ToMonoString(dotnetString);
            stringLen = bufLength - 1 < (uint)monoStr.Length ? bufLength - 1 : (uint)monoStr.Length;
            for (i = 0; i < stringLen; i++)
            {
                buf[i] = (byte)monoStr[i];
            }
            buf[i] = 0;
        }
コード例 #4
0
        public static tAsyncCall *ToString(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            char           ch;
            string         s;
            tSystemString *pResult;

            ch      = *(char *)pThis_;
            s       = ch.ToString();
            pResult = System_String.FromMonoString(s);

            Sys.INTERNALCALL_RESULT_PTR(pReturnValue, pResult);

            return(null);
        }
コード例 #5
0
        public static void DotNetStringToCString(byte *buf, uint bufLength, /*STRING*/ byte *dotnetString)
        {
            uint stringLen;
            /*STRING2*/
            char *dotnetString2 = System_String.GetString(null /* This is ok */, dotnetString, &stringLen);

            if (stringLen > bufLength)
            {
                Sys.Crash("String of length %i was too long for buffer of length %i\n", stringLen, bufLength);
            }

            int i;

            for (i = 0; i < stringLen; i++)
            {
                buf[i] = (byte)dotnetString2[i];
            }
            buf[i] = 0;
        }
コード例 #6
0
ファイル: System.Type.cs プロジェクト: pandyer/dnaunity
        public static tAsyncCall *GetMethod(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            // Read param
            byte *methodName = stackalloc byte[256];

            DotNetStringToCString(methodName, (uint)256, ((tSystemString **)pParams)[0]);

            // Get metadata for the 'this' type
            tRuntimeType *pRuntimeType = (tRuntimeType *)pThis_;
            tMD_TypeDef * pTypeDef     = pRuntimeType->pTypeDef;

            // Search for the method by name
            for (int i = 0; i < pTypeDef->numMethods; i++)
            {
                if (S.strcmp(pTypeDef->ppMethods[i]->name, methodName) == 0)
                {
                    tMD_MethodDef *pMethodInstDef = pTypeDef->ppMethods[i];

                    // Instantiate a MethodInfo
                    tMethodInfo *pMethodInfo = (tMethodInfo *)Heap.AllocType(Type.types[Type.TYPE_SYSTEM_REFLECTION_METHODINFO]);

                    // Assign ownerType
                    pMethodInfo->methodBase.ownerType = pThis_;

                    // Assign name
                    pMethodInfo->methodBase.name = System_String.FromCharPtrASCII(pMethodInstDef->name);

                    // Assign method def
                    pMethodInfo->methodBase.methodDef = pMethodInstDef;

                    *(/*HEAP_PTR*/ byte **)pReturnValue = (/*HEAP_PTR*/ byte *)pMethodInfo;
                    return(null);
                }
            }

            // Not found
            *(/*HEAP_PTR*/ byte **)pReturnValue = null;
            return(null);
        }
コード例 #7
0
ファイル: System.Type.cs プロジェクト: pandyer/dnaunity
        public static tAsyncCall *GetProperties(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            tRuntimeType *pRuntimeType = (tRuntimeType *)pThis_;
            tMD_TypeDef * pTypeDef     = pRuntimeType->pTypeDef;
            tMetaData *   pMetaData    = pTypeDef->pMetaData;

            // First we search through the table of propertymaps to find the propertymap for the requested type
            uint i;
            /*IDX_TABLE*/
            uint firstIdx = 0, lastIdxExc = 0;
            uint numPropertyRows    = pMetaData->tables.numRows[MetaDataTable.MD_TABLE_PROPERTY];
            uint numPropertymapRows = pMetaData->tables.numRows[MetaDataTable.MD_TABLE_PROPERTYMAP];

            for (i = 1; i <= numPropertymapRows; i++)
            {
                tMD_PropertyMap *pPropertyMap = (tMD_PropertyMap *)MetaData.GetTableRow(pMetaData, MetaData.MAKE_TABLE_INDEX(MetaDataTable.MD_TABLE_PROPERTYMAP, i));
                if (pPropertyMap->parent == pTypeDef->tableIndex)
                {
                    firstIdx = MetaData.TABLE_OFS(pPropertyMap->propertyList);
                    if (i < numPropertymapRows)
                    {
                        tMD_PropertyMap *pNextPropertyMap = (tMD_PropertyMap *)MetaData.GetTableRow(pMetaData, MetaData.MAKE_TABLE_INDEX(MetaDataTable.MD_TABLE_PROPERTYMAP, i + 1));
                        lastIdxExc = MetaData.TABLE_OFS(pNextPropertyMap->propertyList);
                    }
                    else
                    {
                        lastIdxExc = numPropertyRows + 1;
                    }
                    break;
                }
            }

            // Instantiate a PropertyInfo[]
            uint         numProperties = lastIdxExc - firstIdx;
            tMD_TypeDef *pArrayType    = Type.GetArrayTypeDef(Type.types[Type.TYPE_SYSTEM_REFLECTION_PROPERTYINFO], null, null);
            /*HEAP_PTR*/
            byte *ret = System_Array.NewVector(pArrayType, numProperties);

            // Allocate to return value straight away, so it cannot be GCed
            *(/*HEAP_PTR*/ byte **)pReturnValue = ret;

            // Now fill the PropertyInfo[]
            for (i = 0; i < numProperties; i++)
            {
                tMD_Property *pPropertyMetadata = (tMD_Property *)MetaData.GetTableRow(pMetaData, MetaData.MAKE_TABLE_INDEX(MetaDataTable.MD_TABLE_PROPERTY, firstIdx + i));

                // Instantiate PropertyInfo and put it in the array
                tPropertyInfo *pPropertyInfo = (tPropertyInfo *)Heap.AllocType(Type.types[Type.TYPE_SYSTEM_REFLECTION_PROPERTYINFO]);
                System_Array.StoreElement(ret, i, (byte *)&pPropertyInfo);

                // Assign ownerType
                pPropertyInfo->ownerType = pThis_;

                // Assign name
                pPropertyInfo->name = System_String.FromCharPtrASCII(pPropertyMetadata->name);

                // Assign propertyType
                uint  sigLength;
                byte *typeSig = MetaData.GetBlob(pPropertyMetadata->typeSig, &sigLength);
                MetaData.DecodeSigEntry(&typeSig); // Ignored: prolog
                MetaData.DecodeSigEntry(&typeSig); // Ignored: number of 'getter' parameters
                tMD_TypeDef *propertyTypeDef = Type.GetTypeFromSig(pMetaData, &typeSig, null, null);
                MetaData.Fill_TypeDef(propertyTypeDef, null, null);
                pPropertyInfo->propertyType = Type.GetTypeObject(propertyTypeDef);
            }

            return(null);
        }
コード例 #8
0
 public static tAsyncCall *GetOSVersionString(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
 {
     *(tSystemString **)pReturnValue = System_String.FromMonoString(System.Environment.OSVersion.Version.ToString());
     return(null);
 }