Bug 1347224 - Part 1: Expose fallible methods on the rust ns[C]String bindings, r=froydnj

This patch adds a series of fallible methods for the rust ns[C]String
bindings, as well as the `set_length` method, which is the same as the
`SetLength` method in C++. `set_length` is marked as unsafe.

The decision was made to make the fallible methods seperate from the
infallible methods, and to use seperate Rust->C++ bindings for each of
them, rather than only binding the fallible bindings, and unwrapping
them in rust-land. This is to try to match the C++ API as closely as
possible, and to ensure that the behavior matches.

MozReview-Commit-ID: FkSomkFUFGD
This commit is contained in:
Michael Layzell
2017-03-20 14:40:25 -04:00
parent b58f0eea67
commit b9d73be7be
3 changed files with 289 additions and 68 deletions

View File

@@ -1380,4 +1380,14 @@ void Gecko_AppendUTF8toString(nsAString* aThis, const nsACString* aOther)
AppendUTF8toUTF16(*aOther, *aThis);
}
bool Gecko_FallibleAppendUTF16toCString(nsACString* aThis, const nsAString* aOther)
{
return AppendUTF16toUTF8(*aOther, *aThis, mozilla::fallible);
}
bool Gecko_FallibleAppendUTF8toString(nsAString* aThis, const nsACString* aOther)
{
return AppendUTF8toUTF16(*aOther, *aThis, mozilla::fallible);
}
}