Type Hint handling in the "message" component of wsdl files ( WideString, AnsiString, UnicodeString handling )

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@768 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2009-04-06 22:25:04 +00:00
parent f9723fb328
commit 85d250cfc0
12 changed files with 263 additions and 66 deletions

View File

@ -35,10 +35,10 @@
-N"obj"
-LE"c:\program files\borland\delphi7\Projects\Bpl"
-LN"c:\program files\borland\delphi7\Projects\Bpl"
-U"..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src"
-O"..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src"
-I"..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src"
-R"..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src"
-U"..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;$(DELPHI)\plate_forme\dunit\dunit-9.3.0\src"
-O"..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;$(DELPHI)\plate_forme\dunit\dunit-9.3.0\src"
-I"..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;$(DELPHI)\plate_forme\dunit\dunit-9.3.0\src"
-R"..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;$(DELPHI)\plate_forme\dunit\dunit-9.3.0\src"
-w-UNSAFE_TYPE
-w-UNSAFE_CODE
-w-UNSAFE_CAST

View File

@ -94,7 +94,7 @@ OutputDir=
UnitOutputDir=obj
PackageDLLOutputDir=
PackageDCPOutputDir=
SearchPath=..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
SearchPath=..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;$(DELPHI)\plate_forme\dunit\dunit-9.3.0\src
Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;dclOfficeXP;Rave70VCL;Rave70CLX;Jcl;JclVcl;JvCoreD7R;JvSystemD7R;JvStdCtrlsD7R;JvAppFrmD7R;JvBandsD7R;JvDBD7R;JvDlgsD7R;JvBDED7R;JvCmpD7R;JvCryptD7R;JvCtrlsD7R;JvCustomD7R;JvDockingD7R;JvDotNetCtrlsD7R;JvEDID7R;JvGlobusD7R;JvHMID7R;JvInterpreterD7R;JvJansD7R;JvManagedThreadsD7R;JvMMD7R;JvNetD7R;JvPageCompsD7R;JvPluginD7R;JvPrintPreviewD7R;JvRuntimeDesignD7R;JvTimeFrameworkD7R;JvUIBD7R;JvValidatorsD7R;JvWizardD7R;JvXPCtrlsD7R;FIBDBMidas7;daADPhysADSD7;daADPhysODBCD7;daADPhysD7;daADComID7;daADPhysDBExpD7;daADPhysASAD7;daADPhysOraclD7;daADPhysMySQLD7;daADPhysDb2D7;daADPhysMSSQLD7;daADPhysMSAccD7;daADGUIxFormsD7;daADCompD7;CRControls70;dac70;dacvcl70;odacvcl70;odac70;oraprov70;dxGDIPlusD7;cxLibraryVCLD7;dxsbD7;dxComnD7;cxEditorsVCLD7;dxThemeD7;cxDataD7;cxExtEditorsVCLD7;cxPageControlVCLD7;cxGridD7;cxSchedulerVCLD7;cxTreeListVCLD7;cxVerticalGridVCLD7;cxPivotGridD7;cxSpreadSheetVCLD7;dxDockingD7;dxNavBarD7;dxLayoutControlD7;dxLayoutControlcxEditAdaptersD7;cxWebD7;cxWebPascalScriptD7;cxWebSnapD7;cxWebTeeChartD7;dxMasterViewD7;dxmdsD7;dxdbtrD7;dxtrmdD7;dxorgcD7;dxdborD7;dxFlowChartD7;dxPSCoreD7;dxPSLnksD7;dxPScxCommonD7;dxPScxGrid6LnkD7;dxPScxPCProdD7;dxPScxPivotGridLnkD7;dxPScxScheduler2LnkD7;dxPScxSSLnkD7;dxPScxTLLnkD7;dxPScxVGridLnkD7;dxPSTeeChartD7;dxPSdxOCLnkD7;dxPSdxDBTVLnkD7;dxPSdxFCLnkD7;dxPSdxLCLnkD7;dxPSdxMVLnkD7;dxPSdxDBOCLnkD7;dxPScxExtCommonD7;dxPsPrVwAdvD7;dxBarExtItemsD7;dxBarD7;dxPSDBTeeChartD7;cxBarEditItemD7;dxBarDBNavD7;dxBarExtDBItemsD7;dxRibbonD7;S403_r70;S403br70
Conditionals=
DebugSourceDirs=
@ -141,21 +141,22 @@ Item0=DUnit
Count=1
Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
[HistoryLists\hlSearchPath]
Count=14
Item0=..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item1=$(DELPHI)\Lib\Debug;C:\PROGRA~1\Borland\Delphi7\MyTools\JVCL\3.20\jcl\lib\d7\debug;..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item2=..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src;..\..\..\ws_helper
Item3=..\;..\..\;..\..\..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src;..\..\..\fcl-units\fcl-passrc\src
Item4=..\;..\..\;..\..\..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item5=..\;..\..\;..\..\..\;C:\Programmes\lazarus\wst\trunk\ws_helper;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item6=..\;..\..\;..\..\..\;..\..\ws_helper;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item7=..\;..\..\;..\..\..\;..\..\ws_helper\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item8=..\;..\..\;..\..\..\;..\..\ws_helper\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src;C:\Programmes\lazarus\wst\trunk\ws_helper
Item9=..\;..\..\;..\..\..\;..\..\..\ws_helper\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item10=..\;..\..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item11=..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item12=C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item13=..\
Count=15
Item0=..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;$(DELPHI)\plate_forme\dunit\dunit-9.3.0\src
Item1=..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item2=$(DELPHI)\Lib\Debug;C:\PROGRA~1\Borland\Delphi7\MyTools\JVCL\3.20\jcl\lib\d7\debug;..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;..\..\..\ws_helper;..\..\..\wst_rtti_filter;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item3=..\;..\..\;..\..\..\;..\..\..\fcl-units\fcl-passrc\src;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src;..\..\..\ws_helper
Item4=..\;..\..\;..\..\..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src;..\..\..\fcl-units\fcl-passrc\src
Item5=..\;..\..\;..\..\..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item6=..\;..\..\;..\..\..\;C:\Programmes\lazarus\wst\trunk\ws_helper;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item7=..\;..\..\;..\..\..\;..\..\ws_helper;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item8=..\;..\..\;..\..\..\;..\..\ws_helper\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item9=..\;..\..\;..\..\..\;..\..\ws_helper\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src;C:\Programmes\lazarus\wst\trunk\ws_helper
Item10=..\;..\..\;..\..\..\;..\..\..\ws_helper\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item11=..\;..\..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item12=..\;C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item13=C:\Program Files\Borland\Delphi7\plate_forme\dunit\dunit-9.3.0\src
Item14=..\
[HistoryLists\hlUnitOutputDirectory]
Count=1
Item0=obj

