xot 0.3.15 → 0.4.0
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/.github/workflows/release-gem.yml +10 -1
- data/.github/workflows/test.yml +9 -0
- data/ChangeLog.md +8 -0
- data/VERSION +1 -1
- data/include/xot/defs.h +1 -1
- data/include/xot/string.h +24 -10
- data/include/xot/windows.h +5 -1
- data/lib/xot/extension.rb +1 -1
- data/lib/xot/util.rb +9 -0
- data/src/string.cpp +60 -16
- data/test/test_util.rb +33 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7e347867590b9d9d97a002320ac500f075dde62556b0944b2a35705b415e2806
|
|
4
|
+
data.tar.gz: c684375fa42a755e7cef817aad1c658fd26f484b515876cb35323e56e1c313bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d94d2378ba6835df631dd21ef26140f3cc43af8c370478d7b7c6ce0e6e433fd08deafa45810970995942e3f1a1f04f4343894aa9ce5c5a276c60f442f1faf0de
|
|
7
|
+
data.tar.gz: 2dd7f8827dd1804be81babfe7b89410f41a96b280ac57f30724c67b63b3356a2ab71cddb4d10465e4ee49c34450d1e5f961dff24a84931a89a0bbf5f60159cda
|
|
@@ -26,8 +26,17 @@ jobs:
|
|
|
26
26
|
- name: setup dependencies
|
|
27
27
|
run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
|
|
28
28
|
|
|
29
|
+
- name: packages
|
|
30
|
+
run: bundle exec rake packages
|
|
31
|
+
|
|
32
|
+
- name: setup zig
|
|
33
|
+
if: github.event.repository.name == 'reflex-terminal'
|
|
34
|
+
uses: mlugg/setup-zig@v2
|
|
35
|
+
with:
|
|
36
|
+
version: 0.16.0
|
|
37
|
+
|
|
29
38
|
- name: test
|
|
30
|
-
run: bundle exec rake
|
|
39
|
+
run: bundle exec rake test
|
|
31
40
|
|
|
32
41
|
- name: create gem
|
|
33
42
|
id: gem
|
data/.github/workflows/test.yml
CHANGED
|
@@ -27,6 +27,15 @@ jobs:
|
|
|
27
27
|
- name: packages
|
|
28
28
|
run: bundle exec rake verbose packages
|
|
29
29
|
|
|
30
|
+
- name: setup zig
|
|
31
|
+
if: github.event.repository.name == 'reflex-terminal'
|
|
32
|
+
uses: mlugg/setup-zig@v2
|
|
33
|
+
with:
|
|
34
|
+
version: 0.16.0
|
|
35
|
+
|
|
36
|
+
- name: vendor
|
|
37
|
+
run: bundle exec rake vendor
|
|
38
|
+
|
|
30
39
|
- name: lib
|
|
31
40
|
run: bundle exec rake verbose lib
|
|
32
41
|
|
data/ChangeLog.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# xot ChangeLog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [v0.4.0] - 2026-08-04
|
|
5
|
+
|
|
6
|
+
- [BREAKING] Rework String conversions to std::wstring and CFString
|
|
7
|
+
- Add a String constructor taking a pointer and a size
|
|
8
|
+
- Add Xot.warn with a uniq option to suppress duplicate warnings
|
|
9
|
+
- Let a source raise _WIN32_WINNT above the Windows 7 baseline
|
|
10
|
+
|
|
11
|
+
|
|
4
12
|
## [v0.3.15] - 2026-06-23
|
|
5
13
|
|
|
6
14
|
- Add WeakRef for weak references to RefCountable
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.4.0
|
data/include/xot/defs.h
CHANGED
data/include/xot/string.h
CHANGED
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
#if defined(OSX) || defined(IOS)
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
struct __CFString;
|
|
31
|
+
|
|
30
32
|
#endif
|
|
31
33
|
|
|
32
34
|
|
|
@@ -34,6 +36,13 @@ namespace Xot
|
|
|
34
36
|
{
|
|
35
37
|
|
|
36
38
|
|
|
39
|
+
#if defined(OSX) || defined(IOS)
|
|
40
|
+
|
|
41
|
+
typedef std::shared_ptr<const __CFString> CFStringPtr;
|
|
42
|
+
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
|
|
37
46
|
class String : public std::string
|
|
38
47
|
{
|
|
39
48
|
|
|
@@ -45,6 +54,8 @@ namespace Xot
|
|
|
45
54
|
|
|
46
55
|
String (const char* str);
|
|
47
56
|
|
|
57
|
+
String (const char* str, size_t size);
|
|
58
|
+
|
|
48
59
|
String (const std::string& str);
|
|
49
60
|
|
|
50
61
|
template <typename ITERATOR>
|
|
@@ -64,6 +75,18 @@ namespace Xot
|
|
|
64
75
|
|
|
65
76
|
friend String operator + (const char* lhs, const String& rhs);
|
|
66
77
|
|
|
78
|
+
#if defined(OSX) || defined(IOS)
|
|
79
|
+
|
|
80
|
+
CFStringPtr to_cfstr () const;
|
|
81
|
+
|
|
82
|
+
#elif defined(WIN32)
|
|
83
|
+
|
|
84
|
+
String (const wchar_t* str, size_t size);
|
|
85
|
+
|
|
86
|
+
std::wstring to_wstr () const;
|
|
87
|
+
|
|
88
|
+
#endif
|
|
89
|
+
|
|
67
90
|
};// String
|
|
68
91
|
|
|
69
92
|
|
|
@@ -79,15 +102,6 @@ namespace Xot
|
|
|
79
102
|
template <typename T> String to_s (const T& val);
|
|
80
103
|
|
|
81
104
|
|
|
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
|
-
|
|
91
105
|
}// Xot
|
|
92
106
|
|
|
93
107
|
|
data/include/xot/windows.h
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
#ifdef WIN32
|
|
8
8
|
#undef _WIN32_WINNT
|
|
9
|
-
#
|
|
9
|
+
#ifdef XOT_WIN32_WINNT
|
|
10
|
+
#define _WIN32_WINNT XOT_WIN32_WINNT
|
|
11
|
+
#else
|
|
12
|
+
#define _WIN32_WINNT _WIN32_WINNT_WIN7
|
|
13
|
+
#endif
|
|
10
14
|
#include <windows.h>
|
|
11
15
|
#include <windowsx.h>
|
|
12
16
|
#endif
|
data/lib/xot/extension.rb
CHANGED
data/lib/xot/util.rb
CHANGED
|
@@ -6,6 +6,15 @@ module Xot
|
|
|
6
6
|
|
|
7
7
|
extend module Util
|
|
8
8
|
|
|
9
|
+
def warn(message, uniq: false)
|
|
10
|
+
if uniq
|
|
11
|
+
@warnings__ ||= {}
|
|
12
|
+
return if @warnings__[message]
|
|
13
|
+
@warnings__[message] = true
|
|
14
|
+
end
|
|
15
|
+
Kernel.warn message
|
|
16
|
+
end
|
|
17
|
+
|
|
9
18
|
def get_env!(name, defval = nil)
|
|
10
19
|
val = ENV[name.to_s] || Object.const_get(name) rescue defval
|
|
11
20
|
val.dup rescue val
|
data/src/string.cpp
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
#include "xot/string.h"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
#include <limits.h>
|
|
4
5
|
#include <stdio.h>
|
|
5
6
|
#include <string.h>
|
|
6
7
|
#include <algorithm>
|
|
7
8
|
#include "xot/exception.h"
|
|
8
9
|
|
|
9
10
|
#if defined(OSX) || defined(IOS)
|
|
10
|
-
#import <CoreFoundation/CoreFoundation.h>
|
|
11
|
+
#import <CoreFoundation/CoreFoundation.h>
|
|
12
|
+
#elif defined(WIN32)
|
|
13
|
+
#include "xot/windows.h"
|
|
11
14
|
#endif
|
|
12
15
|
|
|
13
16
|
|
|
@@ -24,6 +27,11 @@ namespace Xot
|
|
|
24
27
|
{
|
|
25
28
|
}
|
|
26
29
|
|
|
30
|
+
String::String (const char* str, size_t size)
|
|
31
|
+
: Super(str, size)
|
|
32
|
+
{
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
String::String (const std::string& str)
|
|
28
36
|
: Super(str)
|
|
29
37
|
{
|
|
@@ -88,6 +96,57 @@ namespace Xot
|
|
|
88
96
|
return t;
|
|
89
97
|
}
|
|
90
98
|
|
|
99
|
+
#if defined(OSX) || defined(IOS)
|
|
100
|
+
|
|
101
|
+
static void
|
|
102
|
+
release_cfstring (CFTypeRef ref)
|
|
103
|
+
{
|
|
104
|
+
if (ref) CFRelease(ref);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
CFStringPtr
|
|
108
|
+
String::to_cfstr () const
|
|
109
|
+
{
|
|
110
|
+
return CFStringPtr(
|
|
111
|
+
CFStringCreateWithCString(kCFAllocatorDefault, c_str(), kCFStringEncodingUTF8),
|
|
112
|
+
release_cfstring);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#elif defined(WIN32)
|
|
116
|
+
|
|
117
|
+
String::String (const wchar_t* str, size_t size)
|
|
118
|
+
{
|
|
119
|
+
if (size > INT_MAX)
|
|
120
|
+
argument_error(__FILE__, __LINE__);
|
|
121
|
+
if (!str || size == 0) return;
|
|
122
|
+
|
|
123
|
+
int len = WideCharToMultiByte(CP_UTF8, 0, str, (int) size, NULL, 0, NULL, NULL);
|
|
124
|
+
if (len <= 0) system_error(__FILE__, __LINE__);
|
|
125
|
+
|
|
126
|
+
resize((size_t) len);
|
|
127
|
+
WideCharToMultiByte(CP_UTF8, 0, str, (int) size, &(*this)[0], len, NULL, NULL);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
std::wstring
|
|
131
|
+
String::to_wstr () const
|
|
132
|
+
{
|
|
133
|
+
if (empty()) return std::wstring();
|
|
134
|
+
|
|
135
|
+
size_t size = this->size();
|
|
136
|
+
if (size > INT_MAX)
|
|
137
|
+
invalid_state_error(__FILE__, __LINE__);
|
|
138
|
+
|
|
139
|
+
int len = MultiByteToWideChar(CP_UTF8, 0, data(), (int) size, NULL, 0);
|
|
140
|
+
if (len <= 0) system_error(__FILE__, __LINE__);
|
|
141
|
+
|
|
142
|
+
std::wstring result;
|
|
143
|
+
result.resize((size_t) len);
|
|
144
|
+
MultiByteToWideChar(CP_UTF8, 0, data(), (int) size, &result[0], len);
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
#endif
|
|
149
|
+
|
|
91
150
|
|
|
92
151
|
String
|
|
93
152
|
stringf (const char* format, ...)
|
|
@@ -199,21 +258,6 @@ namespace Xot
|
|
|
199
258
|
return to_s((CFStringRef) val.get());
|
|
200
259
|
}
|
|
201
260
|
|
|
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
261
|
#endif
|
|
218
262
|
|
|
219
263
|
|
data/test/test_util.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require_relative 'helper'
|
|
2
|
+
require 'stringio'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TestUtil < Test::Unit::TestCase
|
|
6
|
+
|
|
7
|
+
def util()
|
|
8
|
+
Object.new.extend Xot::Util
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def capture_stderr(&block)
|
|
12
|
+
stderr, $stderr = $stderr, StringIO.new
|
|
13
|
+
block.call
|
|
14
|
+
$stderr.string
|
|
15
|
+
ensure
|
|
16
|
+
$stderr = stderr
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_warn()
|
|
20
|
+
u = util
|
|
21
|
+
assert_equal "x\nx\n", capture_stderr {u.warn "x"; u.warn "x"}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_warn_uniq()
|
|
25
|
+
u = util
|
|
26
|
+
assert_equal "x\ny\n", capture_stderr {
|
|
27
|
+
u.warn "x", uniq: true
|
|
28
|
+
u.warn "x", uniq: true
|
|
29
|
+
u.warn "y", uniq: true
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end# TestUtil
|
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.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- xordog
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-08-04 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++.
|
|
@@ -81,6 +81,7 @@ files:
|
|
|
81
81
|
- test/test_setter.rb
|
|
82
82
|
- test/test_tester.rb
|
|
83
83
|
- test/test_universal_accessor.rb
|
|
84
|
+
- test/test_util.rb
|
|
84
85
|
- xot.gemspec
|
|
85
86
|
homepage: https://github.com/xord/xot
|
|
86
87
|
licenses:
|
|
@@ -119,3 +120,4 @@ test_files:
|
|
|
119
120
|
- test/test_setter.rb
|
|
120
121
|
- test/test_tester.rb
|
|
121
122
|
- test/test_universal_accessor.rb
|
|
123
|
+
- test/test_util.rb
|