/
GSList.pm6
90 lines (69 loc) · 2.48 KB
/
GSList.pm6
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
use v6;
use NativeCall;
use GTK::V3::X;
use GTK::V3::N::NativeLib;
use GTK::V3::Glib::GObject;
#-------------------------------------------------------------------------------
# See /usr/include/glib-2.0/glib/gslist.h
# https://developer.gnome.org/glib/stable/glib-Singly-Linked-List.html
unit class GTK::V3::Glib::GSList:auth<github:MARTIMM>;
#-------------------------------------------------------------------------------
class N-GSList is repr('CPointer') is export { }
#-------------------------------------------------------------------------------
sub g_slist_length ( N-GSList $list --> uint32 )
is native(>k-lib)
{ * }
sub g_slist_last ( N-GSList $list --> N-GSList )
is native(>k-lib)
{ * }
sub g_slist_nth ( N-GSList $list, uint32 $n --> N-GSList )
is native(>k-lib)
{ * }
#sub g_slist_nth_data ( N-GSList $list, uint32 $n --> Any )
# is native(>k-lib)
# { * }
sub g_slist_nth_data_str ( N-GSList $list, uint32 $n --> Str )
is native(>k-lib)
is symbol('g_slist_nth_data')
{ * }
sub g_slist_nth_data_gobject ( N-GSList $list, uint32 $n --> N-GObject )
is native(>k-lib)
is symbol('g_slist_nth_data')
{ * }
#TODO free $!gslist too?
sub g_slist_free ( N-GSList $list )
is native(>k-lib)
{ * }
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
has N-GSList $!gslist;
#-------------------------------------------------------------------------------
submethod BUILD ( N-GSList:D :$!gslist ) { }
#-------------------------------------------------------------------------------
method CALL-ME ( N-GSList $gslist? --> N-GSList ) {
$!gslist = $gslist if ?$gslist;
$!gslist
}
#-------------------------------------------------------------------------------
method FALLBACK ( $native-sub is copy, |c ) {
CATCH { test-catch-exception( $_, $native-sub); }
$native-sub ~~ s:g/ '-' /_/ if $native-sub.index('-');
die X::GTK::V3.new(:message(
"Native sub name '$native-sub' made too short. Keep at least one '-' or '_'."
)
) unless $native-sub.index('_');
my Callable $s;
try { $s = &::($native-sub); }
try { $s = &::("g_slist_$native-sub") unless ?$s; }
#test-call( $s, $!gslist, |c)
$s( $!gslist, |c)
}
#`{{
#-------------------------------------------------------------------------------
method g_list_previous( N-GSList $list --> N-GSList ) {
$!g-list.prev
}
#-------------------------------------------------------------------------------
method g_list_next( N-GSList $list --> N-GSList ) {
$!g-list.next
}
}}