<commit_before>/* valaerrortype.vala
 *
 * Copyright (C) 2008  <NAME>
 *
 * 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:
 * 	<NAME> <<EMAIL>>
 *	<NAME> <<EMAIL>>
 */

using GLib;

/**
 * A class type.
 */
public class Vala.ErrorType : ReferenceType {
	/**
	 * The error domain or null for generic error.
	 */
	public weak ErrorDomain? error_domain { get; set; }

	/**
	 * The error code or null for generic error.
	 */
	public weak ErrorCode? error_code { get; set; }

	public bool dynamic_error { get; set; }

	public ErrorType (ErrorDomain? error_domain, ErrorCode? error_code, SourceReference? source_reference = null) {
		this.error_domain = error_domain;
		this.data_type = error_domain;
		this.error_code = error_code;
		this.source_reference = source_reference;
	}

	public override bool compatible (DataType target_type) {
		/* temporarily ignore type parameters */
		if (target_type.type_parameter != null) {
			return true;
		}

		var et = target_type as ErrorType;

		/* error types are only compatible to error types */
		if (et == null) {
			return false;
		}

		/* every error type is compatible to the base error type */
		if (et.error_domain == null) {
			return true;
		}

		/* otherwhise the error_domain has to be equal */
		if (et.error_domain != error_domain) {
			return false;
		}

		if (et.error_code == null) {
			return true;
		}

		return et.error_code == error_code;
	}

	public override string to_qualified_string (Scope? scope) {
		if (error_domain == null) {
			return "GLib.Error";
		} else {
			return error_domain.get_full_name ();
		}
	}

	public override DataType copy () {
		var result = new ErrorType (error_domain, error_code, source_reference);<commit_msg>Support nullable error types in VAPI files<commit_after>/* valaerrortype.vala
 *
 * Copyright (C) 2008-2010  <NAME>
 *
 * 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:
 * 	<NAME> <<EMAIL>>
 *	<NAME> <<EMAIL>>
 */

using GLib;

/**
 * A class type.
 */
public class Vala.ErrorType : ReferenceType {
	/**
	 * The error domain or null for generic error.
	 */
	public weak ErrorDomain? error_domain { get; set; }

	/**
	 * The error code or null for generic error.
	 */
	public weak ErrorCode? error_code { get; set; }

	public bool dynamic_error { get; set; }

	public ErrorType (ErrorDomain? error_domain, ErrorCode? error_code, SourceReference? source_reference = null) {
		this.error_domain = error_domain;
		this.data_type = error_domain;
		this.error_code = error_code;
		this.source_reference = source_reference;
	}

	public override bool compatible (DataType target_type) {
		/* temporarily ignore type parameters */
		if (target_type.type_parameter != null) {
			return true;
		}

		var et = target_type as ErrorType;

		/* error types are only compatible to error types */
		if (et == null) {
			return false;
		}

		/* every error type is compatible to the base error type */
		if (et.error_domain == null) {
			return true;
		}

		/* otherwhise the error_domain has to be equal */
		if (et.error_domain != error_domain) {
			return false;
		}

		if (et.error_code == null) {
			return true;
		}

		return et.error_code == error_code;
	}

	public override string to_qualified_string (Scope? scope) {
		string result;

		if (error_domain == null) {
			result = "GLib.Error";
		} else {
			result = error_domain.get_full_name ();
		}

		if (nullable) {
			result += "?";
		}

		return result;
	}

	public override DataType copy () {
		var result = new ErrorType (error_domain, error_code, source_reference);
{'fraction_non_alphanumeric': 0.09264915495825697, 'fraction_numerical': 0.007737731622887396, 'mean_word_length': 3.5022914757103574, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1516583', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1436, 'n_words': 570}