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
19,045
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.Visitors.UML_Iterators; with AMF.Visitors.UML_Visitors; with League.Strings.Internals; with Matreshka.Internals.Strings; package body AMF.Internals.UML_Enumeration_Literals is ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant UML_Enumeration_Literal_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Enter_Enumeration_Literal (AMF.UML.Enumeration_Literals.UML_Enumeration_Literal_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant UML_Enumeration_Literal_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Leave_Enumeration_Literal (AMF.UML.Enumeration_Literals.UML_Enumeration_Literal_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant UML_Enumeration_Literal_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then AMF.Visitors.UML_Iterators.UML_Iterator'Class (Iterator).Visit_Enumeration_Literal (Visitor, AMF.UML.Enumeration_Literals.UML_Enumeration_Literal_Access (Self), Control); end if; end Visit_Element; -------------------- -- Get_Classifier -- -------------------- overriding function Get_Classifier (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Enumerations.UML_Enumeration_Access is begin return AMF.UML.Enumerations.UML_Enumeration_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Classifier (Self.Element))); end Get_Classifier; --------------------- -- Get_Enumeration -- --------------------- overriding function Get_Enumeration (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Enumerations.UML_Enumeration_Access is begin return AMF.UML.Enumerations.UML_Enumeration_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Enumeration (Self.Element))); end Get_Enumeration; --------------------- -- Set_Enumeration -- --------------------- overriding procedure Set_Enumeration (Self : not null access UML_Enumeration_Literal_Proxy; To : AMF.UML.Enumerations.UML_Enumeration_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Enumeration (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Enumeration; -------------------- -- Get_Classifier -- -------------------- overriding function Get_Classifier (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is begin return AMF.UML.Classifiers.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Classifier (Self.Element))); end Get_Classifier; -------------- -- Get_Slot -- -------------- overriding function Get_Slot (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Slots.Collections.Set_Of_UML_Slot is begin return AMF.UML.Slots.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Slot (Self.Element))); end Get_Slot; ----------------------- -- Get_Specification -- ----------------------- overriding function Get_Specification (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Value_Specifications.UML_Value_Specification_Access is begin return AMF.UML.Value_Specifications.UML_Value_Specification_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Specification (Self.Element))); end Get_Specification; ----------------------- -- Set_Specification -- ----------------------- overriding procedure Set_Specification (Self : not null access UML_Enumeration_Literal_Proxy; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Specification (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Specification; -------------------------- -- Get_Deployed_Element -- -------------------------- overriding function Get_Deployed_Element (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is begin return AMF.UML.Packageable_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Deployed_Element (Self.Element))); end Get_Deployed_Element; -------------------- -- Get_Deployment -- -------------------- overriding function Get_Deployment (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Deployments.Collections.Set_Of_UML_Deployment is begin return AMF.UML.Deployments.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Deployment (Self.Element))); end Get_Deployment; --------------------------- -- Get_Client_Dependency -- --------------------------- overriding function Get_Client_Dependency (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is begin return AMF.UML.Dependencies.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency (Self.Element))); end Get_Client_Dependency; ------------------------- -- Get_Name_Expression -- ------------------------- overriding function Get_Name_Expression (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access is begin return AMF.UML.String_Expressions.UML_String_Expression_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression (Self.Element))); end Get_Name_Expression; ------------------------- -- Set_Name_Expression -- ------------------------- overriding procedure Set_Name_Expression (Self : not null access UML_Enumeration_Literal_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Name_Expression; ------------------- -- Get_Namespace -- ------------------- overriding function Get_Namespace (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin return AMF.UML.Namespaces.UML_Namespace_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace (Self.Element))); end Get_Namespace; ------------------------ -- Get_Qualified_Name -- ------------------------ overriding function Get_Qualified_Name (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.Optional_String is begin declare use type Matreshka.Internals.Strings.Shared_String_Access; Aux : constant Matreshka.Internals.Strings.Shared_String_Access := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element); begin if Aux = null then return (Is_Empty => True); else return (False, League.Strings.Internals.Create (Aux)); end if; end; end Get_Qualified_Name; ----------------------------------- -- Get_Owning_Template_Parameter -- ----------------------------------- overriding function Get_Owning_Template_Parameter (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is begin return AMF.UML.Template_Parameters.UML_Template_Parameter_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Template_Parameter (Self.Element))); end Get_Owning_Template_Parameter; ----------------------------------- -- Set_Owning_Template_Parameter -- ----------------------------------- overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Enumeration_Literal_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Template_Parameter (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Owning_Template_Parameter; ---------------------------- -- Get_Template_Parameter -- ---------------------------- overriding function Get_Template_Parameter (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is begin return AMF.UML.Template_Parameters.UML_Template_Parameter_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Template_Parameter (Self.Element))); end Get_Template_Parameter; ---------------------------- -- Set_Template_Parameter -- ---------------------------- overriding procedure Set_Template_Parameter (Self : not null access UML_Enumeration_Literal_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Template_Parameter; ---------------- -- Classifier -- ---------------- overriding function Classifier (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Enumerations.UML_Enumeration_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Classifier unimplemented"); raise Program_Error with "Unimplemented procedure UML_Enumeration_Literal_Proxy.Classifier"; return Classifier (Self); end Classifier; ---------------------- -- Deployed_Element -- ---------------------- overriding function Deployed_Element (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Deployed_Element unimplemented"); raise Program_Error with "Unimplemented procedure UML_Enumeration_Literal_Proxy.Deployed_Element"; return Deployed_Element (Self); end Deployed_Element; ------------------------- -- All_Owning_Packages -- ------------------------- overriding function All_Owning_Packages (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented"); raise Program_Error with "Unimplemented procedure UML_Enumeration_Literal_Proxy.All_Owning_Packages"; return All_Owning_Packages (Self); end All_Owning_Packages; ----------------------------- -- Is_Distinguishable_From -- ----------------------------- overriding function Is_Distinguishable_From (Self : not null access constant UML_Enumeration_Literal_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented"); raise Program_Error with "Unimplemented procedure UML_Enumeration_Literal_Proxy.Is_Distinguishable_From"; return Is_Distinguishable_From (Self, N, Ns); end Is_Distinguishable_From; --------------- -- Namespace -- --------------- overriding function Namespace (Self : not null access constant UML_Enumeration_Literal_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented"); raise Program_Error with "Unimplemented procedure UML_Enumeration_Literal_Proxy.Namespace"; return Namespace (Self); end Namespace; ------------------------ -- Is_Compatible_With -- ------------------------ overriding function Is_Compatible_With (Self : not null access constant UML_Enumeration_Literal_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented"); raise Program_Error with "Unimplemented procedure UML_Enumeration_Literal_Proxy.Is_Compatible_With"; return Is_Compatible_With (Self, P); end Is_Compatible_With; --------------------------- -- Is_Template_Parameter -- --------------------------- overriding function Is_Template_Parameter (Self : not null access constant UML_Enumeration_Literal_Proxy) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented"); raise Program_Error with "Unimplemented procedure UML_Enumeration_Literal_Proxy.Is_Template_Parameter"; return Is_Template_Parameter (Self); end Is_Template_Parameter; end AMF.Internals.UML_Enumeration_Literals;
AdaCore/training_material
Ada
812
adb
package body Drawable_Chars is function Image (C : Drawable_Char_T) return String is begin return String (C); end Image; function Debug_Image (C : Sorted_Charset_T) return String is begin -- TODO return ""; end Debug_Image; function Closest (Metric : Sorted_Charset_T; Value : Drawable_Char_Characteristic_T) return Drawable_Char_T is begin -- TODO return ""; end Closest; function Sort_By (Charset : Drawable_Charset_T; Characteristic : Drawable_Char_Caracteristics_List_T) return Sorted_Charset_T is begin return (others => <>); end Sort_By; function Reversed (SC : Sorted_Charset_T) return Sorted_Charset_T is begin return (others => <>); end Reversed; end Drawable_Chars;
reznikmm/matreshka
Ada
4,805
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Text_Numbered_Paragraph_Elements; package Matreshka.ODF_Text.Numbered_Paragraph_Elements is type Text_Numbered_Paragraph_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Numbered_Paragraph_Elements.ODF_Text_Numbered_Paragraph with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Numbered_Paragraph_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Numbered_Paragraph_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Numbered_Paragraph_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Text_Numbered_Paragraph_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Text_Numbered_Paragraph_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Text.Numbered_Paragraph_Elements;
JeremyGrosser/Ada_Drivers_Library
Ada
1,929
ads
-- This package was generated by the Ada_Drivers_Library project wizard script package ADL_Config is Architecture : constant String := "ARM"; -- From board definition Board : constant String := "STM32_H405"; -- From command line CPU_Core : constant String := "ARM Cortex-M4F"; -- From mcu definition Device_Family : constant String := "STM32F4"; -- From board definition Device_Name : constant String := "STM32F405RGTx"; -- From board definition Has_Ravenscar_Full_Runtime : constant String := "True"; -- From board definition Has_Ravenscar_SFP_Runtime : constant String := "True"; -- From board definition Has_ZFP_Runtime : constant String := "False"; -- From board definition High_Speed_External_Clock : constant := 8_000_000; -- From board definition Max_Mount_Name_Length : constant := 128; -- From default value Max_Mount_Points : constant := 2; -- From default value Max_Path_Length : constant := 1024; -- From default value Number_Of_Interrupts : constant := 0; -- From default value Runtime_Name : constant String := "ravenscar-sfp-stm32f4"; -- From default value Runtime_Name_Suffix : constant String := "stm32f4"; -- From board definition Runtime_Profile : constant String := "ravenscar-sfp"; -- From command line Use_Startup_Gen : constant Boolean := False; -- From command line Vendor : constant String := "STMicro"; -- From board definition end ADL_Config;
sudoadminservices/bugbountyservices
Ada
1,719
ads
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "ThreatCrowd" type = "api" function start() setratelimit(10) end function vertical(ctx, domain) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end local resp -- Check if the response data is in the graph database if (cfg ~= nil and cfg.ttl ~= nil and cfg.ttl > 0) then resp = obtain_response(domain, cfg.ttl) end if (resp == nil or resp == "") then local err local hdrs = {['Content-Type']="application/json"} resp, err = request({ url=buildurl(domain), headers=hdrs, }) if (err ~= nil and err ~= "") then return end if (cfg ~= nil and cfg.ttl ~= nil and cfg.ttl > 0) then cache_response(domain, resp) end end local d = json.decode(resp) if (d == nil or d.response_code ~= "1" or #(d.subdomains) == 0) then return end for i, sub in pairs(d.subdomains) do sendnames(ctx, sub) end for i, tb in pairs(d.resolutions) do newaddr(ctx, tb.ip_address, domain) end end function buildurl(domain) return "https://www.threatcrowd.org/searchApi/v2/domain/report/?domain=" .. domain end function sendnames(ctx, content) local names = find(content, subdomainre) if names == nil then return end local found = {} for i, v in pairs(names) do if found[v] == nil then newname(ctx, v) found[v] = true end end end
optikos/oasis
Ada
9,371
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Defining_Identifiers; with Program.Elements.Parameter_Specifications; with Program.Elements.Aspect_Specifications; with Program.Elements.Function_Body_Stubs; with Program.Element_Visitors; package Program.Nodes.Function_Body_Stubs is pragma Preelaborate; type Function_Body_Stub is new Program.Nodes.Node and Program.Elements.Function_Body_Stubs.Function_Body_Stub and Program.Elements.Function_Body_Stubs.Function_Body_Stub_Text with private; function Create (Not_Token : Program.Lexical_Elements.Lexical_Element_Access; Overriding_Token : Program.Lexical_Elements.Lexical_Element_Access; Function_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Return_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Not_Token_2 : Program.Lexical_Elements.Lexical_Element_Access; Null_Token : Program.Lexical_Elements.Lexical_Element_Access; Result_Subtype : not null Program.Elements.Element_Access; Is_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Separate_Token : not null Program.Lexical_Elements .Lexical_Element_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Function_Body_Stub; type Implicit_Function_Body_Stub is new Program.Nodes.Node and Program.Elements.Function_Body_Stubs.Function_Body_Stub with private; function Create (Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Result_Subtype : not null Program.Elements.Element_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False; Has_Not : Boolean := False; Has_Overriding : Boolean := False; Has_Not_Null : Boolean := False) return Implicit_Function_Body_Stub with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Function_Body_Stub is abstract new Program.Nodes.Node and Program.Elements.Function_Body_Stubs.Function_Body_Stub with record Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Result_Subtype : not null Program.Elements.Element_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; end record; procedure Initialize (Self : aliased in out Base_Function_Body_Stub'Class); overriding procedure Visit (Self : not null access Base_Function_Body_Stub; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Name (Self : Base_Function_Body_Stub) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; overriding function Parameters (Self : Base_Function_Body_Stub) return Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; overriding function Result_Subtype (Self : Base_Function_Body_Stub) return not null Program.Elements.Element_Access; overriding function Aspects (Self : Base_Function_Body_Stub) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; overriding function Is_Function_Body_Stub_Element (Self : Base_Function_Body_Stub) return Boolean; overriding function Is_Declaration_Element (Self : Base_Function_Body_Stub) return Boolean; type Function_Body_Stub is new Base_Function_Body_Stub and Program.Elements.Function_Body_Stubs.Function_Body_Stub_Text with record Not_Token : Program.Lexical_Elements.Lexical_Element_Access; Overriding_Token : Program.Lexical_Elements.Lexical_Element_Access; Function_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Return_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Not_Token_2 : Program.Lexical_Elements.Lexical_Element_Access; Null_Token : Program.Lexical_Elements.Lexical_Element_Access; Is_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Separate_Token : not null Program.Lexical_Elements .Lexical_Element_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_Function_Body_Stub_Text (Self : aliased in out Function_Body_Stub) return Program.Elements.Function_Body_Stubs .Function_Body_Stub_Text_Access; overriding function Not_Token (Self : Function_Body_Stub) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Overriding_Token (Self : Function_Body_Stub) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Function_Token (Self : Function_Body_Stub) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Left_Bracket_Token (Self : Function_Body_Stub) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Right_Bracket_Token (Self : Function_Body_Stub) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Return_Token (Self : Function_Body_Stub) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Not_Token_2 (Self : Function_Body_Stub) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Null_Token (Self : Function_Body_Stub) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Is_Token (Self : Function_Body_Stub) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Separate_Token (Self : Function_Body_Stub) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function With_Token (Self : Function_Body_Stub) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Semicolon_Token (Self : Function_Body_Stub) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Has_Not (Self : Function_Body_Stub) return Boolean; overriding function Has_Overriding (Self : Function_Body_Stub) return Boolean; overriding function Has_Not_Null (Self : Function_Body_Stub) return Boolean; type Implicit_Function_Body_Stub is new Base_Function_Body_Stub with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; Has_Not : Boolean; Has_Overriding : Boolean; Has_Not_Null : Boolean; end record; overriding function To_Function_Body_Stub_Text (Self : aliased in out Implicit_Function_Body_Stub) return Program.Elements.Function_Body_Stubs .Function_Body_Stub_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Function_Body_Stub) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Function_Body_Stub) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Function_Body_Stub) return Boolean; overriding function Has_Not (Self : Implicit_Function_Body_Stub) return Boolean; overriding function Has_Overriding (Self : Implicit_Function_Body_Stub) return Boolean; overriding function Has_Not_Null (Self : Implicit_Function_Body_Stub) return Boolean; end Program.Nodes.Function_Body_Stubs;
KipodAfterFree/KAF-2019-FireHog
Ada
3,783
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Menu_Demo.Handler -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control -- $Revision: 1.5 $ -- Binding Version 00.93 ------------------------------------------------------------------------------ with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels; with Terminal_Interface.Curses.Menus; use Terminal_Interface.Curses.Menus; generic with function My_Driver (Men : Menu; K : Key_Code; Pan : Panel) return Boolean; package Sample.Menu_Demo.Handler is procedure Drive_Me (M : in Menu; Lin : in Line_Position; Col : in Column_Position; Title : in String := ""); -- Position the menu at the given point and drive it. procedure Drive_Me (M : in Menu; Title : in String := ""); -- Center menu and drive it. end Sample.Menu_Demo.Handler;
charlie5/aIDE
Ada
1,618
ads
with gtk.Widget; with Gtk.Button; with Gtk.Window; with Adam.exception_Handler, AdaM.Declaration.of_exception; with Gtk.Notebook; with Gtk.Table; package aIDE.Palette.of_exceptions is type Item is new Palette.item with private; type View is access all Item'Class; -- Forge -- function to_exceptions_Palette return View; -- Attributes -- function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget; -- Operations -- procedure show (Self : in out Item; Invoked_by : in Gtk.Button.gtk_Button; Target : in adam.exception_Handler.view; Slot : in Positive); procedure choice_is (Self : in out Item; --Now : in String; -- package_Name : in String; the_Exception : in AdaM.Declaration.of_exception.view); procedure freshen (Self : in out Item); private use gtk.Window, gtk.Button, gtk.Notebook, Gtk.Table; type Item is new Palette.item with record Invoked_by : gtk_Button; Target : adam.exception_Handler.view; Slot : Positive; recent_Table : gtk_Table; top_Notebook, all_Notebook : gtk_Notebook; Top : gtk_Window; delete_Button : gtk_Button; close_Button : gtk_Button; end record; procedure build_recent_List (Self : in out Item); end aIDE.Palette.of_exceptions;
francesco-bongiovanni/ewok-kernel
Ada
1,313
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- package ewok.interrupts.handler with spark_mode => off is function hardfault_handler (frame_a : ewok.t_stack_frame_access) return ewok.t_stack_frame_access; function systick_default_handler (frame_a : ewok.t_stack_frame_access) return ewok.t_stack_frame_access; function default_sub_handler (frame_a : t_stack_frame_access) return t_stack_frame_access with convention => c, export => true, external_name => "Default_SubHandler"; end ewok.interrupts.handler;
tum-ei-rcs/StratoX
Ada
1,899
ads
-- LED-Library by Emanuel Regnath ([email protected]) Date:2_015-05-20 -- -- Description: -- Portable LED Library that features switching, blinking and morse (non-blocking) -- -- Setup: -- To port the lib to your system, simply overwrite the 2 functions LED_HAL_init -- and LED_HAL_set in the .cpp file and adjust the HAL part in the .hpp file -- -- Usage: -- 1. call LED_init which will configure the LED port and pin -- 2. call LED_switch or LED_blink or LED_morse to select the operation mode -- 3. frequently call LED_tick and LED_sync to manage LED timings. -- package LED_Manager with SPARK_Mode is -- HAL: adjust these types to your system -- ---------------------------------------------------------------------------- type Time_Type is new Natural; -- max. value: 7 * BLINK_TIME BLINK_TIME : constant Time_Type := 250; -- arbitrary time basis (dot time in morse mode) type LED_Id_Type is new Integer; -- any led identifier e.g. struct with port and pin -- ---------------------------------------------------------------------------- type LED_State_Type is (ON, OFF); type LED_Blink_Type is (FLASH, FAST, SLOW); type LED_Blink_Speed_Type is array (LED_Blink_Type) of Time_Type; -- configures which LED to use procedure LED_init (id : LED_Id_Type); -- increases the internal timing counter -- elapsed_time should be a divider of BLINK_TIME. procedure LED_tick (elapsed_time : Time_Type); -- perform LED switching in blink or morse mode procedure LED_sync; -- switch LED on or off (will stop blink or morse mode) procedure LED_switchOn; procedure LED_switchOff; -- select blink mode procedure LED_blink (speed : LED_Blink_Type); procedure LED_blinkPulse (on_time : Time_Type; off_time : Time_Type); -- select morse mode -- procedure LED_morse(msg_string : String); -- ensure 0-terminated string! end LED_Manager;
Louis-Aime/Milesian_calendar_Ada
Ada
8,574
adb
-- Package body Julian_calendar ---------------------------------------------------------------------------- -- Copyright Miletus 2016 -- 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: -- 1. The above copyright notice and this permission notice shall be included -- in all copies or substantial portions of the Software. -- 2. Changes with respect to any former version shall be documented. -- -- The software is provided "as is", without warranty of any kind, -- express of implied, including but not limited to the warranties of -- merchantability, fitness for a particular purpose and noninfringement. -- In no event shall the authors of 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. -- Inquiries: www.calendriermilesien.org ------------------------------------------------------------------------------ with Cycle_Computations; package body Julian_calendar is package Julian_Day_cycle is new Cycle_computations.Integer_cycle_computations (Num => Julian_Day'Base); use Julian_Day_cycle; subtype computation_month is integer range 0..12; function is_bissextile_year -- in the sense of Julian or Gregorian (year : Historical_year_number; Calendar : Calendar_type := Unspecified) return Boolean is Is_Julian : Boolean := Calendar = Julian or else (Calendar = Unspecified and then year < 1583); begin return year mod 4 = 0 and then (Is_Julian or else (year mod 100 /= 0 or else year mod 400 = 0)); end is_bissextile_year; function is_valid (date : Roman_date; Calendar : Calendar_type := Unspecified) return Boolean is -- whether the given date is an existing one -- on elaboration, the basic range cheks on record fields have been done begin case date.month is when 4|6|9|11 => return date.day <= 30; when 2 => return date.day <= 28 or else (date.day = 29 and is_bissextile_year (date.year , Calendar)); when others => return True; end case; end is_valid; function JD_to_Roman (jd : Julian_Day; Calendar : Calendar_type := Unspecified) -- Gregorian : Boolean := (jd > 299160)) return Roman_date is Is_Gregorian : Boolean := Calendar = Gregorian or else (Calendar = Unspecified and then jd > 299160); -- by default, the return date shall be specified in gregorian -- if it falls after 1582-10-04 (julian) cc : Cycle_coordinates := (0, jd+1401); -- Initiated for the julian calendar case; -- Base of cycle if julian calendar is 1/3/-4716 julian calendar Shifted_month : Integer; Shifted_year : Historical_year_number := -4716; begin -- 1. Find the year and day-of-year in the shifted Roman calendar, -- i.e. the calendar that begins on 1 March. -- 1.1 If Gregorian, find quadrisaeculum, then century, then quadriannum; -- else find directly quadriannum; -- 1.2 Find shifted year and rank of day in shifted year; -- 1.3 Find shifted month, find day rank in shifted month -- 2. Set to unshifted calendar. if Is_Gregorian then -- 1.1 cc := Decompose_cycle (jd+32044, 146097); -- intialise current day for the computations to -- day of a "gregorian epoch" such as 0 is 1/3/-4800 gregorian Shifted_year := (cc.cycle - 12) * 400; -- Initiated for the gregorian calendar cc := Decompose_cycle_ceiled (cc.phase, 36524, 4); -- cc.cycle is rank of century in quadriseculum, -- cc.phase is rank of days within century. -- rank of century is 0 to 3, phase can be 36524 if rank is 3. Shifted_year := Shifted_year + (cc.cycle) * 100; -- base century end if; -- 1.2; cc and shifted_year already initiated. cc := Decompose_cycle (cc.phase, 1461); -- quadriannum Shifted_year := Shifted_year + cc.cycle * 4; cc := Decompose_cycle_ceiled (cc.phase, 365, 4); -- year in quadriannum Shifted_year := Shifted_year + cc.cycle; -- here we get the (shifted) year and the rank of day, cc.phase. -- 1.3 use a variant of Troesch method cc := Decompose_cycle (5 * cc.Phase + 2 , 153); Shifted_month := cc.Cycle; -- here Shifted_day = cc.Phase / 5; if Shifted_month < 10 -- 0..9 meaning March to December then return (year => Shifted_year, month => Shifted_month + 3, day => cc.Phase/5 + 1); else return (year => Shifted_year + 1, month => Shifted_month - 9, day => cc.Phase/5 + 1); end if; end JD_to_Roman; function Roman_to_JD (Date : Roman_date; Calendar : Calendar_type := Unspecified) return Julian_Day is Is_Gregorian : Boolean := Calendar = Gregorian or else (Calendar = Unspecified and then (Date.year > 1583 or else (Date.year = 1582 and then (Date.month > 10 or else (Date.month = 10 and then Date.day > 4))))); Jd : Julian_Day; Days : Julian_Day_Duration; Shifted_month : integer := Date.month; Shifted_year : Integer := Date.year; Centuries : Integer; begin if not is_valid (date , Calendar) then raise Time_Error; end if; if Shifted_month in 1..2 then Shifted_month := Shifted_month + 9; -- 10 or 11 Shifted_year := Shifted_year - 1; else Shifted_month := Shifted_month - 3; -- 0 to 9 end if; Centuries := (Shifted_year + 4800)/100; -- Computed from -4800; Days := (Shifted_year + 4716) / 4 -- for each leap year + (Shifted_month*306 + 5) / 10 -- osssia + Integer (Fractional_day_in_year (Shifted_month * 30.6)) + date.day - 307; If Is_Gregorian then Days := Days - Centuries + Centuries/4 + 38; end if; Jd := (Shifted_year + 4713) * 365; -- 365 days per years Jd := Jd + Days; Return Jd; end Roman_to_JD; function Julian_to_Gregorian_Delay (Year : Historical_year_number) return Integer is A : Natural := Year + 4800 ; -- force positive. begin return -38 + A/100 - A/400; -- divisions use only with positive arguments end Julian_to_Gregorian_Delay; function Easter_days (Year : Natural; Calendar : Calendar_type := Unspecified) return Natural is Is_Gregorian : Boolean := Calendar = Gregorian or else (Calendar = Unspecified and then year > 1582); -- Initialisation: decompose year in suitable parts, -- Compute Gold number, compute Easter residue. -- Rank of century S : Natural := Year / 100; -- Rank of quadrisaeculum Q : Natural := S/4; -- Rank of quadriannum in current century B : Natural range 0..24 := (Year - S*100) / 4; -- Rank of year in current quadriannum N : Natural range 0..3 := (Year - S*100 - B*4); -- Gold number minus one in Meton's cycle G : Natural range 0..18 := Year mod 19; -- Easter residue, number of days from 21 March until Easter full moon R : Natural range 0..29 := (15 + 19*G -- Computation of Easter residue after Delambre... + Boolean'Pos (Is_Gregorian) * (S - Q - (8*S + 13)/25)) -- Gregorian: add Metemptose and Proemptose. -- Proemptose is computed with the Zeller-Troesch formula. mod 30; -- Take the remainder by 30 residue before correction. begin if Is_Gregorian then R := R - (G + 11*R) / 319 ; -- correction on residue end if; if Is_Gregorian then return 1 + R + (4 - Q + 2*S + 2*B - N - R) mod 7 ; else return 1 + R + (6 + S + 2*B - N - R) mod 7 ; end if; end Easter_days; end Julian_calendar;
zhmu/ananas
Ada
124
adb
-- { dg-do compile } -- { dg-options "-gnatd.F" } package body Allocator2 is procedure Dummy is null; end Allocator2;
charlie5/cBound
Ada
1,654
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with xcb.xcb_client_message_data_t; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_client_message_event_t is -- Item -- type Item is record response_type : aliased Interfaces.Unsigned_8; format : aliased Interfaces.Unsigned_8; sequence : aliased Interfaces.Unsigned_16; window : aliased xcb.xcb_window_t; the_type : aliased xcb.xcb_atom_t; data : aliased xcb.xcb_client_message_data_t.Item; end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_client_message_event_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_client_message_event_t.Item, Element_Array => xcb.xcb_client_message_event_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_client_message_event_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_client_message_event_t.Pointer, Element_Array => xcb.xcb_client_message_event_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_client_message_event_t;
Lyanf/pok
Ada
2,456
ads
-- --------------------------------------------------------------------------- -- -- -- BUFFER constant and type definitions and management services -- -- -- -- --------------------------------------------------------------------------- with APEX.Processes; package APEX.Buffers is Max_Number_Of_Buffers : constant := System_Limit_Number_Of_Buffers; subtype Buffer_Name_Type is Name_Type; type Buffer_Id_Type is private; Null_Buffer_Id : constant Buffer_Id_Type; type Buffer_Status_Type is record Nb_Message : Message_Range_Type; Max_Nb_Message : Message_Range_Type; Max_Message_Size : Message_Size_Type; Waiting_Processes : APEX.Processes.Waiting_Range_Type; end record; procedure Create_Buffer (Buffer_Name : in Buffer_Name_Type; Max_Message_Size : in Message_Size_Type; Max_Nb_Message : in Message_Range_Type; Queuing_Discipline : in Queuing_Discipline_Type; Buffer_Id : out Buffer_Id_Type; Return_Code : out Return_Code_Type); procedure Send_Buffer (Buffer_Id : in Buffer_Id_Type; Message_Addr : in Message_Addr_Type; Length : in Message_Size_Type; Time_Out : in System_Time_Type; Return_Code : out Return_Code_Type); procedure Receive_Buffer (Buffer_Id : in Buffer_Id_Type; Time_Out : in System_Time_Type; Message_Addr : in Message_Addr_Type; -- The message address is passed IN, although the respective message is -- passed OUT Length : out Message_Size_Type; Return_Code : out Return_Code_Type); procedure Get_Buffer_Id (Buffer_Name : in Buffer_Name_Type; Buffer_Id : out Buffer_Id_Type; Return_Code : out Return_Code_Type); procedure Get_Buffer_Status (Buffer_Id : in Buffer_Id_Type; Buffer_Status : out Buffer_Status_Type; Return_Code : out Return_Code_Type); private type Buffer_Id_Type is new APEX_Integer; Null_Buffer_Id : constant Buffer_Id_Type := 0; pragma Convention (C, Buffer_Status_Type); -- POK BINDINGS pragma Import (C, Create_Buffer, "CREATE_BUFFER"); pragma Import (C, Send_Buffer, "SEND_BUFFER"); pragma Import (C, Receive_Buffer, "RECEIVE_BUFFER"); pragma Import (C, Get_Buffer_Id, "GET_BUFFER_ID"); pragma Import (C, Get_Buffer_Status, "GET_BUFFER_STATUS"); -- END OF POK BINDINGS end APEX.Buffers;
alvaromb/Compilemon
Ada
2,021
ads
-- ------------------------------------------------ -- Paquet de declaracions dels tokens -- ------------------------------------------------ -- Versio : 0.2 -- Autors : Jose Ruiz Bravo -- Biel Moya Alcover -- Alvaro Medina Ballester -- ------------------------------------------------ -- Definicio del tipus token. -- -- ------------------------------------------------ package d_token is type token is (pc_procedure, pc_begin, pc_while, pc_if, pc_else, pc_end, pc_loop, pc_constant, pc_type, pc_array, pc_record, pc_is, pc_then, pc_not, pc_in, pc_out, pc_new, pc_null, pc_of, pc_mod, pc_range, pc_and, pc_or, s_assignacio, s_dospunts, s_final, s_coma, s_parentesiobert, s_parentesitancat, s_puntsrang, s_puntrec, op_menor, op_menorigual, op_majorigual, op_major, op_igual, op_distint, op_suma, op_resta, op_multiplicacio, op_divisio, id, const, Error, End_of_Input); end d_token;
aeszter/sharepoint2ics
Ada
114
ads
with Ada.Text_IO; with DOM.Core; procedure Convert (Input : DOM.Core.Node_List; Output : Ada.Text_IO.File_Type);
reznikmm/matreshka
Ada
3,953
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Text_Key2_Attributes; package Matreshka.ODF_Text.Key2_Attributes is type Text_Key2_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Key2_Attributes.ODF_Text_Key2_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Key2_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Key2_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Key2_Attributes;
thorstel/Advent-of-Code-2018
Ada
2,718
adb
package body Opcode_Helper is function Execute_Instruction (Op : String; Reg : Registers; A, B, C : Unsigned_64) return Registers is type Operations is (addr, addi, mulr, muli, banr, bani, borr, bori, setr, seti, gtir, gtri, gtrr, eqir, eqri, eqrr); Result : Registers := Reg; begin case Operations'Value (Op) is when addr => Result (Natural (C)) := Result (Natural (A)) + Result (Natural (B)); when addi => Result (Natural (C)) := Result (Natural (A)) + B; when mulr => Result (Natural (C)) := Result (Natural (A)) * Result (Natural (B)); when muli => Result (Natural (C)) := Result (Natural (A)) * B; when banr => Result (Natural (C)) := Result (Natural (A)) and Result (Natural (B)); when bani => Result (Natural (C)) := Result (Natural (A)) and B; when borr => Result (Natural (C)) := Result (Natural (A)) or Result (Natural (B)); when bori => Result (Natural (C)) := Result (Natural (A)) or B; when setr => Result (Natural (C)) := Result (Natural (A)); when seti => Result (Natural (C)) := A; when gtir => if A > Result (Natural (B)) then Result (Natural (C)) := 1; else Result (Natural (C)) := 0; end if; when gtri => if Result (Natural (A)) > B then Result (Natural (C)) := 1; else Result (Natural (C)) := 0; end if; when gtrr => if Result (Natural (A)) > Result (Natural (B)) then Result (Natural (C)) := 1; else Result (Natural (C)) := 0; end if; when eqir => if A = Result (Natural (B)) then Result (Natural (C)) := 1; else Result (Natural (C)) := 0; end if; when eqri => if Result (Natural (A)) = B then Result (Natural (C)) := 1; else Result (Natural (C)) := 0; end if; when eqrr => if Result (Natural (A)) = Result (Natural (B)) then Result (Natural (C)) := 1; else Result (Natural (C)) := 0; end if; end case; return Result; exception when Constraint_Error => raise Constraint_Error with "There is no " & Op & " operation"; end Execute_Instruction; end Opcode_Helper;
libos-nuse/frankenlibc
Ada
15,817
ads
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- Id: zlib-thin.ads,v 1.11 2004/07/23 06:33:11 vagul Exp with Interfaces.C.Strings; with System; private package ZLib.Thin is -- From zconf.h MAX_MEM_LEVEL : constant := 9; -- zconf.h:105 -- zconf.h:105 MAX_WBITS : constant := 15; -- zconf.h:115 -- 32K LZ77 window -- zconf.h:115 SEEK_SET : constant := 8#0000#; -- zconf.h:244 -- Seek from beginning of file. -- zconf.h:244 SEEK_CUR : constant := 1; -- zconf.h:245 -- Seek from current position. -- zconf.h:245 SEEK_END : constant := 2; -- zconf.h:246 -- Set file pointer to EOF plus "offset" -- zconf.h:246 type Byte is new Interfaces.C.unsigned_char; -- 8 bits -- zconf.h:214 type UInt is new Interfaces.C.unsigned; -- 16 bits or more -- zconf.h:216 type Int is new Interfaces.C.int; type ULong is new Interfaces.C.unsigned_long; -- 32 bits or more -- zconf.h:217 subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr; type ULong_Access is access ULong; type Int_Access is access Int; subtype Voidp is System.Address; -- zconf.h:232 subtype Byte_Access is Voidp; Nul : constant Voidp := System.Null_Address; -- end from zconf Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125 -- zlib.h:125 Z_PARTIAL_FLUSH : constant := 1; -- zlib.h:126 -- will be removed, use -- Z_SYNC_FLUSH instead -- zlib.h:126 Z_SYNC_FLUSH : constant := 2; -- zlib.h:127 -- zlib.h:127 Z_FULL_FLUSH : constant := 3; -- zlib.h:128 -- zlib.h:128 Z_FINISH : constant := 4; -- zlib.h:129 -- zlib.h:129 Z_OK : constant := 8#0000#; -- zlib.h:132 -- zlib.h:132 Z_STREAM_END : constant := 1; -- zlib.h:133 -- zlib.h:133 Z_NEED_DICT : constant := 2; -- zlib.h:134 -- zlib.h:134 Z_ERRNO : constant := -1; -- zlib.h:135 -- zlib.h:135 Z_STREAM_ERROR : constant := -2; -- zlib.h:136 -- zlib.h:136 Z_DATA_ERROR : constant := -3; -- zlib.h:137 -- zlib.h:137 Z_MEM_ERROR : constant := -4; -- zlib.h:138 -- zlib.h:138 Z_BUF_ERROR : constant := -5; -- zlib.h:139 -- zlib.h:139 Z_VERSION_ERROR : constant := -6; -- zlib.h:140 -- zlib.h:140 Z_NO_COMPRESSION : constant := 8#0000#; -- zlib.h:145 -- zlib.h:145 Z_BEST_SPEED : constant := 1; -- zlib.h:146 -- zlib.h:146 Z_BEST_COMPRESSION : constant := 9; -- zlib.h:147 -- zlib.h:147 Z_DEFAULT_COMPRESSION : constant := -1; -- zlib.h:148 -- zlib.h:148 Z_FILTERED : constant := 1; -- zlib.h:151 -- zlib.h:151 Z_HUFFMAN_ONLY : constant := 2; -- zlib.h:152 -- zlib.h:152 Z_DEFAULT_STRATEGY : constant := 8#0000#; -- zlib.h:153 -- zlib.h:153 Z_BINARY : constant := 8#0000#; -- zlib.h:156 -- zlib.h:156 Z_ASCII : constant := 1; -- zlib.h:157 -- zlib.h:157 Z_UNKNOWN : constant := 2; -- zlib.h:158 -- zlib.h:158 Z_DEFLATED : constant := 8; -- zlib.h:161 -- zlib.h:161 Z_NULL : constant := 8#0000#; -- zlib.h:164 -- for initializing zalloc, zfree, opaque -- zlib.h:164 type gzFile is new Voidp; -- zlib.h:646 type Z_Stream is private; type Z_Streamp is access all Z_Stream; -- zlib.h:89 type alloc_func is access function (Opaque : Voidp; Items : UInt; Size : UInt) return Voidp; -- zlib.h:63 type free_func is access procedure (opaque : Voidp; address : Voidp); function zlibVersion return Chars_Ptr; function Deflate (strm : Z_Streamp; flush : Int) return Int; function DeflateEnd (strm : Z_Streamp) return Int; function Inflate (strm : Z_Streamp; flush : Int) return Int; function InflateEnd (strm : Z_Streamp) return Int; function deflateSetDictionary (strm : Z_Streamp; dictionary : Byte_Access; dictLength : UInt) return Int; function deflateCopy (dest : Z_Streamp; source : Z_Streamp) return Int; -- zlib.h:478 function deflateReset (strm : Z_Streamp) return Int; -- zlib.h:495 function deflateParams (strm : Z_Streamp; level : Int; strategy : Int) return Int; -- zlib.h:506 function inflateSetDictionary (strm : Z_Streamp; dictionary : Byte_Access; dictLength : UInt) return Int; -- zlib.h:548 function inflateSync (strm : Z_Streamp) return Int; -- zlib.h:565 function inflateReset (strm : Z_Streamp) return Int; -- zlib.h:580 function compress (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong) return Int; -- zlib.h:601 function compress2 (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong; level : Int) return Int; -- zlib.h:615 function uncompress (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong) return Int; function gzopen (path : Chars_Ptr; mode : Chars_Ptr) return gzFile; function gzdopen (fd : Int; mode : Chars_Ptr) return gzFile; function gzsetparams (file : gzFile; level : Int; strategy : Int) return Int; function gzread (file : gzFile; buf : Voidp; len : UInt) return Int; function gzwrite (file : in gzFile; buf : in Voidp; len : in UInt) return Int; function gzprintf (file : in gzFile; format : in Chars_Ptr) return Int; function gzputs (file : in gzFile; s : in Chars_Ptr) return Int; function gzgets (file : gzFile; buf : Chars_Ptr; len : Int) return Chars_Ptr; function gzputc (file : gzFile; char : Int) return Int; function gzgetc (file : gzFile) return Int; function gzflush (file : gzFile; flush : Int) return Int; function gzseek (file : gzFile; offset : Int; whence : Int) return Int; function gzrewind (file : gzFile) return Int; function gztell (file : gzFile) return Int; function gzeof (file : gzFile) return Int; function gzclose (file : gzFile) return Int; function gzerror (file : gzFile; errnum : Int_Access) return Chars_Ptr; function adler32 (adler : ULong; buf : Byte_Access; len : UInt) return ULong; function crc32 (crc : ULong; buf : Byte_Access; len : UInt) return ULong; function deflateInit (strm : Z_Streamp; level : Int; version : Chars_Ptr; stream_size : Int) return Int; function deflateInit2 (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int; version : Chars_Ptr; stream_size : Int) return Int; function Deflate_Init (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int) return Int; pragma Inline (Deflate_Init); function inflateInit (strm : Z_Streamp; version : Chars_Ptr; stream_size : Int) return Int; function inflateInit2 (strm : in Z_Streamp; windowBits : in Int; version : in Chars_Ptr; stream_size : in Int) return Int; function inflateBackInit (strm : in Z_Streamp; windowBits : in Int; window : in Byte_Access; version : in Chars_Ptr; stream_size : in Int) return Int; -- Size of window have to be 2**windowBits. function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int; pragma Inline (Inflate_Init); function zError (err : Int) return Chars_Ptr; function inflateSyncPoint (z : Z_Streamp) return Int; function get_crc_table return ULong_Access; -- Interface to the available fields of the z_stream structure. -- The application must update next_in and avail_in when avail_in has -- dropped to zero. It must update next_out and avail_out when avail_out -- has dropped to zero. The application must initialize zalloc, zfree and -- opaque before calling the init function. procedure Set_In (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt); pragma Inline (Set_In); procedure Set_Out (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt); pragma Inline (Set_Out); procedure Set_Mem_Func (Strm : in out Z_Stream; Opaque : in Voidp; Alloc : in alloc_func; Free : in free_func); pragma Inline (Set_Mem_Func); function Last_Error_Message (Strm : in Z_Stream) return String; pragma Inline (Last_Error_Message); function Avail_Out (Strm : in Z_Stream) return UInt; pragma Inline (Avail_Out); function Avail_In (Strm : in Z_Stream) return UInt; pragma Inline (Avail_In); function Total_In (Strm : in Z_Stream) return ULong; pragma Inline (Total_In); function Total_Out (Strm : in Z_Stream) return ULong; pragma Inline (Total_Out); function inflateCopy (dest : in Z_Streamp; Source : in Z_Streamp) return Int; function compressBound (Source_Len : in ULong) return ULong; function deflateBound (Strm : in Z_Streamp; Source_Len : in ULong) return ULong; function gzungetc (C : in Int; File : in gzFile) return Int; function zlibCompileFlags return ULong; private type Z_Stream is record -- zlib.h:68 Next_In : Voidp := Nul; -- next input byte Avail_In : UInt := 0; -- number of bytes available at next_in Total_In : ULong := 0; -- total nb of input bytes read so far Next_Out : Voidp := Nul; -- next output byte should be put there Avail_Out : UInt := 0; -- remaining free space at next_out Total_Out : ULong := 0; -- total nb of bytes output so far msg : Chars_Ptr; -- last error message, NULL if no error state : Voidp; -- not visible by applications zalloc : alloc_func := null; -- used to allocate the internal state zfree : free_func := null; -- used to free the internal state opaque : Voidp; -- private data object passed to -- zalloc and zfree data_type : Int; -- best guess about the data type: -- ascii or binary adler : ULong; -- adler32 value of the uncompressed -- data reserved : ULong; -- reserved for future use end record; pragma Convention (C, Z_Stream); pragma Import (C, zlibVersion, "zlibVersion"); pragma Import (C, Deflate, "deflate"); pragma Import (C, DeflateEnd, "deflateEnd"); pragma Import (C, Inflate, "inflate"); pragma Import (C, InflateEnd, "inflateEnd"); pragma Import (C, deflateSetDictionary, "deflateSetDictionary"); pragma Import (C, deflateCopy, "deflateCopy"); pragma Import (C, deflateReset, "deflateReset"); pragma Import (C, deflateParams, "deflateParams"); pragma Import (C, inflateSetDictionary, "inflateSetDictionary"); pragma Import (C, inflateSync, "inflateSync"); pragma Import (C, inflateReset, "inflateReset"); pragma Import (C, compress, "compress"); pragma Import (C, compress2, "compress2"); pragma Import (C, uncompress, "uncompress"); pragma Import (C, gzopen, "gzopen"); pragma Import (C, gzdopen, "gzdopen"); pragma Import (C, gzsetparams, "gzsetparams"); pragma Import (C, gzread, "gzread"); pragma Import (C, gzwrite, "gzwrite"); pragma Import (C, gzprintf, "gzprintf"); pragma Import (C, gzputs, "gzputs"); pragma Import (C, gzgets, "gzgets"); pragma Import (C, gzputc, "gzputc"); pragma Import (C, gzgetc, "gzgetc"); pragma Import (C, gzflush, "gzflush"); pragma Import (C, gzseek, "gzseek"); pragma Import (C, gzrewind, "gzrewind"); pragma Import (C, gztell, "gztell"); pragma Import (C, gzeof, "gzeof"); pragma Import (C, gzclose, "gzclose"); pragma Import (C, gzerror, "gzerror"); pragma Import (C, adler32, "adler32"); pragma Import (C, crc32, "crc32"); pragma Import (C, deflateInit, "deflateInit_"); pragma Import (C, inflateInit, "inflateInit_"); pragma Import (C, deflateInit2, "deflateInit2_"); pragma Import (C, inflateInit2, "inflateInit2_"); pragma Import (C, zError, "zError"); pragma Import (C, inflateSyncPoint, "inflateSyncPoint"); pragma Import (C, get_crc_table, "get_crc_table"); -- since zlib 1.2.0: pragma Import (C, inflateCopy, "inflateCopy"); pragma Import (C, compressBound, "compressBound"); pragma Import (C, deflateBound, "deflateBound"); pragma Import (C, gzungetc, "gzungetc"); pragma Import (C, zlibCompileFlags, "zlibCompileFlags"); pragma Import (C, inflateBackInit, "inflateBackInit_"); -- I stopped binding the inflateBack routines, becouse realize that -- it does not support zlib and gzip headers for now, and have no -- symmetric deflateBack routines. -- ZLib-Ada is symmetric regarding deflate/inflate data transformation -- and has a similar generic callback interface for the -- deflate/inflate transformation based on the regular Deflate/Inflate -- routines. -- pragma Import (C, inflateBack, "inflateBack"); -- pragma Import (C, inflateBackEnd, "inflateBackEnd"); end ZLib.Thin;
zhmu/ananas
Ada
3,895
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 8 8 -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- Handling of packed arrays with Component_Size = 88 package System.Pack_88 is pragma Preelaborate; Bits : constant := 88; type Bits_88 is mod 2 ** Bits; for Bits_88'Size use Bits; -- In all subprograms below, Rev_SSO is set True if the array has the -- non-default scalar storage order. function Get_88 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_88 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. procedure Set_88 (Arr : System.Address; N : Natural; E : Bits_88; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. function GetU_88 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_88 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. This version -- is used when Arr may represent an unaligned address. procedure SetU_88 (Arr : System.Address; N : Natural; E : Bits_88; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. This version -- is used when Arr may represent an unaligned address end System.Pack_88;
zhmu/ananas
Ada
4,262
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S C N -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- This package contains the lexical analyzer routines. This is used by the -- compiler for scanning Ada source files. with Casing; use Casing; with Errout; use Errout; with Scng; with Style; -- use Style; with Types; use Types; package Scn is procedure Initialize_Scanner (Unit : Unit_Number_Type; Index : Source_File_Index); -- Initialize lexical scanner for scanning a new file. The caller has -- completed the construction of the Units.Table entry for the specified -- Unit and Index references the corresponding source file. A special case -- is when Unit = No_Unit, and Index corresponds to the source index for -- reading the configuration pragma file. function Determine_Token_Casing return Casing_Type; -- Determines the casing style of the current token, which is either a -- keyword or an identifier. See also package Casing. procedure Post_Scan; -- Create nodes for tokens: Char_Literal, Identifier, Real_Literal, -- Integer_Literal, String_Literal and Operator_Symbol. procedure Scan_Reserved_Identifier (Force_Msg : Boolean); -- This procedure is called to convert the current token, which the caller -- has checked is for a reserved word, to an equivalent identifier. This is -- of course only used in error situations where the parser can detect that -- a reserved word is being used as an identifier. An appropriate error -- message, pointing to the token, is also issued if either this is the -- first occurrence of misuse of this identifier, or if Force_Msg is True. ------------- -- Scanner -- ------------- -- The scanner used by the compiler is an instantiation of the -- generic package Scng with routines appropriate to the compiler package Scanner is new Scng (Post_Scan => Post_Scan, Error_Msg => Error_Msg, Error_Msg_S => Error_Msg_S, Error_Msg_SC => Error_Msg_SC, Error_Msg_SP => Error_Msg_SP, Style => Style.Style_Inst); procedure Scan renames Scanner.Scan; -- Scan scans out the next token, and advances the scan state accordingly -- (see package Scans for details). If the scan encounters an illegal -- token, then an error message is issued pointing to the bad character, -- and Scan returns a reasonable substitute token of some kind. end Scn;
reznikmm/matreshka
Ada
4,041
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Text_Animation_Steps_Attributes; package Matreshka.ODF_Text.Animation_Steps_Attributes is type Text_Animation_Steps_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Animation_Steps_Attributes.ODF_Text_Animation_Steps_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Animation_Steps_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Animation_Steps_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Animation_Steps_Attributes;
mitchelhaan/ncurses
Ada
3,508
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Text_IO.Integer_IO -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control: -- $Revision: 1.7 $ -- Binding Version 00.93 ------------------------------------------------------------------------------ generic type Num is range <>; package Terminal_Interface.Curses.Text_IO.Integer_IO is Default_Width : Field := Num'Width; Default_Base : Number_Base := 10; procedure Put (Win : in Window; Item : in Num; Width : in Field := Default_Width; Base : in Number_Base := Default_Base); procedure Put (Item : in Num; Width : in Field := Default_Width; Base : in Number_Base := Default_Base); private pragma Inline (Put); end Terminal_Interface.Curses.Text_IO.Integer_IO;
iyan22/AprendeAda
Ada
492
ads
package datos is Max_Elem : constant Integer := 10; type Vector_De_Enteros is array (Integer range <>) of Integer; type Lista_Enteros is record Numeros : Vector_De_Enteros (1 .. Max_Elem); Cont : Integer; end record; type Vector_De_Reales is array (Integer range <>) of Float; type Vector_De_Booleanos is array (Integer range <>) of Boolean; type Vector_De_Caracteres is array (Integer range <>) of Character; end datos;
zhmu/ananas
Ada
230
adb
-- { dg-do compile } -- { dg-options "-gnatd.F" } procedure Unreferenced is X : aliased Integer; Y : access Integer := X'Access; Z : Integer renames Y.all; pragma Unreferenced (Z); begin null; end Unreferenced;
Gabriel-Degret/adalib
Ada
1,464
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 --------------------------------------------------------------------------- with System; with Ada.Containers.Synchronized_Queue_Interfaces; generic with package Queue_Interfaces is new Ada.Containers.Synchronized_Queue_Interfaces (<>); Default_Ceiling : System.Any_Priority := System.Priority'Last; package Ada.Containers.Unbounded_Synchronized_Queues is pragma Preelaborate(Unbounded_Synchronized_Queues); package Implementation is -- not specified by the language end Implementation; protected type Queue (Ceiling : System.Any_Priority := Default_Ceiling) with Priority => Ceiling is new Queue_Interfaces.Queue with overriding entry Enqueue (New_Item : in Queue_Interfaces.Element_Type); overriding entry Dequeue (Element : out Queue_Interfaces.Element_Type); overriding function Current_Use return Count_Type; overriding function Peak_Use return Count_Type; private -- not specified by the language end Queue; private -- not specified by the language end Ada.Containers.Unbounded_Synchronized_Queues;
reznikmm/matreshka
Ada
6,850
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$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.UML.Artifacts; with AMF.Visitors.Standard_Profile_L2_Iterators; with AMF.Visitors.Standard_Profile_L2_Visitors; package body AMF.Internals.Standard_Profile_L2_Libraries is ----------------------- -- Get_Base_Artifact -- ----------------------- overriding function Get_Base_Artifact (Self : not null access constant Standard_Profile_L2_Library_Proxy) return AMF.UML.Artifacts.UML_Artifact_Access is begin return AMF.UML.Artifacts.UML_Artifact_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Base_Artifact (Self.Element))); end Get_Base_Artifact; ----------------------- -- Set_Base_Artifact -- ----------------------- overriding procedure Set_Base_Artifact (Self : not null access Standard_Profile_L2_Library_Proxy; To : AMF.UML.Artifacts.UML_Artifact_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Base_Artifact (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Base_Artifact; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant Standard_Profile_L2_Library_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class (Visitor).Enter_Library (AMF.Standard_Profile_L2.Libraries.Standard_Profile_L2_Library_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant Standard_Profile_L2_Library_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class (Visitor).Leave_Library (AMF.Standard_Profile_L2.Libraries.Standard_Profile_L2_Library_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant Standard_Profile_L2_Library_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class then AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class (Iterator).Visit_Library (Visitor, AMF.Standard_Profile_L2.Libraries.Standard_Profile_L2_Library_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.Standard_Profile_L2_Libraries;
byllgrim/iictl
Ada
10,192
adb
-- See LICENSE file for cc0 license details with Ada.Directories; with Ada.Exceptions; use Ada.Exceptions; -- TODO remove with Ada.Strings; with Ada.Strings.Maps.Constants; with Ada.Strings.Unbounded; -- TODO needed? with Ada.Text_Io; with Iictl; -- TODO unecessary? with Posix.Io; with Posix.Process_Identification; with Posix.Process_Primitives; with Posix.Unsafe_Process_Primitives; -- TODO is there safe fork? with util; package body Srv_Conn is package AD renames Ada.Directories; package AS renames Ada.Strings; package ASMC renames Ada.Strings.Maps.Constants; package ASU renames Ada.Strings.Unbounded; -- TODO unneeded? package ATIO renames Ada.Text_Io; package IUSV renames Util.Unbounded_String_Vectors; package PIO renames Posix.Io; package PPI renames Posix.Process_Identification; package PPP renames Posix.Process_Primitives; package PUPP renames Posix.Unsafe_Process_Primitives; -- TODO remove unused packages -- TODO explicit in? procedure Reconnect_Servers (Irc_Dir : String; Nick : String) is Server_List : Util.Unbounded_String_Vector; -- TODO rename Directory_List? Process_List : Util.Unbounded_String_Vector; -- TODO garbage collector? begin Reap_Defunct_Procs; Server_List := Scan_Server_Directory (Irc_Dir); Process_List := Scan_Ii_Procs; Respawn_Clients (Server_List, Process_List); end Reconnect_Servers; -- TODO better formatting procedure Maintain_Connection (Dir_Ent : in AD.Directory_Entry_Type; Nick : in String) is Srv_Path : String := AD.Full_Name (Dir_Ent); -- TODO simple_name begin if not Util.Is_Fifo_Up (Srv_Path) then Spawn_Client (AD.Simple_Name (Dir_Ent), Nick); else Util.Verbose_Print ("Iictl: Maintain_Connection: " & Srv_Path & " is running"); -- TODO remove -- TODO someone COULD be cat'ing the in file end if; end Maintain_Connection; procedure Spawn_Client (Srv_Name : String; Nick : String) is use type PPI.Process_Id; Cmd : Posix.Filename := "ii"; Argv : Posix.Posix_String_List; begin -- TODO don't assume cwd? -- TODO check if Nick is given if PUPP.Fork = PPI.Null_Process_Id then -- New process Util.Verbose_Print ("Iictl: Spawn_Client: " & Srv_Name); Posix.Append (Argv, Cmd); Posix.Append (Argv, "-s"); Posix.Append (Argv, Posix.To_Posix_String(Srv_Name)); if Nick'Length /= 0 then Posix.Append (Argv, "-n"); Posix.Append (Argv, Posix.To_Posix_String(Nick)); end if; -- TODO exec with ii -i prefix -- TODO refactor PUPP.Exec_Search (Cmd, Argv); else -- Old process null; -- TODO wait for new process to launch ii end if; -- TODO check return or exception -- TODO keep track of PID? end Spawn_Client; procedure Reap_Defunct_Procs is use type Posix.Error_Code; Status : PPP.Termination_Status; begin loop -- TODO upper limit PPP.Wait_For_Child_Process (Status => Status, Block => False); -- TODO use more named parameters --if Status = didnotreap then if not PPP.Status_Available (Status) then exit; end if; Util.Verbose_Print ("Iictl: Reap_Defunct_Procs: Reaped one child"); end loop; exception when Error : Posix.Posix_Error => if Posix.Get_Error_Code = Posix.No_Child_Process then Util.Verbose_Print ("Iictl: Reap_Defunct_Procs: " & "No childs yet!"); -- TODO clean this else raise Posix.Posix_Error with Exception_Message (Error); end if; end; procedure Respawn_Clients (Server_List : Util.Unbounded_String_Vector; Process_List : Util.Unbounded_String_Vector) is begin -- TODO use iterator in other functions as well Server_Loop: for S of Server_List loop if Process_List.Find_Index (S) = IUSV.No_Index then -- TODO find another way to use No_Index Util.Verbose_Print ("Iictl: Respawn_Clients: No proc " & ASU.To_String (S)); Spawn_Client (ASU.To_String (S), "nick"); -- TODO Send name as Unbounded_String -- TODO get nick and all other flags else Util.Verbose_Print ("Iictl: Respawn_Clients: Found proc: " & ASU.To_String (S)); -- TODO remove end if; end loop Server_Loop; end; function Is_Srv_Dir (Dir_Ent : AD.Directory_Entry_Type) return Boolean is use type AD.File_Kind; Name : String := AD.Simple_Name (Dir_Ent); begin if AD.Kind (Dir_Ent) /= AD.Directory then return False; elsif Name (Name'First) = '.' then return False; -- TODO else if no */in */out else return True; end if; end Is_Srv_Dir; function Scan_Server_Directory (Irc_Dir : in String) return Util.Unbounded_String_Vector is Search : AD.Search_Type; Dir_Ent : AD.Directory_Entry_Type; Server_Name : ASU.Unbounded_String; Server_List : Util.Unbounded_String_Vector; begin AD.Start_Search (Search, Irc_Dir, ""); while AD.More_Entries (Search) loop AD.Get_Next_Entry (Search, Dir_Ent); if Is_Srv_Dir (Dir_Ent) then Server_Name := ASU.To_Unbounded_String (AD.Simple_Name (Dir_Ent)); Server_List.Append (Server_Name); Util.Verbose_Print ("Iictl: Scan_Server_Directory: found " & ASU.To_String (Server_Name)); end if; end loop; AD.End_Search (Search); return Server_List; end; function Scan_Ii_Procs return Util.Unbounded_String_Vector is Search : AD.Search_Type; Dir_Ent : AD.Directory_Entry_Type; Process_List : Util.Unbounded_String_Vector; Server_Name : ASU.Unbounded_String; begin AD.Start_Search (Search, "/proc", ""); while AD.More_Entries (Search) loop AD.Get_Next_Entry (Search, Dir_Ent); if Is_Ii_Proc (Dir_Ent) then Server_Name := Get_Server_Name (Dir_Ent); Util.Verbose_Print ("Iictl: Scan_Ii_Procs: Found " & ASU.To_String (Server_Name)); Process_List.Append (Server_Name); end if; end loop; AD.End_Search (Search); return Process_List; end; function Is_Ii_Proc (Dir_Ent : AD.Directory_Entry_Type) return Boolean is Dir_Name : String := AD.Simple_Name (Dir_Ent); File : ATIO.File_Type; Cmdline : ASU.Unbounded_String; Ret : Boolean := False; begin if not Util.Is_Integral (Dir_Name) then return False; end if; ATIO.Open (File, ATIO.In_File, "/proc/" & Dir_Name & "/cmdline"); Cmdline := ASU.To_Unbounded_String (ATIO.Get_Line (File)); -- TODO check only pids for current user --for I in Integer range 1 .. Cmdline.Length loop -- TODO I = 0 .. length for I in Integer range 1 .. ASU.Length (Cmdline) loop --if Cmdline.Element (I) = Character'Val (0) then if ASU.Element (Cmdline, I) = Character'Val (0) then if ASU.Element (Cmdline, I - 1) /= 'i' then ret := False; elsif ASU.Element (Cmdline, I - 2) /= 'i' then ret := False; else Util.Verbose_Print ("Iictl: Is_Ii_Proc: found " & ASU.To_String (Cmdline)); ret := True; end if; -- TODO other programs ending in ii? -- TODO check "*/ii" or "^ii" goto Exit_Is_Ii_Proc; end if; -- TODO non null-terminated cmdline end loop; -- TODO refactor Ret := False; -- Cmdline was not null-terminated <<Exit_Is_Ii_Proc>> ATIO.Close (File); return Ret; exception when ATIO.End_Error => -- TODO goto Exit_Is_Ii_Proc ATIO.Close (File); return False; end; -- TODO rename Get_Server_Flags to get host, nick, port etc function Get_Server_Name (Dir_Ent : AD.Directory_Entry_Type) return ASU.Unbounded_String is -- TODO define type for proc pid string File : ATIO.File_Type; Cmdline : ASU.Unbounded_String; Flag_First : Natural := 0; -- TODO rename Flag_Start? Ctrl_First : Positive; Ctrl_Last : Natural; Ret : ASU.Unbounded_String; Null_Char : ASU.Unbounded_String; begin ATIO.Open (File, ATIO.In_File, "/proc/" & AD.Simple_Name (Dir_Ent) & "/cmdline"); Cmdline := ASU.To_Unbounded_String (ATIO.Get_Line (File)); Flag_First := ASU.Index (Cmdline, "-s"); if Flag_First = 0 then Ret := ASU.To_Unbounded_String ("irc.freenode.net"); -- TODO consider default host else ASU.Find_Token (Cmdline, ASMC.Control_Set, Flag_First + 3, AS.Inside, Ctrl_First, Ctrl_Last); if Ctrl_Last = 0 then Ctrl_Last := ASU.Length (Cmdline); end if; Ret := ASU.Unbounded_Slice (CmdLine, Flag_First + 3, Ctrl_Last - 1); end if; ATIO.Close (File); Util.Verbose_Print ("Iictl: Get_Server_Name: found name " & ASU.To_String (Ret)); return Ret; end; end Srv_Conn;
AdaCore/libadalang
Ada
340
adb
procedure Testifc is package Pouet is type A is interface; procedure Frobulize (Self : A) is null; type E is interface; procedure Barulize (Self : E) is null; type B is new A and E with null record; Inst : B; end Pouet; use Pouet; begin Frobulize (Inst); Inst.Frobulize; end Testifc; pragma Test_Block;
reznikmm/matreshka
Ada
14,989
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_Multiplicity_Elements; with AMF.Internals.UML_Named_Elements; with AMF.UML.Actions; with AMF.UML.Activities; with AMF.UML.Connectable_Element_Template_Parameters; with AMF.UML.Connector_Ends.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Multiplicity_Elements; with AMF.UML.Named_Elements; with AMF.UML.Namespaces; with AMF.UML.Packages.Collections; with AMF.UML.Parameterable_Elements; with AMF.UML.String_Expressions; with AMF.UML.Structured_Activity_Nodes; with AMF.UML.Template_Parameters; with AMF.UML.Types; with AMF.UML.Variables; with AMF.Visitors; package AMF.Internals.UML_Variables is package UML_Multiplicity_Elements is new AMF.Internals.UML_Multiplicity_Elements (AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy); type UML_Variable_Proxy is limited new UML_Multiplicity_Elements.UML_Multiplicity_Element_Proxy and AMF.UML.Variables.UML_Variable with null record; overriding function Get_Activity_Scope (Self : not null access constant UML_Variable_Proxy) return AMF.UML.Activities.UML_Activity_Access; -- Getter of Variable::activityScope. -- -- An activity that owns the variable. overriding procedure Set_Activity_Scope (Self : not null access UML_Variable_Proxy; To : AMF.UML.Activities.UML_Activity_Access); -- Setter of Variable::activityScope. -- -- An activity that owns the variable. overriding function Get_Scope (Self : not null access constant UML_Variable_Proxy) return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access; -- Getter of Variable::scope. -- -- A structured activity node that owns the variable. overriding procedure Set_Scope (Self : not null access UML_Variable_Proxy; To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access); -- Setter of Variable::scope. -- -- A structured activity node that owns the variable. overriding function Get_End (Self : not null access constant UML_Variable_Proxy) return AMF.UML.Connector_Ends.Collections.Ordered_Set_Of_UML_Connector_End; -- Getter of ConnectableElement::end. -- -- Denotes a set of connector ends that attaches to this connectable -- element. overriding function Get_Template_Parameter (Self : not null access constant UML_Variable_Proxy) return AMF.UML.Connectable_Element_Template_Parameters.UML_Connectable_Element_Template_Parameter_Access; -- Getter of ConnectableElement::templateParameter. -- -- The ConnectableElementTemplateParameter for this ConnectableElement -- parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Variable_Proxy; To : AMF.UML.Connectable_Element_Template_Parameters.UML_Connectable_Element_Template_Parameter_Access); -- Setter of ConnectableElement::templateParameter. -- -- The ConnectableElementTemplateParameter for this ConnectableElement -- parameter. overriding function Get_Type (Self : not null access constant UML_Variable_Proxy) return AMF.UML.Types.UML_Type_Access; -- Getter of TypedElement::type. -- -- The type of the TypedElement. -- This information is derived from the return result for this Operation. overriding procedure Set_Type (Self : not null access UML_Variable_Proxy; To : AMF.UML.Types.UML_Type_Access); -- Setter of TypedElement::type. -- -- The type of the TypedElement. -- This information is derived from the return result for this Operation. overriding function Get_Client_Dependency (Self : not null access constant UML_Variable_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_Variable_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_Variable_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_Variable_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_Variable_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_Owning_Template_Parameter (Self : not null access constant UML_Variable_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Variable_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding function Get_Template_Parameter (Self : not null access constant UML_Variable_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Variable_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Is_Accessible_By (Self : not null access constant UML_Variable_Proxy; A : AMF.UML.Actions.UML_Action_Access) return Boolean; -- Operation Variable::isAccessibleBy. -- -- The isAccessibleBy() operation is not defined in standard UML. -- Implementations should define it to specify which actions can access a -- variable. overriding function Ends (Self : not null access constant UML_Variable_Proxy) return AMF.UML.Connector_Ends.Collections.Set_Of_UML_Connector_End; -- Operation ConnectableElement::end. -- -- Missing derivation for ConnectableElement::/end : ConnectorEnd overriding function All_Owning_Packages (Self : not null access constant UML_Variable_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_Variable_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_Variable_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding function Is_Compatible_With (Self : not null access constant UML_Variable_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean; -- Operation ParameterableElement::isCompatibleWith. -- -- The query isCompatibleWith() determines if this parameterable element -- is compatible with the specified parameterable element. By default -- parameterable element P is compatible with parameterable element Q if -- the kind of P is the same or a subtype as the kind of Q. Subclasses -- should override this operation to specify different compatibility -- constraints. overriding function Is_Template_Parameter (Self : not null access constant UML_Variable_Proxy) return Boolean; -- Operation ParameterableElement::isTemplateParameter. -- -- The query isTemplateParameter() determines if this parameterable -- element is exposed as a formal template parameter. overriding function Compatible_With (Self : not null access constant UML_Variable_Proxy; Other : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access) return Boolean; -- Operation MultiplicityElement::compatibleWith. -- -- The operation compatibleWith takes another multiplicity as input. It -- checks if one multiplicity is compatible with another. overriding function Includes_Cardinality (Self : not null access constant UML_Variable_Proxy; C : Integer) return Boolean; -- Operation MultiplicityElement::includesCardinality. -- -- The query includesCardinality() checks whether the specified -- cardinality is valid for this multiplicity. overriding function Includes_Multiplicity (Self : not null access constant UML_Variable_Proxy; M : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access) return Boolean; -- Operation MultiplicityElement::includesMultiplicity. -- -- The query includesMultiplicity() checks whether this multiplicity -- includes all the cardinalities allowed by the specified multiplicity. overriding function Iss (Self : not null access constant UML_Variable_Proxy; Lowerbound : Integer; Upperbound : Integer) return Boolean; -- Operation MultiplicityElement::is. -- -- The operation is determines if the upper and lower bound of the ranges -- are the ones given. overriding procedure Enter_Element (Self : not null access constant UML_Variable_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_Variable_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_Variable_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_Variables;
optikos/ada-lsp
Ada
19,344
adb
-- Copyright (c) 2017 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with League.JSON.Objects; with League.JSON.Streams; with League.Strings.Hash; with LSP.Messages; with LSP.Message_Handlers; with LSP.Servers; with LSP.Stdio_Streams; with LSP.Types; with LSP_Documents; with Ada.Containers.Hashed_Maps; with Ada_Wellknown; with Checkers; with Cross_References; procedure LSP_Test is function "+" (Text : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; package Document_Maps is new Ada.Containers.Hashed_Maps (Key_Type => LSP.Messages.DocumentUri, Element_Type => LSP_Documents.Document, Hash => League.Strings.Hash, Equivalent_Keys => League.Strings."=", "=" => LSP_Documents."="); type Message_Handler (Server : access LSP.Servers.Server) is limited new LSP.Message_Handlers.Request_Handler and LSP.Message_Handlers.Notification_Handler with record Documents : Document_Maps.Map; Checker : Checkers.Checker; XRef : Cross_References.Database; end record; overriding procedure Initialize_Request (Self : access Message_Handler; Value : LSP.Messages.InitializeParams; Response : in out LSP.Messages.Initialize_Response); overriding procedure Exit_Notification (Self : access Message_Handler); overriding procedure Text_Document_Definition_Request (Self : access Message_Handler; Value : LSP.Messages.TextDocumentPositionParams; Response : in out LSP.Messages.Location_Response); overriding procedure Text_Document_Did_Open (Self : access Message_Handler; Value : LSP.Messages.DidOpenTextDocumentParams); overriding procedure Text_Document_Did_Change (Self : access Message_Handler; Value : LSP.Messages.DidChangeTextDocumentParams); overriding procedure Text_Document_Did_Close (Self : access Message_Handler; Value : LSP.Messages.DidCloseTextDocumentParams); overriding procedure Text_Document_Did_Save (Self : access Message_Handler; Value : LSP.Messages.DidSaveTextDocumentParams); overriding procedure Text_Document_Completion_Request (Self : access Message_Handler; Value : LSP.Messages.TextDocumentPositionParams; Response : in out LSP.Messages.Completion_Response); overriding procedure Text_Document_Code_Action_Request (Self : access Message_Handler; Value : LSP.Messages.CodeActionParams; Response : in out LSP.Messages.CodeAction_Response); overriding procedure Text_Document_Highlight_Request (Self : access Message_Handler; Value : LSP.Messages.TextDocumentPositionParams; Response : in out LSP.Messages.Highlight_Response); overriding procedure Text_Document_Hover_Request (Self : access Message_Handler; Value : LSP.Messages.TextDocumentPositionParams; Response : in out LSP.Messages.Hover_Response); overriding procedure Text_Document_References_Request (Self : access Message_Handler; Value : LSP.Messages.ReferenceParams; Response : in out LSP.Messages.Location_Response); overriding procedure Text_Document_Signature_Help_Request (Self : access Message_Handler; Value : LSP.Messages.TextDocumentPositionParams; Response : in out LSP.Messages.SignatureHelp_Response); overriding procedure Text_Document_Symbol_Request (Self : access Message_Handler; Value : LSP.Messages.DocumentSymbolParams; Response : in out LSP.Messages.Symbol_Response); overriding procedure Workspace_Did_Change_Configuration (Self : access Message_Handler; Value : LSP.Messages.DidChangeConfigurationParams); overriding procedure Workspace_Execute_Command_Request (Self : access Message_Handler; Value : LSP.Messages.ExecuteCommandParams; Response : in out LSP.Messages.ExecuteCommand_Response); overriding procedure Workspace_Symbol_Request (Self : access Message_Handler; Value : LSP.Messages.WorkspaceSymbolParams; Response : in out LSP.Messages.Symbol_Response); ------------------------ -- Initialize_Request -- ------------------------ overriding procedure Initialize_Request (Self : access Message_Handler; Value : LSP.Messages.InitializeParams; Response : in out LSP.Messages.Initialize_Response) is use type LSP.Types.LSP_String; Completion_Characters : LSP.Types.LSP_String_Vector; Commands : LSP.Types.LSP_String_Vector; Signature_Keys : LSP.Types.LSP_String_Vector; begin Self.XRef.Initialize (Value.rootUri & "/source/protocol/"); Completion_Characters.Append (+"'"); Commands.Append (+"Text_Edit"); Signature_Keys.Append (+"("); Signature_Keys.Append (+","); Response.result.capabilities.textDocumentSync := (Is_Set => True, Is_Number => True, Value => LSP.Messages.Full); Response.result.capabilities.completionProvider := (Is_Set => True, Value => (resolveProvider => LSP.Types.Optional_False, triggerCharacters => Completion_Characters)); Response.result.capabilities.codeActionProvider := LSP.Types.Optional_True; Response.result.capabilities.executeCommandProvider := (commands => Commands); Response.result.capabilities.hoverProvider := LSP.Types.Optional_True; Response.result.capabilities.signatureHelpProvider := (True, (triggerCharacters => Signature_Keys)); Response.result.capabilities.definitionProvider := LSP.Types.Optional_True; Response.result.capabilities.referencesProvider := LSP.Types.Optional_True; Response.result.capabilities.documentSymbolProvider := LSP.Types.Optional_True; Response.result.capabilities.workspaceSymbolProvider := LSP.Types.Optional_True; end Initialize_Request; --------------------------------------- -- Text_Document_Code_Action_Request -- --------------------------------------- overriding procedure Text_Document_Code_Action_Request (Self : access Message_Handler; Value : LSP.Messages.CodeActionParams; Response : in out LSP.Messages.CodeAction_Response) is use type League.Strings.Universal_String; begin for Item of Value.context.diagnostics loop if Item.message = +"missing "";""" then declare Edit : LSP.Messages.TextDocumentEdit; Command : LSP.Messages.Command; JS : aliased League.JSON.Streams.JSON_Stream; Insert : constant LSP.Messages.TextEdit := (Value.span, +";"); begin Edit.textDocument := (Value.textDocument with version => Self.Documents (Value.textDocument.uri).Version); Edit.edits.Append (Insert); LSP.Messages.TextDocumentEdit'Write (JS'Access, Edit); Command.title := +"Insert semicolon"; Command.command := +"Text_Edit"; Command.arguments := JS.Get_JSON_Document.To_JSON_Array.To_JSON_Value; Response.result.Append (Command); end; end if; end loop; end Text_Document_Code_Action_Request; -------------------------------------- -- Text_Document_Completion_Request -- -------------------------------------- overriding procedure Text_Document_Completion_Request (Self : access Message_Handler; Value : LSP.Messages.TextDocumentPositionParams; Response : in out LSP.Messages.Completion_Response) is Document : LSP_Documents.Document renames Self.Documents (Value.textDocument.uri); Position : constant Natural := Natural (Value.position.character); Line : constant LSP.Types.LSP_String := Document.Get_Line (Value.position.line); begin if Position in 1 .. Line.Length and then Line (Position).To_Wide_Wide_Character = ''' then Response.result.items.Append (Ada_Wellknown.Attributes); -- Remove extra ' after cursor (if any) if Position + 1 in 1 .. Line.Length and then Line (Position + 1).To_Wide_Wide_Character = ''' then declare use type LSP.Types.UTF_16_Index; Edit : constant LSP.Messages.TextEdit := (((Value.position.line, Value.position.character), (Value.position.line, Value.position.character + 1)), others => <>); begin for Item of Response.result.items loop Item.additionalTextEdits.Append (Edit); end loop; end; end if; end if; end Text_Document_Completion_Request; -------------------------------------- -- Text_Document_Definition_Request -- -------------------------------------- overriding procedure Text_Document_Definition_Request (Self : access Message_Handler; Value : LSP.Messages.TextDocumentPositionParams; Response : in out LSP.Messages.Location_Response) is Document : LSP_Documents.Document renames Self.Documents (Value.textDocument.uri); Lookup : constant LSP_Documents.Lookup_Result := Document.Lookup (Value.position); Result : LSP.Messages.Location; Found : Boolean := False; begin case Lookup.Kind is when LSP_Documents.Identifier => Self.XRef.Get_Definition (Lookup.Value, Result, Found); if Found then Response.result.Append (Result); end if; when others => null; end case; end Text_Document_Definition_Request; ------------------------------ -- Text_Document_Did_Change -- ------------------------------ overriding procedure Text_Document_Did_Change (Self : access Message_Handler; Value : LSP.Messages.DidChangeTextDocumentParams) is Document : LSP_Documents.Document; begin Document.Initalize (Value.textDocument.uri, Value.contentChanges.Last_Element.text, Value.textDocument.version); Self.Documents.Replace (Value.textDocument.uri, Document); end Text_Document_Did_Change; ----------------------------- -- Text_Document_Did_Close -- ----------------------------- overriding procedure Text_Document_Did_Close (Self : access Message_Handler; Value : LSP.Messages.DidCloseTextDocumentParams) is begin Self.Documents.Delete (Value.textDocument.uri); end Text_Document_Did_Close; ---------------------------- -- Text_Document_Did_Open -- ---------------------------- overriding procedure Text_Document_Did_Open (Self : access Message_Handler; Value : LSP.Messages.DidOpenTextDocumentParams) is Document : LSP_Documents.Document; begin Document.Initalize (Value.textDocument.uri, Value.textDocument.text, Value.textDocument.version); Self.Documents.Include (Value.textDocument.uri, Document); end Text_Document_Did_Open; ---------------------------- -- Text_Document_Did_Save -- ---------------------------- overriding procedure Text_Document_Did_Save (Self : access Message_Handler; Value : LSP.Messages.DidSaveTextDocumentParams) is File : constant LSP.Types.LSP_String := Value.textDocument.uri.Tail_From (8); -- skip 'file://' schema Note : LSP.Messages.PublishDiagnostics_Notification; begin Self.Checker.Run (File, Note.params.diagnostics); Note.method := +"textDocument/publishDiagnostics"; Note.params.uri := Value.textDocument.uri; Self.Server.Send_Notification (Note); end Text_Document_Did_Save; ----------------------- -- Exit_Notification -- ----------------------- overriding procedure Exit_Notification (Self : access Message_Handler) is begin Self.Server.Stop; end Exit_Notification; ------------------------------------- -- Text_Document_Highlight_Request -- ------------------------------------- overriding procedure Text_Document_Highlight_Request (Self : access Message_Handler; Value : LSP.Messages.TextDocumentPositionParams; Response : in out LSP.Messages.Highlight_Response) is pragma Unreferenced (Response); Document : LSP_Documents.Document renames Self.Documents (Value.textDocument.uri); Lookup : constant LSP_Documents.Lookup_Result := Document.Lookup (Value.position); begin case Lookup.Kind is when LSP_Documents.Identifier => null; when LSP_Documents.None | LSP_Documents.Pragma_Name | LSP_Documents.Attribute_Designator => null; end case; end Text_Document_Highlight_Request; --------------------------------- -- Text_Document_Hover_Request -- --------------------------------- overriding procedure Text_Document_Hover_Request (Self : access Message_Handler; Value : LSP.Messages.TextDocumentPositionParams; Response : in out LSP.Messages.Hover_Response) is Document : LSP_Documents.Document renames Self.Documents (Value.textDocument.uri); Lookup : constant LSP_Documents.Lookup_Result := Document.Lookup (Value.position); begin case Lookup.Kind is when LSP_Documents.Attribute_Designator => Response.result.contents.Append (Ada_Wellknown.Attribute_Hover (Lookup.Value)); when LSP_Documents.None | LSP_Documents.Pragma_Name | LSP_Documents.Identifier => null; end case; end Text_Document_Hover_Request; -------------------------------------- -- Text_Document_References_Request -- -------------------------------------- overriding procedure Text_Document_References_Request (Self : access Message_Handler; Value : LSP.Messages.ReferenceParams; Response : in out LSP.Messages.Location_Response) is Document : LSP_Documents.Document renames Self.Documents (Value.textDocument.uri); Lookup : constant LSP_Documents.Lookup_Result := Document.Lookup (Value.position); begin case Lookup.Kind is when LSP_Documents.Identifier => Self.XRef.Get_References (Name => Lookup.Value, With_Decl => Value.context.includeDeclaration, Result => Response.result); when others => null; end case; end Text_Document_References_Request; ------------------------------------------ -- Text_Document_Signature_Help_Request -- ------------------------------------------ overriding procedure Text_Document_Signature_Help_Request (Self : access Message_Handler; Value : LSP.Messages.TextDocumentPositionParams; Response : in out LSP.Messages.SignatureHelp_Response) is Document : LSP_Documents.Document renames Self.Documents (Value.textDocument.uri); Lookup : constant LSP_Documents.Lookup_Result := Document.Lookup (Value.position); begin case Lookup.Kind is when LSP_Documents.Pragma_Name => Response.result.signatures.Append (Ada_Wellknown.Pragma_Signatures (Lookup.Name)); if not Response.result.signatures.Is_Empty then if Lookup.Parameter > 0 then Response.result.activeParameter := (True, Lookup.Parameter - 1); end if; Response.result.activeSignature := (True, 0); end if; when LSP_Documents.Attribute_Designator | LSP_Documents.Identifier | LSP_Documents.None => null; end case; end Text_Document_Signature_Help_Request; ---------------------------------- -- Text_Document_Symbol_Request -- ---------------------------------- overriding procedure Text_Document_Symbol_Request (Self : access Message_Handler; Value : LSP.Messages.DocumentSymbolParams; Response : in out LSP.Messages.Symbol_Response) is Document : LSP_Documents.Document renames Self.Documents (Value.textDocument.uri); begin Response.result.Append (Document.All_Symbols (+"")); end Text_Document_Symbol_Request; ---------------------------------------- -- Workspace_Did_Change_Configuration -- ---------------------------------------- overriding procedure Workspace_Did_Change_Configuration (Self : access Message_Handler; Value : LSP.Messages.DidChangeConfigurationParams) is Ada : League.JSON.Objects.JSON_Object; begin if Value.settings.To_Object.Contains (+"ada") then Ada := Value.settings.To_Object.Value (+"ada").To_Object; end if; if Ada.Contains (+"project_file") then Self.Checker.Initialize (Ada.Value (+"project_file").To_String); end if; end Workspace_Did_Change_Configuration; --------------------------------------- -- Workspace_Execute_Command_Request -- --------------------------------------- overriding procedure Workspace_Execute_Command_Request (Self : access Message_Handler; Value : LSP.Messages.ExecuteCommandParams; Response : in out LSP.Messages.ExecuteCommand_Response) is use type League.Strings.Universal_String; pragma Unreferenced (Response); Params : LSP.Messages.ApplyWorkspaceEditParams; Applied : Boolean; Error : LSP.Messages.Optional_ResponseError; begin if Value.command = +"Text_Edit" then declare JS : aliased League.JSON.Streams.JSON_Stream; Edit : LSP.Messages.TextDocumentEdit; begin JS.Set_JSON_Document (Value.arguments.To_Array.To_JSON_Document); LSP.Messages.TextDocumentEdit'Read (JS'Access, Edit); Params.edit.documentChanges.Append (Edit); Self.Server.Workspace_Apply_Edit (Params, Applied, Error); end; end if; end Workspace_Execute_Command_Request; ------------------------------ -- Workspace_Symbol_Request -- ------------------------------ overriding procedure Workspace_Symbol_Request (Self : access Message_Handler; Value : LSP.Messages.WorkspaceSymbolParams; Response : in out LSP.Messages.Symbol_Response) is begin for Document of Self.Documents loop Response.result.Append (Document.All_Symbols (Value.query)); end loop; end Workspace_Symbol_Request; Server : aliased LSP.Servers.Server; Handler : aliased Message_Handler (Server'Access); Stream : aliased LSP.Stdio_Streams.Stdio_Stream; begin Ada_Wellknown.Initialize; Server.Initialize (Stream'Unchecked_Access, Handler'Unchecked_Access, Handler'Unchecked_Access); Server.Run; end LSP_Test;
charlie5/lace
Ada
2,074
adb
with opengl.Display .privvy, opengl.surface_Profile.privvy, opengl.Surface .privvy, egl.Binding, System; package body openGL.Context is use egl.Binding, System; procedure define (Self : in out Item; the_Display : access opengl.Display.item'Class; the_surface_Profile : in opengl.surface_Profile.item) is use EGL, opengl.Display .privvy, opengl.surface_Profile.privvy; contextAttribs : EGLint_array := [EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE]; begin Self.egl_Context := eglCreateContext (to_eGL (the_Display.all), to_eGL (the_surface_Profile), EGL_NO_CONTEXT, contextAttribs (contextAttribs'First)'Unchecked_Access); if Self.egl_Context = EGL_NO_CONTEXT then raise opengl.Error with "Unable to create an EGL Context."; end if; Self.Display := the_Display; end define; procedure make_Current (Self : in Item; read_Surface : in opengl.Surface.item; write_Surface : in opengl.Surface.item) is use eGL, opengl.Display.privvy, opengl.Surface.privvy; use type EGLBoolean; Success : constant EGLBoolean := eglmakeCurrent (to_eGL (Self.Display.all), to_eGL (read_Surface), to_eGL (write_Surface), Self.egl_Context); begin if Success = EGL_FALSE then raise openGL.Error with "unable to make egl Context current"; end if; end make_Current; function egl_Context_debug (Self : in Item'Class) return egl.EGLConfig is begin return self.egl_Context; end egl_Context_debug; end openGL.Context;
charlie5/aShell
Ada
1,647
adb
with Shell.Commands.Safe, Ada.Text_IO; procedure Test_Command_Input is procedure Log (Message : in String) renames Ada.Text_IO.Put_Line; procedure NL (Count : in Ada.Text_IO.Positive_Count := 1) renames Ada.Text_IO.New_Line; begin Shell.Open_Log ("Shell.log"); Log ("Begin Test_Command_Input test."); NL (2); declare use Shell, Shell.Commands, Shell.Commands.Safe, Shell.Commands.Safe.Forge; The_Command : Safe.Command := To_Command ("cat -"); begin The_Command.Start (Accepts_Input => True); The_Command.Send (+"Hello world."); delay 0.5; Log ("Output: '" & (+Output_of (Results_Of (The_Command))) & "'"); for i in 1 .. 5 loop The_Command.Send (+i'Image); delay 0.5; Log ("Output: '" & (+Output_of (Results_Of (The_Command))) & "'"); end loop; The_Command.Send (+"Goodbye world."); delay 1.0; Log ("Output: '" & (+Output_of (Results_Of (The_Command))) & "'"); -- while not The_Command.Has_Terminated -- loop -- declare -- Output : constant String := +Output_of (Results_Of (The_Command)); -- begin -- if Output /= "" -- then -- Log ("Output: '" & Output & "'"); -- end if; -- -- delay 0.5; -- end; -- end loop; The_Command.Kill; end; Log ("Stopping spawn client."); Shell.Commands.Safe.Stop_Spawn_Client; NL (2); Log ("End Test_Command_Input test."); end Test_Command_Input;
zhmu/ananas
Ada
1,032
adb
-- { dg-do run } with Tagged3_Pkg; use Tagged3_Pkg; procedure Tagged3 is package SP is type Ref is tagged private; procedure Set (Self : in out Ref'Class; Data : Parent'Class); type Reference_Type (Element : access Parent'Class) is limited null record with Implicit_Dereference => Element; function Get (Self : Ref'Class) return Reference_Type; private type Element_Access is access all Parent'Class; type Ref is tagged record Data : Element_Access; end record; end; package body SP is procedure Set (Self : in out Ref'Class; Data : Parent'Class) is begin Self.Data := new Parent'Class'(Data); end; function Get (Self : Ref'Class) return Reference_Type is begin return Reference_Type'(Element => Self.Data); end; end; DC : Child; RC : SP.Ref; begin RC.Set (DC); Prim1 (RC.Get.Element); -- Test if not Tagged3_Pkg.Child_Prim1_Called then raise Program_Error; end if; end;
tum-ei-rcs/StratoX
Ada
48
ads
package PX4IO with SPARK_Mode is end PX4IO;
zhmu/ananas
Ada
12,187
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- L I B . X R E F . S P A R K _ S P E C I F I C -- -- -- -- B o d y -- -- -- -- Copyright (C) 2011-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 Einfo.Entities; use Einfo.Entities; with Nmake; use Nmake; with SPARK_Xrefs; use SPARK_Xrefs; separate (Lib.Xref) package body SPARK_Specific is --------------------- -- Local Constants -- --------------------- -- Table of SPARK_Entities, True for each entity kind used in SPARK SPARK_Entities : constant array (Entity_Kind) of Boolean := (E_Constant => True, E_Entry => True, E_Function => True, E_In_Out_Parameter => True, E_In_Parameter => True, E_Loop_Parameter => True, E_Operator => True, E_Out_Parameter => True, E_Procedure => True, E_Variable => True, others => False); -- True for each reference type used in SPARK SPARK_References : constant array (Character) of Boolean := ('m' => True, 'r' => True, 's' => True, others => False); --------------------- -- Local Variables -- --------------------- package Drefs is new Table.Table ( Table_Component_Type => Xref_Entry, Table_Index_Type => Xref_Entry_Number, Table_Low_Bound => 1, Table_Initial => Alloc.Drefs_Initial, Table_Increment => Alloc.Drefs_Increment, Table_Name => "Drefs"); -- Table of cross-references for reads and writes through explicit -- dereferences, that are output as reads/writes to the special variable -- "Heap". These references are added to the regular references when -- computing SPARK cross-references. ------------------------- -- Iterate_SPARK_Xrefs -- ------------------------- procedure Iterate_SPARK_Xrefs is procedure Add_SPARK_Xref (Index : Int; Xref : Xref_Entry); function Is_SPARK_Reference (E : Entity_Id; Typ : Character) return Boolean; -- Return whether entity reference E meets SPARK requirements. Typ is -- the reference type. function Is_SPARK_Scope (E : Entity_Id) return Boolean; -- Return whether the entity or reference scope meets requirements for -- being a SPARK scope. -------------------- -- Add_SPARK_Xref -- -------------------- procedure Add_SPARK_Xref (Index : Int; Xref : Xref_Entry) is Ref : Xref_Key renames Xref.Key; begin -- Eliminate entries not appropriate for SPARK if SPARK_Entities (Ekind (Ref.Ent)) and then SPARK_References (Ref.Typ) and then Is_SPARK_Scope (Ref.Ent_Scope) and then Is_SPARK_Scope (Ref.Ref_Scope) and then Is_SPARK_Reference (Ref.Ent, Ref.Typ) then Process (Index, (Entity => Ref.Ent, Ref_Scope => Ref.Ref_Scope, Rtype => Ref.Typ)); end if; end Add_SPARK_Xref; ------------------------ -- Is_SPARK_Reference -- ------------------------ function Is_SPARK_Reference (E : Entity_Id; Typ : Character) return Boolean is begin -- The only references of interest on callable entities are calls. On -- uncallable entities, the only references of interest are reads and -- writes. if Ekind (E) in Overloadable_Kind then return Typ = 's'; -- In all other cases, result is true for reference/modify cases, -- and false for all other cases. else return Typ = 'r' or else Typ = 'm'; end if; end Is_SPARK_Reference; -------------------- -- Is_SPARK_Scope -- -------------------- function Is_SPARK_Scope (E : Entity_Id) return Boolean is Can_Be_Renamed : constant Boolean := Present (E) and then (Is_Subprogram_Or_Entry (E) or else Ekind (E) = E_Package); begin return Present (E) and then not Is_Generic_Unit (E) and then (not Can_Be_Renamed or else No (Renamed_Entity (E))); end Is_SPARK_Scope; -- Start of processing for Add_SPARK_Xrefs begin -- Expose cross-references from private frontend tables to the backend for Index in Drefs.First .. Drefs.Last loop Add_SPARK_Xref (Index, Drefs.Table (Index)); end loop; for Index in Xrefs.First .. Xrefs.Last loop Add_SPARK_Xref (-Index, Xrefs.Table (Index)); end loop; end Iterate_SPARK_Xrefs; --------------------------------------------- -- Enclosing_Subprogram_Or_Library_Package -- --------------------------------------------- function Enclosing_Subprogram_Or_Library_Package (N : Node_Id) return Entity_Id is Context : Entity_Id; begin -- If N is the defining identifier for a subprogram, then return the -- enclosing subprogram or package, not this subprogram. if Nkind (N) in N_Defining_Identifier | N_Defining_Operator_Symbol and then Ekind (N) in Entry_Kind | E_Subprogram_Body | Generic_Subprogram_Kind | Subprogram_Kind then if No (Unit_Declaration_Node (N)) then return Empty; end if; Context := Parent (Unit_Declaration_Node (N)); -- If this was a library-level subprogram then replace Context with -- its Unit, which points to N_Subprogram_* node. if Nkind (Context) = N_Compilation_Unit then Context := Unit (Context); end if; else Context := N; end if; while Present (Context) loop case Nkind (Context) is when N_Package_Body | N_Package_Specification => -- Only return a library-level package if Is_Library_Level_Entity (Defining_Entity (Context)) then Context := Defining_Entity (Context); exit; else Context := Parent (Context); end if; when N_Pragma => -- The enclosing subprogram for a precondition, postcondition, -- or contract case should be the declaration preceding the -- pragma (skipping any other pragmas between this pragma and -- this declaration. while Nkind (Context) = N_Pragma and then Is_List_Member (Context) and then Present (Prev (Context)) loop Context := Prev (Context); end loop; if Nkind (Context) = N_Pragma then -- When used for cross-references then aspects might not be -- yet linked to pragmas; when used for AST navigation in -- GNATprove this routine is expected to follow those links. if From_Aspect_Specification (Context) then Context := Corresponding_Aspect (Context); pragma Assert (Nkind (Context) = N_Aspect_Specification); Context := Entity (Context); else Context := Parent (Context); end if; end if; when N_Entry_Body | N_Entry_Declaration | N_Protected_Type_Declaration | N_Subprogram_Body | N_Subprogram_Declaration | N_Subprogram_Specification | N_Task_Body | N_Task_Type_Declaration => Context := Defining_Entity (Context); exit; when others => Context := Parent (Context); end case; end loop; if Nkind (Context) = N_Defining_Program_Unit_Name then Context := Defining_Identifier (Context); end if; -- Do not return a scope without a proper location if Present (Context) and then Sloc (Context) = No_Location then return Empty; end if; return Context; end Enclosing_Subprogram_Or_Library_Package; -------------------------- -- Generate_Dereference -- -------------------------- procedure Generate_Dereference (N : Node_Id; Typ : Character := 'r') is procedure Create_Heap; -- Create and decorate the special entity which denotes the heap ----------------- -- Create_Heap -- ----------------- procedure Create_Heap is begin Heap := Make_Defining_Identifier (Standard_Location, Name_Enter (Name_Of_Heap_Variable)); Mutate_Ekind (Heap, E_Variable); Set_Is_Internal (Heap, True); Set_Etype (Heap, Standard_Void_Type); Set_Scope (Heap, Standard_Standard); Set_Has_Fully_Qualified_Name (Heap); end Create_Heap; -- Local variables Loc : constant Source_Ptr := Sloc (N); -- Start of processing for Generate_Dereference begin if Loc > No_Location then Drefs.Increment_Last; declare Deref_Entry : Xref_Entry renames Drefs.Table (Drefs.Last); Deref : Xref_Key renames Deref_Entry.Key; begin if No (Heap) then Create_Heap; end if; Deref.Ent := Heap; Deref.Loc := Loc; Deref.Typ := Typ; -- It is as if the special "Heap" was defined in the main unit, -- in the scope of the entity for the main unit. This single -- definition point is required to ensure that sorting cross -- references works for "Heap" references as well. Deref.Eun := Main_Unit; Deref.Lun := Get_Top_Level_Code_Unit (Loc); Deref.Ref_Scope := Enclosing_Subprogram_Or_Library_Package (N); Deref.Ent_Scope := Cunit_Entity (Main_Unit); Deref_Entry.Def := No_Location; Deref_Entry.Ent_Scope_File := Main_Unit; end; end if; end Generate_Dereference; end SPARK_Specific;
reznikmm/matreshka
Ada
3,670
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with League.Holders.Generic_Enumerations; package AMF.DC.Holders.Known_Colors is new League.Holders.Generic_Enumerations (AMF.DC.DC_Known_Color); pragma Preelaborate (AMF.DC.Holders.Known_Colors);
zhmu/ananas
Ada
10,685
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- A D A B K E N D -- -- -- -- B o d y -- -- -- -- Copyright (C) 2001-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. 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. -- -- -- ------------------------------------------------------------------------------ -- This is the version of the Back_End package for back ends written in Ada with Atree; use Atree; with Backend_Utils; use Backend_Utils; with Debug; with Lib; with Opt; use Opt; with Output; use Output; with Osint; use Osint; with Osint.C; use Osint.C; with Switch.C; use Switch.C; with Types; use Types; with System.OS_Lib; use System.OS_Lib; package body Adabkend is use Switch; ------------------- -- Call_Back_End -- ------------------- procedure Call_Back_End is begin if (Opt.Verbose_Mode or Opt.Full_List) and then not Debug.Debug_Flag_7 then Write_Eol; Write_Str (Product_Name); Write_Str (", Copyright "); Write_Str (Copyright_Years); Write_Str (" Ada Core Technologies, Inc."); Write_Str (" (http://www.adacore.com)"); Write_Eol; Write_Eol; end if; -- The front end leaves the Current_Error_Node at a location that is -- meaningless and confusing when emitting bug boxes from the back end. -- Reset the global variable in order to emit "No source file position -- information available" messages on back end crashes. Current_Error_Node := Empty; Driver (Lib.Cunit (Types.Main_Unit)); end Call_Back_End; ----------------------------- -- Scan_Compiler_Arguments -- ----------------------------- procedure Scan_Compiler_Arguments is Output_File_Name_Seen : Boolean := False; -- Set to True after having scanned the file_name for switch -- "-gnatO file_name" Argument_Count : constant Integer := Arg_Count - 1; -- Number of arguments (excluding program name) Args : Argument_List (1 .. Argument_Count); Next_Arg : Positive := 1; procedure Scan_Back_End_Switches (Switch_Chars : String); -- Procedure to scan out switches stored in Switch_Chars. The first -- character is known to be a valid switch character, and there are no -- blanks or other switch terminator characters in the string, so the -- entire string should consist of valid switch characters, except that -- an optional terminating NUL character is allowed. -- -- If the switch is not valid, control will not return. The switches -- must still be scanned to skip the "-o" arguments, or internal GCC -- switches, which may be safely ignored by other back ends. ---------------------------- -- Scan_Back_End_Switches -- ---------------------------- procedure Scan_Back_End_Switches (Switch_Chars : String) is First : constant Positive := Switch_Chars'First + 1; Last : constant Natural := Switch_Last (Switch_Chars); begin -- Process any back end switches, returning if the switch does not -- affect code generation or falling through if it does, so the -- switch will get stored. -- Skip -o, -G or internal GCC switches together with their argument. if Switch_Chars (First .. Last) = "o" or else Switch_Chars (First .. Last) = "G" or else Is_Internal_GCC_Switch (Switch_Chars) then Next_Arg := Next_Arg + 1; return; -- ignore this switch -- Set optimization indicators appropriately. In gcc-based GNAT this -- is picked up from imported variables set by the gcc driver, but -- for compilers with non-gcc back ends we do it here to allow use of -- these switches by the front end. Allowed optimization switches are -- -Os (optimize for size), -O[0123], -O (same as -O1), -Ofast -- (disregard strict standards compliance), and -Og (optimize -- debugging experience). elsif Switch_Chars (First) = 'O' then if First = Last then Optimization_Level := 1; elsif Last - First = 1 then if Switch_Chars (Last) = 's' then Optimize_Size := 1; Optimization_Level := 2; -- Consistent with gcc setting elsif Switch_Chars (Last) in '0' .. '3' then Optimization_Level := Character'Pos (Switch_Chars (Last)) - Character'Pos ('0'); -- Switch -Og is between -O0 and -O1 in GCC. Consider it like -- -O0 for other back ends. elsif Switch_Chars (Last) = 'g' then Optimization_Level := 0; else Fail ("invalid switch: " & Switch_Chars); end if; -- Switch -Ofast enables -O3 elsif Switch_Chars (First + 1 .. Last) = "fast" then Optimization_Level := 3; else Fail ("invalid switch: " & Switch_Chars); end if; elsif Switch_Chars (First .. Last) = "quiet" then return; -- ignore this switch elsif Switch_Chars (First .. Last) = "c" then return; -- ignore this switch -- The -x switch and its language name argument will generally be -- ignored by non-gcc back ends. In any case, we save the switch and -- argument in the compilation switches. elsif Switch_Chars (First .. Last) = "x" then Lib.Store_Compilation_Switch (Switch_Chars); Next_Arg := Next_Arg + 1; declare Argv : constant String := Args (Next_Arg).all; begin if Is_Switch (Argv) then Fail ("language name missing after -x"); else Lib.Store_Compilation_Switch (Argv); end if; end; return; -- Ignore all other back-end switches elsif Scan_Common_Back_End_Switch (Switch_Chars) or else Is_Back_End_Switch (Switch_Chars) then null; -- Give error for junk switch else Fail ("invalid switch: " & Switch_Chars); end if; -- Store any other GCC switches Lib.Store_Compilation_Switch (Switch_Chars); end Scan_Back_End_Switches; -- Start of processing for Scan_Compiler_Args begin -- Put all the arguments in argument list Args for Arg in 1 .. Argument_Count loop declare Argv : String (1 .. Len_Arg (Arg)); begin Fill_Arg (Argv'Address, Arg); Args (Arg) := new String'(Argv); end; end loop; -- Loop through command line arguments, storing them for later access while Next_Arg <= Argument_Count loop Look_At_Arg : declare Argv : constant String := Args (Next_Arg).all; begin if Argv'Length = 0 then Fail ("Empty argument"); end if; -- If the previous switch has set the Output_File_Name_Present -- flag (that is we have seen a -gnatO), then the next argument -- is the name of the output object file. if Opt.Output_File_Name_Present and then not Output_File_Name_Seen then if Is_Switch (Argv) then Fail ("Object file name missing after -gnatO"); else Set_Output_Object_File_Name (Argv); Output_File_Name_Seen := True; end if; -- If the previous switch has set the Search_Directory_Present -- flag (that is if we have just seen -I), then the next -- argument is a search directory path. elsif Search_Directory_Present then if Is_Switch (Argv) then Fail ("search directory missing after -I"); else Add_Src_Search_Dir (Argv); -- Add directory to lib search so that back end can take as -- input ALI files if needed. Otherwise this won't have any -- impact on the compiler. Add_Lib_Search_Dir (Argv); Search_Directory_Present := False; end if; -- If not a switch, must be a file name elsif not Is_Switch (Argv) then Add_File (Argv); -- We must recognize -nostdinc to suppress visibility on the -- standard GNAT RTL sources. elsif Argv (Argv'First + 1 .. Argv'Last) = "nostdinc" then Opt.No_Stdinc := True; -- Front end switch elsif Is_Front_End_Switch (Argv) then Scan_Front_End_Switches (Argv, Args, Next_Arg); -- All non-front-end switches are back-end switches else Scan_Back_End_Switches (Argv); end if; end Look_At_Arg; Next_Arg := Next_Arg + 1; end loop; end Scan_Compiler_Arguments; end Adabkend;
reznikmm/matreshka
Ada
4,210
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016-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.Exceptions; with Ada.Text_IO; with AWS.Server; with League.Strings; with Servlet.Application; procedure Spikedog.AWS_Driver is begin begin Servlet.Application.Initialize (Application_Name => League.Strings.To_Universal_String ("Spikedog Application Server"), Application_Version => League.Strings.To_Universal_String ("0.1"), Organization_Name => League.Strings.To_Universal_String ("Matreshka Project"), Organization_Domain => League.Strings.To_Universal_String ("forge.ada-ru.org")); exception when E : others => Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, Ada.Exceptions.Exception_Information (E)); end; -- Wait till built-in HTTP server is running. AWS.Server.Wait (AWS.Server.No_Server); end Spikedog.AWS_Driver;
Rodeo-McCabe/orka
Ada
9,219
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 Ada.Containers.Vectors; with Ada.Exceptions; with Ada.Real_Time; with Ada.Text_IO; with Orka.Containers.Ring_Buffers; with Orka.OS; package body Orka.Resources.Loader is function Is_Extension (Path, Extension : String) return Boolean is (Path (Path'Last - Extension'Length .. Path'Last) = "." & Extension); use type Loaders.Loader_Access; package Loader_Vectors is new Ada.Containers.Vectors (Positive, Loaders.Loader_Access); -- Using a vector instead of a map gives looking up a loader a time -- complexity of O(n) instead of O(1), but it is assumed that there -- will only be a handful of registered loaders protected Resource_Loaders is procedure Include (Loader : Loaders.Loader_Ptr); -- Add the loader to the list of loaders if it hasn't already -- been added function Has_Loader (Path : String) return Boolean; -- Return True if a loader has been registered that can load the -- file at the given path based on its extension, False otherwise function Loader (Path : String) return Loaders.Loader_Ptr; -- Return a loader based on the extension of the given path private Loaders_Vector : Loader_Vectors.Vector; end Resource_Loaders; protected body Resource_Loaders is procedure Include (Loader : Loaders.Loader_Ptr) is begin if not (for some L of Loaders_Vector => L.Extension = Loader.Extension) then Loaders_Vector.Append (Loader); end if; end Include; function Has_Loader (Path : String) return Boolean is (for some Loader of Loaders_Vector => Is_Extension (Path, Loader.Extension)); function Loader (Path : String) return Loaders.Loader_Ptr is begin for Loader of Loaders_Vector loop if Is_Extension (Path, Loader.Extension) then return Loader; end if; end loop; raise Constraint_Error; end Loader; end Resource_Loaders; ----------------------------------------------------------------------------- type Pair is record Location : Locations.Location_Access; Loader : Loaders.Loader_Access; end record; package Pair_Vectors is new Ada.Containers.Vectors (Positive, Pair); protected Resource_Locations is procedure Add (Location : Locations.Location_Ptr; Loader : Loaders.Loader_Ptr); function Location (Loader : Loaders.Loader_Ptr; Path : String) return Locations.Location_Ptr; -- Return the first location, that match with the given loader, -- containing the file identified by the given path -- -- If none of the locations contain a file identified by the -- given path, the exception Locations.Name_Error is raised. private Pairs : Pair_Vectors.Vector; end Resource_Locations; protected body Resource_Locations is procedure Add (Location : Locations.Location_Ptr; Loader : Loaders.Loader_Ptr) is Element : constant Pair := (Location => Location, Loader => Loader); begin -- Check that the same combination of location and loader isn't -- added multiple times if (for some Pair of Pairs => Pair = Element) then raise Constraint_Error with "Location already added for the given loader"; end if; Pairs.Append (Element); end Add; function Location (Loader : Loaders.Loader_Ptr; Path : String) return Locations.Location_Ptr is File_Not_Found : Boolean := False; begin for Pair of Pairs loop if Loader = Pair.Loader then if Pair.Location.Exists (Path) then return Pair.Location; else File_Not_Found := True; end if; end if; end loop; if File_Not_Found then raise Locations.Name_Error with "Path '" & Path & "' not found"; end if; -- No locations have been added for the given loader raise Constraint_Error with "No locations added for the given loader"; end Location; end Resource_Locations; ----------------------------------------------------------------------------- type Read_Request is record Path : SU.Unbounded_String; Future : Futures.Pointers.Mutable_Pointer; Time : Ada.Real_Time.Time; end record; Null_Request : constant Read_Request := (others => <>); package Buffers is new Orka.Containers.Ring_Buffers (Read_Request); protected Queue is entry Enqueue (Element : Read_Request); entry Dequeue (Element : out Read_Request; Stop : out Boolean); procedure Shutdown; private Requests : Buffers.Buffer (Maximum_Requests); Should_Stop : Boolean := False; end Queue; protected body Queue is entry Enqueue (Element : Read_Request) when not Requests.Is_Full is begin Requests.Add_Last (Element); end Enqueue; entry Dequeue (Element : out Read_Request; Stop : out Boolean) when Should_Stop or else not Requests.Is_Empty is begin Stop := Should_Stop; if Should_Stop then return; end if; Element := Requests.Remove_First; end Dequeue; procedure Shutdown is begin Should_Stop := True; end Shutdown; end Queue; ----------------------------------------------------------------------------- procedure Add_Location (Location : Locations.Location_Ptr; Loader : Loaders.Loader_Ptr) is begin Resource_Locations.Add (Location, Loader); Resource_Loaders.Include (Loader); end Add_Location; function Load (Path : String) return Futures.Pointers.Mutable_Pointer is Slot : Futures.Future_Access; begin if not Resource_Loaders.Has_Loader (Path) then raise Resource_Load_Error with "No registered loader for " & Path; end if; Queues.Slots.Manager.Acquire (Slot); declare Pointer : Futures.Pointers.Mutable_Pointer; begin Pointer.Set (Slot); Queue.Enqueue ((Path => SU.To_Unbounded_String (Path), Future => Pointer, Time => Ada.Real_Time.Clock)); return Pointer; -- Return Pointer instead of Pointer.Get to prevent -- adjust/finalize raising a Storage_Error end; end Load; procedure Shutdown is begin Queue.Shutdown; end Shutdown; task body Loader is Name : String renames Task_Name; Request : Read_Request; Stop : Boolean := False; begin Orka.OS.Set_Task_Name (Name); loop Queue.Dequeue (Request, Stop); exit when Stop; declare Future : Futures.Pointers.Reference renames Request.Future.Get; Promise : Futures.Promise'Class renames Futures.Promise'Class (Future.Value.all); begin Promise.Set_Status (Futures.Running); declare Path : constant String := SU.To_String (Request.Path); Loader : Loaders.Loader_Ptr renames Resource_Loaders.Loader (Path); use Ada.Real_Time; Time_Start : constant Time := Clock; Location : constant Locations.Location_Ptr := Resource_Locations.Location (Loader, Path); Bytes : constant Byte_Array_Pointers.Pointer := Location.Read_Data (Path); Time_End : constant Time := Clock; Reading_Time : constant Time_Span := Time_End - Time_Start; procedure Enqueue (Element : Jobs.Job_Ptr) is begin Job_Queue.Enqueue (Element, Request.Future); end Enqueue; begin Loader.Load ((Bytes, Reading_Time, Request.Time, Request.Path), Enqueue'Access, Location); end; exception when Error : others => Ada.Text_IO.Put_Line (Name & ": " & Ada.Exceptions.Exception_Information (Error)); Promise.Set_Failed (Error); end; -- Finalize the smart pointer (Request.Future) to reduce the -- number of references to the Future object Request := Null_Request; end loop; exception when Error : others => Ada.Text_IO.Put_Line (Name & ": " & Ada.Exceptions.Exception_Information (Error)); end Loader; end Orka.Resources.Loader;
reznikmm/matreshka
Ada
3,769
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016, 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 UI.Actions; with UI.Widgets.Windows; with UI.Events.Mouse.Click; package Demo_Actions is type Demo_Action is new UI.Actions.Action with record Window : UI.Widgets.Windows.Window_Access; end record; type Demo_Action_Access is access all Demo_Action; overriding procedure Triggered_Event (Self : in out Demo_Action; Event : in out UI.Events.Mouse.Click.Click_Event'Class); end Demo_Actions;
reznikmm/matreshka
Ada
3,649
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.Db_Queries_Elements is pragma Preelaborate; type ODF_Db_Queries is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Db_Queries_Access is access all ODF_Db_Queries'Class with Storage_Size => 0; end ODF.DOM.Db_Queries_Elements;
Fabien-Chouteau/coffee-clock
Ada
3,546
adb
------------------------------------------------------------------------------- -- -- -- Coffee Clock -- -- -- -- Copyright (C) 2016-2017 Fabien Chouteau -- -- -- -- Coffee Clock 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. -- -- -- -- Coffee Clock 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 We Noise Maker. If not, see <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------- with Ada.Synchronous_Task_Control; with Real_Time_Clock; with HAL.Real_Time_Clock; use HAL.Real_Time_Clock; with Ada.Real_Time; use Ada.Real_Time; package body Alarm_Handling is procedure Do_Nothing; Sync : Ada.Synchronous_Task_Control.Suspension_Object; Alarm_Time : RTC_Time; Action : Alarm_Action := Do_Nothing'Access; ---------------- -- Do_Nothing -- ---------------- procedure Do_Nothing is null; task Touch_Screen is end Touch_Screen; task body Touch_Screen is Now : HAL.Real_Time_Clock.RTC_Time; Trigger_Time : Time; begin Ada.Synchronous_Task_Control.Suspend_Until_True (Sync); loop Now := Real_Time_Clock.Get_Time; if Now.Hour = Alarm_Time.Hour and then Now.Min = Alarm_Time.Min then -- Trigger alarm Trigger_Time := Clock; -- Call the action procedure Action.all; -- Sleep for at least two minutes to make sure we don't trigger -- the alarm twice. delay until Trigger_Time + Minutes (2); end if; delay until Clock + Milliseconds (500); end loop; end Touch_Screen; ----------- -- Start -- ----------- procedure Start is begin Ada.Synchronous_Task_Control.Set_True (Sync); end Start; ---------------------- -- Set_Alarm_Action -- ---------------------- procedure Set_Alarm_Action (Action : Alarm_Action) is begin Alarm_Handling.Action := Set_Alarm_Action.Action; end Set_Alarm_Action; -------------------- -- Set_Alarm_Time -- -------------------- procedure Set_Alarm_Time (Time : HAL.Real_Time_Clock.RTC_Time) is begin Alarm_Time := Time; end Set_Alarm_Time; -------------------- -- Get_Alarm_Time -- -------------------- function Get_Alarm_Time return HAL.Real_Time_Clock.RTC_Time is (Alarm_Time); end Alarm_Handling;
onox/orka
Ada
1,686
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2022 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Orka.SIMD.SSE2.Doubles; private with Orka.SIMD.SSE2.Integers.Random; package Orka.SIMD.SSE2.Longs.Random with SPARK_Mode => On is pragma Pure; use SIMD.SSE2.Doubles; type State is limited private; pragma Preelaborable_Initialization (State); procedure Next (S : in out State; Value : out m128l) with Inline_Always, Global => null, Depends => ((S, Value) => S); -- Use and modify the given state to generate multiple -- random unsigned integers procedure Next (S : in out State; Value : out m128d) with Inline_Always, Global => null, Depends => ((S, Value) => S); -- Use and modify the given state to generate multiple random -- floating-point numbers in the interval [0, 1). procedure Reset (S : out State; Seed : Duration) with Global => null, Depends => (S => Seed), Pre => Seed /= 0.0; private type State is new Orka.SIMD.SSE2.Integers.Random.State; end Orka.SIMD.SSE2.Longs.Random;
persan/A-gst
Ada
5,101
ads
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h; with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h; with System; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h; with glib; with glib.Values; with System; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_riff_riff_read_h is -- GStreamer RIFF I/O -- * Copyright (C) 2003 Ronald Bultje <[email protected]> -- * -- * riff-read.h: function declarations for parsing a RIFF file -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Library 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 -- * Library General Public License for more details. -- * -- * You should have received a copy of the GNU Library 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. -- -- * Operate using pull_range(). -- function gst_riff_read_chunk (element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; offset : access GLIB.guint64; tag : access GLIB.guint32; chunk_data : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/riff/riff-read.h:36 pragma Import (C, gst_riff_read_chunk, "gst_riff_read_chunk"); -- * These functions operate on provided data (the caller is -- * supposed to strip the chunk headers). The buffer is -- * provided by the caller, the strf/strh/data are filled in -- * by the function. -- function gst_riff_parse_chunk (element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; offset : access GLIB.guint; fourcc : access GLIB.guint32; chunk_data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:49 pragma Import (C, gst_riff_parse_chunk, "gst_riff_parse_chunk"); function gst_riff_parse_file_header (element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; doctype : access GLIB.guint32) return GLIB.gboolean; -- gst/riff/riff-read.h:55 pragma Import (C, gst_riff_parse_file_header, "gst_riff_parse_file_header"); function gst_riff_parse_strh (element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; strh : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:59 pragma Import (C, gst_riff_parse_strh, "gst_riff_parse_strh"); function gst_riff_parse_strf_vids (element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; strf : System.Address; data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:63 pragma Import (C, gst_riff_parse_strf_vids, "gst_riff_parse_strf_vids"); function gst_riff_parse_strf_auds (element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; strf : System.Address; data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:67 pragma Import (C, gst_riff_parse_strf_auds, "gst_riff_parse_strf_auds"); function gst_riff_parse_strf_iavs (element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; strf : System.Address; data : System.Address) return GLIB.gboolean; -- gst/riff/riff-read.h:71 pragma Import (C, gst_riff_parse_strf_iavs, "gst_riff_parse_strf_iavs"); procedure gst_riff_parse_info (element : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; taglist : System.Address); -- gst/riff/riff-read.h:76 pragma Import (C, gst_riff_parse_info, "gst_riff_parse_info"); -- * Init. -- procedure gst_riff_init; -- gst/riff/riff-read.h:83 pragma Import (C, gst_riff_init, "gst_riff_init"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_riff_riff_read_h;
Lucretia/Cherry
Ada
1,641
adb
-- -- The author disclaims copyright to this source code. In place of -- a legal notice, here is a blessing: -- -- May you do good and not evil. -- May you find forgiveness for yourself and forgive others. -- May you share freely, not taking more than you give. -- with Ada.Strings.Unbounded; package body Report_Parsers is use Ada.Strings.Unbounded; type Context_Record is record ARG : Unbounded_String; CTX : Unbounded_String; end record; Global_Parser_Context : aliased Context_Record; function Is_Alnum (C : Character) return Boolean; -- function Get_Context return Context_Access is begin return Global_Parser_Context'Access; end Get_Context; function Get_ARG (Parser : in Context_Access) return String is begin return To_String (Parser.ARG); end Get_ARG; function Get_CTX (Parser : in Context_Access) return String is begin return To_String (Parser.CTX); end Get_CTX; procedure Trim_Right_Symbol (Item : in String; Pos : out Natural) is S : String renames Item; begin Pos := S'Last; -- Skip spaces while Pos >= 1 and S (Pos - 1) = ' ' loop Pos := Pos - 1; end loop; while Pos >= 1 and (Is_Alnum (S (Pos - 1)) or S (Pos - 1) = '_') loop Pos := Pos - 1; end loop; end Trim_Right_Symbol; function Is_Alnum (C : Character) return Boolean is begin return (C in 'a' .. 'z' or C in 'A' .. 'Z' or C in '0' .. '9'); end Is_Alnum; end Report_Parsers;
MinimSecure/unum-sdk
Ada
836
adb
-- Copyright 2012-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package body Pck is procedure Increment (I : in out Integer) is begin I := I + 1; end Increment; end Pck;
reznikmm/matreshka
Ada
10,608
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.String_Vectors; with Asis.Declarations; with Asis.Definitions; with Asis.Elements; with Asis.Expressions; with Properties.Tools; with Properties.Expressions.Identifiers; package body Properties.Expressions.Record_Aggregate is ---------- -- Code -- ---------- function Code (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String is use type League.Strings.Universal_String; use type Asis.Declaration_List; procedure Append (Names : League.Strings.Universal_String; Code : League.Strings.Universal_String); procedure Mark_Done (Name : League.Strings.Universal_String); function Get_Name (Index : Positive) return League.Strings.Universal_String; function Get_Type_Name return League.Strings.Universal_String; Tipe : constant Asis.Element := Asis.Expressions.Corresponding_Expression_Type_Definition (Element); Parts : constant Asis.Declaration_List := Tools.Corresponding_Type_Discriminants (Tipe) & Tools.Corresponding_Type_Components (Tipe); Done : array (Parts'Range) of Boolean := (others => False); Last : Natural := 0; Result : League.Strings.Universal_String; ------------ -- Append -- ------------ procedure Append (Names : League.Strings.Universal_String; Code : League.Strings.Universal_String) is Text : League.Strings.Universal_String; List : constant League.String_Vectors.Universal_String_Vector := Names.Split (','); begin if List.Length = 0 then -- positional association Last := Last + 1; Done (Last) := True; Text := Get_Name (Last); Result.Append (Text); Result.Append (":"); Result.Append (Code); else for J in 1 .. List.Length loop Mark_Done (List.Element (J)); Result.Append (List.Element (J)); Result.Append (":"); Result.Append (Code); end loop; end if; end Append; -------------- -- Get_Name -- -------------- function Get_Name (Index : Positive) return League.Strings.Universal_String is Names : constant Asis.Defining_Name_List := Asis.Declarations.Names (Parts (Index)); begin pragma Assert (Names'Length = 1); return Engine.Text.Get_Property (Names (Names'First), Code.Name); end Get_Name; ------------------- -- Get_Type_Name -- ------------------- function Get_Type_Name return League.Strings.Universal_String is use type Asis.Definition_Kinds; use type Asis.Expression_Kinds; Result : League.Strings.Universal_String; Name : League.Strings.Universal_String; X : Asis.Element := Tipe; Decl : Asis.Declaration; begin -- Unwind all subtype declarations while Asis.Elements.Definition_Kind (X) = Asis.A_Subtype_Indication loop X := Asis.Definitions.Subtype_Mark (X); if Asis.Elements.Expression_Kind (X) = Asis.A_Selected_Component then X := Asis.Expressions.Selector (X); end if; X := Asis.Expressions.Corresponding_Name_Declaration (X); X := Asis.Declarations.Type_Declaration_View (X); end loop; if Asis.Elements.Definition_Kind (X) = Asis.A_Type_Definition then Decl := Asis.Elements.Enclosing_Element (X); Result := Properties.Expressions.Identifiers.Name_Prefix (Engine => Engine, Name => Element, Decl => Asis.Elements.Enclosing_Element (X)); Name := Engine.Text.Get_Property (Asis.Declarations.Names (Decl) (1), Code.Name); Result.Append (Name); end if; return Result; end Get_Type_Name; --------------- -- Mark_Done -- --------------- procedure Mark_Done (Name : League.Strings.Universal_String) is Text : League.Strings.Universal_String; begin for J in Parts'Range loop if not Done (J) then Text := Get_Name (J); if Text = Name then Done (J) := True; return; end if; end if; end loop; end Mark_Done; Names : League.Strings.Universal_String; Text : League.Strings.Universal_String; List : constant Asis.Association_List := Asis.Expressions.Record_Component_Associations (Element); Tipe_Name : constant League.Strings.Universal_String := Get_Type_Name; begin if not Tipe_Name.Is_Empty then Result.Append (Tipe_Name); Result.Append ("._cast("); end if; Result.Append ("{"); for J in List'Range loop Names := Engine.Text.Get_Property (List (J), Engines.Associations); if Names /= League.Strings.To_Universal_String ("others") then Text := Engine.Text.Get_Property (List (J), Name); if not Text.Is_Empty then -- Box <> expression returns empty Code. We ignore such assoc. if J /= List'First then Result.Append (","); end if; Append (Names, Text); end if; end if; end loop; for J in Parts'Range loop if not Done (J) then Text := Get_Name (J); Result.Append (","); Result.Append (Text); Result.Append (":"); Text := Engine.Text.Get_Property (Parts (J), Engines.Initialize); Result.Append (Text); end if; end loop; Result.Append ("}"); if not Tipe_Name.Is_Empty then Result.Append (")"); end if; return Result; end Code; ---------------------------- -- Typed_Array_Initialize -- ---------------------------- function Typed_Array_Initialize (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String is Result : League.Strings.Universal_String; Down : League.Strings.Universal_String; Item : Asis.Expression; List : constant Asis.Association_List := Asis.Expressions.Record_Component_Associations (Element); begin Result.Append ("_result._TA_allign(4);"); for J in List'Range loop pragma Assert (Asis.Expressions.Record_Component_Choices (List (J))'Length = 0, "Named associations in Typed_Array aggregate" & " are not supported"); Item := Asis.Expressions.Component_Expression (List (J)); Down := Engine.Text.Get_Property (Item, Name); Result.Append (Down); end loop; return Result; end Typed_Array_Initialize; end Properties.Expressions.Record_Aggregate;
tum-ei-rcs/StratoX
Ada
6,482
ads
-- -- Copyright (C) 2016, AdaCore -- -- This spec has been automatically generated from STM32F429x.svd pragma Ada_2012; with Interfaces.Bit_Types; with System; package Interfaces.STM32.SYSCFG is pragma Preelaborate; pragma No_Elaboration_Code_All; --------------- -- Registers -- --------------- -------------------- -- MEMRM_Register -- -------------------- subtype MEMRM_MEM_MODE_Field is Interfaces.Bit_Types.UInt3; subtype MEMRM_FB_MODE_Field is Interfaces.Bit_Types.Bit; subtype MEMRM_SWP_FMC_Field is Interfaces.Bit_Types.UInt2; -- memory remap register type MEMRM_Register is record -- Memory mapping selection MEM_MODE : MEMRM_MEM_MODE_Field := 16#0#; -- unspecified Reserved_3_7 : Interfaces.Bit_Types.UInt5 := 16#0#; -- Flash bank mode selection FB_MODE : MEMRM_FB_MODE_Field := 16#0#; -- unspecified Reserved_9_9 : Interfaces.Bit_Types.Bit := 16#0#; -- FMC memory mapping swap SWP_FMC : MEMRM_SWP_FMC_Field := 16#0#; -- unspecified Reserved_12_31 : Interfaces.Bit_Types.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MEMRM_Register use record MEM_MODE at 0 range 0 .. 2; Reserved_3_7 at 0 range 3 .. 7; FB_MODE at 0 range 8 .. 8; Reserved_9_9 at 0 range 9 .. 9; SWP_FMC at 0 range 10 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------ -- PMC_Register -- ------------------ subtype PMC_ADC1DC2_Field is Interfaces.Bit_Types.Bit; subtype PMC_ADC2DC2_Field is Interfaces.Bit_Types.Bit; subtype PMC_ADC3DC2_Field is Interfaces.Bit_Types.Bit; subtype PMC_MII_RMII_SEL_Field is Interfaces.Bit_Types.Bit; -- peripheral mode configuration register type PMC_Register is record -- unspecified Reserved_0_15 : Interfaces.Bit_Types.Short := 16#0#; -- ADC1DC2 ADC1DC2 : PMC_ADC1DC2_Field := 16#0#; -- ADC2DC2 ADC2DC2 : PMC_ADC2DC2_Field := 16#0#; -- ADC3DC2 ADC3DC2 : PMC_ADC3DC2_Field := 16#0#; -- unspecified Reserved_19_22 : Interfaces.Bit_Types.UInt4 := 16#0#; -- Ethernet PHY interface selection MII_RMII_SEL : PMC_MII_RMII_SEL_Field := 16#0#; -- unspecified Reserved_24_31 : Interfaces.Bit_Types.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PMC_Register use record Reserved_0_15 at 0 range 0 .. 15; ADC1DC2 at 0 range 16 .. 16; ADC2DC2 at 0 range 17 .. 17; ADC3DC2 at 0 range 18 .. 18; Reserved_19_22 at 0 range 19 .. 22; MII_RMII_SEL at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; --------------------- -- EXTICR_Register -- --------------------- ------------------ -- EXTICR1.EXTI -- ------------------ -- EXTICR1_EXTI array element subtype EXTICR1_EXTI_Element is Interfaces.Bit_Types.UInt4; -- EXTICR1_EXTI array type EXTICR1_EXTI_Field_Array is array (0 .. 3) of EXTICR1_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR1_EXTI type EXTICR1_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : Interfaces.Bit_Types.Short; when True => -- EXTI as an array Arr : EXTICR1_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR1_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 1 type EXTICR_Register is record -- EXTI x configuration (x = 0 to 3) EXTI : EXTICR1_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : Interfaces.Bit_Types.Short := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EXTICR_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -------------------- -- CMPCR_Register -- -------------------- subtype CMPCR_CMP_PD_Field is Interfaces.Bit_Types.Bit; subtype CMPCR_READY_Field is Interfaces.Bit_Types.Bit; -- Compensation cell control register type CMPCR_Register is record -- Read-only. Compensation cell power-down CMP_PD : CMPCR_CMP_PD_Field := 16#0#; -- unspecified Reserved_1_7 : Interfaces.Bit_Types.UInt7; -- Read-only. READY READY : CMPCR_READY_Field := 16#0#; -- unspecified Reserved_9_31 : Interfaces.Bit_Types.UInt23; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CMPCR_Register use record CMP_PD at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; READY at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- System configuration controller type SYSCFG_Peripheral is record -- memory remap register MEMRM : MEMRM_Register; -- peripheral mode configuration register PMC : PMC_Register; -- external interrupt configuration register 1 EXTICR1 : EXTICR_Register; -- external interrupt configuration register 2 EXTICR2 : EXTICR_Register; -- external interrupt configuration register 3 EXTICR3 : EXTICR_Register; -- external interrupt configuration register 4 EXTICR4 : EXTICR_Register; -- Compensation cell control register CMPCR : CMPCR_Register; end record with Volatile; for SYSCFG_Peripheral use record MEMRM at 0 range 0 .. 31; PMC at 4 range 0 .. 31; EXTICR1 at 8 range 0 .. 31; EXTICR2 at 12 range 0 .. 31; EXTICR3 at 16 range 0 .. 31; EXTICR4 at 20 range 0 .. 31; CMPCR at 32 range 0 .. 31; end record; -- System configuration controller SYSCFG_Periph : aliased SYSCFG_Peripheral with Import, Address => SYSCFG_Base; end Interfaces.STM32.SYSCFG;
reznikmm/matreshka
Ada
7,051
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_Elements; with AMF.UML.Clauses.Collections; with AMF.UML.Executable_Nodes.Collections; with AMF.UML.Output_Pins.Collections; with AMF.Visitors; package AMF.Internals.UML_Clauses is type UML_Clause_Proxy is limited new AMF.Internals.UML_Elements.UML_Element_Proxy and AMF.UML.Clauses.UML_Clause with null record; overriding function Get_Body (Self : not null access constant UML_Clause_Proxy) return AMF.UML.Executable_Nodes.Collections.Set_Of_UML_Executable_Node; -- Getter of Clause::body. -- -- A nested activity fragment that is executed if the test evaluates to -- true and the clause is chosen over any concurrent clauses that also -- evaluate to true. overriding function Get_Body_Output (Self : not null access constant UML_Clause_Proxy) return AMF.UML.Output_Pins.Collections.Ordered_Set_Of_UML_Output_Pin; -- Getter of Clause::bodyOutput. -- -- A list of output pins within the body fragment whose values are moved -- to the result pins of the containing conditional node after execution -- of the clause body. overriding function Get_Decider (Self : not null access constant UML_Clause_Proxy) return AMF.UML.Output_Pins.UML_Output_Pin_Access; -- Getter of Clause::decider. -- -- An output pin within the test fragment the value of which is examined -- after execution of the test to determine whether the body should be -- executed. overriding procedure Set_Decider (Self : not null access UML_Clause_Proxy; To : AMF.UML.Output_Pins.UML_Output_Pin_Access); -- Setter of Clause::decider. -- -- An output pin within the test fragment the value of which is examined -- after execution of the test to determine whether the body should be -- executed. overriding function Get_Predecessor_Clause (Self : not null access constant UML_Clause_Proxy) return AMF.UML.Clauses.Collections.Set_Of_UML_Clause; -- Getter of Clause::predecessorClause. -- -- A set of clauses whose tests must all evaluate false before the current -- clause can be tested. overriding function Get_Successor_Clause (Self : not null access constant UML_Clause_Proxy) return AMF.UML.Clauses.Collections.Set_Of_UML_Clause; -- Getter of Clause::successorClause. -- -- A set of clauses which may not be tested unless the current clause -- tests false. overriding function Get_Test (Self : not null access constant UML_Clause_Proxy) return AMF.UML.Executable_Nodes.Collections.Set_Of_UML_Executable_Node; -- Getter of Clause::test. -- -- A nested activity fragment with a designated output pin that specifies -- the result of the test. overriding procedure Enter_Element (Self : not null access constant UML_Clause_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_Clause_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_Clause_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_Clauses;
tum-ei-rcs/StratoX
Ada
44
ads
../../../../software/modules/sdlog-tools.ads
stcarrez/ada-awa
Ada
8,635
adb
----------------------------------------------------------------------- -- awa-images-tests -- Unit tests for images module -- Copyright (C) 2018, 2019, 2020, 2021, 2022, 2023 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; with Util.Test_Caller; with Util.Strings; with ADO; with Servlet.Requests.Mockup; with Servlet.Responses.Mockup; with ASF.Tests; with AWA.Tests.Helpers.Users; package body AWA.Images.Tests is use Ada.Strings.Unbounded; use ADO; package Caller is new Util.Test_Caller (Test, "Images.Beans"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Images.Beans.Create", Test_Create_Image'Access); Caller.Add_Test (Suite, "Test AWA.Images.Servlets (missing)", Test_Missing_Image'Access); end Add_Tests; -- ------------------------------ -- Get some access on the wiki as anonymous users. -- ------------------------------ procedure Verify_Anonymous (T : in out Test; Page : in String; Title : in String) is pragma Unreferenced (Page, Title); Request : Servlet.Requests.Mockup.Request; Reply : Servlet.Responses.Mockup.Response; begin ASF.Tests.Do_Get (Request, Reply, "/storages/images.html", "images-anonymous-list.html"); ASF.Tests.Assert_Contains (T, "List of pages", Reply, "Wiki list recent page is invalid"); end Verify_Anonymous; -- ------------------------------ -- Verify that the wiki lists contain the given page. -- ------------------------------ procedure Verify_List_Contains (T : in out Test; Name : in String) is pragma Unreferenced (Name); Request : Servlet.Requests.Mockup.Request; Reply : Servlet.Responses.Mockup.Response; begin ASF.Tests.Do_Get (Request, Reply, "/storages/documents.html", "storage-list.html"); ASF.Tests.Assert_Contains (T, "Documents of the workspace", Reply, "List of documents is invalid"); end Verify_List_Contains; -- ------------------------------ -- Test access to the blog as anonymous user. -- ------------------------------ procedure Test_Anonymous_Access (T : in out Test) is begin T.Verify_Anonymous ("", ""); end Test_Anonymous_Access; -- ------------------------------ -- Test creation of image by simulating web requests. -- ------------------------------ procedure Test_Create_Image (T : in out Test) is Request : Servlet.Requests.Mockup.Part_Request (1); Reply : Servlet.Responses.Mockup.Response; Content : Ada.Strings.Unbounded.Unbounded_String; Folder_Id : ADO.Identifier; Image_Id : ADO.Identifier; Path : constant String := Util.Tests.Get_Test_Path ("regtests/result/upload.jpg"); begin AWA.Tests.Helpers.Users.Login ("[email protected]", Request); ASF.Tests.Do_Get (Request, Reply, "/storages/forms/folder-create.html", "folder-create-form-get.html"); -- Create the folder. Request.Set_Parameter ("folder-name", "Image Folder Name"); Request.Set_Parameter ("storage-folder-create-button", "1"); ASF.Tests.Set_CSRF (Request, "storage-folder-create-form", "folder-create-form-get.html"); ASF.Tests.Do_Post (Request, Reply, "/storages/forms/folder-create.html", "folder-create-form.html"); T.Assert (Reply.Get_Status = Servlet.Responses.SC_OK, "Invalid response after folder creation"); Reply.Read_Content (Content); Folder_Id := AWA.Tests.Helpers.Extract_Identifier (To_String (Content), "#folder"); T.Assert (Folder_Id > 0, "Invalid folder id returned"); -- Check the list page. ASF.Tests.Do_Get (Request, Reply, "/storages/images.html", "image-list.html"); ASF.Tests.Assert_Contains (T, "Documents of the workspace", Reply, "List of documents is invalid (title)"); ASF.Tests.Assert_Contains (T, "Image Folder Name", Reply, "List of documents is invalid (content)"); -- Upload an image to the folder. if Ada.Directories.Exists (Path) then Ada.Directories.Delete_File (Path); end if; Ada.Directories.Copy_File (Source_Name => "regtests/files/images/Ada-Lovelace.jpg", Target_Name => Path, Form => "all"); ASF.Tests.Do_Get (Request, Reply, "/storages/forms/upload-form.html", "upload-image-form-get.html"); Request.Set_Parameter ("folder", ADO.Identifier'Image (Folder_Id)); Request.Set_Parameter ("id", "-1"); Request.Set_Parameter ("upload-button", "1"); Request.Set_Part (Position => 1, Name => "upload-file", Path => Path, Content_Type => "image/jpg"); ASF.Tests.Set_CSRF (Request, "uploadForm", "upload-image-form-get.html"); ASF.Tests.Do_Post (Request, Reply, "/storages/forms/upload-form.html", "upload-image-form.html"); T.Assert (Reply.Get_Status = Servlet.Responses.SC_OK, "Invalid response after image upload"); T.Assert_Equals ("application/json", Reply.Get_Content_Type, "Invalid response after upload"); Reply.Read_Content (Content); Image_Id := AWA.Tests.Helpers.Extract_Identifier (To_String (Content), "store"); T.Assert (Image_Id > 0, "Invalid image id returned after upload"); -- Look at the image content. ASF.Tests.Do_Get (Request, Reply, "/storages/images/" & Util.Strings.Image (Natural (Image_Id)) & "/view/upload.jpg", "image-file-data.jpg"); T.Assert (Reply.Get_Status = Servlet.Responses.SC_OK, "Invalid response after image get"); T.Assert_Equals ("image/jpg", Reply.Get_Content_Type, "Invalid response after upload"); -- Look at the image description page. ASF.Tests.Do_Get (Request, Reply, "/storages/image-info/" & Util.Strings.Image (Natural (Image_Id)), "image-file-info.html"); T.Assert (Reply.Get_Status = Servlet.Responses.SC_OK, "Invalid response for image-info page"); T.Assert_Equals ("text/html; charset=UTF-8", Reply.Get_Content_Type, "Invalid response for image-info"); ASF.Tests.Assert_Contains (T, "/storages/files/" & Util.Strings.Image (Natural (Image_Id)) & "/", Reply, "Image info page is invalid (missing link)"); end Test_Create_Image; -- ------------------------------ -- Test getting an image which does not exist. -- ------------------------------ procedure Test_Missing_Image (T : in out Test) is Request : Servlet.Requests.Mockup.Request; Reply : Servlet.Responses.Mockup.Response; begin ASF.Tests.Do_Get (Request, Reply, "/storages/images/12345345/view/missing.jpg", "image-file-missing.html"); ASF.Tests.Assert_Redirect (T, "/asfunit/auth/login.html", Reply, "Invalid redirection for protected page"); AWA.Tests.Helpers.Users.Login ("[email protected]", Request); ASF.Tests.Do_Get (Request, Reply, "/storages/images/12345345/view/missing.jpg", "image-file-missing.html"); T.Assert (Reply.Get_Status = Servlet.Responses.SC_NOT_FOUND, "Invalid response after image get"); end Test_Missing_Image; end AWA.Images.Tests;
apple-oss-distributions/old_ncurses
Ada
17,148
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno <[email protected]> 2000 -- Version Control -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with ncurses2.util; use ncurses2.util; with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Terminal_Interface.Curses.Forms; use Terminal_Interface.Curses.Forms; with Terminal_Interface.Curses.Forms.Field_User_Data; with Ada.Characters.Handling; with Ada.Strings; with Ada.Strings.Bounded; procedure ncurses2.demo_forms is package BS is new Ada.Strings.Bounded.Generic_Bounded_Length (80); type myptr is access Integer; -- The C version stores a pointer in the userptr and -- converts it into a long integer. -- The correct, but inconvenient way to do it is to use a -- pointer to long and keep the pointer constant. -- It just adds one memory piece to allocate and deallocate (not done here) package StringData is new Terminal_Interface.Curses.Forms.Field_User_Data (Integer, myptr); function edit_secure (me : Field; c_in : Key_Code) return Key_Code; function form_virtualize (f : Form; w : Window) return Key_Code; function my_form_driver (f : Form; c : Key_Code) return Boolean; function make_label (frow : Line_Position; fcol : Column_Position; label : String) return Field; function make_field (frow : Line_Position; fcol : Column_Position; rows : Line_Count; cols : Column_Count; secure : Boolean) return Field; procedure display_form (f : Form); procedure erase_form (f : Form); -- prints '*' instead of characters. -- Not that this keeps a bug from the C version: -- type in the psasword field then move off and back. -- the cursor is at position one, but -- this assumes it as at the end so text gets appended instead -- of overwtitting. function edit_secure (me : Field; c_in : Key_Code) return Key_Code is rows, frow : Line_Position; nrow : Natural; cols, fcol : Column_Position; nbuf : Buffer_Number; c : Key_Code := c_in; c2 : Character; use StringData; begin Info (me, rows, cols, frow, fcol, nrow, nbuf); -- TODO if result = Form_Ok and nbuf > 0 then -- C version checked the return value -- of Info, the Ada binding throws an exception I think. if nbuf > 0 then declare temp : BS.Bounded_String; temps : String (1 .. 10); -- TODO Get_Buffer povides no information on the field length? len : myptr; begin Get_Buffer (me, 1, Str => temps); -- strcpy(temp, field_buffer(me, 1)); Get_User_Data (me, len); temp := BS.To_Bounded_String (temps (1 .. len.all)); if c <= Key_Max then c2 := Code_To_Char (c); if Ada.Characters.Handling.Is_Graphic (c2) then BS.Append (temp, c2); len.all := len.all + 1; Set_Buffer (me, 1, BS.To_String (temp)); c := Character'Pos ('*'); else c := 0; end if; else case c is when REQ_BEG_FIELD | REQ_CLR_EOF | REQ_CLR_EOL | REQ_DEL_LINE | REQ_DEL_WORD | REQ_DOWN_CHAR | REQ_END_FIELD | REQ_INS_CHAR | REQ_INS_LINE | REQ_LEFT_CHAR | REQ_NEW_LINE | REQ_NEXT_WORD | REQ_PREV_WORD | REQ_RIGHT_CHAR | REQ_UP_CHAR => c := 0; -- we don't want to do inline editing when REQ_CLR_FIELD => if len.all /= 0 then temp := BS.To_Bounded_String (""); Set_Buffer (me, 1, BS.To_String (temp)); len.all := 0; end if; when REQ_DEL_CHAR | REQ_DEL_PREV => if len.all /= 0 then BS.Delete (temp, BS.Length (temp), BS.Length (temp)); Set_Buffer (me, 1, BS.To_String (temp)); len.all := len.all - 1; end if; when others => null; end case; end if; end; end if; return c; end edit_secure; mode : Key_Code := REQ_INS_MODE; function form_virtualize (f : Form; w : Window) return Key_Code is type lookup_t is record code : Key_Code; result : Key_Code; -- should be Form_Request_Code, but we need MAX_COMMAND + 1 end record; lookup : constant array (Positive range <>) of lookup_t := ( ( Character'Pos ('A') mod 16#20#, REQ_NEXT_CHOICE ), ( Character'Pos ('B') mod 16#20#, REQ_PREV_WORD ), ( Character'Pos ('C') mod 16#20#, REQ_CLR_EOL ), ( Character'Pos ('D') mod 16#20#, REQ_DOWN_FIELD ), ( Character'Pos ('E') mod 16#20#, REQ_END_FIELD ), ( Character'Pos ('F') mod 16#20#, REQ_NEXT_PAGE ), ( Character'Pos ('G') mod 16#20#, REQ_DEL_WORD ), ( Character'Pos ('H') mod 16#20#, REQ_DEL_PREV ), ( Character'Pos ('I') mod 16#20#, REQ_INS_CHAR ), ( Character'Pos ('K') mod 16#20#, REQ_CLR_EOF ), ( Character'Pos ('L') mod 16#20#, REQ_LEFT_FIELD ), ( Character'Pos ('M') mod 16#20#, REQ_NEW_LINE ), ( Character'Pos ('N') mod 16#20#, REQ_NEXT_FIELD ), ( Character'Pos ('O') mod 16#20#, REQ_INS_LINE ), ( Character'Pos ('P') mod 16#20#, REQ_PREV_FIELD ), ( Character'Pos ('R') mod 16#20#, REQ_RIGHT_FIELD ), ( Character'Pos ('S') mod 16#20#, REQ_BEG_FIELD ), ( Character'Pos ('U') mod 16#20#, REQ_UP_FIELD ), ( Character'Pos ('V') mod 16#20#, REQ_DEL_CHAR ), ( Character'Pos ('W') mod 16#20#, REQ_NEXT_WORD ), ( Character'Pos ('X') mod 16#20#, REQ_CLR_FIELD ), ( Character'Pos ('Y') mod 16#20#, REQ_DEL_LINE ), ( Character'Pos ('Z') mod 16#20#, REQ_PREV_CHOICE ), ( Character'Pos ('[') mod 16#20#, -- ESCAPE Form_Request_Code'Last + 1 ), ( Key_Backspace, REQ_DEL_PREV ), ( KEY_DOWN, REQ_DOWN_CHAR ), ( Key_End, REQ_LAST_FIELD ), ( Key_Home, REQ_FIRST_FIELD ), ( KEY_LEFT, REQ_LEFT_CHAR ), ( KEY_LL, REQ_LAST_FIELD ), ( Key_Next, REQ_NEXT_FIELD ), ( KEY_NPAGE, REQ_NEXT_PAGE ), ( KEY_PPAGE, REQ_PREV_PAGE ), ( Key_Previous, REQ_PREV_FIELD ), ( KEY_RIGHT, REQ_RIGHT_CHAR ), ( KEY_UP, REQ_UP_CHAR ), ( Character'Pos ('Q') mod 16#20#, -- QUIT Form_Request_Code'Last + 1 -- TODO MAX_FORM_COMMAND + 1 ) ); c : Key_Code := Getchar (w); me : Field := Current (f); begin if c = Character'Pos (']') mod 16#20# then if mode = REQ_INS_MODE then mode := REQ_OVL_MODE; else mode := REQ_INS_MODE; end if; c := mode; else for n in lookup'Range loop if lookup (n).code = c then c := lookup (n).result; exit; end if; end loop; end if; -- Force the field that the user is typing into to be in reverse video, -- while the other fields are shown underlined. if c <= Key_Max then c := edit_secure (me, c); Set_Background (me, (Reverse_Video => True, others => False)); elsif c <= Form_Request_Code'Last then c := edit_secure (me, c); Set_Background (me, (Under_Line => True, others => False)); end if; return c; end form_virtualize; function my_form_driver (f : Form; c : Key_Code) return Boolean is flag : Driver_Result := Driver (f, F_Validate_Field); begin if c = Form_Request_Code'Last + 1 and flag = Form_Ok then return True; else Beep; return False; end if; end my_form_driver; function make_label (frow : Line_Position; fcol : Column_Position; label : String) return Field is f : Field := Create (1, label'Length, frow, fcol, 0, 0); o : Field_Option_Set := Get_Options (f); begin if f /= Null_Field then Set_Buffer (f, 0, label); o.Active := False; Set_Options (f, o); end if; return f; end make_label; function make_field (frow : Line_Position; fcol : Column_Position; rows : Line_Count; cols : Column_Count; secure : Boolean) return Field is f : Field; use StringData; len : myptr; begin if secure then f := Create (rows, cols, frow, fcol, 0, 1); else f := Create (rows, cols, frow, fcol, 0, 0); end if; if f /= Null_Field then Set_Background (f, (Under_Line => True, others => False)); len := new Integer; len.all := 0; Set_User_Data (f, len); end if; return f; end make_field; procedure display_form (f : Form) is w : Window; rows : Line_Count; cols : Column_Count; begin Scale (f, rows, cols); w := New_Window (rows + 2, cols + 4, 0, 0); if w /= Null_Window then Set_Window (f, w); Set_Sub_Window (f, Derived_Window (w, rows, cols, 1, 2)); Box (w); -- 0,0 Set_KeyPad_Mode (w, True); end if; -- TODO if Post(f) /= Form_Ok then it's a procedure declare begin Post (f); exception when Eti_System_Error | Eti_Bad_Argument | Eti_Posted | Eti_Connected | Eti_Bad_State | Eti_No_Room | Eti_Not_Posted | Eti_Unknown_Command | Eti_No_Match | Eti_Not_Selectable | Eti_Not_Connected | Eti_Request_Denied | Eti_Invalid_Field | Eti_Current => Refresh (w); end; -- end if; end display_form; procedure erase_form (f : Form) is w : Window := Get_Window (f); s : Window := Get_Sub_Window (f); begin Post (f, False); Erase (w); Refresh (w); Delete (s); Delete (w); end erase_form; finished : Boolean := False; f : Field_Array_Access := new Field_Array (1 .. 12); secure : Field; myform : Form; w : Window; c : Key_Code; result : Driver_Result; begin Move_Cursor (Line => 18, Column => 0); Add (Str => "Defined form-traversal keys: ^Q/ESC- exit form"); Add (Ch => newl); Add (Str => "^N -- go to next field ^P -- go to previous field"); Add (Ch => newl); Add (Str => "Home -- go to first field End -- go to last field"); Add (Ch => newl); Add (Str => "^L -- go to field to left ^R -- go to field to right"); Add (Ch => newl); Add (Str => "^U -- move upward to field ^D -- move downward to field"); Add (Ch => newl); Add (Str => "^W -- go to next word ^B -- go to previous word"); Add (Ch => newl); Add (Str => "^S -- go to start of field ^E -- go to end of field"); Add (Ch => newl); Add (Str => "^H -- delete previous char ^Y -- delete line"); Add (Ch => newl); Add (Str => "^G -- delete current word ^C -- clear to end of line"); Add (Ch => newl); Add (Str => "^K -- clear to end of field ^X -- clear field"); Add (Ch => newl); Add (Str => "Arrow keys move within a field as you would expect."); Add (Line => 4, Column => 57, Str => "Forms Entry Test"); Refresh; -- describe the form f (1) := make_label (0, 15, "Sample Form"); f (2) := make_label (2, 0, "Last Name"); f (3) := make_field (3, 0, 1, 18, False); f (4) := make_label (2, 20, "First Name"); f (5) := make_field (3, 20, 1, 12, False); f (6) := make_label (2, 34, "Middle Name"); f (7) := make_field (3, 34, 1, 12, False); f (8) := make_label (5, 0, "Comments"); f (9) := make_field (6, 0, 4, 46, False); f (10) := make_label (5, 20, "Password:"); f (11) := make_field (5, 30, 1, 9, True); secure := f (11); f (12) := Null_Field; myform := New_Form (f); display_form (myform); w := Get_Window (myform); Set_Raw_Mode (SwitchOn => True); Set_NL_Mode (SwitchOn => True); -- lets us read ^M's while not finished loop c := form_virtualize (myform, w); result := Driver (myform, c); case result is when Form_Ok => Add (Line => 5, Column => 57, Str => Get_Buffer (secure, 1)); Clear_To_End_Of_Line; Refresh; when Unknown_Request => finished := my_form_driver (myform, c); when others => Beep; end case; end loop; erase_form (myform); -- TODO Free_Form(myform); -- for (c = 0; f[c] != 0; c++) free_field(f[c]); Set_Raw_Mode (SwitchOn => False); Set_NL_Mode (SwitchOn => True); end ncurses2.demo_forms;
docandrew/troodon
Ada
11,640
ads
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; limited with bits_struct_stat_h; with bits_types_h; limited with bits_types_struct_timespec_h; package sys_stat_h is -- unsupported macro: S_IFMT __S_IFMT -- unsupported macro: S_IFDIR __S_IFDIR -- unsupported macro: S_IFCHR __S_IFCHR -- unsupported macro: S_IFBLK __S_IFBLK -- unsupported macro: S_IFREG __S_IFREG -- unsupported macro: S_IFIFO __S_IFIFO -- unsupported macro: S_IFLNK __S_IFLNK -- unsupported macro: S_IFSOCK __S_IFSOCK -- arg-macro: procedure S_ISDIR (mode) -- __S_ISTYPE((mode), __S_IFDIR) -- arg-macro: procedure S_ISCHR (mode) -- __S_ISTYPE((mode), __S_IFCHR) -- arg-macro: procedure S_ISBLK (mode) -- __S_ISTYPE((mode), __S_IFBLK) -- arg-macro: procedure S_ISREG (mode) -- __S_ISTYPE((mode), __S_IFREG) -- arg-macro: procedure S_ISFIFO (mode) -- __S_ISTYPE((mode), __S_IFIFO) -- arg-macro: procedure S_ISLNK (mode) -- __S_ISTYPE((mode), __S_IFLNK) -- arg-macro: procedure S_ISSOCK (mode) -- __S_ISTYPE((mode), __S_IFSOCK) -- arg-macro: procedure S_TYPEISMQ (buf) -- __S_TYPEISMQ(buf) -- arg-macro: procedure S_TYPEISSEM (buf) -- __S_TYPEISSEM(buf) -- arg-macro: procedure S_TYPEISSHM (buf) -- __S_TYPEISSHM(buf) -- unsupported macro: S_ISUID __S_ISUID -- unsupported macro: S_ISGID __S_ISGID -- unsupported macro: S_ISVTX __S_ISVTX -- unsupported macro: S_IRUSR __S_IREAD -- unsupported macro: S_IWUSR __S_IWRITE -- unsupported macro: S_IXUSR __S_IEXEC -- unsupported macro: S_IRWXU (__S_IREAD|__S_IWRITE|__S_IEXEC) -- unsupported macro: S_IREAD S_IRUSR -- unsupported macro: S_IWRITE S_IWUSR -- unsupported macro: S_IEXEC S_IXUSR -- unsupported macro: S_IRGRP (S_IRUSR >> 3) -- unsupported macro: S_IWGRP (S_IWUSR >> 3) -- unsupported macro: S_IXGRP (S_IXUSR >> 3) -- unsupported macro: S_IRWXG (S_IRWXU >> 3) -- unsupported macro: S_IROTH (S_IRGRP >> 3) -- unsupported macro: S_IWOTH (S_IWGRP >> 3) -- unsupported macro: S_IXOTH (S_IXGRP >> 3) -- unsupported macro: S_IRWXO (S_IRWXG >> 3) -- unsupported macro: ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) -- unsupported macro: ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) -- unsupported macro: DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) S_BLKSIZE : constant := 512; -- /usr/include/sys/stat.h:199 -- Copyright (C) 1991-2021 Free Software Foundation, Inc. -- This file is part of the GNU C Library. -- The GNU C Library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- The GNU C Library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- You should have received a copy of the GNU Lesser General Public -- License along with the GNU C Library; if not, see -- <https://www.gnu.org/licenses/>. -- * POSIX Standard: 5.6 File Characteristics <sys/stat.h> -- -- For __mode_t and __dev_t. -- The Single Unix specification says that some more types are -- available here. -- Test macros for file types. -- These are from POSIX.1b. If the objects are not implemented using separate -- distinct file types, the macros always will evaluate to zero. Unlike the -- other S_* macros the following three take a pointer to a `struct stat' -- object as the argument. -- Protection bits. -- Save swapped text after use (sticky bit). This is pretty well obsolete. -- Read, write, and execute by owner. -- Read, write, and execute by group. -- Read, write, and execute by others. -- Macros for common mode bit masks. -- Get file attributes for FILE and put them in BUF. function stat (uu_file : Interfaces.C.Strings.chars_ptr; uu_buf : access bits_struct_stat_h.stat) return int -- /usr/include/sys/stat.h:205 with Import => True, Convention => C, External_Name => "stat"; -- Get file attributes for the file, device, pipe, or socket -- that file descriptor FD is open on and put them in BUF. function fstat (uu_fd : int; uu_buf : access bits_struct_stat_h.stat) return int -- /usr/include/sys/stat.h:210 with Import => True, Convention => C, External_Name => "fstat"; function stat64 (uu_file : Interfaces.C.Strings.chars_ptr; uu_buf : access bits_struct_stat_h.stat64) return int -- /usr/include/sys/stat.h:224 with Import => True, Convention => C, External_Name => "stat64"; function fstat64 (uu_fd : int; uu_buf : access bits_struct_stat_h.stat64) return int -- /usr/include/sys/stat.h:226 with Import => True, Convention => C, External_Name => "fstat64"; -- Similar to stat, get the attributes for FILE and put them in BUF. -- Relative path names are interpreted relative to FD unless FD is -- AT_FDCWD. function fstatat (uu_fd : int; uu_file : Interfaces.C.Strings.chars_ptr; uu_buf : access bits_struct_stat_h.stat; uu_flag : int) return int -- /usr/include/sys/stat.h:234 with Import => True, Convention => C, External_Name => "fstatat"; function fstatat64 (uu_fd : int; uu_file : Interfaces.C.Strings.chars_ptr; uu_buf : access bits_struct_stat_h.stat64; uu_flag : int) return int -- /usr/include/sys/stat.h:249 with Import => True, Convention => C, External_Name => "fstatat64"; -- Get file attributes about FILE and put them in BUF. -- If FILE is a symbolic link, do not follow it. function lstat (uu_file : Interfaces.C.Strings.chars_ptr; uu_buf : access bits_struct_stat_h.stat) return int -- /usr/include/sys/stat.h:259 with Import => True, Convention => C, External_Name => "lstat"; function lstat64 (uu_file : Interfaces.C.Strings.chars_ptr; uu_buf : access bits_struct_stat_h.stat64) return int -- /usr/include/sys/stat.h:272 with Import => True, Convention => C, External_Name => "lstat64"; -- Set file access permissions for FILE to MODE. -- If FILE is a symbolic link, this affects its target instead. function chmod (uu_file : Interfaces.C.Strings.chars_ptr; uu_mode : bits_types_h.uu_mode_t) return int -- /usr/include/sys/stat.h:280 with Import => True, Convention => C, External_Name => "chmod"; -- Set file access permissions for FILE to MODE. -- If FILE is a symbolic link, this affects the link itself -- rather than its target. function lchmod (uu_file : Interfaces.C.Strings.chars_ptr; uu_mode : bits_types_h.uu_mode_t) return int -- /usr/include/sys/stat.h:287 with Import => True, Convention => C, External_Name => "lchmod"; -- Set file access permissions of the file FD is open on to MODE. function fchmod (uu_fd : int; uu_mode : bits_types_h.uu_mode_t) return int -- /usr/include/sys/stat.h:293 with Import => True, Convention => C, External_Name => "fchmod"; -- Set file access permissions of FILE relative to -- the directory FD is open on. function fchmodat (uu_fd : int; uu_file : Interfaces.C.Strings.chars_ptr; uu_mode : bits_types_h.uu_mode_t; uu_flag : int) return int -- /usr/include/sys/stat.h:299 with Import => True, Convention => C, External_Name => "fchmodat"; -- Set the file creation mask of the current process to MASK, -- and return the old creation mask. function umask (uu_mask : bits_types_h.uu_mode_t) return bits_types_h.uu_mode_t -- /usr/include/sys/stat.h:308 with Import => True, Convention => C, External_Name => "umask"; -- Get the current `umask' value without changing it. -- This function is only available under the GNU Hurd. function getumask return bits_types_h.uu_mode_t -- /usr/include/sys/stat.h:313 with Import => True, Convention => C, External_Name => "getumask"; -- Create a new directory named PATH, with permission bits MODE. function mkdir (uu_path : Interfaces.C.Strings.chars_ptr; uu_mode : bits_types_h.uu_mode_t) return int -- /usr/include/sys/stat.h:317 with Import => True, Convention => C, External_Name => "mkdir"; -- Like mkdir, create a new directory with permission bits MODE. But -- interpret relative PATH names relative to the directory associated -- with FD. function mkdirat (uu_fd : int; uu_path : Interfaces.C.Strings.chars_ptr; uu_mode : bits_types_h.uu_mode_t) return int -- /usr/include/sys/stat.h:324 with Import => True, Convention => C, External_Name => "mkdirat"; -- Create a device file named PATH, with permission and special bits MODE -- and device number DEV (which can be constructed from major and minor -- device numbers with the `makedev' macro above). function mknod (uu_path : Interfaces.C.Strings.chars_ptr; uu_mode : bits_types_h.uu_mode_t; uu_dev : bits_types_h.uu_dev_t) return int -- /usr/include/sys/stat.h:332 with Import => True, Convention => C, External_Name => "mknod"; -- Like mknod, create a new device file with permission bits MODE and -- device number DEV. But interpret relative PATH names relative to -- the directory associated with FD. function mknodat (uu_fd : int; uu_path : Interfaces.C.Strings.chars_ptr; uu_mode : bits_types_h.uu_mode_t; uu_dev : bits_types_h.uu_dev_t) return int -- /usr/include/sys/stat.h:339 with Import => True, Convention => C, External_Name => "mknodat"; -- Create a new FIFO named PATH, with permission bits MODE. function mkfifo (uu_path : Interfaces.C.Strings.chars_ptr; uu_mode : bits_types_h.uu_mode_t) return int -- /usr/include/sys/stat.h:346 with Import => True, Convention => C, External_Name => "mkfifo"; -- Like mkfifo, create a new FIFO with permission bits MODE. But -- interpret relative PATH names relative to the directory associated -- with FD. function mkfifoat (uu_fd : int; uu_path : Interfaces.C.Strings.chars_ptr; uu_mode : bits_types_h.uu_mode_t) return int -- /usr/include/sys/stat.h:353 with Import => True, Convention => C, External_Name => "mkfifoat"; -- Set file access and modification times relative to directory file -- descriptor. function utimensat (uu_fd : int; uu_path : Interfaces.C.Strings.chars_ptr; uu_times : access constant bits_types_struct_timespec_h.timespec; uu_flags : int) return int -- /usr/include/sys/stat.h:360 with Import => True, Convention => C, External_Name => "utimensat"; -- Set file access and modification times of the file associated with FD. function futimens (uu_fd : int; uu_times : access constant bits_types_struct_timespec_h.timespec) return int -- /usr/include/sys/stat.h:368 with Import => True, Convention => C, External_Name => "futimens"; end sys_stat_h;
francesco-bongiovanni/ewok-kernel
Ada
65
ads
/opt/adacore-arm-eabi/arm-eabi/lib/gnat/zfp-stm32f4/gnat/gnat.ads
zhmu/ananas
Ada
5,963
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- ADA.STRINGS.WIDE_UNBOUNDED.WIDE_TEXT_IO -- -- -- -- B o d y -- -- -- -- Copyright (C) 1997-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Wide_Text_IO; use Ada.Wide_Text_IO; package body Ada.Strings.Wide_Unbounded.Wide_Text_IO is -------------- -- Get_Line -- -------------- function Get_Line return Unbounded_Wide_String is Buffer : Wide_String (1 .. 1000); Last : Natural; Str1 : Wide_String_Access; Str2 : Wide_String_Access; Result : Unbounded_Wide_String; begin Get_Line (Buffer, Last); Str1 := new Wide_String'(Buffer (1 .. Last)); while Last = Buffer'Last loop Get_Line (Buffer, Last); Str2 := new Wide_String (1 .. Str1'Last + Last); Str2 (Str1'Range) := Str1.all; Str2 (Str1'Last + 1 .. Str2'Last) := Buffer (1 .. Last); Free (Str1); Str1 := Str2; end loop; Result.Reference := Str1; Result.Last := Str1'Length; return Result; end Get_Line; function Get_Line (File : Ada.Wide_Text_IO.File_Type) return Unbounded_Wide_String is Buffer : Wide_String (1 .. 1000); Last : Natural; Str1 : Wide_String_Access; Str2 : Wide_String_Access; Result : Unbounded_Wide_String; begin Get_Line (File, Buffer, Last); Str1 := new Wide_String'(Buffer (1 .. Last)); while Last = Buffer'Last loop Get_Line (File, Buffer, Last); Str2 := new Wide_String (1 .. Str1'Last + Last); Str2 (Str1'Range) := Str1.all; Str2 (Str1'Last + 1 .. Str2'Last) := Buffer (1 .. Last); Free (Str1); Str1 := Str2; end loop; Result.Reference := Str1; Result.Last := Str1'Length; return Result; end Get_Line; procedure Get_Line (Item : out Unbounded_Wide_String) is begin Get_Line (Current_Input, Item); end Get_Line; procedure Get_Line (File : Ada.Wide_Text_IO.File_Type; Item : out Unbounded_Wide_String) is begin -- We are going to read into the string that is already there and -- allocated. Hopefully it is big enough now, if not, we will extend -- it in the usual manner using Realloc_For_Chunk. -- Make sure we start with at least 80 characters if Item.Reference'Last < 80 then Realloc_For_Chunk (Item, 80); end if; -- Loop to read data, filling current string as far as possible. -- Item.Last holds the number of characters read so far. Item.Last := 0; loop Get_Line (File, Item.Reference (Item.Last + 1 .. Item.Reference'Last), Item.Last); -- If we hit the end of the line before the end of the buffer, then -- we are all done, and the result length is properly set. if Item.Last < Item.Reference'Last then return; end if; -- If not enough room, double it and keep reading Realloc_For_Chunk (Item, Item.Last); end loop; end Get_Line; --------- -- Put -- --------- procedure Put (U : Unbounded_Wide_String) is begin Put (U.Reference (1 .. U.Last)); end Put; procedure Put (File : File_Type; U : Unbounded_Wide_String) is begin Put (File, U.Reference (1 .. U.Last)); end Put; -------------- -- Put_Line -- -------------- procedure Put_Line (U : Unbounded_Wide_String) is begin Put_Line (U.Reference (1 .. U.Last)); end Put_Line; procedure Put_Line (File : File_Type; U : Unbounded_Wide_String) is begin Put_Line (File, U.Reference (1 .. U.Last)); end Put_Line; end Ada.Strings.Wide_Unbounded.Wide_Text_IO;
twdroeger/ada-awa
Ada
57,936
adb
----------------------------------------------------------------------- -- AWA.OAuth.Models -- AWA.OAuth.Models ----------------------------------------------------------------------- -- File generated by ada-gen DO NOT MODIFY -- Template used: templates/model/package-body.xhtml -- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095 ----------------------------------------------------------------------- -- Copyright (C) 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Unchecked_Deallocation; with Util.Beans.Objects.Time; package body AWA.OAuth.Models is use type ADO.Objects.Object_Record_Access; use type ADO.Objects.Object_Ref; pragma Warnings (Off, "formal parameter * is not referenced"); function Application_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => APPLICATION_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Application_Key; function Application_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => APPLICATION_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Application_Key; function "=" (Left, Right : Application_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Application_Ref'Class; Impl : out Application_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Application_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Application_Ref) is Impl : Application_Access; begin Impl := new Application_Impl; Impl.Version := 0; Impl.Create_Date := ADO.DEFAULT_TIME; Impl.Update_Date := ADO.DEFAULT_TIME; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Application -- ---------------------------------------- procedure Set_Id (Object : in out Application_Ref; Value : in ADO.Identifier) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Application_Ref) return ADO.Identifier is Impl : constant Application_Access := Application_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Name (Object : in out Application_Ref; Value : in String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Name, Value); end Set_Name; procedure Set_Name (Object : in out Application_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Name, Value); end Set_Name; function Get_Name (Object : in Application_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Name); end Get_Name; function Get_Name (Object : in Application_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Application_Access := Application_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Name; end Get_Name; procedure Set_Secret_Key (Object : in out Application_Ref; Value : in String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Secret_Key, Value); end Set_Secret_Key; procedure Set_Secret_Key (Object : in out Application_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Secret_Key, Value); end Set_Secret_Key; function Get_Secret_Key (Object : in Application_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Secret_Key); end Get_Secret_Key; function Get_Secret_Key (Object : in Application_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Application_Access := Application_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Secret_Key; end Get_Secret_Key; procedure Set_Client_Id (Object : in out Application_Ref; Value : in String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 4, Impl.Client_Id, Value); end Set_Client_Id; procedure Set_Client_Id (Object : in out Application_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 4, Impl.Client_Id, Value); end Set_Client_Id; function Get_Client_Id (Object : in Application_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Client_Id); end Get_Client_Id; function Get_Client_Id (Object : in Application_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Application_Access := Application_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Client_Id; end Get_Client_Id; function Get_Version (Object : in Application_Ref) return Integer is Impl : constant Application_Access := Application_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Version; end Get_Version; procedure Set_Create_Date (Object : in out Application_Ref; Value : in Ada.Calendar.Time) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Time (Impl.all, 6, Impl.Create_Date, Value); end Set_Create_Date; function Get_Create_Date (Object : in Application_Ref) return Ada.Calendar.Time is Impl : constant Application_Access := Application_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Create_Date; end Get_Create_Date; procedure Set_Update_Date (Object : in out Application_Ref; Value : in Ada.Calendar.Time) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Time (Impl.all, 7, Impl.Update_Date, Value); end Set_Update_Date; function Get_Update_Date (Object : in Application_Ref) return Ada.Calendar.Time is Impl : constant Application_Access := Application_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Update_Date; end Get_Update_Date; procedure Set_Title (Object : in out Application_Ref; Value : in String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 8, Impl.Title, Value); end Set_Title; procedure Set_Title (Object : in out Application_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 8, Impl.Title, Value); end Set_Title; function Get_Title (Object : in Application_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Title); end Get_Title; function Get_Title (Object : in Application_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Application_Access := Application_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Title; end Get_Title; procedure Set_Description (Object : in out Application_Ref; Value : in String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 9, Impl.Description, Value); end Set_Description; procedure Set_Description (Object : in out Application_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 9, Impl.Description, Value); end Set_Description; function Get_Description (Object : in Application_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Description); end Get_Description; function Get_Description (Object : in Application_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Application_Access := Application_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Description; end Get_Description; procedure Set_App_Login_Url (Object : in out Application_Ref; Value : in String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 10, Impl.App_Login_Url, Value); end Set_App_Login_Url; procedure Set_App_Login_Url (Object : in out Application_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 10, Impl.App_Login_Url, Value); end Set_App_Login_Url; function Get_App_Login_Url (Object : in Application_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_App_Login_Url); end Get_App_Login_Url; function Get_App_Login_Url (Object : in Application_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Application_Access := Application_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.App_Login_Url; end Get_App_Login_Url; procedure Set_App_Logo_Url (Object : in out Application_Ref; Value : in String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 11, Impl.App_Logo_Url, Value); end Set_App_Logo_Url; procedure Set_App_Logo_Url (Object : in out Application_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 11, Impl.App_Logo_Url, Value); end Set_App_Logo_Url; function Get_App_Logo_Url (Object : in Application_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_App_Logo_Url); end Get_App_Logo_Url; function Get_App_Logo_Url (Object : in Application_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Application_Access := Application_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.App_Logo_Url; end Get_App_Logo_Url; procedure Set_User (Object : in out Application_Ref; Value : in AWA.Users.Models.User_Ref'Class) is Impl : Application_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 12, Impl.User, Value); end Set_User; function Get_User (Object : in Application_Ref) return AWA.Users.Models.User_Ref'Class is Impl : constant Application_Access := Application_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.User; end Get_User; -- Copy of the object. procedure Copy (Object : in Application_Ref; Into : in out Application_Ref) is Result : Application_Ref; begin if not Object.Is_Null then declare Impl : constant Application_Access := Application_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Application_Access := new Application_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Name := Impl.Name; Copy.Secret_Key := Impl.Secret_Key; Copy.Client_Id := Impl.Client_Id; Copy.Version := Impl.Version; Copy.Create_Date := Impl.Create_Date; Copy.Update_Date := Impl.Update_Date; Copy.Title := Impl.Title; Copy.Description := Impl.Description; Copy.App_Login_Url := Impl.App_Login_Url; Copy.App_Logo_Url := Impl.App_Logo_Url; Copy.User := Impl.User; end; end if; Into := Result; end Copy; procedure Find (Object : in out Application_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Application_Access := new Application_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Application_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Application_Access := new Application_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Application_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Application_Access := new Application_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Application_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Application_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Application_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Application_Impl) is type Application_Impl_Ptr is access all Application_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Application_Impl, Application_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Application_Impl_Ptr := Application_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Application_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, APPLICATION_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Application_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Application_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (APPLICATION_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_1_NAME, -- name Value => Object.Name); Object.Clear_Modified (2); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_1_NAME, -- secret_key Value => Object.Secret_Key); Object.Clear_Modified (3); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_1_NAME, -- client_id Value => Object.Client_Id); Object.Clear_Modified (4); end if; if Object.Is_Modified (6) then Stmt.Save_Field (Name => COL_5_1_NAME, -- create_date Value => Object.Create_Date); Object.Clear_Modified (6); end if; if Object.Is_Modified (7) then Stmt.Save_Field (Name => COL_6_1_NAME, -- update_date Value => Object.Update_Date); Object.Clear_Modified (7); end if; if Object.Is_Modified (8) then Stmt.Save_Field (Name => COL_7_1_NAME, -- title Value => Object.Title); Object.Clear_Modified (8); end if; if Object.Is_Modified (9) then Stmt.Save_Field (Name => COL_8_1_NAME, -- description Value => Object.Description); Object.Clear_Modified (9); end if; if Object.Is_Modified (10) then Stmt.Save_Field (Name => COL_9_1_NAME, -- app_login_url Value => Object.App_Login_Url); Object.Clear_Modified (10); end if; if Object.Is_Modified (11) then Stmt.Save_Field (Name => COL_10_1_NAME, -- app_logo_url Value => Object.App_Logo_Url); Object.Clear_Modified (11); end if; if Object.Is_Modified (12) then Stmt.Save_Field (Name => COL_11_1_NAME, -- user_id Value => Object.User); Object.Clear_Modified (12); end if; if Stmt.Has_Save_Fields then Object.Version := Object.Version + 1; Stmt.Save_Field (Name => "version", Value => Object.Version); Stmt.Set_Filter (Filter => "id = ? and version = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Add_Param (Value => Object.Version - 1); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; else raise ADO.Objects.LAZY_LOCK; end if; end if; end; end if; end Save; procedure Create (Object : in out Application_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (APPLICATION_DEF'Access); Result : Integer; begin Object.Version := 1; Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_1_NAME, -- name Value => Object.Name); Query.Save_Field (Name => COL_2_1_NAME, -- secret_key Value => Object.Secret_Key); Query.Save_Field (Name => COL_3_1_NAME, -- client_id Value => Object.Client_Id); Query.Save_Field (Name => COL_4_1_NAME, -- version Value => Object.Version); Query.Save_Field (Name => COL_5_1_NAME, -- create_date Value => Object.Create_Date); Query.Save_Field (Name => COL_6_1_NAME, -- update_date Value => Object.Update_Date); Query.Save_Field (Name => COL_7_1_NAME, -- title Value => Object.Title); Query.Save_Field (Name => COL_8_1_NAME, -- description Value => Object.Description); Query.Save_Field (Name => COL_9_1_NAME, -- app_login_url Value => Object.App_Login_Url); Query.Save_Field (Name => COL_10_1_NAME, -- app_logo_url Value => Object.App_Logo_Url); Query.Save_Field (Name => COL_11_1_NAME, -- user_id Value => Object.User); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out Application_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (APPLICATION_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Application_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access Application_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := Application_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "name" then return Util.Beans.Objects.To_Object (Impl.Name); elsif Name = "secret_key" then return Util.Beans.Objects.To_Object (Impl.Secret_Key); elsif Name = "client_id" then return Util.Beans.Objects.To_Object (Impl.Client_Id); elsif Name = "create_date" then return Util.Beans.Objects.Time.To_Object (Impl.Create_Date); elsif Name = "update_date" then return Util.Beans.Objects.Time.To_Object (Impl.Update_Date); elsif Name = "title" then return Util.Beans.Objects.To_Object (Impl.Title); elsif Name = "description" then return Util.Beans.Objects.To_Object (Impl.Description); elsif Name = "app_login_url" then return Util.Beans.Objects.To_Object (Impl.App_Login_Url); elsif Name = "app_logo_url" then return Util.Beans.Objects.To_Object (Impl.App_Logo_Url); end if; return Util.Beans.Objects.Null_Object; end Get_Value; procedure List (Object : in out Application_Vector; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, APPLICATION_DEF'Access); begin Stmt.Execute; Application_Vectors.Clear (Object); while Stmt.Has_Elements loop declare Item : Application_Ref; Impl : constant Application_Access := new Application_Impl; begin Impl.Load (Stmt, Session); ADO.Objects.Set_Object (Item, Impl.all'Access); Object.Append (Item); end; Stmt.Next; end loop; end List; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Application_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Name := Stmt.Get_Unbounded_String (1); Object.Secret_Key := Stmt.Get_Unbounded_String (2); Object.Client_Id := Stmt.Get_Unbounded_String (3); Object.Create_Date := Stmt.Get_Time (5); Object.Update_Date := Stmt.Get_Time (6); Object.Title := Stmt.Get_Unbounded_String (7); Object.Description := Stmt.Get_Unbounded_String (8); Object.App_Login_Url := Stmt.Get_Unbounded_String (9); Object.App_Logo_Url := Stmt.Get_Unbounded_String (10); if not Stmt.Is_Null (11) then Object.User.Set_Key_Value (Stmt.Get_Identifier (11), Session); end if; Object.Version := Stmt.Get_Integer (4); ADO.Objects.Set_Created (Object); end Load; function Callback_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => CALLBACK_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Callback_Key; function Callback_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => CALLBACK_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Callback_Key; function "=" (Left, Right : Callback_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Callback_Ref'Class; Impl : out Callback_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Callback_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Callback_Ref) is Impl : Callback_Access; begin Impl := new Callback_Impl; Impl.Version := 0; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Callback -- ---------------------------------------- procedure Set_Id (Object : in out Callback_Ref; Value : in ADO.Identifier) is Impl : Callback_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Callback_Ref) return ADO.Identifier is Impl : constant Callback_Access := Callback_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Url (Object : in out Callback_Ref; Value : in String) is Impl : Callback_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Url, Value); end Set_Url; procedure Set_Url (Object : in out Callback_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Callback_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Url, Value); end Set_Url; function Get_Url (Object : in Callback_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Url); end Get_Url; function Get_Url (Object : in Callback_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Callback_Access := Callback_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Url; end Get_Url; function Get_Version (Object : in Callback_Ref) return Integer is Impl : constant Callback_Access := Callback_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Version; end Get_Version; procedure Set_Application (Object : in out Callback_Ref; Value : in AWA.OAuth.Models.Application_Ref'Class) is Impl : Callback_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 4, Impl.Application, Value); end Set_Application; function Get_Application (Object : in Callback_Ref) return AWA.OAuth.Models.Application_Ref'Class is Impl : constant Callback_Access := Callback_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Application; end Get_Application; -- Copy of the object. procedure Copy (Object : in Callback_Ref; Into : in out Callback_Ref) is Result : Callback_Ref; begin if not Object.Is_Null then declare Impl : constant Callback_Access := Callback_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Callback_Access := new Callback_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Url := Impl.Url; Copy.Version := Impl.Version; Copy.Application := Impl.Application; end; end if; Into := Result; end Copy; procedure Find (Object : in out Callback_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Callback_Access := new Callback_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Callback_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Callback_Access := new Callback_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Callback_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Callback_Access := new Callback_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Callback_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Callback_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Callback_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Callback_Impl) is type Callback_Impl_Ptr is access all Callback_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Callback_Impl, Callback_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Callback_Impl_Ptr := Callback_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Callback_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, CALLBACK_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Callback_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Callback_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (CALLBACK_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_2_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_2_NAME, -- url Value => Object.Url); Object.Clear_Modified (2); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_2_NAME, -- application_id Value => Object.Application); Object.Clear_Modified (4); end if; if Stmt.Has_Save_Fields then Object.Version := Object.Version + 1; Stmt.Save_Field (Name => "version", Value => Object.Version); Stmt.Set_Filter (Filter => "id = ? and version = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Add_Param (Value => Object.Version - 1); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; else raise ADO.Objects.LAZY_LOCK; end if; end if; end; end if; end Save; procedure Create (Object : in out Callback_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (CALLBACK_DEF'Access); Result : Integer; begin Object.Version := 1; Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_2_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_2_NAME, -- url Value => Object.Url); Query.Save_Field (Name => COL_2_2_NAME, -- version Value => Object.Version); Query.Save_Field (Name => COL_3_2_NAME, -- application_id Value => Object.Application); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out Callback_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (CALLBACK_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Callback_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access Callback_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := Callback_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "url" then return Util.Beans.Objects.To_Object (Impl.Url); end if; return Util.Beans.Objects.Null_Object; end Get_Value; procedure List (Object : in out Callback_Vector; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, CALLBACK_DEF'Access); begin Stmt.Execute; Callback_Vectors.Clear (Object); while Stmt.Has_Elements loop declare Item : Callback_Ref; Impl : constant Callback_Access := new Callback_Impl; begin Impl.Load (Stmt, Session); ADO.Objects.Set_Object (Item, Impl.all'Access); Object.Append (Item); end; Stmt.Next; end loop; end List; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Callback_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Url := Stmt.Get_Unbounded_String (1); if not Stmt.Is_Null (3) then Object.Application.Set_Key_Value (Stmt.Get_Identifier (3), Session); end if; Object.Version := Stmt.Get_Integer (2); ADO.Objects.Set_Created (Object); end Load; function Session_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => SESSION_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Session_Key; function Session_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => SESSION_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Session_Key; function "=" (Left, Right : Session_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Session_Ref'Class; Impl : out Session_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Session_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Session_Ref) is Impl : Session_Access; begin Impl := new Session_Impl; Impl.Create_Date := ADO.DEFAULT_TIME; Impl.Expire_Date := ADO.DEFAULT_TIME; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Session -- ---------------------------------------- procedure Set_Id (Object : in out Session_Ref; Value : in ADO.Identifier) is Impl : Session_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Session_Ref) return ADO.Identifier is Impl : constant Session_Access := Session_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Create_Date (Object : in out Session_Ref; Value : in Ada.Calendar.Time) is Impl : Session_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Time (Impl.all, 2, Impl.Create_Date, Value); end Set_Create_Date; function Get_Create_Date (Object : in Session_Ref) return Ada.Calendar.Time is Impl : constant Session_Access := Session_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Create_Date; end Get_Create_Date; procedure Set_Salt (Object : in out Session_Ref; Value : in String) is Impl : Session_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Salt, Value); end Set_Salt; procedure Set_Salt (Object : in out Session_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Session_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Salt, Value); end Set_Salt; function Get_Salt (Object : in Session_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Salt); end Get_Salt; function Get_Salt (Object : in Session_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Session_Access := Session_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Salt; end Get_Salt; procedure Set_Expire_Date (Object : in out Session_Ref; Value : in Ada.Calendar.Time) is Impl : Session_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Time (Impl.all, 4, Impl.Expire_Date, Value); end Set_Expire_Date; function Get_Expire_Date (Object : in Session_Ref) return Ada.Calendar.Time is Impl : constant Session_Access := Session_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Expire_Date; end Get_Expire_Date; procedure Set_Application (Object : in out Session_Ref; Value : in AWA.OAuth.Models.Application_Ref'Class) is Impl : Session_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 5, Impl.Application, Value); end Set_Application; function Get_Application (Object : in Session_Ref) return AWA.OAuth.Models.Application_Ref'Class is Impl : constant Session_Access := Session_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Application; end Get_Application; procedure Set_User (Object : in out Session_Ref; Value : in AWA.Users.Models.User_Ref'Class) is Impl : Session_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 6, Impl.User, Value); end Set_User; function Get_User (Object : in Session_Ref) return AWA.Users.Models.User_Ref'Class is Impl : constant Session_Access := Session_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.User; end Get_User; procedure Set_Session (Object : in out Session_Ref; Value : in AWA.Users.Models.Session_Ref'Class) is Impl : Session_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 7, Impl.Session, Value); end Set_Session; function Get_Session (Object : in Session_Ref) return AWA.Users.Models.Session_Ref'Class is Impl : constant Session_Access := Session_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Session; end Get_Session; -- Copy of the object. procedure Copy (Object : in Session_Ref; Into : in out Session_Ref) is Result : Session_Ref; begin if not Object.Is_Null then declare Impl : constant Session_Access := Session_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Session_Access := new Session_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Create_Date := Impl.Create_Date; Copy.Salt := Impl.Salt; Copy.Expire_Date := Impl.Expire_Date; Copy.Application := Impl.Application; Copy.User := Impl.User; Copy.Session := Impl.Session; end; end if; Into := Result; end Copy; procedure Find (Object : in out Session_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Session_Access := new Session_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Session_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Session_Access := new Session_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Session_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Session_Access := new Session_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Session_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Session_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Session_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Session_Impl) is type Session_Impl_Ptr is access all Session_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Session_Impl, Session_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Session_Impl_Ptr := Session_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Session_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, SESSION_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Session_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Session_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (SESSION_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_3_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_3_NAME, -- create_date Value => Object.Create_Date); Object.Clear_Modified (2); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_3_NAME, -- salt Value => Object.Salt); Object.Clear_Modified (3); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_3_NAME, -- expire_date Value => Object.Expire_Date); Object.Clear_Modified (4); end if; if Object.Is_Modified (5) then Stmt.Save_Field (Name => COL_4_3_NAME, -- application_id Value => Object.Application); Object.Clear_Modified (5); end if; if Object.Is_Modified (6) then Stmt.Save_Field (Name => COL_5_3_NAME, -- user_id Value => Object.User); Object.Clear_Modified (6); end if; if Object.Is_Modified (7) then Stmt.Save_Field (Name => COL_6_3_NAME, -- session_id Value => Object.Session); Object.Clear_Modified (7); end if; if Stmt.Has_Save_Fields then Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; end if; end if; end; end if; end Save; procedure Create (Object : in out Session_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (SESSION_DEF'Access); Result : Integer; begin Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_3_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_3_NAME, -- create_date Value => Object.Create_Date); Query.Save_Field (Name => COL_2_3_NAME, -- salt Value => Object.Salt); Query.Save_Field (Name => COL_3_3_NAME, -- expire_date Value => Object.Expire_Date); Query.Save_Field (Name => COL_4_3_NAME, -- application_id Value => Object.Application); Query.Save_Field (Name => COL_5_3_NAME, -- user_id Value => Object.User); Query.Save_Field (Name => COL_6_3_NAME, -- session_id Value => Object.Session); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out Session_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (SESSION_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Session_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access Session_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := Session_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "create_date" then return Util.Beans.Objects.Time.To_Object (Impl.Create_Date); elsif Name = "salt" then return Util.Beans.Objects.To_Object (Impl.Salt); elsif Name = "expire_date" then return Util.Beans.Objects.Time.To_Object (Impl.Expire_Date); end if; return Util.Beans.Objects.Null_Object; end Get_Value; procedure List (Object : in out Session_Vector; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, SESSION_DEF'Access); begin Stmt.Execute; Session_Vectors.Clear (Object); while Stmt.Has_Elements loop declare Item : Session_Ref; Impl : constant Session_Access := new Session_Impl; begin Impl.Load (Stmt, Session); ADO.Objects.Set_Object (Item, Impl.all'Access); Object.Append (Item); end; Stmt.Next; end loop; end List; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Session_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Create_Date := Stmt.Get_Time (1); Object.Salt := Stmt.Get_Unbounded_String (2); Object.Expire_Date := Stmt.Get_Time (3); if not Stmt.Is_Null (4) then Object.Application.Set_Key_Value (Stmt.Get_Identifier (4), Session); end if; if not Stmt.Is_Null (5) then Object.User.Set_Key_Value (Stmt.Get_Identifier (5), Session); end if; if not Stmt.Is_Null (6) then Object.Session.Set_Key_Value (Stmt.Get_Identifier (6), Session); end if; ADO.Objects.Set_Created (Object); end Load; end AWA.OAuth.Models;
AdaCore/training_material
Ada
4,209
adb
----------------------------------------------------------------------- -- Ada Labs -- -- -- -- Copyright (C) 2008-2009, AdaCore -- -- -- -- Labs 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 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, write to the Free Software Foundation, Inc., 59 Temple -- -- Place - Suite 330, Boston, MA 02111-1307, USA. -- ----------------------------------------------------------------------- with Ada.Text_IO; use Ada.Text_IO; with Ada.Real_Time; use Ada.Real_Time; with Display; use Display; with Display.Basic; use Display.Basic; with Libm_Single; use Libm_Single; procedure Main is -- QUESTION 1 - Part 1 -- define type Bodies_Enum_T as an enumeration of Sun, Earth, Moon, Satellite -- define type Parameters_Enum_T as an enumeration of parameter X, Y, -- Radius, Speed, Distance, Angle -- define type Bodies_Array_T as an array of float indexed by bodies and -- parameters -- define type Colors_Array_T as an array of color (RGBA_T) indexed by bodies -- declare variable Bodies which is an instance of Bodies_Array_T -- declare variable Colors which is an instance of Colors_Array_T -- declare a variable Next of type Time to store the Next step time Next : Time; -- declare a constant Period of 40 milliseconds of type Time_Span defining -- the loop period Period : constant Time_Span := Milliseconds (40); -- reference to the application window Window : Window_ID; -- reference to the graphical canvas associated with the application window Canvas : Canvas_ID; begin -- Create a window 240x320 Window := Create_Window (Width => 240, Height => 320, Name => "Solar System"); -- Retrieve the graphical canvas from the window Canvas := Get_Canvas (Window); -- QUESTION 1 - Part 2 -- initialize Bodies variable with parameters for each body using an aggregate -- Sun Distance = 0.0, Angle = 0.0, Speed = 0.0, Radius = 20.0; -- Earth Distance = 50.0, Angle = 0.0, Speed = 0.02, Radius = 5.0; -- Moon Distance = 15.0, Angle = 0.0, Speed = 0.04, Radius = 2.0; -- Satellite Distance = 8.0, Angle = 0.0, Speed = 0.1, Radius = 1.0; -- QUESTION 1 - Part 3 -- initialize Colors variable with Sun is Yellow, Earth is Blue, Moon is -- White, Satellite is Red -- initialize the Next step time begin the current time (Clock) + the period Next := Clock + Period; while not Is_Killed loop -- QUESTION 2 - part 1 -- create a loop to update each body position and angles -- Note: the Sun does not orbit against any body, you may declare -- and use a subtype to reference the orbiting bodies -- the position of an object around (0,0) at distance d with an angle a -- is (d*cos(a), d*sin(a)) -- update angle parameter of each body adding speed to the previous angle -- QUESTION 2 - part 2 -- create a loop to draw every objects -- use the Draw_Sphere procedure with the Point3D argument (using Z = 0.0) do to it -- update the screen using procedure Swap_Buffers Swap_Buffers (Window); -- wait until Next delay until Next; -- update the Next time adding the period for the next step Next := Next + Period; end loop; end Main;
charlie5/aIDE
Ada
1,112
ads
with AdaM.a_Type.enumeration_literal, gtk.Widget; private with gtk.gEntry, gtk.Box, gtk.Button; limited with adam.a_Type.enumeration_type; package aIDE.Editor.of_enumeration_literal is type Item is new Editor.item with private; type View is access all Item'Class; type enumeration_type_view is access all AdaM.a_Type.enumeration_type.item'Class; package Forge is function to_Editor (the_Target : in AdaM.a_Type.enumeration_literal.view; targets_Parent : in enumeration_type_view) return View; end Forge; overriding function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget; private use gtk.Button, gtk.gEntry, gtk.Box; type Item is new Editor.item with record Target : AdaM.a_Type.enumeration_literal.view; Targets_Parent : enumeration_type_view; top_Box : gtk_Box; name_Entry : Gtk_Entry; rid_Button : gtk_Button; end record; end aIDE.Editor.of_enumeration_literal;
optikos/oasis
Ada
4,450
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Parameter_Associations is function Create (Formal_Parameter : Program.Elements.Expressions.Expression_Access; Arrow_Token : Program.Lexical_Elements.Lexical_Element_Access; Actual_Parameter : not null Program.Elements.Expressions .Expression_Access) return Parameter_Association is begin return Result : Parameter_Association := (Formal_Parameter => Formal_Parameter, Arrow_Token => Arrow_Token, Actual_Parameter => Actual_Parameter, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Formal_Parameter : Program.Elements.Expressions.Expression_Access; Actual_Parameter : not null Program.Elements.Expressions .Expression_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Parameter_Association is begin return Result : Implicit_Parameter_Association := (Formal_Parameter => Formal_Parameter, Actual_Parameter => Actual_Parameter, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Formal_Parameter (Self : Base_Parameter_Association) return Program.Elements.Expressions.Expression_Access is begin return Self.Formal_Parameter; end Formal_Parameter; overriding function Actual_Parameter (Self : Base_Parameter_Association) return not null Program.Elements.Expressions.Expression_Access is begin return Self.Actual_Parameter; end Actual_Parameter; overriding function Arrow_Token (Self : Parameter_Association) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Arrow_Token; end Arrow_Token; overriding function Is_Part_Of_Implicit (Self : Implicit_Parameter_Association) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Parameter_Association) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Parameter_Association) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; procedure Initialize (Self : aliased in out Base_Parameter_Association'Class) is begin if Self.Formal_Parameter.Assigned then Set_Enclosing_Element (Self.Formal_Parameter, Self'Unchecked_Access); end if; Set_Enclosing_Element (Self.Actual_Parameter, Self'Unchecked_Access); null; end Initialize; overriding function Is_Parameter_Association_Element (Self : Base_Parameter_Association) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Parameter_Association_Element; overriding function Is_Association_Element (Self : Base_Parameter_Association) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Association_Element; overriding procedure Visit (Self : not null access Base_Parameter_Association; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Parameter_Association (Self); end Visit; overriding function To_Parameter_Association_Text (Self : aliased in out Parameter_Association) return Program.Elements.Parameter_Associations .Parameter_Association_Text_Access is begin return Self'Unchecked_Access; end To_Parameter_Association_Text; overriding function To_Parameter_Association_Text (Self : aliased in out Implicit_Parameter_Association) return Program.Elements.Parameter_Associations .Parameter_Association_Text_Access is pragma Unreferenced (Self); begin return null; end To_Parameter_Association_Text; end Program.Nodes.Parameter_Associations;
reznikmm/matreshka
Ada
4,009
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Text_Page_Adjust_Attributes; package Matreshka.ODF_Text.Page_Adjust_Attributes is type Text_Page_Adjust_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Page_Adjust_Attributes.ODF_Text_Page_Adjust_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Page_Adjust_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Page_Adjust_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Page_Adjust_Attributes;
reznikmm/matreshka
Ada
1,574
adb
with Ada.Calendar; with League.Application; with League.Strings; --with XML.SAX.Input_Sources.Strings; with XML.SAX.Input_Sources.Streams.Files; with XML.SAX.Simple_Readers; with Events_Printers; with Put_Line; with Read_File; procedure Main is use type League.Strings.Universal_String; use type Ada.Calendar.Time; Source : aliased XML.SAX.Input_Sources.Streams.Files.File_Input_Source; -- Source : aliased XML.SAX.Input_Sources.Strings.String_Input_Source; Reader : aliased XML.SAX.Simple_Readers.SAX_Simple_Reader; Handler : aliased Events_Printers.Events_Printer; Load_Start : Ada.Calendar.Time; Parse_Start : Ada.Calendar.Time; Stop : Ada.Calendar.Time; -- task type T; -- -- task body T is -- begin -- null; -- end T; begin Reader.Set_Entity_Resolver (Handler'Unchecked_Access); Load_Start := Ada.Calendar.Clock; Source.Open_By_File_Name (League.Application.Arguments.Element (1)); -- Source.Set_String (Read_File (Ada.Command_Line.Argument (1))); Parse_Start := Ada.Calendar.Clock; Reader.Parse (Source'Access); Stop := Ada.Calendar.Clock; Put_Line ("Loading time: " & League.Strings.To_Universal_String (Duration'Wide_Wide_Image (Parse_Start - Load_Start))); Put_Line ("Parsing time: " & League.Strings.To_Universal_String (Duration'Wide_Wide_Image (Stop - Parse_Start))); Put_Line ("Processing time:" & League.Strings.To_Universal_String (Duration'Wide_Wide_Image (Stop - Load_Start))); end Main;
joakim-strandberg/wayland_ada_binding
Ada
2,038
adb
package body C_Binding.Linux.Udev.Hardware_Databases is function Udev_Hwdb_Ref (Hwdb : Udev_Hwdb_Ptr) return Udev_Hwdb_Ptr; pragma Import (C, Udev_Hwdb_Ref, "udev_hwdb_ref"); function Udev_Hwdb_Unref (Hwdb : Udev_Hwdb_Ptr) return Udev_Hwdb_Ptr; pragma Import (C, Udev_Hwdb_Unref, "udev_hwdb_unref"); function Udev_Hwdb_Get_Properties_List_Entry (Hwdb : Udev_Hwdb_Ptr; Modalias : C_String; Flags : Unsigned -- Is unused ) return Udev_List_Entry_Ptr; pragma Import (C, Udev_Hwdb_Get_Properties_List_Entry, "udev_hwdb_get_properties_list_entry"); -- Lookup a matching device in the hardware database. The lookup key -- is a modalias string, whose formats are defined for the Linux kernel -- modules. Examples are: pci:v00008086d00001C2D*, usb:v04F2pB221*. -- The first entry of a list of retrieved properties is returned. procedure Acquire (Original : Database; Reference : out Database) is begin Reference.My_Ptr := Udev_Hwdb_Ref (Original.My_Ptr); end Acquire; function Exists (Database : Hardware_Databases.Database) return Boolean is (Database.My_Ptr /= null); procedure Delete (Database : in out Hardware_Databases.Database) is begin Database.My_Ptr := Udev_Hwdb_Unref (Database.My_Ptr); Database.My_Ptr := null; -- Is unnecessary, but static code analyzers cannot know -- Udev_Hwdb_Unref (..) always returns null. end Delete; procedure Properties_List_Entry (Database : Hardware_Databases.Database; Modalias : String; List_Entry : out List_Entries.List_Entry) is begin List_Entry_Base (List_Entry).My_Ptr := Udev_Hwdb_Get_Properties_List_Entry (Database.My_Ptr, +Modalias, 0); end Properties_List_Entry; procedure Finalize (Database : in out Hardware_Databases.Database) is begin if Database.Exists then Database.Delete; end if; end Finalize; end C_Binding.Linux.Udev.Hardware_Databases;
reznikmm/matreshka
Ada
4,041
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Draw_Extrusion_Metal_Attributes; package Matreshka.ODF_Draw.Extrusion_Metal_Attributes is type Draw_Extrusion_Metal_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Extrusion_Metal_Attributes.ODF_Draw_Extrusion_Metal_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Extrusion_Metal_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Extrusion_Metal_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Extrusion_Metal_Attributes;
reznikmm/matreshka
Ada
778
ads
with Ada.Streams; with League.Strings; package Styx.Messages.Opens is type Open_Mode is (Read, Write, Read_Write, Execute); type Open_Request is new Request with record FID : Styx.Messages.FID; Remove_On_Close : Boolean; Trunc : Boolean; Mode : Open_Mode; end record; procedure Visit (Visiter : in out Styx.Request_Visiters.Request_Visiter'Class; Value : Open_Request); type Open_Request_Access is access all Open_Request; type Open_Reply is new Reply with record QID : Styx.Messages.QID; Unit : Styx.Messages.Size; end record; procedure Visit (Visiter : in out Styx.Reply_Visiters.Reply_Visiter'Class; Value : Open_Reply); end Styx.Messages.Opens;
AdaCore/gpr
Ada
3,982
adb
-- -- Copyright (C) 2019-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception -- package body GPR2.Project.Source.Set is type Iterator is new Source_Iterator.Forward_Iterator with record Root : not null access constant Set.Set; end record; overriding function First (Iter : Iterator) return Cursor; overriding function Next (Iter : Iterator; Position : Cursor) return Cursor; ----------- -- Clear -- ----------- procedure Clear (Self : in out Object) is begin Self.S.Clear; end Clear; ------------------------ -- Constant_Reference -- ------------------------ function Constant_Reference (Self : aliased Object; Position : Cursor) return Constant_Reference_Type is Ref : constant Set.Constant_Reference_Type := Set.Constant_Reference (Self.S, Position.Current); begin return Constant_Reference_Type' (Source => Ref.Element.all'Unrestricted_Access, Ref => Ref); end Constant_Reference; -------------- -- Contains -- -------------- function Contains (Self : Object; Source : Project.Source.Object) return Boolean is begin return Self.S.Contains (Source); end Contains; ------------ -- Delete -- ------------ procedure Delete (Self : in out Object; Source : Project.Source.Object) is begin Self.S.Delete (Source); end Delete; ------------- -- Element -- ------------- function Element (Position : Cursor) return Project.Source.Object is begin return Set.Element (Position.Current); end Element; ----------- -- First -- ----------- overriding function First (Iter : Iterator) return Cursor is begin return Cursor'(Current => Iter.Root.First); end First; ------------------- -- First_Element -- ------------------- function First_Element (Self : Object) return Project.Source.Object is begin return Self.S.First_Element; end First_Element; ----------------- -- Has_Element -- ----------------- function Has_Element (Position : Cursor) return Boolean is begin return Set.Has_Element (Position.Current); end Has_Element; ------------- -- Include -- ------------- procedure Include (Self : in out Object; Source : Project.Source.Object) is begin Self.S.Include (Source); end Include; ------------ -- Insert -- ------------ procedure Insert (Self : in out Object; Source : Project.Source.Object; Position : out Cursor; Inserted : out Boolean) is begin Self.S.Insert (Source, Position.Current, Inserted); end Insert; ------------ -- Insert -- ------------ procedure Insert (Self : in out Object; Source : Project.Source.Object) is begin Self.S.Insert (Source); end Insert; ------------- -- Iterate -- ------------- function Iterate (Self : Object) return Source_Iterator.Forward_Iterator'Class is begin return Iterator'(Root => Self.S'Unrestricted_Access); end Iterate; ---------- -- Next -- ---------- overriding function Next (Iter : Iterator; Position : Cursor) return Cursor is Next : constant Set.Cursor := Set.Next (Position.Current); begin return Cursor'(Current => Next); end Next; ------------- -- Replace -- ------------- procedure Replace (Self : in out Object; Position : Cursor; Source : Project.Source.Object) is begin Self.S.Replace_Element (Position.Current, Source); end Replace; procedure Replace (Self : in out Object; Source : Project.Source.Object) is begin Self.S.Replace (Source); end Replace; ----------- -- Union -- ----------- procedure Union (Self : in out Object; Sources : Object) is begin Self.S.Union (Sources.S); end Union; end GPR2.Project.Source.Set;
charlie5/cBound
Ada
1,525
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with xcb.xcb_render_triangle_t; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_render_triangle_iterator_t is -- Item -- type Item is record data : access xcb.xcb_render_triangle_t.Item; the_rem : aliased Interfaces.C.int; index : aliased Interfaces.C.int; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_render_triangle_iterator_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_triangle_iterator_t.Item, Element_Array => xcb.xcb_render_triangle_iterator_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_triangle_iterator_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_triangle_iterator_t.Pointer, Element_Array => xcb.xcb_render_triangle_iterator_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_render_triangle_iterator_t;
AdaCore/libadalang
Ada
1,576
adb
with Ada.Text_IO; use Ada.Text_IO; use all type Ada.Text_IO.File_Type; procedure Example is subtype Nat is Integer range 0 .. Integer'Last; type Rec (N : Natural) is tagged record S : String (1 .. N); end record; type Money_Type is delta 0.01 digits 14; generic with procedure Put_Line (S : String); package Things is procedure Process (S : access Wide_String) with Pre => S /= null and then S'Length > 0 and then (for all I in S.all'Range => Wide_Character'Pos (S.all (I)) = 0); end Things; package body Things is ------------- -- Process -- ------------- procedure Process (S : access Wide_String) is begin Print_Loop : for C of S.all loop Print_Block : declare C_Pos : constant Integer := Wide_Character'Pos (C); begin if C_Pos < Character'Pos (Character'Last) then declare CS : constant String := (1 => Character'Val (C_Pos)); begin Put_Line (CS); end; end if; end Print_Block; end loop Print_Loop; end Process; end Things; package Text_IO_Things is new Things (Put_Line); A : Integer := 0; ["03C0"] : Standard.Integer := 0; S : aliased Wide_String := "Hello, ["03C0"] world!"; Hex_Digits : array (0 .. 15) of Character := "0123456789abcdef"; begin Text_IO_Things.Process (S'Access); end;
io7m/coreland-postgres-ada
Ada
15,303
adb
------------------------------------------------------------------------------ -- -- -- P G A D A . D A T A B A S E -- -- -- -- B o d y -- -- -- -- Copyright (c) Samuel Tardieu 2000 -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of Samuel Tardieu 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 SAMUEL TARDIEU 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 SAMUEL -- -- TARDIEU OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -- -- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -- -- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -- -- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -- -- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -- -- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Deallocation; with Interfaces.C.Strings; with Interfaces.C; package body PGAda.Database is package ICS renames Interfaces.C.Strings; package IC renames Interfaces.C; use type ICS.chars_ptr; use type IC.int; use type PGAda.Thin.PG_Conn_Access_t; use type PGAda.Thin.PG_Result_Access_t; Exec_Status_Match : constant array (Thin.Exec_Status_t) of Exec_Status_t := (PGAda.Thin.PGRES_EMPTY_QUERY => Empty_Query, PGAda.Thin.PGRES_COMMAND_OK => Command_OK, PGAda.Thin.PGRES_TUPLES_OK => Tuples_OK, PGAda.Thin.PGRES_COPY_OUT => Copy_Out, PGAda.Thin.PGRES_COPY_IN => Copy_In, PGAda.Thin.PGRES_BAD_RESPONSE => Bad_Response, PGAda.Thin.PGRES_NONFATAL_ERROR => Non_Fatal_Error, PGAda.Thin.PGRES_FATAL_ERROR => Fatal_Error); ----------------------- -- Local subprograms -- ----------------------- function C_String_Or_Null (S : String) return ICS.chars_ptr; procedure Free (S : in out ICS.chars_ptr); -- Create a C string or return Null_Ptr if the string is empty, and -- free it if needed. ------------ -- Adjust -- ------------ procedure Adjust (Result : in out Result_t) is begin Result.Ref_Count.all := Result.Ref_Count.all + 1; end Adjust; ---------------------- -- C_String_Or_Null -- ---------------------- function C_String_Or_Null (S : String) return ICS.chars_ptr is begin if S = "" then return ICS.Null_Ptr; else return ICS.New_String (S); end if; end C_String_Or_Null; ----------- -- Clear -- ----------- procedure Clear (Result : in out Result_t) is begin PGAda.Thin.PQ_Clear (Result.Actual); Result.Actual := null; end Clear; -------------------- -- Command_Status -- -------------------- function Command_Status (Result : Result_t) return String is begin return ICS.Value (PGAda.Thin.PQ_Cmd_Status (Result.Actual)); end Command_Status; -------------------- -- Command_Tuples -- -------------------- function Command_Tuples (Result : Result_t) return String is begin return ICS.Value (PGAda.Thin.PQ_Cmd_Tuples (Result.Actual)); end Command_Tuples; -------- -- DB -- -------- function DB (Connection : Connection_t) return String is begin return ICS.Value (PGAda.Thin.PQ_Db (Connection.Actual)); end DB; ------------------- -- Error_Message -- ------------------- function Error_Message (Connection : Connection_t) return String is begin return ICS.Value (PGAda.Thin.PQ_Error_Message (Connection.Actual)); end Error_Message; ------------------- -- Error_Message -- ------------------- function Error_Message (Result : Result_t) return String is begin return Result_Error_Field (Result => Result, Field => PGAda.Thin.PG_DIAG_MESSAGE_PRIMARY); end Error_Message; ---------- -- Exec -- ---------- procedure Exec (Connection : in Connection_t'Class; Query : in String; Result : out Result_t; Status : out Exec_Status_t) is C_Query : ICS.chars_ptr := ICS.New_String (Query); begin Result.Actual := PGAda.Thin.PQ_Exec (Connection.Actual, C_Query); ICS.Free (C_Query); Status := Result_Status (Result); end Exec; ---------- -- Exec -- ---------- procedure Exec (Connection : in Connection_t'Class; Query : in String; Result : out Result_t) is C_Query : ICS.chars_ptr := ICS.New_String (Query); begin Result.Actual := PGAda.Thin.PQ_Exec (Connection.Actual, C_Query); ICS.Free (C_Query); end Exec; ---------- -- Exec -- ---------- function Exec (Connection : Connection_t'Class; Query : String) return Result_t is Result : Result_t; begin Exec (Connection, Query, Result); return Result; end Exec; ---------- -- Exec -- ---------- procedure Exec (Connection : in Connection_t'Class; Query : in String) is Result : Result_t; begin -- Result value ignored by call pragma Warnings (off); Exec (Connection, Query, Result); pragma Warnings (on); end Exec; ---------------- -- Field_Name -- ---------------- function Field_Name (Result : Result_t; Field_Index : Positive) return String is begin return ICS.Value (PGAda.Thin.PQ_F_Name (Result.Actual, IC.int (Field_Index) - 1)); end Field_Name; -------------- -- Finalize -- -------------- procedure Finalize (Connection : in out Connection_t) is begin if Connection.Actual /= null then Finish (Connection); end if; end Finalize; -------------- -- Finalize -- -------------- procedure Finalize (Result : in out Result_t) is procedure Free is new Ada.Unchecked_Deallocation (Natural, Natural_Access_t); begin Result.Ref_Count.all := Result.Ref_Count.all - 1; if Result.Ref_Count.all = 0 and then Result.Actual /= null then Free (Result.Ref_Count); Clear (Result); end if; end Finalize; ------------ -- Finish -- ------------ procedure Finish (Connection : in out Connection_t) is begin PGAda.Thin.PQ_Finish (Connection.Actual); Connection.Actual := null; end Finish; ---------- -- Free -- ---------- procedure Free (S : in out ICS.chars_ptr) is begin if S /= ICS.Null_Ptr then ICS.Free (S); end if; end Free; ---------------- -- Get_Length -- ---------------- function Get_Length (Result : Result_t; Tuple_Index : Positive; Field_Index : Positive) return Natural is begin return Natural (PGAda.Thin.PQ_Get_Length (Result.Actual, IC.int (Tuple_Index) - 1, IC.int (Field_Index) - 1)); end Get_Length; --------------- -- Get_Value -- --------------- function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Index : Positive) return String is begin return ICS.Value (PGAda.Thin.PQ_Get_Value (Result.Actual, IC.int (Tuple_Index) - 1, IC.int (Field_Index) - 1)); end Get_Value; --------------- -- Get_Value -- --------------- function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Name : String) return String is C_Name : ICS.chars_ptr := ICS.New_String (Field_Name); Ret : constant String := Get_Value (Result, Tuple_Index, 1 + Natural (PGAda.Thin.PQ_F_Number (Result.Actual, C_Name))); begin Free (C_Name); return Ret; end Get_Value; --------------- -- Get_Value -- --------------- function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Index : Positive) return Integer is begin return Integer'Value (Get_Value (Result, Tuple_Index, Field_Index)); end Get_Value; --------------- -- Get_Value -- --------------- function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Name : String) return Integer is begin return Integer'Value (Get_Value (Result, Tuple_Index, Field_Name)); end Get_Value; --------------- -- Get_Value -- --------------- function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Index : Positive) return Long_Integer is begin return Long_Integer'Value (Get_Value (Result, Tuple_Index, Field_Index)); end Get_Value; --------------- -- Get_Value -- --------------- function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Name : String) return Long_Integer is begin return Long_Integer'Value (Get_Value (Result, Tuple_Index, Field_Name)); end Get_Value; --------------- -- Get_Value -- --------------- function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Index : Positive) return Long_Long_Integer is begin return Long_Long_Integer'Value (Get_Value (Result, Tuple_Index, Field_Index)); end Get_Value; --------------- -- Get_Value -- --------------- function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Name : String) return Long_Long_Integer is begin return Long_Long_Integer'Value (Get_Value (Result, Tuple_Index, Field_Name)); end Get_Value; ---------- -- Host -- ---------- function Host (Connection : Connection_t) return String is begin return ICS.Value (PGAda.Thin.PQ_Host (Connection.Actual)); end Host; ------------- -- Is_Null -- ------------- function Is_Null (Result : Result_t; Tuple_Index : Positive; Field_Index : Positive) return Boolean is begin return 1 = PGAda.Thin.PQ_Get_Is_Null (Result.Actual, IC.int (Tuple_Index) - 1, IC.int (Field_Index) - 1); end Is_Null; ---------------- -- Nbr_Fields -- ---------------- function Nbr_Fields (Result : Result_t) return Natural is begin return Natural (PGAda.Thin.PQ_N_Fields (Result.Actual)); end Nbr_Fields; ---------------- -- Nbr_Tuples -- ---------------- function Nbr_Tuples (Result : Result_t) return Natural is begin return Natural (PGAda.Thin.PQ_N_Tuples (Result.Actual)); end Nbr_Tuples; ---------------- -- OID_Status -- ---------------- function OID_Status (Result : Result_t) return String is begin return ICS.Value (PGAda.Thin.PQ_Oid_Status (Result.Actual)); end OID_Status; ------------- -- Options -- ------------- function Options (Connection : Connection_t) return String is begin return ICS.Value (PGAda.Thin.PQ_Options (Connection.Actual)); end Options; ---------- -- Port -- ---------- function Port (Connection : Connection_t) return Positive is begin return Positive'Value (ICS.Value (PGAda.Thin.PQ_Port (Connection.Actual))); end Port; ----------- -- Reset -- ----------- procedure Reset (Connection : in Connection_t) is begin PGAda.Thin.PQ_Reset (Connection.Actual); end Reset; ------------------- -- Result_Status -- ------------------- function Result_Status (Result : Result_t) return Exec_Status_t is begin return Exec_Status_Match (PGAda.Thin.PQ_Result_Status (Result.Actual)); end Result_Status; ------------------------ -- Result_Error_Field -- ------------------------ function Result_Error_Field (Result : Result_t; Field : Error_Field) return String is C_Res : constant ICS.chars_ptr := PGAda.Thin.PQ_Result_Error_Field (Result.Actual, Field); begin if C_Res = ICS.Null_Ptr then return ""; else return ICS.Value (C_Res); end if; end Result_Error_Field; ---------------- -- Error_Code -- ---------------- function Error_Code (Result : Result_t) return PGAda.Errors.Error_Value_t is begin return PGAda.Errors.Error_Value (Result_Error_Field (Result, PGAda.Thin.PG_DIAG_SQLSTATE)); end Error_Code; ------------------ -- Set_DB_Login -- ------------------ procedure Set_DB_Login (Connection : in out Connection_t; Host : in String := ""; Port : in Natural := 0; Options : in String := ""; TTY : in String := ""; DB_Name : in String := ""; Login : in String := ""; Password : in String := "") is C_Host : ICS.chars_ptr := C_String_Or_Null (Host); C_Port : ICS.chars_ptr; C_Options : ICS.chars_ptr := C_String_Or_Null (Options); C_TTY : ICS.chars_ptr := C_String_Or_Null (TTY); C_DB_Name : ICS.chars_ptr := C_String_Or_Null (DB_Name); C_Login : ICS.chars_ptr := C_String_Or_Null (Login); C_Password : ICS.chars_ptr := C_String_Or_Null (Password); begin if Port = 0 then C_Port := ICS.Null_Ptr; else C_Port := ICS.New_String (Positive'Image (Port)); end if; Connection.Actual := PGAda.Thin.PQ_Set_Db_Login (C_Host, C_Port, C_Options, C_TTY, C_DB_Name, C_Login, C_Password); Free (C_Host); Free (C_Port); Free (C_Options); Free (C_TTY); Free (C_DB_Name); Free (C_Login); Free (C_Password); if Connection.Actual = null then raise PG_Error; end if; end Set_DB_Login; ------------ -- Status -- ------------ function Status (Connection : Connection_t) return Connection_Status_t is begin case PGAda.Thin.PQ_Status (Connection.Actual) is when PGAda.Thin.CONNECTION_OK => return Connection_OK; when PGAda.Thin.CONNECTION_BAD => return Connection_Bad; end case; end Status; end PGAda.Database;
mfkiwl/ewok-kernel-security-OS
Ada
1,092
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with ewok; use ewok; with ewok.interrupts; package ewok.mpu.handler with spark_mode => on is procedure init with global => (in_out => (ewok.interrupts.interrupt_table)); function memory_fault_handler (frame_a : t_stack_frame_access) return t_stack_frame_access; end ewok.mpu.handler;
luk9400/nsi
Ada
469
ads
package Selection with SPARK_Mode is type Arr is array (Integer range <>) of Integer; function Sorted (A: Arr) return Boolean is (for all I in A'First .. A'Last - 1 => A (I) <= A (I + 1)) with Ghost, Pre => A'Last > Integer'First; procedure Sort (A: in out Arr) with Pre => A'First in Integer'First + 1 .. Integer'Last - 1 and A'Last in Integer'First + 1 .. Integer'Last - 1, Post => Sorted (A); end Selection;
stcarrez/ada-security
Ada
1,700
adb
----------------------------------------------------------------------- -- Security testsuite - Ada Security Test suite -- Copyright (C) 2011, 2012, 2013, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Security.Auth.Tests; with Security.Permissions.Tests; with Security.Policies.Tests; with Security.OAuth.JWT.Tests; with Security.OAuth.Clients.Tests; with Security.OAuth.Servers.Tests; with Security.Random.Tests; package body Security.Testsuite is Tests : aliased Util.Tests.Test_Suite; function Suite return Util.Tests.Access_Test_Suite is Ret : constant Util.Tests.Access_Test_Suite := Tests'Access; begin Security.Random.Tests.Add_Tests (Ret); Security.OAuth.JWT.Tests.Add_Tests (Ret); Security.Auth.Tests.Add_Tests (Ret); Security.Permissions.Tests.Add_Tests (Ret); Security.Policies.Tests.Add_Tests (Ret); Security.OAuth.Clients.Tests.Add_Tests (Ret); Security.OAuth.Servers.Tests.Add_Tests (Ret); return Ret; end Suite; end Security.Testsuite;
optikos/oasis
Ada
4,427
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Elements.Raise_Statements; with Program.Element_Visitors; package Program.Nodes.Raise_Statements is pragma Preelaborate; type Raise_Statement is new Program.Nodes.Node and Program.Elements.Raise_Statements.Raise_Statement and Program.Elements.Raise_Statements.Raise_Statement_Text with private; function Create (Raise_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Raised_Exception : Program.Elements.Expressions.Expression_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Associated_Message : Program.Elements.Expressions.Expression_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Raise_Statement; type Implicit_Raise_Statement is new Program.Nodes.Node and Program.Elements.Raise_Statements.Raise_Statement with private; function Create (Raised_Exception : Program.Elements.Expressions.Expression_Access; Associated_Message : Program.Elements.Expressions.Expression_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Raise_Statement with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Raise_Statement is abstract new Program.Nodes.Node and Program.Elements.Raise_Statements.Raise_Statement with record Raised_Exception : Program.Elements.Expressions.Expression_Access; Associated_Message : Program.Elements.Expressions.Expression_Access; end record; procedure Initialize (Self : aliased in out Base_Raise_Statement'Class); overriding procedure Visit (Self : not null access Base_Raise_Statement; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Raised_Exception (Self : Base_Raise_Statement) return Program.Elements.Expressions.Expression_Access; overriding function Associated_Message (Self : Base_Raise_Statement) return Program.Elements.Expressions.Expression_Access; overriding function Is_Raise_Statement_Element (Self : Base_Raise_Statement) return Boolean; overriding function Is_Statement_Element (Self : Base_Raise_Statement) return Boolean; type Raise_Statement is new Base_Raise_Statement and Program.Elements.Raise_Statements.Raise_Statement_Text with record Raise_Token : not null Program.Lexical_Elements .Lexical_Element_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_Raise_Statement_Text (Self : aliased in out Raise_Statement) return Program.Elements.Raise_Statements.Raise_Statement_Text_Access; overriding function Raise_Token (Self : Raise_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function With_Token (Self : Raise_Statement) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Semicolon_Token (Self : Raise_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Raise_Statement is new Base_Raise_Statement with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Raise_Statement_Text (Self : aliased in out Implicit_Raise_Statement) return Program.Elements.Raise_Statements.Raise_Statement_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Raise_Statement) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Raise_Statement) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Raise_Statement) return Boolean; end Program.Nodes.Raise_Statements;
zhmu/ananas
Ada
2,067
adb
-- { dg-do run } with Init11; use Init11; with Text_IO; use Text_IO; with Dump; procedure P11 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 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } Put ("My_R2 :"); Dump (My_R2'Address, R2'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "My_R2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } Local_R1 := My_R1; Put ("Local_R1 :"); Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } Local_R2 := My_R2; Put ("Local_R2 :"); Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } Local_R1 := (I => 16#12345678#, A => (16#AB0012#, 16#CD0034#, 16#EF0056#)); Put ("Local_R1 :"); Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } Local_R2 := (I => 16#12345678#, A => (16#AB0012#, 16#CD0034#, 16#EF0056#)); Put ("Local_R2 :"); Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } Local_R1.I := Local_R2.I; Local_R1.A(1) := Local_R2.A(1); Local_R1.A(2) := Local_R2.A(2); Local_R1.A(3) := Local_R2.A(3); Put ("Local_R1 :"); Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R1 : 78 56 34 12 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } Local_R2.I := Local_R1.I; Local_R2.A(1) := Local_R1.A(1); Local_R2.A(2) := Local_R1.A(2); Local_R2.A(3) := Local_R1.A(3); Put ("Local_R2 :"); Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements); New_Line; -- { dg-output "Local_R2 : 12 34 56 78 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } end;
reznikmm/matreshka
Ada
8,430
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.DC; with AMF.DG.Clip_Paths; with AMF.DG.Groups; with AMF.DG.Markers; with AMF.DG.Polygons; with AMF.DG.Styles.Collections; with AMF.Internals.DG_Elements; with AMF.Visitors; package AMF.Internals.DG_Polygons is type DG_Polygon_Proxy is limited new AMF.Internals.DG_Elements.DG_Element_Proxy and AMF.DG.Polygons.DG_Polygon with null record; overriding function Get_Point (Self : not null access constant DG_Polygon_Proxy) return AMF.DC.Sequence_Of_DC_Point; -- Getter of Polygon::point. -- -- a list of 3 or more points making up the polygon. overriding function Get_Start_Marker (Self : not null access constant DG_Polygon_Proxy) return AMF.DG.Markers.DG_Marker_Access; -- Getter of MarkedElement::startMarker. -- -- an optional start marker that aligns with the first vertex of the -- marked element. overriding procedure Set_Start_Marker (Self : not null access DG_Polygon_Proxy; To : AMF.DG.Markers.DG_Marker_Access); -- Setter of MarkedElement::startMarker. -- -- an optional start marker that aligns with the first vertex of the -- marked element. overriding function Get_End_Marker (Self : not null access constant DG_Polygon_Proxy) return AMF.DG.Markers.DG_Marker_Access; -- Getter of MarkedElement::endMarker. -- -- an optional end marker that aligns with the last vertex of the marked -- element. overriding procedure Set_End_Marker (Self : not null access DG_Polygon_Proxy; To : AMF.DG.Markers.DG_Marker_Access); -- Setter of MarkedElement::endMarker. -- -- an optional end marker that aligns with the last vertex of the marked -- element. overriding function Get_Mid_Marker (Self : not null access constant DG_Polygon_Proxy) return AMF.DG.Markers.DG_Marker_Access; -- Getter of MarkedElement::midMarker. -- -- an optional mid marker that aligns with all vertices of the marked -- element except the first and the last. overriding procedure Set_Mid_Marker (Self : not null access DG_Polygon_Proxy; To : AMF.DG.Markers.DG_Marker_Access); -- Setter of MarkedElement::midMarker. -- -- an optional mid marker that aligns with all vertices of the marked -- element except the first and the last. overriding function Get_Group (Self : not null access constant DG_Polygon_Proxy) return AMF.DG.Groups.DG_Group_Access; -- Getter of GraphicalElement::group. -- -- the group element that owns this graphical element. overriding procedure Set_Group (Self : not null access DG_Polygon_Proxy; To : AMF.DG.Groups.DG_Group_Access); -- Setter of GraphicalElement::group. -- -- the group element that owns this graphical element. overriding function Get_Local_Style (Self : not null access constant DG_Polygon_Proxy) return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style; -- Getter of GraphicalElement::localStyle. -- -- a list of locally-owned styles for this graphical element. overriding function Get_Shared_Style (Self : not null access constant DG_Polygon_Proxy) return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style; -- Getter of GraphicalElement::sharedStyle. -- -- a list of shared styles for this graphical element. overriding function Get_Transform (Self : not null access constant DG_Polygon_Proxy) return AMF.DG.Sequence_Of_DG_Transform; -- Getter of GraphicalElement::transform. -- -- a list of zero or more transforms to apply to this graphical element. overriding function Get_Clip_Path (Self : not null access constant DG_Polygon_Proxy) return AMF.DG.Clip_Paths.DG_Clip_Path_Access; -- Getter of GraphicalElement::clipPath. -- -- an optional reference to a clip path element that masks the painting of -- this graphical element. overriding procedure Set_Clip_Path (Self : not null access DG_Polygon_Proxy; To : AMF.DG.Clip_Paths.DG_Clip_Path_Access); -- Setter of GraphicalElement::clipPath. -- -- an optional reference to a clip path element that masks the painting of -- this graphical element. overriding procedure Enter_Element (Self : not null access constant DG_Polygon_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Leave_Element (Self : not null access constant DG_Polygon_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Visit_Element (Self : not null access constant DG_Polygon_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); end AMF.Internals.DG_Polygons;
zhmu/ananas
Ada
244
adb
package body Inline17_Pkg3 is function "+" (Field : SQL_Field'Class) return Integer is begin return 0; end; function Unchecked_Get (Self : Ref) return Integer is begin return Self.Data; end; end Inline17_Pkg3;
charlie5/cBound
Ada
1,484
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_close_font_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; font : aliased xcb.xcb_font_t; end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_close_font_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_close_font_request_t.Item, Element_Array => xcb.xcb_close_font_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_close_font_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_close_font_request_t.Pointer, Element_Array => xcb.xcb_close_font_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_close_font_request_t;
zhmu/ananas
Ada
4,033
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . S O C K E T S . P O L L . W A I T -- -- -- -- B o d y -- -- -- -- Copyright (C) 2020-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Wait implementation on top of Windows select call -- -- Microsoft Windows from Vista version has WSAPoll function in API which is -- similar to POSIX poll call, but experiments show that the WSAPoll is much -- slower than select at least in Windows version 10.0.18363.1016. with GNAT.Sockets.Poll.G_Wait; separate (GNAT.Sockets.Poll) procedure Wait (Fds : in out Set; Timeout : Interfaces.C.int; Result : out Integer) is use Interfaces; type FD_Array is array (1 .. Fds.Length) of FD_Type with Convention => C; type FD_Set_Type is record Count : C.int; Set : FD_Array; end record with Convention => C; procedure Reset_Socket_Set (Set : in out FD_Set_Type) with Inline; procedure Insert_Socket_In_Set (Set : in out FD_Set_Type; FD : FD_Type) with Inline; function Is_Socket_In_Set (Set : FD_Set_Type; FD : FD_Type) return C.int with Import, Convention => C, External_Name => "__gnat_is_socket_in_set"; -------------------------- -- Insert_Socket_In_Set -- -------------------------- procedure Insert_Socket_In_Set (Set : in out FD_Set_Type; FD : FD_Type) is begin Set.Count := Set.Count + 1; Set.Set (Integer (Set.Count)) := FD; end Insert_Socket_In_Set; ---------------------- -- Reset_Socket_Set -- ---------------------- procedure Reset_Socket_Set (Set : in out FD_Set_Type) is begin Set.Count := 0; end Reset_Socket_Set; ---------- -- Poll -- ---------- procedure Poll is new G_Wait (FD_Set_Type, Reset_Socket_Set, Insert_Socket_In_Set, Is_Socket_In_Set); begin Poll (Fds, Timeout, Result); end Wait;
gitter-badger/libAnne
Ada
602
adb
package body Generics.Mathematics is function Greatest_Common_Divisor(A, B : in Integer_Type) return Integer_Type is M : Integer_Type := A; N : Integer_Type := B; T : Integer_Type; begin while N /= 0 loop T := M; M := N; N := T mod N; end loop; return M; end Greatest_Common_Divisor; function Least_Common_Multiple(A, B : in Integer_Type) return Integer_Type is function GCD is new Greatest_Common_Divisor(Integer_Type); begin if A = 0 or B = 0 then return 0; end if; return abs(A) * (abs(B) / GCD(A, B)); end Least_Common_Multiple; end Generics.Mathematics;
reznikmm/matreshka
Ada
4,615
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Text.Date_Adjust_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Date_Adjust_Attribute_Node is begin return Self : Text_Date_Adjust_Attribute_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Date_Adjust_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Date_Adjust_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Date_Adjust_Attribute, Text_Date_Adjust_Attribute_Node'Tag); end Matreshka.ODF_Text.Date_Adjust_Attributes;
reznikmm/matreshka
Ada
5,097
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.UML.Generalizations.Collections is pragma Preelaborate; package UML_Generalization_Collections is new AMF.Generic_Collections (UML_Generalization, UML_Generalization_Access); type Set_Of_UML_Generalization is new UML_Generalization_Collections.Set with null record; Empty_Set_Of_UML_Generalization : constant Set_Of_UML_Generalization; type Ordered_Set_Of_UML_Generalization is new UML_Generalization_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Generalization : constant Ordered_Set_Of_UML_Generalization; type Bag_Of_UML_Generalization is new UML_Generalization_Collections.Bag with null record; Empty_Bag_Of_UML_Generalization : constant Bag_Of_UML_Generalization; type Sequence_Of_UML_Generalization is new UML_Generalization_Collections.Sequence with null record; Empty_Sequence_Of_UML_Generalization : constant Sequence_Of_UML_Generalization; private Empty_Set_Of_UML_Generalization : constant Set_Of_UML_Generalization := (UML_Generalization_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Generalization : constant Ordered_Set_Of_UML_Generalization := (UML_Generalization_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Generalization : constant Bag_Of_UML_Generalization := (UML_Generalization_Collections.Bag with null record); Empty_Sequence_Of_UML_Generalization : constant Sequence_Of_UML_Generalization := (UML_Generalization_Collections.Sequence with null record); end AMF.UML.Generalizations.Collections;
AdaCore/libadalang
Ada
412
adb
procedure Test is type Base is tagged null record; type T (X : Natural) is new Base with record case X is when 1 .. 10 => C_A : Integer; when others => null; end case; end record; type U is new T (8) with record C_B : Integer; end record; R : U := (X => 8, C_A => 13, C_B => 14); pragma Test_Statement; begin null; end Test;
reznikmm/matreshka
Ada
3,744
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.Draw_Fill_Image_Width_Attributes is pragma Preelaborate; type ODF_Draw_Fill_Image_Width_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Draw_Fill_Image_Width_Attribute_Access is access all ODF_Draw_Fill_Image_Width_Attribute'Class with Storage_Size => 0; end ODF.DOM.Draw_Fill_Image_Width_Attributes;
charlie5/lace
Ada
256
adb
package body openGL.Frustum is procedure normalise (Planes : in out Plane_array) is use Geometry_3D; begin for Each in Planes'Range loop normalise (Planes (Each)); end loop; end normalise; end openGL.Frustum;
zhmu/ananas
Ada
665
ads
pragma Restrictions (No_Abort_Statements); pragma Restrictions (Max_Asynchronous_Select_Nesting => 0); with Ada.Finalization; with System.Atomic_Counters; package Opt75_Pkg is type Rec is record Counter : System.Atomic_Counters.Atomic_Counter; end record; type Rec_Ptr is access all Rec; Empty_Rec : aliased Rec; type T is new Ada.Finalization.Controlled with record Ref : Rec_Ptr := Empty_Rec'Access; end record; overriding procedure Adjust (Object : in out T); Empty : constant T := (Ada.Finalization.Controlled with Ref => Empty_Rec'Access); type Arr is array (Integer range 1 .. 8, Integer range 1 .. 4) of T; end Opt75_Pkg;
reznikmm/matreshka
Ada
5,196
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.UML.Invocation_Actions.Collections is pragma Preelaborate; package UML_Invocation_Action_Collections is new AMF.Generic_Collections (UML_Invocation_Action, UML_Invocation_Action_Access); type Set_Of_UML_Invocation_Action is new UML_Invocation_Action_Collections.Set with null record; Empty_Set_Of_UML_Invocation_Action : constant Set_Of_UML_Invocation_Action; type Ordered_Set_Of_UML_Invocation_Action is new UML_Invocation_Action_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Invocation_Action : constant Ordered_Set_Of_UML_Invocation_Action; type Bag_Of_UML_Invocation_Action is new UML_Invocation_Action_Collections.Bag with null record; Empty_Bag_Of_UML_Invocation_Action : constant Bag_Of_UML_Invocation_Action; type Sequence_Of_UML_Invocation_Action is new UML_Invocation_Action_Collections.Sequence with null record; Empty_Sequence_Of_UML_Invocation_Action : constant Sequence_Of_UML_Invocation_Action; private Empty_Set_Of_UML_Invocation_Action : constant Set_Of_UML_Invocation_Action := (UML_Invocation_Action_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Invocation_Action : constant Ordered_Set_Of_UML_Invocation_Action := (UML_Invocation_Action_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Invocation_Action : constant Bag_Of_UML_Invocation_Action := (UML_Invocation_Action_Collections.Bag with null record); Empty_Sequence_Of_UML_Invocation_Action : constant Sequence_Of_UML_Invocation_Action := (UML_Invocation_Action_Collections.Sequence with null record); end AMF.UML.Invocation_Actions.Collections;
zhmu/ananas
Ada
4,863
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- B U T I L -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- This package contains utility routines for the binder with Namet; use Namet; with Types; use Types; package Butil is function Is_Predefined_Unit return Boolean; -- Given a unit name stored in Name_Buffer with length in Name_Len, -- returns True if this is the name of a predefined unit or a child of -- a predefined unit (including the obsolescent renamings). This is used -- in the preference selection (see Better_Choice in body of Binde). function Is_Internal_Unit return Boolean; -- Given a unit name stored in Name_Buffer with length in Name_Len, -- returns True if this is the name of an internal unit or a child of -- an internal unit. Similar in usage to Is_Predefined_Unit. -- Note: the following functions duplicate functionality in Uname, but -- we want to avoid bringing Uname into the binder since it generates -- to many unnecessary dependencies, and makes the binder too large. function Uname_Less (U1, U2 : Unit_Name_Type) return Boolean; -- Determines if the unit name U1 is alphabetically before U2 procedure Write_Unit_Name (U : Unit_Name_Type); -- Output unit name with (body) or (spec) after as required. On return -- Name_Len is set to the number of characters which were output. --------------- -- Iterators -- --------------- -- The following type represents an iterator over all units that are -- specified in the forced-elaboration-order file supplied by the binder -- via switch -f. type Forced_Units_Iterator is private; function Has_Next (Iter : Forced_Units_Iterator) return Boolean; pragma Inline (Has_Next); -- Determine whether iterator Iter has more units to examine function Iterate_Forced_Units return Forced_Units_Iterator; pragma Inline (Iterate_Forced_Units); -- Obtain an iterator over all units in the forced-elaboration-order file procedure Next (Iter : in out Forced_Units_Iterator; Unit_Name : out Unit_Name_Type; Unit_Line : out Logical_Line_Number); pragma Inline (Next); -- Return the current unit referenced by iterator Iter along with the -- line number it appears on, and advance to the next available unit. private First_Line_Number : constant Logical_Line_Number := No_Line_Number + 1; type Forced_Units_Iterator is record Order : String_Ptr := null; -- A reference to the contents of the forced-elaboration-order file, -- read in as a string. Order_Index : Positive := 1; -- Index into the order string Order_Line : Logical_Line_Number := First_Line_Number; -- Logical line number within the order string Unit_Line : Logical_Line_Number := No_Line_Number; -- The logical line number of the current unit name within the order -- string. Unit_Name : Unit_Name_Type := No_Unit_Name; -- The current unit name parsed from the order string end record; end Butil;
charlie5/lace
Ada
2,756
ads
package collada.Library -- -- Provides a namespace and core types for the specific collada library child packages. -- is type Float_array_view is access Float_array; type Text_array_view is access Text_array; ---------- -- Sources -- type Source is record Id : Text; array_Id : Text; Floats : Float_array_view; Texts : Text_array_view; end record; type Sources is array (Positive range <>) of Source; type Sources_view is access Sources; ---------- --- Inputs -- type Semantic is (Unknown, BINORMAL, -- Geometric binormal (bitangent) vector. COLOR, -- Color coordinate vector. Color inputs are RGB (float3_type). CONTINUITY, -- Continuity constraint at the control vertex (CV). IMAGE, -- Raster or MIP-level input. INPUT, -- Sampler input. IN_TANGENT, -- Tangent vector for preceding control point. INTERPOLATION, -- Sampler interpolation type. INV_BIND_MATRIX, -- Inverse of local-to-world matrix. JOINT, -- Skin influence identifier. LINEAR_STEPS, -- Number of piece-wise linear approximation steps to use for the spline segment that follows this CV. MORPH_TARGET, -- Morph targets for mesh morphing. MORPH_WEIGHT, -- Weights for mesh morphing. NORMAL, -- Normal vector. OUTPUT, -- Sampler output. OUT_TANGENT, -- Tangent vector for succeeding control point. POSITION, -- Geometric coordinate vector. TANGENT, -- Geometric tangent vector. TEXBINORMAL, -- Texture binormal (bitangent) vector. TEXCOORD, -- Texture coordinate vector. TEXTANGENT, -- Texture tangent vector. UV, -- Generic parameter vector. VERTEX, -- Mesh vertex. WEIGHT); -- Skin influence weighting value. type Input_t is record Semantic : library.Semantic := Unknown; Source : Text; Offset : Natural := 0; end record; type Inputs is array (Positive range <>) of Input_t; null_Input : constant Input_t; function find_in (Self : Inputs; the_Semantic : in library.Semantic) return Input_t; private null_Input : constant Input_t := (others => <>); end collada.Library;
stcarrez/ada-keystore
Ada
4,477
ads
----------------------------------------------------------------------- -- keystore-tests -- Tests for akt command -- Copyright (C) 2019, 2020, 2023 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with Util.Systems.Os; package Keystore.Tests is pragma Warnings (Off, "*condition is always*"); function Is_Windows return Boolean is (Util.Systems.Os.Directory_Separator = '\'); pragma Warnings (On, "*condition is always*"); EXE : constant String := (if Is_Windows then ".exe" else ""); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test the akt help command. procedure Test_Tool_Help (T : in out Test); -- Test the akt keystore creation. procedure Test_Tool_Create (T : in out Test); procedure Test_Tool_Create_Error (T : in out Test); -- Test the akt keystore creation with password file. procedure Test_Tool_Create_Password_File (T : in out Test); procedure Test_Tool_Create_Password_Command (T : in out Test); -- Test the akt command adding and removing values. procedure Test_Tool_Set_Remove (T : in out Test); procedure Test_Tool_Set_Remove_2 (T : in out Test); -- Test the akt command setting a big file. procedure Test_Tool_Set_Big (T : in out Test); -- Test the akt get command. procedure Test_Tool_Get (T : in out Test); -- Test the akt get command with errors. procedure Test_Tool_Get_Error (T : in out Test); -- Test the akt command with invalid parameters. procedure Test_Tool_Invalid (T : in out Test); -- Test the akt edit command. procedure Test_Tool_Edit (T : in out Test); procedure Test_Tool_Edit_Error (T : in out Test); -- Test the akt store and akt extract commands. procedure Test_Tool_Store_Extract (T : in out Test); procedure Test_Tool_Store_Extract_Tree (T : in out Test); -- Test the akt store command with errors. procedure Test_Tool_Store_Error (T : in out Test); procedure Test_Tool_Extract_Error (T : in out Test); -- Test the akt password-set command. procedure Test_Tool_Password_Set (T : in out Test); procedure Test_Tool_Password_Add_Limit (T : in out Test); -- Test the akt with an interactive password. procedure Test_Tool_Interactive_Password (T : in out Test); -- Test the akt with data blocks written in separate files. procedure Test_Tool_Separate_Data (T : in out Test); -- Test the akt config command. procedure Test_Tool_Set_Config (T : in out Test); -- Test the akt info command on several keystore files. procedure Test_Tool_Info (T : in out Test); procedure Test_Tool_Info_Error (T : in out Test); procedure Test_Tool_List_Error (T : in out Test); -- Test the akt commands with --wallet-key-file procedure Test_Tool_With_Wallet_Key_File (T : in out Test); procedure Test_Tool_Corrupted_1 (T : in out Test); procedure Test_Tool_Corrupted_2 (T : in out Test); procedure Test_Tool_Missing_Storage (T : in out Test); procedure Test_Tool_Version (T : in out Test); procedure Test_Tool_Bad_File (T : in out Test); procedure Test_Tool_Nested_Wallet (T : in out Test); -- Test the OTP command. procedure Test_Tool_OTP (T : in out Test); -- Test the OTP command with various errors. procedure Test_Tool_OTP_Error (T : in out Test); -- Test the OTP command with interactive mode. procedure Test_Tool_OTP_Interactive (T : in out Test); -- Test the genkey command. procedure Test_Tool_Genkey (T : in out Test); procedure Store_Extract (T : in out Test; Command : in String; Name : in String; Path : in String); end Keystore.Tests;
stcarrez/sql-benchmark
Ada
2,182
ads
-- -- -- package IEEE_754 Copyright (c) Dmitry A. Kazakov -- -- Interface Luebeck -- -- Summer, 2008 -- -- -- -- Last revision : 11:26 27 Jul 2008 -- -- -- -- 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 Interfaces; package IEEE_754 is pragma Pure (IEEE_754); subtype Byte is Interfaces.Unsigned_8; Not_A_Number_Error : exception; Positive_Overflow_Error : exception; Negative_Overflow_Error : exception; end IEEE_754;
adamnemecek/GA_Ada
Ada
1,618
adb
package body Multivector_Type_Base is -- ---------------------------------------------------------------------------- -- procedure Set_Grade_Usage (Base : in out Type_Base; GU : GA_Maths.Grade_Usage) is -- theBase : Type_Base; -- begin -- theBase.M_GU := GU; -- end Set_Grade_Usage; -- ---------------------------------------------------------------------------- -- procedure Set_M_Type (Base : in out Type_Base; theType : Object_Type) is -- begin -- Base.M_Type := theType; -- end Set_M_Type; -- ---------------------------------------------------------------------------- -- procedure Set_Parity (Base : in out Type_Base; Par : Parity) is -- begin -- Base.M_Parity := Par; -- end Set_Parity; -- ---------------------------------------------------------------------------- -- procedure Set_Top_Grade (Base : in out Type_Base; Grade :Integer) is -- begin -- Base.M_Top_Grade := Grade; -- end Set_Top_Grade; -- ---------------------------------------------------------------------------- procedure Set_Type_Base (Base : in out MV_Typebase; Zero : boolean; Object : Object_Type; Grade : integer; GU : GA_Maths.Grade_Usage; Par : Parity := No_Parity) is begin Base.M_Zero := Zero; Base.M_Type := Object; Base.M_Grade := Grade; Base.M_Grade_Use := GU; Base.M_Parity := Par; end Set_Type_Base; -- ---------------------------------------------------------------------------- end Multivector_Type_Base;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
5,521
ads
-- This spec has been automatically generated from STM32F103.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.DBG is pragma Preelaborate; --------------- -- Registers -- --------------- subtype IDCODE_DEV_ID_Field is STM32_SVD.UInt12; subtype IDCODE_REV_ID_Field is STM32_SVD.UInt16; -- DBGMCU_IDCODE type IDCODE_Register is record -- Read-only. DEV_ID DEV_ID : IDCODE_DEV_ID_Field; -- unspecified Reserved_12_15 : STM32_SVD.UInt4; -- Read-only. REV_ID REV_ID : IDCODE_REV_ID_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for IDCODE_Register use record DEV_ID at 0 range 0 .. 11; Reserved_12_15 at 0 range 12 .. 15; REV_ID at 0 range 16 .. 31; end record; subtype CR_DBG_SLEEP_Field is STM32_SVD.Bit; subtype CR_DBG_STOP_Field is STM32_SVD.Bit; subtype CR_DBG_STANDBY_Field is STM32_SVD.Bit; subtype CR_TRACE_IOEN_Field is STM32_SVD.Bit; subtype CR_TRACE_MODE_Field is STM32_SVD.UInt2; subtype CR_DBG_IWDG_STOP_Field is STM32_SVD.Bit; subtype CR_DBG_WWDG_STOP_Field is STM32_SVD.Bit; subtype CR_DBG_TIM1_STOP_Field is STM32_SVD.Bit; subtype CR_DBG_TIM2_STOP_Field is STM32_SVD.Bit; subtype CR_DBG_TIM3_STOP_Field is STM32_SVD.Bit; subtype CR_DBG_TIM4_STOP_Field is STM32_SVD.Bit; subtype CR_DBG_CAN1_STOP_Field is STM32_SVD.Bit; subtype CR_DBG_I2C1_SMBUS_TIMEOUT_Field is STM32_SVD.Bit; subtype CR_DBG_I2C2_SMBUS_TIMEOUT_Field is STM32_SVD.Bit; subtype CR_DBG_TIM8_STOP_Field is STM32_SVD.Bit; subtype CR_DBG_TIM5_STOP_Field is STM32_SVD.Bit; subtype CR_DBG_TIM6_STOP_Field is STM32_SVD.Bit; subtype CR_DBG_TIM7_STOP_Field is STM32_SVD.Bit; subtype CR_DBG_CAN2_STOP_Field is STM32_SVD.Bit; -- DBGMCU_CR type CR_Register is record -- DBG_SLEEP DBG_SLEEP : CR_DBG_SLEEP_Field := 16#0#; -- DBG_STOP DBG_STOP : CR_DBG_STOP_Field := 16#0#; -- DBG_STANDBY DBG_STANDBY : CR_DBG_STANDBY_Field := 16#0#; -- unspecified Reserved_3_4 : STM32_SVD.UInt2 := 16#0#; -- TRACE_IOEN TRACE_IOEN : CR_TRACE_IOEN_Field := 16#0#; -- TRACE_MODE TRACE_MODE : CR_TRACE_MODE_Field := 16#0#; -- DBG_IWDG_STOP DBG_IWDG_STOP : CR_DBG_IWDG_STOP_Field := 16#0#; -- DBG_WWDG_STOP DBG_WWDG_STOP : CR_DBG_WWDG_STOP_Field := 16#0#; -- DBG_TIM1_STOP DBG_TIM1_STOP : CR_DBG_TIM1_STOP_Field := 16#0#; -- DBG_TIM2_STOP DBG_TIM2_STOP : CR_DBG_TIM2_STOP_Field := 16#0#; -- DBG_TIM3_STOP DBG_TIM3_STOP : CR_DBG_TIM3_STOP_Field := 16#0#; -- DBG_TIM4_STOP DBG_TIM4_STOP : CR_DBG_TIM4_STOP_Field := 16#0#; -- DBG_CAN1_STOP DBG_CAN1_STOP : CR_DBG_CAN1_STOP_Field := 16#0#; -- DBG_I2C1_SMBUS_TIMEOUT DBG_I2C1_SMBUS_TIMEOUT : CR_DBG_I2C1_SMBUS_TIMEOUT_Field := 16#0#; -- DBG_I2C2_SMBUS_TIMEOUT DBG_I2C2_SMBUS_TIMEOUT : CR_DBG_I2C2_SMBUS_TIMEOUT_Field := 16#0#; -- DBG_TIM8_STOP DBG_TIM8_STOP : CR_DBG_TIM8_STOP_Field := 16#0#; -- DBG_TIM5_STOP DBG_TIM5_STOP : CR_DBG_TIM5_STOP_Field := 16#0#; -- DBG_TIM6_STOP DBG_TIM6_STOP : CR_DBG_TIM6_STOP_Field := 16#0#; -- DBG_TIM7_STOP DBG_TIM7_STOP : CR_DBG_TIM7_STOP_Field := 16#0#; -- DBG_CAN2_STOP DBG_CAN2_STOP : CR_DBG_CAN2_STOP_Field := 16#0#; -- unspecified Reserved_22_31 : STM32_SVD.UInt10 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record DBG_SLEEP at 0 range 0 .. 0; DBG_STOP at 0 range 1 .. 1; DBG_STANDBY at 0 range 2 .. 2; Reserved_3_4 at 0 range 3 .. 4; TRACE_IOEN at 0 range 5 .. 5; TRACE_MODE at 0 range 6 .. 7; DBG_IWDG_STOP at 0 range 8 .. 8; DBG_WWDG_STOP at 0 range 9 .. 9; DBG_TIM1_STOP at 0 range 10 .. 10; DBG_TIM2_STOP at 0 range 11 .. 11; DBG_TIM3_STOP at 0 range 12 .. 12; DBG_TIM4_STOP at 0 range 13 .. 13; DBG_CAN1_STOP at 0 range 14 .. 14; DBG_I2C1_SMBUS_TIMEOUT at 0 range 15 .. 15; DBG_I2C2_SMBUS_TIMEOUT at 0 range 16 .. 16; DBG_TIM8_STOP at 0 range 17 .. 17; DBG_TIM5_STOP at 0 range 18 .. 18; DBG_TIM6_STOP at 0 range 19 .. 19; DBG_TIM7_STOP at 0 range 20 .. 20; DBG_CAN2_STOP at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Debug support type DBG_Peripheral is record -- DBGMCU_IDCODE IDCODE : aliased IDCODE_Register; -- DBGMCU_CR CR : aliased CR_Register; end record with Volatile; for DBG_Peripheral use record IDCODE at 16#0# range 0 .. 31; CR at 16#4# range 0 .. 31; end record; -- Debug support DBG_Periph : aliased DBG_Peripheral with Import, Address => System'To_Address (16#E0042000#); end STM32_SVD.DBG;
Fabien-Chouteau/Ada_Drivers_Library
Ada
4,929
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017, 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 nRF51.GPIO; use nRF51.GPIO; with MicroBit.Time; use MicroBit.Time; package body MicroBit.Buttons is type Button_State_Array is array (Button_Id) of Button_State; Points : constant array (Button_Id) of GPIO_Point := (MB_P5, MB_P11); States : Button_State_Array := (others => Released); Subscribers : array (1 .. 10) of Button_Callback := (others => null); procedure Initialize; procedure Tick_Handler; ---------------- -- Initialize -- ---------------- procedure Initialize is Conf : GPIO_Configuration; begin Conf.Mode := Mode_In; Conf.Resistors := No_Pull; Conf.Input_Buffer := Input_Buffer_Connect; Conf.Sense := Sense_Disabled; for Pt of Points loop Pt.Configure_IO (Conf); end loop; if not Tick_Subscribe (Tick_Handler'Access) then raise Program_Error; end if; end Initialize; ------------------ -- Tick_Handler -- ------------------ procedure Tick_Handler is Prev_States : constant Button_State_Array := States; begin -- Update all components of States array for Id in Button_Id loop if not Set (Points (Id)) then States (Id) := Pressed; else States (Id) := Released; end if; end loop; -- Notify changes to subscribers for Id in Button_Id loop if States (Id) /= Prev_States (Id) then for Sub of Subscribers loop if Sub /= null then Sub.all (Id, States (Id)); end if; end loop; end if; end loop; end Tick_Handler; ----------- -- State -- ----------- function State (Button : Button_Id) return Button_State is begin return States (Button); end State; --------------- -- Subscribe -- --------------- function Subscribe (Callback : not null Button_Callback) return Boolean is begin for Subs of Subscribers loop if Subs = null then Subs := Callback; return True; end if; end loop; return False; end Subscribe; ----------------- -- Unsubscribe -- ----------------- function Unsubscribe (Callback : not null Button_Callback) return Boolean is begin for Subs of Subscribers loop if Subs = Callback then Subs := null; return True; end if; end loop; return False; end Unsubscribe; begin Initialize; end MicroBit.Buttons;
persan/advent-of-code-2020
Ada
135
adb
with Ada.Text_IO; use Ada.Text_IO; procedure Adventofcode.Day_15.Main is begin Put_Line ("Day-15"); end Adventofcode.Day_15.Main;
JKI757/coinapi-sdk
Ada
2,791
ads
-- OEML _ REST API -- This section will provide necessary information about the `CoinAPI OEML REST API` protocol. This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a> -- -- The version of the OpenAPI document: v1 -- Contact: [email protected] -- -- NOTE: This package is auto generated by OpenAPI-Generator 5.2.0. -- https://openapi-generator.tech -- Do not edit the class manually. with .Models; with Swagger.Clients; package .Clients is pragma Style_Checks ("-mr"); type Client_Type is new Swagger.Clients.Client_Type with null record; -- Get balances -- Get current currency balance from all or single exchange. procedure V_1Balances_Get (Client : in out Client_Type; Exchange_Id : in Swagger.Nullable_UString; Result : out .Models.Balance_Type_Vectors.Vector); -- Cancel all orders request -- This request cancels all open orders on single specified exchange. procedure V_1Orders_Cancel_All_Post (Client : in out Client_Type; Order_Cancel_All_Request_Type : in .Models.OrderCancelAllRequest_Type; Result : out .Models.MessageReject_Type); -- Cancel order request -- Request cancel for an existing order. The order can be canceled using the `client_order_id` or `exchange_order_id`. procedure V_1Orders_Cancel_Post (Client : in out Client_Type; Order_Cancel_Single_Request_Type : in .Models.OrderCancelSingleRequest_Type; Result : out .Models.OrderExecutionReport_Type); -- Get open orders -- Get last execution reports for open orders across all or single exchange. procedure V_1Orders_Get (Client : in out Client_Type; Exchange_Id : in Swagger.Nullable_UString; Result : out .Models.OrderExecutionReport_Type_Vectors.Vector); -- Send new order -- This request creating new order for the specific exchange. procedure V_1Orders_Post (Client : in out Client_Type; Order_New_Single_Request_Type : in .Models.OrderNewSingleRequest_Type; Result : out .Models.OrderExecutionReport_Type); -- Get order execution report -- Get the last order execution report for the specified order. The requested order does not need to be active or opened. procedure V_1Orders_Status_Client_Order_Id_Get (Client : in out Client_Type; Client_Order_Id : in Swagger.UString; Result : out .Models.OrderExecutionReport_Type); -- Get open positions -- Get current open positions across all or single exchange. procedure V_1Positions_Get (Client : in out Client_Type; Exchange_Id : in Swagger.Nullable_UString; Result : out .Models.Position_Type_Vectors.Vector); end .Clients;
tum-ei-rcs/StratoX
Ada
225
ads
with System; package Crash is procedure Last_Chance_Handler (Source_Location : System.Address; Line : Integer); pragma Export (C, Last_Chance_Handler, "__gnat_last_chance_handler"); end Crash;
AdaCore/Ada_Drivers_Library
Ada
4,362
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 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. -- -- -- ------------------------------------------------------------------------------ package body STM32.Board is ------------------ -- All_LEDs_Off -- ------------------ procedure All_LEDs_Off is begin Clear (All_LEDs); end All_LEDs_Off; ----------------- -- All_LEDs_On -- ----------------- procedure All_LEDs_On is begin Set (All_LEDs); end All_LEDs_On; --------------------- -- Initialize_LEDs -- --------------------- procedure Initialize_LEDs is begin Enable_Clock (All_LEDs); Configure_IO (All_LEDs, (Mode => Mode_Out, Output_Type => Push_Pull, Speed => Speed_100MHz, Resistors => Floating)); end Initialize_LEDs; ------------------------- -- Initialize_I2C_GPIO -- ------------------------- procedure Initialize_I2C_GPIO (Port : in out I2C_Port) is Id : constant I2C_Port_Id := As_Port_Id (Port); Points : constant GPIO_Points (1 .. 2) := (if Id = I2C_Id_1 then (PB8, PB9) elsif Id = I2C_Id_3 then (PH7, PH8) else (PA0, PA0)); begin if Id = I2C_Id_2 or else Id = I2C_Id_4 then raise Unknown_Device with "This I2C_Port cannot be used on this board"; end if; Enable_Clock (Points); Configure_IO (Points, (Mode => Mode_AF, AF => GPIO_AF_I2C2_4, AF_Speed => Speed_25MHz, AF_Output_Type => Open_Drain, Resistors => Floating)); Lock (Points); end Initialize_I2C_GPIO; -------------------------------- -- Configure_User_Button_GPIO -- -------------------------------- procedure Configure_User_Button_GPIO is begin Enable_Clock (User_Button_Point); Configure_IO (User_Button_Point, (Mode_In, Resistors => Floating)); end Configure_User_Button_GPIO; end STM32.Board;
reznikmm/matreshka
Ada
3,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.Attributes; package ODF.DOM.Chart_Style_Name_Attributes is pragma Preelaborate; type ODF_Chart_Style_Name_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Chart_Style_Name_Attribute_Access is access all ODF_Chart_Style_Name_Attribute'Class with Storage_Size => 0; end ODF.DOM.Chart_Style_Name_Attributes;
manthonyaiello/LmcpGen
Ada
20,091
adb
with AVTAS.LMCP.ByteBuffers; use AVTAS.LMCP.ByteBuffers; with Ada.Text_IO; use Ada.Text_IO; with Ada.Assertions; use Ada.Assertions; with Ada.Strings.Unbounded; -- use Ada.Strings.Unbounded; with Ada.Exceptions; use Ada.Exceptions; with AVTAS.LMCP.Types; use AVTAS.LMCP.Types; procedure Test_ByteBuffers with SPARK_Mode is Failed : Natural := 0; package ASU renames Ada.Strings.Unbounded; begin -- get from relative index -------------------------------------------------- declare C : constant := 100; -- arbitrary B : ByteBuffer (Capacity => C); V : UInt16 := 42; begin Put ("Get UInt16 at absolute index: "); B.Put_Uint16 (V); B.Rewind; V := 0; B.Get_UInt16 (V); if V = 42 then Put_Line ("passed"); else Put_Line ("failed, wrong value read"); end if; exception when Assertion_Error => Put_Line ("FAILED (raised Assertion_Error)"); Failed := Failed + 1; when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; -- get from absolute index -------------------------------------------------- declare -- 123456789ABC String_Input : constant String := "Hello World!"; Index_After_String : constant := 2 + String_Input'Length; -- the 2-byte length of the string precedes the actual string content so -- we add 2 UInt32_Input : constant UInt32 := 42; Byte_Input : constant Byte := 42; Expected_High_Water_Mark : constant := 2 + String_Input'Length + 4 + 1; -- 2-bytes for string length + length of string + 4 bytes for uint32 + 1 byte for boolean Buffer : ByteBuffer (Capacity => 100); begin Put ("Get_UInt32 from absolute index > position and <= high water mark: "); Buffer.Put_String (String_Input); Buffer.Put_UInt32 (UInt32_Input); Buffer.Put_Byte (Byte_Input); Buffer.Rewind; Assert (Position (Buffer) = 0, "Invalid position in test Get_UInt32 absolute"); Assert (High_Water_Mark (Buffer) = Expected_High_Water_Mark, "Invalid high water mark in test Get_UInt32 absolute"); -- now we read back one of the written values at an absolute position -- that is greater than the current position but not greater than the -- high water mark, which should succeed declare Output : UInt32; begin Buffer.Get_UInt32 (Output, First => Index_After_String); if Output = UInt32_Input then Put_Line ("passed"); else Put_Line ("FAILED (value read /= value written)"); Failed := Failed + 1; end if; end; exception when Error : others => Put_Line (Exception_Message (Error)); Failed := Failed + 1; end; declare String_Input : constant String := "Hello World!"; Expected_High_Water_Mark : constant := 2 + String_Input'Length; -- 2-bytes for string length + length of string Invalid_Index : constant Index := Expected_High_Water_Mark + 1; Buffer : ByteBuffer (Capacity => 100); begin Put ("Get_UInt32 from absolute index > position and > high water mark: "); Buffer.Put_String (String_Input); Buffer.Rewind; Assert (Position (Buffer) = 0, "Invalid position in test Get_UInt32 absolute > high water mark"); Assert (High_Water_Mark (Buffer) = Expected_High_Water_Mark, "Invalid high water mark in test Get_UInt32 absolute > high water mark"); -- now we read back from an index greater than the high water mark, which should fail declare Output : UInt32; begin Buffer.Get_UInt32 (Output, First => Invalid_Index); Put_Line ("FAILED (should have raised Assertion_Error)"); Failed := Failed + 1; exception when Assertion_Error => Put_Line ("passed"); end; exception when Error : others => Put_Line (Exception_Message (Error)); Failed := Failed + 1; end; -- strings ------------------------------------------------------------------ declare C : constant := 100; -- arbitrary B : ByteBuffer (Capacity => C); S : constant String (1 .. C + 1) := (others => 'x'); begin Put ("Inserting string with length > capacity: "); B.Put_String (S); Put_Line ("FAILED (should have raised Assertion_Error)"); Failed := Failed + 1; exception when Assertion_Error => Put_Line ("passed"); when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare C : constant := 100; -- arbitrary B : ByteBuffer (Capacity => C); L : constant := C - 2; -- leave room for length inserted into buffer too S : constant String (1 .. L) := (others => 'x'); begin Put ("Inserting string with length < capacity: "); B.Put_String (S); Put_Line ("passed"); exception when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare C : constant := UInt16'Last; B : ByteBuffer (Capacity => C + 2); S : constant String (1 .. Integer (UInt16'Last) + 1) := (others => 'x'); begin Put ("Inserting string with length > UInt16'Last, with sufficient capacity: "); B.Put_String (S); Put_Line ("FAILED (should have raised Assertion_Error)"); Failed := Failed + 1; exception when Assertion_Error => Put_Line ("passed"); when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare C : constant := UInt16'Last; B : ByteBuffer (Capacity => C + 2); S : constant String (1 .. Integer (UInt16'Last)) := (others => 'x'); begin Put ("Inserting string with length = UInt16'Last, with sufficient capacity: "); B.Put_String (S); Put_Line ("passed"); exception when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; -- getting Strings ---------------------------------------------------------- declare C : constant := 100; -- arbitrary B : ByteBuffer (Capacity => C); Corrupted_String_Length : constant := C + 1; -- anything > C will do S : String (1 .. Corrupted_String_Length); Last : Integer; Unused : UInt32; begin Put ("Getting string with stored length > remaining bytes in message: "); -- Write a value that Get_String is going to read as the length of the -- string in the message. The value must be > buffer capacity. B.Put_UInt16 (Corrupted_String_Length); -- Prepare to start getting values as if a message is in the buffer, -- starting with a string. The actual characters are immaterial so we -- don't bother to insert them into the buffer. -- -- Note that this wouldn't happen without some sort of buffer -- corruption because Put_String would have failed when attempting to -- write that any chars into the buffer (since we know the buffer isn't -- big enough in this test, on purpose). B.Rewind; B.Get_String (S, Last, Unused); pragma Assert (B.Position = 2); pragma Assert (Last = -1); Put_Line ("passed"); exception when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; -- the case in which stored length > string arg length AND we just set Last to -1 declare C : constant := 10; -- arbitrary B : ByteBuffer (Capacity => C); Written : constant String (1 .. 8) := "helloyou"; Read : String (1 .. 5) := (others => ' '); Last : Integer; Stored_Length : UInt32; begin Put ("Getting string with stored length > arg length: "); B.Put_String (Written); B.Rewind; B.Get_String (Read, Last, Stored_Length); if Last /= -1 then Put_Line ("failed (incorrect value for Last)"); Failed := Failed + 1; elsif B.Position /= 2 then Put_Line ("failed (wrong Position)"); Failed := Failed + 1; else Put_Line ("passed"); end if; exception when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare C : constant := 100; -- arbitrary B : ByteBuffer (Capacity => C); Written : constant String (1 .. 5) := "world"; Read : String (1 .. 10) := (others => ' '); Last : Integer; Unused : UInt32; begin Put ("Getting string with stored length < arg length: "); B.Put_String (Written); -- prepare to start getting values as if a message is in the buffer, -- starting with a string B.Rewind; B.Get_String (Read, Last, Unused); if Last /= Written'Length then Put_Line ("failed (incorrect value for Last)"); Failed := Failed + 1; elsif Read (1 .. Last) = Written then Put_Line ("passed"); else Put_Line ("failed (incorrect value read)"); Failed := Failed + 1; end if; exception when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; -- writing unbounded strings ------------------------------------------------- declare C : constant := 100; -- arbitrary B : ByteBuffer (Capacity => C); L : constant := C + 1; S : constant ASU.Unbounded_String := ASU.To_Unbounded_String (Source => String'(1 .. L => 'x')); begin Put ("Inserting unbounded string with length > capacity: "); B.Put_Unbounded_String (S); Put_Line ("FAILED (should have raised Assertion_Error)"); Failed := Failed + 1; exception when Assertion_Error => Put_Line ("passed"); when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare C : constant := 100; -- arbitrary L : constant := C - 2; -- leave room for length inserted into buffer too B : ByteBuffer (Capacity => C); S : constant ASU.Unbounded_String := ASU.To_Unbounded_String (Source => String'(1 .. L => 'x')); begin Put ("Inserting unbounded string with length < capacity: "); B.Put_Unbounded_String (S); Put_Line ("passed"); exception when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare C : constant := UInt16'Last; B : ByteBuffer (Capacity => C + 2); L : constant := Integer (C) + 1; S : constant ASU.Unbounded_String := ASU.To_Unbounded_String (Source => String'(1 .. L => 'x')); begin Put ("Inserting unbounded string with length > UInt16'Last, with sufficient capacity: "); B.Put_Unbounded_String (S); Put_Line ("FAILED (should have raised Assertion_Error)"); Failed := Failed + 1; exception when Assertion_Error => Put_Line ("passed"); when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare C : constant := 2; -- the 2 bytes for the string's bounds B : ByteBuffer (Capacity => C); L : constant := 0; S : constant ASU.Unbounded_String := ASU.To_Unbounded_String (Source => String'(1 .. L => 'x')); begin Put ("Inserting unbounded string with length = 0, with sufficient capacity: "); B.Put_Unbounded_String (S); Put_Line ("passed"); exception when Assertion_Error => Put_Line ("FAILED (raised Assertion_Error)"); Failed := Failed + 1; when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare C : constant := 1; -- less than the 2 bytes for the string's bounds B : ByteBuffer (Capacity => C); L : constant := 0; S : constant ASU.Unbounded_String := ASU.To_Unbounded_String (Source => String'(1 .. L => 'x')); begin Put ("Inserting unbounded string with length = 0, without sufficient capacity: "); B.Put_Unbounded_String (S); Put_Line ("FAILED"); -- we didn't have room for the bounds Failed := Failed + 1; exception when Assertion_Error => Put_Line ("passed"); when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare C : constant := 100; -- arbitrary L : constant := C - 2; -- leave room for length inserted into buffer too B : ByteBuffer (Capacity => C); S : constant ASU.Unbounded_String := ASU.To_Unbounded_String (Source => String'(1 .. L => 'x')); begin Put ("Inserting unbounded string with length < capacity: "); B.Put_Unbounded_String (S); Put_Line ("passed"); exception when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; -- reading unbounded strings ------------------------------------------------- declare C : constant := Max_String_Length; B : ByteBuffer (Capacity => C + 2); L : constant := Integer (C); S : constant ASU.Unbounded_String := ASU.To_Unbounded_String (Source => String'(1 .. L => 'x')); O : ASU.Unbounded_String := ASU.To_Unbounded_String (Length => L); Num_Stored : UInt32; use ASU; begin Put ("Getting unbounded string with length = Max_String_Length, with sufficient capacity: "); B.Put_Unbounded_String (S); B.Rewind; B.Get_Unbounded_String (O, Num_Stored); if Num_Stored /= Max_String_Length then Put_Line ("failed (num stored mismatch)"); Failed := Failed + 1; elsif O /= S then Put_Line ("failed (content mismatch)"); Failed := Failed + 1; else Put_Line ("passed"); end if; exception when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; -- raw bytes ---------------------------------------------------------------- declare C : constant := 100; -- arbitrary B : ByteBuffer (Capacity => C); S : constant String (1 .. C + 1) := (others => 'x'); begin Put ("Inserting raw bytes from String with length > capacity: "); B.Put_Raw_Bytes (S); Put_Line ("FAILED (should have raised Assertion_Error)"); Failed := Failed + 1; exception when Assertion_Error => Put_Line ("passed"); when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare C : constant := 100; -- arbitrary B : ByteBuffer (Capacity => C); L : constant := C - 2; -- leave room for length inserted into buffer too S : constant String (1 .. L) := (others => 'x'); begin Put ("Inserting raw bytes from String with length < capacity: "); B.Put_Raw_Bytes (S); Put_Line ("passed"); exception when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare B : ByteBuffer (Capacity => Index (UInt16'Last) + 2); S : constant String (1 .. Integer (UInt16'Last) + 1) := (others => 'x'); begin Put ("Inserting raw bytes from String with length > UInt16'Last, with sufficient capacity: "); B.Put_Raw_Bytes (S); Put_Line ("failed"); Failed := Failed + 1; exception when Assertion_Error => Put_Line ("passed"); when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare C : constant := 100; -- arbitrary B : ByteBuffer (Capacity => C); L : constant := C - 2; -- leave room for length inserted into buffer too S : constant Byte_Array (1 .. L) := (others => Character'Pos ('x')); begin Put ("Inserting raw bytes with length < capacity: "); B.Put_Raw_Bytes (S); Put_Line ("passed"); exception when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; declare C : constant := UInt32 (Positive'Last) + 10; type ByteBuffer_Pointer is access ByteBuffer; BBP : constant ByteBuffer_Pointer := new ByteBuffer (C); L : constant := Positive'Last; type Byte_Array_Pointer is access Byte_Array (1 .. L); BAP : constant Byte_Array_Pointer := new Byte_Array'(1 .. L => Character'Pos ('x')); begin Put ("Inserting raw bytes with length = Positive'Last: "); BBP.Put_Raw_Bytes (BAP.all); Put_Line ("passed"); exception when Error : others => Put_Line (Exception_Information (Error)); Failed := Failed + 1; end; -- sequence of writes followed by sequence of reads ------------------------ declare Byte_Input : constant Byte := 42; String_Input : constant String := "Hello World!"; UInt32_Input : constant UInt32 := 42; Real32_Input : constant Real32 := 42.42; Boolean_Input : constant Boolean := True; UInt64_Input : constant UInt64 := 84; Buffer : ByteBuffer (Capacity => 1024); begin Put ("Multiple writes folowed by reads of those written values: "); -- NB: the order of the following must match the order of the calls to Get_* below Buffer.Put_Byte (Byte_Input); Buffer.Put_String (String_Input); Buffer.Put_UInt32 (UInt32_Input); Buffer.Put_Unbounded_String (ASU.To_Unbounded_String (String_Input)); Buffer.Put_Real32 (Real32_Input); Buffer.Put_Boolean (Boolean_Input); Buffer.Put_UInt64 (UInt64_Input); -- now we read back what was written Buffer.Rewind; declare Output : Byte; begin Buffer.Get_Byte (Output); pragma Assert (Output = Byte_Input, "Getting Byte failed"); end; declare Output : String (String_Input'Range); Last : Natural; Unused : UInt32; begin Buffer.Get_String (Output, Last, Unused); pragma Assert (Last = String_Input'Length, "Getting string Last failed"); pragma Assert (Output (1 .. Last) = String_Input, "Getting string failed"); end; declare Output : UInt32; begin Buffer.Get_UInt32 (Output); pragma Assert (Output = UInt32_Input, "Getting UInt32 failed"); end; declare Output : ASU.Unbounded_String; Num_Stored : UInt32; begin Buffer.Get_Unbounded_String (Output, Num_Stored); pragma Assert (Num_Stored = String_Input'Length, "Getting Unbounded_String failed (stored count mismatch)"); pragma Assert (ASU.To_String (Output) = String_Input, "Getting Unbounded_String failed (content mismatch)"); end; declare Output : Real32; begin Buffer.Get_Real32 (Output); pragma Assert (Output = Real32_Input, "Getting Real32 failed"); end; declare Output : Boolean; begin Buffer.Get_Boolean (Output); pragma Assert (Output = Boolean_Input, "Getting Boolean failed"); end; declare Output : UInt64; begin Buffer.Get_UInt64 (Output); pragma Assert (Output = UInt64_Input, "Getting UInt64 failed"); end; Put_Line ("passed"); exception when Error : others => Put_Line (Exception_Message (Error)); Failed := Failed + 1; end; -- done --------------------------------------------------------------------- New_Line; Put_Line ("Failed Tests:" & Failed'Image); Put_Line ("ByteBuffer testing complete"); end Test_ByteBuffers;
MinimSecure/unum-sdk
Ada
1,115
adb
-- Copyright 2007-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. procedure Foo is begin begin raise Constraint_Error; -- SPOT1 exception when others => null; end; begin raise Program_Error; -- SPOT2 exception when others => null; end; begin pragma Assert (False); -- SPOT3 null; exception when others => null; end; raise Constraint_Error; -- SPOT4 end Foo;