+2009-01-04 Jürg Billeter <j@bitron.ch>
+
+ * vala/valacodewriter.vala:
+ * vala/valadelegate.vala:
+ * vala/valafield.vala:
+ * vala/valaformalparameter.vala:
+ * vala/valamethod.vala:
+
+ Replace [NoArrayLength] by [CCode (array_length = false)], which
+ can also be applied to single parameters, fixes bug 532486
+
+ * gobject/valaccodecompiler.vala:
+ * compiler/valacompiler.vala:
+ * vapi/glib-2.0.vapi:
+ * vapigen/valagidlparser.vala:
+ * vapigen/valavapigen.vala:
+
+ Adapt to attribute changes
+
2009-01-04 Jürg Billeter <j@bitron.ch>
* vala/valabinaryexpression.vala:
/* valacompiler.vala
*
- * Copyright (C) 2006-2008 Jürg Billeter
+ * Copyright (C) 2006-2009 Jürg Billeter
* Copyright (C) 1996-2002, 2004, 2005, 2006 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
static string basedir;
static string directory;
static bool version;
- [NoArrayLength ()]
+ [CCode (array_length = false)]
+ [NoArrayLength]
static string[] sources;
- [NoArrayLength ()]
+ [CCode (array_length = false)]
+ [NoArrayLength]
static string[] vapi_directories;
static string library;
- [NoArrayLength ()]
+ [CCode (array_length = false)]
+ [NoArrayLength]
static string[] packages;
static string target_glib;
static bool non_null_experimental;
static bool disable_dbus_transformation;
static string cc_command;
+ [CCode (array_length = false)]
[NoArrayLength]
static string[] cc_options;
static string dump_tree;
/* valaccodecompiler.vala
*
- * Copyright (C) 2007-2008 Jürg Billeter
+ * Copyright (C) 2007-2009 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
* @param context a code context
*/
[NoArrayLength]
- public void compile (CodeContext context, string? cc_command, string[] cc_options) {
+ public void compile (CodeContext context, string? cc_command, [CCode (array_length = false)] string[] cc_options) {
string pc = "pkg-config --cflags";
if (!context.compile_only) {
pc += " --libs";
bool custom_cname = (f.get_cname () != f.get_default_cname ());
bool custom_ctype = (f.get_ctype () != null);
bool custom_cheaders = (f.parent_symbol is Namespace);
- if (custom_cname || custom_ctype || custom_cheaders) {
+ if (custom_cname || custom_ctype || custom_cheaders || (f.no_array_length && f.field_type is ArrayType)) {
write_indent ();
write_string ("[CCode (");
write_string ("cheader_filename = \"%s\"".printf (cheaders));
}
- write_string (")]");
- }
+ if (f.no_array_length && f.field_type is ArrayType) {
+ if (custom_cname || custom_ctype || custom_cheaders) {
+ write_string (", ");
+ }
- if (f.no_array_length && f.field_type is ArrayType) {
- write_indent ();
- write_string ("[NoArrayLength]");
+ write_string ("array_length = false");
+ }
+
+ write_string (")]");
}
write_indent ();
ccode_params.append_printf ("%stype = \"%s\"", separator, param.ctype);
separator = ", ";
}
+ if (param.no_array_length && param.parameter_type is ArrayType) {
+ ccode_params.append_printf ("%sarray_length = false", separator);
+ separator = ", ";
+ }
if (!float_equal (param.carray_length_parameter_position, i + 0.1)) {
ccode_params.append_printf ("%sarray_length_pos = %g", separator, param.carray_length_parameter_position);
separator = ", ";
write_indent ();
write_string ("[ReturnsModifiedPointer]");
}
- if (m.no_array_length) {
- bool array_found = (m.return_type is ArrayType);
- foreach (FormalParameter param in m.get_parameters ()) {
- if (param.parameter_type is ArrayType) {
- array_found = true;
- break;
- }
- }
- if (array_found) {
- write_indent ();
- write_string ("[NoArrayLength]");
- }
- }
var ccode_params = new StringBuilder ();
var separator = "";
ccode_params.append_printf ("%sinstance_pos = %g", separator, m.cinstance_parameter_position);
separator = ", ";
}
+ if (m.no_array_length && m.return_type is ArrayType) {
+ ccode_params.append_printf ("%sarray_length = false", separator);
+ separator = ", ";
+ }
if (!float_equal (m.carray_length_parameter_position, -3)) {
ccode_params.append_printf ("%sarray_length_pos = %g", separator, m.carray_length_parameter_position);
separator = ", ";
/* valadelegate.vala
*
- * Copyright (C) 2006-2008 Jürg Billeter
+ * Copyright (C) 2006-2009 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
public double cdelegate_target_parameter_position { get; set; }
/**
- * Specifies whether the array length should implicitly be passed
- * if the parameter type is an array.
+ * Specifies whether the array length should be returned implicitly
+ * if the return type is an array.
*/
- public bool no_array_length {
- get {
- return _no_array_length;
- }
- set {
- _no_array_length = value;
- foreach (FormalParameter param in parameters) {
- param.no_array_length = value;
- }
- }
- }
+ public bool no_array_length { get; set; }
private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
private string cname;
private DataType _return_type;
- private bool _no_array_length;
/**
* Creates a new delegate.
* @param param a formal parameter
*/
public void add_parameter (FormalParameter param) {
- if (no_array_length) {
- param.no_array_length = true;
- }
// default C parameter position
param.cparameter_position = parameters.size + 1;
param.carray_length_parameter_position = param.cparameter_position + 0.1;
if (a.has_argument ("instance_pos")) {
cinstance_parameter_position = a.get_double ("instance_pos");
}
+ if (a.has_argument ("array_length")) {
+ no_array_length = !a.get_bool ("array_length");
+ }
if (a.has_argument ("array_length_pos")) {
carray_length_parameter_position = a.get_double ("array_length_pos");
}
foreach (Attribute a in attributes) {
if (a.name == "CCode") {
process_ccode_attribute (a);
- } else if (a.name == "NoArrayLength") {
- no_array_length = true;
}
}
}
add_cheader_filename (filename);
}
}
+ if (a.has_argument ("array_length")) {
+ no_array_length = !a.get_bool ("array_length");
+ }
if (a.has_argument ("array_length_cname")) {
set_array_length_cname (a.get_string ("array_length_cname"));
}
foreach (Attribute a in attributes) {
if (a.name == "CCode") {
process_ccode_attribute (a);
- } else if (a.name == "NoArrayLength") {
- no_array_length = true;
}
}
}
/* valaformalparameter.vala
*
- * Copyright (C) 2006-2008 Jürg Billeter, Raffaele Sandrini
+ * Copyright (C) 2006-2009 Jürg Billeter
+ * Copyright (C) 2006-2008 Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
public Expression default_expression { get; set; }
/**
- * Specifies whether the array length should implicitly be passed
+ * Specifies whether the array length should be passed implicitly
* if the parameter type is an array.
*/
public bool no_array_length { get; set; }
if (a.has_argument ("type")) {
ctype = a.get_string ("type");
}
+ if (a.has_argument ("array_length")) {
+ no_array_length = !a.get_bool ("array_length");
+ }
if (a.has_argument ("array_length_pos")) {
carray_length_parameter_position = a.get_double ("array_length_pos");
}
/* valamethod.vala
*
- * Copyright (C) 2006-2008 Jürg Billeter, Raffaele Sandrini
+ * Copyright (C) 2006-2009 Jürg Billeter
+ * Copyright (C) 2006-2008 Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
public double cdelegate_target_parameter_position { get; set; }
/**
- * Specifies whether the array length should implicitly be passed
- * if the parameter type is an array.
+ * Specifies whether the array length should be returned implicitly
+ * if the return type is an array.
*/
- public bool no_array_length {
- get {
- return _no_array_length;
- }
- set {
- _no_array_length = value;
- foreach (FormalParameter param in parameters) {
- param.no_array_length = value;
- }
- }
- }
+ public bool no_array_length { get; set; }
/**
* Specifies whether this method expects printf-style format arguments.
private string cname;
private string _vfunc_name;
private string _sentinel;
- private bool _no_array_length;
private Gee.List<Expression> preconditions = new ArrayList<Expression> ();
private Gee.List<Expression> postconditions = new ArrayList<Expression> ();
private DataType _return_type;
* @param param a formal parameter
*/
public void add_parameter (FormalParameter param) {
- if (no_array_length) {
- param.no_array_length = true;
- }
// default C parameter position
param.cparameter_position = parameters.size + 1;
param.carray_length_parameter_position = param.cparameter_position + 0.1;
if (a.has_argument ("instance_pos")) {
cinstance_parameter_position = a.get_double ("instance_pos");
}
+ if (a.has_argument ("array_length")) {
+ no_array_length = !a.get_bool ("array_length");
+ }
if (a.has_argument ("array_length_pos")) {
carray_length_parameter_position = a.get_double ("array_length_pos");
}
returns_modified_pointer = true;
} else if (a.name == "FloatingReference") {
return_type.floating_reference = true;
- } else if (a.name == "NoArrayLength") {
- no_array_length = true;
} else if (a.name == "PrintfFormat") {
printf_format = true;
}
public string escape (string exceptions);
[CCode (cname = "g_strcompress")]
public string compress ();
- [CCode (cname = "g_strsplit")]
+ [CCode (cname = "g_strsplit", array_length = false)]
[NoArrayLength]
public string[] split (string delimiter, int max_tokens = 0);
- [CCode (cname = "g_strsplit_set")]
- [NoArrayLength]
+ [CCode (cname = "g_strsplit_set", array_length = false)]
public string[] split_set (string delimiters, int max_tokens = 0);
[CCode (cname = "g_strjoinv")]
[NoArrayLength]
- public static string joinv (string separator, string[] str_array);
+ public static string joinv (string separator, [CCode (array_length = false)] string[] str_array);
[CCode (cname = "g_strjoin")]
public static string join (string separator, ...);
[CCode (cname = "g_strnfill")]
public bool wait (Cond cond, Mutex mutex);
public bool prepare (out int priority);
public int query (int max_priority, out int timeout_, PollFD[] fds);
- [NoArrayLength]
+ [CCode (array_length = false)]
public int check (int max_priority, PollFD[] fds, int n_fds);
public void dispatch ();
public void set_poll_func (PollFunc func);
/* String Utility Functions */
- [NoArrayLength]
- public uint strv_length (string[] str_array);
+ public uint strv_length ([CCode (array_length = false)] string[] str_array);
[CCode (cname = "errno", cheader_filename = "errno.h")]
public int errno;
public static size_t encode_close (bool break_lines, char* _out, ref int state, ref int save);
public static string encode (uchar[] data);
public static size_t decode_step (char[] _in, uchar* _out, ref int state, ref uint save);
- [NoArrayLength]
+ [CCode (array_length = false)]
public static uchar[] decode (string text, out size_t out_len);
}
public class Checksum {
public Checksum (ChecksumType checksum_type);
public Checksum copy ();
- [NoArrayLength]
- public void update (uchar[] data, size_t length);
+ public void update ([CCode (array_length = false)] uchar[] data, size_t length);
public weak string get_string ();
- [NoArrayLength]
- public void get_digest (uint8[] buffer, ref size_t digest_len);
+ public void get_digest ([CCode (array_length = false)] uint8[] buffer, ref size_t digest_len);
[CCode (cname = "g_compute_checksum_for_data")]
public static string compute_for_data (ChecksumType checksum_type, uchar[] data);
[CCode (cname = "g_compute_checksum_for_string")]
[CCode (copy_function = "g_rand_copy", free_function = "g_rand_free")]
public class Rand {
public Rand.with_seed (uint32 seed);
- [NoArrayLength ()]
- public Rand.with_seed_array (uint32[] seed, uint seed_length);
+ public Rand.with_seed_array ([CCode (array_length = false)] uint32[] seed, uint seed_length);
public Rand ();
public void set_seed (uint32 seed);
- [NoArrayLength ()]
- public void set_seed_array (uint32[] seed, uint seed_length);
+ public void set_seed_array ([CCode (array_length = false)] uint32[] seed, uint seed_length);
public bool boolean ();
[CCode (cname = "g_rand_int")]
public uint32 next_int ();
public static bool set_variable (string variable, string value, bool overwrite);
[CCode (cname = "g_unsetenv")]
public static void unset_variable (string variable);
- [CCode (cname = "g_listenv")]
- [NoArrayLength]
+ [CCode (cname = "g_listenv", array_length = false)]
public static string[] list_variables ();
[CCode (cname = "g_get_user_name")]
public static weak string get_user_name ();
public static weak string get_user_config_dir ();
[CCode (cname = "g_get_user_special_dir")]
public static weak string get_user_special_dir (UserDirectory directory);
- [CCode (cname = "g_get_system_data_dirs"), NoArrayLength]
+ [CCode (cname = "g_get_system_data_dirs", array_length = false)]
+ [NoArrayLength]
public static weak string[] get_system_data_dirs ();
- [CCode (cname = "g_get_system_config_dirs"), NoArrayLength]
+ [CCode (cname = "g_get_system_config_dirs")]
public static weak string[] get_system_config_dirs ();
[CCode (cname = "g_get_host_name")]
public static weak string get_host_name ();
[CCode (lower_case_cprefix = "g_")]
namespace Process {
- [NoArrayLength ()]
- public static bool spawn_async_with_pipes (string? working_directory, string[] argv, string[]? envp, SpawnFlags _flags, SpawnChildSetupFunc? child_setup, out Pid child_pid, out int standard_input = null, out int standard_output = null, out int standard_error = null) throws SpawnError;
- [NoArrayLength ()]
- public static bool spawn_async (string? working_directory, string[] argv, string[]? envp, SpawnFlags _flags, SpawnChildSetupFunc? child_setup, out Pid child_pid) throws SpawnError;
- [NoArrayLength ()]
- public static bool spawn_sync (string? working_directory, string[] argv, string[]? envp, SpawnFlags _flags, SpawnChildSetupFunc? child_setup, out string standard_output = null, out string standard_error = null, out int exit_status = null) throws SpawnError;
+ public static bool spawn_async_with_pipes (string? working_directory, [CCode (array_length = false)] string[] argv, [CCode (array_length = false)] string[]? envp, SpawnFlags _flags, SpawnChildSetupFunc? child_setup, out Pid child_pid, out int standard_input = null, out int standard_output = null, out int standard_error = null) throws SpawnError;
+ public static bool spawn_async (string? working_directory, [CCode (array_length = false)] string[] argv, [CCode (array_length = false)] string[]? envp, SpawnFlags _flags, SpawnChildSetupFunc? child_setup, out Pid child_pid) throws SpawnError;
+ public static bool spawn_sync (string? working_directory, [CCode (array_length = false)] string[] argv, [CCode (array_length = false)] string[]? envp, SpawnFlags _flags, SpawnChildSetupFunc? child_setup, out string standard_output = null, out string standard_error = null, out int exit_status = null) throws SpawnError;
public static bool spawn_command_line_async (string command_line) throws SpawnError;
public static bool spawn_command_line_sync (string command_line, out string standard_output = null, out string standard_error = null, out int exit_status = null) throws SpawnError;
[CCode (cname = "g_spawn_close_pid")]
public bool get_ignore_unknown_options ();
public string get_help (bool main_help, OptionGroup? group);
[NoArrayLength]
- public void add_main_entries (OptionEntry[] entries, string? translation_domain);
+ public void add_main_entries ([CCode (array_length = false)] OptionEntry[] entries, string? translation_domain);
public void add_group (OptionGroup# group);
public void set_main_group (OptionGroup# group);
public weak OptionGroup get_main_group ();
[CCode (free_function = "g_option_group_free")]
public class OptionGroup {
public OptionGroup (string name, string description, string help_description, void* user_data, DestroyNotify? destroy);
- [NoArrayLength]
- public void add_entries (OptionEntry[] entries);
+ public void add_entries ([CCode (array_length = false)] OptionEntry[] entries);
public void set_parse_hooks (OptionParseFunc pre_parse_func, OptionParseFunc post_parse_hook);
public void set_error_hook (OptionErrorFunc error_func);
public void set_translate_func (TranslateFunc func, DestroyNotify? destroy_notify);
public bool match_full (string str, long string_len = -1, int start_position = 0, RegexMatchFlags match_options = 0, out MatchInfo match_info = null) throws RegexError;
public bool match_all (string str, RegexMatchFlags match_options = 0, out MatchInfo match_info = null);
public bool match_all_full (string str, long string_len = -1, int start_position = 0, RegexMatchFlags match_options = 0, out MatchInfo match_info = null) throws RegexError;
- [NoArrayLength]
+ [CCode (array_length = false)]
public static string[] split_simple (string pattern, string str, RegexCompileFlags compile_options = 0, RegexMatchFlags match_options = 0);
- [NoArrayLength]
+ [CCode (array_length = false)]
public string[] split (string str, RegexMatchFlags match_options = 0);
- [NoArrayLength]
- public bool split_full (string str, long string_len = -1, int start_position = 0, RegexMatchFlags match_options = 0, int max_tokens = 0) throws RegexError;
+ [CCode (array_length = false)]
+ public string[] split_full (string str, long string_len = -1, int start_position = 0, RegexMatchFlags match_options = 0, int max_tokens = 0) throws RegexError;
public string replace (string str, long string_len, int start_position, string replacement, RegexMatchFlags match_options = 0) throws RegexError;
public string replace_literal (string str, long string_len, int start_position, string replacement, RegexMatchFlags match_options = 0) throws RegexError;
public string replace_eval (string str, long string_len, int start_position, RegexMatchFlags match_options = 0, RegexEvalCallback eval, void* user_data) throws RegexError;
public bool fetch_pos (int match_num, out int start_pos, out int end_pos);
public string fetch_named (string name);
public bool fetch_named_pos (string name, out int start_pos, out int end_pos);
- [NoArrayLength]
+ [CCode (array_length = false)]
public string[] fetch_all ();
}
public void get_position (out int line_number, out int char_number);
}
- [NoArrayLength]
- public delegate void MarkupParserStartElementFunc (MarkupParseContext context, string element_name, string[] attribute_names, string[] attribute_values) throws MarkupError;
+ public delegate void MarkupParserStartElementFunc (MarkupParseContext context, string element_name, [CCode (array_length = false)] string[] attribute_names, [CCode (array_length = false)] string[] attribute_values) throws MarkupError;
public delegate void MarkupParserEndElementFunc (MarkupParseContext context, string element_name) throws MarkupError;
public KeyFile ();
public void set_list_separator (char separator);
public bool load_from_file (string file, KeyFileFlags @flags) throws KeyFileError;
- [NoArrayLength]
- public bool load_from_dirs (string file, string[] search_dirs, out string full_path, KeyFileFlags @flags) throws KeyFileError;
+ public bool load_from_dirs (string file, [CCode (array_length = false)] string[] search_dirs, out string full_path, KeyFileFlags @flags) throws KeyFileError;
public bool load_from_data (string data, ulong length, KeyFileFlags @flags) throws KeyFileError;
public bool load_from_data_dirs (string file, out string full_path, KeyFileFlags @flags) throws KeyFileError;
public string to_data (out size_t length) throws KeyFileError;
/* valagidlparser.vala
*
- * Copyright (C) 2006-2008 Jürg Billeter, Raffaele Sandrini
+ * Copyright (C) 2006-2009 Jürg Billeter
+ * Copyright (C) 2006-2008 Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
} else if (eval (nv[1]) == "0") {
show_param = true;
}
+ } else if (nv[0] == "no_array_length") {
+ if (eval (nv[1]) == "1") {
+ p.no_array_length = true;
+ }
} else if (nv[0] == "array_length_pos") {
set_array_length_pos = true;
array_length_pos = eval (nv[1]).to_double ();
return field;
}
+ [CCode (array_length = false)]
[NoArrayLength]
private string[]? get_attributes (string codenode) {
var attributes = codenode_attributes_map.get (codenode);
/* valavapigen.vala
*
- * Copyright (C) 2006-2008 Jürg Billeter
+ * Copyright (C) 2006-2009 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
static string directory;
static bool version;
static bool quiet_mode;
- [NoArrayLength ()]
+ [CCode (array_length = false)]
+ [NoArrayLength]
static string[] sources;
- [NoArrayLength ()]
+ [CCode (array_length = false)]
+ [NoArrayLength]
static string[] vapi_directories;
static string library;
- [NoArrayLength ()]
+ [CCode (array_length = false)]
+ [NoArrayLength]
static string[] packages;
static string metadata_filename;
CodeContext context;