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 InetAddressMaskClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20}
21
22func (x *InetAddressMaskClass) GoPointer() uintptr {
23 return uintptr(unsafe.Pointer(x))
24}
25
26type InetAddressMaskPrivate struct {
27 _ structs.HostLayout
28}
29
30func (x *InetAddressMaskPrivate) GoPointer() uintptr {
31 return uintptr(unsafe.Pointer(x))
32}
33
34// `GInetAddressMask` represents a range of IPv4 or IPv6 addresses
35// described by a base address and a length indicating how many bits
36// of the base address are relevant for matching purposes. These are
37// often given in string form. For example, `10.0.0.0/8`, or `fe80::/10`.
38type InetAddressMask struct {
39 gobject.Object
40}
41
42var xInetAddressMaskGLibType func() types.GType
43
44func InetAddressMaskGLibType() types.GType {
45 return xInetAddressMaskGLibType()
46}
47
48func InetAddressMaskNewFromInternalPtr(ptr uintptr) *InetAddressMask {
49 cls := &InetAddressMask{}
50 cls.Ptr = ptr
51 return cls
52}
53
54var xNewInetAddressMask func(uintptr, uint, **glib.Error) uintptr
55
56// Creates a new #GInetAddressMask representing all addresses whose
57// first @length bits match @addr.
58func NewInetAddressMask(AddrVar *InetAddress, LengthVar uint) (*InetAddressMask, error) {
59 var cls *InetAddressMask
60 var cerr *glib.Error
61
62 cret := xNewInetAddressMask(AddrVar.GoPointer(), LengthVar, &cerr)
63
64 if cret == 0 {
65 return nil, cerr
66 }
67 cls = &InetAddressMask{}
68 cls.Ptr = cret
69 if cerr == nil {
70 return cls, nil
71 }
72 return cls, cerr
73
74}
75
76var xNewInetAddressMaskFromString func(string, **glib.Error) uintptr
77
78// Parses @mask_string as an IP address and (optional) length, and
79// creates a new #GInetAddressMask. The length, if present, is
80// delimited by a "/". If it is not present, then the length is
81// assumed to be the full length of the address.
82func NewInetAddressMaskFromString(MaskStringVar string) (*InetAddressMask, error) {
83 var cls *InetAddressMask
84 var cerr *glib.Error
85
86 cret := xNewInetAddressMaskFromString(MaskStringVar, &cerr)
87
88 if cret == 0 {
89 return nil, cerr
90 }
91 cls = &InetAddressMask{}
92 cls.Ptr = cret
93 if cerr == nil {
94 return cls, nil
95 }
96 return cls, cerr
97
98}
99
100var xInetAddressMaskEqual func(uintptr, uintptr) bool
101
102// Tests if @mask and @mask2 are the same mask.
103func (x *InetAddressMask) Equal(Mask2Var *InetAddressMask) bool {
104
105 cret := xInetAddressMaskEqual(x.GoPointer(), Mask2Var.GoPointer())
106 return cret
107}
108
109var xInetAddressMaskGetAddress func(uintptr) uintptr
110
111// Gets @mask's base address
112func (x *InetAddressMask) GetAddress() *InetAddress {
113 var cls *InetAddress
114
115 cret := xInetAddressMaskGetAddress(x.GoPointer())
116
117 if cret == 0 {
118 return nil
119 }
120 gobject.IncreaseRef(cret)
121 cls = &InetAddress{}
122 cls.Ptr = cret
123 return cls
124}
125
126var xInetAddressMaskGetFamily func(uintptr) SocketFamily
127
128// Gets the #GSocketFamily of @mask's address
129func (x *InetAddressMask) GetFamily() SocketFamily {
130
131 cret := xInetAddressMaskGetFamily(x.GoPointer())
132 return cret
133}
134
135var xInetAddressMaskGetLength func(uintptr) uint
136
137// Gets @mask's length
138func (x *InetAddressMask) GetLength() uint {
139
140 cret := xInetAddressMaskGetLength(x.GoPointer())
141 return cret
142}
143
144var xInetAddressMaskMatches func(uintptr, uintptr) bool
145
146// Tests if @address falls within the range described by @mask.
147func (x *InetAddressMask) Matches(AddressVar *InetAddress) bool {
148
149 cret := xInetAddressMaskMatches(x.GoPointer(), AddressVar.GoPointer())
150 return cret
151}
152
153var xInetAddressMaskToString func(uintptr) string
154
155// Converts @mask back to its corresponding string form.
156func (x *InetAddressMask) ToString() string {
157
158 cret := xInetAddressMaskToString(x.GoPointer())
159 return cret
160}
161
162func (c *InetAddressMask) GoPointer() uintptr {
163 if c == nil {
164 return 0
165 }
166 return c.Ptr
167}
168
169func (c *InetAddressMask) SetGoPointer(ptr uintptr) {
170 c.Ptr = ptr
171}
172
173// SetPropertyLength sets the "length" property.
174// The prefix length, in bytes.
175func (x *InetAddressMask) SetPropertyLength(value uint) {
176 var v gobject.Value
177 v.Init(gobject.TypeUintVal)
178 v.SetUint(value)
179 x.SetProperty("length", &v)
180}
181
182// GetPropertyLength gets the "length" property.
183// The prefix length, in bytes.
184func (x *InetAddressMask) GetPropertyLength() uint {
185 var v gobject.Value
186 x.GetProperty("length", &v)
187 return v.GetUint()
188}
189
190// Initializes the object implementing the interface.
191//
192// This method is intended for language bindings. If writing in C,
193// g_initable_new() should typically be used instead.
194//
195// The object must be initialized before any real use after initial
196// construction, either with this function or g_async_initable_init_async().
197//
198// Implementations may also support cancellation. If @cancellable is not %NULL,
199// then initialization can be cancelled by triggering the cancellable object
200// from another thread. If the operation was cancelled, the error
201// %G_IO_ERROR_CANCELLED will be returned. If @cancellable is not %NULL and
202// the object doesn't support cancellable initialization the error
203// %G_IO_ERROR_NOT_SUPPORTED will be returned.
204//
205// If the object is not initialized, or initialization returns with an
206// error, then all operations on the object except g_object_ref() and
207// g_object_unref() are considered to be invalid, and have undefined
208// behaviour. See the [description][iface@Gio.Initable#description] for more details.
209//
210// Callers should not assume that a class which implements #GInitable can be
211// initialized multiple times, unless the class explicitly documents itself as
212// supporting this. Generally, a class’ implementation of init() can assume
213// (and assert) that it will only be called once. Previously, this documentation
214// recommended all #GInitable implementations should be idempotent; that
215// recommendation was relaxed in GLib 2.54.
216//
217// If a class explicitly supports being initialized multiple times, it is
218// recommended that the method is idempotent: multiple calls with the same
219// arguments should return the same results. Only the first call initializes
220// the object; further calls return the result of the first call.
221//
222// One reason why a class might need to support idempotent initialization is if
223// it is designed to be used via the singleton pattern, with a
224// #GObjectClass.constructor that sometimes returns an existing instance.
225// In this pattern, a caller would expect to be able to call g_initable_init()
226// on the result of g_object_new(), regardless of whether it is in fact a new
227// instance.
228func (x *InetAddressMask) Init(CancellableVar *Cancellable) (bool, error) {
229 var cerr *glib.Error
230
231 cret := XGInitableInit(x.GoPointer(), CancellableVar.GoPointer(), &cerr)
232 if cerr == nil {
233 return cret, nil
234 }
235 return cret, cerr
236
237}
238
239func init() {
240 core.SetPackageName("GIO", "gio-2.0")
241 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
242 var libs []uintptr
243 for _, libPath := range core.GetPaths("GIO") {
244 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
245 if err != nil {
246 panic(err)
247 }
248 libs = append(libs, lib)
249 }
250
251 core.PuregoSafeRegister(&xInetAddressMaskGLibType, libs, "g_inet_address_mask_get_type")
252
253 core.PuregoSafeRegister(&xNewInetAddressMask, libs, "g_inet_address_mask_new")
254 core.PuregoSafeRegister(&xNewInetAddressMaskFromString, libs, "g_inet_address_mask_new_from_string")
255
256 core.PuregoSafeRegister(&xInetAddressMaskEqual, libs, "g_inet_address_mask_equal")
257 core.PuregoSafeRegister(&xInetAddressMaskGetAddress, libs, "g_inet_address_mask_get_address")
258 core.PuregoSafeRegister(&xInetAddressMaskGetFamily, libs, "g_inet_address_mask_get_family")
259 core.PuregoSafeRegister(&xInetAddressMaskGetLength, libs, "g_inet_address_mask_get_length")
260 core.PuregoSafeRegister(&xInetAddressMaskMatches, libs, "g_inet_address_mask_matches")
261 core.PuregoSafeRegister(&xInetAddressMaskToString, libs, "g_inet_address_mask_to_string")
262
263}