View File

@ -0,0 +1,46 @@
<?xml version="1.0"?>
<definitions name="uri:echo-service"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="uri:echo-service"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="uri:echo-service"
xmlns:wst="urn:wst_base">
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="uri:echo-service"
targetNamespace="uri:echo-service"/>
</types>
<message name="EchoWideString">
<part name="AValue" type="xsd:string" wst:TypeHint="WideString"/>
</message>
<message name="EchoWideStringResponse">
<part name="result" type="xsd:string" wst:TypeHint="WideString"/>
</message>
<portType name="IEchoService">
<document>
<GUID value="{FCD0F68F-3023-46C6-AD09-1DDA4A2989EB}"/>
</document>
<operation name="EchoWideString">
<input message="tns:EchoWideString"/>
<output message="tns:EchoWideStringResponse"/>
</operation>
</portType>
<binding name="IEchoServiceBinding" type="tns:IEchoService">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="EchoWideString">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="uri:echo-service"/>
</input>
<output>
<soap:body use="literal" namespace="uri:echo-service"/>
</output>
</operation>
</binding>
<service name="IEchoService">
<port name="IEchoServicePort" binding="tns:IEchoServiceBinding">
<soap:address location=""/>
</port>
</service>
</definitions>

View File

@ -20,7 +20,7 @@ uses
{$ELSE}
TestFrameWork, xmldom, wst_delphi_xml,
{$ENDIF}
pastree, pascal_parser_intf, xsd_generator;
pastree, pascal_parser_intf, xsd_generator, wsdl_generator;
type
@ -56,6 +56,16 @@ type
function CreateGenerator(const ADoc : TXMLDocument) : IXsdGenerator;override;
end;
{ TTest_WsdlGenerator }
TTest_WsdlGenerator = class(TTestCase)
protected
function CreateGenerator(const ADoc : TXMLDocument) : IGenerator;
function LoadXmlFromFilesList(const AFileName : string) : TXMLDocument;
published
procedure message_parts_type_hint();
end;
implementation
uses
@ -517,7 +527,7 @@ begin
locDoc := CreateDoc();
g := CreateGenerator(locDoc);
g.Execute(tr,mdl.Name);
WriteXMLFile(locDoc,'.\class_unicodestring_property.xsd');
//WriteXMLFile(locDoc,'.\class_unicodestring_property.xsd');
locExistDoc := LoadXmlFromFilesList('class_unicodestring_property.xsd');
Check(CompareNodes(locExistDoc.DocumentElement,locDoc.DocumentElement),'generated document differs from the existent one.');
finally
@ -899,7 +909,7 @@ begin
locDoc := CreateDoc();
g := CreateGenerator(locDoc);
g.Execute(tr,mdl.Name);
WriteXMLFile(locDoc,'.\class_ansichar_property.xsd');
//WriteXMLFile(locDoc,'.\class_ansichar_property.xsd');
locExistDoc := LoadXmlFromFilesList('class_ansichar_property.xsd');
Check(CompareNodes(locExistDoc.DocumentElement,locDoc.DocumentElement),'generated document differs from the existent one.');
finally
@ -960,7 +970,7 @@ begin
locDoc := CreateDoc();
g := CreateGenerator(locDoc);
g.Execute(tr,mdl.Name);
WriteXMLFile(locDoc,'.\class_widechar_property.xsd');
//WriteXMLFile(locDoc,'.\class_widechar_property.xsd');
locExistDoc := LoadXmlFromFilesList('class_widechar_property.xsd');
Check(CompareNodes(locExistDoc.DocumentElement,locDoc.DocumentElement),'generated document differs from the existent one.');
finally
@ -977,7 +987,82 @@ begin
Result := TXsdGenerator.Create(ADoc) as IXsdGenerator;
end;
{ TTest_WsdlGenerator }
function TTest_WsdlGenerator.CreateGenerator(const ADoc : TXMLDocument) : IGenerator;
begin
Result := TWsdlGenerator.Create(ADoc) as IGenerator;
end;
function TTest_WsdlGenerator.LoadXmlFromFilesList(const AFileName : string) : TXMLDocument;
begin
ReadXMLFile(Result,wstExpandLocalFileName(TestFilesPath + AFileName));
end;
procedure TTest_WsdlGenerator.message_parts_type_hint();
var
tr : TwstPasTreeContainer;
mdl : TPasModule;
cltyp : TPasClassType;
procedure AddMethod_EchoWideString();
var
p : TPasFunction;
pt : TPasFunctionType;
prmDef : TPasArgument;
prmTypeDef : TPasType;
begin
p := TPasFunction(tr.CreateElement(TPasFunction,'EchoWideString',cltyp,visDefault,'',0));
pt := tr.CreateFunctionType('','result',p,False,'',0);
pt.ResultEl.ResultType := tr.FindElementNS('WideString',s_xs) as TPasType;
pt.ResultEl.ResultType.AddRef();
p.ProcType := pt;
cltyp.Members.Add(p);
prmTypeDef := tr.FindElementNS('WideString',s_xs) as TPasType;
prmDef := TPasArgument(tr.CreateElement(TPasArgument,'AValue',pt,visDefault,'',0));
pt.Args.Add(prmDef);
prmDef.ArgType := prmTypeDef;
prmTypeDef.AddRef();
prmDef.Access := argConst;
end;
var
g : IGenerator;
locDoc, locExistDoc : TXMLDocument;
begin
locDoc := nil;
locExistDoc := nil;
tr := TwstPasTreeContainer.Create();
try
CreateWstInterfaceSymbolTable(tr);
mdl := TPasModule(tr.CreateElement(TPasModule,'echo_service',tr.Package,visDefault,'',0));
tr.Package.Modules.Add(mdl);
tr.RegisterExternalAlias(mdl,'uri:echo-service');
mdl.InterfaceSection := TPasSection(tr.CreateElement(TPasSection,'',mdl,visDefault,'',0));
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'IEchoService',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okInterface;
cltyp.InterfaceGUID := '{FCD0F68F-3023-46C6-AD09-1DDA4A2989EB}';
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
tr.AddBinding('IEchoServiceBinding',cltyp);
AddMethod_EchoWideString();
locDoc := CreateDoc();
g := CreateGenerator(locDoc);
g.Execute(tr,mdl.Name);
//WriteXMLFile(locDoc,wstExpandLocalFileName('echo_service.wsdl'));
locExistDoc := LoadXmlFromFilesList('echo_service.wsdl');
Check(CompareNodes(locExistDoc.DocumentElement,locDoc.DocumentElement),'generated document differs from the existent one.');
finally
ReleaseDomNode(locExistDoc);
ReleaseDomNode(locDoc);
FreeAndNil(tr);
end;
end;
initialization
RegisterTest('XSD generator',TTest_XsdGenerator.Suite);
RegisterTest('XSD-WSDL generator',TTest_XsdGenerator.Suite);
RegisterTest('XSD-WSDL generator',TTest_WsdlGenerator.Suite);
end.

