vala r1043 - in trunk: . gobject
- From: rasa svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1043 - in trunk: . gobject
- Date: Sun, 24 Feb 2008 09:52:39 +0000 (GMT)
Author: rasa
Date: Sun Feb 24 09:52:39 2008
New Revision: 1043
URL: http://svn.gnome.org/viewvc/vala?rev=1043&view=rev
Log:
2008-02-24 Raffaele Sandrini <raffaele sandrini ch>
* gobject/valaccodegenerator.vala: fix array lengths with static
fields, fixes bug 515211
Modified:
trunk/ChangeLog
trunk/gobject/valaccodegenerator.vala
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Sun Feb 24 09:52:39 2008
@@ -504,6 +504,25 @@
instance_dispose_fragment.append (new CCodeExpressionStatement (get_unref_expression (lhs, f.type_reference, ma)));
}
} else {
+ /* add array length fields where necessary */
+ if (f.type_reference is ArrayType && !f.no_array_length) {
+ var array_type = (ArrayType) f.type_reference;
+
+ for (int dim = 1; dim <= array_type.rank; dim++) {
+ var len_type = int_type.copy ();
+
+ var cdecl = new CCodeDeclaration (len_type.get_cname ());
+ cdecl.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (f.get_cname (), dim)));
+ if (f.access != SymbolAccessibility.PRIVATE) {
+ cdecl.modifiers = CCodeModifiers.EXTERN;
+ header_type_member_declaration.append (cdecl);
+ } else {
+ cdecl.modifiers = CCodeModifiers.STATIC;
+ source_type_member_declaration.append (cdecl);
+ }
+ }
+ }
+
if (f.initializer != null) {
var rhs = (CCodeExpression) f.initializer.ccodenode;
if (!is_constant_ccode_expression (rhs)) {
@@ -2283,8 +2302,6 @@
} else if (array_expr.symbol_reference is Field) {
var field = (Field) array_expr.symbol_reference;
if (!field.no_array_length) {
- var length_cname = get_array_length_cname (field.name, dim);
-
var ma = (MemberAccess) array_expr;
CCodeExpression pub_inst = null;
@@ -2307,6 +2324,7 @@
}
if (field.instance) {
+ var length_cname = get_array_length_cname (field.name, dim);
var instance_expression_type = new DataType ();
instance_expression_type.data_type = base_type;
var instance_target_type = new DataType ();
@@ -2325,7 +2343,7 @@
length_expr = new CCodeMemberAccess (inst, length_cname);
}
} else {
- length_expr = new CCodeIdentifier (length_cname);
+ length_expr = new CCodeIdentifier (get_array_length_cname (field.get_cname (), dim));
}
if (is_out) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]