Permalink
Browse files

some cleaning of FIA: put METHOD after vtable functions and fix and i…

…mprove doc, no functional changes

git-svn-id: https://svn.parrot.org/parrot/trunk@48430 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 8081f04 commit ac9988d85d5088f62c269a29bfee8b558307f0db @NotFound NotFound committed Aug 12, 2010
Showing with 61 additions and 43 deletions.
  1. +61 −43 src/pmc/fixedintegerarray.pmc
@@ -11,10 +11,6 @@ src/pmc/fixedintegerarray.pmc - fixed size array for integers only
This class, FixedIntegerArray, implements an array of fixed size which stores
INTVALs. It uses Integer PMCs for all of the conversions.
-=head2 Functions
-
-=over 4
-
=cut
*/
@@ -34,33 +30,14 @@ static int auxcmpfunc(ARGIN(const INTVAL *i), ARGIN(const INTVAL *j))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
-/*
-
-=item C<static int auxcmpfunc(const INTVAL *i, const INTVAL *j)>
-
-
-
-=cut
-
-*/
-
-PARROT_PURE_FUNCTION
-static int
-auxcmpfunc(ARGIN(const INTVAL *i), ARGIN(const INTVAL *j))
-{
- ASSERT_ARGS(auxcmpfunc)
- return *i - *j;
-}
pmclass FixedIntegerArray auto_attrs provides array {
ATTR INTVAL size; /* number of INTVALs stored in this array */
ATTR INTVAL * int_array; /* INTVALs are stored here */
/*
-=back
-
-=head2 Methods
+=head2 Vtable functions
=over 4
@@ -521,25 +498,6 @@ Sets the string value of the element at index C<key> to C<value>.
SELF.set_pmc_keyed_int(k, value);
}
- METHOD sort(PMC *cmp_func :optional) {
- UINTVAL n;
- INTVAL size;
-
- GET_ATTR_size(INTERP, SELF, size);
- n = (UINTVAL)size;
-
- if (n > 1) {
- INTVAL *int_array;
- GET_ATTR_int_array(INTERP, SELF, int_array);
- if (PMC_IS_NULL(cmp_func))
- qsort(int_array, n, sizeof (INTVAL),
- (int (*)(const void *, const void*))auxcmpfunc);
- else
- Parrot_quicksort(INTERP, (void**)int_array, n, cmp_func);
- }
- RETURN(PMC *SELF);
- }
-
/*
=item C<INTVAL is_equal(PMC *value)>
@@ -643,6 +601,66 @@ Used to unarchive the array.
int_array[i] = VTABLE_shift_integer(INTERP, info);
}
}
+
+/*
+
+=back
+
+=head2 Methods
+
+=over 4
+
+=item C<PMC *sort()>
+
+Sort the array and return self.
+
+=cut
+
+*/
+
+ METHOD sort(PMC *cmp_func :optional) {
+ UINTVAL n;
+ INTVAL size;
+
+ GET_ATTR_size(INTERP, SELF, size);
+ n = (UINTVAL)size;
+
+ if (n > 1) {
+ INTVAL *int_array;
+ GET_ATTR_int_array(INTERP, SELF, int_array);
+ if (PMC_IS_NULL(cmp_func))
+ qsort(int_array, n, sizeof (INTVAL),
+ (int (*)(const void *, const void*))auxcmpfunc);
+ else
+ Parrot_quicksort(INTERP, (void**)int_array, n, cmp_func);
+ }
+ RETURN(PMC *SELF);
+ }
+
+}
+
+/*
+
+=back
+
+=head2 Auxiliar functions
+
+=over 4
+
+=item C<static int auxcmpfunc(const INTVAL *i, const INTVAL *j)>
+
+INTVAL compare function for qsort usage.
+
+=cut
+
+*/
+
+PARROT_PURE_FUNCTION
+static int
+auxcmpfunc(ARGIN(const INTVAL *i), ARGIN(const INTVAL *j))
+{
+ ASSERT_ARGS(auxcmpfunc)
+ return *i - *j;
}
/*

0 comments on commit ac9988d

Please sign in to comment.