Skip to content

Commit

Permalink
HPCC-33154 Refactor WebAssembly Support
Browse files Browse the repository at this point in the history
Added list / set support

Signed-off-by: Gordon Smith <[email protected]>
  • Loading branch information
GordonSmith committed Jan 2, 2025
1 parent 70ccefc commit 75808aa
Show file tree
Hide file tree
Showing 42 changed files with 2,379 additions and 472 deletions.
1 change: 1 addition & 0 deletions plugins/wasmembed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ref/
8 changes: 6 additions & 2 deletions plugins/wasmembed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ project(wasmembed)
if(WASMEMBED)
ADD_PLUGIN(wasmembed)
if(MAKE_WASMEMBED)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_subdirectory(component-model)

find_path(WASMTIME_CPP_API_INCLUDE_DIRS "wasmtime-cpp-api/wasmtime.hh"
PATHS ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}
)
Expand All @@ -21,6 +24,7 @@ if(WASMEMBED)
include_directories(
${WASMTIME_CPP_API_INCLUDE_DIRS}/wasmtime-c-api
${WASMTIME_CPP_API_INCLUDE_DIRS}/wasmtime-cpp-api

./../../system/include
./../../system/jlib
./../../rtl/eclrtl
Expand All @@ -37,12 +41,12 @@ if(WASMEMBED)
add_library(wasmembed SHARED
wasmembed.cpp
secure-enclave.cpp
abi.cpp
util.cpp
)

target_link_libraries(wasmembed
${WASMTIME_LIB}
component-model-cpp
eclrtl
jlib
)
Expand Down
269 changes: 0 additions & 269 deletions plugins/wasmembed/abi.cpp

This file was deleted.

10 changes: 0 additions & 10 deletions plugins/wasmembed/abi.hpp

This file was deleted.

2 changes: 2 additions & 0 deletions plugins/wasmembed/component-model/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(src)
add_subdirectory(test)
42 changes: 42 additions & 0 deletions plugins/wasmembed/component-model/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
project(component-model-cpp)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(SRC
boolean.cpp
boolean.hpp
context.hpp
context.cpp
float.hpp
float.cpp
integer.hpp
integer.cpp
list.hpp
list.cpp
load.hpp
load.cpp
string.hpp
string.cpp
traits.hpp
traits.cpp
util.hpp
util.cpp
)

add_library(${PROJECT_NAME} STATIC
${SRC}
)

target_link_libraries(${PROJECT_NAME}
)

target_compile_definitions(${PROJECT_NAME}
PRIVATE CMCPP_EXPORTS
)
target_compile_options(${PROJECT_NAME} PUBLIC "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->")

target_include_directories(
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
)
19 changes: 19 additions & 0 deletions plugins/wasmembed/component-model/src/boolean.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "boolean.hpp"
#include "integer.hpp"
#include "util.hpp"

namespace cmcpp
{
namespace boolean
{
void store(CallContext &cx, const bool_t &v, offset ptr)
{
integer::store<uint8_t>(cx, v, ptr);
}

bool_t load(const CallContext &cx, uint32_t ptr)
{
return convert_int_to_bool(integer::load<uint8_t>(cx, ptr));
}
}
}
Loading

0 comments on commit 75808aa

Please sign in to comment.