Merge remote-tracking branch 'upstream/devirtualize-api-dispatch' into integration

This commit is contained in:
J. Nick Koston
2026-03-20 21:31:54 -10:00
4 changed files with 15 additions and 7 deletions
+7 -3
View File
@@ -2971,7 +2971,9 @@ namespace esphome::api {
cpp = FILE_HEADER
cpp += """\
#include "api_pb2_service.h"
#ifdef USE_API
#include "api_connection.h"
#endif
#include "esphome/core/log.h"
namespace esphome::api {
@@ -3073,11 +3075,12 @@ static const char *const TAG = "api.service";
result += "#endif\n"
return result
# Generate read_message as APIConnection method (not base class) so the compiler
# Generate read_message_ as APIConnection method (not base class) so the compiler
# can devirtualize and inline the on_* handler calls within the same class.
# APIConnection declares the override in api_connection.h.
# APIConnection declares this method in api_connection.h.
out = "void APIConnection::read_message_(uint32_t msg_size, uint32_t msg_type, const uint8_t *msg_data) {\n"
out = "#ifdef USE_API\n"
out += "void APIConnection::read_message_(uint32_t msg_size, uint32_t msg_type, const uint8_t *msg_data) {\n"
# Auth check block before dispatch switch
out += " // Check authentication/connection requirements\n"
@@ -3122,6 +3125,7 @@ static const char *const TAG = "api.service";
out += " break;\n"
out += " }\n"
out += "}\n"
out += "#endif // USE_API\n"
cpp += out
hpp += "};\n"