Skip to content

Commit

Permalink
fix: use .from instead
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Gorez <gorez.tony@gmail.com>
  • Loading branch information
tony-go committed Feb 21, 2024
1 parent 1ef594d commit d8503df
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/engine/include/includejs/engine_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class INCLUDEJS_ENGINE_EXPORT Context {
~Context();
#endif
auto make_undefined() const -> Value;
auto make_null() const -> Value;
auto make_error(const std::string &message) const -> Value;
auto make_object() const -> Value;
auto make_promise() const -> Promise;
Expand Down
8 changes: 4 additions & 4 deletions src/engine/javascript_core/engine_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ auto Context::make_undefined() const -> Value {
JSValueMakeUndefined(this->internal->context)};
}

auto Context::make_null() const -> Value {
return {this->internal->context, JSValueMakeNull(this->internal->context)};
}

auto Context::make_error(const std::string &message) const -> Value {
JSStringRef message_value = JSStringCreateWithUTF8CString(message.c_str());
JSValueRef error_arguments[]{
Expand Down Expand Up @@ -84,6 +80,10 @@ auto Context::from(const char *value) const -> Value {
return {this->internal->context, result};
}

auto Context::from(std::nullptr_t) const -> Value {
return {this->internal->context, JSValueMakeNull(this->internal->context)};
}

auto Context::global() const -> Value {
return {this->internal->context, this->internal->global};
}
Expand Down
2 changes: 1 addition & 1 deletion test/engine/engine_value_null_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
TEST(IncludeJS_Engine, create_null) {
sourcemeta::includejs::Engine engine;

auto null = engine.context().make_null();
auto null = engine.context().from(nullptr);
EXPECT_TRUE(null.is_null());
}

Expand Down

0 comments on commit d8503df

Please sign in to comment.