From 4ab42f0e70e7a8324f4b50c51c10eda30e3e09cd Mon Sep 17 00:00:00 2001 From: "jh9216.park" Date: Fri, 15 Jul 2022 03:10:36 -0400 Subject: [PATCH] Implement C# group generator Change-Id: Icefd3413c98c7d0bfe266803f42481f81d6931c7 Signed-off-by: jh9216.park --- Makefile.dibs | 1 + idlc/gen/cs_gen_base.cc | 253 +++++++++++++++++++++++++-------------------- idlc/gen/cs_gen_base.h | 6 ++ idlc/gen/cs_gen_base_cb.h | 51 +++++++++ idlc/gen/cs_group_gen.cc | 155 +++++++++++++++++++++++++++ idlc/gen/cs_group_gen.h | 48 +++++++++ idlc/gen/cs_group_gen_cb.h | 152 +++++++++++++++++++++++++++ idlc/main.cc | 8 +- 8 files changed, 562 insertions(+), 112 deletions(-) create mode 100644 idlc/gen/cs_group_gen.cc create mode 100644 idlc/gen/cs_group_gen.h create mode 100644 idlc/gen/cs_group_gen_cb.h diff --git a/Makefile.dibs b/Makefile.dibs index 1f58b15..676e812 100644 --- a/Makefile.dibs +++ b/Makefile.dibs @@ -31,6 +31,7 @@ SRC_FILES := \ idlc/gen/cs_lib_gen.cc \ idlc/gen/cs_proxy_gen.cc \ idlc/gen/cs_stub_gen.cc \ + idlc/gen/cs_group_gen.cc \ idlc/gen/generator.cc \ idlc/gen/replace_all.cc \ idlc/gen_cion/c_cion_body_gen_base.cc \ diff --git a/idlc/gen/cs_gen_base.cc b/idlc/gen/cs_gen_base.cc index bef1498..912d9d5 100644 --- a/idlc/gen/cs_gen_base.cc +++ b/idlc/gen/cs_gen_base.cc @@ -95,55 +95,71 @@ void CsGeneratorBase::GenStructure(std::ofstream& stream, const Structure& st) { void CsGeneratorBase::GenSerializer(std::ofstream& stream, const Structure& st) { - stream << NLine(1) << Tab(3) << "private static void Serialize(Parcel h, " - << st.GetID() << " param)" << NLine(1); - GenBrace(stream, TAB_SIZE * 3, [&]() { - for (const auto& i : st.GetElements()) { - auto& t = i->GetType(); - if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) { - stream << Tab(4) << "h.Write" - << ConvertTypeToParcelType(t.ToString()) - << "(param." - << i->GetID() - << ");" << NLine(1); - } else { - stream << Tab(4) << "Serialize(h, param." << i->GetID() - << ");" << NLine(1); - } - } - }); - stream << NLine(1); + stream << GetSerializer(st); +} - stream << Tab(3) << "private static void Deserialize(Parcel h, " - << st.GetID() << " param)" << NLine(1); - GenBrace(stream, TAB_SIZE * 3, [&]() { - for (const auto& i : st.GetElements()) { - auto& t = i->GetType(); - if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) { - stream << Tab(4) << "var " << i->GetID() << " = " - << "h.Read" - << ConvertTypeToParcelType(t.ToString()) - << "();" << NLine(1); - stream << Tab(4) << "param." << i->GetID() << " = " << i->GetID() - << ";" << NLine(1); - } else { - stream << Tab(4) << "param." << i->GetID() << " = new " - << ConvertTypeToString(t) - << "();" << NLine(1); - stream << Tab(4) << "Deserialize(h, param." << i->GetID() - << ");" << NLine(1); - } - } - }); +std::string CsGeneratorBase::GetSerializer(const Structure& st) { + std::string str(ReplaceAll(CB_SERIALIZER) + .Change("", st.GetID()) + .Change("", [&]() { + std::string ret; + for (const auto& i : st.GetElements()) { + auto& t = i->GetType(); + if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) { + ret += Tab(4) + "h.Write" + + ConvertTypeToParcelType(t.ToString()) + + "(param." + + i->GetID() + + ");" + NLine(1); + } else { + ret += Tab(4) + "Serialize(h, param." + i->GetID() + + ");" + NLine(1); + } + } + + return ret; + })); + + str += ReplaceAll(CB_DESERIALIZER) + .Change("", st.GetID()) + .Change("", [&]() { + std::string ret; + for (const auto& i : st.GetElements()) { + auto& t = i->GetType(); + if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) { + ret += Tab(4) + "var " + i->GetID() + " = " + + "h.Read" + + ConvertTypeToParcelType(t.ToString()) + + "();" + NLine(1); + ret += Tab(4) + "param." + i->GetID() + " = " + i->GetID() + + ";" + NLine(1); + } else { + ret += Tab(4) + "param." + i->GetID() + " = new " + + ConvertTypeToString(t) + + "();" + NLine(1); + ret += Tab(4) + "Deserialize(h, param." + i->GetID() + + ");" + NLine(1); + } + } + return ret; + }); + return str; } void CsGeneratorBase::GenSerializer(std::ofstream& stream) { + stream << GetSerializer(); +} + +std::string CsGeneratorBase::GetSerializer() { + std::string str; for (auto& i : GetDocument().GetBlocks()) { if (i->GetType() == Block::TYPE_STRUCTURE) { const Structure& st = static_cast(*i); - GenSerializer(stream, st); + str += GetSerializer(st); } } + + return str; } void CsGeneratorBase::AddSerializerList(const BaseType& type) { @@ -155,60 +171,64 @@ void CsGeneratorBase::AddSerializerList(const BaseType& type) { void CsGeneratorBase::GenListSerializer(std::ofstream& stream, const BaseType& type) { - stream << NLine(1) << Tab(3) << "private static void Serialize(Parcel h, " - << ConvertTypeToString(type) << " param)" << NLine(1); - GenBrace(stream, TAB_SIZE * 3, [&]() { - stream << Tab(4) - << "h.WriteArrayCount(param.Count);" - << NLine(1); - stream << Tab(4) << "foreach (var i in param)" << NLine(1); - GenBrace(stream, TAB_SIZE * 4, [&]() { - auto* ptr = type.GetMetaType(); - if (ptr == nullptr) return; - - auto& mt = *ptr; - if (!mt.IsUserDefinedType() && mt.GetMetaType() == nullptr) { - stream << Tab(5) << "h.Write" - << ConvertTypeToParcelType(mt.ToString()) - << "(i);" << NLine(1); - } else { - stream << Tab(5) << "Serialize(h, i);" << NLine(1); - } - }); - }); - stream << NLine(1); + stream << GetListSerializer(type); +} - stream << Tab(3) << "private static void Deserialize(Parcel h, " - << ConvertTypeToString(type) << " param)" << NLine(1); - GenBrace(stream, TAB_SIZE * 3, [&]() { - stream << Tab(4) - << "int l = h.ReadArrayCount();" - << NLine(1); - stream << Tab(4) << "for (int i = 0; i < l; i++)" << NLine(1); - GenBrace(stream, TAB_SIZE * 4, [&]() { - auto* ptr = type.GetMetaType(); - if (ptr == nullptr) - return; - - auto& mt = *ptr; - if (!mt.IsUserDefinedType() && mt.GetMetaType() == nullptr) { - stream << Tab(5) << "var v = h.Read" - << ConvertTypeToParcelType(mt.ToString()) - << "();" << NLine(1); - } else { - stream << Tab(5) << "var v = new " << ConvertTypeToString(mt) - << "();" << NLine(1); - stream << Tab(5) << "Deserialize(h, v);" << NLine(1); - } - if (type.ToString() == "list") - stream << Tab(5) << "param.AddLast(v);" << NLine(1); - else - stream << Tab(5) << "param.Add(v);" << NLine(1); - }); - }); +std::string CsGeneratorBase::GetListSerializer(const BaseType& type) { + std::string str(ReplaceAll(CB_LIST_SERIALIZER) + .Change("", ConvertTypeToString(type)) + .Change("", [&]() { + std::string ret; + auto* ptr = type.GetMetaType(); + if (ptr == nullptr) + return ret; + + auto& mt = *ptr; + if (!mt.IsUserDefinedType() && mt.GetMetaType() == nullptr) { + ret += Tab(5) + "h.Write" + + ConvertTypeToParcelType(mt.ToString()) + + "(i);" + NLine(1); + } else { + ret += Tab(5) + "Serialize(h, i);" + NLine(1); + } + return ret; + })); + + str += ReplaceAll(CB_DESERIALIZER) + .Change("", ConvertTypeToString(type)) + .Change("", [&]() { + std::string ret; + auto* ptr = type.GetMetaType(); + if (ptr == nullptr) + return ret; + + auto& mt = *ptr; + if (!mt.IsUserDefinedType() && mt.GetMetaType() == nullptr) { + ret += Tab(5) + "var v = h.Read" + + ConvertTypeToParcelType(mt.ToString()) + + "();" + NLine(1); + } else { + ret += Tab(5) + "var v = new " + ConvertTypeToString(mt) + + "();" + NLine(1); + ret += Tab(5) + "Deserialize(h, v);" + NLine(1); + } + + if (type.ToString() == "list") + ret += Tab(5) + "param.AddLast(v);" + NLine(1); + else + ret += Tab(5) + "param.Add(v);" + NLine(1); + + return ret; + }); + + return str; } void CsGeneratorBase::GenListSerializer(std::ofstream& stream) { + stream << GetListSerializer(); +} + +std::string CsGeneratorBase::GetListSerializer() { serializer_list_.clear(); for (auto& i : GetDocument().GetBlocks()) { if (i->GetType() == Block::TYPE_STRUCTURE) { @@ -230,10 +250,13 @@ void CsGeneratorBase::GenListSerializer(std::ofstream& stream) { } } + std::string ret; for (auto& p : serializer_list_) { const BaseType* t = p.second; - GenListSerializer(stream, *t); + ret += GetListSerializer(*t); } + + return ret; } std::string CsGeneratorBase::ConvertTypeToString(const BaseType& type) { @@ -348,20 +371,22 @@ void CsGeneratorBase::GenWriteBundle(std::ofstream& stream, }); } -void CsGeneratorBase::GenMethodId(std::ofstream& stream, - const Interface& iface) { - stream << Tab(3) << "private enum MethodId : int" << NLine(1); - GenBrace(stream, TAB_SIZE * 3, [&]() { - int cnt = 2; - stream << Tab(4) << "__Result = 0," << NLine(1); - stream << Tab(4) << "__Callback = 1," << NLine(1); - for (const auto& i : iface.GetDeclarations()) { - if (i->GetMethodType() == Declaration::MethodType::DELEGATE) - continue; - stream << Tab(4) - << i->GetID() << " = " << cnt++ << "," << NLine(1); - } - }); +std::string CsGeneratorBase::GetMethodId(const Interface& iface) { + return std::string(ReplaceAll(CB_METHOD_IDS) + .Change("", [&](){ + int cnt = 2; + std::string str; + for (const auto& i : iface.GetDeclarations()) { + if (i->GetMethodType() == Declaration::MethodType::DELEGATE) + continue; + str += Tab(4) + i->GetID() + " = " + std::to_string(cnt++) + "," + NLine(1); + } + return str; + })); +} + +void CsGeneratorBase::GenMethodId(std::ofstream& stream, const Interface& iface) { + stream << GetMethodId(iface); } void CsGeneratorBase::GenDelegateId(std::ofstream& stream, @@ -380,14 +405,20 @@ void CsGeneratorBase::GenDelegateId(std::ofstream& stream, } void CsGeneratorBase::GenDeclaration(std::ofstream& stream, - const Declaration& decl, bool semicol) { - stream << ConvertTypeToString(decl.GetType()) << " " - << decl.GetID() << "("; - GenParameters(stream, decl.GetParameters()); + const Declaration& decl, bool semicol) { + stream << GetDeclaration(decl, semicol); +} + +std::string CsGeneratorBase::GetDeclaration(const Declaration& decl, bool semicol) { + std::string ret; + ret += ConvertTypeToString(decl.GetType()) + " " + + decl.GetID() + "("; + ret += GetParameters(decl.GetParameters()); if (semicol) - stream << ");"; + ret += ");"; else - stream << ")"; + ret += ")"; + return ret; } void CsGeneratorBase::GenParameters(std::ofstream& stream, diff --git a/idlc/gen/cs_gen_base.h b/idlc/gen/cs_gen_base.h index c7c4cdd..7400a4c 100644 --- a/idlc/gen/cs_gen_base.h +++ b/idlc/gen/cs_gen_base.h @@ -36,13 +36,19 @@ class CsGeneratorBase : public Generator { void GenStructures(std::ofstream& stream); void GenStructure(std::ofstream& stream, const Structure& st); void GenSerializer(std::ofstream& stream); + std::string GetSerializer(); void GenSerializer(std::ofstream& stream, const Structure& st); + std::string GetSerializer(const Structure& st); void GenListSerializer(std::ofstream& stream); + std::string GetListSerializer(); void GenListSerializer(std::ofstream& stream, const BaseType& type); + std::string GetListSerializer(const BaseType& type); void GenMethodId(std::ofstream& stream, const Interface& iface); + std::string GetMethodId(const Interface& iface); void GenDelegateId(std::ofstream& stream, const Interface& iface); void GenDeclaration(std::ofstream& stream, const Declaration& decl, bool semicol = true); + std::string GetDeclaration(const Declaration& decl, bool semicol = true); void GenParameters(std::ofstream& stream, const Parameters& ps); void GenCallbacks(std::ofstream& stream, const Interface& iface, bool is_proxy); diff --git a/idlc/gen/cs_gen_base_cb.h b/idlc/gen/cs_gen_base_cb.h index aabc490..c349111 100644 --- a/idlc/gen/cs_gen_base_cb.h +++ b/idlc/gen/cs_gen_base_cb.h @@ -126,4 +126,55 @@ R"__cs_cb( } )__cs_cb"; +const char CB_METHOD_IDS[] = +R"__cs_cb( + private enum MethodId : int + { + __Result = 0, + __Callback = 1, + + } +)__cs_cb"; + +const char CB_SERIALIZER[] = +R"__cs_cb( + private static void Serialize(Parcel h, param) + { + + } +)__cs_cb"; + +const char CB_DESERIALIZER[] = +R"__cs_cb( + private static void Deserialize(Parcel h, param) + { + + } +)__cs_cb"; + +const char CB_LIST_SERIALIZER[] = +R"__cs_cb( + private static void Serialize(Parcel h, param) + { + h.WriteArrayCount(param.Count); + foreach (var i in param) + { + + } + } +)__cs_cb"; + +const char CB_LIST_DESERIALIZER[] = +R"__cs_cb( + private static void Deserialize(Parcel h, param) + { + int l = h.ReadArrayCount(); + for (int i = 0; i < l; i++) + { + + } + } +)__cs_cb"; + + #endif // IDLC_CS_GEN_CS_GEN_BASE_CB_H_ diff --git a/idlc/gen/cs_group_gen.cc b/idlc/gen/cs_group_gen.cc new file mode 100644 index 0000000..b1161e5 --- /dev/null +++ b/idlc/gen/cs_group_gen.cc @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "idlc/gen/cs_group_gen.h" + +namespace { +#include "idlc/gen/cs_group_gen_cb.h" +} + +namespace tidl { + +CsGroupGen::CsGroupGen(std::shared_ptr doc) + : CsGeneratorBase(doc) {} + +void CsGroupGen::OnInitGen(std::ofstream& stream) { + GenVersion(stream); + stream << CB_USING; + GenNamespace(stream); +} + +void CsGroupGen::OnFiniGen(std::ofstream& stream) { +} + +void CsGroupGen::GenNamespace(std::ofstream& stream) { + stream << NLine(1); + stream << "namespace RPCPort" << NLine(1); + GenBrace(stream, 0, [&]() { + stream << "namespace " << GetFileNamespace() << NLine(1); + GenBrace(stream, 0, [&]() { + GenStructures(stream); + stream << Tab(1) << "namespace Group" << NLine(1); + GenBrace(stream, TAB_SIZE, [&]() { + GenInterfaces(stream); + }); + }); + }); +} + +void CsGroupGen::GenInterfaces(std::ofstream& stream) { + for (auto& i : GetDocument().GetBlocks()) { + if (i->GetType() != Block::TYPE_INTERFACE) + continue; + Interface& iface = static_cast(*i); + GenInterface(stream, iface); + stream << NLine(1); + } +} + +void CsGroupGen::GenInterface(std::ofstream& stream, const Interface& iface) { + ReplaceAll(CB_INTERFACE_FULL) + .Change("", iface.GetID()) + .Change("", GetMethodId(iface)) + .Change("", GetSerializer()) + .Change("", GetListSerializer()) + .Change("", GetMethods(iface)) + .Change("", GetDispatchers(iface)) + .Out(stream); +} + +std::string CsGroupGen::GetDispatchers(const Interface& iface) { + std::string ret; + for (const auto& i : iface.GetDeclarations()) { + ret += ReplaceAll(CB_DISPATCHER) + .Change("", i->GetID()) + .Change("", GetParamDeserializer(*i)) + .Change("", GetCallParams(*i)); + } + + return ret; +} + +std::string CsGroupGen::GetMethods(const Interface& iface) { + std::string ret; + auto& decls = iface.GetDeclarations(); + for (const auto& i : decls) { + ret += ReplaceAll(CB_METHOD) + .Change("", GetParameters(i->GetParameters())) + .Change("", i->GetComments().empty() ? "" : + AddIndent(TAB_SIZE * 3, i->GetComments())) + .Change("", GetDeclaration(*i, false)) + .Change("", i->GetID()) + .Change("", GetParamSerializer(*i)) + .Change("", iface.GetID()); + } + + return ret; +} + +std::string CsGroupGen::GetParamSerializer(const Declaration& decl) { + std::string m; + for (const auto& i : decl.GetParameters()) { + auto& pt = i->GetParameterType(); + if (pt.GetDirection() == ParameterType::Direction::OUT) + continue; + m += Tab(5) + ConvertTypeToSerializer(pt.GetBaseType(), i->GetID(), "p"); + } + + return m; +} + +std::string CsGroupGen::GetParamDeserializer(const Declaration& decl) { + int cnt = 1; + std::string m; + for (const auto& i : decl.GetParameters()) { + if (i->GetParameterType().GetDirection() == ParameterType::Direction::OUT) { + cnt++; + continue; + } + + std::string v = "param" + std::to_string(cnt); + std::string c = ConvertTypeToDeserializer( + i->GetParameterType().GetBaseType(), v, "p"); + m += AddIndent(TAB_SIZE * 6, c); + cnt++; + } + + return m; +} + +std::string CsGroupGen::GetCallParams(const Declaration& decl) { + int cnt = 1; + std::string m; + for (const auto& i : decl.GetParameters()) { + if (cnt != 1) { + m += ", "; + } + + std::string v = "param" + std::to_string(cnt); + auto& pt = i->GetParameterType(); + if (pt.GetDirection() == ParameterType::Direction::OUT) { + m += "out " + ConvertTypeToString(pt.GetBaseType()) + " "; + } else if (pt.GetDirection() == ParameterType::Direction::REF) { + m += "ref "; + } + m += v; + cnt++; + } + + return m; +} + +} // namespace tidl diff --git a/idlc/gen/cs_group_gen.h b/idlc/gen/cs_group_gen.h new file mode 100644 index 0000000..59bb5dd --- /dev/null +++ b/idlc/gen/cs_group_gen.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IDLC_GEN_CS_GROUP_GEN_H_ +#define IDLC_GEN_CS_GROUP_GEN_H_ + +#include +#include + +#include "idlc/gen/cs_gen_base.h" + +namespace tidl { + +class CsGroupGen : public CsGeneratorBase { + public: + explicit CsGroupGen(std::shared_ptr doc); + virtual ~CsGroupGen() = default; + + void OnInitGen(std::ofstream& stream) override; + void OnFiniGen(std::ofstream& stream) override; + + private: + void GenNamespace(std::ofstream& stream); + void GenInterfaces(std::ofstream& stream); + void GenInterface(std::ofstream& stream, const Interface& iface); + std::string GetMethods(const Interface& iface); + std::string GetParamSerializer(const Declaration& decl); + std::string GetParamDeserializer(const Declaration& decl); + std::string GetDispatchers(const Interface& iface); + std::string GetCallParams(const Declaration& decl); +}; + +} // namespace tidl + +#endif // IDLC_GEN_CS_GROUP_GEN_H_ \ No newline at end of file diff --git a/idlc/gen/cs_group_gen_cb.h b/idlc/gen/cs_group_gen_cb.h new file mode 100644 index 0000000..d5aaada --- /dev/null +++ b/idlc/gen/cs_group_gen_cb.h @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IDLC_GEN_CS_GROUP_GEN_CB_H_ +#define IDLC_GEN_CS_GROUP_GEN_CB_H_ + +const char CB_USING[] = +R"__cs_cb( +using System; +using Tizen.Applications; +using Tizen.Applications.EventManager; +using Tizen.Applications.RPCPort; + +)__cs_cb"; + +const char CB_INTERFACE_FULL[] = +R"__cs_cb( + public class : IDisposable + { + private EventReceiver _eventReceiver; + private Object _lock = new Object(); + private bool _disposedValue = false; + + private Bundle GetBundleFromParcel(Parcel p) + { + byte[] bytes = p.ToBytes(); + Bundle b = new Bundle(); + b.AddItem("TIDL_RAW", bytes); + return b; + } + + private Parcel GetParcelFromBundle(Bundle b) + { + byte[] bytes = (byte[])b.GetItem("TIDL_RAW"); + + return new Parcel(bytes); + } + + private string GetEventName(string appid, string iface_name) + { + return "event." + appid + ".tidl_iface_" + iface_name; + } + + private void OnReceive(Parcel p) + { + int cmd = p.ReadInt(); + + switch ((MethodId)cmd) + { + + } + } + + + + + + public (string senderAppid) + { + string eventName = GetEventName(senderAppid, ""); + _eventReceiver = new EventReceiver(eventName); + _eventReceiver.Received += (obj, args) => + { + Bundle b = args.Data; + using (var parcel = GetParcelFromBundle(b)) + { + OnReceive(parcel); + } + }; + } + + public () + { + } + + ~() + { + Dispose(false); + } + + protected void Dispose(bool disposing) + { + if (!_disposedValue) + { + if (disposing) + { + if (_eventReceiver != null) + { + _eventReceiver.Dispose(); + _eventReceiver = null; + } + } + + _disposedValue = true; + } + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + + + } +)__cs_cb"; + +const char CB_METHOD[] = +R"__cs_cb( + public delegate void EventHandler(); + public event EventHandler Event; + + public + { + using (Parcel p = new Parcel()) + { + p.WriteInt((int)MethodId.); + + var bundle = GetBundleFromParcel(p); + string eventName = GetEventName(Application.Current.ApplicationInfo.ApplicationId, ""); + ApplicationEventManager.Publish(eventName, bundle); + } + } +)__cs_cb"; + +const char CB_DISPATCHER[] = +R"__cs_cb( + case MethodId.: + { + + Event?.Invoke(); + break; + } +)__cs_cb"; + + + +#endif // IDLC_GEN_CS_GROUP_GEN_CB_H_ diff --git a/idlc/main.cc b/idlc/main.cc index 4df018a..4e4228f 100644 --- a/idlc/main.cc +++ b/idlc/main.cc @@ -22,6 +22,7 @@ #include "idlc/ast/parser.h" #include "idlc/gen/cs_proxy_gen.h" #include "idlc/gen/cs_stub_gen.h" +#include "idlc/gen/cs_group_gen.h" #include "idlc/gen/cs_lib_gen.h" #include "idlc/gen/c_proxy_header_gen.h" #include "idlc/gen/c_proxy_body_gen.h" @@ -338,7 +339,12 @@ void GenerateGroupCodes(std::shared_ptr options, } case tidl::Options::LANGUAGE_TYPE_CSHARP: - case tidl::Options::LANGUAGE_TYPE_JAVA: + { + tidl::CsGroupGen group(ps.GetDoc()); + group.Run(options->GetOutput() + ".cs"); + break; + } + default: break; } -- 2.7.4