xot 0.3.5 → 0.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb32bfca53b907bc70eda1e106532a0122abb189b0ff74fe150213bfc4b54e27
4
- data.tar.gz: 5ab847804b982c1f5ab647237a87bd4665e2fbf5713d9b072b88aa409f8b9896
3
+ metadata.gz: b2990bbdfda0d6d33a86bbc3a17541ed0bab27d49fbcaaf28c5f4df12992f280
4
+ data.tar.gz: bfe965639a4592d05a39d73a467328a7c2d3188b85da9e999867ae796484d047
5
5
  SHA512:
6
- metadata.gz: d1e9dab3c783e57d0c2623955a575a8f1f097ae00246695275b11407d2ee7c338f23785eac5f371179d259765bd177a36e005ca96d680c7e5f2a1e0d4692bfe6
7
- data.tar.gz: 03f3adb2c666002145f1d3874221721dc23d04e93431574b163387fda9ccaa13430b292dd554af7d9f239577852297e2e7327f7edd7627ba100041006d338db1
6
+ metadata.gz: b63394e1a1cc9b8bfa1b6c4832ce059b668d023a7e18be341dd9cfb1af9c33d5cbe715651bb3904247de9d5fd4c0ad7f719b43f8a82550800ecc7ad36efa7c1c
7
+ data.tar.gz: 8869fdafed934a52a321204b3874ad9bedac0279b8d8ec5ce3efd605cd72999b1fa51b4ad7858ff00ca2e928f9012f8a36cc708880b743b37065560daedbfc85
data/ChangeLog.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # xot ChangeLog
2
2
 
3
3
 
4
+ ## [v0.3.6] - 2025-04-08
5
+
6
+ - Move cfrelease() and CFStringPtr from rays to xot
7
+
8
+
4
9
  ## [v0.3.5] - 2025-03-24
5
10
 
6
11
  - Add PULL_REQUEST_TEMPLATE.md
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.5
1
+ 0.3.6
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
 
@@ -71,6 +77,15 @@ namespace Xot
71
77
  template <typename T> String to_s (const T& val);
72
78
 
73
79
 
80
+ #if defined(OSX) || defined(IOS)
81
+
82
+ typedef std::shared_ptr<const __CFString> CFStringPtr;
83
+
84
+ CFStringPtr cfstring (const char* str);
85
+
86
+ #endif
87
+
88
+
74
89
  }// Xot
75
90
 
76
91
 
data/include/xot/util.h CHANGED
@@ -131,6 +131,13 @@ namespace Xot
131
131
  }
132
132
 
133
133
 
134
+ #if defined(OSX) || defined(IOS)
135
+
136
+ void safe_cfrelease (const void* ref);
137
+
138
+ #endif
139
+
140
+
134
141
  }// Xot
135
142
 
136
143
 
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
  {
@@ -167,5 +170,46 @@ namespace Xot
167
170
  return val;
168
171
  }
169
172
 
173
+ #if defined(OSX) || defined(IOS)
174
+
175
+ template <> String
176
+ to_s<CFStringRef> (const CFStringRef& val)
177
+ {
178
+ if (!val || CFGetTypeID(val) != CFStringGetTypeID())
179
+ return String();
180
+
181
+ CFIndex len = CFStringGetMaximumSizeForEncoding(
182
+ CFStringGetLength(val), kCFStringEncodingUTF8) + 1;
183
+
184
+ std::unique_ptr<char[]> buffer(new char[len]);
185
+ if (!CFStringGetCString(val, buffer.get(), len, kCFStringEncodingUTF8))
186
+ system_error(__FILE__, __LINE__);
187
+
188
+ return buffer.get();
189
+ }
190
+
191
+ template <> String
192
+ to_s<CFStringPtr> (const CFStringPtr& val)
193
+ {
194
+ return to_s((CFStringRef) val.get());
195
+ }
196
+
197
+
198
+ static void
199
+ release_cfstring (CFTypeRef ref)
200
+ {
201
+ if (ref) CFRelease(ref);
202
+ }
203
+
204
+ CFStringPtr
205
+ cfstring (const char* str)
206
+ {
207
+ CFStringRef ref = CFStringCreateWithCString(
208
+ kCFAllocatorDefault, str, kCFStringEncodingUTF8);
209
+ return CFStringPtr(ref, release_cfstring);
210
+ }
211
+
212
+ #endif
213
+
170
214
 
171
215
  }// 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.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-23 00:00:00.000000000 Z
11
+ date: 2025-04-08 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++.