[svn:parrot] r36847 - in trunk: . include/parrot src t/src

NotFound at svn.parrot.org NotFound at svn.parrot.org
Tue Feb 17 23:49:49 UTC 2009


Author: NotFound
Date: Tue Feb 17 23:49:48 2009
New Revision: 36847
URL: https://trac.parrot.org/parrot/changeset/36847

Log:
[core] forward declare core types in a new header file, move Parrot_compile_string to embed.h, unskip a embed test, TT #343

Added:
   trunk/include/parrot/core_types.h   (contents, props changed)
Modified:
   trunk/MANIFEST
   trunk/include/parrot/embed.h
   trunk/include/parrot/extend.h
   trunk/include/parrot/interpreter.h
   trunk/include/parrot/parrot.h
   trunk/include/parrot/string.h
   trunk/src/embed.c
   trunk/src/inter_misc.c
   trunk/t/src/embed.t

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	Tue Feb 17 23:39:04 2009	(r36846)
+++ trunk/MANIFEST	Tue Feb 17 23:49:48 2009	(r36847)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Tue Feb 17 17:11:06 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Tue Feb 17 23:32:32 2009 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -888,6 +888,7 @@
 include/parrot/cclass.h                                     [main]include
 include/parrot/charset.h                                    [main]include
 include/parrot/compiler.h                                   [main]include
+include/parrot/core_types.h                                 [main]include
 include/parrot/datatypes.h                                  [main]include
 include/parrot/debugger.h                                   [main]include
 include/parrot/dynext.h                                     [main]include

Added: trunk/include/parrot/core_types.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/include/parrot/core_types.h	Tue Feb 17 23:49:48 2009	(r36847)
@@ -0,0 +1,28 @@
+/* core_types.h
+ *  Copyright (C) 2009, Parrot Foundation.
+ *  SVN Info
+ *     $Id$
+ *  Overview:
+ *     Forward declaration of the interpreter basic types
+ */
+
+#ifndef PARROT_CORE_TYPES_H_GUARD
+#define PARROT_CORE_TYPES_H_GUARD
+
+typedef struct PMC PMC;
+typedef PMC *Parrot_PMC;
+
+struct parrot_string_t;
+typedef struct parrot_string_t *Parrot_String;
+
+struct parrot_interp_t;
+typedef struct parrot_interp_t *Parrot_Interp;
+
+#endif   /* PARROT_CORE_TYPES_H_GUARD */
+
+/*
+ * Local variables:
+ *   c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */

Modified: trunk/include/parrot/embed.h
==============================================================================
--- trunk/include/parrot/embed.h	Tue Feb 17 23:39:04 2009	(r36846)
+++ trunk/include/parrot/embed.h	Tue Feb 17 23:49:48 2009	(r36847)
@@ -15,6 +15,7 @@
 #ifndef PARROT_EMBED_H_GUARD
 #define PARROT_EMBED_H_GUARD
 
+#include "parrot/core_types.h"  /* types used */
 #include "parrot/compiler.h"    /* compiler capabilities */
 #include "parrot/config.h"      /* PARROT_VERSION, PARROT_JIT_CAPABLE... */
 #include "parrot/interpreter.h" /* give us the interpreter flags */
@@ -59,6 +60,9 @@
 
 PARROT_EXPORT void Parrot_runcode(Parrot_Interp, int argc, char **argv);
 
+PARROT_EXPORT Parrot_PMC Parrot_compile_string(Parrot_Interp,
+        Parrot_String type, const char *code, Parrot_String *error);
+
 PARROT_EXPORT void Parrot_destroy(Parrot_Interp);
 
 PARROT_EXPORT Parrot_Opcode * Parrot_debug(Parrot_Interp, Parrot_Interp, Parrot_Opcode *pc);

Modified: trunk/include/parrot/extend.h
==============================================================================
--- trunk/include/parrot/extend.h	Tue Feb 17 23:39:04 2009	(r36846)
+++ trunk/include/parrot/extend.h	Tue Feb 17 23:49:48 2009	(r36847)
@@ -16,6 +16,7 @@
 #define PARROT_EXTEND_H_GUARD
 
 #include <stdarg.h>
+#include "parrot/core_types.h"
 #include "parrot/config.h"      /* PARROT_VERSION, PARROT_JIT_CAPABLE... */
 #include "parrot/interpreter.h" /* give us the interpreter flags */
 #include "parrot/warnings.h"    /* give us the warnings flags    */
