* mono-endian.h, mono-endian.c: new macro MONO_DOUBLE_ASSERT_ENDIANITY to
[mono.git] / mono / metadata / image.h
index 0421c81f51b0fc7c13bcb80871303532e0e10869..4cbfe5f46705569cd1f3dea213596b99a3a6b7fe 100644 (file)
@@ -3,26 +3,37 @@
 
 #include <stdio.h>
 #include <glib.h>
+#include <gmodule.h>
 
 typedef struct _MonoImage MonoImage;
-typedef struct _MonoImage MonoMetadata;
+
+typedef struct {
+       const char *name;
+       const char *culture;
+       const char *hash_value;
+       guint32 hash_len;
+       guint32 flags;
+       guint16 major, minor, build, revision;
+} MonoAssemblyName;
 
 typedef struct {
        int   ref_count;
-       char *name;
-       
+       char *basedir;
+       MonoAssemblyName aname;
+       GModule *aot_module;
        MonoImage *image;
        /* Load files here */
+       void *dynamic;
 } MonoAssembly;
 
 typedef struct {
-       guint32  offset;
+       const char* data;
        guint32  size;
 } MonoStreamHeader;
 
 typedef struct {
        guint32   rows, row_size;
-       char     *base;
+       const char *base;
 
        /*
         * Tables contain up to 9 columns and the possible sizes of the
@@ -40,8 +51,15 @@ typedef struct {
 struct _MonoImage {
        int   ref_count;
        FILE *f;
+       /* if f is NULL the image was loaded rom raw data */
+       char *raw_data;
+       guint32 raw_data_len;
+       gboolean raw_data_allocated;
        char *name;
        const char *assembly_name;
+       const char *module_name;
+       const char *version;
+       char *guid;
        void *image_info;
 
        char                *raw_metadata;
@@ -54,7 +72,7 @@ struct _MonoImage {
        MonoStreamHeader     heap_guid;
        MonoStreamHeader     heap_tables;
                            
-       char                *tables_base;
+       const char          *tables_base;
 
        MonoTableInfo        tables [64];
 
@@ -66,11 +84,20 @@ struct _MonoImage {
         */
        MonoAssembly **references;
 
+       MonoImage **modules;
+
+       /*
+        * The Assembly this image was loaded from.
+        */
+       MonoAssembly *assembly;
+
        /*
         * Indexed by method tokens and typedef tokens.
         */
        GHashTable *method_cache;
        GHashTable *class_cache;
+       /* indexed by a generic type instantiation */
+       GHashTable *generics_cache;
        /*
         * Indexes namespaces to hash tables that map class name to typedef token.
         */
@@ -82,6 +109,24 @@ struct _MonoImage {
         */
        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;
+
+       void *reflection_info;
+
        /*
         * user_info is a public field and is not touched by the
         * metadata engine
@@ -89,22 +134,44 @@ struct _MonoImage {
        void *user_info;
 };
 
-enum MonoImageOpenStatus {
+typedef enum {
        MONO_IMAGE_OK,
        MONO_IMAGE_ERROR_ERRNO,
        MONO_IMAGE_MISSING_ASSEMBLYREF,
        MONO_IMAGE_IMAGE_INVALID
-};
+} MonoImageOpenStatus;
 
 MonoImage    *mono_image_open     (const char *fname,
-                                  enum MonoImageOpenStatus *status);
+                                  MonoImageOpenStatus *status);
+MonoImage    *mono_image_open_from_data (char *data, guint32 data_len, gboolean need_copy,
+                                         MonoImageOpenStatus *status);
 MonoImage    *mono_image_loaded   (const char *name);
+MonoImage    *mono_image_loaded_by_guid (const char *guid);
+void          mono_image_init     (MonoImage *image);
 void          mono_image_close    (MonoImage *image);
-const char   *mono_image_strerror (enum MonoImageOpenStatus status);
+const char   *mono_image_strerror (MonoImageOpenStatus status);
 
 int           mono_image_ensure_section     (MonoImage *image,
                                             const char *section);
 int           mono_image_ensure_section_idx (MonoImage *image,
                                             int section);
-       
+
+guint32       mono_image_get_entry_point    (MonoImage *image);
+const char   *mono_image_get_resource       (MonoImage *image, guint32 offset, guint32 *size);
+
+void          mono_image_load_references    (MonoImage *image, MonoImageOpenStatus *status);
+
+/* This actually returns a MonoPEResourceDataEntry *, but declaring it
+ * causes an include file loop.
+ */
+gpointer      mono_image_lookup_resource (MonoImage *image, guint32 res_id,
+                                         guint32 lang_id, gunichar2 *name);
+
+const char*   mono_image_get_public_key  (MonoImage *image, guint32 *size);
+const char*   mono_image_get_strong_name (MonoImage *image, guint32 *size);
+guint32       mono_image_strong_name_position (MonoImage *image, guint32 *size);
+void          mono_image_add_to_name_cache (MonoImage *image, 
+                                                                                       const char *nspace, 
+                                                                                       const char *name, guint32 idx);
+
 #endif