From bf8e760d50e37842253f92767a144d439426c598 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Wed, 11 Jul 2007 14:23:50 +0000 Subject: [PATCH] fix order in C header file test public delegate 2007-07-11 Juerg Billeter * ccode/valaccodefragment.vala, ccode/valaccodenode.vala, ccode/valaccodeoncesection.vala, gobject/valacodegenerator.vala, gobject/valacodegeneratorsourcefile.vala: fix order in C header file * tests/test-014.vala, tests/test-014.out: test public delegate Fixes bug 442703 svn path=/trunk/; revision=345 --- ChangeLog | 9 +++++++++ ccode/valaccodefragment.vala | 6 ++++++ ccode/valaccodenode.vala | 11 +++++++++++ ccode/valaccodeoncesection.vala | 5 +---- gobject/valacodegenerator.vala | 2 +- gobject/valacodegeneratorsourcefile.vala | 1 - tests/test-014.out | 2 +- tests/test-014.vala | 4 ++-- 8 files changed, 31 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7d4344b4..1a64d04d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-07-11 Jürg Billeter + + * ccode/valaccodefragment.vala, ccode/valaccodenode.vala, + ccode/valaccodeoncesection.vala, gobject/valacodegenerator.vala, + gobject/valacodegeneratorsourcefile.vala: fix order in C header file + * tests/test-014.vala, tests/test-014.out: test public delegate + + Fixes bug 442703 + 2007-07-11 Jürg Billeter * vala/valaforeachstatement.vala: call visit_end_full_expression for diff --git a/ccode/valaccodefragment.vala b/ccode/valaccodefragment.vala index b344383f0..86ed0d592 100644 --- a/ccode/valaccodefragment.vala +++ b/ccode/valaccodefragment.vala @@ -57,4 +57,10 @@ public class Vala.CCodeFragment : CCodeNode { node.write_declaration (writer); } } + + public override void write_combined (CCodeWriter! writer) { + foreach (CCodeNode node in children) { + node.write_combined (writer); + } + } } diff --git a/ccode/valaccodenode.vala b/ccode/valaccodenode.vala index 77c66d420..18240a697 100644 --- a/ccode/valaccodenode.vala +++ b/ccode/valaccodenode.vala @@ -48,4 +48,15 @@ public abstract class Vala.CCodeNode { */ public virtual void write_declaration (CCodeWriter! writer) { } + + /** + * Writes declaration and implementation combined for this code node and + * all children with the specified C code writer. + * + * @param writer a C code writer + */ + public virtual void write_combined (CCodeWriter! writer) { + write_declaration (writer); + write (writer); + } } diff --git a/ccode/valaccodeoncesection.vala b/ccode/valaccodeoncesection.vala index 5d0ceff34..f049d8d2a 100644 --- a/ccode/valaccodeoncesection.vala +++ b/ccode/valaccodeoncesection.vala @@ -44,10 +44,7 @@ public class Vala.CCodeOnceSection : CCodeFragment { writer.write_string (define); writer.write_newline (); foreach (CCodeNode node in get_children ()) { - node.write_declaration (writer); - } - foreach (CCodeNode node in get_children ()) { - node.write (writer); + node.write_combined (writer); } writer.write_indent (); writer.write_string ("#endif"); diff --git a/gobject/valacodegenerator.vala b/gobject/valacodegenerator.vala index 70faaaa9b..3d1ae542b 100644 --- a/gobject/valacodegenerator.vala +++ b/gobject/valacodegenerator.vala @@ -314,7 +314,7 @@ public class Vala.CodeGenerator : CodeVisitor { var ctypedef = new CCodeTypeDefinition (cb.return_type.get_cname (), cfundecl); if (cb.access != MemberAccessibility.PRIVATE) { - header_type_declaration.append (ctypedef); + header_type_definition.append (ctypedef); } else { source_type_member_declaration.append (ctypedef); } diff --git a/gobject/valacodegeneratorsourcefile.vala b/gobject/valacodegeneratorsourcefile.vala index f29c89802..a3b7f3e58 100644 --- a/gobject/valacodegeneratorsourcefile.vala +++ b/gobject/valacodegeneratorsourcefile.vala @@ -139,7 +139,6 @@ public class Vala.CodeGenerator { once.append (new CCodeIdentifier ("G_END_DECLS")); once.append (new CCodeNewline ()); once.append (new CCodeNewline ()); - once.write_declaration (writer); once.write (writer); writer.close (); diff --git a/tests/test-014.out b/tests/test-014.out index 3be1de6ce..4f3a6b477 100644 --- a/tests/test-014.out +++ b/tests/test-014.out @@ -1 +1 @@ -Callback Test: 1 2 3 +Delegate Test: 1 2 3 diff --git a/tests/test-014.vala b/tests/test-014.vala index 30b727b6b..5ac7f87fc 100644 --- a/tests/test-014.vala +++ b/tests/test-014.vala @@ -1,6 +1,6 @@ using GLib; -static delegate int Maman.ActionCallback (); +public static delegate int Maman.ActionCallback (); class Maman.Bar { static int do_action () { @@ -8,7 +8,7 @@ class Maman.Bar { } static int main (string[] args) { - stdout.printf ("Callback Test: 1"); + stdout.printf ("Delegate Test: 1"); ActionCallback cb = do_action; -- 2.47.3