diff options
Diffstat (limited to 'bitbake/lib/bb/parse/parse_c/bitbakec.pyx')
-rw-r--r-- | bitbake/lib/bb/parse/parse_c/bitbakec.pyx | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/bitbake/lib/bb/parse/parse_c/bitbakec.pyx b/bitbake/lib/bb/parse/parse_c/bitbakec.pyx new file mode 100644 index 0000000000..362cc2021e --- /dev/null +++ b/bitbake/lib/bb/parse/parse_c/bitbakec.pyx | |||
@@ -0,0 +1,180 @@ | |||
1 | # ex:ts=4:sw=4:sts=4:et | ||
2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
3 | |||
4 | cdef extern from "stdio.h": | ||
5 | ctypedef int FILE | ||
6 | FILE *fopen(char*, char*) | ||
7 | int fclose(FILE *fp) | ||
8 | |||
9 | |||
10 | cdef extern from "lexerc.h": | ||
11 | ctypedef struct lex_t: | ||
12 | void* parser | ||
13 | void* scanner | ||
14 | FILE* file | ||
15 | void* data | ||
16 | |||
17 | int lineError | ||
18 | int errorParse | ||
19 | |||
20 | cdef extern void parse(FILE*, object) | ||
21 | |||
22 | def parsefile(object file, object data): | ||
23 | print "parsefile: 1", file, data | ||
24 | |||
25 | # Open the file | ||
26 | cdef FILE* f | ||
27 | |||
28 | f = fopen(file, "r") | ||
29 | print "parsefile: 2 opening file" | ||
30 | if (f == NULL): | ||
31 | raise IOError("No such file %s." % file) | ||
32 | |||
33 | print "parsefile: 3 parse" | ||
34 | parse(f, data) | ||
35 | |||
36 | # Close the file | ||
37 | print "parsefile: 4 closing" | ||
38 | fclose(f) | ||
39 | |||
40 | |||
41 | cdef public void e_assign(lex_t* container, char* key, char* what): | ||
42 | print "e_assign", key, what | ||
43 | d = <object>container.data | ||
44 | d.setVar(key, what) | ||
45 | |||
46 | cdef public void e_export(lex_t* c, char* what): | ||
47 | print "e_export", what | ||
48 | #exp: | ||
49 | # bb.data.setVarFlag(key, "export", 1, data) | ||
50 | d = <object>container.data | ||
51 | d.setVarFlag(key, "export", 1) | ||
52 | |||
53 | cdef public void e_immediate(lex_t* c, char* key, char* what): | ||
54 | print "e_immediate", key, what | ||
55 | #colon: | ||
56 | # val = bb.data.expand(groupd["value"], data) | ||
57 | d = <object>c.data | ||
58 | d.setVar(key, d.expand(what)) | ||
59 | |||
60 | cdef public void e_cond(lex_t* c, char* key, char* what): | ||
61 | print "e_cond", key, what | ||
62 | #ques: | ||
63 | # val = bb.data.getVar(key, data) | ||
64 | # if val == None: | ||
65 | # val = groupd["value"] | ||
66 | d = <object>c.data | ||
67 | d.setVar(key, (d.getVar(key) or what)) | ||
68 | |||
69 | cdef public void e_prepend(lex_t* c, char* key, char* what): | ||
70 | print "e_prepend", key, what | ||
71 | #prepend: | ||
72 | # val = "%s %s" % (groupd["value"], (bb.data.getVar(key, data) or "")) | ||
73 | d = <object>c.data | ||
74 | d.setVar(key, what + " " + (d.getVar(key) or "")) | ||
75 | |||
76 | cdef public void e_append(lex_t* c, char* key, char* what): | ||
77 | print "e_append", key, what | ||
78 | #append: | ||
79 | # val = "%s %s" % ((bb.data.getVar(key, data) or ""), groupd["value"]) | ||
80 | d = <object>c.data | ||
81 | d.setVar(key, (d.getVar(key) or "") + " " + what) | ||
82 | |||
83 | cdef public void e_precat(lex_t* c, char* key, char* what): | ||
84 | print "e_precat", key, what | ||
85 | #predot: | ||
86 | # val = "%s%s" % (groupd["value"], (bb.data.getVar(key, data) or "")) | ||
87 | d = <object>c.data | ||
88 | d.setVar(key, what + (d.getVar(key) or "")) | ||
89 | |||
90 | cdef public void e_postcat(lex_t* c, char* key, char* what): | ||
91 | print "e_postcat", key, what | ||
92 | #postdot: | ||
93 | # val = "%s%s" % ((bb.data.getVar(key, data) or ""), groupd["value"]) | ||
94 | d = <object>c.data | ||
95 | d.setVar(key, (d.getVar(key) or "") + what) | ||
96 | |||
97 | cdef public void e_addtask(lex_t* c, char* name, char* before, char* after): | ||
98 | print "e_addtask", name, before, after | ||
99 | # func = m.group("func") | ||
100 | # before = m.group("before") | ||
101 | # after = m.group("after") | ||
102 | # if func is None: | ||
103 | # return | ||
104 | # var = "do_" + func | ||
105 | # | ||
106 | # data.setVarFlag(var, "task", 1, d) | ||
107 | # | ||
108 | # if after is not None: | ||
109 | # # set up deps for function | ||
110 | # data.setVarFlag(var, "deps", after.split(), d) | ||
111 | # if before is not None: | ||
112 | # # set up things that depend on this func | ||
113 | # data.setVarFlag(var, "postdeps", before.split(), d) | ||
114 | # return | ||
115 | |||
116 | do = "do_%s" % name | ||
117 | d = <object>c.data | ||
118 | d.setVarFlag(do, "task", 1) | ||
119 | |||
120 | if strlen(before) > 0: | ||
121 | d.setVarFlag(do, "deps", ("%s" % after).split()) | ||
122 | if strlen(after) > 0: | ||
123 | d.setVarFlag(do, "deps", ("%s" % before).split()) | ||
124 | |||
125 | |||
126 | cdef public void e_addhandler(lex_t* c, char* h): | ||
127 | print "e_addhandler", h | ||
128 | # data.setVarFlag(h, "handler", 1, d) | ||
129 | d = <object>c.data | ||
130 | d.setVarFlag(h, "handler", 1) | ||
131 | |||
132 | cdef public void e_export_func(lex_t* c, char* function): | ||
133 | print "e_export_func", function | ||
134 | pass | ||
135 | |||
136 | cdef public void e_inherit(lex_t* c, char* file): | ||
137 | print "e_inherit", file | ||
138 | pass | ||
139 | |||
140 | cdef public void e_include(lex_t* c, char* file): | ||
141 | print "e_include", file | ||
142 | d = <object>c.data | ||
143 | d.expand(file) | ||
144 | |||
145 | try: | ||
146 | parsefile(file, d) | ||
147 | except IOError: | ||
148 | print "Could not include required file %s" % file | ||
149 | |||
150 | |||
151 | cdef public void e_require(lex_t* c, char* file): | ||
152 | print "e_require", file | ||
153 | d = <object>c.data | ||
154 | d.expand(file) | ||
155 | |||
156 | try: | ||
157 | parsefile(file, d) | ||
158 | except IOError: | ||
159 | raise CParseError("Could not include required file %s" % file) | ||
160 | |||
161 | cdef public void e_proc(lex_t* c, char* key, char* what): | ||
162 | print "e_proc", key, what | ||
163 | pass | ||
164 | |||
165 | cdef public void e_proc_python(lex_t* c, char* key, char* what): | ||
166 | print "e_proc_python", key, what | ||
167 | pass | ||
168 | |||
169 | cdef public void e_proc_fakeroot(lex_t* c, char* key, char* what): | ||
170 | print "e_fakeroot", key, what | ||
171 | pass | ||
172 | |||
173 | cdef public void e_def(lex_t* c, char* a, char* b, char* d): | ||
174 | print "e_def", key, what | ||
175 | pass | ||
176 | |||
177 | cdef public void e_parse_error(lex_t* c): | ||
178 | print "e_parse_error", "line:", lineError, "parse:", errorParse | ||
179 | raise CParseError("There was an parse error, sorry unable to give more information at the current time.") | ||
180 | |||