Lines Matching refs:AddLine
51 text.AddLine("// Automatic generation of D-Bus interfaces:");
53 text.AddLine(StringPrintf("// - %s", interface.name.c_str()));
56 text.AddLine(StringPrintf("#ifndef %s", header_guard.c_str()));
57 text.AddLine(StringPrintf("#define %s", header_guard.c_str()));
58 text.AddLine("#include <memory>");
59 text.AddLine("#include <string>");
60 text.AddLine("#include <vector>");
62 text.AddLine("#include <base/bind.h>");
63 text.AddLine("#include <base/callback.h>");
64 text.AddLine("#include <base/logging.h>");
65 text.AddLine("#include <base/macros.h>");
66 text.AddLine("#include <base/memory/ref_counted.h>");
67 text.AddLine("#include <brillo/any.h>");
68 text.AddLine("#include <brillo/dbus/dbus_method_invoker.h>");
69 text.AddLine("#include <brillo/dbus/dbus_property.h>");
70 text.AddLine("#include <brillo/dbus/dbus_signal_handler.h>");
71 text.AddLine("#include <brillo/errors/error.h>");
72 text.AddLine("#include <brillo/variant_dictionary.h>");
73 text.AddLine("#include <dbus/bus.h>");
74 text.AddLine("#include <dbus/message.h>");
75 text.AddLine("#include <dbus/object_manager.h>");
76 text.AddLine("#include <dbus/object_path.h>");
77 text.AddLine("#include <dbus/object_proxy.h>");
84 text.AddLine(StringPrintf("class %s;",
97 text.AddLine(StringPrintf("#endif // %s", header_guard.c_str()));
109 text.AddLine("// Automatic generation of D-Bus interface mock proxies for:");
111 text.AddLine(StringPrintf("// - %s", interface.name.c_str()));
114 text.AddLine(StringPrintf("#ifndef %s", header_guard.c_str()));
115 text.AddLine(StringPrintf("#define %s", header_guard.c_str()));
116 text.AddLine("#include <string>");
117 text.AddLine("#include <vector>");
119 text.AddLine("#include <base/callback_forward.h>");
120 text.AddLine("#include <base/logging.h>");
121 text.AddLine("#include <base/macros.h>");
122 text.AddLine("#include <brillo/any.h>");
123 text.AddLine("#include <brillo/errors/error.h>");
124 text.AddLine("#include <brillo/variant_dictionary.h>");
125 text.AddLine("#include <gmock/gmock.h>");
169 text.AddLine(StringPrintf("#include \"%s\"",
181 text.AddLine(StringPrintf("#endif // %s", header_guard.c_str()));
197 text->AddLine(StringPrintf("// Abstract interface proxy for %s.",
200 text->AddLine(StringPrintf("class %s {", base_interface_name.c_str()));
203 text->AddLine(
215 text->AddLine("virtual const dbus::ObjectPath& GetObjectPath() const = 0;");
220 text->AddLine("};");
238 text->AddLine(StringPrintf("// Interface proxy for %s.",
241 text->AddLine(StringPrintf("class %s final : public %s {",
269 text->AddLine("scoped_refptr<dbus::Bus> bus_;");
271 text->AddLine("std::string service_name_;");
273 text->AddLine(StringPrintf("const std::string service_name_{\"%s\"};",
277 text->AddLine("dbus::ObjectPath object_path_;");
279 text->AddLine(StringPrintf("const dbus::ObjectPath object_path_{\"%s\"};",
283 text->AddLine("PropertySet* property_set_;");
284 text->AddLine(
289 text->AddLine("dbus::ObjectProxy* dbus_object_proxy_;");
293 text->AddLine(StringPrintf(
297 text->AddLine(StringPrintf("DISALLOW_COPY_AND_ASSIGN(%s);",
300 text->AddLine("};");
321 text->AddLine(StringPrintf("// Mock object for %s.",
323 text->AddLine(StringPrintf("class %s : public %s {",
327 text->AddLine(StringPrintf("%s() = default;", mock_name.c_str()));
344 text->AddLine(StringPrintf("MOCK_CONST_METHOD0(%s, %s());",
347 text->AddLine(StringPrintf("MOCK_METHOD2(set_%s, void(%s, "
352 text->AddLine(
357 text->AddLine(StringPrintf(
369 text->AddLine("};");
390 block.AddLine(StringPrintf("%s(%s) :", class_name.c_str(),
393 block.AddLine(StringPrintf("%s(", class_name.c_str()));
396 block.AddLine(StringPrintf("%s,", GetParamString(args[i]).c_str()));
398 block.AddLine(StringPrintf("%s) :", GetParamString(args.back()).c_str()));
402 block.AddLine(StringPrintf("%s_{%s},", arg.name.c_str(),
405 block.AddLine("dbus_object_proxy_{");
412 block.AddLine("}");
421 block.AddLine(StringPrintf("~%s() override {", class_name.c_str()));
422 AddLine("}");
429 text->AddLine("void ReleaseObjectProxy(const base::Closure& callback) {");
433 text->AddLine("}");
439 text->AddLine("const dbus::ObjectPath& GetObjectPath() const override {");
441 text->AddLine("}");
447 text->AddLine("dbus::ObjectProxy* GetObjectProxy() const { "
456 text->AddLine(StringPrintf("%svoid SetPropertyChangedCallback(",
466 text->AddLine("}");
469 text->AddLine(
471 text->AddLine("PropertySet* GetProperties() { return property_set_; }");
477 text->AddLine("void OnPropertyChanged(const std::string& property_name) {");
479 text->AddLine("if (!on_property_changed_.is_null())");
481 text->AddLine("on_property_changed_.Run(this, property_name);");
484 text->AddLine("}");
495 block.AddLine(StringPrintf("%svoid Register%sSignalHandler(",
500 block.AddLine(StringPrintf(
506 block.AddLine("brillo::dbus_utils::ConnectToSignal(");
508 block.AddLine("dbus_object_proxy_,");
509 block.AddLine(StringPrintf("\"%s\",", interface_name.c_str()));
510 block.AddLine(StringPrintf("\"%s\",", signal.name.c_str()));
511 block.AddLine("signal_callback,");
512 block.AddLine("on_connected_callback);");
515 block.AddLine("}");
529 block.AddLine("class PropertySet : public dbus::PropertySet {");
534 block.AddLine("const PropertyChangedCallback& callback)");
538 block.AddLine(StringPrintf("\"%s\",", interface.name.c_str()));
539 block.AddLine("callback} {");
544 block.AddLine(
550 block.AddLine("}");
557 block.AddLine(
568 block.AddLine("};");
589 text->AddLine(
600 text->AddLine(
610 text->AddLine("}");
621 text->AddLine(
629 text->AddLine("}");
644 block.AddLine(StringPrintf("%sbool %s(",
656 block.AddLine(StringPrintf(
665 block.AddLine(StringPrintf(
668 block.AddLine("brillo::ErrorPtr* error,");
669 block.AddLine(
676 block.AddLine(
679 block.AddLine("timeout_ms,");
680 block.AddLine("dbus_object_proxy_,");
681 block.AddLine(StringPrintf("\"%s\",", interface_name.c_str()));
682 block.AddLine(StringPrintf("\"%s\",", method.name.c_str()));
685 block.AddLine(StringPrintf("%s,", last_argument.c_str()));
688 block.AddLine(StringPrintf("%s);", last_argument.c_str()));
691 block.AddLine("return response && "
694 block.AddLine(brillo::string_utils::Join(", ", out_param_names) + ");");
697 block.AddLine("}");
711 block.AddLine(StringPrintf("%svoid %sAsync(",
723 block.AddLine(StringPrintf(
735 block.AddLine(StringPrintf(
738 block.AddLine(
740 block.AddLine(
747 block.AddLine("brillo::dbus_utils::CallMethodWithTimeout(");
749 block.AddLine("timeout_ms,");
750 block.AddLine("dbus_object_proxy_,");
751 block.AddLine(StringPrintf("\"%s\",", interface_name.c_str()));
752 block.AddLine(StringPrintf("\"%s\",", method.name.c_str()));
753 block.AddLine("success_callback,");
756 block.AddLine(StringPrintf("%s,", last_argument.c_str()));
759 block.AddLine(StringPrintf("%s);", last_argument.c_str()));
763 block.AddLine("}");
842 block.AddLine(StringPrintf("%s,", arguments[i].c_str()));
843 AddLine(StringPrintf("%s) override {", arguments.back().c_str()));
846 block.AddLine(StringPrintf(
854 block.AddLine("return false;");
859 block.AddLine("}");
869 block.AddLine(StringPrintf("%s,", arguments[i].c_str()));
870 block.AddLine(StringPrintf("%s));", arguments.back().c_str()));
894 block.AddLine(arg_lines[i]);
896 block.AddLine(
910 block->AddLine(StringPrintf("const base::Closure& %s,",
923 block->AddLine(StringPrintf("%s,", last_argument.c_str()));
929 block->AddLine(StringPrintf("%s%s)>& %s,",
952 text->AddLine(StringPrintf("class %s : "
974 text->AddLine(StringPrintf("DISALLOW_COPY_AND_ASSIGN(%s);",
977 text->AddLine("};");
993 text->AddLine("const std::string& service_name)");
996 text->AddLine(StringPrintf("%s(const scoped_refptr<dbus::Bus>& bus)",
1000 text->AddLine(": bus_{bus},");
1003 text->AddLine("service_name_{service_name},");
1005 text->AddLine("dbus_object_manager_{bus->GetObjectManager(");
1008 text->AddLine("service_name,");
1010 text->AddLine(StringPrintf("\"%s\",", config.service_name.c_str()));
1012 text->AddLine(StringPrintf("dbus::ObjectPath{\"%s\"})} {",
1019 text->AddLine(
1024 text->AddLine("}");
1032 text->AddLine(StringPrintf("~%s() override {", class_name.c_str()));
1035 text->AddLine(
1040 text->AddLine("}");
1046 text->AddLine("dbus::ObjectManager* GetObjectManagerProxy() const {");
1048 text->AddLine("}");
1061 text->AddLine(StringPrintf("%sInterface* Get%s(",
1065 text->AddLine("const dbus::ObjectPath& object_path) {");
1068 text->AddLine(StringPrintf("auto p = %s.find(object_path);",
1070 text->AddLine(StringPrintf("if (p != %s.end())", map_name.c_str()));
1072 text->AddLine("return p->second.get();");
1074 text->AddLine("return nullptr;");
1076 text->AddLine("}");
1080 text->AddLine(StringPrintf("%sInterface* Get%s() {",
1084 text->AddLine(StringPrintf("if (%s.empty())", map_name.c_str()));
1086 text->AddLine(StringPrintf("return %s.begin()->second.get();",
1089 text->AddLine("}");
1093 text->AddLine(
1098 text->AddLine(StringPrintf("std::vector<%sInterface*> values;",
1100 text->AddLine(StringPrintf("values.reserve(%s.size());", map_name.c_str()));
1101 text->AddLine(StringPrintf("for (const auto& pair : %s)", map_name.c_str()));
1103 text->AddLine("return values;");
1105 text->AddLine("}");
1108 text->AddLine(StringPrintf("void Set%sAddedCallback(",
1111 text->AddLine(
1116 text->AddLine(StringPrintf("on_%s_added_ = callback;",
1119 text->AddLine("}");
1122 text->AddLine(StringPrintf("void Set%sRemovedCallback(",
1125 text->AddLine("const base::Callback<void(const dbus::ObjectPath&)>& "
1129 text->AddLine(StringPrintf("on_%s_removed_ = callback;",
1132 text->AddLine("}");
1150 text->AddLine("const std::string& /* interface_name */,");
1151 text->AddLine("const std::string& /* property_name */) {}");
1159 text->AddLine("const std::string& interface_name,");
1160 text->AddLine("const std::string& property_name) {");
1168 text->AddLine(StringPrintf("if (interface_name == \"%s\") {",
1172 text->AddLine(StringPrintf("auto p = %s.find(object_path);",
1174 text->AddLine(StringPrintf("if (p == %s.end())", map_name.c_str()));
1176 text->AddLine("return;");
1178 text->AddLine("p->second->OnPropertyChanged(property_name);");
1179 text->AddLine("return;");
1181 text->AddLine("}");
1184 text->AddLine("}");
1192 text->AddLine("void ObjectAdded(");
1194 text->AddLine("const dbus::ObjectPath& object_path,");
1195 text->AddLine("const std::string& interface_name) override {");
1201 text->AddLine(StringPrintf("if (interface_name == \"%s\") {",
1205 text->AddLine("auto property_set =");
1207 text->AddLine(StringPrintf("static_cast<%s::PropertySet*>(",
1210 text->AddLine("dbus_object_manager_->GetProperties(object_path, "
1215 text->AddLine(StringPrintf("std::unique_ptr<%s> %s_proxy{",
1229 text->AddLine(new_instance);
1231 text->AddLine("};");
1232 text->AddLine(StringPrintf("auto p = %s_instances_.emplace(object_path, "
1235 text->AddLine(StringPrintf("if (!on_%s_added_.is_null())",
1238 text->AddLine(StringPrintf("on_%s_added_.Run(p.first->second.get());",
1241 text->AddLine("return;");
1243 text->AddLine("}");
1246 text->AddLine("}");
1253 text->AddLine("void ObjectRemoved(");
1255 text->AddLine("const dbus::ObjectPath& object_path,");
1256 text->AddLine("const std::string& interface_name) override {");
1262 text->AddLine(StringPrintf("if (interface_name == \"%s\") {",
1265 text->AddLine(StringPrintf("auto p = %s_instances_.find(object_path);",
1267 text->AddLine(StringPrintf("if (p != %s_instances_.end()) {",
1270 text->AddLine(StringPrintf("if (!on_%s_removed_.is_null())",
1273 text->AddLine(StringPrintf("on_%s_removed_.Run(object_path);",
1276 text->AddLine(StringPrintf("%s_instances_.erase(p);",
1279 text->AddLine("}");
1280 text->AddLine("return;");
1282 text->AddLine("}");
1285 text->AddLine("}");
1293 text->AddLine("dbus::PropertySet* CreateProperties(");
1295 text->AddLine("dbus::ObjectProxy* object_proxy,");
1296 text->AddLine("const dbus::ObjectPath& object_path,");
1297 text->AddLine("const std::string& interface_name) override {");
1302 text->AddLine(StringPrintf("if (interface_name == \"%s\") {",
1305 text->AddLine(StringPrintf("return new %s::PropertySet{",
1308 text->AddLine("object_proxy,");
1313 text->AddLine("weak_ptr_factory_.GetWeakPtr(),");
1314 text->AddLine("object_path,");
1315 text->AddLine("interface_name)");
1318 text->AddLine("};");
1320 text->AddLine("}");
1324 text->AddLine("<< interface_name;");
1326 text->AddLine("return nullptr;");
1328 text->AddLine("}");
1337 text->AddLine("scoped_refptr<dbus::Bus> bus_;");
1339 text->AddLine("std::string service_name_;");
1341 text->AddLine("dbus::ObjectManager* dbus_object_manager_;");
1346 text->AddLine(StringPrintf("std::unique_ptr<%s>> %s_instances_;",
1350 text->AddLine(
1354 text->AddLine(StringPrintf("base::Callback<void(const dbus::ObjectPath&)> "
1358 text->AddLine(