Move all cbindgen generated code into

sixtyfps::cbindgen_private

Having private in the name makes it clear that this is ... private,
and cbindgen helps remember that it's generated.
This commit is contained in:
Simon Hausmann 2020-08-25 15:29:48 +02:00
parent 2fa953ce8a
commit 14fe897086
12 changed files with 108 additions and 108 deletions

View file

@ -16,27 +16,27 @@ namespace sixtyfps {
struct SharedString
{
SharedString() { internal::sixtyfps_shared_string_from_bytes(this, "", 0); }
SharedString() { cbindgen_private::sixtyfps_shared_string_from_bytes(this, "", 0); }
SharedString(std::string_view s)
{
internal::sixtyfps_shared_string_from_bytes(this, s.data(), s.size());
cbindgen_private::sixtyfps_shared_string_from_bytes(this, s.data(), s.size());
}
SharedString(const char *s) : SharedString(std::string_view(s)) { }
SharedString(const SharedString &other)
{
internal::sixtyfps_shared_string_clone(this, &other);
cbindgen_private::sixtyfps_shared_string_clone(this, &other);
}
~SharedString() { internal::sixtyfps_shared_string_drop(this); }
~SharedString() { cbindgen_private::sixtyfps_shared_string_drop(this); }
SharedString &operator=(const SharedString &other)
{
internal::sixtyfps_shared_string_drop(this);
internal::sixtyfps_shared_string_clone(this, &other);
cbindgen_private::sixtyfps_shared_string_drop(this);
cbindgen_private::sixtyfps_shared_string_clone(this, &other);
return *this;
}
SharedString &operator=(std::string_view s)
{
internal::sixtyfps_shared_string_drop(this);
internal::sixtyfps_shared_string_from_bytes(this, s.data(), s.size());
cbindgen_private::sixtyfps_shared_string_drop(this);
cbindgen_private::sixtyfps_shared_string_from_bytes(this, s.data(), s.size());
return *this;
}
SharedString &operator=(SharedString &&other)
@ -45,8 +45,8 @@ struct SharedString
return *this;
}
operator std::string_view() const { return internal::sixtyfps_shared_string_bytes(this); }
auto data() const -> const char * { return internal::sixtyfps_shared_string_bytes(this); }
operator std::string_view() const { return cbindgen_private::sixtyfps_shared_string_bytes(this); }
auto data() const -> const char * { return cbindgen_private::sixtyfps_shared_string_bytes(this); }
static SharedString from_number(double n) { return SharedString(n); }
@ -61,7 +61,7 @@ struct SharedString
private:
/// Use SharedString::from_number
explicit SharedString(double n) { internal::sixtyfps_shared_string_from_number(this, n); }
explicit SharedString(double n) { cbindgen_private::sixtyfps_shared_string_from_number(this, n); }
void *inner; // opaque
};
}