@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/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 bound_value_for_record::into_range() const -> range_type {
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 bound_value_for_record::size() const -> std::size_t {
10
+ auto value_for_record::size() const -> std::size_t {
13
11
  return keys().size();
14
12
  }
15
13
 
16
- auto bound_value_for_record::keys() const -> const keys_type& {
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::value_of<vector_tag>::from(property_names)};
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
- bound_value_for_record::iterator_transform::iterator_transform(const bound_value_for_record& subject) :
29
+ value_for_record::iterator_transform::iterator_transform(const value_for_record& subject) :
32
30
  subject_{&subject} {}
33
31
 
34
- auto bound_value_for_record::iterator_transform::operator()(value_of<value_tag> key) const -> value_type {
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 bound_value_for_record : public bound_value_next<record_tag> {
8
+ class value_for_record : public value_next<record_tag> {
9
9
  public:
10
- using bound_value_next<record_tag>::bound_value_next;
11
- using keys_type = bound_value<vector_tag>;
12
- using key_type = value_of<primitive_tag>;
13
- using mapped_type = value_of<value_tag>;
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 bound_value_for_record& subject_);
20
- auto operator()(value_of<value_tag> key) const -> value_type;
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 bound_value_for_record* subject_;
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;
@@ -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