Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Require creation of P5Namespace through proper channels

  • Loading branch information...
commit 4c0982aaf2829e42074e04cfd7fa3170c97c5f36 1 parent 5145ceb
@sorear sorear authored
Showing with 28 additions and 37 deletions.
  1. +24 −0 src/pmc/p5interpreter.pmc
  2. +4 −37 src/pmc/p5namespace.pmc
View
24 src/pmc/p5interpreter.pmc
@@ -30,6 +30,7 @@ These are the vtable functions for the P5Interpreter class.
/* Need to know a bit about other PMCs. */
#include "pmc_p5scalar.h"
+#include "pmc_p5namespace.h"
#include "bkmarshal.h"
/* Tracking of whether we've initialized or not. */
@@ -160,6 +161,29 @@ Run the Perl 5 code.
return blizkost_return_from_invoke(interp, next);
}
+
+/*
+
+=item C<PMC *get_namespace(const char *name)>
+
+Acquire a namespace handle.
+
+=cut
+
+*/
+
+ METHOD PMC *get_namespace(STRING *name) {
+ PMC *pmc = Parrot_pmc_new_noinit(interp, pmc_type(interp,
+ string_from_literal(interp, "P5Namespace")));
+ /* Set up the underlying structure. */
+ PMC_data(pmc) = mem_allocate_zeroed_typed(Parrot_P5Namespace_attributes);
+ PObj_custom_mark_SET(pmc);
+ PObj_custom_destroy_SET(pmc);
+ SETATTR_P5Namespace_p5i(interp, pmc, SELF);
+ SETATTR_P5Namespace_ns_name(interp, pmc, name);
+
+ return pmc;
+ }
}
/*
View
41 src/pmc/p5namespace.pmc
@@ -34,29 +34,13 @@ These are the vtable functions for the P5Namespace class.
pmclass P5Namespace group blizkost_group dynpmc {
ATTR PMC *p5i;
- ATTR PMC *marshall_cache;
ATTR STRING *ns_name;
-/*
-
-=item C<void init()>
-
-Set up P5Namespace PMC.
-
-=cut
-
-*/
-
- VTABLE void init_pmc(PMC *p5i) {
- /* Set up the underlying structure. */
- PMC_data(SELF) = mem_allocate_zeroed_typed(Parrot_P5Namespace_attributes);
- PObj_custom_mark_SET(SELF);
- PObj_custom_destroy_SET(SELF);
- SET_ATTR_p5i(interp, SELF, p5i);
- SET_ATTR_marshall_cache(interp, SELF, PMCNULL);
+ VTABLE void init() {
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_ILL_INHERIT,
+ "P5Namespace values can only be created through an interpreter");
}
-
/*
=item C<void mark()>
@@ -68,15 +52,12 @@ Mark GC-ables.
*/
VTABLE void mark() {
if (PMC_data(SELF)) {
- PMC *p5i, *cache;
+ PMC *p5i;
STRING *name;
GET_ATTR_p5i(interp, SELF, p5i);
- GET_ATTR_marshall_cache(interp, SELF, cache);
GET_ATTR_ns_name(interp, SELF, name);
if (p5i)
Parrot_gc_mark_PObj_alive(interp, (PObj*)p5i);
- if (cache)
- Parrot_gc_mark_PObj_alive(interp, (PObj*)cache);
if (name)
Parrot_gc_mark_PObj_alive(interp, (PObj*)name);
}
@@ -97,20 +78,6 @@ Free underlying structure.
mem_sys_free(PMC_data(SELF));
}
-
-/*
-
-=item C<void set_string_native(STRING *name)>
-
-Set the name of the Perl 5 namespace that we map to.
-
-=cut
-
-*/
- VTABLE void set_string_native(STRING *name) {
- SET_ATTR_ns_name(interp, SELF, name);
- }
-
/*
=item C<PMC *find_method(STRING *name)>
Please sign in to comment.
Something went wrong with that request. Please try again.