[svn:parrot] r42860 - in branches/cs_csr_merge: include/parrot src src/call

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Dec 2 12:56:18 UTC 2009


Author: bacek
Date: Wed Dec  2 12:56:17 2009
New Revision: 42860
URL: https://trac.parrot.org/parrot/changeset/42860

Log:
Move append_result function from src/extend.c into src/call/args.c

We need direct access to CallSignature guts.

Modified:
   branches/cs_csr_merge/include/parrot/call.h
   branches/cs_csr_merge/include/parrot/extend.h
   branches/cs_csr_merge/src/call/args.c
   branches/cs_csr_merge/src/extend.c

Modified: branches/cs_csr_merge/include/parrot/call.h
==============================================================================
--- branches/cs_csr_merge/include/parrot/call.h	Wed Dec  2 10:07:53 2009	(r42859)
+++ branches/cs_csr_merge/include/parrot/call.h	Wed Dec  2 12:56:17 2009	(r42860)
@@ -154,6 +154,16 @@
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 
 PARROT_EXPORT
+void Parrot_pcc_append_result(PARROT_INTERP,
+    ARGIN(PMC *sig_object),
+    ARGIN(STRING *type),
+    ARGIN(void *result))
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3)
+        __attribute__nonnull__(4);
+
+PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 PMC* Parrot_pcc_build_sig_object_from_op(PARROT_INTERP,
@@ -253,6 +263,11 @@
         FUNC_MODIFIES(*arg_flags)
         FUNC_MODIFIES(*return_flags);
 
+#define ASSERT_ARGS_Parrot_pcc_append_result __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp) \
+    , PARROT_ASSERT_ARG(sig_object) \
+    , PARROT_ASSERT_ARG(type) \
+    , PARROT_ASSERT_ARG(result))
 #define ASSERT_ARGS_Parrot_pcc_build_sig_object_from_op \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \

Modified: branches/cs_csr_merge/include/parrot/extend.h
==============================================================================
--- branches/cs_csr_merge/include/parrot/extend.h	Wed Dec  2 10:07:53 2009	(r42859)
+++ branches/cs_csr_merge/include/parrot/extend.h	Wed Dec  2 12:56:17 2009	(r42860)
@@ -452,15 +452,6 @@
         __attribute__nonnull__(2)
         __attribute__nonnull__(3);
 
-void append_result(PARROT_INTERP,
-    ARGIN(PMC *sig_object),
-    ARGIN(Parrot_String type),
-    ARGIN(void *result))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        __attribute__nonnull__(4);
-
 #define ASSERT_ARGS_Parrot_call_method __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(signature))
@@ -604,11 +595,6 @@
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(pio) \
     , PARROT_ASSERT_ARG(s))
-#define ASSERT_ARGS_append_result __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(sig_object) \
-    , PARROT_ASSERT_ARG(type) \
-    , PARROT_ASSERT_ARG(result))
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/extend.c */
 

