summaryrefslogtreecommitdiff
path: root/tests/methods/parameter-ccode-type.vala
blob: c9f7206fab53de9277e6de91dcfe45104735ef49 (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
void foo ([CCode (array_length = false, type = "const gchar**")] string[]? sa) {
	assert (sa[1] == "bar");
}

const string[] BARS = { "foo", "bar", null };

void bar ([CCode (array_length = false, type = "const gchar***")] out unowned string[]? sa) {
	sa = BARS;
}

void manam ([CCode (array_length = false, type = "const GObject**")] Object[]? oa) {
	assert (oa[1] == null);
}

void faz ([CCode (type = "const GObject*")] Object? o) {
	assert (o == null);
}

void baz ([CCode (type = "const GObject**")] out unowned Object? o) {
	o = null ;
}

void minim ([CCode (type = "gpointer*")] out unowned void* p) {
	p = null;
}

void main () {
	{
		foo ({ "foo", "bar", null });
	}
	{
		unowned string[] sa;
		bar (out sa);
	}
	{
		manam ({ null });
	}
	{
		faz (null);
	}
	{
		unowned Object? o;
		baz (out o);
		assert (o == null);
	}
	{
		unowned void* p;
		minim (out p);
		assert (p == null);
	}
}