From d7d49d7d4c3c9d9f723041e82e925dd1884917d6 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Fri, 2 Mar 2018 09:27:14 +0900 Subject: [PATCH] Call access-control API Change-Id: I47fde8d5d3093d5839497820784a69d55d4f653c Signed-off-by: Junghoon Park --- idlc/cpp_gen/cpp_stub_body_gen.cc | 28 +++++++++++++++++++++++----- idlc/cpp_gen/cpp_stub_body_gen.h | 1 + 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/idlc/cpp_gen/cpp_stub_body_gen.cc b/idlc/cpp_gen/cpp_stub_body_gen.cc index c329d2e..9c586cf 100644 --- a/idlc/cpp_gen/cpp_stub_body_gen.cc +++ b/idlc/cpp_gen/cpp_stub_body_gen.cc @@ -86,8 +86,8 @@ void CppStubBodyGen::GenServiceBase(std::ofstream& stream, stream << NLine(1); } -void CppStubBodyGen::GenDefaultMethods(std::ofstream& stream, - const Interface& iface) { +void CppStubBodyGen::GenConstructor(std::ofstream& stream, + const Interface& iface) { const char cb[] = R"__cpp_cb( $$::$$() { @@ -95,8 +95,28 @@ $$::$$() { rpc_port_stub_add_connected_event_cb(stub_, OnConnectedCB, this); rpc_port_stub_add_disconnected_event_cb(stub_, OnDisconnectedCB, this); rpc_port_stub_add_received_event_cb(stub_, OnReceivedCB, this); +)__cpp_cb"; + + GenTemplate(cb, stream, + [&]()->std::string { return iface.GetID(); }, + [&]()->std::string { return iface.GetID(); }, + [&]()->std::string { return iface.GetID(); } + ); + + for (auto& i : iface.GetAttributes().GetAttrs()) { + if (i->GetKey() == "privilege") { + stream << Tab(1) << "rpc_port_stub_add_privilege(stub_, \"" + << i->GetValue() << "\");" << NLine(1); + } + } + + stream << "}" << NLine(1); } +void CppStubBodyGen::GenDefaultMethods(std::ofstream& stream, + const Interface& iface) { + const char cb[] = +R"__cpp_cb( $$::~$$() { if (stub_) { rpc_port_stub_destroy(stub_); @@ -129,6 +149,7 @@ void $$::OnDisconnectedCB(const char* sender, const char* instance, void *data) } )__cpp_cb"; + GenConstructor(stream, iface); GenTemplate(cb, stream, [&]()->std::string { return iface.GetID(); }, [&]()->std::string { return iface.GetID(); }, @@ -139,9 +160,6 @@ void $$::OnDisconnectedCB(const char* sender, const char* instance, void *data) [&]()->std::string { return iface.GetID(); }, [&]()->std::string { return iface.GetID(); }, [&]()->std::string { return iface.GetID(); }, - [&]()->std::string { return iface.GetID(); }, - [&]()->std::string { return iface.GetID(); }, - [&]()->std::string { return iface.GetID(); }, [&]()->std::string { return iface.GetID(); } ); stream << NLine(1); diff --git a/idlc/cpp_gen/cpp_stub_body_gen.h b/idlc/cpp_gen/cpp_stub_body_gen.h index 76e2083..fa8b7cc 100644 --- a/idlc/cpp_gen/cpp_stub_body_gen.h +++ b/idlc/cpp_gen/cpp_stub_body_gen.h @@ -40,6 +40,7 @@ class CppStubBodyGen : public CppGeneratorBase { void GenDefaultMethods(std::ofstream& stream, const Interface& iface); void GenReceivedEvent(std::ofstream& stream, const Interface& iface); void GenInvocation(std::ofstream& stream, const Declaration& decl); + void GenConstructor(std::ofstream& stream, const Interface& iface); }; } // namespace tidl -- 2.7.4