Fix gst_netaddress_*_ip6_address bindings, patch by Andrew Feren, fixes
[vala-lang.git] / vala / valaobjecttype.vala
blobac5f28a45b33ca15ae0e791949653896cf6a6b67
1 /* valaobjecttype.vala
3 * Copyright (C) 2007-2008 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 * A class type.
28 public class Vala.ObjectType : ReferenceType {
29 /**
30 * The referred class or interface.
32 public weak ObjectTypeSymbol type_symbol { get; set; }
34 public ObjectType (ObjectTypeSymbol type_symbol) {
35 this.type_symbol = type_symbol;
36 data_type = type_symbol;
39 public override DataType copy () {
40 var result = new ObjectType (type_symbol);
41 result.source_reference = source_reference;
42 result.value_owned = value_owned;
43 result.nullable = nullable;
44 result.is_dynamic = is_dynamic;
45 result.floating_reference = floating_reference;
47 foreach (DataType arg in get_type_arguments ()) {
48 result.add_type_argument (arg.copy ());
51 return result;
54 public override string? get_cname () {
55 return "%s*".printf (type_symbol.get_cname (!value_owned));
58 public override bool stricter (DataType target_type) {
59 var obj_target_type = target_type as ObjectType;
60 if (obj_target_type == null) {
61 return false;
64 if (value_owned != target_type.value_owned) {
65 return false;
68 if (nullable && !target_type.nullable) {
69 return false;
72 return type_symbol.is_subtype_of (obj_target_type.type_symbol);
75 public override bool is_invokable () {
76 var cl = type_symbol as Class;
77 if (cl != null && cl.default_construction_method != null) {
78 return true;
79 } else {
80 return false;
84 public override DataType? get_return_type () {
85 var cl = type_symbol as Class;
86 if (cl != null && cl.default_construction_method != null) {
87 return cl.default_construction_method.return_type;
88 } else {
89 return null;
93 public override Gee.List<FormalParameter>? get_parameters () {
94 var cl = type_symbol as Class;
95 if (cl != null && cl.default_construction_method != null) {
96 return cl.default_construction_method.get_parameters ();
97 } else {
98 return null;
102 public override bool check (SemanticAnalyzer analyzer) {
103 return type_symbol.check (analyzer);