mirror of
https://github.com/esphome/esphome.git
synced 2025-07-28 14:16:40 +00:00
Resolve esphome::optional vs std::optional ambiguity in code generation (#9119)
This commit is contained in:
parent
78c8447d1e
commit
bf161f1eaa
@ -29,7 +29,9 @@ Component = esphome_ns.class_("Component")
|
|||||||
ComponentPtr = Component.operator("ptr")
|
ComponentPtr = Component.operator("ptr")
|
||||||
PollingComponent = esphome_ns.class_("PollingComponent", Component)
|
PollingComponent = esphome_ns.class_("PollingComponent", Component)
|
||||||
Application = esphome_ns.class_("Application")
|
Application = esphome_ns.class_("Application")
|
||||||
optional = esphome_ns.class_("optional")
|
# Create optional with explicit namespace to avoid ambiguity with std::optional
|
||||||
|
# The generated code will use esphome::optional instead of just optional
|
||||||
|
optional = global_ns.namespace("esphome").class_("optional")
|
||||||
arduino_json_ns = global_ns.namespace("ArduinoJson")
|
arduino_json_ns = global_ns.namespace("ArduinoJson")
|
||||||
JsonObject = arduino_json_ns.class_("JsonObject")
|
JsonObject = arduino_json_ns.class_("JsonObject")
|
||||||
JsonObjectConst = arduino_json_ns.class_("JsonObjectConst")
|
JsonObjectConst = arduino_json_ns.class_("JsonObjectConst")
|
||||||
|
@ -66,5 +66,5 @@ def test_text_config_lamda_is_set(generate_main):
|
|||||||
main_cpp = generate_main("tests/component_tests/text/test_text.yaml")
|
main_cpp = generate_main("tests/component_tests/text/test_text.yaml")
|
||||||
|
|
||||||
# Then
|
# Then
|
||||||
assert "it_4->set_template([=]() -> optional<std::string> {" in main_cpp
|
assert "it_4->set_template([=]() -> esphome::optional<std::string> {" in main_cpp
|
||||||
assert 'return std::string{"Hello"};' in main_cpp
|
assert 'return std::string{"Hello"};' in main_cpp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user