Skip to content

Commit 7020551

Browse files
committed
chore: Replace fmt::format with std::format
Signed-off-by: GitHub <noreply@github.com>
1 parent a1e7041 commit 7020551

25 files changed

+727
-777
lines changed

CMakeLists.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,8 @@ endif()
5050
# if CMAKE_SYSTEM_NAME is WASI disable the exceptions
5151
if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
5252
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
53-
54-
set(FMT_OS OFF CACHE BOOL "" FORCE)
5553
endif()
5654

57-
FetchContent_Declare(
58-
fmt
59-
GIT_REPOSITORY https://github.com/fmtlib/fmt
60-
GIT_TAG 11.0.2
61-
GIT_SHALLOW 1
62-
)
63-
64-
# set FMT_INSTALL to OFF to avoid installing fmt
65-
set(FMT_INSTALL OFF CACHE BOOL "" FORCE)
66-
67-
FetchContent_MakeAvailable(fmt)
68-
6955
FetchContent_Declare(
7056
utfcpp
7157
GIT_REPOSITORY https://github.com/nemtrif/utfcpp

packages/cxx-gen-ast/src/gen_ast_dump_cc.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export function gen_ast_dump_cc({ ast, output }: { ast: AST; output: string }) {
4040
if (member.kind === "node-list") {
4141
emit(` if (ast->${member.name}) {`);
4242
emit(` ++indent_;`);
43-
emit(` out_ << cxx::format("{:{}}", "", indent_ * 2);`);
44-
emit(` out_ << cxx::format("{}\\n", "${fieldName}");`);
43+
emit(` out_ << std::format("{:{}}", "", indent_ * 2);`);
44+
emit(` out_ << std::format("{}\\n", "${fieldName}");`);
4545
emit(` for (auto it = ast->${member.name}; it; it = it->next) {`);
4646
emit(` accept(it->value);`);
4747
emit(` }`);
@@ -54,25 +54,25 @@ export function gen_ast_dump_cc({ ast, output }: { ast: AST; output: string }) {
5454
} else if (member.kind == "attribute" && member.type === "bool") {
5555
emit(` if (ast->${member.name}) {`);
5656
emit(` ++indent_;`);
57-
emit(` out_ << cxx::format("{:{}}", "", indent_ * 2);`);
57+
emit(` out_ << std::format("{:{}}", "", indent_ * 2);`);
5858
emit(
59-
` out_ << cxx::format("${fieldName}: {}\\n", ast->${member.name});`,
59+
` out_ << std::format("${fieldName}: {}\\n", ast->${member.name});`
6060
);
6161
emit(` --indent_;`);
6262
emit(` }`);
6363
} else if (member.kind == "attribute" && member.type === "int") {
6464
emit(` ++indent_;`);
65-
emit(` out_ << cxx::format("{:{}}", "", indent_ * 2);`);
65+
emit(` out_ << std::format("{:{}}", "", indent_ * 2);`);
6666
emit(
67-
` out_ << cxx::format("${fieldName}: {}\\n", ast->${member.name});`,
67+
` out_ << std::format("${fieldName}: {}\\n", ast->${member.name});`
6868
);
6969
emit(` --indent_;`);
7070
} else if (member.kind == "attribute" && member.type.endsWith("Literal")) {
7171
emit(` if (ast->${member.name}) {`);
7272
emit(` ++indent_;`);
73-
emit(` out_ << cxx::format("{:{}}", "", indent_ * 2);`);
73+
emit(` out_ << std::format("{:{}}", "", indent_ * 2);`);
7474
emit(
75-
` out_ << cxx::format("${fieldName}: {}\\n", ast->${member.name}->value());`,
75+
` out_ << std::format("${fieldName}: {}\\n", ast->${member.name}->value());`
7676
);
7777
emit(` --indent_;`);
7878
emit(` }`);
@@ -82,9 +82,9 @@ export function gen_ast_dump_cc({ ast, output }: { ast: AST; output: string }) {
8282
) {
8383
emit(` if (ast->${member.name} != TokenKind::T_EOF_SYMBOL) {`);
8484
emit(` ++indent_;`);
85-
emit(` out_ << cxx::format("{:{}}", "", indent_ * 2);`);
85+
emit(` out_ << std::format("{:{}}", "", indent_ * 2);`);
8686
emit(
87-
` out_ << cxx::format("${fieldName}: {}\\n", Token::spell(ast->${member.name}));`,
87+
` out_ << std::format("${fieldName}: {}\\n", Token::spell(ast->${member.name}));`
8888
);
8989
emit(` --indent_;`);
9090
emit(` }`);
@@ -93,9 +93,9 @@ export function gen_ast_dump_cc({ ast, output }: { ast: AST; output: string }) {
9393
member.type == "ImplicitCastKind"
9494
) {
9595
emit(` ++indent_;`);
96-
emit(` out_ << cxx::format("{:{}}", "", indent_ * 2);`);
96+
emit(` out_ << std::format("{:{}}", "", indent_ * 2);`);
9797
emit(
98-
` out_ << cxx::format("${fieldName}: {}\\n", to_string(ast->${member.name}));`,
98+
` out_ << std::format("${fieldName}: {}\\n", to_string(ast->${member.name}));`
9999
);
100100
emit(` --indent_;`);
101101
}
@@ -105,7 +105,7 @@ export function gen_ast_dump_cc({ ast, output }: { ast: AST; output: string }) {
105105
nodes.forEach(({ name, base, members }) => {
106106
emit();
107107
emit(`void ASTPrinter::visit(${name}* ast) {`);
108-
emit(` out_ << cxx::format("{}\\n", "${astName(name)}");`);
108+
emit(` out_ << std::format("{}\\n", "${astName(name)}");`);
109109

110110
const baseMembers = ast.baseMembers.get(base);
111111

@@ -135,7 +135,7 @@ export function gen_ast_dump_cc({ ast, output }: { ast: AST; output: string }) {
135135
#include <cxx/translation_unit.h>
136136
#include <cxx/names.h>
137137
#include <cxx/literals.h>
138-
#include <cxx/private/format.h>
138+
#include <format>
139139
140140
#include <algorithm>
141141
#include <iostream>
@@ -153,9 +153,9 @@ void ASTPrinter::operator()(AST* ast) {
153153
void ASTPrinter::accept(AST* ast, std::string_view field) {
154154
if (!ast) return;
155155
++indent_;
156-
out_ << cxx::format("{:{}}", "", indent_ * 2);
156+
out_ << std::format("{:{}}", "", indent_ * 2);
157157
if (!field.empty()) {
158-
out_ << cxx::format("{}: ", field);
158+
out_ << std::format("{}: ", field);
159159
}
160160
ast->accept(this);
161161
--indent_;
@@ -164,9 +164,9 @@ void ASTPrinter::accept(AST* ast, std::string_view field) {
164164
void ASTPrinter::accept(const Identifier* id, std::string_view field) {
165165
if (!id) return;
166166
++indent_;
167-
out_ << cxx::format("{:{}}", "", indent_ * 2);
168-
if (!field.empty()) out_ << cxx::format("{}: ", field);
169-
out_ << cxx::format("{}\\n", id->value());
167+
out_ << std::format("{:{}}", "", indent_ * 2);
168+
if (!field.empty()) out_ << std::format("{}: ", field);
169+
out_ << std::format("{}\\n", id->value());
170170
--indent_;
171171
}
172172

packages/cxx-gen-ast/src/gen_ast_encoder_cc.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function gen_ast_encoder_cc({
4444
const emitLiteral = (
4545
m: Attribute,
4646
table: string,
47-
finalizers: (() => void)[],
47+
finalizers: (() => void)[]
4848
) => {
4949
const fieldName = toSnakeName(m.name);
5050

@@ -70,7 +70,7 @@ export function gen_ast_encoder_cc({
7070
const className = makeClassName(base);
7171
emit();
7272
emit(
73-
` auto ASTEncoder::accept${className}(${base}* ast) -> std::tuple<flatbuffers::Offset<>, std::uint32_t> {`,
73+
` auto ASTEncoder::accept${className}(${base}* ast) -> std::tuple<flatbuffers::Offset<>, std::uint32_t> {`
7474
);
7575
emit(` if (!ast) return {};`);
7676
emit(` flatbuffers::Offset<> offset;`);
@@ -201,7 +201,7 @@ export function gen_ast_encoder_cc({
201201
#include <cxx/literals.h>
202202
#include <cxx/names.h>
203203
#include <cxx/translation_unit.h>
204-
#include <cxx/private/format.h>
204+
#include <format>
205205
206206
#include <algorithm>
207207

0 commit comments

Comments
 (0)