Skip to content

Commit 6da60bd

Browse files
committed
pod -> reinterpret and UnionStore -> UnionStorage
1 parent 2427859 commit 6da60bd

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

cpp2rust/converter/models/converter_refcount.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ void ConverterRefCount::AddDefaultTraitForUnion(const clang::RecordDecl *decl) {
474474
PushBrace impl_brace(*this);
475475
StrCat("fn default() -> Self");
476476
PushBrace fn_brace(*this);
477-
StrCat(std::format("{} {{ __store: libcc2rs::UnionStore::new({}) }}", name,
477+
StrCat(std::format("{} {{ __store: libcc2rs::UnionStorage::new({}) }}", name,
478478
ctx_.getASTRecordLayout(decl).getSize().getQuantity()));
479479
}
480480

@@ -491,14 +491,14 @@ void ConverterRefCount::EmitRustUnion(clang::RecordDecl *decl) {
491491
StrCat(")]");
492492

493493
StrCat(
494-
std::format("pub struct {} {{ __store: libcc2rs::UnionStore, }}", name));
494+
std::format("pub struct {} {{ __store: libcc2rs::UnionStorage, }}", name));
495495

496496
StrCat(std::format("impl {}", name));
497497
{
498498
PushBrace impl_brace(*this);
499499
for (auto *field : decl->fields()) {
500500
StrCat(std::format(
501-
"pub fn {}(&self) -> Ptr<{}> {{ self.__store.pod(0) }}",
501+
"pub fn {}(&self) -> Ptr<{}> {{ self.__store.reinterpret(0) }}",
502502
GetNamedDeclAsString(field), Mapper::Map(field->getType())));
503503
}
504504
}

libcc2rs/src/union.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@ use std::{cell::RefCell, rc::Rc};
66
use crate::Ptr;
77
use crate::reinterpret::{ByteRepr, OriginalAlloc, SliceOriginalAlloc};
88

9-
pub struct UnionStore {
9+
pub struct UnionStorage {
1010
bytes: Rc<RefCell<Vec<u8>>>,
1111
}
1212

13-
impl UnionStore {
13+
impl UnionStorage {
1414
pub fn new(size: usize) -> Self {
15-
UnionStore {
15+
UnionStorage {
1616
bytes: Rc::new(RefCell::new(vec![0u8; size])),
1717
}
1818
}
1919

20-
pub fn pod<T: ByteRepr>(&self, offset: usize) -> Ptr<T> {
20+
pub fn reinterpret<T: ByteRepr>(&self, offset: usize) -> Ptr<T> {
2121
let alloc: Rc<dyn OriginalAlloc> = Rc::new(SliceOriginalAlloc {
2222
weak: Rc::downgrade(&self.bytes),
2323
});
2424
Ptr::reinterpreted(alloc, offset)
2525
}
2626
}
2727

28-
impl Clone for UnionStore {
28+
impl Clone for UnionStorage {
2929
fn clone(&self) -> Self {
30-
UnionStore {
30+
UnionStorage {
3131
bytes: Rc::new(RefCell::new(self.bytes.borrow().clone())),
3232
}
3333
}

0 commit comments

Comments
 (0)