mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-22 17:22:21 -05:00
Made CPascal dynamically link from the Plugins folder... STILL an error from running inside Simba, need to do more research. Its fairly stable though
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@493 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
12804e9d4a
commit
89916c30a5
Binary file not shown.
BIN
trunk/Plugins/libcpascal.so
Executable file
BIN
trunk/Plugins/libcpascal.so
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -27,7 +27,7 @@
|
|||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<local>
|
||||||
<FormatVersion Value="1"/>
|
<FormatVersion Value="1"/>
|
||||||
<LaunchingApplication Use="True" PathPlusParams="/usr/bin/gnome-terminal -t 'Lazarus Run Output' -e '$(LazarusDir)/tools/runwait.sh $(TargetCmdLine)'"/>
|
<LaunchingApplication PathPlusParams="/usr/bin/gnome-terminal -t 'Lazarus Run Output' -e '$(LazarusDir)/tools/runwait.sh $(TargetCmdLine)'"/>
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="2">
|
<RequiredPackages Count="2">
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
object Form1: TForm1
|
object Form1: TForm1
|
||||||
Left = 706
|
Left = 593
|
||||||
Height = 557
|
Height = 557
|
||||||
Top = 373
|
Top = 321
|
||||||
Width = 734
|
Width = 734
|
||||||
ActiveControl = ScriptPanel
|
ActiveControl = ScriptPanel
|
||||||
Caption = 'THA FUKING SIMBA'
|
Caption = 'THA FUKING SIMBA'
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{ This is an automatically generated lazarus resource file }
|
{ This is an automatically generated lazarus resource file }
|
||||||
|
|
||||||
LazarusResources.Add('TForm1','FORMDATA',[
|
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'
|
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'Q'#2#6'Height'#3'-'#2#3'Top'#3'A'#1#5'Wid'
|
||||||
+'dth'#3#222#2#13'ActiveControl'#7#11'ScriptPanel'#7'Caption'#6#16'THA FUKING'
|
+'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
|
+'SIMBA'#12'ClientHeight'#3#20#2#11'ClientWidth'#3#222#2#10'KeyPreview'#9#4'M'
|
||||||
+'Menu'#7#8'MainMenu'#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCreate'#9
|
+'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'
|
+'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
|
+#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'
|
+'ToolBar1'#4'Left'#2#0#6'Height'#2#24#3'Top'#2#0#5'Width'#3#222#2#7'Caption'
|
||||||
|
@ -536,7 +536,7 @@ begin
|
|||||||
CurrentSyncInfo.SyncMethod:= @Self.SafeCallThread;
|
CurrentSyncInfo.SyncMethod:= @Self.SafeCallThread;
|
||||||
UseCPascal := LoadSettingDef('Settings/Interpreter/UseCPascal', 'True');
|
UseCPascal := LoadSettingDef('Settings/Interpreter/UseCPascal', 'True');
|
||||||
if lowercase(UseCPascal) = 'true' then
|
if lowercase(UseCPascal) = 'true' then
|
||||||
ScriptThread := TCPThread.Create('libcpascal',True,@CurrentSyncInfo,PluginsPath)
|
ScriptThread := TCPThread.Create(True,@CurrentSyncInfo,PluginsPath)
|
||||||
else
|
else
|
||||||
ScriptThread := TPSThread.Create(True,@CurrentSyncInfo,PluginsPath);
|
ScriptThread := TPSThread.Create(True,@CurrentSyncInfo,PluginsPath);
|
||||||
{$IFNDEF TERMINALWRITELN}
|
{$IFNDEF TERMINALWRITELN}
|
||||||
|
@ -143,7 +143,7 @@ type
|
|||||||
instance: pointer;
|
instance: pointer;
|
||||||
added_methods: array of TExpMethod;
|
added_methods: array of TExpMethod;
|
||||||
public
|
public
|
||||||
constructor Create(libname: string; CreateSuspended: Boolean; TheSyncInfo : PSyncInfo; plugin_dir: string);
|
constructor Create(CreateSuspended: Boolean; TheSyncInfo : PSyncInfo; plugin_dir: string);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure SetScript(script: string); override;
|
procedure SetScript(script: string); override;
|
||||||
procedure Execute; override;
|
procedure Execute; override;
|
||||||
@ -151,25 +151,20 @@ type
|
|||||||
procedure AddMethod(meth: TExpMethod); override;
|
procedure AddMethod(meth: TExpMethod); override;
|
||||||
end;
|
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
|
threadvar
|
||||||
CurrThread : TMThread;
|
CurrThread : TMThread;
|
||||||
var
|
var
|
||||||
PluginsGlob: TMPlugins;
|
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}
|
implementation
|
||||||
{$link ./libcpascal.so}
|
|
||||||
{$else}
|
|
||||||
{$linklib ./libcpascal.dll}
|
|
||||||
{$endif}
|
|
||||||
|
|
||||||
uses
|
uses
|
||||||
colour_conv,dtmutil,
|
colour_conv,dtmutil,
|
||||||
@ -678,6 +673,19 @@ end;
|
|||||||
|
|
||||||
{***implementation TCPThread***}
|
{***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;
|
function Interpreter_Precompiler(name, args: PChar): boolean; stdcall;
|
||||||
var
|
var
|
||||||
local_name, local_args: string;
|
local_name, local_args: string;
|
||||||
@ -693,10 +701,12 @@ begin
|
|||||||
CurrThread.HandleError(line,pos,err,errCompile,'')
|
CurrThread.HandleError(line,pos,err,errCompile,'')
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TCPThread.Create(libname: string; CreateSuspended: Boolean; TheSyncInfo : PSyncInfo; plugin_dir: string);
|
constructor TCPThread.Create(CreateSuspended: Boolean; TheSyncInfo : PSyncInfo; plugin_dir: string);
|
||||||
var
|
var
|
||||||
plugin_idx: integer;
|
plugin_idx: integer;
|
||||||
begin
|
begin
|
||||||
|
if libcpascal = 0 then
|
||||||
|
LoadCPascal(plugin_dir);
|
||||||
instance:= interp_init(@Interpreter_Precompiler, @Interpreter_ErrorHandler);
|
instance:= interp_init(@Interpreter_Precompiler, @Interpreter_ErrorHandler);
|
||||||
inherited Create(CreateSuspended, TheSyncInfo, plugin_dir);
|
inherited Create(CreateSuspended, TheSyncInfo, plugin_dir);
|
||||||
end;
|
end;
|
||||||
@ -751,6 +761,7 @@ end;
|
|||||||
|
|
||||||
initialization
|
initialization
|
||||||
PluginsGlob := TMPlugins.Create;
|
PluginsGlob := TMPlugins.Create;
|
||||||
|
libcpascal:= 0;
|
||||||
finalization
|
finalization
|
||||||
//PluginsGlob.Free;
|
//PluginsGlob.Free;
|
||||||
//Its a nice idea, but it will segfault... the program is closing anyway.
|
//Its a nice idea, but it will segfault... the program is closing anyway.
|
||||||
|
Loading…
Reference in New Issue
Block a user