1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 08:41:59 +00:00
This commit is contained in:
J. Nick Koston
2025-12-06 23:30:15 -06:00
parent 5264584202
commit 36036014cc
3 changed files with 0 additions and 24 deletions

View File

@@ -19,7 +19,6 @@ from esphome.cpp_generator import ( # noqa: F401
RawExpression,
RawStatement,
Statement,
StringRefLiteral,
StructInitializer,
TemplateArguments,
add,

View File

@@ -243,23 +243,6 @@ class LogStringLiteral(Literal):
return f"LOG_STR({cpp_string_escape(self.string)})"
class StringRefLiteral(Literal):
"""A StringRef literal using from_lit() for compile-time string references.
Uses StringRef::from_lit() which stores pointer + length (8 bytes) instead of
std::string (24-32 bytes + heap allocation). The string data stays in flash.
"""
__slots__ = ("string",)
def __init__(self, string: str) -> None:
super().__init__()
self.string = string
def __str__(self) -> str:
return f"StringRef::from_lit({cpp_string_escape(self.string)})"
class IntLiteral(Literal):
__slots__ = ("i",)

View File

@@ -248,12 +248,6 @@ class TestLiterals:
(cg.FloatLiteral(4.2), "4.2f"),
(cg.FloatLiteral(1.23456789), "1.23456789f"),
(cg.FloatLiteral(math.nan), "NAN"),
(cg.StringRefLiteral("foo"), 'StringRef::from_lit("foo")'),
(cg.StringRefLiteral(""), 'StringRef::from_lit("")'),
(
cg.StringRefLiteral('with "quotes"'),
'StringRef::from_lit("with \\042quotes\\042")',
),
),
)
def test_str__simple(self, target: cg.Literal, expected: str):