Skip to content

Commit 06f1694

Browse files
committed
Renamte vtable impl -> virtual methods
1 parent e893fd2 commit 06f1694

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

‎cpp2rust/converter/converter.cpp‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ std::unordered_set<std::string> Converter::globals_;
2929
std::vector<std::string> Converter::global_inits_;
3030
std::unordered_set<std::string> Converter::abstract_structs_;
3131
Converter::RecordIndex Converter::record_decls_;
32-
std::map<std::string, Converter::DeferredBlock> Converter::vtable_impls_;
32+
std::map<std::string, Converter::DeferredBlock> Converter::virtual_methods_;
3333

3434
void Converter::ConvertUniquePtrDeref(clang::CXXOperatorCallExpr *expr) {
3535
bool is_star = expr->getOperator() == clang::OverloadedOperatorKind::OO_Star;
@@ -68,8 +68,8 @@ void Converter::EmitDeferredBlock(const DeferredBlock &block,
6868
out += "}\n";
6969
}
7070

71-
void Converter::EmitVTableImpls(std::string &out) {
72-
for (const auto &[name, impl] : vtable_impls_) {
71+
void Converter::EmitVirtualMethods(std::string &out) {
72+
for (const auto &[name, impl] : virtual_methods_) {
7373
EmitDeferredBlock(impl, out);
7474
}
7575
}
@@ -868,7 +868,7 @@ void Converter::EmitRustStructOrUnion(clang::RecordDecl *decl) {
868868
// C++ method decls
869869
if (auto *cxx = clang::dyn_cast<clang::CXXRecordDecl>(decl)) {
870870
ConvertCXXRecordMethods(cxx);
871-
ConvertVTableMethods(cxx);
871+
ConvertVirtualMethods(cxx);
872872
}
873873

874874
// Traits
@@ -1065,7 +1065,7 @@ bool Converter::VisitCXXMethodDecl(clang::CXXMethodDecl *decl) {
10651065
PushCurrFunction push_fn(*this, decl);
10661066

10671067
if (decl->isOutOfLine() && !decl->overridden_methods().empty()) {
1068-
return ConvertVTableMethod(decl);
1068+
return ConvertOutOfLineVirtualMethod(decl);
10691069
}
10701070
if (decl->isOutOfLine() && !decl->isTemplateInstantiation()) {
10711071
return ConvertOutOfLineMethod(decl);
@@ -4465,9 +4465,9 @@ void Converter::ConvertCXXMethodDecls(
44654465
}
44664466

44674467
Converter::DeferredBlock &
4468-
Converter::VTableImplFor(const clang::CXXRecordDecl *decl) {
4468+
Converter::VirtualMethodsFor(const clang::CXXRecordDecl *decl) {
44694469
auto name = GetRecordName(decl);
4470-
auto [it, inserted] = vtable_impls_.try_emplace(name);
4470+
auto [it, inserted] = virtual_methods_.try_emplace(name);
44714471
if (inserted) {
44724472
it->second.header = std::format(
44734473
"{} impl {} for {}", keyword_unsafe_,
@@ -4476,7 +4476,7 @@ Converter::VTableImplFor(const clang::CXXRecordDecl *decl) {
44764476
return it->second;
44774477
}
44784478

4479-
void Converter::ConvertVTableMethods(clang::CXXRecordDecl *decl) {
4479+
void Converter::ConvertVirtualMethods(clang::CXXRecordDecl *decl) {
44804480
if (decl->bases_begin() == decl->bases_end()) {
44814481
return;
44824482
}
@@ -4492,17 +4492,17 @@ void Converter::ConvertVTableMethods(clang::CXXRecordDecl *decl) {
44924492
if (!any) {
44934493
return;
44944494
}
4495-
VTableImplFor(decl).body += body;
4495+
VirtualMethodsFor(decl).body += body;
44964496
}
44974497

4498-
bool Converter::ConvertVTableMethod(clang::CXXMethodDecl *decl) {
4498+
bool Converter::ConvertOutOfLineVirtualMethod(clang::CXXMethodDecl *decl) {
44994499
auto *record = decl->getParent();
45004500
if (record->bases_begin() == record->bases_end()) {
45014501
return false;
45024502
}
45034503
Buffer buf(*this);
45044504
auto emitted = ConvertCXXMethodDecl(decl);
4505-
VTableImplFor(record).body += std::move(buf).str();
4505+
VirtualMethodsFor(record).body += std::move(buf).str();
45064506
return emitted;
45074507
}
45084508

‎cpp2rust/converter/converter.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
5555
static void EmitOpaqueRecords(std::string &out);
5656
static void EmitGlobalInits(Model model, std::string &out);
5757

58-
static void EmitVTableImpls(std::string &out);
58+
static void EmitVirtualMethods(std::string &out);
5959

6060
virtual bool VisitBuiltinType(clang::BuiltinType *type);
6161

@@ -603,9 +603,9 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
603603
const std::string_view signature,
604604
bool (*predicate)(clang::CXXMethodDecl *));
605605

606-
void ConvertVTableMethods(clang::CXXRecordDecl *decl);
606+
void ConvertVirtualMethods(clang::CXXRecordDecl *decl);
607607

608-
bool ConvertVTableMethod(clang::CXXMethodDecl *decl);
608+
bool ConvertOutOfLineVirtualMethod(clang::CXXMethodDecl *decl);
609609

610610
void AddOrdTrait(const clang::CXXRecordDecl *decl);
611611

@@ -914,11 +914,11 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
914914
std::string header;
915915
std::string body;
916916
};
917-
static std::map<std::string, DeferredBlock> vtable_impls_;
917+
static std::map<std::string, DeferredBlock> virtual_methods_;
918918

919919
static void EmitDeferredBlock(const DeferredBlock &block, std::string &out);
920920

921-
DeferredBlock &VTableImplFor(const clang::CXXRecordDecl *decl);
921+
DeferredBlock &VirtualMethodsFor(const clang::CXXRecordDecl *decl);
922922

923923
std::string hoisted_records_;
924924

‎cpp2rust/cpp2rust_lib.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ std::string TranspileSrc(std::string_view cc_code, Model model,
3232
cc_code, tool_args, std::filesystem::path(filename).filename().string(),
3333
filename.ends_with(".c") ? CLANG_C_COMPILER : CLANG_CXX_COMPILER);
3434
Converter::EmitOpaqueRecords(rs_code);
35-
Converter::EmitVTableImpls(rs_code);
35+
Converter::EmitVirtualMethods(rs_code);
3636
if (model == Model::kRefCount) {
3737
ConverterRefCount::EmitMethodsOnPtr(rs_code);
3838
}
@@ -77,7 +77,7 @@ std::string TranspileDir(std::string_view build_dir, Model model,
7777
FrontendActionFactory factory(rs_code, model, rules_dir);
7878
Tool.run(&factory);
7979
Converter::EmitOpaqueRecords(rs_code);
80-
Converter::EmitVTableImpls(rs_code);
80+
Converter::EmitVirtualMethods(rs_code);
8181
if (model == Model::kRefCount) {
8282
ConverterRefCount::EmitMethodsOnPtr(rs_code);
8383
}

0 commit comments

Comments
 (0)