/*
* appdomain.c: AppDomain functions
*
- * Author:
+ * Authors:
* Dietmar Maurer (dietmar@ximian.com)
* Patrik Torstensson
+ * Gonzalo Paniagua Javier (gonzalo@ximian.com)
*
- * (C) 2001 Ximian, Inc.
+ * (c) 2001-2003 Ximian, Inc. (http://www.ximian.com)
*/
#include <config.h>
HANDLE mono_delegate_semaphore = NULL;
CRITICAL_SECTION mono_delegate_section;
+static gunichar2 process_guid [36];
+static gboolean process_guid_set = FALSE;
+
static MonoAssembly *
mono_domain_assembly_preload (MonoAssemblyName *aname,
gchar **assemblies_path,
g_assert (mono_delegate_semaphore != INVALID_HANDLE_VALUE);
InitializeCriticalSection (&mono_delegate_section);
+ mono_context_init (domain);
+ mono_context_set (domain->default_context);
+
mono_thread_init (start_cb, attach_cb);
/* GC init has to happen after thread init */
return;
}
+void
+mono_context_init (MonoDomain *domain)
+{
+ MonoClass *class;
+ MonoAppContext *context;
+
+ class = mono_class_from_name (mono_defaults.corlib, "System.Runtime.Remoting.Contexts", "Context");
+ context = (MonoAppContext *) mono_object_new (domain, class);
+ context->domain_id = domain->domain_id;
+ context->context_id = 0;
+ domain->default_context = context;
+}
+
/* This must not be called while there are still running threads executing
* managed code.
*/
data->setup = setup;
data->friendly_name = mono_string_to_utf8 (friendly_name);
+ mono_context_init (data);
+
/* FIXME: what to do next ? */
return ad;
gint i;
gint npaths = 0;
gchar **pvt_split = NULL;
+ GError *error = NULL;
if (domain->search_path != NULL)
return;
/* FIXME: is this needed? */
if (strncmp (*tmp, "file://", 7) == 0) {
gchar *file = *tmp;
- *tmp = g_strdup (*tmp + 7);
- g_free (file);
+ gchar *uri = *tmp;
+
+ if (uri [7] != '/')
+ uri = g_strdup_printf ("file:///%s", uri + 7);
+
+ *tmp = g_filename_from_uri (uri, NULL, &error);
+ if (uri != file)
+ g_free (uri);
+
+ if (error != NULL) {
+ g_warning ("%s\n", error->message);
+ g_error_free (error);
+ *tmp = file;
+ } else {
+ g_free (file);
+ }
}
} else {
name = filename = mono_string_to_utf8 (fname);
- /* FIXME: move uri handling to mono_assembly_open */
- if (strncmp (filename, "file://", 7) == 0)
- filename += 7;
-
ass = mono_assembly_open (filename, &status);
g_free (name);
value = g_strstrip (g_strdup (value));
len = strlen (value);
if (len % 2) {
+ g_free (value);
g_strfreev (parts);
return FALSE;
}
if (i % 2) {
l = g_ascii_xdigit_value (value [i]);
if (l == -1) {
+ g_free (value);
g_strfreev (parts);
return FALSE;
}
} else {
h = g_ascii_xdigit_value (value [i]);
if (h == -1) {
+ g_free (value);
g_strfreev (parts);
return FALSE;
}
}
}
+ g_free (value);
/*
g_print ("PublicKeyToken: ");
return mono_context_get ();
}
+MonoAppContext *
+ves_icall_System_AppDomain_InternalGetDefaultContext ()
+{
+ MONO_ARCH_SAVE_REGS;
+
+ return mono_domain_get ()->default_context;
+}
+
MonoAppContext *
ves_icall_System_AppDomain_InternalSetContext (MonoAppContext *mc)
{
MonoAppContext *old_context = mono_context_get ();
- MonoDomain *context_domain = mono_domain_get_by_id (mc->domain_id);
MONO_ARCH_SAVE_REGS;
mono_context_set (mc);
- mono_domain_set (context_domain);
return old_context;
}
+
+MonoString *
+ves_icall_System_AppDomain_InternalGetProcessGuid (MonoString* newguid)
+{
+ mono_domain_lock (mono_root_domain);
+ if (process_guid_set) {
+ mono_domain_unlock (mono_root_domain);
+ return mono_string_new_utf16 (mono_domain_get (), process_guid, sizeof(process_guid)/2);
+ }
+ memcpy (process_guid, mono_string_chars(newguid), sizeof(process_guid));
+ process_guid_set = TRUE;
+ mono_domain_unlock (mono_root_domain);
+ return newguid;
+}