Skip to content

Commit

Permalink
chore: delete SOURCEMETA_ refs (#46)
Browse files Browse the repository at this point in the history
Close #43

Signed-off-by: Tony Gorez <gorez.tony@gmail.com>
  • Loading branch information
tony-go authored Feb 22, 2024
1 parent a482369 commit e469c9d
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion cmake/CompilerOptions.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function(sourcemeta_includejs_add_compile_options target)
function(includejs_add_compile_options target)
if(NOA_COMPILER_MSVC)
# See https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category
target_compile_options("${target}" PRIVATE
Expand Down
6 changes: 3 additions & 3 deletions src/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ if(INCLUDEJS_INSTALL)
endif()
endif()

sourcemeta_includejs_add_compile_options(includejs_engine)
includejs_add_compile_options(includejs_engine)

if(INCLUDEJS_BACKEND STREQUAL "JavaScriptCore")
find_package(JavaScriptCore REQUIRED)
target_link_libraries(includejs_engine
PRIVATE JavaScriptCore::JavaScriptCore)
target_compile_definitions(includejs_engine
PUBLIC SOURCEMETA_INCLUDEJS_ENGINE_JAVASCRIPT_CORE)
PUBLIC INCLUDEJS_ENGINE_JAVASCRIPT_CORE)
elseif(INCLUDEJS_BACKEND STREQUAL "V8")
find_package(V8 REQUIRED)
target_link_libraries(includejs_engine
PRIVATE V8::V8)
target_compile_definitions(includejs_engine
PUBLIC SOURCEMETA_INCLUDEJS_ENGINE_V8)
PUBLIC INCLUDEJS_ENGINE_V8)
else()
message(FATAL_ERROR "Unknown IncludeJS backend: ${INCLUDEJS_BACKEND}")
endif()
2 changes: 1 addition & 1 deletion src/engine/common/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <utility> // std::move
#include <vector> // std::vector

#if !defined(SOURCEMETA_INCLUDEJS_ENGINE_V8)
#if !defined(INCLUDEJS_ENGINE_V8)

