Author: petdance
Date: Tue Jun 5 08:13:36 2007
New Revision: 18821
Modified:
trunk/config/gen/makefiles/root.in
trunk/include/parrot/mmd.h
trunk/include/parrot/objects.h
trunk/src/mmd.c
trunk/src/objects.c
trunk/tools/build/headerize.pl
Log:
mmd.c and some of objects.c now have their headers automatically headerized.
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in (original)
+++ trunk/config/gen/makefiles/root.in Tue Jun 5 08:13:36 2007
@@ -1830,6 +1830,8 @@
src/pic.o \
src/stacks.o \
src/stack_common.o \
+ src/mmd.o \
+ src/objects.o
###############################################################################
#
Modified: trunk/include/parrot/mmd.h
==============================================================================
--- trunk/include/parrot/mmd.h (original)
+++ trunk/include/parrot/mmd.h Tue Jun 5 08:13:36 2007
@@ -3,7 +3,7 @@
* SVN Info
* $Id$
* Overview:
- * This is the api header for the mmd subsystem
+ * This is the API header for the mmd subsystem
* Data Structure and Algorithms:
* History:
* Notes:
@@ -13,20 +13,9 @@
#ifndef PARROT_MMD_H_GUARD
#define PARROT_MMD_H_GUARD
-/* inplace */
-PARROT_API void mmd_dispatch_v_pp(Parrot_Interp, PMC *, PMC *, INTVAL);
-PARROT_API void mmd_dispatch_v_pi(Parrot_Interp, PMC *, INTVAL, INTVAL);
-PARROT_API void mmd_dispatch_v_pn(Parrot_Interp, PMC *, FLOATVAL, INTVAL);
-PARROT_API void mmd_dispatch_v_ps(Parrot_Interp, PMC *, STRING *, INTVAL);
-
-/* return result */
-PARROT_API PMC* mmd_dispatch_p_ppp(Parrot_Interp, PMC *, PMC *, PMC *, INTVAL);
-PARROT_API PMC* mmd_dispatch_p_pip(Parrot_Interp, PMC *, INTVAL, PMC *,
INTVAL);
-PARROT_API PMC* mmd_dispatch_p_pnp(Parrot_Interp, PMC *, FLOATVAL, PMC *,
INTVAL);
-PARROT_API PMC* mmd_dispatch_p_psp(Parrot_Interp, PMC *, STRING *, PMC *,
INTVAL);
-
-/* compare */
-PARROT_API INTVAL mmd_dispatch_i_pp(Parrot_Interp, PMC *, PMC *, INTVAL);
+#include "parrot/config.h"
+#include "parrot/compiler.h"
+#include "parrot/parrot.h"
/* function typedefs */
typedef PMC* (*mmd_f_p_ppp)(Interp *, PMC *, PMC *, PMC *);
@@ -41,26 +30,12 @@
typedef INTVAL (*mmd_f_i_pp) (Interp *, PMC *, PMC *);
-PARROT_API void mmd_add_by_class(Parrot_Interp, INTVAL, STRING *, STRING *,
funcptr_t);
-PARROT_API void mmd_register(Parrot_Interp, INTVAL, INTVAL, INTVAL, funcptr_t);
-PARROT_API void mmd_register_sub(Parrot_Interp, INTVAL, INTVAL, INTVAL, PMC*);
-PARROT_API void mmd_add_function(Parrot_Interp, INTVAL, funcptr_t);
-PARROT_API void mmd_add_function_sub(Parrot_Interp, INTVAL, PMC*);
-PARROT_API void mmd_destroy(Parrot_Interp);
-PARROT_API PMC *mmd_vtfind(Parrot_Interp, INTVAL, INTVAL, INTVAL);
-
typedef struct _MMD_init {
INTVAL func_nr;
INTVAL left, right;
funcptr_t func_ptr;
} MMD_init;
-PARROT_API void Parrot_mmd_register_table(Interp*, INTVAL, const MMD_init *,
INTVAL);
-PARROT_API void Parrot_mmd_rebuild_table(Interp*, INTVAL class_enum, INTVAL
func_nr);
-
-PARROT_API funcptr_t get_mmd_dispatch_type(Interp *interp,
- INTVAL function, INTVAL left_type, INTVAL right_type, int *is_pmc);
-
typedef struct _MMD_table {
funcptr_t *mmd_funcs; /* The functions for the MMD table */
UINTVAL x; /* The x coord for each table */
@@ -68,15 +43,123 @@
} MMD_table;
-PARROT_API PMC *Parrot_mmd_sort_candidate_list(Interp *, PMC *candidates);
-PARROT_API PMC *Parrot_MMD_search_default_infix(Interp *, STRING *meth,
- INTVAL left_type, INTVAL right_type);
+/* HEADERIZER BEGIN: src/mmd.c */
+
+PARROT_API PMC * Parrot_MMD_search_default_infix( Interp *interp,
+ STRING *meth,
+ INTVAL left_type,
+ INTVAL right_type );
+
+PARROT_API void Parrot_mmd_rebuild_table( Interp* interp,
+ INTVAL type,
+ INTVAL func_nr );
+
+PARROT_API void Parrot_mmd_register_table( Interp* interp,
+ INTVAL type,
+ const MMD_init *mmd_table,
+ INTVAL n );
+
+PARROT_API PMC * Parrot_mmd_sort_candidate_list( Interp *interp,
+ PMC *candidates );
+
+PARROT_API funcptr_t get_mmd_dispatch_type( Interp *interp,
+ INTVAL func_nr,
+ INTVAL left_type,
+ INTVAL right_type,
+ int *is_pmc /*NN*/ )
+ __attribute__nonnull__(5);
+
+PARROT_API void mmd_add_by_class( Interp *interp,
+ INTVAL functype,
+ STRING *left_class,
+ STRING *right_class,
+ funcptr_t funcptr );
+
+PARROT_API void mmd_add_function( Interp *interp,
+ INTVAL func_nr,
+ funcptr_t function );
+
+PARROT_API void mmd_destroy( Parrot_Interp interp );
+PARROT_API INTVAL mmd_dispatch_i_pp( Interp *interp,
+ PMC *left /*NN*/,
+ PMC *right /*NN*/,
+ INTVAL func_nr )
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
+
+PARROT_API PMC* mmd_dispatch_p_pip( Interp *interp,
+ PMC *left,
+ INTVAL right,
+ PMC *dest,
+ INTVAL func_nr );
+
+PARROT_API PMC* mmd_dispatch_p_pnp( Interp *interp,
+ PMC *left,
+ FLOATVAL right,
+ PMC *dest,
+ INTVAL func_nr );
+
+PARROT_API PMC* mmd_dispatch_p_ppp( Interp *interp,
+ PMC *left,
+ PMC *right,
+ PMC *dest,
+ INTVAL func_nr );
+
+PARROT_API PMC* mmd_dispatch_p_psp( Interp *interp,
+ PMC *left,
+ STRING *right,
+ PMC *dest,
+ INTVAL func_nr );
+
+PARROT_API void mmd_dispatch_v_pi( Interp *interp,
+ PMC *left,
+ INTVAL right,
+ INTVAL func_nr );
+
+PARROT_API void mmd_dispatch_v_pn( Interp *interp,
+ PMC *left /*NN*/,
+ FLOATVAL right,
+ INTVAL func_nr )
+ __attribute__nonnull__(2);
+
+PARROT_API void mmd_dispatch_v_pp( Interp *interp,
+ PMC *left /*NN*/,
+ PMC *right /*NN*/,
+ INTVAL func_nr )
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
+
+PARROT_API void mmd_dispatch_v_ps( Interp *interp,
+ PMC *left /*NN*/,
+ STRING *right,
+ INTVAL func_nr )
+ __attribute__nonnull__(2);
+
+PARROT_API void mmd_register( Interp *interp,
+ INTVAL func_nr,
+ INTVAL left_type,
+ INTVAL right_type,
+ funcptr_t funcptr );
+
+PARROT_API void mmd_register_sub( Interp *interp,
+ INTVAL func_nr,
+ INTVAL left_type,
+ INTVAL right_type,
+ PMC *sub );
+
+PARROT_API PMC * mmd_vtfind(
+ Parrot_Interp interp,
+ INTVAL func_nr,
+ INTVAL left,
+ INTVAL right );
+
+/* HEADERIZER END: src/mmd.c */
/*
* in src/objects.c :
*/
PARROT_API const char* Parrot_MMD_method_name(Interp* i, INTVAL idx);
-PARROT_API INTVAL Parrot_MMD_method_idx(Interp *interp, char *name);
+PARROT_API INTVAL Parrot_MMD_method_idx(Interp *interp, const char *name);
#endif /* PARROT_MMD_H_GUARD */
Modified: trunk/include/parrot/objects.h
==============================================================================
--- trunk/include/parrot/objects.h (original)
+++ trunk/include/parrot/objects.h Tue Jun 5 08:13:36 2007
@@ -28,37 +28,125 @@
PCD_MAX
} PARROT_CLASS_DATA_ENUM;
-PARROT_API PMC *Parrot_single_subclass(Parrot_Interp, PMC *, PMC *);
-PARROT_API void Parrot_new_class(Parrot_Interp, PMC *, PMC *);
-PARROT_API PMC *Parrot_class_lookup(Parrot_Interp, STRING *);
-PARROT_API PMC *Parrot_class_lookup_p(Parrot_Interp, PMC *);
-PARROT_API void Parrot_add_parent(Parrot_Interp, PMC *, PMC *);
-PARROT_API PMC *Parrot_remove_parent(Parrot_Interp, PMC *, PMC *);
-PARROT_API PMC *Parrot_multi_subclass(Parrot_Interp, PMC *, STRING *);
-PARROT_API void Parrot_instantiate_object(Parrot_Interp, PMC *);
-PARROT_API void Parrot_instantiate_object_init(Parrot_Interp, PMC *, PMC *);
-PARROT_API INTVAL Parrot_object_isa(Parrot_Interp interp, PMC *, PMC *);
-PARROT_API PMC *Parrot_new_method_cache(Parrot_Interp);
-PARROT_API PMC *Parrot_find_method_with_cache(Parrot_Interp, PMC *, STRING *);
-PARROT_API PMC *Parrot_find_method_direct(Parrot_Interp, PMC *, STRING *);
-PARROT_API INTVAL Parrot_add_attribute(Parrot_Interp, PMC*, STRING*);
-PARROT_API void Parrot_note_method_offset(Parrot_Interp, UINTVAL, PMC *);
-PARROT_API PMC *Parrot_get_attrib_by_num(Parrot_Interp, PMC *, INTVAL);
-PARROT_API void Parrot_set_attrib_by_num(Parrot_Interp, PMC *, INTVAL, PMC *);
-PARROT_API PMC *Parrot_get_attrib_by_str(Parrot_Interp, PMC *, STRING*);
-PARROT_API void Parrot_set_attrib_by_str(Parrot_Interp, PMC *, STRING*, PMC *);
-PARROT_API INTVAL Parrot_get_attrib_num(Parrot_Interp, PMC *, STRING *);
-PARROT_API INTVAL Parrot_class_offset(Parrot_Interp, PMC *, STRING *);
-PARROT_API PMC *Parrot_find_class_constructor(Parrot_Interp, STRING *, INTVAL);
-PARROT_API PMC *Parrot_find_class_destructor(Parrot_Interp, STRING *, INTVAL);
-PARROT_API PMC *Parrot_find_class_fallback(Parrot_Interp, STRING *, INTVAL);
-PARROT_API void Parrot_set_class_constructor(Parrot_Interp, STRING *, INTVAL,
STRING *);
-PARROT_API void Parrot_set_class_destructor(Parrot_Interp, STRING *, INTVAL,
STRING *);
-PARROT_API void Parrot_set_class_fallback(Parrot_Interp, STRING *, INTVAL,
STRING *);
-PARROT_API void Parrot_invalidate_method_cache(Interp*, STRING *_class, STRING
*meth);
-PARROT_API STRING *readable_name(Parrot_Interp, PMC *);
-PARROT_API INTVAL Parrot_get_vtable_index(Interp *, const STRING *name);
-PARROT_API PMC *Parrot_find_vtable_meth(Interp* interp, PMC *pmc, STRING
*meth);
+/* HEADERIZER BEGIN: src/objects.c */
+
+void Parrot_ComposeRole( Interp *interp,
+ PMC *role,
+ PMC *exclude,
+ int got_exclude,
+ PMC *alias,
+ int got_alias,
+ PMC *methods_hash,
+ PMC *roles_list );
+
+PMC* Parrot_ComputeMRO_C3( Interp *interp, PMC *_class );
+PARROT_API INTVAL Parrot_MMD_method_idx( Interp *interp, const char *name );
+PARROT_API const char* Parrot_MMD_method_name( Interp *interp, INTVAL idx );
+PARROT_API INTVAL Parrot_add_attribute( Interp *interp,
+ PMC* _class,
+ STRING* attr );
+
+PARROT_API void Parrot_add_parent( Interp *interp, PMC *_class, PMC *parent );
+PARROT_API PMC * Parrot_class_lookup( Interp *interp, STRING *class_name );
+PMC * Parrot_class_lookup_p( Interp *interp, PMC *class_name );
+PARROT_API INTVAL Parrot_class_offset( Interp *interp,
+ PMC *object,
+ STRING *_class );
+
+PARROT_API PMC * Parrot_find_class_constructor( Interp *interp,
+ STRING *_class,
+ INTVAL classtoken );
+
+PARROT_API PMC * Parrot_find_class_destructor( Interp *interp,
+ STRING *_class,
+ INTVAL classtoken );
+
+PARROT_API PMC * Parrot_find_class_fallback( Interp *interp,
+ STRING *_class,
+ INTVAL classtoken );
+
+PARROT_API PMC * Parrot_find_method_direct( Interp *interp,
+ PMC *_class,
+ STRING *method_name );
+
+PARROT_API PMC * Parrot_find_method_with_cache( Interp *interp,
+ PMC *_class,
+ STRING *method_name /*NN*/ )
+ __attribute__nonnull__(3);
+
+PARROT_API PMC* Parrot_find_vtable_meth( Interp *interp,
+ PMC *pmc,
+ STRING *meth );
+
+PARROT_API PMC * Parrot_get_attrib_by_num( Interp *interp,
+ PMC *object,
+ INTVAL attrib );
+
+PARROT_API PMC * Parrot_get_attrib_by_str( Interp *interp,
+ PMC *object,
+ STRING *attr );
+
+PARROT_API INTVAL Parrot_get_vtable_index( Interp *interp,
+ const STRING *name /*NN*/ )
+ __attribute__nonnull__(2);
+
+PARROT_API void Parrot_instantiate_object( Interp *interp, PMC *object );
+PARROT_API void Parrot_instantiate_object_init( Interp *interp,
+ PMC *object,
+ PMC *init );
+
+PARROT_API void Parrot_invalidate_method_cache( Interp *interp,
+ STRING *_class,
+ STRING *meth );
+
+PARROT_API PMC * Parrot_multi_subclass( Interp *interp,
+ PMC *base_class_array,
+ STRING *child_class_name );
+
+PARROT_API void Parrot_new_class( Interp *interp, PMC *_class, PMC *name );
+PARROT_API PMC * Parrot_new_method_cache( Interp *interp );
+PARROT_API void Parrot_note_method_offset( Interp *interp,
+ UINTVAL offset,
+ PMC *method );
+
+PARROT_API INTVAL Parrot_object_isa( Interp *interp, PMC *pmc, PMC *_class );
+PARROT_API PMC * Parrot_remove_parent( Interp *interp,
+ PMC *removed_class,
+ PMC *existing_class );
+
+PARROT_API void Parrot_set_attrib_by_num( Interp *interp,
+ PMC *object,
+ INTVAL attrib,
+ PMC *value );
+
+PARROT_API void Parrot_set_attrib_by_str( Interp *interp,
+ PMC *object,
+ STRING *attr,
+ PMC *value );
+
+PARROT_API void Parrot_set_class_constructor( Interp *interp,
+ STRING *_class,
+ INTVAL classtoken,
+ STRING *method );
+
+PARROT_API void Parrot_set_class_destructor( Interp *interp,
+ STRING *_class,
+ INTVAL classtoken,
+ STRING *method );
+
+PARROT_API void Parrot_set_class_fallback( Interp *interp,
+ STRING *_class,
+ INTVAL classtoken,
+ STRING *method );
+
+PARROT_API PMC * Parrot_single_subclass( Interp *interp,
+ PMC *base_class,
+ PMC *name );
+
+void destroy_object_cache( Interp *interp );
+void mark_object_cache( Interp *interp );
+PARROT_API STRING* readable_name( Interp *interp, PMC *name );
+/* HEADERIZER END: src/objects.c */
/* Objects, classes and PMCarrays all use the same data scheme:
* PMC_data() holds a malloced array, PMC_int_val() is the size of it
Modified: trunk/src/mmd.c
==============================================================================
--- trunk/src/mmd.c (original)
+++ trunk/src/mmd.c Tue Jun 5 08:13:36 2007
@@ -40,11 +40,15 @@
*/
+#include "parrot/compiler.h"
#include "parrot/parrot.h"
+#include "parrot/mmd.h"
#include "parrot/oplib/ops.h"
#include "mmd.str"
#include <assert.h>
+/* HEADER: include/parrot/mmd.h */
+
#define MMD_DEBUG 0
static void mmd_create_builtin_multi_meth_2(Interp *, PMC *ns,
@@ -92,14 +96,14 @@
}
#endif
-
+PARROT_API
funcptr_t
get_mmd_dispatch_type(Interp *interp, INTVAL func_nr, INTVAL left_type,
- INTVAL right_type, int *is_pmc /*NN*/)
+ INTVAL right_type, int * const is_pmc /*NN*/ )
{
funcptr_t func, func_;
INTVAL r;
- MMD_table *table = interp->binop_mmd_funcs + func_nr;
+ MMD_table * const table = interp->binop_mmd_funcs + func_nr;
const UINTVAL x_funcs = table->x;
const UINTVAL y_funcs = table->y;
@@ -159,8 +163,12 @@
static funcptr_t
-get_mmd_dispatcher(Interp *interp, PMC *left, PMC * right,
- INTVAL function, int *is_pmc)
+get_mmd_dispatcher(Interp *interp, PMC *left, PMC *right,
+ INTVAL function, int *is_pmc /*NN*/)
+ __attribute__nonnull__(5);
+static funcptr_t
+get_mmd_dispatcher(Interp *interp, PMC *left, PMC *right,
+ INTVAL function, int *is_pmc /*NN*/)
{
const UINTVAL left_type = VTABLE_type(interp, left);
const UINTVAL right_type = VTABLE_type(interp, right);
@@ -170,18 +178,17 @@
/*
-=item C<static PMC*
-mmd_deref(Interp *interp, INTVAL function, PMC *value)>
-
+FUNCDOC:
If C<value> is a reference-like PMC, dereference it so we can make an MMD
call on the 'real' value.
-=cut
-
*/
static PMC *
-mmd_deref(Interp *interp, INTVAL function, PMC *value)
+mmd_deref(Interp *interp, INTVAL function, PMC *value /*NN*/)
+ __attribute__nonnull__(3);
+static PMC *
+mmd_deref(Interp *interp, INTVAL function, PMC *value /*NN*/)
{
if (VTABLE_type(interp, value) != value->vtable->base_type)
return VTABLE_get_pmc(interp, value);
@@ -191,17 +198,13 @@
/*
-=item C<static void
-mmd_ensure_writable(Interp *, INTVAL function, PMC *pmc)>
-
+FUNCDOC:
Make sure C<pmc> is writable enough for C<function>.
-=cut
-
*/
static void
-mmd_ensure_writable(Interp *interp, INTVAL function, PMC *pmc) {
+mmd_ensure_writable(Interp *interp, INTVAL function, PMC *pmc /*NULLOK*/) {
if (!PMC_IS_NULL(pmc) && (pmc->vtable->flags & VTABLE_IS_READONLY_FLAG))
real_exception(interp, 0, 1, "%s applied to read-only argument",
Parrot_MMD_method_name(interp, function));
@@ -260,6 +263,7 @@
*/
+PARROT_API
PMC*
mmd_dispatch_p_ppp(Interp *interp,
PMC *left, PMC *right, PMC *dest, INTVAL func_nr)
@@ -287,6 +291,7 @@
}
}
+PARROT_API
PMC*
mmd_dispatch_p_pip(Interp *interp,
PMC *left, INTVAL right, PMC *dest, INTVAL func_nr)
@@ -319,6 +324,7 @@
}
}
+PARROT_API
PMC*
mmd_dispatch_p_pnp(Interp *interp,
PMC *left, FLOATVAL right, PMC *dest, INTVAL func_nr)
@@ -346,15 +352,15 @@
}
}
+PARROT_API
PMC*
mmd_dispatch_p_psp(Interp *interp,
PMC *left, STRING *right, PMC *dest, INTVAL func_nr)
{
mmd_f_p_psp real_function;
int is_pmc;
- UINTVAL left_type;
+ const UINTVAL left_type = left->vtable->base_type;
- left_type = left->vtable->base_type;
real_function = (mmd_f_p_psp)get_mmd_dispatch_type(interp,
func_nr, left_type, enum_type_STRING, &is_pmc);
if (is_pmc) {
@@ -374,14 +380,14 @@
/*
* inplace variants
*/
+PARROT_API
void
mmd_dispatch_v_pp(Interp *interp,
- PMC *left, PMC *right, INTVAL func_nr)
+ PMC *left /*NN*/, PMC *right /*NN*/, INTVAL func_nr)
{
mmd_f_v_pp real_function;
int is_pmc;
-
left = mmd_deref(interp, func_nr, left);
right = mmd_deref(interp, func_nr, right);
@@ -399,6 +405,7 @@
}
}
+PARROT_API
void
mmd_dispatch_v_pi(Interp *interp,
PMC *left, INTVAL right, INTVAL func_nr)
@@ -422,9 +429,10 @@
}
}
+PARROT_API
void
mmd_dispatch_v_pn(Interp *interp,
- PMC *left, FLOATVAL right, INTVAL func_nr)
+ PMC *left /*NN*/, FLOATVAL right, INTVAL func_nr)
{
mmd_f_v_pn real_function;
int is_pmc;
@@ -445,9 +453,10 @@
}
}
+PARROT_API
void
mmd_dispatch_v_ps(Interp *interp,
- PMC *left, STRING *right, INTVAL func_nr)
+ PMC *left /*NN*/, STRING *right, INTVAL func_nr)
{
mmd_f_v_ps real_function;
int is_pmc;
@@ -470,20 +479,16 @@
/*
-=item C<INTVAL
-mmd_dispatch_i_pp(Interp *interp,
- PMC *left, PMC *right, INTVAL func_nr)>
-
+FUNCDOC:
Like C<mmd_dispatch_p_ppp()>, only it returns an C<INTVAL>. This is used
by MMD compare functions.
-=cut
-
*/
+PARROT_API
INTVAL
mmd_dispatch_i_pp(Interp *interp,
- PMC *left, PMC *right, INTVAL func_nr)
+ PMC *left /*NN*/, PMC *right /*NN*/, INTVAL func_nr)
{
mmd_f_i_pp real_function;
int is_pmc;
@@ -508,19 +513,15 @@
/*
-=item C<void
-mmd_add_function(Interp *interp,
- INTVAL funcnum, funcptr_t function)>
-
+FUNCDOC:
Add a new binary MMD function to the list of functions the MMD system knows
of. C<func_num> is the number of the new function. C<function> is ignored.
TODO change this to a MMD register interface that takes a function *name*.
-=cut
-
*/
+PARROT_API
void
mmd_add_function(Interp *interp,
INTVAL func_nr, funcptr_t function)
@@ -550,13 +551,9 @@
/*
-=item C<static void
-mmd_expand_x(Interp *interp, INTVAL func_nr, INTVAL new_x)>
-
+FUNCDOC:
Expands the function table in the X dimension to include C<new_x>.
-=cut
-
*/
static void
@@ -609,13 +606,9 @@
/*
-=item C<static void
-mmd_expand_y(Interp *interp, INTVAL func_nr, INTVAL new_y)>
-
+FUNCDOC:
Expands the function table in the Y direction.
-=cut
-
*/
static void
@@ -640,12 +633,7 @@
/*
-=item C<void
-mmd_add_by_class(Interp *interp,
- INTVAL functype,
- STRING *left_class, STRING *right_class,
- funcptr_t funcptr)>
-
+FUNCDOC:
Add a function to the MMD table by class name, rather than class number.
Handles the case where the named class isn't loaded yet.
@@ -666,10 +654,9 @@
The function table must exist, but if it is too small, it will
automatically be expanded.
-=cut
-
*/
+PARROT_API
void
mmd_add_by_class(Interp *interp,
INTVAL functype,
@@ -692,12 +679,7 @@
/*
-=item C<void
-mmd_register(Interp *interp,
- INTVAL func_num,
- INTVAL left_type, INTVAL right_type,
- funcptr_t funcptr)>
-
+FUNCDOC:
Register a function C<funcptr> for MMD function table C<func_num> for classes
C<left_type> and C<right_type>. The left and right types are C<INTVAL>s that
represent the class ID numbers.
@@ -718,10 +700,9 @@
can be considered a bug, and will be resolved at some point in the
future.
-=cut
-
*/
+PARROT_API
void
mmd_register(Interp *interp,
INTVAL func_nr,
@@ -753,6 +734,7 @@
table->mmd_funcs[offset] = funcptr;
}
+PARROT_API
void
mmd_register_sub(Interp *interp,
INTVAL func_nr,
@@ -772,15 +754,12 @@
/*
-=item C<void
-mmd_destroy(Parrot_Interp interp)>
-
+FUNCDOC:
Frees all the memory allocated used the MMD subsystem.
-=cut
-
*/
+PARROT_API
void
mmd_destroy(Parrot_Interp interp)
{
@@ -799,20 +778,18 @@
/*
-=item C<PMC *
-mmd_vtfind(Parrot_Interp interp, INTVAL type, INTVAL left, INTVAL right)>
-
+FUNCDOC:
Return an MMD PMC function for the given data types. The return result is
either a Sub PMC (for PASM MMD functions) or a NCI PMC holding the
C function pointer in PMC_struct_val.
-=cut
-
*/
+PARROT_API
PMC *
mmd_vtfind(Parrot_Interp interp, INTVAL func_nr,
- INTVAL left, INTVAL right) {
+ INTVAL left, INTVAL right)
+{
int is_pmc;
PMC *f;
const funcptr_t func = get_mmd_dispatch_type(interp,
@@ -840,6 +817,7 @@
static int mmd_maybe_candidate(Interp *, PMC *pmc, PMC *arg_tuple, PMC *cl);
static void mmd_sort_candidates(Interp *, PMC *arg_tuple, PMC *cl);
+PARROT_API
PMC *
Parrot_MMD_search_default_infix(Interp *interp, STRING *meth,
INTVAL left_type, INTVAL right_type)
@@ -863,7 +841,9 @@
*/
-PMC *Parrot_mmd_sort_candidate_list(Interp *interp, PMC *candidates)
+PARROT_API
+PMC *
+Parrot_mmd_sort_candidate_list(Interp *interp, PMC *candidates)
{
PMC *arg_tuple;
INTVAL n;
@@ -1622,15 +1602,12 @@
/*
-=item C<void Parrot_mmd_register_table(Interp*, INTVAL type,
- MMD_init *, INTVAL)>
-
+FUNCDOC:
Register MMD functions for this PMC type.
-=cut
-
*/
+PARROT_API
void
Parrot_mmd_register_table(Interp* interp, INTVAL type,
const MMD_init *mmd_table, INTVAL n)
@@ -1682,6 +1659,7 @@
*/
+PARROT_API
void
Parrot_mmd_rebuild_table(Interp* interp, INTVAL type, INTVAL func_nr)
{
Modified: trunk/src/objects.c
==============================================================================
--- trunk/src/objects.c (original)
+++ trunk/src/objects.c Tue Jun 5 08:13:36 2007
@@ -12,31 +12,28 @@
=head2 Functions
-=over 4
-
-=cut
-
*/
#define PARROT_IN_OBJECTS_C
#include "parrot/parrot.h"
+#include "parrot/objects.h"
#include <assert.h>
#include "objects.str"
+/* HEADER: include/parrot/objects.h */
+
static void parrot_class_register(Interp *interp, PMC *name,
PMC *new_class, PMC *parent, PMC *mro);
/*
-=item C<INTVAL Parrot_get_vtable_index(Interp *interp, STRING *name)>
-
+FUNCDOC:
Return index if C<name> is a valid vtable slot name.
-=cut
-
*/
+PARROT_API
INTVAL
Parrot_get_vtable_index(Interp *interp, const STRING *name /*NN*/)
{
@@ -74,13 +71,9 @@
/*
-=item C<static PMC* find_vtable_meth_ns(Interp *interp, PMC *ns,
- INTVAL vtable_index)>
-
+FUNCDOC:
Return Sub PMC if a method with the vtable name exists in ns
-=cut
-
*/
static PMC*
@@ -112,15 +105,13 @@
/*
-=item C<PMC* Parrot_find_vtable_meth(Interp *interp, PMC *pmc, STRING *meth)>
-
+FUNCDOC:
Given pmc, run through its mro looking for the meth vtable method.
Return the vtable method PMC if found.
-=cut
-
*/
+PARROT_API
PMC*
Parrot_find_vtable_meth(Interp *interp, PMC *pmc, STRING *meth)
{
@@ -161,15 +152,14 @@
/*
-=item C<STRING* readable_name(Interp *interp, PMC *name)>
-
+FUNCDOC:
Given a String or Key PMC return the STRING* representation
-=cut
-
XXX this function, key_set_to_string, and the key PMC get_repr should be
consolidated
+
*/
+PARROT_API
STRING*
readable_name(Interp *interp, PMC *name)
{
@@ -194,12 +184,9 @@
/*
-=item C< static void fail_if_exist(Interp *interp, PMC *name)>
-
+FUNCDOC:
Throws an exception if a PMC or class with the same name already exists.
-=cut
-
XXX uses global class registry
*/
@@ -305,14 +292,11 @@
/*
-=item C<static void create_deleg_pmc_vtable(Interp *, PMC *_class, PMC
*class_name, int full)>
-
+FUNCDOC:
Create a vtable that dispatches either to the contained PMC in the first
attribute (deleg_pmc) or to an overridden method (delegate), depending
on the existence of the method for this class.
-=cut
-
*/
static void
@@ -372,21 +356,17 @@
}
}
-/*
-
-=item C<const char* Parrot_MMD_method_name(Interp*, INTVAL)>
-
-Return the method name for the given MMD enum.
-
-=item C<INTVAL Parrot_MMD_method_idx(Interp*, STRING *)>
-Return the MMD function number for method name or -1 on failure.
+/* HEADER: include/parrot/mmd.h */
-TODO allow dynamic expansion at runtime.
+/*
-=cut
+FUNCDOC:
+Return the method name for the given MMD enum.
*/
+
+PARROT_API
const char*
Parrot_MMD_method_name(Interp *interp, INTVAL idx)
{
@@ -398,8 +378,18 @@
return Parrot_mmd_func_names[idx];
}
+/*
+
+FUNCDOC:
+Return the MMD function number for method name or -1 on failure.
+
+TODO allow dynamic expansion at runtime.
+
+*/
+
+PARROT_API
INTVAL
-Parrot_MMD_method_idx(Interp *interp, char *name)
+Parrot_MMD_method_idx(Interp *interp, const char * const name)
{
INTVAL i;
@@ -414,17 +404,14 @@
/*
-=item C<PMC *
-Parrot_single_subclass(Interp *interp, PMC *base_class, PMC *child_class_name)>
-
+FUNCDOC:
Subclass a class. Single parent class, nice and straightforward. If
C<child_class> is C<NULL>, this is an anonymous subclass we're creating,
function.
-=cut
-
*/
+PARROT_API
PMC *
Parrot_single_subclass(Interp *interp, PMC *base_class, PMC *name)
{
@@ -522,15 +509,12 @@
/*
-=item C<void
-Parrot_new_class(Interp *interp, PMC *_class, PMC *class_name)>
-
+FUNCDOC:
Creates a new class, named C<class_name>.
-=cut
-
*/
+PARROT_API
void
Parrot_new_class(Interp *interp, PMC *_class, PMC *name)
{
@@ -573,19 +557,13 @@
/*
-=item C<PMC *
-Parrot_class_lookup(Interp *interp, STRING *class_name)>
-
-=item C<PMC *
-Parrot_class_lookup_p(Interp *interp, PMC *class_name)>
-
+FUNCDOC:
Looks for the class named C<class_name> and returns it if it exists.
Otherwise it returns C<PMCNULL>.
-=cut
-
*/
+PARROT_API
PMC *
Parrot_class_lookup(Interp *interp, STRING *class_name)
{
@@ -600,6 +578,14 @@
return pmc;
}
+/*
+
+FUNCDOC:
+Looks for the class named C<class_name> and returns it if it exists.
+Otherwise it returns C<PMCNULL>.
+
+*/
+
PMC *
Parrot_class_lookup_p(Interp *interp, PMC *class_name)
{
@@ -642,17 +628,13 @@
/*
-=item C<static void
-parrot_class_register(Interp *interp, PMC *class_name, PMC *new_class, PMC
*mro)>
-
+FUNCDOC:
This is the way to register a new Parrot class as an instantiable
type. Doing this involves putting it in the class hash, setting its
vtable so that the C<init> method initializes objects of the class rather than
the class itself, and adding it to the interpreter's base type table so
you can create a new C<foo> in PASM like this: C<new Px, foo>.
-=cut
-
*/
static void
@@ -895,25 +877,22 @@
/*
-=item C<void
-Parrot_instantiate_object(Interp *interp, PMC *object, PMC *init)>
-
+FUNCDOC:
Creates a Parrot object. Takes a passed-in class PMC that has sufficient
-information to describe the layout of the object and, well, makes the
-darned object.
-
-=cut
+information to describe the layout of the object and makes the object.
*/
static void instantiate_object(Interp*, PMC *object, PMC *init);
+PARROT_API
void
Parrot_instantiate_object_init(Interp *interp, PMC *object, PMC *init)
{
instantiate_object(interp, object, init);
}
+PARROT_API
void
Parrot_instantiate_object(Interp *interp, PMC *object)
{
@@ -960,9 +939,7 @@
/*
-=item C<PMC *
-Parrot_add_parent(Interp *interp, PMC *_class, PMC *parent)>
-
+FUNCDOC:
Add the parent class to the current class' parent list. This also
involved adding all the parent's parents, as well as all attributes of
the parent classes that we're adding in.
@@ -971,8 +948,6 @@
and Python (>= 2.3). See also:
L<http://pugs.blogs.com/pugs/2005/07/day_165_r5671_j.html>
-=cut
-
*/
/* create a list if non-empty lists */
@@ -1077,6 +1052,7 @@
return class_mro_merge(interp, lall);
}
+PARROT_API
void
Parrot_add_parent(Interp *interp, PMC *_class, PMC *parent)
{
@@ -1117,15 +1093,12 @@
/*
-=item C<PMC * Parrot_remove_parent(Interp *interp, PMC *removed_class,
- PMC *existing_class)>
-
+FUNCDOC:
This currently does nothing but return C<PMCNULL>.
-=cut
-
*/
+PARROT_API
PMC *
Parrot_remove_parent(Interp *interp, PMC *removed_class, PMC *existing_class) {
return PMCNULL;
@@ -1133,16 +1106,12 @@
/*
-=item C<PMC *
-Parrot_multi_subclass(Interp *interp, PMC *base_class_array,
- STRING *child_class_name)>
-
+FUNCDOC:
This currently does nothing but return C<PMCNULL>.
-=cut
-
*/
+PARROT_API
PMC *
Parrot_multi_subclass(Interp *interp, PMC *base_class_array,
STRING *child_class_name) {
@@ -1151,15 +1120,12 @@
/*
-=item C<INTVAL
-Parrot_object_isa(Interp *interp, PMC *pmc, PMC *_class)>
-
+FUNCDOC:
Returns whether the object C<pmc> is an instance of class C<_class>.
-=cut
-
*/
+PARROT_API
INTVAL
Parrot_object_isa(Interp *interp, PMC *pmc, PMC *_class)
{
@@ -1183,50 +1149,19 @@
/*
-=item C<PMC *
-Parrot_new_method_cache(Interp *interp)>
-
+FUNCDOC:
This should create and return a new method cache PMC.
Currently it does nothing but return C<PMCNULL>.
-=cut
-
*/
+PARROT_API
PMC *
Parrot_new_method_cache(Interp *interp) {
return PMCNULL;
}
-/*
-
-=item C<PMC *
-Parrot_find_method_with_cache(Interp *interp, PMC *_class, STRING
*method_name)>
-
-Find a method PMC for a named method, given the class PMC, current
-interp, and name of the method.
-
-This routine should use the current scope's method cache, if there is
-one. If not, it creates a new method cache. Or, rather, it will when
-we've got that bit working. For now it unconditionally goes and looks up
-the name in the global stash.
-
-=item C<PMC *
-Parrot_find_method_direct(Interp *interp, PMC *_class, STRING *method_name)>
-
-Find a method PMC for a named method, given the class PMC, current
-interpreter, and name of the method. Don't use a possible method cache.
-
-=item void Parrot_invalidate_method_cache(Interp *, STRING *_class)
-
-Clear method cache for the given class. If class is NULL, caches for
-all classes are invalidated.
-
-=cut
-
-*/
-
static PMC* find_method_direct_1(Interp*, PMC *, STRING*);
void
@@ -1291,6 +1226,15 @@
invalidate_type_caches(interp, i);
}
+/*
+
+FUNCDOC:
+Clear method cache for the given class. If class is NULL, caches for
+all classes are invalidated.
+
+*/
+
+PARROT_API
void
Parrot_invalidate_method_cache(Interp *interp, STRING *_class, STRING *meth)
{
@@ -1329,6 +1273,15 @@
* If this hash is implemented mark it during DOD
*/
+/*
+
+FUNCDOC:
+Find a method PMC for a named method, given the class PMC, current
+interpreter, and name of the method. Don't use a possible method cache.
+
+*/
+
+PARROT_API
PMC *
Parrot_find_method_direct(Interp *interp, PMC *_class, STRING *method_name)
{
@@ -1347,8 +1300,22 @@
return PMCNULL;
}
+/*
+
+FUNCDOC:
+Find a method PMC for a named method, given the class PMC, current
+interp, and name of the method.
+
+This routine should use the current scope's method cache, if there is
+one. If not, it creates a new method cache. Or, rather, it will when
+we've got that bit working. For now it unconditionally goes and looks up
+the name in the global stash.
+
+*/
+
+PARROT_API
PMC *
-Parrot_find_method_with_cache(Interp *interp, PMC *_class, STRING *method_name
/* NN */)
+Parrot_find_method_with_cache(Interp *interp, PMC *_class, STRING *method_name
/*NN*/)
{
UINTVAL type, bits, i;
@@ -1479,41 +1446,37 @@
}
/*
-=item C<void
-Parrot_note_method_offset(Interp *interp, UINTVAL offset, PMC *method)>
+FUNCDOC:
Notes where in the hierarchy we just found a method. Used so that we
can do a next and continue the search through the hierarchy for the
next instance of this method.
*/
+
+PARROT_API
void
Parrot_note_method_offset(Interp *interp, UINTVAL offset, PMC *method) {
}
/*
-=item C<INTVAL
-Parrot_add_attribute(Interp *interp, PMC* _class, STRING* attr)>
-
+FUNCDOC:
Adds the attribute C<attr> to the class.
-=cut
-
-*/
-
-/* Life is ever so much easier if a class keeps its attributes at the
+ Life is ever so much easier if a class keeps its attributes at the
end of the attribute array, since we don't have to insert and
reorder attributes. Inserting's no big deal, especially since we're
going to break horribly if you insert into a class that's been
- subclassed, but it'll do for now */
+ subclassed, but it'll do for now.
+*/
+
+PARROT_API
INTVAL
Parrot_add_attribute(Interp *interp, PMC* _class, STRING* attr)
{
STRING *full_attr_name;
- char *c_error;
-
SLOTTYPE * const class_array = (SLOTTYPE *)PMC_data(_class);
STRING * const class_name = VTABLE_get_string(interp,
get_attrib_num(class_array, PCD_CLASS_NAME));
@@ -1531,9 +1494,8 @@
full_attr_name = string_concat(interp, full_attr_name, attr, 0);
/* TODO escape NUL char */
- if (VTABLE_exists_keyed_str(interp, attr_hash, full_attr_name))
- {
- c_error = string_to_cstring(interp, full_attr_name);
+ if (VTABLE_exists_keyed_str(interp, attr_hash, full_attr_name)) {
+ char * const c_error = string_to_cstring(interp, full_attr_name);
internal_exception(1, "Attribute '%s' already exists", c_error);
string_cstring_free(c_error);
}
@@ -1551,21 +1513,13 @@
/*
-=item C<PMC *
-Parrot_get_attrib_by_num(Interp *interp, PMC *object, INTVAL attrib)>
-
+FUNCDOC:
Returns attribute number C<attrib> from C<object>. Presumably the code
is asking for the correct attribute number.
-=item C<PMC *
-Parrot_get_attrib_by_str(Interp *interp, PMC *object, STRING *attr)>
-
-Returns attribute with full qualified name C<attr> from C<object>.
-
-=cut
-
*/
+PARROT_API
PMC *
Parrot_get_attrib_by_num(Interp *interp, PMC *object, INTVAL attrib)
{
@@ -1637,6 +1591,14 @@
return 0;
}
+/*
+
+FUNCDOC:
+Returns attribute with full qualified name C<attr> from C<object>.
+
+*/
+
+PARROT_API
PMC *
Parrot_get_attrib_by_str(Interp *interp, PMC *object, STRING *attr)
{
@@ -1646,24 +1608,16 @@
/*
-=item C<PMC *
-Parrot_set_attrib_by_num(Interp *interp, PMC *object,
- INTVAL attrib, PMC *value)>
-
+FUNCDOC:
Set attribute number C<attrib> from C<object> to C<value>. Presumably the code
is asking for the correct attribute number.
-=item C<PMC *
-Parrot_set_attrib_by_str(Interp *interp, PMC *object, STRING *attr, PMC
*value)>
-
-Sets attribute with full qualified name C<attr> from C<object> to C<value>.
-
-=cut
-
*/
+PARROT_API
void
-Parrot_set_attrib_by_num(Interp *interp, PMC *object, INTVAL attrib, PMC
*value) {
+Parrot_set_attrib_by_num(Interp *interp, PMC *object, INTVAL attrib, PMC
*value)
+{
SLOTTYPE * const attrib_array = PMC_data_typed(object, SLOTTYPE *);
const INTVAL attrib_count = PMC_int_val(object);
@@ -1674,14 +1628,25 @@
set_attrib_num(object, attrib_array, attrib, value);
}
+/*
+
+FUNCDOC:
+Sets attribute with full qualified name C<attr> from C<object> to C<value>.
+
+*/
+
+PARROT_API
void
-Parrot_set_attrib_by_str(Interp *interp, PMC *object, STRING *attr, PMC
*value) {
+Parrot_set_attrib_by_str(Interp *interp, PMC *object, STRING *attr, PMC *value)
+{
Parrot_set_attrib_by_num(interp, object,
attr_str_2_num(interp, object, attr), value);
}
+PARROT_API
INTVAL
-Parrot_class_offset(Interp *interp, PMC *object, STRING *_class) {
+Parrot_class_offset(Interp *interp, PMC *object, STRING *_class)
+{
PMC *class_pmc, *mro, *attribs;
INTVAL offset, i, n, attr_count;
@@ -1718,43 +1683,57 @@
/*
-=item C<PMC *Parrot_find_class_constructor(Interp *interp,
- STRING *_class, INTVAL classtoken)>
-
+FUNCDOC:
Find and return the constructor method PMC for the named sub. The
classtoken is an identifier for the class used for fast lookup, or 0
if you don't have an identifier token (which, as they're currently
undefined, is pretty likely).
-=cut
-
*/
-PMC *Parrot_find_class_constructor(Interp *interp, STRING *_class,
- INTVAL classtoken) {
+PARROT_API
+PMC *
+Parrot_find_class_constructor(Interp *interp, STRING *_class,
+ INTVAL classtoken)
+{
return PMCNULL;
}
-PMC *Parrot_find_class_destructor(Interp *interp, STRING *_class,
- INTVAL classtoken) {
+PARROT_API
+PMC *
+Parrot_find_class_destructor(Interp *interp, STRING *_class,
+ INTVAL classtoken)
+{
return PMCNULL;
}
-PMC *Parrot_find_class_fallback(Interp *interp, STRING *_class,
- INTVAL classtoken) {
+PARROT_API
+PMC *
+Parrot_find_class_fallback(Interp *interp, STRING *_class,
+ INTVAL classtoken)
+{
return PMCNULL;
}
-void Parrot_set_class_constructor(Interp *interp, STRING *_class,
- INTVAL classtoken, STRING *method) {
+PARROT_API
+void
+Parrot_set_class_constructor(Interp *interp, STRING *_class,
+ INTVAL classtoken, STRING *method)
+{
}
-void Parrot_set_class_destructor(Interp *interp, STRING *_class,
- INTVAL classtoken, STRING *method) {
+PARROT_API
+void
+Parrot_set_class_destructor(Interp *interp, STRING *_class,
+ INTVAL classtoken, STRING *method)
+{
}
-void Parrot_set_class_fallback(Interp *interp, STRING *_class,
- INTVAL classtoken, STRING *method) {
+PARROT_API
+void
+Parrot_set_class_fallback(Interp *interp, STRING *_class,
+ INTVAL classtoken, STRING *method)
+{
}
@@ -1762,17 +1741,8 @@
/* ********* BELOW HERE IS NEW PPD15 IMPLEMENTATION RELATED STUFF ********* */
/* ************************************************************************ */
-/*
-
-=item C<PMC* Parrot_ComputeMRO_C3(Interp *interp, PMC *_class)>
-
-Computes the C3 linearization for the given class.
-
-=cut
-
-*/
-
-static PMC* C3_merge(Interp *interp, PMC *merge_list)
+static PMC*
+C3_merge(Interp *interp, PMC *merge_list)
{
PMC *result = pmc_new(interp, enum_class_ResizablePMCArray);
const int list_count = VTABLE_elements(interp, merge_list);
@@ -1856,7 +1826,15 @@
return result;
}
-PMC* Parrot_ComputeMRO_C3(Interp *interp, PMC *_class)
+/*
+
+FUNCDOC:
+Computes the C3 linearization for the given class.
+
+*/
+
+PMC*
+Parrot_ComputeMRO_C3(Interp *interp, PMC *_class)
{
PMC *result;
PMC *merge_list = pmc_new(interp, enum_class_ResizablePMCArray);
@@ -1913,11 +1891,7 @@
/*
-=item C<void Parrot_ComposeRole(Interp *interp, PMC *role,
- PMC *exclude, int got_exclude,
- PMC *alias, int got_alias,
- PMC *methods_hash, PMC *roles_list)>
-
+FUNCDOC:
Used by the Class and Object PMCs internally to compose a role into either of
them. The C<role> parameter is the role that we are composing into the class
or role. C<methods_hash> is the hash of method names to invokable PMCs that
@@ -1933,7 +1907,8 @@
*/
-void Parrot_ComposeRole(Interp *interp, PMC *role,
+void
+Parrot_ComposeRole(Interp *interp, PMC *role,
PMC *exclude, int got_exclude,
PMC *alias, int got_alias,
PMC *methods_hash, PMC *roles_list)
@@ -1968,12 +1943,10 @@
while (VTABLE_get_bool(interp, methods_iter)) {
/* Get current method and its name. */
- STRING *method_name;
- PMC *cur_method;
int excluded;
- method_name = VTABLE_shift_string(interp, methods_iter);
- cur_method = VTABLE_get_pmc_keyed_str(interp, methods, method_name);
+ STRING * const method_name = VTABLE_shift_string(interp, methods_iter);
+ PMC * const cur_method = VTABLE_get_pmc_keyed_str(interp, methods,
method_name);
/* Need to find the name we'll check for a conflict on. */
excluded = 0;
@@ -2098,8 +2071,6 @@
/*
-=back
-
=head1 SEE ALSO
F<include/parrot/objects.h>, F<docs/pdds/pdd15_objects.pod>.
Modified: trunk/tools/build/headerize.pl
==============================================================================
--- trunk/tools/build/headerize.pl (original)
+++ trunk/tools/build/headerize.pl Tue Jun 5 08:13:36 2007
@@ -28,6 +28,8 @@
* Test the POD of the stuff we're parsing.
+* Somehow handle static functions in the source file
+
=head1 NOTES
* the .c files MUST have a /* HEADER: foo/bar.h */ directive in them
@@ -142,7 +144,7 @@
my $parms = join( " ", @lines );
$parms =~ s/\s+/ /g;
- $parms =~ s/([^(]+)\s*\((.+)\);?/$2/ or die "Couldn't handle $proto";
+ $parms =~ s/([^(]+)\s*\((.+)\);?/$2/ or die qq{Couldn't handle "$proto"};
my $funcname = $1;
$parms = $2;
my @parms = split( /\s*,\s*/, $parms );