Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed codigstd tests

  • Loading branch information...
commit cc0610ab4ec0c4fb214e64d37f1dea13c7d1fa8d 1 parent 167abf5
@bluescreen10 bluescreen10 authored
View
7 MANIFEST
@@ -900,6 +900,7 @@ ext/nqp-rx/t/p6regex/rx_modifiers [test]
ext/nqp-rx/t/p6regex/rx_quantifiers [test]
ext/nqp-rx/t/p6regex/rx_subrules [test]
ext/nqp-rx/t/p6regex/rx_syntax [test]
+include/parrot/api.h [main]include
include/parrot/atomic.h [main]include
include/parrot/atomic/fallback.h [main]include
include/parrot/atomic/gcc_pcc.h [main]include
@@ -915,7 +916,6 @@ include/parrot/datatypes.h [main]include
include/parrot/debugger.h [main]include
include/parrot/dynext.h [main]include
include/parrot/embed.h [main]include
-include/parrot/api.h [main]include
include/parrot/encoding.h [main]include
include/parrot/enums.h [main]include
include/parrot/exceptions.h [main]include
@@ -1246,6 +1246,9 @@ src/dynpmc/rotest.pmc []
src/dynpmc/subproxy.pmc []
src/embed.c []
src/embed/api.c []
+src/embed/embed_private.h []
+src/embed/pmc.c []
+src/embed/strings.c []
src/exceptions.c []
src/exit.c []
src/extend.c []
@@ -1937,6 +1940,8 @@ t/src/README []doc
t/src/atomic.t [test]
t/src/basic.t [test]
t/src/embed.t [test]
+t/src/embed/pmc.t [test]
+t/src/embed/strings.t [test]
t/src/exit.t [test]
t/src/extend.t [test]
t/src/pointer_array.t [test]
View
19 compilers/imcc/main.c
@@ -156,12 +156,13 @@ Set up the const struct declaration for cmd_options
*/
-// TODO: Weed out the options that IMCC doesn't use, and rename this function
-// to something more imcc-ish
+/* TODO: Weed out the options that IMCC doesn't use, and rename this function
+ to something more imcc-ish
+*/
+
static const struct longopt_opt_decl *
Parrot_cmd_options(void)
{
- //ASSERT_ARGS(Parrot_cmd_options)
static const struct longopt_opt_decl cmd_options[] = {
{ '.', '.', (OPTION_flags)0, { "--wait" } },
{ 'D', 'D', OPTION_optional_FLAG, { "--parrot-debug" } },
@@ -636,6 +637,18 @@ compile_to_bytecode(PARROT_INTERP,
return pf;
}
+/*
+
+=item C<int imcc_run_api(PMC * interp_pmc, const char *sourcefile, int argc,
+const char **argv, PMC **pbcpmc)>
+
+This is a wrapper around C<imcc_run> function in which the input parameter is a
+PMC interpreter.
+
+=cut
+
+*/
+
PARROT_API
int
imcc_run_api(ARGMOD(PMC * interp_pmc), ARGIN(const char *sourcefile), int argc,
View
39 examples/embed/embedded_pir.c
@@ -1,39 +0,0 @@
-/*
- * Sample of an embedding application: compiles and executes "hello_world.pir"
- */
-
-#include<stdio.h>
-#include <stdlib.h>
-
-#include "parrot/api.h"
-
-int main(int argc, const char **argv)
-{
- int exitcode;
- Parrot_PMC * interp;
- Parrot_PMC * compiler;
- Parrot_PMC * bytecode;
-
- // Create the interpreter
- if (!Parrot_api_make_interpreter(NULL,NULL,NULL,&interp) ) {
- fprintf(stderr,"FATAL: Can't create the interpreter");
- return 1;
- }
-
- // Compile hello_world.pir and execute it
- if ( Parrot_api_load_language(interp, "PIR") &&
- Parrot_api_get_compiler(interp, "PIR", &compiler) &&
- Parrot_api_compile_file(interp, compiler, "hello_world.pir", &bytecode) &&
- Parrot_api_load_bytecode(interp, bytecode) &&
- Parrot_api_run(interp, &exitcode))
- {
- return exitcode;
- }
- else
- {
- // Print last error to stderr
- const char * err = Parrot_api_get_last_error(interp);
- fprintf(stderr, err);
- return 1;
- }
-}
View
4 examples/embed/hello_world.pir
@@ -1,4 +0,0 @@
-# Sample creation of a "Hello world" program
-.sub 'main' :main
- say 'Hello World!'
-.end
View
270 include/parrot/api.h
@@ -94,9 +94,8 @@ PARROT_API
Parrot_Int Parrot_api_disassemble_bytecode(
Parrot_PMC interp_pmc,
Parrot_PMC pbc,
- ARGIN(const char * const outfile),
- Parrot_Int opts)
- __attribute__nonnull__(3);
+ ARGIN_NULLOK(const char * const outfile),
+ Parrot_Int opts);
PARROT_API
Parrot_Int Parrot_api_flag(
@@ -252,8 +251,7 @@ Parrot_Int Parrot_api_wrap_imcc_hack(
#define ASSERT_ARGS_Parrot_api_destroy_interpreter \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_api_disassemble_bytecode \
- __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(outfile))
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_api_flag __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_api_get_compiler __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(compiler))
@@ -300,87 +298,101 @@ Parrot_Int Parrot_api_wrap_imcc_hack(
PARROT_API
Parrot_Int Parrot_api_string_export_ascii(
- Parrot_PMC interp_pmc,
+ ARGIN(Parrot_PMC interp_pmc),
ARGIN(Parrot_String string),
ARGOUT(char ** strout))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(* strout);
PARROT_API
Parrot_Int Parrot_api_string_export_wchar(
- Parrot_PMC interp_pmc,
+ ARGIN(Parrot_PMC interp_pmc),
ARGIN(Parrot_String string),
ARGOUT(wchar_t ** strout))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(* strout);
PARROT_API
Parrot_Int Parrot_api_string_free_exported_ascii(
- Parrot_PMC interp_pmc,
+ ARGIN(Parrot_PMC interp_pmc),
ARGIN(char * const str))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_API
Parrot_Int Parrot_api_string_free_exported_wchar(
- Parrot_PMC interp_pmc,
+ ARGIN(Parrot_PMC interp_pmc),
ARGIN(wchar_t * const str))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2);
PARROT_API
Parrot_Int Parrot_api_string_import_ascii(
- Parrot_PMC interp_pmc,
+ ARGIN(Parrot_PMC interp_pmc),
ARGIN(const char * str),
ARGOUT(Parrot_String * out))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(* out);
PARROT_API
Parrot_Int Parrot_api_string_import_binary(
- Parrot_PMC interp_pmc,
+ ARGIN(Parrot_PMC interp_pmc),
ARGIN(const unsigned char *bytes),
- Parrot_Int length,
+ ARGIN_NULLOK(Parrot_Int length),
ARGOUT(Parrot_String *out))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(4)
FUNC_MODIFIES(*out);
PARROT_API
Parrot_Int Parrot_api_string_import_wchar(
- Parrot_PMC interp_pmc,
+ ARGIN(Parrot_PMC interp_pmc),
ARGIN(wchar_t * str),
ARGOUT(Parrot_String * out))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(* out);
#define ASSERT_ARGS_Parrot_api_string_export_ascii \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(string) \
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(string) \
, PARROT_ASSERT_ARG(strout))
#define ASSERT_ARGS_Parrot_api_string_export_wchar \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(string) \
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(string) \
, PARROT_ASSERT_ARG(strout))
#define ASSERT_ARGS_Parrot_api_string_free_exported_ascii \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(str))
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(str))
#define ASSERT_ARGS_Parrot_api_string_free_exported_wchar \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(str))
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(str))
#define ASSERT_ARGS_Parrot_api_string_import_ascii \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(str) \
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(str) \
, PARROT_ASSERT_ARG(out))
#define ASSERT_ARGS_Parrot_api_string_import_binary \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(bytes) \
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(bytes) \
, PARROT_ASSERT_ARG(out))
#define ASSERT_ARGS_Parrot_api_string_import_wchar \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(str) \
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(str) \
, PARROT_ASSERT_ARG(out))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/embed/strings.c */
@@ -390,185 +402,267 @@ Parrot_Int Parrot_api_string_import_wchar(
PARROT_API
Parrot_Int Parrot_api_add_exception_handler(
- Parrot_PMC interp_pmc,
- Parrot_PMC handler);
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC handler))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
PARROT_API
Parrot_Int Parrot_api_pmc_box_string(
- Parrot_PMC interp_pmc,
- Parrot_String str,
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_String str),
ARGOUT(Parrot_PMC * str_pmc))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(* str_pmc);
PARROT_API
Parrot_Int Parrot_api_pmc_deserialize(
- Parrot_PMC interp_pmc,
- Parrot_String fpmc,
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_String fpmc),
ARGOUT(Parrot_PMC * pmc))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(* pmc);
PARROT_API
Parrot_Int Parrot_api_pmc_deserialize_bytes(
- Parrot_PMC interp_pmc,
+ ARGIN(Parrot_PMC interp_pmc),
ARGIN(const unsigned char * const fpmc),
- Parrot_Int length,
+ ARGIN_NULLOK(Parrot_Int length),
ARGOUT(Parrot_PMC * pmc))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(4)
FUNC_MODIFIES(* pmc);
PARROT_API
Parrot_Int Parrot_api_pmc_get_class(
- Parrot_PMC interp_pmc,
- Parrot_PMC key,
- ARGOUT(Parrot_PMC *class))
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC key),
+ ARGOUT(Parrot_PMC *class_pmc))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
__attribute__nonnull__(3)
- FUNC_MODIFIES(*class);
+ FUNC_MODIFIES(*class_pmc);
PARROT_API
Parrot_Int Parrot_api_pmc_get_float(
- Parrot_PMC interp_pmc,
- Parrot_PMC pmc,
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC pmc),
ARGOUT(Parrot_Float * value))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(* value);
PARROT_API
Parrot_Int Parrot_api_pmc_get_integer(
- Parrot_PMC interp_pmc,
- Parrot_PMC pmc,
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC pmc),
ARGOUT(Parrot_Int * value))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(* value);
PARROT_API
Parrot_Int Parrot_api_pmc_get_keyed_int(
- Parrot_PMC interp_pmc,
- Parrot_PMC pmc,
- Parrot_Int key,
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC pmc),
+ ARGIN_NULLOK(Parrot_Int key),
ARGOUT(Parrot_PMC * value))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
__attribute__nonnull__(4)
FUNC_MODIFIES(* value);
PARROT_API
Parrot_Int Parrot_api_pmc_get_keyed_string(
- Parrot_PMC interp_pmc,
- Parrot_PMC pmc,
- Parrot_String key,
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC pmc),
+ ARGIN(Parrot_String key),
ARGOUT(Parrot_PMC * value))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3)
__attribute__nonnull__(4)
FUNC_MODIFIES(* value);
PARROT_API
Parrot_Int Parrot_api_pmc_get_string(
- Parrot_PMC interp_pmc,
- Parrot_PMC pmc,
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC pmc),
ARGOUT(Parrot_String * str))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(* str);
PARROT_API
Parrot_Int Parrot_api_pmc_invoke(
- Parrot_PMC interp_pmc,
- Parrot_PMC sub,
- Parrot_PMC signature);
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC sub),
+ ARGIN(Parrot_PMC signature))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
PARROT_API
Parrot_Int Parrot_api_pmc_new(
- Parrot_PMC interp_pmc,
- Parrot_PMC class,
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC class_pmc),
ARGOUT(Parrot_PMC *pmc))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
__attribute__nonnull__(3)
FUNC_MODIFIES(*pmc);
PARROT_API
Parrot_Int Parrot_api_pmc_null(
- Parrot_PMC interp_pmc,
+ ARGIN(Parrot_PMC interp_pmc),
ARGMOD(Parrot_PMC *pmctonull))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*pmctonull);
PARROT_API
Parrot_Int Parrot_api_pmc_set_float(
- Parrot_PMC interp_pmc,
- Parrot_PMC pmc,
- Parrot_Float value);
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC pmc),
+ ARGIN_NULLOK(Parrot_Float value))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
PARROT_API
Parrot_Int Parrot_api_pmc_set_integer(
- Parrot_PMC interp_pmc,
- Parrot_PMC pmc,
- Parrot_Int value);
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC pmc),
+ ARGIN_NULLOK(Parrot_Int value))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
PARROT_API
Parrot_Int Parrot_api_pmc_set_keyed_int(
- Parrot_PMC interp_pmc,
- Parrot_PMC pmc,
- Parrot_Int key,
- Parrot_PMC value);
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC pmc),
+ ARGIN_NULLOK(Parrot_Int key),
+ ARGIN(Parrot_PMC value))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(4);
PARROT_API
Parrot_Int Parrot_api_pmc_set_keyed_string(
- Parrot_PMC interp_pmc,
- Parrot_PMC pmc,
- Parrot_String key,
- Parrot_PMC value);
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC pmc),
+ ARGIN(Parrot_String key),
+ ARGIN(Parrot_PMC value))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3)
+ __attribute__nonnull__(4);
PARROT_API
Parrot_Int Parrot_api_pmc_set_string(
- Parrot_PMC interp_pmc,
- Parrot_PMC pmc,
- Parrot_String value);
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_PMC pmc),
+ ARGIN(Parrot_String value))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
PARROT_API
Parrot_Int Parrot_api_pmc_wrap_string_array(
- Parrot_PMC interp_pmc,
- Parrot_Int argc,
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN_NULLOK(Parrot_Int argc),
ARGIN(const char ** argv),
ARGOUT(Parrot_PMC * args))
+ __attribute__nonnull__(1)
__attribute__nonnull__(3)
__attribute__nonnull__(4)
FUNC_MODIFIES(* args);
#define ASSERT_ARGS_Parrot_api_add_exception_handler \
- __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(handler))
#define ASSERT_ARGS_Parrot_api_pmc_box_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(str_pmc))
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(str) \
+ , PARROT_ASSERT_ARG(str_pmc))
#define ASSERT_ARGS_Parrot_api_pmc_deserialize __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(pmc))
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(fpmc) \
+ , PARROT_ASSERT_ARG(pmc))
#define ASSERT_ARGS_Parrot_api_pmc_deserialize_bytes \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(fpmc) \
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(fpmc) \
, PARROT_ASSERT_ARG(pmc))
#define ASSERT_ARGS_Parrot_api_pmc_get_class __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(class))
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(key) \
+ , PARROT_ASSERT_ARG(class_pmc))
#define ASSERT_ARGS_Parrot_api_pmc_get_float __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(value))
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(pmc) \
+ , PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_Parrot_api_pmc_get_integer __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(value))
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(pmc) \
+ , PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_Parrot_api_pmc_get_keyed_int __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(value))
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(pmc) \
+ , PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_Parrot_api_pmc_get_keyed_string \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(value))
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(pmc) \
+ , PARROT_ASSERT_ARG(key) \
+ , PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_Parrot_api_pmc_get_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(str))
-#define ASSERT_ARGS_Parrot_api_pmc_invoke __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(pmc) \
+ , PARROT_ASSERT_ARG(str))
+#define ASSERT_ARGS_Parrot_api_pmc_invoke __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(sub) \
+ , PARROT_ASSERT_ARG(signature))
#define ASSERT_ARGS_Parrot_api_pmc_new __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(pmc))
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(class_pmc) \
+ , PARROT_ASSERT_ARG(pmc))
#define ASSERT_ARGS_Parrot_api_pmc_null __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(pmctonull))
-#define ASSERT_ARGS_Parrot_api_pmc_set_float __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
-#define ASSERT_ARGS_Parrot_api_pmc_set_integer __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
-#define ASSERT_ARGS_Parrot_api_pmc_set_keyed_int __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(pmctonull))
+#define ASSERT_ARGS_Parrot_api_pmc_set_float __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(pmc))
+#define ASSERT_ARGS_Parrot_api_pmc_set_integer __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(pmc))
+#define ASSERT_ARGS_Parrot_api_pmc_set_keyed_int __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(pmc) \
+ , PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_Parrot_api_pmc_set_keyed_string \
- __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
-#define ASSERT_ARGS_Parrot_api_pmc_set_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+ __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(pmc) \
+ , PARROT_ASSERT_ARG(key) \
+ , PARROT_ASSERT_ARG(value))
+#define ASSERT_ARGS_Parrot_api_pmc_set_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(pmc) \
+ , PARROT_ASSERT_ARG(value))
#define ASSERT_ARGS_Parrot_api_pmc_wrap_string_array \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(argv) \
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(argv) \
, PARROT_ASSERT_ARG(args))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/embed/pmc.c */
View
14 src/debug.c
@@ -3264,7 +3264,8 @@ PDB_help(PARROT_INTERP, ARGIN(const char *command))
/*
-=item C<STRING *Parrot_dbg_get_exception_backtrace(PARROT_INTERP, ARGMOD(PMC * exception))>
+=item C<STRING * Parrot_dbg_get_exception_backtrace(PARROT_INTERP, PMC *
+exception)>
Returns an string containing the backtrace of the interpreter's call chain for a given exception.
@@ -3276,7 +3277,7 @@ Returns an string containing the backtrace of the interpreter's call chain for a
STRING *
Parrot_dbg_get_exception_backtrace(PARROT_INTERP, ARGMOD(PMC * exception))
{
- ASSERT_ARGS(PDB_backtrace)
+ ASSERT_ARGS(Parrot_dbg_get_exception_backtrace)
STRING *str;
PMC *old = PMCNULL;
int rec_level = 0;
@@ -3295,9 +3296,9 @@ Parrot_dbg_get_exception_backtrace(PARROT_INTERP, ARGMOD(PMC * exception))
/*
-=item CS<static PMC * get_exception_context(PARROT_INTERP, ARGMOD(PMC * exception))>
+=item C<static PMC * get_exception_context(PARROT_INTERP, PMC * exception)>
-Returns the context in which the exception was generated.
+Returns the context in which the exception was generated.
=cut
@@ -3306,6 +3307,7 @@ Returns the context in which the exception was generated.
static PMC *
get_exception_context(PARROT_INTERP, ARGMOD(PMC * exception))
{
+ ASSERT_ARGS(get_exception_context)
PMC * const thrower = VTABLE_get_attr_str(interp, exception, CONST_STRING(interp, "thrower"));
if (!PMC_IS_NULL(thrower))
return thrower;
@@ -3344,8 +3346,8 @@ PDB_backtrace(PARROT_INTERP)
/*
-=item C<static STRING * PDB_get_continuation_backtrace(PARROT_INTERP, ARGMOD_NULLOK(PMC * sub),
-ARGMOD(PMC * ctx))>
+=item C<static STRING * PDB_get_continuation_backtrace(PARROT_INTERP, PMC * sub,
+PMC * ctx)>
Returns an string with the backtrace of interpreter's call chain for the given sub including
context information.
View
295 src/embed/api.c
@@ -3,11 +3,15 @@ Copyright (C) 2010, Parrot Foundation.
=head1 NAME
-src/embed/api.c - TO COME
+src/embed/api.c - The Parrot embedding interface
=head1 DESCRIPTION
-TO COME.
+This file implements functions of the Parrot embedding interface.
+
+=head2 Functions
+
+=over 4
=cut
@@ -24,15 +28,17 @@ TO COME.
/*
-=item C<Parrot_Int Parrot_api_get_result(Parrot_PMC interp_pmc, ARGOUT(Parrot_Int *is_error),
-ARGOUT(Parrot_PMC * exception), ARGOUT(Parrot_Int *exit_code), ARGOUT(Parrot_String * errmsg))>
+=item C<Parrot_Int Parrot_api_get_result(Parrot_PMC interp_pmc, Parrot_Int
+*is_error, Parrot_PMC * exception, Parrot_Int *exit_code, Parrot_String *
+errmsg)>
-Gets the results of the last API function call and stores the results in C<is_error>,
-C<exception>, C<exit_code> and C<errmsg>. This function returns a true value if this
-call is successful and false value otherwise. The stored information is as follow:
+Gets the results of the last API function call and stores the results in
+C<is_error>, C<exception>, C<exit_code> and C<errmsg>. This function returns
+a true value if this call is successful and false value otherwise. The stored
+information is as follow:
-C<is_error> a true value if an unhandled exception was thrown or the program terminated
-with an error condition and a false value otherwise.
+C<is_error> a true value if an unhandled exception was thrown or the program
+terminated with an error condition and a false value otherwise.
C<exception> the last exception thrown.
@@ -50,6 +56,7 @@ Parrot_api_get_result(Parrot_PMC interp_pmc, ARGOUT(Parrot_Int *is_error),
ARGOUT(Parrot_PMC * exception), ARGOUT(Parrot_Int *exit_code),
ARGOUT(Parrot_String * errmsg))
{
+ ASSERT_ARGS(Parrot_api_get_result)
EMBED_API_CALLIN(interp_pmc, interp)
*exit_code = interp->exit_code;
*exception = interp->final_exception;
@@ -69,11 +76,11 @@ Parrot_api_get_result(Parrot_PMC interp_pmc, ARGOUT(Parrot_Int *is_error),
/*
=item C<Parrot_Int Parrot_api_get_exception_backtrace(Parrot_PMC interp_pmc,
-Parrot_PMC exception, ARGOUT(Parrot_String * bt))>
+Parrot_PMC exception, Parrot_String * bt)>
-Gets the backtrace of the interpreter's call chain for the given exception C<expcetion>
-and stores the results in string C<bt>. This function returns a true value if this
-call is successful and false value otherwise.
+Gets the backtrace of the interpreter's call chain for the given exception
+C<expcetion> and stores the results in string C<bt>. This function returns a
+true value if this call is successful and false value otherwise.
=cut
@@ -84,6 +91,7 @@ Parrot_Int
Parrot_api_get_exception_backtrace(Parrot_PMC interp_pmc,
Parrot_PMC exception, ARGOUT(Parrot_String * bt))
{
+ ASSERT_ARGS(Parrot_api_get_exception_backtrace)
EMBED_API_CALLIN(interp_pmc, interp)
STRING * const bts = Parrot_dbg_get_exception_backtrace(interp, exception);
*bt = bts;
@@ -93,13 +101,13 @@ Parrot_api_get_exception_backtrace(Parrot_PMC interp_pmc,
/*
-=item C<Parrot_Int Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int flags,
-ARGIN_NULLOK(Parrot_Init_Args *args), ARGOUT(Parrot_PMC *interp))>
+=item C<Parrot_Int Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int
+flags, Parrot_Init_Args *args, Parrot_PMC *interp)>
-Creates a new interpreter and stores it in C<interp>. It takes three optional parameters
-the new interpreter's C<flags>, the initialization paremeters C<args> and the C<parent>
-interpreter. This function returns a true value if this call is successful and false
-value otherwise.
+Creates a new interpreter and stores it in C<interp>. It takes three optional
+parameters the new interpreter's C<flags>, the initialization paremeters C<args>
+and the C<parent> interpreter. This function returns a true value if this call
+is successful and false value otherwise.
=cut
@@ -110,7 +118,7 @@ Parrot_Int
Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int flags,
ARGIN_NULLOK(Parrot_Init_Args *args), ARGOUT(Parrot_PMC *interp))
{
- //ASSERT_ARGS(Parrot_api_make_interpreter)
+ ASSERT_ARGS(Parrot_api_make_interpreter)
int alt_stacktop;
Parrot_Interp interp_raw;
void *stacktop_ptr = &alt_stacktop;
@@ -134,12 +142,12 @@ Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int flags,
/*
-=item C<Parrot_Int Parrot_api_set_runcore(Parrot_PMC interp_pmc, ARGIN(const char * corename),
-Parrot_UInt trace)>
+=item C<Parrot_Int Parrot_api_set_runcore(Parrot_PMC interp_pmc, const char *
+corename, Parrot_UInt trace)>
-Sets the C<interp_pmc>'s bytecode running core, the core is specified by the C<corename>
-parameter. This function returns a true value if this call is successful and false value
-otherwise.
+Sets the C<interp_pmc>'s bytecode running core, the core is specified by the
+C<corename>. This function returns a true value if this call is successful and
+false value otherwise.
=cut
@@ -150,7 +158,7 @@ Parrot_Int
Parrot_api_set_runcore(Parrot_PMC interp_pmc, ARGIN(const char * corename),
Parrot_UInt trace)
{
- //ASSERT_ARGS(Parrot_api_set_runcore)
+ ASSERT_ARGS(Parrot_api_set_runcore)
EMBED_API_CALLIN(interp_pmc, interp)
if (trace) {
Parrot_pcc_trace_flags_on(interp, interp->ctx, trace);
@@ -178,11 +186,12 @@ Parrot_api_set_runcore(Parrot_PMC interp_pmc, ARGIN(const char * corename),
/*
-=item C<Parrot_Int Parrot_api_debug_flag(Parrot_PMC interp_pmc, Parrot_Int flags, Parrot_Int set)>
+=item C<Parrot_Int Parrot_api_debug_flag(Parrot_PMC interp_pmc, Parrot_Int
+flags, Parrot_Int set)>
-Set/Unset the C<interp_pmc>'s debug flags. If C<set> is in a true value debug flags are set
-otherwise debug flags are cleared. This function returns a true value if this call is successful
-and false value otherwise.
+Sets/Unsets the C<interp_pmc>'s debug flags. If C<set> is in a true value debug
+flags are set otherwise debug flags are cleared. This function returns a true
+value if this call is successful and false value otherwise.
=cut
@@ -192,7 +201,7 @@ PARROT_API
Parrot_Int
Parrot_api_debug_flag(Parrot_PMC interp_pmc, Parrot_Int flags, Parrot_Int set)
{
- //ASSERT_ARGS(Parrot_api_debug_flag)
+ ASSERT_ARGS(Parrot_api_debug_flag)
EMBED_API_CALLIN(interp_pmc, interp)
if (set)
interp->debug_flags |= flags;
@@ -203,11 +212,12 @@ Parrot_api_debug_flag(Parrot_PMC interp_pmc, Parrot_Int flags, Parrot_Int set)
/*
-=item C<Parrot_Int Parrot_api_flag(Parrot_PMC interp_pmc, Parrot_Int flags, Parrot_Int set)>
+=item C<Parrot_Int Parrot_api_flag(Parrot_PMC interp_pmc, Parrot_Int flags,
+Parrot_Int set)>
-Set/Unset the C<interp_pmc>'s general flags. If C<set> is in a true value general flags are
-set otherwise passed flags are cleared. This function returns a true value if this call is
-successful and false value otherwise.
+Set/Unset the C<interp_pmc>'s general flags. If C<set> is in a true value general
+flags are set otherwise passed flags are cleared. This function returns a true
+value if this call is successful and false value otherwise.
=cut
@@ -217,7 +227,7 @@ PARROT_API
Parrot_Int
Parrot_api_flag(Parrot_PMC interp_pmc, Parrot_Int flags, Parrot_Int set)
{
- //ASSERT_ARGS(Parrot_api_flag)
+ ASSERT_ARGS(Parrot_api_flag)
EMBED_API_CALLIN(interp_pmc, interp)
if (set) {
Interp_flags_SET(interp, flags);
@@ -231,10 +241,11 @@ Parrot_api_flag(Parrot_PMC interp_pmc, Parrot_Int flags, Parrot_Int set)
/*
-=item C<Parrot_Int Parrot_api_set_executable_name(Parrot_PMC interp_pmc, ARGIN(const char * name))>
+=item C<Parrot_Int Parrot_api_set_executable_name(Parrot_PMC interp_pmc, const
+char * name)>
-Sets the executable name for the C<interp_pmc> interpreter. This function returns a true
-value if this call is successful and false value otherwise.
+Sets the executable name for the C<interp_pmc> interpreter. This function returns
+a true value if this call is successful and false value otherwise.
=cut
@@ -244,7 +255,7 @@ PARROT_API
Parrot_Int
Parrot_api_set_executable_name(Parrot_PMC interp_pmc, ARGIN(const char * name))
{
- //ASSERT_ARGS(Parrot_api_set_executable_name)
+ ASSERT_ARGS(Parrot_api_set_executable_name)
EMBED_API_CALLIN(interp_pmc, interp)
STRING * const name_str = Parrot_str_new(interp, name, 0);
PMC * const name_pmc = Parrot_pmc_new(interp, enum_class_String);
@@ -258,8 +269,9 @@ Parrot_api_set_executable_name(Parrot_PMC interp_pmc, ARGIN(const char * name))
=item C<Parrot_Int Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)>
-Destroys the C<interp_pmc> interpreter, freeing the memory structures allocated for it.
-This function returns a true value if this call is successful and false value otherwise.
+Destroys the C<interp_pmc> interpreter, freeing the memory structures allocated
+for it. This function returns a true value if this call is successful and false
+value otherwise.
=cut
@@ -269,7 +281,7 @@ PARROT_API
Parrot_Int
Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)
{
- //ASSERT_ARGS(Parrot_api_destroy_interpreter)
+ ASSERT_ARGS(Parrot_api_destroy_interpreter)
EMBED_API_CALLIN(interp_pmc, interp)
Parrot_destroy(interp);
Parrot_x_exit(interp, 0);
@@ -281,8 +293,8 @@ Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)
=item C<Parrot_Int Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc, const
char *filename, Parrot_PMC * pbc)>
-Load a bytecode file and return a bytecode PMC. This function returns a true value
-if this call is successful and false value otherwise.
+Load a bytecode file and stores the resulting bytecode in C<pbc>. This function
+returns a true value if this call is successful and false value otherwise.
=cut
@@ -296,7 +308,7 @@ Parrot_Int
Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc,
ARGIN(const char *filename), ARGOUT(Parrot_PMC * pbc))
{
- //ASSERT_ARGS(Parrot_api_load_bytecode_file)
+ ASSERT_ARGS(Parrot_api_load_bytecode_file)
EMBED_API_CALLIN(interp_pmc, interp)
PackFile * const pf = Parrot_pbc_read(interp, filename, 0);
if (!pf)
@@ -309,12 +321,12 @@ Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc,
/*
-=item C<Parrot_Int Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc,
-ARGIN(const unsigned char * const pbc), Parrot_Int bytecode_size,
-ARGOUT(Parrot_PMC * pbcpmc))>
+=item C<Parrot_Int Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc, const
+unsigned char * const pbc, Parrot_Int bytecode_size, Parrot_PMC * pbcpmc)>
-
-This function returns a true value if this call is successful and false value otherwise.
+Unpacks a bytecode from a buffer C<pbc> of a C<bytecode_size> size, and stores
+the resulting bytecode in C<pbcpmc>. This function returns a true value if this
+call is successful and false value otherwise.
=cut
@@ -326,6 +338,7 @@ Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc,
ARGIN(const unsigned char * const pbc), Parrot_Int bytecode_size,
ARGOUT(Parrot_PMC * pbcpmc))
{
+ ASSERT_ARGS(Parrot_api_load_bytecode_bytes)
EMBED_API_CALLIN(interp_pmc, interp)
PackFile * const pf = PackFile_new(interp, 0);
if (!pf)
@@ -343,11 +356,25 @@ Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc,
/* TODO: This only works with the inital bytecode. After this we should use
Parrot_append_bytecode or something similar */
+/*
+
+=item C<Parrot_Int Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
+pbc, Parrot_PMC *main_sub)>
+
+Prepares the bytecode C<pbc> to be run and stores the entry point subroutine in
+C<main_sub>. This function returns a true value if this call is successful and
+false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
ARGOUT(Parrot_PMC *main_sub))
{
+ ASSERT_ARGS(Parrot_api_ready_bytecode)
EMBED_API_CALLIN(interp_pmc, interp)
PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
@@ -369,12 +396,25 @@ Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
EMBED_API_CALLOUT(interp_pmc, interp)
}
+
+/*
+
+=item C<Parrot_Int Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
+pbc, Parrot_PMC mainargs)>
+
+Runs the bytecode C<pbc> passing optional C<mainargs> parameters. This function
+returns a true value if this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
Parrot_PMC mainargs)
{
- //ASSERT_ARGS(Parrot_api_run_bytecode)
+ ASSERT_ARGS(Parrot_api_run_bytecode)
EMBED_API_CALLIN(interp_pmc, interp)
PMC * main_sub = NULL;
@@ -408,38 +448,77 @@ Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc,
+Parrot_PMC pbc, const char * const outfile, Parrot_Int opts)>
+
+Disassembles and prints out the C<pbc> bytecode. This function returns a true
+value if this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
- ARGIN(const char * const outfile), Parrot_Int opts)
+ ARGIN_NULLOK(const char * const outfile), Parrot_Int opts)
{
+ ASSERT_ARGS(Parrot_api_disassemble_bytecode)
EMBED_API_CALLIN(interp_pmc, interp)
PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
if (!pf)
Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
if (pf->cur_cs != NULL)
Parrot_pbc_load(interp, pf);
+ /* TODO: Break up the dependency with emebed.c */
Parrot_disassemble(interp, outfile, (Parrot_disassemble_options)opts);
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int
+flags)>
+
+Enables C<inter_pmc>'s warning messages the type of warning information to be
+print out is specified by C<flags>. This function returns a true value if this
+call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int flags)
{
- //ASSERT_ARGS(Parrot_api_set_warnings)
+ ASSERT_ARGS(Parrot_api_set_warnings)
EMBED_API_CALLIN(interp_pmc, interp)
/* Activates the given warnings. (Macro from warnings.h.) */
PARROT_WARNINGS_on(interp, flags);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_set_output_file(Parrot_PMC interp_pmc, const char
+* filename)>
+
+Sets the C<interp_pmc>'s output file name specified by C<filename>. This function
+returns a true value if this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
Parrot_api_set_output_file(Parrot_PMC interp_pmc,
ARGIN_NULLOK(const char * filename))
{
- //ASSERT_ARGS(Parrot_api_set_output_file)
+ ASSERT_ARGS(Parrot_api_set_output_file)
EMBED_API_CALLIN(interp_pmc, interp)
if (!filename && !interp->output_file)
interp->output_file = "-";
@@ -448,34 +527,70 @@ Parrot_api_set_output_file(Parrot_PMC interp_pmc,
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
+const char *path)>
+
+Adds C<path> to the C<inter_pmc>'s library search path list. This function
+returns a true value if this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
ARGIN(const char *path))
{
- //ASSERT_ARGS(Parrot_api_add_library_search_path)
+ ASSERT_ARGS(Parrot_api_add_library_search_path)
EMBED_API_CALLIN(interp_pmc, interp)
Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LIBRARY);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
+const char *path)>
+
+Adds C<path> to the C<inter_pmc>'s include search path list. This function
+returns a true value if this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
ARGIN(const char *path))
{
- //ASSERT_ARGS(Parrot_api_add_include_search_path)
+ ASSERT_ARGS(Parrot_api_add_include_search_path)
EMBED_API_CALLIN(interp_pmc, interp)
Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_INCLUDE);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
+const char *path)>
+
+Adds C<path> to the C<inter_pmc>'s dynext search path list. This function
+returns a true value if this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
ARGIN(const char *path))
{
- //ASSERT_ARGS(Parrot_api_add_dynext_search_path)
+ ASSERT_ARGS(Parrot_api_add_dynext_search_path)
EMBED_API_CALLIN(interp_pmc, interp)
Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_DYNEXT);
EMBED_API_CALLOUT(interp_pmc, interp)
@@ -486,8 +601,9 @@ Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
=item C<Parrot_Int Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int
in, Parrot_Int out, Parrot_Int err)>
-Set the std file descriptors for the embedded interpreter. Any file descriptor
-passed as argument and set to C<PIO_INVALID_HANDLE> is ignored.
+Set the C<interp_pmc>'s standard file descriptors STDIN, STDOUT, STDERR. Any
+file descriptor set to C<PIO_INVALID_HANDLE> is ignored. This function returns
+a true value if this call is successful and false value otherwise.
=cut
@@ -498,7 +614,7 @@ Parrot_Int
Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int in,
Parrot_Int out, Parrot_Int err)
{
- //ASSERT_ARGS(Parrot_api_set_stdhandles)
+ ASSERT_ARGS(Parrot_api_set_stdhandles)
EMBED_API_CALLIN(interp_pmc, interp)
void *dummy;
@@ -524,20 +640,47 @@ Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int in,
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
+Parrot_String *runtime)>
+
+Stores in C<runtime> the C<interp_pmc>'s running path. This function returns a
+true value if this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
ARGOUT(Parrot_String *runtime))
{
+ ASSERT_ARGS(Parrot_api_get_runtime_path)
EMBED_API_CALLIN(interp_pmc, interp)
*runtime = Parrot_get_runtime_path(interp);
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc,
+Parrot_PMC confighash)>
+
+Sets the C<interp_pmc>'s configuration hash passed in C<confighash>. This
+function returns a true value if this call is successful and false value
+otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc, Parrot_PMC confighash)
{
+ ASSERT_ARGS(Parrot_api_set_configuration_hash)
EMBED_API_CALLIN(interp_pmc, interp)
Parrot_set_config_hash_pmc(interp, confighash);
Parrot_lib_update_paths_from_config_hash(interp);
@@ -545,9 +688,20 @@ Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc, Parrot_PMC confighash)
}
/*
-This is an evil hack to provide a wrapper around IMCC to catch unhandled
-exceptions without having to assume IMCC is linked in with libparrot. Delete
-this as soon as we don't need it anymore.
+
+=item C<Parrot_Int Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc, const char *
+sourcefile, int argc, const char **argv, Parrot_PMC* bytecodepmc, int *result,
+imcc_hack_func_t func)>
+
+WARNING: This is an evil hack to provide a wrapper around IMCC to catch unhandled
+exceptions without having to assume IMCC is linked in with libparrot. Delete this
+as soon as we don't need it anymore.
+
+This function returns a true value if this call is successful and false value
+otherwise.
+
+=cut
+
*/
PARROT_API
@@ -556,6 +710,7 @@ Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc, const char * sourcefile,
int argc, const char **argv, Parrot_PMC* bytecodepmc, int *result,
imcc_hack_func_t func)
{
+ ASSERT_ARGS(Parrot_api_wrap_imcc_hack)
EMBED_API_CALLIN(interp_pmc, interp)
*result = func(interp_pmc, sourcefile, argc, argv, bytecodepmc);
EMBED_API_CALLOUT(interp_pmc, interp)
@@ -566,8 +721,9 @@ Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc, const char * sourcefile,
=item C<Parrot_Int Parrot_api_load_language(Parrot_PMC interp_pmc, Parrot_String
lang)>
-Load the compiler libraries for a given high-level language into the
-interpreter.
+Loads the HLL compiler libraries for C<lang> into the C<interp_pmc>. This
+function returns a true value if this call is successful and false value
+otherwise.
=cut
@@ -583,12 +739,14 @@ Parrot_api_load_language(Parrot_PMC interp_pmc, Parrot_String lang)
EMBED_API_CALLOUT(interp_pmc, interp);
}
-
/*
=item C<Parrot_Int Parrot_api_get_compiler(Parrot_PMC interp_pmc, Parrot_String
type, Parrot_PMC *compiler)>
+Gets the compiler PMC and stores it in C<compiler>. This function returns a true
+value if this call is successful and false value otherwise.
+
=cut
*/
@@ -609,6 +767,9 @@ Parrot_api_get_compiler(Parrot_PMC interp_pmc, Parrot_String type,
=item C<Parrot_Int Parrot_api_set_compiler(Parrot_PMC interp_pmc, Parrot_String
type, Parrot_PMC compiler)>
+Sets the C<compiler> object for the C<type> files. This function returns a true
+value if this call is successful and false value otherwise.
+
=cut
*/
View
21 src/embed/embed_private.h
@@ -1,6 +1,11 @@
+/* api.h
+ * Copyright (C) 2001-2010, Parrot Foundation.
+ * Overview:
+ * Parrot embed API's private macros
+ */
-#ifndef PARROT_EMBED_PRIVATE_H
-#define PARROT_EMBED_PRIVATE_H
+#ifndef PARROT_EMBED_PRIVATE_H_GUARD
+#define PARROT_EMBED_PRIVATE_H_GUARD
#include "pmc/pmc_parrotinterpreter.h"
@@ -19,7 +24,8 @@
Interp * const __interp = GET_INTERP(p); \
__interp->api_jmp_buf = NULL; \
return !__interp->exit_code; \
- } else { \
+ } \
+ else { \
{
#define EMBED_API_CALLOUT(p, i) \
@@ -32,4 +38,11 @@
return 1; \
}
-#endif /* PARROT_EMBED_PRIVATE_H */
+#endif /* PARROT_EMBED_PRIVATE_H_GUARD */
+
+/*
+ * Local variables:
+ * c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
+ */
View
365 src/embed/pmc.c
@@ -1,25 +1,72 @@
+/*
+Copyright (C) 2010, Parrot Foundation.
+
+=head1 NAME
+
+src/embed/pmc.c - The Parrot PMC embedding interface
+
+=head1 DESCRIPTION
+
+This file implements PMC functions of the Parrot embedding interface.
+
+=head2 Functions
+
+=over 4
+
+=cut
+
+*/
+
#include "parrot/parrot.h"
#include "parrot/api.h"
#include "embed_private.h"
/* HEADERIZER HFILE: include/parrot/api.h */
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_deserialize(Parrot_PMC interp_pmc,
+Parrot_String fpmc, Parrot_PMC * pmc)>
+
+Deserializes the PMC contained in C<fpmc> string and stores it in C<pmc>. This
+function returns a true value if this call is successful and false value
+otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_deserialize(Parrot_PMC interp_pmc, Parrot_String fpmc,
+Parrot_api_pmc_deserialize(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_String fpmc),
ARGOUT(Parrot_PMC * pmc))
{
+ ASSERT_ARGS(Parrot_api_pmc_deserialize)
EMBED_API_CALLIN(interp_pmc, interp)
*pmc = Parrot_thaw(interp, fpmc);
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_deserialize_bytes(Parrot_PMC interp_pmc, const
+unsigned char * const fpmc, Parrot_Int length, Parrot_PMC * pmc)>
+
+Deserializes the PMC contained in C<fpmc> buffer of C<length> and stores it in
+C<pmc>. This function returns a true value if this call is successful and false
+value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_deserialize_bytes(Parrot_PMC interp_pmc,
- ARGIN(const unsigned char * const fpmc), Parrot_Int length,
+Parrot_api_pmc_deserialize_bytes(ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(const unsigned char * const fpmc), ARGIN_NULLOK(Parrot_Int length),
ARGOUT(Parrot_PMC * pmc))
{
+ ASSERT_ARGS(Parrot_api_pmc_deserialize_bytes)
EMBED_API_CALLIN(interp_pmc, interp)
STRING * const fpmc_str = Parrot_str_new_init(interp, (const char *)fpmc,
length, Parrot_binary_encoding_ptr, PObj_external_FLAG);
@@ -27,120 +74,284 @@ Parrot_api_pmc_deserialize_bytes(Parrot_PMC interp_pmc,
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_null(Parrot_PMC interp_pmc, Parrot_PMC
+*pmctonull)>
+
+Nullify C<pmctonull> PMC. This function returns a true value if this call is
+successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_null(Parrot_PMC interp_pmc, ARGMOD(Parrot_PMC *pmctonull))
+Parrot_api_pmc_null(ARGIN(Parrot_PMC interp_pmc), ARGMOD(Parrot_PMC *pmctonull))
{
+ ASSERT_ARGS(Parrot_api_pmc_null)
EMBED_API_CALLIN(interp_pmc, interp)
*pmctonull = PMCNULL;
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_get_string(Parrot_PMC interp_pmc, Parrot_PMC
+pmc, Parrot_String * str)>
+
+Stores an string in C<str> that represents the string value of the PMC. This
+function returns a true value if this call is successful and false value
+otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_get_string(Parrot_PMC interp_pmc, Parrot_PMC pmc,
+Parrot_api_pmc_get_string(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC pmc),
ARGOUT(Parrot_String * str))
{
+ ASSERT_ARGS(Parrot_api_pmc_get_string)
EMBED_API_CALLIN(interp_pmc, interp)
*str = VTABLE_get_string(interp, pmc);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_get_integer(Parrot_PMC interp_pmc, Parrot_PMC
+pmc, Parrot_Int * value)>
+
+Stores an integer in C<value> that represents the integer value of the PMC. This
+function returns a true value if this call is successful and false value
+otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_get_integer(Parrot_PMC interp_pmc, Parrot_PMC pmc,
+Parrot_api_pmc_get_integer(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC pmc),
ARGOUT(Parrot_Int * value))
{
+ ASSERT_ARGS(Parrot_api_pmc_get_integer)
EMBED_API_CALLIN(interp_pmc, interp)
*value = VTABLE_get_integer(interp, pmc);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_get_float(Parrot_PMC interp_pmc, Parrot_PMC
+pmc, Parrot_Float * value)>
+
+Stores a float in C<value> that represents the float value of the PMC. This
+function returns a true value if this call is successful and false value
+otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_get_float(Parrot_PMC interp_pmc, Parrot_PMC pmc,
+Parrot_api_pmc_get_float(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC pmc),
ARGOUT(Parrot_Float * value))
{
+ ASSERT_ARGS(Parrot_api_pmc_get_float)
EMBED_API_CALLIN(interp_pmc, interp)
*value = VTABLE_get_number(interp, pmc);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_get_keyed_int(Parrot_PMC interp_pmc,
+Parrot_PMC pmc, Parrot_Int key, Parrot_PMC * value)>
+
+Stores the integer value of whatever is stored at the element of the C<pmc>
+indexed by C<key>. This function returns a true value if this call is successful
+and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_get_keyed_int(Parrot_PMC interp_pmc, Parrot_PMC pmc,
- Parrot_Int key, ARGOUT(Parrot_PMC * value))
+Parrot_api_pmc_get_keyed_int(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC pmc),
+ ARGIN_NULLOK(Parrot_Int key), ARGOUT(Parrot_PMC * value))
{
+ ASSERT_ARGS(Parrot_api_pmc_get_keyed_int)
EMBED_API_CALLIN(interp_pmc, interp)
*value = VTABLE_get_pmc_keyed_int(interp, pmc, key);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_get_keyed_string(Parrot_PMC interp_pmc,
+Parrot_PMC pmc, Parrot_String key, Parrot_PMC * value)>
+
+Stores the string value of whatever is stored at the element of the C<pmc>
+indexed by C<key>. This function returns a true value if this call is successful
+and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_get_keyed_string(Parrot_PMC interp_pmc, Parrot_PMC pmc,
- Parrot_String key, ARGOUT(Parrot_PMC * value))
+Parrot_api_pmc_get_keyed_string(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC pmc),
+ ARGIN(Parrot_String key), ARGOUT(Parrot_PMC * value))
{
+ ASSERT_ARGS(Parrot_api_pmc_get_keyed_string)
EMBED_API_CALLIN(interp_pmc, interp)
*value = VTABLE_get_pmc_keyed_str(interp, pmc, key);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_set_string(Parrot_PMC interp_pmc, Parrot_PMC
+pmc, Parrot_String value)>
+
+Sets the string C<value> as C<pmc>'s value. This function returns a true value if
+this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_set_string(Parrot_PMC interp_pmc, Parrot_PMC pmc,
- Parrot_String value)
+Parrot_api_pmc_set_string(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC pmc),
+ ARGIN(Parrot_String value))
{
+ ASSERT_ARGS(Parrot_api_pmc_set_string)
EMBED_API_CALLIN(interp_pmc, interp)
VTABLE_set_string_native(interp, pmc, value);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_set_integer(Parrot_PMC interp_pmc, Parrot_PMC
+pmc, Parrot_Int value)>
+
+Sets the integer C<value> as C<pmc>'s value. This function returns a true value
+if this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_set_integer(Parrot_PMC interp_pmc, Parrot_PMC pmc,
- Parrot_Int value)
+Parrot_api_pmc_set_integer(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC pmc),
+ ARGIN_NULLOK(Parrot_Int value))
{
+ ASSERT_ARGS(Parrot_api_pmc_set_integer)
EMBED_API_CALLIN(interp_pmc, interp)
VTABLE_set_integer_native(interp, pmc, value);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_set_float(Parrot_PMC interp_pmc, Parrot_PMC
+pmc, Parrot_Float value)>
+
+Sets the float C<value> as the C<pmc>'s value. This function returns a true value
+if this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_set_float(Parrot_PMC interp_pmc, Parrot_PMC pmc,
- Parrot_Float value)
+Parrot_api_pmc_set_float(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC pmc),
+ ARGIN_NULLOK(Parrot_Float value))
{
+ ASSERT_ARGS(Parrot_api_pmc_set_float)
EMBED_API_CALLIN(interp_pmc, interp)
VTABLE_set_number_native(interp, pmc, value);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_set_keyed_int(Parrot_PMC interp_pmc,
+Parrot_PMC pmc, Parrot_Int key, Parrot_PMC value)>
+
+Stets the integer C<value> at the element of the C<pmc> indexed by C<key>. This
+function returns a true value if this call is successful and false value
+otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_set_keyed_int(Parrot_PMC interp_pmc, Parrot_PMC pmc,
- Parrot_Int key, Parrot_PMC value)
+Parrot_api_pmc_set_keyed_int(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC pmc),
+ ARGIN_NULLOK(Parrot_Int key), ARGIN(Parrot_PMC value))
{
+ ASSERT_ARGS(Parrot_api_pmc_set_keyed_int)
EMBED_API_CALLIN(interp_pmc, interp)
VTABLE_set_pmc_keyed_int(interp, pmc, key, value);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_set_keyed_string(Parrot_PMC interp_pmc,
+Parrot_PMC pmc, Parrot_String key, Parrot_PMC value)>
+
+Stets the string C<value> at the element of the C<pmc> indexed by C<key>. This
+function returns a true value if this call is successful and false value
+otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_set_keyed_string(Parrot_PMC interp_pmc, Parrot_PMC pmc,
- Parrot_String key, Parrot_PMC value)
+Parrot_api_pmc_set_keyed_string(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC pmc),
+ ARGIN(Parrot_String key), ARGIN(Parrot_PMC value))
{
+ ASSERT_ARGS(Parrot_api_pmc_set_keyed_string)
EMBED_API_CALLIN(interp_pmc, interp)
VTABLE_set_pmc_keyed_str(interp, pmc, key, value);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_box_string(Parrot_PMC interp_pmc,
+Parrot_String str, Parrot_PMC * str_pmc)>
+
+Wraps the string C<str> into a PMC and stores the results in C<str_pmc>. This
+function returns a true value if this call is successful and false value
+otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_box_string(Parrot_PMC interp_pmc, Parrot_String str,
+Parrot_api_pmc_box_string(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_String str),
ARGOUT(Parrot_PMC * str_pmc))
{
+ ASSERT_ARGS(Parrot_api_pmc_box_string)
EMBED_API_CALLIN(interp_pmc, interp)
*str_pmc = Parrot_pmc_new(interp, enum_class_String);
VTABLE_set_string_native(interp, *str_pmc, str);
@@ -149,20 +360,48 @@ Parrot_api_pmc_box_string(Parrot_PMC interp_pmc, Parrot_String str,
/* TODO: Box int and Box float */
+/*
+
+=item C<Parrot_Int Parrot_api_add_exception_handler(Parrot_PMC interp_pmc,
+Parrot_PMC handler)>
+
+Adds a C<handler> to scheduler's list of handlers. This function returns a true
+value if this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_add_exception_handler(Parrot_PMC interp_pmc, Parrot_PMC handler)
+Parrot_api_add_exception_handler(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC handler))
{
+ ASSERT_ARGS(Parrot_api_add_exception_handler)
EMBED_API_CALLIN(interp_pmc, interp)
Parrot_cx_add_handler(interp, handler);
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_invoke(Parrot_PMC interp_pmc, Parrot_PMC sub,
+Parrot_PMC signature)>
+
+Invokes the C<sub> with C<signature> PMC in which parameters are stored. This
+function returns a true value if this call is successful and false value
+otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_invoke(Parrot_PMC interp_pmc, Parrot_PMC sub, Parrot_PMC signature)
+Parrot_api_pmc_invoke(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC sub),
+ ARGIN(Parrot_PMC signature))
{
- EMBED_API_CALLIN(interp_pmc, interp);
+ ASSERT_ARGS(Parrot_api_pmc_invoke)
+ EMBED_API_CALLIN(interp_pmc, interp)
PMC * const old_call_obj = Parrot_pcc_get_signature(interp,
CURRENT_CONTEXT(interp));
Parrot_pcc_invoke_from_sig_object(interp, sub, signature);
@@ -170,12 +409,25 @@ Parrot_api_pmc_invoke(Parrot_PMC interp_pmc, Parrot_PMC sub, Parrot_PMC signatur
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_wrap_string_array(Parrot_PMC interp_pmc,
+Parrot_Int argc, const char ** argv, Parrot_PMC * args)>
+
+Wraps an C<argv> string array of C<argc> size into a PMC array and stores it in
+C<args>. This function returns a true value if this call is successful and false
+value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_wrap_string_array(Parrot_PMC interp_pmc, Parrot_Int argc,
+Parrot_api_pmc_wrap_string_array(ARGIN(Parrot_PMC interp_pmc), ARGIN_NULLOK(Parrot_Int argc),
ARGIN(const char ** argv), ARGOUT(Parrot_PMC * args))
{
- //ASSERT_ARGS(Parrot_api_build_argv_array)
+ ASSERT_ARGS(Parrot_api_pmc_wrap_string_array)
EMBED_API_CALLIN(interp_pmc, interp)
PMC * const userargv = Parrot_pmc_new(interp, enum_class_ResizableStringArray);
@@ -192,21 +444,66 @@ Parrot_api_pmc_wrap_string_array(Parrot_PMC interp_pmc, Parrot_Int argc,
EMBED_API_CALLOUT(interp_pmc, interp)
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_get_class(Parrot_PMC interp_pmc, Parrot_PMC
+key, Parrot_PMC *class_pmc)>
+
+Lookup the PMC class named C<key> and stores it in the C<class_pmc> PMC. This
+function returns a true value if this call is successful and false value
+otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_get_class(Parrot_PMC interp_pmc, Parrot_PMC key,
- ARGOUT(Parrot_PMC *class))
+Parrot_api_pmc_get_class(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC key),
+ ARGOUT(Parrot_PMC *class_pmc))
{
- EMBED_API_CALLIN(interp_pmc, interp);
- *class = Parrot_oo_get_class(interp, key);
+ ASSERT_ARGS(Parrot_api_pmc_get_class)
+ EMBED_API_CALLIN(interp_pmc, interp)
+ *class_pmc = Parrot_oo_get_class(interp, key);
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_pmc_new(Parrot_PMC interp_pmc, Parrot_PMC
+class_pmc, Parrot_PMC *pmc)>
+
+Instantiate a new PMC of C<class_pmc> and stores the brand new object in C<pmc>.
+This function returns a true value if this call is successful and false value
+otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_pmc_new(Parrot_PMC interp_pmc, Parrot_PMC class, ARGOUT(Parrot_PMC *pmc))
+Parrot_api_pmc_new(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_PMC class_pmc),
+ ARGOUT(Parrot_PMC *pmc))
{
- EMBED_API_CALLIN(interp_pmc, interp);
- *pmc = VTABLE_instantiate(interp, class, PMCNULL);
+ ASSERT_ARGS(Parrot_api_pmc_new)
+ EMBED_API_CALLIN(interp_pmc, interp)
+ *pmc = VTABLE_instantiate(interp, class_pmc, PMCNULL);
EMBED_API_CALLOUT(interp_pmc, interp);
}
+
+/*
+
+=back
+
+=cut
+
+*/
+
+/*
+ * Local variables:
+ * c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
+ */
+
View
176 src/embed/strings.c
@@ -1,46 +1,108 @@
+/*
+Copyright (C) 2010, Parrot Foundation.
+
+=head1 NAME
+
+src/embed/strings.c - The Parrot String embedding interface
+
+=head1 DESCRIPTION
+
+This file implements string functions of the Parrot embedding interface.
+
+=head2 Functions
+
+=over 4
+
+=cut
+
+*/
+
#include "parrot/parrot.h"
#include "embed_private.h"
#include "parrot/api.h"
/* HEADERIZER HFILE: include/parrot/api.h */
+/*
+
+=item C<Parrot_Int Parrot_api_string_export_ascii(Parrot_PMC interp_pmc,
+Parrot_String string, char ** strout)>
+
+Exports the ascii Parrot_String C<string> into a C string and stores it in
+C<strout>. This function returns a true value if this call is successful and
+false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_string_export_ascii(Parrot_PMC interp_pmc, ARGIN(Parrot_String string), ARGOUT(char ** strout))
+Parrot_api_string_export_ascii(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_String string),
+ ARGOUT(char ** strout))
{
- //ASSERT_ARGS(Parrot_api_string_export)
+ ASSERT_ARGS(Parrot_api_string_export_ascii)
EMBED_API_CALLIN(interp_pmc, interp);
- if(!STRING_IS_NULL(string))
+ if (!STRING_IS_NULL(string))
*strout = Parrot_str_to_cstring(interp, string);
else
*strout = NULL;
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_string_free_exported_ascii(Parrot_PMC interp_pmc,
+char * const str)>
+
+Releases the allocated memory for C<str>. This function returns a true value if
+this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_string_free_exported_ascii(Parrot_PMC interp_pmc, ARGIN(char * const str))
+Parrot_api_string_free_exported_ascii(ARGIN(Parrot_PMC interp_pmc), ARGIN(char * const str))
{
+ ASSERT_ARGS(Parrot_api_string_free_exported_ascii)
EMBED_API_CALLIN(interp_pmc, interp);
- if(str != NULL)
+ if (str != NULL)
Parrot_str_free_cstring(str);
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_string_export_wchar(Parrot_PMC interp_pmc,
+Parrot_String string, wchar_t ** strout)>
+
+Exports the wchar Parrot_String C<string> into a C string and stores it in
+C<strout>. This function returns a true value if this call is successful and
+false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_string_export_wchar(Parrot_PMC interp_pmc, ARGIN(Parrot_String string), ARGOUT(wchar_t ** strout))
+Parrot_api_string_export_wchar(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_String string),
+ ARGOUT(wchar_t ** strout))
{
+ ASSERT_ARGS(Parrot_api_string_export_wchar)
+ EMBED_API_CALLIN(interp_pmc, interp)
+
char *cstr;
size_t len;
wchar_t *wstrout;
- EMBED_API_CALLIN(interp_pmc, interp);
- if(!STRING_IS_NULL(string)) {
+ if (!STRING_IS_NULL(string)) {
cstr = Parrot_str_to_cstring(interp, string);
len = strlen(cstr);
- wstrout = (wchar_t *) malloc (sizeof(wchar_t) * len + 1);
+ wstrout = (wchar_t *) malloc(sizeof (wchar_t) * len + 1);
mbstowcs(wstrout, cstr, len);
wstrout[len] = L'\0';
@@ -51,38 +113,80 @@ Parrot_api_string_export_wchar(Parrot_PMC interp_pmc, ARGIN(Parrot_String string
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_string_free_exported_wchar(Parrot_PMC interp_pmc,
+wchar_t * const str)>
+
+Releases the allocated memory for C<str>. This function returns a true value if
+this call is successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_string_free_exported_wchar(Parrot_PMC interp_pmc, ARGIN(wchar_t * const str))
+Parrot_api_string_free_exported_wchar(ARGIN(Parrot_PMC interp_pmc), ARGIN(wchar_t * const str))
{
- EMBED_API_CALLIN(interp_pmc, interp);
- if(str != NULL)
+ ASSERT_ARGS(Parrot_api_string_free_exported_wchar)
+ EMBED_API_CALLIN(interp_pmc, interp)
+ if (str != NULL)
free(str);
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_string_import_ascii(Parrot_PMC interp_pmc, const
+char * str, Parrot_String * out)>
+
+Transforms ascii string C<str> into a Parrot_String and stores the result in
+C<out>. This function returns a true value if this call is successful and false
+value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_string_import_ascii(Parrot_PMC interp_pmc, ARGIN(const char * str), ARGOUT(Parrot_String * out))
+Parrot_api_string_import_ascii(ARGIN(Parrot_PMC interp_pmc), ARGIN(const char * str),
+ ARGOUT(Parrot_String * out))
{
- //ASSERT_ARGS(Parrot_api_string_import)
- EMBED_API_CALLIN(interp_pmc, interp);
+ ASSERT_ARGS(Parrot_api_string_import_ascii)
+ EMBED_API_CALLIN(interp_pmc, interp)
*out = Parrot_str_new(interp, str, 0);
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_string_import_wchar(Parrot_PMC interp_pmc, wchar_t
+* str, Parrot_String * out)>
+
+Transforms wchar string C<str> into a Parrot_String and stores the result in
+C<out>. This function returns a true value if this call is successful and false
+value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_string_import_wchar(Parrot_PMC interp_pmc, ARGIN(wchar_t * str), ARGOUT(Parrot_String * out))
+Parrot_api_string_import_wchar(ARGIN(Parrot_PMC interp_pmc), ARGIN(wchar_t * str),
+ ARGOUT(Parrot_String * out))
{
+ ASSERT_ARGS(Parrot_api_string_import_wchar)
+ EMBED_API_CALLIN(interp_pmc, interp)
+
char *cstr;
size_t len;
- EMBED_API_CALLIN(interp_pmc, interp);
-
len = wcslen(str);
- cstr = (char *) malloc (sizeof(char) * len + 1);
+ cstr = (char *) malloc(sizeof (char) * len + 1);
wcstombs(cstr, str, len);
cstr[len] = '\0';
@@ -92,12 +196,42 @@ Parrot_api_string_import_wchar(Parrot_PMC interp_pmc, ARGIN(wchar_t * str), ARGO
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=item C<Parrot_Int Parrot_api_string_import_binary(Parrot_PMC interp_pmc, const
+unsigned char *bytes, Parrot_Int length, Parrot_String *out)>
+
+Transforms the buffer C<bytes> of size C<length> into a Parrot_String and stores
+the result in C<out>. This function returns a true value if this call is
+successful and false value otherwise.
+
+=cut
+
+*/
+
PARROT_API
Parrot_Int
-Parrot_api_string_import_binary(Parrot_PMC interp_pmc, ARGIN(const unsigned char *bytes), Parrot_Int length, ARGOUT(Parrot_String *out))
+Parrot_api_string_import_binary(ARGIN(Parrot_PMC interp_pmc), ARGIN(const unsigned char *bytes),
+ ARGIN_NULLOK(Parrot_Int length), ARGOUT(Parrot_String *out))
{
- EMBED_API_CALLIN(interp_pmc, interp);
+ ASSERT_ARGS(Parrot_api_string_import_binary)
+ EMBED_API_CALLIN(interp_pmc, interp)
*out = Parrot_str_new(interp, (const char *)bytes, length);
EMBED_API_CALLOUT(interp_pmc, interp);
}
+/*
+
+=back
+
+=cut
+
+*/
+
+/*
+ * Local variables:
+ * c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
+ */
+
View
24 src/exit.c
@@ -52,9 +52,9 @@ Parrot_x_on_exit(PARROT_INTERP, ARGIN(exit_handler_f function), ARGIN_NULLOK(voi
/*
-=item C<void Parrot_x_exit(PARROT_INTERP, int status)>
+=item C<void Parrot_x_jump_out(PARROT_INTERP, int status)>
-Exit, calling any registered exit handlers.
+Jumps out returning to the caller api function.
=cut
@@ -74,6 +74,16 @@ Parrot_x_jump_out(PARROT_INTERP, int status)
exit(status);
}
+/*
+
+=item C<void Parrot_x_jump_out_error(PARROT_INTERP, int status)>
+
+Jumps out returning to the caller api function indicating an error condition.
+
+=cut
+
+*/
+
PARROT_EXPORT
PARROT_DOES_NOT_RETURN
PARROT_COLD
@@ -87,6 +97,16 @@ Parrot_x_jump_out_error(PARROT_INTERP, int status)
Parrot_x_jump_out(interp, status);
}
+/*
+
+=item C<void Parrot_x_exit(PARROT_INTERP, int status)>
+
+Exit, calling any registered exit handlers.
+
+=cut
+
+*/
+
PARROT_EXPORT
PARROT_DOES_NOT_RETURN
PARROT_COLD
View
13 src/gc/api.c
@@ -105,11 +105,22 @@ implementation, and malloc wrappers for various purposes. These are unused.
#endif
+/*
+
+=item C<void Parrot_gc_set_system_type(PARROT_INTERP, const char *name)>
+
+Sets the type specified by C<name> of garbage collector.
+
+=cut
+
+*/
+
+
PARROT_EXPORT
void
Parrot_gc_set_system_type(PARROT_INTERP, const char *name)
{
- //ASSERT_ARGS(Parrot_gc_set_system_type)
+ ASSERT_ARGS(Parrot_gc_set_system_type)
if (STREQ(name, "MS"))
interp->gc_sys->sys_type = MS;
if (STREQ(name, "MS2"))
View
13 src/global_setup.c
@@ -59,7 +59,7 @@ static void Parrot_gbl_setup_2(PARROT_INTERP)
=item C<void Parrot_gbl_set_config_hash_internal(const unsigned char*
parrot_config, unsigned int parrot_config_size)>
-Called by Parrot_set_config_hash with the serialised hash which
+Called by Parrot_set_config_hash with the serialized hash which
will be used in subsequently created Interpreters.
=cut
@@ -77,6 +77,17 @@ Parrot_gbl_set_config_hash_internal(ARGIN(const unsigned char* parrot_config),
}
}
+/*
+
+=item C<void Parrot_set_config_hash_pmc(PARROT_INTERP, PMC * config)>
+
+Called by embed API with the pmc hash which will be used in subsequently created
+Interpreters.
+
+=cut
+
+*/
+
void
Parrot_set_config_hash_pmc(PARROT_INTERP, ARGMOD(PMC * config))
{
View
10 src/library.c
@@ -235,6 +235,16 @@ parrot_init_library_paths(PARROT_INTERP)
#endif
}
+/*
+
+=item C<void Parrot_lib_update_paths_from_config_hash(PARROT_INTERP)>
+
+Updates library paths from the config hash stored in the interpreter.
+
+=cut
+
+*/
+
PARROT_EXPORT
void
Parrot_lib_update_paths_from_config_hash(PARROT_INTERP)
View
3  src/longopt.c
@@ -85,6 +85,7 @@ longopt_get(int argc, ARGIN(const char* argv[]),
ARGIN(const struct longopt_opt_decl options[]),
ARGMOD(struct longopt_opt_info* info_buf))
{
+ ASSERT_ARGS(longopt_get)
const int dex = info_buf->opt_index;
info_buf->opt_id = 0;
@@ -134,6 +135,7 @@ longopt_get_longopt(int argc, ARGIN(const char* argv[]),
ARGIN(const struct longopt_opt_decl options[]),
ARGMOD(struct longopt_opt_info* info_buf))
{
+ ASSERT_ARGS(longopt_get_longopt)
const int dex = info_buf->opt_index;
int optlen = 0;
const struct longopt_opt_decl* dptr;
@@ -229,6 +231,7 @@ longopt_get_shortopt(int argc, ARGIN(const char* argv[]),
ARGIN(const struct longopt_opt_decl options[]),
ARGMOD(struct longopt_opt_info* info_buf))
{
+ ASSERT_ARGS(longopt_get_shortopt)
const int dex = info_buf->opt_index;
const struct longopt_opt_decl* dptr;
const char* pos;
View
64 src/main.c
@@ -134,8 +134,8 @@ main(int argc, const char *argv[])
GET_INIT_STRUCT(initargs);
/* internationalization setup */
/* setlocale(LC_ALL, ""); */
- //PARROT_BINDTEXTDOMAIN(PACKAGE, LOCALEDIR);
- //PARROT_TEXTDOMAIN(PACKAGE);
+ /* PARROT_BINDTEXTDOMAIN(PACKAGE, LOCALEDIR); */
+ /* PARROT_TEXTDOMAIN(PACKAGE); */
/* Parse minimal subset of flags */
parseflags_minimal(initargs, argc, argv);
@@ -168,9 +168,20 @@ main(int argc, const char *argv[])
exit(EXIT_SUCCESS);
}
+/*
+
+=item C<static void show_last_error_and_exit(Parrot_PMC interp)>
+
+Prints out the C<interp>'s last error and exits.
+
+=cut
+
+*/
+
static void
show_last_error_and_exit(Parrot_PMC interp)
{
+ ASSERT_ARGS(show_last_error_and_exit)
Parrot_String errmsg, backtrace;
Parrot_Int exit_code, is_error;
Parrot_PMC exception;
@@ -186,9 +197,22 @@ show_last_error_and_exit(Parrot_PMC interp)
exit(exit_code);
}
+/*
+
+=item C<static void print_parrot_string(Parrot_PMC interp, FILE *vector,
+Parrot_String str, int newline)>
+
+Prints C<str> parrot string into the file handle C<vector> and an optional new
+line if C<newline> is set to a true value.
+
+=cut
+
+*/
+
static void
print_parrot_string(Parrot_PMC interp, FILE *vector, Parrot_String str, int newline)
{
+ ASSERT_ARGS(print_parrot_string)
char * msg_raw;
if (!str)
return;
@@ -215,7 +239,7 @@ PARROT_PURE_FUNCTION
static int
is_all_digits(ARGIN(const char *s))
{
- //ASSERT_ARGS(is_all_digits);
+ ASSERT_ARGS(is_all_digits)
for (; *s; ++s)
if (!isdigit((unsigned char)*s))
return 0;
@@ -238,7 +262,7 @@ PARROT_PURE_FUNCTION
static int
is_all_hex_digits(ARGIN(const char *s))
{
- //ASSERT_ARGS(is_all_hex_digits);
+ ASSERT_ARGS(is_all_hex_digits);
for (; *s; ++s)
if (!isxdigit(*s))
return 0;
@@ -258,7 +282,7 @@ Outputs usage error message.
static void
usage(ARGMOD(FILE *fp))
{
- //ASSERT_ARGS(usage)
+ ASSERT_ARGS(usage)
fprintf(fp,
"parrot -[acEGhprtvVwy.] [-d [FLAGS]] [-D [FLAGS]]"
"[-O [level]] [-R runcore] [-o FILE] <file>\n");
@@ -277,7 +301,7 @@ Print out list of debugging flag values.
static void
help_debug(void)
{
- //ASSERT_ARGS(help_debug)
+ ASSERT_ARGS(help_debug)
/* split printf for C89 compliance on string length */
printf(
"--imcc-debug -d [Flags] ...\n"
@@ -322,7 +346,7 @@ Print out "help" list of options.
static void
help(void)
{
- //ASSERT_ARGS(help)
+ ASSERT_ARGS(help)
/* split printf for C89 compliance on string length */
printf(
"parrot [Options] <file>\n"
@@ -366,7 +390,7 @@ help(void)
/*
-=item C<const struct longopt_opt_decl * Parrot_cmd_options(void)>
+=item C<static const struct longopt_opt_decl * Parrot_cmd_options(void)>
Set up the const struct declaration for cmd_options
@@ -374,12 +398,12 @@ Set up the const struct declaration for cmd_options
*/
-// TODO: Weed out the options that are not used by this executable
+/* TODO: Weed out the options that are not used by this executable */
+
static
const struct longopt_opt_decl *
Parrot_cmd_options(void)
{
- //ASSERT_ARGS(Parrot_cmd_options)
static const struct longopt_opt_decl cmd_options[] = {
{ '.', '.', (OPTION_flags)0, { "--wait" } },
{ 'D', 'D', OPTION_optional_FLAG, { "--parrot-debug" } },
@@ -429,7 +453,7 @@ Print out parrot version number.
static void
Parrot_version(void)
{
- //ASSERT_ARGS(Parrot_version)
+ ASSERT_ARGS(Parrot_version)
printf("This is Parrot version " PARROT_VERSION);
printf(" built for " PARROT_ARCHNAME ".\n");
printf("Copyright (C) 2001-2010, Parrot Foundation.\n\
@@ -456,7 +480,7 @@ Parse minimal subset of args required for initializing interpreter.
static void
parseflags_minimal(ARGMOD(Parrot_Init_Args * initargs), int argc, ARGIN(const char *argv[]))
{
- //ASSERT_ARGS(parseflags_minimal)
+ ASSERT_ARGS(parseflags_minimal)
int pos = 0;
@@ -555,7 +579,7 @@ parseflags(Parrot_PMC interp,
ARGOUT(int *pgm_argc), ARGOUT(const char ***pgm_argv),
ARGMOD(const char **core), ARGMOD(Parrot_Int *trace))
{
- //ASSERT_ARGS(parseflags)
+ ASSERT_ARGS(parseflags)
struct longopt_opt_info opt = LONGOPT_OPT_INFO_INIT;
int status;
int result = 1;
@@ -579,19 +603,19 @@ parseflags(Parrot_PMC interp,
case 't':
if (opt.opt_arg && is_all_hex_digits(opt.opt_arg)) {
const unsigned long _temp = strtoul(opt.opt_arg, NULL, 16);
- //const Parrot_trace_flags _temp_flag = (Parrot_trace_flags)_temp;
+ /* const Parrot_trace_flags _temp_flag = (Parrot_trace_flags)_temp; */
const Parrot_Int _temp_flag = _temp;
*trace = _temp_flag;
}
else
*trace = 0x01;
- //*trace = PARROT_TRACE_OPS_FLAG;
+ /* *trace = PARROT_TRACE_OPS_FLAG; */
break;
case 'D':
if (opt.opt_arg && is_all_hex_digits(opt.opt_arg))
Parrot_api_debug_flag(interp, strtoul(opt.opt_arg, NULL, 16), 1);
else
- //Parrot_api_debug_flag(interp, PARROT_MEM_STAT_DEBUG_FLAG, 1);
+ /* Parrot_api_debug_flag(interp, PARROT_MEM_STAT_DEBUG_FLAG, 1); */
Parrot_api_debug_flag(interp, 0x01, 1);
break;
@@ -626,17 +650,17 @@ parseflags(Parrot_PMC interp,
case OPT_GC_DEBUG:
/*
#if DISABLE_GC_DEBUG
- //Parrot_warn(interp, PARROT_WARNINGS_ALL_FLAG,
+ // Parrot_warn(interp, PARROT_WARNINGS_ALL_FLAG,