Support calling C++ methods from Rust
These methods can be declared in the bridge by naming the first
argument self and making it a reference to the containing class, e.g.,
fn get(self: &C) -> usize;
fn set(self: &mut C, n: usize);
This syntax requires Rust 1.43.
Note that the implementation also changes the internal naming of shim
functions so that they also contain the name of the owning class, if
any. This allows defining multiple methods with the same name on
different objects.
diff --git a/tests/ffi/tests.cc b/tests/ffi/tests.cc
index d72bfd0..2daae53 100644
--- a/tests/ffi/tests.cc
+++ b/tests/ffi/tests.cc
@@ -15,6 +15,11 @@
size_t C::get() const { return this->n; }
+size_t C::set(size_t n) {
+ this->n = n;
+ return this->n;
+}
+
size_t c_return_primitive() { return 2020; }
Shared c_return_shared() { return Shared{2020}; }