2008-01-03 Jürg Billeter <j@bitron.ch>
+ * gobject/valaccodegenerator.vala,
+ gobject/valaccodegeneratormethod.vala,
+ ccode/valaccodeformalparameter.vala: add limited support for defining
+ methods with variable argument list
+
+2008-01-03 Jürg Billeter <j@bitron.ch>
+
* vapi/glib-2.0.vapi: remove close method from FileStream class as it's
also the implicitly called free function, fixes bug 506817
/* valaccodeformalparameter.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2008 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/**
* The parameter name.
*/
- public string! name { get; set construct; }
+ public string name { get; set; }
/**
* The parameter type.
*/
- public string! type_name { get; set construct; }
-
+ public string type_name { get; set; }
+
+ /**
+ * Specifies whether the function accepts an indefinite number of
+ * arguments.
+ */
+ public bool ellipsis { get; set; }
+
public CCodeFormalParameter (string! n, string! type) {
name = n;
type_name = type;
}
-
+
+ public CCodeFormalParameter.with_ellipsis () {
+ ellipsis = true;
+ }
+
public override void write (CCodeWriter! writer) {
- writer.write_string (type_name);
- writer.write_string (" ");
- writer.write_string (name);
+ if (!ellipsis) {
+ writer.write_string (type_name);
+ writer.write_string (" ");
+ writer.write_string (name);
+ } else {
+ writer.write_string ("...");
+ }
}
}
/* valaccodegenerator.vala
*
- * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
+ * Copyright (C) 2006-2008 Jürg Billeter, Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
}
p.ccodenode = new CCodeFormalParameter (cname, ctypename);
+ } else {
+ p.ccodenode = new CCodeFormalParameter.with_ellipsis ();
}
}
/* valaccodegeneratormethod.vala
*
- * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
+ * Copyright (C) 2006-2008 Jürg Billeter, Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
var params = m.get_parameters ();
foreach (FormalParameter param in params) {
- if (!param.no_array_length && param.type_reference.data_type is Array) {
+ if (!param.no_array_length && param.type_reference != null && param.type_reference.data_type is Array) {
var arr = (Array) param.type_reference.data_type;
var length_ctype = "int";
}
}
foreach (FormalParameter param in m.get_parameters ()) {
+ if (param.ellipsis) {
+ break;
+ }
+
var t = param.type_reference.data_type;
if (t != null && t.is_reference_type () && !param.type_reference.is_out) {
var type_check = create_method_type_check_statement (m, creturn_type, t, param.type_reference.non_null, param.name);