bubblezone 0.1.0-aarch64-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +370 -0
- data/bubblezone.gemspec +39 -0
- data/ext/bubblezone/extconf.rb +65 -0
- data/ext/bubblezone/extension.c +107 -0
- data/ext/bubblezone/extension.h +36 -0
- data/ext/bubblezone/manager.c +127 -0
- data/ext/bubblezone/zone_info.c +100 -0
- data/go/bubblezone.go +369 -0
- data/go/build/linux_arm64/libbubblezone.a +0 -0
- data/go/build/linux_arm64/libbubblezone.h +114 -0
- data/go/go.mod +28 -0
- data/go/go.sum +47 -0
- data/lib/bubblezone/3.2/bubblezone.so +0 -0
- data/lib/bubblezone/3.3/bubblezone.so +0 -0
- data/lib/bubblezone/3.4/bubblezone.so +0 -0
- data/lib/bubblezone/4.0/bubblezone.so +0 -0
- data/lib/bubblezone/manager.rb +56 -0
- data/lib/bubblezone/version.rb +5 -0
- data/lib/bubblezone/zone_info.rb +25 -0
- data/lib/bubblezone.rb +59 -0
- metadata +84 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#include "extension.h"
|
|
2
|
+
|
|
3
|
+
static void manager_free(void *pointer) {
|
|
4
|
+
bubblezone_manager_t *manager = (bubblezone_manager_t *)pointer;
|
|
5
|
+
|
|
6
|
+
if (manager->handle != 0) {
|
|
7
|
+
bubblezone_free_manager(manager->handle);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
xfree(manager);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static size_t manager_memsize(const void *pointer) {
|
|
14
|
+
return sizeof(bubblezone_manager_t);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const rb_data_type_t manager_type = {
|
|
18
|
+
.wrap_struct_name = "Bubblezone::Manager",
|
|
19
|
+
.function = {
|
|
20
|
+
.dmark = NULL,
|
|
21
|
+
.dfree = manager_free,
|
|
22
|
+
.dsize = manager_memsize,
|
|
23
|
+
},
|
|
24
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
static VALUE manager_alloc(VALUE klass) {
|
|
28
|
+
bubblezone_manager_t *manager = ALLOC(bubblezone_manager_t);
|
|
29
|
+
manager->handle = bubblezone_new_manager();
|
|
30
|
+
return TypedData_Wrap_Struct(klass, &manager_type, manager);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
VALUE manager_wrap(VALUE klass, unsigned long long handle) {
|
|
34
|
+
bubblezone_manager_t *manager = ALLOC(bubblezone_manager_t);
|
|
35
|
+
manager->handle = handle;
|
|
36
|
+
return TypedData_Wrap_Struct(klass, &manager_type, manager);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static VALUE manager_initialize(VALUE self) {
|
|
40
|
+
return self;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static VALUE manager_close(VALUE self) {
|
|
44
|
+
GET_MANAGER(self, manager);
|
|
45
|
+
bubblezone_manager_close(manager->handle);
|
|
46
|
+
return Qnil;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static VALUE manager_set_enabled(VALUE self, VALUE enabled) {
|
|
50
|
+
GET_MANAGER(self, manager);
|
|
51
|
+
bubblezone_manager_set_enabled(manager->handle, RTEST(enabled) ? 1 : 0);
|
|
52
|
+
return enabled;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static VALUE manager_enabled(VALUE self) {
|
|
56
|
+
GET_MANAGER(self, manager);
|
|
57
|
+
return bubblezone_manager_enabled(manager->handle) ? Qtrue : Qfalse;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static VALUE manager_new_prefix(VALUE self) {
|
|
61
|
+
GET_MANAGER(self, manager);
|
|
62
|
+
|
|
63
|
+
char *prefix = bubblezone_manager_new_prefix(manager->handle);
|
|
64
|
+
VALUE rb_prefix = rb_utf8_str_new_cstr(prefix);
|
|
65
|
+
bubblezone_free(prefix);
|
|
66
|
+
|
|
67
|
+
return rb_prefix;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static VALUE manager_mark(VALUE self, VALUE zone_id, VALUE text) {
|
|
71
|
+
GET_MANAGER(self, manager);
|
|
72
|
+
Check_Type(zone_id, T_STRING);
|
|
73
|
+
Check_Type(text, T_STRING);
|
|
74
|
+
|
|
75
|
+
char *result = bubblezone_manager_mark(manager->handle, StringValueCStr(zone_id), StringValueCStr(text));
|
|
76
|
+
VALUE rb_result = rb_utf8_str_new_cstr(result);
|
|
77
|
+
bubblezone_free(result);
|
|
78
|
+
|
|
79
|
+
return rb_result;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static VALUE manager_clear(VALUE self, VALUE zone_id) {
|
|
83
|
+
GET_MANAGER(self, manager);
|
|
84
|
+
Check_Type(zone_id, T_STRING);
|
|
85
|
+
bubblezone_manager_clear(manager->handle, StringValueCStr(zone_id));
|
|
86
|
+
return Qnil;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static VALUE manager_get(VALUE self, VALUE zone_id) {
|
|
90
|
+
GET_MANAGER(self, manager);
|
|
91
|
+
Check_Type(zone_id, T_STRING);
|
|
92
|
+
|
|
93
|
+
unsigned long long handle = bubblezone_manager_get(manager->handle, StringValueCStr(zone_id));
|
|
94
|
+
|
|
95
|
+
if (handle == 0) {
|
|
96
|
+
return Qnil;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return zone_info_wrap(cZoneInfo, handle);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static VALUE manager_scan(VALUE self, VALUE text) {
|
|
103
|
+
GET_MANAGER(self, manager);
|
|
104
|
+
Check_Type(text, T_STRING);
|
|
105
|
+
|
|
106
|
+
char *result = bubblezone_manager_scan(manager->handle, StringValueCStr(text));
|
|
107
|
+
VALUE rb_result = rb_utf8_str_new_cstr(result);
|
|
108
|
+
bubblezone_free(result);
|
|
109
|
+
|
|
110
|
+
return rb_result;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
void Init_bubblezone_manager(void) {
|
|
114
|
+
cManager = rb_define_class_under(mBubblezone, "Manager", rb_cObject);
|
|
115
|
+
|
|
116
|
+
rb_define_alloc_func(cManager, manager_alloc);
|
|
117
|
+
|
|
118
|
+
rb_define_method(cManager, "initialize", manager_initialize, 0);
|
|
119
|
+
rb_define_method(cManager, "close", manager_close, 0);
|
|
120
|
+
rb_define_method(cManager, "enabled=", manager_set_enabled, 1);
|
|
121
|
+
rb_define_method(cManager, "enabled?", manager_enabled, 0);
|
|
122
|
+
rb_define_method(cManager, "new_prefix", manager_new_prefix, 0);
|
|
123
|
+
rb_define_method(cManager, "mark", manager_mark, 2);
|
|
124
|
+
rb_define_method(cManager, "clear", manager_clear, 1);
|
|
125
|
+
rb_define_method(cManager, "get", manager_get, 1);
|
|
126
|
+
rb_define_method(cManager, "scan", manager_scan, 1);
|
|
127
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#include "extension.h"
|
|
2
|
+
|
|
3
|
+
static void zone_info_free(void *pointer) {
|
|
4
|
+
bubblezone_zone_info_t *zone_info = (bubblezone_zone_info_t *)pointer;
|
|
5
|
+
|
|
6
|
+
if (zone_info->handle != 0) {
|
|
7
|
+
bubblezone_free_zone_info(zone_info->handle);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
xfree(zone_info);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static size_t zone_info_memsize(const void *pointer) {
|
|
14
|
+
return sizeof(bubblezone_zone_info_t);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const rb_data_type_t zone_info_type = {
|
|
18
|
+
.wrap_struct_name = "Bubblezone::ZoneInfo",
|
|
19
|
+
.function = {
|
|
20
|
+
.dmark = NULL,
|
|
21
|
+
.dfree = zone_info_free,
|
|
22
|
+
.dsize = zone_info_memsize,
|
|
23
|
+
},
|
|
24
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
VALUE zone_info_wrap(VALUE klass, unsigned long long handle) {
|
|
29
|
+
bubblezone_zone_info_t *zone_info = ALLOC(bubblezone_zone_info_t);
|
|
30
|
+
zone_info->handle = handle;
|
|
31
|
+
return TypedData_Wrap_Struct(klass, &zone_info_type, zone_info);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static VALUE zone_info_start_x(VALUE self) {
|
|
35
|
+
GET_ZONE_INFO(self, zone_info);
|
|
36
|
+
return INT2NUM(bubblezone_zone_info_start_x(zone_info->handle));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static VALUE zone_info_start_y(VALUE self) {
|
|
40
|
+
GET_ZONE_INFO(self, zone_info);
|
|
41
|
+
return INT2NUM(bubblezone_zone_info_start_y(zone_info->handle));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static VALUE zone_info_end_x(VALUE self) {
|
|
45
|
+
GET_ZONE_INFO(self, zone_info);
|
|
46
|
+
return INT2NUM(bubblezone_zone_info_end_x(zone_info->handle));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static VALUE zone_info_end_y(VALUE self) {
|
|
50
|
+
GET_ZONE_INFO(self, zone_info);
|
|
51
|
+
return INT2NUM(bubblezone_zone_info_end_y(zone_info->handle));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static VALUE zone_info_is_zero(VALUE self) {
|
|
55
|
+
GET_ZONE_INFO(self, zone_info);
|
|
56
|
+
return bubblezone_zone_info_is_zero(zone_info->handle) ? Qtrue : Qfalse;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static VALUE zone_info_in_bounds(VALUE self, VALUE x, VALUE y) {
|
|
60
|
+
GET_ZONE_INFO(self, zone_info);
|
|
61
|
+
Check_Type(x, T_FIXNUM);
|
|
62
|
+
Check_Type(y, T_FIXNUM);
|
|
63
|
+
|
|
64
|
+
return bubblezone_zone_info_in_bounds(zone_info->handle, NUM2INT(x), NUM2INT(y)) ? Qtrue : Qfalse;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static VALUE zone_info_pos(VALUE self, VALUE x, VALUE y) {
|
|
68
|
+
GET_ZONE_INFO(self, zone_info);
|
|
69
|
+
Check_Type(x, T_FIXNUM);
|
|
70
|
+
Check_Type(y, T_FIXNUM);
|
|
71
|
+
|
|
72
|
+
int out_x, out_y;
|
|
73
|
+
int success = bubblezone_zone_info_pos(zone_info->handle, NUM2INT(x), NUM2INT(y), &out_x, &out_y);
|
|
74
|
+
|
|
75
|
+
if (!success) {
|
|
76
|
+
return rb_ary_new_from_args(2, INT2NUM(-1), INT2NUM(-1));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return rb_ary_new_from_args(2, INT2NUM(out_x), INT2NUM(out_y));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static VALUE zone_info_alloc_error(VALUE klass) {
|
|
83
|
+
rb_raise(rb_eTypeError, "allocator undefined for Bubblezone::ZoneInfo - use Manager#get instead");
|
|
84
|
+
return Qnil;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void Init_bubblezone_zone_info(void) {
|
|
88
|
+
cZoneInfo = rb_define_class_under(mBubblezone, "ZoneInfo", rb_cObject);
|
|
89
|
+
|
|
90
|
+
rb_define_alloc_func(cZoneInfo, zone_info_alloc_error);
|
|
91
|
+
rb_undef_method(rb_singleton_class(cZoneInfo), "new");
|
|
92
|
+
|
|
93
|
+
rb_define_method(cZoneInfo, "start_x", zone_info_start_x, 0);
|
|
94
|
+
rb_define_method(cZoneInfo, "start_y", zone_info_start_y, 0);
|
|
95
|
+
rb_define_method(cZoneInfo, "end_x", zone_info_end_x, 0);
|
|
96
|
+
rb_define_method(cZoneInfo, "end_y", zone_info_end_y, 0);
|
|
97
|
+
rb_define_method(cZoneInfo, "zero?", zone_info_is_zero, 0);
|
|
98
|
+
rb_define_method(cZoneInfo, "in_bounds?", zone_info_in_bounds, 2);
|
|
99
|
+
rb_define_method(cZoneInfo, "pos", zone_info_pos, 2);
|
|
100
|
+
}
|
data/go/bubblezone.go
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
*/
|
|
6
|
+
import "C"
|
|
7
|
+
|
|
8
|
+
import (
|
|
9
|
+
"runtime/debug"
|
|
10
|
+
"sync"
|
|
11
|
+
"unsafe"
|
|
12
|
+
zone "github.com/lrstanley/bubblezone"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
var (
|
|
16
|
+
nextID uint64 = 1
|
|
17
|
+
nextIDMu sync.Mutex
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
func getNextID() uint64 {
|
|
21
|
+
nextIDMu.Lock()
|
|
22
|
+
defer nextIDMu.Unlock()
|
|
23
|
+
id := nextID
|
|
24
|
+
nextID++
|
|
25
|
+
return id
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var (
|
|
29
|
+
managers = make(map[uint64]*zone.Manager)
|
|
30
|
+
managersMu sync.RWMutex
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
func allocManager(m *zone.Manager) uint64 {
|
|
34
|
+
managersMu.Lock()
|
|
35
|
+
defer managersMu.Unlock()
|
|
36
|
+
id := getNextID()
|
|
37
|
+
managers[id] = m
|
|
38
|
+
return id
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
func getManager(id uint64) *zone.Manager {
|
|
42
|
+
managersMu.RLock()
|
|
43
|
+
defer managersMu.RUnlock()
|
|
44
|
+
return managers[id]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var (
|
|
48
|
+
zoneInfos = make(map[uint64]*zone.ZoneInfo)
|
|
49
|
+
zoneInfosMu sync.RWMutex
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
func allocZoneInfo(z *zone.ZoneInfo) uint64 {
|
|
53
|
+
if z == nil {
|
|
54
|
+
return 0
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
zoneInfosMu.Lock()
|
|
58
|
+
defer zoneInfosMu.Unlock()
|
|
59
|
+
id := getNextID()
|
|
60
|
+
zoneInfos[id] = z
|
|
61
|
+
|
|
62
|
+
return id
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
func getZoneInfo(id uint64) *zone.ZoneInfo {
|
|
66
|
+
zoneInfosMu.RLock()
|
|
67
|
+
defer zoneInfosMu.RUnlock()
|
|
68
|
+
return zoneInfos[id]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//export bubblezone_free
|
|
72
|
+
func bubblezone_free(pointer *C.char) {
|
|
73
|
+
C.free(unsafe.Pointer(pointer))
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//export bubblezone_upstream_version
|
|
77
|
+
func bubblezone_upstream_version() *C.char {
|
|
78
|
+
info, ok := debug.ReadBuildInfo()
|
|
79
|
+
if !ok {
|
|
80
|
+
return C.CString("unknown")
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
for _, dep := range info.Deps {
|
|
84
|
+
if dep.Path == "github.com/lrstanley/bubblezone" {
|
|
85
|
+
return C.CString(dep.Version)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return C.CString("unknown")
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//export bubblezone_new_manager
|
|
93
|
+
func bubblezone_new_manager() C.ulonglong {
|
|
94
|
+
m := zone.New()
|
|
95
|
+
return C.ulonglong(allocManager(m))
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
//export bubblezone_free_manager
|
|
99
|
+
func bubblezone_free_manager(id C.ulonglong) {
|
|
100
|
+
managersMu.Lock()
|
|
101
|
+
|
|
102
|
+
defer managersMu.Unlock()
|
|
103
|
+
|
|
104
|
+
if m, ok := managers[uint64(id)]; ok {
|
|
105
|
+
m.Close()
|
|
106
|
+
delete(managers, uint64(id))
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//export bubblezone_manager_close
|
|
111
|
+
func bubblezone_manager_close(id C.ulonglong) {
|
|
112
|
+
m := getManager(uint64(id))
|
|
113
|
+
|
|
114
|
+
if m != nil {
|
|
115
|
+
m.Close()
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//export bubblezone_manager_set_enabled
|
|
120
|
+
func bubblezone_manager_set_enabled(id C.ulonglong, enabled C.int) {
|
|
121
|
+
m := getManager(uint64(id))
|
|
122
|
+
|
|
123
|
+
if m != nil {
|
|
124
|
+
m.SetEnabled(enabled != 0)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//export bubblezone_manager_enabled
|
|
129
|
+
func bubblezone_manager_enabled(id C.ulonglong) C.int {
|
|
130
|
+
m := getManager(uint64(id))
|
|
131
|
+
|
|
132
|
+
if m != nil && m.Enabled() {
|
|
133
|
+
return 1
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return 0
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
//export bubblezone_manager_new_prefix
|
|
140
|
+
func bubblezone_manager_new_prefix(id C.ulonglong) *C.char {
|
|
141
|
+
m := getManager(uint64(id))
|
|
142
|
+
|
|
143
|
+
if m == nil {
|
|
144
|
+
return C.CString("")
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return C.CString(m.NewPrefix())
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
//export bubblezone_manager_mark
|
|
151
|
+
func bubblezone_manager_mark(id C.ulonglong, zoneID *C.char, text *C.char) *C.char {
|
|
152
|
+
m := getManager(uint64(id))
|
|
153
|
+
|
|
154
|
+
if m == nil {
|
|
155
|
+
return C.CString(C.GoString(text))
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
result := m.Mark(C.GoString(zoneID), C.GoString(text))
|
|
159
|
+
|
|
160
|
+
return C.CString(result)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
//export bubblezone_manager_clear
|
|
164
|
+
func bubblezone_manager_clear(id C.ulonglong, zoneID *C.char) {
|
|
165
|
+
m := getManager(uint64(id))
|
|
166
|
+
|
|
167
|
+
if m != nil {
|
|
168
|
+
m.Clear(C.GoString(zoneID))
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
//export bubblezone_manager_get
|
|
173
|
+
func bubblezone_manager_get(id C.ulonglong, zoneID *C.char) C.ulonglong {
|
|
174
|
+
m := getManager(uint64(id))
|
|
175
|
+
|
|
176
|
+
if m == nil {
|
|
177
|
+
return 0
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
z := m.Get(C.GoString(zoneID))
|
|
181
|
+
|
|
182
|
+
return C.ulonglong(allocZoneInfo(z))
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
//export bubblezone_manager_scan
|
|
186
|
+
func bubblezone_manager_scan(id C.ulonglong, text *C.char) *C.char {
|
|
187
|
+
m := getManager(uint64(id))
|
|
188
|
+
|
|
189
|
+
if m == nil {
|
|
190
|
+
return C.CString(C.GoString(text))
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
result := m.Scan(C.GoString(text))
|
|
194
|
+
|
|
195
|
+
return C.CString(result)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
//export bubblezone_free_zone_info
|
|
199
|
+
func bubblezone_free_zone_info(id C.ulonglong) {
|
|
200
|
+
zoneInfosMu.Lock()
|
|
201
|
+
defer zoneInfosMu.Unlock()
|
|
202
|
+
delete(zoneInfos, uint64(id))
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
//export bubblezone_zone_info_start_x
|
|
206
|
+
func bubblezone_zone_info_start_x(id C.ulonglong) C.int {
|
|
207
|
+
z := getZoneInfo(uint64(id))
|
|
208
|
+
|
|
209
|
+
if z == nil {
|
|
210
|
+
return 0
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return C.int(z.StartX)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
//export bubblezone_zone_info_start_y
|
|
217
|
+
func bubblezone_zone_info_start_y(id C.ulonglong) C.int {
|
|
218
|
+
z := getZoneInfo(uint64(id))
|
|
219
|
+
|
|
220
|
+
if z == nil {
|
|
221
|
+
return 0
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return C.int(z.StartY)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
//export bubblezone_zone_info_end_x
|
|
228
|
+
func bubblezone_zone_info_end_x(id C.ulonglong) C.int {
|
|
229
|
+
z := getZoneInfo(uint64(id))
|
|
230
|
+
|
|
231
|
+
if z == nil {
|
|
232
|
+
return 0
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return C.int(z.EndX)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
//export bubblezone_zone_info_end_y
|
|
239
|
+
func bubblezone_zone_info_end_y(id C.ulonglong) C.int {
|
|
240
|
+
z := getZoneInfo(uint64(id))
|
|
241
|
+
|
|
242
|
+
if z == nil {
|
|
243
|
+
return 0
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return C.int(z.EndY)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
//export bubblezone_zone_info_is_zero
|
|
250
|
+
func bubblezone_zone_info_is_zero(id C.ulonglong) C.int {
|
|
251
|
+
z := getZoneInfo(uint64(id))
|
|
252
|
+
|
|
253
|
+
if z == nil || z.IsZero() {
|
|
254
|
+
return 1
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return 0
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
//export bubblezone_zone_info_in_bounds
|
|
261
|
+
func bubblezone_zone_info_in_bounds(id C.ulonglong, x C.int, y C.int) C.int {
|
|
262
|
+
z := getZoneInfo(uint64(id))
|
|
263
|
+
|
|
264
|
+
if z == nil {
|
|
265
|
+
return 0
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if z.IsZero() {
|
|
269
|
+
return 0
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if z.StartX > z.EndX || z.StartY > z.EndY {
|
|
273
|
+
return 0
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if int(x) < z.StartX || int(y) < z.StartY {
|
|
277
|
+
return 0
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if int(x) > z.EndX || int(y) > z.EndY {
|
|
281
|
+
return 0
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return 1
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
//export bubblezone_zone_info_pos
|
|
288
|
+
func bubblezone_zone_info_pos(id C.ulonglong, x C.int, y C.int, outX *C.int, outY *C.int) C.int {
|
|
289
|
+
z := getZoneInfo(uint64(id))
|
|
290
|
+
|
|
291
|
+
if z == nil {
|
|
292
|
+
*outX = -1
|
|
293
|
+
*outY = -1
|
|
294
|
+
return 0
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if z.IsZero() {
|
|
298
|
+
*outX = -1
|
|
299
|
+
*outY = -1
|
|
300
|
+
return 0
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
inBounds := bubblezone_zone_info_in_bounds(id, x, y)
|
|
304
|
+
|
|
305
|
+
if inBounds == 0 {
|
|
306
|
+
*outX = -1
|
|
307
|
+
*outY = -1
|
|
308
|
+
return 0
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
*outX = C.int(int(x) - z.StartX)
|
|
312
|
+
*outY = C.int(int(y) - z.StartY)
|
|
313
|
+
|
|
314
|
+
return 1
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
//export bubblezone_new_global
|
|
318
|
+
func bubblezone_new_global() {
|
|
319
|
+
zone.NewGlobal()
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
//export bubblezone_global_close
|
|
323
|
+
func bubblezone_global_close() {
|
|
324
|
+
zone.Close()
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
//export bubblezone_global_set_enabled
|
|
328
|
+
func bubblezone_global_set_enabled(enabled C.int) {
|
|
329
|
+
zone.SetEnabled(enabled != 0)
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
//export bubblezone_global_enabled
|
|
333
|
+
func bubblezone_global_enabled() C.int {
|
|
334
|
+
if zone.Enabled() {
|
|
335
|
+
return 1
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return 0
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
//export bubblezone_global_new_prefix
|
|
342
|
+
func bubblezone_global_new_prefix() *C.char {
|
|
343
|
+
return C.CString(zone.NewPrefix())
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
//export bubblezone_global_mark
|
|
347
|
+
func bubblezone_global_mark(zoneID *C.char, text *C.char) *C.char {
|
|
348
|
+
result := zone.Mark(C.GoString(zoneID), C.GoString(text))
|
|
349
|
+
return C.CString(result)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
//export bubblezone_global_clear
|
|
353
|
+
func bubblezone_global_clear(zoneID *C.char) {
|
|
354
|
+
zone.Clear(C.GoString(zoneID))
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
//export bubblezone_global_get
|
|
358
|
+
func bubblezone_global_get(zoneID *C.char) C.ulonglong {
|
|
359
|
+
z := zone.Get(C.GoString(zoneID))
|
|
360
|
+
return C.ulonglong(allocZoneInfo(z))
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
//export bubblezone_global_scan
|
|
364
|
+
func bubblezone_global_scan(text *C.char) *C.char {
|
|
365
|
+
result := zone.Scan(C.GoString(text))
|
|
366
|
+
return C.CString(result)
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
func main() {}
|
|
Binary file
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/* Code generated by cmd/cgo; DO NOT EDIT. */
|
|
2
|
+
|
|
3
|
+
/* package github.com/marcoroth/bubblezone-ruby/go */
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
#line 1 "cgo-builtin-export-prolog"
|
|
7
|
+
|
|
8
|
+
#include <stddef.h>
|
|
9
|
+
|
|
10
|
+
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
|
11
|
+
#define GO_CGO_EXPORT_PROLOGUE_H
|
|
12
|
+
|
|
13
|
+
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
14
|
+
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
/* Start of preamble from import "C" comments. */
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
#line 3 "bubblezone.go"
|
|
23
|
+
|
|
24
|
+
#include <stdlib.h>
|
|
25
|
+
|
|
26
|
+
#line 1 "cgo-generated-wrapper"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/* End of preamble from import "C" comments. */
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/* Start of boilerplate cgo prologue. */
|
|
33
|
+
#line 1 "cgo-gcc-export-header-prolog"
|
|
34
|
+
|
|
35
|
+
#ifndef GO_CGO_PROLOGUE_H
|
|
36
|
+
#define GO_CGO_PROLOGUE_H
|
|
37
|
+
|
|
38
|
+
typedef signed char GoInt8;
|
|
39
|
+
typedef unsigned char GoUint8;
|
|
40
|
+
typedef short GoInt16;
|
|
41
|
+
typedef unsigned short GoUint16;
|
|
42
|
+
typedef int GoInt32;
|
|
43
|
+
typedef unsigned int GoUint32;
|
|
44
|
+
typedef long long GoInt64;
|
|
45
|
+
typedef unsigned long long GoUint64;
|
|
46
|
+
typedef GoInt64 GoInt;
|
|
47
|
+
typedef GoUint64 GoUint;
|
|
48
|
+
typedef size_t GoUintptr;
|
|
49
|
+
typedef float GoFloat32;
|
|
50
|
+
typedef double GoFloat64;
|
|
51
|
+
#ifdef _MSC_VER
|
|
52
|
+
#include <complex.h>
|
|
53
|
+
typedef _Fcomplex GoComplex64;
|
|
54
|
+
typedef _Dcomplex GoComplex128;
|
|
55
|
+
#else
|
|
56
|
+
typedef float _Complex GoComplex64;
|
|
57
|
+
typedef double _Complex GoComplex128;
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
/*
|
|
61
|
+
static assertion to make sure the file is being used on architecture
|
|
62
|
+
at least with matching size of GoInt.
|
|
63
|
+
*/
|
|
64
|
+
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
|
65
|
+
|
|
66
|
+
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
67
|
+
typedef _GoString_ GoString;
|
|
68
|
+
#endif
|
|
69
|
+
typedef void *GoMap;
|
|
70
|
+
typedef void *GoChan;
|
|
71
|
+
typedef struct { void *t; void *v; } GoInterface;
|
|
72
|
+
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
|
73
|
+
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
/* End of boilerplate cgo prologue. */
|
|
77
|
+
|
|
78
|
+
#ifdef __cplusplus
|
|
79
|
+
extern "C" {
|
|
80
|
+
#endif
|
|
81
|
+
|
|
82
|
+
extern void bubblezone_free(char* pointer);
|
|
83
|
+
extern char* bubblezone_upstream_version();
|
|
84
|
+
extern long long unsigned int bubblezone_new_manager();
|
|
85
|
+
extern void bubblezone_free_manager(long long unsigned int id);
|
|
86
|
+
extern void bubblezone_manager_close(long long unsigned int id);
|
|
87
|
+
extern void bubblezone_manager_set_enabled(long long unsigned int id, int enabled);
|
|
88
|
+
extern int bubblezone_manager_enabled(long long unsigned int id);
|
|
89
|
+
extern char* bubblezone_manager_new_prefix(long long unsigned int id);
|
|
90
|
+
extern char* bubblezone_manager_mark(long long unsigned int id, char* zoneID, char* text);
|
|
91
|
+
extern void bubblezone_manager_clear(long long unsigned int id, char* zoneID);
|
|
92
|
+
extern long long unsigned int bubblezone_manager_get(long long unsigned int id, char* zoneID);
|
|
93
|
+
extern char* bubblezone_manager_scan(long long unsigned int id, char* text);
|
|
94
|
+
extern void bubblezone_free_zone_info(long long unsigned int id);
|
|
95
|
+
extern int bubblezone_zone_info_start_x(long long unsigned int id);
|
|
96
|
+
extern int bubblezone_zone_info_start_y(long long unsigned int id);
|
|
97
|
+
extern int bubblezone_zone_info_end_x(long long unsigned int id);
|
|
98
|
+
extern int bubblezone_zone_info_end_y(long long unsigned int id);
|
|
99
|
+
extern int bubblezone_zone_info_is_zero(long long unsigned int id);
|
|
100
|
+
extern int bubblezone_zone_info_in_bounds(long long unsigned int id, int x, int y);
|
|
101
|
+
extern int bubblezone_zone_info_pos(long long unsigned int id, int x, int y, int* outX, int* outY);
|
|
102
|
+
extern void bubblezone_new_global();
|
|
103
|
+
extern void bubblezone_global_close();
|
|
104
|
+
extern void bubblezone_global_set_enabled(int enabled);
|
|
105
|
+
extern int bubblezone_global_enabled();
|
|
106
|
+
extern char* bubblezone_global_new_prefix();
|
|
107
|
+
extern char* bubblezone_global_mark(char* zoneID, char* text);
|
|
108
|
+
extern void bubblezone_global_clear(char* zoneID);
|
|
109
|
+
extern long long unsigned int bubblezone_global_get(char* zoneID);
|
|
110
|
+
extern char* bubblezone_global_scan(char* text);
|
|
111
|
+
|
|
112
|
+
#ifdef __cplusplus
|
|
113
|
+
}
|
|
114
|
+
#endif
|