glib-2.0: Add g_unichar_ismark binding
[vala-lang.git] / vala / valaobjecttypesymbol.vala
blob14fc230dacf30899ae6f101a9d2442b92fb3024f
1 /* valaobjecttypesymbol.vala
3 * Copyright (C) 2008-2009 Jürg Billeter
4 * Copyright (C) 2008 Philip Van Hoof
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Author:
21 * Jürg Billeter <j@bitron.ch>
22 * Philip Van Hoof <pvanhoof@gnome.org>
26 /**
27 * Represents a runtime data type for objects and interfaces. This data type may
28 * be defined in Vala source code or imported from an external library with a
29 * Vala API file.
31 public abstract class Vala.ObjectTypeSymbol : TypeSymbol {
32 private List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
34 public ObjectTypeSymbol (string name, SourceReference? source_reference = null, Comment? comment = null) {
35 base (name, source_reference, comment);
38 public abstract List<Method> get_methods ();
39 public abstract List<Signal> get_signals ();
40 public abstract List<Property> get_properties ();
42 /**
43 * Appends the specified parameter to the list of type parameters.
45 * @param p a type parameter
47 public void add_type_parameter (TypeParameter p) {
48 type_parameters.add (p);
49 scope.add (p.name, p);
52 /**
53 * Returns a copy of the type parameter list.
55 * @return list of type parameters
57 public List<TypeParameter> get_type_parameters () {
58 return type_parameters;
61 public override int get_type_parameter_index (string name) {
62 int i = 0;
63 foreach (TypeParameter parameter in type_parameters) {
64 if (parameter.name == name) {
65 return i;
67 i++;
69 return -1;
72 public ObjectType get_this_type () {
73 var result = new ObjectType (this);
74 foreach (var type_parameter in get_type_parameters ()) {
75 var type_arg = new GenericType (type_parameter);
76 type_arg.value_owned = true;
77 result.add_type_argument (type_arg);
79 return result;
82 /**
83 * Adds the specified method as a hidden member to this class,
84 * primarily used for default signal handlers.
86 * The hidden methods are not part of the `methods` collection.
88 * There may also be other use cases, eg, convert array.resize() to
89 * this type of method?
91 * @param m a method
93 public void add_hidden_method (Method m) {
94 if (m.binding == MemberBinding.INSTANCE) {
95 if (m.this_parameter != null) {
96 m.scope.remove (m.this_parameter.name);
98 m.this_parameter = new Parameter ("this", get_this_type ());
99 m.scope.add (m.this_parameter.name, m.this_parameter);
101 if (!(m.return_type is VoidType) && m.get_postconditions ().size > 0) {
102 if (m.result_var != null) {
103 m.scope.remove (m.result_var.name);
105 m.result_var = new LocalVariable (m.return_type.copy (), "result");
106 m.result_var.is_result = true;
109 scope.add (null, m);