[svn:parrot] r44857 - in trunk: src src/pmc t/pmc
tewk at svn.parrot.org
tewk at svn.parrot.org
Wed Mar 10 17:37:58 UTC 2010
Author: tewk
Date: Wed Mar 10 17:37:56 2010
New Revision: 44857
URL: https://trac.parrot.org/parrot/changeset/44857
Log:
VTABLE_init_int commented out tests
Modified:
trunk/src/pmc.c
trunk/src/pmc/fixedbooleanarray.pmc
trunk/src/pmc/fixedfloatarray.pmc
trunk/src/pmc/fixedintegerarray.pmc
trunk/src/pmc/fixedpmcarray.pmc
trunk/src/pmc/fixedstringarray.pmc
trunk/t/pmc/fixedbooleanarray.t
trunk/t/pmc/fixedfloatarray.t
trunk/t/pmc/fixedintegerarray.t
trunk/t/pmc/fixedpmcarray.t
trunk/t/pmc/fixedstringarray.t
Modified: trunk/src/pmc.c
==============================================================================
--- trunk/src/pmc.c Wed Mar 10 17:20:53 2010 (r44856)
+++ trunk/src/pmc.c Wed Mar 10 17:37:56 2010 (r44857)
@@ -581,8 +581,11 @@
ASSERT_ARGS(Parrot_pmc_new_init)
PMC *const classobj = interp->vtables[base_type]->pmc_class;
- if (!PMC_IS_NULL(classobj) && PObj_is_class_TEST(classobj))
- return VTABLE_instantiate(interp, classobj, init);
+ if (!PMC_IS_NULL(classobj) && PObj_is_class_TEST(classobj)) {
+ PMC *initial = Parrot_pmc_new(interp, Parrot_get_ctx_HLL_type(interp, enum_class_Integer));
+ VTABLE_set_integer_native(interp, initial, init);
+ VTABLE_instantiate(interp, classobj, initial);
+ }
else {
PMC * const pmc = get_new_pmc_header(interp, base_type, 0);
VTABLE_init_int(interp, pmc, init);
Modified: trunk/src/pmc/fixedbooleanarray.pmc
==============================================================================
--- trunk/src/pmc/fixedbooleanarray.pmc Wed Mar 10 17:20:53 2010 (r44856)
+++ trunk/src/pmc/fixedbooleanarray.pmc Wed Mar 10 17:37:56 2010 (r44857)
@@ -62,6 +62,26 @@
/*
+=item C<void init_int(INTVAL size)>
+
+Initializes the array.
+
+=cut
+
+*/
+
+ VTABLE void init_int(INTVAL size) {
+ const size_t size_in_bytes = get_size_in_bytes(size);
+
+ SET_ATTR_size(INTERP, SELF, size);
+ SET_ATTR_resize_threshold(INTERP, SELF, size_in_bytes * BITS_PER_CHAR);
+ SET_ATTR_bit_array(INTERP, SELF, mem_gc_allocate_n_zeroed_typed(INTERP, size_in_bytes, unsigned char));
+ PObj_custom_destroy_SET(SELF);
+ }
+
+
+/*
+
=item C<void destroy()>
Destroys the array.
Modified: trunk/src/pmc/fixedfloatarray.pmc
==============================================================================
--- trunk/src/pmc/fixedfloatarray.pmc Wed Mar 10 17:20:53 2010 (r44856)
+++ trunk/src/pmc/fixedfloatarray.pmc Wed Mar 10 17:37:56 2010 (r44857)
@@ -48,6 +48,22 @@
/*
+=item C<void init_int(INTVAL size)>
+
+Initializes the array.
+
+=cut
+
+*/
+
+ VTABLE void init_int(INTVAL new_size) {
+ SET_ATTR_size(INTERP, SELF, new_size);
+ SET_ATTR_float_array(INTERP, SELF, mem_gc_allocate_n_typed(INTERP, new_size, FLOATVAL));
+ PObj_custom_destroy_SET(SELF);
+ }
+
+/*
+
=item C<PMC *clone()>
Creates and returns a copy of the array.
Modified: trunk/src/pmc/fixedintegerarray.pmc
==============================================================================
--- trunk/src/pmc/fixedintegerarray.pmc Wed Mar 10 17:20:53 2010 (r44856)
+++ trunk/src/pmc/fixedintegerarray.pmc Wed Mar 10 17:37:56 2010 (r44857)
@@ -45,6 +45,22 @@
/*
+=item C<void init_int(INTVAL size)>
+
+Initializes the array.
+
+=cut
+
+*/
+
+ VTABLE void init_int(INTVAL size) {
+ SET_ATTR_size(INTERP, SELF, size);
+ SET_ATTR_int_array(INTERP, SELF, mem_gc_allocate_n_typed(INTERP, size, INTVAL));
+ PObj_custom_destroy_SET(SELF);
+ }
+
+/*
+
=item C<void destroy()>
Destroys the array.
Modified: trunk/src/pmc/fixedpmcarray.pmc
==============================================================================
--- trunk/src/pmc/fixedpmcarray.pmc Wed Mar 10 17:20:53 2010 (r44856)
+++ trunk/src/pmc/fixedpmcarray.pmc Wed Mar 10 17:37:56 2010 (r44857)
@@ -78,6 +78,33 @@
/*
+=item C<void init_int(INTVAL size)>
+
+Initializes the array.
+
+=cut
+
+*/
+
+ VTABLE void init_int(INTVAL size) {
+ PMC **data;
+ int i;
+
+ if (size < 0)
+ Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
+ _("FixedPMCArray: Cannot set array size to a negative number"));
+
+ SET_ATTR_size(INTERP, SELF, size);
+ data = mem_gc_allocate_n_typed(INTERP, size, PMC *);
+
+ for (i = 0; i < size; i++)
+ data[i] = PMCNULL;
+
+ PObj_custom_destroy_SET(SELF);
+ }
+
+/*
+
=item C<void destroy()>
Destroys the array.
Modified: trunk/src/pmc/fixedstringarray.pmc
==============================================================================
--- trunk/src/pmc/fixedstringarray.pmc Wed Mar 10 17:20:53 2010 (r44856)
+++ trunk/src/pmc/fixedstringarray.pmc Wed Mar 10 17:37:56 2010 (r44857)
@@ -45,6 +45,23 @@
/*
+=item C<void init_int(INTVAL size)>
+
+Initializes the array.
+
+=cut
+
+*/
+
+ VTABLE void init_int(INTVAL size) {
+ SET_ATTR_size(INTERP, SELF, size);
+ SET_ATTR_str_array(INTERP, SELF, mem_gc_allocate_n_zeroed_typed(INTERP, size, STRING*));
+ PObj_custom_mark_destroy_SETALL(SELF);
+ }
+
+
+/*
+
=item C<void destroy()>
Destroys the array.
Modified: trunk/t/pmc/fixedbooleanarray.t
==============================================================================
--- trunk/t/pmc/fixedbooleanarray.t Wed Mar 10 17:20:53 2010 (r44856)
+++ trunk/t/pmc/fixedbooleanarray.t Wed Mar 10 17:37:56 2010 (r44857)
@@ -39,6 +39,7 @@
'clone'()
get_iter()
fill()
+# 'test_new_style_init'()
.end
.sub 'setting_array_size'
@@ -332,6 +333,12 @@
.end
+.sub 'test_new_style_init'
+ $P0 = new ['FixedBooleanArray'], 10
+
+ $I0 = $P0
+ is($I0, 10, "New style init creates the correct # of elements")
+.end
# Local Variables:
# mode: pir
Modified: trunk/t/pmc/fixedfloatarray.t
==============================================================================
--- trunk/t/pmc/fixedfloatarray.t Wed Mar 10 17:20:53 2010 (r44856)
+++ trunk/t/pmc/fixedfloatarray.t Wed Mar 10 17:37:56 2010 (r44857)
@@ -30,6 +30,7 @@
what_is_truth()
interface_check()
get_iter_test()
+# 'test_new_style_init'()
.end
.sub array_size_tests
@@ -245,6 +246,12 @@
is($S0, "1.1,99.99,-345.001,", "get_iter works")
.end
+.sub 'test_new_style_init'
+ $P0 = new ['FixedFloatArray'], 10
+
+ $I0 = $P0
+ is($I0, 10, "New style init creates the correct # of elements")
+.end
# Local Variables:
# mode: pir
Modified: trunk/t/pmc/fixedintegerarray.t
==============================================================================
--- trunk/t/pmc/fixedintegerarray.t Wed Mar 10 17:20:53 2010 (r44856)
+++ trunk/t/pmc/fixedintegerarray.t Wed Mar 10 17:37:56 2010 (r44857)
@@ -31,6 +31,7 @@
'test_interface_done'() # 4 tests
'test_get_iter'() # 1 test
'test_equality'() # 5 tests
+# 'test_new_style_init'() # 1 test
.end
.sub 'test_set_size'
@@ -235,6 +236,12 @@
is(a1, a2, "Equal when second element same")
.end
+.sub 'test_new_style_init'
+ $P0 = new ['FixedIntegerArray'], 10
+
+ $I0 = $P0
+ is($I0, 10, "New style init creates the correct # of elements")
+.end
# Local Variables:
# mode: pir
Modified: trunk/t/pmc/fixedpmcarray.t
==============================================================================
--- trunk/t/pmc/fixedpmcarray.t Wed Mar 10 17:20:53 2010 (r44856)
+++ trunk/t/pmc/fixedpmcarray.t Wed Mar 10 17:37:56 2010 (r44857)
@@ -46,6 +46,7 @@
test_splice()
test_sort()
test_exists()
+# 'test_new_style_init'()
.end
.sub test_exists
@@ -666,6 +667,13 @@
is($I0,1,'size of FixedPMCArray is 1')
.end
+.sub 'test_new_style_init'
+ $P0 = new ['FixedPMCArray'], 10
+
+ $I0 = $P0
+ is($I0, 10, "New style init creates the correct # of elements")
+.end
+
# Local Variables:
# mode: pir
# fill-column: 100
Modified: trunk/t/pmc/fixedstringarray.t
==============================================================================
--- trunk/t/pmc/fixedstringarray.t Wed Mar 10 17:20:53 2010 (r44856)
+++ trunk/t/pmc/fixedstringarray.t Wed Mar 10 17:37:56 2010 (r44857)
@@ -38,6 +38,7 @@
'test_equality'() # 5 tests
'test_gc'() # 4 tests
'test_number'() # 2 tests
+# 'test_new_style_init'() # 1 test
.end
.sub 'test_set_size'
@@ -376,6 +377,12 @@
is($N0, 3.0, "get_number returns correct size")
.end
+.sub 'test_new_style_init'
+ $P0 = new ['FixedStringArray'], 10
+
+ $I0 = $P0
+ is($I0, 10, "New style init creates the correct # of elements")
+.end
# Local Variables:
# mode: pir
More information about the parrot-commits
mailing list