repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
ytomino/yaml-ada | Ada | 107 | adb | with Ada.Text_IO;
with YAML;
procedure version is
begin
Ada.Text_IO.Put_Line (YAML.Version);
end version;
|
redparavoz/ada-wiki | Ada | 18,276 | adb | -----------------------------------------------------------------------
-- wiki-parsers-tests -- Unit tests for wiki parsing
-- Copyright (C) 2011, 2012, 2013, 2015, 2016, 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.Strings.UTF_Encoding.Wide_Wide_Strings;
with Util.Test_Caller;
with Wiki.Utils;
with Wiki.Helpers;
with Wiki.Streams.Builders;
with Wiki.Render.Text;
package body Wiki.Parsers.Tests is
use Wiki.Helpers;
package Caller is new Util.Test_Caller (Test, "Wikis.Parsers");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (bold)",
Test_Wiki_Bold'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (italic)",
Test_Wiki_Italic'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (italic, bold)",
Test_Wiki_Formats'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (headings)",
Test_Wiki_Section'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (lists)",
Test_Wiki_List'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (links)",
Test_Wiki_Link'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (quote)",
Test_Wiki_Quote'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (line break)",
Test_Wiki_Line_Break'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (image)",
Test_Wiki_Image'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (preformatted)",
Test_Wiki_Preformatted'Access);
Caller.Add_Test (Suite, "Test Wiki.Text.Renderer",
Test_Wiki_Text_Renderer'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (String UTF-8)",
Test_Wiki_UTF_8'Access);
end Add_Tests;
-- ------------------------------
-- Test bold rendering.
-- ------------------------------
procedure Test_Wiki_Bold (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><b>bold</b></p>",
Wiki.Utils.To_Html ("*bold*", SYNTAX_GOOGLE),
"Bold rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <b>bold</b> y</p>",
Wiki.Utils.To_Html ("x *bold* y", SYNTAX_GOOGLE),
"Bold rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <b>bold y</b></p>",
Wiki.Utils.To_Html ("x *bold y", SYNTAX_MIX),
"Bold rendering invalid (MIX)");
Util.Tests.Assert_Equals (T, "<p>x <b>item y</b> p</p>",
Wiki.Utils.To_Html ("x __item y__ p", SYNTAX_DOTCLEAR),
"Bold rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x _item y_ p</p>",
Wiki.Utils.To_Html ("x _item y_ p", SYNTAX_DOTCLEAR),
"No bold rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <b>bold</b> y</p>",
Wiki.Utils.To_Html ("x '''bold''' y", SYNTAX_PHPBB),
"Bold rendering invalid (PHPBB)");
end Test_Wiki_Bold;
-- ------------------------------
-- Test italic rendering.
-- ------------------------------
procedure Test_Wiki_Italic (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><i>item</i></p>",
Wiki.Utils.To_Html ("_item_", SYNTAX_GOOGLE),
"Italic rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <i>item</i> y</p>",
Wiki.Utils.To_Html ("x _item_ y", SYNTAX_GOOGLE),
"Italic rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <i>item y</i></p>",
Wiki.Utils.To_Html ("x _item y", SYNTAX_MIX),
"Italic rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <i>item y</i> p</p>",
Wiki.Utils.To_Html ("x ''item y'' p", SYNTAX_DOTCLEAR),
"Italic rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <i>item y</i> p</p>",
Wiki.Utils.To_Html ("x ''item y'' p", SYNTAX_PHPBB),
"Italic rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x 'item y<i> p</i></p>",
Wiki.Utils.To_Html ("x 'item y'' p", SYNTAX_PHPBB),
"Italic rendering invalid");
end Test_Wiki_Italic;
-- ------------------------------
-- Test various format rendering.
-- ------------------------------
procedure Test_Wiki_Formats (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><i>it</i><b><i>bold</i></b><i>em</i></p>",
Wiki.Utils.To_Html ("_it*bold*em_", SYNTAX_GOOGLE),
"Italic+Bold rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <i>item</i> y</p>",
Wiki.Utils.To_Html ("x _item_ y", SYNTAX_GOOGLE),
"Italic rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <i>item y</i></p>",
Wiki.Utils.To_Html ("x _item y", SYNTAX_GOOGLE),
"Italic rendering invalid");
end Test_Wiki_Formats;
-- ------------------------------
-- Test heading rendering.
-- ------------------------------
procedure Test_Wiki_Section (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<h1>item</h1>",
Wiki.Utils.To_Html ("= item =", SYNTAX_GOOGLE),
"H1 rendering invalid");
Util.Tests.Assert_Equals (T, "<h2>item</h2>",
Wiki.Utils.To_Html ("== item == ", SYNTAX_GOOGLE),
"H2 rendering invalid");
Util.Tests.Assert_Equals (T, "<h3>item</h3>",
Wiki.Utils.To_Html ("=== item === ", SYNTAX_GOOGLE),
"H3 rendering invalid");
Util.Tests.Assert_Equals (T, "<h4>item</h4>",
Wiki.Utils.To_Html ("==== item ==== ", SYNTAX_GOOGLE),
"H4 rendering invalid");
Util.Tests.Assert_Equals (T, "<h5>item</h5>",
Wiki.Utils.To_Html ("===== item =====", SYNTAX_GOOGLE),
"H5 rendering invalid");
Util.Tests.Assert_Equals (T, "<h6>item</h6>",
Wiki.Utils.To_Html ("====== item ===", SYNTAX_GOOGLE),
"H6 rendering invalid");
Util.Tests.Assert_Equals (T, "<h1>item</h1><h2>item2</h2>",
Wiki.Utils.To_Html ("= item =" & CR & "== item2 ==",
SYNTAX_GOOGLE),
"H1 rendering invalid");
Util.Tests.Assert_Equals (T, "<h1>item</h1><h2>item2</h2>",
Wiki.Utils.To_Html ("= item =" & CR & "== item2 ==",
SYNTAX_GOOGLE),
"H1 rendering invalid");
end Test_Wiki_Section;
-- ------------------------------
-- Test list rendering.
-- ------------------------------
procedure Test_Wiki_List (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<ol><li>item</li></ol>",
Wiki.Utils.To_Html ("# item", SYNTAX_GOOGLE),
"Ordered list rendering invalid");
Util.Tests.Assert_Equals (T, "<ol><li>item item " & ASCII.LF &
"</li><li>item2 item2" & ASCII.LF &
"</li><li><ol>item3</li></ol></ol>",
Wiki.Utils.To_Html ("# item item " & LF & "# item2 item2" & LF & "## item3",
SYNTAX_GOOGLE),
"Ordered rendering invalid");
Util.Tests.Assert_Equals (T, "<ul><li>item</li></ul>",
Wiki.Utils.To_Html (" * item", SYNTAX_GOOGLE),
"Bullet list rendering invalid");
Util.Tests.Assert_Equals (T, "<ul><li>item</li></ul>",
Wiki.Utils.To_Html ("* item", SYNTAX_DOTCLEAR),
"Bullet list rendering invalid");
end Test_Wiki_List;
-- ------------------------------
-- Test link rendering.
-- ------------------------------
procedure Test_Wiki_Link (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><a href=""name"">name</a></p>",
Wiki.Utils.To_Html ("[name]", SYNTAX_GOOGLE),
"Link rendering invalid");
Util.Tests.Assert_Equals (T, "<p><a href=""http://www.joe.com/item"" "
& "lang=""en"" title=""some""" &
">name</a></p>",
Wiki.Utils.To_Html ("[name |http://www.joe.com/item|en|some]",
SYNTAX_DOTCLEAR),
"Link rendering invalid");
Util.Tests.Assert_Equals (T, "<p><a href=""name"">name</a></p>",
Wiki.Utils.To_Html ("[[name]]", SYNTAX_CREOLE),
"Link rendering invalid");
Util.Tests.Assert_Equals (T, "<p>[d</p>",
Wiki.Utils.To_Html ("[d", SYNTAX_CREOLE),
"No link rendering invalid");
Util.Tests.Assert_Equals (T, "<p><a " &
"href=""http://www.joe.com/item"">http://www.joe.com/item</a></p>",
Wiki.Utils.To_Html ("[http://www.joe.com/item]",
SYNTAX_DOTCLEAR),
"Link rendering invalid");
Util.Tests.Assert_Equals (T, "<p><a href=""name"">name</a></p>",
Wiki.Utils.To_Html ("[[name]]", SYNTAX_MEDIA_WIKI),
"Link rendering invalid");
end Test_Wiki_Link;
-- ------------------------------
-- Test quote rendering.
-- ------------------------------
procedure Test_Wiki_Quote (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><q>quote</q></p>",
Wiki.Utils.To_Html ("{{quote}}", SYNTAX_DOTCLEAR),
"Quote rendering invalid");
Util.Tests.Assert_Equals (T, "<p><q lang=""en"">quote</q></p>",
Wiki.Utils.To_Html ("{{quote|en}}", SYNTAX_DOTCLEAR),
"Quote rendering invalid");
Util.Tests.Assert_Equals (T, "<p><q cite=""http://www.sun.com"" lang=""en"">quote</q></p>",
Wiki.Utils.To_Html ("{{quote|en|http://www.sun.com}}",
SYNTAX_DOTCLEAR),
"Quote rendering invalid");
Util.Tests.Assert_Equals (T, "<p>{quote}}</p>",
Wiki.Utils.To_Html ("{quote}}", SYNTAX_DOTCLEAR),
"No quote rendering invalid");
end Test_Wiki_Quote;
-- ------------------------------
-- Test line break rendering.
-- ------------------------------
procedure Test_Wiki_Line_Break (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p>a<br />b</p>",
Wiki.Utils.To_Html ("a%%%b", SYNTAX_DOTCLEAR),
"Line break rendering invalid");
Util.Tests.Assert_Equals (T, "<p>a<br />b</p>",
Wiki.Utils.To_Html ("a\\b", SYNTAX_CREOLE),
"Line break rendering invalid");
Util.Tests.Assert_Equals (T, "<p>a%%b</p>",
Wiki.Utils.To_Html ("a%%b", SYNTAX_DOTCLEAR),
"No line break rendering invalid");
Util.Tests.Assert_Equals (T, "<p>a%b</p>",
Wiki.Utils.To_Html ("a%b", SYNTAX_DOTCLEAR),
"No line break rendering invalid");
end Test_Wiki_Line_Break;
-- ------------------------------
-- Test image rendering.
-- ------------------------------
procedure Test_Wiki_Image (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><img src=""/image/t.png"" /></p>",
Wiki.Utils.To_Html ("((/image/t.png))", SYNTAX_DOTCLEAR),
"Image rendering invalid");
Util.Tests.Assert_Equals (T, "<p><img src=""/image/t.png"" alt=""title"" /></p>",
Wiki.Utils.To_Html ("((/image/t.png|title))", SYNTAX_DOTCLEAR),
"Image rendering invalid");
Util.Tests.Assert_Equals (T, "<p><img " &
"src=""/image/t.png"" longdesc=""describe"" alt=""title"" /></p>",
Wiki.Utils.To_Html ("((/image/t.png|title|x|describe))",
SYNTAX_DOTCLEAR),
"Image rendering invalid");
end Test_Wiki_Image;
-- ------------------------------
-- Test preformatted rendering.
-- ------------------------------
procedure Test_Wiki_Preformatted (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><tt>code</tt></p>",
Wiki.Utils.To_Html ("{{{code}}}", SYNTAX_GOOGLE),
"Preformat rendering invalid");
Util.Tests.Assert_Equals (T, "<pre>* code *" & ASCII.LF & "</pre>",
Wiki.Utils.To_Html ("///" & LF & "* code *" & LF & "///",
SYNTAX_DOTCLEAR),
"Preformat rendering invalid");
Util.Tests.Assert_Equals (T, "<pre>item1 x" & ASCII.LF & "item2 x" & ASCII.LF & "item3 x"
& ASCII.LF & "</pre>",
Wiki.Utils.To_Html (" item1 x" & LF & " item2 x" & LF & " item3 x",
SYNTAX_DOTCLEAR),
"Preformat rendering invalid");
Util.Tests.Assert_Equals (T, "<pre>item1 x" & ASCII.LF & "item2 x"
& ASCII.LF & "item3 x"
& ASCII.LF & "</pre>",
Wiki.Utils.To_Html (" item1 x" & CR & LF & " item2 x"
& CR & LF & " item3 x",
SYNTAX_DOTCLEAR),
"Preformat rendering invalid");
end Test_Wiki_Preformatted;
-- ------------------------------
-- Test the text renderer.
-- ------------------------------
procedure Test_Wiki_Text_Renderer (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, ASCII.LF & "code",
Wiki.Utils.To_Text ("{{{code}}}", SYNTAX_GOOGLE),
"Preformat rendering invalid");
Util.Tests.Assert_Equals (T, ASCII.LF & "bold item my_title" & ASCII.LF,
Wiki.Utils.To_Text ("_bold_ __item__ [my_title]", SYNTAX_GOOGLE),
"Preformat rendering invalid");
end Test_Wiki_Text_Renderer;
-- ------------------------------
-- Test the string parser with UTF-8 support.
-- ------------------------------
procedure Test_Wiki_UTF_8 (T : in out Test) is
procedure Check (Text : in Wiki.Strings.WString);
Test_Chars : constant array (Natural range <>) of Wiki.Strings.WChar
:= (Wiki.Strings.WChar'Val (16#7f#),
Wiki.Strings.WChar'Val (16#80#),
Wiki.Strings.WChar'Val (16#AE#),
Wiki.Strings.WChar'Val (16#1ff#),
Wiki.Strings.WChar'Val (16#1fff#),
Wiki.Strings.WChar'Val (16#1ffff#),
Wiki.Strings.WChar'Val (16#0fffff#));
procedure Check (Text : in Wiki.Strings.WString) is
procedure Get (Value : in Wiki.Strings.WString);
Doc : Wiki.Documents.Document;
Engine : Wiki.Parsers.Parser;
Renderer : aliased Wiki.Render.Text.Text_Renderer;
Stream : aliased Wiki.Streams.Builders.Output_Builder_Stream;
Content : constant String :=
Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Encode (Text);
procedure Get (Value : in Wiki.Strings.WString) is
begin
-- Verify that we got the expected characters.
T.Assert (Wiki.Helpers.LF & Text = Value, "Invalid parsing for [" & Content & "]");
end Get;
begin
Engine.Set_Syntax (SYNTAX_MEDIA_WIKI);
Engine.Parse (Content, Doc);
Renderer.Set_Output_Stream (Stream'Unchecked_Access);
Renderer.Render (Doc);
Stream.Iterate (Get'Access);
end Check;
begin
for I in Test_Chars'Range loop
Check (Test_Chars (I) & "");
end loop;
for J in Test_Chars'Range loop
for I in Test_Chars'Range loop
Check (Test_Chars (I) & Test_Chars (J) & "");
end loop;
end loop;
end Test_Wiki_UTF_8;
end Wiki.Parsers.Tests;
|
reznikmm/matreshka | Ada | 4,205 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2016-2020, 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 WebAPI.UI_Events.Mouse;
package WUI.Events.Mouse is
pragma Preelaborate;
type Mouse_Button is
(Button_1,
Button_2,
Button_3);
-- type Mouse_Buttons is array (Mouse_Button) of Boolean;
type Abstract_Mouse_Event is
abstract new WUI.Events.Abstract_Event with private;
-- function Buttons
-- (Self : Abstract_Mouse_Event'Class) return Mouse_Buttons;
function X (Self : Abstract_Mouse_Event'Class) return Long_Float;
function Y (Self : Abstract_Mouse_Event'Class) return Long_Float;
package Constructors is
procedure Initialize
(Self : in out Abstract_Mouse_Event'Class;
Event : not null access WebAPI.UI_Events.Mouse.Mouse_Event'Class);
end Constructors;
private
type Abstract_Mouse_Event is
abstract new WUI.Events.Abstract_Event with null record;
end WUI.Events.Mouse;
|
1Crazymoney/LearnAda | Ada | 353 | ads | package Garden_Pkg is
subtype Position is Positive range 1..10;
function GetRandPos return Position;
function GetField(pos : Position) return Boolean;
procedure SprayField(pos : Position);
procedure SprayAbsorbed;
private
type Fields is array(Integer range <>) of Boolean;
Garden : Fields(1..10) := (1..10 => false);
end Garden_Pkg;
|
reznikmm/matreshka | Ada | 3,724 | 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.Style_Default_Page_Layout_Elements is
pragma Preelaborate;
type ODF_Style_Default_Page_Layout is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Style_Default_Page_Layout_Access is
access all ODF_Style_Default_Page_Layout'Class
with Storage_Size => 0;
end ODF.DOM.Style_Default_Page_Layout_Elements;
|
reznikmm/increment | Ada | 1,072 | ads | -- Copyright (c) 2015-2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Containers.Vectors;
with League.Strings;
with XML.Templates.Streams;
package Tests.Commands is
pragma Preelaborate;
type Command_Kind is
(Commit,
Dump_Tree,
Run,
Set_EOS_Text,
Set_Token_Text);
type Command (Kind : Command_Kind := Commit) is record
case Kind is
when Commit | Run =>
null;
when Set_EOS_Text | Set_Token_Text =>
Text : League.Strings.Universal_String;
case Kind is
when Set_Token_Text =>
Token : Positive;
when others =>
null;
end case;
when Dump_Tree =>
Dump : XML.Templates.Streams.XML_Stream_Element_Vectors.Vector;
end case;
end record;
package Command_Vectors is
new Ada.Containers.Vectors (Positive, Command);
end Tests.Commands;
|
reznikmm/matreshka | Ada | 4,083 | 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.Style_Font_Size_Rel_Asian_Attributes;
package Matreshka.ODF_Style.Font_Size_Rel_Asian_Attributes is
type Style_Font_Size_Rel_Asian_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Font_Size_Rel_Asian_Attributes.ODF_Style_Font_Size_Rel_Asian_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Font_Size_Rel_Asian_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Font_Size_Rel_Asian_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Font_Size_Rel_Asian_Attributes;
|
AdaCore/libadalang | Ada | 1,067 | adb | procedure Test is
A : constant Boolean := True;
B : constant Boolean := False;
procedure Pouet0 is null;
--% node.p_has_aspect('inline')
procedure Pouet1 is null
with Inline;
--% node.p_has_aspect('inline')
procedure Pouet2
with Inline;
procedure Pouet2 is null;
--% node.p_has_aspect('inline')
package Pkg is
procedure Pouet3;
--% node.p_has_aspect('inline')
end Pkg;
package body Pkg is
procedure Pouet3 is null;
pragma Inline (Pouet3);
end Pkg;
generic
procedure Pouet3 with Inline;
--% node.p_has_aspect('inline')
procedure Pouet3 is null;
--% node.p_has_aspect('inline')
package P is
type Vector is private with
Default_Initial_Condition => True;
private
type Vector is null record;
--% node.p_has_aspect("default_initial_condition")
end P;
generic
procedure Pouet4;
--% node.p_has_aspect('inline')
pragma Inline (Pouet4);
procedure Pouet4 is null;
--% node.p_has_aspect('inline')
begin
null;
end Test;
|
iyan22/AprendeAda | Ada | 911 | adb |
with ada.text_io, ada.integer_text_io;
use ada.text_io, ada.integer_text_io;
with ada.text_io, ada.integer_text_io;
use ada.text_io, ada.integer_text_io;
with divisores;
procedure prueba_divisores is
n1, divisor:integer:=0;
begin
-- caso de prueba 1:
n1:=4;
put("El resultado deberia de ser 1 2 4:");
new_line;
put("Y tu programa dice que:");
divisores(n1);
new_line;
-- caso de prueba 2:
n1:=20;
put("El resultado deberia de ser 1 2 4 5 10 20:");
new_line;
put("Y tu programa dice que:");
divisores(n1);
new_line;
-- caso de prueba 3:
n1:=1;
put("El resultado deberia de ser 1:");
new_line;
put("Y tu programa dice que:");
divisores(n1);
new_line;
-- caso de prueba 4:
n1:=11;
put("El resultado deberia de ser 1 11:");
new_line;
put("Y tu programa dice que:");
divisores(n1);
new_line;
end prueba_divisores;
|
AdaCore/Ada_Drivers_Library | Ada | 9,106 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2018, AdaCore --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- This file provides declarations for devices on the STM32F7 Discovery kits
-- manufactured by ST Microelectronics.
with Ada.Interrupts.Names; use Ada.Interrupts;
with System;
with STM32.Device; use STM32.Device;
with STM32.DMA; use STM32.DMA;
with STM32.DMA.Interrupts; use STM32.DMA.Interrupts;
with STM32.FMC; use STM32.FMC;
with STM32.GPIO; use STM32.GPIO;
with STM32.I2C; use STM32.I2C;
use STM32;
with Audio;
with Touch_Panel_FT5336;
with Framebuffer_RK043FN48H;
with SDCard;
package STM32.Board is
pragma Elaborate_Body;
subtype User_LED is GPIO_Point;
Green_LED : User_LED renames PI1;
LED1 : User_LED renames Green_LED;
LCH_LED : User_LED renames Green_LED;
All_LEDs : GPIO_Points := (1 => Green_LED);
procedure Initialize_LEDs;
-- MUST be called prior to any use of the LEDs
procedure Turn_On (This : in out User_LED) renames STM32.GPIO.Set;
procedure Turn_Off (This : in out User_LED) renames STM32.GPIO.Clear;
procedure Toggle (This : in out User_LED) renames STM32.GPIO.Toggle;
procedure All_LEDs_Off with Inline;
procedure All_LEDs_On with Inline;
procedure Toggle_LEDs (These : in out GPIO_Points)
renames STM32.GPIO.Toggle;
-- GPIO Pins for FMC
FMC_A : constant GPIO_Points :=
(PF0, PF1, PF2, PF3, PF4, PF5, PF12, PF13, PF14, PF15, PG0, PG1);
FMC_D : constant GPIO_Points :=
(PD14, PD15, PD0, PD1, PE7, PE8, PE9, PE10,
PE11, PE12, PE13, PE14, PE15, PD8, PD9, PD10);
FMC_SDNWE : GPIO_Point renames PH5;
FMC_SDNRAS : GPIO_Point renames PF11;
FMC_SDNCAS : GPIO_Point renames PG15;
FMC_SDCLK : GPIO_Point renames PG8;
FMC_BA0 : GPIO_Point renames PG4;
FMC_BA1 : GPIO_Point renames PG5;
FMC_SDNE0 : GPIO_Point renames PH3;
FMC_SDCKE0 : GPIO_Point renames PC3;
FMC_NBL0 : GPIO_Point renames PE0;
FMC_NBL1 : GPIO_Point renames PE1;
SDRAM_PINS : constant GPIO_Points :=
FMC_A & FMC_D & FMC_SDNWE & FMC_SDNRAS & FMC_SDNCAS &
FMC_SDCLK & FMC_BA0 & FMC_BA1 & FMC_SDNE0 & FMC_SDCKE0 &
FMC_NBL0 & FMC_NBL1;
-- SDRAM CONFIGURATION Parameters
SDRAM_Base : constant := 16#C0000000#;
SDRAM_Size : constant := 16#800000#;
SDRAM_Bank : constant STM32.FMC.FMC_SDRAM_Cmd_Target_Bank :=
STM32.FMC.FMC_Bank1_SDRAM;
SDRAM_Mem_Width : constant STM32.FMC.FMC_SDRAM_Memory_Bus_Width :=
STM32.FMC.FMC_SDMemory_Width_16b;
SDRAM_Row_Bits : constant STM32.FMC.FMC_SDRAM_Row_Address_Bits :=
STM32.FMC.FMC_RowBits_Number_12b;
SDRAM_CAS_Latency : constant STM32.FMC.FMC_SDRAM_CAS_Latency :=
STM32.FMC.FMC_CAS_Latency_2;
SDRAM_CLOCK_Period : constant STM32.FMC.FMC_SDRAM_Clock_Configuration :=
STM32.FMC.FMC_SDClock_Period_2;
SDRAM_Read_Burst : constant STM32.FMC.FMC_SDRAM_Burst_Read :=
STM32.FMC.FMC_Read_Burst_Disable;
SDRAM_Read_Pipe : constant STM32.FMC.FMC_SDRAM_Read_Pipe_Delay :=
STM32.FMC.FMC_ReadPipe_Delay_0;
SDRAM_Refresh_Cnt : constant := 1539;
SDRAM_Min_Delay_In_ns : constant := 60;
---------
-- I2C --
---------
procedure Initialize_I2C_GPIO (Port : in out I2C_Port)
with
-- I2C_2 and I2C_4 are not accessible on this board
Pre => As_Port_Id (Port) = I2C_Id_1
or else
As_Port_Id (Port) = I2C_Id_3;
--------------------------------
-- Screen/Touch panel devices --
--------------------------------
LCD_Natural_Width : constant := Framebuffer_RK043FN48H.LCD_Natural_Width;
LCD_Natural_Height : constant := Framebuffer_RK043FN48H.LCD_Natural_Height;
Display : Framebuffer_RK043FN48H.Frame_Buffer;
Touch_Panel : Touch_Panel_FT5336.Touch_Panel;
-----------
-- Audio --
-----------
Audio_I2C : I2C_Port renames I2C_3;
Audio_I2C_SDA : STM32.GPIO.GPIO_Point renames STM32.Device.PH7;
Audio_I2C_SCL : STM32.GPIO.GPIO_Point renames STM32.Device.PH8;
Audio_I2C_AF : STM32.GPIO_Alternate_Function renames STM32.Device.GPIO_AF_I2C3_4;
Audio_INT : GPIO_Point renames PD6;
-- Audio DMA configuration
Audio_DMA : DMA_Controller renames DMA_2;
Audio_Out_DMA_Interrupt : Ada.Interrupts.Interrupt_ID renames
Ada.Interrupts.Names.DMA2_Stream4_Interrupt;
Audio_DMA_Out_Stream : DMA_Stream_Selector renames Stream_4;
Audio_DMA_Out_Channel : DMA_Channel_Selector renames Channel_3;
Audio_Device : aliased Audio.WM8994_Audio_Device (Audio_I2C'Access);
--------------------------
-- micro SD card reader --
--------------------------
SD_Detect_Pin : STM32.GPIO.GPIO_Point renames PC13;
SD_DMA : DMA_Controller renames DMA_2;
SD_DMA_Rx_Stream : DMA_Stream_Selector renames Stream_3;
SD_DMA_Rx_Channel : DMA_Channel_Selector renames Channel_4;
SD_DMA_Tx_Stream : DMA_Stream_Selector renames Stream_6;
SD_DMA_Tx_Channel : DMA_Channel_Selector renames Channel_4;
SD_Pins : constant GPIO_Points :=
(PC8, PC9, PC10, PC11, PC12, PD2);
SD_Pins_AF : constant GPIO_Alternate_Function := GPIO_AF_SDMMC1_12;
SD_Pins_2 : constant GPIO_Points := (1 .. 0 => <>);
SD_Pins_AF_2 : constant GPIO_Alternate_Function := GPIO_AF_SDMMC1_12;
SD_Interrupt : Ada.Interrupts.Interrupt_ID renames
Ada.Interrupts.Names.SDMMC1_Interrupt;
DMA2_Stream3 : aliased DMA_Interrupt_Controller
(DMA_2'Access, Stream_3,
Ada.Interrupts.Names.DMA2_Stream3_Interrupt,
System.Interrupt_Priority'Last);
DMA2_Stream6 : aliased DMA_Interrupt_Controller
(DMA_2'Access, Stream_6,
Ada.Interrupts.Names.DMA2_Stream6_Interrupt,
System.Interrupt_Priority'Last);
SD_Rx_DMA_Int : DMA_Interrupt_Controller renames DMA2_Stream3;
SD_Tx_DMA_Int : DMA_Interrupt_Controller renames DMA2_Stream6;
SDCard_Device : aliased SDCard.SDCard_Controller (SDMMC_1'Access);
------------------
-- User button --
------------------
User_Button_Point : GPIO_Point renames PI11;
User_Button_Interrupt : constant Interrupt_ID := Names.EXTI15_10_Interrupt;
procedure Configure_User_Button_GPIO;
-- Configures the GPIO port/pin for the blue user button. Sufficient
-- for polling the button, and necessary for having the button generate
-- interrupts.
end STM32.Board;
|
burratoo/Acton | Ada | 7,728 | ads | ------------------------------------------------------------------------------------------
-- --
-- ACTON PROCESSOR SUPPORT PACKAGE --
-- --
-- ATMEL.AT91SAM7S.AIC --
-- --
-- Copyright (C) 2014-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
with Interfaces; use Interfaces;
with System; use System;
package Atmel.AT91SAM7S.AIC with Preelaborate is
--------------------------
-- AIC Memory Addresses --
--------------------------
AIC_Base_Address : constant := 16#FFFF_F000#;
SMR_Offset_Address : constant := 16#000#;
SVR_Offset_Address : constant := 16#080#;
IVR_Offset_Address : constant := 16#100#;
FVR_Offset_Address : constant := 16#104#;
ISR_Offset_Address : constant := 16#108#;
IPR_Offset_Address : constant := 16#10C#;
IMR_Offset_Address : constant := 16#110#;
CISR_Offset_Address : constant := 16#114#;
IECR_Offset_Address : constant := 16#120#;
IDCR_Offset_Address : constant := 16#124#;
ICCR_Offset_Address : constant := 16#128#;
ISCR_Offset_Address : constant := 16#12C#;
EOICR_Offset_Address : constant := 16#130#;
SPU_Offset_Address : constant := 16#134#;
DCR_Offset_Address : constant := 16#138#;
FFER_Offset_Address : constant := 16#140#;
FFDR_Offset_Address : constant := 16#144#;
FFSR_Offset_Address : constant := 16#148#;
-----------------------
-- Hardware Features --
-----------------------
type AIC_Interrupt_Priority is range 0 .. 7 with Size => 3;
type Interrupt_Source_Type is
(Low_Level_Sensitive,
Negative_Edge_Triggered,
High_Level_Sensitive,
Positive_Edge_Triggered);
---------------
-- AIC Types --
---------------
type Source_Mode_Type is record
Priority_Level : AIC_Interrupt_Priority;
Interrupt_Source : Interrupt_Source_Type;
end record with Size => Standard'Word_Size;
type Interrupt_Status_Type is record
Current_Interrupt : Peripheral_Id;
end record with Size => Standard'Word_Size;
type Peripheral_Bit_Field is array (Peripheral_Id) of Boolean
with Pack, Size => Standard'Word_Size;
type Interrupt_Pending_Type is record
Interrupt_Pending : Peripheral_Bit_Field;
end record with Size => Standard'Word_Size;
type Interrupt_Enabled_Bit_Field is array (Peripheral_Id) of Enabled_Type
with Pack, Size => Standard'Word_Size;
type Interrupt_Enabled_Type is record
Interrupt : Interrupt_Enabled_Bit_Field;
end record with Size => Standard'Word_Size;
type Active_Type is (Deactive, Active);
type Core_Interrupt_Status_Type is record
NFIQ : Active_Type;
NIRQ : Active_Type;
end record with Size => Standard'Word_Size;
type Interrupt_Enable_No_Change_Field is
array (Peripheral_Id) of Enable_No_Change_Type
with Pack, Size => Standard'Word_Size;
type Interrupt_Enable_No_Change_Type is record
Interrupt : Interrupt_Enable_No_Change_Field;
end record with Size => Standard'Word_Size;
type Interrupt_Disable_No_Change_Field is
array (Peripheral_Id) of Disable_No_Change_Type
with Pack, Size => Standard'Word_Size;
type Interrupt_Disable_No_Change_Type is record
Interrupt : Interrupt_Disable_No_Change_Field;
end record with Size => Standard'Word_Size;
type Interrupt_Clear_Type is record
Clear_Interrupt : Peripheral_Bit_Field;
end record with Size => Standard'Word_Size;
type Interrupt_Set_Type is record
Set_Interrupt : Peripheral_Bit_Field;
end record with Size => Standard'Word_Size;
type Debug_Control_Type is record
Protection_Mode : Enable_Type;
General_Mask : Boolean;
end record with Size => 32;
------------------------------
-- Hardware Representations --
------------------------------
for Interrupt_Source_Type use
(Low_Level_Sensitive => 0,
Negative_Edge_Triggered => 1,
High_Level_Sensitive => 2,
Positive_Edge_Triggered => 3);
for Source_Mode_Type use record
Priority_Level at 0 range 0 .. 2;
Interrupt_Source at 0 range 5 .. 6;
end record;
for Interrupt_Status_Type use record
Current_Interrupt at 0 range 0 .. 4;
end record;
for Core_Interrupt_Status_Type use record
NFIQ at 0 range 0 .. 0;
NIRQ at 0 range 1 .. 1;
end record;
for Debug_Control_Type use record
Protection_Mode at 0 range 0 .. 0;
General_Mask at 0 range 1 .. 1;
end record;
-------------------
-- AIC Registers --
-------------------
Source_Mode_Register : array (Peripheral_Id) of Source_Mode_Type
with Alignment => 4,
Address => System'To_Address (AIC_Base_Address + SMR_Offset_Address);
Source_Vector_Register : array (Peripheral_Id) of Address
with Alignment => 4,
Address => System'To_Address (AIC_Base_Address + SVR_Offset_Address);
Interrupt_Vector_Register : Address
with Address => System'To_Address (AIC_Base_Address + IVR_Offset_Address);
FIQ_Vector_Register : Address
with Address => System'To_Address (AIC_Base_Address + FVR_Offset_Address);
Interrupt_Status_Register : Interrupt_Status_Type
with Address => System'To_Address (AIC_Base_Address + ISR_Offset_Address);
Interrupt_Pending_Register : Interrupt_Pending_Type
with Address => System'To_Address (AIC_Base_Address + IPR_Offset_Address);
Interrupt_Mask_Register : Interrupt_Enabled_Type
with Address => System'To_Address (AIC_Base_Address + IMR_Offset_Address);
Core_Interrupt_Status_Register : Core_Interrupt_Status_Type
with Address => System'To_Address
(AIC_Base_Address + CISR_Offset_Address);
Interrupt_Enable_Command_Register : Interrupt_Enable_No_Change_Type
with Address => System'To_Address
(AIC_Base_Address + IECR_Offset_Address);
Interrupt_Disable_Command_Register : Interrupt_Disable_No_Change_Type
with Address => System'To_Address
(AIC_Base_Address + IDCR_Offset_Address);
Interrupt_Clear_Command_Register : Interrupt_Clear_Type
with Address => System'To_Address
(AIC_Base_Address + ICCR_Offset_Address);
Interrupt_Set_Command_Register : Interrupt_Set_Type
with Address => System'To_Address
(AIC_Base_Address + ISCR_Offset_Address);
End_Of_Interrupt_Command_Register : Unsigned_32
with Address => System'To_Address
(AIC_Base_Address + EOICR_Offset_Address);
Spurious_Interrupt_Vector_Register : Address
with Address => System'To_Address (AIC_Base_Address + SPU_Offset_Address);
Debug_Control_Register : Debug_Control_Type
with Address => System'To_Address (AIC_Base_Address + DCR_Offset_Address);
Fast_Forcing_Enable_Register : Interrupt_Enable_No_Change_Type
with Address => System'To_Address
(AIC_Base_Address + FFER_Offset_Address);
Fast_Forcing_Disable_Register : Interrupt_Disable_No_Change_Type
with Address => System'To_Address
(AIC_Base_Address + FFDR_Offset_Address);
Fast_Forcing_Status_Register : Interrupt_Enabled_Type
with Address => System'To_Address
(AIC_Base_Address + FFSR_Offset_Address);
end Atmel.AT91SAM7S.AIC;
|
zhmu/ananas | Ada | 6,156 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . B I G N U M S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2012-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 Ada.Unchecked_Conversion;
with System.Generic_Bignums;
with System.Secondary_Stack; use System.Secondary_Stack;
with System.Shared_Bignums; use System.Shared_Bignums;
with System.Storage_Elements; use System.Storage_Elements;
package body System.Bignums is
function Allocate_Bignum (D : Digit_Vector; Neg : Boolean) return Bignum;
-- Allocate Bignum value with the given contents
procedure Free_Bignum (X : in out Bignum) is null;
-- No op when using the secondary stack
function To_Bignum (X : aliased in out Bignum) return Bignum is (X);
---------------------
-- Allocate_Bignum --
---------------------
function Allocate_Bignum (D : Digit_Vector; Neg : Boolean) return Bignum is
Addr : aliased Address;
begin
-- Note: The approach used here is designed to avoid strict aliasing
-- warnings that appeared previously using unchecked conversion.
SS_Allocate (Addr, Storage_Offset (4 + 4 * D'Length));
declare
B : Bignum;
for B'Address use Addr'Address;
pragma Import (Ada, B);
BD : Bignum_Data (D'Length);
for BD'Address use Addr;
pragma Import (Ada, BD);
-- Expose a writable view of discriminant BD.Len so that we can
-- initialize it. We need to use the exact layout of the record
-- to ensure that the Length field has 24 bits as expected.
type Bignum_Data_Header is record
Len : Length;
Neg : Boolean;
end record;
for Bignum_Data_Header use record
Len at 0 range 0 .. 23;
Neg at 3 range 0 .. 7;
end record;
BDH : Bignum_Data_Header;
for BDH'Address use BD'Address;
pragma Import (Ada, BDH);
pragma Assert (BDH.Len'Size = BD.Len'Size);
begin
BDH.Len := D'Length;
BDH.Neg := Neg;
B.D := D;
return B;
end;
end Allocate_Bignum;
package Sec_Stack_Bignums is new System.Generic_Bignums
(Bignum, Allocate_Bignum, Free_Bignum, To_Bignum);
function Big_Add (X, Y : Bignum) return Bignum
renames Sec_Stack_Bignums.Big_Add;
function Big_Sub (X, Y : Bignum) return Bignum
renames Sec_Stack_Bignums.Big_Sub;
function Big_Mul (X, Y : Bignum) return Bignum
renames Sec_Stack_Bignums.Big_Mul;
function Big_Div (X, Y : Bignum) return Bignum
renames Sec_Stack_Bignums.Big_Div;
function Big_Exp (X, Y : Bignum) return Bignum
renames Sec_Stack_Bignums.Big_Exp;
function Big_Mod (X, Y : Bignum) return Bignum
renames Sec_Stack_Bignums.Big_Mod;
function Big_Rem (X, Y : Bignum) return Bignum
renames Sec_Stack_Bignums.Big_Rem;
function Big_Neg (X : Bignum) return Bignum
renames Sec_Stack_Bignums.Big_Neg;
function Big_Abs (X : Bignum) return Bignum
renames Sec_Stack_Bignums.Big_Abs;
function Big_EQ (X, Y : Bignum) return Boolean
renames Sec_Stack_Bignums.Big_EQ;
function Big_NE (X, Y : Bignum) return Boolean
renames Sec_Stack_Bignums.Big_NE;
function Big_GE (X, Y : Bignum) return Boolean
renames Sec_Stack_Bignums.Big_GE;
function Big_LE (X, Y : Bignum) return Boolean
renames Sec_Stack_Bignums.Big_LE;
function Big_GT (X, Y : Bignum) return Boolean
renames Sec_Stack_Bignums.Big_GT;
function Big_LT (X, Y : Bignum) return Boolean
renames Sec_Stack_Bignums.Big_LT;
function Bignum_In_LLI_Range (X : Bignum) return Boolean
renames Sec_Stack_Bignums.Bignum_In_LLI_Range;
function To_Bignum (X : Long_Long_Integer) return Bignum
renames Sec_Stack_Bignums.To_Bignum;
function From_Bignum (X : Bignum) return Long_Long_Integer
renames Sec_Stack_Bignums.From_Bignum;
end System.Bignums;
|
jhumphry/parse_args | Ada | 2,208 | ads | -- parse_args-generic_discrete_option.ads
-- A simple command line option parser
-- Copyright (c) 2015, James Humphry
--
-- Permission to use, copy, modify, and/or 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.
pragma Profile(No_Implementation_Extensions);
generic
type Element is private;
Fallback_Default : Element;
with function Value (S : String) return Element;
with function Image (Arg : Element) return String;
with procedure Valid (Arg : in Element; Result : in out Boolean) is null;
package Parse_Args.Generic_Options is
type Element_Option is new Option with private;
overriding function Image (O : in Element_Option) return String;
not overriding function Value (O : in Element_Option) return Element;
function Value(A : in Argument_Parser; Name : in String) return Element;
function Make_Option(Default : in Element := Fallback_Default)
return Option_Ptr;
private
type Element_Option is new Option with record
Value : Element := Fallback_Default;
Default : Element := Fallback_Default;
end record;
overriding procedure Set_Option
(O : in out Element_Option;
A : in out Argument_Parser'Class);
overriding procedure Set_Option_Argument
(O : in out Element_Option;
Arg : in String;
A : in out Argument_Parser'Class);
overriding function Image (O : in Element_Option) return String is
(Image (O.Value));
not overriding function Value (O : in Element_Option) return Element is
(O.Value);
end Parse_Args.Generic_Options;
|
SayCV/rtems-addon-packages | Ada | 24,423 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000-2008,2011 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$
-- $Date$
-- Binding Version 01.00
------------------------------------------------------------------------------
with ncurses2.util; use ncurses2.util;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Interfaces.C;
with System.Storage_Elements;
with System.Address_To_Access_Conversions;
with Ada.Text_IO;
-- with Ada.Real_Time; use Ada.Real_Time;
-- TODO is there a way to use Real_Time or Ada.Calendar in place of
-- gettimeofday?
-- Demonstrate pads.
procedure ncurses2.demo_pad is
type timestruct is record
seconds : Integer;
microseconds : Integer;
end record;
type myfunc is access function (w : Window) return Key_Code;
function gettime return timestruct;
procedure do_h_line (y : Line_Position;
x : Column_Position;
c : Attributed_Character;
to : Column_Position);
procedure do_v_line (y : Line_Position;
x : Column_Position;
c : Attributed_Character;
to : Line_Position);
function padgetch (win : Window) return Key_Code;
function panner_legend (line : Line_Position) return Boolean;
procedure panner_legend (line : Line_Position);
procedure panner_h_cleanup (from_y : Line_Position;
from_x : Column_Position;
to_x : Column_Position);
procedure panner_v_cleanup (from_y : Line_Position;
from_x : Column_Position;
to_y : Line_Position);
procedure panner (pad : Window;
top_xp : Column_Position;
top_yp : Line_Position;
portyp : Line_Position;
portxp : Column_Position;
pgetc : myfunc);
function gettime return timestruct is
retval : timestruct;
use Interfaces.C;
type timeval is record
tv_sec : long;
tv_usec : long;
end record;
pragma Convention (C, timeval);
-- TODO function from_timeval is new Ada.Unchecked_Conversion(
-- timeval_a, System.Storage_Elements.Integer_Address);
-- should Interfaces.C.Pointers be used here?
package myP is new System.Address_To_Access_Conversions (timeval);
use myP;
t : constant Object_Pointer := new timeval;
function gettimeofday
(TP : System.Storage_Elements.Integer_Address;
TZP : System.Storage_Elements.Integer_Address) return int;
pragma Import (C, gettimeofday, "gettimeofday");
tmp : int;
begin
tmp := gettimeofday (System.Storage_Elements.To_Integer
(myP.To_Address (t)),
System.Storage_Elements.To_Integer
(myP.To_Address (null)));
if tmp < 0 then
retval.seconds := 0;
retval.microseconds := 0;
else
retval.seconds := Integer (t.all.tv_sec);
retval.microseconds := Integer (t.all.tv_usec);
end if;
return retval;
end gettime;
-- in C, The behavior of mvhline, mvvline for negative/zero length is
-- unspecified, though we can rely on negative x/y values to stop the
-- macro. Except Ada makes Line_Position(-1) = Natural - 1 so forget it.
procedure do_h_line (y : Line_Position;
x : Column_Position;
c : Attributed_Character;
to : Column_Position) is
begin
if to > x then
Move_Cursor (Line => y, Column => x);
Horizontal_Line (Line_Size => Natural (to - x), Line_Symbol => c);
end if;
end do_h_line;
procedure do_v_line (y : Line_Position;
x : Column_Position;
c : Attributed_Character;
to : Line_Position) is
begin
if to > y then
Move_Cursor (Line => y, Column => x);
Vertical_Line (Line_Size => Natural (to - y), Line_Symbol => c);
end if;
end do_v_line;
function padgetch (win : Window) return Key_Code is
c : Key_Code;
c2 : Character;
begin
c := Getchar (win);
c2 := Code_To_Char (c);
case c2 is
when '!' =>
ShellOut (False);
return Key_Refresh;
when Character'Val (Character'Pos ('r') mod 16#20#) => -- CTRL('r')
End_Windows;
Refresh;
return Key_Refresh;
when Character'Val (Character'Pos ('l') mod 16#20#) => -- CTRL('l')
return Key_Refresh;
when 'U' =>
return Key_Cursor_Up;
when 'D' =>
return Key_Cursor_Down;
when 'R' =>
return Key_Cursor_Right;
when 'L' =>
return Key_Cursor_Left;
when '+' =>
return Key_Insert_Line;
when '-' =>
return Key_Delete_Line;
when '>' =>
return Key_Insert_Char;
when '<' =>
return Key_Delete_Char;
-- when ERR=> /* FALLTHRU */
when 'q' =>
return (Key_Exit);
when others =>
return (c);
end case;
end padgetch;
show_panner_legend : Boolean := True;
function panner_legend (line : Line_Position) return Boolean is
legend : constant array (0 .. 3) of String (1 .. 61) :=
(
"Use arrow keys (or U,D,L,R) to pan, q to quit (?,t,s flags) ",
"Use ! to shell-out. Toggle legend:?, timer:t, scroll mark:s.",
"Use +,- (or j,k) to grow/shrink the panner vertically. ",
"Use <,> (or h,l) to grow/shrink the panner horizontally. ");
legendsize : constant := 4;
n : constant Integer := legendsize - Integer (Lines - line);
begin
if line < Lines and n >= 0 then
Move_Cursor (Line => line, Column => 0);
if show_panner_legend then
Add (Str => legend (n));
end if;
Clear_To_End_Of_Line;
return show_panner_legend;
end if;
return False;
end panner_legend;
procedure panner_legend (line : Line_Position) is
begin
if not panner_legend (line) then
Beep;
end if;
end panner_legend;
procedure panner_h_cleanup (from_y : Line_Position;
from_x : Column_Position;
to_x : Column_Position) is
begin
if not panner_legend (from_y) then
do_h_line (from_y, from_x, Blank2, to_x);
end if;
end panner_h_cleanup;
procedure panner_v_cleanup (from_y : Line_Position;
from_x : Column_Position;
to_y : Line_Position) is
begin
if not panner_legend (from_y) then
do_v_line (from_y, from_x, Blank2, to_y);
end if;
end panner_v_cleanup;
procedure panner (pad : Window;
top_xp : Column_Position;
top_yp : Line_Position;
portyp : Line_Position;
portxp : Column_Position;
pgetc : myfunc) is
function f (y : Line_Position) return Line_Position;
function f (x : Column_Position) return Column_Position;
function greater (y1, y2 : Line_Position) return Integer;
function greater (x1, x2 : Column_Position) return Integer;
top_x : Column_Position := top_xp;
top_y : Line_Position := top_yp;
porty : Line_Position := portyp;
portx : Column_Position := portxp;
-- f[x] returns max[x - 1, 0]
function f (y : Line_Position) return Line_Position is
begin
if y > 0 then
return y - 1;
else
return y; -- 0
end if;
end f;
function f (x : Column_Position) return Column_Position is
begin
if x > 0 then
return x - 1;
else
return x; -- 0
end if;
end f;
function greater (y1, y2 : Line_Position) return Integer is
begin
if y1 > y2 then
return 1;
else
return 0;
end if;
end greater;
function greater (x1, x2 : Column_Position) return Integer is
begin
if x1 > x2 then
return 1;
else
return 0;
end if;
end greater;
pymax : Line_Position;
basey : Line_Position := 0;
pxmax : Column_Position;
basex : Column_Position := 0;
c : Key_Code;
scrollers : Boolean := True;
before, after : timestruct;
timing : Boolean := True;
package floatio is new Ada.Text_IO.Float_IO (Long_Float);
begin
Get_Size (pad, pymax, pxmax);
Allow_Scrolling (Mode => False); -- we don't want stdscr to scroll!
c := Key_Refresh;
loop
-- During shell-out, the user may have resized the window. Adjust
-- the port size of the pad to accommodate this. Ncurses
-- automatically resizes all of the normal windows to fit on the
-- new screen.
if top_x > Columns then
top_x := Columns;
end if;
if portx > Columns then
portx := Columns;
end if;
if top_y > Lines then
top_y := Lines;
end if;
if porty > Lines then
porty := Lines;
end if;
case c is
when Key_Refresh | Character'Pos ('?') =>
if c = Key_Refresh then
Erase;
else -- '?'
show_panner_legend := not show_panner_legend;
end if;
panner_legend (Lines - 4);
panner_legend (Lines - 3);
panner_legend (Lines - 2);
panner_legend (Lines - 1);
when Character'Pos ('t') =>
timing := not timing;
if not timing then
panner_legend (Lines - 1);
end if;
when Character'Pos ('s') =>
scrollers := not scrollers;
-- Move the top-left corner of the pad, keeping the
-- bottom-right corner fixed.
when Character'Pos ('h') =>
-- increase-columns: move left edge to left
if top_x = 0 then
Beep;
else
panner_v_cleanup (top_y, top_x, porty);
top_x := top_x - 1;
end if;
when Character'Pos ('j') =>
-- decrease-lines: move top-edge down
if top_y >= porty then
Beep;
else
if top_y /= 0 then
panner_h_cleanup (top_y - 1, f (top_x), portx);
end if;
top_y := top_y + 1;
end if;
when Character'Pos ('k') =>
-- increase-lines: move top-edge up
if top_y = 0 then
Beep;
else
top_y := top_y - 1;
panner_h_cleanup (top_y, top_x, portx);
end if;
when Character'Pos ('l') =>
-- decrease-columns: move left-edge to right
if top_x >= portx then
Beep;
else
if top_x /= 0 then
panner_v_cleanup (f (top_y), top_x - 1, porty);
end if;
top_x := top_x + 1;
end if;
-- Move the bottom-right corner of the pad, keeping the
-- top-left corner fixed.
when Key_Insert_Char =>
-- increase-columns: move right-edge to right
if portx >= pxmax or portx >= Columns then
Beep;
else
panner_v_cleanup (f (top_y), portx - 1, porty);
portx := portx + 1;
-- C had ++portx instead of portx++, weird.
end if;
when Key_Insert_Line =>
-- increase-lines: move bottom-edge down
if porty >= pymax or porty >= Lines then
Beep;
else
panner_h_cleanup (porty - 1, f (top_x), portx);
porty := porty + 1;
end if;
when Key_Delete_Char =>
-- decrease-columns: move bottom edge up
if portx <= top_x then
Beep;
else
portx := portx - 1;
panner_v_cleanup (f (top_y), portx, porty);
end if;
when Key_Delete_Line =>
-- decrease-lines
if porty <= top_y then
Beep;
else
porty := porty - 1;
panner_h_cleanup (porty, f (top_x), portx);
end if;
when Key_Cursor_Left =>
-- pan leftwards
if basex > 0 then
basex := basex - 1;
else
Beep;
end if;
when Key_Cursor_Right =>
-- pan rightwards
-- if (basex + portx - (pymax > porty) < pxmax)
if basex + portx -
Column_Position (greater (pymax, porty)) < pxmax then
-- if basex + portx < pxmax or
-- (pymax > porty and basex + portx - 1 < pxmax) then
basex := basex + 1;
else
Beep;
end if;
when Key_Cursor_Up =>
-- pan upwards
if basey > 0 then
basey := basey - 1;
else
Beep;
end if;
when Key_Cursor_Down =>
-- pan downwards
-- same as if (basey + porty - (pxmax > portx) < pymax)
if basey + porty -
Line_Position (greater (pxmax, portx)) < pymax then
-- if (basey + porty < pymax) or
-- (pxmax > portx and basey + porty - 1 < pymax) then
basey := basey + 1;
else
Beep;
end if;
when Character'Pos ('H') |
Key_Home |
Key_Find =>
basey := 0;
when Character'Pos ('E') |
Key_End |
Key_Select =>
if pymax < porty then
basey := 0;
else
basey := pymax - porty;
end if;
when others =>
Beep;
end case;
-- more writing off the screen.
-- Interestingly, the exception is not handled if
-- we put a block around this.
-- delcare --begin
if top_y /= 0 and top_x /= 0 then
Add (Line => top_y - 1, Column => top_x - 1,
Ch => ACS_Map (ACS_Upper_Left_Corner));
end if;
if top_x /= 0 then
do_v_line (top_y, top_x - 1, ACS_Map (ACS_Vertical_Line), porty);
end if;
if top_y /= 0 then
do_h_line (top_y - 1, top_x, ACS_Map (ACS_Horizontal_Line), portx);
end if;
-- exception when Curses_Exception => null; end;
-- in C was ... pxmax > portx - 1
if scrollers and pxmax >= portx then
declare
length : constant Column_Position := portx - top_x - 1;
lowend, highend : Column_Position;
begin
-- Instead of using floats, I'll use integers only.
lowend := top_x + (basex * length) / pxmax;
highend := top_x + ((basex + length) * length) / pxmax;
do_h_line (porty - 1, top_x, ACS_Map (ACS_Horizontal_Line),
lowend);
if highend < portx then
Switch_Character_Attribute
(Attr => (Reverse_Video => True, others => False),
On => True);
do_h_line (porty - 1, lowend, Blank2, highend + 1);
Switch_Character_Attribute
(Attr => (Reverse_Video => True, others => False),
On => False);
do_h_line (porty - 1, highend + 1,
ACS_Map (ACS_Horizontal_Line), portx);
end if;
end;
else
do_h_line (porty - 1, top_x, ACS_Map (ACS_Horizontal_Line), portx);
end if;
if scrollers and pymax >= porty then
declare
length : constant Line_Position := porty - top_y - 1;
lowend, highend : Line_Position;
begin
lowend := top_y + (basey * length) / pymax;
highend := top_y + ((basey + length) * length) / pymax;
do_v_line (top_y, portx - 1, ACS_Map (ACS_Vertical_Line),
lowend);
if highend < porty then
Switch_Character_Attribute
(Attr => (Reverse_Video => True, others => False),
On => True);
do_v_line (lowend, portx - 1, Blank2, highend + 1);
Switch_Character_Attribute
(Attr => (Reverse_Video => True, others => False),
On => False);
do_v_line (highend + 1, portx - 1,
ACS_Map (ACS_Vertical_Line), porty);
end if;
end;
else
do_v_line (top_y, portx - 1, ACS_Map (ACS_Vertical_Line), porty);
end if;
if top_y /= 0 then
Add (Line => top_y - 1, Column => portx - 1,
Ch => ACS_Map (ACS_Upper_Right_Corner));
end if;
if top_x /= 0 then
Add (Line => porty - 1, Column => top_x - 1,
Ch => ACS_Map (ACS_Lower_Left_Corner));
end if;
declare
begin
-- Here is another place where it is possible
-- to write to the corner of the screen.
Add (Line => porty - 1, Column => portx - 1,
Ch => ACS_Map (ACS_Lower_Right_Corner));
exception
when Curses_Exception => null;
end;
before := gettime;
Refresh_Without_Update;
declare
-- the C version allows the panel to have a zero height
-- wich raise the exception
begin
Refresh_Without_Update
(
pad,
basey, basex,
top_y, top_x,
porty - Line_Position (greater (pxmax, portx)) - 1,
portx - Column_Position (greater (pymax, porty)) - 1);
exception
when Curses_Exception => null;
end;
Update_Screen;
if timing then
declare
s : String (1 .. 7);
elapsed : Long_Float;
begin
after := gettime;
elapsed := (Long_Float (after.seconds - before.seconds) +
Long_Float (after.microseconds
- before.microseconds)
/ 1.0e6);
Move_Cursor (Line => Lines - 1, Column => Columns - 20);
floatio.Put (s, elapsed, Aft => 3, Exp => 0);
Add (Str => s);
Refresh;
end;
end if;
c := pgetc (pad);
exit when c = Key_Exit;
end loop;
Allow_Scrolling (Mode => True);
end panner;
Gridsize : constant := 3;
Gridcount : Integer := 0;
Pad_High : constant Line_Count := 200;
Pad_Wide : constant Column_Count := 200;
panpad : Window := New_Pad (Pad_High, Pad_Wide);
begin
if panpad = Null_Window then
Cannot ("cannot create requested pad");
return;
end if;
for i in 0 .. Pad_High - 1 loop
for j in 0 .. Pad_Wide - 1 loop
if i mod Gridsize = 0 and j mod Gridsize = 0 then
if i = 0 or j = 0 then
Add (panpad, '+');
else
-- depends on ASCII?
Add (panpad,
Ch => Character'Val (Character'Pos ('A') +
Gridcount mod 26));
Gridcount := Gridcount + 1;
end if;
elsif i mod Gridsize = 0 then
Add (panpad, '-');
elsif j mod Gridsize = 0 then
Add (panpad, '|');
else
declare
-- handle the write to the lower right corner error
begin
Add (panpad, ' ');
exception
when Curses_Exception => null;
end;
end if;
end loop;
end loop;
panner_legend (Lines - 4);
panner_legend (Lines - 3);
panner_legend (Lines - 2);
panner_legend (Lines - 1);
Set_KeyPad_Mode (panpad, True);
-- Make the pad (initially) narrow enough that a trace file won't wrap.
-- We'll still be able to widen it during a test, since that's required
-- for testing boundaries.
panner (panpad, 2, 2, Lines - 5, Columns - 15, padgetch'Access);
Delete (panpad);
End_Windows; -- Hmm, Erase after End_Windows
Erase;
end ncurses2.demo_pad;
|
AdaCore/training_material | Ada | 3,405 | adb | with Ada.Exceptions;
with Movies; use Movies;
with Char_Display_Driver; use Char_Display_Driver;
with Ada.Calendar;
use type Ada.Calendar.Time;
with Logs;
with Drawable_Chars.Latin_1;
package body Movie_Servers is
protected body Play_Settings_T is
function FPS return Positive is (FPS_Value);
procedure Set_FPS (Value : Positive) is
begin
FPS_Value := Value;
end Set_FPS;
function Charset return Sorted_Charset_T is (Charset_Value);
procedure Set_Charset (Value : Sorted_Charset_T) is
begin
Charset_Value := Value;
end Set_Charset;
end Play_Settings_T;
function Make_Default return Movie_Server_Task_T is
S : constant Play_Settings_Access_T := new Play_Settings_T;
begin
S.Set_FPS (4);
S.Set_Charset (Drawable_Chars.Latin_1.By_Black);
return T : Movie_Server_Task_T (Play_Settings => S);
end Make_Default;
procedure Display_Frame
(CD : in out Char_Display; Movie : Movie_T; Frame : Frame_T)
is
begin
CD.Surf := Movies.Frame (Movie, Frame);
Char_Display_Driver.Display (CD);
end Display_Frame;
task body Movie_Server_Task_T is
Playing : Boolean := False;
Frame : Frame_T;
End_Of_Times : constant Ada.Calendar.Time :=
Ada.Calendar.Time_Of (Ada.Calendar.Year_Number'Last, 12, 31);
Next_Frame_Time : Ada.Calendar.Time := End_Of_Times;
Movie : Movies.Movie_T := Null_Movie;
CD : Char_Display;
begin
loop
select
accept Play_Loop (Dir : String) do
Movie := Movies.Load_From (Dir);
declare
Res : constant Resolution_T := Resolution (Movie);
begin
CD :=
(Rows => Res.Rows, Columns => Res.Columns, others => <>);
end;
Playing := True;
Frame := Frame_T'First;
Next_Frame_Time := Ada.Calendar.Clock;
end Play_Loop;
or
accept Pause do
Playing := False;
end Pause;
or
accept Resume do
Playing := True;
Next_Frame_Time := Ada.Calendar.Clock;
end Resume;
or
accept Stop do
Movie := Null_Movie;
end Stop;
or
accept Finish;
exit;
or
delay until Next_Frame_Time;
end select;
if Playing and Movie /= Null_Movie then
CD.Lux_Charset := Play_Settings.Charset;
Display_Frame (CD, Movie, Frame);
Logs.Put_Line (File_Name (Movie));
if Frame = Frames_Number (Movie) then
Frame := Frame_T'First;
else
Frame := Frame_T'Succ (Frame);
end if;
Next_Frame_Time :=
Next_Frame_Time + 1.0 / Duration (Play_Settings.FPS);
else
Next_Frame_Time := End_Of_Times;
end if;
end loop;
exception
when E : others =>
Logs.Put (Sty => Logs.White_On_Red, S => " error ");
Logs.Put_Line (" " & Ada.Exceptions.Exception_Name (E));
Logs.Put_Line (Ada.Exceptions.Exception_Message (E));
end Movie_Server_Task_T;
end Movie_Servers;
|
persan/protobuf-ada | Ada | 4,621 | adb | pragma Ada_2012;
package body Protocol_Buffers.Message is
------------------------------------------
-- 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
Protocol_Buffers.IO.Coded_Input_Stream.Instance)
is
begin
The_Message.Merge_Partial_From_Coded_Input_Stream (The_Coded_Input_Stream);
pragma Compile_Time_Warning (Standard.True, "Inline_Merge_From_Coded_Input_Stream contains only temporary implementation ...");
end Inline_Merge_From_Coded_Input_Stream;
--------------------------------
-- Serialize_To_Output_Stream --
--------------------------------
procedure Serialize_To_Output_Stream
(The_Message : in Message.Instance'Class;
Output_Stream : in not null
Ada.Streams.Stream_IO.Stream_Access)
is
begin
pragma Compile_Time_Warning (Standard.True, "Serialize_To_Output_Stream should signal error when message has not been initialized");
if The_Message.Is_Initialized then
The_Message.Serialize_Partial_To_Output_Stream (Output_Stream);
end if;
end Serialize_To_Output_Stream;
----------------------------------------
-- Serialize_Partial_To_Output_Stream --
----------------------------------------
procedure Serialize_Partial_To_Output_Stream
(The_Message : in Message.Instance'Class;
Output_Stream : in not null
Ada.Streams.Stream_IO.Stream_Access)
is
A_Coded_Output_Stream : Protocol_Buffers.IO.Coded_Output_Stream.Instance
(Protocol_Buffers.IO.Coded_Output_Stream.Root_Stream_Access (Output_Stream));
begin
The_Message.Serialize_With_Cached_Sizes (A_Coded_Output_Stream);
pragma Compile_Time_Warning (Standard.True, "Serialize_Partial_To_Output_Stream contains only temporary implementation ...");
end Serialize_Partial_To_Output_Stream;
-----------------------------
-- Parse_From_Input_Stream --
-----------------------------
procedure Parse_From_Input_Stream
(The_Message : in out Message.Instance'Class;
Input_Stream : in not null
Ada.Streams.Stream_IO.Stream_Access)
is
A_Coded_Input_Stream : Protocol_Buffers.IO.Coded_Input_Stream.Instance
(Protocol_Buffers.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);
pragma Compile_Time_Warning (Standard.True, "Parse_From_Input_Stream contains only temporary implementation ...");
end Parse_From_Input_Stream;
-------------------------------------
-- Parse_Partial_From_Input_Stream --
-------------------------------------
procedure Parse_Partial_From_Input_Stream
(The_Message : in out Message.Instance'Class;
Input_Stream : in not null
Ada.Streams.Stream_IO.Stream_Access)
is
A_Coded_Input_Stream : Protocol_Buffers.IO.Coded_Input_Stream.Instance
(Protocol_Buffers.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_Partial_From_Input_Stream;
-----------------------------
-- Merge_From_Input_Stream --
-----------------------------
procedure Merge_From_Input_Stream
(The_Message : in out Message.Instance'Class;
Input_Stream : in not null
Ada.Streams.Stream_IO.Stream_Access)
is
A_Coded_Input_Stream : Protocol_Buffers.IO.Coded_Input_Stream.Instance
(Protocol_Buffers.IO.Coded_Input_Stream.Root_Stream_Access (Input_Stream));
begin
Inline_Merge_From_Coded_Input_Stream (The_Message, A_Coded_Input_Stream);
pragma Compile_Time_Warning (Standard.True, "Merge_From_Input_Stream contains only temporary implementation ...");
end Merge_From_Input_Stream;
-----------------------------
-- Merge_Partial_From_Input_Stream --
-----------------------------
procedure Merge_Partial_From_Input_Stream
(The_Message : in out Message.Instance'Class;
Input_Stream : in not null
Ada.Streams.Stream_IO.Stream_Access)
is
A_Coded_Input_Stream : Protocol_Buffers.IO.Coded_Input_Stream.Instance
(Protocol_Buffers.IO.Coded_Input_Stream.Root_Stream_Access (Input_Stream));
begin
Inline_Merge_From_Coded_Input_Stream (The_Message, A_Coded_Input_Stream);
end Merge_Partial_From_Input_Stream;
end Protocol_Buffers.Message;
|
ohenley/ada-util | Ada | 3,225 | ads | -----------------------------------------------------------------------
-- util-streams-encoders -- Streams with encoding and decoding capabilities
-- 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 Util.Encoders;
-- == Encoding Streams ==
-- The <tt>Encoding_Stream</tt> tagged record represents a stream with encoding capabilities.
-- The stream passes the data to be written to the <tt>Transformer</tt> interface that
-- allows to make transformations on the data before being written.
--
-- Encode : Util.Streams.Buffered.Encoders.Encoding_Stream;
--
-- The encoding stream manages a buffer that is used to hold the encoded data before it is
-- written to the target stream. The <tt>Initialize</tt> procedure must be called to indicate
-- the target stream, the size of the buffer and the encoding format to be used.
--
-- Encode.Initialize (Output => File'Access, Size => 4096, Format => "base64");
--
package Util.Streams.Buffered.Encoders is
pragma Preelaborate;
-- -----------------------
-- Encoding stream
-- -----------------------
-- The <b>Encoding_Stream</b> is an output stream which uses an encoder to
-- transform the data before writing it to the output. The transformer can
-- change the data by encoding it in Base64, Base16 or encrypting it.
type Encoding_Stream is limited new Util.Streams.Buffered.Output_Buffer_Stream with private;
-- Initialize the stream to write on the given stream.
-- An internal buffer is allocated for writing the stream.
procedure Initialize (Stream : in out Encoding_Stream;
Output : in Output_Stream_Access;
Size : in Natural;
Format : in String);
-- Close the sink.
overriding
procedure Close (Stream : in out Encoding_Stream);
-- Write the buffer array to the output stream.
overriding
procedure Write (Stream : in out Encoding_Stream;
Buffer : in Ada.Streams.Stream_Element_Array);
-- Flush the buffer by writing on the output stream.
-- Raises Data_Error if there is no output stream.
overriding
procedure Flush (Stream : in out Encoding_Stream);
private
type Encoding_Stream is limited new Util.Streams.Buffered.Output_Buffer_Stream with record
Transform : Util.Encoders.Transformer_Access;
end record;
-- Flush the stream and release the buffer.
overriding
procedure Finalize (Object : in out Encoding_Stream);
end Util.Streams.Buffered.Encoders;
|
reznikmm/matreshka | Ada | 3,858 | 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 Matreshka.ODF_Elements.Style.Default_Style;
package ODF.DOM.Elements.Style.Default_Style.Internals is
function Create
(Node : Matreshka.ODF_Elements.Style.Default_Style.Style_Default_Style_Access)
return ODF.DOM.Elements.Style.Default_Style.ODF_Style_Default_Style;
function Wrap
(Node : Matreshka.ODF_Elements.Style.Default_Style.Style_Default_Style_Access)
return ODF.DOM.Elements.Style.Default_Style.ODF_Style_Default_Style;
end ODF.DOM.Elements.Style.Default_Style.Internals;
|
jscparker/math_packages | Ada | 1,815 | ads | --
-- PACKAGE Chebychev_Quadrature
--
-- The package provides tables and procedures for Gaussian quadrature
-- based on Chebychev polynomials (Gaussian-Chebychev quadrature).
-- The number of points used in the quadrature (callocation points)
-- is the generic formal parameter: No_Of_Gauss_Points.
--
-- Usually not the best quadrature routine, but works well in special
-- cases.
--
-- Use the following fragment to calculate the definite integral
-- of a function F(X) in an interval (X_Starting, X_Final):
--
-- Find_Gauss_Nodes (X_Starting, X_Final, X_gauss);
--
-- for I in Gauss_Index loop
-- F_val(I) := F (X_gauss(I));
-- end loop;
-- -- Evaluate the function at the callocation points just once.
--
-- Get_Integral (F_val, X_Starting, X_Final, Area);
--
generic
type Real is digits <>;
No_Of_Gauss_Points : Positive;
with function Cos (X : Real) return Real is <>;
with function Sin (X : Real) return Real is <>;
package Chebychev_Quadrature is
type Gauss_Index is new Positive range 1 .. No_Of_Gauss_Points;
type Gauss_Values is array(Gauss_Index) of Real;
-- Plug X_Starting and X_Final into the following to get the
-- the points X_gauss at which the function to
-- be integrated must be evaluated:
procedure Find_Gauss_Nodes
(X_Starting : in Real;
X_Final : in Real;
X_gauss : out Gauss_Values);
type Function_Values is array(Gauss_Index) of Real;
-- Fill array F_val of this type with values function F:
--
-- for I in Gauss_Index loop
-- F_val(I) := F (X_gauss(I));
-- end loop;
procedure Get_Integral
(F_val : in Function_Values;
X_Starting : in Real;
X_Final : in Real;
Area : out Real);
end Chebychev_Quadrature;
|
reznikmm/matreshka | Ada | 4,735 | 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_Text.Relative_Tab_Stop_Position_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Relative_Tab_Stop_Position_Attribute_Node is
begin
return Self : Text_Relative_Tab_Stop_Position_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Relative_Tab_Stop_Position_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Relative_Tab_Stop_Position_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Relative_Tab_Stop_Position_Attribute,
Text_Relative_Tab_Stop_Position_Attribute_Node'Tag);
end Matreshka.ODF_Text.Relative_Tab_Stop_Position_Attributes;
|
mfkiwl/ewok-kernel-security-OS | Ada | 3,308 | ads | --
-- 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.tasks_shared; use ewok.tasks_shared;
with ewok.devices_shared; use ewok.devices_shared;
with ewok.exported.devices;
with ewok.exported.interrupts;
with soc.interrupts;
with soc.devmap;
with m4.mpu;
package ewok.devices
with spark_mode => off
is
type t_device_type is (DEV_TYPE_USER, DEV_TYPE_KERNEL);
type t_device_state is -- FIXME
(DEV_STATE_UNUSED,
DEV_STATE_RESERVED,
DEV_STATE_REGISTERED,
DEV_STATE_ENABLED);
type t_checked_user_device is new ewok.exported.devices.t_user_device;
type t_checked_user_device_access is access all t_checked_user_device;
type t_device is record
udev : aliased t_checked_user_device;
task_id : t_task_id := ID_UNUSED;
periph_id : soc.devmap.t_periph_id := soc.devmap.NO_PERIPH;
status : t_device_state := DEV_STATE_UNUSED;
end record;
registered_device : array (t_registered_device_id) of t_device;
procedure get_registered_device_entry
(dev_id : out t_device_id;
success : out boolean);
procedure release_registered_device_entry (dev_id : t_registered_device_id);
function get_task_from_id(dev_id : t_registered_device_id)
return t_task_id;
function get_user_device (dev_id : t_registered_device_id)
return t_checked_user_device_access
with inline_always;
function get_device_size (dev_id : t_registered_device_id)
return unsigned_32;
function get_device_addr (dev_id : t_registered_device_id)
return system_address;
function is_device_region_ro (dev_id : t_registered_device_id)
return boolean;
function get_device_subregions_mask (dev_id : t_registered_device_id)
return m4.mpu.t_subregion_mask;
function get_interrupt_config_from_interrupt
(interrupt : soc.interrupts.t_interrupt)
return ewok.exported.interrupts.t_interrupt_config_access;
procedure register_device
(task_id : in t_task_id;
udev : in ewok.exported.devices.t_user_device_access;
dev_id : out t_device_id;
success : out boolean);
procedure release_device
(task_id : in t_task_id;
dev_id : in t_registered_device_id;
success : out boolean);
procedure enable_device
(dev_id : in t_registered_device_id;
success : out boolean);
function sanitize_user_defined_device
(udev : in ewok.exported.devices.t_user_device_access;
task_id : in t_task_id)
return boolean;
end ewok.devices;
|
AdaCore/Ada_Drivers_Library | Ada | 3,390 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- 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 LCD_Std_Out;
package body Output_Utils is
-----------
-- Print --
-----------
procedure Print (X, Y : Natural; Msg : String) renames LCD_Std_Out.Put;
--------------------------
-- Print_Static_Content --
--------------------------
procedure Print_Static_Content (Stable : Angle_Rates) is
begin
-- print the constant offsets computed when the device is motionless
Print (0, Line1_Stable, "Stable X:" & Stable.X'Img);
Print (0, Line2_Stable, "Stable Y:" & Stable.Y'Img);
Print (0, Line3_Stable, "Stable Z:" & Stable.Z'Img);
-- print the static labels for the values after the offset is removed
Print (0, Line1_Adjusted, "Adjusted X:");
Print (0, Line2_Adjusted, "Adjusted Y:");
Print (0, Line3_Adjusted, "Adjusted Z:");
-- print the static labels for the final values
Print (0, Line1_Final, "X:");
Print (0, Line2_Final, "Y:");
Print (0, Line3_Final, "Z:");
end Print_Static_Content;
end Output_Utils;
|
AdaCore/ada-traits-containers | Ada | 537 | adb | --
-- Copyright (C) 2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
pragma Ada_2012;
with Conts.Lists.Definite_Unbounded;
with Support;
procedure Main is
package Int_Lists is new Conts.Lists.Definite_Unbounded (Integer);
package Tests is new Support
(Image => Integer'Image,
Elements => Int_Lists.Elements.Traits,
Storage => Int_Lists.Storage.Traits,
Lists => Int_Lists.Lists);
L1, L2 : Int_Lists.List;
begin
Tests.Test (L1, L2);
end Main;
|
jhumphry/PRNG_Zoo | Ada | 1,030 | ads | --
-- PRNG Zoo
-- Copyright (c) 2014 - 2015, James Humphry
--
-- Permission to use, copy, modify, and/or 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.
with AUnit.Test_Cases; use AUnit.Test_Cases;
generic
type P is new PRNG with private;
N : Positive := 64;
seed1 : U64 := 27182818;
seed2 : U64 := 31415926;
procedure PRNGTests_Suite.Sanity_Checks(T : in out Test_Case'Class);
|
osannolik/ada-canopen | Ada | 10,191 | adb | with ACO.Protocols.Service_Data;
package body ACO.Nodes.Remotes is
overriding
procedure Set_State
(This : in out Remote;
State : in ACO.States.State)
is
begin
This.NMT.Request_State (State);
-- If there is no heartbeat or node guarding, just assume the requested
-- state is correct...
if This.Od.Get_Heartbeat_Producer_Period = 0 then
This.NMT.Set (State);
end if;
end Set_State;
overriding
function Get_State
(This : Remote)
return ACO.States.State
is
begin
return This.NMT.Get;
end Get_State;
overriding
procedure Start
(This : in out Remote)
is
begin
This.Handler.Start;
end Start;
function Is_Complete
(This : SDO_Request)
return Boolean
is
begin
return ACO.SDO_Sessions.Is_Complete (This.Status);
end Is_Complete;
procedure Suspend_Until_Result
(This : in out SDO_Request;
Result : out SDO_Result)
is
begin
if This.Id in ACO.SDO_Sessions.Valid_Endpoint_Nr then
declare
Request : Request_Data renames This.Node.SDO.Requests (This.Id);
begin
Ada.Synchronous_Task_Control.Suspend_Until_True (Request.Suspension);
Result := Request.Status;
end;
else
Result := ACO.SDO_Sessions.Error;
end if;
end Suspend_Until_Result;
procedure Suspend_Until_Result
(This : in out SDO_Read_Request;
Result : out SDO_Result)
is
begin
SDO_Request (This).Suspend_Until_Result (Result);
case Result is
when ACO.SDO_Sessions.Complete =>
This.Get_Entry;
when ACO.SDO_Sessions.Error =>
This.Node.SDO.Clear (This.Id);
end case;
end Suspend_Until_Result;
procedure Get_Entry
(This : in out SDO_Read_Request)
is
begin
This.Node.SDO.Get_Read_Entry (This.Id, This.To_Entry.all);
This.Node.SDO.Clear (This.Id);
end Get_Entry;
function Status
(This : SDO_Request)
return SDO_Status
is
begin
if This.Id in ACO.SDO_Sessions.Valid_Endpoint_Nr then
return This.Node.SDO.Requests (This.Id).Status;
else
return ACO.SDO_Sessions.Error;
end if;
end Status;
procedure Write
(This : in out Remote;
Request : in out SDO_Write_Request'Class;
Index : in ACO.OD_Types.Object_Index;
Subindex : in ACO.OD_Types.Object_Subindex;
An_Entry : in ACO.OD_Types.Entry_Base'Class)
is
begin
This.SDO.Write_Remote_Entry
(Node => This.Id,
Index => Index,
Subindex => Subindex,
An_Entry => An_Entry,
Endpoint_Id => Request.Id);
if Request.Id in ACO.SDO_Sessions.Valid_Endpoint_Nr'Range then
declare
Req_Data : Request_Data renames This.SDO.Requests (Request.Id);
begin
Req_Data.Status := ACO.SDO_Sessions.Pending;
Req_Data.Operation := Write;
Ada.Synchronous_Task_Control.Set_False (Req_Data.Suspension);
end;
end if;
end Write;
overriding
procedure Write
(This : in out Remote;
Index : in ACO.OD_Types.Object_Index;
Subindex : in ACO.OD_Types.Object_Subindex;
An_Entry : in ACO.OD_Types.Entry_Base'Class)
is
Request : SDO_Write_Request (This'Access);
begin
This.Write (Request => Request,
Index => Index,
Subindex => Subindex,
An_Entry => An_Entry);
declare
Result : SDO_Result;
begin
Request.Suspend_Until_Result (Result);
end;
end Write;
overriding
procedure Read
(This : in out Remote;
Index : in ACO.OD_Types.Object_Index;
Subindex : in ACO.OD_Types.Object_Subindex;
To_Entry : out ACO.OD_Types.Entry_Base'Class)
is
Result : ACO.Nodes.Remotes.SDO_Result;
begin
This.Read
(Index => Index,
Subindex => Subindex,
Result => Result,
To_Entry => To_Entry);
case Result is
when ACO.SDO_Sessions.Complete =>
null;
when ACO.SDO_Sessions.Error =>
raise Failed_To_Read_Entry_Of_Node
with Result'Img & " index =" & Index'Img;
end case;
end Read;
procedure Read
(This : in out Remote;
Index : in ACO.OD_Types.Object_Index;
Subindex : in ACO.OD_Types.Object_Subindex;
Result : out ACO.Nodes.Remotes.SDO_Result;
To_Entry : out ACO.OD_Types.Entry_Base'Class)
is
Request : ACO.Nodes.Remotes.SDO_Read_Request
(This'Access, To_Entry'Access);
begin
This.Read
(Request => Request,
Index => Index,
Subindex => Subindex);
Request.Suspend_Until_Result (Result);
end Read;
procedure Read
(This : in out Remote;
Request : in out SDO_Read_Request'Class;
Index : in ACO.OD_Types.Object_Index;
Subindex : in ACO.OD_Types.Object_Subindex)
is
begin
This.SDO.Read_Remote_Entry
(Node => This.Id,
Index => Index,
Subindex => Subindex,
Endpoint_Id => Request.Id);
if Request.Id in ACO.SDO_Sessions.Valid_Endpoint_Nr'Range then
declare
Req_Data : Request_Data renames This.SDO.Requests (Request.Id);
begin
Req_Data.Status := ACO.SDO_Sessions.Pending;
Req_Data.Operation := Read;
Ada.Synchronous_Task_Control.Set_False (Req_Data.Suspension);
end;
end if;
end Read;
function Generic_Read
(This : in out Remote;
Index : ACO.OD_Types.Object_Index;
Subindex : ACO.OD_Types.Object_Subindex)
return Entry_T
is
An_Entry : aliased Entry_T;
Request : ACO.Nodes.Remotes.SDO_Read_Request
(This'Access, An_Entry'Access);
Result : ACO.Nodes.Remotes.SDO_Result;
begin
This.Read
(Request => Request,
Index => Index,
Subindex => Subindex);
Request.Suspend_Until_Result (Result);
if not Request.Is_Complete then
raise Failed_To_Read_Entry_Of_Node
with Result'Img & " index =" & Index'Img;
end if;
return An_Entry;
end Generic_Read;
procedure Set_Heartbeat_Timeout
(This : in out Remote;
Timeout : in Natural)
is
begin
This.NMT.Set_Heartbeat_Timeout (Timeout);
end Set_Heartbeat_Timeout;
procedure On_Message_Dispatch
(This : in out Remote;
Msg : in ACO.Messages.Message)
is
begin
if This.NMT.Is_Valid (Msg) then
This.NMT.Message_Received (Msg);
elsif This.EC.Is_Valid (Msg) then
This.EC.Message_Received (Msg);
elsif This.SDO.Is_Valid (Msg) then
This.SDO.Message_Received (Msg);
end if;
end On_Message_Dispatch;
procedure Periodic_Actions
(This : in out Remote;
T_Now : in Ada.Real_Time.Time)
is
begin
This.NMT.Periodic_Actions (T_Now);
This.SDO.Periodic_Actions (T_Now);
end Periodic_Actions;
overriding
procedure Result_Callback
(This : in out Remote_Client;
Session : in ACO.SDO_Sessions.SDO_Session;
Result : in ACO.SDO_Sessions.SDO_Result)
is
Request : Request_Data renames This.Requests (Session.Endpoint.Id);
begin
Request.Status := Result;
case Request.Operation is
when Write =>
This.Clear (Session.Endpoint.Id);
when Read =>
null;
end case;
Ada.Synchronous_Task_Control.Set_True (Request.Suspension);
This.Od.Events.Node_Events.Put
((Event => ACO.Events.SDO_Status_Update,
SDO_Status => (Endpoint_Id => Session.Endpoint.Id,
Result => Result)));
end Result_Callback;
overriding
function Tx_CAN_Id
(This : Remote_Client;
Parameter : ACO.SDO_Sessions.SDO_Parameters)
return ACO.Messages.Id_Type
is
(Parameter.CAN_Id_C2S);
overriding
function Rx_CAN_Id
(This : Remote_Client;
Parameter : ACO.SDO_Sessions.SDO_Parameters)
return ACO.Messages.Id_Type
is
(Parameter.CAN_Id_S2C);
overriding
function Get_Endpoint
(This : Remote_Client;
Rx_CAN_Id : ACO.Messages.Id_Type)
return ACO.SDO_Sessions.Endpoint_Type
is
use type ACO.Messages.Id_Type;
-- Clients always initiate a session and a remote client always use the
-- default mandatory Id's, meaning we should make sure we use the same
-- endpoint as when we sent the initial request...
Endpoint : constant ACO.SDO_Sessions.Endpoint_Type :=
This.Get_Endpoint (Server_Node => This.Id);
begin
if This.Rx_CAN_Id (Endpoint.Parameters) = Rx_CAN_Id then
return Endpoint;
else
return ACO.SDO_Sessions.No_Endpoint;
end if;
end Get_Endpoint;
overriding
function Get_Endpoint
(This : Remote_Client;
Server_Node : ACO.Messages.Node_Nr)
return ACO.SDO_Sessions.Endpoint_Type
is
use type ACO.Messages.Id_Type;
-- As a remote client we only know the OD of the server, therefore we can
-- use any of the C2S-Id's of the server.
-- But the mandatory Server-Rx-Id is a good choice...
Tx_CAN_Id : constant ACO.Messages.CAN_Id_Type :=
(As_Id => False,
Code => ACO.Protocols.Service_Data.SDO_C2S_Id,
Node => Server_Node);
I : ACO.SDO_Sessions.Endpoint_Nr :=
ACO.SDO_Sessions.Valid_Endpoint_Nr'First;
begin
for P of This.Od.Get_SDO_Server_Parameters loop
if This.Tx_CAN_Id (P) = Tx_CAN_Id.Id then
return (Id => I, Parameters => P);
end if;
I := ACO.SDO_Sessions.Endpoint_Nr'Succ (I);
end loop;
return ACO.SDO_Sessions.No_Endpoint;
end Get_Endpoint;
end ACO.Nodes.Remotes;
|
HeisenbugLtd/cache-sim | Ada | 849 | adb | ------------------------------------------------------------------------------
-- Copyright (C) 2012-2020 by Heisenbug Ltd.
--
-- 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);
package body Caches.Access_Patterns is
-----------------------------------------------------------------------------
-- End_Of_Pattern
-----------------------------------------------------------------------------
function End_Of_Pattern (This : in Pattern) return Boolean is
begin
return This.Length = This.Count;
end End_Of_Pattern;
end Caches.Access_Patterns;
|
stcarrez/ada-asf | Ada | 2,394 | ads | -----------------------------------------------------------------------
-- components-utils-escape -- Escape generated content produced by component children
-- Copyright (C) 2011, 2012, 2014, 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 ASF.Components.Core;
with ASF.Contexts.Faces;
with ASF.Contexts.Writer;
package ASF.Components.Utils.Escapes is
-- Name of the attribute that control the escape mode.
-- When the attribute is set to 'xml', the content is escaped using XML
-- escape rules. Otherwise, the content is escaped using Javascript rules.
ESCAPE_MODE_NAME : constant String := "mode";
-- ------------------------------
-- UIEscape
-- ------------------------------
-- The <b>UIEscape</b> component catches the rendering of child components to
-- perform specific escape actions on the content.
type UIEscape is new ASF.Components.Core.UIComponentBase with private;
-- Write the content that was collected by rendering the inner children.
-- Escape the content using Javascript escape rules.
procedure Write_Content (UI : in UIEscape;
Writer : in out Contexts.Writer.Response_Writer'Class;
Content : in String;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
-- Encode the children components in a local buffer.
overriding
procedure Encode_Children (UI : in UIEscape;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
private
type UIEscape is new ASF.Components.Core.UIComponentBase with null record;
end ASF.Components.Utils.Escapes;
|
zhmu/ananas | Ada | 3,920 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- ADA.STRINGS.TEXT_BUFFERS.FILES --
-- --
-- B o d y --
-- --
-- Copyright (C) 2020-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. --
-- --
------------------------------------------------------------------------------
package body Ada.Strings.Text_Buffers.Files is
procedure Put_UTF_8_Implementation
(Buffer : in out Root_Buffer_Type'Class;
Item : UTF_Encoding.UTF_8_String) is
Result : Integer;
begin
Result := OS.Write (File_Buffer (Buffer).FD,
Item (Item'First)'Address,
Item'Length);
if Result /= Item'Length then
raise Program_Error with OS.Errno_Message;
end if;
end Put_UTF_8_Implementation;
function Create_From_FD
(FD : System.OS_Lib.File_Descriptor;
Close_Upon_Finalization : Boolean := True) return File_Buffer
is
use OS;
begin
if FD = Invalid_FD then
raise Program_Error with OS.Errno_Message;
end if;
return Result : File_Buffer do
Result.FD := FD;
Result.Close_Upon_Finalization := Close_Upon_Finalization;
end return;
end Create_From_FD;
function Create_File (Name : String) return File_Buffer is
begin
return Create_From_FD (OS.Create_File (Name, Fmode => OS.Binary));
end Create_File;
procedure Finalize (Ref : in out Self_Ref) is
Success : Boolean;
use OS;
begin
if Ref.Self.FD /= OS.Invalid_FD
and then Ref.Self.Close_Upon_Finalization
then
Close (Ref.Self.FD, Success);
if not Success then
raise Program_Error with OS.Errno_Message;
end if;
end if;
Ref.Self.FD := OS.Invalid_FD;
end Finalize;
end Ada.Strings.Text_Buffers.Files;
|
AdaCore/ada-traits-containers | Ada | 1,182 | adb | --
-- Copyright (C) 2016-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
pragma Ada_2012;
package body Conts.Algorithms.SPARK is
----------
-- Find --
----------
function Find
(Self : Cursors.Container;
E : Getters.Element)
return Cursors.Cursor
with SPARK_Mode => Off
is
function Find_Impl is
new Conts.Algorithms.Find (Cursors, Getters, "=");
begin
return Find_Impl (Self, E);
end Find;
--------------
-- Contains --
--------------
function Contains
(Self : Cursors.Container;
E : Getters.Element)
return Boolean
with SPARK_Mode => Off
is
function Contains_Impl is
new Conts.Algorithms.Contains (Cursors, Getters, "=");
begin
return Contains_Impl (Self, E);
end Contains;
------------
-- Equals --
------------
function Equals (Left, Right : Cursors.Container) return Boolean
with SPARK_Mode => Off
is
function Equals_Impl is
new Conts.Algorithms.Equals (Cursors, Getters, "=");
begin
return Equals_Impl (Left, Right);
end Equals;
end Conts.Algorithms.SPARK;
|
stcarrez/ada-awa | Ada | 88,775 | adb | -----------------------------------------------------------------------
-- AWA.Blogs.Models -- AWA.Blogs.Models
-----------------------------------------------------------------------
-- File generated by Dynamo DO NOT MODIFY
-- Template used: templates/model/package-body.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 Ada.Unchecked_Deallocation;
with Util.Beans.Objects.Time;
with ASF.Events.Faces.Actions;
with AWA.Events.Action_Method;
pragma Warnings (On);
package body AWA.Blogs.Models is
pragma Style_Checks ("-mrIu");
pragma Warnings (Off, "formal parameter * is not referenced");
pragma Warnings (Off, "use clause for type *");
pragma Warnings (Off, "use clause for private type *");
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
function Blog_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => BLOG_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Blog_Key;
function Blog_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => BLOG_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Blog_Key;
function "=" (Left, Right : Blog_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Blog_Ref'Class;
Impl : out Blog_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Blog_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Blog_Ref) is
Impl : Blog_Access;
begin
Impl := new Blog_Impl;
Impl.Version := 0;
Impl.Create_Date := ADO.DEFAULT_TIME;
Impl.Update_Date := ADO.DEFAULT_TIME;
Impl.Format := Format_Type'First;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Blog
-- ----------------------------------------
procedure Set_Id (Object : in out Blog_Ref;
Value : in ADO.Identifier) is
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Blog_Ref)
return ADO.Identifier is
Impl : constant Blog_Access
:= Blog_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Name (Object : in out Blog_Ref;
Value : in String) is
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_String (Impl.all, 2, Impl.Name, Value);
end Set_Name;
procedure Set_Name (Object : in out Blog_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Unbounded_String (Impl.all, 2, Impl.Name, Value);
end Set_Name;
function Get_Name (Object : in Blog_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Blog_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Blog_Access
:= Blog_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
function Get_Version (Object : in Blog_Ref)
return Integer is
Impl : constant Blog_Access
:= Blog_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Uid (Object : in out Blog_Ref;
Value : in String) is
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_String (Impl.all, 4, Impl.Uid, Value);
end Set_Uid;
procedure Set_Uid (Object : in out Blog_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Unbounded_String (Impl.all, 4, Impl.Uid, Value);
end Set_Uid;
function Get_Uid (Object : in Blog_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Uid);
end Get_Uid;
function Get_Uid (Object : in Blog_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Blog_Access
:= Blog_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Uid;
end Get_Uid;
procedure Set_Create_Date (Object : in out Blog_Ref;
Value : in Ada.Calendar.Time) is
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 5, Impl.Create_Date, Value);
end Set_Create_Date;
function Get_Create_Date (Object : in Blog_Ref)
return Ada.Calendar.Time is
Impl : constant Blog_Access
:= Blog_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Create_Date;
end Get_Create_Date;
procedure Set_Update_Date (Object : in out Blog_Ref;
Value : in Ada.Calendar.Time) is
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 6, Impl.Update_Date, Value);
end Set_Update_Date;
function Get_Update_Date (Object : in Blog_Ref)
return Ada.Calendar.Time is
Impl : constant Blog_Access
:= Blog_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Update_Date;
end Get_Update_Date;
procedure Set_Url (Object : in out Blog_Ref;
Value : in String) is
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_String (Impl.all, 7, Impl.Url, Value);
end Set_Url;
procedure Set_Url (Object : in out Blog_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Unbounded_String (Impl.all, 7, Impl.Url, Value);
end Set_Url;
function Get_Url (Object : in Blog_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Url);
end Get_Url;
function Get_Url (Object : in Blog_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Blog_Access
:= Blog_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Url;
end Get_Url;
procedure Set_Format (Object : in out Blog_Ref;
Value : in Format_Type) is
procedure Set_Field_Discrete is
new ADO.Audits.Set_Field_Operation
(Format_Type,
Format_Type_Objects.To_Object);
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
Set_Field_Discrete (Impl.all, 8, Impl.Format, Value);
end Set_Format;
function Get_Format (Object : in Blog_Ref)
return Format_Type is
Impl : constant Blog_Access
:= Blog_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Format;
end Get_Format;
procedure Set_Default_Image_Url (Object : in out Blog_Ref;
Value : in String) is
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_String (Impl.all, 9, Impl.Default_Image_Url, Value);
end Set_Default_Image_Url;
procedure Set_Default_Image_Url (Object : in out Blog_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Unbounded_String (Impl.all, 9, Impl.Default_Image_Url, Value);
end Set_Default_Image_Url;
function Get_Default_Image_Url (Object : in Blog_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Default_Image_Url);
end Get_Default_Image_Url;
function Get_Default_Image_Url (Object : in Blog_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Blog_Access
:= Blog_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Default_Image_Url;
end Get_Default_Image_Url;
procedure Set_Workspace (Object : in out Blog_Ref;
Value : in AWA.Workspaces.Models.Workspace_Ref'Class) is
Impl : Blog_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 10, Impl.Workspace, Value);
end Set_Workspace;
function Get_Workspace (Object : in Blog_Ref)
return AWA.Workspaces.Models.Workspace_Ref'Class is
Impl : constant Blog_Access
:= Blog_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Workspace;
end Get_Workspace;
-- Copy of the object.
procedure Copy (Object : in Blog_Ref;
Into : in out Blog_Ref) is
Result : Blog_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Blog_Access
:= Blog_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Blog_Access
:= new Blog_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Name := Impl.Name;
Copy.Version := Impl.Version;
Copy.Uid := Impl.Uid;
Copy.Create_Date := Impl.Create_Date;
Copy.Update_Date := Impl.Update_Date;
Copy.Url := Impl.Url;
Copy.Format := Impl.Format;
Copy.Default_Image_Url := Impl.Default_Image_Url;
Copy.Workspace := Impl.Workspace;
end;
end if;
Into := Result;
end Copy;
overriding
procedure Find (Object : in out Blog_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Blog_Access := new Blog_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Blog_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Blog_Access := new Blog_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Blog_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Blog_Access := new Blog_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Reload (Object : in out Blog_Ref;
Session : in out ADO.Sessions.Session'Class;
Updated : out Boolean) is
Result : ADO.Objects.Object_Record_Access;
Impl : Blog_Access;
Query : ADO.SQL.Query;
Id : ADO.Identifier;
begin
if Object.Is_Null then
raise ADO.Objects.NULL_ERROR;
end if;
Object.Prepare_Modify (Result);
Impl := Blog_Impl (Result.all)'Access;
Id := ADO.Objects.Get_Key_Value (Impl.all);
Query.Bind_Param (Position => 1, Value => Id);
Query.Bind_Param (Position => 2, Value => Impl.Version);
Query.Set_Filter ("id = ? AND version != ?");
declare
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, BLOG_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Updated := True;
Impl.Load (Stmt, Session);
else
Updated := False;
end if;
end;
end Reload;
overriding
procedure Save (Object : in out Blog_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Blog_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
overriding
procedure Delete (Object : in out Blog_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
overriding
procedure Destroy (Object : access Blog_Impl) is
type Blog_Impl_Ptr is access all Blog_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Blog_Impl, Blog_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Blog_Impl_Ptr := Blog_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
overriding
procedure Find (Object : in out Blog_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, BLOG_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Blog_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
overriding
procedure Save (Object : in out Blog_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (BLOG_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_1_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_1_NAME, -- uid
Value => Object.Uid);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_1_NAME, -- create_date
Value => Object.Create_Date);
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (6) then
Stmt.Save_Field (Name => COL_5_1_NAME, -- update_date
Value => Object.Update_Date);
Object.Clear_Modified (6);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_1_NAME, -- url
Value => Object.Url);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_1_NAME, -- format
Value => Integer (Format_Type'Enum_Rep (Object.Format)));
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_1_NAME, -- default_image_url
Value => Object.Default_Image_Url);
Object.Clear_Modified (9);
end if;
if Object.Is_Modified (10) then
Stmt.Save_Field (Name => COL_9_1_NAME, -- workspace_id
Value => Object.Workspace);
Object.Clear_Modified (10);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
ADO.Audits.Save (Object, Session);
end;
end if;
end Save;
overriding
procedure Create (Object : in out Blog_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (BLOG_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_1_NAME, -- name
Value => Object.Name);
Query.Save_Field (Name => COL_2_1_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_3_1_NAME, -- uid
Value => Object.Uid);
Query.Save_Field (Name => COL_4_1_NAME, -- create_date
Value => Object.Create_Date);
Query.Save_Field (Name => COL_5_1_NAME, -- update_date
Value => Object.Update_Date);
Query.Save_Field (Name => COL_6_1_NAME, -- url
Value => Object.Url);
Query.Save_Field (Name => COL_7_1_NAME, -- format
Value => Integer (Format_Type'Enum_Rep (Object.Format)));
Query.Save_Field (Name => COL_8_1_NAME, -- default_image_url
Value => Object.Default_Image_Url);
Query.Save_Field (Name => COL_9_1_NAME, -- workspace_id
Value => Object.Workspace);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
ADO.Audits.Save (Object, Session);
end Create;
overriding
procedure Delete (Object : in out Blog_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (BLOG_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Blog_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Blog_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Blog_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "name" then
return Util.Beans.Objects.To_Object (Impl.Name);
elsif Name = "uid" then
return Util.Beans.Objects.To_Object (Impl.Uid);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Create_Date);
elsif Name = "update_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Update_Date);
elsif Name = "url" then
return Util.Beans.Objects.To_Object (Impl.Url);
elsif Name = "format" then
return Format_Type_Objects.To_Object (Impl.Format);
elsif Name = "default_image_url" then
return Util.Beans.Objects.To_Object (Impl.Default_Image_Url);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
procedure List (Object : in out Blog_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, BLOG_DEF'Access);
begin
Stmt.Execute;
Blog_Vectors.Clear (Object);
while Stmt.Has_Elements loop
declare
Item : Blog_Ref;
Impl : constant Blog_Access := new Blog_Impl;
begin
Impl.Load (Stmt, Session);
ADO.Objects.Set_Object (Item, Impl.all'Access);
Object.Append (Item);
end;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Blog_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Name := Stmt.Get_Unbounded_String (1);
Object.Uid := Stmt.Get_Unbounded_String (3);
Object.Create_Date := Stmt.Get_Time (4);
Object.Update_Date := Stmt.Get_Time (5);
Object.Url := Stmt.Get_Unbounded_String (6);
Object.Format := Format_Type'Enum_Val (Stmt.Get_Integer (7));
Object.Default_Image_Url := Stmt.Get_Unbounded_String (8);
if not Stmt.Is_Null (9) then
Object.Workspace.Set_Key_Value (Stmt.Get_Identifier (9), Session);
end if;
Object.Version := Stmt.Get_Integer (2);
ADO.Objects.Set_Created (Object);
end Load;
function Post_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => POST_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Post_Key;
function Post_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => POST_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Post_Key;
function "=" (Left, Right : Post_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Post_Ref'Class;
Impl : out Post_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Post_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Post_Ref) is
Impl : Post_Access;
begin
Impl := new Post_Impl;
Impl.Create_Date := ADO.DEFAULT_TIME;
Impl.Version := 0;
Impl.Publish_Date.Is_Null := True;
Impl.Status := Post_Status_Type'First;
Impl.Allow_Comments := False;
Impl.Read_Count := 0;
Impl.Format := Format_Type'First;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Post
-- ----------------------------------------
procedure Set_Id (Object : in out Post_Ref;
Value : in ADO.Identifier) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Post_Ref)
return ADO.Identifier is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Title (Object : in out Post_Ref;
Value : in String) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_String (Impl.all, 2, Impl.Title, Value);
end Set_Title;
procedure Set_Title (Object : in out Post_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Unbounded_String (Impl.all, 2, Impl.Title, Value);
end Set_Title;
function Get_Title (Object : in Post_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Title);
end Get_Title;
function Get_Title (Object : in Post_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Title;
end Get_Title;
procedure Set_Text (Object : in out Post_Ref;
Value : in String) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Text, Value);
end Set_Text;
procedure Set_Text (Object : in out Post_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Text, Value);
end Set_Text;
function Get_Text (Object : in Post_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Text);
end Get_Text;
function Get_Text (Object : in Post_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Text;
end Get_Text;
procedure Set_Create_Date (Object : in out Post_Ref;
Value : in Ada.Calendar.Time) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 4, Impl.Create_Date, Value);
end Set_Create_Date;
function Get_Create_Date (Object : in Post_Ref)
return Ada.Calendar.Time is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Create_Date;
end Get_Create_Date;
procedure Set_Uri (Object : in out Post_Ref;
Value : in String) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_String (Impl.all, 5, Impl.Uri, Value);
end Set_Uri;
procedure Set_Uri (Object : in out Post_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Unbounded_String (Impl.all, 5, Impl.Uri, Value);
end Set_Uri;
function Get_Uri (Object : in Post_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Uri);
end Get_Uri;
function Get_Uri (Object : in Post_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Uri;
end Get_Uri;
function Get_Version (Object : in Post_Ref)
return Integer is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Publish_Date (Object : in out Post_Ref;
Value : in ADO.Nullable_Time) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Time (Impl.all, 7, Impl.Publish_Date, Value);
end Set_Publish_Date;
function Get_Publish_Date (Object : in Post_Ref)
return ADO.Nullable_Time is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Publish_Date;
end Get_Publish_Date;
procedure Set_Status (Object : in out Post_Ref;
Value : in Post_Status_Type) is
procedure Set_Field_Discrete is
new ADO.Audits.Set_Field_Operation
(Post_Status_Type,
Post_Status_Type_Objects.To_Object);
Impl : Post_Access;
begin
Set_Field (Object, Impl);
Set_Field_Discrete (Impl.all, 8, Impl.Status, Value);
end Set_Status;
function Get_Status (Object : in Post_Ref)
return Post_Status_Type is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Status;
end Get_Status;
procedure Set_Allow_Comments (Object : in out Post_Ref;
Value : in Boolean) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Boolean (Impl.all, 9, Impl.Allow_Comments, Value);
end Set_Allow_Comments;
function Get_Allow_Comments (Object : in Post_Ref)
return Boolean is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Allow_Comments;
end Get_Allow_Comments;
procedure Set_Read_Count (Object : in out Post_Ref;
Value : in Integer) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 10, Impl.Read_Count, Value);
end Set_Read_Count;
function Get_Read_Count (Object : in Post_Ref)
return Integer is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Read_Count;
end Get_Read_Count;
procedure Set_Summary (Object : in out Post_Ref;
Value : in String) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_String (Impl.all, 11, Impl.Summary, Value);
end Set_Summary;
procedure Set_Summary (Object : in out Post_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Unbounded_String (Impl.all, 11, Impl.Summary, Value);
end Set_Summary;
function Get_Summary (Object : in Post_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Summary);
end Get_Summary;
function Get_Summary (Object : in Post_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Summary;
end Get_Summary;
procedure Set_Format (Object : in out Post_Ref;
Value : in Format_Type) is
procedure Set_Field_Discrete is
new ADO.Audits.Set_Field_Operation
(Format_Type,
Format_Type_Objects.To_Object);
Impl : Post_Access;
begin
Set_Field (Object, Impl);
Set_Field_Discrete (Impl.all, 12, Impl.Format, Value);
end Set_Format;
function Get_Format (Object : in Post_Ref)
return Format_Type is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Format;
end Get_Format;
procedure Set_Author (Object : in out Post_Ref;
Value : in AWA.Users.Models.User_Ref'Class) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 13, Impl.Author, Value);
end Set_Author;
function Get_Author (Object : in Post_Ref)
return AWA.Users.Models.User_Ref'Class is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Author;
end Get_Author;
procedure Set_Blog (Object : in out Post_Ref;
Value : in Blog_Ref'Class) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 14, Impl.Blog, Value);
end Set_Blog;
function Get_Blog (Object : in Post_Ref)
return Blog_Ref'Class is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Blog;
end Get_Blog;
procedure Set_Image (Object : in out Post_Ref;
Value : in AWA.Images.Models.Image_Ref'Class) is
Impl : Post_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 15, Impl.Image, Value);
end Set_Image;
function Get_Image (Object : in Post_Ref)
return AWA.Images.Models.Image_Ref'Class is
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Image;
end Get_Image;
-- Copy of the object.
procedure Copy (Object : in Post_Ref;
Into : in out Post_Ref) is
Result : Post_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Post_Access
:= Post_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Post_Access
:= new Post_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Title := Impl.Title;
Copy.Text := Impl.Text;
Copy.Create_Date := Impl.Create_Date;
Copy.Uri := Impl.Uri;
Copy.Version := Impl.Version;
Copy.Publish_Date := Impl.Publish_Date;
Copy.Status := Impl.Status;
Copy.Allow_Comments := Impl.Allow_Comments;
Copy.Read_Count := Impl.Read_Count;
Copy.Summary := Impl.Summary;
Copy.Format := Impl.Format;
Copy.Author := Impl.Author;
Copy.Blog := Impl.Blog;
Copy.Image := Impl.Image;
end;
end if;
Into := Result;
end Copy;
overriding
procedure Find (Object : in out Post_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Post_Access := new Post_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Post_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Post_Access := new Post_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Post_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Post_Access := new Post_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Reload (Object : in out Post_Ref;
Session : in out ADO.Sessions.Session'Class;
Updated : out Boolean) is
Result : ADO.Objects.Object_Record_Access;
Impl : Post_Access;
Query : ADO.SQL.Query;
Id : ADO.Identifier;
begin
if Object.Is_Null then
raise ADO.Objects.NULL_ERROR;
end if;
Object.Prepare_Modify (Result);
Impl := Post_Impl (Result.all)'Access;
Id := ADO.Objects.Get_Key_Value (Impl.all);
Query.Bind_Param (Position => 1, Value => Id);
Query.Bind_Param (Position => 2, Value => Impl.Version);
Query.Set_Filter ("id = ? AND version != ?");
declare
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, POST_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Updated := True;
Impl.Load (Stmt, Session);
else
Updated := False;
end if;
end;
end Reload;
overriding
procedure Save (Object : in out Post_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Post_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
overriding
procedure Delete (Object : in out Post_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
overriding
procedure Destroy (Object : access Post_Impl) is
type Post_Impl_Ptr is access all Post_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Post_Impl, Post_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Post_Impl_Ptr := Post_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
overriding
procedure Find (Object : in out Post_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, POST_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Post_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
overriding
procedure Save (Object : in out Post_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (POST_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_2_NAME, -- title
Value => Object.Title);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_2_NAME, -- text
Value => Object.Text);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_2_NAME, -- create_date
Value => Object.Create_Date);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_2_NAME, -- uri
Value => Object.Uri);
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_2_NAME, -- publish_date
Value => Object.Publish_Date);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_2_NAME, -- status
Value => Integer (Post_Status_Type'Enum_Rep (Object.Status)));
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_2_NAME, -- allow_comments
Value => Object.Allow_Comments);
Object.Clear_Modified (9);
end if;
if Object.Is_Modified (10) then
Stmt.Save_Field (Name => COL_9_2_NAME, -- read_count
Value => Object.Read_Count);
Object.Clear_Modified (10);
end if;
if Object.Is_Modified (11) then
Stmt.Save_Field (Name => COL_10_2_NAME, -- summary
Value => Object.Summary);
Object.Clear_Modified (11);
end if;
if Object.Is_Modified (12) then
Stmt.Save_Field (Name => COL_11_2_NAME, -- format
Value => Integer (Format_Type'Enum_Rep (Object.Format)));
Object.Clear_Modified (12);
end if;
if Object.Is_Modified (13) then
Stmt.Save_Field (Name => COL_12_2_NAME, -- author_id
Value => Object.Author);
Object.Clear_Modified (13);
end if;
if Object.Is_Modified (14) then
Stmt.Save_Field (Name => COL_13_2_NAME, -- blog_id
Value => Object.Blog);
Object.Clear_Modified (14);
end if;
if Object.Is_Modified (15) then
Stmt.Save_Field (Name => COL_14_2_NAME, -- image_id
Value => Object.Image);
Object.Clear_Modified (15);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
ADO.Audits.Save (Object, Session);
end;
end if;
end Save;
overriding
procedure Create (Object : in out Post_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (POST_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_2_NAME, -- title
Value => Object.Title);
Query.Save_Field (Name => COL_2_2_NAME, -- text
Value => Object.Text);
Query.Save_Field (Name => COL_3_2_NAME, -- create_date
Value => Object.Create_Date);
Query.Save_Field (Name => COL_4_2_NAME, -- uri
Value => Object.Uri);
Query.Save_Field (Name => COL_5_2_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_6_2_NAME, -- publish_date
Value => Object.Publish_Date);
Query.Save_Field (Name => COL_7_2_NAME, -- status
Value => Integer (Post_Status_Type'Enum_Rep (Object.Status)));
Query.Save_Field (Name => COL_8_2_NAME, -- allow_comments
Value => Object.Allow_Comments);
Query.Save_Field (Name => COL_9_2_NAME, -- read_count
Value => Object.Read_Count);
Query.Save_Field (Name => COL_10_2_NAME, -- summary
Value => Object.Summary);
Query.Save_Field (Name => COL_11_2_NAME, -- format
Value => Integer (Format_Type'Enum_Rep (Object.Format)));
Query.Save_Field (Name => COL_12_2_NAME, -- author_id
Value => Object.Author);
Query.Save_Field (Name => COL_13_2_NAME, -- blog_id
Value => Object.Blog);
Query.Save_Field (Name => COL_14_2_NAME, -- image_id
Value => Object.Image);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
ADO.Audits.Save (Object, Session);
end Create;
overriding
procedure Delete (Object : in out Post_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (POST_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Post_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Post_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Post_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "title" then
return Util.Beans.Objects.To_Object (Impl.Title);
elsif Name = "text" then
return Util.Beans.Objects.To_Object (Impl.Text);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Create_Date);
elsif Name = "uri" then
return Util.Beans.Objects.To_Object (Impl.Uri);
elsif Name = "publish_date" then
if Impl.Publish_Date.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.Time.To_Object (Impl.Publish_Date.Value);
end if;
elsif Name = "status" then
return Post_Status_Type_Objects.To_Object (Impl.Status);
elsif Name = "allow_comments" then
return Util.Beans.Objects.To_Object (Impl.Allow_Comments);
elsif Name = "read_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Read_Count));
elsif Name = "summary" then
return Util.Beans.Objects.To_Object (Impl.Summary);
elsif Name = "format" then
return Format_Type_Objects.To_Object (Impl.Format);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Post_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Title := Stmt.Get_Unbounded_String (1);
Object.Text := Stmt.Get_Unbounded_String (2);
Object.Create_Date := Stmt.Get_Time (3);
Object.Uri := Stmt.Get_Unbounded_String (4);
Object.Publish_Date := Stmt.Get_Nullable_Time (6);
Object.Status := Post_Status_Type'Enum_Val (Stmt.Get_Integer (7));
Object.Allow_Comments := Stmt.Get_Boolean (8);
Object.Read_Count := Stmt.Get_Integer (9);
Object.Summary := Stmt.Get_Unbounded_String (10);
Object.Format := Format_Type'Enum_Val (Stmt.Get_Integer (11));
if not Stmt.Is_Null (12) then
Object.Author.Set_Key_Value (Stmt.Get_Identifier (12), Session);
end if;
if not Stmt.Is_Null (13) then
Object.Blog.Set_Key_Value (Stmt.Get_Identifier (13), Session);
end if;
if not Stmt.Is_Null (14) then
Object.Image.Set_Key_Value (Stmt.Get_Identifier (14), Session);
end if;
Object.Version := Stmt.Get_Integer (5);
ADO.Objects.Set_Created (Object);
end Load;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Admin_Post_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "title" then
return Util.Beans.Objects.To_Object (From.Title);
elsif Name = "uri" then
return Util.Beans.Objects.To_Object (From.Uri);
elsif Name = "date" then
return Util.Beans.Objects.Time.To_Object (From.Date);
elsif Name = "status" then
return Post_Status_Type_Objects.To_Object (From.Status);
elsif Name = "read_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Read_Count));
elsif Name = "username" then
return Util.Beans.Objects.To_Object (From.Username);
elsif Name = "comment_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Comment_Count));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Admin_Post_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "title" then
Item.Title := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "uri" then
Item.Uri := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "date" then
Item.Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "status" then
Item.Status := Post_Status_Type_Objects.To_Value (Value);
elsif Name = "read_count" then
Item.Read_Count := Util.Beans.Objects.To_Integer (Value);
elsif Name = "username" then
Item.Username := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "comment_count" then
Item.Comment_Count := Util.Beans.Objects.To_Integer (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Admin_Post_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The Admin_Post_Info describes a post in the administration interface.
-- --------------------
procedure List (Object : in out Admin_Post_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Admin_Post_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Admin_Post_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Title := Stmt.Get_Unbounded_String (1);
Into.Uri := Stmt.Get_Unbounded_String (2);
Into.Date := Stmt.Get_Time (3);
Into.Status := Post_Status_Type'Enum_Val (Stmt.Get_Integer (4));
Into.Read_Count := Stmt.Get_Natural (5);
Into.Username := Stmt.Get_Unbounded_String (6);
Into.Comment_Count := Stmt.Get_Natural (7);
end Read;
begin
Stmt.Execute;
Admin_Post_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Blog_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "title" then
return Util.Beans.Objects.To_Object (From.Title);
elsif Name = "uid" then
return Util.Beans.Objects.To_Object (From.Uid);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (From.Create_Date);
elsif Name = "post_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Post_Count));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Blog_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "title" then
Item.Title := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "uid" then
Item.Uid := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "create_date" then
Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "post_count" then
Item.Post_Count := Util.Beans.Objects.To_Integer (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Blog_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The list of blogs.
-- --------------------
procedure List (Object : in out Blog_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Blog_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Blog_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Title := Stmt.Get_Unbounded_String (1);
Into.Uid := Stmt.Get_Unbounded_String (2);
Into.Create_Date := Stmt.Get_Time (3);
Into.Post_Count := Stmt.Get_Integer (4);
end Read;
begin
Stmt.Execute;
Blog_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Comment_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "post_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Post_Id));
elsif Name = "title" then
return Util.Beans.Objects.To_Object (From.Title);
elsif Name = "author" then
return Util.Beans.Objects.To_Object (From.Author);
elsif Name = "email" then
return Util.Beans.Objects.To_Object (From.Email);
elsif Name = "date" then
return Util.Beans.Objects.Time.To_Object (From.Date);
elsif Name = "status" then
return AWA.Comments.Models.Status_Type_Objects.To_Object (From.Status);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Comment_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "post_id" then
Item.Post_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "title" then
Item.Title := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "author" then
Item.Author := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "email" then
Item.Email := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "date" then
Item.Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "status" then
Item.Status := AWA.Comments.Models.Status_Type_Objects.To_Value (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Comment_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The comment information.
-- --------------------
procedure List (Object : in out Comment_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Comment_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Comment_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Post_Id := Stmt.Get_Identifier (1);
Into.Title := Stmt.Get_Unbounded_String (2);
Into.Author := Stmt.Get_Unbounded_String (3);
Into.Email := Stmt.Get_Unbounded_String (4);
Into.Date := Stmt.Get_Time (5);
Into.Status := AWA.Comments.Models.Status_Type'Enum_Val (Stmt.Get_Integer (6));
end Read;
begin
Stmt.Execute;
Comment_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Image_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "folder_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Folder_Id));
elsif Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (From.Create_Date);
elsif Name = "uri" then
return Util.Beans.Objects.To_Object (From.Uri);
elsif Name = "storage" then
return AWA.Storages.Models.Storage_Type_Objects.To_Object (From.Storage);
elsif Name = "mime_type" then
return Util.Beans.Objects.To_Object (From.Mime_Type);
elsif Name = "file_size" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.File_Size));
elsif Name = "width" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Width));
elsif Name = "height" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Height));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Image_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "folder_id" then
Item.Folder_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "create_date" then
Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "uri" then
Item.Uri := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "storage" then
Item.Storage := AWA.Storages.Models.Storage_Type_Objects.To_Value (Value);
elsif Name = "mime_type" then
Item.Mime_Type := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "file_size" then
Item.File_Size := Util.Beans.Objects.To_Integer (Value);
elsif Name = "width" then
Item.Width := Util.Beans.Objects.To_Integer (Value);
elsif Name = "height" then
Item.Height := Util.Beans.Objects.To_Integer (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Image_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The information about an image used in a wiki page.
-- --------------------
procedure List (Object : in out Image_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Image_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Image_Info) is
begin
Into.Folder_Id := Stmt.Get_Identifier (0);
Into.Id := Stmt.Get_Identifier (1);
Into.Create_Date := Stmt.Get_Time (2);
Into.Uri := Stmt.Get_Unbounded_String (3);
Into.Storage := AWA.Storages.Models.Storage_Type'Enum_Val (Stmt.Get_Integer (4));
Into.Mime_Type := Stmt.Get_Unbounded_String (5);
Into.File_Size := Stmt.Get_Integer (6);
Into.Width := Stmt.Get_Integer (7);
Into.Height := Stmt.Get_Integer (8);
end Read;
begin
Stmt.Execute;
Image_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Month_Stat_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "year" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Year));
elsif Name = "month" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Month));
elsif Name = "count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Count));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Month_Stat_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "year" then
Item.Year := Util.Beans.Objects.To_Integer (Value);
elsif Name = "month" then
Item.Month := Util.Beans.Objects.To_Integer (Value);
elsif Name = "count" then
Item.Count := Util.Beans.Objects.To_Integer (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Month_Stat_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The month statistics.
-- --------------------
procedure List (Object : in out Month_Stat_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Month_Stat_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Month_Stat_Info) is
begin
Into.Year := Stmt.Get_Natural (0);
Into.Month := Stmt.Get_Natural (1);
Into.Count := Stmt.Get_Natural (2);
end Read;
begin
Stmt.Execute;
Month_Stat_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Post_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "title" then
return Util.Beans.Objects.To_Object (From.Title);
elsif Name = "uri" then
return Util.Beans.Objects.To_Object (From.Uri);
elsif Name = "date" then
return Util.Beans.Objects.Time.To_Object (From.Date);
elsif Name = "username" then
return Util.Beans.Objects.To_Object (From.Username);
elsif Name = "format" then
return Format_Type_Objects.To_Object (From.Format);
elsif Name = "summary" then
return Util.Beans.Objects.To_Object (From.Summary);
elsif Name = "text" then
return Util.Beans.Objects.To_Object (From.Text);
elsif Name = "allow_comments" then
return Util.Beans.Objects.To_Object (From.Allow_Comments);
elsif Name = "comment_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Comment_Count));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Post_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "title" then
Item.Title := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "uri" then
Item.Uri := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "date" then
Item.Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "username" then
Item.Username := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "format" then
Item.Format := Format_Type_Objects.To_Value (Value);
elsif Name = "summary" then
Item.Summary := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "text" then
Item.Text := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "allow_comments" then
Item.Allow_Comments := Util.Beans.Objects.To_Boolean (Value);
elsif Name = "comment_count" then
Item.Comment_Count := Util.Beans.Objects.To_Integer (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Post_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The Post_Info describes a post to be displayed in the blog page
-- --------------------
procedure List (Object : in out Post_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Post_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Post_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Title := Stmt.Get_Unbounded_String (1);
Into.Uri := Stmt.Get_Unbounded_String (2);
Into.Date := Stmt.Get_Time (3);
Into.Username := Stmt.Get_Unbounded_String (4);
Into.Format := Format_Type'Enum_Val (Stmt.Get_Integer (5));
Into.Summary := Stmt.Get_Unbounded_String (6);
Into.Text := Stmt.Get_Unbounded_String (7);
Into.Allow_Comments := Stmt.Get_Boolean (8);
Into.Comment_Count := Stmt.Get_Natural (9);
end Read;
begin
Stmt.Execute;
Post_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
procedure Op_Create (Bean : in out Blog_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Create (Bean : in out Blog_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Blog_Bean'Class (Bean).Create (Outcome);
end Op_Create;
package Binding_Blog_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Blog_Bean,
Method => Op_Create,
Name => "create");
procedure Op_Create_Default (Bean : in out Blog_Bean;
Event : in AWA.Events.Module_Event'Class);
procedure Op_Create_Default (Bean : in out Blog_Bean;
Event : in AWA.Events.Module_Event'Class) is
begin
Blog_Bean'Class (Bean).Create_Default (Event);
end Op_Create_Default;
package Binding_Blog_Bean_2 is
new AWA.Events.Action_Method.Bind (Bean => Blog_Bean,
Method => Op_Create_Default,
Name => "create_default");
procedure Op_Load (Bean : in out Blog_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Blog_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Blog_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Blog_Bean_3 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Blog_Bean,
Method => Op_Load,
Name => "load");
Binding_Blog_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Blog_Bean_1.Proxy'Access,
2 => Binding_Blog_Bean_2.Proxy'Access,
3 => Binding_Blog_Bean_3.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Blog_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Blog_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Blog_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "name" then
Item.Set_Name (Util.Beans.Objects.To_String (Value));
elsif Name = "uid" then
Item.Set_Uid (Util.Beans.Objects.To_String (Value));
elsif Name = "create_date" then
Item.Set_Create_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "update_date" then
Item.Set_Update_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "url" then
Item.Set_Url (Util.Beans.Objects.To_String (Value));
elsif Name = "format" then
Item.Set_Format (Format_Type_Objects.To_Value (Value));
elsif Name = "default_image_url" then
Item.Set_Default_Image_Url (Util.Beans.Objects.To_String (Value));
end if;
end Set_Value;
procedure Op_Save (Bean : in out Post_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Save (Bean : in out Post_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Post_Bean'Class (Bean).Save (Outcome);
end Op_Save;
package Binding_Post_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Post_Bean,
Method => Op_Save,
Name => "save");
procedure Op_Delete (Bean : in out Post_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Delete (Bean : in out Post_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Post_Bean'Class (Bean).Delete (Outcome);
end Op_Delete;
package Binding_Post_Bean_2 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Post_Bean,
Method => Op_Delete,
Name => "delete");
procedure Op_Load (Bean : in out Post_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Post_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Post_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Post_Bean_3 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Post_Bean,
Method => Op_Load,
Name => "load");
procedure Op_Load_Admin (Bean : in out Post_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load_Admin (Bean : in out Post_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Post_Bean'Class (Bean).Load_Admin (Outcome);
end Op_Load_Admin;
package Binding_Post_Bean_4 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Post_Bean,
Method => Op_Load_Admin,
Name => "load_admin");
procedure Op_Setup (Bean : in out Post_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Setup (Bean : in out Post_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Post_Bean'Class (Bean).Setup (Outcome);
end Op_Setup;
package Binding_Post_Bean_5 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Post_Bean,
Method => Op_Setup,
Name => "setup");
procedure Op_Publish (Bean : in out Post_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Publish (Bean : in out Post_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Post_Bean'Class (Bean).Publish (Outcome);
end Op_Publish;
package Binding_Post_Bean_6 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Post_Bean,
Method => Op_Publish,
Name => "publish");
Binding_Post_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Post_Bean_1.Proxy'Access,
2 => Binding_Post_Bean_2.Proxy'Access,
3 => Binding_Post_Bean_3.Proxy'Access,
4 => Binding_Post_Bean_4.Proxy'Access,
5 => Binding_Post_Bean_5.Proxy'Access,
6 => Binding_Post_Bean_6.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Post_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Post_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Post_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "title" then
Item.Set_Title (Util.Beans.Objects.To_String (Value));
elsif Name = "text" then
Item.Set_Text (Util.Beans.Objects.To_String (Value));
elsif Name = "create_date" then
Item.Set_Create_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "uri" then
Item.Set_Uri (Util.Beans.Objects.To_String (Value));
elsif Name = "publish_date" then
if Util.Beans.Objects.Is_Null (Value) then
Item.Set_Publish_Date (ADO.Nullable_Time '(Is_Null => True, others => <>));
else
Item.Set_Publish_Date (ADO.Nullable_Time '(Is_Null => False,
Value => Util.Beans.Objects.Time.To_Time (Value)));
end if;
elsif Name = "status" then
Item.Set_Status (Post_Status_Type_Objects.To_Value (Value));
elsif Name = "allow_comments" then
Item.Set_Allow_Comments (Util.Beans.Objects.To_Boolean (Value));
elsif Name = "read_count" then
Item.Set_Read_Count (Util.Beans.Objects.To_Integer (Value));
elsif Name = "summary" then
Item.Set_Summary (Util.Beans.Objects.To_String (Value));
elsif Name = "format" then
Item.Set_Format (Format_Type_Objects.To_Value (Value));
end if;
end Set_Value;
procedure Op_Load (Bean : in out Post_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Post_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Post_List_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Post_List_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Post_List_Bean,
Method => Op_Load,
Name => "load");
Binding_Post_List_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Post_List_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Post_List_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Post_List_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Post_List_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "tag" then
return Util.Beans.Objects.To_Object (From.Tag);
elsif Name = "page" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page));
elsif Name = "count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Count));
elsif Name = "page_size" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Size));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Post_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "tag" then
Item.Tag := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "page" then
Item.Page := Util.Beans.Objects.To_Integer (Value);
elsif Name = "count" then
Item.Count := Util.Beans.Objects.To_Integer (Value);
elsif Name = "page_size" then
Item.Page_Size := Util.Beans.Objects.To_Integer (Value);
end if;
end Set_Value;
procedure Op_Load (Bean : in out Stat_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Stat_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Stat_List_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Stat_List_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Stat_List_Bean,
Method => Op_Load,
Name => "load");
Binding_Stat_List_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Stat_List_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Stat_List_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Stat_List_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Stat_List_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "blog_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Blog_Id));
elsif Name = "post_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Post_Id));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Stat_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "blog_id" then
Item.Blog_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "post_id" then
Item.Post_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
end if;
end Set_Value;
end AWA.Blogs.Models;
|
AdaCore/libadalang | Ada | 127 | ads | package X is
type Read_Bytes_Proc is access procedure (Bytes : String);
procedure Load(Read : Read_Bytes_Proc);
end X;
|
burratoo/Acton | Ada | 2,267 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK COMPONENTS --
-- --
-- OAK.AGENT.TASKS.ACTIVATION --
-- --
-- Copyright (C) 2011-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
-- This package handles task activation.
package Oak.Agent.Tasks.Activation with Preelaborate is
procedure Continue_Activation
(Activator : in Task_Id;
Next_Task_To_Run : out Task_Id);
-- Continues the activation process.
-- The procedure will select an unactivated task once each call until all
-- the tasks in the list have been activated, in which case the Activator
-- task will be selected to run. If a task terminates instead of
-- successfully activating, all tasks are terminated.
procedure Finish_Activation
(Activator : in Task_Id);
-- Called when all tasks on the activation chain have been activated.
-- Releases the tasks on the chain (i.e. they get added to their scheduler
-- agents) and the Activator is allowed to continue on its merry way.
procedure Purge_Activation_List
(Activator : in Task_Id;
Activation_List : in Task_List);
-- Called when a task within the activation list fails at either its
-- elaboration or activation. Causes any storage associated with the tasks
-- to be deallocated.
procedure Start_Activation
(Activator : in Task_Id;
Activation_List : in Task_List);
-- Starts the activation of a list of tasks within the activation list. The
-- task that is activating a set of tasks contained within the activation
-- chain is called the Activator.
end Oak.Agent.Tasks.Activation;
|
persan/midnightsun-ctf-LoveLacedLetter | Ada | 288 | ads | with Posix;
generic
with procedure Encode (Source_File_Name : Posix.C_String;
Output_File_Name : Posix.C_String;
Offset : Natural;
Text : String) is <>;
procedure Hide.Encode_Generic;
|
AdaCore/Ada_Drivers_Library | Ada | 3,957 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- This package handles the Hershey font format.
with Interfaces; use Interfaces;
with HAL; use HAL;
package Hershey_Fonts is
type Font_Desc is access constant String;
type Hershey_Font is private;
type Glyph_Index is private;
function Read (Fnt : Font_Desc) return Hershey_Font;
procedure Read (Fnt : Font_Desc;
Ret : out Hershey_Font);
function Strlen (S : String;
Fnt : Hershey_Font;
Height : Natural) return Natural;
generic
with procedure Draw_Line
(X0, Y0, X1, Y1 : Natural;
Width : Positive);
procedure Draw_Glyph
(Fnt : Hershey_Font;
C : Character;
X : in out Natural;
Y : Natural;
Height : Natural;
Bold : Boolean);
private
type Coord is record
X : Interfaces.Integer_8;
Y : Interfaces.Integer_8;
end record with Size => 16;
Raise_Pen : constant Coord := (others => Integer_8'First);
type Coord_Array is array (Positive range <>) of Coord
with Component_Size => 16;
type Glyph is record
Vertices : Natural;
Width : UInt8;
Height : UInt8;
Coords : Coord_Array (1 .. 120);
end record with Pack;
type Glyph_Index is new Positive range 1 .. 96;
type Glyph_Array is array (Glyph_Index) of Glyph;
type Hershey_Font is record
Number_Of_Glyphs : Glyph_Index;
Glyphs : Glyph_Array;
Font_Height : UInt8;
Baseline : UInt8;
end record;
end Hershey_Fonts;
|
reznikmm/matreshka | Ada | 3,987 | 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.Style_Display_Attributes;
package Matreshka.ODF_Style.Display_Attributes is
type Style_Display_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Display_Attributes.ODF_Style_Display_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Display_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Display_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Display_Attributes;
|
rguilloteau/pok | Ada | 1,368 | ads | -- 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
-- ---------------------------------------------------------------------------
-- --
-- TIME constant and type definitions and management services --
-- --
-- ---------------------------------------------------------------------------
package APEX.Timing is
procedure Timed_Wait
(Delay_Time : in System_Time_Type;
Return_Code : out Return_Code_Type);
procedure Periodic_Wait (Return_Code : out Return_Code_Type);
procedure Get_Time
(System_Time : out System_Time_Type;
Return_Code : out Return_Code_Type);
procedure Replenish
(Budget_Time : in System_Time_Type;
Return_Code : out Return_Code_Type);
-- POK BINDINGS
pragma Import (C, Timed_Wait, "TIMED_WAIT");
pragma Import (C, Periodic_Wait, "PERIODIC_WAIT");
pragma Import (C, Get_Time, "GET_TIME");
pragma Import (C, Replenish, "REPLENISH");
-- END OF POK BINDINGS
end Apex.Timing;
|
reznikmm/matreshka | Ada | 5,915 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- 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 package provides namespace builder. It accepts root Schema_Node for
-- some namespace and constructs Namespace_Node by processing all owned and
-- imported components.
------------------------------------------------------------------------------
with Matreshka.XML_Schema.AST;
with Matreshka.XML_Schema.Visitors;
package Matreshka.XML_Schema.Namespace_Builders is
pragma Preelaborate;
type Namespace_Builder is
limited new Matreshka.XML_Schema.Visitors.Abstract_Visitor with private;
function Get_Namespace
(Self : Namespace_Builder'Class)
return Matreshka.XML_Schema.AST.Namespace_Access;
private
type Namespace_Builder is
limited new Matreshka.XML_Schema.Visitors.Abstract_Visitor with record
Namespace : Matreshka.XML_Schema.AST.Namespace_Access;
end record;
overriding procedure Enter_Attribute_Declaration
(Self : in out Namespace_Builder;
Node : not null Matreshka.XML_Schema.AST.Attribute_Declaration_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control);
overriding procedure Enter_Attribute_Group_Definition
(Self : in out Namespace_Builder;
Node :
not null Matreshka.XML_Schema.AST.Attribute_Group_Definition_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control);
overriding procedure Enter_Complex_Type_Definition
(Self : in out Namespace_Builder;
Node :
not null Matreshka.XML_Schema.AST.Complex_Type_Definition_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control);
overriding procedure Enter_Element_Declaration
(Self : in out Namespace_Builder;
Node : not null Matreshka.XML_Schema.AST.Element_Declaration_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control);
overriding procedure Enter_Model_Group_Definition
(Self : in out Namespace_Builder;
Node : not null Matreshka.XML_Schema.AST.Model_Group_Definition_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control);
overriding procedure Enter_Schema
(Self : in out Namespace_Builder;
Node : not null Matreshka.XML_Schema.AST.Schema_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control);
overriding procedure Enter_Simple_Type_Definition
(Self : in out Namespace_Builder;
Node : not null Matreshka.XML_Schema.AST.Simple_Type_Definition_Access;
Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control);
end Matreshka.XML_Schema.Namespace_Builders;
|
sungyeon/drake | Ada | 298 | ads | pragma License (Unrestricted);
-- Ada 2012
with System.Storage_Pools.Subpools;
procedure Ada.Unchecked_Deallocate_Subpool (
Subpool : in out System.Storage_Pools.Subpools.Subpool_Handle);
pragma Preelaborate (Ada.Unchecked_Deallocate_Subpool);
pragma Inline (Ada.Unchecked_Deallocate_Subpool);
|
reznikmm/matreshka | Ada | 24,923 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library 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$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_000F is
pragma Preelaborate;
Group_000F : aliased constant Core_Second_Stage
:= (16#00# => -- 0F00
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#01# .. 16#03# => -- 0F01 .. 0F03
(Other_Symbol, Neutral,
Other, Other, Other, Break_Before,
(Grapheme_Base => True,
others => False)),
16#04# => -- 0F04
(Other_Punctuation, Neutral,
Other, Other, Other, Break_Before,
(Grapheme_Base => True,
others => False)),
16#05# => -- 0F05
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#06# .. 16#07# => -- 0F06 .. 0F07
(Other_Punctuation, Neutral,
Other, Other, Other, Break_Before,
(Grapheme_Base => True,
others => False)),
16#08# => -- 0F08
(Other_Punctuation, Neutral,
Other, Other, Other, Glue,
(Terminal_Punctuation
| Grapheme_Base => True,
others => False)),
16#09# .. 16#0A# => -- 0F09 .. 0F0A
(Other_Punctuation, Neutral,
Other, Other, Other, Break_Before,
(Grapheme_Base => True,
others => False)),
16#0B# => -- 0F0B
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Grapheme_Base => True,
others => False)),
16#0C# => -- 0F0C
(Other_Punctuation, Neutral,
Other, Other, Other, Glue,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#0D# .. 16#11# => -- 0F0D .. 0F11
(Other_Punctuation, Neutral,
Other, Other, Other, Exclamation,
(Terminal_Punctuation
| Grapheme_Base => True,
others => False)),
16#12# => -- 0F12
(Other_Punctuation, Neutral,
Other, Other, Other, Glue,
(Terminal_Punctuation
| Grapheme_Base => True,
others => False)),
16#13# => -- 0F13
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#14# => -- 0F14
(Other_Punctuation, Neutral,
Other, Other, Other, Exclamation,
(Grapheme_Base => True,
others => False)),
16#15# .. 16#17# => -- 0F15 .. 0F17
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#18# .. 16#19# => -- 0F18 .. 0F19
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#1A# .. 16#1F# => -- 0F1A .. 0F1F
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#20# .. 16#29# => -- 0F20 .. 0F29
(Decimal_Number, Neutral,
Other, Numeric, Numeric, Numeric,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#2A# .. 16#33# => -- 0F2A .. 0F33
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#34# => -- 0F34
(Other_Symbol, Neutral,
Other, Other, Other, Break_After,
(Grapheme_Base => True,
others => False)),
16#35# => -- 0F35
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#36# => -- 0F36
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#37# => -- 0F37
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#38# => -- 0F38
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#39# => -- 0F39
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#3A# => -- 0F3A
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Grapheme_Base => True,
others => False)),
16#3B# => -- 0F3B
(Close_Punctuation, Neutral,
Other, Other, Close, Close_Punctuation,
(Grapheme_Base => True,
others => False)),
16#3C# => -- 0F3C
(Open_Punctuation, Neutral,
Other, Other, Close, Open_Punctuation,
(Grapheme_Base => True,
others => False)),
16#3D# => -- 0F3D
(Close_Punctuation, Neutral,
Other, Other, Close, Close_Punctuation,
(Grapheme_Base => True,
others => False)),
16#3E# .. 16#3F# => -- 0F3E .. 0F3F
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Diacritic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#40# .. 16#42# => -- 0F40 .. 0F42
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#43# => -- 0F43
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#44# .. 16#47# => -- 0F44 .. 0F47
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#48# => -- 0F48
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#49# .. 16#4C# => -- 0F49 .. 0F4C
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#4D# => -- 0F4D
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#4E# .. 16#51# => -- 0F4E .. 0F51
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#52# => -- 0F52
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#53# .. 16#56# => -- 0F53 .. 0F56
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#57# => -- 0F57
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#58# .. 16#5B# => -- 0F58 .. 0F5B
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#5C# => -- 0F5C
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#5D# .. 16#68# => -- 0F5D .. 0F68
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#69# => -- 0F69
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#6A# .. 16#6C# => -- 0F6A .. 0F6C
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#6D# .. 16#70# => -- 0F6D .. 0F70
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#73# => -- 0F73
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#75# .. 16#76# => -- 0F75 .. 0F76
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#77# => -- 0F77
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Deprecated
| Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#78# => -- 0F78
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#79# => -- 0F79
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Deprecated
| Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#7F# => -- 0F7F
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Break_After,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#81# => -- 0F81
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#82# .. 16#83# => -- 0F82 .. 0F83
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#84# => -- 0F84
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| Grapheme_Link
| ID_Continue
| XID_Continue => True,
others => False)),
16#85# => -- 0F85
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Grapheme_Base => True,
others => False)),
16#86# .. 16#87# => -- 0F86 .. 0F87
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#88# .. 16#8C# => -- 0F88 .. 0F8C
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#93# => -- 0F93
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#98# => -- 0F98
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#9D# => -- 0F9D
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#A2# => -- 0FA2
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#A7# => -- 0FA7
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#AC# => -- 0FAC
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#B9# => -- 0FB9
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#BD# => -- 0FBD
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#BE# .. 16#BF# => -- 0FBE .. 0FBF
(Other_Symbol, Neutral,
Other, Other, Other, Break_After,
(Grapheme_Base => True,
others => False)),
16#C0# .. 16#C5# => -- 0FC0 .. 0FC5
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#C6# => -- 0FC6
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#C7# .. 16#CC# => -- 0FC7 .. 0FCC
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#CD# => -- 0FCD
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#CE# .. 16#CF# => -- 0FCE .. 0FCF
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#D0# .. 16#D1# => -- 0FD0 .. 0FD1
(Other_Punctuation, Neutral,
Other, Other, Other, Break_Before,
(Grapheme_Base => True,
others => False)),
16#D2# => -- 0FD2
(Other_Punctuation, Neutral,
Other, Other, Other, Break_After,
(Grapheme_Base => True,
others => False)),
16#D3# => -- 0FD3
(Other_Punctuation, Neutral,
Other, Other, Other, Break_Before,
(Grapheme_Base => True,
others => False)),
16#D4# => -- 0FD4
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#D5# .. 16#D8# => -- 0FD5 .. 0FD8
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#D9# .. 16#DA# => -- 0FD9 .. 0FDA
(Other_Punctuation, Neutral,
Other, Other, Other, Glue,
(Grapheme_Base => True,
others => False)),
16#DB# .. 16#FF# => -- 0FDB .. 0FFF
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
others =>
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_000F;
|
JohnYang97/Space-Convoy | Ada | 12,315 | adb | -- Suggestions for packages which might be useful:
with Ada.Real_Time; use Ada.Real_Time;
-- with Ada.Text_IO; use Ada.Text_IO;
with Exceptions; use Exceptions;
-- with Real_Type; use Real_Type;
-- with Generic_Sliding_Statistics;
-- with Rotations; use Rotations;
with Vectors_3D; use Vectors_3D;
with Vehicle_Interface; use Vehicle_Interface;
with Vehicle_Message_Type; use Vehicle_Message_Type;
with Ada.Containers.Hashed_Maps;
with Swarm_Structures_Base; use Swarm_Structures_Base;
-- with Ada.Text_IO; use Ada.Text_IO;
-- Author : Wenjun Yang
-- u_id : u6251843
-- Discussing with Chenhao Tong, a student who is interested in distributed system design,
-- the overall design of system and basic algorithms used for coordination.
-- Discussing with Zhaoyu Feng (u6392260) and Yiluo Wei (u6227375) about the design and implementation of stage d.
package body Vehicle_Task_Type is
task body Vehicle_Task is
-- Vehicle_No of corresponding drone
Vehicle_No : Positive;
-- Decide whether the drone receives message before, true if the drone hasn't received any messages.
Empty_Message_Box : Boolean := True;
-- The message that will be sent by the drone
Message_Sent : Inter_Vehicle_Messages;
-- The message received by the drone (not useful if it is outdated)
Message_Received : Inter_Vehicle_Messages;
-- The message accepted by the drone (lastest message, contains the correct position of globe)
Message_Accepted : Inter_Vehicle_Messages;
-- Decide whether the drone needs charge. if so, then the drone goes to comparison.
First_Line : Boolean := False;
-- Decide whether the drone in a emergency mode. If so, the drone head to globe directly.
Second_Line : Boolean := False;
-- If the drone finds the globe, the parameter is set to true.
Find_Energy : Boolean := False;
-- Record the time when the drone finds the globe
Find_Energy_Time : Time;
-- Record the position of energy globe
Global_Pos : Vector_3D;
-- Record the vehicle_No and current energy level of other drones.
package My_Hash is new Ada.Containers.Hashed_Maps (Key_Type => Positive,
Element_Type => Vehicle_Charges,
Hash => ID_Hashed,
Equivalent_Keys => "=");
use My_Hash;
Charge_Map : My_Hash.Map;
-- Record the vehicle_No of live and dead vehicles.
Vehicle_No_Set,
Delete_No_Set : No_Set;
-- Return the minimum energy level of all the drones
function Minimum_Energy_Around return Vehicle_Charges is
min : Vehicle_Charges := Full_Charge;
begin
for pair in Charge_Map.Iterate loop
if Element (pair) <= min then
min := Element (pair);
end if;
end loop;
return min;
end Minimum_Energy_Around;
-- Return the Vehicle_No order of a specific drone in the live drone set
function Position_In_Set (No : Positive) return Integer is
Counter : Integer := 0;
begin
for value in Vehicle_No_Set.Iterate loop
if Element (value) < No then
Counter := Counter + 1;
end if;
end loop;
Counter := Counter + 1;
return Counter;
end Position_In_Set;
begin
-- You need to react to this call and provide your task_id.
-- You can e.g. employ the assigned vehicle number (Vehicle_No)
-- in communications with other vehicles.
accept Identify (Set_Vehicle_No : Positive; Local_Task_Id : out Task_Id) do
Vehicle_No := Set_Vehicle_No;
Local_Task_Id := Current_Task;
end Identify;
-- Replace the rest of this task with your own code.
-- Maybe synchronizing on an external event clock like "Wait_For_Next_Physics_Update",
-- yet you can synchronize on e.g. the real-time clock as well.
-- Without control this vehicle will go for its natural swarming instinct.
select
Flight_Termination.Stop;
then abort
Outer_task_loop : loop
declare
Globes : constant Energy_Globes := Energy_Globes_Around;
begin
Wait_For_Next_Physics_Update;
-- Define at what level of current charge, the drone start to charge and what level of current
-- charge, the drone is in emergency mode.
if Current_Charge <= 0.5 then
Second_Line := True;
elsif Current_Charge <= 0.85 then
First_Line := True;
end if;
-- Record the vehicle_No and current charge level of this drone
if Charge_Map.Contains (Vehicle_No) then
Charge_Map.Replace (Vehicle_No, Current_Charge);
else
Charge_Map.Insert (Vehicle_No, Current_Charge);
end if;
-- Record the vehicle_No of this drone, which represents the drone is still alive
if not Vehicle_No_Set.Contains (Vehicle_No) then
Vehicle_No_Set.Insert (Vehicle_No);
end if;
-- Message received part
while Messages_Waiting loop
-- Receive the message
Receive (Message_Received);
-- Record the id and current energy level of other drones
if Charge_Map.Contains (Message_Received.ID) then
Charge_Map.Replace (Message_Received.ID, Message_Received.My_Energy);
else
Charge_Map.Insert (Message_Received.ID, Message_Received.My_Energy);
end if;
-- Update the message of live and dead drones' information by combining the outside info
-- with my own info.
Vehicle_No_Set.Union (Message_Received.Exist_Neighbours_No);
Delete_No_Set.Union (Message_Received.Delete_Neighbours_No);
-- if the drone has not received any messgae, receive any message even the message is outdated.
if Empty_Message_Box then
-- Have received a message, the message box is not empty any more.
Empty_Message_Box := False;
Message_Accepted := Message_Received;
-- Obtain the position of globe
Global_Pos := Message_Accepted.Energy_Globe_Pos;
elsif not Empty_Message_Box then
-- if the drone has received a message, compare the time of new message and received message,
-- accept the new message if it is the latest one.
if Message_Accepted.Message_Send_Time <= Message_Received.Message_Send_Time then
Message_Accepted := Message_Received;
Global_Pos := Message_Accepted.Energy_Globe_Pos;
end if;
end if;
end loop;
-- Update the live drones set by deleting the dead drones' number.
Vehicle_No_Set.Difference (Delete_No_Set);
-- Find energy
-- Delete the position of globe if the info is received 3 seconds ago,
-- the action will guarantee that the drone will always try to find a
-- globe rather than depend on other drones.
if Find_Energy and then (Clock - Find_Energy_Time) >= Seconds (3) then
Find_Energy := False;
end if;
-- Detect globes
if Globes'Length > 0 then
if Globes'Length = 1 then
-- If there is a globe around, record the position and time when drone finds the globe.
Global_Pos := Globes (1).Position;
Find_Energy_Time := Clock;
else
-- If there is more than one globe around, always choose the closest globe.
Global_Pos := Globes (1).Position;
for Globe of Globes loop
if abs (Globe.Position - Position) < abs (Global_Pos - Position) then
Global_Pos := Globe.Position;
end if;
end loop;
Find_Energy_Time := Clock;
end if;
Find_Energy := True;
end if;
-- Message sent
-- send the message
Message_Sent := (ID => Vehicle_No,
Energy_Globe_Pos => Global_Pos,
Message_Send_Time => Clock,
Energy_Globe_Find => Find_Energy,
My_Energy => Current_Charge,
Exist_Neighbours_No => Vehicle_No_Set,
Delete_Neighbours_No => Delete_No_Set
);
Send (Message_Sent);
-- Stage D implementation, delete the vehicle_No of entra drones if the current vehicle
-- number is greater than Target_No_of_Elements
if Position_In_Set (Vehicle_No) > Target_No_of_Elements then
Delete_No_Set.Insert (Vehicle_No);
-- Go to die
exit Outer_task_loop;
end if;
-- if the drone is in emergency mode, it heads to the globe immediately.
if Second_Line then
-- Heading to destination
Set_Destination (Global_Pos);
-- In the largest speed
Set_Throttle (1.0);
elsif (not Second_Line and then First_Line and then Find_Energy)
or else (not Second_Line and then First_Line and then (not Find_Energy) and then Message_Accepted.Energy_Globe_Find)
-- if the drone needs charge but not in emergency and it finds the position of globe OR
-- it doesn't find the position but receives the position from other drones, it should prepare to attend comparison.
then
-- If its current charge is the lowest one among all the drones, the drone heads to globe.
if Current_Charge <= Minimum_Energy_Around then
Set_Destination (Global_Pos);
Set_Throttle (0.8);
else
-- otherwise, waiting for next round comparison
Set_Destination (Global_Pos);
Set_Throttle (0.2);
end if;
end if;
-- Update the information after the drone gets charged from the globe
if Current_Charge = 1.0 then
First_Line := False;
Second_Line := False;
Set_Throttle (0.2);
-- Sending messages to other drones when the drone finshed charging
Message_Sent := (ID => Vehicle_No,
Energy_Globe_Pos => Global_Pos,
Message_Send_Time => Clock,
Energy_Globe_Find => Find_Energy,
My_Energy => Current_Charge,
Exist_Neighbours_No => Vehicle_No_Set,
Delete_Neighbours_No => Delete_No_Set
);
Send (Message_Sent);
end if;
-- Clear the drone's charge list to get everything updated.
Charge_Map.Clear;
end;
end loop Outer_task_loop;
end select;
exception
when E : others => Show_Exception (E);
end Vehicle_Task;
end Vehicle_Task_Type;
|
hamadgin2/dd-wrt | Ada | 15,503 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000-2008,2018 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.9 $
-- $Date: 2018/07/07 23:33:16 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- TODO use Default_Character where appropriate
-- This is an Ada version of ncurses
-- I translated this because it tests the most features.
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Trace; use Terminal_Interface.Curses.Trace;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Latin_1;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Strings.Unbounded;
with ncurses2.util; use ncurses2.util;
with ncurses2.getch_test;
with ncurses2.attr_test;
with ncurses2.color_test;
with ncurses2.demo_panels;
with ncurses2.color_edit;
with ncurses2.slk_test;
with ncurses2.acs_display;
with ncurses2.acs_and_scroll;
with ncurses2.flushinp_test;
with ncurses2.test_sgr_attributes;
with ncurses2.menu_test;
with ncurses2.demo_pad;
with ncurses2.demo_forms;
with ncurses2.overlap_test;
with ncurses2.trace_set;
with ncurses2.getopt; use ncurses2.getopt;
package body ncurses2.m is
function To_trace (n : Integer) return Trace_Attribute_Set;
procedure usage;
procedure Set_Terminal_Modes;
function Do_Single_Test (c : Character) return Boolean;
function To_trace (n : Integer) return Trace_Attribute_Set is
a : Trace_Attribute_Set := (others => False);
m : Integer;
rest : Integer;
begin
m := n mod 2;
if 1 = m then
a.Times := True;
end if;
rest := n / 2;
m := rest mod 2;
if 1 = m then
a.Tputs := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Update := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Cursor_Move := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Character_Output := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Calls := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Virtual_Puts := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Input_Events := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.TTY_State := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Internal_Calls := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Character_Calls := True;
end if;
rest := rest / 2;
m := rest mod 2;
if 1 = m then
a.Termcap_TermInfo := True;
end if;
return a;
end To_trace;
-- these are type Stdscr_Init_Proc;
function rip_footer (
Win : Window;
Columns : Column_Count) return Integer;
pragma Convention (C, rip_footer);
function rip_footer (
Win : Window;
Columns : Column_Count) return Integer is
begin
Set_Background (Win, (Ch => ' ',
Attr => (Reverse_Video => True, others => False),
Color => 0));
Erase (Win);
Move_Cursor (Win, 0, 0);
Add (Win, "footer:" & Columns'Img & " columns");
Refresh_Without_Update (Win);
return 0; -- Curses_OK;
end rip_footer;
function rip_header (
Win : Window;
Columns : Column_Count) return Integer;
pragma Convention (C, rip_header);
function rip_header (
Win : Window;
Columns : Column_Count) return Integer is
begin
Set_Background (Win, (Ch => ' ',
Attr => (Reverse_Video => True, others => False),
Color => 0));
Erase (Win);
Move_Cursor (Win, 0, 0);
Add (Win, "header:" & Columns'Img & " columns");
-- 'Img is a GNAT extention
Refresh_Without_Update (Win);
return 0; -- Curses_OK;
end rip_header;
procedure usage is
-- type Stringa is access String;
use Ada.Strings.Unbounded;
-- tbl : constant array (Positive range <>) of Stringa := (
tbl : constant array (Positive range <>) of Unbounded_String
:= (
To_Unbounded_String ("Usage: ncurses [options]"),
To_Unbounded_String (""),
To_Unbounded_String ("Options:"),
To_Unbounded_String (" -a f,b set default-colors " &
"(assumed white-on-black)"),
To_Unbounded_String (" -d use default-colors if terminal " &
"supports them"),
To_Unbounded_String (" -e fmt specify format for soft-keys " &
"test (e)"),
To_Unbounded_String (" -f rip-off footer line " &
"(can repeat)"),
To_Unbounded_String (" -h rip-off header line " &
"(can repeat)"),
To_Unbounded_String (" -s msec specify nominal time for " &
"panel-demo (default: 1, to hold)"),
To_Unbounded_String (" -t mask specify default trace-level " &
"(may toggle with ^T)")
);
begin
for n in tbl'Range loop
Put_Line (Standard_Error, To_String (tbl (n)));
end loop;
-- exit(EXIT_FAILURE);
-- TODO should we use Set_Exit_Status and throw and exception?
end usage;
procedure Set_Terminal_Modes is begin
Set_Raw_Mode (SwitchOn => False);
Set_Cbreak_Mode (SwitchOn => True);
Set_Echo_Mode (SwitchOn => False);
Allow_Scrolling (Mode => True);
Use_Insert_Delete_Line (Do_Idl => True);
Set_KeyPad_Mode (SwitchOn => True);
end Set_Terminal_Modes;
nap_msec : Integer := 1;
function Do_Single_Test (c : Character) return Boolean is
begin
case c is
when 'a' =>
getch_test;
when 'b' =>
attr_test;
when 'c' =>
if not Has_Colors then
Cannot ("does not support color.");
else
color_test;
end if;
when 'd' =>
if not Has_Colors then
Cannot ("does not support color.");
elsif not Can_Change_Color then
Cannot ("has hardwired color values.");
else
color_edit;
end if;
when 'e' =>
slk_test;
when 'f' =>
acs_display;
when 'o' =>
demo_panels (nap_msec);
when 'g' =>
acs_and_scroll;
when 'i' =>
flushinp_test (Standard_Window);
when 'k' =>
test_sgr_attributes;
when 'm' =>
menu_test;
when 'p' =>
demo_pad;
when 'r' =>
demo_forms;
when 's' =>
overlap_test;
when 't' =>
trace_set;
when '?' =>
null;
when others => return False;
end case;
return True;
end Do_Single_Test;
command : Character;
my_e_param : Soft_Label_Key_Format := Four_Four;
assumed_colors : Boolean := False;
default_colors : Boolean := False;
default_fg : Color_Number := White;
default_bg : Color_Number := Black;
-- nap_msec was an unsigned long integer in the C version,
-- yet napms only takes an int!
c : Integer;
c2 : Character;
optind : Integer := 1; -- must be initialized to one.
optarg : getopt.stringa;
length : Integer;
tmpi : Integer;
package myio is new Ada.Text_IO.Integer_IO (Integer);
save_trace : Integer := 0;
save_trace_set : Trace_Attribute_Set;
function main return Integer is
begin
loop
Qgetopt (c, Argument_Count, Argument'Access,
"a:de:fhs:t:", optind, optarg);
exit when c = -1;
c2 := Character'Val (c);
case c2 is
when 'a' =>
-- Ada doesn't have scanf, it doesn't even have a
-- regular expression library.
assumed_colors := True;
myio.Get (optarg.all, Integer (default_fg), length);
myio.Get (optarg.all (length + 2 .. optarg.all'Length),
Integer (default_bg), length);
when 'd' =>
default_colors := True;
when 'e' =>
myio.Get (optarg.all, tmpi, length);
if tmpi > 3 then
usage;
return 1;
end if;
my_e_param := Soft_Label_Key_Format'Val (tmpi);
when 'f' =>
Rip_Off_Lines (-1, rip_footer'Access);
when 'h' =>
Rip_Off_Lines (1, rip_header'Access);
when 's' =>
myio.Get (optarg.all, nap_msec, length);
when 't' =>
myio.Get (optarg.all, save_trace, length);
when others =>
usage;
return 1;
end case;
end loop;
-- the C version had a bunch of macros here.
-- if (!isatty(fileno(stdin)))
-- isatty is not available in the standard Ada so skip it.
save_trace_set := To_trace (save_trace);
Trace_On (save_trace_set);
Init_Soft_Label_Keys (my_e_param);
Init_Screen;
Set_Background (Ch => (Ch => Blank,
Attr => Normal_Video,
Color => Color_Pair'First));
if Has_Colors then
Start_Color;
if default_colors then
Use_Default_Colors;
elsif assumed_colors then
Assume_Default_Colors (default_fg, default_bg);
end if;
end if;
Set_Terminal_Modes;
Save_Curses_Mode (Curses);
End_Windows;
-- TODO add macro #if blocks.
Put_Line ("Welcome to " & Curses_Version & ". Press ? for help.");
loop
Put_Line ("This is the ncurses main menu");
Put_Line ("a = keyboard and mouse input test");
Put_Line ("b = character attribute test");
Put_Line ("c = color test pattern");
Put_Line ("d = edit RGB color values");
Put_Line ("e = exercise soft keys");
Put_Line ("f = display ACS characters");
Put_Line ("g = display windows and scrolling");
Put_Line ("i = test of flushinp()");
Put_Line ("k = display character attributes");
Put_Line ("m = menu code test");
Put_Line ("o = exercise panels library");
Put_Line ("p = exercise pad features");
Put_Line ("q = quit");
Put_Line ("r = exercise forms code");
Put_Line ("s = overlapping-refresh test");
Put_Line ("t = set trace level");
Put_Line ("? = repeat this command summary");
Put ("> ");
Flush;
command := Ada.Characters.Latin_1.NUL;
-- get_input:
-- loop
declare
Ch : Character;
begin
Get (Ch);
-- TODO if read(ch) <= 0
-- TODO ada doesn't have an Is_Space function
command := Ch;
-- TODO if ch = '\n' or '\r' are these in Ada?
end;
-- end loop get_input;
declare
begin
if Do_Single_Test (command) then
Flush_Input;
Set_Terminal_Modes;
Reset_Curses_Mode (Curses);
Clear;
Refresh;
End_Windows;
if command = '?' then
Put_Line ("This is the ncurses capability tester.");
Put_Line ("You may select a test from the main menu by " &
"typing the");
Put_Line ("key letter of the choice (the letter to left " &
"of the =)");
Put_Line ("at the > prompt. The commands `x' or `q' will " &
"exit.");
end if;
-- continue; --why continue in the C version?
end if;
exception
when Curses_Exception => End_Windows;
end;
exit when command = 'q';
end loop;
Curses_Free_All;
return 0; -- TODO ExitProgram(EXIT_SUCCESS);
end main;
end ncurses2.m;
|
reznikmm/matreshka | Ada | 4,257 | adb | ------------------------------------------------------------------------------
-- --
-- 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 Matreshka.DOM_Nodes;
with XML.DOM.Elements.Internals;
package body ODF.DOM.Elements.Table.Table_Column.Internals is
------------
-- Create --
------------
function Create
(Node : Matreshka.ODF_Elements.Table.Table_Column.Table_Table_Column_Access)
return ODF.DOM.Elements.Table.Table_Column.ODF_Table_Table_Column is
begin
return
(XML.DOM.Elements.Internals.Create
(Matreshka.DOM_Nodes.Element_Access (Node)) with null record);
end Create;
----------
-- Wrap --
----------
function Wrap
(Node : Matreshka.ODF_Elements.Table.Table_Column.Table_Table_Column_Access)
return ODF.DOM.Elements.Table.Table_Column.ODF_Table_Table_Column is
begin
return
(XML.DOM.Elements.Internals.Wrap
(Matreshka.DOM_Nodes.Element_Access (Node)) with null record);
end Wrap;
end ODF.DOM.Elements.Table.Table_Column.Internals;
|
Rodeo-McCabe/orka | Ada | 1,409 | 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.
package GL.API.Uniforms.Doubles is
pragma Preelaborate;
use GL.Types.Doubles;
package Uniform1 is new Loader.Procedure_With_3_Params
("glProgramUniform1d", UInt, Int, Double);
package Uniform2v is new Loader.Procedure_With_4_Params
("glProgramUniform2dv", UInt, Int, Size, Vector2_Array);
package Uniform3v is new Loader.Procedure_With_4_Params
("glProgramUniform3dv", UInt, Int, Size, Vector3_Array);
package Uniform4v is new Loader.Procedure_With_4_Params
("glProgramUniform4dv", UInt, Int, Size, Vector4_Array);
package Uniform_Matrix4 is new Loader.Procedure_With_5_Params
("glProgramUniformMatrix4dv", UInt, Int, Size, Low_Level.Bool,
Matrix4_Array);
end GL.API.Uniforms.Doubles;
|
jorge-real/TTS-Ravenscar | Ada | 6,713 | adb | with System;
with Ada.Real_Time; use Ada.Real_Time;
with Time_Triggered_Scheduling; -- use Time_Triggered_Scheduling;
-- The following packages are for tracing and timing support
with Ada.Exceptions; use Ada.Exceptions;
with Logging_Support; use Logging_Support;
with Use_CPU; use Use_CPU;
with Ada.Text_IO; use Ada.Text_IO;
with Epoch_Support; use Epoch_Support;
with STM32.Board; use STM32.Board;
-- with Stats;
package body TTS_Example2 is
-- package MyStats is new Stats (5);
-- Instantiation of generic TT scheduler
No_Of_TT_Works : constant := 3;
package TT_Scheduler is new Time_Triggered_Scheduling (No_Of_TT_Works);
use TT_Scheduler;
function New_Slot (ms : Natural;
WId : Any_Work_Id;
Slot_Separation : Natural := 0) return Time_Slot;
function New_Slot (ms : Natural;
WId : Any_Work_Id;
Slot_Separation : Natural := 0) return Time_Slot is
Slot : Time_Slot;
begin
Slot.Slot_Duration := Milliseconds (ms);
Slot.Work_Id := WId;
Slot.Next_Slot_Separation := Milliseconds (Slot_Separation);
return Slot;
end New_Slot;
----------------------------
-- Time-triggered plans --
----------------------------
TTP1 : aliased Time_Triggered_Plan :=
(
New_Slot (30, 1),
New_Slot (70, Empty_Slot),
New_Slot (60, 2),
New_Slot (40, Empty_Slot),
New_Slot (90, 3),
New_Slot (10, Mode_Change_Slot)
);
TTP2 : aliased Time_Triggered_Plan :=
(
New_Slot (90, 3),
New_Slot (10, Empty_Slot),
New_Slot (60, 2),
New_Slot (40, Empty_Slot),
New_Slot (30, 1),
New_Slot (70, Mode_Change_Slot)
);
Null_Plan : aliased Time_Triggered_Plan :=
(
0 => New_Slot (100, Empty_Slot),
1 => New_Slot (100, Mode_Change_Slot)
);
-------------------
-- Task Patterns --
-------------------
-- A basic TT task
task type Basic_TT_Task (Work_Id : Regular_Work_Id;
Execution_Time_MS : Natural)
with Priority => System.Priority'Last is
end Basic_TT_Task;
task body Basic_TT_Task is
Work_To_Be_Done : constant Natural := Execution_Time_MS;
LED_To_Turn : User_LED;
When_Was_Released : Time;
-- Jitter : Time_Span;
begin
case Work_Id is
when 1 =>
LED_To_Turn := Red_LED;
when 2 =>
LED_To_Turn := Blue_LED;
when 3 =>
LED_To_Turn := Green_LED;
end case;
loop
Wait_For_Activation (Work_Id, When_Was_Released);
-- Jitter := Clock - When_Was_Released;
-- Log (No_Event, "|---> Jitter of Worker" & Integer'Image (Integer (Work_Id)) &
-- " = " & Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- MyStats.Register_Time(Integer(Work_Id)*2-1, Jitter);
Set (Probe_TT_Point);
Turn_On (LED_To_Turn);
Work (Work_To_Be_Done);
Turn_Off (LED_To_Turn);
Clear (Probe_TT_Point);
-- Log (Stop_Task, "W" & Character'Val (Character'Pos ('0') + Integer (Work_Id)));
end loop;
exception
when E : others =>
Put_Line ("Periodic worker W" & Character'Val (Character'Pos ('0') + Integer (Work_Id)) &
": " & Exception_Message (E));
end Basic_TT_Task;
-------------------------------
-- Priority scheduled tasks --
-------------------------------
task type DM_Task (Id : Natural; Period : Integer; Prio : System.Priority)
with Priority => Prio;
task body DM_Task is
Next : Time := Epoch;
Per : constant Time_Span := Milliseconds (Period);
Jitter : Time_Span;
begin
loop
delay until Next;
Jitter := Clock - Next;
Log (No_Event, "|---------> Jitter of DM Task" & Integer'Image (Id) &
" = " & Duration'Image (1000.0 * To_Duration (Jitter)) & " ms.");
-- MyStats.Register_Time(Integer(Id)*2-1, Jitter);
-- Log (Start_Task, "T" & Character'Val (Character'Pos ('0') + Integer (Id)));
Set (Probe_ET_Point);
Turn_On (Orange_LED);
Work (5);
Next := Next + Per;
Turn_Off (Orange_LED);
Clear (Probe_ET_Point);
-- Log (Stop_Task, "T" & Character'Val (Character'Pos ('0') + Integer (Id)));
end loop;
exception
when E : others =>
Put_Line (Exception_Message (E));
end DM_Task;
-- Event-triggered tasks
T4 : DM_Task (Id => 4, Period => 90, Prio => System.Priority'First + 1);
T5 : DM_Task (Id => 5, Period => 210, Prio => System.Priority'First);
-- Time-triggered tasks
-- Work_ID, Execution (ms)
Wk1 : Basic_TT_Task (1, 20);
Wk2 : Basic_TT_Task (2, 40);
Wk3 : Basic_TT_Task (3, 60);
procedure Main is
K : Integer := 0; -- Number of iterations in main loop
begin
-- Generate trace header --
Log (No_Event, "1 M1"); -- Nr of modes
Log (No_Event, "5"); -- Nr of works + Nr of tasks
Log (No_Event, "W1 9.200 9.200 0.0 10"); -- Task_name Period Deadline Phasing Priority
Log (No_Event, "W2 9.200 9.200 0.0 9");
Log (No_Event, "W3 9.200 9.200 0.0 8");
Log (No_Event, "T4 0.600 0.600 0.0 5");
Log (No_Event, "T5 0.800 0.800 0.0 4");
Log (No_Event, ":BODY");
delay until Epoch;
loop
Log (Mode_Change, "M1");
Set_Plan (TTP1'Access);
delay until Epoch + Seconds (K * 30 + 10);
Log (Mode_Change, "Null Plan");
Set_Plan (Null_Plan'Access);
delay until Epoch + Seconds (K * 30 + 15);
Log (Mode_Change, "M2");
Set_Plan (TTP2'Access);
delay until Epoch + Seconds (K * 30 + 25);
Log (Mode_Change, "Null Plan");
Set_Plan (Null_Plan'Access);
delay until Epoch + Seconds (K * 30 + 30);
K := K + 1;
end loop;
-- MyStats.Print_Stats;
-- delay until Time_Last;
end Main;
procedure Configure_Probe_Points;
procedure Configure_Probe_Points is
Configuration : GPIO_Port_Configuration;
begin
Configuration.Mode := Mode_Out;
Configuration.Output_Type := Push_Pull;
Configuration.Speed := Speed_50MHz;
Configuration.Resistors := Floating;
Enable_Clock (Probe_TT_Point & Probe_ET_Point);
Configure_IO (Probe_TT_Point & Probe_ET_Point, Configuration);
Clear (Probe_TT_Point);
Clear (Probe_ET_Point);
end Configure_Probe_Points;
begin
Configure_Probe_Points;
Initialize_LEDs;
All_LEDs_Off;
end TTS_Example2;
|
AdaCore/gpr | Ada | 3,627 | ads | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception
--
-- This package record the relation between unit name and the different part
-- composing it. From a unit name we can retrieve the source where the spec,
-- the body or separates are to be found.
with GPR2.Unit;
package GPR2.Project.Unit_Info is
type Object is tagged private;
Undefined : constant Object;
function Is_Defined (Self : Object) return Boolean;
-- Returns true if Self is defined
function Is_Empty (Self : Object) return Boolean;
function Create
(Name : Name_Type;
Spec : Unit.Source_Unit_Identifier := Unit.Undefined_Id;
Main_Body : Unit.Source_Unit_Identifier := Unit.Undefined_Id;
Separates : Unit.Source_Unit_Vectors.Vector :=
Unit.Source_Unit_Vectors.Empty_Vector) return Object;
-- Constructor for a Unit object
function Name (Self : Object) return Name_Type
with Pre => Self.Is_Defined;
-- Returns the unit name
function Has_Spec (Self : Object) return Boolean
with Pre => Self.Is_Defined;
-- Returns True if a spec is defined for this unit
function Spec (Self : Object) return Unit.Source_Unit_Identifier
with Pre => Self.Is_Defined;
-- Returns the Spec
function Has_Body (Self : Object) return Boolean
with Pre => Self.Is_Defined;
-- Returns True if a body is defined for this unit
function Main_Body (Self : Object) return Unit.Source_Unit_Identifier
with Pre => Self.Is_Defined;
-- Returns the Body
function Separates (Self : Object) return Unit.Source_Unit_Vectors.Vector
with Pre => Self.Is_Defined;
-- Returns all separates
procedure Update_Name
(Self : in out Object; Name : Name_Type)
with Pre => Self.Is_Defined;
-- Sets unit spec
procedure Update_Spec
(Self : in out Object; Source : Unit.Source_Unit_Identifier)
with Pre => Self.Is_Defined and then Source.Source.Is_Defined;
-- Sets unit spec
procedure Update_Body
(Self : in out Object; Source : Unit.Source_Unit_Identifier)
with Pre => Self.Is_Defined and then Source.Source.Is_Defined;
-- Sets unit body
procedure Remove_Body (Self : in out Object)
with Pre => Self.Is_Defined;
-- Sets unit body
procedure Update_Separates
(Self : in out Object; Source : Unit.Source_Unit_Identifier)
with Pre => Self.Is_Defined and then Source.Source.Is_Defined;
-- Appends separate
private
use GPR2.Unit;
type Object is tagged record
Name : Unbounded_String;
Spec : Source_Unit_Identifier;
Main_Body : Source_Unit_Identifier;
Separates : Source_Unit_Vectors.Vector;
end record;
Undefined : constant Object := (others => <>);
function Is_Defined (Self : Object) return Boolean is
(Self /= Undefined);
function Is_Empty (Self : Object) return Boolean is
(not Self.Has_Spec
and then not Self.Has_Body
and then Self.Separates.Is_Empty);
function Has_Spec (Self : Object) return Boolean is
(Self.Spec.Source.Is_Defined);
function Has_Body (Self : Object) return Boolean is
(Self.Main_Body.Source.Is_Defined);
function Spec (Self : Object) return Source_Unit_Identifier is (Self.Spec);
function Main_Body (Self : Object) return Source_Unit_Identifier is
(Self.Main_Body);
function Separates
(Self : Object) return Source_Unit_Vectors.Vector is (Self.Separates);
function Name (Self : Object) return Name_Type is
(Name_Type (To_String (Self.Name)));
end GPR2.Project.Unit_Info;
|
strenkml/EE368 | Ada | 61 | ads |
package Test.RAM is
procedure Run_Tests;
end Test.RAM;
|
rtoal/enhanced-dining-philosophers | Ada | 1,196 | ads | ------------------------------------------------------------------------------
-- meals.ads
--
-- A package containing the public data type Meal. A meal consists of an en-
-- tree, an optional soup, and an optional dessert. Three meal operations are
-- provided:
--
-- Random_Meal A random meal.
-- Price (M) The price of meal M.
-- S & M concatentates unbounded string S and text of M.
------------------------------------------------------------------------------
with Randoms, Ada.Strings.Unbounded;
use Randoms, Ada.Strings.Unbounded;
package Meals is
type Entree_Selection is (
Paella,
Wu_Hsiang_Chi,
Bogracs_Gulyas,
Spanokopita,
Moui_Nagden,
Sambal_Goreng_Udang
);
type Soup_Selection is (
No_Soup,
Albondigas
);
type Dessert_Selection is (
No_Dessert,
Berog
);
type Meal is record
Entree : Entree_Selection;
Soup : Soup_Selection;
Dessert : Dessert_Selection;
end record;
function Random_Meal return Meal;
function Price (M: Meal) return Float;
function "&" (S: Unbounded_String; M: Meal) return Unbounded_String;
end Meals;
|
reznikmm/clic | Ada | 1,113 | ads | with AAA.Strings;
with CLIC.Subcommand;
package CLIC_Ex.Commands.Switches_And_Args is
type Instance
is new CLIC.Subcommand.Command
with private;
overriding
function Name (Cmd : Instance) return CLIC.Subcommand.Identifier
is ("switches_and_args");
overriding
function Switches_As_Args (This : Instance) return Boolean
is (True);
overriding
procedure Execute (Cmd : in out Instance;
Args : AAA.Strings.Vector);
overriding
function Long_Description (Cmd : Instance) return AAA.Strings.Vector
is (AAA.Strings.Empty_Vector);
overriding
procedure Setup_Switches
(Cmd : in out Instance;
Config : in out CLIC.Subcommand.Switches_Configuration)
is null;
overriding
function Short_Description (Cmd : Instance) return String
is ("Print all the sub-command switches and args");
overriding
function Usage_Custom_Parameters (Cmd : Instance) return String
is ("[switches] [args]");
private
type Instance
is new CLIC.Subcommand.Command
with null record;
end CLIC_Ex.Commands.Switches_And_Args;
|
reznikmm/matreshka | Ada | 6,780 | 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_Form.Number_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Form_Number_Element_Node is
begin
return Self : Form_Number_Element_Node do
Matreshka.ODF_Form.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Form_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Form_Number_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Form_Number
(ODF.DOM.Form_Number_Elements.ODF_Form_Number_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Form_Number_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Number_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Form_Number_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Form_Number
(ODF.DOM.Form_Number_Elements.ODF_Form_Number_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Form_Number_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) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Form_Number
(Visitor,
ODF.DOM.Form_Number_Elements.ODF_Form_Number_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Form_URI,
Matreshka.ODF_String_Constants.Number_Element,
Form_Number_Element_Node'Tag);
end Matreshka.ODF_Form.Number_Elements;
|
AdaCore/gpr | Ada | 205 | ads | package First_Package is
procedure Call;
end First_Package;
-- Multi-units is not supported. The parsing shall not reach
-- this part.
package Second_Package is
procedure Call;
end Second_Package; |
tum-ei-rcs/StratoX | Ada | 47,508 | ads | -- This spec has been automatically generated from STM32F40x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with HAL;
with System;
package STM32_SVD.Ethernet is
pragma Preelaborate;
---------------
-- Registers --
---------------
--------------------
-- MACCR_Register --
--------------------
subtype MACCR_BL_Field is HAL.UInt2;
subtype MACCR_IFG_Field is HAL.UInt3;
-- Ethernet MAC configuration register
type MACCR_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- RE
RE : Boolean := False;
-- TE
TE : Boolean := False;
-- DC
DC : Boolean := False;
-- BL
BL : MACCR_BL_Field := 16#0#;
-- APCS
APCS : Boolean := False;
-- unspecified
Reserved_8_8 : HAL.Bit := 16#0#;
-- RD
RD : Boolean := False;
-- IPCO
IPCO : Boolean := False;
-- DM
DM : Boolean := False;
-- LM
LM : Boolean := False;
-- ROD
ROD : Boolean := False;
-- FES
FES : Boolean := False;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#1#;
-- CSD
CSD : Boolean := False;
-- IFG
IFG : MACCR_IFG_Field := 16#0#;
-- unspecified
Reserved_20_21 : HAL.UInt2 := 16#0#;
-- JD
JD : Boolean := False;
-- WD
WD : Boolean := False;
-- unspecified
Reserved_24_24 : HAL.Bit := 16#0#;
-- CSTF
CSTF : Boolean := False;
-- unspecified
Reserved_26_31 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACCR_Register use record
Reserved_0_1 at 0 range 0 .. 1;
RE at 0 range 2 .. 2;
TE at 0 range 3 .. 3;
DC at 0 range 4 .. 4;
BL at 0 range 5 .. 6;
APCS at 0 range 7 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
RD at 0 range 9 .. 9;
IPCO at 0 range 10 .. 10;
DM at 0 range 11 .. 11;
LM at 0 range 12 .. 12;
ROD at 0 range 13 .. 13;
FES at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
CSD at 0 range 16 .. 16;
IFG at 0 range 17 .. 19;
Reserved_20_21 at 0 range 20 .. 21;
JD at 0 range 22 .. 22;
WD at 0 range 23 .. 23;
Reserved_24_24 at 0 range 24 .. 24;
CSTF at 0 range 25 .. 25;
Reserved_26_31 at 0 range 26 .. 31;
end record;
---------------------
-- MACFFR_Register --
---------------------
-- Ethernet MAC frame filter register
type MACFFR_Register is record
-- no description available
PM : Boolean := False;
-- no description available
HU : Boolean := False;
-- no description available
HM : Boolean := False;
-- no description available
DAIF : Boolean := False;
-- no description available
RAM : Boolean := False;
-- no description available
BFD : Boolean := False;
-- no description available
PCF : Boolean := False;
-- no description available
SAIF : Boolean := False;
-- no description available
SAF : Boolean := False;
-- no description available
HPF : Boolean := False;
-- unspecified
Reserved_10_30 : HAL.UInt21 := 16#0#;
-- no description available
RA : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACFFR_Register use record
PM at 0 range 0 .. 0;
HU at 0 range 1 .. 1;
HM at 0 range 2 .. 2;
DAIF at 0 range 3 .. 3;
RAM at 0 range 4 .. 4;
BFD at 0 range 5 .. 5;
PCF at 0 range 6 .. 6;
SAIF at 0 range 7 .. 7;
SAF at 0 range 8 .. 8;
HPF at 0 range 9 .. 9;
Reserved_10_30 at 0 range 10 .. 30;
RA at 0 range 31 .. 31;
end record;
-----------------------
-- MACMIIAR_Register --
-----------------------
subtype MACMIIAR_CR_Field is HAL.UInt3;
subtype MACMIIAR_MR_Field is HAL.UInt5;
subtype MACMIIAR_PA_Field is HAL.UInt5;
-- Ethernet MAC MII address register
type MACMIIAR_Register is record
-- no description available
MB : Boolean := False;
-- no description available
MW : Boolean := False;
-- no description available
CR : MACMIIAR_CR_Field := 16#0#;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- no description available
MR : MACMIIAR_MR_Field := 16#0#;
-- no description available
PA : MACMIIAR_PA_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACMIIAR_Register use record
MB at 0 range 0 .. 0;
MW at 0 range 1 .. 1;
CR at 0 range 2 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
MR at 0 range 6 .. 10;
PA at 0 range 11 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-----------------------
-- MACMIIDR_Register --
-----------------------
subtype MACMIIDR_TD_Field is HAL.Short;
-- Ethernet MAC MII data register
type MACMIIDR_Register is record
-- no description available
TD : MACMIIDR_TD_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACMIIDR_Register use record
TD at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
---------------------
-- MACFCR_Register --
---------------------
subtype MACFCR_PLT_Field is HAL.UInt2;
subtype MACFCR_PT_Field is HAL.Short;
-- Ethernet MAC flow control register
type MACFCR_Register is record
-- no description available
FCB : Boolean := False;
-- no description available
TFCE : Boolean := False;
-- no description available
RFCE : Boolean := False;
-- no description available
UPFD : Boolean := False;
-- no description available
PLT : MACFCR_PLT_Field := 16#0#;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- no description available
ZQPD : Boolean := False;
-- unspecified
Reserved_8_15 : HAL.Byte := 16#0#;
-- no description available
PT : MACFCR_PT_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACFCR_Register use record
FCB at 0 range 0 .. 0;
TFCE at 0 range 1 .. 1;
RFCE at 0 range 2 .. 2;
UPFD at 0 range 3 .. 3;
PLT at 0 range 4 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
ZQPD at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
PT at 0 range 16 .. 31;
end record;
------------------------
-- MACVLANTR_Register --
------------------------
subtype MACVLANTR_VLANTI_Field is HAL.Short;
-- Ethernet MAC VLAN tag register
type MACVLANTR_Register is record
-- no description available
VLANTI : MACVLANTR_VLANTI_Field := 16#0#;
-- no description available
VLANTC : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACVLANTR_Register use record
VLANTI at 0 range 0 .. 15;
VLANTC at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
------------------------
-- MACPMTCSR_Register --
------------------------
-- Ethernet MAC PMT control and status register
type MACPMTCSR_Register is record
-- no description available
PD : Boolean := False;
-- no description available
MPE : Boolean := False;
-- no description available
WFE : Boolean := False;
-- unspecified
Reserved_3_4 : HAL.UInt2 := 16#0#;
-- no description available
MPR : Boolean := False;
-- no description available
WFR : Boolean := False;
-- unspecified
Reserved_7_8 : HAL.UInt2 := 16#0#;
-- no description available
GU : Boolean := False;
-- unspecified
Reserved_10_30 : HAL.UInt21 := 16#0#;
-- no description available
WFFRPR : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACPMTCSR_Register use record
PD at 0 range 0 .. 0;
MPE at 0 range 1 .. 1;
WFE at 0 range 2 .. 2;
Reserved_3_4 at 0 range 3 .. 4;
MPR at 0 range 5 .. 5;
WFR at 0 range 6 .. 6;
Reserved_7_8 at 0 range 7 .. 8;
GU at 0 range 9 .. 9;
Reserved_10_30 at 0 range 10 .. 30;
WFFRPR at 0 range 31 .. 31;
end record;
----------------------
-- MACDBGR_Register --
----------------------
-- Ethernet MAC debug register
type MACDBGR_Register is record
-- Read-only. CR
CR : Boolean;
-- Read-only. CSR
CSR : Boolean;
-- Read-only. ROR
ROR : Boolean;
-- Read-only. MCF
MCF : Boolean;
-- Read-only. MCP
MCP : Boolean;
-- Read-only. MCFHP
MCFHP : Boolean;
-- unspecified
Reserved_6_31 : HAL.UInt26;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACDBGR_Register use record
CR at 0 range 0 .. 0;
CSR at 0 range 1 .. 1;
ROR at 0 range 2 .. 2;
MCF at 0 range 3 .. 3;
MCP at 0 range 4 .. 4;
MCFHP at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
--------------------
-- MACSR_Register --
--------------------
-- Ethernet MAC interrupt status register
type MACSR_Register is record
-- unspecified
Reserved_0_2 : HAL.UInt3 := 16#0#;
-- Read-only. no description available
PMTS : Boolean := False;
-- Read-only. no description available
MMCS : Boolean := False;
-- Read-only. no description available
MMCRS : Boolean := False;
-- Read-only. no description available
MMCTS : Boolean := False;
-- unspecified
Reserved_7_8 : HAL.UInt2 := 16#0#;
-- no description available
TSTS : Boolean := False;
-- unspecified
Reserved_10_31 : HAL.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACSR_Register use record
Reserved_0_2 at 0 range 0 .. 2;
PMTS at 0 range 3 .. 3;
MMCS at 0 range 4 .. 4;
MMCRS at 0 range 5 .. 5;
MMCTS at 0 range 6 .. 6;
Reserved_7_8 at 0 range 7 .. 8;
TSTS at 0 range 9 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
---------------------
-- MACIMR_Register --
---------------------
-- Ethernet MAC interrupt mask register
type MACIMR_Register is record
-- unspecified
Reserved_0_2 : HAL.UInt3 := 16#0#;
-- no description available
PMTIM : Boolean := False;
-- unspecified
Reserved_4_8 : HAL.UInt5 := 16#0#;
-- no description available
TSTIM : Boolean := False;
-- unspecified
Reserved_10_31 : HAL.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACIMR_Register use record
Reserved_0_2 at 0 range 0 .. 2;
PMTIM at 0 range 3 .. 3;
Reserved_4_8 at 0 range 4 .. 8;
TSTIM at 0 range 9 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
----------------------
-- MACA0HR_Register --
----------------------
subtype MACA0HR_MACA0H_Field is HAL.Short;
-- Ethernet MAC address 0 high register
type MACA0HR_Register is record
-- MAC address0 high
MACA0H : MACA0HR_MACA0H_Field := 16#FFFF#;
-- unspecified
Reserved_16_30 : HAL.UInt15 := 16#10#;
-- Read-only. Always 1
MO : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA0HR_Register use record
MACA0H at 0 range 0 .. 15;
Reserved_16_30 at 0 range 16 .. 30;
MO at 0 range 31 .. 31;
end record;
----------------------
-- MACA1HR_Register --
----------------------
subtype MACA1HR_MACA1H_Field is HAL.Short;
subtype MACA1HR_MBC_Field is HAL.UInt6;
-- Ethernet MAC address 1 high register
type MACA1HR_Register is record
-- no description available
MACA1H : MACA1HR_MACA1H_Field := 16#FFFF#;
-- unspecified
Reserved_16_23 : HAL.Byte := 16#0#;
-- no description available
MBC : MACA1HR_MBC_Field := 16#0#;
-- no description available
SA : Boolean := False;
-- no description available
AE : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA1HR_Register use record
MACA1H at 0 range 0 .. 15;
Reserved_16_23 at 0 range 16 .. 23;
MBC at 0 range 24 .. 29;
SA at 0 range 30 .. 30;
AE at 0 range 31 .. 31;
end record;
----------------------
-- MACA2HR_Register --
----------------------
subtype MACA2HR_MAC2AH_Field is HAL.Short;
subtype MACA2HR_MBC_Field is HAL.UInt6;
-- Ethernet MAC address 2 high register
type MACA2HR_Register is record
-- no description available
MAC2AH : MACA2HR_MAC2AH_Field := 16#FFFF#;
-- unspecified
Reserved_16_23 : HAL.Byte := 16#0#;
-- no description available
MBC : MACA2HR_MBC_Field := 16#0#;
-- no description available
SA : Boolean := False;
-- no description available
AE : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA2HR_Register use record
MAC2AH at 0 range 0 .. 15;
Reserved_16_23 at 0 range 16 .. 23;
MBC at 0 range 24 .. 29;
SA at 0 range 30 .. 30;
AE at 0 range 31 .. 31;
end record;
----------------------
-- MACA2LR_Register --
----------------------
subtype MACA2LR_MACA2L_Field is HAL.UInt31;
-- Ethernet MAC address 2 low register
type MACA2LR_Register is record
-- no description available
MACA2L : MACA2LR_MACA2L_Field := 16#7FFFFFFF#;
-- unspecified
Reserved_31_31 : HAL.Bit := 16#1#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA2LR_Register use record
MACA2L at 0 range 0 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
----------------------
-- MACA3HR_Register --
----------------------
subtype MACA3HR_MACA3H_Field is HAL.Short;
subtype MACA3HR_MBC_Field is HAL.UInt6;
-- Ethernet MAC address 3 high register
type MACA3HR_Register is record
-- no description available
MACA3H : MACA3HR_MACA3H_Field := 16#FFFF#;
-- unspecified
Reserved_16_23 : HAL.Byte := 16#0#;
-- no description available
MBC : MACA3HR_MBC_Field := 16#0#;
-- no description available
SA : Boolean := False;
-- no description available
AE : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MACA3HR_Register use record
MACA3H at 0 range 0 .. 15;
Reserved_16_23 at 0 range 16 .. 23;
MBC at 0 range 24 .. 29;
SA at 0 range 30 .. 30;
AE at 0 range 31 .. 31;
end record;
--------------------
-- MMCCR_Register --
--------------------
-- Ethernet MMC control register
type MMCCR_Register is record
-- no description available
CR : Boolean := False;
-- no description available
CSR : Boolean := False;
-- no description available
ROR : Boolean := False;
-- no description available
MCF : Boolean := False;
-- no description available
MCP : Boolean := False;
-- no description available
MCFHP : Boolean := False;
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCCR_Register use record
CR at 0 range 0 .. 0;
CSR at 0 range 1 .. 1;
ROR at 0 range 2 .. 2;
MCF at 0 range 3 .. 3;
MCP at 0 range 4 .. 4;
MCFHP at 0 range 5 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
---------------------
-- MMCRIR_Register --
---------------------
-- Ethernet MMC receive interrupt register
type MMCRIR_Register is record
-- unspecified
Reserved_0_4 : HAL.UInt5 := 16#0#;
-- no description available
RFCES : Boolean := False;
-- no description available
RFAES : Boolean := False;
-- unspecified
Reserved_7_16 : HAL.UInt10 := 16#0#;
-- no description available
RGUFS : Boolean := False;
-- unspecified
Reserved_18_31 : HAL.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCRIR_Register use record
Reserved_0_4 at 0 range 0 .. 4;
RFCES at 0 range 5 .. 5;
RFAES at 0 range 6 .. 6;
Reserved_7_16 at 0 range 7 .. 16;
RGUFS at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
---------------------
-- MMCTIR_Register --
---------------------
-- Ethernet MMC transmit interrupt register
type MMCTIR_Register is record
-- unspecified
Reserved_0_13 : HAL.UInt14;
-- Read-only. no description available
TGFSCS : Boolean;
-- Read-only. no description available
TGFMSCS : Boolean;
-- unspecified
Reserved_16_20 : HAL.UInt5;
-- Read-only. no description available
TGFS : Boolean;
-- unspecified
Reserved_22_31 : HAL.UInt10;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCTIR_Register use record
Reserved_0_13 at 0 range 0 .. 13;
TGFSCS at 0 range 14 .. 14;
TGFMSCS at 0 range 15 .. 15;
Reserved_16_20 at 0 range 16 .. 20;
TGFS at 0 range 21 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
----------------------
-- MMCRIMR_Register --
----------------------
-- Ethernet MMC receive interrupt mask register
type MMCRIMR_Register is record
-- unspecified
Reserved_0_4 : HAL.UInt5 := 16#0#;
-- no description available
RFCEM : Boolean := False;
-- no description available
RFAEM : Boolean := False;
-- unspecified
Reserved_7_16 : HAL.UInt10 := 16#0#;
-- no description available
RGUFM : Boolean := False;
-- unspecified
Reserved_18_31 : HAL.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCRIMR_Register use record
Reserved_0_4 at 0 range 0 .. 4;
RFCEM at 0 range 5 .. 5;
RFAEM at 0 range 6 .. 6;
Reserved_7_16 at 0 range 7 .. 16;
RGUFM at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
----------------------
-- MMCTIMR_Register --
----------------------
-- Ethernet MMC transmit interrupt mask register
type MMCTIMR_Register is record
-- unspecified
Reserved_0_13 : HAL.UInt14 := 16#0#;
-- no description available
TGFSCM : Boolean := False;
-- no description available
TGFMSCM : Boolean := False;
-- no description available
TGFM : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MMCTIMR_Register use record
Reserved_0_13 at 0 range 0 .. 13;
TGFSCM at 0 range 14 .. 14;
TGFMSCM at 0 range 15 .. 15;
TGFM at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
----------------------
-- PTPTSCR_Register --
----------------------
subtype PTPTSCR_TSCNT_Field is HAL.UInt2;
-- Ethernet PTP time stamp control register
type PTPTSCR_Register is record
-- no description available
TSE : Boolean := False;
-- no description available
TSFCU : Boolean := False;
-- no description available
TSSTI : Boolean := False;
-- no description available
TSSTU : Boolean := False;
-- no description available
TSITE : Boolean := False;
-- no description available
TTSARU : Boolean := False;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- no description available
TSSARFE : Boolean := False;
-- no description available
TSSSR : Boolean := False;
-- no description available
TSPTPPSV2E : Boolean := False;
-- no description available
TSSPTPOEFE : Boolean := False;
-- no description available
TSSIPV6FE : Boolean := False;
-- no description available
TSSIPV4FE : Boolean := True;
-- no description available
TSSEME : Boolean := False;
-- no description available
TSSMRME : Boolean := False;
-- no description available
TSCNT : PTPTSCR_TSCNT_Field := 16#0#;
-- no description available
TSPFFMAE : 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 PTPTSCR_Register use record
TSE at 0 range 0 .. 0;
TSFCU at 0 range 1 .. 1;
TSSTI at 0 range 2 .. 2;
TSSTU at 0 range 3 .. 3;
TSITE at 0 range 4 .. 4;
TTSARU at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
TSSARFE at 0 range 8 .. 8;
TSSSR at 0 range 9 .. 9;
TSPTPPSV2E at 0 range 10 .. 10;
TSSPTPOEFE at 0 range 11 .. 11;
TSSIPV6FE at 0 range 12 .. 12;
TSSIPV4FE at 0 range 13 .. 13;
TSSEME at 0 range 14 .. 14;
TSSMRME at 0 range 15 .. 15;
TSCNT at 0 range 16 .. 17;
TSPFFMAE at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
----------------------
-- PTPSSIR_Register --
----------------------
subtype PTPSSIR_STSSI_Field is HAL.Byte;
-- Ethernet PTP subsecond increment register
type PTPSSIR_Register is record
-- no description available
STSSI : PTPSSIR_STSSI_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 PTPSSIR_Register use record
STSSI at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
----------------------
-- PTPTSLR_Register --
----------------------
subtype PTPTSLR_STSS_Field is HAL.UInt31;
-- Ethernet PTP time stamp low register
type PTPTSLR_Register is record
-- Read-only. no description available
STSS : PTPTSLR_STSS_Field;
-- Read-only. no description available
STPNS : Boolean;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPTSLR_Register use record
STSS at 0 range 0 .. 30;
STPNS at 0 range 31 .. 31;
end record;
-----------------------
-- PTPTSLUR_Register --
-----------------------
subtype PTPTSLUR_TSUSS_Field is HAL.UInt31;
-- Ethernet PTP time stamp low update register
type PTPTSLUR_Register is record
-- no description available
TSUSS : PTPTSLUR_TSUSS_Field := 16#0#;
-- no description available
TSUPNS : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPTSLUR_Register use record
TSUSS at 0 range 0 .. 30;
TSUPNS at 0 range 31 .. 31;
end record;
----------------------
-- PTPTSSR_Register --
----------------------
-- Ethernet PTP time stamp status register
type PTPTSSR_Register is record
-- Read-only. no description available
TSSO : Boolean;
-- Read-only. no description available
TSTTR : Boolean;
-- unspecified
Reserved_2_31 : HAL.UInt30;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPTSSR_Register use record
TSSO at 0 range 0 .. 0;
TSTTR at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-----------------------
-- PTPPPSCR_Register --
-----------------------
-- Ethernet PTP PPS control register
type PTPPPSCR_Register is record
-- Read-only. TSSO
TSSO : Boolean;
-- Read-only. TSTTR
TSTTR : Boolean;
-- unspecified
Reserved_2_31 : HAL.UInt30;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PTPPPSCR_Register use record
TSSO at 0 range 0 .. 0;
TSTTR at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
---------------------
-- DMABMR_Register --
---------------------
subtype DMABMR_DSL_Field is HAL.UInt5;
subtype DMABMR_PBL_Field is HAL.UInt6;
subtype DMABMR_RTPR_Field is HAL.UInt2;
subtype DMABMR_RDP_Field is HAL.UInt6;
-- Ethernet DMA bus mode register
type DMABMR_Register is record
-- no description available
SR : Boolean := True;
-- no description available
DA : Boolean := False;
-- no description available
DSL : DMABMR_DSL_Field := 16#0#;
-- no description available
EDFE : Boolean := False;
-- no description available
PBL : DMABMR_PBL_Field := 16#21#;
-- no description available
RTPR : DMABMR_RTPR_Field := 16#0#;
-- no description available
FB : Boolean := False;
-- no description available
RDP : DMABMR_RDP_Field := 16#0#;
-- no description available
USP : Boolean := False;
-- no description available
FPM : Boolean := False;
-- no description available
AAB : Boolean := False;
-- no description available
MB : Boolean := False;
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMABMR_Register use record
SR at 0 range 0 .. 0;
DA at 0 range 1 .. 1;
DSL at 0 range 2 .. 6;
EDFE at 0 range 7 .. 7;
PBL at 0 range 8 .. 13;
RTPR at 0 range 14 .. 15;
FB at 0 range 16 .. 16;
RDP at 0 range 17 .. 22;
USP at 0 range 23 .. 23;
FPM at 0 range 24 .. 24;
AAB at 0 range 25 .. 25;
MB at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
--------------------
-- DMASR_Register --
--------------------
subtype DMASR_RPS_Field is HAL.UInt3;
subtype DMASR_TPS_Field is HAL.UInt3;
subtype DMASR_EBS_Field is HAL.UInt3;
-- Ethernet DMA status register
type DMASR_Register is record
-- no description available
TS : Boolean := False;
-- no description available
TPSS : Boolean := False;
-- no description available
TBUS : Boolean := False;
-- no description available
TJTS : Boolean := False;
-- no description available
ROS : Boolean := False;
-- no description available
TUS : Boolean := False;
-- no description available
RS : Boolean := False;
-- no description available
RBUS : Boolean := False;
-- no description available
RPSS : Boolean := False;
-- no description available
PWTS : Boolean := False;
-- no description available
ETS : Boolean := False;
-- unspecified
Reserved_11_12 : HAL.UInt2 := 16#0#;
-- no description available
FBES : Boolean := False;
-- no description available
ERS : Boolean := False;
-- no description available
AIS : Boolean := False;
-- no description available
NIS : Boolean := False;
-- Read-only. no description available
RPS : DMASR_RPS_Field := 16#0#;
-- Read-only. no description available
TPS : DMASR_TPS_Field := 16#0#;
-- Read-only. no description available
EBS : DMASR_EBS_Field := 16#0#;
-- unspecified
Reserved_26_26 : HAL.Bit := 16#0#;
-- Read-only. no description available
MMCS : Boolean := False;
-- Read-only. no description available
PMTS : Boolean := False;
-- Read-only. no description available
TSTS : Boolean := False;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMASR_Register use record
TS at 0 range 0 .. 0;
TPSS at 0 range 1 .. 1;
TBUS at 0 range 2 .. 2;
TJTS at 0 range 3 .. 3;
ROS at 0 range 4 .. 4;
TUS at 0 range 5 .. 5;
RS at 0 range 6 .. 6;
RBUS at 0 range 7 .. 7;
RPSS at 0 range 8 .. 8;
PWTS at 0 range 9 .. 9;
ETS at 0 range 10 .. 10;
Reserved_11_12 at 0 range 11 .. 12;
FBES at 0 range 13 .. 13;
ERS at 0 range 14 .. 14;
AIS at 0 range 15 .. 15;
NIS at 0 range 16 .. 16;
RPS at 0 range 17 .. 19;
TPS at 0 range 20 .. 22;
EBS at 0 range 23 .. 25;
Reserved_26_26 at 0 range 26 .. 26;
MMCS at 0 range 27 .. 27;
PMTS at 0 range 28 .. 28;
TSTS at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
---------------------
-- DMAOMR_Register --
---------------------
subtype DMAOMR_RTC_Field is HAL.UInt2;
subtype DMAOMR_TTC_Field is HAL.UInt3;
-- Ethernet DMA operation mode register
type DMAOMR_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- SR
SR : Boolean := False;
-- OSF
OSF : Boolean := False;
-- RTC
RTC : DMAOMR_RTC_Field := 16#0#;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- FUGF
FUGF : Boolean := False;
-- FEF
FEF : Boolean := False;
-- unspecified
Reserved_8_12 : HAL.UInt5 := 16#0#;
-- ST
ST : Boolean := False;
-- TTC
TTC : DMAOMR_TTC_Field := 16#0#;
-- unspecified
Reserved_17_19 : HAL.UInt3 := 16#0#;
-- FTF
FTF : Boolean := False;
-- TSF
TSF : Boolean := False;
-- unspecified
Reserved_22_23 : HAL.UInt2 := 16#0#;
-- DFRF
DFRF : Boolean := False;
-- RSF
RSF : Boolean := False;
-- DTCEFD
DTCEFD : Boolean := False;
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAOMR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
SR at 0 range 1 .. 1;
OSF at 0 range 2 .. 2;
RTC at 0 range 3 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
FUGF at 0 range 6 .. 6;
FEF at 0 range 7 .. 7;
Reserved_8_12 at 0 range 8 .. 12;
ST at 0 range 13 .. 13;
TTC at 0 range 14 .. 16;
Reserved_17_19 at 0 range 17 .. 19;
FTF at 0 range 20 .. 20;
TSF at 0 range 21 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
DFRF at 0 range 24 .. 24;
RSF at 0 range 25 .. 25;
DTCEFD at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
---------------------
-- DMAIER_Register --
---------------------
-- Ethernet DMA interrupt enable register
type DMAIER_Register is record
-- no description available
TIE : Boolean := False;
-- no description available
TPSIE : Boolean := False;
-- no description available
TBUIE : Boolean := False;
-- no description available
TJTIE : Boolean := False;
-- no description available
ROIE : Boolean := False;
-- no description available
TUIE : Boolean := False;
-- no description available
RIE : Boolean := False;
-- no description available
RBUIE : Boolean := False;
-- no description available
RPSIE : Boolean := False;
-- no description available
RWTIE : Boolean := False;
-- no description available
ETIE : Boolean := False;
-- unspecified
Reserved_11_12 : HAL.UInt2 := 16#0#;
-- no description available
FBEIE : Boolean := False;
-- no description available
ERIE : Boolean := False;
-- no description available
AISE : Boolean := False;
-- no description available
NISE : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAIER_Register use record
TIE at 0 range 0 .. 0;
TPSIE at 0 range 1 .. 1;
TBUIE at 0 range 2 .. 2;
TJTIE at 0 range 3 .. 3;
ROIE at 0 range 4 .. 4;
TUIE at 0 range 5 .. 5;
RIE at 0 range 6 .. 6;
RBUIE at 0 range 7 .. 7;
RPSIE at 0 range 8 .. 8;
RWTIE at 0 range 9 .. 9;
ETIE at 0 range 10 .. 10;
Reserved_11_12 at 0 range 11 .. 12;
FBEIE at 0 range 13 .. 13;
ERIE at 0 range 14 .. 14;
AISE at 0 range 15 .. 15;
NISE at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
------------------------
-- DMAMFBOCR_Register --
------------------------
subtype DMAMFBOCR_MFC_Field is HAL.Short;
subtype DMAMFBOCR_MFA_Field is HAL.UInt11;
-- Ethernet DMA missed frame and buffer overflow counter register
type DMAMFBOCR_Register is record
-- no description available
MFC : DMAMFBOCR_MFC_Field := 16#0#;
-- no description available
OMFC : Boolean := False;
-- no description available
MFA : DMAMFBOCR_MFA_Field := 16#0#;
-- no description available
OFOC : Boolean := False;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAMFBOCR_Register use record
MFC at 0 range 0 .. 15;
OMFC at 0 range 16 .. 16;
MFA at 0 range 17 .. 27;
OFOC at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
-----------------------
-- DMARSWTR_Register --
-----------------------
subtype DMARSWTR_RSWTC_Field is HAL.Byte;
-- Ethernet DMA receive status watchdog timer register
type DMARSWTR_Register is record
-- RSWTC
RSWTC : DMARSWTR_RSWTC_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 DMARSWTR_Register use record
RSWTC at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Ethernet: media access control (MAC)
type Ethernet_MAC_Peripheral is record
-- Ethernet MAC configuration register
MACCR : MACCR_Register;
-- Ethernet MAC frame filter register
MACFFR : MACFFR_Register;
-- Ethernet MAC hash table high register
MACHTHR : HAL.Word;
-- Ethernet MAC hash table low register
MACHTLR : HAL.Word;
-- Ethernet MAC MII address register
MACMIIAR : MACMIIAR_Register;
-- Ethernet MAC MII data register
MACMIIDR : MACMIIDR_Register;
-- Ethernet MAC flow control register
MACFCR : MACFCR_Register;
-- Ethernet MAC VLAN tag register
MACVLANTR : MACVLANTR_Register;
-- Ethernet MAC PMT control and status register
MACPMTCSR : MACPMTCSR_Register;
-- Ethernet MAC debug register
MACDBGR : MACDBGR_Register;
-- Ethernet MAC interrupt status register
MACSR : MACSR_Register;
-- Ethernet MAC interrupt mask register
MACIMR : MACIMR_Register;
-- Ethernet MAC address 0 high register
MACA0HR : MACA0HR_Register;
-- Ethernet MAC address 0 low register
MACA0LR : HAL.Word;
-- Ethernet MAC address 1 high register
MACA1HR : MACA1HR_Register;
-- Ethernet MAC address1 low register
MACA1LR : HAL.Word;
-- Ethernet MAC address 2 high register
MACA2HR : MACA2HR_Register;
-- Ethernet MAC address 2 low register
MACA2LR : MACA2LR_Register;
-- Ethernet MAC address 3 high register
MACA3HR : MACA3HR_Register;
-- Ethernet MAC address 3 low register
MACA3LR : HAL.Word;
end record
with Volatile;
for Ethernet_MAC_Peripheral use record
MACCR at 0 range 0 .. 31;
MACFFR at 4 range 0 .. 31;
MACHTHR at 8 range 0 .. 31;
MACHTLR at 12 range 0 .. 31;
MACMIIAR at 16 range 0 .. 31;
MACMIIDR at 20 range 0 .. 31;
MACFCR at 24 range 0 .. 31;
MACVLANTR at 28 range 0 .. 31;
MACPMTCSR at 44 range 0 .. 31;
MACDBGR at 52 range 0 .. 31;
MACSR at 56 range 0 .. 31;
MACIMR at 60 range 0 .. 31;
MACA0HR at 64 range 0 .. 31;
MACA0LR at 68 range 0 .. 31;
MACA1HR at 72 range 0 .. 31;
MACA1LR at 76 range 0 .. 31;
MACA2HR at 80 range 0 .. 31;
MACA2LR at 84 range 0 .. 31;
MACA3HR at 88 range 0 .. 31;
MACA3LR at 92 range 0 .. 31;
end record;
-- Ethernet: media access control (MAC)
Ethernet_MAC_Periph : aliased Ethernet_MAC_Peripheral
with Import, Address => Ethernet_MAC_Base;
-- Ethernet: MAC management counters
type Ethernet_MMC_Peripheral is record
-- Ethernet MMC control register
MMCCR : MMCCR_Register;
-- Ethernet MMC receive interrupt register
MMCRIR : MMCRIR_Register;
-- Ethernet MMC transmit interrupt register
MMCTIR : MMCTIR_Register;
-- Ethernet MMC receive interrupt mask register
MMCRIMR : MMCRIMR_Register;
-- Ethernet MMC transmit interrupt mask register
MMCTIMR : MMCTIMR_Register;
-- Ethernet MMC transmitted good frames after a single collision counter
MMCTGFSCCR : HAL.Word;
-- Ethernet MMC transmitted good frames after more than a single
-- collision
MMCTGFMSCCR : HAL.Word;
-- Ethernet MMC transmitted good frames counter register
MMCTGFCR : HAL.Word;
-- Ethernet MMC received frames with CRC error counter register
MMCRFCECR : HAL.Word;
-- Ethernet MMC received frames with alignment error counter register
MMCRFAECR : HAL.Word;
-- MMC received good unicast frames counter register
MMCRGUFCR : HAL.Word;
end record
with Volatile;
for Ethernet_MMC_Peripheral use record
MMCCR at 0 range 0 .. 31;
MMCRIR at 4 range 0 .. 31;
MMCTIR at 8 range 0 .. 31;
MMCRIMR at 12 range 0 .. 31;
MMCTIMR at 16 range 0 .. 31;
MMCTGFSCCR at 76 range 0 .. 31;
MMCTGFMSCCR at 80 range 0 .. 31;
MMCTGFCR at 104 range 0 .. 31;
MMCRFCECR at 148 range 0 .. 31;
MMCRFAECR at 152 range 0 .. 31;
MMCRGUFCR at 196 range 0 .. 31;
end record;
-- Ethernet: MAC management counters
Ethernet_MMC_Periph : aliased Ethernet_MMC_Peripheral
with Import, Address => Ethernet_MMC_Base;
-- Ethernet: Precision time protocol
type Ethernet_PTP_Peripheral is record
-- Ethernet PTP time stamp control register
PTPTSCR : PTPTSCR_Register;
-- Ethernet PTP subsecond increment register
PTPSSIR : PTPSSIR_Register;
-- Ethernet PTP time stamp high register
PTPTSHR : HAL.Word;
-- Ethernet PTP time stamp low register
PTPTSLR : PTPTSLR_Register;
-- Ethernet PTP time stamp high update register
PTPTSHUR : HAL.Word;
-- Ethernet PTP time stamp low update register
PTPTSLUR : PTPTSLUR_Register;
-- Ethernet PTP time stamp addend register
PTPTSAR : HAL.Word;
-- Ethernet PTP target time high register
PTPTTHR : HAL.Word;
-- Ethernet PTP target time low register
PTPTTLR : HAL.Word;
-- Ethernet PTP time stamp status register
PTPTSSR : PTPTSSR_Register;
-- Ethernet PTP PPS control register
PTPPPSCR : PTPPPSCR_Register;
end record
with Volatile;
for Ethernet_PTP_Peripheral use record
PTPTSCR at 0 range 0 .. 31;
PTPSSIR at 4 range 0 .. 31;
PTPTSHR at 8 range 0 .. 31;
PTPTSLR at 12 range 0 .. 31;
PTPTSHUR at 16 range 0 .. 31;
PTPTSLUR at 20 range 0 .. 31;
PTPTSAR at 24 range 0 .. 31;
PTPTTHR at 28 range 0 .. 31;
PTPTTLR at 32 range 0 .. 31;
PTPTSSR at 40 range 0 .. 31;
PTPPPSCR at 44 range 0 .. 31;
end record;
-- Ethernet: Precision time protocol
Ethernet_PTP_Periph : aliased Ethernet_PTP_Peripheral
with Import, Address => Ethernet_PTP_Base;
-- Ethernet: DMA controller operation
type Ethernet_DMA_Peripheral is record
-- Ethernet DMA bus mode register
DMABMR : DMABMR_Register;
-- Ethernet DMA transmit poll demand register
DMATPDR : HAL.Word;
-- EHERNET DMA receive poll demand register
DMARPDR : HAL.Word;
-- Ethernet DMA receive descriptor list address register
DMARDLAR : HAL.Word;
-- Ethernet DMA transmit descriptor list address register
DMATDLAR : HAL.Word;
-- Ethernet DMA status register
DMASR : DMASR_Register;
-- Ethernet DMA operation mode register
DMAOMR : DMAOMR_Register;
-- Ethernet DMA interrupt enable register
DMAIER : DMAIER_Register;
-- Ethernet DMA missed frame and buffer overflow counter register
DMAMFBOCR : DMAMFBOCR_Register;
-- Ethernet DMA receive status watchdog timer register
DMARSWTR : DMARSWTR_Register;
-- Ethernet DMA current host transmit descriptor register
DMACHTDR : HAL.Word;
-- Ethernet DMA current host receive descriptor register
DMACHRDR : HAL.Word;
-- Ethernet DMA current host transmit buffer address register
DMACHTBAR : HAL.Word;
-- Ethernet DMA current host receive buffer address register
DMACHRBAR : HAL.Word;
end record
with Volatile;
for Ethernet_DMA_Peripheral use record
DMABMR at 0 range 0 .. 31;
DMATPDR at 4 range 0 .. 31;
DMARPDR at 8 range 0 .. 31;
DMARDLAR at 12 range 0 .. 31;
DMATDLAR at 16 range 0 .. 31;
DMASR at 20 range 0 .. 31;
DMAOMR at 24 range 0 .. 31;
DMAIER at 28 range 0 .. 31;
DMAMFBOCR at 32 range 0 .. 31;
DMARSWTR at 36 range 0 .. 31;
DMACHTDR at 72 range 0 .. 31;
DMACHRDR at 76 range 0 .. 31;
DMACHTBAR at 80 range 0 .. 31;
DMACHRBAR at 84 range 0 .. 31;
end record;
-- Ethernet: DMA controller operation
Ethernet_DMA_Periph : aliased Ethernet_DMA_Peripheral
with Import, Address => Ethernet_DMA_Base;
end STM32_SVD.Ethernet;
|
stcarrez/ada-wiki | Ada | 17,597 | adb | -----------------------------------------------------------------------
-- wiki-parsers-tests -- Unit tests for wiki parsing
-- Copyright (C) 2011, 2012, 2013, 2015, 2016, 2017, 2021, 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.UTF_Encoding.Wide_Wide_Strings;
with Util.Test_Caller;
with Wiki.Utils;
with Wiki.Helpers;
with Wiki.Streams.Builders;
with Wiki.Render.Text;
package body Wiki.Parsers.Tests is
use Wiki.Helpers;
package Caller is new Util.Test_Caller (Test, "Wikis.Parsers");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (bold)",
Test_Wiki_Bold'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (italic)",
Test_Wiki_Italic'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (italic, bold)",
Test_Wiki_Formats'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (headings)",
Test_Wiki_Section'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (lists)",
Test_Wiki_List'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (links)",
Test_Wiki_Link'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (quote)",
Test_Wiki_Quote'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (line break)",
Test_Wiki_Line_Break'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (image)",
Test_Wiki_Image'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (preformatted)",
Test_Wiki_Preformatted'Access);
Caller.Add_Test (Suite, "Test Wiki.Text.Renderer",
Test_Wiki_Text_Renderer'Access);
Caller.Add_Test (Suite, "Test Wiki.Parsers.Parse (String UTF-8)",
Test_Wiki_UTF_8'Access);
end Add_Tests;
-- ------------------------------
-- Test bold rendering.
-- ------------------------------
procedure Test_Wiki_Bold (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><b>bold</b></p>",
Wiki.Utils.To_Html ("*bold*", SYNTAX_GOOGLE),
"Bold rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <b>bold</b> y</p>",
Wiki.Utils.To_Html ("x *bold* y", SYNTAX_GOOGLE),
"Bold rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <strong>bold y</strong></p>",
Wiki.Utils.To_Html ("x **bold y**", SYNTAX_CREOLE),
"Bold rendering invalid (CREOLE)");
Util.Tests.Assert_Equals (T, "<p>x <b>item y</b> p</p>",
Wiki.Utils.To_Html ("x __item y__ p", SYNTAX_DOTCLEAR),
"Bold rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x _item y_ p</p>",
Wiki.Utils.To_Html ("x _item y_ p", SYNTAX_DOTCLEAR),
"No bold rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <b>bold</b> y</p>",
Wiki.Utils.To_Html ("x '''bold''' y", SYNTAX_MEDIA_WIKI),
"Bold rendering invalid (MediaWiki)");
end Test_Wiki_Bold;
-- ------------------------------
-- Test italic rendering.
-- ------------------------------
procedure Test_Wiki_Italic (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><i>item</i></p>",
Wiki.Utils.To_Html ("_item_", SYNTAX_GOOGLE),
"Italic rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <i>item</i> y</p>",
Wiki.Utils.To_Html ("x _item_ y", SYNTAX_GOOGLE),
"Italic rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <em>item y</em></p>",
Wiki.Utils.To_Html ("x //item y//", SYNTAX_CREOLE),
"Italic rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <i>item y</i> p</p>",
Wiki.Utils.To_Html ("x ''item y'' p", SYNTAX_DOTCLEAR),
"Italic rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <i>item y</i> p</p>",
Wiki.Utils.To_Html ("x ''item y'' p", SYNTAX_MEDIA_WIKI),
"Italic rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x 'item y<i> p</i></p>",
Wiki.Utils.To_Html ("x 'item y'' p", SYNTAX_MEDIA_WIKI),
"Italic rendering invalid");
end Test_Wiki_Italic;
-- ------------------------------
-- Test various format rendering.
-- ------------------------------
procedure Test_Wiki_Formats (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><i>it</i><b><i>bold</i></b><i>em</i></p>",
Wiki.Utils.To_Html ("_it*bold*em_", SYNTAX_GOOGLE),
"Italic+Bold rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <i>item</i> y</p>",
Wiki.Utils.To_Html ("x _item_ y", SYNTAX_GOOGLE),
"Italic rendering invalid");
Util.Tests.Assert_Equals (T, "<p>x <i>item y</i></p>",
Wiki.Utils.To_Html ("x _item y_", SYNTAX_GOOGLE),
"Italic rendering invalid");
end Test_Wiki_Formats;
-- ------------------------------
-- Test heading rendering.
-- ------------------------------
procedure Test_Wiki_Section (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<h1>item</h1>",
Wiki.Utils.To_Html ("= item =", SYNTAX_GOOGLE),
"H1 rendering invalid");
Util.Tests.Assert_Equals (T, "<h2>item</h2>",
Wiki.Utils.To_Html ("== item == ", SYNTAX_GOOGLE),
"H2 rendering invalid");
Util.Tests.Assert_Equals (T, "<h3>item</h3>",
Wiki.Utils.To_Html ("=== item === ", SYNTAX_GOOGLE),
"H3 rendering invalid");
Util.Tests.Assert_Equals (T, "<h4>item</h4>",
Wiki.Utils.To_Html ("==== item ==== ", SYNTAX_GOOGLE),
"H4 rendering invalid");
Util.Tests.Assert_Equals (T, "<h5>item</h5>",
Wiki.Utils.To_Html ("===== item =====", SYNTAX_GOOGLE),
"H5 rendering invalid");
Util.Tests.Assert_Equals (T, "<h1>item</h1><h2>item2</h2>",
Wiki.Utils.To_Html ("= item =" & CR & "== item2 ==",
SYNTAX_GOOGLE),
"H1 rendering invalid");
Util.Tests.Assert_Equals (T, "<h1>item</h1><h2>item2</h2>",
Wiki.Utils.To_Html ("= item =" & CR & "== item2 ==",
SYNTAX_GOOGLE),
"H1 rendering invalid");
end Test_Wiki_Section;
-- ------------------------------
-- Test list rendering.
-- ------------------------------
procedure Test_Wiki_List (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<ol><li>item</li></ol>",
Wiki.Utils.To_Html ("1. item", SYNTAX_MARKDOWN),
"Ordered list rendering invalid");
Util.Tests.Assert_Equals (T, "<ol><li>item item" &
"</li><li>item2 item2" &
"</li><li>item3</li></ol>",
Wiki.Utils.To_Html ("1. item item " & LF & "2. item2 item2" & LF & "3. item3",
SYNTAX_MARKDOWN),
"Ordered rendering invalid");
Util.Tests.Assert_Equals (T, "<ul><li>item</li></ul>",
Wiki.Utils.To_Html (" * item", SYNTAX_MARKDOWN),
"Bullet list rendering invalid");
Util.Tests.Assert_Equals (T, "<ul><li>item</li></ul>",
Wiki.Utils.To_Html ("* item", SYNTAX_DOTCLEAR),
"Bullet list rendering invalid");
end Test_Wiki_List;
-- ------------------------------
-- Test link rendering.
-- ------------------------------
procedure Test_Wiki_Link (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><a href=""name"">name</a></p>",
Wiki.Utils.To_Html ("[name]", SYNTAX_GOOGLE),
"Link rendering invalid");
Util.Tests.Assert_Equals (T, "<p><a href=""http://www.joe.com/item"" "
& "lang=""en"" title=""some""" &
">name</a></p>",
Wiki.Utils.To_Html ("[name |http://www.joe.com/item|en|some]",
SYNTAX_DOTCLEAR),
"Link rendering invalid");
Util.Tests.Assert_Equals (T, "<p><a href=""name"">name</a></p>",
Wiki.Utils.To_Html ("[[name]]", SYNTAX_CREOLE),
"Link rendering invalid");
Util.Tests.Assert_Equals (T, "<p>[d</p>",
Wiki.Utils.To_Html ("[d", SYNTAX_CREOLE),
"No link rendering invalid");
Util.Tests.Assert_Equals (T, "<p><a " &
"href=""http://www.joe.com/item"">http://www.joe.com/item</a></p>",
Wiki.Utils.To_Html ("[http://www.joe.com/item]",
SYNTAX_DOTCLEAR),
"Link rendering invalid");
Util.Tests.Assert_Equals (T, "<p><a href=""name"">name</a></p>",
Wiki.Utils.To_Html ("[[name]]", SYNTAX_MEDIA_WIKI),
"Link rendering invalid");
end Test_Wiki_Link;
-- ------------------------------
-- Test quote rendering.
-- ------------------------------
procedure Test_Wiki_Quote (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><q>quote</q></p>",
Wiki.Utils.To_Html ("{{quote}}", SYNTAX_DOTCLEAR),
"Quote rendering invalid");
Util.Tests.Assert_Equals (T, "<p><q lang=""en"">quote</q></p>",
Wiki.Utils.To_Html ("{{quote|en}}", SYNTAX_DOTCLEAR),
"Quote rendering invalid");
Util.Tests.Assert_Equals (T, "<p><q cite=""http://www.sun.com"" lang=""en"">quote</q></p>",
Wiki.Utils.To_Html ("{{quote|en|http://www.sun.com}}",
SYNTAX_DOTCLEAR),
"Quote rendering invalid");
Util.Tests.Assert_Equals (T, "<p>{quote}}</p>",
Wiki.Utils.To_Html ("{quote}}", SYNTAX_DOTCLEAR),
"No quote rendering invalid");
end Test_Wiki_Quote;
-- ------------------------------
-- Test line break rendering.
-- ------------------------------
procedure Test_Wiki_Line_Break (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p>a<br>b</p>",
Wiki.Utils.To_Html ("a%%%b", SYNTAX_DOTCLEAR),
"Line break rendering invalid");
Util.Tests.Assert_Equals (T, "<p>a<br>b</p>",
Wiki.Utils.To_Html ("a\\b", SYNTAX_CREOLE),
"Line break rendering invalid");
Util.Tests.Assert_Equals (T, "<p>a%%b</p>",
Wiki.Utils.To_Html ("a%%b", SYNTAX_DOTCLEAR),
"No line break rendering invalid");
Util.Tests.Assert_Equals (T, "<p>a%b</p>",
Wiki.Utils.To_Html ("a%b", SYNTAX_DOTCLEAR),
"No line break rendering invalid");
end Test_Wiki_Line_Break;
-- ------------------------------
-- Test image rendering.
-- ------------------------------
procedure Test_Wiki_Image (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<p><img src=""/image/t.png"" /></p>",
Wiki.Utils.To_Html ("((/image/t.png))", SYNTAX_DOTCLEAR),
"Image rendering invalid");
Util.Tests.Assert_Equals (T, "<p><img src=""/image/t.png"" alt=""title"" /></p>",
Wiki.Utils.To_Html ("((/image/t.png|title))", SYNTAX_DOTCLEAR),
"Image rendering invalid");
Util.Tests.Assert_Equals (T, "<p><img " &
"src=""/image/t.png"" longdesc=""describe"" alt=""title"" /></p>",
Wiki.Utils.To_Html ("((/image/t.png|title|x|describe))",
SYNTAX_DOTCLEAR),
"Image rendering invalid");
end Test_Wiki_Image;
-- ------------------------------
-- Test preformatted rendering.
-- ------------------------------
procedure Test_Wiki_Preformatted (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "<pre><code>* code *" & ASCII.LF & "</code></pre>",
Wiki.Utils.To_Html ("///" & LF & "* code *" & LF & "///",
SYNTAX_DOTCLEAR),
"Preformat rendering invalid");
Util.Tests.Assert_Equals (T, "<pre><code>item1 x" & ASCII.LF & "item2 x"
& ASCII.LF & "item3 x"
& "</code></pre>",
Wiki.Utils.To_Html (" item1 x" & LF & " item2 x" & LF & " item3 x",
SYNTAX_DOTCLEAR),
"Preformat rendering invalid");
end Test_Wiki_Preformatted;
-- ------------------------------
-- Test the text renderer.
-- ------------------------------
procedure Test_Wiki_Text_Renderer (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, ASCII.LF & "code" & ASCII.LF,
Wiki.Utils.To_Text ("`code`", SYNTAX_MARKDOWN),
"Preformat rendering invalid");
Util.Tests.Assert_Equals (T, ASCII.LF & "bold item my_title" & ASCII.LF,
Wiki.Utils.To_Text ("_bold_ __item__ [my_title]", SYNTAX_GOOGLE),
"Preformat rendering invalid");
end Test_Wiki_Text_Renderer;
-- ------------------------------
-- Test the string parser with UTF-8 support.
-- ------------------------------
procedure Test_Wiki_UTF_8 (T : in out Test) is
procedure Check (Text : in Wiki.Strings.WString);
Test_Chars : constant array (Natural range <>) of Wiki.Strings.WChar
:= (Wiki.Strings.WChar'Val (16#7f#),
Wiki.Strings.WChar'Val (16#80#),
Wiki.Strings.WChar'Val (16#AE#),
Wiki.Strings.WChar'Val (16#1ff#),
Wiki.Strings.WChar'Val (16#1fff#),
Wiki.Strings.WChar'Val (16#1ffff#),
Wiki.Strings.WChar'Val (16#0fffff#));
procedure Check (Text : in Wiki.Strings.WString) is
procedure Get (Value : in Wiki.Strings.WString);
Doc : Wiki.Documents.Document;
Engine : Wiki.Parsers.Parser;
Renderer : aliased Wiki.Render.Text.Text_Renderer;
Stream : aliased Wiki.Streams.Builders.Output_Builder_Stream;
Content : constant String :=
Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Encode (Text);
procedure Get (Value : in Wiki.Strings.WString) is
begin
-- Verify that we got the expected characters.
T.Assert (Wiki.Helpers.LF & Text & Wiki.Helpers.LF = Value,
"Invalid parsing for [" & Content & "]");
end Get;
begin
Engine.Set_Syntax (SYNTAX_MEDIA_WIKI);
Engine.Parse (Content, Doc);
Renderer.Set_Output_Stream (Stream'Unchecked_Access);
Renderer.Set_No_Newline (Enable => False);
Renderer.Render (Doc);
Stream.Iterate (Get'Access);
end Check;
begin
for I in Test_Chars'Range loop
Check (Test_Chars (I) & "");
end loop;
for J in Test_Chars'Range loop
for I in Test_Chars'Range loop
Check (Test_Chars (I) & Test_Chars (J) & "");
end loop;
end loop;
end Test_Wiki_UTF_8;
end Wiki.Parsers.Tests;
|
reznikmm/matreshka | Ada | 4,618 | 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.Text_S_Elements;
package Matreshka.ODF_Text.S_Elements is
type Text_S_Element_Node is
new Matreshka.ODF_Text.Abstract_Text_Element_Node
and ODF.DOM.Text_S_Elements.ODF_Text_S
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_S_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_S_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Text_S_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 Text_S_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 Text_S_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_Text.S_Elements;
|
io7m/coreland-posix-ada | Ada | 756 | adb | with POSIX.Error;
use type POSIX.Error.Error_t;
with POSIX.File;
with POSIX.Permissions;
with Test;
procedure T_Open1 is
Error_Value : POSIX.Error.Error_t;
Descriptor : POSIX.File.Descriptor_t;
begin
POSIX.File.Unlink ("tmp/open1", Error_Value);
Test.Assert (Error_Value'Valid);
POSIX.File.Open_Create
(File_Name => "tmp/open1",
Non_Blocking => False,
Mode => POSIX.Permissions.Default_File_Mode,
Descriptor => Descriptor,
Error_Value => Error_Value);
Test.Assert (Error_Value = POSIX.Error.Error_None);
POSIX.File.Close (Descriptor, Error_Value);
Test.Assert (Error_Value = POSIX.Error.Error_None);
POSIX.File.Unlink ("tmp/open1", Error_Value);
Test.Assert (Error_Value'Valid);
end T_Open1;
|
leo-brewin/adm-bssn-numerical | Ada | 8,064 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Support; use Support;
with Support.Cmdline; use Support.Cmdline;
with Support.Strings; use Support.Strings;
with Support.RegEx; use Support.RegEx;
with Ada.Directories;
procedure Ada_Merge is
txt : File_Type;
max_recurse_depth : Constant := 10;
recurse_depth : Integer := 0;
src_file_name : String := read_command_arg ('i',"<no-source>");
out_file_name : String := read_command_arg ('o',"<no-output>");
silent : Boolean := find_command_arg ('S'); -- true: do not wrap include text in beg/end pairs
markup : Boolean := not silent; -- true: do wrap include text in beg/end pairs
function File_Exists (the_file_name : string) return boolean renames Ada.Directories.Exists;
procedure include_files
(prev_path : String;
this_line : String;
prev_indent : Integer)
is
-- allow simple variations of the Input syntax:
-- \Input for TeX, use \Input to avoid confusion with \input
-- $Input for Ada/Python/Cadabra
-- note that this is only for convenience, the comment string will be deduced
-- from the file extension of the Input'ed file
re_inc_file : String := "^[\t ]*(\\|\$)Input\{""([_a-zA-Z0-9./-]+)""\}";
-- this function is not used
function not_tex_comment
(the_line : String)
return Boolean
is
re_tex_comment : String := "^\s*%";
begin
return (not grep (the_line, re_tex_comment));
end not_tex_comment;
function is_include_file
(the_line : String)
Return Boolean
is
begin
return grep (the_line,re_inc_file);
end is_include_file;
function absolute_path
(the_path : String; -- full path to most recent include file, e.g. foo/bah/cow.tex
the_line : String) -- contains relative path to new include file, e.g., \Input{"cat/dot/fly.tex"}
Return String -- full path to new include file, e.g., foo/bah/cat/dog/fly.tex
is
re_dirname : String := "([_a-zA-Z0-9./-]*\/)"; -- as per dirname in bash
tmp_path : String (1..the_path'last+the_line'last); -- overestimate length of string
new_path : String (1..the_path'last+the_line'last);
begin
-- drop the simple file name from the existing path
writestr (tmp_path, trim ( grep (the_path,re_dirname,1,fail => "") ));
-- append new file path to the path
writestr (new_path, cut(tmp_path)&trim ( grep (the_line,re_inc_file,2,fail => "") ));
return cut(new_path);
end absolute_path;
function absolute_indent
(indent : Integer;
the_line : String)
Return Integer
is
start : Integer;
begin
start := 0;
for i in the_line'Range loop
if the_line (i) /= ' ' then
start := max(0,i-1);
exit;
end if;
end loop;
return indent + start;
end absolute_indent;
function set_comment (the_line : String) return String
is
re_file_ext : String := "(\.[a-z]+)""";
the_ext : String := grep (the_line,re_file_ext,1,fail => "?");
begin
if markup then
if the_ext = ".tex" then return "%";
elsif the_ext = ".py" then return "#";
elsif the_ext = ".cdb" then return "#";
elsif the_ext = ".ads" then return "--";
elsif the_ext = ".adb" then return "--";
elsif the_ext = ".adt" then return "--";
elsif the_ext = ".ad" then return "--";
else return "#";
end if;
else
return "#";
end if;
end set_comment;
function filter (the_line : String) return String
is
tmp_line : String := the_line;
re_uuid : String := "(uuid):([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12})";
the_beg, the_end : Integer;
found : Boolean;
begin
-- "uuid" is reserved for the original source
-- the new file being created by this job must use a prefix other than "uuid"
-- replace the prefix "uuid" with "file"
if regex_match (the_line, re_uuid) then
grep (the_beg, the_end, found, the_line, re_uuid, 1);
tmp_line (the_beg..the_end) := "file";
end if;
return tmp_line;
end filter;
begin
recurse_depth := recurse_depth + 1;
if recurse_depth > max_recurse_depth then
Put_Line ("> merge-src: Too many nested Input{...}'s (max = "&str(max_recurse_depth)&"), exit");
halt(1);
end if;
declare
src : File_Type;
the_path : String := absolute_path (prev_path, this_line);
the_indent : Integer := absolute_indent (prev_indent, this_line);
comment : String := set_comment (this_line);
begin
if markup then
Put_Line (txt, spc(the_indent)&comment&" beg"&make_str(recurse_depth,2)&": ./" & the_path);
end if;
if File_Exists (the_path)
then Open (src, In_File, the_path);
else raise Name_Error with "Could not find the file "&""""&str(the_path)&"""";
end if;
loop
begin
declare
the_line : String := filter (Get_Line (src));
begin
if is_include_file (the_line)
then include_files (the_path, the_line, the_indent);
else Put_Line (txt, spc(the_indent)&the_line);
end if;
end;
exception
when end_error => exit;
end;
end loop;
Close (src);
if markup then
Put_Line (txt, spc(the_indent)&comment&" end"&make_str(recurse_depth,2)&": ./" & the_path);
end if;
end;
recurse_depth := recurse_depth - 1;
end include_files;
procedure show_info is
begin
Put_Line ("------------------------------------------------------------------------------");
Put_Line (" Merges a set of source files into a single file.");
Put_Line (" Usage:");
Put_Line (" merge-src -i <source> -o <output> [-hS]");
Put_Line (" Files:");
Put_Line (" <source> : the source that may contain include statements in the form");
Put_Line (" \Input{file-name}");
Put_Line (" <output> : the merged file");
Put_Line (" Options:");
Put_Line (" -h : help, show this help message, then exit");
Put_Line (" -S : silent, do not wrap included text in beg/end pairs");
Put_Line (" Example:");
Put_Line (" merge-src -i driver.tex -o merged.tex");
Put_Line ("------------------------------------------------------------------------------");
end show_info;
procedure initialize is
begin
if find_command_arg ('h') then
show_info;
halt(0);
end if;
if src_file_name = out_file_name
then
Put_Line ("> merge-src: Indentical files names for input and output, exit.");
halt(1);
end if;
if not File_Exists (src_file_name) then
Put_Line ("> merge-src: Source file """ & cut (src_file_name) & """ not found, exit.");
halt(1);
end if;
end initialize;
begin
initialize;
-- copy the source to the output, but with \Input{...} fully expanded
Create (txt, Out_File, out_file_name);
include_files ("", "\Input{"""&src_file_name&"""}", 0);
Close (txt);
if recurse_depth /= 0 then
Put_Line("> merge-src: error during merger");
Put_Line("> recursion depth should be zero, actual value: "&str(recurse_depth));
end if;
end Ada_Merge;
|
zhmu/ananas | Ada | 178 | ads |
-- { dg-final { scan-tree-dump "= 1145258561|= 1094861636" "optimized" } }
package Opt82_Pkg is
type Rec is record
A, B, C, D : Character;
end record;
end Opt82_Pkg;
|
niechaojun/Amass | Ada | 830 | ads | -- Copyright 2017 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "Mnemonic"
type = "api"
function start()
setratelimit(1)
end
function vertical(ctx, domain)
local page, err = request({url=apiurl(domain)})
if (err ~= nil and err ~= '') then
return
end
local resp = json.decode(page)
if (resp == nil or resp["responseCode"] ~= 200) then
return
end
for i, tb in pairs(resp.data) do
if ((tb.rrtype == "a" or tb.rrtype == "aaaa") and inscope(ctx, tb.query)) then
newname(ctx, tb.query)
newaddr(ctx, tb.answer, tb.query)
end
end
end
function apiurl(domain)
return "https://api.mnemonic.no/pdns/v3/" .. domain
end
|
houey/Amass | Ada | 2,196 | ads | -- Copyright 2017-2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "GitHub"
type = "api"
function start()
setratelimit(7)
end
function check()
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c ~= nil and c.key ~= nil and c.key ~= "") then
return true
end
return false
end
function vertical(ctx, domain)
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c == nil or c.key == nil or c.key == "") then
return
end
for i=1,100 do
local vurl = buildurl(domain, i)
local resp, err = request(ctx, {
url=vurl,
headers={
['Authorization']="token " .. c.key,
['Content-Type']="application/json",
},
})
if (err ~= nil and err ~= "") then
return
end
local d = json.decode(resp)
if (d == nil or d['total_count'] == 0 or #(d.items) == 0) then
return
end
for i, item in pairs(d.items) do
search_item(ctx, item)
end
end
end
function search_item(ctx, item)
local info, err = request(ctx, {
url=item.url,
headers={['Content-Type']="application/json"},
})
if (err ~= nil and err ~= "") then
return
end
local data = json.decode(info)
if (data == nil or data['download_url'] == nil) then
return
end
local content, err = request(ctx, {url=data['download_url']})
if err == nil then
sendnames(ctx, content)
end
end
function buildurl(domain, pagenum)
return "https://api.github.com/search/code?q=\"" .. domain .. "\"&page=" .. pagenum .. "&per_page=100"
end
function sendnames(ctx, content)
local names = find(content, subdomainre)
if names == nil then
return
end
local found = {}
for i, v in pairs(names) do
if found[v] == nil then
newname(ctx, v)
found[v] = true
end
end
end
|
ohenley/ada-util | Ada | 5,963 | adb | -----------------------------------------------------------------------
-- util-locales -- Locale support
-- Copyright (C) 2001, 2002, 2003, 2009, 2010, 2011, 2015, 2018 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.Hash;
package body Util.Locales is
-- ------------------------------
-- Get the lowercase two-letter ISO-639 code.
-- ------------------------------
function Get_Language (Loc : in Locale) return String is
begin
if Loc = null then
return "";
else
return Loc (1 .. 2);
end if;
end Get_Language;
-- ------------------------------
-- Get the ISO 639-2 language code.
-- ------------------------------
function Get_ISO3_Language (Loc : in Locale) return String is
begin
if Loc = null or else Loc'Length <= 3 then
return "";
end if;
if Loc'Length <= 6 then
return Loc (4 .. 6);
end if;
return Loc (7 .. 9);
end Get_ISO3_Language;
-- ------------------------------
-- Get the uppercase two-letter ISO-3166 code.
-- ------------------------------
function Get_Country (Loc : in Locale) return String is
begin
if Loc = null or else Loc'Length <= 2 or else Loc (3) /= '_' then
return "";
else
return Loc (4 .. 5);
end if;
end Get_Country;
-- ------------------------------
-- Get the ISO-3166-2 country code.
-- ------------------------------
function Get_ISO3_Country (Loc : in Locale) return String is
begin
if Loc = null or else Loc'Length <= 5 then
return "";
else
return Loc (10 .. Loc'Last);
end if;
end Get_ISO3_Country;
-- ------------------------------
-- Get the variant code
-- ------------------------------
function Get_Variant (Loc : in Locale) return String is
begin
if Loc = null or else Loc'Length <= 13 then
return "";
else
return Loc (7 .. 8);
end if;
end Get_Variant;
-- ------------------------------
-- Get the locale for the given language code
-- ------------------------------
function Get_Locale (Language : in String) return Locale is
Length : constant Natural := Language'Length;
Lower : Natural := Locales'First;
Upper : Natural := Locales'Last;
Pos : Natural;
Result : Locale;
begin
while Lower <= Upper loop
Pos := (Lower + Upper) / 2;
Result := Locales (Pos);
if Result'Length < Length then
if Result.all < Language (Language'First .. Language'First + Result'Length - 1) then
Lower := Pos + 1;
else
Upper := Pos - 1;
end if;
elsif Result'Length > Length and then Result (Length + 1) = '.'
and then Result (1 .. Length) = Language
then
return Result;
elsif Result (1 .. Length) < Language then
Lower := Pos + 1;
else
Upper := Pos - 1;
end if;
end loop;
return NULL_LOCALE;
end Get_Locale;
-- ------------------------------
-- Get the locale for the given language and country code
-- ------------------------------
function Get_Locale (Language : in String;
Country : in String) return Locale is
begin
if Language'Length /= 2 or else (Country'Length /= 0 and Country'Length /= 2) then
return NULL_LOCALE;
elsif Country'Length = 0 then
return Get_Locale (Language);
else
return Get_Locale (Language & "_" & Country);
end if;
end Get_Locale;
-- ------------------------------
-- Get the locale for the given language, country and variant code
-- ------------------------------
function Get_Locale (Language : in String;
Country : in String;
Variant : in String) return Locale is
begin
if Language'Length /= 2
or else (Country'Length /= 0 and Country'Length /= 2)
or else (Variant'Length /= 0 and Variant'Length /= 2)
then
return NULL_LOCALE;
end if;
if Country'Length = 0 and Variant'Length = 0 then
return Get_Locale (Language);
elsif Variant'Length = 0 then
return Get_Locale (Language, Country);
else
return Get_Locale (Language & "_" & Country & "_" & Variant);
end if;
end Get_Locale;
-- ------------------------------
-- Get the locale code in the form <i>language</i>_<i>country</i>_<i>variant</i>.
-- ------------------------------
function To_String (Loc : in Locale) return String is
begin
if Loc = null then
return "";
elsif Loc'Length > 3 and Loc (3) = '.' then
return Loc (1 .. 2);
elsif Loc'Length > 6 and Loc (6) = '.' then
return Loc (1 .. 5);
else
return Loc (1 .. 8);
end if;
end To_String;
-- ------------------------------
-- Compute the hash value of the locale.
-- ------------------------------
function Hash (Loc : in Locale) return Ada.Containers.Hash_Type is
use type Ada.Containers.Hash_Type;
begin
return Ada.Strings.Hash (Loc.all);
end Hash;
end Util.Locales;
|
aherd2985/Amass | Ada | 835 | ads | -- Copyright 2017 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "Mnemonic"
type = "api"
function start()
setratelimit(1)
end
function vertical(ctx, domain)
local page, err = request(ctx, {url=apiurl(domain)})
if (err ~= nil and err ~= '') then
return
end
local resp = json.decode(page)
if (resp == nil or resp["responseCode"] ~= 200) then
return
end
for i, tb in pairs(resp.data) do
if ((tb.rrtype == "a" or tb.rrtype == "aaaa") and inscope(ctx, tb.query)) then
newname(ctx, tb.query)
newaddr(ctx, tb.answer, tb.query)
end
end
end
function apiurl(domain)
return "https://api.mnemonic.no/pdns/v3/" .. domain
end
|
reznikmm/gela | Ada | 4,591 | ads | with Gela.Elements.Defining_Names;
with Gela.Elements.Full_Type_Declarations;
with Gela.Elements.Formal_Type_Declarations;
with Gela.Elements.Subtype_Marks;
with Gela.Elements.Discriminant_Parts;
with Gela.Lexical_Types;
with Gela.Semantic_Types;
with Gela.Types.Simple;
with Gela.Types.Untagged_Records;
with Gela.Types.Visitors;
with Gela.Type_Categories;
package Gela.Plain_Type_Views is
pragma Preelaborate;
type Type_View is new Gela.Type_Categories.Type_View
and Gela.Types.Simple.Character_Type
and Gela.Types.Simple.Enumeration_Type
and Gela.Types.Simple.Signed_Integer_Type
and Gela.Types.Simple.Floating_Point_Type
and Gela.Types.Simple.Object_Access_Type
and Gela.Types.Simple.Subprogram_Access_Type
and Gela.Types.Untagged_Records.Untagged_Record_Type with private;
type Type_View_Access is access all Type_View'Class;
function Create_Full_Type
(Index : Gela.Semantic_Types.Type_View_Index;
Category : Gela.Type_Categories.Category_Kinds;
Decl : Gela.Elements.Full_Type_Declarations
.Full_Type_Declaration_Access)
return Gela.Type_Categories.Type_View_Access;
function Create_Root_Type
(Index : Gela.Semantic_Types.Type_View_Index;
Category : Gela.Type_Categories.Category_Kinds;
Decl : Gela.Elements.Full_Type_Declarations
.Full_Type_Declaration_Access)
return Gela.Type_Categories.Type_View_Access;
function Create_Formal_Type
(Index : Gela.Semantic_Types.Type_View_Index;
Category : Gela.Type_Categories.Category_Kinds;
Decl : Gela.Elements.Formal_Type_Declarations
.Formal_Type_Declaration_Access)
return Gela.Type_Categories.Type_View_Access;
private
type Type_View is new Gela.Type_Categories.Type_View
and Gela.Types.Simple.Character_Type
and Gela.Types.Simple.Enumeration_Type
and Gela.Types.Simple.Signed_Integer_Type
and Gela.Types.Simple.Floating_Point_Type
and Gela.Types.Simple.Object_Access_Type
and Gela.Types.Simple.Subprogram_Access_Type
and Gela.Types.Untagged_Records.Untagged_Record_Type with
record
Index : Gela.Semantic_Types.Type_View_Index;
Category : Gela.Type_Categories.Category_Kinds;
Def : access Gela.Elements.Element'Class;
Name : Gela.Elements.Defining_Names.Defining_Name_Access;
Discr : Gela.Elements.Discriminant_Parts.Discriminant_Part_Access;
end record;
overriding function Category
(Self : Type_View) return Gela.Type_Categories.Category_Kinds;
overriding function Get_Discriminant
(Self : Type_View;
Symbol : Gela.Lexical_Types.Symbol)
return Gela.Elements.Defining_Names.Defining_Name_Access;
overriding function Get_Component
(Self : Type_View;
Symbol : Gela.Lexical_Types.Symbol)
return Gela.Elements.Defining_Names.Defining_Name_Access;
overriding function Get_Designated
(Self : Type_View)
return Gela.Elements.Subtype_Marks.Subtype_Mark_Access;
overriding function Is_The_Same_Type
(Left : Type_View;
Right : Gela.Types.Type_View'Class) return Boolean;
overriding function Is_Expected_Type
(Self : Type_View;
Expected : not null Gela.Types.Type_View_Access) return Boolean;
overriding procedure Visit
(Self : not null access Type_View;
Visiter : in out Gela.Types.Visitors.Type_Visitor'Class);
overriding function Is_Array (Self : Type_View) return Boolean;
overriding function Is_Character (Self : Type_View) return Boolean;
overriding function Is_Enumeration (Self : Type_View) return Boolean;
overriding function Is_Floating_Point (Self : Type_View) return Boolean;
overriding function Is_Modular_Integer (Self : Type_View) return Boolean;
overriding function Is_Object_Access (Self : Type_View) return Boolean;
overriding function Is_Record (Self : Type_View) return Boolean;
overriding function Is_Signed_Integer (Self : Type_View) return Boolean;
overriding function Is_Universal (Self : Type_View) return Boolean;
overriding function Is_Root (Self : Type_View) return Boolean;
overriding function Defining_Name (Self : Type_View)
return Gela.Elements.Defining_Names.Defining_Name_Access;
overriding function Type_View_Index
(Self : Type_View) return Gela.Semantic_Types.Type_View_Index;
type Root_Type_View is new Type_View with null record;
overriding function Is_Root (Self : Root_Type_View) return Boolean;
end Gela.Plain_Type_Views;
|
twdroeger/ada-awa | Ada | 3,805 | adb | -----------------------------------------------------------------------
-- awa-mail-components-messages -- Mail UI Message
-- Copyright (C) 2012 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;
with AWA.Mail.Clients;
package body AWA.Mail.Components.Messages is
-- ------------------------------
-- Set the mail message instance.
-- ------------------------------
procedure Set_Message (UI : in out UIMailMessage;
Message : in AWA.Mail.Clients.Mail_Message_Access) is
begin
UI.Message := Message;
end Set_Message;
-- ------------------------------
-- Get the mail message instance.
-- ------------------------------
overriding
function Get_Message (UI : in UIMailMessage) return AWA.Mail.Clients.Mail_Message_Access is
begin
return UI.Message;
end Get_Message;
-- ------------------------------
-- Render the end of the input component. Closes the DL/DD list.
-- ------------------------------
overriding
procedure Encode_End (UI : in UIMailMessage;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
use type AWA.Mail.Clients.Mail_Message_Access;
begin
if UI.Message /= null and UI.Is_Rendered (Context) then
UI.Message.Send;
end if;
end Encode_End;
-- ------------------------------
-- Finalize and release the mail message.
-- ------------------------------
overriding
procedure Finalize (UI : in out UIMailMessage) is
procedure Free is
new Ada.Unchecked_Deallocation (Object => AWA.Mail.Clients.Mail_Message'Class,
Name => AWA.Mail.Clients.Mail_Message_Access);
begin
Free (UI.Message);
end Finalize;
-- ------------------------------
-- Render the mail subject and initializes the message with its content.
-- ------------------------------
overriding
procedure Encode_Children (UI : in UIMailSubject;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
procedure Process (Content : in String);
procedure Process (Content : in String) is
Msg : constant AWA.Mail.Clients.Mail_Message_Access := UI.Get_Message;
begin
Msg.Set_Subject (Content);
end Process;
begin
UI.Wrap_Encode_Children (Context, Process'Access);
end Encode_Children;
-- ------------------------------
-- Render the mail body and initializes the message with its content.
-- ------------------------------
overriding
procedure Encode_Children (UI : in UIMailBody;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
procedure Process (Content : in String);
procedure Process (Content : in String) is
Msg : constant AWA.Mail.Clients.Mail_Message_Access := UI.Get_Message;
begin
Msg.Set_Body (Content);
end Process;
begin
UI.Wrap_Encode_Children (Context, Process'Access);
end Encode_Children;
end AWA.Mail.Components.Messages;
|
AdaCore/libadalang | Ada | 287 | adb | procedure Foo is
π : constant Float := 3.14;
["00E9"] : Wide_Character := '["00E9"]';
begin
-- Test case folding: the above is a lower-case pi while there is an
-- upper-case below.
pragma Test (Π);
-- Test brackets decoding
pragma Test (É);
end Foo;
|
OneWingedShark/Byron | Ada | 126 | ads | With
Lexington.Aux.Constants.Token_Set;
Package Lexington.Token_Set_Pkg.Constants
renames Lexington.Aux.Constants.Token_Set;
|
faelys/ada-syslog | Ada | 1,317 | adb | ------------------------------------------------------------------------------
-- Copyright (c) 2014, 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. --
------------------------------------------------------------------------------
with GNAT.Sockets;
procedure Syslog.Guess.Hostname is
begin
Set_Hostname (GNAT.Sockets.Host_Name);
end Syslog.Guess.Hostname;
|
docandrew/troodon | Ada | 6,684 | ads | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Extensions;
package bits_thread_shared_types_h is
-- Common threading primitives definitions for both POSIX and C11.
-- Copyright (C) 2017-2021 Free Software Foundation, Inc.
-- This file is part of the GNU C Library.
-- The GNU C Library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
-- The GNU C Library 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
-- Lesser General Public License for more details.
-- You should have received a copy of the GNU Lesser General Public
-- License along with the GNU C Library; if not, see
-- <https://www.gnu.org/licenses/>.
-- Arch-specific definitions. Each architecture must define the following
-- macros to define the expected sizes of pthread data types:
-- __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t.
-- __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t.
-- __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t.
-- __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t.
-- __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t.
-- __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t.
-- __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t.
-- __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t.
-- __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t.
-- The additional macro defines any constraint for the lock alignment
-- inside the thread structures:
-- __LOCK_ALIGNMENT - for internal lock/futex usage.
-- Same idea but for the once locking primitive:
-- __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition.
-- Common definition of pthread_mutex_t.
type uu_pthread_internal_list;
type uu_pthread_internal_list is record
uu_prev : access uu_pthread_internal_list; -- /usr/include/bits/thread-shared-types.h:51
uu_next : access uu_pthread_internal_list; -- /usr/include/bits/thread-shared-types.h:52
end record
with Convention => C_Pass_By_Copy; -- /usr/include/bits/thread-shared-types.h:49
subtype uu_pthread_list_t is uu_pthread_internal_list; -- /usr/include/bits/thread-shared-types.h:53
type uu_pthread_internal_slist;
type uu_pthread_internal_slist is record
uu_next : access uu_pthread_internal_slist; -- /usr/include/bits/thread-shared-types.h:57
end record
with Convention => C_Pass_By_Copy; -- /usr/include/bits/thread-shared-types.h:55
subtype uu_pthread_slist_t is uu_pthread_internal_slist; -- /usr/include/bits/thread-shared-types.h:58
-- Arch-specific mutex definitions. A generic implementation is provided
-- by sysdeps/nptl/bits/struct_mutex.h. If required, an architecture
-- can override it by defining:
-- 1. struct __pthread_mutex_s (used on both pthread_mutex_t and mtx_t
-- definition). It should contains at least the internal members
-- defined in the generic version.
-- 2. __LOCK_ALIGNMENT for any extra attribute for internal lock used with
-- atomic operations.
-- 3. The macro __PTHREAD_MUTEX_INITIALIZER used for static initialization.
-- It should initialize the mutex internal flag.
-- Arch-sepecific read-write lock definitions. A generic implementation is
-- provided by struct_rwlock.h. If required, an architecture can override it
-- by defining:
-- 1. struct __pthread_rwlock_arch_t (used on pthread_rwlock_t definition).
-- It should contain at least the internal members defined in the
-- generic version.
-- 2. The macro __PTHREAD_RWLOCK_INITIALIZER used for static initialization.
-- It should initialize the rwlock internal type.
-- Common definition of pthread_cond_t.
type anon_4 is record
uu_low : aliased unsigned; -- /usr/include/bits/thread-shared-types.h:99
uu_high : aliased unsigned; -- /usr/include/bits/thread-shared-types.h:100
end record
with Convention => C_Pass_By_Copy;
type anon_3 (discr : unsigned := 0) is record
case discr is
when 0 =>
uu_wseq : aliased Extensions.unsigned_long_long; -- /usr/include/bits/thread-shared-types.h:96
when others =>
uu_wseq32 : aliased anon_4; -- /usr/include/bits/thread-shared-types.h:101
end case;
end record
with Convention => C_Pass_By_Copy,
Unchecked_Union => True;
type anon_6 is record
uu_low : aliased unsigned; -- /usr/include/bits/thread-shared-types.h:108
uu_high : aliased unsigned; -- /usr/include/bits/thread-shared-types.h:109
end record
with Convention => C_Pass_By_Copy;
type anon_5 (discr : unsigned := 0) is record
case discr is
when 0 =>
uu_g1_start : aliased Extensions.unsigned_long_long; -- /usr/include/bits/thread-shared-types.h:105
when others =>
uu_g1_start32 : aliased anon_6; -- /usr/include/bits/thread-shared-types.h:110
end case;
end record
with Convention => C_Pass_By_Copy,
Unchecked_Union => True;
type uu_pthread_cond_s_array992 is array (0 .. 1) of aliased unsigned;
type uu_pthread_cond_s is record
parent : aliased anon_3;
field_2 : aliased anon_5;
uu_g_refs : aliased uu_pthread_cond_s_array992; -- /usr/include/bits/thread-shared-types.h:112
uu_g_size : aliased uu_pthread_cond_s_array992; -- /usr/include/bits/thread-shared-types.h:113
uu_g1_orig_size : aliased unsigned; -- /usr/include/bits/thread-shared-types.h:114
uu_wrefs : aliased unsigned; -- /usr/include/bits/thread-shared-types.h:115
uu_g_signals : aliased uu_pthread_cond_s_array992; -- /usr/include/bits/thread-shared-types.h:116
end record
with Convention => C_Pass_By_Copy; -- /usr/include/bits/thread-shared-types.h:92
subtype uu_tss_t is unsigned; -- /usr/include/bits/thread-shared-types.h:119
subtype uu_thrd_t is unsigned_long; -- /usr/include/bits/thread-shared-types.h:120
-- skipped anonymous struct anon_7
type uu_once_flag is record
uu_data : aliased int; -- /usr/include/bits/thread-shared-types.h:124
end record
with Convention => C_Pass_By_Copy; -- /usr/include/bits/thread-shared-types.h:125
end bits_thread_shared_types_h;
|
Componolit/libsparkcrypto | Ada | 2,760 | adb | -------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2010, Alexander Senier
-- Copyright (C) 2010, 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 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.Byteswap32;
package body LSC.Internal.Byteorder32 is
function Native_To_BE (Item : Types.Word32) return Types.Word32
is
begin
return Item;
end Native_To_BE;
---------------------------------------------------------------------------
function Native_To_LE (Item : Types.Word32) return Types.Word32
is
begin
return Byteswap32.Swap (Item);
end Native_To_LE;
---------------------------------------------------------------------------
function BE_To_Native (Item : Types.Word32) return Types.Word32
is
begin
return Item;
end BE_To_Native;
---------------------------------------------------------------------------
function LE_To_Native (Item : Types.Word32) return Types.Word32
is
begin
return Byteswap32.Swap (Item);
end LE_To_Native;
end LSC.Internal.Byteorder32;
|
burratoo/Acton | Ada | 13,235 | adb | ------------------------------------------------------------------------------------------
-- --
-- ACTON PROCESSOR SUPPORT PACKAGE --
-- --
-- ATMEL.AT91SAM7S.USART --
-- --
-- Copyright (C) 2014-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
with Atmel.AT91SAM7S.AIC;
with Atmel.AT91SAM7S.PIO; use Atmel.AT91SAM7S.PIO;
with Atmel.AT91SAM7S.PMC; use Atmel.AT91SAM7S.PMC;
package body Atmel.AT91SAM7S.USART is
procedure Initialise_Interface
(Interface_Id : in USART_Id;
USART_Settings : in Mode_Type;
Receiver_Timeout : in Unsigned_16;
Baud_Rate : in Baud_Rate_Generator_Type) is
begin
case Interface_Id is
when 0 =>
null;
-- USART_Interface_0.Initialise_Interface
-- (USART_Settings, Baud_Rate);
when 1 =>
USART_Interface_1.Initialise_Interface
(USART_Settings,
Receiver_Timeout,
Baud_Rate);
end case;
end Initialise_Interface;
procedure Reset_Interface (Interface_Id : in USART_Id) is
begin
case Interface_Id is
when 0 =>
null;
-- USART_Interface_0.Initialise_Interface
-- (USART_Settings, Baud_Rate);
when 1 =>
USART_Interface_1.Reset_Interface;
end case;
end Reset_Interface;
function Interface_Is_Ready (Interface_Id : USART_Id) return Boolean is
begin
case Interface_Id is
when 0 =>
return False;
-- return PMC.Peripheral_Clock_Status_Register (P_US0) = Enabled;
when 1 =>
return PMC.Peripheral_Clock_Status_Register (P_US1) = Enabled;
end case;
end Interface_Is_Ready;
procedure Exchange_Data
(Using_Interface : in USART_Id;
Send_Message : in Address;
Send_Message_Length : in Unsigned_16;
Recieve_Message : in Address;
Recieve_Message_Length : in Unsigned_16) is
begin
case Using_Interface is
when 0 =>
null;
-- USART_Interface_0.Exchange_Data
-- (Send_Message => Send_Message,
-- Send_Message_Length => Send_Message_Length,
-- Recieve_Message => Recieve_Message,
-- Recieve_Message_Length => Recieve_Message_Length);
-- USART_Interface_0.Wait_For_Transmission;
when 1 =>
USART_Interface_1.Exchange_Data
(Send_Message => Send_Message,
Send_Message_Length => Send_Message_Length,
Recieve_Message => Recieve_Message,
Recieve_Message_Length => Recieve_Message_Length);
USART_Interface_1.Wait_For_Transmission;
end case;
end Exchange_Data;
function Receive_Bytes_Remaining (On_Interface : USART_Id) return Natural is
begin
case On_Interface is
when 0 =>
return 0;
when 1 =>
return Natural (USART (1).Receive_Counter_Register);
end case;
end Receive_Bytes_Remaining;
-- protected body USART_Interface_0 is
-- procedure Initialise_Interface
-- (USART_Settings : in Mode_Type;
-- Baud_Rate : in Baud_Rate_Generator_Type) is
-- begin
-- -- Turn on USART Clock
-- PMC.Peripheral_Clock_Enable_Register :=
-- (P_US0 => Enable,
-- others => No_Change);
--
-- -- Setup Pins
--
-- PIO.PIO_Disable_Register :=
-- (IO_Line_A_USART_RXD0 => Disable,
-- IO_Line_A_USART_TXD0 => Disable,
-- IO_Line_B_USART_SCK0 => Disable,
-- others => No_Change);
--
-- PIO.Peripheral_A_Select_Register :=
-- (IO_Line_A_USART_RXD0 => PIO.Use_Peripheral,
-- IO_Line_A_USART_TXD0 => PIO.Use_Peripheral,
-- others => PIO.No_Change);
--
-- PIO.Peripheral_B_Select_Register :=
-- (IO_Line_B_USART_SCK0 => PIO.Use_Peripheral,
-- others => PIO.No_Change);
--
-- if USART_Settings.USART_Mode = Hardware_Handshaking then
-- PIO.PIO_Disable_Register :=
-- (IO_Line_A_USART_RTS0 => Disable,
-- IO_Line_A_USART_CTS0 => Disable,
-- others => No_Change);
--
-- PIO.Peripheral_A_Select_Register :=
-- (IO_Line_A_USART_RTS0 => PIO.Use_Peripheral,
-- IO_Line_A_USART_CTS0 => PIO.Use_Peripheral,
-- others => No_Change);
-- end if;
--
-- -- Setup USART unit
--
-- USART (0).Mode_Register := USART_Settings;
-- USART (0).Control_Register :=
-- (Receiver_State => Enable,
-- Transmitter_State => Enable,
-- Break => No_Change,
-- Data_Terminal_Ready_State => No_Change,
-- Request_To_Send_State => No_Change,
-- others => False);
--
-- USART (0).Transfer_Control_Register :=
-- (Receiver_Transfer_Enable => Enable,
-- Transmitter_Transfer_Enable => Enable,
-- others => No_Change);
-- end Initialise_Interface;
--
-- procedure Exchange_Data
-- (Send_Message : in Address;
-- Send_Message_Length : in Unsigned_16;
-- Recieve_Message : in Address;
-- Recieve_Message_Length : in Unsigned_16) is
-- begin
-- Transfer_Completed := False;
--
-- if Send_Message /= Null_Address and then Send_Message_Length > 0
-- then
-- USART (0).Transmit_Pointer_Register := Send_Message;
-- USART (0).Transmit_Counter_Register := Send_Message_Length;
-- USART (0).Interrupt_Enable_Register :=
-- (End_Of_Transmitter_Transfer => Enable,
-- others => No_Change);
-- end if;
--
-- if Recieve_Message /= Null_Address and then Recieve_Message_Length
-- > 0 then
-- USART (0).Receive_Pointer_Register := Recieve_Message;
-- USART (0).Receive_Counter_Register := Recieve_Message_Length;
-- USART (0).Interrupt_Enable_Register :=
-- (End_Of_Receive_Transfer => Enable,
-- others => No_Change);
-- end if;
-- end Exchange_Data;
--
-- entry Wait_For_Transmission when Transfer_Completed is
-- begin
-- null;
-- end Wait_For_Transmission;
--
--
-- procedure Interface_Handler is
-- begin
-- if USART (0).Channel_Status_Register.End_Of_Transmitter_Transfer
-- and USART (0).Channel_Status_Register.End_Of_Receive_Transfer
-- then
-- USART (0).Interrupt_Disable_Register :=
-- (End_Of_Transmitter_Transfer => Disable,
-- End_Of_Receive_Transfer => Disable,
-- others => No_Change);
-- Transfer_Completed := True;
-- end if;
-- end Interface_Handler;
--
-- end USART_Interface_0;
protected body USART_Interface_1 is
procedure Initialise_Interface
(USART_Settings : in Mode_Type;
Receiver_Timeout : in Unsigned_16;
Baud_Rate : in Baud_Rate_Generator_Type) is
begin
-- Turn on USART Clock
PMC.Peripheral_Clock_Enable_Register :=
(P_US1 => Enable,
others => No_Change);
-- Setup Pins
PIO.PIO_Disable_Register :=
(IO_Line_A_USART_RXD1 => Disable,
IO_Line_A_USART_TXD1 => Disable,
IO_Line_A_USART_SCK1 => Disable,
others => No_Change);
PIO.Peripheral_A_Select_Register :=
(IO_Line_A_USART_RXD1 => PIO.Use_Peripheral,
IO_Line_A_USART_TXD1 => PIO.Use_Peripheral,
IO_Line_A_USART_SCK1 => PIO.Use_Peripheral,
others => PIO.No_Change);
if USART_Settings.USART_Mode = Hardware_Handshaking then
PIO.PIO_Disable_Register :=
(IO_Line_A_USART_RTS1 => Disable,
IO_Line_A_USART_CTS1 => Disable,
others => No_Change);
PIO.Peripheral_A_Select_Register :=
(IO_Line_A_USART_RTS1 => PIO.Use_Peripheral,
IO_Line_A_USART_CTS1 => PIO.Use_Peripheral,
others => No_Change);
end if;
USART (1).Mode_Register := USART_Settings;
USART (1).Control_Register :=
(Receiver_State => Enable,
Transmitter_State => Enable,
Break => No_Change,
Data_Terminal_Ready_State => No_Change,
Request_To_Send_State => No_Change,
others => False);
USART (1).Transfer_Control_Register :=
(Receiver_Transfer => Enable,
Transmitter_Transfer => Enable);
USART (1).Baud_Rate_Generator_Register := Baud_Rate;
USART (1).Receiver_Time_Out_Register.Value := Receiver_Timeout;
AIC.Interrupt_Enable_Command_Register.Interrupt :=
(P_US1 => Enable,
others => No_Change);
end Initialise_Interface;
procedure Exchange_Data
(Send_Message : in Address;
Send_Message_Length : in Unsigned_16;
Recieve_Message : in Address;
Recieve_Message_Length : in Unsigned_16) is
begin
Transfer_Completed := False;
if Send_Message /= Null_Address and then Send_Message_Length > 0 then
USART (1).Transmit_Pointer_Register := Send_Message;
USART (1).Transmit_Counter_Register := Send_Message_Length;
USART (1).Interrupt_Enable_Register :=
(End_Of_Transmitter_Transfer => Enable,
others => No_Change);
end if;
if Recieve_Message /= Null_Address
and then Recieve_Message_Length > 0
then
USART (1).Receive_Pointer_Register := Recieve_Message;
USART (1).Receive_Counter_Register := Recieve_Message_Length;
USART (1).Interrupt_Enable_Register :=
(End_Of_Receive_Transfer => Enable,
Time_Out => Enable,
others => No_Change);
USART (1).Control_Register :=
(Rearm_Time_Out => False,
Start_Time_Out => True,
Receiver_State => No_Change,
Transmitter_State => No_Change,
Break => No_Change,
Data_Terminal_Ready_State => No_Change,
Request_To_Send_State => No_Change,
others => False);
end if;
end Exchange_Data;
entry Wait_For_Transmission when Transfer_Completed is
begin
null;
end Wait_For_Transmission;
procedure Reset_Interface is
begin
USART (1).Control_Register :=
(Reset_Receiver => True,
Reset_Transmitter => True,
Receiver_State => No_Change,
Transmitter_State => No_Change,
Break => No_Change,
Data_Terminal_Ready_State => No_Change,
Request_To_Send_State => No_Change,
others => False);
Transfer_Completed := True;
end Reset_Interface;
procedure Interface_Handler is
begin
if USART (1).Channel_Status_Register.End_Of_Transmitter_Transfer
and USART (1).Channel_Status_Register.End_Of_Receive_Transfer then
USART (1).Interrupt_Disable_Register :=
(End_Of_Transmitter_Transfer => Disable,
End_Of_Receive_Transfer => Disable,
Time_Out => Disable,
others => No_Change);
Transfer_Completed := True;
elsif USART (1).Channel_Status_Register.Time_Out then
USART (1).Interrupt_Disable_Register := (others => No_Change);
Transfer_Completed := True;
end if;
end Interface_Handler;
end USART_Interface_1;
end Atmel.AT91SAM7S.USART;
|
vpodzime/ada-util | Ada | 1,711 | ads | -----------------------------------------------------------------------
-- discrete properties -- Generic package for get/set of discrete properties
-- Copyright (C) 2001, 2002, 2003, 2006, 2008, 2009, 2010 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.
-----------------------------------------------------------------------
generic
type Property_Type is (<>);
-- with function To_String (Val : Property_Type) return String is <>;
-- with function From_String (Val : String) return Property_Type is <>;
package Util.Properties.Discrete is
-- Get the property value
function Get (Self : in Manager'Class;
Name : in String) return Property_Type;
-- Get the property value.
-- Return the default if the property does not exist.
function Get (Self : in Manager'Class;
Name : in String;
Default : in Property_Type) return Property_Type;
-- Set the property value
procedure Set (Self : in out Manager'Class;
Name : in String;
Value : in Property_Type);
end Util.Properties.Discrete;
|
reznikmm/matreshka | Ada | 3,981 | 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.Fo_Page_Width_Attributes;
package Matreshka.ODF_Fo.Page_Width_Attributes is
type Fo_Page_Width_Attribute_Node is
new Matreshka.ODF_Fo.Abstract_Fo_Attribute_Node
and ODF.DOM.Fo_Page_Width_Attributes.ODF_Fo_Page_Width_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Fo_Page_Width_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Fo_Page_Width_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Fo.Page_Width_Attributes;
|
reznikmm/matreshka | Ada | 6,760 | 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_Anim.Param_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Anim_Param_Element_Node is
begin
return Self : Anim_Param_Element_Node do
Matreshka.ODF_Anim.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Anim_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Anim_Param_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Anim_Param
(ODF.DOM.Anim_Param_Elements.ODF_Anim_Param_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Anim_Param_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Param_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Anim_Param_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Anim_Param
(ODF.DOM.Anim_Param_Elements.ODF_Anim_Param_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Anim_Param_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) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Anim_Param
(Visitor,
ODF.DOM.Anim_Param_Elements.ODF_Anim_Param_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Anim_URI,
Matreshka.ODF_String_Constants.Param_Element,
Anim_Param_Element_Node'Tag);
end Matreshka.ODF_Anim.Param_Elements;
|
jamiepg1/sdlada | Ada | 4,613 | ads | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2014 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.Palettes
--
-- Palettes, colours and various conversions.
--------------------------------------------------------------------------------------------------------------------
with Ada.Finalization;
with Ada.Iterator_Interfaces;
with Interfaces.C.Pointers;
package SDL.Video.Palettes is
package C renames Interfaces.C;
type Colour_Component is range 0 .. 255 with
Size => 8,
Convention => C;
type Colour is
record
Red : Colour_Component;
Green : Colour_Component;
Blue : Colour_Component;
alpha : Colour_Component;
end record with
Convention => C,
Size => Colour_Component'Size * 4;
for Colour use
record
Red at 0 range 0 .. 7;
Green at 0 range 8 .. 15;
Blue at 0 range 16 .. 23;
Alpha at 0 range 24 .. 31;
end record;
Null_Colour : constant Colour := Colour'(others => Colour_Component'First);
type RGB_Colour is
record
Red : Colour_Component;
Green : Colour_Component;
Blue : Colour_Component;
end record;
Null_RGB_Colour : constant RGB_Colour := RGB_Colour'(others => Colour_Component'First);
-- Cursor type for our iterator.
type Cursor is private;
No_Element : constant Cursor;
function Element (Position : in Cursor) return Colour;
function Has_Element (Position : Cursor) return Boolean;
-- Create the iterator interface package.
package Palette_Iterator_Interfaces is new
Ada.Iterator_Interfaces (Cursor, Has_Element);
type Palette is tagged limited private with
Default_Iterator => Iterate,
Iterator_Element => Colour,
Constant_Indexing => Constant_Reference;
type Palette_Access is access Palette;
function Constant_Reference
(Container : aliased Palette;
Position : Cursor) return Colour;
function Iterate (Container : Palette)
return Palette_Iterator_Interfaces.Forward_Iterator'Class;
function Create (Total_Colours : in Positive) return Palette;
procedure Free (Container : in out Palette);
Empty_Palette : constant Palette;
private
type Colour_Array is array (C.size_t range <>) of aliased Colour with
Convention => C;
package Colour_Array_Pointer is new Interfaces.C.Pointers
(Index => C.size_t,
Element => Colour,
Element_Array => Colour_Array,
Default_Terminator => Null_Colour);
type Internal_Palette is
record
Total : C.int;
Colours : Colour_array_Pointer.Pointer;
Version : Interfaces.Unsigned_32;
Ref_Count : C.int;
end record with
Convention => C;
type Internal_Palette_Access is access Internal_Palette with
Convention => C;
type Palette is tagged limited
record
Data : Internal_Palette_Access;
end record;
type Palette_Constant_Access is access constant Palette;
type Cursor is
record
Container : Palette_Constant_Access;
Index : Natural;
Current : Colour_array_Pointer.Pointer;
end record;
No_Element : constant Cursor := Cursor'(Container => null,
Index => Natural'First,
Current => null);
Empty_Palette : constant Palette := Palette'(Data => null);
end SDL.Video.Palettes;
|
stcarrez/ada-util | Ada | 2,589 | ads | -----------------------------------------------------------------------
-- util-http-rest -- REST API support
-- Copyright (C) 2012, 2013 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.Serialize.IO;
with Util.Http.Clients;
with Util.Serialize.Mappers.Record_Mapper;
-- The <b>Util.Http.Rest</b> package defines a REST client type which helps in writing
-- REST client APIs. A REST client is similar to an HTTP client but it provides additional
-- operations that are useful in REST APIs.
package Util.Http.Rest is
-- -----------------------
-- REST client
-- -----------------------
type Client is new Util.Http.Clients.Client with private;
-- Execute an HTTP GET operation using the <b>Http</b> client on the given <b>URI</b>.
-- Upon successful reception of the response, parse the JSON result and populate the
-- serialization context associated with the parser.
procedure Get (Http : in out Client;
URI : in String;
Parser : in out Util.Serialize.IO.Parser'Class;
Sink : in out Util.Serialize.IO.Reader'Class);
-- Execute an HTTP GET operation on the given <b>URI</b> and parse the JSON response
-- into the target object referred to by <b>Into</b> by using the mapping described
-- in <b>Mapping</b>.
generic
-- Package that maps the element into a record.
with package Element_Mapper is
new Util.Serialize.Mappers.Record_Mapper (<>);
procedure Rest_Get (URI : in String;
Mapping : in Util.Serialize.Mappers.Mapper_Access;
Path : in String := "";
Into : in Element_Mapper.Element_Type_Access);
private
type Client is new Util.Http.Clients.Client with record
Status : Natural := 0;
end record;
end Util.Http.Rest;
|
silky/synth | Ada | 7,404 | ads | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
private with Replicant.Platform;
package PortScan.Packages is
-- This routine first removes all invalid packages (package from removed
-- port or older version) and inserts the origins of the remaining packages
-- into the port list for a limited tree scan.
procedure preclean_repository (repository : String);
-- If performing a limited build run (likely 99% of the use cases), only
-- the queued packages will be checked. The checks are limited to finding
-- options changes and dependency changes. Obsolete packages (related or
-- unrelated to upcoming build) are not removed; this would occur in
-- clean_repository(). These old packages will not interfere at this step.
procedure limited_sanity_check (repository : String; dry_run : Boolean;
suppress_remote : Boolean);
-- Iterate through the final build queue to remove any packages that
-- match the current package names (currently unused)
procedure remove_queue_packages (repository : String);
-- This procedure empties the given repository without discrimination.
-- (Well, it's limited to "*.txz" matches, but normally that's everything)
-- (currently unused)
procedure wipe_out_repository (repository : String);
-- Sometimes, especially with the single ports-mgmt/pkg check, there is
-- nothing left to do after the sanity check. Let's provide a way to
-- detect that case.
function queue_is_empty return Boolean;
-- Returns the size of the queue before it was pared down.
function original_queue_size return Natural;
-- After the initial queue is created, and before the limited sanity
-- check, we go through each port and check if it has cached options.
-- If it does, then it's checked for validity. If it has too many or
-- too few options, or an option's name doesn't match, the port is
-- printed to stdout. The rest of the ports are checked, but at that
-- point the function has failed.
function limited_cached_options_check return Boolean;
-- Returns True on success; stores value in global external_repository
function located_external_repository return Boolean;
-- Returns the value of the stored external repository
function top_external_repository return String;
-- Given the path components for a package, query it for the port origin
function query_origin (fullpath : String) return String;
private
type dim_packages is array (scanners) of string_crate.Vector;
stored_packages : dim_packages;
stored_origins : dim_packages;
pkgscan_progress : dim_progress := (others => 0);
pkgscan_total : Natural := 0;
abi_formats : Replicant.package_abi;
external_repository : JT.Text;
original_queue_len : AC.Count_Type;
obsolete_pkg_log : TIO.File_Type;
obsolete_log_open : Boolean := False;
-- Debugging purposes only, can be turned on by environment variable
debug_dep_check : Boolean := False;
debug_opt_check : Boolean := False;
-- This function returns "True" if the scanned options exactly match
-- the options in the already-built package. Usually it's already known
-- that a package exists before the function is called, but an existence
-- check will be performed just in case (failure returns "False")
function passed_option_check (repository : String; id : port_id;
skip_exist_check : Boolean := False)
return Boolean;
-- This function returns "True" if the scanned dependencies match exactly
-- what the current ports tree has.
function passed_dependency_check (query_result : JT.Text; id : port_id)
return Boolean;
-- This function returns "True" if the scanned package has the expected
-- package ABI, e.g. dragonfly:4.6:x86:64, freebsd:10:amd64
function passed_abi_check (repository : String; id : port_id;
skip_exist_check : Boolean := False)
return Boolean;
-- This calculates the ABI for the platform and stores it. The value is
-- used by passed_abi_check()
procedure establish_package_architecture;
-- Scan directory that contains the packages (*.txz) and stores the
-- file names in the container. Returns False if no packages are found.
function scan_repository (repository : String) return Boolean;
-- standard method to spawn commands in this package (and get output)
function generic_system_command (command : String) return JT.Text;
-- Evaluates the stored options. If none exists, return True
-- If Exists and all the options match exactly what has already been
-- scanned for the port (names, not values) then return True else False.
function passed_options_cache_check (id : port_id) return Boolean;
-- For each package in the query, check the ABI and options (this is the
-- only time they are checked). If those pass, query the dependencies,
-- store the result, and check them. Set the "deletion" flag as needed.
-- The dependency check is NOT performed yet.
procedure initial_package_scan (repository : String; id : port_id);
-- Same as above, but for packages in the external repository
procedure remote_package_scan (id : port_id);
-- The result of the dependency query giving "id" port_id
function result_of_dependency_query (repository : String; id : port_id)
return JT.Text;
-- Using the same make_queue as was used to scan the ports, use tasks
-- (up to 32) to do the initial scanning of the ports, including getting
-- the pkg dependency query.
procedure parallel_package_scan (repository : String; remote_scan : Boolean;
show_progress : Boolean);
-- Prior to this procedure, the list of existing packages is split as
-- a balanced array so this scan will query the package for its origin
-- and package name. If the origin still exists, the port will be
-- scanned for the current package name. If either check fails, the
-- package will be deleted, otherwise the origin will be preserved for
-- a further in-depth check.
procedure parallel_preliminary_package_scan (repository : String;
show_progress : Boolean);
-- given a port_id, return the package name (no .txz extension!)
function id2pkgname (id : port_id) return String;
-- Turn on option and dependency debug checks programmatically
procedure activate_debugging_code;
-- Given an origin (already validated) and the name of the package in
-- focus, return True if "make -V PKGFILE:T" matches the filename
function current_package_name (origin, file_name : String) return Boolean;
-- Dedicated progress meter for prescanning packages
function package_scan_progress return String;
-- Open log to document packages that get deleted and the reason why
procedure start_obsolete_package_logging;
-- Write to log if open and optionally output a copy to screen.
procedure obsolete_notice (message : String; write_to_screen : Boolean);
end PortScan.Packages;
|
reznikmm/matreshka | Ada | 52,259 | 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.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.OCL_Attributes;
with AMF.String_Collections;
with AMF.UML.Classifier_Template_Parameters;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Collaboration_Uses.Collections;
with AMF.UML.Comments.Collections;
with AMF.UML.Constraints.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Element_Imports.Collections;
with AMF.UML.Elements.Collections;
with AMF.UML.Features.Collections;
with AMF.UML.Generalization_Sets.Collections;
with AMF.UML.Generalizations.Collections;
with AMF.UML.Named_Elements.Collections;
with AMF.UML.Namespaces.Collections;
with AMF.UML.Operations.Collections;
with AMF.UML.Package_Imports.Collections;
with AMF.UML.Packageable_Elements.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameterable_Elements.Collections;
with AMF.UML.Properties.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.Redefinable_Template_Signatures;
with AMF.UML.String_Expressions;
with AMF.UML.Substitutions.Collections;
with AMF.UML.Template_Bindings.Collections;
with AMF.UML.Template_Parameters;
with AMF.UML.Template_Signatures;
with AMF.UML.Types;
with AMF.UML.Use_Cases.Collections;
with AMF.Visitors.OCL_Iterators;
with AMF.Visitors.OCL_Visitors;
with League.Strings.Internals;
with Matreshka.Internals.Strings;
package body AMF.Internals.OCL_Set_Types is
----------------------
-- Get_Element_Type --
----------------------
overriding function Get_Element_Type
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Classifiers.UML_Classifier_Access is
begin
return
AMF.UML.Classifiers.UML_Classifier_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Element_Type
(Self.Element)));
end Get_Element_Type;
----------------------
-- Set_Element_Type --
----------------------
overriding procedure Set_Element_Type
(Self : not null access OCL_Set_Type_Proxy;
To : AMF.UML.Classifiers.UML_Classifier_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Element_Type
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Element_Type;
-------------------------
-- Get_Owned_Attribute --
-------------------------
overriding function Get_Owned_Attribute
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property is
begin
return
AMF.UML.Properties.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Attribute
(Self.Element)));
end Get_Owned_Attribute;
-------------------------
-- Get_Owned_Operation --
-------------------------
overriding function Get_Owned_Operation
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Operations.Collections.Ordered_Set_Of_UML_Operation is
begin
return
AMF.UML.Operations.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Operation
(Self.Element)));
end Get_Owned_Operation;
-------------------
-- Get_Attribute --
-------------------
overriding function Get_Attribute
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property is
begin
return
AMF.UML.Properties.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Attribute
(Self.Element)));
end Get_Attribute;
---------------------------
-- Get_Collaboration_Use --
---------------------------
overriding function Get_Collaboration_Use
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use is
begin
return
AMF.UML.Collaboration_Uses.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Collaboration_Use
(Self.Element)));
end Get_Collaboration_Use;
-----------------
-- Get_Feature --
-----------------
overriding function Get_Feature
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature is
begin
return
AMF.UML.Features.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Feature
(Self.Element)));
end Get_Feature;
-----------------
-- Get_General --
-----------------
overriding function Get_General
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
return
AMF.UML.Classifiers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_General
(Self.Element)));
end Get_General;
------------------------
-- Get_Generalization --
------------------------
overriding function Get_Generalization
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization is
begin
return
AMF.UML.Generalizations.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Generalization
(Self.Element)));
end Get_Generalization;
--------------------------
-- Get_Inherited_Member --
--------------------------
overriding function Get_Inherited_Member
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
return
AMF.UML.Named_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Inherited_Member
(Self.Element)));
end Get_Inherited_Member;
---------------------
-- Get_Is_Abstract --
---------------------
overriding function Get_Is_Abstract
(Self : not null access constant OCL_Set_Type_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.OCL_Attributes.Internal_Get_Is_Abstract
(Self.Element);
end Get_Is_Abstract;
---------------------
-- Set_Is_Abstract --
---------------------
overriding procedure Set_Is_Abstract
(Self : not null access OCL_Set_Type_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Is_Abstract
(Self.Element, To);
end Set_Is_Abstract;
---------------------------------
-- Get_Is_Final_Specialization --
---------------------------------
overriding function Get_Is_Final_Specialization
(Self : not null access constant OCL_Set_Type_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.OCL_Attributes.Internal_Get_Is_Final_Specialization
(Self.Element);
end Get_Is_Final_Specialization;
---------------------------------
-- Set_Is_Final_Specialization --
---------------------------------
overriding procedure Set_Is_Final_Specialization
(Self : not null access OCL_Set_Type_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Is_Final_Specialization
(Self.Element, To);
end Set_Is_Final_Specialization;
----------------------------------
-- Get_Owned_Template_Signature --
----------------------------------
overriding function Get_Owned_Template_Signature
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access is
begin
return
AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Template_Signature
(Self.Element)));
end Get_Owned_Template_Signature;
----------------------------------
-- Set_Owned_Template_Signature --
----------------------------------
overriding procedure Set_Owned_Template_Signature
(Self : not null access OCL_Set_Type_Proxy;
To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Owned_Template_Signature
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Owned_Template_Signature;
------------------------
-- Get_Owned_Use_Case --
------------------------
overriding function Get_Owned_Use_Case
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case is
begin
return
AMF.UML.Use_Cases.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Use_Case
(Self.Element)));
end Get_Owned_Use_Case;
--------------------------
-- Get_Powertype_Extent --
--------------------------
overriding function Get_Powertype_Extent
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set is
begin
return
AMF.UML.Generalization_Sets.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Powertype_Extent
(Self.Element)));
end Get_Powertype_Extent;
------------------------------
-- Get_Redefined_Classifier --
------------------------------
overriding function Get_Redefined_Classifier
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
return
AMF.UML.Classifiers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Redefined_Classifier
(Self.Element)));
end Get_Redefined_Classifier;
------------------------
-- Get_Representation --
------------------------
overriding function Get_Representation
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access is
begin
return
AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Representation
(Self.Element)));
end Get_Representation;
------------------------
-- Set_Representation --
------------------------
overriding procedure Set_Representation
(Self : not null access OCL_Set_Type_Proxy;
To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Representation
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Representation;
----------------------
-- Get_Substitution --
----------------------
overriding function Get_Substitution
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution is
begin
return
AMF.UML.Substitutions.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Substitution
(Self.Element)));
end Get_Substitution;
----------------------------
-- Get_Template_Parameter --
----------------------------
overriding function Get_Template_Parameter
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access is
begin
return
AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Template_Parameter
(Self.Element)));
end Get_Template_Parameter;
----------------------------
-- Set_Template_Parameter --
----------------------------
overriding procedure Set_Template_Parameter
(Self : not null access OCL_Set_Type_Proxy;
To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Template_Parameter;
------------------
-- Get_Use_Case --
------------------
overriding function Get_Use_Case
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case is
begin
return
AMF.UML.Use_Cases.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Use_Case
(Self.Element)));
end Get_Use_Case;
------------------------
-- Get_Element_Import --
------------------------
overriding function Get_Element_Import
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import is
begin
return
AMF.UML.Element_Imports.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Element_Import
(Self.Element)));
end Get_Element_Import;
-------------------------
-- Get_Imported_Member --
-------------------------
overriding function Get_Imported_Member
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is
begin
return
AMF.UML.Packageable_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Imported_Member
(Self.Element)));
end Get_Imported_Member;
----------------
-- Get_Member --
----------------
overriding function Get_Member
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
return
AMF.UML.Named_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Member
(Self.Element)));
end Get_Member;
----------------------
-- Get_Owned_Member --
----------------------
overriding function Get_Owned_Member
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
return
AMF.UML.Named_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Member
(Self.Element)));
end Get_Owned_Member;
--------------------
-- Get_Owned_Rule --
--------------------
overriding function Get_Owned_Rule
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint is
begin
return
AMF.UML.Constraints.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Rule
(Self.Element)));
end Get_Owned_Rule;
------------------------
-- Get_Package_Import --
------------------------
overriding function Get_Package_Import
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import is
begin
return
AMF.UML.Package_Imports.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Package_Import
(Self.Element)));
end Get_Package_Import;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
begin
return
AMF.UML.Dependencies.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Client_Dependency
(Self.Element)));
end Get_Client_Dependency;
--------------
-- Get_Name --
--------------
overriding function Get_Name
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.OCL_Attributes.Internal_Get_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Name;
--------------
-- Set_Name --
--------------
overriding procedure Set_Name
(Self : not null access OCL_Set_Type_Proxy;
To : AMF.Optional_String) is
begin
if To.Is_Empty then
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name
(Self.Element, null);
else
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name
(Self.Element,
League.Strings.Internals.Internal (To.Value));
end if;
end Set_Name;
-------------------------
-- Get_Name_Expression --
-------------------------
overriding function Get_Name_Expression
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access is
begin
return
AMF.UML.String_Expressions.UML_String_Expression_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Name_Expression
(Self.Element)));
end Get_Name_Expression;
-------------------------
-- Set_Name_Expression --
-------------------------
overriding procedure Set_Name_Expression
(Self : not null access OCL_Set_Type_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name_Expression
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Name_Expression;
-------------------
-- Get_Namespace --
-------------------
overriding function Get_Namespace
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
return
AMF.UML.Namespaces.UML_Namespace_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Namespace
(Self.Element)));
end Get_Namespace;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.OCL_Attributes.Internal_Get_Qualified_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Qualified_Name;
--------------------
-- Get_Visibility --
--------------------
overriding function Get_Visibility
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Optional_UML_Visibility_Kind is
begin
return
AMF.Internals.Tables.OCL_Attributes.Internal_Get_Visibility
(Self.Element);
end Get_Visibility;
--------------------
-- Set_Visibility --
--------------------
overriding procedure Set_Visibility
(Self : not null access OCL_Set_Type_Proxy;
To : AMF.UML.Optional_UML_Visibility_Kind) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Visibility
(Self.Element, To);
end Set_Visibility;
-----------------------
-- Get_Owned_Comment --
-----------------------
overriding function Get_Owned_Comment
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Comments.Collections.Set_Of_UML_Comment is
begin
return
AMF.UML.Comments.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Comment
(Self.Element)));
end Get_Owned_Comment;
-----------------------
-- Get_Owned_Element --
-----------------------
overriding function Get_Owned_Element
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
return
AMF.UML.Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Element
(Self.Element)));
end Get_Owned_Element;
---------------
-- Get_Owner --
---------------
overriding function Get_Owner
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Elements.UML_Element_Access is
begin
return
AMF.UML.Elements.UML_Element_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owner
(Self.Element)));
end Get_Owner;
-----------------
-- Get_Package --
-----------------
overriding function Get_Package
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Packages.UML_Package_Access is
begin
return
AMF.UML.Packages.UML_Package_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Package
(Self.Element)));
end Get_Package;
-----------------
-- Set_Package --
-----------------
overriding procedure Set_Package
(Self : not null access OCL_Set_Type_Proxy;
To : AMF.UML.Packages.UML_Package_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Package
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Package;
--------------------
-- Get_Visibility --
--------------------
overriding function Get_Visibility
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.UML_Visibility_Kind is
begin
return
AMF.Internals.Tables.OCL_Attributes.Internal_Get_Visibility
(Self.Element).Value;
end Get_Visibility;
--------------------
-- Set_Visibility --
--------------------
overriding procedure Set_Visibility
(Self : not null access OCL_Set_Type_Proxy;
To : AMF.UML.UML_Visibility_Kind) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Visibility
(Self.Element, (False, To));
end Set_Visibility;
-----------------------------------
-- Get_Owning_Template_Parameter --
-----------------------------------
overriding function Get_Owning_Template_Parameter
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owning_Template_Parameter
(Self.Element)));
end Get_Owning_Template_Parameter;
-----------------------------------
-- Set_Owning_Template_Parameter --
-----------------------------------
overriding procedure Set_Owning_Template_Parameter
(Self : not null access OCL_Set_Type_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Owning_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Owning_Template_Parameter;
----------------------------
-- Get_Template_Parameter --
----------------------------
overriding function Get_Template_Parameter
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Template_Parameter
(Self.Element)));
end Get_Template_Parameter;
----------------------------
-- Set_Template_Parameter --
----------------------------
overriding procedure Set_Template_Parameter
(Self : not null access OCL_Set_Type_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Template_Parameter;
----------------------------------
-- Get_Owned_Template_Signature --
----------------------------------
overriding function Get_Owned_Template_Signature
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access is
begin
return
AMF.UML.Template_Signatures.UML_Template_Signature_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Template_Signature
(Self.Element)));
end Get_Owned_Template_Signature;
----------------------------------
-- Set_Owned_Template_Signature --
----------------------------------
overriding procedure Set_Owned_Template_Signature
(Self : not null access OCL_Set_Type_Proxy;
To : AMF.UML.Template_Signatures.UML_Template_Signature_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Owned_Template_Signature
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Owned_Template_Signature;
--------------------------
-- Get_Template_Binding --
--------------------------
overriding function Get_Template_Binding
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding is
begin
return
AMF.UML.Template_Bindings.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Template_Binding
(Self.Element)));
end Get_Template_Binding;
-----------------
-- Get_Is_Leaf --
-----------------
overriding function Get_Is_Leaf
(Self : not null access constant OCL_Set_Type_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.OCL_Attributes.Internal_Get_Is_Leaf
(Self.Element);
end Get_Is_Leaf;
-----------------
-- Set_Is_Leaf --
-----------------
overriding procedure Set_Is_Leaf
(Self : not null access OCL_Set_Type_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Is_Leaf
(Self.Element, To);
end Set_Is_Leaf;
---------------------------
-- Get_Redefined_Element --
---------------------------
overriding function Get_Redefined_Element
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element is
begin
return
AMF.UML.Redefinable_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Redefined_Element
(Self.Element)));
end Get_Redefined_Element;
------------------------------
-- Get_Redefinition_Context --
------------------------------
overriding function Get_Redefinition_Context
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
return
AMF.UML.Classifiers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Redefinition_Context
(Self.Element)));
end Get_Redefinition_Context;
-------------
-- Inherit --
-------------
overriding function Inherit
(Self : not null access constant OCL_Set_Type_Proxy;
Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Inherit unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Inherit";
return Inherit (Self, Inhs);
end Inherit;
------------------
-- All_Features --
------------------
overriding function All_Features
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Features unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.All_Features";
return All_Features (Self);
end All_Features;
-----------------
-- All_Parents --
-----------------
overriding function All_Parents
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Parents unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.All_Parents";
return All_Parents (Self);
end All_Parents;
-----------------
-- Conforms_To --
-----------------
overriding function Conforms_To
(Self : not null access constant OCL_Set_Type_Proxy;
Other : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Conforms_To unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Conforms_To";
return Conforms_To (Self, Other);
end Conforms_To;
-------------
-- General --
-------------
overriding function General
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "General unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.General";
return General (Self);
end General;
-----------------------
-- Has_Visibility_Of --
-----------------------
overriding function Has_Visibility_Of
(Self : not null access constant OCL_Set_Type_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Has_Visibility_Of unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Has_Visibility_Of";
return Has_Visibility_Of (Self, N);
end Has_Visibility_Of;
-------------------------
-- Inheritable_Members --
-------------------------
overriding function Inheritable_Members
(Self : not null access constant OCL_Set_Type_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Inheritable_Members unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Inheritable_Members";
return Inheritable_Members (Self, C);
end Inheritable_Members;
----------------------
-- Inherited_Member --
----------------------
overriding function Inherited_Member
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Inherited_Member unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Inherited_Member";
return Inherited_Member (Self);
end Inherited_Member;
-----------------
-- Is_Template --
-----------------
overriding function Is_Template
(Self : not null access constant OCL_Set_Type_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Template unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Is_Template";
return Is_Template (Self);
end Is_Template;
-------------------------
-- May_Specialize_Type --
-------------------------
overriding function May_Specialize_Type
(Self : not null access constant OCL_Set_Type_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "May_Specialize_Type unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.May_Specialize_Type";
return May_Specialize_Type (Self, C);
end May_Specialize_Type;
-------------
-- Parents --
-------------
overriding function Parents
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Parents unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Parents";
return Parents (Self);
end Parents;
------------------------
-- Exclude_Collisions --
------------------------
overriding function Exclude_Collisions
(Self : not null access constant OCL_Set_Type_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Exclude_Collisions unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Exclude_Collisions";
return Exclude_Collisions (Self, Imps);
end Exclude_Collisions;
-------------------------
-- Get_Names_Of_Member --
-------------------------
overriding function Get_Names_Of_Member
(Self : not null access constant OCL_Set_Type_Proxy;
Element : AMF.UML.Named_Elements.UML_Named_Element_Access)
return AMF.String_Collections.Set_Of_String is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Get_Names_Of_Member unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Get_Names_Of_Member";
return Get_Names_Of_Member (Self, Element);
end Get_Names_Of_Member;
--------------------
-- Import_Members --
--------------------
overriding function Import_Members
(Self : not null access constant OCL_Set_Type_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Import_Members unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Import_Members";
return Import_Members (Self, Imps);
end Import_Members;
---------------------
-- Imported_Member --
---------------------
overriding function Imported_Member
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Imported_Member unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Imported_Member";
return Imported_Member (Self);
end Imported_Member;
---------------------------------
-- Members_Are_Distinguishable --
---------------------------------
overriding function Members_Are_Distinguishable
(Self : not null access constant OCL_Set_Type_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Members_Are_Distinguishable unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Members_Are_Distinguishable";
return Members_Are_Distinguishable (Self);
end Members_Are_Distinguishable;
------------------
-- Owned_Member --
------------------
overriding function Owned_Member
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Owned_Member unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Owned_Member";
return Owned_Member (Self);
end Owned_Member;
--------------------
-- All_Namespaces --
--------------------
overriding function All_Namespaces
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Namespaces unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.All_Namespaces";
return All_Namespaces (Self);
end All_Namespaces;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.All_Owning_Packages";
return All_Owning_Packages (Self);
end All_Owning_Packages;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant OCL_Set_Type_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Is_Distinguishable_From";
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
---------------
-- Namespace --
---------------
overriding function Namespace
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Namespace";
return Namespace (Self);
end Namespace;
--------------------
-- Qualified_Name --
--------------------
overriding function Qualified_Name
(Self : not null access constant OCL_Set_Type_Proxy)
return League.Strings.Universal_String is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Qualified_Name unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Qualified_Name";
return Qualified_Name (Self);
end Qualified_Name;
---------------
-- Separator --
---------------
overriding function Separator
(Self : not null access constant OCL_Set_Type_Proxy)
return League.Strings.Universal_String is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Separator unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Separator";
return Separator (Self);
end Separator;
------------------------
-- All_Owned_Elements --
------------------------
overriding function All_Owned_Elements
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owned_Elements unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.All_Owned_Elements";
return All_Owned_Elements (Self);
end All_Owned_Elements;
-------------------
-- Must_Be_Owned --
-------------------
overriding function Must_Be_Owned
(Self : not null access constant OCL_Set_Type_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Must_Be_Owned unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Must_Be_Owned";
return Must_Be_Owned (Self);
end Must_Be_Owned;
-----------------
-- Conforms_To --
-----------------
overriding function Conforms_To
(Self : not null access constant OCL_Set_Type_Proxy;
Other : AMF.UML.Types.UML_Type_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Conforms_To unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Conforms_To";
return Conforms_To (Self, Other);
end Conforms_To;
------------------------
-- Is_Compatible_With --
------------------------
overriding function Is_Compatible_With
(Self : not null access constant OCL_Set_Type_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Is_Compatible_With";
return Is_Compatible_With (Self, P);
end Is_Compatible_With;
---------------------------
-- Is_Template_Parameter --
---------------------------
overriding function Is_Template_Parameter
(Self : not null access constant OCL_Set_Type_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Is_Template_Parameter";
return Is_Template_Parameter (Self);
end Is_Template_Parameter;
----------------------------
-- Parameterable_Elements --
----------------------------
overriding function Parameterable_Elements
(Self : not null access constant OCL_Set_Type_Proxy)
return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Parameterable_Elements unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Parameterable_Elements";
return Parameterable_Elements (Self);
end Parameterable_Elements;
------------------------
-- Is_Consistent_With --
------------------------
overriding function Is_Consistent_With
(Self : not null access constant OCL_Set_Type_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Consistent_With unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Is_Consistent_With";
return Is_Consistent_With (Self, Redefinee);
end Is_Consistent_With;
-----------------------------------
-- Is_Redefinition_Context_Valid --
-----------------------------------
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant OCL_Set_Type_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Redefinition_Context_Valid unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Set_Type_Proxy.Is_Redefinition_Context_Valid";
return Is_Redefinition_Context_Valid (Self, Redefined);
end Is_Redefinition_Context_Valid;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant OCL_Set_Type_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.OCL_Visitors.OCL_Visitor'Class then
AMF.Visitors.OCL_Visitors.OCL_Visitor'Class
(Visitor).Enter_Set_Type
(AMF.OCL.Set_Types.OCL_Set_Type_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant OCL_Set_Type_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.OCL_Visitors.OCL_Visitor'Class then
AMF.Visitors.OCL_Visitors.OCL_Visitor'Class
(Visitor).Leave_Set_Type
(AMF.OCL.Set_Types.OCL_Set_Type_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant OCL_Set_Type_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.OCL_Iterators.OCL_Iterator'Class then
AMF.Visitors.OCL_Iterators.OCL_Iterator'Class
(Iterator).Visit_Set_Type
(Visitor,
AMF.OCL.Set_Types.OCL_Set_Type_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.OCL_Set_Types;
|
gitter-badger/libAnne | Ada | 1,253 | adb | with Mathematics.Arrays;
use Mathematics.Arrays;
package body Colors.Models.Red_Green_Blue is
function Red(Self : RGB_Color) return Percent is (Percent(Self.Red / Short_Short_Modular'Last));
function Red(Self : RGB_Color) return Short_Short_Modular is (Self.Red);
function Green(Self : RGB_Color) return Percent is (Percent(Self.Green / Short_Short_Modular'Last));
function Green(Self : RGB_Color) return Short_Short_Modular is (Self.Green);
function Blue(Self : RGB_Color) return Percent is (Percent(Self.Blue / Short_Short_Modular'Last));
function Blue(Self : RGB_Color) return Short_Short_Modular is (Self.Blue);
function RGB(Red, Green, Blue : Percent; α : Percent := 100.0) return RGB_Color is
A : Short_Short_Modular := Short_Short_Modular(Decimal(α) * 2.55);
R : Short_Short_Modular := Short_Short_Modular(Decimal(Red) * 2.55);
G : Short_Short_Modular := Short_Short_Modular(Decimal(Green) * 2.55);
B : Short_Short_Modular := Short_Short_Modular(Decimal(Blue) * 2.55);
begin
return RGB_Color'(A, R, G, B);
end RGB;
function RGB(Red, Green, Blue : Short_Short_Modular; α : Short_Short_Modular := Short_Short_Modular'Last) return RGB_Color is (RGB_Color'(α, Red, Green, Blue));
end Colors.Models.Red_Green_Blue;
|
AdaCore/Ada_Drivers_Library | Ada | 15,261 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2022, AdaCore --
-- --
-- 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_Conversion;
with HAL.GPIO; use HAL.GPIO;
package body MCP23x17 is
function "+" is new Ada.Unchecked_Conversion (Source => UInt8,
Target => Port_IO_Array);
function "+" is new Ada.Unchecked_Conversion (Source => Port_IO_Array,
Target => UInt8);
procedure Loc_IO_Write
(This : in out MCP23x17_IO_Expander'Class;
Addr : Register_Address;
Value : UInt8)
with Inline_Always;
procedure Loc_IO_Read
(This : MCP23x17_IO_Expander'Class;
Addr : Register_Address;
Value : out UInt8)
with Inline_Always;
procedure Set_Bit
(This : in out MCP23x17_IO_Expander;
Addr : Register_Address;
Pin : MCP23x17_Pin_Number;
Val : Boolean := True);
function Read_Bit
(This : MCP23x17_IO_Expander;
Addr : Register_Address;
Pin : MCP23x17_Pin_Number)
return Boolean;
------------------
-- Loc_IO_Write --
------------------
procedure Loc_IO_Write
(This : in out MCP23x17_IO_Expander'Class;
Addr : Register_Address;
Value : UInt8)
is
begin
IO_Write (This, Addr, Value);
end Loc_IO_Write;
-----------------
-- Loc_IO_Read --
-----------------
procedure Loc_IO_Read
(This : MCP23x17_IO_Expander'Class;
Addr : Register_Address;
Value : out UInt8)
is
begin
IO_Read (This, Addr, Value);
end Loc_IO_Read;
-------------
-- Set_Bit --
-------------
procedure Set_Bit
(This : in out MCP23x17_IO_Expander;
Addr : Register_Address;
Pin : MCP23x17_Pin_Number;
Val : Boolean := True)
is
Prev : UInt8;
Next : Port_IO_Array;
begin
Loc_IO_Read (This, Addr, Prev);
Next := +Prev;
Next (Pin) := Val;
if +Next /= Prev then
Loc_IO_Write (This, Addr, +Next);
end if;
end Set_Bit;
--------------
-- Read_Bit --
--------------
function Read_Bit
(This : MCP23x17_IO_Expander;
Addr : Register_Address;
Pin : MCP23x17_Pin_Number)
return Boolean
is
Reg : UInt8;
IOs : Port_IO_Array;
begin
Loc_IO_Read (This, Addr, Reg);
IOs := +Reg;
return IOs (Pin);
end Read_Bit;
---------------
-- Configure --
---------------
procedure Configure (This : in out MCP23x17_IO_Expander;
Pin : MCP23x17_Pin;
Output : Boolean;
Pull_Up : Boolean;
Invert_Input : Boolean := False)
is
begin
This.Configure_Mode (Pin, Output);
This.Configure_Pull_Up (Pin, Pull_Up);
This.Configure_Polarity (Pin, Invert_Input);
end Configure;
procedure Configure_Mode (This : in out MCP23x17_IO_Expander;
Pin : MCP23x17_Pin;
Output : Boolean)
is
-- 1 = Pin is configured as an input.
-- 0 = Pin is configured as an output.
-- Data Sheet 3.5.1 I/O Direction Register
begin
case Pin.Port is
when A => Set_Bit (This, IO_Dir_A, Pin.Pin_Nr, not Output);
when B => Set_Bit (This, IO_Dir_B, Pin.Pin_Nr, not Output);
end case;
end Configure_Mode;
-- Configure all pins of a port as input or output
procedure Configure_Mode (This : in out MCP23x17_IO_Expander;
Port : MCP23x17_Port;
Output : Boolean)
is begin
case Port is
when A => Loc_IO_Write (This, IO_Dir_A, (if Output then 16#00# else 16#FF#));
when B => Loc_IO_Write (This, IO_Dir_B, (if Output then 16#00# else 16#FF#));
end case;
end Configure_Mode;
procedure Configure_Polarity (This : in out MCP23x17_IO_Expander;
Pin : MCP23x17_Pin;
Invert_Input : Boolean)
is
begin
case Pin.Port is
when A => Set_Bit (This, I_Pol_A, Pin.Pin_Nr, Invert_Input);
when B => Set_Bit (This, I_Pol_B, Pin.Pin_Nr, Invert_Input);
end case;
end Configure_Polarity;
procedure Configure_Polarity (This : in out MCP23x17_IO_Expander;
Port : MCP23x17_Port;
Invert_Input : Boolean)
is
begin
case Port is
when A => Loc_IO_Write (This, I_Pol_A, (if Invert_Input then 16#FF# else 16#00#));
when B => Loc_IO_Write (This, I_Pol_B, (if Invert_Input then 16#FF# else 16#00#));
end case;
end Configure_Polarity;
function Input_Is_Inverted (This : MCP23x17_IO_Expander;
Pin : MCP23x17_Pin) return Boolean
is
begin
case Pin.Port is
when A => return Read_Bit (This, I_Pol_A, Pin.Pin_Nr);
when B => return Read_Bit (This, I_Pol_B, Pin.Pin_Nr);
end case;
end Input_Is_Inverted;
---------------
-- Is_Output --
---------------
function Is_Output (This : in out MCP23x17_IO_Expander;
Pin : MCP23x17_Pin)
return Boolean
is
begin
case Pin.Port is
when A => return not Read_Bit (This, IO_Dir_A, Pin.Pin_Nr);
when B => return not Read_Bit (This, IO_Dir_B, Pin.Pin_Nr);
end case;
end Is_Output;
-----------------------
-- Configure_Pull_Up --
-----------------------
procedure Configure_Pull_Up (This : in out MCP23x17_IO_Expander;
Pin : MCP23x17_Pin;
Pull_Up : Boolean)
is
Reg : constant Register_Address :=
(if Pin.Port = A then GP_Pu_A else GP_Pu_B);
begin
Set_Bit (This, Reg, Pin.Pin_Nr, Pull_Up);
end Configure_Pull_Up;
procedure Configure_Pull_Up (This : in out MCP23x17_IO_Expander;
Port : MCP23x17_Port;
Pull_Up : Boolean)
is
Reg : constant Register_Address :=
(if Port = A then GP_Pu_A else GP_Pu_B);
begin
Loc_IO_Write (This, Reg, (if Pull_Up then 16#FF# else 16#00#));
end Configure_Pull_Up;
-----------------
-- Has_Pull_Up --
-----------------
function Has_Pull_Up (This : MCP23x17_IO_Expander;
Pin : MCP23x17_Pin) return Boolean
is
Reg : constant Register_Address :=
(if Pin.Port = A then GP_Pu_A else GP_Pu_B);
begin
return Read_Bit (This, Reg, Pin.Pin_Nr);
end Has_Pull_Up;
------------
-- Is_Set --
------------
function Is_Set (This : MCP23x17_IO_Expander;
Pin : MCP23x17_Pin) return Boolean
is
Reg : constant Register_Address :=
(if Pin.Port = A then GP_IO_A else GP_IO_B);
Val : UInt8;
IOs : Port_IO_Array;
begin
Loc_IO_Read (This, Reg, Val);
IOs := +Val;
return IOs (Pin.Pin_Nr);
end Is_Set;
---------
-- Set --
---------
procedure Set (This : in out MCP23x17_IO_Expander;
Pin : MCP23x17_Pin;
Value : Boolean := True)
is
begin
case Pin.Port is
when A => Set_Bit (This, GP_IO_A, Pin.Pin_Nr, Value);
when B => Set_Bit (This, GP_IO_B, Pin.Pin_Nr, Value);
end case;
end Set;
-----------
-- Clear --
-----------
procedure Clear (This : in out MCP23x17_IO_Expander;
Pin : MCP23x17_Pin)
is
begin
Set (This, Pin, False);
end Clear;
------------
-- Toggle --
------------
procedure Toggle (This : in out MCP23x17_IO_Expander;
Pin : MCP23x17_Pin)
is
begin
Set (This, Pin, not Is_Set (This, Pin));
end Toggle;
------------
-- Get_IO --
------------
-- Return the current status of all pins of a port in an array
function Get_IO (This : in out MCP23x17_IO_Expander;
Port : MCP23x17_Port) return Port_IO_Array
is
Val : UInt8;
begin
if Port = A then
Loc_IO_Read (This, GP_IO_A, Val);
else
Loc_IO_Read (This, GP_IO_B, Val);
end if;
return +Val;
end Get_IO;
-- Return the current status of all pins of a given port in an array
procedure Get_IO (This : in out MCP23x17_IO_Expander;
Port : MCP23x17_Port;
IOs : out Port_IO_Array)
is
begin
IOs := Get_IO (This, Port);
end Get_IO;
-- Set the current status of selected pins with an array
procedure Set_IO (This : in out MCP23x17_IO_Expander;
Port : MCP23x17_Port;
IOs : Port_IO_Array)
is
begin
case Port is
when A => Loc_IO_Write (This, GP_IO_A, +IOs);
when B => Loc_IO_Write (This, GP_IO_B, +IOs);
end case;
end Set_IO;
-------------------
-- As_GPIO_Point --
-------------------
function As_GPIO_Point (This : in out MCP23x17_IO_Expander;
Pin : MCP23x17_Pin)
return not null HAL.GPIO.Any_GPIO_Point
is
begin
case Pin.Port is
when A =>
This.A_Points (Pin.Pin_Nr) := (Device => This'Unchecked_Access,
Port => A,
Pin_Nr => Pin.Pin_Nr);
return This.A_Points (Pin.Pin_Nr)'Unchecked_Access;
when B =>
This.B_Points (Pin.Pin_Nr) := (Device => This'Unchecked_Access,
Port => B,
Pin_Nr => Pin.Pin_Nr);
return This.B_Points (Pin.Pin_Nr)'Unchecked_Access;
end case;
end As_GPIO_Point;
----------
-- Mode --
----------
overriding
function Mode (This : MCP23x17_GPIO_Point) return HAL.GPIO.GPIO_Mode is
begin
return (if This.Device.Is_Output (Pin => (This.Port, This.Pin_Nr))
then HAL.GPIO.Output else HAL.GPIO.Input);
end Mode;
--------------
-- Set_Mode --
--------------
overriding
procedure Set_Mode (This : in out MCP23x17_GPIO_Point;
Mode : HAL.GPIO.GPIO_Config_Mode)
is
begin
This.Device.Configure_Mode (Pin => (This.Port, This.Pin_Nr),
Output => (Mode = HAL.GPIO.Output));
end Set_Mode;
-------------------
-- Pull_Resistor --
-------------------
overriding
function Pull_Resistor (This : MCP23x17_GPIO_Point)
return HAL.GPIO.GPIO_Pull_Resistor
is
begin
return (if This.Device.Has_Pull_Up ((This.Port, This.Pin_Nr)) then
HAL.GPIO.Pull_Up
else
HAL.GPIO.Floating);
end Pull_Resistor;
-----------------------
-- Set_Pull_Resistor --
-----------------------
overriding
procedure Set_Pull_Resistor (This : in out MCP23x17_GPIO_Point;
Pull : HAL.GPIO.GPIO_Pull_Resistor)
is
begin
This.Device.Configure_Pull_Up ((This.Port, This.Pin_Nr), Pull = HAL.GPIO.Pull_Up);
end Set_Pull_Resistor;
---------
-- Set --
---------
overriding
function Set (This : MCP23x17_GPIO_Point) return Boolean is
begin
return This.Device.Is_Set ((This.Port, This.Pin_Nr));
end Set;
---------
-- Set --
---------
overriding
procedure Set (This : in out MCP23x17_GPIO_Point) is
begin
This.Device.Set ((This.Port, This.Pin_Nr), True);
end Set;
-----------
-- Clear --
-----------
overriding
procedure Clear (This : in out MCP23x17_GPIO_Point) is
begin
This.Device.Set ((This.Port, This.Pin_Nr), False);
end Clear;
------------
-- Toggle --
------------
overriding
procedure Toggle (This : in out MCP23x17_GPIO_Point) is
begin
This.Device.Toggle ((This.Port, This.Pin_Nr));
end Toggle;
-- set the module configuration
procedure Set_Module_Configuration (This : in out MCP23x17_IO_Expander;
Conf : Module_Configuration)
is
function "+" is new Ada.Unchecked_Conversion (Source => Module_Configuration,
Target => UInt8);
begin
Loc_IO_Write (This, IO_Con, +Conf);
end Set_Module_Configuration;
-- return the current module configuration.
procedure Get_Module_Configuration (This : in out MCP23x17_IO_Expander;
Conf : out Module_Configuration)
is
function "+" is new Ada.Unchecked_Conversion (Source => UInt8,
Target => Module_Configuration);
C : UInt8;
begin
Loc_IO_Read (This, IO_Con, C);
Conf := +C;
end Get_Module_Configuration;
end MCP23x17;
|
pdaxrom/Kino2 | Ada | 4,581 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Form_Demo.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
-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control
-- $Revision: 1.9 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Sample.Form_Demo.Aux;
package body Sample.Form_Demo.Handler is
package Aux renames Sample.Form_Demo.Aux;
procedure Drive_Me (F : in Form;
Title : in String := "")
is
L : Line_Count;
C : Column_Count;
Y : Line_Position;
X : Column_Position;
begin
Aux.Geometry (F, L, C, Y, X);
Drive_Me (F, Y, X, Title);
end Drive_Me;
procedure Drive_Me (F : in Form;
Lin : in Line_Position;
Col : in Column_Position;
Title : in String := "")
is
Pan : Panel := Aux.Create (F, Title, Lin, Col);
V : Cursor_Visibility := Normal;
Handle_CRLF : Boolean := True;
begin
Set_Cursor_Visibility (V);
if Aux.Count_Active (F) = 1 then
Handle_CRLF := False;
end if;
loop
declare
K : Key_Code := Aux.Get_Request (F, Pan, Handle_CRLF);
R : Driver_Result;
begin
if (K = 13 or else K = 10) and then not Handle_CRLF then
R := Unknown_Request;
else
R := Driver (F, K);
end if;
case R is
when Form_Ok => null;
when Unknown_Request =>
if My_Driver (F, K, Pan) then
exit;
end if;
when others => Beep;
end case;
end;
end loop;
Set_Cursor_Visibility (V);
Aux.Destroy (F, Pan);
end Drive_Me;
end Sample.Form_Demo.Handler;
|
reznikmm/gela | Ada | 7,407 | adb | package body Gela.Property_Getters is
--------------
-- On_Index --
--------------
overriding procedure On_Index
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Lexical_Types.Token_Count)
is
pragma Unreferenced (Element);
begin
Self.Index := Value;
end On_Index;
---------------
-- On_Env_In --
---------------
overriding procedure On_Env_In
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Semantic_Types.Env_Index)
is
pragma Unreferenced (Element);
begin
Self.Env_In := Value;
end On_Env_In;
----------------
-- On_Env_Out --
----------------
overriding procedure On_Env_Out
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Semantic_Types.Env_Index)
is
pragma Unreferenced (Element);
begin
Self.Env_Out := Value;
end On_Env_Out;
-------------
-- On_Down --
-------------
overriding procedure On_Down
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Interpretations.Interpretation_Index)
is
pragma Unreferenced (Element);
begin
Self.Down := Value;
end On_Down;
---------------
-- On_Errors --
---------------
overriding procedure On_Errors
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Semantic_Types.Error_Set_Index)
is
pragma Unreferenced (Element);
begin
Self.Errors := Value;
end On_Errors;
-----------
-- On_Up --
-----------
overriding procedure On_Up
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Interpretations.Interpretation_Tuple_Index)
is
pragma Unreferenced (Element);
begin
Self.Up_Tuple := Value;
end On_Up;
-----------
-- On_Up --
-----------
overriding procedure On_Up
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Interpretations.Interpretation_Tuple_List_Index)
is
pragma Unreferenced (Element);
begin
Self.Up_Tuple_List := Value;
end On_Up;
------------------
-- On_Name_List --
------------------
overriding procedure On_Name_List
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Lexical_Types.Symbol_List)
is
pragma Unreferenced (Element);
begin
Self.Name_List := Value;
end On_Name_List;
--------------------------
-- On_Limited_With_List --
--------------------------
overriding procedure On_Limited_With_List
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Lexical_Types.Symbol_List)
is
pragma Unreferenced (Element);
begin
Self.Limited_With_List := Value;
end On_Limited_With_List;
------------------
-- On_With_List --
------------------
overriding procedure On_With_List
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Lexical_Types.Symbol_List)
is
pragma Unreferenced (Element);
begin
Self.With_List := Value;
end On_With_List;
-----------
-- On_Up --
-----------
overriding procedure On_Up
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Interpretations.Interpretation_Set_Index)
is
pragma Unreferenced (Element);
begin
Self.Up_Set := Value;
end On_Up;
---------------------
-- On_Static_Value --
---------------------
overriding procedure On_Static_Value
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Semantic_Types.Value_Index)
is
pragma Unreferenced (Element);
begin
Self.Static_Value := Value;
end On_Static_Value;
------------------------------
-- On_Chosen_Interpretation --
------------------------------
overriding procedure On_Chosen_Interpretation
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Interpretations.Interpretation_Kinds)
is
pragma Unreferenced (Element);
begin
Self.Chosen_Interpretation := Value;
end On_Chosen_Interpretation;
----------------------
-- On_Defining_Name --
----------------------
overriding procedure On_Defining_Name
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Elements.Defining_Names.Defining_Name_Access)
is
pragma Unreferenced (Element);
begin
Self.Defining_Name := Value;
end On_Defining_Name;
------------------
-- On_Full_Name --
------------------
overriding procedure On_Full_Name
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Lexical_Types.Symbol)
is
pragma Unreferenced (Element);
begin
Self.Full_Name := Value;
end On_Full_Name;
---------------------------
-- On_Declarative_Region --
---------------------------
overriding procedure On_Declarative_Region
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Semantic_Types.Env_Index)
is
pragma Unreferenced (Element);
begin
Self.Declarative_Region := Value;
end On_Declarative_Region;
--------------------------------------
-- On_Corresponding_Generic_Element --
--------------------------------------
overriding procedure On_Corresponding_Generic_Element
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Elements.Element_Access)
is
pragma Unreferenced (Element);
begin
Self.Corresponding_Generic_Element := Value;
end On_Corresponding_Generic_Element;
---------------------------
-- On_Corresponding_View --
---------------------------
overriding procedure On_Corresponding_View
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Elements.Element_Access)
is
pragma Unreferenced (Element);
begin
Self.Corresponding_View := Value;
end On_Corresponding_View;
-------------------
-- On_Type_Index --
-------------------
overriding procedure On_Type_Index
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Semantic_Types.Type_View_Index)
is
pragma Unreferenced (Element);
begin
Self.Type_Index := Value;
end On_Type_Index;
---------------------------
-- On_Corresponding_Type --
---------------------------
overriding procedure On_Corresponding_Type
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Elements.Element_Access)
is
pragma Unreferenced (Element);
begin
Self.Corresponding_Type := Value;
end On_Corresponding_Type;
-----------------
-- On_Expanded --
-----------------
overriding procedure On_Expanded
(Self : in out Getter;
Element : Gela.Elements.Element_Access;
Value : Gela.Elements.Element_Access)
is
pragma Unreferenced (Element);
begin
Self.Expanded := Value;
end On_Expanded;
end Gela.Property_Getters;
|
zhmu/ananas | Ada | 405 | adb | -- { dg-do compile }
-- { dg-options "-O" }
with Aggr11_Pkg; use Aggr11_Pkg;
procedure Aggr11 is
A : Arr := ((1 => (Kind => No_Error, B => True),
2 => (Kind => Error),
3 => (Kind => Error),
4 => (Kind => No_Error, B => True),
5 => (Kind => No_Error, B => True),
6 => (Kind => No_Error, B => True)));
begin
null;
end;
|
reznikmm/matreshka | Ada | 19,079 | adb | ------------------------------------------------------------------------------
-- --
-- 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$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.Visitors.UML_Iterators;
with AMF.Visitors.UML_Visitors;
with League.Strings.Internals;
with Matreshka.Internals.Strings;
package body AMF.Internals.UML_Expressions is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UML_Expression_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Enter_Expression
(AMF.UML.Expressions.UML_Expression_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UML_Expression_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Leave_Expression
(AMF.UML.Expressions.UML_Expression_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UML_Expression_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.UML_Iterators.UML_Iterator'Class then
AMF.Visitors.UML_Iterators.UML_Iterator'Class
(Iterator).Visit_Expression
(Visitor,
AMF.UML.Expressions.UML_Expression_Access (Self),
Control);
end if;
end Visit_Element;
-----------------
-- Get_Operand --
-----------------
overriding function Get_Operand
(Self : not null access constant UML_Expression_Proxy)
return AMF.UML.Value_Specifications.Collections.Ordered_Set_Of_UML_Value_Specification is
begin
return
AMF.UML.Value_Specifications.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Operand
(Self.Element)));
end Get_Operand;
----------------
-- Get_Symbol --
----------------
overriding function Get_Symbol
(Self : not null access constant UML_Expression_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.UML_Attributes.Internal_Get_Symbol (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Symbol;
----------------
-- Set_Symbol --
----------------
overriding procedure Set_Symbol
(Self : not null access UML_Expression_Proxy;
To : AMF.Optional_String) is
begin
if To.Is_Empty then
AMF.Internals.Tables.UML_Attributes.Internal_Set_Symbol
(Self.Element, null);
else
AMF.Internals.Tables.UML_Attributes.Internal_Set_Symbol
(Self.Element,
League.Strings.Internals.Internal (To.Value));
end if;
end Set_Symbol;
--------------
-- Get_Type --
--------------
overriding function Get_Type
(Self : not null access constant UML_Expression_Proxy)
return AMF.UML.Types.UML_Type_Access is
begin
return
AMF.UML.Types.UML_Type_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Type
(Self.Element)));
end Get_Type;
--------------
-- Set_Type --
--------------
overriding procedure Set_Type
(Self : not null access UML_Expression_Proxy;
To : AMF.UML.Types.UML_Type_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Type
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Type;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant UML_Expression_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
begin
return
AMF.UML.Dependencies.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
(Self.Element)));
end Get_Client_Dependency;
-------------------------
-- Get_Name_Expression --
-------------------------
overriding function Get_Name_Expression
(Self : not null access constant UML_Expression_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access is
begin
return
AMF.UML.String_Expressions.UML_String_Expression_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
(Self.Element)));
end Get_Name_Expression;
-------------------------
-- Set_Name_Expression --
-------------------------
overriding procedure Set_Name_Expression
(Self : not null access UML_Expression_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Name_Expression;
-------------------
-- Get_Namespace --
-------------------
overriding function Get_Namespace
(Self : not null access constant UML_Expression_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
return
AMF.UML.Namespaces.UML_Namespace_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
(Self.Element)));
end Get_Namespace;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant UML_Expression_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Qualified_Name;
-----------------------------------
-- Get_Owning_Template_Parameter --
-----------------------------------
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Expression_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Template_Parameter
(Self.Element)));
end Get_Owning_Template_Parameter;
-----------------------------------
-- Set_Owning_Template_Parameter --
-----------------------------------
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Expression_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Owning_Template_Parameter;
----------------------------
-- Get_Template_Parameter --
----------------------------
overriding function Get_Template_Parameter
(Self : not null access constant UML_Expression_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Template_Parameter
(Self.Element)));
end Get_Template_Parameter;
----------------------------
-- Set_Template_Parameter --
----------------------------
overriding procedure Set_Template_Parameter
(Self : not null access UML_Expression_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Template_Parameter;
-------------------
-- Boolean_Value --
-------------------
overriding function Boolean_Value
(Self : not null access constant UML_Expression_Proxy)
return AMF.Optional_Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Boolean_Value unimplemented");
raise Program_Error with "Unimplemented procedure UML_Expression_Proxy.Boolean_Value";
return Boolean_Value (Self);
end Boolean_Value;
-------------------
-- Integer_Value --
-------------------
overriding function Integer_Value
(Self : not null access constant UML_Expression_Proxy)
return AMF.Optional_Integer is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Integer_Value unimplemented");
raise Program_Error with "Unimplemented procedure UML_Expression_Proxy.Integer_Value";
return Integer_Value (Self);
end Integer_Value;
------------------------
-- Is_Compatible_With --
------------------------
overriding function Is_Compatible_With
(Self : not null access constant UML_Expression_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented");
raise Program_Error with "Unimplemented procedure UML_Expression_Proxy.Is_Compatible_With";
return Is_Compatible_With (Self, P);
end Is_Compatible_With;
-------------------
-- Is_Computable --
-------------------
overriding function Is_Computable
(Self : not null access constant UML_Expression_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Computable unimplemented");
raise Program_Error with "Unimplemented procedure UML_Expression_Proxy.Is_Computable";
return Is_Computable (Self);
end Is_Computable;
-------------
-- Is_Null --
-------------
overriding function Is_Null
(Self : not null access constant UML_Expression_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Null unimplemented");
raise Program_Error with "Unimplemented procedure UML_Expression_Proxy.Is_Null";
return Is_Null (Self);
end Is_Null;
----------------
-- Real_Value --
----------------
overriding function Real_Value
(Self : not null access constant UML_Expression_Proxy)
return AMF.Optional_Real is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Real_Value unimplemented");
raise Program_Error with "Unimplemented procedure UML_Expression_Proxy.Real_Value";
return Real_Value (Self);
end Real_Value;
------------------
-- String_Value --
------------------
overriding function String_Value
(Self : not null access constant UML_Expression_Proxy)
return AMF.Optional_String is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "String_Value unimplemented");
raise Program_Error with "Unimplemented procedure UML_Expression_Proxy.String_Value";
return String_Value (Self);
end String_Value;
---------------------
-- Unlimited_Value --
---------------------
overriding function Unlimited_Value
(Self : not null access constant UML_Expression_Proxy)
return AMF.Optional_Unlimited_Natural is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Unlimited_Value unimplemented");
raise Program_Error with "Unimplemented procedure UML_Expression_Proxy.Unlimited_Value";
return Unlimited_Value (Self);
end Unlimited_Value;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant UML_Expression_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
raise Program_Error with "Unimplemented procedure UML_Expression_Proxy.All_Owning_Packages";
return All_Owning_Packages (Self);
end All_Owning_Packages;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Expression_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error with "Unimplemented procedure UML_Expression_Proxy.Is_Distinguishable_From";
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
---------------
-- Namespace --
---------------
overriding function Namespace
(Self : not null access constant UML_Expression_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
raise Program_Error with "Unimplemented procedure UML_Expression_Proxy.Namespace";
return Namespace (Self);
end Namespace;
---------------------------
-- Is_Template_Parameter --
---------------------------
overriding function Is_Template_Parameter
(Self : not null access constant UML_Expression_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented");
raise Program_Error with "Unimplemented procedure UML_Expression_Proxy.Is_Template_Parameter";
return Is_Template_Parameter (Self);
end Is_Template_Parameter;
end AMF.Internals.UML_Expressions;
|
reznikmm/matreshka | Ada | 5,328 | 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 AMF.Generic_Collections;
package AMF.OCL.Unspecified_Value_Exps.Collections is
pragma Preelaborate;
package OCL_Unspecified_Value_Exp_Collections is
new AMF.Generic_Collections
(OCL_Unspecified_Value_Exp,
OCL_Unspecified_Value_Exp_Access);
type Set_Of_OCL_Unspecified_Value_Exp is
new OCL_Unspecified_Value_Exp_Collections.Set with null record;
Empty_Set_Of_OCL_Unspecified_Value_Exp : constant Set_Of_OCL_Unspecified_Value_Exp;
type Ordered_Set_Of_OCL_Unspecified_Value_Exp is
new OCL_Unspecified_Value_Exp_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_OCL_Unspecified_Value_Exp : constant Ordered_Set_Of_OCL_Unspecified_Value_Exp;
type Bag_Of_OCL_Unspecified_Value_Exp is
new OCL_Unspecified_Value_Exp_Collections.Bag with null record;
Empty_Bag_Of_OCL_Unspecified_Value_Exp : constant Bag_Of_OCL_Unspecified_Value_Exp;
type Sequence_Of_OCL_Unspecified_Value_Exp is
new OCL_Unspecified_Value_Exp_Collections.Sequence with null record;
Empty_Sequence_Of_OCL_Unspecified_Value_Exp : constant Sequence_Of_OCL_Unspecified_Value_Exp;
private
Empty_Set_Of_OCL_Unspecified_Value_Exp : constant Set_Of_OCL_Unspecified_Value_Exp
:= (OCL_Unspecified_Value_Exp_Collections.Set with null record);
Empty_Ordered_Set_Of_OCL_Unspecified_Value_Exp : constant Ordered_Set_Of_OCL_Unspecified_Value_Exp
:= (OCL_Unspecified_Value_Exp_Collections.Ordered_Set with null record);
Empty_Bag_Of_OCL_Unspecified_Value_Exp : constant Bag_Of_OCL_Unspecified_Value_Exp
:= (OCL_Unspecified_Value_Exp_Collections.Bag with null record);
Empty_Sequence_Of_OCL_Unspecified_Value_Exp : constant Sequence_Of_OCL_Unspecified_Value_Exp
:= (OCL_Unspecified_Value_Exp_Collections.Sequence with null record);
end AMF.OCL.Unspecified_Value_Exps.Collections;
|
clinta/synth | Ada | 47,364 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Ada.Characters.Latin_1;
with Ada.Containers.Vectors;
with Ada.Directories;
with Ada.Exceptions;
with GNAT.OS_Lib;
with Parameters;
with Unix;
package body Replicant is
package PM renames Parameters;
package AC renames Ada.Containers;
package AD renames Ada.Directories;
package EX renames Ada.Exceptions;
package OSL renames GNAT.OS_Lib;
package LAT renames Ada.Characters.Latin_1;
-------------------
-- mount_point --
-------------------
function location (mount_base : String; point : folder) return String is
begin
case point is
when bin => return mount_base & root_bin;
when sbin => return mount_base & root_sbin;
when usr_bin => return mount_base & root_usr_bin;
when usr_include => return mount_base & root_usr_include;
when usr_lib => return mount_base & root_usr_lib;
when usr_lib32 => return mount_base & root_usr_lib32;
when usr_libdata => return mount_base & root_usr_libdata;
when usr_libexec => return mount_base & root_usr_libexec;
when usr_local => return mount_base & root_localbase;
when usr_sbin => return mount_base & root_usr_sbin;
when usr_share => return mount_base & root_usr_share;
when usr_src => return mount_base & root_usr_src;
when lib => return mount_base & root_lib;
when dev => return mount_base & root_dev;
when etc => return mount_base & root_etc;
when etc_default => return mount_base & root_etc_default;
when etc_mtree => return mount_base & root_etc_mtree;
when etc_rcd => return mount_base & root_etc_rcd;
when tmp => return mount_base & root_tmp;
when var => return mount_base & root_var;
when home => return mount_base & root_home;
when proc => return mount_base & root_proc;
when linux => return mount_base & root_linux;
when boot => return mount_base & root_boot;
when root => return mount_base & root_root;
when xports => return mount_base & root_xports;
when options => return mount_base & root_options;
when libexec => return mount_base & root_libexec;
when packages => return mount_base & root_packages;
when distfiles => return mount_base & root_distfiles;
when wrkdirs => return mount_base & root_wrkdirs;
when ccache => return mount_base & root_ccache;
end case;
end location;
--------------------
-- mount_target --
--------------------
function mount_target (point : folder) return String is
begin
case point is
when xports => return JT.USS (PM.configuration.dir_portsdir);
when options => return JT.USS (PM.configuration.dir_options);
when packages => return JT.USS (PM.configuration.dir_packages);
when distfiles => return JT.USS (PM.configuration.dir_distfiles);
when ccache => return JT.USS (PM.configuration.dir_ccache);
when others => return "ERROR";
end case;
end mount_target;
------------------------
-- get_master_mount --
------------------------
function get_master_mount return String is
begin
return JT.USS (PM.configuration.dir_buildbase) & "/" & reference_base;
end get_master_mount;
-----------------------
-- get_slave_mount --
-----------------------
function get_slave_mount (id : builders) return String is
begin
return JT.USS (PM.configuration.dir_buildbase) & "/" & slave_name (id);
end get_slave_mount;
------------------
-- initialize --
------------------
procedure initialize (testmode : Boolean; num_cores : cpu_range)
is
opsys : nullfs_flavor := dragonfly;
mm : constant String := get_master_mount;
maspas : constant String := "/master.passwd";
etcmp : constant String := "/etc" & maspas;
command : constant String := "/usr/sbin/pwd_mkdb -p -d " & mm & " " &
mm & maspas;
begin
smp_cores := num_cores;
developer_mode := testmode;
support_locks := testmode and then Unix.env_variable_defined ("LOCK");
if JT.equivalent (PM.configuration.operating_sys, "FreeBSD") then
opsys := freebsd;
end if;
flavor := opsys;
if AD.Exists (mm) then
annihilate_directory_tree (mm);
end if;
AD.Create_Path (mm);
AD.Copy_File (etcmp, mm & maspas);
execute (command);
create_base_group (mm);
cache_port_variables (mm);
create_mtree_exc_preinst (mm);
create_mtree_exc_preconfig (mm);
end initialize;
----------------
-- finalize --
----------------
procedure finalize
is
mm : constant String := get_master_mount;
begin
if AD.Exists (mm) then
annihilate_directory_tree (mm);
end if;
end finalize;
--------------------
-- mount_nullfs --
--------------------
procedure mount_nullfs (target, mount_point : String;
mode : mount_mode := readonly)
is
cmd_freebsd : constant String := "/sbin/mount_nullfs";
cmd_dragonfly : constant String := "/sbin/mount_null";
command : JT.Text;
begin
if not AD.Exists (mount_point) then
raise scenario_unexpected with
"mount point " & mount_point & " does not exist";
end if;
if not AD.Exists (target) then
raise scenario_unexpected with
"mount target " & target & " does not exist";
end if;
case flavor is
when freebsd => command := JT.SUS (cmd_freebsd);
when dragonfly => command := JT.SUS (cmd_dragonfly);
when unknown =>
raise scenario_unexpected with
"Mounting on unknown operating system";
end case;
case mode is
when readonly => JT.SU.Append (command, " -o ro");
when readwrite => null;
end case;
JT.SU.Append (command, " " & target);
JT.SU.Append (command, " " & mount_point);
execute (JT.USS (command));
end mount_nullfs;
-----------------------
-- mount_linprocfs --
-----------------------
procedure mount_linprocfs (mount_point : String)
is
cmd_freebsd : constant String := "/sbin/mount -t linprocfs linproc " &
mount_point;
begin
-- DragonFly has lost it's Linux Emulation capability.
-- FreeBSD has it for both amd64 and i386
-- We should return if FreeBSD arch is not amd64 or i386, but synth
-- will not run on any other arches at the moment, so we don't have
-- to check (and we don't have that information yet anyway)
if flavor = freebsd then
execute (cmd_freebsd);
end if;
end mount_linprocfs;
---------------
-- unmount --
---------------
procedure unmount (device_or_node : String)
is
command : constant String := "/sbin/umount " & device_or_node;
begin
-- failure to unmount causes stderr squawks which messes up curses
-- display. Just ignore for now (Add robustness later)
silent_exec (command);
exception
when others => null; -- silently fail
end unmount;
-----------------------
-- forge_directory --
-----------------------
procedure forge_directory (target : String) is
begin
AD.Create_Path (New_Directory => target);
exception
when failed : others =>
TIO.Put_Line (EX.Exception_Information (failed));
raise scenario_unexpected with
"failed to create " & target & " directory";
end forge_directory;
-------------------
-- mount_tmpfs --
-------------------
procedure mount_tmpfs (mount_point : String; max_size_M : Natural := 0)
is
cmd_freebsd : constant String := "/sbin/mount -t tmpfs";
cmd_dragonfly : constant String := "/sbin/mount_tmpfs";
command : JT.Text;
begin
case flavor is
when freebsd => command := JT.SUS (cmd_freebsd);
when dragonfly => command := JT.SUS (cmd_dragonfly);
when unknown =>
raise scenario_unexpected with
"Mounting on unknown operating system";
end case;
if max_size_M > 0 then
JT.SU.Append (command, " -o size=" & JT.trim (max_size_M'Img) & "M");
end if;
JT.SU.Append (command, " tmpfs " & mount_point);
execute (JT.USS (command));
end mount_tmpfs;
---------------------
-- mount_devices --
---------------------
procedure mount_devices (path_to_dev : String)
is
command : constant String := "/sbin/mount -t devfs devfs " & path_to_dev;
begin
execute (command);
end mount_devices;
--------------------
-- mount_procfs --
--------------------
procedure mount_procfs (path_to_proc : String)
is
command : constant String := "/sbin/mount -t procfs proc " & path_to_proc;
begin
execute (command);
end mount_procfs;
------------------
-- get_suffix --
------------------
function slave_name (id : builders) return String
is
id_image : constant String := Integer (id)'Img;
suffix : String := "SL00";
begin
if id < 10 then
suffix (4) := id_image (2);
else
suffix (3 .. 4) := id_image (2 .. 3);
end if;
return suffix;
end slave_name;
---------------------
-- folder_access --
---------------------
procedure folder_access (path : String; operation : folder_operation)
is
cmd_freebsd : constant String := "/bin/chflags";
cmd_dragonfly : constant String := "/usr/bin/chflags";
flag_lock : constant String := " schg ";
flag_unlock : constant String := " noschg ";
command : JT.Text;
begin
if not AD.Exists (path) then
raise scenario_unexpected with
"chflags: " & path & " path does not exist";
end if;
case flavor is
when freebsd => command := JT.SUS (cmd_freebsd);
when dragonfly => command := JT.SUS (cmd_dragonfly);
when unknown =>
raise scenario_unexpected with
"Executing cflags on unknown operating system";
end case;
case operation is
when lock => JT.SU.Append (command, flag_lock & path);
when unlock => JT.SU.Append (command, flag_unlock & path);
end case;
execute (JT.USS (command));
end folder_access;
----------------------
-- create_symlink --
----------------------
procedure create_symlink (destination, symbolic_link : String)
is
command : constant String :=
"/bin/ln -s " & destination & " " & symbolic_link;
begin
execute (command);
end create_symlink;
---------------------------
-- populate_var_folder --
---------------------------
procedure populate_var_folder (path : String)
is
command : constant String := "/usr/sbin/mtree -p " & path &
" -f /etc/mtree/BSD.var.dist -deqU";
begin
silent_exec (command);
end populate_var_folder;
---------------
-- execute --
---------------
procedure execute (command : String)
is
Args : OSL.Argument_List_Access;
Exit_Status : Integer;
begin
Args := OSL.Argument_String_To_List (command);
Exit_Status := OSL.Spawn (Program_Name => Args (Args'First).all,
Args => Args (Args'First + 1 .. Args'Last));
OSL.Free (Args);
if Exit_Status /= 0 then
raise scenario_unexpected with
command & " => failed with code" & Exit_Status'Img;
end if;
end execute;
-------------------
-- silent_exec --
-------------------
procedure silent_exec (command : String) is
begin
if not Unix.piped_mute_command (command) then
raise scenario_unexpected with
command & " => failed (exit code not 0)";
end if;
end silent_exec;
------------------------------
-- internal_system_command --
------------------------------
function internal_system_command (command : String) return JT.Text
is
content : JT.Text;
status : Integer;
begin
content := Unix.piped_command (command, status);
if status /= 0 then
raise scenario_unexpected with "cmd: " & command &
" (return code =" & status'Img & ")";
end if;
return content;
end internal_system_command;
-------------------------
-- create_base_group --
-------------------------
procedure create_base_group (path_to_mm : String)
is
subtype sysgroup is String (1 .. 8);
type groupset is array (1 .. 34) of sysgroup;
users : constant groupset :=
("wheel ", "daemon ", "kmem ", "sys ",
"tty ", "operator", "mail ", "bin ",
"news ", "man ", "games ", "staff ",
"sshd ", "smmsp ", "mailnull", "guest ",
"bind ", "proxy ", "authpf ", "_pflogd ",
"unbound ", "ftp ", "video ", "hast ",
"uucp ", "xten ", "dialer ", "network ",
"_sdpd ", "_dhcp ", "www ", "vknet ",
"nogroup ", "nobody ");
group : TIO.File_Type;
live_file : TIO.File_Type;
keepit : Boolean;
target : constant String := path_to_mm & "/group";
live_origin : constant String := "/etc/group";
begin
TIO.Open (File => live_file, Mode => TIO.In_File, Name => live_origin);
TIO.Create (File => group, Mode => TIO.Out_File, Name => target);
while not TIO.End_Of_File (live_file) loop
keepit := False;
declare
line : String := TIO.Get_Line (live_file);
begin
for grpindex in groupset'Range loop
declare
grpcolon : String := JT.trim (users (grpindex)) & ":";
begin
if grpcolon'Length <= line'Length then
if grpcolon = line (1 .. grpcolon'Last) then
keepit := True;
exit;
end if;
end if;
end;
end loop;
if keepit then
TIO.Put_Line (group, line);
end if;
end;
end loop;
TIO.Close (live_file);
TIO.Close (group);
end create_base_group;
--------------------
-- create_group --
--------------------
procedure create_group (path_to_etc : String)
is
mm : constant String := get_master_mount;
group : constant String := "/group";
begin
AD.Copy_File (Source_Name => mm & group,
Target_Name => path_to_etc & group);
end create_group;
---------------------
-- create_passwd --
---------------------
procedure create_passwd (path_to_etc : String)
is
mm : constant String := get_master_mount;
maspwd : constant String := "/master.passwd";
passwd : constant String := "/passwd";
spwd : constant String := "/spwd.db";
pwd : constant String := "/pwd.db";
begin
AD.Copy_File (Source_Name => mm & passwd,
Target_Name => path_to_etc & passwd);
AD.Copy_File (Source_Name => mm & maspwd,
Target_Name => path_to_etc & maspwd);
AD.Copy_File (Source_Name => mm & spwd,
Target_Name => path_to_etc & spwd);
AD.Copy_File (Source_Name => mm & pwd,
Target_Name => path_to_etc & pwd);
end create_passwd;
------------------------
-- copy_mtree_files --
------------------------
procedure copy_mtree_files (path_to_mtree : String)
is
mtree : constant String := "/etc/mtree";
root : constant String := "/BSD.root.dist";
usr : constant String := "/BSD.usr.dist";
var : constant String := "/BSD.var.dist";
begin
AD.Copy_File (Source_Name => mtree & root,
Target_Name => path_to_mtree & root);
AD.Copy_File (Source_Name => mtree & usr,
Target_Name => path_to_mtree & usr);
AD.Copy_File (Source_Name => mtree & var,
Target_Name => path_to_mtree & var);
end copy_mtree_files;
------------------------
-- create_make_conf --
------------------------
procedure create_make_conf (path_to_etc : String)
is
makeconf : TIO.File_Type;
profilemc : constant String := PM.synth_confdir & "/" &
JT.USS (PM.configuration.profile) & "-make.conf";
varcache : constant String := get_master_mount & "/varcache.conf";
begin
TIO.Create (File => makeconf,
Mode => TIO.Out_File,
Name => path_to_etc & "/make.conf");
TIO.Put_Line (makeconf, "USE_PACKAGE_DEPENDS=yes");
TIO.Put_Line (makeconf, "PACKAGE_BUILDING=yes");
TIO.Put_Line (makeconf, "BATCH=yes");
TIO.Put_Line (makeconf, "PKG_CREATE_VERBOSE=yes");
TIO.Put_Line (makeconf, "PORTSDIR=/xports");
TIO.Put_Line (makeconf, "DISTDIR=/distfiles");
TIO.Put_Line (makeconf, "WRKDIRPREFIX=/construction");
TIO.Put_Line (makeconf, "PORT_DBDIR=/options");
TIO.Put_Line (makeconf, "PACKAGES=/packages");
TIO.Put_Line (makeconf, "MAKE_JOBS_NUMBER_LIMIT=" &
(JT.trim (PM.configuration.jobs_limit'Img)));
if developer_mode then
TIO.Put_Line (makeconf, "DEVELOPER=1");
end if;
if AD.Exists (JT.USS (PM.configuration.dir_ccache)) then
TIO.Put_Line (makeconf, "WITH_CCACHE_BUILD=yes");
TIO.Put_Line (makeconf, "CCACHE_DIR=/ccache");
end if;
concatenate_makeconf (makeconf, profilemc);
concatenate_makeconf (makeconf, varcache);
TIO.Close (makeconf);
end create_make_conf;
------------------------
-- copy_resolv_conf --
------------------------
procedure copy_resolv_conf (path_to_etc : String)
is
original : constant String := "/etc/resolv.conf";
begin
if not AD.Exists (original) then
return;
end if;
AD.Copy_File (Source_Name => original,
Target_Name => path_to_etc & "/resolv.conf");
end copy_resolv_conf;
-----------------------
-- copy_rc_default --
-----------------------
procedure copy_rc_default (path_to_etc : String)
is
rc_default : constant String := "/defaults/rc.conf";
etc_rcconf : constant String := "/etc" & rc_default;
begin
if not AD.Exists (etc_rcconf) then
return;
end if;
AD.Copy_File (Source_Name => etc_rcconf,
Target_Name => path_to_etc & rc_default);
end copy_rc_default;
---------------------------
-- create_etc_services --
---------------------------
procedure create_etc_services (path_to_etc : String)
is
svcfile : TIO.File_Type;
begin
TIO.Create (File => svcfile,
Mode => TIO.Out_File,
Name => path_to_etc & "/services");
TIO.Put_Line (svcfile,
"ftp 21/tcp" & LAT.LF &
"ftp 21/udp" & LAT.LF &
"ssh 22/tcp" & LAT.LF &
"ssh 22/udp" & LAT.LF &
"http 80/tcp" & LAT.LF &
"http 80/udp" & LAT.LF &
"https 443/tcp" & LAT.LF &
"https 443/udp" & LAT.LF);
TIO.Close (svcfile);
end create_etc_services;
------------------------
-- create_etc_fstab --
------------------------
procedure create_etc_fstab (path_to_etc : String)
is
fstab : TIO.File_Type;
begin
TIO.Create (File => fstab,
Mode => TIO.Out_File,
Name => path_to_etc & "/fstab");
TIO.Put_Line (fstab, "linproc /usr/compat/proc linprocfs rw 0 0");
TIO.Close (fstab);
end create_etc_fstab;
------------------------
-- execute_ldconfig --
------------------------
procedure execute_ldconfig (id : builders)
is
smount : constant String := get_slave_mount (id);
command : constant String := chroot & smount &
" /sbin/ldconfig -m /lib /usr/lib";
begin
execute (command);
end execute_ldconfig;
-------------------------------
-- standalone_pkg8_install --
-------------------------------
function standalone_pkg8_install (id : builders) return Boolean
is
smount : constant String := get_slave_mount (id);
taropts : constant String := "-C / */pkg-static";
command : constant String := chroot & smount &
" /usr/bin/tar -xf /packages/Latest/pkg.txz " & taropts;
begin
silent_exec (command);
return True;
exception
when others => return False;
end standalone_pkg8_install;
------------------------
-- build_repository --
------------------------
function build_repository (id : builders; sign_command : String := "")
return Boolean
is
smount : constant String := get_slave_mount (id);
command : constant String := chroot & smount & " " &
host_localbase & "/sbin/pkg-static repo /packages";
sc_cmd : constant String := host_pkg8 & " repo " & smount &
"/packages signing_command: ";
key_loc : constant String := "/etc/repo.key";
use_key : constant Boolean := AD.Exists (smount & key_loc);
use_cmd : constant Boolean := not JT.IsBlank (sign_command);
begin
if not standalone_pkg8_install (id) then
TIO.Put_Line ("Failed to install pkg-static in builder" & id'Img);
return False;
end if;
if use_key then
silent_exec (command & " " & key_loc);
elsif use_cmd then
silent_exec (sc_cmd & sign_command);
else
silent_exec (command);
end if;
return True;
exception
when quepaso : others =>
TIO.Put_Line (EX.Exception_Message (quepaso));
return False;
end build_repository;
---------------------------------
-- annihilate_directory_tree --
---------------------------------
procedure annihilate_directory_tree (tree : String)
is
command : constant String := "/bin/rm -rf " & tree;
begin
silent_exec (command);
exception
when others => null;
end annihilate_directory_tree;
--------------------
-- launch_slave --
--------------------
procedure launch_slave (id : builders; opts : slave_options)
is
function clean_mount_point (point : folder) return String;
slave_base : constant String := get_slave_mount (id);
slave_work : constant String := slave_base & "_work";
slave_local : constant String := slave_base & "_localbase";
slave_linux : constant String := slave_base & "_linux";
dir_system : constant String := JT.USS (PM.configuration.dir_system);
live_system : constant Boolean := (dir_system = "/");
function clean_mount_point (point : folder) return String is
begin
if live_system then
return location ("", point);
else
return location (dir_system, point);
end if;
end clean_mount_point;
begin
forge_directory (slave_base);
mount_tmpfs (slave_base);
for mnt in folder'Range loop
forge_directory (location (slave_base, mnt));
end loop;
for mnt in subfolder'Range loop
mount_nullfs (target => clean_mount_point (mnt),
mount_point => location (slave_base, mnt));
end loop;
folder_access (location (slave_base, home), lock);
folder_access (location (slave_base, root), lock);
mount_nullfs (mount_target (xports), location (slave_base, xports));
mount_nullfs (mount_target (options), location (slave_base, options));
mount_nullfs (mount_target (packages), location (slave_base, packages),
mode => readwrite);
mount_nullfs (mount_target (distfiles), location (slave_base, distfiles),
mode => readwrite);
if PM.configuration.tmpfs_workdir then
mount_tmpfs (location (slave_base, wrkdirs), 12 * 1024);
else
forge_directory (slave_work);
mount_nullfs (slave_work, location (slave_base, wrkdirs), readwrite);
end if;
if not support_locks and then PM.configuration.tmpfs_localbase then
mount_tmpfs (slave_base & root_localbase, 12 * 1024);
else
forge_directory (slave_local);
mount_nullfs (slave_local, slave_base & root_localbase, readwrite);
end if;
if opts.need_procfs then
mount_procfs (path_to_proc => location (slave_base, proc));
end if;
if flavor = freebsd then
if opts.need_linprocfs then
if PM.configuration.tmpfs_localbase then
mount_tmpfs (slave_base & root_linux, 12 * 1024);
else
forge_directory (slave_linux);
mount_nullfs (slave_linux, slave_base & root_linux, readwrite);
end if;
forge_directory (slave_base & root_linproc);
mount_linprocfs (mount_point => slave_base & root_linproc);
end if;
declare
lib32 : String := clean_mount_point (usr_lib32);
begin
if AD.Exists (lib32) then
mount_nullfs (target => lib32,
mount_point => location (slave_base, usr_lib32));
end if;
end;
declare
bootdir : String := clean_mount_point (boot);
begin
if AD.Exists (bootdir) then
mount_nullfs (target => bootdir,
mount_point => location (slave_base, boot));
mount_tmpfs (slave_base & root_kmodules, 100);
end if;
end;
end if;
declare
srcdir : String := clean_mount_point (usr_src);
begin
if AD.Exists (srcdir) then
mount_nullfs (srcdir, location (slave_base, usr_src));
if AD.Exists (srcdir & "/sys") then
create_symlink (destination => "usr/src/sys",
symbolic_link => slave_base & "/sys");
end if;
end if;
end;
if AD.Exists (mount_target (ccache)) then
mount_nullfs (mount_target (ccache), location (slave_base, ccache),
mode => readwrite);
end if;
mount_devices (location (slave_base, dev));
populate_var_folder (location (slave_base, var));
copy_mtree_files (location (slave_base, etc_mtree));
copy_rc_default (location (slave_base, etc));
copy_resolv_conf (location (slave_base, etc));
create_make_conf (location (slave_base, etc));
create_passwd (location (slave_base, etc));
create_group (location (slave_base, etc));
create_etc_services (location (slave_base, etc));
create_etc_fstab (location (slave_base, etc));
execute_ldconfig (id);
exception
when hiccup : others => EX.Reraise_Occurrence (hiccup);
end launch_slave;
---------------------
-- destroy_slave --
---------------------
procedure destroy_slave (id : builders; opts : slave_options)
is
slave_base : constant String := get_slave_mount (id);
slave_work : constant String := slave_base & "_work";
slave_local : constant String := slave_base & "_localbase";
slave_linux : constant String := slave_base & "_linux";
dir_system : constant String := JT.USS (PM.configuration.dir_system);
begin
unmount (slave_base & root_localbase);
if support_locks or else not PM.configuration.tmpfs_localbase then
-- We can't use AD.Delete_Tree because it skips directories
-- starting with "." (pretty useless then)
annihilate_directory_tree (slave_local);
end if;
unmount (location (slave_base, wrkdirs));
if not PM.configuration.tmpfs_workdir then
annihilate_directory_tree (slave_work);
end if;
if AD.Exists (root_usr_src) then
unmount (location (slave_base, usr_src));
end if;
if AD.Exists (mount_target (ccache)) then
unmount (location (slave_base, ccache));
end if;
if flavor = freebsd then
if opts.need_linprocfs then
unmount (slave_base & root_linproc);
unmount (slave_base & root_linux);
if not PM.configuration.tmpfs_localbase then
annihilate_directory_tree (slave_linux);
end if;
end if;
if AD.Exists (location (dir_system, usr_lib32)) then
unmount (location (slave_base, usr_lib32));
end if;
if AD.Exists (location (dir_system, boot)) then
unmount (slave_base & root_kmodules);
unmount (location (slave_base, boot));
end if;
end if;
if opts.need_procfs then
unmount (location (slave_base, proc));
end if;
unmount (location (slave_base, dev));
unmount (location (slave_base, xports));
unmount (location (slave_base, options));
unmount (location (slave_base, packages));
unmount (location (slave_base, distfiles));
for mnt in subfolder'Range loop
unmount (location (slave_base, mnt));
end loop;
folder_access (location (slave_base, home), unlock);
folder_access (location (slave_base, root), unlock);
folder_access (location (slave_base, var) & "/empty", unlock);
unmount (slave_base);
annihilate_directory_tree (slave_base);
exception
when hiccup : others => EX.Reraise_Occurrence (hiccup);
end destroy_slave;
--------------------------
-- synth_mounts_exist --
--------------------------
function synth_mounts_exist return Boolean
is
buildbase : constant String := JT.USS (PM.configuration.dir_buildbase);
command : constant String := "/bin/df -h";
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
begin
comres := internal_system_command (command);
crlen1 := JT.SU.Length (comres);
loop
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
if JT.contains (topline, buildbase) then
return True;
end if;
end loop;
return False;
exception
when others =>
return True;
end synth_mounts_exist;
-----------------------------
-- clear_existing_mounts --
-----------------------------
function clear_existing_mounts return Boolean
is
package crate is new AC.Vectors (Index_Type => Positive,
Element_Type => JT.Text,
"=" => JT.SU."=");
package sorter is new crate.Generic_Sorting ("<" => JT.SU."<");
procedure annihilate (cursor : crate.Cursor);
buildbase : constant String := JT.USS (PM.configuration.dir_buildbase);
command1 : constant String := "/bin/df -h";
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
mindex : Natural;
mlength : Natural;
mpoints : crate.Vector;
procedure annihilate (cursor : crate.Cursor)
is
mountpoint : constant String := JT.USS (crate.Element (cursor));
begin
unmount (mountpoint);
if AD.Exists (mountpoint) then
AD.Delete_Directory (mountpoint);
end if;
exception
when others => null;
end annihilate;
begin
comres := internal_system_command (command1);
crlen1 := JT.SU.Length (comres);
loop
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
if JT.contains (topline, buildbase) then
mindex := JT.SU.Index (topline, buildbase);
mlength := JT.SU.Length (topline);
mpoints.Append (JT.SUS (JT.SU.Slice (topline, mindex, mlength)));
end if;
end loop;
sorter.Sort (Container => mpoints);
mpoints.Reverse_Iterate (Process => annihilate'Access);
if synth_mounts_exist then
return False;
end if;
-- No need to remove empty dirs, the upcoming run will do that.
return True;
end clear_existing_mounts;
----------------------------
-- disk_workareas_exist --
----------------------------
function disk_workareas_exist return Boolean
is
Search : AD.Search_Type;
buildbase : constant String := JT.USS (PM.configuration.dir_buildbase);
result : Boolean := False;
begin
if not AD.Exists (buildbase) then
return False;
end if;
AD.Start_Search (Search => Search,
Directory => buildbase,
Filter => (AD.Directory => True, others => False),
Pattern => "SL*_*");
result := AD.More_Entries (Search => Search);
return result;
end disk_workareas_exist;
--------------------------------
-- clear_existing_workareas --
--------------------------------
function clear_existing_workareas return Boolean
is
Search : AD.Search_Type;
Dir_Ent : AD.Directory_Entry_Type;
buildbase : constant String := JT.USS (PM.configuration.dir_buildbase);
begin
AD.Start_Search (Search => Search,
Directory => buildbase,
Filter => (AD.Directory => True, others => False),
Pattern => "SL*_*");
while AD.More_Entries (Search => Search) loop
AD.Get_Next_Entry (Search => Search, Directory_Entry => Dir_Ent);
declare
target : constant String := buildbase & "/" &
AD.Simple_Name (Dir_Ent);
begin
annihilate_directory_tree (target);
end;
end loop;
return True;
exception
when others => return False;
end clear_existing_workareas;
----------------------------
-- concatenate_makeconf --
----------------------------
procedure concatenate_makeconf (makeconf_handle : TIO.File_Type;
target_name : String)
is
fragment : TIO.File_Type;
begin
if AD.Exists (target_name) then
TIO.Open (File => fragment, Mode => TIO.In_File, Name => target_name);
while not TIO.End_Of_File (fragment) loop
declare
Line : String := TIO.Get_Line (fragment);
begin
TIO.Put_Line (makeconf_handle, Line);
end;
end loop;
TIO.Close (fragment);
end if;
exception
when others => null;
end concatenate_makeconf;
----------------------------
-- cache_port_variables --
----------------------------
procedure cache_port_variables (path_to_mm : String)
is
function create_OSRELEASE (OSRELEASE : String) return String;
OSVER : constant String := get_osversion_from_param_header;
ARCH : constant String := get_arch_from_bourne_shell;
portsdir : constant String := JT.USS (PM.configuration.dir_portsdir);
fullport : constant String := portsdir & "/ports-mgmt/pkg";
command : constant String :=
"/usr/bin/make __MAKE_CONF=/dev/null -C " & fullport &
" -VHAVE_COMPAT_IA32_KERN -VCONFIGURE_MAX_CMD_LEN";
content : JT.Text;
topline : JT.Text;
status : Integer;
vconf : TIO.File_Type;
type result_range is range 1 .. 2;
function create_OSRELEASE (OSRELEASE : String) return String
is
-- FreeBSD OSVERSION is 6 or 7 digits
-- OSVERSION [M]MNNPPP
-- DragonFly OSVERSION is 6 digits
-- OSVERSION MNNNPP
len : constant Natural := OSRELEASE'Length;
FL : constant Natural := len - 4;
OSR : constant String (1 .. len) := OSRELEASE;
MM : String (1 .. 2) := " ";
PP : String (1 .. 2) := " ";
begin
if len < 6 then
return "1.0-SYNTH";
end if;
if len = 6 then
MM (2) := OSR (1);
else
MM := OSR (1 .. 2);
end if;
if flavor = dragonfly then
if OSR (3) = '0' then
PP (2) := OSR (4);
else
PP := OSR (3 .. 4);
end if;
else
if OSR (FL) = '0' then
PP (2) := OSR (FL + 1);
else
PP := OSR (FL .. FL + 1);
end if;
end if;
return JT.trim (MM) & "." & JT.trim (PP) & "-SYNTH";
end create_OSRELEASE;
release : constant String := create_OSRELEASE (OSVER);
begin
builder_env := JT.blank;
content := Unix.piped_command (command, status);
if status /= 0 then
raise scenario_unexpected with
"cache_port_variables: return code =" & status'Img;
end if;
TIO.Create (File => vconf,
Mode => TIO.Out_File,
Name => path_to_mm & "/varcache.conf");
for k in result_range loop
JT.nextline (lineblock => content, firstline => topline);
declare
value : constant String := JT.USS (topline);
begin
case k is
when 1 => TIO.Put_Line (vconf, "HAVE_COMPAT_IA32_KERN=" & value);
when 2 => TIO.Put_Line (vconf, "CONFIGURE_MAX_CMD_LEN=" & value);
end case;
end;
end loop;
TIO.Put_Line (vconf, "_SMP_CPUS=" & JT.int2str (Integer (smp_cores)));
TIO.Put_Line (vconf, "UID=0");
TIO.Put_Line (vconf, "ARCH=" & ARCH);
TIO.Put (vconf, "OPSYS=");
case flavor is
when freebsd => TIO.Put_Line (vconf, "FreeBSD");
TIO.Put_Line (vconf, "OSVERSION=" & OSVER);
JT.SU.Append (builder_env, "UNAME_s=FreeBSD " &
"UNAME_v=FreeBSD\ " & release);
when dragonfly => TIO.Put_Line (vconf, "DragonFly");
TIO.Put_Line (vconf, "DFLYVERSION=" & OSVER);
TIO.Put_Line (vconf, "OSVERSION=9999999");
JT.SU.Append (builder_env, "UNAME_s=DragonFly " &
"UNAME_v=DragonFly\ " & release);
when unknown => TIO.Put_Line (vconf, "Unknown");
end case;
TIO.Put_Line (vconf, "OSREL=" & release (1 .. release'Last - 6));
TIO.Put_Line (vconf, "_OSRELEASE=" & release);
TIO.Close (vconf);
JT.SU.Append (builder_env, " UNAME_p=" & ARCH);
JT.SU.Append (builder_env, " UNAME_m=" & ARCH);
JT.SU.Append (builder_env, " UNAME_r=" & release & " ");
end cache_port_variables;
---------------------------------------
-- write_common_mtree_exclude_base --
---------------------------------------
procedure write_common_mtree_exclude_base (mtreefile : TIO.File_Type) is
begin
TIO.Put_Line
(mtreefile,
"./bin" & LAT.LF
& "./boot" & LAT.LF
& "./ccache" & LAT.LF
& "./compat/linux/proc" & LAT.LF
& "./construction" & LAT.LF
& "./dev" & LAT.LF
& "./distfiles" & LAT.LF
& "./lib" & LAT.LF
& "./libexec" & LAT.LF
& "./home" & LAT.LF
& "./options" & LAT.LF
& "./packages" & LAT.LF
& "./proc" & LAT.LF
& "./root" & LAT.LF
& "./sbin" & LAT.LF
& "./tmp" & LAT.LF
& "./usr/bin" & LAT.LF
& "./usr/include" & LAT.LF
& "./usr/lib" & LAT.LF
& "./usr/lib32" & LAT.LF
& "./usr/libdata" & LAT.LF
& "./usr/libexec" & LAT.LF
& "./usr/sbin" & LAT.LF
& "./usr/share" & LAT.LF
& "./usr/src" & LAT.LF
& "./var/db/fontconfig" & LAT.LF
& "./var/run" & LAT.LF
& "./var/tmp" & LAT.LF
& "./xports"
);
end write_common_mtree_exclude_base;
--------------------------------
-- write_preinstall_section --
--------------------------------
procedure write_preinstall_section (mtreefile : TIO.File_Type) is
begin
TIO.Put_Line
(mtreefile,
"./etc/group" & LAT.LF
& "./etc/make.conf" & LAT.LF
& "./etc/make.conf.bak" & LAT.LF
& "./etc/make.nxb.conf" & LAT.LF
& "./etc/master.passwd" & LAT.LF
& "./etc/passwd" & LAT.LF
& "./etc/pwd.db" & LAT.LF
& "./etc/shells" & LAT.LF
& "./etc/spwd.db" & LAT.LF
& "./var/db/freebsd-update" & LAT.LF
& "./var/db/pkg" & LAT.LF
& "./var/log" & LAT.LF
& "./var/mail" & LAT.LF
& "./var/tmp" & LAT.LF
& "./usr/local/etc/gconf/gconf.xml.defaults/%gconf-tree*.xml" & LAT.LF
& "./usr/local/lib/gio/modules/giomodule.cache" & LAT.LF
& "./usr/local/info/dir" & LAT.LF
& "./usr/local/*/info/dir" & LAT.LF
& "./usr/local/*/ls-R" & LAT.LF
& "./usr/local/share/octave/octave_packages" & LAT.LF
& "./usr/local/share/xml/catalog.ports"
);
end write_preinstall_section;
--------------------------------
-- create_mtree_exc_preinst --
--------------------------------
procedure create_mtree_exc_preinst (path_to_mm : String)
is
mtreefile : TIO.File_Type;
filename : constant String := path_to_mm & "/mtree.prestage.exclude";
begin
TIO.Create (File => mtreefile, Mode => TIO.Out_File, Name => filename);
write_common_mtree_exclude_base (mtreefile);
write_preinstall_section (mtreefile);
TIO.Close (mtreefile);
end create_mtree_exc_preinst;
----------------------------------
-- create_mtree_exc_preconfig --
----------------------------------
procedure create_mtree_exc_preconfig (path_to_mm : String)
is
mtreefile : TIO.File_Type;
filename : constant String := path_to_mm & "/mtree.preconfig.exclude";
begin
TIO.Create (File => mtreefile, Mode => TIO.Out_File, Name => filename);
write_common_mtree_exclude_base (mtreefile);
TIO.Close (mtreefile);
end create_mtree_exc_preconfig;
---------------------------------------
-- get_osversion_from_param_header --
---------------------------------------
function get_osversion_from_param_header return String
is
function get_pattern return String;
function get_pattern return String
is
DFVER : constant String := "#define __DragonFly_version ";
FBVER : constant String := "#define __FreeBSD_version ";
BADVER : constant String := "#define __Unknown_version ";
begin
case flavor is
when freebsd => return FBVER;
when dragonfly => return DFVER;
when unknown => return BADVER;
end case;
end get_pattern;
header : TIO.File_Type;
badres : constant String := "100000";
pattern : constant String := get_pattern;
paramh : constant String := JT.USS (PM.configuration.dir_system) &
"/usr/include/sys/param.h";
begin
TIO.Open (File => header, Mode => TIO.In_File, Name => paramh);
while not TIO.End_Of_File (header) loop
declare
Line : constant String := TIO.Get_Line (header);
begin
if JT.contains (Line, pattern) then
declare
OSVER : constant String := JT.part_2 (Line, pattern);
len : constant Natural := OSVER'Length;
begin
exit when len < 7;
TIO.Close (header);
case OSVER (OSVER'First + 6) is
when '0' .. '9' =>
return JT.trim (OSVER (OSVER'First .. OSVER'First + 6));
when others =>
return JT.trim (OSVER (OSVER'First .. OSVER'First + 5));
end case;
end;
end if;
end;
end loop;
TIO.Close (header);
return badres;
exception
when others =>
if TIO.Is_Open (header) then
TIO.Close (header);
end if;
return badres;
end get_osversion_from_param_header;
----------------------------------
-- get_arch_from_bourne_shell --
----------------------------------
function get_arch_from_bourne_shell return String
is
command : constant String := "/usr/bin/file -b " &
JT.USS (PM.configuration.dir_system) & "/bin/sh";
badarch : constant String := "BADARCH";
comres : JT.Text;
begin
comres := internal_system_command (command);
declare
unlen : constant Natural := JT.SU.Length (comres) - 1;
fileinfo : constant String := JT.USS (comres)(1 .. unlen);
arch : constant String (1 .. 11) :=
fileinfo (fileinfo'First + 27 .. fileinfo'First + 37);
begin
if arch (1 .. 6) = "x86-64" then
case flavor is
when freebsd => return "amd64";
when dragonfly => return "x86_64";
when unknown => return badarch;
end case;
elsif arch = "Intel 80386" then
return "i386";
else
return badarch;
end if;
end;
exception
when others =>
return badarch;
end get_arch_from_bourne_shell;
------------------------
-- jail_environment --
------------------------
function jail_environment return JT.Text is
begin
return builder_env;
end jail_environment;
--------------------------------------
-- boot_modules_directory_missing --
--------------------------------------
function boot_modules_directory_missing return Boolean is
begin
if JT.equivalent (PM.configuration.operating_sys, "FreeBSD") then
declare
sroot : constant String := JT.USS (PM.configuration.dir_system);
bootdir : constant String := sroot & root_boot;
modsdir : constant String := sroot & root_kmodules;
begin
if AD.Exists (bootdir) and then not AD.Exists (modsdir) then
return True;
end if;
end;
end if;
return False;
end boot_modules_directory_missing;
end Replicant;
|
zhmu/ananas | Ada | 376 | adb | -- { dg-do run }
procedure Aliased2 is
type Rec is record
Data : access constant String;
end record;
function Get (S : aliased String) return Rec is
R : Rec := (Data => S'Unchecked_Access);
begin
return R;
end;
S : aliased String := "Hello";
R : Rec := Get (S);
begin
if R.Data'Length /= S'Length then
raise Program_Error;
end if;
end;
|
stcarrez/ada-asf | Ada | 7,894 | adb | -----------------------------------------------------------------------
-- asf-tests - ASF Tests Framework
-- Copyright (C) 2011, 2012, 2013, 2015, 2017, 2018, 2019, 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.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Ada.Strings.Fixed;
with Ada.Strings.Unbounded;
with Util.Files;
with Servlet.Core;
with ASF.Servlets.Faces;
with ASF.Servlets.Ajax;
with Servlet.Filters;
with Servlet.Core.Files;
with Servlet.Core.Measures;
with ASF.Responses;
with ASF.Contexts.Faces;
with EL.Variables.Default;
package body ASF.Tests is
CONTEXT_PATH : constant String := "/asfunit";
App_Created : ASF.Applications.Main.Application_Access;
App : ASF.Applications.Main.Application_Access;
Faces : aliased ASF.Servlets.Faces.Faces_Servlet;
Ajax : aliased ASF.Servlets.Ajax.Ajax_Servlet;
Files : aliased Servlet.Core.Files.File_Servlet;
Measures : aliased Servlet.Core.Measures.Measure_Servlet;
-- ------------------------------
-- Initialize the awa test framework mockup.
-- ------------------------------
procedure Initialize (Props : in Util.Properties.Manager;
Application : in ASF.Applications.Main.Application_Access := null;
Factory : in out ASF.Applications.Main.Application_Factory'Class) is
use type ASF.Applications.Main.Application_Access;
C : ASF.Applications.Config;
Empty : Util.Properties.Manager;
begin
if Application /= null then
App := Application;
else
if App_Created = null then
App_Created := new ASF.Applications.Main.Application;
end if;
App := App_Created;
end if;
C.Copy (Props);
App.Initialize (C, Factory);
App.Register ("layoutMsg", "layout");
App.Set_Global ("contextPath", CONTEXT_PATH);
-- Register the servlets and filters
App.Add_Servlet (Name => "faces", Server => Faces'Access);
App.Add_Servlet (Name => "ajax", Server => Ajax'Access);
App.Add_Servlet (Name => "files", Server => Files'Access);
App.Add_Servlet (Name => "measures", Server => Measures'Access);
App.Add_Filter (Name => "measures",
Filter => Servlet.Filters.Filter'Class (Measures)'Access);
-- Define servlet mappings
App.Add_Mapping (Name => "faces", Pattern => "*.html");
App.Add_Mapping (Name => "ajax", Pattern => "/ajax/*");
App.Add_Mapping (Name => "files", Pattern => "*.css");
App.Add_Mapping (Name => "files", Pattern => "*.js");
App.Add_Mapping (Name => "files", Pattern => "*.html");
App.Add_Mapping (Name => "files", Pattern => "*.txt");
App.Add_Mapping (Name => "files", Pattern => "*.png");
App.Add_Mapping (Name => "files", Pattern => "*.jpg");
App.Add_Mapping (Name => "files", Pattern => "*.gif");
App.Add_Mapping (Name => "files", Pattern => "*.pdf");
App.Add_Mapping (Name => "files", Pattern => "*.properties");
App.Add_Mapping (Name => "files", Pattern => "*.xhtml");
App.Add_Mapping (Name => "measures", Pattern => "stats.xml");
App.Add_Filter_Mapping (Name => "measures", Pattern => "*");
App.Add_Filter_Mapping (Name => "measures", Pattern => "/ajax/*");
App.Add_Filter_Mapping (Name => "measures", Pattern => "*.html");
App.Add_Filter_Mapping (Name => "measures", Pattern => "*.xhtml");
Servlet.Tests.Initialize (Empty, CONTEXT_PATH, App.all'Access);
end Initialize;
-- ------------------------------
-- Get the test application.
-- ------------------------------
function Get_Application return ASF.Applications.Main.Application_Access is
use type Servlet.Core.Servlet_Registry_Access;
Result : constant Servlet.Core.Servlet_Registry_Access := Servlet.Tests.Get_Application;
begin
if Result = null then
return App;
elsif Result.all in ASF.Applications.Main.Application'Class then
return ASF.Applications.Main.Application'Class (Result.all)'Access;
else
return App;
end if;
end Get_Application;
-- ------------------------------
-- Extract from the response output saved in `Filename` the form parameter
-- that corresponds to the `Field` hidden field.
-- ------------------------------
function Extract (Field : in String;
Filename : in String) return String is
use Ada.Strings.Unbounded;
procedure Process (Line : in String);
Pattern : constant String := "<input type=""hidden"" name=""" & Field & """ value=""";
Result : Ada.Strings.Unbounded.Unbounded_String;
procedure Process (Line : in String) is
Pos, Sep : Natural;
begin
Pos := Ada.Strings.Fixed.Index (Line, Pattern);
if Pos > 0 then
Pos := Pos + Pattern'Length;
Sep := Ada.Strings.Fixed.Index (Line, """", Pos);
if Sep > 0 then
Result := To_Unbounded_String (Line (Pos .. Sep - 1));
end if;
end if;
end Process;
begin
Util.Files.Read_File (Util.Tests.Get_Test_Path (Filename), Process'Access);
return To_String (Result);
end Extract;
-- ------------------------------
-- Set in the request the CSRF form parameter identified by `Field` that
-- can be extracted from the response output saved in `Filename`.
-- ------------------------------
procedure Set_CSRF (Request : in out ASF.Requests.Mockup.Request'Class;
Field : in String;
Filename : in String) is
Token : constant String := Extract (Field, Filename);
begin
Request.Set_Parameter (Field, Token);
end Set_CSRF;
-- ------------------------------
-- Cleanup the test instance.
-- ------------------------------
overriding
procedure Tear_Down (T : in out EL_Test) is
procedure Free is
new Ada.Unchecked_Deallocation (EL.Contexts.Default.Default_Context'Class,
EL.Contexts.Default.Default_Context_Access);
procedure Free is
new Ada.Unchecked_Deallocation (EL.Variables.Variable_Mapper'Class,
EL.Variables.Variable_Mapper_Access);
procedure Free is
new Ada.Unchecked_Deallocation (EL.Contexts.Default.Default_ELResolver'Class,
EL.Contexts.Default.Default_ELResolver_Access);
begin
ASF.Contexts.Faces.Restore (null);
Free (T.ELContext);
Free (T.Variables);
Free (T.Root_Resolver);
end Tear_Down;
-- ------------------------------
-- Setup the test instance.
-- ------------------------------
overriding
procedure Set_Up (T : in out EL_Test) is
begin
T.ELContext := new EL.Contexts.Default.Default_Context;
T.Root_Resolver := new EL.Contexts.Default.Default_ELResolver;
T.Variables := new EL.Variables.Default.Default_Variable_Mapper;
T.ELContext.Set_Resolver (T.Root_Resolver.all'Access);
T.ELContext.Set_Variable_Mapper (T.Variables.all'Access);
end Set_Up;
end ASF.Tests;
|
python36/vibecrypt | Ada | 4,920 | adb | with Ada.Text_IO;
with file_crypter;
with byte_package;
with Ada.Command_Line;
with System.os_lib;
with Ada.Exceptions;
procedure vibecrypt is
in_file : byte_package.byte_io.File_Type;
out_file : byte_package.byte_io.File_Type;
mode : file_crypter.mode;
password : file_crypter.key_s;
procedure help is
begin
Ada.text_io.put_line(
"Vibecrypt is very simple tool to encrypt/decrypt your file." & ASCII.FF & ASCII.CR &
"Written in Ada. Uses Raiden cypher (http://raiden-cipher.sourceforge.net/)" & ASCII.FF & ASCII.CR &
"Help:" & ASCII.FF & ASCII.CR &
" vibecrypter -h" & ASCII.FF & ASCII.CR &
"Usage:" & ASCII.FF & ASCII.CR &
" vibecrypt key -e|-d in_file out_file [-r]" & ASCII.FF & ASCII.CR &
" key: length from 6 to 16 characters." & ASCII.FF & ASCII.CR &
" if length < 16 - will be supplemented with underscores ('_')." & ASCII.FF & ASCII.CR &
" if length > 16 - will be truncated to 16 characters" & ASCII.FF & ASCII.CR &
" -e: encryption" & ASCII.FF & ASCII.CR &
" -d: decryption" & ASCII.FF & ASCII.CR &
" -r: rewrite file" & ASCII.FF & ASCII.CR &
"Example:" & ASCII.FF & ASCII.CR &
" vibecrypt " & '"' & "0123456789abcdef" & '"' & "-e test_m.txt test_c.txt -r" & ASCII.FF & ASCII.CR &
"The key can contain one of the characters:" & ASCII.FF & ASCII.CR &
" ' ', '!', '" & '"' & "', '#', '$', '%', '&'," & ASCII.FF & ASCII.CR &
" ''', '(', ')', '*', '+', ',', '-', '.', '/', '0'," & ASCII.FF & ASCII.CR &
" '1', '2', '3', '4', '5', '6', '7', '8', '9', ':'," & ASCII.FF & ASCII.CR &
" ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D'," & ASCII.FF & ASCII.CR &
" 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N'," & ASCII.FF & ASCII.CR &
" 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X'," & ASCII.FF & ASCII.CR &
" 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b'," & ASCII.FF & ASCII.CR &
" 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'," & ASCII.FF & ASCII.CR &
" 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v'," & ASCII.FF & ASCII.CR &
" 'w', 'x', 'y', 'z', '{', '|', '}', '~'");
end help;
begin
if Ada.Command_Line.Argument_Count = 1 and Ada.Command_Line.Argument(1) = "-h" then
help;
system.os_lib.os_exit(0);
elsif Ada.Command_Line.Argument_Count not in 4..5 then
Ada.text_io.put_line("see format");
system.os_lib.os_exit(0);
end if;
if Ada.Command_Line.Argument(1)'length < 6 then
Ada.text_io.put_line("Minimum key length - 6");
system.os_lib.os_exit(0);
elsif Ada.Command_Line.Argument(1)'length >= 16 then
password := Ada.Command_Line.Argument(1)(1..16);
else
password(1..Ada.Command_Line.Argument(1)'length) := Ada.Command_Line.Argument(1);
for i in (Ada.Command_Line.Argument(1)'length + 1)..16 loop
password(i) := character'val(character'pos(' ') + i);
end loop;
end if;
for i in 1..16 loop
if password(i) not in ' '..'~' then
Ada.text_io.put_line("The key contains an invalid character");
system.os_lib.os_exit(0);
end if;
end loop;
file_crypter.init_key(password);
if Ada.Command_Line.Argument(2) = "-e" then
mode := file_crypter.mode'(file_crypter.encrypt);
elsif Ada.Command_Line.Argument(2) = "-d" then
mode := file_crypter.mode'(file_crypter.decrypt);
else
Ada.text_io.put_line("The first argument must be -e or -d");
system.os_lib.os_exit(0);
end if;
if not system.os_lib.Is_Regular_File(Ada.Command_Line.Argument(3)) then
Ada.text_io.put_line(Ada.Command_Line.Argument(3) & " is not a regular file");
system.os_lib.os_exit(0);
else
byte_package.byte_io.open(in_file, byte_package.byte_io.In_File, Ada.Command_Line.Argument(3), "");
end if;
if Ada.Command_Line.Argument_Count = 5 then
if Ada.Command_Line.Argument(5) /= "-r" then
Ada.text_io.put_line("The fifth argument can be only -r");
system.os_lib.os_exit(0);
end if;
if not system.os_lib.Is_Writable_File(Ada.Command_Line.Argument(4)) then
Ada.text_io.put_line(Ada.Command_Line.Argument(4) & " is not a writable file");
system.os_lib.os_exit(0);
end if;
byte_package.byte_io.open(out_file, byte_package.byte_io.Out_File, Ada.Command_Line.Argument(4), "");
else
if system.os_lib.Is_Regular_File(Ada.Command_Line.Argument(4)) then
Ada.text_io.put_line(Ada.Command_Line.Argument(4) & " already exists. Use -r to overwrite");
system.os_lib.os_exit(0);
end if;
byte_package.byte_io.create(out_file, byte_package.byte_io.Out_File, Ada.Command_Line.Argument(4), "");
end if;
file_crypter.file_crypt(in_file, out_file, mode);
byte_package.byte_io.close(in_file);
byte_package.byte_io.close(out_file);
exception
when Error: others =>
Ada.Text_IO.Put_Line("Error: " & Ada.Exceptions.Exception_Message(Error));
end vibecrypt;
|
DrenfongWong/tkm-rpc | Ada | 425 | ads | with Ada.Unchecked_Conversion;
package Tkmrpc.Response.Ike.Dh_Generate_Key.Convert is
function To_Response is new Ada.Unchecked_Conversion (
Source => Dh_Generate_Key.Response_Type,
Target => Response.Data_Type);
function From_Response is new Ada.Unchecked_Conversion (
Source => Response.Data_Type,
Target => Dh_Generate_Key.Response_Type);
end Tkmrpc.Response.Ike.Dh_Generate_Key.Convert;
|
persan/AdaYaml | Ada | 175 | ads | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
package Yaml.Dumping_Tests is
end Yaml.Dumping_Tests;
|
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_Cond_Style_Name_Attributes;
package Matreshka.ODF_Text.Cond_Style_Name_Attributes is
type Text_Cond_Style_Name_Attribute_Node is
new Matreshka.ODF_Text.Abstract_Text_Attribute_Node
and ODF.DOM.Text_Cond_Style_Name_Attributes.ODF_Text_Cond_Style_Name_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Cond_Style_Name_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Cond_Style_Name_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Text.Cond_Style_Name_Attributes;
|
reznikmm/matreshka | Ada | 4,059 | 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.Style_Rel_Column_Width_Attributes;
package Matreshka.ODF_Style.Rel_Column_Width_Attributes is
type Style_Rel_Column_Width_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Rel_Column_Width_Attributes.ODF_Style_Rel_Column_Width_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Rel_Column_Width_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Rel_Column_Width_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Rel_Column_Width_Attributes;
|
burratoo/Acton | Ada | 2,075 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK COMPONENTS --
-- --
-- OAK.PROTECTED_OBJECTS --
-- --
-- Copyright (C) 2012-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
with Oak.Agent; use Oak.Agent;
with Oak.Brokers; use Oak.Brokers;
with Oak.Indices; use Oak.Indices;
with Oak.Message; use Oak.Message;
package Oak.Protected_Objects with Preelaborate is
procedure Acquire_Protected_Object_For_Interrupt (PO : in Protected_Id);
-- Acquires a protected object without the overhead that a normal enter
-- request would have since the interrupt should already be at the ceiling
-- priority of the protected object.
procedure Process_Enter_Request
(Entering_Agent : in Task_Id;
PO : in Protected_Id;
Subprogram_Kind : in Protected_Subprogram_Type;
Entry_Id : in Entry_Index);
-- Processess a task's entry request to the desired protected object.
procedure Process_Exit_Request
(Exiting_Agent : in Task_Id;
PO : in Protected_Id);
-- Processess a task's exit request from the desired protected object.
procedure Process_Interrupt_Exit (PO : in Protected_Id);
-- Processess an interrupt's exit request from the desired protected
-- object.
procedure Release_Protected_Object_For_Interrupt (PO : in Protected_Id);
-- Releases the protected object that was possesed by an interrupt.
end Oak.Protected_Objects;
|
reznikmm/matreshka | Ada | 3,654 | 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.Dc_Language_Elements is
pragma Preelaborate;
type ODF_Dc_Language is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Dc_Language_Access is
access all ODF_Dc_Language'Class
with Storage_Size => 0;
end ODF.DOM.Dc_Language_Elements;
|
reznikmm/matreshka | Ada | 15,661 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-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.String_Vectors.Internals;
with League.Strings.Internals;
with Matreshka.Internals.Strings.Configuration;
package body League.String_Vectors is
use Matreshka.Internals.String_Vectors;
use Matreshka.Internals.Strings;
use Matreshka.Internals.Strings.Configuration;
---------
-- "=" --
---------
function "="
(Left : Universal_String_Vector;
Right : Universal_String_Vector) return Boolean
is
LD : constant not null
Matreshka.Internals.String_Vectors.Shared_String_Vector_Access
:= Left.Data;
RD : constant not null
Matreshka.Internals.String_Vectors.Shared_String_Vector_Access
:= Right.Data;
begin
-- Both objects shared same shared object, they are equal.
if LD = RD then
return True;
end if;
-- Objects have different length, they are not equal.
if LD.Unused /= RD.Unused then
return False;
end if;
-- Check whether all strings are equal.
for J in 0 .. LD.Unused - 1 loop
if not String_Handler.Is_Equal (LD.Value (J), RD.Value (J)) then
return False;
end if;
end loop;
return True;
end "=";
------------
-- Adjust --
------------
overriding procedure Adjust (Self : in out Universal_String_Vector) is
begin
Matreshka.Internals.String_Vectors.Reference (Self.Data);
end Adjust;
------------
-- Append --
------------
procedure Append
(Self : in out Universal_String_Vector'Class;
Item : League.Strings.Universal_String'Class) is
begin
Append (Self.Data, League.Strings.Internals.Internal (Item));
Matreshka.Internals.Strings.Reference
(League.Strings.Internals.Internal (Item));
end Append;
------------
-- Append --
------------
procedure Append
(Self : in out Universal_String_Vector'Class;
Item : Universal_String_Vector'Class) is
begin
for J in 1 .. Item.Length loop
Self.Append (Item.Element (J));
end loop;
end Append;
-----------
-- Clear --
-----------
procedure Clear (Self : in out Universal_String_Vector'Class) is
begin
Matreshka.Internals.String_Vectors.Dereference (Self.Data);
Self.Data :=
Matreshka.Internals.String_Vectors.Empty_Shared_String_Vector'Access;
end Clear;
-------------
-- Element --
-------------
function Element
(Self : Universal_String_Vector'Class;
Index : Positive) return League.Strings.Universal_String
is
Position : constant String_Vector_Index
:= String_Vector_Index (Index - 1);
begin
if Position >= Self.Data.Unused then
raise Constraint_Error with "Index is out of range";
end if;
return League.Strings.Internals.Create (Self.Data.Value (Position));
end Element;
---------------
-- Ends_With --
---------------
function Ends_With
(Self : Universal_String_Vector'Class;
String : League.Strings.Universal_String'Class) return Boolean
is
use type League.Strings.Universal_String;
begin
return
Self.Length >= 1
and then Self (Self.Length)
= League.Strings.Universal_String (String);
end Ends_With;
---------------
-- Ends_With --
---------------
function Ends_With
(Self : Universal_String_Vector'Class;
Vector : Universal_String_Vector'Class) return Boolean
is
use type League.Strings.Universal_String;
begin
if Self.Length >= Vector.Length then
for J in reverse 1 .. Vector.Length loop
if Self (Self.Length - Vector.Length + J) /= Vector (J) then
return False;
end if;
end loop;
return True;
end if;
return False;
end Ends_With;
---------------
-- Ends_With --
---------------
function Ends_With
(Self : Universal_String_Vector'Class;
String : Wide_Wide_String) return Boolean is
begin
return Self.Ends_With (League.Strings.To_Universal_String (String));
end Ends_With;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Self : in out Universal_String_Vector) is
begin
-- Finalize can be called more than once (as specified by language
-- standard), thus implementation should provide protection from
-- multiple finalization.
if Self.Data /= null then
Dereference (Self.Data);
end if;
end Finalize;
-----------
-- Index --
-----------
function Index
(Self : Universal_String_Vector'Class;
Pattern : League.Strings.Universal_String'Class) return Natural
is
V_D : constant not null
Matreshka.Internals.String_Vectors.Shared_String_Vector_Access
:= Self.Data;
P_D : constant not null Shared_String_Access
:= League.Strings.Internals.Internal (Pattern);
Index : Matreshka.Internals.String_Vectors.String_Vector_Index := 0;
begin
while Index < V_D.Unused loop
if String_Handler.Is_Equal (V_D.Value (Index), P_D) then
return Positive (Index + 1);
end if;
Index := Index + 1;
end loop;
return 0;
end Index;
-----------
-- Index --
-----------
function Index
(Self : Universal_String_Vector'Class;
Pattern : Wide_Wide_String) return Natural is
begin
return Self.Index (League.Strings.To_Universal_String (Pattern));
end Index;
------------
-- Insert --
------------
procedure Insert
(Self : in out Universal_String_Vector'Class;
Index : Positive;
Item : League.Strings.Universal_String'Class)
is
Position : constant String_Vector_Index
:= String_Vector_Index (Index - 1);
begin
if Position > Self.Data.Unused then
raise Constraint_Error with "Index is out of range";
end if;
Matreshka.Internals.String_Vectors.Insert
(Self.Data, Position, League.Strings.Internals.Internal (Item));
end Insert;
--------------
-- Is_Empty --
--------------
function Is_Empty (Self : Universal_String_Vector'Class) return Boolean is
begin
return Self.Data.Unused = 0;
end Is_Empty;
----------
-- Join --
----------
function Join
(Self : Universal_String_Vector'Class;
Separator : League.Strings.Universal_String'Class)
return League.Strings.Universal_String is
begin
return Result : League.Strings.Universal_String do
if not Self.Is_Empty then
Result.Append (Self.Element (1));
end if;
for J in 2 .. Self.Length loop
Result.Append (Separator);
Result.Append (Self.Element (J));
end loop;
end return;
end Join;
----------
-- Join --
----------
function Join
(Self : Universal_String_Vector'Class;
Separator : Wide_Wide_String)
return League.Strings.Universal_String is
begin
return Self.Join (League.Strings.To_Universal_String (Separator));
end Join;
----------
-- Join --
----------
function Join
(Self : Universal_String_Vector'Class;
Separator : League.Characters.Universal_Character'Class)
return League.Strings.Universal_String is
begin
return Result : League.Strings.Universal_String do
if not Self.Is_Empty then
Result.Append (Self.Element (1));
end if;
for J in 2 .. Self.Length loop
Result.Append (Separator);
Result.Append (Self.Element (J));
end loop;
end return;
end Join;
----------
-- Join --
----------
function Join
(Self : Universal_String_Vector'Class;
Separator : Wide_Wide_Character)
return League.Strings.Universal_String is
begin
return Self.Join (League.Characters.To_Universal_Character (Separator));
end Join;
------------
-- Length --
------------
function Length (Self : Universal_String_Vector'Class) return Natural is
begin
return Natural (Self.Data.Unused);
end Length;
-------------
-- Prepend --
-------------
procedure Prepend
(Self : in out Universal_String_Vector'Class;
Item : Universal_String_Vector'Class) is
begin
Matreshka.Internals.String_Vectors.Prepend (Self.Data, Item.Data);
end Prepend;
----------
-- Read --
----------
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : out Universal_String_Vector)
is
Aux : League.Strings.Universal_String;
Length : Natural;
begin
Natural'Read (Stream, Length);
Item.Clear;
for J in 1 .. Length loop
League.Strings.Universal_String'Read (Stream, Aux);
Item.Append (Aux);
end loop;
end Read;
-------------
-- Replace --
-------------
procedure Replace
(Self : in out Universal_String_Vector'Class;
Index : Positive;
Item : League.Strings.Universal_String'Class)
is
Position : constant String_Vector_Index
:= String_Vector_Index (Index - 1);
begin
if Position >= Self.Data.Unused then
raise Constraint_Error with "Index is out of range";
end if;
Matreshka.Internals.String_Vectors.Replace
(Self.Data, Position, League.Strings.Internals.Internal (Item));
end Replace;
-----------
-- Slice --
-----------
function Slice
(Self : Universal_String_Vector'Class;
Low : Positive;
High : Natural) return Universal_String_Vector
is
SD : constant not null
Matreshka.Internals.String_Vectors.Shared_String_Vector_Access
:= Self.Data;
TD : Matreshka.Internals.String_Vectors.Shared_String_Vector_Access;
begin
if Low > High then
-- By Ada conventions, slice is empty when Low is greater than High.
-- Actual values of Low and High is not important here.
return Empty_Universal_String_Vector;
elsif Low > Self.Length or else High > Self.Length then
-- Otherwise, both Low and High should be less or equal to Length.
raise Constraint_Error with "Index is out of range";
end if;
TD := Allocate (String_Vector_Index (High - Low + 1));
for J in String_Vector_Index (Low - 1)
.. String_Vector_Index (High - 1)
loop
Reference (SD.Value (J));
TD.Value (TD.Unused) := SD.Value (J);
TD.Unused := TD.Unused + 1;
end loop;
return League.String_Vectors.Internals.Wrap (TD);
end Slice;
-----------------
-- Starts_With --
-----------------
function Starts_With
(Self : Universal_String_Vector'Class;
String : League.Strings.Universal_String'Class) return Boolean
is
use type League.Strings.Universal_String;
begin
return
Self.Length >= 1
and then Self (1) = League.Strings.Universal_String (String);
end Starts_With;
-----------------
-- Starts_With --
-----------------
function Starts_With
(Self : Universal_String_Vector'Class;
Vector : Universal_String_Vector'Class) return Boolean
is
use type League.Strings.Universal_String;
begin
if Self.Length >= Vector.Length then
for J in 1 .. Vector.Length loop
if Self (J) /= Vector (J) then
return False;
end if;
end loop;
return True;
end if;
return False;
end Starts_With;
-----------------
-- Starts_With --
-----------------
function Starts_With
(Self : Universal_String_Vector'Class;
String : Wide_Wide_String) return Boolean is
begin
return Self.Starts_With (League.Strings.To_Universal_String (String));
end Starts_With;
-----------
-- Write --
-----------
procedure Write
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Universal_String_Vector) is
begin
String_Vector_Index'Write (Stream, Item.Data.Unused);
for J in 1 .. Item.Length loop
League.Strings.Universal_String'Write (Stream, Item.Element (J));
end loop;
end Write;
end League.String_Vectors;
|
MinimSecure/unum-sdk | Ada | 874 | adb | -- Copyright 2014-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/>.
with Pck; use Pck;
procedure Foo is
A1 : Packed_Array := Make (1, 2);
A2 : Packed_Array renames A1;
begin
Do_Nothing (A2'Address); -- STOP
end Foo;
|
pombredanne/ravenadm | Ada | 36,943 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Ada.Characters.Latin_1;
with Ada.Directories;
with Ada.Exceptions;
with File_Operations;
with Utilities;
with PortScan.Log;
package body Port_Specification.Web is
package LAT renames Ada.Characters.Latin_1;
package DIR renames Ada.Directories;
package FOP renames File_Operations;
package LOG renames PortScan.Log;
package UTL renames Utilities;
--------------------------------------------------------------------------------------------
-- produce_page
--------------------------------------------------------------------------------------------
procedure produce_page
(specs : Portspecs;
variant : String;
dossier : TIO.File_Type;
portdir : String;
blocked : String;
created : CAL.Time;
changed : CAL.Time;
devscan : Boolean) is
begin
TIO.Put_Line (dossier, page_header ("Ravenport: " & specs.get_namebase));
TIO.Put_Line (dossier, generate_body (specs => specs,
variant => variant,
portdir => portdir,
blocked => blocked,
created => created,
changed => changed,
devscan => devscan));
TIO.Put_Line (dossier, page_footer);
end produce_page;
--------------------------------------------------------------------------------------------
-- escape_value
--------------------------------------------------------------------------------------------
function escape_value (raw : String) return String
is
function htmlval (rawchar : Character) return String;
focus : constant String :=
LAT.Quotation &
LAT.Less_Than_Sign &
LAT.Greater_Than_Sign &
LAT.Ampersand;
curlen : Natural := raw'Length;
result : String (1 .. raw'Length * 6) := (others => ' ');
function htmlval (rawchar : Character) return String is
begin
case rawchar is
when LAT.Quotation => return """;
when LAT.Less_Than_Sign => return "<";
when LAT.Greater_Than_Sign => return ">";
when LAT.Ampersand => return "&";
when others => return "";
end case;
end htmlval;
begin
result (1 .. curlen) := raw;
for x in focus'Range loop
if HT.count_char (result (1 .. curlen), focus (x)) > 0 then
declare
newstr : constant String :=
HT.replace_char (result (1 .. curlen), focus (x), htmlval (focus (x)));
begin
curlen := newstr'Length;
result (1 .. curlen) := newstr;
end;
end if;
end loop;
return result (1 .. curlen);
end escape_value;
--------------------------------------------------------------------------------------------
-- nvpair
--------------------------------------------------------------------------------------------
function nvpair (name, value : String) return String is
begin
return " " & name & LAT.Equals_Sign & LAT.Quotation & escape_value (value) & LAT.Quotation;
end nvpair;
--------------------------------------------------------------------------------------------
-- page_header
--------------------------------------------------------------------------------------------
function page_header (title : String) return String
is
bing : constant String := LAT.Greater_Than_Sign & LAT.LF;
content : constant String := "Ravenports individual port description";
csslink : constant String := "../../../style/ravenports.css";
begin
return
"<!doctype html" & bing &
"<html" & nvpair ("lang", "en") & bing &
"<head" & bing &
" <title>" & escape_value (title) & "</title" & bing &
" <meta" & nvpair ("charset", "utf-8") & bing &
" <meta" & nvpair ("name", "description") & nvpair ("content", content) & bing &
" <link" & nvpair ("rel", "stylesheet") & nvpair ("href", csslink) & bing &
"</head" & bing &
"<body>";
end page_header;
--------------------------------------------------------------------------------------------
-- page_footer
--------------------------------------------------------------------------------------------
function page_footer return String
is
bing : constant String := LAT.Greater_Than_Sign & LAT.LF;
link1val : constant String := "Ravenports catalog";
link2val : constant String := "Ravenports official site";
begin
return
" <div" & nvpair ("id", "footer") & bing &
" <div" & nvpair ("id", "catlink") & ">" &
link ("../../../index.html", "footlink", link1val) & " | " &
link ("http://ravenports.ironwolf.systems/", "footlink", link2val) &
"</div" & bing &
" </div" & bing &
"</body>" & LAT.LF & "</html>";
end page_footer;
--------------------------------------------------------------------------------------------
-- div
--------------------------------------------------------------------------------------------
function div (id, value : String) return String is
begin
return "<div" & nvpair ("id", id) & ">" & escape_value (value) & "</div>" & LAT.LF;
end div;
--------------------------------------------------------------------------------------------
-- body_template
--------------------------------------------------------------------------------------------
function body_template return String
is
ediv : constant String := "</div>" & LAT.LF;
etd : constant String := "</td>" & LAT.LF;
etr : constant String := "</tr>" & LAT.LF;
btr : constant String := "<tr>" & LAT.LF;
raw : constant String :=
" <div id='namebase'>@NAMEBASE@" & ediv &
" <div id='shortblock'>" & LAT.LF &
" <table id='sbt1'>" & LAT.LF &
" <tbody>" & LAT.LF &
" " & btr &
" <td>Port variant" & etd &
" <td id='variant'>@VARIANT@" & etd &
" " & etr &
" " & btr &
" <td>Summary" & etd &
" <td id='summary'>@TAGLINE@" & etd &
" " & etr &
"@BROKEN@" &
"@DEPRECATED@" &
"@ONLY_PLATFORM@" &
"@EXC_PLATFORM@" &
"@EXC_ARCH@" &
" " & btr &
" <td>Package version" & etd &
" <td id='pkgversion'>@PKGVERSION@" & etd &
" " & etr &
" " & btr &
" <td>Homepage" & etd &
" <td id='homepage'>@HOMEPAGE@" & etd &
" " & etr &
" " & btr &
" <td>Keywords" & etd &
" <td id='keywords'>@KEYWORDS@" & etd &
" " & etr &
" " & btr &
" <td>Maintainer" & etd &
" <td id='maintainer'>@MAINTAINER@" & etd &
" " & etr &
" " & btr &
" <td>License" & etd &
" <td id='license'>@LICENSE@" & etd &
" " & etr &
" " & btr &
" <td>Other variants" & etd &
" <td id='othervar'>@OTHERVAR@" & etd &
" " & etr &
" " & btr &
" <td>Ravenports" & etd &
" <td id='ravenports'>@LNK_BUILDSHEET@ | @LNK_HISTORY_BS@" & etd &
" " & etr &
" " & btr &
" <td>Ravensource" & etd &
" <td id='ravensource'>@LNK_PORT@ | @LNK_HISTORY_PORT@" & etd &
" " & etr &
" " & btr &
" <td>Last modified" & etd &
" <td id='mdate'>@MDATETIME@" & etd &
" " & etr &
" " & btr &
" <td>Port created" & etd &
" <td id='cdate'>@CDATETIME@" & etd &
" " & etr &
" </tbody>" & LAT.LF &
" </table>" & LAT.LF &
" " & ediv &
" <div id='pkgdesc'>" & LAT.LF &
" <div id='pdtitle'>Subpackage Descriptions" & ediv &
" <table id='pdt2'>" & LAT.LF &
" <tbody>" & LAT.LF &
"@DESCBODY@" &
" </tbody>" & LAT.LF &
" </table>" & LAT.LF &
" " & ediv &
" <div id='options'>" & LAT.LF &
" <div id='optiontitle'>" &
"Configuration Switches (platform-specific settings discarded)" & ediv &
" <div id='optionblock'>@OPTIONBLOCK@" & ediv &
" " & ediv &
" <div id='dependencies'>" & LAT.LF &
" <div id='deptitle'>Package Dependencies by Type" & ediv &
" <table id='dpt3'>" & LAT.LF &
" <tbody>" & LAT.LF &
"@DEPBODY@" &
" </tbody>" & LAT.LF &
" </table>" & LAT.LF &
" " & ediv &
" <div id='master_sites'>" & LAT.LF &
" <div id='mstitle'>Download groups" & ediv &
" <table id='dlt4'>" & LAT.LF &
" <tbody>" & LAT.LF &
"@SITES@" &
" </tbody>" & LAT.LF &
" </table>" & LAT.LF &
" " & ediv &
" <div id='distinfo'>" & LAT.LF &
" <div id='disttitle'>Distribution File Information" & ediv &
" <div id='distblock'>@DISTINFO@" & ediv &
" " & ediv &
" <div id='upstream'>" & LAT.LF &
" <div id='ustitle'>Ports that require @NAMEBASE@:@VARIANT@" & ediv &
" <div id='upstream_inner'>" & LAT.LF &
" <table id='ust5'>" & LAT.LF &
" <tbody>" & LAT.LF &
"@UPSTREAM@" &
" </tbody>" & LAT.LF &
" </table>" & LAT.LF &
" " & ediv &
" </div>";
begin
return HT.replace_all (S => raw, reject => LAT.Apostrophe, shiny => LAT.Quotation);
end body_template;
--------------------------------------------------------------------------------------------
-- two_cell_row_template
--------------------------------------------------------------------------------------------
function two_cell_row_template return String is
begin
return
" <tr>" & LAT.LF &
" <td>@CELL1@</td>" & LAT.LF &
" <td>@CELL2@</td>" & LAT.LF &
" </tr>" & LAT.LF;
end two_cell_row_template;
--------------------------------------------------------------------------------------------
-- link
--------------------------------------------------------------------------------------------
function link (href, link_class, value : String) return String is
begin
return "<a" & nvpair ("href", href) & nvpair ("class", link_class) & ">" & value & "</a>";
end link;
--------------------------------------------------------------------------------------------
-- format_homepage
--------------------------------------------------------------------------------------------
function format_homepage (homepage : String) return String is
begin
if homepage = homepage_none then
return "No known homepage";
end if;
return link (homepage, "hplink", homepage);
end format_homepage;
--------------------------------------------------------------------------------------------
-- list_scheme
--------------------------------------------------------------------------------------------
function list_scheme (licenses, scheme : String) return String
is
stripped : constant String := HT.replace_all (licenses, LAT.Quotation, ' ');
begin
if HT.IsBlank (licenses) then
return "Not yet specified";
end if;
if scheme = "single" then
return stripped;
end if;
return stripped & LAT.Space & LAT.Left_Parenthesis & scheme & LAT.Right_Parenthesis;
end list_scheme;
--------------------------------------------------------------------------------------------
-- other_variants
--------------------------------------------------------------------------------------------
function other_variants (specs : Portspecs; variant : String) return String
is
nvar : Natural := specs.get_number_of_variants;
counter : Natural := 0;
result : HT.Text;
begin
if nvar = 1 then
return "There are no other variants.";
end if;
for x in 1 .. nvar loop
declare
nextvar : constant String := specs.get_list_item (sp_variants, x);
begin
if nextvar /= variant then
counter := counter + 1;
if counter > 1 then
HT.SU.Append (result, " | ");
end if;
HT.SU.Append (result, link ("../" & nextvar & "/", "ovlink", nextvar));
end if;
end;
end loop;
return HT.USS (result);
end other_variants;
--------------------------------------------------------------------------------------------
-- subpackage_description_block
--------------------------------------------------------------------------------------------
function subpackage_description_block
(specs : Portspecs;
namebase : String;
variant : String;
portdir : String) return String
is
function description (variant, subpackage : String) return String;
num_pkgs : Natural := specs.get_subpackage_length (variant);
result : HT.Text;
id2 : constant String := namebase & LAT.Hyphen & variant;
function description (variant, subpackage : String) return String
is
trunk : constant String := portdir & "/descriptions/desc.";
desc1 : constant String := trunk & subpackage & "." & variant;
desc2 : constant String := trunk & subpackage;
begin
if DIR.Exists (desc1) then
return FOP.get_file_contents (desc1);
elsif DIR.Exists (desc2) then
return FOP.get_file_contents (desc2);
end if;
if subpackage = "docs" then
return "This is the documents subpackage of the " & id2 & " port.";
elsif subpackage = "examples" then
return "This is the examples subpackage of the " & id2 & " port.";
elsif subpackage = "complete" then
return
"This is the " & id2 & " metapackage." & LAT.LF &
"It pulls in all subpackages of " & id2 & ".";
else
return "Subpackage description undefined (port maintainer error).";
end if;
end description;
begin
for x in 1 .. num_pkgs loop
declare
row : HT.Text := HT.SUS (two_cell_row_template);
spkg : constant String := specs.get_subpackage_item (variant, x);
begin
-- Don't escape CELL2, it's preformatted
row := HT.replace_substring (row, "@CELL1@", spkg);
row := HT.replace_substring (row, "@CELL2@", description (variant, spkg));
HT.SU.Append (result, row);
end;
end loop;
return HT.USS (result);
end subpackage_description_block;
--------------------------------------------------------------------------------------------
-- dependency_block
--------------------------------------------------------------------------------------------
function dependency_block (specs : Portspecs) return String
is
function link_block (field : spec_field) return String;
procedure add_row (field : spec_field; listlen : Natural);
result : HT.Text;
nb : constant Natural := specs.get_list_length (sp_build_deps);
nbr : constant Natural := specs.get_list_length (sp_buildrun_deps);
nr : constant Natural := specs.get_list_length (sp_run_deps);
xr : constant Natural := Natural (specs.extra_rundeps.Length);
sb : constant Natural := Natural (specs.opsys_b_deps.Length);
sbr : constant Natural := Natural (specs.opsys_br_deps.Length);
sr : constant Natural := Natural (specs.opsys_r_deps.Length);
procedure add_row (field : spec_field; listlen : Natural) is
begin
if listlen > 0 then
declare
row : HT.Text := HT.SUS (two_cell_row_template);
begin
if field = sp_build_deps then
row := HT.replace_substring (row, "@CELL1@", "Build (only)");
elsif field = sp_buildrun_deps then
row := HT.replace_substring (row, "@CELL1@", "Build and Runtime");
else
row := HT.replace_substring (row, "@CELL1@", "Runtime (only)");
end if;
row := HT.replace_substring (row, "@CELL2@", link_block (field));
HT.SU.Append (result, row);
end;
end if;
end add_row;
function link_block (field : spec_field) return String
is
procedure spkg_scan (position : list_crate.Cursor);
procedure opsys_scan (position : list_crate.Cursor);
procedure dump_dep (position : string_crate.Cursor);
procedure process_opsys_dep (position : string_crate.Cursor);
procedure dump_opsys_dep (position : def_crate.Cursor);
listlen : constant Natural := specs.get_list_length (field);
cell : HT.Text;
spkg : HT.Text;
ostr : HT.Text;
tempstore : def_crate.Map;
procedure spkg_scan (position : list_crate.Cursor)
is
rec : group_list renames list_crate.Element (position);
begin
spkg := rec.group;
rec.list.Iterate (dump_dep'Access);
end spkg_scan;
procedure opsys_scan (position : list_crate.Cursor)
is
rec : group_list renames list_crate.Element (position);
begin
ostr := rec.group;
rec.list.Iterate (process_opsys_dep'Access);
end opsys_scan;
procedure dump_dep (position : string_crate.Cursor)
is
dep : String := HT.USS (string_crate.Element (position));
namebase : String := HT.specific_field (dep, 1, ":");
bucket : String := UTL.bucket (namebase);
variant : String := HT.specific_field (dep, 3, ":");
href : String := "../../../bucket_" & bucket & "/" & namebase & "/" & variant;
value : String := dep & " (" & HT.USS (spkg) & " subpackage)";
lnk : String := link (href, "deplink", value);
begin
if HT.IsBlank (cell) then
HT.SU.Append (cell, LAT.LF & lnk);
else
HT.SU.Append (cell, "<br/>" & LAT.LF & lnk);
end if;
end dump_dep;
procedure dump_opsys_dep (position : def_crate.Cursor)
is
dep : String := HT.USS (def_crate.Key (position));
namebase : String := HT.specific_field (dep, 1, ":");
bucket : String := UTL.bucket (namebase);
variant : String := HT.specific_field (dep, 3, ":");
href : String := "../../../bucket_" & bucket & "/" & namebase & "/" & variant;
value : String := dep & " (" & HT.USS (def_crate.Element (position)) & ")";
lnk : String := link (href, "deplink", value);
begin
if HT.IsBlank (cell) then
HT.SU.Append (cell, LAT.LF & lnk);
else
HT.SU.Append (cell, "<br/>" & LAT.LF & lnk);
end if;
end dump_opsys_dep;
procedure process_opsys_dep (position : string_crate.Cursor)
is
new_index : HT.Text renames string_crate.Element (position);
new_value : HT.Text;
begin
if tempstore.Contains (new_index) then
new_value := tempstore.Element (new_index);
HT.SU.Append (new_value, ", " & HT.USS (ostr));
tempstore.Delete (new_index);
tempstore.Insert (new_index, new_value);
else
tempstore.Insert (new_index, ostr);
end if;
end process_opsys_dep;
begin
for x in 1 .. listlen loop
declare
dep : String := specs.get_list_item (field, x);
namebase : String := HT.specific_field (dep, 1, ":");
bucket : String := UTL.bucket (namebase);
variant : String := HT.specific_field (dep, 3, ":");
href : String := "../../../bucket_" & bucket & "/" & namebase & "/" & variant;
lnk : String := link (href, "deplink", dep);
begin
if x = 1 then
HT.SU.Append (cell, LAT.LF & lnk);
else
HT.SU.Append (cell, "<br/>" & LAT.LF & lnk);
end if;
end;
end loop;
if field = sp_build_deps then
specs.opsys_b_deps.Iterate (opsys_scan'Access);
end if;
if field = sp_buildrun_deps then
specs.opsys_br_deps.Iterate (opsys_scan'Access);
end if;
if field = sp_run_deps then
specs.opsys_r_deps.Iterate (opsys_scan'Access);
specs.extra_rundeps.Iterate (spkg_scan'Access);
end if;
tempstore.Iterate (dump_opsys_dep'Access);
return HT.USS (cell);
end link_block;
begin
if nb + nr + nbr + xr = 0 then
return " <tr><td>This package has no dependency requirements of any kind.</td></tr>";
end if;
add_row (sp_build_deps, nb + sb);
add_row (sp_buildrun_deps, nbr + sbr);
add_row (sp_run_deps, nr + sr + xr);
return HT.USS (result);
end dependency_block;
--------------------------------------------------------------------------------------------
-- retrieve_distinfo
--------------------------------------------------------------------------------------------
function retrieve_distinfo (specs : Portspecs; portdir : String) return String
is
distinfo : String := portdir & "/distinfo";
begin
if DIR.Exists (distinfo) then
return FOP.get_file_contents (distinfo);
else
return "This port does not contain distinfo information.";
end if;
end retrieve_distinfo;
--------------------------------------------------------------------------------------------
-- master_sites_block
--------------------------------------------------------------------------------------------
function master_sites_block (specs : Portspecs) return String
is
procedure group_scan (position : list_crate.Cursor);
procedure dump_sites (position : string_crate.Cursor);
function make_link (site : String) return String;
num_groups : constant Natural := Natural (specs.dl_sites.Length);
first_group : constant String := HT.USS (list_crate.Element (specs.dl_sites.First).group);
cell2 : HT.Text;
result : HT.Text;
function make_link (site : String) return String
is
lnk : constant String := link (site, "sitelink", site);
begin
if HT.contains (site, "://") then
return lnk;
else
return "mirror://" & site;
end if;
end make_link;
procedure dump_sites (position : string_crate.Cursor)
is
site_string : HT.Text renames string_crate.Element (position);
lnk : constant String := make_link (HT.USS (site_string));
begin
if HT.IsBlank (cell2) then
HT.SU.Append (cell2, LAT.LF & lnk);
else
HT.SU.Append (cell2, "<br/>" & LAT.LF & lnk);
end if;
end dump_sites;
procedure group_scan (position : list_crate.Cursor)
is
rec : group_list renames list_crate.Element (position);
cell1 : constant String := HT.USS (rec.group);
row : HT.Text := HT.SUS (two_cell_row_template);
begin
cell2 := HT.SU.Null_Unbounded_String;
rec.list.Iterate (dump_sites'Access);
row := HT.replace_substring (row, "@CELL1@", cell1);
row := HT.replace_substring (row, "@CELL2@", HT.USS (cell2));
HT.SU.Append (result, row);
end group_scan;
begin
if num_groups = 1 and then
first_group = dlgroup_none
then
return " <tr><td>This port does not download anything.</td></tr>";
end if;
specs.dl_sites.Iterate (group_scan'Access);
return HT.USS (result);
end master_sites_block;
--------------------------------------------------------------------------------------------
-- deprecated_message
--------------------------------------------------------------------------------------------
function deprecated_message (specs : Portspecs) return String
is
row1 : HT.Text := HT.SUS (two_cell_row_template);
row2 : HT.Text := HT.SUS (two_cell_row_template);
begin
if HT.IsBlank (specs.deprecated) then
return "";
end if;
row1 := HT.replace_substring (row1, "@CELL1@", "DEPRECATED");
row1 := HT.replace_substring (row1, "@CELL2@", HT.USS (specs.deprecated));
row2 := HT.replace_substring (row2, "@CELL1@", "Expiration Date");
row2 := HT.replace_substring (row2, "@CELL2@", HT.USS (specs.expire_date));
return HT.USS (row1) & HT.USS (row2);
end deprecated_message;
--------------------------------------------------------------------------------------------
-- broken_attributes
--------------------------------------------------------------------------------------------
function broken_attributes (specs : Portspecs) return String
is
procedure group_scan (position : list_crate.Cursor);
procedure dump_messages (position : string_crate.Cursor);
row1 : HT.Text := HT.SUS (two_cell_row_template);
content : HT.Text;
index : HT.Text;
procedure group_scan (position : list_crate.Cursor)
is
rec : group_list renames list_crate.Element (position);
begin
index := rec.group;
rec.list.Iterate (dump_messages'Access);
end group_scan;
procedure dump_messages (position : string_crate.Cursor)
is
message : HT.Text renames string_crate.Element (position);
esc_msg : String := "[" & HT.USS (index) & "] " & escape_value (HT.USS (message));
begin
if HT.IsBlank (content) then
HT.SU.Append (content, LAT.LF & esc_msg);
else
HT.SU.Append (content, "<br/>" & LAT.LF & esc_msg);
end if;
end dump_messages;
begin
if specs.broken.Is_Empty then
return "";
end if;
specs.broken.Iterate (group_scan'Access);
row1 := HT.replace_substring (row1, "@CELL1@", "BROKEN");
row1 := HT.replace_substring (row1, "@CELL2@", HT.USS (content));
return HT.USS (row1);
end broken_attributes;
--------------------------------------------------------------------------------------------
-- inclusive_platform
--------------------------------------------------------------------------------------------
function inclusive_platform (specs : Portspecs) return String
is
procedure dump (position : string_crate.Cursor);
row1 : HT.Text := HT.SUS (two_cell_row_template);
content : HT.Text;
procedure dump (position : string_crate.Cursor)
is
message : HT.Text renames string_crate.Element (position);
begin
if HT.IsBlank (content) then
HT.SU.Append (content, message);
else
HT.SU.Append (content, " | " & HT.USS (message));
end if;
end dump;
begin
if specs.inc_opsys.Is_Empty then
return "";
end if;
specs.inc_opsys.Iterate (dump'Access);
row1 := HT.replace_substring (row1, "@CELL1@", "Only for platform");
row1 := HT.replace_substring (row1, "@CELL2@", HT.USS (content));
return HT.USS (row1);
end inclusive_platform;
--------------------------------------------------------------------------------------------
-- exclusive_platform
--------------------------------------------------------------------------------------------
function exclusive_platform (specs : Portspecs) return String
is
procedure dump (position : string_crate.Cursor);
row1 : HT.Text := HT.SUS (two_cell_row_template);
content : HT.Text;
procedure dump (position : string_crate.Cursor)
is
message : HT.Text renames string_crate.Element (position);
begin
if HT.IsBlank (content) then
HT.SU.Append (content, message);
else
HT.SU.Append (content, " | " & HT.USS (message));
end if;
end dump;
begin
if specs.exc_opsys.Is_Empty then
return "";
end if;
specs.exc_opsys.Iterate (dump'Access);
row1 := HT.replace_substring (row1, "@CELL1@", "Exclude platform");
row1 := HT.replace_substring (row1, "@CELL2@", HT.USS (content));
return HT.USS (row1);
end exclusive_platform;
--------------------------------------------------------------------------------------------
-- exclusive_arch
--------------------------------------------------------------------------------------------
function exclusive_arch (specs : Portspecs) return String
is
procedure dump (position : string_crate.Cursor);
row1 : HT.Text := HT.SUS (two_cell_row_template);
content : HT.Text;
procedure dump (position : string_crate.Cursor)
is
message : HT.Text renames string_crate.Element (position);
begin
if HT.IsBlank (content) then
HT.SU.Append (content, message);
else
HT.SU.Append (content, " | " & HT.USS (message));
end if;
end dump;
begin
if specs.exc_arch.Is_Empty then
return "";
end if;
specs.exc_arch.Iterate (dump'Access);
row1 := HT.replace_substring (row1, "@CELL1@", "Exclude architecture");
row1 := HT.replace_substring (row1, "@CELL2@", HT.USS (content));
return HT.USS (row1);
end exclusive_arch;
--------------------------------------------------------------------------------------------
-- upstream
--------------------------------------------------------------------------------------------
function upstream (blocked : String) return String
is
markers : HT.Line_Markers;
result : HT.Text;
begin
if HT.IsBlank (blocked) then
return "<tr><td>No other ports depend on this one.</td></tr>" & LAT.LF;
end if;
HT.initialize_markers (blocked, markers);
loop
exit when not HT.next_line_present (blocked, markers);
declare
line : constant String := HT.extract_line (blocked, markers);
cell : constant String := HT.specific_field (line, 1, ";");
href : constant String := HT.specific_field (line, 2, ";");
lnk : constant String := link (href, "upslink", cell);
row1 : HT.Text := HT.SUS (two_cell_row_template);
begin
row1 := HT.replace_substring (row1, "@CELL1@", lnk);
row1 := HT.replace_substring (row1, "@CELL2@", HT.specific_field (line, 3, ";"));
HT.SU.Append (result, row1);
end;
end loop;
return HT.USS (result);
exception
when issue : others =>
return "<tr><td>" & Ada.Exceptions.Exception_Message (issue) & "</td></tr>" & LAT.LF &
"<tr><td>" & blocked & "</td></tr>" & LAT.LF;
end upstream;
--------------------------------------------------------------------------------------------
-- generate_body
--------------------------------------------------------------------------------------------
function generate_body
(specs : Portspecs;
variant : String;
portdir : String;
blocked : String;
created : CAL.Time;
changed : CAL.Time;
devscan : Boolean) return String
is
result : HT.Text := HT.SUS (body_template);
namebase : constant String := specs.get_namebase;
bucket : constant String := UTL.bucket (namebase);
catport : constant String := "bucket_" & bucket & "/" & namebase;
subject : constant String := "Ravenports:%20" & specs.get_namebase & "%20port";
homepage : constant String := format_homepage (specs.get_field_value (sp_homepage));
tagline : constant String := escape_value (specs.get_tagline (variant));
isocdate : constant String := LOG.timestamp (created, True);
isomdate : constant String := LOG.timestamp (changed, True);
licenses : constant String := list_scheme (specs.get_field_value (sp_licenses),
specs.get_license_scheme);
lnk_bs : constant String :=
link ("https://raw.githubusercontent.com/jrmarino/Ravenports/master/" & catport,
"ghlink", "Buildsheet");
lnk_bshy : constant String :=
link ("https://github.com/jrmarino/Ravenports/commits/master/" & catport,
"histlink", "History");
lnk_port : constant String :=
link ("https://github.com/jrmarino/ravensource/tree/master/" & catport,
"ghlink", "Port Directory");
lnk_pthy : constant String :=
link ("https://github.com/jrmarino/ravensource/commits/master/" & catport,
"histlink", "History");
begin
result := HT.replace_substring (result, "@NAMEBASE@", namebase);
result := HT.replace_substring (result, "@NAMEBASE@", namebase);
result := HT.replace_substring (result, "@VARIANT@", variant);
result := HT.replace_substring (result, "@VARIANT@", variant);
result := HT.replace_substring (result, "@HOMEPAGE@", homepage);
result := HT.replace_substring (result, "@TAGLINE@", tagline);
result := HT.replace_substring (result, "@PKGVERSION@", specs.calculate_pkgversion);
result := HT.replace_substring (result, "@MAINTAINER@", specs.get_web_contacts (subject));
result := HT.replace_substring (result, "@KEYWORDS@", specs.get_field_value (sp_keywords));
result := HT.replace_substring (result, "@LICENSE@", licenses);
result := HT.replace_substring (result, "@CDATETIME@", isocdate);
result := HT.replace_substring (result, "@MDATETIME@", isomdate);
result := HT.replace_substring (result, "@LNK_BUILDSHEET@", lnk_bs);
result := HT.replace_substring (result, "@LNK_HISTORY_BS@", lnk_bshy);
result := HT.replace_substring (result, "@LNK_PORT@", lnk_port);
result := HT.replace_substring (result, "@LNK_HISTORY_PORT@", lnk_pthy);
result := HT.replace_substring (result, "@OTHERVAR@", other_variants (specs, variant));
result := HT.replace_substring (result, "@OPTIONBLOCK@", specs.options_summary (variant));
result := HT.replace_substring (result, "@DISTINFO@", retrieve_distinfo (specs, portdir));
result := HT.replace_substring (result, "@DEPBODY@", dependency_block (specs));
result := HT.replace_substring (result, "@SITES@", master_sites_block (specs));
result := HT.replace_substring (result, "@DEPRECATED@", deprecated_message (specs));
result := HT.replace_substring (result, "@BROKEN@", broken_attributes (specs));
result := HT.replace_substring (result, "@ONLY_PLATFORM@", inclusive_platform (specs));
result := HT.replace_substring (result, "@EXC_PLATFORM@", exclusive_platform (specs));
result := HT.replace_substring (result, "@EXC_ARCH@", exclusive_arch (specs));
result := HT.replace_substring (result, "@UPSTREAM@", upstream (blocked));
result := HT.replace_substring
(result, "@DESCBODY@", subpackage_description_block (specs, namebase, variant, portdir));
return HT.USS (result);
end generate_body;
--------------------------------------------------------------------------------------------
-- generate_catalog_index
--------------------------------------------------------------------------------------------
function generate_catalog_index
(dossier : TIO.File_Type;
row_assembly_block : String) return Boolean is
begin
declare
template_file : String := host_localbase & "/share/ravenadm/catalog.template";
template : constant String := FOP.get_file_contents (template_file);
fullpage : HT.Text := HT.SUS (template);
begin
fullpage := HT.replace_substring (fullpage, "@ROW_ASSY@", row_assembly_block);
TIO.Put_Line (dossier, HT.USS (fullpage));
return True;
end;
exception
when others =>
TIO.Put_Line ("Failed to create the web site index");
return False;
end generate_catalog_index;
end Port_Specification.Web;
|
reznikmm/matreshka | Ada | 3,419 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2017, 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 WUI.Slots.Strings;
package WUI.String_Slots renames WUI.Slots.Strings;
|
AdaCore/libadalang | Ada | 2,789 | ads | with Highlighter;
package Colors is
type Color_Level is mod 2 ** 8;
type Color_Type is record
Red, Green, Blue : Color_Level;
end record;
type Token_Style is record
Color : Color_Type;
Bold : Boolean;
end record;
-- Graphical attributes for an highlighting type
type Token_Styles is array (Highlighter.Highlight_Type) of Token_Style;
type Style_Type is record
Background_Color : Color_Type;
Selected_Bg_Color : Color_Type;
Tok_Styles : Token_Styles;
end record;
-- Set of graphical attributes for syntax highlighting
package Default_Style is
use Highlighter;
Bg_Color : constant Color_Type := (8, 8, 8);
Selected_Bg_Color : constant Color_Type := (36, 36, 36);
Text_Color : constant Color_Type := (248, 248, 242);
Comment_Color : constant Color_Type := (117, 113, 105);
Keyword_Color : constant Color_Type := (255, 95, 135);
Keyword_Special_Color : constant Color_Type := (224, 128, 32);
Preprocessor_Color : constant Color_Type := (215, 255, 215);
Number_Color : constant Color_Type := (175, 95, 255);
String_Color : constant Color_Type := (230, 219, 116);
Label_Color : constant Color_Type := (255, 250, 15);
Block_Color : constant Color_Type := (138, 226, 52);
Type_Color : constant Color_Type := (102, 217, 239);
Attribute_Ref_Color : constant Color_Type := (232, 70, 109);
Style : constant Style_Type :=
(Background_Color => Bg_Color,
Selected_Bg_Color => Selected_Bg_Color,
Tok_Styles =>
(Text => (Text_Color, False),
Comment => (Comment_Color, False),
Keyword => (Keyword_Color, True),
Keyword_Type => (Type_Color, False),
Keyword_Special => (Keyword_Special_Color, False),
Punctuation => (Text_Color, False),
Punctuation_Special => (Type_Color, False),
Operator => (Keyword_Color, False),
Preprocessor_Directive => (Preprocessor_Color, False),
Integer_Literal => (Number_Color, False),
String_Literal => (String_Color, False),
Character_Literal => (String_Color, False),
Identifier => (Text_Color, False),
Label_Name => (Label_Color, False),
Block_Name => (Block_Color, False),
Type_Name => (Type_Color, False),
Attribute_Name => (Attribute_Ref_Color, False)));
end Default_Style;
end Colors;
|
hayasam/lightweight-effectiveness | Ada | 1,277 | adb | --
-- CDDL HEADER START
--
-- The contents of this file are subject to the terms of the
-- Common Development and Distribution License (the "License").
-- You may not use this file except in compliance with the License.
--
-- See LICENSE.txt included in this distribution for the specific
-- language governing permissions and limitations under the License.
--
-- When distributing Covered Code, include this CDDL HEADER in each
-- file and include the License file at LICENSE.txt.
-- If applicable, add the following below this CDDL HEADER, with the
-- fields enclosed by brackets "[]" replaced with your own identifying
-- information: Portions Copyright [yyyy] [name of copyright owner]
--
-- CDDL HEADER END
--
--
-- Copyright (c) 2017, Chris Fraire <[email protected]>.
--
with Ada.Text_IO; use Ada.Text_IO;
procedure Hello is
begin
Put_Line("Hello, world!");
Put_Line("""
Hello?""");
Put_Line('?');
Put_Line('
');
Put(0);
Put(12);
Put(123_456);
Put(3.14159_26);
Put(2#1111_1111#);
Put(16#E#E1);
Put(16#F.FF#E+2);
Put_Line();
Put_Line("Archimedes said ""Εύρηκα""");
end Hello;
-- Test a URL that is not matched fully by a rule using just {URIChar} and
-- {FnameChar}:
-- https://msdn.microsoft.com/en-us/library/windows/desktop/ms633591(v=vs.85).aspx
|
reznikmm/matreshka | Ada | 3,834 | 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_List_Level_Position_And_Space_Mode_Attributes is
pragma Preelaborate;
type ODF_Text_List_Level_Position_And_Space_Mode_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_List_Level_Position_And_Space_Mode_Attribute_Access is
access all ODF_Text_List_Level_Position_And_Space_Mode_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_List_Level_Position_And_Space_Mode_Attributes;
|
AdaCore/gpr | Ada | 16 | ads | procedure Repl;
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.