@@ -26,8 +27,6 @@
    but that would be really annoying */
 #if defined(PARROT_IN_CORE)
 
-#define Parrot_String STRING *
-#define Parrot_PMC PMC *
 #define Parrot_Language Parrot_Int
 #define Parrot_VTABLE VTABLE *
 
@@ -43,8 +42,6 @@
 
 #else
 
-typedef void * Parrot_String;
-typedef void * Parrot_PMC;
 typedef Parrot_Int Parrot_Language;
 typedef void * Parrot_Encoding;
 typedef void * Parrot_CharType;

Modified: trunk/include/parrot/interpreter.h
==============================================================================
--- trunk/include/parrot/interpreter.h	Tue Feb 17 23:39:04 2009	(r36846)
+++ trunk/include/parrot/interpreter.h	Tue Feb 17 23:49:48 2009	(r36847)
@@ -110,13 +110,9 @@
 
 #ifdef PARROT_IN_CORE
 
-#define Parrot_String   STRING *
-#define Parrot_PMC      PMC *
 #define Parrot_Language Parrot_Int
 #define Parrot_Vtable struct _vtable*
 
-typedef struct parrot_interp_t *Parrot_Interp;
-
 typedef Parrot_Interp_flag Interp_flags;
 typedef Parrot_Run_core_t Run_Cores;
 
@@ -610,19 +606,6 @@
         FUNC_MODIFIES(*error);
 
 PARROT_EXPORT
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-PMC * Parrot_compile_string(PARROT_INTERP,
-    ARGIN(STRING *type),
-    ARGIN(const char *code),
-    ARGOUT(STRING **error))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3)
-        __attribute__nonnull__(4)
-        FUNC_MODIFIES(*error);
-
-PARROT_EXPORT
 void Parrot_compreg(PARROT_INTERP,
     ARGIN(STRING *type),
     NOTNULL(Parrot_compiler_func_t func))
@@ -675,11 +658,6 @@
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(fullname) \
     || PARROT_ASSERT_ARG(error)
-#define ASSERT_ARGS_Parrot_compile_string __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(type) \
-    || PARROT_ASSERT_ARG(code) \
-    || PARROT_ASSERT_ARG(error)
 #define ASSERT_ARGS_Parrot_compreg __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(type) \
@@ -728,9 +706,6 @@
 
 #else /* !PARROT_IN_CORE */
 
-struct Parrot_Interp_;
-typedef struct Parrot_Interp_ *Parrot_Interp;
-
 typedef void * *(*native_func_t)(PARROT_INTERP,
                                  void *cur_opcode,
                                  void *start_code);

Modified: trunk/include/parrot/parrot.h
==============================================================================
--- trunk/include/parrot/parrot.h	Tue Feb 17 23:39:04 2009	(r36846)
+++ trunk/include/parrot/parrot.h	Tue Feb 17 23:49:48 2009	(r36847)
@@ -18,6 +18,8 @@
 #ifndef PARROT_PARROT_H_GUARD
 #define PARROT_PARROT_H_GUARD
 
+#include "parrot/core_types.h"
+
 #if defined(INSIDE_GLOBAL_SETUP)
 #  define VAR_SCOPE
 #else
@@ -116,7 +118,6 @@
 #define OPCODE_TYPE_JAVA 4871757
 #define OPCODE_TYPE_MSNET 0x2e4e4554
 
-typedef struct PMC PMC;
 typedef void STRING_FUNCS;
 typedef struct parrot_interp_t Interp;
 

Modified: trunk/include/parrot/string.h
==============================================================================
--- trunk/include/parrot/string.h	Tue Feb 17 23:39:04 2009	(r36846)
+++ trunk/include/parrot/string.h	Tue Feb 17 23:49:48 2009	(r36847)
@@ -13,10 +13,9 @@
 #ifndef PARROT_STRING_H_GUARD
 #define PARROT_STRING_H_GUARD
 
+#include "parrot/core_types.h"
 #include "parrot/config.h"
 
-struct parrot_string_t;
-
 #ifdef PARROT_IN_CORE
 
 #include "parrot/pobj.h"

Modified: trunk/src/embed.c
==============================================================================
--- trunk/src/embed.c	Tue Feb 17 23:39:04 2009	(r36846)
+++ trunk/src/embed.c	Tue Feb 17 23:49:48 2009	(r36847)
@@ -22,6 +22,8 @@
 #include "parrot/embed.h"
 #include "parrot/oplib/ops.h"
 
