From 980f7f882d9437c73ecd8c7fc0cf6c15b97a01e5 Mon Sep 17 00:00:00 2001 From: inoussa Date: Tue, 16 Feb 2016 19:35:06 +0000 Subject: [PATCH] Fix: Hyphens(-) support in procedure/function names of the service's interface. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4509 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../files/function_composed_name.wsdl | 51 +++++++++++++++ wst/trunk/tests/test_suite/test_parsers.pas | 62 +++++++++++++++++++ wst/trunk/ws_helper/generator.pas | 9 ++- wst/trunk/ws_helper/wsdl_parser.pas | 8 ++- 4 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 wst/trunk/tests/test_suite/files/function_composed_name.wsdl diff --git a/wst/trunk/tests/test_suite/files/function_composed_name.wsdl b/wst/trunk/tests/test_suite/files/function_composed_name.wsdl new file mode 100644 index 000000000..7bbdec1f9 --- /dev/null +++ b/wst/trunk/tests/test_suite/files/function_composed_name.wsdl @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wst/trunk/tests/test_suite/test_parsers.pas b/wst/trunk/tests/test_suite/test_parsers.pas index 6923da54b..87907b4a3 100644 --- a/wst/trunk/tests/test_suite/test_parsers.pas +++ b/wst/trunk/tests/test_suite/test_parsers.pas @@ -349,6 +349,7 @@ type procedure parameter_const_default(); procedure parameter_composed_name(); procedure parameter_composed_name_function(); + procedure method_composed_name(); procedure soap_action(); end; @@ -5163,6 +5164,67 @@ begin end; end; +procedure TTest_WsdlParser.method_composed_name(); +const PROC_METHOD_NAME = 'Composed-Name-Proc'; PROC_METHOD_ID = 'Composed_Name_Proc'; + FUNC_METHOD_NAME = 'Composed-Name-Func'; FUNC_METHOD_ID = 'Composed_Name_Func'; +var + tr : TwstPasTreeContainer; + + function FindProc(const AName : string; AIntf : TPasClassType) : TPasProcedure; + var + k : Integer; + begin + Result := nil; + for k := 0 to (AIntf.Members.Count - 1) do begin + if TObject(AIntf.Members[k]).InheritsFrom(TPasProcedure) and + (tr.GetExternalName(TPasElement(AIntf.Members[k])) = AName) + then begin + Result := TPasProcedure(AIntf.Members[k]); + Break; + end; + end; + end; + +var + elt : TPasElement; + intf : TPasClassType; + mth : TPasProcedure; + mthType : TPasProcedureType; + res : TPasResultElement; + arg : TPasArgument; + i, c : Integer; +begin + tr := ParseDoc('function_composed_name'); + try + elt := tr.FindElement('TestService'); + CheckNotNull(elt,'TestService'); + CheckIs(elt,TPasClassType); + intf := elt as TPasClassType; + CheckEquals(Ord(okInterface),Ord(intf.ObjKind)); + + c := 0; + for i := 0 to (intf.Members.Count - 1) do begin + if TObject(TObject(intf.Members[i])).InheritsFrom(TPasProcedure) then + c := c+1; + end; + CheckEquals(2,c,'number of method'); + + mth := FindProc(PROC_METHOD_NAME,intf); + CheckNotNull(mth,PROC_METHOD_NAME +' not found'); + CheckEquals(PROC_METHOD_ID,mth.Name,'internal name'); + mthType := mth.ProcType; + CheckIs(mthType,TPasProcedureType); + + mth := FindProc(FUNC_METHOD_NAME,intf); + CheckNotNull(mth,FUNC_METHOD_NAME +' not found'); + CheckEquals(FUNC_METHOD_ID,mth.Name,'internal name'); + mthType := mth.ProcType; + CheckIs(mthType,TPasFunctionType); + finally + tr.Free(); + end; +end; + procedure TTest_WsdlParser.soap_action(); var tr : TwstPasTreeContainer; diff --git a/wst/trunk/ws_helper/generator.pas b/wst/trunk/ws_helper/generator.pas index d43635340..07c15678b 100644 --- a/wst/trunk/ws_helper/generator.pas +++ b/wst/trunk/ws_helper/generator.pas @@ -1480,7 +1480,9 @@ Var for k := 0 to Pred(mtds.Count) do begin if TPasElement(mtds[k]).InheritsFrom(TPasProcedure) then begin mtd := TPasProcedure(mtds[k]); - WriteLn('RegisterVerbHandler(%s,{$IFDEF FPC}@{$ENDIF}%sHandler);',[QuotedStr(mtd.Name),mtd.Name]); + WriteLn( + 'RegisterVerbHandler(%s,{$IFDEF FPC}@{$ENDIF}%sHandler);', + [QuotedStr(FSymbolTable.GetExternalName(mtd)),mtd.Name]); end; end; EndAutoIndent(); @@ -1554,7 +1556,10 @@ Var WriteLn('procedure Server_service_Register%sService();',[strBuff]); WriteLn('Begin'); IncIndent(); - WriteLn('GetServerServiceRegistry().Register(%s,T%s_ServiceBinderFactory.Create() as IItemFactory);',[QuotedStr(AIntf.Name),strBuff]); + WriteLn( + 'GetServerServiceRegistry().Register(%s,T%s_ServiceBinderFactory.Create() as IItemFactory);', + [QuotedStr(FSymbolTable.GetExternalName(AIntf)),strBuff] + ); DecIndent(); WriteLn('End;'); EndAutoIndent(); diff --git a/wst/trunk/ws_helper/wsdl_parser.pas b/wst/trunk/ws_helper/wsdl_parser.pas index c4a91f4b6..4ee387c53 100644 --- a/wst/trunk/ws_helper/wsdl_parser.pas +++ b/wst/trunk/ws_helper/wsdl_parser.pas @@ -851,6 +851,7 @@ function TWsdlParser.ParseOperation( then begin locProcType := tmpMthd.ProcType; locFunc := TPasFunction(SymbolTable.CreateElement(TPasFunction,tmpMthd.Name,AOwner,visDefault,'',0)); + SymbolTable.RegisterExternalAlias(locFunc,SymbolTable.GetExternalName(tmpMthd)); locFuncType := SymbolTable.CreateFunctionType('','Result',locFunc,False,'',0); locFunc.ProcType := locFuncType; resArgIndex := FindIndexOfResultArg(locProcType.Args); @@ -880,8 +881,13 @@ function TWsdlParser.ParseOperation( begin AMthd := nil; - tmpMthd := TPasProcedure(SymbolTable.CreateElement(TPasProcedure,AMthdName,AOwner,visDefault,'',0)); + tmpMthd := + TPasProcedure( + SymbolTable.CreateElement(TPasProcedure,ExtractIdentifier(AMthdName), + AOwner,visDefault,'',0) + ); try + SymbolTable.RegisterExternalAlias(tmpMthd,AMthdName); ParseInputMessage(); ParseOutputMessage(); except