return str;
}
+std::string CStubBodyGen::GetTrustedModeString(const std::string& id,
+ const Attribute& attr) {
+ std::string str;
+
+ str += GenTemplateString(CB_INTERFACE_TRUSTED_MODE_BLOCK,
+ [&]()->std::string {
+ return "rpc_port_stub_set_trusted(__" + id +
+ "_stub, " + attr.GetValue() + ")";
+ },
+ [&]()->std::string {
+ return attr.GetValue();
+ }
+ );
+ return str;
+}
+
void CStubBodyGen::GenInterfaceDelegators(std::ofstream& stream,
const Interface& inf) {
for (auto& i : inf.GetDeclarations().GetDecls()) {
[&]()->std::string {
std::string str;
for (auto& a : inf.GetAttributes().GetAttrs()) {
- if (a->GetKey() != "privilege")
- continue;
- str += GetAddPrivilegeString(inf.GetID(), *a);
- str += NLine(1);
+ if (a->GetKey() == "privilege") {
+ str += GetAddPrivilegeString(inf.GetID(), *a);
+ str += NLine(1);
+ } else if (a->GetKey() == "trusted" && a->GetValue() == "true") {
+ str += GetTrustedModeString(inf.GetID(), *a);
+ str += NLine(1);
+ }
}
if (!str.empty())
std::string GetAddEventCBString(const std::string& id);
std::string GetAddPrivilegeString(const std::string& id,
const Attribute& attr);
+ std::string GetTrustedModeString(const std::string& id,
+ const Attribute& attr);
};
} // namespace tidl
return r;
}
)__c_cb";
+
+const char CB_INTERFACE_TRUSTED_MODE_BLOCK[] =
+R"__c_cb(r = $$;
+if (r != 0) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set trusted mode($$)");
+ return r;
+}
+)__c_cb";
if (i->GetKey() == "privilege") {
stream << Tab(1) << "rpc_port_stub_add_privilege(stub_, \""
<< i->GetValue() << "\");" << NLine(1);
+ } else if (i->GetKey() == "trusted" && i->GetValue() == "true") {
+ stream << Tab(1) << "rpc_port_stub_set_trusted(stub_, "
+ << i->GetValue() << ");" << NLine(1);
}
}
//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);
+
+ //int rpc_port_stub_set_trusted(rpc_port_stub_h h, const bool trusted);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_set_trusted")]
+ internal static extern int SetTrusted(IntPtr handle, bool trusted);
}
)__cs_cb";
if (i->GetKey() == "privilege") {
stream << Tab(4) << "Interop.LibRPCPort.Stub.AddPrivilege(_stub, \""
<< i->GetValue() << "\");" << NLine(1);
+ } else if (i->GetKey() == "trusted" && i->GetValue() == "true") {
+ stream << Tab(4) << "Interop.LibRPCPort.Stub.SetTrusted(_stub, "
+ << i->GetValue() << ");" << NLine(1);
}
}
stream << Tab(3) << "}" << NLine(1);