From 6f2ed76d83632a779b6df6aef0453d037b94717c Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 3 Apr 2018 07:45:13 +0200 Subject: [PATCH] Improve the code for proxy generation more of a layout improvement, to avoid any code duplication. The mechanics remain the same - write an explicit specialisation - trigger template intantiation within a dedicated translation unit --- src/common/display-interface-proxy.cpp | 35 ++-- src/common/notification-interface-proxy.cpp | 34 ++-- src/include/interfaceproxy.hpp | 3 +- .../session-command-interface-proxy.cpp | 33 ++-- .../play/dummy-player-interface-proxy.cpp | 35 ++-- wiki/thinkPad.ichthyo.mm | 152 +++++++++++++----- 6 files changed, 176 insertions(+), 116 deletions(-) diff --git a/src/common/display-interface-proxy.cpp b/src/common/display-interface-proxy.cpp index 30d74a507..ac8cbdc93 100644 --- a/src/common/display-interface-proxy.cpp +++ b/src/common/display-interface-proxy.cpp @@ -34,12 +34,6 @@ */ - - - - -/* ==================== gui::Display ====================================== */ - #include "include/display-facade.h" #include "include/interfaceproxy.hpp" @@ -58,9 +52,16 @@ namespace lumiera { namespace lumiera { namespace facade { - using IHandle = InstanceHandle< LUMIERA_INTERFACE_INAME(lumieraorg_Display, 0) - , lumiera::Display - >; + + + /* ==================== gui::Display ====================================== */ + + using Interface = LUMIERA_INTERFACE_INAME(lumieraorg_Display, 0); + using Facade = lumiera::Display; + + using IHandle = InstanceHandle; + + template<> class Proxy : public Binding @@ -81,16 +82,12 @@ namespace facade { public: - using IBinding::IBinding; + using Binding::Binding; }; -} //namespace facade - - -// emit code for the proxy implementation here... -template -class InstanceHandle< LUMIERA_INTERFACE_INAME(lumieraorg_Display, 0) - , lumiera::Display - >; -} // namespace lumiera + /** emit proxy code here... */ + template + class Link; + +}} //namespace facade::lumiera diff --git a/src/common/notification-interface-proxy.cpp b/src/common/notification-interface-proxy.cpp index 5debc71ab..cb8951562 100644 --- a/src/common/notification-interface-proxy.cpp +++ b/src/common/notification-interface-proxy.cpp @@ -32,11 +32,6 @@ */ - - - -/* ==================== GuiNotification =================================== */ - #include "include/gui-notification-facade.h" #include "include/interfaceproxy.hpp" @@ -50,9 +45,15 @@ namespace facade { using lib::diff::MutationMessage; - using IHandle = InstanceHandle< LUMIERA_INTERFACE_INAME(lumieraorg_GuiNotification, 0) - , gui::GuiNotification - >; + + /* ==================== SessionCommand =================================== */ + + using Interface = LUMIERA_INTERFACE_INAME(lumieraorg_GuiNotification, 0); + using Facade = gui::GuiNotification; + + using IHandle = InstanceHandle; + + template<> class Proxy : public Binding @@ -69,15 +70,12 @@ namespace facade { public: - using IBinding::IBinding; + using Binding::Binding; }; -} //namespace facade - - -// emit code for the proxy implementation here... -template -class InstanceHandle< LUMIERA_INTERFACE_INAME(lumieraorg_GuiNotification, 0) - , gui::GuiNotification - >; -} // namespace lumiera + + /** emit proxy code here... */ + template + class Link; + +}} //namespace facade::lumiera diff --git a/src/include/interfaceproxy.hpp b/src/include/interfaceproxy.hpp index 261d3a95d..f9b315a3a 100644 --- a/src/include/interfaceproxy.hpp +++ b/src/include/interfaceproxy.hpp @@ -153,8 +153,7 @@ namespace facade { struct Binding> : public FA { - typedef InstanceHandle IHandle; - typedef Binding IBinding; + using IHandle = InstanceHandle; I& _i_; diff --git a/src/proc/control/session-command-interface-proxy.cpp b/src/proc/control/session-command-interface-proxy.cpp index 518f93a2c..35ffdb106 100644 --- a/src/proc/control/session-command-interface-proxy.cpp +++ b/src/proc/control/session-command-interface-proxy.cpp @@ -32,11 +32,6 @@ */ - - - -/* ==================== SessionCommand =================================== */ - #include "include/session-command-facade.h" #include "include/interfaceproxy.hpp" @@ -48,9 +43,14 @@ namespace control{ namespace lumiera { namespace facade { - using IHandle = InstanceHandle< LUMIERA_INTERFACE_INAME(lumieraorg_SessionCommand, 0) - , proc::control::SessionCommand - >; + + + /* ==================== SessionCommand =================================== */ + + using Interface = LUMIERA_INTERFACE_INAME(lumieraorg_SessionCommand, 0); + using Facade = proc::control::SessionCommand; + + using IHandle = InstanceHandle; template<> @@ -66,15 +66,12 @@ namespace facade { public: - using IBinding::IBinding; + using Binding::Binding; }; -} //namespace facade - - -// emit code for the proxy implementation here... -template -class InstanceHandle< LUMIERA_INTERFACE_INAME(lumieraorg_SessionCommand, 0) - , proc::control::SessionCommand - >; -} // namespace lumiera + + /** emit proxy code here... */ + template + class Link; + +}} //namespace facade::lumiera diff --git a/src/proc/play/dummy-player-interface-proxy.cpp b/src/proc/play/dummy-player-interface-proxy.cpp index 0bb788bf8..8435e8737 100644 --- a/src/proc/play/dummy-player-interface-proxy.cpp +++ b/src/proc/play/dummy-player-interface-proxy.cpp @@ -47,12 +47,6 @@ */ - - - - - /* ==================== DummyPlayer ======================================= */ - #include "include/dummy-player-facade.h" #include "include/interfaceproxy.hpp" @@ -60,6 +54,8 @@ namespace lumiera { // emit the vtable here into this translation unit within liblumieracommon.so ... DummyPlayer::~DummyPlayer() { } + DummyPlayer::ProcessImplementationLink::~ProcessImplementationLink() { }; + /** static storage for the facade access front-end */ lib::Depend DummyPlayer::facade; @@ -69,9 +65,14 @@ namespace lumiera { namespace facade { - using IHandle = InstanceHandle< LUMIERA_INTERFACE_INAME(lumieraorg_DummyPlayer, 0) - , lumiera::DummyPlayer - >; + + + /* ==================== DummyPlayer ======================================= */ + + using Interface = LUMIERA_INTERFACE_INAME(lumieraorg_DummyPlayer, 0); + using Facade = lumiera::DummyPlayer; + + using IHandle = InstanceHandle; template<> @@ -105,9 +106,14 @@ namespace lumiera { public: - using IBinding::IBinding; + using Binding::Binding; }; + + /** emit proxy code here... */ + template + class Link; + } // namespace facade @@ -120,14 +126,5 @@ namespace lumiera { impl().doPlay(yes); } - // emit the VTable and typeinfo for this interface here (in liblumieracommon.so) - DummyPlayer::ProcessImplementationLink::~ProcessImplementationLink() { }; - - - -template -class InstanceHandle< LUMIERA_INTERFACE_INAME(lumieraorg_DummyPlayer, 0) - , lumiera::DummyPlayer - >; } // namespace lumiera diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index e5f50c990..715e4c324 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -28192,8 +28192,8 @@ - - + + @@ -28295,8 +28295,8 @@ - - + + @@ -28409,8 +28409,8 @@ - - + + @@ -28442,8 +28442,9 @@ - - + + + @@ -28475,8 +28476,8 @@ - - + + @@ -28545,7 +28546,7 @@ - + @@ -28560,16 +28561,18 @@ - - + + + + - - + + @@ -28581,15 +28584,16 @@ - - + + + - + @@ -28613,19 +28617,23 @@ - - - - - - - - - - + + + + + + + + + + + + - - + + + + @@ -28677,30 +28685,94 @@ - + + - + - - + + - - + + - - - - + + + + + + + + + + + + + + + + +

+ obwohl es das sollte. +

+

+ Aber anscheinend macht der Compiler das nur partiell, +

+

+ denn es wird ja nur eine const& an den ctor von Binding übergeben. +

+

+ +

+

+ Allerdings erscheint es mir nicht sinnvoll, hier mit Tricksereien zu arbeiten! +

+ + +
+
+ + + + +
+ + + + + + +

+ sie ist zwar nicht schön -- aber was ist an einem Interface-Binding schon "schön"? +

+

+ +

+

+ Sie ist hinreichend wartbar, sofern man sie per copy-n-pate vervielfältigt. +

+

+ Es wäre sogar denkbar, in diesen Rump eine generierte Proxy-Klasse zu kleben, +

+

+ da nur wenige Variable erstetzt werden müßten. +

+ + +
+ +
+