repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
reznikmm/matreshka | Ada | 4,557 | 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_Fo.Margin_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Fo_Margin_Attribute_Node is
begin
return Self : Fo_Margin_Attribute_Node do
Matreshka.ODF_Fo.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Fo_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Fo_Margin_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Margin_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Fo_URI,
Matreshka.ODF_String_Constants.Margin_Attribute,
Fo_Margin_Attribute_Node'Tag);
end Matreshka.ODF_Fo.Margin_Attributes;
|
VitalijBondarenko/Formatted_Output_NG | Ada | 3,923 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (c) 2016-2022 Vitalii Bondarenko <[email protected]> --
-- --
------------------------------------------------------------------------------
-- --
-- The MIT License (MIT) --
-- --
-- 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, 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 AUTHORS OR 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. --
------------------------------------------------------------------------------
generic
type Item_Type is range <>;
package Formatted_Output.Integer_Output is
function "&" (Fmt : Format_Type; Value : Item_Type'Base) return Format_Type;
-- Replaces leftmost formatting sequence in Fmt with formatted Value image,
-- then returns Fmt. Raises exception Format_Error when invalid formatting
-- sequence is found or no formatting sequence found at all.
--
-- Format sequences for integer types:
--
-- %[flags][<width>](d|x|X|o|b)
--
-- Flag characters can be:
-- - The converted value is to be left adjusted on the field boundary.
-- (The default is right justification.)
-- * The converted value is to be center adjusted on the field boundary.
-- (The default is right justification.)
-- + A sign (+ or -) should always be placed before a number produced by a
-- signed conversion. By default, a sign is used only for negative numbers.
-- # Used with o, x or X specifiers the value is use with Base in C style.
-- ~ As above, but using Ada style based <base>#<number>#
-- 0 The value should be zero padded.
-- _ The output is to be grouped with grouping character '_'.
-- Group size is 3 for Base = 10 and 4 for other.
-- ' For decimal conversion (d) the output is to be grouped with thousands'
-- grouping characters if the locale information indicates any.
--
-- <width> is decimal number specifying minimum field width.
--
-- Format specifier can be:
-- d Convert as decimal.
-- x Convert as hexadecimal (lowercase).
-- X Convert as hexadecimal (uppercase).
-- o Convert as octal.
-- b Convert as binary.
end Formatted_Output.Integer_Output;
|
HackInvent/Ada_Drivers_Library | Ada | 2,794 | adb | pragma Warnings (Off);
pragma Ada_95;
pragma Source_File_Name (ada_main, Spec_File_Name => "b__blink.ads");
pragma Source_File_Name (ada_main, Body_File_Name => "b__blink.adb");
pragma Suppress (Overflow_Check);
package body ada_main is
E49 : Short_Integer; pragma Import (Ada, E49, "system__bb__timing_events_E");
E05 : Short_Integer; pragma Import (Ada, E05, "ada__real_time_E");
E79 : Short_Integer; pragma Import (Ada, E79, "stm32__exti_E");
E75 : Short_Integer; pragma Import (Ada, E75, "stm32__rcc_E");
E88 : Short_Integer; pragma Import (Ada, E88, "stm32__spi_E");
E73 : Short_Integer; pragma Import (Ada, E73, "stm32__gpio_E");
E69 : Short_Integer; pragma Import (Ada, E69, "stm32__device_E");
E77 : Short_Integer; pragma Import (Ada, E77, "stm32__syscfg_E");
Sec_Default_Sized_Stacks : array (1 .. 1) of aliased System.Secondary_Stack.SS_Stack (System.Parameters.Runtime_Default_Sec_Stack_Size);
procedure adainit is
Binder_Sec_Stacks_Count : Natural;
pragma Import (Ada, Binder_Sec_Stacks_Count, "__gnat_binder_ss_count");
Default_Secondary_Stack_Size : System.Parameters.Size_Type;
pragma Import (C, Default_Secondary_Stack_Size, "__gnat_default_ss_size");
Default_Sized_SS_Pool : System.Address;
pragma Import (Ada, Default_Sized_SS_Pool, "__gnat_default_ss_pool");
begin
null;
ada_main'Elab_Body;
Default_Secondary_Stack_Size := System.Parameters.Runtime_Default_Sec_Stack_Size;
Binder_Sec_Stacks_Count := 1;
Default_Sized_SS_Pool := Sec_Default_Sized_Stacks'Address;
System.Bb.Timing_Events'Elab_Body;
E49 := E49 + 1;
Ada.Real_Time'Elab_Body;
E05 := E05 + 1;
E79 := E79 + 1;
E75 := E75 + 1;
STM32.SPI'ELAB_BODY;
E88 := E88 + 1;
STM32.DEVICE'ELAB_SPEC;
E69 := E69 + 1;
STM32.GPIO'ELAB_BODY;
E73 := E73 + 1;
E77 := E77 + 1;
end adainit;
procedure Ada_Main_Program;
pragma Import (Ada, Ada_Main_Program, "_ada_blink");
procedure main is
Ensure_Reference : aliased System.Address := Ada_Main_Program_Name'Address;
pragma Volatile (Ensure_Reference);
begin
adainit;
Ada_Main_Program;
end;
-- BEGIN Object file/option list
-- /home/badr/hackinvent/Ada_Drivers_Library/examples/STM32H743_Nucleo/blink.o
-- -L/home/badr/hackinvent/Ada_Drivers_Library/examples/STM32H743_Nucleo/
-- -L/home/badr/hackinvent/Ada_Drivers_Library/examples/STM32H743_Nucleo/
-- -L/home/badr/hackinvent/Ada_Drivers_Library/boards/stm32h743_nucleo/obj/sfp_lib_Debug/
-- -L/home/badr/GNAT/2018-arm-elf/arm-eabi/lib/gnat/ravenscar-sfp-stm32h743nucleo/adalib/
-- -static
-- -lgnarl
-- -lgnat
-- END Object file/option list
end ada_main;
|
AdaCore/gpr | Ada | 39 | adb | with a;procedure m is begin null;end m; |
reznikmm/matreshka | Ada | 3,593 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- 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 System.Address_Image;
with Ada.Strings.Hash;
function XML.DOM.Nodes.Hash
(Node : XML.DOM.Nodes.DOM_Node) return Ada.Containers.Hash_Type is
begin
return Ada.Strings.Hash (System.Address_Image (Node.Node.all'Address));
end XML.DOM.Nodes.Hash;
|
jhumphry/auto_counters | Ada | 2,242 | ads | -- protected_counters.ads
-- Task safe counters for use with smart_ptrs
-- Copyright (c) 2016, 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);
with Counters_Spec;
package Protected_Counters is
protected type Counter is
entry Lock;
procedure Unlock;
procedure Initialize_New_Counter;
function Use_Count return Natural;
entry Check_Increment_Use_Count;
entry Decrement_Use_Count;
function Weak_Ptr_Count return Natural;
entry Increment_Weak_Ptr_Count;
entry Decrement_Weak_Ptr_Count;
private
Locked : Boolean := True;
SP_Count : Natural := 1;
WP_Count : Natural := 0;
end Counter;
type Counter_Ptr is access Counter;
function Make_New_Counter return Counter_Ptr;
procedure Deallocate_If_Unused (C : in out Counter_Ptr) with Inline;
function Use_Count (C : in Counter) return Natural is
(C.Use_Count) with Inline;
procedure Check_Increment_Use_Count (C : in out Counter) with Inline;
procedure Decrement_Use_Count (C : in out Counter) with Inline;
function Weak_Ptr_Count (C : in Counter) return Natural is
(C.Weak_Ptr_Count) with Inline;
procedure Increment_Weak_Ptr_Count (C : in out Counter) with Inline;
procedure Decrement_Weak_Ptr_Count (C : in out Counter) with Inline;
package Protected_Counters_Spec is new Counters_Spec(Counter => Counter,
Counter_Ptr => Counter_Ptr);
end Protected_Counters;
|
micahwelf/FLTK-Ada | Ada | 2,864 | adb |
with
Interfaces.C,
System;
use type
System.Address;
package body FLTK.Widgets.Boxes is
procedure box_set_draw_hook
(W, D : in System.Address);
pragma Import (C, box_set_draw_hook, "box_set_draw_hook");
pragma Inline (box_set_draw_hook);
procedure box_set_handle_hook
(W, H : in System.Address);
pragma Import (C, box_set_handle_hook, "box_set_handle_hook");
pragma Inline (box_set_handle_hook);
function new_fl_box
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_box, "new_fl_box");
pragma Inline (new_fl_box);
procedure free_fl_box
(B : in System.Address);
pragma Import (C, free_fl_box, "free_fl_box");
pragma Inline (free_fl_box);
procedure fl_box_draw
(W : in System.Address);
pragma Import (C, fl_box_draw, "fl_box_draw");
pragma Inline (fl_box_draw);
function fl_box_handle
(W : in System.Address;
E : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_box_handle, "fl_box_handle");
pragma Inline (fl_box_handle);
procedure Finalize
(This : in out Box) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in Box'Class
then
if This.Needs_Dealloc then
free_fl_box (This.Void_Ptr);
end if;
This.Void_Ptr := System.Null_Address;
end if;
Finalize (Widget (This));
end Finalize;
package body Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Box is
begin
return This : Box do
This.Void_Ptr := new_fl_box
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
box_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
box_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
end return;
end Create;
end Forge;
procedure Draw
(This : in out Box) is
begin
fl_box_draw (This.Void_Ptr);
end Draw;
function Handle
(This : in out Box;
Event : in Event_Kind)
return Event_Outcome is
begin
return Event_Outcome'Val
(fl_box_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
end Handle;
end FLTK.Widgets.Boxes;
|
persan/protobuf-ada | Ada | 47 | ads | package Jspb.Exttest is
end Jspb.Exttest; |
zhmu/ananas | Ada | 13,575 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G E N _ I L . G E N --
-- --
-- S p e c --
-- --
-- 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. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- "Language design is library design and library design is language design".
-- -- Bjarne Stroustrup
-- This package provides a "little language" for defining type hierarchies,
-- which we call "Gen_IL.Gen". In particular, it is used to describe the type
-- hierarchies rooted at Node_Id and Entity_Id in the intermediate language
-- used by GNAT.
-- The type hierarchy is a strict hierarchy (treeish, no multiple
-- inheritance). We have "abstract" and "concrete" types. Each type has a
-- "parent", except for the root type (Node_Id or Entity_Id). All leaf types
-- in the hierarchy are concrete; all nonleaf types (including the two root
-- types) are abstract. One can create instances of concrete, but not
-- abstract, types.
--
-- Descendants of Node_Id/Node_Kind are node types, and descendants of
-- Entity_Id/Entity_Kind are entity types.
--
-- Types have "fields". Each type inherits all the fields from its parent, and
-- may add new ones. A node field can be marked "syntactic"; entity fields are
-- never syntactic. A nonsyntactic field is "semantic".
--
-- If a field is syntactic, then the constructors in Nmake take a parameter to
-- initialize that field. In addition, the tree-traversal routines in Atree
-- (Traverse_Func and Traverse_Proc) traverse syntactic fields that are of
-- type Node_Id (or subtypes of Node_Id) or List_Id. Finally, (with some
-- exceptions documented in the body) the setter for a syntactic node or list
-- field "Set_F (N, Val)" will set the Parent of Val to N, unless Val is Empty
-- or Error[_List].
--
-- Note that the same field can be syntactic in some node types but semantic
-- in other node types. This is an added complexity that we might want to
-- eliminate someday. We shouldn't add any new such cases.
--
-- A "program" written in the Gen_IL.Gen language consists of calls to the
-- "Create_..." routines below, followed by a call to Compile, also below. In
-- order to understand what's going on, you need to look not only at the
-- Gen_IL.Gen "code", but at the output of the compiler -- at least, look at
-- the specs of Sinfo.Nodes and Einfo.Entities, because GNAT invokes those
-- directly. It's not like a normal language where you don't usually have to
-- look at the generated machine code.
--
-- Thus, the Gen_IL.Gen code is really Ada code, and when you run it as an Ada
-- program, it generates the above-mentioned files. The program is somewhat
-- unusual in that it has no input. Everything it needs to generate code is
-- embodied in it.
-- Why don't we just use a variant record, instead of inventing a wheel?
-- Or a hierarchy of tagged types?
--
-- The key feature that Ada's variant records and tagged types lack, and that
-- this little language has, is that if two types have a field with the same
-- name, then those are the same field, even though they weren't inherited
-- from a common ancestor. Such fields are required to have the same type, the
-- same default value, and the same extra precondition.
with Gen_IL.Types; use Gen_IL.Types;
pragma Warnings (Off);
with Gen_IL.Fields; use Gen_IL.Fields; -- for children
pragma Warnings (On);
with Gen_IL.Internals; use Gen_IL.Internals;
use Gen_IL.Internals.Type_Vectors;
use Gen_IL.Internals.Field_Vectors;
package Gen_IL.Gen is
procedure Create_Root_Node_Type
(T : Abstract_Node;
Fields : Field_Sequence := No_Fields)
with Pre => T = Node_Kind;
-- Create the root node type (Node_Kind), which is an abstract type
procedure Create_Abstract_Node_Type
(T : Abstract_Node; Parent : Abstract_Type;
Fields : Field_Sequence := No_Fields);
-- Create an abstract node type (other than the root node type)
procedure Create_Concrete_Node_Type
(T : Concrete_Node; Parent : Abstract_Type;
Fields : Field_Sequence := No_Fields;
Nmake_Assert : String := "");
-- Create a concrete node type. Every node is an instance of a concrete
-- node type. Nmake_Assert is an assertion to put in the Make_... function
-- in the generated Nmake package. It should be a String that represents a
-- Boolean expression.
procedure Create_Root_Entity_Type
(T : Abstract_Entity;
Fields : Field_Sequence := No_Fields)
with Pre => T = Entity_Kind;
-- Create the root entity type (Entity_Kind), which is an abstract type
procedure Create_Abstract_Entity_Type
(T : Abstract_Entity; Parent : Abstract_Type;
Fields : Field_Sequence := No_Fields);
-- Create an abstract entity type (other than the root entity type)
procedure Create_Concrete_Entity_Type
(T : Concrete_Entity; Parent : Abstract_Type;
Fields : Field_Sequence := No_Fields);
-- Create a concrete entity type. Every entity is an instance of a concrete
-- entity type.
function Create_Syntactic_Field
(Field : Node_Field;
Field_Type : Type_Enum;
Default_Value : Field_Default_Value := No_Default;
Pre, Pre_Get, Pre_Set : String := "") return Field_Desc;
-- Create a syntactic field of a node type. Entities do not have syntactic
-- fields.
function Create_Semantic_Field
(Field : Field_Enum;
Field_Type : Type_Enum;
Type_Only : Type_Only_Enum := No_Type_Only;
Pre, Pre_Get, Pre_Set : String := "") return Field_Desc;
-- Create a semantic field of a node or entity type
-- Create_Syntactic_Field is used for syntactic fields of nodes. The order
-- of calls to Create_Syntactic_Field determines the order of the formal
-- parameters of the Make_... functions in Nmake.
--
-- Create_Semantic_Field is used for semantic fields of nodes, and all
-- fields of entities are considered semantic. The order of calls doesn't
-- make any difference.
--
-- Field_Type is the type of the field. Default_Value is the default value
-- for the parameter of the Make_... function in Nmake; this is effective
-- only for syntactic fields. Flag fields of syntactic nodes always have a
-- default value, which is False unless specified as Default_True. Pre is
-- an additional precondition for the field getter and setter, in addition
-- to the precondition that asserts that the type has that field. It should
-- be a String that represents a Boolean expression. Pre_Get and Pre_Set
-- are similar to Pre, but for the getter or setter only, respectively.
--
-- If multiple calls to these occur for the same Field but different types,
-- the Field_Type, Pre, Pre_Get, and Pre_Set must match. Default_Value
-- should match for syntactic fields. See the declaration of Type_Only_Enum
-- for Type_Only.
--
-- (The matching Default_Value requirement is a simplification from the
-- earlier hand-written version.)
-- When adding new node or entity kinds, or adding new fields, all back
-- ends must be made aware of the changes. In addition, the documentation
-- in Sinfo or Einfo needs to be updated.
-- To add a new node or entity type, add it to the enumeration type in
-- Gen_IL.Types, taking care that it is in the approprate range
-- (Abstract_Node, Abstract_Entity, Concrete_Node, or Concrete_Entity).
-- Then add a call to one of the above type-creation procedures to
-- Gen_IL.Gen.Gen_Nodes or Gen_IL.Gen.Gen_Entities.
--
-- To add a new field to a type, add it to the enumeration type in
-- Gen_IL.Fields in the appropriate range. Then add a call to one of
-- the above field-creation procedures to Gen_IL.Gen.Gen_Nodes or
-- Gen_IL.Gen.Gen_Entities.
--
-- If a type or field name does not follow the usual Mixed_Case convention,
-- such as "SPARK_Pragma", then you have to add a special case to one of
-- the Image functions in Gen_IL.Internals and in Treepr.
-- Forward references are not allowed. So if you say:
--
-- Create..._Type (..., Parent => P);
--
-- then Create..._Type must have already been called to create P.
--
-- Likewise, if you say:
--
-- Create..._Field (T, F, Field_Type, ...);
--
-- then Create..._Type must have already been called to create T and
-- (if it's a node or entity type) to create Field_Type.
--
-- To delete a node or entity type, delete it from Gen_IL.Types, update the
-- subranges in Gen_IL.Internals if necessary, and delete all occurrences
-- from Gen_IL.Gen.Gen_Entities. To delete a field, delete it from
-- Gen_IL.Fields, and delete all occurrences from Gen_IL.Gen.Gen_Entities.
-- If a field is not set, it is initialized by default to whatever value is
-- represented by all-zero bits, with some exceptions. This means Flags are
-- initialized to False, Node_Ids and List_Ids are initialized to Empty,
-- and enumeration fields are initialized to 'First of the type (assuming
-- there is no representation clause).
--
-- Elists default to No_Elist.
--
-- Fields of type Uint (but not its subtypes) are initialized to No_Uint.
-- Fields of subtypes Valid_Uint, Unat, Upos, Nonzero_Uint, and Ureal have
-- no default; it is an error to call a getter before calling the setter.
-- Likewise, other types whose range does not include zero have no default
-- (see package Types for the ranges).
--
-- If a node is created by a function in Nmake, then the defaults are
-- different from what is specified above. The parameters of Make_...
-- functions can have defaults specified; see Create_Syntactic_Field.
procedure Create_Node_Union_Type
(T : Abstract_Node; Children : Type_Array);
procedure Create_Entity_Union_Type
(T : Abstract_Entity; Children : Type_Array);
-- Create a "union" type that is the union of the Children. This is used
-- for nonhierachical types. This is the opposite of the normal "object
-- oriented" routines above, which create child types based on existing
-- parents. Here we are creating parent types based on existing child
-- types. A union type is considered to be an abstract type because it has
-- multiple children. We do not allow union types to have their own fields,
-- because that would introduce the well-known complexity of multiple
-- inheritance. That restriction could be relaxed, but for now, union types
-- are mainly for allowing things like "Pre => X in Some_Union_Type".
Illegal : exception;
-- Exception raised when Gen_IL code (in particular in Gen_Nodes and
-- Gen_Entities) is illegal. We don't try elaborate error recovery, but
-- hopefully the exception message will indicate what's wrong. You might
-- have to go in the debugger to see which line it's complaining about.
procedure Compile;
private
function Sy
(Field : Node_Field;
Field_Type : Type_Enum;
Default_Value : Field_Default_Value := No_Default;
Pre, Pre_Get, Pre_Set : String := "") return Field_Sequence;
function Sm
(Field : Field_Enum;
Field_Type : Type_Enum;
Type_Only : Type_Only_Enum := No_Type_Only;
Pre, Pre_Get, Pre_Set : String := "") return Field_Sequence;
-- The above functions return Field_Sequence. This is a trick to get around
-- the fact that Ada doesn't allow singleton positional aggregates. It
-- allows us to write things like:
--
-- Cc (N_Empty, Node_Kind,
-- (Sy (Chars, Name_Id, Default_No_Name)));
--
-- where that thing pretending to be an aggregate is really a parenthesized
-- expression. See Gen_Nodes for documentation of the functions these are
-- standing in for.
end Gen_IL.Gen;
|
stcarrez/ada-ado | Ada | 1,015 | ads | -----------------------------------------------------------------------
-- mysql-lib.ads -- MySQL Library information
-- Copyright (C) 2011, 2012, 2013, 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.
-----------------------------------------------------------------------
package Mysql.Lib is
pragma Pure;
pragma Style_Checks ("-mr");
MYSQL_LIB_NAME : constant String := "-lmariadb";
end Mysql.Lib;
|
reznikmm/matreshka | Ada | 3,697 | 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 XML.DOM.Elements;
package ODF.DOM.Elements.Style.List_Level_Label_Alignment is
type ODF_Style_List_Level_Label_Alignment is
new XML.DOM.Elements.DOM_Element with private;
private
type ODF_Style_List_Level_Label_Alignment is
new XML.DOM.Elements.DOM_Element with null record;
end ODF.DOM.Elements.Style.List_Level_Label_Alignment;
|
stcarrez/ada-asf | Ada | 7,108 | adb | -----------------------------------------------------------------------
-- messages - A simple memory-based forum
-- Copyright (C) 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 Ada.Calendar;
with Util.Beans.Objects.Time;
with ASF.Events.Faces.Actions;
package body Messages is
use Ada.Strings.Unbounded;
Database : aliased Forum;
-- ------------------------------
-- Get the value identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Message_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "text" then
return Util.Beans.Objects.To_Object (From.Text);
elsif Name = "email" then
return Util.Beans.Objects.To_Object (From.Email);
elsif Name = "id" then
return Util.Beans.Objects.To_Object (Integer (From.Id));
else
return Util.Beans.Objects.Null_Object;
end if;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name.
-- ------------------------------
overriding
procedure Set_Value (From : in out Message_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "text" then
From.Text := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "email" then
From.Email := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "id" then
From.Id := Message_Id (Util.Beans.Objects.To_Integer (Value));
end if;
end Set_Value;
-- ------------------------------
-- Post the message.
-- ------------------------------
procedure Post (From : in out Message_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
if Length (From.Text) > 200 then
Ada.Strings.Unbounded.Replace_Slice (From.Text, 200, Length (From.Text), "...");
end if;
Database.Post (From);
Outcome := To_Unbounded_String ("posted");
end Post;
package Post_Binding is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Message_Bean,
Method => Post,
Name => "post");
Binding_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (Post_Binding.Proxy'Unchecked_Access, Post_Binding.Proxy'Unchecked_Access);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Message_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Create a message bean instance.
-- ------------------------------
function Create_Message_Bean return Util.Beans.Basic.Readonly_Bean_Access is
Result : constant Message_Bean_Access := new Message_Bean;
begin
return Result.all'Access;
end Create_Message_Bean;
-- ------------------------------
-- Get the value identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Forum_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "count" then
return Util.Beans.Objects.To_Object (Integer (From.Get_Count));
elsif Name = "today" then
return Util.Beans.Objects.Time.To_Object (Ada.Calendar.Clock);
else
return Util.Beans.Objects.Null_Object;
end if;
end Get_Value;
-- ------------------------------
-- Get the number of elements in the list.
-- ------------------------------
overriding
function Get_Count (From : in Forum_Bean) return Natural is
pragma Unreferenced (From);
begin
return Database.Get_Message_Count;
end Get_Count;
-- ------------------------------
-- Set the current row index. Valid row indexes start at 1.
-- ------------------------------
overriding
procedure Set_Row_Index (From : in out Forum_Bean;
Index : in Natural) is
begin
From.Pos := Message_Id (Index);
From.Msg := Database.Get_Message (From.Pos);
end Set_Row_Index;
-- ------------------------------
-- Get the element at the current row index.
-- ------------------------------
overriding
function Get_Row (From : in Forum_Bean) return Util.Beans.Objects.Object is
begin
return From.Current;
end Get_Row;
-- ------------------------------
-- Create the list of messages.
-- ------------------------------
function Create_Message_List return Util.Beans.Basic.Readonly_Bean_Access is
F : constant Forum_Bean_Access := new Forum_Bean;
begin
F.Current := Util.Beans.Objects.To_Object (F.Msg'Access, Util.Beans.Objects.STATIC);
return F.all'Access;
end Create_Message_List;
protected body Forum is
-- ------------------------------
-- Post the message in the forum.
-- ------------------------------
procedure Post (Message : in Message_Bean) is
use type Ada.Containers.Count_Type;
begin
if Messages.Length > 100 then
Messages.Delete (Message_Id'First);
end if;
Messages.Append (Message);
end Post;
-- ------------------------------
-- Delete the message identified by <b>Id</b>.
-- ------------------------------
procedure Delete (Id : in Message_Id) is
begin
Messages.Delete (Id);
end Delete;
-- ------------------------------
-- Get the message identified by <b>Id</b>.
-- ------------------------------
function Get_Message (Id : in Message_Id) return Message_Bean is
begin
return Messages.Element (Id);
end Get_Message;
-- ------------------------------
-- Get the number of messages in the forum.
-- ------------------------------
function Get_Message_Count return Natural is
begin
return Natural (Messages.Length);
end Get_Message_Count;
end Forum;
end Messages;
|
AdaCore/training_material | Ada | 2,483 | adb | ------------------------------------------------------------------------------
-- --
-- Hardware Abstraction Layer for STM32 Targets --
-- --
-- Copyright (C) 2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Machine_Code; use System.Machine_Code;
package body Memory_Barriers is
----------------------------------
-- Data_Synchronization_Barrier --
----------------------------------
procedure Data_Synchronization_Barrier is
pragma Suppress (All_Checks);
begin
Asm ("DSB #0xF", Volatile => True); -- 15 is 'Sy", ie "full system"
end Data_Synchronization_Barrier;
end Memory_Barriers;
|
kisom/rover-mk1 | Ada | 682 | ads | with Interfaces;
use Interfaces;
package ROSA.Tasks is
type States is (Running, Suspended, Waiting, Ready);
type Task_Status is (OK,
Not_Ready,
Not_Running);
type Tasking is private;
-- Initialise a new tasking structure.
procedure Create (Task_ID, Priority : in Unsigned_8; t : out Tasking);
-- Start up a ready task, putting it into the running state.
function Run (t : in Tasking) return Task_Status;
-- Suspend a running task.
function Suspend (t : in Tasking) return Task_Status;
private
type Tasking is record
Task_ID : Unsigned_8;
State : States;
Priority : Unsigned_8;
end record;
end ROSA.Tasks;
|
godunko/adawebui | Ada | 3,649 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2018-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: 5903 $ $Date: 2018-12-26 22:07:33 +0300 (Wed, 26 Dec 2018) $
------------------------------------------------------------------------------
with Web.UI.Widgets.Spin_Boxes.Generic_Integers;
with Web.UI.Integer_Slots.Emitters;
package Web.UI.Widgets.Spin_Boxes.Integers is
new Web.UI.Widgets.Spin_Boxes.Generic_Integers
(Integer, Web.UI.Integer_Slots, Web.UI.Integer_Slots.Emitters);
|
reznikmm/matreshka | Ada | 594 | adb | with ada_parse, ada_lex.io, ada_lex, text_io;
use ada_parse, text_io;
procedure parse is
in_file_name: string(1..80);
last : natural;
begin
text_io.put("Enter input file: ");
text_io.get_line(in_file_name, last);
ada_lex.io.open_input(in_file_name(1..last));
ada_lex.io.create_output;
put_line("---- Starting parse ----");
ada_lex.linenum;
yyparse;
ada_lex.io.close_input;
ada_lex.io.close_output;
put_line("---- Finished parse ----");
new_line;
put(integer'image(number_of_errors));
put_line(" errors found");
end parse;
|
reznikmm/matreshka | Ada | 3,699 | 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.Number_Boolean_Style_Elements is
pragma Preelaborate;
type ODF_Number_Boolean_Style is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Number_Boolean_Style_Access is
access all ODF_Number_Boolean_Style'Class
with Storage_Size => 0;
end ODF.DOM.Number_Boolean_Style_Elements;
|
reznikmm/matreshka | Ada | 3,652 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package AMF3.Slots.Collections is
-- pragma Preelaborate;
type Collection_Slot is new Abstract_Slot with private;
private
type Collection_Slot is new Abstract_Slot with null record;
overriding function Get
(Self : Collection_Slot) return League.Holders.Holder;
end AMF3.Slots.Collections;
|
davidkristola/vole | Ada | 35,321 | adb | with Interfaces; use Interfaces;
with Ada.Text_IO;
with Ada.Exceptions; use Ada.Exceptions;
with kv.avm.Log; use kv.avm.Log;
with kv.avm.Memories;
with kv.avm.Tuples;
with kv.avm.Actor_References;
with kv.avm.Messages;
with kv.avm.Control; use kv.avm.Control;
with kv.avm.Executables;
with kv.avm.actor_pool;
package body kv.avm.Processors is
use kv.avm.Instructions;
use kv.avm.Registers;
-----------------------------------------------------------------------------
procedure Initialize
(Self : in out Processor_Type;
Machine : in kv.avm.control.Control_Access) is
begin
Self.Machine := Machine;
Self.Failed_Assertion_Count := 0;
end Initialize;
-----------------------------------------------------------------------------
procedure Step
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Status : out kv.avm.Control.Status_Type) is
Instruction : kv.avm.Instructions.Instruction_Type;
Program_Counter : Interfaces.Unsigned_32;
function Log_Entry return String is
begin
return "kv.avm.processor.Step "&Frame.Debug_Info;
end Log_Entry;
use kv.avm.Control;
begin
Status := kv.avm.Control.Active;
Log_If(Log_Entry'Access);
Program_Counter := Frame.Program_Counter;
Frame.Fetch_And_Increment(Instruction);
case Instruction.Op_Code is
when No_Op =>
Self.No_Op(Frame);
when Stop_Frame =>
Self.Stop_Frame(Frame);
when Reply =>
Self.Reply(Frame, Instruction);
when Jump =>
Self.Jump(Frame, Instruction);
when Jump_Abs | Jump_Rel =>
Self.Jump_Immediate(Frame, Instruction);
when Set =>
Self.Set(Frame, Instruction);
when Branch_Abs .. Branch_Neq =>
Self.Branch(Frame, Instruction);
when Fold =>
Self.Fold(Frame, Instruction);
when Peek =>
Self.Peek(Frame, Instruction, Status);
when New_Actor =>
Self.New_Actor(Frame, Instruction, Status);
when Compute =>
Self.Compute(Frame, Instruction);
when Emit =>
Self.Emit(Frame, Instruction);
when Self_Tail_Send | Self_Tail_Call =>
Self.Self_Tail_X(Frame, Instruction);
when Halt_Actor =>
Self.Halt_Actor(Frame, Instruction);
when Trap =>
Self.Trap(Frame, Instruction, Status);
when Actor_Call =>
Self.Actor_Call(Frame, Instruction, Status);
when Self_Call =>
Self.Self_Call(Frame, Instruction);
when Super_Call =>
Self.Super_Call(Frame, Instruction);
when Self_Send =>
Self.Self_Send(Frame, Instruction);
when format_5a2_type =>
Self.Format_5A2(Frame, Instruction, Status);
when Peek_Immediate =>
Self.Peek_Immediate(Frame, Instruction, Status);
when Assert =>
Self.Assert(Frame, Instruction);
when others =>
raise Unimplemented_Error;
end case;
if Status = kv.avm.Control.Blocked then
Put_Line("Frame "&Frame.Image&" returned Blocked status.");
Frame.Set_Program_Counter(Program_Counter);
Frame.Set_Blocked(True);
elsif Status = kv.avm.Control.Deferred then
Put_Line("Frame "&Frame.Image&" returned Deferred status.");
Frame.Set_Program_Counter(Program_Counter);
end if;
exception
when Error: others =>
Put_Line("EXCEPTION: "&Exception_Information(Error));
Frame.Set_Program_Counter(Program_Counter); -- Return the progam counter to the value it had on entry
raise;
end Step;
-----------------------------------------------------------------------------
function Get_Failed_Assertion_Count(Self : Processor_Type) return Natural is
begin
return Self.Failed_Assertion_Count;
end Get_Failed_Assertion_Count;
-----------------------------------------------------------------------------
function Get_Machine(Self : Processor_Type) return kv.avm.Control.Control_Access is
begin
return Self.Machine;
end Get_Machine;
-----------------------------------------------------------------------------
procedure No_Op
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type) is
begin
null;
end No_Op;
-----------------------------------------------------------------------------
procedure Stop_Frame
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type) is
begin
Frame.Set_Program_Counter(Frame.Program_Counter - 1);
Frame.Set_Running(False);
end Stop_Frame;
-----------------------------------------------------------------------------
function Get_Or_Make_Tuple
(Frame : in kv.avm.Frames.Frame_Type;
Index : in kv.avm.references.reference_type) return kv.avm.Tuples.Tuple_Type is
Data : kv.avm.Tuples.Tuple_Type;
begin
if Frame.Get(Index).Format = kv.avm.Registers.Tuple then
return Frame.Get(Index).folded_tuple;
elsif Frame.Get(Index).Format = kv.avm.Registers.Tuple_Map then
return Frame.Fold(Index);
else
declare
Register : aliased kv.avm.Registers.Register_Type := Frame.Get(Index);
begin
Data.Fold_One(Register'ACCESS);
end;
return Data;
end if;
end Get_Or_Make_Tuple;
-----------------------------------------------------------------------------
procedure Reply
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
Data : kv.avm.Tuples.Tuple_Type;
My_Instance : kv.avm.Executables.Executable_Access;
use kv.avm.control;
begin
Frame.Set_Running(False);
-- If the return value is a tuple, send it...
Data := Get_Or_Make_Tuple(Frame.all, Instr.value);
-- if Frame.Get(Instr.value).Format = kv.avm.Registers.Tuple then
-- Data := Frame.Get(Instr.value).folded_tuple;
-- else
-- --TODO: check to see of this is a tuple map
-- -- Otherwise build a singleton tuple from the answer and send that.
-- -- Technically, this is a convenience function to avoid a FOLD instruction
-- -- before each reply, but since it is expected that most returns are
-- -- a single value, this should be worthwhile.
-- declare
-- Register : aliased kv.avm.Registers.Register_Type := Frame.Get(Instr.value);
-- begin
-- Data.Fold_One(Register'ACCESS);
-- end;
-- end if;
if Frame.Is_Self_Replying then
Put_Line("Reply to self!");
My_Instance := kv.avm.actor_pool.Resolve(Frame.Get_Instance);
My_Instance.Process_Internal_Response(Data);
else
if Self.Machine = null then
Put_Line("ERROR: Machine is not set!");
end if;
Self.Machine.Post_Response
(Reply_To => Frame.Get_Invoker,
Answer => Data,
Future => Frame.Get_Invoker_Future);
end if;
end Reply;
-----------------------------------------------------------------------------
procedure Set
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
begin
--!@#$ This is where we would put in type checking, etc.
Frame.Vet_Operands(Instr.Lhs, Instr.Rhs);
Frame.Set(Instr.Lhs, Frame.Get(Instr.Rhs));
end Set;
-----------------------------------------------------------------------------
procedure Jump
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
Destination : kv.avm.Registers.Register_Type;
begin
Destination := Frame.Get(Instr.Value);
Frame.Set_Program_Counter(Interfaces.Unsigned_32(Destination.unsigned_value));
end Jump;
-----------------------------------------------------------------------------
procedure Jump_Immediate
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
Jump_Target : Interfaces.Unsigned_32;
begin
if Instr.op_code = jump_abs then
Jump_Target := Instr.jump;
else -- Instr.op_code = branch_rel
-- Target is a signed integer stored in an unsigned field
-- Simply adding target to the program
-- counter produces the correct result.
Jump_Target := Frame.Program_Counter + Instr.jump;
end if;
Frame.Set_Program_Counter(Jump_Target);
end Jump_Immediate;
-----------------------------------------------------------------------------
generic
with function Op(Lhs : Interfaces.Unsigned_64; Rhs : Interfaces.Unsigned_64) return Interfaces.Unsigned_64;
function U_Op(Lhs : Register_Type; Rhs : Register_Type) return Register_Type;
function U_Op(Lhs : Register_Type; Rhs : Register_Type) return Register_Type is
Intermediate : Interfaces.Unsigned_64;
begin
Intermediate := Op(Lhs.unsigned_value, Rhs.unsigned_value);
return (format => Unsigned_Integer, unsigned_value => Intermediate);
end U_Op;
function U_Add is new U_Op(Interfaces."+");
function U_Sub is new U_Op(Interfaces."-");
function U_Mul is new U_Op(Interfaces."*");
function U_Div is new U_Op(Interfaces."/");
function U_Mod is new U_Op(Interfaces."mod");
-----------------------------------------------------------------------------
generic
with function Op(Lhs : Interfaces.Integer_64; Rhs : Interfaces.Integer_64) return Interfaces.Integer_64;
function S_Op(Lhs : Register_Type; Rhs : Register_Type) return Register_Type;
function S_Op(Lhs : Register_Type; Rhs : Register_Type) return Register_Type is
Intermediate : Interfaces.Integer_64;
begin
Intermediate := Op(Lhs.signed_value, Rhs.signed_value);
return (format => Signed_Integer, signed_value => Intermediate);
end S_Op;
function S_Add is new S_Op(Interfaces."+");
function S_Sub is new S_Op(Interfaces."-");
function S_Mul is new S_Op(Interfaces."*");
function S_Div is new S_Op(Interfaces."/");
function S_Mod is new S_Op(Interfaces."mod");
function Unimplemented_Op(Lhs : Register_Type; Rhs : Register_Type) return Register_Type is
begin
Put_Line("Unimplemented_Op raising Unimplemented_Error!");
raise Unimplemented_Error;
return Lhs; -- Unreachable
end Unimplemented_Op;
type Operator_Access is access function(Lhs : Register_Type; Rhs : Register_Type) return Register_Type;
type Operation_Lookup_Table_Type is array (Data_Kind) of Operator_Access;
Add_Operations : constant Operation_Lookup_Table_Type :=
(Signed_Integer => S_Add'ACCESS,
Unsigned_Integer => U_Add'ACCESS,
others => Unimplemented_Op'ACCESS);
Sub_Operations : constant Operation_Lookup_Table_Type :=
(Signed_Integer => S_Sub'ACCESS,
Unsigned_Integer => U_Sub'ACCESS,
others => Unimplemented_Op'ACCESS);
Mul_Operations : constant Operation_Lookup_Table_Type :=
(Signed_Integer => S_Mul'ACCESS,
Unsigned_Integer => U_Mul'ACCESS,
others => Unimplemented_Op'ACCESS);
Div_Operations : constant Operation_Lookup_Table_Type :=
(Signed_Integer => S_Div'ACCESS,
Unsigned_Integer => U_Div'ACCESS,
others => Unimplemented_Op'ACCESS);
Mod_Operations : constant Operation_Lookup_Table_Type :=
(Signed_Integer => S_Mod'ACCESS,
Unsigned_Integer => U_Mod'ACCESS,
others => Unimplemented_Op'ACCESS);
-----------------------------------------------------------------------------
generic
with function Op(Lhs : Interfaces.Unsigned_64; Rhs : Interfaces.Unsigned_64) return Boolean;
function U_Compare(Lhs : Register_Type; Rhs : Register_Type) return Boolean;
function U_Compare(Lhs : Register_Type; Rhs : Register_Type) return Boolean is
begin
return Op(Lhs.unsigned_value, Rhs.unsigned_value);
end U_Compare;
function U_Eq is new U_Compare(Interfaces."=");
function U_Neq is new U_Compare(Interfaces."/=");
function U_Lt is new U_Compare(Interfaces."<");
function U_Lte is new U_Compare(Interfaces."<=");
function U_Gt is new U_Compare(Interfaces.">");
function U_Gte is new U_Compare(Interfaces.">=");
-----------------------------------------------------------------------------
generic
with function Op(Lhs : Interfaces.Integer_64; Rhs : Interfaces.Integer_64) return Boolean;
function S_Compare(Lhs : Register_Type; Rhs : Register_Type) return Boolean;
function S_Compare(Lhs : Register_Type; Rhs : Register_Type) return Boolean is
begin
return Op(Lhs.signed_value, Rhs.signed_value);
end S_Compare;
function S_Eq is new S_Compare(Interfaces."=");
function S_Neq is new S_Compare(Interfaces."/=");
function S_Lt is new S_Compare(Interfaces."<");
function S_Lte is new S_Compare(Interfaces."<=");
function S_Gt is new S_Compare(Interfaces.">");
function S_Gte is new S_Compare(Interfaces.">=");
function Unimplemented_Compare(Lhs : Register_Type; Rhs : Register_Type) return Boolean is
begin
Put_Line("Unimplemented_Compare raising Unimplemented_Error!");
raise Unimplemented_Error;
return False; -- Unreachable
end Unimplemented_Compare;
type Compare_Access is access function(Lhs : Register_Type; Rhs : Register_Type) return Boolean;
type Compare_Lookup_Table_Type is array (Data_Kind) of Compare_Access;
type Compare_Lookup_Table_Access is access constant Compare_Lookup_Table_Type;
Compare_Eq : aliased constant Compare_Lookup_Table_Type :=
(Signed_Integer => S_Eq'ACCESS,
Unsigned_Integer => U_Eq'ACCESS,
others => Unimplemented_Compare'ACCESS);
Compare_Neq : aliased constant Compare_Lookup_Table_Type :=
(Signed_Integer => S_Neq'ACCESS,
Unsigned_Integer => U_Neq'ACCESS,
others => Unimplemented_Compare'ACCESS);
Compare_Lt : aliased constant Compare_Lookup_Table_Type :=
(Signed_Integer => S_Lt'ACCESS,
Unsigned_Integer => U_Lt'ACCESS,
others => Unimplemented_Compare'ACCESS);
Compare_Lte : aliased constant Compare_Lookup_Table_Type :=
(Signed_Integer => S_Lte'ACCESS,
Unsigned_Integer => U_Lte'ACCESS,
others => Unimplemented_Compare'ACCESS);
Compare_Gt : aliased constant Compare_Lookup_Table_Type :=
(Signed_Integer => S_Gt'ACCESS,
Unsigned_Integer => U_Gt'ACCESS,
others => Unimplemented_Compare'ACCESS);
Compare_Gte : aliased constant Compare_Lookup_Table_Type :=
(Signed_Integer => S_Gte'ACCESS,
Unsigned_Integer => U_Gte'ACCESS,
others => Unimplemented_Compare'ACCESS);
Compare_Lookup : constant array (Compare_Type) of Compare_Lookup_Table_Access :=
(Eq => Compare_Eq'ACCESS,
Neq => Compare_Neq'ACCESS,
L_t => Compare_Lt'ACCESS,
Lte => Compare_Lte'ACCESS,
G_t => Compare_Gt'ACCESS,
Gte => Compare_Gte'ACCESS);
-----------------------------------------------------------------------------
generic
Lookup_Table : in Operation_Lookup_Table_Type;
procedure Generic_Operation
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
A : in Reference_Type;
X : in Reference_Type;
Y : in Reference_Type);
procedure Generic_Operation
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
A : in Reference_Type;
X : in Reference_Type;
Y : in Reference_Type) is
Data_Format : Data_Kind;
Operator : Operator_Access;
begin
--Put_Line("kv.avm.processor.Generic_Operation "&Ref_Img(A)&" <= "&Ref_Img(X)&" op "&Ref_Img(Y));
Frame.Vet_Operands(A, X, Y);
Data_Format := Frame.Get(X).format; -- A might be unassigned
Operator := Lookup_Table(Data_Format);
Frame.Set(A, Operator(Frame.Get(X), Frame.Get(Y)));
end Generic_Operation;
-----------------------------------------------------------------------------
procedure Add_Instance is new Generic_Operation(Add_Operations);
-----------------------------------------------------------------------------
procedure Subtract_Instance is new Generic_Operation(Sub_Operations);
-----------------------------------------------------------------------------
procedure Multiply_Instance is new Generic_Operation(Mul_Operations);
-----------------------------------------------------------------------------
procedure Divide_Instance is new Generic_Operation(Div_Operations);
-----------------------------------------------------------------------------
procedure Modulo_Instance is new Generic_Operation(Mod_Operations);
-----------------------------------------------------------------------------
procedure Branch
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
Branch_Target : Interfaces.Unsigned_32;
Condition : kv.avm.Registers.Register_Type;
begin
Condition := Frame.Get(Instr.condition);
if Condition.bit then
if Instr.op_code = branch_abs then
Branch_Target := Instr.target;
elsif Instr.op_code = branch_rel then
-- Target is a signed integer stored in an unsigned field
-- Simply adding target to the program
-- counter produces the correct result.
Branch_Target := Frame.Program_Counter + Instr.target;
else
return;
end if;
else
if Instr.op_code = branch_neq then
Branch_Target := Frame.Program_Counter + Instr.target;
else
return;
end if;
end if;
Frame.Set_Program_Counter(Branch_Target);
end Branch;
-----------------------------------------------------------------------------
procedure Fold
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
begin
Frame.Set(Instr.lhs, (format => kv.avm.Registers.Tuple, folded_tuple => Frame.Fold(Instr.rhs)));
end Fold;
-----------------------------------------------------------------------------
procedure Peek
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type;
Status : out kv.avm.Control.Status_Type) is
Register : kv.avm.Registers.Register_Type;
The_Tuple : kv.avm.Tuples.Tuple_Type;
begin
--Put_Line("kv.avm.processor.Peek "&Ref_Img(Instr.A)&" <= peek from tuple "&Ref_Img(Instr.X)&", index "&Ref_Img(Instr.Y));
-- Return values are sent back as tuples, so a PEEK is the normal means of accessing the data.
-- This data might be an unfufilled future.
Register := Frame.Get(Instr.X);
if Register.Format = kv.avm.Registers.Future then
--Put_Line("Frame="&Frame.Image&" blocking on Future="&Interfaces.Unsigned_32'IMAGE(Register.ID));
Status := kv.avm.Control.Blocked;
return;
end if;
The_Tuple := Register.folded_tuple;
Frame.Set(Instr.A, The_Tuple.Peek(Interfaces.Unsigned_32(Frame.Get(Instr.Y).unsigned_value)).all);
Status := kv.avm.Control.Active;
end Peek;
Constructor_Name : aliased constant String := "CONSTRUCTOR";
-----------------------------------------------------------------------------
procedure New_Actor
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type;
Status : out kv.avm.Control.Status_Type) is
Fresh_Actor : kv.avm.Actor_References.Actor_Reference_Type;
Folded_Tuple : aliased kv.avm.Tuples.Tuple_Type;
Register : aliased kv.avm.Registers.Register_Type;
Message : kv.avm.Messages.Message_Type;
use kv.avm.Registers;
begin
--Put_Line("kv.avm.processor.New_Actor called with name = '"&Frame.Get(Instr.Y).Actor_Kind.all&"'.");
Self.Machine.New_Actor(+Frame.Get(Instr.Y).Actor_Kind, Fresh_Actor);
Frame.Set(Instr.A, (format => kv.avm.Registers.Actor_Reference, Instance => Fresh_Actor));
Folded_Tuple := Get_Or_Make_Tuple(Frame.all, Instr.X);
-- if Frame.Get(Instr.X).format = kv.avm.Registers.Tuple then
-- Folded_Tuple := Frame.Get(Instr.X).folded_tuple;
-- else
-- --Put_Line("kv.avm.processor.New_Actor folding a tuple around "&Ref_Img(Instr.X)&" = "&Reg_Img(Frame.Get(Instr.X)));
-- Register := Frame.Get(Instr.X);
-- Folded_Tuple.Fold_One(Register'ACCESS);
-- end if;
Message.Initialize
(Source => Frame.Get_Instance,
Reply_To => Frame.Get_Instance,
Destination => Fresh_Actor,
Message_Name => Constructor_Name,
Data => Folded_Tuple,
Future => kv.avm.control.NO_FUTURE);
Self.Machine.Post_Message
(Message => Message,
Status => Status);
end New_Actor;
-----------------------------------------------------------------------------
procedure Compute
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
Compare_Op : Compare_Access;
X : kv.avm.Registers.Register_Type;
Y : kv.avm.Registers.Register_Type;
use kv.avm.Registers;
True_Value : constant kv.avm.Registers.Register_Type := (format => Bit_Or_Boolean, bit => True);
False_Value : constant kv.avm.Registers.Register_Type := (format => Bit_Or_Boolean, bit => False);
begin
case Instr.Action is
when Add =>
Add_Instance(Self, Frame, Instr.Result, Instr.Left, Instr.Right);
when Sub =>
Subtract_Instance(Self, Frame, Instr.Result, Instr.Left, Instr.Right);
when Mul =>
Multiply_Instance(Self, Frame, Instr.Result, Instr.Left, Instr.Right);
when Div =>
Divide_Instance(Self, Frame, Instr.Result, Instr.Left, Instr.Right);
when Modulo =>
Modulo_Instance(Self, Frame, Instr.Result, Instr.Left, Instr.Right);
when Compare_Type =>
X := Frame.Get(Instr.Left);
Y := Frame.Get(Instr.Right);
Compare_Op := Compare_Lookup(Instr.Action)(X.format);
if Compare_Op(X, Y) then
Frame.Set(Instr.Result, True_Value);
else
Frame.Set(Instr.Result, False_Value);
end if;
when others =>
raise Unimplemented_Error;
end case;
end Compute;
-----------------------------------------------------------------------------
procedure Emit
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
Value : kv.avm.Registers.Register_Type;
use kv.avm.Registers;
begin
Value := Frame.Get(Instr.value);
Ada.Text_IO.Put("Emit:");
case Value.format is
when Signed_Integer =>
Ada.Text_IO.Put_Line(Interfaces.Integer_64'IMAGE(Value.signed_value));
when Unsigned_Integer =>
Ada.Text_IO.Put_Line(Interfaces.Unsigned_64'IMAGE(Value.unsigned_value));
when Bit_Or_Boolean =>
Ada.Text_IO.Put_Line(Boolean'IMAGE(Value.bit));
when Floatingpoint =>
Ada.Text_IO.Put_Line(Interfaces.IEEE_Float_64'IMAGE(Value.value));
when Immutable_String =>
Ada.Text_IO.Put_Line(+Value.The_String);
when Future =>
Ada.Text_IO.Put_Line(Interfaces.Unsigned_32'IMAGE(Value.ID));
when Message_Definition =>
Ada.Text_IO.Put_Line(+Value.Message_Name);
when others =>
Ada.Text_IO.Put_Line("EMIT not yet implemented for this register type.");
end case;
end Emit;
-----------------------------------------------------------------------------
procedure Self_Tail_X
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
Future : Interfaces.Unsigned_32 := kv.avm.control.NO_FUTURE;
Folded_Tuple : aliased kv.avm.Tuples.Tuple_Type;
begin
Put_Line("kv.avm.processor.Self_Tail_X message args="&Ref_Img(Instr.args_5b2)&", mdef="&Ref_Img(Instr.mdef_5b2));
if Instr.Op_Code = Self_Tail_Call then
-- This is a tail call, need the future that the active frame was invoked with
Future := Frame.Get_Invoker_Future;
else
-- This is a tail send, if there was a future, it is being lost.
Future := kv.avm.control.NO_FUTURE;
end if;
Folded_Tuple := Get_Or_Make_Tuple(Frame.all, Instr.args_5b2);
Frame.Process_Gosub
(Tail_Call => True,
Supercall => False,
Message_Name => Frame.Get(Instr.mdef_5b2).Message_Name,
Data => Folded_Tuple, --Frame.Get(Instr.args_5b2).folded_tuple,
Future => Future);
end Self_Tail_X;
-----------------------------------------------------------------------------
procedure Halt_Actor
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
begin
Frame.Set_Program_Counter(Frame.Program_Counter - 1);
Frame.Halt_Actor;
end Halt_Actor;
-----------------------------------------------------------------------------
procedure Trap
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type;
Status : out kv.avm.Control.Status_Type) is
Answer : kv.avm.Registers.Register_Type;
use kv.avm.Registers;
begin
-- Unsigned integer traps are handled by the processor, string traps go to the machine.
--
if Frame.Get(Instr.X).Format = Unsigned_Integer then
case Frame.Get(Instr.X).Unsigned_Value is
when 1 =>
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line("The answser is: "&Reg_Img(Frame.Get(Instr.Y)));
Ada.Text_IO.New_Line;
when others =>
raise Unimplemented_Error;
end case;
elsif Frame.Get(Instr.X).Format = Immutable_String then
Self.Machine.Trap_To_The_Machine(+Frame.Get(Instr.X).The_String, Frame.Get(Instr.Y), Answer, Status);
Frame.Set(Instr.A, Answer);
else
raise Unimplemented_Error;
end if;
end Trap;
-----------------------------------------------------------------------------
procedure Self_Call
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
Future : Interfaces.Unsigned_32 := kv.avm.control.NO_FUTURE;
Folded_Tuple : aliased kv.avm.Tuples.Tuple_Type;
begin
Put_Line("kv.avm.processor.Self_Call reply into=" & Ref_Img(Instr.rply_5b1) & ", message arguments="&Ref_Img(Instr.args_5b1)&", message profile="&Ref_Img(Instr.mdef_5b1));
Self.Machine.Generate_Next_Future(Future);
Frame.Set_Reply_Information(Instr.rply_5b1, Future);
Folded_Tuple := Get_Or_Make_Tuple(Frame.all, Instr.args_5b1);
Frame.Process_Gosub
(Tail_Call => False,
Supercall => False,
Message_Name => Frame.Get(Instr.mdef_5b1).Message_Name,
Data => Folded_Tuple, --Frame.Get(Instr.args_5b1).folded_tuple,
Future => Future);
end Self_Call;
-----------------------------------------------------------------------------
procedure Super_Call
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
Future : Interfaces.Unsigned_32 := kv.avm.control.NO_FUTURE;
Folded_Tuple : aliased kv.avm.Tuples.Tuple_Type;
begin
Put_Line("kv.avm.processor.Super_Call reply into=" & Ref_Img(Instr.rply_5b1) & ", message arguments="&Ref_Img(Instr.args_5b1)&", message profile="&Ref_Img(Instr.mdef_5b1));
Self.Machine.Generate_Next_Future(Future);
Frame.Set_Reply_Information(Instr.rply_5b1, Future);
--!@#$
Folded_Tuple := Get_Or_Make_Tuple(Frame.all, Instr.args_5b1);
Frame.Process_Gosub
(Tail_Call => False,
Supercall => True,
Message_Name => Frame.Get(Instr.mdef_5b1).Message_Name,
Data => Folded_Tuple, --Frame.Get(Instr.args_5b1).folded_tuple,
Future => Future);
end Super_Call;
-----------------------------------------------------------------------------
procedure Actor_Call
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type;
Status : out kv.avm.Control.Status_Type) is
Future : Interfaces.Unsigned_32 := kv.avm.control.NO_FUTURE;
Message : kv.avm.Messages.Message_Type;
Folded_Tuple : aliased kv.avm.Tuples.Tuple_Type;
begin
Put_Line("kv.avm.processor.Actor_Call reply into=" & Ref_Img(Instr.rply_5a1) &
", message arguments=" & Ref_Img(Instr.args_5a1) &
", actor=" & Ref_Img(Instr.actr_5a1) &
", message profile=" & Ref_Img(Instr.mdef_5a1));
Self.Machine.Generate_Next_Future(Future);
Frame.Set_Reply_Information(Instr.rply_5a1, Future);
Folded_Tuple := Get_Or_Make_Tuple(Frame.all, Instr.args_5a1);
Message.Initialize
(Source => Frame.Get_Instance,
Reply_To => Frame.Get_Instance,
Destination => Frame.Get(Instr.actr_5a1).Instance,
Message_Name => +Frame.Get(Instr.mdef_5a1).Message_Name,
Data => Folded_Tuple, --Frame.Get(Instr.args_5a1).folded_tuple,
Future => Future);
Self.Machine.Post_Message
(Message => Message,
Status => Status);
end Actor_Call;
-----------------------------------------------------------------------------
procedure Format_5A2
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type;
Status : out kv.avm.Control.Status_Type) is
Future : Interfaces.Unsigned_32 := kv.avm.control.NO_FUTURE;
Reply_To : kv.avm.Actor_References.Actor_Reference_Type;
--Status : kv.avm.Control.Status_Type;
Message : kv.avm.Messages.Message_Type;
Folded_Tuple : aliased kv.avm.Tuples.Tuple_Type;
begin
Put_Line("kv.avm.processor.Format_5A2 message arguments=" & Ref_Img(Instr.args_5a2) &
", actor=" & Ref_Img(Instr.actr_5a2) &
", message profile=" & Ref_Img(Instr.mdef_5a2));
if Instr.op_code = Actor_Tail_Call then
-- This is a tail call, need the future that the active frame was invoked with
Future := Frame.Get_Invoker_Future;
end if;
if Instr.op_code = Actor_Send then
Reply_To := Frame.Get_Instance;
else
Reply_To := Frame.Get_Invoker;
end if;
Folded_Tuple := Get_Or_Make_Tuple(Frame.all, Instr.args_5a2);
Message.Initialize
(Source => Frame.Get_Instance,
Reply_To => Reply_To,
Destination => Frame.Get(Instr.actr_5a2).Instance,
Message_Name => +Frame.Get(Instr.mdef_5a2).Message_Name,
Data => Folded_Tuple, --Frame.Get(Instr.args_5a2).folded_tuple,
Future => Future);
Self.Machine.Post_Message
(Message => Message,
Status => Status);
end Format_5A2;
-----------------------------------------------------------------------------
procedure Peek_Immediate
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type;
Status : out kv.avm.Control.Status_Type) is
Register : kv.avm.Registers.Register_Type;
The_Tuple : kv.avm.Tuples.Tuple_Type;
begin
-- Return values are sent back as tuples, so a PEEK is the normal means of accessing the data.
-- This data might be an unfufilled future.
Register := Frame.Get(Instr.tuple);
if Register.Format = kv.avm.Registers.Future then
--Put_Line("Frame="&Frame.Image&" blocking on Future="&Interfaces.Unsigned_32'IMAGE(Register.ID));
Status := kv.avm.Control.Blocked;
return;
end if;
The_Tuple := Register.folded_tuple;
Frame.Set(Instr.lvalue, The_Tuple.Peek(Interfaces.Unsigned_32(Instr.index)).all);
Status := kv.avm.Control.Active;
end Peek_Immediate;
-----------------------------------------------------------------------------
procedure Assert
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
Condition : kv.avm.Registers.Register_Type;
begin
Condition := Frame.Get(Instr.value);
if not Condition.bit then
-- The assertion failed.
Frame.Set_Program_Counter(Frame.Program_Counter - 1);
Frame.Halt_Actor;
Self.Failed_Assertion_Count := Self.Failed_Assertion_Count + 1;
Put_Error("Machine Assertion Failed at " & Frame.Debug_Info);
end if;
end Assert;
-----------------------------------------------------------------------------
procedure Self_Send
(Self : in out Processor_Type;
Frame : access kv.avm.Frames.Frame_Type;
Instr : in kv.avm.Instructions.Instruction_Type) is
Status : kv.avm.Control.Status_Type;
Message : kv.avm.Messages.Message_Type;
Folded_Tuple : aliased kv.avm.Tuples.Tuple_Type;
begin
Put_Line("kv.avm.processor.Self_Send message arguments="&Ref_Img(Instr.args_5b2)&", message profile="&Ref_Img(Instr.mdef_5b2));
Folded_Tuple := Get_Or_Make_Tuple(Frame.all, Instr.args_5b2);
Message.Initialize
(Source => Frame.Get_Instance,
Reply_To => Frame.Get_Instance,
Destination => Frame.Get_Instance,
Message_Name => +Frame.Get(Instr.mdef_5b2).Message_Name,
Data => Folded_Tuple, --Frame.Get(Instr.args_5b2).folded_tuple,
Future => kv.avm.control.NO_FUTURE);
Self.Machine.Post_Message
(Message => Message,
Status => Status);
end Self_Send;
end kv.avm.Processors;
|
reznikmm/matreshka | Ada | 4,746 | 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.Db_Driver_Settings_Elements;
package Matreshka.ODF_Db.Driver_Settings_Elements is
type Db_Driver_Settings_Element_Node is
new Matreshka.ODF_Db.Abstract_Db_Element_Node
and ODF.DOM.Db_Driver_Settings_Elements.ODF_Db_Driver_Settings
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Db_Driver_Settings_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Db_Driver_Settings_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Db_Driver_Settings_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 Db_Driver_Settings_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 Db_Driver_Settings_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_Db.Driver_Settings_Elements;
|
AdaCore/libadalang | Ada | 504 | adb | procedure Test is
package Pkg is
type T is null record;
procedure Prim (X : T);
end Pkg;
package body Pkg is
procedure Foo (X : T) is null;
procedure Prim (X : T) renames Foo;
end Pkg;
package Der is
type U is new Pkg.T;
end Der;
use Der;
X : U;
begin
Prim (X);
--% called=node.f_call.p_referenced_decl()
--% next=called.p_next_part_for_decl()
--% renamed=next.f_renames.f_renamed_object
--% renamed.p_referenced_decl()
end Test;
|
reznikmm/matreshka | Ada | 4,871 | 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.Internals.Element_Collections;
with AMF.Internals.Tables.CMOF_Attributes;
package body AMF.Internals.CMOF_Redefinable_Elements is
use AMF.Internals.Tables.CMOF_Attributes;
-----------------
-- Get_Is_Leaf --
-----------------
overriding function Get_Is_Leaf
(Self : not null access constant CMOF_Redefinable_Element_Proxy)
return Boolean is
begin
return Internal_Get_Is_Leaf (Self.Element);
end Get_Is_Leaf;
---------------------------
-- Get_Redefined_Element --
---------------------------
overriding function Get_Redefined_Element
(Self : not null access constant CMOF_Redefinable_Element_Proxy)
return AMF.CMOF.Redefinable_Elements.Collections.Set_Of_CMOF_Redefinable_Element is
begin
return
AMF.CMOF.Redefinable_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(Internal_Get_Redefined_Element (Self.Element)));
end Get_Redefined_Element;
------------------------------
-- Get_Redefinition_Context --
------------------------------
overriding function Get_Redefinition_Context
(Self : not null access constant CMOF_Redefinable_Element_Proxy)
return AMF.CMOF.Classifiers.Collections.Set_Of_CMOF_Classifier is
begin
return
AMF.CMOF.Classifiers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(Internal_Get_Redefinition_Context (Self.Element)));
end Get_Redefinition_Context;
end AMF.Internals.CMOF_Redefinable_Elements;
|
reznikmm/matreshka | Ada | 4,614 | 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.Db_Key_Elements;
package Matreshka.ODF_Db.Key_Elements is
type Db_Key_Element_Node is
new Matreshka.ODF_Db.Abstract_Db_Element_Node
and ODF.DOM.Db_Key_Elements.ODF_Db_Key
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Db_Key_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Db_Key_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Db_Key_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 Db_Key_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 Db_Key_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_Db.Key_Elements;
|
reznikmm/matreshka | Ada | 3,698 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2009, 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 is GNAT specific version of the package. It can or can't be
-- compatible with other Ada compilers.
------------------------------------------------------------------------------
with Interfaces;
package Matreshka.Internals.Host_Types is
pragma Pure;
subtype Longest_Integer is Interfaces.Integer_64;
end Matreshka.Internals.Host_Types;
|
reznikmm/matreshka | Ada | 4,719 | 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.Style_Tab_Stops_Elements;
package Matreshka.ODF_Style.Tab_Stops_Elements is
type Style_Tab_Stops_Element_Node is
new Matreshka.ODF_Style.Abstract_Style_Element_Node
and ODF.DOM.Style_Tab_Stops_Elements.ODF_Style_Tab_Stops
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Style_Tab_Stops_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Tab_Stops_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Style_Tab_Stops_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 Style_Tab_Stops_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 Style_Tab_Stops_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_Style.Tab_Stops_Elements;
|
zhmu/ananas | Ada | 5,147 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T K R --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Gnatvsn;
with Krunch;
with Switch; use Switch;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Command_Line; use Ada.Command_Line;
with System.IO; use System.IO;
procedure Gnatkr is
pragma Ident (Gnatvsn.Gnat_Static_Version_String);
Count : Natural;
Maxlen : Integer;
Exit_Program : exception;
function Get_Maximum_File_Name_Length return Integer;
pragma Import (C, Get_Maximum_File_Name_Length,
"__gnat_get_maximum_file_name_length");
procedure Usage;
-- Output usage information
-----------
-- Usage --
-----------
procedure Usage is
begin
Put_Line ("Usage: gnatkr filename[.extension] [krunch-count]");
end Usage;
procedure Check_Version_And_Help is new Check_Version_And_Help_G (Usage);
begin
Check_Version_And_Help ("GNATKR", "1992");
Count := Argument_Count;
if Count < 1 or else Count > 2 then
Usage;
raise Exit_Program;
else
-- If the length (krunch-count) argument is omitted use the system
-- default if there is one, otherwise use 8.
if Count = 1 then
Maxlen := Get_Maximum_File_Name_Length;
if Maxlen = -1 then
Maxlen := 8;
end if;
else
Maxlen := 0;
for J in Argument (2)'Range loop
if Argument (2) (J) /= ' ' then
if Argument (2) (J) not in '0' .. '9' then
Put_Line ("Illegal argument for krunch-count");
raise Exit_Program;
else
Maxlen := Maxlen * 10 +
Character'Pos (Argument (2) (J)) - Character'Pos ('0');
end if;
end if;
end loop;
-- Zero means crunch only system files
if Maxlen = 0 then
Maxlen := Natural'Last;
end if;
end if;
declare
Fname : String := Argument (1);
Klen : Natural := Fname'Length;
Extp : Boolean := False;
-- True if extension is present
Ext : Natural := 0;
-- If extension is present, points to it (init to prevent warning)
begin
-- Remove extension if present (an extension is defined as the
-- section of the file name after the last dot in the name. If
-- there is no dot in the name, then
-- name is all lower case and contains no other instances of dots)
for J in reverse 1 .. Klen loop
if Fname (J) = '.' then
Extp := True;
Ext := J;
Klen := J - 1;
exit;
end if;
end loop;
-- Fold to lower case and replace dots by dashes
for J in 1 .. Klen loop
Fname (J) := To_Lower (Fname (J));
if Fname (J) = '.' then
Fname (J) := '-';
end if;
end loop;
Krunch (Fname, Klen, Maxlen, False);
Put (Fname (1 .. Klen));
if Extp then
Put (Fname (Ext .. Fname'Length));
end if;
New_Line;
end;
end if;
Set_Exit_Status (Success);
exception
when Exit_Program =>
Set_Exit_Status (Failure);
end Gnatkr;
|
AdaCore/gpr | Ada | 1,389 | ads | ------------------------------------------------------------------------------
-- --
-- GPR2 PROJECT MANAGER --
-- --
-- Copyright (C) 2019-2023, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with GNAT; see file COPYING. If not, --
-- see <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
package GPRclean with Pure is
end GPRclean;
|
damaki/libkeccak | Ada | 2,928 | ads | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Interfaces;
with Keccak.Generic_KeccakF;
with Keccak.Generic_KeccakF.Byte_Lanes;
with Keccak.Generic_KeccakF.Lane_Complementing_Permutation;
with Keccak.Padding;
pragma Elaborate_All (Keccak.Generic_KeccakF);
pragma Elaborate_All (Keccak.Generic_KeccakF.Byte_Lanes);
pragma Elaborate_All (Keccak.Generic_KeccakF.Lane_Complementing_Permutation);
-- @summary
-- Instantiation of Keccak with a state size of 1600 bits (64-bit lanes).
package Keccak.Keccak_1600
with SPARK_Mode => On
is
package KeccakF_1600 is new Keccak.Generic_KeccakF
(Lane_Size_Log => 6,
Lane_Type => Interfaces.Unsigned_64);
subtype State is KeccakF_1600.Lane_Complemented_State;
package KeccakF_1600_Permutation is new KeccakF_1600.Lane_Complementing_Permutation
(Rotate_Left => Interfaces.Rotate_Left);
package KeccakF_1600_Lanes is new KeccakF_1600.Byte_Lanes
(Shift_Left => Interfaces.Shift_Left,
Shift_Right => Interfaces.Shift_Right);
procedure XOR_Pad101_Into_State is new Keccak.Padding.XOR_Pad101_Into_State
(State_Size_Bits => 1600,
State_Type => State,
XOR_Byte_Into_State => KeccakF_1600_Lanes.XOR_Byte_Into_State);
end Keccak.Keccak_1600;
|
zertovitch/zip-ada | Ada | 12,634 | adb | ------------------------------------------------------------------------------
-- File: ZipAda.adb
-- Description: A minimal standalone command-line zip archiving utility
-- using the Zip-Ada library.
-- Author: Gautier de Montmollin
------------------------------------------------------------------------------
-- Important changes:
--
-- ZA v. 49: password can be set
-- ZA v. 28: uses the Zip.Create package
-- ZA v. 26: modified for the new Zip_Stream package
with Ada.Calendar,
Ada.Command_Line,
Ada.Directories,
Ada.Text_IO,
Ada.Wide_Text_IO,
Ada.Float_Text_IO,
Ada.Strings.Fixed,
Ada.Strings.UTF_Encoding.Conversions,
Ada.Strings.Unbounded,
Ada.Strings.Wide_Fixed,
Ada.Characters.Handling;
with Interfaces;
with Zip_Streams;
with Zip.Compress,
Zip.Create;
with Zip_Console_IO;
with Show_License;
procedure ZipAda is
T0, T1 : Ada.Calendar.Time;
seconds_elapsed : Duration;
use Ada.Calendar, Ada.Characters.Handling, Ada.Command_Line,
Ada.Directories, Ada.Float_Text_IO,
Ada.Strings.Unbounded, Ada.Text_IO;
use Zip_Streams;
use Zip.Create;
procedure Blurb is
begin
Put_Line ("ZipAda * minimalistic standalone zipping tool.");
Put_Line ("Demo for Zip-Ada library, by G. de Montmollin");
Put_Line ("Library version " & Zip.version & " dated " & Zip.reference);
Put_Line ("URL: " & Zip.web);
Show_License (Current_Output, "zip.ads");
end Blurb;
function Cut_name (n : Wide_String; l : Natural) return Wide_String is
dots : constant Wide_String := "...";
begin
if n'Length > l then
return dots & n (n'Last - (l - 1) + dots'Length .. n'Last);
else
return n;
end if;
end Cut_name;
-- Final zipfile stream
MyStream : aliased File_Zipstream;
Info : Zip_Create_Info;
password, password_confirm : Unbounded_String;
procedure Add_1_Stream (Stream : in out Root_Zipstream_Type'Class) is
Compressed_Size : Zip.Zip_64_Data_Size_Type;
Final_Method : Natural;
use Interfaces;
begin
Put (" Adding ");
declare
maxlen : constant := 24;
Unicode_name : constant Wide_String :=
Ada.Strings.UTF_Encoding.Conversions.Convert (Get_Name (Stream));
cut : constant Wide_String := Cut_name (Unicode_name, maxlen);
use Ada.Strings.Wide_Fixed;
begin
Ada.Wide_Text_IO.Put (cut & (1 + maxlen - cut'Length) * ' ');
end;
--
Add_Stream
(Info, Stream,
Zip_Console_IO.My_feedback'Access,
To_String (password), Compressed_Size, Final_Method);
--
if Size (Stream) = 0 then
Put (" ");
end if;
Put (' ');
declare
meth : constant String := Zip.Image (Zip.Method_from_code (Final_Method));
use Ada.Strings.Fixed;
begin
Put (meth & (Zip.PKZip_method'Width - meth'Length) * ' ');
end;
if Size (Stream) > 0 then
Put (", to ");
Put (100.0 * Float (Compressed_Size) / Float (Size (Stream)), 3, 2, 0);
Put ('%');
end if;
Put_Line (", done.");
end Add_1_Stream;
function Add_zip_ext (s : String) return String is
begin
if s'Length < 4 or else
To_Upper (s (s'Last - 3 .. s'Last)) /= ".ZIP"
then
return s & ".zip";
else
return s;
end if;
end Add_zip_ext;
use Zip.Compress;
method : Compression_Method := Deflate_1;
zip_name_set : Boolean := False;
procedure Zip_a_file (arg : String) is
InStream : File_Zipstream;
begin
Set_Name (InStream, arg);
Set_Time (InStream, Ada.Directories.Modification_Time (arg));
Set_Unicode_Name_Flag (InStream, True);
Open (InStream, In_File);
Add_1_Stream (InStream);
Close (InStream);
exception
when Ada.Text_IO.Use_Error =>
Put_Line (" ** Warning: skipping invalid entry: " & arg);
end Zip_a_file;
len : Natural := 0; -- absolute directory prefix, to be skipped.
-- Recursive directory scan expanded from this example:
--
-- http://rosettacode.org/wiki/Walk_a_directory/Recursively#Ada
procedure Walk (Directory_Or_File_Name : String; Pattern : String; Level : Natural; Recursive : Boolean) is
--
procedure Process_file (Item : Directory_Entry_Type) is
begin
if Simple_Name (Item) /= "." and then Simple_Name (Item) /= ".." then
declare
fn : constant String := Full_Name (Item);
begin
Zip_a_file (fn (fn'First + len .. fn'Last));
end;
end if;
end Process_file;
--
procedure Walk_subdirectory (Item : Directory_Entry_Type) is
begin
if Simple_Name (Item) /= "." and then Simple_Name (Item) /= ".." then
Walk (Full_Name (Item), Pattern, Level + 1, True);
end if;
exception
when Ada.Directories.Name_Error => null;
end Walk_subdirectory;
--
begin
if Level = 0 then -- Figure out the length of the absolute path
len := Full_Name (".")'Length + 1;
end if;
-- Process files
Search (Directory_Or_File_Name, Pattern, (Directory => False, others => True), Process_file'Access);
-- Process subdirectories
if Recursive then
Search (Directory_Or_File_Name, "", (Directory => True, others => False), Walk_subdirectory'Access);
end if;
exception
when Ada.Directories.Name_Error => -- "unknown directory" -> probably a file.
if Level = 0 then
if Zip.Exists (Directory_Or_File_Name) then
Zip_a_file (Directory_Or_File_Name);
else
Put_Line (" ** Warning [a]: name not matched: " & Directory_Or_File_Name);
end if;
Zip_a_file (Directory_Or_File_Name);
end if;
end Walk;
type Scan_mode is (
files_only,
files_and_dirs,
files_and_dirs_recursive,
patterns_recursive
);
scan : Scan_mode := files_only;
procedure Enter_password (title : String; pwd : out Unbounded_String) is
c : Character;
begin
Put_Line (title);
loop
Get_Immediate (c);
exit when c < ' ';
pwd := pwd & c;
end loop;
end Enter_password;
Wrong_password, Overwrite_disallowed : exception;
procedure Process_argument (i : Positive) is
arg : constant String := Argument (i);
arg_zip : constant String := Add_zip_ext (arg);
answer : Character;
begin
if arg (arg'First) = '-' or arg (arg'First) = '/' then
-- Options
declare
-- Spaces to avoid too short slices
opt : constant String := arg (arg'First + 1 .. arg'Last) & " ";
eX : constant String := opt (opt'First .. opt'First + 1);
begin
if eX = "e0" then
method := Store;
elsif eX = "er" then
case opt (opt'First + 2) is
when '1' => method := Reduce_1;
when '2' => method := Reduce_2;
when '3' => method := Reduce_3;
when others => method := Reduce_4;
end case;
elsif eX = "es" then
method := Shrink;
elsif eX = "ed" then
case opt (opt'First + 2) is
when 'f' => method := Deflate_Fixed;
when '0' => method := Deflate_0;
when '1' => method := Deflate_1;
when '2' => method := Deflate_2;
when 'r' => method := Deflate_R;
when others => method := Deflate_3;
end case;
elsif eX = "el" then
case opt (opt'First + 2) is
when '0' => method := LZMA_0;
when '1' => method := LZMA_1;
when '2' => method := LZMA_2;
when others => method := LZMA_3;
end case;
elsif eX = "ep" then
case opt (opt'First + 2) is
when '1' => method := Preselection_1;
when others => method := Preselection_2;
end case;
elsif opt (opt'First .. opt'First + 3) = "dir " then
scan := Scan_mode'Max (scan, files_and_dirs);
elsif eX = "r " then
scan := files_and_dirs_recursive;
elsif eX = "r2" then
scan := patterns_recursive;
elsif opt (opt'First) = 'p' or opt (opt'First) = 's' then
-- The "-s" variant is kept for compatibility.
if arg'Length > 2 then -- Password is appended to the option
password := To_Unbounded_String (arg (arg'First + 2 .. arg'Last));
else
Enter_password ("Enter password", password);
Enter_password ("Confirm password", password_confirm);
if password /= password_confirm then
Put_Line ("Password mismatch.");
raise Wrong_password;
end if;
end if;
end if;
end;
elsif not zip_name_set then
zip_name_set := True;
if Zip.Exists (arg_zip) then
Put ("Archive " & arg_zip & " already exists! Overwrite (y/n) ?");
Get_Immediate (answer);
answer := To_Upper (answer);
Put_Line (" -> " & answer);
if answer /= 'Y' then
Put_Line ("Stopped.");
raise Overwrite_disallowed;
end if;
end if;
Put_Line ("Creating archive " & arg_zip);
Put_Line ("Method: " & Compression_Method'Image (method));
T0 := Clock;
Create_Archive (Info, MyStream'Unchecked_Access, arg_zip, method, Zip.error_on_duplicate);
else -- First real argument has already been used for archive's name
if To_Upper (arg) = To_Upper (Name (Info)) then
Put_Line (" ** Warning: skipping archive's name as entry: " & arg);
-- avoid zipping the archive itself!
-- NB: case insensitive
else
case scan is
when files_only =>
if Zip.Exists (arg) then
Zip_a_file (arg);
else
Put_Line (" ** Warning [b]: name not matched: " & arg);
end if;
when files_and_dirs =>
Walk (arg, "*", 0, False);
when files_and_dirs_recursive =>
Walk (arg, "*", 0, True);
when patterns_recursive =>
Walk (".", arg, 0, True);
end case;
end if;
end if;
end Process_argument;
begin
Blurb;
-- Set the file name encoding as UTF-8.
-- NB: GNAT (as of version CE 2019) doesn't seem to need it.
Zip_Streams.Form_For_IO_Open_and_Create := To_Unbounded_String ("encoding=utf8");
--
for i in 1 .. Argument_Count loop
Process_argument (i);
end loop;
--
-- We are done, or no archive was created.
--
if Is_Created (Info) then
Finish (Info);
T1 := Clock;
seconds_elapsed := T1 - T0;
Put ("Time elapsed : ");
Put (Float (seconds_elapsed), 4, 2, 0);
Put_Line (" sec");
else
Put_Line ("Usage: zipada [options] archive[.zip] name(s)");
New_Line;
Put_Line ("Options: -e0 : ""Store"": zero compression, archiving only (like tar)");
Put_Line (" -erN : ""Reduce"" 2-pass method, factor N = 1..4");
Put_Line (" -es : ""Shrink"" method (LZW algorithm)");
Put_Line (" -edf : ""Deflate"" method, with one ""fixed"" block (weak)");
Put_Line (" -edN : ""Deflate"" method, ""dynamic"" compression, strength N = 0..3");
Put_Line (" -elN : ""LZMA"" method, strength N = 0..3");
Put_Line (" -epN : preselection of an appropriate method, strength N = 1..2");
New_Line;
Put_Line (" NB: default method is ""Deflate"", strength 1 (-ed1)");
New_Line;
Put_Line (" -dir : name(s) may be also directories,");
Put_Line (" whose entire contents will be archived");
Put_Line (" -r : same as ""-dir"", but recursively archives full subdirectories");
Put_Line (" of the named directories as well");
Put_Line (" -r2 : search name(s) in current and all subdirectories as well;");
Put_Line (" please enclose name(s) that have wildcards with");
Put_Line (" single quotes, for example: '*.adb'");
Put_Line (" -p : define a password for encryption (user is prompted)");
Put_Line (" -pPwd : define a password for encryption (e.g. ""Pwd"")");
end if;
end ZipAda;
|
tum-ei-rcs/StratoX | Ada | 6,206 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, 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 STMicroelectronics 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 is based on: --
-- --
-- @file stm32f407xx.h et al. --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief CMSIS STM32F407xx Device Peripheral Access Layer Header File. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
-- This file provides register definitions for the STM32F4 (ARM Cortex M4F)
-- microcontrollers from ST Microelectronics.
with STM32_SVD.EXTI; use STM32_SVD.EXTI;
with STM32_SVD.SYSCFG; use STM32_SVD.SYSCFG;
with STM32.EXTI;
with STM32.Device; use STM32.Device;
package body STM32.SYSCFG is
procedure Connect_External_Interrupt
(Port : Internal_GPIO_Port;
Pin : GPIO_Pin_Index);
procedure Connect_External_Interrupt
(Port : Internal_GPIO_Port;
Pin : GPIO_Pin_Index)
is
Port_Name : constant GPIO_Port_Id := As_GPIO_Port_Id (Port);
begin
-- Finally we assign the port 'number' to the EXTI_n value within the
-- control register. We depend upon the Port enumerals' underlying
-- numeric representation values matching what the hardware expects,
-- that is, the values 0 .. n-1, which we get automatically unless
-- overridden.
case Pin is
when 0 .. 3 =>
SYSCFG_Periph.EXTICR1.EXTI.Arr (Pin) :=
GPIO_Port_Id'Enum_Rep (Port_Name);
when 4 .. 7 =>
SYSCFG_Periph.EXTICR2.EXTI.Arr (Pin) :=
GPIO_Port_Id'Enum_Rep (Port_Name);
when 8 .. 11 =>
SYSCFG_Periph.EXTICR3.EXTI.Arr (Pin) :=
GPIO_Port_Id'Enum_Rep (Port_Name);
when 12 .. 15 =>
SYSCFG_Periph.EXTICR4.EXTI.Arr (Pin) :=
GPIO_Port_Id'Enum_Rep (Port_Name);
end case;
end Connect_External_Interrupt;
--------------------------------
-- Connect_External_Interrupt --
--------------------------------
procedure Connect_External_Interrupt
(Port : Internal_GPIO_Port;
Pin : GPIO_Pin)
is
begin
Connect_External_Interrupt (Port, GPIO_Pin'Pos (Pin));
end Connect_External_Interrupt;
--------------------------------
-- Connect_External_Interrupt --
--------------------------------
procedure Connect_External_Interrupt
(Point : GPIO_Point)
is
begin
Connect_External_Interrupt (Point.Periph.all, Point.Pin);
end Connect_External_Interrupt;
--------------------------------
-- Connect_External_Interrupt --
--------------------------------
procedure Connect_External_Interrupt
(Port : Internal_GPIO_Port;
Pins : GPIO_Pins)
is
begin
for Pin of Pins loop
Connect_External_Interrupt (Port, Pin);
end loop;
end Connect_External_Interrupt;
------------------------------
-- Clear_External_Interrupt --
------------------------------
procedure Clear_External_Interrupt (Pin : GPIO_Pin) is
use STM32.EXTI;
begin
Clear_External_Interrupt (External_Line_Number'Val (GPIO_Pin'Pos (Pin)));
end Clear_External_Interrupt;
------------------------------
-- Clear_External_Interrupt --
------------------------------
procedure Clear_External_Interrupt (Pin : GPIO_Pin_Index) is
begin
EXTI_Periph.PR.PR.Arr (Pin) := True; -- Set to 1 to clear
end Clear_External_Interrupt;
end STM32.SYSCFG;
|
reznikmm/matreshka | Ada | 6,865 | adb | ------------------------------------------------------------------------------
-- --
-- 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 Ada.Command_Line;
with Ada.Directories;
with Ada.Text_IO;
with Ada.Exceptions;
with AWS.Server;
with League.Application;
package body Spikedog.Service is
-------------
-- Control --
-------------
overriding procedure Control
(Self : in out Service;
Control : Services.Control_Kind;
Status : Services.Status_Listener_Access) is
begin
case Control is
when Services.Stop =>
Status.Set_Status (Services.Stop_Pending);
Self.Stop_Flag.Release;
when others =>
null;
end case;
end Control;
----------
-- Name --
----------
overriding function Name
(Self : Service) return League.Strings.Universal_String is
begin
return Self.Application_Name;
end Name;
---------
-- Run --
---------
overriding procedure Run
(Self : in out Service;
Args : League.String_Vectors.Universal_String_Vector;
Status : Services.Status_Listener_Access)
is
Exec : constant String := Ada.Command_Line.Command_Name;
Dir : constant String := Ada.Directories.Containing_Directory (Exec);
Temp : constant League.Strings.Universal_String :=
League.Application.Environment.Value
(League.Strings.To_Universal_String ("TEMP"));
-- This is usually C:|Windows\TEMP
Server : Matreshka.Servlet_Servers.Server_Access;
File : Ada.Text_IO.File_Type;
Success : Boolean;
begin
Ada.Directories.Set_Directory (Dir);
Status.Set_Status (Services.Running);
League.Application.Set_Application_Name (Self.Application_Name);
League.Application.Set_Application_Version
(League.Strings.To_Universal_String ("0.1"));
League.Application.Set_Organization_Name
(League.Strings.To_Universal_String ("Matreshka Project"));
League.Application.Set_Organization_Domain
(League.Strings.To_Universal_String ("forge.ada-ru.org"));
Ada.Text_IO.Create
(File, Name => Temp.To_UTF_8_String & "\spikedog.log");
Ada.Text_IO.Put_Line (File, "Starting " & Args (1).To_UTF_8_String);
Ada.Text_IO.Flush (File);
Ada.Text_IO.Set_Output (File);
Ada.Text_IO.Set_Error (File);
Self.AWS_Server.Initialize;
Server := Self.AWS_Server'Unchecked_Access;
Self.Container.Initialize (Server, Success);
Ada.Text_IO.Put_Line (File, "Initialize " & Boolean'Image (Success));
Self.Stop_Flag.Acquire;
Status.Set_Status (Services.Stop_Pending);
Ada.Text_IO.Put_Line (File, "Stopping");
Ada.Text_IO.Close (File);
AWS.Server.Shutdown (AWS.Server.Get_Current.all);
-- Wait till built-in HTTP server is running.
AWS.Server.Wait (AWS.Server.No_Server);
Status.Set_Status (Services.Stopped);
exception
when E: others =>
declare
File : Ada.Text_IO.File_Type;
begin
Ada.Text_IO.Create
(File, Name => Temp.To_UTF_8_String & "\spikedog-raise.log");
Ada.Text_IO.Put_Line
(File, Ada.Exceptions.Exception_Information (E));
Ada.Text_IO.Close (File);
raise;
end;
end Run;
---------------
-- Semaphore --
---------------
protected body Semaphore is
entry Acquire when not Busy is
begin
Busy := True;
end Acquire;
entry Release when Busy is
begin
Busy := False;
end Release;
end Semaphore;
end Spikedog.Service;
|
reznikmm/matreshka | Ada | 6,498 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-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$
------------------------------------------------------------------------------
private with League.Strings;
private with XML.SAX.Attributes;
private with XML.SAX.Locators;
with XML.SAX.Writers;
with XML.Templates.Streams;
package XML.SAX.Event_Writers is
type Event_Writer is limited new XML.SAX.Writers.SAX_Writer with private;
function Get_Stream
(Self : Event_Writer'Class)
return XML.Templates.Streams.XML_Stream_Element_Vectors.Vector;
-- Returns accumulated stream.
private
type Event_Writer is limited new XML.SAX.Writers.SAX_Writer with record
Locator : XML.SAX.Locators.SAX_Locator;
Stream : XML.Templates.Streams.XML_Stream_Element_Vectors.Vector;
end record;
overriding procedure Characters
(Self : in out Event_Writer;
Text : League.Strings.Universal_String;
Success : in out Boolean);
overriding procedure Comment
(Self : in out Event_Writer;
Text : League.Strings.Universal_String;
Success : in out Boolean);
overriding procedure End_CDATA
(Self : in out Event_Writer;
Success : in out Boolean);
overriding procedure End_DTD
(Self : in out Event_Writer;
Success : in out Boolean);
overriding procedure Set_Document_Locator
(Self : in out Event_Writer;
Locator : XML.SAX.Locators.SAX_Locator);
overriding procedure End_Element
(Self : in out Event_Writer;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Success : in out Boolean);
overriding procedure End_Prefix_Mapping
(Self : in out Event_Writer;
Prefix : League.Strings.Universal_String;
Success : in out Boolean);
overriding function Error_String
(Self : Event_Writer) return League.Strings.Universal_String;
overriding procedure Ignorable_Whitespace
(Self : in out Event_Writer;
Text : League.Strings.Universal_String;
Success : in out Boolean);
overriding procedure Processing_Instruction
(Self : in out Event_Writer;
Target : League.Strings.Universal_String;
Data : League.Strings.Universal_String;
Success : in out Boolean);
overriding procedure Start_CDATA
(Self : in out Event_Writer;
Success : in out Boolean);
overriding procedure Start_DTD
(Self : in out Event_Writer;
Name : League.Strings.Universal_String;
Public_Id : League.Strings.Universal_String;
System_Id : League.Strings.Universal_String;
Success : in out Boolean);
overriding procedure Start_Element
(Self : in out Event_Writer;
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String;
Attributes : XML.SAX.Attributes.SAX_Attributes;
Success : in out Boolean);
overriding procedure Start_Prefix_Mapping
(Self : in out Event_Writer;
Prefix : League.Strings.Universal_String;
Namespace_URI : League.Strings.Universal_String;
Success : in out Boolean);
end XML.SAX.Event_Writers;
|
DrenfongWong/tkm-rpc | Ada | 405 | ads | with Ada.Unchecked_Conversion;
package Tkmrpc.Response.Cfg.Tkm_Limits.Convert is
function To_Response is new Ada.Unchecked_Conversion (
Source => Tkm_Limits.Response_Type,
Target => Response.Data_Type);
function From_Response is new Ada.Unchecked_Conversion (
Source => Response.Data_Type,
Target => Tkm_Limits.Response_Type);
end Tkmrpc.Response.Cfg.Tkm_Limits.Convert;
|
zhmu/ananas | Ada | 3,180 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . V A L _ E N U M _ 1 6 --
-- --
-- S p e c --
-- --
-- Copyright (C) 2021-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. --
-- --
------------------------------------------------------------------------------
-- Instantiation of System.Value_N for enumeration types whose names table
-- has a length that fits in a 16-bit but not an 8-bit integer.
with Interfaces;
with System.Value_N;
package System.Val_Enum_16 is
pragma Preelaborate;
package Impl is new Value_N (Interfaces.Integer_16);
function Value_Enumeration_16
(Names : String;
Indexes : System.Address;
Hash : Impl.Hash_Function_Ptr;
Num : Natural;
Str : String)
return Natural
renames Impl.Value_Enumeration;
function Valid_Value_Enumeration_16
(Names : String;
Indexes : System.Address;
Hash : Impl.Hash_Function_Ptr;
Num : Natural;
Str : String)
return Boolean
renames Impl.Valid_Value_Enumeration;
end System.Val_Enum_16;
|
jrmarino/AdaBase | Ada | 1,201 | adb | with AdaBase;
with Connect;
with Ada.Text_IO;
with AdaBase.Logger.Facility;
procedure Fruit3 is
package CON renames Connect;
package TIO renames Ada.Text_IO;
package ALF renames AdaBase.Logger.Facility;
numrows : AdaBase.Affected_Rows;
log : constant String := "/tmp/fruit3.test.log";
cmd : constant String := "DELETE FROM fruits WHERE color = 'red'";
begin
CON.DR.command_standard_logger (device => ALF.file, action => ALF.attach);
CON.DR.set_logger_filename (filename => log);
TIO.Put_Line ("The " & log & " has been attached.");
CON.connect_database;
numrows := CON.DR.execute (sql => cmd);
TIO.Put_Line ("SQL: " & cmd);
TIO.Put_Line ("Result: Deleted" & numrows'Img & " rows");
CON.DR.command_standard_logger (device => ALF.file, action => ALF.detach);
TIO.Put_Line ("The " & log & " has been deattached.");
numrows := CON.DR.execute (sql => cmd);
TIO.Put_Line ("Second execution:");
TIO.Put_Line ("Result: Deleted" & numrows'Img & " rows");
CON.DR.command_standard_logger (device => ALF.file, action => ALF.attach);
TIO.Put_Line ("The " & log & " has been attached.");
CON.DR.rollback;
CON.DR.disconnect;
end Fruit3;
|
reznikmm/gela | Ada | 3,238 | adb | with Interfaces.C;
-- with League.Strings.Internals;
-- with Matreshka.Internals.Utf16;
package body Gela.XSLT is
use Interfaces;
type xmlDocPtr is access all Integer;
type xsltStylesheetPtr is access all Integer;
type Buffer_Access is access all C.char_array (1 .. C.size_t'Last);
type Buffer_Access_Access is access all Buffer_Access;
type Int_Ptr is access all C.int;
pragma Linker_Options ("-lxml2");
pragma Linker_Options ("-lxslt");
-- function xmlReadMemory
-- (Buffer : Matreshka.Internals.Utf16.Utf16_String;
-- Size : Interfaces.C.int;
-- Base : Interfaces.C.char_array;
-- Encoding : Interfaces.C.char_array;
-- Options : Interfaces.C.int)
-- return xmlDocPtr;
-- pragma Import (C, xmlReadMemory, "xmlReadMemory");
function xmlParseFile (XML : C.char_array) return xmlDocPtr;
pragma Import (C, xmlParseFile, "xmlParseFile");
-- function xsltParseStylesheetDoc
-- (XML : Interfaces.C.char_array)
-- return xsltStylesheetPtr;
-- pragma Import (C, xsltParseStylesheetDoc, "xsltParseStylesheetDoc");
function xsltParseStylesheetFile
(File : C.char_array)
return xsltStylesheetPtr;
pragma Import (C, xsltParseStylesheetFile, "xsltParseStylesheetFile");
function xsltApplyStylesheet
(Style : xsltStylesheetPtr;
XML : xmlDocPtr;
Params : xmlDocPtr)
return xmlDocPtr;
pragma Import (C, xsltApplyStylesheet, "xsltApplyStylesheet");
function xsltSaveResultToString
(Buffer : Buffer_Access_Access;
Size : Int_Ptr;
XML : xmlDocPtr;
Style : xsltStylesheetPtr)
return C.int;
pragma Import (C, xsltSaveResultToString, "xsltSaveResultToString");
procedure xmlFreeDoc (Doc : xmlDocPtr);
pragma Import (C, xmlFreeDoc, "xmlFreeDoc");
procedure xsltFreeStylesheet (Doc : xsltStylesheetPtr);
pragma Import (C, xsltFreeStylesheet, "xsltFreeStylesheet");
procedure free (Doc : Buffer_Access);
pragma Import (C, free, "free");
function Transform
(XML : League.Strings.Universal_String;
XSL : League.Strings.Universal_String)
return League.Strings.Universal_String
is
use type C.int;
XML_Name : constant C.char_array := C.To_C (XML.To_UTF_8_String);
XSL_Name : constant C.char_array := C.To_C (XSL.To_UTF_8_String);
XML_Doc : xmlDocPtr;
Result : xmlDocPtr;
Style : xsltStylesheetPtr;
Buffer : aliased Buffer_Access;
Size : aliased C.int;
X : C.int;
begin
XML_Doc := xmlParseFile (XML_Name);
Style := xsltParseStylesheetFile (XSL_Name);
Result := xsltApplyStylesheet (Style, XML_Doc, null);
X := xsltSaveResultToString
(Buffer => Buffer'Unchecked_Access,
Size => Size'Unchecked_Access,
XML => Result,
Style => Style);
pragma Assert (X = 0);
xmlFreeDoc (XML_Doc);
xsltFreeStylesheet (Style);
return Result : constant League.Strings.Universal_String
:= League.Strings.From_UTF_8_String
(C.To_Ada (Buffer (1 .. C.size_t (Size)), False))
do
free (Buffer);
end return;
end Transform;
end Gela.XSLT;
|
charlie5/cBound | Ada | 1,509 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_get_screen_saver_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_get_screen_saver_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_get_screen_saver_request_t.Item,
Element_Array => xcb.xcb_get_screen_saver_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_get_screen_saver_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_get_screen_saver_request_t.Pointer,
Element_Array => xcb.xcb_get_screen_saver_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_get_screen_saver_request_t;
|
reznikmm/matreshka | Ada | 4,926 | 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_01F4 is
pragma Preelaborate;
Group_01F4 : aliased constant Core_Second_Stage
:= (16#A0# => -- 01F4A0
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#A2# => -- 01F4A2
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#A4# => -- 01F4A4
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#AF# => -- 01F4AF
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#B1# .. 16#B2# => -- 01F4B1 .. 01F4B2
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#FF# => -- 01F4FF
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
others =>
(Other_Symbol, Neutral,
Other, Other, Other, Ideographic,
(Grapheme_Base => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_01F4;
|
tum-ei-rcs/StratoX | Ada | 4,762 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . B B . T I M I N G _ E V E N T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2011-2013, AdaCore --
-- --
-- GNARL 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. GNARL 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. --
-- --
-- --
-- --
-- --
-- --
-- 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/>. --
-- --
------------------------------------------------------------------------------
with System.BB.Time;
with System.Multiprocessors;
package System.Bb.Timing_Events
with SPARK_Mode => On is
pragma Preelaborate;
type Timing_Event;
type Timing_Event_Handler
is access procedure (Event : in out Timing_Event'Class);
type Timing_Event_Access is access all Timing_Event;
type Timing_Event is tagged limited record
Timeout : System.BB.Time.Time := System.BB.Time.Time'First;
-- The time at which the user's handler should be invoked when the event
-- is "set" (i.e., when Handler is not null).
Handler : Timing_Event_Handler := null;
-- An access value designating the protected procedure to be invoked at
-- the Timeout time in the future. When this value is null the event is
-- said to be "cleared" and no timeout is processed.
Next : Timing_Event_Access := null;
-- Next event in the list
Prev : Timing_Event_Access := null;
-- Previous event in the list
CPU : System.Multiprocessors.CPU;
-- Owner of the timing event
end record;
procedure Set_Handler
(Event : in out Timing_Event;
At_Time : System.BB.Time.Time;
Handler : Timing_Event_Handler);
-- Associate the handler Handler with the event Event: if Handler is null
-- the event is cleared; otherwise, it is set, and the execution time for
-- the event to be At_Time.
--
-- A call of a procedure Set_Handler for an event that is already set
-- replaces the handler and the time of execution; if Handler is not null,
-- the event remains set.
function Current_Handler
(Event : Timing_Event) return Timing_Event_Handler;
-- Return the handler associated with Event if that event is set, null
-- otherwise.
procedure Cancel_Handler
(Event : in out Timing_Event;
Cancelled : out Boolean);
-- Clear the event if it is set. Cancelled is assigned True if the event
-- was set prior to it being cleared; otherwise, it is assigned False.
function Time_Of_Event (Event : Timing_Event) return System.BB.Time.Time;
-- Return the time of the event if the event is set, Time'First otherwise
function Get_Next_Timeout
(CPU_Id : System.Multiprocessors.CPU) return System.BB.Time.Time;
pragma Inline (Get_Next_Timeout);
-- Return the next expiration time for all timing events associated with
-- CPU_Id. Return Time'Last if no timing event is pending for CPU_Id.
procedure Execute_Expired_Timing_Events (Now : System.BB.Time.Time);
-- Execute all timing events whose expiration time is before Now
end System.BB.Timing_Events;
|
mirror/ncurses | Ada | 7,011 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Terminfo --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright 2020 Thomas E. Dickey --
-- Copyright 2000-2006,2009 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.7 $
-- $Date: 2020/02/02 23:34:34 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with Ada.Unchecked_Conversion;
package body Terminal_Interface.Curses.Terminfo is
function Is_MinusOne_Pointer (P : chars_ptr) return Boolean;
function Is_MinusOne_Pointer (P : chars_ptr) return Boolean is
type Weird_Address is new System.Storage_Elements.Integer_Address;
Invalid_Pointer : constant Weird_Address := -1;
function To_Weird is new Ada.Unchecked_Conversion
(Source => chars_ptr, Target => Weird_Address);
begin
if To_Weird (P) = Invalid_Pointer then
return True;
else
return False;
end if;
end Is_MinusOne_Pointer;
pragma Inline (Is_MinusOne_Pointer);
------------------------------------------------------------------------------
function Get_Flag (Name : String) return Boolean
is
function tigetflag (id : char_array) return Curses_Bool;
pragma Import (C, tigetflag);
Txt : char_array (0 .. Name'Length);
Length : size_t;
begin
To_C (Name, Txt, Length);
if tigetflag (Txt) = Curses_Bool (Curses_True) then
return True;
else
return False;
end if;
end Get_Flag;
------------------------------------------------------------------------------
procedure Get_String (Name : String;
Value : out Terminfo_String;
Result : out Boolean)
is
function tigetstr (id : char_array) return chars_ptr;
pragma Import (C, tigetstr, "tigetstr");
Txt : char_array (0 .. Name'Length);
Length : size_t;
Txt2 : chars_ptr;
begin
To_C (Name, Txt, Length);
Txt2 := tigetstr (Txt);
if Txt2 = Null_Ptr then
Result := False;
elsif Is_MinusOne_Pointer (Txt2) then
raise Curses_Exception;
else
Value := Terminfo_String (Fill_String (Txt2));
Result := True;
end if;
end Get_String;
------------------------------------------------------------------------------
function Has_String (Name : String) return Boolean
is
function tigetstr (id : char_array) return chars_ptr;
pragma Import (C, tigetstr, "tigetstr");
Txt : char_array (0 .. Name'Length);
Length : size_t;
Txt2 : chars_ptr;
begin
To_C (Name, Txt, Length);
Txt2 := tigetstr (Txt);
if Txt2 = Null_Ptr then
return False;
elsif Is_MinusOne_Pointer (Txt2) then
raise Curses_Exception;
else
return True;
end if;
end Has_String;
------------------------------------------------------------------------------
function Get_Number (Name : String) return Integer is
function tigetstr (s : char_array) return C_Int;
pragma Import (C, tigetstr);
Txt : char_array (0 .. Name'Length);
Length : size_t;
begin
To_C (Name, Txt, Length);
return Integer (tigetstr (Txt));
end Get_Number;
------------------------------------------------------------------------------
procedure Put_String (Str : Terminfo_String;
affcnt : Natural := 1;
putc : putctype := null) is
function tputs (str : char_array;
affcnt : C_Int;
putc : putctype) return C_Int;
function putp (str : char_array) return C_Int;
pragma Import (C, tputs);
pragma Import (C, putp);
Txt : char_array (0 .. Str'Length);
Length : size_t;
Err : C_Int;
begin
To_C (String (Str), Txt, Length);
if putc = null then
Err := putp (Txt);
else
Err := tputs (Txt, C_Int (affcnt), putc);
end if;
if Err = Curses_Err then
raise Curses_Exception;
end if;
end Put_String;
end Terminal_Interface.Curses.Terminfo;
|
yannickmoy/atomic | Ada | 11,933 | ads | generic
type T is mod <>;
package Atomic.Generic64
with Preelaborate, Spark_Mode => On
is
-- Based on GCC atomic built-ins. See:
-- https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
--
-- The specification is exactly the same for all sizes of data (8, 16, 32,
-- 64).
type Instance is limited private;
-- This type is limited and private, it can only be manipulated using the
-- primitives below.
function Init (Val : T) return Instance
with Post => Value (Init'Result) = Val;
-- Can be used to initialize an atomic instance:
--
-- A : Atomic.Unsigned_8.Instance := Atomic.Unsigned_8.Init (0);
function Value (This : Instance) return T
with Ghost;
-- Ghost function to get the value of an instance without needing it
-- aliased. This function can be used in contracts for instance.
-- This doesn't use the atomic built-ins.
function Load (This : aliased Instance;
Order : Mem_Order := Seq_Cst)
return T
with Pre => Order in Relaxed | Consume | Acquire | Seq_Cst,
Post => Load'Result = Value (This);
procedure Store (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Pre => Order in Relaxed | Release | Seq_Cst,
Post => Value (This) = Val;
procedure Exchange (This : aliased in out Instance;
Val : T;
Old : out T;
Order : Mem_Order := Seq_Cst)
with Pre => Order in Relaxed | Acquire | Release | Acq_Rel | Seq_Cst,
Post => Old = Value (This)'Old and then Value (This) = Val;
procedure Compare_Exchange (This : aliased in out Instance;
Expected : T;
Desired : T;
Weak : Boolean;
Success : out Boolean;
Success_Order : Mem_Order := Seq_Cst;
Failure_Order : Mem_Order := Seq_Cst)
with Pre => Failure_Order in Relaxed | Consume | Acquire | Seq_Cst
and then
not Stronger (Failure_Order, Success_Order),
Post => Success = (Value (This)'Old = Expected)
and then
(if Success then Value (This) = Desired);
procedure Add (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Post => Value (This) = Value (This)'Old + Val;
procedure Sub (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Post => Value (This) = Value (This)'Old - Val;
procedure Op_And (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Post => Value (This) = (Value (This)'Old and Val);
procedure Op_XOR (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Post => Value (This) = (Value (This)'Old xor Val);
procedure Op_OR (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Post => Value (This) = (Value (This)'Old or Val);
procedure NAND (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Post => Value (This) = not (Value (This)'Old and Val);
procedure Add_Fetch (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = (Value (This)'Old + Val)
and then Value (This) = Result;
procedure Sub_Fetch (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = (Value (This)'Old - Val)
and then Value (This) = Result;
procedure And_Fetch (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = (Value (This)'Old and Val)
and then Value (This) = Result;
procedure XOR_Fetch (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = (Value (This)'Old xor Val)
and then Value (This) = Result;
procedure OR_Fetch (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = (Value (This)'Old or Val)
and then Value (This) = Result;
procedure NAND_Fetch (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = not (Value (This)'Old and Val)
and then Value (This) = Result;
procedure Fetch_Add (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and Value (This) = (Value (This)'Old + Val);
procedure Fetch_Sub (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and Value (This) = (Value (This)'Old - Val);
procedure Fetch_And (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and Value (This) = (Value (This)'Old and Val);
procedure Fetch_XOR (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and Value (This) = (Value (This)'Old xor Val);
procedure Fetch_OR (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and Value (This) = (Value (This)'Old or Val);
procedure Fetch_NAND (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and Value (This) = not (Value (This)'Old and Val);
-- NOT SPARK compatible --
function Exchange (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => Exchange'Result = Value (This)'Old
and then Value (This) = Val;
function Compare_Exchange (This : aliased in out Instance;
Expected : T;
Desired : T;
Weak : Boolean;
Success_Order : Mem_Order := Seq_Cst;
Failure_Order : Mem_Order := Seq_Cst)
return Boolean
with SPARK_Mode => Off,
Post =>
Compare_Exchange'Result = (Value (This)'Old = Expected)
and then
(if Compare_Exchange'Result then Value (This) = Desired);
function Add_Fetch (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => Add_Fetch'Result = (Value (This)'Old + Val)
and then Value (This) = Add_Fetch'Result;
function Sub_Fetch (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => Sub_Fetch'Result = (Value (This)'Old - Val)
and then Value (This) = Sub_Fetch'Result;
function And_Fetch (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => And_Fetch'Result = (Value (This)'Old and Val)
and then Value (This) = And_Fetch'Result;
function XOR_Fetch (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => XOR_Fetch'Result = (Value (This)'Old xor Val)
and then Value (This) = XOR_Fetch'Result;
function OR_Fetch (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => OR_Fetch'Result = (Value (This)'Old or Val)
and then Value (This) = OR_Fetch'Result;
function NAND_Fetch (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => NAND_Fetch'Result = not (Value (This)'Old and Val)
and then Value (This) = NAND_Fetch'Result;
function Fetch_Add (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off;
function Fetch_Sub (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off;
function Fetch_And (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off;
function Fetch_XOR (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off;
function Fetch_OR (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off;
function Fetch_NAND (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off;
private
type Instance is new T;
----------
-- Init --
----------
function Init (Val : T) return Instance
is (Instance (Val));
-----------
-- Value --
-----------
function Value (This : Instance) return T
is (T (This));
pragma Inline (Init);
pragma Inline (Load);
pragma Inline (Store);
pragma Inline (Exchange);
pragma Inline (Compare_Exchange);
pragma Inline (Add);
pragma Inline (Sub);
pragma Inline (Add_Fetch);
pragma Inline (Sub_Fetch);
pragma Inline (Fetch_Add);
pragma Inline (Fetch_Sub);
pragma Inline (Op_And);
pragma Inline (Op_XOR);
pragma Inline (Op_OR);
pragma Inline (NAND);
pragma Inline (And_Fetch);
pragma Inline (XOR_Fetch);
pragma Inline (OR_Fetch);
pragma Inline (NAND_Fetch);
pragma Inline (Fetch_And);
pragma Inline (Fetch_XOR);
pragma Inline (Fetch_OR);
pragma Inline (Fetch_NAND);
end Atomic.Generic64;
|
sungyeon/drake | Ada | 8,345 | adb | pragma Check_Policy (Trace => Ignore);
with Ada.Unchecked_Conversion;
with System.Address_To_Named_Access_Conversions;
with System.Formatting.Address;
with System.Stack;
with System.Storage_Map;
with System.Unwind.Occurrences;
with System.Unwind.Standard;
with C.basetsd;
with C.vadefs;
with C.winbase;
with C.windef;
with C.winnls;
package body System.Unwind.Mapping is
pragma Suppress (All_Checks);
use type C.size_t;
use type C.windef.DWORD;
use type C.winnt.struct_EXCEPTION_REGISTRATION_RECORD_ptr;
package LPSTR_Conv is
new Address_To_Named_Access_Conversions (C.char, C.winnt.LPSTR);
package LPWSTR_Conv is
new Address_To_Named_Access_Conversions (C.winnt.WCHAR, C.winnt.LPWSTR);
-- implementation
function New_Machine_Occurrence_From_SEH (
Exception_Record : C.winnt.struct_EXCEPTION_RECORD_ptr)
return Representation.Machine_Occurrence_Access
is
function Cast is
new Ada.Unchecked_Conversion (C.windef.HMODULE, C.windef.LPCVOID);
function Cast is
new Ada.Unchecked_Conversion (C.winnt.LPWSTR_ptr, C.winnt.LPTSTR);
function Cast is
new Ada.Unchecked_Conversion (
C.basetsd.ULONG_PTR_ptr,
C.vadefs.va_list_ptr);
-- space for overflow detection, decided for CB1010C
Stack_Overflow_Space : constant :=
(Standard'Address_Size / Standard'Storage_Unit) * 8 * 1024 * 1024;
-- the components of the exception
Code : constant C.windef.DWORD := Exception_Record.ExceptionCode;
Eexception_Id : Exception_Data_Access;
Stack_Guard : Address := Null_Address;
begin
pragma Check (Trace, Ada.Debug.Put ("enter"));
case Code is
when C.winbase.EXCEPTION_ACCESS_VIOLATION => -- 0xC0000005
-- get stack range
declare
Stack_Top, Stack_Bottom : Address;
AV_Address : constant Address :=
System'To_Address (
Exception_Record.ExceptionInformation (1));
begin
Stack.Get (Top => Stack_Top, Bottom => Stack_Bottom);
if AV_Address >= Stack_Top - Stack_Overflow_Space
and then AV_Address < Stack_Bottom
then -- stack overflow
Stack_Guard := Stack_Top + 4096;
Eexception_Id := Standard.Storage_Error'Access;
else
Eexception_Id := Standard.Program_Error'Access;
end if;
end;
when C.winbase.EXCEPTION_INVALID_HANDLE => -- 0xC0000008
Eexception_Id := Standard.Constraint_Error'Access;
when C.winbase.EXCEPTION_ARRAY_BOUNDS_EXCEEDED -- 0xC000008C
| C.winbase.EXCEPTION_FLT_DENORMAL_OPERAND -- 0xC000008D
| C.winbase.EXCEPTION_FLT_DIVIDE_BY_ZERO -- 0xC000008E
| C.winbase.EXCEPTION_FLT_INEXACT_RESULT -- 0xC000008F
| C.winbase.EXCEPTION_FLT_INVALID_OPERATION -- 0xC0000090
| C.winbase.EXCEPTION_FLT_OVERFLOW -- 0xC0000091
| C.winbase.EXCEPTION_FLT_STACK_CHECK -- 0xC0000092
| C.winbase.EXCEPTION_FLT_UNDERFLOW -- 0xC0000093
| C.winbase.EXCEPTION_INT_DIVIDE_BY_ZERO -- 0xC0000094
| C.winbase.EXCEPTION_INT_OVERFLOW => -- 0xC0000095
Eexception_Id := Standard.Constraint_Error'Access;
when C.winbase.EXCEPTION_STACK_OVERFLOW => -- 0xC00000FD
-- get stack range
declare
Dummy : Address;
begin
Stack.Get (Top => Stack_Guard, Bottom => Dummy);
end;
Stack_Guard := Stack_Guard + 4096;
-- Storage_Error
Eexception_Id := Standard.Storage_Error'Access;
when others =>
Eexception_Id := null;
end case;
if Eexception_Id /= null then
declare
Message : String (1 .. 256);
Message_Last : Natural;
Wide_Message : aliased C.winnt.LPWSTR;
Wide_Message_Length : C.windef.DWORD;
begin
Wide_Message_Length := C.winbase.FormatMessage (
dwFlags =>
C.winbase.FORMAT_MESSAGE_FROM_HMODULE
or C.winbase.FORMAT_MESSAGE_ARGUMENT_ARRAY
or C.winbase.FORMAT_MESSAGE_ALLOCATE_BUFFER,
lpSource => Cast (Storage_Map.NTDLL),
dwMessageId => Code,
dwLanguageId => C.winnt.LANG_USER_DEFAULT,
lpBuffer => Cast (Wide_Message'Unchecked_Access),
nSize => 0,
Arguments =>
Cast (Exception_Record.ExceptionInformation (0)'Access));
declare
Wide_Message_Last : constant Natural :=
Integer (Wide_Message_Length);
Wide_Message_All : Wide_String (1 .. Wide_Message_Last);
for Wide_Message_All'Address use
LPWSTR_Conv.To_Address (Wide_Message);
begin
if Wide_Message_All (
Wide_Message_Last - 2 .. Wide_Message_Last) =
"""0x"
and then Code = C.winbase.EXCEPTION_ACCESS_VIOLATION
then
-- bug of FormatString ???
-- there are some reports in stackoverflow.com
-- perhaps, FormatString can not convert %p in
-- 'The instruction at %p referenced memory at %p.'
Message (1 .. 21) := "The instruction at 0x";
Message_Last := 21;
Formatting.Address.Image (
Address (Exception_Record.ExceptionAddress),
Message (
Message_Last + 1 ..
Message'Last
+ Formatting.Address.Address_String'Length),
Set => Formatting.Lower_Case);
Message_Last :=
Message_Last + Formatting.Address.Address_String'Length;
Message (Message_Last + 1 .. Message_Last + 24) :=
" referenced memory at 0x";
Message_Last := Message_Last + 24;
Formatting.Address.Image (
System'To_Address (
Exception_Record.ExceptionInformation (1)),
Message (
Message_Last + 1 ..
Message_Last
+ Formatting.Address.Address_String'Length),
Set => Formatting.Lower_Case);
Message_Last :=
Message_Last + Formatting.Address.Address_String'Length;
Message (Message_Last + 1) := '.';
Message_Last := Message_Last + 1;
else
Message_Last := Natural (
C.winnls.WideCharToMultiByte (
C.winnls.CP_UTF8,
0,
Wide_Message,
C.signed_int (Wide_Message_Length),
LPSTR_Conv.To_Pointer (Message'Address),
Message'Length,
null,
null));
end if;
end;
declare
Dummy : C.windef.HLOCAL;
begin
Dummy := C.winbase.LocalFree (
C.windef.HLOCAL (LPWSTR_Conv.To_Address (Wide_Message)));
end;
declare
Result : constant
not null Representation.Machine_Occurrence_Access :=
Occurrences.New_Machine_Occurrence (
Stack_Guard => Stack_Guard);
begin
Occurrences.Set_Exception_Message (
Id => Eexception_Id,
Message => Message,
X => Result.Occurrence);
Occurrences.Backtrace (Result.Occurrence);
pragma Check (Trace, Ada.Debug.Put ("leave, mapped"));
return Result;
end;
end;
else
pragma Check (Trace, Ada.Debug.Put ("leave, unmapped!"));
return null; -- would not be handled in Ada
end if;
end New_Machine_Occurrence_From_SEH;
end System.Unwind.Mapping;
|
charlie5/cBound | Ada | 1,675 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_render_query_pict_index_values_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
minor_opcode : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
format : aliased xcb.xcb_render_pictformat_t;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_render_query_pict_index_values_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_query_pict_index_values_request_t.Item,
Element_Array =>
xcb.xcb_render_query_pict_index_values_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_render_query_pict_index_values_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_query_pict_index_values_request_t.Pointer,
Element_Array =>
xcb.xcb_render_query_pict_index_values_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_render_query_pict_index_values_request_t;
|
alire-project/GNAT-FSF-builds | Ada | 116 | adb | with Plop;
procedure Hello is
B : Plop.B;
C : Plop.C;
begin
Plop.Print (B);
Plop.Print (C);
end Hello;
|
tyudosen/HeterogeneousStack | Ada | 1,968 | adb | with Ada.Text_IO, Ada.Unchecked_Deallocation;
use Ada.Text_IO;
package body hetro_stack is
procedure Free is new Ada.Unchecked_Deallocation(hetroStackElem, hetroStackElemPtr);
procedure PushFront(Stack: in out hetroStack; Data: ItemPt) is
Pt : hetroStackElemPtr := new hetroStackElem;
begin
Pt.Data := Data;
Pt.RightPtr := Stack.Top.RightPtr;
Pt.LeftPtr := Stack.Top;
Pt.RightPtr.LeftPtr := Pt;
Pt.LeftPtr.RightPtr := Pt;
Stack.Count := Stack.Count + 1;
end PushFront;
procedure SetHeadNode(Stack: in out hetroStack) is
HeadNode : hetroStackElemPtr := new hetroStackElem;
begin
HeadNode.RightPtr := HeadNode;
HeadNode.LeftPtr := HeadNode;
Stack.Top := HeadNode;
end SetHeadNode;
procedure PushRear(Stack: in out hetroStack; Data: ItemPt ) is
Pt: hetroStackElemPtr := new hetroStackElem;
begin
Pt.Data := Data;
Pt.LeftPtr := Stack.Top.LeftPtr;
Pt.RightPtr := Stack.Top;
Pt.LeftPtr.RightPtr := Pt;
Pt.RightPtr.LeftPtr := Pt;
Stack.Count := Stack.Count + 1;
end PushRear;
function StackSize(Stack: hetroStack) return integer is
begin
return Stack.Count;
end StackSize;
procedure PrintList(List: in hetroStack) is
Pt : hetroStackElemPtr;
begin
Pt := List.Top.RightPtr;
while Pt /= List.Top loop
PrintData(Pt.Data.all);
Pt := Pt.RightPtr;
end loop;
end PrintList;
function RemoveSpecificNode(Stack: in out hetroStack; Data: ItemPt) return ItemPt is
Pt: hetroStackElemPtr;
Item : ItemPt;
begin
Pt := Stack.Top.RightPtr;
while Pt /= Stack.Top loop
if Data.all = Pt.Data.all then
Pt.LeftPtr.RightPtr := Pt.RightPtr;
Pt.RightPtr.LeftPtr := Pt.LeftPtr;
Item := Pt.Data;
Free(Pt);
Stack.Count := Stack.Count - 1;
return Item;
end if;
Pt := Pt.RightPtr;
end loop;
return null;
end RemoveSpecificNode;
end hetro_stack; |
zhmu/ananas | Ada | 2,085 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- B I N D U S G --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Procedure to generate screen of usage information if no file name present
package Bindusg is
procedure Display;
-- Display binder usage if not already displayed
end Bindusg;
|
strenkml/EE368 | Ada | 1,819 | adb |
package body Benchmark.QSort is
function Create_QSort return Benchmark_Pointer is
begin
return new QSort_Type;
end Create_QSort;
procedure Set_Argument(benchmark : in out QSort_Type;
arg : in String) is
value : constant String := Extract_Argument(arg);
begin
if Check_Argument(arg, "size") then
benchmark.size := Positive'Value(value);
else
Set_Argument(Benchmark_Type(benchmark), arg);
end if;
exception
when others =>
raise Invalid_Argument;
end Set_Argument;
procedure Sort(benchmark : in QSort_Type;
left, right : in Integer) is
a : Integer := left;
b : Integer := right;
av : Integer;
bv : Integer;
pivot : constant Integer := Read_Value(benchmark, left);
begin
loop
while a <= right loop
av := Read_Value(benchmark, a);
exit when av >= pivot;
a := a + 1;
end loop;
while b >= left loop
bv := Read_Value(benchmark, b);
exit when bv <= pivot;
b := b - 1;
end loop;
exit when a > b;
Write_Value(benchmark, a, bv);
Write_Value(benchmark, b, av);
a := a + 1;
b := b - 1;
end loop;
if a - 1 > left then
Sort(benchmark, left, a - 1);
end if;
if right > a then
Sort(benchmark, a, right);
end if;
end Sort;
procedure Run(benchmark : in QSort_Type) is
begin
-- Generate the data set.
for i in 0 .. benchmark.size - 1 loop
Write_Value(benchmark, i, Get_Random(benchmark));
end loop;
-- Sort in place.
Sort(benchmark, 0, benchmark.size - 1);
end Run;
end Benchmark.QSort;
|
stcarrez/ada-enet | Ada | 1,015 | adb | -----------------------------------------------------------------------
-- net-utils-random -- Network utilities random operation
-- 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 STM32.RNG.Interrupts;
separate (Net.Utils)
function Random return Uint32 is
begin
return Uint32 (STM32.RNG.Interrupts.Random);
end Random;
|
AdaCore/libadalang | Ada | 53 | adb | with D;
procedure Test is
begin
D.Main;
end Test;
|
reznikmm/matreshka | Ada | 3,793 | 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 ODF.Constants;
package body Matreshka.ODF_Attributes.Style.Parent_Style_Name is
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Parent_Style_Name_Node)
return League.Strings.Universal_String is
begin
return ODF.Constants.Parent_Style_Name_Name;
end Get_Local_Name;
end Matreshka.ODF_Attributes.Style.Parent_Style_Name;
|
AdaCore/training_material | Ada | 358 | adb | procedure Main is
--$ begin cut
package P is
type T is limited private;
-- Does not need to declare any capability
-- Declares a constraint: limited
private
type T is tagged null record;
-- Declares a capability: tagged
-- Does not need to declare any constraint
end P;
--$ end cut
begin
null;
end Main;
|
reznikmm/matreshka | Ada | 14,964 | 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_000D is
pragma Preelaborate;
Group_000D : aliased constant Core_Second_Stage
:= (16#00# => -- 0D00
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#01# => -- 0D01
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#02# .. 16#03# => -- 0D02 .. 0D03
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#04# => -- 0D04
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#0D# => -- 0D0D
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#11# => -- 0D11
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#3B# .. 16#3C# => -- 0D3B .. 0D3C
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#3E# => -- 0D3E
(Spacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Other_Grapheme_Extend
| Alphabetic
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#3F# .. 16#40# => -- 0D3F .. 0D40
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#41# .. 16#44# => -- 0D41 .. 0D44
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#45# => -- 0D45
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#46# .. 16#48# => -- 0D46 .. 0D48
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#49# => -- 0D49
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#4A# .. 16#4C# => -- 0D4A .. 0D4C
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#4D# => -- 0D4D
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| Grapheme_Link
| ID_Continue
| XID_Continue => True,
others => False)),
16#4F# .. 16#56# => -- 0D4F .. 0D56
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#57# => -- 0D57
(Spacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Other_Grapheme_Extend
| Alphabetic
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#58# .. 16#5F# => -- 0D58 .. 0D5F
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#62# .. 16#63# => -- 0D62 .. 0D63
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#64# .. 16#65# => -- 0D64 .. 0D65
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#66# .. 16#6F# => -- 0D66 .. 0D6F
(Decimal_Number, Neutral,
Other, Numeric, Numeric, Numeric,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#70# .. 16#75# => -- 0D70 .. 0D75
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#76# .. 16#78# => -- 0D76 .. 0D78
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#79# => -- 0D79
(Other_Symbol, Neutral,
Other, Other, Other, Postfix_Numeric,
(Grapheme_Base => True,
others => False)),
16#80# .. 16#81# => -- 0D80 .. 0D81
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#82# .. 16#83# => -- 0D82 .. 0D83
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#84# => -- 0D84
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#97# .. 16#99# => -- 0D97 .. 0D99
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#B2# => -- 0DB2
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#BC# => -- 0DBC
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#BE# .. 16#BF# => -- 0DBE .. 0DBF
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#C7# .. 16#C9# => -- 0DC7 .. 0DC9
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#CA# => -- 0DCA
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| Grapheme_Link
| ID_Continue
| XID_Continue => True,
others => False)),
16#CB# .. 16#CE# => -- 0DCB .. 0DCE
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#CF# => -- 0DCF
(Spacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Other_Grapheme_Extend
| Alphabetic
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#D0# .. 16#D1# => -- 0DD0 .. 0DD1
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#D2# .. 16#D4# => -- 0DD2 .. 0DD4
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#D5# => -- 0DD5
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#D6# => -- 0DD6
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#D7# => -- 0DD7
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#D8# .. 16#DE# => -- 0DD8 .. 0DDE
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#DF# => -- 0DDF
(Spacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Other_Grapheme_Extend
| Alphabetic
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#E0# .. 16#E5# => -- 0DE0 .. 0DE5
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#E6# .. 16#EF# => -- 0DE6 .. 0DEF
(Decimal_Number, Neutral,
Other, Numeric, Numeric, Numeric,
(Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#F0# .. 16#F1# => -- 0DF0 .. 0DF1
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#F2# .. 16#F3# => -- 0DF2 .. 0DF3
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#F4# => -- 0DF4
(Other_Punctuation, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
16#F5# .. 16#FF# => -- 0DF5 .. 0DFF
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
others =>
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_000D;
|
reznikmm/matreshka | Ada | 3,961 | 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.Form_Title_Attributes;
package Matreshka.ODF_Form.Title_Attributes is
type Form_Title_Attribute_Node is
new Matreshka.ODF_Form.Abstract_Form_Attribute_Node
and ODF.DOM.Form_Title_Attributes.ODF_Form_Title_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Form_Title_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Form_Title_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Form.Title_Attributes;
|
wookey-project/ewok-legacy | Ada | 1,095 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
package body ewok.mpu.interfaces
with spark_mode => off
is
function init
return types.c.t_retval
is
ok : boolean;
begin
ewok.mpu.init (ok);
if ok then
return types.c.SUCCESS;
else
return types.c.FAILURE;
end if;
end init;
end ewok.mpu.interfaces;
|
annexi-strayline/AURA | Ada | 8,912 | adb | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- Reference Implementation --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- 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 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 --
-- OWNER 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.Text_IO;
with Ada.Exceptions;
with Ada.Characters.Conversions;
with Ada.Strings.Fixed;
with Ada.Strings.Wide_Wide_Unbounded;
with Ada_Lexical_Parser; use Ada_Lexical_Parser;
with Registrar.Source_Files;
separate (Checkout)
function Parse_Checkout_Spec (Unit: Registrar.Library_Units.Library_Unit)
return Repositories.Repository_Index
is
use Registrar.Source_Files;
use type Repositories.Repository_Index;
Stream: aliased Source_Stream
:= Checkout_Read_Stream (Unit.Spec_File);
Source: Source_Buffer (Stream'Access);
E: Lexical_Element;
package WWU renames Ada.Strings.Wide_Wide_Unbounded;
procedure Next_Element is
begin
loop
E := Next_Element (Source);
exit when E.Category /= Comment;
end loop;
end Next_Element;
function Category return Lexical_Category is (E.Category);
function Content return Wide_Wide_String
is (WWU.To_Wide_Wide_String (E.Content));
Repo_Index: Repositories.Repository_Index;
function Read_Index return Repositories.Repository_Index is
use WWU;
Ident: constant Unbounded_Wide_Wide_String
:= To_Unbounded_Wide_Wide_String (Content);
Lead_In: constant Wide_Wide_String := "repository_";
begin
-- Content should be an identifier that is expected to be
-- "repository_xyz". We need to read in xyz
Assert (Check => Slice (Source => Ident,
Low => 1,
High => Lead_In'Length)
= Lead_In,
Message => "Expected identifier of repository_nnn");
declare
use Ada.Characters.Conversions;
package Index_IO is new Ada.Text_IO.Integer_IO
(Repositories.Repository_Index);
Number_Part: constant String
:= To_String (Slice (Source => Ident,
Low => Lead_In'Length + 1,
High => Length (Ident)));
Last: Positive;
Index: Repositories.Repository_Index;
begin
Index_IO.Get (From => Number_Part,
Item => Index,
Last => Last);
Assert (Check => Last = Number_Part'Last,
Message => "Repository index is too large");
return Index;
exception
when Ada.Text_IO.Data_Error =>
raise Ada.Assertions.Assertion_Error with
"Repository index must be a number.";
end;
end Read_Index;
begin
-- We expect exactly one with statement:
-- with AURA.Repository_X;
Next_Element;
Assert (Check => Category = Reserved_Word and then Content = "with",
Message => "Expected with");
Next_Element;
Assert (Check => Category = Identifier and then Content = "aura",
Message => "With shall be AURA.Repository_X only");
Next_Element;
Assert (Check => Category = Delimiter and then Content = ".",
Message => "Expected '.'");
Next_Element;
Assert (Check => Category = Identifier,
Message => "Identifier expected");
Repo_Index := Read_Index;
Next_Element;
Assert (Check => Category = Delimiter and then Content = ";",
Message => "';' expected");
Next_Element;
Assert (Check => Category = Reserved_Word and then Content = "package",
Message => "Expected package");
-- Note that we don't need to actually check the package identifier, as this
-- was handled by the unit entry logic (the name of Unit itself is derrived
-- from parsing the identifier), we just want to specifically see what is
-- after "renames" (it must be the same as the withed repository)
loop
Next_Element;
exit when Category = Reserved_Word and then Content = "renames";
end loop;
-- "AURA." is valid next, but typically not what we find - but it is legal
Next_Element;
Assert (Check => Category = Identifier,
Message => "Expected identifier");
if Content = "AURA" then
Next_Element;
Assert (Check => Category = Delimiter and then Content = ".",
Message => "Expected repository package identifier after "
& "'AURA.'");
-- We now should be at the repositoy identifier
Next_Element;
Assert (Check => Category = Identifier,
Message => "Expected repository package identifier");
end if;
declare
use Ada.Strings;
use Ada.Strings.Fixed;
begin
Assert (Check => Read_Index = Repo_Index,
Message => "Checkout rename mismatch. Expected " &
"Repository_"
& Trim
(Source => Repositories.Repository_Index'Image (Repo_Index),
Side => Both));
end;
-- Lastly a closing delimiter
Next_Element;
Assert (Check => Category = Delimiter and then Content = ";",
Message => "Expected ';'");
return Repo_Index;
exception
when e: Ada.Assertions.Assertion_Error =>
declare
Pos: Source_Position := Last_Position (Source);
begin
raise Ada.Assertions.Assertion_Error with
Unit.Spec_File.Full_Name
& ":" & Positive'Image (Pos.Line)
& ":" & Positive'Image (Pos.Column)
& " - " & Ada.Exceptions.Exception_Information (e);
end;
end Parse_Checkout_Spec;
|
faelys/natools | Ada | 30,422 | adb | ------------------------------------------------------------------------------
-- Copyright (c) 2016, 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 Ada.Unchecked_Deallocation;
package body Natools.Smaz.Tools is
package Sx renames Natools.S_Expressions;
function Build_Node
(Map : Dictionary_Maps.Map;
Empty_Value : Natural)
return Trie_Node;
function Dummy_Hash (Value : String) return Natural;
-- Placeholder for Hash member, always raises Program_Error
function Image (B : Boolean) return String;
-- Return correctly-cased image of B
procedure Free is new Ada.Unchecked_Deallocation
(Trie_Node, Trie_Node_Access);
------------------------------
-- Local Helper Subprograms --
------------------------------
function Build_Node
(Map : Dictionary_Maps.Map;
Empty_Value : Natural)
return Trie_Node
is
function First_Character (S : String) return Character
is (S (S'First));
function Is_Current (Cursor : Dictionary_Maps.Cursor; C : Character)
return Boolean
is (Dictionary_Maps.Has_Element (Cursor)
and then First_Character (Dictionary_Maps.Key (Cursor)) = C);
function Suffix (S : String) return String;
function Suffix (S : String) return String is
begin
return S (S'First + 1 .. S'Last);
end Suffix;
use type Ada.Containers.Count_Type;
Cursor : Dictionary_Maps.Cursor;
Result : Trie_Node
:= (Ada.Finalization.Controlled with
Is_Leaf => False,
Index => Empty_Value,
Children => (others => null));
begin
pragma Assert (Dictionary_Maps.Length (Map) >= 1);
Cursor := Dictionary_Maps.Find (Map, "");
if Dictionary_Maps.Has_Element (Cursor) then
Result.Index := Natural (Dictionary_Maps.Element (Cursor));
end if;
for C in Character'Range loop
Cursor := Dictionary_Maps.Ceiling (Map, (1 => C));
if Is_Current (Cursor, C) then
if not Is_Current (Dictionary_Maps.Next (Cursor), C)
and then Dictionary_Maps.Key (Cursor) = (1 => C)
then
Result.Children (C)
:= new Trie_Node'(Ada.Finalization.Controlled with
Is_Leaf => True,
Index => Natural (Dictionary_Maps.Element (Cursor)));
else
declare
New_Map : Dictionary_Maps.Map;
begin
loop
Dictionary_Maps.Insert
(New_Map,
Suffix (Dictionary_Maps.Key (Cursor)),
Dictionary_Maps.Element (Cursor));
Dictionary_Maps.Next (Cursor);
exit when not Is_Current (Cursor, C);
end loop;
Result.Children (C)
:= new Trie_Node'(Build_Node (New_Map, Empty_Value));
end;
end if;
end if;
end loop;
return Result;
end Build_Node;
function Dummy_Hash (Value : String) return Natural is
pragma Unreferenced (Value);
begin
raise Program_Error with "Dummy_Hash called";
return 0;
end Dummy_Hash;
function Image (B : Boolean) return String is
begin
if B then
return "True";
else
return "False";
end if;
end Image;
----------------------
-- Public Interface --
----------------------
function Append_String
(Dict : in Dictionary;
Value : in String)
return Dictionary is
begin
return Dictionary'
(Dict_Last => Dict.Dict_Last + 1,
String_Size => Dict.String_Size + Value'Length,
Variable_Length_Verbatim => Dict.Variable_Length_Verbatim,
Max_Word_Length => Positive'Max (Dict.Max_Word_Length, Value'Length),
Offsets => Dict.Offsets & (1 => Dict.String_Size + 1),
Values => Dict.Values & Value,
Hash => Dummy_Hash'Access);
end Append_String;
procedure Print_Dictionary_In_Ada
(Dict : in Dictionary;
Hash_Image : in String := "TODO";
Max_Width : in Positive := 70;
First_Prefix : in String := " := (";
Prefix : in String := " ";
Half_Indent : in String := " ")
is
procedure Append_Entity
(Buffer : in out String;
Last : in out Natural;
Entity : in String);
function Double_Quote (S : String; Count : Natural) return String;
function Offsets_Suffix (I : Ada.Streams.Stream_Element) return String;
function Strip_Image (S : String) return String;
function Values_Separator (I : Positive) return String;
procedure Append_Entity
(Buffer : in out String;
Last : in out Natural;
Entity : in String) is
begin
if Last + 1 + Entity'Length <= Buffer'Last then
Buffer (Last + 1) := ' ';
Buffer (Last + 2 .. Last + 1 + Entity'Length) := Entity;
Last := Last + 1 + Entity'Length;
else
Put_Line (Buffer (Buffer'First .. Last));
Last := Buffer'First + Prefix'Length - 1;
Buffer (Last + 1 .. Last + Half_Indent'Length) := Half_Indent;
Last := Last + Half_Indent'Length;
Buffer (Last + 1 .. Last + Entity'Length) := Entity;
Last := Last + Entity'Length;
end if;
end Append_Entity;
function Double_Quote (S : String; Count : Natural) return String is
begin
if Count = 0 then
return S;
else
return Quoted : String (1 .. S'Length + Count) do
declare
O : Positive := Quoted'First;
begin
for I in S'Range loop
Quoted (O) := S (I);
O := O + 1;
if S (I) = '"' then
Quoted (O) := S (I);
O := O + 1;
end if;
end loop;
end;
end return;
end if;
end Double_Quote;
function Offsets_Suffix (I : Ada.Streams.Stream_Element) return String is
begin
if I < Dict.Offsets'Last then
return ",";
else
return "),";
end if;
end Offsets_Suffix;
function Strip_Image (S : String) return String is
begin
if S'Length > 0 and then S (S'First) = ' ' then
return S (S'First + 1 .. S'Last);
else
return S;
end if;
end Strip_Image;
function Values_Separator (I : Positive) return String is
begin
if I > Dict.Values'First then
return "& ";
else
return "";
end if;
end Values_Separator;
Line_Buffer : String (1 .. Max_Width + Prefix'Length);
Buffer_Last : Natural;
begin
Put_Line (First_Prefix & "Dict_Last =>"
& Ada.Streams.Stream_Element'Image (Dict.Dict_Last) & ',');
Put_Line (Prefix & "String_Size =>"
& Natural'Image (Dict.String_Size) & ',');
Put_Line (Prefix & "Variable_Length_Verbatim => "
& Image (Dict.Variable_Length_Verbatim) & ',');
Put_Line (Prefix & "Max_Word_Length =>"
& Natural'Image (Dict.Max_Word_Length) & ',');
Line_Buffer (1 .. Prefix'Length) := Prefix;
Line_Buffer (Prefix'Length + 1 .. Prefix'Length + 11) := "Offsets => ";
Buffer_Last := Prefix'Length + 11;
for I in Dict.Offsets'Range loop
Append_Entity (Line_Buffer, Buffer_Last, Strip_Image
(Positive'Image (Dict.Offsets (I)) & Offsets_Suffix (I)));
if I = Dict.Offsets'First then
Line_Buffer (Prefix'Length + 12) := '(';
end if;
end loop;
Put_Line (Line_Buffer (Line_Buffer'First .. Buffer_Last));
Line_Buffer (Prefix'Length + 1 .. Prefix'Length + 9) := "Values =>";
Buffer_Last := Prefix'Length + 9;
declare
I : Positive := Dict.Values'First;
First, Last : Positive;
Quote_Count : Natural;
begin
Values_Loop :
while I <= Dict.Values'Last loop
Add_Unprintable :
while Dict.Values (I) not in ' ' .. '~' loop
Append_Entity
(Line_Buffer, Buffer_Last,
Values_Separator (I) & Character'Image (Dict.Values (I)));
I := I + 1;
exit Values_Loop when I > Dict.Values'Last;
end loop Add_Unprintable;
First := I;
Quote_Count := 0;
Find_Printable_Substring :
loop
if Dict.Values (I) = '"' then
Quote_Count := Quote_Count + 1;
end if;
I := I + 1;
exit Find_Printable_Substring when I > Dict.Values'Last
or else Dict.Values (I) not in ' ' .. '~';
end loop Find_Printable_Substring;
Last := I - 1;
Split_Lines :
loop
declare
Partial_Quote_Count : Natural := 0;
Partial_Width : Natural := 0;
Partial_Last : Natural := First - 1;
Sep : constant String := Values_Separator (First);
Available_Length : constant Natural
:= (if Line_Buffer'Last > Buffer_Last + Sep'Length + 4
then Line_Buffer'Last - Buffer_Last - Sep'Length - 4
else Line_Buffer'Length - Prefix'Length
- Half_Indent'Length - Sep'Length - 3);
begin
if 1 + Last - First + Quote_Count < Available_Length then
Append_Entity
(Line_Buffer, Buffer_Last,
Sep & '"' & Double_Quote
(Dict.Values (First .. Last), Quote_Count) & '"');
exit Split_Lines;
else
Count_Quotes :
loop
if Dict.Values (Partial_Last + 1) = '"' then
exit Count_Quotes
when Partial_Width + 2 > Available_Length;
Partial_Width := Partial_Width + 1;
Partial_Quote_Count := Partial_Quote_Count + 1;
else
exit Count_Quotes
when Partial_Width + 1 > Available_Length;
end if;
Partial_Width := Partial_Width + 1;
Partial_Last := Partial_Last + 1;
end loop Count_Quotes;
Append_Entity
(Line_Buffer, Buffer_Last, Sep & '"'
& Double_Quote
(Dict.Values (First .. Partial_Last),
Partial_Quote_Count)
& '"');
First := Partial_Last + 1;
Quote_Count := Quote_Count - Partial_Quote_Count;
end if;
end;
end loop Split_Lines;
end loop Values_Loop;
Put_Line (Line_Buffer (Line_Buffer'First .. Buffer_Last) & ',');
end;
Line_Buffer (Prefix'Length + 1 .. Prefix'Length + 7) := "Hash =>";
Buffer_Last := Prefix'Length + 7;
Append_Entity (Line_Buffer, Buffer_Last, Hash_Image & ");");
Put_Line (Line_Buffer (Line_Buffer'First .. Buffer_Last));
end Print_Dictionary_In_Ada;
procedure Read_List
(List : out String_Lists.List;
Descriptor : in out S_Expressions.Descriptor'Class)
is
use type Sx.Events.Event;
Event : Sx.Events.Event := Descriptor.Current_Event;
begin
String_Lists.Clear (List);
if Event = Sx.Events.Open_List then
Descriptor.Next (Event);
end if;
Read_Loop :
loop
case Event is
when Sx.Events.Add_Atom =>
String_Lists.Append
(List, Sx.To_String (Descriptor.Current_Atom));
when Sx.Events.Open_List =>
Descriptor.Close_Current_List;
when Sx.Events.End_Of_Input | Sx.Events.Error
| Sx.Events.Close_List =>
exit Read_Loop;
end case;
Descriptor.Next (Event);
end loop Read_Loop;
end Read_List;
function Remove_Element
(Dict : in Dictionary;
Index : in Ada.Streams.Stream_Element)
return Dictionary
is
Removed_Length : constant Positive := Dict_Entry (Dict, Index)'Length;
function New_Offsets return Offset_Array;
function New_Values return String;
function New_Offsets return Offset_Array is
Result : Offset_Array (0 .. Dict.Dict_Last - 1);
begin
for I in Result'Range loop
if I < Index then
Result (I) := Dict.Offsets (I);
else
Result (I) := Dict.Offsets (I + 1) - Removed_Length;
end if;
end loop;
return Result;
end New_Offsets;
function New_Values return String is
begin
if Index < Dict.Dict_Last then
return Dict.Values (1 .. Dict.Offsets (Index) - 1)
& Dict.Values (Dict.Offsets (Index + 1) .. Dict.Values'Last);
else
return Dict.Values (1 .. Dict.Offsets (Index) - 1);
end if;
end New_Values;
New_Max_Word_Length : Positive := Dict.Max_Word_Length;
begin
if Removed_Length = Dict.Max_Word_Length then
New_Max_Word_Length := 1;
for I in Dict.Offsets'Range loop
if I /= Index
and then Dict_Entry (Dict, I)'Length > New_Max_Word_Length
then
New_Max_Word_Length := Dict_Entry (Dict, I)'Length;
end if;
end loop;
end if;
return Dictionary'
(Dict_Last => Dict.Dict_Last - 1,
String_Size => Dict.String_Size - Removed_Length,
Variable_Length_Verbatim => Dict.Variable_Length_Verbatim,
Max_Word_Length => New_Max_Word_Length,
Offsets => New_Offsets,
Values => New_Values,
Hash => Dummy_Hash'Access);
end Remove_Element;
function Replace_Element
(Dict : in Dictionary;
Index : in Ada.Streams.Stream_Element;
Value : in String)
return Dictionary
is
Removed_Length : constant Positive := Dict_Entry (Dict, Index)'Length;
Length_Delta : constant Integer := Value'Length - Removed_Length;
function New_Offsets return Offset_Array;
function New_Values return String;
function New_Offsets return Offset_Array is
Result : Offset_Array (Dict.Offsets'First .. Dict.Dict_Last);
begin
for I in Result'Range loop
if I <= Index then
Result (I) := Dict.Offsets (I);
else
Result (I) := Dict.Offsets (I) + Length_Delta;
end if;
end loop;
return Result;
end New_Offsets;
function New_Values return String is
begin
if Index = 0 then
return Value
& Dict.Values (Dict.Offsets (Index + 1) .. Dict.Values'Last);
elsif Index < Dict.Dict_Last then
return Dict.Values (1 .. Dict.Offsets (Index) - 1)
& Value
& Dict.Values (Dict.Offsets (Index + 1) .. Dict.Values'Last);
else
return Dict.Values (1 .. Dict.Offsets (Index) - 1) & Value;
end if;
end New_Values;
New_Max_Word_Length : Positive := Dict.Max_Word_Length;
begin
if Removed_Length = Dict.Max_Word_Length then
New_Max_Word_Length := 1;
for I in Dict.Offsets'Range loop
if I /= Index
and then Dict_Entry (Dict, I)'Length > New_Max_Word_Length
then
New_Max_Word_Length := Dict_Entry (Dict, I)'Length;
end if;
end loop;
end if;
if New_Max_Word_Length < Value'Length then
New_Max_Word_Length := Value'Length;
end if;
return Dictionary'
(Dict_Last => Dict.Dict_Last,
String_Size => Dict.String_Size + Length_Delta,
Variable_Length_Verbatim => Dict.Variable_Length_Verbatim,
Max_Word_Length => New_Max_Word_Length,
Offsets => New_Offsets,
Values => New_Values,
Hash => Dummy_Hash'Access);
end Replace_Element;
function To_Dictionary
(List : in String_Lists.List;
Variable_Length_Verbatim : in Boolean)
return Dictionary
is
Dict_Last : constant Ada.Streams.Stream_Element
:= Ada.Streams.Stream_Element (String_Lists.Length (List)) - 1;
String_Size : Natural := 0;
Max_Word_Length : Positive := 1;
begin
for S of List loop
String_Size := String_Size + S'Length;
if S'Length > Max_Word_Length then
Max_Word_Length := S'Length;
end if;
end loop;
declare
Offsets : Offset_Array (0 .. Dict_Last);
Values : String (1 .. String_Size);
Current_Offset : Positive := 1;
Current_Index : Ada.Streams.Stream_Element := 0;
Next_Offset : Positive;
begin
for S of List loop
Offsets (Current_Index) := Current_Offset;
Next_Offset := Current_Offset + S'Length;
Values (Current_Offset .. Next_Offset - 1) := S;
Current_Offset := Next_Offset;
Current_Index := Current_Index + 1;
end loop;
pragma Assert (Current_Index = Dict_Last + 1);
pragma Assert (Current_Offset = String_Size + 1);
return
(Dict_Last => Dict_Last,
String_Size => String_Size,
Variable_Length_Verbatim => Variable_Length_Verbatim,
Max_Word_Length => Max_Word_Length,
Offsets => Offsets,
Values => Values,
Hash => Dummy_Hash'Access);
end;
end To_Dictionary;
---------------------------------
-- Dynamic Dictionary Searches --
---------------------------------
overriding procedure Adjust (Node : in out Trie_Node) is
begin
if not Node.Is_Leaf then
for C in Node.Children'Range loop
if Node.Children (C) /= null then
Node.Children (C) := new Trie_Node'(Node.Children (C).all);
end if;
end loop;
end if;
end Adjust;
overriding procedure Finalize (Node : in out Trie_Node) is
begin
if not Node.Is_Leaf then
for C in Node.Children'Range loop
Free (Node.Children (C));
end loop;
end if;
end Finalize;
procedure Initialize (Trie : out Search_Trie; Dict : in Dictionary) is
Map : Dictionary_Maps.Map;
begin
for I in Dict.Offsets'Range loop
Dictionary_Maps.Insert (Map, Dict_Entry (Dict, I), I);
end loop;
Trie := (Not_Found => Natural (Dict.Dict_Last) + 1,
Root => Build_Node (Map, Natural (Dict.Dict_Last) + 1));
end Initialize;
function Linear_Search (Value : String) return Natural is
Result : Ada.Streams.Stream_Element := 0;
begin
for S of List_For_Linear_Search loop
exit when S = Value;
Result := Result + 1;
end loop;
return Natural (Result);
end Linear_Search;
function Map_Search (Value : String) return Natural is
Cursor : constant Dictionary_Maps.Cursor
:= Dictionary_Maps.Find (Search_Map, Value);
begin
if Dictionary_Maps.Has_Element (Cursor) then
return Natural (Dictionary_Maps.Element (Cursor));
else
return Natural (Ada.Streams.Stream_Element'Last);
end if;
end Map_Search;
function Search (Trie : in Search_Trie; Value : in String) return Natural is
Index : Positive := Value'First;
Position : Trie_Node_Access;
begin
if Value'Length = 0 then
return Trie.Not_Found;
end if;
Position := Trie.Root.Children (Value (Index));
loop
if Position = null then
return Trie.Not_Found;
end if;
Index := Index + 1;
if Index not in Value'Range then
return Position.Index;
elsif Position.Is_Leaf then
return Trie.Not_Found;
end if;
Position := Position.Children (Value (Index));
end loop;
end Search;
procedure Set_Dictionary_For_Map_Search (Dict : in Dictionary) is
begin
Dictionary_Maps.Clear (Search_Map);
for I in Dict.Offsets'Range loop
Dictionary_Maps.Insert (Search_Map, Dict_Entry (Dict, I), I);
end loop;
end Set_Dictionary_For_Map_Search;
procedure Set_Dictionary_For_Trie_Search (Dict : in Dictionary) is
begin
Initialize (Trie_For_Search, Dict);
end Set_Dictionary_For_Trie_Search;
function Trie_Search (Value : String) return Natural is
begin
return Search (Trie_For_Search, Value);
end Trie_Search;
-------------------
-- Word Counting --
-------------------
procedure Add_Substrings
(Counter : in out Word_Counter;
Phrase : in String;
Min_Size : in Positive;
Max_Size : in Positive) is
begin
for First in Phrase'First .. Phrase'Last - Min_Size + 1 loop
for Last in First + Min_Size - 1
.. Natural'Min (First + Max_Size - 1, Phrase'Last)
loop
Add_Word (Counter, Phrase (First .. Last));
end loop;
end loop;
end Add_Substrings;
procedure Add_Word
(Counter : in out Word_Counter;
Word : in String;
Count : in String_Count := 1)
is
procedure Update
(Key : in String; Element : in out String_Count);
procedure Update
(Key : in String; Element : in out String_Count)
is
pragma Unreferenced (Key);
begin
Element := Element + Count;
end Update;
Cursor : constant Word_Maps.Cursor := Word_Maps.Find (Counter.Map, Word);
begin
if Word_Maps.Has_Element (Cursor) then
Word_Maps.Update_Element (Counter.Map, Cursor, Update'Access);
else
Word_Maps.Insert (Counter.Map, Word, Count);
end if;
end Add_Word;
procedure Add_Words
(Counter : in out Word_Counter;
Phrase : in String;
Min_Size : in Positive;
Max_Size : in Positive)
is
subtype Word_Part is Character with Static_Predicate
=> Word_Part in '0' .. '9' | 'A' .. 'Z' | 'a' .. 'z'
| Character'Val (128) .. Character'Val (255);
I, First, Next : Positive;
begin
if Max_Size < Min_Size then
return;
end if;
I := Phrase'First;
Main_Loop :
while I in Phrase'Range loop
Skip_Non_Word :
while I in Phrase'Range and then Phrase (I) not in Word_Part loop
I := I + 1;
end loop Skip_Non_Word;
exit Main_Loop when I not in Phrase'Range;
First := I;
Skip_Word :
while I in Phrase'Range and then Phrase (I) in Word_Part loop
I := I + 1;
end loop Skip_Word;
Next := I;
if Next - First in Min_Size .. Max_Size then
Add_Word (Counter, Phrase (First .. Next - 1));
end if;
end loop Main_Loop;
end Add_Words;
procedure Evaluate_Dictionary
(Dict : in Dictionary;
Corpus : in String_Lists.List;
Compressed_Size : out Ada.Streams.Stream_Element_Count;
Counts : out Dictionary_Counts) is
begin
Compressed_Size := 0;
Counts := (others => 0);
for S of Corpus loop
Evaluate_Dictionary_Partial
(Dict, S, Compressed_Size, Counts);
end loop;
end Evaluate_Dictionary;
procedure Evaluate_Dictionary_Partial
(Dict : in Dictionary;
Corpus_Entry : in String;
Compressed_Size : in out Ada.Streams.Stream_Element_Count;
Counts : in out Dictionary_Counts)
is
use type Ada.Streams.Stream_Element_Offset;
Verbatim_Code_Count : constant Ada.Streams.Stream_Element_Offset
:= Ada.Streams.Stream_Element_Offset
(Ada.Streams.Stream_Element'Last - Dict.Dict_Last);
Verbatim_Length : Ada.Streams.Stream_Element_Offset;
Input_Byte : Ada.Streams.Stream_Element;
Compressed : constant Ada.Streams.Stream_Element_Array
:= Compress (Dict, Corpus_Entry);
Index : Ada.Streams.Stream_Element_Offset := Compressed'First;
begin
Compressed_Size := Compressed_Size + Compressed'Length;
while Index in Compressed'Range loop
Input_Byte := Compressed (Index);
if Input_Byte in Dict.Offsets'Range then
Counts (Input_Byte) := Counts (Input_Byte) + 1;
Index := Index + 1;
else
if not Dict.Variable_Length_Verbatim then
Verbatim_Length := Ada.Streams.Stream_Element_Offset
(Ada.Streams.Stream_Element'Last - Input_Byte) + 1;
elsif Input_Byte < Ada.Streams.Stream_Element'Last then
Verbatim_Length := Ada.Streams.Stream_Element_Offset
(Ada.Streams.Stream_Element'Last - Input_Byte);
else
Index := Index + 1;
Verbatim_Length := Ada.Streams.Stream_Element_Offset
(Compressed (Index)) + Verbatim_Code_Count - 1;
end if;
Index := Index + Verbatim_Length + 1;
end if;
end loop;
end Evaluate_Dictionary_Partial;
procedure Filter_By_Count
(Counter : in out Word_Counter;
Threshold_Count : in String_Count)
is
Position, Next : Word_Maps.Cursor;
begin
Position := Word_Maps.First (Counter.Map);
while Word_Maps.Has_Element (Position) loop
Next := Word_Maps.Next (Position);
if Word_Maps.Element (Position) < Threshold_Count then
Word_Maps.Delete (Counter.Map, Position);
end if;
Position := Next;
end loop;
pragma Assert (for all Count of Counter.Map => Count >= Threshold_Count);
end Filter_By_Count;
function Simple_Dictionary
(Counter : in Word_Counter;
Word_Count : in Natural;
Method : in Methods.Enum := Methods.Encoded)
return String_Lists.List
is
use type Ada.Containers.Count_Type;
Target_Count : constant Ada.Containers.Count_Type
:= Ada.Containers.Count_Type (Word_Count);
Set : Scored_Word_Sets.Set;
Result : String_Lists.List;
begin
for Cursor in Word_Maps.Iterate (Counter.Map) loop
Scored_Word_Sets.Include (Set, To_Scored_Word (Cursor, Method));
if Scored_Word_Sets.Length (Set) > Target_Count then
Scored_Word_Sets.Delete_Last (Set);
end if;
end loop;
for Cursor in Scored_Word_Sets.Iterate (Set) loop
Result.Append (Scored_Word_Sets.Element (Cursor).Word);
end loop;
return Result;
end Simple_Dictionary;
procedure Simple_Dictionary_And_Pending
(Counter : in Word_Counter;
Word_Count : in Natural;
Selected : out String_Lists.List;
Pending : out String_Lists.List;
Method : in Methods.Enum := Methods.Encoded;
Max_Pending_Count : in Ada.Containers.Count_Type
:= Ada.Containers.Count_Type'Last)
is
use type Ada.Containers.Count_Type;
Target_Count : constant Ada.Containers.Count_Type
:= Ada.Containers.Count_Type (Word_Count);
Set : Scored_Word_Sets.Set;
begin
for Cursor in Word_Maps.Iterate (Counter.Map) loop
Scored_Word_Sets.Insert (Set, To_Scored_Word (Cursor, Method));
end loop;
Selected := String_Lists.Empty_List;
Pending := String_Lists.Empty_List;
for Cursor in Scored_Word_Sets.Iterate (Set) loop
if String_Lists.Length (Selected) < Target_Count then
Selected.Append (Scored_Word_Sets.Element (Cursor).Word);
else
Pending.Append (Scored_Word_Sets.Element (Cursor).Word);
exit when String_Lists.Length (Selected) >= Max_Pending_Count;
end if;
end loop;
end Simple_Dictionary_And_Pending;
function To_Scored_Word
(Cursor : in Word_Maps.Cursor;
Method : in Methods.Enum)
return Scored_Word
is
Word : constant String := Word_Maps.Key (Cursor);
begin
return Scored_Word'
(Size => Word'Length,
Word => Word,
Score => Score (Word_Maps.Element (Cursor), Word'Length, Method));
end To_Scored_Word;
function Worst_Index
(Dict : in Dictionary;
Counts : in Dictionary_Counts;
Method : in Methods.Enum;
First, Last : in Ada.Streams.Stream_Element)
return Ada.Streams.Stream_Element
is
Result : Ada.Streams.Stream_Element := First;
Worst_Score : Score_Value := Score (Dict, Counts, First, Method);
S : Score_Value;
begin
for I in First + 1 .. Last loop
S := Score (Dict, Counts, I, Method);
if S < Worst_Score then
Result := I;
Worst_Score := S;
end if;
end loop;
return Result;
end Worst_Index;
end Natools.Smaz.Tools;
|
zrmyers/VulkanAda | Ada | 15,514 | ads | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2020 Zane Myers
--
-- 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, 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
-- AUTHORS OR 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.
--------------------------------------------------------------------------------
with Vulkan.Math.GenMatrix;
with Vulkan.Math.GenFType;
use Vulkan.Math.GenFType;
--------------------------------------------------------------------------------
--< @group Vulkan Math GenMatrix
--------------------------------------------------------------------------------
--< @summary
--< This provides an instantiation of a generic matrix for the Vkm_Float type.
--<
--< @description
--< The Vkm_Matrix type is a generic floating point matrix that can contain up to
--< 4 rows and 4 columns.
--------------------------------------------------------------------------------
package Vulkan.Math.GenFMatrix is
pragma Preelaborate;
pragma Pure;
--< @private
--< GFM is an instantiation of the GenMatrix package for the Vkm_Float type.
package GFM is new Vulkan.Math.GenMatrix(
Base_Type => Vkm_Float,
Base_Vector_Type => Vkm_GenFType,
x => GFT.x,
y => GFT.y,
z => GFT.z,
w => GFT.w,
Make_GenType => GFT.Make_GenType,
Image => GFT.Image,
Set => GFT.Component,
Get => GFT.Component);
--< The Vkm_GenFMatrix is a subtype of Vkm_GenMatrix from the instantiated GFM
--< package.
subtype Vkm_Mat is GFM.Vkm_GenMatrix;
----------------------------------------------------------------------------
--< @summary
--< Get the image of the Vkm_Mat matrix.
--<
--< @param instance
--< The instance of matrix to get the image of.
--<
--< @return
--< The image of the matrix.
----------------------------------------------------------------------------
function Image (instance : in Vkm_Mat) return String is
(GFM.Image(instance)) with inline;
----------------------------------------------------------------------------
--< @summary
--< Equality operator for two Vkm_Mat2x2 matrices.
--<
--< @description
--< Determine whether two matrices are equal.
--<
--< @param left
--< The left operator argument.
--<
--< @param right
--< The right operator argument.
--<
--< @return
--< True if the two matrices are equal. Otherwise false.
----------------------------------------------------------------------------
function "=" (left, right : in Vkm_Mat) return Vkm_Bool renames GFM.Op_Is_Equal;
----------------------------------------------------------------------------
--< @summary
--< Unary plus operator for a Vkm_Mat matrix.
--<
--< @description
--< Return the matrix unchanged.
--<
--< @param right
--< The value to apply the unary operator to.
--<
--< @return
--< The result of the operator on the matrix.
----------------------------------------------------------------------------
function "+" (right : in Vkm_Mat) return Vkm_Mat is
(right) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Unary minus operator for a Vkm_Mat matrix.
--<
--< @description
--< Return the matrix negated.
----------------------------------------------------------------------------
function "-" is new GFM.Apply_Func_IM_RM("-");
----------------------------------------------------------------------------
--< @summary
--< Unary Absolute Value operator for a Vkm_Mat matrix.
--<
--< @description
--< Return a matrix of the absolute values of each element of the input matrix.
----------------------------------------------------------------------------
function "abs" is new GFM.Apply_Func_IM_RM("abs");
----------------------------------------------------------------------------
--< @summary
--< Modulo operator for two Vkm_Mat matrices.
--<
--< @description
--< Perform Modulo component-wise on two Vkm_Mat matrices.
----------------------------------------------------------------------------
function "mod" is new GFM.Apply_Func_IM_IM_RM("mod");
----------------------------------------------------------------------------
--< @summary
--< Modulo operator for a Vkm_Mat matrix and a Vkm_Float value.
--<
--< @description
--< Perform Modulo component-wise on the matrix and scalar.
----------------------------------------------------------------------------
function "mod" is new GFM.Apply_Func_IM_IS_RM("mod");
----------------------------------------------------------------------------
--< @summary
--< Modulo operator for a Vkm_Mat matrix and a Vkm_Float value.
--<
--< @description
--< Perform Modulo component-wise on the matrix and scalar.
----------------------------------------------------------------------------
function "mod" is new GFM.Apply_Func_IS_IM_RM("mod");
----------------------------------------------------------------------------
--< @summary
--< Power operator for two Vkm_Mat matrices.
--<
--< @description
--< Perform Power component-wise on two Vkm_Mat matrices.
----------------------------------------------------------------------------
function "**" is new GFM.Apply_Func_IM_IM_RM("**");
----------------------------------------------------------------------------
--< @summary
--< Power operator for a Vkm_Mat matrix and a Vkm_Float value.
--<
--< @description
--< Perform Power component-wise on the matrix and scalar.
----------------------------------------------------------------------------
function "**" is new GFM.Apply_Func_IM_IS_RM("**");
----------------------------------------------------------------------------
--< @summary
--< Power operator for a Vkm_Mat matrix and a Vkm_Float value.
--<
--< @description
--< Perform Power component-wise on the matrix and scalar.
----------------------------------------------------------------------------
function "**" is new GFM.Apply_Func_IS_IM_RM("**");
----------------------------------------------------------------------------
--< @summary
--< Addition operator for two Vkm_Mat matrices.
--<
--< @description
--< Perform Addition component-wise on two Vkm_Mat matrices.
----------------------------------------------------------------------------
function "+" is new GFM.Apply_Func_IM_IM_RM("+");
----------------------------------------------------------------------------
--< @summary
--< Addition operator for a Vkm_Mat matrix and a Vkm_Float value.
--<
--< @description
--< Perform Addition component-wise on the matrix and scalar.
----------------------------------------------------------------------------
function "+" is new GFM.Apply_Func_IM_IS_RM("+");
----------------------------------------------------------------------------
--< @summary
--< Addition operator for a Vkm_Mat matrix and a Vkm_Float value.
--<
--< @description
--< Perform Addition component-wise on the matrix and scalar.
----------------------------------------------------------------------------
function "+" is new GFM.Apply_Func_IS_IM_RM("+");
----------------------------------------------------------------------------
--< @summary
--< Subtraction operator for two Vkm_Mat matrices.
--<
--< @description
--< Perform Subtraction component-wise on two Vkm_Mat matrices.
----------------------------------------------------------------------------
function "-" is new GFM.Apply_Func_IM_IM_RM("-");
----------------------------------------------------------------------------
--< @summary
--< Subtraction operator for a Vkm_Mat matrix and a Vkm_Float value.
--<
--< @description
--< Perform Subtraction component-wise on the matrix and scalar.
----------------------------------------------------------------------------
function "-" is new GFM.Apply_Func_IM_IS_RM("-");
----------------------------------------------------------------------------
--< @summary
--< Subtraction operator for a Vkm_Mat matrix and a Vkm_Float value.
--<
--< @description
--< Perform Subtraction component-wise on the matrix and scalar.
----------------------------------------------------------------------------
function "-" is new GFM.Apply_Func_IS_IM_RM("-");
----------------------------------------------------------------------------
--< @summary
--< Remainder operator for two Vkm_Mat matrices.
--<
--< @description
--< Perform Remainder component-wise on two Vkm_Mat matrices.
----------------------------------------------------------------------------
function "rem" is new GFM.Apply_Func_IM_IM_RM(Vkm_Float'Remainder);
----------------------------------------------------------------------------
--< @summary
--< Remainder operator for a Vkm_Mat matrix and a Vkm_Float value.
--<
--< @description
--< Perform Remainder component-wise on the matrix and scalar.
----------------------------------------------------------------------------
function "rem" is new GFM.Apply_Func_IM_IS_RM(Vkm_Float'Remainder);
----------------------------------------------------------------------------
--< @summary
--< Remainder operator for a Vkm_Mat matrix and a Vkm_Float value.
--<
--< @description
--< Perform Remainder component-wise on the matrix and scalar.
----------------------------------------------------------------------------
function "rem" is new GFM.Apply_Func_IS_IM_RM(Vkm_Float'Remainder);
----------------------------------------------------------------------------
--< @summary
--< Division operator for two Vkm_Mat matrices.
--<
--< @description
--< Perform Division component-wise on two Vkm_Mat matrices.
----------------------------------------------------------------------------
function "/" is new GFM.Apply_Func_IM_IM_RM("/");
----------------------------------------------------------------------------
--< @summary
--< Division operator for a Vkm_Mat matrix and a Vkm_Float value.
--<
--< @description
--< Perform Division component-wise on the matrix and scalar.
----------------------------------------------------------------------------
function "/" is new GFM.Apply_Func_IM_IS_RM("/");
----------------------------------------------------------------------------
--< @summary
--< Division operator for a Vkm_Mat matrix and a Vkm_Float value.
--<
--< @description
--< Perform Division component-wise on the matrix and scalar.
----------------------------------------------------------------------------
function "/" is new GFM.Apply_Func_IS_IM_RM("/");
----------------------------------------------------------------------------
--< @summary
--< Linear Algebraic Multiplication for two Vkm_Mat matrices.
--<
--< @description
--< Perform Linear Algebraic Multiplication of the left Vkm_Mat by the right
--< Vkm_Mat matrix.
--<
--< @param left
--< The left operator argument.
--<
--< @param right
--< The right operator argument.
--<
--< @return
--< The result of the component-wise operator on the arguments.
----------------------------------------------------------------------------
function "*" (left, right : in Vkm_Mat) return Vkm_Mat renames GFM.Op_Matrix_Mult_Matrix;
----------------------------------------------------------------------------
--< @summary
--< Multiplication operator for a Vkm_GenMatrix matrix and a Vkm_GenFType value.
--<
--< @description
--< Perform Multiplication component-wise on the matrix and vector.
--<
--< @param left
--< The matrix that is multiplied with the vector.
--<
--< @param right
--< The vector that is multiplied by the matrix.
--<
--< @return
--< The product of the matrix with the vector.
----------------------------------------------------------------------------
function "*" (
left : in Vkm_Mat;
right : in Vkm_GenFType ) return Vkm_GenFType renames GFM.Op_Matrix_Mult_Vector;
----------------------------------------------------------------------------
--< @summary
--< Multiplication operator for a Vkm_GenMatrix matrix and a Vkm_GenFType value.
--<
--< @description
--< Perform Multiplication component-wise on the matrix and vector.
--<
--< @param left
--< The vector that is multiplied with the matrix.
--<
--< @param right
--< The matrix that is multiplied by the vector.
--<
--< @return
--< The product of the vector with the matrix.
----------------------------------------------------------------------------
function "*" (
left : in Vkm_GenFType;
right : in Vkm_Mat ) return Vkm_GenFType renames GFM.Op_Vector_Mult_Matrix;
----------------------------------------------------------------------------
--< @summary
--< Multiply a matrix and a scalar.
--<
--< @description
--< Multiplies a left scalar and a right matrix.
----------------------------------------------------------------------------
function "*" is new GFM.Apply_Func_IS_IM_RM("*");
----------------------------------------------------------------------------
--< @summary
--< Multiply a matrix and a scalar.
--<
--< @description
--< Multiplies a right scalar and a left matrix.
----------------------------------------------------------------------------
function "*" is new GFM.Apply_Func_IM_IS_RM("*");
end Vulkan.Math.GenFMatrix;
|
reznikmm/matreshka | Ada | 5,613 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools 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 package provides name resolver.
--
-- XXX Note: components can be specified in any order, thus this resolver
-- should do several passes to handle all possible combination correctly. For
-- example, it can be separated onto several visitors, which will be run in
-- appropriate order. For now, following dependencies are not handled
-- correctly in some cases:
--
-- - binding operation to interface operation reference resolution:
-- {extended_interface} property must be resolved already.
------------------------------------------------------------------------------
with WSDL.AST;
private with WSDL.AST.Endpoints;
private with WSDL.AST.Services;
private with WSDL.Iterators;
with WSDL.Visitors;
package WSDL.Name_Resolvers is
pragma Preelaborate;
type Name_Resolver is limited new WSDL.Visitors.WSDL_Visitor with private;
procedure Set_Root
(Self : in out Name_Resolver'Class;
Root : WSDL.AST.Description_Access);
private
type Name_Resolver is limited new WSDL.Visitors.WSDL_Visitor with record
Root : WSDL.AST.Description_Access;
end record;
overriding procedure Enter_Binding
(Self : in out Name_Resolver;
Node : not null WSDL.AST.Binding_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Binding_Fault
(Self : in out Name_Resolver;
Node : not null WSDL.AST.Binding_Fault_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Binding_Operation
(Self : in out Name_Resolver;
Node : not null WSDL.AST.Binding_Operation_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Endpoint
(Self : in out Name_Resolver;
Node : not null WSDL.AST.Endpoints.Endpoint_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Interface
(Self : in out Name_Resolver;
Node : not null WSDL.AST.Interface_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Service
(Self : in out Name_Resolver;
Node : not null WSDL.AST.Services.Service_Access;
Control : in out WSDL.Iterators.Traverse_Control);
end WSDL.Name_Resolvers;
|
reznikmm/matreshka | Ada | 4,766 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- 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 League.Strings;
with Matreshka.DOM_Nodes;
with XML.DOM.Entities;
with XML.DOM.Visitors;
package Matreshka.DOM_Entities is
pragma Preelaborate;
type Entity_Node is new Matreshka.DOM_Nodes.Node
and XML.DOM.Entities.DOM_Entity with null record;
overriding procedure Enter_Node
(Self : not null access Entity_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding function Get_Node_Name
(Self : not null access constant Entity_Node)
return League.Strings.Universal_String;
overriding function Get_Node_Type
(Self : not null access constant Entity_Node) return XML.DOM.Node_Type;
overriding procedure Leave_Node
(Self : not null access Entity_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Node
(Self : not null access Entity_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);
-- Dispatch call to corresponding subprogram of iterator interface.
end Matreshka.DOM_Entities;
|
Gabriel-Degret/adalib | Ada | 1,437 | ads | -- Standard Ada library specification
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
package Ada.Directories.Hierarchical_File_Names is
function Is_Simple_Name (Name : in String) return Boolean;
function Is_Root_Directory_Name (Name : in String) return Boolean;
function Is_Parent_Directory_Name (Name : in String) return Boolean;
function Is_Current_Directory_Name (Name : in String) return Boolean;
function Is_Full_Name (Name : in String) return Boolean;
function Is_Relative_Name (Name : in String) return Boolean;
function Simple_Name (Name : in String) return String
renames Ada.Directories.Simple_Name;
function Containing_Directory (Name : in String) return String
renames Ada.Directories.Containing_Directory;
function Initial_Directory (Name : in String) return String;
function Relative_Name (Name : in String) return String;
function Compose (Directory : in String := "";
Relative_Name : in String;
Extension : in String := "") return String;
end Ada.Directories.Hierarchical_File_Names;
|
reznikmm/matreshka | Ada | 3,754 | 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.Svg_Underline_Thickness_Attributes is
pragma Preelaborate;
type ODF_Svg_Underline_Thickness_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Svg_Underline_Thickness_Attribute_Access is
access all ODF_Svg_Underline_Thickness_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Svg_Underline_Thickness_Attributes;
|
reznikmm/matreshka | Ada | 3,963 | 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.Table_Step_Attributes;
package Matreshka.ODF_Table.Step_Attributes is
type Table_Step_Attribute_Node is
new Matreshka.ODF_Table.Abstract_Table_Attribute_Node
and ODF.DOM.Table_Step_Attributes.ODF_Table_Step_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Step_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Step_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Table.Step_Attributes;
|
reznikmm/matreshka | Ada | 5,156 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, 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 storage implementation for Windows Registry.
------------------------------------------------------------------------------
private with System;
package Matreshka.Internals.Settings.Registry is
type Registry_Settings is new Abstract_Settings with private;
function Create
(Manager : not null access Abstract_Manager'Class;
Key : League.Strings.Universal_String;
Read_Only : Boolean) return not null Settings_Access;
-- Creates registry storage pointing to specified key. When Read_Only is
-- True no modifications are allowed.
private
type HANDLER is new System.Address;
type HKEY is new HANDLER;
type Registry_Settings is new Abstract_Settings with record
Name : League.Strings.Universal_String;
Handler : aliased HKEY;
Read_Only : Boolean;
end record;
overriding function Contains
(Self : Registry_Settings;
Key : League.Strings.Universal_String) return Boolean;
overriding procedure Finalize
(Self : not null access Registry_Settings);
overriding function Name
(Self : not null access Registry_Settings)
return League.Strings.Universal_String;
-- Returns name of the storage. For Windows Registry storage it is system
-- registry path.
overriding procedure Remove
(Self : in out Registry_Settings;
Key : League.Strings.Universal_String);
overriding procedure Set_Value
(Self : in out Registry_Settings;
Key : League.Strings.Universal_String;
Value : League.Holders.Holder);
overriding procedure Sync (Self : in out Registry_Settings);
overriding function Value
(Self : Registry_Settings;
Key : League.Strings.Universal_String)
return League.Holders.Holder;
end Matreshka.Internals.Settings.Registry;
|
zrmyers/VulkanAda | Ada | 6,762 | adb | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2021 Zane Myers
--
-- 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, 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
-- AUTHORS OR 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.
--------------------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Characters.Latin_1;
with Vulkan.Test.Framework;
with Vulkan.Math.GenFMatrix;
with Vulkan.Math.Mat4x3;
with Vulkan.Math.Mat2x2;
with Vulkan.Math.Mat2x4;
with Vulkan.Math.GenFType;
with Vulkan.Math.Vec4;
with Vulkan.Math.Vec3;
use Ada.Text_IO;
use Ada.Characters.Latin_1;
use Vulkan.Math.Mat2x2;
use Vulkan.Math.Mat4x3;
use Vulkan.Math.Mat2x4;
use Vulkan.Math.GenFType;
use Vulkan.Math.Vec4;
use Vulkan.Math.Vec3;
use Vulkan.Test.Framework;
--------------------------------------------------------------------------------
--< @group Vulkan Math Basic Types
--------------------------------------------------------------------------------
--< @summary
--< This package provides tests for single precision floating point mat4x3.
--------------------------------------------------------------------------------
package body Vulkan.Math.Mat4x3.Test is
-- Test Mat4x3
procedure Test_Mat4x3 is
vec1 : Vkm_Vec4 :=
Make_Vec4(1.0, 2.0, 3.0, 4.0);
vec2 : Vkm_Vec3 :=
Make_Vec3(1.0, 2.0, 3.0);
mat1 : Vkm_Mat4x3 :=
Make_Mat4x3;
mat2 : Vkm_Mat4x3 :=
Make_Mat4x3(0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
mat3 : Vkm_Mat4x3 :=
Make_Mat4x3(vec2, - vec2, 2.0 * vec2, -2.0 * vec2);
mat4 : Vkm_Mat4x3 :=
Make_Mat4x3(mat2);
mat5 : Vkm_Mat2x2 :=
Make_Mat2x2(5.0);
mat6 : Vkm_Mat4x3 :=
Make_Mat4x3(mat5);
mat7 : Vkm_Mat2x4 :=
Make_Mat2x4( 1.0, -1.0, 0.5, 1.5,
-1.0, 2.0, 1.0, 1.0);
begin
Put_Line(LF & "Testing Mat4x3 Constructors...");
Put_Line("mat1 " & mat1.Image);
Assert_Mat4x3_Equals(mat1, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0);
Put_Line("mat2 " & mat2.Image);
Assert_Mat4x3_Equals(mat2, 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line("mat3 " & mat3.Image);
Assert_Mat4x3_Equals(mat3, 1.0, 2.0, 3.0,
-1.0, -2.0, -3.0,
2.0, 4.0, 6.0,
-2.0, -4.0, -6.0);
Put_Line("mat4 " & mat4.Image);
Assert_Mat4x3_Equals(mat4, 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line("mat6 " & mat6.Image);
Assert_Mat4x3_Equals(mat6, 5.0, 0.0, 0.0,
0.0, 5.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0);
Put_Line("Testing '=' operator...");
Put_Line(" mat2 != mat3");
Assert_Vkm_Bool_Equals(mat2 = mat3, False);
Put_Line(" mat4 != mat5");
Assert_Vkm_Bool_Equals(mat4 = mat5, False);
Put_Line(" mat4 = mat2");
Assert_Vkm_Bool_Equals(mat4 = mat2, True);
Put_Line(" Testing unary '+/-' operator");
Put_Line(" + mat4 = " & Image(+ mat4));
Assert_Mat4x3_Equals(+mat4, 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line(" - mat4 = " & Image(- mat4));
Assert_Mat4x3_Equals(-mat4, 0.0, -1.0, -2.0,
-3.0, -4.0, -5.0,
-6.0, -7.0, -8.0,
-9.0, -10.0, -11.0);
Put_Line("+(- mat4) = " & Image(+(- mat4)));
Assert_Mat4x3_Equals(+(-mat4), 0.0, -1.0, -2.0,
-3.0, -4.0, -5.0,
-6.0, -7.0, -8.0,
-9.0, -10.0, -11.0);
Put_Line("Testing 'abs' operator...");
Put_Line(" abs(- mat4) = " & Image(abs(-mat4)));
Assert_Mat4x3_Equals(abs(-mat4), 0.0, 1.0, 2.0,
3.0, 4.0, 5.0,
6.0, 7.0, 8.0,
9.0, 10.0, 11.0);
Put_Line("Testing '+' operator...");
Put_Line(" mat4 + mat3 = " & Image(mat4 + mat3));
Assert_Mat4x3_Equals(mat4 + mat3, 1.0, 3.0, 5.0,
2.0, 2.0, 2.0,
8.0, 11.0, 14.0,
7.0, 6.0, 5.0);
Put_Line("Testing '-' operator...");
Put_Line(" mat4 - mat3 = " & Image(mat4 -mat3));
Assert_Mat4x3_Equals(mat4 - mat3, -1.0, -1.0, -1.0,
4.0, 6.0, 8.0,
4.0, 3.0, 2.0,
11.0, 14.0, 17.0);
Put_Line("Testing '*' operator...");
Put_Line(" mat7 * mat4 = " & Image(mat7 * mat4));
Assert_Mat2x3_Equals(mat7 * mat4, 13.5, 15.5, 17.5,
21.0, 24.0, 27.0);
Put_Line(" mat4 * vec2 = " & Image(mat4 * vec2));
Assert_Vec4_Equals(mat4 * vec2, 8.0, 26.0, 44.0, 62.0);
Put_Line(" vec1 * mat4 = " & Image(vec1 * mat4));
Assert_Vec3_Equals(vec1 * mat4, 60.0, 70.0, 80.0);
end Test_Mat4x3;
end Vulkan.Math.Mat4x3.Test;
|
jrmarino/zstd-ada | Ada | 1,905 | ads | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Ada.Streams;
package Zstandard.Functions.Streaming_Decompression is
package STR renames Ada.Streams;
Output_container_size : constant Thin.IC.size_t := Thin.ZSTD_DStreamOutSize;
subtype Output_Data_Container is
STR.Stream_Element_Array (1 .. STR.Stream_Element_Offset (Output_container_size));
type Decompressor is tagged private;
-- This is the initialization procedure.
-- The input stream and output buffer capacity are externally provided
procedure Initialize
(mechanism : out Decompressor;
input_stream : not null access STR.Root_Stream_Type'Class);
-- Decompress data as each input chunk is received
-- if "complete" then the decompression is complete (don't call procedure any more)
-- The "last_element" is the end of the container range (e.g. 1 .. last_element)
procedure Decompress_Data
(mechanism : Decompressor;
complete : out Boolean;
output_data : out Output_Data_Container;
last_element : out Natural);
streaming_decompression_initialization : exception;
streaming_decompression_error : exception;
private
Recommended_Chunk_Size : constant Thin.IC.size_t := Thin.ZSTD_DStreamInSize;
type Decompressor is tagged
record
source_stream : access STR.Root_Stream_Type'Class;
zstd_stream : Thin.ZSTD_DStream_ptr := Thin.Null_DStream_pointer;
end record;
function convert_to_stream_array
(char_data : Thin.IC.char_array;
number_characters : Thin.IC.size_t) return STR.Stream_Element_Array;
function convert_to_char_array
(stream_data : STR.Stream_Element_Array;
output_array_size : Thin.IC.size_t) return Thin.IC.char_array;
end Zstandard.Functions.Streaming_Decompression;
|
sungyeon/drake | Ada | 2,081 | ads | pragma License (Unrestricted);
-- implementation unit specialized for Windows
with System.Synchronous_Objects;
with C.winbase;
with C.windef;
with C.winnt;
package System.Native_Tasks is
pragma Preelaborate;
-- thread
subtype Handle_Type is C.winnt.HANDLE;
function Current return Handle_Type
renames C.winbase.GetCurrentThread;
subtype Parameter_Type is C.windef.LPVOID;
subtype Result_Type is C.windef.DWORD;
subtype Thread_Body_Type is C.winbase.PTHREAD_START_ROUTINE;
pragma Convention_Identifier (Thread_Body_CC, WINAPI);
-- WINAPI is stdcall convention on 32bit, or C convention on 64bit.
procedure Create (
Handle : aliased out Handle_Type;
Parameter : Parameter_Type;
Thread_Body : Thread_Body_Type;
Error : out Boolean);
procedure Join (
Handle : Handle_Type; -- of target thread
Current_Abort_Event : access Synchronous_Objects.Event;
Result : aliased out Result_Type;
Error : out Boolean);
procedure Detach (
Handle : in out Handle_Type;
Error : out Boolean);
-- stack
function Info_Block (Handle : Handle_Type) return C.winnt.struct_TEB_ptr;
-- signals
type Abort_Handler is access procedure;
pragma Favor_Top_Level (Abort_Handler);
procedure Install_Abort_Handler (Handler : Abort_Handler);
procedure Uninstall_Abort_Handler;
pragma Inline (Install_Abort_Handler);
pragma Inline (Uninstall_Abort_Handler);
procedure Send_Abort_Signal (
Handle : Handle_Type;
Abort_Event : in out Synchronous_Objects.Event;
Error : out Boolean);
procedure Resend_Abort_Signal (Handle : Handle_Type; Error : out Boolean) is
null;
pragma Inline (Resend_Abort_Signal);
-- [gcc-7] can not skip calling null procedure
procedure Block_Abort_Signal (Abort_Event : Synchronous_Objects.Event);
procedure Unblock_Abort_Signal is null;
pragma Inline (Unblock_Abort_Signal);
-- [gcc-7] can not skip calling null procedure
-- scheduling
procedure Yield;
end System.Native_Tasks;
|
zhmu/ananas | Ada | 1,572 | adb | -- { dg-do run }
with Init13; use Init13;
with Ada.Numerics; use Ada.Numerics;
with Text_IO; use Text_IO;
with Dump;
procedure P13 is
Local_R1 : R1;
Local_R2 : R2;
begin
Put ("My_R1 :");
Dump (My_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "My_R1 : db 0f 49 40 db 0f 49 c0.*\n" }
Put ("My_R2 :");
Dump (My_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "My_R2 : 40 49 0f db c0 49 0f db.*\n" }
Local_R1 := My_R1;
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : db 0f 49 40 db 0f 49 c0.*\n" }
Local_R2 := My_R2;
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 40 49 0f db c0 49 0f db.*\n" }
Local_R1.F := (Pi, -Pi);
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : db 0f 49 40 db 0f 49 c0.*\n" }
Local_R2.F := (Pi, -Pi);
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 40 49 0f db c0 49 0f db.*\n" }
Local_R1.F := Local_R2.F;
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : db 0f 49 40 db 0f 49 c0.*\n" }
Local_R2.F := Local_R1.F;
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 40 49 0f db c0 49 0f db.*\n" }
end;
|
AdaCore/libadalang | Ada | 91 | adb | procedure Pkg.Foo is
X : Integer;
pragma Test_Statement;
begin
null;
end Pkg.Foo;
|
nateroling/swagger-codegen | Ada | 11,800 | adb | -- Swagger Petstore
-- This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special_key` to test the authorization filters.
--
-- OpenAPI spec version: 1.0.0
-- Contact: [email protected]
--
-- NOTE: This package is auto generated by the swagger code generator 2.3.1.
-- https://github.com/swagger-api/swagger-codegen.git
-- Do not edit the class manually.
package body Samples.Petstore.Models is
use Swagger.Streams;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in ApiResponse_Type) is
begin
Into.Start_Entity (Name);
Into.Write_Entity ("code", Value.Code);
Into.Write_Entity ("type", Value.P_Type);
Into.Write_Entity ("message", Value.Message);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in ApiResponse_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out ApiResponse_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "code", Value.Code);
Swagger.Streams.Deserialize (Object, "type", Value.P_Type);
Swagger.Streams.Deserialize (Object, "message", Value.Message);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out ApiResponse_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : ApiResponse_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Category_Type) is
begin
Into.Start_Entity (Name);
Serialize (Into, "id", Value.Id);
Into.Write_Entity ("name", Value.Name);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Category_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Category_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "id", Value.Id);
Swagger.Streams.Deserialize (Object, "name", Value.Name);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Category_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Category_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Order_Type) is
begin
Into.Start_Entity (Name);
Serialize (Into, "id", Value.Id);
Serialize (Into, "petId", Value.Pet_Id);
Into.Write_Entity ("quantity", Value.Quantity);
Into.Write_Entity ("shipDate", Value.Ship_Date);
Into.Write_Entity ("status", Value.Status);
Into.Write_Entity ("complete", Value.Complete);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Order_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Order_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "id", Value.Id);
Swagger.Streams.Deserialize (Object, "petId", Value.Pet_Id);
Swagger.Streams.Deserialize (Object, "quantity", Value.Quantity);
Deserialize (Object, "shipDate", Value.Ship_Date);
Swagger.Streams.Deserialize (Object, "status", Value.Status);
Swagger.Streams.Deserialize (Object, "complete", Value.Complete);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Order_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Order_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Tag_Type) is
begin
Into.Start_Entity (Name);
Serialize (Into, "id", Value.Id);
Into.Write_Entity ("name", Value.Name);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Tag_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Tag_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "id", Value.Id);
Swagger.Streams.Deserialize (Object, "name", Value.Name);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Tag_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Tag_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Pet_Type) is
begin
Into.Start_Entity (Name);
Serialize (Into, "id", Value.Id);
Serialize (Into, "category", Value.Category);
Into.Write_Entity ("name", Value.Name);
Serialize (Into, "photoUrls", Value.Photo_Urls);
Serialize (Into, "tags", Value.Tags);
Into.Write_Entity ("status", Value.Status);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Pet_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Pet_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "id", Value.Id);
Deserialize (Object, "category", Value.Category);
Swagger.Streams.Deserialize (Object, "name", Value.Name);
Swagger.Streams.Deserialize (Object, "photoUrls", Value.Photo_Urls);
Deserialize (Object, "tags", Value.Tags);
Swagger.Streams.Deserialize (Object, "status", Value.Status);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Pet_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : Pet_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in User_Type) is
begin
Into.Start_Entity (Name);
Serialize (Into, "id", Value.Id);
Into.Write_Entity ("username", Value.Username);
Into.Write_Entity ("firstName", Value.First_Name);
Into.Write_Entity ("lastName", Value.Last_Name);
Into.Write_Entity ("email", Value.Email);
Into.Write_Entity ("password", Value.Password);
Into.Write_Entity ("phone", Value.Phone);
Into.Write_Entity ("userStatus", Value.User_Status);
Into.End_Entity (Name);
end Serialize;
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in User_Type_Vectors.Vector) is
begin
Into.Start_Array (Name);
for Item of Value loop
Serialize (Into, "", Item);
end loop;
Into.End_Array (Name);
end Serialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out User_Type) is
Object : Swagger.Value_Type;
begin
Swagger.Streams.Deserialize (From, Name, Object);
Swagger.Streams.Deserialize (Object, "id", Value.Id);
Swagger.Streams.Deserialize (Object, "username", Value.Username);
Swagger.Streams.Deserialize (Object, "firstName", Value.First_Name);
Swagger.Streams.Deserialize (Object, "lastName", Value.Last_Name);
Swagger.Streams.Deserialize (Object, "email", Value.Email);
Swagger.Streams.Deserialize (Object, "password", Value.Password);
Swagger.Streams.Deserialize (Object, "phone", Value.Phone);
Swagger.Streams.Deserialize (Object, "userStatus", Value.User_Status);
end Deserialize;
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out User_Type_Vectors.Vector) is
List : Swagger.Value_Array_Type;
Item : User_Type;
begin
Value.Clear;
Swagger.Streams.Deserialize (From, Name, List);
for Data of List loop
Deserialize (Data, "", Item);
Value.Append (Item);
end loop;
end Deserialize;
end Samples.Petstore.Models;
|
jrmarino/zstd-ada | Ada | 1,930 | adb | with Zstandard.Functions; use Zstandard.Functions;
with Ada.Command_line; use Ada.Command_Line;
with Ada.Directories; use Ada.Directories;
with Ada.Text_IO; use Ada.Text_IO;
procedure Demo_Ada is
begin
if Argument_Count /= 1 then
Put_Line ("Zstandard version: " & Zstd_Version);
Put_Line ("usage:");
Put_Line (Command_Name & " <path/to/file.zst>");
return;
end if;
declare
path2file : String renames Argument (1);
namelen : constant Natural := path2file'Length;
nlast : constant Natural := path2file'Last;
begin
if not Exists (path2file) then
Put_Line ("File '" & path2file & "' does not exist, aborting.");
return;
else
if namelen < 5 or else
path2file (nlast - 3 .. nlast) /= ".zst"
then
Put_Line ("File name doesn't have the .zst extension, aborting.");
return;
end if;
end if;
end;
declare
type Real4 is digits 4;
path2file : String renames Argument (1);
nlast : constant Natural := path2file'Last;
decmpfile : String := path2file (path2file'First .. nlast - 4);
srcsize : Zstandard.Functions.File_Size;
dstsize : Zstandard.Functions.File_Size;
gooddecmp : Boolean;
error_msg : String := Decompress_File (source_file => path2file,
output_file => decmpfile,
source_size => srcsize,
output_size => dstsize,
successful => gooddecmp);
begin
if gooddecmp then
Put_Line (" original file size:" & srcsize'Img);
Put_Line (" compressed file size:" & dstsize'Img);
Put_Line (" new file: " & decmpfile);
else
Put_Line (error_msg);
end if;
end;
end Demo_Ada;
|
zhmu/ananas | Ada | 4,341 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.GENERIC_CONSTRAINED_ARRAY_SORT --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
-- This algorithm was adapted from GNAT.Heap_Sort_G (see g-hesorg.ad[sb])
procedure Ada.Containers.Generic_Constrained_Array_Sort
(Container : in out Array_Type)
is
subtype T is Long_Long_Integer;
function To_Index (J : T) return Index_Type;
pragma Inline (To_Index);
procedure Sift (S : T);
A : Array_Type renames Container;
--------------
-- To_Index --
--------------
function To_Index (J : T) return Index_Type is
K : constant T'Base := Index_Type'Pos (A'First) + J - T'(1);
begin
return Index_Type'Val (K);
end To_Index;
Max : T := A'Length;
Temp : Element_Type;
----------
-- Sift --
----------
procedure Sift (S : T) is
C : T := S;
Son : T;
begin
loop
Son := 2 * C;
exit when Son > Max;
declare
Son_Index : Index_Type := To_Index (Son);
begin
if Son < Max then
if A (Son_Index) < A (Index_Type'Succ (Son_Index)) then
Son := Son + 1;
Son_Index := Index_Type'Succ (Son_Index);
end if;
end if;
A (To_Index (C)) := A (Son_Index); -- Move (Son, C);
end;
C := Son;
end loop;
while C /= S loop
declare
Father : constant T := C / 2;
begin
if A (To_Index (Father)) < Temp then -- Lt (Father, 0)
A (To_Index (C)) := A (To_Index (Father)); -- Move (Father, C)
C := Father;
else
exit;
end if;
end;
end loop;
A (To_Index (C)) := Temp; -- Move (0, C);
end Sift;
-- Start of processing for Generic_Constrained_Array_Sort
begin
for J in reverse 1 .. Max / 2 loop
Temp := Container (To_Index (J)); -- Move (J, 0);
Sift (J);
end loop;
while Max > 1 loop
Temp := A (To_Index (Max)); -- Move (Max, 0);
A (To_Index (Max)) := A (A'First); -- Move (1, Max);
Max := Max - 1;
Sift (1);
end loop;
end Ada.Containers.Generic_Constrained_Array_Sort;
|
zhmu/ananas | Ada | 4,106 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . W C H _ S T W --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains the routine used to convert strings to wide (wide)
-- strings for use by wide (wide) image attribute.
with System.WCh_Con;
package System.WCh_StW is
pragma Pure;
procedure String_To_Wide_String
(S : String;
R : out Wide_String;
L : out Natural;
EM : System.WCh_Con.WC_Encoding_Method);
-- This routine simply takes its argument and converts it to wide string
-- format, storing the result in R (1 .. L), with L being set appropriately
-- on return. The caller guarantees that R is long enough to accommodate
-- the result. This is used in the context of the Wide_Image attribute,
-- where the argument is the corresponding 'Image attribute. Any wide
-- character escape sequences in the string are converted to the
-- corresponding wide character value. No syntax checks are made, it is
-- assumed that any such sequences are validly formed (this must be assured
-- by the caller), and results from the fact that Wide_Image is only used
-- on strings that have been built by the compiler, such as images of
-- enumeration literals. If the method for encoding is a shift-in,
-- shift-out convention, then it is assumed that normal (non-wide
-- character) mode holds at the start and end of the argument string. EM
-- indicates the wide character encoding method.
-- Note: in the WCEM_Brackets case, the brackets escape sequence is used
-- only for codes greater than 16#FF#.
procedure String_To_Wide_Wide_String
(S : String;
R : out Wide_Wide_String;
L : out Natural;
EM : System.WCh_Con.WC_Encoding_Method);
-- Same function with Wide_Wide_String output
end System.WCh_StW;
|
AdaCore/gpr | Ada | 95 | adb | with GNAT.IO; use GNAT.IO;
with Lib;
procedure main is
begin
Put_Line (Lib.Msg);
end main;
|
jwarwick/aoc_2020 | Ada | 303 | adb | -- AOC 2020, Day 24
with Ada.Text_IO; use Ada.Text_IO;
with Day; use Day;
procedure main is
part1 : constant Natural := count_tiles("input.txt");
part2 : constant Natural := evolve_tiles("input.txt", 100);
begin
put_line("Part 1: " & part1'IMAGE);
put_line("Part 2: " & part2'IMAGE);
end main;
|
onox/orka | Ada | 6,737 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2018 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with GL.Barriers;
with GL.Compute;
with GL.Types.Compute;
with Orka.Logging.Default;
with Orka.Rendering.Programs.Modules;
package body Orka.Culling is
use all type Orka.Logging.Default_Module;
use all type Orka.Logging.Severity;
procedure Log is new Orka.Logging.Default.Generic_Log (Renderer);
function Create_Culler
(Location : Resources.Locations.Location_Ptr) return Culler
is
use Rendering.Programs;
begin
return Result : Culler
:= (Program_Frustum => Create_Program (Modules.Create_Module
(Location, CS => "cull-frustum.comp")),
Program_Compact => Create_Program (Modules.Create_Module
(Location, CS => "compact-commands.comp")),
PS_Factory => Algorithms.Prefix_Sums.Create_Factory (Location),
others => <>)
do
Result.Uniform_CF_Instances := Result.Program_Frustum.Uniform ("instances");
Result.Uniform_VP := Result.Program_Frustum.Uniform ("viewProj");
Result.Uniform_CC_Instances := Result.Program_Compact.Uniform ("instances");
end return;
end Create_Culler;
function Create_Instance
(Culler : Culler_Ptr; Transforms, Commands : Natural) return Cull_Instance
is
use Rendering.Buffers;
use all type Types.Element_Type;
Work_Group_Size : constant GL.Types.Compute.Dimension_Size_Array
:= Culler.Program_Frustum.Compute_Work_Group_Size;
Local_Size : constant Natural := Natural (Work_Group_Size (X));
Padding : constant Boolean := Transforms rem Local_Size /= 0;
Work_Groups : constant Natural
:= Transforms / Local_Size + (if Padding then 1 else 0);
pragma Assert (Work_Groups <= 65_535);
begin
return Result : constant Cull_Instance
:= (Culler => Culler,
Work_Groups => Work_Groups,
Prefix_Sum => Algorithms.Prefix_Sums.Prefix_Sum
(Culler.PS_Factory.Create_Prefix_Sum (Transforms)),
Buffer_Visibles => Create_Buffer
(Flags => (others => False),
Kind => UInt_Type,
Length => Transforms),
Buffer_Indices => Create_Buffer
(Flags => (others => False),
Kind => UInt_Type,
Length => Transforms),
Compacted_Transforms => Create_Buffer
(Flags => (others => False),
Kind => Single_Matrix_Type,
Length => Transforms),
Compacted_Commands => Create_Buffer
(Flags => (others => False),
Kind => Elements_Command_Type,
Length => Commands))
do
Log (Debug, "Created culler for" &
Transforms'Image & " transforms and" &
Commands'Image & " commands");
Log (Debug, " cull frustum:" &
Work_Groups'Image & " groups x" & Local_Size'Image & " transforms");
end return;
end Create_Instance;
procedure Bind (Object : in out Culler; View_Projection : Transforms.Matrix4) is
begin
Object.Uniform_VP.Set_Matrix (View_Projection);
end Bind;
-----------------------------------------------------------------------------
procedure Memory_Barrier with Inline is
begin
GL.Barriers.Memory_Barrier ((Shader_Storage | Buffer_Update => True, others => False));
end Memory_Barrier;
use all type Rendering.Buffers.Indexed_Buffer_Target;
procedure Cull_Frustum
(Object : in out Cull_Instance;
Transforms : Rendering.Buffers.Bindable_Buffer'Class;
Bounds : Rendering.Buffers.Buffer) is
begin
Transforms.Bind (Shader_Storage, 0);
Bounds.Bind (Shader_Storage, 1);
Object.Buffer_Visibles.Bind (Shader_Storage, 2);
Object.Culler.Program_Frustum.Use_Program;
Memory_Barrier;
GL.Compute.Dispatch_Compute (X => Unsigned_32 (Object.Work_Groups));
end Cull_Frustum;
procedure Compact
(Object : in out Cull_Instance;
Transforms : Rendering.Buffers.Bindable_Buffer'Class;
Commands : Rendering.Buffers.Buffer) is
begin
Object.Buffer_Indices.Bind (Shader_Storage, 0);
Object.Buffer_Visibles.Bind (Shader_Storage, 1);
Transforms.Bind (Shader_Storage, 2);
Object.Compacted_Transforms.Bind (Shader_Storage, 3);
-- Buffer Commands acts as a template (with instanceCount = 0 for
-- every draw call), copy it to Compacted_Commands so that the
-- compute shader does not modify it
Commands.Copy_Data (Object.Compacted_Commands);
Object.Compacted_Commands.Bind (Shader_Storage, 4);
Object.Culler.Program_Compact.Use_Program;
Memory_Barrier;
GL.Compute.Dispatch_Compute (X => Unsigned_32 (Object.Work_Groups));
end Compact;
procedure Cull
(Object : in out Cull_Instance;
Transforms : Rendering.Buffers.Bindable_Buffer'Class;
Bounds, Commands : Rendering.Buffers.Buffer;
Compacted_Transforms, Compacted_Commands : out Rendering.Buffers.Buffer;
Instances : Natural) is
begin
Object.Culler.Uniform_CF_Instances.Set_UInt (Unsigned_32 (Instances));
Object.Culler.Uniform_CC_Instances.Set_UInt (Unsigned_32 (Instances));
-- Perform frustum culling and fill Buffer_Visibles with a 1 or 0
-- for each part depending on whether the part intersects the frustum
Object.Cull_Frustum (Transforms, Bounds);
-- Store the prefix sum of Buffer_Visibles in Buffer_Indices
Memory_Barrier;
Object.Buffer_Visibles.Copy_Data (Object.Buffer_Indices);
Object.Prefix_Sum.Compute_Prefix_Sum (Object.Buffer_Indices);
-- Create a compacted array of transforms: if a part is visible
-- according to Buffer_Visibles, then its transform will be copied
-- to the position denoted by the part's offset number in Buffer_Indices
Object.Compact (Transforms, Commands);
Compacted_Transforms := Object.Compacted_Transforms;
Compacted_Commands := Object.Compacted_Commands;
end Cull;
end Orka.Culling;
|
guillaume-lin/tsc | Ada | 7,149 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses2.util --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Eugene V. Melaragno <[email protected]> 2000
-- Version Control
-- $Revision: 1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Ada.Text_IO;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
pragma Warnings (Off);
with Terminal_Interface.Curses.Aux;
pragma Warnings (On);
with Terminal_Interface.Curses.Trace; use Terminal_Interface.Curses.Trace;
with Ada.Text_IO; use Ada.Text_IO;
with Interfaces.C;
with Interfaces.C.Strings;
with Ada.Characters.Handling;
with ncurses2.genericPuts;
package body ncurses2.util is
-- #defines from C
-- #define CTRL(x) ((x) & 0x1f)
function CTRL (c : Character) return Key_Code is
begin
return Character'Pos (c) mod 16#20#;
-- uses a property of ASCII
-- A = 16#41#; a = 16#61#; ^A = 1 or 16#1#
end CTRL;
function CTRL (c : Character) return Character is
begin
return Character'Val (Character'Pos (c) mod 16#20#);
-- uses a property of ASCII
-- A = 16#41#; a = 16#61#; ^A = 1 or 16#1#
end CTRL;
save_trace : Trace_Attribute_Set;
-- Common function to allow ^T to toggle trace-mode in the middle of a test
-- so that trace-files can be made smaller.
function Getchar (win : Window := Standard_Window) return Key_Code is
c : Key_Code;
begin
-- #ifdef TRACE
c := Get_Keystroke (win);
while c = CTRL ('T') loop
-- if _nc_tracing in C
if Current_Trace_Setting /= Trace_Disable then
save_trace := Current_Trace_Setting;
Trace_Put ("TOGGLE-TRACING OFF");
Current_Trace_Setting := Trace_Disable;
else
Current_Trace_Setting := save_trace;
end if;
Trace_On (Current_Trace_Setting);
if Current_Trace_Setting /= Trace_Disable then
Trace_Put ("TOGGLE-TRACING ON");
end if;
end loop;
-- #else c := Get_Keystroke;
return c;
end Getchar;
procedure Getchar (win : Window := Standard_Window) is
x : Key_Code;
begin
x := Getchar (win);
end Getchar;
procedure Pause is
begin
Move_Cursor (Line => Lines - 1, Column => 0);
Add (Str => "Press any key to continue... ");
Getchar;
end Pause;
procedure Cannot (s : String) is
use Interfaces.C;
use Interfaces.C.Strings;
use Terminal_Interface.Curses.Aux;
function getenv (x : char_array) return chars_ptr;
pragma Import (C, getenv, "getenv");
tmp1 : char_array (0 .. 10);
package p is new ncurses2.genericPuts (1024);
use p;
use p.BS;
tmpb : BS.Bounded_String;
Length : size_t;
begin
To_C ("TERM", tmp1, Length);
Fill_String (getenv (tmp1), tmpb);
Add (Ch => newl);
myAdd (Str => "This " & tmpb & " terminal " & s);
Pause;
end Cannot;
procedure ShellOut (message : Boolean) is
use Interfaces.C;
Txt : char_array (0 .. 10);
Length : size_t;
procedure system (x : char_array);
pragma Import (C, system, "system");
begin
To_C ("sh", Txt, Length);
if message then
Add (Str => "Shelling out...");
end if;
Save_Curses_Mode (Mode => Curses);
End_Windows;
system (Txt);
if message then
Add (Str => "returned from shellout.");
Add (Ch => newl);
end if;
Refresh;
end ShellOut;
function Is_Digit (c : Key_Code) return Boolean is
begin
if c >= 16#100# then
return False;
else
return Ada.Characters.Handling.Is_Digit (Character'Val (c));
end if;
end Is_Digit;
procedure P (s : String) is
begin
Add (Str => s);
Add (Ch => newl);
end P;
function Code_To_Char (c : Key_Code) return Character is
begin
if c > Character'Pos (Character'Last) then
return Character'Val (0);
-- maybe raise exception?
else
return Character'Val (c);
end if;
end Code_To_Char;
-- This was untestable due to a bug in GNAT (3.12p)
-- Hmm, what bug? I don't remember.
function ctoi (c : Character) return Integer is
begin
return Character'Pos (c) - Character'Pos ('0');
end ctoi;
end ncurses2.util;
|
dkm/atomic | Ada | 2,635 | ads | package Atomic
with Preelaborate,
Spark_Mode
is
type Mem_Order is
(Relaxed, -- Implies no inter-thread ordering constraints
Consume,
-- This is currently implemented using the stronger __ATOMIC_ACQUIRE
-- memory order because of a deficiency in C++11's semantics for
-- memory_order_consume.
Acquire,
-- Creates an inter-thread happens-before constraint from the release
-- (or stronger) semantic store to this acquire load. Can prevent
-- hoisting of code to before the operation.
Release,
-- Creates an inter-thread happens-before constraint to acquire (or
-- stronger) semantic loads that read from this release store. Can
-- prevent sinking of code to after the operation.
Acq_Rel, -- Combines the effects of both Acquire and Release
Seq_Cst); -- Enforces total ordering with all other Seq_Cst operations
for Mem_Order use
(Relaxed => 0,
Consume => 1,
Acquire => 2,
Release => 3,
Acq_Rel => 4,
Seq_Cst => 5);
function Stronger (A, B : Mem_Order) return Boolean;
----------
-- Flag --
----------
type Flag is limited private;
function Init (Val : Boolean) return Flag
with Post => Value (Init'Result) = Val;
-- Can be used to initialize an Atomic_Flag:
--
-- A : Atomic.Flag := Atomic.Init (0);
function Set (This : aliased Flag;
Order : Mem_Order := Seq_Cst)
return Boolean
with Pre => Order in Relaxed | Consume | Acquire | Seq_Cst,
Post => Set'Result = Value (This);
procedure Test_And_Set (This : aliased in out Flag;
Result : out Boolean;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and then Value (This) = True;
procedure Clear (This : aliased in out Flag;
Order : Mem_Order := Seq_Cst)
with Pre => Order in Relaxed | Release | Seq_Cst,
Post => Value (This) = False;
function Value (This : Flag) return Boolean
with Ghost;
-- Ghost function to get the value of an Flag without needing it aliased.
-- This doesn't use the atomic built-ins.
private
function Stronger (A, B : Mem_Order) return Boolean
is (A > B);
type Flag is mod 2 ** 8
with Size => 8;
-----------
-- Value --
-----------
function Value (This : Flag) return Boolean
is (This /= 0);
pragma Inline (Init);
pragma Inline (Set);
pragma Inline (Test_And_Set);
pragma Inline (Clear);
pragma Inline (Value);
end Atomic;
|
reznikmm/matreshka | Ada | 4,696 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Style.Text_Underline_Width_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Text_Underline_Width_Attribute_Node is
begin
return Self : Style_Text_Underline_Width_Attribute_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Text_Underline_Width_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Text_Underline_Width_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Text_Underline_Width_Attribute,
Style_Text_Underline_Width_Attribute_Node'Tag);
end Matreshka.ODF_Style.Text_Underline_Width_Attributes;
|
MinimSecure/unum-sdk | Ada | 1,446 | adb | -- Copyright 2010-2016 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;
package body Mixed is
-- We are importing symbols from foo.o, so make sure this object file
-- gets linked in.
Pragma Linker_Options ("foo.o");
type Color is (Red, Green, Blue);
procedure C_Function;
pragma Import (C, C_Function, "c_function");
procedure Callme;
pragma Export (C, Callme, "callme");
procedure Break_Me (Light : Color) is
begin
Put_Line ("Light: " & Color'Image (Light)); -- STOP
end Break_Me;
procedure Callme is
begin
Break_Me (Red);
Break_Me (Green);
Break_Me (Blue);
end Callme;
procedure Start_Test is
begin
-- Call C_Function, which will call Callme.
C_Function;
end Start_Test;
end Mixed;
|
DrenfongWong/tkm-rpc | Ada | 2,618 | ads | with Tkmrpc.Types;
with Tkmrpc.Operations.Ike;
package Tkmrpc.Request.Ike.Esa_Create is
Data_Size : constant := 320;
type Data_Type is record
Esa_Id : Types.Esa_Id_Type;
Isa_Id : Types.Isa_Id_Type;
Sp_Id : Types.Sp_Id_Type;
Ea_Id : Types.Ea_Id_Type;
Dh_Id : Types.Dh_Id_Type;
Nc_Loc_Id : Types.Nc_Id_Type;
Nonce_Rem : Types.Nonce_Type;
Initiator : Types.Init_Type;
Esp_Spi_Loc : Types.Esp_Spi_Type;
Esp_Spi_Rem : Types.Esp_Spi_Type;
end record;
for Data_Type use record
Esa_Id at 0 range 0 .. (8 * 8) - 1;
Isa_Id at 8 range 0 .. (8 * 8) - 1;
Sp_Id at 16 range 0 .. (4 * 8) - 1;
Ea_Id at 20 range 0 .. (8 * 8) - 1;
Dh_Id at 28 range 0 .. (8 * 8) - 1;
Nc_Loc_Id at 36 range 0 .. (8 * 8) - 1;
Nonce_Rem at 44 range 0 .. (260 * 8) - 1;
Initiator at 304 range 0 .. (8 * 8) - 1;
Esp_Spi_Loc at 312 range 0 .. (4 * 8) - 1;
Esp_Spi_Rem at 316 range 0 .. (4 * 8) - 1;
end record;
for Data_Type'Size use Data_Size * 8;
Padding_Size : constant := Request.Body_Size - Data_Size;
subtype Padding_Range is Natural range 1 .. Padding_Size;
subtype Padding_Type is Types.Byte_Sequence (Padding_Range);
type Request_Type is record
Header : Request.Header_Type;
Data : Data_Type;
Padding : Padding_Type;
end record;
for Request_Type use record
Header at 0 range 0 .. (Request.Header_Size * 8) - 1;
Data at Request.Header_Size range 0 .. (Data_Size * 8) - 1;
Padding at Request.Header_Size + Data_Size range
0 .. (Padding_Size * 8) - 1;
end record;
for Request_Type'Size use Request.Request_Size * 8;
Null_Request : constant Request_Type :=
Request_Type'
(Header =>
Request.Header_Type'(Operation => Operations.Ike.Esa_Create,
Request_Id => 0),
Data =>
Data_Type'(Esa_Id => Types.Esa_Id_Type'First,
Isa_Id => Types.Isa_Id_Type'First,
Sp_Id => Types.Sp_Id_Type'First,
Ea_Id => Types.Ea_Id_Type'First,
Dh_Id => Types.Dh_Id_Type'First,
Nc_Loc_Id => Types.Nc_Id_Type'First,
Nonce_Rem => Types.Null_Nonce_Type,
Initiator => Types.Init_Type'First,
Esp_Spi_Loc => Types.Esp_Spi_Type'First,
Esp_Spi_Rem => Types.Esp_Spi_Type'First),
Padding => Padding_Type'(others => 0));
end Tkmrpc.Request.Ike.Esa_Create;
|
reznikmm/matreshka | Ada | 27,202 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Named_Elements;
with AMF.String_Collections;
with AMF.UML.Activities;
with AMF.UML.Activity_Edges.Collections;
with AMF.UML.Activity_Groups.Collections;
with AMF.UML.Activity_Nodes.Collections;
with AMF.UML.Activity_Partitions.Collections;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Constraints.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Element_Imports.Collections;
with AMF.UML.Exception_Handlers.Collections;
with AMF.UML.Input_Pins.Collections;
with AMF.UML.Interruptible_Activity_Regions.Collections;
with AMF.UML.Named_Elements.Collections;
with AMF.UML.Namespaces;
with AMF.UML.Output_Pins.Collections;
with AMF.UML.Package_Imports.Collections;
with AMF.UML.Packageable_Elements.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Structured_Activity_Nodes;
with AMF.UML.Variables.Collections;
with AMF.Visitors;
package AMF.Internals.UML_Structured_Activity_Nodes is
type UML_Structured_Activity_Node_Proxy is
limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy
and AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node with null record;
overriding function Get_Activity
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activities.UML_Activity_Access;
-- Getter of StructuredActivityNode::activity.
--
-- Activity immediately containing the node.
overriding procedure Set_Activity
(Self : not null access UML_Structured_Activity_Node_Proxy;
To : AMF.UML.Activities.UML_Activity_Access);
-- Setter of StructuredActivityNode::activity.
--
-- Activity immediately containing the node.
overriding function Get_Edge
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of StructuredActivityNode::edge.
--
-- Edges immediately contained in the structured node.
overriding function Get_Must_Isolate
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return Boolean;
-- Getter of StructuredActivityNode::mustIsolate.
--
-- If true, then the actions in the node execute in isolation from actions
-- outside the node.
overriding procedure Set_Must_Isolate
(Self : not null access UML_Structured_Activity_Node_Proxy;
To : Boolean);
-- Setter of StructuredActivityNode::mustIsolate.
--
-- If true, then the actions in the node execute in isolation from actions
-- outside the node.
overriding function Get_Node
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node;
-- Getter of StructuredActivityNode::node.
--
-- Nodes immediately contained in the group.
overriding function Get_Structured_Node_Input
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Input_Pins.Collections.Set_Of_UML_Input_Pin;
-- Getter of StructuredActivityNode::structuredNodeInput.
--
overriding function Get_Structured_Node_Output
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Output_Pins.Collections.Set_Of_UML_Output_Pin;
-- Getter of StructuredActivityNode::structuredNodeOutput.
--
overriding function Get_Variable
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Variables.Collections.Set_Of_UML_Variable;
-- Getter of StructuredActivityNode::variable.
--
-- A variable defined in the scope of the structured activity node. It has
-- no value and may not be accessed
overriding function Get_Element_Import
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import;
-- Getter of Namespace::elementImport.
--
-- References the ElementImports owned by the Namespace.
overriding function Get_Imported_Member
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Getter of Namespace::importedMember.
--
-- References the PackageableElements that are members of this Namespace
-- as a result of either PackageImports or ElementImports.
overriding function Get_Member
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::member.
--
-- A collection of NamedElements identifiable within the Namespace, either
-- by being owned or by being introduced by importing or inheritance.
overriding function Get_Owned_Member
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::ownedMember.
--
-- A collection of NamedElements owned by the Namespace.
overriding function Get_Owned_Rule
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Namespace::ownedRule.
--
-- Specifies a set of Constraints owned by this Namespace.
overriding function Get_Package_Import
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import;
-- Getter of Namespace::packageImport.
--
-- References the PackageImports owned by the Namespace.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Structured_Activity_Node_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Get_Contained_Edge
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityGroup::containedEdge.
--
-- Edges immediately contained in the group.
overriding function Get_Contained_Node
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node;
-- Getter of ActivityGroup::containedNode.
--
-- Nodes immediately contained in the group.
overriding function Get_In_Activity
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activities.UML_Activity_Access;
-- Getter of ActivityGroup::inActivity.
--
-- Activity containing the group.
overriding procedure Set_In_Activity
(Self : not null access UML_Structured_Activity_Node_Proxy;
To : AMF.UML.Activities.UML_Activity_Access);
-- Setter of ActivityGroup::inActivity.
--
-- Activity containing the group.
overriding function Get_Subgroup
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group;
-- Getter of ActivityGroup::subgroup.
--
-- Groups immediately contained in the group.
overriding function Get_Super_Group
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activity_Groups.UML_Activity_Group_Access;
-- Getter of ActivityGroup::superGroup.
--
-- Group immediately containing the group.
overriding function Get_Context
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Classifiers.UML_Classifier_Access;
-- Getter of Action::context.
--
-- The classifier that owns the behavior of which this action is a part.
overriding function Get_Input
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Input_Pins.Collections.Ordered_Set_Of_UML_Input_Pin;
-- Getter of Action::input.
--
-- The ordered set of input pins connected to the Action. These are among
-- the total set of inputs.
overriding function Get_Is_Locally_Reentrant
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return Boolean;
-- Getter of Action::isLocallyReentrant.
--
-- If true, the action can begin a new, concurrent execution, even if
-- there is already another execution of the action ongoing. If false, the
-- action cannot begin a new execution until any previous execution has
-- completed.
overriding procedure Set_Is_Locally_Reentrant
(Self : not null access UML_Structured_Activity_Node_Proxy;
To : Boolean);
-- Setter of Action::isLocallyReentrant.
--
-- If true, the action can begin a new, concurrent execution, even if
-- there is already another execution of the action ongoing. If false, the
-- action cannot begin a new execution until any previous execution has
-- completed.
overriding function Get_Local_Postcondition
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Action::localPostcondition.
--
-- Constraint that must be satisfied when executed is completed.
overriding function Get_Local_Precondition
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Action::localPrecondition.
--
-- Constraint that must be satisfied when execution is started.
overriding function Get_Output
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Output_Pins.Collections.Ordered_Set_Of_UML_Output_Pin;
-- Getter of Action::output.
--
-- The ordered set of output pins connected to the Action. The action
-- places its results onto pins in this set.
overriding function Get_Handler
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Exception_Handlers.Collections.Set_Of_UML_Exception_Handler;
-- Getter of ExecutableNode::handler.
--
-- A set of exception handlers that are examined if an uncaught exception
-- propagates to the outer level of the executable node.
overriding function Get_In_Group
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group;
-- Getter of ActivityNode::inGroup.
--
-- Groups containing the node.
overriding function Get_In_Interruptible_Region
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region;
-- Getter of ActivityNode::inInterruptibleRegion.
--
-- Interruptible regions containing the node.
overriding function Get_In_Partition
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition;
-- Getter of ActivityNode::inPartition.
--
-- Partitions containing the node.
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access;
-- Getter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Structured_Activity_Node_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access);
-- Setter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding function Get_Incoming
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::incoming.
--
-- Edges that have the node as target.
overriding function Get_Outgoing
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::outgoing.
--
-- Edges that have the node as source.
overriding function Get_Redefined_Node
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node;
-- Getter of ActivityNode::redefinedNode.
--
-- Inherited nodes replaced by this node in a specialization of the
-- activity.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Structured_Activity_Node_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function Exclude_Collisions
(Self : not null access constant UML_Structured_Activity_Node_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::excludeCollisions.
--
-- The query excludeCollisions() excludes from a set of
-- PackageableElements any that would not be distinguishable from each
-- other in this namespace.
overriding function Get_Names_Of_Member
(Self : not null access constant UML_Structured_Activity_Node_Proxy;
Element : AMF.UML.Named_Elements.UML_Named_Element_Access)
return AMF.String_Collections.Set_Of_String;
-- Operation Namespace::getNamesOfMember.
--
-- The query getNamesOfMember() takes importing into account. It gives
-- back the set of names that an element would have in an importing
-- namespace, either because it is owned, or if not owned then imported
-- individually, or if not individually then from a package.
-- The query getNamesOfMember() gives a set of all of the names that a
-- member would have in a Namespace. In general a member can have multiple
-- names in a Namespace if it is imported more than once with different
-- aliases. The query takes account of importing. It gives back the set of
-- names that an element would have in an importing namespace, either
-- because it is owned, or if not owned then imported individually, or if
-- not individually then from a package.
overriding function Import_Members
(Self : not null access constant UML_Structured_Activity_Node_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importMembers.
--
-- The query importMembers() defines which of a set of PackageableElements
-- are actually imported into the namespace. This excludes hidden ones,
-- i.e., those which have names that conflict with names of owned members,
-- and also excludes elements which would have the same name when imported.
overriding function Imported_Member
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importedMember.
--
-- The importedMember property is derived from the ElementImports and the
-- PackageImports. References the PackageableElements that are members of
-- this Namespace as a result of either PackageImports or ElementImports.
overriding function Members_Are_Distinguishable
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return Boolean;
-- Operation Namespace::membersAreDistinguishable.
--
-- The Boolean query membersAreDistinguishable() determines whether all of
-- the namespace's members are distinguishable within it.
overriding function Owned_Member
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Namespace::ownedMember.
--
-- Missing derivation for Namespace::/ownedMember : NamedElement
overriding function All_Owning_Packages
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Structured_Activity_Node_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Context
(Self : not null access constant UML_Structured_Activity_Node_Proxy)
return AMF.UML.Classifiers.UML_Classifier_Access;
-- Operation Action::context.
--
-- Missing derivation for Action::/context : Classifier
overriding function Is_Consistent_With
(Self : not null access constant UML_Structured_Activity_Node_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Structured_Activity_Node_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding procedure Enter_Element
(Self : not null access constant UML_Structured_Activity_Node_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Structured_Activity_Node_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Structured_Activity_Node_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Structured_Activity_Nodes;
|
reznikmm/matreshka | Ada | 3,641 | 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 XML.DOM.Elements;
package ODF.DOM.Elements.Text.Outline_Style is
type ODF_Text_Outline_Style is
new XML.DOM.Elements.DOM_Element with private;
private
type ODF_Text_Outline_Style is
new XML.DOM.Elements.DOM_Element with null record;
end ODF.DOM.Elements.Text.Outline_Style;
|
flyx/OpenGLAda | Ada | 836 | adb | -- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with Interfaces.C.Strings;
with Glfw.API;
package body Glfw.Windows.Clipboard is
function Get (Object : not null access Window'Class) return String is
use type Interfaces.C.Strings.chars_ptr;
Raw : constant Interfaces.C.Strings.chars_ptr
:= API.Get_Clipboard_String (Object.Handle);
begin
if Raw = Interfaces.C.Strings.Null_Ptr then
raise Operation_Exception with "Could not get clipboard string";
end if;
return Interfaces.C.Strings.Value (Raw);
end Get;
procedure Set (Object : not null access Window'Class; Value : String) is
begin
API.Set_Clipboard_String (Object.Handle, Interfaces.C.To_C (Value));
end Set;
end Glfw.Windows.Clipboard;
|
jrcarter/Ada_GUI | Ada | 4,839 | adb | -- --
-- package Strings_Edit.Fields Copyright (c) Dmitry A. Kazakov --
-- Implementation Luebeck --
-- Spring, 2002 --
-- --
-- Last revision : 21:03 21 Apr 2009 --
-- --
-- This library 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 2 of --
-- the License, or (at your option) any later version. This 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 --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
package body Strings_Edit.Fields is
function Get_Output_Field
( Destination : String;
Pointer : Integer;
Field : Natural
) return Natural is
Result : Natural := Field;
begin
if Result = 0 then
Result := Destination'Last - Pointer + 1;
end if;
if ( Pointer < Destination'First
or else
Pointer + Result - 1 > Destination'Last
)
then
raise Layout_Error;
end if;
return Result;
end Get_Output_Field;
procedure Adjust_Output_Field
( Destination : in out String;
Pointer : in out Integer;
Index : Integer;
Out_Field : Natural;
Field : Natural;
Justify : Alignment;
Fill : Character
) is
begin
if Field = 0 then
Pointer := Index;
else
declare
Last : constant Integer := Pointer + Out_Field - 1;
begin
if Out_Field /= Index - Pointer then
case Justify is
when Left =>
for Position in Index..Last loop
Destination (Position) := Fill;
end loop;
when Center =>
declare
Length : constant Natural := Index - Pointer;
First : constant Integer :=
Pointer + (Out_Field - Length) / 2;
Next : constant Integer := First + Length;
begin
Destination (First..Next - 1) :=
Destination (Pointer..Index - 1);
for Position in Pointer..First - 1 loop
Destination (Position) := Fill;
end loop;
for Position in Next..Last loop
Destination (Position) := Fill;
end loop;
end;
when Right =>
declare
First : constant Integer :=
Last + 1 - Index + Pointer;
begin
Destination (First..Last) :=
Destination (Pointer..Index - 1);
for Position in Pointer..First - 1 loop
Destination (Position) := Fill;
end loop;
end;
end case;
end if;
Pointer := Last + 1;
end;
end if;
end Adjust_Output_Field;
end Strings_Edit.Fields;
|
reznikmm/matreshka | Ada | 16,824 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-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$
------------------------------------------------------------------------------
pragma Ada_2012;
private package XML.SAX.Simple_Readers.Scanner.Actions is
function On_Attribute_Name_In_Attribute_List_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles name of the attribute in the attribute list declaration.
function On_Attribute_Type
(Self : in out Simple_Reader'Class;
Type_Token : Token) return Token;
-- Handles attribute type in attribute type declaration. Checks whether
-- whitespace is present before type keyword and resets whitespace flag.
-- Returns Type_Token on success, otherwise return Error.
function On_Open_Parenthesis_In_Notation_Attribute
(Self : in out Simple_Reader'Class) return Token;
-- Handles open parenthesis in notation attribute delaration. Checks
-- whether whitespace is present before open parenthesis. Returns
-- Token_Open_Parenthesis on success and reports error and returns Error
-- othewise.
function On_Close_Parenthesis_In_Notation_Attribute
(Self : in out Simple_Reader'Class) return Token;
-- Handles close parenthesis in notation attribute delaration. Resets
-- whitespace matching flag. Returns Token_Close_Parenthesis.
procedure On_Attribute_Value_Character_Data
(Self : in out Simple_Reader'Class);
-- Handles character data in the attribute value.
function On_Attribute_Value_Close_Delimiter
(Self : in out Simple_Reader'Class) return Boolean;
-- Process close delimiter of attribute value. Returns True when
-- attribute's value is closed.
function On_Attribute_Value_Open_Delimiter
(Self : in out Simple_Reader'Class;
State : Interfaces.Unsigned_32) return Boolean;
-- Process open delimiter of attribute value. Returns True on success,
-- otherwise returns False.
procedure On_Attribute_Value_Open_Delimiter
(Self : in out Simple_Reader'Class;
State : Interfaces.Unsigned_32);
-- Process open delimiter of attribute value. Same as before, but doesn't
-- check presence of whitespace before delimiter.
function On_Character_Data
(Self : in out Simple_Reader'Class) return Token;
-- Handles character data in as well as apperance of forbidden ']]>' string
-- in the character data.
function On_Character_Reference
(Self : in out Simple_Reader'Class;
Hex : Boolean) return Token;
-- Processes character reference, except character reference in attribute
-- value.
function On_Character_Reference_In_Attribute_Value
(Self : in out Simple_Reader'Class;
Hex : Boolean) return Boolean;
-- Processes character reference in attribute value. Returns False when
-- error was detected and reported to application.
function On_Close_Of_Conditional_Section
(Self : in out Simple_Reader'Class) return Token;
-- Handles close of conditional section.
function On_Close_Of_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles close of entity declaration.
function On_Close_Of_Document_Type_Declaration
(Self : in out Simple_Reader'Class) return Boolean;
-- Handles close of document type declaration. Returns True when
-- close token must be returned to parser, otherwise scanning must be
-- continued because it pushes external subset entity into the scanner's
-- stack.
function On_Close_Of_Empty_Element_Tag
(Self : in out Simple_Reader'Class) return Token;
-- Handles close of empty element tag.
function On_Close_Of_Processing_Instruction
(Self : in out Simple_Reader'Class;
Is_Empty : Boolean) return Token;
-- Handles close of processing instructio. When Is_Empty is True it means
-- that processing instruction doesn't have data.
function On_Close_Of_Tag
(Self : in out Simple_Reader'Class) return Token;
-- Handles close of element tag and of document type declaration,
function On_Close_Of_XML_Or_Text_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles close of XML declaration and text declaration.
procedure On_Conditional_Section_Directive
(Self : in out Simple_Reader'Class;
Include : Boolean);
-- Handles directive of conditional section.
procedure On_Content_Of_Ignore_Conditional_Section
(Self : in out Simple_Reader'Class);
-- Handles content of ignore conditional section.
function On_Default_Declaration
(Self : in out Simple_Reader'Class;
State : Interfaces.Unsigned_32;
Default_Token : Token) return Token;
-- Handles default declaration of attribute definition. Checks for
-- whitespace before the token and returns Error when this check fail,
-- otherwise returns Default_Token. Resets whitespace detection flag and
-- enter specified start condition.
function On_Element_Name_In_Attribute_List_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles element's name in attribute list declaration.
function On_Entity_Value_Close_Delimiter
(Self : in out Simple_Reader'Class) return Token;
-- Process entity value close delimiter, rule [9]. It is also handle
-- "Include In Literal" (4.4.5) mode for parameter entities, when quotation
-- and apostrophe characters are not recognized as delimiters.
function On_Entity_Value_Open_Delimiter
(Self : in out Simple_Reader'Class) return Token;
-- Handles open delimiter of entity value.
function On_General_Entity_Reference_In_Attribute_Value
(Self : in out Simple_Reader'Class) return Boolean;
-- Handles general entity reference in attribute value.
function On_General_Entity_Reference_In_Document_Content
(Self : in out Simple_Reader'Class) return Token;
-- Handles general entity reference in document content. Do several checks
-- and push entity contents into the scanner's stack. Returns
-- Token_Entity_Start on success when replacement text is pushed in stack;
-- End_Of_Input when replacement text is empty and doesn't pushed into the
-- stack; and returns Error on any error.
function On_General_Entity_Reference_In_Entity_Value
(Self : in out Simple_Reader'Class) return Token;
-- Handles general entity reference in entity value.
function On_Parameter_Entity_Reference_In_Entity_Value
(Self : in out Simple_Reader'Class) return Boolean;
-- Handles parameter entity reference in entity value.
function On_Parameter_Entity_Reference_In_Markup_Declaration
(Self : in out Simple_Reader'Class) return Boolean;
-- Handles parameter entity reference inside markup declaration in the
-- document type declaration.
function On_Parameter_Entity_Reference_In_Document_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles parameter entity reference outside of markup declaration in the
-- document type declaration.
function On_Less_Than_Sign_In_Attribute_Value
(Self : in out Simple_Reader'Class) return Token;
-- Handling of less-than sign in attribute value.
function On_Name_In_Attribute_List_Declaration_Notation
(Self : in out Simple_Reader'Class) return Token;
-- Handles name of the notation in the attribute list declaration.
function On_Name_In_Element_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles name of the element declaration.
function On_Name_In_Element_Declaration_Children
(Self : in out Simple_Reader'Class) return Token;
-- Handles name of the children element in element declaration.
function On_Name_In_Element_Start_Tag
(Self : in out Simple_Reader'Class) return Token;
-- Handles name of the attribute in element start tag or empty element tag.
function On_Name_In_Entity_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles name of the entity in the entity declaration.
function On_Name_In_Entity_Declaration_Notation
(Self : in out Simple_Reader'Class) return Token;
-- Handles name of the notation in the entity declaration.
function On_NDATA (Self : in out Simple_Reader'Class) return Token;
-- Handles NDATA keyword in entity declaration.
procedure On_No_XML_Declaration (Self : in out Simple_Reader'Class);
-- Handles start of document and external parsed entities which doesn't
-- starts from XML declaration.
function On_Open_Of_Attribute_List_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles open of attribute list declaration.
function On_Open_Of_Conditional_Section
(Self : in out Simple_Reader'Class) return Token;
-- Handles open of conditional section. Returns Token_Conditional_Open on
-- success, Error otherwise.
function On_Open_Of_Conditional_Section_Content
(Self : in out Simple_Reader'Class) return Boolean;
-- Handles open of content of conditional section.
function On_Open_Of_Document_Type_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles open of document type declaration.
function On_Open_Of_Element_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles open of element declaration.
function On_Open_Of_End_Tag
(Self : in out Simple_Reader'Class) return Token;
-- Handles open of end tag.
function On_Open_Of_Internal_Subset
(Self : in out Simple_Reader'Class) return Token;
-- Handles open of internal subset of document type declaration.
function On_Open_Of_Notation_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles open of notation declaration.
function On_Open_Of_Processing_Instruction
(Self : in out Simple_Reader'Class) return Token;
-- Handles open of processing instruction.
function On_Open_Of_Start_Tag
(Self : in out Simple_Reader'Class) return Token;
-- Handles open of start tag or empty element tag.
function On_Open_Of_XML_Or_Text_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles open of XML declaration in document or text declaration in
-- external entity or external subset.
function On_Public_Literal
(Self : in out Simple_Reader'Class) return Token;
-- Handles public literal.
function On_System_Literal
(Self : in out Simple_Reader'Class) return Token;
-- Handles system literal.
function On_Unexpected_Character
(Self : in out Simple_Reader'Class) return Token;
-- General handling of unexpected character.
function On_Whitespace_In_Document
(Self : in out Simple_Reader'Class) return Boolean;
-- Handles whitespaces outside of markup. Returns True and sets YYLVal when
-- document content analysis started, and return False otherwise.
procedure On_Whitespace_In_Processing_Instruction
(Self : in out Simple_Reader'Class);
-- Handles sequence of whitespaces between processing instruction's target
-- and data.
function On_Version_Keyword
(Self : in out Simple_Reader'Class) return Token;
-- Handles 'version' keyword in XML declaration or text declaration.
function On_Encoding_Keyword
(Self : in out Simple_Reader'Class) return Token;
-- Handles 'encoding' keyword in XML declaration or text declaration.
function On_Standalone_Keyword
(Self : in out Simple_Reader'Class) return Token;
-- Handles 'standalone' keyword in XML declaration.
function On_Percent_Sign
(Self : in out Simple_Reader'Class) return Token;
-- Handles percent sign in parameter entity declaration.
function On_CDATA (Self : in out Simple_Reader'Class) return Token;
-- Handles CDATA section.
function On_Close_Parenthesis_In_Content_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles close parenthesis in element content model and mixed content
-- declaration, productions [49], [50], [51].
function On_Open_Parenthesis_In_Content_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles open parenthesis in element content model and mixed content
-- declaration, productions [49], [50], [51].
function On_Question_Mark_In_Content_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles question mark in element content model, productions [47], [48].
function On_Plus_In_Content_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles plus in element content model, productions [47], [48].
function On_Asterisk_In_Content_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles asterisk in element content model and mixed content declaration,
-- productions [47], [48], [51].
function On_Open_Of_CDATA
(Self : in out Simple_Reader'Class) return Token;
-- Handles open of CDATA section.
function On_Close_Of_CDATA
(Self : in out Simple_Reader'Class) return Token;
-- Handles close of CDATA section.
function On_Attribute_Value_In_XML_Declaration
(Self : in out Simple_Reader'Class) return Token;
-- Handles value of attribute in the XML declaration.
function On_System_Keyword_In_Document_Type
(Self : in out Simple_Reader'Class) return Token;
-- Handles SYSTEM keyword in document type declaration.
function On_System_Keyword_In_Entity_Or_Notation
(Self : in out Simple_Reader'Class) return Token;
-- Handles SYSTEM keyword in entity definition or notation declaration.
end XML.SAX.Simple_Readers.Scanner.Actions;
|
AdaCore/gpr | Ada | 76 | adb | -- windows version
package body Pck is
procedure Call is null;
end Pck;
|
osannolik/ada-canopen | Ada | 2,578 | ads | with Ada.Real_Time;
with ACO.CANopen;
private with ACO.Events;
private with ACO.Utils.Generic_Alarms;
private with ACO.Slave_Monitors;
package ACO.Protocols.Error_Control.Masters is
type Master
(Id : ACO.Messages.Node_Nr;
Handler : not null access ACO.CANopen.Handler;
Od : not null access ACO.OD.Object_Dictionary'Class)
is new EC with private;
procedure Periodic_Actions
(This : in out Master;
T_Now : in Ada.Real_Time.Time);
private
package Alarms is new ACO.Utils.Generic_Alarms (1);
type Heartbeat_Producer_Alarm
(Ref : not null access Master)
is new Alarms.Alarm_Type with null record;
overriding
procedure Signal
(This : access Heartbeat_Producer_Alarm;
T_Now : in Ada.Real_Time.Time);
type Entry_Update_Subscriber
(Ref : not null access Master)
is new ACO.Events.Event_Listener (ACO.Events.OD_Entry_Update)
with null record;
overriding
procedure On_Event
(This : in out Entry_Update_Subscriber;
Data : in ACO.Events.Event_Data);
type Node_State_Change_Subscriber
(Ref : not null access Master)
is new ACO.Events.Event_Listener (ACO.Events.State_Transition)
with null record;
overriding
procedure On_Event
(This : in out Node_State_Change_Subscriber;
Data : in ACO.Events.Event_Data);
type Master
(Id : ACO.Messages.Node_Nr;
Handler : not null access ACO.CANopen.Handler;
Od : not null access ACO.OD.Object_Dictionary'Class)
is new EC (Id, Od) with record
Entry_Update : aliased Entry_Update_Subscriber (Master'Access);
State_Change : aliased Node_State_Change_Subscriber (Master'Access);
Timers : Alarms.Alarm_Manager;
Producer_Alarm : aliased Heartbeat_Producer_Alarm (Master'Access);
Monitor : ACO.Slave_Monitors.Slave_Monitor (Od);
end record;
overriding
procedure Initialize
(This : in out Master);
overriding
procedure Finalize
(This : in out Master);
procedure On_Heartbeat
(This : in out Master;
Id : in ACO.Messages.Node_Nr;
Hbt_State : in EC_Commands.EC_State);
function Create_Heartbeat
(State : ACO.States.State;
Node_Id : ACO.Messages.Node_Nr)
return ACO.Messages.Message;
procedure Send_Bootup
(This : in out Master);
procedure Heartbeat_Producer_Start
(This : in out Master);
procedure Heartbeat_Producer_Stop
(This : in out Master);
end ACO.Protocols.Error_Control.Masters;
|
zhmu/ananas | Ada | 620 | adb | -- { dg-do run }
with Interfaces; use Interfaces;
procedure Exp0_Eval is
F_Count : Natural := 0;
function F return Integer is
begin
F_Count := F_Count + 1;
return 1;
end F;
function F return Unsigned_32 is
begin
F_Count := F_Count + 1;
return 1;
end F;
R : constant Integer :=
F ** 0 +
F * 0 +
0 * F +
Integer (Unsigned_32'(F) mod 1) +
Integer (Unsigned_32'(F) rem 1);
pragma Warnings (Off, R);
begin
if F_Count /= 5 then
raise Program_Error
with "incorrect numbers of calls to F:" & F_Count'Img;
end if;
end Exp0_Eval;
|
Heziode/lsystem-editor | Ada | 1,797 | adb | -------------------------------------------------------------------------------
-- LSE -- L-System Editor
-- Author: Heziode
--
-- License:
-- MIT License
--
-- Copyright (c) 2018 Quentin Dauprat (Heziode) <[email protected]>
--
-- 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, 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
-- AUTHORS OR 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.
-------------------------------------------------------------------------------
package body LSE.Model.L_System.Error.Missing_Rule is
function Initialize return Instance
is
begin
return Instance '(Error => Error_Type.Missing_Rule);
end Initialize;
function Get_Error (This : Instance) return String
is
pragma Unreferenced (This);
begin
return "No Growth Rule found";
end Get_Error;
end LSE.Model.L_System.Error.Missing_Rule;
|
AdaCore/Ada_Drivers_Library | Ada | 2,431 | 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. --
-- --
------------------------------------------------------------------------------
with MCP23x08.I2C;
package MCP23008 renames MCP23x08.I2C;
|
reznikmm/matreshka | Ada | 4,001 | 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.Smil_KeySplines_Attributes;
package Matreshka.ODF_Smil.KeySplines_Attributes is
type Smil_KeySplines_Attribute_Node is
new Matreshka.ODF_Smil.Abstract_Smil_Attribute_Node
and ODF.DOM.Smil_KeySplines_Attributes.ODF_Smil_KeySplines_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Smil_KeySplines_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Smil_KeySplines_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Smil.KeySplines_Attributes;
|
reznikmm/matreshka | Ada | 5,075 | 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.ODF_String_Constants;
package body Matreshka.ODF_Anim is
------------------
-- Constructors --
------------------
package body Constructors is
----------------
-- Initialize --
----------------
procedure Initialize
(Self : not null access Abstract_Anim_Attribute_Node'Class;
Document : not null Matreshka.DOM_Nodes.Document_Access;
Prefix : League.Strings.Universal_String) is
begin
Matreshka.DOM_Attributes.Constructors.Initialize (Self, Document);
Self.Prefix := Prefix;
end Initialize;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : not null access Abstract_Anim_Element_Node'Class;
Document : not null Matreshka.DOM_Nodes.Document_Access;
Prefix : League.Strings.Universal_String) is
begin
Matreshka.DOM_Elements.Constructors.Initialize (Self, Document);
Self.Prefix := Prefix;
end Initialize;
end Constructors;
-----------------------
-- Get_Namespace_URI --
-----------------------
overriding function Get_Namespace_URI
(Self : not null access constant Abstract_Anim_Attribute_Node)
return League.Strings.Universal_String is
begin
return Matreshka.ODF_String_Constants.Anim_URI;
end Get_Namespace_URI;
-----------------------
-- Get_Namespace_URI --
-----------------------
overriding function Get_Namespace_URI
(Self : not null access constant Abstract_Anim_Element_Node)
return League.Strings.Universal_String is
begin
return Matreshka.ODF_String_Constants.Anim_URI;
end Get_Namespace_URI;
end Matreshka.ODF_Anim;
|
AdaDoom3/wayland_ada_binding | Ada | 3,230 | ads | ------------------------------------------------------------------------------
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 3, or (at your option) any later --
-- version. This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
-- This unit provides a specialization of the element traits, for use with
-- definite elements, i.e. elements whose size is known at compile time.
-- Such elements do not need an extra level of indirection via pointers to
-- be stored in a container.
pragma Ada_2012;
generic
type Element_Type is private;
-- Must be a copyable type (as defined in conts-elements.ads), and
-- therefore not a pointer type. In such a case, use
-- conts-elements-indefinite.ads instead, and let it do the allocations
-- itself.
with procedure Free (E : in out Element_Type) is null;
-- Free is called when the element is no longer used (removed from
-- its container for instance). Most of the time this will do
-- nothing, but this procedure is useful if the Element_Type is an
-- access type that you want to deallocate.
Movable : Boolean := True; -- should be False for controlled types
package Conts.Elements.Definite with SPARK_Mode is
function Identity (E : Element_Type) return Element_Type is (E) with Inline;
package Traits is new Conts.Elements.Traits
(Element_Type => Element_Type,
Stored_Type => Element_Type,
Returned_Type => Element_Type,
Constant_Returned_Type => Element_Type,
Copyable => True,
Movable => Movable,
Release => Free,
To_Stored => Identity,
To_Returned => Identity,
To_Constant_Returned => Identity,
To_Element => Identity,
Copy => Identity);
end Conts.Elements.Definite;
|
sungyeon/drake | Ada | 4,722 | ads | pragma License (Unrestricted);
with Ada.Calendar.Time_Zones;
package Ada.Calendar.Formatting is
-- Day of the week:
type Day_Name is (
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday);
-- modified
-- function Day_of_Week (Date : Time) return Day_Name;
function Day_Of_Week (
Date : Time;
Time_Zone : Time_Zones.Time_Offset := 0) -- additional
return Day_Name;
pragma Pure_Function (Day_Of_Week);
pragma Inline (Day_Of_Week);
-- Note: RM defined Day_*o*f_Week, but GNAT runtime defined Day_*O*f_Week.
-- Hours:Minutes:Seconds access:
subtype Hour_Number is Natural range 0 .. 23;
subtype Minute_Number is Natural range 0 .. 59;
subtype Second_Number is Natural range 0 .. 59;
subtype Second_Duration is Day_Duration range 0.0 .. 1.0;
function Year (Date : Time; Time_Zone : Time_Zones.Time_Offset := 0)
return Year_Number;
pragma Pure_Function (Year);
pragma Inline (Year);
function Month (Date : Time; Time_Zone : Time_Zones.Time_Offset := 0)
return Month_Number;
pragma Pure_Function (Month);
pragma Inline (Month);
function Day (Date : Time; Time_Zone : Time_Zones.Time_Offset := 0)
return Day_Number;
pragma Pure_Function (Day);
pragma Inline (Day);
function Hour (Date : Time; Time_Zone : Time_Zones.Time_Offset := 0)
return Hour_Number;
pragma Pure_Function (Hour);
pragma Inline (Hour);
function Minute (Date : Time; Time_Zone : Time_Zones.Time_Offset := 0)
return Minute_Number;
pragma Pure_Function (Minute);
pragma Inline (Minute);
function Second (Date : Time) return Second_Number;
pragma Pure_Function (Second);
pragma Inline (Second);
function Sub_Second (Date : Time) return Second_Duration;
pragma Pure_Function (Sub_Second);
-- extended
-- This function returns seconds in a day
-- (including the offset of the time zone).
function Seconds (Date : Time; Time_Zone : Time_Zones.Time_Offset := 0)
return Day_Duration;
pragma Pure_Function (Seconds);
-- Note: Seconds is inefficient.
function Seconds_Of (
Hour : Hour_Number;
Minute : Minute_Number;
Second : Second_Number := 0;
Sub_Second : Second_Duration := 0.0)
return Day_Duration;
procedure Split (
Seconds : Day_Duration;
Hour : out Hour_Number;
Minute : out Minute_Number;
Second : out Second_Number;
Sub_Second : out Second_Duration);
function Time_Of (
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Hour : Hour_Number;
Minute : Minute_Number;
Second : Second_Number;
Sub_Second : Second_Duration := 0.0;
Leap_Second : Boolean := False;
Time_Zone : Time_Zones.Time_Offset := 0)
return Time;
function Time_Of (
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Seconds : Day_Duration := 0.0;
Leap_Second : Boolean := False;
Time_Zone : Time_Zones.Time_Offset := 0)
return Time;
procedure Split (
Date : Time;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number;
Hour : out Hour_Number;
Minute : out Minute_Number;
Second : out Second_Number;
Sub_Second : out Second_Duration;
Time_Zone : Time_Zones.Time_Offset := 0);
procedure Split (
Date : Time;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number;
Hour : out Hour_Number;
Minute : out Minute_Number;
Second : out Second_Number;
Sub_Second : out Second_Duration;
Leap_Second : out Boolean;
Time_Zone : Time_Zones.Time_Offset := 0);
procedure Split (
Date : Time;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number;
Seconds : out Day_Duration;
Leap_Second : out Boolean;
Time_Zone : Time_Zones.Time_Offset := 0);
-- Simple image and value:
function Image (
Date : Time;
Include_Time_Fraction : Boolean := False;
Time_Zone : Time_Zones.Time_Offset := 0)
return String;
function Value (
Date : String;
Time_Zone : Time_Zones.Time_Offset := 0)
return Time;
function Image (
Elapsed_Time : Duration;
Include_Time_Fraction : Boolean := False)
return String;
function Value (Elapsed_Time : String) return Duration;
-- extended
-- The format of time-zone is "+00:00".
function Image (Time_Zone : Time_Zones.Time_Offset) return String;
function Value (Time_Zone : String) return Time_Zones.Time_Offset;
end Ada.Calendar.Formatting;
|
Kidev/Ada_Drivers_Library | Ada | 16,912 | adb | ------------------------------------------------------------------------------
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with STM32.DMA2D.Interrupt;
with STM32.DMA2D.Polling;
with STM32.SDRAM; use STM32.SDRAM;
package body Framebuffer_LTDC is
procedure Internal_Update_Layer
(Display : in out Frame_Buffer;
Layer : Positive);
----------------
-- Initialize --
----------------
procedure Initialize
(Display : in out Frame_Buffer;
Width : Positive;
Height : Positive;
H_Sync : Natural;
H_Back_Porch : Natural;
H_Front_Porch : Natural;
V_Sync : Natural;
V_Back_Porch : Natural;
V_Front_Porch : Natural;
PLLSAI_N : UInt9;
PLLSAI_R : UInt3;
DivR : Natural;
Orientation : HAL.Framebuffer.Display_Orientation := Default;
Mode : HAL.Framebuffer.Wait_Mode := Interrupt)
is
begin
Display.Width := Width;
Display.Height := Height;
if (Width > Height and then Orientation = Portrait)
or else (Height > Width and then Orientation = Landscape)
then
Display.Swapped := True;
else
Display.Swapped := False;
end if;
STM32.LTDC.Initialize
(Width => Width,
Height => Height,
H_Sync => H_Sync,
H_Back_Porch => H_Back_Porch,
H_Front_Porch => H_Front_Porch,
V_Sync => V_Sync,
V_Back_Porch => V_Back_Porch,
V_Front_Porch => V_Front_Porch,
PLLSAI_N => PLLSAI_N,
PLLSAI_R => PLLSAI_R,
DivR => DivR);
STM32.SDRAM.Initialize;
case Mode is
when Polling =>
STM32.DMA2D.Polling.Initialize;
when Interrupt =>
STM32.DMA2D.Interrupt.Initialize;
end case;
end Initialize;
---------------------
-- Set_Orientation --
---------------------
overriding procedure Set_Orientation
(Display : in out Frame_Buffer;
Orientation : HAL.Framebuffer.Display_Orientation)
is
Old : constant Boolean := Display.Swapped;
Tmp : Natural;
use STM32.DMA2D_Bitmap;
begin
if (Display.Width > Display.Height and then Orientation = Portrait)
or else
(Display.Height > Display.Width and then Orientation = Landscape)
then
Display.Swapped := True;
else
Display.Swapped := False;
end if;
if Old = Display.Swapped then
return;
end if;
for Layer in STM32.LTDC.LCD_Layer loop
for Buf in 1 .. 2 loop
if Display.Buffers (Layer, Buf) /= Null_Buffer then
Display.Buffers (Layer, Buf).Currently_Swapped := Display.Swapped;
Tmp := Display.Buffers (Layer, Buf).Actual_Width;
Display.Buffers (Layer, Buf).Actual_Width :=
Display.Buffers (Layer, Buf).Height;
Display.Buffers (Layer, Buf).Actual_Height := Tmp;
Display.Buffers (Layer, Buf).Set_Source (HAL.Bitmap.Black);
Display.Buffers (Layer, Buf).Fill;
end if;
end loop;
end loop;
end Set_Orientation;
--------------
-- Set_Mode --
--------------
overriding procedure Set_Mode
(Display : in out Frame_Buffer;
Mode : HAL.Framebuffer.Wait_Mode)
is
pragma Unreferenced (Display);
begin
case Mode is
when Polling =>
STM32.DMA2D.Polling.Initialize;
when Interrupt =>
STM32.DMA2D.Interrupt.Initialize;
end case;
end Set_Mode;
-----------------
-- Initialized --
-----------------
overriding function Initialized
(Display : Frame_Buffer) return Boolean
is
pragma Unreferenced (Display);
begin
return STM32.LTDC.Initialized;
end Initialized;
----------------
-- Max_Layers --
----------------
overriding function Max_Layers
(Display : Frame_Buffer)
return Positive
is
pragma Unreferenced (Display);
begin
return 2;
end Max_Layers;
---------------
-- Supported --
---------------
overriding function Supported
(Display : Frame_Buffer;
Mode : HAL.Framebuffer.FB_Color_Mode) return Boolean
is
pragma Unreferenced (Display, Mode);
begin
-- The LTDC supports all HAL color modes
return True;
end Supported;
-----------
-- Width --
-----------
overriding function Width
(Display : Frame_Buffer)
return Positive
is
begin
if not Display.Swapped then
return Display.Width;
else
return Display.Height;
end if;
end Width;
------------
-- Height --
------------
overriding function Height
(Display : Frame_Buffer)
return Positive
is
begin
if not Display.Swapped then
return Display.Height;
else
return Display.Width;
end if;
end Height;
-------------
-- Swapped --
-------------
overriding function Swapped
(Display : Frame_Buffer) return Boolean
is
begin
return Display.Swapped;
end Swapped;
--------------------
-- Set_Background --
--------------------
overriding procedure Set_Background
(Display : Frame_Buffer; R, G, B : UInt8)
is
pragma Unreferenced (Display);
begin
STM32.LTDC.Set_Background (R, G, B);
end Set_Background;
----------------------
-- Initialize_Layer --
----------------------
overriding procedure Initialize_Layer
(Display : in out Frame_Buffer;
Layer : Positive;
Mode : HAL.Framebuffer.FB_Color_Mode;
X : Natural := 0;
Y : Natural := 0;
Width : Positive := Positive'Last;
Height : Positive := Positive'Last)
is
LCD_Layer : constant STM32.LTDC.LCD_Layer :=
(if Layer = 1
then STM32.LTDC.Layer1
else STM32.LTDC.Layer2);
W : Natural := Width;
H : Natural := Height;
X0 : Natural := X;
Y0 : Natural := Y;
begin
if Display.Swapped then
if Height = Positive'Last then
W := Display.Width;
else
W := Height;
end if;
if Width = Positive'Last then
H := Display.Height;
else
H := Width;
end if;
X0 := Y;
Y0 := Display.Height - X - H;
end if;
if X0 >= Display.Width then
raise Constraint_Error with "Layer X position outside of screen";
elsif Y0 >= Display.Height then
raise Constraint_Error with "Layer Y position outside of screen";
end if;
if W = Positive'Last or else X0 + W > Display.Width then
W := Display.Width - X0;
end if;
if H = Positive'Last or else Y0 + H > Display.Height then
H := Display.Height - Y0;
end if;
if not Display.Swapped then
for Buf in 1 .. 2 loop
Display.Buffers (LCD_Layer, Buf) :=
(Addr =>
Reserve (UInt32 (HAL.Bitmap.Bits_Per_Pixel (Mode) * W * H / 8)),
Actual_Width => W,
Actual_Height => H,
Actual_Color_Mode => Mode,
Currently_Swapped => False,
Native_Source => 0);
Display.Buffers (LCD_Layer, Buf).Set_Source (HAL.Bitmap.Black);
Display.Buffers (LCD_Layer, Buf).Fill;
end loop;
else
for Buf in 1 .. 2 loop
Display.Buffers (LCD_Layer, Buf) :=
(Addr =>
Reserve (UInt32 (HAL.Bitmap.Bits_Per_Pixel (Mode) * W * H / 8)),
Actual_Width => H,
Actual_Height => W,
Actual_Color_Mode => Mode,
Currently_Swapped => True,
Native_Source => 0);
Display.Buffers (LCD_Layer, Buf).Set_Source (HAL.Bitmap.Black);
Display.Buffers (LCD_Layer, Buf).Fill;
end loop;
end if;
Display.Current (LCD_Layer) := 1;
STM32.LTDC.Layer_Init
(Layer => LCD_Layer,
Config => STM32.LTDC.To_LTDC_Mode (Mode),
Buffer => Display.Buffers (LCD_Layer, 1).Addr,
X => X0,
Y => Y0,
W => W,
H => H,
Constant_Alpha => 255,
BF => STM32.LTDC.BF_Pixel_Alpha_X_Constant_Alpha);
end Initialize_Layer;
-----------------
-- Initialized --
-----------------
overriding function Initialized
(Display : Frame_Buffer;
Layer : Positive) return Boolean
is
LCD_Layer : constant STM32.LTDC.LCD_Layer :=
(if Layer = 1
then STM32.LTDC.Layer1
else STM32.LTDC.Layer2);
use type STM32.DMA2D_Bitmap.DMA2D_Bitmap_Buffer;
begin
return
Display.Buffers (LCD_Layer, 1) /= STM32.DMA2D_Bitmap.Null_Buffer;
end Initialized;
---------------------------
-- Internal_Update_Layer --
---------------------------
procedure Internal_Update_Layer
(Display : in out Frame_Buffer;
Layer : Positive)
is
LCD_Layer : constant STM32.LTDC.LCD_Layer :=
(if Layer = 1
then STM32.LTDC.Layer1
else STM32.LTDC.Layer2);
begin
case Display.Current (LCD_Layer) is
when 0 =>
null;
when 1 =>
Display.Buffers (LCD_Layer, 2).Wait_Transfer;
STM32.LTDC.Set_Frame_Buffer
(Layer => LCD_Layer,
Addr => Display.Buffers (LCD_Layer, 2).Addr);
Display.Current (LCD_Layer) := 2;
when 2 =>
Display.Buffers (LCD_Layer, 1).Wait_Transfer;
STM32.LTDC.Set_Frame_Buffer
(Layer => LCD_Layer,
Addr => Display.Buffers (LCD_Layer, 1).Addr);
Display.Current (LCD_Layer) := 1;
end case;
end Internal_Update_Layer;
------------------
-- Update_Layer --
------------------
overriding procedure Update_Layer
(Display : in out Frame_Buffer;
Layer : Positive;
Copy_Back : Boolean := False)
is
Visible, Hidden : STM32.DMA2D_Bitmap.DMA2D_Bitmap_Buffer;
LCD_Layer : constant STM32.LTDC.LCD_Layer :=
(if Layer = 1
then STM32.LTDC.Layer1
else STM32.LTDC.Layer2);
begin
Internal_Update_Layer (Display, Layer);
STM32.LTDC.Reload_Config (Immediate => False);
if Copy_Back then
if Display.Current (LCD_Layer) = 1 then
Visible := Display.Buffers (LCD_Layer, 1);
Hidden := Display.Buffers (LCD_Layer, 2);
else
Visible := Display.Buffers (LCD_Layer, 2);
Hidden := Display.Buffers (LCD_Layer, 1);
end if;
STM32.DMA2D_Bitmap.Copy_Rect
(Visible, (0, 0), Hidden, (0, 0), Visible.Width, Visible.Height,
Synchronous => True);
end if;
end Update_Layer;
-------------------
-- Update_Layers --
-------------------
overriding procedure Update_Layers
(Display : in out Frame_Buffer)
is
begin
for J in 1 .. 2 loop
if Display.Initialized (J) then
Internal_Update_Layer (Display, J);
end if;
end loop;
STM32.LTDC.Reload_Config (Immediate => False);
end Update_Layers;
-------------------
-- Update_Layers --
-------------------
procedure Update_Layers
(Display : in out Frame_Buffer;
Copy_Layer1 : Boolean;
Copy_Layer2 : Boolean)
is
use type STM32.LTDC.LCD_Layer;
Visible, Hidden : STM32.DMA2D_Bitmap.DMA2D_Bitmap_Buffer;
begin
for J in 1 .. 2 loop
if Display.Initialized (J) then
Internal_Update_Layer (Display, J);
end if;
end loop;
STM32.LTDC.Reload_Config (Immediate => False);
for LCD_Layer in STM32.LTDC.LCD_Layer'Range loop
if (LCD_Layer = STM32.LTDC.Layer1 and then Copy_Layer1)
or else (LCD_Layer = STM32.LTDC.Layer2 and then Copy_Layer2)
then
if Display.Current (LCD_Layer) = 1 then
Visible := Display.Buffers (LCD_Layer, 1);
Hidden := Display.Buffers (LCD_Layer, 2);
else
Visible := Display.Buffers (LCD_Layer, 2);
Hidden := Display.Buffers (LCD_Layer, 1);
end if;
STM32.DMA2D_Bitmap.Copy_Rect
(Visible, (0, 0), Hidden, (0, 0), Visible.Width, Visible.Height,
Synchronous => True);
end if;
end loop;
end Update_Layers;
----------------
-- Color_Mode --
----------------
overriding function Color_Mode
(Display : Frame_Buffer;
Layer : Positive)
return HAL.Framebuffer.FB_Color_Mode
is
LCD_Layer : constant STM32.LTDC.LCD_Layer :=
(if Layer = 1
then STM32.LTDC.Layer1
else STM32.LTDC.Layer2);
begin
return Display.Buffers (LCD_Layer, 1).Color_Mode;
end Color_Mode;
-------------------
-- Hidden_Buffer --
-------------------
overriding function Hidden_Buffer
(Display : in out Frame_Buffer;
Layer : Positive)
return not null HAL.Bitmap.Any_Bitmap_Buffer
is
LCD_Layer : constant STM32.LTDC.LCD_Layer :=
(if Layer = 1
then STM32.LTDC.Layer1
else STM32.LTDC.Layer2);
begin
case Display.Current (LCD_Layer) is
when 0 | 2 =>
return Display.Buffers (LCD_Layer, 1)'Unchecked_Access;
when 1 =>
return Display.Buffers (LCD_Layer, 2)'Unchecked_Access;
end case;
end Hidden_Buffer;
----------------
-- Pixel_Size --
----------------
overriding function Pixel_Size
(Display : Frame_Buffer;
Layer : Positive) return Positive
is
LCD_Layer : constant STM32.LTDC.LCD_Layer :=
(if Layer = 1
then STM32.LTDC.Layer1
else STM32.LTDC.Layer2);
begin
return
HAL.Bitmap.Bits_Per_Pixel
(Display.Buffers (LCD_Layer, 1).Color_Mode) / 8;
end Pixel_Size;
end Framebuffer_LTDC;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 2,436 | ads | with STM32GD.GPIO; use STM32GD.GPIO;
with STM32GD.GPIO.Pin;
with STM32GD.SPI;
with STM32GD.SPI.Peripheral;
with STM32GD.USART;
with STM32GD.USART.Peripheral;
with STM32GD.RTC;
with STM32GD.Clock;
with STM32GD.Clock.Tree;
with Drivers.Text_IO;
package STM32GD.Board is
package CLOCKS is new STM32GD.Clock.Tree;
package GPIO renames STM32GD.GPIO;
package SCLK is new GPIO.Pin (Pin => GPIO.Pin_5, Port => GPIO.Port_A, Mode => GPIO.Mode_AF);
package MISO is new GPIO.Pin (Pin => GPIO.Pin_6, Port => GPIO.Port_A, Mode => GPIO.Mode_AF);
package MOSI is new GPIO.Pin (Pin => GPIO.Pin_7, Port => GPIO.Port_A, Mode => GPIO.Mode_AF);
package CSN is new GPIO.Pin (Pin => GPIO.Pin_4, Port => GPIO.Port_A, Mode => GPIO.Mode_Out);
package LED is new GPIO.Pin (Pin => GPIO.Pin_1, Port => GPIO.Port_A, Mode => GPIO.Mode_Out);
package TX is new GPIO.Pin (Pin => GPIO.Pin_2, Port => GPIO.Port_A, Pull_Resistor => GPIO.Pull_Up, Mode => GPIO.Mode_AF, Alternate_Function => 1);
package RX is new GPIO.Pin (Pin => GPIO.Pin_3, Port => GPIO.Port_A, Pull_Resistor => GPIO.Pull_Up, Mode => GPIO.Mode_AF, Alternate_Function => 1);
package P1_IN is new GPIO.Pin (Pin => GPIO.Pin_8, Port => GPIO.Port_A);
package P2_IN is new GPIO.Pin (Pin => GPIO.Pin_11, Port => GPIO.Port_A);
package P3_IN is new GPIO.Pin (Pin => GPIO.Pin_12, Port => GPIO.Port_A);
package P4_IN is new GPIO.Pin (Pin => GPIO.Pin_14, Port => GPIO.Port_A);
package P5_IN is new GPIO.Pin (Pin => GPIO.Pin_3, Port => GPIO.Port_B);
package P6_IN is new GPIO.Pin (Pin => GPIO.Pin_4, Port => GPIO.Port_B);
package P7_IN is new GPIO.Pin (Pin => GPIO.Pin_5, Port => GPIO.Port_B);
package P8_IN is new GPIO.Pin (Pin => GPIO.Pin_6, Port => GPIO.Port_B);
package P9_IN is new GPIO.Pin (Pin => GPIO.Pin_7, Port => GPIO.Port_B);
package P10_IN is new GPIO.Pin (Pin => GPIO.Pin_0, Port => GPIO.Port_A);
package USART is new STM32GD.USART.Peripheral (USART => STM32GD.USART.USART_2, Speed => 115200,
Clock_Tree => CLOCKS, Clock => STM32GD.Clock.PCLK);
package RTC is new STM32GD.RTC (Clock_Tree => STM32GD.Board.Clocks, Clock => STM32GD.Clock.LSI);
package Text_IO is new Drivers.Text_IO (USART => STM32GD.Board.USART);
package SPI is new STM32GD.SPI.Peripheral (SPI => STM32GD.SPI.SPI_1);
procedure Init;
end STM32GD.Board;
|
iyan22/AprendeAda | Ada | 146 | adb | with ada.text_io, ada.integer_text_io;
use ada.text_io, ada.integer_text_io;
procedure sacar_ficha is
begin
put("Ficha sale");
end sacar_ficha; |
AdaCore/libadalang | Ada | 89 | ads | with Boo;
package Far is
pragma Section ("In Far");
pragma Test (Boo.A);
end Far;
|
LiberatorUSA/GUCEF | Ada | 3,187 | adb | package body agar.gui.widget.file_dialog is
use type c.int;
package cbinds is
function allocate_mru
(parent : widget_access_t;
key : cs.chars_ptr;
flags : flags_t) return file_dialog_access_t;
pragma import (c, allocate_mru, "AG_FileDlgNewMRU");
function set_directory
(dialog : file_dialog_access_t;
path : cs.chars_ptr) return c.int;
pragma import (c, set_directory, "AG_FileDlgSetDirectoryS");
procedure set_directory_mru
(dialog : file_dialog_access_t;
key : cs.chars_ptr;
path : cs.chars_ptr);
pragma import (c, set_directory_mru, "AG_FileDlgSetDirectoryMRU");
procedure set_filename
(dialog : file_dialog_access_t;
file : cs.chars_ptr);
pragma import (c, set_filename, "AG_FileDlgSetFilenameS");
function add_filetype
(dialog : file_dialog_access_t;
description : cs.chars_ptr;
extensions : cs.chars_ptr;
fmt : agar.core.types.void_ptr_t) return filetype_access_t;
pragma import (c, add_filetype, "AG_FileDlgAddType");
end cbinds;
function allocate_mru
(parent : widget_access_t;
key : string;
flags : flags_t) return file_dialog_access_t
is
ca_key : aliased c.char_array := c.to_c (key);
begin
return cbinds.allocate_mru
(parent => parent,
key => cs.to_chars_ptr (ca_key'unchecked_access),
flags => flags);
end allocate_mru;
function set_directory
(dialog : file_dialog_access_t;
path : string) return boolean
is
ca_path : aliased c.char_array := c.to_c (path);
begin
return cbinds.set_directory
(dialog => dialog,
path => cs.to_chars_ptr (ca_path'unchecked_access)) = 0;
end set_directory;
procedure set_directory_mru
(dialog : file_dialog_access_t;
key : string;
path : string)
is
ca_key : aliased c.char_array := c.to_c (key);
ca_path : aliased c.char_array := c.to_c (path);
begin
cbinds.set_directory_mru
(dialog => dialog,
key => cs.to_chars_ptr (ca_key'unchecked_access),
path => cs.to_chars_ptr (ca_path'unchecked_access));
end set_directory_mru;
procedure set_filename
(dialog : file_dialog_access_t;
file : string)
is
ca_file : aliased c.char_array := c.to_c (file);
begin
cbinds.set_filename
(dialog => dialog,
file => cs.to_chars_ptr (ca_file'unchecked_access));
end set_filename;
function add_filetype
(dialog : file_dialog_access_t;
description : string;
extensions : string) return filetype_access_t
is
ca_desc : aliased c.char_array := c.to_c (description);
ca_ext : aliased c.char_array := c.to_c (extensions);
begin
return cbinds.add_filetype
(dialog => dialog,
description => cs.to_chars_ptr (ca_desc'unchecked_access),
extensions => cs.to_chars_ptr (ca_ext'unchecked_access),
fmt => agar.core.types.null_ptr);
end add_filetype;
function widget (dialog : file_dialog_access_t) return widget_access_t is
begin
return dialog.widget'access;
end widget;
end agar.gui.widget.file_dialog;
|
GauBen/Arbre-Genealogique | Ada | 3,097 | ads | -- Package Graphe
-- Gère le stockage et la manipulation de graphes orientés.
-- Généricité :
-- Les sommets et les arêtes sont étiquetés par les éléments des types
-- T_Etiquette_Sommet et T_Etiquette_Arete
generic
type T_Etiquette_Sommet is private;
type T_Etiquette_Arete is private;
package Graphe is
-- Type accessibles de l'extérieur : le graphe et la liste d'adjacence,
-- pour explorer les arêtes sortant d'un sommet
type T_Graphe is limited private;
type T_Liste_Adjacence is limited private;
-- Type public pour la lecture de la liste d'adjacence
type T_Arete_Etiquetee is record
Etiquette : T_Etiquette_Arete;
Destination : T_Etiquette_Sommet;
end record;
-- Exceptions : une étiquette donnée ne correspond � aucun sommet
Sommet_Non_Trouve : exception;
-- La liste donnée est vide
Vide : exception;
-- Initialise un graphe vide.
procedure Initialiser (Graphe : out T_Graphe);
-- Libère l'espace mémoire occupé par un graphe.
procedure Detruire (Graphe : in out T_Graphe);
-- Ajoute un sommet au graphe avec l'étiquette donnée.
procedure Ajouter_Sommet
(Graphe : in out T_Graphe; Etiquette : T_Etiquette_Sommet);
-- Ajoute une arête entre deux sommets donnés.
procedure Ajouter_Arete
(Graphe : in out T_Graphe; Origine : in T_Etiquette_Sommet;
Etiquette : in T_Etiquette_Arete; Destination : in T_Etiquette_Sommet);
-- Renvoie la liste des arêtes sortant du sommet donné.
procedure Chaine_Adjacence
(Adjacence : out T_Liste_Adjacence; Graphe : in T_Graphe;
Origine : in T_Etiquette_Sommet);
-- Renvoie vrai si on peut continuer à itérer.
function Adjacence_Non_Vide (Adjacence : T_Liste_Adjacence) return Boolean;
-- Lit l'arête suivante et avance la lecture.
procedure Arete_Suivante
(Adjacence : in out T_Liste_Adjacence; Arete : out T_Arete_Etiquetee);
procedure Supprimer_Arete
(Graphe : in T_Graphe; Origine : in T_Etiquette_Sommet;
Etiquette_Arete : in T_Etiquette_Arete;
Destination : in T_Etiquette_Sommet);
function Indiquer_Sommet_Existe
(Graphe : T_Graphe; Etiquette : T_Etiquette_Sommet) return Boolean;
function Est_Vide (Graphe : T_Graphe) return Boolean;
-- Applique une procédure P sur tous les éléments du registre.
generic
with procedure P (Cle : in T_Etiquette_Sommet; Liste : in out T_Liste_Adjacence);
procedure Appliquer_Sur_Tous_Sommets (Graphe : in T_Graphe);
private
-- Un graphe est représenté par une liste chaînée de sommets
-- et les arêtes par une liste chaînée aussi
type T_Sommet;
type T_Arete;
type T_Graphe is access T_Sommet;
type T_Liste_Adjacence is access T_Arete;
type T_Sommet is record
Etiquette : T_Etiquette_Sommet;
Arete : T_Liste_Adjacence;
Suivant : T_Graphe;
end record;
type T_Arete is record
Etiquette : T_Etiquette_Arete;
Destination : T_Graphe;
Suivante : T_Liste_Adjacence;
end record;
end Graphe;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.