tagged release 0.6.4
[parrot.git] / languages / dotnet / pmc / dotnetmemberrefmetadata.pmc
blobce8b5cea1feae7b0e8ccf6826f38f2978158de46
1 /*
2  * $Id$
3  * Copyright (C) 2006-2008, The Perl Foundation.
4  */
6 /* .NET CLI MemberRef Metadata PMC */
9 #include "parrot/extend.h"
10 #include "tableinfo.h"
11 #include "structures.h"
14 pmclass DotNetMemberRefMetadata dynpmc group dotnet {
16     /* Instance initialization. We need a custom DOD marking and destroy. */
17     void init()
18     {
19         PObj_custom_mark_SET(SELF);
20         PObj_active_destroy_SET(SELF);
21     }
24     /* Get string vtable function; returns the name of the member. */
25     STRING* get_string()
26     {
27         dotnet_memberref *c = (dotnet_memberref *)PMC_struct_val(SELF);
29         /* Handle cases where we've an invalid PMC. */
30         if (!c || !c->str_name)
31             real_exception(INTERP, NULL, E_StandardError,
32                "Invalid DotNetMemberRefMetadata PMC");
34         return c->str_name;
35     }
38     /* Garbage Collection mark routine. */
39     void mark()
40     {
41         /* Tell the GC about stuff we're holding on to. */
42         dotnet_memberref *c = (dotnet_memberref *)PMC_struct_val(SELF);
44         if (c && c->str_name)
45             pobject_lives(INTERP, (PObj*)c->str_name);
46     }
49     /* Destructor. */
50     void destroy()
51     {
52         /* Cleanup any memory we're using. */
53         if (PMC_struct_val(SELF)) {
54             mem_sys_free(PMC_struct_val(SELF));
55             PMC_struct_val(SELF) = NULL;
56         }
57     }
60     /* Get the location of the signature blob for this member. */
61     METHOD INTVAL get_signature()
62     {
63         dotnet_memberref *c = (dotnet_memberref *)PMC_struct_val(SELF);
64         INTVAL            result;
66         /* Handle cases where we've an invalid PMC. */
67         if (!c)
68             real_exception(INTERP, NULL, E_StandardError,
69                "Invalid DotNetMemberRefMetadata PMC");
71         result = c->signature;
72         RETURN(INTVAL result);
73     }
76     /* Get the type of "class" that the member belongs to. */
77     METHOD INTVAL get_class_type()
78     {
79         dotnet_memberref *c = (dotnet_memberref *)PMC_struct_val(SELF);
80         INTVAL            result;
82         /* Handle cases where we've an invalid PMC. */
83         if (!c)
84             real_exception(INTERP, NULL, E_StandardError,
85                "Invalid DotNetMemberRefMetadata PMC");
87         result = c->class_type;
88         RETURN(INTVAL result);
89     }
92     /* Get the id of "class" that the member belongs to. */
93     METHOD INTVAL get_class_id()
94     {
95         dotnet_memberref *c = (dotnet_memberref *)PMC_struct_val(SELF);
96         INTVAL            result;
98         /* Handle cases where we've an invalid PMC. */
99         if (!c)
100             real_exception(INTERP, NULL, E_StandardError,
101                "Invalid DotNetMemberRefMetadata PMC");
103         result = c->class_id;
104         RETURN(INTVAL result);
105     }
110  * Local variables:
111  *   c-file-style: "parrot"
112  * End:
113  * vim: expandtab shiftwidth=4:
114  */