Fix wrapper for delegates returning arrays, fixes bug 564474
[vala-lang.git] / gobject / valaccodegenerator.vala
blob0f535d2cf1a1524d32424393695d5e2b3515a9a0
1 /* valaccodegenerator.vala
3 * Copyright (C) 2006-2008 Jürg Billeter, Raffaele Sandrini
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * Author:
20 * Jürg Billeter <j@bitron.ch>
21 * Raffaele Sandrini <raffaele@sandrini.ch>
24 using GLib;
25 using Gee;
27 /**
28 * Code visitor generating C Code.
30 public class Vala.CCodeGenerator : CodeGenerator {
31 public CCodeModule head;
33 public CCodeGenerator () {
34 /* included by inheritance
35 head = new CCodeBaseModule (this, head);
36 head = new CCodeStructModule (this, head);
37 head = new CCodeMethodModule (this, head);
38 head = new CCodeControlFlowModule (this, head);
39 head = new CCodeMemberAccessModule (this, head);
40 head = new CCodeAssignmentModule (this, head);
41 head = new CCodeMethodCallModule (this, head);
42 head = new CCodeArrayModule (this, head);
43 head = new CCodeDelegateModule (this, head);
44 head = new GErrorModule (this, head);
45 head = new GTypeModule (this, head);
46 head = new GObjectModule (this, head);
47 head = new GSignalModule (this, head);
48 head = new GAsyncModule (this, head);
49 head = new DBusClientModule (this, head);
51 head = new DBusServerModule (this, head);
54 public override void emit (CodeContext context) {
55 head.emit (context);
58 public override void visit_source_file (SourceFile source_file) {
59 head.visit_source_file (source_file);
62 public override void visit_class (Class cl) {
63 head.visit_class (cl);
66 public override void visit_interface (Interface iface) {
67 head.visit_interface (iface);
70 public override void visit_struct (Struct st) {
71 head.visit_struct (st);
74 public override void visit_enum (Enum en) {
75 head.visit_enum (en);
78 public override void visit_enum_value (EnumValue ev) {
79 head.visit_enum_value (ev);
82 public override void visit_error_domain (ErrorDomain edomain) {
83 head.visit_error_domain (edomain);
86 public override void visit_error_code (ErrorCode ecode) {
87 head.visit_error_code (ecode);
90 public override void visit_delegate (Delegate d) {
91 head.visit_delegate (d);
94 public override void visit_member (Member m) {
95 head.visit_member (m);
98 public override void visit_constant (Constant c) {
99 head.visit_constant (c);
102 public override void visit_field (Field f) {
103 head.visit_field (f);
106 public override void visit_method (Method m) {
107 head.visit_method (m);
110 public override void visit_creation_method (CreationMethod m) {
111 head.visit_creation_method (m);
114 public override void visit_formal_parameter (FormalParameter p) {
115 head.visit_formal_parameter (p);
118 public override void visit_property (Property prop) {
119 head.visit_property (prop);
122 public override void visit_property_accessor (PropertyAccessor acc) {
123 head.visit_property_accessor (acc);
126 public override void visit_signal (Signal sig) {
127 head.visit_signal (sig);
130 public override void visit_constructor (Constructor c) {
131 head.visit_constructor (c);
134 public override void visit_destructor (Destructor d) {
135 head.visit_destructor (d);
138 public override void visit_block (Block b) {
139 head.visit_block (b);
142 public override void visit_empty_statement (EmptyStatement stmt) {
143 head.visit_empty_statement (stmt);
146 public override void visit_declaration_statement (DeclarationStatement stmt) {
147 head.visit_declaration_statement (stmt);
150 public override void visit_local_variable (LocalVariable local) {
151 head.visit_local_variable (local);
154 public override void visit_initializer_list (InitializerList list) {
155 head.visit_initializer_list (list);
158 public override void visit_end_full_expression (Expression expr) {
159 head.visit_end_full_expression (expr);
162 public override void visit_expression_statement (ExpressionStatement stmt) {
163 head.visit_expression_statement (stmt);
166 public override void visit_if_statement (IfStatement stmt) {
167 head.visit_if_statement (stmt);
170 public override void visit_switch_statement (SwitchStatement stmt) {
171 head.visit_switch_statement (stmt);
174 public override void visit_switch_section (SwitchSection section) {
175 head.visit_switch_section (section);
178 public override void visit_switch_label (SwitchLabel label) {
179 head.visit_switch_label (label);
182 public override void visit_while_statement (WhileStatement stmt) {
183 head.visit_while_statement (stmt);
186 public override void visit_do_statement (DoStatement stmt) {
187 head.visit_do_statement (stmt);
190 public override void visit_for_statement (ForStatement stmt) {
191 head.visit_for_statement (stmt);
194 public override void visit_foreach_statement (ForeachStatement stmt) {
195 head.visit_foreach_statement (stmt);
198 public override void visit_break_statement (BreakStatement stmt) {
199 head.visit_break_statement (stmt);
202 public override void visit_continue_statement (ContinueStatement stmt) {
203 head.visit_continue_statement (stmt);
206 public override void visit_return_statement (ReturnStatement stmt) {
207 head.visit_return_statement (stmt);
210 public override void visit_yield_statement (YieldStatement stmt) {
211 head.visit_yield_statement (stmt);
214 public override void visit_throw_statement (ThrowStatement stmt) {
215 head.visit_throw_statement (stmt);
218 public override void visit_try_statement (TryStatement stmt) {
219 head.visit_try_statement (stmt);
222 public override void visit_catch_clause (CatchClause clause) {
223 head.visit_catch_clause (clause);
226 public override void visit_lock_statement (LockStatement stmt) {
227 head.visit_lock_statement (stmt);
230 public override void visit_delete_statement (DeleteStatement stmt) {
231 head.visit_delete_statement (stmt);
234 public override void visit_expression (Expression expr) {
235 head.visit_expression (expr);
238 public override void visit_array_creation_expression (ArrayCreationExpression expr) {
239 head.visit_array_creation_expression (expr);
242 public override void visit_boolean_literal (BooleanLiteral expr) {
243 head.visit_boolean_literal (expr);
246 public override void visit_character_literal (CharacterLiteral expr) {
247 head.visit_character_literal (expr);
250 public override void visit_integer_literal (IntegerLiteral expr) {
251 head.visit_integer_literal (expr);
254 public override void visit_real_literal (RealLiteral expr) {
255 head.visit_real_literal (expr);
258 public override void visit_string_literal (StringLiteral expr) {
259 head.visit_string_literal (expr);
262 public override void visit_null_literal (NullLiteral expr) {
263 head.visit_null_literal (expr);
266 public override void visit_parenthesized_expression (ParenthesizedExpression expr) {
267 head.visit_parenthesized_expression (expr);
270 public override void visit_member_access (MemberAccess expr) {
271 head.visit_member_access (expr);
274 public override void visit_method_call (MethodCall expr) {
275 head.visit_method_call (expr);
278 public override void visit_element_access (ElementAccess expr) {
279 head.visit_element_access (expr);
282 public override void visit_base_access (BaseAccess expr) {
283 head.visit_base_access (expr);
286 public override void visit_postfix_expression (PostfixExpression expr) {
287 head.visit_postfix_expression (expr);
290 public override void visit_object_creation_expression (ObjectCreationExpression expr) {
291 head.visit_object_creation_expression (expr);
294 public override void visit_sizeof_expression (SizeofExpression expr) {
295 head.visit_sizeof_expression (expr);
298 public override void visit_typeof_expression (TypeofExpression expr) {
299 head.visit_typeof_expression (expr);
302 public override void visit_unary_expression (UnaryExpression expr) {
303 head.visit_unary_expression (expr);
306 public override void visit_cast_expression (CastExpression expr) {
307 head.visit_cast_expression (expr);
310 public override void visit_pointer_indirection (PointerIndirection expr) {
311 head.visit_pointer_indirection (expr);
314 public override void visit_addressof_expression (AddressofExpression expr) {
315 head.visit_addressof_expression (expr);
318 public override void visit_reference_transfer_expression (ReferenceTransferExpression expr) {
319 head.visit_reference_transfer_expression (expr);
322 public override void visit_binary_expression (BinaryExpression expr) {
323 head.visit_binary_expression (expr);
326 public override void visit_type_check (TypeCheck expr) {
327 head.visit_type_check (expr);
330 public override void visit_lambda_expression (LambdaExpression l) {
331 head.visit_lambda_expression (l);
334 public override void visit_assignment (Assignment a) {
335 head.visit_assignment (a);