People were complaining about bloat already? Well, I'm not a great believer in
taking 1800 lines to do what you can do more clearly in 700; nor taking 43
functions, many of which are completely unused, to do the work of 14. This
refactoring does not attempt to disguise the fact that C is not
object-oriented Perl.

The attached patch reduces packfile.c to a manageable size, removes some
memory allocation bugs, makes the string type and encoding support correct,
and also makes it considerably easier to read and understand. I still think
that 700 is too many for such a simple job, but we'll have to wait until after
the bytecode PDD is finished to see how many more we can lose. But still,
given that packfile.c was second only in length to the core ops files and
three times the size of anything else, I think this isn't bad for a first
trim.

Yes, this removes some of the functionality for creating packfiles, which
we don't currently use, but I've moved those to another file so that they
can be XS-wrapped and used by the assembler as was the plan all along. 

It also removes the functions for dumping packfiles; I've already expressed
my opinions of pdump, and might even be happy with just a Perl disassembler.
But I've moved the dump functions into a separate file as well just in case.

In other news, "struct PackFile" is an amazingly misleading name, and I'd
welcome suggestions for a replacement. When you have a full struct PackFile,
what you have is neither packed, nor a file.

Simon

-- 
Henry, I'm a Regent Master of the Ancient and Venerable House of Congregation.
Being eccentrically dull is practically my job description.
    - Jonathan Jones
? .gdb_history
? april.fool
? packdump.c
? packout.c
? pfcps.c
? queens.pbc
? test.pasm
? test.pasms
? test.pbc
? Parrot/Config.pm
? Parrot/PMC.pm
? Parrot/Types.pm
? Parrot/OpLib/core.pm
? docs/pdds/pdd13_bytecode.pdd
Index: MANIFEST
===================================================================
RCS file: /cvs/public/parrot/MANIFEST,v
retrieving revision 1.114
diff -d -u -r1.114 MANIFEST
--- MANIFEST    5 Feb 2002 09:20:07 -0000       1.114
+++ MANIFEST    11 Mar 2002 02:21:29 -0000
@@ -69,6 +69,8 @@
 examples/assembly/trace.pasm
 examples/mops/README
 examples/mops/mops.c
+examples/mops/mops.cs
+examples/mops/mops.il
 examples/mops/mops.pl
 examples/mops/mops.ps
 examples/mops/mops.py
Index: Makefile.in
===================================================================
RCS file: /cvs/public/parrot/Makefile.in,v
retrieving revision 1.131
diff -d -u -r1.131 Makefile.in
--- Makefile.in 15 Feb 2002 02:30:02 -0000      1.131
+++ Makefile.in 11 Mar 2002 02:21:30 -0000
@@ -143,7 +143,7 @@
 .c$(O):
        $(CC) $(CFLAGS) ${cc_o_out}$@ -c $<
 
-all : $(TEST_PROG) $(PDUMP) docs
+all : $(TEST_PROG) docs
 
 mops: examples/assembly/mops${exe} examples/mops/mops${exe}
 
@@ -205,8 +205,8 @@
 # Parrot Dump
 #
 
-$(PDUMP): pdump$(O) $(O_FILES)
-       $(LD) ${ld_out}$(PDUMP) $(O_FILES) pdump$(O) $(C_LIBS) $(LDFLAGS)
+#$(PDUMP): pdump$(O) packfile$(O)
+       #$(LD) ${ld_out}$(PDUMP) pdump$(O) packfile$(O) string$(O) chartype$(O) 
+memory$(O) $(C_LIBS) $(LDFLAGS)
 
 
 ###############################################################################
Index: chartype.c
===================================================================
RCS file: /cvs/public/parrot/chartype.c,v
retrieving revision 1.1
diff -d -u -r1.1 chartype.c
--- chartype.c  31 Oct 2001 22:51:31 -0000      1.1
+++ chartype.c  11 Mar 2002 02:21:30 -0000
@@ -15,6 +15,8 @@
 extern const CHARTYPE usascii_chartype;
 extern const CHARTYPE unicode_chartype;
 
