summaryrefslogtreecommitdiff
path: root/vala/valapointer.vala
blob: 12b3afea9253b8f7b9b70e750d6d8a1a5910bdc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* valapointer.vala
 *
 * Copyright (C) 2007  Jürg Billeter
 *
 * 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 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:
 * 	Jürg Billeter <j@bitron.ch>
 */

using GLib;

/**
 * Represents a pointer-type.
 */
public class Vala.Pointer : DataType {
	/**
	 * The type to which this pointer type points.
	 */
	public DataType! referent_type { get; set construct; }
	
	private string cname;
	
	public Pointer (construct DataType! referent_type, construct SourceReference source_reference = null) {
	}

	construct {
		name = referent_type.name + "*";
	}

	public override string get_cname (bool const_type = false) {
		if (cname == null) {
			if (referent_type.is_reference_type ()) {
				cname = "%s**".printf (referent_type.get_cname ());
			} else {
				cname = "%s*".printf (referent_type.get_cname ());
			}
		}

		return cname;
	}

	public override bool is_reference_type () {
		return false;
	}
	
	public override ref string get_upper_case_cname (string infix) {
		return null;
	}

	public override ref string get_lower_case_cname (string infix) {
		return null;
	}

	public override string get_free_function () {
		return null;
	}
	
	public override ref List<string> get_cheader_filenames () {
		return referent_type.get_cheader_filenames ();
	}

	public override string get_type_id () {
		return "G_TYPE_POINTER";
	}

	public override string get_marshaller_type_name () {
		return "POINTER";
	}

	public override string get_get_value_function () {
		return "g_value_get_pointer";
	}
	
	public override string get_set_value_function () {
		return "g_value_set_pointer";
	}
}