+#include "../compilers/imcc/imc.h"
+
 /* HEADERIZER HFILE: none */ /* The visible types are different than what we use in here */
 
 /* HEADERIZER BEGIN: static */
@@ -1252,6 +1254,44 @@
 
 /*
 
+=item C<Parrot_PMC Parrot_compile_string>
+
+Compile code string.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+Parrot_PMC
+Parrot_compile_string(PARROT_INTERP, Parrot_String type,
+        const char *code, Parrot_String *error)
+{
+
+    /* For the benefit of embedders that does not load any pbc
+     * before compiling a string
+     */
+    if (! interp->initial_pf) {
+        PackFile *pf = PackFile_new_dummy(interp, "compile_string");
+        /* Assumption: there is no valid reason to fail to create it.
+         * If the assumption changes, replace the assertio with a
+         * runtime check
+         */
+        PARROT_ASSERT(interp->initial_pf);
+    }
+
+    if (Parrot_str_compare(interp, Parrot_str_new(interp, "PIR", 3), type) == 0)
+        return IMCC_compile_pir_s(interp, code, error);
+
+    if (Parrot_str_compare(interp, Parrot_str_new(interp, "PASM", 4), type) == 0)
+        return IMCC_compile_pasm_s(interp, code, error);
+
+    *error = Parrot_str_new(interp, "Invalid interpreter type", 0);
+    return NULL;
+}
+
+/*
+
 =back
 
 =head1 SEE ALSO

Modified: trunk/src/inter_misc.c
==============================================================================
--- trunk/src/inter_misc.c	Tue Feb 17 23:39:04 2009	(r36846)
+++ trunk/src/inter_misc.c	Tue Feb 17 23:49:48 2009	(r36847)
@@ -152,47 +152,6 @@
 
 /*
 
-=item C<PMC * Parrot_compile_string>
-
-Compile code string.
-
-=cut
-
-*/
-
-PARROT_EXPORT
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-PMC *
-Parrot_compile_string(PARROT_INTERP, ARGIN(STRING *type),
-        ARGIN(const char *code), ARGOUT(STRING **error))
-{
-    ASSERT_ARGS(Parrot_compile_string)
-
-    /* For the benefit of embedders that does not load any pbc
-     * before compiling a string
-     */
-    if (! interp->initial_pf) {
-        PackFile *pf = PackFile_new_dummy(interp, "compile_string");
-        /* Assumption: there is no valid reason to fail to create it.
-         * If the assumption changes, replace the assertio with a
-         * runtime check
-         */
-        PARROT_ASSERT(interp->initial_pf);
-    }
-
-    if (Parrot_str_compare(interp, CONST_STRING(interp, "PIR"), type) == 0)
-        return IMCC_compile_pir_s(interp, code, error);
-
-    if (Parrot_str_compare(interp, CONST_STRING(interp, "PASM"), type) == 0)
-        return IMCC_compile_pasm_s(interp, code, error);
-
-    *error = CONST_STRING(interp, "Invalid interpreter type");
-    return NULL;
-}
-
-/*
-
 =item C<void * Parrot_compile_file>
 
 Compile code file.

Modified: trunk/t/src/embed.t
==============================================================================
--- trunk/t/src/embed.t	Tue Feb 17 23:39:04 2009	(r36846)
+++ trunk/t/src/embed.t	Tue Feb 17 23:49:48 2009	(r36847)
@@ -57,11 +57,6 @@
 Done
 OUTPUT
 
-# Unskip this after commit patch in TT #343
-SKIP : {
-
-    skip('Not ready yet, skipped until next release', 1);
-
 c_output_is( <<'CODE', <<'OUTPUT', "Hello world" );
 
 #include <stdio.h>
@@ -69,7 +64,6 @@
 
 #include "parrot/embed.h"
 #include "parrot/extend.h"
-#include "parrot/interpreter.h"
 
 void fail(const char *msg);
 
@@ -84,7 +78,7 @@
     Parrot_Interp interp;
     Parrot_String compiler;
     Parrot_String errstr;
-    Parrot_PMC *code;
+    Parrot_PMC code;
 
     /* Create the interprter and show a message using parrot io */
     interp = Parrot_new(NULL);
@@ -112,8 +106,6 @@
 Hello, pir
 OUTPUT
 
-}
-
 # Old tests, skipped al
 
 SKIP: {


More information about the parrot-commits mailing list