vala r2136 - in trunk: . gobject
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2136 - in trunk: . gobject
- Date: Fri, 12 Dec 2008 10:00:12 +0000 (UTC)
Author: juergbi
Date: Fri Dec 12 10:00:12 2008
New Revision: 2136
URL: http://svn.gnome.org/viewvc/vala?rev=2136&view=rev
Log:
2008-12-12 JÃrg Billeter <j bitron ch>
* gobject/valadbusclientmodule.vala:
* gobject/valadbusmodule.vala:
Fix array length and size handling in static D-Bus clients
Modified:
trunk/ChangeLog
trunk/gobject/valadbusclientmodule.vala
trunk/gobject/valadbusmodule.vala
Modified: trunk/gobject/valadbusclientmodule.vala
==============================================================================
--- trunk/gobject/valadbusclientmodule.vala (original)
+++ trunk/gobject/valadbusclientmodule.vala Fri Dec 12 10:00:12 2008
@@ -1038,15 +1038,17 @@
cdecl.add_declarator (new CCodeVariableDeclarator ("_result"));
postfragment.append (cdecl);
- var target = new CCodeIdentifier ("_result");
- var expr = read_expression (postfragment, m.return_type, new CCodeIdentifier ("_iter"), target);
- postfragment.append (new CCodeExpressionStatement (new CCodeAssignment (target, expr)));
-
if (m.return_type is ArrayType) {
cdecl = new CCodeDeclaration ("int");
cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("_result_length1", new CCodeConstant ("0")));
postfragment.append (cdecl);
+ }
+ var target = new CCodeIdentifier ("_result");
+ var expr = read_expression (postfragment, m.return_type, new CCodeIdentifier ("_iter"), target);
+ postfragment.append (new CCodeExpressionStatement (new CCodeAssignment (target, expr)));
+
+ if (m.return_type is ArrayType) {
// TODO check that parameter is not NULL (out parameters are optional)
postfragment.append (new CCodeExpressionStatement (new CCodeAssignment (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("result_length1")), new CCodeIdentifier ("_result_length1"))));
}
Modified: trunk/gobject/valadbusmodule.vala
==============================================================================
--- trunk/gobject/valadbusmodule.vala (original)
+++ trunk/gobject/valadbusmodule.vala Fri Dec 12 10:00:12 2008
@@ -130,14 +130,18 @@
cfor.add_iterator (new CCodeUnaryExpression (CCodeUnaryOperator.POSTFIX_INCREMENT, new CCodeIdentifier (temp_name + "_length1")));
var size_check = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeIdentifier (temp_name + "_size"), new CCodeIdentifier (temp_name + "_length1"));
+ var renew_block = new CCodeBlock ();
+
+ // tmp_size = (tmp_size > 0) ? (2 * tmp_size) : 4;
var init_check = new CCodeBinaryExpression (CCodeBinaryOperator.GREATER_THAN, new CCodeIdentifier (temp_name + "_size"), new CCodeConstant ("0"));
var new_size = new CCodeConditionalExpression (init_check, new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeConstant ("2"), new CCodeIdentifier (temp_name + "_size")), new CCodeConstant ("4"));
+ renew_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier (temp_name + "_size"), new_size)));
+
var renew_call = new CCodeFunctionCall (new CCodeIdentifier ("g_renew"));
renew_call.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ()));
renew_call.add_argument (new CCodeIdentifier (temp_name));
- renew_call.add_argument (new_size);
+ renew_call.add_argument (new CCodeIdentifier (temp_name + "_size"));
var renew_stmt = new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier (temp_name), renew_call));
- var renew_block = new CCodeBlock ();
renew_block.add_statement (renew_stmt);
var cif = new CCodeIfStatement (size_check, renew_block);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]