Author: chromatic
Date: Wed May 16 22:09:00 2007
New Revision: 18578

Modified:
   trunk/compilers/imcc/pbc.c   (contents, props changed)
   trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm
   trunk/src/inter_call.c
   trunk/src/mmd.c
   trunk/src/objects.c
   trunk/src/ops/object.ops   (contents, props changed)
   trunk/src/ops/pmc.ops   (contents, props changed)
   trunk/src/pmc/default.pmc
   trunk/src/pmc/super.pmc

Log:
[OO] Return PMCNULL instead of plain NULL from method-finding functions.

This means using PMC_IS_NULL() appropriately in other places.

This means touching up a few source nits such as missing copyrights and SVN 
properties on a few other files.

Modified: trunk/compilers/imcc/pbc.c
==============================================================================
--- trunk/compilers/imcc/pbc.c  (original)
+++ trunk/compilers/imcc/pbc.c  Wed May 16 22:09:00 2007
@@ -1,3 +1,8 @@
+/*
+ * Copyright (C) 2007, The Perl Foundation.
+ * $Id$
+ */
+
 #include "imc.h"
 #include "pbc.h"
 #include "parrot/packfile.h"
@@ -578,7 +583,7 @@
     PMC *decl_lex_meth            = VTABLE_find_method(interp,
                                         lex_info_class, decl_lex);
 
-    if (!decl_lex_meth)
+    if (PMC_IS_NULL(decl_lex_meth))
         real_exception(interp, NULL, METH_NOT_FOUND,
                 "Method '%Ss' not found", decl_lex);
 

Modified: trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm
==============================================================================
--- trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm (original)
+++ trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm Wed May 16 22:09:00 2007
@@ -1,4 +1,4 @@
-# Copyright (C) 2004-2006, The Perl Foundation.
+# Copyright (C) 2004-2007, The Perl Foundation.
 # $Id$
 
 package Parrot::Pmc2c::PCCMETHOD;
@@ -523,7 +523,7 @@
       PMC_cont(ret_cont)->from_ctx = ctx;
 
       pccinvoke_meth = VTABLE_find_method(interp, $invocant, $method_name);
-      if (!pccinvoke_meth)
+      if (PMC_IS_NULL(pccinvoke_meth))
           real_exception(interp, NULL, METH_NOT_FOUND,
             "Method '%Ss' not found", $method_name);
       else

Modified: trunk/src/inter_call.c
==============================================================================
--- trunk/src/inter_call.c      (original)
+++ trunk/src/inter_call.c      Wed May 16 22:09:00 2007
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2001-2003, The Perl Foundation.
+Copyright (C) 2001-2007, The Perl Foundation.
 $Id$
 
 =head1 NAME
@@ -1498,7 +1498,7 @@
     ctx->current_cont = ret_cont;
     PMC_cont(ret_cont)->from_ctx = ctx;
     pccinvoke_meth = VTABLE_find_method(interp, pmc, method_name);
