3 * Copyright (C) 2006-2008, The Perl Foundation.
6 /* .NET CLI Class Metadata PMC */
9 #include "parrot/extend.h"
10 #include "tableinfo.h"
11 #include "structures.h"
14 pmclass DotNetClassMetadata dynpmc group dotnet {
16 /* Instance initialization. We need a custom DOD marking and destroy. */
19 PObj_custom_mark_SET(SELF);
20 PObj_active_destroy_SET(SELF);
24 /* Get string vtable function; returns the name of the class. */
27 dotnet_class *c = (dotnet_class *)PMC_struct_val(SELF);
29 /* Handle cases where we've an invalid PMC. */
30 if (c == NULL || c->str_name == NULL)
31 real_exception(INTERP, NULL, E_StandardError,
32 "Invalid DotNetClassMetadata PMC");
38 /* Garbage Collection mark routine. */
41 /* Tell the GC about stuff we're holding on to. */
42 dotnet_class *c = (dotnet_class *)PMC_struct_val(SELF);
45 pobject_lives(INTERP, (PObj *)c->parent);
47 pobject_lives(INTERP, (PObj *)c->str_name);
49 pobject_lives(INTERP, (PObj *)c->str_namespace);
51 pobject_lives(INTERP, (PObj *)c->str_fullname);
53 pobject_lives(INTERP, (PObj *)c->fields);
55 pobject_lives(INTERP, (PObj *)c->methods);
56 if (c->interface_types)
57 pobject_lives(INTERP, (PObj *)c->interface_types);
59 pobject_lives(INTERP, (PObj *)c->interface_ids);
67 /* Cleanup any memory we're using. */
68 if (PMC_struct_val(SELF))
70 mem_sys_free(PMC_struct_val(SELF));
71 PMC_struct_val(SELF) = NULL;
76 /* Get the namespace of the class. */
77 METHOD STRING* get_namespace()
79 dotnet_class *c = (dotnet_class *)PMC_struct_val(SELF);
82 /* Handle cases where we've an invalid PMC. */
84 real_exception(INTERP, NULL, E_StandardError,
85 "Invalid DotNetClassMetadata PMC");
86 result = c->str_namespace;
87 RETURN(STRING *result);
91 /* Get the fully qualified name of the class. */
92 METHOD STRING* get_fullname()
94 dotnet_class *c = (dotnet_class *)PMC_struct_val(SELF);
97 /* Handle cases where we've an invalid PMC. */
99 real_exception(INTERP, NULL, E_StandardError,
100 "Invalid DotNetClassMetadata PMC");
102 result = c->str_fullname;
103 RETURN(STRING *result);
107 /* Get the flags of the class. */
108 METHOD INTVAL get_flags()
110 dotnet_class *c = (dotnet_class *)PMC_struct_val(SELF);
113 /* Handle cases where we've an invalid PMC. */
115 real_exception(INTERP, NULL, E_StandardError,
116 "Invalid DotNetClassMetadata PMC");
118 result = (INTVAL)c->flags;
119 RETURN(INTVAL result);
122 /* Get a PMC array of fields belonging to the class. */
123 METHOD PMC* get_fields()
125 dotnet_class *c = (dotnet_class *)PMC_struct_val(SELF);
128 /* Handle cases where we've an invalid PMC or no fields. */
130 real_exception(INTERP, NULL, E_StandardError,
131 "Invalid DotNetClassMetadata PMC");
136 result = pmc_new(INTERP, enum_class_FixedPMCArray);
142 /* Get a PMC array of methods belonging to the class. */
143 METHOD PMC* get_methods()
145 dotnet_class *c = (dotnet_class *)PMC_struct_val(SELF);
148 /* Handle cases where we've an invalid PMC or no methods. */
150 real_exception(INTERP, NULL, E_StandardError,
151 "Invalid DotNetClassMetadata PMC");
156 result = pmc_new(INTERP, enum_class_FixedPMCArray);
162 /* Get the id of the class that this one inherits. */
163 METHOD INTVAL get_parent_id()
165 dotnet_class *c = (dotnet_class *)PMC_struct_val(SELF);
168 /* Handle cases where we've an invalid PMC. */
170 real_exception(INTERP, NULL, E_StandardError,
171 "Invalid DotNetClassMetadata PMC");
173 result = (INTVAL)c->parent_id;
174 RETURN(INTVAL result);
178 /* Get the type of the class that this one inherits. This is either a
179 type defined in this module or a reference to another module. */
180 METHOD INTVAL get_parent_type()
182 dotnet_class *c = (dotnet_class *)PMC_struct_val(SELF);
185 /* Handle cases where we've an invalid PMC. */
187 real_exception(INTERP, NULL, E_StandardError,
188 "Invalid DotNetClassMetadata PMC");
190 result = (INTVAL)c->parent_type;
192 RETURN(INTVAL result);
196 /* Get the array of ids of the interfaces this class implements. */
197 METHOD PMC* get_interface_ids()
199 dotnet_class *c = (dotnet_class *)PMC_struct_val(SELF);
202 /* Handle cases where we've an invalid PMC. */
203 if (!c || !c->interface_ids)
204 real_exception(INTERP, NULL, E_StandardError,
205 "Invalid DotNetClassMetadata PMC");
207 result = c->interface_ids;
212 /* Get the array of types of the interfaces this class implements. */
213 METHOD PMC* get_interface_types()
215 dotnet_class *c = (dotnet_class *)PMC_struct_val(SELF);
218 /* Handle cases where we've an invalid PMC. */
219 if (c == NULL || c->interface_types == NULL)
220 real_exception(INTERP, NULL, E_StandardError,
221 "Invalid DotNetClassMetadata PMC");
223 result = c->interface_types;
231 * c-file-style: "parrot"
233 * vim: expandtab shiftwidth=4: