mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-22 09:12:19 -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>
|
||||
<local>
|
||||
<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>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
|
@ -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'
|
||||
|
@ -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'
|
||||
|
@ -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}
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user