1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type SocketAddressClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20
21 xGetFamily uintptr
22
23 xGetNativeSize uintptr
24
25 xToNative uintptr
26}
27
28func (x *SocketAddressClass) GoPointer() uintptr {
29 return uintptr(unsafe.Pointer(x))
30}
31
32// OverrideGetFamily sets the "get_family" callback function.
33func (x *SocketAddressClass) OverrideGetFamily(cb func(*SocketAddress) SocketFamily) {
34 if cb == nil {
35 x.xGetFamily = 0
36 } else {
37 x.xGetFamily = purego.NewCallback(func(AddressVarp uintptr) SocketFamily {
38 return cb(SocketAddressNewFromInternalPtr(AddressVarp))
39 })
40 }
41}
42
43// GetGetFamily gets the "get_family" callback function.
44func (x *SocketAddressClass) GetGetFamily() func(*SocketAddress) SocketFamily {
45 if x.xGetFamily == 0 {
46 return nil
47 }
48 var rawCallback func(AddressVarp uintptr) SocketFamily
49 purego.RegisterFunc(&rawCallback, x.xGetFamily)
50 return func(AddressVar *SocketAddress) SocketFamily {
51 return rawCallback(AddressVar.GoPointer())
52 }
53}
54
55// OverrideGetNativeSize sets the "get_native_size" callback function.
56func (x *SocketAddressClass) OverrideGetNativeSize(cb func(*SocketAddress) int) {
57 if cb == nil {
58 x.xGetNativeSize = 0
59 } else {
60 x.xGetNativeSize = purego.NewCallback(func(AddressVarp uintptr) int {
61 return cb(SocketAddressNewFromInternalPtr(AddressVarp))
62 })
63 }
64}
65
66// GetGetNativeSize gets the "get_native_size" callback function.
67func (x *SocketAddressClass) GetGetNativeSize() func(*SocketAddress) int {
68 if x.xGetNativeSize == 0 {
69 return nil
70 }
71 var rawCallback func(AddressVarp uintptr) int
72 purego.RegisterFunc(&rawCallback, x.xGetNativeSize)
73 return func(AddressVar *SocketAddress) int {
74 return rawCallback(AddressVar.GoPointer())
75 }
76}
77
78// OverrideToNative sets the "to_native" callback function.
79func (x *SocketAddressClass) OverrideToNative(cb func(*SocketAddress, uintptr, uint) bool) {
80 if cb == nil {
81 x.xToNative = 0
82 } else {
83 x.xToNative = purego.NewCallback(func(AddressVarp uintptr, DestVarp uintptr, DestlenVarp uint) bool {
84 return cb(SocketAddressNewFromInternalPtr(AddressVarp), DestVarp, DestlenVarp)
85 })
86 }
87}
88
89// GetToNative gets the "to_native" callback function.
90func (x *SocketAddressClass) GetToNative() func(*SocketAddress, uintptr, uint) bool {
91 if x.xToNative == 0 {
92 return nil
93 }
94 var rawCallback func(AddressVarp uintptr, DestVarp uintptr, DestlenVarp uint) bool
95 purego.RegisterFunc(&rawCallback, x.xToNative)
96 return func(AddressVar *SocketAddress, DestVar uintptr, DestlenVar uint) bool {
97 return rawCallback(AddressVar.GoPointer(), DestVar, DestlenVar)
98 }
99}
100
101// `GSocketAddress` is the equivalent of
102// [`struct sockaddr`](man:sockaddr(3type)) and its subtypes in the BSD sockets
103// API. This is an abstract class; use [class@Gio.InetSocketAddress] for
104// internet sockets, or [class@Gio.UnixSocketAddress] for UNIX domain sockets.
105type SocketAddress struct {
106 gobject.Object
107}
108
109var xSocketAddressGLibType func() types.GType
110
111func SocketAddressGLibType() types.GType {
112 return xSocketAddressGLibType()
113}
114
115func SocketAddressNewFromInternalPtr(ptr uintptr) *SocketAddress {
116 cls := &SocketAddress{}
117 cls.Ptr = ptr
118 return cls
119}
120
121var xNewSocketAddressFromNative func(uintptr, uint) uintptr
122
123// Creates a #GSocketAddress subclass corresponding to the native
124// struct sockaddr @native.
125func NewSocketAddressFromNative(NativeVar uintptr, LenVar uint) *SocketAddress {
126 var cls *SocketAddress
127
128 cret := xNewSocketAddressFromNative(NativeVar, LenVar)
129
130 if cret == 0 {
131 return nil
132 }
133 cls = &SocketAddress{}
134 cls.Ptr = cret
135 return cls
136}
137
138var xSocketAddressGetFamily func(uintptr) SocketFamily
139
140// Gets the socket family type of @address.
141func (x *SocketAddress) GetFamily() SocketFamily {
142
143 cret := xSocketAddressGetFamily(x.GoPointer())
144 return cret
145}
146
147var xSocketAddressGetNativeSize func(uintptr) int
148
149// Gets the size of @address's native struct sockaddr.
150// You can use this to allocate memory to pass to
151// g_socket_address_to_native().
152func (x *SocketAddress) GetNativeSize() int {
153
154 cret := xSocketAddressGetNativeSize(x.GoPointer())
155 return cret
156}
157
158var xSocketAddressToNative func(uintptr, uintptr, uint, **glib.Error) bool
159
160// Converts a #GSocketAddress to a native struct sockaddr, which can
161// be passed to low-level functions like connect() or bind().
162//
163// If not enough space is available, a %G_IO_ERROR_NO_SPACE error
164// is returned. If the address type is not known on the system
165// then a %G_IO_ERROR_NOT_SUPPORTED error is returned.
166func (x *SocketAddress) ToNative(DestVar uintptr, DestlenVar uint) (bool, error) {
167 var cerr *glib.Error
168
169 cret := xSocketAddressToNative(x.GoPointer(), DestVar, DestlenVar, &cerr)
170 if cerr == nil {
171 return cret, nil
172 }
173 return cret, cerr
174
175}
176
177func (c *SocketAddress) GoPointer() uintptr {
178 if c == nil {
179 return 0
180 }
181 return c.Ptr
182}
183
184func (c *SocketAddress) SetGoPointer(ptr uintptr) {
185 c.Ptr = ptr
186}
187
188// Creates a #GSocketAddressEnumerator for @connectable.
189func (x *SocketAddress) Enumerate() *SocketAddressEnumerator {
190 var cls *SocketAddressEnumerator
191
192 cret := XGSocketConnectableEnumerate(x.GoPointer())
193
194 if cret == 0 {
195 return nil
196 }
197 cls = &SocketAddressEnumerator{}
198 cls.Ptr = cret
199 return cls
200}
201
202// Creates a #GSocketAddressEnumerator for @connectable that will
203// return a #GProxyAddress for each of its addresses that you must connect
204// to via a proxy.
205//
206// If @connectable does not implement
207// g_socket_connectable_proxy_enumerate(), this will fall back to
208// calling g_socket_connectable_enumerate().
209func (x *SocketAddress) ProxyEnumerate() *SocketAddressEnumerator {
210 var cls *SocketAddressEnumerator
211
212 cret := XGSocketConnectableProxyEnumerate(x.GoPointer())
213
214 if cret == 0 {
215 return nil
216 }
217 cls = &SocketAddressEnumerator{}
218 cls.Ptr = cret
219 return cls
220}
221
222// Format a #GSocketConnectable as a string. This is a human-readable format for
223// use in debugging output, and is not a stable serialization format. It is not
224// suitable for use in user interfaces as it exposes too much information for a
225// user.
226//
227// If the #GSocketConnectable implementation does not support string formatting,
228// the implementation’s type name will be returned as a fallback.
229func (x *SocketAddress) ToString() string {
230
231 cret := XGSocketConnectableToString(x.GoPointer())
232 return cret
233}
234
235func init() {
236 core.SetPackageName("GIO", "gio-2.0")
237 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
238 var libs []uintptr
239 for _, libPath := range core.GetPaths("GIO") {
240 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
241 if err != nil {
242 panic(err)
243 }
244 libs = append(libs, lib)
245 }
246
247 core.PuregoSafeRegister(&xSocketAddressGLibType, libs, "g_socket_address_get_type")
248
249 core.PuregoSafeRegister(&xNewSocketAddressFromNative, libs, "g_socket_address_new_from_native")
250
251 core.PuregoSafeRegister(&xSocketAddressGetFamily, libs, "g_socket_address_get_family")
252 core.PuregoSafeRegister(&xSocketAddressGetNativeSize, libs, "g_socket_address_get_native_size")
253 core.PuregoSafeRegister(&xSocketAddressToNative, libs, "g_socket_address_to_native")
254
255}