mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2025-02-10 00:32:39 +00:00
Touch up PR 67
This commit is contained in:
parent
4fcfa945c6
commit
85db5a01b2
@ -1031,7 +1031,7 @@ fn write_rust_vec_impl(out: &mut OutFile, ty: &Type) {
|
||||
writeln!(
|
||||
out,
|
||||
" return cxxbridge02$rust_vec${}$drop(this);",
|
||||
instance
|
||||
instance,
|
||||
);
|
||||
writeln!(out, "}}");
|
||||
|
||||
@ -1044,7 +1044,7 @@ fn write_rust_vec_impl(out: &mut OutFile, ty: &Type) {
|
||||
writeln!(
|
||||
out,
|
||||
"Vec<{}>::operator ::std::vector<{}>() const noexcept {{",
|
||||
inner, inner
|
||||
inner, inner,
|
||||
);
|
||||
writeln!(out, " ::std::vector<{}> v;", inner);
|
||||
writeln!(out, " v.reserve(this->size());");
|
||||
|
@ -602,6 +602,7 @@ fn expand_rust_vec(namespace: &Namespace, ty: &Type, ident: &Ident) -> TokenStre
|
||||
unsafe extern "C" fn #local_vector_from(this: *mut ::cxx::RustVec<#inner>, vector: *mut ::cxx::RealVector<#inner>) {
|
||||
this.as_ref().unwrap().into_vector(vector.as_mut().unwrap());
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[export_name = #link_len]
|
||||
unsafe extern "C" fn #local_len(this: *const ::cxx::RustVec<#inner>) -> usize {
|
||||
this.as_ref().unwrap().len()
|
||||
|
@ -71,6 +71,7 @@ impl<'a, T: VectorTarget<T>> IntoIterator for &'a RealVector<T> {
|
||||
|
||||
impl<'a, T: VectorTarget<T>> Iterator for VectorIntoIterator<'a, T> {
|
||||
type Item = &'a T;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.index = self.index + 1;
|
||||
self.v.get(self.index - 1)
|
||||
|
@ -59,29 +59,28 @@ std::unique_ptr<std::string> c_return_unique_ptr_string() {
|
||||
}
|
||||
|
||||
std::unique_ptr<std::vector<uint8_t>> c_return_unique_ptr_vector_u8() {
|
||||
auto retval =
|
||||
std::unique_ptr<std::vector<uint8_t>>(new std::vector<uint8_t>());
|
||||
retval->push_back(86);
|
||||
retval->push_back(75);
|
||||
retval->push_back(30);
|
||||
retval->push_back(9);
|
||||
return retval;
|
||||
auto vec = std::unique_ptr<std::vector<uint8_t>>(new std::vector<uint8_t>());
|
||||
vec->push_back(86);
|
||||
vec->push_back(75);
|
||||
vec->push_back(30);
|
||||
vec->push_back(9);
|
||||
return vec;
|
||||
}
|
||||
|
||||
std::unique_ptr<std::vector<double>> c_return_unique_ptr_vector_f64() {
|
||||
auto retval = std::unique_ptr<std::vector<double>>(new std::vector<double>());
|
||||
retval->push_back(86.0);
|
||||
retval->push_back(75.0);
|
||||
retval->push_back(30.0);
|
||||
retval->push_back(9.5);
|
||||
return retval;
|
||||
auto vec = std::unique_ptr<std::vector<double>>(new std::vector<double>());
|
||||
vec->push_back(86.0);
|
||||
vec->push_back(75.0);
|
||||
vec->push_back(30.0);
|
||||
vec->push_back(9.5);
|
||||
return vec;
|
||||
}
|
||||
|
||||
std::unique_ptr<std::vector<Shared>> c_return_unique_ptr_vector_shared() {
|
||||
auto retval = std::unique_ptr<std::vector<Shared>>(new std::vector<Shared>());
|
||||
retval->push_back(Shared{1010});
|
||||
retval->push_back(Shared{1011});
|
||||
return retval;
|
||||
auto vec = std::unique_ptr<std::vector<Shared>>(new std::vector<Shared>());
|
||||
vec->push_back(Shared{1010});
|
||||
vec->push_back(Shared{1011});
|
||||
return vec;
|
||||
}
|
||||
|
||||
void c_take_primitive(size_t n) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user