Author: urs
Date: 2005-04-24 02:46:09 -0400 (Sun, 24 Apr 2005)
New Revision: 43510

Modified:
   trunk/objc-sharp/src/CocoaMono.h
   trunk/objc-sharp/src/MonoHelper.c
Log:
fix NSMainApplication issue

Modified: trunk/objc-sharp/src/CocoaMono.h
===================================================================
--- trunk/objc-sharp/src/CocoaMono.h    2005-04-23 20:46:53 UTC (rev 43509)
+++ trunk/objc-sharp/src/CocoaMono.h    2005-04-24 06:46:09 UTC (rev 43510)
@@ -36,7 +36,7 @@
 typedef const struct _MonoClass * MonoClassRef;
 typedef const struct _MonoObject * MonoObjectRef;
 
-int (*sObjCMainFPtr)(int argc, const char* argv[]);
+extern int (*sObjCMainFPtr)(int argc, const char* argv[]);
 int MonoMain(int argc, const char* argv[]);
 
 // Objective-C types

Modified: trunk/objc-sharp/src/MonoHelper.c
===================================================================
--- trunk/objc-sharp/src/MonoHelper.c   2005-04-23 20:46:53 UTC (rev 43509)
+++ trunk/objc-sharp/src/MonoHelper.c   2005-04-24 06:46:09 UTC (rev 43510)
@@ -37,227 +37,227 @@
 #include <mono/metadata/object.h>
 #include <mono/metadata/loader.h>
 
