Commit ade628e4 authored by Mathias Hasselmann's avatar Mathias Hasselmann Committed by Mathias Hasselmann
Browse files

consider sentinel information provide sentinel information for functions

2007-08-16  Mathias Hasselmann  <mathias.hasselmann@gmx.de>

	* gobject/valacodegeneratorinvocationexpression.vala,
	vala/valainterfacewriter.vala, vala/valamethod.vala,
	vapigen/valagidlparser.vala: consider sentinel information
	* vapi/packages/gtk+-2.0/gtk+-2.0.metadata: provide sentinel
	information for functions with variable length argument lists

svn path=/trunk/; revision=474
parent 0f4e8af3
2007-08-16 Mathias Hasselmann <mathias.hasselmann@gmx.de>
* gobject/valacodegeneratorinvocationexpression.vala,
vala/valainterfacewriter.vala, vala/valamethod.vala,
vapigen/valagidlparser.vala: consider sentinel information
* vapi/packages/gtk+-2.0/gtk+-2.0.metadata: provide sentinel
information for functions with variable length argument lists
2007-08-16 Mathias Hasselmann <mathias.hasselmann@gmx.de>
* vapi/packages/gtk+-2.0/gtk+-2.0.metadata: properly inform vapigen
......
......@@ -322,7 +322,7 @@ public class Vala.CodeGenerator {
/* ensure variable argument list ends with NULL
* except when using printf-style arguments */
if ((m == null || !m.printf_format) && !(m is DBusMethod)) {
ccall.add_argument (new CCodeConstant ("NULL"));
ccall.add_argument (new CCodeConstant (m.sentinel));
}
}
......
......@@ -460,9 +460,22 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_indent ();
write_string ("[InstanceByReference]");
}
var ccode_params = new String ();
var separator = "";
if (m.get_cname () != m.get_default_cname ()) {
ccode_params.append_printf ("%scname = \"%s\"", separator, m.get_cname ());
separator = ", ";
}
if (m.sentinel != m.DEFAULT_SENTINEL) {
ccode_params.append_printf ("%ssentinel = \"%s\"", separator, m.sentinel);
separator = ", ";
}
if (ccode_params.len > 0) {
write_indent ();
write_string ("[CCode (cname = \"%s\")]".printf (m.get_cname ()));
write_string ("[CCode (%s)]".printf (ccode_params.str));
}
write_indent ();
......
......@@ -28,6 +28,8 @@ using Gee;
* Represents a type or namespace method.
*/
public class Vala.Method : Member, Invokable {
public const string DEFAULT_SENTINEL = "NULL";
/**
* The return type of this method.
*/
......@@ -71,6 +73,22 @@ public class Vala.Method : Member, Invokable {
}
}
/**
* The sentinel to use for terminating variable length argument lists.
*/
public string! sentinel {
get {
if (_sentinel == null) {
return DEFAULT_SENTINEL;
}
return _sentinel;
}
set {
_sentinel = value;
}
}
/**
* Specifies whether this method is abstract. Abstract methods have no
......@@ -152,6 +170,7 @@ public class Vala.Method : Member, Invokable {
private Gee.List<FormalParameter> parameters = new ArrayList<FormalParameter> ();
private string cname;
private string _vfunc_name;
private string _sentinel;
private bool _no_array_length;
private Gee.List<TypeReference> error_domains = new ArrayList<TypeReference> ();
......@@ -278,6 +297,9 @@ public class Vala.Method : Member, Invokable {
if (a.has_argument ("vfunc_name")) {
this.vfunc_name = a.get_string ("vfunc_name");
}
if (a.has_argument ("sentinel")) {
this.sentinel = a.get_string ("sentinel");
}
}
/**
......
......@@ -20,6 +20,7 @@ GtkContainer::add has_emitter="1"
GtkContainer::check_resize has_emitter="1"
GtkContainer::remove has_emitter="1"
GtkContainer::set_focus_child has_emitter="1"
gtk_dialog_set_alternative_button_order sentinel="-1"
GtkDialog::response has_emitter="1"
GtkEditable::delete_text has_emitter="1"
GtkEditable::insert_text has_emitter="1"
......@@ -32,8 +33,8 @@ GtkItem::deselect has_emitter="1"
GtkItem::select has_emitter="1"
GtkItem::toggle has_emitter="1"
gtk_list_store_new ellipsis="1"
gtk_list_store_insert_with_values ellipsis="1"
gtk_list_store_set ellipsis="1"
gtk_list_store_insert_with_values ellipsis="1" sentinel="-1"
gtk_list_store_set ellipsis="1" sentinel="-1"
GtkMenuItem::activate has_emitter="1"
GtkMenuItem::toggle_size_allocate has_emitter="1"
GtkMenuItem::toggle_size_request has_emitter="1"
......@@ -61,7 +62,7 @@ GtkToggleActionEntry is_value_type="1"
GtkToggleButton::toggled has_emitter="1"
GtkToolItem::set_tooltip has_emitter="1"
GtkTreeIter is_value_type="1"
gtk_tree_model_get ellipsis="1"
gtk_tree_model_get ellipsis="1" sentinel="-1"
gtk_tree_model_get_path transfer_ownership="1"
gtk_tree_model_get_string_from_iter transfer_ownership="1"
GtkTreeModel::row_changed has_emitter="1"
......@@ -69,10 +70,11 @@ GtkTreeModel::row_deleted has_emitter="1"
GtkTreeModel::row_has_child_toggled has_emitter="1"
GtkTreeModel::row_inserted has_emitter="1"
GtkTreeModel::rows_reordered has_emitter="1"
gtk_tree_path_new_from_indices sentinel="-1"
GtkTreePath is_value_type="0"
gtk_tree_store_new ellipsis="1"
gtk_tree_store_insert_with_values ellipsis="1"
gtk_tree_store_set ellipsis="1"
gtk_tree_store_insert_with_values ellipsis="1" sentinel="-1"
gtk_tree_store_set ellipsis="1" sentinel="-1"
GtkTreeSortable::sort_column_changed has_emitter="1"
gtk_tree_view_insert_column_with_attributes ellipsis="1"
GtkTreeView::row_activated has_emitter="1"
......
......@@ -799,6 +799,8 @@ public class Vala.GIdlParser : CodeVisitor {
if (eval (nv[1]) == "1") {
return_type.transfers_ownership = true;
}
} else if (nv[0] == "sentinel") {
m.sentinel = eval (nv[1]);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment