[svn:parrot] r45390 - trunk/src/pmc

petdance at svn.parrot.org petdance at svn.parrot.org
Sat Apr 3 05:01:20 UTC 2010


Author: petdance
Date: Sat Apr  3 05:01:19 2010
New Revision: 45390
URL: https://trac.parrot.org/parrot/changeset/45390

Log:
consting and removed old history

Modified:
   trunk/src/pmc/resizablepmcarray.pmc
   trunk/src/pmc/resizablestringarray.pmc

Modified: trunk/src/pmc/resizablepmcarray.pmc
==============================================================================
--- trunk/src/pmc/resizablepmcarray.pmc	Sat Apr  3 00:46:43 2010	(r45389)
+++ trunk/src/pmc/resizablepmcarray.pmc	Sat Apr  3 05:01:19 2010	(r45390)
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2001-2009, Parrot Foundation.
+Copyright (C) 2001-2010, Parrot Foundation.
 $Id$
 
 =head1 NAME
@@ -86,7 +86,7 @@
             INTVAL i, cur, needed;
             i = cur = PMC_threshold(SELF);
             if (cur < 8192)
-                cur = size < 2 * cur ? 2 * cur : size;
+                cur = (size < 2 * cur) ? (2 * cur) : size;
             else {
                 needed = size - cur;
                 cur   += needed + 4096;
@@ -285,8 +285,8 @@
     }
 
     VTABLE void delete_keyed_int(INTVAL idx) {
-        PMC   **data = PMC_array(SELF);
-        INTVAL  n    = PMC_size(SELF);
+        PMC ** const data = PMC_array(SELF);
+        const INTVAL  n   = PMC_size(SELF);
         INTVAL  i;
 
         for (i = idx; i < n - 1; ++i)
@@ -320,7 +320,7 @@
     }
 
     VTABLE INTVAL exists_keyed(PMC *key) {
-        INTVAL ix = VTABLE_get_integer(INTERP, key);
+        const INTVAL ix = VTABLE_get_integer(INTERP, key);
         return SELF.exists_keyed_int(ix);
     }
 
