Author: petdance
Date: Fri Jun 15 21:42:33 2007
New Revision: 19036
Modified:
trunk/config/gen/makefiles/root.in
trunk/include/parrot/sub.h
trunk/src/sub.c
Log:
headerized sub.c
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in (original)
+++ trunk/config/gen/makefiles/root.in Fri Jun 15 21:42:33 2007
@@ -1868,6 +1868,7 @@
src/stacks.o \
src/string.o \
src/string_primitives.o \
+ src/sub.o \
src/trace.o \
src/tsq.o \
src/utils.o \
Modified: trunk/include/parrot/sub.h
==============================================================================
--- trunk/include/parrot/sub.h (original)
+++ trunk/include/parrot/sub.h Fri Jun 15 21:42:33 2007
@@ -1,5 +1,5 @@
/* sub.h
- * Copyright (C) 2001-2003, The Perl Foundation.
+ * Copyright (C) 2001-2007, The Perl Foundation.
* SVN Info
* $Id$
* Overview:
@@ -206,25 +206,62 @@
} Parrot_Context_info;
/* HEADERIZER BEGIN: src/sub.c */
-/* HEADERIZER END: src/sub.c */
-
-struct Parrot_sub * new_sub(Interp * interp);
-struct Parrot_sub * new_closure(Interp * interp);
-struct Parrot_coro * new_coroutine(Interp * interp);
-struct Parrot_cont * new_continuation(Interp * interp, struct Parrot_cont *to);
-struct Parrot_cont * new_ret_continuation(Interp * interp);
-
-PARROT_API PMC * new_ret_continuation_pmc(Interp *, opcode_t * address);
-void mark_context(Interp *, parrot_context_t *);
+PARROT_API PMC * new_ret_continuation_pmc( Interp *interp /*NN*/,
+ opcode_t *address )
+ __attribute__nonnull__(1);
+
+PARROT_API int Parrot_Context_get_info( Interp *interp /*NN*/,
+ parrot_context_t *ctx /*NN*/,
+ Parrot_Context_info *info /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
+
+PARROT_API STRING* Parrot_Context_infostr( Interp *interp /*NN*/,
+ parrot_context_t *ctx /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_API STRING* Parrot_full_sub_name( Interp *interp /*NN*/,
+ PMC* sub /*NULLOK*/ )
+ __attribute__nonnull__(1);
+
+PARROT_API PMC* parrot_new_closure( Interp *interp /*NN*/, PMC *sub_pmc )
+ __attribute__nonnull__(1);
+
+void invalidate_retc_context( Interp *interp /*NN*/, PMC *cont /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+void mark_context( Interp *interp /*NN*/, parrot_context_t* ctx /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+Parrot_sub * new_closure( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1);
+
+Parrot_cont * new_continuation( Interp *interp /*NN*/,
+ Parrot_cont *to /*NULLOK*/ )
+ __attribute__nonnull__(1);
+
+Parrot_coro * new_coroutine( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1);
+
+Parrot_cont * new_ret_continuation( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1);
+
+Parrot_sub * new_sub( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1);
+
+PMC* Parrot_find_pad( Interp *interp /*NN*/,
+ STRING *lex_name,
+ parrot_context_t *ctx /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(3);
-void invalidate_retc_context(Interp *interp, PMC *cont);
-
-PARROT_API STRING* Parrot_full_sub_name(Interp *interp, PMC* sub);
-PARROT_API int Parrot_Context_get_info(Interp *interp, parrot_context_t *,
Parrot_Context_info *);
-PARROT_API STRING* Parrot_Context_infostr(Interp *interp, parrot_context_t *);
+/* HEADERIZER END: src/sub.c */
-PARROT_API PMC* Parrot_find_pad(Interp*, STRING *lex_name, parrot_context_t *);
PARROT_API PMC* parrot_new_closure(Interp*, PMC*);
#endif /* PARROT_SUB_H_GUARD */
Modified: trunk/src/sub.c
==============================================================================
--- trunk/src/sub.c (original)
+++ trunk/src/sub.c Fri Jun 15 21:42:33 2007
@@ -12,28 +12,23 @@
=head2 Functions
-=over 4
-
-=cut
-
*/
#include "parrot/parrot.h"
#include "parrot/oplib/ops.h"
+/* HEADER: include/parrot/sub.h */
+
/*
-=item C<void
-mark_context(Interp *interp, parrot_context_t* ctx)>
+FUNCDOC: mark_context
Marks the context C<*ctx>.
-=cut
-
*/
void
-mark_context(Interp *interp, parrot_context_t* ctx /*NN*/)
+mark_context(Interp *interp /*NN*/, parrot_context_t* ctx /*NN*/)
{
PObj *obj;
int i;
@@ -77,17 +72,14 @@
/*
-=item C<Parrot_sub *
-new_sub(Interp *interp)>
+FUNCDOC: new_sub
Returns a new C<Parrot_sub>.
-=cut
-
*/
Parrot_sub *
-new_sub(Interp *interp)
+new_sub(Interp *interp /*NN*/)
{
/* Using system memory until I figure out GC issues */
Parrot_sub * const newsub = mem_allocate_zeroed_typed(Parrot_sub);
@@ -97,38 +89,33 @@
/*
-=item C<Parrot_sub *
-new_closure(Interp *interp)>
+FUNCDOC: new_closure
Returns a new C<Parrot_sub> with its own sctatchpad.
XXX: Need to document semantics in detail.
-=cut
-
*/
Parrot_sub *
-new_closure(Interp *interp)
+new_closure(Interp *interp /*NN*/)
{
Parrot_sub * const newsub = new_sub(interp);
return newsub;
}
+
/*
-=item C<Parrot_cont *
-new_continuation(Interp *interp, Parrot_cont *to)>
+FUNCDOC: new_continuation
Returns a new C<Parrot_cont> to the context of C<to> with its own copy of the
current interpreter context. If C<to> is C<NULL>, then the C<to_ctx> is set
to the current context.
-=cut
-
*/
Parrot_cont *
-new_continuation(Interp *interp, Parrot_cont *to)
+new_continuation(Interp *interp /*NN*/, Parrot_cont *to /*NULLOK*/)
{
Parrot_cont * const cc = mem_allocate_typed(Parrot_cont);
Parrot_Context * const to_ctx = to ? to->to_ctx : CONTEXT(interp->ctx);
@@ -152,19 +139,17 @@
/*
-=item C<Parrot_cont *
-new_ret_continuation(Interp *interp)>
+FUNCDOC: new_ret_continuation
Returns a new C<Parrot_cont> pointing to the current context.
-=cut
-
*/
Parrot_cont *
-new_ret_continuation(Interp *interp)
+new_ret_continuation(Interp *interp /*NN*/)
{
Parrot_cont * const cc = mem_allocate_typed(Parrot_cont);
+
cc->to_ctx = CONTEXT(interp->ctx);
cc->from_ctx = NULL; /* filled in during a call */
cc->dynamic_state = NULL;
@@ -177,19 +162,16 @@
/*
-=item C<Parrot_coro *
-new_coroutine(Interp *interp)>
+FUNCDOC: new_coroutine
Returns a new C<Parrot_coro>.
XXX: Need to document semantics in detail.
-=cut
-
*/
Parrot_coro *
-new_coroutine(Interp *interp)
+new_coroutine(Interp *interp /*NN*/)
{
Parrot_coro * const co = mem_allocate_zeroed_typed(Parrot_coro);
@@ -201,18 +183,16 @@
/*
-=item C<PMC *
-new_ret_continuation_pmc(Interp * interp, opcode_t * address)>
+FUNCDOC: new_ret_continuation_pmc
Returns a new C<RetContinuation> PMC. Uses one from the cache,
if possible; otherwise, creates a new one.
-=cut
-
*/
+PARROT_API
PMC *
-new_ret_continuation_pmc(Interp *interp, opcode_t * address)
+new_ret_continuation_pmc(Interp *interp /*NN*/, opcode_t *address)
{
PMC* const continuation = pmc_new(interp, enum_class_RetContinuation);
VTABLE_set_pointer(interp, continuation, address);
@@ -221,16 +201,14 @@
/*
-=item C< void invalidate_retc_context(Interp *, PMC *cont)>
+FUNCDOC: invalidate_retc_context
Make true Continuation from all RetContinuations up the call chain.
-=cut
-
*/
void
-invalidate_retc_context(Interp *interp, PMC *cont)
+invalidate_retc_context(Interp *interp /*NN*/, PMC *cont /*NN*/)
{
Parrot_Context *ctx = PMC_cont(cont)->from_ctx;
@@ -251,23 +229,22 @@
}
+/* XXX use method lookup - create interface
+ * see also pbc.c
+ */
+extern PMC* Parrot_NameSpace_nci_get_name(Interp *interp, PMC* pmc);
+
/*
-=item C<Parrot_full_sub_name>
+FUNCDOC: Parrot_full_sub_name
Return namespace, name, and location of subroutine.
-=cut
-
*/
-/* XXX use method lookup - create interface
- * see also pbc.c
- */
-extern PMC* Parrot_NameSpace_nci_get_name(Interp *interp, PMC* pmc);
-
+PARROT_API
STRING*
-Parrot_full_sub_name(Interp *interp, PMC* sub)
+Parrot_full_sub_name(Interp *interp /*NN*/, PMC* sub /*NULLOK*/)
{
Parrot_sub * s;
STRING *res;
@@ -290,16 +267,17 @@
}
j = const_string(interp, ";");
- res = string_join(interp, j, ns_array);
+ res = string_join(interp, j, ns_array);
Parrot_unblock_DOD(interp);
return res;
}
return NULL;
}
+PARROT_API
int
-Parrot_Context_get_info(Interp *interp, parrot_context_t *ctx,
- Parrot_Context_info *info)
+Parrot_Context_get_info(Interp *interp /*NN*/, parrot_context_t *ctx /*NN*/,
+ Parrot_Context_info *info /*NN*/)
{
Parrot_sub *sub;
DECL_CONST_CAST;
@@ -377,13 +355,14 @@
return 1;
}
+PARROT_API
STRING*
-Parrot_Context_infostr(Interp *interp, parrot_context_t *ctx)
+Parrot_Context_infostr(Interp *interp /*NN*/, parrot_context_t *ctx /*NN*/)
{
Parrot_Context_info info;
- const char* const msg = (CONTEXT(interp->ctx) == ctx) ?
- "current instr.:":
- "called from Sub";
+ const char* const msg = (CONTEXT(interp->ctx) == ctx)
+ ? "current instr.:"
+ : "called from Sub";
STRING *res;
Parrot_block_DOD(interp);
@@ -406,16 +385,14 @@
/*
-=item C<PMC* Parrot_find_pad(Interp*, STRING *lex_name)>
+FUNCDOC: Parrot_find_pad
Locate the LexPad containing the given name. Return NULL on failure.
-=cut
-
*/
PMC*
-Parrot_find_pad(Interp *interp, STRING *lex_name, parrot_context_t *ctx)
+Parrot_find_pad(Interp *interp /*NN*/, STRING *lex_name, parrot_context_t *ctx
/*NN*/)
{
while (1) {
PMC * const lex_pad = ctx->lex_pad;
@@ -444,22 +421,20 @@
return NULL;
}
+PARROT_API
PMC*
-parrot_new_closure(Interp *interp, PMC *sub_pmc)
+parrot_new_closure(Interp *interp /*NN*/, PMC *sub_pmc)
{
- PMC *clos_pmc;
- Parrot_sub *clos, *sub;
PMC *cont;
- parrot_context_t *ctx;
- clos_pmc = VTABLE_clone(interp, sub_pmc);
- sub = PMC_sub(sub_pmc);
- clos = PMC_sub(clos_pmc);
+ PMC * const clos_pmc = VTABLE_clone(interp, sub_pmc);
+ Parrot_sub * const sub = PMC_sub(sub_pmc);
+ Parrot_sub * const clos = PMC_sub(clos_pmc);
/*
* the given sub_pmc has to have an :outer(sub) that is
* this subroutine
*/
- ctx = CONTEXT(interp->ctx);
+ parrot_context_t * const ctx = CONTEXT(interp->ctx);
if (PMC_IS_NULL(sub->outer_sub)) {
real_exception(interp, NULL, INVALID_OPERATION,
"'%Ss' isn't a closure (no :outer)", sub->name);
@@ -490,9 +465,8 @@
#endif
return clos_pmc;
}
-/*
-=back
+/*
=head1 SEE ALSO
@@ -502,8 +476,6 @@
Initial version by Melvin on 2002/06/6.
-=cut
-
*/