From: Jürg Billeter Date: Fri, 24 Oct 2008 09:30:44 +0000 (+0000) Subject: Add CCodeModule and CCodeBaseModule classes as preparation to make the X-Git-Tag: VALA_0_5_1~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89d5195ad70d6c066f23d717545e2b65efab2075;p=thirdparty%2Fvala.git Add CCodeModule and CCodeBaseModule classes as preparation to make the 2008-10-24 Jürg Billeter * gobject/Makefile.am: * gobject/valaccodebasemodule.vala: * gobject/valaccodegenerator.vala: * gobject/valaccodemodule.vala: Add CCodeModule and CCodeBaseModule classes as preparation to make the backend more modular svn path=/trunk/; revision=1882 --- diff --git a/ChangeLog b/ChangeLog index fee87d66a..964b8c3f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-10-24 Jürg Billeter + + * gobject/Makefile.am: + * gobject/valaccodebasemodule.vala: + * gobject/valaccodegenerator.vala: + * gobject/valaccodemodule.vala: + + Add CCodeModule and CCodeBaseModule classes as preparation to + make the backend more modular + 2008-10-24 Jürg Billeter * gobject/valaccodeinvocationexpressionbinding.vala: diff --git a/gobject/Makefile.am b/gobject/Makefile.am index 1d116c0ba..8193b6c69 100644 --- a/gobject/Makefile.am +++ b/gobject/Makefile.am @@ -14,6 +14,7 @@ lib_LTLIBRARIES = \ libvala_la_VALASOURCES = \ valaccodearraycreationexpressionbinding.vala \ valaccodeassignmentbinding.vala \ + valaccodebasemodule.vala \ valaccodebinding.vala \ valaccodeclassbinding.vala \ valaccodecompiler.vala \ @@ -31,6 +32,7 @@ libvala_la_VALASOURCES = \ valaccodeinvocationexpressionbinding.vala \ valaccodememberaccessbinding.vala \ valaccodemethodbinding.vala \ + valaccodemodule.vala \ valaccodeobjecttypesymbolbinding.vala \ valaccodetypesymbolbinding.vala \ valaclassregisterfunction.vala \ diff --git a/gobject/valaccodebasemodule.vala b/gobject/valaccodebasemodule.vala new file mode 100644 index 000000000..9fef4a18e --- /dev/null +++ b/gobject/valaccodebasemodule.vala @@ -0,0 +1,30 @@ +/* valaccodebasemodule.vala + * + * Copyright (C) 2008 Jürg Billeter + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: + * Jürg Billeter + */ + +/** + * Code visitor generating C Code. + */ +public class Vala.CCodeBaseModule : CCodeModule { + public CCodeBaseModule (CCodeModule? next) { + base (next); + } +} diff --git a/gobject/valaccodegenerator.vala b/gobject/valaccodegenerator.vala index 0279e48f5..81b513a70 100644 --- a/gobject/valaccodegenerator.vala +++ b/gobject/valaccodegenerator.vala @@ -28,6 +28,8 @@ using Gee; * Code visitor generating C Code. */ public class Vala.CCodeGenerator : CodeGenerator { + CCodeModule head; + public CodeContext context; public Symbol root_symbol; @@ -139,6 +141,8 @@ public class Vala.CCodeGenerator : CodeGenerator { private Set wrappers; public CCodeGenerator () { + this.head = new CCodeBaseModule (null); + predefined_marshal_set = new HashSet (str_hash, str_equal); predefined_marshal_set.add ("VOID:VOID"); predefined_marshal_set.add ("VOID:BOOLEAN"); @@ -205,6 +209,8 @@ public class Vala.CCodeGenerator : CodeGenerator { } public override void emit (CodeContext context) { + this.head.emit (context); + this.context = context; context.find_header_cycles (); diff --git a/gobject/valaccodemodule.vala b/gobject/valaccodemodule.vala new file mode 100644 index 000000000..d78de0a9d --- /dev/null +++ b/gobject/valaccodemodule.vala @@ -0,0 +1,42 @@ +/* valaccodemodule.vala + * + * Copyright (C) 2008 Jürg Billeter + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: + * Jürg Billeter + */ + +using Gee; + +/** + * Code visitor generating C Code. + */ +public abstract class Vala.CCodeModule { + public weak CCodeModule head { get; private set; } + + public CCodeModule? next { get; private set; } + + public CCodeModule (CCodeModule? next) { + this.next = next; + } + + public virtual void emit (CodeContext context) { + if (next != null) { + next.emit (context); + } + } +}