Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2022-02-14 02:44:30 +0300
committerGitHub <noreply@github.com>2022-02-14 02:44:30 +0300
commit34be1af5e17195dd9ce127e1daa7ab2bafd2df84 (patch)
tree7947b63af699a5ba9ef7ae841c54c7fb1d3add2d /src/util.h
parent60b8e795993cd6fcb7dc70d696a6ebe7aa0ef3d4 (diff)
src: merge ToJsSet into ToV8Value
This addresses a `TODO` comment, and makes use of the opportunity to also clean up our `MaybeLocal` handling in this area and start accepting `std::string_view` where we accept `std::string`. PR-URL: https://github.com/nodejs/node/pull/41757 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/util.h b/src/util.h
index 06c67d273ba..8c21c53a134 100644
--- a/src/util.h
+++ b/src/util.h
@@ -36,7 +36,9 @@
#include <limits>
#include <memory>
#include <string>
+#include <string_view>
#include <type_traits>
+#include <set>
#include <unordered_map>
#include <utility>
#include <vector>
@@ -644,7 +646,7 @@ using DeleteFnPtr = typename FunctionDeleter<T, function>::Pointer;
std::vector<std::string> SplitString(const std::string& in, char delim);
inline v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
- const std::string& str,
+ std::string_view str,
v8::Isolate* isolate = nullptr);
template <typename T, typename test_for_number =
typename std::enable_if<std::numeric_limits<T>::is_specialized, bool>::type>
@@ -655,6 +657,10 @@ template <typename T>
inline v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
const std::vector<T>& vec,
v8::Isolate* isolate = nullptr);
+template <typename T>
+inline v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
+ const std::set<T>& set,
+ v8::Isolate* isolate = nullptr);
template <typename T, typename U>
inline v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
const std::unordered_map<T, U>& map,