Skip to content
This repository
Newer
Older
100644 188 lines (118 sloc) 3.169 kb
9255c820 » paultcochrane
2007-03-26 [src] Set svn:keywords and svn:eol-style properties appropriately
1 /*
2 Copyright (C) 2007, The Perl Foundation.
3 $Id$
4
5 =head1 NAME
6
7 src/pmc/exporter.pmc - Export globals from one namespace to another
8
9 =head1 DESCRIPTION
10
11 Exports globals from one namespace to another
12
13 =head2 Functions
14
15 =over 4
16
17 =cut
18
19 */
20
21 #include "parrot/parrot.h"
22 #define PARROT_EXPORTER(e) ((Parrot_Exporter *) PMC_data(e))
23
24 typedef struct Parrot_Exporter {
25 PMC *ns_src; /* The source NameSpace PMC */
26 PMC *ns_dest; /* The destination NameSpace PMC */
27 PMC *globals; /* The globals to export - a ResizableStringArray */
28 } Parrot_Exporter;
29
30
31 pmclass Exporter
32 need_ext {
33
34
35 /*
36
37 =item C<void init()>
38
39 Instantiates an Exporter.
40
41 =cut
42
43 */
44
45 void init() {
46 Parrot_Exporter *exp = NULL;
47
48 /* Custom DOD mark and destory. */
49 PObj_custom_mark_SET(SELF);
50 PObj_active_destroy_SET(SELF);
51
52 /* Set up the object. */
53 exp = mem_sys_allocate_zeroed(sizeof(Parrot_Exporter));
54 exp->ns_src = pmc_new(interp, enum_class_NameSpace);
55 exp->ns_dest = pmc_new(interp, enum_class_NameSpace);
56 exp->globals = pmc_new(interp, enum_class_ResizableStringArray);
57 PMC_data(SELF) = exp;
58 }
59
60
61 /*
62
63 =item C<void src(PMC *)>
64
65 Return the C<globals> array.
66
67 =cut
68
69 */
70
71 PCCMETHOD void src(PMC *src :optional, int got_src :opt_flag) {
72 Parrot_Exporter *exp = PARROT_EXPORTER(SELF);
73 PMC *ret_ns_src;
74
75 /* TODO deal with non-namespace pmcs */
76 if (got_src) {
77 exp->ns_src = VTABLE_clone(interp, src);
78 }
79 else {
80 ret_ns_src = VTABLE_clone(interp, exp->ns_src);
81 PCCRETURN(PMC *ret_ns_src);
82 }
83 }
84
85
86 /*
87
88 =item C<PMC *globals(void)>
89
90 Return the C<globals> array.
91
92 =cut
93
94 */
95
96 PCCMETHOD void globals() {
97 Parrot_Exporter *exp = PARROT_EXPORTER(SELF);
98 PMC *ret_globals = VTABLE_clone(interp, exp->globals);
99 PCCRETURN(PMC *ret_globals);
100 }
101
102
103 /*
104
105 =item C<void add_global(PMC *global)>
106
107 Add C<global> to the array of globals.
108
109 =cut
110
111 */
112
113 void add_global(PMC *global) {
114 Parrot_Exporter *exp = PARROT_EXPORTER(SELF);
115 PMC *globals = exp->globals;
116 }
117
118
119 /*
120
121 =item C<PMC *import(PMC *dest, PMC *src, PMC *globals)>
122
123 Import C<globals> from the C<src> namespace to the C<dest> namespace.
124
125 =cut
126
127 */
128
129 PMC *import(PMC *dest, PMC *src, PMC *globals) {
130 Parrot_Exporter *exp = PARROT_EXPORTER(SELF);
131 /* */
132 return PMCNULL;
133 }
134
135 /*
136
137 =item C<void destory()>
138
139 Free the object's underlying struct.
140
141 =cut
142
143 */
144 void destroy() {
145 mem_sys_free(PMC_data(SELF));
146 }
147
148
149 /*
150
151 =item C<void mark()>
152
153 Mark any referenced strings and PMCs.
154
155 =cut
156
157 */
158 void mark() {
159 Parrot_Exporter *exp = PARROT_EXPORTER(SELF);
160 if (exp->ns_src)
161 pobject_lives(interp, (PObj*)exp->ns_src);
162 if (exp->ns_dest)
163 pobject_lives(interp, (PObj*)exp->ns_dest);
164 if (exp->globals)
165 pobject_lives(interp, (PObj*)exp->globals);
166 }
167
168
169 }
170
171 /*
172
173 =back
174
175 =head1 SEE ALSO
176
177 F<docs/pdds/pdd17_basic_types.pod>.
178
179 =cut
180
181 */
182
183 /*
184 * Local variables:
185 * c-file-style: "parrot"
186 * End:
187 * vim: expandtab shiftwidth=4:
188 */
Something went wrong with that request. Please try again.