xot 0.3.5 → 0.3.7
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 +4 -4
- data/ChangeLog.md +10 -0
- data/VERSION +1 -1
- data/ext/xot/tester.cpp +0 -6
- data/include/xot/string.h +17 -0
- data/include/xot/util.h +7 -7
- data/lib/xot/rake/util.rb +4 -0
- data/lib/xot/rake.rb +3 -5
- data/lib/xot/test.rb +8 -0
- data/src/string.cpp +50 -1
- data/src/util.cpp +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cc5ed60541fa3ee86c6eec2210bd614ce1c57f61962021f22a779cae98e22b3
|
4
|
+
data.tar.gz: f1857f64a4750a53f7ae890c3c5b668f02e5cfe7a4095611a97184281d2e5da3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cda7e24a4978142f25ac13d0c96bb81d85b97fbeffea50fb9bed676f377a4daa47cfe9a2abd1c8f3035622feb45d30137f16cecf5b3fc191a705e23901d87dd2
|
7
|
+
data.tar.gz: e7a9e2ae5345700370276cba16b11c1ff4fc3f48c6f409037227330758c7de6bff67c7eeba6aa6c2c76150a6da8690252a4875d2a08e8a75e88f3c38fc678a66
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# xot ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.3.7] - 2025-05-11
|
5
|
+
|
6
|
+
- Delete Xot::clip(), and use std::clamp()
|
7
|
+
|
8
|
+
|
9
|
+
## [v0.3.6] - 2025-04-08
|
10
|
+
|
11
|
+
- Move cfrelease() and CFStringPtr from rays to xot
|
12
|
+
|
13
|
+
|
4
14
|
## [v0.3.5] - 2025-03-24
|
5
15
|
|
6
16
|
- Add PULL_REQUEST_TEMPLATE.md
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.7
|
data/ext/xot/tester.cpp
CHANGED
@@ -90,12 +90,6 @@ test_util ()
|
|
90
90
|
if (Xot::bit(2) != 0x4) return false;
|
91
91
|
if (Xot::bit(3) != 0x8) return false;
|
92
92
|
|
93
|
-
if (!(Xot::clip(10, 100, 50) == 50)) return false;
|
94
|
-
if (!(Xot::clip(10, 100, 10) == 10)) return false;
|
95
|
-
if (!(Xot::clip(10, 100, 100) == 100)) return false;
|
96
|
-
if (!(Xot::clip(10, 100, 0) == 10)) return false;
|
97
|
-
if (!(Xot::clip(10, 100, 200) == 100)) return false;
|
98
|
-
|
99
93
|
static const int F0 = Xot::bit(0), F1 = Xot::bit(1), F2 = Xot::bit(2);
|
100
94
|
|
101
95
|
int flags = 0;
|
data/include/xot/string.h
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
#include <stdarg.h>
|
8
|
+
#include <memory>
|
8
9
|
#include <string>
|
9
10
|
#include <vector>
|
10
11
|
|
@@ -24,6 +25,11 @@
|
|
24
25
|
while (false)
|
25
26
|
|
26
27
|
|
28
|
+
#if defined(OSX) || defined(IOS)
|
29
|
+
struct __CFString;
|
30
|
+
#endif
|
31
|
+
|
32
|
+
|
27
33
|
namespace Xot
|
28
34
|
{
|
29
35
|
|
@@ -39,6 +45,8 @@ namespace Xot
|
|
39
45
|
|
40
46
|
String (const char* str);
|
41
47
|
|
48
|
+
String (const std::string& str);
|
49
|
+
|
42
50
|
template <typename ITERATOR>
|
43
51
|
String (ITERATOR begin, ITERATOR end) : Super(begin, end) {}
|
44
52
|
|
@@ -71,6 +79,15 @@ namespace Xot
|
|
71
79
|
template <typename T> String to_s (const T& val);
|
72
80
|
|
73
81
|
|
82
|
+
#if defined(OSX) || defined(IOS)
|
83
|
+
|
84
|
+
typedef std::shared_ptr<const __CFString> CFStringPtr;
|
85
|
+
|
86
|
+
CFStringPtr cfstring (const char* str);
|
87
|
+
|
88
|
+
#endif
|
89
|
+
|
90
|
+
|
74
91
|
}// Xot
|
75
92
|
|
76
93
|
|
data/include/xot/util.h
CHANGED
@@ -34,13 +34,6 @@ namespace Xot
|
|
34
34
|
return (T) (base << nth);
|
35
35
|
}
|
36
36
|
|
37
|
-
template <typename T>
|
38
|
-
inline constexpr T
|
39
|
-
clip (T minval, T maxval, T value)
|
40
|
-
{
|
41
|
-
return value > maxval ? maxval : (value < minval ? minval : value);
|
42
|
-
}
|
43
|
-
|
44
37
|
|
45
38
|
inline constexpr double
|
46
39
|
deg2rad (double degree)
|
@@ -131,6 +124,13 @@ namespace Xot
|
|
131
124
|
}
|
132
125
|
|
133
126
|
|
127
|
+
#if defined(OSX) || defined(IOS)
|
128
|
+
|
129
|
+
void safe_cfrelease (const void* ref);
|
130
|
+
|
131
|
+
#endif
|
132
|
+
|
133
|
+
|
134
134
|
}// Xot
|
135
135
|
|
136
136
|
|
data/lib/xot/rake/util.rb
CHANGED
data/lib/xot/rake.rb
CHANGED
@@ -39,10 +39,6 @@ module Xot
|
|
39
39
|
Hash[*src_exts.map {|ext| [".#{ext}", to]}.flatten]
|
40
40
|
end
|
41
41
|
|
42
|
-
def defs()
|
43
|
-
env_array :DEFS, []
|
44
|
-
end
|
45
|
-
|
46
42
|
def test_alones()
|
47
43
|
env :TESTS_ALONE, []
|
48
44
|
end
|
@@ -288,7 +284,7 @@ module Xot
|
|
288
284
|
|
289
285
|
def use_external_library(
|
290
286
|
repos, branch: nil, tag: nil, commit: nil,
|
291
|
-
incdirs: nil, srcdirs: nil, excludes: [],
|
287
|
+
incdirs: nil, srcdirs: nil, defs: [], excludes: [],
|
292
288
|
submodules: [], post_submodules: nil,
|
293
289
|
&after_clone_block)
|
294
290
|
|
@@ -296,10 +292,12 @@ module Xot
|
|
296
292
|
dir = "#{vendor_dir}/#{name}"
|
297
293
|
incdirs = [incdirs].flatten.map {|s| s ? "#{dir}/#{s}" : dir}
|
298
294
|
srcdirs = [srcdirs].flatten.map {|s| s ? "#{dir}/#{s}" : dir}
|
295
|
+
defs = [defs].flatten
|
299
296
|
excludes = [excludes].flatten
|
300
297
|
|
301
298
|
append_env 'INCDIRS', incdirs
|
302
299
|
append_env 'SRCDIRS', srcdirs
|
300
|
+
append_env 'DEFS', defs
|
303
301
|
append_env 'EXCLUDES', excludes unless excludes.empty?
|
304
302
|
|
305
303
|
alias_task :vendor => "vendor:#{name}"
|
data/lib/xot/test.rb
CHANGED
@@ -17,11 +17,19 @@ module Xot
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def assert_each_in_epsilon(expected, actual, *args)
|
20
|
+
assert_equal expected.size, actual.size
|
20
21
|
expected.zip(actual) do |e, a|
|
21
22
|
assert_in_epsilon e, a, *args
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
26
|
+
def assert_each_in_delta(expected, actual, *args)
|
27
|
+
assert_equal expected.size, actual.size
|
28
|
+
expected.zip(actual) do |e, a|
|
29
|
+
assert_in_delta e, a, *args
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
25
33
|
end# Test
|
26
34
|
|
27
35
|
|
data/src/string.cpp
CHANGED
@@ -4,9 +4,12 @@
|
|
4
4
|
#include <stdio.h>
|
5
5
|
#include <string.h>
|
6
6
|
#include <algorithm>
|
7
|
-
#include <memory>
|
8
7
|
#include "xot/exception.h"
|
9
8
|
|
9
|
+
#if defined(OSX) || defined(IOS)
|
10
|
+
#import <CoreFoundation/CoreFoundation.h>
|
11
|
+
#endif
|
12
|
+
|
10
13
|
|
11
14
|
namespace Xot
|
12
15
|
{
|
@@ -21,6 +24,11 @@ namespace Xot
|
|
21
24
|
{
|
22
25
|
}
|
23
26
|
|
27
|
+
String::String (const std::string& str)
|
28
|
+
: Super(str)
|
29
|
+
{
|
30
|
+
}
|
31
|
+
|
24
32
|
String
|
25
33
|
String::upcase () const
|
26
34
|
{
|
@@ -167,5 +175,46 @@ namespace Xot
|
|
167
175
|
return val;
|
168
176
|
}
|
169
177
|
|
178
|
+
#if defined(OSX) || defined(IOS)
|
179
|
+
|
180
|
+
template <> String
|
181
|
+
to_s<CFStringRef> (const CFStringRef& val)
|
182
|
+
{
|
183
|
+
if (!val || CFGetTypeID(val) != CFStringGetTypeID())
|
184
|
+
return String();
|
185
|
+
|
186
|
+
CFIndex len = CFStringGetMaximumSizeForEncoding(
|
187
|
+
CFStringGetLength(val), kCFStringEncodingUTF8) + 1;
|
188
|
+
|
189
|
+
std::unique_ptr<char[]> buffer(new char[len]);
|
190
|
+
if (!CFStringGetCString(val, buffer.get(), len, kCFStringEncodingUTF8))
|
191
|
+
system_error(__FILE__, __LINE__);
|
192
|
+
|
193
|
+
return buffer.get();
|
194
|
+
}
|
195
|
+
|
196
|
+
template <> String
|
197
|
+
to_s<CFStringPtr> (const CFStringPtr& val)
|
198
|
+
{
|
199
|
+
return to_s((CFStringRef) val.get());
|
200
|
+
}
|
201
|
+
|
202
|
+
|
203
|
+
static void
|
204
|
+
release_cfstring (CFTypeRef ref)
|
205
|
+
{
|
206
|
+
if (ref) CFRelease(ref);
|
207
|
+
}
|
208
|
+
|
209
|
+
CFStringPtr
|
210
|
+
cfstring (const char* str)
|
211
|
+
{
|
212
|
+
CFStringRef ref = CFStringCreateWithCString(
|
213
|
+
kCFAllocatorDefault, str, kCFStringEncodingUTF8);
|
214
|
+
return CFStringPtr(ref, release_cfstring);
|
215
|
+
}
|
216
|
+
|
217
|
+
#endif
|
218
|
+
|
170
219
|
|
171
220
|
}// Xot
|
data/src/util.cpp
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
|
4
4
|
#include <stdlib.h>
|
5
5
|
|
6
|
+
#if defined(OSX) || defined(IOS)
|
7
|
+
#import <CoreFoundation/CFBase.h>
|
8
|
+
#endif
|
9
|
+
|
6
10
|
|
7
11
|
namespace Xot
|
8
12
|
{
|
@@ -49,4 +53,15 @@ namespace Xot
|
|
49
53
|
}
|
50
54
|
|
51
55
|
|
56
|
+
#if defined(OSX) || defined(IOS)
|
57
|
+
|
58
|
+
void
|
59
|
+
safe_cfrelease (const void* ref)
|
60
|
+
{
|
61
|
+
if (ref) CFRelease(ref);
|
62
|
+
}
|
63
|
+
|
64
|
+
#endif
|
65
|
+
|
66
|
+
|
52
67
|
}// Xot
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This library include some useful utility classes and functions for development
|
14
14
|
with C++.
|