Merge pull request #2020 from tomjepp/master
[mono.git] / mono / metadata / reflection.h
index bd6a2d894d299fc67eae9208d449066b58d2919c..a0808099593d856c768224a3b4609c05deda5bc0 100644 (file)
@@ -3,20 +3,14 @@
 
 #include <mono/metadata/object.h>
 
-typedef struct MonoTypeNameParse MonoTypeNameParse;
+MONO_BEGIN_DECLS
 
-struct MonoTypeNameParse {
-       char *name_space;
-       char *name;
-       MonoAssemblyName assembly;
-       GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
-       GList *nested;
-};
+typedef struct MonoTypeNameParse MonoTypeNameParse;
 
 typedef struct {
        MonoMethod *ctor;
-       guint32     data_size;
-       const guchar* data;
+       uint32_t     data_size;
+       const mono_byte* data;
 } MonoCustomAttrEntry;
 
 typedef struct {
@@ -26,6 +20,8 @@ typedef struct {
        MonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY];
 } MonoCustomAttrInfo;
 
+#define MONO_SIZEOF_CUSTOM_ATTR_INFO (offsetof (MonoCustomAttrInfo, attrs))
+
 /* 
  * Information which isn't in the MonoMethod structure is stored here for
  * dynamic methods.
@@ -34,8 +30,8 @@ typedef struct {
        char **param_names;
        MonoMarshalSpec **param_marshall;
        MonoCustomAttrInfo **param_cattr;
-       guint8** param_defaults;
-       guint32 *param_default_types;
+       uint8_t** param_defaults;
+       uint32_t *param_default_types;
        char *dllentry, *dll;
 } MonoReflectionMethodAux;
 
@@ -45,40 +41,44 @@ typedef enum {
        ResolveTokenError_Other
 } MonoResolveTokenError;
 
-int           mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
-MonoType*     mono_reflection_get_type   (MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase, gboolean *type_resolve);
-MonoType*     mono_reflection_type_from_name (char *name, MonoImage *image);
-guint32       mono_reflection_get_token (MonoObject *obj);
-
-MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
-MonoReflectionModule*   mono_module_get_object   (MonoDomain *domain, MonoImage *image);
-MonoReflectionModule*   mono_module_file_get_object (MonoDomain *domain, MonoImage *image, int table_index);
-MonoReflectionType*     mono_type_get_object     (MonoDomain *domain, MonoType *type);
-MonoReflectionMethod*   mono_method_get_object   (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
-MonoReflectionField*    mono_field_get_object    (MonoDomain *domain, MonoClass *klass, MonoClassField *field);
-MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property);
-MonoReflectionEvent*    mono_event_get_object    (MonoDomain *domain, MonoClass *klass, MonoEvent *event);
+MONO_API int           mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
+MONO_API MonoType*     mono_reflection_get_type   (MonoImage* image, MonoTypeNameParse *info, mono_bool ignorecase, mono_bool *type_resolve);
+MONO_API void          mono_reflection_free_type_info (MonoTypeNameParse *info);
+MONO_API MonoType*     mono_reflection_type_from_name (char *name, MonoImage *image);
+MONO_API uint32_t      mono_reflection_get_token (MonoObject *obj);
+
+MONO_API MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
+MONO_API MonoReflectionModule*   mono_module_get_object   (MonoDomain *domain, MonoImage *image);
+MONO_API MonoReflectionModule*   mono_module_file_get_object (MonoDomain *domain, MonoImage *image, int table_index);
+MONO_API MonoReflectionType*     mono_type_get_object     (MonoDomain *domain, MonoType *type);
+MONO_API MonoReflectionMethod*   mono_method_get_object   (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
+MONO_API MonoReflectionField*    mono_field_get_object    (MonoDomain *domain, MonoClass *klass, MonoClassField *field);
+MONO_API MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property);
+MONO_API MonoReflectionEvent*    mono_event_get_object    (MonoDomain *domain, MonoClass *klass, MonoEvent *event);
 /* note: this one is slightly different: we keep the whole array of params in the cache */
