[vala] glib-2.0: Simplify creation of GLib.Array
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] glib-2.0: Simplify creation of GLib.Array
- Date: Sun, 22 May 2011 20:41:37 +0000 (UTC)
commit c4926de991f6f1d6cb94e35b4e227aec31461b29
Author: Jürg Billeter <j bitron ch>
Date: Sat May 21 17:44:34 2011 +0200
glib-2.0: Simplify creation of GLib.Array
codegen/valaccodebasemodule.vala | 9 ++++++++-
vapi/glib-2.0.vapi | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 87818a1..b77cd80 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4114,6 +4114,13 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
param = params_it.get ();
ellipsis = param.ellipsis;
if (!ellipsis) {
+ // g_array_new: element size
+ if (cl == garray_type && param.name == "element_size") {
+ var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
+ csizeof.add_argument (new CCodeIdentifier (expr.type_reference.get_type_arguments ().get (0).get_cname ()));
+ cexpr = csizeof;
+ }
+
if (!param.no_array_length && param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
for (int dim = 1; dim <= array_type.rank; dim++) {
@@ -4159,7 +4166,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ellipsis = true;
break;
}
-
+
if (param.initializer == null) {
Report.error (expr.source_reference, "no default expression for argument %d".printf (i));
return;
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 815654a..3299b24 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -4177,7 +4177,7 @@ namespace GLib {
[CCode (cname = "len")]
public uint length;
- public Array (bool zero_terminated, bool clear, ulong element_size);
+ public Array (bool zero_terminated = true, bool clear = true, ulong element_size = 0);
[CCode (cname = "g_array_sized_new")]
public Array.sized (bool zero_terminated, bool clear, ulong element_size, uint reserved_size);
public void append_val (owned G value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]