/* * private static String GetRelativeSearchPathInternal(Object appDomain); */ ILString *_IL_AppDomain_GetRelativeSearchPathInternal(ILExecThread *thread, ILObject *appDomain) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { const char *appRelativePath; IL_METADATA_RDLOCK((ILExecProcess *)appDomain); appRelativePath = ILContextGetRelativeSearchDir(((ILExecProcess *)appDomain)->context); if(appRelativePath) { ILString *result; IL_METADATA_UNLOCK((ILExecProcess *)appDomain); result = ILStringCreate(thread, appRelativePath); if(!result) { ILExecThreadThrowOutOfMemory(thread); return 0; } return result; } IL_METADATA_UNLOCK((ILExecProcess *)appDomain); } return 0; }
/* * private static String GetFriendlyNameInternal(Object appDomain); */ ILString *_IL_AppDomain_GetFriendlyNameInternal(ILExecThread *thread, ILObject *appDomain) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { char *friendlyName; IL_METADATA_RDLOCK((ILExecProcess *)appDomain); friendlyName = _ILExecProcessGetFriendlyName(((ILExecProcess *)appDomain)); if(friendlyName) { ILString *result; IL_METADATA_UNLOCK((ILExecProcess *)appDomain); result = ILStringCreate(thread, friendlyName); if(!result) { ILExecThreadThrowOutOfMemory(thread); return 0; } return result; } IL_METADATA_UNLOCK((ILExecProcess *)appDomain); } return 0; }
/* * private static String GetBaseDirectoryInternal(Object appDomain); */ ILString *_IL_AppDomain_GetBaseDirectoryInternal(ILExecThread *thread, ILObject *appDomain) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { const char *baseDir; IL_METADATA_RDLOCK((ILExecProcess *)appDomain); baseDir = ILContextGetApplicationBaseDir(((ILExecProcess *)appDomain)->context); if(baseDir) { ILString *result; IL_METADATA_UNLOCK((ILExecProcess *)appDomain); result = ILStringCreate(thread, baseDir); if(!result) { ILExecThreadThrowOutOfMemory(thread); return 0; } return result; } IL_METADATA_UNLOCK((ILExecProcess *)appDomain); } return 0; }
ILObject *_ILGetClrType(ILExecThread *thread, ILClass *classInfo) { ILObject *obj; classInfo = ILClassResolve(classInfo); if(!classInfo) { thread->thrownException = _ILSystemException (thread, "System.TypeInitializationException"); return 0; } /* Make sure that the class has been laid out */ IL_METADATA_WRLOCK(_ILExecThreadProcess(thread)); if(!_ILLayoutClass(_ILExecThreadProcess(thread), classInfo)) { IL_METADATA_UNLOCK(_ILExecThreadProcess(thread)); thread->thrownException = _ILSystemException (thread, "System.TypeInitializationException"); return 0; } IL_METADATA_UNLOCK(_ILExecThreadProcess(thread)); /* Does the class already have a "ClrType" instance? */ if(((ILClassPrivate *)(classInfo->userData))->clrType) { return ((ILClassPrivate *)(classInfo->userData))->clrType; } /* Create a new "ClrType" instance */ if(!(thread->process->clrTypeClass)) { thread->thrownException = _ILSystemException (thread, "System.TypeInitializationException"); return 0; } obj = _ILEngineAllocObject(thread, thread->process->clrTypeClass); if(!obj) { return 0; } /* Fill in the object with the class information */ ((System_Reflection *)obj)->privateData = classInfo; /* Attach the object to the class so that it will be returned for future calls to this function */ ((ILClassPrivate *)(classInfo->userData))->clrType = obj; /* Return the object to the caller */ return obj; }
/* * private static void SetPrivateBinPaths(Object appDomain, String[] splitPaths); */ void _IL_AppDomainSetup_SetPrivateBinPaths(ILExecThread *thread, ILObject *appDomain, System_Array *splitPaths) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { if (splitPaths && (ArrayLength(splitPaths) > 0)) { char **libraryDirs = 0; int numLibraryDirs = 0; System_String **buffer = (System_String **)ArrayToBuffer(splitPaths); int i; /* loop counter */ /* allocate the array for the the new directories */ if (!(libraryDirs = (char **)ILMalloc(sizeof(char *) * ArrayLength(splitPaths)))) { ILExecThreadThrowOutOfMemory(thread); return; } /* now append the dirs */ for (i = 0; i < ArrayLength(splitPaths); i++) { if (buffer[i] && buffer[i]->length) { libraryDirs[numLibraryDirs] = _ToAnsiString(thread, (ILString *)buffer[i]); numLibraryDirs++; } } IL_METADATA_WRLOCK((ILExecProcess *)appDomain); /* now set the new library dirs */ ILContextSetLibraryDirs(((ILExecProcess *)appDomain)->context, libraryDirs, numLibraryDirs); IL_METADATA_UNLOCK((ILExecProcess *)appDomain); } else { IL_METADATA_WRLOCK((ILExecProcess *)appDomain); /* now clear the library dirs */ ILContextClearLibraryDirs(((ILExecProcess *)appDomain)->context); IL_METADATA_UNLOCK((ILExecProcess *)appDomain); } } }
/* * private static void SetRelativeSearchPathInternal(Object appDomain, String appRelativePath); */ void _IL_AppDomain_SetRelativeSearchPathInternal(ILExecThread *thread, ILObject *appDomain, ILString *appRelativePath) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { if(appRelativePath) { char *path = _ToAnsiString(thread, appRelativePath); if(!path) { ILExecThreadThrowOutOfMemory(thread); return; } IL_METADATA_WRLOCK((ILExecProcess *)appDomain); ILContextSetRelativeSearchDir(((ILExecProcess *)appDomain)->context, path); } else { IL_METADATA_WRLOCK((ILExecProcess *)appDomain); ILContextSetRelativeSearchDir(((ILExecProcess *)appDomain)->context, 0); } IL_METADATA_UNLOCK((ILExecProcess *)appDomain); } }
/* * private static void SetFriendlyNameInternal(Object appDomain, String friendlyName); */ void _IL_AppDomain_SetFriendlyNameInternal(ILExecThread *thread, ILObject *appDomain, ILString *friendlyName) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { if(friendlyName) { char *name = _ToAnsiString(thread, friendlyName); if(!name) { ILExecThreadThrowOutOfMemory(thread); return; } IL_METADATA_WRLOCK((ILExecProcess *)appDomain); ILExecProcessSetFriendlyName((ILExecProcess *)appDomain, name); } else { IL_METADATA_WRLOCK((ILExecProcess *)appDomain); ILExecProcessSetFriendlyName((ILExecProcess *)appDomain, 0); } IL_METADATA_UNLOCK((ILExecProcess *)appDomain); } }
/* * private static void SetBaseDirectoryInternal(Object appDomain, String baseDirectory); */ void _IL_AppDomain_SetBaseDirectoryInternal(ILExecThread *thread, ILObject *appDomain, ILString *baseDirectory) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { if(baseDirectory) { char *path = _ToAnsiString(thread, baseDirectory); if(!path) { ILExecThreadThrowOutOfMemory(thread); return; } IL_METADATA_WRLOCK((ILExecProcess *)appDomain); ILContextSetApplicationBaseDir(((ILExecProcess *)appDomain)->context, path); } else { IL_METADATA_WRLOCK((ILExecProcess *)appDomain); ILContextSetApplicationBaseDir(((ILExecProcess *)appDomain)->context, 0); } IL_METADATA_UNLOCK((ILExecProcess *)appDomain); } }
/* * private static void AppendPrivatePathInternal(Object appDomain, String[] splitPaths); */ void _IL_AppDomain_AppendPrivatePathsInternal(ILExecThread *thread, ILObject *appDomain, System_Array *splitPaths) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { if (splitPaths && (ArrayLength(splitPaths) > 0)) { char **libraryDirs; int numLibraryDirs; char **newLibraryDirs; System_String **buffer = (System_String **)ArrayToBuffer(splitPaths); int i; /* loop counter */ IL_METADATA_WRLOCK((ILExecProcess *)appDomain); ILContextGetLibraryDirs(((ILExecProcess *)appDomain)->context, &libraryDirs, &numLibraryDirs); /* allocate the array for the old + the new directories */ if (!(newLibraryDirs = (char **)ILMalloc(sizeof(char *) * (numLibraryDirs + ArrayLength(splitPaths))))) { IL_METADATA_UNLOCK((ILExecProcess *)appDomain); ILExecThreadThrowOutOfMemory(thread); return; } /* copy over the old directories */ for (i = 0; i < numLibraryDirs; i++) { newLibraryDirs[i] = libraryDirs[i]; } /* now append the new dirs */ for (i = 0; i < ArrayLength(splitPaths); i++) { if (buffer[i] && buffer[i]->length) { newLibraryDirs[numLibraryDirs] = ILStringToPathname(thread, (ILString *)buffer[i]); numLibraryDirs++; } } /* now set the new library dirs */ ILContextSetLibraryDirs(((ILExecProcess *)appDomain)->context, newLibraryDirs, numLibraryDirs); IL_METADATA_UNLOCK((ILExecProcess *)appDomain); } } }
/* * private static void ClearShadowCopyPathInternal(Object appDomain); */ void _IL_AppDomain_ClearShadowCopyPathInternal(ILExecThread *thread, ILObject *appDomain) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { IL_METADATA_WRLOCK((ILExecProcess *)appDomain); ILContextClearShadowCopyDirs(((ILExecProcess *)appDomain)->context); IL_METADATA_UNLOCK((ILExecProcess *)appDomain); } }
/* * private static void SetShadowCopyFilesInternal(Object appDomain, ILBool shadowCopyFiles); */ void _IL_AppDomain_SetShadowCopyFilesInternal(ILExecThread *thread, ILObject *appDomain, ILBool shadowCopyFiles) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { IL_METADATA_WRLOCK((ILExecProcess *)appDomain); ILContextSetShadowCopyFiles(((ILExecProcess *)appDomain)->context, (int)shadowCopyFiles); IL_METADATA_UNLOCK((ILExecProcess *)appDomain); } }
/* * private static void GetPrivateBinPaths(Object appDomain, ref String[] splitPaths); */ void _IL_AppDomainSetup_GetPrivateBinPaths(ILExecThread *thread, ILObject *appDomain, System_Array **splitPaths) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { char **libraryDirs = 0; int numLibraryDirs = 0; IL_METADATA_RDLOCK((ILExecProcess *)appDomain); /* now clear the library dirs */ ILContextGetLibraryDirs(((ILExecProcess *)appDomain)->context, &libraryDirs, &numLibraryDirs); IL_METADATA_UNLOCK((ILExecProcess *)appDomain); if (numLibraryDirs > 0) { System_Array *array; ILString **buffer; int i; /* loop counter */ /* create the assembly array */ array = (System_Array *)ILExecThreadNew(thread, "[oSystem.String;", "(Ti)V", (ILVaInt)numLibraryDirs); if (!array) { ILExecThreadThrowOutOfMemory(thread); return; } buffer = ArrayToBuffer(array); for (i = 0; i < numLibraryDirs; i++) { buffer[i] = ILStringCreate(thread, libraryDirs[i]); } /* return the array */ *splitPaths = array; } else { *splitPaths = 0; } } }
/* * private static void SetShadowCopyPathInternal(Object appDomain, String[] splitPaths); */ void _IL_AppDomain_SetShadowCopyPathInternal(ILExecThread *thread, ILObject *appDomain, System_Array *splitPaths) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { if (splitPaths && (ArrayLength(splitPaths) > 0)) { char **shadowCopyDirs; int numShadowCopyDirs = 0; System_String **buffer = (System_String **)ArrayToBuffer(splitPaths); int i; /* loop counter */ /* allocate the array for the directories */ if (!(shadowCopyDirs = (char **)ILMalloc(sizeof(char *) * (ArrayLength(splitPaths))))) { ILExecThreadThrowOutOfMemory(thread); return; } /* now copy the dirs */ for (i = 0; i < ArrayLength(splitPaths); i++) { if (buffer[i] && buffer[i]->length) { shadowCopyDirs[numShadowCopyDirs] = _ToAnsiString(thread, (ILString *)buffer[i]); numShadowCopyDirs++; } } IL_METADATA_WRLOCK((ILExecProcess *)appDomain); /* now set the new shadow copy dirs */ ILContextSetShadowCopyDirs(((ILExecProcess *)appDomain)->context, shadowCopyDirs, numShadowCopyDirs); IL_METADATA_UNLOCK((ILExecProcess *)appDomain); } else { _IL_AppDomain_ClearShadowCopyPathInternal(thread, appDomain); } } }
/* * private static Assembly[] GetAssembliesInternal(Object appDomain); */ System_Array *_IL_AppDomain_GetAssembliesInternal(ILExecThread *thread, ILObject *appDomain) { if(!IsAppDomainUnloaded(thread, (ILExecProcess *)appDomain)) { ILContext *context; ILImage *image; ILInt32 num; System_Array *array; ILObject **buffer; ILImage **images; ILImage **ptr; IL_METADATA_RDLOCK((ILExecProcess *)appDomain); context = ((ILExecProcess *)appDomain)->context; /* count out the number of images */ image = 0; num = 0; while((image = ILContextNextImage(context, image)) != 0) { ++num; } /* create the image array */ if (!(images = (ILImage **)ILMalloc(sizeof(ILImage *)*num))) { IL_METADATA_UNLOCK((ILExecProcess *)appDomain); ILExecThreadThrowOutOfMemory(thread); return 0; } /* fill the image array */ image = 0; ptr = images; while((image = ILContextNextImage(context, image)) != 0) { *ptr = image; ++ptr; } IL_METADATA_UNLOCK((ILExecProcess *)appDomain); /* create the assembly array */ array = (System_Array *)ILExecThreadNew(thread, "[oSystem.Reflection.Assembly;", "(Ti)V", (ILVaInt)num); if(!array) { ILExecThreadThrowOutOfMemory(thread); return 0; } /* fill the assembly array */ ptr = images; buffer = (ILObject **)(ArrayToBuffer(array)); while(num > 0) { *buffer = ImageToAssembly(thread, *ptr); ++buffer; ++ptr; --num; } /* cleanup */ ILFree(images); /* return the assembly array */ return array; } return (System_Array *)0; }