[svn:parrot] r48389 - in branches/unshared_buffers: . compilers/data_json compilers/imcc compilers/pct compilers/pge compilers/tge config/auto/sizes config/auto/zlib docs/book/draft docs/book/pct docs/dev docs/pdds examples/embed examples/languages/abc examples/languages/squaak examples/pge ext/nqp-rx include/parrot lib/Parrot lib/Parrot/Configure/Step ports/cygwin ports/debian runtime/parrot/languages runtime/parrot/library runtime/parrot/library/Digest runtime/parrot/library/Math src src/call src/gc src/interp src/runcore src/string/encoding t/codingstd t/compilers/tge t/oo t/pmc t/src t/steps/init/hints tools/build tools/dev tools/util

darbelo at svn.parrot.org darbelo at svn.parrot.org
Tue Aug 10 22:03:31 UTC 2010


Author: darbelo
Date: Tue Aug 10 22:03:29 2010
New Revision: 48389
URL: https://trac.parrot.org/parrot/changeset/48389

Log:
Sync with trunk.

Added:
   branches/unshared_buffers/t/codingstd/pmc_docs.t
      - copied unchanged from r48388, trunk/t/codingstd/pmc_docs.t
Modified:
   branches/unshared_buffers/   (props changed)
   branches/unshared_buffers/CREDITS
   branches/unshared_buffers/MANIFEST
   branches/unshared_buffers/compilers/data_json/Rules.mak   (props changed)
   branches/unshared_buffers/compilers/imcc/Rules.in   (props changed)
   branches/unshared_buffers/compilers/pct/Rules.mak   (props changed)
   branches/unshared_buffers/compilers/pge/Rules.mak   (props changed)
   branches/unshared_buffers/compilers/tge/Rules.mak   (props changed)
   branches/unshared_buffers/config/auto/sizes/intval_maxmin_c.in   (props changed)
   branches/unshared_buffers/config/auto/zlib/   (props changed)
   branches/unshared_buffers/docs/book/draft/README   (props changed)
   branches/unshared_buffers/docs/book/draft/appa_glossary.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/appb_patch_submission.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/appc_command_line_options.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/appd_build_options.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/appe_source_code.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/ch01_introduction.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/ch02_getting_started.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/ch07_dynpmcs.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/ch08_dynops.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/ch10_opcode_reference.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/ch11_directive_reference.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/ch12_operator_reference.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/chXX_hlls.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/chXX_library.pod   (props changed)
   branches/unshared_buffers/docs/book/draft/chXX_testing_and_debugging.pod   (props changed)
   branches/unshared_buffers/docs/book/pct/ch01_introduction.pod   (props changed)
   branches/unshared_buffers/docs/book/pct/ch02_getting_started.pod   (props changed)
   branches/unshared_buffers/docs/book/pct/ch03_compiler_tools.pod   (props changed)
   branches/unshared_buffers/docs/book/pct/ch04_pge.pod   (props changed)
   branches/unshared_buffers/docs/book/pct/ch05_nqp.pod   (props changed)
   branches/unshared_buffers/docs/dev/c_functions.pod   (props changed)
   branches/unshared_buffers/docs/pdds/pdd30_install.pod   (props changed)
   branches/unshared_buffers/examples/embed/cotorra.c   (props changed)
   branches/unshared_buffers/examples/languages/abc/   (props changed)
   branches/unshared_buffers/examples/languages/squaak/   (props changed)
   branches/unshared_buffers/examples/pge/demo.pir   (props changed)
   branches/unshared_buffers/ext/nqp-rx/Rules.mak   (props changed)
   branches/unshared_buffers/include/parrot/call.h   (contents, props changed)
   branches/unshared_buffers/include/parrot/gc_api.h   (props changed)
   branches/unshared_buffers/include/parrot/memory.h
   branches/unshared_buffers/include/parrot/runcore_api.h   (props changed)
   branches/unshared_buffers/include/parrot/runcore_profiling.h   (props changed)
   branches/unshared_buffers/include/parrot/runcore_trace.h   (props changed)
   branches/unshared_buffers/lib/Parrot/Configure/Step/Test.pm   (props changed)
   branches/unshared_buffers/lib/Parrot/H2inc.pm   (props changed)
   branches/unshared_buffers/ports/cygwin/parrot-1.0.0-1.cygport   (props changed)
   branches/unshared_buffers/ports/debian/libparrot-dev.install.in   (props changed)
   branches/unshared_buffers/ports/debian/libparrot.install.in   (props changed)
   branches/unshared_buffers/ports/debian/parrot-doc.install.in   (props changed)
   branches/unshared_buffers/ports/debian/parrot.install.in   (props changed)
   branches/unshared_buffers/runtime/parrot/languages/   (props changed)
   branches/unshared_buffers/runtime/parrot/library/Digest/MD5.pir
   branches/unshared_buffers/runtime/parrot/library/Math/Rand.pir   (props changed)
   branches/unshared_buffers/runtime/parrot/library/Rules.mak   (props changed)
   branches/unshared_buffers/src/call/args.c
   branches/unshared_buffers/src/call/ops.c   (props changed)
   branches/unshared_buffers/src/call/pcc.c   (props changed)
   branches/unshared_buffers/src/exceptions.c
   branches/unshared_buffers/src/gc/alloc_memory.c   (contents, props changed)
   branches/unshared_buffers/src/gc/alloc_resources.c   (props changed)
   branches/unshared_buffers/src/gc/api.c   (props changed)
   branches/unshared_buffers/src/gc/malloc.c   (props changed)
   branches/unshared_buffers/src/gc/malloc_trace.c   (props changed)
   branches/unshared_buffers/src/gc/mark_sweep.c   (props changed)
   branches/unshared_buffers/src/gc/system.c   (props changed)
   branches/unshared_buffers/src/interp/inter_cb.c   (props changed)
   branches/unshared_buffers/src/interp/inter_create.c   (props changed)
   branches/unshared_buffers/src/interp/inter_misc.c   (props changed)
   branches/unshared_buffers/src/runcore/cores.c   (props changed)
   branches/unshared_buffers/src/runcore/main.c   (props changed)
   branches/unshared_buffers/src/runcore/profiling.c   (props changed)
   branches/unshared_buffers/src/runcore/trace.c   (props changed)
   branches/unshared_buffers/src/string/encoding/ucs2.c
   branches/unshared_buffers/src/string/encoding/ucs4.c
   branches/unshared_buffers/t/compilers/tge/NoneGrammar.tg   (props changed)
   branches/unshared_buffers/t/oo/objects.t   (props changed)
   branches/unshared_buffers/t/oo/root_new.t   (props changed)
   branches/unshared_buffers/t/pmc/namespace-old.t   (props changed)
   branches/unshared_buffers/t/src/embed.t   (props changed)
   branches/unshared_buffers/t/steps/init/hints/linux-01.t   (props changed)
   branches/unshared_buffers/tools/build/h2inc.pl   (props changed)
   branches/unshared_buffers/tools/dev/fetch_languages.pl   (props changed)
   branches/unshared_buffers/tools/dev/mk_gitignore.pl   (props changed)
   branches/unshared_buffers/tools/util/perlcritic-cage.conf   (props changed)

