You've already forked lazarus-ccr
chelper: updated objc converting. fixing Caption issue with the Chelper options window, #18529
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1479 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -30,6 +30,7 @@ var
|
|||||||
ConfigFileRO : Boolean = false;
|
ConfigFileRO : Boolean = false;
|
||||||
ParseAll : Boolean = false;
|
ParseAll : Boolean = false;
|
||||||
ShowCodeSize : Boolean = False; // show the size of code processed
|
ShowCodeSize : Boolean = False; // show the size of code processed
|
||||||
|
isPascalUnit : Boolean = False; // convert to pascal unit
|
||||||
|
|
||||||
function StringFromFile(const FileName: AnsiString): AnsiString;
|
function StringFromFile(const FileName: AnsiString): AnsiString;
|
||||||
var
|
var
|
||||||
@@ -71,8 +72,10 @@ begin
|
|||||||
end else if p='-o' then begin
|
end else if p='-o' then begin
|
||||||
inc(i);
|
inc(i);
|
||||||
OutputFile:=ParamStr(i);
|
OutputFile:=ParamStr(i);
|
||||||
end else if p='-all' then
|
end else if p='-all' then begin
|
||||||
ParseAll:=True;
|
ParseAll:=True
|
||||||
|
end else if p='-pasunit' then
|
||||||
|
isPascalUnit:=True;
|
||||||
inc(i);
|
inc(i);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -88,6 +91,7 @@ begin
|
|||||||
writeln(' -defines filename - macros definition file. should be in C-preprocessor format');
|
writeln(' -defines filename - macros definition file. should be in C-preprocessor format');
|
||||||
writeln(' -showunparsed - writes out unprased entities by their classname (for debugging only)');
|
writeln(' -showunparsed - writes out unprased entities by their classname (for debugging only)');
|
||||||
writeln(' -codesize - show two numbers of the code processed (used by Chelper)');
|
writeln(' -codesize - show two numbers of the code processed (used by Chelper)');
|
||||||
|
writeln(' -pasunit - generates a pascal unit');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ReadParams(var InputFileName: String);
|
procedure ReadParams(var InputFileName: String);
|
||||||
@@ -106,6 +110,22 @@ begin
|
|||||||
InputFileName:=ParamStr(ParamCount);
|
InputFileName:=ParamStr(ParamCount);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function GetPascalUnitName(const UnitName: String): String;
|
||||||
|
begin
|
||||||
|
Result:=ChangeFileExt(UnitName, '');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddPascalUnit(outs: TStrings; const UnitName: String);
|
||||||
|
begin
|
||||||
|
if not Assigned(outs) then Exit;
|
||||||
|
outs.Insert(0, 'unit '+UnitName+';');
|
||||||
|
outs.Insert(1, '');
|
||||||
|
outs.Insert(2, 'interface');
|
||||||
|
outs.Add( 'implementation');
|
||||||
|
outs.Add( 'end.');
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
inps, outs : TStringList;
|
inps, outs : TStringList;
|
||||||
i : Integer;
|
i : Integer;
|
||||||
@@ -135,6 +155,11 @@ begin
|
|||||||
if ShowCodeSize then outs.Insert(0, Format('%d %d', [p.Y,p.X]));
|
if ShowCodeSize then outs.Insert(0, Format('%d %d', [p.Y,p.X]));
|
||||||
if err.isError then outs.Insert(0, Format('error %d %d %s',[err.ErrorPos.Y, err.ErrorPos. X, err.ErrorMsg]) );
|
if err.isError then outs.Insert(0, Format('error %d %d %s',[err.ErrorPos.Y, err.ErrorPos. X, err.ErrorMsg]) );
|
||||||
|
|
||||||
|
if isPascalUnit then begin
|
||||||
|
AddPascalUnit(outs, GetPascalUnitName(fn));
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
if OutputFile<>'' then
|
if OutputFile<>'' then
|
||||||
outs.SaveToFile(OutputFile)
|
outs.SaveToFile(OutputFile)
|
||||||
else
|
else
|
||||||
|
@@ -743,11 +743,11 @@ const
|
|||||||
begin
|
begin
|
||||||
SetPasSection(wr, 'type');
|
SetPasSection(wr, 'type');
|
||||||
if cent.isCategory then begin
|
if cent.isCategory then begin
|
||||||
wr.W(cent.Name + ' = objccategory');
|
wr.W(cent.Name + ' = objccategory external ');
|
||||||
if cent.SuperClass<>'' then wr.W('('+cent.SuperClass+')');
|
if cent.SuperClass<>'' then wr.W('('+cent.SuperClass+')');
|
||||||
wr.Wln;
|
wr.Wln;
|
||||||
end else begin
|
end else begin
|
||||||
wr.W(cent.Name + ' = objcclass');
|
wr.W(cent.Name + ' = objcclass external ');
|
||||||
if cent.SuperClass<>'' then wr.W('('+cent.SuperClass);
|
if cent.SuperClass<>'' then wr.W('('+cent.SuperClass);
|
||||||
if cent.Protocols.Count>0 then begin
|
if cent.Protocols.Count>0 then begin
|
||||||
if cent.SuperClass='' then wr.W('(id, ')
|
if cent.SuperClass='' then wr.W('(id, ')
|
||||||
@@ -781,7 +781,7 @@ begin
|
|||||||
WriteObjCMethods(cent.Methods);
|
WriteObjCMethods(cent.Methods);
|
||||||
wr.DecIdent;
|
wr.DecIdent;
|
||||||
end;
|
end;
|
||||||
wr.Wln('end external;');
|
wr.Wln('end;');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodeConvertor.WriteObjCProtocol(cent:TObjCProtocol);
|
procedure TCodeConvertor.WriteObjCProtocol(cent:TObjCProtocol);
|
||||||
@@ -794,7 +794,7 @@ begin
|
|||||||
for i:=0 to cent.Names.Count-1 do
|
for i:=0 to cent.Names.Count-1 do
|
||||||
wr.Wln(cent.Names[i]+'Protocol = objcprotocol; external name '''+cent.Names[i]+''';');
|
wr.Wln(cent.Names[i]+'Protocol = objcprotocol; external name '''+cent.Names[i]+''';');
|
||||||
end else begin
|
end else begin
|
||||||
wr.W(cent.Names[0]+'Protocol = objcprotocol');
|
wr.W(cent.Names[0]+'Protocol = objcprotocol external');
|
||||||
|
|
||||||
if cent.Protocols.Count>0 then begin
|
if cent.Protocols.Count>0 then begin
|
||||||
wr.W('(');
|
wr.W('(');
|
||||||
@@ -809,7 +809,7 @@ begin
|
|||||||
wr.DecIdent;
|
wr.DecIdent;
|
||||||
end;
|
end;
|
||||||
wr.W('end; ');
|
wr.W('end; ');
|
||||||
wr.Wln(' external name '''+cent.Names[0]+''';');
|
wr.Wln(' name '''+cent.Names[0]+''';');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -819,7 +819,7 @@ var
|
|||||||
begin
|
begin
|
||||||
SetPasSection(wr, 'type');
|
SetPasSection(wr, 'type');
|
||||||
for i:=0 to cent.ClassList.Count-1 do
|
for i:=0 to cent.ClassList.Count-1 do
|
||||||
wr.WLn(cent.ClassList[i] +' = objcclass; external;');
|
wr.WLn(cent.ClassList[i] +' = objcclass external;');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@@ -1349,6 +1349,7 @@ begin
|
|||||||
xp:='((1 shl ('+PasExp(x)+'))-1)';
|
xp:='((1 shl ('+PasExp(x)+'))-1)';
|
||||||
// returns true, if x is single number expression. V is the value of the number
|
// returns true, if x is single number expression. V is the value of the number
|
||||||
wr.W( GetIdFromPart(st.fields[i].v.FirstName) + ' : 0..'+xp+';');
|
wr.W( GetIdFromPart(st.fields[i].v.FirstName) + ' : 0..'+xp+';');
|
||||||
|
WriteLnCommentForOffset(st.fields[i].v.Offset);
|
||||||
end else
|
end else
|
||||||
WriteFuncOrVar(st.fields[i].v, False, True);
|
WriteFuncOrVar(st.fields[i].v, False, True);
|
||||||
end;
|
end;
|
||||||
|
@@ -8,28 +8,28 @@ object CtoPasConfig: TCtoPasConfig
|
|||||||
ClientWidth = 668
|
ClientWidth = 668
|
||||||
OnClose = FormClose
|
OnClose = FormClose
|
||||||
OnResize = FormResize
|
OnResize = FormResize
|
||||||
LCLVersion = '0.9.29'
|
LCLVersion = '0.9.31'
|
||||||
object Notebook1: TNotebook
|
object Notebook1: TNotebook
|
||||||
Left = 16
|
Left = 16
|
||||||
Height = 559
|
Height = 559
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 635
|
Width = 635
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
|
||||||
PageIndex = 0
|
PageIndex = 0
|
||||||
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
TabStop = True
|
||||||
object pageMain: TPage
|
object pageMain: TPage
|
||||||
Caption = 'Main'
|
ClientWidth = 635
|
||||||
ClientWidth = 629
|
ClientHeight = 559
|
||||||
ClientHeight = 520
|
|
||||||
object Panel1: TPanel
|
object Panel1: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 228
|
Height = 228
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 629
|
Width = 635
|
||||||
Align = alTop
|
Align = alTop
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 228
|
ClientHeight = 228
|
||||||
ClientWidth = 629
|
ClientWidth = 635
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
Left = 6
|
Left = 6
|
||||||
@@ -107,9 +107,9 @@ object CtoPasConfig: TCtoPasConfig
|
|||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideRight.Control = btnSelect
|
AnchorSideRight.Control = btnSelect
|
||||||
Left = 64
|
Left = 64
|
||||||
Height = 21
|
Height = 22
|
||||||
Top = 172
|
Top = 172
|
||||||
Width = 388
|
Width = 394
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Left = 6
|
BorderSpacing.Left = 6
|
||||||
BorderSpacing.Right = 6
|
BorderSpacing.Right = 6
|
||||||
@@ -117,7 +117,7 @@ object CtoPasConfig: TCtoPasConfig
|
|||||||
end
|
end
|
||||||
object btnSelect: TButton
|
object btnSelect: TButton
|
||||||
AnchorSideRight.Control = btnEdit
|
AnchorSideRight.Control = btnEdit
|
||||||
Left = 458
|
Left = 464
|
||||||
Height = 20
|
Height = 20
|
||||||
Top = 172
|
Top = 172
|
||||||
Width = 70
|
Width = 70
|
||||||
@@ -129,7 +129,7 @@ object CtoPasConfig: TCtoPasConfig
|
|||||||
TabOrder = 5
|
TabOrder = 5
|
||||||
end
|
end
|
||||||
object btnEdit: TButton
|
object btnEdit: TButton
|
||||||
Left = 548
|
Left = 554
|
||||||
Height = 20
|
Height = 20
|
||||||
Top = 172
|
Top = 172
|
||||||
Width = 70
|
Width = 70
|
||||||
@@ -143,7 +143,7 @@ object CtoPasConfig: TCtoPasConfig
|
|||||||
Left = 325
|
Left = 325
|
||||||
Height = 22
|
Height = 22
|
||||||
Top = 100
|
Top = 100
|
||||||
Width = 293
|
Width = 299
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
TabOrder = 7
|
TabOrder = 7
|
||||||
end
|
end
|
||||||
@@ -161,21 +161,21 @@ object CtoPasConfig: TCtoPasConfig
|
|||||||
end
|
end
|
||||||
object Panel2: TPanel
|
object Panel2: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 292
|
Height = 331
|
||||||
Top = 228
|
Top = 228
|
||||||
Width = 629
|
Width = 635
|
||||||
Align = alClient
|
Align = alClient
|
||||||
Alignment = taLeftJustify
|
Alignment = taLeftJustify
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 292
|
ClientHeight = 331
|
||||||
ClientWidth = 629
|
ClientWidth = 635
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
object Splitter1: TSplitter
|
object Splitter1: TSplitter
|
||||||
Cursor = crVSplit
|
Cursor = crVSplit
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 5
|
Height = 5
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 629
|
Width = 635
|
||||||
Align = alTop
|
Align = alTop
|
||||||
ResizeAnchor = akTop
|
ResizeAnchor = akTop
|
||||||
end
|
end
|
||||||
@@ -189,9 +189,9 @@ object CtoPasConfig: TCtoPasConfig
|
|||||||
end
|
end
|
||||||
object Memo1: TMemo
|
object Memo1: TMemo
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 242
|
Height = 281
|
||||||
Top = 44
|
Top = 44
|
||||||
Width = 617
|
Width = 623
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
BorderSpacing.Left = 6
|
BorderSpacing.Left = 6
|
||||||
@@ -204,7 +204,7 @@ object CtoPasConfig: TCtoPasConfig
|
|||||||
Left = 476
|
Left = 476
|
||||||
Height = 20
|
Height = 20
|
||||||
Top = 14
|
Top = 14
|
||||||
Width = 147
|
Width = 153
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
Caption = 'Reset to defaults'
|
Caption = 'Reset to defaults'
|
||||||
@@ -214,9 +214,8 @@ object CtoPasConfig: TCtoPasConfig
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
object pageConverter: TPage
|
object pageConverter: TPage
|
||||||
Caption = 'Converter'
|
ClientWidth = 2464
|
||||||
ClientWidth = 616
|
ClientHeight = 1528
|
||||||
ClientHeight = 382
|
|
||||||
object edtExtTool: TEdit
|
object edtExtTool: TEdit
|
||||||
AnchorSideTop.Control = chkUseExternal
|
AnchorSideTop.Control = chkUseExternal
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
|
@@ -55,7 +55,7 @@ type
|
|||||||
var
|
var
|
||||||
CtoPasConfig: TCtoPasConfig;
|
CtoPasConfig: TCtoPasConfig;
|
||||||
|
|
||||||
function ShowConfigDialog: TCtoPasConfig;
|
function ShowConfigDialog : TCtoPasConfig;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@@ -55,6 +55,35 @@ function SkipLine(const s: AnsiString; var index: Integer): AnsiString;
|
|||||||
|
|
||||||
procedure OffsetToLinePos(const t: AnsiString; Offset: Integer; var P: TPoint);
|
procedure OffsetToLinePos(const t: AnsiString; Offset: Integer; var P: TPoint);
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
TRange = record stofs, endofs : Integer; end;
|
||||||
|
|
||||||
|
{ TSubBuffer }
|
||||||
|
|
||||||
|
TSubBuffer = class(TObject)
|
||||||
|
Ranges : array of TRange;
|
||||||
|
RangesCount : Integer;
|
||||||
|
Name : string;
|
||||||
|
Tag : TObject;
|
||||||
|
constructor Create(const AName: string; ATag: TObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TTextBuffer }
|
||||||
|
|
||||||
|
TTextBuffer = class(TObject)
|
||||||
|
private
|
||||||
|
function GetSubBuffer(i: Integer): TSubBuffer;
|
||||||
|
protected
|
||||||
|
function GetCount: Integer;
|
||||||
|
public
|
||||||
|
buffer: String;
|
||||||
|
constructor Create(const Abuffer: String=''; const aname: string = ''; aobj: TObject = nil);
|
||||||
|
procedure InsertSubBuffer(pos: Integer; const ABuffer: string; const AName: string = ''; ATag: TObject = '');
|
||||||
|
property SubBuffer[i: Integer]: TSubBuffer read GetSubBuffer;
|
||||||
|
property Count: Integer read GetCount;
|
||||||
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
function ScanWhile(const s: AnsiString; var index: Integer; const ch: TCharSet): AnsiString;
|
function ScanWhile(const s: AnsiString; var index: Integer; const ch: TCharSet): AnsiString;
|
||||||
@@ -168,5 +197,38 @@ begin
|
|||||||
P.X := Offset - le + 1;
|
P.X := Offset - le + 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TTextBuffer }
|
||||||
|
|
||||||
|
function TTextBuffer.GetSubBuffer(i: Integer): TSubBuffer;
|
||||||
|
begin
|
||||||
|
Result:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TTextBuffer.GetCount: Integer;
|
||||||
|
begin
|
||||||
|
Result:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TTextBuffer.Create(const Abuffer: String; const aname: string;
|
||||||
|
aobj: TObject);
|
||||||
|
begin
|
||||||
|
if abuffer<>'' then
|
||||||
|
InsertSubBuffer(1, abuffer, aname, aobj);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTextBuffer.InsertSubBuffer(pos: Integer; const ABuffer: string; const AName: string; ATag: TObject);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TSubBuffer }
|
||||||
|
|
||||||
|
constructor TSubBuffer.Create(const AName: string; ATag: TObject);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
Name:=AName;
|
||||||
|
Tag:=ATag;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user