Skip to content

Commit 88c9d17

Browse files
committed
Add support for NaN, +/-INF in SOAP float and double support.
For T310-007.
1 parent 6dfcb87 commit 88c9d17

14 files changed

+594
-53
lines changed

regtests/0325_float_nan/test.opt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!xmlada DEAD

regtests/0325_float_nan/test.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
1.10000
2+
+Inf****
3+
-Inf****
4+
NaN*****
5+
1.20000000000000
6+
+Inf*************
7+
-Inf*************
8+
NaN**************

regtests/0325_float_nan/test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from test_support import *
2+
3+
# wsdl commited to not require ada2wsdl tool
4+
# exec_cmd('ada2wsdl',
5+
# ['-q', '-f', '-I.', '-Pwsdl_nan_main',
6+
# '-a', 'http://localhost:7071', 'wsdl_nan.ads', '-o', 'wsdl_nan.wsdl'])
7+
8+
exec_cmd('wsdl2aws',
9+
['-q', '-f', '-cb', '-types', 'wsdl_nan', 'wsdl_nan.wsdl'])
10+
11+
build_and_run('wsdl_nan_main');

regtests/0325_float_nan/wsdl_nan.adb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
------------------------------------------------------------------------------
2+
-- Ada Web Server --
3+
-- --
4+
-- Copyright (C) 2020, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it --
7+
-- under terms of the GNU General Public License as published by the --
8+
-- Free Software Foundation; either version 3, or (at your option) any --
9+
-- later version. This software is distributed in the hope that it will --
10+
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+
-- General Public License for more details. --
13+
-- --
14+
-- You should have received a copy of the GNU General Public License --
15+
-- distributed with this software; see file COPYING3. If not, go --
16+
-- to http://www.gnu.org/licenses for a complete copy of the license. --
17+
------------------------------------------------------------------------------
18+
19+
package body WSDL_NaN is
20+
21+
------------
22+
-- Echo_D --
23+
------------
24+
25+
function Echo_D (V : Long_Float) return Long_Float is
26+
begin
27+
return V;
28+
end Echo_D;
29+
30+
------------
31+
-- Echo_F --
32+
------------
33+
34+
function Echo_F (V : Float) return Float is
35+
begin
36+
return V;
37+
end Echo_F;
38+
39+
end WSDL_NaN;

regtests/0325_float_nan/wsdl_nan.ads

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
------------------------------------------------------------------------------
2+
-- Ada Web Server --
3+
-- --
4+
-- Copyright (C) 2020, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it --
7+
-- under terms of the GNU General Public License as published by the --
8+
-- Free Software Foundation; either version 3, or (at your option) any --
9+
-- later version. This software is distributed in the hope that it will --
10+
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+
-- General Public License for more details. --
13+
-- --
14+
-- You should have received a copy of the GNU General Public License --
15+
-- distributed with this software; see file COPYING3. If not, go --
16+
-- to http://www.gnu.org/licenses for a complete copy of the license. --
17+
------------------------------------------------------------------------------
18+
19+
package WSDL_NaN is
20+
21+
function Echo_F (V : Float) return Float;
22+
23+
function Echo_D (V : Long_Float) return Long_Float;
24+
25+
end WSDL_NaN;