Modified: branches/unshared_buffers/CREDITS
==============================================================================
--- branches/unshared_buffers/CREDITS	Tue Aug 10 21:03:21 2010	(r48388)
+++ branches/unshared_buffers/CREDITS	Tue Aug 10 22:03:29 2010	(r48389)
@@ -810,6 +810,10 @@
 D: Pynie
 E: pmichaud at pobox.com
 
+N: Paul C. Anagnostopoulos
+U: Paul_the_Greek
+D: Memory management
+
 N: Paul Cochrane
 U: paultcochrane
 D: Changing the newspaper in the parrot cage

Modified: branches/unshared_buffers/MANIFEST
==============================================================================
--- branches/unshared_buffers/MANIFEST	Tue Aug 10 21:03:21 2010	(r48388)
+++ branches/unshared_buffers/MANIFEST	Tue Aug 10 22:03:29 2010	(r48389)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Tue Aug  3 18:21:50 2010 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Sun Aug  8 16:31:42 2010 UT
 #
 # See below for documentation on the format of this file.
 #
@@ -1503,6 +1503,7 @@
 t/codingstd/pdd_format.t                                    [test]
 t/codingstd/perlcritic.t                                    [test]
 t/codingstd/pir_code_coda.t                                 [test]
+t/codingstd/pmc_docs.t                                      [test]
 t/codingstd/pod_description.t                               [test]
 t/codingstd/pod_syntax.t                                    [test]
 t/codingstd/pod_todo.t                                      [test]