View File

@ -175,6 +175,7 @@ type
procedure signature_return();
procedure xsd_not_declared_at_top_node();
procedure xsd_not_declared_at_top_node_2();
procedure message_parts_type_hint();
end;
implementation
@ -2199,6 +2200,55 @@ begin
ParseDoc('xsd_not_declared_at_top_node_2').Free();
end;
procedure TTest_WsdlParser.message_parts_type_hint();
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 ( TPasProcedure(AIntf.Members[k]).Name = AName ) then begin
Result := TPasProcedure(AIntf.Members[k]);
Break;
end;
end;
end;
var
tr : TwstPasTreeContainer;
elt : TPasElement;
intf : TPasClassType;
mth : TPasProcedure;
mthType : TPasProcedureType;
res : TPasResultElement;
arg : TPasArgument;
begin
tr := ParseDoc('echo_service');
try
elt := tr.FindElement('IEchoService');
CheckNotNull(elt,'IEchoService');
CheckIs(elt,TPasClassType);
intf := elt as TPasClassType;
CheckEquals(Ord(okInterface),Ord(intf.ObjKind));
mth := FindProc('EchoWideString',intf);
CheckNotNull(mth,'EchoWideString not found');
CheckEquals('EchoWideString',mth.Name);
mthType := mth.ProcType;
CheckIs(mthType,TPasFunctionType);
res := TPasFunctionType(mthType).ResultEl;
CheckNotNull(res, 'Result');
CheckEquals(LowerCase('WideString'), LowerCase(res.ResultType.Name),'Result');
CheckEquals(1, mthType.Args.Count, 'Parameter count');
arg := TPasArgument(mthType.Args[0]);
CheckNotNull(arg);
CheckEquals(LowerCase('AValue'), LowerCase(arg.Name));
CheckEquals(LowerCase('WideString'), LowerCase(arg.ArgType.Name),'Parameter');
finally
tr.Free();
end;
end;
function TTest_WsdlParser.LoadComplexType_Class_default_values() : TwstPasTreeContainer;
begin
Result := ParseDoc(x_complexType_class_default);

View File

@ -2,11 +2,13 @@
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="6"/>
<Version Value="7"/>
<General>
<Flags>
<LRSInOutputDirectory Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<IconPath Value=".\"/>
<TargetFileExt Value=".exe"/>
</General>
<PublishOptions>

View File

@ -2,11 +2,13 @@
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="6"/>
<Version Value="7"/>
<General>
<Flags>
<LRSInOutputDirectory Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<IconPath Value=".\"/>
<TargetFileExt Value=".exe"/>
</General>
<VersionInfo>
@ -141,6 +143,9 @@
<CompilerOptions>
<Version Value="8"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="wst_test_suite_gui"/>
</Target>
<SearchPaths>
<IncludeFiles Value="..\..\"/>
<OtherUnitFiles Value="..\..\;..\..\ws_helper\;..\..\wst_rtti_filter\;..\..\fcl-json\src\"/>
@ -169,7 +174,7 @@
</Options>
</Linking>
<Other>
<CustomOptions Value="-FE./
<CustomOptions Value="
"/>
<CompilerPath Value="$(CompPath)"/>
</Other>