1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-25 02:32:19 -05:00

Wrapper Converter for RUTIS.

This commit is contained in:
Niels 2010-09-05 20:31:56 +02:00
parent 1d17f75796
commit 5bed611826
5 changed files with 2710 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,168 @@
unit main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, SynEdit, SynHighlighterPas;
type
{ TfrmMain }
TfrmMain = class(TForm)
btnGo: TButton;
pnlMain: TPanel;
Splitter1: TSplitter;
Splitter2: TSplitter;
eIn: TSynEdit;
eOut: TSynEdit;
eDebug: TSynEdit;
PasHL: TSynPasSyn;
procedure btnGoClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
frmMain: TfrmMain;
implementation
uses
v_ideCodeParser;
{$R *.lfm}
{ TfrmMain }
procedure TfrmMain.btnGoClick(Sender: TObject);
procedure Debug(s: string); overload;
begin
if (Trim(eOut.Text) <> '') then
eDebug.Lines.Append(s)
else
eDebug.Text := s;
end;
procedure Debug(v: Variant); overload;
begin
Debug(string(v));
end;
procedure Write(s: string); overload;
begin
if (Trim(eOut.Text) <> '') then
eOut.Text := eOut.Text + s
else
eOut.Text := s;
end;
procedure Write(v: Variant); overload;
begin
Write(string(v));
end;
var
p: TCodeParser;
m: TMemoryStream;
a, b, c: TDeclarationArray;
i, ii, iii, pc: Integer;
s: string;
d: TDeclaration;
Fail: Boolean;
begin
p := TCodeParser.Create;
m := TMemoryStream.Create;
try
eOut.BeginUpdate;
eOut.ClearAll;
eDebug.BeginUpdate;
eDebug.ClearAll;
eIn.Lines.SaveToStream(m);
try
p.Run(m);
except on E : Exception do
Debug(e.Message);
end;
a := p.Items.GetItemsOfClass(TciProcedureDeclaration);
Debug('Start converting '+IntToStr(Length(a))+' methods!');
for i := 0 to High(a) do
with TciProcedureDeclaration(a[i]) do
begin
if (Name = nil) then
begin
Debug('No name found, skipping..');
Continue;
end;
s := 'procedure _RUTIS_'+Name.ShortText+
'(Stack: TRutisStack; Params: PRutisParamInfoArray; Result: PRutisParamInfo);'+LineEnding+
'begin'+LineEnding+' ';
d := Items.GetFirstItemOfClass(TciReturnType);
if (d <> nil) then
s := s+'P'+d.ShortText+'(Result^.Data)^ := ';
s := s+Name.ShortText+'(';
pc := 0;
Fail := False;
b := GetParamDeclarations();
for ii := 0 to High(b) do
begin
d := b[ii].Items.GetFirstItemOfClass(TciParameterType);
if (d = nil) then
begin
Debug('No parameter type found in '+Name.ShortText+', skipping..');
Fail := True;
Break;
end;
c := b[ii].Items.GetItemsOfClass(TciParameterName);
if (Length(c) < 1) then
begin
Debug('No parameter names found in '+Name.ShortText+', skipping..');
Fail := True;
Break;
end;
for iii := High(c) downto 0 do
begin
if (pc > 0) then
s := s+', ';
s := s+'P'+d.ShortText+'(Params^['+IntToStr(pc)+'].Data)^';
Inc(pc);
end;
end;
if Fail then
Continue;
s := s+');'+LineEnding+'end;';
if (i > 0) then
s := LineEnding+s;
Write(s);
Debug('Done "'+Name.ShortText+'"!');
end;
finally
m.Free;
p.Free;
eOut.EndUpdate;
eDebug.EndUpdate;
end;
Debug('Done :)');
end;
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,304 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<MainUnit Value="0"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
<ActiveWindowIndexAtStart Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="SynEdit"/>
<MinVersion Major="1" Valid="True"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="15">
<Unit0>
<Filename Value="ruwa.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ruwa"/>
<UsageCount Value="20"/>
</Unit0>
<Unit1>
<Filename Value="main.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="frmMain"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="main"/>
<EditorIndex Value="0"/>
<WindowIndex Value="0"/>
<TopLine Value="115"/>
<CursorPos X="41" Y="150"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="..\..\Units\Misc\v_MiscFunctions.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="v_MiscFunctions"/>
<UsageCount Value="20"/>
</Unit2>
<Unit3>
<Filename Value="..\..\Units\Misc\ValistusDefines.inc"/>
<IsPartOfProject Value="True"/>
<UsageCount Value="20"/>
</Unit3>
<Unit4>
<Filename Value="..\..\Units\Misc\CastaliaPasLex.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="CastaliaPasLex"/>
<UsageCount Value="20"/>
</Unit4>
<Unit5>
<Filename Value="..\..\Units\Misc\CastaliaPasLexTypes.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="CastaliaPasLexTypes"/>
<UsageCount Value="20"/>
</Unit5>
<Unit6>
<Filename Value="..\..\Units\Misc\CastaliaSimplePasPar.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="CastaliaSimplePasPar"/>
<UsageCount Value="20"/>
</Unit6>
<Unit7>
<Filename Value="..\..\Units\Misc\CastaliaSimplePasParTypes.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="CastaliaSimplePasParTypes"/>
<UsageCount Value="20"/>
</Unit7>
<Unit8>
<Filename Value="..\..\Units\Misc\v_autocompleteform.pas"/>
<UnitName Value="v_autocompleteform"/>
<UsageCount Value="20"/>
</Unit8>
<Unit9>
<Filename Value="..\..\Units\Misc\v_Constants.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="v_Constants"/>
<UsageCount Value="20"/>
</Unit9>
<Unit10>
<Filename Value="..\..\Units\Misc\v_ideCodeInsight.pas"/>
<UnitName Value="v_ideCodeInsight"/>
<WindowIndex Value="0"/>
<TopLine Value="239"/>
<CursorPos X="35" Y="286"/>
<UsageCount Value="20"/>
</Unit10>
<Unit11>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="v_ideCodeParser"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="8" Y="8"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
<Filename Value="..\..\..\FPC\Source\rtl\win\sysutils.pp"/>
<UnitName Value="sysutils"/>
<WindowIndex Value="0"/>
<TopLine Value="567"/>
<CursorPos X="29" Y="596"/>
<UsageCount Value="10"/>
</Unit12>
<Unit13>
<Filename Value="..\..\..\LazSVN\components\synedit\synedit.pp"/>
<UnitName Value="SynEdit"/>
<WindowIndex Value="0"/>
<TopLine Value="6433"/>
<CursorPos X="34" Y="6451"/>
<UsageCount Value="10"/>
</Unit13>
<Unit14>
<Filename Value="..\..\..\FPC\Source\rtl\win32\system.pp"/>
<UnitName Value="System"/>
<WindowIndex Value="0"/>
<TopLine Value="17"/>
<CursorPos X="2" Y="35"/>
<UsageCount Value="10"/>
</Unit14>
</Units>
<JumpHistory Count="29" HistoryIndex="28">
<Position1>
<Filename Value="main.pas"/>
<Caret Line="76" Column="45" TopLine="53"/>
</Position1>
<Position2>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="125" Column="24" TopLine="103"/>
</Position2>
<Position3>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="864" Column="30" TopLine="846"/>
</Position3>
<Position4>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="892" Column="26" TopLine="863"/>
</Position4>
<Position5>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="1193" Column="133" TopLine="1175"/>
</Position5>
<Position6>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="1422" Column="28" TopLine="1404"/>
</Position6>
<Position7>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="1429" Column="114" TopLine="1404"/>
</Position7>
<Position8>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="1441" Column="36" TopLine="1424"/>
</Position8>
<Position9>
<Filename Value="main.pas"/>
<Caret Line="98" Column="24" TopLine="69"/>
</Position9>
<Position10>
<Filename Value="main.pas"/>
<Caret Line="80" Column="101" TopLine="63"/>
</Position10>
<Position11>
<Filename Value="main.pas"/>
<Caret Line="60" Column="12" TopLine="52"/>
</Position11>
<Position12>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="42" Column="89" TopLine="33"/>
</Position12>
<Position13>
<Filename Value="main.pas"/>
<Caret Line="83" Column="31" TopLine="63"/>
</Position13>
<Position14>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="43" Column="33" TopLine="25"/>
</Position14>
<Position15>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="379" Column="46" TopLine="361"/>
</Position15>
<Position16>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="656" Column="56" TopLine="638"/>
</Position16>
<Position17>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="674" Column="44" TopLine="656"/>
</Position17>
<Position18>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="680" Column="56" TopLine="654"/>
</Position18>
<Position19>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="701" Column="58" TopLine="683"/>
</Position19>
<Position20>
<Filename Value="main.pas"/>
<Caret Line="104" Column="24" TopLine="90"/>
</Position20>
<Position21>
<Filename Value="..\..\Units\Misc\v_ideCodeParser.pas"/>
<Caret Line="8" Column="8" TopLine="1"/>
</Position21>
<Position22>
<Filename Value="main.pas"/>
<Caret Line="117" Column="51" TopLine="103"/>
</Position22>
<Position23>
<Filename Value="main.pas"/>
<Caret Line="100" Column="20" TopLine="105"/>
</Position23>
<Position24>
<Filename Value="main.pas"/>
<Caret Line="101" Column="1" TopLine="83"/>
</Position24>
<Position25>
<Filename Value="main.pas"/>
<Caret Line="137" Column="35" TopLine="111"/>
</Position25>
<Position26>
<Filename Value="main.pas"/>
<Caret Line="101" Column="1" TopLine="83"/>
</Position26>
<Position27>
<Filename Value="main.pas"/>
<Caret Line="78" Column="13" TopLine="61"/>
</Position27>
<Position28>
<Filename Value="main.pas"/>
<Caret Line="62" Column="22" TopLine="37"/>
</Position28>
<Position29>
<Filename Value="main.pas"/>
<Caret Line="147" Column="18" TopLine="125"/>
</Position29>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="ruwa"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)\;..\..\Units\Misc\"/>
<OtherUnitFiles Value="..\..\Units\Misc\"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,21 @@
program ruwa;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, main, v_MiscFunctions, CastaliaPasLex, CastaliaPasLexTypes,
CastaliaSimplePasPar, CastaliaSimplePasParTypes,
v_Constants, v_ideCodeParser;
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TfrmMain, frmMain);
Application.Run;
end.