+static const CHARTYPE* chartype_array[enum_chartype_MAX];
+
 const CHARTYPE *
 chartype_lookup(const char *name) {
     if (strcmp(name, "usascii") == 0) {
@@ -26,6 +28,15 @@
     else {
         return NULL;
     }
+}
+
+const CHARTYPE *
+chartype_lookup_index(INTVAL n) {
+    if (!chartype_array[0]) {
+        chartype_array[enum_chartype_unicode] = &unicode_chartype; 
+        chartype_array[enum_chartype_usascii] = &usascii_chartype; 
+    }
+    return chartype_array[n];
 }
 
 CHARTYPE_TRANSCODER
Index: encoding.c
===================================================================
RCS file: /cvs/public/parrot/encoding.c,v
retrieving revision 1.1
diff -d -u -r1.1 encoding.c
--- encoding.c  31 Oct 2001 22:51:31 -0000      1.1
+++ encoding.c  11 Mar 2002 02:21:30 -0000
@@ -17,6 +17,8 @@
 extern const ENCODING utf16_encoding;
 extern const ENCODING utf32_encoding;
 
+static const ENCODING* encoding_array[enum_encoding_MAX]; 
+
 const ENCODING *
 encoding_lookup(const char *name) {
     if (strcmp(name, "singlebyte") == 0) {
@@ -34,6 +36,17 @@
     else {
         return NULL;
     }
+}
+
+const ENCODING *
+encoding_lookup_index(INTVAL n) {
+    if (!encoding_array[0]) {
+        encoding_array[enum_encoding_singlebyte] = &singlebyte_encoding;
+        encoding_array[enum_encoding_utf8]       = &utf8_encoding;
+        encoding_array[enum_encoding_utf16]      = &utf16_encoding;
+        encoding_array[enum_encoding_utf32]      = &utf32_encoding;
+    }
+    return encoding_array[n];
 }
 
 /*
Index: packfile.c
===================================================================
RCS file: /cvs/public/parrot/packfile.c,v
retrieving revision 1.25
diff -d -u -r1.25 packfile.c
--- packfile.c  15 Feb 2002 02:30:02 -0000      1.25
+++ packfile.c  11 Mar 2002 02:21:30 -0000
@@ -13,10 +13,8 @@
 #include "parrot/parrot.h"
 #include "parrot/packfile.h"
 
-
 #define TRACE_PACKFILE 0
 
-
 /******************************************************************************
 
 =head1 PackFile Manipulation Functions
@@ -28,72 +26,59 @@
 See L<parrotbyte> for information about the structure of the
 frozen bycode.
 
-=cut
-
-******************************************************************************/
-
-
-/******************************************************************************
-
 =head2 PackFile Structure Functions
 
 =over 4
 
-=cut
-
-******************************************************************************/
-
-
-/***************************************
-
 =item new
 
 Allocate a new empty PackFile.
 
-NOTE: The PackFile's magic is automatically set to PARROT_MAGIC.
-
 =cut
 
 ***************************************/
 
 struct PackFile *
 PackFile_new(void) {
-    struct PackFile * self = mem_sys_allocate((UINTVAL)sizeof(struct PackFile));
+    struct PackFile * pf = mem_sys_allocate((UINTVAL)sizeof(struct PackFile));
 
-    if (!self) {
+    if (!pf) {
         fprintf(stderr, "PackFile_new: Unable to allocate!\n");
         return NULL;
     }
 
-    self->magic       = PARROT_MAGIC;
-    self->fixup_table = PackFile_FixupTable_new();
+    /* Create fixup table */
+    pf->fixup_table = mem_sys_allocate((UINTVAL)sizeof(struct PackFile_FixupTable));
 
-    if (!self->fixup_table) {
+    if (!pf->fixup_table) {
         fprintf(stderr, "PackFile_new: Unable to allocate fixup table!\n");
-        mem_sys_free(self);
+        PackFile_destroy(pf);
         return NULL;
     }
+    pf->fixup_table->dummy = 0;
 
-    self->const_table = PackFile_ConstTable_new();
+    /* Create constant table */
+    pf->const_table = mem_sys_allocate((UINTVAL)sizeof(struct PackFile_ConstTable));
 
-    if (!self->const_table) {
+    if (!pf->const_table) {
         fprintf(stderr, "PackFile_new: Unable to allocate constant table!\n");
-        PackFile_FixupTable_DELETE(self->fixup_table);
-        self->fixup_table = NULL;
-        mem_sys_free(self);
+        PackFile_destroy(pf);
         return NULL;
     }
+    pf->const_table->const_count = 0;
+    pf->const_table->constants   = NULL;
 
-    self->byte_code      = NULL;
-    self->byte_code_size = 0;
+    /* Other fields empty for now */
+    pf->byte_code      = NULL;
+    pf->byte_code_size = 0;
 
-    return self;
+    return pf;
 }
 
 
 /***************************************
 
-=item DELETE
+=item destroy
 
 Delete a PackFile.
 
@@ -102,162 +87,43 @@
 ***************************************/
 
 void
-PackFile_DELETE(struct PackFile * self) {
-    if (!self) {
-        fprintf(stderr, "PackFile_DELETE: self == NULL!\n");
+PackFile_destroy(struct PackFile * pf) {
+    if (!pf) {
+        fprintf(stderr, "PackFile_destroy: pf == NULL!\n");
         return;
     }
 
-    PackFile_clear(self);
-
-    PackFile_FixupTable_DELETE(self->fixup_table);
-    self->fixup_table = NULL;
-
-    PackFile_ConstTable_DELETE(self->const_table);
-    self->const_table = NULL;
-
-    return;
-}
-
-
-/***************************************
-
-=item clear
-
-Clear a PackFile.
-
-NOTE: The PackFile's magic is set to PARROT_MAGIC, not to zero (0).
-
-=cut
-
-***************************************/
-
-void
-PackFile_clear(struct PackFile * self) {
-    if (!self) {
-        fprintf(stderr, "PackFile_clear: self == NULL!\n");
-        return;
+    if (pf->fixup_table) {
+        mem_sys_free(pf->fixup_table);
     }
-
-    self->magic = PARROT_MAGIC;
-
-    PackFile_FixupTable_clear(self->fixup_table);
-    PackFile_ConstTable_clear(self->const_table);
-
-    if (self->byte_code) {
-        mem_sys_free(self->byte_code);
-        self->byte_code = NULL;
+    
+    if (pf->const_table) {
+        PackFile_ConstTable_clear(pf->const_table);
+        mem_sys_free(pf->const_table);
     }
 
-    self->byte_code_size = 0;
+    if (pf->byte_code) {
+        mem_sys_free(pf->byte_code);
+    }
 
+    mem_sys_free(pf);
     return;
 }
 
+/* Internal function to check segment_size % sizeof(opcode_t) */
+static BOOLVAL
+PackFile_check_segment_size(opcode_t segment_size, const char* debug) {
+#if TRACE_PACKFILE
+    printf("PackFile_unpack(): Unpacking %ld bytes for %s table...\n", 
+        segment_size, debug);
+#endif
 
-/***************************************
-
-=item get_magic
-
-Get the PackFile's magic. You really should not need to use this, but it is
-here for completeness of the interface.
-
-=cut
-
-***************************************/
-
-opcode_t
-PackFile_get_magic(struct PackFile * self) {
-    return self->magic;
-}
-
-
-/***************************************
-
-=item set_magic
-
-Set the PackFile's magic. You really should not need to use this, but it is
-here for completeness of the interface.
-
-=cut
-
-***************************************/
-
-void
-PackFile_set_magic(struct PackFile * self, opcode_t magic) {
-    self->magic = magic;
-}
-
-
-/***************************************
-
-=item get_byte_code_size
-
-Get the size of the byte code.
-
-=cut
-
-***************************************/
-
-opcode_t
-PackFile_get_byte_code_size(struct PackFile * self) {
-    return self->byte_code_size;
-}
-
-
-/***************************************
-
-=item get_byte_code
-
-Get the byte code.
-
-NOTE: The memory is owned by the PackFile.
-
-=cut
-
-***************************************/
-
-opcode_t *
-PackFile_get_byte_code(struct PackFile * self) {
-    return self->byte_code;
-}
-
-
-/***************************************
-
-=item set_byte_code
-
-Set the byte code.
-
-NOTE: The PackFile makes its own copy of the byte code, so you still
-own the memory for the input byte code.
-
-=cut
-
-***************************************/
-
-void
-PackFile_set_byte_code(struct PackFile * self, size_t byte_code_size, opcode_t * 
byte_code) {
-    if (self->byte_code) {
-        mem_sys_free(self->byte_code);
-        self->byte_code = NULL;
-        self->byte_code_size = 0;
-    }
-
-    if (byte_code_size > 0 && byte_code) {
-        self->byte_code = mem_sys_allocate(byte_code_size);
-
-        if (!self->byte_code) {
-            fprintf(stderr, "Could not allocate buffer to copy byte code!\n");
-            return;
-        }
-
-        mem_sys_memcopy(self->byte_code, byte_code, byte_code_size);
-
-        self->byte_code_size = byte_code_size;
+    if (segment_size % sizeof(opcode_t)) {
+        fprintf(stderr, "PackFile_unpack: Illegal %s table segment size %ld (must be 
+multiple of %ld)!\n",
+            debug, segment_size, sizeof(opcode_t));
+        return 0;
     }
-
-    return;
+    return 1;
 }
 
 
@@ -297,20 +163,19 @@
         return 0;
     }
 
-    PackFile_clear(self);
-
     cursor = packed;
 
     /*
     ** Unpack and verify the magic:
     */
 
-    self->magic = *cursor;
-    cursor++;
+    {
+        opcode_t magic  = *cursor++;
 
-    if (self->magic != PARROT_MAGIC) {
-        fprintf(stderr, "PackFile_unpack: Not a Parrot PackFile!\n");
-        return 0;
+        if (magic != PARROT_MAGIC) {
+            fprintf(stderr, "PackFile_unpack: Not a Parrot PackFile!\n");
+            return 0;
+        }
     }
 
 #if TRACE_PACKFILE
@@ -321,16 +186,8 @@
     ** Unpack the Fixup Table Segment:
     */
 
-    segment_size = *cursor;
-    cursor++;
-
-#if TRACE_PACKFILE
-    printf("PackFile_unpack(): Unpacking %ld bytes for fixup table...\n", 
segment_size);
-#endif
-
-    if (segment_size % sizeof(opcode_t)) {
-        fprintf(stderr, "PackFile_unpack: Illegal fixup table segment size %d (must 
be multiple of %d)!\n",
-            (int)segment_size, sizeof(opcode_t));
+    segment_size = *cursor++;
+    if (!PackFile_check_segment_size(segment_size, "fixup")) {
         return 0;
     }
 
@@ -345,16 +202,8 @@
     ** Unpack the Constant Table Segment:
     */
 
-    segment_size = *cursor;
-    cursor++;
-
-#if TRACE_PACKFILE
-    printf("PackFile_unpack(): Unpacking %ld bytes for constant table...\n", 
segment_size);
-#endif
-
-    if (segment_size % sizeof(opcode_t)) {
-        fprintf(stderr, "PackFile_unpack: Illegal constant table segment size %d 
(must be multiple of %d)!\n",
-            (int)segment_size, sizeof(opcode_t));
+    segment_size = *cursor++;
+    if (!PackFile_check_segment_size(segment_size, "constant")) {
         return 0;
     }
 
@@ -369,12 +218,10 @@
     ** Unpack the Byte Code Segment:
     */
 
-    segment_size = *cursor;
-    cursor++;
-
-#if TRACE_PACKFILE
-    printf("PackFile_unpack(): Unpacking %ld bytes for byte code...\n", segment_size);
-#endif
+    segment_size = *cursor++;
+    if (!PackFile_check_segment_size(segment_size, "bytecode")) {
+        return 0;
+    }
 
     self->byte_code_size = segment_size;
 
@@ -395,215 +242,14 @@
     return ((size_t)(cursor - packed)*sizeof(opcode_t)) == packed_size;
 }
 
-
-/***************************************
-
-=item pack_size
-
-Determine the size of the buffer needed in order to pack the PackFile into a
-contiguous region of memory.
-
-=cut
-
-***************************************/
-
-opcode_t
-PackFile_pack_size(struct PackFile * self) {
-    opcode_t magic_size;
-    opcode_t segment_length_size;
-    opcode_t fixup_table_size;
-    opcode_t const_table_size;
-
-    magic_size          = sizeof(opcode_t);
-    segment_length_size = sizeof(opcode_t);
-
-#if TRACE_PACKFILE
-    printf("getting fixup table size...\n");
-#endif
-
-    fixup_table_size    = PackFile_FixupTable_pack_size(self->fixup_table);
-
-#if TRACE_PACKFILE
-    printf("  ... it is %ld\n", fixup_table_size);
-#endif
-
-#if TRACE_PACKFILE
-    printf("getting const table size...\n");
-#endif
-
-    const_table_size    = PackFile_ConstTable_pack_size(self->const_table);
-
-#if TRACE_PACKFILE
-    printf("  ... it is %ld\n", const_table_size);
-#endif
-
-    return magic_size
-        + segment_length_size + fixup_table_size
-        + segment_length_size + const_table_size
-        + segment_length_size + self->byte_code_size;
-}
-
-
-/***************************************
-
-=item pack
-
-Pack the PackFile into a contiguous region of memory. NOTE: The memory block
-had better have at least the amount of memory indicated by
-PackFile_pack_size()!
-
-=cut
-
-***************************************/
-
-void
-PackFile_pack(struct PackFile * self, opcode_t * packed) {
-    opcode_t * cursor              = packed;
-    opcode_t   fixup_table_size    = PackFile_FixupTable_pack_size(self->fixup_table);
-    opcode_t   const_table_size    = PackFile_ConstTable_pack_size(self->const_table);
-
-    /* Pack the magic */
-
-    *cursor = self->magic;
-    cursor++;
-
-    /* Pack the fixup table size, followed by the packed fixup table */
-
-    *cursor = fixup_table_size;
-    cursor++;
-
-    PackFile_FixupTable_pack(self->fixup_table, cursor);
-    cursor += fixup_table_size / sizeof(opcode_t); /* Sizes are in bytes */
-
-    /* Pack the constant table size, followed by the packed constant table */
-
-    *cursor = const_table_size;
-    cursor++;
-
-    PackFile_ConstTable_pack(self->const_table, cursor);
-    cursor += const_table_size / sizeof(opcode_t); /* Sizes are in bytes */
-
-    /* Pack the byte code size, followed by the byte code */
-
-    *cursor = self->byte_code_size;
-    cursor++;
-
-    if (self->byte_code_size) {
-        mem_sys_memcopy(cursor, self->byte_code, self->byte_code_size);
-    }
-
-    return;
-}
-
-
-/***************************************
-
-=item dump
-
-Dump the PackFile to standard out in a human-readable form.
-
-=cut
-
-***************************************/
-
-void
-PackFile_dump(struct PackFile * self) {
-    size_t i;
-
-    printf("MAGIC => 0x%08lx,\n", (unsigned long) self->magic);
-
-    printf("FIXUP => {\n");
-
-    PackFile_FixupTable_dump(self->fixup_table);
-
-    printf("},\n");
-
-    printf("CONST => [\n");
-
-    PackFile_ConstTable_dump(self->const_table);
-
-    printf("],\n");
-
-    printf("BCODE => [ # %ld bytes", (long)self->byte_code_size);
-
-    for (i = 0; i < self->byte_code_size / sizeof(opcode_t); i++) {
-        if (i % 8 == 0) {
-            printf("\n    %08lx:  ", (unsigned long) i * sizeof(opcode_t));
-        }
-        printf("%08lx ", (unsigned long) self->byte_code[i]);
-    }
-
-    printf("\n]\n");
-
-    return;
-}
-
-
 /*
 
 =back
 
-=cut
-
-*/
-
-
-/******************************************************************************
-
 =head2 PackFile FixupTable Structure Functions
 
 =over 4
 
-=cut
-
-******************************************************************************/
-
-
-/***************************************
-
-=item new
-
-Allocate a new empty PackFile FixupTable.
-
-=cut
-
-***************************************/
-
-struct PackFile_FixupTable *
-PackFile_FixupTable_new(void) {
-    struct PackFile_FixupTable * self = mem_sys_allocate((UINTVAL)sizeof(struct 
PackFile_FixupTable));
-
-    self->dummy = 0;
-
-    return self;
-}
-
-
-/***************************************
-
-=item DELETE
-
-Delete a PackFile FixupTable.
-
-=cut
-
-***************************************/
-
-void
-PackFile_FixupTable_DELETE(struct PackFile_FixupTable * self) {
-    if (!self) {
-        fprintf(stderr, "PackFile_FixupTable_DELETE: self == NULL!\n");
-        return;
-    }
-
-    mem_sys_free(self);
-
-    return;
-}
-
-
-/***************************************
-
 =item clear
 
 Clear a PackFile FixupTable.
@@ -637,136 +283,20 @@
 
 ***************************************/
 
-opcode_t
+BOOLVAL
 PackFile_FixupTable_unpack(struct PackFile_FixupTable * self, opcode_t * packed, 
opcode_t packed_size) {
     UNUSED (self); UNUSED (packed); UNUSED (packed_size);
     return 1;
 }
 
-
-/***************************************
-
-=item pack_size
-
-Determine the size of the buffer needed in order to pack the PackFile into a
-contiguous region of memory.
-
-=cut
-
-***************************************/
-
-opcode_t
-PackFile_FixupTable_pack_size(struct PackFile_FixupTable * self) {
-    UNUSED (self);
-    return 0;
-}
-
-
-/***************************************
-
-=item pack
-
-Pack the PackFile FixupTable into a contiguous region of memory. NOTE: The memory
-block had better have at least the amount of memory indicated by
-PackFile_FixupTable_pack_size()!
-
-=cut
-
-***************************************/
-
-void
-PackFile_FixupTable_pack(struct PackFile_FixupTable * self, opcode_t * packed) {
-    UNUSED (self); UNUSED (packed);
-    return;
-}
-
-
-/***************************************
-
-=item dump
-
-Dump the PackFile FixupTable to standard output.
-
-=cut
-
-***************************************/
-
-void
-PackFile_FixupTable_dump(struct PackFile_FixupTable * self) {
-    UNUSED (self);
-    return;
-}
-
-
-
 /*
 
 =back
 
-=cut
-
-*/
-
-
-/******************************************************************************
-
 =head2 PackFile ConstTable Structure Functions
 
 =over 4
 
-=cut
-
-******************************************************************************/
-
-
-/***************************************
-
-=item new
-
-Allocate a new empty PackFile ConstTable.
-
-=cut
-
-***************************************/
-
-struct PackFile_ConstTable *
-PackFile_ConstTable_new(void) {
-    struct PackFile_ConstTable * self = mem_sys_allocate((UINTVAL)sizeof(struct 
PackFile_ConstTable));
-
-    self->const_count = 0;
-    self->constants   = NULL;
-
-    return self;
-}
-
-
-/***************************************
-
-=item DELETE
-
-Delete a PackFile ConstTable.
-
-=cut
-
-***************************************/
-
-void
-PackFile_ConstTable_DELETE(struct PackFile_ConstTable * self) {
-    if (!self) {
-        fprintf(stderr, "PackFile_ConstTable_DELETE: self == NULL!\n");
-        return;
-    }
-
-    PackFile_ConstTable_clear(self);
-
-    mem_sys_free(self);
-
-    return;
-}
-
-
-/***************************************
-
 =item clear
 
 Clear a PackFile ConstTable.
@@ -780,16 +310,18 @@
     opcode_t i;
 
     if (!self) {
-        fprintf(stderr, "PackFile_ConstTable_DELETE: self == NULL!\n");
+        fprintf(stderr, "PackFile_ConstTable_clear: self == NULL!\n");
         return;
     }
 
     for(i = 0; i < self->const_count; i++) {
-        PackFile_Constant_DELETE(self->constants[i]);
+        PackFile_Constant_destroy(self->constants[i]);
         self->constants[i] = NULL;
     }
 
-    mem_sys_free(self->constants);
+    if (self->const_count) {
+        mem_sys_free(self->constants);
+    }
 
     self->constants   = NULL;
     self->const_count = 0;
@@ -797,100 +329,6 @@
     return;
 }
 
-
-/***************************************
-
-=item get_const_count
-
-Get the number of constants in the ConstTable.
-
-=cut
-
-***************************************/
-
-opcode_t
-PackFile_ConstTable_get_const_count(struct PackFile_ConstTable * self) {
-    if (!self) {
-        fprintf(stderr, "PackFile_ConstTable_get_const_count: self == NULL!\n");
-        return -1;
-    }
-
-    return self->const_count;
-}
-
-
-/***************************************
-
-=item push_constant
-
-Push a new Constant onto the ConstTable. Note: the Constant now belongs
-to the ConstTable.
-
-=cut
-
-***************************************/
-
-void
-PackFile_ConstTable_push_constant(struct PackFile_ConstTable * self, struct 
PackFile_Constant * constant) {
-    struct PackFile_Constant ** temp;
-    opcode_t                   i;
-
-    if (!self) {
-        fprintf(stderr, "PackFile_ConstTable_push_constant: self == NULL!\n");
-        return;
-    }
-
-    if (!constant) {
-        fprintf(stderr, "PackFile_ConstTable_push_constant: constant == NULL!\n");
-        return;
-    }
-
-    temp = mem_sys_allocate((self->const_count + 1) * sizeof(struct PackFile_Constant 
*));
-
-    if (!temp) {
-        fprintf(stderr, "Unable to reallocate Constant array to push a new 
Constant!\n");
-        return;
-    }
-
-    for (i = 0; i < self->const_count; i++) {
-        temp[i] = self->constants[i];
-    }
-
-    temp[self->const_count++] = constant;
-
-    mem_sys_free(self->constants);
-
-    self->constants = temp;
-
-    return;
-}
-
-
-/***************************************
-
-=item constant
-
-Retrieve a Constant from the ConstTable.
-
-=cut
-
-***************************************/
-
-struct PackFile_Constant *
-PackFile_ConstTable_constant(struct PackFile_ConstTable * self, opcode_t idx) {
-    if (!self) {
-        fprintf(stderr, "PackFile_ConstTable_constant: self == NULL!\n");
-        return NULL;
-    }
-
-    if (idx < 0 || idx >= self->const_count) {
-        return NULL;
-    }
-
-    return self->constants[idx];
-}
-
-
 /***************************************
 
 =item unpack
@@ -906,11 +344,10 @@
 
 ***************************************/
 
-opcode_t
+BOOLVAL
 PackFile_ConstTable_unpack(struct Parrot_Interp *interpreter, struct 
PackFile_ConstTable * self, opcode_t * packed, opcode_t packed_size) {
     opcode_t * cursor;
     opcode_t   i;
-    opcode_t   rc = 1;
 
     if (!self) {
         fprintf(stderr, "PackFile_ConstTable_unpack: self == NULL!\n");
@@ -921,8 +358,7 @@
 
     cursor = packed;
 
-    self->const_count = *cursor;
-    cursor++;
+    self->const_count = *cursor++;
 
 #if TRACE_PACKFILE
     printf("PackFile_ConstTable_unpack(): Unpacking %ld constants...\n", 
self->const_count);
@@ -941,143 +377,33 @@
     }
 
     for(i = 0; i < self->const_count; i++) {
+        BOOLVAL   rc;
 #if TRACE_PACKFILE
         printf("PackFile_ConstTable_unpack(): Unpacking constant %ld...\n", i);
 #endif
 
         self->constants[i] = PackFile_Constant_new();
         rc = PackFile_Constant_unpack(interpreter, self->constants[i], cursor, 
packed_size - (cursor - packed));
+        if (rc == 0) {
+            return 0;
+        }
         /* NOTE: It would be nice if each of these had its own length first */
 
         cursor += 
            PackFile_Constant_pack_size(self->constants[i])/sizeof(opcode_t);
     }
 
-    return rc;
-}
-
-
-/***************************************
-
-=item pack_size
-
-Determine the size of the buffer needed in order to pack the PackFile into a
-contiguous region of memory.
-
-=cut
-
-***************************************/
-
-opcode_t
-PackFile_ConstTable_pack_size(struct PackFile_ConstTable * self) {
-    opcode_t i;
-    opcode_t size = 0;
-
-    if (!self) {
-        fprintf(stderr, "PackFile_ConstTable_size: self == NULL!\n");
-        return -1;
-    }
-
-    for(i = 0; i < self->const_count; i++) {
-#if TRACE_PACKFILE
-        printf("  ... Getting size of constant #%ld...\n", i);
-#endif
-        size += PackFile_Constant_pack_size(self->constants[i]);
-    }
-
-    return sizeof(opcode_t) + size;
-}
-
-
-/***************************************
-
-=item pack
-
-Pack the PackFile ConstTable into a contiguous region of memory. NOTE: The memory
-block had better have at least the amount of memory indicated by
-PackFile_ConstTable_pack_size()!
-
-=cut
-
-***************************************/
-
-void
-PackFile_ConstTable_pack(struct PackFile_ConstTable * self, opcode_t * packed) {
-    opcode_t * cursor;
-    opcode_t   i;
-
-    if (!self) {
-        fprintf(stderr, "PackFile_ConstTable_pack: self == NULL!\n");
-        return;
-    }
-
-    cursor = packed;
-
-    *cursor = self->const_count;
-    cursor++;
-
-    for(i = 0; i < self->const_count; i++) {
-        PackFile_Constant_pack(self->constants[i], cursor);
-
-        cursor += 
-           PackFile_Constant_pack_size(self->constants[i])/sizeof(opcode_t);
-    }
-
-    return;
-}
-
-
-/***************************************
-
-=item dump
-
-Dump the PackFile ConstTable to standard output.
-
-=cut
-
-***************************************/
-
-void
-PackFile_ConstTable_dump(struct PackFile_ConstTable * self) {
-    opcode_t     i;
-
-    if (!self) {
-        fprintf(stderr, "PackFile_ConstTable_dump: self == NULL!\n");
-        return;
-    }
-
-    for(i = 0; i < self->const_count; i++) {
-        printf("    # %ld:\n", (long) i);
-        PackFile_Constant_dump(self->constants[i]);
-    }
-
-    return;
+    return 1;
 }
 
-
 /*
 
 =back
 
-=cut
-
-*/
-
-
-
-/******************************************************************************
-
 =head2 PackFile Constant Structure Functions
 
 =over 4
 
-=cut
-
-******************************************************************************
-
-
-***************************************
-
 =item new
 
 Allocate a new empty PackFile Constant.
@@ -1096,73 +422,9 @@
     return self;
 }
 
-
 /***************************************
 
-=item new_integer
-
-Allocate a new PackFile Constant containing an opcode_t.
-
-=cut
-
-***************************************/
-
-struct PackFile_Constant *
-PackFile_Constant_new_integer(opcode_t i) {
-    struct PackFile_Constant * self = mem_sys_allocate((UINTVAL)sizeof(struct 
PackFile_Constant));
-
-    self->type    = PFC_INTEGER;
-    self->integer = i;
-
-    return self;
-}
-
-
-/***************************************
-
-=item new_number
-
-Allocate a new PackFile Constant containing an FLOATVAL.
-
-=cut
-
-***************************************/
-
-struct PackFile_Constant *
-PackFile_Constant_new_number(FLOATVAL n) {
-    struct PackFile_Constant * self = mem_sys_allocate((UINTVAL)sizeof(struct 
PackFile_Constant));
-
-    self->type    = PFC_NUMBER;
-    self->number = n;
-
-    return self;
-}
-
-
-/***************************************
-
-=item new_string
-
-Allocate a new PackFile Constant containing a string.
-
-=cut
-
-***************************************/
-
-struct PackFile_Constant *
-PackFile_Constant_new_string(struct Parrot_Interp *interpreter, STRING * s) {
-    struct PackFile_Constant * self = mem_sys_allocate((UINTVAL)sizeof(struct 
PackFile_Constant));
-
-    self->type   = PFC_STRING;
-    self->string = string_copy(interpreter, s);
-
-    return self;
-}
-
-
-/***************************************
-
-=item DELETE
+=item destroy
 
 Delete a PackFile Constant.
 
@@ -1171,34 +433,9 @@
 ***************************************/
 
 void
-PackFile_Constant_DELETE(struct PackFile_Constant * self) {
-    if (!self) {
-        fprintf(stderr, "PackFile_Constant_DELETE: self == NULL!\n");
-        return;
-    }
-
-    PackFile_Constant_clear(self);
-
-    mem_sys_free(self);
-
-    return;
-}
-
-
-/***************************************
-
-=item clear
-
-Clear a PackFile Constant.
-
-=cut
-
-***************************************/
-
-void
-PackFile_Constant_clear(struct PackFile_Constant * self) {
+PackFile_Constant_destroy(struct PackFile_Constant * self) {
     if (!self) {
-        fprintf(stderr, "PackFile_Constant_clear: self == NULL!\n");
+        fprintf(stderr, "PackFile_Constant_destroy: self == NULL!\n");
         return;
     }
 
@@ -1206,10 +443,6 @@
         case PFC_NONE:
             break;
 
-        case PFC_INTEGER:
-            self->integer = 0;
-            break;
-
         case PFC_NUMBER:
             self->number = 0.0;
             break;
@@ -1227,32 +460,65 @@
             break;
     }
 
-    self->type     = PFC_NONE;
+    mem_sys_free(self);
 
     return;
 }
 
-
 /***************************************
 
-=item get_type
+=item pack_size
 
-Get the Constant type.
+Determine the size of the buffer needed in order to pack the PackFile Constant into a
+contiguous region of memory.
 
 =cut
 
 ***************************************/
 
 opcode_t
-PackFile_Constant_get_type(struct PackFile_Constant * self) {
+PackFile_Constant_pack_size(struct PackFile_Constant * self) {
+    opcode_t packed_size;
+    opcode_t padded_size;
+
     if (!self) {
-        /* TODO: Is it OK to be silent about this? */
-        return PFC_NONE;
+        /* TODO: OK to gloss over this? */
+        return (opcode_t) 0;
     }
 
-    return self->type;
-}
+    switch(self->type) {
+        case PFC_NONE:
+            packed_size = 0;
+            break;
+
+        case PFC_NUMBER:
+            packed_size = sizeof(FLOATVAL); /* XXX need to pad this? */
+            break;
+
+        case PFC_STRING:
+            padded_size = self->string->bufused;
+
+            if (padded_size % sizeof(opcode_t)) {
+                padded_size += sizeof(opcode_t) - (padded_size % sizeof(opcode_t));
+            }
+
+           /* Include space for flags, encoding, type, and size fields.  */
+            packed_size = 4 * sizeof(opcode_t) + padded_size;
+            break;
 
+        default:
+            packed_size = 0;
+            break;
+    }
+
+    /* Tack on space for the initial type and size fields */
+    if (packed_size) {
+        return packed_size + 2 * sizeof(opcode_t);
+    }
+    else {
+        return 0;
+    }
+}
 
 /***************************************
 
@@ -1285,45 +551,23 @@
 
     cursor    = packed;
 
-    type      = *cursor;
-    cursor++;
+    type      = *cursor++;
+    size      = *cursor++;
 
 #if TRACE_PACKFILE
     printf("PackFile_Constant_unpack(): Type is %ld ('%c')...\n", type, (char)type);
-#endif
-
-    size      = *cursor;
-    cursor++;
-
-#if TRACE_PACKFILE
     printf("PackFile_Constant_unpack(): Size is %ld...\n", size);
 #endif
 
     switch (type) {
         case PFC_NONE:
-#if TRACE_PACKFILE
-            rc = printf("PackFile_Constant_unpack(): Unpacking no-type 
constant...\n");
-#endif
-            break;
-
-        case PFC_INTEGER:
-#if TRACE_PACKFILE
-            printf("PackFile_Constant_unpack(): Unpacking integer constant...\n");
-#endif
-            rc = PackFile_Constant_unpack_integer(self, cursor, size);
             break;
 
         case PFC_NUMBER:
-#if TRACE_PACKFILE
-            printf("PackFile_Constant_unpack(): Unpacking number constant...\n");
-#endif
             rc = PackFile_Constant_unpack_number(self, cursor, size);
             break;
 
         case PFC_STRING:
-#if TRACE_PACKFILE
-            printf("PackFile_Constant_unpack(): Unpacking string constant...\n");
-#endif
             rc = PackFile_Constant_unpack_string(interpreter, self, cursor, size);
             break;
 
@@ -1336,46 +580,6 @@
     return rc;
 }
 
-
-/***************************************
-
-=item unpack_integer
-
-Unpack a PackFile Constant integer from a block of memory. The format is:
-
-  opcode_t value
-
-Returns one (1) if everything is OK, else zero (0).
-
-=cut
-
-***************************************/
-
-opcode_t
-PackFile_Constant_unpack_integer(struct PackFile_Constant * self, opcode_t * packed, 
opcode_t packed_size) {
-    opcode_t *   cursor;
-    opcode_t     value;
-
-    UNUSED (packed_size);
-
-    if (!self) {
-        return 0;
-    }
-
-    PackFile_Constant_clear(self);
-
-    cursor    = packed;
-
-    value     = *cursor;
-    cursor++;
-
-    self->type    = PFC_INTEGER;
-    self->integer = value;
-
-    return 1;
-}
-
-
 /***************************************
 
 =item unpack_number
@@ -1401,8 +605,6 @@
         return 0;
     }
 
-    PackFile_Constant_clear(self);
-
     cursor    = packed;
 
     /* We need to do a memcpy from the packed area to the value 
@@ -1456,302 +658,28 @@
         return 0;
     }
 
-    PackFile_Constant_clear(self);
-
     cursor    = packed;
 
-    flags     = (UINTVAL) *cursor; 
-    cursor++;
+    flags     = (UINTVAL) *cursor++; 
+    encoding  = *cursor++;
+    type      = *cursor++;
+    size      = (size_t) *cursor++; /* These may need to be separate */
 
 #if TRACE_PACKFILE
     printf("PackFile_Constant_unpack_string(): flags are 0x%04x...\n", flags);
-#endif
-
-    encoding  = *cursor;
-    cursor++;
-
-#if TRACE_PACKFILE
     printf("PackFile_Constant_unpack_string(): encoding is %ld...\n", encoding);
-#endif
-
-    type      = *cursor;
-    cursor++;
-
-#if TRACE_PACKFILE
     printf("PackFile_Constant_unpack_string(): type is %ld...\n", type);
-#endif
-
-    size      = (size_t) *cursor;
-    cursor++;
-
-#if TRACE_PACKFILE
     printf("PackFile_Constant_unpack_string(): size is %ld...\n", size);
 #endif
 
     self->type   = PFC_STRING;
-    if (encoding == 0) {
-        self->string = string_make(interpreter, cursor, size, NULL, flags,
-                                   NULL); /* fixme */
-    }
-    else if (encoding == 3) {
-        self->string = string_make(interpreter, cursor, size,
-                                   encoding_lookup("utf32"), flags,
-                                   chartype_lookup("unicode")); /* fixme */
-    }
-    else {
-      return 0;
-    }
-
-    return 1;
-}
-
-
-/***************************************
-
-=item pack_size
-
-Determine the size of the buffer needed in order to pack the PackFile Constant into a
-contiguous region of memory.
-
-=cut
-
-***************************************/
-
-opcode_t
-PackFile_Constant_pack_size(struct PackFile_Constant * self) {
-    opcode_t packed_size;
-    opcode_t padded_size;
-
-    if (!self) {
-        /* TODO: OK to gloss over this? */
-        return (opcode_t) 0;
-    }
-
-    switch(self->type) {
-        case PFC_NONE:
-            packed_size = 0;
-            break;
-
-        case PFC_INTEGER:
-            packed_size = sizeof(opcode_t);
-            break;
-
-        case PFC_NUMBER:
-            packed_size = sizeof(FLOATVAL); /* XXX need to pad this? */
-            break;
-
-        case PFC_STRING:
-            padded_size = self->string->bufused;
-
-            if (padded_size % sizeof(opcode_t)) {
-                padded_size += sizeof(opcode_t) - (padded_size % sizeof(opcode_t));
-            }
-
-           /* Include space for flags, encoding, type, and size fields.  */
-            packed_size = 4 * sizeof(opcode_t) + padded_size;
-            break;
-
-        default:
-            packed_size = 0;
-            break;
-    }
-
-    /* Tack on space for the initial type and size fields */
-    if (packed_size) {
-        return packed_size + 2 * sizeof(opcode_t);
-    }
-    else {
-        return 0;
-    }
-}
-
-
-/***************************************
-
-=item pack
-
-Pack the PackFile Constant into a contiguous region of memory. NOTE: The memory
-block had better have at least the amount of memory indicated by
-PackFile_Constant_pack_size()!
-
-The data is zero-padded to an opcode_t-boundary, so pad bytes may be added.
-(Note this padding is not yet implemented for FLOATVALs.)
-
-=cut
-
-***************************************/
-
-void
-PackFile_Constant_pack(struct PackFile_Constant * self, opcode_t * packed) {
-    opcode_t * cursor;
-    FLOATVAL *   nv_ptr;
-    char *     charcursor;
-    size_t       i;
-    opcode_t     padded_size;
-    opcode_t     packed_size;
-
-    if (!self) {
-        /* TODO: OK to be silent here? */
-        return;
-    }
-
-    cursor  = packed;
-
-    *cursor = self->type;
-    cursor++;
-
-    switch (self->type) {
-        case PFC_NONE:
-            *cursor = 0;
-            cursor++;
-
-            /* TODO: OK to be silent here? */
-            break;
-
-        case PFC_INTEGER:
-            *cursor = sizeof(opcode_t);
-            cursor++;
-
-            *cursor = self->integer;
-            cursor++;
-            break;
 
-        case PFC_NUMBER:
-            *cursor = sizeof(FLOATVAL);
-            cursor++;
-           /* XXX Use memcpy() to avoid alignment issues.
-              Also, do we need to pad things out to an opcode_t boundary?  
-              Consider gcc/x86, with opcode_t = (long long) and 
-              FLOATVAL = (long double):
-                   sizeof(long long) = 8
-                   sizeof(long double) = 12
-           */
-           mem_sys_memcopy(cursor,  &self->number, sizeof(FLOATVAL) );
-            cursor += sizeof(FLOATVAL)/sizeof(opcode_t); /* XXX */
-           /* XXX cursor is possibly wrong now (because of alignment
-              issues) but isn't returned from this function anyway!
-           */
-            break;
-
-        case PFC_STRING:
-            padded_size = self->string->bufused;
-
-            if (padded_size % sizeof(opcode_t)) {
-                padded_size += sizeof(opcode_t) - (padded_size % sizeof(opcode_t));
-            }
-
-           /* Include space for flags, encoding, type, and size fields.  */
-            packed_size = 4 * sizeof(opcode_t) + padded_size;
-
-            *cursor = packed_size;
-            cursor++;
-
-            *cursor = self->string->flags;
-            cursor++;
-
-            if (strcmp(self->string->type->name, "usascii") == 0 &&
-                strcmp(self->string->encoding->name, "singlebyte") == 0 ) {
-                *cursor = 0; /* fixme */
-            }
-            else if (strcmp(self->string->type->name, "unicode") == 0 &&
-                     strcmp(self->string->encoding->name, "utf32") == 0 ) {
-                *cursor = 3; /* fixme */
-            }
-            cursor++;
-
-            *cursor = 0; /* fixme */
-            cursor++;
-
-            *cursor = self->string->bufused;
-            cursor++;
-
-           /* Switch to char * since rest of string is addressed by
-              characters to ensure padding.  */
-           charcursor = (char *)cursor;
-
-            if (self->string->bufstart) {
-                mem_sys_memcopy(charcursor, self->string->bufstart, 
self->string->bufused);
-                charcursor += self->string->bufused;
-
-                if (self->string->bufused % sizeof(opcode_t)) {
-                    for(i = 0; i < (sizeof(opcode_t) - (self->string->bufused % 
sizeof(opcode_t))); i++) {
-                        charcursor[i] = 0;
-                    }
-                }
-            }
-           /* If cursor is needed below, uncomment the following and
-              ignore the gcc -Wcast-align warning.  charcursor is
-              guaranteed to be aligned correctly by the padding logic
-              above.
-           cursor = (opcode_t *) charcursor;
-           */
-            break;
-
-        default:
-            /* TODO: OK to be silent here? */
-            break;
-    }
-
-    return;
-}
-
-
-/***************************************
-
-=item dump
-
-Dump the PackFile Constant to standard output.
-
-=cut
-
-***************************************/
-
-void
-PackFile_Constant_dump(struct PackFile_Constant * self) {
-    if (!self) {
-        /* TODO: OK to be silent here? */
-        return;
-    }
-
-    switch (self->type) {
-        case PFC_NONE:
-            /* TODO: OK to be silent here? */
-            printf("    [ 'PFC_NONE', undef ],\n");
-            break;
-
-        case PFC_INTEGER:
-            printf("    [ 'PFC_INTEGER', %ld ],\n", (long) self->integer);
-            break;
-
-        case PFC_NUMBER:
-            printf("    [ 'PFC_NUMBER', %g ],\n", self->number);
-            break;
-
-        case PFC_STRING:
-            printf("    [ 'PFC_STRING', {\n");
-            printf("        FLAGS    => 0x%04lx,\n", (long) self->string->flags);
-            printf("        ENCODING => %s,\n",
-                    self->string->encoding->name);
-            printf("        TYPE     => %s,\n",
-                    self->string->type->name);
-            printf("        SIZE     => %ld,\n",
-                    (long) self->string->bufused);
-            /* TODO: Won't do anything reasonable for most encodings */
-            printf("        DATA     => '%.*s'\n",
-                   (int)self->string->bufused,
-                   (char *) self->string->bufstart);
-            printf("    } ],\n");
-            break;
-
-        default:
-            /* TODO: OK to be silent here? */
-            break;
-    }
+    self->string = string_make(interpreter, cursor, size,
+        encoding_lookup_index(encoding), flags,
+        chartype_lookup_index(type));
 
-    return;
+    return 1;
 }
-
-
 
 /*
 
Index: chartypes/unicode.c
===================================================================
RCS file: /cvs/public/parrot/chartypes/unicode.c,v
retrieving revision 1.9
diff -d -u -r1.9 unicode.c
--- chartypes/unicode.c 27 Jan 2002 11:33:55 -0000      1.9
+++ chartypes/unicode.c 11 Mar 2002 02:21:30 -0000
@@ -33,6 +33,7 @@
 }
 
 const CHARTYPE unicode_chartype = {
+    enum_chartype_unicode,
     "unicode",
     "utf32",
     unicode_transcode_from,
Index: chartypes/usascii.c
===================================================================
RCS file: /cvs/public/parrot/chartypes/usascii.c,v
retrieving revision 1.6
diff -d -u -r1.6 usascii.c
--- chartypes/usascii.c 22 Jan 2002 00:48:00 -0000      1.6
+++ chartypes/usascii.c 11 Mar 2002 02:21:30 -0000
@@ -56,6 +56,7 @@
 }
 
 const CHARTYPE usascii_chartype = {
+    enum_chartype_usascii,
     "usascii",
     "singlebyte",
     usascii_transcode_from,
Index: encodings/singlebyte.c
===================================================================
RCS file: /cvs/public/parrot/encodings/singlebyte.c,v
retrieving revision 1.12
diff -d -u -r1.12 singlebyte.c
--- encodings/singlebyte.c      14 Jan 2002 20:04:26 -0000      1.12
+++ encodings/singlebyte.c      11 Mar 2002 02:21:31 -0000
@@ -55,6 +55,7 @@
 }
 
 const ENCODING singlebyte_encoding = {
+    enum_encoding_singlebyte,
     "singlebyte",
     1,
     singlebyte_characters,
Index: encodings/utf16.c
===================================================================
RCS file: /cvs/public/parrot/encodings/utf16.c,v
retrieving revision 1.9
diff -d -u -r1.9 utf16.c
--- encodings/utf16.c   14 Jan 2002 20:04:26 -0000      1.9
+++ encodings/utf16.c   11 Mar 2002 02:21:31 -0000
@@ -123,6 +123,7 @@
 }
 
 const ENCODING utf16_encoding = {
+    enum_encoding_utf16,
     "utf16",
     UTF16_MAXLEN,
     utf16_characters,
Index: encodings/utf32.c
===================================================================
RCS file: /cvs/public/parrot/encodings/utf32.c,v
retrieving revision 1.7
diff -d -u -r1.7 utf32.c
--- encodings/utf32.c   14 Jan 2002 20:04:26 -0000      1.7
+++ encodings/utf32.c   11 Mar 2002 02:21:31 -0000
@@ -60,6 +60,7 @@
 }
 
 const ENCODING utf32_encoding = {
+    enum_encoding_utf32,
     "utf32",
     4,
     utf32_characters,
Index: encodings/utf8.c
===================================================================
RCS file: /cvs/public/parrot/encodings/utf8.c,v
retrieving revision 1.10
diff -d -u -r1.10 utf8.c
--- encodings/utf8.c    14 Jan 2002 20:04:26 -0000      1.10
+++ encodings/utf8.c    11 Mar 2002 02:21:31 -0000
@@ -120,6 +120,7 @@
 }
 
 const ENCODING utf8_encoding = {
+    enum_encoding_utf8,
     "utf8",
     UTF8_MAXLEN,
     utf8_characters,
Index: include/parrot/chartype.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/chartype.h,v
retrieving revision 1.5
diff -d -u -r1.5 chartype.h
--- include/parrot/chartype.h   28 Jan 2002 04:01:15 -0000      1.5
+++ include/parrot/chartype.h   11 Mar 2002 02:21:32 -0000
@@ -15,7 +15,14 @@
 
 typedef UINTVAL (*CHARTYPE_TRANSCODER)(UINTVAL c);
 
+enum {
+    enum_chartype_unicode,
+    enum_chartype_usascii,
+    enum_chartype_MAX
+};
+
 typedef struct {
+    INTVAL index;
     const char *name;
     const char *default_encoding;
     CHARTYPE_TRANSCODER (*transcode_from)(const char *from);
@@ -26,6 +33,9 @@
 
 const CHARTYPE *
 chartype_lookup(const char *name);
+
+const CHARTYPE *
+chartype_lookup_index(INTVAL n);
 
 CHARTYPE_TRANSCODER
 chartype_lookup_transcoder(const CHARTYPE *from, const CHARTYPE *to);
Index: include/parrot/encoding.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/encoding.h,v
retrieving revision 1.8
diff -d -u -r1.8 encoding.h
--- include/parrot/encoding.h   1 Jan 2002 20:23:46 -0000       1.8
+++ include/parrot/encoding.h   11 Mar 2002 02:21:32 -0000
@@ -13,7 +13,16 @@
 #if !defined(PARROT_ENCODING_H_GUARD)
 #define PARROT_ENCODING_H_GUARD
 
+enum {
+    enum_encoding_singlebyte,
+    enum_encoding_utf8,
+    enum_encoding_utf16,
+    enum_encoding_utf32,
+    enum_encoding_MAX
+};
+
 typedef struct {
+    INTVAL index;
     const char *name;
     UINTVAL max_bytes;
     UINTVAL (*characters)(const void *ptr, UINTVAL bytes);
@@ -25,6 +34,9 @@
 
 const ENCODING *
 encoding_lookup(const char *name);
+
+const ENCODING *
+encoding_lookup_index(INTVAL n);
 
 #endif
 
Index: include/parrot/packfile.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/packfile.h,v
retrieving revision 1.12
diff -d -u -r1.12 packfile.h
--- include/parrot/packfile.h   11 Feb 2002 17:57:11 -0000      1.12
+++ include/parrot/packfile.h   11 Mar 2002 02:21:32 -0000
@@ -21,7 +21,6 @@
 };
 
 #define PFC_NONE    '\0'
-#define PFC_INTEGER 'i'
 #define PFC_NUMBER  'n'
 #define PFC_STRING  's'
 
@@ -40,7 +39,6 @@
 
 
 struct PackFile {
-    opcode_t                     magic;
     struct PackFile_FixupTable * fixup_table;
     struct PackFile_ConstTable * const_table;
     size_t                       byte_code_size;  /* size in bytes */
@@ -56,100 +54,31 @@
 PackFile_new(void);
 
 void
-PackFile_DELETE(struct PackFile * self);
-
-void
-PackFile_clear(struct PackFile * self);
-
-opcode_t
-PackFile_get_magic(struct PackFile * self);
-
-void 
-PackFile_set_magic(struct PackFile * self, opcode_t magic);
-
-opcode_t
-PackFile_get_byte_code_size(struct PackFile * self);
-
-opcode_t *
-PackFile_get_byte_code(struct PackFile * self);
-
-void
-PackFile_set_byte_code(struct PackFile * self, size_t byte_code_size, opcode_t * 
byte_code);
+PackFile_destroy(struct PackFile * self);
 
 opcode_t
 PackFile_unpack(struct Parrot_Interp *interpreter, struct PackFile * self, opcode_t * 
packed, size_t packed_size);
 
-opcode_t
-PackFile_pack_size(struct PackFile * self);
-
-void
-PackFile_pack(struct PackFile * self, opcode_t * packed);
-
-void
-PackFile_dump(struct PackFile * self);
-
-
 /*
 ** PackFile_FixupTable Functions:
 */
 
-struct PackFile_FixupTable *
-PackFile_FixupTable_new(void);
-
-void
-PackFile_FixupTable_DELETE(struct PackFile_FixupTable * self);
-
 void
 PackFile_FixupTable_clear(struct PackFile_FixupTable * self);
 
-opcode_t
+BOOLVAL
 PackFile_FixupTable_unpack(struct PackFile_FixupTable * self, opcode_t * packed, 
opcode_t packed_size);
 
-opcode_t
-PackFile_FixupTable_pack_size(struct PackFile_FixupTable * self);
-
-void
-PackFile_FixupTable_pack(struct PackFile_FixupTable * self, opcode_t * packed);
-
-void
-PackFile_FixupTable_dump(struct PackFile_FixupTable * self);
-
-
 /*
 ** PackFile_ConstTable Functions:
 */
 
-struct PackFile_ConstTable *
-PackFile_ConstTable_new(void);
-
-void
-PackFile_ConstTable_DELETE(struct PackFile_ConstTable * self);
-
 void
 PackFile_ConstTable_clear(struct PackFile_ConstTable * self);
 
-opcode_t
-PackFile_ConstTable_get_const_count(struct PackFile_ConstTable * self);
-
-void
-PackFile_ConstTable_push_constant(struct PackFile_ConstTable * self, struct 
PackFile_Constant * constant);
-
-struct PackFile_Constant *
-PackFile_ConstTable_constant(struct PackFile_ConstTable * self, opcode_t idx);
-
-opcode_t
+BOOLVAL
 PackFile_ConstTable_unpack(struct Parrot_Interp *interpreter, struct 
PackFile_ConstTable * self, opcode_t * packed, opcode_t packed_size);
 
-opcode_t
-PackFile_ConstTable_pack_size(struct PackFile_ConstTable * self);
-
-void
-PackFile_ConstTable_pack(struct PackFile_ConstTable * self, opcode_t * packed);
-
-void
-PackFile_ConstTable_dump(struct PackFile_ConstTable * self);
-
-
 /*
 ** PackFile_Constant Functions:
 */
@@ -157,40 +86,13 @@
 struct PackFile_Constant *
 PackFile_Constant_new(void);
 
-struct PackFile_Constant *
-PackFile_Constant_new_integer(opcode_t i);
-
-struct PackFile_Constant *
-PackFile_Constant_new_number(FLOATVAL n);
-
-struct PackFile_Constant *
-PackFile_Constant_new_string(struct Parrot_Interp *interpreter, STRING * s);
-
-void
-PackFile_Constant_DELETE(struct PackFile_Constant * self);
-
-void
-PackFile_Constant_clear(struct PackFile_Constant * self);
-
-opcode_t
-PackFile_Constant_get_type(struct PackFile_Constant * self);
-
-void
-PackFile_Constant_set_integer(struct PackFile_Constant * self, opcode_t i);
-
-void
-PackFile_Constant_set_number(struct PackFile_Constant * self, FLOATVAL n);
-
 void
-PackFile_Constant_set_string(struct PackFile_Constant * self, STRING * s);
+PackFile_Constant_destroy(struct PackFile_Constant * self);
 
 opcode_t
 PackFile_Constant_unpack(struct Parrot_Interp *interpreter, struct PackFile_Constant 
* self, opcode_t * packed, opcode_t packed_size);
 
 opcode_t
-PackFile_Constant_unpack_integer(struct PackFile_Constant * self, opcode_t * packed, 
opcode_t packed_size);
-
-opcode_t
 PackFile_Constant_unpack_number(struct PackFile_Constant * self, opcode_t * packed, 
opcode_t packed_size);
 
 opcode_t
@@ -198,13 +100,6 @@
 
 opcode_t
 PackFile_Constant_pack_size(struct PackFile_Constant * self);
-
-void
-PackFile_Constant_pack(struct PackFile_Constant * self, opcode_t * packed);
-
-void
-PackFile_Constant_dump(struct PackFile_Constant * self);
-
 
 #endif /* PACKFILE_H */
 

Reply via email to