From 63822c946206f00b4e8a2148038378ba52800ee4 Mon Sep 17 00:00:00 2001 From: loesje_ Date: Mon, 19 Mar 2012 14:10:59 +0000 Subject: [PATCH] * Updated the gui-project for the new type-mappings git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2356 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/idlparser/idlparser.pas | 1 + applications/idlparser/idltypemap.cfg | 15 +++++ applications/idlparser/main.pas | 2 +- applications/idlparser/pascaltypesettings.lfm | 63 +++++-------------- applications/idlparser/pascaltypesettings.pas | 19 +----- applications/idlparser/readme.txt | 10 +-- 6 files changed, 37 insertions(+), 73 deletions(-) create mode 100644 applications/idlparser/idltypemap.cfg diff --git a/applications/idlparser/idlparser.pas b/applications/idlparser/idlparser.pas index 287cdd4c6..81f982463 100644 --- a/applications/idlparser/idlparser.pas +++ b/applications/idlparser/idlparser.pas @@ -161,6 +161,7 @@ var IDLString: string; pCurrent: pchar; AWord: string; + LineNr: integer; pWordStart: pchar; wordchars: set of char; UUIDAttribute: string; diff --git a/applications/idlparser/idltypemap.cfg b/applications/idlparser/idltypemap.cfg new file mode 100644 index 000000000..bb8b8708b --- /dev/null +++ b/applications/idlparser/idltypemap.cfg @@ -0,0 +1,15 @@ +wstring=PWideChar +string=PAnsiChar +boolean=longbool +FILE=PFILE +nsQIResult,out= +nsCIDRef,in=TGuid,constref +nsIIDRef,in=TGuid,constref +long=idllong +short=idlshort +float=idlfloat +long,unsigned=idlulong +short,unsigned=idlushort +float,unsigned=idlufloat +AUTF8String,f=AUTF8String, +DOMString,f=DOMString, diff --git a/applications/idlparser/main.pas b/applications/idlparser/main.pas index a2ae7df6d..080b134ac 100644 --- a/applications/idlparser/main.pas +++ b/applications/idlparser/main.pas @@ -96,7 +96,7 @@ begin try IDLList.OwnsObjects:=true; ParseFile(IDLList, memoIDLFile.Lines); - GeneratePascalSource(IDLList,memoPascalfile.Lines,TypeSettings.ValueListEditor1.Strings,TypeSettings.cTypes.Lines, cbParamPrefix.Checked); + GeneratePascalSource(IDLList,memoPascalfile.Lines,TypeSettings.ValueListEditor1.Strings, cbParamPrefix.Checked); finally IDLList.Free; end; diff --git a/applications/idlparser/pascaltypesettings.lfm b/applications/idlparser/pascaltypesettings.lfm index a2f2fe580..fca44298f 100644 --- a/applications/idlparser/pascaltypesettings.lfm +++ b/applications/idlparser/pascaltypesettings.lfm @@ -26,10 +26,10 @@ object TypeSettings: TTypeSettings AutoFillColumns = True FixedCols = 0 FixedRows = 0 - RowCount = 3 + RowCount = 4 TabOrder = 0 Strings.Strings = ( - '--=see lazarus bug 21480 ' + 'IDL-Type=Pascal-Type' 'wstring=PWideChar' 'boolean=longbool' '' @@ -123,28 +123,6 @@ object TypeSettings: TTypeSettings ClientHeight = 277 ClientWidth = 253 TabOrder = 2 - object cTypes: TMemo - Left = 0 - Height = 225 - Top = 22 - Width = 253 - Align = alClient - Lines.Strings = ( - 'long' - 'short' - 'float' - ) - TabOrder = 0 - end - object Label3: TLabel - Left = 0 - Height = 22 - Top = 0 - Width = 253 - Align = alTop - Caption = 'List of c-types' - ParentColor = False - end object pCListBottom: TPanel Left = 0 Height = 30 @@ -152,31 +130,18 @@ object TypeSettings: TTypeSettings Width = 253 Align = alBottom BevelOuter = bvNone - ClientHeight = 30 - ClientWidth = 253 - TabOrder = 1 - object bSaveClist: TButton - Left = 151 - Height = 26 - Top = 2 - Width = 100 - Align = alRight - BorderSpacing.Around = 2 - Caption = 'Save to file' - OnClick = bSaveClistClick - TabOrder = 0 - end - object bLoadCList: TButton - Left = 2 - Height = 26 - Top = 2 - Width = 100 - Align = alLeft - BorderSpacing.Around = 2 - Caption = 'Load from file' - OnClick = bLoadCListClick - TabOrder = 1 - end + TabOrder = 0 + end + object Label1: TLabel + Left = 3 + Height = 241 + Top = 3 + Width = 247 + Align = alClient + BorderSpacing.Around = 3 + Caption = 'Each IDL-Type is transated into it''s corresponding Pascal-Type. '#10#10'There are some special cases. It could be that an idl-type has the flag ''unsigned''. You can specify how to handle this flag by adding '',unsigned'' to the IDL-typename. For example:'#10'long,unsigned=culong'#10'translated unsigned long types to the culong type from fpc''s ctypes unit.'#10#10'It is possible to specify to add ''var'',''constref'',''out'' or ''const'' when a type is passed as a variable, by adding '',var'', '',const'' etc to the Pascal-typename. For example'#10'pchar=char,var'#10'will adapt idl-type pchar parameters to ''var paramname: char''.'#10#10'In IDL it is possible to set a function parameter to ''in'',''out'' or ''inout''. To specify how to handle these you have to add '',in'','',out'' or '',inout'' to the IDL-typename. For example:'#10'nsCIDRef,in=TGuid,constref'#10'will translate nsCIDRef parameters which are marked with the ''in'' keyword to ''constref AParamName: TGuid''.'#10#10'When the Pascal-type is left empty, A parameter is translated to ''out ParamName'' with further no additions.'#10#10'When the IDL-parses has to do something special when a given IDL-type is a function result, add the '',f'' suffix to the IDL-typename. When the Pascal-typename of such a rule contains a comma (,) the parameter will be forced to be passed as a parameter, and not as a function result.' + ParentColor = False + WordWrap = True end end object OpenDialog: TOpenDialog diff --git a/applications/idlparser/pascaltypesettings.pas b/applications/idlparser/pascaltypesettings.pas index 514cd1db0..2b0948c38 100644 --- a/applications/idlparser/pascaltypesettings.pas +++ b/applications/idlparser/pascaltypesettings.pas @@ -43,13 +43,10 @@ type { TTypeSettings } TTypeSettings = class(TForm) - bLoadCList: TButton; bSaveMap: TButton; bLoadMap: TButton; - bSaveClist: TButton; - cTypes: TMemo; + Label1: TLabel; Label2: TLabel; - Label3: TLabel; OpenDialog: TOpenDialog; pMapBottom: TPanel; pCListBottom: TPanel; @@ -58,9 +55,7 @@ type SaveDialog: TSaveDialog; Splitter1: TSplitter; ValueListEditor1: TValueListEditor; - procedure bLoadCListClick(Sender: TObject); procedure bLoadMapClick(Sender: TObject); - procedure bSaveClistClick(Sender: TObject); procedure bSaveMapClick(Sender: TObject); private { private declarations } @@ -83,18 +78,6 @@ begin ValueListEditor1.Strings.LoadFromFile(OpenDialog.FileName); end; -procedure TTypeSettings.bSaveClistClick(Sender: TObject); -begin - if SaveDialog.Execute then - cTypes.Lines.SaveToFile(SaveDialog.FileName); -end; - -procedure TTypeSettings.bLoadCListClick(Sender: TObject); -begin - if OpenDialog.Execute then - cTypes.Lines.LoadFromFile(OpenDialog.FileName); -end; - procedure TTypeSettings.bSaveMapClick(Sender: TObject); begin if SaveDialog.Execute then diff --git a/applications/idlparser/readme.txt b/applications/idlparser/readme.txt index e486d56ad..11c3c3c1a 100644 --- a/applications/idlparser/readme.txt +++ b/applications/idlparser/readme.txt @@ -6,11 +6,11 @@ It could be that it can be used or extended to parse idl-files from other projects, but I never tested that. The generated Pascal-sources are as close as possible to the original idl -files. C-types are converted to their corresponding types in fpc's ctypes -unit. +files. -It is possible to map some types from their idl to Pascal name. You can also -specify which types have to be converted to their ctypes-unit equivalent. +It is possible to specify what to do with each idl-type and how to +translate them into Pascal code. These settings are passed in a separate +configuration file. An example of such a file is idltypemap.cfg. All files are licensed by the modified LGPL, as used in the Lazarus LCL. @@ -18,4 +18,4 @@ I hope this is useful for someone, Joost van der Sluis, CNOC -March 14, 2012 +March 19, 2012