[vala] Add support for generic array duplication
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Add support for generic array duplication
- Date: Wed, 24 Mar 2010 20:16:20 +0000 (UTC)
commit 976a7362b1e730c82990663301c777e658f33115
Author: Luca Bruno <lethalman88 gmail com>
Date: Wed Mar 24 14:05:44 2010 +0100
Add support for generic array duplication
Fixes bug 613745.
codegen/valaccodearraymodule.vala | 5 +++++
codegen/valaccodebasemodule.vala | 10 +++++++++-
2 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index df8ee4d..093605d 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -775,6 +775,11 @@ internal class Vala.CCodeArrayModule : CCodeMethodCallModule {
function.add_parameter (new CCodeFormalParameter ("self", array_type.get_cname ()));
// total length over all dimensions
function.add_parameter (new CCodeFormalParameter ("length", "int"));
+ if (array_type.element_type is GenericType) {
+ // dup function array elements
+ string func_name = "%s_dup_func".printf (array_type.element_type.type_parameter.name.down ());
+ function.add_parameter (new CCodeFormalParameter (func_name, "GBoxedCopyFunc"));
+ }
// definition
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index c937531..1e7175d 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2333,7 +2333,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
}
bool is_in_generic_type (DataType type) {
- if (type.type_parameter.parent_symbol is TypeSymbol
+ if (current_symbol != null && type.type_parameter.parent_symbol is TypeSymbol
&& (current_method == null || current_method.binding == MemberBinding.INSTANCE)) {
return true;
} else {
@@ -3832,6 +3832,14 @@ internal class Vala.CCodeBaseModule : CCodeModule {
}
ccall.add_argument (csizeexpr);
+
+ if (array_type.element_type is GenericType) {
+ var elem_dupexpr = get_dup_func_expression (array_type.element_type, node.source_reference);
+ if (elem_dupexpr == null) {
+ elem_dupexpr = new CCodeConstant ("NULL");
+ }
+ ccall.add_argument (elem_dupexpr);
+ }
}
var ccomma = new CCodeCommaExpression ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]