+2006-05-19 Jürg Billeter <j@bitron.ch>
+
+ * vala/valacodegenerator.vala: include header file in corresponding
+ source file, generate class macros and typedefs
+ * ccode/valaccodeincludedirective.vala
+ * ccode/valaccodemacroreplacement.vala: c macro definition
+ * ccode/valaccodetypedefinition.vala: c typedef
+ * bindings/glib-2.0.vala: correct comment
+
2006-05-18 Jürg Billeter <j@bitron.ch>
* vala/valacodecontext.vala: add get_source_files method
-/* GLib.vala
+/* glib-2.0.vala
*
* Copyright (C) 2006 Jürg Billeter
*
--- /dev/null
+/* valaccodeincludedirective.vala
+ *
+ * Copyright (C) 2006 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 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 <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+ public class CCodeIncludeDirective : CCodeNode {
+ public string filename { get; construct; }
+
+ public override void write (CCodeWriter writer) {
+ writer.write_indent ();
+ writer.write_string ("#include <");
+ writer.write_string (filename);
+ writer.write_string (">");
+ writer.write_newline ();
+ }
+ }
+}
--- /dev/null
+/* valaccodemacroreplacement.vala
+ *
+ * Copyright (C) 2006 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 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 <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+ public class CCodeMacroReplacement : CCodeNode {
+ public string name { get; construct; }
+ public string replacement { get; construct; }
+
+ public override void write (CCodeWriter writer) {
+ writer.write_indent ();
+ writer.write_string ("#define ");
+ writer.write_string (name);
+ writer.write_string (" ");
+ writer.write_string (replacement);
+ writer.write_newline ();
+ }
+ }
+}
--- /dev/null
+/* valaccodetypedefinition.vala
+ *
+ * Copyright (C) 2006 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 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 <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+ public class CCodeTypeDefinition : CCodeNode {
+ public string type_name { get; construct; }
+ public string typedef_name { get; construct; }
+
+ public override void write (CCodeWriter writer) {
+ writer.write_indent ();
+ writer.write_string ("typedef ");
+ writer.write_string (type_name);
+ writer.write_string (" ");
+ writer.write_string (typedef_name);
+ writer.write_string (";");
+ writer.write_newline ();
+ }
+ }
+}
if (source_file.comment != null) {
header_begin.append (new CCodeComment (text = source_file.comment));
}
+
+ source_include_directives.append (new CCodeIncludeDirective (filename = source_file.get_cheader_filename ()));
}
public override void visit_end_source_file (SourceFile source_file) {
instance_struct = new CCodeStruct (name = "_%s".printf (cl.get_cname ()));
class_struct = new CCodeStruct (name = "_%sClass".printf (cl.get_cname ()));
+
+ var macro = "(%s_get_type ())".printf (cl.get_lower_case_cname (null));
+ header_type_declaration.append (new CCodeMacroReplacement (name = cl.get_upper_case_cname ("TYPE_"), replacement = macro));
+
+ macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (cl.get_upper_case_cname ("TYPE_"), cl.get_cname ());
+ header_type_declaration.append (new CCodeMacroReplacement (name = "%s(obj)".printf (cl.get_upper_case_cname (null)), replacement = macro));
+
+ macro = "(G_TYPE_CHECK_CLASS_CAST ((klass), %s, %sClass))".printf (cl.get_upper_case_cname ("TYPE_"), cl.get_cname ());
+ header_type_declaration.append (new CCodeMacroReplacement (name = "%s_CLASS(klass)".printf (cl.get_upper_case_cname (null)), replacement = macro));
+
+ macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (cl.get_upper_case_cname ("TYPE_"));
+ header_type_declaration.append (new CCodeMacroReplacement (name = "%s(obj)".printf (cl.get_upper_case_cname ("IS_")), replacement = macro));
+
+ macro = "(G_TYPE_CHECK_CLASS_TYPE ((klass), %s))".printf (cl.get_upper_case_cname ("TYPE_"));
+ header_type_declaration.append (new CCodeMacroReplacement (name = "%s_CLASS(klass)".printf (cl.get_upper_case_cname ("IS_")), replacement = macro));
+
+ macro = "(G_TYPE_INSTANCE_GET_CLASS ((obj), %s, %sClass))".printf (cl.get_upper_case_cname ("TYPE_"), cl.get_cname ());
+ header_type_declaration.append (new CCodeMacroReplacement (name = "%s_GET_CLASS(obj)".printf (cl.get_upper_case_cname (null)), replacement = macro));
+
+
+ header_type_declaration.append (new CCodeTypeDefinition (type_name = "struct %s".printf (instance_struct.name), typedef_name = cl.get_cname ()));
+ header_type_declaration.append (new CCodeTypeDefinition (type_name = "struct %s".printf (class_struct.name), typedef_name = "%sClass".printf (cl.get_cname ())));
+
instance_struct.add_field (cl.base_class.get_cname (), "parent");
class_struct.add_field ("%sClass".printf (cl.base_class.get_cname ()), "parent");