Modified: branches/unshared_buffers/include/parrot/call.h
==============================================================================
--- branches/unshared_buffers/include/parrot/call.h	Tue Aug 10 21:03:21 2010	(r48388)
+++ branches/unshared_buffers/include/parrot/call.h	Tue Aug 10 22:03:29 2010	(r48389)
@@ -29,6 +29,7 @@
                                              * jump buffer stack */
     opcode_t                *handler_start; /* Used in exception handling */
     int                      id;            /* runloop id */
+    PMC                     *exception;     /* Reference to the exception object */
 
     /* let the biggest element cross the cacheline boundary */
     Parrot_jump_buff         resume;        /* jmp_buf */

Modified: branches/unshared_buffers/include/parrot/memory.h
==============================================================================
--- branches/unshared_buffers/include/parrot/memory.h	Tue Aug 10 21:03:21 2010	(r48388)
+++ branches/unshared_buffers/include/parrot/memory.h	Tue Aug 10 22:03:29 2010	(r48389)
@@ -17,20 +17,33 @@
 /* Use these macros instead of calling the functions listed below. */
 /* They protect against things like passing null to mem__sys_realloc, */
 /* which is not portable. */
-#define mem_internal_allocate(x) mem__internal_allocate((x), __FILE__, __LINE__)
-#define mem_internal_allocate_typed(type) \
-    (type *)mem__internal_allocate(sizeof (type), __FILE__, __LINE__)
-#define mem_internal_allocate_zeroed(x) mem__internal_allocate_zeroed((x), \
-    __FILE__, __LINE__)
+
+/* It was decided that having a second set of memory allocation functions
+   is a waste. These macros were rewritten to use the much more prevalent
+   mem_sys_* functions and then the mem__internal_* functions were
+   eliminated. */
+
+#define mem_internal_allocate(x) mem_sys_allocate(x)
+
+#define mem_internal_allocate_typed(type) (type *)mem_sys_allocate(sizeof (type))
+
+#define mem_internal_allocate_zeroed(x) mem_sys_allocate_zeroed(x)
+
 #define mem_internal_allocate_zeroed_typed(type) \
-    (type *)mem__internal_allocate_zeroed(sizeof (type), __FILE__, __LINE__)
+    (type *)mem_sys_allocate_zeroed(sizeof (type))
+
 #define mem_internal_allocate_n_zeroed_typed(n, type) \
-    (type *)mem__internal_allocate_zeroed((n) * sizeof (type), __FILE__, __LINE__)
+    (type *)mem_sys_allocate_zeroed((n) * sizeof (type))
+
+#define mem_internal_realloc(x, y) mem_sys_realloc((x), (y))
+
+#define mem_internal_realloc_zeroed(p, x, y) mem_sys_realloc_zeroed((p), (x), (y))
+
+#define mem_internal_realloc_n_zeroed_typed(p, x, y, type) \
+  (type *)mem_sys_realloc_zeroed((p), (x) * sizeof (type), (y) * sizeof (type))
+
+#define mem_internal_free(x) mem_sys_free(x)
 
