David Tolnay
78a5f8d123
Restyle Box::value_type deprecation to be preserved in generated code
2020-12-28 11:40:38 -08:00
David Tolnay
f62458f075
Define member type Slice<T>::value_type = T
2020-12-27 19:38:43 -08:00
David Tolnay
e47a4d94d0
Rename Box value_type to element_type
...
This matches the member type naming on unique_ptr.
https://en.cppreference.com/w/cpp/memory/unique_ptr#Member_types
It appears value_type is for a member type of a container or iterator
while element_type is for the target of a smart pointer.
2020-12-27 19:35:24 -08:00
David Tolnay
725bf505b4
Reuse Slice<T>'s iterator for Vec iteration too
2020-12-27 13:38:44 -08:00
David Tolnay
e1df7ddba0
Eliminate Vec stride symbol in favor of size_of
2020-12-27 13:29:06 -08:00
David Tolnay
5ce110e807
Update Slice implementation to respect runtime size_of
2020-12-27 13:19:45 -08:00
David Tolnay
eee622c4ac
Obtain accurate alignment for empty slice of opaque Rust type
2020-12-27 13:08:09 -08:00
David Tolnay
6f92baa8ff
Obtain Slice iterator stride in a way that works for opaque types
2020-12-27 12:59:47 -08:00
David Tolnay
a1ddbf846f
Track stride as runtime value in Slice iterator
2020-12-27 12:52:02 -08:00
David Tolnay
c30e447134
Expand Slice iterator to be random access iterator
2020-12-27 12:43:48 -08:00
David Tolnay
db388c9090
Update Slice iterator definition to follow canonical signatures
2020-12-27 12:43:48 -08:00
David Tolnay
78dd535756
Add checked and unchecked indexing to rust::Slice
2020-12-27 12:32:22 -08:00
David Tolnay
ee6ecfcf91
Add rust::size_of, align_of accessors that work for opaque types
2020-12-27 12:20:25 -08:00
David Tolnay
7506863fa4
Move is_complete type trait to header
2020-12-27 12:20:25 -08:00
David Tolnay
0c9c3e6e33
Use the same ordering of < <= > >= operators everywhere
2020-12-27 00:52:25 -08:00
David Tolnay
fa5a4a6b5b
Add debug assertions to some Vec indexing
2020-12-21 14:08:08 -08:00
David Tolnay
d4fff5d951
Mark Vec front/back noexcept
2020-12-21 14:04:11 -08:00
David Tolnay
cca2e616e0
Add c_str() member function for rust::String
2020-12-18 12:49:56 -08:00
David Tolnay
be3cbf7694
Use integer standard library types from std namespace
...
The implementation is not required to define these types in the global
namespace.
2020-12-12 22:16:01 -08:00
David Tolnay
74dd66f781
Import sys/types.h for ssize_t
...
Previously the header file generated for the following bridge did not
compile.
#[cxx::bridge]
mod ffi {
struct S {
x: isize,
}
}
example-ecfac19134395bcc/out/cxxbridge/sources/example/src/main.rs.cc:15:15: error: ‘ssize_t’ does not name a type
15 | using isize = ssize_t;
| ^~~~~~~
example-ecfac19134395bcc/out/cxxbridge/sources/example/src/main.rs.cc:26:11: error: ‘isize’ in namespace ‘rust’ does not name a type
26 | ::rust::isize x;
| ^~~~~
2020-12-12 22:03:58 -08:00
David Tolnay
1e784a3487
Add aliases for the Rust numeric primitives
2020-12-12 21:34:52 -08:00
David Tolnay
2e637d96d1
Format with clang-format 10
2020-12-12 21:08:01 -08:00
David Tolnay
439ed0b91a
Remove unneeded self check in Box<T>::operator=
...
As long as T's operator= correctly handles self assignment, this logic
is correct without the additional check.
2020-12-12 17:01:06 -08:00
David Tolnay
f448e20075
Hide raw alloc/dealloc functions
2020-12-12 16:42:45 -08:00
David Tolnay
e7d662d51d
Free Box allocation on T constructor exception
2020-12-12 16:38:22 -08:00
David Tolnay
e5703162e8
Move Box alloc/dealloc functions to guard object
2020-12-12 16:31:01 -08:00
David Tolnay
25b3c1d1e2
Add dealloc shim for Box to dealloc without running T's Drop
2020-12-12 16:29:34 -08:00
David Tolnay
c5dc45a0b3
Fix uninitialized Drop on exception in rust::Box<T>::in_place
2020-12-12 15:44:46 -08:00
David Tolnay
c4b3422dee
Delete private Box default constructor
2020-12-12 15:24:52 -08:00
David Tolnay
665178e914
Fix omitted typenames incompatible with Visual C++ 2015
2020-12-12 08:50:07 -08:00
David Tolnay
dd42c72287
Add Vec copy assignment operator
2020-12-11 14:05:26 -08:00
David Tolnay
9007e46b03
Add Vec copy constructor
2020-12-11 14:05:12 -08:00
David Tolnay
dc62d713bc
Expose Vec capacity to C++
2020-12-11 13:53:17 -08:00
David Tolnay
300072b5f3
Touch up PR 538
2020-12-03 12:27:27 -08:00
Yan Zaretskiy
efd5cd443c
Implement the random access iterator for rust::Vec
2020-12-03 09:22:22 -05:00
David Tolnay
908d5e5dc5
Add non-const indexing for rust::Vec
2020-11-30 00:37:22 -08:00
David Tolnay
f799b3781c
Add std::initializer_list constructor for rust::Vec
2020-11-30 00:11:30 -08:00
David Tolnay
ff86dce342
Add comparison operators for Str and String
2020-11-29 22:37:49 -08:00
David Tolnay
828e513a94
Add Str(const String &) noexcept constructor
2020-11-29 20:41:26 -08:00
David Tolnay
f031c32dca
Remove TryFn since throwing fn ptr are not implemented yet
2020-11-29 19:41:33 -08:00
David Tolnay
e468f05d8f
Link to bindings documentation on website from header
2020-11-29 19:39:35 -08:00
David Tolnay
ff7f5fb8cc
Add String and Str iterators
2020-11-25 21:06:33 -08:00
David Tolnay
d1df4c7621
Include <iterator> for input_iterator_tag
2020-11-25 20:38:16 -08:00
David Tolnay
ac6cb54e3b
Add iterator for rust::Slice
2020-11-25 20:27:32 -08:00
David Tolnay
7b16a39a02
Consider T alignment for empty rust::Slice
2020-11-25 20:23:14 -08:00
David Tolnay
248215e206
Replace uint8_t with char for byte-based computations in Vec iterator
2020-11-25 19:41:16 -08:00
David Tolnay
5515a9e820
Generalize SliceRef codegen to non-u8 element type
2020-11-25 19:34:42 -08:00
David Tolnay
a857c32d40
Public deleted Opaque special members to resolve modernize-use-equals-delete
...
include/cxx.h:303:3: warning: deleted member function should be public [modernize-use-equals-delete]
Opaque() = delete;
^
include/cxx.h:304:3: warning: deleted member function should be public [modernize-use-equals-delete]
Opaque(const Opaque &) = delete;
^
include/cxx.h:305:3: warning: deleted member function should be public [modernize-use-equals-delete]
~Opaque() = delete;
^
2020-11-25 16:27:25 -08:00
David Tolnay
365fc7c66a
Add common base class for opaque Rust types
2020-11-25 16:22:54 -08:00
David Tolnay
a5d72c6b99
Share type between Vec<T>::const_iterator and Vec<const T>::iterator
2020-11-25 14:36:59 -08:00