-
Notifications
You must be signed in to change notification settings - Fork 0
/
dither_go.go
2184 lines (1870 loc) · 62.7 KB
/
dither_go.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
/*
cgo stubs for package dither_go.
File is generated by gopy. Do not edit.
gopy build -no-make -output=dither_go/bindings -vm=python3 ./dither_go github.com/tfuxu/dither-gopy
*/
package main
/*
#cgo CFLAGS: -I/usr/include/python3.11 -Wno-error -Wno-implicit-function-declaration -Wno-int-conversion
#cgo LDFLAGS: -L/usr/lib -lpython3.11 -ldl -lm
// #define Py_LIMITED_API // need full API for PyRun*
#include <Python.h>
typedef uint8_t bool;
// static inline is trick for avoiding need for extra .c file
// the following are used for build value -- switch on reflect.Kind
// or the types equivalent
static inline PyObject* gopy_build_bool(uint8_t val) {
return Py_BuildValue("b", val);
}
static inline PyObject* gopy_build_int64(int64_t val) {
return Py_BuildValue("k", val);
}
static inline PyObject* gopy_build_uint64(uint64_t val) {
return Py_BuildValue("K", val);
}
static inline PyObject* gopy_build_float64(double val) {
return Py_BuildValue("d", val);
}
static inline PyObject* gopy_build_string(const char* val) {
return Py_BuildValue("s", val);
}
static inline void gopy_decref(PyObject* obj) { // macro
Py_XDECREF(obj);
}
static inline void gopy_incref(PyObject* obj) { // macro
Py_XINCREF(obj);
}
static inline int gopy_method_check(PyObject* obj) { // macro
return PyMethod_Check(obj);
}
static inline void gopy_err_handle() {
if(PyErr_Occurred() != NULL) {
PyErr_Print();
}
}
*/
import "C"
import (
"errors"
"reflect"
"unsafe"
"github.com/go-python/gopy/gopyh" // handler
"image"
"image/color"
"image/draw"
"github.com/tfuxu/dither-go/dither_go"
dither "github.com/tfuxu/dither-gopy"
)
// main doesn't do anything in lib / pkg mode, but is essential for exe mode
func main() {
}
// initialization functions -- can be called from python after library is loaded
// GoPyInitRunFile runs a separate python file -- call in GoPyInit if it
// steals the main thread e.g., for GUI event loop, as in GoGi startup.
//export GoPyInit
func GoPyInit() {
}
// type for the handle -- int64 for speed (can switch to string)
type GoHandle int64
type CGoHandle C.longlong
// DecRef decrements the reference count for the specified handle
// and deletes it it goes to zero.
//
//export DecRef
func DecRef(handle CGoHandle) {
gopyh.DecRef(gopyh.CGoHandle(handle))
}
// IncRef increments the reference count for the specified handle.
//
//export IncRef
func IncRef(handle CGoHandle) {
gopyh.IncRef(gopyh.CGoHandle(handle))
}
// NumHandles returns the number of handles currently in use.
//
//export NumHandles
func NumHandles() int {
return gopyh.NumHandles()
}
// boolGoToPy converts a Go bool to python-compatible C.char
func boolGoToPy(b bool) C.char {
if b {
return 1
}
return 0
}
// boolPyToGo converts a python-compatible C.Char to Go bool
func boolPyToGo(b C.char) bool {
if b != 0 {
return true
}
return false
}
func complex64GoToPy(c complex64) *C.PyObject {
return C.PyComplex_FromDoubles(C.double(real(c)), C.double(imag(c)))
}
func complex64PyToGo(o *C.PyObject) complex64 {
v := C.PyComplex_AsCComplex(o)
return complex(float32(v.real), float32(v.imag))
}
func complex128GoToPy(c complex128) *C.PyObject {
return C.PyComplex_FromDoubles(C.double(real(c)), C.double(imag(c)))
}
func complex128PyToGo(o *C.PyObject) complex128 {
v := C.PyComplex_AsCComplex(o)
return complex(float64(v.real), float64(v.imag))
}
// errorGoToPy converts a Go error to python-compatible C.CString
func errorGoToPy(e error) *C.char {
if e != nil {
return C.CString(e.Error())
}
return C.CString("")
}
// --- generated code for package: dither_go below: ---
// ---- External Types Outside of Targeted Packages ---
// Converters for pointer handles for type: *image.Paletted
func ptrFromHandle_Ptr_image_Paletted(h CGoHandle) *image.Paletted {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "*image.Paletted")
if p == nil {
return nil
}
return gopyh.Embed(p, reflect.TypeOf(image.Paletted{})).(*image.Paletted)
}
func handleFromPtr_Ptr_image_Paletted(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("*image.Paletted", p))
}
// Converters for pointer handles for type: *image.RGBA
func ptrFromHandle_Ptr_image_RGBA(h CGoHandle) *image.RGBA {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "*image.RGBA")
if p == nil {
return nil
}
return gopyh.Embed(p, reflect.TypeOf(image.RGBA{})).(*image.RGBA)
}
func handleFromPtr_Ptr_image_RGBA(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("*image.RGBA", p))
}
// Converters for pointer handles for type: image.Image
func ptrFromHandle_image_Image(h CGoHandle) image.Image {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "image.Image")
if p == nil {
return nil
}
return p.(image.Image)
}
func handleFromPtr_image_Image(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("image.Image", p))
}
// Converters for non-pointer handles for type: image.Paletted
func ptrFromHandle_image_Paletted(h CGoHandle) *image.Paletted {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "image.Paletted")
if p == nil {
return nil
}
return gopyh.Embed(p, reflect.TypeOf(image.Paletted{})).(*image.Paletted)
}
func handleFromPtr_image_Paletted(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("image.Paletted", p))
}
// Converters for non-pointer handles for type: image.Point
func ptrFromHandle_image_Point(h CGoHandle) *image.Point {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "image.Point")
if p == nil {
return nil
}
return gopyh.Embed(p, reflect.TypeOf(image.Point{})).(*image.Point)
}
func handleFromPtr_image_Point(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("image.Point", p))
}
// Converters for non-pointer handles for type: image.RGBA
func ptrFromHandle_image_RGBA(h CGoHandle) *image.RGBA {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "image.RGBA")
if p == nil {
return nil
}
return gopyh.Embed(p, reflect.TypeOf(image.RGBA{})).(*image.RGBA)
}
func handleFromPtr_image_RGBA(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("image.RGBA", p))
}
// Converters for non-pointer handles for type: image.Rectangle
func ptrFromHandle_image_Rectangle(h CGoHandle) *image.Rectangle {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "image.Rectangle")
if p == nil {
return nil
}
return gopyh.Embed(p, reflect.TypeOf(image.Rectangle{})).(*image.Rectangle)
}
func handleFromPtr_image_Rectangle(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("image.Rectangle", p))
}
// Converters for pointer handles for type: color.Color
func ptrFromHandle_color_Color(h CGoHandle) color.Color {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "color.Color")
if p == nil {
return nil
}
return p.(color.Color)
}
func handleFromPtr_color_Color(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("color.Color", p))
}
// Converters for pointer handles for type: color.Model
func ptrFromHandle_color_Model(h CGoHandle) color.Model {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "color.Model")
if p == nil {
return nil
}
return p.(color.Model)
}
func handleFromPtr_color_Model(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("color.Model", p))
}
// Converters for implicit pointer handles for type: color.Palette
func ptrFromHandle_color_Palette(h CGoHandle) *color.Palette {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "color.Palette")
if p == nil {
return nil
}
return p.(*color.Palette)
}
func deptrFromHandle_color_Palette(h CGoHandle) color.Palette {
p := ptrFromHandle_color_Palette(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_color_Palette(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("color.Palette", p))
}
// --- wrapping slice: color.Palette ---
//
//export color_Palette_CTor
func color_Palette_CTor() CGoHandle {
return CGoHandle(handleFromPtr_color_Palette(&color.Palette{}))
}
//export color_Palette_len
func color_Palette_len(handle CGoHandle) int {
return len(deptrFromHandle_color_Palette(handle))
}
//export color_Palette_elem
func color_Palette_elem(handle CGoHandle, _idx int) CGoHandle {
s := deptrFromHandle_color_Palette(handle)
return handleFromPtr_color_Color(s[_idx])
}
//export color_Palette_subslice
func color_Palette_subslice(handle CGoHandle, _st, _ed int) CGoHandle {
s := deptrFromHandle_color_Palette(handle)
ss := s[_st:_ed]
return CGoHandle(handleFromPtr_color_Palette(&ss))
}
//export color_Palette_set
func color_Palette_set(handle CGoHandle, _idx int, _vl CGoHandle) {
s := deptrFromHandle_color_Palette(handle)
s[_idx] = ptrFromHandle_color_Color(_vl)
}
//export color_Palette_append
func color_Palette_append(handle CGoHandle, _vl CGoHandle) {
s := ptrFromHandle_color_Palette(handle)
*s = append(*s, ptrFromHandle_color_Color(_vl))
}
// Converters for non-pointer handles for type: color.RGBA
func ptrFromHandle_color_RGBA(h CGoHandle) *color.RGBA {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "color.RGBA")
if p == nil {
return nil
}
return gopyh.Embed(p, reflect.TypeOf(color.RGBA{})).(*color.RGBA)
}
func handleFromPtr_color_RGBA(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("color.RGBA", p))
}
// Converters for non-pointer handles for type: color.RGBA64
func ptrFromHandle_color_RGBA64(h CGoHandle) *color.RGBA64 {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "color.RGBA64")
if p == nil {
return nil
}
return gopyh.Embed(p, reflect.TypeOf(color.RGBA64{})).(*color.RGBA64)
}
func handleFromPtr_color_RGBA64(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("color.RGBA64", p))
}
// Converters for pointer handles for type: draw.Image
func ptrFromHandle_draw_Image(h CGoHandle) draw.Image {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "draw.Image")
if p == nil {
return nil
}
return p.(draw.Image)
}
func handleFromPtr_draw_Image(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("draw.Image", p))
}
// ---- Package: go ---
// ---- Types ---
// Converters for implicit pointer handles for type: []bool
func ptrFromHandle_Slice_bool(h CGoHandle) *[]bool {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]bool")
if p == nil {
return nil
}
return p.(*[]bool)
}
func deptrFromHandle_Slice_bool(h CGoHandle) []bool {
p := ptrFromHandle_Slice_bool(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_Slice_bool(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("[]bool", p))
}
// --- wrapping slice: []bool ---
//
//export Slice_bool_CTor
func Slice_bool_CTor() CGoHandle {
return CGoHandle(handleFromPtr_Slice_bool(&[]bool{}))
}
//export Slice_bool_len
func Slice_bool_len(handle CGoHandle) int {
return len(deptrFromHandle_Slice_bool(handle))
}
//export Slice_bool_elem
func Slice_bool_elem(handle CGoHandle, _idx int) C.char {
s := deptrFromHandle_Slice_bool(handle)
return boolGoToPy(s[_idx])
}
//export Slice_bool_subslice
func Slice_bool_subslice(handle CGoHandle, _st, _ed int) CGoHandle {
s := deptrFromHandle_Slice_bool(handle)
ss := s[_st:_ed]
return CGoHandle(handleFromPtr_Slice_bool(&ss))
}
//export Slice_bool_set
func Slice_bool_set(handle CGoHandle, _idx int, _vl C.char) {
s := deptrFromHandle_Slice_bool(handle)
s[_idx] = boolPyToGo(_vl)
}
//export Slice_bool_append
func Slice_bool_append(handle CGoHandle, _vl C.char) {
s := ptrFromHandle_Slice_bool(handle)
*s = append(*s, boolPyToGo(_vl))
}
// Converters for implicit pointer handles for type: []byte
func ptrFromHandle_Slice_byte(h CGoHandle) *[]byte {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]byte")
if p == nil {
return nil
}
return p.(*[]byte)
}
func deptrFromHandle_Slice_byte(h CGoHandle) []byte {
p := ptrFromHandle_Slice_byte(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_Slice_byte(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("[]byte", p))
}
// --- wrapping slice: []byte ---
//
//export Slice_byte_CTor
func Slice_byte_CTor() CGoHandle {
return CGoHandle(handleFromPtr_Slice_byte(&[]byte{}))
}
//export Slice_byte_len
func Slice_byte_len(handle CGoHandle) int {
return len(deptrFromHandle_Slice_byte(handle))
}
//export Slice_byte_elem
func Slice_byte_elem(handle CGoHandle, _idx int) C.char {
s := deptrFromHandle_Slice_byte(handle)
return C.char(s[_idx])
}
//export Slice_byte_subslice
func Slice_byte_subslice(handle CGoHandle, _st, _ed int) CGoHandle {
s := deptrFromHandle_Slice_byte(handle)
ss := s[_st:_ed]
return CGoHandle(handleFromPtr_Slice_byte(&ss))
}
//export Slice_byte_set
func Slice_byte_set(handle CGoHandle, _idx int, _vl C.char) {
s := deptrFromHandle_Slice_byte(handle)
s[_idx] = byte(_vl)
}
//export Slice_byte_append
func Slice_byte_append(handle CGoHandle, _vl C.char) {
s := ptrFromHandle_Slice_byte(handle)
*s = append(*s, byte(_vl))
}
// Converters for implicit pointer handles for type: []error
func ptrFromHandle_Slice_error(h CGoHandle) *[]error {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]error")
if p == nil {
return nil
}
return p.(*[]error)
}
func deptrFromHandle_Slice_error(h CGoHandle) []error {
p := ptrFromHandle_Slice_error(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_Slice_error(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("[]error", p))
}
// --- wrapping slice: []error ---
//
//export Slice_error_CTor
func Slice_error_CTor() CGoHandle {
return CGoHandle(handleFromPtr_Slice_error(&[]error{}))
}
//export Slice_error_len
func Slice_error_len(handle CGoHandle) int {
return len(deptrFromHandle_Slice_error(handle))
}
//export Slice_error_elem
func Slice_error_elem(handle CGoHandle, _idx int) *C.char {
s := deptrFromHandle_Slice_error(handle)
return errorGoToPy(s[_idx])
}
//export Slice_error_subslice
func Slice_error_subslice(handle CGoHandle, _st, _ed int) CGoHandle {
s := deptrFromHandle_Slice_error(handle)
ss := s[_st:_ed]
return CGoHandle(handleFromPtr_Slice_error(&ss))
}
//export Slice_error_set
func Slice_error_set(handle CGoHandle, _idx int, _vl *C.char) {
s := deptrFromHandle_Slice_error(handle)
s[_idx] = errors.New(C.GoString(_vl))
}
//export Slice_error_append
func Slice_error_append(handle CGoHandle, _vl *C.char) {
s := ptrFromHandle_Slice_error(handle)
*s = append(*s, errors.New(C.GoString(_vl)))
}
// Converters for implicit pointer handles for type: []float32
func ptrFromHandle_Slice_float32(h CGoHandle) *[]float32 {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]float32")
if p == nil {
return nil
}
return p.(*[]float32)
}
func deptrFromHandle_Slice_float32(h CGoHandle) []float32 {
p := ptrFromHandle_Slice_float32(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_Slice_float32(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("[]float32", p))
}
// --- wrapping slice: []float32 ---
//
//export Slice_float32_CTor
func Slice_float32_CTor() CGoHandle {
return CGoHandle(handleFromPtr_Slice_float32(&[]float32{}))
}
//export Slice_float32_len
func Slice_float32_len(handle CGoHandle) int {
return len(deptrFromHandle_Slice_float32(handle))
}
//export Slice_float32_elem
func Slice_float32_elem(handle CGoHandle, _idx int) C.float {
s := deptrFromHandle_Slice_float32(handle)
return C.float(s[_idx])
}
//export Slice_float32_subslice
func Slice_float32_subslice(handle CGoHandle, _st, _ed int) CGoHandle {
s := deptrFromHandle_Slice_float32(handle)
ss := s[_st:_ed]
return CGoHandle(handleFromPtr_Slice_float32(&ss))
}
//export Slice_float32_set
func Slice_float32_set(handle CGoHandle, _idx int, _vl C.float) {
s := deptrFromHandle_Slice_float32(handle)
s[_idx] = float32(_vl)
}
//export Slice_float32_append
func Slice_float32_append(handle CGoHandle, _vl C.float) {
s := ptrFromHandle_Slice_float32(handle)
*s = append(*s, float32(_vl))
}
// Converters for implicit pointer handles for type: []float64
func ptrFromHandle_Slice_float64(h CGoHandle) *[]float64 {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]float64")
if p == nil {
return nil
}
return p.(*[]float64)
}
func deptrFromHandle_Slice_float64(h CGoHandle) []float64 {
p := ptrFromHandle_Slice_float64(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_Slice_float64(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("[]float64", p))
}
// --- wrapping slice: []float64 ---
//
//export Slice_float64_CTor
func Slice_float64_CTor() CGoHandle {
return CGoHandle(handleFromPtr_Slice_float64(&[]float64{}))
}
//export Slice_float64_len
func Slice_float64_len(handle CGoHandle) int {
return len(deptrFromHandle_Slice_float64(handle))
}
//export Slice_float64_elem
func Slice_float64_elem(handle CGoHandle, _idx int) C.double {
s := deptrFromHandle_Slice_float64(handle)
return C.double(s[_idx])
}
//export Slice_float64_subslice
func Slice_float64_subslice(handle CGoHandle, _st, _ed int) CGoHandle {
s := deptrFromHandle_Slice_float64(handle)
ss := s[_st:_ed]
return CGoHandle(handleFromPtr_Slice_float64(&ss))
}
//export Slice_float64_set
func Slice_float64_set(handle CGoHandle, _idx int, _vl C.double) {
s := deptrFromHandle_Slice_float64(handle)
s[_idx] = float64(_vl)
}
//export Slice_float64_append
func Slice_float64_append(handle CGoHandle, _vl C.double) {
s := ptrFromHandle_Slice_float64(handle)
*s = append(*s, float64(_vl))
}
// Converters for implicit pointer handles for type: []int
func ptrFromHandle_Slice_int(h CGoHandle) *[]int {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]int")
if p == nil {
return nil
}
return p.(*[]int)
}
func deptrFromHandle_Slice_int(h CGoHandle) []int {
p := ptrFromHandle_Slice_int(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_Slice_int(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("[]int", p))
}
// --- wrapping slice: []int ---
//
//export Slice_int_CTor
func Slice_int_CTor() CGoHandle {
return CGoHandle(handleFromPtr_Slice_int(&[]int{}))
}
//export Slice_int_len
func Slice_int_len(handle CGoHandle) int {
return len(deptrFromHandle_Slice_int(handle))
}
//export Slice_int_elem
func Slice_int_elem(handle CGoHandle, _idx int) C.longlong {
s := deptrFromHandle_Slice_int(handle)
return C.longlong(s[_idx])
}
//export Slice_int_subslice
func Slice_int_subslice(handle CGoHandle, _st, _ed int) CGoHandle {
s := deptrFromHandle_Slice_int(handle)
ss := s[_st:_ed]
return CGoHandle(handleFromPtr_Slice_int(&ss))
}
//export Slice_int_set
func Slice_int_set(handle CGoHandle, _idx int, _vl C.longlong) {
s := deptrFromHandle_Slice_int(handle)
s[_idx] = int(_vl)
}
//export Slice_int_append
func Slice_int_append(handle CGoHandle, _vl C.longlong) {
s := ptrFromHandle_Slice_int(handle)
*s = append(*s, int(_vl))
}
// Converters for implicit pointer handles for type: []int16
func ptrFromHandle_Slice_int16(h CGoHandle) *[]int16 {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]int16")
if p == nil {
return nil
}
return p.(*[]int16)
}
func deptrFromHandle_Slice_int16(h CGoHandle) []int16 {
p := ptrFromHandle_Slice_int16(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_Slice_int16(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("[]int16", p))
}
// --- wrapping slice: []int16 ---
//
//export Slice_int16_CTor
func Slice_int16_CTor() CGoHandle {
return CGoHandle(handleFromPtr_Slice_int16(&[]int16{}))
}
//export Slice_int16_len
func Slice_int16_len(handle CGoHandle) int {
return len(deptrFromHandle_Slice_int16(handle))
}
//export Slice_int16_elem
func Slice_int16_elem(handle CGoHandle, _idx int) C.short {
s := deptrFromHandle_Slice_int16(handle)
return C.short(s[_idx])
}
//export Slice_int16_subslice
func Slice_int16_subslice(handle CGoHandle, _st, _ed int) CGoHandle {
s := deptrFromHandle_Slice_int16(handle)
ss := s[_st:_ed]
return CGoHandle(handleFromPtr_Slice_int16(&ss))
}
//export Slice_int16_set
func Slice_int16_set(handle CGoHandle, _idx int, _vl C.short) {
s := deptrFromHandle_Slice_int16(handle)
s[_idx] = int16(_vl)
}
//export Slice_int16_append
func Slice_int16_append(handle CGoHandle, _vl C.short) {
s := ptrFromHandle_Slice_int16(handle)
*s = append(*s, int16(_vl))
}
// Converters for implicit pointer handles for type: []int32
func ptrFromHandle_Slice_int32(h CGoHandle) *[]int32 {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]int32")
if p == nil {
return nil
}
return p.(*[]int32)
}
func deptrFromHandle_Slice_int32(h CGoHandle) []int32 {
p := ptrFromHandle_Slice_int32(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_Slice_int32(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("[]int32", p))
}
// --- wrapping slice: []int32 ---
//
//export Slice_int32_CTor
func Slice_int32_CTor() CGoHandle {
return CGoHandle(handleFromPtr_Slice_int32(&[]int32{}))
}
//export Slice_int32_len
func Slice_int32_len(handle CGoHandle) int {
return len(deptrFromHandle_Slice_int32(handle))
}
//export Slice_int32_elem
func Slice_int32_elem(handle CGoHandle, _idx int) C.long {
s := deptrFromHandle_Slice_int32(handle)
return C.long(s[_idx])
}
//export Slice_int32_subslice
func Slice_int32_subslice(handle CGoHandle, _st, _ed int) CGoHandle {
s := deptrFromHandle_Slice_int32(handle)
ss := s[_st:_ed]
return CGoHandle(handleFromPtr_Slice_int32(&ss))
}
//export Slice_int32_set
func Slice_int32_set(handle CGoHandle, _idx int, _vl C.long) {
s := deptrFromHandle_Slice_int32(handle)
s[_idx] = int32(_vl)
}
//export Slice_int32_append
func Slice_int32_append(handle CGoHandle, _vl C.long) {
s := ptrFromHandle_Slice_int32(handle)
*s = append(*s, int32(_vl))
}
// Converters for implicit pointer handles for type: []int64
func ptrFromHandle_Slice_int64(h CGoHandle) *[]int64 {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]int64")
if p == nil {
return nil
}
return p.(*[]int64)
}
func deptrFromHandle_Slice_int64(h CGoHandle) []int64 {
p := ptrFromHandle_Slice_int64(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_Slice_int64(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("[]int64", p))
}
// --- wrapping slice: []int64 ---
//
//export Slice_int64_CTor
func Slice_int64_CTor() CGoHandle {
return CGoHandle(handleFromPtr_Slice_int64(&[]int64{}))
}
//export Slice_int64_len
func Slice_int64_len(handle CGoHandle) int {
return len(deptrFromHandle_Slice_int64(handle))
}
//export Slice_int64_elem
func Slice_int64_elem(handle CGoHandle, _idx int) C.longlong {
s := deptrFromHandle_Slice_int64(handle)
return C.longlong(s[_idx])
}
//export Slice_int64_subslice
func Slice_int64_subslice(handle CGoHandle, _st, _ed int) CGoHandle {
s := deptrFromHandle_Slice_int64(handle)
ss := s[_st:_ed]
return CGoHandle(handleFromPtr_Slice_int64(&ss))
}
//export Slice_int64_set
func Slice_int64_set(handle CGoHandle, _idx int, _vl C.longlong) {
s := deptrFromHandle_Slice_int64(handle)
s[_idx] = int64(_vl)
}
//export Slice_int64_append
func Slice_int64_append(handle CGoHandle, _vl C.longlong) {
s := ptrFromHandle_Slice_int64(handle)
*s = append(*s, int64(_vl))
}
// Converters for implicit pointer handles for type: []int8
func ptrFromHandle_Slice_int8(h CGoHandle) *[]int8 {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]int8")
if p == nil {
return nil
}
return p.(*[]int8)
}
func deptrFromHandle_Slice_int8(h CGoHandle) []int8 {
p := ptrFromHandle_Slice_int8(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_Slice_int8(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("[]int8", p))
}
// --- wrapping slice: []int8 ---
//
//export Slice_int8_CTor
func Slice_int8_CTor() CGoHandle {
return CGoHandle(handleFromPtr_Slice_int8(&[]int8{}))
}
//export Slice_int8_len
func Slice_int8_len(handle CGoHandle) int {
return len(deptrFromHandle_Slice_int8(handle))
}
//export Slice_int8_elem
func Slice_int8_elem(handle CGoHandle, _idx int) C.char {
s := deptrFromHandle_Slice_int8(handle)
return C.char(s[_idx])
}
//export Slice_int8_subslice
func Slice_int8_subslice(handle CGoHandle, _st, _ed int) CGoHandle {
s := deptrFromHandle_Slice_int8(handle)
ss := s[_st:_ed]
return CGoHandle(handleFromPtr_Slice_int8(&ss))
}
//export Slice_int8_set
func Slice_int8_set(handle CGoHandle, _idx int, _vl C.char) {
s := deptrFromHandle_Slice_int8(handle)
s[_idx] = int8(_vl)
}
//export Slice_int8_append
func Slice_int8_append(handle CGoHandle, _vl C.char) {
s := ptrFromHandle_Slice_int8(handle)
*s = append(*s, int8(_vl))
}
// Converters for implicit pointer handles for type: []rune
func ptrFromHandle_Slice_rune(h CGoHandle) *[]rune {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]rune")
if p == nil {
return nil
}
return p.(*[]rune)
}
func deptrFromHandle_Slice_rune(h CGoHandle) []rune {
p := ptrFromHandle_Slice_rune(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_Slice_rune(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("[]rune", p))
}
// --- wrapping slice: []rune ---
//
//export Slice_rune_CTor
func Slice_rune_CTor() CGoHandle {
return CGoHandle(handleFromPtr_Slice_rune(&[]rune{}))
}
//export Slice_rune_len
func Slice_rune_len(handle CGoHandle) int {
return len(deptrFromHandle_Slice_rune(handle))
}
//export Slice_rune_elem
func Slice_rune_elem(handle CGoHandle, _idx int) C.long {
s := deptrFromHandle_Slice_rune(handle)
return C.long(s[_idx])
}
//export Slice_rune_subslice
func Slice_rune_subslice(handle CGoHandle, _st, _ed int) CGoHandle {
s := deptrFromHandle_Slice_rune(handle)
ss := s[_st:_ed]
return CGoHandle(handleFromPtr_Slice_rune(&ss))
}
//export Slice_rune_set
func Slice_rune_set(handle CGoHandle, _idx int, _vl C.long) {
s := deptrFromHandle_Slice_rune(handle)
s[_idx] = rune(_vl)
}
//export Slice_rune_append
func Slice_rune_append(handle CGoHandle, _vl C.long) {
s := ptrFromHandle_Slice_rune(handle)
*s = append(*s, rune(_vl))
}
// Converters for implicit pointer handles for type: []string
func ptrFromHandle_Slice_string(h CGoHandle) *[]string {
p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]string")
if p == nil {
return nil
}
return p.(*[]string)
}
func deptrFromHandle_Slice_string(h CGoHandle) []string {
p := ptrFromHandle_Slice_string(h)
if p == nil {
return nil
}
return *p
}
func handleFromPtr_Slice_string(p interface{}) CGoHandle {
return CGoHandle(gopyh.Register("[]string", p))
}
// --- wrapping slice: []string ---
//
//export Slice_string_CTor
func Slice_string_CTor() CGoHandle {
return CGoHandle(handleFromPtr_Slice_string(&[]string{}))
}
//export Slice_string_len
func Slice_string_len(handle CGoHandle) int {