From e725ac0132bf8c80f93396c94494d5ae2ffa0183 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Fri, 29 Jul 2022 15:38:33 +0900 Subject: [PATCH] [aitt] Implement Java generator Change-Id: I410f3f5074b2ad5e13a4ac752cd23a00e73783bf Signed-off-by: Ilho Kim --- Makefile.dibs | 1 + .../aitt_plugin_java_transportable.cc | 95 +++++++++++++++++++++ .../aitt_plugin_java_transportable.h | 38 +++++++++ idlc/gen_aitt_plugin/aitt_plugin_loader.cc | 3 +- idlc/gen_cion/default_java_transportable.cc | 98 ++++++++++++++++++++++ idlc/gen_cion/default_java_transportable.h | 5 ++ idlc/gen_cion/java_cion_common_gen.cc | 6 +- idlc/gen_cion/java_cion_gen_base.cc | 32 ++++--- idlc/gen_cion/java_cion_gen_cb.h | 89 +++----------------- idlc/gen_cion/java_cion_group_gen.cc | 9 +- idlc/gen_cion/java_cion_group_gen_cb.h | 6 +- idlc/gen_cion/java_cion_group_repo_gen.cc | 2 + idlc/gen_cion/java_cion_proxy_gen.cc | 12 ++- idlc/gen_cion/java_cion_proxy_gen_cb.h | 10 +-- idlc/gen_cion/java_cion_proxy_repo_gen.cc | 2 + idlc/gen_cion/java_cion_structure_gen.cc | 2 +- idlc/gen_cion/java_cion_stub_gen.cc | 2 + idlc/gen_cion/java_cion_stub_gen_cb.h | 10 +-- idlc/gen_cion/java_cion_stub_repo_gen.cc | 2 + idlc/gen_cion/java_transportable.h | 5 ++ idlc/main.cc | 42 ++++++++++ 21 files changed, 357 insertions(+), 114 deletions(-) create mode 100644 idlc/gen_aitt_plugin/aitt_plugin_java_transportable.cc create mode 100644 idlc/gen_aitt_plugin/aitt_plugin_java_transportable.h diff --git a/Makefile.dibs b/Makefile.dibs index 6f30787..141b42b 100644 --- a/Makefile.dibs +++ b/Makefile.dibs @@ -66,6 +66,7 @@ SRC_FILES := \ idlc/gen_aitt_plugin/aitt_plugin_internal_body_gen.cc \ idlc/gen_aitt_plugin/aitt_plugin_internal_header_gen.cc \ idlc/gen_aitt_plugin/aitt_plugin_loader.cc \ + idlc/gen_aitt_plugin/aitt_plugin_java_transportable.cc \ idlc/options.cc \ idlc/main.cc diff --git a/idlc/gen_aitt_plugin/aitt_plugin_java_transportable.cc b/idlc/gen_aitt_plugin/aitt_plugin_java_transportable.cc new file mode 100644 index 0000000..bb5540d --- /dev/null +++ b/idlc/gen_aitt_plugin/aitt_plugin_java_transportable.cc @@ -0,0 +1,95 @@ +/* + * 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_aitt_plugin/aitt_plugin_java_transportable.h" + +#include + +#include "idlc/gen/replace_all.h" + +namespace { + +constexpr const char __CLIENT_BASE_CONSTRUCTOR[] = +R"__java_cb( + /** + * Constructor + * @param mContext The Context + * @param serviceName Service name + */ + public ClientBase(Context mContext, String serviceName, String brokerIp) { + mClient = new (mContext, serviceName, brokerIp); + this.mContext = mContext; + } +)__java_cb"; + +constexpr const char __SERVER_BASE_CONSTRUCTOR[] = +R"__java_cb( + /** + * Constructor + * @param mContext Context + * @param mServiceName Service name + * @param mDisplayName Display name + */ + public ServerBase(Context mContext, String mServiceName, String mDisplayName, String brokerIp) { + mServer = new (mContext, mServiceName, mDisplayName, brokerIp); + this.mContext = mContext; + this.mServiceName = mServiceName; + this.mDisplayName = mDisplayName; + } +)__java_cb"; + +constexpr const char __GROUP_BASE_CONSTRUCTOR[] = +R"__java_cb( + /** + * Constructor + * @param mContext The Context + * @param topicName Topic name + */ + public GroupBase(Context mContext, String topicName, String brokerIp) { + mGroup = new (mContext, topicName, brokerIp); + this.mContext = mContext; + } +)__java_cb"; + +} // namespace + +namespace tidl { + +std::string AittPluginJavaTransportable::GenInclude() const { + return "import org.tizen.aitt.*;"; +} + +std::string AittPluginJavaTransportable::GenParcelInclude() const { + return "import org.tizen.aitt.AittParcel;"; +} + +std::string AittPluginJavaTransportable::GenParcel() const { + return "AittParcel"; +} + +std::string AittPluginJavaTransportable::GenClientBaseConstructor() const { + return __CLIENT_BASE_CONSTRUCTOR; +} + +std::string AittPluginJavaTransportable::GenServerBaseConstructor() const { + return __SERVER_BASE_CONSTRUCTOR; +} + +std::string AittPluginJavaTransportable::GenGroupBaseConstructor() const { + return __GROUP_BASE_CONSTRUCTOR; +} + +} // namespace tidl diff --git a/idlc/gen_aitt_plugin/aitt_plugin_java_transportable.h b/idlc/gen_aitt_plugin/aitt_plugin_java_transportable.h new file mode 100644 index 0000000..05d107d --- /dev/null +++ b/idlc/gen_aitt_plugin/aitt_plugin_java_transportable.h @@ -0,0 +1,38 @@ +/* + * 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_AITT_PLUGIN_JAVA_TRANSPORTABLE_H_ +#define IDLC_GEN_AITT_PLUGIN_JAVA_TRANSPORTABLE_H_ + +#include + +#include "idlc/gen_cion/default_java_transportable.h" + +namespace tidl { + +class AittPluginJavaTransportable : public DefaultJavaTransportable { + public: + std::string GenInclude() const override; + std::string GenParcelInclude() const override; + std::string GenParcel() const override; + std::string GenClientBaseConstructor() const override; + std::string GenServerBaseConstructor() const override; + std::string GenGroupBaseConstructor() const override; +}; + +} // namespace tidl + +#endif // IDLC_GEN_AITT_PLUGIN_JAVA_TRANSPORTABLE_H_ diff --git a/idlc/gen_aitt_plugin/aitt_plugin_loader.cc b/idlc/gen_aitt_plugin/aitt_plugin_loader.cc index e1d75f2..6df5431 100644 --- a/idlc/gen_aitt_plugin/aitt_plugin_loader.cc +++ b/idlc/gen_aitt_plugin/aitt_plugin_loader.cc @@ -17,6 +17,7 @@ #include "idlc/gen_aitt_plugin/aitt_plugin_loader.h" #include "idlc/gen_aitt_plugin/aitt_plugin_c_transportable.h" +#include "idlc/gen_aitt_plugin/aitt_plugin_java_transportable.h" #include "idlc/gen_cion/default_cpp_transportable.h" #include "idlc/gen_cion/default_java_transportable.h" #include "idlc/gen_cion/default_cs_transportable.h" @@ -28,7 +29,7 @@ AIttPluginLoader::AIttPluginLoader(const std::string& plugin_path) { C_.reset(new AittPluginCTransportable()); // Cpp_.reset(new DefaultCppTransportable()); // Cs_.reset(new DefaultCsTransportable()); -// Java_.reset(new DefaultJavaTransportable()); + Java_.reset(new AittPluginJavaTransportable()); } else { // TODO } diff --git a/idlc/gen_cion/default_java_transportable.cc b/idlc/gen_cion/default_java_transportable.cc index c9005be..3801f32 100644 --- a/idlc/gen_cion/default_java_transportable.cc +++ b/idlc/gen_cion/default_java_transportable.cc @@ -72,6 +72,84 @@ constexpr const char __PEER_INFO_GET_APPID[] = constexpr const char __PEER_INFO_GET_UUID[] = ".getUuid()"; +constexpr const char __CLIENT_BASE_CONSTRUCTOR[] = +R"__java_cb( + /** + * Constructor + * @param mContext The Context + * @param serviceName Service name + */ + public ClientBase(Context mContext, String serviceName) { + mClient = new (mContext, serviceName); + this.mContext = mContext; + } + + /** + * Constructor with security information + * @param mContext The context + * @param serviceName Service name + * @param sec Security information + */ + public ClientBase(Context mContext, String serviceName, sec) { + mClient = new (mContext, serviceName, sec); + this.mContext = mContext; + } +)__java_cb"; + +constexpr const char __SERVER_BASE_CONSTRUCTOR[] = +R"__java_cb( + /** + * Constructor + * @param mContext Context + * @param mServiceName Service name + * @param mDisplayName Display name + */ + public ServerBase(Context mContext, String mServiceName, String mDisplayName) { + mServer = new (mContext, mServiceName, mDisplayName); + this.mContext = mContext; + this.mServiceName = mServiceName; + this.mDisplayName = mDisplayName; + } + + /** + * Constructor with security information + * @param mContext Context + * @param mServiceName Service name + * @param mDisplayName Display name + * @param sec Security information + */ + public ServerBase(Context mContext, String mServiceName, String mDisplayName, sec) { + mServer = new (mContext, mServiceName, mDisplayName, sec); + this.mContext = mContext; + this.mServiceName = mServiceName; + this.mDisplayName = mDisplayName; + } +)__java_cb"; + +constexpr const char __GROUP_BASE_CONSTRUCTOR[] = +R"__java_cb( + /** + * Constructor + * @param mContext The Context + * @param topicName Topic name + */ + public GroupBase(Context mContext, String topicName) { + mGroup = new (mContext, topicName); + this.mContext = mContext; + } + + /** + * Constructor with security information + * @param mContext The context + * @param topicName Topic name + * @param sec Security information + */ + public GroupBase(Context mContext, String topicName, sec) { + mGroup = new (mContext, topicName, sec); + this.mContext = mContext; + } +)__java_cb"; + } // namespace namespace tidl { @@ -80,6 +158,14 @@ std::string DefaultJavaTransportable::GenInclude() const { return "import org.tizen.cion.*;"; } +std::string DefaultJavaTransportable::GenParcelInclude() const { + return "import org.tizen.cion.CionParcel;"; +} + +std::string DefaultJavaTransportable::GenParcel() const { + return "CionParcel"; +} + std::string DefaultJavaTransportable::GenClientChannel() const { return "ClientChannel"; } @@ -226,4 +312,16 @@ std::string DefaultJavaTransportable::GenPeerInfoGetUUID( { "", peer} })); } +std::string DefaultJavaTransportable::GenClientBaseConstructor() const { + return __CLIENT_BASE_CONSTRUCTOR; +} + +std::string DefaultJavaTransportable::GenServerBaseConstructor() const { + return __SERVER_BASE_CONSTRUCTOR; +} + +std::string DefaultJavaTransportable::GenGroupBaseConstructor() const { + return __GROUP_BASE_CONSTRUCTOR; +} + } // namespace tidl diff --git a/idlc/gen_cion/default_java_transportable.h b/idlc/gen_cion/default_java_transportable.h index f49bc28..f2a3557 100644 --- a/idlc/gen_cion/default_java_transportable.h +++ b/idlc/gen_cion/default_java_transportable.h @@ -27,6 +27,8 @@ class DefaultJavaTransportable : public JavaTransportable { public: virtual ~DefaultJavaTransportable() = default; std::string GenInclude() const override; + std::string GenParcelInclude() const override; + std::string GenParcel() const override; std::string GenClientChannel() const override; std::string GenServerChannel() const override; std::string GenGroupChannel() const override; @@ -59,6 +61,9 @@ class DefaultJavaTransportable : public JavaTransportable { std::string peer) const override; std::string GenPeerInfoGetAppID(std::string peer) const override; std::string GenPeerInfoGetUUID(std::string peer) const override; + std::string GenClientBaseConstructor() const override; + std::string GenServerBaseConstructor() const override; + std::string GenGroupBaseConstructor() const override; }; } // namespace tidl diff --git a/idlc/gen_cion/java_cion_common_gen.cc b/idlc/gen_cion/java_cion_common_gen.cc index 9c32632..7850897 100644 --- a/idlc/gen_cion/java_cion_common_gen.cc +++ b/idlc/gen_cion/java_cion_common_gen.cc @@ -37,7 +37,11 @@ void JavaCionCommonGen::OnInitGen(std::ofstream& stream) { stream.open(fname + "/DelegatorBase.java"); stream << "package org.tizen.gen." << FileName + ".common;" << NLine(1); - stream << ReplaceAll(DELEGATOR_BASE, "", GetDelegateId()); + stream << ReplaceAll(DELEGATOR_BASE, { + { "", GetDelegateId() }, + { "", GetTransportable().Java().GenParcelInclude() }, + { "", GetTransportable().Java().GenParcel() } + }); stream.close(); stream.open(fname + "/NotConnectedSocketException.java"); diff --git a/idlc/gen_cion/java_cion_gen_base.cc b/idlc/gen_cion/java_cion_gen_base.cc index d4739ac..7831352 100644 --- a/idlc/gen_cion/java_cion_gen_base.cc +++ b/idlc/gen_cion/java_cion_gen_base.cc @@ -248,8 +248,9 @@ std::string JavaCionGeneratorBase::MakeDir(const std::string& file_name, void JavaCionGeneratorBase::GenSerializer(std::ofstream& stream, const Structure& st) { - stream << Tab(1) << "private static void serialize(CionParcel h, " - << st.GetID() << " param) "; + stream << Tab(1) << ReplaceAll("private static void serialize( h, ", + "", GetTransportable().Java().GenParcel()) + << st.GetID() << " param) "; GenBrace(stream, TAB_SIZE * 1, [&]() { for (const auto& i : st.GetElements()) { auto& t = i->GetType(); @@ -270,8 +271,9 @@ void JavaCionGeneratorBase::GenSerializer(std::ofstream& stream, } }, false); stream << NLine(1); - stream << Tab(1) << "private static void deserialize(CionParcel h, " - << st.GetID() << " param) "; + stream << Tab(1) << ReplaceAll("private static void deserialize( h, ", + "", GetTransportable().Java().GenParcel()) + << st.GetID() << " param) "; GenBrace(stream, TAB_SIZE * 1, [&]() { for (const auto& i : st.GetElements()) { auto& t = i->GetType(); @@ -316,9 +318,10 @@ void JavaCionGeneratorBase::GenListSerializer(std::ofstream& stream, return; auto& mt = *ptr; - stream << Tab(1) << "private static void serialize(CionParcel h, " - << ConvertTypeToString(type) << " param, " - << ConvertTypeToString(mt, true) << " a) "; + stream << Tab(1) << ReplaceAll("private static void serialize( h, ", + "", GetTransportable().Java().GenParcel()) + << ConvertTypeToString(type) << " param, " + << ConvertTypeToString(mt, true) << " a) "; GenBrace(stream, TAB_SIZE, [&]() { stream << Tab(2) << "h.write(param.size());" @@ -339,9 +342,10 @@ void JavaCionGeneratorBase::GenListSerializer(std::ofstream& stream, }, false); stream << NLine(1); - stream << Tab(1) << "private static void deserialize(CionParcel h, " - << ConvertTypeToString(type) << " param, " - << ConvertTypeToString(mt, true) << " a) "; + stream << Tab(1) << ReplaceAll("private static void deserialize( h, ", + "", GetTransportable().Java().GenParcel()) + << ConvertTypeToString(type) << " param, " + << ConvertTypeToString(mt, true) << " a) "; GenBrace(stream, TAB_SIZE, [&]() { stream << Tab(2) << "int l = h.readInt();" @@ -427,7 +431,10 @@ void JavaCionGeneratorBase::GenCallbackProxy(std::ofstream& stream, const Declaration& decl, const std::string& id) { std::string str; - str = ReplaceAll(CB_CALLBACK_CLASS_PROXY, "", decl.GetID()); + str = ReplaceAll(CB_CALLBACK_CLASS_PROXY, { + { "", decl.GetID() }, + { "", GetTransportable().Java().GenParcel() } + }); str = ReplaceAll(str, "", GetParameters(decl.GetParameters())); str = ReplaceAll(str, "", @@ -443,7 +450,8 @@ void JavaCionGeneratorBase::GenCallbackStub(std::ofstream& stream, std::string str; str = ReplaceAll(CB_CALLBACK_CLASS_STUB, { { "", decl.GetID() }, - { "", GetTransportable().Java().GenPeerInfoType() } + { "", GetTransportable().Java().GenPeerInfoType() }, + { "", GetTransportable().Java().GenParcel() } }); str = ReplaceAll(str, "", GetParameters(decl.GetParameters())); diff --git a/idlc/gen_cion/java_cion_gen_cb.h b/idlc/gen_cion/java_cion_gen_cb.h index 6f50581..2901323 100644 --- a/idlc/gen_cion/java_cion_gen_cb.h +++ b/idlc/gen_cion/java_cion_gen_cb.h @@ -34,28 +34,7 @@ public abstract class ClientBase implements DiscoveryCallback, private mClient; private Context mContext; - - /** - * Constructor - * @param mContext The Context - * @param serviceName Service name - */ - public ClientBase(Context mContext, String serviceName) { - mClient = new (mContext, serviceName); - this.mContext = mContext; - } - - /** - * Constructor with security information - * @param mContext The context - * @param serviceName Service name - * @param sec Security information - */ - public ClientBase(Context mContext, String serviceName, sec) { - mClient = new (mContext, serviceName, sec); - this.mContext = mContext; - } - + /** * Disconnects server */ @@ -135,34 +114,7 @@ public abstract class ServerBase implements ServerConnectionLifecycleCallback, private String mServiceName; private String mDisplayName; - - /** - * Constructor - * @param mContext Context - * @param mServiceName Service name - * @param mDisplayName Display name - */ - public ServerBase(Context mContext, String mServiceName, String mDisplayName) { - mServer = new (mContext, mServiceName, mDisplayName); - this.mContext = mContext; - this.mServiceName = mServiceName; - this.mDisplayName = mDisplayName; - } - - /** - * Constructor with security information - * @param mContext Context - * @param mServiceName Service name - * @param mDisplayName Display name - * @param sec Security information - */ - public ServerBase(Context mContext, String mServiceName, String mDisplayName, sec) { - mServer = new (mContext, mServiceName, mDisplayName, sec); - this.mContext = mContext; - this.mServiceName = mServiceName; - this.mDisplayName = mDisplayName; - } - + /** * Gets context * @return Context @@ -252,28 +204,7 @@ public abstract class GroupBase implements GroupConnectionLifecycleCallback{ private mGroup; private Context mContext; - - /** - * Constructor - * @param mContext The Context - * @param topicName Topic name - */ - public GroupBase(Context mContext, String topicName) { - mGroup = new (mContext, topicName); - this.mContext = mContext; - } - - /** - * Constructor with security information - * @param mContext The context - * @param topicName Topic name - * @param sec Security information - */ - public GroupBase(Context mContext, String topicName, sec) { - mGroup = new (mContext, topicName, sec); - this.mContext = mContext; - } - + /** * Subscribes the topic. */ @@ -342,7 +273,7 @@ public class Ref { const char DELEGATOR_BASE[] = R"__java_cb( -import org.tizen.cion.CionParcel; + /** * Abstract class for making delegator @@ -373,7 +304,7 @@ public abstract class DelegatorBase { * This method will be invoked when the remote callback is called * @param parcel Data */ - public abstract void onInvoked(CionParcel parcel); + public abstract void onInvoked( parcel); /** * Gets sequence ID @@ -399,13 +330,13 @@ public abstract class DelegatorBase { return mOnce; } - public static void serialize(CionParcel h, DelegatorBase from) { + public static void serialize( h, DelegatorBase from) { h.write(from.mId); h.write(from.mSeqId); h.write(from.mOnce); } - public static void deserialize(CionParcel h, DelegatorBase to) { + public static void deserialize( h, DelegatorBase to) { to.mId = h.readInt(); to.mSeqId = h.readInt(); to.mOnce = h.readBoolean(); @@ -441,7 +372,7 @@ R"__java_cb( } @Override - public final void onInvoked(CionParcel parcel) { + public final void onInvoked( parcel) { } @@ -471,7 +402,7 @@ R"__java_cb( } @Override - public final void onInvoked(CionParcel parcel) {} + public final void onInvoked( parcel) {} /** * Invokes a remote callback @@ -482,7 +413,7 @@ R"__java_cb( if (isOnce() && !mValid) throw new InvalidCallbackException(); - CionParcel p = new CionParcel(); + p = new (); p.write(__CALLBACK); serialize(p, this); diff --git a/idlc/gen_cion/java_cion_group_gen.cc b/idlc/gen_cion/java_cion_group_gen.cc index b132241..c1e7afb 100644 --- a/idlc/gen_cion/java_cion_group_gen.cc +++ b/idlc/gen_cion/java_cion_group_gen.cc @@ -155,8 +155,10 @@ void JavaCionGroupGen::GenMethods(std::ofstream& stream, const Interface& iface) void JavaCionGroupGen::GenCionPayloadReceivedEvent(std::ofstream& stream, const Interface& iface) { - stream << ReplaceAll(CB_ON_PAYLOAD_RECEIVED_FRONT, - "", GetTransportable().Java().GenPeerInfoType()); + stream << ReplaceAll(CB_ON_PAYLOAD_RECEIVED_FRONT, { + { "", GetTransportable().Java().GenPeerInfoType() }, + { "", GetTransportable().Java().GenParcel() } + }); for (const auto& i : iface.GetDeclarations()) { if (i->GetMethodType() == Declaration::MethodType::DELEGATE || @@ -198,7 +200,8 @@ void JavaCionGroupGen::GenHandlerInvocation(std::ofstream& stream, } void JavaCionGroupGen::GenInvocation(std::ofstream& stream, const Declaration& decl) { - GenTemplate(CB_INVOCATION_PRE, stream, + GenTemplate(std::string(ReplaceAll(CB_INVOCATION_PRE, + "", GetTransportable().Java().GenParcel())), stream, [&]()->std::string { std::string st; st += Tab(2) diff --git a/idlc/gen_cion/java_cion_group_gen_cb.h b/idlc/gen_cion/java_cion_group_gen_cb.h index cf1cf5a..e69ce0f 100644 --- a/idlc/gen_cion/java_cion_group_gen_cb.h +++ b/idlc/gen_cion/java_cion_group_gen_cb.h @@ -52,9 +52,9 @@ R"__java_cb( @Override return; } - CionParcel parcelReceived; + parcelReceived; - parcelReceived = new CionParcel(((DataPayload)payload).getData()); + parcelReceived = new (((DataPayload)payload).getData()); int cmd = parcelReceived.readInt(); switch (cmd) { @@ -69,7 +69,7 @@ R"__java_cb( )__java_cb"; const char CB_INVOCATION_PRE[] = -R"__java_cb( CionParcel p = new CionParcel(); +R"__java_cb( p = new (); $$ )__java_cb"; diff --git a/idlc/gen_cion/java_cion_group_repo_gen.cc b/idlc/gen_cion/java_cion_group_repo_gen.cc index 0ab0ab1..895cc80 100644 --- a/idlc/gen_cion/java_cion_group_repo_gen.cc +++ b/idlc/gen_cion/java_cion_group_repo_gen.cc @@ -43,6 +43,8 @@ void JavaCionGroupRepoGen::OnInitGen(std::ofstream& stream) { stream << "package org.tizen.gen." << FileName + ".group;" << NLine(2); stream << ReplaceAll(DEFAULT_GROUP_REPO, { { "", GetTransportable().Java().GenInclude() }, + { "", + GetTransportable().Java().GenGroupBaseConstructor() }, { "", GetTransportable().Java().GenGroupChannel() }, { "", GetTransportable().Java().GenGroupSubscribe("mGroup") }, diff --git a/idlc/gen_cion/java_cion_proxy_gen.cc b/idlc/gen_cion/java_cion_proxy_gen.cc index cdf65b8..bd078e7 100644 --- a/idlc/gen_cion/java_cion_proxy_gen.cc +++ b/idlc/gen_cion/java_cion_proxy_gen.cc @@ -65,8 +65,10 @@ void JavaCionProxyGen::GenInterface(std::ofstream& stream, const Interface& ifac GenCallbacks(stream, iface, true); GenDelegateId(stream, iface); GenMethodId(stream, iface); - stream << ReplaceAll(CB_EVENT_METHODS, - "", GetTransportable().Java().GenPeerInfoType()); + stream << ReplaceAll(CB_EVENT_METHODS, { + { "", GetTransportable().Java().GenPeerInfoType() }, + { "", GetTransportable().Java().GenParcel() }, + }); GenSerializer(stream); GenListSerializer(stream); GenShareFile(stream, iface, true); @@ -140,7 +142,8 @@ void JavaCionProxyGen::GenMethods(std::ofstream& stream, const Interface& iface) } void JavaCionProxyGen::GenInvocation(std::ofstream& stream, const Declaration& decl) { - GenTemplate(CB_INVOCATION_PRE, stream, + GenTemplate(std::string(ReplaceAll(CB_INVOCATION_PRE, "", + GetTransportable().Java().GenParcel())), stream, [&]()->std::string { std::string st; st += Tab(2) @@ -170,7 +173,8 @@ void JavaCionProxyGen::GenInvocation(std::ofstream& stream, const Declaration& d if (decl.GetMethodType() == Declaration::MethodType::ASYNC) { st += CB_ASYNC_INVOCATION_MID; } else { - st += CB_SYNC_INVOCATION_MID; + st += ReplaceAll(CB_SYNC_INVOCATION_MID, + "", GetTransportable().Java().GenParcel()); } for (const auto& i : decl.GetParameters()) { diff --git a/idlc/gen_cion/java_cion_proxy_gen_cb.h b/idlc/gen_cion/java_cion_proxy_gen_cb.h index 21e560f..a68fec5 100644 --- a/idlc/gen_cion/java_cion_proxy_gen_cb.h +++ b/idlc/gen_cion/java_cion_proxy_gen_cb.h @@ -33,7 +33,7 @@ R"__java_cb( const char CB_EVENT_METHODS[] = R"__java_cb( - private void processReceivedEvent(CionParcel parcel) { + private void processReceivedEvent( parcel) { int id = parcel.readInt(); int seqId = parcel.readInt(); boolean once = parcel.readBoolean(); @@ -86,9 +86,9 @@ R"__java_cb( if(payload.getType() == IPayload.PayloadType.PAYLOAD_FILE) { onFileReceived((FilePayload)payload, status); } else { - CionParcel parcelReceived; + parcelReceived; - parcelReceived = new CionParcel(((DataPayload)payload).getData()); + parcelReceived = new (((DataPayload)payload).getData()); int cmd = parcelReceived.readInt(); if (cmd != __CALLBACK) return; @@ -126,7 +126,7 @@ const char CB_INVOCATION_PRE[] = R"__java_cb( if (!mOnline) throw new NotConnectedSocketException(); - CionParcel p = new CionParcel(); + p = new (); $$ )__java_cb"; @@ -150,7 +150,7 @@ R"__java_cb( // Send byte[] dataReceived = sendData(p.toByteArray()); - CionParcel parcelReceived = new CionParcel(dataReceived); + parcelReceived = new (dataReceived); int cmd = parcelReceived.readInt(); if (cmd != __RESULT) diff --git a/idlc/gen_cion/java_cion_proxy_repo_gen.cc b/idlc/gen_cion/java_cion_proxy_repo_gen.cc index 4c04cfe..80fd2a1 100644 --- a/idlc/gen_cion/java_cion_proxy_repo_gen.cc +++ b/idlc/gen_cion/java_cion_proxy_repo_gen.cc @@ -44,6 +44,8 @@ void JavaCionProxyRepoGen::OnInitGen(std::ofstream& stream) { stream << ReplaceAll(DEFAULT_PROXY_REPO, { { "", GetTransportable().Java().GenInclude() }, { "", GetTransportable().Java().GenPeerInfoType() }, + { "", + GetTransportable().Java().GenClientBaseConstructor() }, { "", GetTransportable().Java().GenClientChannel() }, { "", GetTransportable().Java() .GenClientSendAsync("mClient", "payload") }, diff --git a/idlc/gen_cion/java_cion_structure_gen.cc b/idlc/gen_cion/java_cion_structure_gen.cc index e34b6c9..d40cf2d 100644 --- a/idlc/gen_cion/java_cion_structure_gen.cc +++ b/idlc/gen_cion/java_cion_structure_gen.cc @@ -51,7 +51,7 @@ void JavaCionStructureGen::GenStructure(std::ofstream& stream, const Structure& st) { const char variable[] = "$$\n"; - stream << "import org.tizen.cion.CionParcel;" << NLine(1); + stream << GetTransportable().Java().GenParcelInclude() << NLine(1); stream << "import java.util.ArrayList;" << NLine(1); stream << "import java.util.LinkedList;" << NLine(1); stream << NLine(1); diff --git a/idlc/gen_cion/java_cion_stub_gen.cc b/idlc/gen_cion/java_cion_stub_gen.cc index 74edda9..d701044 100644 --- a/idlc/gen_cion/java_cion_stub_gen.cc +++ b/idlc/gen_cion/java_cion_stub_gen.cc @@ -109,6 +109,7 @@ void JavaCionStubGen::GenReceivedSyncEvent(std::ofstream& stream, GetTransportable().Java().GenPeerInfoGetUUID("i.mClient") }, { "", GetTransportable().Java().GenPeerInfoGetUUID("info") }, + { "", GetTransportable().Java().GenParcel() } }); for (const auto& i : iface.GetDeclarations()) { if (i->GetMethodType() != Declaration::MethodType::SYNC) @@ -134,6 +135,7 @@ void JavaCionStubGen::GenReceivedAsyncEvent(std::ofstream& stream, GetTransportable().Java().GenPeerInfoGetUUID("i.mClient") }, { "", GetTransportable().Java().GenPeerInfoGetUUID("info") }, + { "", GetTransportable().Java().GenParcel() } }); for (const auto& i : iface.GetDeclarations()) { if (i->GetMethodType() != Declaration::MethodType::ASYNC) diff --git a/idlc/gen_cion/java_cion_stub_gen_cb.h b/idlc/gen_cion/java_cion_stub_gen_cb.h index 381b48a..c434eac 100644 --- a/idlc/gen_cion/java_cion_stub_gen_cb.h +++ b/idlc/gen_cion/java_cion_stub_gen_cb.h @@ -130,7 +130,7 @@ R"__java_cb( @Override public final void onPayloadReceived( info, IPayload data, PayloadTransferStatus status) { try { - CionParcel p; + p; ServiceBase b = null; for (ServiceBase i : mServices) { @@ -153,7 +153,7 @@ R"__java_cb( } DataPayload dp = (DataPayload)data; - p = new CionParcel(dp.getData()); + p = new (dp.getData()); int cmd = p.readInt(); switch (cmd) { )__java_cb"; @@ -174,10 +174,10 @@ const char CB_ON_RECEIVED_SYNC_EVENT_FRONT[] = R"__java_cb( @Override public final byte[] onDataReceived( info, byte[] data) { - CionParcel p; + p; byte[] returnData = new byte[0]; - p = new CionParcel(data); + p = new (data); try { ServiceBase b = null; @@ -195,7 +195,7 @@ R"__java_cb( if (b == null) return returnData; - CionParcel result = new CionParcel(); + result = new (); int cmd = p.readInt(); switch (cmd) { diff --git a/idlc/gen_cion/java_cion_stub_repo_gen.cc b/idlc/gen_cion/java_cion_stub_repo_gen.cc index 3c855b5..b640b03 100644 --- a/idlc/gen_cion/java_cion_stub_repo_gen.cc +++ b/idlc/gen_cion/java_cion_stub_repo_gen.cc @@ -44,6 +44,8 @@ void JavaCionStubRepoGen::OnInitGen(std::ofstream& stream) { stream << ReplaceAll(DEFAULT_STUB_REPO, { { "", GetTransportable().Java().GenInclude() }, { "", GetTransportable().Java().GenPeerInfoType() }, + { "", + GetTransportable().Java().GenServerBaseConstructor() }, { "", GetTransportable().Java().GenServerChannel() }, { "", GetTransportable().Java().GenServerSendAsync("mServer", "payload") }, { "", GetTransportable().Java().GenServerListen("mServer") }, diff --git a/idlc/gen_cion/java_transportable.h b/idlc/gen_cion/java_transportable.h index ec23311..42ccd32 100644 --- a/idlc/gen_cion/java_transportable.h +++ b/idlc/gen_cion/java_transportable.h @@ -25,6 +25,8 @@ class JavaTransportable { public: virtual ~JavaTransportable() = default; virtual std::string GenInclude() const = 0; + virtual std::string GenParcelInclude() const = 0; + virtual std::string GenParcel() const = 0; virtual std::string GenClientChannel() const = 0; virtual std::string GenServerChannel() const = 0; virtual std::string GenGroupChannel() const = 0; @@ -57,6 +59,9 @@ class JavaTransportable { std::string peer) const = 0; virtual std::string GenPeerInfoGetAppID(std::string peer) const = 0; virtual std::string GenPeerInfoGetUUID(std::string peer) const = 0; + virtual std::string GenClientBaseConstructor() const = 0; + virtual std::string GenServerBaseConstructor() const = 0; + virtual std::string GenGroupBaseConstructor() const = 0; }; } // namespace tidl diff --git a/idlc/main.cc b/idlc/main.cc index ba6d098..1e72e51 100644 --- a/idlc/main.cc +++ b/idlc/main.cc @@ -161,6 +161,20 @@ void GenerateStubCodes(std::shared_ptr options, } case tidl::Options::LANGUAGE_TYPE_JAVA: { + tidl::JavaCionStubRepoGen repo(ps.GetDoc(), trans); + repo.Run(options->GetOutput(), true); + + tidl::JavaCionStubGen view_model(ps.GetDoc(), trans); + view_model.Run(options->GetOutput(), true); + + tidl::JavaCionUtilityGen utilities(ps.GetDoc(), trans); + utilities.Run(options->GetOutput(), true); + + tidl::JavaCionStructureGen structures(ps.GetDoc(), trans); + structures.Run(options->GetOutput(), true); + + tidl::JavaCionCommonGen cgen(ps.GetDoc(), trans); + cgen.Run(options->GetOutput(), true); break; } @@ -297,6 +311,20 @@ void GenerateProxyCodes(std::shared_ptr options, } case tidl::Options::LANGUAGE_TYPE_JAVA: { + tidl::JavaCionProxyRepoGen base_files(ps.GetDoc(), trans); + base_files.Run(options->GetOutput(), true); + + tidl::JavaCionProxyGen view_model(ps.GetDoc(), trans); + view_model.Run(options->GetOutput(), true); + + tidl::JavaCionUtilityGen utilities(ps.GetDoc(), trans); + utilities.Run(options->GetOutput(), true); + + tidl::JavaCionStructureGen structures(ps.GetDoc(), trans); + structures.Run(options->GetOutput(), true); + + tidl::JavaCionCommonGen cgen(ps.GetDoc(), trans); + cgen.Run(options->GetOutput(), true); break; } @@ -432,6 +460,20 @@ void GenerateGroupCodes(std::shared_ptr options, } case tidl::Options::LANGUAGE_TYPE_JAVA: { + tidl::JavaCionGroupRepoGen repo(ps.GetDoc(), trans); + repo.Run(options->GetOutput(), true); + + tidl::JavaCionGroupGen view_model(ps.GetDoc(), trans); + view_model.Run(options->GetOutput(), true); + + tidl::JavaCionUtilityGen utilities(ps.GetDoc(), trans); + utilities.Run(options->GetOutput(), true); + + tidl::JavaCionStructureGen structures(ps.GetDoc(), trans); + structures.Run(options->GetOutput(), true); + + tidl::JavaCionCommonGen cgen(ps.GetDoc(), trans); + cgen.Run(options->GetOutput(), true); break; } -- 2.7.4