+2009-02-17 Ryan Lortie <desrt@desrt.ca>
+
+ * gobject/valaccodebasemodule.vala:
+ * vala/valacodewriter.vala:
+ * vala/valastruct.vala:
+ * vapigen/valagidlparser.vala:
+
+ Add support for a 'use_const' CCode attribute and GIDL XML attribute
+ that, when set to false, causes Vala not to emit the 'const' modifier
+ on structure type input arguments. This is useful for structure types
+ that, by convention, are not used with const (eg: GtkTreeIter).
+
+ * vapi/packages/gtk+-2.0/gtk+-2.0.metadata:
+ * vapi/gtk+-2.0.vapi:
+
+ Add 'use_const' for GtkTreeIter to the gtk+-2.0 metadata. Regenerate
+ vapi.
+
2009-02-16 Ryan Lortie <desrt@desrt.ca>
* vala/valaclass.vala: only use g_value_set_pointer if the GType of a
if (p.parameter_type.data_type is Struct) {
var st = (Struct) p.parameter_type.data_type;
if (!st.is_simple_type () && p.direction == ParameterDirection.IN) {
- ctypename = "const " + ctypename;
+ if (st.use_const) {
+ ctypename = "const " + ctypename;
+ }
+
if (!p.parameter_type.nullable) {
ctypename += "*";
}
return node.ccodenode;
}
}
+
+// vim:sw=8 noet
write_string ("type_id = \"%s\", ".printf (st.get_type_id ()));
}
+ if (!st.use_const) {
+ write_string ("use_const = false, ");
+ }
+
bool first = true;
string cheaders = "";
foreach (string cheader in st.get_cheader_filenames ()) {
*/
public Method default_construction_method { get; set; }
+ /**
+ * Specifies if 'const' should be emitted for input parameters
+ * of this type.
+ */
+ public bool use_const { get; set; default = true; }
+
/**
* Specifies whether this struct has a registered GType.
*/
if (a.has_argument ("destroy_function")) {
set_destroy_function (a.get_string ("destroy_function"));
}
+ if (a.has_argument ("use_const")) {
+ use_const = a.get_bool ("use_const");
+ }
}
private void process_boolean_type_attribute (Attribute a) {
return !error;
}
}
+
+// vim:sw=8 noet
public weak Gtk.ActionCallback callback;
public bool is_active;
}
- [CCode (type_id = "GTK_TYPE_TREE_ITER", cheader_filename = "gtk/gtk.h")]
+ [CCode (type_id = "GTK_TYPE_TREE_ITER", use_const = false, cheader_filename = "gtk/gtk.h")]
public struct TreeIter {
public int stamp;
public void* user_data;
GtkToolbar.gpointer hidden="1"
gtk_tool_item_toolbar_reconfigured hidden="1"
GtkToolItem::set_tooltip hidden="1"
-GtkTreeIter is_value_type="1"
+GtkTreeIter is_value_type="1" use_const="0"
gtk_tree_model_filter_new.root nullable="1"
gtk_tree_model_get ellipsis="1" sentinel="-1"
gtk_tree_model_get_iter.iter is_out="1"
if (eval (nv[1]) == "1") {
st.set_simple_type (true);
}
+ } else if (nv[0] == "use_const") {
+ if (eval (nv[1]) == "0") {
+ st.use_const = false;
+ }
}
}
}
var nv = attr.split ("=", 2);
if (nv[0] == "cheader_filename") {
st.add_cheader_filename (eval (nv[1]));
+ } else if (nv[0] == "use_const") {
+ if (eval (nv[1]) == "0") {
+ st.use_const = false;
+ }
}
}
}
var m = parse_function ((IdlNodeFunction) member, true);
if (m != null) {
iface.add_method (m);
- }
+ }
}
} else if (member.type == IdlNodeTypeId.VFUNC) {
var m = parse_virtual ((IdlNodeVFunc) member, current_type_func_map.get (member.name), true);
return sig;
}
}
+
+// vim:sw=8 noet