Author: Whiteknight
Date: Fri Jan 16 15:19:29 2009
New Revision: 35654
Modified:
trunk/src/oo.c
trunk/src/pmc/namespace.pmc
Log:
[Core] Some quick-hack fixes for TT#8. ResizableStringArray should now be more usable with get_class.
Modified: trunk/src/oo.c
==============================================================================
--- trunk/src/oo.c (original)
+++ trunk/src/oo.c Fri Jan 16 15:19:29 2009
@@ -221,7 +221,17 @@
if (PMC_IS_NULL(classobj)) {
/* Look up a low-level class and create a proxy */
- const INTVAL type = pmc_type(interp, VTABLE_get_string(interp, key));
+ INTVAL type;
+ const INTVAL base_type = key->vtable->base_type;
+
+ /* XXX TT#182: This is a hack! We should be able to treat all
+ PMC types the same through pmc_type_p or some interface to it */
+ if (base_type == enum_class_Key
+ || base_type == enum_class_ResizableStringArray
+ || base_type == enum_class_String)
+ type = pmc_type_p(interp, key);
+ else
+ type = pmc_type(interp, VTABLE_get_string(interp, key));
/* Reject invalid type numbers */
if (type > interp->n_vtable_max || type <= 0)
Modified: trunk/src/pmc/namespace.pmc
==============================================================================
--- trunk/src/pmc/namespace.pmc (original)
+++ trunk/src/pmc/namespace.pmc Fri Jan 16 15:19:29 2009
@@ -463,47 +463,50 @@
if (PMC_IS_NULL(key))
return PMCNULL;
- if (key->vtable->base_type == enum_class_String)
- return SELF.get_pointer_keyed_str(VTABLE_get_string(INTERP, key));
+ switch (key->vtable->base_type) {
+ case enum_class_String:
+ return SELF.get_pointer_keyed_str(VTABLE_get_string(INTERP, key));
+ case enum_class_Key: {
+ /* this loop (and function) could use a rewrite for clarity */
+ while (1) {
+ STRING * const part = VTABLE_get_string(INTERP, key);
+ key = key_next(INTERP, key);
- if (key->vtable->base_type == enum_class_Key) {
- /* this loop (and function) could use a rewrite for clarity */
- while (1) {
- STRING * const part = VTABLE_get_string(INTERP, key);
- key = key_next(INTERP, key);
+ if (!key)
+ return VTABLE_get_pointer_keyed_str(INTERP, ns, part);
- if (!key)
- return VTABLE_get_pointer_keyed_str(INTERP, ns, part);
+ ns = Parrot_get_namespace_keyed_str(INTERP, ns, part);
- ns = Parrot_get_namespace_keyed_str(INTERP, ns, part);
+ if (PMC_IS_NULL(ns))
+ return PMCNULL;
+ }
- if (PMC_IS_NULL(ns))
- return PMCNULL;
+ return ns;
}
+ case enum_class_ResizableStringArray: {
+ INTVAL elements = VTABLE_elements(interp, key);
+ INTVAL i;
+ for (i = 0; i < elements; ++i) {
+ STRING * const part = VTABLE_get_string_keyed_int(interp, key, i);
+
+ /* Last entry in the array */
+ if ((i + 1) >= elements)
+ return VTABLE_get_pointer_keyed_str(INTERP, ns, part);
- return ns;
- }
-
- if (key->vtable->base_type == enum_class_ResizableStringArray) {
- INTVAL elements = VTABLE_elements(interp, key);
- INTVAL i;
- for (i = 0; i < elements; ++i) {
- STRING * const part = VTABLE_get_string_keyed_int(interp, key, i);
-
- /* Last entry in the array */
- if ((i + 1) >= elements)
- return VTABLE_get_pointer_keyed_str(INTERP, ns, part);
+ ns = Parrot_get_namespace_keyed_str(INTERP, ns, part);
- ns = Parrot_get_namespace_keyed_str(INTERP, ns, part);
-
- if (PMC_IS_NULL(ns))
- return PMCNULL;
+ if (PMC_IS_NULL(ns))
+ return PMCNULL;
+ }
+ return ns;
}
- return ns;
+ case enum_class_NameSpace:
+ /* XXX TT#182: Implement this! */
+ return PMCNULL;
+ default:
+ Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_GLOBAL_NOT_FOUND,
+ "Invalid namespace key in get_pointer_keyed");
}
-
- Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_GLOBAL_NOT_FOUND,
- "Invalid namespace key in get_pointer_keyed");
}
/*
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.