summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuerg Billeter <j@bitron.ch>2007-07-27 15:36:23 +0000
committerJürg Billeter <juergbi@src.gnome.org>2007-07-27 15:36:23 +0000
commit5a32f9e2108feff5cdc997fd79303e5f4e9b6175 (patch)
treebbb31850d9a7279f7e6cfb2561b3a80ef0536b1d
parentb49e7bae77c537a08cf5c5cb1850fc34d859252a (diff)
downloadvala-5a32f9e2108feff5cdc997fd79303e5f4e9b6175.tar.gz
add internal copy of libgee and use Gee.ArrayList, Gee.HashMap, and
2007-07-27 Juerg Billeter <j@bitron.ch> * Makefile.am, README, configure.ac, gee/Makefile.am, gee/arraylist.vala, gee/collection.vala, gee/hashmap.vala, gee/hashset.vala, gee/iterable.vala, gee/iterator.vala, gee/list.vala, gee/map.vala, gee/readonlycollection.vala, gee/readonlylist.vala, gee/readonlymap.vala, gee/readonlyset.vala, gee/set.vala, vala/Makefile.am, vala/parser.y, vala/valaarray.vala, vala/valaarraycreationexpression.vala, vala/valaattribute.vala, vala/valablock.vala, vala/valacallback.vala, vala/valaclass.vala, vala/valacodecontext.vala, vala/valacodenode.vala, vala/valadatatype.vala, vala/valaelementaccess.vala, vala/valaenum.vala, vala/valaexpression.vala, vala/valafield.vala, vala/valaformalparameter.vala, vala/valaforstatement.vala, vala/valainitializerlist.vala, vala/valainstancecast.vala, vala/valainterface.vala, vala/valainterfacewriter.vala, vala/valainvocationexpression.vala, vala/valainvokable.vala, vala/valalambdaexpression.vala, vala/valalocalvariabledeclaration.vala, vala/valamember.vala, vala/valamemberaccess.vala, vala/valamemorymanager.vala, vala/valamethod.vala, vala/valanamespace.vala, vala/valaobjectcreationexpression.vala, vala/valapointer.vala, vala/valascope.vala, vala/valasemanticanalyzer.vala, vala/valasignal.vala, vala/valasourcefile.vala, vala/valasourcefilecycle.vala, vala/valastruct.vala, vala/valaswitchsection.vala, vala/valaswitchstatement.vala, vala/valasymbol.vala, vala/valasymbolresolver.vala, vala/valatrystatement.vala, vala/valatypeparameter.vala, vala/valatypereference.vala, vala/valavariabledeclarator.vala, ccode/Makefile.am, ccode/valaccodeblock.vala, ccode/valaccodecasestatement.vala, ccode/valaccodecommaexpression.vala, ccode/valaccodedeclaration.vala, ccode/valaccodeenum.vala, ccode/valaccodeforstatement.vala, ccode/valaccodefragment.vala, ccode/valaccodefunction.vala, ccode/valaccodefunctioncall.vala, ccode/valaccodefunctiondeclarator.vala, ccode/valaccodeinitializerlist.vala, ccode/valaccodestruct.vala, ccode/valaccodeswitchstatement.vala, gobject/Makefile.am, gobject/valaclassregisterfunction.vala, gobject/valacodegenerator.vala, gobject/valacodegeneratorassignment.vala, gobject/valacodegeneratorclass.vala, gobject/valacodegeneratorinterface.vala, gobject/valacodegeneratorinvocationexpression.vala, gobject/valacodegeneratormemberaccess.vala, gobject/valacodegeneratormethod.vala, gobject/valacodegeneratorsignal.vala, gobject/valacodegeneratorsourcefile.vala, gobject/valainterfaceregisterfunction.vala, compiler/Makefile.am, vapi/gio-standalone.vala, vapi/gstreamer-0.10.vala, vapi/gtk+-2.0.vala, vapigen/Makefile.am, vapigen/valagidlparser.vala: add internal copy of libgee and use Gee.ArrayList, Gee.HashMap, and Gee.HashSet instead of GLib.List and GLib.HashTable svn path=/trunk/; revision=406
-rw-r--r--ChangeLog54
-rw-r--r--Makefile.am2
-rw-r--r--README2
-rw-r--r--ccode/Makefile.am2
-rw-r--r--ccode/valaccodeblock.vala7
-rw-r--r--ccode/valaccodecasestatement.vala10
-rw-r--r--ccode/valaccodecommaexpression.vala7
-rw-r--r--ccode/valaccodedeclaration.vala10
-rw-r--r--ccode/valaccodeenum.vala10
-rw-r--r--ccode/valaccodeforstatement.vala17
-rw-r--r--ccode/valaccodefragment.vala9
-rw-r--r--ccode/valaccodefunction.vala15
-rw-r--r--ccode/valaccodefunctioncall.vala9
-rw-r--r--ccode/valaccodefunctiondeclarator.vala10
-rw-r--r--ccode/valaccodeinitializerlist.vala7
-rw-r--r--ccode/valaccodestruct.vala10
-rw-r--r--ccode/valaccodeswitchstatement.vala12
-rw-r--r--compiler/Makefile.am2
-rw-r--r--configure.ac1
-rw-r--r--gee/Makefile.am82
-rw-r--r--gee/arraylist.vala186
-rw-r--r--gee/collection.vala68
-rw-r--r--gee/hashmap.vala332
-rw-r--r--gee/hashset.vala202
-rw-r--r--gee/iterable.vala37
-rw-r--r--gee/iterator.vala42
-rw-r--r--gee/list.vala67
-rw-r--r--gee/map.vala88
-rw-r--r--gee/readonlycollection.vala82
-rw-r--r--gee/readonlylist.vala110
-rw-r--r--gee/readonlymap.vala87
-rw-r--r--gee/readonlyset.vala82
-rw-r--r--gee/set.vala28
-rw-r--r--gobject/Makefile.am2
-rw-r--r--gobject/valaclassregisterfunction.vala2
-rw-r--r--gobject/valacodegenerator.vala246
-rw-r--r--gobject/valacodegeneratorassignment.vala19
-rw-r--r--gobject/valacodegeneratorclass.vala10
-rw-r--r--gobject/valacodegeneratorinterface.vala2
-rw-r--r--gobject/valacodegeneratorinvocationexpression.vala37
-rw-r--r--gobject/valacodegeneratormemberaccess.vala2
-rw-r--r--gobject/valacodegeneratormethod.vala13
-rw-r--r--gobject/valacodegeneratorsignal.vala8
-rw-r--r--gobject/valacodegeneratorsourcefile.vala43
-rw-r--r--gobject/valainterfaceregisterfunction.vala2
-rw-r--r--vala/Makefile.am3
-rw-r--r--vala/parser.y23
-rw-r--r--vala/valaarray.vala9
-rw-r--r--vala/valaarraycreationexpression.vala15
-rw-r--r--vala/valaattribute.vala5
-rw-r--r--vala/valablock.vala17
-rw-r--r--vala/valacallback.vala23
-rw-r--r--vala/valaclass.vala65
-rw-r--r--vala/valacodecontext.vala57
-rw-r--r--vala/valacodenode.vala2
-rw-r--r--vala/valadatatype.vala23
-rw-r--r--vala/valaelementaccess.vala13
-rw-r--r--vala/valaenum.vala13
-rw-r--r--vala/valaexpression.vala5
-rw-r--r--vala/valafield.vala3
-rw-r--r--vala/valaformalparameter.vala3
-rw-r--r--vala/valaforstatement.vala46
-rw-r--r--vala/valainitializerlist.vala16
-rw-r--r--vala/valainstancecast.vala2
-rw-r--r--vala/valainterface.vala51
-rw-r--r--vala/valainterfacewriter.vala19
-rw-r--r--vala/valainvocationexpression.vala41
-rw-r--r--vala/valainvokable.vala3
-rw-r--r--vala/valalambdaexpression.vala29
-rw-r--r--vala/valalocalvariabledeclaration.vala26
-rw-r--r--vala/valamember.vala18
-rw-r--r--vala/valamemberaccess.vala28
-rw-r--r--vala/valamemorymanager.vala21
-rw-r--r--vala/valamethod.vala32
-rw-r--r--vala/valanamespace.vala71
-rw-r--r--vala/valaobjectcreationexpression.vala33
-rw-r--r--vala/valapointer.vala5
-rw-r--r--vala/valascope.vala9
-rw-r--r--vala/valasemanticanalyzer.vala142
-rw-r--r--vala/valasignal.vala9
-rw-r--r--vala/valasourcefile.vala80
-rw-r--r--vala/valasourcefilecycle.vala5
-rw-r--r--vala/valastruct.vala43
-rw-r--r--vala/valaswitchsection.vala24
-rw-r--r--vala/valaswitchstatement.vala19
-rw-r--r--vala/valasymbol.vala7
-rw-r--r--vala/valasymbolresolver.vala3
-rw-r--r--vala/valatrystatement.vala11
-rw-r--r--vala/valatypeparameter.vala18
-rw-r--r--vala/valatypereference.vala19
-rw-r--r--vala/valavariabledeclarator.vala3
-rw-r--r--vapi/gio-standalone.vala124
-rw-r--r--vapi/gstreamer-0.10.vala8
-rw-r--r--vapi/gtk+-2.0.vala10
-rw-r--r--vapigen/Makefile.am2
-rw-r--r--vapigen/valagidlparser.vala45
96 files changed, 2451 insertions, 925 deletions
diff --git a/ChangeLog b/ChangeLog
index db74f1b63..934ce6e53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,59 @@
2007-07-27 Jürg Billeter <j@bitron.ch>
+ * Makefile.am, README, configure.ac, gee/Makefile.am,
+ gee/arraylist.vala, gee/collection.vala, gee/hashmap.vala,
+ gee/hashset.vala, gee/iterable.vala, gee/iterator.vala, gee/list.vala,
+ gee/map.vala, gee/readonlycollection.vala, gee/readonlylist.vala,
+ gee/readonlymap.vala, gee/readonlyset.vala, gee/set.vala,
+ vala/Makefile.am, vala/parser.y, vala/valaarray.vala,
+ vala/valaarraycreationexpression.vala, vala/valaattribute.vala,
+ vala/valablock.vala, vala/valacallback.vala, vala/valaclass.vala,
+ vala/valacodecontext.vala, vala/valacodenode.vala,
+ vala/valadatatype.vala, vala/valaelementaccess.vala,
+ vala/valaenum.vala, vala/valaexpression.vala, vala/valafield.vala,
+ vala/valaformalparameter.vala, vala/valaforstatement.vala,
+ vala/valainitializerlist.vala, vala/valainstancecast.vala,
+ vala/valainterface.vala, vala/valainterfacewriter.vala,
+ vala/valainvocationexpression.vala, vala/valainvokable.vala,
+ vala/valalambdaexpression.vala,
+ vala/valalocalvariabledeclaration.vala, vala/valamember.vala,
+ vala/valamemberaccess.vala, vala/valamemorymanager.vala,
+ vala/valamethod.vala, vala/valanamespace.vala,
+ vala/valaobjectcreationexpression.vala, vala/valapointer.vala,
+ vala/valascope.vala, vala/valasemanticanalyzer.vala,
+ vala/valasignal.vala, vala/valasourcefile.vala,
+ vala/valasourcefilecycle.vala, vala/valastruct.vala,
+ vala/valaswitchsection.vala, vala/valaswitchstatement.vala,
+ vala/valasymbol.vala, vala/valasymbolresolver.vala,
+ vala/valatrystatement.vala, vala/valatypeparameter.vala,
+ vala/valatypereference.vala, vala/valavariabledeclarator.vala,
+ ccode/Makefile.am, ccode/valaccodeblock.vala,
+ ccode/valaccodecasestatement.vala,
+ ccode/valaccodecommaexpression.vala, ccode/valaccodedeclaration.vala,
+ ccode/valaccodeenum.vala, ccode/valaccodeforstatement.vala,
+ ccode/valaccodefragment.vala, ccode/valaccodefunction.vala,
+ ccode/valaccodefunctioncall.vala,
+ ccode/valaccodefunctiondeclarator.vala,
+ ccode/valaccodeinitializerlist.vala, ccode/valaccodestruct.vala,
+ ccode/valaccodeswitchstatement.vala, gobject/Makefile.am,
+ gobject/valaclassregisterfunction.vala,
+ gobject/valacodegenerator.vala,
+ gobject/valacodegeneratorassignment.vala,
+ gobject/valacodegeneratorclass.vala,
+ gobject/valacodegeneratorinterface.vala,
+ gobject/valacodegeneratorinvocationexpression.vala,
+ gobject/valacodegeneratormemberaccess.vala,
+ gobject/valacodegeneratormethod.vala,
+ gobject/valacodegeneratorsignal.vala,
+ gobject/valacodegeneratorsourcefile.vala,
+ gobject/valainterfaceregisterfunction.vala, compiler/Makefile.am,
+ vapi/gio-standalone.vala, vapi/gstreamer-0.10.vala,
+ vapi/gtk+-2.0.vala, vapigen/Makefile.am, vapigen/valagidlparser.vala:
+ add internal copy of libgee and use Gee.ArrayList, Gee.HashMap, and
+ Gee.HashSet instead of GLib.List and GLib.HashTable
+
+2007-07-27 Jürg Billeter <j@bitron.ch>
+
* vala/Makefile.am, vala/valaarray.vala, vala/valaarraymovemethod.vala,
vala/valadatatype.vala, vala/valatypeparameter.vala,
gobject/valacodegenerator.vala,
diff --git a/Makefile.am b/Makefile.am
index c5f266038..8e613ca0a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,6 +8,7 @@ VAPIGEN_SUBDIRS = \
endif
SUBDIRS = \
+ gee \
ccode \
vala \
gobject \
@@ -19,6 +20,7 @@ SUBDIRS = \
$(NULL)
DIST_SUBDIRS = \
+ gee \
ccode \
vala \
gobject \
diff --git a/README b/README
index 37bf45ce3..107d7b57c 100644
--- a/README
+++ b/README
@@ -40,4 +40,4 @@ all compile-time information is available when generating a binding.
More information about Vala is available at
- http://www.paldo.org/vala/
+ http://live.gnome.org/Vala/
diff --git a/ccode/Makefile.am b/ccode/Makefile.am
index 66b6ee479..39dae094d 100644
--- a/ccode/Makefile.am
+++ b/ccode/Makefile.am
@@ -215,7 +215,7 @@ ccodeinclude_HEADERS = \
$(NULL)
ccode.vala ccode.vala.stamp: $(filter %.vala,$(libvalaccode_la_SOURCES))
- $(VALAC) --vapidir $(srcdir)/../vapi --library ccode $^
+ $(VALAC) --vapidir $(srcdir)/../vapi --vapidir ../gee --pkg gee --library ccode $^
touch $@
libvalaccode_la_LIBADD = \
diff --git a/ccode/valaccodeblock.vala b/ccode/valaccodeblock.vala
index 342109945..20bc9a6cc 100644
--- a/ccode/valaccodeblock.vala
+++ b/ccode/valaccodeblock.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a C code block.
@@ -32,13 +33,13 @@ public class Vala.CCodeBlock : CCodeStatement {
*/
public bool suppress_newline { get; set; }
- List<CCodeNode> statements;
+ private Gee.List<CCodeNode> statements = new ArrayList<CCodeNode> ();
/**
* Prepend the specified statement to the list of statements.
*/
public void prepend_statement (CCodeNode! statement) {
- statements.prepend (statement);
+ statements.insert (0, statement);
}
/**
@@ -46,7 +47,7 @@ public class Vala.CCodeBlock : CCodeStatement {
*/
public void add_statement (CCodeNode! statement) {
/* allow generic nodes to include comments */
- statements.append (statement);
+ statements.add (statement);
}
public override void write (CCodeWriter! writer) {
diff --git a/ccode/valaccodecasestatement.vala b/ccode/valaccodecasestatement.vala
index 4cbee4b61..a75efa9d2 100644
--- a/ccode/valaccodecasestatement.vala
+++ b/ccode/valaccodecasestatement.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a case block in a switch statement in C code.
@@ -29,12 +30,11 @@ public class Vala.CCodeCaseStatement : CCodeStatement {
/**
* The case expression.
*/
- public CCodeExpression! expression { get; set construct; }
+ public CCodeExpression! expression { get; set; }
- private List<CCodeStatement> statements;
+ private Gee.List<CCodeStatement> statements = new ArrayList<CCodeStatement> ();
- public CCodeCaseStatement (CCodeExpression! expr) {
- expression = expr;
+ public CCodeCaseStatement (construct CCodeExpression! expression) {
}
/**
@@ -43,7 +43,7 @@ public class Vala.CCodeCaseStatement : CCodeStatement {
* @param stmt a statement
*/
public void add_statement (CCodeStatement! stmt) {
- statements.append (stmt);
+ statements.add (stmt);
}
public override void write (CCodeWriter! writer) {
diff --git a/ccode/valaccodecommaexpression.vala b/ccode/valaccodecommaexpression.vala
index 7bce662fe..a177aaad9 100644
--- a/ccode/valaccodecommaexpression.vala
+++ b/ccode/valaccodecommaexpression.vala
@@ -1,6 +1,6 @@
/* valaccodecommaexpression.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 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
@@ -21,12 +21,13 @@
*/
using GLib;
+using Gee;
/**
* Represents a comma separated expression list in the C code.
*/
public class Vala.CCodeCommaExpression : CCodeExpression {
- private List<CCodeExpression> inner;
+ private Gee.List<CCodeExpression> inner = new ArrayList<CCodeExpression> ();
/**
* Appends the specified expression to the expression list.
@@ -34,7 +35,7 @@ public class Vala.CCodeCommaExpression : CCodeExpression {
* @param expr a C code expression
*/
public void append_expression (CCodeExpression! expr) {
- inner.append (expr);
+ inner.add (expr);
}
public override void write (CCodeWriter! writer) {
diff --git a/ccode/valaccodedeclaration.vala b/ccode/valaccodedeclaration.vala
index c0d8605ef..68537a103 100644
--- a/ccode/valaccodedeclaration.vala
+++ b/ccode/valaccodedeclaration.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a local variable declaration in the C code.
@@ -29,17 +30,16 @@ public class Vala.CCodeDeclaration : CCodeStatement {
/**
* The type of the local variable.
*/
- public string! type_name { get; set construct; }
+ public string! type_name { get; set; }
/**
* The declaration modifier.
*/
public CCodeModifiers modifiers { get; set; }
- private List<CCodeDeclarator> declarators;
+ private Gee.List<CCodeDeclarator> declarators = new ArrayList<CCodeDeclarator> ();
- public CCodeDeclaration (string! _type_name) {
- type_name = _type_name;
+ public CCodeDeclaration (construct string! type_name) {
}
/**
@@ -48,7 +48,7 @@ public class Vala.CCodeDeclaration : CCodeStatement {
* @param decl a declarator
*/
public void add_declarator (CCodeDeclarator! decl) {
- declarators.append (decl);
+ declarators.add (decl);
}
public override void write (CCodeWriter! writer) {
diff --git a/ccode/valaccodeenum.vala b/ccode/valaccodeenum.vala
index 656cea6e6..06f185621 100644
--- a/ccode/valaccodeenum.vala
+++ b/ccode/valaccodeenum.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents an enum in the C code.
@@ -31,10 +32,9 @@ public class Vala.CCodeEnum : CCodeNode {
*/
public string name { get; set; }
- private List<string> values;
+ private Gee.List<string> values = new ArrayList<string> ();
- public CCodeEnum (string n = null) {
- name = n;
+ public CCodeEnum (construct string name = null) {
}
/**
@@ -45,9 +45,9 @@ public class Vala.CCodeEnum : CCodeNode {
*/
public void add_value (string! name, string value = null) {
if (value == null) {
- values.append (name);
+ values.add (name);
} else {
- values.append ("%s = %s".printf (name, value));
+ values.add ("%s = %s".printf (name, value));
}
}
diff --git a/ccode/valaccodeforstatement.vala b/ccode/valaccodeforstatement.vala
index c8ea4e24d..37600927a 100644
--- a/ccode/valaccodeforstatement.vala
+++ b/ccode/valaccodeforstatement.vala
@@ -1,6 +1,6 @@
/* valaccodeforstatement.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 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
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a for iteration statement in the C code.
@@ -29,19 +30,17 @@ public class Vala.CCodeForStatement : CCodeStatement {
/**
* The loop condition.
*/
- public CCodeExpression! condition { get; set construct; }
+ public CCodeExpression! condition { get; set; }
/**
* The loop body.
*/
public CCodeStatement body { get; set; }
- private List<CCodeExpression> initializer;
- private List<CCodeExpression> iterator;
+ private Gee.List<CCodeExpression> initializer = new ArrayList<CCodeExpression> ();
+ private Gee.List<CCodeExpression> iterator = new ArrayList<CCodeExpression> ();
- public CCodeForStatement (CCodeExpression! cond, CCodeStatement stmt = null) {
- condition = cond;
- body = stmt;
+ public CCodeForStatement (construct CCodeExpression! condition, construct CCodeStatement body = null) {
}
/**
@@ -50,7 +49,7 @@ public class Vala.CCodeForStatement : CCodeStatement {
* @param expr an initializer expression
*/
public void add_initializer (CCodeExpression! expr) {
- initializer.append (expr);
+ initializer.add (expr);
}
/**
@@ -59,7 +58,7 @@ public class Vala.CCodeForStatement : CCodeStatement {
* @param expr an iterator expression
*/
public void add_iterator (CCodeExpression! expr) {
- iterator.append (expr);
+ iterator.add (expr);
}
public override void write (CCodeWriter! writer) {
diff --git a/ccode/valaccodefragment.vala b/ccode/valaccodefragment.vala
index 86ed0d592..6c8f1b468 100644
--- a/ccode/valaccodefragment.vala
+++ b/ccode/valaccodefragment.vala
@@ -21,12 +21,13 @@
*/
using GLib;
+using Gee;
/**
* Represents a container for C code nodes.
*/
public class Vala.CCodeFragment : CCodeNode {
- private List<CCodeNode> children;
+ private Gee.List<CCodeNode> children = new ArrayList<CCodeNode> ();
/**
* Appends the specified code node to this code fragment.
@@ -34,7 +35,7 @@ public class Vala.CCodeFragment : CCodeNode {
* @param node a C code node
*/
public void append (CCodeNode! node) {
- children.append (node);
+ children.add (node);
}
/**
@@ -42,8 +43,8 @@ public class Vala.CCodeFragment : CCodeNode {
*
* @return children list
*/
- public List<weak CCodeNode> get_children () {
- return children.copy ();
+ public Collection<CCodeNode> get_children () {
+ return new ReadOnlyCollection<CCodeNode> (children);
}
public override void write (CCodeWriter! writer) {
diff --git a/ccode/valaccodefunction.vala b/ccode/valaccodefunction.vala
index eee58c277..855d6d00d 100644
--- a/ccode/valaccodefunction.vala
+++ b/ccode/valaccodefunction.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a function declaration in the C code.
@@ -29,7 +30,7 @@ public class Vala.CCodeFunction : CCodeNode {
/**
* The name of this function.
*/
- public string! name { get; set construct; }
+ public string! name { get; set; }
/**
* The function modifiers.
@@ -39,18 +40,16 @@ public class Vala.CCodeFunction : CCodeNode {
/**
* The function return type.
*/
- public string! return_type { get; set construct; }
+ public string! return_type { get; set; }
/**
* The function body.
*/
public CCodeBlock block { get; set; }
- private List<CCodeFormalParameter> parameters;
+ private Gee.List<CCodeFormalParameter> parameters = new ArrayList<CCodeFormalParameter> ();
- public CCodeFunction (string! _name, string! _return_type) {
- name = _name;
- return_type = _return_type;
+ public CCodeFunction (construct string! name, construct string! return_type) {
}
/**
@@ -59,7 +58,7 @@ public class Vala.CCodeFunction : CCodeNode {
* @param param a formal parameter
*/
public void add_parameter (CCodeFormalParameter! param) {
- parameters.append (param);
+ parameters.add (param);
}
/**
@@ -75,7 +74,7 @@ public class Vala.CCodeFunction : CCodeNode {
* func.parameters = parameters.copy ();
*/
foreach (CCodeFormalParameter param in parameters) {
- func.parameters.append (param);
+ func.parameters.add (param);
}
func.block = block;
diff --git a/ccode/valaccodefunctioncall.vala b/ccode/valaccodefunctioncall.vala
index fa6a7d449..93aadd7ec 100644
--- a/ccode/valaccodefunctioncall.vala
+++ b/ccode/valaccodefunctioncall.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a function call in the C code.
@@ -31,7 +32,7 @@ public class Vala.CCodeFunctionCall : CCodeExpression {
*/
public CCodeExpression call { get; set; }
- private List<CCodeExpression> arguments;
+ private Gee.List<CCodeExpression> arguments = new ArrayList<CCodeExpression> ();
public CCodeFunctionCall (construct CCodeExpression call = null) {
}
@@ -42,7 +43,7 @@ public class Vala.CCodeFunctionCall : CCodeExpression {
* @param expr a C code expression
*/
public void add_argument (CCodeExpression! expr) {
- arguments.append (expr);
+ arguments.add (expr);
}
/**
@@ -50,8 +51,8 @@ public class Vala.CCodeFunctionCall : CCodeExpression {
*
* @return list of arguments
*/
- public List<weak CCodeExpression> get_arguments () {
- return arguments.copy ();
+ public Gee.List<CCodeExpression> get_arguments () {
+ return new ReadOnlyList<CCodeExpression> (arguments);
}
public override void write (CCodeWriter! writer) {
diff --git a/ccode/valaccodefunctiondeclarator.vala b/ccode/valaccodefunctiondeclarator.vala
index 663456f24..ac96f07d3 100644
--- a/ccode/valaccodefunctiondeclarator.vala
+++ b/ccode/valaccodefunctiondeclarator.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a function pointer declarator in the C code.
@@ -29,12 +30,11 @@ public class Vala.CCodeFunctionDeclarator : CCodeDeclarator {
/**
* The declarator name.
*/
- public string! name { get; set construct; }
+ public string! name { get; set; }
- private List<CCodeFormalParameter> parameters;
+ private Gee.List<CCodeFormalParameter> parameters = new ArrayList<CCodeFormalParameter> ();
- public CCodeFunctionDeclarator (string! n) {
- name = n;
+ public CCodeFunctionDeclarator (construct string! name) {
}
/**
@@ -43,7 +43,7 @@ public class Vala.CCodeFunctionDeclarator : CCodeDeclarator {
* @param param a formal parameter
*/
public void add_parameter (CCodeFormalParameter! param) {
- parameters.append (param);
+ parameters.add (param);
}
public override void write (CCodeWriter! writer) {
diff --git a/ccode/valaccodeinitializerlist.vala b/ccode/valaccodeinitializerlist.vala
index fcbe00590..f2b007d93 100644
--- a/ccode/valaccodeinitializerlist.vala
+++ b/ccode/valaccodeinitializerlist.vala
@@ -1,6 +1,6 @@
/* valaccodeinitializerlist.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 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
@@ -21,12 +21,13 @@
*/
using GLib;
+using Gee;
/**
* Represents a struct or array initializer list in the C code.
*/
public class Vala.CCodeInitializerList : CCodeExpression {
- private List<CCodeExpression> initializers;
+ private Gee.List<CCodeExpression> initializers = new ArrayList<CCodeExpression> ();
/**
* Appends the specified expression to this initializer list.
@@ -34,7 +35,7 @@ public class Vala.CCodeInitializerList : CCodeExpression {
* @param expr an expression
*/
public void append (CCodeExpression! expr) {
- initializers.append (expr);
+ initializers.add (expr);
}
public override void write (CCodeWriter! writer) {
diff --git a/ccode/valaccodestruct.vala b/ccode/valaccodestruct.vala
index 30e6be2d3..2b92226e6 100644
--- a/ccode/valaccodestruct.vala
+++ b/ccode/valaccodestruct.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a struct declaration in the C code.
@@ -29,12 +30,11 @@ public class Vala.CCodeStruct : CCodeNode {
/**
* The struct name.
*/
- public string! name { get; set construct; }
+ public string! name { get; set; }
- private List<CCodeDeclaration> declarations;
+ private Gee.List<CCodeDeclaration> declarations = new ArrayList<CCodeDeclaration> ();
- public CCodeStruct (string! n) {
- name = n;
+ public CCodeStruct (construct string! name) {
}
/**
@@ -43,7 +43,7 @@ public class Vala.CCodeStruct : CCodeNode {
* @param decl a variable declaration
*/
public void add_declaration (CCodeDeclaration! decl) {
- declarations.append (decl);
+ declarations.add (decl);
}
/**
diff --git a/ccode/valaccodeswitchstatement.vala b/ccode/valaccodeswitchstatement.vala
index fb4b49bf3..8a12d8d88 100644
--- a/ccode/valaccodeswitchstatement.vala
+++ b/ccode/valaccodeswitchstatement.vala
@@ -1,6 +1,6 @@
/* valaccodeswitchstatement.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 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
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a switch selection statement in the C code.
@@ -29,12 +30,11 @@ public class Vala.CCodeSwitchStatement : CCodeStatement {
/**
* The switch expression.
*/
- public CCodeExpression! expression { get; set construct; }
+ public CCodeExpression! expression { get; set; }
- private List<CCodeCaseStatement> case_statements;
+ private Gee.List<CCodeCaseStatement> case_statements = new ArrayList<CCodeCaseStatement> ();
- public CCodeSwitchStatement (CCodeExpression! expr) {
- expression = expr;
+ public CCodeSwitchStatement (construct CCodeExpression! expression) {
}
/**
@@ -43,7 +43,7 @@ public class Vala.CCodeSwitchStatement : CCodeStatement {
* @param case_stmt a case statement
*/
public void add_case (CCodeCaseStatement! case_stmt) {
- case_statements.append (case_stmt);
+ case_statements.add (case_stmt);
}
public override void write (CCodeWriter! writer) {
diff --git a/compiler/Makefile.am b/compiler/Makefile.am
index 8b3e00cdf..750d0ee43 100644
--- a/compiler/Makefile.am
+++ b/compiler/Makefile.am
@@ -18,7 +18,7 @@ valac_SOURCES = \
$(NULL)
valac.vala.stamp: $(filter %.vala,$(valac_SOURCES))
- $(VALAC) --vapidir $(srcdir)/../vapi --vapidir ../ccode --pkg ccode --vapidir ../vala --pkg vala --vapidir ../gobject --pkg gobject --pkg config $^
+ $(VALAC) --vapidir $(srcdir)/../vapi --vapidir ../gee --pkg gee --vapidir ../ccode --pkg ccode --vapidir ../vala --pkg vala --vapidir ../gobject --pkg gobject --pkg config $^
touch $@
valac_CPPFLAGS = \
diff --git a/configure.ac b/configure.ac
index 9fc77c5d3..208c34fa4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,6 +37,7 @@ AC_SUBST(GLIB_LIBS)
AC_CONFIG_FILES([Makefile
vala-1.0.pc
+ gee/Makefile
ccode/Makefile
vala/Makefile
gobject/Makefile
diff --git a/gee/Makefile.am b/gee/Makefile.am
new file mode 100644
index 000000000..9570518aa
--- /dev/null
+++ b/gee/Makefile.am
@@ -0,0 +1,82 @@
+NULL =
+
+INCLUDES = \
+ $(GLIB_CFLAGS) \
+ $(NULL)
+
+BUILT_SOURCES = gee.vala.stamp
+
+noinst_LTLIBRARIES = \
+ libgee.la
+ $(NULL)
+
+libgee_la_SOURCES = \
+ gee.vala.stamp \
+ arraylist.c \
+ arraylist.h \
+ arraylist.vala \
+ collection.c \
+ collection.h \
+ collection.vala \
+ hashmap.c \
+ hashmap.h \
+ hashmap.vala \
+ hashset.c \
+ hashset.h \
+ hashset.vala \
+ iterable.c \
+ iterable.h \
+ iterable.vala \
+ iterator.c \
+ iterator.h \
+ iterator.vala \
+ list.c \
+ list.h \
+ list.vala \
+ map.c \
+ map.h \
+ map.vala \
+ readonlycollection.c \
+ readonlycollection.h \
+ readonlycollection.vala \
+ readonlylist.c \
+ readonlylist.h \
+ readonlylist.vala \
+ readonlymap.c \
+ readonlymap.h \
+ readonlymap.vala \
+ readonlyset.c \
+ readonlyset.h \
+ readonlyset.vala \
+ set.c \
+ set.h \
+ set.vala \
+ $(NULL)
+
+geeincludedir = $(includedir)/vala-1.0/gee
+
+geeinclude_HEADERS = \
+ arraylist.h \
+ collection.h \
+ hashmap.h \
+ hashset.h \
+ iterable.h \
+ iterator.h \
+ list.h \
+ map.h \
+ readonlycollection.h \
+ readonlylist.h \
+ readonlymap.h \
+ readonlyset.h \
+ set.h \
+ $(NULL)
+
+gee.vala gee.vala.stamp: $(filter %.vala,$(libgee_la_SOURCES))
+ $(VALAC) --vapidir $(srcdir)/../vapi --library gee $^
+ touch $@
+
+libgee_la_LIBADD = \
+ $(GLIB_LIBS) \
+ $(NULL)
+
+EXTRA_DIST = gee.vala gee.vala.stamp
diff --git a/gee/arraylist.vala b/gee/arraylist.vala
new file mode 100644
index 000000000..9853bfd6c
--- /dev/null
+++ b/gee/arraylist.vala
@@ -0,0 +1,186 @@
+/* arraylist.vala
+ *
+ * Copyright (C) 2004-2005 Novell, Inc
+ * Copyright (C) 2005 David Waite
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+/**
+ * Arrays of arbitrary elements which grow automatically as elements are added.
+ */
+public class Gee.ArrayList<G> : Iterable<G>, Collection<G>, List<G> {
+ public int size {
+ get { return _size; }
+ }
+
+ public EqualFunc equal_func {
+ set { _equal_func = value; }
+ }
+
+ private G[] _items = new G[4];
+ private int _size;
+ private EqualFunc _equal_func;
+
+ // concurrent modification protection
+ private int _stamp = 0;
+
+ public ArrayList (construct EqualFunc equal_func = GLib.direct_equal) {
+ }
+
+ public Gee.Iterator<G> iterator () {
+ return new Iterator<G> (this);
+ }
+
+ public bool contains (G item) {
+ return (index_of (item) != -1);
+ }
+
+ public int index_of (G item) {
+ for (int index = 0; index < _size; index++) {
+ if (_equal_func (_items[index], item)) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ public G get (int index) {
+ assert (index >= 0 && index < _size);
+
+ return _items[index];
+ }
+
+ public void set (int index, G item) {
+ assert (index >= 0 && index < _size);
+
+ _items[index] = item;
+ }
+
+ public bool add (G item) {
+ if (_size == _items.length) {
+ grow_if_needed (1);
+ }
+ _items[_size++] = item;
+ _stamp++;
+ return true;
+ }
+
+ public void insert (int index, G item) {
+ assert (index >= 0 && index <= _size);
+
+ if (_size == _items.length) {
+ grow_if_needed (1);
+ }
+ shift (index, 1);
+ _items[index] = item;
+ _stamp++;
+ }
+
+ public bool remove (G item) {
+ for (int index = 0; index < _size; index++) {
+ if (_equal_func (_items[index], item)) {
+ remove_at (index);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void remove_at (int index) {
+ assert (index >= 0 && index < _size);
+
+ _items[index] = null;
+
+ shift (index + 1, -1);
+
+ _stamp++;
+ }
+
+ public void clear () {
+ for (int index = 0; index < _size; index++) {
+ _items[index] = null;
+ }
+ _size = 0;
+ _stamp++;
+ }
+
+ private void shift (int start, int delta) {
+ assert (start >= 0 && start <= _size && start >= -delta);
+
+ _items.move (start, start + delta, _size - start);
+
+ _size += delta;
+ }
+
+ private void grow_if_needed (int new_count) {
+ assert (new_count >= 0);
+
+ int minimum_size = _size + new_count;
+ if (minimum_size > _items.length) {
+ // double the capacity unless we add even more items at this time
+ set_capacity (new_count > _items.length ? minimum_size : 2 * _items.length);
+ }
+ }
+
+ private void set_capacity (int value) {
+ assert (value >= _size);
+
+ _items.resize (value);
+ }
+
+ private class Iterator<G> : Gee.Iterator<G> {
+ public ArrayList<G> list {
+ set {
+ _list = value;
+ _stamp = _list._stamp;
+ }
+ }
+
+ private ArrayList<G> _list;
+ private int _index = -1;
+
+ // concurrent modification protection
+ public int _stamp = 0;
+
+ public Iterator (construct ArrayList! list) {
+ }
+
+ public bool next () {
+ assert (_stamp == _list._stamp);
+ if (_index < _list._size) {
+ _index++;
+ }
+ return (_index < _list._size);
+ }
+
+ public G get () {
+ assert (_stamp == _list._stamp);
+
+ if (_index < 0 || _index >= _list._size) {
+ return null;
+ }
+
+ return _list.get (_index);
+ }
+ }
+}
+
diff --git a/gee/collection.vala b/gee/collection.vala
new file mode 100644
index 000000000..4b109084c
--- /dev/null
+++ b/gee/collection.vala
@@ -0,0 +1,68 @@
+/* collection.vala
+ *
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+/**
+ * Serves as the base interface for implementing collection classes. Defines
+ * size, iteration, and modification methods.
+ */
+public interface Gee.Collection<G> : Iterable<G> {
+ /**
+ * The number of items in this collection.
+ */
+ public abstract int size { get; }
+
+ /**
+ * Determines whether this collection contains the specified item.
+ *
+ * @param item the item to locate in the collection
+ *
+ * @return true if item is found, false otherwise
+ */
+ public abstract bool contains (G item);
+
+ /**
+ * Adds an item to this collection. Must not be called on read-only
+ * collections.
+ *
+ * @param item the item to add to the collection
+ *
+ * @return true if the collection has been changed, false otherwise
+ */
+ public abstract bool add (G item);
+
+ /**
+ * Removes the first occurence of an item from this collection. Must not
+ * be called on read-only collections.
+ *
+ * @param item the item to remove from the collection
+ *
+ * @return true if the collection has been changed, false otherwise
+ */
+ public abstract bool remove (G item);
+
+ /**
+ * Removes all items from this collection. Must not be called on
+ * read-only collections.
+ */
+ public abstract void clear ();
+}
+
diff --git a/gee/hashmap.vala b/gee/hashmap.vala
new file mode 100644
index 000000000..890bc7ad9
--- /dev/null
+++ b/gee/hashmap.vala
@@ -0,0 +1,332 @@
+/* hashmap.vala
+ *
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * Copyright (C) 1997-2000 GLib Team and others
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+/**
+ * Hashtable implementation of the Map interface.
+ */
+public class Gee.HashMap<K,V> : Map<K,V> {
+ public int size {
+ get { return _nnodes; }
+ }
+
+ public HashFunc key_hash_func {
+ set { _key_hash_func = value; }
+ }
+
+ public EqualFunc key_equal_func {
+ set { _key_equal_func = value; }
+ }
+
+ public EqualFunc value_equal_func {
+ set { _value_equal_func = value; }
+ }
+
+ private int _array_size;
+ private int _nnodes;
+ private Node<K,V>[] _nodes;
+
+ // concurrent modification protection
+ private int _stamp = 0;
+
+ private HashFunc _key_hash_func;
+ private EqualFunc _key_equal_func;
+ private EqualFunc _value_equal_func;
+
+ private const int MIN_SIZE = 11;
+ private const int MAX_SIZE = 13845163;
+
+ public HashMap (construct HashFunc key_hash_func = GLib.direct_hash, construct EqualFunc key_equal_func = GLib.direct_equal, construct EqualFunc value_equal_func = GLib.direct_equal) {
+ }
+
+ construct {
+ _array_size = MIN_SIZE;
+ _nodes = new Node<K,V>[_array_size];
+ }
+
+ public Set<K> get_keys () {
+ return new KeySet<K,V> (this);
+ }
+
+ public Collection<V> get_values () {
+ return new ValueCollection<K,V> (this);
+ }
+
+ private Node<K,V>* lookup_node (K key) {
+ uint hash_value = _key_hash_func (key);
+ Node<K,V>* node = &_nodes[hash_value % _array_size];
+ while ((*node) != null && (hash_value != (*node).key_hash || !_key_equal_func ((*node).key, key))) {
+ node = &((*node).next);
+ }
+ return node;
+ }
+
+ public bool contains (K key) {
+ Node<K,V>* node = lookup_node (key);
+ return (*node != null);
+ }
+
+ public V get (K key) {
+ weak Node<K,V> node = *lookup_node (key);
+ if (node != null) {
+ return node.value;
+ } else {
+ return null;
+ }
+ }
+
+ public void set (K key, V value) {
+ Node<K,V>* node = lookup_node (key);
+ if (*node != null) {
+ (*node).value = value;
+ } else {
+ uint hash_value = _key_hash_func (key);
+ *node = new Node<K,V> (key, value, hash_value);
+ _nnodes++;
+ resize ();
+ }
+ _stamp++;
+ }
+
+ public bool remove (K key) {
+ Node<K,V>* node = lookup_node (key);
+ if (*node != null) {
+ (*node).key = null;
+ (*node).value = null;
+ *node = (*node).next;
+ _nnodes--;
+ resize ();
+ _stamp++;
+ return true;
+ }
+ return false;
+ }
+
+ public void clear () {
+ for (int i = 0; i < _array_size; i++) {
+ Node<K,V> node = #_nodes[i];
+ while (node != null) {
+ Node next = #node.next;
+ node.key = null;
+ node.value = null;
+ node = #next;
+ }
+ }
+ _nnodes = 0;
+ resize ();
+ }
+
+ private void resize () {
+ if ((_array_size >= 3 * _nnodes && _array_size >= MIN_SIZE) ||
+ (3 * _array_size <= _nnodes && _array_size < MAX_SIZE)) {
+ int new_array_size = SpacedPrimes.closest (_nnodes);
+ new_array_size = new_array_size.clamp (MIN_SIZE, MAX_SIZE);
+
+ Node<K,V>[] new_nodes = new Node<K,V>[new_array_size];
+
+ for (int i = 0; i < _array_size; i++) {
+ Node<K,V> node;
+ Node<K,V> next;
+ for (node = #_nodes[i]; node != null; node = #next) {
+ next = #node.next;
+ uint hash_val = node.key_hash % new_array_size;
+ node.next = #new_nodes[hash_val];
+ new_nodes[hash_val] = #node;
+ }
+ }
+ _nodes = #new_nodes;
+ _array_size = new_array_size;
+ }
+ }
+
+ ~HashSet () {
+ clear ();
+ }
+
+ [ReferenceType]
+ private struct Node<K,V> {
+ public K key;
+ public V value;
+ public Node<K,V> next;
+ public uint key_hash;
+
+ public Node (K# k, V# v, uint hash) {
+ key = #k;
+ value = #v;
+ key_hash = hash;
+ }
+ }
+
+ private class KeySet<K,V> : Iterable<K>, Collection<K>, Set<K> {
+ public HashMap<K,V> map {
+ set { _map = value; }
+ }
+
+ private HashMap<K,V> _map;
+
+ public KeySet (construct HashMap! map) {
+ }
+
+ public Iterator<K> iterator () {
+ return new KeyIterator<K,V> (_map);
+ }
+
+ public int size {
+ get { return _map.size; }
+ }
+
+ public bool add (K key) {
+ assert_not_reached ();
+ return false;
+ }
+
+ public void clear () {
+ assert_not_reached ();
+ }
+
+ public bool remove (K key) {
+ assert_not_reached ();
+ return false;
+ }
+
+ public bool contains (K key) {
+ return _map.contains (key);
+ }
+ }
+
+ private class KeyIterator<K,V> : Iterator<K> {
+ public HashMap<K,V> map {
+ set {
+ _map = value;
+ _stamp = _map._stamp;
+ }
+ }
+
+ private HashMap<K,V> _map;
+ private int _index = -1;
+ private weak Node<K,V> _node;
+
+ // concurrent modification protection
+ private int _stamp;
+
+ public KeyIterator (construct HashMap! map) {
+ }
+
+ public bool next () {
+ if (_node != null) {
+ _node = _node.next;
+ }
+ while (_node == null && _index + 1 < _map._array_size) {
+ _index++;
+ _node = _map._nodes[_index];
+ }
+ return (_node != null);
+ }
+
+ public K get () {
+ assert (_stamp == _map._stamp);
+ assert (_node != null);
+ return _node.key;
+ }
+ }
+
+ private class ValueCollection<K,V> : Iterable<V>, Collection<V> {
+ public HashMap<K,V> map {
+ set { _map = value; }
+ }
+
+ private HashMap<K,V> _map;
+
+ public ValueCollection (construct HashMap! map) {
+ }
+
+ public Iterator<V> iterator () {
+ return new ValueIterator<K,V> (_map);
+ }
+
+ public int size {
+ get { return _map.size; }
+ }
+
+ public bool add (V value) {
+ assert_not_reached ();
+ }
+
+ public void clear () {
+ assert_not_reached ();
+ }
+
+ public bool remove (V value) {
+ assert_not_reached ();
+ }
+
+ public bool contains (V value) {
+ Iterator<V> it = iterator ();
+ while (it.next ()) {
+ if (_map._value_equal_func (it.get (), value)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ private class ValueIterator<K,V> : Iterator<V> {
+ public HashMap<K,V> map {
+ set {
+ _map = value;
+ _stamp = _map._stamp;
+ }
+ }
+
+ private HashMap<V,K> _map;
+ private int _index = -1;
+ private weak Node<K,V> _node;
+
+ // concurrent modification protection
+ private int _stamp;
+
+ public ValueIterator (construct HashMap! map) {
+ }
+
+ public bool next () {
+ if (_node != null) {
+ _node = _node.next;
+ }
+ while (_node == null && _index + 1 < _map._array_size) {
+ _index++;
+ _node = _map._nodes[_index];
+ }
+ return (_node != null);
+ }
+
+ public V get () {
+ assert (_stamp == _map._stamp);
+ assert (_node != null);
+ return _node.value;
+ }
+ }
+}
+
diff --git a/gee/hashset.vala b/gee/hashset.vala
new file mode 100644
index 000000000..f0bb5f46a
--- /dev/null
+++ b/gee/hashset.vala
@@ -0,0 +1,202 @@
+/* hashset.vala
+ *
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * Copyright (C) 1997-2000 GLib Team and others
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+/**
+ * Hashtable implementation of the Set interface.
+ */
+public class Gee.HashSet<G> : Iterable<G>, Collection<G>, Set<G> {
+ public int size {
+ get { return _nnodes; }
+ }
+
+ public HashFunc hash_func {
+ set { _hash_func = value; }
+ }
+
+ public EqualFunc equal_func {
+ set { _equal_func = value; }
+ }
+
+ private int _array_size;
+ private int _nnodes;
+ private Node<G>[] _nodes;
+
+ // concurrent modification protection
+ private int _stamp = 0;
+
+ private HashFunc _hash_func;
+ private EqualFunc _equal_func;
+
+ private const int MIN_SIZE = 11;
+ private const int MAX_SIZE = 13845163;
+
+ public HashSet (construct HashFunc hash_func = GLib.direct_hash, construct EqualFunc equal_func = GLib.direct_equal) {
+ }
+
+ construct {
+ _array_size = MIN_SIZE;
+ _nodes = new Node<G>[_array_size];
+ }
+
+ private Node<G>* lookup_node (G key) {
+ uint hash_value = _hash_func (key);
+ Node<G>* node = &_nodes[hash_value % _array_size];
+ while ((*node) != null && (hash_value != (*node).key_hash || !_equal_func ((*node).key, key))) {
+ node = &((*node).next);
+ }
+ return node;
+ }
+
+ public bool contains (G key) {
+ Node<G>* node = lookup_node (key);
+ return (*node != null);
+ }
+
+ public Gee.Iterator<G> iterator () {
+ return new Iterator<G> (this);
+ }
+
+ public bool add (G key) {
+ Node<G>* node = lookup_node (key);
+ if (*node != null) {
+ return false;
+ } else {
+ uint hash_value = _hash_func (key);
+ *node = new Node<G> (key, hash_value);
+ _nnodes++;
+ resize ();
+ _stamp++;
+ return true;
+ }
+ }
+
+ public bool remove (G key) {
+ Node<G>* node = lookup_node (key);
+ if (*node != null) {
+ (*node).key = null;
+ *node = (*node).next;
+ _nnodes--;
+ resize ();
+ _stamp++;
+ return true;
+ }
+ return false;
+ }
+
+ public void clear () {
+ for (int i = 0; i < _array_size; i++) {
+ Node<G> node = #_nodes[i];
+ while (node != null) {
+ Node next = #node.next;
+ node.key = null;
+ node = #next;
+ }
+ }
+ _nnodes = 0;
+ resize ();
+ }
+
+ private void resize () {
+ if ((_array_size >= 3 * _nnodes && _array_size >= MIN_SIZE) ||
+ (3 * _array_size <= _nnodes && _array_size < MAX_SIZE)) {
+ int new_array_size = SpacedPrimes.closest (_nnodes);
+ new_array_size = new_array_size.clamp (MIN_SIZE, MAX_SIZE);
+
+ Node<G>[] new_nodes = new Node<G>[new_array_size];
+
+ for (int i = 0; i < _array_size; i++) {
+ Node<G> node;
+ Node<G> next;
+ for (node = #_nodes[i]; node != null; node = #next) {
+ next = #node.next;
+ uint hash_val = node.key_hash % new_array_size;
+ node.next = #new_nodes[hash_val];
+ new_nodes[hash_val] = #node;
+ }
+ }
+ _nodes = #new_nodes;
+ _array_size = new_array_size;
+ }
+ }
+
+ ~HashSet () {
+ clear ();
+ }
+
+ [ReferenceType]
+ private struct Node<G> {
+ public G key;
+ public Node<G> next;
+ public uint key_hash;
+
+ public Node (G# k, uint hash) {
+ key = #k;
+ key_hash = hash;
+ }
+ }
+
+ private class Iterator<G> : Gee.Iterator<G> {
+ public HashSet<G> set {
+ set {
+ _set = value;
+ _stamp = _set._stamp;
+ // find first node
+ while (_node == null && _index + 1 < _set._array_size) {
+ _index++;
+ _node = _set._nodes[_index];
+ }
+ }
+ }
+
+ private HashSet<G> _set;
+ private int _index = -1;
+ private weak Node<G> _node;
+
+ // concurrent modification protection
+ private int _stamp = 0;
+
+ public Iterator (construct HashSet! set) {
+ }
+
+ public bool next () {
+ if (_node != null) {
+ _node = _node.next;
+ }
+ while (_node == null && _index + 1 < _set._array_size) {
+ _index++;
+ _node = _set._nodes[_index];
+ }
+ return (_node != null);
+ }
+
+ public G get () {
+ assert (_stamp == _set._stamp);
+ assert (_node != null);
+ return _node.key;
+ }
+ }
+}
+
diff --git a/gee/iterable.vala b/gee/iterable.vala
new file mode 100644
index 000000000..1b3e66dd7
--- /dev/null
+++ b/gee/iterable.vala
@@ -0,0 +1,37 @@
+/* iterable.vala
+ *
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+/**
+ * Implemented by classes that support a simple iteration over instances of the
+ * collection.
+ */
+public interface Gee.Iterable<G> {
+ /**
+ * Returns a Iterator that can be used for simple iteration over a
+ * collection.
+ *
+ * @return a Iterator that can be used for simple iteration over a
+ * collection
+ */
+ public abstract Iterator<G> iterator ();
+}
+
diff --git a/gee/iterator.vala b/gee/iterator.vala
new file mode 100644
index 000000000..a4019462c
--- /dev/null
+++ b/gee/iterator.vala
@@ -0,0 +1,42 @@
+/* iterator.vala
+ *
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+/**
+ * Implemented by classes that support a simple iteration over instances of the
+ * collection.
+ */
+public interface Gee.Iterator<G> {
+ /**
+ * Advances to the next element in the iteration.
+ *
+ * @return true if the iterator has a next element
+ */
+ public abstract bool next ();
+
+ /**
+ * Returns the current element in the iteration.
+ *
+ * @return the current element in the iteration
+ */
+ public abstract G get ();
+}
+
diff --git a/gee/list.vala b/gee/list.vala
new file mode 100644
index 000000000..0ff967b47
--- /dev/null
+++ b/gee/list.vala
@@ -0,0 +1,67 @@
+/* list.vala
+ *
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+/**
+ * Represents a collection of items in a well-defined order.
+ */
+public interface Gee.List<G> : GLib.Object, Collection<G> {
+ /**
+ * Returns the item at the specified index in this list.
+ *
+ * @param index zero-based index of the item to be returned
+ *
+ * @return the item at the specified index in the list
+ */
+ public abstract G get (int index);
+
+ /**
+ * Sets the item at the specified index in this list.
+ *
+ * @param index zero-based index of the item to be set
+ */
+ public abstract void set (int index, G item);
+
+ /**
+ * Returns the index of the first occurence of the specified item in
+ * this list.
+ *
+ * @return the index of the first occurence of the specified item, or
+ * -1 if the item could not be found
+ */
+ public abstract int index_of (G item);
+
+ /**
+ * Inserts an item into this list at the specified position.
+ *
+ * @param index zero-based index at which item is inserted
+ * @param item item to insert into the list
+ */
+ public abstract void insert (int index, G item);
+
+ /**
+ * Removes the item at the specified index of this list.
+ *
+ * @param index zero-based index of the item to be removed
+ */
+ public abstract void remove_at (int index);
+}
+
diff --git a/gee/map.vala b/gee/map.vala
new file mode 100644
index 000000000..6dcee69cf
--- /dev/null
+++ b/gee/map.vala
@@ -0,0 +1,88 @@
+/* map.vala
+ *
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+/**
+ * A map is a generic collection of key/value pairs.
+ */
+public interface Gee.Map<K,V> {
+ /**
+ * The number of items in this map.
+ */
+ public abstract int size { get; }
+
+ /**
+ * Returns the keys of this map as a read-only set.
+ *
+ * @return the keys of the map
+ */
+ public abstract Set<K> get_keys ();
+
+ /**
+ * Returns the values of this map as a read-only collection.
+ *
+ * @return the values of the map
+ */
+ public abstract Collection<V> get_values ();
+
+ /**
+ * Determines whether this map contains the specified key.
+ *
+ * @param key the key to locate in the map
+ *
+ * @return true if key is found, false otherwise
+ */
+ public abstract bool contains (K key);
+
+ /**
+ * Returns the value of the specified key in this map.
+ *
+ * @param key the key whose value is to be retrieved
+ *
+ * @return the value associated with the key, or null if the key
+ * couldn't be found
+ */
+ public abstract V get (K key);
+
+ /**
+ * Inserts a new key and value into this map.
+ *
+ * @param key the key to insert
+ * @param value the value to associate with the key
+ */
+ public abstract void set (K key, V value);
+
+ /**
+ * Removes the specified key from this map.
+ *
+ * @param key the key to remove from the map
+ *
+ * @return true if the map has been changed, false otherwise
+ */
+ public abstract bool remove (K key);
+
+ /**
+ * Removes all items from this collection. Must not be called on
+ * read-only collections.
+ */
+ public abstract void clear ();
+}
+
diff --git a/gee/readonlycollection.vala b/gee/readonlycollection.vala
new file mode 100644
index 000000000..30a6ea60f
--- /dev/null
+++ b/gee/readonlycollection.vala
@@ -0,0 +1,82 @@
+/* readonlycollection.vala
+ *
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+/**
+ * Represents a read-only collection of items.
+ */
+public class Gee.ReadOnlyCollection<G> : Iterable<G>, Collection<G> {
+ public int size {
+ get { return _collection.size; }
+ }
+
+ public Collection<G> collection {
+ set { _collection = value; }
+ }
+
+ private Collection<G> _collection;
+
+ public ReadOnlyCollection (construct Collection<G> collection = null) {
+ }
+
+ public Gee.Iterator<G> iterator () {
+ if (_collection == null) {
+ return new Iterator<G> ();
+ }
+
+ return _collection.iterator ();
+ }
+
+ public bool contains (G item) {
+ if (_collection == null) {
+ return false;
+ }
+
+ return _collection.contains (item);
+ }
+
+ public bool add (G item) {
+ assert_not_reached ();
+ return false;
+ }
+
+ public bool remove (G item) {
+ assert_not_reached ();
+ return false;
+ }
+
+ public void clear () {
+ assert_not_reached ();
+ }
+
+ private class Iterator<G> : Gee.Iterator<G> {
+ public bool next () {
+ return false;
+ }
+
+ public G get () {
+ return null;
+ }
+ }
+}
+
diff --git a/gee/readonlylist.vala b/gee/readonlylist.vala
new file mode 100644
index 000000000..b07fa4aeb
--- /dev/null
+++ b/gee/readonlylist.vala
@@ -0,0 +1,110 @@
+/* readonlylist.vala
+ *
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+/**
+ * Represents a read-only collection of items in a well-defined order.
+ */
+public class Gee.ReadOnlyList<G> : Iterable<G>, Collection<G>, List<G> {
+ public int size {
+ get { return _list.size; }
+ }
+
+ public List<G> list {
+ set { _list = value; }
+ }
+
+ private List<G> _list;
+
+ public ReadOnlyList (construct List<G> list = null) {
+ }
+
+ public Gee.Iterator<G> iterator () {
+ if (_list == null) {
+ return new Iterator<G> ();
+ }
+
+ return _list.iterator ();
+ }
+
+ public bool contains (G item) {
+ if (_list == null) {
+ return false;
+ }
+
+ return _list.contains (item);
+ }
+
+ public int index_of (G item) {
+ if (_list == null) {
+ return -1;
+ }
+
+ return _list.index_of (item);
+ }
+
+ public bool add (G item) {
+ assert_not_reached ();
+ return false;
+ }
+
+ public bool remove (G item) {
+ assert_not_reached ();
+ return false;
+ }
+
+ public void insert (int index, G item) {
+ assert_not_reached ();
+ }
+
+ public void remove_at (int index) {
+ assert_not_reached ();
+ }
+
+ public G get (int index) {
+ if (_list == null) {
+ return null;
+ }
+
+ return _list.get (index);
+ }
+
+ public void set (int index, G o) {
+ assert_not_reached ();
+ }
+
+ public void clear () {
+ assert_not_reached ();
+ }
+
+ class Iterator<G> : Gee.Iterator<G> {
+ public bool next () {
+ return false;
+ }
+
+ public G get () {
+ return null;
+ }
+ }
+}
+
diff --git a/gee/readonlymap.vala b/gee/readonlymap.vala
new file mode 100644
index 000000000..f36c9aaed
--- /dev/null
+++ b/gee/readonlymap.vala
@@ -0,0 +1,87 @@
+/* readonlymap.vala
+ *
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+/**
+ * Represents a read-only collection of key/value pairs.
+ */
+public class Gee.ReadOnlyMap<K,V> : Map<K,V> {
+ public int size {
+ get { return _map.size; }
+ }
+
+ public Map<K,V> map {
+ set { _map = value; }
+ }
+
+ private Map<K,V> _map;
+
+ public ReadOnlyMap (construct Map<K,V> map = null) {
+ }
+
+ public Set<K> get_keys () {
+ if (_map == null) {
+ return new ReadOnlySet<K> ();
+ }
+
+ return _map.get_keys ();
+ }
+
+ public Collection<V> get_values () {
+ if (_map == null) {
+ return new ReadOnlyCollection<V> ();
+ }
+
+ return _map.get_values ();
+ }
+
+ public bool contains (K key) {
+ if (_map == null) {
+ return false;
+ }
+
+ return _map.contains (key);
+ }
+
+ public V get (K key) {
+ if (_map == null) {
+ return null;
+ }
+
+ return _map.get (key);
+ }
+
+ public void set (K key, V value) {
+ assert_not_reached ();
+ }
+
+ public bool remove (K key) {
+ assert_not_reached ();
+ return false;
+ }
+
+ public void clear () {
+ assert_not_reached ();
+ }
+}
+
diff --git a/gee/readonlyset.vala b/gee/readonlyset.vala
new file mode 100644
index 000000000..81db5b3f8
--- /dev/null
+++ b/gee/readonlyset.vala
@@ -0,0 +1,82 @@
+/* readonlyset.vala
+ *
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+/**
+ * Represents a read-only collection of items without duplicates.
+ */
+public class Gee.ReadOnlySet<G> : Iterable<G>, Collection<G>, Set<G> {
+ public int size {
+ get { return _set.size; }
+ }
+
+ public Set<G> set {
+ set { _set = value; }
+ }
+
+ private Set<G> _set;
+
+ public ReadOnlySet (construct Set<G> set = null) {
+ }
+
+ public Gee.Iterator<G> iterator () {
+ if (_set == null) {
+ return new Iterator<G> ();
+ }
+
+ return _set.iterator ();
+ }
+
+ public bool contains (G item) {
+ if (_set == null) {
+ return false;
+ }
+
+ return _set.contains (item);
+ }
+
+ public bool add (G item) {
+ assert_not_reached ();
+ return false;
+ }
+
+ public bool remove (G item) {
+ assert_not_reached ();
+ return false;
+ }
+
+ public void clear () {
+ assert_not_reached ();
+ }
+
+ private class Iterator<G> : Gee.Iterator<G> {
+ public bool next () {
+ return false;
+ }
+
+ public G get () {
+ return null;
+ }
+ }
+}
+
diff --git a/gee/set.vala b/gee/set.vala
new file mode 100644
index 000000000..efdf7ae8d
--- /dev/null
+++ b/gee/set.vala
@@ -0,0 +1,28 @@
+/* set.vala
+ *
+ * Copyright (C) 2007 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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Jürg Billeter <j@bitron.ch>
+ */
+
+/**
+ * A set is a collection without duplicates.
+ */
+public interface Gee.Set<G> : Collection<G> {
+}
+
diff --git a/gobject/Makefile.am b/gobject/Makefile.am
index 248aec5d7..08758d407 100644
--- a/gobject/Makefile.am
+++ b/gobject/Makefile.am
@@ -76,7 +76,7 @@ gobjectinclude_HEADERS = \
$(NULL)
gobject.vala gobject.vala.stamp: $(filter %.vala,$(libvala_la_SOURCES))
- $(VALAC) --vapidir $(srcdir)/../vapi --vapidir ../ccode --pkg ccode --vapidir ../vala --pkg vala --library gobject $^
+ $(VALAC) --vapidir $(srcdir)/../vapi --vapidir ../gee --pkg gee --vapidir ../ccode --pkg ccode --vapidir ../vala --pkg vala --library gobject $^
touch $@
libvala_la_LIBADD = \
diff --git a/gobject/valaclassregisterfunction.vala b/gobject/valaclassregisterfunction.vala
index 8d5a9cf93..65bc28e42 100644
--- a/gobject/valaclassregisterfunction.vala
+++ b/gobject/valaclassregisterfunction.vala
@@ -29,7 +29,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
/**
* Specifies the class to be registered.
*/
- public Class! class_reference { get; set construct; }
+ public weak Class! class_reference { get; set; }
/**
* Creates a new C function to register the specified class at runtime.
diff --git a/gobject/valacodegenerator.vala b/gobject/valacodegenerator.vala
index f1cae2fec..236ce0b92 100644
--- a/gobject/valacodegenerator.vala
+++ b/gobject/valacodegenerator.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
/**
* Code visitor generating C Code.
@@ -65,15 +66,15 @@ public class Vala.CodeGenerator : CodeVisitor {
CCodeBlock block;
/* all temporary variables */
- List<VariableDeclarator> temp_vars;
+ ArrayList<VariableDeclarator> temp_vars = new ArrayList<VariableDeclarator> ();
/* temporary variables that own their content */
- List<VariableDeclarator> temp_ref_vars;
+ ArrayList<VariableDeclarator> temp_ref_vars = new ArrayList<VariableDeclarator> ();
/* cache to check whether a certain marshaller has been created yet */
- HashTable<string,bool> user_marshal_list;
+ Gee.Set<string> user_marshal_set;
/* (constant) hash table with all predefined marshallers */
- HashTable<string,bool> predefined_marshal_list;
+ Gee.Set<string> predefined_marshal_set;
/* (constant) hash table with all C keywords */
- HashTable<string,bool> c_keywords;
+ Gee.Set<string> c_keywords;
private int next_temp_var_id = 0;
private int current_try_id = 0;
@@ -120,69 +121,69 @@ public class Vala.CodeGenerator : CodeVisitor {
}
construct {
- predefined_marshal_list = new HashTable (str_hash, str_equal);
- predefined_marshal_list.insert ("VOID:VOID", true);
- predefined_marshal_list.insert ("VOID:BOOLEAN", true);
- predefined_marshal_list.insert ("VOID:CHAR", true);
- predefined_marshal_list.insert ("VOID:UCHAR", true);
- predefined_marshal_list.insert ("VOID:INT", true);
- predefined_marshal_list.insert ("VOID:UINT", true);
- predefined_marshal_list.insert ("VOID:LONG", true);
- predefined_marshal_list.insert ("VOID:ULONG", true);
- predefined_marshal_list.insert ("VOID:ENUM", true);
- predefined_marshal_list.insert ("VOID:FLAGS", true);
- predefined_marshal_list.insert ("VOID:FLOAT", true);
- predefined_marshal_list.insert ("VOID:DOUBLE", true);
- predefined_marshal_list.insert ("VOID:STRING", true);
- predefined_marshal_list.insert ("VOID:POINTER", true);
- predefined_marshal_list.insert ("VOID:OBJECT", true);
- predefined_marshal_list.insert ("STRING:OBJECT,POINTER", true);
- predefined_marshal_list.insert ("VOID:UINT,POINTER", true);
- predefined_marshal_list.insert ("BOOLEAN:FLAGS", true);
-
- c_keywords = new HashTable (str_hash, str_equal);
+ predefined_marshal_set = new HashSet<string> (str_hash, str_equal);
+ predefined_marshal_set.add ("VOID:VOID");
+ predefined_marshal_set.add ("VOID:BOOLEAN");
+ predefined_marshal_set.add ("VOID:CHAR");
+ predefined_marshal_set.add ("VOID:UCHAR");
+ predefined_marshal_set.add ("VOID:INT");
+ predefined_marshal_set.add ("VOID:UINT");
+ predefined_marshal_set.add ("VOID:LONG");
+ predefined_marshal_set.add ("VOID:ULONG");
+ predefined_marshal_set.add ("VOID:ENUM");
+ predefined_marshal_set.add ("VOID:FLAGS");
+ predefined_marshal_set.add ("VOID:FLOAT");
+ predefined_marshal_set.add ("VOID:DOUBLE");
+ predefined_marshal_set.add ("VOID:STRING");
+ predefined_marshal_set.add ("VOID:POINTER");
+ predefined_marshal_set.add ("VOID:OBJECT");
+ predefined_marshal_set.add ("STRING:OBJECT,POINTER");
+ predefined_marshal_set.add ("VOID:UINT,POINTER");
+ predefined_marshal_set.add ("BOOLEAN:FLAGS");
+
+ c_keywords = new HashSet<string> (str_hash, str_equal);
// C99 keywords
- c_keywords.insert ("_Bool", true);
- c_keywords.insert ("_Complex", true);
- c_keywords.insert ("_Imaginary", true);
- c_keywords.insert ("auto", true);
- c_keywords.insert ("break", true);
- c_keywords.insert ("case", true);
- c_keywords.insert ("char", true);
- c_keywords.insert ("const", true);
- c_keywords.insert ("continue", true);
- c_keywords.insert ("default", true);
- c_keywords.insert ("do", true);
- c_keywords.insert ("double", true);
- c_keywords.insert ("else", true);
- c_keywords.insert ("enum", true);
- c_keywords.insert ("extern", true);
- c_keywords.insert ("float", true);
- c_keywords.insert ("for", true);
- c_keywords.insert ("goto", true);
- c_keywords.insert ("if", true);
- c_keywords.insert ("inline", true);
- c_keywords.insert ("int", true);
- c_keywords.insert ("long", true);
- c_keywords.insert ("register", true);
- c_keywords.insert ("restrict", true);
- c_keywords.insert ("return", true);
- c_keywords.insert ("short", true);
- c_keywords.insert ("signed", true);
- c_keywords.insert ("sizeof", true);
- c_keywords.insert ("static", true);
- c_keywords.insert ("struct", true);
- c_keywords.insert ("switch", true);
- c_keywords.insert ("typedef", true);
- c_keywords.insert ("union", true);
- c_keywords.insert ("unsigned", true);
- c_keywords.insert ("void", true);
- c_keywords.insert ("volatile", true);
- c_keywords.insert ("while", true);
+ c_keywords.add ("_Bool");
+ c_keywords.add ("_Complex");
+ c_keywords.add ("_Imaginary");
+ c_keywords.add ("auto");
+ c_keywords.add ("break");
+ c_keywords.add ("case");
+ c_keywords.add ("char");
+ c_keywords.add ("const");
+ c_keywords.add ("continue");
+ c_keywords.add ("default");
+ c_keywords.add ("do");
+ c_keywords.add ("double");
+ c_keywords.add ("else");
+ c_keywords.add ("enum");
+ c_keywords.add ("extern");
+ c_keywords.add ("float");
+ c_keywords.add ("for");
+ c_keywords.add ("goto");
+ c_keywords.add ("if");
+ c_keywords.add ("inline");
+ c_keywords.add ("int");
+ c_keywords.add ("long");
+ c_keywords.add ("register");
+ c_keywords.add ("restrict");
+ c_keywords.add ("return");
+ c_keywords.add ("short");
+ c_keywords.add ("signed");
+ c_keywords.add ("sizeof");
+ c_keywords.add ("static");
+ c_keywords.add ("struct");
+ c_keywords.add ("switch");
+ c_keywords.add ("typedef");
+ c_keywords.add ("union");
+ c_keywords.add ("unsigned");
+ c_keywords.add ("void");
+ c_keywords.add ("volatile");
+ c_keywords.add ("while");
// MSVC keywords
- c_keywords.insert ("cdecl", true);
+ c_keywords.add ("cdecl");
}
/**
@@ -447,8 +448,8 @@ public class Vala.CodeGenerator : CodeVisitor {
ma.symbol_reference = f;
var array_len_lhs = get_array_length_cexpression (ma, 1);
- var sizes = ((ArrayCreationExpression) f.initializer).get_sizes ();
- var size = (Expression) sizes.data;
+ Gee.List<Expression> sizes = ((ArrayCreationExpression) f.initializer).get_sizes ();
+ var size = sizes[0];
instance_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (array_len_lhs, (CCodeExpression) size.ccodenode)));
}
}
@@ -791,11 +792,11 @@ public class Vala.CodeGenerator : CodeVisitor {
}
create_temp_decl (stmt, temp_vars);
- temp_vars = null;
+ temp_vars.clear ();
}
private string! get_variable_cname (string! name) {
- if (c_keywords.lookup (name)) {
+ if (c_keywords.contains (name)) {
return name + "_";
} else {
return name;
@@ -812,7 +813,7 @@ public class Vala.CodeGenerator : CodeVisitor {
len_decl.type_reference = new TypeReference ();
len_decl.type_reference.data_type = int_type.data_type;
- temp_vars.prepend (len_decl);
+ temp_vars.insert (0, len_decl);
}
}
@@ -834,7 +835,7 @@ public class Vala.CodeGenerator : CodeVisitor {
var ccomma = new CCodeCommaExpression ();
var temp_decl = get_temp_variable_declarator (decl.type_reference);
- temp_vars.prepend (temp_decl);
+ temp_vars.insert (0, temp_decl);
ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (temp_decl.name), rhs));
for (int dim = 1; dim <= arr.rank; dim++) {
@@ -1013,8 +1014,8 @@ public class Vala.CodeGenerator : CodeVisitor {
public override void visit_end_full_expression (Expression! expr) {
if (!memory_management) {
- temp_vars = null;
- temp_ref_vars = null;
+ temp_vars.clear ();
+ temp_ref_vars.clear ();
return;
}
@@ -1032,19 +1033,19 @@ public class Vala.CodeGenerator : CodeVisitor {
* expr.temp_vars = temp_vars;
* when deep list copying works
*/
- expr.temp_vars = null;
+ expr.temp_vars.clear ();
foreach (VariableDeclarator decl1 in temp_vars) {
- expr.temp_vars.append (decl1);
+ expr.temp_vars.add (decl1);
}
- temp_vars = null;
+ temp_vars.clear ();
- if (temp_ref_vars == null) {
+ if (((Gee.List<VariableDeclarator>) temp_ref_vars).size == 0) {
/* nothing to do without temporary variables */
return;
}
var full_expr_decl = get_temp_variable_declarator (expr.static_type);
- expr.temp_vars.append (full_expr_decl);
+ expr.temp_vars.add (full_expr_decl);
var expr_list = new CCodeCommaExpression ();
expr_list.append_expression (new CCodeAssignment (new CCodeIdentifier (full_expr_decl.name), (CCodeExpression) expr.ccodenode));
@@ -1059,10 +1060,10 @@ public class Vala.CodeGenerator : CodeVisitor {
expr.ccodenode = expr_list;
- temp_ref_vars = null;
+ temp_ref_vars.clear ();
}
- private void append_temp_decl (CCodeFragment! cfrag, List<VariableDeclarator> temp_vars) {
+ private void append_temp_decl (CCodeFragment! cfrag, Collection<VariableDeclarator> temp_vars) {
foreach (VariableDeclarator decl in temp_vars) {
var cdecl = new CCodeDeclaration (decl.type_reference.get_cname (true, !decl.type_reference.takes_ownership));
@@ -1110,7 +1111,7 @@ public class Vala.CodeGenerator : CodeVisitor {
var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeIdentifier ("inner_error"), new CCodeConstant ("NULL"));
cfrag.append (new CCodeIfStatement (ccond, cerror_block));
- } else if (current_method != null && current_method.get_error_domains ().length () > 0) {
+ } else if (current_method != null && current_method.get_error_domains ().size > 0) {
// current method can fail, propagate error
// TODO ensure one of the error domains matches
@@ -1162,12 +1163,12 @@ public class Vala.CodeGenerator : CodeVisitor {
/* free temporary objects */
if (!memory_management) {
- temp_vars = null;
- temp_ref_vars = null;
+ temp_vars.clear ();
+ temp_ref_vars.clear ();
return;
}
- if (temp_vars == null) {
+ if (((Gee.List<VariableDeclarator>) temp_vars).size == 0) {
/* nothing to do without temporary variables */
return;
}
@@ -1185,14 +1186,14 @@ public class Vala.CodeGenerator : CodeVisitor {
stmt.ccodenode = cfrag;
- temp_vars = null;
- temp_ref_vars = null;
+ temp_vars.clear ();
+ temp_ref_vars.clear ();
}
- private void create_temp_decl (Statement! stmt, List<VariableDeclarator> temp_vars) {
+ private void create_temp_decl (Statement! stmt, Collection<VariableDeclarator> temp_vars) {
/* declare temporary variables */
- if (temp_vars == null) {
+ if (temp_vars.size == 0) {
/* nothing to do without temporary variables */
return;
}
@@ -1219,7 +1220,7 @@ public class Vala.CodeGenerator : CodeVisitor {
public override void visit_switch_statement (SwitchStatement! stmt) {
// we need a temporary variable to save the property value
var temp_decl = get_temp_variable_declarator (stmt.expression.static_type);
- stmt.expression.temp_vars.prepend (temp_decl);
+ stmt.expression.temp_vars.insert (0, temp_decl);
var ctemp = new CCodeIdentifier (temp_decl.name);
@@ -1231,7 +1232,7 @@ public class Vala.CodeGenerator : CodeVisitor {
create_temp_decl (stmt, stmt.expression.temp_vars);
- List<weak Statement> default_statements = null;
+ Collection<Statement> default_statements = null;
// generate nested if statements
CCodeStatement ctopstmt = null;
@@ -1371,7 +1372,7 @@ public class Vala.CodeGenerator : CodeVisitor {
var cfrag = new CCodeFragment ();
append_temp_decl (cfrag, temp_vars);
cbody.add_statement (cfrag);
- temp_vars = null;
+ temp_vars.clear ();
}
var cdecl = new CCodeDeclaration (stmt.type_reference.get_cname ());
@@ -1409,7 +1410,7 @@ public class Vala.CodeGenerator : CodeVisitor {
var cfrag = new CCodeFragment ();
append_temp_decl (cfrag, temp_vars);
cbody.add_statement (cfrag);
- temp_vars = null;
+ temp_vars.clear ();
}
var cdecl = new CCodeDeclaration (stmt.type_reference.get_cname ());
@@ -1467,7 +1468,7 @@ public class Vala.CodeGenerator : CodeVisitor {
var cfrag = new CCodeFragment ();
append_temp_decl (cfrag, temp_vars);
cbody.add_statement (cfrag);
- temp_vars = null;
+ temp_vars.clear ();
}
var cdecl = new CCodeDeclaration (stmt.type_reference.get_cname ());
@@ -1504,8 +1505,9 @@ public class Vala.CodeGenerator : CodeVisitor {
element_expr = convert_from_generic_pointer (element_expr, stmt.type_reference);
- List<weak TypeReference> type_arg_list = it_method.return_type.get_type_arguments ();
- var it_type = SemanticAnalyzer.get_actual_type (stmt.collection.static_type, it_method, (TypeReference) type_arg_list.data, stmt);
+ Iterator<TypeReference> type_arg_it = it_method.return_type.get_type_arguments ().iterator ();
+ type_arg_it.next ();
+ var it_type = SemanticAnalyzer.get_actual_type (stmt.collection.static_type, it_method, type_arg_it.get (), stmt);
if (stmt.type_reference.takes_ownership && !it_type.takes_ownership) {
var ma = new MemberAccess.simple (stmt.variable_name);
@@ -1516,7 +1518,7 @@ public class Vala.CodeGenerator : CodeVisitor {
var cfrag = new CCodeFragment ();
append_temp_decl (cfrag, temp_vars);
cbody.add_statement (cfrag);
- temp_vars = null;
+ temp_vars.clear ();
}
var cdecl = new CCodeDeclaration (stmt.type_reference.get_cname ());
@@ -1632,7 +1634,7 @@ public class Vala.CodeGenerator : CodeVisitor {
ccomma.append_expression (new CCodeIdentifier (return_expr_decl.name));
expr.ccodenode = ccomma;
- expr.temp_vars.append (return_expr_decl);
+ expr.temp_vars.add (return_expr_decl);
}
public override void visit_begin_return_statement (ReturnStatement! stmt) {
@@ -1694,7 +1696,7 @@ public class Vala.CodeGenerator : CodeVisitor {
ccomma.append_expression (new CCodeIdentifier (return_expr_decl.name));
stmt.return_expression.ccodenode = ccomma;
- stmt.return_expression.temp_vars.append (return_expr_decl);
+ stmt.return_expression.temp_vars.add (return_expr_decl);
}
create_local_free_expr (stmt.return_expression);
@@ -1854,7 +1856,7 @@ public class Vala.CodeGenerator : CodeVisitor {
var name_cnode = new CCodeIdentifier (temp_var.name);
int i = 0;
- temp_vars.prepend (temp_var);
+ temp_vars.insert (0, temp_var);
ce.append_expression (new CCodeAssignment (name_cnode, gnew));
@@ -1926,13 +1928,13 @@ public class Vala.CodeGenerator : CodeVisitor {
}
if (array_expr is ArrayCreationExpression) {
- List<weak Expression> size = ((ArrayCreationExpression) array_expr).get_sizes ();
- var length_expr = size.nth_data (dim - 1);
+ Gee.List<Expression> size = ((ArrayCreationExpression) array_expr).get_sizes ();
+ var length_expr = size[dim - 1];
return (CCodeExpression) length_expr.ccodenode;
} else if (array_expr is InvocationExpression) {
var invocation_expr = (InvocationExpression) array_expr;
- List<weak CCodeExpression> size = invocation_expr.get_array_sizes ();
- return size.nth_data (dim - 1);
+ Gee.List<CCodeExpression> size = invocation_expr.get_array_sizes ();
+ return size[dim - 1];
} else if (array_expr.symbol_reference != null) {
if (array_expr.symbol_reference is FormalParameter) {
var param = (FormalParameter) array_expr.symbol_reference;
@@ -2026,13 +2028,13 @@ public class Vala.CodeGenerator : CodeVisitor {
public override void visit_element_access (ElementAccess! expr)
{
- List<weak Expression> indices = expr.get_indices ();
- int rank = indices.length ();
+ Gee.List<Expression> indices = expr.get_indices ();
+ int rank = indices.size;
var container_type = expr.container.static_type.data_type;
var ccontainer = (CCodeExpression) expr.container.ccodenode;
- var cindex = (CCodeExpression) indices.nth_data (0).ccodenode;
+ var cindex = (CCodeExpression) indices[0].ccodenode;
if (container_type == string_type.data_type) {
// access to unichar in a string
var coffsetcall = new CCodeFunctionCall (new CCodeIdentifier ("g_utf8_offset_to_pointer"));
@@ -2047,8 +2049,10 @@ public class Vala.CodeGenerator : CodeVisitor {
(container_type == list_type || container_type.is_subtype_of (list_type) ||
container_type == map_type || container_type.is_subtype_of (map_type))) {
var get_method = (Method) container_type.scope.lookup ("get");
- List<weak FormalParameter> get_params = get_method.get_parameters ();
- var get_param = (FormalParameter) get_params.data;
+ Collection<FormalParameter> get_params = get_method.get_parameters ();
+ Iterator<FormalParameter> get_params_it = get_params.iterator ();
+ get_params_it.next ();
+ var get_param = get_params_it.get ();
if (get_param.type_reference.type_parameter != null) {
var index_type = SemanticAnalyzer.get_actual_type (expr.container.static_type, get_method, get_param.type_reference, expr);
@@ -2064,7 +2068,7 @@ public class Vala.CodeGenerator : CodeVisitor {
// access to element in an array
for (int i = 1; i < rank; i++) {
var cmul = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, cindex, get_array_length_cexpression (expr.container, i + 1));
- cindex = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, cmul, (CCodeExpression) indices.nth_data (i).ccodenode);
+ cindex = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, cmul, (CCodeExpression) indices[i].ccodenode);
}
expr.ccodenode = new CCodeElementAccess (ccontainer, cindex);
}
@@ -2086,7 +2090,7 @@ public class Vala.CodeGenerator : CodeVisitor {
// assign current value to temp variable
var temp_decl = get_temp_variable_declarator (prop.type_reference);
- temp_vars.prepend (temp_decl);
+ temp_vars.insert (0, temp_decl);
ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (temp_decl.name), (CCodeExpression) expr.inner.ccodenode));
// increment/decrement property
@@ -2143,7 +2147,7 @@ public class Vala.CodeGenerator : CodeVisitor {
return ccall;
} else {
var decl = get_temp_variable_declarator (expr.static_type, false);
- temp_vars.prepend (decl);
+ temp_vars.insert (0, decl);
var ctemp = new CCodeIdentifier (decl.name);
@@ -2214,8 +2218,8 @@ public class Vala.CodeGenerator : CodeVisitor {
if (expr.ref_leaked) {
var decl = get_temp_variable_declarator (expr.static_type);
- temp_vars.prepend (decl);
- temp_ref_vars.prepend (decl);
+ temp_vars.insert (0, decl);
+ temp_ref_vars.insert (0, decl);
expr.ccodenode = new CCodeParenthesizedExpression (new CCodeAssignment (new CCodeIdentifier (get_variable_cname (decl.name)), (CCodeExpression) expr.ccodenode));
} else if (expr.ref_missing) {
expr.ccodenode = get_ref_expression (expr);
@@ -2268,11 +2272,11 @@ public class Vala.CodeGenerator : CodeVisitor {
bool ellipsis = false;
int i = 1;
- weak List<weak FormalParameter> params_it = params;
+ Iterator<FormalParameter> params_it = params.iterator ();
foreach (Expression arg in expr.get_argument_list ()) {
CCodeExpression cexpr = (CCodeExpression) arg.ccodenode;
- if (params_it != null) {
- var param = (FormalParameter) params_it.data;
+ if (params_it.next ()) {
+ var param = params_it.get ();
ellipsis = param.ellipsis;
if (!param.ellipsis
&& param.type_reference.data_type != null
@@ -2288,13 +2292,9 @@ public class Vala.CodeGenerator : CodeVisitor {
ccall.add_argument (cexpr);
i++;
-
- if (params_it != null) {
- params_it = params_it.next;
- }
}
- while (params_it != null) {
- var param = (FormalParameter) params_it.data;
+ while (params_it.next ()) {
+ var param = params_it.get ();
if (param.ellipsis) {
ellipsis = true;
@@ -2313,8 +2313,6 @@ public class Vala.CodeGenerator : CodeVisitor {
ccall.add_argument ((CCodeExpression) param.default_expression.ccodenode);
i++;
-
- params_it = params_it.next;
}
if (expr.can_fail) {
@@ -2408,7 +2406,7 @@ public class Vala.CodeGenerator : CodeVisitor {
/* (tmp = var, var = null, tmp) */
var ccomma = new CCodeCommaExpression ();
var temp_decl = get_temp_variable_declarator (expr.static_type);
- temp_vars.prepend (temp_decl);
+ temp_vars.insert (0, temp_decl);
var cvar = new CCodeIdentifier (temp_decl.name);
ccomma.append_expression (new CCodeAssignment (cvar, (CCodeExpression) expr.inner.ccodenode));
diff --git a/gobject/valacodegeneratorassignment.vala b/gobject/valacodegeneratorassignment.vala
index 591e39b4e..4633cf53b 100644
--- a/gobject/valacodegeneratorassignment.vala
+++ b/gobject/valacodegeneratorassignment.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
public class Vala.CodeGenerator {
public override void visit_end_assignment (Assignment! a) {
@@ -153,7 +154,7 @@ public class Vala.CodeGenerator {
// get signal id
var ccomma = new CCodeCommaExpression ();
var temp_decl = get_temp_variable_declarator (uint_type);
- temp_vars.prepend (temp_decl);
+ temp_vars.insert (0, temp_decl);
var parse_call = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_parse_name"));
parse_call.add_argument (sig.get_canonical_cconstant ());
var decl_type = (DataType) sig.parent_symbol;
@@ -206,17 +207,21 @@ public class Vala.CodeGenerator {
var expr = (ElementAccess) a.left;
var container_type = expr.container.static_type.data_type;
- List<weak Expression> indices = expr.get_indices ();
+ Collection<Expression> indices = expr.get_indices ();
+ Iterator<Expression> indices_it = indices.iterator ();
+ indices_it.next ();
var ccontainer = (CCodeExpression) expr.container.ccodenode;
- var cindex = (CCodeExpression) indices.nth_data (0).ccodenode;
+ var cindex = (CCodeExpression) indices_it.get ().ccodenode;
if (container_type != null && list_type != null && map_type != null &&
(container_type == list_type || container_type.is_subtype_of (list_type) ||
container_type == map_type || container_type.is_subtype_of (map_type))) {
var set_method = (Method) container_type.scope.lookup ("set");
- List<weak FormalParameter> set_params = set_method.get_parameters ();
- var set_param = (FormalParameter) set_params.data;
+ Collection<FormalParameter> set_params = set_method.get_parameters ();
+ Iterator<FormalParameter> set_params_it = set_params.iterator ();
+ set_params_it.next ();
+ var set_param = set_params_it.get ();
if (set_param.type_reference.type_parameter != null) {
var index_type = SemanticAnalyzer.get_actual_type (expr.container.static_type, set_method, set_param.type_reference, a);
@@ -255,7 +260,7 @@ public class Vala.CodeGenerator {
var ccomma = new CCodeCommaExpression ();
var temp_decl = get_temp_variable_declarator (a.left.static_type);
- temp_vars.prepend (temp_decl);
+ temp_vars.insert (0, temp_decl);
ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (temp_decl.name), rhs));
if (unref_old) {
/* unref old value */
@@ -304,7 +309,7 @@ public class Vala.CodeGenerator {
var cea = (CCodeElementAccess) a.left.ccodenode;
if (!(cea.index is CCodeConstant || cea.index is CCodeIdentifier)) {
var index_temp_decl = get_temp_variable_declarator (int_type);
- temp_vars.prepend (index_temp_decl);
+ temp_vars.insert (0, index_temp_decl);
var ccomma = new CCodeCommaExpression ();
ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (index_temp_decl.name), cea.index));
diff --git a/gobject/valacodegeneratorclass.vala b/gobject/valacodegeneratorclass.vala
index 2db8b2160..f38322ef5 100644
--- a/gobject/valacodegeneratorclass.vala
+++ b/gobject/valacodegeneratorclass.vala
@@ -122,7 +122,7 @@ public class Vala.CodeGenerator {
}
add_instance_init_function (cl);
- if ((memory_management && cl.get_fields () != null) || cl.destructor != null) {
+ if ((memory_management && cl.get_fields ().size > 0) || cl.destructor != null) {
add_dispose_function (cl);
}
@@ -201,15 +201,14 @@ public class Vala.CodeGenerator {
}
/* set dispose function */
- if (memory_management && cl.get_fields () != null) {
+ if (memory_management && cl.get_fields ().size > 0) {
var ccast = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_CLASS"));
ccast.add_argument (new CCodeIdentifier ("klass"));
init_block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (ccast, "dispose"), new CCodeIdentifier ("%s_dispose".printf (cl.get_lower_case_cname (null))))));
}
/* connect overridden methods */
- var methods = cl.get_methods ();
- foreach (Method m in methods) {
+ foreach (Method m in cl.get_methods ()) {
if (m.base_method == null) {
continue;
}
@@ -313,8 +312,7 @@ public class Vala.CodeGenerator {
var parent_assignment = new CCodeAssignment (new CCodeIdentifier (parent_iface_var), ccall);
init_block.add_statement (new CCodeExpressionStatement (parent_assignment));
- var methods = cl.get_methods ();
- foreach (Method m in methods) {
+ foreach (Method m in cl.get_methods ()) {
if (m.base_interface_method == null) {
continue;
}
diff --git a/gobject/valacodegeneratorinterface.vala b/gobject/valacodegeneratorinterface.vala
index 29253dd5f..1669ed8e0 100644
--- a/gobject/valacodegeneratorinterface.vala
+++ b/gobject/valacodegeneratorinterface.vala
@@ -156,7 +156,7 @@ public class Vala.CodeGenerator {
csignew.add_argument (marshal_arg);
var params = sig.get_parameters ();
- var params_len = params.length ();
+ var params_len = params.size;
if (sig.return_type.type_parameter != null) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else if (sig.return_type.data_type == null) {
diff --git a/gobject/valacodegeneratorinvocationexpression.vala b/gobject/valacodegeneratorinvocationexpression.vala
index 104f285c0..306fecedf 100644
--- a/gobject/valacodegeneratorinvocationexpression.vala
+++ b/gobject/valacodegeneratorinvocationexpression.vala
@@ -22,13 +22,14 @@
*/
using GLib;
+using Gee;
public class Vala.CodeGenerator {
public override void visit_end_invocation_expression (InvocationExpression! expr) {
var ccall = new CCodeFunctionCall ((CCodeExpression) expr.call.ccodenode);
Method m = null;
- List<weak FormalParameter> params;
+ Collection<FormalParameter> params;
if (!(expr.call is MemberAccess)) {
expr.error = true;
@@ -106,14 +107,14 @@ public class Vala.CodeGenerator {
bool ellipsis = false;
var i = 1;
- weak List<weak FormalParameter> params_it = params;
+ Iterator<FormalParameter> params_it = params.iterator ();
foreach (Expression arg in expr.get_argument_list ()) {
/* explicitly use strong reference as ccall gets
* unrefed at end of inner block
*/
CCodeExpression cexpr = (CCodeExpression) arg.ccodenode;
- if (params_it != null) {
- var param = (FormalParameter) params_it.data;
+ if (params_it.next ()) {
+ var param = params_it.get ();
ellipsis = param.ellipsis;
if (!ellipsis) {
if (param.type_reference.data_type != null
@@ -142,13 +143,9 @@ public class Vala.CodeGenerator {
ccall.add_argument (cexpr);
i++;
-
- if (params_it != null) {
- params_it = params_it.next;
- }
}
- while (params_it != null) {
- var param = (FormalParameter) params_it.data;
+ while (params_it.next ()) {
+ var param = params_it.get ();
if (param.ellipsis) {
ellipsis = true;
@@ -175,8 +172,6 @@ public class Vala.CodeGenerator {
ccall.add_argument ((CCodeExpression) param.default_expression.ccodenode);
i++;
-
- params_it = params_it.next;
}
/* add length argument for methods returning arrays */
@@ -187,7 +182,7 @@ public class Vala.CodeGenerator {
var temp_decl = get_temp_variable_declarator (int_type);
var temp_ref = new CCodeIdentifier (temp_decl.name);
- temp_vars.prepend (temp_decl);
+ temp_vars.insert (0, temp_decl);
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
@@ -229,12 +224,14 @@ public class Vala.CodeGenerator {
if (m is ArrayResizeMethod) {
// FIXME: size expression must not be evaluated twice at runtime (potential side effects)
- var new_size = (CCodeExpression) ((CodeNode) expr.get_argument_list ().data).ccodenode;
+ Iterator<Expression> arg_it = expr.get_argument_list ().iterator ();
+ arg_it.next ();
+ var new_size = (CCodeExpression) arg_it.get ().ccodenode;
var temp_decl = get_temp_variable_declarator (int_type);
var temp_ref = new CCodeIdentifier (temp_decl.name);
- temp_vars.prepend (temp_decl);
+ temp_vars.insert (0, temp_decl);
/* memset needs string.h */
string_h_needed = true;
@@ -261,20 +258,20 @@ public class Vala.CodeGenerator {
var temp_decl = get_temp_variable_declarator (string_type);
var temp_ref = new CCodeIdentifier (temp_decl.name);
- temp_vars.prepend (temp_decl);
+ temp_vars.insert (0, temp_decl);
- List<weak CCodeExpression> args = ccall.get_arguments ();
+ Gee.List<CCodeExpression> args = ccall.get_arguments ();
var coffsetcall = new CCodeFunctionCall (new CCodeIdentifier ("g_utf8_offset_to_pointer"));
// full string
- coffsetcall.add_argument (args.nth_data (0));
+ coffsetcall.add_argument (args[0]);
// offset
- coffsetcall.add_argument (args.nth_data (1));
+ coffsetcall.add_argument (args[1]);
var coffsetcall2 = new CCodeFunctionCall (new CCodeIdentifier ("g_utf8_offset_to_pointer"));
coffsetcall2.add_argument (temp_ref);
// len
- coffsetcall2.add_argument (args.nth_data (2));
+ coffsetcall2.add_argument (args[2]);
var cndupcall = new CCodeFunctionCall (new CCodeIdentifier ("g_strndup"));
cndupcall.add_argument (temp_ref);
diff --git a/gobject/valacodegeneratormemberaccess.vala b/gobject/valacodegeneratormemberaccess.vala
index 7eaa2fbdc..f9ffa3103 100644
--- a/gobject/valacodegeneratormemberaccess.vala
+++ b/gobject/valacodegeneratormemberaccess.vala
@@ -126,7 +126,7 @@ public class Vala.CodeGenerator {
// we need a temporary variable to save the property value
var temp_decl = get_temp_variable_declarator (expr.static_type);
- temp_vars.prepend (temp_decl);
+ temp_vars.insert (0, temp_decl);
var ctemp = new CCodeIdentifier (temp_decl.name);
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, ctemp));
diff --git a/gobject/valacodegeneratormethod.vala b/gobject/valacodegeneratormethod.vala
index 252e83707..455dd6efe 100644
--- a/gobject/valacodegeneratormethod.vala
+++ b/gobject/valacodegeneratormethod.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
public class Vala.CodeGenerator {
public override void visit_method (Method! m) {
@@ -176,7 +177,7 @@ public class Vala.CodeGenerator {
function.add_parameter (instance_param);
}
- if (m.get_error_domains ().length () > 0) {
+ if (m.get_error_domains ().size > 0) {
var cparam = new CCodeFormalParameter ("error", "GError**");
function.add_parameter (cparam);
if (vdeclarator != null) {
@@ -511,18 +512,20 @@ public class Vala.CodeGenerator {
}
var params = m.get_parameters ();
- if (params.length () == 0) {
+ if (params.size == 0) {
// method may have no parameters
args_parameter = false;
return true;
}
-
- if (params.length () > 1) {
+
+ if (params.size > 1) {
// method must not have more than one parameter
return false;
}
- var param = (FormalParameter) params.data;
+ Iterator<FormalParameter> params_it = params.iterator ();
+ params_it.next ();
+ var param = params_it.get ();
if (param.type_reference.is_out) {
// parameter must not be an out parameter
diff --git a/gobject/valacodegeneratorsignal.vala b/gobject/valacodegeneratorsignal.vala
index 393171a8c..5cf59d615 100644
--- a/gobject/valacodegeneratorsignal.vala
+++ b/gobject/valacodegeneratorsignal.vala
@@ -40,8 +40,7 @@ public class Vala.CodeGenerator {
var params = sig.get_parameters ();
if (prefix == null) {
- // FIXME remove equality check with cast in next revision
- if (predefined_marshal_list.lookup (signature) != (bool) null) {
+ if (predefined_marshal_set.contains (signature)) {
prefix = "g_cclosure_marshal";
} else {
prefix = "g_cclosure_user_marshal";
@@ -114,8 +113,7 @@ public class Vala.CodeGenerator {
/* check whether a signal with the same signature already exists for this source file (or predefined) */
signature = get_signal_signature (sig);
- // FIXME remove equality checks with cast in next revision
- if (predefined_marshal_list.lookup (signature) != (bool) null || user_marshal_list.lookup (signature) != (bool) null) {
+ if (predefined_marshal_set.contains (signature) || user_marshal_set.contains (signature)) {
return;
}
@@ -231,7 +229,7 @@ public class Vala.CodeGenerator {
signal_marshaller.block = marshaller_body;
source_signal_marshaller_definition.append (signal_marshaller);
- user_marshal_list.insert (signature, true);
+ user_marshal_set.add (signature);
}
}
diff --git a/gobject/valacodegeneratorsourcefile.vala b/gobject/valacodegeneratorsourcefile.vala
index cb1e98472..579e79ae5 100644
--- a/gobject/valacodegeneratorsourcefile.vala
+++ b/gobject/valacodegeneratorsourcefile.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
public class Vala.CodeGenerator {
private CCodeIncludeDirective get_internal_include (string! filename) {
@@ -40,7 +41,7 @@ public class Vala.CodeGenerator {
source_signal_marshaller_definition = new CCodeFragment ();
source_signal_marshaller_declaration = new CCodeFragment ();
- user_marshal_list = new HashTable (str_hash, str_equal);
+ user_marshal_set = new HashSet<string> (str_hash, str_equal);
next_temp_var_id = 0;
@@ -53,33 +54,33 @@ public class Vala.CodeGenerator {
header_begin.append (new CCodeIncludeDirective ("glib-object.h"));
source_include_directives.append (new CCodeIncludeDirective (source_file.get_cheader_filename (), true));
- List<string> used_includes = null;
- used_includes.append ("glib.h");
- used_includes.append ("glib-object.h");
- used_includes.append (source_file.get_cheader_filename ());
+ Gee.List<string> used_includes = new ArrayList<string> (str_equal);
+ used_includes.add ("glib.h");
+ used_includes.add ("glib-object.h");
+ used_includes.add (source_file.get_cheader_filename ());
- foreach (string filename1 in source_file.get_header_external_includes ()) {
- if (used_includes.find_custom (filename1, strcmp) == null) {
- header_begin.append (new CCodeIncludeDirective (filename1));
- used_includes.append (filename1);
+ foreach (string filename in source_file.get_header_external_includes ()) {
+ if (!used_includes.contains (filename)) {
+ header_begin.append (new CCodeIncludeDirective (filename));
+ used_includes.add (filename);
}
}
- foreach (string filename2 in source_file.get_header_internal_includes ()) {
- if (used_includes.find_custom (filename2, strcmp) == null) {
- header_begin.append (get_internal_include (filename2));
- used_includes.append (filename2);
+ foreach (string filename in source_file.get_header_internal_includes ()) {
+ if (!used_includes.contains (filename)) {
+ header_begin.append (get_internal_include (filename));
+ used_includes.add (filename);
}
}
- foreach (string filename3 in source_file.get_source_external_includes ()) {
- if (used_includes.find_custom (filename3, strcmp) == null) {
- source_include_directives.append (new CCodeIncludeDirective (filename3));
- used_includes.append (filename3);
+ foreach (string filename in source_file.get_source_external_includes ()) {
+ if (!used_includes.contains (filename)) {
+ source_include_directives.append (new CCodeIncludeDirective (filename));
+ used_includes.add (filename);
}
}
- foreach (string filename4 in source_file.get_source_internal_includes ()) {
- if (used_includes.find_custom (filename4, strcmp) == null) {
- source_include_directives.append (get_internal_include (filename4));
- used_includes.append (filename4);
+ foreach (string filename in source_file.get_source_internal_includes ()) {
+ if (!used_includes.contains (filename)) {
+ source_include_directives.append (get_internal_include (filename));
+ used_includes.add (filename);
}
}
if (source_file.is_cycle_head) {
diff --git a/gobject/valainterfaceregisterfunction.vala b/gobject/valainterfaceregisterfunction.vala
index 44bdaaab6..b5a26a012 100644
--- a/gobject/valainterfaceregisterfunction.vala
+++ b/gobject/valainterfaceregisterfunction.vala
@@ -30,7 +30,7 @@ public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
/**
* Specifies the interface to be registered.
*/
- public Interface! interface_reference { get; set construct; }
+ public weak Interface! interface_reference { get; set; }
public InterfaceRegisterFunction (Interface! iface) {
interface_reference = iface;
diff --git a/vala/Makefile.am b/vala/Makefile.am
index 922b70abc..efa478461 100644
--- a/vala/Makefile.am
+++ b/vala/Makefile.am
@@ -425,11 +425,12 @@ valainclude_HEADERS = \
$(NULL)
vala.vala vala.vala.stamp: $(filter %.vala,$(libvalacore_la_SOURCES))
- $(VALAC) --vapidir $(srcdir)/../vapi --vapidir ../ccode --pkg ccode --library vala $^
+ $(VALAC) --vapidir $(srcdir)/../vapi --vapidir ../gee --pkg gee --vapidir ../ccode --pkg ccode --library vala $^
touch $@
libvalacore_la_LIBADD = \
$(GLIB_LIBS) \
+ ../gee/libgee.la \
../ccode/libvalaccode.la \
$(NULL)
diff --git a/vala/parser.y b/vala/parser.y
index 4e573ec1f..1799bb6f8 100644
--- a/vala/parser.y
+++ b/vala/parser.y
@@ -1740,8 +1740,8 @@ for_statement
}
| FOR OPEN_PARENS local_variable_declaration SEMICOLON opt_expression SEMICOLON opt_statement_expression_list CLOSE_PARENS embedded_statement
{
- GList *l;
- GList *decls;
+ GeeCollection *decls;
+ GeeIterator *decls_it;
ValaDeclarationStatement *decl_statement;
@@ -1757,8 +1757,10 @@ for_statement
decls = vala_local_variable_declaration_get_variable_declarators ($3);
- for (l = decls; l != NULL; l = l->next) {
- ValaVariableDeclarator *decl = l->data;
+ decls_it = gee_iterable_iterator (GEE_ITERABLE (decls));
+ g_object_unref (decls);
+ while (gee_iterator_next (decls_it)) {
+ ValaVariableDeclarator *decl = gee_iterator_get (decls_it);
ValaExpression *init = vala_variable_declarator_get_initializer (decl);
if (init != NULL) {
@@ -1772,7 +1774,7 @@ for_statement
vala_variable_declarator_set_initializer (decl, NULL);
}
}
- g_list_free (decls);
+ g_object_unref (decls_it);
decl_statement = vala_declaration_statement_new ($3, src);
g_object_unref ($3);
@@ -1781,6 +1783,7 @@ for_statement
g_object_unref (decl_statement);
if ($7 != NULL) {
+ GList *l;
for (l = $7; l != NULL; l = l->next) {
vala_for_statement_add_iterator (for_statement, l->data);
g_object_unref (l->data);
@@ -2130,7 +2133,6 @@ namespace_member_declaration
class_declaration
: comment opt_attributes opt_access_modifier opt_modifiers CLASS identifier opt_name_specifier opt_type_parameter_list opt_class_base
{
- GList *l;
ValaSourceReference *src;
char *name = $6;
@@ -2140,6 +2142,7 @@ class_declaration
if ($7 != NULL) {
ValaSourceReference *ns_src = src(@6);
+ g_object_unref (parent_symbol);
parent_symbol = vala_scope_lookup (parent_scope, $6);
if (parent_symbol != NULL) {
if (check_is_namespace (parent_symbol, src)) {
@@ -2190,6 +2193,7 @@ class_declaration
vala_class_set_is_static (VALA_CLASS (current_symbol), TRUE);
}
if ($8 != NULL) {
+ GList *l;
for (l = $8; l != NULL; l = l->next) {
vala_class_add_type_parameter (VALA_CLASS (current_symbol), l->data);
g_object_unref (l->data);
@@ -2197,6 +2201,7 @@ class_declaration
g_list_free ($8);
}
if ($9 != NULL) {
+ GList *l;
for (l = $9; l != NULL; l = l->next) {
vala_class_add_base_type (VALA_CLASS (current_symbol), l->data);
g_object_unref (l->data);
@@ -2886,6 +2891,7 @@ struct_header
if ($6 != NULL) {
ValaSourceReference *ns_src = src(@5);
+ g_object_unref (parent_symbol);
parent_symbol = vala_scope_lookup (parent_scope, $5);
if (parent_symbol != NULL) {
if (check_is_namespace (parent_symbol, src)) {
@@ -2933,6 +2939,8 @@ struct_header
}
g_list_free ($8);
}
+
+ g_object_unref (parent_symbol);
}
;
@@ -2980,6 +2988,7 @@ interface_declaration
if ($7 != NULL) {
ValaSourceReference *ns_src = src(@6);
+ g_object_unref (parent_symbol);
parent_symbol = vala_scope_lookup (parent_scope, $6);
if (parent_symbol != NULL) {
if (check_is_namespace (parent_symbol, src)) {
@@ -3101,6 +3110,7 @@ enum_declaration
if ($6 != NULL) {
ValaSourceReference *ns_src = src(@5);
+ g_object_unref (parent_symbol);
parent_symbol = vala_scope_lookup (parent_scope, $5);
if (parent_symbol != NULL) {
if (check_is_namespace (parent_symbol, src)) {
@@ -3208,6 +3218,7 @@ callback_declaration
if ($8 != NULL) {
ValaSourceReference *ns_src = src(@7);
+ g_object_unref (parent_symbol);
parent_symbol = vala_scope_lookup (parent_scope, $7);
if (parent_symbol != NULL) {
if (check_is_namespace (parent_symbol, src)) {
diff --git a/vala/valaarray.vala b/vala/valaarray.vala
index e545ec3da..d72ce9c4c 100644
--- a/vala/valaarray.vala
+++ b/vala/valaarray.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
/**
* Represents an array type i.e. everything with direct accessable elements.
@@ -31,12 +32,12 @@ public class Vala.Array : DataType {
/**
* DataType of which this is an array of.
*/
- public DataType element_type { get; set construct; }
+ public weak DataType element_type { get; set construct; }
/**
* TypeParameter of which this is an array of.
*/
- public TypeParameter element_type_parameter { get; set construct; }
+ public weak TypeParameter element_type_parameter { get; set construct; }
/**
* The rank of this array.
@@ -122,11 +123,11 @@ public class Vala.Array : DataType {
return "g_free";
}
- public override List<weak string> get_cheader_filenames () {
+ public override Collection<string> get_cheader_filenames () {
if (element_type != null) {
return element_type.get_cheader_filenames ();
} else {
- return null;
+ return base.get_cheader_filenames ();
}
}
diff --git a/vala/valaarraycreationexpression.vala b/vala/valaarraycreationexpression.vala
index aa2dfa013..6c6d6293b 100644
--- a/vala/valaarraycreationexpression.vala
+++ b/vala/valaarraycreationexpression.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
/**
* Represents an array creation expression e.g. "new int[] {1,2,3}".
@@ -40,7 +41,7 @@ public class Vala.ArrayCreationExpression : Expression {
/**
* The size for each dimension ascending from left to right.
*/
- private List<Expression> sizes;
+ private Gee.List<Expression> sizes = new ArrayList<Expression> ();
/**
* The root array initializer list.
@@ -51,21 +52,17 @@ public class Vala.ArrayCreationExpression : Expression {
* Add a size expression.
*/
public void append_size (Expression! size) {
- sizes.append (size);
+ sizes.add (size);
}
/**
* Get the sizes for all dimensions ascending from left to right.
*/
- public List<weak Expression> get_sizes () {
- return sizes.copy ();
+ public Gee.List<Expression> get_sizes () {
+ return new ReadOnlyList<Expression> (sizes);
}
- public ArrayCreationExpression (TypeReference _element_type, int _rank, InitializerList _initializer, SourceReference source) {
- element_type = _element_type;
- rank = _rank;
- initializer_list = _initializer;
- source_reference = source;
+ public ArrayCreationExpression (construct TypeReference element_type, construct int rank, construct InitializerList initializer_list, construct SourceReference source_reference) {
}
public override void accept (CodeVisitor! visitor) {
diff --git a/vala/valaattribute.vala b/vala/valaattribute.vala
index f43c0eebe..f2cd87f47 100644
--- a/vala/valaattribute.vala
+++ b/vala/valaattribute.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents an attribute specified in the source code.
@@ -34,7 +35,7 @@ public class Vala.Attribute : CodeNode {
/**
* Contains all specified attribute arguments.
*/
- public List<NamedArgument> args;
+ public Gee.List<NamedArgument> args = new ArrayList<NamedArgument> ();
/**
* Creates a new attribute.
@@ -52,7 +53,7 @@ public class Vala.Attribute : CodeNode {
* @param arg named argument
*/
public void add_argument (NamedArgument! arg) {
- args.append (arg);
+ args.add (arg);
}
/**
diff --git a/vala/valablock.vala b/vala/valablock.vala
index 94830a608..5d25bd950 100644
--- a/vala/valablock.vala
+++ b/vala/valablock.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a source code block.
@@ -32,8 +33,8 @@ public class Vala.Block : Symbol, Statement {
*/
public bool contains_jump_statement { get; set; }
- private List<Statement> statement_list;
- private List<VariableDeclarator> local_variables;
+ private Gee.List<Statement> statement_list = new ArrayList<Statement> ();
+ private Gee.List<VariableDeclarator> local_variables = new ArrayList<VariableDeclarator> ();
/**
* Creates a new block.
@@ -49,7 +50,7 @@ public class Vala.Block : Symbol, Statement {
* @param stmt a statement
*/
public void add_statement (Statement! stmt) {
- statement_list.append (stmt);
+ statement_list.add (stmt);
}
/**
@@ -57,8 +58,8 @@ public class Vala.Block : Symbol, Statement {
*
* @return statement list
*/
- public List<weak Statement> get_statements () {
- return statement_list.copy ();
+ public Collection<Statement> get_statements () {
+ return new ReadOnlyCollection<Statement> (statement_list);
}
/**
@@ -67,7 +68,7 @@ public class Vala.Block : Symbol, Statement {
* @param decl a variable declarator
*/
public void add_local_variable (VariableDeclarator! decl) {
- local_variables.append (decl);
+ local_variables.add (decl);
}
/**
@@ -75,8 +76,8 @@ public class Vala.Block : Symbol, Statement {
*
* @return variable declarator list
*/
- public List<weak VariableDeclarator> get_local_variables () {
- return local_variables.copy ();
+ public Collection<VariableDeclarator> get_local_variables () {
+ return new ReadOnlyCollection<VariableDeclarator> (local_variables);
}
public override void accept (CodeVisitor! visitor) {
diff --git a/vala/valacallback.vala b/vala/valacallback.vala
index a959fb198..5140382e6 100644
--- a/vala/valacallback.vala
+++ b/vala/valacallback.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a function callback type.
@@ -38,9 +39,9 @@ public class Vala.Callback : DataType {
*/
public bool instance { get; set; }
- private List<TypeParameter> type_parameters;
+ private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
- private List<FormalParameter> parameters;
+ private Gee.List<FormalParameter> parameters = new ArrayList<FormalParameter> ();
private string cname;
/**
@@ -60,7 +61,7 @@ public class Vala.Callback : DataType {
* @param p a type parameter
*/
public void add_type_parameter (TypeParameter! p) {
- type_parameters.append (p);
+ type_parameters.add (p);
p.type = this;
scope.add (p.name, p);
}
@@ -71,7 +72,7 @@ public class Vala.Callback : DataType {
* @param param a formal parameter
*/
public void add_parameter (FormalParameter! param) {
- parameters.append (param);
+ parameters.add (param);
scope.add (param.name, param);
}
@@ -80,8 +81,8 @@ public class Vala.Callback : DataType {
*
* @return parameter list
*/
- public List<weak FormalParameter> get_parameters () {
- return parameters.copy ();
+ public Collection<FormalParameter> get_parameters () {
+ return new ReadOnlyCollection<FormalParameter> (parameters);
}
/**
@@ -97,7 +98,7 @@ public class Vala.Callback : DataType {
}
var method_params = m.get_parameters ();
- weak List<weak FormalParameter> method_params_it = method_params;
+ Iterator<FormalParameter> method_params_it = method_params.iterator ();
bool first = true;
foreach (FormalParameter param in parameters) {
/* use first callback parameter as instance parameter if
@@ -110,20 +111,18 @@ public class Vala.Callback : DataType {
}
/* method is allowed to accept less arguments */
- if (method_params_it == null) {
+ if (!method_params_it.next ()) {
break;
}
- var method_param = (FormalParameter) method_params_it.data;
+ var method_param = method_params_it.get ();
if (!param.type_reference.stricter (method_param.type_reference)) {
return false;
}
-
- method_params_it = method_params_it.next;
}
/* method may not expect more arguments */
- if (method_params_it != null) {
+ if (method_params_it.next ()) {
return false;
}
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 2786aba86..17f3c2999 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a class declaration in the source code.
@@ -58,19 +59,19 @@ public class Vala.Class : DataType {
private bool _has_private_fields;
- private List<TypeParameter> type_parameters;
+ private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
- private List<TypeReference> base_types;
+ private Gee.List<TypeReference> base_types = new ArrayList<TypeReference> ();
- private List<Constant> constants;
- private List<Field> fields;
- private List<Method> methods;
- private List<Property> properties;
- private List<Signal> signals;
+ private Gee.List<Constant> constants = new ArrayList<Constant> ();
+ private Gee.List<Field> fields = new ArrayList<Field> ();
+ private Gee.List<Method> methods = new ArrayList<Method> ();
+ private Gee.List<Property> properties = new ArrayList<Property> ();
+ private Gee.List<Signal> signals = new ArrayList<Signal> ();
// inner types
- private List<Class> classes;
- private List<Struct> structs;
+ private Gee.List<Class> classes = new ArrayList<Class> ();
+ private Gee.List<Struct> structs = new ArrayList<Struct> ();
/**
* Specifies the default construction method.
@@ -94,9 +95,7 @@ public class Vala.Class : DataType {
* @param source reference to source code
* @return newly created class
*/
- public Class (string! _name, SourceReference source = null) {
- name = _name;
- source_reference = source;
+ public Class (construct string! name, construct SourceReference source_reference = null) {
}
/**
@@ -106,7 +105,7 @@ public class Vala.Class : DataType {
* @param type a class or interface reference
*/
public void add_base_type (TypeReference! type) {
- base_types.append (type);
+ base_types.add (type);
}
/**
@@ -114,8 +113,8 @@ public class Vala.Class : DataType {
*
* @return list of base types
*/
- public List<weak TypeReference> get_base_types () {
- return base_types.copy ();
+ public Collection<TypeReference> get_base_types () {
+ return new ReadOnlyCollection<TypeReference> (base_types);
}
/**
@@ -124,7 +123,7 @@ public class Vala.Class : DataType {
* @param p a type parameter
*/
public void add_type_parameter (TypeParameter! p) {
- type_parameters.append (p);
+ type_parameters.add (p);
p.type = this;
scope.add (p.name, p);
}
@@ -134,8 +133,8 @@ public class Vala.Class : DataType {
*
* @return list of type parameters
*/
- public List<weak TypeParameter> get_type_parameters () {
- return type_parameters.copy ();
+ public Collection<TypeParameter> get_type_parameters () {
+ return new ReadOnlyCollection<TypeParameter> (type_parameters);
}
/**
@@ -144,7 +143,7 @@ public class Vala.Class : DataType {
* @param c a constant
*/
public void add_constant (Constant! c) {
- constants.append (c);
+ constants.add (c);
scope.add (c.name, c);
}
@@ -156,7 +155,7 @@ public class Vala.Class : DataType {
public void add_field (Field! f) {
// non_null fields not yet supported due to initialization issues
f.type_reference.non_null = false;
- fields.append (f);
+ fields.add (f);
if (f.access == MemberAccessibility.PRIVATE && f.instance) {
_has_private_fields = true;
}
@@ -168,8 +167,8 @@ public class Vala.Class : DataType {
*
* @return list of fields
*/
- public List<weak Field> get_fields () {
- return fields.copy ();
+ public Collection<Field> get_fields () {
+ return new ReadOnlyCollection<Field> (fields);
}
/**
@@ -187,7 +186,7 @@ public class Vala.Class : DataType {
default_construction_method = m;
}
- methods.append (m);
+ methods.add (m);
scope.add (m.name, m);
}
@@ -196,8 +195,8 @@ public class Vala.Class : DataType {
*
* @return list of methods
*/
- public List<weak Method> get_methods () {
- return methods.copy ();
+ public Collection<Method> get_methods () {
+ return new ReadOnlyCollection<Method> (methods);
}
/**
@@ -206,7 +205,7 @@ public class Vala.Class : DataType {
* @param prop a property
*/
public void add_property (Property! prop, bool no_field = false) {
- properties.append (prop);
+ properties.add (prop);
scope.add (prop.name, prop);
prop.this_parameter = new FormalParameter ("this", new TypeReference ());
@@ -230,8 +229,8 @@ public class Vala.Class : DataType {
*
* @return list of properties
*/
- public List<weak Property> get_properties () {
- return properties.copy ();
+ public Collection<Property> get_properties () {
+ return new ReadOnlyCollection<Property> (properties);
}
/**
@@ -240,7 +239,7 @@ public class Vala.Class : DataType {
* @param sig a signal
*/
public void add_signal (Signal! sig) {
- signals.append (sig);
+ signals.add (sig);
scope.add (sig.name, sig);
}
@@ -249,8 +248,8 @@ public class Vala.Class : DataType {
*
* @return list of signals
*/
- public List<weak Signal> get_signals () {
- return signals.copy ();
+ public Collection<Signal> get_signals () {
+ return new ReadOnlyCollection<Signal> (signals);
}
/**
@@ -259,7 +258,7 @@ public class Vala.Class : DataType {
* @param cl a class
*/
public void add_class (Class! cl) {
- classes.append (cl);
+ classes.add (cl);
scope.add (cl.name, cl);
}
@@ -269,7 +268,7 @@ public class Vala.Class : DataType {
* @param st a struct
*/
public void add_struct (Struct! st) {
- structs.append (st);
+ structs.add (st);
scope.add (st.name, st);
}
diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala
index 4ae5d3f26..b99a45e11 100644
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* The root of the code tree.
@@ -84,12 +85,12 @@ public class Vala.CodeContext {
*/
public Method module_init_method { get; set; }
- List<SourceFile> source_files;
+ private Gee.List<SourceFile> source_files = new ArrayList<SourceFile> ();
private Namespace! _root = new Namespace (null);
- List<SourceFileCycle> cycles;
+ private Gee.List<SourceFileCycle> cycles = new ArrayList<SourceFileCycle> ();
- private List<string> packages;
+ private Gee.List<string> packages = new ArrayList<string> (str_equal);
/**
* The root namespace of the symbol tree.
@@ -105,8 +106,8 @@ public class Vala.CodeContext {
*
* @return list of source files
*/
- public List<weak SourceFile> get_source_files () {
- return source_files.copy ();
+ public Collection<SourceFile> get_source_files () {
+ return new ReadOnlyCollection<SourceFile> (source_files);
}
/**
@@ -115,7 +116,7 @@ public class Vala.CodeContext {
* @param file a source file
*/
public void add_source_file (SourceFile! file) {
- source_files.append (file);
+ source_files.add (file);
}
/**
@@ -123,8 +124,8 @@ public class Vala.CodeContext {
*
* @return list of used packages
*/
- public List<weak string> get_packages () {
- return packages.copy ();
+ public Collection<string> get_packages () {
+ return new ReadOnlyCollection<string> (packages);
}
/**
@@ -134,7 +135,7 @@ public class Vala.CodeContext {
* @return true if the specified package is being used
*/
public bool has_package (string! pkg) {
- return packages.find_custom (pkg, strcmp) != null;
+ return packages.contains (pkg);
}
/**
@@ -143,7 +144,7 @@ public class Vala.CodeContext {
* @param pkg a package name
*/
public void add_package (string! pkg) {
- packages.append (pkg);
+ packages.add (pkg);
}
/**
@@ -171,7 +172,7 @@ public class Vala.CodeContext {
}
if (file.mark == 0) {
- visit (file, null);
+ visit (file, new ArrayList<SourceFile> ());
}
}
@@ -179,7 +180,7 @@ public class Vala.CodeContext {
* hard dependencies on other files in the cycle
*/
foreach (SourceFileCycle cycle in cycles) {
- cycle.head = find_cycle_head ((SourceFile) cycle.files.data);
+ cycle.head = find_cycle_head (cycle.files.get (0));
cycle.head.is_cycle_head = true;
}
@@ -227,16 +228,12 @@ public class Vala.CodeContext {
return file;
}
- private void visit (SourceFile! file, List<SourceFile> chain) {
- /* no deep copy available yet
- * var l = chain.copy ();
- */
- List<weak SourceFile> l = null;
+ private void visit (SourceFile! file, Collection<SourceFile> chain) {
+ Gee.List<SourceFile> l = new ArrayList<SourceFile> ();
foreach (SourceFile chain_file in chain) {
- l.append (chain_file);
+ l.add (chain_file);
}
- l.append (file);
- /* end workaround */
+ l.add (file);
/* mark file as currently being visited */
file.mark = 1;
@@ -250,7 +247,7 @@ public class Vala.CodeContext {
/* found cycle */
var cycle = new SourceFileCycle ();
- cycles.append (cycle);
+ cycles.add (cycle);
bool cycle_start_found = false;
foreach (SourceFile cycle_file in l) {
@@ -275,29 +272,17 @@ public class Vala.CodeContext {
/* file is in an other cycle, merge the two cycles */
- /* broken memory management cycles.remove (cycle_file.cycle); */
- List<weak SourceFileCycle> newlist = null;
- foreach (SourceFileCycle oldcycle in cycles) {
- if (oldcycle != cycle_file.cycle) {
- newlist.append (oldcycle);
- }
- }
- cycles = null;
- foreach (SourceFileCycle newcycle in newlist) {
- cycles.append (newcycle);
- }
- newlist = null;
- /* end workaround for broken memory management */
+ cycles.remove (cycle_file.cycle);
foreach (SourceFile inner_cycle_file in cycle_file.cycle.files) {
if (inner_cycle_file.cycle != cycle) {
/* file in inner cycle not yet added to outer cycle */
- cycle.files.append (inner_cycle_file);
+ cycle.files.add (inner_cycle_file);
inner_cycle_file.cycle = cycle;
}
}
} else {
- cycle.files.append (cycle_file);
+ cycle.files.add (cycle_file);
cycle_file.cycle = cycle;
}
}
diff --git a/vala/valacodenode.vala b/vala/valacodenode.vala
index 245284c45..ecb4401f8 100644
--- a/vala/valacodenode.vala
+++ b/vala/valacodenode.vala
@@ -32,7 +32,7 @@ public abstract class Vala.CodeNode {
/**
* Parent of this code node.
*/
- public CodeNode parent_node { get; set; }
+ public weak CodeNode parent_node { get; set; }
/**
* References the location in the source file where this code node has
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index ac2eecd17..d419a52d6 100644
--- a/vala/valadatatype.vala
+++ b/vala/valadatatype.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a runtime data type. This data type may be defined in Vala source
@@ -36,12 +37,12 @@ public abstract class Vala.DataType : Symbol {
*/
public MemberAccessibility access;
- private List<string> cheader_filenames;
+ private Gee.List<string> cheader_filenames = new ArrayList<string> ();
private Pointer pointer_type;
/* holds the array types of this type; each rank is a separate one */
- private HashTable<int,Array> array_types;
+ private Map<int,Array> array_types;
/**
* Returns the name of this data type as it is used in C code.
@@ -178,19 +179,19 @@ public abstract class Vala.DataType : Symbol {
return null;
}
- public override List<weak string> get_cheader_filenames () {
- if (cheader_filenames == null) {
+ public override Collection<string> get_cheader_filenames () {
+ if (cheader_filenames.size == 0) {
/* default to header filenames of the namespace */
foreach (string filename in parent_symbol.get_cheader_filenames ()) {
add_cheader_filename (filename);
}
- if (cheader_filenames == null && source_reference != null && !source_reference.file.pkg) {
+ if (cheader_filenames.size == 0 && source_reference != null && !source_reference.file.pkg) {
// don't add default include directives for VAPI files
- cheader_filenames.append (source_reference.file.get_cinclude_filename ());
+ cheader_filenames.add (source_reference.file.get_cinclude_filename ());
}
}
- return cheader_filenames.copy ();
+ return new ReadOnlyCollection<string> (cheader_filenames);
}
/**
@@ -200,7 +201,7 @@ public abstract class Vala.DataType : Symbol {
* @param filename a C header filename
*/
public void add_cheader_filename (string! filename) {
- cheader_filenames.append (filename);
+ cheader_filenames.add (filename);
}
/**
@@ -231,12 +232,12 @@ public abstract class Vala.DataType : Symbol {
Array array_type = null;
if (array_types != null) {
- array_type = array_types.lookup (rank);
+ array_type = array_types[rank];
}
if (array_type == null) {
if (array_types == null) {
- array_types = new HashTable.full (direct_hash, direct_equal, null, g_object_unref);
+ array_types = new HashMap<int,Array> ();
}
var new_array_type = new Array (this, rank, source_reference);
@@ -252,7 +253,7 @@ public abstract class Vala.DataType : Symbol {
/* link the array type to the same source as the container type */
new_array_type.source_reference = this.source_reference;
- array_types.insert (rank, new_array_type);
+ array_types[rank] = new_array_type;
array_type = new_array_type;
}
diff --git a/vala/valaelementaccess.vala b/vala/valaelementaccess.vala
index d5c613bd6..b390d6979 100644
--- a/vala/valaelementaccess.vala
+++ b/vala/valaelementaccess.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
/**
* Represents an array access expression e.g. "a[1,2]".
@@ -35,19 +36,17 @@ public class Vala.ElementAccess : Expression {
/**
* Expressions representing the indices we want to access inside the container.
*/
- private List<Expression>! indices;
+ private Gee.List<Expression>! indices = new ArrayList<Expression> ();
public void append_index (Expression! index) {
- indices.append (index);
+ indices.add (index);
}
- public List<weak Expression> get_indices () {
- return indices.copy ();
+ public Gee.List<Expression> get_indices () {
+ return new ReadOnlyList<Expression> (indices);
}
- public ElementAccess (Expression _container, SourceReference source) {
- container = _container;
- source_reference = source;
+ public ElementAccess (construct Expression container, construct SourceReference source_reference) {
}
public override void accept (CodeVisitor! visitor) {
diff --git a/vala/valaenum.vala b/vala/valaenum.vala
index fd7c520f2..684855f1e 100644
--- a/vala/valaenum.vala
+++ b/vala/valaenum.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents an enum declaration in the source code.
@@ -31,8 +32,8 @@ public class Vala.Enum : DataType {
*/
public bool error_domain { get; set; }
- private List<EnumValue> values;
- private List<Method> methods;
+ private Gee.List<EnumValue> values = new ArrayList<EnumValue> ();
+ private Gee.List<Method> methods = new ArrayList<Method> ();
private string cname;
private string cprefix;
private string lower_case_cprefix;
@@ -54,7 +55,7 @@ public class Vala.Enum : DataType {
* @param value an enum value
*/
public void add_value (EnumValue! value) {
- values.append (value);
+ values.add (value);
scope.add (value.name, value);
}
@@ -76,7 +77,7 @@ public class Vala.Enum : DataType {
m.scope.add (m.this_parameter.name, m.this_parameter);
}
- methods.append (m);
+ methods.add (m);
scope.add (m.name, m);
}
@@ -85,8 +86,8 @@ public class Vala.Enum : DataType {
*
* @return list of methods
*/
- public List<weak Method> get_methods () {
- return methods.copy ();
+ public Collection<Method> get_methods () {
+ return new ReadOnlyCollection<Method> (methods);
}
public override void accept (CodeVisitor! visitor) {
diff --git a/vala/valaexpression.vala b/vala/valaexpression.vala
index ac47f2b8b..c37bc5670 100644
--- a/vala/valaexpression.vala
+++ b/vala/valaexpression.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Base class for all code nodes that might be used as an expression.
@@ -43,7 +44,7 @@ public abstract class Vala.Expression : CodeNode {
/**
* The symbol this expression refers to.
*/
- public Symbol symbol_reference { get; set; }
+ public weak Symbol symbol_reference { get; set; }
/**
* Specifies that this expression transfers ownership without a receiver
@@ -77,5 +78,5 @@ public abstract class Vala.Expression : CodeNode {
*
* The code generator sets and uses them for memory management.
*/
- public List<VariableDeclarator> temp_vars;
+ public ArrayList<VariableDeclarator> temp_vars = new ArrayList<VariableDeclarator> ();
}
diff --git a/vala/valafield.vala b/vala/valafield.vala
index ceec48747..fc28cc018 100644
--- a/vala/valafield.vala
+++ b/vala/valafield.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a type or namespace field.
@@ -129,7 +130,7 @@ public class Vala.Field : Member, Invokable, Lockable {
}
}
- public List<weak FormalParameter> get_parameters () {
+ public Collection<FormalParameter> get_parameters () {
if (!is_invokable ()) {
return null;
}
diff --git a/vala/valaformalparameter.vala b/vala/valaformalparameter.vala
index 363e26ac7..54b729321 100644
--- a/vala/valaformalparameter.vala
+++ b/vala/valaformalparameter.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a formal parameter in method and callback signatures.
@@ -93,7 +94,7 @@ public class Vala.FormalParameter : Symbol, Invokable {
}
}
- public List<weak FormalParameter> get_parameters () {
+ public Collection<FormalParameter> get_parameters () {
if (!is_invokable ()) {
return null;
}
diff --git a/vala/valaforstatement.vala b/vala/valaforstatement.vala
index 038a1e72a..217f19675 100644
--- a/vala/valaforstatement.vala
+++ b/vala/valaforstatement.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a for iteration statement in the source code.
@@ -52,8 +53,8 @@ public class Vala.ForStatement : CodeNode, Statement {
}
}
- private List<Expression> initializer;
- private List<Expression> iterator;
+ private Gee.List<Expression> initializer = new ArrayList<Expression> ();
+ private Gee.List<Expression> iterator = new ArrayList<Expression> ();
private Expression! _condition;
private Block _body;
@@ -61,10 +62,10 @@ public class Vala.ForStatement : CodeNode, Statement {
/**
* Creates a new for statement.
*
- * @param cond loop condition
- * @param body loop body
- * @param source reference to source code
- * @return newly created for statement
+ * @param cond loop condition
+ * @param body loop body
+ * @param source_reference reference to source code
+ * @return newly created for statement
*/
public ForStatement (construct Expression condition, construct Block body, construct SourceReference source_reference = null) {
}
@@ -76,7 +77,7 @@ public class Vala.ForStatement : CodeNode, Statement {
*/
public void add_initializer (Expression! init) {
init.parent_node = this;
- initializer.append (init);
+ initializer.add (init);
}
/**
@@ -84,8 +85,8 @@ public class Vala.ForStatement : CodeNode, Statement {
*
* @return initializer list
*/
- public List<weak Expression> get_initializer () {
- return initializer.copy ();
+ public Collection<Expression> get_initializer () {
+ return new ReadOnlyCollection<Expression> (initializer);
}
/**
@@ -95,7 +96,7 @@ public class Vala.ForStatement : CodeNode, Statement {
*/
public void add_iterator (Expression! iter) {
iter.parent_node = this;
- iterator.append (iter);
+ iterator.add (iter);
}
/**
@@ -103,8 +104,8 @@ public class Vala.ForStatement : CodeNode, Statement {
*
* @return iterator
*/
- public List<weak Expression> get_iterator () {
- return iterator.copy ();
+ public Collection<Expression> get_iterator () {
+ return new ReadOnlyCollection<Expression> (iterator);
}
public override void accept (CodeVisitor! visitor) {
@@ -128,29 +129,22 @@ public class Vala.ForStatement : CodeNode, Statement {
}
public override void replace (CodeNode! old_node, CodeNode! new_node) {
- weak List<Expression> iter;
-
if (condition == old_node) {
condition = (Expression) new_node;
return;
}
- for (iter = initializer; iter != null; iter = iter.next) {
- if (iter.data == old_node) {
- weak List<Expression> silbling = iter.next;
- initializer.delete_link (iter);
- initializer.insert_before (silbling, new_node);
+ for (int i = 0; i < initializer.size; i++) {
+ if (initializer[i] == old_node) {
+ initializer[i] = (Expression) new_node;
return;
}
}
-
- for (iter = iterator; iter != null; iter = iter.next) {
- if (iter.data == old_node) {
- weak List<Expression> silbling = iter.next;
- iterator.delete_link (iter);
- iterator.insert_before (silbling, new_node);
+ for (int i = 0; i < iterator.size; i++) {
+ if (iterator[i] == old_node) {
+ iterator[i] = (Expression) new_node;
return;
}
- }
+ }
}
}
diff --git a/vala/valainitializerlist.vala b/vala/valainitializerlist.vala
index ed0555159..6793c10b5 100644
--- a/vala/valainitializerlist.vala
+++ b/vala/valainitializerlist.vala
@@ -21,12 +21,13 @@
*/
using GLib;
+using Gee;
/**
* Represents an array or struct initializer list in the source code.
*/
public class Vala.InitializerList : Expression {
- private List<Expression> initializers;
+ private Gee.List<Expression> initializers = new ArrayList<Expression> ();
/**
* Appends the specified expression to this initializer list.
@@ -34,7 +35,7 @@ public class Vala.InitializerList : Expression {
* @param expr an expression
*/
public void append (Expression! expr) {
- initializers.append (expr);
+ initializers.add (expr);
}
/**
@@ -42,18 +43,17 @@ public class Vala.InitializerList : Expression {
*
* @return expression list
*/
- public List<weak Expression> get_initializers () {
- return initializers.copy ();
+ public Collection<Expression> get_initializers () {
+ return new ReadOnlyCollection<Expression> (initializers);
}
/**
* Creates a new initializer list.
*
- * @param source reference to source code
- * @return newly created initializer list
+ * @param source_reference reference to source code
+ * @return newly created initializer list
*/
- public InitializerList (SourceReference source) {
- source_reference = source;
+ public InitializerList (construct SourceReference source_reference) {
}
public override void accept (CodeVisitor! visitor) {
diff --git a/vala/valainstancecast.vala b/vala/valainstancecast.vala
index f154ce99f..15a8374c5 100644
--- a/vala/valainstancecast.vala
+++ b/vala/valainstancecast.vala
@@ -29,7 +29,7 @@ public class Vala.InstanceCast : CCodeFunctionCall {
/**
* The target type.
*/
- public DataType! type_reference { get; set construct; }
+ public weak DataType! type_reference { get; set construct; }
/**
* The expression to be cast.
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index aecf335c3..1fa120d4a 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a class declaration in the source code.
@@ -32,14 +33,14 @@ public class Vala.Interface : DataType {
*/
public bool is_static { get; set; }
- private List<TypeParameter> type_parameters;
+ private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
- private List<TypeReference> prerequisites;
+ private Gee.List<TypeReference> prerequisites = new ArrayList<TypeReference> ();
- private List<Method> methods;
- private List<Field> fields;
- private List<Property> properties;
- private List<Signal> signals;
+ private Gee.List<Method> methods = new ArrayList<Method> ();
+ private Gee.List<Field> fields = new ArrayList<Field> ();
+ private Gee.List<Property> properties = new ArrayList<Property> ();
+ private Gee.List<Signal> signals = new ArrayList<Signal> ();
private string cname;
private string lower_case_csuffix;
@@ -62,7 +63,7 @@ public class Vala.Interface : DataType {
* @param p a type parameter
*/
public void add_type_parameter (TypeParameter! p) {
- type_parameters.append (p);
+ type_parameters.add (p);
p.type = this;
scope.add (p.name, p);
}
@@ -72,8 +73,8 @@ public class Vala.Interface : DataType {
*
* @return list of type parameters
*/
- public List<weak TypeParameter> get_type_parameters () {
- return type_parameters.copy ();
+ public Collection<TypeParameter> get_type_parameters () {
+ return new ReadOnlyCollection<TypeParameter> (type_parameters);
}
/**
@@ -83,7 +84,7 @@ public class Vala.Interface : DataType {
* @param type an interface or class reference
*/
public void add_prerequisite (TypeReference! type) {
- prerequisites.append (type);
+ prerequisites.add (type);
}
/**
@@ -93,7 +94,7 @@ public class Vala.Interface : DataType {
* @param type an interface or class reference
*/
public void prepend_prerequisite (TypeReference! type) {
- prerequisites.prepend (type);
+ prerequisites.insert (0, type);
}
/**
@@ -101,8 +102,8 @@ public class Vala.Interface : DataType {
*
* @return list of base types
*/
- public List<weak TypeReference> get_prerequisites () {
- return prerequisites.copy ();
+ public Collection<TypeReference> get_prerequisites () {
+ return new ReadOnlyCollection<TypeReference> (prerequisites);
}
/**
@@ -123,7 +124,7 @@ public class Vala.Interface : DataType {
m.scope.add (m.this_parameter.name, m.this_parameter);
}
- methods.append (m);
+ methods.add (m);
scope.add (m.name, m);
}
@@ -132,8 +133,8 @@ public class Vala.Interface : DataType {
*
* @return list of methods
*/
- public List<weak Method> get_methods () {
- return methods.copy ();
+ public Collection<Method> get_methods () {
+ return new ReadOnlyCollection<Method> (methods);
}
/**
@@ -145,7 +146,7 @@ public class Vala.Interface : DataType {
public void add_field (Field! f) {
// non_null fields not yet supported due to initialization issues
f.type_reference.non_null = false;
- fields.append (f);
+ fields.add (f);
scope.add (f.name, f);
}
@@ -154,8 +155,8 @@ public class Vala.Interface : DataType {
*
* @return list of fields
*/
- public List<weak Field> get_fields () {
- return fields.copy ();
+ public Collection<Field> get_fields () {
+ return new ReadOnlyCollection<Field> (fields);
}
/**
@@ -164,7 +165,7 @@ public class Vala.Interface : DataType {
* @param prop a property
*/
public void add_property (Property! prop) {
- properties.append (prop);
+ properties.add (prop);
scope.add (prop.name, prop);
}
@@ -173,8 +174,8 @@ public class Vala.Interface : DataType {
*
* @return list of properties
*/
- public List<weak Property> get_properties () {
- return properties.copy ();
+ public Collection<Property> get_properties () {
+ return new ReadOnlyCollection<Property> (properties);
}
/**
@@ -183,7 +184,7 @@ public class Vala.Interface : DataType {
* @param sig a signal
*/
public void add_signal (Signal! sig) {
- signals.append (sig);
+ signals.add (sig);
scope.add (sig.name, sig);
}
@@ -192,8 +193,8 @@ public class Vala.Interface : DataType {
*
* @return list of signals
*/
- public List<weak Signal> get_signals () {
- return signals.copy ();
+ public Collection<Signal> get_signals () {
+ return new ReadOnlyCollection<Signal> (signals);
}
public override string get_cname (bool const_type = false) {
diff --git a/vala/valainterfacewriter.vala b/vala/valainterfacewriter.vala
index 4fddb81ef..1ed50f73f 100644
--- a/vala/valainterfacewriter.vala
+++ b/vala/valainterfacewriter.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
/**
* Code visitor generating Vala API file for the public interface.
@@ -112,7 +113,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_identifier (cl.name);
var type_params = cl.get_type_parameters ();
- if (type_params != null) {
+ if (type_params.size > 0) {
write_string ("<");
bool first = true;
foreach (TypeParameter type_param in type_params) {
@@ -127,7 +128,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
var base_types = cl.get_base_types ();
- if (base_types != null) {
+ if (base_types.size > 0) {
write_string (" : ");
bool first = true;
@@ -218,7 +219,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_identifier (iface.name);
var type_params = iface.get_type_parameters ();
- if (type_params != null) {
+ if (type_params.size > 0) {
write_string ("<");
bool first = true;
foreach (TypeParameter type_param in type_params) {
@@ -233,7 +234,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
var prerequisites = iface.get_prerequisites ();
- if (prerequisites != null) {
+ if (prerequisites.size > 0) {
write_string (" : ");
bool first = true;
@@ -336,7 +337,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_newline ();
}
- private void write_params (List<FormalParameter> params) {
+ private void write_params (Collection<FormalParameter> params) {
write_string ("(");
bool first = true;
@@ -392,7 +393,8 @@ public class Vala.InterfaceWriter : CodeVisitor {
if (type == null) {
write_string ("void");
} else {
- if (!cb.return_type.transfers_ownership) {
+ if (cb.return_type.transfers_ownership) {
+ } else if ((cb.return_type.data_type != null && cb.return_type.data_type.is_reference_type ()) || cb.return_type.type_parameter != null) {
write_string ("weak ");
}
@@ -547,7 +549,8 @@ public class Vala.InterfaceWriter : CodeVisitor {
if (type == null) {
write_string ("void");
} else {
- if (!sig.return_type.transfers_ownership) {
+ if (sig.return_type.transfers_ownership) {
+ } else if ((sig.return_type.data_type != null && sig.return_type.data_type.is_reference_type ()) || sig.return_type.type_parameter != null) {
write_string ("weak ");
}
@@ -598,7 +601,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
var type_args = type.get_type_arguments ();
- if (!(type.data_type is Array) && type_args != null) {
+ if (!(type.data_type is Array) && type_args.size > 0) {
write_string ("<");
bool first = true;
foreach (TypeReference type_arg in type_args) {
diff --git a/vala/valainvocationexpression.vala b/vala/valainvocationexpression.vala
index afe100612..aefdb95d8 100644
--- a/vala/valainvocationexpression.vala
+++ b/vala/valainvocationexpression.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents an invocation expression in the source code.
@@ -41,19 +42,17 @@ public class Vala.InvocationExpression : Expression {
public Expression! _call;
- private List<Expression> argument_list;
- private List<CCodeExpression> array_sizes;
+ private Gee.List<Expression> argument_list = new ArrayList<Expression> ();
+ private Gee.List<CCodeExpression> array_sizes = new ArrayList<CCodeExpression> ();
/**
* Creates a new invocation expression.
*
- * @param call method to call
- * @param source reference to source code
- * @return newly created invocation expression
+ * @param call method to call
+ * @param source_reference reference to source code
+ * @return newly created invocation expression
*/
- public InvocationExpression (Expression! _call, SourceReference source = null) {
- call = _call;
- source_reference = source;
+ public InvocationExpression (construct Expression! call, construct SourceReference source_reference = null) {
}
/**
@@ -62,7 +61,7 @@ public class Vala.InvocationExpression : Expression {
* @param arg an argument
*/
public void add_argument (Expression! arg) {
- argument_list.append (arg);
+ argument_list.add (arg);
arg.parent_node = this;
}
@@ -71,23 +70,23 @@ public class Vala.InvocationExpression : Expression {
*
* @return argument list
*/
- public List<weak Expression> get_argument_list () {
- return argument_list.copy ();
+ public Collection<Expression> get_argument_list () {
+ return new ReadOnlyCollection<Expression> (argument_list);
}
/**
* Add an array size C code expression.
*/
public void append_array_size (CCodeExpression! size) {
- array_sizes.append (size);
+ array_sizes.add (size);
}
/**
* Get the C code expression for array sizes for all dimensions
* ascending from left to right.
*/
- public List<weak CCodeExpression> get_array_sizes () {
- return array_sizes.copy ();
+ public Gee.List<CCodeExpression> get_array_sizes () {
+ return new ReadOnlyList<CCodeExpression> (array_sizes);
}
public override void accept (CodeVisitor! visitor) {
@@ -95,8 +94,7 @@ public class Vala.InvocationExpression : Expression {
visitor.visit_begin_invocation_expression (this);
- // iterate over list copy as list may change in loop body
- foreach (Expression expr in argument_list.copy ()) {
+ foreach (Expression expr in argument_list) {
expr.accept (visitor);
}
@@ -108,14 +106,9 @@ public class Vala.InvocationExpression : Expression {
call = (Expression) new_node;
}
- weak List<Expression> l = argument_list.find (old_node);
- if (l != null) {
- if (new_node.parent_node != null) {
- return;
- }
-
- argument_list.insert_before (l, new_node);
- argument_list.remove_link (l);
+ int index = argument_list.index_of (old_node);
+ if (index >= 0 && new_node.parent_node == null) {
+ argument_list[index] = (Expression) new_node;
new_node.parent_node = this;
}
}
diff --git a/vala/valainvokable.vala b/vala/valainvokable.vala
index d9838cbe2..dcf7d9174 100644
--- a/vala/valainvokable.vala
+++ b/vala/valainvokable.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a possibly invokable code object.
@@ -45,5 +46,5 @@ public interface Vala.Invokable : Symbol {
*
* @return parameter list
*/
- public abstract List<weak FormalParameter> get_parameters ();
+ public abstract Collection<FormalParameter> get_parameters ();
}
diff --git a/vala/valalambdaexpression.vala b/vala/valalambdaexpression.vala
index 7d8241ec9..a597ab774 100644
--- a/vala/valalambdaexpression.vala
+++ b/vala/valalambdaexpression.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a lambda expression in the source code. Lambda expressions are
@@ -44,30 +45,26 @@ public class Vala.LambdaExpression : Expression {
*/
public Method method { get; set; }
- private List<string> parameters;
+ private Gee.List<string> parameters = new ArrayList<string> ();
/**
* Creates a new lambda expression.
*
- * @param body expression body
- * @param source reference to source code
- * @return newly created lambda expression
+ * @param expression_body expression body
+ * @param source_reference reference to source code
+ * @return newly created lambda expression
*/
- public LambdaExpression (Expression! body, SourceReference source) {
- expression_body = body;
- source_reference = source;
+ public LambdaExpression (construct Expression! expression_body, construct SourceReference source_reference) {
}
/**
* Creates a new lambda expression with statement body.
*
- * @param body statement body
- * @param source reference to source code
- * @return newly created lambda expression
+ * @param statement_body statement body
+ * @param source_reference reference to source code
+ * @return newly created lambda expression
*/
- public LambdaExpression.with_statement_body (Block! body, SourceReference source) {
- statement_body = body;
- source_reference = source;
+ public LambdaExpression.with_statement_body (construct Block! statement_body, construct SourceReference source_reference) {
}
/**
@@ -76,7 +73,7 @@ public class Vala.LambdaExpression : Expression {
* @param param parameter name
*/
public void add_parameter (string! param) {
- parameters.append (param);
+ parameters.add (param);
}
/**
@@ -84,8 +81,8 @@ public class Vala.LambdaExpression : Expression {
*
* @return parameter list
*/
- public List<weak string> get_parameters () {
- return parameters.copy ();
+ public Collection<string> get_parameters () {
+ return new ReadOnlyCollection<string> (parameters);
}
public override void accept (CodeVisitor! visitor) {
diff --git a/vala/valalocalvariabledeclaration.vala b/vala/valalocalvariabledeclaration.vala
index 1bcbf3288..a8ea9696b 100644
--- a/vala/valalocalvariabledeclaration.vala
+++ b/vala/valalocalvariabledeclaration.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a local variable declaration in the source code.
@@ -31,18 +32,16 @@ public class Vala.LocalVariableDeclaration : CodeNode {
*/
public TypeReference type_reference { get; set; }
- private List<VariableDeclarator> variable_declarators;
+ private Gee.List<VariableDeclarator> variable_declarators = new ArrayList<VariableDeclarator> ();
/**
* Creates a new local variable declaration.
*
- * @param type type of the variable
- * @param source reference to source code
- * @return newly created local variable declaration
+ * @param type_reference type of the variable
+ * @param source_reference reference to source code
+ * @return newly created local variable declaration
*/
- public LocalVariableDeclaration (TypeReference type, SourceReference source) {
- type_reference = type;
- source_reference = source;
+ public LocalVariableDeclaration (construct TypeReference type_reference, construct SourceReference source_reference) {
}
/**
@@ -50,11 +49,10 @@ public class Vala.LocalVariableDeclaration : CodeNode {
* of the variable is inferred from the expression used to initialize
* the variable.
*
- * @param source reference to source code
- * @return newly created local variable declaration
+ * @param source_reference reference to source code
+ * @return newly created local variable declaration
*/
- public LocalVariableDeclaration.var_type (SourceReference source) {
- source_reference = source;
+ public LocalVariableDeclaration.var_type (construct SourceReference source_reference) {
}
/**
@@ -64,7 +62,7 @@ public class Vala.LocalVariableDeclaration : CodeNode {
* @param declarator a variable declarator
*/
public void add_declarator (VariableDeclarator! declarator) {
- variable_declarators.append (declarator);
+ variable_declarators.add (declarator);
}
/**
@@ -72,8 +70,8 @@ public class Vala.LocalVariableDeclaration : CodeNode {
*
* @return variable declarator list
*/
- public List<weak VariableDeclarator> get_variable_declarators () {
- return variable_declarators.copy ();
+ public Collection<VariableDeclarator> get_variable_declarators () {
+ return new ReadOnlyCollection<VariableDeclarator> (variable_declarators);
}
public override void accept (CodeVisitor! visitor) {
diff --git a/vala/valamember.vala b/vala/valamember.vala
index 33b0d34c4..d2a7510ad 100644
--- a/vala/valamember.vala
+++ b/vala/valamember.vala
@@ -21,31 +21,33 @@
*/
using GLib;
+using Gee;
/**
* Represents a general class member.
*/
public class Vala.Member : Symbol {
- private List<string> cheader_filenames;
+ private Gee.List<string> cheader_filenames = new ArrayList<string> ();
public override void accept (CodeVisitor! visitor) {
visitor.visit_member (this);
}
-
- public override List<weak string> get_cheader_filenames () {
- if (cheader_filenames == null) {
+
+ public override Collection<string> get_cheader_filenames () {
+ if (cheader_filenames.size == 0) {
/* default to header filenames of the namespace */
foreach (string filename in parent_symbol.get_cheader_filenames ()) {
add_cheader_filename (filename);
}
- if (cheader_filenames == null && source_reference != null && !source_reference.file.pkg) {
+ if (cheader_filenames.size == 0 && source_reference != null && !source_reference.file.pkg) {
// don't add default include directives for VAPI files
- cheader_filenames.append (source_reference.file.get_cinclude_filename ());
+ cheader_filenames.add (source_reference.file.get_cinclude_filename ());
}
}
- return cheader_filenames.copy ();
+ return new ReadOnlyCollection<string> (cheader_filenames);
}
+
/**
* Adds a filename to the list of C header filenames users of this data
@@ -54,6 +56,6 @@ public class Vala.Member : Symbol {
* @param filename a C header filename
*/
public void add_cheader_filename (string! filename) {
- cheader_filenames.append (filename);
+ cheader_filenames.add (filename);
}
}
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index 42598022c..5f32ed50a 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents an access to a type member in the source code.
@@ -44,28 +45,23 @@ public class Vala.MemberAccess : Expression {
/**
* The name of the member.
*/
- public string! member_name { get; set construct; }
+ public string! member_name { get; set; }
private Expression _inner;
- private List<TypeReference> type_argument_list;
+ private Gee.List<TypeReference> type_argument_list = new ArrayList<TypeReference> ();
/**
* Creates a new member access expression.
*
- * @param inner parent of the member
- * @param member member name
- * @param source reference to source code
- * @return newly created member access expression
+ * @param inner parent of the member
+ * @param member_name member name
+ * @param source_reference reference to source code
+ * @return newly created member access expression
*/
- public MemberAccess (Expression _inner, string! member, SourceReference source = null) {
- inner = _inner;
- member_name = member;
- source_reference = source;
+ public MemberAccess (construct Expression inner, construct string! member_name, construct SourceReference source_reference = null) {
}
- public MemberAccess.simple (string! member, SourceReference source = null) {
- member_name = member;
- source_reference = source;
+ public MemberAccess.simple (construct string! member_name, construct SourceReference source_reference = null) {
}
/**
@@ -74,7 +70,7 @@ public class Vala.MemberAccess : Expression {
* @param arg a type reference
*/
public void add_type_argument (TypeReference! arg) {
- type_argument_list.append (arg);
+ type_argument_list.add (arg);
}
/**
@@ -82,8 +78,8 @@ public class Vala.MemberAccess : Expression {
*
* @return type argument list
*/
- public List<weak TypeReference> get_type_arguments () {
- return type_argument_list.copy ();
+ public Collection<TypeReference> get_type_arguments () {
+ return new ReadOnlyCollection<TypeReference> (type_argument_list);
}
public override void accept (CodeVisitor! visitor) {
diff --git a/vala/valamemorymanager.vala b/vala/valamemorymanager.vala
index 43149c86f..f62244ed7 100644
--- a/vala/valamemorymanager.vala
+++ b/vala/valamemorymanager.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
/**
* Code visitor analyzing memory usage. The memory manager finds leaked and
@@ -172,12 +173,12 @@ public class Vala.MemoryManager : CodeVisitor {
public override void visit_end_invocation_expression (InvocationExpression! expr) {
var msym = (Invokable) expr.call.symbol_reference;
- List<weak FormalParameter> params = msym.get_parameters ();
+ Collection<FormalParameter> params = msym.get_parameters ();
- weak List<weak FormalParameter> params_it = params;
+ Iterator<FormalParameter> params_it = params.iterator ();
foreach (Expression arg in expr.get_argument_list ()) {
- if (params_it != null) {
- var param = (FormalParameter) params_it.data;
+ if (params_it.next ()) {
+ var param = params_it.get ();
if (!param.ellipsis
&& ((param.type_reference.data_type != null
&& param.type_reference.data_type.is_reference_type ())
@@ -201,8 +202,6 @@ public class Vala.MemoryManager : CodeVisitor {
} else {
visit_possibly_leaked_expression (arg);
}
-
- params_it = params_it.next;
} else {
visit_possibly_leaked_expression (arg);
}
@@ -215,12 +214,12 @@ public class Vala.MemoryManager : CodeVisitor {
}
var msym = (Invokable) expr.symbol_reference;
- List<weak FormalParameter> params = msym.get_parameters ();
+ Collection<FormalParameter> params = msym.get_parameters ();
- weak List<weak FormalParameter> params_it = params;
+ Iterator<FormalParameter> params_it = params.iterator ();
foreach (Expression arg in expr.get_argument_list ()) {
- if (params_it != null) {
- var param = (FormalParameter) params_it.data;
+ if (params_it.next ()) {
+ var param = params_it.get ();
if (!param.ellipsis
&& ((param.type_reference.data_type != null
&& param.type_reference.data_type.is_reference_type ())
@@ -241,8 +240,6 @@ public class Vala.MemoryManager : CodeVisitor {
} else {
visit_possibly_leaked_expression (arg);
}
-
- params_it = params_it.next;
} else {
visit_possibly_leaked_expression (arg);
}
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index d54f9b73c..0c597dcb7 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a type or namespace method.
@@ -132,12 +133,11 @@ public class Vala.Method : Member, Invokable {
public bool printf_format { get; set; }
private bool _instance = true;
- private List<FormalParameter> parameters;
+ private Gee.List<FormalParameter> parameters = new ArrayList<FormalParameter> ();
private string cname;
private bool _no_array_length;
- private List<TypeReference> error_domains;
- private List<string> cheader_filenames;
-
+ private Gee.List<TypeReference> error_domains = new ArrayList<TypeReference> ();
+
/**
* Creates a new method.
*
@@ -159,14 +159,14 @@ public class Vala.Method : Member, Invokable {
param.no_array_length = true;
}
- parameters.append (param);
+ parameters.add (param);
if (!param.ellipsis) {
scope.add (param.name, param);
}
}
- public List<weak FormalParameter> get_parameters () {
- return parameters.copy ();
+ public Collection<FormalParameter> get_parameters () {
+ return new ReadOnlyCollection<FormalParameter> (parameters);
}
public TypeReference get_return_type () {
@@ -295,24 +295,20 @@ public class Vala.Method : Member, Invokable {
return false;
}
- var method_params = m2.get_parameters ();
- weak List<weak FormalParameter> method_params_it = method_params;
+ Iterator<FormalParameter> method_params_it = m2.get_parameters ().iterator ();
foreach (FormalParameter param in parameters) {
/* method may not expect less arguments */
- if (method_params_it == null) {
+ if (!method_params_it.next ()) {
return false;
}
- var method_param = (FormalParameter) method_params_it.data;
- if (!method_param.type_reference.equals (param.type_reference)) {
+ if (!method_params_it.get ().type_reference.equals (param.type_reference)) {
return false;
}
-
- method_params_it = method_params_it.next;
}
/* method may not expect more arguments */
- if (method_params_it != null) {
+ if (method_params_it.next ()) {
return false;
}
@@ -325,7 +321,7 @@ public class Vala.Method : Member, Invokable {
* @param error_domain an error domain
*/
public void add_error_domain (TypeReference! error_domain) {
- error_domains.append (error_domain);
+ error_domains.add (error_domain);
}
/**
@@ -333,7 +329,7 @@ public class Vala.Method : Member, Invokable {
*
* @return list of error domains
*/
- public List<weak TypeReference> get_error_domains () {
- return error_domains.copy ();
+ public Collection<TypeReference> get_error_domains () {
+ return new ReadOnlyCollection<TypeReference> (error_domains);
}
}
diff --git a/vala/valanamespace.vala b/vala/valanamespace.vala
index 25c235047..f4b63fc15 100644
--- a/vala/valanamespace.vala
+++ b/vala/valanamespace.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a namespace declaration in the source code.
@@ -31,28 +32,28 @@ public class Vala.Namespace : Symbol {
*/
public bool pkg { get; set; }
- private List<Class> classes;
- private List<Interface> interfaces;
- private List<Struct> structs;
- private List<Enum> enums;
- private List<Callback> callbacks;
- private List<Constant> constants;
- private List<Field> fields;
- private List<Method> methods;
+ private Gee.List<Class> classes = new ArrayList<Class> ();
+ private Gee.List<Interface> interfaces = new ArrayList<Interface> ();
+ private Gee.List<Struct> structs = new ArrayList<Struct> ();
+ private Gee.List<Enum> enums = new ArrayList<Enum> ();
+ private Gee.List<Callback> callbacks = new ArrayList<Callback> ();
+ private Gee.List<Constant> constants = new ArrayList<Constant> ();
+ private Gee.List<Field> fields = new ArrayList<Field> ();
+ private Gee.List<Method> methods = new ArrayList<Method> ();
private string cprefix;
private string lower_case_cprefix;
- private List<string> cheader_filenames;
+ private Gee.List<string> cheader_filenames = new ArrayList<string> ();
- private List<Namespace> namespaces;
+ private Gee.List<Namespace> namespaces = new ArrayList<Namespace> ();
/**
* Creates a new namespace.
*
- * @param name namespace name
- * @param source reference to source code
- * @return newly created namespace
+ * @param name namespace name
+ * @param source_reference reference to source code
+ * @return newly created namespace
*/
public Namespace (construct string name, construct SourceReference source_reference = null) {
}
@@ -63,7 +64,7 @@ public class Vala.Namespace : Symbol {
* @param ns a namespace
*/
public void add_namespace (Namespace! ns) {
- namespaces.append (ns);
+ namespaces.add (ns);
scope.add (ns.name, ns);
}
@@ -72,8 +73,8 @@ public class Vala.Namespace : Symbol {
*
* @return namespace list
*/
- public List<weak Namespace> get_namespaces () {
- return namespaces.copy ();
+ public Collection<Namespace> get_namespaces () {
+ return new ReadOnlyCollection<Namespace> (namespaces);
}
/**
@@ -82,7 +83,7 @@ public class Vala.Namespace : Symbol {
* @param cl a class
*/
public void add_class (Class! cl) {
- classes.append (cl);
+ classes.add (cl);
scope.add (cl.name, cl);
}
@@ -92,7 +93,7 @@ public class Vala.Namespace : Symbol {
* @param iface an interface
*/
public void add_interface (Interface! iface) {
- interfaces.append (iface);
+ interfaces.add (iface);
scope.add (iface.name, iface);
}
@@ -102,7 +103,7 @@ public class Vala.Namespace : Symbol {
* @param st a struct
*/
public void add_struct (Struct! st) {
- structs.append (st);
+ structs.add (st);
scope.add (st.name, st);
}
@@ -112,7 +113,7 @@ public class Vala.Namespace : Symbol {
* @param en an enum
*/
public void add_enum (Enum! en) {
- enums.append (en);
+ enums.add (en);
scope.add (en.name, en);
}
@@ -122,7 +123,7 @@ public class Vala.Namespace : Symbol {
* @param cb a callback
*/
public void add_callback (Callback! cb) {
- callbacks.append (cb);
+ callbacks.add (cb);
scope.add (cb.name, cb);
}
@@ -131,8 +132,8 @@ public class Vala.Namespace : Symbol {
*
* @return struct list
*/
- public List<weak Struct> get_structs () {
- return structs.copy ();
+ public Collection<Struct> get_structs () {
+ return new ReadOnlyCollection<Struct> (structs);
}
/**
@@ -140,8 +141,8 @@ public class Vala.Namespace : Symbol {
*
* @return class list
*/
- public List<weak Class> get_classes () {
- return classes.copy ();
+ public Collection<Class> get_classes () {
+ return new ReadOnlyCollection<Class> (classes);
}
/**
@@ -149,8 +150,8 @@ public class Vala.Namespace : Symbol {
*
* @return interface list
*/
- public List<weak Interface> get_interfaces () {
- return interfaces.copy ();
+ public Collection<Interface> get_interfaces () {
+ return new ReadOnlyCollection<Interface> (interfaces);
}
/**
@@ -159,7 +160,7 @@ public class Vala.Namespace : Symbol {
* @param constant a constant
*/
public void add_constant (Constant! constant) {
- constants.append (constant);
+ constants.add (constant);
scope.add (constant.name, constant);
}
@@ -169,7 +170,7 @@ public class Vala.Namespace : Symbol {
* @param f a field
*/
public void add_field (Field! f) {
- fields.append (f);
+ fields.add (f);
scope.add (f.name, f);
}
@@ -192,7 +193,7 @@ public class Vala.Namespace : Symbol {
return;
}
- methods.append (m);
+ methods.add (m);
scope.add (m.name, m);
}
@@ -287,8 +288,8 @@ public class Vala.Namespace : Symbol {
this.lower_case_cprefix = cprefix;
}
- public override List<weak string> get_cheader_filenames () {
- return cheader_filenames.copy ();
+ public override Collection<string> get_cheader_filenames () {
+ return new ReadOnlyCollection<string> (cheader_filenames);
}
/**
@@ -317,8 +318,8 @@ public class Vala.Namespace : Symbol {
* @param cheader_filename header filename
*/
public void set_cheader_filename (string! cheader_filename) {
- cheader_filenames = null;
- cheader_filenames.append (cheader_filename);
+ cheader_filenames = new ArrayList<string> ();
+ cheader_filenames.add (cheader_filename);
}
private void process_ccode_attribute (Attribute! a) {
@@ -331,7 +332,7 @@ public class Vala.Namespace : Symbol {
if (a.has_argument ("cheader_filename")) {
var val = a.get_string ("cheader_filename");
foreach (string filename in val.split (",")) {
- cheader_filenames.append (filename);
+ cheader_filenames.add (filename);
}
}
}
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index 5adf02228..80a138a3c 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents an object creation expression in the source code.
@@ -43,18 +44,16 @@ public class Vala.ObjectCreationExpression : Expression {
*/
public MemberAccess member_name { get; set; }
- private List<Expression> argument_list;
+ private Gee.List<Expression> argument_list = new ArrayList<Expression> ();
/**
* Creates a new object creation expression.
*
- * @param type object type to create
- * @param source reference to source code
- * @return newly created object creation expression
+ * @param member_name object type to create
+ * @param source_reference reference to source code
+ * @return newly created object creation expression
*/
- public ObjectCreationExpression (MemberAccess! name, SourceReference source) {
- member_name = name;
- source_reference = source;
+ public ObjectCreationExpression (construct MemberAccess! member_name, construct SourceReference source_reference) {
}
/**
@@ -63,7 +62,7 @@ public class Vala.ObjectCreationExpression : Expression {
* @param arg an argument
*/
public void add_argument (Expression! arg) {
- argument_list.append (arg);
+ argument_list.add (arg);
arg.parent_node = this;
}
@@ -72,8 +71,8 @@ public class Vala.ObjectCreationExpression : Expression {
*
* @return argument list
*/
- public List<weak Expression> get_argument_list () {
- return argument_list.copy ();
+ public Collection<Expression> get_argument_list () {
+ return new ReadOnlyCollection<Expression> (argument_list);
}
public override void accept (CodeVisitor! visitor) {
@@ -87,8 +86,7 @@ public class Vala.ObjectCreationExpression : Expression {
visitor.visit_begin_object_creation_expression (this);
- // iterate over list copy as list may change in loop body
- foreach (Expression arg in argument_list.copy ()) {
+ foreach (Expression arg in argument_list) {
arg.accept (visitor);
}
@@ -96,14 +94,9 @@ public class Vala.ObjectCreationExpression : Expression {
}
public override void replace (CodeNode! old_node, CodeNode! new_node) {
- weak List<Expression> l = argument_list.find (old_node);
- if (l != null) {
- if (new_node.parent_node != null) {
- return;
- }
-
- argument_list.insert_before (l, new_node);
- argument_list.remove_link (l);
+ int index = argument_list.index_of (old_node);
+ if (index >= 0 && new_node.parent_node == null) {
+ argument_list[index] = (Expression) new_node;
new_node.parent_node = this;
}
}
diff --git a/vala/valapointer.vala b/vala/valapointer.vala
index 8da6b4a27..4eada9009 100644
--- a/vala/valapointer.vala
+++ b/vala/valapointer.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a pointer-type.
@@ -29,7 +30,7 @@ public class Vala.Pointer : DataType {
/**
* The type to which this pointer type points.
*/
- public DataType! referent_type { get; set construct; }
+ public weak DataType! referent_type { get; set construct; }
private string cname;
@@ -68,7 +69,7 @@ public class Vala.Pointer : DataType {
return null;
}
- public override List<weak string> get_cheader_filenames () {
+ public override Collection<string> get_cheader_filenames () {
return referent_type.get_cheader_filenames ();
}
diff --git a/vala/valascope.vala b/vala/valascope.vala
index 745c8e58a..6a5610481 100644
--- a/vala/valascope.vala
+++ b/vala/valascope.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a part of the symbol tree.
@@ -36,7 +37,7 @@ public class Vala.Scope {
*/
public weak Scope parent_scope { get; set; }
- private HashTable<string,Symbol> symbol_table;
+ private Map<string,Symbol> symbol_table;
/**
* Creates a new scope.
@@ -56,14 +57,14 @@ public class Vala.Scope {
public void add (string name, Symbol! sym) {
if (name != null) {
if (symbol_table == null) {
- symbol_table = new HashTable.full (str_hash, str_equal, g_free, g_object_unref);
+ symbol_table = new HashMap<string,Symbol> (str_hash, str_equal);
} else if (lookup (name) != null) {
owner.error = true;
Report.error (owner.source_reference, "`%s' already contains a definition for `%s'".printf (owner.get_full_name (), name));
return;
}
- symbol_table.insert (name, sym);
+ symbol_table[name] = sym;
}
sym.owner = this;
}
@@ -79,7 +80,7 @@ public class Vala.Scope {
if (symbol_table == null) {
return null;
}
- Symbol sym = symbol_table.lookup (name);
+ Symbol sym = symbol_table[name];
if (sym != null && !sym.active) {
sym = null;
}
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index 1a3310cbd..a6445e83a 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
/**
* Code visitor analyzing and checking code.
@@ -39,7 +40,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
Class current_class;
Struct current_struct;
- List<weak NamespaceReference> current_using_directives;
+ Collection<NamespaceReference> current_using_directives;
TypeReference bool_type;
TypeReference string_type;
@@ -146,21 +147,21 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
cl.accept_children (this);
/* gather all prerequisites */
- List<DataType> prerequisites = null;
+ Gee.List<DataType> prerequisites = new ArrayList<DataType> ();
foreach (TypeReference base_type in cl.get_base_types ()) {
if (base_type.data_type is Interface) {
- prerequisites.concat (get_all_prerequisites ((Interface) base_type.data_type));
+ get_all_prerequisites ((Interface) base_type.data_type, prerequisites);
}
}
/* check whether all prerequisites are met */
- List<string> missing_prereqs = null;
+ Gee.List<string> missing_prereqs = new ArrayList<string> ();
foreach (DataType prereq in prerequisites) {
if (!class_is_a (cl, prereq)) {
- missing_prereqs.prepend (prereq.get_full_name ());
+ missing_prereqs.insert (0, prereq.get_full_name ());
}
}
/* report any missing prerequisites */
- if (missing_prereqs != null) {
+ if (missing_prereqs.size > 0) {
cl.error = true;
string error_string = "%s: some prerequisites (".printf (cl.get_full_name ());
@@ -222,9 +223,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
current_class = null;
}
- private List<DataType> get_all_prerequisites (Interface! iface) {
- List<DataType> ret = null;
-
+ private void get_all_prerequisites (Interface! iface, Collection<DataType> list) {
foreach (TypeReference prereq in iface.get_prerequisites ()) {
DataType type = prereq.data_type;
/* skip on previous errors */
@@ -232,15 +231,12 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
continue;
}
- ret.prepend (type);
+ list.add (type);
if (type is Interface) {
- ret.concat (get_all_prerequisites ((Interface) type));
+ get_all_prerequisites ((Interface) type, list);
}
}
-
- ret.reverse ();
- return #ret;
}
private bool class_is_a (Class! cl, DataType! t) {
@@ -996,8 +992,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
* @param expr an array creation expression
*/
public override void visit_end_array_creation_expression (ArrayCreationExpression! expr) {
- int i;
- List<weak Expression> size = expr.get_sizes ();
+ Collection<Expression> size = expr.get_sizes ();
/* check for errors in the size list */
if (size != null) {
@@ -1143,16 +1138,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
expr.static_type.floating_reference = false;
}
- private DataType find_parent_type (Symbol sym) {
- while (sym != null) {
- if (sym is DataType) {
- return (DataType) sym;
- }
- sym = sym.parent_symbol;
- }
- return null;
- }
-
public override void visit_member_access (MemberAccess! expr) {
Symbol base_symbol = null;
@@ -1323,7 +1308,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
return;
}
- List<weak FormalParameter> params;
+ Collection<FormalParameter> params;
if (msym is Invokable) {
var m = (Invokable) msym;
@@ -1341,26 +1326,24 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
}
var args = expr.get_argument_list ();
- weak List<weak Expression> arg_it = args;
+ Iterator<Expression> arg_it = args.iterator ();
foreach (FormalParameter param in params) {
if (param.ellipsis) {
break;
}
- if (arg_it != null) {
- var arg = (Expression) arg_it.data;
+ if (arg_it.next ()) {
+ Expression arg = arg_it.get ();
/* store expected type for callback parameters */
arg.expected_type = param.type_reference;
-
- arg_it = arg_it.next;
}
}
}
- private bool check_arguments (Expression! expr, Symbol! msym, List<FormalParameter> params, List<Expression> args) {
- weak List<weak Expression> prev_arg_it = null;
- weak List<weak Expression> arg_it = args;
+ private bool check_arguments (Expression! expr, Symbol! msym, Collection<FormalParameter> params, Collection<Expression> args) {
+ Expression prev_arg = null;
+ Iterator<Expression> arg_it = args.iterator ();
bool diag = (msym.get_attribute ("Diagnostics") != null);
@@ -1377,14 +1360,14 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
current_source_file.add_symbol_dependency (param.type_reference.data_type, SourceFileDependencyType.SOURCE);
}
- if (arg_it == null) {
+ if (!arg_it.next ()) {
if (param.default_expression == null) {
expr.error = true;
- Report.error (expr.source_reference, "Too few arguments, method `%s' does not take %d arguments".printf (msym.get_full_name (), args.length ()));
+ Report.error (expr.source_reference, "Too few arguments, method `%s' does not take %d arguments".printf (msym.get_full_name (), args.size));
return false;
}
} else {
- var arg = (Expression) arg_it.data;
+ var arg = arg_it.get ();
if (arg.static_type == null) {
// disallow untyped arguments except for type inference of callbacks
if (!(param.type_reference.data_type is Callback)) {
@@ -1398,21 +1381,20 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
return false;
}
- prev_arg_it = arg_it;
- arg_it = arg_it.next;
+ prev_arg = arg;
i++;
}
}
- if (!ellipsis && arg_it != null) {
+ if (!ellipsis && arg_it.next ()) {
expr.error = true;
- Report.error (expr.source_reference, "Too many arguments, method `%s' does not take %d arguments".printf (msym.get_full_name (), args.length ()));
+ Report.error (expr.source_reference, "Too many arguments, method `%s' does not take %d arguments".printf (msym.get_full_name (), args.size));
return false;
}
- if (diag && prev_arg_it != null) {
- var format_arg = (Expression) prev_arg_it.data;
+ if (diag && prev_arg != null) {
+ var format_arg = prev_arg;
if (format_arg is LiteralExpression) {
var format_lit = (StringLiteral) ((LiteralExpression) format_arg).literal;
format_lit.value = "\"%s:%d: %s".printf (expr.source_reference.file.filename, expr.source_reference.first_line, format_lit.value.offset (1));
@@ -1430,7 +1412,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
var msym = expr.call.symbol_reference;
TypeReference ret_type;
- List<weak FormalParameter> params;
+ Collection<FormalParameter> params;
if (msym is Invokable) {
var m = (Invokable) msym;
@@ -1470,7 +1452,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
if (msym is Method) {
var m = (Method) msym;
- expr.tree_can_fail = expr.can_fail = (m.get_error_domains ().length () > 0);
+ expr.tree_can_fail = expr.can_fail = (m.get_error_domains ().size > 0);
}
expr.static_type = ret_type;
@@ -1482,7 +1464,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
TypeReference instance_type = derived_instance_type;
// trace type arguments back to the datatype where the method has been declared
while (instance_type.data_type != generic_member.parent_symbol) {
- List<weak TypeReference> base_types = null;
+ Collection<TypeReference> base_types = null;
if (instance_type.data_type is Class) {
var cl = (Class) instance_type.data_type;
base_types = cl.get_base_types ();
@@ -1508,7 +1490,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
node_reference.error = true;
return null;
}
- type_arg = instance_type.get_type_arguments ().nth_data (param_index);
+ type_arg = instance_type.get_type_arguments ().get (param_index);
}
instance_base_type.add_type_argument (type_arg);
}
@@ -1527,7 +1509,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
node_reference.error = true;
return null;
}
- var actual_type = (TypeReference) instance_type.get_type_arguments ().nth_data (param_index);
+ var actual_type = (TypeReference) instance_type.get_type_arguments ().get (param_index);
if (actual_type == null) {
Report.error (node_reference.source_reference, "internal error: no actual argument found for type parameter %s".printf (generic_type.type_parameter.name));
node_reference.error = true;
@@ -1554,15 +1536,15 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
if (container_type is Array) {
var args = expr.container.static_type.get_type_arguments ();
- if (args.length () != 1) {
+ if (args.size != 1) {
expr.error = true;
- Report.error (expr.source_reference, "internal error: array reference with %d type arguments, expected 1".printf (args.length ()));
+ Report.error (expr.source_reference, "internal error: array reference with %d type arguments, expected 1".printf (args.size));
return;
}
- expr.static_type = (TypeReference) args.data;
+ expr.static_type = args.get (0);
} else if (container_type == string_type.data_type) {
- if (expr.get_indices ().length () != 1) {
+ if (expr.get_indices ().size != 1) {
expr.error = true;
Report.error (expr.source_reference, "Element access with more than one dimension is not supported for strings");
return;
@@ -1572,13 +1554,15 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
} else if (container_type != null && list_type != null && map_type != null &&
(container_type == list_type || container_type.is_subtype_of (list_type) ||
container_type == map_type || container_type.is_subtype_of (map_type))) {
- List<weak Expression> indices = expr.get_indices ();
- if (indices.length () != 1) {
+ Collection<Expression> indices = expr.get_indices ();
+ if (indices.size != 1) {
expr.error = true;
Report.error (expr.source_reference, "Element access with more than one dimension is not supported for the specified type");
return;
}
- var index = (Expression) indices.data;
+ Iterator<Expression> indices_it = indices.iterator ();
+ indices_it.next ();
+ var index = indices_it.get ();
index_int_type_check = false;
var get_sym = container_type.scope.lookup ("get");
@@ -1588,8 +1572,10 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
return;
}
var get_method = (Method) get_sym;
- List<weak FormalParameter> get_params = get_method.get_parameters ();
- var get_param = (FormalParameter) get_params.data;
+ Collection<FormalParameter> get_params = get_method.get_parameters ();
+ Iterator<FormalParameter> get_params_it = get_params.iterator ();
+ get_params_it.next ();
+ var get_param = get_params_it.get ();
var index_type = get_param.type_reference;
if (index_type.type_parameter != null) {
@@ -1632,12 +1618,14 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
expr.error = true;
Report.error (expr.source_reference, "Base access invalid outside of class and struct");
return;
- } else if (current_struct.get_base_types ().length () != 1) {
+ } else if (current_struct.get_base_types ().size != 1) {
expr.error = true;
- Report.error (expr.source_reference, "Base access invalid without base type %d".printf (current_struct.get_base_types ().length ()));
+ Report.error (expr.source_reference, "Base access invalid without base type %d".printf (current_struct.get_base_types ().size));
return;
}
- expr.static_type = current_struct.get_base_types ().first ().data;
+ Iterator<TypeReference> base_type_it = current_struct.get_base_types ().iterator ();
+ base_type_it.next ();
+ expr.static_type = base_type_it.get ();
} else {
expr.static_type = new TypeReference ();
expr.static_type.data_type = current_class.base_class;
@@ -1749,7 +1737,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
}
}
- if (expr.symbol_reference == null && expr.get_argument_list ().length () != 0) {
+ if (expr.symbol_reference == null && expr.get_argument_list ().size != 0) {
expr.static_type = null;
expr.error = true;
Report.error (expr.source_reference, "No arguments allowed when constructing type `%s'".printf (type.get_full_name ()));
@@ -1760,13 +1748,15 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
var m = (Method) expr.symbol_reference;
check_arguments (expr, m, m.get_parameters (), expr.get_argument_list ());
- expr.tree_can_fail = expr.can_fail = (m.get_error_domains ().length () > 0);
+ expr.tree_can_fail = expr.can_fail = (m.get_error_domains ().size > 0);
} else if (type is Enum) {
- if (expr.get_argument_list ().length () == 0) {
+ if (expr.get_argument_list ().size == 0) {
expr.error = true;
Report.error (expr.source_reference, "Too few arguments, errors need at least 1 argument");
} else {
- var ex = (Expression) expr.get_argument_list ().data;
+ Iterator<Expression> arg_it = expr.get_argument_list ().iterator ();
+ arg_it.next ();
+ var ex = arg_it.get ();
if (ex.static_type == null || !is_type_compatible (ex.static_type, string_type)) {
expr.error = true;
Report.error (expr.source_reference, "Invalid type for argument 1");
@@ -2126,7 +2116,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
expr.static_type = bool_type;
}
- private TypeReference compute_common_base_type (List<TypeReference> types) {
+ private TypeReference compute_common_base_type (Collection<TypeReference> types) {
bool null_found = false;
bool class_or_iface_found = false;
bool type_param_found = false;
@@ -2246,9 +2236,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
}
/* FIXME: support memory management */
- List<TypeReference> types;
- types.append (expr.true_expression.static_type);
- types.append (expr.false_expression.static_type);
+ Gee.List<TypeReference> types = new ArrayList<TypeReference> ();
+ types.add (expr.true_expression.static_type);
+ types.add (expr.false_expression.static_type);
expr.static_type = compute_common_base_type (types);
}
@@ -2303,23 +2293,21 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
l.method.owner = current_symbol.scope;
var lambda_params = l.get_parameters ();
- weak List<weak FormalParameter> lambda_param_it = lambda_params;
+ Iterator<string> lambda_param_it = lambda_params.iterator ();
foreach (FormalParameter cb_param in cb.get_parameters ()) {
- if (lambda_param_it == null) {
+ if (!lambda_param_it.next ()) {
/* lambda expressions are allowed to have less parameters */
break;
}
- var lambda_param = (string) lambda_param_it.data;
+ string lambda_param = lambda_param_it.get ();
var param = new FormalParameter (lambda_param, cb_param.type_reference);
l.method.add_parameter (param);
-
- lambda_param_it = lambda_param_it.next;
}
- if (lambda_param_it != null) {
+ if (lambda_param_it.next ()) {
/* lambda expressions may not expect more parameters */
l.error = true;
Report.error (l.source_reference, "lambda expression: too many parameters");
@@ -2543,12 +2531,12 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
/* rhs transfers ownership of the expression */
var args = ea.container.static_type.get_type_arguments ();
- if (args.length () != 1) {
+ if (args.size != 1) {
a.error = true;
Report.error (ea.source_reference, "internal error: array reference without type arguments");
return;
}
- var element_type = (TypeReference) args.data;
+ var element_type = args.get (0);
if (!element_type.takes_ownership) {
/* lhs doesn't own the value */
diff --git a/vala/valasignal.vala b/vala/valasignal.vala
index bf142af27..dc3cc3c55 100644
--- a/vala/valasignal.vala
+++ b/vala/valasignal.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents an object signal. Signals enable objects to provide notifications.
@@ -42,7 +43,7 @@ public class Vala.Signal : Member, Invokable, Lockable {
*/
public bool has_emitter { get; set; }
- private List<FormalParameter> parameters;
+ private Gee.List<FormalParameter> parameters = new ArrayList<FormalParameter> ();
private Callback generated_callback;
private string cname;
@@ -66,12 +67,12 @@ public class Vala.Signal : Member, Invokable, Lockable {
* @param param a formal parameter
*/
public void add_parameter (FormalParameter! param) {
- parameters.append (param);
+ parameters.add (param);
scope.add (param.name, param);
}
- public List<weak FormalParameter> get_parameters () {
- return parameters.copy ();
+ public Collection<FormalParameter> get_parameters () {
+ return new ReadOnlyCollection<FormalParameter> (parameters);
}
public TypeReference get_return_type () {
diff --git a/vala/valasourcefile.vala b/vala/valasourcefile.vala
index 261199665..b8e2effc7 100644
--- a/vala/valasourcefile.vala
+++ b/vala/valasourcefile.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a Vala source or VAPI package file.
@@ -68,21 +69,21 @@ public class Vala.SourceFile {
*/
public weak CodeContext context { get; set; }
- private List<NamespaceReference> using_directives;
+ private Gee.List<NamespaceReference> using_directives = new ArrayList<NamespaceReference> ();
- private List<CodeNode> nodes;
+ private Gee.List<CodeNode> nodes = new ArrayList<CodeNode> ();
private string cheader_filename = null;
private string csource_filename = null;
private string cinclude_filename = null;
- private List<string> header_external_includes;
- private List<string> header_internal_includes;
- private List<string> source_external_includes;
- private List<string> source_internal_includes;
+ private Gee.List<string> header_external_includes = new ArrayList<string> ();
+ private Gee.List<string> header_internal_includes = new ArrayList<string> ();
+ private Gee.List<string> source_external_includes = new ArrayList<string> ();
+ private Gee.List<string> source_internal_includes = new ArrayList<string> ();
- private List<weak SourceFile> header_internal_full_dependencies;
- private List<weak SourceFile> header_internal_dependencies;
+ private Gee.List<weak SourceFile> header_internal_full_dependencies = new ArrayList<weak SourceFile> ();
+ private Gee.List<weak SourceFile> header_internal_dependencies = new ArrayList<weak SourceFile> ();
/**
* Creates a new source file.
@@ -100,7 +101,7 @@ public class Vala.SourceFile {
* @param ns reference to namespace
*/
public void add_using_directive (NamespaceReference! ns) {
- using_directives.append (ns);
+ using_directives.add (ns);
}
/**
@@ -108,8 +109,8 @@ public class Vala.SourceFile {
*
* @return using directive list
*/
- public List<weak NamespaceReference> get_using_directives () {
- return using_directives.copy ();
+ public Collection<NamespaceReference> get_using_directives () {
+ return new ReadOnlyCollection<NamespaceReference> (using_directives);
}
/**
@@ -118,16 +119,7 @@ public class Vala.SourceFile {
* @param node a code node
*/
public void add_node (CodeNode! node) {
- nodes.append (node);
- }
-
- /**
- * Removes the specified code node from this source file.
- *
- * @param node a code node
- */
- public void remove_node (CodeNode! node) {
- nodes.remove (node);
+ nodes.add (node);
}
/**
@@ -135,8 +127,8 @@ public class Vala.SourceFile {
*
* @return code node list
*/
- public List<weak CodeNode> get_nodes () {
- return nodes.copy ();
+ public Collection<CodeNode> get_nodes () {
+ return new ReadOnlyCollection<CodeNode> (nodes);
}
public void accept (CodeVisitor! visitor) {
@@ -205,6 +197,10 @@ public class Vala.SourceFile {
* @param dep_type type of dependency
*/
public void add_symbol_dependency (Symbol! sym, SourceFileDependencyType dep_type) {
+ if (pkg) {
+ return;
+ }
+
Symbol s;
if (sym is DataType ||
@@ -227,11 +223,11 @@ public class Vala.SourceFile {
if (dep_type == SourceFileDependencyType.SOURCE) {
if (s.source_reference.file.pkg) {
foreach (string fn in s.get_cheader_filenames ()) {
- source_external_includes.append (fn);
+ source_external_includes.add (fn);
}
} else {
foreach (string fn in s.get_cheader_filenames ()) {
- source_internal_includes.append (fn);
+ source_internal_includes.add (fn);
}
}
return;
@@ -240,19 +236,19 @@ public class Vala.SourceFile {
if (s.source_reference.file.pkg) {
/* external package */
foreach (string fn in s.get_cheader_filenames ()) {
- header_external_includes.append (fn);
+ header_external_includes.add (fn);
}
return;
}
if (dep_type == SourceFileDependencyType.HEADER_FULL || (s is DataType && !((DataType)s).is_reference_type ())) {
foreach (string fn in s.get_cheader_filenames ()) {
- header_internal_includes.append (fn);
+ header_internal_includes.add (fn);
}
- header_internal_full_dependencies.append (s.source_reference.file);
+ header_internal_full_dependencies.add (s.source_reference.file);
}
- header_internal_dependencies.append (s.source_reference.file);
+ header_internal_dependencies.add (s.source_reference.file);
}
/**
@@ -261,8 +257,8 @@ public class Vala.SourceFile {
*
* @return external include list for C header file
*/
- public weak List<string> get_header_external_includes () {
- return header_external_includes;
+ public Collection<string> get_header_external_includes () {
+ return new ReadOnlyCollection<string> (header_external_includes);
}
/**
@@ -274,7 +270,7 @@ public class Vala.SourceFile {
public void add_header_internal_include (string! include) {
/* skip includes to self */
if (include != get_cinclude_filename ()) {
- header_internal_includes.append (include);
+ header_internal_includes.add (include);
}
}
@@ -284,8 +280,8 @@ public class Vala.SourceFile {
*
* @return internal include list for C header file
*/
- public weak List<string> get_header_internal_includes () {
- return header_internal_includes;
+ public Collection<string> get_header_internal_includes () {
+ return new ReadOnlyCollection<string> (header_internal_includes);
}
/**
@@ -294,8 +290,8 @@ public class Vala.SourceFile {
*
* @return include list for C source file
*/
- public weak List<string> get_source_external_includes () {
- return source_external_includes;
+ public Collection<string> get_source_external_includes () {
+ return new ReadOnlyCollection<string> (source_external_includes);
}
/**
@@ -304,8 +300,8 @@ public class Vala.SourceFile {
*
* @return include list for C source file
*/
- public weak List<string> get_source_internal_includes () {
- return source_internal_includes;
+ public Collection<string> get_source_internal_includes () {
+ return new ReadOnlyCollection<string> (source_internal_includes);
}
/**
@@ -314,8 +310,8 @@ public class Vala.SourceFile {
*
* @return definite source file dependencies
*/
- public weak List<SourceFile> get_header_internal_full_dependencies () {
- return header_internal_full_dependencies;
+ public Collection<weak SourceFile> get_header_internal_full_dependencies () {
+ return new ReadOnlyCollection<weak SourceFile> (header_internal_full_dependencies);
}
/**
@@ -324,8 +320,8 @@ public class Vala.SourceFile {
*
* @return loose source file dependencies
*/
- public weak List<SourceFile> get_header_internal_dependencies () {
- return header_internal_dependencies;
+ public Collection<weak SourceFile> get_header_internal_dependencies () {
+ return new ReadOnlyCollection<weak SourceFile> (header_internal_dependencies);
}
}
diff --git a/vala/valasourcefilecycle.vala b/vala/valasourcefilecycle.vala
index e77f6cd4e..2154deece 100644
--- a/vala/valasourcefilecycle.vala
+++ b/vala/valasourcefilecycle.vala
@@ -1,6 +1,6 @@
/* valasourcefilecycle.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 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
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a dependency cycle of source files.
@@ -29,7 +30,7 @@ public class Vala.SourceFileCycle {
/**
* The members of this source file cycle.
*/
- public List<weak SourceFile> files;
+ public Gee.List<weak SourceFile> files = new ArrayList<weak SourceFile> ();
/**
* The head of this source file cycle.
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index dcfdf4d4f..2d512e165 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -21,17 +21,18 @@
*/
using GLib;
+using Gee;
/**
* Represents a struct declaration in the source code.
*/
public class Vala.Struct : DataType {
- private List<TypeParameter> type_parameters;
- private List<Constant> constants;
- private List<Field> fields;
- private List<Method> methods;
+ private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
+ private Gee.List<Constant> constants = new ArrayList<Constant> ();
+ private Gee.List<Field> fields = new ArrayList<Field> ();
+ private Gee.List<Method> methods = new ArrayList<Method> ();
- private List<TypeReference> base_types;
+ private Gee.List<TypeReference> base_types = new ArrayList<TypeReference> ();
private string cname;
private string const_cname;
@@ -57,13 +58,11 @@ public class Vala.Struct : DataType {
/**
* Creates a new struct.
*
- * @param name type name
- * @param source reference to source code
- * @return newly created struct
+ * @param name type name
+ * @param source_reference reference to source code
+ * @return newly created struct
*/
- public Struct (string! _name, SourceReference source = null) {
- name = _name;
- source_reference = source;
+ public Struct (construct string! name, construct SourceReference source_reference = null) {
}
/**
@@ -72,7 +71,7 @@ public class Vala.Struct : DataType {
* @param p a type parameter
*/
public void add_type_parameter (TypeParameter! p) {
- type_parameters.append (p);
+ type_parameters.add (p);
p.type = this;
scope.add (p.name, p);
}
@@ -83,7 +82,7 @@ public class Vala.Struct : DataType {
* @param c a constant
*/
public void add_constant (Constant! c) {
- constants.append (c);
+ constants.add (c);
scope.add (c.name, c);
}
@@ -93,7 +92,7 @@ public class Vala.Struct : DataType {
* @param f a field
*/
public void add_field (Field! f) {
- fields.append (f);
+ fields.add (f);
scope.add (f.name, f);
}
@@ -102,8 +101,8 @@ public class Vala.Struct : DataType {
*
* @return list of fields
*/
- public List<weak Field> get_fields () {
- return fields.copy ();
+ public Collection<Field> get_fields () {
+ return new ReadOnlyCollection<Field> (fields);
}
/**
@@ -123,7 +122,7 @@ public class Vala.Struct : DataType {
default_construction_method = m;
}
- methods.append (m);
+ methods.add (m);
scope.add (m.name, m);
}
@@ -132,8 +131,8 @@ public class Vala.Struct : DataType {
*
* @return list of methods
*/
- public List<weak Method> get_methods () {
- return methods.copy ();
+ public Collection<Method> get_methods () {
+ return new ReadOnlyCollection<Method> (methods);
}
public override void accept (CodeVisitor! visitor) {
@@ -424,7 +423,7 @@ public class Vala.Struct : DataType {
* @param type a class or interface reference
*/
public void add_base_type (TypeReference! type) {
- base_types.append (type);
+ base_types.add (type);
}
/**
@@ -432,8 +431,8 @@ public class Vala.Struct : DataType {
*
* @return list of base types
*/
- public List<weak TypeReference> get_base_types () {
- return base_types.copy ();
+ public Collection<TypeReference> get_base_types () {
+ return new ReadOnlyCollection<TypeReference> (base_types);
}
public override int get_type_parameter_index (string! name) {
diff --git a/vala/valaswitchsection.vala b/vala/valaswitchsection.vala
index f7fd10e2f..6b6cf5b1a 100644
--- a/vala/valaswitchsection.vala
+++ b/vala/valaswitchsection.vala
@@ -21,22 +21,22 @@
*/
using GLib;
+using Gee;
/**
* Represents a switch section in the source code.
*/
public class Vala.SwitchSection : CodeNode {
- private List<SwitchLabel> labels;
- private List<Statement> statement_list;
+ private Gee.List<SwitchLabel> labels = new ArrayList<SwitchLabel> ();
+ private Gee.List<Statement> statement_list = new ArrayList<Statement> ();
/**
* Creates a new switch section.
*
- * @param source reference to source code
- * @return newly created switch section
+ * @param source_reference reference to source code
+ * @return newly created switch section
*/
- public SwitchSection (SourceReference source) {
- source_reference = source;
+ public SwitchSection (construct SourceReference source_reference) {
}
/**
@@ -45,7 +45,7 @@ public class Vala.SwitchSection : CodeNode {
* @param label a switch label
*/
public void add_label (SwitchLabel! label) {
- labels.append (label);
+ labels.add (label);
}
/**
@@ -53,8 +53,8 @@ public class Vala.SwitchSection : CodeNode {
*
* @return switch label list
*/
- public List<weak SwitchLabel> get_labels () {
- return labels.copy ();
+ public Collection<SwitchLabel> get_labels () {
+ return new ReadOnlyCollection<SwitchLabel> (labels);
}
public bool has_default_label () {
@@ -73,7 +73,7 @@ public class Vala.SwitchSection : CodeNode {
* @param stmt a statement
*/
public void add_statement (Statement! stmt) {
- statement_list.append (stmt);
+ statement_list.add (stmt);
}
/**
@@ -81,8 +81,8 @@ public class Vala.SwitchSection : CodeNode {
*
* @return statement list
*/
- public List<weak Statement> get_statements () {
- return statement_list.copy ();
+ public Collection<Statement> get_statements () {
+ return new ReadOnlyCollection<Statement> (statement_list);
}
public override void accept (CodeVisitor! visitor) {
diff --git a/vala/valaswitchstatement.vala b/vala/valaswitchstatement.vala
index 1d0ae011f..40a1a1d0f 100644
--- a/vala/valaswitchstatement.vala
+++ b/vala/valaswitchstatement.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a switch selection statement in the source code.
@@ -40,18 +41,16 @@ public class Vala.SwitchStatement : CodeNode, Statement {
}
private Expression! _expression;
- private List<SwitchSection> sections;
+ private Gee.List<SwitchSection> sections = new ArrayList<SwitchSection> ();
/**
* Creates a new switch statement.
*
- * @param expr switch expression
- * @param source reference to source code
- * @return newly created switch statement
+ * @param expression switch expression
+ * @param source_reference reference to source code
+ * @return newly created switch statement
*/
- public SwitchStatement (Expression! expr, SourceReference source) {
- expression = expr;
- source_reference = source;
+ public SwitchStatement (construct Expression! expression, construct SourceReference source_reference) {
}
/**
@@ -60,7 +59,7 @@ public class Vala.SwitchStatement : CodeNode, Statement {
* @param section a switch section
*/
public void add_section (SwitchSection! section) {
- sections.append (section);
+ sections.add (section);
}
/**
@@ -68,8 +67,8 @@ public class Vala.SwitchStatement : CodeNode, Statement {
*
* @return section list
*/
- public List<weak SwitchSection> get_sections () {
- return sections.copy ();
+ public Collection<SwitchSection> get_sections () {
+ return new ReadOnlyCollection<SwitchSection> (sections);
}
public override void accept (CodeVisitor! visitor) {
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index 0ff6f9af4..83d76e6e2 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a node in the symbol tree.
@@ -71,7 +72,7 @@ public abstract class Vala.Symbol : CodeNode {
get { return _scope; }
}
- private Scope _owner;
+ private weak Scope _owner;
private Scope _scope;
construct {
@@ -144,8 +145,8 @@ public abstract class Vala.Symbol : CodeNode {
*
* @return list of C header filenames for this symbol
*/
- public virtual List<weak string> get_cheader_filenames () {
- return null;
+ public virtual Collection<string> get_cheader_filenames () {
+ return new ReadOnlyCollection<string> ();
}
/**
diff --git a/vala/valasymbolresolver.vala b/vala/valasymbolresolver.vala
index c76898c18..e5921de21 100644
--- a/vala/valasymbolresolver.vala
+++ b/vala/valasymbolresolver.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Code visitor resolving symbol names.
@@ -28,7 +29,7 @@ using GLib;
public class Vala.SymbolResolver : CodeVisitor {
Symbol root_symbol;
Scope current_scope;
- List<weak NamespaceReference> current_using_directives;
+ Collection<NamespaceReference> current_using_directives;
Class object_class;
diff --git a/vala/valatrystatement.vala b/vala/valatrystatement.vala
index dca02eca2..ad2f73cb1 100644
--- a/vala/valatrystatement.vala
+++ b/vala/valatrystatement.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a try statement in the source code.
@@ -29,14 +30,14 @@ public class Vala.TryStatement : CodeNode, Statement {
/**
* Specifies the body of the try statement.
*/
- public Block! body { get; set construct; }
+ public Block! body { get; set; }
/**
* Specifies the body of the optional finally clause.
*/
public Block finally_body { get; set; }
- private List<CatchClause> catch_clauses;
+ private Gee.List<CatchClause> catch_clauses = new ArrayList<CatchClause> ();
/**
* Creates a new try statement.
@@ -55,7 +56,7 @@ public class Vala.TryStatement : CodeNode, Statement {
* @param clause a catch clause
*/
public void add_catch_clause (CatchClause! clause) {
- catch_clauses.append (clause);
+ catch_clauses.add (clause);
}
/**
@@ -63,8 +64,8 @@ public class Vala.TryStatement : CodeNode, Statement {
*
* @return list of catch clauses
*/
- public List<weak CatchClause> get_catch_clauses () {
- return catch_clauses.copy ();
+ public Collection<CatchClause> get_catch_clauses () {
+ return new ReadOnlyCollection<CatchClause> (catch_clauses);
}
public override void accept (CodeVisitor! visitor) {
diff --git a/vala/valatypeparameter.vala b/vala/valatypeparameter.vala
index 5867d2537..4d59588ab 100644
--- a/vala/valatypeparameter.vala
+++ b/vala/valatypeparameter.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a generic type parameter in the source code.
@@ -32,8 +33,7 @@ public class Vala.TypeParameter : Symbol {
public weak DataType type;
/* holds the array types of this type; each rank is a separate one */
- /* FIXME: uses string because int does not work as key yet */
- private HashTable<string,Array> array_types = new HashTable.full (str_hash, str_equal, g_free, g_object_unref);
+ private Map<int,Array> array_types;
/**
* Creates a new generic type parameter.
@@ -58,9 +58,17 @@ public class Vala.TypeParameter : Symbol {
* @return array type for this type parameter
*/
public Array! get_array (int rank) {
- Array array_type = (Array) array_types.lookup (rank.to_string ());
-
+ Array array_type = null;
+
+ if (array_types != null) {
+ array_type = array_types[rank];
+ }
+
if (array_type == null) {
+ if (array_types == null) {
+ array_types = new HashMap<int,Array> ();
+ }
+
var new_array_type = new Array.with_type_parameter (this, rank, source_reference);
parent_symbol.scope.add (new_array_type.name, new_array_type);
@@ -74,7 +82,7 @@ public class Vala.TypeParameter : Symbol {
/* link the array type to the same source as the container type */
new_array_type.source_reference = this.source_reference;
- array_types.insert (rank.to_string (), new_array_type);
+ array_types[rank] = new_array_type;
array_type = new_array_type;
}
diff --git a/vala/valatypereference.vala b/vala/valatypereference.vala
index 482a8493a..133d8ffc1 100644
--- a/vala/valatypereference.vala
+++ b/vala/valatypereference.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
/**
* A reference to a data type. This is used to specify static types of
@@ -104,7 +105,7 @@ public class Vala.TypeReference : CodeNode {
*/
public bool is_weak { get; set; }
- private List<TypeReference> type_argument_list;
+ private ArrayList<TypeReference> type_argument_list = new ArrayList<TypeReference> ();
public TypeReference () {
}
@@ -166,7 +167,7 @@ public class Vala.TypeReference : CodeNode {
* @param arg a type reference
*/
public void add_type_argument (TypeReference! arg) {
- type_argument_list.append (arg);
+ type_argument_list.add (arg);
}
/**
@@ -174,20 +175,22 @@ public class Vala.TypeReference : CodeNode {
*
* @return type argument list
*/
- public List<weak TypeReference> get_type_arguments () {
- return type_argument_list.copy ();
+ public Gee.List<TypeReference> get_type_arguments () {
+ return new ReadOnlyList<TypeReference> (type_argument_list);
}
/**
* Removes all generic type arguments.
*/
public void remove_all_type_arguments () {
- type_argument_list = null;
+ type_argument_list.clear ();
}
public override void accept (CodeVisitor! visitor) {
- foreach (TypeReference type_arg in type_argument_list) {
- type_arg.accept (visitor);
+ if (((Gee.List<TypeReference>) type_argument_list).size > 0) {
+ foreach (TypeReference type_arg in type_argument_list) {
+ type_arg.accept (visitor);
+ }
}
visitor.visit_type_reference (this);
@@ -290,7 +293,7 @@ public class Vala.TypeReference : CodeNode {
result.is_weak = is_weak;
foreach (TypeReference arg in type_argument_list) {
- result.type_argument_list.append (arg.copy ());
+ result.type_argument_list.add (arg.copy ());
}
return result;
diff --git a/vala/valavariabledeclarator.vala b/vala/valavariabledeclarator.vala
index 743a4348b..1e28e2205 100644
--- a/vala/valavariabledeclarator.vala
+++ b/vala/valavariabledeclarator.vala
@@ -21,6 +21,7 @@
*/
using GLib;
+using Gee;
/**
* Represents a variable declarator in the source code.
@@ -73,7 +74,7 @@ public class Vala.VariableDeclarator : Symbol, Invokable {
visitor.visit_variable_declarator (this);
}
- public List<weak FormalParameter> get_parameters () {
+ public Collection<FormalParameter> get_parameters () {
if (!is_invokable ()) {
return null;
}
diff --git a/vapi/gio-standalone.vala b/vapi/gio-standalone.vala
index d1ece9d65..21ccbb5ae 100644
--- a/vapi/gio-standalone.vala
+++ b/vapi/gio-standalone.vala
@@ -1,6 +1,6 @@
[CCode (cprefix = "G", lower_case_cprefix = "g_")]
namespace GLib {
- [CCode (cprefix = "G_DIRECTORY_MONITOR_EVENT_", cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cprefix = "G_DIRECTORY_MONITOR_EVENT_", cheader_filename = "gio/gvfs.h,glib.h")]
public enum DirectoryMonitorEvent {
CHANGED,
DELETED,
@@ -8,7 +8,7 @@ namespace GLib {
ATTRIBUTE_CHANGED,
UNMOUNTED,
}
- [CCode (cprefix = "G_FILE_ATTRIBUTE_TYPE_", cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cprefix = "G_FILE_ATTRIBUTE_TYPE_", cheader_filename = "gio/gvfs.h,glib.h")]
public enum FileAttributeType {
INVALID,
STRING,
@@ -18,23 +18,23 @@ namespace GLib {
UINT64,
INT64,
}
- [CCode (cprefix = "G_FILE_COPY_", cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cprefix = "G_FILE_COPY_", cheader_filename = "gio/gvfs.h,glib.h")]
public enum FileCopyFlags {
OVERWRITE,
BACKUP,
}
- [CCode (cprefix = "G_FILE_FLAG_", cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cprefix = "G_FILE_FLAG_", cheader_filename = "gio/gvfs.h,glib.h")]
public enum FileFlags {
HIDDEN,
SYMLINK,
LOCAL,
VIRTUAL,
}
- [CCode (cprefix = "G_FILE_GET_INFO_NOFOLLOW_", cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cprefix = "G_FILE_GET_INFO_NOFOLLOW_", cheader_filename = "gio/gvfs.h,glib.h")]
public enum FileGetInfoFlags {
SYMLINKS,
}
- [CCode (cprefix = "G_FILE_MONITOR_EVENT_", cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cprefix = "G_FILE_MONITOR_EVENT_", cheader_filename = "gio/gvfs.h,glib.h")]
public enum FileMonitorEvent {
CHANGED,
DELETED,
@@ -42,7 +42,7 @@ namespace GLib {
ATTRIBUTE_CHANGED,
UNMOUNTED,
}
- [CCode (cprefix = "G_FILE_TYPE_", cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cprefix = "G_FILE_TYPE_", cheader_filename = "gio/gvfs.h,glib.h")]
public enum FileType {
UNKNOWN,
REGULAR,
@@ -52,7 +52,7 @@ namespace GLib {
SHORTCUT,
MOUNTABLE,
}
- [CCode (cprefix = "G_IO_ERROR_", cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cprefix = "G_IO_ERROR_", cheader_filename = "gio/gvfs.h,glib.h")]
public enum IOErrorEnum {
FAILED,
NOT_FOUND,
@@ -80,7 +80,7 @@ namespace GLib {
WRONG_MTIME,
TIMED_OUT,
}
- [CCode (cprefix = "G_PASSWORD_FLAGS_", cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cprefix = "G_PASSWORD_FLAGS_", cheader_filename = "gio/gvfs.h,glib.h")]
public enum PasswordFlags {
NEED_PASSWORD,
NEED_USERNAME,
@@ -88,13 +88,13 @@ namespace GLib {
SAVING_SUPPORTED,
ANON_SUPPORTED,
}
- [CCode (cprefix = "G_PASSWORD_SAVE_", cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cprefix = "G_PASSWORD_SAVE_", cheader_filename = "gio/gvfs.h,glib.h")]
public enum PasswordSave {
NEVER,
FOR_SESSION,
PERMANENTLY,
}
- [CCode (cprefix = "G_UNIX_MOUNT_TYPE_", cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cprefix = "G_UNIX_MOUNT_TYPE_", cheader_filename = "gio/gvfs.h,glib.h")]
public enum UnixMountType {
UNKNOWN,
FLOPPY,
@@ -110,7 +110,7 @@ namespace GLib {
CAMERA,
HD,
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class BufferedInputStream : GLib.FilterInputStream {
public static GLib.Type get_type ();
public BufferedInputStream (GLib.InputStream base_stream);
@@ -118,7 +118,7 @@ namespace GLib {
[NoAccessorMethod]
public weak uint buffer_size { get; construct; }
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class BufferedOutputStream : GLib.FilterOutputStream {
public static GLib.Type get_type ();
public BufferedOutputStream (GLib.OutputStream base_stream);
@@ -126,7 +126,7 @@ namespace GLib {
[NoAccessorMethod]
public weak uint buffer_size { get; construct; }
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class Cancellable : GLib.Object {
public void cancel ();
public int get_fd ();
@@ -136,12 +136,12 @@ namespace GLib {
public void reset ();
public signal void cancelled ();
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class DesktopAppInfo : GLib.Object, GLib.AppInfo {
public static GLib.Type get_type ();
public DesktopAppInfo (string desktop_id);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class DirectoryMonitor : GLib.Object {
public virtual bool cancel ();
public void emit_event (GLib.File child, GLib.File other_file, GLib.DirectoryMonitorEvent event_type);
@@ -149,7 +149,7 @@ namespace GLib {
public void set_rate_limit (int limit_msecs);
public signal void changed (GLib.File child, GLib.File other_file, GLib.DirectoryMonitorEvent event_type);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class FileEnumerator : GLib.Object {
public static GLib.Type get_type ();
public bool has_pending ();
@@ -160,13 +160,13 @@ namespace GLib {
public virtual bool stop (GLib.Cancellable cancellable, GLib.Error error);
public virtual void stop_async (int io_priority, GLib.AsyncStopEnumeratingCallback callback, pointer user_data, GLib.Cancellable cancellable);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class FileIcon : GLib.Object, GLib.Icon, GLib.LoadableIcon {
public weak GLib.File get_file ();
public static GLib.Type get_type ();
public FileIcon (GLib.File file);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class FileInfo : GLib.Object {
public weak GLib.FileInfo copy ();
public weak string get_attribute_as_string (string attribute);
@@ -209,12 +209,12 @@ namespace GLib {
public void set_size (int64 size);
public void set_symlink_target (string symlink_target);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class FileInputStream : GLib.InputStream, GLib.Seekable {
public virtual weak GLib.FileInfo get_file_info (string attributes, GLib.Cancellable cancellable, GLib.Error error);
public static GLib.Type get_type ();
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class FileMonitor : GLib.Object {
public virtual bool cancel ();
public static weak GLib.DirectoryMonitor directory (GLib.File file);
@@ -224,7 +224,7 @@ namespace GLib {
public void set_rate_limit (int limit_msecs);
public signal void changed (GLib.File file, GLib.File other_file, GLib.FileMonitorEvent event_type);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class FileOutputStream : GLib.OutputStream {
public virtual weak GLib.FileInfo get_file_info (string attributes, GLib.Cancellable cancellable, GLib.Error error);
public void get_final_mtime (GLib.TimeVal mtime);
@@ -233,21 +233,21 @@ namespace GLib {
public void set_final_mtime (GLib.TimeVal final_mtime);
public void set_should_get_final_mtime (bool get_final_mtime);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class FilterInputStream : GLib.InputStream {
public weak GLib.InputStream get_base_stream ();
public static GLib.Type get_type ();
[NoAccessorMethod]
public weak GLib.InputStream base_stream { get; construct; }
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class FilterOutputStream : GLib.OutputStream {
public weak GLib.OutputStream get_base_stream ();
public static GLib.Type get_type ();
[NoAccessorMethod]
public weak GLib.OutputStream base_stream { get; construct; }
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class InputStream : GLib.Object {
public virtual bool close (GLib.Cancellable cancellable, GLib.Error error);
public virtual void close_async (int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback callback, pointer user_data);
@@ -264,12 +264,12 @@ namespace GLib {
public virtual void skip_async (ulong count, int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback callback, pointer user_data);
public virtual long skip_finish (GLib.AsyncResult result, GLib.Error error);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class LocalDirectoryMonitor : GLib.DirectoryMonitor {
public static GLib.Type get_type ();
public static weak GLib.DirectoryMonitor start (string dirname);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class LocalFile : GLib.Object, GLib.File {
public static GLib.Type get_type ();
public static weak GLib.FileInfo info_get (string basename, string path, GLib.FileAttributeMatcher attribute_matcher, GLib.FileGetInfoFlags flags, GLib.LocalParentFileInfo parent_info, GLib.Error error);
@@ -277,39 +277,39 @@ namespace GLib {
public static void info_get_parent_info (string dir, GLib.FileAttributeMatcher attribute_matcher, GLib.LocalParentFileInfo parent_info);
public LocalFile (string filename);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class LocalFileEnumerator : GLib.FileEnumerator {
public static GLib.Type get_type ();
public LocalFileEnumerator (string filename, string attributes, GLib.FileGetInfoFlags flags, GLib.Cancellable cancellable, GLib.Error error);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class LocalFileInputStream : GLib.FileInputStream {
public static GLib.Type get_type ();
public LocalFileInputStream (int fd);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class LocalFileMonitor : GLib.FileMonitor {
public static GLib.Type get_type ();
public static weak GLib.FileMonitor start (string dirname);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class LocalFileOutputStream : GLib.FileOutputStream {
public static weak GLib.FileOutputStream append (string filename, GLib.Cancellable cancellable, GLib.Error error);
public static weak GLib.FileOutputStream create (string filename, GLib.Cancellable cancellable, GLib.Error error);
public static GLib.Type get_type ();
public static weak GLib.FileOutputStream replace (string filename, ulong mtime, bool make_backup, GLib.Cancellable cancellable, GLib.Error error);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class LocalVfs : GLib.Object, GLib.Vfs {
public static GLib.Type get_type ();
public LocalVfs ();
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class MemoryInputStream : GLib.InputStream, GLib.Seekable {
public static weak GLib.InputStream from_data (pointer data, ulong len);
public static GLib.Type get_type ();
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class MemoryOutputStream : GLib.OutputStream, GLib.Seekable {
public static GLib.Type get_type ();
public MemoryOutputStream (GLib.ByteArray data);
@@ -321,7 +321,7 @@ namespace GLib {
[NoAccessorMethod]
public weak uint size_limit { get; set; }
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class MountOperation : GLib.Object {
public bool get_anonymous ();
public int get_choice ();
@@ -342,7 +342,7 @@ namespace GLib {
[HasEmitter]
public signal void reply (bool abort);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class OutputStream : GLib.Object {
public virtual bool close (GLib.Cancellable cancellable, GLib.Error error);
public virtual void close_async (int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback callback, pointer user_data);
@@ -359,7 +359,7 @@ namespace GLib {
public virtual void write_async (pointer buffer, ulong count, int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback callback, pointer user_data);
public virtual long write_finish (GLib.AsyncResult result, GLib.Error error);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class SimpleAsyncResult : GLib.Object, GLib.AsyncResult {
public void complete ();
public void complete_in_idle ();
@@ -381,31 +381,31 @@ namespace GLib {
public void set_op_res_gpointer (pointer op_res, GLib.DestroyNotify destroy_op_res);
public void set_op_res_gssize (long op_res);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class SocketInputStream : GLib.InputStream {
public static GLib.Type get_type ();
public SocketInputStream (int fd, bool close_fd_at_close);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class SocketOutputStream : GLib.OutputStream {
public static GLib.Type get_type ();
public SocketOutputStream (int fd, bool close_fd_at_close);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class ThemedIcon : GLib.Object, GLib.Icon {
public weak string get_names ();
public static GLib.Type get_type ();
public ThemedIcon (string iconname);
public ThemedIcon.from_names (string iconnames);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class UnionDrive : GLib.Object, GLib.Drive {
public bool child_is_for_monitor (GLib.VolumeMonitor child_monitor);
public static GLib.Type get_type ();
public bool is_for_child_drive (GLib.Drive child_drive);
public UnionDrive (GLib.VolumeMonitor union_monitor, GLib.Drive child_drive, GLib.VolumeMonitor child_monitor);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class UnionVolume : GLib.Object, GLib.Volume {
public void add_volume (GLib.Volume volume, GLib.VolumeMonitor monitor);
public weak GLib.Volume get_child_for_monitor (GLib.VolumeMonitor child_monitor);
@@ -415,13 +415,13 @@ namespace GLib {
public UnionVolume (GLib.VolumeMonitor union_monitor, GLib.Volume volume, GLib.VolumeMonitor monitor);
public void remove_volume (GLib.Volume volume);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class UnionVolumeMonitor : GLib.VolumeMonitor {
public weak GLib.Drive convert_drive (GLib.Drive child_drive);
public weak GLib.List convert_volumes (GLib.List child_volumes);
public static GLib.Type get_type ();
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class UnixDrive : GLib.Object, GLib.Drive {
public void disconnected ();
public static GLib.Type get_type ();
@@ -430,7 +430,7 @@ namespace GLib {
public void set_volume (GLib.UnixVolume volume);
public void unset_volume (GLib.UnixVolume volume);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class UnixVolume : GLib.Object, GLib.Volume {
public static GLib.Type get_type ();
public bool has_mountpoint (string mountpoint);
@@ -438,13 +438,13 @@ namespace GLib {
public void unmounted ();
public void unset_drive (GLib.UnixDrive drive);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class UnixVolumeMonitor : GLib.VolumeMonitor {
public static GLib.Type get_type ();
public weak GLib.UnixDrive lookup_drive_for_mountpoint (string mountpoint);
public UnixVolumeMonitor ();
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class VolumeMonitor : GLib.Object {
public virtual weak GLib.List get_connected_drives ();
public virtual weak GLib.List get_mounted_volumes ();
@@ -455,11 +455,11 @@ namespace GLib {
public signal void drive_connected (GLib.Drive drive);
public signal void drive_disconnected (GLib.Drive drive);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public class Win32AppInfo : GLib.Object, GLib.AppInfo {
public static GLib.Type get_type ();
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public interface AppInfo {
public static weak GLib.AppInfo create_from_commandline (string commandline, string application_name, GLib.Error error);
public virtual weak GLib.AppInfo dup ();
@@ -475,13 +475,13 @@ namespace GLib {
public virtual bool supports_uris ();
public virtual bool supports_xdg_startup_notify ();
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public interface AsyncResult {
public virtual weak GLib.Object get_source_object ();
public static GLib.Type get_type ();
public virtual pointer get_user_data ();
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public interface Drive {
public virtual bool can_eject ();
public virtual bool can_mount ();
@@ -548,20 +548,20 @@ namespace GLib {
public virtual void unmount_mountable (GLib.Cancellable cancellable, GLib.AsyncReadyCallback callback, pointer user_data);
public virtual bool unmount_mountable_finish (GLib.AsyncResult result, GLib.Error error);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public interface Icon {
public virtual bool equal (GLib.Icon icon2);
public static GLib.Type get_type ();
public static uint hash (pointer icon);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public interface LoadableIcon {
public static GLib.Type get_type ();
public virtual weak GLib.InputStream load (int size, string type, GLib.Cancellable cancellable, GLib.Error error);
public virtual void load_async (int size, GLib.Cancellable cancellable, GLib.AsyncReadyCallback callback, pointer user_data);
public virtual weak GLib.InputStream load_finish (GLib.AsyncResult res, string type, GLib.Error error);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public interface Seekable {
public virtual bool can_seek ();
public virtual bool can_truncate ();
@@ -570,7 +570,7 @@ namespace GLib {
public virtual int64 tell ();
public virtual bool truncate (int64 offset, GLib.Cancellable cancellable, GLib.Error err);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public interface Vfs {
public static weak GLib.Vfs get ();
public virtual weak GLib.File get_file_for_path (string path);
@@ -578,7 +578,7 @@ namespace GLib {
public static GLib.Type get_type ();
public virtual weak GLib.File parse_name (string parse_name);
}
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public interface Volume {
public virtual bool can_eject ();
public virtual bool can_unmount ();
@@ -595,14 +595,14 @@ namespace GLib {
public signal void changed ();
}
[ReferenceType]
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public struct AsyncResultData {
public pointer async_object;
public weak GLib.Error error;
public pointer user_data;
}
[ReferenceType]
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public struct FileAttributeMatcher {
public bool enumerate_namespace (string @namespace);
public weak string enumerate_next ();
@@ -612,19 +612,19 @@ namespace GLib {
public FileAttributeMatcher (string attributes);
}
[ReferenceType]
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public struct IOJob {
public void send_to_mainloop (GLib.IODataFunc func, pointer user_data, GLib.DestroyNotify notify, bool block);
}
[ReferenceType]
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public struct LocalParentFileInfo {
public bool writable;
public bool is_sticky;
public int owner;
}
[ReferenceType]
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public struct UnixMount {
public weak string mount_path;
public weak string device_path;
@@ -632,7 +632,7 @@ namespace GLib {
public bool is_read_only;
}
[ReferenceType]
- [CCode (cheader_filename = "gio/gvfs.h, glib.h")]
+ [CCode (cheader_filename = "gio/gvfs.h,glib.h")]
public struct UnixMountPoint {
public weak string mount_path;
public weak string device_path;
diff --git a/vapi/gstreamer-0.10.vala b/vapi/gstreamer-0.10.vala
index ec18bcd05..c61c2b430 100644
--- a/vapi/gstreamer-0.10.vala
+++ b/vapi/gstreamer-0.10.vala
@@ -1725,7 +1725,7 @@ namespace Gst {
public static delegate Gst.IteratorResult IteratorNextFunction (Gst.Iterator it, pointer result);
public static delegate void IteratorResyncFunction (Gst.Iterator it);
public static delegate void LogFunction (Gst.DebugCategory category, Gst.DebugLevel level, string file, string function, int line, GLib.Object object, Gst.DebugMessage message, pointer data);
- public static delegate Gst.MiniObject MiniObjectCopyFunction (Gst.MiniObject obj);
+ public static delegate weak Gst.MiniObject MiniObjectCopyFunction (Gst.MiniObject obj);
public static delegate void MiniObjectFinalizeFunction (Gst.MiniObject obj);
public static delegate bool PadAcceptCapsFunction (Gst.Pad pad, Gst.Caps caps);
public static delegate bool PadActivateFunction (Gst.Pad pad);
@@ -1737,9 +1737,9 @@ namespace Gst {
public static delegate bool PadDispatcherFunction (Gst.Pad pad, pointer data);
public static delegate bool PadEventFunction (Gst.Pad pad, Gst.Event event);
public static delegate void PadFixateCapsFunction (Gst.Pad pad, Gst.Caps caps);
- public static delegate Gst.Caps PadGetCapsFunction (Gst.Pad pad);
+ public static delegate weak Gst.Caps PadGetCapsFunction (Gst.Pad pad);
public static delegate Gst.FlowReturn PadGetRangeFunction (Gst.Pad pad, uint64 offset, uint length, Gst.Buffer buffer);
- public static delegate GLib.List PadIntLinkFunction (Gst.Pad pad);
+ public static delegate weak GLib.List PadIntLinkFunction (Gst.Pad pad);
public static delegate Gst.PadLinkReturn PadLinkFunction (Gst.Pad pad, Gst.Pad peer);
public static delegate bool PadQueryFunction (Gst.Pad pad, Gst.Query query);
public static delegate bool PadSetCapsFunction (Gst.Pad pad, Gst.Caps caps);
@@ -1756,7 +1756,7 @@ namespace Gst {
public static delegate int ValueCompareFunc (GLib.Value value1, GLib.Value value2);
public static delegate bool ValueDeserializeFunc (GLib.Value dest, string s);
public static delegate bool ValueIntersectFunc (GLib.Value dest, GLib.Value value1, GLib.Value value2);
- public static delegate string ValueSerializeFunc (GLib.Value value1);
+ public static delegate weak string ValueSerializeFunc (GLib.Value value1);
public static delegate bool ValueSubtractFunc (GLib.Value dest, GLib.Value minuend, GLib.Value subtrahend);
public static delegate bool ValueUnionFunc (GLib.Value dest, GLib.Value value1, GLib.Value value2);
public static void init (ref string[] args);
diff --git a/vapi/gtk+-2.0.vala b/vapi/gtk+-2.0.vala
index fdd432a92..347401ff5 100644
--- a/vapi/gtk+-2.0.vala
+++ b/vapi/gtk+-2.0.vala
@@ -2763,7 +2763,7 @@ namespace Gtk {
public signal void page_reordered (Gtk.Widget p0, uint p1);
public signal void page_removed (Gtk.Widget p0, uint p1);
public signal void page_added (Gtk.Widget p0, uint p1);
- public signal Gtk.Notebook create_window (Gtk.Widget page, int x, int y);
+ public signal weak Gtk.Notebook create_window (Gtk.Widget page, int x, int y);
}
[CCode (cheader_filename = "gtk/gtk.h")]
public class Object : GLib.InitiallyUnowned {
@@ -3045,7 +3045,7 @@ namespace Gtk {
public signal void draw_page (Gtk.PrintContext context, int page_nr);
public signal void end_print (Gtk.PrintContext context);
public signal void status_changed ();
- public signal Gtk.Widget create_custom_widget ();
+ public signal weak Gtk.Widget create_custom_widget ();
public signal void custom_widget_apply (Gtk.Widget widget);
public signal bool preview (Gtk.PrintOperationPreview preview, Gtk.PrintContext context, Gtk.Window parent);
}
@@ -3392,7 +3392,7 @@ namespace Gtk {
public weak int digits { get; set; }
public weak bool draw_value { get; set; }
public weak Gtk.PositionType value_pos { get; set; }
- public signal string format_value (double value);
+ public signal weak string format_value (double value);
}
[CCode (cheader_filename = "gtk/gtk.h")]
public class ScaleButton : Gtk.Button {
@@ -6257,7 +6257,7 @@ namespace Gtk {
public static delegate void MnemonicHashForeach (uint keyval, GLib.SList targets, pointer data);
public static delegate void ModuleDisplayInitFunc (Gdk.Display display);
public static delegate void ModuleInitFunc (int argc, string argv);
- public static delegate Gtk.Notebook NotebookWindowCreationFunc (Gtk.Notebook source, Gtk.Widget page, int x, int y, pointer data);
+ public static delegate weak Gtk.Notebook NotebookWindowCreationFunc (Gtk.Notebook source, Gtk.Widget page, int x, int y, pointer data);
public static delegate void PageSetupDoneFunc (Gtk.PageSetup page_setup, pointer data);
public static delegate void PrintFunc (pointer func_data, string str);
public static delegate void PrintJobCompleteFunc (Gtk.PrintJob print_job, pointer user_data, GLib.Error error);
@@ -6272,7 +6272,7 @@ namespace Gtk {
public static delegate uchar TextBufferSerializeFunc (Gtk.TextBuffer register_buffer, Gtk.TextBuffer content_buffer, out Gtk.TextIter start, out Gtk.TextIter end, ulong length, pointer user_data);
public static delegate bool TextCharPredicate (unichar ch, pointer user_data);
public static delegate void TextTagTableForeach (Gtk.TextTag tag, pointer data);
- public static delegate string TranslateFunc (string path, pointer func_data);
+ public static delegate weak string TranslateFunc (string path, pointer func_data);
public static delegate void TreeCellDataFunc (Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, out Gtk.TreeIter iter, pointer data);
public static delegate void TreeDestroyCountFunc (Gtk.TreeView tree_view, Gtk.TreePath path, int children, pointer user_data);
public static delegate int TreeIterCompareFunc (Gtk.TreeModel model, out Gtk.TreeIter a, out Gtk.TreeIter b, pointer user_data);
diff --git a/vapigen/Makefile.am b/vapigen/Makefile.am
index 04f241b49..0cb0e817e 100644
--- a/vapigen/Makefile.am
+++ b/vapigen/Makefile.am
@@ -26,7 +26,7 @@ vapigen_SOURCES = \
$(NULL)
vapigen.vala.stamp: $(filter %.vala,$(vapigen_SOURCES))
- $(VALAC) --vapidir $(srcdir)/../vapi --vapidir ../ccode --pkg ccode --vapidir ../vala --pkg vala --vapidir ../gobject-introspection --pkg gidl $^
+ $(VALAC) --vapidir $(srcdir)/../vapi --vapidir ../gee --pkg gee --vapidir ../ccode --pkg ccode --vapidir ../vala --pkg vala --vapidir ../gobject-introspection --pkg gidl $^
touch $@
vapigen_LDADD = \
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index 2dfbbec5a..1954a3f5c 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -22,6 +22,7 @@
*/
using GLib;
+using Gee;
/**
* Code visitor parsing all GIDL files.
@@ -34,8 +35,8 @@ public class Vala.GIdlParser : CodeVisitor {
private SourceReference current_source_reference;
private DataType current_data_type;
- private HashTable<string,string> codenode_attributes_map;
- private HashTable<string,string> current_type_symbol_map;
+ private Map<string,string> codenode_attributes_map;
+ private Gee.Set<string> current_type_symbol_set;
/**
* Parse all source files in the specified code context and build a
@@ -59,7 +60,7 @@ public class Vala.GIdlParser : CodeVisitor {
current_source_file = source_file;
- codenode_attributes_map = new HashTable.full (str_hash, str_equal, g_free, g_free);
+ codenode_attributes_map = new HashMap<string,string> (str_hash, str_equal);
if (FileUtils.test (metadata_filename, FileTest.EXISTS)) {
try {
@@ -73,7 +74,7 @@ public class Vala.GIdlParser : CodeVisitor {
continue;
}
- codenode_attributes_map.insert (line_parts[0], line_parts[1]);
+ codenode_attributes_map.set (line_parts[0], line_parts[1]);
}
} catch (FileError e) {
Report.error (null, "Unable to read metadata file: %s".printf (e.message));
@@ -367,18 +368,18 @@ public class Vala.GIdlParser : CodeVisitor {
current_data_type = cl;
- current_type_symbol_map = new HashTable<string,string>.full (str_hash, str_equal, g_free, g_free);
- var current_type_vfunc_map = new HashTable<string,string>.full (str_hash, str_equal, g_free, g_free);
+ current_type_symbol_set = new HashSet<string> (str_hash, str_equal);
+ var current_type_vfunc_map = new HashMap<string,string> (str_hash, str_equal);
foreach (weak IdlNode member in node.members) {
if (member.type == IdlNodeTypeId.VFUNC) {
- current_type_vfunc_map.insert (member.name, "1");
+ current_type_vfunc_map.set (member.name, "1");
}
}
foreach (weak IdlNode member in node.members) {
if (member.type == IdlNodeTypeId.FUNCTION) {
- bool is_virtual = current_type_vfunc_map.lookup (member.name) != null;
+ bool is_virtual = current_type_vfunc_map.get (member.name) != null;
var m = parse_function ((IdlNodeFunction) member, is_virtual);
if (m != null) {
@@ -399,7 +400,7 @@ public class Vala.GIdlParser : CodeVisitor {
foreach (weak IdlNode member in node.members) {
if (member.type == IdlNodeTypeId.FIELD) {
- if (current_type_symbol_map.lookup (member.name) == null) {
+ if (!current_type_symbol_set.contains (member.name)) {
var f = parse_field ((IdlNodeField) member);
if (f != null) {
cl.add_field (f);
@@ -411,19 +412,19 @@ public class Vala.GIdlParser : CodeVisitor {
foreach (Property prop in cl.get_properties ()) {
var getter = "get_%s".printf (prop.name);
- if (prop.get_accessor != null && current_type_symbol_map.lookup (getter) == null) {
+ if (prop.get_accessor != null && !current_type_symbol_set.contains (getter)) {
prop.no_accessor_method = true;
}
var setter = "set_%s".printf (prop.name);
- if (prop.set_accessor != null && current_type_symbol_map.lookup (setter) == null) {
+ if (prop.set_accessor != null && !current_type_symbol_set.contains (setter)) {
prop.no_accessor_method = true;
}
}
current_data_type = null;
- current_type_symbol_map = null;
+ current_type_symbol_set = null;
return cl;
}
@@ -450,16 +451,16 @@ public class Vala.GIdlParser : CodeVisitor {
current_data_type = iface;
- var current_type_vfunc_map = new HashTable<string,string>.full (str_hash, str_equal, g_free, g_free);
+ var current_type_vfunc_map = new HashMap<string,string> (str_hash, str_equal);
foreach (weak IdlNode member in node.members) {
if (member.type == IdlNodeTypeId.VFUNC) {
- current_type_vfunc_map.insert (member.name, "1");
+ current_type_vfunc_map.set (member.name, "1");
}
}
foreach (weak IdlNode member in node.members) {
if (member.type == IdlNodeTypeId.FUNCTION) {
- bool is_virtual = current_type_vfunc_map.lookup (member.name) != null;
+ bool is_virtual = current_type_vfunc_map.get (member.name) != null;
var m = parse_function ((IdlNodeFunction) member, is_virtual, true);
if (m != null) {
@@ -734,8 +735,8 @@ public class Vala.GIdlParser : CodeVisitor {
// GIDL generator can't provide array parameter information yet
m.no_array_length = true;
- if (current_type_symbol_map != null) {
- current_type_symbol_map.insert (node.name, "1");
+ if (current_type_symbol_set != null) {
+ current_type_symbol_set.add (node.name);
}
if (current_data_type != null) {
@@ -872,8 +873,8 @@ public class Vala.GIdlParser : CodeVisitor {
prop.access = MemberAccessibility.PUBLIC;
prop.interface_only = true;
- if (current_type_symbol_map != null) {
- current_type_symbol_map.insert (prop.name, "1");
+ if (current_type_symbol_set != null) {
+ current_type_symbol_set.add (prop.name);
}
return prop;
@@ -916,8 +917,8 @@ public class Vala.GIdlParser : CodeVisitor {
}
}
- if (current_type_symbol_map != null) {
- current_type_symbol_map.insert (node.name, "1");
+ if (current_type_symbol_set != null) {
+ current_type_symbol_set.add (node.name);
}
var field = new Field (node.name, type, null, current_source_reference);
@@ -928,7 +929,7 @@ public class Vala.GIdlParser : CodeVisitor {
[NoArrayLength]
private string[] get_attributes (string! codenode) {
- string attributes = codenode_attributes_map.lookup (codenode);
+ string attributes = codenode_attributes_map.get (codenode);
if (attributes == null) {
return null;
}