Modified: branches/cs_csr_merge/src/call/args.c
==============================================================================
--- branches/cs_csr_merge/src/call/args.c	Wed Dec  2 10:07:53 2009	(r42859)
+++ branches/cs_csr_merge/src/call/args.c	Wed Dec  2 12:56:17 2009	(r42860)
@@ -3193,6 +3193,81 @@
 
 /*
 
+=item C<void Parrot_pcc_append_result(PARROT_INTERP, PMC *sig_object, STRING
+*type, void *result)>
+
+Helper function between old and new style PCC to append return pointer to signature.
+
+To be removed with deprecated functions.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_pcc_append_result(PARROT_INTERP, ARGIN(PMC *sig_object), ARGIN(STRING *type), ARGIN(void *result))
+{
+    ASSERT_ARGS(Parrot_pcc_append_result)
+    STRING *full_sig;
+    PMC    *return_flags;
+    INTVAL  return_flags_size;
+
+    Parrot_String return_flags_name = Parrot_str_new_constant(interp, "return_flags");
+    Parrot_String sig_name          = Parrot_str_new_constant(interp, "signature");
+
+    full_sig = VTABLE_get_string(interp, sig_object);
+    /* Append ->[T] */
+    Parrot_str_concat(interp, full_sig, Parrot_str_new_constant(interp, "->"), 0);
+    Parrot_str_concat(interp, full_sig, type, 0);
+
+    csr_set_pointer_keyed_int(interp, sig_object, csr_elements(interp, sig_object), result);
+
+    /* Update returns_flag */
+    return_flags = VTABLE_get_attr_str(interp, sig_object, return_flags_name);
+    if (PMC_IS_NULL(return_flags)) {
+        /* Create return_flags for single element */
+        return_flags = pmc_new(interp, enum_class_FixedIntegerArray);
+        return_flags_size = 0;
+        VTABLE_set_integer_native(interp, return_flags, 1);
+        VTABLE_set_attr_str(interp, sig_object, return_flags_name, return_flags);
+    }
+    else {
+        /* Extend return_flags by one element */
+        return_flags_size = VTABLE_elements(interp, return_flags);
+        VTABLE_set_integer_native(interp, return_flags, return_flags_size + 1);
+    }
+    switch (Parrot_str_indexed(interp, type, 0)) {
+        case 'I':
+            VTABLE_set_integer_keyed_int(interp, return_flags, return_flags_size,
+                    PARROT_ARG_INTVAL);
+            csr_push_integer(interp, sig_object, PARROT_ARG_INTVAL);
+            break;
+        case 'N':
+            VTABLE_set_integer_keyed_int(interp, return_flags, return_flags_size,
+                    PARROT_ARG_FLOATVAL);
+            csr_push_integer(interp, sig_object, PARROT_ARG_FLOATVAL);
+            break;
+        case 'S':
+            VTABLE_set_integer_keyed_int(interp, return_flags, return_flags_size,
+                    PARROT_ARG_STRING);
+            csr_push_integer(interp, sig_object, PARROT_ARG_STRING);
+            break;
+        case 'P':
+            VTABLE_set_integer_keyed_int(interp, return_flags, return_flags_size,
+                    PARROT_ARG_PMC);
+            csr_push_integer(interp, sig_object, PARROT_ARG_PMC);
+            break;
+        default:
+            Parrot_ex_throw_from_c_args(interp, NULL,
+                EXCEPTION_INVALID_OPERATION,
+                "invalid signature string element!");
+    }
+
+}
+
+/*
+
 =back
 
 =head1 SEE ALSO

Modified: branches/cs_csr_merge/src/extend.c
==============================================================================
--- branches/cs_csr_merge/src/extend.c	Wed Dec  2 10:07:53 2009	(r42859)
+++ branches/cs_csr_merge/src/extend.c	Wed Dec  2 12:56:17 2009	(r42860)
@@ -1011,87 +1011,6 @@
 
 /*
 
-=item C<void append_result(PARROT_INTERP, PMC *sig_object, Parrot_String type,
-void *result)>
-
-Helper function between old and new style PCC to append return pointer to signature.
-
-To be removed with deprecated functions.
-
-=cut
-
-*/
-
-void
-append_result(PARROT_INTERP, ARGIN(PMC *sig_object), ARGIN(Parrot_String type), ARGIN(void *result))
-{
-    ASSERT_ARGS(append_result)
-    Parrot_String full_sig;
-    Parrot_PMC    returns;
-    Parrot_PMC    return_flags;
-    Parrot_Int    return_flags_size;
-
-    Parrot_String return_name       = Parrot_str_new_constant(interp, "returns");
-    Parrot_String return_flags_name = Parrot_str_new_constant(interp, "return_flags");
-    Parrot_String sig_name          = Parrot_str_new_constant(interp, "signature");
-
-    full_sig = VTABLE_get_string(interp, sig_object);
-    /* Append ->[T] */
-    Parrot_str_concat(interp, full_sig, Parrot_str_new_constant(interp, "->"), 0);
-    Parrot_str_concat(interp, full_sig, type, 0);
-
-    returns = VTABLE_get_attr_str(interp, sig_object, return_name);
-    if (PMC_IS_NULL(returns)) {
-        returns = pmc_new(interp, enum_class_CallSignatureReturns);
-        VTABLE_set_attr_str(interp, sig_object, return_name, returns);
-    }
-    VTABLE_set_pointer_keyed_int(interp, returns, VTABLE_elements(interp, returns), result);
-
-    /* Update returns_flag */
-    return_flags = VTABLE_get_attr_str(interp, sig_object, return_flags_name);
-    if (PMC_IS_NULL(return_flags)) {
-        /* Create return_flags for single element */
-        return_flags = pmc_new(interp, enum_class_FixedIntegerArray);
-        return_flags_size = 0;
-        VTABLE_set_integer_native(interp, return_flags, 1);
-        VTABLE_set_attr_str(interp, sig_object, return_flags_name, return_flags);
-    }
-    else {
-        /* Extend return_flags by one element */
-        return_flags_size = VTABLE_elements(interp, return_flags);
-        VTABLE_set_integer_native(interp, return_flags, return_flags_size + 1);
-    }
-    switch (Parrot_str_indexed(interp, type, 0)) {
-        case 'I':
-            VTABLE_set_integer_keyed_int(interp, return_flags, return_flags_size,
-                    PARROT_ARG_INTVAL);
-            VTABLE_push_integer(interp, returns, PARROT_ARG_INTVAL);
-            break;
-        case 'N':
-            VTABLE_set_integer_keyed_int(interp, return_flags, return_flags_size,
-                    PARROT_ARG_FLOATVAL);
-            VTABLE_push_integer(interp, returns, PARROT_ARG_FLOATVAL);
-            break;
-        case 'S':
-            VTABLE_set_integer_keyed_int(interp, return_flags, return_flags_size,
-                    PARROT_ARG_STRING);
-            VTABLE_push_integer(interp, returns, PARROT_ARG_STRING);
-            break;
-        case 'P':
-            VTABLE_set_integer_keyed_int(interp, return_flags, return_flags_size,
-                    PARROT_ARG_PMC);
-            VTABLE_push_integer(interp, returns, PARROT_ARG_PMC);
-            break;
-        default:
-            Parrot_ex_throw_from_c_args(interp, NULL,
-                EXCEPTION_INVALID_OPERATION,
-                "invalid signature string element!");
-    }
-
-}
-
-/*
-
 =item C<void Parrot_ext_call(PARROT_INTERP, Parrot_PMC sub_pmc, const char
 *signature, ...)>
 
@@ -1194,7 +1113,7 @@
         case 'V':
         case 'P':
         {
-            append_result(interp, sig_object, Parrot_str_new_constant(interp, "P"), &result);
+            Parrot_pcc_append_result(interp, sig_object, Parrot_str_new_constant(interp, "P"), &result);
             break;
         }
         default:
@@ -1244,7 +1163,7 @@
     /* Add the return argument onto the call signature object (a bit
      * hackish, added for backward compatibility in deprecated API function,
      * see TT #1145). */
