wsdl function "result" part is determined now as ( in order and stops when ok ) :
  * "result" part
  * "return" part
  * "_result" part
  * "result_" part
  * "_return" part
  * "return_" part
  * the last part

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@546 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2008-09-10 01:46:45 +00:00
parent 271046c7e6
commit 7240986847
4 changed files with 74 additions and 21 deletions

View File

@@ -71,6 +71,8 @@ type
TDerivationMode = ( dmNone, dmExtension, dmRestriction );
TSequenceType = ( stElement, stAll );
TParserTypeHint = ( pthDeriveFromSoapArray );
TParserTypeHints = set of TParserTypeHint;
{ TPropInfoReference }
@@ -109,6 +111,7 @@ type
FDerivationMode : TDerivationMode;
FDerivationNode : TDOMNode;
FSequenceType : TSequenceType;
FHints : TParserTypeHints;
private
//helper routines
function ExtractElementCursor(out AAttCursor : IObjectCursor):IObjectCursor;
@@ -614,6 +617,7 @@ var
locContentChildCrs, locCrs : IObjectCursor;
locSymbol : TPasElement;
locBaseTypeLocalSpace, locBaseTypeLocalName, locBaseTypeInternalName, locFilterStr : string;
locBaseTypeLocalSpaceExpanded : string;
begin
locFilterStr := CreateQualifiedNameFilterStr(s_extension,FContext.GetXsShortNames());
locContentChildCrs := CreateChildrenCursor(FContentNode,cetRttiNode);
@@ -667,14 +671,23 @@ begin
raise EXsdParserException.CreateFmt('"%s" was expected to be a type definition.',[locSymbol.Name]);
end;
end else begin
locBaseTypeInternalName := ExtractIdentifier(locBaseTypeLocalName);
if IsReservedKeyWord(locBaseTypeInternalName) then
locBaseTypeInternalName := '_' + locBaseTypeInternalName ;
FBaseType := TPasUnresolvedTypeRef(FSymbols.CreateElement(TPasUnresolvedTypeRef,locBaseTypeInternalName,Self.Module.InterfaceSection,visDefault,'',0));
Self.Module.InterfaceSection.Declarations.Add(FBaseType);
Self.Module.InterfaceSection.Types.Add(FBaseType);
if not AnsiSameText(locBaseTypeInternalName,locBaseTypeLocalName) then
FSymbols.RegisterExternalAlias(FBaseType,locBaseTypeLocalName);
if ( FDerivationMode = dmRestriction ) and
( locBaseTypeLocalName = 'Array' ) and
( FContext.FindNameSpace(locBaseTypeLocalSpace,locBaseTypeLocalSpaceExpanded) and
( locBaseTypeLocalSpaceExpanded = s_soapEncodingNameSpace )
)
then begin
FHints := FHints + [pthDeriveFromSoapArray];
end else begin
locBaseTypeInternalName := ExtractIdentifier(locBaseTypeLocalName);
if IsReservedKeyWord(locBaseTypeInternalName) then
locBaseTypeInternalName := '_' + locBaseTypeInternalName ;
FBaseType := TPasUnresolvedTypeRef(FSymbols.CreateElement(TPasUnresolvedTypeRef,locBaseTypeInternalName,Self.Module.InterfaceSection,visDefault,'',0));
Self.Module.InterfaceSection.Declarations.Add(FBaseType);
Self.Module.InterfaceSection.Types.Add(FBaseType);
if not AnsiSameText(locBaseTypeInternalName,locBaseTypeLocalName) then
FSymbols.RegisterExternalAlias(FBaseType,locBaseTypeLocalName);
end;
end;
end;
end;
@@ -907,7 +920,9 @@ begin
internalName := Format('_%s',[internalName]);
end;
if ( FDerivationMode = dmRestriction ) and FSymbols.SameName(FBaseType,s_array) then begin
if ( pthDeriveFromSoapArray in FHints ) or
( ( FDerivationMode = dmRestriction ) and FSymbols.SameName(FBaseType,s_array) )
then begin
Result := ExtractSoapArray(ATypeName,internalName,hasInternalName);
end else begin
arrayItems := TPropInfoReferenceList.Create();

View File