-enum {
-       FILE_CONTAINS_METADATA      = 0,
-       FILE_CONTAINS_NO_METADATA   = 1
-};
-#define METHOD_ATTRIBUTE_STATIC                    0x0010
-#define FIELD_ATTRIBUTE_STATIC                0x0010
-#define TYPE_ATTRIBUTE_VISIBILITY_MASK       0x00000007
-#define TYPE_ATTRIBUTE_PUBLIC                0x00000001
-#define TYPE_ATTRIBUTE_NESTED_PUBLIC         0x00000002
-#define METHOD_ATTRIBUTE_SPECIAL_NAME              0x0800
-#define PARAM_ATTRIBUTE_IN                 0x0001
-#define PARAM_ATTRIBUTE_OUT                0x0002
-typedef struct _MonoReflectionType {
-       MonoObject object;
-       MonoType  *type;
-} _MonoReflectionType;
-typedef struct _MonoAssembly {
-       int   ref_count;
-       char *basedir;
-       MonoAssemblyName aname;
-       GModule *aot_module;
-       MonoImage *image;
-       guint8 in_gac;
-       guint8 dynamic;
-       guint8 corlib_internal;
-       gboolean ref_only;
-       /* security manager flags (one bit is for lazy initialization) */
-       guint32 ecma:2;         /* Has the ECMA key */
-       guint32 aptc:2;         /* Has the [AllowPartiallyTrustedCallers] 
attributes */
-       guint32 fulltrust:2;    /* Has FullTrust permission */
-       guint32 unmanaged:2;    /* Has SecurityPermissionFlag.UnmanagedCode 
permission */
-} _MonoAssembly;
-typedef struct {
-       const char* data;
-       guint32  size;
-} MonoStreamHeader;
-typedef struct _MonoTableInfo {
-       const char *base;
-       guint       rows     : 24;
-       guint       row_size : 8;
-
-       /*
-        * Tables contain up to 9 columns and the possible sizes of the
-        * fields in the documentation are 1, 2 and 4 bytes.  So we
-        * can encode in 2 bits the size.
-        *
-        * A 32 bit value can encode the resulting size
-        *
-        * The top eight bits encode the number of columns in the table.
-        * we only need 4, but 8 is aligned no shift required. 
-        */
-       guint32   size_bitfield;
-} _MonoTableInfo;
-typedef struct _MonoImage {
-       int   ref_count;
-       FILE *file_descr;
-       /* if file_descr is NULL the image was loaded from raw data */
-       char *raw_data;
-       guint32 raw_data_len;
-       guint8 raw_data_allocated;
-
-       /* Whenever this is a dynamically emitted module */
-       guint8 dynamic;
-
-       char *name;
-       const char *assembly_name;
-       const char *module_name;
-       const char *version;
-       char *guid;
-       void *image_info;
-       MonoMemPool         *mempool;
-
-       char                *raw_metadata;
-                           
-       guint8               idx_string_wide, idx_guid_wide, idx_blob_wide;
-                           
-       MonoStreamHeader     heap_strings;
-       MonoStreamHeader     heap_us;
-       MonoStreamHeader     heap_blob;
-       MonoStreamHeader     heap_guid;
-       MonoStreamHeader     heap_tables;
-                           
-       const char          *tables_base;
-
-       /**/
-       _MonoTableInfo        tables [MONO_TABLE_NUM];
-
-       /*
-        * references is initialized only by using the mono_assembly_open
-        * function, and not by using the lowlevel mono_image_open.
-        *
-        * It is NULL terminated.
-        */
-       MonoAssembly **references;
-
-       MonoImage **modules;
-       guint32 module_count;
-
-       MonoImage **files;
-
-       /*
-        * The Assembly this image was loaded from.
-        */
-       MonoAssembly *assembly;
-
-       /*
-        * Indexed by method tokens and typedef tokens.
-        */
-       GHashTable *method_cache;
-       GHashTable *class_cache;
-       /*
-        * Indexed by fielddef and memberref tokens
-        */
-       GHashTable *field_cache;
-
-       /* indexed by typespec tokens. */
-       GHashTable *typespec_cache;
-       /* indexed by token */
-       GHashTable *memberref_signatures;
-       GHashTable *helper_signatures;
-
-       /*
-        * Indexes namespaces to hash tables that map class name to typedef 
token.
-        */
-       GHashTable *name_cache;
-
-       /*
-        * Indexed by ((rank << 24) | (typedef & 0xffffff)), which limits us to 
a
-        * maximal rank of 255
-        */
-       GHashTable *array_cache;
-
-       /*
-        * indexed by MonoMethodSignature 
-        */
-       GHashTable *delegate_begin_invoke_cache;
-       GHashTable *delegate_end_invoke_cache;
-       GHashTable *delegate_invoke_cache;
-
-       /*
-        * indexed by MonoMethod pointers 
-        */
-       GHashTable *runtime_invoke_cache;
-       GHashTable *managed_wrapper_cache;
-       GHashTable *native_wrapper_cache;
-       GHashTable *remoting_invoke_cache;
-       GHashTable *synchronized_cache;
-       GHashTable *unbox_wrapper_cache;
-
-       void *reflection_info;
-
-       /*
-        * user_info is a public field and is not touched by the
-        * metadata engine
-        */
-       void *user_info;
-
-       /* dll map entries */
-       GHashTable *dll_map;
-} _MonoImage;
-typedef struct _MonoReflectionMethod {
-       MonoObject object;
-       MonoMethod *method;
-       MonoString *name;
-       MonoReflectionType *reftype;
-} _MonoReflectionMethod;
-typedef struct {
-       MonoImage *corlib;
-       MonoClass *object_class;
-       MonoClass *byte_class;
-       MonoClass *void_class;
-       MonoClass *boolean_class;
-       MonoClass *sbyte_class;
-       MonoClass *int16_class;
-       MonoClass *uint16_class;
-       MonoClass *int32_class;
-       MonoClass *uint32_class;
-       MonoClass *int_class;
-       MonoClass *uint_class;
-       MonoClass *int64_class;
-       MonoClass *uint64_class;
-       MonoClass *single_class;
-       MonoClass *double_class;
-       MonoClass *char_class;
-       MonoClass *string_class;
-       MonoClass *enum_class;
-       MonoClass *array_class;
-       MonoClass *delegate_class;
-       MonoClass *multicastdelegate_class;
-       MonoClass *asyncresult_class;
-       MonoClass *waithandle_class;
-       MonoClass *typehandle_class;
-       MonoClass *fieldhandle_class;
-       MonoClass *methodhandle_class;
-       MonoClass *monotype_class;
-       MonoClass *exception_class;
-       MonoClass *threadabortexception_class;
-       MonoClass *thread_class;
-       MonoClass *transparent_proxy_class;
-       MonoClass *real_proxy_class;
-       MonoClass *mono_method_message_class;
-       MonoClass *appdomain_class;
-       MonoClass *field_info_class;
-       MonoClass *method_info_class;
-       MonoClass *stringbuilder_class;
-       MonoClass *math_class;
-       MonoClass *stack_frame_class;
-       MonoClass *stack_trace_class;
-       MonoClass *marshal_class;
-       MonoClass *iserializeable_class;
-       MonoClass *serializationinfo_class;
-       MonoClass *streamingcontext_class;
-       MonoClass *typed_reference_class;
-       MonoClass *argumenthandle_class;
-       MonoClass *marshalbyrefobject_class;
-       MonoClass *monitor_class;
-       MonoClass *iremotingtypeinfo_class;
-       MonoClass *runtimesecurityframe_class;
-} MonoDefaults;
-extern MonoDefaults mono_defaults;
+enum {
+       FILE_CONTAINS_METADATA      = 0,
+       FILE_CONTAINS_NO_METADATA   = 1
+};
+#define METHOD_ATTRIBUTE_STATIC                    0x0010
+#define FIELD_ATTRIBUTE_STATIC                0x0010
+#define TYPE_ATTRIBUTE_VISIBILITY_MASK       0x00000007
+#define TYPE_ATTRIBUTE_PUBLIC                0x00000001
+#define TYPE_ATTRIBUTE_NESTED_PUBLIC         0x00000002
+#define METHOD_ATTRIBUTE_SPECIAL_NAME              0x0800
+#define PARAM_ATTRIBUTE_IN                 0x0001
+#define PARAM_ATTRIBUTE_OUT                0x0002
+typedef struct _MonoReflectionType {
+       MonoObject object;
+       MonoType  *type;
+} _MonoReflectionType;
+typedef struct _MonoAssembly {
+       int   ref_count;
+       char *basedir;
+       MonoAssemblyName aname;
+       GModule *aot_module;
+       MonoImage *image;
+       guint8 in_gac;
+       guint8 dynamic;
+       guint8 corlib_internal;
+       gboolean ref_only;
+       /* security manager flags (one bit is for lazy initialization) */
+       guint32 ecma:2;         /* Has the ECMA key */
+       guint32 aptc:2;         /* Has the [AllowPartiallyTrustedCallers] 
attributes */
+       guint32 fulltrust:2;    /* Has FullTrust permission */
+       guint32 unmanaged:2;    /* Has SecurityPermissionFlag.UnmanagedCode 
permission */
+} _MonoAssembly;
+typedef struct {
+       const char* data;
+       guint32  size;
+} MonoStreamHeader;
+typedef struct _MonoTableInfo {
+       const char *base;
+       guint       rows     : 24;
+       guint       row_size : 8;
 
+       /*
+        * Tables contain up to 9 columns and the possible sizes of the
+        * fields in the documentation are 1, 2 and 4 bytes.  So we
+        * can encode in 2 bits the size.
+        *
+        * A 32 bit value can encode the resulting size
+        *
+        * The top eight bits encode the number of columns in the table.
+        * we only need 4, but 8 is aligned no shift required. 
+        */
+       guint32   size_bitfield;
+} _MonoTableInfo;
+typedef struct _MonoImage {
+       int   ref_count;
+       FILE *file_descr;
+       /* if file_descr is NULL the image was loaded from raw data */
+       char *raw_data;
+       guint32 raw_data_len;
+       guint8 raw_data_allocated;
+
+       /* Whenever this is a dynamically emitted module */
+       guint8 dynamic;
+
+       char *name;
+       const char *assembly_name;
+       const char *module_name;
+       const char *version;
+       char *guid;
+       void *image_info;
+       MonoMemPool         *mempool;
+
+       char                *raw_metadata;
+                           
+       guint8               idx_string_wide, idx_guid_wide, idx_blob_wide;
+                           
+       MonoStreamHeader     heap_strings;
+       MonoStreamHeader     heap_us;
+       MonoStreamHeader     heap_blob;
+       MonoStreamHeader     heap_guid;
+       MonoStreamHeader     heap_tables;
+                           
+       const char          *tables_base;
+
+       /**/
+       _MonoTableInfo        tables [MONO_TABLE_NUM];
+
+       /*
+        * references is initialized only by using the mono_assembly_open
+        * function, and not by using the lowlevel mono_image_open.
+        *
+        * It is NULL terminated.
+        */
+       MonoAssembly **references;
+
+       MonoImage **modules;
+       guint32 module_count;
+
+       MonoImage **files;
+
+       /*
+        * The Assembly this image was loaded from.
+        */
+       MonoAssembly *assembly;
+
+       /*
+        * Indexed by method tokens and typedef tokens.
+        */
+       GHashTable *method_cache;
+       GHashTable *class_cache;
+       /*
+        * Indexed by fielddef and memberref tokens
+        */
+       GHashTable *field_cache;
+
+       /* indexed by typespec tokens. */
+       GHashTable *typespec_cache;
+       /* indexed by token */
+       GHashTable *memberref_signatures;
+       GHashTable *helper_signatures;
+
+       /*
+        * Indexes namespaces to hash tables that map class name to typedef 
token.
+        */
+       GHashTable *name_cache;
+
+       /*
+        * Indexed by ((rank << 24) | (typedef & 0xffffff)), which limits us to 
a
+        * maximal rank of 255
+        */
+       GHashTable *array_cache;
+
+       /*
+        * indexed by MonoMethodSignature 
+        */
+       GHashTable *delegate_begin_invoke_cache;
+       GHashTable *delegate_end_invoke_cache;
+       GHashTable *delegate_invoke_cache;
+
+       /*
+        * indexed by MonoMethod pointers 
+        */
+       GHashTable *runtime_invoke_cache;
+       GHashTable *managed_wrapper_cache;
+       GHashTable *native_wrapper_cache;
+       GHashTable *remoting_invoke_cache;
+       GHashTable *synchronized_cache;
+       GHashTable *unbox_wrapper_cache;
+
+       void *reflection_info;
+
+       /*
+        * user_info is a public field and is not touched by the
+        * metadata engine
+        */
+       void *user_info;
+
+       /* dll map entries */
+       GHashTable *dll_map;
+} _MonoImage;
+typedef struct _MonoReflectionMethod {
+       MonoObject object;
+       MonoMethod *method;
+       MonoString *name;
+       MonoReflectionType *reftype;
+} _MonoReflectionMethod;
+typedef struct {
+       MonoImage *corlib;
+       MonoClass *object_class;
+       MonoClass *byte_class;
+       MonoClass *void_class;
+       MonoClass *boolean_class;
+       MonoClass *sbyte_class;
+       MonoClass *int16_class;
+       MonoClass *uint16_class;
+       MonoClass *int32_class;
+       MonoClass *uint32_class;
+       MonoClass *int_class;
+       MonoClass *uint_class;
+       MonoClass *int64_class;
+       MonoClass *uint64_class;
+       MonoClass *single_class;
+       MonoClass *double_class;
+       MonoClass *char_class;
+       MonoClass *string_class;
+       MonoClass *enum_class;
+       MonoClass *array_class;
+       MonoClass *delegate_class;
+       MonoClass *multicastdelegate_class;
+       MonoClass *asyncresult_class;
+       MonoClass *waithandle_class;
+       MonoClass *typehandle_class;
+       MonoClass *fieldhandle_class;
+       MonoClass *methodhandle_class;
+       MonoClass *monotype_class;
+       MonoClass *exception_class;
+       MonoClass *threadabortexception_class;
+       MonoClass *thread_class;
+       MonoClass *transparent_proxy_class;
+       MonoClass *real_proxy_class;
+       MonoClass *mono_method_message_class;
+       MonoClass *appdomain_class;
+       MonoClass *field_info_class;
+       MonoClass *method_info_class;
+       MonoClass *stringbuilder_class;
+       MonoClass *math_class;
+       MonoClass *stack_frame_class;
+       MonoClass *stack_trace_class;
+       MonoClass *marshal_class;
+       MonoClass *iserializeable_class;
+       MonoClass *serializationinfo_class;
+       MonoClass *streamingcontext_class;
+       MonoClass *typed_reference_class;
+       MonoClass *argumenthandle_class;
+       MonoClass *marshalbyrefobject_class;
+       MonoClass *monitor_class;
+       MonoClass *iremotingtypeinfo_class;
+       MonoClass *runtimesecurityframe_class;
+} MonoDefaults;
+extern MonoDefaults mono_defaults;
+
 #include "CocoaMono.h"
 #include <string.h>
 
