Author: petdance
Date: Sun Jun 3 21:15:34 2007
New Revision: 18794
Modified:
trunk/config/gen/makefiles/root.in
trunk/include/parrot/stacks.h
trunk/src/stack_common.c
trunk/src/stacks.c
Log:
stacks.h now can be handled by the headerizer
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in (original)
+++ trunk/config/gen/makefiles/root.in Sun Jun 3 21:15:34 2007
@@ -1828,6 +1828,8 @@
src/string.o \
src/string_primitives.o \
src/pic.o \
+ src/stacks.o \
+ src/stack_common.o \
###############################################################################
#
Modified: trunk/include/parrot/stacks.h
==============================================================================
--- trunk/include/parrot/stacks.h (original)
+++ trunk/include/parrot/stacks.h Sun Jun 3 21:15:34 2007
@@ -46,52 +46,82 @@
#define STACK_CLEANUP_NULL ((Stack_cleanup_method)NULLfunc)
-PARROT_API void stack_system_init(Interp *interp);
-PARROT_API void stack_destroy(Stack_Chunk_t * top);
+/* HEADERIZER BEGIN: src/stacks.c */
-/*
- * stack_common functions
- */
-Stack_Chunk_t * register_new_stack(Parrot_Interp, const char *name, size_t);
-Stack_Chunk_t * cst_new_stack_chunk(Parrot_Interp, const Stack_Chunk_t *chunk);
-void* stack_prepare_push(Parrot_Interp, Stack_Chunk_t **stack_p);
-void* stack_prepare_pop(Parrot_Interp, Stack_Chunk_t **stack_p);
-void mark_stack_chunk_cache(Parrot_Interp interp);
-
-/*
- * pad, user, control stacks
- */
-
-PARROT_API Stack_Chunk_t * new_stack(Interp *interp, const char *name);
-PARROT_API void mark_stack(Interp *, Stack_Chunk_t * cur_stack)
- __attribute__nonnull__(2);
-
-PARROT_API size_t stack_height(Interp *interp, const Stack_Chunk_t *stack_base)
- __attribute__nonnull__(2);
-
-PARROT_API Stack_Entry_t * stack_entry(Interp *intepreter, Stack_Chunk_t
*stack_base,
- INTVAL stack_depth)
- __attribute__nonnull__(2);
-
-PARROT_API void rotate_entries(Interp *interp, Stack_Chunk_t **stack_base,
- INTVAL num_entries);
-
-PARROT_API void stack_push(Interp *interp, Stack_Chunk_t **stack_base,
- void *thing, Stack_entry_type type,
- Stack_cleanup_method cleanup);
-
-PARROT_API void *stack_pop(Interp *interp, Stack_Chunk_t **stack_base,
- void *where, Stack_entry_type type);
-
-PARROT_API void *pop_dest(Interp *interp);
-
-PARROT_API void *stack_peek(Interp *interp, Stack_Chunk_t *stack,
- Stack_entry_type *type);
-
-PARROT_API Stack_entry_type get_entry_type(Interp *interp, const Stack_Entry_t
*entry)
- __attribute__nonnull__(2);
+PARROT_API void Parrot_dump_dynamic_environment( Interp *interp,
+ Stack_Chunk_t *dynamic_env /*NN*/ )
+ __attribute__nonnull__(2);
+
+PARROT_API Stack_entry_type get_entry_type( Interp *interp,
+ const Stack_Entry_t *entry /*NN*/ )
+ __attribute__nonnull__(2);
+
+PARROT_API void mark_stack( Interp *interp, Stack_Chunk_t *chunk /*NN*/ )
+ __attribute__nonnull__(2);
+
+PARROT_API Stack_Chunk_t * new_stack( Interp *interp,
+ const char *name /*NN*/ )
+ __attribute__nonnull__(2);
+
+PARROT_API void * pop_dest( Interp *interp );
+PARROT_API void rotate_entries( Interp *interp,
+ Stack_Chunk_t **stack_p /*NN*/,
+ INTVAL num_entries )
+ __attribute__nonnull__(2);
+
+PARROT_API void stack_destroy( Stack_Chunk_t * top );
+PARROT_API Stack_Entry_t * stack_entry( Interp *interp,
+ Stack_Chunk_t *stack /*NN*/,
+ INTVAL depth )
+ __attribute__nonnull__(2);
+
+PARROT_API size_t stack_height( Interp *interp,
+ const Stack_Chunk_t *chunk /*NN*/ )
+ __attribute__nonnull__(2);
+
+PARROT_API void * stack_peek( Interp *interp,
+ Stack_Chunk_t *stack_base /*NN*/,
+ Stack_entry_type *type /*NULLOK*/ )
+ __attribute__nonnull__(2);
+
+PARROT_API void * stack_pop( Interp *interp,
+ Stack_Chunk_t **stack_p /*NN*/,
+ void *where /*NULLOK*/,
+ Stack_entry_type type )
+ __attribute__nonnull__(2);
+
+PARROT_API void stack_push( Interp *interp,
+ Stack_Chunk_t **stack_p /*NN*/,
+ void *thing,
+ Stack_entry_type type,
+ Stack_cleanup_method cleanup )
+ __attribute__nonnull__(2);
+
+/* HEADERIZER END: src/stacks.c */
+/* HEADERIZER BEGIN: src/stack_common.c */
+
+PARROT_API Stack_Chunk_t * cst_new_stack_chunk(
+ Parrot_Interp interp,
+ const Stack_Chunk_t *chunk /*NN*/ )
+ __attribute__nonnull__(2);
+
+PARROT_API Stack_Chunk_t * register_new_stack( Interp *interp,
+ const char *name /*NN*/,
+ size_t item_size )
+ __attribute__nonnull__(2);
+
+PARROT_API void* stack_prepare_pop(
+ Parrot_Interp interp,
+ Stack_Chunk_t **stack_p /*NN*/ )
+ __attribute__nonnull__(2);
+
+PARROT_API void* stack_prepare_push(
+ Parrot_Interp interp,
+ Stack_Chunk_t **stack_p /*NN*/ )
+ __attribute__nonnull__(2);
-void Parrot_dump_dynamic_environment(Interp *, struct Stack_Chunk *);
+PARROT_API void stack_system_init( Interp *interp );
+/* HEADERIZER END: src/stack_common.c */
#define ERROR_STACK_EMPTY 1
Modified: trunk/src/stack_common.c
==============================================================================
--- trunk/src/stack_common.c (original)
+++ trunk/src/stack_common.c Sun Jun 3 21:15:34 2007
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2004, The Perl Foundation.
+Copyright (C) 2001-2007, The Perl Foundation.
$Id$
=head1 NAME
@@ -15,26 +15,23 @@
=head2 Functions
-=over 4
-
-=cut
-
*/
#include "parrot/parrot.h"
+#include "parrot/stacks.h"
#include <assert.h>
-/*
+/* HEADER: include/parrot/stacks.h */
-=item C<void stack_system_init(Interp *interp)>
+/*
+FUNCDOC:
Called from C<make_interpreter()> to initialize the interpreter's
register stacks.
-=cut
-
*/
+PARROT_API
void
stack_system_init(Interp *interp)
{
@@ -43,18 +40,15 @@
/*
-=item C<Stack_Chunk_t *
-register_new_stack(Interp *interp, const char *name, size_t item_size)>
-
+FUNCDOC:
Create a new stack and name it. C<< stack->name >> is used for
debugging/error reporting.
-=cut
-
*/
-Stack_Chunk_t * register_new_stack(Interp *interp,
- const char *name /*NN*/, size_t item_size)
+PARROT_API
+Stack_Chunk_t *
+register_new_stack(Interp *interp, const char *name /*NN*/, size_t item_size)
{
Stack_Chunk_t *chunk;
@@ -69,17 +63,14 @@
/*
-=item C<Stack_Chunk_t *
-cst_new_stack_chunk(Interp *interp, const Stack_Chunk_t *chunk)>
-
+FUNCDOC:
Get a new chunk either from the freelist or allocate one.
-=cut
-
*/
-Stack_Chunk_t *cst_new_stack_chunk(Parrot_Interp interp,
- const Stack_Chunk_t *chunk /*NN*/)
+PARROT_API
+Stack_Chunk_t *
+cst_new_stack_chunk(Parrot_Interp interp, const Stack_Chunk_t *chunk /*NN*/)
{
Small_Object_Pool * const pool =
get_bufferlike_pool(interp, chunk->size);
@@ -95,15 +86,12 @@
/*
-=item C<void*
-stack_prepare_push(Parrot_Interp interp, Stack_Chunk_t **stack_p)>
-
+FUNCDOC:
Return a pointer, where new entries go for push.
-=cut
-
*/
+PARROT_API
void*
stack_prepare_push(Parrot_Interp interp, Stack_Chunk_t **stack_p /*NN*/)
{
@@ -118,15 +106,12 @@
/*
-=item C<void*
-stack_prepare_pop(Parrot_Interp interp, Stack_Chunk_t **stack_p)>
-
+FUNCDOC:
Return a pointer, where new entries are poped off.
-=cut
-
*/
+PARROT_API
void*
stack_prepare_pop(Parrot_Interp interp, Stack_Chunk_t **stack_p /*NN*/)
{
@@ -144,8 +129,6 @@
/*
-=back
-
=head1 SEE ALSO
F<include/parrot/stacks.h>, F<src/stacks.c>, F<src/registers.c>
Modified: trunk/src/stacks.c
==============================================================================
--- trunk/src/stacks.c (original)
+++ trunk/src/stacks.c Sun Jun 3 21:15:34 2007
@@ -13,27 +13,23 @@
=head2 Functions
-=over 4
-
-=cut
-
*/
#include "parrot/parrot.h"
+#include "parrot/stacks.h"
#include <assert.h>
-/*
+/* HEADER: include/parrot/stacks.h */
-=item C<Stack_Chunk_t *
-new_stack(Interp *interp, const char *name)>
+/*
+FUNCDOC:
Create a new stack and name it. C<< stack->name >> is used for
debugging/error reporting.
-=cut
-
*/
+PARROT_API
Stack_Chunk_t *
new_stack(Interp *interp, const char *name /*NN*/)
{
@@ -44,15 +40,12 @@
/*
-=item C<void
-mark_stack(Interp *interp, Stack_Chunk_t *chunk)>
-
+FUNCDOC:
Mark entries in a stack structure during DOD.
-=cut
-
*/
+PARROT_API
void
mark_stack(Interp *interp, Stack_Chunk_t *chunk /*NN*/)
{
@@ -79,15 +72,14 @@
}
/*
-=item C<void
-stack_destroy(Stack_Chunk_t * top)>
-
-GC does it all.
+FUNCDOC:
+stack_destroy() doesn't need to do anything, since GC does it all.
=cut
*/
+PARROT_API
void
stack_destroy(Stack_Chunk_t * top)
{
@@ -96,15 +88,12 @@
/*
-=item C<size_t
-stack_height(Interp *interp, const Stack_Chunk_t *top)>
-
+FUNCDOC:
Returns the height of the stack. The maximum "depth" is height - 1.
-=cut
-
*/
+PARROT_API
size_t
stack_height(Interp *interp, const Stack_Chunk_t *chunk /*NN*/)
{
@@ -122,23 +111,20 @@
/*
-=item C<Stack_Entry_t *
-stack_entry(Interp *interp, Stack_Chunk_t *stack, INTVAL depth)>
-
+FUNCDOC:
If C<< depth >= 0 >>, return the entry at that depth from the top of the
stack, with 0 being the top entry. If C<depth < 0>, then return the
entry C<|depth|> entries from the bottom of the stack. Returns C<NULL>
if C<|depth| > number> of entries in stack.
-=cut
-
*/
+PARROT_API
Stack_Entry_t *
stack_entry(Interp *interp, Stack_Chunk_t *stack /*NN*/, INTVAL depth)
{
Stack_Chunk_t *chunk;
- Stack_Entry_t *entry = NULL;
+ Stack_Entry_t *entry;
size_t offset = (size_t)depth;
/* For negative depths, look from the bottom of the stack up. */
@@ -164,19 +150,15 @@
/*
-=item C<void
-rotate_entries(Interp *interp, Stack_Chunk_t **stack_p,
- INTVAL num_entries)>
-
-Rotate the top N entries by one. If C<N > 0>, the rotation is bubble
-up, so the top most element becomes the Nth element. If C<N < 0>, the
+FUNCDOC:
+Rotate the top N entries by one. If C<< N > 0 >>, the rotation is bubble
+up, so the top most element becomes the Nth element. If C<< N < 0 >>, the
rotation is bubble down, so that the Nth element becomes the top most
element.
-=cut
-
*/
+PARROT_API
void
rotate_entries(Interp *interp,
Stack_Chunk_t **stack_p /*NN*/,
@@ -189,7 +171,6 @@
return;
}
-
if (num_entries < 0) {
INTVAL i;
Stack_Entry_t temp;
@@ -228,10 +209,7 @@
/*
-=item C<void
-stack_push(Interp *interp, Stack_Chunk_t **stack_p,
- void *thing, Stack_entry_type type, Stack_cleanup_method cleanup)>
-
+FUNCDOC:
Push something on the generic stack.
Note that the cleanup pointer, if non-C<NULL>, points to a routine
@@ -241,15 +219,14 @@
call stack, or localize (or tempify, or whatever we're calling it)
variable or something.
-=cut
-
*/
+PARROT_API
void
stack_push(Interp *interp, Stack_Chunk_t **stack_p /*NN*/,
void *thing, Stack_entry_type type, Stack_cleanup_method cleanup)
{
- Stack_Entry_t *entry = (Stack_Entry_t *)stack_prepare_push(interp,
stack_p);
+ Stack_Entry_t * const entry = (Stack_Entry_t *)stack_prepare_push(interp,
stack_p);
/* Remember the type */
entry->entry_type = type;
@@ -284,19 +261,15 @@
/*
-=item C<void *
-stack_pop(Interp *interp, Stack_Chunk_t **stack_p,
- void *where, Stack_entry_type type)>
-
+FUNCDOC:
Pop off an entry and return a pointer to the contents.
-=cut
-
*/
+PARROT_API
void *
stack_pop(Interp *interp, Stack_Chunk_t **stack_p /*NN*/,
- void *where, Stack_entry_type type)
+ void *where /*NULLOK*/, Stack_entry_type type)
{
Stack_Entry_t * const entry = (Stack_Entry_t *)stack_prepare_pop(interp,
stack_p);
@@ -347,15 +320,12 @@
/*
-=item C<void *
-pop_dest(Interp *interp)>
-
+FUNCDOC:
Pop off a destination entry and return a pointer to the contents.
-=cut
-
*/
+PARROT_API
void *
pop_dest(Interp *interp)
{
@@ -369,21 +339,17 @@
/*
-=item C<void *
-stack_peek(Interp *interp, Stack_Chunk_t *stack_base,
- Stack_entry_type *type)>
-
+FUNCDOC:
Peek at stack and return pointer to entry and the type of the entry.
-=cut
-
*/
+PARROT_API
void *
stack_peek(Interp *interp, Stack_Chunk_t *stack_base /*NN*/,
Stack_entry_type *type /*NULLOK*/)
{
- Stack_Entry_t * const entry = stack_entry(interp, stack_base, 0);
+ const Stack_Entry_t * const entry = stack_entry(interp, stack_base, 0);
if (entry == NULL) {
return NULL;
}
@@ -402,10 +368,12 @@
/*
+FUNCDOC:
Returns the stack entry type of C<entry>.
*/
+PARROT_API
Stack_entry_type
get_entry_type(Interp *interp, const Stack_Entry_t *entry /*NN*/)
{
@@ -414,20 +382,16 @@
/*
-=item C<void
-Parrot_dump_dynamic_environment(Interp *interp,
- Stack_Chunk_t *dynamic_env)>
-
+FUNCDOC:
Print a representation of the dynamic stack to the standard error (using
C<PIO_eprintf>). This is used only temporarily for debugging.
-=cut
-
*/
+PARROT_API
void
Parrot_dump_dynamic_environment(Interp *interp,
- Stack_Chunk_t *dynamic_env)
+ Stack_Chunk_t *dynamic_env /*NN*/)
{
int height = (int) stack_height(interp, dynamic_env);
@@ -461,8 +425,6 @@
/*
-=back
-
=head1 SEE ALSO
F<include/parrot/stacks.h>, F<include/parrot/enums.h>, and