Generate access-control code for c# stub generator 49/166449/3
authorJunghoon Park <jh9216.park@samsung.com>
Wed, 10 Jan 2018 08:18:00 +0000 (17:18 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Wed, 10 Jan 2018 08:31:31 +0000 (17:31 +0900)
Change-Id: Id983e207e3fbfd0215a36d1dc3075f8ef8ce8f69
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
idlc/code_block/cs_stub_interop.cb
idlc/cs_gen/cs_stub_gen.cc

index 12b2ec7..2cd8d9b 100644 (file)
@@ -35,4 +35,8 @@
             //int rpc_port_stub_add_received_event_cb(rpc_port_stub_h h, rpc_port_stub_received_event_cb cb, void* data);
             [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_add_received_event_cb")]
             internal static extern int AddReceivedEventCb(IntPtr handle, ReceivedEventCallback cb, IntPtr data);
+
+            //int rpc_port_stub_add_privilege(rpc_port_stub_h h, const char *privilege);
+            [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_add_privilege")]
+            internal static extern int AddPrivilege(IntPtr handle, string privilege);
         }
\ No newline at end of file
index db72c01..64a6ced 100644 (file)
@@ -270,8 +270,7 @@ void CsStubGen::GenCtor(std::ofstream& stream, const Interface& iface) {
       "    Interop.LibRPCPort.Stub.Create(out _stub, \"$$\");\n" \
       "    Interop.LibRPCPort.Stub.AddReceivedEventCb(_stub, OnReceivedEvent, IntPtr.Zero);\n" \
       "    Interop.LibRPCPort.Stub.AddConnectedEventCb(_stub, OnConnectedEvent, IntPtr.Zero);\n" \
-      "    Interop.LibRPCPort.Stub.AddDisconnectedEventCb(_stub, OnDisconnectedEvent, IntPtr.Zero);\n" \
-      "}\n";
+      "    Interop.LibRPCPort.Stub.AddDisconnectedEventCb(_stub, OnDisconnectedEvent, IntPtr.Zero);\n";
 
   GenTemplate(AddIndent(TAB_SIZE * 3, ctor), stream,
     [&]()->std::string {
@@ -281,7 +280,14 @@ void CsStubGen::GenCtor(std::ofstream& stream, const Interface& iface) {
       return iface.GetID();
     }
   );
-  stream << NLine(1);
+
+  for (auto& i : iface.GetAttributes().GetAttrs()) {
+    if (i->GetKey() == "privilege") {
+      stream << Tab(4) << "Interop.LibRPCPort.Stub.AddPrivilege(_stub, \""
+             << i->GetValue() << "\");" << NLine(1);
+    }
+  }
+  stream << Tab(3) << "}" << NLine(2);
 }
 
 void CsStubGen::GenCommonMethods(std::ofstream& stream) {