Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 820 lines (628 sloc) 23.689 kb
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
1 /*
2 Copyright (C) 2010, Parrot Foundation.
3
4 =head1 NAME
5
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
6 src/embed/api.c - The Parrot embedding interface
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
7
8 =head1 DESCRIPTION
9
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
10 This file implements functions of the Parrot embedding interface.
11
12 =head2 Functions
13
14 =over 4
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
15
16 =cut
17
18 */
19
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
20 #include "parrot/parrot.h"
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
21 #include "parrot/runcore_api.h"
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
22 #include "parrot/embed.h"
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
23 #include "parrot/api.h"
1b6d1ce @Whiteknight start breaking up the embedding stuff into multiple files. Add embed_pri...
Whiteknight authored
24 #include "embed_private.h"
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
25
3f8ed92 @Whiteknight fix some file references and run headerizer to see my work so far
Whiteknight authored
26 /* HEADERIZER HFILE: include/parrot/api.h */
27
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
28
29 /*
30
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
31 =item C<Parrot_Int Parrot_api_get_result(Parrot_PMC interp_pmc, Parrot_Int
32 *is_error, Parrot_PMC * exception, Parrot_Int *exit_code, Parrot_String *
33 errmsg)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
34
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
35 Gets the results of the last API function call and stores the results in
36 C<is_error>, C<exception>, C<exit_code> and C<errmsg>. This function returns
37 a true value if this call is successful and false value otherwise. The stored
38 information is as follow:
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
39
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
40 C<is_error> a true value if an unhandled exception was thrown or the program
41 terminated with an error condition and a false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
42
43 C<exception> the last exception thrown.
44
45 C<exit_code> the exit code of the running program.
46
47 C<errmsg> contains an string with the last error message.
48
49 =cut
50
51 */
52
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
53 PARROT_API
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
54 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
55 Parrot_api_get_result(Parrot_PMC interp_pmc, ARGOUT(Parrot_Int *is_error),
56 ARGOUT(Parrot_PMC * exception), ARGOUT(Parrot_Int *exit_code),
57 ARGOUT(Parrot_String * errmsg))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
58 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
59 ASSERT_ARGS(Parrot_api_get_result)
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
60 EMBED_API_CALLIN(interp_pmc, interp)
be50d63 @bluescreen10 Implemented first version of Parrot_get_result, now a lot of failing tes...
bluescreen10 authored
61 *exit_code = interp->exit_code;
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
62 *exception = interp->final_exception;
73f662d @Whiteknight some fixes so libparrot builds with g++
Whiteknight authored
63 if (PMC_IS_NULL(*exception)) {
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
64 *is_error = 0;
65 *errmsg = STRINGNULL;
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
66 }
67 else {
b3af8c9 @Whiteknight fix main.c so that we check the is_error flag and only show an error mes...
Whiteknight authored
68 STRING * const severity_str = Parrot_str_new(interp, "severity", 0);
69 INTVAL severity = VTABLE_get_integer_keyed_str(interp, *exception, severity_str);
70 *is_error = (severity != EXCEPT_exit);
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
71 *errmsg = VTABLE_get_string(interp, *exception);
72 }
73 interp->final_exception = PMCNULL;
be50d63 @bluescreen10 Implemented first version of Parrot_get_result, now a lot of failing tes...
bluescreen10 authored
74 interp->exit_code = 0;
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
75 EMBED_API_CALLOUT(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
76 }
77
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
78 /*
79
80 =item C<Parrot_Int Parrot_api_get_exception_backtrace(Parrot_PMC interp_pmc,
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
81 Parrot_PMC exception, Parrot_String * bt)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
82
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
83 Gets the backtrace of the interpreter's call chain for the given exception
84 C<expcetion> and stores the results in string C<bt>. This function returns a
85 true value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
86
87 =cut
88
89 */
90
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
91 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
92 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
93 Parrot_api_get_exception_backtrace(Parrot_PMC interp_pmc,
94 Parrot_PMC exception, ARGOUT(Parrot_String * bt))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
95 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
96 ASSERT_ARGS(Parrot_api_get_exception_backtrace)
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
97 EMBED_API_CALLIN(interp_pmc, interp)
3c6f7d0 @Whiteknight rethrow caches the old backtrace.
Whiteknight authored
98 if (PMC_IS_NULL(exception))
99 *bt = STRINGNULL;
100 else
0a4f093 @Whiteknight build fixes
Whiteknight authored
101 *bt = Parrot_ex_build_complete_backtrace_string(interp, exception);
2483c68 @Whiteknight implement the new error-handling mechanism. Instead of a string, we pass...
Whiteknight authored
102 EMBED_API_CALLOUT(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
103 }
104
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
105
106 /*
107
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
108 =item C<Parrot_Int Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int
109 flags, Parrot_Init_Args *args, Parrot_PMC *interp)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
110
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
111 Creates a new interpreter and stores it in C<interp>. It takes three optional
112 parameters the new interpreter's C<flags>, the initialization paremeters C<args>
113 and the C<parent> interpreter. This function returns a true value if this call
114 is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
115
116 =cut
117
118 */
119
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
120 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
121 Parrot_Int
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't being u...
Whiteknight authored
122 Parrot_api_make_interpreter(Parrot_PMC parent, Parrot_Int flags,
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
123 ARGIN_NULLOK(Parrot_Init_Args *args), ARGOUT(Parrot_PMC *interp))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
124 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
125 ASSERT_ARGS(Parrot_api_make_interpreter)
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
126 int alt_stacktop;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
127 Parrot_Interp interp_raw;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an inte...
Whiteknight authored
128 void *stacktop_ptr = &alt_stacktop;
82cbd84 @Whiteknight parrot executable compiles, but miniparrot does not link. I need to sort...
Whiteknight authored
129 const Parrot_Interp parent_raw = PMC_IS_NULL(parent) ? NULL : GET_RAW_INTERP(parent);
130 interp_raw = allocate_interpreter(parent_raw, flags);
131 if (args) {
132 if (args->stacktop)
133 stacktop_ptr = args->stacktop;
134 if (args->gc_system)
135 Parrot_gc_set_system_type(interp_raw, args->gc_system);
136 if (args->gc_threshold)
137 interp_raw->gc_threshold = args->gc_threshold;
138 if (args->hash_seed)
139 interp_raw->hash_seed = args->hash_seed;
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an inte...
Whiteknight authored
140 }
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
141 initialize_interpreter(interp_raw, stacktop_ptr);
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
142 *interp = VTABLE_get_pmc_keyed_int(
143 interp_raw, interp_raw->iglobals, (Parrot_Int)IGLOBALS_INTERPRETER);
f2252b4 @Whiteknight remove the two-stage initialization dance. We can now initialize an inte...
Whiteknight authored
144 return !PMC_IS_NULL(*interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
145 }
146
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
147 /*
148
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
149 =item C<Parrot_Int Parrot_api_set_runcore(Parrot_PMC interp_pmc, const char *
150 corename, Parrot_UInt trace)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
151
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
152 Sets the C<interp_pmc>'s bytecode running core, the core is specified by the
153 C<corename>. This function returns a true value if this call is successful and
154 false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
155
156 =cut
157
158 */
159
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
160 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
161 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
162 Parrot_api_set_runcore(Parrot_PMC interp_pmc, ARGIN(const char * corename),
163 Parrot_UInt trace)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
164 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
165 ASSERT_ARGS(Parrot_api_set_runcore)
3ea891c First round of syntax error fixes
Mariano Wahlmann authored
166 EMBED_API_CALLIN(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
167 if (trace) {
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
168 Parrot_pcc_trace_flags_on(interp, interp->ctx, trace);
169 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
170 }
171 else {
372f8f7 @bluescreen10 Make bounds runcore available
bluescreen10 authored
172 if (!strcmp(corename, "slow") || !strcmp(corename, "bounds"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
173 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
174 else if (!strcmp(corename, "fast") ||
175 !strcmp(corename, "jit") || !strcmp(corename, "function"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
176 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "fast"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
177 else if (!strcmp(corename, "exec"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
178 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "exec"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
179 else if (!strcmp(corename, "trace"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
180 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
181 else if (!strcmp(corename, "profiling"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
182 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "profiling"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
183 else if (!strcmp(corename, "gcdebug"))
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
184 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "gcdebug"));
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
185 else
186 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Invalid runcore type %s", corename);
187 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
188 EMBED_API_CALLOUT(interp_pmc, interp)
189 }
190
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
191 /*
192
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
193 =item C<Parrot_Int Parrot_api_debug_flag(Parrot_PMC interp_pmc, Parrot_Int
194 flags, Parrot_Int set)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
195
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
196 Sets/Unsets the C<interp_pmc>'s debug flags. If C<set> is in a true value debug
197 flags are set otherwise debug flags are cleared. This function returns a true
198 value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
199
200 =cut
201
202 */
203
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
204 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
205 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
206 Parrot_api_debug_flag(Parrot_PMC interp_pmc, Parrot_Int flags, Parrot_Int set)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
207 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
208 ASSERT_ARGS(Parrot_api_debug_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
209 EMBED_API_CALLIN(interp_pmc, interp)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
210 if (set)
211 interp->debug_flags |= flags;
212 else
213 interp->debug_flags &= ~flags;
214 EMBED_API_CALLOUT(interp_pmc, interp);
215 }
216
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
217 /*
218
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
219 =item C<Parrot_Int Parrot_api_flag(Parrot_PMC interp_pmc, Parrot_Int flags,
220 Parrot_Int set)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
221
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
222 Set/Unset the C<interp_pmc>'s general flags. If C<set> is in a true value general
223 flags are set otherwise passed flags are cleared. This function returns a true
224 value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
225
226 =cut
227
228 */
229
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
230 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
231 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
232 Parrot_api_flag(Parrot_PMC interp_pmc, Parrot_Int flags, Parrot_Int set)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
233 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
234 ASSERT_ARGS(Parrot_api_flag)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
235 EMBED_API_CALLIN(interp_pmc, interp)
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
236 if (set) {
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
237 Interp_flags_SET(interp, flags);
238 if (flags & (PARROT_BOUNDS_FLAG | PARROT_PROFILE_FLAG))
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
239 Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
240 }
241 else
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
242 Interp_flags_CLEAR(interp, flags);
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
243 EMBED_API_CALLOUT(interp_pmc, interp);
244 }
245
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
246 /*
247
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
248 =item C<Parrot_Int Parrot_api_set_executable_name(Parrot_PMC interp_pmc, const
249 char * name)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
250
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
251 Sets the executable name for the C<interp_pmc> interpreter. This function returns
252 a true value if this call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
253
254 =cut
255
256 */
257
f68bf56 @Whiteknight add Parrot_api_flag and Parrot_api_debug_flag. Use these in main.c inste...
Whiteknight authored
258 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
259 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
260 Parrot_api_set_executable_name(Parrot_PMC interp_pmc, ARGIN(const char * name))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
261 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
262 ASSERT_ARGS(Parrot_api_set_executable_name)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
263 EMBED_API_CALLIN(interp_pmc, interp)
9cc3ace @plobsing allow for unicode names of fakecutables
plobsing authored
264 STRING * const name_str = Parrot_str_from_platform_cstring(interp, name);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
265 PMC * const name_pmc = Parrot_pmc_new(interp, enum_class_String);
1a692e9 @Whiteknight _set_executable_name takes a C string instead of a Parrot string, for co...
Whiteknight authored
266 VTABLE_set_string_native(interp, name_pmc, name_str);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
267 VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE,
268 name_pmc);
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
269 EMBED_API_CALLOUT(interp_pmc, interp);
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
270 }
271
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
272 /*
273
274 =item C<Parrot_Int Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)>
275
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
276 Destroys the C<interp_pmc> interpreter, freeing the memory structures allocated
277 for it. This function returns a true value if this call is successful and false
278 value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
279
280 =cut
281
282 */
283
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
284 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
285 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
286 Parrot_api_destroy_interpreter(Parrot_PMC interp_pmc)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
287 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
288 ASSERT_ARGS(Parrot_api_destroy_interpreter)
2dc5187 @nwellnhof [embed] Fix segfault with --leak-test option
nwellnhof authored
289 void * _oldtop;
290 Parrot_jump_buff env;
291 Interp * const interp = GET_INTERP(interp_pmc);
292 _oldtop = interp->lo_var_ptr;
293 if (_oldtop == NULL)
294 interp->lo_var_ptr = &_oldtop;
295 interp->api_jmp_buf = &env;
296 if (setjmp(env)) {
297 /* We can't check for potential errors because the interpreter
298 * might have been destroyed. */
299 return 1;
300 }
301 else {
302 Parrot_destroy(interp);
303 Parrot_x_exit(interp, 0);
304 /* Never reached, x_exit calls longjmp */
305 return 1;
306 }
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
307 }
308
309 /*
310
b9cdf9c @jkeenan After fixing C++ comments, I re-ran headerizer and modified these files....
jkeenan authored
311 =item C<Parrot_Int Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc, const
312 char *filename, Parrot_PMC * pbc)>
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
313
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
314 Load a bytecode file and stores the resulting bytecode in C<pbc>. This function
315 returns a true value if this call is successful and false value otherwise.
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
316
317 =cut
318
319 */
320
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebuild...
Whiteknight authored
321 /* TODO: This only works with the inital bytecode. After this we should use
322 Parrot_append_bytecode or something similar */
323
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
324 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
325 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
326 Parrot_api_load_bytecode_file(Parrot_PMC interp_pmc,
327 ARGIN(const char *filename), ARGOUT(Parrot_PMC * pbc))
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
328 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
329 ASSERT_ARGS(Parrot_api_load_bytecode_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
330 EMBED_API_CALLIN(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
331 PackFile * const pf = Parrot_pbc_read(interp, filename, 0);
332 if (!pf)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
333 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not load packfile");
734d38f @mikehh linelength problem - missing newline added
mikehh authored
334 do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL);
335 *pbc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
336 VTABLE_set_pointer(interp, *pbc, pf);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
337 EMBED_API_CALLOUT(interp_pmc, interp)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
338 }
339
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
340 /*
341
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
342 =item C<Parrot_Int Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc, const
343 unsigned char * const pbc, Parrot_Int bytecode_size, Parrot_PMC * pbcpmc)>
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
344
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
345 Unpacks a bytecode from a buffer C<pbc> of a C<bytecode_size> size, and stores
346 the resulting bytecode in C<pbcpmc>. This function returns a true value if this
347 call is successful and false value otherwise.
3653784 @bluescreen10 Embed API Documentation round 1
bluescreen10 authored
348
349 =cut
350
351 */
352
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
353 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
354 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
355 Parrot_api_load_bytecode_bytes(Parrot_PMC interp_pmc,
356 ARGIN(const unsigned char * const pbc), Parrot_Int bytecode_size,
357 ARGOUT(Parrot_PMC * pbcpmc))
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults buildi...
Whiteknight authored
358 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
359 ASSERT_ARGS(Parrot_api_load_bytecode_bytes)
99428c2 Make src/embed/pmc.c & src/embed/api.c compile with gcc
Mariano Wahlmann authored
360 EMBED_API_CALLIN(interp_pmc, interp)
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults buildi...
Whiteknight authored
361 PackFile * const pf = PackFile_new(interp, 0);
362 if (!pf)
363 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not create packfile");
364
365 if (!PackFile_unpack(interp, pf, (const opcode_t *)pbc, bytecode_size))
366 Parrot_ex_throw_from_c_args(interp, NULL, 1, "could not unpack packfile");
39626b8 @Kristaba Some fix. do_sub_pragmas is back public for now
Kristaba authored
367 do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL);
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults buildi...
Whiteknight authored
368 *pbcpmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
369 VTABLE_set_pointer(interp, *pbcpmc, pf);
370 EMBED_API_CALLOUT(interp_pmc, interp);
371 }
372
6be2b4a @Whiteknight remove the ASSERT_ARGS stuff, and other things that are borking thebuild...
Whiteknight authored
373 /* Load the bytecode into the interpreter, but don't execute it */
374 /* TODO: This only works with the inital bytecode. After this we should use
375 Parrot_append_bytecode or something similar */
376
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
377 /*
378
379 =item C<Parrot_Int Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
380 pbc, Parrot_PMC *main_sub)>
381
382 Prepares the bytecode C<pbc> to be run and stores the entry point subroutine in
383 C<main_sub>. This function returns a true value if this call is successful and
384 false value otherwise.
385
386 =cut
387
388 */
389
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't being u...
Whiteknight authored
390 PARROT_API
391 Parrot_Int
392 Parrot_api_ready_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
393 ARGOUT(Parrot_PMC *main_sub))
394 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
395 ASSERT_ARGS(Parrot_api_ready_bytecode)
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't being u...
Whiteknight authored
396 EMBED_API_CALLIN(interp_pmc, interp)
397 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
398
399 /* Debugging mode nonsense. */
400 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
401 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
402 interp->run_core->name);
403 }
404
405 if (!pf)
406 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
407 if (pf->cur_cs != NULL)
408 Parrot_pbc_load(interp, pf);
409 PackFile_fixup_subs(interp, PBC_MAIN, NULL);
410 *main_sub = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
411 Parrot_pcc_set_constants(interp, interp->ctx, interp->code->const_table);
412 EMBED_API_CALLOUT(interp_pmc, interp)
413 }
414
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
415
416 /*
417
418 =item C<Parrot_Int Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC
419 pbc, Parrot_PMC mainargs)>
420
421 Runs the bytecode C<pbc> passing optional C<mainargs> parameters. This function
422 returns a true value if this call is successful and false value otherwise.
423
424 =cut
425
426 */
427
46b7a9d @Whiteknight upconvert pbc_to_exe to use the new API. it builds, but segfaults buildi...
Whiteknight authored
428 PARROT_API
429 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
430 Parrot_api_run_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
431 Parrot_PMC mainargs)
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
432 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
433 ASSERT_ARGS(Parrot_api_run_bytecode)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
434 EMBED_API_CALLIN(interp_pmc, interp)
65bf81a @Whiteknight actually run the code, don't just look at it. Miniparrot runs now. parro...
Whiteknight authored
435 PMC * main_sub = NULL;
436
98cd26c @Whiteknight don't call Parrot_pbc_load if the PBC comes straight out of IMCC. IMCC d...
Whiteknight authored
437 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
9f7a94c @Whiteknight make sure to set :main() args in the iglobals array. This makes ops2c ru...
Whiteknight authored
438
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
439 /* Debugging mode nonsense. */
440 if (Interp_debug_TEST(interp, PARROT_START_DEBUG_FLAG)) {
441 Parrot_io_eprintf(interp, "*** Parrot VM: %Ss core ***\n",
442 interp->run_core->name);
709eae7 @Whiteknight add in a handful of additional API functions, though they aren't being u...
Whiteknight authored
443 }
704e3c4 @bluescreen10 Made another test case pass by putting debug information. Also removed s...
bluescreen10 authored
444
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
445 if (!pf)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
446 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
98cd26c @Whiteknight don't call Parrot_pbc_load if the PBC comes straight out of IMCC. IMCC d...
Whiteknight authored
447 if (pf->cur_cs != NULL)
448 Parrot_pbc_load(interp, pf);
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
449 PackFile_fixup_subs(interp, PBC_MAIN, NULL);
65bf81a @Whiteknight actually run the code, don't just look at it. Miniparrot runs now. parro...
Whiteknight authored
450 main_sub = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
451
452 /* if no sub was marked being :main, we create a dummy sub with offset 0 */
453
454 if (!main_sub)
455 main_sub = set_current_sub(interp);
456
457 Parrot_pcc_set_sub(interp, CURRENT_CONTEXT(interp), NULL);
458 Parrot_pcc_set_constants(interp, interp->ctx, interp->code->const_table);
459
9f7a94c @Whiteknight make sure to set :main() args in the iglobals array. This makes ops2c ru...
Whiteknight authored
460 VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_ARGV_LIST, mainargs);
73f662d @Whiteknight some fixes so libparrot builds with g++
Whiteknight authored
461 Parrot_pcc_invoke_sub_from_c_args(interp, main_sub, "P->", mainargs);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
462 EMBED_API_CALLOUT(interp_pmc, interp)
687438e @Whiteknight add in the prototype embedding API functions I've been playing with
Whiteknight authored
463 }
4a128d5 @Whiteknight lots of little changes
Whiteknight authored
464
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
465 /*
466
467 =item C<Parrot_Int Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc,
468 Parrot_PMC pbc, const char * const outfile, Parrot_Int opts)>
469
470 Disassembles and prints out the C<pbc> bytecode. This function returns a true
471 value if this call is successful and false value otherwise.
472
473 =cut
474
475 */
476
d4e8708 @Whiteknight add a failure macro for when an API call fails. Implement a few more fun...
Whiteknight authored
477 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
478 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
479 Parrot_api_disassemble_bytecode(Parrot_PMC interp_pmc, Parrot_PMC pbc,
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
480 ARGIN_NULLOK(const char * const outfile), Parrot_Int opts)
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function to ...
Whiteknight authored
481 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
482 ASSERT_ARGS(Parrot_api_disassemble_bytecode)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
483 EMBED_API_CALLIN(interp_pmc, interp)
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function to ...
Whiteknight authored
484 PackFile * const pf = (PackFile *)VTABLE_get_pointer(interp, pbc);
485 if (!pf)
486 Parrot_ex_throw_from_c_args(interp, NULL, 1, "Could not get packfile");
487 if (pf->cur_cs != NULL)
488 Parrot_pbc_load(interp, pf);
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
489 /* TODO: Break up the dependency with emebed.c */
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function to ...
Whiteknight authored
490 Parrot_disassemble(interp, outfile, (Parrot_disassemble_options)opts);
491 EMBED_API_CALLOUT(interp_pmc, interp);
492 }
493
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
494 /*
495
496 =item C<Parrot_Int Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int
497 flags)>
498
499 Enables C<inter_pmc>'s warning messages the type of warning information to be
500 print out is specified by C<flags>. This function returns a true value if this
501 call is successful and false value otherwise.
502
503 =cut
504
505 */
506
590f387 @Whiteknight update pbc_disassemble to the new API. Had to add a new API function to ...
Whiteknight authored
507 PARROT_API
508 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
509 Parrot_api_set_warnings(Parrot_PMC interp_pmc, Parrot_Int flags)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
510 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
511 ASSERT_ARGS(Parrot_api_set_warnings)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
512 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
513 /* Activates the given warnings. (Macro from warnings.h.) */
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
514 PARROT_WARNINGS_on(interp, flags);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
515 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
516 }
517
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
518 /*
519
520 =item C<Parrot_Int Parrot_api_set_output_file(Parrot_PMC interp_pmc, const char
521 * filename)>
522
523 Sets the C<interp_pmc>'s output file name specified by C<filename>. This function
524 returns a true value if this call is successful and false value otherwise.
525
526 =cut
527
528 */
529
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
530 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
531 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
532 Parrot_api_set_output_file(Parrot_PMC interp_pmc,
533 ARGIN_NULLOK(const char * filename))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
534 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
535 ASSERT_ARGS(Parrot_api_set_output_file)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
536 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
537 if (!filename && !interp->output_file)
538 interp->output_file = "-";
539 else
540 interp->output_file = filename;
c1ab56e More fixes, almost there
Mariano Wahlmann authored
541 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
542 }
543
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
544 /*
545
546 =item C<Parrot_Int Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
547 const char *path)>
548
549 Adds C<path> to the C<inter_pmc>'s library search path list. This function
550 returns a true value if this call is successful and false value otherwise.
551
552 =cut
553
554 */
555
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
556 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
557 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
558 Parrot_api_add_library_search_path(Parrot_PMC interp_pmc,
559 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
560 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
561 ASSERT_ARGS(Parrot_api_add_library_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
562 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
563 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_LIBRARY);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
564 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
565 }
566
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
567 /*
568
569 =item C<Parrot_Int Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
570 const char *path)>
571
572 Adds C<path> to the C<inter_pmc>'s include search path list. This function
573 returns a true value if this call is successful and false value otherwise.
574
575 =cut
576
577 */
578
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
579 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
580 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
581 Parrot_api_add_include_search_path(Parrot_PMC interp_pmc,
582 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
583 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
584 ASSERT_ARGS(Parrot_api_add_include_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
585 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
586 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_INCLUDE);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
587 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
588 }
589
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
590 /*
591
592 =item C<Parrot_Int Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
593 const char *path)>
594
595 Adds C<path> to the C<inter_pmc>'s dynext search path list. This function
596 returns a true value if this call is successful and false value otherwise.
597
598 =cut
599
600 */
601
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
602 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
603 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
604 Parrot_api_add_dynext_search_path(Parrot_PMC interp_pmc,
605 ARGIN(const char *path))
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
606 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
607 ASSERT_ARGS(Parrot_api_add_dynext_search_path)
c1ab56e More fixes, almost there
Mariano Wahlmann authored
608 EMBED_API_CALLIN(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
609 Parrot_lib_add_path_from_cstring(interp, path, PARROT_LIB_PATH_DYNEXT);
c1ab56e More fixes, almost there
Mariano Wahlmann authored
610 EMBED_API_CALLOUT(interp_pmc, interp)
9d25cd4 @Whiteknight change the imcc_run function to return a PackFile PMC so we can use it w...
Whiteknight authored
611 }
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
612
613 /*
614
c7def2f @jkeenan Run 'perl tools/dev/headerizer.pl src/embed/api.o'.
jkeenan authored
615 =item C<Parrot_Int Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int
616 in, Parrot_Int out, Parrot_Int err)>
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
617
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
618 Set the C<interp_pmc>'s standard file descriptors STDIN, STDOUT, STDERR. Any
619 file descriptor set to C<PIO_INVALID_HANDLE> is ignored. This function returns
620 a true value if this call is successful and false value otherwise.
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
621
622 =cut
623
624 */
f30aa2f @kapace Added some tests for embed api, get/set compiler and commented set_std_h...
kapace authored
625 /* Whiteknight told me that theres no way to test this for now, so it should be
626 commented out, for now.
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
627
628 PARROT_API
e98ef02 @Whiteknight lots of fixes. We still don't build completely, but we are much closer t...
Whiteknight authored
629 Parrot_Int
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
630 Parrot_api_set_stdhandles(Parrot_PMC interp_pmc, Parrot_Int in,
631 Parrot_Int out, Parrot_Int err)
3259cda First cut of Parrot_api_set_stdhandles API function
Mariano Wahlmann authored
632 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
633 ASSERT_ARGS(Parrot_api_set_stdhandles)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
634 EMBED_API_CALLIN(interp_pmc, interp)
635 void *dummy;
636
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
637 if (PIO_INVALID_HANDLE != (PIOHANDLE)in) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
638 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
639 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)in);
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
640 dummy = (void *)Parrot_io_stdhandle(interp, PIO_STDIN_FILENO, pmc);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
641 }
642
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
643 if (PIO_INVALID_HANDLE != (PIOHANDLE)out) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
644 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
645 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)out);
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
646 dummy = (void *)Parrot_io_stdhandle(interp, PIO_STDOUT_FILENO, pmc);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
647 }
648
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
649 if (PIO_INVALID_HANDLE != (PIOHANDLE)err) {
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
650 PMC * const pmc = Parrot_pmc_new(interp, enum_class_FileHandle);
aef7ea1 Fixed stdin,stdout and stderr Andy++ pointed out
Mariano Wahlmann authored
651 Parrot_io_set_os_handle(interp, pmc, (PIOHANDLE)err);
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
652 dummy = (void *)Parrot_io_stdhandle(interp, PIO_STDERR_FILENO, pmc);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
653 }
16e368d @Whiteknight fix several build warnings in src/embed/* in gcc, g++, and icc
Whiteknight authored
654 UNUSED(dummy);
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
655
656 EMBED_API_CALLOUT(interp_pmc, interp)
f30aa2f @kapace Added some tests for embed api, get/set compiler and commented set_std_h...
kapace authored
657 }*/
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
658
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
659 /*
660
661 =item C<Parrot_Int Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
662 Parrot_String *runtime)>
663
664 Stores in C<runtime> the C<interp_pmc>'s running path. This function returns a
665 true value if this call is successful and false value otherwise.
666
667 =cut
668
669 */
670
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
671 PARROT_API
672 Parrot_Int
1216a51 @Whiteknight quick initial pass for codestd
Whiteknight authored
673 Parrot_api_get_runtime_path(Parrot_PMC interp_pmc,
674 ARGOUT(Parrot_String *runtime))
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
675 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
676 ASSERT_ARGS(Parrot_api_get_runtime_path)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
677 EMBED_API_CALLIN(interp_pmc, interp)
f41cf98 @Whiteknight many more fixes. We build main.c now but fail in some of the alternate f...
Whiteknight authored
678 *runtime = Parrot_get_runtime_path(interp);
679 EMBED_API_CALLOUT(interp_pmc, interp);
680 }
681
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
682 /*
683
684 =item C<Parrot_Int Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc,
685 Parrot_PMC confighash)>
686
687 Sets the C<interp_pmc>'s configuration hash passed in C<confighash>. This
688 function returns a true value if this call is successful and false value
689 otherwise.
690
691 =cut
692
693 */
694
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash as...
Whiteknight authored
695 PARROT_API
696 Parrot_Int
697 Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc, Parrot_PMC confighash)
698 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
699 ASSERT_ARGS(Parrot_api_set_configuration_hash)
e9934d7 Made it compile with gcc
Mariano Wahlmann authored
700 EMBED_API_CALLIN(interp_pmc, interp)
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash as...
Whiteknight authored
701 Parrot_set_config_hash_pmc(interp, confighash);
5c2c3d4 @Whiteknight fix library paths. The build now progresses through all the parts that r...
Whiteknight authored
702 Parrot_lib_update_paths_from_config_hash(interp);
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash as...
Whiteknight authored
703 EMBED_API_CALLOUT(interp_pmc, interp);
704 }
705
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
706 /*
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
707
708 =item C<Parrot_Int Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc, const char *
709 sourcefile, int argc, const char **argv, Parrot_PMC* bytecodepmc, int *result,
710 imcc_hack_func_t func)>
711
712 WARNING: This is an evil hack to provide a wrapper around IMCC to catch unhandled
713 exceptions without having to assume IMCC is linked in with libparrot. Delete this
714 as soon as we don't need it anymore.
715
716 This function returns a true value if this call is successful and false value
717 otherwise.
718
719 =cut
720
e1ced3e @Whiteknight add a note explaining this stupid function
Whiteknight authored
721 */
722
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch error...
Whiteknight authored
723 PARROT_API
724 Parrot_Int
eaf402c @nwellnhof Fix headerizer warnings
nwellnhof authored
725 Parrot_api_wrap_imcc_hack(Parrot_PMC interp_pmc, ARGIN(const char * sourcefile),
726 int argc, ARGIN(const char **argv), ARGMOD(Parrot_PMC* bytecodepmc),
727 ARGOUT(int *result), imcc_hack_func_t func)
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch error...
Whiteknight authored
728 {
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
729 ASSERT_ARGS(Parrot_api_wrap_imcc_hack)
5b6a239 @Whiteknight Add a new, temporary hack API for wrapping up IMCC so we can catch error...
Whiteknight authored
730 EMBED_API_CALLIN(interp_pmc, interp)
731 *result = func(interp_pmc, sourcefile, argc, argv, bytecodepmc);
732 EMBED_API_CALLOUT(interp_pmc, interp)
733 }
c4ccd13 @Whiteknight first prototype of a new mechanism for setting the configuration hash as...
Whiteknight authored
734
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
735 /*
736
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
737 =item C<Parrot_Int Parrot_api_load_language(Parrot_PMC interp_pmc, Parrot_String
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
738 lang)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
739
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
740 Loads the HLL compiler libraries for C<lang> into the C<interp_pmc>. This
741 function returns a true value if this call is successful and false value
742 otherwise.
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
743
744 =cut
745
746 */
747
748 PARROT_API
749 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
750 Parrot_api_load_language(Parrot_PMC interp_pmc, Parrot_String lang)
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
751 {
752 ASSERT_ARGS(Parrot_api_load_language)
753 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
754 Parrot_load_language(interp, lang);
755 EMBED_API_CALLOUT(interp_pmc, interp);
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
756 }
757
758 /*
759
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
760 =item C<Parrot_Int Parrot_api_get_compiler(Parrot_PMC interp_pmc, Parrot_String
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
761 type, Parrot_PMC *compiler)>
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
762
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
763 Gets the compiler PMC and stores it in C<compiler>. This function returns a true
764 value if this call is successful and false value otherwise.
765
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
766 =cut
767
768 */
769
770 PARROT_API
771 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
772 Parrot_api_get_compiler(Parrot_PMC interp_pmc, Parrot_String type,
773 ARGOUT(Parrot_PMC *compiler))
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
774 {
775 ASSERT_ARGS(Parrot_api_get_compiler)
776 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
777 *compiler = Parrot_get_compiler(interp, type);
778 EMBED_API_CALLOUT(interp_pmc, interp);
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
779 }
780
781 /*
782
783 =item C<Parrot_Int Parrot_api_set_compiler(Parrot_PMC interp_pmc, Parrot_String
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
784 type, Parrot_PMC compiler)>
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
785
cc0610a @bluescreen10 Fixed codigstd tests
bluescreen10 authored
786 Sets the C<compiler> object for the C<type> files. This function returns a true
787 value if this call is successful and false value otherwise.
788
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
789 =cut
790
791 */
792
793 PARROT_API
794 Parrot_Int
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
795 Parrot_api_set_compiler(Parrot_PMC interp_pmc, Parrot_String type,
796 Parrot_PMC compiler)
f0bd1e1 First cut of load_language, set_compiler, get compiler
Mariano Wahlmann authored
797 {
798 ASSERT_ARGS(Parrot_api_set_compiler)
799 EMBED_API_CALLIN(interp_pmc, interp)
d74cf45 @Whiteknight fix build warnings in src/embed/api.c
Whiteknight authored
800 Parrot_set_compiler(interp, type, compiler);
801 EMBED_API_CALLOUT(interp_pmc, interp);
3562b6b Unfished work implemented API functions
Mariano Wahlmann authored
802 }
0814f94 Merged changes with branch
Mariano Wahlmann authored
803
6f90f7d @nol888 Add API functions to get a class from an array, and to instantiate a PMC...
nol888 authored
804
0814f94 Merged changes with branch
Mariano Wahlmann authored
805 /*
806
1311cec @jkeenan [codingstd] Fix files so they pass c_operator, c_parens, pod_syntax, and
jkeenan authored
807 =back
808
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
809 =cut
0814f94 Merged changes with branch
Mariano Wahlmann authored
810
7db7331 @jkeenan Correct C-comment syntax error.
jkeenan authored
811 */
9703ef5 @jkeenan [codingstd] C-style coda needed. No cuddled elses.
jkeenan authored
812
540a832 @jkeenan [codingstd] Mostly linelength fixes.
jkeenan authored
813 /*
814 * Local variables:
815 * c-file-style: "parrot"
816 * End:
817 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
818 */
0814f94 Merged changes with branch
Mariano Wahlmann authored
819
Something went wrong with that request. Please try again.