Commit 98602e20 authored by Jürg Billeter's avatar Jürg Billeter

Drop ReadOnly* collection classes

They are not very useful in the compiler as they are not immutable,
which means that they do not allow iteration while modifying the
underlying collection.
parent 898564ab
......@@ -42,7 +42,7 @@ public class Vala.CCodeCommaExpression : CCodeExpression {
}
public List<CCodeExpression> get_inner () {
return new ReadOnlyList<CCodeExpression> (inner);
return inner;
}
public override void write (CCodeWriter writer) {
......
......@@ -43,7 +43,7 @@ public class Vala.CCodeFragment : CCodeNode {
* @return children list
*/
public List<CCodeNode> get_children () {
return new ReadOnlyList<CCodeNode> (children);
return children;
}
public override void write (CCodeWriter writer) {
......
......@@ -56,7 +56,7 @@ public class Vala.CCodeFunctionCall : CCodeExpression {
* @return list of arguments
*/
public List<CCodeExpression> get_arguments () {
return new ReadOnlyList<CCodeExpression> (arguments);
return arguments;
}
public override void write (CCodeWriter writer) {
......
......@@ -21,10 +21,6 @@ libgee_la_VALASOURCES = \
iterator.vala \
list.vala \
map.vala \
readonlycollection.vala \
readonlylist.vala \
readonlymap.vala \
readonlyset.vala \
set.vala \
$(NULL)
......
/* readonlycollection.vala
*
* Copyright (C) 2007-2008 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.1 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 Vala.ReadOnlyCollection<G> : CollectionObject, Iterable<G>, Collection<G> {
public int size {
get { return _collection.size; }
}
public Collection<G> collection {
set { _collection = value; }
}
private Collection<G> _collection;
public ReadOnlyCollection (Collection<G>? collection = null) {
this.collection = collection;
}
public Type get_element_type () {
return typeof (G);
}
public Vala.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 ();
}
public bool remove (G item) {
assert_not_reached ();
}
public void clear () {
assert_not_reached ();
}
private class Iterator<G> : CollectionObject, Vala.Iterator<G> {
public bool next () {
return false;
}
public G? get () {
return null;
}
}
}
/* readonlylist.vala
*
* Copyright (C) 2007-2008 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.1 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 Vala.ReadOnlyList<G> : CollectionObject, 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 (List<G>? list = null) {
this.list = list;
}
public Type get_element_type () {
return typeof (G);
}
public Vala.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 ();
}
public bool remove (G item) {
assert_not_reached ();
}
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> : CollectionObject, Vala.Iterator<G> {
public bool next () {
return false;
}
public G? get () {
return null;
}
}
}
/* readonlymap.vala
*
* Copyright (C) 2007-2008 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.1 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 Vala.ReadOnlyMap<K,V> : CollectionObject, 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 (Map<K,V>? map = null) {
this.map = map;
}
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 ();
}
public void clear () {
assert_not_reached ();
}
}
/* readonlyset.vala
*
* Copyright (C) 2007-2008 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.1 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 Vala.ReadOnlySet<G> : CollectionObject, 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 (Set<G>? set = null) {
this.set = set;
}
public Type get_element_type () {
return typeof (G);
}
public Vala.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 ();
}
public bool remove (G item) {
assert_not_reached ();
}
public void clear () {
assert_not_reached ();
}
private class Iterator<G> : CollectionObject, Vala.Iterator<G> {
public bool next () {
return false;
}
public G? get () {
return null;
}
}
}
......@@ -79,7 +79,7 @@ public class Vala.ArrayCreationExpression : Expression {
* Get the sizes for all dimensions ascending from left to right.
*/
public List<Expression> get_sizes () {
return new ReadOnlyList<Expression> (sizes);
return sizes;
}
public ArrayCreationExpression (DataType element_type, int rank, InitializerList? initializer_list, SourceReference source_reference) {
......
......@@ -70,11 +70,11 @@ public class Vala.BasicBlock {
}
public List<weak BasicBlock> get_predecessors () {
return new ReadOnlyList<weak BasicBlock> (predecessors);
return predecessors;
}
public List<weak BasicBlock> get_successors () {
return new ReadOnlyList<weak BasicBlock> (successors);
return successors;
}
public void add_child (BasicBlock block) {
......
......@@ -108,7 +108,7 @@ public class Vala.Block : Symbol, Statement {
* @return variable declarator list
*/
public List<LocalVariable> get_local_variables () {
return new ReadOnlyList<LocalVariable> (local_variables);
return local_variables;
}
public override void accept (CodeVisitor visitor) {
......
......@@ -146,7 +146,7 @@ public class Vala.Class : ObjectTypeSymbol {
* @return list of classes
*/
public List<Class> get_classes () {
return new ReadOnlyList<Class> (classes);
return classes;
}
/**
......@@ -155,7 +155,7 @@ public class Vala.Class : ObjectTypeSymbol {
* @return list of structs
*/
public List<Struct> get_structs () {
return new ReadOnlyList<Struct> (structs);
return structs;
}
/**
......@@ -164,7 +164,7 @@ public class Vala.Class : ObjectTypeSymbol {
* @return list of enums
*/
public List<Enum> get_enums () {
return new ReadOnlyList<Enum> (enums);
return enums;
}
/**
......@@ -173,7 +173,7 @@ public class Vala.Class : ObjectTypeSymbol {
* @return list of delegates
*/
public List<Delegate> get_delegates () {
return new ReadOnlyList<Delegate> (delegates);
return delegates;
}
/**
......@@ -263,7 +263,7 @@ public class Vala.Class : ObjectTypeSymbol {
* @return list of base types
*/
public List<DataType> get_base_types () {
return new ReadOnlyList<DataType> (base_types);
return base_types;
}
/**
......@@ -297,7 +297,7 @@ public class Vala.Class : ObjectTypeSymbol {
* @return list of fields
*/
public List<Field> get_fields () {
return new ReadOnlyList<Field> (fields);
return fields;
}
/**
......@@ -306,7 +306,7 @@ public class Vala.Class : ObjectTypeSymbol {
* @return list of constants
*/
public List<Constant> get_constants () {
return new ReadOnlyList<Constant> (constants);
return constants;
}
/**
......@@ -354,7 +354,7 @@ public class Vala.Class : ObjectTypeSymbol {
* @return list of methods
*/
public override List<Method> get_methods () {
return new ReadOnlyList<Method> (methods);
return methods;
}
/**
......@@ -380,7 +380,7 @@ public class Vala.Class : ObjectTypeSymbol {
* @return list of properties
*/
public override List<Property> get_properties () {
return new ReadOnlyList<Property> (properties);
return properties;
}
/**
......@@ -399,7 +399,7 @@ public class Vala.Class : ObjectTypeSymbol {
* @return list of signals
*/
public override List<Signal> get_signals () {
return new ReadOnlyList<Signal> (signals);
return signals;
}
/**
......
......@@ -229,7 +229,7 @@ public class Vala.CodeContext {
* @return list of source files
*/
public List<SourceFile> get_source_files () {
return new ReadOnlyList<SourceFile> (source_files);
return source_files;
}
/**
......@@ -238,7 +238,7 @@ public class Vala.CodeContext {
* @return list of C source files
*/
public List<string> get_c_source_files () {
return new ReadOnlyList<string> (c_source_files);
return c_source_files;
}
/**
......@@ -265,7 +265,7 @@ public class Vala.CodeContext {
* @return list of used packages
*/
public List<string> get_packages () {
return new ReadOnlyList<string> (packages);
return packages;
}
/**
......
......@@ -96,7 +96,7 @@ public abstract class Vala.CodeNode {
return _error_types;
}
if (_empty_type_list == null) {
_empty_type_list = new ReadOnlyList<DataType> (new ArrayList<DataType> ());
_empty_type_list = new ArrayList<DataType> ();
}
return _empty_type_list;
}
......
......@@ -85,7 +85,7 @@ public abstract class Vala.DataType : CodeNode {
return type_argument_list;
}
if (_empty_type_list == null) {
_empty_type_list = new ReadOnlyList<DataType> (new ArrayList<DataType> ());
_empty_type_list = new ArrayList<DataType> ();
}
return _empty_type_list;
}
......
......@@ -130,7 +130,7 @@ public class Vala.Delegate : TypeSymbol {
* @return parameter list
*/
public List<FormalParameter> get_parameters () {
return new ReadOnlyList<FormalParameter> (parameters);
return parameters;
}
/**
......
......@@ -54,7 +54,7 @@ public class Vala.ElementAccess : Expression {
}
public List<Expression> get_indices () {
return new ReadOnlyList<Expression> (indices);
return indices;
}
public ElementAccess (Expression container, SourceReference source_reference) {
......
......@@ -96,7 +96,7 @@ public class Vala.Enum : TypeSymbol {
* @return list of enum values
*/
public List<EnumValue> get_values () {
return new ReadOnlyList<EnumValue> (values);
return values;
}
/**
......@@ -105,7 +105,7 @@ public class Vala.Enum : TypeSymbol {
* @return list of methods
*/
public List<Method> get_methods () {
return new ReadOnlyList<Method> (methods);
return methods;
}
public override void accept (CodeVisitor visitor) {
......
......@@ -81,7 +81,7 @@ public class Vala.ErrorDomain : TypeSymbol {
* @return list of error codes
*/
public List<ErrorCode> get_codes () {
return new ReadOnlyList<ErrorCode> (codes);
return codes;
}
/**
......@@ -90,7 +90,7 @@ public class Vala.ErrorDomain : TypeSymbol {
* @return list of methods
*/
public List<Method> get_methods () {
return new ReadOnlyList<Method> (methods);
return methods;
}
public override void accept (CodeVisitor visitor) {
......
......@@ -101,7 +101,7 @@ public abstract class Vala.Expression : CodeNode {
* ascending from left to right.
*/
public List<CCodeExpression> get_array_sizes () {
return new ReadOnlyList<CCodeExpression> (array_sizes);
return array_sizes;
}
public Statement? parent_statement {
......
......@@ -90,7 +90,7 @@ public class Vala.ForStatement : CodeNode, Statement {
* @return initializer list
*/
public List<Expression> get_initializer () {
return new ReadOnlyList<Expression> (initializer);
return initializer;
}
/**
......@@ -109,7 +109,7 @@ public class Vala.ForStatement : CodeNode, Statement {
* @return iterator
*/
public List<Expression> get_iterator () {
return new ReadOnlyList<Expression> (iterator);
return iterator;
}
public override void accept (CodeVisitor visitor) {
......
......@@ -46,7 +46,7 @@ public class Vala.InitializerList : Expression {
* @return expression list
*/
public List<Expression> get_initializers () {
return new ReadOnlyList<Expression> (initializers);
return initializers;
}
/**
......
......@@ -51,7 +51,7 @@ public class Vala.Interface : ObjectTypeSymbol {
* @return list of classes
*/
public List<Class> get_classes () {
return new ReadOnlyList<Class> (classes);
return classes;
}
/**
......@@ -60,7 +60,7 @@ public class Vala.Interface : ObjectTypeSymbol {
* @return list of structs
*/
public List<Struct> get_structs () {
return new ReadOnlyList<Struct> (structs);
return structs;
}
/**
......@@ -69,7 +69,7 @@ public class Vala.Interface : ObjectTypeSymbol {
* @return list of enums
*/
public List<Enum> get_enums () {
return new ReadOnlyList<Enum> (enums);
return enums;
}
/**
......@@ -78,7 +78,7 @@ public class Vala.Interface : ObjectTypeSymbol {
* @return list of delegates
*/
public List<Delegate> get_delegates () {
return new ReadOnlyList<Delegate> (delegates);
return delegates;
}
/**
......@@ -119,7 +119,7 @@ public class Vala.Interface : ObjectTypeSymbol {
* @return list of base types
*/
public List<DataType> get_prerequisites () {
return new ReadOnlyList<DataType> (prerequisites);
return prerequisites;
}
/**
......@@ -153,7 +153,7 @@ public class Vala.Interface : ObjectTypeSymbol {
* @return list of methods
*/
public override List<Method> get_methods () {
return new ReadOnlyList<Method> (methods);
return methods;
}
/**
......@@ -173,7 +173,7 @@ public class Vala.Interface : ObjectTypeSymbol {
* @return list of fields
*/
public List<Field> get_fields () {
return new ReadOnlyList<Field> (fields);
return fields;
}
/**
......@@ -192,7 +192,7 @@ public class Vala.Interface : ObjectTypeSymbol {
* @return list of constants
*/
public List<Constant> get_constants () {
return new