@auto_js/utility 0.0.5 → 0.0.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.
@@ -88,6 +88,8 @@ class bind_explicit<Invocable, auto(Args...) noexcept(Nx)->Result, Bound...> : p
88
88
 
89
89
  public:
90
90
  using storage_type::storage_type;
91
+ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125779
92
+ using function_signature = auto(Args...) noexcept(Nx) -> Result;
91
93
 
92
94
  // This overload allows `std::invocable<bind<...>>` without a reference, which makes concept
93
95
  // parameters work correctly.
package/memory/memory.cc CHANGED
@@ -2,6 +2,7 @@ export module util:memory;
2
2
  export import :memory.autorelease_pool;
3
3
  export import :memory.comparator;
4
4
  export import :memory.noinit_allocator;
5
+ import :platform.lockable;
5
6
  import std;
6
7
 
7
8
  namespace util {
@@ -57,4 +58,24 @@ auto safe_pointer_upcast(std::unique_ptr<Type, Deleter> unique) {
57
58
  return std::unique_ptr<To, cast_deleter>{std::move(unique)};
58
59
  }
59
60
 
61
+ // `std::atomic<std::shared_ptr<T>>` replacement when not available (macOS)
62
+ #if __cpp_lib_atomic_shared_ptr
63
+
64
+ export template <class Type>
65
+ using atomic_shared_ptr = std::atomic<std::shared_ptr<Type>>;
66
+
67
+ #else
68
+
69
+ export template <class Type>
70
+ class atomic_shared_ptr {
71
+ public:
72
+ auto load(auto /*order*/) const -> std::shared_ptr<Type> { return pointer_.read(); }
73
+ auto store(auto value, auto /*order*/) -> void { *pointer_.write() = std::move(value); }
74
+
75
+ private:
76
+ util::lockable<std::shared_ptr<Type>> pointer_;
77
+ };
78
+
79
+ #endif
80
+
60
81
  } // namespace util
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auto_js/utility",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "author": "https://github.com/laverdet/",
5
5
  "homepage": "https://github.com/laverdet/isolated-vm/tree/experimental/packages/utility",
6
6
  "license": "ISC",
@@ -120,9 +120,19 @@ template <class Function>
120
120
  struct function_signature<Function>
121
121
  : remove_function_cvref<std::remove_pointer_t<std::decay_t<Function>>> {};
122
122
 
123
+ // Explicit function signature for `util::bind`
124
+ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125779
125
+ template <class Type>
126
+ concept has_explicit_function_signature = requires { typename Type::function_signature; };
127
+
128
+ template <has_explicit_function_signature Type>
129
+ struct function_signature<Type> : std::type_identity<typename Type::function_signature> {};
130
+
123
131
  // Struct type with `operator()` (lambda, etc)
124
132
  template <class Type>
125
- requires requires { &std::remove_cvref_t<Type>::operator(); }
133
+ concept has_function_call_operator = requires { &std::remove_cvref_t<Type>::operator(); };
134
+ template <has_function_call_operator Type>
135
+ requires(!has_explicit_function_signature<Type>)
126
136
  struct function_signature<Type>
127
137
  : function_operator_signature<Type, unbound_member_function_signature_t<decltype(&std::remove_cvref_t<Type>::operator())>> {};
128
138