@auto_js/napi 0.0.1
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 +55 -0
- package/LICENSE +13 -0
- package/README.md +255 -0
- package/_module.cc +19 -0
- package/api/api.cc +10 -0
- package/api/callback_info.cc +41 -0
- package/api/finalizer.cc +44 -0
- package/api/handle_scope.cc +23 -0
- package/api/invoke.cc +99 -0
- package/api/uv_handle.cc +113 -0
- package/api/uv_scheduler.cc +56 -0
- package/api/uv_scheduler.h.cc +73 -0
- package/handle/bound_value.cc +49 -0
- package/handle/reference.cc +93 -0
- package/handle/remote.cc +92 -0
- package/handle/types.cc +136 -0
- package/handle/value.cc +52 -0
- package/include/napi_js_initialize.h +7 -0
- package/package.json +16 -0
- package/support/callback.cc +266 -0
- package/support/callback_storage.cc +64 -0
- package/support/class_template_storage.cc +62 -0
- package/support/container.cc +78 -0
- package/support/environment.cc +33 -0
- package/support/environment.h.cc +56 -0
- package/support/environment_fwd.cc +15 -0
- package/support/error_scope.cc +22 -0
- package/support/initialize.cc +25 -0
- package/support/initialize.h.cc +48 -0
- package/support/promise.cc +130 -0
- package/support/string_table.cc +45 -0
- package/support/utility.cc +76 -0
- package/transfer/accept.cc +349 -0
- package/transfer/visit.cc +268 -0
- package/upload/macro.jpg +0 -0
- package/value/array.cc +32 -0
- package/value/array.h.cc +55 -0
- package/value/class.cc +147 -0
- package/value/class.h.cc +32 -0
- package/value/dictionary.cc +33 -0
- package/value/dictionary.h.cc +56 -0
- package/value/external.cc +54 -0
- package/value/function.cc +52 -0
- package/value/function.h.cc +30 -0
- package/value/object.cc +30 -0
- package/value/object.h.cc +59 -0
- package/value/primitive.cc +160 -0
- package/value/primitive.h.cc +101 -0
- package/value/value.cc +10 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module;
|
|
2
|
+
#include <array>
|
|
3
|
+
#include <span>
|
|
4
|
+
#include <tuple>
|
|
5
|
+
#include <variant>
|
|
6
|
+
#include <vector>
|
|
7
|
+
export module napi_js:function_definitions;
|
|
8
|
+
import :api;
|
|
9
|
+
import :callback;
|
|
10
|
+
import :function;
|
|
11
|
+
|
|
12
|
+
namespace js::napi {
|
|
13
|
+
|
|
14
|
+
template <class Result>
|
|
15
|
+
auto value_for_function::apply(auto_environment auto& env, auto&& args) -> Result {
|
|
16
|
+
auto arg_values = js::transfer_in_strict<std::vector<napi_value>>(std::forward<decltype(args)>(args), env);
|
|
17
|
+
return invoke<Result>(env, std::span{arg_values});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
template <class Result>
|
|
21
|
+
auto value_for_function::call(auto_environment auto& env, auto&&... args) -> Result {
|
|
22
|
+
auto arg_values = js::transfer_in_strict<std::array<napi_value, sizeof...(args)>>(std::forward_as_tuple(args...), env);
|
|
23
|
+
return invoke<Result>(env, std::span{arg_values});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
template <class Result>
|
|
27
|
+
auto value_for_function::invoke(auto_environment auto& env, std::span<napi_value> args) -> Result {
|
|
28
|
+
auto undefined = js::transfer_in_strict<napi_value>(std::monostate{}, env);
|
|
29
|
+
auto* result = napi::invoke(napi_call_function, napi_env{env}, undefined, napi_value{*this}, args.size(), args.data());
|
|
30
|
+
return js::transfer_out<Result>(result, env);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
template <auto_environment Environment>
|
|
34
|
+
auto value_for_function::make(Environment& env, auto function) -> value<function_tag> {
|
|
35
|
+
auto [ callback, data ] = make_callback_storage(env, make_free_function<Environment>(std::move(function).callback));
|
|
36
|
+
auto make = [ & ](void* data) -> value<function_tag> {
|
|
37
|
+
return value<function_tag>::from(napi::invoke(napi_create_function, napi_env{env}, function.name.data(), function.name.length(), callback, data));
|
|
38
|
+
};
|
|
39
|
+
if constexpr (requires { typename decltype(data)::element_type; }) {
|
|
40
|
+
// Function requires finalizer
|
|
41
|
+
auto function = make(data.get());
|
|
42
|
+
return apply_finalizer(std::move(data), [ & ](auto* data, napi_finalize finalize, void* hint) -> value<function_tag> {
|
|
43
|
+
napi::invoke0(napi_add_finalizer, napi_env{env}, function, data, finalize, hint, nullptr);
|
|
44
|
+
return function;
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
// No finalizer needed
|
|
48
|
+
return make(data);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
} // namespace js::napi
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module;
|
|
2
|
+
#include <span>
|
|
3
|
+
#include <variant>
|
|
4
|
+
export module napi_js:function;
|
|
5
|
+
import :environment_fwd;
|
|
6
|
+
import :primitive;
|
|
7
|
+
import :value_handle;
|
|
8
|
+
import util;
|
|
9
|
+
|
|
10
|
+
namespace js::napi {
|
|
11
|
+
|
|
12
|
+
class value_for_function : public value_next<function_tag> {
|
|
13
|
+
public:
|
|
14
|
+
using value_next<function_tag>::value_next;
|
|
15
|
+
|
|
16
|
+
template <class Result = std::monostate>
|
|
17
|
+
auto apply(auto_environment auto& env, auto&& args) -> Result;
|
|
18
|
+
|
|
19
|
+
template <class Result = std::monostate>
|
|
20
|
+
auto call(auto_environment auto& env, auto&&... args) -> Result;
|
|
21
|
+
|
|
22
|
+
template <auto_environment Environment>
|
|
23
|
+
static auto make(Environment& env, auto function) -> value<function_tag>;
|
|
24
|
+
|
|
25
|
+
private:
|
|
26
|
+
template <class Result>
|
|
27
|
+
auto invoke(auto_environment auto& env, std::span<napi_value> args) -> Result;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
} // namespace js::napi
|
package/value/object.cc
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module napi_js;
|
|
2
|
+
import :api;
|
|
3
|
+
import :bound_value;
|
|
4
|
+
import :value_handle;
|
|
5
|
+
|
|
6
|
+
namespace js::napi {
|
|
7
|
+
|
|
8
|
+
// object
|
|
9
|
+
auto bound_value_for_object::get(napi_value key) const -> value<value_tag> {
|
|
10
|
+
return value<value_tag>::from(napi::invoke(napi_get_property, env(), napi_value{*this}, key));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
auto bound_value_for_object::has(napi_value key) const -> bool {
|
|
14
|
+
return napi::invoke(napi_has_own_property, env(), napi_value{*this}, key);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
auto bound_value_for_object::set(napi_value key, napi_value value) -> void {
|
|
18
|
+
napi::invoke0(napi_set_property, env(), napi_value{*this}, key, value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// date
|
|
22
|
+
auto value_for_date::make(const environment& env, js_clock::time_point date) -> value<date_tag> {
|
|
23
|
+
return value<date_tag>::from(napi::invoke(napi_create_date, napi_env{env}, date.time_since_epoch().count()));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
bound_value_for_date::operator js_clock::time_point() const {
|
|
27
|
+
return js_clock::time_point{js_clock::duration{napi::invoke(napi_get_date_value, env(), napi_value{*this})}};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
} // namespace js::napi
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module;
|
|
2
|
+
#include <array>
|
|
3
|
+
#include <tuple>
|
|
4
|
+
#include <utility>
|
|
5
|
+
export module napi_js:object;
|
|
6
|
+
import :api;
|
|
7
|
+
import :bound_value;
|
|
8
|
+
import :environment_fwd;
|
|
9
|
+
import :primitive;
|
|
10
|
+
import :value_handle;
|
|
11
|
+
|
|
12
|
+
namespace js::napi {
|
|
13
|
+
|
|
14
|
+
// object
|
|
15
|
+
class value_for_object : public value_next<object_tag> {
|
|
16
|
+
public:
|
|
17
|
+
using value_next<object_tag>::value_next;
|
|
18
|
+
|
|
19
|
+
auto assign(this value<object_tag> self, auto_environment auto& env, auto source) -> void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
class bound_value_for_object : public bound_value_next<object_tag> {
|
|
23
|
+
public:
|
|
24
|
+
using bound_value_next<object_tag>::bound_value_next;
|
|
25
|
+
|
|
26
|
+
template <class Type>
|
|
27
|
+
[[nodiscard]] auto try_cast(std::type_identity<Type> /*type*/) const -> Type*;
|
|
28
|
+
|
|
29
|
+
[[nodiscard]] auto get(napi_value key) const -> value<value_tag>;
|
|
30
|
+
[[nodiscard]] auto has(napi_value key) const -> bool;
|
|
31
|
+
|
|
32
|
+
auto set(napi_value key, napi_value value) -> void;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// date
|
|
36
|
+
class value_for_date : public value_next<date_tag> {
|
|
37
|
+
public:
|
|
38
|
+
using value_next<date_tag>::value_next;
|
|
39
|
+
static auto make(const environment& env, js_clock::time_point date) -> value<date_tag>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
class bound_value_for_date : public bound_value_next<date_tag> {
|
|
43
|
+
public:
|
|
44
|
+
using bound_value_next<date_tag>::bound_value_next;
|
|
45
|
+
[[nodiscard]] explicit operator js_clock::time_point() const;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// ---
|
|
49
|
+
|
|
50
|
+
template <class Type>
|
|
51
|
+
auto bound_value_for_object::try_cast(std::type_identity<Type> /*type*/) const -> Type* {
|
|
52
|
+
if (napi::invoke(napi_check_object_type_tag, env(), napi_value{*this}, &type_tag_for<Type>)) {
|
|
53
|
+
return static_cast<Type*>(napi::invoke(napi_unwrap, env(), napi_value{*this}));
|
|
54
|
+
} else {
|
|
55
|
+
return nullptr;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
} // namespace js::napi
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
module;
|
|
2
|
+
#include <cstdint>
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <string_view>
|
|
5
|
+
module napi_js;
|
|
6
|
+
import :api;
|
|
7
|
+
import :bound_value;
|
|
8
|
+
import :value_handle;
|
|
9
|
+
|
|
10
|
+
namespace js::napi {
|
|
11
|
+
|
|
12
|
+
// undefined
|
|
13
|
+
auto value_for_undefined::make(const environment& env) -> value<undefined_tag> {
|
|
14
|
+
return value<undefined_tag>::from(napi::invoke(napi_get_undefined, napi_env{env}));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// null
|
|
18
|
+
auto value_for_null::make(const environment& env) -> value<null_tag> {
|
|
19
|
+
return value<null_tag>::from(napi::invoke(napi_get_null, napi_env{env}));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// boolean
|
|
23
|
+
auto value_for_boolean::make(const environment& env, bool boolean) -> value<boolean_tag> {
|
|
24
|
+
return value<boolean_tag>::from(napi::invoke(napi_get_boolean, napi_env{env}, boolean));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
bound_value_for_boolean::operator bool() const {
|
|
28
|
+
return napi::invoke(napi_get_value_bool, env(), napi_value{*this});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// number
|
|
32
|
+
auto value_for_number::make(const environment& env, double number) -> value<number_tag> {
|
|
33
|
+
return value<number_tag>::from(napi::invoke(napi_create_double, napi_env{env}, number));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
auto value_for_number::make(const environment& env, int32_t number) -> value<number_tag> {
|
|
37
|
+
return value<number_tag>::from(napi::invoke(napi_create_int32, napi_env{env}, number));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
auto value_for_number::make(const environment& env, int64_t number) -> value<number_tag> {
|
|
41
|
+
return value<number_tag>::from(napi::invoke(napi_create_int64, napi_env{env}, number));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
auto value_for_number::make(const environment& env, uint32_t number) -> value<number_tag> {
|
|
45
|
+
return value<number_tag>::from(napi::invoke(napi_create_uint32, napi_env{env}, number));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
bound_value_for_number::operator double() const {
|
|
49
|
+
return napi::invoke(napi_get_value_double, env(), napi_value{*this});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
bound_value_for_number::operator int32_t() const {
|
|
53
|
+
return napi::invoke(napi_get_value_int32, env(), napi_value{*this});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
bound_value_for_number::operator int64_t() const {
|
|
57
|
+
return napi::invoke(napi_get_value_int64, env(), napi_value{*this});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
bound_value_for_number::operator uint32_t() const {
|
|
61
|
+
return napi::invoke(napi_get_value_uint32, env(), napi_value{*this});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// bigint
|
|
65
|
+
auto value_for_bigint::make(const environment& env, const bigint& number) -> value<bigint_tag> {
|
|
66
|
+
return value<bigint_tag>::from(napi::invoke(napi_create_bigint_words, napi_env{env}, number.sign_bit(), number.size(), number.data()));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
auto value_for_bigint::make(const environment& env, int64_t number) -> value<bigint_tag> {
|
|
70
|
+
return value<bigint_tag>::from(napi::invoke(napi_create_bigint_int64, napi_env{env}, number));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
auto value_for_bigint::make(const environment& env, uint64_t number) -> value<bigint_tag> {
|
|
74
|
+
return value<bigint_tag>::from(napi::invoke(napi_create_bigint_uint64, napi_env{env}, number));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
bound_value_for_bigint::operator bigint() const {
|
|
78
|
+
js::bigint value;
|
|
79
|
+
auto one_word = uint64_t{};
|
|
80
|
+
auto length = size_t{1};
|
|
81
|
+
napi::invoke0(napi_get_value_bigint_words, env(), napi_value{*this}, &value.sign_bit(), &length, &one_word);
|
|
82
|
+
if (value.sign_bit() == 0 && length == 1) {
|
|
83
|
+
return js::bigint{one_word};
|
|
84
|
+
}
|
|
85
|
+
value.resize_and_overwrite(length, [ & ](auto* words, auto length) noexcept {
|
|
86
|
+
if (length > 0) {
|
|
87
|
+
napi::invoke0_noexcept(napi_get_value_bigint_words, env(), napi_value{*this}, &value.sign_bit(), &length, words);
|
|
88
|
+
}
|
|
89
|
+
return length;
|
|
90
|
+
});
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
bound_value_for_bigint::operator int64_t() const {
|
|
95
|
+
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
|
|
96
|
+
int64_t value;
|
|
97
|
+
// nb: `lossless` error not checked for consistency with `napi_get_value_int32`,
|
|
98
|
+
// `napi_get_value_string_latin1`, etc which don't return any errors.
|
|
99
|
+
napi::invoke(napi_get_value_bigint_int64, env(), napi_value{*this}, &value);
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
bound_value_for_bigint::operator uint64_t() const {
|
|
104
|
+
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
|
|
105
|
+
uint64_t value;
|
|
106
|
+
napi::invoke(napi_get_value_bigint_uint64, env(), napi_value{*this}, &value);
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// string
|
|
111
|
+
auto value_for_string::make(const environment& env, std::string_view string) -> value<string_tag> {
|
|
112
|
+
return value<string_tag>::from(napi::invoke(napi_create_string_latin1, napi_env{env}, string.data(), string.length()));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
auto value_for_string::make(const environment& env, std::u8string_view string) -> value<string_tag> {
|
|
116
|
+
return value<string_tag>::from(napi::invoke(napi_create_string_utf8, napi_env{env}, reinterpret_cast<const char*>(string.data()), string.length()));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
auto value_for_string::make(const environment& env, std::u16string_view string) -> value<string_tag> {
|
|
120
|
+
return value<string_tag>::from(napi::invoke(napi_create_string_utf16, napi_env{env}, string.data(), string.length()));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
auto value_for_string::make_property_name(const environment& env, std::string_view string) -> value<string_tag> {
|
|
124
|
+
return value<string_tag>::from(napi::invoke(node_api_create_property_key_latin1, napi_env{env}, reinterpret_cast<const char*>(string.data()), string.length()));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
auto value_for_string::make_property_name(const environment& env, std::u8string_view string) -> value<string_tag> {
|
|
128
|
+
return value<string_tag>::from(napi::invoke(node_api_create_property_key_utf8, napi_env{env}, reinterpret_cast<const char*>(string.data()), string.length()));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
auto value_for_string::make_property_name(const environment& env, std::u16string_view string) -> value<string_tag> {
|
|
132
|
+
return value<string_tag>::from(napi::invoke(node_api_create_property_key_utf16, napi_env{env}, string.data(), string.length()));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
bound_value_for_string::operator std::string() const {
|
|
136
|
+
std::string string;
|
|
137
|
+
auto length = napi::invoke(napi_get_value_string_latin1, env(), napi_value{*this}, nullptr, 0);
|
|
138
|
+
if (length > 0) {
|
|
139
|
+
string.resize_and_overwrite(length + 1, [ this ](char* data, size_t length) noexcept -> size_t {
|
|
140
|
+
napi::invoke_noexcept(napi_get_value_string_latin1, env(), napi_value{*this}, data, length);
|
|
141
|
+
return length - 1;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
bound_value_for_string::operator std::u16string() const {
|
|
148
|
+
// nb: napi requires that the returned string is null-terminated for some reason.
|
|
149
|
+
std::u16string string;
|
|
150
|
+
auto length = napi::invoke(napi_get_value_string_utf16, env(), napi_value{*this}, nullptr, 0);
|
|
151
|
+
if (length > 0) {
|
|
152
|
+
string.resize_and_overwrite(length + 1, [ this ](char16_t* data, size_t length) noexcept -> size_t {
|
|
153
|
+
napi::invoke_noexcept(napi_get_value_string_utf16, env(), napi_value{*this}, data, length);
|
|
154
|
+
return length - 1;
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
} // namespace js::napi
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
module;
|
|
2
|
+
#include <cstddef>
|
|
3
|
+
#include <cstdint>
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <string_view>
|
|
6
|
+
#include <variant>
|
|
7
|
+
export module napi_js:primitive;
|
|
8
|
+
import :api;
|
|
9
|
+
import :bound_value;
|
|
10
|
+
import :environment_fwd;
|
|
11
|
+
import :value_handle;
|
|
12
|
+
|
|
13
|
+
namespace js::napi {
|
|
14
|
+
|
|
15
|
+
// undefined
|
|
16
|
+
class value_for_undefined : public value_next<undefined_tag> {
|
|
17
|
+
public:
|
|
18
|
+
using value_next<undefined_tag>::value_next;
|
|
19
|
+
static auto make(const environment& env) -> value<undefined_tag>;
|
|
20
|
+
static auto make(const environment& env, std::monostate /*undefined*/) -> value<undefined_tag> { return make(env); }
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// null
|
|
24
|
+
class value_for_null : public value_next<null_tag> {
|
|
25
|
+
public:
|
|
26
|
+
using value_next<null_tag>::value_next;
|
|
27
|
+
static auto make(const environment& env) -> value<null_tag>;
|
|
28
|
+
static auto make(const environment& env, std::nullptr_t /*null*/) -> value<null_tag> { return make(env); }
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// boolean
|
|
32
|
+
class value_for_boolean : public value_next<boolean_tag> {
|
|
33
|
+
public:
|
|
34
|
+
using value_next<boolean_tag>::value_next;
|
|
35
|
+
static auto make(const environment& env, bool boolean) -> value<boolean_tag>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
class bound_value_for_boolean : public bound_value_next<boolean_tag> {
|
|
39
|
+
public:
|
|
40
|
+
using bound_value_next<boolean_tag>::bound_value_next;
|
|
41
|
+
[[nodiscard]] explicit operator bool() const;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// number
|
|
45
|
+
class value_for_number : public value_next<number_tag> {
|
|
46
|
+
public:
|
|
47
|
+
using value_next<number_tag>::value_next;
|
|
48
|
+
static auto make(const environment& env, double number) -> value<number_tag>;
|
|
49
|
+
static auto make(const environment& env, int32_t number) -> value<number_tag>;
|
|
50
|
+
static auto make(const environment& env, int64_t number) -> value<number_tag>;
|
|
51
|
+
static auto make(const environment& env, uint32_t number) -> value<number_tag>;
|
|
52
|
+
|
|
53
|
+
static auto make_property_name(const environment& env, int32_t number) -> value<number_tag> { return make(env, number); }
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
class bound_value_for_number : public bound_value_next<number_tag> {
|
|
57
|
+
public:
|
|
58
|
+
using bound_value_next<number_tag>::bound_value_next;
|
|
59
|
+
[[nodiscard]] explicit operator double() const;
|
|
60
|
+
[[nodiscard]] explicit operator int32_t() const;
|
|
61
|
+
[[nodiscard]] explicit operator int64_t() const;
|
|
62
|
+
[[nodiscard]] explicit operator uint32_t() const;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// bigint
|
|
66
|
+
class value_for_bigint : public value_next<bigint_tag> {
|
|
67
|
+
public:
|
|
68
|
+
using value_next<bigint_tag>::value_next;
|
|
69
|
+
static auto make(const environment& env, const bigint& number) -> value<bigint_tag>;
|
|
70
|
+
static auto make(const environment& env, int64_t number) -> value<bigint_tag>;
|
|
71
|
+
static auto make(const environment& env, uint64_t number) -> value<bigint_tag>;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
class bound_value_for_bigint : public bound_value_next<bigint_tag> {
|
|
75
|
+
public:
|
|
76
|
+
using bound_value_next<bigint_tag>::bound_value_next;
|
|
77
|
+
[[nodiscard]] explicit operator bigint() const;
|
|
78
|
+
[[nodiscard]] explicit operator int64_t() const;
|
|
79
|
+
[[nodiscard]] explicit operator uint64_t() const;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// string
|
|
83
|
+
class value_for_string : public value_next<string_tag> {
|
|
84
|
+
public:
|
|
85
|
+
using value_next<string_tag>::value_next;
|
|
86
|
+
static auto make(const environment& env, std::string_view string) -> value<string_tag>;
|
|
87
|
+
static auto make(const environment& env, std::u8string_view string) -> value<string_tag>;
|
|
88
|
+
static auto make(const environment& env, std::u16string_view string) -> value<string_tag>;
|
|
89
|
+
static auto make_property_name(const environment& env, std::string_view string) -> value<string_tag>;
|
|
90
|
+
static auto make_property_name(const environment& env, std::u8string_view string) -> value<string_tag>;
|
|
91
|
+
static auto make_property_name(const environment& env, std::u16string_view string) -> value<string_tag>;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
class bound_value_for_string : public bound_value_next<string_tag> {
|
|
95
|
+
public:
|
|
96
|
+
using bound_value_next<string_tag>::bound_value_next;
|
|
97
|
+
[[nodiscard]] explicit operator std::string() const;
|
|
98
|
+
[[nodiscard]] explicit operator std::u16string() const;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
} // namespace js::napi
|