public bool array_null_terminated {
get {
if (_array_null_terminated == null) {
- if (ccode != null && ccode.has_argument ("array_null_terminated")) {
+ // If arrays claim to have an array-length and also are null-terminated then rely on the given length
+ if (ccode != null && ccode.has_argument ("array_length") && ccode.get_bool ("array_length")) {
+ _array_null_terminated = false;
+ } else if (ccode != null && ccode.has_argument ("array_null_terminated")) {
_array_null_terminated = ccode.get_bool ("array_null_terminated");
} else {
_array_null_terminated = get_default_array_null_terminated ();
--- /dev/null
+GIR
+
+Input:
+
+ <function name="get_string_list" c:identifier="test_get_string_list">
+ <return-value transfer-ownership="full">
+ <array length="1" zero-terminated="1" c:type="gchar**">
+ <type name="utf8"/>
+ </array>
+ </return-value>
+ <parameters>
+ <parameter name="key" transfer-ownership="none">
+ <type name="utf8" c:type="const gchar*"/>
+ </parameter>
+ <parameter name="length"
+ direction="out"
+ caller-allocates="0"
+ transfer-ownership="full"
+ optional="1"
+ allow-none="1">
+ <type name="gsize" c:type="gsize*"/>
+ </parameter>
+ </parameters>
+ </function>
+
+Output:
+
+[CCode (array_length = true, array_length_pos = 1.1, array_length_type = "gsize", array_null_terminated = true, cheader_filename = "test.h")]
+public static string[] get_string_list (string key);
if (metadata.has_argument (ArgumentType.ARRAY_LENGTH_IDX)) {
array_length_idx = metadata.get_integer (ArgumentType.ARRAY_LENGTH_IDX);
} else {
- if (no_array_length) {
- param.set_attribute_bool ("CCode", "array_length", false);
+ if (no_array_length || array_null_terminated) {
+ param.set_attribute_bool ("CCode", "array_length", !no_array_length);
}
if (array_null_terminated) {
param.set_attribute_bool ("CCode", "array_null_terminated", array_null_terminated);
field.set_attribute_string ("CCode", "cname", cname);
}
if (type is ArrayType) {
- if (!no_array_length && !array_null_terminated && array_length_idx > -1) {
+ if (!no_array_length && array_length_idx > -1) {
current.array_length_idx = array_length_idx;
}
- if (no_array_length) {
- field.set_attribute_bool ("CCode", "array_length", false);
+ if (no_array_length || array_null_terminated) {
+ field.set_attribute_bool ("CCode", "array_length", !no_array_length);
}
if (array_null_terminated) {
field.set_attribute_bool ("CCode", "array_null_terminated", true);
prop.access = SymbolAccessibility.PUBLIC;
prop.external = true;
prop.is_abstract = is_abstract;
- if (no_array_length) {
- prop.set_attribute_bool ("CCode", "array_length", false);
+ if (no_array_length || array_null_terminated) {
+ prop.set_attribute_bool ("CCode", "array_length", !no_array_length);
}
if (array_null_terminated) {
prop.set_attribute_bool ("CCode", "array_null_terminated", true);
if (return_type is ArrayType && metadata.has_argument (ArgumentType.ARRAY_LENGTH_IDX)) {
return_array_length_idx = metadata.get_integer (ArgumentType.ARRAY_LENGTH_IDX);
} else {
- if (return_no_array_length) {
- s.set_attribute_bool ("CCode", "array_length", false);
+ if (return_no_array_length || return_array_null_terminated) {
+ s.set_attribute_bool ("CCode", "array_length", !return_no_array_length);
}
if (return_array_null_terminated) {
s.set_attribute_bool ("CCode", "array_null_terminated", true);
public uint64 get_uint64 (string group_name, string key) throws KeyFileError;
[Version (since = "2.12")]
public double get_double (string group_name, string key) throws KeyFileError;
- [CCode (array_length_type = "gsize")]
+ [CCode (array_length = true, array_length_type = "gsize", array_null_terminated = true)]
public string[] get_string_list (string group_name, string key) throws KeyFileError;
[CCode (array_length_type = "gsize")]
public string[] get_locale_string_list (string group_name, string key, string? locale = null) throws KeyFileError;