@@ -271,6 +271,10 @@
        const char **argv;
 } MainThreadArgs;
 
+int _argc;
+const char* _argv[];
+int (*sObjCMainFPtr)(int argc, const char* argv[]);
+
 static void main_thread_handler (gpointer user_data)
 {
        MainThreadArgs *main_args=(MainThreadArgs *)user_data;
@@ -294,6 +298,7 @@
        mono_interp_exec (main_args->domain, assembly, main_args->argc,
                (char**)main_args->argv);
 #endif
+       printf("mono_thread_handler done %p\n", sObjCMainFPtr);
 }
 
 int 
@@ -335,8 +340,11 @@
        mono_runtime_exec_managed_code (domain, main_thread_handler,
                                        &main_args);
        // now enter the Cocoa main loop
-       if (sObjCMainFPtr != NULL)
+       if (sObjCMainFPtr != NULL) {
+               printf("Entering Cocoa main loop\n");
                sObjCMainFPtr(argc, argv);
+               printf("Cocoa main loop done\n");
+       }
        
        retval=mono_environment_exitcode_get ();
        
@@ -349,13 +357,13 @@
 }
 
 static MonoMethodSignature* _mono_method_get_signature(MonoMethod* method_) {
-       typedef struct _MonoMethod {
-               guint16 flags;  /* method flags */
-               guint16 iflags; /* method implementation flags */
-               guint32 token;
-               MonoClass *klass;
-               MonoMethodSignature *signature;
-       } _MonoMethod;
+       typedef struct _MonoMethod {
+               guint16 flags;  /* method flags */
+               guint16 iflags; /* method implementation flags */
+               guint32 token;
+               MonoClass *klass;
+               MonoMethodSignature *signature;
+       } _MonoMethod;
 
        _MonoMethod* method = (_MonoMethod*)method_;
        return method->signature;
@@ -678,8 +686,8 @@
        if (_klass != NULL)
        {
                MonoClass *klass = (MonoClass*)_klass;
-               gpointer iter = NULL;
-               MonoClassField *field;
+               gpointer iter = NULL;
+               MonoClassField *field;
                while ((field = mono_class_get_fields (klass, &iter))) {
                        MonoType *type = mono_field_get_type(field);
                        
@@ -699,8 +707,8 @@
        if (_klass != NULL)
        {
                MonoClass *klass = (MonoClass*)_klass;
-               gpointer iter = NULL;
-               MonoProperty *property;
+               gpointer iter = NULL;
+               MonoProperty *property;
                while ((property = mono_class_get_properties (klass, &iter))) {
                        if ((property_is_static(property) != 0) != (useStatic 
!= 0))
                                continue;
@@ -718,8 +726,8 @@
        if (_klass != NULL)
        {
                MonoClass *klass = (MonoClass*)_klass;
-               gpointer iter = NULL;
-               MonoMethod *method;
+               gpointer iter = NULL;
+               MonoMethod *method;
                while ((method = mono_class_get_methods (klass, &iter))) {
                        printf("\nMonoHelper MonoGetMethodNames:  %s", 
mono_method_get_name(method));
                        if (strcmp(mono_method_get_name(method), ".cctor") == 0)
@@ -755,8 +763,8 @@
        if (_klass != NULL)
        {
                MonoClass *klass = (MonoClass*)_klass;
-               gpointer iter = NULL;
-               MonoMethod *method;
+               gpointer iter = NULL;
+               MonoMethod *method;
                while ((method = mono_class_get_methods (klass, &iter))) {
                        MonoReflectionMethod* refMethod;
 
@@ -783,8 +791,8 @@
        if (_klass != NULL)
        {
                MonoClass *klass = (MonoClass*)_klass;
-               gpointer iter = NULL;
-               MonoProperty *property;
+               gpointer iter = NULL;
+               MonoProperty *property;
                while ((property = mono_class_get_properties (klass, &iter))) {
                        MonoReflectionProperty* refProp;
                        if ((property_is_static(property) != 0) != (useStatic 
!= 0))
@@ -805,8 +813,8 @@
        if (_klass != NULL)
        {
                MonoClass *klass = (MonoClass*)_klass;
-               gpointer iter = NULL;
-               MonoClassField *field;
+               gpointer iter = NULL;
+               MonoClassField *field;
                while ((field = mono_class_get_fields (klass, &iter))) {
                        MonoReflectionField* refField;
                        if (((mono_field_get_type(field)->attrs & 
FIELD_ATTRIBUTE_STATIC) != 0) != (useStatic != 0))
@@ -1120,16 +1128,16 @@
 }
 
 
-typedef struct {
-       MonoObject object;
-       MonoReflectionType *ClassImpl;
-       MonoObject *DefaultValueImpl;
-       MonoObject *MemberImpl;
-       MonoString *NameImpl;
-       gint32 PositionImpl;
-       guint32 AttrsImpl;
-       MonoObject *MarshalAsImpl;
-} MonoReflectionParameter;
+typedef struct {
+       MonoObject object;
+       MonoReflectionType *ClassImpl;
+       MonoObject *DefaultValueImpl;
+       MonoObject *MemberImpl;
+       MonoString *NameImpl;
+       gint32 PositionImpl;
+       guint32 AttrsImpl;
+       MonoObject *MarshalAsImpl;
+} MonoReflectionParameter;
 // MonoParameterInfo
 MonoClassRef MonoParameterGetOwnerKlass(MonoObjectRef _parameterInfo)
 {
@@ -1169,11 +1177,11 @@
 
 
 // MonoPropertyInfo
-struct _MonoReflectionProperty {
-       MonoObject object;
-       MonoClass *klass;
-       MonoProperty *property;
-};
+struct _MonoReflectionProperty {
+       MonoObject object;
+       MonoClass *klass;
+       MonoProperty *property;
+};
 MonoClassRef MonoPropertyGetOwnerKlass(MonoObjectRef _propertyInfo)
 {
        MonoReflectionProperty* propertyInfo = 
(MonoReflectionProperty*)_propertyInfo;
@@ -1205,14 +1213,14 @@
 
 
 // MonoFieldInfo
-struct _MonoReflectionField {
-       MonoObject object;
-       MonoClass *klass;
-       MonoClassField *field;
-       MonoString *name;
-       MonoReflectionType *type;
-       guint32 attrs;
-};
+struct _MonoReflectionField {
+       MonoObject object;
+       MonoClass *klass;
+       MonoClassField *field;
+       MonoString *name;
+       MonoReflectionType *type;
+       guint32 attrs;
+};
 MonoClassRef MonoFieldGetOwnerKlass(MonoObjectRef _fieldInfo)
 {
        MonoReflectionField* fieldInfo = (MonoReflectionField*)_fieldInfo;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to