forked from AdaDoom3/AdaDoom3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
neo-foundation-data_types.adb
210 lines (208 loc) · 5.93 KB
/
neo-foundation-data_types.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
package body Neo.Foundation.Data_Types
is
-----------------------------
-- Is_Low_Order_Byte_First --
-----------------------------
function Is_Low_Order_Byte_First
return Boolean
is
begin
return DOES_MACHINE_ORDER_LOW_BYTE_FIRST;
end Is_Low_Order_Byte_First;
------------------------------
-- Is_High_Order_Byte_First --
------------------------------
function Is_High_Order_Byte_First
return Boolean
is
begin
return not Is_Low_Order_Byte_First;
end Is_High_Order_Byte_First;
-----------------------------
-- To_Access_Character_1_C --
-----------------------------
function To_Access_Character_1_C(
Item : in String_1_C)
return Access_Character_1_C
is
begin
return To_Unchecked_Access_Character_1_C(Item(Item'First)'Address);
end To_Access_Character_1_C;
-----------------------------
-- To_Access_Character_2_C --
-----------------------------
function To_Access_Character_2_C(
Item : in String_2)
return Access_Character_2_C
is
begin
return To_Unchecked_Access_Character_2_C(To_String_2_C(Item)'Address);
end To_Access_Character_2_C;
--------------------------------------
-- To_Access_Constant_Character_2_C --
--------------------------------------
function To_Access_Constant_Character_2_C(
Item : in String_2_C)
return Access_Constant_Character_2_C
is
begin
return To_Unchecked_Access_Constant_Character_2_C(Item(Item'First)'Address);
end To_Access_Constant_Character_2_C;
function To_Access_Constant_Character_2_C(
Item : in String_2)
return Access_Constant_Character_2_C
is
begin
return To_Access_Constant_Character_2_C(To_C(Item));
end To_Access_Constant_Character_2_C;
function To_Access_Constant_Character_1_C(
Item : in String_1_C)
return Access_Constant_Character_1_C
is
begin
return To_Unchecked_Access_Constant_Character_1_C(Item(Item'First)'Address);
end To_Access_Constant_Character_1_C;
---------------------------
-- To_Integer_4_Signed_C --
---------------------------
function To_Integer_4_Signed_C(
Item : in String_1_C)
return Integer_4_Signed_C
is
begin
return To_Unchecked_Integer_4_Signed_C(Item(Item'First)'Address);
end To_Integer_4_Signed_C;
-------------------
-- To_String_1_C --
-------------------
function To_String_1_C(
Item : in String_1)
return String_1_C
is
begin
return To_C(Item);
end To_String_1_C;
function To_String_1_C(
Item : in String_2)
return String_1_C
is
begin
return To_C("");--To_String_1(Item));
end To_String_1_C;
-----------------
-- To_String_1 --
-----------------
function To_String_1(
Item : in String_1_C)
return String_1
is
begin
return "";
end To_String_1;
function To_String_1(
Item : in String_2)
return String_1
is
begin
return "";
end To_String_1;
-------------------
-- To_String_2_C --
-------------------
function To_String_2_C(
Item : in String_2)
return String_2_C
is
begin
return To_C(Item & Character_2'Val(0));
end To_String_2_C;
-----------------
-- To_String_2 --
-----------------
function To_String_2(
Item : in String_1_C)
return String_2
is
begin
return "";
end To_String_2;
function To_String_2(
Item : in String_2_C)
return String_2
is
begin
return "";
end To_String_2;
function To_String_2(
Item : in String_1)
return String_2
is
Result : String_2(Item'First..Item'Last) := (others => Character_2'Val(0));
begin
for I in Item'Range loop
Result(I) := Character_2'Val(Character_1'Pos(Item(I)));
end loop;
return Result;
end To_String_2;
function To_String_2(
Item : in Access_Constant_Character_2_C)
return String_2
is
Length : Integer_4_Signed := 0;
Pointer : Access_Constant_Character_2_C := Item;
begin
while Pointer.All /= WChar_T'Val(0) loop
Length := Length + 1;
Pointer :=
To_Unchecked_Access_Constant_Character_2_C(
To_Unchecked_Integer_4_Unsigned(Pointer) + Character_2_C'Size / 8);
end loop;
--------------
Create_Result:
--------------
declare
Result : String_2(1..Length) := (others => Character_2'Val(0));
begin
Pointer := Item;
for I in 1..Result'Length loop
Result(I) := Character_2(Pointer.All);
Pointer :=
To_Unchecked_Access_Constant_Character_2_C(
To_Unchecked_Integer_4_Unsigned(Pointer) + Character_2_C'Size / 8);
end loop;
return Result;
end Create_Result;
end To_String_2;
-------------
-- To_Bits --
-------------
-- function To_Bits(
-- Number : in Float_4_Real;
-- Exponent_Bits : in Integer_4_Positive;
-- Mantissa_Bits : in Integer_4_Positive)
-- return Integer_4_Unsigned
-- is
-- pragma Assert(
-- Exponent_Bits >= 2 and Exponent_Bits <= 8 and
-- Mantissa_Bits >= 2 and Mantissa_Bits <= 23,
-- "Parameters don't fit required specification.");
-- Maximum_Bits : Integer_4_Unsigned := Shift_Left(Shift_Left(1, Exponent_Bits - 1) - 1, Mantissa_Bits) or (Shift_Left(1, Mantissa_Bits) - 1);
-- Minimum_Bits : Integer_4_Unsigned := Shift_Left(Shift_Left(1, Exponent_Bits) - 2, Mantissa_Bits) or 1;
-- begin
end Neo.Foundation.Data_Types;