diff --git a/lazproj/PluginApi/CoeditPlugApi.d b/lazproj/PluginApi/CoeditPlugApi.d deleted file mode 100644 index 894e7dc2..00000000 --- a/lazproj/PluginApi/CoeditPlugApi.d +++ /dev/null @@ -1,140 +0,0 @@ -module CoeditPlugApi; - - alias void* Host_t; - alias void* Plugin_t; - - // API version - immutable uint CE_PLG_API_VER = 0; - - /// When passed to the Coedit dispatcher, it shows a 'hello plugin' message. - immutable uint HELLO_PLUGIN = 0xFFFFFFFF; - -// Denotes the emiter and the message kind ------------------------------------- - - /// Coedit sends an event. - immutable uint HOST_EVENT = 0x10000000; - /// Coedit sends some data. - immutable uint HOST_DATA = 0x20000000; - /// The plug-in sends an event. - immutable uint PLUG_EVENT = 0x30000000; - /// The plug-in sends some data. - immutable uint PLUG_DATA = 0x40000000; - -// Denotes the message context ------------------------------------------------- - - /// the dispatcher call is related to the project(s) - immutable uint CTXT_PROJ = 0x01000000; - /// the dispatcher call is related to the document(s) - immutable uint CTXT_DOCS = 0x02000000; - /// the dispatcher call is related to the edition of a document. - immutable uint CTXT_EDIT = 0x03000000; - /// the dispatcher call is related to the Coedit 'Message Widget'. - immutable uint CTXT_MSGS = 0x04000000; - /// the dispatcher call is related to the Coedit dialogs. - immutable uint CTXT_DLGS = 0x05000000; - -// The events kinds ------------------------------------------------------------ - - /// somethings's just changed. - immutable uint EV_CHANGED = 0x00000001; - /// something's just been selected. - immutable uint EV_FOCUSED = 0x00000002; - /// something's just been closed. - immutable uint EV_CLOSED = 0x00000003; - /// something's just been created. - immutable uint EV_NEW = 0x00000004; - /// something gonna be compiled. - immutable uint EV_COMPILE = 0x00000005; - /// something gonna be executed. - immutable uint EV_RUN = 0x00000006; - -// The data kinds -------------------------------------------------------------- - - /// data1 is used to set/get a filename. data1 is a PChar. data0 represents an index. - immutable uint DT_FNAME = 0x00000001; - /// data0 represents a count. - immutable uint DT_COUNT = 0x00000002; - - /// data1 is used to set a message. data1 is a PChar. - immutable uint DT_ERR = 0x00000001; - /// ditto - immutable uint DT_INF = 0x00000002; - /// ditto - immutable uint DT_WARN = 0x00000003; - -// terminal opCodes (emiter + context + event/data kind) ----------------------- - - /// Coedit says that the project's just been modified. - immutable uint HOST_PROJ_CHANGED = HOST_EVENT + CTXT_PROJ + EV_CHANGED; - - /// opCode for asking for a document filename. data0 must be the document index. - immutable uint PLUG_WANT_DOC_NAME = PLUG_EVENT + CTXT_DOCS + DT_FNAME; - - /// opCode for getting a document filenmae. data1 is a PChar to the filename. - immutable uint HOST_GIVE_DOC_NAME = HOST_DATA + CTXT_DOCS + DT_FNAME; - - /// opCodes for displaying a message in a dialog box. - immutable uint PLUG_DLGS_ERR = PLUG_DATA + CTXT_DLGS + DT_ERR; - /// ditto. - immutable uint PLUG_DLGS_WARN = PLUG_DATA + CTXT_DLGS + DT_WARN; - /// ditto. - immutable uint PLUG_DLGS_INF = PLUG_DATA + CTXT_DLGS + DT_INF; - - /// opCodes for displaying a message in the 'Message Widget'. - immutable uint PLUG_MSGS_ERR = PLUG_DATA + CTXT_MSGS + DT_ERR; - /// ditto. - immutable uint PLUG_MSGS_WARN = PLUG_DATA + CTXT_MSGS + DT_WARN; - /// ditto. - immutable uint PLUG_MSGS_INF = PLUG_DATA + CTXT_MSGS + DT_INF; - -// host-side prototypes -------------------------------------------------------- - - /** - * A plugin asks for some information or it passes data here. - * Data1 and data2 are some pointers to a particular variable type. - * In the plugin hostCreatePlugProc, a the location of COedit dispatcher is passed - * to the plugin. - */ - extern(C) alias plugDispatchToHostProc = - void function(Plugin_t aPlugin, uint opCode, uint data0, void* data1, void* data2); - -// plugin-side prototypes------------------------------------------------------- - - /** - * Coedit initializes a plugin, the result is passed during the runtime as "aTarget". - * In the plugin implementation, it must be named 'createPlug'. - * If the result is null then the Plugin is not used at all. - * If the plugin is not warped in a class than the result must be set on something - * that can be pointed to (e.g: a global variable). - */ - extern(C) alias hostCreatePlugProc = - Plugin_t function (plugDispatchToHostProc aHost); - - /** - * Coedit closes and aTarget can be destroyed. - * In the plugin implementation, it must be named 'destroyPlug'. - */ - extern(C) alias hostDestroyPlugProc = - void function (Plugin_t aTarget); - - /** - * Coedit events and data are passed here. data1 and data2 can be casted according to opCode. - * In the plugin implementation, it must be named 'dispatchToPlug'. - */ - extern(C) alias hostDispatchToPlugProc = - void function(Plugin_t aPlugin, uint opCode, uint data0, void* data1, void* data2); - -// helpers --------------------------------------------------------------------- - -uint getEmiter(in uint opCode){ - return opCode & 0xF0000000; -} - -uint getContext(in uint opCode){ - return opCode & 0x0FF00000; -} - -uint getCommand(in uint opCode){ - return opCode & 0x000FFFFF; -} - diff --git a/lazproj/PluginApi/DTemplate/CoeditPlug.coedit b/lazproj/PluginApi/DTemplate/CoeditPlug.coedit deleted file mode 100644 index 60a82d04..00000000 --- a/lazproj/PluginApi/DTemplate/CoeditPlug.coedit +++ /dev/null @@ -1,42 +0,0 @@ -object CurrentProject: TCEProject - OptionsCollection = < - item - name = 'toPlugDir' - outputOptions.binaryKind = sharedlib - outputOptions.noBoundsCheck = False - outputOptions.boundsCheck = onAlways - outputOptions.optimizations = True - outputOptions.release = True - pathsOptions.outputFilename = '..\..\plugins\CoeditPlug.dll' - preBuildProcess.options = [] - preBuildProcess.showWindow = swoNone - postBuildProcess.options = [] - postBuildProcess.showWindow = swoNone - runOptions.options = [] - runOptions.showWindow = swoNone - end - item - name = 'abovePlugDir' - outputOptions.binaryKind = sharedlib - outputOptions.inlining = True - outputOptions.noBoundsCheck = False - outputOptions.boundsCheck = onAlways - outputOptions.optimizations = True - outputOptions.release = True - pathsOptions.outputFilename = '..\..\plugins\temp\CoeditPlug.dll' - preBuildProcess.options = [] - preBuildProcess.showWindow = swoNone - postBuildProcess.options = [] - postBuildProcess.showWindow = swoNone - runOptions.options = [] - runOptions.showWindow = swoNone - end> - Sources.Strings = ( - '..\CoeditPlugApi.d' - 'CoeditPlug.d' - ) - ConfigurationIndex = 1 - LibraryAliases.Strings = ( - 'iz' - ) -end diff --git a/lazproj/PluginApi/DTemplate/CoeditPlug.d b/lazproj/PluginApi/DTemplate/CoeditPlug.d deleted file mode 100644 index f9fc95bb..00000000 --- a/lazproj/PluginApi/DTemplate/CoeditPlug.d +++ /dev/null @@ -1,143 +0,0 @@ -module CoeditPlug; - -/* -Under linux: - -Build: -1:dmd -c CoeditPlug.d ../CoeditPlugApi.d pathtoIZ/types.d -fPIC -(or with a coedit project, select outputKind : object (which is actually -c)) -2:dmd -ofCOeditPlug.so -shared -defaultlib=libphobos2.so - -Note about IZ: - -The GC will make the plugin crash if coeditPlug is not an izObject -because (?). However since izObjects have their own, G.C free, de/allocators -it just instanciates fine. -*/ - - -import std.stdio, std.string, std.conv; -import core.runtime; -import CoeditPlugApi; -import iz.types; - -version(Posix) -{ - -} -else -{ - import std.c.windows.windows; - import core.sys.windows.dll; -} - - -coeditPlug plugin; - -class coeditPlug: izObject -{ - protected - { - plugDispatchToHostProc fDispatcher; - Plugin_t asPlugin_t(){return cast(Plugin_t)this;} - } - public - { - static this() - { - Runtime.initialize(); - } - - static ~this() - { - Runtime.terminate(); - } - - this(plugDispatchToHostProc aDispatcher) - { - assert(aDispatcher, "the Coedit dispatcher is missing"); - fDispatcher = aDispatcher; - version(none) - { - fDispatcher(asPlugin_t, HELLO_PLUGIN, 0, null, null); - } - auto msg = "simple Coedit plugin is created".toStringz; - fDispatcher(asPlugin_t, PLUG_MSGS_INF, 0, cast(void*)msg, null); - } - - void hostEvent(uint eventContext, uint eventKind) - { - auto msg = (to!string(eventContext) ~ " " ~ to!string(eventKind)).toStringz; - fDispatcher(asPlugin_t, PLUG_MSGS_INF, 0, cast(void*)msg, null); - } - - void hostData(uint dataContext, uint dataKind, uint data0, void* data1, void* data2) - { - } - } -} - - -extern(C) export -Plugin_t createPlug(plugDispatchToHostProc aHost) -{ - plugin = new coeditPlug(aHost); - return &plugin; -} - -extern(C) export -void destroyPlug(Plugin_t aPlug) -{ - delete plugin; -} - -extern(C) export -void dispatchToPlug(Plugin_t aPlugin, uint opCode, uint data0, void* data1, void* data2) -{ - assert(&plugin == aPlugin); - coeditPlug* plg = (cast(coeditPlug*) aPlugin); - - auto emit = opCode.getEmiter; - auto ctxt = opCode.getContext; - auto comd = opCode.getCommand; - - if (emit == HOST_EVENT) - plg.hostEvent(ctxt, comd); - else - plg.hostData(ctxt, comd, data0, data1, data2); -} - -version(Posix) -{ -} -else -{ - __gshared HINSTANCE g_hInst; - - extern (Windows) - BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) - { - switch (ulReason) - { - case DLL_PROCESS_ATTACH: - g_hInst = hInstance; - dll_process_attach( hInstance, true ); - break; - - case DLL_PROCESS_DETACH: - dll_process_detach( hInstance, true ); - break; - - case DLL_THREAD_ATTACH: - dll_thread_attach( true, true ); - break; - - case DLL_THREAD_DETACH: - dll_thread_detach( true, true ); - break; - - default: break; - } - return true; - } -} diff --git a/lazproj/coedit.lpi b/lazproj/coedit.lpi index 875c529b..5f770df9 100644 --- a/lazproj/coedit.lpi +++ b/lazproj/coedit.lpi @@ -140,7 +140,7 @@ - + @@ -245,124 +245,114 @@ - - - - - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - + + - + diff --git a/lazproj/coedit.lpr b/lazproj/coedit.lpr index 3c51c451..5de38527 100644 --- a/lazproj/coedit.lpr +++ b/lazproj/coedit.lpr @@ -8,7 +8,7 @@ uses {$ENDIF}{$ENDIF} Interfaces, Forms, lazcontrols, runtimetypeinfocontrols, ce_observer, ce_libman, ce_tools, ce_dcd, ce_main, ce_writableComponent, ce_options, ce_symstring, - ce_staticmacro, ce_icons, ce_dubwrap, ce_inspectors; + ce_staticmacro, ce_icons, ce_inspectors; {$R *.res} diff --git a/src/ce_main.pas b/src/ce_main.pas index 2bb8a7bb..fcfd9f13 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -183,7 +183,6 @@ type fProject: TCEProject; fProjMru: TMruFileList; fFileMru: TMruFileList; - fPlugList: TCEPlugDescriptorList; fWidgList: TCEWidgetList; fMesgWidg: TCEMessagesWidget; fEditWidg: TCEEditorWidget; @@ -234,13 +233,11 @@ type procedure checkCompilo; procedure InitMRUs; procedure InitWidgets; - procedure InitPlugins; procedure InitDocking; procedure InitSettings; procedure SaveSettings; procedure LoadDocking; procedure SaveDocking; - procedure KillPlugs; procedure FreeRunnableProc; // widget interfaces subroutines @@ -288,8 +285,6 @@ type property processInput: TCEProcInputWidget read fPrInpWidg; end; - procedure PlugDispatchToHost(aPlugin: TCEPlugin; opCode: LongWord; data0: Integer; data1, data2: Pointer); cdecl; - var CEMainForm: TCEMainForm; @@ -369,9 +364,6 @@ begin end; end; end; - value := application.GetOptionValue('plugs'); - if value <> 'OFF' then - InitPlugins; value := application.GetOptionValue('p', 'project'); if (value <> '') and fileExists(value) then openProj(value); @@ -402,53 +394,6 @@ begin fFileMru.OnChange := @mruChange; end; -procedure TCEMainForm.InitPlugins; -var - pth: string; - fname: string; - i: NativeInt; - lst: TStringList; - hdl: TLibHandle; - plg: PPlugDescriptor; -begin - fPlugList := TCEPlugDescriptorList.Create; - pth := extractFilePath(application.ExeName) + 'plugins'; - lst := TStringList.Create; - try - listFiles(lst, pth, false); - for i := 0 to lst.Count-1 do - begin - fname := lst.Strings[i]; - if extractFileExt(fname) <> '.' + SharedSuffix then - continue; - hdl := LoadLibrary(fname); - if hdl = NilHandle then - continue; - - plg := new(PPlugDescriptor); - plg^.Handle := hdl; - plg^.HostCreatePlug := THostCreatePlug(GetProcAddress(hdl, 'createPlug')); - plg^.HostDestroyPlug := THostDestroyPlug(GetProcAddress(hdl, 'destroyPlug')); - plg^.HostDispatchToPlug := THostDispatchToPlug(GetProcAddress(hdl, 'dispatchToPlug')); - if plg^.HostCreatePlug <> nil then - plg^.Plugin := plg^.HostCreatePlug(@PlugDispatchToHost); - - if (plg^.HostCreatePlug = nil) or (plg^.HostDestroyPlug = nil) or - (plg^.HostDispatchToPlug = nil) then - begin - Dispose(plg); - {$IFDEF RELEASE} - FreeLibrary(Hdl); - {$ENDIF} - continue; - end; - fPlugList.addPlugin(plg); - end; - finally - lst.Free; - end; -end; - procedure TCEMainForm.InitWidgets; var widg: TCEWidget; @@ -669,28 +614,6 @@ begin end; end; -procedure TCEMainForm.KillPlugs; -var - descr: TPlugDescriptor; - i: NativeInt; -begin - if fPlugList = nil then exit; - for i := 0 to fPlugList.Count-1 do - begin - descr := fPlugList.plugin[i]; - descr.HostDestroyPlug(descr.Plugin); - {$IFDEF RELEASE} - FreeLibrary(descr.Handle); - {$ENDIF} - end; - while fPlugList.Count <> 0 do - begin - Dispose(PPlugDescriptor(fPlugList.Items[fPlugList.Count-1])); - fPlugList.Delete(fPlugList.Count-1); - end; - fPlugList.Free; -end; - procedure TCEMainForm.FreeRunnableProc; var fname: string; @@ -710,8 +633,6 @@ destructor TCEMainForm.destroy; begin SaveSettings; // - KillPlugs; - // fWidgList.Free; fProjMru.Free; fFileMru.Free; @@ -1782,40 +1703,6 @@ begin end; {$ENDREGION} -procedure PlugDispatchToHost(aPlugin: TCEPlugin; opCode: LongWord; data0: Integer; data1, data2: Pointer); cdecl; -//var - //ctxt: NativeUint; - //oper: NativeUint; -begin - - if opCode = HELLO_PLUGIN then begin - dlgOkInfo('Hello plugin'); - exit; - end; -{ - ctxt := opCode and $0F000000; - oper := opCode and $000FFFFF; - - case ctxt of - CTXT_MSGS: - case oper of - //DT_ERR: CEMainForm.MessageWidget.addCeErr(PChar(data1)); - //DT_INF: CEMainForm.MessageWidget.addCeInf(PChar(data1)); - //DT_WARN: CEMainForm.MessageWidget.addCeWarn(PChar(data1)); - //else CEMainForm.MessageWidget.addCeWarn('unsupported dispatcher opCode'); - end; - CTXT_DLGS: - case oper of - DT_ERR: dlgOkError(PChar(data1)); - DT_INF: dlgOkInfo(PChar(data1)); - DT_WARN: dlgOkInfo(PChar(data1)); - //else CEMainForm.MessageWidget.addCeWarn('unsupported dispatcher opCode'); - end; - //else CEMainForm.MessageWidget.addCeWarn('unsupported dispatcher opCode'); - end;} - -end; - initialization RegisterClasses([TCEOptions]); end.