vala r1482 - in trunk: . gobject



Author: juergbi
Date: Thu May 29 10:52:34 2008
New Revision: 1482
URL: http://svn.gnome.org/viewvc/vala?rev=1482&view=rev

Log:
2008-05-29  Juerg Billeter  <j bitron ch>

	* gobject/valaccodeclassbinding.vala:
	* gobject/valaccodegenerator.vala:
	* gobject/valaccodemethodbinding.vala:
	* gobject/valaclassregisterfunction.vala:

	Simplify generated _new functions for non-GObject classes


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodeclassbinding.vala
   trunk/gobject/valaccodegenerator.vala
   trunk/gobject/valaccodemethodbinding.vala
   trunk/gobject/valaclassregisterfunction.vala

Modified: trunk/gobject/valaccodeclassbinding.vala
==============================================================================
--- trunk/gobject/valaccodeclassbinding.vala	(original)
+++ trunk/gobject/valaccodeclassbinding.vala	Thu May 29 10:52:34 2008
@@ -511,7 +511,7 @@
 	}
 	
 	private void add_instance_init_function (Class cl) {
-		var instance_init = new CCodeFunction ("%s_init".printf (cl.get_lower_case_cname (null)), "void");
+		var instance_init = new CCodeFunction ("%s_instance_init".printf (cl.get_lower_case_cname (null)), "void");
 		instance_init.add_parameter (new CCodeFormalParameter ("self", "%s *".printf (cl.get_cname ())));
 		instance_init.modifiers = CCodeModifiers.STATIC;
 		
@@ -525,13 +525,7 @@
 		}
 		
 		init_block.add_statement (codegen.instance_init_fragment);
-		
-		var init_sym = cl.scope.lookup ("init");
-		if (init_sym != null) {
-			var init_fun = (Method) init_sym;
-			init_block.add_statement (init_fun.body.ccodenode);
-		}
-		
+
 		codegen.source_type_member_definition.append (instance_init);
 	}
 	

Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala	(original)
+++ trunk/gobject/valaccodegenerator.vala	Thu May 29 10:52:34 2008
@@ -2908,11 +2908,6 @@
 
 			if (expr.type_reference.data_type is Struct && !(m.cinstance_parameter_position < 0)) {
 				creation_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance));
-			} else if (expr.type_reference.data_type is Class) {
-				var cl = (Class) expr.type_reference.data_type;
-				if (!cl.is_compact && cl.base_class == null) {
-					creation_call.add_argument (new CCodeIdentifier (cl.get_type_id ()));
-				}
 			}
 
 			if (expr.type_reference.data_type is Class && expr.type_reference.data_type.is_subtype_of (gobject_type)) {

Modified: trunk/gobject/valaccodemethodbinding.vala
==============================================================================
--- trunk/gobject/valaccodemethodbinding.vala	(original)
+++ trunk/gobject/valaccodemethodbinding.vala	Thu May 29 10:52:34 2008
@@ -179,10 +179,6 @@
 			cparam_map.set (codegen.get_param_pos (m.cinstance_parameter_position), class_param);
 		}
 
-		if (in_fundamental_creation_method) {
-			cparam_map.set (codegen.get_param_pos (0.1), new CCodeFormalParameter ("type", "GType"));
-		}
-
 		if (in_gobject_creation_method) {
 			// memory management for generic types
 			int type_param_index = 0;
@@ -317,20 +313,12 @@
 							param_name = new CCodeIdentifier ("%s_destroy_func".printf (type_param.name.down ()));
 							cinit.append (new CCodeExpressionStatement (get_construct_property_assignment (prop_name, new PointerType (new VoidType ()), param_name)));
 						}
-					} else if (in_fundamental_creation_method) {
-						var cl = (Class) m.parent_symbol;
-						var cdecl = new CCodeDeclaration (cl.get_cname () + "*");
-						var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_create_instance"));
-						ccall.add_argument (new CCodeIdentifier ("type"));
-						cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("self", new CCodeCastExpression (ccall, cl.get_cname () + "*")));
-						cinit.append (cdecl);
 					} else if (in_gtypeinstance_creation_method) {
 						var cl = (Class) m.parent_symbol;
 						var cdecl = new CCodeDeclaration (cl.get_cname () + "*");
-						var fundamental_class = find_fundamental_class (cl);
-						var ccall = new CCodeFunctionCall (new CCodeIdentifier (fundamental_class.default_construction_method.get_cname ()));
+						var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_type_create_instance"));
 						ccall.add_argument (new CCodeIdentifier (cl.get_type_id ()));
-						cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("self", ccall));
+						cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("self", new CCodeCastExpression (ccall, cl.get_cname () + "*")));
 						cinit.append (cdecl);
 					} else if (codegen.current_type_symbol is Class) {
 						var cl = (Class) m.parent_symbol;

Modified: trunk/gobject/valaclassregisterfunction.vala
==============================================================================
--- trunk/gobject/valaclassregisterfunction.vala	(original)
+++ trunk/gobject/valaclassregisterfunction.vala	Thu May 29 10:52:34 2008
@@ -66,7 +66,7 @@
 	}
 	
 	public override string get_instance_init_func_name () {
-		return "%s_init".printf (class_reference.get_lower_case_cname (null));
+		return "%s_instance_init".printf (class_reference.get_lower_case_cname (null));
 	}
 	
 	public override string get_parent_type_name () {



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