//int rpc_port_parcel_read_array_count(rpc_port_parcel_h h, int *count);
[DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_read_array_count")]
internal static extern ErrorCode ReadArrayCount(IntPtr parcelHandle, out int count);
+
+ //int rpc_port_parcel_burst_read(rpc_port_parcel_h h, unsigned char *buf, unsigned int size);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_burst_read")]
+ internal static extern ErrorCode Read(IntPtr parcelHandle, [In, Out] byte[] buf, int size);
+
+ //int rpc_port_parcel_burst_write(rpc_port_parcel_h h, const unsigned char *buf, unsigned int size);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_burst_write")]
+ internal static extern ErrorCode Write(IntPtr parcelHandle, byte[] buf, int size);
+ }
+
+ internal static partial class Proxy
+ {
+ //typedef void (*rpc_port_proxy_connected_event_cb)(const char *ep, const char* port_name, rpc_port_h port, void* data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ConnectedEventCallback(string endPoint, string port_name, IntPtr port, IntPtr data);
+
+ //typedef void (*rpc_port_proxy_disconnected_event_cb)(const char *ep, const char* port_name, void* data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void DisconnectedEventCallback(string endPoint, string port_name, IntPtr data);
+
+ //typedef void (*rpc_port_proxy_rejected_event_cb) (const char* ep, const char* port_name, void* data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void RejectedEventCallback(string endPoint, string port_name, IntPtr data);
+
+ //typedef void (*rpc_port_proxy_received_event_cb) (const char* ep, const char* port_name, void* data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ReceivedEventCallback(string endPoint, string port_name, IntPtr data);
+
+ //int rpc_port_proxy_create(rpc_port_proxy_h *h);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_create")]
+ internal static extern ErrorCode Create(out IntPtr handle);
+
+ //int rpc_port_proxy_destroy(rpc_port_proxy_h h);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_destroy")]
+ internal static extern ErrorCode Destroy(IntPtr handle);
+
+ //int rpc_port_proxy_connect(rpc_port_proxy_h h, const char *appid, const char* port);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_connect")]
+ internal static extern ErrorCode Connect(IntPtr handle, string appId, string port);
+
+ //int rpc_port_proxy_add_connected_event_cb(rpc_port_proxy_h h, rpc_port_proxy_connected_event_cb cb, void* data);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_add_connected_event_cb")]
+ internal static extern ErrorCode AddConnectedEventCb(IntPtr handle, ConnectedEventCallback cb, IntPtr data);
+
+ //int rpc_port_proxy_add_disconnected_event_cb(rpc_port_proxy_h h, rpc_port_proxy_disconnected_event_cb cb, void* data);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_add_disconnected_event_cb")]
+ internal static extern ErrorCode AddDisconnectedEventCb(IntPtr handle, DisconnectedEventCallback cb, IntPtr data);
+
+ //int rpc_port_proxy_add_rejected_event_cb(rpc_port_proxy_h h, rpc_port_proxy_rejected_event_cb cb, void* data);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_add_rejected_event_cb")]
+ internal static extern ErrorCode AddRejectedEventCb(IntPtr handle, RejectedEventCallback cb, IntPtr data);
+
+ //int rpc_port_proxy_add_received_event_cb(rpc_port_proxy_h h, rpc_port_proxy_received_event_cb cb, void* data);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_add_received_event_cb")]
+ internal static extern ErrorCode AddReceivedEventCb(IntPtr handle, ReceivedEventCallback cb, IntPtr data);
+ }
+
+ internal static partial class Stub
+ {
+ //typedef void (*rpc_port_stub_connected_event_cb)(const char *sender, const char *instance, void* data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ConnectedEventCallback(string sender, string instance, IntPtr data);
+
+ //typedef void (* rpc_port_stub_disconnected_event_cb) (const char* sender, const char *instance, void* data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void DisconnectedEventCallback(string sender, string instance, IntPtr data);
+
+ //typedef void (* rpc_port_stub_received_event_cb) (const char* sender, const char *instance, rpc_port_h port, void* data);
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate int ReceivedEventCallback(string sender, string instance, IntPtr port, IntPtr data);
+
+ //int rpc_port_stub_create(rpc_port_stub_h* h, const char* port_name);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_create")]
+ internal static extern ErrorCode Create(out IntPtr handle, string portName);
+
+ //int rpc_port_stub_destroy(rpc_port_stub_h h);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_destroy")]
+ internal static extern ErrorCode Destroy(IntPtr handle);
+
+ //int rpc_port_stub_listen(rpc_port_stub_h h);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_listen")]
+ internal static extern ErrorCode Listen(IntPtr handle);
+
+ //int rpc_port_stub_add_connected_event_cb(rpc_port_stub_h h, rpc_port_stub_connected_event_cb cb, void* data);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_add_connected_event_cb")]
+ internal static extern ErrorCode AddConnectedEventCb(IntPtr handle, ConnectedEventCallback cb, IntPtr data);
+
+ //int rpc_port_stub_add_disconnected_event_cb(rpc_port_stub_h h, rpc_port_stub_disconnected_event_cb cb, void* data);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_add_disconnected_event_cb")]
+ internal static extern ErrorCode AddDisconnectedEventCb(IntPtr handle, DisconnectedEventCallback cb, IntPtr data);
+
+ //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 ErrorCode 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 ErrorCode 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 ErrorCode SetTrusted(IntPtr handle, bool trusted);
}
-$$
}
}
)__cs_cb";
+++ /dev/null
-/*
- * Copyright (c) 2018 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_CS_GEN_CS_CB_PROXY_INTEROP_H_
-#define IDLC_CS_GEN_CS_CB_PROXY_INTEROP_H_
-
-const char cs_cb_proxy_interop[] =
-R"__cs_cb(
- internal static partial class Proxy
- {
- //typedef void (*rpc_port_proxy_connected_event_cb)(const char *ep, const char* port_name, rpc_port_h port, void* data);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void ConnectedEventCallback(string endPoint, string port_name, IntPtr port, IntPtr data);
-
- //typedef void (*rpc_port_proxy_disconnected_event_cb)(const char *ep, const char* port_name, void* data);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void DisconnectedEventCallback(string endPoint, string port_name, IntPtr data);
-
- //typedef void (*rpc_port_proxy_rejected_event_cb) (const char* ep, const char* port_name, void* data);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void RejectedEventCallback(string endPoint, string port_name, IntPtr data);
-
- //typedef void (*rpc_port_proxy_received_event_cb) (const char* ep, const char* port_name, void* data);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void ReceivedEventCallback(string endPoint, string port_name, IntPtr data);
-
- //int rpc_port_proxy_create(rpc_port_proxy_h *h);
- [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_create")]
- internal static extern ErrorCode Create(out IntPtr handle);
-
- //int rpc_port_proxy_destroy(rpc_port_proxy_h h);
- [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_destroy")]
- internal static extern ErrorCode Destroy(IntPtr handle);
-
- //int rpc_port_proxy_connect(rpc_port_proxy_h h, const char *appid, const char* port);
- [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_connect")]
- internal static extern ErrorCode Connect(IntPtr handle, string appId, string port);
-
- //int rpc_port_proxy_add_connected_event_cb(rpc_port_proxy_h h, rpc_port_proxy_connected_event_cb cb, void* data);
- [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_add_connected_event_cb")]
- internal static extern ErrorCode AddConnectedEventCb(IntPtr handle, ConnectedEventCallback cb, IntPtr data);
-
- //int rpc_port_proxy_add_disconnected_event_cb(rpc_port_proxy_h h, rpc_port_proxy_disconnected_event_cb cb, void* data);
- [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_add_disconnected_event_cb")]
- internal static extern ErrorCode AddDisconnectedEventCb(IntPtr handle, DisconnectedEventCallback cb, IntPtr data);
-
- //int rpc_port_proxy_add_rejected_event_cb(rpc_port_proxy_h h, rpc_port_proxy_rejected_event_cb cb, void* data);
- [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_add_rejected_event_cb")]
- internal static extern ErrorCode AddRejectedEventCb(IntPtr handle, RejectedEventCallback cb, IntPtr data);
-
- //int rpc_port_proxy_add_received_event_cb(rpc_port_proxy_h h, rpc_port_proxy_received_event_cb cb, void* data);
- [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_proxy_add_received_event_cb")]
- internal static extern ErrorCode AddReceivedEventCb(IntPtr handle, ReceivedEventCallback cb, IntPtr data);
- }
-)__cs_cb";
-
-#endif // IDLC_CS_GEN_CS_CB_PROXY_INTEROP_H_
--- /dev/null
+/*
+ * Copyright (c) 2018 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_CS_GEN_CS_CB_RPC_PORT_H_
+#define IDLC_CS_GEN_CS_CB_RPC_PORT_H_
+
+const char cs_cb_rpc_port[] =
+R"__cs_cb(
+namespace Tizen.Applications.RPCPort
+{
+ public class InvalidIOException : InvalidOperationException { }
+ public class InvalidIDException : InvalidOperationException { }
+ public class PermissionDeniedException : InvalidOperationException { }
+ public class InvalidProtocolException : InvalidOperationException { }
+ public class NotConnectedSocketException : InvalidOperationException { }
+ public class InvalidCallbackException : InvalidOperationException { }
+
+ public class Port
+ {
+ internal IntPtr Handle { get; set; }
+ internal Port() { }
+ }
+
+ public class Parcel : IDisposable
+ {
+ private IntPtr _handle;
+
+ public Parcel()
+ {
+ Interop.LibRPCPort.Parcel.Create(out _handle);
+ }
+
+ public Parcel(Port port)
+ {
+ Interop.LibRPCPort.Parcel.CreateFromPort(out _handle, port.Handle);
+ }
+
+ public void Send(Port p)
+ {
+ Interop.LibRPCPort.Parcel.Send(_handle, p.Handle);
+ }
+
+ public void WriteByte(byte b)
+ {
+ Interop.LibRPCPort.Parcel.WriteByte(_handle, b);
+ }
+
+ public void WriteShort(short b)
+ {
+ Interop.LibRPCPort.Parcel.WriteInt16(_handle, b);
+ }
+
+ public void WriteInt(int b)
+ {
+ Interop.LibRPCPort.Parcel.WriteInt32(_handle, b);
+ }
+
+ public void WriteLong(long b)
+ {
+ Interop.LibRPCPort.Parcel.WriteInt64(_handle, b);
+ }
+
+ public void WriteFloat(float b)
+ {
+ Interop.LibRPCPort.Parcel.WriteFloat(_handle, b);
+ }
+
+ public void WriteDouble(double b)
+ {
+ Interop.LibRPCPort.Parcel.WriteDouble(_handle, b);
+ }
+
+ public void WriteString(string b)
+ {
+ Interop.LibRPCPort.Parcel.WriteString(_handle, b);
+ }
+
+ public void WriteBool(bool b)
+ {
+ Interop.LibRPCPort.Parcel.WriteBool(_handle, b);
+ }
+
+ public void WriteBundle(Bundle b)
+ {
+ Interop.LibRPCPort.Parcel.WriteBundle(_handle, b.SafeBundleHandle.DangerousGetHandle());
+ }
+
+ public void WriteArrayCount(int cnt)
+ {
+ Interop.LibRPCPort.Parcel.WriteArrayCount(_handle, cnt);
+ }
+
+ public byte ReadByte()
+ {
+ Interop.LibRPCPort.Parcel.ReadByte(_handle, out byte b);
+ return b;
+ }
+
+ public short ReadShort()
+ {
+ Interop.LibRPCPort.Parcel.ReadInt16(_handle, out short b);
+ return b;
+ }
+
+ public int ReadInt()
+ {
+ Interop.LibRPCPort.Parcel.ReadInt32(_handle, out int b);
+ return b;
+ }
+
+ public long ReadLong()
+ {
+ Interop.LibRPCPort.Parcel.ReadInt64(_handle, out long b);
+ return b;
+ }
+
+ public float ReadFloat()
+ {
+ Interop.LibRPCPort.Parcel.ReadFloat(_handle, out float b);
+ return b;
+ }
+
+ public double ReadDouble()
+ {
+ Interop.LibRPCPort.Parcel.ReadDouble(_handle, out double b);
+ return b;
+ }
+
+ public string ReadString()
+ {
+ Interop.LibRPCPort.Parcel.ReadString(_handle, out string b);
+ return b;
+ }
+
+ public bool ReadBool()
+ {
+ Interop.LibRPCPort.Parcel.ReadBool(_handle, out bool b);
+ return b;
+ }
+
+ public Bundle ReadBundle()
+ {
+ Interop.LibRPCPort.Parcel.ReadBundle(_handle, out IntPtr b);
+
+ return new Bundle(new SafeBundleHandle(b, true));
+ }
+
+ public int ReadArrayCount()
+ {
+ Interop.LibRPCPort.Parcel.ReadArrayCount(_handle, out int b);
+ return b;
+ }
+
+ public void Write(byte[] bytes)
+ {
+ Interop.LibRPCPort.Parcel.Write(_handle, bytes, bytes.Length);
+ }
+
+ public byte[] Read(int size)
+ {
+ var ret = new byte[size];
+ Interop.LibRPCPort.Parcel.Read(_handle, ret, size);
+ return ret;
+ }
+
+ #region IDisposable Support
+ private bool disposedValue = false;
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!disposedValue)
+ {
+ if (disposing)
+ {
+ }
+
+ if (_handle != IntPtr.Zero)
+ {
+ Interop.LibRPCPort.Parcel.Destroy(_handle);
+ _handle = IntPtr.Zero;
+ }
+
+ disposedValue = true;
+ }
+ }
+
+ ~Parcel()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ #endregion
+ }
+
+ public abstract class ProxyBase : IDisposable
+ {
+ private Interop.LibRPCPort.Proxy.ConnectedEventCallback _connectedEventCallback;
+ private Interop.LibRPCPort.Proxy.DisconnectedEventCallback _disconnectedEventCallback;
+ private Interop.LibRPCPort.Proxy.RejectedEventCallback _rejectedEventCallback;
+ private Interop.LibRPCPort.Proxy.ReceivedEventCallback _receivedEventCallback;
+ private IntPtr _proxy;
+
+ protected Port Port { get; private set; }
+
+ public ProxyBase()
+ {
+ if (Interop.LibRPCPort.Proxy.Create(out _proxy) != Interop.LibRPCPort.ErrorCode.None)
+ throw new InvalidIOException();
+ _connectedEventCallback = new Interop.LibRPCPort.Proxy.ConnectedEventCallback(OnConnectedEvent);
+ _disconnectedEventCallback = new Interop.LibRPCPort.Proxy.DisconnectedEventCallback(OnDisconnectedEvent);
+ _rejectedEventCallback = new Interop.LibRPCPort.Proxy.RejectedEventCallback(OnRejectedEvent);
+ _receivedEventCallback = new Interop.LibRPCPort.Proxy.ReceivedEventCallback(OnReceivedEvent);
+ Interop.LibRPCPort.Proxy.AddConnectedEventCb(_proxy, _connectedEventCallback, IntPtr.Zero);
+ Interop.LibRPCPort.Proxy.AddDisconnectedEventCb(_proxy, _disconnectedEventCallback, IntPtr.Zero);
+ Interop.LibRPCPort.Proxy.AddRejectedEventCb(_proxy, _rejectedEventCallback, IntPtr.Zero);
+ Interop.LibRPCPort.Proxy.AddReceivedEventCb(_proxy, _receivedEventCallback, IntPtr.Zero);
+ }
+
+ protected void Connect(string appid, string port)
+ {
+ var err = Interop.LibRPCPort.Proxy.Connect(_proxy, appid, port);
+ switch (err)
+ {
+ case Interop.LibRPCPort.ErrorCode.InvalidParameter:
+ throw new InvalidIDException();
+ case Interop.LibRPCPort.ErrorCode.PermissionDenied:
+ throw new PermissionDeniedException();
+ case Interop.LibRPCPort.ErrorCode.IoError:
+ throw new InvalidIOException();
+ }
+ }
+
+ protected abstract void OnConnectedEvent(string endPoint, string portName, Port port);
+ protected abstract void OnDisconnectedEvent(string endPoint, string portName);
+ protected abstract void OnReceivedEvent(string endPoint, string portName);
+ protected abstract void OnRejectedEvent(string endPoint, string portName);
+
+ private void OnConnectedEvent(string endPoint, string portName, IntPtr port, IntPtr data)
+ {
+ Port = new Port() { Handle = port };
+ OnConnectedEvent(endPoint, portName, Port);
+ }
+
+ private void OnDisconnectedEvent(string endPoint, string portName, IntPtr data)
+ {
+ Port = null;
+ OnDisconnectedEvent(endPoint, portName);
+ }
+
+ private void OnReceivedEvent(string endPoint, string portName, IntPtr data)
+ {
+ OnReceivedEvent(endPoint, portName);
+ }
+
+ private void OnRejectedEvent(string endPoint, string portName, IntPtr data)
+ {
+ OnRejectedEvent(endPoint, portName);
+ }
+
+ #region IDisposable Support
+ private bool disposedValue = false;
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!disposedValue)
+ {
+ if (disposing)
+ {
+ }
+ if (_proxy != IntPtr.Zero)
+ Interop.LibRPCPort.Proxy.Destroy(_proxy);
+ _proxy = IntPtr.Zero;
+
+ disposedValue = true;
+ }
+ }
+
+ ~ProxyBase()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ #endregion
+ }
+
+ public abstract class StubBase : IDisposable
+ {
+ private Interop.LibRPCPort.Stub.ConnectedEventCallback _connectedEventCallback;
+ private Interop.LibRPCPort.Stub.DisconnectedEventCallback _disconnectedEventCallback;
+ private Interop.LibRPCPort.Stub.ReceivedEventCallback _receivedEventCallback;
+ private IntPtr _stub;
+
+ public string PortName { get; private set; }
+
+ public StubBase(string portName)
+ {
+ if (Interop.LibRPCPort.Stub.Create(out _stub, portName) != Interop.LibRPCPort.ErrorCode.None)
+ throw new InvalidIOException();
+ PortName = portName;
+ _connectedEventCallback = new Interop.LibRPCPort.Stub.ConnectedEventCallback(OnConnectedEvent);
+ _disconnectedEventCallback = new Interop.LibRPCPort.Stub.DisconnectedEventCallback(OnDisconnectedEvent);
+ _receivedEventCallback = new Interop.LibRPCPort.Stub.ReceivedEventCallback(OnReceivedEvent);
+ Interop.LibRPCPort.Stub.AddReceivedEventCb(_stub, _receivedEventCallback, IntPtr.Zero);
+ Interop.LibRPCPort.Stub.AddConnectedEventCb(_stub, _connectedEventCallback, IntPtr.Zero);
+ Interop.LibRPCPort.Stub.AddDisconnectedEventCb(_stub, _disconnectedEventCallback, IntPtr.Zero);
+ }
+
+ protected void Listen()
+ {
+ var err = Interop.LibRPCPort.Stub.Listen(_stub);
+ switch (err)
+ {
+ case Interop.LibRPCPort.ErrorCode.InvalidParameter:
+ case Interop.LibRPCPort.ErrorCode.IoError:
+ throw new InvalidIOException();
+ }
+ }
+
+ protected void AddPrivilege(string privilege)
+ {
+ var err = Interop.LibRPCPort.Stub.AddPrivilege(_stub, privilege);
+ switch (err)
+ {
+ case Interop.LibRPCPort.ErrorCode.InvalidParameter:
+ throw new InvalidIOException();
+ }
+ }
+
+ protected void SetTrusted(bool trusted)
+ {
+ var err = Interop.LibRPCPort.Stub.SetTrusted(_stub, trusted);
+ switch (err)
+ {
+ case Interop.LibRPCPort.ErrorCode.InvalidParameter:
+ throw new InvalidIOException();
+ }
+ }
+
+ protected abstract void OnConnectedEvent(string sender, string instance);
+
+ protected abstract void OnDisconnectedEvent(string sender, string instance);
+
+ protected abstract bool OnReceivedEvent(string sender, string instance, Port port);
+
+ protected abstract void OnTerminatedEvent();
+
+ private void OnConnectedEvent(string sender, string instance, IntPtr data)
+ {
+ OnConnectedEvent(sender, instance);
+ }
+
+ private void OnDisconnectedEvent(string sender, string instance, IntPtr data)
+ {
+ OnDisconnectedEvent(sender, instance);
+ }
+
+ private int OnReceivedEvent(string sender, string instance, IntPtr port, IntPtr data)
+ {
+ bool b = OnReceivedEvent(sender, instance, new Port() { Handle = port });
+ if (b)
+ return 0;
+ return -1;
+ }
+
+ #region IDisposable Support
+ private bool disposedValue = false;
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!disposedValue)
+ {
+ if (disposing)
+ {
+ }
+
+ OnTerminatedEvent();
+
+ if (_stub != IntPtr.Zero)
+ Interop.LibRPCPort.Proxy.Destroy(_stub);
+ _stub = IntPtr.Zero;
+
+ disposedValue = true;
+ }
+ }
+
+ ~StubBase()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ #endregion
+ }
+}
+
+)__cs_cb";
+
+#endif // IDLC_CS_GEN_CS_CB_RPC_PORT_H_
+++ /dev/null
-/*
- * Copyright (c) 2018 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_CS_GEN_CS_CB_STUB_INTEROP_H_
-#define IDLC_CS_GEN_CS_CB_STUB_INTEROP_H_
-
-const char cs_cb_stub_interop[] =
-R"__cs_cb(
- internal static partial class Stub
- {
- //typedef void (*rpc_port_stub_connected_event_cb)(const char *sender, const char *instance, void* data);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void ConnectedEventCallback(string sender, string instance, IntPtr data);
-
- //typedef void (* rpc_port_stub_disconnected_event_cb) (const char* sender, const char *instance, void* data);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void DisconnectedEventCallback(string sender, string instance, IntPtr data);
-
- //typedef void (* rpc_port_stub_received_event_cb) (const char* sender, const char *instance, rpc_port_h port, void* data);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate int ReceivedEventCallback(string sender, string instance, IntPtr port, IntPtr data);
-
- //int rpc_port_stub_create(rpc_port_stub_h* h, const char* port_name);
- [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_create")]
- internal static extern ErrorCode Create(out IntPtr handle, string portName);
-
- //int rpc_port_stub_destroy(rpc_port_stub_h h);
- [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_destroy")]
- internal static extern ErrorCode Destroy(IntPtr handle);
-
- //int rpc_port_stub_listen(rpc_port_stub_h h);
- [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_listen")]
- internal static extern ErrorCode Listen(IntPtr handle);
-
- //int rpc_port_stub_add_connected_event_cb(rpc_port_stub_h h, rpc_port_stub_connected_event_cb cb, void* data);
- [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_add_connected_event_cb")]
- internal static extern ErrorCode AddConnectedEventCb(IntPtr handle, ConnectedEventCallback cb, IntPtr data);
-
- //int rpc_port_stub_add_disconnected_event_cb(rpc_port_stub_h h, rpc_port_stub_disconnected_event_cb cb, void* data);
- [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_stub_add_disconnected_event_cb")]
- internal static extern ErrorCode AddDisconnectedEventCb(IntPtr handle, DisconnectedEventCallback cb, IntPtr data);
-
- //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 ErrorCode 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 ErrorCode 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 ErrorCode SetTrusted(IntPtr handle, bool trusted);
- }
-)__cs_cb";
-
-#endif // IDLC_CS_GEN_CS_CB_STUB_INTEROP_H_
namespace {
#include "idlc/cs_gen/cs_cb_copyright.h"
#include "idlc/cs_gen/cs_gen_base_cb.h"
+#include "idlc/cs_gen/cs_cb_rpc_port.h"
}
namespace tidl {
parcel_type_map_ = {
{"char", "Byte"},
- {"int", "Int32"},
- {"short", "Int16"},
- {"long", "Int64"},
+ {"int", "Int"},
+ {"short", "Short"},
+ {"long", "Long"},
{"string", "String"},
{"bool", "Bool"},
{"float", "Float"},
};
}
-void CsGeneratorBase::GenExceptions(std::ofstream& stream) {
- stream << CB_EXCEPTIONS;
-}
-
void CsGeneratorBase::GenStructures(std::ofstream& stream) {
for (auto& i : GetDocument().GetBlocks()) {
if (i->GetType() != Block::TYPE_STRUCTURE)
void CsGeneratorBase::GenSerializer(std::ofstream& stream,
const Structure& st) {
- stream << NLine(1) << Tab(3) << "private static void Serialize(IntPtr h, "
+ stream << NLine(1) << Tab(3) << "private static void Serialize(Parcel h, "
<< st.GetID() << " param)" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
for (auto& i : st.GetElements().GetElms()) {
auto& t = i->GetType();
if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
- if (t.ToString() == "bundle") {
- GenWriteBundle(stream, i->GetID());
- } else {
- stream << Tab(4) << "Interop.LibRPCPort.Parcel.Write"
- << ConvertTypeToParcelType(t.ToString())
- << "(h, param."
- << i->GetID()
- << ");" << NLine(1);
- }
+ 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 << Tab(3) << "private static void Deserialize(IntPtr h, "
+ stream << Tab(3) << "private static void Deserialize(Parcel h, "
<< st.GetID() << " param)" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
for (auto& i : st.GetElements().GetElms()) {
auto& t = i->GetType();
if (!t.IsUserDefinedType() && t.GetMetaType() == nullptr) {
- stream << Tab(4) << "Interop.LibRPCPort.Parcel.Read"
+ stream << Tab(4) << "var " << i->GetID() << " = "
+ << "h.Read"
<< ConvertTypeToParcelType(t.ToString())
- << "(h, out var "
- << i->GetID()
- << ");" << NLine(1);
- if (t.ToString() == "bundle") {
- stream << Tab(4) << "param." << i->GetID()
- << " = new Bundle(new SafeBundleHandle(" << i->GetID()
- << ", true));" << NLine(1);
- } else {
- stream << Tab(4) << "param." << i->GetID() << " = " << i->GetID()
- << ";" << NLine(1);
- }
+ << "();" << NLine(1);
+ stream << Tab(4) << "param." << i->GetID() << " = " << i->GetID()
+ << ";" << NLine(1);
} else {
stream << Tab(4) << "param." << i->GetID() << " = new "
<< ConvertTypeToString(t)
void CsGeneratorBase::GenListSerializer(std::ofstream& stream,
const BaseType& type) {
- stream << NLine(1) << Tab(3) << "private static void Serialize(IntPtr h, "
+ stream << NLine(1) << Tab(3) << "private static void Serialize(Parcel h, "
<< ConvertTypeToString(type) << " param)" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
stream << Tab(4)
- << "Interop.LibRPCPort.Parcel.WriteArrayCount(h, param.Count);"
+ << "h.WriteArrayCount(param.Count);"
<< NLine(1);
stream << Tab(4) << "foreach (var i in param)" << NLine(1);
GenBrace(stream, TAB_SIZE * 4, [&]() {
auto& mt = *type.GetMetaType();
if (!mt.IsUserDefinedType() && mt.GetMetaType() == nullptr) {
- stream << Tab(5) << "Interop.LibRPCPort.Parcel.Write"
+ stream << Tab(5) << "h.Write"
<< ConvertTypeToParcelType(mt.ToString())
- << "(h, i);" << NLine(1);
+ << "(i);" << NLine(1);
} else {
stream << Tab(5) << "Serialize(h, i);" << NLine(1);
}
});
stream << NLine(1);
- stream << Tab(3) << "private static void Deserialize(IntPtr h, "
+ stream << Tab(3) << "private static void Deserialize(Parcel h, "
<< ConvertTypeToString(type) << " param)" << NLine(1);
GenBrace(stream, TAB_SIZE * 3, [&]() {
stream << Tab(4)
- << "Interop.LibRPCPort.Parcel.ReadArrayCount(h, out int l);"
+ << "int l = h.ReadArrayCount();"
<< NLine(1);
stream << Tab(4) << "for (int i = 0; i < l; i++)" << NLine(1);
GenBrace(stream, TAB_SIZE * 4, [&]() {
auto& mt = *type.GetMetaType();
if (!mt.IsUserDefinedType() && mt.GetMetaType() == nullptr) {
- stream << Tab(5) << "Interop.LibRPCPort.Parcel.Read"
+ stream << Tab(5) << "var v = h.Read"
<< ConvertTypeToParcelType(mt.ToString())
- << "(h, out var v);" << NLine(1);
+ << "();" << NLine(1);
} else {
stream << Tab(5) << "var v = new " << ConvertTypeToString(mt)
<< "();" << NLine(1);
std::string ret;
if (make_new_type) {
- ret = "Interop.LibRPCPort.Parcel.Read" +
- parcel_type_map_[type.ToString()] +
- "(" + parcel + ", out " +
- ConvertTypeToString(type) + " " +
- id + ");\n";
+ ret = ConvertTypeToString(type) + " "
+ + id + " = " + parcel + ".Read"
+ + parcel_type_map_[type.ToString()]
+ + "();\n";
} else {
- ret = "Interop.LibRPCPort.Parcel.Read" +
- parcel_type_map_[type.ToString()] +
- "(" + parcel + ", out " +
- id + ");\n";
+ ret = id + " = " + parcel + ".Read"
+ + parcel_type_map_[type.ToString()]
+ + "();\n";
}
return ret;
return ret;
}
- ret += "Interop.LibRPCPort.Parcel.Write" +
- parcel_type_map_[type.ToString()] + "(" + parcel + ", " + id + ");\n";
+ ret += parcel + ".Write"
+ + parcel_type_map_[type.ToString()] + "(" + id + ");\n";
return ret;
}
void CsGeneratorBase::GenReceivedEvent(std::ofstream& stream,
const Declaration& decl,
const std::string& id) {
- stream << Tab(4) << "internal override void OnReceivedEvent(IntPtr parcel)"
+ stream << Tab(4) << "internal override void OnReceivedEvent(Parcel parcel)"
<< NLine(1);
GenBrace(stream, TAB_SIZE * 4, [&]() {
int cnt = 1;
auto& pt = i->GetParameterType();
m += ConvertTypeToSerializer(pt.GetBaseType(), i->GetID(), "p", id);
}
- return AddIndent(TAB_SIZE * 5, m);
+ return AddIndent(TAB_SIZE * 6, m);
});
}
void GenParameters(std::ofstream& stream, const Parameters& ps);
void GenCallbacks(std::ofstream& stream, const Interface& iface,
bool is_proxy);
- void GenExceptions(std::ofstream& stream);
std::string ConvertTypeToString(const BaseType& type);
std::string ConvertTypeToDeserializer(const BaseType& type,
#ifndef IDLC_CS_GEN_CS_GEN_BASE_CB_H_
#define IDLC_CS_GEN_CS_GEN_BASE_CB_H_
-const char CB_EXCEPTIONS[] =
-R"__cs_cb( public class InvalidIOException : InvalidOperationException {}
- public class InvalidIDException : InvalidOperationException {}
- public class PermissionDeniedException : InvalidOperationException {}
- public class InvalidProtocolException : InvalidOperationException {}
- public class NotConnectedSocketException : InvalidOperationException {}
- public class InvalidCallbackException : InvalidOperationException {}
-
-)__cs_cb";
-
const char CB_CALLBACK_BASE[] =
R"__cs_cb(
public abstract class CallbackBase
Once = once;
}
- internal virtual void OnReceivedEvent(IntPtr port) {}
+ internal virtual void OnReceivedEvent(Parcel p) {}
- internal static void Serialize(IntPtr h, CallbackBase param)
+ internal static void Serialize(Parcel h, CallbackBase param)
{
- Interop.LibRPCPort.Parcel.WriteInt32(h, param.Id);
- Interop.LibRPCPort.Parcel.WriteInt32(h, param.SeqId);
- Interop.LibRPCPort.Parcel.WriteBool(h, param.Once);
+ h.WriteInt(param.Id);
+ h.WriteInt(param.SeqId);
+ h.WriteBool(param.Once);
}
- internal static void Deserialize(IntPtr h, CallbackBase param)
+ internal static void Deserialize(Parcel h, CallbackBase param)
{
- Interop.LibRPCPort.Parcel.ReadInt32(h, out var id);
- param.Id = id;
- Interop.LibRPCPort.Parcel.ReadInt32(h, out var seqId);
- param.SeqId = seqId;
- Interop.LibRPCPort.Parcel.ReadBool(h, out var once);
- param.Once = once;
+ param.Id = h.ReadInt();
+ param.SeqId = h.ReadInt();
+ param.Once = h.ReadBool();
}
}
)__cs_cb";
const char CB_CALLBACK_CTOR_STUB[] =
-R"__cs_cb( internal $$(IntPtr port, WeakReference service) : base((int)DelegateId.$$, false)
+R"__cs_cb( internal $$(Port port, WeakReference service) : base((int)DelegateId.$$, false)
{
_port = port;
_service = service;
)__cs_cb";
const char CB_CALLBACK_STUB_MEMBERS[] =
-R"__cs_cb( private IntPtr _port;
+R"__cs_cb( private Port _port;
private WeakReference _service;
private bool _valid = true;
R"__cs_cb(
public void Invoke($$)
{
- if (_port == IntPtr.Zero || _service == null)
+ if (_port == null)
throw new NotConnectedSocketException();
if (!_service.IsAlive)
throw new InvalidProtocolException();
if (Once && !_valid)
throw new InvalidCallbackException();
- Interop.LibRPCPort.Parcel.Create(out IntPtr p);
- Interop.LibRPCPort.Parcel.WriteInt32(p, (int)MethodId.__Callback);
- Serialize(p, this);
+ using (var p = new Parcel())
+ {
+ p.WriteInt((int)MethodId.__Callback);
+ Serialize(p, this);
$$
- // Send
- Interop.LibRPCPort.Parcel.Send(p, _port);
- Interop.LibRPCPort.Parcel.Destroy(p);
- _valid = false;
+ // Send
+ p.Send(_port);
+ _valid = false;
+ }
}
)__cs_cb";
R"__cs_cb(
if (param.$$ != null)
{
- Interop.LibRPCPort.Parcel.WriteBundle(h, param.$$.SafeBundleHandle.DangerousGetHandle());
+ h.WriteBundle(param.$$);
}
else
{
- Interop.LibRPCPort.Parcel.WriteBundle(h, new Bundle().SafeBundleHandle.DangerousGetHandle());
+ h.WriteBundle(new Bundle());
}
)__cs_cb";
--- /dev/null
+/*
+ * Copyright (c) 2018 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/cs_gen/cs_lib_gen.h"
+
+namespace {
+#include "idlc/cs_gen/cs_cb_rpc_port.h"
+#include "idlc/cs_gen/cs_cb_interop.h"
+}
+
+namespace tidl {
+
+CsLibGen::CsLibGen(std::shared_ptr<Document> doc)
+ : CsGeneratorBase(doc) {}
+
+void CsLibGen::OnInitGen(std::ofstream& stream) {
+ GenCopyright(stream);
+ stream << "using System;" << NLine(1)
+ << "using System.Collections.Generic;" << NLine(1)
+ << "using System.Runtime.InteropServices;" << NLine(1)
+ << "using Tizen.Applications;" << NLine(1);
+ GenInterop(stream);
+ GenRpcPort(stream);
+}
+
+void CsLibGen::OnFiniGen(std::ofstream& stream) {}
+
+void CsLibGen::GenInterop(std::ofstream& stream) {
+ stream << cs_cb_interop;
+}
+
+void CsLibGen::GenRpcPort(std::ofstream& stream) {
+ stream << cs_cb_rpc_port;
+}
+
+} // namespace tidl
--- /dev/null
+/*
+ * Copyright (c) 2018 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_CS_GEN_CS_LIB_GEN_H_
+#define IDLC_CS_GEN_CS_LIB_GEN_H_
+
+#include <memory>
+#include <string>
+
+#include "idlc/cs_gen/cs_gen_base.h"
+
+namespace tidl {
+
+class CsLibGen : public CsGeneratorBase {
+ public:
+ explicit CsLibGen(std::shared_ptr<Document> doc);
+ virtual ~CsLibGen() = default;
+
+ void OnInitGen(std::ofstream& stream) override;
+ void OnFiniGen(std::ofstream& stream) override;
+
+ private:
+ void GenInterop(std::ofstream& stream);
+ void GenRpcPort(std::ofstream& stream);
+};
+
+} // namespace tidl
+
+#endif // IDLC_CS_GEN_CS_LIB_GEN_H_
#include "idlc/cs_gen/cs_proxy_gen.h"
namespace {
-#include "idlc/cs_gen/cs_cb_interop.h"
-#include "idlc/cs_gen/cs_cb_proxy_interop.h"
#include "idlc/cs_gen/cs_proxy_gen_cb.h"
}
GenCopyright(stream);
stream << "using System;" << NLine(1)
<< "using System.Collections.Generic;" << NLine(1)
- << "using System.Runtime.InteropServices;" << NLine(1)
- << "using Tizen.Applications;" << NLine(1);
- GenInterop(stream);
+ << "using System.Threading;" << NLine(1)
+ << "using Tizen.Applications;" << NLine(1)
+ << "using Tizen.Applications.RPCPort;" << NLine(1);
GenNamespace(stream);
}
GenBrace(stream, 0, [&]() {
stream << "namespace " << GetFileNamespace() << NLine(1);
GenBrace(stream, 0, [&]() {
- GenExceptions(stream);
GenStructures(stream);
stream << Tab(1) << "namespace Proxy" << NLine(1);
GenBrace(stream, TAB_SIZE, [&]() {
});
}
-void CsProxyGen::GenInterop(std::ofstream& stream) {
- stream << "namespace RPCPort" << NLine(1);
- GenBrace(stream, 0, [&]() {
- stream << "namespace " << GetFileNamespace() << NLine(1);
- GenBrace(stream, 0, [&]() {
- GenTemplate(AddIndent(TAB_SIZE, ::cs_cb_interop), stream,
- [&]()->std::string {
- return AddIndent(TAB_SIZE, ::cs_cb_proxy_interop);
- });
- });
- });
- stream << NLine(1);
-}
-
void CsProxyGen::GenInterfaces(std::ofstream& stream) {
for (auto& i : GetDocument().GetBlocks()) {
if (i->GetType() != Block::TYPE_INTERFACE)
void CsProxyGen::GenInterface(std::ofstream& stream, const Interface& iface) {
stream << Tab(2) << "public class " << iface.GetID()
- << " : IDisposable" << NLine(1);
+ << " : ProxyBase" << NLine(1);
GenBrace(stream, TAB_SIZE * 2, [&]() {
stream << CB_DATA_MEMBERS;
GenCallbacks(stream, iface, true);
GenCtor(stream, iface);
GenConnectMethod(stream, iface);
GenMethods(stream, iface);
- GenDisposable(stream, iface);
});
}
}
void CsProxyGen::GenInvocation(std::ofstream& stream, const Declaration& decl) {
- stream << CB_INVOCATION_PRE;
-
- // Serialize
- stream << Tab(4)
- << "Interop.LibRPCPort.Parcel.WriteInt32(p, (int)MethodId."
- << decl.GetID() << ");" << NLine(1);
- std::string m;
- std::string l;
- for (auto& i : decl.GetParameters().GetParams()) {
- auto& pt = i->GetParameterType();
- if (pt.GetDirection() == ParameterType::Direction::OUT)
- continue;
- m += ConvertTypeToSerializer(pt.GetBaseType(), i->GetID(), "p");
- if (IsDelegateType(pt.GetBaseType())) {
- l += "_delegateList.Add(" + i->GetID() + ");\n";
- }
- }
- stream << AddIndent(TAB_SIZE * 4, m) << NLine(1);
-
- if (decl.GetMethodType() == Declaration::MethodType::SYNC)
- stream << Tab(4) << "IntPtr parcel_received;" << NLine(1);
- stream << Tab(4) << "lock (_lock)" << NLine(1);
- GenBrace(stream, TAB_SIZE * 4, [&]() {
- if (!l.empty())
- stream << AddIndent(TAB_SIZE * 5, l) << NLine(1);
- stream << CB_INVOCATION_MID << NLine(1);
- if (decl.GetMethodType() == Declaration::MethodType::SYNC) {
- stream << Tab(5) << "// Receive" << NLine(1);
- stream << Tab(5)
- << "ConsumeCommand(out parcel_received, _port);" << NLine(1);
- }
- });
- stream << NLine(1);
-
- // Deserialize
- if (decl.GetMethodType() == Declaration::MethodType::ASYNC) {
- stream << Tab(4) << "Interop.LibRPCPort.Parcel.Destroy(p);"
- << NLine(1);
- return;
- }
-
- const char* receive_block =
- "if (parcel_received == IntPtr.Zero)\n" \
- "{\n" \
- " Interop.LibRPCPort.Parcel.Destroy(p);\n" \
- " throw new InvalidProtocolException();\n" \
- "}\n";
- stream << AddIndent(TAB_SIZE * 4, receive_block) << NLine(1);
-
- for (auto& i : decl.GetParameters().GetParams()) {
- if (i->GetParameterType().GetDirection() == ParameterType::Direction::IN) {
- continue;
- }
-
- std::string c = ConvertTypeToDeserializer(
- i->GetParameterType().GetBaseType(),
- i->GetID(), "parcel_received", false);
- if (c != "")
- stream << AddIndent(TAB_SIZE * 4, c);
- }
-
- if (decl.GetType().ToString() != "void") {
- stream << AddIndent(TAB_SIZE * 4,
+ GenTemplate(CB_INVOCATION_PRE, stream,
+ [&]()->std::string {
+ std::string st;
+ st += Tab(5)
+ + "p.WriteInt((int)MethodId." + decl.GetID() + ");" + NLine(1);
+ std::string m;
+ std::string l;
+ for (auto& i : decl.GetParameters().GetParams()) {
+ auto& pt = i->GetParameterType();
+ if (pt.GetDirection() == ParameterType::Direction::OUT)
+ continue;
+ m += ConvertTypeToSerializer(pt.GetBaseType(), i->GetID(), "p");
+ if (IsDelegateType(pt.GetBaseType())) {
+ l += "_delegateList.Add(" + i->GetID() + ");\n";
+ }
+ }
+
+ st += AddIndent(TAB_SIZE * 5, m) + NLine(1);
+
+ if (decl.GetMethodType() == Declaration::MethodType::SYNC)
+ st += Tab(5) + "Parcel parcelReceived;" + NLine(1);
+ st += Tab(5) + "lock (_lock)" + NLine(1);
+ st += Tab(5) + "{" + NLine(1);
+ if (!l.empty())
+ st += AddIndent(TAB_SIZE * 6, l) + NLine(1);
+ st += CB_INVOCATION_MID + NLine(1);
+ if (decl.GetMethodType() == Declaration::MethodType::SYNC) {
+ st += Tab(6) + "// Receive" + NLine(1);
+ st += Tab(6)
+ + "ConsumeCommand(out parcelReceived, Port);" + NLine(1);
+ }
+ st += Tab(5) + "}";
+
+ // Deserialize
+ if (decl.GetMethodType() == Declaration::MethodType::ASYNC) {
+ return st;
+ }
+
+ const char* receive_block =
+ "if (parcelReceived == null)\n" \
+ "{\n" \
+ " throw new InvalidProtocolException();\n" \
+ "}\n";
+ st += NLine(1) + AddIndent(TAB_SIZE * 5, receive_block) + NLine(1);
+
+ for (auto& i : decl.GetParameters().GetParams()) {
+ if (i->GetParameterType().GetDirection() ==
+ ParameterType::Direction::IN) {
+ continue;
+ }
+
+ std::string c = ConvertTypeToDeserializer(
+ i->GetParameterType().GetBaseType(),
+ i->GetID(), "parcelReceived", false);
+ if (c != "")
+ st += AddIndent(TAB_SIZE * 5, c);
+ }
+
+ if (decl.GetType().ToString() != "void") {
+ st += AddIndent(TAB_SIZE * 5,
ConvertTypeToDeserializer(decl.GetType(),
- "ret", "parcel_received"));
- }
+ "ret", "parcelReceived"));
+ }
- stream << Tab(4) << "Interop.LibRPCPort.Parcel.Destroy(p);"
- << NLine(1);
- stream << Tab(4) << "Interop.LibRPCPort.Parcel.Destroy(parcel_received);"
- << NLine(1);
- stream << Tab(4) << "return ret;" << NLine(1);
-}
+ st += Tab(5) + "parcelReceived.Dispose();" + NLine(1);
+ st += Tab(5) + "return ret;";
-void CsProxyGen::GenDisposable(std::ofstream& stream, const Interface& iface) {
- GenTemplate(CB_DISPOSABLE, stream,
- [&]()->std::string {
- return iface.GetID();
+ return st;
});
}
private:
void GenNamespace(std::ofstream& stream);
- void GenInterop(std::ofstream& stream);
void GenInterfaces(std::ofstream& stream);
void GenInterface(std::ofstream& stream, const Interface& iface);
void GenCtor(std::ofstream& stream, const Interface& iface);
void GenConnectMethod(std::ofstream& stream, const Interface& iface);
void GenMethods(std::ofstream& stream, const Interface& iface);
- void GenDisposable(std::ofstream& stream, const Interface& iface);
void GenInvocation(std::ofstream& stream, const Declaration& decl);
};
public event EventHandler Disconnected;
public event EventHandler Rejected;
- private IntPtr _proxy;
- private IntPtr _port;
private bool _online = false;
private string _appId;
private Object _lock = new Object();
private List<CallbackBase> _delegateList = new List<CallbackBase>();
- private Interop.LibRPCPort.Proxy.ConnectedEventCallback _connectedEventCallback;
- private Interop.LibRPCPort.Proxy.DisconnectedEventCallback _disconnectedEventCallback;
- private Interop.LibRPCPort.Proxy.RejectedEventCallback _rejectedEventCallback;
- private Interop.LibRPCPort.Proxy.ReceivedEventCallback _receivedEventCallback;
)__cs_cb";
const char CB_EVENT_METHODS[] =
R"__cs_cb(
- private void OnConnectedEvent(string endPoint, string port_name, IntPtr port, IntPtr data)
+ protected override void OnConnectedEvent(string endPoint, string portName, Port port)
{
- _port = port;
_online = true;
Connected?.Invoke(this, null);
}
- private void OnDisconnectedEvent(string endPoint, string port_name, IntPtr data)
+ protected override void OnDisconnectedEvent(string endPoint, string portName)
{
+ _online = false;
Disconnected?.Invoke(this, null);
}
- private void OnRejectedEvent(string endPoint, string port_name, IntPtr data)
+ protected override void OnRejectedEvent(string endPoint, string portName)
{
Rejected?.Invoke(this, null);
}
- private void ProcessReceivedEvent(IntPtr parcel)
+ private void ProcessReceivedEvent(Parcel parcel)
{
- Interop.LibRPCPort.Parcel.ReadInt32(parcel, out int id);
- Interop.LibRPCPort.Parcel.ReadInt32(parcel, out int seqId);
- Interop.LibRPCPort.Parcel.ReadBool(parcel, out bool once);
+ int id = parcel.ReadInt();
+ int seqId = parcel.ReadInt();
+ bool once = parcel.ReadBool();
foreach (var i in _delegateList)
{
}
}
- private void OnReceivedEvent(string endPoint, string port_name, IntPtr data)
+ protected override void OnReceivedEvent(string endPoint, string portName)
{
- IntPtr parcel_received;
- lock (_lock)
+ Parcel parcelReceived;
+ if (!Monitor.TryEnter(_lock))
+ return;
+
+ parcelReceived = new Parcel(Port);
+ Monitor.Exit(_lock);
+
+ using (parcelReceived)
{
- if (Interop.LibRPCPort.Parcel.CreateFromPort(out parcel_received, _port) != 0)
+ int cmd = parcelReceived.ReadInt();
+ if (cmd != (int)MethodId.__Callback)
+ {
return;
- }
+ }
- Interop.LibRPCPort.Parcel.ReadInt32(parcel_received, out int cmd);
- if (cmd != (int)MethodId.__Callback)
- {
- Interop.LibRPCPort.Parcel.Destroy(parcel_received);
- throw new InvalidProtocolException();
+ ProcessReceivedEvent(parcelReceived);
}
-
- ProcessReceivedEvent(parcel_received);
- Interop.LibRPCPort.Parcel.Destroy(parcel_received);
}
- private void ConsumeCommand(out IntPtr parcel, IntPtr port)
+ private void ConsumeCommand(out Parcel parcel, Port port)
{
do
{
- var ret = Interop.LibRPCPort.Parcel.CreateFromPort(out IntPtr p, port);
+ var p = new Parcel(port);
- if (ret != Interop.LibRPCPort.ErrorCode.None)
- break;
- Interop.LibRPCPort.Parcel.ReadInt32(p, out int cmd);
+ int cmd = p.ReadInt();
if (cmd == (int)MethodId.__Result)
{
parcel = p;
}
ProcessReceivedEvent(p);
- Interop.LibRPCPort.Parcel.Destroy(p);
- parcel = IntPtr.Zero;
+ p.Dispose();
+ parcel = null;
} while (true);
- parcel = IntPtr.Zero;
}
)__cs_cb";
/// <remark> If you want to use this method, you must add privileges.</remark>
public void Connect()
{
- if (Interop.LibRPCPort.Proxy.Create(out _proxy) != Interop.LibRPCPort.ErrorCode.None)
- throw new InvalidIOException();
- _connectedEventCallback = new Interop.LibRPCPort.Proxy.ConnectedEventCallback(OnConnectedEvent);
- _disconnectedEventCallback = new Interop.LibRPCPort.Proxy.DisconnectedEventCallback(OnDisconnectedEvent);
- _rejectedEventCallback = new Interop.LibRPCPort.Proxy.RejectedEventCallback(OnRejectedEvent);
- _receivedEventCallback = new Interop.LibRPCPort.Proxy.ReceivedEventCallback(OnReceivedEvent);
- Interop.LibRPCPort.Proxy.AddConnectedEventCb(_proxy, _connectedEventCallback, IntPtr.Zero);
- Interop.LibRPCPort.Proxy.AddDisconnectedEventCb(_proxy, _disconnectedEventCallback, IntPtr.Zero);
- Interop.LibRPCPort.Proxy.AddRejectedEventCb(_proxy, _rejectedEventCallback, IntPtr.Zero);
- Interop.LibRPCPort.Proxy.AddReceivedEventCb(_proxy, _receivedEventCallback, IntPtr.Zero);
-
- var err = Interop.LibRPCPort.Proxy.Connect(_proxy, _appId, "$$");
- switch (err)
- {
- case Interop.LibRPCPort.ErrorCode.InvalidParameter:
- throw new InvalidIDException();
- case Interop.LibRPCPort.ErrorCode.PermissionDenied:
- throw new PermissionDeniedException();
- case Interop.LibRPCPort.ErrorCode.IoError:
- throw new InvalidIOException();
- }
+ Connect(_appId, "$$");
}
/// <summary>
}
)__cs_cb";
-const char CB_DISPOSABLE[] =
-R"__cs_cb(
- #region IDisposable Support
- private bool disposedValue = false;
-
- protected virtual void Dispose(bool disposing)
- {
- if (!disposedValue)
- {
- if (disposing)
- {
- }
-
- if (_proxy != IntPtr.Zero)
- Interop.LibRPCPort.Proxy.Destroy(_proxy);
-
- disposedValue = true;
- }
- }
-
- ~$$() {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
- #endregion
-)__cs_cb";
-
const char CB_INVOCATION_PRE[] =
R"__cs_cb( if (!_online)
throw new NotConnectedSocketException();
- Interop.LibRPCPort.Parcel.Create(out IntPtr p);
+ using (Parcel p = new Parcel())
+ {
+$$
+ }
)__cs_cb";
const char CB_INVOCATION_MID[] =
-R"__cs_cb( // Send
- Interop.LibRPCPort.Parcel.Send(p, _port);
+R"__cs_cb( // Send
+ p.Send(Port);
)__cs_cb";
#endif // IDLC_CS_GEN_CS_PROXY_GEN_CB_H_
#include "idlc/cs_gen/cs_stub_gen.h"
namespace {
-#include "idlc/cs_gen/cs_cb_interop.h"
-#include "idlc/cs_gen/cs_cb_stub_interop.h"
#include "idlc/cs_gen/cs_stub_gen_cb.h"
}
GenCopyright(stream);
stream << "using System;" << NLine(1)
<< "using System.Collections.Generic;" << NLine(1)
- << "using System.Runtime.InteropServices;" << NLine(1)
- << "using Tizen.Applications;" << NLine(1);
- GenInterop(stream);
+ << "using Tizen.Applications;" << NLine(1)
+ << "using Tizen.Applications.RPCPort;" << NLine(1);
+
GenNamespace(stream);
}
void CsStubGen::OnFiniGen(std::ofstream& stream) {}
-void CsStubGen::GenInterop(std::ofstream& stream) {
- stream << "namespace RPCPort" << NLine(1);
- GenBrace(stream, 0, [&]() {
- stream << "namespace " << GetFileNamespace() << NLine(1);
- GenBrace(stream, 0, [&]() {
- GenTemplate(AddIndent(TAB_SIZE, ::cs_cb_interop), stream,
- [&]()->std::string {
- return AddIndent(TAB_SIZE, ::cs_cb_stub_interop);
- });
- });
- });
- stream << NLine(1);
-}
-
void CsStubGen::GenNamespace(std::ofstream& stream) {
stream << "namespace RPCPort" << NLine(1);
GenBrace(stream, 0, [&]() {
stream << "namespace " << GetFileNamespace() << NLine(1);
GenBrace(stream, 0, [&]() {
- GenExceptions(stream);
GenStructures(stream);
stream << Tab(1) << "namespace Stub" << NLine(1);
GenBrace(stream, TAB_SIZE, [&]() {
void CsStubGen::GenInterface(std::ofstream& stream, const Interface& iface) {
stream << Tab(2) << "public sealed class " << iface.GetID()
- << " : IDisposable" << NLine(1);
+ << " : StubBase" << NLine(1);
GenBrace(stream, TAB_SIZE * 2, [&]() {
stream << CB_DATA_MEMBERS;
GenServiceBase(stream, iface);
for (auto& i : iface.GetDeclarations().GetDecls()) {
if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
continue;
- stream << Tab(5) << "case MethodId." << i->GetID() << ":" << NLine(1);
- GenBrace(stream, TAB_SIZE * 6, [&]() {
+ stream << Tab(7) << "case MethodId." << i->GetID() << ":" << NLine(1);
+ GenBrace(stream, TAB_SIZE * 8, [&]() {
GenInvocation(stream, *i);
- stream << Tab(7) << "break;" << NLine(1);
+ stream << Tab(9) << "break;" << NLine(1);
});
}
stream << CB_ON_RECEIVED_EVENT_BACK;
std::string v = "param" + std::to_string(cnt);
std::string c = ConvertTypeToDeserializer(
i->GetParameterType().GetBaseType(), v, "p");
- stream << AddIndent(TAB_SIZE * 7, c);
+ stream << AddIndent(TAB_SIZE * 9, c);
cnt++;
}
}
m += ");\n";
- stream << AddIndent(TAB_SIZE * 7, m);
+ stream << AddIndent(TAB_SIZE * 9, m);
// Serialize
if (decl.GetMethodType() == Declaration::MethodType::ASYNC)
return;
cnt = 0;
- m = "Interop.LibRPCPort.Parcel.WriteInt32(result, (int)MethodId.__Result);\n";
+ m = "result.WriteInt((int)MethodId.__Result);\n";
for (auto& i : decl.GetParameters().GetParams()) {
auto& pt = i->GetParameterType();
cnt++;
m += ConvertTypeToSerializer(decl.GetType(), "retVal", "result");
}
- m += "Interop.LibRPCPort.Parcel.Send(result, port);\n";
- stream << AddIndent(TAB_SIZE * 7, m);
+ m += "result.Send(port);\n";
+ stream << AddIndent(TAB_SIZE * 9, m);
}
void CsStubGen::GenConnectedEvent(std::ofstream& stream) {
for (auto& i : iface.GetAttributes().GetAttrs()) {
if (i->GetKey() == "privilege") {
- stream << Tab(4) << "Interop.LibRPCPort.Stub.AddPrivilege(_stub, \""
+ stream << Tab(4) << "AddPrivilege(\""
<< i->GetValue() << "\");" << NLine(1);
} else if (i->GetKey() == "trusted" && i->GetValue() == "true") {
- stream << Tab(4) << "Interop.LibRPCPort.Stub.SetTrusted(_stub, "
+ stream << Tab(4) << "SetTrusted("
<< i->GetValue() << ");" << NLine(1);
}
}
}
void CsStubGen::GenDisposable(std::ofstream& stream, const Interface& iface) {
- GenTemplate(CB_DISPOSABLE, stream,
- [&]()->std::string {
- return iface.GetID();
- });
+ stream << CB_DISPOSABLE;
}
} // namespace tidl
private:
void GenNamespace(std::ofstream& stream);
- void GenInterop(std::ofstream& stream);
void GenInterfaces(std::ofstream& stream);
void GenInterface(std::ofstream& stream, const Interface& iface);
void GenServiceBase(std::ofstream& stream, const Interface& iface);
#define IDLC_CS_GEN_CS_STUB_GEN_CB_H_
const char CB_DATA_MEMBERS[] =
-R"__cs_cb( private IntPtr _stub;
- private List<ServiceBase> _services = new List<ServiceBase>();
+R"__cs_cb( private List<ServiceBase> _services = new List<ServiceBase>();
private Type _serviceType;
- private Interop.LibRPCPort.Stub.ConnectedEventCallback _connectedEventCallback;
- private Interop.LibRPCPort.Stub.DisconnectedEventCallback _disconnectedEventCallback;
- private Interop.LibRPCPort.Stub.ReceivedEventCallback _receivedEventCallback;
)__cs_cb";
const char CB_SERVICE_BASE_FRONT[] =
const char CB_ON_RECEIVED_EVENT_FRONT[] =
R"__cs_cb(
- private int OnReceivedEvent(string sender, string instance, IntPtr port, IntPtr data)
+ protected override bool OnReceivedEvent(string sender, string instance, Port port)
{
- var ret = Interop.LibRPCPort.Parcel.CreateFromPort(out IntPtr p, port);
-
- if (ret != Interop.LibRPCPort.ErrorCode.None)
- return -1;
-
- ServiceBase b = null;
-
- foreach (var i in _services)
+ using (var p = new Parcel(port))
{
- if (i.Instance.Equals(instance))
+ ServiceBase b = null;
+
+ foreach (var i in _services)
{
- b = i;
- break;
+ if (i.Instance.Equals(instance))
+ {
+ b = i;
+ break;
+ }
}
- }
- if (b == null)
- {
- Interop.LibRPCPort.Parcel.Destroy(p);
- return -1;
- }
+ if (b == null)
+ {
+ return false;
+ }
- Interop.LibRPCPort.Parcel.Create(out IntPtr result);
- Interop.LibRPCPort.Parcel.ReadInt32(p, out int cmd);
+ using (var result = new Parcel())
+ {
+ int cmd = p.ReadInt();
- switch ((MethodId)cmd)
- {
+ switch ((MethodId)cmd)
+ {
)__cs_cb";
const char CB_ON_RECEIVED_EVENT_BACK[] =
R"__cs_cb(
- default:
- Interop.LibRPCPort.Parcel.Destroy(p);
- Interop.LibRPCPort.Parcel.Destroy(result);
- return -1;
- }
-
- Interop.LibRPCPort.Parcel.Destroy(p);
- Interop.LibRPCPort.Parcel.Destroy(result);
+ default:
+ return false;
+ }
+ }
- return 0;
+ return true;
+ }
}
)__cs_cb";
const char CB_ON_CONNECTED_EVENT[] =
R"__cs_cb(
- private void OnConnectedEvent(string sender, string instance, IntPtr data)
+ protected override void OnConnectedEvent(string sender, string instance)
{
ServiceBase s = Activator.CreateInstance(_serviceType) as ServiceBase;
s.Sender = sender;
)__cs_cb";
const char CB_ON_DISCONNECTED_EVENT[] =
- R"__cs_cb(
- private void OnDisconnectedEvent(string sender, string instance, IntPtr data)
+R"__cs_cb(
+ protected override void OnDisconnectedEvent(string sender, string instance)
{
foreach (var i in _services)
{
const char CB_CTOR_FRONT[] =
R"__cs_cb(
- public $$()
+ public $$() : base("$$")
{
- if (Interop.LibRPCPort.Stub.Create(out _stub, "$$") != Interop.LibRPCPort.ErrorCode.None)
- throw new InvalidIOException();
- _connectedEventCallback = new Interop.LibRPCPort.Stub.ConnectedEventCallback(OnConnectedEvent);
- _disconnectedEventCallback = new Interop.LibRPCPort.Stub.DisconnectedEventCallback(OnDisconnectedEvent);
- _receivedEventCallback = new Interop.LibRPCPort.Stub.ReceivedEventCallback(OnReceivedEvent);
- Interop.LibRPCPort.Stub.AddReceivedEventCb(_stub, _receivedEventCallback, IntPtr.Zero);
- Interop.LibRPCPort.Stub.AddConnectedEventCb(_stub, _connectedEventCallback, IntPtr.Zero);
- Interop.LibRPCPort.Stub.AddDisconnectedEventCb(_stub, _disconnectedEventCallback, IntPtr.Zero);
)__cs_cb";
const char CB_COMMON_METHODS[] =
if (!typeof(ServiceBase).IsAssignableFrom(serviceType))
throw new ArgumentException("Invalid type");
_serviceType = serviceType;
- var err = Interop.LibRPCPort.Stub.Listen(_stub);
- switch (err)
- {
- case Interop.LibRPCPort.ErrorCode.InvalidParameter:
- case Interop.LibRPCPort.ErrorCode.IoError:
- throw new InvalidIOException();
- }
+ Listen();
}
/// <summary>
const char CB_DISPOSABLE[] =
R"__cs_cb(
- #region IDisposable Support
- private bool disposedValue = false;
-
- private void Dispose(bool disposing)
+ protected override void OnTerminatedEvent()
{
- if (!disposedValue)
+ foreach (var i in _services)
{
- if (disposing)
- {
- }
-
- foreach (var i in _services)
- {
- i.OnTerminate();
- }
-
- _services = null;
- if (_stub != IntPtr.Zero)
- Interop.LibRPCPort.Stub.Destroy(_stub);
- disposedValue = true;
+ i.OnTerminate();
}
}
-
- ~$$() {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
- #endregion
)__cs_cb";
#endif // IDLC_CS_GEN_CS_STUB_GEN_CB_H_
#include "idlc/parser.h"
#include "idlc/cs_gen/cs_proxy_gen.h"
#include "idlc/cs_gen/cs_stub_gen.h"
+#include "idlc/cs_gen/cs_lib_gen.h"
#include "idlc/c_gen/c_proxy_header_gen.h"
#include "idlc/c_gen/c_proxy_body_gen.h"
#include "idlc/c_gen/c_stub_header_gen.h"
std::string GetInput() const { return input_; }
std::string GetOutput() const { return output_; }
bool HasNamespace() const { return hasNamespace_; }
+ bool HasRpcPortLib() const { return hasRpcPortLib_; }
private:
enum Cmd {
OPT_INPUT,
OPT_OUTPUT,
OPT_NAMESPACE,
+ OPT_RPCLIB,
OPT_MAX
};
std::string output_;
std::string help_;
bool hasNamespace_ = false;
+ bool hasRpcPortLib_ = false;
};
void Options::PrintUsage() {
"Add the prefix in the funtion name as output file name " \
"(C language only).",
NULL },
+ { "rpclib", 'r', 0, G_OPTION_ARG_NONE, &opt[OPT_RPCLIB],
+ "Generate C# library for rpc-port " \
+ "(C# language only).",
+ NULL },
{ NULL }
};
options->input_ = static_cast<char*>(opt[OPT_INPUT]);
options->output_ = static_cast<char*>(opt[OPT_OUTPUT]);
options->hasNamespace_ = opt[OPT_NAMESPACE] ? true : false;
+ options->hasRpcPortLib_ = opt[OPT_RPCLIB] ? true : false;
return options;
}
if (options->GetLanguage() == "C#") {
tidl::CsProxyGen proxy(ps.GetDoc());
proxy.Run(options->GetOutput() + ".cs");
+ if (options->HasRpcPortLib()) {
+ tidl::CsLibGen lib(ps.GetDoc());
+ lib.Run("rpc-port.cs");
+ }
} else if (options->GetLanguage() == "C++") {
tidl::CppProxyHeaderGen proxy_header(ps.GetDoc());
proxy_header.Run(options->GetOutput() + ".h");
if (options->GetLanguage() == "C#") {
tidl::CsStubGen stub(ps.GetDoc());
stub.Run(options->GetOutput() + ".cs");
+ if (options->HasRpcPortLib()) {
+ tidl::CsLibGen lib(ps.GetDoc());
+ lib.Run("rpc-port.cs");
+ }
} else if (options->GetLanguage() == "C++") {
tidl::CppStubHeaderGen stub_header(ps.GetDoc());
stub_header.Run(options->GetOutput() + ".h");
ASSERT_TRUE(FindStringFromFile("test.cs", "namespace RPCPort"));
ASSERT_TRUE(FindStringFromFile("test.cs",
- " internal static partial class Proxy"));
- ASSERT_TRUE(FindStringFromFile("test.cs",
" public sealed class Student"));
ASSERT_TRUE(FindStringFromFile("test.cs",
" public string name { get; set; }"));
ASSERT_TRUE(FindStringFromFile("test_stub.cs", "namespace RPCPort"));
ASSERT_TRUE(FindStringFromFile("test_stub.cs",
- " internal static partial class Stub"));
- ASSERT_TRUE(FindStringFromFile("test_stub.cs",
" public sealed class Student"));
ASSERT_TRUE(FindStringFromFile("test_stub.cs",
" public string name { get; set; }"));