-#define mem_internal_realloc(x, y) mem__internal_realloc((x), (y), __FILE__, __LINE__)
-#define mem_internal_realloc_zeroed(p, x, y) mem__internal_realloc_zeroed((p), (x), (y), __FILE__, __LINE__)
-#define mem_internal_realloc_n_zeroed_typed(p, x, y, type) (type *)mem__internal_realloc_zeroed((p), (x) * sizeof (type), (y) * sizeof (type), __FILE__, __LINE__)
-#define mem_internal_free(x) mem__internal_free((x), __FILE__, __LINE__)
 
 #define mem_sys_memcopy memcpy
 #define mem_sys_memmove memmove
@@ -93,47 +106,6 @@
 char * mem_sys_strdup(ARGIN(const char *src))
         __attribute__nonnull__(1);
 
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-void * mem__internal_allocate(
-    size_t size,
-    ARGIN(const char *file),
-    int line)
-        __attribute__nonnull__(2);
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-void * mem__internal_allocate_zeroed(
-    size_t size,
-    ARGIN(const char *file),
-    int line)
-        __attribute__nonnull__(2);
-
-void mem__internal_free(
-    ARGFREE(void *from),
-    ARGIN(const char *file),
-    int line)
-        __attribute__nonnull__(2);
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-void * mem__internal_realloc(
-    ARGFREE(void *from),
-    size_t size,
-    ARGIN(const char *file),
-    int line)
-        __attribute__nonnull__(3);
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-void * mem__internal_realloc_zeroed(
-    ARGFREE(void *from),
-    size_t size,
-    size_t old_size,
-    ARGIN(const char *file),
-    int line)
-        __attribute__nonnull__(4);
-
 #define ASSERT_ARGS_mem_sys_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #define ASSERT_ARGS_mem_sys_allocate_zeroed __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #define ASSERT_ARGS_mem_sys_free __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
@@ -141,16 +113,6 @@
 #define ASSERT_ARGS_mem_sys_realloc_zeroed __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #define ASSERT_ARGS_mem_sys_strdup __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(src))
-#define ASSERT_ARGS_mem__internal_allocate __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(file))
-#define ASSERT_ARGS_mem__internal_allocate_zeroed __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(file))
-#define ASSERT_ARGS_mem__internal_free __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(file))
-#define ASSERT_ARGS_mem__internal_realloc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(file))
-#define ASSERT_ARGS_mem__internal_realloc_zeroed __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(file))
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/gc/alloc_memory.c */
 

Modified: branches/unshared_buffers/runtime/parrot/library/Digest/MD5.pir
==============================================================================
--- branches/unshared_buffers/runtime/parrot/library/Digest/MD5.pir	Tue Aug 10 21:03:21 2010	(r48388)
+++ branches/unshared_buffers/runtime/parrot/library/Digest/MD5.pir	Tue Aug 10 22:03:29 2010	(r48389)
@@ -49,6 +49,8 @@
 
 =cut
 
+.HLL 'parrot'
+
 .loadlib 'bit_ops'
 
 ###########################################################################

