Author: chromatic
Date: Sat Apr 14 20:31:19 2007
New Revision: 18216
Modified:
trunk/docs/vtables.pod
trunk/lib/Parrot/Pmc2c.pm
trunk/lib/Parrot/Vtable.pm
trunk/src/hll.c
trunk/src/jit/i386/jit_emit.h
trunk/src/jit/sun4/jit_emit.h
trunk/t/tools/pmc2c.t
Changes in other areas also in this revision:
Modified:
trunk/docs/pdds/draft/pddXX_pmc.pod
Log:
Added typedef for struct _vtable, then used VTABLE everywhere, as it was
already available.
Modified: trunk/docs/vtables.pod
==============================================================================
--- trunk/docs/vtables.pod (original)
+++ trunk/docs/vtables.pod Sat Apr 14 20:31:19 2007
@@ -93,8 +93,8 @@
you run F<Configure.pl>. If you're not writing a built-in class, you need to
indicate this by using the 'extension' keyword after the 'pmclass YOURCLASS'
declaration in F<src/pmc/YOURCLASS.pmc>. Then, change the type of the C<init>
-function to return C<struct _vtable>, and then return C<temp_base_vtable>
-instead of assigning to the interpreter specific C<vtables> array.
+function to return C<VTABLE>, and then return C<temp_base_vtable> instead of
+assigning to the interpreter specific C<vtables> array.
To finish up adding a built-in class:
Modified: trunk/lib/Parrot/Pmc2c.pm
==============================================================================
--- trunk/lib/Parrot/Pmc2c.pm (original)
+++ trunk/lib/Parrot/Pmc2c.pm Sat Apr 14 20:31:19 2007
@@ -836,7 +836,7 @@
my $enum_name = $self->{flags}{dynpmc} ? -1 : "enum_class_$classname";
my $methlist = join( ",\n ", @$methods );
$cout .= <<ENDOFCODE;
- const struct _vtable $name = {
+ const VTABLE $name = {
NULL, /* namespace */
$enum_name, /* base_type */
NULL, /* whoami */
@@ -916,12 +916,12 @@
/*
* create vtable - clone it - we have to set a few items
*/
- struct _vtable *vt_clone =
+ VTABLE *vt_clone =
Parrot_clone_vtable(interp, &temp_base_vtable);
EOC
for my $k ( keys %extra_vt ) {
$cout .= <<"EOC";
- struct _vtable *vt_${k}_clone =
+ VTABLE *vt_${k}_clone =
Parrot_clone_vtable(interp, &temp_${k}_vtable);
EOC
}
Modified: trunk/lib/Parrot/Vtable.pm
==============================================================================
--- trunk/lib/Parrot/Vtable.pm (original)
+++ trunk/lib/Parrot/Vtable.pm Sat Apr 14 20:31:19 2007
@@ -148,28 +148,28 @@
$struct = <<"EOF";
typedef enum {
- VTABLE_IS_CONST_FLAG = 0x01,
- VTABLE_HAS_CONST_TOO = 0x02,
- VTABLE_PMC_NEEDS_EXT = 0x04,
- VTABLE_DATA_IS_PMC = 0x08,
- VTABLE_PMC_IS_SINGLETON = 0x10,
- VTABLE_IS_SHARED_FLAG = 0x20,
- VTABLE_IS_CONST_PMC_FLAG = 0x40,
- VTABLE_HAS_READONLY_FLAG = 0x80,
- VTABLE_IS_READONLY_FLAG = 0x100
+ VTABLE_IS_CONST_FLAG = 0x001,
+ VTABLE_HAS_CONST_TOO = 0x002,
+ VTABLE_PMC_NEEDS_EXT = 0x004,
+ VTABLE_DATA_IS_PMC = 0x008,
+ VTABLE_PMC_IS_SINGLETON = 0x010,
+ VTABLE_IS_SHARED_FLAG = 0x020,
+ VTABLE_IS_CONST_PMC_FLAG = 0x040,
+ VTABLE_HAS_READONLY_FLAG = 0x080,
+ VTABLE_IS_READONLY_FLAG = 0x100
} vtable_flags_t;
-struct _vtable {
- PMC * _namespace; /* Pointer to namespace for this class */
- INTVAL base_type; /* 'type' value for MMD */
- STRING* whoami; /* Name of class this vtable is for */
- UINTVAL flags; /* Flags. Duh */
- STRING* does_str; /* space-separated list of interfaces */
- STRING* isa_str; /* space-separated list of classes */
- PMC *class; /* for PMCs: a PMC of that type
- for objects: the class PMC */
- PMC *mro; /* array PMC of [class, parents ... ] */
- struct _vtable *ro_variant_vtable; /* A varient of this vtable with the
+typedef struct _vtable {
+ PMC *_namespace; /* Pointer to namespace for this class */
+ INTVAL base_type; /* 'type' value for MMD */
+ STRING *whoami; /* Name of class this vtable is for */
+ UINTVAL flags; /* Flags. Duh */
+ STRING *does_str; /* space-separated list of interfaces */
+ STRING *isa_str; /* space-separated list of classes */
+ PMC *class; /* for PMCs: a PMC of that type
+ for objects: the class PMC */
+ PMC *mro; /* array PMC of [class, parents ... ] */
+ struct _vtable *ro_variant_vtable; /* A variant of this vtable with the
opposite IS_READONLY flag */
/* Vtable Functions */
@@ -179,7 +179,7 @@
$struct .= " $entry->[1]_method_t $entry->[1];\n";
}
- $struct .= "};\n";
+ $struct .= "} _vtable;\n";
return $struct;
}
Modified: trunk/src/hll.c
==============================================================================
--- trunk/src/hll.c (original)
+++ trunk/src/hll.c Sat Apr 14 20:31:19 2007
@@ -112,8 +112,7 @@
}
INTVAL
-Parrot_register_HLL(Interp *interp,
- STRING *hll_name, STRING *hll_lib)
+Parrot_register_HLL(Interp *interp, STRING *hll_name, STRING *hll_lib)
{
PMC *entry, *name, *type_hash, *ns_hash, *hll_info;
INTVAL idx;
Modified: trunk/src/jit/i386/jit_emit.h
==============================================================================
--- trunk/src/jit/i386/jit_emit.h (original)
+++ trunk/src/jit/i386/jit_emit.h Sat Apr 14 20:31:19 2007
@@ -2450,7 +2450,7 @@
char *L4 = NULL;
/* get the offset of the first vtable func */
- offset = offsetof(struct _vtable, init);
+ offset = offsetof(VTABLE, init);
offset += nvtable * sizeof (void *);
op = *jit_info->cur_op;
if (op == PARROT_OP_set_i_p_ki) {
@@ -2770,7 +2770,7 @@
{
int p1, i2;
op_info_t *op_info = &interp->op_info_table[*jit_info->cur_op];
- size_t offset = offsetof(struct _vtable, init);
+ size_t offset = offsetof(VTABLE, init);
extern PARROT_API char **Parrot_exec_rel_addr;
extern PARROT_API int Parrot_exec_rel_count;
Modified: trunk/src/jit/sun4/jit_emit.h
==============================================================================
--- trunk/src/jit/sun4/jit_emit.h (original)
+++ trunk/src/jit/sun4/jit_emit.h Sat Apr 14 20:31:19 2007
@@ -849,7 +849,7 @@
int idx, pi, i;
size_t offset;
- offset = offsetof(struct _vtable, init);
+ offset = offsetof(VTABLE, init);
offset += nvtable * sizeof (void *);
for (idx = 1; idx <= n; idx++) {
@@ -1107,7 +1107,7 @@
Interp *interp)
{
void *igniter = (void (*)(void))pmc_new_noinit;
- size_t offset = offsetof(struct _vtable, init);
+ size_t offset = offsetof(VTABLE, init);
int p1 = *(jit_info->cur_op + 1);
int i2 = *(jit_info->cur_op + 2);
Modified: trunk/t/tools/pmc2c.t
==============================================================================
--- trunk/t/tools/pmc2c.t (original)
+++ trunk/t/tools/pmc2c.t Sat Apr 14 20:31:19 2007
@@ -101,7 +101,7 @@
void
Parrot_a_class_init(Parrot_Interp interp, int entry, int pass)
{
- const struct _vtable temp_base_vtable = {
+ const VTABLE temp_base_vtable = {
END_C
pmc2c_output_like( <<'END_PMC', <<'END_C', 'comment passthrough' );
@@ -136,7 +136,7 @@
pmc2c_output_like( <<'END_PMC', <<'END_C', 'need_ext' );
pmclass a need_ext { }
END_PMC
- const struct _vtable temp_base_vtable = {
+ const VTABLE temp_base_vtable = {
NULL, /* namespace */
enum_class_a, /* base_type */
NULL, /* whoami */
@@ -149,7 +149,7 @@
void
Parrot_a_class_init(Parrot_Interp interp, int entry, int pass)
{
- const struct _vtable temp_base_vtable = {
+ const VTABLE temp_base_vtable = {
NULL, /* namespace */
enum_class_a, /* base_type */
NULL, /* whoami */
@@ -162,7 +162,7 @@
void
Parrot_Consta_class_init(Parrot_Interp interp, int entry, int pass)
{
- const struct _vtable temp_base_vtable = {
+ const VTABLE temp_base_vtable = {
NULL, /* namespace */
enum_class_Consta, /* base_type */
NULL, /* whoami */