3 * Copyright (C) 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
20 * Jürg Billeter <j@bitron.ch>
21 * Raffaele Sandrini <raffaele@sandrini.ch>
29 public class Vala
.ErrorType
: ReferenceType
{
31 * The error domain or null for generic error.
33 public weak ErrorDomain? error_domain
{ get; set; }
36 * The error code or null for generic error.
38 public weak ErrorCode? error_code
{ get; set; }
40 public ErrorType (ErrorDomain? error_domain
, ErrorCode? error_code
, SourceReference? source_reference
= null) {
41 this
.error_domain
= error_domain
;
42 this
.data_type
= error_domain
;
43 this
.error_code
= error_code
;
44 this
.source_reference
= source_reference
;
47 public override bool compatible (DataType target_type
) {
48 /* temporarily ignore type parameters */
49 if (target_type
.type_parameter
!= null) {
53 var et
= target_type as ErrorType
;
55 /* error types are only compatible to error types */
60 /* every error type is compatible to the base error type */
61 if (et
.error_domain
== null) {
65 /* otherwhise the error_domain has to be equal */
66 if (et
.error_domain
!= error_domain
) {
70 if (et
.error_code
== null) {
74 return et
.error_code
== error_code
;
77 public override string to_qualified_string (Scope? scope
) {
78 if (error_domain
== null) {
81 return error_domain
.get_full_name ();
85 public override DataType
copy () {
86 var result
= new
ErrorType (error_domain
, error_code
, source_reference
);
87 result
.value_owned
= value_owned
;
88 result
.nullable
= nullable
;
93 public override string?
get_cname () {
97 public override string?
get_lower_case_cname (string? infix
= null) {
98 if (error_domain
== null) {
102 return "g_%s_error".printf (infix
);
105 return error_domain
.get_lower_case_cname (infix
);
109 public override bool equals (DataType type2
) {
110 var et
= type2 as ErrorType
;
116 return error_domain
== et
.error_domain
;
119 public override Symbol?
get_member (string member_name
) {
120 var root_symbol
= source_reference
.file
.context
.root
;
121 var gerror_symbol
= root_symbol
.scope
.lookup ("GLib").scope
.lookup ("Error");
122 return gerror_symbol
.scope
.lookup (member_name
);
125 public override string?
get_type_id () {
126 return "G_TYPE_POINTER";
129 public override bool is_reference_type_or_type_parameter () {
133 public override bool check (SemanticAnalyzer analyzer
) {
134 if (error_domain
!= null) {
135 return error_domain
.check (analyzer
);