/
cgo_helpers.go
11197 lines (9562 loc) · 327 KB
/
cgo_helpers.go
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
// WARNING: This file has automatically been generated on Sat, 15 May 2021 15:29:56 EEST.
// Code generated by https://git.io/c-for-go. DO NOT EDIT.
package nk
/*
#include "nk.h"
#include <stdlib.h>
#include "cgo_helpers.h"
*/
import "C"
import (
"fmt"
"runtime"
"sync"
"unsafe"
)
// cgoAllocMap stores pointers to C allocated memory for future reference.
type cgoAllocMap struct {
mux sync.RWMutex
m map[unsafe.Pointer]struct{}
}
var cgoAllocsUnknown = new(cgoAllocMap)
func (a *cgoAllocMap) Add(ptr unsafe.Pointer) {
a.mux.Lock()
if a.m == nil {
a.m = make(map[unsafe.Pointer]struct{})
}
a.m[ptr] = struct{}{}
a.mux.Unlock()
}
func (a *cgoAllocMap) IsEmpty() bool {
a.mux.RLock()
isEmpty := len(a.m) == 0
a.mux.RUnlock()
return isEmpty
}
func (a *cgoAllocMap) Borrow(b *cgoAllocMap) {
if b == nil || b.IsEmpty() {
return
}
b.mux.Lock()
a.mux.Lock()
for ptr := range b.m {
if a.m == nil {
a.m = make(map[unsafe.Pointer]struct{})
}
a.m[ptr] = struct{}{}
delete(b.m, ptr)
}
a.mux.Unlock()
b.mux.Unlock()
}
func (a *cgoAllocMap) Free() {
a.mux.Lock()
for ptr := range a.m {
C.free(ptr)
delete(a.m, ptr)
}
a.mux.Unlock()
}
func (x PluginAlloc) PassRef() (ref *C.nk_plugin_alloc, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if pluginAlloc88237AC9Func == nil {
pluginAlloc88237AC9Func = x
}
return (*C.nk_plugin_alloc)(C.nk_plugin_alloc_88237ac9), nil
}
func (x PluginAlloc) PassValue() (ref C.nk_plugin_alloc, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if pluginAlloc88237AC9Func == nil {
pluginAlloc88237AC9Func = x
}
return (C.nk_plugin_alloc)(C.nk_plugin_alloc_88237ac9), nil
}
func NewPluginAllocRef(ref unsafe.Pointer) *PluginAlloc {
return (*PluginAlloc)(ref)
}
//export pluginAlloc88237AC9
func pluginAlloc88237AC9(carg0 C.nk_handle, cold unsafe.Pointer, carg2 C.nk_size) unsafe.Pointer {
if pluginAlloc88237AC9Func != nil {
arg088237ac9 := *(*Handle)(unsafe.Pointer(&carg0))
old88237ac9 := (unsafe.Pointer)(unsafe.Pointer(cold))
arg288237ac9 := (Size)(carg2)
ret88237ac9 := pluginAlloc88237AC9Func(arg088237ac9, old88237ac9, arg288237ac9)
ret, _ := ret88237ac9, cgoAllocsUnknown
return ret
}
panic("callback func has not been set (race?)")
}
var pluginAlloc88237AC9Func PluginAlloc
func (x PluginFree) PassRef() (ref *C.nk_plugin_free, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if pluginFree9E32BB09Func == nil {
pluginFree9E32BB09Func = x
}
return (*C.nk_plugin_free)(C.nk_plugin_free_9e32bb09), nil
}
func (x PluginFree) PassValue() (ref C.nk_plugin_free, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if pluginFree9E32BB09Func == nil {
pluginFree9E32BB09Func = x
}
return (C.nk_plugin_free)(C.nk_plugin_free_9e32bb09), nil
}
func NewPluginFreeRef(ref unsafe.Pointer) *PluginFree {
return (*PluginFree)(ref)
}
//export pluginFree9E32BB09
func pluginFree9E32BB09(carg0 C.nk_handle, cold unsafe.Pointer) {
if pluginFree9E32BB09Func != nil {
arg09e32bb09 := *(*Handle)(unsafe.Pointer(&carg0))
old9e32bb09 := (unsafe.Pointer)(unsafe.Pointer(cold))
pluginFree9E32BB09Func(arg09e32bb09, old9e32bb09)
return
}
panic("callback func has not been set (race?)")
}
var pluginFree9E32BB09Func PluginFree
func (x PluginFilter) PassRef() (ref *C.nk_plugin_filter, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if pluginFilter1DF5F22CFunc == nil {
pluginFilter1DF5F22CFunc = x
}
return (*C.nk_plugin_filter)(C.nk_plugin_filter_1df5f22c), nil
}
func (x PluginFilter) PassValue() (ref C.nk_plugin_filter, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if pluginFilter1DF5F22CFunc == nil {
pluginFilter1DF5F22CFunc = x
}
return (C.nk_plugin_filter)(C.nk_plugin_filter_1df5f22c), nil
}
func NewPluginFilterRef(ref unsafe.Pointer) *PluginFilter {
return (*PluginFilter)(ref)
}
//export pluginFilter1DF5F22C
func pluginFilter1DF5F22C(carg0 *C.struct_nk_text_edit, cunicode C.nk_rune) C.int {
if pluginFilter1DF5F22CFunc != nil {
arg01df5f22c := NewTextEditRef(unsafe.Pointer(carg0))
unicode1df5f22c := (Rune)(cunicode)
ret1df5f22c := pluginFilter1DF5F22CFunc(arg01df5f22c, unicode1df5f22c)
ret, _ := (C.int)(ret1df5f22c), cgoAllocsUnknown
return ret
}
panic("callback func has not been set (race?)")
}
var pluginFilter1DF5F22CFunc PluginFilter
func (x PluginPaste) PassRef() (ref *C.nk_plugin_paste, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if pluginPaste70E696C4Func == nil {
pluginPaste70E696C4Func = x
}
return (*C.nk_plugin_paste)(C.nk_plugin_paste_70e696c4), nil
}
func (x PluginPaste) PassValue() (ref C.nk_plugin_paste, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if pluginPaste70E696C4Func == nil {
pluginPaste70E696C4Func = x
}
return (C.nk_plugin_paste)(C.nk_plugin_paste_70e696c4), nil
}
func NewPluginPasteRef(ref unsafe.Pointer) *PluginPaste {
return (*PluginPaste)(ref)
}
//export pluginPaste70E696C4
func pluginPaste70E696C4(carg0 C.nk_handle, carg1 *C.struct_nk_text_edit) {
if pluginPaste70E696C4Func != nil {
arg070e696c4 := *(*Handle)(unsafe.Pointer(&carg0))
arg170e696c4 := NewTextEditRef(unsafe.Pointer(carg1))
pluginPaste70E696C4Func(arg070e696c4, arg170e696c4)
return
}
panic("callback func has not been set (race?)")
}
var pluginPaste70E696C4Func PluginPaste
// packPCharString creates a Go string backed by *C.char and avoids copying.
func packPCharString(p *C.char) (raw string) {
if p != nil && *p != 0 {
h := (*stringHeader)(unsafe.Pointer(&raw))
h.Data = unsafe.Pointer(p)
for *p != 0 {
p = (*C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + 1)) // p++
}
h.Len = int(uintptr(unsafe.Pointer(p)) - uintptr(h.Data))
}
return
}
type stringHeader struct {
Data unsafe.Pointer
Len int
}
// RawString reperesents a string backed by data on the C side.
type RawString string
// Copy returns a Go-managed copy of raw string.
func (raw RawString) Copy() string {
if len(raw) == 0 {
return ""
}
h := (*stringHeader)(unsafe.Pointer(&raw))
return C.GoStringN((*C.char)(h.Data), C.int(h.Len))
}
func (x PluginCopy) PassRef() (ref *C.nk_plugin_copy, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if pluginCopy9EA6C143Func == nil {
pluginCopy9EA6C143Func = x
}
return (*C.nk_plugin_copy)(C.nk_plugin_copy_9ea6c143), nil
}
func (x PluginCopy) PassValue() (ref C.nk_plugin_copy, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if pluginCopy9EA6C143Func == nil {
pluginCopy9EA6C143Func = x
}
return (C.nk_plugin_copy)(C.nk_plugin_copy_9ea6c143), nil
}
func NewPluginCopyRef(ref unsafe.Pointer) *PluginCopy {
return (*PluginCopy)(ref)
}
//export pluginCopy9EA6C143
func pluginCopy9EA6C143(carg0 C.nk_handle, carg1 *C.char, clen C.int) {
if pluginCopy9EA6C143Func != nil {
arg09ea6c143 := *(*Handle)(unsafe.Pointer(&carg0))
arg19ea6c143 := packPCharString(carg1)
len9ea6c143 := (int32)(clen)
pluginCopy9EA6C143Func(arg09ea6c143, arg19ea6c143, len9ea6c143)
return
}
panic("callback func has not been set (race?)")
}
var pluginCopy9EA6C143Func PluginCopy
func (x TextWidthF) PassRef() (ref *C.nk_text_width_f, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if textWidthF67477C0Func == nil {
textWidthF67477C0Func = x
}
return (*C.nk_text_width_f)(C.nk_text_width_f_67477c0), nil
}
func (x TextWidthF) PassValue() (ref C.nk_text_width_f, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if textWidthF67477C0Func == nil {
textWidthF67477C0Func = x
}
return (C.nk_text_width_f)(C.nk_text_width_f_67477c0), nil
}
func NewTextWidthFRef(ref unsafe.Pointer) *TextWidthF {
return (*TextWidthF)(ref)
}
//export textWidthF67477C0
func textWidthF67477C0(carg0 C.nk_handle, ch C.float, carg2 *C.char, clen C.int) C.float {
if textWidthF67477C0Func != nil {
arg067477c0 := *(*Handle)(unsafe.Pointer(&carg0))
h67477c0 := (float32)(ch)
arg267477c0 := packPCharString(carg2)
len67477c0 := (int32)(clen)
ret67477c0 := textWidthF67477C0Func(arg067477c0, h67477c0, arg267477c0, len67477c0)
ret, _ := (C.float)(ret67477c0), cgoAllocsUnknown
return ret
}
panic("callback func has not been set (race?)")
}
var textWidthF67477C0Func TextWidthF
func (x QueryFontGlyphF) PassRef() (ref *C.nk_query_font_glyph_f, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if queryFontGlyphF5BA87240Func == nil {
queryFontGlyphF5BA87240Func = x
}
return (*C.nk_query_font_glyph_f)(C.nk_query_font_glyph_f_5ba87240), nil
}
func (x QueryFontGlyphF) PassValue() (ref C.nk_query_font_glyph_f, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if queryFontGlyphF5BA87240Func == nil {
queryFontGlyphF5BA87240Func = x
}
return (C.nk_query_font_glyph_f)(C.nk_query_font_glyph_f_5ba87240), nil
}
func NewQueryFontGlyphFRef(ref unsafe.Pointer) *QueryFontGlyphF {
return (*QueryFontGlyphF)(ref)
}
//export queryFontGlyphF5BA87240
func queryFontGlyphF5BA87240(chandle C.nk_handle, cfontHeight C.float, cglyph *C.struct_nk_user_font_glyph, ccodepoint C.nk_rune, cnextCodepoint C.nk_rune) {
if queryFontGlyphF5BA87240Func != nil {
handle5ba87240 := *(*Handle)(unsafe.Pointer(&chandle))
fontHeight5ba87240 := (float32)(cfontHeight)
glyph5ba87240 := NewUserFontGlyphRef(unsafe.Pointer(cglyph))
codepoint5ba87240 := (Rune)(ccodepoint)
nextCodepoint5ba87240 := (Rune)(cnextCodepoint)
queryFontGlyphF5BA87240Func(handle5ba87240, fontHeight5ba87240, glyph5ba87240, codepoint5ba87240, nextCodepoint5ba87240)
return
}
panic("callback func has not been set (race?)")
}
var queryFontGlyphF5BA87240Func QueryFontGlyphF
func (x CommandCustomCallback) PassRef() (ref *C.nk_command_custom_callback, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if commandCustomCallbackD451FDB1Func == nil {
commandCustomCallbackD451FDB1Func = x
}
return (*C.nk_command_custom_callback)(C.nk_command_custom_callback_d451fdb1), nil
}
func (x CommandCustomCallback) PassValue() (ref C.nk_command_custom_callback, allocs *cgoAllocMap) {
if x == nil {
return nil, nil
}
if commandCustomCallbackD451FDB1Func == nil {
commandCustomCallbackD451FDB1Func = x
}
return (C.nk_command_custom_callback)(C.nk_command_custom_callback_d451fdb1), nil
}
func NewCommandCustomCallbackRef(ref unsafe.Pointer) *CommandCustomCallback {
return (*CommandCustomCallback)(ref)
}
//export commandCustomCallbackD451FDB1
func commandCustomCallbackD451FDB1(ccanvas unsafe.Pointer, cx C.short, cy C.short, cw C.ushort, ch C.ushort, ccallbackData C.nk_handle) {
if commandCustomCallbackD451FDB1Func != nil {
canvasd451fdb1 := (unsafe.Pointer)(unsafe.Pointer(ccanvas))
xd451fdb1 := (int16)(cx)
yd451fdb1 := (int16)(cy)
wd451fdb1 := (uint16)(cw)
hd451fdb1 := (uint16)(ch)
callbackDatad451fdb1 := *(*Handle)(unsafe.Pointer(&ccallbackData))
commandCustomCallbackD451FDB1Func(canvasd451fdb1, xd451fdb1, yd451fdb1, wd451fdb1, hd451fdb1, callbackDatad451fdb1)
return
}
panic("callback func has not been set (race?)")
}
var commandCustomCallbackD451FDB1Func CommandCustomCallback
// Ref returns a reference to C object as it is.
func (x *Allocator) Ref() *C.struct_nk_allocator {
if x == nil {
return nil
}
return (*C.struct_nk_allocator)(unsafe.Pointer(x))
}
// Free cleanups the referenced memory using C free.
func (x *Allocator) Free() {
if x != nil {
C.free(unsafe.Pointer(x))
}
}
// NewAllocatorRef converts the C object reference into a raw struct reference without wrapping.
func NewAllocatorRef(ref unsafe.Pointer) *Allocator {
return (*Allocator)(ref)
}
// NewAllocator allocates a new C object of this type and converts the reference into
// a raw struct reference without wrapping.
func NewAllocator() *Allocator {
return (*Allocator)(allocStructNkAllocatorMemory(1))
}
// allocStructNkAllocatorMemory allocates memory for type C.struct_nk_allocator in C.
// The caller is responsible for freeing the this memory via C.free.
func allocStructNkAllocatorMemory(n int) unsafe.Pointer {
mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfStructNkAllocatorValue))
if mem == nil {
panic(fmt.Sprintln("memory alloc error: ", err))
}
return mem
}
const sizeOfStructNkAllocatorValue = unsafe.Sizeof([1]C.struct_nk_allocator{})
// PassRef returns a reference to C object as it is or allocates a new C object of this type.
func (x *Allocator) PassRef() *C.struct_nk_allocator {
if x == nil {
x = (*Allocator)(allocStructNkAllocatorMemory(1))
}
return (*C.struct_nk_allocator)(unsafe.Pointer(x))
}
// GetUserdata returns a reference to C object within a struct
func (s *Allocator) GetUserdata() *Handle {
var ret *Handle
ret = (*Handle)(unsafe.Pointer(&s.userdata))
return ret
}
// GetAlloc returns a reference to C object within a struct
func (s *Allocator) GetAlloc() *PluginAlloc {
var ret *PluginAlloc
ret = NewPluginAllocRef(unsafe.Pointer(&s.alloc))
return ret
}
// GetFree returns a reference to C object within a struct
func (s *Allocator) GetFree() *PluginFree {
var ret *PluginFree
ret = NewPluginFreeRef(unsafe.Pointer(&s.free))
return ret
}
// Ref returns a reference to C object as it is.
func (x *BakedFont) Ref() *C.struct_nk_baked_font {
if x == nil {
return nil
}
return (*C.struct_nk_baked_font)(unsafe.Pointer(x))
}
// Free cleanups the referenced memory using C free.
func (x *BakedFont) Free() {
if x != nil {
C.free(unsafe.Pointer(x))
}
}
// NewBakedFontRef converts the C object reference into a raw struct reference without wrapping.
func NewBakedFontRef(ref unsafe.Pointer) *BakedFont {
return (*BakedFont)(ref)
}
// NewBakedFont allocates a new C object of this type and converts the reference into
// a raw struct reference without wrapping.
func NewBakedFont() *BakedFont {
return (*BakedFont)(allocStructNkBakedFontMemory(1))
}
// allocStructNkBakedFontMemory allocates memory for type C.struct_nk_baked_font in C.
// The caller is responsible for freeing the this memory via C.free.
func allocStructNkBakedFontMemory(n int) unsafe.Pointer {
mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfStructNkBakedFontValue))
if mem == nil {
panic(fmt.Sprintln("memory alloc error: ", err))
}
return mem
}
const sizeOfStructNkBakedFontValue = unsafe.Sizeof([1]C.struct_nk_baked_font{})
// PassRef returns a reference to C object as it is or allocates a new C object of this type.
func (x *BakedFont) PassRef() *C.struct_nk_baked_font {
if x == nil {
x = (*BakedFont)(allocStructNkBakedFontMemory(1))
}
return (*C.struct_nk_baked_font)(unsafe.Pointer(x))
}
// GetHeight returns a reference to C object within a struct
func (s *BakedFont) GetHeight() *float32 {
var ret *float32
ret = (*float32)(unsafe.Pointer(&s.height))
return ret
}
// GetAscent returns a reference to C object within a struct
func (s *BakedFont) GetAscent() *float32 {
var ret *float32
ret = (*float32)(unsafe.Pointer(&s.ascent))
return ret
}
// GetDescent returns a reference to C object within a struct
func (s *BakedFont) GetDescent() *float32 {
var ret *float32
ret = (*float32)(unsafe.Pointer(&s.descent))
return ret
}
// GetGlyphOffset returns a reference to C object within a struct
func (s *BakedFont) GetGlyphOffset() *Rune {
var ret *Rune
ret = (*Rune)(unsafe.Pointer(&s.glyph_offset))
return ret
}
// GetGlyphCount returns a reference to C object within a struct
func (s *BakedFont) GetGlyphCount() *Rune {
var ret *Rune
ret = (*Rune)(unsafe.Pointer(&s.glyph_count))
return ret
}
// GetRanges returns a reference to C object within a struct
func (s *BakedFont) GetRanges() **Rune {
var ret **Rune
ret = (**Rune)(unsafe.Pointer(&s.ranges))
return ret
}
// Ref returns a reference to C object as it is.
func (x *Buffer) Ref() *C.struct_nk_buffer {
if x == nil {
return nil
}
return (*C.struct_nk_buffer)(unsafe.Pointer(x))
}
// Free cleanups the referenced memory using C free.
func (x *Buffer) Free() {
if x != nil {
C.free(unsafe.Pointer(x))
}
}
// NewBufferRef converts the C object reference into a raw struct reference without wrapping.
func NewBufferRef(ref unsafe.Pointer) *Buffer {
return (*Buffer)(ref)
}
// NewBuffer allocates a new C object of this type and converts the reference into
// a raw struct reference without wrapping.
func NewBuffer() *Buffer {
return (*Buffer)(allocStructNkBufferMemory(1))
}
// allocStructNkBufferMemory allocates memory for type C.struct_nk_buffer in C.
// The caller is responsible for freeing the this memory via C.free.
func allocStructNkBufferMemory(n int) unsafe.Pointer {
mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfStructNkBufferValue))
if mem == nil {
panic(fmt.Sprintln("memory alloc error: ", err))
}
return mem
}
const sizeOfStructNkBufferValue = unsafe.Sizeof([1]C.struct_nk_buffer{})
// PassRef returns a reference to C object as it is or allocates a new C object of this type.
func (x *Buffer) PassRef() *C.struct_nk_buffer {
if x == nil {
x = (*Buffer)(allocStructNkBufferMemory(1))
}
return (*C.struct_nk_buffer)(unsafe.Pointer(x))
}
// GetMarker returns a reference to C object within a struct
func (s *Buffer) GetMarker() [2]BufferMarker {
var ret [2]BufferMarker
ret = *(*[2]BufferMarker)(unsafe.Pointer(&s.marker))
return ret
}
// GetPool returns a reference to C object within a struct
func (s *Buffer) GetPool() *Allocator {
var ret *Allocator
ret = (*Allocator)(unsafe.Pointer(&s.pool))
return ret
}
// GetType returns a reference to C object within a struct
func (s *Buffer) GetType() *AllocationType {
var ret *AllocationType
ret = (*AllocationType)(unsafe.Pointer(&s._type))
return ret
}
// GetMemory returns a reference to C object within a struct
func (s *Buffer) GetMemory() *Memory {
var ret *Memory
ret = (*Memory)(unsafe.Pointer(&s.memory))
return ret
}
// GetGrowFactor returns a reference to C object within a struct
func (s *Buffer) GetGrowFactor() *float32 {
var ret *float32
ret = (*float32)(unsafe.Pointer(&s.grow_factor))
return ret
}
// GetAllocated returns a reference to C object within a struct
func (s *Buffer) GetAllocated() *Size {
var ret *Size
ret = (*Size)(unsafe.Pointer(&s.allocated))
return ret
}
// GetNeeded returns a reference to C object within a struct
func (s *Buffer) GetNeeded() *Size {
var ret *Size
ret = (*Size)(unsafe.Pointer(&s.needed))
return ret
}
// GetCalls returns a reference to C object within a struct
func (s *Buffer) GetCalls() *Size {
var ret *Size
ret = (*Size)(unsafe.Pointer(&s.calls))
return ret
}
// GetSize returns a reference to C object within a struct
func (s *Buffer) GetSize() *Size {
var ret *Size
ret = (*Size)(unsafe.Pointer(&s.size))
return ret
}
// Ref returns a reference to C object as it is.
func (x *BufferMarker) Ref() *C.struct_nk_buffer_marker {
if x == nil {
return nil
}
return (*C.struct_nk_buffer_marker)(unsafe.Pointer(x))
}
// Free cleanups the referenced memory using C free.
func (x *BufferMarker) Free() {
if x != nil {
C.free(unsafe.Pointer(x))
}
}
// NewBufferMarkerRef converts the C object reference into a raw struct reference without wrapping.
func NewBufferMarkerRef(ref unsafe.Pointer) *BufferMarker {
return (*BufferMarker)(ref)
}
// NewBufferMarker allocates a new C object of this type and converts the reference into
// a raw struct reference without wrapping.
func NewBufferMarker() *BufferMarker {
return (*BufferMarker)(allocStructNkBufferMarkerMemory(1))
}
// allocStructNkBufferMarkerMemory allocates memory for type C.struct_nk_buffer_marker in C.
// The caller is responsible for freeing the this memory via C.free.
func allocStructNkBufferMarkerMemory(n int) unsafe.Pointer {
mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfStructNkBufferMarkerValue))
if mem == nil {
panic(fmt.Sprintln("memory alloc error: ", err))
}
return mem
}
const sizeOfStructNkBufferMarkerValue = unsafe.Sizeof([1]C.struct_nk_buffer_marker{})
// PassRef returns a reference to C object as it is or allocates a new C object of this type.
func (x *BufferMarker) PassRef() *C.struct_nk_buffer_marker {
if x == nil {
x = (*BufferMarker)(allocStructNkBufferMarkerMemory(1))
}
return (*C.struct_nk_buffer_marker)(unsafe.Pointer(x))
}
// GetActive returns a reference to C object within a struct
func (s *BufferMarker) GetActive() *int32 {
var ret *int32
ret = (*int32)(unsafe.Pointer(&s.active))
return ret
}
// GetOffset returns a reference to C object within a struct
func (s *BufferMarker) GetOffset() *Size {
var ret *Size
ret = (*Size)(unsafe.Pointer(&s.offset))
return ret
}
// Ref returns a reference to C object as it is.
func (x *Chart) Ref() *C.struct_nk_chart {
if x == nil {
return nil
}
return (*C.struct_nk_chart)(unsafe.Pointer(x))
}
// Free cleanups the referenced memory using C free.
func (x *Chart) Free() {
if x != nil {
C.free(unsafe.Pointer(x))
}
}
// NewChartRef converts the C object reference into a raw struct reference without wrapping.
func NewChartRef(ref unsafe.Pointer) *Chart {
return (*Chart)(ref)
}
// NewChart allocates a new C object of this type and converts the reference into
// a raw struct reference without wrapping.
func NewChart() *Chart {
return (*Chart)(allocStructNkChartMemory(1))
}
// allocStructNkChartMemory allocates memory for type C.struct_nk_chart in C.
// The caller is responsible for freeing the this memory via C.free.
func allocStructNkChartMemory(n int) unsafe.Pointer {
mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfStructNkChartValue))
if mem == nil {
panic(fmt.Sprintln("memory alloc error: ", err))
}
return mem
}
const sizeOfStructNkChartValue = unsafe.Sizeof([1]C.struct_nk_chart{})
// PassRef returns a reference to C object as it is or allocates a new C object of this type.
func (x *Chart) PassRef() *C.struct_nk_chart {
if x == nil {
x = (*Chart)(allocStructNkChartMemory(1))
}
return (*C.struct_nk_chart)(unsafe.Pointer(x))
}
// GetSlot returns a reference to C object within a struct
func (s *Chart) GetSlot() *int32 {
var ret *int32
ret = (*int32)(unsafe.Pointer(&s.slot))
return ret
}
// GetX returns a reference to C object within a struct
func (s *Chart) GetX() *float32 {
var ret *float32
ret = (*float32)(unsafe.Pointer(&s.x))
return ret
}
// GetY returns a reference to C object within a struct
func (s *Chart) GetY() *float32 {
var ret *float32
ret = (*float32)(unsafe.Pointer(&s.y))
return ret
}
// GetW returns a reference to C object within a struct
func (s *Chart) GetW() *float32 {
var ret *float32
ret = (*float32)(unsafe.Pointer(&s.w))
return ret
}
// GetH returns a reference to C object within a struct
func (s *Chart) GetH() *float32 {
var ret *float32
ret = (*float32)(unsafe.Pointer(&s.h))
return ret
}
// GetSlots returns a reference to C object within a struct
func (s *Chart) GetSlots() [4]ChartSlot {
var ret [4]ChartSlot
ret = *(*[4]ChartSlot)(unsafe.Pointer(&s.slots))
return ret
}
// Ref returns a reference to C object as it is.
func (x *ChartSlot) Ref() *C.struct_nk_chart_slot {
if x == nil {
return nil
}
return (*C.struct_nk_chart_slot)(unsafe.Pointer(x))
}
// Free cleanups the referenced memory using C free.
func (x *ChartSlot) Free() {
if x != nil {
C.free(unsafe.Pointer(x))
}
}
// NewChartSlotRef converts the C object reference into a raw struct reference without wrapping.
func NewChartSlotRef(ref unsafe.Pointer) *ChartSlot {
return (*ChartSlot)(ref)
}
// NewChartSlot allocates a new C object of this type and converts the reference into
// a raw struct reference without wrapping.
func NewChartSlot() *ChartSlot {
return (*ChartSlot)(allocStructNkChartSlotMemory(1))
}
// allocStructNkChartSlotMemory allocates memory for type C.struct_nk_chart_slot in C.
// The caller is responsible for freeing the this memory via C.free.
func allocStructNkChartSlotMemory(n int) unsafe.Pointer {
mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfStructNkChartSlotValue))
if mem == nil {
panic(fmt.Sprintln("memory alloc error: ", err))
}
return mem
}
const sizeOfStructNkChartSlotValue = unsafe.Sizeof([1]C.struct_nk_chart_slot{})
// PassRef returns a reference to C object as it is or allocates a new C object of this type.
func (x *ChartSlot) PassRef() *C.struct_nk_chart_slot {
if x == nil {
x = (*ChartSlot)(allocStructNkChartSlotMemory(1))
}
return (*C.struct_nk_chart_slot)(unsafe.Pointer(x))
}
// GetType returns a reference to C object within a struct
func (s *ChartSlot) GetType() *ChartType {
var ret *ChartType
ret = (*ChartType)(unsafe.Pointer(&s._type))
return ret
}
// GetColor returns a reference to C object within a struct
func (s *ChartSlot) GetColor() *Color {
var ret *Color
ret = (*Color)(unsafe.Pointer(&s.color))
return ret
}
// GetHighlight returns a reference to C object within a struct
func (s *ChartSlot) GetHighlight() *Color {
var ret *Color
ret = (*Color)(unsafe.Pointer(&s.highlight))
return ret
}
// GetMin returns a reference to C object within a struct
func (s *ChartSlot) GetMin() *float32 {
var ret *float32
ret = (*float32)(unsafe.Pointer(&s.min))
return ret
}
// GetMax returns a reference to C object within a struct
func (s *ChartSlot) GetMax() *float32 {
var ret *float32
ret = (*float32)(unsafe.Pointer(&s.max))
return ret
}
// GetRange returns a reference to C object within a struct
func (s *ChartSlot) GetRange() *float32 {
var ret *float32
ret = (*float32)(unsafe.Pointer(&s._range))
return ret
}
// GetCount returns a reference to C object within a struct
func (s *ChartSlot) GetCount() *int32 {
var ret *int32
ret = (*int32)(unsafe.Pointer(&s.count))
return ret
}
// GetLast returns a reference to C object within a struct
func (s *ChartSlot) GetLast() *Vec2 {
var ret *Vec2
ret = (*Vec2)(unsafe.Pointer(&s.last))
return ret
}
// GetIndex returns a reference to C object within a struct
func (s *ChartSlot) GetIndex() *int32 {
var ret *int32
ret = (*int32)(unsafe.Pointer(&s.index))
return ret
}
// Ref returns a reference to C object as it is.
func (x *Clipboard) Ref() *C.struct_nk_clipboard {
if x == nil {
return nil
}
return (*C.struct_nk_clipboard)(unsafe.Pointer(x))
}
// Free cleanups the referenced memory using C free.
func (x *Clipboard) Free() {
if x != nil {
C.free(unsafe.Pointer(x))
}
}
// NewClipboardRef converts the C object reference into a raw struct reference without wrapping.
func NewClipboardRef(ref unsafe.Pointer) *Clipboard {
return (*Clipboard)(ref)
}
// NewClipboard allocates a new C object of this type and converts the reference into
// a raw struct reference without wrapping.
func NewClipboard() *Clipboard {
return (*Clipboard)(allocStructNkClipboardMemory(1))
}
// allocStructNkClipboardMemory allocates memory for type C.struct_nk_clipboard in C.
// The caller is responsible for freeing the this memory via C.free.
func allocStructNkClipboardMemory(n int) unsafe.Pointer {
mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfStructNkClipboardValue))
if mem == nil {
panic(fmt.Sprintln("memory alloc error: ", err))
}
return mem
}
const sizeOfStructNkClipboardValue = unsafe.Sizeof([1]C.struct_nk_clipboard{})
// PassRef returns a reference to C object as it is or allocates a new C object of this type.
func (x *Clipboard) PassRef() *C.struct_nk_clipboard {
if x == nil {
x = (*Clipboard)(allocStructNkClipboardMemory(1))
}
return (*C.struct_nk_clipboard)(unsafe.Pointer(x))
}
// GetUserdata returns a reference to C object within a struct
func (s *Clipboard) GetUserdata() *Handle {
var ret *Handle
ret = (*Handle)(unsafe.Pointer(&s.userdata))
return ret
}
// GetPaste returns a reference to C object within a struct
func (s *Clipboard) GetPaste() *PluginPaste {
var ret *PluginPaste
ret = NewPluginPasteRef(unsafe.Pointer(&s.paste))
return ret
}
// GetCopy returns a reference to C object within a struct
func (s *Clipboard) GetCopy() *PluginCopy {
var ret *PluginCopy
ret = NewPluginCopyRef(unsafe.Pointer(&s.copy))
return ret
}
// Ref returns a reference to C object as it is.
func (x *Color) Ref() *C.struct_nk_color {