Skip to content

Commit

Permalink
symmetric API
Browse files Browse the repository at this point in the history
  • Loading branch information
cpetig committed Aug 28, 2024
1 parent e9d9c4e commit 5f0ec6c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion crates/cpp/tests/meshless_strings/component_b/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ libcomponent_b.a: the_world.o guest.o
ar rcvs $@ $^

bindgen:
../../../../../target/debug/wit-bindgen cpp ../wit --symmetric --wasm64 --format
../../../../../target/debug/wit-bindgen cpp ../wit --symmetric --new-api --format

clean:
-rm *~ *.a *.o
1 change: 0 additions & 1 deletion crates/cpp/tests/meshless_strings/component_b/guest.cpp

This file was deleted.

13 changes: 13 additions & 0 deletions crates/cpp/tests/meshless_strings/component_b/guest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "the_world_cpp.h"

void exports::foo::foo::strings::A(std::string_view x) {
::foo::foo::strings::A(x);
}

wit::string exports::foo::foo::strings::B() {
return ::foo::foo::strings::B();
}

wit::string exports::foo::foo::strings::C(std::string_view x, std::string_view b) {
return ::foo::foo::strings::C(x, b);
}
16 changes: 4 additions & 12 deletions crates/cpp/tests/meshless_strings/component_b/the_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ extern "C" __attribute__((__export_name__("foo:foo/strings#a"))) void
fooX3AfooX2FstringsX00a(uint8_t *arg0, size_t arg1) {
auto len0 = arg1;

auto string0 =
wit::string::from_view(std::string_view((char const *)(arg0), len0));

exports::foo::foo::strings::A(std::move(string0));
exports::foo::foo::strings::A(std::string_view((char const *)(arg0), len0));
}
extern "C" __attribute__((__export_name__("foo:foo/strings#b"))) void
fooX3AfooX2FstringsX00b(uint8_t *arg0) {
Expand All @@ -89,16 +86,11 @@ fooX3AfooX2FstringsX00c(uint8_t *arg0, size_t arg1, uint8_t *arg2, size_t arg3,
uint8_t *arg4) {
auto len0 = arg1;

auto string0 =
wit::string::from_view(std::string_view((char const *)(arg0), len0));

auto len1 = arg3;

auto string1 =
wit::string::from_view(std::string_view((char const *)(arg2), len1));

auto result2 =
exports::foo::foo::strings::C(std::move(string0), std::move(string1));
auto result2 = exports::foo::foo::strings::C(
std::string_view((char const *)(arg0), len0),
std::string_view((char const *)(arg2), len1));
auto const &vec3 = result2;
auto ptr3 = (uint8_t *)(vec3.data());
auto len3 = (size_t)(vec3.size());
Expand Down
4 changes: 2 additions & 2 deletions crates/cpp/tests/meshless_strings/component_b/the_world_cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ namespace exports {
namespace foo {
namespace foo {
namespace strings {
void A(wit::string &&x);
void A(std::string_view x);
wit::string B();
wit::string C(wit::string &&a, wit::string &&b);
wit::string C(std::string_view a, std::string_view b);
} // namespace strings
} // namespace foo
} // namespace foo
Expand Down

0 comments on commit 5f0ec6c

Please sign in to comment.