@@ -370,8 +370,8 @@
 
     VTABLE void push_float(FLOATVAL value) {
 
-        INTVAL size = PMC_size(SELF);
-        PMC   *val  = Parrot_pmc_new(INTERP, enum_class_Float);
+        const INTVAL size = PMC_size(SELF);
+        PMC   * const val = Parrot_pmc_new(INTERP, enum_class_Float);
 
         VTABLE_set_number_native(INTERP, val, value);
         SELF.set_pmc_keyed_int(size, val);
@@ -381,8 +381,8 @@
 
     VTABLE void push_integer(INTVAL value) {
 
-        INTVAL size = PMC_size(SELF);
-        PMC   *val  = Parrot_pmc_new(INTERP, enum_class_Integer);
+        const INTVAL size = PMC_size(SELF);
+        PMC   * const val = Parrot_pmc_new(INTERP, enum_class_Integer);
 
         VTABLE_set_integer_native(INTERP, val, value);
         SELF.set_pmc_keyed_int(size, val);
@@ -392,7 +392,7 @@
 
     VTABLE void push_pmc(PMC *value) {
 
-        INTVAL size = PMC_size(SELF);
+        const INTVAL size = PMC_size(SELF);
         SELF.set_integer_native(size + 1);
         ((PMC **)PMC_array(SELF))[size] = value;
 
@@ -401,8 +401,8 @@
 
     VTABLE void push_string(STRING *value) {
 
-        INTVAL size = PMC_size(SELF);
-        PMC   *val  = Parrot_pmc_new(INTERP, enum_class_String);
+        const INTVAL size = PMC_size(SELF);
+        PMC   * const val = Parrot_pmc_new(INTERP, enum_class_String);
 
         VTABLE_assign_string_native(INTERP, val, value);
         SELF.set_pmc_keyed_int(size, val);
@@ -505,8 +505,8 @@
 
     VTABLE void unshift_float(FLOATVAL value) {
 
-        INTVAL  size = PMC_size(SELF);
-        PMC    *val  = Parrot_pmc_new(INTERP, enum_class_Float);
+        const INTVAL size = PMC_size(SELF);
+        PMC * const val   = Parrot_pmc_new(INTERP, enum_class_Float);
         PMC   **data;
         INTVAL  i;
 
@@ -525,8 +525,8 @@
 
     VTABLE void unshift_integer(INTVAL value) {
 
-        INTVAL  size = PMC_size(SELF);
-        PMC    *val  = Parrot_pmc_new(INTERP, enum_class_Integer);
+        const INTVAL size = PMC_size(SELF);
+        PMC * const val   = Parrot_pmc_new(INTERP, enum_class_Integer);
         PMC    **data;
         INTVAL   i;
 
@@ -545,7 +545,7 @@
 
     VTABLE void unshift_pmc(PMC *value) {
 
-        INTVAL  size = PMC_size(SELF);
+        const INTVAL size = PMC_size(SELF);
         PMC   **data;
         INTVAL  i;
 
@@ -563,8 +563,8 @@
 
     VTABLE void unshift_string(STRING *value) {
 
-        INTVAL  size = PMC_size(SELF);
-        PMC    *val  = Parrot_pmc_new(INTERP, enum_class_String);
+        const INTVAL size = PMC_size(SELF);
+        PMC * const val  = Parrot_pmc_new(INTERP, enum_class_String);
         PMC   **data;
         INTVAL  i;
 
@@ -592,7 +592,7 @@
 */
 
     VTABLE PMC *clone() {
-        PMC *copy = SUPER();
+        PMC * const copy = SUPER();
 
         /* copy trimmed extra space */
         PMC_threshold(copy) = PMC_size(SELF);
@@ -612,9 +612,8 @@
 
     METHOD append(PMC *other) {
 
-        INTVAL i;
-        INTVAL n = VTABLE_elements(INTERP, SELF);
-        INTVAL m = VTABLE_elements(INTERP, other);
+        const INTVAL n = VTABLE_elements(INTERP, SELF);
+        const INTVAL m = VTABLE_elements(INTERP, other);
 
         if (!m)
             RETURN(void);
@@ -624,14 +623,15 @@
 
         if (other->vtable->base_type == SELF->vtable->base_type
         ||  other->vtable->base_type == enum_class_FixedPMCArray) {
-            PMC **other_data = PMC_array(other);
-            PMC **this_data  = PMC_array(SELF);
+            PMC ** const other_data = PMC_array(other);
+            PMC ** const this_data  = PMC_array(SELF);
 
             /* libc is faster at copying data than a manual loop here */
             memmove(this_data + n, other_data, m  * sizeof (PMC *));
         }
         else {
-            PMC **this_data = PMC_array(SELF);
+            PMC ** const this_data = PMC_array(SELF);
+            INTVAL i;
 
             for (i = 0; i < m; ++i)
                 this_data[n + i] = VTABLE_get_pmc_keyed_int(INTERP, other, i);
@@ -650,11 +650,11 @@
     VTABLE STRING *get_repr() {
 
         INTVAL  j;
-        INTVAL  n   = VTABLE_elements(INTERP, SELF);
+        const INTVAL n = VTABLE_elements(INTERP, SELF);
         STRING *res = CONST_STRING(INTERP, "[ ");
 
         for (j = 0; j < n; ++j) {
-            PMC *val = SELF.get_pmc_keyed_int(j);
+            PMC * const val = SELF.get_pmc_keyed_int(j);
             res      = Parrot_str_append(INTERP, res, VTABLE_get_repr(INTERP, val));
 
             if (j < n - 1)
@@ -684,7 +684,7 @@
 
         const INTVAL length = VTABLE_elements(INTERP, SELF);
         const INTVAL elems  = VTABLE_elements(INTERP, value);
-        INTVAL       shift  = elems - count;
+        const INTVAL shift  = elems - count;
         INTVAL       i;
 
         /* start from end? */
@@ -735,12 +735,12 @@
 */
 
     METHOD shift() {
-        PMC *value = VTABLE_shift_pmc(INTERP, SELF);
+        PMC * const value = VTABLE_shift_pmc(INTERP, SELF);
         RETURN(PMC *value);
     }
 
     METHOD pop() {
-        PMC *value = VTABLE_pop_pmc(INTERP, SELF);
+        PMC * const value = VTABLE_pop_pmc(INTERP, SELF);
         RETURN(PMC *value);
     }
 

Modified: trunk/src/pmc/resizablestringarray.pmc
==============================================================================
--- trunk/src/pmc/resizablestringarray.pmc	Sat Apr  3 00:46:43 2010	(r45389)
+++ trunk/src/pmc/resizablestringarray.pmc	Sat Apr  3 05:01:19 2010	(r45390)
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2001-2009, Parrot Foundation.
+Copyright (C) 2001-2010, Parrot Foundation.
 $Id$
 
 =head1 NAME
@@ -166,7 +166,7 @@
 */
 
     VTABLE INTVAL pop_integer() {
-        PMC *pmcval = SELF.pop_pmc();
+        PMC * const pmcval = SELF.pop_pmc();
         return VTABLE_get_integer(INTERP, pmcval);
     }
 
@@ -181,7 +181,7 @@
 */
 
     VTABLE FLOATVAL pop_float() {
-        PMC *pmcval = SELF.pop_pmc();
+        PMC * const pmcval = SELF.pop_pmc();
         return VTABLE_get_number(INTERP, pmcval);
     }
 
@@ -238,7 +238,7 @@
             INTVAL cur = i;
 
             if (cur < 8192)
-                cur = new_size < 2 * cur ? 2 * cur : new_size;
+                cur = (new_size < 2 * cur) ? (2 * cur) : new_size;
             else {
                 cur = new_size + 4096;
                 cur &= ~0xfff;
@@ -268,7 +268,7 @@
 */
 
     VTABLE PMC *clone() {
-        PMC *copy = SUPER();
+        PMC * const copy = SUPER();
         INTVAL size;
         GET_ATTR_size(interp, SELF, size);
         /* copy trimmed extra space */
@@ -311,8 +311,8 @@
 */
 
     VTABLE PMC *shift_pmc() {
-        STRING *strval = SELF.shift_string();
-        PMC    *value  = Parrot_pmc_new(INTERP, enum_class_String);
+        STRING * const strval = SELF.shift_string();
+        PMC    * const value  = Parrot_pmc_new(INTERP, enum_class_String);
 
         VTABLE_set_string_native(INTERP, value, strval);
 
@@ -330,7 +330,7 @@
 */
 
     VTABLE INTVAL shift_integer() {
-        PMC *pmcval = SELF.shift_pmc();
+        PMC * const pmcval = SELF.shift_pmc();
         return VTABLE_get_integer(INTERP, pmcval);
     }
 
@@ -345,7 +345,7 @@
 */
 
     VTABLE FLOATVAL shift_float() {
-        PMC *pmcval = SELF.shift_pmc();
+        PMC * const pmcval = SELF.shift_pmc();
         return VTABLE_get_number(INTERP, pmcval);
     }
 
@@ -362,7 +362,7 @@
 */
 
     VTABLE void push_pmc(PMC *value) {
-        STRING *strvalue = VTABLE_get_string(INTERP, value);
+        STRING * const strvalue = VTABLE_get_string(INTERP, value);
         SELF.push_string(strvalue);
     }
 
@@ -378,7 +378,7 @@
 */
 
     VTABLE void push_integer(INTVAL value) {
-        PMC    *ret = Parrot_pmc_new(INTERP, enum_class_String);
+        PMC    * const ret = Parrot_pmc_new(INTERP, enum_class_String);
         STRING *val;
 
         VTABLE_set_integer_native(INTERP, ret, value);
@@ -398,7 +398,7 @@
 */
 
     VTABLE void push_float(FLOATVAL value) {
-        PMC    *ret = Parrot_pmc_new(INTERP, enum_class_String);
+        PMC    * const ret = Parrot_pmc_new(INTERP, enum_class_String);
         STRING *val;
 
         VTABLE_set_number_native(INTERP, ret, value);
@@ -474,7 +474,7 @@
 */
 
     VTABLE void unshift_pmc(PMC *value) {
-        STRING *strvalue = VTABLE_get_string(INTERP, value);
+        STRING * const strvalue = VTABLE_get_string(INTERP, value);
         SELF.unshift_string(strvalue);
     }
 
@@ -490,7 +490,7 @@
 */
 
     VTABLE void unshift_integer(INTVAL value) {
-        PMC    *ret = Parrot_pmc_new(INTERP, enum_class_String);
+        PMC    * const ret = Parrot_pmc_new(INTERP, enum_class_String);
         STRING *val;
 
         VTABLE_set_integer_native(INTERP, ret, value);
@@ -510,7 +510,7 @@
 */
 
     VTABLE void unshift_float(FLOATVAL value) {
-        PMC    *ret = Parrot_pmc_new(INTERP, enum_class_String);
+        PMC    * const ret = Parrot_pmc_new(INTERP, enum_class_String);
         STRING *val;
 
         VTABLE_set_number_native(INTERP, ret, value);
@@ -552,7 +552,7 @@
 */
 
     VTABLE void delete_keyed(PMC *key) {
-        INTVAL    idx  = VTABLE_get_integer(INTERP, key);
+        const INTVAL idx = VTABLE_get_integer(INTERP, key);
         STRING  **str_array;
         UINTVAL   size, i;
 
@@ -642,12 +642,12 @@
 */
 
     METHOD shift() {
-        PMC *value = SELF.shift_pmc();
+        PMC * const value = SELF.shift_pmc();
         RETURN(PMC *value);
     }
 
     METHOD pop() {
-        PMC *value = SELF.pop_pmc();
+        PMC * const value = SELF.pop_pmc();
         RETURN(PMC *value);
     }
 
@@ -681,13 +681,6 @@
 
 F<docs/pdds/pdd17_basic_types.pod>.
 
-=head1 HISTORY
-
-Initial version                  - Matt Fowles 2004-06-11
-Changed allocator to double size - Matt Fowles 2004-06-15
-Added push_string                - Bernhard Schmalhofer 2004-10-17
-moved available size to int_val2 - Matt Fowles 2005-07-22
-
 =cut
 
 */


More information about the parrot-commits mailing list