-    if (!pccinvoke_meth) {
+    if (PMC_IS_NULL(pccinvoke_meth)) {
         real_exception(interp, NULL, METH_NOT_FOUND, "Method '%Ss' not found", 
method_name);
     }
     else {

Modified: trunk/src/mmd.c
==============================================================================
--- trunk/src/mmd.c     (original)
+++ trunk/src/mmd.c     Wed May 16 22:09:00 2007
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2003-2006, The Perl Foundation.
+Copyright (C) 2003-2007, The Perl Foundation.
 $Id$
 
 =head1 NAME
@@ -1147,7 +1147,7 @@
         for (i = start_at_parent; i < n; ++i) {
             _class = VTABLE_get_pmc_keyed_int(interp, mro, i);
             pmc = Parrot_find_method_with_cache(interp, _class, meth);
-            if (pmc) {
+            if (!PMC_IS_NULL(pmc)) {
                 /*
                  * mmd_is_hidden would consider all previous candidates
                  * XXX pass current n so that only candidates from this
@@ -1609,7 +1609,7 @@
     meth_name = const_string(interp, short_name);
     _class = interp->vtables[type]->pmc_class;
     method = Parrot_find_method_direct(interp, _class, meth_name);
-    if (!method) {
+    if (PMC_IS_NULL(method)) {
         /* first method */
         method = constant_pmc_new(interp, enum_class_NCI);
         VTABLE_set_pointer_keyed_str(interp, method,

Modified: trunk/src/objects.c
==============================================================================
--- trunk/src/objects.c (original)
+++ trunk/src/objects.c Wed May 16 22:09:00 2007
@@ -138,7 +138,7 @@
     INTVAL vtable_index = Parrot_get_vtable_index(interp, meth);
 
     if (vtable_index == -1)
-        return NULL;
+        return PMCNULL;
 
     /* Get class. */
     if (PObj_is_object_TEST(pmc))
@@ -807,16 +807,16 @@
     PMC *prop;
     prop = VTABLE_getprop(interp, _class, prop_str);
     if (!VTABLE_defined(interp, prop))
-        return NULL;
+        return PMCNULL;
     meth = VTABLE_get_string(interp, prop);
 #else
     props = PMC_metadata(_class);
     if (!props)
-        return NULL;
+        return PMCNULL;
     b = parrot_hash_get_bucket(interp,
                 (Hash*) PMC_struct_val(props), prop_str);
     if (!b)
-        return NULL;
+        return PMCNULL;
     meth = PMC_str_val((PMC*) b->value);
 #endif
 
@@ -824,7 +824,7 @@
     ns        = VTABLE_pmc_namespace(interp, _class);
     method    = VTABLE_get_pmc_keyed_str(interp, ns, meth);
 
-    return PMC_IS_NULL(method) ? NULL : method;
+    return method;
 }
 
 
@@ -891,7 +891,7 @@
         meth = get_init_meth(interp, parent_class,
                 CONST_STRING(interp, "BUILD"), &meth_str);
         /* no method found and no BUILD property set? */
-        if (!meth && meth_str == NULL) {
+        if (PMC_IS_NULL(meth) && meth_str == NULL) {
             PMC   *ns;
             INTVAL vtable_index;
 
@@ -1154,7 +1154,7 @@
 =item C<PMC * Parrot_remove_parent(Interp *interp, PMC *removed_class,
     PMC *existing_class)>
 
-This currently does nothing but return C<NULL>.
+This currently does nothing but return C<PMCNULL>.
 
 =cut
 
@@ -1162,7 +1162,7 @@
 
 PMC *
 Parrot_remove_parent(Interp *interp, PMC *removed_class, PMC *existing_class) {
-    return NULL;
+    return PMCNULL;
 }
 
 /*
@@ -1171,7 +1171,7 @@
 Parrot_multi_subclass(Interp *interp, PMC *base_class_array,
     STRING *child_class_name)>
 
-This currently does nothing but return C<NULL>.
+This currently does nothing but return C<PMCNULL>.
 
 =cut
 
@@ -1180,7 +1180,7 @@
 PMC *
 Parrot_multi_subclass(Interp *interp, PMC *base_class_array,
     STRING *child_class_name) {
-    return NULL;
+    return PMCNULL;
 }
 
 /*
@@ -1222,7 +1222,7 @@
 
 This should create and return a new method cache PMC.
 
-Currently it does nothing but return C<NULL>.
+Currently it does nothing but return C<PMCNULL>.
 
 =cut
 
@@ -1230,7 +1230,7 @@
 
 PMC *
 Parrot_new_method_cache(Interp *interp) {
-    return NULL;
+    return PMCNULL;
 }
 
 /*
@@ -1378,7 +1378,7 @@
     if (string_equal(interp, method_name, s1) == 0)
         return find_method_direct_1(interp, _class, s2);
 
-    return NULL;
+    return PMCNULL;
 }
 
 PMC *
@@ -1508,7 +1508,7 @@
         }
     }
     TRACE_FM(interp, _class, method_name, NULL);
-    return NULL;
+    return PMCNULL;
 }
 
 /*
@@ -1765,17 +1765,17 @@
 
 PMC *Parrot_find_class_constructor(Interp *interp, STRING *_class,
                                    INTVAL classtoken) {
-    return NULL;
+    return PMCNULL;
 }
 
 PMC *Parrot_find_class_destructor(Interp *interp, STRING *_class,
                                   INTVAL classtoken) {
-    return NULL;
+    return PMCNULL;
 }
 
 PMC *Parrot_find_class_fallback(Interp *interp, STRING *_class,
                                 INTVAL classtoken) {
-    return NULL;
+    return PMCNULL;
 }
 
 void Parrot_set_class_constructor(Interp *interp, STRING *_class,

Modified: trunk/src/ops/object.ops
==============================================================================
--- trunk/src/ops/object.ops    (original)
+++ trunk/src/ops/object.ops    Wed May 16 22:09:00 2007
@@ -1,5 +1,10 @@
 /*
-** object.ops
+
+Copyright (C) 2001-2007, The Perl Foundation.
+$Id$
+
+object.ops
+
 */
 
 
@@ -55,7 +60,7 @@
   meth = $2;
   next = expr NEXT();
   method_pmc = VTABLE_find_method(interp, object, meth);
-  if (!method_pmc) {
+  if (PMC_IS_NULL(method_pmc)) {
     real_exception(interp, next, METH_NOT_FOUND,
         "Method '%Ss' not found", meth);
   }
@@ -91,7 +96,7 @@
   meth = $2;
   next = expr NEXT();
   method_pmc = VTABLE_find_method(interp, object, meth);
-  if (!method_pmc) {
+  if (PMC_IS_NULL(method_pmc)) {
     real_exception(interp, next, METH_NOT_FOUND,
         "Method '%Ss' not found", meth);
   }
@@ -125,7 +130,7 @@
   object = $1;
   meth = $2;
   method_pmc = VTABLE_find_method(interp, object, meth);
-  if (!method_pmc) {
+  if (PMC_IS_NULL(method_pmc)) {
     real_exception(interp, next, METH_NOT_FOUND,
         "Method '%Ss' not found", meth);
   }

Modified: trunk/src/ops/pmc.ops
==============================================================================
--- trunk/src/ops/pmc.ops       (original)
+++ trunk/src/ops/pmc.ops       Wed May 16 22:09:00 2007
@@ -1,5 +1,10 @@
 /*
-** pmc.ops
+
+Copyright (C) 2001-2007, The Perl Foundation.
+$Id$
+
+pmc.ops
+
 */
 
 VERSION = PARROT_VERSION;
@@ -270,7 +275,7 @@
 op find_method(out PMC, invar PMC, in STR) {
     opcode_t * resume = expr NEXT();
     $1 = $2->vtable->find_method(interp, $2, $3);
-    if (!$1 || !VTABLE_defined(interp, $1)) {
+    if (PMC_IS_NULL($1) || !VTABLE_defined(interp, $1)) {
         char *method_name = string_to_cstring(interp, $3);
         real_exception(interp, resume, METH_NOT_FOUND,
             "Method '%s' not found", method_name);

Modified: trunk/src/pmc/default.pmc
==============================================================================
--- trunk/src/pmc/default.pmc   (original)
+++ trunk/src/pmc/default.pmc   Wed May 16 22:09:00 2007
@@ -487,7 +487,7 @@
     }
 
 
-    PMC* find_method(STRING* method_name) {
+    PMC* find_method(STRING *method_name) {
         return Parrot_find_method_with_cache(INTERP, SELF, method_name);
     }
 
@@ -878,8 +878,8 @@
 
 */
 
-    INTVAL can(STRING* method) {
-        return VTABLE_find_method(INTERP, SELF, method) != NULL;
+    INTVAL can(STRING *method) {
+        return !PMC_IS_NULL(VTABLE_find_method(INTERP, SELF, method));
     }
 
 /*

Modified: trunk/src/pmc/super.pmc
==============================================================================
--- trunk/src/pmc/super.pmc     (original)
+++ trunk/src/pmc/super.pmc     Wed May 16 22:09:00 2007
@@ -94,7 +94,7 @@
             pobject_lives(INTERP, (PObj *)PMC_struct_val(SELF));
     }
 
-    PMC* find_method(STRING* name) {
+    PMC* find_method(STRING *name) {
         PMC *mro, *_class;
 
         PMC * const obj = PMC_pmc_val(SELF);

Reply via email to