tagged release 0.6.4
[parrot.git] / languages / dotnet / pmc / dotnettyperefmetadata.pmc
blobf1034ecc8a2a75a7ea62e73dcadb3c60966bdad1
1 /*
2  * $Id$
3  * Copyright (C) 2006-2008, The Perl Foundation.
4  */
6 /* .NET CLI TypeRef Metadata PMC */
9 #include "parrot/extend.h"
10 #include "tableinfo.h"
11 #include "structures.h"
14 pmclass DotNetTypeRefMetadata 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 referenced type. */
25     STRING* get_string()
26     {
27         dotnet_typeref *c = (dotnet_typeref *)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 DotNetTypeRefMetadata 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_typeref *c = (dotnet_typeref *)PMC_struct_val(SELF);
43         if (c) {
44             if (c->str_name)
45                 pobject_lives(INTERP, (PObj*)c->str_name);
46             if (c->str_namespace)
47                 pobject_lives(INTERP, (PObj*)c->str_namespace);
48         }
49     }
52     /* Destructor. */
53     void destroy()
54     {
55         /* Cleanup any memory we're using. */
56         if (PMC_struct_val(SELF)) {
57             mem_sys_free(PMC_struct_val(SELF));
58             PMC_struct_val(SELF) = NULL;
59         }
60     }
63     /* Get the namespace of the referenced type. */
64     METHOD STRING* get_namespace()
65     {
66         dotnet_typeref *c = (dotnet_typeref *)PMC_struct_val(SELF);
67         STRING         *result;
69         /* Handle cases where we've an invalid PMC. */
70         if (!c)
71             real_exception(INTERP, NULL, E_StandardError,
72                "Invalid DotNetTypeRefMetadata PMC");
74         result = c->str_namespace;
75         RETURN(STRING *result);
76     }
79     /* Get the resolution scope. */
80     METHOD INTVAL get_resolution_scope()
81     {
82         dotnet_typeref *c = (dotnet_typeref *)PMC_struct_val(SELF);
83         INTVAL          result;
85         /* Handle cases where we've an invalid PMC. */
86         if (!c)
87             real_exception(INTERP, NULL, E_StandardError,
88                "Invalid DotNetTypeRefMetadata PMC");
90         result = c->resolution_scope;
91         RETURN(INTVAL result);
92     }
97  * Local variables:
98  *   c-file-style: "parrot"
99  * End:
100  * vim: expandtab shiftwidth=4:
101  */