@@ -557,6 +557,35 @@ function TWsdlParser.ParseOperation(
end;
procedure ParseOutputMessage();
function FindIndexOfResultArg(AArgList : TList) : PtrInt;
const RESULT_ARG_NAMES : array[0..5] of string = ( 'result', 'return', '_result', 'result_', '_return', 'return_' );
var
p, q : PtrInt;
idx_found : Boolean;
resItemName : string;
arg : TPasArgument;
begin
Result := -1;
idx_found := False;
p := Low(RESULT_ARG_NAMES);
while ( not idx_found ) and ( p <= High(RESULT_ARG_NAMES) ) do begin
resItemName := RESULT_ARG_NAMES[p];
for q := 0 to Pred(AArgList.Count) do begin
arg := TPasArgument(AArgList[q]);
if ( arg.Access = argOut ) and ( LowerCase(arg.Name) = resItemName ) then begin
idx_found := True;
Break;
end;
end;
Inc(p);
end;
if idx_found then
Result := q
else
Result := AArgList.Count - 1;
end;
var
outMsg, strBuffer : string;
outMsgNode, tmpNode : TDOMNode;
@@ -568,8 +597,9 @@ function TWsdlParser.ParseOperation(
locProcType : TPasProcedureType;
locFunc : TPasFunction;
locFuncType : TPasFunctionType;
j : Integer;
j : PtrInt;
arg_a, arg_b : TPasArgument;
resArgIndex : PtrInt;
begin
if ExtractMsgName(s_output,outMsg) then begin
outMsgNode := FindMessageNode(outMsg);
@@ -653,16 +683,19 @@ function TWsdlParser.ParseOperation(
locFunc := TPasFunction(SymbolTable.CreateElement(TPasFunction,tmpMthd.Name,AOwner,visDefault,'',0));
locFuncType := SymbolTable.CreateFunctionType('','Result',locFunc,False,'',0);
locFunc.ProcType := locFuncType;
for j := 0 to ( locProcType.Args.Count - 2 ) do begin
arg_a := TPasArgument(locProcType.Args[j]);
arg_b := TPasArgument(SymbolTable.CreateElement(TPasArgument,arg_a.Name,locFuncType,visDefault,'',0));
locFuncType.Args.Add(arg_b);
arg_b.Access := arg_a.Access;
arg_b.ArgType := arg_a.ArgType;
arg_b.ArgType.AddRef();
SymbolTable.RegisterExternalAlias(arg_b,SymbolTable.GetExternalName(arg_a));
resArgIndex := FindIndexOfResultArg(locProcType.Args);
for j := 0 to ( locProcType.Args.Count - 1 ) do begin
if ( j <> resArgIndex ) then begin
arg_a := TPasArgument(locProcType.Args[j]);
arg_b := TPasArgument(SymbolTable.CreateElement(TPasArgument,arg_a.Name,locFuncType,visDefault,'',0));
locFuncType.Args.Add(arg_b);
arg_b.Access := arg_a.Access;
arg_b.ArgType := arg_a.ArgType;
arg_b.ArgType.AddRef();
SymbolTable.RegisterExternalAlias(arg_b,SymbolTable.GetExternalName(arg_a));
end;
end;
j := locProcType.Args.Count - 1;
j := resArgIndex;
arg_a := TPasArgument(locProcType.Args[j]);
locFuncType.ResultEl.ResultType := arg_a.ArgType;
SymbolTable.RegisterExternalAlias(locFuncType.ResultEl,SymbolTable.GetExternalName(arg_a));

View File

@@ -76,6 +76,7 @@ const
s_soap : WideString = 'http://schemas.xmlsoap.org/wsdl/soap/';
s_soap_short_name = 'soap';
s_soapAction = 'soapAction';
s_soapEncodingNameSpace = 'http://schemas.xmlsoap.org/soap/encoding/';
s_soapInputEncoding = 'Input_EncodingStyle';
s_soapOutputEncoding = 'OutputEncodingStyle';
s_soapStyle = 'style';

View File

@@ -114,7 +114,8 @@ type
constructor Create(
ADoc : TXMLDocument;
ASymbols : TwstPasTreeContainer;
const AModuleName : string
const AModuleName : string;
const ANotifier : TOnParserMessage = nil
);
end;
@@ -568,12 +569,15 @@ end;
constructor TXsdParser.Create(
ADoc : TXMLDocument;
ASymbols : TwstPasTreeContainer;
const AModuleName : string
const AModuleName : string;
const ANotifier : TOnParserMessage
);
var
locName : string;
begin
inherited Create(ADoc,ADoc.DocumentElement,ASymbols,nil);
if Assigned(ANotifier) then
FOnMessage := ANotifier;
if not IsStrEmpty(AModuleName) then begin
locName := ExtractIdentifier(AModuleName);
if not IsStrEmpty(locName) then begin