namespace includejs {

Expand Down
2 changes: 1 addition & 1 deletion src/engine/common/engine_context.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <includejs/engine_context.h>

#if !defined(SOURCEMETA_INCLUDEJS_ENGINE_V8)
#if !defined(INCLUDEJS_ENGINE_V8)

namespace includejs {

Expand Down
6 changes: 3 additions & 3 deletions src/engine/include/includejs/engine.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SOURCEMETA_INCLUDEJS_ENGINE_H_
#define SOURCEMETA_INCLUDEJS_ENGINE_H_
#ifndef INCLUDEJS_ENGINE_H_
#define INCLUDEJS_ENGINE_H_

/// @defgroup engine Engine
/// @brief The IncludeJS higher-level abstraction of a JavaScript engine
Expand Down Expand Up @@ -35,7 +35,7 @@ class INCLUDEJS_ENGINE_EXPORT Engine {
-> Value;

// TODO(RaisinTen): Add support for bind_function() to the V8 backend.
#if !defined(SOURCEMETA_INCLUDEJS_ENGINE_V8)
#if !defined(INCLUDEJS_ENGINE_V8)
auto bind_function(std::initializer_list<std::string> location,
Function function) -> void;
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/engine/include/includejs/engine_context.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SOURCEMETA_INCLUDEJS_ENGINE_CONTEXT_H_
#define SOURCEMETA_INCLUDEJS_ENGINE_CONTEXT_H_
#ifndef INCLUDEJS_ENGINE_CONTEXT_H_
#define INCLUDEJS_ENGINE_CONTEXT_H_

#include "engine_export.h"

Expand Down
4 changes: 2 additions & 2 deletions src/engine/include/includejs/engine_error.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SOURCEMETA_INCLUDEJS_ENGINE_ERROR_H_
#define SOURCEMETA_INCLUDEJS_ENGINE_ERROR_H_
#ifndef INCLUDEJS_ENGINE_ERROR_H_
#define INCLUDEJS_ENGINE_ERROR_H_

#include "engine_export.h"

Expand Down
30 changes: 15 additions & 15 deletions src/engine/include/includejs/engine_function.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#ifndef SOURCEMETA_INCLUDEJS_ENGINE_FUNCTION_H_
#define SOURCEMETA_INCLUDEJS_ENGINE_FUNCTION_H_
#ifndef INCLUDEJS_ENGINE_FUNCTION_H_
#define INCLUDEJS_ENGINE_FUNCTION_H_

#include "engine_export.h"

#include <includejs/engine_context.h>
#include <includejs/engine_value.h>

#if defined(SOURCEMETA_INCLUDEJS_ENGINE_JAVASCRIPT_CORE)
#if defined(INCLUDEJS_ENGINE_JAVASCRIPT_CORE)
#include <exception> // std::exception
#include <vector> // std::vector
#endif

#ifdef DOXYGEN
/// @ingroup engine
#define SOURCEMETA_INCLUDEJS_ARGS
#define INCLUDEJS_ARGS
#else
#if __cplusplus >= 202002L
#include <span> // std::span
#define SOURCEMETA_INCLUDEJS_ARGS std::span<includejs::Value>
#define INCLUDEJS_ARGS std::span<includejs::Value>
#else
#define SOURCEMETA_INCLUDEJS_ARGS const std::vector<includejs::Value> &
#define INCLUDEJS_ARGS const std::vector<includejs::Value> &
#endif
#endif

#if defined(SOURCEMETA_INCLUDEJS_ENGINE_JAVASCRIPT_CORE)
#if defined(INCLUDEJS_ENGINE_JAVASCRIPT_CORE)
namespace includejs {
// This is a opaque function signature that can be force-casted into
// JSObjectCallAsFunctionCallback
Expand All @@ -33,8 +33,8 @@ using Function = const void *(*)(const void *, const void *, const void *,
} // namespace includejs
#endif

#if defined(SOURCEMETA_INCLUDEJS_ENGINE_JAVASCRIPT_CORE)
#define __SOURCEMETA_INCLUDEJS_EXPOSE_FUNCTION_INTERNAL(function, call_as) \
#if defined(INCLUDEJS_ENGINE_JAVASCRIPT_CORE)
#define _INCLUDEJS_EXPOSE_FUNCTION_INTERNAL(function, call_as) \
static const void *function(const void *context, const void *, const void *, \
const size_t argc, const void *raw_arguments[], \
const void **exception) { \
Expand All @@ -55,15 +55,15 @@ using Function = const void *(*)(const void *, const void *, const void *,

#ifdef DOXYGEN
/// @ingroup engine
#define SOURCEMETA_INCLUDEJS_EXPOSE_FUNCTION(function)
#define INCLUDEJS_EXPOSE_FUNCTION(function)
/// @ingroup engine
#define SOURCEMETA_INCLUDEJS_EXPOSE_TEMPLATE_FUNCTION(function)
#define INCLUDEJS_EXPOSE_TEMPLATE_FUNCTION(function)
#else
#define SOURCEMETA_INCLUDEJS_EXPOSE_FUNCTION(function) \
__SOURCEMETA_INCLUDEJS_EXPOSE_FUNCTION_INTERNAL(function, function)
#define SOURCEMETA_INCLUDEJS_EXPOSE_TEMPLATE_FUNCTION(function) \
#define INCLUDEJS_EXPOSE_FUNCTION(function) \
_INCLUDEJS_EXPOSE_FUNCTION_INTERNAL(function, function)
#define INCLUDEJS_EXPOSE_TEMPLATE_FUNCTION(function) \
template <typename... Args> \
__SOURCEMETA_INCLUDEJS_EXPOSE_FUNCTION_INTERNAL(function, function<Args...>)
_INCLUDEJS_EXPOSE_FUNCTION_INTERNAL(function, function<Args...>)
#endif

#endif
4 changes: 2 additions & 2 deletions src/engine/include/includejs/engine_promise.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SOURCEMETA_INCLUDEJS_ENGINE_PROMISE_H_
#define SOURCEMETA_INCLUDEJS_ENGINE_PROMISE_H_
#ifndef INCLUDEJS_ENGINE_PROMISE_H_
#define INCLUDEJS_ENGINE_PROMISE_H_

#include "engine_export.h"

Expand Down
4 changes: 2 additions & 2 deletions src/engine/include/includejs/engine_value.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SOURCEMETA_INCLUDEJS_ENGINE_VALUE_H_
#define SOURCEMETA_INCLUDEJS_ENGINE_VALUE_H_
#ifndef INCLUDEJS_ENGINE_VALUE_H_
#define INCLUDEJS_ENGINE_VALUE_H_

#include "engine_export.h"

Expand Down
2 changes: 1 addition & 1 deletion test/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ add_executable(includejs_engine_unit
engine_value_undefined_test.cc
engine_value_null_test.cc)

sourcemeta_includejs_add_compile_options(includejs_engine_unit)
includejs_add_compile_options(includejs_engine_unit)

target_link_libraries(includejs_engine_unit
PRIVATE GTest::gtest GTest::gtest_main)
Expand Down
16 changes: 8 additions & 8 deletions test/engine/engine_binding_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
#include <includejs/engine.h>

static auto is_string(const includejs::Context &context,
SOURCEMETA_INCLUDEJS_ARGS arguments) -> includejs::Value {
INCLUDEJS_ARGS arguments) -> includejs::Value {
return context.from(!arguments.empty() && arguments.front().is_string());
}

// TODO: Add overload that doesn't take arguments
static auto get_details(const includejs::Context &context,
SOURCEMETA_INCLUDEJS_ARGS) -> includejs::Value {
static auto get_details(const includejs::Context &context, INCLUDEJS_ARGS)
-> includejs::Value {
includejs::Value result{context.make_object()};
result.set("version", context.from("1.0.0"));
return result;
}

static auto promise_test(const includejs::Context &context,
SOURCEMETA_INCLUDEJS_ARGS) -> includejs::Value {
static auto promise_test(const includejs::Context &context, INCLUDEJS_ARGS)
-> includejs::Value {
includejs::Promise promise{context.make_promise()};
promise.resolve(context.from(true));
return promise.value();
}

SOURCEMETA_INCLUDEJS_EXPOSE_FUNCTION(is_string);
SOURCEMETA_INCLUDEJS_EXPOSE_FUNCTION(get_details);
SOURCEMETA_INCLUDEJS_EXPOSE_FUNCTION(promise_test);
INCLUDEJS_EXPOSE_FUNCTION(is_string);
INCLUDEJS_EXPOSE_FUNCTION(get_details);
INCLUDEJS_EXPOSE_FUNCTION(promise_test);

TEST(IncludeJS_Engine, bind_global_root_integer) {
includejs::Engine engine;
Expand Down
2 changes: 1 addition & 1 deletion test/packaging/find_package/hello.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
auto main() -> int {
includejs::Engine engine;
// TODO(RaisinTen): Remove this once V8 supports this.
#if !defined(SOURCEMETA_INCLUDEJS_ENGINE_V8)
#if !defined(INCLUDEJS_ENGINE_V8)
includejs::Value result{engine.evaluate("1 + 3", "index.js")};
assert(result.is_number());
std::cout << result.to_number() << "\n";
Expand Down

0 comments on commit e469c9d

Please sign in to comment.