From e433d4af4cf78c88dc0cb3e8139e835470b72fd3 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 22 Mar 2020 23:43:07 -0400 Subject: Extend Rust FFI Do idiomatic C++ copy and move constructors for a few things, so wrapping structs' defaults can work. --- src/libstore/path.hh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/libstore/path.hh') diff --git a/src/libstore/path.hh b/src/libstore/path.hh index c90bb1fff..186976855 100644 --- a/src/libstore/path.hh +++ b/src/libstore/path.hh @@ -13,6 +13,7 @@ extern "C" { void ffi_StorePath_drop(void *); bool ffi_StorePath_less_than(const StorePath & a, const StorePath & b); bool ffi_StorePath_eq(const StorePath & a, const StorePath & b); + void ffi_StorePath_clone_to(const StorePath & _other, StorePath & _this); unsigned char * ffi_StorePath_hash_data(const StorePath & p); } @@ -43,6 +44,19 @@ struct StorePath : rust::Value<3 * sizeof(void *) + 24, ffi_StorePath_drop> return !(*this == other); } + StorePath(StorePath && that) = default; + + StorePath(const StorePath & that) + { + ffi_StorePath_clone_to(that, *this); + } + + void operator = (const StorePath & that) + { + (rust::Value<3 * sizeof(void *) + 24, ffi_StorePath_drop>::operator = (that)); + ffi_StorePath_clone_to(that, *this); + } + StorePath clone() const; /* Check whether a file name ends with the extension for -- cgit v1.2.3