[svn:parrot] r39403 - in branches/pmc_i_ops: config/init runtime/parrot/languages/parrot src/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Fri Jun 5 13:03:45 UTC 2009


Author: bacek
Date: Fri Jun  5 13:03:40 2009
New Revision: 39403
URL: https://trac.parrot.org/parrot/changeset/39403

Log:
Merge branch 'master' into pmc_i_ops

Modified:
   branches/pmc_i_ops/config/init/defaults.pm
   branches/pmc_i_ops/runtime/parrot/languages/parrot/parrot.pir
   branches/pmc_i_ops/src/pmc/stringhandle.pmc
   branches/pmc_i_ops/src/pmc/sub.pmc

Modified: branches/pmc_i_ops/config/init/defaults.pm
==============================================================================
--- branches/pmc_i_ops/config/init/defaults.pm	Fri Jun  5 09:28:47 2009	(r39402)
+++ branches/pmc_i_ops/config/init/defaults.pm	Fri Jun  5 13:03:40 2009	(r39403)
@@ -206,9 +206,6 @@
         make_set_make => $Config{make_set_make},
         make_and      => '&&',
 
-        # for cygwin
-        cygchkdll => '',
-
         # make_c: Command to emulate GNU make's C<-C directory> option:  chdir
         # to C<directory> before executing $(MAKE)
         make_c => '$(PERL) -e \'chdir shift @ARGV; system q{$(MAKE)}, @ARGV; exit $$? >> 8;\'',

Modified: branches/pmc_i_ops/runtime/parrot/languages/parrot/parrot.pir
==============================================================================
--- branches/pmc_i_ops/runtime/parrot/languages/parrot/parrot.pir	Fri Jun  5 09:28:47 2009	(r39402)
+++ branches/pmc_i_ops/runtime/parrot/languages/parrot/parrot.pir	Fri Jun  5 13:03:40 2009	(r39403)
@@ -30,7 +30,8 @@
     library['name'] = name
     library['filename'] = file
     # If this fails, we should build a hash of DEFAULT and ALL => the normal ns
-    $P0 = get_hll_global name, 'EXPORT'
+    $P0 = get_hll_namespace name
+    $P0 = $P0['EXPORT']
     library['symbols'] = $P0
     $P0 = get_hll_namespace name
     library['namespace'] = $P0

Modified: branches/pmc_i_ops/src/pmc/stringhandle.pmc
==============================================================================
--- branches/pmc_i_ops/src/pmc/stringhandle.pmc	Fri Jun  5 09:28:47 2009	(r39402)
+++ branches/pmc_i_ops/src/pmc/stringhandle.pmc	Fri Jun  5 13:03:40 2009	(r39403)
@@ -11,15 +11,40 @@
 The StringHandle PMC performs I/O operations, but on an internal string rather
 than an external file. Commonly used as a mock FileHandle for testing.
 
-=head2 Vtable Functions
+=cut
+
+*/
+
+#include "../src/io/io_private.h"
+
+PARROT_INLINE
+static int encoding_is_utf8(PARROT_INTERP, ARGIN_NULLOK(STRING *s));
+
+/*
+
+=head2 Internal Functions
 
 =over 4
 
+=item C<static int encoding_is_utf8()>
+
+Helper function for internal usage. Return 1 if the string argument is
+not null and has utf8 encoding, 0 otherwise.
+
+=back
+
 =cut
 
 */
 
-#include "../src/io/io_private.h"
+PARROT_INLINE
+static int encoding_is_utf8(PARROT_INTERP, ARGIN_NULLOK(STRING *s))
+{
+    if (STRING_IS_NULL(s))
+        return 0;
+    else
+        return Parrot_str_equal(interp, s, CONST_STRING(interp, "utf8"));
+}
 
 pmclass StringHandle need_ext {
     ATTR INTVAL  flags;               /* Filehandle flags             */
@@ -31,6 +56,10 @@
 
 /*
 
+=head2 Vtable Functions
+
+=over 4
+
 =item C<void init()>
 
 Initializes a newly created StringHandle object.
@@ -176,8 +205,7 @@
             STRING *encoding;
 
             GET_ATTR_encoding(INTERP, SELF, encoding);
-            if (!STRING_IS_NULL(encoding)
-            &&  Parrot_str_equal(INTERP, encoding, CONST_STRING(INTERP, "utf8")))
+            if (encoding_is_utf8(INTERP, encoding))
                 new_string = string_make(INTERP, "", 0, "unicode", 0);
             else
                 new_string = Parrot_str_new(INTERP, "", 0);
@@ -343,9 +371,7 @@
         if (STRING_IS_NULL(string_result)) {
             STRING *encoding;
             GET_ATTR_encoding(INTERP, SELF, encoding);
-            if (!STRING_IS_NULL(encoding) &&
-                    Parrot_str_equal(INTERP, encoding,
-                        Parrot_str_new_constant(INTERP, "utf8")))
+            if (encoding_is_utf8(INTERP, encoding))
                 string_result = string_make(INTERP, "", 0, "unicode", 0);
             else
                 string_result = Parrot_str_new_constant(INTERP, "");
@@ -432,9 +458,9 @@
 
     METHOD buffer_type(STRING *new_type :optional, INTVAL got_type :opt_flag) {
         INTVAL flags;
-        STRING * const nobuffer_string   = Parrot_str_new_constant(INTERP, "unbuffered");
-        STRING * const linebuffer_string = Parrot_str_new_constant(INTERP, "line-buffered");
-        STRING * const fullbuffer_string = Parrot_str_new_constant(INTERP, "full-buffered");
+        STRING * const nobuffer_string   = CONST_STRING(INTERP, "unbuffered");
+        STRING * const linebuffer_string = CONST_STRING(INTERP, "line-buffered");
+        STRING * const fullbuffer_string = CONST_STRING(INTERP, "full-buffered");
 
         GET_ATTR_flags(INTERP, SELF, flags);
 

Modified: branches/pmc_i_ops/src/pmc/sub.pmc
==============================================================================
--- branches/pmc_i_ops/src/pmc/sub.pmc	Fri Jun  5 09:28:47 2009	(r39402)
+++ branches/pmc_i_ops/src/pmc/sub.pmc	Fri Jun  5 13:03:40 2009	(r39403)
@@ -440,20 +440,21 @@
         if (other->vtable->base_type == SELF->vtable->base_type) {
             Parrot_sub *my_sub;
             Parrot_sub *other_sub;
+            PMC_get_sub(INTERP, SELF, my_sub);
+            PMC_get_sub(INTERP, other, other_sub);
 
+            /* Increase reference count of destination before
+             * freeing the one in self, to avoid problems in
+             * case of self assignment */
+            if (other_sub->ctx)
+                Parrot_context_ref(interp, other_sub->ctx);
             /* get rid of this context, if attached */
-            PMC_get_sub(INTERP, SELF, my_sub);
             if (my_sub->ctx)
                 Parrot_free_context(INTERP, my_sub->ctx, 1);
 
             /* copy the sub struct */
-            PMC_get_sub(INTERP, other, other_sub);
             memmove(my_sub, other_sub, sizeof (Parrot_sub));
 
-            /* attach to the new context, if it exists */
-            if (my_sub->ctx)
-                Parrot_context_ref(interp, my_sub->ctx);
-
             /* copy the name so it's a different string in memory */
             if (my_sub->name)
                 my_sub->name = Parrot_str_copy(INTERP, my_sub->name);


More information about the parrot-commits mailing list