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