2 * Copyright (C) 2001-2008, The Perl Foundation.
6 * This is the Parrot extension mechanism, the face we present to
7 * extension modules and whatnot
8 * Data Structure and Algorithms:
12 * extend.c, docs/pdds/pdd11_extending.pod.
15 #ifndef PARROT_EXTEND_H_GUARD
16 #define PARROT_EXTEND_H_GUARD
19 #include "parrot/config.h" /* PARROT_VERSION, PARROT_JIT_CAPABLE... */
20 #include "parrot/interpreter.h" /* give us the interpreter flags */
21 #include "parrot/warnings.h" /* give us the warnings flags */
23 /* Two versions of each routine, one for when we're building the core
24 and one for when people are writing extensions. If this gets abused
25 we'll split this into two pieces and not install the core version,
26 but that would be really annoying */
27 #if defined(PARROT_IN_CORE)
29 #define Parrot_String STRING *
30 #define Parrot_PMC PMC *
31 #define Parrot_Language Parrot_Int
32 #define Parrot_VTABLE VTABLE *
34 /* Macro to save off the original stack pointer for DOD scanning. If
35 the stacktop was NULL, then set it to the address of the cached
36 pointer, which is on the stack and as good a thing as any to use as
38 #define PARROT_CALLIN_START(x) void *oldtop = (x)->lo_var_ptr; \
39 if (!oldtop) (x)->lo_var_ptr = &oldtop;
40 /* Put the stack top back, if what we cached was NULL. Otherwise we
41 leave it alone and assume it's OK */
42 #define PARROT_CALLIN_END(x) if (!oldtop) (x)->lo_var_ptr = NULL;
46 typedef void * Parrot_String
;
47 typedef void * Parrot_PMC
;
48 typedef Parrot_Int Parrot_Language
;
49 typedef void * Parrot_Encoding
;
50 typedef void * Parrot_CharType
;
51 typedef const void * Parrot_Const_Encoding
;
52 typedef const void * Parrot_Const_CharType
;
53 typedef const void * Parrot_VTABLE
;
57 #include "parrot/extend_vtable.h" /* the auto-generated prototypes */
59 /* HEADERIZER BEGIN: src/extend.c */
60 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
63 PARROT_WARN_UNUSED_RESULT
64 PARROT_CAN_RETURN_NULL
65 void * Parrot_call_method(PARROT_INTERP
,
69 ARGIN(const char *signature
),
71 __attribute__nonnull__(1)
72 __attribute__nonnull__(5);
75 Parrot_Float
Parrot_call_method_ret_float(PARROT_INTERP
,
79 ARGIN(const char *signature
),
81 __attribute__nonnull__(1)
82 __attribute__nonnull__(5);
85 Parrot_Int
Parrot_call_method_ret_int(PARROT_INTERP
,
89 ARGIN(const char *signature
),
91 __attribute__nonnull__(1)
92 __attribute__nonnull__(5);
95 PARROT_WARN_UNUSED_RESULT
96 PARROT_CAN_RETURN_NULL
97 void* Parrot_call_sub(PARROT_INTERP
,
99 ARGIN(const char *signature
),
101 __attribute__nonnull__(1)
102 __attribute__nonnull__(3);
105 Parrot_Float
Parrot_call_sub_ret_float(PARROT_INTERP
,
107 ARGIN(const char *signature
),
109 __attribute__nonnull__(1)
110 __attribute__nonnull__(3);
113 Parrot_Int
Parrot_call_sub_ret_int(PARROT_INTERP
,
115 ARGIN(const char *signature
),
117 __attribute__nonnull__(1)
118 __attribute__nonnull__(3);
121 int Parrot_eprintf(NULLOK_INTERP
, ARGIN(const char *s
), ...)
122 __attribute__nonnull__(2);
125 PARROT_WARN_UNUSED_RESULT
126 Parrot_Language
Parrot_find_language(SHIM_INTERP
, SHIM(char *language
));
129 int Parrot_fprintf(PARROT_INTERP
,
130 ARGIN(Parrot_PMC pio
),
131 ARGIN(const char *s
),
133 __attribute__nonnull__(1)
134 __attribute__nonnull__(2)
135 __attribute__nonnull__(3);
138 void Parrot_free_cstring(ARGIN_NULLOK(char *string
));
141 Parrot_Int
Parrot_get_intreg(PARROT_INTERP
, Parrot_Int regnum
)
142 __attribute__nonnull__(1);
145 Parrot_Float
Parrot_get_numreg(PARROT_INTERP
, Parrot_Int regnum
)
146 __attribute__nonnull__(1);
149 Parrot_PMC
Parrot_get_pmcreg(PARROT_INTERP
, Parrot_Int regnum
)
150 __attribute__nonnull__(1);
153 Parrot_String
Parrot_get_strreg(PARROT_INTERP
, Parrot_Int regnum
)
154 __attribute__nonnull__(1);
158 Parrot_VTABLE
Parrot_get_vtable(PARROT_INTERP
, Parrot_Int id
)
159 __attribute__nonnull__(1);
162 PARROT_WARN_UNUSED_RESULT
163 PARROT_CANNOT_RETURN_NULL
164 Parrot_String
Parrot_new_string(PARROT_INTERP
,
165 ARGIN_NULLOK(const char *buffer
),
167 ARGIN_NULLOK(const char * const encoding_name
),
169 __attribute__nonnull__(1);
172 void Parrot_PMC_delete_pmckey(PARROT_INTERP
, Parrot_PMC pmc
, Parrot_PMC key
)
173 __attribute__nonnull__(1);
177 PARROT_CAN_RETURN_NULL
178 char * Parrot_PMC_get_cstring(PARROT_INTERP
, Parrot_PMC pmc
)
179 __attribute__nonnull__(1);
183 PARROT_CAN_RETURN_NULL
184 char * Parrot_PMC_get_cstring_intkey(PARROT_INTERP
,
187 __attribute__nonnull__(1);
191 PARROT_CAN_RETURN_NULL
192 char * Parrot_PMC_get_cstringn(PARROT_INTERP
,
193 ARGIN(Parrot_PMC pmc
),
194 ARGOUT(Parrot_Int
*length
))
195 __attribute__nonnull__(1)
196 __attribute__nonnull__(2)
197 __attribute__nonnull__(3)
198 FUNC_MODIFIES(*length
);
202 PARROT_CAN_RETURN_NULL
203 char * Parrot_PMC_get_cstringn_intkey(PARROT_INTERP
,
204 ARGIN(Parrot_PMC pmc
),
205 ARGOUT(Parrot_Int
*length
),
207 __attribute__nonnull__(1)
208 __attribute__nonnull__(2)
209 __attribute__nonnull__(3)
210 FUNC_MODIFIES(*length
);
213 Parrot_Int
Parrot_PMC_get_intval(PARROT_INTERP
, Parrot_PMC pmc
)
214 __attribute__nonnull__(1);
217 Parrot_Int
Parrot_PMC_get_intval_intkey(PARROT_INTERP
,
220 __attribute__nonnull__(1);
223 Parrot_Int
Parrot_PMC_get_intval_pmckey(PARROT_INTERP
,
226 __attribute__nonnull__(1);
229 Parrot_Float
Parrot_PMC_get_numval(PARROT_INTERP
, Parrot_PMC pmc
)
230 __attribute__nonnull__(1);
233 Parrot_Float
Parrot_PMC_get_numval_intkey(PARROT_INTERP
,
236 __attribute__nonnull__(1);
239 Parrot_PMC
Parrot_PMC_get_pmc_intkey(PARROT_INTERP
,
242 __attribute__nonnull__(1);
245 PARROT_WARN_UNUSED_RESULT
246 PARROT_CAN_RETURN_NULL
247 void * Parrot_PMC_get_pointer_intkey(PARROT_INTERP
,
250 __attribute__nonnull__(1);
253 Parrot_String
Parrot_PMC_get_string_intkey(PARROT_INTERP
,
256 __attribute__nonnull__(1);
259 Parrot_PMC
Parrot_PMC_new(PARROT_INTERP
, Parrot_Int type
)
260 __attribute__nonnull__(1);
263 Parrot_PMC
Parrot_PMC_null(void);
266 void Parrot_PMC_push_intval(PARROT_INTERP
, Parrot_PMC pmc
, Parrot_Int value
)
267 __attribute__nonnull__(1);
270 void Parrot_PMC_push_numval(PARROT_INTERP
,
273 __attribute__nonnull__(1);
276 void Parrot_PMC_set_cstring(PARROT_INTERP
,
278 ARGIN_NULLOK(const char *value
))
279 __attribute__nonnull__(1);
282 void Parrot_PMC_set_cstring_intkey(PARROT_INTERP
,
285 ARGIN_NULLOK(const char *value
))
286 __attribute__nonnull__(1);
289 void Parrot_PMC_set_cstringn(PARROT_INTERP
,
291 ARGIN_NULLOK(const char *value
),
293 __attribute__nonnull__(1);
296 void Parrot_PMC_set_cstringn_intkey(PARROT_INTERP
,
299 ARGIN_NULLOK(const char *value
),
301 __attribute__nonnull__(1);
304 void Parrot_PMC_set_intval(PARROT_INTERP
, Parrot_PMC pmc
, Parrot_Int value
)
305 __attribute__nonnull__(1);
308 void Parrot_PMC_set_intval_intkey(PARROT_INTERP
,
312 __attribute__nonnull__(1);
315 void Parrot_PMC_set_numval(PARROT_INTERP
,
318 __attribute__nonnull__(1);
321 void Parrot_PMC_set_numval_intkey(PARROT_INTERP
,
325 __attribute__nonnull__(1);
328 void Parrot_PMC_set_pmc_intkey(PARROT_INTERP
,
332 __attribute__nonnull__(1);
335 void Parrot_PMC_set_pmc_pmckey(PARROT_INTERP
,
339 __attribute__nonnull__(1);
342 void Parrot_PMC_set_pointer_intkey(PARROT_INTERP
,
343 ARGIN(Parrot_PMC pmc
),
345 ARGIN_NULLOK(void *value
))
346 __attribute__nonnull__(1)
347 __attribute__nonnull__(2);
350 void Parrot_PMC_set_string(PARROT_INTERP
,
353 __attribute__nonnull__(1);
356 void Parrot_PMC_set_string_intkey(PARROT_INTERP
,
360 __attribute__nonnull__(1);
363 void Parrot_PMC_set_vtable(SHIM_INTERP
,
365 Parrot_VTABLE vtable
);
368 Parrot_Int
Parrot_PMC_typenum(PARROT_INTERP
,
369 ARGIN_NULLOK(const char *_class
))
370 __attribute__nonnull__(1);
373 int Parrot_printf(NULLOK_INTERP
, ARGIN(const char *s
), ...)
374 __attribute__nonnull__(2);
377 void Parrot_register_pmc(PARROT_INTERP
, Parrot_PMC pmc
)
378 __attribute__nonnull__(1);
381 void Parrot_set_intreg(PARROT_INTERP
, Parrot_Int regnum
, Parrot_Int value
)
382 __attribute__nonnull__(1);
385 void Parrot_set_numreg(PARROT_INTERP
, Parrot_Int regnum
, Parrot_Float value
)
386 __attribute__nonnull__(1);
389 void Parrot_set_pmcreg(PARROT_INTERP
, Parrot_Int regnum
, Parrot_PMC value
)
390 __attribute__nonnull__(1);
393 void Parrot_set_strreg(PARROT_INTERP
,
396 __attribute__nonnull__(1);
399 void Parrot_unregister_pmc(PARROT_INTERP
, Parrot_PMC pmc
)
400 __attribute__nonnull__(1);
403 int Parrot_vfprintf(PARROT_INTERP
,
404 ARGIN(Parrot_PMC pio
),
405 ARGIN(const char *s
),
407 __attribute__nonnull__(1)
408 __attribute__nonnull__(2)
409 __attribute__nonnull__(3);
411 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
412 /* HEADERIZER END: src/extend.c */
414 #endif /* PARROT_EXTEND_H_GUARD */
418 * c-file-style: "parrot"
420 * vim: expandtab shiftwidth=4: