girparser: Provide default constructor for classes.
[vala-lang.git] / vala / valatypesymbol.vala
blob956939b8ef77eb5234099d58dbff05801b2086a4
1 /* valatypesymbol.vala
3 * Copyright (C) 2006-2010 Jürg Billeter
4 * Copyright (C) 2006-2008 Raffaele Sandrini
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 * Raffaele Sandrini <raffaele@sandrini.ch>
25 using GLib;
27 /**
28 * Represents a runtime data type. This data type may be defined in Vala source
29 * code or imported from an external library with a Vala API file.
31 public abstract class Vala.TypeSymbol : Symbol {
32 public TypeSymbol (string? name, SourceReference? source_reference = null, Comment? comment = null) {
33 base (name, source_reference, comment);
36 /**
37 * Returns the name of this data type as it is used in C code.
39 * @return the name to be used in C code
41 public abstract string get_cname (bool const_type = false);
43 /**
44 * Checks whether this data type has value or reference type semantics.
46 * @return true if this data type has reference type semantics
48 public virtual bool is_reference_type () {
49 return false;
52 /**
53 * Returns the C function name that duplicates instances of this data
54 * type. The specified C function must accept one argument referencing
55 * the instance of this data type and return a reference to the
56 * duplicate.
58 * @return the name of the C function if supported or null otherwise
60 public virtual string? get_dup_function () {
61 return null;
64 /**
65 * Returns the C function name that frees instances of this data type.
66 * The specified C function must accept one argument pointing to the
67 * instance to be freed.
69 * @return the name of the C function if supported or null otherwise
71 public virtual string? get_free_function () {
72 return null;
75 /**
76 * Returns the C function name that copies contents of instances of
77 * this data type. This is only applicable to structs. The specified
78 * C function must accept two arguments, the first is the source value
79 * and the second is the destination value.
81 * @return the name of the C function if supported or null otherwise
83 public virtual string? get_copy_function () {
84 return null;
87 /**
88 * Returns the C function name that destroys the contents of instances
89 * of this data type. This is only applicable to structs. The specified
90 * C function must accept one argument pointing to the instance to be
91 * destroyed.
93 * @return the name of the C function if supported or null otherwise
95 public virtual string? get_destroy_function () {
96 return null;
99 /**
100 * Checks whether this data type supports reference counting. This is
101 * only valid for reference types.
103 * @return true if this data type supports reference counting
105 public virtual bool is_reference_counting () {
106 return false;
110 * Returns the C function name that increments the reference count of
111 * instances of this data type. This is only valid for data types
112 * supporting reference counting. The specified C function must accept
113 * one argument referencing the instance of this data type and return
114 * the reference.
116 * @return the name of the C function or null if this data type does not
117 * support reference counting
119 public virtual string? get_ref_function () {
120 return null;
124 * Returns the C function name that decrements the reference count of
125 * instances of this data type. This is only valid for data types
126 * supporting reference counting. The specified C function must accept
127 * one argument referencing the instance of this data type.
129 * @return the name of the C function or null if this data type does not
130 * support reference counting
132 public virtual string? get_unref_function () {
133 return null;
137 * Returns the C function name that sinks the reference count of
138 * "floating" instances of this data type. This is only valid for data
139 * types supporting floating references. The specified C function must
140 * accept one argument referencing the instance of this data type and
141 * return a non-floating reference.
143 * The ref_sink function is called for any constructor of the class and
144 * for other methods that have the class as a return value and are
145 * marked with the 'floating' attribute.
147 * @return the name of the C function or null if this data type does not
148 * support floating reference counts
150 public virtual string? get_ref_sink_function () {
151 return null;
155 * Returns the C symbol representing the runtime type id for this data
156 * type. The specified symbol must express a registered GType.
158 * @return the name of the GType name in C code or null if this data
159 * type is not registered with GType
161 public virtual string? get_type_id () {
162 return null;
166 * Returns the name of this data type as used in C code marshallers
168 * @return type name for marshallers
170 public virtual string? get_marshaller_type_name () {
171 return null;
175 * Returns the cname of the GValue parameter spec function.
177 public virtual string? get_param_spec_function () {
178 return null;
182 * Returns the cname of the GValue getter function.
184 public virtual string? get_get_value_function () {
185 return null;
189 * Returns the cname of the GValue setter function.
191 public virtual string? get_set_value_function () {
192 return null;
196 * Returns the cname of the GValue taker function.
198 public virtual string? get_take_value_function () {
199 return null;
203 * Returns the C name of this data type in upper case. Words are
204 * separated by underscores. The upper case C name of the namespace is
205 * prefix of the result.
207 * @param infix a string to be placed between namespace and data type
208 * name or null
209 * @return the upper case name to be used in C code
211 public virtual string? get_upper_case_cname (string? infix = null) {
212 return null;
216 * Returns the default value for the given type. Returning null means
217 * there is no default value (i.e. not that the default name is NULL).
219 * @return the name of the default value
221 public virtual string? get_default_value () {
222 return null;
226 * Checks whether this data type is equal to or a subtype of the
227 * specified data type.
229 * @param t a data type
230 * @return true if t is a supertype of this data type, false otherwise
232 public virtual bool is_subtype_of (TypeSymbol t) {
233 return (this == t);
237 * Return the index of the specified type parameter name.
239 public virtual int get_type_parameter_index (string name) {
240 return -1;