@crossbind/core-embind-jsi 2.0.0-beta.58 → 2.0.0-beta.60

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @crossbind/core-embind-jsi
2
2
 
3
+ ## 2.0.0-beta.60
4
+
5
+ ### Patch Changes
6
+
7
+ - Supplied the `std::char_traits<unsigned char>` that embind's raw-byte string binding needs. The
8
+ standard has never defined one, and libc++ used to instantiate the primary template anyway; from
9
+ the release NDK r30 ships it static_asserts instead, so naming
10
+ `std::basic_string<unsigned char>` stopped compiling at all. The binding is unchanged, and the
11
+ traits cost nothing on the toolchains that did not need them.
12
+
3
13
  ## 2.0.0-beta.53
4
14
 
5
15
  ### Patch Changes
@@ -27,6 +27,56 @@
27
27
 
28
28
  #include <jsi/jsi.h>
29
29
 
30
+ // embind registers std::basic_string<unsigned char> as the raw-byte counterpart to UTF-8
31
+ // std::string, but the standard has never defined std::char_traits for unsigned char. libc++ used
32
+ // to instantiate the primary template anyway; from the release NDK r30 ships it static_asserts
33
+ // instead, so merely naming the type stops compiling. Supplying the traits keeps the binding and
34
+ // costs nothing on the toolchains that did not need it.
35
+ namespace std {
36
+ template <>
37
+ struct char_traits<unsigned char> {
38
+ using char_type = unsigned char;
39
+ using int_type = int;
40
+ using off_type = streamoff;
41
+ using pos_type = streampos;
42
+ using state_type = mbstate_t;
43
+
44
+ static constexpr void assign(char_type& a, const char_type& b) noexcept { a = b; }
45
+ static constexpr bool eq(char_type a, char_type b) noexcept { return a == b; }
46
+ static constexpr bool lt(char_type a, char_type b) noexcept { return a < b; }
47
+
48
+ static int compare(const char_type* a, const char_type* b, size_t n) {
49
+ return n == 0 ? 0 : __builtin_memcmp(a, b, n);
50
+ }
51
+ static size_t length(const char_type* s) {
52
+ size_t n = 0;
53
+ while (s[n]) ++n;
54
+ return n;
55
+ }
56
+ static const char_type* find(const char_type* s, size_t n, const char_type& c) {
57
+ for (size_t i = 0; i < n; ++i)
58
+ if (s[i] == c) return s + i;
59
+ return nullptr;
60
+ }
61
+ static char_type* move(char_type* d, const char_type* s, size_t n) {
62
+ return n == 0 ? d : static_cast<char_type*>(__builtin_memmove(d, s, n));
63
+ }
64
+ static char_type* copy(char_type* d, const char_type* s, size_t n) {
65
+ return n == 0 ? d : static_cast<char_type*>(__builtin_memcpy(d, s, n));
66
+ }
67
+ static char_type* assign(char_type* d, size_t n, char_type c) {
68
+ for (size_t i = 0; i < n; ++i) d[i] = c;
69
+ return d;
70
+ }
71
+
72
+ static constexpr int_type not_eof(int_type c) noexcept { return eq_int_type(c, eof()) ? ~eof() : c; }
73
+ static constexpr char_type to_char_type(int_type c) noexcept { return char_type(c); }
74
+ static constexpr int_type to_int_type(char_type c) noexcept { return int_type(c); }
75
+ static constexpr bool eq_int_type(int_type a, int_type b) noexcept { return a == b; }
76
+ static constexpr int_type eof() noexcept { return int_type(EOF); }
77
+ };
78
+ } // namespace std
79
+
30
80
  // #include <android/log.h>
31
81
  // #define APPNAME "react-native-crossbind"
32
82
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossbind/core-embind-jsi",
3
- "version": "2.0.0-beta.58",
3
+ "version": "2.0.0-beta.60",
4
4
  "description": "The Embind JSI integration tool enables seamless C++ integration with React Native and Expo.",
5
5
  "homepage": "https://github.com/crossbind/crossbind/tree/main/core/embind-jsi#readme",
6
6
  "repository": {