Author: petdance
Date: Tue May 29 23:25:55 2007
New Revision: 18679

Modified:
   trunk/src/objects.c
   trunk/src/pmc/class.pmc

Log:
 more PMC consting

Modified: trunk/src/objects.c
==============================================================================
--- trunk/src/objects.c (original)
+++ trunk/src/objects.c Tue May 29 23:25:55 2007
@@ -1970,10 +1970,10 @@
     PMC *roles_of_role;
     PMC *proposed_add_methods;
 
-    int i, j, roles_count, roles_of_role_count;
+    int i, roles_of_role_count;
 
     /* Check we have not already composed the role; if so, just ignore it. */
-    roles_count = VTABLE_elements(interp, roles_list);
+    int roles_count = VTABLE_elements(interp, roles_list);
 
     for (i = 0; i < roles_count; i++) {
         if (VTABLE_get_pmc_keyed_int(interp, roles_list, i) == role)
@@ -2012,9 +2012,7 @@
             exclude_count = VTABLE_elements(interp, exclude);
 
             for (i = 0; i < exclude_count; i++) {
-                STRING *check;
-
-                check = VTABLE_get_string_keyed_int(interp, exclude, i);
+                const STRING * const check = 
VTABLE_get_string_keyed_int(interp, exclude, i);
 
                 if (string_equal(interp, check, method_name) == 0) {
                     excluded = 1;
@@ -2055,9 +2053,7 @@
         /* Now see if we've got an alias. */
         if (got_alias && VTABLE_exists_keyed_str(interp, alias, method_name)) {
             /* Got one. Get name to alias it to. */
-            STRING *alias_name;
-
-            alias_name = VTABLE_get_string_keyed_str(interp,
+            STRING * const alias_name = VTABLE_get_string_keyed_str(interp,
                 alias, method_name);
 
             /* Is there a method with this name already in the class?
@@ -2095,11 +2091,8 @@
 
     while (VTABLE_get_bool(interp, methods_iter)) {
         /* Get current method and its name. */
-        STRING *method_name;
-        PMC    *cur_method;
-
-        method_name = VTABLE_shift_string(interp, methods_iter);
-        cur_method  = VTABLE_get_pmc_keyed_str(interp, proposed_add_methods,
+        STRING * const method_name = VTABLE_shift_string(interp, methods_iter);
+        PMC *    const cur_method  = VTABLE_get_pmc_keyed_str(interp, 
proposed_add_methods,
             method_name);
 
         /* Add it to the methods of the class. */
@@ -2120,8 +2113,8 @@
 
     for (i = 0; i < roles_of_role_count; i++) {
         /* Only add if we don't already have it in the list. */
-        PMC *cur_role;
-        cur_role = VTABLE_get_pmc_keyed_int(interp, roles_of_role, i);
+        PMC * const cur_role = VTABLE_get_pmc_keyed_int(interp, roles_of_role, 
i);
+        int j;
 
         for (j = 0; j < roles_count; j++) {
             if (VTABLE_get_pmc_keyed_int(interp, roles_list, j) == cur_role) {

Modified: trunk/src/pmc/class.pmc
==============================================================================
--- trunk/src/pmc/class.pmc     (original)
+++ trunk/src/pmc/class.pmc     Tue May 29 23:25:55 2007
@@ -91,18 +91,18 @@
 /* Build a string representing the fully qualified class name. */
 STRING* Parrot_Class_get_fq_classname(Parrot_Interp interp, Parrot_Class 
*class_info) {
     STRING *fq_class = string_from_cstring(interp, "", 0);
-    STRING *seperator = string_from_const_cstring(interp, "::", 0);
+    STRING * const separator = string_from_const_cstring(interp, "::", 0);
     if (!PMC_IS_NULL(class_info->_namespace)) {
         /* If we have a namespace name, make a key from its name. */
         /* XXX BAD AND WRONG! Need to call get_name method properly! */
-        PMC *fq_name = Parrot_NameSpace_nci_get_name(interp, 
class_info->_namespace);
-        int elements = VTABLE_elements(interp, fq_name);
+        PMC * const fq_name = Parrot_NameSpace_nci_get_name(interp, 
class_info->_namespace);
+        const int elements = VTABLE_elements(interp, fq_name);
         int j;
         for (j = 0; j < elements; j++) {
             /* Append to class name. */
             fq_class = string_append(interp, fq_class,
                 VTABLE_get_string_keyed_int(interp, fq_name, j));
-            fq_class = string_append(interp, fq_class, seperator);
+            fq_class = string_append(interp, fq_class, separator);
         }
     } else if (class_info->name != NULL) {
         /* If we don't have a namespace but we do have a name,
@@ -116,11 +116,11 @@
 /* This function builds the attribute index (table to map class name and
  * attribute name to an index) for the current class. */
 static void build_attrib_index(Parrot_Interp interp, PMC *self) {
-    Parrot_Class *_class = PARROT_CLASS(self);
-    int num_classes = VTABLE_elements(interp, _class->all_parents);
+    Parrot_Class * const _class = PARROT_CLASS(self);
+    const int num_classes = VTABLE_elements(interp, _class->all_parents);
     int i;
     int cur_index = 0;
-    PMC *table = pmc_new(interp, enum_class_Hash);
+    PMC * const table = pmc_new(interp, enum_class_Hash);
 
     /* We will go over the list of all parents to construct the table. */
     for (i = 0; i < num_classes; i++) {
@@ -255,11 +255,11 @@
     if (VTABLE_exists_keyed_str(interp, info,
         string_from_const_cstring(interp, "parents", 0))) {
         /* Loop over parents array and add them. */
-        PMC *parent_list = VTABLE_get_pmc_keyed_str(interp, info,
+        PMC * const parent_list = VTABLE_get_pmc_keyed_str(interp, info,
             string_from_const_cstring(interp, "parents", 0));
-        int parent_count = VTABLE_elements(interp, parent_list);
+        const int parent_count = VTABLE_elements(interp, parent_list);
         for (i = 0; i < parent_count; i++) {
-            PMC *parent = VTABLE_get_pmc_keyed_int(interp, parent_list, i);
+            PMC * const parent = VTABLE_get_pmc_keyed_int(interp, parent_list, 
i);
             VTABLE_add_parent(interp, self, parent);
         }
     }
@@ -268,11 +268,11 @@
     if (VTABLE_exists_keyed_str(interp, info,
         string_from_const_cstring(interp, "roles", 0))) {
         /* Loop over roles array and compose them. */
-        PMC *role_list = VTABLE_get_pmc_keyed_str(interp, info,
+        PMC * const role_list = VTABLE_get_pmc_keyed_str(interp, info,
             string_from_const_cstring(interp, "roles", 0));
-        int role_count = VTABLE_elements(interp, role_list);
+        const int role_count = VTABLE_elements(interp, role_list);
         for (i = 0; i < role_count; i++) {
-            PMC *role = VTABLE_get_pmc_keyed_int(interp, role_list, i);
+            PMC * const role = VTABLE_get_pmc_keyed_int(interp, role_list, i);
             VTABLE_add_role(interp, self, role);
         }
     }
@@ -281,11 +281,11 @@
     if (VTABLE_exists_keyed_str(interp, info,
         string_from_const_cstring(interp, "attributes", 0))) {
         /* Loop over attributes array and add them. */
-        PMC *attrib_name_list = VTABLE_get_pmc_keyed_str(interp, info,
+        PMC * const attrib_name_list = VTABLE_get_pmc_keyed_str(interp, info,
             string_from_const_cstring(interp, "attributes", 0));
-        int attrib_count = VTABLE_elements(interp, attrib_name_list);
+        const int attrib_count = VTABLE_elements(interp, attrib_name_list);
         for (i = 0; i < attrib_count; i++) {
-            STRING *attrib_name = VTABLE_get_string_keyed_int(interp,
+            STRING * const attrib_name = VTABLE_get_string_keyed_int(interp,
                 attrib_name_list, i);
             VTABLE_add_attribute(interp, self, attrib_name, PMCNULL);
         }
@@ -295,15 +295,15 @@
     if (VTABLE_exists_keyed_str(interp, info,
         string_from_const_cstring(interp, "methods", 0))) {
         /* Get the methods hash. */
-        PMC *methods = VTABLE_get_pmc_keyed_str(interp, info,
+        PMC * const methods = VTABLE_get_pmc_keyed_str(interp, info,
             string_from_const_cstring(interp, "methods", 0));
 
         /* Iterate over the list of methods. */
-        PMC *iter = VTABLE_get_iter(interp, methods);
+        PMC * const iter = VTABLE_get_iter(interp, methods);
         while (VTABLE_get_bool(interp, iter)) {
             /* Add the method. */
-            STRING *method_name = VTABLE_shift_string(interp, iter);
-            PMC *method_pmc = VTABLE_get_pmc_keyed_str(interp, methods, 
method_name);
+            STRING * const method_name = VTABLE_shift_string(interp, iter);
+            PMC * const method_pmc = VTABLE_get_pmc_keyed_str(interp, methods, 
method_name);
             VTABLE_add_method(interp, self, method_name, method_pmc);
         }
     }
@@ -376,7 +376,7 @@
     void init_pmc(PMC* init_data) {
         Parrot_Class *_class = NULL;
         PMC *arg;
-        INTVAL arg_type = VTABLE_type(interp, init_data);
+        const INTVAL arg_type = VTABLE_type(interp, init_data);
 
         /* Set up the object. */
         SELF.init();
@@ -386,14 +386,14 @@
         {
             case enum_class_String:
                 {
-                  STRING *nameStr = CONST_STRING(interp, "name");
+                  STRING * const nameStr = CONST_STRING(interp, "name");
                   arg = pmc_new(interp, enum_class_Hash);
                   VTABLE_set_pmc_keyed_str(interp, arg, nameStr, init_data);
                 }
                 break;
             case enum_class_Key:
                 {
-                  STRING *nameStr = CONST_STRING(interp, "namespace");
+                  STRING * const nameStr = CONST_STRING(interp, "namespace");
                   arg = pmc_new(interp, enum_class_Hash);
                   VTABLE_set_pmc_keyed_str(interp, arg, nameStr, init_data);
                 }
@@ -405,7 +405,7 @@
             /* slow attempt to determine init_data type */
             default:
                 if (VTABLE_isa(interp, init_data, CONST_STRING(interp, 
"String"))) {
-                    STRING *nameStr = CONST_STRING(interp, "name");
+                    STRING * const nameStr = CONST_STRING(interp, "name");
                     arg = pmc_new(interp, enum_class_Hash);
                     VTABLE_set_pmc_keyed_str(interp, arg, nameStr, init_data);
                 }
@@ -454,7 +454,7 @@
 */
 
     void mark() {
-        Parrot_Class *_class = PARROT_CLASS(SELF);
+        Parrot_Class * const _class = PARROT_CLASS(SELF);
         if (_class->name)
             pobject_lives(interp, (PObj*)_class->name);
         if (_class->_namespace)
@@ -495,8 +495,8 @@
 
     void add_attribute(STRING *name, PMC *type)
     {
-        Parrot_Class *_class = PARROT_CLASS(SELF);
-        PMC *new_attribute = pmc_new(interp, enum_class_Hash);
+        Parrot_Class * const _class = PARROT_CLASS(SELF);
+        PMC * const new_attribute = pmc_new(interp, enum_class_Hash);
 
         /* If we've been instantiated already, need a new class. */
         if (_class->instantiated) {
@@ -532,7 +532,7 @@
 */
     void add_method(STRING *name, PMC *sub)
     {
-        Parrot_Class *_class = PARROT_CLASS(SELF);
+        Parrot_Class * const _class = PARROT_CLASS(SELF);
 
         /* If we have already added a method with this name... */
         if (VTABLE_exists_keyed_str(interp, _class->methods, name)) {
@@ -557,7 +557,7 @@
 */
     void add_parent(PMC *parent)
     {
-        Parrot_Class *_class = PARROT_CLASS(SELF);
+        Parrot_Class * const _class = PARROT_CLASS(SELF);
 
         /* If we've been instantiated already, need a new class. */
         if (_class->instantiated) {
@@ -592,7 +592,7 @@
 */
     void add_role(PMC *role)
     {
-        Parrot_Class *_class = PARROT_CLASS(SELF);
+        Parrot_Class * const _class = PARROT_CLASS(SELF);
 
         /* Do the composition. */
         Parrot_ComposeRole(interp, role, PMCNULL, 0, PMCNULL, 0,

Reply via email to