[vala] codewriter: Support fixed-length arrays
- From: JÃrg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codewriter: Support fixed-length arrays
- Date: Mon, 6 Aug 2012 20:21:32 +0000 (UTC)
commit 625418f829153cbd4748ee17ba49982fb4cd8476
Author: JÃrg Billeter <j bitron ch>
Date: Mon Aug 6 22:18:49 2012 +0200
codewriter: Support fixed-length arrays
Fixes bug 618689.
vala/valaarraytype.vala | 8 ++++++--
vala/valacodewriter.vala | 13 ++++++++++++-
2 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala
index 6654870..f1bcba1 100644
--- a/vala/valaarraytype.vala
+++ b/vala/valaarraytype.vala
@@ -1,6 +1,6 @@
/* valaarraytype.vala
*
- * Copyright (C) 2007-2011 JÃrg Billeter
+ * Copyright (C) 2007-2012 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
@@ -153,7 +153,11 @@ public class Vala.ArrayType : ReferenceType {
}
public override string to_qualified_string (Scope? scope) {
- return "%s[%s]%s".printf (element_type.to_qualified_string (scope), string.nfill (rank - 1, ','), nullable ? "?" : "");
+ if (!fixed_length) {
+ return "%s[%s]%s".printf (element_type.to_qualified_string (scope), string.nfill (rank - 1, ','), nullable ? "?" : "");
+ } else {
+ return element_type.to_qualified_string (scope);
+ }
}
public override bool compatible (DataType target_type) {
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index 7a79614..30c36f4 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -1,6 +1,6 @@
/* valacodewriter.vala
*
- * Copyright (C) 2006-2010 JÃrg Billeter
+ * Copyright (C) 2006-2012 JÃrg Billeter
* Copyright (C) 2006-2008 Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
@@ -509,6 +509,7 @@ public class Vala.CodeWriter : CodeVisitor {
write_string (" ");
write_identifier (c.name);
+ write_type_suffix (c.type_reference);
if (type == CodeWriterType.FAST && c.value != null) {
write_string(" = ");
c.value.accept (this);
@@ -545,6 +546,7 @@ public class Vala.CodeWriter : CodeVisitor {
write_string (" ");
write_identifier (f.name);
+ write_type_suffix (f.variable_type);
write_string (";");
write_newline ();
}
@@ -605,6 +607,7 @@ public class Vala.CodeWriter : CodeVisitor {
write_string (" ");
write_identifier (param.name);
+ write_type_suffix (param.variable_type);
if (param.initializer != null) {
write_string (" = ");
@@ -847,6 +850,7 @@ public class Vala.CodeWriter : CodeVisitor {
write_type (local.variable_type);
write_string (" ");
write_identifier (local.name);
+ write_type_suffix (local.variable_type);
if (local.initializer != null) {
write_string (" = ");
local.initializer.accept (this);
@@ -1446,6 +1450,13 @@ public class Vala.CodeWriter : CodeVisitor {
write_string (type.to_qualified_string (current_scope));
}
+ private void write_type_suffix (DataType type) {
+ var array_type = type as ArrayType;
+ if (array_type != null && array_type.fixed_length) {
+ write_string ("[%d]".printf (array_type.length));
+ }
+ }
+
private void write_string (string s) {
stream.printf ("%s", s);
bol = false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]