From 77a0dc234e1925173a8944e9e641d72d9fe39aba Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 22 May 2018 00:15:20 +0300 Subject: awful crutch for Pascal plugins to use pseudo-constructor a la CMPlugin --- include/delphi/m_api.pas | 19 +++++++++++++++++++ include/delphi/m_helpers.inc | 3 +-- include/delphi/m_langpack.inc | 4 ++-- 3 files changed, 22 insertions(+), 4 deletions(-) (limited to 'include/delphi') diff --git a/include/delphi/m_api.pas b/include/delphi/m_api.pas index 70d52c39af..21b2a365ac 100644 --- a/include/delphi/m_api.pas +++ b/include/delphi/m_api.pas @@ -140,6 +140,16 @@ type true : (uuid :MUUID); // plugin's unique identifier end; +type + PCMPlugin = ^CMPlugin; + CMPlugin = record + m_hInst : THANDLE; + m_szModule : PAnsiChar; + m_pInfo : PPLUGININFOEX; + m_hLogger : THANDLE; + m_hLang : int; + end; + //----- Fork enchancement ----- { Miranda/System/LoadModule event @@ -180,6 +190,7 @@ var { has to be returned via MirandaPluginInfo and has to be statically allocated, this means only one module can return info, you shouldn't be merging them anyway! } PluginInfo: TPLUGININFOEX; + g_plugin: CMPlugin; {$include m_clist.inc} {$include m_genmenu.inc} @@ -243,4 +254,12 @@ implementation {$undef M_API_UNIT} {$include m_helpers.inc} +initialization + g_plugin.m_hInst := hInstance; + RegisterPlugin(g_plugin); + hLangpack := g_plugin.m_hLang; + +finalization + UnregisterPlugin(g_plugin); + end. diff --git a/include/delphi/m_helpers.inc b/include/delphi/m_helpers.inc index 9810ff69a4..bea8231de3 100644 --- a/include/delphi/m_helpers.inc +++ b/include/delphi/m_helpers.inc @@ -254,9 +254,8 @@ end; function Langpack_Register:int_ptr; begin - mir_getLP(PluginInfo, hLangpack); cli := Clist_GetInterface(); - result:=hLangpack; + result := hLangpack; end; diff --git a/include/delphi/m_langpack.inc b/include/delphi/m_langpack.inc index 3091b574b3..597c0cf1db 100644 --- a/include/delphi/m_langpack.inc +++ b/include/delphi/m_langpack.inc @@ -35,7 +35,7 @@ const ME_LANGPACK_CHANGE:PAnsiChar = 'LangPack/Changed'; -procedure mir_getLP(var pInfo:TPLUGININFOEX; var hLang:int); stdcall; - external CoreDLL name 'mir_getLP'; +procedure RegisterPlugin(var pInfo:CMPlugin); stdcall; external AppDLL; +procedure UnregisterPlugin(var pInfo:CMPlugin); stdcall; external AppDLL; {$ENDIF} -- cgit v1.2.3