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:
@@ -370,9 +370,24 @@ void Gecko_AppendCString(nsACString* aThis, const nsACString* aOther)
|
||||
aThis->Append(*aOther);
|
||||
}
|
||||
|
||||
void Gecko_TruncateCString(nsACString* aThis)
|
||||
void Gecko_SetLengthCString(nsACString* aThis, uint32_t aLength)
|
||||
{
|
||||
aThis->Truncate();
|
||||
aThis->SetLength(aLength);
|
||||
}
|
||||
|
||||
bool Gecko_FallibleAssignCString(nsACString* aThis, const nsACString* aOther)
|
||||
{
|
||||
return aThis->Assign(*aOther, mozilla::fallible);
|
||||
}
|
||||
|
||||
bool Gecko_FallibleAppendCString(nsACString* aThis, const nsACString* aOther)
|
||||
{
|
||||
return aThis->Append(*aOther, mozilla::fallible);
|
||||
}
|
||||
|
||||
bool Gecko_FallibleSetLengthCString(nsACString* aThis, uint32_t aLength)
|
||||
{
|
||||
return aThis->SetLength(aLength, mozilla::fallible);
|
||||
}
|
||||
|
||||
void Gecko_FinalizeString(nsAString* aThis)
|
||||
@@ -390,9 +405,24 @@ void Gecko_AppendString(nsAString* aThis, const nsAString* aOther)
|
||||
aThis->Append(*aOther);
|
||||
}
|
||||
|
||||
void Gecko_TruncateString(nsAString* aThis)
|
||||
void Gecko_SetLengthString(nsAString* aThis, uint32_t aLength)
|
||||
{
|
||||
aThis->Truncate();
|
||||
aThis->SetLength(aLength);
|
||||
}
|
||||
|
||||
bool Gecko_FallibleAssignString(nsAString* aThis, const nsAString* aOther)
|
||||
{
|
||||
return aThis->Assign(*aOther, mozilla::fallible);
|
||||
}
|
||||
|
||||
bool Gecko_FallibleAppendString(nsAString* aThis, const nsAString* aOther)
|
||||
{
|
||||
return aThis->Append(*aOther, mozilla::fallible);
|
||||
}
|
||||
|
||||
bool Gecko_FallibleSetLengthString(nsAString* aThis, uint32_t aLength)
|
||||
{
|
||||
return aThis->SetLength(aLength, mozilla::fallible);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user