1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-01 10:52:19 +01:00

[api] Use C++17 nested namespace syntax (#9856)

This commit is contained in:
J. Nick Koston
2025-07-23 21:15:42 -10:00
committed by GitHub
parent 705ea4ebaa
commit c74f12be98
27 changed files with 62 additions and 124 deletions

View File

@@ -2045,8 +2045,7 @@ def main() -> None:
#include "proto.h"
namespace esphome {
namespace api {
namespace esphome::api {
"""
@@ -2057,8 +2056,7 @@ namespace api {
#include "esphome/core/helpers.h"
#include <cstring>
namespace esphome {
namespace api {
namespace esphome::api {
"""
@@ -2072,8 +2070,7 @@ namespace api {
#ifdef HAS_PROTO_MESSAGE_DUMP
namespace esphome {
namespace api {
namespace esphome::api {
// Helper function to append a quoted string, handling empty StringRef
static inline void append_quoted_string(std::string &out, const StringRef &ref) {
@@ -2265,19 +2262,16 @@ static void dump_field(std::string &out, const char *field_name, T value, int in
content += """\
} // namespace api
} // namespace esphome
} // namespace esphome::api
"""
cpp += """\
} // namespace api
} // namespace esphome
} // namespace esphome::api
"""
dump_cpp += """\
} // namespace api
} // namespace esphome
} // namespace esphome::api
#endif // HAS_PROTO_MESSAGE_DUMP
"""
@@ -2299,8 +2293,7 @@ static void dump_field(std::string &out, const char *field_name, T value, int in
#include "api_pb2.h"
namespace esphome {
namespace api {
namespace esphome::api {
"""
@@ -2309,8 +2302,7 @@ namespace api {
#include "api_pb2_service.h"
#include "esphome/core/log.h"
namespace esphome {
namespace api {
namespace esphome::api {
static const char *const TAG = "api.service";
@@ -2451,13 +2443,11 @@ static const char *const TAG = "api.service";
hpp += """\
} // namespace api
} // namespace esphome
} // namespace esphome::api
"""
cpp += """\
} // namespace api
} // namespace esphome
} // namespace esphome::api
"""
with open(root / "api_pb2_service.h", "w", encoding="utf-8") as f: