repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
michael-hardeman/contacts_app | Ada | 43,165 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../../License.txt
package body AdaBase.Statement.Base.SQLite is
-------------------
-- log_problem --
-------------------
procedure log_problem
(statement : SQLite_statement;
category : Log_Category;
message : String;
pull_codes : Boolean := False;
break : Boolean := False)
is
error_msg : CT.Text := CT.blank;
error_code : Driver_Codes := 0;
sqlstate : SQL_State := stateless;
begin
if pull_codes then
error_msg := CT.SUS (statement.last_driver_message);
error_code := statement.last_driver_code;
sqlstate := statement.last_sql_state;
end if;
logger_access.all.log_problem
(driver => statement.dialect,
category => category,
message => CT.SUS (message),
error_msg => error_msg,
error_code => error_code,
sqlstate => sqlstate,
break => break);
end log_problem;
--------------------
-- column_count --
--------------------
overriding
function column_count (Stmt : SQLite_statement) return Natural is
begin
return Stmt.num_columns;
end column_count;
-------------------
-- column_name --
-------------------
overriding
function column_name (Stmt : SQLite_statement; index : Positive)
return String
is
maxlen : constant Natural := Natural (Stmt.column_info.Length);
begin
if index > maxlen then
raise INVALID_COLUMN_INDEX with "Max index is" & maxlen'Img &
" but" & index'Img & " attempted";
end if;
return CT.USS (Stmt.column_info.Element (Index => index).field_name);
end column_name;
--------------------
-- column_table --
--------------------
overriding
function column_table (Stmt : SQLite_statement; index : Positive)
return String
is
maxlen : constant Natural := Natural (Stmt.column_info.Length);
begin
if index > maxlen then
raise INVALID_COLUMN_INDEX with "Max index is" & maxlen'Img &
" but" & index'Img & " attempted";
end if;
return CT.USS (Stmt.column_info.Element (Index => index).table);
end column_table;
------------------
-- initialize --
------------------
overriding
procedure initialize (Object : in out SQLite_statement)
is
use type ACS.SQLite_Connection_Access;
conn : ACS.SQLite_Connection_Access renames Object.sqlite_conn;
logcat : Log_Category;
begin
if conn = null then
return;
end if;
logger_access := Object.log_handler;
Object.dialect := driver_sqlite;
Object.connection := ACB.Base_Connection_Access (conn);
case Object.type_of_statement is
when direct_statement =>
Object.sql_final := new String'(CT.trim_sql
(Object.initial_sql.all));
logcat := statement_execution;
when prepared_statement =>
Object.sql_final := new String'(Object.transform_sql
(Object.initial_sql.all));
logcat := statement_preparation;
end case;
if conn.prepare_statement (stmt => Object.stmt_handle,
sql => Object.sql_final.all)
then
Object.successful_execution := True;
Object.log_nominal (category => logcat,
message => Object.sql_final.all);
else
Object.log_problem
(category => statement_preparation,
message => "Failed to parse SQL query: '" &
Object.sql_final.all & "'",
pull_codes => True);
return;
end if;
if Object.type_of_statement = prepared_statement then
-- Check that we have as many markers as expected
declare
params : Natural := conn.prep_markers_found (Object.stmt_handle);
errmsg : String := "marker mismatch," &
Object.realmccoy.Length'Img & " expected but" &
params'Img & " found by SQLite";
begin
if params /= Natural (Object.realmccoy.Length) then
Object.log_problem
(category => statement_preparation,
message => errmsg);
return;
end if;
end;
else
if not Object.private_execute then
Object.log_problem
(category => statement_preparation,
message => "Failed to execute a direct SQL query");
return;
end if;
end if;
Object.scan_column_information;
exception
when HELL : others =>
Object.log_problem
(category => statement_preparation,
message => ACS.EX.Exception_Message (HELL));
end initialize;
-------------------------------
-- scan_column_information --
-------------------------------
procedure scan_column_information (Stmt : out SQLite_statement)
is
function fn (raw : String) return CT.Text;
function sn (raw : String) return String;
function fn (raw : String) return CT.Text is
begin
case Stmt.con_case_mode is
when upper_case =>
return CT.SUS (ACH.To_Upper (raw));
when lower_case =>
return CT.SUS (ACH.To_Lower (raw));
when natural_case =>
return CT.SUS (raw);
end case;
end fn;
function sn (raw : String) return String is
begin
case Stmt.con_case_mode is
when upper_case =>
return ACH.To_Upper (raw);
when lower_case =>
return ACH.To_Lower (raw);
when natural_case =>
return raw;
end case;
end sn;
conn : ACS.SQLite_Connection_Access renames Stmt.sqlite_conn;
begin
Stmt.num_columns := conn.fields_in_result (Stmt.stmt_handle);
for index in Natural range 0 .. Stmt.num_columns - 1 loop
declare
info : column_info;
brec : bindrec;
name : String := conn.field_name (Stmt.stmt_handle, index);
tname : String := conn.field_true_name (Stmt.stmt_handle, index);
table : String := conn.field_table (Stmt.stmt_handle, index);
dbase : String := conn.field_database (Stmt.stmt_handle, index);
begin
brec.v00 := False; -- placeholder
info.field_name := fn (name);
info.table := fn (table);
conn.get_field_meta_data (stmt => Stmt.stmt_handle,
database => dbase,
table => table,
column => tname,
data_type => info.sqlite_type,
nullable => info.null_possible);
case info.sqlite_type is
when BND.SQLITE_INTEGER => info.field_type := ft_byte8;
when BND.SQLITE_TEXT => info.field_type := ft_utf8;
when BND.SQLITE_BLOB => info.field_type := ft_chain;
when BND.SQLITE_FLOAT => info.field_type := ft_real18;
when BND.SQLITE_NULL => info.field_type := ft_nbyte0;
end case;
Stmt.column_info.Append (New_Item => info);
-- The following pre-populates for bind support
Stmt.crate.Append (New_Item => brec);
Stmt.headings_map.Insert (Key => sn (name),
New_Item => Stmt.crate.Last_Index);
end;
end loop;
end scan_column_information;
--------------------------
-- column_native_type --
--------------------------
overriding
function column_native_type (Stmt : SQLite_statement; index : Positive)
return field_types
is
maxlen : constant Natural := Natural (Stmt.column_info.Length);
begin
if index > maxlen then
raise INVALID_COLUMN_INDEX with "Max index is" & maxlen'Img &
" but" & index'Img & " attempted";
end if;
return Stmt.column_info.Element (Index => index).field_type;
end column_native_type;
----------------------
-- last_insert_id --
----------------------
overriding
function last_insert_id (Stmt : SQLite_statement) return Trax_ID
is
conn : ACS.SQLite_Connection_Access renames Stmt.sqlite_conn;
begin
return conn.lastInsertID;
end last_insert_id;
----------------------
-- last_sql_state --
----------------------
overriding
function last_sql_state (Stmt : SQLite_statement) return SQL_State
is
conn : ACS.SQLite_Connection_Access renames Stmt.sqlite_conn;
begin
return conn.SqlState;
end last_sql_state;
------------------------
-- last_driver_code --
------------------------
overriding
function last_driver_code (Stmt : SQLite_statement) return Driver_Codes
is
conn : ACS.SQLite_Connection_Access renames Stmt.sqlite_conn;
begin
return conn.driverCode;
end last_driver_code;
---------------------------
-- last_driver_message --
---------------------------
overriding
function last_driver_message (Stmt : SQLite_statement) return String
is
conn : ACS.SQLite_Connection_Access renames Stmt.sqlite_conn;
begin
return conn.driverMessage;
end last_driver_message;
---------------------
-- rows_returned --
---------------------
overriding
function rows_returned (Stmt : SQLite_statement) return Affected_Rows is
begin
-- Not supported by SQLite
return 0;
end rows_returned;
--------------------
-- discard_rest --
--------------------
overriding
procedure discard_rest (Stmt : out SQLite_statement)
is
conn : ACS.SQLite_Connection_Access renames Stmt.sqlite_conn;
begin
Stmt.rows_leftover := (Stmt.step_result = data_pulled);
conn.reset_prep_stmt (stmt => Stmt.stmt_handle);
Stmt.step_result := unset;
end discard_rest;
-----------------------
-- private_execute --
-----------------------
function private_execute (Stmt : out SQLite_statement) return Boolean
is
conn : ACS.SQLite_Connection_Access renames Stmt.sqlite_conn;
begin
if conn.prep_fetch_next (Stmt.stmt_handle) then
Stmt.step_result := data_pulled;
else
Stmt.step_result := progam_complete;
Stmt.impacted := conn.rows_affected_by_execution;
end if;
return True;
exception
when ACS.STMT_FETCH_FAIL =>
Stmt.step_result := error_seen;
return False;
end private_execute;
------------------
-- execute #1 --
------------------
overriding
function execute (Stmt : out SQLite_statement) return Boolean
is
conn : ACS.SQLite_Connection_Access renames Stmt.sqlite_conn;
num_markers : constant Natural := Natural (Stmt.realmccoy.Length);
status_successful : Boolean := True;
begin
if Stmt.type_of_statement = direct_statement then
raise INVALID_FOR_DIRECT_QUERY
with "The execute command is for prepared statements only";
end if;
Stmt.successful_execution := False;
conn.reset_prep_stmt (Stmt.stmt_handle);
Stmt.reclaim_canvas;
Stmt.step_result := unset;
Stmt.rows_leftover := False;
if num_markers > 0 then
-- Check to make sure all prepared markers are bound
for sx in Natural range 1 .. num_markers loop
if not Stmt.realmccoy.Element (sx).bound then
raise STMT_PREPARATION
with "Prep Stmt column" & sx'Img & " unbound";
end if;
end loop;
-- Now bind the actual values to the markers
begin
for sx in Natural range 1 .. num_markers loop
Stmt.bind_canvas.Append (Stmt.construct_bind_slot (sx));
end loop;
Stmt.log_nominal (category => statement_execution,
message => "Exec with" & num_markers'Img &
" bound parameters");
exception
when CBS : others =>
Stmt.log_problem (category => statement_execution,
message => ACS.EX.Exception_Message (CBS));
return False;
end;
else
-- No binding required, just execute the prepared statement
Stmt.log_nominal (category => statement_execution,
message => "Exec without bound parameters");
end if;
begin
if conn.prep_fetch_next (Stmt.stmt_handle) then
Stmt.step_result := data_pulled;
else
Stmt.step_result := progam_complete;
Stmt.impacted := conn.rows_affected_by_execution;
end if;
Stmt.successful_execution := True;
exception
when ACS.STMT_FETCH_FAIL =>
Stmt.step_result := error_seen;
status_successful := False;
end;
return status_successful;
end execute;
------------------
-- execute #2 --
------------------
overriding
function execute (Stmt : out SQLite_statement; parameters : String;
delimiter : Character := '|') return Boolean
is
function parameters_given return Natural;
num_markers : constant Natural := Natural (Stmt.realmccoy.Length);
function parameters_given return Natural
is
result : Natural := 1;
begin
for x in parameters'Range loop
if parameters (x) = delimiter then
result := result + 1;
end if;
end loop;
return result;
end parameters_given;
begin
if Stmt.type_of_statement = direct_statement then
raise INVALID_FOR_DIRECT_QUERY
with "The execute command is for prepared statements only";
end if;
if num_markers /= parameters_given then
raise STMT_PREPARATION
with "Parameter number mismatch, " & num_markers'Img &
" expected, but" & parameters_given'Img & " provided.";
end if;
declare
index : Natural := 1;
arrow : Natural := parameters'First;
scans : Boolean := False;
start : Natural := 1;
stop : Natural := 0;
begin
for x in parameters'Range loop
if parameters (x) = delimiter then
if not scans then
Stmt.auto_assign (index, "");
else
Stmt.auto_assign (index, parameters (start .. stop));
scans := False;
end if;
index := index + 1;
else
stop := x;
if not scans then
start := x;
scans := True;
end if;
end if;
end loop;
if not scans then
Stmt.auto_assign (index, "");
else
Stmt.auto_assign (index, parameters (start .. stop));
end if;
end;
return Stmt.execute;
end execute;
------------------
-- fetch_next --
------------------
overriding
function fetch_next (Stmt : out SQLite_statement) return ARS.Datarow
is
conn : ACS.SQLite_Connection_Access renames Stmt.sqlite_conn;
begin
if Stmt.step_result /= data_pulled then
return ARS.Empty_Datarow;
end if;
declare
maxlen : constant Natural := Natural (Stmt.column_info.Length);
result : ARS.Datarow;
begin
for F in 1 .. maxlen loop
declare
colinfo : column_info renames Stmt.column_info.Element (F);
field : ARF.Std_Field;
dvariant : ARF.Variant;
scol : constant Natural := F - 1;
last_one : constant Boolean := (F = maxlen);
heading : constant String := CT.USS (colinfo.field_name);
isnull : constant Boolean :=
conn.field_is_null (Stmt.stmt_handle, scol);
begin
if isnull then
field := ARF.spawn_null_field (colinfo.field_type);
else
case colinfo.field_type is
when ft_nbyte0 =>
-- This should never occur though
dvariant := (datatype => ft_nbyte0, v00 => False);
when ft_byte8 =>
dvariant :=
(datatype => ft_byte8,
v10 => conn.retrieve_integer (Stmt.stmt_handle, scol));
when ft_real18 =>
dvariant :=
(datatype => ft_real18,
v12 => conn.retrieve_double (Stmt.stmt_handle, scol));
when ft_utf8 =>
declare
datatext : AR.Textual :=
conn.retrieve_text (Stmt.stmt_handle, scol);
begin
if seems_like_bit_string (datatext) then
dvariant := (datatype => ft_bits,
v20 => datatext);
else
dvariant := (datatype => ft_utf8,
v21 => datatext);
end if;
end;
when ft_chain => null;
when others => raise INVALID_FOR_RESULT_SET
with "Impossible field type (internal bug??)";
end case;
case colinfo.field_type is
when ft_chain =>
field := ARF.spawn_field
(binob => ARC.convert
(conn.retrieve_blob
(stmt => Stmt.stmt_handle,
index => scol,
maxsz => Stmt.con_max_blob)));
when ft_nbyte0 | ft_byte8 | ft_real18 | ft_utf8 =>
field := ARF.spawn_field (data => dvariant,
null_data => isnull);
when others => null;
end case;
end if;
result.push (heading => heading,
field => field,
last_field => last_one);
end;
end loop;
begin
if conn.prep_fetch_next (Stmt.stmt_handle) then
Stmt.step_result := data_pulled;
else
Stmt.step_result := progam_complete;
end if;
exception
when ACS.STMT_FETCH_FAIL =>
Stmt.step_result := error_seen;
end;
return result;
end;
end fetch_next;
------------------
-- fetch_bound --
------------------
overriding
function fetch_bound (Stmt : out SQLite_statement) return Boolean
is
conn : ACS.SQLite_Connection_Access renames Stmt.sqlite_conn;
begin
if Stmt.step_result /= data_pulled then
return False;
end if;
declare
maxlen : constant Natural := Stmt.num_columns;
begin
for F in 1 .. maxlen loop
declare
dossier : bindrec renames Stmt.crate.Element (F);
colinfo : column_info renames Stmt.column_info.Element (F);
Tout : constant field_types := dossier.output_type;
Tnative : constant field_types := colinfo.field_type;
dvariant : ARF.Variant;
scol : constant Natural := F - 1;
begin
if not dossier.bound then
goto continue;
end if;
case Tnative is
when ft_byte8 =>
dvariant :=
(datatype => ft_byte8,
v10 => conn.retrieve_integer (Stmt.stmt_handle, scol));
when ft_real18 =>
dvariant :=
(datatype => ft_real18,
v12 => conn.retrieve_double (Stmt.stmt_handle, scol));
when ft_utf8 =>
dvariant :=
(datatype => ft_utf8,
v21 => conn.retrieve_text (Stmt.stmt_handle, scol));
when ft_chain =>
declare
bin : String :=
conn.retrieve_blob
(stmt => Stmt.stmt_handle,
index => scol,
maxsz => Stmt.con_max_blob);
begin
dvariant := (datatype => ft_chain,
v17 => CT.SUS (bin));
end;
when others => raise INVALID_FOR_RESULT_SET
with "Impossible field type (internal bug??)";
end case;
if Tnative = ft_byte8 and then
(Tout = ft_nbyte0 or else
Tout = ft_nbyte1 or else
Tout = ft_nbyte2 or else
Tout = ft_nbyte3 or else
Tout = ft_nbyte4 or else
Tout = ft_nbyte8 or else
Tout = ft_byte1 or else
Tout = ft_byte2 or else
Tout = ft_byte3 or else
Tout = ft_byte4 or else
Tout = ft_byte8)
then
case Tout is
when ft_nbyte0 =>
dossier.a00.all := ARC.convert (dvariant.v10);
when ft_nbyte1 =>
dossier.a01.all := ARC.convert (dvariant.v10);
when ft_nbyte2 =>
dossier.a02.all := ARC.convert (dvariant.v10);
when ft_nbyte3 =>
dossier.a03.all := ARC.convert (dvariant.v10);
when ft_nbyte4 =>
dossier.a04.all := ARC.convert (dvariant.v10);
when ft_nbyte8 =>
dossier.a05.all := ARC.convert (dvariant.v10);
when ft_byte1 =>
dossier.a06.all := ARC.convert (dvariant.v10);
when ft_byte2 =>
dossier.a07.all := ARC.convert (dvariant.v10);
when ft_byte3 =>
dossier.a08.all := ARC.convert (dvariant.v10);
when ft_byte4 =>
dossier.a09.all := ARC.convert (dvariant.v10);
when ft_byte8 =>
dossier.a10.all := dvariant.v10;
when others => null;
end case;
elsif Tnative = ft_real18 and then
(Tout = ft_real9 or else
Tout = ft_real18)
then
if Tout = ft_real18 then
dossier.a12.all := dvariant.v12;
else
dossier.a11.all := ARC.convert (dvariant.v12);
end if;
elsif Tnative = ft_utf8 and then
(Tout = ft_textual or else
Tout = ft_widetext or else
Tout = ft_supertext or else
Tout = ft_timestamp or else
Tout = ft_enumtype or else
Tout = ft_settype or else
Tout = ft_utf8 or else
Tout = ft_bits)
then
declare
STU : String := ARC.convert (dvariant.v21);
STA : String := ARC.cvu2str (CT.USS (dvariant.v21));
begin
case Tout is
when ft_textual => dossier.a13.all := CT.SUS (STA);
when ft_widetext => dossier.a14.all := convert (STA);
when ft_supertext => dossier.a15.all := convert (STA);
when ft_timestamp => dossier.a16.all := ARC.convert (STU);
when ft_enumtype => dossier.a18.all := ARC.convert (STU);
when ft_utf8 => dossier.a21.all := STU;
when ft_settype =>
declare
FL : Natural := dossier.a19.all'Length;
items : constant Natural := CT.num_set_items (STU);
begin
if items > FL then
raise BINDING_SIZE_MISMATCH with
"native size : " & items'Img &
" greater than binding size : " & FL'Img;
end if;
dossier.a19.all := ARC.convert (STU, FL);
end;
when ft_bits =>
declare
FL : Natural := dossier.a20.all'Length;
DVLEN : Natural := STA'Length;
begin
if DVLEN > FL then
raise BINDING_SIZE_MISMATCH with "native size : " &
DVLEN'Img & " greater than binding size : " &
FL'Img;
end if;
dossier.a20.all := ARC.convert (STA, FL);
end;
when others => null;
end case;
end;
elsif Tnative = ft_chain and then Tout = ft_chain then
declare
ST : String := ARC.convert (dvariant.v17);
FL : Natural := dossier.a17.all'Length;
DVLEN : Natural := ST'Length;
begin
if DVLEN > FL then
raise BINDING_SIZE_MISMATCH with "native size : " &
DVLEN'Img & " greater than binding size : " & FL'Img;
end if;
dossier.a17.all := ARC.convert (ST, FL);
end;
else
raise BINDING_TYPE_MISMATCH with "native type " &
field_types'Image (Tnative) &
" is incompatible with binding type " &
field_types'Image (Tout);
end if;
end;
<<continue>>
end loop;
end;
begin
if conn.prep_fetch_next (Stmt.stmt_handle) then
Stmt.step_result := data_pulled;
else
Stmt.step_result := progam_complete;
end if;
exception
when ACS.STMT_FETCH_FAIL =>
Stmt.step_result := error_seen;
end;
return True;
end fetch_bound;
-----------------
-- fetch_all --
-----------------
overriding
function fetch_all (Stmt : out SQLite_statement) return ARS.Datarow_Set
is
subtype rack_range is Positive range 1 .. 20000;
dataset_size : Natural := 0;
arrow : rack_range := rack_range'First;
rack : ARS.Datarow_Set (rack_range);
nullset : constant ARS.Datarow_Set (1 .. 0) :=
(others => ARS.Empty_Datarow);
begin
if Stmt.step_result /= data_pulled then
return nullset;
end if;
-- With SQLite, we don't know many rows of data are fetched, ever.
-- For practical purposes, let's limit a result set to 20k rows
-- Rather than dynamically allocating rows and having to worry about
-- copying them to a fixed array, let's just allocate a 20k set and
-- return the part we need. That should be more efficient considering
-- trade-offs.
--
-- Note that this was originally intended to be a 100k row result set.
-- but gcc 5.3 is core dumping with "illegal" instruction if the
-- rack_range is >= 25000. Maybe a problem with containers? But it
-- happened with a 100k array of access to datarows too!
loop
rack (arrow) := Stmt.fetch_next;
exit when rack (arrow).data_exhausted;
dataset_size := dataset_size + 1;
if arrow = rack_range'Last then
Stmt.discard_rest;
exit;
end if;
arrow := arrow + 1;
end loop;
if dataset_size = 0 then
-- nothing was fetched
return nullset;
end if;
return rack (1 .. dataset_size);
end fetch_all;
--------------
-- Adjust --
--------------
overriding
procedure Adjust (Object : in out SQLite_statement) is
begin
-- The stmt object goes through this evolution:
-- A) created in private_prepare()
-- B) copied to new object in prepare(), A) destroyed
-- C) copied to new object in program, B) destroyed
-- We don't want to take any action until C) is destroyed, so add a
-- reference counter upon each assignment. When finalize sees a
-- value of "2", it knows it is the program-level statement and then
-- it can release memory releases, but not before!
Object.assign_counter := Object.assign_counter + 1;
-- Since the finalization is looking for a specific reference
-- counter, any further assignments would fail finalization, so
-- just prohibit them outright.
if Object.assign_counter > 2 then
raise STMT_PREPARATION
with "Statement objects cannot be re-assigned.";
end if;
end Adjust;
----------------
-- finalize --
----------------
overriding
procedure finalize (Object : in out SQLite_statement)
is
use type BND.sqlite3_stmt_Access;
begin
if Object.assign_counter /= 2 then
return;
end if;
if Object.stmt_handle /= null then
if not Object.sqlite_conn.prep_finalize (Object.stmt_handle) then
Object.log_problem
(category => statement_preparation,
message => "Deallocating statement resources",
pull_codes => True);
end if;
end if;
if Object.sql_final /= null then
free_sql (Object.sql_final);
end if;
Object.reclaim_canvas;
end finalize;
---------------------------
-- construct_bind_slot --
---------------------------
function construct_bind_slot (Stmt : SQLite_statement; marker : Positive)
return sqlite_canvas
is
zone : bindrec renames Stmt.realmccoy.Element (marker);
conn : ACS.SQLite_Connection_Access renames Stmt.sqlite_conn;
vartype : constant field_types := zone.output_type;
okay : Boolean := True;
product : sqlite_canvas;
BT : BND.ICS.chars_ptr renames product.buffer_text;
BB : BND.ICS.char_array_access renames product.buffer_binary;
use type AR.NByte0_Access;
use type AR.NByte1_Access;
use type AR.NByte2_Access;
use type AR.NByte3_Access;
use type AR.NByte4_Access;
use type AR.NByte8_Access;
use type AR.Byte1_Access;
use type AR.Byte2_Access;
use type AR.Byte3_Access;
use type AR.Byte4_Access;
use type AR.Byte8_Access;
use type AR.Real9_Access;
use type AR.Real18_Access;
use type AR.Str1_Access;
use type AR.Str2_Access;
use type AR.Str4_Access;
use type AR.Time_Access;
use type AR.Enum_Access;
use type AR.Chain_Access;
use type AR.Settype_Access;
use type AR.Bits_Access;
use type AR.S_UTF8_Access;
use type AR.Geometry_Access;
begin
if zone.null_data then
if not conn.marker_is_null (Stmt.stmt_handle, marker) then
raise STMT_EXECUTION
with "failed to bind NULL marker" & marker'Img;
end if;
else
case vartype is
when ft_nbyte0 | ft_nbyte1 | ft_nbyte2 | ft_nbyte3 | ft_nbyte4 |
ft_nbyte8 | ft_byte1 | ft_byte2 | ft_byte3 | ft_byte4 |
ft_byte8 =>
declare
hold : AR.Byte8;
begin
case vartype is
when ft_nbyte0 =>
if zone.a00 = null then
hold := ARC.convert (zone.v00);
else
hold := ARC.convert (zone.a00.all);
end if;
when ft_nbyte1 =>
if zone.a01 = null then
hold := ARC.convert (zone.v01);
else
hold := ARC.convert (zone.a01.all);
end if;
when ft_nbyte2 =>
if zone.a02 = null then
hold := ARC.convert (zone.v02);
else
hold := ARC.convert (zone.a02.all);
end if;
when ft_nbyte3 =>
if zone.a03 = null then
hold := ARC.convert (zone.v03);
else
hold := ARC.convert (zone.a03.all);
end if;
when ft_nbyte4 =>
if zone.a04 = null then
hold := ARC.convert (zone.v04);
else
hold := ARC.convert (zone.a04.all);
end if;
when ft_nbyte8 =>
if zone.a05 = null then
hold := ARC.convert (zone.v05);
else
hold := ARC.convert (zone.a05.all);
end if;
when ft_byte1 =>
if zone.a06 = null then
hold := ARC.convert (zone.v06);
else
hold := ARC.convert (zone.a06.all);
end if;
when ft_byte2 =>
if zone.a07 = null then
hold := ARC.convert (zone.v07);
else
hold := ARC.convert (zone.a07.all);
end if;
when ft_byte3 =>
if zone.a08 = null then
hold := ARC.convert (zone.v08);
else
hold := ARC.convert (zone.a08.all);
end if;
when ft_byte4 =>
if zone.a09 = null then
hold := ARC.convert (zone.v09);
else
hold := ARC.convert (zone.a09.all);
end if;
when ft_byte8 =>
if zone.a10 = null then
hold := zone.v10;
else
hold := zone.a10.all;
end if;
when others => hold := 0;
end case;
okay := conn.marker_is_integer (Stmt.stmt_handle,
marker, hold);
end;
when ft_real9 | ft_real18 =>
declare
hold : AR.Real18;
begin
if vartype = ft_real18 then
if zone.a12 = null then
hold := zone.v12;
else
hold := zone.a12.all;
end if;
else
if zone.a11 = null then
hold := ARC.convert (zone.v11);
else
hold := ARC.convert (zone.a11.all);
end if;
end if;
okay := conn.marker_is_double (Stmt.stmt_handle,
marker, hold);
end;
when ft_textual =>
if zone.a13 = null then
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.v13), BT);
else
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.a13.all), BT);
end if;
when ft_widetext =>
if zone.a14 = null then
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.v14), BT);
else
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.a14.all), BT);
end if;
when ft_supertext =>
if zone.a15 = null then
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.v15), BT);
else
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.a15.all), BT);
end if;
when ft_timestamp =>
if zone.a16 = null then
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.v16), BT);
else
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.a16.all), BT);
end if;
when ft_enumtype =>
if zone.a18 = null then
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.v18), BT);
else
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.a18.all), BT);
end if;
when ft_settype =>
if zone.a19 = null then
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.v19), BT);
else
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.a19.all), BT);
end if;
when ft_chain =>
if zone.a17 = null then
okay := conn.marker_is_blob (Stmt.stmt_handle, marker,
ARC.convert (zone.v17), BB);
else
okay := conn.marker_is_blob (Stmt.stmt_handle, marker,
ARC.convert (zone.a17.all), BB);
end if;
when ft_bits =>
if zone.a20 = null then
okay := conn.marker_is_blob (Stmt.stmt_handle, marker,
ARC.convert (zone.v20), BB);
else
okay := conn.marker_is_blob (Stmt.stmt_handle, marker,
ARC.convert (zone.a20.all), BB);
end if;
when ft_utf8 =>
if zone.a21 = null then
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
ARC.convert (zone.v21), BT);
else
okay := conn.marker_is_text (Stmt.stmt_handle, marker,
zone.a21.all, BT);
end if;
when ft_geometry =>
if zone.a22 = null then
okay := conn.marker_is_text
(Stmt.stmt_handle, marker, WKB.produce_WKT (zone.v22), BT);
else
okay := conn.marker_is_text
(Stmt.stmt_handle, marker,
Spatial_Data.Well_Known_Text (zone.a22.all), BT);
end if;
end case;
if not okay then
Stmt.log_problem (category => statement_execution,
message => "failed to bind " & vartype'Img &
" type to marker " & marker'Img,
pull_codes => True,
break => True);
end if;
end if;
return product;
end construct_bind_slot;
----------------------
-- reclaim_canvas --
----------------------
procedure reclaim_canvas (Stmt : out SQLite_statement)
is
use type BND.ICS.char_array_access;
use type BND.ICS.chars_ptr;
begin
for x in Positive range 1 .. Natural (Stmt.bind_canvas.Length) loop
declare
SC : sqlite_canvas renames Stmt.bind_canvas.Element (x);
BT : BND.ICS.chars_ptr := SC.buffer_text;
BB : BND.ICS.char_array_access := SC.buffer_binary;
begin
if BT /= BND.ICS.Null_Ptr then
BND.ICS.Free (BT);
end if;
if BB /= null then
free_binary (BB);
end if;
end;
end loop;
Stmt.bind_canvas.Clear;
end reclaim_canvas;
----------------------
-- fetch_next_set --
----------------------
overriding
procedure fetch_next_set (Stmt : out SQLite_statement;
data_present : out Boolean;
data_fetched : out Boolean)
is
pragma Unreferenced (Stmt);
-- Stored precedures are not supported on SQLite
-- There's nothting that would generate multiple result sets
-- with a single query.
begin
data_fetched := False;
data_present := False;
end fetch_next_set;
------------------
-- bit_string --
------------------
function seems_like_bit_string (candidate : CT.Text) return Boolean
is
canstr : String := CT.USS (candidate);
begin
if canstr'Length > 64 then
return False;
end if;
for x in canstr'Range loop
if canstr (x) /= '0' and then canstr (x) /= '1' then
return False;
end if;
end loop;
return True;
end seems_like_bit_string;
end AdaBase.Statement.Base.SQLite;
|
skordal/cupcake | Ada | 6,558 | adb | -- The Cupcake GUI Toolkit
-- (c) Kristian Klomsten Skordal 2012 <[email protected]>
-- Report bugs and issues on <http://github.com/skordal/cupcake/issues>
-- vim:ts=3:sw=3:et:si:sta
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
package body Cupcake.Windows is
-- Creates a new window:
function New_Window (Width, Height : in Positive; Title : in String)
return Window
is
Size : constant Primitives.Dimension := (Width, Height);
begin
return New_Window (Size, Title);
end New_Window;
-- Creates a new window:
function New_Window (Size : in Primitives.Dimension; Title : in String)
return Window
is
Retval : constant Window := new Window_Record;
begin
Retval.Backend_Data := Backends.Get_Backend.New_Window (Title, Size);
Retval.ID := Backends.Get_Backend.Get_Window_ID (Retval.Backend_Data);
Retval.Size := Size;
return Retval;
end New_Window;
-- Destroys a window:
procedure Destroy (Object : not null access Window_Record) is
-- Deallocation procedure for window records:
type Window_Access is access all Window_Record;
procedure Free is new Ada.Unchecked_Deallocation (
Object => Window_Record,
Name => Window_Access);
Win : Window_Access := Window_Access (Object);
begin
Object.Set_Visible (False);
Backends.Get_Backend.Destroy_Window (Object.Backend_Data);
Free (Win);
end Destroy;
-- Sets the visibility of a window:
procedure Set_Visible (This : access Window_Record'Class;
Visible : in Boolean := True)
is
use Window_Lists;
Window_Cursor : Cursor := Visible_Window_List.Find (Item => This);
begin
if Visible and not Has_Element (Window_Cursor) then
Visible_Window_List.Append (This);
Backends.Get_Backend.Set_Window_Visibility (
This.Backend_Data, Visible);
elsif (not Visible and Has_Element (Window_Cursor))
and then Element (Window_Cursor).Close_Handler
then
Visible_Window_List.Delete (Window_Cursor);
Backends.Get_Backend.Set_Window_Visibility (This.Backend_Data,
Visible);
if Visible_Window_List.Is_Empty then
Backends.Get_Backend.Exit_Main_Loop;
end if;
end if;
end Set_Visible;
-- Gets the size of a window:
function Get_Size (This : in Window_Record'Class)
return Primitives.Dimension is
begin
return This.Size;
end Get_Size;
-- Sets the size of a window:
procedure Set_Size (This : in out Window_Record'Class;
Size : in Primitives.Dimension) is
begin
Backends.Get_Backend.Set_Window_Size (This.Backend_Data, Size);
end Set_Size;
-- Gets the background color of a window:
function Get_Background_Color (This : in Window_Record'Class)
return Colors.Color is
begin
return This.Background_Color;
end Get_Background_Color;
-- Sets the background color of a window:
procedure Set_Background_Color (This : out Window_Record'Class;
Color : in Colors.Color) is
begin
This.Background_Color := Color;
end Set_Background_Color;
-- Expose event handler:
procedure Expose_Handler (This : in Window_Record'Class) is
begin
Backends.Get_Backend.Fill_Area (This.Backend_Data, ((0, 0), This.Size),
This.Background_Color);
end Expose_Handler;
-- Resize event handler:
procedure Resize_Handler (This : in out Window_Record'Class;
New_Size : in Primitives.Dimension) is
begin
This.Size := New_Size;
end Resize_Handler;
-- Window close event handler:
function Close_Handler (This : in Window_Record'Class) return Boolean is
begin
return True;
end Close_Handler;
-- Posts an expose event to a window:
procedure Post_Expose (ID : in Backends.Window_ID_Type) is
Target : constant Window := Get_Visible_Window (ID);
begin
if Target /= null then
Target.Post_Expose;
end if;
end Post_Expose;
-- Posts an expose event to a window:
procedure Post_Expose (This : in Window_Record'Class) is
begin
if Debug_Mode then
Ada.Text_IO.Put_Line ("[Cupcake.Windows.Post_Expose] "
& "Expose received for window ID "
& Backends.Window_ID_Type'Image (This.ID));
end if;
This.Expose_Handler;
end Post_Expose;
-- Posts a resize event to a window:
procedure Post_Resize (ID : in Backends.Window_ID_Type;
Width, Height : in Natural) is
begin
Post_Resize (ID, (Width, Height));
end Post_Resize;
-- Posts a resize event to a window:
procedure Post_Resize (ID : in Backends.Window_ID_Type;
New_Size : in Primitives.Dimension)
is
use Primitives;
Target : constant Window := Get_Visible_Window (ID);
begin
if Target /= null and then Target.Size /= New_Size then
if Debug_Mode then
Ada.Text_IO.Put_Line ("[Cupcake.Windows.Post_Resize] "
& "Resize event received for window ID "
& Backends.Window_ID_Type'Image (ID));
end if;
Target.Resize_Handler (New_Size);
end if;
end Post_Resize;
-- Posts a close event to a window:
procedure Post_Close_Event (ID : in Backends.Window_ID_Type) is
Target : constant Window := Get_Visible_Window (ID);
begin
if Target /= null then
if Debug_Mode then
Ada.Text_IO.Put_Line ("[Cupcake.Windows.Post_Close_Event] "
& "Close request received for window ID "
& Backends.Window_ID_Type'Image (ID));
end if;
Target.Set_Visible (False);
end if;
end Post_Close_Event;
-- Gets a pointer to a visible window or null if no window was found:
function Get_Visible_Window (ID : in Backends.Window_ID_Type)
return Window
is
use Backends;
begin
for Win of Visible_Window_List loop
if Win.ID = ID then
return Win;
end if;
end loop;
return null;
end Get_Visible_Window;
-- Gets the backend data for a visible window or null if no window was
-- found:
function Get_Visible_Window (ID : in Backends.Window_ID_Type)
return Backends.Window_Data_Pointer is
Target : constant Window := Get_Visible_Window (ID);
begin
if Target /= null then
return Target.Backend_Data;
else
return Backends.Null_Window_Data_Pointer;
end if;
end Get_Visible_Window;
end Cupcake.Windows;
|
reznikmm/matreshka | Ada | 4,743 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Number_Text_Style_Elements;
package Matreshka.ODF_Number.Text_Style_Elements is
type Number_Text_Style_Element_Node is
new Matreshka.ODF_Number.Abstract_Number_Element_Node
and ODF.DOM.Number_Text_Style_Elements.ODF_Number_Text_Style
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Number_Text_Style_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Number_Text_Style_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Number_Text_Style_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Number_Text_Style_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Number_Text_Style_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Number.Text_Style_Elements;
|
reznikmm/matreshka | Ada | 6,795 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Internals.Utp_Elements;
with AMF.String_Collections;
with AMF.UML.Behaviors;
with AMF.Utp.Test_Logs;
with AMF.Visitors;
package AMF.Internals.Utp_Test_Logs is
type Utp_Test_Log_Proxy is
limited new AMF.Internals.Utp_Elements.Utp_Element_Proxy
and AMF.Utp.Test_Logs.Utp_Test_Log with null record;
overriding function Get_Base_Behavior
(Self : not null access constant Utp_Test_Log_Proxy)
return AMF.UML.Behaviors.UML_Behavior_Access;
-- Getter of TestLog::base_Behavior.
--
overriding procedure Set_Base_Behavior
(Self : not null access Utp_Test_Log_Proxy;
To : AMF.UML.Behaviors.UML_Behavior_Access);
-- Setter of TestLog::base_Behavior.
--
overriding function Get_Tester
(Self : not null access constant Utp_Test_Log_Proxy)
return AMF.String_Collections.Set_Of_String;
-- Getter of TestLog::tester.
--
overriding function Get_Executed_At
(Self : not null access constant Utp_Test_Log_Proxy)
return AMF.Optional_String;
-- Getter of TestLog::executedAt.
--
overriding procedure Set_Executed_At
(Self : not null access Utp_Test_Log_Proxy;
To : AMF.Optional_String);
-- Setter of TestLog::executedAt.
--
overriding function Get_Duration
(Self : not null access constant Utp_Test_Log_Proxy)
return AMF.Optional_String;
-- Getter of TestLog::duration.
--
overriding procedure Set_Duration
(Self : not null access Utp_Test_Log_Proxy;
To : AMF.Optional_String);
-- Setter of TestLog::duration.
--
overriding function Get_Verdict
(Self : not null access constant Utp_Test_Log_Proxy)
return AMF.Utp.Utp_Verdict;
-- Getter of TestLog::verdict.
--
overriding procedure Set_Verdict
(Self : not null access Utp_Test_Log_Proxy;
To : AMF.Utp.Utp_Verdict);
-- Setter of TestLog::verdict.
--
overriding function Get_Verdict_Reason
(Self : not null access constant Utp_Test_Log_Proxy)
return AMF.Optional_String;
-- Getter of TestLog::verdictReason.
--
overriding procedure Set_Verdict_Reason
(Self : not null access Utp_Test_Log_Proxy;
To : AMF.Optional_String);
-- Setter of TestLog::verdictReason.
--
overriding function Get_Sut_Version
(Self : not null access constant Utp_Test_Log_Proxy)
return AMF.Optional_String;
-- Getter of TestLog::sutVersion.
--
overriding procedure Set_Sut_Version
(Self : not null access Utp_Test_Log_Proxy;
To : AMF.Optional_String);
-- Setter of TestLog::sutVersion.
--
overriding procedure Enter_Element
(Self : not null access constant Utp_Test_Log_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Leave_Element
(Self : not null access constant Utp_Test_Log_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Visit_Element
(Self : not null access constant Utp_Test_Log_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Internals.Utp_Test_Logs;
|
VMika/DES_Ada | Ada | 2,639 | ads |
WITH P_StepHandler;
USE P_StepHandler;
with P_StructuralTypes;
use P_StructuralTypes;
package P_StepHandler.FeistelHandler is
type T_BinaryIntegerArray is array (0..15) of T_BinaryUnit (1..4);
type T_SBox is array (0..3, 0..15) of Integer;
type T_SBoxArray is array (1..8) of T_SBox;
type FeistelHandler is new T_StepHandler with private;
type Ptr_FeistelHandler is access all FeistelHandler;
--- CONSTRUCTOR ---
function Make (Handler : in out FeistelHandler) return FeistelHandler;
--- PROCEDURE ---
procedure Handle (Self : in out FeistelHandler);
function Process_Block (Self : in FeistelHandler;
Block : in out T_BinaryBlock)
return T_BinaryBlock;
procedure Feistel_Round (Self : in FeistelHandler;
Block : in out T_BinaryBlock;
Round : in Integer);
function Feistel_Function (Self : in FeistelHandler;
HalfBlock : T_BinaryHalfBlock;
SubKey : T_BinarySubKey)
return T_BinaryHalfBlock;
function Expansion (HalfBlock : T_BinaryHalfBlock)
return T_BinaryExpandedBlock;
function SBox_Substitution (Self : in FeistelHandler;
ExpandedBlock : T_BinaryExpandedBlock)
return T_BinaryHalfBlock;
function SBox_Output (Self : in FeistelHandler;
Input : T_BinaryUnit;
SBoxNumber : Integer) return T_BinaryUnit;
function Permutation (HalfBlock : T_BinaryHalfBlock)
return T_BinaryHalfBlock;
procedure FinalInversion (Block : in out T_BinaryBlock);
---- GETTER ----
function Get_SBoxArray (Self : in out FeistelHandler) return T_SBoxArray;
function Get_SBoxOutputArray (Self : in out FeistelHandler)
return T_BinaryIntegerArray;
---- SETTER ----
procedure Set_SubKeyArrayAccess (Self : in out FeistelHandler;
Ptr : in BinarySubKeyArray_Access);
procedure Set_Mode (Self : in out FeistelHandler;
Mode : Character);
PRIVATE
type FeistelHandler is new P_StepHandler.T_StepHandler with record
Ptr_SubKeyArray : BinarySubKeyArray_Access;
SBoxOutputArray : T_BinaryIntegerArray;
SBoxArray : T_SBoxArray;
Mode : Character;
end record;
end P_StepHandler.FeistelHandler;
|
reznikmm/matreshka | Ada | 4,688 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Style.Text_Underline_Mode_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Text_Underline_Mode_Attribute_Node is
begin
return Self : Style_Text_Underline_Mode_Attribute_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Text_Underline_Mode_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Text_Underline_Mode_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Text_Underline_Mode_Attribute,
Style_Text_Underline_Mode_Attribute_Node'Tag);
end Matreshka.ODF_Style.Text_Underline_Mode_Attributes;
|
Componolit/libsparkcrypto | Ada | 21,285 | adb | -------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2012, Stefan Berghofer
-- Copyright (C) 2012, secunet Security Networks AG
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- * Neither the name of the author nor the names of its contributors may be
-- used to endorse or promote products derived from this software without
-- specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with LSC.Internal.Types;
with LSC.Internal.Bignum;
with LSC.Internal.EC;
with LSC.Internal.EC_Signature;
with AUnit.Assertions; use AUnit.Assertions;
pragma Style_Checks ("-s");
pragma Warnings (Off, "formal parameter ""T"" is not referenced");
use type LSC.Internal.Bignum.Big_Int;
use type LSC.Internal.EC_Signature.Signature_Type;
package body LSC_Internal_Test_EC
is
subtype Coord_Index is Natural range 0 .. 16;
subtype Coord is LSC.Internal.Bignum.Big_Int (Coord_Index);
---------------------------------------------------------------------------
procedure Precompute_Values (P, A, B, Q : Coord;
RP, AM, BM, RQ : out Coord;
P_Inv, Q_Inv : out LSC.Internal.Types.Word32)
is
begin
LSC.Internal.Bignum.Size_Square_Mod (P, P'First, P'Last, RP, RP'First);
P_Inv := LSC.Internal.Bignum.Word_Inverse (P (P'First));
LSC.Internal.Bignum.Size_Square_Mod (Q, Q'First, Q'Last, RQ, RQ'First);
Q_Inv := LSC.Internal.Bignum.Word_Inverse (Q (Q'First));
LSC.Internal.Bignum.Mont_Mult
(AM, AM'First, AM'Last, A, A'First, RP, RP'First,
P, P'First, P_Inv);
LSC.Internal.Bignum.Mont_Mult
(BM, BM'First, BM'Last, B, B'First, RP, RP'First,
P, P'First, P_Inv);
end Precompute_Values;
---------------------------------------------------------------------------
-- 521-bit elliptic curve, see RFC 4753 / 4754
P : constant Coord := Coord'
(16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#,
16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#,
16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#,
16#FFFFFFFF#, 16#000001FF#);
A : constant Coord := Coord'
(16#FFFFFFFC#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#,
16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#,
16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#,
16#FFFFFFFF#, 16#000001FF#);
B : constant Coord := Coord'
(16#6B503F00#, 16#EF451FD4#, 16#3D2C34F1#, 16#3573DF88#, 16#3BB1BF07#,
16#1652C0BD#, 16#EC7E937B#, 16#56193951#, 16#8EF109E1#, 16#B8B48991#,
16#99B315F3#, 16#A2DA725B#, 16#B68540EE#, 16#929A21A0#, 16#8E1C9A1F#,
16#953EB961#, 16#00000051#);
Base_X : constant Coord := Coord'
(16#C2E5BD66#, 16#F97E7E31#, 16#856A429B#, 16#3348B3C1#, 16#A2FFA8DE#,
16#FE1DC127#, 16#EFE75928#, 16#A14B5E77#, 16#6B4D3DBA#, 16#F828AF60#,
16#053FB521#, 16#9C648139#, 16#2395B442#, 16#9E3ECB66#, 16#0404E9CD#,
16#858E06B7#, 16#000000C6#);
Base_Y : constant Coord := Coord'
(16#9FD16650#, 16#88BE9476#, 16#A272C240#, 16#353C7086#, 16#3FAD0761#,
16#C550B901#, 16#5EF42640#, 16#97EE7299#, 16#273E662C#, 16#17AFBD17#,
16#579B4468#, 16#98F54449#, 16#2C7D1BD9#, 16#5C8A5FB4#, 16#9A3BC004#,
16#39296A78#, 16#00000118#);
Q : constant Coord := Coord'
(16#91386409#, 16#BB6FB71E#, 16#899C47AE#, 16#3BB5C9B8#, 16#F709A5D0#,
16#7FCC0148#, 16#BF2F966B#, 16#51868783#, 16#FFFFFFFA#, 16#FFFFFFFF#,
16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#, 16#FFFFFFFF#,
16#FFFFFFFF#, 16#000001FF#);
---------------------------------------------------------------------------
-- See RFC 4753 (section 8.3) for test values
procedure Test_ECDH (T : in out Test_Cases.Test_Case'Class)
is
Priv : constant Coord := Coord'
(16#382D4A52#, 16#68C27A57#, 16#B072462F#, 16#7B2639BA#, 16#9777F595#,
16#71D937BA#, 16#C2952C67#, 16#85A30FE1#, 16#72A095AA#, 16#CE476081#,
16#57B5393D#, 16#3C61ACAB#, 16#ACCCA512#, 16#B3EF411A#, 16#89F4DABD#,
16#ADE9319A#, 16#00000037#);
Priv_Other : constant Coord := Coord'
(16#51685EB9#, 16#311F5CB1#, 16#A4A4EFFC#, 16#CCA7458A#, 16#E4C2F869#,
16#BF2A3163#, 16#3757A3BD#, 16#7D600B34#, 16#201E9C67#, 16#3F078380#,
16#0F97BCCC#, 16#E30FDC78#, 16#7CDFA16B#, 16#DD0E872E#, 16#AF43793F#,
16#BA99A847#, 16#00000145#);
Shared_Expected_X : constant Coord := Coord'
(16#19F3DDEA#, 16#E417996D#, 16#3151F2BE#, 16#15A3A8CC#, 16#0C06B3C7#,
16#78685981#, 16#AA240A34#, 16#7E73CA4B#, 16#9B04D142#, 16#E5E6B2D7#,
16#07F97894#, 16#086FA644#, 16#7C4521CB#, 16#DB8E7C78#, 16#6956BC8E#,
16#4C7D79AE#, 16#00000114#);
Shared_Expected_Y : constant Coord := Coord'
(16#9BAFFA43#, 16#8569D6C9#, 16#E0BDD1F8#, 16#E8DA1B38#, 16#0C3EB622#,
16#E5B3A8E5#, 16#EDB1E13C#, 16#3C63EA05#, 16#ADAA9FFC#, 16#5D1B5242#,
16#18D078E0#, 16#CFE59CDA#, 16#1C1674E5#, 16#17D853EF#, 16#B2947AC0#,
16#01E6B17D#, 16#000001B9#);
Pub_X, Pub_Y, Pub_Other_X, Pub_Other_Y : Coord;
Shared_X, Shared_Y, Shared_Other_X, Shared_Other_Y : Coord;
X, Y, Z : Coord;
RP, AM, BM, RQ : Coord;
P_Inv, Q_Inv : LSC.Internal.Types.Word32;
begin
Precompute_Values (P, A, B, Q, RP, AM, BM, RQ, P_Inv, Q_Inv);
-- Compute public values from secrets
LSC.Internal.EC.Point_Mult
(X1 => Base_X,
X1_First => Base_X'First,
X1_Last => Base_X'Last,
Y1 => Base_Y,
Y1_First => Base_Y'First,
Z1 => LSC.Internal.EC.One,
Z1_First => LSC.Internal.EC.One'First,
E => Priv,
E_First => Priv'First,
E_Last => Priv'Last,
X2 => X,
X2_First => X'First,
Y2 => Y,
Y2_First => Y'First,
Z2 => Z,
Z2_First => Z'First,
A => AM,
A_First => AM'First,
M => P,
M_First => P'First,
M_Inv => P_Inv);
LSC.Internal.EC.Make_Affine
(X, X'First, X'Last, Y, Y'First, Z, Z'First,
Pub_X, Pub_X'First, Pub_Y, Pub_Y'First,
RP, RP'First, P, P'First, P_Inv);
LSC.Internal.EC.Point_Mult
(X1 => Base_X,
X1_First => Base_X'First,
X1_Last => Base_X'Last,
Y1 => Base_Y,
Y1_First => Base_Y'First,
Z1 => LSC.Internal.EC.One,
Z1_First => LSC.Internal.EC.One'First,
E => Priv_Other,
E_First => Priv_Other'First,
E_Last => Priv_Other'Last,
X2 => X,
X2_First => X'First,
Y2 => Y,
Y2_First => Y'First,
Z2 => Z,
Z2_First => Z'First,
A => AM,
A_First => AM'First,
M => P,
M_First => P'First,
M_Inv => P_Inv);
LSC.Internal.EC.Make_Affine
(X, X'First, X'Last, Y, Y'First, Z, Z'First,
Pub_Other_X, Pub_Other_X'First, Pub_Other_Y, Pub_Other_Y'First,
RP, RP'First, P, P'First, P_Inv);
-- Now compute shared secret
LSC.Internal.EC.Point_Mult
(X1 => Pub_Other_X,
X1_First => Pub_Other_X'First,
X1_Last => Pub_Other_X'Last,
Y1 => Pub_Other_Y,
Y1_First => Pub_Other_Y'First,
Z1 => LSC.Internal.EC.One,
Z1_First => LSC.Internal.EC.One'First,
E => Priv,
E_First => Priv'First,
E_Last => Priv'Last,
X2 => X,
X2_First => X'First,
Y2 => Y,
Y2_First => Y'First,
Z2 => Z,
Z2_First => Z'First,
A => AM,
A_First => AM'First,
M => P,
M_First => P'First,
M_Inv => P_Inv);
LSC.Internal.EC.Make_Affine
(X, X'First, X'Last, Y, Y'First, Z, Z'First,
Shared_X, Shared_X'First, Shared_Y, Shared_Y'First,
RP, RP'First, P, P'First, P_Inv);
LSC.Internal.EC.Point_Mult
(X1 => Pub_X,
X1_First => Pub_X'First,
X1_Last => Pub_X'Last,
Y1 => Pub_Y,
Y1_First => Pub_Y'First,
Z1 => LSC.Internal.EC.One,
Z1_First => LSC.Internal.EC.One'First,
E => Priv_Other,
E_First => Priv_Other'First,
E_Last => Priv_Other'Last,
X2 => X,
X2_First => X'First,
Y2 => Y,
Y2_First => Y'First,
Z2 => Z,
Z2_First => Z'First,
A => AM,
A_First => AM'First,
M => P,
M_First => P'First,
M_Inv => P_Inv);
LSC.Internal.EC.Make_Affine
(X, X'First, X'Last, Y, Y'First, Z, Z'First,
Shared_Other_X, Shared_Other_X'First, Shared_Other_Y, Shared_Other_Y'First,
RP, RP'First, P, P'First, P_Inv);
-- Check if shared secrets are equal
Assert
(Shared_X = Shared_Other_X and then Shared_Y = Shared_Other_Y and then
Shared_X = Shared_Expected_X and then Shared_Y = Shared_Expected_Y,
"Invalid ECDH operation");
end Test_ECDH;
---------------------------------------------------------------------------
-- See RFC 4754 (section 8.3) for test values
function Test_Sign
(T : LSC.Internal.EC_Signature.Signature_Type;
Bad : Boolean)
return Boolean
is
Hash : constant Coord := Coord'
(16#A54CA49F#, 16#2A9AC94F#, 16#643CE80E#, 16#454D4423#, 16#A3FEEBBD#,
16#36BA3C23#, 16#274FC1A8#, 16#2192992A#, 16#4B55D39A#, 16#0A9EEEE6#,
16#89A97EA2#, 16#12E6FA4E#, 16#AE204131#, 16#CC417349#, 16#93617ABA#,
16#DDAF35A1#, 16#00000000#);
Priv : constant Coord := Coord'
(16#8B375FA1#, 16#C5B153B4#, 16#0C5D5481#, 16#62E95C7E#, 16#0FFAD6F0#,
16#ADF78B57#, 16#7FF9D704#, 16#7779060A#, 16#84912059#, 16#209D7DF5#,
16#34BDF8C1#, 16#13C17BFD#, 16#5112A3D8#, 16#0EAD4549#, 16#51DCAB0A#,
16#FDA34094#, 16#00000065#);
Rand : constant Coord := Coord'
(16#1B956C2F#, 16#0B1B7F0C#, 16#C3378A54#, 16#BD7382CF#, 16#42F9B4A4#,
16#825FF24F#, 16#6497B1EF#, 16#78F9DE6B#, 16#46F93737#, 16#42B8B62F#,
16#7A9B2443#, 16#96F55619#, 16#933D7340#, 16#4D7E4359#, 16#9F5A4134#,
16#C2B30541#, 16#000000C1#);
-- RFC 4754 only specifies expected results for ECDSA
Sign1_Expected : constant Coord := Coord'
(16#20552251#, 16#ACEE5443#, 16#D9362CAE#, 16#0ED7DBB8#, 16#4A927888#,
16#D93CF879#, 16#0B22C269#, 16#2F281A7E#, 16#4339B19F#, 16#B68E2E6F#,
16#8FC6AAAA#, 16#34FDE831#, 16#30539885#, 16#7DD5341D#, 16#92D0DCA5#,
16#FD3836AF#, 16#00000154#);
Sign2_Expected : constant Coord := Coord'
(16#66472660#, 16#C68D62F8#, 16#51AE01AA#, 16#9E70AAC8#, 16#9534FA50#,
16#BF2F3D23#, 16#D1CF9BCC#, 16#67101F67#, 16#2DF49753#, 16#8C10C836#,
16#96EC926C#, 16#521E87A6#, 16#03FF9CDD#, 16#05A9A1BB#, 16#90D1CEB6#,
16#05A70302#, 16#00000177#);
Inv_Priv, PubX, PubY, Sign1, Sign2, X, Y, Z, H : Coord;
Success : Boolean;
RP, AM, BM, RQ : Coord;
P_Inv, Q_Inv : LSC.Internal.Types.Word32;
begin
Precompute_Values (P, A, B, Q, RP, AM, BM, RQ, P_Inv, Q_Inv);
case T is
when LSC.Internal.EC_Signature.ECGDSA =>
LSC.Internal.EC.Invert
(Priv, Priv'First, Priv'Last, H, H'First,
RQ, RQ'First, Q, Q'First, Q_Inv);
LSC.Internal.Bignum.Mont_Mult
(Inv_Priv, Inv_Priv'First, Inv_Priv'Last,
H, H'First, LSC.Internal.EC.One, LSC.Internal.EC.One'First,
Q, Q'First, Q_Inv);
LSC.Internal.EC.Point_Mult
(X1 => Base_X,
X1_First => Base_X'First,
X1_Last => Base_X'Last,
Y1 => Base_Y,
Y1_First => Base_Y'First,
Z1 => LSC.Internal.EC.One,
Z1_First => LSC.Internal.EC.One'First,
E => Inv_Priv,
E_First => Inv_Priv'First,
E_Last => Inv_Priv'Last,
X2 => X,
X2_First => X'First,
Y2 => Y,
Y2_First => Y'First,
Z2 => Z,
Z2_First => Z'First,
A => AM,
A_First => AM'First,
M => P,
M_First => P'First,
M_Inv => P_Inv);
when LSC.Internal.EC_Signature.ECDSA =>
LSC.Internal.EC.Point_Mult
(X1 => Base_X,
X1_First => Base_X'First,
X1_Last => Base_X'Last,
Y1 => Base_Y,
Y1_First => Base_Y'First,
Z1 => LSC.Internal.EC.One,
Z1_First => LSC.Internal.EC.One'First,
E => Priv,
E_First => Priv'First,
E_Last => Priv'Last,
X2 => X,
X2_First => X'First,
Y2 => Y,
Y2_First => Y'First,
Z2 => Z,
Z2_First => Z'First,
A => AM,
A_First => AM'First,
M => P,
M_First => P'First,
M_Inv => P_Inv);
end case;
LSC.Internal.EC.Make_Affine
(X, X'First, X'Last, Y, Y'First, Z, Z'First,
PubX, PubX'First, PubY, PubY'First,
RP, RP'First, P, P'First, P_Inv);
LSC.Internal.EC_Signature.Sign
(Sign1 => Sign1,
Sign1_First => Sign1'First,
Sign1_Last => Sign1'Last,
Sign2 => Sign2,
Sign2_First => Sign2'First,
Hash => Hash,
Hash_First => Hash'First,
Rand => Rand,
Rand_First => Rand'First,
T => T,
Priv => Priv,
Priv_First => Priv'First,
BX => Base_X,
BX_First => Base_X'First,
BY => Base_Y,
BY_First => Base_Y'First,
A => AM,
A_First => AM'First,
M => P,
M_First => P'First,
M_Inv => P_Inv,
RM => RP,
RM_First => RP'First,
N => Q,
N_First => Q'First,
N_Inv => Q_Inv,
RN => RQ,
RN_First => RQ'First,
Success => Success);
-- Check if signature manipulation is detected
if Bad then
Sign1 (5) := 12345;
end if;
return
Success and then
(Bad or else T = LSC.Internal.EC_Signature.ECGDSA or else
(Sign1 = Sign1_Expected and then Sign2 = Sign2_Expected)) and then
(LSC.Internal.EC_Signature.Verify
(Sign1 => Sign1,
Sign1_First => Sign1'First,
Sign1_Last => Sign1'Last,
Sign2 => Sign2,
Sign2_First => Sign2'First,
Hash => Hash,
Hash_First => Hash'First,
T => T,
PubX => PubX,
PubX_First => PubX'First,
PubY => PubY,
PubY_First => PubY'First,
BX => Base_X,
BX_First => Base_X'First,
BY => Base_Y,
BY_First => Base_Y'First,
A => AM,
A_First => AM'First,
M => P,
M_First => P'First,
M_Inv => P_Inv,
RM => RP,
RM_First => RP'First,
N => Q,
N_First => Q'First,
N_Inv => Q_Inv,
RN => RQ,
RN_First => RQ'First) xor Bad);
end Test_Sign;
---------------------------------------------------------------------------
procedure Test_Uncompress_Point (T : in out Test_Cases.Test_Case'Class)
is
Y : Coord;
Success : Boolean;
RP, AM, BM, RQ : Coord;
P_Inv, Q_Inv : LSC.Internal.Types.Word32;
begin
Precompute_Values (P, A, B, Q, RP, AM, BM, RQ, P_Inv, Q_Inv);
LSC.Internal.EC.Uncompress_Point
(X => Base_X,
X_First => Base_X'First,
X_Last => Base_X'Last,
Even => True,
A => AM,
A_First => AM'First,
B => BM,
B_First => BM'First,
R => RP,
R_First => RP'First,
M => P,
M_First => P'First,
M_Inv => P_Inv,
Y => Y,
Y_First => Y'First,
Success => Success);
Assert (Success and then Y = Base_Y, "Invalid");
end Test_Uncompress_Point;
---------------------------------------------------------------------------
procedure Test_Bad_ECDSA_Signature (T : in out Test_Cases.Test_Case'Class)
is
begin
Assert (Test_Sign (LSC.Internal.EC_Signature.ECDSA, True), "Invalid");
end Test_Bad_ECDSA_Signature;
---------------------------------------------------------------------------
procedure Test_Good_ECDSA_Signature (T : in out Test_Cases.Test_Case'Class)
is
begin
Assert (Test_Sign (LSC.Internal.EC_Signature.ECDSA, False), "Invalid");
end Test_Good_ECDSA_Signature;
---------------------------------------------------------------------------
procedure Test_Bad_ECGDSA_Signature (T : in out Test_Cases.Test_Case'Class)
is
begin
Assert (Test_Sign (LSC.Internal.EC_Signature.ECGDSA, True), "Invalid");
end Test_Bad_ECGDSA_Signature;
---------------------------------------------------------------------------
procedure Test_Good_ECGDSA_Signature (T : in out Test_Cases.Test_Case'Class)
is
begin
Assert (Test_Sign (LSC.Internal.EC_Signature.ECGDSA, False), "Invalid");
end Test_Good_ECGDSA_Signature;
---------------------------------------------------------------------------
procedure Test_Base_Point_On_Curve (T : in out Test_Cases.Test_Case'Class)
is
RP, AM, BM, RQ : Coord;
P_Inv, Q_Inv : LSC.Internal.Types.Word32;
begin
Precompute_Values (P, A, B, Q, RP, AM, BM, RQ, P_Inv, Q_Inv);
Assert
(LSC.Internal.EC.On_Curve
(Base_X, Base_X'First, Base_X'Last, Base_Y, Base_Y'First,
AM, AM'First, BM, BM'First, RP, RP'First, P, P'First, P_Inv), "Invalid");
end Test_Base_Point_On_Curve;
---------------------------------------------------------------------------
procedure Register_Tests (T : in out Test_Case) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Test_Base_Point_On_Curve'Access, "Base point on curve");
Register_Routine (T, Test_ECDH'Access, "ECDH key agreement");
Register_Routine (T, Test_Bad_ECDSA_Signature'Access, "ECDSA signature (bad)");
Register_Routine (T, Test_Good_ECDSA_Signature'Access, "ECDSA signature (good)");
Register_Routine (T, Test_Bad_ECGDSA_Signature'Access, "ECGDSA signature (bad)");
Register_Routine (T, Test_Good_ECGDSA_Signature'Access, "ECGDSA signature (good)");
Register_Routine (T, Test_Uncompress_Point'Access, "Uncompress point");
end Register_Tests;
---------------------------------------------------------------------------
function Name (T : Test_Case) return Test_String is
begin
return Format ("EC");
end Name;
end LSC_Internal_Test_EC;
|
reznikmm/matreshka | Ada | 4,684 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
--private with Ada.Finalization;
--private with AMF.Internals.Collections.Strings;
package AMF.Real_Collections is
pragma Preelaborate;
-- type Collection_Of_Real is tagged private;
--
-- type Set_Of_Real is new Collection_Of_Real with private;
-- type Ordered_Set_Of_Real is new Collection_Of_Real with private;
-- type Bag_Of_Real is new Collection_Of_Real with private;
type Sequence_Of_Real is new Integer;
-- type Collection_Of_Real is tagged private;
--
-- type Set_Of_Real is new Collection_Of_Real with private;
-- type Ordered_Set_Of_Real is new Collection_Of_Real with private;
-- type Bag_Of_Real is new Collection_Of_Real with private;
-- type Sequence_Of_Real is new Collection_Of_Real with private;
private
-- type Collection_Of_Real is
-- new Ada.Finalization.Controlled with null record;
---- type Collection_Of_Real is new Ada.Finalization.Controlled with record
---- Collection :
---- AMF.Internals.Collections.Reals.Shared_Real_Collection_Access;
---- end record;
--
-- type Set_Of_Real is new Collection_Of_Real with null record;
-- type Ordered_Set_Of_Real is new Collection_Of_Real with null record;
-- type Bag_Of_Real is new Collection_Of_Real with null record;
-- type Sequence_Of_Real is new Collection_Of_Real with null record;
end AMF.Real_Collections;
|
sungyeon/drake | Ada | 6,449 | adb | with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
package body Ada.Containers.Access_Holders is
use type Weak_Access_Holders.Data_Access;
subtype Nonnull_Data_Access is not null Data_Access;
function Upcast is
new Unchecked_Conversion (
Nonnull_Data_Access,
System.Reference_Counting.Container);
function Downcast is
new Unchecked_Conversion (
System.Reference_Counting.Container,
Nonnull_Data_Access);
type Data_Access_Access is access all Nonnull_Data_Access;
type Container_Access is access all System.Reference_Counting.Container;
function Upcast is
new Unchecked_Conversion (Data_Access_Access, Container_Access);
procedure Free_Data (X : in out System.Reference_Counting.Data_Access);
procedure Free_Data (X : in out System.Reference_Counting.Data_Access) is
procedure Unchecked_Free is
new Unchecked_Deallocation (Data, Data_Access);
Y : Data_Access := Downcast (X);
begin
Weak_Access_Holders.Clear_Weaks (
Y.Super,
Null_Data.Super'Unrestricted_Access);
Free (Y.Item);
Unchecked_Free (Y);
X := null;
end Free_Data;
-- implementation
function Null_Holder return Holder is
begin
return (Finalization.Controlled
with Data => Null_Data'Unrestricted_Access);
end Null_Holder;
overriding function "=" (Left, Right : Holder) return Boolean is
begin
return Left.Data = Right.Data;
end "=";
function To_Holder (Source : Name) return Holder is
begin
return Result : Holder do
if Source /= Null_Data.Item then
Result.Data := new Data'((1, null), Source);
end if;
end return;
end To_Holder;
function Is_Null (Container : Holder) return Boolean is
begin
return Container.Data = Null_Data'Unrestricted_Access;
end Is_Null;
procedure Clear (Container : in out Holder) is
begin
Finalize (Container);
Container.Data := Null_Data'Unrestricted_Access;
end Clear;
function Element (Container : Holder'Class) return Name is
begin
return Constant_Reference (Holder (Container));
end Element;
procedure Replace_Element (Target : in out Holder; Source : Name) is
begin
Clear (Target);
if Source /= Null_Data.Item then
Target.Data := new Data'((1, null), Source);
end if;
end Replace_Element;
function Constant_Reference (Container : Holder) return Name is
begin
return Container.Data.Item;
end Constant_Reference;
procedure Assign (Target : in out Holder; Source : Holder) is
begin
System.Reference_Counting.Assign (
Target => Upcast (Target.Data'Unchecked_Access),
Source => Upcast (Source.Data'Unrestricted_Access),
Free => Free_Data'Access);
end Assign;
procedure Move (Target : in out Holder; Source : in out Holder) is
begin
System.Reference_Counting.Move (
Target => Upcast (Target.Data'Unchecked_Access),
Source => Upcast (Source.Data'Unchecked_Access),
Sentinel => Upcast (Null_Data'Unrestricted_Access),
Free => Free_Data'Access);
end Move;
procedure Swap (I, J : in out Holder) is
Temp : constant Data_Access := I.Data;
begin
I.Data := J.Data;
J.Data := Temp;
end Swap;
overriding procedure Adjust (Object : in out Holder) is
begin
System.Reference_Counting.Adjust (Upcast (Object.Data'Unchecked_Access));
end Adjust;
overriding procedure Finalize (Object : in out Holder) is
begin
System.Reference_Counting.Clear (
Target => Upcast (Object.Data'Unchecked_Access),
Free => Free_Data'Access);
end Finalize;
package body Weak is
function Downcast is
new Unchecked_Conversion (
Weak_Access_Holders.Data_Access,
Data_Access);
overriding function "=" (Left, Right : Weak_Holder) return Boolean is
begin
return Left.Super.Data = Right.Super.Data;
end "=";
function To_Weak_Holder (Source : Holder) return Weak_Holder is
begin
return Result : Weak_Holder :=
(Finalization.Controlled
with Super => (
Data => Source.Data.Super'Unchecked_Access,
Previous => <>,
Next => <>))
do
Adjust (Result);
end return;
end To_Weak_Holder;
function Null_Weak_Holder return Weak_Holder is
begin
return (Finalization.Controlled with others => <>);
end Null_Weak_Holder;
function To_Holder (Source : Weak_Holder) return Holder is
begin
return Result : Holder do
if not Is_Null (Source) then
Result.Data := Downcast (Source.Super.Data);
Adjust (Result);
end if;
end return;
end To_Holder;
function Is_Null (Container : Weak_Holder) return Boolean is
begin
return Container.Super.Data = Null_Data.Super'Unrestricted_Access;
end Is_Null;
procedure Clear (Container : in out Weak_Holder) is
begin
Finalize (Container);
Initialize (Container);
end Clear;
procedure Assign (Target : in out Weak_Holder; Source : Holder) is
begin
Clear (Target);
Target.Super.Data := Source.Data.Super'Unchecked_Access;
Adjust (Target);
end Assign;
procedure Assign (Target : in out Holder; Source : Weak_Holder) is
begin
Clear (Target);
Target.Data := Downcast (Source.Super.Data);
Adjust (Target);
end Assign;
overriding procedure Initialize (Object : in out Weak_Holder) is
begin
Object.Super.Data := Null_Data.Super'Unrestricted_Access;
Object.Super.Previous := null;
Object.Super.Next := null;
end Initialize;
overriding procedure Adjust (Object : in out Weak_Holder) is
begin
if not Is_Null (Object) then
Weak_Access_Holders.Add_Weak (Object.Super'Unchecked_Access);
end if;
end Adjust;
overriding procedure Finalize (Object : in out Weak_Holder) is
begin
if not Is_Null (Object) then
Weak_Access_Holders.Remove_Weak (Object.Super'Unchecked_Access);
end if;
end Finalize;
end Weak;
end Ada.Containers.Access_Holders;
|
SSOCsoft/FSAM | Ada | 1,856 | adb | Pragma Ada_2012;
Pragma Assertion_Policy( Check );
Pragma Restrictions( No_Implementation_Aspect_Specifications );
Pragma Restrictions( No_Implementation_Attributes );
Pragma Restrictions( No_Implementation_Pragmas );
Package Body FITS.Utils with SPARK_Mode => On is
Function Left_Trim( S : String; Ch : Character:= Space ) return String is
(if S'Length not in Positive then ""
elsif S(S'First) /= Ch then S
else Left_Trim( S(Positive'Succ(S'First)..S'Last), Ch )
);
Function Right_Trim( S : String; Ch : Character:= Space ) return String is
(if S'Length not in Positive then ""
elsif S(S'Last) /= Ch then S
else Right_Trim( S(S'First..Positive'Pred(S'Last)), Ch )
);
Function Trim( S : String; Ch : Character:= Space ) return String is
( Left_Trim( Right_Trim(S, Ch), Ch ) );
Function Index( S : String; Ch : Character ) return Natural is
Begin
Return Result : Natural := 0 do
Search:
For Index in S'Range loop
if S(Index) = Ch then
Result:= Index;
Exit Search;
End If;
End Loop Search;
End return;
End Index;
Function Count( S : String; Ch : Character ) return Natural is
Begin
Return Result : Natural := Natural'First do
Scan:
For C of S loop
if C = Ch then
Result:= Natural'Succ( Result );
End If;
End Loop Scan;
End return;
End Count;
Function Do_Map( S : String ) return String is
Begin
Return Result : String := S do
For I in Result'Range loop
Result(I):= Map( Result(I) );
end loop;
End return;
End Do_Map;
End FITS.Utils;
|
godunko/adawebpack | Ada | 5,557 | adb | ------------------------------------------------------------------------------
-- --
-- AdaWebPack --
-- --
------------------------------------------------------------------------------
-- Copyright © 2020, Vadim Godunko --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body WASM.Objects is
use type Interfaces.Unsigned_32;
procedure Seize (Identifier : Object_Identifier)
with Import => True,
Convention => C,
Link_Name => "__adawebpack__wasm__object_seize";
procedure Release (Identifier : Object_Identifier)
with Import => True,
Convention => C,
Link_Name => "__adawebpack__wasm__object_release";
procedure Unreference (Self : in out Shared_Data_Access);
-- Decrement reference counter and release object when reference counter
-- is zero. Parameter sets to null on exit.
------------
-- Adjust --
------------
overriding procedure Adjust (Self : in out Object_Reference) is
begin
if Self.Shared /= null then
Self.Shared.Counter := Self.Shared.Counter + 1;
end if;
end Adjust;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Self : in out Object_Reference) is
begin
Unreference (Self.Shared);
end Finalize;
----------------
-- Identifier --
----------------
function Identifier
(Self : Object_Reference'Class) return Object_Identifier is
begin
if Self.Shared = null then
return Null_Object_Identifier;
else
return Self.Shared.Identifier;
end if;
end Identifier;
-----------------
-- Instantiate --
-----------------
function Instantiate
(Identifier : Object_Identifier) return Object_Reference is
begin
if Identifier = Null_Object_Identifier then
return (Ada.Finalization.Controlled with Shared => null);
else
Seize (Identifier);
return
(Ada.Finalization.Controlled
with Shared =>
new Shared_Data'(Counter => <>, Identifier => Identifier));
end if;
end Instantiate;
-------------
-- Is_Null --
-------------
function Is_Null (Self : Object_Reference'Class) return Boolean is
begin
return Self.Identifier = Null_Object_Identifier;
end Is_Null;
--------------
-- Set_Null --
--------------
procedure Set_Null (Self : in out Object_Reference'Class) is
begin
Unreference (Self.Shared);
end Set_Null;
-----------------
-- Unreference --
-----------------
procedure Unreference (Self : in out Shared_Data_Access) is
procedure Free is
new Ada.Unchecked_Deallocation (Shared_Data, Shared_Data_Access);
begin
if Self /= null then
Self.Counter := Self.Counter - 1;
if Self.Counter = 0 then
Release (Self.Identifier);
Free (Self);
else
Self := null;
end if;
end if;
end Unreference;
end WASM.Objects;
|
reznikmm/matreshka | Ada | 3,609 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.Utp.Coding_Rules.Hash is
new AMF.Elements.Generic_Hash (Utp_Coding_Rule, Utp_Coding_Rule_Access);
|
reznikmm/matreshka | Ada | 39,401 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Strings;
with Matreshka.DOM_Nodes.Documents;
with Matreshka.ODF_Attributes.Draw.End_Line_Spacing_Horizontal;
with Matreshka.ODF_Attributes.Draw.End_Line_Spacing_Vertical;
with Matreshka.ODF_Attributes.Draw.Fill_Color;
with Matreshka.ODF_Attributes.Draw.Shadow_Offset_X;
with Matreshka.ODF_Attributes.Draw.Shadow_Offset_Y;
with Matreshka.ODF_Attributes.Draw.Start_Line_Spacing_Horizontal;
with Matreshka.ODF_Attributes.Draw.Start_Line_Spacing_Vertical;
with Matreshka.ODF_Attributes.FO.Background_Color;
with Matreshka.ODF_Attributes.FO.Border;
with Matreshka.ODF_Attributes.FO.Border_Bottom;
with Matreshka.ODF_Attributes.FO.Border_Left;
with Matreshka.ODF_Attributes.FO.Border_Right;
with Matreshka.ODF_Attributes.FO.Border_Top;
with Matreshka.ODF_Attributes.FO.Country;
with Matreshka.ODF_Attributes.FO.Font_Size;
with Matreshka.ODF_Attributes.FO.Font_Style;
with Matreshka.ODF_Attributes.FO.Font_Weight;
with Matreshka.ODF_Attributes.FO.Hyphenate;
with Matreshka.ODF_Attributes.FO.Hyphenation_Ladder_Count;
with Matreshka.ODF_Attributes.FO.Hyphenation_Push_Char_Count;
with Matreshka.ODF_Attributes.FO.Hyphenation_Remain_Char_Count;
with Matreshka.ODF_Attributes.FO.Keep_Together;
with Matreshka.ODF_Attributes.FO.Keep_With_Next;
with Matreshka.ODF_Attributes.FO.Language;
with Matreshka.ODF_Attributes.FO.Margin;
with Matreshka.ODF_Attributes.FO.Margin_Bottom;
with Matreshka.ODF_Attributes.FO.Margin_Left;
with Matreshka.ODF_Attributes.FO.Margin_Right;
with Matreshka.ODF_Attributes.FO.Margin_Top;
with Matreshka.ODF_Attributes.FO.Padding;
with Matreshka.ODF_Attributes.FO.Page_Height;
with Matreshka.ODF_Attributes.FO.Page_Width;
with Matreshka.ODF_Attributes.FO.Text_Align;
with Matreshka.ODF_Attributes.FO.Text_Indent;
with Matreshka.ODF_Attributes.FO.Wrap_Option;
with Matreshka.ODF_Attributes.Office.Value_Type;
with Matreshka.ODF_Attributes.Office.Version;
with Matreshka.ODF_Attributes.Style.Adjustment;
with Matreshka.ODF_Attributes.Style.Class;
with Matreshka.ODF_Attributes.Style.Color;
with Matreshka.ODF_Attributes.Style.Column_Width;
with Matreshka.ODF_Attributes.Style.Contextual_Spacing;
with Matreshka.ODF_Attributes.Style.Country_Asian;
with Matreshka.ODF_Attributes.Style.Country_Complex;
with Matreshka.ODF_Attributes.Style.Default_Outline_Level;
with Matreshka.ODF_Attributes.Style.Display_Name;
with Matreshka.ODF_Attributes.Style.Distance_After_Sep;
with Matreshka.ODF_Attributes.Style.Distance_Before_Sep;
with Matreshka.ODF_Attributes.Style.Family;
with Matreshka.ODF_Attributes.Style.Flow_With_Text;
with Matreshka.ODF_Attributes.Style.Font_Family_Generic;
with Matreshka.ODF_Attributes.Style.Font_Independent_Line_Spacing;
with Matreshka.ODF_Attributes.Style.Font_Name;
with Matreshka.ODF_Attributes.Style.Font_Name_Asian;
with Matreshka.ODF_Attributes.Style.Font_Name_Complex;
with Matreshka.ODF_Attributes.Style.Font_Pitch;
with Matreshka.ODF_Attributes.Style.Font_Size_Asian;
with Matreshka.ODF_Attributes.Style.Font_Size_Complex;
with Matreshka.ODF_Attributes.Style.Font_Style_Asian;
with Matreshka.ODF_Attributes.Style.Font_Style_Complex;
with Matreshka.ODF_Attributes.Style.Font_Weight_Asian;
with Matreshka.ODF_Attributes.Style.Font_Weight_Complex;
with Matreshka.ODF_Attributes.Style.Footnote_Max_Height;
with Matreshka.ODF_Attributes.Style.Justify_Single_Word;
with Matreshka.ODF_Attributes.Style.Language_Asian;
with Matreshka.ODF_Attributes.Style.Language_Complex;
with Matreshka.ODF_Attributes.Style.Letter_Kerning;
with Matreshka.ODF_Attributes.Style.Line_Break;
with Matreshka.ODF_Attributes.Style.Line_Style;
with Matreshka.ODF_Attributes.Style.Name;
with Matreshka.ODF_Attributes.Style.Next_Style_Name;
with Matreshka.ODF_Attributes.Style.Num_Format;
with Matreshka.ODF_Attributes.Style.Page_Layout_Name;
with Matreshka.ODF_Attributes.Style.Parent_Style_Name;
with Matreshka.ODF_Attributes.Style.Print_Orientation;
with Matreshka.ODF_Attributes.Style.Punctuation_Wrap;
with Matreshka.ODF_Attributes.Style.Rel_Column_Width;
with Matreshka.ODF_Attributes.Style.Rel_Width;
with Matreshka.ODF_Attributes.Style.Tab_Stop_Distance;
with Matreshka.ODF_Attributes.Style.Text_Autospace;
with Matreshka.ODF_Attributes.Style.Text_Underline_Color;
with Matreshka.ODF_Attributes.Style.Text_Underline_Style;
with Matreshka.ODF_Attributes.Style.Text_Underline_Width;
with Matreshka.ODF_Attributes.Style.Use_Window_Font_Color;
with Matreshka.ODF_Attributes.Style.Vertical_Align;
with Matreshka.ODF_Attributes.Style.Width;
with Matreshka.ODF_Attributes.Style.Writing_Mode;
with Matreshka.ODF_Attributes.SVG.Font_Family;
with Matreshka.ODF_Attributes.SVG.Stroke_Color;
with Matreshka.ODF_Attributes.Table.Align;
with Matreshka.ODF_Attributes.Table.Border_Model;
with Matreshka.ODF_Attributes.Table.Name;
with Matreshka.ODF_Attributes.Table.Number_Columns_Spanned;
with Matreshka.ODF_Attributes.Table.Style_Name;
with Matreshka.ODF_Attributes.Text.Display_Outline_Level;
with Matreshka.ODF_Attributes.Text.Footnotes_Position;
with Matreshka.ODF_Attributes.Text.Increment;
with Matreshka.ODF_Attributes.Text.Label_Followed_By;
with Matreshka.ODF_Attributes.Text.Level;
with Matreshka.ODF_Attributes.Text.Line_Number;
with Matreshka.ODF_Attributes.Text.List_Level_Position_And_Space_Mode;
with Matreshka.ODF_Attributes.Text.List_Tab_Stop_Position;
with Matreshka.ODF_Attributes.Text.Min_Label_Distance;
with Matreshka.ODF_Attributes.Text.Name;
with Matreshka.ODF_Attributes.Text.Note_Class;
with Matreshka.ODF_Attributes.Text.Number_Lines;
with Matreshka.ODF_Attributes.Text.Number_Position;
with Matreshka.ODF_Attributes.Text.Offset;
with Matreshka.ODF_Attributes.Text.Outline_Level;
with Matreshka.ODF_Attributes.Text.Start_Numbering_At;
with Matreshka.ODF_Attributes.Text.Start_Value;
with Matreshka.ODF_Attributes.Text.Style_Name;
with Matreshka.ODF_Elements.Office.Automatic_Styles;
with Matreshka.ODF_Elements.Office.Bodies;
with Matreshka.ODF_Elements.Office.Document_Content;
with Matreshka.ODF_Elements.Office.Document_Styles;
with Matreshka.ODF_Elements.Office.Font_Face_Decls;
with Matreshka.ODF_Elements.Office.Master_Styles;
with Matreshka.ODF_Elements.Office.Scripts;
with Matreshka.ODF_Elements.Office.Styles;
with Matreshka.ODF_Elements.Office.Text;
with Matreshka.ODF_Elements.Style.Background_Image;
with Matreshka.ODF_Elements.Style.Default_Style;
with Matreshka.ODF_Elements.Style.Font_Face;
with Matreshka.ODF_Elements.Style.Footer_Style;
with Matreshka.ODF_Elements.Style.Footnote_Sep;
with Matreshka.ODF_Elements.Style.Graphic_Properties;
with Matreshka.ODF_Elements.Style.Header_Style;
with Matreshka.ODF_Elements.Style.List_Level_Label_Alignment;
with Matreshka.ODF_Elements.Style.List_Level_Properties;
with Matreshka.ODF_Elements.Style.Master_Page;
with Matreshka.ODF_Elements.Style.Page_Layout;
with Matreshka.ODF_Elements.Style.Page_Layout_Properties;
with Matreshka.ODF_Elements.Style.Paragraph_Properties;
with Matreshka.ODF_Elements.Style.Style;
with Matreshka.ODF_Elements.Style.Tab_Stops;
with Matreshka.ODF_Elements.Style.Table_Cell_Properties;
with Matreshka.ODF_Elements.Style.Table_Column_Properties;
with Matreshka.ODF_Elements.Style.Table_Properties;
with Matreshka.ODF_Elements.Style.Table_Row_Properties;
with Matreshka.ODF_Elements.Style.Text_Properties;
with Matreshka.ODF_Elements.Table.Covered_Table_Cell;
with Matreshka.ODF_Elements.Table.Table;
with Matreshka.ODF_Elements.Table.Table_Cell;
with Matreshka.ODF_Elements.Table.Table_Column;
with Matreshka.ODF_Elements.Table.Table_Row;
with Matreshka.ODF_Elements.Text.H;
with Matreshka.ODF_Elements.Text.Linenumbering_Configuration;
with Matreshka.ODF_Elements.Text.Notes_Configuration;
with Matreshka.ODF_Elements.Text.Outline_Level_Style;
with Matreshka.ODF_Elements.Text.Outline_Style;
with Matreshka.ODF_Elements.Text.P;
with Matreshka.ODF_Elements.Text.Sequence_Decl;
with Matreshka.ODF_Elements.Text.Sequence_Decls;
with Matreshka.ODF_Elements.Text.Span;
package Matreshka.ODF_Documents is
type Document_Node is
new Matreshka.DOM_Nodes.Documents.Abstract_Document with null record;
type Document_Access is access all Document_Node'Class;
function Create_Draw_End_Line_Spacing_Horizontal
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Draw.End_Line_Spacing_Horizontal.Draw_End_Line_Spacing_Horizontal_Access;
function Create_Draw_End_Line_Spacing_Vertical
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Draw.End_Line_Spacing_Vertical.Draw_End_Line_Spacing_Vertical_Access;
function Create_Draw_Fill_Color
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Draw.Fill_Color.Draw_Fill_Color_Access;
function Create_Draw_Shadow_Offset_X
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Draw.Shadow_Offset_X.Draw_Shadow_Offset_X_Access;
function Create_Draw_Shadow_Offset_Y
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Draw.Shadow_Offset_Y.Draw_Shadow_Offset_Y_Access;
function Create_Draw_Start_Line_Spacing_Horizontal
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Draw.Start_Line_Spacing_Horizontal.Draw_Start_Line_Spacing_Horizontal_Access;
function Create_Draw_Start_Line_Spacing_Vertical
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Draw.Start_Line_Spacing_Vertical.Draw_Start_Line_Spacing_Vertical_Access;
function Create_FO_Background_Color
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Background_Color.FO_Background_Color_Access;
function Create_FO_Border
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Border.FO_Border_Access;
function Create_FO_Border_Bottom
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Border_Bottom.FO_Border_Bottom_Access;
function Create_FO_Border_Left
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Border_Left.FO_Border_Left_Access;
function Create_FO_Border_Right
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Border_Right.FO_Border_Right_Access;
function Create_FO_Border_Top
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Border_Top.FO_Border_Top_Access;
function Create_FO_Country
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Country.FO_Country_Access;
function Create_FO_Font_Size
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Font_Size.FO_Font_Size_Access;
function Create_FO_Font_Style
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Font_Style.FO_Font_Style_Access;
function Create_FO_Font_Weight
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Font_Weight.FO_Font_Weight_Access;
function Create_FO_Hyphenate
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Hyphenate.FO_Hyphenate_Access;
function Create_FO_Hyphenation_Ladder_Count
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Hyphenation_Ladder_Count.FO_Hyphenation_Ladder_Count_Access;
function Create_FO_Hyphenation_Push_Char_Count
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Hyphenation_Push_Char_Count.FO_Hyphenation_Push_Char_Count_Access;
function Create_FO_Hyphenation_Remain_Char_Count
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Hyphenation_Remain_Char_Count.FO_Hyphenation_Remain_Char_Count_Access;
function Create_FO_Keep_Together
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Keep_Together.FO_Keep_Together_Access;
function Create_FO_Keep_With_Next
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Keep_With_Next.FO_Keep_With_Next_Access;
function Create_FO_Language
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Language.FO_Language_Access;
function Create_FO_Margin
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Margin.FO_Margin_Access;
function Create_FO_Margin_Bottom
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Margin_Bottom.FO_Margin_Bottom_Access;
function Create_FO_Margin_Left
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Margin_Left.FO_Margin_Left_Access;
function Create_FO_Margin_Right
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Margin_Right.FO_Margin_Right_Access;
function Create_FO_Margin_Top
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Margin_Top.FO_Margin_Top_Access;
function Create_FO_Padding
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Padding.FO_Padding_Access;
function Create_FO_Page_Height
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Page_Height.FO_Page_Height_Access;
function Create_FO_Page_Width
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Page_Width.FO_Page_Width_Access;
function Create_FO_Text_Align
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Text_Align.FO_Text_Align_Access;
function Create_FO_Text_Indent
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Text_Indent.FO_Text_Indent_Access;
function Create_FO_Wrap_Option
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.FO.Wrap_Option.FO_Wrap_Option_Access;
function Create_Office_Automatic_Styles
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Office.Automatic_Styles.Office_Automatic_Styles_Access;
function Create_Office_Body
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Office.Bodies.Office_Body_Access;
function Create_Office_Document_Content
(Self : not null access Document_Node'Class)
return
Matreshka.ODF_Elements.Office.Document_Content.Office_Document_Content_Access;
function Create_Office_Document_Styles
(Self : not null access Document_Node'Class)
return
Matreshka.ODF_Elements.Office.Document_Styles.Office_Document_Styles_Access;
function Create_Office_Font_Face_Decls
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Office.Font_Face_Decls.Office_Font_Face_Decls_Access;
function Create_Office_Master_Styles
(Self : not null access Document_Node'Class)
return
Matreshka.ODF_Elements.Office.Master_Styles.Office_Master_Styles_Access;
function Create_Office_Scripts
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Office.Scripts.Office_Scripts_Access;
function Create_Office_Styles
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Office.Styles.Office_Styles_Access;
function Create_Office_Text
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Office.Text.Office_Text_Access;
function Create_Office_Value_Type
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Office.Value_Type.Office_Value_Type_Access;
function Create_Office_Version
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Office.Version.Office_Version_Access;
function Create_Style_Background_Image
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Background_Image.Style_Background_Image_Access;
function Create_Style_Adjustment
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Adjustment.Style_Adjustment_Access;
function Create_Style_Class
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Class.Style_Class_Access;
function Create_Style_Color
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Color.Style_Color_Access;
function Create_Style_Column_Width
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Column_Width.Style_Column_Width_Access;
function Create_Style_Contextual_Spacing
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Contextual_Spacing.Style_Contextual_Spacing_Access;
function Create_Style_Country_Asian
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Country_Asian.Style_Country_Asian_Access;
function Create_Style_Country_Complex
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Country_Complex.Style_Country_Complex_Access;
function Create_Style_Default_Outline_Level
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Default_Outline_Level.Style_Default_Outline_Level_Access;
function Create_Style_Default_Style
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Default_Style.Style_Default_Style_Access;
function Create_Style_Display_Name
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Display_Name.Style_Display_Name_Access;
function Create_Style_Distance_After_Sep
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Distance_After_Sep.Style_Distance_After_Sep_Access;
function Create_Style_Distance_Before_Sep
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Distance_Before_Sep.Style_Distance_Before_Sep_Access;
function Create_Style_Family
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Family.Style_Family_Access;
function Create_Style_Flow_With_Text
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Flow_With_Text.Style_Flow_With_Text_Access;
function Create_Style_Font_Face
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Font_Face.Style_Font_Face_Access;
function Create_Style_Font_Family_Generic
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Font_Family_Generic.Style_Font_Family_Generic_Access;
function Create_Style_Font_Independent_Line_Spacing
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Font_Independent_Line_Spacing.Style_Font_Independent_Line_Spacing_Access;
function Create_Style_Font_Name
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Font_Name.Style_Font_Name_Access;
function Create_Style_Font_Name_Asian
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Font_Name_Asian.Style_Font_Name_Asian_Access;
function Create_Style_Font_Name_Complex
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Font_Name_Complex.Style_Font_Name_Complex_Access;
function Create_Style_Font_Pitch
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Font_Pitch.Style_Font_Pitch_Access;
function Create_Style_Font_Size_Asian
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Font_Size_Asian.Style_Font_Size_Asian_Access;
function Create_Style_Font_Size_Complex
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Font_Size_Complex.Style_Font_Size_Complex_Access;
function Create_Style_Font_Style_Asian
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Font_Style_Asian.Style_Font_Style_Asian_Access;
function Create_Style_Font_Style_Complex
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Font_Style_Complex.Style_Font_Style_Complex_Access;
function Create_Style_Font_Weight_Asian
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Font_Weight_Asian.Style_Font_Weight_Asian_Access;
function Create_Style_Font_Weight_Complex
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Font_Weight_Complex.Style_Font_Weight_Complex_Access;
function Create_Style_Footer_Style
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Footer_Style.Style_Footer_Style_Access;
function Create_Style_Footnote_Max_Height
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Footnote_Max_Height.Style_Footnote_Max_Height_Access;
function Create_Style_Footnote_Sep
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Footnote_Sep.Style_Footnote_Sep_Access;
function Create_Style_Graphic_Properties
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Graphic_Properties.Style_Graphic_Properties_Access;
function Create_Style_Header_Style
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Header_Style.Style_Header_Style_Access;
function Create_Style_Justify_Single_Word
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Justify_Single_Word.Style_Justify_Single_Word_Access;
function Create_Style_Language_Asian
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Language_Asian.Style_Language_Asian_Access;
function Create_Style_Language_Complex
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Language_Complex.Style_Language_Complex_Access;
function Create_Style_Letter_Kerning
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Letter_Kerning.Style_Letter_Kerning_Access;
function Create_Style_Line_Break
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Line_Break.Style_Line_Break_Access;
function Create_Style_Line_Style
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Line_Style.Style_Line_Style_Access;
function Create_Style_List_Level_Label_Alignment
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.List_Level_Label_Alignment.Style_List_Level_Label_Alignment_Access;
function Create_Style_List_Level_Properties
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.List_Level_Properties.Style_List_Level_Properties_Access;
function Create_Style_Master_Page
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Master_Page.Style_Master_Page_Access;
function Create_Style_Name
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Name.Style_Name_Access;
function Create_Style_Next_Style_Name
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Next_Style_Name.Style_Next_Style_Name_Access;
function Create_Style_Num_Format
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Num_Format.Style_Num_Format_Access;
function Create_Style_Page_Layout
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Page_Layout.Style_Page_Layout_Access;
function Create_Style_Page_Layout_Properties
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Page_Layout_Properties.Style_Page_Layout_Properties_Access;
function Create_Style_Paragraph_Properties
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Paragraph_Properties.Style_Paragraph_Properties_Access;
function Create_Style_Page_Layout_Name
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Page_Layout_Name.Style_Page_Layout_Name_Access;
function Create_Style_Parent_Style_Name
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Parent_Style_Name.Style_Parent_Style_Name_Access;
function Create_Style_Print_Orientation
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Print_Orientation.Style_Print_Orientation_Access;
function Create_Style_Punctuation_Wrap
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Punctuation_Wrap.Style_Punctuation_Wrap_Access;
function Create_Style_Rel_Column_Width
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Rel_Column_Width.Style_Rel_Column_Width_Access;
function Create_Style_Rel_Width
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Rel_Width.Style_Rel_Width_Access;
function Create_Style_Style
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Style.Style_Style_Access;
function Create_Style_Tab_Stop_Distance
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Tab_Stop_Distance.Style_Tab_Stop_Distance_Access;
function Create_Style_Tab_Stops
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Tab_Stops.Style_Tab_Stops_Access;
function Create_Style_Table_Properties
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Table_Properties.Style_Table_Properties_Access;
function Create_Style_Table_Cell_Properties
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Table_Cell_Properties.Style_Table_Cell_Properties_Access;
function Create_Style_Table_Column_Properties
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Table_Column_Properties.Style_Table_Column_Properties_Access;
function Create_Style_Table_Row_Properties
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Table_Row_Properties.Style_Table_Row_Properties_Access;
function Create_Style_Text_Autospace
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Text_Autospace.Style_Text_Autospace_Access;
function Create_Style_Text_Underline_Color
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Text_Underline_Color.Style_Text_Underline_Color_Access;
function Create_Style_Text_Underline_Style
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Text_Underline_Style.Style_Text_Underline_Style_Access;
function Create_Style_Text_Underline_Width
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Text_Underline_Width.Style_Text_Underline_Width_Access;
function Create_Style_Text_Properties
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Style.Text_Properties.Style_Text_Properties_Access;
function Create_Style_Use_Window_Font_Color
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Use_Window_Font_Color.Style_Use_Window_Font_Color_Access;
function Create_Style_Vertical_Align
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Vertical_Align.Style_Vertical_Align_Access;
function Create_Style_Width
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Width.Style_Width_Access;
function Create_Style_Writing_Mode
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Style.Writing_Mode.Style_Writing_Mode_Access;
function Create_SVG_Font_Family
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.SVG.Font_Family.SVG_Font_Family_Access;
function Create_SVG_Stroke_Color
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.SVG.Stroke_Color.SVG_Stroke_Color_Access;
function Create_Table_Align
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Table.Align.Table_Align_Access;
function Create_Table_Border_Model
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Table.Border_Model.Table_Border_Model_Access;
function Create_Table_Covered_Table_Cell
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Table.Covered_Table_Cell.Table_Covered_Table_Cell_Access;
function Create_Table_Name
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Table.Name.Table_Name_Access;
function Create_Table_Number_Columns_Spanned
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Table.Number_Columns_Spanned.Table_Number_Columns_Spanned_Access;
function Create_Table_Style_Name
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Table.Style_Name.Table_Style_Name_Access;
function Create_Table_Table
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Table.Table.Table_Table_Access;
function Create_Table_Table_Cell
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Table.Table_Cell.Table_Table_Cell_Access;
function Create_Table_Table_Column
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Table.Table_Column.Table_Table_Column_Access;
function Create_Table_Table_Row
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Table.Table_Row.Table_Table_Row_Access;
function Create_Text_Display_Outline_Level
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Display_Outline_Level.Text_Display_Outline_Level_Access;
function Create_Text_Footnotes_Position
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Footnotes_Position.Text_Footnotes_Position_Access;
function Create_Text_H
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Text.H.Text_H_Access;
function Create_Text_Increment
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Increment.Text_Increment_Access;
function Create_Text_Label_Followed_By
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Label_Followed_By.Text_Label_Followed_By_Access;
function Create_Text_Level
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Level.Text_Level_Access;
function Create_Text_Line_Number
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Line_Number.Text_Line_Number_Access;
function Create_Text_Linenumbering_Configuration
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Text.Linenumbering_Configuration.Text_Linenumbering_Configuration_Access;
function Create_Text_List_Level_Position_And_Space_Mode
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.List_Level_Position_And_Space_Mode.Text_List_Level_Position_And_Space_Mode_Access;
function Create_Text_List_Tab_Stop_Position
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.List_Tab_Stop_Position.Text_List_Tab_Stop_Position_Access;
function Create_Text_Min_Label_Distance
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Min_Label_Distance.Text_Min_Label_Distance_Access;
function Create_Text_Name
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Name.Text_Name_Access;
function Create_Text_Notes_Configuration
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Text.Notes_Configuration.Text_Notes_Configuration_Access;
function Create_Text_Note_Class
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Note_Class.Text_Note_Class_Access;
function Create_Text_Number_Lines
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Number_Lines.Text_Number_Lines_Access;
function Create_Text_Number_Position
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Number_Position.Text_Number_Position_Access;
function Create_Text_Offset
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Offset.Text_Offset_Access;
function Create_Text_Outline_Level
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Outline_Level.Text_Outline_Level_Access;
function Create_Text_Outline_Level_Style
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Text.Outline_Level_Style.Text_Outline_Level_Style_Access;
function Create_Text_Outline_Style
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Text.Outline_Style.Text_Outline_Style_Access;
function Create_Text_P
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Text.P.Text_P_Access;
function Create_Text_Sequence_Decl
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Text.Sequence_Decl.Text_Sequence_Decl_Access;
function Create_Text_Sequence_Decls
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Text.Sequence_Decls.Text_Sequence_Decls_Access;
function Create_Text_Span
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Elements.Text.Span.Text_Span_Access;
function Create_Text_Start_Numbering_At
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Start_Numbering_At.Text_Start_Numbering_At_Access;
function Create_Text_Start_Value
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Start_Value.Text_Start_Value_Access;
function Create_Text_Style_Name
(Self : not null access Document_Node'Class)
return Matreshka.ODF_Attributes.Text.Style_Name.Text_Style_Name_Access;
overriding function Create_Attribute
(Self : not null access Document_Node;
Namespace_URI : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String)
return not null Matreshka.DOM_Nodes.Attribute_Access;
overriding function Create_Element
(Self : not null access Document_Node;
Namespace_URI : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String)
return not null Matreshka.DOM_Nodes.Element_Access;
overriding function Create
(The_Type : not null access Matreshka.DOM_Nodes.Documents.Document_Type)
return Document_Node;
end Matreshka.ODF_Documents;
|
reznikmm/matreshka | Ada | 3,734 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_Style_Override_Attributes is
pragma Preelaborate;
type ODF_Text_Style_Override_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_Style_Override_Attribute_Access is
access all ODF_Text_Style_Override_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_Style_Override_Attributes;
|
persan/protobuf-ada | Ada | 7,714 | adb | pragma Ada_2012;
with Ada.Text_IO;
package body Google.Protobuf.Message is
----------------------------------------
-- Print_Initialization_Error_Message --
----------------------------------------
procedure Print_Initialization_Error_Message
(Action : in String;
The_Message : in Message.Instance'Class)
is
begin
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error,
"Can't " & Action & " message of type " &
The_Message.Get_Type_Name & " because it is " &
"missing required fields.");
end Print_Initialization_Error_Message;
------------------------------------------
-- Inline_Merge_From_Coded_Input_Stream --
------------------------------------------
procedure Inline_Merge_From_Coded_Input_Stream
(The_Message : in out Message.Instance'Class;
The_Coded_Input_Stream : in out
Google.Protobuf.IO.Coded_Input_Stream.Instance)
is
begin
The_Message.Merge_Partial_From_Coded_Input_Stream (The_Coded_Input_Stream);
if not The_Message.Is_Initialized then
Print_Initialization_Error_Message ("parse", The_Message);
end if;
end Inline_Merge_From_Coded_Input_Stream;
--------------------------------
-- Serialize_To_Output_Stream --
--------------------------------
procedure Serialize_To_Output_Stream
(The_Message : in out Message.Instance'Class;
Output_Stream : not null access
Ada.Streams.Root_Stream_Type'Class)
is
begin
if not The_Message.Is_Initialized then
Print_Initialization_Error_Message ("serialize", The_Message);
end if;
The_Message.Serialize_Partial_To_Output_Stream (Output_Stream);
end Serialize_To_Output_Stream;
----------------------------------------
-- Serialize_To_Coded_Output_Stream --
----------------------------------------
procedure Serialize_To_Coded_Output_Stream
(The_Message : in out Message.Instance'Class;
The_Coded_Output_Stream : in out
Google.Protobuf.IO.Coded_Output_Stream.Instance)
is
begin
if not The_Message.Is_Initialized then
Print_Initialization_Error_Message ("serialize", The_Message);
end if;
The_Message.Serialize_Partial_To_Coded_Output_Stream (The_Coded_Output_Stream);
end Serialize_To_Coded_Output_Stream;
----------------------------------------
-- Serialize_Partial_To_Output_Stream --
----------------------------------------
procedure Serialize_Partial_To_Output_Stream
(The_Message : in out Message.Instance'Class;
Output_Stream : not null access
Ada.Streams.Root_Stream_Type'Class)
is
A_Coded_Output_Stream : Google.Protobuf.IO.Coded_Output_Stream.Instance
(Google.Protobuf.IO.Coded_Output_Stream.Root_Stream_Access (Output_Stream));
Size : Google.Protobuf.Wire_Format.PB_Object_Size;
pragma Unreferenced (Size);
begin
Size := The_Message.Byte_Size; -- Force caching of message size.
The_Message.Serialize_With_Cached_Sizes (A_Coded_Output_Stream);
end Serialize_Partial_To_Output_Stream;
----------------------------------------
-- Serialize_Partial_To_Coded_Output_Stream --
----------------------------------------
procedure Serialize_Partial_To_Coded_Output_Stream
(The_Message : in out Message.Instance'Class;
The_Coded_Output_Stream : in out
Google.Protobuf.IO.Coded_Output_Stream.Instance)
is
Size : Google.Protobuf.Wire_Format.PB_Object_Size;
pragma Unreferenced (Size);
begin
Size := The_Message.Byte_Size; -- Force caching of message size.
The_Message.Serialize_With_Cached_Sizes (The_Coded_Output_Stream);
end Serialize_Partial_To_Coded_Output_Stream;
-----------------------------
-- Parse_From_Input_Stream --
-----------------------------
procedure Parse_From_Input_Stream
(The_Message : in out Message.Instance'Class;
Input_Stream : not null access
Ada.Streams.Root_Stream_Type'Class)
is
A_Coded_Input_Stream : Google.Protobuf.IO.Coded_Input_Stream.Instance
(Google.Protobuf.IO.Coded_Input_Stream.Root_Stream_Access (Input_Stream));
begin
The_Message.Clear;
Inline_Merge_From_Coded_Input_Stream (The_Message, A_Coded_Input_Stream);
end Parse_From_Input_Stream;
-----------------------------------
-- Parse_From_Coded_Input_Stream --
-----------------------------------
procedure Parse_From_Coded_Input_Stream
(The_Message : in out Message.Instance'Class;
The_Coded_Input_Stream : in out
Google.Protobuf.IO.Coded_Input_Stream.Instance)
is
begin
The_Message.Clear;
Inline_Merge_From_Coded_Input_Stream (The_Message, The_Coded_Input_Stream);
end Parse_From_Coded_Input_Stream;
-------------------------------------
-- Parse_Partial_From_Input_Stream --
-------------------------------------
procedure Parse_Partial_From_Input_Stream
(The_Message : in out Message.Instance'Class;
Input_Stream : not null access
Ada.Streams.Root_Stream_Type'Class)
is
A_Coded_Input_Stream : Google.Protobuf.IO.Coded_Input_Stream.Instance
(Google.Protobuf.IO.Coded_Input_Stream.Root_Stream_Access (Input_Stream));
begin
The_Message.Clear;
The_Message.Merge_Partial_From_Coded_Input_Stream (A_Coded_Input_Stream);
end Parse_Partial_From_Input_Stream;
-------------------------------------------
-- Parse_Partial_From_Coded_Input_Stream --
-------------------------------------------
procedure Parse_Partial_From_Coded_Input_Stream
(The_Message : in out Message.Instance'Class;
The_Coded_Input_Stream : in out
Google.Protobuf.IO.Coded_Input_Stream.Instance)
is
begin
The_Message.Clear;
The_Message.Merge_Partial_From_Coded_Input_Stream (The_Coded_Input_Stream);
end Parse_Partial_From_Coded_Input_Stream;
-----------------------------
-- Merge_From_Input_Stream --
-----------------------------
procedure Merge_From_Input_Stream
(The_Message : in out Message.Instance'Class;
Input_Stream : not null access
Ada.Streams.Root_Stream_Type'Class)
is
A_Coded_Input_Stream : Google.Protobuf.IO.Coded_Input_Stream.Instance
(Google.Protobuf.IO.Coded_Input_Stream.Root_Stream_Access (Input_Stream));
begin
Inline_Merge_From_Coded_Input_Stream (The_Message, A_Coded_Input_Stream);
end Merge_From_Input_Stream;
-----------------------------------
-- Merge_From_Coded_Input_Stream --
-----------------------------------
procedure Merge_From_Coded_Input_Stream
(The_Message : in out Message.Instance'Class;
The_Coded_Input_Stream : in out
Google.Protobuf.IO.Coded_Input_Stream.Instance)
is
begin
Inline_Merge_From_Coded_Input_Stream (The_Message, The_Coded_Input_Stream);
end Merge_From_Coded_Input_Stream;
-------------------------------------
-- Merge_Partial_From_Input_Stream --
-------------------------------------
procedure Merge_Partial_From_Input_Stream
(The_Message : in out Message.Instance'Class;
Input_Stream : not null access
Ada.Streams.Root_Stream_Type'Class)
is
A_Coded_Input_Stream : Google.Protobuf.IO.Coded_Input_Stream.Instance
(Google.Protobuf.IO.Coded_Input_Stream.Root_Stream_Access (Input_Stream));
begin
The_Message.Merge_Partial_From_Coded_Input_Stream (A_Coded_Input_Stream);
end Merge_Partial_From_Input_Stream;
end Google.Protobuf.Message;
|
zhmu/ananas | Ada | 95,227 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . B O U N D E D _ V E C T O R S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
with Ada.Containers.Generic_Array_Sort;
with System; use type System.Address;
with System.Put_Images;
package body Ada.Containers.Bounded_Vectors is
pragma Warnings (Off, "variable ""Busy*"" is not referenced");
pragma Warnings (Off, "variable ""Lock*"" is not referenced");
-- See comment in Ada.Containers.Helpers
-----------------------
-- Local Subprograms --
-----------------------
function To_Array_Index (Index : Index_Type'Base) return Count_Type'Base;
---------
-- "&" --
---------
function "&" (Left, Right : Vector) return Vector is
LN : constant Count_Type := Length (Left);
RN : constant Count_Type := Length (Right);
N : Count_Type'Base; -- length of result
J : Count_Type'Base; -- for computing intermediate index values
Last : Index_Type'Base; -- Last index of result
begin
-- We decide that the capacity of the result is the sum of the lengths
-- of the vector parameters. We could decide to make it larger, but we
-- have no basis for knowing how much larger, so we just allocate the
-- minimum amount of storage.
-- Here we handle the easy cases first, when one of the vector
-- parameters is empty. (We say "easy" because there's nothing to
-- compute, that can potentially overflow.)
if LN = 0 then
if RN = 0 then
return Empty_Vector;
end if;
return Vector'(Capacity => RN,
Elements => Right.Elements (1 .. RN),
Last => Right.Last,
others => <>);
end if;
if RN = 0 then
return Vector'(Capacity => LN,
Elements => Left.Elements (1 .. LN),
Last => Left.Last,
others => <>);
end if;
-- Neither of the vector parameters is empty, so must compute the length
-- of the result vector and its last index. (This is the harder case,
-- because our computations must avoid overflow.)
-- There are two constraints we need to satisfy. The first constraint is
-- that a container cannot have more than Count_Type'Last elements, so
-- we must check the sum of the combined lengths. Note that we cannot
-- simply add the lengths, because of the possibility of overflow.
if Checks and then LN > Count_Type'Last - RN then
raise Constraint_Error with "new length is out of range";
end if;
-- It is now safe to compute the length of the new vector, without fear
-- of overflow.
N := LN + RN;
-- The second constraint is that the new Last index value cannot
-- exceed Index_Type'Last. We use the wider of Index_Type'Base and
-- Count_Type'Base as the type for intermediate values.
if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then
-- We perform a two-part test. First we determine whether the
-- computed Last value lies in the base range of the type, and then
-- determine whether it lies in the range of the index (sub)type.
-- Last must satisfy this relation:
-- First + Length - 1 <= Last
-- We regroup terms:
-- First - 1 <= Last - Length
-- Which can rewrite as:
-- No_Index <= Last - Length
if Checks and then
Index_Type'Base'Last - Index_Type'Base (N) < No_Index
then
raise Constraint_Error with "new length is out of range";
end if;
-- We now know that the computed value of Last is within the base
-- range of the type, so it is safe to compute its value:
Last := No_Index + Index_Type'Base (N);
-- Finally we test whether the value is within the range of the
-- generic actual index subtype:
if Checks and then Last > Index_Type'Last then
raise Constraint_Error with "new length is out of range";
end if;
elsif Index_Type'First <= 0 then
-- Here we can compute Last directly, in the normal way. We know that
-- No_Index is less than 0, so there is no danger of overflow when
-- adding the (positive) value of length.
J := Count_Type'Base (No_Index) + N; -- Last
if Checks and then J > Count_Type'Base (Index_Type'Last) then
raise Constraint_Error with "new length is out of range";
end if;
-- We know that the computed value (having type Count_Type) of Last
-- is within the range of the generic actual index subtype, so it is
-- safe to convert to Index_Type:
Last := Index_Type'Base (J);
else
-- Here Index_Type'First (and Index_Type'Last) is positive, so we
-- must test the length indirectly (by working backwards from the
-- largest possible value of Last), in order to prevent overflow.
J := Count_Type'Base (Index_Type'Last) - N; -- No_Index
if Checks and then J < Count_Type'Base (No_Index) then
raise Constraint_Error with "new length is out of range";
end if;
-- We have determined that the result length would not create a Last
-- index value outside of the range of Index_Type, so we can now
-- safely compute its value.
Last := Index_Type'Base (Count_Type'Base (No_Index) + N);
end if;
declare
LE : Elements_Array renames Left.Elements (1 .. LN);
RE : Elements_Array renames Right.Elements (1 .. RN);
begin
return Vector'(Capacity => N,
Elements => LE & RE,
Last => Last,
others => <>);
end;
end "&";
function "&" (Left : Vector; Right : Element_Type) return Vector is
LN : constant Count_Type := Length (Left);
begin
-- We decide that the capacity of the result is the sum of the lengths
-- of the parameters. We could decide to make it larger, but we have no
-- basis for knowing how much larger, so we just allocate the minimum
-- amount of storage.
-- We must compute the length of the result vector and its last index,
-- but in such a way that overflow is avoided. We must satisfy two
-- constraints: the new length cannot exceed Count_Type'Last, and the
-- new Last index cannot exceed Index_Type'Last.
if Checks and then LN = Count_Type'Last then
raise Constraint_Error with "new length is out of range";
end if;
if Checks and then Left.Last >= Index_Type'Last then
raise Constraint_Error with "new length is out of range";
end if;
return Vector'(Capacity => LN + 1,
Elements => Left.Elements (1 .. LN) & Right,
Last => Left.Last + 1,
others => <>);
end "&";
function "&" (Left : Element_Type; Right : Vector) return Vector is
RN : constant Count_Type := Length (Right);
begin
-- We decide that the capacity of the result is the sum of the lengths
-- of the parameters. We could decide to make it larger, but we have no
-- basis for knowing how much larger, so we just allocate the minimum
-- amount of storage.
-- We compute the length of the result vector and its last index, but in
-- such a way that overflow is avoided. We must satisfy two constraints:
-- the new length cannot exceed Count_Type'Last, and the new Last index
-- cannot exceed Index_Type'Last.
if Checks and then RN = Count_Type'Last then
raise Constraint_Error with "new length is out of range";
end if;
if Checks and then Right.Last >= Index_Type'Last then
raise Constraint_Error with "new length is out of range";
end if;
return Vector'(Capacity => 1 + RN,
Elements => Left & Right.Elements (1 .. RN),
Last => Right.Last + 1,
others => <>);
end "&";
function "&" (Left, Right : Element_Type) return Vector is
begin
-- We decide that the capacity of the result is the sum of the lengths
-- of the parameters. We could decide to make it larger, but we have no
-- basis for knowing how much larger, so we just allocate the minimum
-- amount of storage.
-- We must compute the length of the result vector and its last index,
-- but in such a way that overflow is avoided. We must satisfy two
-- constraints: the new length cannot exceed Count_Type'Last (here, we
-- know that that condition is satisfied), and the new Last index cannot
-- exceed Index_Type'Last.
if Checks and then Index_Type'First >= Index_Type'Last then
raise Constraint_Error with "new length is out of range";
end if;
return Vector'(Capacity => 2,
Elements => [Left, Right],
Last => Index_Type'First + 1,
others => <>);
end "&";
---------
-- "=" --
---------
overriding function "=" (Left, Right : Vector) return Boolean is
begin
if Left.Last /= Right.Last then
return False;
end if;
if Left.Length = 0 then
return True;
end if;
declare
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
Lock_Left : With_Lock (Left.TC'Unrestricted_Access);
Lock_Right : With_Lock (Right.TC'Unrestricted_Access);
begin
for J in Count_Type range 1 .. Left.Length loop
if Left.Elements (J) /= Right.Elements (J) then
return False;
end if;
end loop;
end;
return True;
end "=";
------------
-- Assign --
------------
procedure Assign (Target : in out Vector; Source : Vector) is
begin
if Target'Address = Source'Address then
return;
end if;
if Checks and then Target.Capacity < Source.Length then
raise Capacity_Error -- ???
with "Target capacity is less than Source length";
end if;
Target.Clear;
Target.Elements (1 .. Source.Length) :=
Source.Elements (1 .. Source.Length);
Target.Last := Source.Last;
end Assign;
------------
-- Append --
------------
procedure Append
(Container : in out Vector;
New_Item : Element_Type;
Count : Count_Type)
is
begin
if Count = 0 then
return;
end if;
if Checks and then Container.Last >= Index_Type'Last then
raise Constraint_Error with "vector is already at its maximum length";
end if;
Container.Insert (Container.Last + 1, New_Item, Count);
end Append;
-------------------
-- Append_Vector --
-------------------
procedure Append_Vector (Container : in out Vector; New_Item : Vector) is
begin
if New_Item.Is_Empty then
return;
end if;
if Checks and then Container.Last >= Index_Type'Last then
raise Constraint_Error with "vector is already at its maximum length";
end if;
Container.Insert_Vector (Container.Last + 1, New_Item);
end Append_Vector;
------------
-- Append --
------------
procedure Append (Container : in out Vector;
New_Item : Element_Type)
is
begin
Insert (Container, Last_Index (Container) + 1, New_Item, 1);
end Append;
--------------
-- Capacity --
--------------
function Capacity (Container : Vector) return Count_Type is
begin
return Container.Elements'Length;
end Capacity;
-----------
-- Clear --
-----------
procedure Clear (Container : in out Vector) is
begin
TC_Check (Container.TC);
Container.Last := No_Index;
end Clear;
------------------------
-- Constant_Reference --
------------------------
function Constant_Reference
(Container : aliased Vector;
Position : Cursor) return Constant_Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with "Position cursor denotes wrong container";
end if;
if Checks and then Position.Index > Position.Container.Last then
raise Constraint_Error with "Position cursor is out of range";
end if;
declare
A : Elements_Array renames Container.Elements;
J : constant Count_Type := To_Array_Index (Position.Index);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Constant_Reference_Type :=
(Element => A (J)'Unchecked_Access,
Control => (Controlled with TC))
do
Busy (TC.all);
end return;
end;
end Constant_Reference;
function Constant_Reference
(Container : aliased Vector;
Index : Index_Type) return Constant_Reference_Type
is
begin
if Checks and then Index > Container.Last then
raise Constraint_Error with "Index is out of range";
end if;
declare
A : Elements_Array renames Container.Elements;
J : constant Count_Type := To_Array_Index (Index);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Constant_Reference_Type :=
(Element => A (J)'Unchecked_Access,
Control => (Controlled with TC))
do
Busy (TC.all);
end return;
end;
end Constant_Reference;
--------------
-- Contains --
--------------
function Contains
(Container : Vector;
Item : Element_Type) return Boolean
is
begin
return Find_Index (Container, Item) /= No_Index;
end Contains;
----------
-- Copy --
----------
function Copy
(Source : Vector;
Capacity : Count_Type := 0) return Vector
is
C : constant Count_Type :=
(if Capacity = 0 then Source.Length
else Capacity);
begin
if Checks and then C < Source.Length then
raise Capacity_Error with "Capacity too small";
end if;
return Target : Vector (C) do
Target.Elements (1 .. Source.Length) :=
Source.Elements (1 .. Source.Length);
Target.Last := Source.Last;
end return;
end Copy;
------------
-- Delete --
------------
procedure Delete
(Container : in out Vector;
Index : Extended_Index;
Count : Count_Type := 1)
is
Old_Last : constant Index_Type'Base := Container.Last;
Old_Len : constant Count_Type := Container.Length;
New_Last : Index_Type'Base;
Count2 : Count_Type'Base; -- count of items from Index to Old_Last
Off : Count_Type'Base; -- Index expressed as offset from IT'First
begin
TC_Check (Container.TC);
-- Delete removes items from the vector, the number of which is the
-- minimum of the specified Count and the items (if any) that exist from
-- Index to Container.Last. There are no constraints on the specified
-- value of Count (it can be larger than what's available at this
-- position in the vector, for example), but there are constraints on
-- the allowed values of the Index.
-- As a precondition on the generic actual Index_Type, the base type
-- must include Index_Type'Pred (Index_Type'First); this is the value
-- that Container.Last assumes when the vector is empty. However, we do
-- not allow that as the value for Index when specifying which items
-- should be deleted, so we must manually check. (That the user is
-- allowed to specify the value at all here is a consequence of the
-- declaration of the Extended_Index subtype, which includes the values
-- in the base range that immediately precede and immediately follow the
-- values in the Index_Type.)
if Checks and then Index < Index_Type'First then
raise Constraint_Error with "Index is out of range (too small)";
end if;
-- We do allow a value greater than Container.Last to be specified as
-- the Index, but only if it's immediately greater. This allows the
-- corner case of deleting no items from the back end of the vector to
-- be treated as a no-op. (It is assumed that specifying an index value
-- greater than Last + 1 indicates some deeper flaw in the caller's
-- algorithm, so that case is treated as a proper error.)
if Index > Old_Last then
if Checks and then Index > Old_Last + 1 then
raise Constraint_Error with "Index is out of range (too large)";
end if;
return;
end if;
-- Here and elsewhere we treat deleting 0 items from the container as a
-- no-op, even when the container is busy, so we simply return.
if Count = 0 then
return;
end if;
-- The tampering bits exist to prevent an item from being deleted (or
-- otherwise harmfully manipulated) while it is being visited. Query,
-- Update, and Iterate increment the busy count on entry, and decrement
-- the count on exit. Delete checks the count to determine whether it is
-- being called while the associated callback procedure is executing.
-- We first calculate what's available for deletion starting at
-- Index. Here and elsewhere we use the wider of Index_Type'Base and
-- Count_Type'Base as the type for intermediate values. (See function
-- Length for more information.)
if Count_Type'Base'Last >= Index_Type'Pos (Index_Type'Base'Last) then
Count2 := Count_Type'Base (Old_Last) - Count_Type'Base (Index) + 1;
else
Count2 := Count_Type'Base (Old_Last - Index + 1);
end if;
-- If more elements are requested (Count) for deletion than are
-- available (Count2) for deletion beginning at Index, then everything
-- from Index is deleted. There are no elements to slide down, and so
-- all we need to do is set the value of Container.Last.
if Count >= Count2 then
Container.Last := Index - 1;
return;
end if;
-- There are some elements aren't being deleted (the requested count was
-- less than the available count), so we must slide them down to
-- Index. We first calculate the index values of the respective array
-- slices, using the wider of Index_Type'Base and Count_Type'Base as the
-- type for intermediate calculations.
if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then
Off := Count_Type'Base (Index - Index_Type'First);
New_Last := Old_Last - Index_Type'Base (Count);
else
Off := Count_Type'Base (Index) - Count_Type'Base (Index_Type'First);
New_Last := Index_Type'Base (Count_Type'Base (Old_Last) - Count);
end if;
-- The array index values for each slice have already been determined,
-- so we just slide down to Index the elements that weren't deleted.
declare
EA : Elements_Array renames Container.Elements;
Idx : constant Count_Type := EA'First + Off;
begin
EA (Idx .. Old_Len - Count) := EA (Idx + Count .. Old_Len);
Container.Last := New_Last;
end;
end Delete;
procedure Delete
(Container : in out Vector;
Position : in out Cursor;
Count : Count_Type := 1)
is
pragma Warnings (Off, Position);
begin
if Checks and then Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with "Position cursor denotes wrong container";
end if;
if Checks and then Position.Index > Container.Last then
raise Program_Error with "Position index is out of range";
end if;
Delete (Container, Position.Index, Count);
Position := No_Element;
end Delete;
------------------
-- Delete_First --
------------------
procedure Delete_First
(Container : in out Vector;
Count : Count_Type := 1)
is
begin
if Count = 0 then
return;
elsif Count >= Length (Container) then
Clear (Container);
return;
else
Delete (Container, Index_Type'First, Count);
end if;
end Delete_First;
-----------------
-- Delete_Last --
-----------------
procedure Delete_Last
(Container : in out Vector;
Count : Count_Type := 1)
is
begin
-- The tampering bits exist to prevent an item from being deleted (or
-- otherwise harmfully manipulated) while it is being visited. Query,
-- Update, and Iterate increment the busy count on entry, and decrement
-- the count on exit. Delete_Last checks the count to determine whether
-- it is being called while the associated callback procedure is
-- executing.
TC_Check (Container.TC);
if Count = 0 then
return;
end if;
-- There is no restriction on how large Count can be when deleting
-- items. If it is equal or greater than the current length, then this
-- is equivalent to clearing the vector. (In particular, there's no need
-- for us to actually calculate the new value for Last.)
-- If the requested count is less than the current length, then we must
-- calculate the new value for Last. For the type we use the widest of
-- Index_Type'Base and Count_Type'Base for the intermediate values of
-- our calculation. (See the comments in Length for more information.)
if Count >= Container.Length then
Container.Last := No_Index;
elsif Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then
Container.Last := Container.Last - Index_Type'Base (Count);
else
Container.Last :=
Index_Type'Base (Count_Type'Base (Container.Last) - Count);
end if;
end Delete_Last;
-------------
-- Element --
-------------
function Element
(Container : Vector;
Index : Index_Type) return Element_Type
is
begin
if Checks and then Index > Container.Last then
raise Constraint_Error with "Index is out of range";
else
return Container.Elements (To_Array_Index (Index));
end if;
end Element;
function Element (Position : Cursor) return Element_Type is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
else
return Position.Container.Element (Position.Index);
end if;
end Element;
-----------
-- Empty --
-----------
function Empty (Capacity : Count_Type := 10) return Vector is
begin
return Result : Vector (Capacity) do
Reserve_Capacity (Result, Capacity);
end return;
end Empty;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Iterator) is
begin
Unbusy (Object.Container.TC);
end Finalize;
----------
-- Find --
----------
function Find
(Container : Vector;
Item : Element_Type;
Position : Cursor := No_Element) return Cursor
is
begin
if Position.Container /= null then
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with "Position cursor denotes wrong container";
end if;
if Checks and then Position.Index > Container.Last then
raise Program_Error with "Position index is out of range";
end if;
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock : With_Lock (Container.TC'Unrestricted_Access);
begin
for J in Position.Index .. Container.Last loop
if Container.Elements (To_Array_Index (J)) = Item then
return Cursor'(Container'Unrestricted_Access, J);
end if;
end loop;
return No_Element;
end;
end Find;
----------------
-- Find_Index --
----------------
function Find_Index
(Container : Vector;
Item : Element_Type;
Index : Index_Type := Index_Type'First) return Extended_Index
is
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
Lock : With_Lock (Container.TC'Unrestricted_Access);
begin
for Indx in Index .. Container.Last loop
if Container.Elements (To_Array_Index (Indx)) = Item then
return Indx;
end if;
end loop;
return No_Index;
end Find_Index;
-----------
-- First --
-----------
function First (Container : Vector) return Cursor is
begin
if Is_Empty (Container) then
return No_Element;
else
return (Container'Unrestricted_Access, Index_Type'First);
end if;
end First;
function First (Object : Iterator) return Cursor is
begin
-- The value of the iterator object's Index component influences the
-- behavior of the First (and Last) selector function.
-- When the Index component is No_Index, this means the iterator
-- object was constructed without a start expression, in which case the
-- (forward) iteration starts from the (logical) beginning of the entire
-- sequence of items (corresponding to Container.First, for a forward
-- iterator).
-- Otherwise, this is iteration over a partial sequence of items.
-- When the Index component isn't No_Index, the iterator object was
-- constructed with a start expression, that specifies the position
-- from which the (forward) partial iteration begins.
if Object.Index = No_Index then
return First (Object.Container.all);
else
return Cursor'(Object.Container, Object.Index);
end if;
end First;
-------------------
-- First_Element --
-------------------
function First_Element (Container : Vector) return Element_Type is
begin
if Checks and then Container.Last = No_Index then
raise Constraint_Error with "Container is empty";
end if;
return Container.Elements (To_Array_Index (Index_Type'First));
end First_Element;
-----------------
-- First_Index --
-----------------
function First_Index (Container : Vector) return Index_Type is
pragma Unreferenced (Container);
begin
return Index_Type'First;
end First_Index;
-----------------
-- New_Vector --
-----------------
function New_Vector (First, Last : Index_Type) return Vector
is
begin
return (To_Vector (Count_Type (Last - First + 1)));
end New_Vector;
---------------------
-- Generic_Sorting --
---------------------
package body Generic_Sorting is
---------------
-- Is_Sorted --
---------------
function Is_Sorted (Container : Vector) return Boolean is
begin
if Container.Last <= Index_Type'First then
return True;
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock : With_Lock (Container.TC'Unrestricted_Access);
EA : Elements_Array renames Container.Elements;
begin
for J in 1 .. Container.Length - 1 loop
if EA (J + 1) < EA (J) then
return False;
end if;
end loop;
return True;
end;
end Is_Sorted;
-----------
-- Merge --
-----------
procedure Merge (Target, Source : in out Vector) is
I, J : Count_Type;
begin
-- The semantics of Merge changed slightly per AI05-0021. It was
-- originally the case that if Target and Source denoted the same
-- container object, then the GNAT implementation of Merge did
-- nothing. However, it was argued that RM05 did not precisely
-- specify the semantics for this corner case. The decision of the
-- ARG was that if Target and Source denote the same non-empty
-- container object, then Program_Error is raised.
if Source.Is_Empty then
return;
end if;
TC_Check (Source.TC);
if Checks and then Target'Address = Source'Address then
raise Program_Error with
"Target and Source denote same non-empty container";
end if;
if Target.Is_Empty then
Move (Target => Target, Source => Source);
return;
end if;
I := Target.Length;
Target.Set_Length (I + Source.Length);
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
TA : Elements_Array renames Target.Elements;
SA : Elements_Array renames Source.Elements;
Lock_Target : With_Lock (Target.TC'Unchecked_Access);
Lock_Source : With_Lock (Source.TC'Unchecked_Access);
begin
J := Target.Length;
while not Source.Is_Empty loop
pragma Assert (Source.Length <= 1
or else not (SA (Source.Length) < SA (Source.Length - 1)));
if I = 0 then
TA (1 .. J) := SA (1 .. Source.Length);
Source.Last := No_Index;
exit;
end if;
pragma Assert (I <= 1
or else not (TA (I) < TA (I - 1)));
if SA (Source.Length) < TA (I) then
TA (J) := TA (I);
I := I - 1;
else
TA (J) := SA (Source.Length);
Source.Last := Source.Last - 1;
end if;
J := J - 1;
end loop;
end;
end Merge;
----------
-- Sort --
----------
procedure Sort (Container : in out Vector) is
procedure Sort is
new Generic_Array_Sort
(Index_Type => Count_Type,
Element_Type => Element_Type,
Array_Type => Elements_Array,
"<" => "<");
begin
if Container.Last <= Index_Type'First then
return;
end if;
-- The exception behavior for the vector container must match that
-- for the list container, so we check for cursor tampering here
-- (which will catch more things) instead of for element tampering
-- (which will catch fewer things). It's true that the elements of
-- this vector container could be safely moved around while (say) an
-- iteration is taking place (iteration only increments the busy
-- counter), and so technically all we would need here is a test for
-- element tampering (indicated by the lock counter), that's simply
-- an artifact of our array-based implementation. Logically Sort
-- requires a check for cursor tampering.
TC_Check (Container.TC);
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock : With_Lock (Container.TC'Unchecked_Access);
begin
Sort (Container.Elements (1 .. Container.Length));
end;
end Sort;
end Generic_Sorting;
------------------------
-- Get_Element_Access --
------------------------
function Get_Element_Access
(Position : Cursor) return not null Element_Access is
begin
return Position.Container.Elements
(To_Array_Index (Position.Index))'Access;
end Get_Element_Access;
-----------------
-- Has_Element --
-----------------
function Has_Element (Position : Cursor) return Boolean is
begin
if Position.Container = null then
return False;
end if;
return Position.Index <= Position.Container.Last;
end Has_Element;
------------
-- Insert --
------------
procedure Insert
(Container : in out Vector;
Before : Extended_Index;
New_Item : Element_Type;
Count : Count_Type := 1)
is
EA : Elements_Array renames Container.Elements;
Old_Length : constant Count_Type := Container.Length;
Max_Length : Count_Type'Base; -- determined from range of Index_Type
New_Length : Count_Type'Base; -- sum of current length and Count
Index : Index_Type'Base; -- scratch for intermediate values
J : Count_Type'Base; -- scratch
begin
-- The tampering bits exist to prevent an item from being harmfully
-- manipulated while it is being visited. Query, Update, and Iterate
-- increment the busy count on entry, and decrement the count on
-- exit. Insert checks the count to determine whether it is being called
-- while the associated callback procedure is executing.
TC_Check (Container.TC);
-- As a precondition on the generic actual Index_Type, the base type
-- must include Index_Type'Pred (Index_Type'First); this is the value
-- that Container.Last assumes when the vector is empty. However, we do
-- not allow that as the value for Index when specifying where the new
-- items should be inserted, so we must manually check. (That the user
-- is allowed to specify the value at all here is a consequence of the
-- declaration of the Extended_Index subtype, which includes the values
-- in the base range that immediately precede and immediately follow the
-- values in the Index_Type.)
if Checks and then Before < Index_Type'First then
raise Constraint_Error with
"Before index is out of range (too small)";
end if;
-- We do allow a value greater than Container.Last to be specified as
-- the Index, but only if it's immediately greater. This allows for the
-- case of appending items to the back end of the vector. (It is assumed
-- that specifying an index value greater than Last + 1 indicates some
-- deeper flaw in the caller's algorithm, so that case is treated as a
-- proper error.)
if Checks and then Before > Container.Last
and then Before > Container.Last + 1
then
raise Constraint_Error with
"Before index is out of range (too large)";
end if;
-- We treat inserting 0 items into the container as a no-op, even when
-- the container is busy, so we simply return.
if Count = 0 then
return;
end if;
-- There are two constraints we need to satisfy. The first constraint is
-- that a container cannot have more than Count_Type'Last elements, so
-- we must check the sum of the current length and the insertion
-- count. Note that we cannot simply add these values, because of the
-- possibility of overflow.
if Checks and then Old_Length > Count_Type'Last - Count then
raise Constraint_Error with "Count is out of range";
end if;
-- It is now safe compute the length of the new vector, without fear of
-- overflow.
New_Length := Old_Length + Count;
-- The second constraint is that the new Last index value cannot exceed
-- Index_Type'Last. In each branch below, we calculate the maximum
-- length (computed from the range of values in Index_Type), and then
-- compare the new length to the maximum length. If the new length is
-- acceptable, then we compute the new last index from that.
if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then
-- We have to handle the case when there might be more values in the
-- range of Index_Type than in the range of Count_Type.
if Index_Type'First <= 0 then
-- We know that No_Index (the same as Index_Type'First - 1) is
-- less than 0, so it is safe to compute the following sum without
-- fear of overflow.
Index := No_Index + Index_Type'Base (Count_Type'Last);
if Index <= Index_Type'Last then
-- We have determined that range of Index_Type has at least as
-- many values as in Count_Type, so Count_Type'Last is the
-- maximum number of items that are allowed.
Max_Length := Count_Type'Last;
else
-- The range of Index_Type has fewer values than in Count_Type,
-- so the maximum number of items is computed from the range of
-- the Index_Type.
Max_Length := Count_Type'Base (Index_Type'Last - No_Index);
end if;
else
-- No_Index is equal or greater than 0, so we can safely compute
-- the difference without fear of overflow (which we would have to
-- worry about if No_Index were less than 0, but that case is
-- handled above).
if Index_Type'Last - No_Index >=
Count_Type'Pos (Count_Type'Last)
then
-- We have determined that range of Index_Type has at least as
-- many values as in Count_Type, so Count_Type'Last is the
-- maximum number of items that are allowed.
Max_Length := Count_Type'Last;
else
-- The range of Index_Type has fewer values than in Count_Type,
-- so the maximum number of items is computed from the range of
-- the Index_Type.
Max_Length := Count_Type'Base (Index_Type'Last - No_Index);
end if;
end if;
elsif Index_Type'First <= 0 then
-- We know that No_Index (the same as Index_Type'First - 1) is less
-- than 0, so it is safe to compute the following sum without fear of
-- overflow.
J := Count_Type'Base (No_Index) + Count_Type'Last;
if J <= Count_Type'Base (Index_Type'Last) then
-- We have determined that range of Index_Type has at least as
-- many values as in Count_Type, so Count_Type'Last is the maximum
-- number of items that are allowed.
Max_Length := Count_Type'Last;
else
-- The range of Index_Type has fewer values than Count_Type does,
-- so the maximum number of items is computed from the range of
-- the Index_Type.
Max_Length :=
Count_Type'Base (Index_Type'Last) - Count_Type'Base (No_Index);
end if;
else
-- No_Index is equal or greater than 0, so we can safely compute the
-- difference without fear of overflow (which we would have to worry
-- about if No_Index were less than 0, but that case is handled
-- above).
Max_Length :=
Count_Type'Base (Index_Type'Last) - Count_Type'Base (No_Index);
end if;
-- We have just computed the maximum length (number of items). We must
-- now compare the requested length to the maximum length, as we do not
-- allow a vector expand beyond the maximum (because that would create
-- an internal array with a last index value greater than
-- Index_Type'Last, with no way to index those elements).
if Checks and then New_Length > Max_Length then
raise Constraint_Error with "Count is out of range";
end if;
if Checks and then New_Length > Container.Capacity then
raise Capacity_Error with "New length is larger than capacity";
end if;
J := To_Array_Index (Before);
if Before > Container.Last then
-- The new items are being appended to the vector, so no
-- sliding of existing elements is required.
EA (J .. New_Length) := [others => New_Item];
else
-- The new items are being inserted before some existing
-- elements, so we must slide the existing elements up to their
-- new home.
EA (J + Count .. New_Length) := EA (J .. Old_Length);
EA (J .. J + Count - 1) := [others => New_Item];
end if;
if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then
Container.Last := No_Index + Index_Type'Base (New_Length);
else
Container.Last :=
Index_Type'Base (Count_Type'Base (No_Index) + New_Length);
end if;
end Insert;
procedure Insert_Vector
(Container : in out Vector;
Before : Extended_Index;
New_Item : Vector)
is
N : constant Count_Type := Length (New_Item);
B : Count_Type; -- index Before converted to Count_Type
begin
-- Use Insert_Space to create the "hole" (the destination slice) into
-- which we copy the source items.
Insert_Space (Container, Before, Count => N);
if N = 0 then
-- There's nothing else to do here (vetting of parameters was
-- performed already in Insert_Space), so we simply return.
return;
end if;
B := To_Array_Index (Before);
if Container'Address /= New_Item'Address then
-- This is the simple case. New_Item denotes an object different
-- from Container, so there's nothing special we need to do to copy
-- the source items to their destination, because all of the source
-- items are contiguous.
Container.Elements (B .. B + N - 1) := New_Item.Elements (1 .. N);
return;
end if;
-- We refer to array index value Before + N - 1 as J. This is the last
-- index value of the destination slice.
-- New_Item denotes the same object as Container, so an insertion has
-- potentially split the source items. The destination is always the
-- range [Before, J], but the source is [Index_Type'First, Before) and
-- (J, Container.Last]. We perform the copy in two steps, using each of
-- the two slices of the source items.
declare
subtype Src_Index_Subtype is Count_Type'Base range 1 .. B - 1;
Src : Elements_Array renames Container.Elements (Src_Index_Subtype);
begin
-- We first copy the source items that precede the space we
-- inserted. (If Before equals Index_Type'First, then this first
-- source slice will be empty, which is harmless.)
Container.Elements (B .. B + Src'Length - 1) := Src;
end;
declare
subtype Src_Index_Subtype is Count_Type'Base range
B + N .. Container.Length;
Src : Elements_Array renames Container.Elements (Src_Index_Subtype);
begin
-- We next copy the source items that follow the space we inserted.
Container.Elements (B + N - Src'Length .. B + N - 1) := Src;
end;
end Insert_Vector;
procedure Insert_Vector
(Container : in out Vector;
Before : Cursor;
New_Item : Vector)
is
Index : Index_Type'Base;
begin
if Checks and then Before.Container /= null
and then Before.Container /= Container'Unchecked_Access
then
raise Program_Error with "Before cursor denotes wrong container";
end if;
if Is_Empty (New_Item) then
return;
end if;
if Before.Container = null
or else Before.Index > Container.Last
then
if Checks and then Container.Last = Index_Type'Last then
raise Constraint_Error with
"vector is already at its maximum length";
end if;
Index := Container.Last + 1;
else
Index := Before.Index;
end if;
Insert_Vector (Container, Index, New_Item);
end Insert_Vector;
procedure Insert_Vector
(Container : in out Vector;
Before : Cursor;
New_Item : Vector;
Position : out Cursor)
is
Index : Index_Type'Base;
begin
if Checks and then Before.Container /= null
and then Before.Container /= Container'Unchecked_Access
then
raise Program_Error with "Before cursor denotes wrong container";
end if;
if Is_Empty (New_Item) then
if Before.Container = null
or else Before.Index > Container.Last
then
Position := No_Element;
else
Position := (Container'Unchecked_Access, Before.Index);
end if;
return;
end if;
if Before.Container = null
or else Before.Index > Container.Last
then
if Checks and then Container.Last = Index_Type'Last then
raise Constraint_Error with
"vector is already at its maximum length";
end if;
Index := Container.Last + 1;
else
Index := Before.Index;
end if;
Insert_Vector (Container, Index, New_Item);
Position := Cursor'(Container'Unchecked_Access, Index);
end Insert_Vector;
procedure Insert
(Container : in out Vector;
Before : Cursor;
New_Item : Element_Type;
Count : Count_Type := 1)
is
Index : Index_Type'Base;
begin
if Checks and then Before.Container /= null
and then Before.Container /= Container'Unchecked_Access
then
raise Program_Error with "Before cursor denotes wrong container";
end if;
if Count = 0 then
return;
end if;
if Before.Container = null
or else Before.Index > Container.Last
then
if Checks and then Container.Last = Index_Type'Last then
raise Constraint_Error with
"vector is already at its maximum length";
end if;
Index := Container.Last + 1;
else
Index := Before.Index;
end if;
Insert (Container, Index, New_Item, Count);
end Insert;
procedure Insert
(Container : in out Vector;
Before : Cursor;
New_Item : Element_Type;
Position : out Cursor;
Count : Count_Type := 1)
is
Index : Index_Type'Base;
begin
if Checks and then Before.Container /= null
and then Before.Container /= Container'Unchecked_Access
then
raise Program_Error with "Before cursor denotes wrong container";
end if;
if Count = 0 then
if Before.Container = null
or else Before.Index > Container.Last
then
Position := No_Element;
else
Position := (Container'Unchecked_Access, Before.Index);
end if;
return;
end if;
if Before.Container = null
or else Before.Index > Container.Last
then
if Checks and then Container.Last = Index_Type'Last then
raise Constraint_Error with
"vector is already at its maximum length";
end if;
Index := Container.Last + 1;
else
Index := Before.Index;
end if;
Insert (Container, Index, New_Item, Count);
Position := Cursor'(Container'Unchecked_Access, Index);
end Insert;
procedure Insert
(Container : in out Vector;
Before : Extended_Index;
Count : Count_Type := 1)
is
New_Item : Element_Type; -- Default-initialized value
pragma Warnings (Off, New_Item);
begin
Insert (Container, Before, New_Item, Count);
end Insert;
procedure Insert
(Container : in out Vector;
Before : Cursor;
Position : out Cursor;
Count : Count_Type := 1)
is
New_Item : Element_Type; -- Default-initialized value
pragma Warnings (Off, New_Item);
begin
Insert (Container, Before, New_Item, Position, Count);
end Insert;
------------------
-- Insert_Space --
------------------
procedure Insert_Space
(Container : in out Vector;
Before : Extended_Index;
Count : Count_Type := 1)
is
EA : Elements_Array renames Container.Elements;
Old_Length : constant Count_Type := Container.Length;
Max_Length : Count_Type'Base; -- determined from range of Index_Type
New_Length : Count_Type'Base; -- sum of current length and Count
Index : Index_Type'Base; -- scratch for intermediate values
J : Count_Type'Base; -- scratch
begin
-- The tampering bits exist to prevent an item from being harmfully
-- manipulated while it is being visited. Query, Update, and Iterate
-- increment the busy count on entry, and decrement the count on
-- exit. Insert checks the count to determine whether it is being called
-- while the associated callback procedure is executing.
TC_Check (Container.TC);
-- As a precondition on the generic actual Index_Type, the base type
-- must include Index_Type'Pred (Index_Type'First); this is the value
-- that Container.Last assumes when the vector is empty. However, we do
-- not allow that as the value for Index when specifying where the new
-- items should be inserted, so we must manually check. (That the user
-- is allowed to specify the value at all here is a consequence of the
-- declaration of the Extended_Index subtype, which includes the values
-- in the base range that immediately precede and immediately follow the
-- values in the Index_Type.)
if Checks and then Before < Index_Type'First then
raise Constraint_Error with
"Before index is out of range (too small)";
end if;
-- We do allow a value greater than Container.Last to be specified as
-- the Index, but only if it's immediately greater. This allows for the
-- case of appending items to the back end of the vector. (It is assumed
-- that specifying an index value greater than Last + 1 indicates some
-- deeper flaw in the caller's algorithm, so that case is treated as a
-- proper error.)
if Checks and then Before > Container.Last
and then Before > Container.Last + 1
then
raise Constraint_Error with
"Before index is out of range (too large)";
end if;
-- We treat inserting 0 items into the container as a no-op, even when
-- the container is busy, so we simply return.
if Count = 0 then
return;
end if;
-- There are two constraints we need to satisfy. The first constraint is
-- that a container cannot have more than Count_Type'Last elements, so
-- we must check the sum of the current length and the insertion count.
-- Note that we cannot simply add these values, because of the
-- possibility of overflow.
if Checks and then Old_Length > Count_Type'Last - Count then
raise Constraint_Error with "Count is out of range";
end if;
-- It is now safe compute the length of the new vector, without fear of
-- overflow.
New_Length := Old_Length + Count;
-- The second constraint is that the new Last index value cannot exceed
-- Index_Type'Last. In each branch below, we calculate the maximum
-- length (computed from the range of values in Index_Type), and then
-- compare the new length to the maximum length. If the new length is
-- acceptable, then we compute the new last index from that.
if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then
-- We have to handle the case when there might be more values in the
-- range of Index_Type than in the range of Count_Type.
if Index_Type'First <= 0 then
-- We know that No_Index (the same as Index_Type'First - 1) is
-- less than 0, so it is safe to compute the following sum without
-- fear of overflow.
Index := No_Index + Index_Type'Base (Count_Type'Last);
if Index <= Index_Type'Last then
-- We have determined that range of Index_Type has at least as
-- many values as in Count_Type, so Count_Type'Last is the
-- maximum number of items that are allowed.
Max_Length := Count_Type'Last;
else
-- The range of Index_Type has fewer values than in Count_Type,
-- so the maximum number of items is computed from the range of
-- the Index_Type.
Max_Length := Count_Type'Base (Index_Type'Last - No_Index);
end if;
else
-- No_Index is equal or greater than 0, so we can safely compute
-- the difference without fear of overflow (which we would have to
-- worry about if No_Index were less than 0, but that case is
-- handled above).
if Index_Type'Last - No_Index >=
Count_Type'Pos (Count_Type'Last)
then
-- We have determined that range of Index_Type has at least as
-- many values as in Count_Type, so Count_Type'Last is the
-- maximum number of items that are allowed.
Max_Length := Count_Type'Last;
else
-- The range of Index_Type has fewer values than in Count_Type,
-- so the maximum number of items is computed from the range of
-- the Index_Type.
Max_Length := Count_Type'Base (Index_Type'Last - No_Index);
end if;
end if;
elsif Index_Type'First <= 0 then
-- We know that No_Index (the same as Index_Type'First - 1) is less
-- than 0, so it is safe to compute the following sum without fear of
-- overflow.
J := Count_Type'Base (No_Index) + Count_Type'Last;
if J <= Count_Type'Base (Index_Type'Last) then
-- We have determined that range of Index_Type has at least as
-- many values as in Count_Type, so Count_Type'Last is the maximum
-- number of items that are allowed.
Max_Length := Count_Type'Last;
else
-- The range of Index_Type has fewer values than Count_Type does,
-- so the maximum number of items is computed from the range of
-- the Index_Type.
Max_Length :=
Count_Type'Base (Index_Type'Last) - Count_Type'Base (No_Index);
end if;
else
-- No_Index is equal or greater than 0, so we can safely compute the
-- difference without fear of overflow (which we would have to worry
-- about if No_Index were less than 0, but that case is handled
-- above).
Max_Length :=
Count_Type'Base (Index_Type'Last) - Count_Type'Base (No_Index);
end if;
-- We have just computed the maximum length (number of items). We must
-- now compare the requested length to the maximum length, as we do not
-- allow a vector expand beyond the maximum (because that would create
-- an internal array with a last index value greater than
-- Index_Type'Last, with no way to index those elements).
if Checks and then New_Length > Max_Length then
raise Constraint_Error with "Count is out of range";
end if;
-- An internal array has already been allocated, so we need to check
-- whether there is enough unused storage for the new items.
if Checks and then New_Length > Container.Capacity then
raise Capacity_Error with "New length is larger than capacity";
end if;
-- In this case, we're inserting space into a vector that has already
-- allocated an internal array, and the existing array has enough
-- unused storage for the new items.
if Before <= Container.Last then
-- The space is being inserted before some existing elements,
-- so we must slide the existing elements up to their new home.
J := To_Array_Index (Before);
EA (J + Count .. New_Length) := EA (J .. Old_Length);
end if;
-- New_Last is the last index value of the items in the container after
-- insertion. Use the wider of Index_Type'Base and Count_Type'Base to
-- compute its value from the New_Length.
if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then
Container.Last := No_Index + Index_Type'Base (New_Length);
else
Container.Last :=
Index_Type'Base (Count_Type'Base (No_Index) + New_Length);
end if;
end Insert_Space;
procedure Insert_Space
(Container : in out Vector;
Before : Cursor;
Position : out Cursor;
Count : Count_Type := 1)
is
Index : Index_Type'Base;
begin
if Checks and then Before.Container /= null
and then Before.Container /= Container'Unchecked_Access
then
raise Program_Error with "Before cursor denotes wrong container";
end if;
if Count = 0 then
if Before.Container = null
or else Before.Index > Container.Last
then
Position := No_Element;
else
Position := (Container'Unchecked_Access, Before.Index);
end if;
return;
end if;
if Before.Container = null
or else Before.Index > Container.Last
then
if Checks and then Container.Last = Index_Type'Last then
raise Constraint_Error with
"vector is already at its maximum length";
end if;
Index := Container.Last + 1;
else
Index := Before.Index;
end if;
Insert_Space (Container, Index, Count => Count);
Position := Cursor'(Container'Unchecked_Access, Index);
end Insert_Space;
--------------
-- Is_Empty --
--------------
function Is_Empty (Container : Vector) return Boolean is
begin
return Container.Last < Index_Type'First;
end Is_Empty;
-------------
-- Iterate --
-------------
procedure Iterate
(Container : Vector;
Process : not null access procedure (Position : Cursor))
is
Busy : With_Busy (Container.TC'Unrestricted_Access);
begin
for Indx in Index_Type'First .. Container.Last loop
Process (Cursor'(Container'Unrestricted_Access, Indx));
end loop;
end Iterate;
function Iterate
(Container : Vector)
return Vector_Iterator_Interfaces.Reversible_Iterator'Class
is
V : constant Vector_Access := Container'Unrestricted_Access;
begin
-- The value of its Index component influences the behavior of the First
-- and Last selector functions of the iterator object. When the Index
-- component is No_Index (as is the case here), this means the iterator
-- object was constructed without a start expression. This is a complete
-- iterator, meaning that the iteration starts from the (logical)
-- beginning of the sequence of items.
-- Note: For a forward iterator, Container.First is the beginning, and
-- for a reverse iterator, Container.Last is the beginning.
return It : constant Iterator :=
(Limited_Controlled with
Container => V,
Index => No_Index)
do
Busy (Container.TC'Unrestricted_Access.all);
end return;
end Iterate;
function Iterate
(Container : Vector;
Start : Cursor)
return Vector_Iterator_Interfaces.Reversible_Iterator'Class
is
V : constant Vector_Access := Container'Unrestricted_Access;
begin
-- It was formerly the case that when Start = No_Element, the partial
-- iterator was defined to behave the same as for a complete iterator,
-- and iterate over the entire sequence of items. However, those
-- semantics were unintuitive and arguably error-prone (it is too easy
-- to accidentally create an endless loop), and so they were changed,
-- per the ARG meeting in Denver on 2011/11. However, there was no
-- consensus about what positive meaning this corner case should have,
-- and so it was decided to simply raise an exception. This does imply,
-- however, that it is not possible to use a partial iterator to specify
-- an empty sequence of items.
if Checks and then Start.Container = null then
raise Constraint_Error with
"Start position for iterator equals No_Element";
end if;
if Checks and then Start.Container /= V then
raise Program_Error with
"Start cursor of Iterate designates wrong vector";
end if;
if Checks and then Start.Index > V.Last then
raise Constraint_Error with
"Start position for iterator equals No_Element";
end if;
-- The value of its Index component influences the behavior of the First
-- and Last selector functions of the iterator object. When the Index
-- component is not No_Index (as is the case here), it means that this
-- is a partial iteration, over a subset of the complete sequence of
-- items. The iterator object was constructed with a start expression,
-- indicating the position from which the iteration begins. Note that
-- the start position has the same value irrespective of whether this is
-- a forward or reverse iteration.
return It : constant Iterator :=
(Limited_Controlled with
Container => V,
Index => Start.Index)
do
Busy (Container.TC'Unrestricted_Access.all);
end return;
end Iterate;
----------
-- Last --
----------
function Last (Container : Vector) return Cursor is
begin
if Is_Empty (Container) then
return No_Element;
else
return (Container'Unrestricted_Access, Container.Last);
end if;
end Last;
function Last (Object : Iterator) return Cursor is
begin
-- The value of the iterator object's Index component influences the
-- behavior of the Last (and First) selector function.
-- When the Index component is No_Index, this means the iterator object
-- was constructed without a start expression, in which case the
-- (reverse) iteration starts from the (logical) beginning of the entire
-- sequence (corresponding to Container.Last, for a reverse iterator).
-- Otherwise, this is iteration over a partial sequence of items. When
-- the Index component is not No_Index, the iterator object was
-- constructed with a start expression, that specifies the position from
-- which the (reverse) partial iteration begins.
if Object.Index = No_Index then
return Last (Object.Container.all);
else
return Cursor'(Object.Container, Object.Index);
end if;
end Last;
------------------
-- Last_Element --
------------------
function Last_Element (Container : Vector) return Element_Type is
begin
if Checks and then Container.Last = No_Index then
raise Constraint_Error with "Container is empty";
end if;
return Container.Elements (Container.Length);
end Last_Element;
----------------
-- Last_Index --
----------------
function Last_Index (Container : Vector) return Extended_Index is
begin
return Container.Last;
end Last_Index;
------------
-- Length --
------------
function Length (Container : Vector) return Count_Type is
L : constant Index_Type'Base := Container.Last;
F : constant Index_Type := Index_Type'First;
begin
-- The base range of the index type (Index_Type'Base) might not include
-- all values for length (Count_Type). Contrariwise, the index type
-- might include values outside the range of length. Hence we use
-- whatever type is wider for intermediate values when calculating
-- length. Note that no matter what the index type is, the maximum
-- length to which a vector is allowed to grow is always the minimum
-- of Count_Type'Last and (IT'Last - IT'First + 1).
-- For example, an Index_Type with range -127 .. 127 is only guaranteed
-- to have a base range of -128 .. 127, but the corresponding vector
-- would have lengths in the range 0 .. 255. In this case we would need
-- to use Count_Type'Base for intermediate values.
-- Another case would be the index range -2**63 + 1 .. -2**63 + 10. The
-- vector would have a maximum length of 10, but the index values lie
-- outside the range of Count_Type (which is only 32 bits). In this
-- case we would need to use Index_Type'Base for intermediate values.
if Count_Type'Base'Last >= Index_Type'Pos (Index_Type'Base'Last) then
return Count_Type'Base (L) - Count_Type'Base (F) + 1;
else
return Count_Type (L - F + 1);
end if;
end Length;
----------
-- Move --
----------
procedure Move
(Target : in out Vector;
Source : in out Vector)
is
begin
if Target'Address = Source'Address then
return;
end if;
TC_Check (Target.TC);
TC_Check (Source.TC);
if Checks and then Target.Capacity < Source.Length then
raise Capacity_Error -- ???
with "Target capacity is less than Source length";
end if;
-- Clear Target now, in case element assignment fails
Target.Last := No_Index;
Target.Elements (1 .. Source.Length) :=
Source.Elements (1 .. Source.Length);
Target.Last := Source.Last;
Source.Last := No_Index;
end Move;
----------
-- Next --
----------
function Next (Position : Cursor) return Cursor is
begin
if Position.Container = null then
return No_Element;
elsif Position.Index < Position.Container.Last then
return (Position.Container, Position.Index + 1);
else
return No_Element;
end if;
end Next;
function Next (Object : Iterator; Position : Cursor) return Cursor is
begin
if Position.Container = null then
return No_Element;
end if;
if Checks and then Position.Container /= Object.Container then
raise Program_Error with
"Position cursor of Next designates wrong vector";
end if;
return Next (Position);
end Next;
procedure Next (Position : in out Cursor) is
begin
if Position.Container = null then
return;
elsif Position.Index < Position.Container.Last then
Position.Index := Position.Index + 1;
else
Position := No_Element;
end if;
end Next;
-------------
-- Prepend --
-------------
procedure Prepend
(Container : in out Vector;
New_Item : Element_Type;
Count : Count_Type := 1)
is
begin
Insert (Container, Index_Type'First, New_Item, Count);
end Prepend;
--------------------
-- Prepend_Vector --
--------------------
procedure Prepend_Vector (Container : in out Vector; New_Item : Vector) is
begin
Insert_Vector (Container, Index_Type'First, New_Item);
end Prepend_Vector;
--------------
-- Previous --
--------------
procedure Previous (Position : in out Cursor) is
begin
if Position.Container = null then
return;
elsif Position.Index > Index_Type'First then
Position.Index := Position.Index - 1;
else
Position := No_Element;
end if;
end Previous;
function Previous (Position : Cursor) return Cursor is
begin
if Position.Container = null then
return No_Element;
elsif Position.Index > Index_Type'First then
return (Position.Container, Position.Index - 1);
else
return No_Element;
end if;
end Previous;
function Previous (Object : Iterator; Position : Cursor) return Cursor is
begin
if Position.Container = null then
return No_Element;
end if;
if Checks and then Position.Container /= Object.Container then
raise Program_Error with
"Position cursor of Previous designates wrong vector";
end if;
return Previous (Position);
end Previous;
----------------------
-- Pseudo_Reference --
----------------------
function Pseudo_Reference
(Container : aliased Vector'Class) return Reference_Control_Type
is
TC : constant Tamper_Counts_Access := Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Control_Type := (Controlled with TC) do
Busy (TC.all);
end return;
end Pseudo_Reference;
-------------------
-- Query_Element --
-------------------
procedure Query_Element
(Container : Vector;
Index : Index_Type;
Process : not null access procedure (Element : Element_Type))
is
Lock : With_Lock (Container.TC'Unrestricted_Access);
V : Vector renames Container'Unrestricted_Access.all;
begin
if Checks and then Index > Container.Last then
raise Constraint_Error with "Index is out of range";
end if;
Process (V.Elements (To_Array_Index (Index)));
end Query_Element;
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Element : Element_Type))
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
Query_Element (Position.Container.all, Position.Index, Process);
end Query_Element;
---------------
-- Put_Image --
---------------
procedure Put_Image
(S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : Vector)
is
First_Time : Boolean := True;
use System.Put_Images;
begin
Array_Before (S);
for X of V loop
if First_Time then
First_Time := False;
else
Simple_Array_Between (S);
end if;
Element_Type'Put_Image (S, X);
end loop;
Array_After (S);
end Put_Image;
----------
-- Read --
----------
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Container : out Vector)
is
Length : Count_Type'Base;
Last : Index_Type'Base := No_Index;
begin
Clear (Container);
Count_Type'Base'Read (Stream, Length);
Reserve_Capacity (Container, Capacity => Length);
for Idx in Count_Type range 1 .. Length loop
Last := Last + 1;
Element_Type'Read (Stream, Container.Elements (Idx));
Container.Last := Last;
end loop;
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Position : out Cursor)
is
begin
raise Program_Error with "attempt to stream vector cursor";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Item : out Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Read;
---------------
-- Reference --
---------------
function Reference
(Container : aliased in out Vector;
Position : Cursor) return Reference_Type
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with "Position cursor denotes wrong container";
end if;
if Checks and then Position.Index > Position.Container.Last then
raise Constraint_Error with "Position cursor is out of range";
end if;
declare
A : Elements_Array renames Container.Elements;
J : constant Count_Type := To_Array_Index (Position.Index);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Type :=
(Element => A (J)'Unchecked_Access,
Control => (Controlled with TC))
do
Busy (TC.all);
end return;
end;
end Reference;
function Reference
(Container : aliased in out Vector;
Index : Index_Type) return Reference_Type
is
begin
if Checks and then Index > Container.Last then
raise Constraint_Error with "Index is out of range";
end if;
declare
A : Elements_Array renames Container.Elements;
J : constant Count_Type := To_Array_Index (Index);
TC : constant Tamper_Counts_Access :=
Container.TC'Unrestricted_Access;
begin
return R : constant Reference_Type :=
(Element => A (J)'Unchecked_Access,
Control => (Controlled with TC))
do
Busy (TC.all);
end return;
end;
end Reference;
---------------------
-- Replace_Element --
---------------------
procedure Replace_Element
(Container : in out Vector;
Index : Index_Type;
New_Item : Element_Type)
is
begin
TE_Check (Container.TC);
if Checks and then Index > Container.Last then
raise Constraint_Error with "Index is out of range";
end if;
Container.Elements (To_Array_Index (Index)) := New_Item;
end Replace_Element;
procedure Replace_Element
(Container : in out Vector;
Position : Cursor;
New_Item : Element_Type)
is
begin
TE_Check (Container.TC);
if Checks and then Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with "Position cursor denotes wrong container";
end if;
if Checks and then Position.Index > Container.Last then
raise Constraint_Error with "Position cursor is out of range";
end if;
Container.Elements (To_Array_Index (Position.Index)) := New_Item;
end Replace_Element;
----------------------
-- Reserve_Capacity --
----------------------
procedure Reserve_Capacity
(Container : in out Vector;
Capacity : Count_Type)
is
begin
if Checks and then Capacity > Container.Capacity then
raise Capacity_Error with "Capacity is out of range";
end if;
end Reserve_Capacity;
----------------------
-- Reverse_Elements --
----------------------
procedure Reverse_Elements (Container : in out Vector) is
E : Elements_Array renames Container.Elements;
Idx : Count_Type;
Jdx : Count_Type;
begin
if Container.Length <= 1 then
return;
end if;
-- The exception behavior for the vector container must match that for
-- the list container, so we check for cursor tampering here (which will
-- catch more things) instead of for element tampering (which will catch
-- fewer things). It's true that the elements of this vector container
-- could be safely moved around while (say) an iteration is taking place
-- (iteration only increments the busy counter), and so technically
-- all we would need here is a test for element tampering (indicated
-- by the lock counter), that's simply an artifact of our array-based
-- implementation. Logically Reverse_Elements requires a check for
-- cursor tampering.
TC_Check (Container.TC);
Idx := 1;
Jdx := Container.Length;
while Idx < Jdx loop
declare
EI : constant Element_Type := E (Idx);
begin
E (Idx) := E (Jdx);
E (Jdx) := EI;
end;
Idx := Idx + 1;
Jdx := Jdx - 1;
end loop;
end Reverse_Elements;
------------------
-- Reverse_Find --
------------------
function Reverse_Find
(Container : Vector;
Item : Element_Type;
Position : Cursor := No_Element) return Cursor
is
Last : Index_Type'Base;
begin
if Checks and then Position.Container /= null
and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with "Position cursor denotes wrong container";
end if;
Last :=
(if Position.Container = null or else Position.Index > Container.Last
then Container.Last
else Position.Index);
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
declare
Lock : With_Lock (Container.TC'Unrestricted_Access);
begin
for Indx in reverse Index_Type'First .. Last loop
if Container.Elements (To_Array_Index (Indx)) = Item then
return Cursor'(Container'Unrestricted_Access, Indx);
end if;
end loop;
return No_Element;
end;
end Reverse_Find;
------------------------
-- Reverse_Find_Index --
------------------------
function Reverse_Find_Index
(Container : Vector;
Item : Element_Type;
Index : Index_Type := Index_Type'Last) return Extended_Index
is
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
Lock : With_Lock (Container.TC'Unrestricted_Access);
Last : constant Index_Type'Base :=
Index_Type'Min (Container.Last, Index);
begin
for Indx in reverse Index_Type'First .. Last loop
if Container.Elements (To_Array_Index (Indx)) = Item then
return Indx;
end if;
end loop;
return No_Index;
end Reverse_Find_Index;
---------------------
-- Reverse_Iterate --
---------------------
procedure Reverse_Iterate
(Container : Vector;
Process : not null access procedure (Position : Cursor))
is
Busy : With_Busy (Container.TC'Unrestricted_Access);
begin
for Indx in reverse Index_Type'First .. Container.Last loop
Process (Cursor'(Container'Unrestricted_Access, Indx));
end loop;
end Reverse_Iterate;
----------------
-- Set_Length --
----------------
procedure Set_Length (Container : in out Vector; Length : Count_Type) is
Count : constant Count_Type'Base := Container.Length - Length;
begin
-- Set_Length allows the user to set the length explicitly, instead of
-- implicitly as a side-effect of deletion or insertion. If the
-- requested length is less than the current length, this is equivalent
-- to deleting items from the back end of the vector. If the requested
-- length is greater than the current length, then this is equivalent to
-- inserting "space" (nonce items) at the end.
if Count >= 0 then
Container.Delete_Last (Count);
elsif Checks and then Container.Last >= Index_Type'Last then
raise Constraint_Error with "vector is already at its maximum length";
else
Container.Insert_Space (Container.Last + 1, -Count);
end if;
end Set_Length;
----------
-- Swap --
----------
procedure Swap (Container : in out Vector; I, J : Index_Type) is
E : Elements_Array renames Container.Elements;
begin
TE_Check (Container.TC);
if Checks and then I > Container.Last then
raise Constraint_Error with "I index is out of range";
end if;
if Checks and then J > Container.Last then
raise Constraint_Error with "J index is out of range";
end if;
if I = J then
return;
end if;
declare
EI_Copy : constant Element_Type := E (To_Array_Index (I));
begin
E (To_Array_Index (I)) := E (To_Array_Index (J));
E (To_Array_Index (J)) := EI_Copy;
end;
end Swap;
procedure Swap (Container : in out Vector; I, J : Cursor) is
begin
if Checks and then I.Container = null then
raise Constraint_Error with "I cursor has no element";
end if;
if Checks and then J.Container = null then
raise Constraint_Error with "J cursor has no element";
end if;
if Checks and then I.Container /= Container'Unrestricted_Access then
raise Program_Error with "I cursor denotes wrong container";
end if;
if Checks and then J.Container /= Container'Unrestricted_Access then
raise Program_Error with "J cursor denotes wrong container";
end if;
Swap (Container, I.Index, J.Index);
end Swap;
--------------------
-- To_Array_Index --
--------------------
function To_Array_Index (Index : Index_Type'Base) return Count_Type'Base is
Offset : Count_Type'Base;
begin
-- We know that
-- Index >= Index_Type'First
-- hence we also know that
-- Index - Index_Type'First >= 0
-- The issue is that even though 0 is guaranteed to be a value in
-- the type Index_Type'Base, there's no guarantee that the difference
-- is a value in that type. To prevent overflow we use the wider
-- of Count_Type'Base and Index_Type'Base to perform intermediate
-- calculations.
if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then
Offset := Count_Type'Base (Index - Index_Type'First);
else
Offset := Count_Type'Base (Index) -
Count_Type'Base (Index_Type'First);
end if;
-- The array index subtype for all container element arrays
-- always starts with 1.
return 1 + Offset;
end To_Array_Index;
---------------
-- To_Cursor --
---------------
function To_Cursor
(Container : Vector;
Index : Extended_Index) return Cursor
is
begin
if Index not in Index_Type'First .. Container.Last then
return No_Element;
end if;
return Cursor'(Container'Unrestricted_Access, Index);
end To_Cursor;
--------------
-- To_Index --
--------------
function To_Index (Position : Cursor) return Extended_Index is
begin
if Position.Container = null then
return No_Index;
end if;
if Position.Index <= Position.Container.Last then
return Position.Index;
end if;
return No_Index;
end To_Index;
---------------
-- To_Vector --
---------------
function To_Vector (Length : Count_Type) return Vector is
Index : Count_Type'Base;
Last : Index_Type'Base;
begin
if Length = 0 then
return Empty_Vector;
end if;
-- We create a vector object with a capacity that matches the specified
-- Length, but we do not allow the vector capacity (the length of the
-- internal array) to exceed the number of values in Index_Type'Range
-- (otherwise, there would be no way to refer to those components via an
-- index). We must therefore check whether the specified Length would
-- create a Last index value greater than Index_Type'Last.
if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then
-- We perform a two-part test. First we determine whether the
-- computed Last value lies in the base range of the type, and then
-- determine whether it lies in the range of the index (sub)type.
-- Last must satisfy this relation:
-- First + Length - 1 <= Last
-- We regroup terms:
-- First - 1 <= Last - Length
-- Which can rewrite as:
-- No_Index <= Last - Length
if Checks and then
Index_Type'Base'Last - Index_Type'Base (Length) < No_Index
then
raise Constraint_Error with "Length is out of range";
end if;
-- We now know that the computed value of Last is within the base
-- range of the type, so it is safe to compute its value:
Last := No_Index + Index_Type'Base (Length);
-- Finally we test whether the value is within the range of the
-- generic actual index subtype:
if Checks and then Last > Index_Type'Last then
raise Constraint_Error with "Length is out of range";
end if;
elsif Index_Type'First <= 0 then
-- Here we can compute Last directly, in the normal way. We know that
-- No_Index is less than 0, so there is no danger of overflow when
-- adding the (positive) value of Length.
Index := Count_Type'Base (No_Index) + Length; -- Last
if Checks and then Index > Count_Type'Base (Index_Type'Last) then
raise Constraint_Error with "Length is out of range";
end if;
-- We know that the computed value (having type Count_Type) of Last
-- is within the range of the generic actual index subtype, so it is
-- safe to convert to Index_Type:
Last := Index_Type'Base (Index);
else
-- Here Index_Type'First (and Index_Type'Last) is positive, so we
-- must test the length indirectly (by working backwards from the
-- largest possible value of Last), in order to prevent overflow.
Index := Count_Type'Base (Index_Type'Last) - Length; -- No_Index
if Checks and then Index < Count_Type'Base (No_Index) then
raise Constraint_Error with "Length is out of range";
end if;
-- We have determined that the value of Length would not create a
-- Last index value outside of the range of Index_Type, so we can now
-- safely compute its value.
Last := Index_Type'Base (Count_Type'Base (No_Index) + Length);
end if;
return V : Vector (Capacity => Length) do
V.Last := Last;
end return;
end To_Vector;
function To_Vector
(New_Item : Element_Type;
Length : Count_Type) return Vector
is
Index : Count_Type'Base;
Last : Index_Type'Base;
begin
if Length = 0 then
return Empty_Vector;
end if;
-- We create a vector object with a capacity that matches the specified
-- Length, but we do not allow the vector capacity (the length of the
-- internal array) to exceed the number of values in Index_Type'Range
-- (otherwise, there would be no way to refer to those components via an
-- index). We must therefore check whether the specified Length would
-- create a Last index value greater than Index_Type'Last.
if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then
-- We perform a two-part test. First we determine whether the
-- computed Last value lies in the base range of the type, and then
-- determine whether it lies in the range of the index (sub)type.
-- Last must satisfy this relation:
-- First + Length - 1 <= Last
-- We regroup terms:
-- First - 1 <= Last - Length
-- Which can rewrite as:
-- No_Index <= Last - Length
if Checks and then
Index_Type'Base'Last - Index_Type'Base (Length) < No_Index
then
raise Constraint_Error with "Length is out of range";
end if;
-- We now know that the computed value of Last is within the base
-- range of the type, so it is safe to compute its value:
Last := No_Index + Index_Type'Base (Length);
-- Finally we test whether the value is within the range of the
-- generic actual index subtype:
if Checks and then Last > Index_Type'Last then
raise Constraint_Error with "Length is out of range";
end if;
elsif Index_Type'First <= 0 then
-- Here we can compute Last directly, in the normal way. We know that
-- No_Index is less than 0, so there is no danger of overflow when
-- adding the (positive) value of Length.
Index := Count_Type'Base (No_Index) + Length; -- same value as V.Last
if Checks and then Index > Count_Type'Base (Index_Type'Last) then
raise Constraint_Error with "Length is out of range";
end if;
-- We know that the computed value (having type Count_Type) of Last
-- is within the range of the generic actual index subtype, so it is
-- safe to convert to Index_Type:
Last := Index_Type'Base (Index);
else
-- Here Index_Type'First (and Index_Type'Last) is positive, so we
-- must test the length indirectly (by working backwards from the
-- largest possible value of Last), in order to prevent overflow.
Index := Count_Type'Base (Index_Type'Last) - Length; -- No_Index
if Checks and then Index < Count_Type'Base (No_Index) then
raise Constraint_Error with "Length is out of range";
end if;
-- We have determined that the value of Length would not create a
-- Last index value outside of the range of Index_Type, so we can now
-- safely compute its value.
Last := Index_Type'Base (Count_Type'Base (No_Index) + Length);
end if;
return V : Vector (Capacity => Length) do
V.Elements := [others => New_Item];
V.Last := Last;
end return;
end To_Vector;
--------------------
-- Update_Element --
--------------------
procedure Update_Element
(Container : in out Vector;
Index : Index_Type;
Process : not null access procedure (Element : in out Element_Type))
is
Lock : With_Lock (Container.TC'Unchecked_Access);
begin
if Checks and then Index > Container.Last then
raise Constraint_Error with "Index is out of range";
end if;
Process (Container.Elements (To_Array_Index (Index)));
end Update_Element;
procedure Update_Element
(Container : in out Vector;
Position : Cursor;
Process : not null access procedure (Element : in out Element_Type))
is
begin
if Checks and then Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Checks and then Position.Container /= Container'Unrestricted_Access
then
raise Program_Error with "Position cursor denotes wrong container";
end if;
Update_Element (Container, Position.Index, Process);
end Update_Element;
-----------
-- Write --
-----------
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Container : Vector)
is
N : Count_Type;
begin
N := Container.Length;
Count_Type'Base'Write (Stream, N);
for J in 1 .. N loop
Element_Type'Write (Stream, Container.Elements (J));
end loop;
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Position : Cursor)
is
begin
raise Program_Error with "attempt to stream vector cursor";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Item : Constant_Reference_Type)
is
begin
raise Program_Error with "attempt to stream reference";
end Write;
end Ada.Containers.Bounded_Vectors;
|
AdaDoom3/completely-unscientific-benchmarks | Ada | 2,754 | adb |
package body Trees is
-----------------
-- Delete_Node --
-----------------
procedure Delete_Node (N : in out Node_Ptr) is
begin
if n /= null then
if n.left /= null then delete_node(n.left); end if;
if n.right /= null then delete_node(n.right); end if;
free(n);
end if;
end;
-----------
-- Merge --
-----------
function Merge (lower, greater: NodePtr) return NodePtr is
begin
if lower = null then return greater; end if;
if greater = null then return lower; end if;
if lower.y < greater.y then
lower.right := merge(lower.right, greater);
return lower;
else
greater.left := merge(lower, greater.left);
return greater;
end if;
end;
function Merge (lower, equal, greater: NodePtr) return NodePtr is
begin
return merge(merge(lower, equal), greater);
end;
-----------
-- Split --
-----------
procedure Split (orig: NodePtr; lower, greaterOrEqual: in out NodePtr; val: Integer) is
begin
if orig = null then
lower := null;
greaterOrEqual := null;
return;
end if;
if orig.x < val then
lower := orig;
split(lower.right, lower.right, greaterOrEqual, val);
else
greaterOrEqual := orig;
split(greaterOrEqual.left, lower, greaterOrEqual.left, val);
end if;
end;
procedure Split (orig: Node_Ptr; lower, equal, greater: in out NodePtr; val: Integer) is
Equal_Or_Greater : Node_Ptr;
begin
Split (orig, lower, equalOrGreater, val);
Split (equalOrGreater, equal, greater, val + 1);
end;
---------------
-- Has_Value --
---------------
function Has_Value (t: in out Tree; x: Integer) return Boolean is
lower, equal, greater: NodePtr;
begin
split(t.root, lower, equal, greater, x);
t.root := merge(lower, equal, greater);
return equal /= null;
end;
------------
-- Insert --
------------
procedure Insert (t: in out Tree; x: Integer) is
lower, equal, greater: NodePtr;
begin
split(t.root, lower, equal, greater, x);
if Equal = null then
N := new Node_Type;
N.X := x;
N.Y := Random (G);
end if;
t.root := merge(lower, equal, greater);
end;
-----------
-- Erase --
-----------
procedure Erase (T : in out Tree_Type; Item : Integer) is
lower, equal, greater: NodePtr;
begin
split(t.root, lower, equal, greater, x);
t.root := merge(lower, greater);
-- Node deletion doesn't seem to affect running time by much
delete_node(equal);
end;
--------------------
-- Initialization --
--------------------
begin
Reset (G);
end;
|
melwyncarlo/ProjectEuler | Ada | 1,830 | adb | with Ada.Integer_Text_IO;
with Ada.Numerics.Elementary_Functions;
-- Copyright 2021 Melwyn Francis Carlo
procedure A017 is
use Ada.Integer_Text_IO;
use Ada.Numerics.Elementary_Functions;
N : Integer := 0;
And_Str_Length : constant Integer := 3;
Hundred_Str_Length : constant Integer := 7;
One_Thousand_Str_Length : constant Integer := 11;
-- The first elements are dummy elements.
Ones_Str_Length : constant array (Integer range 0 .. 9) of Integer :=
(0, 3, 3, 5, 4, 4, 3, 5, 5, 4);
Tens_Str_Length : constant array (Integer range 0 .. 9) of Integer :=
(0, 3, 6, 6, 5, 5, 5, 7, 6, 6);
Elevens_Str_Length : constant array (Integer range 0 .. 9) of Integer :=
(0, 6, 6, 8, 8, 7, 7, 9, 8, 8);
Number_Length, Ones_Number, Tens_Number : Integer;
begin
for I in 1 .. 999 loop
Number_Length := Integer (Float'Floor (Log (Float (I), 10.0))) + 1;
Ones_Number := I mod 10;
Tens_Number := (Integer (Float'Floor (Float (I) / 10.0))) mod 10;
if Number_Length > 2 then
N := N
+ Ones_Str_Length (Integer (Float'Floor (Float (I) / 100.0)))
+ Hundred_Str_Length;
if Ones_Number > 0 or Tens_Number > 0 then
N := N + And_Str_Length;
end if;
end if;
if Number_Length > 1 then
if Tens_Number = 1 then
if Ones_Number = 0 then
N := N + Tens_Str_Length (1);
else
N := N + Elevens_Str_Length (Ones_Number);
end if;
goto Continue;
else
N := N + Tens_Str_Length (Tens_Number);
end if;
end if;
N := N + Ones_Str_Length (Ones_Number);
<<Continue>>
end loop;
N := N + One_Thousand_Str_Length;
Put (N, Width => 0);
end A017;
|
AdaCore/Ada_Drivers_Library | Ada | 21,529 | ads | -- This spec has been automatically generated from STM32F429x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.SAI is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype ACR1_MODE_Field is HAL.UInt2;
subtype ACR1_PRTCFG_Field is HAL.UInt2;
subtype ACR1_DS_Field is HAL.UInt3;
subtype ACR1_SYNCEN_Field is HAL.UInt2;
subtype ACR1_MCJDIV_Field is HAL.UInt4;
-- AConfiguration register 1
type ACR1_Register is record
-- Audio block mode
MODE : ACR1_MODE_Field := 16#0#;
-- Protocol configuration
PRTCFG : ACR1_PRTCFG_Field := 16#0#;
-- unspecified
Reserved_4_4 : HAL.Bit := 16#0#;
-- Data size
DS : ACR1_DS_Field := 16#2#;
-- Least significant bit first
LSBFIRST : Boolean := False;
-- Clock strobing edge
CKSTR : Boolean := False;
-- Synchronization enable
SYNCEN : ACR1_SYNCEN_Field := 16#0#;
-- Mono mode
MONO : Boolean := False;
-- Output drive
OutDri : Boolean := False;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
-- Audio block A enable
SAIAEN : Boolean := False;
-- DMA enable
DMAEN : Boolean := False;
-- unspecified
Reserved_18_18 : HAL.Bit := 16#0#;
-- No divider
NODIV : Boolean := False;
-- Master clock divider
MCJDIV : ACR1_MCJDIV_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ACR1_Register use record
MODE at 0 range 0 .. 1;
PRTCFG at 0 range 2 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
DS at 0 range 5 .. 7;
LSBFIRST at 0 range 8 .. 8;
CKSTR at 0 range 9 .. 9;
SYNCEN at 0 range 10 .. 11;
MONO at 0 range 12 .. 12;
OutDri at 0 range 13 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
SAIAEN at 0 range 16 .. 16;
DMAEN at 0 range 17 .. 17;
Reserved_18_18 at 0 range 18 .. 18;
NODIV at 0 range 19 .. 19;
MCJDIV at 0 range 20 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype ACR2_FTH_Field is HAL.UInt3;
subtype ACR2_MUTECN_Field is HAL.UInt6;
subtype ACR2_COMP_Field is HAL.UInt2;
-- AConfiguration register 2
type ACR2_Register is record
-- FIFO threshold
FTH : ACR2_FTH_Field := 16#0#;
-- FIFO flush
FFLUS : Boolean := False;
-- Tristate management on data line
TRIS : Boolean := False;
-- Mute
MUTE : Boolean := False;
-- Mute value
MUTEVAL : Boolean := False;
-- Mute counter
MUTECN : ACR2_MUTECN_Field := 16#0#;
-- Complement bit
CPL : Boolean := False;
-- Companding mode
COMP : ACR2_COMP_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ACR2_Register use record
FTH at 0 range 0 .. 2;
FFLUS at 0 range 3 .. 3;
TRIS at 0 range 4 .. 4;
MUTE at 0 range 5 .. 5;
MUTEVAL at 0 range 6 .. 6;
MUTECN at 0 range 7 .. 12;
CPL at 0 range 13 .. 13;
COMP at 0 range 14 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype AFRCR_FRL_Field is HAL.UInt8;
subtype AFRCR_FSALL_Field is HAL.UInt7;
-- AFRCR
type AFRCR_Register is record
-- Frame length
FRL : AFRCR_FRL_Field := 16#7#;
-- Frame synchronization active level length
FSALL : AFRCR_FSALL_Field := 16#0#;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- Frame synchronization definition
FSDEF : Boolean := False;
-- Frame synchronization polarity
FSPOL : Boolean := False;
-- Frame synchronization offset
FSOFF : Boolean := False;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AFRCR_Register use record
FRL at 0 range 0 .. 7;
FSALL at 0 range 8 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
FSDEF at 0 range 16 .. 16;
FSPOL at 0 range 17 .. 17;
FSOFF at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype ASLOTR_FBOFF_Field is HAL.UInt5;
subtype ASLOTR_SLOTSZ_Field is HAL.UInt2;
subtype ASLOTR_NBSLOT_Field is HAL.UInt4;
subtype ASLOTR_SLOTEN_Field is HAL.UInt16;
-- ASlot register
type ASLOTR_Register is record
-- First bit offset
FBOFF : ASLOTR_FBOFF_Field := 16#0#;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- Slot size
SLOTSZ : ASLOTR_SLOTSZ_Field := 16#0#;
-- Number of slots in an audio frame
NBSLOT : ASLOTR_NBSLOT_Field := 16#0#;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
-- Slot enable
SLOTEN : ASLOTR_SLOTEN_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ASLOTR_Register use record
FBOFF at 0 range 0 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
SLOTSZ at 0 range 6 .. 7;
NBSLOT at 0 range 8 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
SLOTEN at 0 range 16 .. 31;
end record;
-- AInterrupt mask register2
type AIM_Register is record
-- Overrun/underrun interrupt enable
OVRUDRIE : Boolean := False;
-- Mute detection interrupt enable
MUTEDET : Boolean := False;
-- Wrong clock configuration interrupt enable
WCKCFG : Boolean := False;
-- FIFO request interrupt enable
FREQIE : Boolean := False;
-- Codec not ready interrupt enable
CNRDYIE : Boolean := False;
-- Anticipated frame synchronization detection interrupt enable
AFSDETIE : Boolean := False;
-- Late frame synchronization detection interrupt enable
LFSDET : Boolean := False;
-- unspecified
Reserved_7_31 : HAL.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AIM_Register use record
OVRUDRIE at 0 range 0 .. 0;
MUTEDET at 0 range 1 .. 1;
WCKCFG at 0 range 2 .. 2;
FREQIE at 0 range 3 .. 3;
CNRDYIE at 0 range 4 .. 4;
AFSDETIE at 0 range 5 .. 5;
LFSDET at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
subtype ASR_FLVL_Field is HAL.UInt3;
-- AStatus register
type ASR_Register is record
-- Overrun / underrun
OVRUDR : Boolean := False;
-- Mute detection
MUTEDET : Boolean := False;
-- Wrong clock configuration flag. This bit is read only.
WCKCFG : Boolean := False;
-- FIFO request
FREQ : Boolean := False;
-- Codec not ready
CNRDY : Boolean := False;
-- Anticipated frame synchronization detection
AFSDET : Boolean := False;
-- Late frame synchronization detection
LFSDET : Boolean := False;
-- unspecified
Reserved_7_15 : HAL.UInt9 := 16#0#;
-- FIFO level threshold
FLVL : ASR_FLVL_Field := 16#0#;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ASR_Register use record
OVRUDR at 0 range 0 .. 0;
MUTEDET at 0 range 1 .. 1;
WCKCFG at 0 range 2 .. 2;
FREQ at 0 range 3 .. 3;
CNRDY at 0 range 4 .. 4;
AFSDET at 0 range 5 .. 5;
LFSDET at 0 range 6 .. 6;
Reserved_7_15 at 0 range 7 .. 15;
FLVL at 0 range 16 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- AClear flag register
type ACLRFR_Register is record
-- Clear overrun / underrun
OVRUDR : Boolean := False;
-- Mute detection flag
MUTEDET : Boolean := False;
-- Clear wrong clock configuration flag
WCKCFG : Boolean := False;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Clear codec not ready flag
CNRDY : Boolean := False;
-- Clear anticipated frame synchronization detection flag.
CAFSDET : Boolean := False;
-- Clear late frame synchronization detection flag
LFSDET : Boolean := False;
-- unspecified
Reserved_7_31 : HAL.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ACLRFR_Register use record
OVRUDR at 0 range 0 .. 0;
MUTEDET at 0 range 1 .. 1;
WCKCFG at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
CNRDY at 0 range 4 .. 4;
CAFSDET at 0 range 5 .. 5;
LFSDET at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
subtype BCR1_MODE_Field is HAL.UInt2;
subtype BCR1_PRTCFG_Field is HAL.UInt2;
subtype BCR1_DS_Field is HAL.UInt3;
subtype BCR1_SYNCEN_Field is HAL.UInt2;
subtype BCR1_MCJDIV_Field is HAL.UInt4;
-- BConfiguration register 1
type BCR1_Register is record
-- Audio block mode
MODE : BCR1_MODE_Field := 16#0#;
-- Protocol configuration
PRTCFG : BCR1_PRTCFG_Field := 16#0#;
-- unspecified
Reserved_4_4 : HAL.Bit := 16#0#;
-- Data size
DS : BCR1_DS_Field := 16#2#;
-- Least significant bit first
LSBFIRST : Boolean := False;
-- Clock strobing edge
CKSTR : Boolean := False;
-- Synchronization enable
SYNCEN : BCR1_SYNCEN_Field := 16#0#;
-- Mono mode
MONO : Boolean := False;
-- Output drive
OutDri : Boolean := False;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
-- Audio block B enable
SAIBEN : Boolean := False;
-- DMA enable
DMAEN : Boolean := False;
-- unspecified
Reserved_18_18 : HAL.Bit := 16#0#;
-- No divider
NODIV : Boolean := False;
-- Master clock divider
MCJDIV : BCR1_MCJDIV_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BCR1_Register use record
MODE at 0 range 0 .. 1;
PRTCFG at 0 range 2 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
DS at 0 range 5 .. 7;
LSBFIRST at 0 range 8 .. 8;
CKSTR at 0 range 9 .. 9;
SYNCEN at 0 range 10 .. 11;
MONO at 0 range 12 .. 12;
OutDri at 0 range 13 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
SAIBEN at 0 range 16 .. 16;
DMAEN at 0 range 17 .. 17;
Reserved_18_18 at 0 range 18 .. 18;
NODIV at 0 range 19 .. 19;
MCJDIV at 0 range 20 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype BCR2_FTH_Field is HAL.UInt3;
subtype BCR2_MUTECN_Field is HAL.UInt6;
subtype BCR2_COMP_Field is HAL.UInt2;
-- BConfiguration register 2
type BCR2_Register is record
-- FIFO threshold
FTH : BCR2_FTH_Field := 16#0#;
-- FIFO flush
FFLUS : Boolean := False;
-- Tristate management on data line
TRIS : Boolean := False;
-- Mute
MUTE : Boolean := False;
-- Mute value
MUTEVAL : Boolean := False;
-- Mute counter
MUTECN : BCR2_MUTECN_Field := 16#0#;
-- Complement bit
CPL : Boolean := False;
-- Companding mode
COMP : BCR2_COMP_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BCR2_Register use record
FTH at 0 range 0 .. 2;
FFLUS at 0 range 3 .. 3;
TRIS at 0 range 4 .. 4;
MUTE at 0 range 5 .. 5;
MUTEVAL at 0 range 6 .. 6;
MUTECN at 0 range 7 .. 12;
CPL at 0 range 13 .. 13;
COMP at 0 range 14 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype BFRCR_FRL_Field is HAL.UInt8;
subtype BFRCR_FSALL_Field is HAL.UInt7;
-- BFRCR
type BFRCR_Register is record
-- Frame length
FRL : BFRCR_FRL_Field := 16#7#;
-- Frame synchronization active level length
FSALL : BFRCR_FSALL_Field := 16#0#;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- Frame synchronization definition
FSDEF : Boolean := False;
-- Frame synchronization polarity
FSPOL : Boolean := False;
-- Frame synchronization offset
FSOFF : Boolean := False;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BFRCR_Register use record
FRL at 0 range 0 .. 7;
FSALL at 0 range 8 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
FSDEF at 0 range 16 .. 16;
FSPOL at 0 range 17 .. 17;
FSOFF at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype BSLOTR_FBOFF_Field is HAL.UInt5;
subtype BSLOTR_SLOTSZ_Field is HAL.UInt2;
subtype BSLOTR_NBSLOT_Field is HAL.UInt4;
subtype BSLOTR_SLOTEN_Field is HAL.UInt16;
-- BSlot register
type BSLOTR_Register is record
-- First bit offset
FBOFF : BSLOTR_FBOFF_Field := 16#0#;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- Slot size
SLOTSZ : BSLOTR_SLOTSZ_Field := 16#0#;
-- Number of slots in an audio frame
NBSLOT : BSLOTR_NBSLOT_Field := 16#0#;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
-- Slot enable
SLOTEN : BSLOTR_SLOTEN_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BSLOTR_Register use record
FBOFF at 0 range 0 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
SLOTSZ at 0 range 6 .. 7;
NBSLOT at 0 range 8 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
SLOTEN at 0 range 16 .. 31;
end record;
-- BInterrupt mask register2
type BIM_Register is record
-- Overrun/underrun interrupt enable
OVRUDRIE : Boolean := False;
-- Mute detection interrupt enable
MUTEDET : Boolean := False;
-- Wrong clock configuration interrupt enable
WCKCFG : Boolean := False;
-- FIFO request interrupt enable
FREQIE : Boolean := False;
-- Codec not ready interrupt enable
CNRDYIE : Boolean := False;
-- Anticipated frame synchronization detection interrupt enable
AFSDETIE : Boolean := False;
-- Late frame synchronization detection interrupt enable
LFSDETIE : Boolean := False;
-- unspecified
Reserved_7_31 : HAL.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BIM_Register use record
OVRUDRIE at 0 range 0 .. 0;
MUTEDET at 0 range 1 .. 1;
WCKCFG at 0 range 2 .. 2;
FREQIE at 0 range 3 .. 3;
CNRDYIE at 0 range 4 .. 4;
AFSDETIE at 0 range 5 .. 5;
LFSDETIE at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
subtype BSR_FLVL_Field is HAL.UInt3;
-- BStatus register
type BSR_Register is record
-- Read-only. Overrun / underrun
OVRUDR : Boolean;
-- Read-only. Mute detection
MUTEDET : Boolean;
-- Read-only. Wrong clock configuration flag
WCKCFG : Boolean;
-- Read-only. FIFO request
FREQ : Boolean;
-- Read-only. Codec not ready
CNRDY : Boolean;
-- Read-only. Anticipated frame synchronization detection
AFSDET : Boolean;
-- Read-only. Late frame synchronization detection
LFSDET : Boolean;
-- unspecified
Reserved_7_15 : HAL.UInt9;
-- Read-only. FIFO level threshold
FLVL : BSR_FLVL_Field;
-- unspecified
Reserved_19_31 : HAL.UInt13;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BSR_Register use record
OVRUDR at 0 range 0 .. 0;
MUTEDET at 0 range 1 .. 1;
WCKCFG at 0 range 2 .. 2;
FREQ at 0 range 3 .. 3;
CNRDY at 0 range 4 .. 4;
AFSDET at 0 range 5 .. 5;
LFSDET at 0 range 6 .. 6;
Reserved_7_15 at 0 range 7 .. 15;
FLVL at 0 range 16 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- BClear flag register
type BCLRFR_Register is record
-- Write-only. Clear overrun / underrun
OVRUDR : Boolean := False;
-- Write-only. Mute detection flag
MUTEDET : Boolean := False;
-- Write-only. Clear wrong clock configuration flag
WCKCFG : Boolean := False;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Write-only. Clear codec not ready flag
CNRDY : Boolean := False;
-- Write-only. Clear anticipated frame synchronization detection flag
CAFSDET : Boolean := False;
-- Write-only. Clear late frame synchronization detection flag
LFSDET : Boolean := False;
-- unspecified
Reserved_7_31 : HAL.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BCLRFR_Register use record
OVRUDR at 0 range 0 .. 0;
MUTEDET at 0 range 1 .. 1;
WCKCFG at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
CNRDY at 0 range 4 .. 4;
CAFSDET at 0 range 5 .. 5;
LFSDET at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Serial audio interface
type SAI_Peripheral is record
-- AConfiguration register 1
ACR1 : aliased ACR1_Register;
-- AConfiguration register 2
ACR2 : aliased ACR2_Register;
-- AFRCR
AFRCR : aliased AFRCR_Register;
-- ASlot register
ASLOTR : aliased ASLOTR_Register;
-- AInterrupt mask register2
AIM : aliased AIM_Register;
-- AStatus register
ASR : aliased ASR_Register;
-- AClear flag register
ACLRFR : aliased ACLRFR_Register;
-- AData register
ADR : aliased HAL.UInt32;
-- BConfiguration register 1
BCR1 : aliased BCR1_Register;
-- BConfiguration register 2
BCR2 : aliased BCR2_Register;
-- BFRCR
BFRCR : aliased BFRCR_Register;
-- BSlot register
BSLOTR : aliased BSLOTR_Register;
-- BInterrupt mask register2
BIM : aliased BIM_Register;
-- BStatus register
BSR : aliased BSR_Register;
-- BClear flag register
BCLRFR : aliased BCLRFR_Register;
-- BData register
BDR : aliased HAL.UInt32;
end record
with Volatile;
for SAI_Peripheral use record
ACR1 at 16#4# range 0 .. 31;
ACR2 at 16#8# range 0 .. 31;
AFRCR at 16#C# range 0 .. 31;
ASLOTR at 16#10# range 0 .. 31;
AIM at 16#14# range 0 .. 31;
ASR at 16#18# range 0 .. 31;
ACLRFR at 16#1C# range 0 .. 31;
ADR at 16#20# range 0 .. 31;
BCR1 at 16#24# range 0 .. 31;
BCR2 at 16#28# range 0 .. 31;
BFRCR at 16#2C# range 0 .. 31;
BSLOTR at 16#30# range 0 .. 31;
BIM at 16#34# range 0 .. 31;
BSR at 16#38# range 0 .. 31;
BCLRFR at 16#3C# range 0 .. 31;
BDR at 16#40# range 0 .. 31;
end record;
-- Serial audio interface
SAI_Periph : aliased SAI_Peripheral
with Import, Address => System'To_Address (16#40015800#);
end STM32_SVD.SAI;
|
zhmu/ananas | Ada | 298 | ads | -- { dg-do compile }
package Access_Constant is
c: aliased constant integer := 3;
type const_ptr is access constant integer;
cp : const_ptr := c'access;
procedure inc (var_ptr: access integer :=
cp) -- { dg-error "access-to-constant" }
is abstract;
end Access_Constant;
|
damaki/libkeccak | Ada | 4,408 | ads | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Keccak.Generic_Parallel_Sponge;
with Keccak.Padding;
pragma Elaborate_All (Keccak.Generic_Parallel_Sponge);
package Keccak.Parallel_Keccak_1600.Rounds_12
with SPARK_Mode => On
is
procedure Permute_All_P2 is new KeccakF_1600_P2.Permute_All
(First_Round => 12,
Num_Rounds => 12);
procedure Permute_All_P4 is new KeccakF_1600_P4.Permute_All
(First_Round => 12,
Num_Rounds => 12);
procedure Permute_All_P8 is new KeccakF_1600_P8.Permute_All
(Permute_All_P4);
package Parallel_Sponge_P2 is new Keccak.Generic_Parallel_Sponge
(State_Size => 1600,
State_Type => KeccakF_1600_P2.Parallel_State,
Parallelism => 2,
Init => KeccakF_1600_P2.Init,
Permute_All => Permute_All_P2,
XOR_Bits_Into_State_Separate => KeccakF_1600_P2.XOR_Bits_Into_State_Separate,
XOR_Bits_Into_State_All => KeccakF_1600_P2.XOR_Bits_Into_State_All,
Extract_Bytes => KeccakF_1600_P2.Extract_Bytes,
Pad => Keccak.Padding.Pad101_Single_Block,
Min_Padding_Bits => Keccak.Padding.Pad101_Min_Bits);
package Parallel_Sponge_P4 is new Keccak.Generic_Parallel_Sponge
(State_Size => 1600,
State_Type => KeccakF_1600_P4.Parallel_State,
Parallelism => 4,
Init => KeccakF_1600_P4.Init,
Permute_All => Permute_All_P4,
XOR_Bits_Into_State_Separate => KeccakF_1600_P4.XOR_Bits_Into_State_Separate,
XOR_Bits_Into_State_All => KeccakF_1600_P4.XOR_Bits_Into_State_All,
Extract_Bytes => KeccakF_1600_P4.Extract_Bytes,
Pad => Keccak.Padding.Pad101_Single_Block,
Min_Padding_Bits => Keccak.Padding.Pad101_Min_Bits);
package Parallel_Sponge_P8 is new Keccak.Generic_Parallel_Sponge
(State_Size => 1600,
State_Type => KeccakF_1600_P8.Parallel_State,
Parallelism => 8,
Init => KeccakF_1600_P8.Init,
Permute_All => Permute_All_P8,
XOR_Bits_Into_State_Separate => KeccakF_1600_P8.XOR_Bits_Into_State_Separate,
XOR_Bits_Into_State_All => KeccakF_1600_P8.XOR_Bits_Into_State_All,
Extract_Bytes => KeccakF_1600_P8.Extract_Bytes,
Pad => Keccak.Padding.Pad101_Single_Block,
Min_Padding_Bits => Keccak.Padding.Pad101_Min_Bits);
end Keccak.Parallel_Keccak_1600.Rounds_12;
|
charlie5/lace | Ada | 35,443 | adb | with
collada.Library.geometries,
collada.Library.controllers,
collada.Library.animations,
collada.Library.visual_scenes,
XML,
ada.Calendar.formatting,
ada.Strings.fixed,
ada.Characters.latin_1,
ada.Text_IO;
package body collada.Document
is
use ada.Strings.unbounded;
------------
-- Utilities
--
function "+" (From : in String) return unbounded_String
renames to_unbounded_String;
function to_Time (From : in String) return ada.Calendar.Time
is
Pad : String := From;
Index : constant Natural := ada.Strings.fixed.Index (Pad, "T");
begin
if Index /= 0 then
Pad (Index) := ' ';
end if;
return ada.Calendar.formatting.Value (Pad);
exception
when constraint_Error =>
return ada.Calendar.Clock; -- TODO: Temporary debug measure to handle unknown date formats.
end to_Time;
function to_int_Array (From : in String) return int_Array
is
use ada.Strings.fixed;
the_Array : int_Array (1 .. 500_000);
Count : math.Index := 0;
Start : Natural := 1;
Cursor : Natural := Index (From, " ");
begin
if Cursor = 0
then
return [1 => Integer'Value (From)];
end if;
loop
if From (Start .. Cursor-1) /= ""
and then From (Start .. Cursor-1) /= "" & ada.Characters.latin_1.LF
then
Count := Count + 1;
the_Array (Count) := Integer'Value (From (Start .. Cursor-1));
end if;
Start := Cursor + 1;
Cursor := Index (From, " ", Start);
exit when Cursor = 0;
end loop;
if Start <= From'Last
then
Count := Count + 1;
the_Array (Count) := Integer'Value (From (Start .. From'Last));
end if;
return the_Array (1 .. Count);
end to_int_Array;
function to_float_Array (From : in String) return float_Array
is
begin
if From = ""
then
return float_Array' (1 .. 0 => <>);
end if;
declare
use ada.Strings.fixed;
the_Array : float_Array (1 .. 500_000);
Count : math.Index := 0;
Start : Integer := 1;
Cursor : Integer := Index (From, " ");
begin
if Cursor = 0
then
return [1 => math.Real'Value (From)];
end if;
loop
if From (Start .. Cursor-1) /= ""
and then From (Start .. Cursor-1) /= "" & ada.Characters.latin_1.LF
then
Count := Count + 1;
the_Array (Count) := math.Real'Value (From (Start .. Cursor-1));
end if;
Start := Cursor + 1;
Cursor := Index (From, " ", Start);
exit when Cursor = 0;
end loop;
if From (Start .. From'Last) /= ""
then
Count := Count + 1;
the_Array (Count) := math.Real'Value (From (Start .. From'Last));
end if;
return the_Array (1 .. Count);
end;
end to_float_Array;
function to_Text_array (From : in String) return Text_array
is
begin
if From = ""
then
return Text_array' (1 .. 0 => <>);
end if;
declare
use ada.Strings.fixed;
the_Array : Text_array (1 .. 40_000);
Count : math.Index := 0;
Start : Integer := 1;
Cursor : Integer := Index (From, " ");
begin
if Cursor = 0
then
return [1 => +From];
end if;
loop
if From (Start .. Cursor-1) /= ""
and then From (Start .. Cursor-1) /= "" & ada.Characters.latin_1.LF
then
Count := Count + 1;
the_Array (Count) := +From (Start .. Cursor-1);
end if;
Start := Cursor + 1;
Cursor := Index (From, " ", Start);
exit when Cursor = 0;
end loop;
if From (Start .. From'Last) /= ""
then
Count := Count + 1;
the_Array (Count) := +From (Start .. From'Last);
end if;
return the_Array (1 .. Count);
end;
end to_Text_array;
function to_Matrix (From : in String) return Matrix_4x4
is
the_Floats : constant math.Vector_16 := math.Vector_16 (to_float_Array (From));
begin
return math.to_Matrix_4x4 (the_Floats);
end to_Matrix;
function to_Source (From : in xml.Element) return collada.Library.Source
is
the_xml_Id : constant access xml.Attribute_t := From.Attribute ("id");
the_xml_float_Array : constant access xml.Element := From.Child ("float_array");
the_xml_text_Array : constant access xml.Element := From.Child ("Name_array");
the_array_Length : Natural;
pragma Unreferenced (the_array_Length);
the_Source : Library.source;
begin
the_Source.Id := +the_xml_Id.Value;
if the_xml_float_Array /= null
then
the_Source.array_Id := +the_xml_float_Array.Attribute ("id").Value;
the_array_Length := Natural'Value (the_xml_float_Array.Attribute ("count").Value);
the_Source.Floats := new float_Array' (to_float_Array (the_xml_float_Array.Data));
elsif the_xml_text_Array /= null
then
the_Source.array_Id := +the_xml_text_Array.Attribute ("id").Value;
the_array_Length := Natural'Value (the_xml_text_Array.Attribute ("count").Value);
the_Source.Texts := new Text_array' (to_Text_array (the_xml_text_Array.Data));
end if;
return the_Source;
end to_Source;
function to_Input (From : in xml.Element) return collada.Library.Input_t
is
use collada.Library;
the_xml_Semantic : constant access xml.Attribute_t := From.Attribute ("semantic");
the_xml_Source : constant access xml.Attribute_t := From.Attribute ("source");
the_xml_Offset : constant access xml.Attribute_t := From.Attribute ("offset");
the_Input : Input_t;
begin
the_Input.Semantic := Semantic'Value (the_xml_Semantic.Value);
the_Input.Source := +the_xml_Source .Value;
if the_xml_Offset /= null
then
the_Input.Offset := Natural'Value (the_xml_Offset.Value);
end if;
return the_Input;
end to_Input;
function to_Vertices (From : in xml.Element) return collada.Library.geometries.Vertices
is
use collada.Library,
collada.Library.geometries;
the_xml_Id : constant access xml.Attribute_t := From.Attribute ("id");
the_xml_Inputs : constant xml.Elements := From.Children ("input");
the_Vertices : geometries.Vertices;
begin
the_Vertices.Id := +the_xml_Id.Value;
the_Vertices.Inputs := new Inputs (the_xml_Inputs'Range);
for i in the_xml_Inputs'Range
loop
the_Vertices.Inputs (i) := to_Input (the_xml_Inputs (i).all);
end loop;
return the_Vertices;
end to_Vertices;
function to_Polylist (From : in xml.Element) return collada.Library.geometries.Primitive
is
use collada.Library,
collada.Library.geometries;
the_xml_Count : constant access xml.Attribute_t := From.Attribute ("count");
the_xml_Material : constant access xml.Attribute_t := From.Attribute ("material");
the_xml_Inputs : constant xml.Elements := From.Children ("input");
the_xml_vCount : constant access xml.Element := From.Child ("vcount");
the_xml_P : constant access xml.Element := From.Child ("p");
the_Polylist : geometries.Primitive (polyList);
begin
the_Polylist.Count := Natural'Value (the_xml_Count.Value);
if the_xml_Material /= null
then
the_Polylist.Material := +the_xml_Material.Value;
end if;
the_Polylist.Inputs := new Inputs (the_xml_Inputs'Range);
for i in the_xml_Inputs'Range
loop
the_Polylist.Inputs (i) := to_Input (the_xml_Inputs (i).all);
end loop;
the_Polylist.vCount := new int_Array' (to_int_Array (the_xml_vCount.Data));
the_Polylist.P_List := new int_array_List' (1 => new int_Array' (to_int_Array (the_xml_P.Data)));
return the_Polylist;
end to_Polylist;
function to_Polygon (From : in xml.Element) return collada.Library.geometries.Primitive
is
use collada.Library,
collada.Library.geometries;
the_xml_Count : constant access xml.Attribute_t := From.Attribute ("count");
the_xml_Material : constant access xml.Attribute_t := From.Attribute ("material");
the_xml_Inputs : constant xml.Elements := From.Children ("input");
the_xml_Ps : constant xml.Elements := From.Children ("p");
the_Polygons : geometries.Primitive (Polygons);
begin
the_Polygons.Count := Natural'Value (the_xml_Count.Value);
if the_xml_Material /= null
then
the_Polygons.Material := +the_xml_Material.Value;
end if;
-- Do inputs.
--
the_Polygons.Inputs := new Inputs (the_xml_Inputs'Range);
for i in the_xml_Inputs'Range
loop
the_Polygons.Inputs (i) := to_Input (the_xml_Inputs (i).all);
end loop;
-- Do P list.
--
the_Polygons.P_List := new int_array_List (1 .. the_xml_Ps'Length);
for i in the_Polygons.P_List'Range
loop
the_Polygons.P_List (i) := new int_Array' (to_int_Array (the_xml_Ps (i).Data));
end loop;
return the_Polygons;
end to_Polygon;
function to_Triangles (From : in xml.Element) return collada.Library.geometries.Primitive
is
use collada.Library,
collada.Library.geometries;
the_xml_Count : constant access xml.Attribute_t := From.Attribute ("count");
the_xml_Material : constant access xml.Attribute_t := From.Attribute ("material");
the_xml_Inputs : constant xml.Elements := From.Children ("input");
the_xml_Ps : constant xml.Elements := From.Children ("p");
the_Triangles : geometries.Primitive (Triangles);
begin
the_Triangles.Count := Natural'Value (the_xml_Count.Value);
if the_xml_Material /= null
then
the_Triangles.Material := +the_xml_Material.Value;
end if;
-- Do inputs.
--
the_Triangles.Inputs := new Inputs (the_xml_Inputs'Range);
for i in the_xml_Inputs'Range
loop
the_Triangles.Inputs (i) := to_Input (the_xml_Inputs (i).all);
end loop;
-- Do P list.
--
the_Triangles.P_List := new int_array_List (1 .. the_xml_Ps'Length);
for i in the_Triangles.P_List'Range
loop
the_Triangles.P_List (i) := new int_Array' (to_int_Array (the_xml_Ps (i).Data));
end loop;
return the_Triangles;
end to_Triangles;
function to_Joints (From : in xml.Element) return collada.Library.controllers.Joints
is
use collada.Library,
collada.Library.controllers;
the_xml_Inputs : constant xml.Elements := From.Children ("input");
the_Joints : controllers.Joints;
begin
the_Joints.Inputs := new Inputs (the_xml_Inputs'Range);
for i in the_xml_Inputs'Range
loop
the_Joints.Inputs (i) := to_Input (the_xml_Inputs (i).all);
end loop;
return the_Joints;
end to_Joints;
function to_vertex_Weights (From : in xml.Element) return collada.Library.controllers.vertex_Weights
is
use collada.Library,
collada.Library.controllers;
the_xml_Count : constant access xml.Attribute_t := From.Attribute ("count");
the_xml_Inputs : constant xml.Elements := From.Children ("input");
the_xml_vCount : constant access xml.Element := From.Child ("vcount");
the_xml_V : constant access xml.Element := From.Child ("v");
the_Weights : controllers.vertex_Weights;
begin
the_Weights.Count := Natural'Value (the_xml_Count.Value);
the_Weights.Inputs := new Inputs (the_xml_Inputs'Range);
for i in the_xml_Inputs'Range
loop
the_Weights.Inputs (i) := to_Input (the_xml_Inputs (i).all);
end loop;
the_Weights.v_Count := new int_Array' (to_int_Array (the_xml_vCount.Data));
the_Weights.V := new int_array' (to_int_Array (the_xml_V.Data));
return the_Weights;
end to_vertex_Weights;
function to_Sampler (From : in xml.Element) return collada.Library.animations.Sampler
is
use collada.Library,
collada.Library.animations;
the_xml_Id : constant access xml.Attribute_t := From.Attribute ("id");
the_xml_Inputs : constant xml.Elements := From.Children ("input");
the_Sampler : animations.Sampler;
begin
the_Sampler.Id := +the_xml_Id.Value;
the_Sampler.Inputs := new Inputs (the_xml_Inputs'Range);
for i in the_xml_Inputs'Range
loop
the_Sampler.Inputs (i) := to_Input (the_xml_Inputs (i).all);
end loop;
return the_Sampler;
end to_Sampler;
function to_Channel (From : in xml.Element) return collada.Library.animations.Channel
is
use collada.Library,
collada.Library.animations;
the_xml_Source : constant access xml.Attribute_t := From.Attribute ("source");
the_xml_Target : constant access xml.Attribute_t := From.Attribute ("target");
the_Channel : animations.Channel;
begin
the_Channel.Source := +the_xml_Source.Value;
the_Channel.Target := +the_xml_Target.Value;
return the_Channel;
end to_Channel;
---------------
-- Construction
--
function to_Document (Filename : in String) return Item
is
use XML;
the_xml_Tree : constant xml.Element := xml.to_XML (Filename);
the_collada_Tree : constant access xml.Element := the_xml_Tree.Child (named => "COLLADA");
the_Document : Document.item;
begin
parse_the_asset_Element:
declare
the_Asset : constant access xml.Element := the_collada_Tree.Child (named => "asset");
the_Contributor : constant access xml.Element := the_Asset.Child (named => "contributor");
the_creation_Date : constant access xml.Element := the_Asset.Child (named => "created");
the_modification_Date : constant access xml.Element := the_Asset.Child (named => "modified");
the_Unit : constant access xml.Element := the_Asset.Child (named => "unit");
the_up_Axis : constant access xml.Element := the_Asset.Child (named => "up_axis");
begin
-- Parse the 'contributor' element.
--
if the_Contributor /= null
then
declare
the_Author : constant access xml.Element := the_Contributor .Child (named => "author");
the_authoring_Tool : constant access xml.Element := the_Contributor .Child (named => "authoring_tool");
begin
if the_Author /= null
then
the_Document.Asset.Contributor.Author := +the_Author.Data;
end if;
if the_authoring_Tool /= null
then
the_document.asset.contributor.authoring_Tool := +the_authoring_Tool.Data;
end if;
end;
end if;
-- Parse the creation and modification dates.
--
if the_creation_Date /= null
then
the_document.asset.Created := to_Time (the_creation_Date.Data);
end if;
if the_modification_Date /= null
then
the_document.asset.Modified := to_Time (the_modification_Date.Data);
end if;
-- Parse the 'unit' element.
--
if the_Unit /= null
then
the_document.asset.Unit.Name := +the_Unit.Attribute (named => "name") .Value;
the_document.asset.Unit.Meter := Float'Value (the_Unit.Attribute (named => "meter").Value);
end if;
-- Parse the 'up_axis' element.
--
if the_up_Axis /= null
then
the_document.asset.up_Axis := collada.asset.up_Direction'Value (the_up_Axis.Data);
end if;
end parse_the_asset_Element;
---------------------------------
--- Parse the 'library' elements.
--
parse_the_geometries_Library:
declare
the_Library : constant access xml.Element := the_collada_Tree.Child (named => "library_geometries");
begin
if the_Library /= null
then
declare
use collada.Library.geometries;
the_Geometries : constant xml.Elements := the_Library.Children (named => "geometry");
begin
the_Document.Libraries.Geometries.Contents := new Geometry_array (the_Geometries'Range);
for Each in the_Geometries'Range
loop
declare
the_xml_Geometry : access xml.Element renames the_Geometries (Each);
the_Geometry : Geometry renames the_Document.Libraries.Geometries.Contents (Each);
the_xml_Id : constant access xml.Attribute_t'Class := the_xml_Geometry.Attribute ("id");
the_xml_Name : constant access xml.Attribute_t'Class := the_xml_Geometry.Attribute ("name");
begin
the_Geometry.Id := +the_xml_Id.Value;
if the_xml_Name /= null
then
the_Geometry.Name := +the_xml_Name.Value;
end if;
parse_Mesh:
declare
the_xml_Mesh : access xml.Element renames the_xml_Geometry.Child ("mesh");
the_xml_Vertices : constant access xml.Element := the_xml_Mesh .Child ("vertices");
the_xml_Sources : constant xml.Elements := the_xml_Mesh.Children ("source");
begin
the_Geometry.Mesh.Sources := new library.Sources (the_xml_Sources'Range);
-- Parse sources.
--
for i in the_xml_Sources'Range
loop
the_Geometry.Mesh.Sources (i) := to_Source (the_xml_Sources (i).all);
end loop;
-- Parse vertices.
--
the_Geometry.Mesh.Vertices := to_Vertices (the_xml_Vertices.all);
-- Parse primitives.
--
declare
the_xml_Polylists : constant xml.Elements := the_xml_Mesh.Children (named => "polylist");
the_xml_Polygons : constant xml.Elements := the_xml_Mesh.Children (named => "polygons");
the_xml_Triangles : constant xml.Elements := the_xml_Mesh.Children (named => "triangles");
primitive_Count : Natural := 0;
primitive_Total : constant Natural := the_xml_Polylists'Length
+ the_xml_Polygons 'Length
+ the_xml_Triangles'Length;
begin
the_Geometry.Mesh.Primitives := new Primitives (1 .. primitive_Total);
-- polylists
--
for i in the_xml_Polylists'Range
loop
primitive_Count := primitive_Count + 1;
the_Geometry.Mesh.Primitives (primitive_Count) := to_Polylist (the_xml_Polylists (i).all);
end loop;
-- polygons
--
for i in the_xml_Polygons'Range
loop
primitive_Count := primitive_Count + 1;
the_Geometry.Mesh.Primitives (primitive_Count) := to_Polygon (the_xml_Polygons (i).all);
end loop;
-- Triangles
--
for i in the_xml_Triangles'Range
loop
primitive_Count := primitive_Count + 1;
the_Geometry.Mesh.Primitives (primitive_Count) := to_Triangles (the_xml_Triangles (i).all);
end loop;
end;
end parse_Mesh;
end;
end loop;
end;
end if;
end parse_the_geometries_Library;
-- Parse the controllers library.
--
declare
the_Library : constant access xml.Element := the_collada_Tree.Child (named => "library_controllers");
begin
if the_Library /= null
then
declare
use collada.Library.controllers;
the_Controllers : constant xml.Elements := the_Library.Children (named => "controller");
begin
the_Document.Libraries.controllers.Contents := new Controller_array (the_Controllers'Range);
for Each in the_Controllers'Range
loop
declare
the_xml_Controller : access xml.Element renames the_Controllers (Each);
the_Controller : Controller renames the_Document.Libraries.controllers.Contents (Each);
the_xml_Id : constant access xml.Attribute_t'Class := the_xml_Controller.Attribute ("id");
the_xml_Name : constant access xml.Attribute_t'Class := the_xml_Controller.Attribute ("name");
begin
the_Controller.Id := +the_xml_Id.Value;
if the_xml_Name /= null
then
the_Controller.Name := +the_xml_Name.Value;
end if;
parse_Skin:
declare
the_xml_Skin : access xml.Element renames the_xml_Controller.Child ("skin");
the_xml_Sources : constant xml.Elements := the_xml_Skin.Children ("source");
the_xml_Matrix : constant access xml.Element := the_xml_Skin.Child ("bind_shape_matrix");
the_xml_Joints : constant access xml.Element := the_xml_Skin.Child ("joints");
the_xml_Weights : constant access xml.Element := the_xml_Skin.Child ("vertex_weights");
begin
the_Controller.Skin.main_Source := +the_xml_Skin.Attribute ("source").Value;
the_Controller.Skin.bind_shape_Matrix := to_float_Array (the_xml_Matrix.Data);
-- Parse sources.
--
the_Controller.Skin.Sources := new library.Sources (the_xml_Sources'Range);
for i in the_xml_Sources'Range
loop
the_Controller.Skin.Sources (i) := to_Source (the_xml_Sources (i).all);
end loop;
the_Controller.Skin.Joints := to_Joints (the_xml_Joints.all);
the_Controller.Skin.vertex_Weights := to_vertex_Weights (the_xml_Weights.all);
end parse_Skin;
end;
end loop;
end;
end if;
end;
-- Parse the visual_Scenes library.
--
declare
the_Library : constant access xml.Element := the_collada_Tree.Child (named => "library_visual_scenes");
begin
if the_Library /= null
then
declare
use collada.Library.visual_scenes;
the_visual_Scenes : constant xml.Elements := the_Library.Children (named => "visual_scene");
begin
the_Document.Libraries.visual_Scenes.Contents := new visual_Scene_array (the_visual_Scenes'Range);
for Each in the_visual_Scenes'Range
loop
declare
the_visual_Scene : visual_Scene renames the_document.Libraries.visual_Scenes.Contents (Each);
the_xml_Scene : access xml.Element renames the_visual_Scenes (Each);
the_xml_Id : constant access xml.Attribute_t'Class := the_xml_Scene.Attribute ("id");
the_xml_Name : constant access xml.Attribute_t'Class := the_xml_Scene.Attribute ("name");
begin
the_visual_Scene.Id := +the_xml_Id.Value;
if the_xml_Name /= null
then
the_visual_Scene.Name := +the_xml_Name.Value;
end if;
parse_Nodes:
declare
the_xml_root_Node : constant access xml.Element := the_xml_Scene.Child ("node");
function to_Node (the_XML : access xml.Element;
Parent : in Library.visual_scenes.Node_view) return Library.visual_scenes.Node_view
is
the_xml_Sid : constant access xml.Attribute_t'Class := the_xml.Attribute ("sid");
the_xml_Id : constant access xml.Attribute_t'Class := the_xml.Attribute ("id");
the_xml_Name : constant access xml.Attribute_t'Class := the_xml.Attribute ("name");
the_xml_Type : access xml.Attribute_t'Class := the_xml.Attribute ("type");
the_xml_Translate : access xml.Element := the_xml.Child ("translate");
the_xml_Scale : access xml.Element := the_xml.Child ("scale");
the_xml_Rotates : xml.Elements := the_xml.Children ("rotate");
the_xml_Children : xml.Elements := the_xml.Children ("node");
the_Node : constant Library.visual_scenes.Node_view := new Library.visual_scenes.Node;
begin
if the_xml_Id /= null
then
the_Node.Id_is (+the_xml_Id.Value);
end if;
if the_xml_Sid /= null
then
the_Node.Sid_is (+the_xml_Sid.Value);
end if;
if the_xml_Name /= null
then
the_Node.Name_is (+the_xml_Name.Value);
end if;
the_Node.Parent_is (Parent);
-- Parse children.
--
declare
the_xml_Children : constant xml.Elements := the_XML.Children;
the_Child : access xml.Element;
begin
for i in the_xml_Children'Range
loop
the_Child := the_xml_Children (i);
if the_Child.Name = "translate"
then
the_Node.add (Transform' (Kind => Translate,
Sid => to_Text (the_Child.Attribute ("sid").Value),
Vector => Vector_3 (to_Float_array (the_Child.Data))));
elsif the_Child.Name = "rotate"
then
declare
use collada.Math;
the_Data : constant Vector_4 := Vector_4 (to_Float_array (the_Child.Data));
begin
the_Node.add (Transform' (Kind => Rotate,
Sid => to_Text (the_Child.Attribute ("sid").Value),
Axis => Vector_3 (the_Data (1 .. 3)),
Angle => to_Radians (math.Degrees (the_Data (4)))));
end;
elsif the_Child.Name = "scale"
then
the_Node.add (Transform' (Kind => Scale,
Sid => to_Text (the_Child.Attribute ("sid").Value),
Scale => Vector_3 (to_Float_array (the_Child.Data))));
elsif the_Child.Name = "matrix"
then
declare
the_Data : constant Matrix_4x4 := to_Matrix (the_Child.Data); -- Will be column vectors.
the_child_Sid : constant access xml.Attribute_t'Class := the_Child.Attribute ("sid");
the_sid_Text : Text;
begin
if the_child_Sid = null
then
the_sid_Text := to_Text ("");
else
the_sid_Text := to_Text (the_child_Sid.Value);
end if;
the_Node.add (Transform' (Kind => full_Transform,
Sid => the_sid_Text,
Matrix => the_Data));
end;
elsif the_Child.Name = "node"
then
the_Node.add (the_Child => to_Node (the_Child, Parent => the_Node)); -- Recurse.
elsif the_Child.Name = "instance_controller"
then
declare
the_skeleton_Child : constant access xml.Element := the_Child.Child ("skeleton");
begin
the_Document.Libraries.visual_Scenes.skeletal_Root := +the_skeleton_Child.Data (2 .. the_skeleton_Child.Data'Last);
end;
elsif the_Child.Name = "instance_geometry"
then
ada.Text_IO.put_Line ("TODO: Handle instance_geometry.");
else
ada.Text_IO.put_Line ("TODO: Unhandled collada 'visual scene element' found: " & the_Child.Name & ".");
end if;
end loop;
end;
return the_Node;
end to_Node;
begin
the_visual_Scene.root_Node := to_Node (the_xml_root_Node, Parent => null);
end parse_Nodes;
end;
end loop;
end;
end if;
end;
-- Parse the animations library.
--
declare
the_Library : constant access xml.Element := the_collada_Tree.Child (named => "library_animations");
begin
if the_Library /= null
then
declare
use collada.Library.animations;
the_Animations : constant xml.Elements := the_Library.Children (named => "animation");
begin
the_document.Libraries.animations.Contents := new Animation_array (the_Animations'Range);
for Each in the_Animations'Range
loop
declare
the_Animation : Animation renames the_document.Libraries.animations.Contents (Each);
child_Animation : constant access xml.Element := the_Animations (Each).Child ("animation");
the_xml_Animation : constant access xml.Element := (if child_Animation = null then the_Animations (Each) else child_Animation);
-- the_xml_Animation : access xml.Element renames the_Animations (Each); --.Child ("animation");
the_xml_Id : constant access xml.Attribute_t'Class := the_xml_Animation.Attribute ("id");
the_xml_Name : constant access xml.Attribute_t'Class := the_xml_Animation.Attribute ("name");
begin
the_Animation.Id := +the_xml_Id.Value;
if the_xml_Name /= null
then
the_Animation.Name := +the_xml_Name.Value;
end if;
the_Animation.Sampler := to_Sampler (the_xml_Animation.Child ("sampler").all);
the_Animation.Channel := to_Channel (the_xml_Animation.Child ("channel").all);
parse_Sources:
declare
the_xml_Sources : constant xml.Elements := the_xml_Animation.Children ("source");
begin
the_Animation.Sources := new library.Sources (the_xml_Sources'Range);
for i in the_xml_Sources'Range
loop
the_Animation.Sources (i) := to_Source (the_xml_Sources (i).all);
end loop;
end parse_Sources;
end;
end loop;
end;
end if;
end;
--- Parse the 'scene' element.
--
-- TODO
return the_Document;
end to_Document;
function Asset (Self : in Item) return collada.Asset.item
is
begin
return Self.Asset;
end Asset;
function Libraries (Self : in Item) return collada.Libraries.item
is
begin
return Self.Libraries;
end Libraries;
end collada.Document;
|
onox/sdlada | Ada | 4,436 | ads | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2018 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Inputs.Joysticks
--------------------------------------------------------------------------------------------------------------------
with Ada.Finalization;
private with SDL.C_Pointers;
with SDL.Events.Joysticks;
package SDL.Inputs.Joysticks is
Joystick_Error : exception;
-- Use to determine whether there are no joysticks.
type All_Devices is range 0 .. 2 ** 31 - 1 with
Convention => C,
Size => 32;
-- This range is the range of all connected joysticks.
subtype Devices is All_Devices range All_Devices'First + 1 .. All_Devices'Last;
-- SDL_Joystick_ID = instance ID.
type Instances is range 0 .. 2 ** 31 - 1 with
Convention => C,
Size => 32;
type GUID_Element is range 0 .. 255 with
convention => C,
Size => 8;
type GUID_Array is array (1 .. 16) of aliased GUID_Element with
Convention => C;
-- Pack => True;
type GUIDs is
record
Data : GUID_Array;
end record with
Convention => C_Pass_By_Copy;
-- Device specific information.
function Total return All_Devices;
function Name (Device : in Devices) return String;
function GUID (Device : in Devices) return GUIDs;
-- GUID utilities.
function Image (GUID : in GUIDs) return String;
function Value (GUID : in String) return GUIDs;
-- Joysticks.
type Joystick is new Ada.Finalization.Limited_Controlled with private;
Null_Joystick : constant Joystick;
function "=" (Left, Right : in Joystick) return Boolean with
Inline => True;
procedure Close (Self : in out Joystick);
-- Information.
function Axes (Self : in Joystick) return SDL.Events.Joysticks.Axes;
function Balls (Self : in Joystick) return SDL.Events.Joysticks.Balls;
function Buttons (Self : in Joystick) return SDL.Events.Joysticks.Buttons;
function Hats (Self : in Joystick) return SDL.Events.Joysticks.Hats;
function Name (Self : in Joystick) return String;
function Is_Haptic (Self : in Joystick) return Boolean;
function Is_Attached (Self : in Joystick) return Boolean;
function GUID (Self : in Joystick) return GUIDs;
function Instance (Self : in Joystick) return Instances;
-- Data.
function Axis_Value (Self : in Joystick;
Axis : in SDL.Events.Joysticks.Axes) return SDL.Events.Joysticks.Axes_Values;
procedure Ball_Value (Self : in Joystick;
Ball : in SDL.Events.Joysticks.Balls;
Delta_X, Delta_Y : out SDL.Events.Joysticks.Ball_Values);
function Hat_Value (Self : in Joystick;
Hat : in SDL.Events.Joysticks.Hats) return SDL.Events.Joysticks.Hat_Positions;
function Is_Button_Pressed (Self : in Joystick; Button : in SDL.Events.Joysticks.Buttons)
return SDL.Events.Button_State;
private
type Joystick is new Ada.Finalization.Limited_Controlled with
record
Internal : SDL.C_Pointers.Joystick_Pointer := null;
Owns : Boolean := True;
end record;
Null_Joystick : constant Joystick := (Ada.Finalization.Limited_Controlled with Internal => null, Owns => True);
end SDL.Inputs.Joysticks;
|
rguilloteau/pok | Ada | 462 | adb | -- POK header
--
-- The following file is a part of the POK project. Any modification should
-- be made according to the POK licence. You CANNOT use this file or a part
-- of a file for your own project.
--
-- For more information on the POK licence, please see our LICENCE FILE
--
-- Please follow the coding guidelines described in doc/CODING_GUIDELINES
--
-- Copyright (c) 2007-2020 POK team
|
reznikmm/matreshka | Ada | 5,021 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Strings.Hash;
with Ada.Tags;
with Ada.Unchecked_Deallocation;
package body Web_Services.SOAP.Messages is
--------------
-- Finalize --
--------------
procedure Finalize (Self : in out SOAP_Message) is
procedure Free is
new Ada.Unchecked_Deallocation
(Web_Services.SOAP.Headers.Abstract_SOAP_Header'Class,
Web_Services.SOAP.Headers.SOAP_Header_Access);
procedure Free is
new Ada.Unchecked_Deallocation
(Web_Services.SOAP.Payloads.Abstract_SOAP_Payload'Class,
Web_Services.SOAP.Payloads.SOAP_Payload_Access);
Position : Header_Sets.Cursor;
Header : Web_Services.SOAP.Headers.SOAP_Header_Access;
begin
while not Self.Headers.Is_Empty loop
Position := Self.Headers.First;
Header := Header_Sets.Element (Position);
Self.Headers.Delete (Position);
Free (Header);
end loop;
Free (Self.Payload);
end Finalize;
----------
-- Free --
----------
procedure Free (Message : in out SOAP_Message_Access) is
procedure Free is
new Ada.Unchecked_Deallocation
(Web_Services.SOAP.Messages.SOAP_Message,
Web_Services.SOAP.Messages.SOAP_Message_Access);
begin
if Message /= null then
Finalize (Message.all);
Free (Message);
end if;
end Free;
----------
-- Hash --
----------
function Hash
(Item : Web_Services.SOAP.Headers.SOAP_Header_Access)
return Ada.Containers.Hash_Type is
begin
return Ada.Strings.Hash (Ada.Tags.External_Tag (Item'Tag));
end Hash;
end Web_Services.SOAP.Messages;
|
stcarrez/bbox-ada-api | Ada | 4,161 | adb | -----------------------------------------------------------------------
-- druss-config -- Configuration management for Druss
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Environment_Variables;
with Ada.Directories;
with Ada.Strings.Unbounded;
with Interfaces.C.Strings;
with Util.Files;
with Util.Log.Loggers;
with Util.Systems.Os;
with Util.Properties;
package body Druss.Config is
use Ada.Strings.Unbounded;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Druss.Config");
function Get_Default_Path return String;
procedure Save;
Cfg : Util.Properties.Manager;
Cfg_Path : Ada.Strings.Unbounded.Unbounded_String;
-- ------------------------------
-- Get the default configuration path.
-- ------------------------------
function Get_Default_Path return String is
Home : constant String := Ada.Environment_Variables.Value ("HOME");
Def_Path : constant String := Util.Files.Compose (Home, ".config/druss/druss.properties");
begin
return Def_Path;
end Get_Default_Path;
-- ------------------------------
-- Initialize the configuration.
-- ------------------------------
procedure Initialize (Path : in String) is
Def_Path : constant String := Get_Default_Path;
begin
if Path'Length > 0 and then Ada.Directories.Exists (Path) then
Cfg.Load_Properties (Path);
Cfg_Path := Ada.Strings.Unbounded.To_Unbounded_String (Path);
elsif Ada.Directories.Exists (Def_Path) then
Cfg.Load_Properties (Def_Path);
Cfg_Path := Ada.Strings.Unbounded.To_Unbounded_String (Def_Path);
end if;
end Initialize;
procedure Save is
Path : constant String
:= (if Length (Cfg_Path) = 0 then Get_Default_Path else To_String (Cfg_Path));
Dir : constant String := Ada.Directories.Containing_Directory (Path);
P : Interfaces.C.Strings.chars_ptr;
begin
if not Ada.Directories.Exists (Path) then
Ada.Directories.Create_Path (Dir);
P := Interfaces.C.Strings.New_String (Dir);
if Util.Systems.Os.Sys_Chmod (P, 8#0700#) /= 0 then
Log.Error ("Cannot set the permission of {0}", Dir);
end if;
Interfaces.C.Strings.Free (P);
end if;
Cfg.Save_Properties (Path);
-- Set the permission on the file to allow only the user to read/write that file.
P := Interfaces.C.Strings.New_String (Path);
if Util.Systems.Os.Sys_Chmod (P, 8#0600#) /= 0 then
Log.Error ("Cannot set the permission of {0}", Path);
end if;
Interfaces.C.Strings.Free (P);
end Save;
-- ------------------------------
-- Get the configuration parameter.
-- ------------------------------
function Get (Name : in String) return String is
begin
return Cfg.Get (Name);
end Get;
-- ------------------------------
-- Initalize the list of gateways from the configuration file.
-- ------------------------------
procedure Get_Gateways (List : in out Druss.Gateways.Gateway_Vector) is
begin
Druss.Gateways.Initialize (Cfg, List);
end Get_Gateways;
-- ------------------------------
-- Save the list of gateways.
-- ------------------------------
procedure Save_Gateways (List : in Druss.Gateways.Gateway_Vector) is
begin
Druss.Gateways.Save_Gateways (Cfg, List);
Save;
end Save_Gateways;
end Druss.Config;
|
zhmu/ananas | Ada | 5,213 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . T A S K _ I N F O --
-- --
-- S p e c --
-- --
-- Copyright (C) 2007-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains the definitions and routines associated with the
-- implementation and use of the Task_Info pragma. It is specialized
-- appropriately for targets that make use of this pragma.
-- Note: the compiler generates direct calls to this interface, via Rtsfind.
-- Any changes to this interface may require corresponding compiler changes.
-- The functionality in this unit is now provided by the predefined package
-- System.Multiprocessors and the CPU aspect. This package is obsolescent.
-- This is the GNU/Linux version of this module
with System.OS_Interface;
package System.Task_Info is
pragma Obsolescent (Task_Info, "use System.Multiprocessors and CPU aspect");
pragma Preelaborate;
pragma Elaborate_Body;
-- To ensure that a body is allowed
-- The Linux kernel provides a way to define the ideal processor to use for
-- a given thread. The ideal processor is not necessarily the one that will
-- be used by the OS but the OS will always try to schedule this thread to
-- the specified processor if it is available.
-- The Task_Info pragma:
-- pragma Task_Info (EXPRESSION);
-- allows the specification on a task by task basis of a value of type
-- System.Task_Info.Task_Info_Type to be passed to a task when it is
-- created. The specification of this type, and the effect on the task
-- that is created is target dependent.
-- The Task_Info pragma appears within a task definition (compare the
-- definition and implementation of pragma Priority). If no such pragma
-- appears, then the value Unspecified_Task_Info is passed. If a pragma
-- is present, then it supplies an alternative value. If the argument of
-- the pragma is a discriminant reference, then the value can be set on
-- a task by task basis by supplying the appropriate discriminant value.
-- Note that this means that the type used for Task_Info_Type must be
-- suitable for use as a discriminant (i.e. a scalar or access type).
-----------------------
-- Thread Attributes --
-----------------------
subtype CPU_Set is System.OS_Interface.cpu_set_t;
Any_CPU : constant CPU_Set := (bits => [others => True]);
No_CPU : constant CPU_Set := (bits => [others => False]);
Invalid_CPU_Number : exception;
-- Raised when an invalid CPU mask has been specified
-- i.e. An empty CPU set
type Thread_Attributes is record
CPU_Affinity : aliased CPU_Set := Any_CPU;
end record;
Default_Thread_Attributes : constant Thread_Attributes := (others => <>);
type Task_Info_Type is access all Thread_Attributes;
Unspecified_Task_Info : constant Task_Info_Type := null;
function Number_Of_Processors return Positive;
-- Returns the number of processors on the running host
end System.Task_Info;
|
reznikmm/matreshka | Ada | 4,550 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Svg.Bbox_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Svg_Bbox_Attribute_Node is
begin
return Self : Svg_Bbox_Attribute_Node do
Matreshka.ODF_Svg.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Svg_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Svg_Bbox_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Bbox_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Svg_URI,
Matreshka.ODF_String_Constants.Bbox_Attribute,
Svg_Bbox_Attribute_Node'Tag);
end Matreshka.ODF_Svg.Bbox_Attributes;
|
reznikmm/matreshka | Ada | 565 | adb | with Styx.Request_Visiters;
with Styx.Reply_Visiters;
package body Styx.Messages.Versions is
-----------
-- Visit --
-----------
procedure Visit
(Visiter : in out Styx.Request_Visiters.Request_Visiter'Class;
Value : Version_Request) is
begin
Visiter.Version (Value);
end Visit;
-----------
-- Visit --
-----------
procedure Visit
(Visiter : in out Styx.Reply_Visiters.Reply_Visiter'Class;
Value : Version_Reply) is
begin
Visiter.Version (Value);
end Visit;
end Styx.Messages.Versions;
|
zhmu/ananas | Ada | 22,397 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . D I R E C T O R Y _ O P E R A T I O N S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1998-2022, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.IO_Exceptions;
with Ada.Characters.Handling;
with Ada.Strings.Fixed;
with Ada.Unchecked_Deallocation;
with Ada.Unchecked_Conversion;
with System; use System;
with System.CRTL; use System.CRTL;
with GNAT.OS_Lib;
package body GNAT.Directory_Operations is
use Ada;
Filename_Max : constant Integer := 1024;
-- 1024 is the value of FILENAME_MAX in stdio.h
procedure Free is new
Ada.Unchecked_Deallocation (Dir_Type_Value, Dir_Type);
On_Windows : constant Boolean := GNAT.OS_Lib.Directory_Separator = '\';
-- An indication that we are on Windows. Used in Get_Current_Dir, to
-- deal with drive letters in the beginning of absolute paths.
---------------
-- Base_Name --
---------------
function Base_Name
(Path : Path_Name;
Suffix : String := "") return String
is
function Get_File_Names_Case_Sensitive return Integer;
pragma Import
(C, Get_File_Names_Case_Sensitive,
"__gnat_get_file_names_case_sensitive");
Case_Sensitive_File_Name : constant Boolean :=
Get_File_Names_Case_Sensitive = 1;
function Basename
(Path : Path_Name;
Suffix : String := "") return String;
-- This function does the job. The only difference between Basename
-- and Base_Name (the parent function) is that the former is case
-- sensitive, while the latter is not. Path and Suffix are adjusted
-- appropriately before calling Basename under platforms where the
-- file system is not case sensitive.
--------------
-- Basename --
--------------
function Basename
(Path : Path_Name;
Suffix : String := "") return String
is
Cut_Start : Natural :=
Strings.Fixed.Index
(Path, Dir_Seps, Going => Strings.Backward);
Cut_End : Natural;
begin
-- Cut_Start point to the first basename character
Cut_Start := (if Cut_Start = 0 then Path'First else Cut_Start + 1);
-- Cut_End point to the last basename character
Cut_End := Path'Last;
-- If basename ends with Suffix, adjust Cut_End
if Suffix /= ""
and then Path (Path'Last - Suffix'Length + 1 .. Cut_End) = Suffix
then
Cut_End := Path'Last - Suffix'Length;
end if;
Check_For_Standard_Dirs : declare
Offset : constant Integer := Path'First - Base_Name.Path'First;
BN : constant String :=
Base_Name.Path (Cut_Start - Offset .. Cut_End - Offset);
-- Here we use Base_Name.Path to keep the original casing
Has_Drive_Letter : constant Boolean :=
OS_Lib.Path_Separator /= ':';
-- If Path separator is not ':' then we are on a DOS based OS
-- where this character is used as a drive letter separator.
begin
if BN = "." or else BN = ".." then
return "";
elsif Has_Drive_Letter
and then BN'Length > 2
and then Characters.Handling.Is_Letter (BN (BN'First))
and then BN (BN'First + 1) = ':'
then
-- We have a DOS drive letter prefix, remove it
return BN (BN'First + 2 .. BN'Last);
else
return BN;
end if;
end Check_For_Standard_Dirs;
end Basename;
-- Start of processing for Base_Name
begin
if Path'Length <= Suffix'Length then
return Path;
end if;
if Case_Sensitive_File_Name then
return Basename (Path, Suffix);
else
return Basename
(Characters.Handling.To_Lower (Path),
Characters.Handling.To_Lower (Suffix));
end if;
end Base_Name;
----------------
-- Change_Dir --
----------------
procedure Change_Dir (Dir_Name : Dir_Name_Str) is
C_Dir_Name : constant String := Dir_Name & ASCII.NUL;
begin
if chdir (C_Dir_Name) /= 0 then
raise Directory_Error;
end if;
end Change_Dir;
-----------
-- Close --
-----------
procedure Close (Dir : in out Dir_Type) is
Discard : Integer;
pragma Warnings (Off, Discard);
function closedir (directory : DIRs) return Integer;
pragma Import (C, closedir, "__gnat_closedir");
begin
if not Is_Open (Dir) then
raise Directory_Error;
end if;
Discard := closedir (DIRs (Dir.all));
Free (Dir);
end Close;
--------------
-- Dir_Name --
--------------
function Dir_Name (Path : Path_Name) return Dir_Name_Str is
Last_DS : constant Natural :=
Strings.Fixed.Index
(Path, Dir_Seps, Going => Strings.Backward);
begin
if Last_DS = 0 then
-- There is no directory separator, returns current working directory
return "." & Dir_Separator;
else
return Path (Path'First .. Last_DS);
end if;
end Dir_Name;
-----------------
-- Expand_Path --
-----------------
function Expand_Path
(Path : Path_Name;
Mode : Environment_Style := System_Default) return Path_Name
is
Environment_Variable_Char : Character;
pragma Import (C, Environment_Variable_Char, "__gnat_environment_char");
Result : OS_Lib.String_Access := new String (1 .. 200);
Result_Last : Natural := 0;
procedure Append (C : Character);
procedure Append (S : String);
-- Append to Result
procedure Double_Result_Size;
-- Reallocate Result, doubling its size
function Is_Var_Prefix (C : Character) return Boolean;
pragma Inline (Is_Var_Prefix);
procedure Read (K : in out Positive);
-- Update Result while reading current Path starting at position K. If
-- a variable is found, call Var below.
procedure Var (K : in out Positive);
-- Translate variable name starting at position K with the associated
-- environment value.
------------
-- Append --
------------
procedure Append (C : Character) is
begin
if Result_Last = Result'Last then
Double_Result_Size;
end if;
Result_Last := Result_Last + 1;
Result (Result_Last) := C;
end Append;
procedure Append (S : String) is
begin
while Result_Last + S'Length - 1 > Result'Last loop
Double_Result_Size;
end loop;
Result (Result_Last + 1 .. Result_Last + S'Length) := S;
Result_Last := Result_Last + S'Length;
end Append;
------------------------
-- Double_Result_Size --
------------------------
procedure Double_Result_Size is
New_Result : constant OS_Lib.String_Access :=
new String (1 .. 2 * Result'Last);
begin
New_Result (1 .. Result_Last) := Result (1 .. Result_Last);
OS_Lib.Free (Result);
Result := New_Result;
end Double_Result_Size;
-------------------
-- Is_Var_Prefix --
-------------------
function Is_Var_Prefix (C : Character) return Boolean is
begin
return (C = Environment_Variable_Char and then Mode = System_Default)
or else
(C = '$' and then (Mode = UNIX or else Mode = Both))
or else
(C = '%' and then (Mode = DOS or else Mode = Both));
end Is_Var_Prefix;
----------
-- Read --
----------
procedure Read (K : in out Positive) is
P : Character;
begin
For_All_Characters : loop
if Is_Var_Prefix (Path (K)) then
P := Path (K);
-- Could be a variable
if K < Path'Last then
if Path (K + 1) = P then
-- Not a variable after all, this is a double $ or %,
-- just insert one in the result string.
Append (P);
K := K + 1;
else
-- Let's parse the variable
Var (K);
end if;
else
-- We have an ending $ or % sign
Append (P);
end if;
else
-- This is a standard character, just add it to the result
Append (Path (K));
end if;
-- Skip to next character
K := K + 1;
exit For_All_Characters when K > Path'Last;
end loop For_All_Characters;
end Read;
---------
-- Var --
---------
procedure Var (K : in out Positive) is
P : constant Character := Path (K);
T : Character;
E : Positive;
begin
K := K + 1;
pragma Annotate (CodePeer, Modified, P);
if P = '%' or else Path (K) = '{' then
-- Set terminator character
if P = '%' then
T := '%';
else
T := '}';
K := K + 1;
end if;
-- Look for terminator character, k point to the first character
-- for the variable name.
E := K;
loop
E := E + 1;
exit when Path (E) = T or else E = Path'Last;
end loop;
if Path (E) = T then
-- OK found, translate with environment value
declare
Env : OS_Lib.String_Access :=
OS_Lib.Getenv (Path (K .. E - 1));
begin
Append (Env.all);
OS_Lib.Free (Env);
end;
else
-- No terminator character, not a variable after all or a
-- syntax error, ignore it, insert string as-is.
Append (P); -- Add prefix character
if T = '}' then -- If we were looking for curly bracket
Append ('{'); -- terminator, add the curly bracket
end if;
Append (Path (K .. E));
end if;
else
-- The variable name is everything from current position to first
-- non letter/digit character.
E := K;
-- Check that first character is a letter
if Characters.Handling.Is_Letter (Path (E)) then
E := E + 1;
Var_Name : loop
exit Var_Name when E > Path'Last;
if Characters.Handling.Is_Letter (Path (E))
or else Characters.Handling.Is_Digit (Path (E))
then
E := E + 1;
else
exit Var_Name;
end if;
end loop Var_Name;
E := E - 1;
declare
Env : OS_Lib.String_Access := OS_Lib.Getenv (Path (K .. E));
begin
Append (Env.all);
OS_Lib.Free (Env);
end;
else
-- This is not a variable after all
Append ('$');
Append (Path (E));
end if;
end if;
K := E;
end Var;
-- Start of processing for Expand_Path
begin
declare
K : Positive := Path'First;
begin
Read (K);
declare
Returned_Value : constant String := Result (1 .. Result_Last);
begin
OS_Lib.Free (Result);
return Returned_Value;
end;
end;
end Expand_Path;
--------------------
-- File_Extension --
--------------------
function File_Extension (Path : Path_Name) return String is
First : Natural :=
Strings.Fixed.Index
(Path, Dir_Seps, Going => Strings.Backward);
Dot : Natural;
begin
if First = 0 then
First := Path'First;
end if;
Dot := Strings.Fixed.Index (Path (First .. Path'Last),
".",
Going => Strings.Backward);
if Dot = 0 or else Dot = Path'Last then
return "";
else
return Path (Dot .. Path'Last);
end if;
end File_Extension;
---------------
-- File_Name --
---------------
function File_Name (Path : Path_Name) return String is
begin
return Base_Name (Path);
end File_Name;
---------------------
-- Format_Pathname --
---------------------
function Format_Pathname
(Path : Path_Name;
Style : Path_Style := System_Default) return String
is
N_Path : String := Path;
K : Positive := N_Path'First;
Prev_Dirsep : Boolean := False;
begin
if Dir_Separator = '\'
and then Path'Length > 1
and then Path (K .. K + 1) = "\\"
then
if Style = UNIX then
N_Path (K .. K + 1) := "//";
end if;
K := K + 2;
end if;
for J in K .. Path'Last loop
if Strings.Maps.Is_In (Path (J), Dir_Seps) then
if not Prev_Dirsep then
case Style is
when UNIX => N_Path (K) := '/';
when DOS => N_Path (K) := '\';
when System_Default => N_Path (K) := Dir_Separator;
end case;
K := K + 1;
end if;
Prev_Dirsep := True;
else
N_Path (K) := Path (J);
K := K + 1;
Prev_Dirsep := False;
end if;
end loop;
return N_Path (N_Path'First .. K - 1);
end Format_Pathname;
---------------------
-- Get_Current_Dir --
---------------------
Max_Path : Integer;
pragma Import (C, Max_Path, "__gnat_max_path_len");
function Get_Current_Dir return Dir_Name_Str is
Current_Dir : String (1 .. Max_Path + 1);
Last : Natural;
begin
Get_Current_Dir (Current_Dir, Last);
return Current_Dir (1 .. Last);
end Get_Current_Dir;
procedure Get_Current_Dir (Dir : out Dir_Name_Str; Last : out Natural) is
Path_Len : Natural := Max_Path;
Buffer : String (Dir'First .. Dir'First + Max_Path + 1);
procedure Local_Get_Current_Dir
(Dir : System.Address;
Length : System.Address);
pragma Import (C, Local_Get_Current_Dir, "__gnat_get_current_dir");
begin
Local_Get_Current_Dir (Buffer'Address, Path_Len'Address);
if Path_Len = 0 then
raise Ada.IO_Exceptions.Use_Error
with "current directory does not exist";
end if;
Last :=
(if Dir'Length > Path_Len then Dir'First + Path_Len - 1 else Dir'Last);
Dir (Buffer'First .. Last) := Buffer (Buffer'First .. Last);
-- By default, the drive letter on Windows is in upper case
if On_Windows and then Last > Dir'First and then
Dir (Dir'First + 1) = ':'
then
Dir (Dir'First) :=
Ada.Characters.Handling.To_Upper (Dir (Dir'First));
end if;
end Get_Current_Dir;
-------------
-- Is_Open --
-------------
function Is_Open (Dir : Dir_Type) return Boolean is
begin
return Dir /= Null_Dir
and then System.Address (Dir.all) /= System.Null_Address;
end Is_Open;
--------------
-- Make_Dir --
--------------
procedure Make_Dir (Dir_Name : Dir_Name_Str) is
C_Dir_Name : constant String := Dir_Name & ASCII.NUL;
begin
if CRTL.mkdir (C_Dir_Name, Unspecified) /= 0 then
raise Directory_Error;
end if;
end Make_Dir;
----------
-- Open --
----------
procedure Open
(Dir : out Dir_Type;
Dir_Name : Dir_Name_Str)
is
function opendir (file_name : String) return DIRs;
pragma Import (C, opendir, "__gnat_opendir");
C_File_Name : constant String := Dir_Name & ASCII.NUL;
begin
Dir := new Dir_Type_Value'(Dir_Type_Value (opendir (C_File_Name)));
if not Is_Open (Dir) then
Free (Dir);
Dir := Null_Dir;
raise Directory_Error;
end if;
end Open;
----------
-- Read --
----------
procedure Read
(Dir : Dir_Type;
Str : out String;
Last : out Natural)
is
Filename_Addr : Address;
Filename_Len : aliased Integer;
Buffer : array (0 .. Filename_Max + 12) of Character;
-- 12 is the size of the dirent structure (see dirent.h), without the
-- field for the filename.
function readdir_gnat
(Directory : System.Address;
Buffer : System.Address;
Last : not null access Integer) return System.Address;
pragma Import (C, readdir_gnat, "__gnat_readdir");
begin
if not Is_Open (Dir) then
raise Directory_Error;
end if;
Filename_Addr :=
readdir_gnat
(System.Address (Dir.all), Buffer'Address, Filename_Len'Access);
if Filename_Addr = System.Null_Address then
Last := 0;
return;
end if;
Last :=
(if Str'Length > Filename_Len then Str'First + Filename_Len - 1
else Str'Last);
declare
subtype Path_String is String (1 .. Filename_Len);
type Path_String_Access is access Path_String;
function Address_To_Access is new
Ada.Unchecked_Conversion
(Source => Address,
Target => Path_String_Access);
Path_Access : constant Path_String_Access :=
Address_To_Access (Filename_Addr);
begin
for J in Str'First .. Last loop
Str (J) := Path_Access (J - Str'First + 1);
end loop;
end;
end Read;
-------------------------
-- Read_Is_Thread_Safe --
-------------------------
function Read_Is_Thread_Safe return Boolean is
function readdir_is_thread_safe return Integer;
pragma Import
(C, readdir_is_thread_safe, "__gnat_readdir_is_thread_safe");
begin
return (readdir_is_thread_safe /= 0);
end Read_Is_Thread_Safe;
----------------
-- Remove_Dir --
----------------
procedure Remove_Dir
(Dir_Name : Dir_Name_Str;
Recursive : Boolean := False)
is
C_Dir_Name : constant String := Dir_Name & ASCII.NUL;
Last : Integer;
Str : String (1 .. Filename_Max);
Success : Boolean;
Current_Dir : Dir_Type;
begin
-- Remove the directory only if it is empty
if not Recursive then
if rmdir (C_Dir_Name) /= 0 then
raise Directory_Error;
end if;
-- Remove directory and all files and directories that it may contain
else
Open (Current_Dir, Dir_Name);
loop
Read (Current_Dir, Str, Last);
exit when Last = 0;
if GNAT.OS_Lib.Is_Directory
(Dir_Name & Dir_Separator & Str (1 .. Last))
then
if Str (1 .. Last) /= "."
and then
Str (1 .. Last) /= ".."
then
-- Recursive call to remove a subdirectory and all its
-- files.
Remove_Dir
(Dir_Name & Dir_Separator & Str (1 .. Last),
True);
end if;
else
GNAT.OS_Lib.Delete_File
(Dir_Name & Dir_Separator & Str (1 .. Last),
Success);
if not Success then
raise Directory_Error;
end if;
end if;
end loop;
Close (Current_Dir);
Remove_Dir (Dir_Name);
end if;
end Remove_Dir;
end GNAT.Directory_Operations;
|
rui314/mold | Ada | 4,330 | ads | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: zlib-streams.ads,v 1.12 2004/05/31 10:53:40 vagul Exp $
package ZLib.Streams is
type Stream_Mode is (In_Stream, Out_Stream, Duplex);
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
type Stream_Type is
new Ada.Streams.Root_Stream_Type with private;
procedure Read
(Stream : in out Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Write
(Stream : in out Stream_Type;
Item : in Ada.Streams.Stream_Element_Array);
procedure Flush
(Stream : in out Stream_Type;
Mode : in Flush_Mode := Sync_Flush);
-- Flush the written data to the back stream,
-- all data placed to the compressor is flushing to the Back stream.
-- Should not be used until necessary, because it is decreasing
-- compression.
function Read_Total_In (Stream : in Stream_Type) return Count;
pragma Inline (Read_Total_In);
-- Return total number of bytes read from back stream so far.
function Read_Total_Out (Stream : in Stream_Type) return Count;
pragma Inline (Read_Total_Out);
-- Return total number of bytes read so far.
function Write_Total_In (Stream : in Stream_Type) return Count;
pragma Inline (Write_Total_In);
-- Return total number of bytes written so far.
function Write_Total_Out (Stream : in Stream_Type) return Count;
pragma Inline (Write_Total_Out);
-- Return total number of bytes written to the back stream.
procedure Create
(Stream : out Stream_Type;
Mode : in Stream_Mode;
Back : in Stream_Access;
Back_Compressed : in Boolean;
Level : in Compression_Level := Default_Compression;
Strategy : in Strategy_Type := Default_Strategy;
Header : in Header_Type := Default;
Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size;
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size);
-- Create the Compression/Decompression stream.
-- If mode is In_Stream then Write operation is disabled.
-- If mode is Out_Stream then Read operation is disabled.
-- If Back_Compressed is true then
-- Data written to the Stream is compressing to the Back stream
-- and data read from the Stream is decompressed data from the Back stream.
-- If Back_Compressed is false then
-- Data written to the Stream is decompressing to the Back stream
-- and data read from the Stream is compressed data from the Back stream.
-- !!! When the Need_Header is False ZLib-Ada is using undocumented
-- ZLib 1.1.4 functionality to do not create/wait for ZLib headers.
function Is_Open (Stream : Stream_Type) return Boolean;
procedure Close (Stream : in out Stream_Type);
private
use Ada.Streams;
type Buffer_Access is access all Stream_Element_Array;
type Stream_Type
is new Root_Stream_Type with
record
Mode : Stream_Mode;
Buffer : Buffer_Access;
Rest_First : Stream_Element_Offset;
Rest_Last : Stream_Element_Offset;
-- Buffer for Read operation.
-- We need to have this buffer in the record
-- because not all read data from back stream
-- could be processed during the read operation.
Buffer_Size : Stream_Element_Offset;
-- Buffer size for write operation.
-- We do not need to have this buffer
-- in the record because all data could be
-- processed in the write operation.
Back : Stream_Access;
Reader : Filter_Type;
Writer : Filter_Type;
end record;
end ZLib.Streams;
|
reznikmm/matreshka | Ada | 4,017 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Text_Number_Lines_Attributes;
package Matreshka.ODF_Text.Number_Lines_Attributes is
type Text_Number_Lines_Attribute_Node is
new Matreshka.ODF_Text.Abstract_Text_Attribute_Node
and ODF.DOM.Text_Number_Lines_Attributes.ODF_Text_Number_Lines_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Number_Lines_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Number_Lines_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Text.Number_Lines_Attributes;
|
adamkruszewski/qweyboard | Ada | 2,819 | adb | with String_Helpers; use String_Helpers;
with Ada.Command_Line;
with Ada.Task_Termination;
with Ada.Task_Identification;
with Configuration;
with Logging;
with Qweyboard;
with Input_Backend;
with Output_Backend;
procedure Main is
use Logging;
Settings : Configuration.Settings;
begin
Ada.Task_Termination.Set_Specific_Handler (Ada.Task_Identification.Current_Task, Logging.Termination_Handler.Diagnostics'Access);
Ada.Task_Termination.Set_Dependents_Fallback_Handler (Logging.Termination_Handler.Diagnostics'Access);
Configuration.Get_Settings (Settings);
Log.Set_Verbosity (Settings.Log_Level);
Log.Chat ("[Main] Got settings and set log verbosity");
Log.Chat ("[Main] Loading language");
Configuration.Load_Language (Settings);
-- Then kick off the Softboard!
Qweyboard.Softboard.Ready_Wait;
Log.Chat ("[Main] Softboard started");
-- Configure softboard
Qweyboard.Softboard.Configure (Settings);
Log.Chat ("[Main] Softboard configured");
-- First wait for the output backend to be ready
Output_Backend.Output.Ready_Wait;
Log.Chat ("[Main] Output backend ready");
-- Then wait for input backend to be ready
Input_Backend.Input.Ready_Wait;
Log.Chat ("[Main] Input backend ready");
exception
when Configuration.ARGUMENTS_ERROR =>
Log.Error ("Usage: " & W (Ada.Command_Line.Command_Name) & " [OPTION]");
Log.Error (" ");
Log.Error ("[OPTION] is any combination of the following options: ");
Log.Error (" ");
Log.Error (" -l <language file> : Modifies the standard layout with the ");
Log.Error (" key mappings indicated in the specified ");
Log.Error (" language file. ");
Log.Error (" ");
Log.Error (" -t <milliseconds> : Set the timeout for what counts as one ");
Log.Error (" stroke. If you want 0, NKRO is strongly ");
Log.Error (" recommended. Default value is 500, which ");
Log.Error (" is probably way too high. ");
Log.Error (" ");
Log.Error (" -v,-vv,-vvv : Sets the log level of the software. If you ");
Log.Error (" want to know what goes on inside, this is ");
Log.Error (" where to poke... ");
Ada.Command_Line.Set_Exit_Status (1);
end Main;
|
stcarrez/ada-awa | Ada | 7,999 | ads | -----------------------------------------------------------------------
-- awa-storages-services -- Storage service
-- Copyright (C) 2012, 2016, 2019, 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Calendar;
with Ada.Strings.Unbounded;
with Util.Concurrent.Counters;
with Security.Permissions;
with ADO;
with ASF.Parts;
with AWA.Modules;
with AWA.Modules.Lifecycles;
with AWA.Storages.Models;
with AWA.Storages.Stores;
with AWA.Storages.Stores.Databases;
-- == Storage Service ==
-- The <tt>Storage_Service</tt> provides the operations to access and use the persisent storage.
-- It controls the permissions that grant access to the service for users.
--
-- Other modules can be notified of storage changes by registering a listener
-- on the storage module.
--
-- @include awa-storages-stores.ads
package AWA.Storages.Services is
package ACL_Create_Storage is new Security.Permissions.Definition ("storage-create");
package ACL_Delete_Storage is new Security.Permissions.Definition ("storage-delete");
package ACL_Create_Folder is new Security.Permissions.Definition ("folder-create");
type Read_Mode is (READ, WRITE);
type Expire_Type is (ONE_HOUR, ONE_DAY, TWO_DAYS, ONE_WEEK, ONE_YEAR, NEVER);
package Storage_Lifecycle is
new AWA.Modules.Lifecycles (Element_Type => AWA.Storages.Models.Storage_Ref'Class);
subtype Listener is Storage_Lifecycle.Listener;
-- ------------------------------
-- Storage Service
-- ------------------------------
-- The <b>Storage_Service</b> defines a set of operations to store and retrieve
-- a data object from the persistent storage. The data object is treated as a raw
-- byte stream. The persistent storage can be implemented by a database, a file
-- system or a remote service such as Amazon AWS.
type Storage_Service is new AWA.Modules.Module_Manager with private;
type Storage_Service_Access is access all Storage_Service'Class;
-- Initializes the storage service.
overriding
procedure Initialize (Service : in out Storage_Service;
Module : in AWA.Modules.Module'Class);
-- Get the persistent store that manages the data store identified by <tt>Kind</tt>.
function Get_Store (Service : in Storage_Service;
Kind : in AWA.Storages.Models.Storage_Type)
return AWA.Storages.Stores.Store_Access;
-- Create or save the folder.
procedure Save_Folder (Service : in Storage_Service;
Folder : in out AWA.Storages.Models.Storage_Folder_Ref'Class);
-- Load the folder instance identified by the given identifier.
procedure Load_Folder (Service : in Storage_Service;
Folder : in out AWA.Storages.Models.Storage_Folder_Ref'Class;
Id : in ADO.Identifier);
-- Save the data object contained in the <b>Data</b> part element into the
-- target storage represented by <b>Into</b>.
procedure Save (Service : in Storage_Service;
Into : in out AWA.Storages.Models.Storage_Ref'Class;
Data : in ASF.Parts.Part'Class;
Storage : in AWA.Storages.Models.Storage_Type);
procedure Save (Service : in Storage_Service;
Into : in out AWA.Storages.Models.Storage_Ref'Class;
Data : in ASF.Parts.Part'Class);
-- Save the file described <b>File</b> in the storage
-- object represented by <b>Into</b> and managed by the storage service.
procedure Save (Service : in Storage_Service;
Into : in out AWA.Storages.Models.Storage_Ref'Class;
File : in AWA.Storages.Storage_File;
Storage : in AWA.Storages.Models.Storage_Type);
-- Save the file pointed to by the <b>Path</b> string in the storage
-- object represented by <b>Into</b> and managed by the storage service.
procedure Save (Service : in Storage_Service;
Into : in out AWA.Storages.Models.Storage_Ref'Class;
Path : in String;
Storage : in AWA.Storages.Models.Storage_Type);
-- Load the storage instance identified by the given identifier.
procedure Load_Storage (Service : in Storage_Service;
Storage : in out AWA.Storages.Models.Storage_Ref'Class;
Id : in ADO.Identifier);
-- Load the storage instance stored in a folder and identified by a name.
procedure Load_Storage (Service : in Storage_Service;
Storage : in out AWA.Storages.Models.Storage_Ref'Class;
Folder : in ADO.Identifier;
Name : in String;
Found : out Boolean);
-- Load the storage content identified by <b>From</b> into the blob descriptor <b>Into</b>.
-- Raises the <b>NOT_FOUND</b> exception if there is no such storage.
procedure Load (Service : in Storage_Service;
From : in ADO.Identifier;
Name : out Ada.Strings.Unbounded.Unbounded_String;
Mime : out Ada.Strings.Unbounded.Unbounded_String;
Date : out Ada.Calendar.Time;
Into : out ADO.Blob_Ref);
procedure Load (Service : in Storage_Service;
From : in ADO.Identifier;
Kind : in AWA.Storages.Models.Storage_Type;
Into : out ADO.Blob_Ref);
-- Load the storage content into a file. If the data is not stored in a file, a temporary
-- file is created with the data content fetched from the store (ex: the database).
-- The `Mode` parameter indicates whether the file will be read or written.
-- The `Expire` parameter allows to control the expiration of the temporary file.
procedure Get_Local_File (Service : in Storage_Service;
From : in ADO.Identifier;
Mode : in Read_Mode := READ;
Into : in out Storage_File);
procedure Create_Local_File (Service : in out Storage_Service;
Into : in out AWA.Storages.Storage_File);
-- Deletes the storage instance.
procedure Delete (Service : in Storage_Service;
Storage : in out AWA.Storages.Models.Storage_Ref'Class);
-- Deletes the storage instance.
procedure Delete (Service : in Storage_Service;
Storage : in ADO.Identifier);
-- Publish or not the storage instance.
procedure Publish (Service : in Storage_Service;
Id : in ADO.Identifier;
State : in Boolean;
File : in out AWA.Storages.Models.Storage_Ref'Class);
private
type Store_Access_Array is
array (AWA.Storages.Models.Storage_Type) of AWA.Storages.Stores.Store_Access;
type Storage_Service is new AWA.Modules.Module_Manager with record
Stores : Store_Access_Array;
Database_Store : aliased AWA.Storages.Stores.Databases.Database_Store;
Database_Max_Size : Natural;
Temp_Id : Util.Concurrent.Counters.Counter;
end record;
end AWA.Storages.Services;
|
sungyeon/drake | Ada | 5,605 | adb | -- *** this line is for test ***
with Ada.Calendar;
with Ada.Credentials;
with Ada.Directories.Information;
with Ada.Directories.Temporary;
with Ada.Directories.Volumes;
with Ada.Text_IO;
procedure directories is
use type Ada.Calendar.Time;
use type Ada.Directories.File_Kind;
use type Ada.Directories.File_Size;
use type Ada.Directories.Information.File_Id;
begin
Ada.Debug.Put ("**** user");
Ada.Debug.Put ("current user: " & Ada.Credentials.User_Name);
-- iteration (closure style)
Ada.Debug.Put ("**** iterate 1");
declare
First : Boolean := True;
procedure Process (Directory_Entry : Ada.Directories.Directory_Entry_Type) is
begin
if First then
Ada.Debug.Put (Ada.Directories.Information.Owner (Directory_Entry));
Ada.Debug.Put (Ada.Directories.Information.Group (Directory_Entry));
First := False;
end if;
Ada.Debug.Put (Ada.Directories.Simple_Name (Directory_Entry));
end Process;
begin
Ada.Directories.Search (".", "*", Process => Process'Access);
end;
-- iteration (AI12-0009-1, iterator)
Ada.Debug.Put ("**** iterate 2");
declare
Listing : aliased Ada.Directories.Directory_Listing :=
Ada.Directories.Entries (".");
Ite : Ada.Directories.Directory_Iterators.Forward_Iterator'Class :=
Ada.Directories.Iterate (Listing);
Position : Ada.Directories.Cursor :=
Ada.Directories.Directory_Iterators.First (Ite);
begin
while Ada.Directories.Has_Entry (Position) loop
Ada.Debug.Put (
Ada.Directories.Simple_Name (
Listing.Constant_Reference (Position).Element.all));
Position := Ada.Directories.Directory_Iterators.Next (Ite, Position);
end loop;
end;
-- iteration (AI12-0009-1, generalized loop iteration)
Ada.Debug.Put ("**** iterate 3");
for I of Ada.Directories.Entries (".") loop
Ada.Debug.Put (Ada.Directories.Simple_Name (I));
end loop;
-- copy
Ada.Debug.Put ("**** copy");
begin
Ada.Directories.Copy_File ("%%%%NOTHING1%%%%", "%%%%NOTHING2%%%%");
raise Program_Error;
exception
when Ada.Directories.Name_Error => null;
end;
-- modification time
Ada.Debug.Put ("**** modification time");
declare
Name : constant String := Ada.Directories.Temporary.Create_Temporary_File;
File : Ada.Text_IO.File_Type;
The_Time : constant Ada.Calendar.Time := Ada.Calendar.Time_Of (1999, 7, 1);
begin
Ada.Debug.Put (Name);
Ada.Text_IO.Create (File, Ada.Text_IO.Out_File, Name);
Ada.Text_IO.Close (File);
if abs (Ada.Directories.Modification_Time (Name) - Ada.Calendar.Clock) > 1.0 then
raise Program_Error;
end if;
Ada.Directories.Set_Modification_Time (Name, The_Time);
if abs (Ada.Directories.Modification_Time (Name) - The_Time) > 1.0 then
raise Program_Error;
end if;
Ada.Directories.Delete_File (Name);
end;
-- getting information by Name versus by Directory_Entry
Ada.Debug.Put ("**** information");
declare
Name : constant String := "directories.adb";
Directory_Entry : Ada.Directories.Directory_Entry_Type := Ada.Directories.Get_Entry (Name);
begin
pragma Assert (Ada.Directories.Simple_Name (Name) = Ada.Directories.Simple_Name (Directory_Entry));
pragma Assert (Ada.Directories.Kind (Name) = Ada.Directories.Kind (Directory_Entry));
pragma Assert (Ada.Directories.Size (Name) = Ada.Directories.Size (Directory_Entry));
pragma Assert (Ada.Directories.Modification_Time (Name) = Ada.Directories.Modification_Time (Directory_Entry));
pragma Assert (Ada.Directories.Information.Identity (Name) = Ada.Directories.Information.Identity (Directory_Entry));
null;
end;
-- user permissions
Ada.Debug.Put ("**** permissions");
declare
UP : Ada.Directories.Information.User_Permission_Set_Type :=
Ada.Directories.Information.User_Permission_Set ("directories.adb");
begin
for I in UP'Range loop
Ada.Debug.Put (
Ada.Directories.Information.User_Permission'Image (I)
& " => "
& Boolean'Image (UP (I)));
end loop;
end;
-- symbolic link
Ada.Debug.Put ("**** symbolic link");
declare
Source_Name : String := Ada.Directories.Full_Name ("directories.adb");
Linked_Name : String := Ada.Directories.Temporary.Create_Temporary_File;
File : Ada.Text_IO.File_Type;
begin
Ada.Debug.Put (Linked_Name);
Ada.Directories.Symbolic_Link (Source_Name, Linked_Name);
Ada.Text_IO.Open (File, Ada.Text_IO.In_File, Linked_Name);
if Ada.Text_IO.Get_Line (File) /= "-- *** this line is for test ***" then
raise Program_Error;
end if;
Ada.Text_IO.Close (File);
if Ada.Directories.Information.Read_Symbolic_Link (Linked_Name) /= Source_Name then
raise Program_Error;
end if;
Ada.Directories.Delete_File (Linked_Name);
end;
-- filesystem
Ada.Debug.Put ("**** file system");
declare
FS : Ada.Directories.Volumes.File_System := Ada.Directories.Volumes.Where ("directories.adb");
begin
pragma Assert (Ada.Directories.Volumes.Is_Assigned (FS));
Ada.Debug.Put (Ada.Directories.File_Size'Image (Ada.Directories.Volumes.Size (FS)));
Ada.Debug.Put (Ada.Directories.File_Size'Image (Ada.Directories.Volumes.Free_Space (FS)));
begin
Ada.Debug.Put (Ada.Directories.Volumes.Owner (FS));
exception
when Program_Error =>
Ada.Debug.Put ("Ada.Directories.Volumes.Owner is unimplemented!");
end;
Ada.Debug.Put (Ada.Directories.Volumes.Format_Name (FS));
Ada.Debug.Put (Ada.Directories.Volumes.Directory (FS));
Ada.Debug.Put (Ada.Directories.Volumes.Device (FS));
Ada.Debug.Put ("case preserving: " & Boolean'Image (Ada.Directories.Volumes.Case_Preserving (FS)));
Ada.Debug.Put ("case sensitive: " & Boolean'Image (Ada.Directories.Volumes.Case_Sensitive (FS)));
end;
Ada.Debug.Put ("OK");
end directories;
|
usainzg/EHU | Ada | 1,989 | adb | WITH Ada.Text_Io; USE Ada.Text_Io;
procedure Ver_Contiene_Caracter is
-- salida: 7 booleanos(SE)
-- post: corresponden a cada uno de los casos de pruebas dise�ados.
-- pre: { True }
function Contiene_Caracter (
S : String;
L : Character)
return Boolean is
-- EJERCICIO 3- ESPECIFICA E IMPLEMENTA recursivamente el subprograma
-- Contiene_a que decide si el string S contiene el car�cter 'a'.
BEGIN
-- Completar
if S'Size = 0 then
return False;
end if;
if S(S'First) = L then
return True;
end if;
return Contiene_Caracter(S(S'First + 1 .. S'Last), L);
end Contiene_Caracter ;
-- post: { True <=> Contiene_a(S, L) }
begin
Put_Line("-------------------------------------");
Put("La palabra vacia no contiene el caracter 'a': ");
Put(Boolean'Image(Contiene_Caracter("", 'a')));
New_Line;
New_Line;
New_Line;
Put_Line("-------------------------------------");
Put_Line("Palabras de un caracter");
Put("-- La palabra de 1 caracter 'a' contiene el caracter 'a': ");
Put(Boolean'Image(Contiene_Caracter("a", 'a')));
New_Line;
Put("-- La palabra de 1 caracter 'b' contiene el caracter 'b': ");
Put(Boolean'Image(Contiene_Caracter("b", 'b')));
New_Line;
New_Line;
New_Line;
Put_Line("-------------------------------------");
Put_Line("Palabras de varios caracteres");
Put("-- 'abcd' contiene el caracter 'b': ");
Put(Boolean'Image(Contiene_Caracter("abcd", 'b')));
New_Line;
Put("-- 'dcba' contiene el caracter 'a': ");
Put(Boolean'Image(Contiene_Caracter("dcba", 'a')));
New_Line;
Put("-- 'dcbabcd' contiene el caracter 'a': ");
Put(Boolean'Image(Contiene_Caracter("dcbabcd", 'a')));
New_Line;
Put("-- Pero 'dcbbcd' no contiene el caracter 'e': ");
Put(Boolean'Image(Contiene_Caracter("dcbbcd", 'e')));
New_Line;
Put_Line("-------------------------------------");
end Ver_Contiene_Caracter;
|
reznikmm/matreshka | Ada | 4,898 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- Circle is a graphical element that defines a circular shape with a given
-- center point and a radius.
------------------------------------------------------------------------------
limited with AMF.DC;
with AMF.DG.Graphical_Elements;
package AMF.DG.Circles is
pragma Preelaborate;
type DG_Circle is limited interface
and AMF.DG.Graphical_Elements.DG_Graphical_Element;
type DG_Circle_Access is
access all DG_Circle'Class;
for DG_Circle_Access'Storage_Size use 0;
not overriding function Get_Center
(Self : not null access constant DG_Circle)
return AMF.DC.DC_Point is abstract;
-- Getter of Circle::center.
--
-- the center point of the circle in the x-y coordinate system.
not overriding procedure Set_Center
(Self : not null access DG_Circle;
To : AMF.DC.DC_Point) is abstract;
-- Setter of Circle::center.
--
-- the center point of the circle in the x-y coordinate system.
not overriding function Get_Radius
(Self : not null access constant DG_Circle)
return AMF.Real is abstract;
-- Getter of Circle::radius.
--
-- a real number (>=0) that represents the radius of the circle.
not overriding procedure Set_Radius
(Self : not null access DG_Circle;
To : AMF.Real) is abstract;
-- Setter of Circle::radius.
--
-- a real number (>=0) that represents the radius of the circle.
end AMF.DG.Circles;
|
zhmu/ananas | Ada | 88 | adb | -- { dg-do compile }
package body Assert2 is
procedure Dummy is null;
end Assert2;
|
faelys/natools | Ada | 2,796 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2015, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.S_Expressions.Conditionals.Strings provides primitives to --
-- evaluate S-expression conditions about strings. --
------------------------------------------------------------------------------
with Natools.S_Expressions.Conditionals.Generic_Evaluate;
with Natools.S_Expressions.Lockable;
package Natools.S_Expressions.Conditionals.Strings is
pragma Preelaborate;
type Settings (Data : not null access constant String) is record
Case_Sensitive : Boolean := True;
end record;
type Context
(Data : not null access constant String;
Parametric_Fallback : access function
(Settings : in Strings.Settings;
Name : in Atom;
Arguments : in out Lockable.Descriptor'Class)
return Boolean;
Simple_Fallback : access function
(Settings : in Strings.Settings;
Name : in Atom)
return Boolean)
is record
Settings : Strings.Settings (Data);
end record;
function Parametric_Evaluate
(Context : in Strings.Context;
Name : in Atom;
Arguments : in out Lockable.Descriptor'Class)
return Boolean;
function Simple_Evaluate
(Context : in Strings.Context;
Name : in Atom)
return Boolean;
function Evaluate is new Generic_Evaluate
(Context, Parametric_Evaluate, Simple_Evaluate);
function Evaluate
(Text : in String;
Expression : in out Lockable.Descriptor'Class)
return Boolean;
end Natools.S_Expressions.Conditionals.Strings;
|
onox/sdlada | Ada | 2,051 | ads | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2018 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Video.Renderers.Makers
--
-- Constructor subprograms for Renderers.
--------------------------------------------------------------------------------------------------------------------
package SDL.Video.Renderers.Makers is
procedure Create
(Rend : in out Renderer;
Window : in out SDL.Video.Windows.Window;
Driver : in Positive;
Flags : in Renderer_Flags := Default_Renderer_Flags);
-- Specifically create a renderer using the first available driver.
procedure Create
(Rend : in out Renderer;
Window : in out SDL.Video.Windows.Window;
Flags : in Renderer_Flags := Default_Renderer_Flags);
-- Create a software renderer using a surface.
procedure Create
(Rend : in out Renderer;
Surface : in SDL.Video.Surfaces.Surface);
-- SDL_CreateWindowAndRenderer
end SDL.Video.Renderers.Makers;
|
wookey-project/ewok-legacy | Ada | 18,867 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ewok.exported.dma; use ewok.exported.dma;
with ewok.sanitize;
with ewok.tasks;
with ewok.interrupts;
with ewok.devices_shared;
with ewok.debug;
#if CONFIG_KERNEL_DOMAIN
with ewok.perm;
#end if;
with soc.dma; use soc.dma;
with soc.dma.interfaces; use soc.dma.interfaces;
with soc.nvic;
with c.socinfo; use type c.socinfo.t_device_soc_infos_access;
package body ewok.dma
with spark_mode => off
is
procedure get_registered_dma_entry
(index : out ewok.dma_shared.t_registered_dma_index;
success : out boolean)
is
begin
for id in registered_dma'range loop
if registered_dma(id).status = DMA_UNUSED then
registered_dma(id).status := DMA_USED;
index := id;
success := true;
return;
end if;
end loop;
success := false;
end get_registered_dma_entry;
function has_same_dma_channel
(index : ewok.dma_shared.t_registered_dma_index;
user_config : ewok.exported.dma.t_dma_user_config)
return boolean
is
begin
if registered_dma(index).config.dma_id =
soc.dma.t_dma_periph_index (user_config.controller)
and
registered_dma(index).config.stream =
soc.dma.t_stream_index (user_config.stream)
and
registered_dma(index).config.channel =
soc.dma.t_channel_index (user_config.channel)
then
return true;
else
return false;
end if;
end has_same_dma_channel;
function stream_is_already_used
(user_config : ewok.exported.dma.t_dma_user_config)
return boolean
is
begin
for index in registered_dma'range loop
if registered_dma(index).status /= DMA_UNUSED then
if registered_dma(index).config.dma_id =
soc.dma.t_dma_periph_index (user_config.controller)
and
registered_dma(index).config.stream =
soc.dma.t_stream_index (user_config.stream)
then
return true;
end if;
end if;
end loop;
return false;
end stream_is_already_used;
function task_owns_dma_stream
(caller_id : ewok.tasks_shared.t_task_id;
dma_id : ewok.exported.dma.t_controller;
stream_id : ewok.exported.dma.t_stream)
return boolean
is
begin
for index in registered_dma'range loop
if registered_dma(index).task_id = caller_id
and then
registered_dma(index).config.dma_id =
soc.dma.t_dma_periph_index (dma_id)
and then
registered_dma(index).config.stream =
soc.dma.t_stream_index (stream_id)
then
return true;
end if;
end loop;
return false;
end task_owns_dma_stream;
procedure enable_dma_stream
(index : in ewok.dma_shared.t_registered_dma_index)
is
begin
if registered_dma(index).status = DMA_CONFIGURED then
soc.dma.interfaces.enable_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
end if;
end enable_dma_stream;
procedure disable_dma_stream
(index : in ewok.dma_shared.t_registered_dma_index)
is
begin
if registered_dma(index).status = DMA_CONFIGURED then
soc.dma.interfaces.disable_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
end if;
end disable_dma_stream;
procedure enable_dma_irq
(index : in ewok.dma_shared.t_registered_dma_index)
is
-- DMAs have only one IRQ line per stream
intr : constant soc.interrupts.t_interrupt :=
registered_dma(index).devinfo.all.interrupt_list
(c.socinfo.t_dev_interrupt_range'first);
begin
soc.nvic.enable_irq (soc.nvic.to_irq_number (intr));
end enable_dma_irq;
function is_config_complete
(config : soc.dma.interfaces.t_dma_config)
return boolean
is
begin
if config.in_addr = 0 or
config.out_addr = 0 or
config.bytes = 0 or
config.transfer_dir = MEMORY_TO_MEMORY or
(config.transfer_dir = MEMORY_TO_PERIPHERAL and config.in_handler = 0)
or
(config.transfer_dir = PERIPHERAL_TO_MEMORY and config.out_handler = 0)
then
return false;
else
return true;
end if;
end is_config_complete;
function sanitize_dma
(user_config : ewok.exported.dma.t_dma_user_config;
caller_id : ewok.tasks_shared.t_task_id;
to_configure : ewok.exported.dma.t_config_mask;
mode : ewok.tasks_shared.t_task_mode)
return boolean
is
begin
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
if to_configure.buffer_in then
if not ewok.sanitize.is_word_in_allocated_device
(user_config.in_addr, caller_id)
then
return false;
end if;
end if;
if to_configure.buffer_out then
if not ewok.sanitize.is_range_in_any_slot
(user_config.out_addr, unsigned_32 (user_config.size),
caller_id, mode)
and
not ewok.sanitize.is_range_in_dma_shm
(user_config.out_addr, unsigned_32 (user_config.size),
SHM_ACCESS_WRITE, caller_id)
then
return false;
end if;
end if;
if to_configure.handlers then
if not ewok.sanitize.is_word_in_txt_slot
(user_config.out_handler, caller_id)
then
return false;
end if;
end if;
when MEMORY_TO_PERIPHERAL =>
if to_configure.buffer_in then
if not ewok.sanitize.is_range_in_any_slot
(user_config.in_addr, unsigned_32 (user_config.size),
caller_id, mode)
and
not ewok.sanitize.is_range_in_dma_shm
(user_config.in_addr, unsigned_32 (user_config.size),
SHM_ACCESS_READ, caller_id)
then
return false;
end if;
end if;
if to_configure.buffer_out then
if not ewok.sanitize.is_word_in_allocated_device
(user_config.out_addr, caller_id)
then
return false;
end if;
end if;
if to_configure.handlers then
if not ewok.sanitize.is_word_in_txt_slot
(user_config.in_handler, caller_id)
then
return false;
end if;
end if;
when MEMORY_TO_MEMORY =>
return false;
end case;
return true;
end sanitize_dma;
function sanitize_dma_shm
(shm : ewok.exported.dma.t_dma_shm_info;
caller_id : ewok.tasks_shared.t_task_id;
mode : ewok.tasks_shared.t_task_mode)
return boolean
is
begin
if not ewok.tasks.is_real_user (shm.granted_id) then
pragma DEBUG (debug.log (debug.ERROR, "sanitize_dma_shm(): wrong target"));
return false;
end if;
if shm.accessed_id /= caller_id then
pragma DEBUG (debug.log (debug.ERROR, "sanitize_dma_shm(): wrong caller"));
return false;
end if;
#if CONFIG_KERNEL_DOMAIN
if not ewok.perm.is_same_domain (shm.granted_id, shm.accessed_id) then
pragma DEBUG (debug.log (debug.ERROR, "sanitize_dma_shm(): not same domain"));
return false;
end if;
#end if;
if not ewok.sanitize.is_range_in_data_slot
(shm.base, shm.size, caller_id, mode) and
not ewok.sanitize.is_range_in_devices_slot
(shm.base, shm.size, caller_id)
then
pragma DEBUG (debug.log (debug.ERROR, "sanitize_dma_shm(): shm not in range"));
return false;
end if;
return true;
end sanitize_dma_shm;
procedure reconfigure_stream
(user_config : in out ewok.exported.dma.t_dma_user_config;
index : in ewok.dma_shared.t_registered_dma_index;
to_configure : in ewok.exported.dma.t_config_mask;
caller_id : in ewok.tasks_shared.t_task_id;
success : out boolean)
is
ok : boolean;
begin
if not to_configure.buffer_size then
user_config.size := registered_dma(index).config.bytes;
else
registered_dma(index).config.bytes := user_config.size;
end if;
if to_configure.buffer_in then
registered_dma(index).config.in_addr := user_config.in_addr;
end if;
if to_configure.buffer_out then
registered_dma(index).config.out_addr := user_config.out_addr;
end if;
if to_configure.mode then
registered_dma(index).config.mode := user_config.mode;
end if;
if to_configure.priority then
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
registered_dma(index).config.out_priority :=
user_config.out_priority;
when MEMORY_TO_PERIPHERAL =>
registered_dma(index).config.in_priority :=
user_config.in_priority;
when MEMORY_TO_MEMORY =>
pragma DEBUG (debug.log
(debug.ERROR,
"reconfigure_stream(): MEMORY_TO_MEMORY not implemented"));
success := false;
return;
end case;
end if;
if to_configure.direction then
registered_dma(index).config.transfer_dir := user_config.transfer_dir;
end if;
if to_configure.handlers then
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
registered_dma(index).config.out_handler :=
user_config.out_handler;
ewok.interrupts.set_interrupt_handler
(registered_dma(index).devinfo.all.interrupt_list(c.socinfo.t_dev_interrupt_range'first),
ewok.interrupts.to_handler_access (user_config.out_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
when MEMORY_TO_PERIPHERAL =>
registered_dma(index).config.in_handler :=
user_config.in_handler;
ewok.interrupts.set_interrupt_handler
(registered_dma(index).devinfo.all.interrupt_list(c.socinfo.t_dev_interrupt_range'first),
ewok.interrupts.to_handler_access (user_config.in_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
when MEMORY_TO_MEMORY =>
pragma DEBUG (debug.log (debug.ERROR, "reconfigure_stream(): MEMORY_TO_MEMORY not implemented"));
success := false;
return;
end case;
end if;
--
-- Configuring the DMA
--
soc.dma.interfaces.reconfigure_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream,
registered_dma(index).config,
soc.dma.interfaces.t_config_mask (to_configure));
if is_config_complete (registered_dma(index).config) then
registered_dma(index).status := DMA_CONFIGURED;
soc.dma.interfaces.enable_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
else
registered_dma(index).status := DMA_USED;
end if;
success := true;
end reconfigure_stream;
procedure init_stream
(user_config : in ewok.exported.dma.t_dma_user_config;
caller_id : in ewok.tasks_shared.t_task_id;
index : out ewok.dma_shared.t_registered_dma_index;
success : out boolean)
is
ok : boolean;
begin
-- Find a free entry in the registered_dma array
get_registered_dma_entry (index, ok);
if not ok then
pragma DEBUG (debug.log ("dma.init(): no DMA entry available"));
success := false;
return;
end if;
-- Copy the user configuration
registered_dma(index).config :=
(dma_id => soc.dma.t_dma_periph_index (user_config.controller),
stream => soc.dma.t_stream_index (user_config.stream),
channel => soc.dma.t_channel_index (user_config.channel),
bytes => user_config.size,
in_addr => user_config.in_addr,
in_priority => user_config.in_priority,
in_handler => user_config.in_handler,
out_addr => user_config.out_addr,
out_priority => user_config.out_priority,
out_handler => user_config.out_handler,
flow_controller => user_config.flow_controller,
transfer_dir => user_config.transfer_dir,
mode => user_config.mode,
data_size => user_config.data_size,
memory_inc => boolean (user_config.memory_inc),
periph_inc => boolean (user_config.periph_inc),
mem_burst_size => user_config.mem_burst_size,
periph_burst_size => user_config.periph_burst_size);
registered_dma(index).task_id := caller_id;
registered_dma(index).devinfo :=
c.socinfo.soc_devmap_find_dma_device
(user_config.controller, user_config.stream);
if registered_dma(index).devinfo = NULL then
pragma DEBUG (debug.log ("dma.init(): unknown DMA device"));
success := false;
return;
end if;
-- Set up the interrupt handler
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
if user_config.out_handler /= 0 then
ewok.interrupts.set_interrupt_handler
(registered_dma(index).devinfo.all.interrupt_list(c.socinfo.t_dev_interrupt_range'first),
ewok.interrupts.to_handler_access (user_config.out_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
end if;
when MEMORY_TO_PERIPHERAL =>
if user_config.in_handler /= 0 then
ewok.interrupts.set_interrupt_handler
(registered_dma(index).devinfo.all.interrupt_list(c.socinfo.t_dev_interrupt_range'first),
ewok.interrupts.to_handler_access (user_config.in_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
end if;
when MEMORY_TO_MEMORY =>
pragma DEBUG (debug.log ("dma.init(): MEMORY_TO_MEMORY not implemented"));
success := false;
return;
end case;
if is_config_complete (registered_dma(index).config) then
registered_dma(index).status := DMA_CONFIGURED;
else
registered_dma(index).status := DMA_USED;
end if;
-- Reset the DMA stream
soc.dma.interfaces.reset_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
-- Configure the DMA stream
soc.dma.interfaces.configure_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream,
registered_dma(index).config);
success := true;
end init_stream;
procedure init
is
begin
soc.dma.enable_clocks;
end init;
procedure clear_dma_interrupts
(caller_id : in ewok.tasks_shared.t_task_id;
interrupt : in soc.interrupts.t_interrupt)
is
soc_dma_id : soc.dma.t_dma_periph_index;
soc_stream_id : soc.dma.t_stream_index;
ok : boolean;
begin
soc.dma.get_dma_stream_from_interrupt
(interrupt, soc_dma_id, soc_stream_id, ok);
if not ok then
raise program_error;
end if;
if not task_owns_dma_stream (caller_id, t_controller (soc_dma_id),
t_stream (soc_stream_id))
then
raise program_error;
end if;
soc.dma.interfaces.clear_all_interrupts
(soc_dma_id, soc_stream_id);
end clear_dma_interrupts;
procedure get_status_register
(caller_id : in ewok.tasks_shared.t_task_id;
interrupt : in soc.interrupts.t_interrupt;
status : out soc.dma.t_dma_stream_int_status;
success : out boolean)
is
soc_dma_id : soc.dma.t_dma_periph_index;
soc_stream_id : soc.dma.t_stream_index;
ok : boolean;
begin
soc.dma.get_dma_stream_from_interrupt
(interrupt, soc_dma_id, soc_stream_id, ok);
if not ok then
success := false;
return;
end if;
if not task_owns_dma_stream (caller_id,
t_controller (soc_dma_id),
t_stream (soc_stream_id))
then
success := false;
return;
end if;
status := soc.dma.interfaces.get_interrupt_status
(soc_dma_id, soc_stream_id);
soc.dma.interfaces.clear_all_interrupts (soc_dma_id, soc_stream_id);
success := true;
end get_status_register;
end ewok.dma;
|
reznikmm/matreshka | Ada | 5,566 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A send signal action is an action that creates a signal instance from its
-- inputs, and transmits it to the target object, where it may cause the
-- firing of a state machine transition or the execution of an activity. The
-- argument values are available to the execution of associated behaviors.
-- The requestor continues execution immediately. Any reply message is
-- ignored and is not transmitted to the requestor. If the input is already a
-- signal instance, use a send object action.
------------------------------------------------------------------------------
limited with AMF.UML.Input_Pins;
with AMF.UML.Invocation_Actions;
limited with AMF.UML.Signals;
package AMF.UML.Send_Signal_Actions is
pragma Preelaborate;
type UML_Send_Signal_Action is limited interface
and AMF.UML.Invocation_Actions.UML_Invocation_Action;
type UML_Send_Signal_Action_Access is
access all UML_Send_Signal_Action'Class;
for UML_Send_Signal_Action_Access'Storage_Size use 0;
not overriding function Get_Signal
(Self : not null access constant UML_Send_Signal_Action)
return AMF.UML.Signals.UML_Signal_Access is abstract;
-- Getter of SendSignalAction::signal.
--
-- The type of signal transmitted to the target object.
not overriding procedure Set_Signal
(Self : not null access UML_Send_Signal_Action;
To : AMF.UML.Signals.UML_Signal_Access) is abstract;
-- Setter of SendSignalAction::signal.
--
-- The type of signal transmitted to the target object.
not overriding function Get_Target
(Self : not null access constant UML_Send_Signal_Action)
return AMF.UML.Input_Pins.UML_Input_Pin_Access is abstract;
-- Getter of SendSignalAction::target.
--
-- The target object to which the signal is sent.
not overriding procedure Set_Target
(Self : not null access UML_Send_Signal_Action;
To : AMF.UML.Input_Pins.UML_Input_Pin_Access) is abstract;
-- Setter of SendSignalAction::target.
--
-- The target object to which the signal is sent.
end AMF.UML.Send_Signal_Actions;
|
Jellix/elan520 | Ada | 7,411 | ads | ------------------------------------------------------------------------
-- Copyright (C) 2005-2020 by <[email protected]> --
-- --
-- This work is free. You can redistribute it and/or modify it under --
-- the terms of the Do What The Fuck You Want To Public License, --
-- Version 2, as published by Sam Hocevar. See the LICENSE file for --
-- more details. --
------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------
-- AMD Élan(tm) SC 520 embedded microprocessor --
-- MMCR -> General-Purpose Timer Registers --
-- --
-- reference: User's Manual Chapter 17, --
-- Register Set Manual Chapter 14 --
------------------------------------------------------------------------
with Elan520.Basic_Types;
package Elan520.GP_Timer_Registers is
---------------------------------------------------------------------
-- GP Timers Status (GPTMRSTA) --
-- Memory Mapped, Read/Write(!) --
-- MMCR Offset C70h --
-- NOTE: writing a 1 (True) to the register resets (clears) the --
-- appropriate bit --
---------------------------------------------------------------------
MMCR_OFFSET_STATUS : constant := 16#C70#;
STATUS_SIZE : constant := 8;
type Status is
record
T0_Int_Sta : Boolean;
T1_Int_Sta : Boolean;
T2_Int_Sta : Boolean;
end record;
for Status use
record
T0_Int_Sta at 0 range 0 .. 0;
T1_Int_Sta at 0 range 1 .. 1;
T2_Int_Sta at 0 range 2 .. 2;
-- bits 3 .. 7 are reserved
end record;
for Status'Size use STATUS_SIZE;
-- type used for clock source and retrigger mode selections
-- bits [4:2]
-- RTG PSC_SEL EXT_CLK clock mode
-- 0 0 0 Internal, cpu clock, gated
-- 0 0 1 External
-- 0 1 0 Internal, prescaled, gated
-- 0 1 1 N/A (same as 001)
-- 1 0 0 Internal, cpu clock, retriggered
-- 1 0 1 N/A (same as 001)
-- 1 1 0 internal, prescaled, retriggered
-- 1 1 1 N/A (same as 001)
type Clock_Source is (Internal_Gated,
External,
Prescaled_Gated,
Internal_Retriggered,
Prescaled_Retriggered);
for Clock_Source use (Internal_Gated => 2#000#,
External => 2#001#,
Prescaled_Gated => 2#010#,
Internal_Retriggered => 2#100#,
Prescaled_Retriggered => 2#110#);
for Clock_Source'Size use 3;
-- type used for the enable bits (ENB, P_ENB_WR)
-- bits [15:14]
type Enable_Set is (Dont_Care, Disable, Enable);
for Enable_Set use (Dont_Care => 2#00#,
Disable => 2#01#,
Enable => 2#11#);
for Enable_Set'Size use 2;
---------------------------------------------------------------------
-- GP Timer Mode/Control (GPTMRxCTL) --
-- Memory Mapped, Read/Write(!) --
-- MMCR Offset C72h (GP Timer 0) --
-- C7Ah (GP Timer 1) --
---------------------------------------------------------------------
MMCR_OFFSET_T0_CONTROL : constant := 16#C72#;
MMCR_OFFSET_T1_CONTROL : constant := 16#C7A#;
CONTROL_SIZE : constant := 16;
type Control is
record
Continuous_Mode : Basic_Types.Positive_Bit;
Alternate_Compare : Basic_Types.Positive_Bit;
-- this combines RTG, EXT_CLK and PSC_SEL bits
Clock_Mode : Clock_Source;
Max_Count_Reached : Boolean;
Max_Count_In_Use : Boolean;
Interrupt : Basic_Types.Positive_Bit;
Enable_Mode : Enable_Set;
end record;
for Control use
record
Continuous_Mode at 0 range 0 .. 0;
Alternate_Compare at 0 range 1 .. 1;
Clock_Mode at 0 range 2 .. 4;
Max_Count_Reached at 0 range 5 .. 5;
-- bits [11:6] are reserved
Max_Count_In_Use at 0 range 12 .. 12;
Interrupt at 0 range 13 .. 13;
Enable_Mode at 0 range 14 .. 15;
end record;
---------------------------------------------------------------------
-- GP Timer 2 Mode/Control (GPTMR2CTL) --
-- Memory Mapped, Read/Write(!) --
-- MMCR Offset C82h --
---------------------------------------------------------------------
MMCR_OFFSET_T2_CONTROL : constant := 16#C82#;
T2_CONTROL_SIZE : constant := CONTROL_SIZE;
type Control_2 is
record
Continuous_Mode : Basic_Types.Positive_Bit;
Max_Count_Reached : Boolean;
Interrupt : Basic_Types.Positive_Bit;
Enable_Mode : Enable_Set;
end record;
for Control_2 use
record
Continuous_Mode at 0 range 0 .. 0;
-- bits [4:1] are reserved
Max_Count_Reached at 0 range 5 .. 5;
-- bits [12:6] are reserved
Interrupt at 0 range 13 .. 13;
Enable_Mode at 0 range 14 .. 15;
end record;
-- type used for all count registers
type Count is range 0 .. 65535;
for Count'Size use 16;
---------------------------------------------------------------------
-- GP Count/Maxcount Compare registers --
-- Memory Mapped, Read/Write --
-- MMCR Offset C74h, (Timer 0 Count, GPTMR0CNT) --
-- C76h, (Timer 0 Maxcount Compare A, GPTMR0MAXCMPA) --
-- C78h, (Timer 0 Maxcount Compare B, GPTMR0MAXCMPB) --
-- C7Ch, (Timer 1 Count, GPTMR1CNT) --
-- C7Eh, (Timer 1 Maxcount Compare A, GPTMR1MAXCMPA) --
-- C80h, (Timer 1 Maxcount Compare A, GPTMR1MAXCMPB) --
-- C84h, (Timer 2 Count, GPTMR2CNT) --
-- C86h, (Timer 2 Maxcount Compare A, GPTMR2MAXCMPA) --
---------------------------------------------------------------------
MMCR_OFFSET_T0_COUNT : constant := 16#C74#;
MMCR_OFFSET_T0_MAX_A : constant := 16#C76#;
MMCR_OFFSET_T0_MAX_B : constant := 16#C78#;
MMCR_OFFSET_T1_COUNT : constant := 16#C7C#;
MMCR_OFFSET_T1_MAX_A : constant := 16#C7E#;
MMCR_OFFSET_T1_MAX_B : constant := 16#C80#;
MMCR_OFFSET_T2_COUNT : constant := 16#C84#;
MMCR_OFFSET_T2_MAX_A : constant := 16#C86#;
end Elan520.GP_Timer_Registers;
|
jwarwick/aoc_2020 | Ada | 320 | ads | -- AOC 2020, Day 18
package Day is
function hw_sum(filename : in String) return Long_Integer;
function hw_newmath_sum(filename : in String) return Long_Integer;
private
function eval_string(expr : in String) return Long_Integer;
function eval_newmath_string(expr : in String) return Long_Integer;
end Day;
|
peterfrankjohnson/compiler | Ada | 25 | adb | ../../test/helloworld.adb |
charlesdaniels/libagar | Ada | 13,111 | ads | ------------------------------------------------------------------------------
-- AGAR GUI LIBRARY --
-- A G A R . K E Y B O A R D --
-- S p e c --
------------------------------------------------------------------------------
with Interfaces.C;
with Interfaces.C.Strings;
with Agar.Input_Device;
package Agar.Keyboard is
package C renames Interfaces.C;
package CS renames Interfaces.C.Strings;
package INDEV renames Agar.Input_Device;
use type C.int;
use type C.unsigned;
---------------------
-- Virtual Keysyms --
---------------------
type Key_Sym is
(KEY_NONE,
KEY_BACKSPACE,
KEY_TAB,
KEY_CLEAR,
KEY_RETURN,
KEY_PAUSE,
KEY_ESCAPE,
KEY_SPACE,
KEY_EXCLAIM,
KEY_QUOTEDBL,
KEY_HASH,
KEY_DOLLAR,
KEY_PERCENT,
KEY_AMPERSAND,
KEY_QUOTE,
KEY_LEFT_PAREN,
KEY_RIGHT_PAREN,
KEY_ASTERISK,
KEY_PLUS,
KEY_COMMA,
KEY_MINUS,
KEY_PERIOD,
KEY_SLASH,
KEY_0,
KEY_1,
KEY_2,
KEY_3,
KEY_4,
KEY_5,
KEY_6,
KEY_7,
KEY_8,
KEY_9,
KEY_COLON,
KEY_SEMICOLON,
KEY_LESS,
KEY_EQUALS,
KEY_GREATER,
KEY_QUESTION,
KEY_AT,
KEY_LEFT_BRACKET,
KEY_BACKSLASH,
KEY_RIGHT_BRACKET,
KEY_CARET,
KEY_UNDERSCORE,
KEY_BACKQUOTE,
KEY_A,
KEY_B,
KEY_C,
KEY_D,
KEY_E,
KEY_F,
KEY_G,
KEY_H,
KEY_I,
KEY_J,
KEY_K,
KEY_L,
KEY_M,
KEY_N,
KEY_O,
KEY_P,
KEY_Q,
KEY_R,
KEY_S,
KEY_T,
KEY_U,
KEY_V,
KEY_W,
KEY_X,
KEY_Y,
KEY_Z,
KEY_DELETE,
KEY_KP0,
KEY_KP1,
KEY_KP2,
KEY_KP3,
KEY_KP4,
KEY_KP5,
KEY_KP6,
KEY_KP7,
KEY_KP8,
KEY_KP9,
KEY_KP_PERIOD,
KEY_KP_DIVIDE,
KEY_KP_MULTIPLY,
KEY_KP_MINUS,
KEY_KP_PLUS,
KEY_KP_ENTER,
KEY_KP_EQUALS,
KEY_UP,
KEY_DOWN,
KEY_RIGHT,
KEY_LEFT,
KEY_INSERT,
KEY_HOME,
KEY_END,
KEY_PAGE_UP,
KEY_PAGE_DOWN,
KEY_F1,
KEY_F2,
KEY_F3,
KEY_F4,
KEY_F5,
KEY_F6,
KEY_F7,
KEY_F8,
KEY_F9,
KEY_F10,
KEY_F11,
KEY_F12,
KEY_F13,
KEY_F14,
KEY_F15,
KEY_NUM_LOCK,
KEY_CAPS_LOCK,
KEY_SCROLL_LOCK,
KEY_RIGHT_SHIFT,
KEY_LEFT_SHIFT,
KEY_RIGHT_CTRL,
KEY_LEFT_CTRL,
KEY_RIGHT_ALT,
KEY_LEFT_ALT,
KEY_RIGHT_META,
KEY_LEFT_META,
KEY_LEFT_SUPER,
KEY_RIGHT_SUPER,
KEY_MODE,
KEY_COMPOSE,
KEY_HELP,
KEY_PRINT,
KEY_SYSREQ,
KEY_BREAK,
KEY_MENU,
KEY_POWER,
KEY_EURO,
KEY_UNDO,
KEY_GRAVE,
KEY_KP_CLEAR,
KEY_COMMAND,
KEY_FUNCTION,
KEY_VOLUME_UP,
KEY_VOLUME_DOWN,
KEY_VOLUME_MUTE,
KEY_F16,
KEY_F17,
KEY_F18,
KEY_F19,
KEY_F20,
KEY_F21,
KEY_F22,
KEY_F23,
KEY_F24,
KEY_F25,
KEY_F26,
KEY_F27,
KEY_F28,
KEY_F29,
KEY_F30,
KEY_F31,
KEY_F32,
KEY_F33,
KEY_F34,
KEY_F35,
KEY_BEGIN,
KEY_RESET,
KEY_STOP,
KEY_USER,
KEY_SYSTEM,
KEY_PRINT_SCREEN,
KEY_CLEAR_LINE,
KEY_CLEAR_DISPLAY,
KEY_INSERT_LINE,
KEY_DELETE_LINE,
KEY_INSERT_CHAR,
KEY_DELETE_CHAR,
KEY_PREV,
KEY_NEXT,
KEY_SELECT,
KEY_EXECUTE,
KEY_REDO,
KEY_FIND,
KEY_MODE_SWITCH,
KEY_LAST,
KEY_ANY);
for Key_Sym use
(KEY_NONE => 16#00_00#,
KEY_BACKSPACE => 16#00_08#,
KEY_TAB => 16#00_09#,
KEY_CLEAR => 16#00_0c#,
KEY_RETURN => 16#00_0d#,
KEY_PAUSE => 16#00_13#,
KEY_ESCAPE => 16#00_1b#,
KEY_SPACE => 16#00_20#, -- --
KEY_EXCLAIM => 16#00_21#, -- ! --
KEY_QUOTEDBL => 16#00_22#, -- " --
KEY_HASH => 16#00_23#, -- # --
KEY_DOLLAR => 16#00_24#, -- $ --
KEY_PERCENT => 16#00_25#, -- % --
KEY_AMPERSAND => 16#00_26#, -- & --
KEY_QUOTE => 16#00_27#, -- ' --
KEY_LEFT_PAREN => 16#00_28#, -- ( --
KEY_RIGHT_PAREN => 16#00_29#, -- ) --
KEY_ASTERISK => 16#00_2a#, -- * --
KEY_PLUS => 16#00_2b#, -- + --
KEY_COMMA => 16#00_2c#, -- , --
KEY_MINUS => 16#00_2d#, -- - --
KEY_PERIOD => 16#00_2e#, -- . --
KEY_SLASH => 16#00_2f#, -- / --
KEY_0 => 16#00_30#, -- 0 --
KEY_1 => 16#00_31#, -- 1 --
KEY_2 => 16#00_32#, -- 2 --
KEY_3 => 16#00_33#, -- 3 --
KEY_4 => 16#00_34#, -- 4 --
KEY_5 => 16#00_35#, -- 5 --
KEY_6 => 16#00_36#, -- 6 --
KEY_7 => 16#00_37#, -- 7 --
KEY_8 => 16#00_38#, -- 8 --
KEY_9 => 16#00_39#, -- 9 --
KEY_COLON => 16#00_3a#, -- : --
KEY_SEMICOLON => 16#00_3b#, -- ; --
KEY_LESS => 16#00_3c#, -- < --
KEY_EQUALS => 16#00_3d#, -- = --
KEY_GREATER => 16#00_3e#, -- > --
KEY_QUESTION => 16#00_3f#, -- ? --
KEY_AT => 16#00_40#, -- @ --
KEY_LEFT_BRACKET => 16#00_5b#, -- [ --
KEY_BACKSLASH => 16#00_5c#, -- \ --
KEY_RIGHT_BRACKET => 16#00_5d#, -- ] --
KEY_CARET => 16#00_5e#, -- ^ --
KEY_UNDERSCORE => 16#00_5f#, -- _ --
KEY_BACKQUOTE => 16#00_60#, -- ` --
KEY_A => 16#00_61#, -- a --
KEY_B => 16#00_62#, -- b --
KEY_C => 16#00_63#, -- c --
KEY_D => 16#00_64#, -- d --
KEY_E => 16#00_65#, -- e --
KEY_F => 16#00_66#, -- f --
KEY_G => 16#00_67#, -- g --
KEY_H => 16#00_68#, -- h --
KEY_I => 16#00_69#, -- i --
KEY_J => 16#00_6a#, -- j --
KEY_K => 16#00_6b#, -- k --
KEY_L => 16#00_6c#, -- l --
KEY_M => 16#00_6d#, -- m --
KEY_N => 16#00_6e#, -- n --
KEY_O => 16#00_6f#, -- o --
KEY_P => 16#00_70#, -- p --
KEY_Q => 16#00_71#, -- q --
KEY_R => 16#00_72#, -- r --
KEY_S => 16#00_73#, -- s --
KEY_T => 16#00_74#, -- t --
KEY_U => 16#00_75#, -- u --
KEY_V => 16#00_76#, -- v --
KEY_W => 16#00_77#, -- w --
KEY_X => 16#00_78#, -- x --
KEY_Y => 16#00_79#, -- y --
KEY_Z => 16#00_7a#, -- z --
KEY_DELETE => 16#00_7f#,
KEY_KP0 => 16#01_00#,
KEY_KP1 => 16#01_01#,
KEY_KP2 => 16#01_02#,
KEY_KP3 => 16#01_03#,
KEY_KP4 => 16#01_04#,
KEY_KP5 => 16#01_05#,
KEY_KP6 => 16#01_06#,
KEY_KP7 => 16#01_07#,
KEY_KP8 => 16#01_08#,
KEY_KP9 => 16#01_09#,
KEY_KP_PERIOD => 16#01_0a#,
KEY_KP_DIVIDE => 16#01_0b#,
KEY_KP_MULTIPLY => 16#01_0c#,
KEY_KP_MINUS => 16#01_0d#,
KEY_KP_PLUS => 16#01_0e#,
KEY_KP_ENTER => 16#01_0f#,
KEY_KP_EQUALS => 16#01_10#,
KEY_UP => 16#01_11#,
KEY_DOWN => 16#01_12#,
KEY_RIGHT => 16#01_13#,
KEY_LEFT => 16#01_14#,
KEY_INSERT => 16#01_15#,
KEY_HOME => 16#01_16#,
KEY_END => 16#01_17#,
KEY_PAGE_UP => 16#01_18#,
KEY_PAGE_DOWN => 16#01_19#,
KEY_F1 => 16#01_1a#,
KEY_F2 => 16#01_1b#,
KEY_F3 => 16#01_1c#,
KEY_F4 => 16#01_1d#,
KEY_F5 => 16#01_1e#,
KEY_F6 => 16#01_1f#,
KEY_F7 => 16#01_20#,
KEY_F8 => 16#01_21#,
KEY_F9 => 16#01_22#,
KEY_F10 => 16#01_23#,
KEY_F11 => 16#01_24#,
KEY_F12 => 16#01_25#,
KEY_F13 => 16#01_26#,
KEY_F14 => 16#01_27#,
KEY_F15 => 16#01_28#,
KEY_NUM_LOCK => 16#01_2c#,
KEY_CAPS_LOCK => 16#01_2d#,
KEY_SCROLL_LOCK => 16#01_2e#,
KEY_RIGHT_SHIFT => 16#01_2f#,
KEY_LEFT_SHIFT => 16#01_30#,
KEY_RIGHT_CTRL => 16#01_31#,
KEY_LEFT_CTRL => 16#01_32#,
KEY_RIGHT_ALT => 16#01_33#,
KEY_LEFT_ALT => 16#01_34#,
KEY_RIGHT_META => 16#01_35#,
KEY_LEFT_META => 16#01_36#,
KEY_LEFT_SUPER => 16#01_37#,
KEY_RIGHT_SUPER => 16#01_38#,
KEY_MODE => 16#01_39#,
KEY_COMPOSE => 16#01_3a#,
KEY_HELP => 16#01_3b#,
KEY_PRINT => 16#01_3c#,
KEY_SYSREQ => 16#01_3d#,
KEY_BREAK => 16#01_3e#,
KEY_MENU => 16#01_3f#,
KEY_POWER => 16#01_40#,
KEY_EURO => 16#01_41#,
KEY_UNDO => 16#01_42#,
KEY_GRAVE => 16#01_43#,
KEY_KP_CLEAR => 16#01_44#,
KEY_COMMAND => 16#01_45#,
KEY_FUNCTION => 16#01_46#,
KEY_VOLUME_UP => 16#01_47#,
KEY_VOLUME_DOWN => 16#01_48#,
KEY_VOLUME_MUTE => 16#01_49#,
KEY_F16 => 16#01_4a#,
KEY_F17 => 16#01_4b#,
KEY_F18 => 16#01_4c#,
KEY_F19 => 16#01_4d#,
KEY_F20 => 16#01_4e#,
KEY_F21 => 16#01_4f#,
KEY_F22 => 16#01_50#,
KEY_F23 => 16#01_51#,
KEY_F24 => 16#01_52#,
KEY_F25 => 16#01_53#,
KEY_F26 => 16#01_54#,
KEY_F27 => 16#01_55#,
KEY_F28 => 16#01_56#,
KEY_F29 => 16#01_57#,
KEY_F30 => 16#01_58#,
KEY_F31 => 16#01_59#,
KEY_F32 => 16#01_5a#,
KEY_F33 => 16#01_5b#,
KEY_F34 => 16#01_5c#,
KEY_F35 => 16#01_5d#,
KEY_BEGIN => 16#01_5e#,
KEY_RESET => 16#01_5f#,
KEY_STOP => 16#01_60#,
KEY_USER => 16#01_61#,
KEY_SYSTEM => 16#01_62#,
KEY_PRINT_SCREEN => 16#01_63#,
KEY_CLEAR_LINE => 16#01_64#,
KEY_CLEAR_DISPLAY => 16#01_65#,
KEY_INSERT_LINE => 16#01_66#,
KEY_DELETE_LINE => 16#01_67#,
KEY_INSERT_CHAR => 16#01_68#,
KEY_DELETE_CHAR => 16#01_69#,
KEY_PREV => 16#01_6a#,
KEY_NEXT => 16#01_6b#,
KEY_SELECT => 16#01_6c#,
KEY_EXECUTE => 16#01_6d#,
KEY_REDO => 16#01_6e#,
KEY_FIND => 16#01_6f#,
KEY_MODE_SWITCH => 16#01_70#,
KEY_LAST => 16#01_71#,
KEY_ANY => 16#ff_ff#);
for Key_Sym'Size use C.int'Size;
-------------------
-- Key Modifiers --
-------------------
KEYMOD_NONE : constant C.unsigned := 16#00_00#;
KEYMOD_LEFT_SHIFT : constant C.unsigned := 16#00_01#;
KEYMOD_RIGHT_SHIFT : constant C.unsigned := 16#00_02#;
KEYMOD_LEFT_CTRL : constant C.unsigned := 16#00_40#;
KEYMOD_RIGHT_CTRL : constant C.unsigned := 16#00_80#;
KEYMOD_LEFT_ALT : constant C.unsigned := 16#01_00#;
KEYMOD_RIGHT_ALT : constant C.unsigned := 16#02_00#;
KEYMOD_LEFT_META : constant C.unsigned := 16#04_00#;
KEYMOD_RIGHT_META : constant C.unsigned := 16#08_00#;
KEYMOD_NUM_LOCK : constant C.unsigned := 16#10_00#;
KEYMOD_CAPS_LOCK : constant C.unsigned := 16#20_00#;
KEYMOD_MODE : constant C.unsigned := 16#40_00#;
KEYMOD_ANY : constant C.unsigned := 16#ff_ff#;
KEYMOD_CTRL : constant C.unsigned := KEYMOD_LEFT_CTRL or KEYMOD_RIGHT_CTRL;
KEYMOD_SHIFT : constant C.unsigned := KEYMOD_LEFT_SHIFT or KEYMOD_RIGHT_SHIFT;
KEYMOD_ALT : constant C.unsigned := KEYMOD_LEFT_ALT or KEYMOD_RIGHT_ALT;
KEYMOD_META : constant C.unsigned := KEYMOD_LEFT_META or KEYMOD_RIGHT_META;
type Virtual_Key_t is record
Symbol : Key_Sym; -- Virtual key
Modifier : C.int; -- Virtual key modifier mask
Unicode : Interfaces.Unsigned_32; -- Corresponding Unicode or 0
end record
with Convention => C;
---------------------
-- Keyboard Device --
---------------------
type Keyboard_Keys_Access is access all C.int with Convention => C;
type Keyboard_Device is limited record
Super : aliased INDEV.Input_Device; -- Input_Device -> Keyboard
Flags : C.unsigned;
Keys : Keyboard_Keys_Access;
Key_Count : C.unsigned;
Mod_State : C.unsigned;
end record
with Convention => C;
type Keyboard_Device_Access is access all Keyboard_Device with Convention => C;
subtype Keyboard_Device_not_null_Access is not null Keyboard_Device_Access;
end Agar.Keyboard;
|
optikos/oasis | Ada | 430 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Nodes.Generic_Vectors;
with Program.Elements.Variants;
package Program.Nodes.Variant_Vectors is new
Program.Nodes.Generic_Vectors (Program.Elements.Variants.Variant_Vector);
pragma Preelaborate (Program.Nodes.Variant_Vectors);
|
reznikmm/matreshka | Ada | 6,623 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A connector end is an endpoint of a connector, which attaches the
-- connector to a connectable element. Each connector end is part of one
-- connector.
------------------------------------------------------------------------------
limited with AMF.UML.Connectable_Elements;
with AMF.UML.Multiplicity_Elements;
limited with AMF.UML.Properties;
package AMF.UML.Connector_Ends is
pragma Preelaborate;
type UML_Connector_End is limited interface
and AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element;
type UML_Connector_End_Access is
access all UML_Connector_End'Class;
for UML_Connector_End_Access'Storage_Size use 0;
not overriding function Get_Defining_End
(Self : not null access constant UML_Connector_End)
return AMF.UML.Properties.UML_Property_Access is abstract;
-- Getter of ConnectorEnd::definingEnd.
--
-- A derived association referencing the corresponding association end on
-- the association which types the connector owing this connector end.
-- This association is derived by selecting the association end at the
-- same place in the ordering of association ends as this connector end.
not overriding function Get_Part_With_Port
(Self : not null access constant UML_Connector_End)
return AMF.UML.Properties.UML_Property_Access is abstract;
-- Getter of ConnectorEnd::partWithPort.
--
-- Indicates the role of the internal structure of a classifier with the
-- port to which the connector end is attached.
not overriding procedure Set_Part_With_Port
(Self : not null access UML_Connector_End;
To : AMF.UML.Properties.UML_Property_Access) is abstract;
-- Setter of ConnectorEnd::partWithPort.
--
-- Indicates the role of the internal structure of a classifier with the
-- port to which the connector end is attached.
not overriding function Get_Role
(Self : not null access constant UML_Connector_End)
return AMF.UML.Connectable_Elements.UML_Connectable_Element_Access is abstract;
-- Getter of ConnectorEnd::role.
--
-- The connectable element attached at this connector end. When an
-- instance of the containing classifier is created, a link may (depending
-- on the multiplicities) be created to an instance of the classifier that
-- types this connectable element.
not overriding procedure Set_Role
(Self : not null access UML_Connector_End;
To : AMF.UML.Connectable_Elements.UML_Connectable_Element_Access) is abstract;
-- Setter of ConnectorEnd::role.
--
-- The connectable element attached at this connector end. When an
-- instance of the containing classifier is created, a link may (depending
-- on the multiplicities) be created to an instance of the classifier that
-- types this connectable element.
not overriding function Defining_End
(Self : not null access constant UML_Connector_End)
return AMF.UML.Properties.UML_Property_Access is abstract;
-- Operation ConnectorEnd::definingEnd.
--
-- Missing derivation for ConnectorEnd::/definingEnd : Property
end AMF.UML.Connector_Ends;
|
albinjal/ada_basic | Ada | 34 | adb | [email protected]:1551414623 |
AdaCore/Ada_Drivers_Library | Ada | 1,877 | ads | -- This spec has been automatically generated from STM32F46_79x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.CRC is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype IDR_IDR_Field is HAL.UInt8;
-- Independent Data register
type IDR_Register is record
-- Independent Data register
IDR : IDR_IDR_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IDR_Register use record
IDR at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Control register
type CR_Register is record
-- Write-only. Control regidter
CR : Boolean := False;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
CR at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Cyclic Redundancy Check (CRC) unit
type CRC_Peripheral is record
-- Data register
DR : aliased HAL.UInt32;
-- Independent Data register
IDR : aliased IDR_Register;
-- Control register
CR : aliased CR_Register;
end record
with Volatile;
for CRC_Peripheral use record
DR at 16#0# range 0 .. 31;
IDR at 16#4# range 0 .. 31;
CR at 16#8# range 0 .. 31;
end record;
-- Cyclic Redundancy Check (CRC) unit
CRC_Periph : aliased CRC_Peripheral
with Import, Address => System'To_Address (16#40023000#);
end STM32_SVD.CRC;
|
DrenfongWong/tkm-rpc | Ada | 1,133 | adb | with Tkmrpc.Servers.Ike;
with Tkmrpc.Response.Ike.Tkm_Limits.Convert;
package body Tkmrpc.Operation_Handlers.Ike.Tkm_Limits is
-------------------------------------------------------------------------
procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type) is
pragma Unreferenced (Req);
Specific_Res : Response.Ike.Tkm_Limits.Response_Type;
begin
Specific_Res := Response.Ike.Tkm_Limits.Null_Response;
Servers.Ike.Tkm_Limits
(Result => Specific_Res.Header.Result,
Max_Active_Requests => Specific_Res.Data.Max_Active_Requests,
Nc_Contexts => Specific_Res.Data.Nc_Contexts,
Dh_Contexts => Specific_Res.Data.Dh_Contexts,
Cc_Contexts => Specific_Res.Data.Cc_Contexts,
Ae_Contexts => Specific_Res.Data.Ae_Contexts,
Isa_Contexts => Specific_Res.Data.Isa_Contexts,
Esa_Contexts => Specific_Res.Data.Esa_Contexts);
Res := Response.Ike.Tkm_Limits.Convert.To_Response (S => Specific_Res);
end Handle;
end Tkmrpc.Operation_Handlers.Ike.Tkm_Limits;
|
stcarrez/ada-asf | Ada | 2,804 | ads | -----------------------------------------------------------------------
-- volume - A simple bean example
-- Copyright (C) 2010, 2011, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Basic;
with Util.Beans.Methods;
with ASF.Components.Base;
with ASF.Contexts.Faces;
with ASF.Converters;
package Volume is
type My_Float is delta 0.01 digits 10;
type Compute_Bean is new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record
Height : My_Float := -1.0;
Radius : My_Float := -1.0;
Volume : My_Float := -1.0;
end record;
-- Get the value identified by the name.
overriding
function Get_Value (From : Compute_Bean;
Name : String) return Util.Beans.Objects.Object;
-- Set the value identified by the name.
overriding
procedure Set_Value (From : in out Compute_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
-- Compute the volume of the cylinder.
procedure Run (From : in out Compute_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
-- This bean provides some methods that can be used in a Method_Expression
overriding
function Get_Method_Bindings (From : in Compute_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access;
type Float_Converter is new ASF.Converters.Converter with null record;
overriding
function To_String (Convert : in Float_Converter;
Context : in ASF.Contexts.Faces.Faces_Context'Class;
Component : in ASF.Components.Base.UIComponent'Class;
Value : in Util.Beans.Objects.Object) return String;
overriding
function To_Object (Convert : in Float_Converter;
Context : in ASF.Contexts.Faces.Faces_Context'Class;
Component : in ASF.Components.Base.UIComponent'Class;
Value : in String) return Util.Beans.Objects.Object;
end Volume;
|
reznikmm/matreshka | Ada | 4,680 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Style.Distance_After_Sep_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Distance_After_Sep_Attribute_Node is
begin
return Self : Style_Distance_After_Sep_Attribute_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Distance_After_Sep_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Distance_After_Sep_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Distance_After_Sep_Attribute,
Style_Distance_After_Sep_Attribute_Node'Tag);
end Matreshka.ODF_Style.Distance_After_Sep_Attributes;
|
reznikmm/matreshka | Ada | 4,041 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Text_Number_Position_Attributes;
package Matreshka.ODF_Text.Number_Position_Attributes is
type Text_Number_Position_Attribute_Node is
new Matreshka.ODF_Text.Abstract_Text_Attribute_Node
and ODF.DOM.Text_Number_Position_Attributes.ODF_Text_Number_Position_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Number_Position_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Number_Position_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Text.Number_Position_Attributes;
|
albertklee/SPARKZumo | Ada | 2,213 | adb | pragma SPARK_Mode;
package body Fixed_Point_Math is
Pi : constant := 3.141592;
One : constant F := 1.0;
function Reduce (X : F) return F;
---------
-- Sin --
---------
function Sin (X : F) return F
Is
X2 : constant F := X * X;
begin
if X < 0.0 then
return -Sin (-X);
elsif X < Pi / 4 then
return F (X * (One - F (X2 * (One / 6 - F (X2 * (One / 120
- X2 / (120 * 6 * 7)))))));
elsif X < Pi / 2 then
return Cos (Pi / 2 - X);
else
-- Bring value of X in safe range.
return Sin (Reduce (X));
end if;
end Sin;
---------
-- Cos --
---------
function Cos (X : F) return F
is
X2 : constant F := X * X;
begin
if X < 0.0 then
return Cos (-X);
elsif X < Pi / 4 then
return 1.0 - F (X2 / 2 * (One - F (X2 * (F (One - X2 / 30) / 12))));
elsif X < Pi / 2 then
return Sin (Pi / 2 - X);
else
return Cos (Reduce (X));
end if;
end Cos;
----------
-- Sqrt --
----------
-- function Sqrt (X : F) return F
-- is
-- Accuracy : constant := F'Delta;
-- Lo, Hi, Guess : F;
-- begin
-- if X < 0.0 then
-- return Sqrt (-X);
-- end if;
--
-- if X < One then
-- Lo := X;
-- Hi := One;
-- else
-- Lo := One;
-- Hi := X;
-- end if;
--
-- while Hi - Lo > 2.0 * Accuracy loop
-- Guess := (Lo + Hi) / 2.0;
-- if Guess * Guess > X then
-- Hi := Guess;
-- else
-- Lo := Guess;
-- end if;
-- end loop;
-- return (Lo + Hi) / 2.0;
-- end Sqrt;
------------
-- Reduce --
------------
function Reduce (X : F) return F
is
Excess : F := X;
begin
while abs Excess > Pi / 2 loop
Excess := Excess - Pi / 2;
end loop;
if X > 0.0 then
return Excess;
else
return -Excess;
end if;
end Reduce;
end Fixed_Point_Math;
|
reznikmm/matreshka | Ada | 20,029 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Calendars.ISO_8601;
with League.Holders.Booleans;
with League.Holders.JSON_Arrays;
with League.Holders.JSON_Objects;
with League.JSON.Arrays;
with League.JSON.Objects;
with League.JSON.Values;
with AWFC.Accounts.Users;
with Forum.Categories.Objects;
with Forum.Posts.References;
package body Server.Servlets.Forum_Servlets is
Page_Size : constant := 20;
function "+"
(Item : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
function Category_To_JSON
(Self : Forum.Categories.References.Category)
return League.JSON.Objects.JSON_Object;
function Topic_To_JSON
(Self : Forum.Topics.References.Topic)
return League.JSON.Objects.JSON_Object;
function Post_To_JSON
(Self : Forum.Posts.References.Post)
return League.JSON.Objects.JSON_Object;
function Page_To_JSON
(Page : Positive;
Total : Positive)
return League.JSON.Objects.JSON_Object;
function User_To_JSON
(Self : AWFC.Accounts.Users.User_Access)
return League.JSON.Objects.JSON_Object;
Format : constant League.Strings.Universal_String :=
+"yyyy-MM-dd HH:mm:ss";
---------------------
-- Bind_Parameters --
---------------------
overriding procedure Bind_Parameters
(Self : in out Forum_List_Page;
Processor : in out XML.Templates.Processors.Template_Processor'Class)
is
List : League.JSON.Arrays.JSON_Array;
begin
for J of Self.Categories loop
List.Append (Category_To_JSON (J).To_JSON_Value);
end loop;
Processor.Set_Parameter
(+"base", League.Holders.To_Holder (Self.Base.To_Universal_String));
Processor.Set_Parameter
(+"list", League.Holders.JSON_Arrays.To_Holder (List));
end Bind_Parameters;
---------------------
-- Bind_Parameters --
---------------------
overriding procedure Bind_Parameters
(Self : in out Topic_List_Page;
Processor : in out XML.Templates.Processors.Template_Processor'Class)
is
List : League.JSON.Arrays.JSON_Array;
Topics : constant Forum.Topics.References.Topic_Vector :=
Self.Category.Object.Get_Topics
(From => (Self.Page - 1) * Page_Size + 1,
To => Self.Page * Page_Size);
begin
Processor.Set_Parameter
(+"category",
League.Holders.JSON_Objects.To_Holder
(Category_To_JSON (Self.Category)));
Processor.Set_Parameter
(+"page",
League.Holders.JSON_Objects.To_Holder
(Page_To_JSON (Self.Page, Self.Category.Object.Get_Topic_Count)));
for J of Topics loop
List.Append (Topic_To_JSON (J).To_JSON_Value);
end loop;
Processor.Set_Parameter
(+"base", League.Holders.To_Holder (Self.Base.To_Universal_String));
Processor.Set_Parameter
(+"list", League.Holders.JSON_Arrays.To_Holder (List));
end Bind_Parameters;
---------------------
-- Bind_Parameters --
---------------------
overriding procedure Bind_Parameters
(Self : in out Post_List_Page;
Processor : in out XML.Templates.Processors.Template_Processor'Class)
is
List : League.JSON.Arrays.JSON_Array;
Posts : constant Forum.Posts.References.Post_Vector :=
Self.Topic.Object.Get_Posts
(From => (Self.Page - 1) * Page_Size + 1,
To => Self.Page * Page_Size);
begin
Processor.Set_Parameter
(+"category",
League.Holders.JSON_Objects.To_Holder
(Category_To_JSON (Self.Category)));
Processor.Set_Parameter
(+"topic",
League.Holders.JSON_Objects.To_Holder
(Topic_To_JSON (Self.Topic)));
Processor.Set_Parameter
(+"page",
League.Holders.JSON_Objects.To_Holder
(Page_To_JSON (Self.Page, Self.Topic.Object.Get_Post_Count)));
for J of Posts loop
List.Append (Post_To_JSON (J).To_JSON_Value);
end loop;
Processor.Set_Parameter
(+"base", League.Holders.To_Holder (Self.Base.To_Universal_String));
Processor.Set_Parameter
(+"list", League.Holders.JSON_Arrays.To_Holder (List));
end Bind_Parameters;
----------------------
-- Category_To_JSON --
----------------------
function Category_To_JSON
(Self : Forum.Categories.References.Category)
return League.JSON.Objects.JSON_Object is
begin
return Result : League.JSON.Objects.JSON_Object do
Result.Insert
(+"id",
League.JSON.Values.To_JSON_Value
(Forum.Categories.Encode (Self.Object.Get_Identifier)));
Result.Insert
(+"title",
League.JSON.Values.To_JSON_Value (Self.Object.Get_Title));
Result.Insert
(+"description",
League.JSON.Values.To_JSON_Value (Self.Object.Get_Description));
Result.Insert
(+"topic_count",
League.JSON.Values.To_JSON_Value
(+Natural'Wide_Wide_Image (Self.Object.Get_Topic_Count)));
end return;
end Category_To_JSON;
------------
-- Do_Get --
------------
overriding procedure Do_Get
(Self : in out Forum_Servlet;
Request : Servlet.HTTP_Requests.HTTP_Servlet_Request'Class;
Response : in out Servlet.HTTP_Responses.HTTP_Servlet_Response'Class)
is
function Get_Page_Number
(Image : League.Strings.Universal_String;
Page : out Positive) return Boolean;
---------------------
-- Get_Page_Number --
---------------------
function Get_Page_Number
(Image : League.Strings.Universal_String;
Page : out Positive) return Boolean
is
begin
Page := Positive'Wide_Wide_Value (Image.To_Wide_Wide_String);
return True;
exception
when Constraint_Error =>
return False;
end Get_Page_Number;
Path : constant League.String_Vectors.Universal_String_Vector
:= Request.Get_Path_Info;
Category : Forum.Categories.Category_Identifier;
Topic : Forum.Topics.Topic_Identifier;
Page : Positive := 1;
begin
if Path.Length = 0 then
Self.Get_Categories (Request, Response);
return;
elsif Path.Length = 2 then
if Forum.Categories.Decode (Path (1), Category)
and then Get_Page_Number (Path (2), Page)
then
Self.Get_Topics (Category, Page, Request, Response);
return;
end if;
elsif Path.Length = 3 then
if Forum.Categories.Decode (Path (1), Category)
and then Forum.Topics.Decode (Path (2), Topic)
and then Get_Page_Number (Path (3), Page)
then
Self.Get_Posts (Category, Topic, Page, Request, Response);
return;
end if;
end if;
-- Report error when decoding of URL fails
Response.Set_Status (Servlet.HTTP_Responses.Not_Found);
Response.Set_Content_Type (+"text/plain");
end Do_Get;
--------------------
-- Get_Categories --
--------------------
not overriding procedure Get_Categories
(Self : in out Forum_Servlet;
Request : Servlet.HTTP_Requests.HTTP_Servlet_Request'Class;
Response : in out Servlet.HTTP_Responses.HTTP_Servlet_Response'Class)
is
Forum_List : Forum_List_Page;
Path : League.String_Vectors.Universal_String_Vector
:= Request.Get_Servlet_Path;
begin
Path.Prepend
(League.String_Vectors.Universal_String_Vector'
(Request.Get_Context_Path));
Response.Set_Status (Servlet.HTTP_Responses.OK);
Response.Set_Content_Type (+"text/html");
Response.Set_Character_Encoding (+"UTF-8");
Response.Get_Output_Stream.Write
(Self.Forum_List.Render
(Request.Get_Session.all, Path, Self.Server.Get_Categories));
end Get_Categories;
---------------
-- Get_Posts --
---------------
not overriding procedure Get_Posts
(Self : in out Forum_Servlet;
Category : Forum.Categories.Category_Identifier;
Topic : Forum.Topics.Topic_Identifier;
Page : Positive;
Request : Servlet.HTTP_Requests.HTTP_Servlet_Request'Class;
Response : in out Servlet.HTTP_Responses.HTTP_Servlet_Response'Class)
is
Found : Boolean;
Path : League.String_Vectors.Universal_String_Vector
:= Request.Get_Servlet_Path;
begin
Path.Prepend
(League.String_Vectors.Universal_String_Vector'
(Request.Get_Context_Path));
Self.Post_List.Base.Set_Absolute_Path (Path);
Self.Post_List.Page := Page;
Self.Server.Get_Category
(Identifier => Category,
Value => Self.Post_List.Category,
Found => Found);
if not Found then
Response.Set_Status (Servlet.HTTP_Responses.Not_Found);
Response.Set_Content_Type (+"text/plain");
return;
end if;
Self.Server.Get_Topic
(Identifier => Topic,
Category => Category,
Value => Self.Post_List.Topic,
Found => Found);
if not Found then
Response.Set_Status (Servlet.HTTP_Responses.Not_Found);
Response.Set_Content_Type (+"text/plain");
return;
end if;
Response.Set_Status (Servlet.HTTP_Responses.OK);
Response.Set_Content_Type (+"text/html");
Response.Set_Character_Encoding (+"UTF-8");
Response.Get_Output_Stream.Write (Self.Post_List.Render);
end Get_Posts;
----------------------
-- Get_Servlet_Info --
----------------------
overriding function Get_Servlet_Info
(Self : Forum_Servlet) return League.Strings.Universal_String is
begin
return League.Strings.To_Universal_String ("Forum Servlet");
end Get_Servlet_Info;
----------------
-- Get_Topics --
----------------
not overriding procedure Get_Topics
(Self : in out Forum_Servlet;
Category : Forum.Categories.Category_Identifier;
Page : Positive;
Request : Servlet.HTTP_Requests.HTTP_Servlet_Request'Class;
Response : in out Servlet.HTTP_Responses.HTTP_Servlet_Response'Class)
is
Found : Boolean;
Path : League.String_Vectors.Universal_String_Vector
:= Request.Get_Servlet_Path;
begin
Path.Prepend
(League.String_Vectors.Universal_String_Vector'
(Request.Get_Context_Path));
Self.Topic_List.Base.Set_Absolute_Path (Path);
Self.Topic_List.Page := Page;
Self.Server.Get_Category
(Identifier => Category,
Value => Self.Topic_List.Category,
Found => Found);
if not Found then
Response.Set_Status (Servlet.HTTP_Responses.Not_Found);
Response.Set_Content_Type (+"text/plain");
return;
end if;
Response.Set_Status (Servlet.HTTP_Responses.OK);
Response.Set_Content_Type (+"text/html");
Response.Set_Character_Encoding (+"UTF-8");
Response.Get_Output_Stream.Write (Self.Topic_List.Render);
end Get_Topics;
----------------
-- Initialize --
----------------
overriding procedure Initialize
(Self : in out Forum_Servlet;
Config : not null access Servlet.Configs.Servlet_Config'Class) is
begin
Servlet.HTTP_Servlets.HTTP_Servlet (Self).Initialize (Config);
Self.Forum_List.Initialize
(Config.Get_Servlet_Context,
+"/WEB-INF/templates/page.xhtml.tmpl",
+"/WEB-INF/templates/forum_list.xhtml.tmpl");
Self.Topic_List.Initialize
(Config.Get_Servlet_Context,
+"/WEB-INF/templates/page.xhtml.tmpl",
+"/WEB-INF/templates/topic_list.xhtml.tmpl");
Self.Post_List.Initialize
(Config.Get_Servlet_Context,
+"/WEB-INF/templates/page.xhtml.tmpl",
+"/WEB-INF/templates/post_list.xhtml.tmpl");
end Initialize;
------------------
-- Page_To_JSON --
------------------
function Page_To_JSON
(Page : Positive;
Total : Positive)
return League.JSON.Objects.JSON_Object
is
function To_JSON_Value
(Value : Natural) return League.JSON.Values.JSON_Value;
-------------------
-- To_JSON_Value --
-------------------
function To_JSON_Value
(Value : Natural) return League.JSON.Values.JSON_Value
is
Image : constant Wide_Wide_String := Natural'Wide_Wide_Image (Value);
begin
return League.JSON.Values.To_JSON_Value (+Image (2 .. Image'Last));
end To_JSON_Value;
Total_Pages : constant Positive :=
(Total - 1 + Page_Size) / Page_Size;
begin
return Result : League.JSON.Objects.JSON_Object do
Result.Insert (+"current", To_JSON_Value (Page));
Result.Insert (+"total", To_JSON_Value (Total_Pages));
Result.Insert (+"prev", To_JSON_Value (Page - 1));
Result.Insert (+"next", To_JSON_Value (Page + 1));
Result.Insert
(+"has_prev",
League.JSON.Values.To_JSON_Value (Page > 1));
Result.Insert
(+"has_next",
League.JSON.Values.To_JSON_Value (Page < Total_Pages));
Result.Insert
(+"single",
League.JSON.Values.To_JSON_Value (Total_Pages = 1));
end return;
end Page_To_JSON;
------------------
-- Post_To_JSON --
------------------
function Post_To_JSON
(Self : Forum.Posts.References.Post)
return League.JSON.Objects.JSON_Object is
begin
return Result : League.JSON.Objects.JSON_Object do
Result.Insert
(+"id",
League.JSON.Values.To_JSON_Value
(Forum.Posts.Encode (Self.Object.Get_Identifier)));
Result.Insert
(+"text",
League.JSON.Values.To_JSON_Value (Self.Object.Get_Text));
Result.Insert
(+"creation_time",
League.JSON.Values.To_JSON_Value
(League.Calendars.ISO_8601.Image
(Format, Self.Object.Get_Creation_Time)));
Result.Insert
(+"author",
User_To_JSON (Self.Object.Get_Author).To_JSON_Value);
end return;
end Post_To_JSON;
------------
-- Render --
------------
function Render
(Self : in out Forum_List_Page'Class;
Session : Servlet.HTTP_Sessions.HTTP_Session'Class;
Path : League.String_Vectors.Universal_String_Vector;
Categories : Forum.Categories.References.Category_Vector)
return League.Strings.Universal_String is
begin
Self.Categories := Categories;
Self.Base.Set_Absolute_Path (Path);
return Self.Render;
end Render;
-------------------
-- Topic_To_JSON --
-------------------
function Topic_To_JSON
(Self : Forum.Topics.References.Topic)
return League.JSON.Objects.JSON_Object
is
begin
return Result : League.JSON.Objects.JSON_Object do
Result.Insert
(+"id",
League.JSON.Values.To_JSON_Value
(Forum.Topics.Encode (Self.Object.Get_Identifier)));
Result.Insert
(+"title",
League.JSON.Values.To_JSON_Value (Self.Object.Get_Title));
Result.Insert
(+"description",
League.JSON.Values.To_JSON_Value (Self.Object.Get_Description));
Result.Insert
(+"creation_time",
League.JSON.Values.To_JSON_Value
(League.Calendars.ISO_8601.Image
(Format, Self.Object.Get_Creation_Time)));
Result.Insert
(+"created_by",
User_To_JSON (Self.Object.Get_Created_By).To_JSON_Value);
Result.Insert
(+"last_post",
Post_To_JSON (Self.Object.Get_Last_Post).To_JSON_Value);
Result.Insert
(+"post_count",
League.JSON.Values.To_JSON_Value
(+Natural'Wide_Wide_Image (Self.Object.Get_Post_Count)));
end return;
end Topic_To_JSON;
------------------
-- User_To_JSON --
------------------
function User_To_JSON
(Self : AWFC.Accounts.Users.User_Access)
return League.JSON.Objects.JSON_Object
is
Email : constant League.Strings.Universal_String := Self.Get_Email;
begin
return Result : League.JSON.Objects.JSON_Object do
Result.Insert
(+"email",
League.JSON.Values.To_JSON_Value (Email));
Result.Insert
(+"nick",
League.JSON.Values.To_JSON_Value
(Email.Head (Email.Index ("@") - 1)));
end return;
end User_To_JSON;
end Server.Servlets.Forum_Servlets;
|
zhmu/ananas | Ada | 403 | adb | -- { dg-do run { target i?86-*-* x86_64-*-* alpha*-*-* ia64-*-* } }
with Unchecked_Conversion;
procedure Unchecked_Convert6b is
subtype c_5 is string(1..5);
function int2c5 is -- { dg-warning "different sizes" }
new unchecked_conversion (source => integer, target => c_5);
c5 : c_5;
begin
c5 := int2c5(16#12#);
if c5 (1) /= ASCII.DC2 then
raise Program_Error;
end if;
end;
|
Rodeo-McCabe/orka | Ada | 923 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ahven.Framework;
package Test_SIMD_SSE_Logical is
type Test is new Ahven.Framework.Test_Case with null record;
overriding
procedure Initialize (T : in out Test);
private
procedure Test_And;
procedure Test_Or;
end Test_SIMD_SSE_Logical;
|
kontena/ruby-packer | Ada | 3,460 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Text_IO.Integer_IO --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2003,2009 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.12 $
-- Binding Version 01.00
------------------------------------------------------------------------------
generic
type Num is range <>;
package Terminal_Interface.Curses.Text_IO.Integer_IO is
Default_Width : Field := Num'Width;
Default_Base : Number_Base := 10;
procedure Put
(Win : Window;
Item : Num;
Width : Field := Default_Width;
Base : Number_Base := Default_Base);
procedure Put
(Item : Num;
Width : Field := Default_Width;
Base : Number_Base := Default_Base);
private
pragma Inline (Put);
end Terminal_Interface.Curses.Text_IO.Integer_IO;
|
reznikmm/matreshka | Ada | 3,588 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body UAFLEX.Generator is
function Image (X : Natural) return Wide_Wide_String is
Text : constant Wide_Wide_String := Natural'Wide_Wide_Image (X);
begin
return Text (2 .. Text'Last);
end Image;
end UAFLEX.Generator;
|
zhmu/ananas | Ada | 9,072 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 1 0 0 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Storage_Elements;
with System.Unsigned_Types;
package body System.Pack_100 is
subtype Bit_Order is System.Bit_Order;
Reverse_Bit_Order : constant Bit_Order :=
Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order));
subtype Ofs is System.Storage_Elements.Storage_Offset;
subtype Uns is System.Unsigned_Types.Unsigned;
subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7;
use type System.Storage_Elements.Storage_Offset;
use type System.Unsigned_Types.Unsigned;
type Cluster is record
E0, E1, E2, E3, E4, E5, E6, E7 : Bits_100;
end record;
for Cluster use record
E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
end record;
for Cluster'Size use Bits * 8;
for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment,
1 +
1 * Boolean'Pos (Bits mod 2 = 0) +
2 * Boolean'Pos (Bits mod 4 = 0));
-- Use maximum possible alignment, given the bit field size, since this
-- will result in the most efficient code possible for the field.
type Cluster_Ref is access Cluster;
type Rev_Cluster is new Cluster
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_Cluster_Ref is access Rev_Cluster;
-- The following declarations are for the case where the address
-- passed to GetU_100 or SetU_100 is not guaranteed to be aligned.
-- These routines are used when the packed array is itself a
-- component of a packed record, and therefore may not be aligned.
type ClusterU is new Cluster;
for ClusterU'Alignment use 1;
type ClusterU_Ref is access ClusterU;
type Rev_ClusterU is new ClusterU
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_ClusterU_Ref is access Rev_ClusterU;
------------
-- Get_100 --
------------
function Get_100
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_100
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end Get_100;
-------------
-- GetU_100 --
-------------
function GetU_100
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_100
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : ClusterU_Ref with Address => A'Address, Import;
RC : Rev_ClusterU_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end GetU_100;
------------
-- Set_100 --
------------
procedure Set_100
(Arr : System.Address;
N : Natural;
E : Bits_100;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end Set_100;
-------------
-- SetU_100 --
-------------
procedure SetU_100
(Arr : System.Address;
N : Natural;
E : Bits_100;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : ClusterU_Ref with Address => A'Address, Import;
RC : Rev_ClusterU_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end SetU_100;
end System.Pack_100;
|
optikos/oasis | Ada | 9,099 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Nodes.Task_Body_Declarations is
function Create
(Task_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Body_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Is_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Declarations : Program.Element_Vectors.Element_Vector_Access;
Begin_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Statements : not null Program.Element_Vectors
.Element_Vector_Access;
Exception_Token : Program.Lexical_Elements.Lexical_Element_Access;
Exception_Handlers : Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access;
End_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Task_Body_Declaration is
begin
return Result : Task_Body_Declaration :=
(Task_Token => Task_Token, Body_Token => Body_Token, Name => Name,
With_Token => With_Token, Aspects => Aspects, Is_Token => Is_Token,
Declarations => Declarations, Begin_Token => Begin_Token,
Statements => Statements, Exception_Token => Exception_Token,
Exception_Handlers => Exception_Handlers, End_Token => End_Token,
End_Name => End_Name, Semicolon_Token => Semicolon_Token,
Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Declarations : Program.Element_Vectors.Element_Vector_Access;
Statements : not null Program.Element_Vectors
.Element_Vector_Access;
Exception_Handlers : Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access;
End_Name : Program.Elements.Identifiers.Identifier_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Task_Body_Declaration is
begin
return Result : Implicit_Task_Body_Declaration :=
(Name => Name, Aspects => Aspects, Declarations => Declarations,
Statements => Statements, Exception_Handlers => Exception_Handlers,
End_Name => End_Name, Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Name
(Self : Base_Task_Body_Declaration)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access is
begin
return Self.Name;
end Name;
overriding function Aspects
(Self : Base_Task_Body_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is
begin
return Self.Aspects;
end Aspects;
overriding function Declarations
(Self : Base_Task_Body_Declaration)
return Program.Element_Vectors.Element_Vector_Access is
begin
return Self.Declarations;
end Declarations;
overriding function Statements
(Self : Base_Task_Body_Declaration)
return not null Program.Element_Vectors.Element_Vector_Access is
begin
return Self.Statements;
end Statements;
overriding function Exception_Handlers
(Self : Base_Task_Body_Declaration)
return Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access is
begin
return Self.Exception_Handlers;
end Exception_Handlers;
overriding function End_Name
(Self : Base_Task_Body_Declaration)
return Program.Elements.Identifiers.Identifier_Access is
begin
return Self.End_Name;
end End_Name;
overriding function Task_Token
(Self : Task_Body_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Task_Token;
end Task_Token;
overriding function Body_Token
(Self : Task_Body_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Body_Token;
end Body_Token;
overriding function With_Token
(Self : Task_Body_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.With_Token;
end With_Token;
overriding function Is_Token
(Self : Task_Body_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Is_Token;
end Is_Token;
overriding function Begin_Token
(Self : Task_Body_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Begin_Token;
end Begin_Token;
overriding function Exception_Token
(Self : Task_Body_Declaration)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Exception_Token;
end Exception_Token;
overriding function End_Token
(Self : Task_Body_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.End_Token;
end End_Token;
overriding function Semicolon_Token
(Self : Task_Body_Declaration)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Semicolon_Token;
end Semicolon_Token;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Task_Body_Declaration)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Task_Body_Declaration)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Task_Body_Declaration)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
procedure Initialize
(Self : aliased in out Base_Task_Body_Declaration'Class) is
begin
Set_Enclosing_Element (Self.Name, Self'Unchecked_Access);
for Item in Self.Aspects.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
for Item in Self.Declarations.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
for Item in Self.Statements.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
for Item in Self.Exception_Handlers.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
if Self.End_Name.Assigned then
Set_Enclosing_Element (Self.End_Name, Self'Unchecked_Access);
end if;
null;
end Initialize;
overriding function Is_Task_Body_Declaration_Element
(Self : Base_Task_Body_Declaration)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Task_Body_Declaration_Element;
overriding function Is_Declaration_Element
(Self : Base_Task_Body_Declaration)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Declaration_Element;
overriding procedure Visit
(Self : not null access Base_Task_Body_Declaration;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Task_Body_Declaration (Self);
end Visit;
overriding function To_Task_Body_Declaration_Text
(Self : aliased in out Task_Body_Declaration)
return Program.Elements.Task_Body_Declarations
.Task_Body_Declaration_Text_Access is
begin
return Self'Unchecked_Access;
end To_Task_Body_Declaration_Text;
overriding function To_Task_Body_Declaration_Text
(Self : aliased in out Implicit_Task_Body_Declaration)
return Program.Elements.Task_Body_Declarations
.Task_Body_Declaration_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Task_Body_Declaration_Text;
end Program.Nodes.Task_Body_Declarations;
|
Rodeo-McCabe/orka | Ada | 1,500 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Orka.SIMD.SSE.Singles;
package Orka.SIMD.SSE4_1.Singles.Math is
pragma Pure;
use Orka.SIMD.SSE.Singles;
function Round (Elements : m128; Rounding : Unsigned_32) return m128
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_roundps";
function Round_Nearest_Integer (Elements : m128) return m128 is
(Round (Elements, 0));
-- Round each element to the nearest integer
function Floor (Elements : m128) return m128 is
(Round (Elements, 1));
-- Round each element down to an integer value
function Ceil (Elements : m128) return m128 is
(Round (Elements, 2));
-- Round each element up to an integer value
function Round_Truncate (Elements : m128) return m128 is
(Round (Elements, 3));
-- Round each element to zero
end Orka.SIMD.SSE4_1.Singles.Math;
|
AdaCore/libadalang | Ada | 112 | adb | procedure Testexp is
A : Float := 12412335125.99 ** 2;
pragma Test_Statement;
begin
null;
end Testexp;
|
michalkonecny/polypaver | Ada | 427 | adb | with PolyPaver.Floats;
package body Example is
function Sqrt (X : in Float) return Float
is
R,S : Float;
begin
S := X;
R := PolyPaver.Floats.Add(PolyPaver.Floats.Multiply(0.5,X),0.5);
while R /= s loop
--# assert R in -0.25*X**2+X .. 0.25*X**2+1.0 ;
S := r;
R := PolyPaver.Floats.Multiply(0.5,
PolyPaver.Floats.Add(S,PolyPaver.Floats.Divide(X,S)));
end loop;
return R;
end Sqrt;
end Example; |
MinimSecure/unum-sdk | Ada | 937 | adb | -- Copyright 2018-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Enum_With_Gap is
procedure Do_Nothing (E : AR_Access) is
begin
null;
end Do_Nothing;
procedure Do_Nothing (E : String_Access) is
begin
null;
end Do_Nothing;
end Enum_With_Gap;
|
MatrixMike/AdaDemo1 | Ada | 876 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Latin_1;
with Ada.Numerics;
with Ada.Float_text_IO;
with Ada.Numerics.Float_Random;
procedure Learn is
subtype Alphabet is Character range 'A' .. 'Z';
Random_Value : Float; My_Generator : Ada.Numerics.Float_Random.Generator;
begin
-- Random_Value := 150.0;
Put_Line ("Learning Ada from " & Alphabet'First & " to " & Alphabet'Last);
Ada.Text_IO.Put (Item => Ada.Characters.Latin_1.Copyright_Sign);
-- Initialize the generator from the system clock
Ada.Numerics.Float_Random.Reset (My_Generator);
for I in 1..8 loop
-- Get a random float between 0.0 and 1.0
Random_Value := Ada.Numerics.Float_Random.Random (My_Generator); -- Scale the float to between 100.0 and 250.0
Random_Value := 150.0 * Random_Value + 100.0;
Ada.Float_Text_IO.Put (Random_Value);
end loop;
end Learn;
|
reznikmm/matreshka | Ada | 3,627 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.String_Expressions.Hash is
new AMF.Elements.Generic_Hash (UML_String_Expression, UML_String_Expression_Access);
|
reznikmm/matreshka | Ada | 5,064 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Named_Elements.Collections is
pragma Preelaborate;
package UML_Named_Element_Collections is
new AMF.Generic_Collections
(UML_Named_Element,
UML_Named_Element_Access);
type Set_Of_UML_Named_Element is
new UML_Named_Element_Collections.Set with null record;
Empty_Set_Of_UML_Named_Element : constant Set_Of_UML_Named_Element;
type Ordered_Set_Of_UML_Named_Element is
new UML_Named_Element_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Named_Element : constant Ordered_Set_Of_UML_Named_Element;
type Bag_Of_UML_Named_Element is
new UML_Named_Element_Collections.Bag with null record;
Empty_Bag_Of_UML_Named_Element : constant Bag_Of_UML_Named_Element;
type Sequence_Of_UML_Named_Element is
new UML_Named_Element_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Named_Element : constant Sequence_Of_UML_Named_Element;
private
Empty_Set_Of_UML_Named_Element : constant Set_Of_UML_Named_Element
:= (UML_Named_Element_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Named_Element : constant Ordered_Set_Of_UML_Named_Element
:= (UML_Named_Element_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Named_Element : constant Bag_Of_UML_Named_Element
:= (UML_Named_Element_Collections.Bag with null record);
Empty_Sequence_Of_UML_Named_Element : constant Sequence_Of_UML_Named_Element
:= (UML_Named_Element_Collections.Sequence with null record);
end AMF.UML.Named_Elements.Collections;
|
gerr135/ada_composition | Ada | 4,805 | adb | --
-- The demo of type hierarchy use: declarations, loops, dereferencing..
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
with Ada.Command_Line, GNAT.Command_Line;
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO;
with Ada.Containers.Vectors;
with Iface_lists.Fixed;
with Iface_lists.Dynamic;
with Iface_lists.Vectors;
with Base; use Base;
procedure Test_list_combo is
package ACV is new Ada.Containers.Vectors(Base.Index, Base_Fixed5);
package PL is new Iface_Lists(Base.Index_Base, Base_Interface);
package PLF is new PL.Fixed(Base_Fixed5);
package PLDD is new PL.Dynamic(Base_Dynamic);
package PLDV is new PL.Dynamic(Base_Vector);
package PLVV is new PL.Vectors(Base_Vector);
-- lc : PL.List_Interface'Class := PLD.To_Vector(5);
begin -- main
Put_Line("testing Ada.Containers.Vectors..");
declare
v : ACV.Vector := ACV.To_Vector(5);
begin
Put("assigning values .. ");
for i in Base.Index range 1 .. 5 loop
v(i) := set_idx_fixed(i);
end loop;
Put_Line("done;");
Put(" indices: First =" & v.First_Index'img & ", Last =" & v.Last_Index'img);
Put_Line(", Length =" & v.Length'img);
Put_Line("done; values (of-loop): ");
for item of v loop
item.print;
end loop;
Put_Line("now direct indexing: ");
for i in Base.Index range 1 .. 5 loop
declare
item : Base_Fixed5 := v(i);
begin
item.print;
end;
end loop;
end;
New_Line;
--
New_Line;
Put_Line("testing Lists.Fixed ..");
declare
lf : PLF.List(5);
begin
Put("assigning values .. ");
for i in Base.Index range 1 .. 5 loop
lf(i) := Base_Interface'Class(set_idx_fixed(i));
end loop;
Put_Line("done;");
Put(" indices: First =" & lf.First_Index'img & ", Last =" & lf.Last_Index'img);
Put_Line(", Length =" & lf.Length'img);
Put_Line("done; values (of-loop): ");
for item of lf loop
item.print;
end loop;
Put_Line("now direct indexing: ");
for i in Base.Index range 1 .. 5 loop
declare
item : Base_Fixed5 := Base_Fixed5(lf(i).Data.all);
begin
item.print;
end;
end loop;
end;
New_Line;
--
New_Line;
Put_Line("testing Lists.Dynamic with Base_Dynamic ..");
declare
use PLDD;
ld : PLDD.List := To_Vector(5);
begin
Put("assigning values .. ");
for i in Base.Index range 1 .. 5 loop
New_Line; Put(" i="&i'Img);
ld(i) := Base_Interface'Class(set_idx_dynamic(i));
end loop;
New_Line;
Put_Line("done;");
Put(" indices: First =" & ld.First_Index'img & ", Last =" & ld.Last_Index'img);
Put_Line(", Length =" & ld.Length'img);
Put_Line("done; values (of-loop): ");
for item of ld loop
item.print;
end loop;
Put_Line("now direct indexing: ");
for i in Base.Index range 1 .. 5 loop
declare
item : Base_Dynamic := Base_Dynamic(ld(i).Data.all);
begin
item.print;
end;
end loop;
end;
New_Line;
--
New_Line;
Put_Line("testing Lists.Dynamic with Base_Vector ..");
declare
use PLDV;
ld : PLDV.List := To_Vector(5);
begin
Put("assigning values .. ");
for i in Base.Index range 1 .. 5 loop
New_Line; Put(" i="&i'Img);
ld(i) := Base_Interface'Class(set_idx_vector(i)); -- this assignment of the constructed vector seems to trigger that weird storage errors
-- what's more, simply changing whitespace - adding a line-break between New_Line and Put
-- changes "heap exhausted" into "stack overflow" error..
end loop;
New_Line;
Put_Line("done;");
Put(" indices: First =" & ld.First_Index'img & ", Last =" & ld.Last_Index'img);
Put_Line(", Length =" & ld.Length'img);
Put_Line("done; values (of-loop): ");
for item of ld loop
item.print;
end loop;
Put_Line("now direct indexing: ");
for i in Base.Index range 1 .. 5 loop
declare
item : Base_Vector := Base_Vector(ld(i).Data.all);
begin
item.print;
end;
end loop;
end;
New_Line;
--
end Test_List_combo;
|
dilawar/ahir | Ada | 217 | ads | -- RUN: %llvmgcc -c %s
package Field_Order is
type Tagged_Type is abstract tagged null record;
type With_Discriminant (L : Positive) is new Tagged_Type with record
S : String (1 .. L);
end record;
end;
|
reznikmm/matreshka | Ada | 3,686 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with League.Holders.Generic_Enumerations;
package AMF.OCL.Holders.Collection_Kinds is
new League.Holders.Generic_Enumerations
(AMF.OCL.OCL_Collection_Kind);
pragma Preelaborate (AMF.OCL.Holders.Collection_Kinds);
|
dan76/Amass | Ada | 4,184 | ads | -- Copyright © by Jeff Foley 2017-2023. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
-- SPDX-License-Identifier: Apache-2.0
name = "ShadowServer"
type = "misc"
local shadowServerWhoisAddress = ""
-- shadowServerWhoisURL is the URL for the ShadowServer whois server.
local shadowServerWhoisURL = "asn.shadowserver.org"
function start()
set_rate_limit(2)
end
function asn(ctx, addr, asn)
if (shadowServerWhoisAddress == "") then
shadowServerWhoisAddress = get_whois_addr(ctx)
if (shadowServerWhoisAddress == "") then return end
end
local result
if (asn == 0) then
if (addr == "") then return end
result = origin(ctx, addr)
if (result == nil) then return end
local cidrs = netblocks(ctx, result.asn)
if (cidrs == nil or #cidrs == 0) then return end
result['netblocks'] = cidrs
else
local cidrs = netblocks(ctx, asn)
if (cidrs == nil or #cidrs == 0) then return end
if (addr == "") then
local parts = split(cidrs[1], "/")
if (#parts < 2) then return end
addr = parts[1]
end
result = origin(ctx, addr)
if (result == nil) then return end
result['netblocks'] = cidrs
end
new_asn(ctx, result)
end
function origin(ctx, addr)
if not is_ipv4(addr) then return nil end
local name = reverse_ip(addr) .. ".origin.asn.shadowserver.org"
local resp, err = resolve(ctx, name, "TXT", false)
if ((err ~= nil and err ~= "") or #resp == 0) then
log(ctx, "failed to resolve the TXT record for " .. name .. ": " .. err)
return nil
end
local fields = split(resp[1].rrdata, "|")
return {
['addr']=addr,
['asn']=tonumber(trim_space(fields[1])),
['prefix']=trim_space(fields[2]),
['cc']=trim_space(fields[4]),
['desc']=trim_space(fields[3]) .. " - " .. trim_space(fields[5]),
}
end
function netblocks(ctx, asn)
local conn, err = socket.connect(ctx, shadowServerWhoisAddress, 43, "tcp")
if (err ~= nil and err ~= "") then
log(ctx, "failed to connect to " .. shadowServerWhoisAddress .. " on port 43: " .. err)
return nil
end
_, err = conn:send("prefix " .. tostring(asn) .. "\n")
if (err ~= nil and err ~= "") then
log(ctx, "failed to send the ASN parameter to " .. shadowServerWhoisAddress .. ": " .. err)
conn:close()
return nil
end
local data
data, err = conn:recv_all()
if (err ~= nil and err ~= "") then
log(ctx, "failed to receive the response from " .. shadowServerWhoisAddress .. ": " .. err)
conn:close()
return nil
end
local netblocks = {}
for _, block in pairs(split(data, "\n")) do
table.insert(netblocks, trim_space(block))
end
conn:close()
return netblocks
end
function split(str, delim)
local result = {}
local pattern = "[^%" .. delim .. "]+"
local matches = find(str, pattern)
if (matches == nil or #matches == 0) then return result end
for _, match in pairs(matches) do
table.insert(result, match)
end
return result
end
function get_whois_addr(ctx)
local resp, err = resolve(ctx, shadowServerWhoisURL, "A", false)
if ((err ~= nil and err ~= "") or #resp == 0) then
log(ctx, "failed to resolve the A record for " .. shadowServerWhoisURL .. ": " .. err)
return ""
end
return resp[1].rrdata
end
function is_ipv4(addr)
local octets = { addr:match("^(%d+)%.(%d+)%.(%d+)%.(%d+)$") }
if (#octets == 4) then
for _, v in pairs(octets) do
if tonumber(v) > 255 then return false end
end
return true
end
return false
end
function reverse_ip(addr)
local octets = { addr:match("^(%d+)%.(%d+)%.(%d+)%.(%d+)$") }
local ip = ""
for i, o in pairs(octets) do
local n = o
if (i ~= 1) then n = n .. "." end
ip = n .. ip
end
return ip
end
function trim_space(s)
if (s == nil) then return "" end
return s:match( "^%s*(.-)%s*$" )
end
|
reznikmm/matreshka | Ada | 3,709 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Text_Page_Continuation_Elements is
pragma Preelaborate;
type ODF_Text_Page_Continuation is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Text_Page_Continuation_Access is
access all ODF_Text_Page_Continuation'Class
with Storage_Size => 0;
end ODF.DOM.Text_Page_Continuation_Elements;
|
alvaromb/Compilemon | Ada | 1,282 | ads | -- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- This software was developed by John Self of the Arcadia project
-- at the University of California, Irvine.
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- TITLE file strings
-- AUTHOR: John Self (UCI)
-- DESCRIPTION used to store lines in the template files
-- NOTES if lines in a template exceed 128 characters we are in trouble
-- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/file_strings.a,v 1.3 90/01/12 15:20:02 self Exp Locker: self $
with vstrings;
package file_string is
new VSTRINGS(128);
|
gonma95/RealTimeSystem_CarDistrations | Ada | 489 | ads | -- Gonzalo Martin Rodriguez
-- Ivan Fernandez Samaniego
package Priorities is
Head_Priority : constant integer := 20; -- d=100, t=400
Risk_Priority : constant integer := 19; -- d=150, t=150
Sporadic_Priority : constant integer := 18; -- d=200, t=200
Distance_Priority : constant integer := 17; -- d=300, t=300
Steering_Priority : constant integer := 16; -- d=350, t=350
Display_Priority : constant integer := 15; -- d=1000, t=1000
end Priorities;
|
AdaCore/libadalang | Ada | 144 | adb | separate (P)
package body Nested is
procedure Boo is
begin
null;
end Boo;
end Nested;
--% node.parent.f_name.p_referenced_decl()
|
joakim-strandberg/wayland_ada_binding | Ada | 4,413 | ads | with C_Binding.Linux.Files;
package C_Binding.Linux.Memory_Maps is
type Memory_Map is tagged limited private;
function Has_Mapping (This : Memory_Map) return Boolean with
Global => null;
function Mapping (This : Memory_Map) return Void_Ptr with
Global => null,
Pre => Has_Mapping (This);
-- Returns 0 on success, otherwise -1.
function Unmap_Memory (This : in out Memory_Map) return Integer with
Global => null,
Post => (if Unmap_Memory'Result = 0 then not Has_Mapping (This));
-- Returns 0 on success, otherwise -1.
function Memory_Unmap
(Address : Void_Ptr;
Length : Ada.Streams.Stream_Element_Count) return Integer with
Global => null;
MAP_FAILED : constant Void_Ptr;
-- Share changes.
MAP_SHARED : constant := 16#01#;
type Memory_Protection is
(
Page_Can_Be_Read,
Page_Can_Be_Read_And_Written
);
procedure Get_Map_Memory
(File : in C_Binding.Linux.Files.File;
Address : Void_Ptr;
Length : Ada.Streams.Stream_Element_Count;
Protection : Memory_Protection;
Flags : Integer;
Offset : Ada.Streams.Stream_Element_Count;
This : in out Memory_Map) with
Global => null,
Pre => not Has_Mapping (This);
private
--
-- Flags to `msync'.
--
-- Sync memory asynchronously.
MS_ASYNC : constant := 1;
-- Synchronous memory sync.
MS_SYNC : constant := 4;
-- Invalidate the caches.
MS_INVALIDATE : constant := 2;
-- Protections are chosen from these bits, OR'd together. The
-- implementation does not necessarily support PROT_EXEC or PROT_WRITE
-- without PROT_READ. The only guarantees are that no writing will be
-- allowed without PROT_WRITE and no access will be allowed for PROT_NONE.
-- Page can be read.
PROT_READ : constant Prot_FLag := 16#1#;
-- Page can be written.
PROT_WRITE : constant Prot_FLag := 16#2#;
-- Page can be executed.
PROT_EXEC : constant Prot_FLag := 16#4#;
-- Page can not be accessed.
PROT_NONE : constant Prot_FLag := 16#0#;
-- Extend change to start of growsdown vma (mprotect only).
PROT_GROWSDOWN : constant Prot_FLag := 16#01000000#;
-- Extend change to start of growsup vma (mprotect only).
PROT_GROWSUP : constant Prot_FLag := 16#02000000#;
type Memory_Protection_To_Prot_Flag_Array is
array (Memory_Protection) of Prot_FLag;
Memory_Protection_To_Prot_Flag : constant Memory_Protection_To_Prot_Flag_Array
:= (
Page_Can_Be_Read => PROT_READ,
Page_Can_Be_Read_And_Written => PROT_READ and PROT_WRITE
);
function Conv is new Ada.Unchecked_Conversion (Source => long,
Target => Void_Ptr);
MAP_FAILED_VALUE : constant long := -1;
MAP_FAILED : constant Void_Ptr := Conv (MAP_FAILED_VALUE);
type Memory_Map is tagged limited record
My_Mapping : Void_Ptr := MAP_FAILED;
My_Length : Size_Type;
end record;
function Has_Mapping
(This : Memory_Map) return Boolean is
(This.My_Mapping /= MAP_FAILED);
function Mapping (This : Memory_Map) return Void_Ptr is
(This.My_Mapping);
function C_Mmap
(Addr : Void_Ptr;
Len : Size_Type;
Prot : Prot_FLag;
Flags : int;
Fd : Interfaces.C.int;
Offset : Interfaces.C.long) return Void_Ptr with
Import => True,
Convention => C,
External_Name => "mmap";
function C_Munmap
(Addr : Void_Ptr;
Length : Size_Type) return Interfaces.C.int with
Import => True,
Convention => C,
External_Name => "munmap";
-- The munmap() system call deletes the mappings for the specified address
-- range, and causes further references to addresses within the range
-- to generate invalid memory references. The region is also automatically
-- unmapped when the process is terminated. On the other hand, closing the
-- file descriptor does not unmap the region.
--
-- The address addr must be a multiple of the page size. All pages
-- containing a part of the indicated range are unmapped,
-- and subsequent references to these pages will generate SIGSEGV.
-- It is not an error if the indicated range does not contain
-- any mapped pages.
end C_Binding.Linux.Memory_Maps;
|
stcarrez/ada-util | Ada | 8,936 | adb | -----------------------------------------------------------------------
-- util-concurrent-sequence_queues -- Concurrent Fifo Queues
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body Util.Concurrent.Sequence_Queues is
-- ------------------------------
-- Put the element in the queue.
-- ------------------------------
procedure Enqueue (Into : in out Queue;
Item : in Element_Type;
Sequence : in Sequence_Type;
Wait : in Duration := FOREVER) is
begin
if Wait < 0.0 then
Into.Buffer.Enqueue (Item, Sequence);
else
select
Into.Buffer.Enqueue (Item, Sequence);
or
delay Wait;
raise Timeout;
end select;
end if;
end Enqueue;
-- ------------------------------
-- Get the next element in sequence from the queue.
-- Wait until the element with the last sequence gets available.
-- The current sequence is then incremented.
-- ------------------------------
procedure Dequeue (From : in out Queue;
Item : out Element_Type;
Sequence : out Sequence_Type;
Wait : in Duration := FOREVER) is
begin
if Wait < 0.0 then
From.Buffer.Dequeue (Item, Sequence);
else
select
From.Buffer.Dequeue (Item, Sequence);
or
delay Wait;
raise Timeout;
end select;
end if;
end Dequeue;
-- ------------------------------
-- Get the number of elements in the queue.
-- ------------------------------
function Get_Count (From : in Queue) return Natural is
begin
return From.Buffer.Get_Count;
end Get_Count;
-- ------------------------------
-- Get the sequence number that will be returned by the next Dequeue.
-- ------------------------------
function Get_Sequence (From : in Queue) return Sequence_Type is
begin
return From.Buffer.Get_Sequence;
end Get_Sequence;
-- ------------------------------
-- Reset the sequence number.
-- ------------------------------
procedure Reset_Sequence (Into : in out Queue;
Start : in Sequence_Type := Sequence_Type'First) is
begin
Into.Buffer.Set_Sequence (Start);
end Reset_Sequence;
-- ------------------------------
-- Set the queue size.
-- ------------------------------
procedure Set_Size (Into : in out Queue;
Capacity : in Positive) is
begin
Into.Buffer.Set_Size (Capacity);
end Set_Size;
-- ------------------------------
-- Initializes the queue.
-- ------------------------------
overriding
procedure Initialize (Object : in out Queue) is
begin
Object.Buffer.Set_Size (Default_Size);
end Initialize;
-- ------------------------------
-- Release the queue elements.
-- ------------------------------
overriding
procedure Finalize (Object : in out Queue) is
begin
Object.Buffer.Set_Size (0);
end Finalize;
-- Queue of objects.
protected body Protected_Queue is
function Get_Index (Sequence : in Sequence_Type) return Natural is
Offset : Natural;
begin
if Sequence < Seq then
raise Invalid_Sequence;
end if;
Offset := Sequence_Type'Pos (Sequence) - Sequence_Type'Pos (Seq);
if First + Offset > Elements'Last then
return Elements'First + Offset - (Elements'Last - First) - 1;
else
return First + Offset;
end if;
end Get_Index;
-- ------------------------------
-- Put the element in the queue.
-- If the queue is full, wait until some room is available.
-- ------------------------------
entry Enqueue (Item : in Element_Type;
Sequence : in Sequence_Type) when Count >= 0 is
Pos : constant Natural := Get_Index (Sequence);
begin
Elements (Pos) := Item;
States (Pos) := True;
Last := Last + 1;
if Last > Elements'Last then
if Clear_On_Dequeue then
Last := Elements'First + 1;
else
Last := Elements'First;
end if;
end if;
Count := Count + 1;
end Enqueue;
-- ------------------------------
-- Get an element from the queue.
-- Wait until one element gets available.
-- ------------------------------
entry Dequeue (Item : out Element_Type;
Sequence : out Sequence_Type) when States (First) is
begin
Count := Count - 1;
Item := Elements (First);
Sequence := Seq;
Seq := Sequence_Type'Succ (Seq);
-- For the clear on dequeue mode, erase the queue element.
-- If the element holds some storage or a reference, this gets cleared here.
-- The element used to clear is at index 0 (which does not exist if Clear_On_Dequeue
-- is false). There is no overhead when this is not used
-- (ie, instantiation/compile time flag).
if Clear_On_Dequeue then
Elements (First) := Elements (0);
end if;
States (First) := False;
First := First + 1;
if First > Elements'Last then
if Clear_On_Dequeue then
First := Elements'First + 1;
else
First := Elements'First;
end if;
end if;
end Dequeue;
-- ------------------------------
-- Get the number of elements in the queue.
-- ------------------------------
function Get_Count return Natural is
begin
return Count;
end Get_Count;
-- ------------------------------
-- Get the sequence number that will be returned by the next Dequeue.
-- ------------------------------
function Get_Sequence return Sequence_Type is
begin
return Seq;
end Get_Sequence;
-- ------------------------------
-- Reset the sequence number.
-- ------------------------------
procedure Set_Sequence (Start : in Sequence_Type) is
begin
Seq := Start;
end Set_Sequence;
-- ------------------------------
-- Set the queue size.
-- ------------------------------
procedure Set_Size (Capacity : in Natural) is
procedure Free is new Ada.Unchecked_Deallocation (Element_Array, Element_Array_Access);
procedure Free is new Ada.Unchecked_Deallocation (Boolean_Array, Boolean_Array_Access);
First_Pos : Natural := 1;
begin
if Clear_On_Dequeue then
First_Pos := 0;
end if;
if Capacity = 0 then
Free (Elements);
Free (States);
elsif Elements = null then
Elements := new Element_Array (First_Pos .. Capacity);
States := new Boolean_Array (First_Pos .. Capacity);
States.all := (others => False);
else
declare
New_Array : constant Element_Array_Access
:= new Element_Array (First_Pos .. Capacity);
New_State : constant Boolean_Array_Access
:= new Boolean_Array (First_Pos .. Capacity);
begin
New_State.all := (others => False);
if Capacity > Elements'Length then
New_Array (First_Pos .. Elements'Last) := Elements (First_Pos .. Elements'Last);
New_State (First_Pos .. Elements'Last) := States (First_Pos .. Elements'Last);
else
New_Array (First_Pos .. Capacity) := Elements (First_Pos .. Capacity);
New_State (First_Pos .. Capacity) := States (First_Pos .. Capacity);
end if;
Free (Elements);
Free (States);
Elements := New_Array;
States := New_State;
end;
end if;
end Set_Size;
end Protected_Queue;
end Util.Concurrent.Sequence_Queues;
|
guillaume-lin/tsc | Ada | 12,579 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Eugene V. Melaragno <[email protected]> 2000
-- Version Control
-- $Revision: 1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with ncurses2.util; use ncurses2.util;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels;
with Terminal_Interface.Curses.Panels.User_Data;
with ncurses2.genericPuts;
procedure ncurses2.demo_panels (nap_mseci : Integer) is
use Int_IO;
function mkpanel (color : Color_Number;
rows : Line_Count;
cols : Column_Count;
tly : Line_Position;
tlx : Column_Position) return Panel;
procedure rmpanel (pan : in out Panel);
procedure pflush;
procedure wait_a_while (msec : Integer);
procedure saywhat (text : String);
procedure fill_panel (pan : Panel);
nap_msec : Integer := nap_mseci;
function mkpanel (color : Color_Number;
rows : Line_Count;
cols : Column_Count;
tly : Line_Position;
tlx : Column_Position) return Panel is
win : Window;
pan : Panel := Null_Panel;
begin
win := New_Window (rows, cols, tly, tlx);
if Null_Window /= win then
pan := New_Panel (win);
if pan = Null_Panel then
Delete (win);
elsif Has_Colors then
declare
fg, bg : Color_Number;
begin
if color = Blue then
fg := White;
else
fg := Black;
end if;
bg := color;
Init_Pair (Color_Pair (color), fg, bg);
Set_Background (win, (Ch => ' ',
Attr => Normal_Video,
Color => Color_Pair (color)));
end;
else
Set_Background (win, (Ch => ' ',
Attr => (Bold_Character => True,
others => False),
Color => Color_Pair (color)));
end if;
end if;
return pan;
end mkpanel;
procedure rmpanel (pan : in out Panel) is
win : Window := Panel_Window (pan);
begin
Delete (pan);
Delete (win);
end rmpanel;
procedure pflush is
begin
Update_Panels;
Update_Screen;
end pflush;
procedure wait_a_while (msec : Integer) is
begin
-- The C version had some #ifdef blocks here
if nap_msec = 1 then
Getchar;
else
Nap_Milli_Seconds (nap_msec);
end if;
end wait_a_while;
procedure saywhat (text : String) is
begin
Move_Cursor (Line => Lines - 1, Column => 0);
Clear_To_End_Of_Line;
Add (Str => text);
end saywhat;
-- from sample-curses_demo.adb
type User_Data is new String (1 .. 2);
type User_Data_Access is access all User_Data;
package PUD is new Panels.User_Data (User_Data, User_Data_Access);
use PUD;
procedure fill_panel (pan : Panel) is
win : Window := Panel_Window (pan);
num : Character := Get_User_Data (pan) (2);
tmp6 : String (1 .. 6) := "-panx-";
maxy : Line_Count;
maxx : Column_Count;
begin
Move_Cursor (win, 1, 1);
tmp6 (5) := num;
Add (win, Str => tmp6);
Clear_To_End_Of_Line (win);
Box (win);
Get_Size (win, maxy, maxx);
for y in 2 .. maxy - 2 loop
for x in 1 .. maxx - 2 loop
Move_Cursor (win, y, x);
Add (win, num);
end loop;
end loop;
end fill_panel;
modstr : array (0 .. 5) of String (1 .. 5) :=
("test ",
"TEST ",
"(**) ",
"*()* ",
"<--> ",
"LAST "
);
package p is new ncurses2.genericPuts (1024);
use p;
use p.BS;
-- the C version said register int y, x;
tmpb : BS.Bounded_String;
begin
Refresh;
for y in 0 .. Integer (Lines - 2) loop
for x in 0 .. Integer (Columns - 1) loop
myPut (tmpb, (y + x) mod 10);
myAdd (Str => tmpb);
end loop;
end loop;
for y in 0 .. 4 loop
declare
p1, p2, p3, p4, p5 : Panel;
U1 : User_Data_Access := new User_Data'("p1");
U2 : User_Data_Access := new User_Data'("p2");
U3 : User_Data_Access := new User_Data'("p3");
U4 : User_Data_Access := new User_Data'("p4");
U5 : User_Data_Access := new User_Data'("p5");
begin
p1 := mkpanel (Red, Lines / 2 - 2, Columns / 8 + 1, 0, 0);
Set_User_Data (p1, U1);
p2 := mkpanel (Green, Lines / 2 + 1, Columns / 7, Lines / 4,
Columns / 10);
Set_User_Data (p2, U2);
p3 := mkpanel (Yellow, Lines / 4, Columns / 10, Lines / 2,
Columns / 9);
Set_User_Data (p3, U3);
p4 := mkpanel (Blue, Lines / 2 - 2, Columns / 8, Lines / 2 - 2,
Columns / 3);
Set_User_Data (p4, U4);
p5 := mkpanel (Magenta, Lines / 2 - 2, Columns / 8, Lines / 2,
Columns / 2 - 2);
Set_User_Data (p5, U5);
fill_panel (p1);
fill_panel (p2);
fill_panel (p3);
fill_panel (p4);
fill_panel (p5);
Hide (p4);
Hide (p5);
pflush;
saywhat ("press any key to continue");
wait_a_while (nap_msec);
saywhat ("h3 s1 s2 s4 s5; press any key to continue");
Move (p1, 0, 0);
Hide (p3);
Show (p1);
Show (p2);
Show (p4);
Show (p5);
pflush;
wait_a_while (nap_msec);
saywhat ("s1; press any key to continue");
Show (p1);
pflush;
wait_a_while (nap_msec);
saywhat ("s2; press any key to continue");
Show (p2);
pflush;
wait_a_while (nap_msec);
saywhat ("m2; press any key to continue");
Move (p2, Lines / 3 + 1, Columns / 8);
pflush;
wait_a_while (nap_msec);
saywhat ("s3;");
Show (p3);
pflush;
wait_a_while (nap_msec);
saywhat ("m3; press any key to continue");
Move (p3, Lines / 4 + 1, Columns / 15);
pflush;
wait_a_while (nap_msec);
saywhat ("b3; press any key to continue");
Bottom (p3);
pflush;
wait_a_while (nap_msec);
saywhat ("s4; press any key to continue");
Show (p4);
pflush;
wait_a_while (nap_msec);
saywhat ("s5; press any key to continue");
Show (p5);
pflush;
wait_a_while (nap_msec);
saywhat ("t3; press any key to continue");
Top (p3);
pflush;
wait_a_while (nap_msec);
saywhat ("t1; press any key to continue");
Top (p1);
pflush;
wait_a_while (nap_msec);
saywhat ("t2; press any key to continue");
Top (p2);
pflush;
wait_a_while (nap_msec);
saywhat ("t3; press any key to continue");
Top (p3);
pflush;
wait_a_while (nap_msec);
saywhat ("t4; press any key to continue");
Top (p4);
pflush;
wait_a_while (nap_msec);
for itmp in 0 .. 5 loop
declare
w4 : Window := Panel_Window (p4);
w5 : Window := Panel_Window (p5);
begin
saywhat ("m4; press any key to continue");
Move_Cursor (w4, Lines / 8, 1);
Add (w4, modstr (itmp));
Move (p4, Lines / 6, Column_Position (itmp) * (Columns / 8));
Move_Cursor (w5, Lines / 6, 1);
Add (w5, modstr (itmp));
pflush;
wait_a_while (nap_msec);
saywhat ("m5; press any key to continue");
Move_Cursor (w4, Lines / 6, 1);
Add (w4, modstr (itmp));
Move (p5, Lines / 3 - 1, (Column_Position (itmp) * 10) + 6);
Move_Cursor (w5, Lines / 8, 1);
Add (w5, modstr (itmp));
pflush;
wait_a_while (nap_msec);
end;
end loop;
saywhat ("m4; press any key to continue");
Move (p4, Lines / 6, 6 * (Columns / 8));
-- Move(p4, Lines / 6, itmp * (Columns / 8));
pflush;
wait_a_while (nap_msec);
saywhat ("t5; press any key to continue");
Top (p5);
pflush;
wait_a_while (nap_msec);
saywhat ("t2; press any key to continue");
Top (p2);
pflush;
wait_a_while (nap_msec);
saywhat ("t1; press any key to continue");
Top (p1);
pflush;
wait_a_while (nap_msec);
saywhat ("d2; press any key to continue");
rmpanel (p2);
pflush;
wait_a_while (nap_msec);
saywhat ("h3; press any key to continue");
Hide (p3);
pflush;
wait_a_while (nap_msec);
saywhat ("d1; press any key to continue");
rmpanel (p1);
pflush;
wait_a_while (nap_msec);
saywhat ("d4; press any key to continue");
rmpanel (p4);
pflush;
wait_a_while (nap_msec);
saywhat ("d5; press any key to continue");
rmpanel (p5);
pflush;
wait_a_while (nap_msec);
if (nap_msec = 1) then
exit;
else
nap_msec := 100;
end if;
end;
end loop;
Erase;
End_Windows;
end ncurses2.demo_panels;
|
reznikmm/matreshka | Ada | 3,664 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Draw_Text_Box_Elements is
pragma Preelaborate;
type ODF_Draw_Text_Box is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Draw_Text_Box_Access is
access all ODF_Draw_Text_Box'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Text_Box_Elements;
|
msrLi/portingSources | Ada | 1,054 | adb | -- Copyright 2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
function New_Bounded (Low, High : Integer) return Bounded is
Result : Bounded (Low .. High);
begin
for J in Low .. High loop
Result (J) := J;
end loop;
return Result;
end New_Bounded;
procedure Do_Nothing (A : System.Address) is
begin
null;
end Do_Nothing;
end Pck;
|
reznikmm/matreshka | Ada | 11,477 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.DC;
with AMF.DG.Clip_Paths;
with AMF.DG.Groups;
with AMF.DG.Markers;
with AMF.DG.Styles.Collections;
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.DD_Attributes;
with AMF.Visitors.DG_Iterators;
with AMF.Visitors.DG_Visitors;
package body AMF.Internals.DG_Polygons is
---------------
-- Get_Point --
---------------
overriding function Get_Point
(Self : not null access constant DG_Polygon_Proxy)
return AMF.DC.Sequence_Of_DC_Point is
begin
return
AMF.Internals.Tables.DD_Attributes.Internal_Get_Point
(Self.Element);
end Get_Point;
----------------------
-- Get_Start_Marker --
----------------------
overriding function Get_Start_Marker
(Self : not null access constant DG_Polygon_Proxy)
return AMF.DG.Markers.DG_Marker_Access is
begin
return
AMF.DG.Markers.DG_Marker_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Start_Marker
(Self.Element)));
end Get_Start_Marker;
----------------------
-- Set_Start_Marker --
----------------------
overriding procedure Set_Start_Marker
(Self : not null access DG_Polygon_Proxy;
To : AMF.DG.Markers.DG_Marker_Access) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Start_Marker
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Start_Marker;
--------------------
-- Get_End_Marker --
--------------------
overriding function Get_End_Marker
(Self : not null access constant DG_Polygon_Proxy)
return AMF.DG.Markers.DG_Marker_Access is
begin
return
AMF.DG.Markers.DG_Marker_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.DD_Attributes.Internal_Get_End_Marker
(Self.Element)));
end Get_End_Marker;
--------------------
-- Set_End_Marker --
--------------------
overriding procedure Set_End_Marker
(Self : not null access DG_Polygon_Proxy;
To : AMF.DG.Markers.DG_Marker_Access) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_End_Marker
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_End_Marker;
--------------------
-- Get_Mid_Marker --
--------------------
overriding function Get_Mid_Marker
(Self : not null access constant DG_Polygon_Proxy)
return AMF.DG.Markers.DG_Marker_Access is
begin
return
AMF.DG.Markers.DG_Marker_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Mid_Marker
(Self.Element)));
end Get_Mid_Marker;
--------------------
-- Set_Mid_Marker --
--------------------
overriding procedure Set_Mid_Marker
(Self : not null access DG_Polygon_Proxy;
To : AMF.DG.Markers.DG_Marker_Access) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Mid_Marker
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Mid_Marker;
---------------
-- Get_Group --
---------------
overriding function Get_Group
(Self : not null access constant DG_Polygon_Proxy)
return AMF.DG.Groups.DG_Group_Access is
begin
return
AMF.DG.Groups.DG_Group_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Group
(Self.Element)));
end Get_Group;
---------------
-- Set_Group --
---------------
overriding procedure Set_Group
(Self : not null access DG_Polygon_Proxy;
To : AMF.DG.Groups.DG_Group_Access) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Group
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Group;
---------------------
-- Get_Local_Style --
---------------------
overriding function Get_Local_Style
(Self : not null access constant DG_Polygon_Proxy)
return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style is
begin
return
AMF.DG.Styles.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Local_Style
(Self.Element)));
end Get_Local_Style;
----------------------
-- Get_Shared_Style --
----------------------
overriding function Get_Shared_Style
(Self : not null access constant DG_Polygon_Proxy)
return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style is
begin
return
AMF.DG.Styles.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Shared_Style
(Self.Element)));
end Get_Shared_Style;
-------------------
-- Get_Transform --
-------------------
overriding function Get_Transform
(Self : not null access constant DG_Polygon_Proxy)
return AMF.DG.Sequence_Of_DG_Transform is
begin
return
AMF.Internals.Tables.DD_Attributes.Internal_Get_Transform
(Self.Element);
end Get_Transform;
-------------------
-- Get_Clip_Path --
-------------------
overriding function Get_Clip_Path
(Self : not null access constant DG_Polygon_Proxy)
return AMF.DG.Clip_Paths.DG_Clip_Path_Access is
begin
return
AMF.DG.Clip_Paths.DG_Clip_Path_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Clip_Path
(Self.Element)));
end Get_Clip_Path;
-------------------
-- Set_Clip_Path --
-------------------
overriding procedure Set_Clip_Path
(Self : not null access DG_Polygon_Proxy;
To : AMF.DG.Clip_Paths.DG_Clip_Path_Access) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Clip_Path
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Clip_Path;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant DG_Polygon_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.DG_Visitors.DG_Visitor'Class then
AMF.Visitors.DG_Visitors.DG_Visitor'Class
(Visitor).Enter_Polygon
(AMF.DG.Polygons.DG_Polygon_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant DG_Polygon_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.DG_Visitors.DG_Visitor'Class then
AMF.Visitors.DG_Visitors.DG_Visitor'Class
(Visitor).Leave_Polygon
(AMF.DG.Polygons.DG_Polygon_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant DG_Polygon_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.DG_Iterators.DG_Iterator'Class then
AMF.Visitors.DG_Iterators.DG_Iterator'Class
(Iterator).Visit_Polygon
(Visitor,
AMF.DG.Polygons.DG_Polygon_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.DG_Polygons;
|
kimtg/euler-ada | Ada | 235 | adb | with ada.text_io;
use ada.text_io;
procedure euler6 is
sum, sq_sum : integer := 0;
begin
for i in 1 .. 100 loop
sum := sum + i;
sq_sum := sq_sum + i * i;
end loop;
put_line(integer'image(sum * sum - sq_sum));
end;
|
stcarrez/ada-asf | Ada | 6,738 | adb | -----------------------------------------------------------------------
-- components-widgets-panels -- Collapsible panels
-- Copyright (C) 2013, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Beans.Objects;
with ASF.Components.Base;
package body ASF.Components.Widgets.Panels is
procedure Render_Action_Icon (Writer : in out ASF.Contexts.Writer.Response_Writer'Class;
Name : in String);
procedure Render_Action_Icon (Writer : in out ASF.Contexts.Writer.Response_Writer'Class;
Name : in String) is
begin
Writer.Start_Element ("a");
Writer.Write_Attribute ("href", "#");
Writer.Write_Attribute ("class", "ui-panel-icon ui-corner-all ui-state-default");
Writer.Start_Element ("span");
Writer.Write_Attribute ("class", Name);
Writer.End_Element ("span");
Writer.End_Element ("a");
end Render_Action_Icon;
-- ------------------------------
-- Render the panel header.
-- ------------------------------
procedure Render_Header (UI : in UIPanel;
Writer : in out ASF.Contexts.Writer.Response_Writer'Class;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
use type ASF.Components.Base.UIComponent_Access;
Header : Util.Beans.Objects.Object;
Header_Facet : ASF.Components.Base.UIComponent_Access;
Closable : constant Boolean := UI.Get_Attribute (CLOSABLE_ATTR_NAME, Context);
Toggleable : constant Boolean := UI.Get_Attribute (TOGGLEABLE_ATTR_NAME, Context);
begin
Writer.Start_Element ("div");
Writer.Write_Attribute ("class", "ui-panel-header ui-widget-header");
Header := UI.Get_Attribute (Name => HEADER_ATTR_NAME, Context => Context);
if not Util.Beans.Objects.Is_Empty (Header) then
Writer.Start_Element ("span");
Writer.Write_Text (Header);
Writer.End_Element ("span");
end if;
-- If there is a header facet, render it now.
Header_Facet := UI.Get_Facet (HEADER_FACET_NAME);
if Header_Facet /= null then
Header_Facet.Encode_All (Context);
end if;
if Closable then
Render_Action_Icon (Writer, "ui-icon ui-icon-closethick");
end if;
if Toggleable then
Render_Action_Icon (Writer, "ui-icon ui-icon-minusthick");
end if;
Writer.End_Element ("div");
-- Write the javascript to support the close and toggle actions.
if Closable or Toggleable then
Writer.Queue_Script ("$(""#");
Writer.Queue_Script (UI.Get_Client_Id);
Writer.Queue_Script (""").panel();");
end if;
end Render_Header;
-- ------------------------------
-- Render the panel footer.
-- ------------------------------
procedure Render_Footer (UI : in UIPanel;
Writer : in out ASF.Contexts.Writer.Response_Writer'Class;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
use type ASF.Components.Base.UIComponent_Access;
Footer : Util.Beans.Objects.Object;
Footer_Facet : ASF.Components.Base.UIComponent_Access;
Has_Footer : Boolean;
begin
Footer_Facet := UI.Get_Facet (FOOTER_FACET_NAME);
Footer := UI.Get_Attribute (Name => FOOTER_ATTR_NAME, Context => Context);
Has_Footer := Footer_Facet /= null or else not Util.Beans.Objects.Is_Empty (Footer);
if Has_Footer then
Writer.Start_Element ("div");
Writer.Write_Attribute ("class", "ui-panel-footer ui-widget-footer");
end if;
if not Util.Beans.Objects.Is_Empty (Footer) then
Writer.Write_Text (Footer);
end if;
-- If there is a footer facet, render it now.
if Footer_Facet /= null then
Footer_Facet.Encode_All (Context);
end if;
if Has_Footer then
Writer.End_Element ("div");
end if;
end Render_Footer;
-- ------------------------------
-- Render the panel header and prepare for the panel content.
-- ------------------------------
overriding
procedure Encode_Begin (UI : in UIPanel;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
Writer : constant Contexts.Writer.Response_Writer_Access := Context.Get_Response_Writer;
begin
if UI.Is_Rendered (Context) then
Writer.Start_Element ("div");
Writer.Write_Attribute ("id", UI.Get_Client_Id);
declare
use Util.Beans.Objects;
Style : constant Object := UI.Get_Attribute (Context, "style");
Class : constant Object := UI.Get_Attribute (Context, "styleClass");
begin
if not Util.Beans.Objects.Is_Null (Class) then
Writer.Write_Attribute ("class", To_String (Class)
& " ui-panel ui-widget ui-corner-all");
else
Writer.Write_Attribute ("class", "ui-panel ui-widget ui-corner-all");
end if;
if not Is_Null (Style) then
Writer.Write_Attribute ("style", Style);
end if;
end;
UIPanel'Class (UI).Render_Header (Writer.all, Context);
Writer.Start_Element ("div");
Writer.Write_Attribute ("class", "ui-panel-content ui-widget-content");
end if;
end Encode_Begin;
-- ------------------------------
-- Render the panel footer.
-- ------------------------------
overriding
procedure Encode_End (UI : in UIPanel;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
Writer : constant Contexts.Writer.Response_Writer_Access := Context.Get_Response_Writer;
begin
if UI.Is_Rendered (Context) then
Writer.End_Element ("div");
UIPanel'Class (UI).Render_Footer (Writer.all, Context);
Writer.End_Element ("div");
end if;
end Encode_End;
end ASF.Components.Widgets.Panels;
|
AdaCore/Ada-IntelliJ | Ada | 2,818 | ads | ------------------------------------------------------------------------------
-- Copyright (C) 2018, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
package Display is
procedure Scroll_Text (Str : String);
-- Scroll a string from right to left across the LED matrix
private
subtype LED_Row_Coord is Natural range 0 .. 4;
-- Row coordinate in LED matrix
subtype LED_Column_Coord is Natural range 0 .. 4;
-- Column coordinate in LED matrix
subtype GPIO_Pin_Index is Natural range 0 .. 31;
-- Pin index of the nRF51 GPIO points
----------------------
-- Pixel to IO Pins --
----------------------
-- There is no one to one correspondence between the GPIO matrix and LED
-- matrix. The GPIO matrix is 3x9 where the LED matrix is 5x5. The types
-- and data below define the mapping from LED matrix coordinates to the
-- GPIO points.
type Row_Range is new Natural range 1 .. 3;
-- Row coordinate in the GPIO matrix
type Column_Range is new Natural range 1 .. 9;
-- Column coordinate in the GPIO matrix
type LED_Point is record
Row_Id : Row_Range;
Column_Id : Column_Range;
end record;
-- Address of an LED in the GPIO matrix
Row_Points : array (Row_Range) of GPIO_Pin_Index :=
(13, 14, 15);
-- Pins for the GPIO matrix rows
Column_Points : array (Column_Range) of GPIO_Pin_Index :=
(04, 05, 06, 07, 08, 09, 10, 11, 12);
-- Pins for the GPIO matrix columns
Map : constant array (LED_Column_Coord, LED_Row_Coord) of LED_Point :=
(((1, 1), (3, 4), (2, 2), (1, 8), (3, 3)),
((2, 4), (3, 5), (1, 9), (1, 7), (2, 7)),
((1, 2), (3, 6), (2, 3), (1, 6), (3, 1)),
((2, 5), (3, 7), (3, 9), (1, 5), (2, 6)),
((1, 3), (3, 8), (2, 1), (1, 4), (3, 2))
);
-- Address of each LED in the GPIO matrix
end Display;
|
reznikmm/matreshka | Ada | 4,568 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Xlink.Type_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Xlink_Type_Attribute_Node is
begin
return Self : Xlink_Type_Attribute_Node do
Matreshka.ODF_Xlink.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Xlink_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Xlink_Type_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Type_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Xlink_URI,
Matreshka.ODF_String_Constants.Type_Attribute,
Xlink_Type_Attribute_Node'Tag);
end Matreshka.ODF_Xlink.Type_Attributes;
|
reznikmm/matreshka | Ada | 4,049 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Presentation_Object_Attributes;
package Matreshka.ODF_Presentation.Object_Attributes is
type Presentation_Object_Attribute_Node is
new Matreshka.ODF_Presentation.Abstract_Presentation_Attribute_Node
and ODF.DOM.Presentation_Object_Attributes.ODF_Presentation_Object_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Object_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Presentation_Object_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Presentation.Object_Attributes;
|
stcarrez/ada-asf | Ada | 2,950 | ads | -----------------------------------------------------------------------
-- asf-beans-mappers -- Read XML managed bean declarations
-- Copyright (C) 2010, 2011, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Beans.Objects;
with Util.Serialize.Mappers.Record_Mapper;
with EL.Contexts;
package ASF.Beans.Mappers is
type Managed_Bean_Fields is (FIELD_NAME,
FIELD_CLASS,
FIELD_SCOPE,
FIELD_MANAGED_BEAN,
FIELD_PROPERTY,
FIELD_PROPERTY_NAME,
FIELD_PROPERTY_VALUE,
FIELD_PROPERTY_CLASS);
type Bean_Factory_Access is access all ASF.Beans.Bean_Factory;
type Managed_Bean is limited record
Name : Util.Beans.Objects.Object;
Class : Util.Beans.Objects.Object;
Scope : Scope_Type := REQUEST_SCOPE;
Factory : Bean_Factory_Access := null;
Params : ASF.Beans.Parameter_Bean_Ref.Ref;
Prop_Name : Util.Beans.Objects.Object;
Prop_Value : Util.Beans.Objects.Object;
Context : EL.Contexts.ELContext_Access := null;
end record;
type Managed_Bean_Access is access all Managed_Bean;
-- Set the field identified by <b>Field</b> with the <b>Value</b>.
procedure Set_Member (MBean : in out Managed_Bean;
Field : in Managed_Bean_Fields;
Value : in Util.Beans.Objects.Object);
-- Setup the XML parser to read the managed bean definitions.
generic
Mapper : in out Util.Serialize.Mappers.Processing;
Factory : in Bean_Factory_Access;
Context : in EL.Contexts.ELContext_Access;
package Reader_Config is
Config : aliased Managed_Bean;
end Reader_Config;
private
package Config_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Managed_Bean,
Element_Type_Access => Managed_Bean_Access,
Fields => Managed_Bean_Fields,
Set_Member => Set_Member);
end ASF.Beans.Mappers;
|
stcarrez/jason | Ada | 32,842 | ads | -----------------------------------------------------------------------
-- Jason.Tickets.Models -- Jason.Tickets.Models
-----------------------------------------------------------------------
-- File generated by Dynamo DO NOT MODIFY
-- Template used: templates/model/package-spec.xhtml
-- Ada Generator: https://github.com/stcarrez/dynamo Version 1.4.0
-----------------------------------------------------------------------
-- Copyright (C) 2023 Stephane.Carrez
-- Written by Stephane.Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
pragma Warnings (Off);
with ADO.Sessions;
with ADO.Objects;
with ADO.Statements;
with ADO.SQL;
with ADO.Schemas;
with ADO.Queries;
with ADO.Queries.Loaders;
with Ada.Calendar;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Objects.Enums;
with Util.Beans.Basic.Lists;
with AWA.Users.Models;
with Jason.Projects.Models;
with Util.Beans.Methods;
pragma Warnings (On);
package Jason.Tickets.Models is
pragma Style_Checks ("-mrIu");
type Actor_Type is (ACTOR_USER, ACTOR_SYSTEM);
for Actor_Type use (ACTOR_USER => 0, ACTOR_SYSTEM => 1);
package Actor_Type_Objects is
new Util.Beans.Objects.Enums (Actor_Type);
type Nullable_Actor_Type is record
Is_Null : Boolean := True;
Value : Actor_Type;
end record;
type Status_Type is (OPEN, ASSIGNED, ACCEPTED, ON_HOLD, REOPEN, REJECTED, CLOSED);
for Status_Type use (OPEN => 0, ASSIGNED => 1, ACCEPTED => 2, ON_HOLD => 3, REOPEN => 4, REJECTED => 5, CLOSED => 6);
package Status_Type_Objects is
new Util.Beans.Objects.Enums (Status_Type);
type Nullable_Status_Type is record
Is_Null : Boolean := True;
Value : Status_Type;
end record;
type Ticket_Type is (INCIDENT, ISSUE, WORK, ENHANCEMENT, LIMITATION, CHANGE_REQUEST);
for Ticket_Type use (INCIDENT => 0, ISSUE => 1, WORK => 2, ENHANCEMENT => 3, LIMITATION => 4, CHANGE_REQUEST => 5);
package Ticket_Type_Objects is
new Util.Beans.Objects.Enums (Ticket_Type);
type Nullable_Ticket_Type is record
Is_Null : Boolean := True;
Value : Ticket_Type;
end record;
type Ticket_Ref is new ADO.Objects.Object_Ref with null record;
type Attribute_Ref is new ADO.Objects.Object_Ref with null record;
-- Create an object key for Ticket.
function Ticket_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Ticket from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Ticket_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Ticket : constant Ticket_Ref;
function "=" (Left, Right : Ticket_Ref'Class) return Boolean;
-- Set the ticket identifier.
procedure Set_Id (Object : in out Ticket_Ref;
Value : in ADO.Identifier);
-- Get the ticket identifier.
function Get_Id (Object : in Ticket_Ref)
return ADO.Identifier;
-- Get the optimistic lock version.
function Get_Version (Object : in Ticket_Ref)
return Integer;
-- Set the ticket summary.
procedure Set_Summary (Object : in out Ticket_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Summary (Object : in out Ticket_Ref;
Value : in String);
-- Get the ticket summary.
function Get_Summary (Object : in Ticket_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Summary (Object : in Ticket_Ref)
return String;
-- Set the ticket project unique identifier.
procedure Set_Ident (Object : in out Ticket_Ref;
Value : in Integer);
-- Get the ticket project unique identifier.
function Get_Ident (Object : in Ticket_Ref)
return Integer;
-- Set the ticket creation date.
procedure Set_Create_Date (Object : in out Ticket_Ref;
Value : in Ada.Calendar.Time);
-- Get the ticket creation date.
function Get_Create_Date (Object : in Ticket_Ref)
return Ada.Calendar.Time;
-- Set the ticket priority.
procedure Set_Priority (Object : in out Ticket_Ref;
Value : in Integer);
-- Get the ticket priority.
function Get_Priority (Object : in Ticket_Ref)
return Integer;
-- Set the ticket status.
procedure Set_Status (Object : in out Ticket_Ref;
Value : in Status_Type);
-- Get the ticket status.
function Get_Status (Object : in Ticket_Ref)
return Status_Type;
-- Set the ticket description.
procedure Set_Description (Object : in out Ticket_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Description (Object : in out Ticket_Ref;
Value : in String);
-- Get the ticket description.
function Get_Description (Object : in Ticket_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Description (Object : in Ticket_Ref)
return String;
-- Set the last ticket update date.
procedure Set_Update_Date (Object : in out Ticket_Ref;
Value : in Ada.Calendar.Time);
-- Get the last ticket update date.
function Get_Update_Date (Object : in Ticket_Ref)
return Ada.Calendar.Time;
-- Set the ticket type.
procedure Set_Kind (Object : in out Ticket_Ref;
Value : in Ticket_Type);
-- Get the ticket type.
function Get_Kind (Object : in Ticket_Ref)
return Ticket_Type;
-- Set the duration to resolve the ticket.
procedure Set_Duration (Object : in out Ticket_Ref;
Value : in Integer);
-- Get the duration to resolve the ticket.
function Get_Duration (Object : in Ticket_Ref)
return Integer;
-- Set the progress percentation (0 .. 100).
procedure Set_Progress (Object : in out Ticket_Ref;
Value : in Integer);
-- Get the progress percentation (0 .. 100).
function Get_Progress (Object : in Ticket_Ref)
return Integer;
--
procedure Set_Project (Object : in out Ticket_Ref;
Value : in Jason.Projects.Models.Project_Ref'Class);
--
function Get_Project (Object : in Ticket_Ref)
return Jason.Projects.Models.Project_Ref'Class;
--
procedure Set_Creator (Object : in out Ticket_Ref;
Value : in AWA.Users.Models.User_Ref'Class);
--
function Get_Creator (Object : in Ticket_Ref)
return AWA.Users.Models.User_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Ticket_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Ticket_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Reload from the database the same object if it was modified.
-- Returns True in `Updated` if the object was reloaded.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Reload (Object : in out Ticket_Ref;
Session : in out ADO.Sessions.Session'Class;
Updated : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Ticket_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Ticket_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Ticket_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Ticket_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
TICKET_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Ticket_Ref);
-- Copy of the object.
procedure Copy (Object : in Ticket_Ref;
Into : in out Ticket_Ref);
package Ticket_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Ticket_Ref,
"=" => "=");
subtype Ticket_Vector is Ticket_Vectors.Vector;
procedure List (Object : in out Ticket_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class);
-- Create an object key for Attribute.
function Attribute_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Attribute from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Attribute_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Attribute : constant Attribute_Ref;
function "=" (Left, Right : Attribute_Ref'Class) return Boolean;
--
procedure Set_Id (Object : in out Attribute_Ref;
Value : in ADO.Identifier);
--
function Get_Id (Object : in Attribute_Ref)
return ADO.Identifier;
--
procedure Set_Value (Object : in out Attribute_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Value (Object : in out Attribute_Ref;
Value : in String);
--
function Get_Value (Object : in Attribute_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Value (Object : in Attribute_Ref)
return String;
--
function Get_Version (Object : in Attribute_Ref)
return Integer;
-- Set the attribute definition.
procedure Set_Definition (Object : in out Attribute_Ref;
Value : in Jason.Projects.Models.Attribute_Definition_Ref'Class);
-- Get the attribute definition.
function Get_Definition (Object : in Attribute_Ref)
return Jason.Projects.Models.Attribute_Definition_Ref'Class;
--
procedure Set_Ticket (Object : in out Attribute_Ref;
Value : in Ticket_Ref'Class);
--
function Get_Ticket (Object : in Attribute_Ref)
return Ticket_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Attribute_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Attribute_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Reload from the database the same object if it was modified.
-- Returns True in `Updated` if the object was reloaded.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Reload (Object : in out Attribute_Ref;
Session : in out ADO.Sessions.Session'Class;
Updated : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Attribute_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Attribute_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Attribute_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Attribute_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
ATTRIBUTE_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Attribute_Ref);
-- Copy of the object.
procedure Copy (Object : in Attribute_Ref;
Into : in out Attribute_Ref);
package Attribute_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Attribute_Ref,
"=" => "=");
subtype Attribute_Vector is Attribute_Vectors.Vector;
procedure List (Object : in out Attribute_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class);
Query_Stats : constant ADO.Queries.Query_Definition_Access;
-- --------------------
-- The list of tickets.
-- --------------------
type List_Info is
new Util.Beans.Basic.Bean with record
-- the ticket identifier.
Id : ADO.Identifier;
-- the ticket ident number.
Ident : Integer;
-- the ticket summary.
Summary : Ada.Strings.Unbounded.Unbounded_String;
-- the ticket priority.
Priority : Integer;
-- the ticket creation date.
Create_Date : Ada.Calendar.Time;
-- the ticket modification date.
Update_Date : Ada.Calendar.Time;
-- the ticket status.
Status : Status_Type;
-- the ticket type.
Kind : Ticket_Type;
-- the ticket duration.
Duration : Integer;
-- the ticket progress.
Progress : Integer;
-- the ticket creator's name.
Creator : Ada.Strings.Unbounded.Unbounded_String;
end record;
-- Get the bean attribute identified by the name.
overriding
function Get_Value (From : in List_Info;
Name : in String) return Util.Beans.Objects.Object;
-- Set the bean attribute identified by the name.
overriding
procedure Set_Value (Item : in out List_Info;
Name : in String;
Value : in Util.Beans.Objects.Object);
package List_Info_Beans is
new Util.Beans.Basic.Lists (Element_Type => List_Info);
package List_Info_Vectors renames List_Info_Beans.Vectors;
subtype List_Info_List_Bean is List_Info_Beans.List_Bean;
type List_Info_List_Bean_Access is access all List_Info_List_Bean;
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
procedure List (Object : in out List_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class);
subtype List_Info_Vector is List_Info_Vectors.Vector;
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
procedure List (Object : in out List_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class);
Query_List : constant ADO.Queries.Query_Definition_Access;
Query_List_Tag_Filter : constant ADO.Queries.Query_Definition_Access;
-- --------------------
-- The ticket information.
-- --------------------
type Ticket_Info is abstract
new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record
-- the ticket identifier.
Id : ADO.Identifier;
-- the ticket ident number.
Ident : Integer;
-- the ticket summary.
Summary : Ada.Strings.Unbounded.Unbounded_String;
-- the ticket description.
Description : Ada.Strings.Unbounded.Unbounded_String;
-- the ticket priority.
Priority : Integer;
-- the ticket creation date.
Create_Date : Ada.Calendar.Time;
-- the ticket modification date.
Update_Date : Ada.Calendar.Time;
-- the ticket status.
Status : Status_Type;
-- the project identifier.
Project_Id : ADO.Identifier;
-- the project name.
Project_Name : Ada.Strings.Unbounded.Unbounded_String;
-- the ticket creator's name.
Creator : Ada.Strings.Unbounded.Unbounded_String;
end record;
-- This bean provides some methods that can be used in a Method_Expression.
overriding
function Get_Method_Bindings (From : in Ticket_Info)
return Util.Beans.Methods.Method_Binding_Array_Access;
-- Get the bean attribute identified by the name.
overriding
function Get_Value (From : in Ticket_Info;
Name : in String) return Util.Beans.Objects.Object;
-- Set the bean attribute identified by the name.
overriding
procedure Set_Value (Item : in out Ticket_Info;
Name : in String;
Value : in Util.Beans.Objects.Object);
procedure Load (Bean : in out Ticket_Info;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract;
-- Read in the object the data from the query result and prepare to read the next row.
-- If there is no row, raise the ADO.NOT_FOUND exception.
procedure Read (Into : in out Ticket_Info;
Stmt : in out ADO.Statements.Query_Statement'Class);
-- Run the query controlled by <b>Context</b> and load the result in <b>Object</b>.
procedure Load (Object : in out Ticket_Info'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class);
Query_Info : constant ADO.Queries.Query_Definition_Access;
-- --------------------
-- save the ticket status, priority, ticket_type with the associated comment.
-- --------------------
type Ticket_Bean is abstract new Jason.Tickets.Models.Ticket_Ref
and Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record
-- the comment associated with the save operation.
Comment : Ada.Strings.Unbounded.Unbounded_String;
end record;
-- This bean provides some methods that can be used in a Method_Expression.
overriding
function Get_Method_Bindings (From : in Ticket_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access;
-- Get the bean attribute identified by the name.
overriding
function Get_Value (From : in Ticket_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the bean attribute identified by the name.
overriding
procedure Set_Value (Item : in out Ticket_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
procedure Load (Bean : in out Ticket_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract;
procedure Create (Bean : in out Ticket_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract;
procedure Save (Bean : in out Ticket_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract;
procedure Save_Status (Bean : in out Ticket_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract;
type Ticket_List_Bean is abstract limited
new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record
Project_Id : ADO.Identifier;
-- the page number.
Page : Integer;
-- the number of tickets found.
Count : Integer;
-- the tag filter.
Tag : Ada.Strings.Unbounded.Unbounded_String;
-- the number of tickets per page.
Page_Size : Integer;
-- the list sort order.
Sort : Ada.Strings.Unbounded.Unbounded_String;
-- the ticket status filter.
Status : Status_Type;
-- the ticket priority filter.
Priority : Integer;
-- the ticket type
Ticket_Kind : Ticket_Type;
end record;
-- This bean provides some methods that can be used in a Method_Expression.
overriding
function Get_Method_Bindings (From : in Ticket_List_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access;
-- Get the bean attribute identified by the name.
overriding
function Get_Value (From : in Ticket_List_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the bean attribute identified by the name.
overriding
procedure Set_Value (Item : in out Ticket_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
procedure Load (Bean : in out Ticket_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract;
type Ticket_Info_Bean is abstract limited
new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record
Ticket_Id : ADO.Identifier;
end record;
-- This bean provides some methods that can be used in a Method_Expression.
overriding
function Get_Method_Bindings (From : in Ticket_Info_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access;
-- Get the bean attribute identified by the name.
overriding
function Get_Value (From : in Ticket_Info_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the bean attribute identified by the name.
overriding
procedure Set_Value (Item : in out Ticket_Info_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
procedure Load (Bean : in out Ticket_Info_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract;
type Stat_Bean is
new Util.Beans.Basic.Bean with record
-- the ticket type.
Kind : Ticket_Type;
-- the ticket priority.
Priority : Integer;
-- the number of tickets.
Count : Integer;
-- the sum of duration for the tickets.
Time : Integer;
-- remain duration.
Remain : Integer;
Done : Integer;
end record;
-- Get the bean attribute identified by the name.
overriding
function Get_Value (From : in Stat_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the bean attribute identified by the name.
overriding
procedure Set_Value (Item : in out Stat_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
type Report_Bean is abstract
new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with null record;
-- This bean provides some methods that can be used in a Method_Expression.
overriding
function Get_Method_Bindings (From : in Report_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access;
-- Get the bean attribute identified by the name.
overriding
function Get_Value (From : in Report_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the bean attribute identified by the name.
overriding
procedure Set_Value (Item : in out Report_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
procedure Load (Bean : in out Report_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is abstract;
private
TICKET_NAME : aliased constant String := "jason_ticket";
COL_0_1_NAME : aliased constant String := "id";
COL_1_1_NAME : aliased constant String := "version";
COL_2_1_NAME : aliased constant String := "summary";
COL_3_1_NAME : aliased constant String := "ident";
COL_4_1_NAME : aliased constant String := "create_date";
COL_5_1_NAME : aliased constant String := "priority";
COL_6_1_NAME : aliased constant String := "status";
COL_7_1_NAME : aliased constant String := "description";
COL_8_1_NAME : aliased constant String := "update_date";
COL_9_1_NAME : aliased constant String := "kind";
COL_10_1_NAME : aliased constant String := "duration";
COL_11_1_NAME : aliased constant String := "progress";
COL_12_1_NAME : aliased constant String := "project_id";
COL_13_1_NAME : aliased constant String := "creator_id";
TICKET_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 14,
Table => TICKET_NAME'Access,
Members => (
1 => COL_0_1_NAME'Access,
2 => COL_1_1_NAME'Access,
3 => COL_2_1_NAME'Access,
4 => COL_3_1_NAME'Access,
5 => COL_4_1_NAME'Access,
6 => COL_5_1_NAME'Access,
7 => COL_6_1_NAME'Access,
8 => COL_7_1_NAME'Access,
9 => COL_8_1_NAME'Access,
10 => COL_9_1_NAME'Access,
11 => COL_10_1_NAME'Access,
12 => COL_11_1_NAME'Access,
13 => COL_12_1_NAME'Access,
14 => COL_13_1_NAME'Access)
);
TICKET_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= TICKET_DEF'Access;
Null_Ticket : constant Ticket_Ref
:= Ticket_Ref'(ADO.Objects.Object_Ref with null record);
type Ticket_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => TICKET_DEF'Access)
with record
Version : Integer;
Summary : Ada.Strings.Unbounded.Unbounded_String;
Ident : Integer;
Create_Date : Ada.Calendar.Time;
Priority : Integer;
Status : Status_Type;
Description : Ada.Strings.Unbounded.Unbounded_String;
Update_Date : Ada.Calendar.Time;
Kind : Ticket_Type;
Duration : Integer;
Progress : Integer;
Project : Jason.Projects.Models.Project_Ref;
Creator : AWA.Users.Models.User_Ref;
end record;
type Ticket_Access is access all Ticket_Impl;
overriding
procedure Destroy (Object : access Ticket_Impl);
overriding
procedure Find (Object : in out Ticket_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Ticket_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Ticket_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Ticket_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Create (Object : in out Ticket_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Ticket_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Ticket_Ref'Class;
Impl : out Ticket_Access);
ATTRIBUTE_NAME : aliased constant String := "jason_attribute";
COL_0_2_NAME : aliased constant String := "id";
COL_1_2_NAME : aliased constant String := "value";
COL_2_2_NAME : aliased constant String := "version";
COL_3_2_NAME : aliased constant String := "definition_id";
COL_4_2_NAME : aliased constant String := "ticket_id";
ATTRIBUTE_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 5,
Table => ATTRIBUTE_NAME'Access,
Members => (
1 => COL_0_2_NAME'Access,
2 => COL_1_2_NAME'Access,
3 => COL_2_2_NAME'Access,
4 => COL_3_2_NAME'Access,
5 => COL_4_2_NAME'Access)
);
ATTRIBUTE_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= ATTRIBUTE_DEF'Access;
Null_Attribute : constant Attribute_Ref
:= Attribute_Ref'(ADO.Objects.Object_Ref with null record);
type Attribute_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => ATTRIBUTE_DEF'Access)
with record
Value : Ada.Strings.Unbounded.Unbounded_String;
Version : Integer;
Definition : Jason.Projects.Models.Attribute_Definition_Ref;
Ticket : Ticket_Ref;
end record;
type Attribute_Access is access all Attribute_Impl;
overriding
procedure Destroy (Object : access Attribute_Impl);
overriding
procedure Find (Object : in out Attribute_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Attribute_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Attribute_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Attribute_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Create (Object : in out Attribute_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Attribute_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Attribute_Ref'Class;
Impl : out Attribute_Access);
package File_1 is
new ADO.Queries.Loaders.File (Path => "tickets-stat.xml",
Sha1 => "9B2B599473F75F92CB5AB5045675E4CCEF926543");
package Def_Stats is
new ADO.Queries.Loaders.Query (Name => "stats",
File => File_1.File'Access);
Query_Stats : constant ADO.Queries.Query_Definition_Access
:= Def_Stats.Query'Access;
package File_2 is
new ADO.Queries.Loaders.File (Path => "tickets-list.xml",
Sha1 => "663F7ABF74B371A1CF27EB0908984D62AE9D34D1");
package Def_Listinfo_List is
new ADO.Queries.Loaders.Query (Name => "list",
File => File_2.File'Access);
Query_List : constant ADO.Queries.Query_Definition_Access
:= Def_Listinfo_List.Query'Access;
package Def_Listinfo_List_Tag_Filter is
new ADO.Queries.Loaders.Query (Name => "list-tag-filter",
File => File_2.File'Access);
Query_List_Tag_Filter : constant ADO.Queries.Query_Definition_Access
:= Def_Listinfo_List_Tag_Filter.Query'Access;
package File_3 is
new ADO.Queries.Loaders.File (Path => "ticket-info.xml",
Sha1 => "D5C042D77C9A68858F200A871CDDD130F6E8262D");
package Def_Ticketinfo_Info is
new ADO.Queries.Loaders.Query (Name => "info",
File => File_3.File'Access);
Query_Info : constant ADO.Queries.Query_Definition_Access
:= Def_Ticketinfo_Info.Query'Access;
end Jason.Tickets.Models;
|
osannolik/ada-canopen | Ada | 2,316 | adb | package body ACO.Protocols.Network_Management.Masters is
procedure Request_State
(This : in out Master;
State : in ACO.States.State)
is
Cmd : NMT_Commands.NMT_Command;
begin
This.Set (State);
Cmd := (As_Raw => False,
Command_Specifier => NMT_Commands.To_CMD_Spec (State),
Node_Id => This.Id);
This.Handler.Put (NMT_Commands.To_Msg (Cmd));
end Request_State;
procedure Set_Heartbeat_Timeout
(This : in out Master;
Timeout : in Natural)
is
begin
This.Timeout_Ms := Timeout;
This.T_Heartbeat_Update := Ada.Real_Time.Time_Last;
end Set_Heartbeat_Timeout;
procedure Periodic_Actions
(This : in out Master;
T_Now : in Ada.Real_Time.Time)
is
use Ada.Real_Time;
use ACO.States;
begin
case This.Get is
when Initializing | Pre_Operational | Operational | Stopped =>
if This.Timeout_Ms > 0 and then
T_Now >= This.T_Heartbeat_Update + Milliseconds (This.Timeout_Ms)
then
This.Set (Unknown_State);
This.Od.Events.Node_Events.Put
((Event => ACO.Events.Heartbeat_Timed_Out,
Node_Id => This.Id));
end if;
when Unknown_State =>
null;
end case;
end Periodic_Actions;
overriding
procedure On_Event
(This : in out Heartbeat_Subscriber;
Data : in ACO.Events.Event_Data)
is
begin
-- TODO: Should really use timestamp of CAN message instead since this
-- event probably is delayed from the time of reception.
This.Ref.T_Heartbeat_Update := This.Ref.Handler.Current_Time;
This.Ref.Set (Data.Received_Heartbeat.State);
end On_Event;
overriding
procedure Initialize
(This : in out Master)
is
begin
NMT (This).Initialize;
This.Od.Events.Node_Events.Attach
(This.Heartbeat_Update'Unchecked_Access);
end Initialize;
overriding
procedure Finalize
(This : in out Master)
is
begin
NMT (This).Finalize;
This.Od.Events.Node_Events.Detach
(This.Heartbeat_Update'Unchecked_Access);
end Finalize;
end ACO.Protocols.Network_Management.Masters;
|
reznikmm/matreshka | Ada | 9,330 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision: 1793 $ $Date: 2011-06-11 10:40:44 +0300 (Сб, 11 июн 2011) $
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
package body Matreshka.Internals.SQL_Drivers.Firebird.Records is
procedure Free is
new Ada.Unchecked_Deallocation (Sqlda_Buffer, Sqlda_Buffer_Access);
procedure Free is
new Ada.Unchecked_Deallocation (Fields.Field, Fields.Field_Access);
------------------
-- Clear_Values --
------------------
procedure Clear_Values (Self : in out Sql_Record) is
Field : Fields.Field_Access;
Nullable : Boolean;
begin
for Idx in 1 .. Self.Cnt loop
Field := Self.Fields.Element (Idx);
Nullable := Field.Is_Nullable;
Field.Set_Null (True);
Field.Is_Nullable (Nullable);
end loop;
end Clear_Values;
-----------
-- Count --
-----------
procedure Count (Self : in out Sql_Record; Value : Isc_Field_Index) is
procedure Allocate_Sqlda;
--------------------
-- Allocate_Sqlda --
--------------------
procedure Allocate_Sqlda is
type Isc_Long_Access is access all Isc_Long;
function Convert is
new Ada.Unchecked_Conversion (Isc_Long_Access, Isc_Sqlda_Access);
type Used_Sqlvars is array (1 .. Self.Cnt) of Isc_Sqlvar;
pragma Convention (C, Used_Sqlvars);
Size : constant Positive
:= (Isc_Sqlda'Size - Isc_Sqlvars'Size + Used_Sqlvars'Size)
/ Isc_Long'Size + 1;
Empty_Var : constant Isc_Sqlvar
:= (Sqltype => Isc_Type_Empty,
Sqlscale => 0,
Sqlsubtype => 0,
Sqllen => 0,
Sqldata => Zero,
Sqlind => null,
Sqlname_Length => 0,
Sqlname => (others => Interfaces.C.nul),
Relname_Length => 0,
Relname => (others => Interfaces.C.nul),
Ownname_Length => 0,
Ownname => (others => Interfaces.C.nul),
Aliasname_Length => 0,
Aliasname => (others => Interfaces.C.nul));
Old : Sqlda_Buffer_Access := Self.Sqlda_Buf;
Field : Fields.Field_Access := null;
begin
Self.Sqlda_Buf := new Sqlda_Buffer (1 .. Size);
Self.Sqlda := Convert (Self.Sqlda_Buf (1)'Access);
if Old /= null then
Self.Sqlda_Buf (1 .. Old'Length) := Old (1 .. Old'Length);
Free (Old);
else
Self.Sqlda.Version := Isc_Sqlda_Current_Version;
Self.Sqlda.Sqldaid := (others => Interfaces.C.nul);
Self.Sqlda.Sqldabc := 0;
end if;
for Idx in 1 .. Self.Size loop
Self.Fields.Element (Idx).Sqlvar := Self.Sqlda.Sqlvar (Idx)'Access;
end loop;
for Idx in Self.Size + 1 .. Self.Cnt loop
Self.Sqlda.Sqlvar (Idx) := Empty_Var;
Field := new Fields.Field;
Field.Codec := Self.Codec;
Field.Utf := Self.Utf;
Field.Sqlvar := Self.Sqlda.Sqlvar (Idx)'Access;
Self.Fields.Append (Field);
end loop;
end Allocate_Sqlda;
begin
Self.Cnt := Value;
if Self.Cnt > 0 then
if Self.Cnt > Self.Size then
Allocate_Sqlda;
Self.Size := Self.Cnt;
end if;
Self.Sqlda.Sqld := Self.Cnt;
Self.Sqlda.Sqln := Self.Cnt;
else
Self.Free_Fields;
Free (Self.Sqlda_Buf);
Self.Sqlda := null;
Self.Size := 0;
end if;
end Count;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Self : in out Sql_Record) is
begin
Self.Free_Fields;
Free (Self.Sqlda_Buf);
end Finalize;
-----------------
-- Free_Fields --
-----------------
procedure Free_Fields (Self : in out Sql_Record) is
Field : Fields.Field_Access;
begin
while not Self.Fields.Is_Empty loop
Field := Self.Fields.First_Element;
Self.Fields.Delete_First;
Free (Field);
end loop;
end Free_Fields;
----------
-- Init --
----------
procedure Init (Self : in out Sql_Record) is
use type Isc_Short;
Field : Fields.Field_Access;
begin
if Self.Sqlda = null then
return;
end if;
for Idx in 1 .. Self.Cnt loop
Field := Self.Fields.Element (Idx);
Field.Srv_Sql_Type := Field.Sqlvar.Sqltype;
Field.Srv_Sql_Len := Field.Sqlvar.Sqllen;
Field.Srv_Sql_Scale := Field.Sqlvar.Sqlscale;
Field.Srv_Sql_Subtype := Field.Sqlvar.Sqlsubtype;
if Field.Srv_Sql_Type = Isc_Type_Text then
if Field.Sqlvar.Sqllen = 0 then
Field.Reserv_Sqldata (1);
else
Field.Adjust_Sqldata;
end if;
elsif Field.Srv_Sql_Type = Isc_Type_Date
or else Field.Srv_Sql_Type = Isc_Type_Time
or else Field.Srv_Sql_Type = Isc_Type_Timestamp
or else Field.Srv_Sql_Type = Isc_Type_Blob
or else Field.Srv_Sql_Type = Isc_Type_Array
or else Field.Srv_Sql_Type = Isc_Type_Quad
or else Field.Srv_Sql_Type = Isc_Type_Short
or else Field.Srv_Sql_Type = Isc_Type_Long
or else Field.Srv_Sql_Type = Isc_Type_Int64
or else Field.Srv_Sql_Type = Isc_Type_Double
or else Field.Srv_Sql_Type = Isc_Type_Float
or else Field.Srv_Sql_Type = Isc_Type_D_Float
or else Field.Srv_Sql_Type = Isc_Type_Boolean
then
Field.Adjust_Sqldata;
elsif Field.Srv_Sql_Type = Isc_Type_Varying then
Field.Reserv_Sqldata (Field.Sqlvar.Sqllen + 2);
end if;
Field.Adjust_Sqlind;
end loop;
end Init;
end Matreshka.Internals.SQL_Drivers.Firebird.Records;
|
AdaCore/libadalang | Ada | 110 | adb | -- This is the only leading comment
procedure One_Leading_Comment is
begin
null;
end One_Leading_Comment;
|
guillaume-lin/tsc | Ada | 8,117 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Keyboard_Handler --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control
-- $Revision: 1.9 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels;
with Terminal_Interface.Curses.Forms; use Terminal_Interface.Curses.Forms;
with Terminal_Interface.Curses.Forms.Field_Types.Enumeration;
use Terminal_Interface.Curses.Forms.Field_Types.Enumeration;
with Sample.Header_Handler; use Sample.Header_Handler;
with Sample.Form_Demo.Aux; use Sample.Form_Demo.Aux;
with Sample.Manifest; use Sample.Manifest;
with Sample.Form_Demo.Handler;
-- This package contains a centralized keyboard handler used throughout
-- this example. The handler establishes a timeout mechanism that provides
-- periodical updates of the common header lines used in this example.
--
package body Sample.Keyboard_Handler is
In_Command : Boolean := False;
function Get_Key (Win : Window := Standard_Window) return Real_Key_Code
is
K : Real_Key_Code;
function Command return Real_Key_Code;
function Command return Real_Key_Code
is
function My_Driver (F : Form;
C : Key_Code;
P : Panel) return Boolean;
package Fh is new Sample.Form_Demo.Handler (My_Driver);
type Label_Array is array (Label_Number) of String (1 .. 8);
Labels : Label_Array;
FA : Field_Array_Access := new Field_Array'
(Make (0, 0, "Command:"),
Make (Top => 0, Left => 9, Width => Columns - 11),
Null_Field);
K : Real_Key_Code := Key_None;
N : Natural := 0;
function My_Driver (F : Form;
C : Key_Code;
P : Panel) return Boolean
is
Ch : Character;
begin
if C in User_Key_Code'Range and then C = QUIT then
if Driver (F, F_Validate_Field) = Form_Ok then
K := Key_None;
return True;
end if;
elsif C in Normal_Key_Code'Range then
Ch := Character'Val (C);
if (Ch = LF or else Ch = CR) then
if Driver (F, F_Validate_Field) = Form_Ok then
declare
Buffer : String (1 .. Positive (Columns - 11));
Cmdc : String (1 .. 8);
begin
Get_Buffer (Fld => FA (2), Str => Buffer);
Trim (Buffer, Left);
if Buffer (1) /= ' ' then
Cmdc := To_Upper (Buffer (Cmdc'Range));
for I in Labels'Range loop
if Cmdc = Labels (I) then
K := Function_Key_Code
(Function_Key_Number (I));
exit;
end if;
end loop;
end if;
return True;
end;
end if;
end if;
end if;
return False;
end My_Driver;
begin
In_Command := True;
for I in Label_Number'Range loop
Get_Soft_Label_Key (I, Labels (I));
Trim (Labels (I), Left);
Translate (Labels (I), Upper_Case_Map);
if Labels (I) (1) /= ' ' then
N := N + 1;
end if;
end loop;
if N > 0 then -- some labels were really set
declare
Enum_Info : Enumeration_Info (N);
Enum_Field : Enumeration_Field;
J : Positive := Enum_Info.Names'First;
Frm : Form := Create (FA);
begin
for I in Label_Number'Range loop
if Labels (I) (1) /= ' ' then
Enum_Info.Names (J) := new String'(Labels (I));
J := J + 1;
end if;
end loop;
Enum_Field := Create (Enum_Info, True);
Set_Field_Type (FA (2), Enum_Field);
Set_Background (FA (2), Normal_Video);
Fh.Drive_Me (Frm, Lines - 3, 0);
Delete (Frm);
Update_Panels; Update_Screen;
end;
end if;
Free (FA, True);
In_Command := False;
return K;
end Command;
begin
Set_Timeout_Mode (Win, Delayed, 30000);
loop
K := Get_Keystroke (Win);
if K = Key_None then -- a timeout occured
Update_Header_Window;
elsif K = 3 and then not In_Command then -- CTRL-C
K := Command;
exit when K /= Key_None;
else
exit;
end if;
end loop;
return K;
end Get_Key;
procedure Init_Keyboard_Handler is
begin
null;
end Init_Keyboard_Handler;
end Sample.Keyboard_Handler;
|
onox/orka | Ada | 1,941 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2021 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Orka.SIMD.SSE2.Integers;
package Orka.SIMD.SSSE3.Integers.Arithmetic is
pragma Pure;
use SIMD.SSE2.Integers;
function "abs" (Elements : m128i) return m128i
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_pabsd128";
function Horizontal_Add (Left, Right : m128i) return m128i
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_phaddd128";
-- Compute the sums of adjacent 32-bit integers in Left and Right
--
-- The two sums (four elements gives two pairs) of elements from Left
-- are stored in the two integers in the lower half, sums from Right in
-- the upper half.
function Horizontal_Subtract (Left, Right : m128i) return m128i
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_phsubd128";
-- Compute the differences of adjacent 32-bit integers in Left and Right
--
-- The two differences (four elements gives two pairs) of elements
-- from Left are stored in the two integers in the lower half, differences
-- from Right in the upper half.
function Negate_Sign (Elements, Signs : m128i) return m128i
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psignd128";
end Orka.SIMD.SSSE3.Integers.Arithmetic;
|
reznikmm/matreshka | Ada | 4,704 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Style.Diagonal_Bl_Tr_Widths_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Diagonal_Bl_Tr_Widths_Attribute_Node is
begin
return Self : Style_Diagonal_Bl_Tr_Widths_Attribute_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Diagonal_Bl_Tr_Widths_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Diagonal_Bl_Tr_Widths_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Diagonal_Bl_Tr_Widths_Attribute,
Style_Diagonal_Bl_Tr_Widths_Attribute_Node'Tag);
end Matreshka.ODF_Style.Diagonal_Bl_Tr_Widths_Attributes;
|
reznikmm/matreshka | Ada | 3,714 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Number_Position_Attributes is
pragma Preelaborate;
type ODF_Number_Position_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Number_Position_Attribute_Access is
access all ODF_Number_Position_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Number_Position_Attributes;
|
ecalderini/bingada | Ada | 1,131 | adb | --*****************************************************************************
--*
--* PROJECT: Bingada
--*
--* FILE: q_bingo-q_gtk-q_intl.adb
--*
--* AUTHOR: Javier Fuica Fernandez
--*
--*****************************************************************************
with GTKADA.INTL;
with TEXT_IO;
package body Q_BINGO.Q_GTK.Q_INTL is
--==================================================================
--C_PATH : CONSTANT STRING := "/usr/local/share/locale";
procedure P_INITIALISE is
begin
if GTKADA.INTL.GETLOCALE = "C" then
GTKADA.INTL.SETLOCALE
(CATEGORY => GTKADA.INTL.LC_MESSAGES,LOCALE => "en_GB");
TEXT_IO.PUT_LINE ("DEFAULT LOCALE changed to : " & GTKADA.INTL.GETLOCALE);
else
GTKADA.INTL.SETLOCALE;
end if;
GTKADA.INTL.BIND_TEXT_DOMAIN
(DOMAIN => "bingada",
DIRNAME => "./messages");
GTKADA.INTL.TEXT_DOMAIN ("bingada");
end P_INITIALISE;
--==================================================================
end Q_BINGO.Q_GTK.Q_INTL;
|
Statkus/json-ada | Ada | 1,505 | ads | -- Copyright (c) 2018 RREE <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ahven.Framework;
package Test_Images is
type Test is new Ahven.Framework.Test_Case with null record;
overriding
procedure Initialize (T : in out Test);
private
-- Keyword
procedure Test_True_Text;
procedure Test_False_Text;
procedure Test_Null_Text;
procedure Test_Escaped_Text;
-- String
procedure Test_Empty_String_Text;
procedure Test_Non_Empty_String_Text;
procedure Test_Number_String_Text;
-- Integer number
procedure Test_Integer_Number_Text;
-- Array
procedure Test_Empty_Array_Text;
procedure Test_One_Element_Array_Text;
procedure Test_Multiple_Elements_Array_Text;
-- Object
procedure Test_Empty_Object_Text;
procedure Test_One_Member_Object_Text;
procedure Test_Multiple_Members_Object_Text;
procedure Test_Array_Object_Array;
procedure Test_Object_Array_Object;
end Test_Images;
|
skordal/ada-regex | Ada | 5,536 | adb | -- Ada regular expression library
-- (c) Kristian Klomsten Skordal 2020 <[email protected]>
-- Report bugs and issues on <https://github.com/skordal/ada-regex>
with Ada.Text_IO;
package body Regex.Debug is
procedure Print_Syntax_Tree (Root : in Regex.Syntax_Trees.Syntax_Tree_Node_Access) is
use Ada.Text_IO;
use Regex.Syntax_Trees;
-- Helper functions:
procedure Print_Set (Set : in Syntax_Tree_Node_Sets.Sorted_Set);
procedure Print_Node_Recursively (Node : in Syntax_Tree_Node_Access; Indentation : Natural);
procedure Print_Set (Set : in Syntax_Tree_Node_Sets.Sorted_Set) is
begin
Put ("{ ");
for Element of Set loop
Put (Natural'Image (Element.Id) & ", ");
end loop;
Put ("}");
end Print_Set;
procedure Print_Node_Recursively (Node : in Syntax_Tree_Node_Access; Indentation : Natural) is
begin
for I in 0 .. Indentation loop
Put (' ');
end loop;
Put ("node " & Natural'Image (Node.Id) & ": ");
case Node.Node_Type is
when Acceptance =>
Put_Line ("accept");
when Single_Character =>
Put ("character " & Character'Image (Node.Char)
& ", nullable = " & Boolean'Image (Nullable (Node))
& ", firstpos = ");
Print_Set (Firstpos (Node));
Put (", lastpos = ");
Print_Set (Lastpos (Node));
Put (", followpos = ");
Print_Set (Node.Followpos);
New_Line;
when Any_Character =>
Put ("any character, nullable = " & Boolean'Image (Nullable (Node))
& ", firstpos = ");
Print_Set (Firstpos (Node));
Put (", lastpos = ");
Print_Set (Lastpos (Node));
Put (", followpos = ");
Print_Set (Node.Followpos);
New_Line;
when Empty_Node =>
Put ("empty node, ε, nullable = " & Boolean'Image (Nullable (Node))
& ", firstpos = ");
Print_Set (Firstpos (Node));
Put (", lastpos = ");
Print_Set (Lastpos (Node));
Put (", followpos = ");
Print_Set (Node.Followpos);
New_Line;
when Alternation =>
Put ("alternation '|', nullable = " & Boolean'Image (Nullable (Node))
& ", firstpos = ");
Print_Set (Firstpos (Node));
Put (", lastpos = ");
Print_Set (Lastpos (Node));
Put (", followpos = ");
Print_Set (Node.Followpos);
New_Line;
Print_Node_Recursively (Node.Left_Child, Indentation + 3);
Print_Node_Recursively (Node.Right_Child, Indentation + 3);
when Concatenation =>
Put ("concatenation, nullable = " & Boolean'Image (Nullable (Node))
& ", firstpos = ");
Print_Set (Firstpos (Node));
Put (", lastpos = ");
Print_Set (Lastpos (Node));
Put (", followpos = ");
Print_Set (Node.Followpos);
New_Line;
Print_Node_Recursively (Node.Left_Child, Indentation + 3);
Print_Node_Recursively (Node.Right_Child, Indentation + 3);
when Kleene_Star =>
Put ("kleene star '*', nullable = " & Boolean'Image (Nullable (Node))
& ", firstpos = ");
Print_Set (Firstpos (Node));
Put (", lastpos = ");
Print_Set (Lastpos (Node));
Put (", followpos = ");
Print_Set (Node.Followpos);
New_Line;
Print_Node_Recursively (Node.Left_Child, Indentation + 3);
end case;
end Print_Node_Recursively;
begin
Put_Line ("Parse tree:");
if Root = null then
Put_Line (" null");
else
Print_Node_Recursively (Root, 3);
end if;
end Print_Syntax_Tree;
procedure Print_State_Machine (States : in Regex.State_Machines.State_Machine_State_Vectors.Vector) is
begin
for State of States loop
Print_State (State.all);
end loop;
end Print_State_Machine;
procedure Print_State (State : in Regex.State_Machines.State_Machine_State) is
use Ada.Text_IO;
use Regex.State_Machines;
begin
Put ("State machine node for {");
for Node of State.Syntax_Tree_Nodes loop
Put (Natural'Image (Node.Id) & ", ");
end loop;
Put_Line ("} (accepting = " & Boolean'Image (State.Accepting) & ")");
for Transition of State.Transitions loop
case Transition.Transition_On.Symbol_Type is
when Single_Character =>
Put (" transition on " & Character'Image (Transition.Transition_On.Char) & " to {");
for Node of Transition.Target_State.Syntax_Tree_Nodes loop
Put (Natural'Image (Node.Id) & ", ");
end loop;
Put_Line ("}");
when Any_Character =>
Put (" transition on any character to {");
for Node of Transition.Target_State.Syntax_Tree_Nodes loop
Put (Natural'Image (Node.Id) & ", ");
end loop;
Put_Line ("}");
end case;
end loop;
end Print_State;
end Regex.Debug;
|
Subsets and Splits