1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
/* valaglibvalue.vala
*
* Copyright (C) 2010 Jürg Billeter
* Copyright (C) 2011 Luca Bruno
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
* Jürg Billeter <j@bitron.ch>
* Luca Bruno <lucabru@src.gnome.org>
*/
public class Vala.GLibValue : TargetValue {
public CCodeExpression cvalue;
public bool lvalue;
public bool non_null;
public string? ctype;
public List<CCodeExpression> array_length_cvalues;
public CCodeExpression? array_size_cvalue;
public bool array_null_terminated;
public CCodeExpression? array_length_cexpr;
public CCodeExpression? delegate_target_cvalue;
public CCodeExpression? delegate_target_destroy_notify_cvalue;
public GLibValue (DataType? value_type = null, CCodeExpression? cvalue = null, bool lvalue = false) {
base (value_type);
this.cvalue = cvalue;
this.lvalue = lvalue;
}
public void append_array_length_cvalue (CCodeExpression length_cvalue) {
if (array_length_cvalues == null) {
array_length_cvalues = new ArrayList<CCodeExpression> ();
}
array_length_cvalues.add (length_cvalue);
}
public GLibValue copy () {
var result = new GLibValue (value_type.copy (), cvalue, lvalue);
result.actual_value_type = actual_value_type;
result.non_null = non_null;
result.ctype = ctype;
if (array_length_cvalues != null) {
foreach (var cexpr in array_length_cvalues) {
result.append_array_length_cvalue (cexpr);
}
}
result.array_size_cvalue = array_size_cvalue;
result.array_null_terminated = array_null_terminated;
result.array_length_cexpr = array_length_cexpr;
result.delegate_target_cvalue = delegate_target_cvalue;
result.delegate_target_destroy_notify_cvalue = delegate_target_destroy_notify_cvalue;
return result;
}
}
namespace Vala {
public static unowned CCodeExpression? get_cvalue (Expression expr) {
if (expr.target_value == null) {
return null;
}
return ((GLibValue) expr.target_value).cvalue;
}
public static unowned CCodeExpression? get_cvalue_ (TargetValue value) {
return ((GLibValue) value).cvalue;
}
public static void set_cvalue (Expression expr, CCodeExpression? cvalue) {
unowned GLibValue glib_value = (GLibValue) expr.target_value;
if (glib_value == null) {
expr.target_value = new GLibValue (expr.value_type);
glib_value = (GLibValue) expr.target_value;
}
glib_value.cvalue = cvalue;
}
public static unowned CCodeExpression? get_array_size_cvalue (TargetValue value) {
return ((GLibValue) value).array_size_cvalue;
}
public static void set_array_size_cvalue (TargetValue value, CCodeExpression? cvalue) {
((GLibValue) value).array_size_cvalue = cvalue;
}
public static unowned CCodeExpression? get_delegate_target (Expression expr) {
if (expr.target_value == null) {
return null;
}
return ((GLibValue) expr.target_value).delegate_target_cvalue;
}
public static void set_delegate_target (Expression expr, CCodeExpression? delegate_target) {
unowned GLibValue? glib_value = (GLibValue) expr.target_value;
if (glib_value == null) {
expr.target_value = new GLibValue (expr.value_type);
glib_value = (GLibValue) expr.target_value;
}
glib_value.delegate_target_cvalue = delegate_target;
}
public static unowned CCodeExpression? get_delegate_target_destroy_notify (Expression expr) {
unowned GLibValue? glib_value = (GLibValue) expr.target_value;
if (glib_value == null) {
return null;
}
return glib_value.delegate_target_destroy_notify_cvalue;
}
public static void set_delegate_target_destroy_notify (Expression expr, CCodeExpression? destroy_notify) {
unowned GLibValue? glib_value = (GLibValue) expr.target_value;
if (glib_value == null) {
expr.target_value = new GLibValue (expr.value_type);
glib_value = (GLibValue) expr.target_value;
}
glib_value.delegate_target_destroy_notify_cvalue = destroy_notify;
}
public static void append_array_length (Expression expr, CCodeExpression size) {
unowned GLibValue? glib_value = (GLibValue) expr.target_value;
if (glib_value == null) {
expr.target_value = new GLibValue (expr.value_type);
glib_value = (GLibValue) expr.target_value;
}
glib_value.append_array_length_cvalue (size);
}
public static void set_array_length (Expression expr, CCodeExpression size) {
unowned GLibValue? glib_value = (GLibValue) expr.target_value;
if (glib_value == null) {
expr.target_value = new GLibValue (expr.value_type);
glib_value = (GLibValue) expr.target_value;
} else {
glib_value.array_length_cvalues = null;
}
glib_value.append_array_length_cvalue (size);
}
public static unowned List<CCodeExpression>? get_array_lengths (Expression expr) {
unowned GLibValue? glib_value = (GLibValue) expr.target_value;
if (glib_value == null) {
return null;
}
return glib_value.array_length_cvalues;
}
public static bool get_lvalue (TargetValue value) {
return ((GLibValue) value).lvalue;
}
public static bool get_non_null (TargetValue value) {
return ((GLibValue) value).non_null;
}
public static unowned string? get_ctype (TargetValue value) {
return ((GLibValue) value).ctype;
}
public static bool get_array_null_terminated (TargetValue value) {
return ((GLibValue) value).array_null_terminated;
}
public static unowned CCodeExpression? get_array_length_cexpr (TargetValue value) {
return ((GLibValue) value).array_length_cexpr;
}
}
|