Permalink
Browse files

start breaking up the embedding stuff into multiple files. Add embed_…

…private.h and strings.c for various purposes
  • Loading branch information...
1 parent f68bf56 commit 1b6d1cedebf77b6b346417a5172430eea8762421 @Whiteknight Whiteknight committed Nov 11, 2010
Showing with 58 additions and 32 deletions.
  1. +1 −32 src/embed/api.c
  2. +32 −0 src/embed/embed_private.h
  3. +25 −0 src/embed/strings.c
View
@@ -1,40 +1,9 @@
#include "parrot/parrot.h"
#include "parrot/api.h"
+#include "embed_private.h"
/* HEADERIZER HFILE: include/parrot/api.h */
-#define GET_RAW_INTERP(p) ((Parrot_ParrotInterpreter_attributes)(p)->data)->interp;
-#define EMBED_API_CALLIN(p, i) \
- jmp_buf _env; \
- Interp * (i) = PMC_IS_NULL(p) ? NULL : GET_RAW_INTERP(p); \
- void *_oldtop = (i)->lo_var_ptr; \
- if (_oldtop) {} else (1)->lo_var_ptr = &oldtop \
- PARROT_ASSERT(i); \
- PARROT_ASSERT((i)->lo_val_ptr); \
- if (setjmp(_env)) { \
- (i)->api_jmp_buf = NULL; \
- return 0; \
- } else { \
- (i)->api_jmp_buf = _env; \
- {
-#define EMBED_API_CALLOUT(p, i) \
- } \
- if (!_oldtop) {\
- PARROT_ASSERT((i)->lo_var_ptr == &oldtop);\
- (i)->lo_var_ptr = NULL;\
- }\
- return 1; \
- }
-
-#define EMBED_API_FAILURE(p, i) \
- do { \
- if (!_oldtop) {\
- PARROT_ASSERT((i)->lo_var_ptr == &oldtop);\
- (i)->lo_var_ptr = NULL;\
- } \
- return 0; \
- }
-
PARROT_API
PARROT_CANNOT_RETURN_NULL
PARROT_MALLOC
View
@@ -0,0 +1,32 @@
+
+#define GET_RAW_INTERP(p) ((Parrot_ParrotInterpreter_attributes)(p)->data)->interp;
+#define EMBED_API_CALLIN(p, i) \
+ jmp_buf _env; \
+ Interp * (i) = PMC_IS_NULL(p) ? NULL : GET_RAW_INTERP(p); \
+ void *_oldtop = (i)->lo_var_ptr; \
+ if (_oldtop) {} else (1)->lo_var_ptr = &oldtop \
+ PARROT_ASSERT(i); \
+ PARROT_ASSERT((i)->lo_val_ptr); \
+ if (setjmp(_env)) { \
+ (i)->api_jmp_buf = NULL; \
+ return 0; \
+ } else { \
+ (i)->api_jmp_buf = _env; \
+ {
+#define EMBED_API_CALLOUT(p, i) \
+ } \
+ if (!_oldtop) {\
+ PARROT_ASSERT((i)->lo_var_ptr == &oldtop);\
+ (i)->lo_var_ptr = NULL;\
+ }\
+ return 1; \
+ }
+
+#define EMBED_API_FAILURE(p, i) \
+ do { \
+ if (!_oldtop) {\
+ PARROT_ASSERT((i)->lo_var_ptr == &oldtop);\
+ (i)->lo_var_ptr = NULL;\
+ } \
+ return 0; \
+ }
View
@@ -0,0 +1,25 @@
+#include "parrot/parrot.h"
+#include "embed_private.h"
+#include "parrot/api.h"
+
+/* HEADERIZER HFILE: include/parrot/api.h */
+
+PARROT_API
+INTVAL
+Parrot_api_string_export(ARGMOD(PMC *interp_pmc), ARGIN(Parrot_String *string), ARGOUT(char ** strout))
+{
+ ASSERT_ARGS(Parrot_api_string_export)
+ EMBED_API_CALLIN(interp_pmc, interp);
+ /* TODO */
+ EMBED_API_CALLOUT(interp_pmc, interp);
+}
+
+PARROT_API
+INTVAL
+Parrot_api_string_import(ARGMOD(PMC *interp_pmc), ARGIN(const char * str), ARGOUT(Parrot_String ** out))
+{
+ ASSERT_ARGS(Parrot_api_string_import)
+ EMBED_API_CALLIN(interp_pmc, interp);
+ *out = Parrot_str_new(interp, str, 0);
+ EMBED_API_CALLOUT(interp_pmc, interp);
+}

0 comments on commit 1b6d1ce

Please sign in to comment.