-    append_result(interp, sig_object, Parrot_str_new_constant(interp, "I"), &result);
+    Parrot_pcc_append_result(interp, sig_object, Parrot_str_new_constant(interp, "I"), &result);
     Parrot_pcc_invoke_from_sig_object(interp, sub_pmc, sig_object);
 
     return result;
@@ -1282,7 +1201,7 @@
     /* Add the return argument onto the call signature object (a bit
      * hackish, added for backward compatibility in deprecated API function,
      * see TT #1145). */
-    append_result(interp, sig_object, Parrot_str_new_constant(interp, "N"), &result);
+    Parrot_pcc_append_result(interp, sig_object, Parrot_str_new_constant(interp, "N"), &result);
     PMC_get_sub(interp, sub_pmc, sub);
     Parrot_pcc_set_constants(interp, CURRENT_CONTEXT(interp), sub->seg->const_table->constants);
     Parrot_pcc_invoke_from_sig_object(interp, sub_pmc, sig_object);
@@ -1342,7 +1261,8 @@
         case 'V':
         case 'P':
         {
-            append_result(interp, sig_object, Parrot_str_new_constant(interp, "P"), &result);
+            Parrot_pcc_append_result(interp, sig_object, Parrot_str_new_constant(interp, "P"),
+                    &result);
             break;
         }
         default:
@@ -1393,7 +1313,7 @@
     va_end(args);
     free(arg_sig);
 
-    append_result(interp, sig_object, Parrot_str_new_constant(interp, "I"), &result);
+    Parrot_pcc_append_result(interp, sig_object, Parrot_str_new_constant(interp, "I"), &result);
     PMC_get_sub(interp, sub_pmc, sub);
     Parrot_pcc_set_constants(interp, CURRENT_CONTEXT(interp), sub->seg->const_table->constants);
     Parrot_pcc_invoke_from_sig_object(interp, sub_pmc, sig_object);
@@ -1434,7 +1354,7 @@
     va_end(args);
     free(arg_sig);
 
-    append_result(interp, sig_object, Parrot_str_new_constant(interp, "N"), &result);
+    Parrot_pcc_append_result(interp, sig_object, Parrot_str_new_constant(interp, "N"), &result);
     PMC_get_sub(interp, sub_pmc, sub);
     Parrot_pcc_set_constants(interp, CURRENT_CONTEXT(interp), sub->seg->const_table->constants);
     Parrot_pcc_invoke_from_sig_object(interp, sub_pmc, sig_object);


More information about the parrot-commits mailing list