1 | #line 39 "t/src/extend_vtable.t" |
---|
2 | #include <stdio.h> |
---|
3 | #include <stdlib.h> |
---|
4 | #include <string.h> |
---|
5 | #include "parrot/embed.h" |
---|
6 | #include "parrot/extend.h" |
---|
7 | #include "parrot/extend_vtable.h" |
---|
8 | |
---|
9 | static void fail(const char *msg); |
---|
10 | static Parrot_String createstring(Parrot_Interp interp, const char * value); |
---|
11 | static Parrot_Interp new_interp(); |
---|
12 | |
---|
13 | static void fail(const char *msg) |
---|
14 | { |
---|
15 | fprintf(stderr, "failed: %s\n", msg); |
---|
16 | exit(EXIT_FAILURE); |
---|
17 | } |
---|
18 | |
---|
19 | static Parrot_String createstring(Parrot_Interp interp, const char * value) |
---|
20 | { |
---|
21 | return Parrot_new_string(interp, value, strlen(value), (const char*)NULL, 0); |
---|
22 | } |
---|
23 | |
---|
24 | static Parrot_Interp new_interp() |
---|
25 | { |
---|
26 | Parrot_Interp interp = Parrot_new(NULL); |
---|
27 | if (!interp) |
---|
28 | fail("Cannot create parrot interpreter"); |
---|
29 | return interp; |
---|
30 | |
---|
31 | } |
---|
32 | |
---|
33 | #line 77 "t/src/extend_vtable.t" |
---|
34 | int main(void) |
---|
35 | { |
---|
36 | Parrot_Interp interp; |
---|
37 | Parrot_PMC pmc, pmc2, pmc3, pmc_string, pmc_string2; |
---|
38 | Parrot_PMC pmc_float, pmc_float2; |
---|
39 | Parrot_PMC rpa, rpa2; |
---|
40 | Parrot_Int type, value, integer, integer2; |
---|
41 | Parrot_Float number, number2; |
---|
42 | Parrot_String string, string2; |
---|
43 | |
---|
44 | interp = new_interp(); |
---|
45 | |
---|
46 | type = Parrot_PMC_typenum(interp, "Integer"); |
---|
47 | rpa = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp, "ResizablePMCArray")); |
---|
48 | rpa2 = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp, "ResizablePMCArray")); |
---|
49 | pmc = Parrot_PMC_new(interp, type); |
---|
50 | pmc2 = Parrot_PMC_new(interp, type); |
---|
51 | pmc3 = Parrot_PMC_new(interp, type); |
---|
52 | |
---|
53 | pmc_string = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp,"String")); |
---|
54 | pmc_string2 = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp,"String")); |
---|
55 | |
---|
56 | pmc_float = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp,"Float")); |
---|
57 | pmc_float2 = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp,"Float")); |
---|
58 | |
---|
59 | Parrot_PMC_set_integer_native(interp, pmc, 42); |
---|
60 | Parrot_PMC_set_integer_native(interp, pmc2, 99); |
---|
61 | |
---|
62 | Parrot_PMC_freeze(interp, pmc, pmc2); |
---|
63 | Parrot_PMC_thaw(interp, pmc, pmc2); |
---|
64 | Parrot_printf(interp,"%d\n", 42); |
---|
65 | |
---|
66 | |
---|
67 | /* TODO: Properly test this */ |
---|
68 | Parrot_PMC_destroy(interp, pmc); |
---|
69 | |
---|
70 | Parrot_destroy(interp); |
---|
71 | printf("Done!\n"); |
---|
72 | return 0; |
---|
73 | } |
---|