vala r1130 - in trunk: . gobject tests



Author: juergbi
Date: Sun Mar 16 21:27:24 2008
New Revision: 1130
URL: http://svn.gnome.org/viewvc/vala?rev=1130&view=rev

Log:
2008-03-16  Juerg Billeter  <j bitron ch>

	* gobject/valaccodegenerator.vala,
	  gobject/valaccodegeneratorsourcefile.vala: emit constants after
	  function declarations as constants may depend on function
	  declarations, fixes bug 501584

	* tests/delegates.vala: test constants depending on function
	  declarations


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodegenerator.vala
   trunk/gobject/valaccodegeneratorsourcefile.vala
   trunk/tests/delegates.vala

Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala	(original)
+++ trunk/gobject/valaccodegenerator.vala	Sun Mar 16 21:27:24 2008
@@ -43,9 +43,11 @@
 	CCodeFragment header_type_declaration;
 	CCodeFragment header_type_definition;
 	CCodeFragment header_type_member_declaration;
+	CCodeFragment header_constant_declaration;
 	CCodeFragment source_begin;
 	CCodeFragment source_include_directives;
 	public CCodeFragment source_type_member_declaration;
+	CCodeFragment source_constant_declaration;
 	CCodeFragment source_signal_marshaller_declaration;
 	public CCodeFragment source_type_member_definition;
 	CCodeFragment class_init_fragment;
@@ -392,9 +394,9 @@
 			cdecl.modifiers = CCodeModifiers.STATIC;
 		
 			if (!c.is_internal_symbol ()) {
-				header_type_member_declaration.append (cdecl);
+				header_constant_declaration.append (cdecl);
 			} else {
-				source_type_member_declaration.append (cdecl);
+				source_constant_declaration.append (cdecl);
 			}
 		}
 	}

Modified: trunk/gobject/valaccodegeneratorsourcefile.vala
==============================================================================
--- trunk/gobject/valaccodegeneratorsourcefile.vala	(original)
+++ trunk/gobject/valaccodegeneratorsourcefile.vala	Sun Mar 16 21:27:24 2008
@@ -177,9 +177,11 @@
 		header_type_declaration = new CCodeFragment ();
 		header_type_definition = new CCodeFragment ();
 		header_type_member_declaration = new CCodeFragment ();
+		header_constant_declaration = new CCodeFragment ();
 		source_begin = new CCodeFragment ();
 		source_include_directives = new CCodeFragment ();
 		source_type_member_declaration = new CCodeFragment ();
+		source_constant_declaration = new CCodeFragment ();
 		source_type_member_definition = new CCodeFragment ();
 		source_signal_marshaller_definition = new CCodeFragment ();
 		source_signal_marshaller_declaration = new CCodeFragment ();
@@ -305,6 +307,8 @@
 		once.append (new CCodeNewline ());
 		once.append (header_type_member_declaration);
 		once.append (new CCodeNewline ());
+		once.append (header_constant_declaration);
+		once.append (new CCodeNewline ());
 		once.append (new CCodeIdentifier ("G_END_DECLS"));
 		once.append (new CCodeNewline ());
 		once.append (new CCodeNewline ());
@@ -321,8 +325,11 @@
 		source_include_directives.write (writer);
 		writer.write_newline ();
 		source_type_member_declaration.write_declaration (writer);
+		writer.write_newline ();
 		source_type_member_declaration.write (writer);
 		writer.write_newline ();
+		source_constant_declaration.write (writer);
+		writer.write_newline ();
 		source_signal_marshaller_declaration.write_declaration (writer);
 		source_signal_marshaller_declaration.write (writer);
 		writer.write_newline ();
@@ -336,9 +343,11 @@
 		header_type_declaration = null;
 		header_type_definition = null;
 		header_type_member_declaration = null;
+		header_constant_declaration = null;
 		source_begin = null;
 		source_include_directives = null;
 		source_type_member_declaration = null;
+		source_constant_declaration = null;
 		source_type_member_definition = null;
 		source_signal_marshaller_definition = null;
 		source_signal_marshaller_declaration = null;

Modified: trunk/tests/delegates.vala
==============================================================================
--- trunk/tests/delegates.vala	(original)
+++ trunk/tests/delegates.vala	Sun Mar 16 21:27:24 2008
@@ -6,11 +6,17 @@
 
 public delegate void Maman.InstanceCallback (int i);
 
+struct Maman.DelegateStruct {
+	public VoidCallback callback;
+}
+
 interface Maman.Foo : Object {
 	public abstract void foo_method (int i);
 }
 
 class Maman.Bar : Object, Foo {
+	const DelegateStruct const_delegate_struct = { do_void_action };
+
 	public Bar () {
 	}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]