mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
gccrs: rust-fmt: Store parsed string in Pieces struct
gcc/rust/ChangeLog: * ast/rust-fmt.cc (Pieces::collect): Fix signature to take ownership of the given string. * ast/rust-fmt.h (struct Pieces): Store parsed string in the struct. libgrust/ChangeLog: * libformat_parser/src/lib.rs: Add debug prompt.
This commit is contained in:
parent
827231aac4
commit
0f9668507c
@ -23,7 +23,7 @@ namespace Rust {
|
||||
namespace Fmt {
|
||||
|
||||
Pieces
|
||||
Pieces::collect (const std::string &to_parse)
|
||||
Pieces::collect (std::string &&to_parse)
|
||||
{
|
||||
auto piece_slice = collect_pieces (to_parse.c_str ());
|
||||
|
||||
@ -34,7 +34,7 @@ Pieces::collect (const std::string &to_parse)
|
||||
// auto pieces = std::vector<Piece> (piece_slice.base_ptr,
|
||||
// piece_slice.base_ptr + piece_slice.len);
|
||||
|
||||
return Pieces (piece_slice);
|
||||
return Pieces (piece_slice, std::move (to_parse));
|
||||
}
|
||||
|
||||
Pieces::~Pieces () { destroy_pieces (slice); }
|
||||
|
@ -251,13 +251,16 @@ void destroy_pieces (PieceSlice);
|
||||
|
||||
struct Pieces
|
||||
{
|
||||
static Pieces collect (const std::string &to_parse);
|
||||
static Pieces collect (std::string &&to_parse);
|
||||
~Pieces ();
|
||||
|
||||
private:
|
||||
Pieces (PieceSlice slice) : slice (slice) {}
|
||||
Pieces (PieceSlice slice, std::string &&to_parse)
|
||||
: slice (slice), to_parse (std::move (to_parse))
|
||||
{}
|
||||
|
||||
PieceSlice slice;
|
||||
std::string to_parse;
|
||||
};
|
||||
|
||||
} // namespace Fmt
|
||||
|
@ -340,6 +340,7 @@ pub struct PieceSlice {
|
||||
pub extern "C" fn collect_pieces(input: *const libc::c_char) -> PieceSlice {
|
||||
// FIXME: Add comment
|
||||
let str = unsafe { CStr::from_ptr(input) };
|
||||
dbg!(str);
|
||||
|
||||
// FIXME: No unwrap
|
||||
let pieces: Vec<ffi::Piece<'_>> = rust::collect_pieces(str.to_str().unwrap())
|
||||
|
Loading…
Reference in New Issue
Block a user