Parser's "CaseSensitive" implementation. To got the parser Case-Sensitive, provide the "-cS" argument at command line when using ws_helper.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1931 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2011-09-10 03:44:54 +00:00
parent 068d0c4144
commit e9067503ae
3 changed files with 49 additions and 12 deletions

View File

@ -30,7 +30,7 @@ Type
cloInterface, cloProxy, cloImp, cloBinder, cloWsdl, cloXsd, cloInterface, cloProxy, cloImp, cloBinder, cloWsdl, cloXsd,
cloOutPutDirRelative, cloOutPutDirAbsolute, cloHandleWrappedParameters, cloOutPutDirRelative, cloOutPutDirAbsolute, cloHandleWrappedParameters,
cloGenerateDocAsComments, cloGenerateObjectCollection, cloGenerateDocAsComments, cloGenerateObjectCollection,
cloFileRenaming, cloPrefixEnum cloFileRenaming, cloPrefixEnum, cloParserCaseSensitive
); );
TComandLineOptions = set of TComandLineOption; TComandLineOptions = set of TComandLineOption;
@ -55,7 +55,7 @@ begin
AAppOptions := []; AAppOptions := [];
c := #0; c := #0;
repeat repeat
c := GetOpt('u:pibo:a:wxydg:f:'); c := GetOpt('u:pibo:a:wxydg:f:c:');
case c of case c of
'u' : 'u' :
begin begin
@ -94,6 +94,11 @@ begin
Include(AAppOptions,cloFileRenaming); Include(AAppOptions,cloFileRenaming);
OptionsArgsMAP[cloFileRenaming] := OptArg; OptionsArgsMAP[cloFileRenaming] := OptArg;
end; end;
'c' :
begin
Include(AAppOptions,cloParserCaseSensitive);
OptionsArgsMAP[cloParserCaseSensitive] := OptArg;
end;
end; end;
until ( c = EndOfOptions ); until ( c = EndOfOptions );
Result := OptInd; Result := OptInd;

View File

@ -101,6 +101,7 @@ type
FCurrentModule: TPasModule; FCurrentModule: TPasModule;
FBindingList : TObjectList; FBindingList : TObjectList;
FProperties : TPropertyHolder; FProperties : TPropertyHolder;
FCaseSensitive : Boolean;
private private
function GetBinding(AIndex : Integer): TwstBinding; function GetBinding(AIndex : Integer): TwstBinding;
function GetBindingCount: Integer; function GetBindingCount: Integer;
@ -163,6 +164,8 @@ type
function IsInitNeed(AType: TPasType): Boolean; function IsInitNeed(AType: TPasType): Boolean;
function IsOfType(AType: TPasType; AClass: TClass): Boolean; function IsOfType(AType: TPasType; AClass: TClass): Boolean;
property CaseSensitive : Boolean read FCaseSensitive write FCaseSensitive;
end; end;
TPasNativeModule = class(TPasModule) TPasNativeModule = class(TPasModule)
@ -751,18 +754,37 @@ begin
decs := AModule.InterfaceSection.Declarations; decs := AModule.InterfaceSection.Declarations;
c := decs.Count; c := decs.Count;
if ( elkDeclaredName in ANameKinds ) then begin if ( elkDeclaredName in ANameKinds ) then begin
for i := 0 to Pred(c) do begin if FCaseSensitive then begin
if AnsiSameText(AName, GetExternalName(TPasElement(decs[i]))) then begin for i := 0 to Pred(c) do begin
Result := TPasElement(decs[i]); if AnsiSameStr(AName, GetExternalName(TPasElement(decs[i]))) then begin
Exit; Result := TPasElement(decs[i]);
Exit;
end;
end;
end else begin
for i := 0 to Pred(c) do begin
if AnsiSameText(AName, GetExternalName(TPasElement(decs[i]))) then begin
Result := TPasElement(decs[i]);
Exit;
end;
end; end;
end; end;
end; end;
if ( Result = nil ) and ( elkName in ANameKinds ) then begin if ( Result = nil ) and ( elkName in ANameKinds ) then begin
for i := 0 to Pred(c) do begin if FCaseSensitive then begin
if AnsiSameText(AName, TPasElement(decs[i]).Name) then begin for i := 0 to Pred(c) do begin
Result := TPasElement(decs[i]); if AnsiSameStr(AName, TPasElement(decs[i]).Name) then begin
Exit; Result := TPasElement(decs[i]);
Exit;
end;
end;
end else begin
for i := 0 to Pred(c) do begin
if AnsiSameText(AName, TPasElement(decs[i]).Name) then begin
Result := TPasElement(decs[i]);
Exit;
end;
end; end;
end; end;
end; end;

View File

@ -17,6 +17,9 @@ resourcestring
' -x Generate XSD file; Can be used to get xsd from pascal' + sNEW_LINE + ' -x Generate XSD file; Can be used to get xsd from pascal' + sNEW_LINE +
' -y Generate easy access interface for wrapped parameters' + sNEW_LINE + ' -y Generate easy access interface for wrapped parameters' + sNEW_LINE +
' -d Generate documentation as comment in the interface file' + sNEW_LINE + ' -d Generate documentation as comment in the interface file' + sNEW_LINE +
' -c Indicate the parser''s case sensitivity : ' + sNEW_LINE +
' S : the paser is case sensitive' + sNEW_LINE +
' I : the paser is not case sensitive' + sNEW_LINE +
' -f Specify unit(s) renaming option : oldName= NewName(;oldName= NewName)* '; ' -f Specify unit(s) renaming option : oldName= NewName(;oldName= NewName)* ';
sCOPYRIGHT = 'ws_helper, Web Service Toolkit 0.6 Copyright (c) 2006, 2007, 2008, 2009, 2010,2011 by Inoussa OUEDRAOGO'; sCOPYRIGHT = 'ws_helper, Web Service Toolkit 0.6 Copyright (c) 2006, 2007, 2008, 2009, 2010,2011 by Inoussa OUEDRAOGO';
@ -76,6 +79,10 @@ var
if ( sourceType = sftXsd ) then begin if ( sourceType = sftXsd ) then begin
AppOptions := AppOptions - [ cloProxy, cloImp, cloBinder, cloWsdl ]; AppOptions := AppOptions - [ cloProxy, cloImp, cloBinder, cloWsdl ];
end; end;
if AnsiSameText('S',Trim(GetOptionArg(cloParserCaseSensitive))) then
Include(AppOptions,cloParserCaseSensitive);
if AnsiSameText('I',Trim(GetOptionArg(cloParserCaseSensitive))) then
Exclude(AppOptions,cloParserCaseSensitive);
end; end;
function GenerateSymbolTable() : Boolean ; function GenerateSymbolTable() : Boolean ;
@ -145,6 +152,8 @@ var
begin begin
try try
WriteLn('Parsing the file : ', inFileName); WriteLn('Parsing the file : ', inFileName);
if symtable.CaseSensitive then
WriteLn('The parser is case sensitive');
case sourceType of case sourceType of
sftPascal : ParsePascalFile(); sftPascal : ParsePascalFile();
sftWSDL : ParseWsdlFile(); sftWSDL : ParseWsdlFile();
@ -356,6 +365,7 @@ begin
Error(errStr); Error(errStr);
end; end;
symtable := TwstPasTreeContainer.Create(); symtable := TwstPasTreeContainer.Create();
symtable.CaseSensitive := cloParserCaseSensitive in AppOptions;
srcMngr := CreateSourceManager(); srcMngr := CreateSourceManager();
if not GenerateSymbolTable() then begin if not GenerateSymbolTable() then begin