Modified: branches/unshared_buffers/src/call/args.c
==============================================================================
--- branches/unshared_buffers/src/call/args.c	Tue Aug 10 21:03:21 2010	(r48388)
+++ branches/unshared_buffers/src/call/args.c	Tue Aug 10 22:03:29 2010	(r48389)
@@ -816,29 +816,29 @@
         /* If the parameter is slurpy, collect all remaining positional
          * arguments into an array.*/
         if (param_flags & PARROT_ARG_SLURPY_ARRAY) {
-            PMC *collect_positional;
-            int  j;
-
             /* Can't handle named slurpy here, go to named argument handling */
-            if (param_flags & PARROT_ARG_NAME)
-                break;
+            if (!(param_flags & PARROT_ARG_NAME)) {
+                PMC *collect_positional;
+                int  j;
+                INTVAL num_positionals = positional_args - arg_index;
+                if (num_positionals < 0)
+                    num_positionals = 0;
+                if (named_count > 0)
+                    Parrot_ex_throw_from_c_args(interp, NULL,
+                        EXCEPTION_INVALID_OPERATION,
+                        "named parameters must follow all positional parameters");
 
-            if (named_count > 0)
-                Parrot_ex_throw_from_c_args(interp, NULL,
-                    EXCEPTION_INVALID_OPERATION,
-                    "named parameters must follow all positional parameters");
+                collect_positional = Parrot_pmc_new_init_int(interp,
+                    Parrot_get_ctx_HLL_type(interp, enum_class_ResizablePMCArray),
+                    num_positionals);
 
-            collect_positional = Parrot_pmc_new_init_int(interp,
-                Parrot_get_ctx_HLL_type(interp, enum_class_ResizablePMCArray),
-                positional_args - arg_index);
+                for (j = 0; arg_index < positional_args; ++arg_index)
+                    VTABLE_set_pmc_keyed_int(interp, collect_positional, j++,
+                        VTABLE_get_pmc_keyed_int(interp, call_object, arg_index));
 
-            for (j = 0; arg_index < positional_args; ++arg_index) {
-                VTABLE_set_pmc_keyed_int(interp, collect_positional, j++,
-                    VTABLE_get_pmc_keyed_int(interp, call_object, arg_index));
+                *accessor->pmc(interp, arg_info, param_index) = collect_positional;
+                ++param_index;
             }
-
-            *accessor->pmc(interp, arg_info, param_index) = collect_positional;
-            ++param_index;
             break; /* Terminate the positional arg loop. */
         }
 

Modified: branches/unshared_buffers/src/exceptions.c
==============================================================================
--- branches/unshared_buffers/src/exceptions.c	Tue Aug 10 21:03:21 2010	(r48388)
+++ branches/unshared_buffers/src/exceptions.c	Tue Aug 10 22:03:29 2010	(r48389)
@@ -242,6 +242,7 @@
     if (PObj_get_FLAGS(handler) & SUB_FLAG_C_HANDLER) {
         /* it's a C exception handler */
         Parrot_runloop * const jump_point = (Parrot_runloop *)address;
+        jump_point->exception = exception;
         longjmp(jump_point->resume, 1);
     }
 
@@ -367,6 +368,7 @@
     if (PObj_get_FLAGS(handler) & SUB_FLAG_C_HANDLER) {
         Parrot_runloop * const jump_point =
             (Parrot_runloop * const)VTABLE_get_pointer(interp, handler);
+        jump_point->exception = exception;
         longjmp(jump_point->resume, 1);
     }
 

Modified: branches/unshared_buffers/src/gc/alloc_memory.c
==============================================================================
--- branches/unshared_buffers/src/gc/alloc_memory.c	Tue Aug 10 21:03:21 2010	(r48388)
+++ branches/unshared_buffers/src/gc/alloc_memory.c	Tue Aug 10 22:03:29 2010	(r48389)
@@ -64,37 +64,6 @@
 
 /*
 
-=item C<void * mem__internal_allocate(size_t size, const char *file, int line)>
-
-Calls C<malloc> to allocate memory from the system, Panics if there is no
-memory available. If C<DETAIL_MEMORY_DEBUG> macro is defined, prints
-debug information to C<STDERR>.
-
-=cut
-
-*/
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-void *
-mem__internal_allocate(size_t size, ARGIN(const char *file), int line)
-{
-    ASSERT_ARGS(mem__internal_allocate)
-    void * const ptr = malloc((size_t)size);
-#ifdef DETAIL_MEMORY_DEBUG
-    fprintf(stderr, "Internal malloc %i at %p (%s/%d)\n",
-            size, ptr, file, line);
-#else
-    UNUSED(file);
-    UNUSED(line);
-#endif
-    if (!ptr)
-        PANIC_OUT_OF_MEM(size);
-    return ptr;
-}
-
-/*
-
 =item C<void * mem_sys_allocate_zeroed(size_t size)>
 
 Uses C<calloc> to allocate system memory.  Guaranteed to succeed, Panics
@@ -122,38 +91,6 @@
 
 /*
 
-=item C<void * mem__internal_allocate_zeroed(size_t size, const char *file, int
-line)>
-
-Uses C<calloc> to allocate system memory.  Guaranteed to succeed, Panics
-otherwise. If C<DETAIL_MEMORY_DEBUG> macro is defined, prints
-debug information to C<STDERR>.
-
-=cut
-
-*/
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-void *
-mem__internal_allocate_zeroed(size_t size, ARGIN(const char *file), int line)
-{
-    ASSERT_ARGS(mem__internal_allocate_zeroed)
-    void * const ptr = calloc(1, (size_t)size);
-#ifdef DETAIL_MEMORY_DEBUG
-    fprintf(stderr, "Internal malloc %i at %p (%s/%d)\n",
-            size, ptr, file, line);
-#else
-    UNUSED(file);
-    UNUSED(line);
-#endif
-    if (!ptr)
-        PANIC_OUT_OF_MEM(size);
-    return ptr;
-}
-
-/*
-
 =item C<void * mem_sys_realloc(void *from, size_t size)>
 
 Resizes a chunk of memory.  Unlike C<realloc>, it can handle a
@@ -226,81 +163,6 @@
 
 /*
 
-=item C<void * mem__internal_realloc(void *from, size_t size, const char *file,
-int line)>
-
-Resizes a chunk of system memory.  Unlike C<realloc>, it can handle a
-NULL pointer, in which case a new memory block is allocated for the
-requested size. If C<DETAIL_MEMORY_DEBUG> macro is defined, debug
-information is printed to C<STDERR>.
-
-=cut
-
-*/
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-void *
-mem__internal_realloc(ARGFREE(void *from), size_t size,
-        ARGIN(const char *file), int line)
-{
-    ASSERT_ARGS(mem__internal_realloc)
-    void * const ptr = realloc(from, size);
-#ifdef DETAIL_MEMORY_DEBUG
-    fprintf(stderr, "internal free of %p (realloc -- %i bytes) (%s/%d)\n",
-            from, size, file, line);
-    fprintf(stderr, "Internal malloc %i at %p (%s/%d)\n",
-            size, ptr, file, line);
-#else
-    UNUSED(file);
-    UNUSED(line);
-#endif
-    if (!ptr)
-        PANIC_OUT_OF_MEM(size);
-    return ptr;
-}
-
-/*
-
-=item C<void * mem__internal_realloc_zeroed(void *from, size_t size, size_t
-old_size, const char *file, int line)>
-
-Reallocates a given buffer of size C<old_size> to C<size>. If the new size
-is larger then the old size, the difference is filled with zeros. Contains
-debugging information, and can print filename and line number where it is
-used if C<DETAIL_MEMORY_DEBUG> is defined.
-
-=cut
-
-*/
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-void *
-mem__internal_realloc_zeroed(ARGFREE(void *from), size_t size, size_t old_size,
-    ARGIN(const char *file), int line)
-{
-    ASSERT_ARGS(mem__internal_realloc_zeroed)
-    void * const ptr = realloc(from, size);
-#ifdef DETAIL_MEMORY_DEBUG
-    fprintf(stderr, "internal free of %p (realloc -- %i bytes) (%s/%d)\n",
-            from, size, file, line);
-    fprintf(stderr, "Internal malloc %i at %p (%s/%d)\n",
-            size, ptr, file, line);
-#else
-    UNUSED(file);
-    UNUSED(line);
-#endif
-    if (!ptr)
-        PANIC_OUT_OF_MEM(size);
-    if (size > old_size)
-        memset((char*)ptr + old_size, 0, size - old_size);
-
-    return ptr;
-}
-
-/*
-
 =item C<void mem_sys_free(void *from)>
 
 Frees a chunk of memory back to the system.
@@ -323,31 +185,6 @@
 
 /*
 
-=item C<void mem__internal_free(void *from, const char *file, int line)>
-
-Frees a chunk of memory back to the system. If
-C<DETAIL_MEMORY_DEBUG> macro is defined, prints debug information to
-C<STDERR>.
-
-=cut
-
-*/
-
-void
-mem__internal_free(ARGFREE(void *from), ARGIN(const char *file), int line)
-{
-    ASSERT_ARGS(mem__internal_free)
-#ifdef DETAIL_MEMORY_DEBUG
-    fprintf(stderr, "Internal free of %p (%s/%d)\n", from, file, line);
-#else
-    UNUSED(file);
-    UNUSED(line);
-#endif
-    free(from);
-}
-
-/*
-
 =item C<char * mem_sys_strdup(const char *src)>
 
 Copy a C string to a new block of memory allocated with mem_sys_allocate,

Modified: branches/unshared_buffers/src/string/encoding/ucs2.c
==============================================================================
--- branches/unshared_buffers/src/string/encoding/ucs2.c	Tue Aug 10 21:03:21 2010	(r48388)
+++ branches/unshared_buffers/src/string/encoding/ucs2.c	Tue Aug 10 22:03:29 2010	(r48389)
@@ -327,8 +327,8 @@
             count * sizeof (UChar));
     }
     else {
-         Buffer_bufstart(dst) = Buffer_bufstart(s) + offs * sizeof (UChar);
-         Buffer_buflen(dst)   = 0;
+        Buffer_bufstart(dst) = Buffer_bufstart(s) + offs * sizeof (UChar);
+        Buffer_buflen(dst)   = 0;
     }
 
     return dst;

Modified: branches/unshared_buffers/src/string/encoding/ucs4.c
==============================================================================
--- branches/unshared_buffers/src/string/encoding/ucs4.c	Tue Aug 10 21:03:21 2010	(r48388)
+++ branches/unshared_buffers/src/string/encoding/ucs4.c	Tue Aug 10 22:03:29 2010	(r48389)
@@ -351,8 +351,8 @@
                         count * sizeof (UChar32));
     }
     else {
-         Buffer_bufstart(dst) = Buffer_bufstart(src) + offset * sizeof (UChar32);
-         Buffer_buflen(dst)   = 0;
+        Buffer_bufstart(dst) = Buffer_bufstart(src) + offset * sizeof (UChar32);
+        Buffer_buflen(dst)   = 0;
     }
 
     return dst;

Copied: branches/unshared_buffers/t/codingstd/pmc_docs.t (from r48388, trunk/t/codingstd/pmc_docs.t)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/unshared_buffers/t/codingstd/pmc_docs.t	Tue Aug 10 22:03:29 2010	(r48389, copy of r48388, trunk/t/codingstd/pmc_docs.t)
@@ -0,0 +1,153 @@
+#! perl
+# Copyright (C) 2006-2010, Parrot Foundation.
+# $Id$
+
+use strict;
+use warnings;
+
+use lib qw( . lib ../lib ../../lib );
+use Test::More;
+use Parrot::Config qw(%PConfig);
+use Parrot::Distribution;
+use Parrot::Headerizer;
+
+=head1 NAME
+
+t/codingstd/pmc_docs.t - checks for missing function documentation
+
+=head1 SYNOPSIS
+
+    # test all files
+    % prove t/codingstd/pmc_docs.t
+
+    # test specific files
+    % perl t/codingstd/pmc_docs.t src/foo.pmc src/bar.pmc
+
+=head1 DESCRIPTION
+
+Checks that all PMC source files have documentation for each function
+declared.
+
+=cut
+
+my $DIST = Parrot::Distribution->new;
+my $headerizer = Parrot::Headerizer->new;
+
+my @files = @ARGV ? @ARGV :
+    map {s/^$PConfig{build_dir}\///; $_}
+    map {s/\\/\//g; $_}
+    map {$_->path} $DIST->pmc_source_files();
+
+plan tests => scalar @files;
+
+my %todos;
+while (<DATA>) {
+    next if /^#/;
+    next if /^\s*$/;
+    chomp;
+    $todos{$_} = 1;
+}
+
+my %all_files = ();
+
+# Traverse each file, analyzing each function declaration therein, then
+# post results in %all_files.
+
+foreach my $path (@files) {
+    my $buf = $DIST->slurp($path);
+    my @function_decls = $headerizer->extract_function_declarations($buf);
+
+    # We start out asserting that every file will have documentation for each
+    # of its function declarations.  We then seek to contradict this
+    # assertion.
+
+    my %this_file = ( overall => 1 );
+
+    for my $function_decl (@function_decls) {
+        my $escaped_decl
+            = $headerizer->generate_documentation_signature($function_decl);
+        $this_file{$function_decl}{esc} = $escaped_decl;
+
+        if ( $buf =~ m/^\Q$escaped_decl\E$(.*?)^=cut/sm ) {
+            my $docs = $1;
+            $docs =~ s/\s//g;
+            if ($docs eq '') { # boilerplate only
+                $this_file{$function_decl}{status} = 0;
+                $this_file{overall} = 0;
+            }
+            else { # documentation found
+                $this_file{$function_decl}{status} = 1;
+            }
+        }
+        else { # no documentation found
+            $this_file{$function_decl}{status} = undef;
+            $this_file{overall} = 0;
+        }
+    }
+    $all_files{$path} = \%this_file;
+}
+
+foreach my $path (sort keys %all_files) {
+    TODO: {
+        local $TODO = 'Missing function docs' if $todos{$path};
+        ok( $all_files{$path}{overall}, $path )
+            or diag( diagnosis( \%all_files, $path ) );
+    }
+}
+
+sub diagnosis {
+    my ($all_files_ref, $path) = @_;
+    my $missing = '';
+    my $boilerplate = '';
+    my %this_file = %{ $all_files_ref->{$path} };
+    delete $this_file{overall};
+    foreach my $decl ( sort keys %this_file ) {
+        if ( ! defined $this_file{$decl}{status} ) {
+            $missing .= "$decl\n";
+            $missing .= "Need:\n";
+            $missing .= "$this_file{$decl}{esc}\n\n";
+        }
+        elsif ( ! $this_file{$decl}{status} ) {
+            $boilerplate .= "$this_file{$decl}{esc}\n\n";
+        }
+        else {
+            # docs!
+        }
+    }
+    my $diagnosis = "$path\n";
+    $diagnosis .= "Undocumented functions:\n\n$missing" if $missing;
+    $diagnosis .= "Boilerplate only:\n$boilerplate" if $boilerplate;
+    return "$diagnosis";
+}
+
+__DATA__
+src/dynpmc/rational.pmc
+src/pmc/bigint.pmc
+src/pmc/bignum.pmc
+src/pmc/callcontext.pmc
+src/pmc/class.pmc
+src/pmc/complex.pmc
+src/pmc/coroutine.pmc
+src/pmc/eval.pmc
+src/pmc/fixedintegerarray.pmc
+src/pmc/hashiterator.pmc
+src/pmc/imageio.pmc
+src/pmc/imageiosize.pmc
+src/pmc/integer.pmc
+src/pmc/namespace.pmc
+src/pmc/nci.pmc
+src/pmc/null.pmc
+src/pmc/object.pmc
+src/pmc/orderedhash.pmc
+src/pmc/packfile.pmc
+src/pmc/role.pmc
+src/pmc/sub.pmc
+src/pmc/threadinterpreter.pmc
+src/pmc/unmanagedstruct.pmc
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:


More information about the parrot-commits mailing list