@auto_js/napi 0.0.8 → 0.0.10
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/CMakeLists.txt +1 -1
- package/README.md +8 -8
- package/_module.cc +3 -2
- package/api/finalizer.cc +1 -1
- package/api/threadsafe_function.cc +3 -6
- package/api/uv_scheduler.h.cc +1 -1
- package/handle/local.cc +112 -0
- package/handle/reference.cc +3 -3
- package/handle/remote.cc +10 -10
- package/handle/types.cc +9 -142
- package/handle/value.cc +122 -30
- package/package.json +4 -4
- package/support/callback.cc +12 -12
- package/support/callback_storage.cc +2 -2
- package/support/class_template_storage.cc +3 -3
- package/support/host.cc +41 -37
- package/support/host.h.cc +11 -11
- package/support/initialize.h.cc +3 -3
- package/support/promise.cc +2 -2
- package/support/string_table.cc +1 -1
- package/transfer/accept.cc +34 -34
- package/transfer/accept.h.cc +91 -75
- package/transfer/visit.cc +121 -78
- package/value/array.cc +5 -7
- package/value/array.h.cc +7 -7
- package/value/array_buffer.cc +26 -29
- package/value/array_buffer.h.cc +50 -52
- package/value/class.cc +9 -10
- package/value/class.h.cc +5 -5
- package/value/external.cc +9 -11
- package/value/function.cc +7 -7
- package/value/function.h.cc +2 -2
- package/value/object.cc +5 -8
- package/value/object.h.cc +8 -15
- package/value/primitive.cc +7 -10
- package/value/primitive.h.cc +15 -15
- package/value/record.cc +6 -8
- package/value/record.h.cc +8 -8
- package/value/value.cc +3 -1
- package/handle/bound_value.cc +0 -47
package/value/record.cc
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
module napi_js;
|
|
2
|
-
import :api;
|
|
3
|
-
import :array;
|
|
4
2
|
import std;
|
|
5
3
|
|
|
6
4
|
namespace js::napi {
|
|
7
5
|
|
|
8
|
-
auto
|
|
6
|
+
auto value_for_record::into_range() const -> range_type {
|
|
9
7
|
return keys() | std::views::transform(iterator_transform{*this});
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
auto
|
|
10
|
+
auto value_for_record::size() const -> std::size_t {
|
|
13
11
|
return keys().size();
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
auto
|
|
14
|
+
auto value_for_record::keys() const -> const keys_type& {
|
|
17
15
|
if (napi_value{keys_} == nullptr) {
|
|
18
16
|
auto* property_names = napi::invoke(
|
|
19
17
|
napi_get_all_property_names,
|
|
@@ -23,15 +21,15 @@ auto bound_value_for_record::keys() const -> const keys_type& {
|
|
|
23
21
|
static_cast<napi_key_filter>(napi_key_enumerable | napi_key_skip_symbols),
|
|
24
22
|
napi_key_keep_numbers
|
|
25
23
|
);
|
|
26
|
-
keys_ = keys_type{env(), js::napi::
|
|
24
|
+
keys_ = keys_type{env(), js::napi::local_of<vector_tag>::from(property_names)};
|
|
27
25
|
}
|
|
28
26
|
return keys_;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
value_for_record::iterator_transform::iterator_transform(const value_for_record& subject) :
|
|
32
30
|
subject_{&subject} {}
|
|
33
31
|
|
|
34
|
-
auto
|
|
32
|
+
auto value_for_record::iterator_transform::operator()(local_of<value_tag> key) const -> value_type {
|
|
35
33
|
return std::pair{key_type::from(key), subject_->get(key)};
|
|
36
34
|
}
|
|
37
35
|
|
package/value/record.h.cc
CHANGED
|
@@ -5,22 +5,22 @@ import std;
|
|
|
5
5
|
|
|
6
6
|
namespace js::napi {
|
|
7
7
|
|
|
8
|
-
class
|
|
8
|
+
class value_for_record : public value_next<record_tag> {
|
|
9
9
|
public:
|
|
10
|
-
using
|
|
11
|
-
using keys_type =
|
|
12
|
-
using key_type =
|
|
13
|
-
using mapped_type =
|
|
10
|
+
using value_next<record_tag>::value_next;
|
|
11
|
+
using keys_type = value_of<vector_tag>;
|
|
12
|
+
using key_type = local_of<primitive_tag>;
|
|
13
|
+
using mapped_type = local_of<value_tag>;
|
|
14
14
|
using value_type = std::pair<key_type, mapped_type>;
|
|
15
15
|
|
|
16
16
|
private:
|
|
17
17
|
class iterator_transform {
|
|
18
18
|
public:
|
|
19
|
-
explicit iterator_transform(const
|
|
20
|
-
auto operator()(
|
|
19
|
+
explicit iterator_transform(const value_for_record& subject_);
|
|
20
|
+
auto operator()(local_of<value_tag> key) const -> value_type;
|
|
21
21
|
|
|
22
22
|
private:
|
|
23
|
-
const
|
|
23
|
+
const value_for_record* subject_;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
public:
|
package/value/value.cc
CHANGED
|
@@ -4,7 +4,9 @@ export import :array;
|
|
|
4
4
|
export import :class_;
|
|
5
5
|
export import :external;
|
|
6
6
|
export import :function;
|
|
7
|
+
export import :handle.local_of;
|
|
8
|
+
export import :handle.types;
|
|
9
|
+
export import :handle.value_of;
|
|
7
10
|
export import :object;
|
|
8
11
|
export import :primitive;
|
|
9
12
|
export import :record;
|
|
10
|
-
export import :value_handle;
|
package/handle/bound_value.cc
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export module napi_js:bound_value;
|
|
2
|
-
import :handle.types;
|
|
3
|
-
import nodejs;
|
|
4
|
-
|
|
5
|
-
namespace js::napi {
|
|
6
|
-
|
|
7
|
-
// Details applied to each level of the `bound_value<T>` hierarchy.
|
|
8
|
-
template <class Tag>
|
|
9
|
-
class bound_value_next : public bound_value<typename Tag::tag_type> {
|
|
10
|
-
public:
|
|
11
|
-
using tag_type = Tag;
|
|
12
|
-
using bound_value<typename Tag::tag_type>::bound_value;
|
|
13
|
-
bound_value_next() = default;
|
|
14
|
-
bound_value_next(napi_env env, value_of<Tag> value) :
|
|
15
|
-
bound_value<typename Tag::tag_type>{env, napi_value{value}} {}
|
|
16
|
-
|
|
17
|
-
// NOLINTNEXTLINE(google-explicit-constructor)
|
|
18
|
-
operator value_of<Tag>() const { return value_of<Tag>::from(napi_value{*this}); }
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// Member & method implementation for stateful objects. Used internally in visitors. I think it
|
|
22
|
-
// might make sense to have the environment specified by a template parameter. Then you would use
|
|
23
|
-
// `bound_value<T>` or something instead of passing the environment to each `value_of<T>` method.
|
|
24
|
-
template <class Tag>
|
|
25
|
-
class bound_value : public value_specialization<Tag>::bound_type {
|
|
26
|
-
public:
|
|
27
|
-
using value_specialization<Tag>::bound_type::bound_type;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
template <class Tag>
|
|
31
|
-
bound_value(auto, value_of<Tag>) -> bound_value<Tag>;
|
|
32
|
-
|
|
33
|
-
template <>
|
|
34
|
-
class bound_value<void> : public value_handle {
|
|
35
|
-
protected:
|
|
36
|
-
bound_value() = default;
|
|
37
|
-
bound_value(napi_env env, napi_value value) :
|
|
38
|
-
value_handle{value},
|
|
39
|
-
env_{env} {}
|
|
40
|
-
|
|
41
|
-
[[nodiscard]] auto env() const -> napi_env { return env_; }
|
|
42
|
-
|
|
43
|
-
private:
|
|
44
|
-
napi_env env_{};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
} // namespace js::napi
|