Release 0.7.8
[vala-lang.git] / vala / valasignaltype.vala
blob4a6b585a6e651023cf234a00dcb7fc929f17fc82
1 /* valasignaltype.vala
3 * Copyright (C) 2007-2009 Jürg Billeter
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * Author:
20 * Jürg Billeter <j@bitron.ch>
23 using GLib;
25 /**
26 * The type of a signal referencea.
28 public class Vala.SignalType : DataType {
29 public Signal signal_symbol { get; set; }
31 Method? connect_method;
32 Method? disconnect_method;
34 public SignalType (Signal signal_symbol) {
35 this.signal_symbol = signal_symbol;
38 public override bool is_invokable () {
39 return true;
42 public override DataType? get_return_type () {
43 return signal_symbol.return_type;
46 public override List<FormalParameter>? get_parameters () {
47 return signal_symbol.get_parameters ();
50 public override DataType copy () {
51 return new SignalType (signal_symbol);
54 public override bool compatible (DataType target_type) {
55 return false;
58 public override string to_qualified_string (Scope? scope) {
59 return signal_symbol.get_full_name ();
62 DelegateType get_handler_type () {
63 var sender_type = new ObjectType ((ObjectTypeSymbol) signal_symbol.parent_symbol);
64 var result = new DelegateType (signal_symbol.get_delegate (sender_type, this));
65 result.value_owned = true;
66 return result;
69 Method get_connect_method () {
70 if (connect_method == null) {
71 connect_method = new Method ("connect", new VoidType ());
72 connect_method.access = SymbolAccessibility.PUBLIC;
73 connect_method.external = true;
74 connect_method.owner = signal_symbol.scope;
75 connect_method.add_parameter (new FormalParameter ("handler", get_handler_type ()));
77 return connect_method;
80 Method get_disconnect_method () {
81 if (disconnect_method == null) {
82 disconnect_method = new Method ("disconnect", new VoidType ());
83 disconnect_method.access = SymbolAccessibility.PUBLIC;
84 disconnect_method.external = true;
85 disconnect_method.owner = signal_symbol.scope;
86 disconnect_method.add_parameter (new FormalParameter ("handler", get_handler_type ()));
88 return disconnect_method;
91 public override Symbol? get_member (string member_name) {
92 if (member_name == "connect") {
93 return get_connect_method ();
94 } else if (member_name == "disconnect") {
95 return get_disconnect_method ();
97 return null;
100 public override List<Symbol> get_symbols () {
101 var symbols = new ArrayList<Symbol> ();
102 symbols.add (signal_symbol);
103 return symbols;