regtests/0325_float_nan/wsdl_nan.wsdl

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<wsdl:definitions name="WSDL_NaN"
3+
targetNamespace="http://soapaws/WSDL_NaN_def/"
4+
xmlns:tns="http://soapaws/WSDL_NaN_def/"
5+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
6+
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
7+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
8+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
10+
xmlns:n1="http://soapaws/Standard_pkg/">
11+
12+
<!-- Generated by AWS/Ada2WSDL v2.0
13+
on Wednesday 18 March 2020 at 18:33:05 -->
14+
15+
<wsdl:message name="Echo_F_Request">
16+
<wsdl:part name="V" type="xsd:float"/>
17+
</wsdl:message>
18+
19+
<wsdl:message name="Echo_F_Response">
20+
<wsdl:part name="Echo_F_Result" type="xsd:float"/>
21+
</wsdl:message>
22+
23+
<wsdl:message name="Echo_D_Request">
24+
<wsdl:part name="V" type="xsd:double"/>
25+
</wsdl:message>
26+
27+
<wsdl:message name="Echo_D_Response">
28+
<wsdl:part name="Echo_D_Result" type="xsd:double"/>
29+
</wsdl:message>
30+
31+
<wsdl:portType name="WSDL_NaN_PortType">
32+
<wsdl:operation name="Echo_F">
33+
<wsdl:input message="tns:Echo_F_Request"/>
34+
<wsdl:output message="tns:Echo_F_Response"/>
35+
</wsdl:operation>
36+
37+
<wsdl:operation name="Echo_D">
38+
<wsdl:input message="tns:Echo_D_Request"/>
39+
<wsdl:output message="tns:Echo_D_Response"/>
40+
</wsdl:operation>
41+
</wsdl:portType>
42+
43+
<wsdl:binding name="WSDL_NaN_Binding" type="tns:WSDL_NaN_PortType">
44+
<soap:binding style="rpc"
45+
transport="http://schemas.xmlsoap.org/soap/http"/>
46+
47+
<wsdl:operation name="Echo_F">
48+
<soap:operation soapAction="Echo_F"/>
49+
<wsdl:input>
50+
<soap:body
51+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
52+
namespace="http://soapaws/WSDL_NaN_def/"
53+
use="encoded"/>
54+
</wsdl:input>
55+
<wsdl:output>
56+
<soap:body
57+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
58+
namespace="http://soapaws/WSDL_NaN_def/"
59+
use="encoded"/>
60+
</wsdl:output>
61+
</wsdl:operation>
62+
63+
<wsdl:operation name="Echo_D">
64+
<soap:operation soapAction="Echo_D"/>
65+
<wsdl:input>
66+
<soap:body
67+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
68+
namespace="http://soapaws/WSDL_NaN_def/"
69+
use="encoded"/>
70+
</wsdl:input>
71+
<wsdl:output>
72+
<soap:body
73+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
74+
namespace="http://soapaws/WSDL_NaN_def/"
75+
use="encoded"/>
76+
</wsdl:output>
77+
</wsdl:operation>
78+
</wsdl:binding>
79+
80+
<wsdl:service name="WSDL_NaN_Service">
81+
<wsdl:port name="WSDL_NaN_Port" binding="tns:WSDL_NaN_Binding">
82+
<soap:address location="http://localhost:7871"/>
83+
</wsdl:port>
84+
</wsdl:service>
85+
</wsdl:definitions>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
------------------------------------------------------------------------------
2+
-- Ada Web Server --
3+
-- --
4+
-- Copyright (C) 2020, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it --
7+
-- under terms of the GNU General Public License as published by the --
8+
-- Free Software Foundation; either version 3, or (at your option) any --
9+
-- later version. This software is distributed in the hope that it will --
10+
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+
-- General Public License for more details. --
13+
-- --
14+
-- You should have received a copy of the GNU General Public License --
15+
-- distributed with this software; see file COPYING3. If not, go --
16+
-- to http://www.gnu.org/licenses for a complete copy of the license. --
17+
------------------------------------------------------------------------------
18+
19+
with Ada.Float_Text_IO;
20+
with Ada.Long_Float_Text_IO;
21+
with Ada.Text_IO;
22+
23+
with AWS.Config.Set;
24+
with AWS.Server;
25+
26+
with SOAP.Dispatchers.Callback;
27+
28+
with WSDL_NaN_Server;
29+
with WSDL_NaN_Service.Client;
30+
31+
procedure WSDL_NaN_Main is
32+
33+
use Ada;
34+
use AWS;
35+
36+
function Float_Infinity return Float
37+
with Import, Convention => Intrinsic, External_Name => "__builtin_inff";
38+
39+
function Long_Float_Infinity return Long_Float
40+
with Import, Convention => Intrinsic, External_Name => "__builtin_inf";
41+
42+
procedure T_Float (V : Float) is
43+
F : Float := 0.0;
44+
begin
45+
F := WSDL_NaN_Service.Client.Echo_F (V);
46+
Float_Text_IO.Put (F, Exp => 0);
47+
Text_IO.New_Line;
48+
end T_Float;
49+
50+
procedure T_Double (V : Long_Float) is
51+
F : Long_Float := 0.0;
52+
begin
53+
F := WSDL_NaN_Service.Client.Echo_D (V);
54+
Long_Float_Text_IO.Put (F, Exp => 0);
55+
Text_IO.New_Line;
56+
end T_Double;
57+
58+
WS : Server.HTTP;
59+
60+
H : WSDL_NaN_Server.Handler;
61+
62+
Conf : Config.Object := Config.Get_Current;
63+
64+
D : Long_Float;
65+
66+
begin
67+
H := SOAP.Dispatchers.Callback.Create
68+
(WSDL_NaN_Server.HTTP_CB'Access,
69+
WSDL_NaN_Server.SOAP_CB'Access,
70+
Schema => WSDL_NaN_Service.Schema);
71+
72+
Config.Set.Server_Host (Conf, "localhost");
73+
Config.Set.Server_Port (Conf, 7871);
74+
75+
Server.Start (WS, H, Conf);
76+
77+
-- Float
78+
79+
T_Float (1.1);
80+
T_Float (+Float_Infinity);
81+
T_Float (-Float_Infinity);
82+
T_Float (Float'Invalid_Value);
83+
84+
-- Long Float
85+
86+
T_Double (1.2);
87+
T_Double (+Long_Float_Infinity);
88+
T_Double (-Long_Float_Infinity);
89+
T_Double (Long_Float'Invalid_Value);
90+
91+
Server.Shutdown (WS);
92+
end WSDL_NaN_Main;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
------------------------------------------------------------------------------
2+
-- Ada Web Server --
3+
-- --
4+
-- Copyright (C) 2020, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it --
7+
-- under terms of the GNU General Public License as published by the --
8+
-- Free Software Foundation; either version 3, or (at your option) any --
9+
-- later version. This software is distributed in the hope that it will --
10+
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+
-- General Public License for more details. --
13+
-- --
14+
-- You should have received a copy of the GNU General Public License --
15+
-- distributed with this software; see file COPYING3. If not, go --
16+
-- to http://www.gnu.org/licenses for a complete copy of the license. --
17+
------------------------------------------------------------------------------
18+
19+
with "aws";
20+
21+
project WSDL_NaN_Main is
22+
for Source_Dirs use (".");
23+
for Main use ("wsdl_nan_main.adb");
24+
end WSDL_NaN_Main;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
------------------------------------------------------------------------------
2+
-- Ada Web Server --
3+
-- --
4+
-- Copyright (C) 2020, AdaCore --
5+
-- --
6+
-- This is free software; you can redistribute it and/or modify it --
7+
-- under terms of the GNU General Public License as published by the --
8+
-- Free Software Foundation; either version 3, or (at your option) any --
9+
-- later version. This software is distributed in the hope that it will --
10+
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
11+
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
12+
-- General Public License for more details. --
13+
-- --
14+
-- You should have received a copy of the GNU General Public License --
15+
-- distributed with this software; see file COPYING3. If not, go --
16+
-- to http://www.gnu.org/licenses for a complete copy of the license. --
17+
------------------------------------------------------------------------------
18+
19+
with Ada.Text_IO;
20+
21+
with AWS.MIME;
22+
with SOAP.Message.Response.Error;
23+
24+
with WSDL_NaN;
25+
with WSDL_NaN_Service.Server;
26+
27+
package body WSDL_NaN_Server is
28+
29+
use Ada;
30+
use SOAP;
31+
32+
function Echo_F_CB is
33+
new WSDL_NaN_Service.Server.Echo_F_CB (WSDL_Nan.Echo_F);
34+
function Echo_D_CB is
35+
new WSDL_NaN_Service.Server.Echo_D_CB (WSDL_Nan.Echo_D);
36+
37+
-------------
38+
-- HTTP_CB --
39+
-------------
40+
41+
function HTTP_CB (Request : Status.Data) return Response.Data is
42+
begin
43+
return Response.Build
44+
(MIME.Text_HTML, "No HTTP request should be called.");
45+
end HTTP_CB;
46+
47+
-------------
48+
-- SOAP_CB --
49+
-------------
50+
51+
function SOAP_CB
52+
(SOAPAction : String;
53+
Payload : Message.Payload.Object;
54+
Request : Status.Data)
55+
return Response.Data is
56+
begin
57+
if SOAPAction = "Echo_F" then
58+
return Echo_F_CB (SOAPAction, Payload, Request);
59+
60+
elsif SOAPAction = "Echo_D" then
61+
return Echo_D_CB (SOAPAction, Payload, Request);
62+
63+
else
64+
return Message.Response.Build
65+
(Message.Response.Error.Build
66+
(Message.Response.Error.Client,
67+
"Wrong SOAP action " & SOAPAction));
68+
end if;
69+
end SOAP_CB;
70+
71+
end WSDL_NaN_Server;

0 commit comments

Comments
 (0)