[svn:parrot] r39561 - in branches/tt761_keys_revamp: include/parrot src
bacek at svn.parrot.org
bacek at svn.parrot.org
Sun Jun 14 10:16:47 UTC 2009
Author: bacek
Date: Sun Jun 14 10:16:46 2009
New Revision: 39561
URL: https://trac.parrot.org/parrot/changeset/39561
Log:
[core] Add pmc_reuse_init similar to pmc_reuse but with initing reused pmc.
Modified:
branches/tt761_keys_revamp/include/parrot/pmc.h
branches/tt761_keys_revamp/src/pmc.c
Modified: branches/tt761_keys_revamp/include/parrot/pmc.h
==============================================================================
--- branches/tt761_keys_revamp/include/parrot/pmc.h Sun Jun 14 10:16:20 2009 (r39560)
+++ branches/tt761_keys_revamp/include/parrot/pmc.h Sun Jun 14 10:16:46 2009 (r39561)
@@ -97,6 +97,18 @@
FUNC_MODIFIES(*pmc);
PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+PARROT_IGNORABLE_RESULT
+PMC * pmc_reuse_init(PARROT_INTERP,
+ ARGIN(PMC *pmc),
+ INTVAL new_type,
+ ARGIN(PMC *init),
+ NULLOK(UINTVAL flags))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(4);
+
+PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
INTVAL pmc_type(PARROT_INTERP, ARGIN_NULLOK(STRING *name))
__attribute__nonnull__(1);
@@ -151,6 +163,10 @@
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc) \
|| PARROT_ASSERT_ARG(class_)
+#define ASSERT_ARGS_pmc_reuse_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(pmc) \
+ || PARROT_ASSERT_ARG(init)
#define ASSERT_ARGS_pmc_type __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_pmc_type_p __attribute__unused__ int _ASSERT_ARGS_CHECK = \
Modified: branches/tt761_keys_revamp/src/pmc.c
==============================================================================
--- branches/tt761_keys_revamp/src/pmc.c Sun Jun 14 10:16:20 2009 (r39560)
+++ branches/tt761_keys_revamp/src/pmc.c Sun Jun 14 10:16:46 2009 (r39561)
@@ -50,6 +50,14 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(* pmc);
+PARROT_CANNOT_RETURN_NULL
+static PMC* pmc_reuse_no_init(PARROT_INTERP,
+ ARGIN(PMC *pmc),
+ INTVAL new_type,
+ SHIM(UINTVAL flags))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
#define ASSERT_ARGS_check_pmc_reuse_flags __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_create_class_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -59,6 +67,9 @@
#define ASSERT_ARGS_pmc_reuse_check_pmc_ext __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc)
+#define ASSERT_ARGS_pmc_reuse_no_init __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(pmc)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
@@ -145,9 +156,68 @@
PARROT_IGNORABLE_RESULT
PMC *
pmc_reuse(PARROT_INTERP, ARGIN(PMC *pmc), INTVAL new_type,
- SHIM(UINTVAL flags))
+ UINTVAL flags)
{
ASSERT_ARGS(pmc_reuse)
+ pmc = pmc_reuse_no_init(interp, pmc, new_type, flags);
+
+ /* Call the base init for the redone pmc. Warning, this should not
+ be called on Object PMCs. */
+ VTABLE_init(interp, pmc);
+
+ return pmc;
+}
+
+/*
+
+=item C<PMC * pmc_reuse_init(PARROT_INTERP, PMC *pmc, INTVAL new_type, PMC
+*init, UINTVAL flags)>
+
+Reuse an existing PMC, turning it into an PMC of the new type. Any
+required internal structure will be put in place (such as the extension area)
+and the PMC will be inited.
+
+Cannot currently handle converting a non-Object PMC into an Object. Use
+C<pmc_reuse_by_class> for that.
+
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PARROT_CANNOT_RETURN_NULL
+PARROT_IGNORABLE_RESULT
+PMC *
+pmc_reuse_init(PARROT_INTERP, ARGIN(PMC *pmc), INTVAL new_type, ARGIN(PMC *init),
+ UINTVAL flags)
+{
+ ASSERT_ARGS(pmc_reuse_init)
+ pmc = pmc_reuse_no_init(interp, pmc, new_type, flags);
+
+ /* Call the base init for the redone pmc. Warning, this should not
+ be called on Object PMCs. */
+ VTABLE_init_pmc(interp, pmc, init);
+
+ return pmc;
+}
+
+/*
+
+=item C<static PMC* pmc_reuse_no_init(PARROT_INTERP, PMC *pmc, INTVAL new_type,
+UINTVAL flags)>
+
+Prepare pmc for reuse. Do all scuffolding except initing.
+
+=cut
+
+*/
+PARROT_CANNOT_RETURN_NULL
+static PMC*
+pmc_reuse_no_init(PARROT_INTERP, ARGIN(PMC *pmc), INTVAL new_type,
+ SHIM(UINTVAL flags)) {
+
+ ASSERT_ARGS(pmc_reuse_no_init)
VTABLE *new_vtable;
INTVAL has_ext, new_flags = 0;
@@ -171,10 +241,6 @@
/* Set the right vtable */
pmc->vtable = new_vtable;
- /* Call the base init for the redone pmc. Warning, this should not
- be called on Object PMCs. */
- VTABLE_init(interp, pmc);
-
return pmc;
}
More information about the parrot-commits
mailing list