codegen: Fix floating reference regression with Variants
[vala-gnome.git] / ccode / valaccodeelementaccess.vala
blob3586aec1f0120925c4198e36d4f07a5bc3c50ff7
1 /* valaccodememberaccess.vala
3 * Copyright (C) 2006 Raffaele Sandrini
4 * Copyright (C) 2006-2008 Jürg Billeter
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Author:
21 * Raffaele Sandrini <raffaele@sandrini.ch>
22 * Jürg Billeter <j@bitron.ch>
25 using GLib;
27 /**
28 * Represents an access to an array member in the C code.
30 public class Vala.CCodeElementAccess : CCodeExpression {
31 /**
32 * Expression representing the container on which we want to access.
34 public CCodeExpression container { get; set; }
36 /**
37 * Expression representing the index we want to access inside the
38 * container.
40 public CCodeExpression index { get; set; }
42 public CCodeElementAccess (CCodeExpression cont, CCodeExpression i) {
43 container = cont;
44 index = i;
47 public override void write (CCodeWriter writer) {
48 container.write_inner (writer);
49 writer.write_string ("[");
50 index.write (writer);
51 writer.write_string ("]");