-MonoArray* mono_param_get_objects  (MonoDomain *domain, MonoMethod *method);
-MonoReflectionMethodBody* mono_method_body_get_object (MonoDomain *domain, MonoMethod *method);
-MonoObject* mono_get_dbnull_object (MonoDomain *domain);
-
-MonoArray*  mono_reflection_get_custom_attrs (MonoObject *obj);
-MonoArray*  mono_reflection_get_custom_attrs_blob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
-
-MonoCustomAttrInfo* mono_reflection_get_custom_attrs_info (MonoObject *obj);
-MonoArray*  mono_custom_attrs_construct (MonoCustomAttrInfo *cinfo);
-MonoCustomAttrInfo* mono_custom_attrs_from_index    (MonoImage *image, guint32 idx);
-MonoCustomAttrInfo* mono_custom_attrs_from_method   (MonoMethod *method);
-MonoCustomAttrInfo* mono_custom_attrs_from_class    (MonoClass *klass);
-MonoCustomAttrInfo* mono_custom_attrs_from_assembly (MonoAssembly *assembly);
-MonoCustomAttrInfo* mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property);
-MonoCustomAttrInfo* mono_custom_attrs_from_event    (MonoClass *klass, MonoEvent *event);
-MonoCustomAttrInfo* mono_custom_attrs_from_field    (MonoClass *klass, MonoClassField *field);
-MonoCustomAttrInfo* mono_custom_attrs_from_param    (MonoMethod *method, guint32 param);
-gboolean            mono_custom_attrs_has_attr      (MonoCustomAttrInfo *ainfo, MonoClass *attr_klass);
-MonoObject*         mono_custom_attrs_get_attr      (MonoCustomAttrInfo *ainfo, MonoClass *attr_klass);
-void                mono_custom_attrs_free          (MonoCustomAttrInfo *ainfo);
+MONO_API MonoArray* mono_param_get_objects  (MonoDomain *domain, MonoMethod *method);
+MONO_API MonoReflectionMethodBody* mono_method_body_get_object (MonoDomain *domain, MonoMethod *method);
+
+MONO_API MonoObject *mono_get_dbnull_object (MonoDomain *domain);
+
+MONO_API MonoArray*  mono_reflection_get_custom_attrs_by_type (MonoObject *obj, MonoClass *attr_klass, MonoError *error);
+MONO_API MonoArray*  mono_reflection_get_custom_attrs (MonoObject *obj);
+MONO_API MonoArray*  mono_reflection_get_custom_attrs_data (MonoObject *obj);
+MONO_API MonoArray*  mono_reflection_get_custom_attrs_blob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
+
+MONO_API MonoCustomAttrInfo* mono_reflection_get_custom_attrs_info (MonoObject *obj);
+MONO_API MonoArray*  mono_custom_attrs_construct (MonoCustomAttrInfo *cinfo);
+MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_index    (MonoImage *image, uint32_t idx);
+MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_method   (MonoMethod *method);
+MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_class    (MonoClass *klass);
+MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_assembly (MonoAssembly *assembly);
+MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property);
+MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_event    (MonoClass *klass, MonoEvent *event);
+MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_field    (MonoClass *klass, MonoClassField *field);
+MONO_API MonoCustomAttrInfo* mono_custom_attrs_from_param    (MonoMethod *method, uint32_t param);
+MONO_API mono_bool           mono_custom_attrs_has_attr      (MonoCustomAttrInfo *ainfo, MonoClass *attr_klass);
+MONO_API MonoObject*         mono_custom_attrs_get_attr      (MonoCustomAttrInfo *ainfo, MonoClass *attr_klass);
+MONO_API void                mono_custom_attrs_free          (MonoCustomAttrInfo *ainfo);
 
 
 #define MONO_DECLSEC_ACTION_MIN                0x1
@@ -105,16 +105,16 @@ enum {
        MONO_DECLSEC_FLAG_DEMAND_CHOICE                 = 0x00020000
 };
 
-guint32 mono_declsec_flags_from_method (MonoMethod *method);
-guint32 mono_declsec_flags_from_class (MonoClass *klass);
-guint32 mono_declsec_flags_from_assembly (MonoAssembly *assembly);
+MONO_API uint32_t mono_declsec_flags_from_method (MonoMethod *method);
+MONO_API uint32_t mono_declsec_flags_from_class (MonoClass *klass);
+MONO_API uint32_t mono_declsec_flags_from_assembly (MonoAssembly *assembly);
 
 /* this structure MUST be kept in synch with RuntimeDeclSecurityEntry
  * located in /mcs/class/corlib/System.Security/SecurityFrame.cs */
 typedef struct {
        char *blob;                             /* pointer to metadata blob */
-       guint32 size;                           /* size of the metadata blob */
-       guint32 index;
+       uint32_t size;                          /* size of the metadata blob */
+       uint32_t index;
 } MonoDeclSecurityEntry;
 
 typedef struct {
@@ -123,13 +123,19 @@ typedef struct {
        MonoDeclSecurityEntry demandchoice;
 } MonoDeclSecurityActions;
 
-MonoBoolean mono_declsec_get_demands (MonoMethod *callee, MonoDeclSecurityActions* demands);
-MonoBoolean mono_declsec_get_linkdemands (MonoMethod *callee, MonoDeclSecurityActions* klass, MonoDeclSecurityActions* cmethod);
-MonoBoolean mono_declsec_get_inheritdemands_class (MonoClass *klass, MonoDeclSecurityActions* demands);
-MonoBoolean mono_declsec_get_inheritdemands_method (MonoMethod *callee, MonoDeclSecurityActions* demands);
+MONO_API MonoBoolean mono_declsec_get_demands (MonoMethod *callee, MonoDeclSecurityActions* demands);
+MONO_API MonoBoolean mono_declsec_get_linkdemands (MonoMethod *callee, MonoDeclSecurityActions* klass, MonoDeclSecurityActions* cmethod);
+MONO_API MonoBoolean mono_declsec_get_inheritdemands_class (MonoClass *klass, MonoDeclSecurityActions* demands);
+MONO_API MonoBoolean mono_declsec_get_inheritdemands_method (MonoMethod *callee, MonoDeclSecurityActions* demands);
+
+MONO_API MonoBoolean mono_declsec_get_method_action (MonoMethod *method, uint32_t action, MonoDeclSecurityEntry *entry);
+MONO_API MonoBoolean mono_declsec_get_class_action (MonoClass *klass, uint32_t action, MonoDeclSecurityEntry *entry);
+MONO_API MonoBoolean mono_declsec_get_assembly_action (MonoAssembly *assembly, uint32_t action, MonoDeclSecurityEntry *entry);
+
+MONO_API MonoType* mono_reflection_type_get_type (MonoReflectionType *reftype);
+
+MONO_API MonoAssembly* mono_reflection_assembly_get_assembly (MonoReflectionAssembly *refassembly);
 
-MonoBoolean mono_declsec_get_method_action (MonoMethod *method, guint32 action, MonoDeclSecurityEntry *entry);
-MonoBoolean mono_declsec_get_class_action (MonoClass *klass, guint32 action, MonoDeclSecurityEntry *entry);
-MonoBoolean mono_declsec_get_assembly_action (MonoAssembly *assembly, guint32 action, MonoDeclSecurityEntry *entry);
+MONO_END_DECLS
 
 #endif /* __METADATA_REFLECTION_H__ */