2009-03-11 Zoltan Varga <vargaz@gmail.com>
[mono-debugger.git] / mono / metadata / reflection.h
blob89b336088e45d437b3e28a9c781e08e9b651b932
1 #ifndef __METADATA_REFLECTION_H__
2 #define __METADATA_REFLECTION_H__
4 #include <mono/metadata/object.h>
6 G_BEGIN_DECLS
8 typedef struct MonoTypeNameParse MonoTypeNameParse;
10 struct MonoTypeNameParse {
11 char *name_space;
12 char *name;
13 MonoAssemblyName assembly;
14 GList *modifiers; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
15 GPtrArray *type_arguments;
16 GList *nested;
19 typedef struct {
20 MonoMethod *ctor;
21 guint32 data_size;
22 const guchar* data;
23 } MonoCustomAttrEntry;
25 typedef struct {
26 int num_attrs;
27 int cached;
28 MonoImage *image;
29 MonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY];
30 } MonoCustomAttrInfo;
32 /*
33 * Information which isn't in the MonoMethod structure is stored here for
34 * dynamic methods.
36 typedef struct {
37 char **param_names;
38 MonoMarshalSpec **param_marshall;
39 MonoCustomAttrInfo **param_cattr;
40 guint8** param_defaults;
41 guint32 *param_default_types;
42 char *dllentry, *dll;
43 } MonoReflectionMethodAux;
45 typedef enum {
46 ResolveTokenError_OutOfRange,
47 ResolveTokenError_BadTable,
48 ResolveTokenError_Other
49 } MonoResolveTokenError;
51 int mono_reflection_parse_type (char *name, MonoTypeNameParse *info);
52 MonoType* mono_reflection_get_type (MonoImage* image, MonoTypeNameParse *info, gboolean ignorecase, gboolean *type_resolve);
53 void mono_reflection_free_type_info (MonoTypeNameParse *info);
54 MonoType* mono_reflection_type_from_name (char *name, MonoImage *image);
55 guint32 mono_reflection_get_token (MonoObject *obj);
57 MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
58 MonoReflectionModule* mono_module_get_object (MonoDomain *domain, MonoImage *image);
59 MonoReflectionModule* mono_module_file_get_object (MonoDomain *domain, MonoImage *image, int table_index);
60 MonoReflectionType* mono_type_get_object (MonoDomain *domain, MonoType *type);
61 MonoReflectionMethod* mono_method_get_object (MonoDomain *domain, MonoMethod *method, MonoClass *refclass);
62 MonoReflectionField* mono_field_get_object (MonoDomain *domain, MonoClass *klass, MonoClassField *field);
63 MonoReflectionProperty* mono_property_get_object (MonoDomain *domain, MonoClass *klass, MonoProperty *property);
64 MonoReflectionEvent* mono_event_get_object (MonoDomain *domain, MonoClass *klass, MonoEvent *event);
65 /* note: this one is slightly different: we keep the whole array of params in the cache */
66 MonoArray* mono_param_get_objects (MonoDomain *domain, MonoMethod *method);
67 MonoReflectionMethodBody* mono_method_body_get_object (MonoDomain *domain, MonoMethod *method);
69 MonoObject *mono_get_dbnull_object (MonoDomain *domain);
71 MonoArray* mono_reflection_get_custom_attrs_by_type (MonoObject *obj, MonoClass *attr_klass);
72 MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj);
73 MonoArray* mono_reflection_get_custom_attrs_data (MonoObject *obj);
74 MonoArray* mono_reflection_get_custom_attrs_blob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues);
76 MonoCustomAttrInfo* mono_reflection_get_custom_attrs_info (MonoObject *obj);
77 MonoArray* mono_custom_attrs_construct (MonoCustomAttrInfo *cinfo);
78 MonoCustomAttrInfo* mono_custom_attrs_from_index (MonoImage *image, guint32 idx);
79 MonoCustomAttrInfo* mono_custom_attrs_from_method (MonoMethod *method);
80 MonoCustomAttrInfo* mono_custom_attrs_from_class (MonoClass *klass);
81 MonoCustomAttrInfo* mono_custom_attrs_from_assembly (MonoAssembly *assembly);
82 MonoCustomAttrInfo* mono_custom_attrs_from_property (MonoClass *klass, MonoProperty *property);
83 MonoCustomAttrInfo* mono_custom_attrs_from_event (MonoClass *klass, MonoEvent *event);
84 MonoCustomAttrInfo* mono_custom_attrs_from_field (MonoClass *klass, MonoClassField *field);
85 MonoCustomAttrInfo* mono_custom_attrs_from_param (MonoMethod *method, guint32 param);
86 gboolean mono_custom_attrs_has_attr (MonoCustomAttrInfo *ainfo, MonoClass *attr_klass);
87 MonoObject* mono_custom_attrs_get_attr (MonoCustomAttrInfo *ainfo, MonoClass *attr_klass);
88 void mono_custom_attrs_free (MonoCustomAttrInfo *ainfo);
91 #define MONO_DECLSEC_ACTION_MIN 0x1
92 #define MONO_DECLSEC_ACTION_MAX 0x12
94 enum {
95 MONO_DECLSEC_FLAG_REQUEST = 0x00000001,
96 MONO_DECLSEC_FLAG_DEMAND = 0x00000002,
97 MONO_DECLSEC_FLAG_ASSERT = 0x00000004,
98 MONO_DECLSEC_FLAG_DENY = 0x00000008,
99 MONO_DECLSEC_FLAG_PERMITONLY = 0x00000010,
100 MONO_DECLSEC_FLAG_LINKDEMAND = 0x00000020,
101 MONO_DECLSEC_FLAG_INHERITANCEDEMAND = 0x00000040,
102 MONO_DECLSEC_FLAG_REQUEST_MINIMUM = 0x00000080,
103 MONO_DECLSEC_FLAG_REQUEST_OPTIONAL = 0x00000100,
104 MONO_DECLSEC_FLAG_REQUEST_REFUSE = 0x00000200,
105 MONO_DECLSEC_FLAG_PREJIT_GRANT = 0x00000400,
106 MONO_DECLSEC_FLAG_PREJIT_DENY = 0x00000800,
107 MONO_DECLSEC_FLAG_NONCAS_DEMAND = 0x00001000,
108 MONO_DECLSEC_FLAG_NONCAS_LINKDEMAND = 0x00002000,
109 MONO_DECLSEC_FLAG_NONCAS_INHERITANCEDEMAND = 0x00004000,
110 MONO_DECLSEC_FLAG_LINKDEMAND_CHOICE = 0x00008000,
111 MONO_DECLSEC_FLAG_INHERITANCEDEMAND_CHOICE = 0x00010000,
112 MONO_DECLSEC_FLAG_DEMAND_CHOICE = 0x00020000
115 guint32 mono_declsec_flags_from_method (MonoMethod *method);
116 guint32 mono_declsec_flags_from_class (MonoClass *klass);
117 guint32 mono_declsec_flags_from_assembly (MonoAssembly *assembly);
119 /* this structure MUST be kept in synch with RuntimeDeclSecurityEntry
120 * located in /mcs/class/corlib/System.Security/SecurityFrame.cs */
121 typedef struct {
122 char *blob; /* pointer to metadata blob */
123 guint32 size; /* size of the metadata blob */
124 guint32 index;
125 } MonoDeclSecurityEntry;
127 typedef struct {
128 MonoDeclSecurityEntry demand;
129 MonoDeclSecurityEntry noncasdemand;
130 MonoDeclSecurityEntry demandchoice;
131 } MonoDeclSecurityActions;
133 MonoBoolean mono_declsec_get_demands (MonoMethod *callee, MonoDeclSecurityActions* demands);
134 MonoBoolean mono_declsec_get_linkdemands (MonoMethod *callee, MonoDeclSecurityActions* klass, MonoDeclSecurityActions* cmethod);
135 MonoBoolean mono_declsec_get_inheritdemands_class (MonoClass *klass, MonoDeclSecurityActions* demands);
136 MonoBoolean mono_declsec_get_inheritdemands_method (MonoMethod *callee, MonoDeclSecurityActions* demands);
138 MonoBoolean mono_declsec_get_method_action (MonoMethod *method, guint32 action, MonoDeclSecurityEntry *entry);
139 MonoBoolean mono_declsec_get_class_action (MonoClass *klass, guint32 action, MonoDeclSecurityEntry *entry);
140 MonoBoolean mono_declsec_get_assembly_action (MonoAssembly *assembly, guint32 action, MonoDeclSecurityEntry *entry);
142 G_END_DECLS
144 #endif /* __METADATA_REFLECTION_H__ */