[svn:parrot] r38008 - branches/packfile_revamp/src/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Fri Apr 10 05:29:56 UTC 2009


Author: bacek
Date: Fri Apr 10 05:29:56 2009
New Revision: 38008
URL: https://trac.parrot.org/parrot/changeset/38008

Log:
Really unpack PackFile and set internal attributes.

Modified:
   branches/packfile_revamp/src/pmc/packfile.pmc

Modified: branches/packfile_revamp/src/pmc/packfile.pmc
==============================================================================
--- branches/packfile_revamp/src/pmc/packfile.pmc	Fri Apr 10 05:29:36 2009	(r38007)
+++ branches/packfile_revamp/src/pmc/packfile.pmc	Fri Apr 10 05:29:56 2009	(r38008)
@@ -125,20 +125,33 @@
 Implementation note: taken from the bottom end of Parrot_pbc_read().
 */
     VTABLE void set_string_native(STRING *str) {
-    /*
+        PackFile        *pf = PackFile_new(interp, 0);
+        const opcode_t  *ptr =
+                (const opcode_t*)Parrot_string_cstring(interp, str);
+        int             length = Parrot_str_byte_length(interp, str);
         Parrot_Packfile_attributes * attrs = PARROT_PACKFILE(SELF);
-        const opcode_t *ptr;
-        int length;
-        
-        ptr = (const opcode_t*)Parrot_string_cstring(interp, attrs->packed);
-        length = Parrot_str_byte_length(interp, str);
-        if (!PackFile_unpack(interp, attrs->pf, ptr, length))
+
+        if (!PackFile_unpack(interp, pf, ptr, length)) {
+            PackFile_destroy(interp, pf);
             Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_MALFORMED_PACKFILE,
                                         "Can't unpack packfile.");
+        }
+
+        /* Copy values from PackFile header to own attributes */
+        attrs->wordsize         = pf->header->wordsize;
+        attrs->byteorder        = pf->header->byteorder;
+        attrs->fptype           = pf->header->floattype;
+        attrs->version_major    = pf->header->major;
+        attrs->version_minor    = pf->header->minor;
+        attrs->version_patch    = pf->header->patch;
+        attrs->bytecode_major   = pf->header->bc_major;
+        attrs->bytecode_minor   = pf->header->bc_minor;
+        attrs->uuid_type        = pf->header->uuid_type;
+
+        attrs->uuid = Parrot_str_new(interp, (char*)pf->header->uuid_data,
+                pf->header->uuid_size);
 
-    */
-        /* Set :main routine */
-        //do_sub_pragmas(interp, attrs->pf->cur_cs, PBC_PBC, NULL);
+        PackFile_destroy(interp, pf);
     }
 
 


More information about the parrot-commits mailing list