Permalink
Browse files

VTABLE_init_int commented out tests

git-svn-id: https://svn.parrot.org/parrot/trunk@44857 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 83ba844 commit 714df2a3a6156761648a0419102d77227304ad85 @tewk tewk committed Mar 10, 2010
View
@@ -581,8 +581,11 @@ Parrot_pmc_new_init_int(PARROT_INTERP, INTVAL base_type, INTVAL init)
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);
@@ -62,6 +62,26 @@ Initializes the array.
/*
+=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.
@@ -48,6 +48,22 @@ Destroys the array.
/*
+=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.
@@ -45,6 +45,22 @@ Initializes the array.
/*
+=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.
View
@@ -78,6 +78,33 @@ Initializes the array.
/*
+=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.
@@ -45,6 +45,23 @@ Initializes the array.
/*
+=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.
@@ -39,6 +39,7 @@ out-of-bounds test. Checks INT and PMC keys.
'clone'()
get_iter()
fill()
+# 'test_new_style_init'()
.end
.sub 'setting_array_size'
@@ -332,6 +333,12 @@ out-of-bounds test. Checks INT and PMC keys.
.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
View
@@ -30,6 +30,7 @@ out-of-bounds test. Checks INT and PMC keys.
what_is_truth()
interface_check()
get_iter_test()
+# 'test_new_style_init'()
.end
.sub array_size_tests
@@ -245,6 +246,12 @@ loop:
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
@@ -31,6 +31,7 @@ out-of-bounds test. Checks INT and PMC keys.
'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 @@ out-of-bounds test. Checks INT and PMC keys.
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
View
@@ -46,6 +46,7 @@ out-of-bounds test. Checks INT and PMC keys.
test_splice()
test_sort()
test_exists()
+# 'test_new_style_init'()
.end
.sub test_exists
@@ -666,6 +667,13 @@ CODE
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
View
@@ -38,6 +38,7 @@ out-of-bounds test. Checks INT and PMC keys.
'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 @@ out-of-bounds test. Checks INT and PMC keys.
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

0 comments on commit 714df2a

Please sign in to comment.