[svn:parrot] r47000 - in trunk: include/parrot src
whiteknight at svn.parrot.org
whiteknight at svn.parrot.org
Wed May 26 00:41:50 UTC 2010
Author: whiteknight
Date: Wed May 26 00:41:49 2010
New Revision: 47000
URL: https://trac.parrot.org/parrot/changeset/47000
Log:
Add new PMC_IS_TYPE() and PMC_IS_TYPE_ENUM() macros on an experimental basis. Employ the first to prove that it works as expected
Modified:
trunk/include/parrot/pmc.h
trunk/src/pmc.c
Modified: trunk/include/parrot/pmc.h
==============================================================================
--- trunk/include/parrot/pmc.h Tue May 25 22:53:48 2010 (r46999)
+++ trunk/include/parrot/pmc.h Wed May 26 00:41:49 2010 (r47000)
@@ -245,6 +245,9 @@
#define pmc_type Parrot_pmc_get_type_str
#define pmc_type_p Parrot_pmc_get_type
+#define PMC_IS_TYPE(p, t) ((p)->vtable->base_type == enum_class_ ## t)
+#define PMC_IS_TYPE_ENUM(p, e) ((p)->vtable->base_type == (e))
+
#endif /* PARROT_PMC_H_GUARD */
/*
Modified: trunk/src/pmc.c
==============================================================================
--- trunk/src/pmc.c Tue May 25 22:53:48 2010 (r46999)
+++ trunk/src/pmc.c Wed May 26 00:41:49 2010 (r47000)
@@ -771,7 +771,7 @@
Parrot_pmc_get_type_str(PARROT_INTERP, ARGIN_NULLOK(STRING *name))
{
ASSERT_ARGS(Parrot_pmc_get_type_str)
- if (!name)
+ if (STRING_IS_NULL(name))
return enum_type_undef;
else {
PMC * const classname_hash = interp->class_hash;
@@ -780,7 +780,8 @@
if (!PMC_IS_NULL(item)) {
/* nested namespace with same name */
- if (item->vtable->base_type == enum_class_NameSpace)
+ if (PMC_IS_TYPE(item, NameSpace))
+ //if (item->vtable->base_type == enum_class_NameSpace)
return enum_type_undef;
else
return VTABLE_get_integer(interp, item);
More information about the parrot-commits
mailing list