diff --git a/trunk/Projects/SAMufasaGUI/libcpascal.dll b/trunk/Plugins/libcpascal.dll similarity index 99% rename from trunk/Projects/SAMufasaGUI/libcpascal.dll rename to trunk/Plugins/libcpascal.dll index 632844d..2c37d1c 100755 Binary files a/trunk/Projects/SAMufasaGUI/libcpascal.dll and b/trunk/Plugins/libcpascal.dll differ diff --git a/trunk/Plugins/libcpascal.so b/trunk/Plugins/libcpascal.so new file mode 100755 index 0000000..7c2e058 Binary files /dev/null and b/trunk/Plugins/libcpascal.so differ diff --git a/trunk/Projects/SAMufasaGUI/libcpascal.a b/trunk/Projects/SAMufasaGUI/libcpascal.a deleted file mode 100644 index 51a710d..0000000 Binary files a/trunk/Projects/SAMufasaGUI/libcpascal.a and /dev/null differ diff --git a/trunk/Projects/SAMufasaGUI/libcpascal.so b/trunk/Projects/SAMufasaGUI/libcpascal.so deleted file mode 100755 index bc0a71b..0000000 Binary files a/trunk/Projects/SAMufasaGUI/libcpascal.so and /dev/null differ diff --git a/trunk/Projects/SAMufasaGUI/project1.lpi b/trunk/Projects/SAMufasaGUI/project1.lpi index c004aaf..688c24a 100644 --- a/trunk/Projects/SAMufasaGUI/project1.lpi +++ b/trunk/Projects/SAMufasaGUI/project1.lpi @@ -27,7 +27,7 @@ - + diff --git a/trunk/Projects/SAMufasaGUI/testunit.lfm b/trunk/Projects/SAMufasaGUI/testunit.lfm index d57bdaf..f08b393 100644 --- a/trunk/Projects/SAMufasaGUI/testunit.lfm +++ b/trunk/Projects/SAMufasaGUI/testunit.lfm @@ -1,7 +1,7 @@ object Form1: TForm1 - Left = 706 + Left = 593 Height = 557 - Top = 373 + Top = 321 Width = 734 ActiveControl = ScriptPanel Caption = 'THA FUKING SIMBA' diff --git a/trunk/Projects/SAMufasaGUI/testunit.lrs b/trunk/Projects/SAMufasaGUI/testunit.lrs index c3c7fbd..a37bfc9 100644 --- a/trunk/Projects/SAMufasaGUI/testunit.lrs +++ b/trunk/Projects/SAMufasaGUI/testunit.lrs @@ -1,10 +1,10 @@ { This is an automatically generated lazarus resource file } LazarusResources.Add('TForm1','FORMDATA',[ - 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#194#2#6'Height'#3'-'#2#3'Top'#3'u'#1#5'Wi' - +'dth'#3#222#2#13'ActiveControl'#7#11'ScriptPanel'#7'Caption'#6#16'THA FUKING' - +' SIMBA'#12'ClientHeight'#3#20#2#11'ClientWidth'#3#222#2#10'KeyPreview'#9#4 - +'Menu'#7#8'MainMenu'#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCreate'#9 + 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'Q'#2#6'Height'#3'-'#2#3'Top'#3'A'#1#5'Wid' + +'th'#3#222#2#13'ActiveControl'#7#11'ScriptPanel'#7'Caption'#6#16'THA FUKING ' + +'SIMBA'#12'ClientHeight'#3#20#2#11'ClientWidth'#3#222#2#10'KeyPreview'#9#4'M' + +'enu'#7#8'MainMenu'#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCreate'#9 +'OnDestroy'#7#11'FormDestroy'#10'OnShortCut'#7#13'FormShortCuts'#8'Position' +#7#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.29'#7'Visible'#9#0#8'TToolBar'#8 +'ToolBar1'#4'Left'#2#0#6'Height'#2#24#3'Top'#2#0#5'Width'#3#222#2#7'Caption' diff --git a/trunk/Projects/SAMufasaGUI/testunit.pas b/trunk/Projects/SAMufasaGUI/testunit.pas index 966daf2..2841cda 100644 --- a/trunk/Projects/SAMufasaGUI/testunit.pas +++ b/trunk/Projects/SAMufasaGUI/testunit.pas @@ -536,7 +536,7 @@ begin CurrentSyncInfo.SyncMethod:= @Self.SafeCallThread; UseCPascal := LoadSettingDef('Settings/Interpreter/UseCPascal', 'True'); if lowercase(UseCPascal) = 'true' then - ScriptThread := TCPThread.Create('libcpascal',True,@CurrentSyncInfo,PluginsPath) + ScriptThread := TCPThread.Create(True,@CurrentSyncInfo,PluginsPath) else ScriptThread := TPSThread.Create(True,@CurrentSyncInfo,PluginsPath); {$IFNDEF TERMINALWRITELN} diff --git a/trunk/Units/MMLAddon/mmlpsthread.pas b/trunk/Units/MMLAddon/mmlpsthread.pas index e51b79b..ec8fe90 100644 --- a/trunk/Units/MMLAddon/mmlpsthread.pas +++ b/trunk/Units/MMLAddon/mmlpsthread.pas @@ -143,7 +143,7 @@ type instance: pointer; added_methods: array of TExpMethod; public - constructor Create(libname: string; CreateSuspended: Boolean; TheSyncInfo : PSyncInfo; plugin_dir: string); + constructor Create(CreateSuspended: Boolean; TheSyncInfo : PSyncInfo; plugin_dir: string); destructor Destroy; override; procedure SetScript(script: string); override; procedure Execute; override; @@ -151,25 +151,20 @@ type procedure AddMethod(meth: TExpMethod); override; end; - function interp_init(precomp: TPrecompiler_Callback; err: TErrorHandeler_Callback): Pointer; cdecl; external; - procedure interp_meth(interp: Pointer; addr: Pointer; def: PChar); cdecl; external; - procedure interp_set(interp: Pointer; ppg: PChar); cdecl; external; - function interp_comp(interp: Pointer): boolean; cdecl; external; - function interp_run(interp: Pointer): boolean; cdecl; external; - procedure interp_free(interp: Pointer); cdecl; external; - threadvar CurrThread : TMThread; var PluginsGlob: TMPlugins; -implementation + libcpascal: integer; + interp_init: function(precomp: TPrecompiler_Callback; err: TErrorHandeler_Callback): Pointer; cdecl; + interp_meth: procedure(interp: Pointer; addr: Pointer; def: PChar); cdecl; + interp_set: procedure(interp: Pointer; ppg: PChar); cdecl; + interp_comp: function(interp: Pointer): boolean; cdecl; + interp_run: function(interp: Pointer): boolean; cdecl; + interp_free: procedure(interp: Pointer); cdecl; -{$ifdef LINUX} - {$link ./libcpascal.so} -{$else} - {$linklib ./libcpascal.dll} -{$endif} +implementation uses colour_conv,dtmutil, @@ -678,6 +673,19 @@ end; {***implementation TCPThread***} +procedure LoadCPascal(plugin_dir: string); +begin + libcpascal:= LoadLibrary(PChar(plugin_dir + 'libcpascal' + {$ifdef LINUX} '.so' {$else} '.dll' {$endif})); + if libcpascal = 0 then + raise Exception.Create('CPascal library not found'); + Pointer(interp_init):= GetProcAddress(libcpascal, PChar('interp_init')); + Pointer(interp_meth):= GetProcAddress(libcpascal, PChar('interp_meth')); + Pointer(interp_set):= GetProcAddress(libcpascal, PChar('interp_set')); + Pointer(interp_comp):= GetProcAddress(libcpascal, PChar('interp_comp')); + Pointer(interp_run):= GetProcAddress(libcpascal, PChar('interp_run')); + Pointer(interp_free):= GetProcAddress(libcpascal, PChar('interp_free')); +end; + function Interpreter_Precompiler(name, args: PChar): boolean; stdcall; var local_name, local_args: string; @@ -693,10 +701,12 @@ begin CurrThread.HandleError(line,pos,err,errCompile,'') end; -constructor TCPThread.Create(libname: string; CreateSuspended: Boolean; TheSyncInfo : PSyncInfo; plugin_dir: string); +constructor TCPThread.Create(CreateSuspended: Boolean; TheSyncInfo : PSyncInfo; plugin_dir: string); var plugin_idx: integer; begin + if libcpascal = 0 then + LoadCPascal(plugin_dir); instance:= interp_init(@Interpreter_Precompiler, @Interpreter_ErrorHandler); inherited Create(CreateSuspended, TheSyncInfo, plugin_dir); end; @@ -751,6 +761,7 @@ end; initialization PluginsGlob := TMPlugins.Create; + libcpascal:= 0; finalization //PluginsGlob.Free; //Its a nice idea, but it will segfault... the program is closing anyway.