repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
reznikmm/matreshka | Ada | 4,001 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Meta_Value_Type_Attributes;
package Matreshka.ODF_Meta.Value_Type_Attributes is
type Meta_Value_Type_Attribute_Node is
new Matreshka.ODF_Meta.Abstract_Meta_Attribute_Node
and ODF.DOM.Meta_Value_Type_Attributes.ODF_Meta_Value_Type_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Meta_Value_Type_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Meta_Value_Type_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Meta.Value_Type_Attributes;
|
strenkml/EE368 | Ada | 3,144 | adb |
with Ada.Assertions; use Ada.Assertions;
with Memory.Container; use Memory.Container;
package body Memory.Join is
function Create_Join(parent : access Wrapper_Type'Class;
index : Natural) return Join_Pointer is
result : constant Join_Pointer := new Join_Type;
begin
result.parent := parent;
result.index := index;
return result;
end Create_Join;
function Clone(mem : Join_Type) return Memory_Pointer is
result : constant Join_Pointer := new Join_Type'(mem);
begin
return Memory_Pointer(result);
end Clone;
procedure Read(mem : in out Join_Type;
address : in Address_Type;
size : in Positive) is
begin
Forward_Read(mem.parent.all, mem.index, address, size);
end Read;
procedure Write(mem : in out Join_Type;
address : in Address_Type;
size : in Positive) is
begin
Forward_Write(mem.parent.all, mem.index, address, size);
end Write;
function Get_Writes(mem : Join_Type) return Long_Integer is
begin
Assert(False, "Memory.Join.Get_Writes not implemented");
return 0;
end Get_Writes;
function To_String(mem : Join_Type) return Unbounded_String is
begin
return To_Unbounded_String("(join)");
end To_String;
function Get_Cost(mem : Join_Type) return Cost_Type is
begin
return 0;
end Get_Cost;
function Get_Word_Size(mem : Join_Type) return Positive is
begin
return Get_Word_Size(mem.parent.all);
end Get_Word_Size;
function Get_Ports(mem : Join_Type) return Port_Vector_Type is
result : Port_Vector_Type;
begin
Assert(False, "Memory.Join.Get_Ports should not be called");
return result;
end Get_Ports;
procedure Generate(mem : in Join_Type;
sigs : in out Unbounded_String;
code : in out Unbounded_String) is
name : constant String := "m" & To_String(Get_ID(mem));
word_bits : constant Natural := 8 * Get_Word_Size(mem);
begin
Declare_Signals(sigs, name, word_bits);
end Generate;
function Get_Path_Length(mem : Join_Type) return Natural is
next : constant Memory_Pointer := Get_Memory(mem.parent.all);
jl : constant Natural := Get_Join_Length(mem.parent.all);
begin
return jl + Get_Path_Length(next.all);
end Get_Path_Length;
procedure Adjust(mem : in out Join_Type) is
begin
Adjust(Memory_Type(mem));
mem.parent := null;
end Adjust;
procedure Set_Parent(mem : in out Join_Type;
parent : access Wrapper_Type'Class) is
begin
mem.parent := parent;
end Set_Parent;
function Find_Join(mem : Memory_Pointer) return Join_Pointer is
begin
if mem.all in Join_Type'Class then
return Join_Pointer(mem);
else
declare
cp : constant Container_Pointer := Container_Pointer(mem);
begin
return Find_Join(Get_Memory(cp.all));
end;
end if;
end Find_Join;
end Memory.Join;
|
godunko/adawebui | Ada | 3,566 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2018-2020, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision: 5870 $ $Date: 2018-09-22 11:46:16 +0200 (Sat, 22 Sep 2018) $
------------------------------------------------------------------------------
with Web.Core.Connectables.Slots_0.Slots_1;
with Web.UI.Widgets;
package Web.UI.Slots.Widgets is
new Core.Connectables.Slots_0.Slots_1 (Web.UI.Widgets.Widget_Access);
|
reznikmm/matreshka | Ada | 3,694 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Draw_Page_Thumbnail_Elements is
pragma Preelaborate;
type ODF_Draw_Page_Thumbnail is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Draw_Page_Thumbnail_Access is
access all ODF_Draw_Page_Thumbnail'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Page_Thumbnail_Elements;
|
pdaxrom/Kino2 | Ada | 3,631 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Text_IO.Aux --
-- --
-- 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, 1996
-- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
-- Version Control:
-- $Revision: 1.11 $
-- Binding Version 01.00
------------------------------------------------------------------------------
private package Terminal_Interface.Curses.Text_IO.Aux is
-- pragma Preelaborate (Aux);
-- This routine is called from the Text_IO output routines for numeric
-- and enumeration types.
--
procedure Put_Buf
(Win : in Window; -- The output window
Buf : in String; -- The buffer containing the text
Width : in Field; -- The width of the output field
Signal : in Boolean := True; -- If true, we raise Layout_Error
Ljust : in Boolean := False); -- The Buf is left justified
end Terminal_Interface.Curses.Text_IO.Aux;
|
reznikmm/matreshka | Ada | 9,852 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.Visitors.UMLDI_Iterators;
with AMF.Visitors.UMLDI_Visitors;
with League.Strings.Internals;
package body AMF.Internals.UMLDI_UML_Keyword_Labels is
--------------
-- Get_Text --
--------------
overriding function Get_Text
(Self : not null access constant UMLDI_UML_Keyword_Label_Proxy)
return League.Strings.Universal_String is
begin
null;
return
League.Strings.Internals.Create
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Text (Self.Element));
end Get_Text;
--------------
-- Set_Text --
--------------
overriding procedure Set_Text
(Self : not null access UMLDI_UML_Keyword_Label_Proxy;
To : League.Strings.Universal_String) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Text
(Self.Element,
League.Strings.Internals.Internal (To));
end Set_Text;
-----------------
-- Get_Is_Icon --
-----------------
overriding function Get_Is_Icon
(Self : not null access constant UMLDI_UML_Keyword_Label_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Icon
(Self.Element);
end Get_Is_Icon;
-----------------
-- Set_Is_Icon --
-----------------
overriding procedure Set_Is_Icon
(Self : not null access UMLDI_UML_Keyword_Label_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Icon
(Self.Element, To);
end Set_Is_Icon;
---------------------
-- Get_Local_Style --
---------------------
overriding function Get_Local_Style
(Self : not null access constant UMLDI_UML_Keyword_Label_Proxy)
return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access is
begin
return
AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Style
(Self.Element)));
end Get_Local_Style;
---------------------
-- Set_Local_Style --
---------------------
overriding procedure Set_Local_Style
(Self : not null access UMLDI_UML_Keyword_Label_Proxy;
To : AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Local_Style
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Local_Style;
-----------------------
-- Get_Model_Element --
-----------------------
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Keyword_Label_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
raise Program_Error;
return X : AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- return
-- AMF.UML.Elements.Collections.Wrap
-- (AMF.Internals.Element_Collections.Wrap
-- (AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element
-- (Self.Element)));
end Get_Model_Element;
-----------------------
-- Get_Model_Element --
-----------------------
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Keyword_Label_Proxy)
return AMF.CMOF.Elements.CMOF_Element_Access is
begin
return
AMF.CMOF.Elements.CMOF_Element_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element
(Self.Element)));
end Get_Model_Element;
---------------------
-- Get_Local_Style --
---------------------
overriding function Get_Local_Style
(Self : not null access constant UMLDI_UML_Keyword_Label_Proxy)
return AMF.DI.Styles.DI_Style_Access is
begin
return
AMF.DI.Styles.DI_Style_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Style
(Self.Element)));
end Get_Local_Style;
---------------------
-- Set_Local_Style --
---------------------
overriding procedure Set_Local_Style
(Self : not null access UMLDI_UML_Keyword_Label_Proxy;
To : AMF.DI.Styles.DI_Style_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Local_Style
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Local_Style;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UMLDI_UML_Keyword_Label_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class then
AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class
(Visitor).Enter_UML_Keyword_Label
(AMF.UMLDI.UML_Keyword_Labels.UMLDI_UML_Keyword_Label_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UMLDI_UML_Keyword_Label_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class then
AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class
(Visitor).Leave_UML_Keyword_Label
(AMF.UMLDI.UML_Keyword_Labels.UMLDI_UML_Keyword_Label_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UMLDI_UML_Keyword_Label_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.UMLDI_Iterators.UMLDI_Iterator'Class then
AMF.Visitors.UMLDI_Iterators.UMLDI_Iterator'Class
(Iterator).Visit_UML_Keyword_Label
(Visitor,
AMF.UMLDI.UML_Keyword_Labels.UMLDI_UML_Keyword_Label_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.UMLDI_UML_Keyword_Labels;
|
Fabien-Chouteau/lvgl-ada | Ada | 7,116 | ads | with Lv.Style;
with Lv.Area;
with Lv.Objx.Page;
with Lv.Objx.Btn;
with Lv.Objx.Cont;
with System;
package Lv.Objx.Win is
subtype Instance is Obj_T;
type Style_T is (Style_Bg,
Style_Content_Bg,
Style_Content_Scrl,
Style_Sb,
Style_Header,
Style_Btn_Rel,
Style_Btn_Pr);
-- Create a window objects
-- @param par pointer to an object, it will be the parent of the new window
-- @param copy pointer to a window object, if not NULL then the new object will be copied from it
-- @return pointer to the created window
function Create (Parent : Obj_T; Copy : Instance) return Instance;
-- Delete all children of the scrl object, without deleting scrl child.
-- @param self pointer to an object
procedure Clean (Self : Instance);
-- Add control button to the header of the window
-- @param self pointer to a window object
-- @param img_src an image source ('lv_img_t' variable, path to file or a symbol)
-- @param rel_action a function pointer to call when the button is released
-- @return pointer to the created button object
function Add_Btn
(Self : Instance;
Img_Src : System.Address;
Rel_Action : Action_Func_T) return Btn.Instance;
-- A release action which can be assigned to a window control button to close it
-- @param btn pointer to the released button
-- @return always LV_ACTION_RES_INV because the button is deleted with the window
function Close_Action (Self : Instance) return Res_T;
----------------------
-- Setter functions --
----------------------
-- Set the title of a window
-- @param self pointer to a window object
-- @param title string of the new title
procedure Set_Title
(Self : Instance;
Title : C_String_Ptr);
-- Set the control button size of a window
-- @param self pointer to a window object
-- @return control button size
procedure Set_Btn_Size (Self : Instance; Size : Lv.Area.Coord_T);
-- Set the layout of the window
-- @param self pointer to a window object
-- @param layout the layout from 'lv_layout_t'
procedure Set_Layout (Self : Instance; Layout : Lv.Objx.Cont.Layout_T);
-- Set the scroll bar mode of a window
-- @param self pointer to a window object
-- @param sb_mode the new scroll bar mode from 'lv_sb_mode_t'
procedure Set_Sb_Mode (Self : Instance; Sb_Mode : Lv.Objx.Page.Mode_T);
-- Set a style of a window
-- @param self pointer to a window object
-- @param type which style should be set
-- @param style pointer to a style
procedure Set_Style
(Self : Instance;
Type_P : Style_T;
Style : Lv.Style.Style);
----------------------
-- Getter functions --
----------------------
-- Get the title of a window
-- @param self pointer to a window object
-- @return title string of the window
function Title (Self : Instance) return C_String_Ptr;
-- Get the content holder object of window (`lv_page`) to allow additional customization
-- @param self pointer to a window object
-- @return the Page object where the window's content is
function Content (Self : Instance) return Page.Instance;
-- Get the control button size of a window
-- @param self pointer to a window object
-- @return control button size
function Btn_Size (Self : Instance) return Lv.Area.Coord_T;
-- Get the pointer of a widow from one of its control button.
-- It is useful in the action of the control buttons where only button is known.
-- @param ctrl_btn pointer to a control button of a window
-- @return pointer to the window of 'ctrl_btn'
function From_Btn (Ctrl_Btn : Btn.Instance) return Instance;
-- Get the layout of a window
-- @param self pointer to a window object
-- @return the layout of the window (from 'lv_layout_t')
function Layout (Self : Instance) return Lv.Objx.Cont.Layout_T;
-- Get the scroll bar mode of a window
-- @param self pointer to a window object
-- @return the scroll bar mode of the window (from 'lv_sb_mode_t')
function Sb_Mode (Self : Instance) return Lv.Objx.Page.Mode_T;
-- Get width of the content area (page scrollable) of the window
-- @param self pointer to a window object
-- @return the width of the content area
function Width (Self : Instance) return Lv.Area.Coord_T;
-- Get a style of a window
-- @param self pointer to a button object
-- @param type which style window be get
-- @return style pointer to a style
function Style
(Self : Instance;
Type_P : Style_T) return Lv.Style.Style;
---------------------
-- Other functions --
---------------------
-- Focus on an object. It ensures that the object will be visible in the window.
-- @param self pointer to a window object
-- @param obj pointer to an object to focus (must be in the window)
-- @param anim_time scroll animation time in milliseconds (0: no animation)
procedure Focus (Self : Instance; Obj : Obj_T; Anim_Time : Uint16_T);
-- Scroll the window horizontally
-- @param self pointer to a window object
-- @param dist the distance to scroll (< 0: scroll right; > 0 scroll left)
procedure Scroll_Hor (Self : Instance; Dist : Lv.Area.Coord_T);
-- Scroll the window vertically
-- @param self pointer to a window object
-- @param dist the distance to scroll (< 0: scroll down; > 0 scroll up)
procedure Scroll_Ver (Self : Instance; Dist : Lv.Area.Coord_T);
-------------
-- Imports --
-------------
pragma Import (C, Create, "lv_win_create");
pragma Import (C, Clean, "lv_win_clean");
pragma Import (C, Add_Btn, "lv_win_add_btn");
pragma Import (C, Close_Action, "lv_win_close_action");
pragma Import (C, Set_Title, "lv_win_set_title");
pragma Import (C, Set_Btn_Size, "lv_win_set_btn_size");
pragma Import (C, Set_Layout, "lv_win_set_layout");
pragma Import (C, Set_Sb_Mode, "lv_win_set_sb_mode");
pragma Import (C, Set_Style, "lv_win_set_style");
pragma Import (C, Title, "lv_win_get_title");
pragma Import (C, Content, "lv_win_get_content");
pragma Import (C, Btn_Size, "lv_win_get_btn_size");
pragma Import (C, From_Btn, "lv_win_get_from_btn");
pragma Import (C, Layout, "lv_win_get_layout");
pragma Import (C, Sb_Mode, "lv_win_get_sb_mode");
pragma Import (C, Width, "lv_win_get_width");
pragma Import (C, Style, "lv_win_get_style");
pragma Import (C, Focus, "lv_win_focus");
pragma Import (C, Scroll_Hor, "lv_win_scroll_hor_inline");
pragma Import (C, Scroll_Ver, "lv_win_scroll_ver_inline");
for Style_T'Size use 8;
for Style_T use (Style_Bg => 0,
Style_Content_Bg => 1,
Style_Content_Scrl => 2,
Style_Sb => 3,
Style_Header => 4,
Style_Btn_Rel => 5,
Style_Btn_Pr => 6);
end Lv.Objx.Win;
|
erik/ada-irc | Ada | 1,582 | ads | -- This package contains the records of messages received from the
-- server in a convenient format.
with Ada.Strings.Unbounded;
package Irc.Message is
package SU renames Ada.Strings.Unbounded;
use type SU.Unbounded_String;
-- Available automatically from Irc.Message.Message when received
-- message is a PRIVMSG
type Privmsg_Message is tagged record
Target : SU.Unbounded_String; -- nick/chan message was sent to
Content : SU.Unbounded_String; -- content of the privmsg
end record;
-- Base message record, returned from Parse_Line, and passed
-- around to handle commands, reply, etc.
type Message is tagged record
Sender : SU.Unbounded_String; -- When a command is sent from the
-- server (PING, etc.) this will be
-- an empty string.
Command : SU.Unbounded_String;
Args : SU.Unbounded_String;
Privmsg : Privmsg_Message; -- Only exists when a PRIVMSG is sent
end record;
-- Given a line received from the server, parses and returns a
-- Message record. Will raise Parse_Error if the message is in an
-- unknown format.
function Parse_Line (Line : in SU.Unbounded_String) return Message;
-- Prints the message out to stdout in a readable format.
-- Currently it is: Sender & "» " & Command & " " & Args
procedure Print (This : Message);
-- Raised by Parse_Line on bad lines.
Parse_Error : exception;
private
procedure Parse_Privmsg (Msg : in out Message);
end Irc.Message;
|
reznikmm/matreshka | Ada | 4,107 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Style_Border_Line_Width_Left_Attributes;
package Matreshka.ODF_Style.Border_Line_Width_Left_Attributes is
type Style_Border_Line_Width_Left_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Border_Line_Width_Left_Attributes.ODF_Style_Border_Line_Width_Left_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Border_Line_Width_Left_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Border_Line_Width_Left_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Border_Line_Width_Left_Attributes;
|
damaki/libkeccak | Ada | 5,597 | ads | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
-- @summary
-- Variants for twisted Keccak-p permutations.
--
-- @group Keccak-f
generic
-- Bit-wise left shift for Lane_Type.
with function Shift_Left (Value : in Lane_Type;
Amount : in Natural) return Lane_Type;
-- Bit-wise right shift for Lane_Type.
with function Shift_Right (Value : in Lane_Type;
Amount : in Natural) return Lane_Type;
package Keccak.Generic_KeccakF.Byte_Lanes.Twisted is
procedure XOR_Bits_Into_State_Twisted (A : in out State;
Data : in Keccak.Types.Byte_Array;
Bit_Len : in Natural)
with Global => null,
Depends => (A =>+ (Data, Bit_Len)),
Pre => (Bit_Len <= State_Size_Bits
and then (Bit_Len + 7) / 8 <= Data'Length);
-- Version of XOR_Bits_Into_State for Twisted Keccak-p
procedure XOR_Bits_Into_State_Twisted (A : in out Lane_Complemented_State;
Data : in Keccak.Types.Byte_Array;
Bit_Len : in Natural)
with Inline,
Global => null,
Depends => (A =>+ (Data, Bit_Len)),
Pre => (Bit_Len <= State_Size_Bits
and then (Bit_Len + 7) / 8 <= Data'Length);
-- Version of XOR_Bits_Into_State for Twisted Keccak-p
procedure XOR_Byte_Into_State_Twisted (A : in out State;
Offset : in Natural;
Value : in Keccak.Types.Byte)
with Global => null,
Depends => (A =>+ (Offset, Value)),
Pre => Offset < (State_Size_Bits + 7) / 8;
procedure XOR_Byte_Into_State_Twisted (A : in out Lane_Complemented_State;
Offset : in Natural;
Value : in Keccak.Types.Byte)
with Global => null,
Depends => (A =>+ (Offset, Value)),
Pre => Offset < (State_Size_Bits + 7) / 8;
procedure Extract_Bytes_Twisted (A : in State;
Data : out Keccak.Types.Byte_Array)
with Global => null,
Depends => (Data =>+ A),
Pre => Data'Length <= ((State_Size_Bits + 7) / 8);
pragma Annotate
(GNATprove, False_Positive,
"""Data"" might not be initialized",
"GNATprove issues a false positive due to the use of loops to initialize Data");
-- Twisted version of Extract_Bytes
procedure Extract_Bytes_Twisted (A : in Lane_Complemented_State;
Data : out Keccak.Types.Byte_Array)
with Global => null,
Depends => (Data =>+ A),
Pre => Data'Length <= ((State_Size_Bits + 7) / 8);
pragma Annotate
(GNATprove, False_Positive,
"""Data"" might not be initialized",
"GNATprove issues a false positive due to the use of loops to initialize Data");
-- Twisted version of Extract_Bytes
procedure Extract_Bits_Twisted (A : in State;
Data : out Keccak.Types.Byte_Array;
Bit_Len : in Natural)
with Global => null,
Depends => (Data =>+ (A, Bit_Len)),
Pre => (Bit_Len <= State_Size_Bits
and then Data'Length = (Bit_Len + 7) / 8);
-- Twisted version of Extract_Bits
procedure Extract_Bits_Twisted (A : in Lane_Complemented_State;
Data : out Keccak.Types.Byte_Array;
Bit_Len : in Natural)
with Global => null,
Depends => (Data =>+ (A, Bit_Len)),
Pre => (Bit_Len <= State_Size_Bits
and then Data'Length = (Bit_Len + 7) / 8);
-- Twisted version of Extract_Bits
end Keccak.Generic_KeccakF.Byte_Lanes.Twisted;
|
reznikmm/matreshka | Ada | 17,950 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Named_Elements;
with AMF.UML.Activities;
with AMF.UML.Activity_Edges.Collections;
with AMF.UML.Activity_Groups.Collections;
with AMF.UML.Activity_Nodes.Collections;
with AMF.UML.Activity_Partitions.Collections;
with AMF.UML.Behaviors;
with AMF.UML.Central_Buffer_Nodes;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Interruptible_Activity_Regions.Collections;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces;
with AMF.UML.Packages.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.States.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Structured_Activity_Nodes;
with AMF.UML.Types;
with AMF.UML.Value_Specifications;
with AMF.Visitors;
package AMF.Internals.UML_Central_Buffer_Nodes is
type UML_Central_Buffer_Node_Proxy is
limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy
and AMF.UML.Central_Buffer_Nodes.UML_Central_Buffer_Node with null record;
overriding function Get_In_State
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.States.Collections.Set_Of_UML_State;
-- Getter of ObjectNode::inState.
--
-- The required states of the object available at this point in the
-- activity.
overriding function Get_Is_Control_Type
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return Boolean;
-- Getter of ObjectNode::isControlType.
--
-- Tells whether the type of the object node is to be treated as control.
overriding procedure Set_Is_Control_Type
(Self : not null access UML_Central_Buffer_Node_Proxy;
To : Boolean);
-- Setter of ObjectNode::isControlType.
--
-- Tells whether the type of the object node is to be treated as control.
overriding function Get_Ordering
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.UML_Object_Node_Ordering_Kind;
-- Getter of ObjectNode::ordering.
--
-- Tells whether and how the tokens in the object node are ordered for
-- selection to traverse edges outgoing from the object node.
overriding procedure Set_Ordering
(Self : not null access UML_Central_Buffer_Node_Proxy;
To : AMF.UML.UML_Object_Node_Ordering_Kind);
-- Setter of ObjectNode::ordering.
--
-- Tells whether and how the tokens in the object node are ordered for
-- selection to traverse edges outgoing from the object node.
overriding function Get_Selection
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Behaviors.UML_Behavior_Access;
-- Getter of ObjectNode::selection.
--
-- Selects tokens for outgoing edges.
overriding procedure Set_Selection
(Self : not null access UML_Central_Buffer_Node_Proxy;
To : AMF.UML.Behaviors.UML_Behavior_Access);
-- Setter of ObjectNode::selection.
--
-- Selects tokens for outgoing edges.
overriding function Get_Upper_Bound
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access;
-- Getter of ObjectNode::upperBound.
--
-- The maximum number of tokens allowed in the node. Objects cannot flow
-- into the node if the upper bound is reached.
overriding procedure Set_Upper_Bound
(Self : not null access UML_Central_Buffer_Node_Proxy;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access);
-- Setter of ObjectNode::upperBound.
--
-- The maximum number of tokens allowed in the node. Objects cannot flow
-- into the node if the upper bound is reached.
overriding function Get_Activity
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Activities.UML_Activity_Access;
-- Getter of ActivityNode::activity.
--
-- Activity containing the node.
overriding procedure Set_Activity
(Self : not null access UML_Central_Buffer_Node_Proxy;
To : AMF.UML.Activities.UML_Activity_Access);
-- Setter of ActivityNode::activity.
--
-- Activity containing the node.
overriding function Get_In_Group
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group;
-- Getter of ActivityNode::inGroup.
--
-- Groups containing the node.
overriding function Get_In_Interruptible_Region
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region;
-- Getter of ActivityNode::inInterruptibleRegion.
--
-- Interruptible regions containing the node.
overriding function Get_In_Partition
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition;
-- Getter of ActivityNode::inPartition.
--
-- Partitions containing the node.
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access;
-- Getter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Central_Buffer_Node_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access);
-- Setter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding function Get_Incoming
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::incoming.
--
-- Edges that have the node as target.
overriding function Get_Outgoing
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::outgoing.
--
-- Edges that have the node as source.
overriding function Get_Redefined_Node
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node;
-- Getter of ActivityNode::redefinedNode.
--
-- Inherited nodes replaced by this node in a specialization of the
-- activity.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Central_Buffer_Node_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Central_Buffer_Node_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Get_Type
(Self : not null access constant UML_Central_Buffer_Node_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_Central_Buffer_Node_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 Is_Consistent_With
(Self : not null access constant UML_Central_Buffer_Node_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Central_Buffer_Node_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding function All_Owning_Packages
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Central_Buffer_Node_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Central_Buffer_Node_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding procedure Enter_Element
(Self : not null access constant UML_Central_Buffer_Node_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Central_Buffer_Node_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Central_Buffer_Node_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Central_Buffer_Nodes;
|
stcarrez/dynamo | Ada | 25,171 | adb | -----------------------------------------------------------------------
-- gen-commands-templates -- Template based command
-- Copyright (C) 2011 - 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.Text_IO;
with Ada.IO_Exceptions;
with Ada.Directories;
with Ada.Streams.Stream_IO;
with GNAT.Command_Line;
with Gen.Artifacts;
with EL.Utils;
with EL.Contexts.Default;
with EL.Functions.Namespaces;
with ASF.Contexts.Faces;
with ASF.Views.Nodes.Core;
with ASF.Beans.Resolvers;
with Util.Log.Loggers;
with Util.Files;
with Util.Streams.Files;
with Util.Streams.Texts;
with Util.Beans.Objects;
with Util.Serialize.Mappers.Record_Mapper;
with Util.Serialize.IO.XML;
package body Gen.Commands.Templates is
use Ada.Strings.Unbounded;
use GNAT.Command_Line;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Gen.Commands.Templates");
-- Apply the patch instruction
procedure Patch_File (Generator : in out Gen.Generator.Handler;
Info : in Patch);
function Match_Line (Line : in String;
Pattern : in String) return Boolean;
-- Check that the line does not match any of the pattern defined in the missing list.
-- Returns True if the line matches one of the pattern and False if there is no match.
function Match_Missing (Line : in String;
Missing : in Util.Strings.Vectors.Vector) return Boolean;
-- Expand a vector of strings by evaluating the EL expressions against the EL context
-- and appending the result into the target list.
procedure Expand (Source : in Util.Strings.Vectors.Vector;
Into : in out Util.Strings.Vectors.Vector;
Context : in EL.Contexts.ELContext'Class);
-- Setup the EL context to evaluate some EL expression by using the generator's
-- context and evaluate a number of EL expression by using the Process procedure.
procedure Evaluate (Generator : in out Gen.Generator.Handler;
Process : access procedure (Context : in EL.Contexts.ELContext'Class));
-- ------------------------------
-- Check if the line matches the pseudo pattern.
-- ------------------------------
function Match_Line (Line : in String;
Pattern : in String) return Boolean is
L_Pos : Natural := Line'First;
P_Pos : Natural := Pattern'First;
begin
-- Skip spaces in the line if the pattern does not start with a space.
if Pattern (P_Pos) /= ' ' then
while L_Pos <= Line'Last and then Line (L_Pos) = ' ' loop
L_Pos := L_Pos + 1;
end loop;
end if;
while P_Pos <= Pattern'Last loop
if L_Pos > Line'Last then
return False;
end if;
if Line (L_Pos) = Pattern (P_Pos) then
if Pattern (P_Pos) /= ' ' then
P_Pos := P_Pos + 1;
end if;
L_Pos := L_Pos + 1;
elsif Pattern (P_Pos) = ' ' and then Line (L_Pos) = Pattern (P_Pos + 1) then
P_Pos := P_Pos + 2;
L_Pos := L_Pos + 1;
elsif Pattern (P_Pos) = ' ' and then Pattern (P_Pos + 1) = '*' then
P_Pos := P_Pos + 1;
L_Pos := L_Pos + 1;
elsif Pattern (P_Pos) = '*' and then Line (L_Pos) = Pattern (P_Pos + 1) then
P_Pos := P_Pos + 2;
L_Pos := L_Pos + 1;
elsif Pattern (P_Pos) = '*' and then Line (L_Pos) /= ' ' then
L_Pos := L_Pos + 1;
else
return False;
end if;
end loop;
return True;
end Match_Line;
-- ------------------------------
-- Check that the line does not match any of the pattern defined in the missing list.
-- Returns True if the line matches one of the pattern and False if there is no match.
-- ------------------------------
function Match_Missing (Line : in String;
Missing : in Util.Strings.Vectors.Vector) return Boolean is
Iter : Util.Strings.Vectors.Cursor := Missing.First;
begin
while Util.Strings.Vectors.Has_Element (Iter) loop
declare
Match : constant String := Util.Strings.Vectors.Element (Iter);
begin
if Match_Line (Line, Match) then
return True;
end if;
Log.Debug ("Check {0} - {1}", Match, Line);
Util.Strings.Vectors.Next (Iter);
end;
end loop;
return False;
end Match_Missing;
-- ------------------------------
-- Expand a vector of strings by evaluating the EL expressions against the EL context
-- and appending the result into the target list.
-- ------------------------------
procedure Expand (Source : in Util.Strings.Vectors.Vector;
Into : in out Util.Strings.Vectors.Vector;
Context : in EL.Contexts.ELContext'Class) is
Iter : Util.Strings.Vectors.Cursor := Source.First;
begin
while Util.Strings.Vectors.Has_Element (Iter) loop
Into.Append (EL.Utils.Eval (Util.Strings.Vectors.Element (Iter), Context));
Util.Strings.Vectors.Next (Iter);
end loop;
end Expand;
-- ------------------------------
-- Setup the EL context to evaluate some EL expression by using the generator's
-- context and evaluate a number of EL expression by using the Process procedure.
-- ------------------------------
procedure Evaluate (Generator : in out Gen.Generator.Handler;
Process : access procedure (Context : in EL.Contexts.ELContext'Class)) is
Context : aliased ASF.Contexts.Faces.Faces_Context;
ELContext : aliased EL.Contexts.Default.Default_Context;
NS_Mapper : aliased EL.Functions.Namespaces.NS_Function_Mapper;
Root_Resolver : aliased ASF.Beans.Resolvers.ELResolver;
begin
-- Build the EL context to evaluate the patterns that must be verified.
-- This allows a pattern to match the module name or application name for example.
Root_Resolver.Initialize (Generator'Unchecked_Access, null);
ELContext.Set_Resolver (Root_Resolver'Unchecked_Access);
NS_Mapper.Set_Namespace (Prefix => "fn",
URI => ASF.Views.Nodes.Core.FN_URI);
NS_Mapper.Set_Namespace (Prefix => "g",
URI => Gen.Generator.G_URI);
Context.Set_ELContext (ELContext'Unchecked_Access);
Generator.Set_Context (Context'Unchecked_Access);
NS_Mapper.Set_Function_Mapper (ELContext.Get_Function_Mapper.all'Access);
ELContext.Set_Function_Mapper (NS_Mapper'Unchecked_Access);
Process (ELContext);
end Evaluate;
-- ------------------------------
-- Apply the patch instruction
-- ------------------------------
procedure Patch_File (Generator : in out Gen.Generator.Handler;
Info : in Patch) is
procedure Save_Output (H : in out Gen.Generator.Handler;
File : in String;
Content : in UString);
procedure Save_Output (H : in out Gen.Generator.Handler;
File : in String;
Content : in UString) is
type State is (MATCH_AFTER, MATCH_BEFORE, MATCH_DONE, MATCH_FAIL);
procedure Process (Line : in String);
procedure Expand (Context : in EL.Contexts.ELContext'Class);
Output_Dir : constant String := H.Get_Result_Directory;
Path : constant String := Util.Files.Compose (Output_Dir, File);
Tmp_File : constant String := Path & ".tmp";
Line_Number : Natural := 0;
After_Pos : Natural := 1;
Current_State : State := MATCH_AFTER;
Tmp_Output : aliased Util.Streams.Files.File_Stream;
Output : Util.Streams.Texts.Print_Stream;
Missing : Util.Strings.Vectors.Vector;
After : Util.Strings.Vectors.Vector;
Before : UString;
procedure Process (Line : in String) is
begin
Line_Number := Line_Number + 1;
case Current_State is
when MATCH_AFTER =>
if Match_Line (Line, After.Element (After_Pos)) then
Log.Info ("Match after at line {0}", Natural'Image (Line_Number));
After_Pos := After_Pos + 1;
if After_Pos > Natural (After.Length) then
Current_State := MATCH_BEFORE;
end if;
end if;
when MATCH_BEFORE =>
if Match_Missing (Line, Missing) then
Log.Info ("Match missing at line {0}", Natural'Image (Line_Number));
Current_State := MATCH_FAIL;
elsif Match_Line (Line, To_String (Before)) then
if Length (Info.Title) > 0 then
H.Info ("Patching file {0} at line {1}: {2}",
Path, Natural'Image (Line_Number), To_String (Info.Title));
else
H.Info ("Patching file {0} at line {1}", Path, Natural'Image (Line_Number));
end if;
Log.Info ("Add content {0}", Content);
Output.Write (Content);
Current_State := MATCH_DONE;
end if;
when MATCH_DONE | MATCH_FAIL =>
null;
end case;
Output.Write (Line);
Output.Write (ASCII.LF);
end Process;
-- ------------------------------
-- Expand the patterns.
-- ------------------------------
procedure Expand (Context : in EL.Contexts.ELContext'Class) is
begin
Expand (Info.Missing, Missing, Context);
Expand (Info.After, After, Context);
Before := To_UString (EL.Utils.Eval (To_String (Info.Before), Context));
end Expand;
begin
Evaluate (Generator, Expand'Access);
Tmp_Output.Create (Name => Tmp_File, Mode => Ada.Streams.Stream_IO.Out_File);
Output.Initialize (Tmp_Output'Unchecked_Access);
-- If the after pattern list is empty, start the missing/before check.
if After.Is_Empty then
Current_State := MATCH_BEFORE;
end if;
-- Read the file line by line and check the after/missing/before patterns.
Util.Files.Read_File (Path, Process'Access);
Output.Close;
if Current_State /= MATCH_DONE then
if not Info.Optional then
if Length (Info.Title) > 0 then
H.Error ("Patch {0} on {1} failed", To_String (Info.Title), Path);
else
H.Error ("Patch {0} failed", Path);
end if;
end if;
Ada.Directories.Delete_File (Tmp_File);
else
Ada.Directories.Delete_File (Path);
Ada.Directories.Rename (Old_Name => Tmp_File,
New_Name => Path);
end if;
exception
when Ada.IO_Exceptions.Name_Error =>
H.Error ("Cannot patch file {0}", Path);
end Save_Output;
begin
Gen.Generator.Generate (Generator, Gen.Artifacts.ITERATION_TABLE,
To_String (Info.Template), Save_Output'Access);
end Patch_File;
-- ------------------------------
-- Execute the command with the arguments.
-- ------------------------------
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler) is
pragma Unreferenced (Name, Args);
function Get_Output_Dir return String;
procedure Expand_Arguments (Context : in EL.Contexts.ELContext'Class);
PARAM_ERROR : exception;
function Get_Output_Dir return String is
Dir : constant String := Generator.Get_Result_Directory;
begin
if Length (Cmd.Base_Dir) = 0 then
return Dir;
else
return Util.Files.Compose (Dir, To_String (Cmd.Base_Dir));
end if;
end Get_Output_Dir;
-- ------------------------------
-- Expand the command line arguments and setup the template global variables
-- before processing the template expansion. The parameters are evaluated in
-- the order defined in the XML file. By setting a global variable with Set_Global
-- the context is changed and the new variable is made available for further evaluations.
-- ------------------------------
procedure Expand_Arguments (Context : in EL.Contexts.ELContext'Class) is
Iter : Param_Vectors.Cursor := Cmd.Params.First;
begin
while Param_Vectors.Has_Element (Iter) loop
declare
P : constant Param := Param_Vectors.Element (Iter);
Value : constant String := Get_Argument;
Result : Util.Beans.Objects.Object;
begin
if P.Value /= Null_Unbounded_String then
Result := EL.Utils.Eval (To_String (P.Value), Context);
elsif not P.Is_Optional and then Value'Length = 0 then
Generator.Error ("Missing argument for {0}", To_String (P.Argument));
raise PARAM_ERROR;
elsif Value'Length /= 0 then
Result := Util.Beans.Objects.To_Object (Value);
end if;
if not P.Is_Optional and then not Util.Beans.Objects.Is_Null (Result) then
Generator.Set_Global (To_String (P.Name), Result);
end if;
end;
Param_Vectors.Next (Iter);
end loop;
end Expand_Arguments;
Out_Dir : constant String := Get_Output_Dir;
begin
Generator.Read_Project ("dynamo.xml", False);
Evaluate (Generator, Expand_Arguments'Access);
Generator.Set_Force_Save (False);
Generator.Set_Result_Directory (Out_Dir);
declare
Iter : Util.Strings.Sets.Cursor := Cmd.Templates.First;
begin
while Util.Strings.Sets.Has_Element (Iter) loop
Gen.Generator.Generate (Generator, Gen.Artifacts.ITERATION_TABLE,
Util.Strings.Sets.Element (Iter),
Gen.Generator.Save_Content'Access);
Util.Strings.Sets.Next (Iter);
end loop;
end;
-- Apply the patch instructions defined for the command.
declare
Iter : Patch_Vectors.Cursor := Cmd.Patches.First;
begin
while Patch_Vectors.Has_Element (Iter) loop
Patch_File (Generator, Patch_Vectors.Element (Iter));
Patch_Vectors.Next (Iter);
end loop;
end;
exception
when PARAM_ERROR =>
return;
end Execute;
-- ------------------------------
-- Write the help associated with the command.
-- ------------------------------
overriding
procedure Help (Cmd : in out Command;
Name : in String;
Generator : in out Gen.Generator.Handler) is
pragma Unreferenced (Generator);
use Ada.Text_IO;
begin
Put_Line (Name & ": " & To_String (Cmd.Title));
Put_Line ("Usage: " & To_String (Cmd.Usage));
New_Line;
Put_Line (To_String (Cmd.Help_Msg));
end Help;
type Command_Fields is (FIELD_NAME,
FIELD_HELP,
FIELD_USAGE,
FIELD_TITLE,
FIELD_BASEDIR,
FIELD_PARAM,
FIELD_PARAM_NAME,
FIELD_PARAM_OPTIONAL,
FIELD_PARAM_ARG,
FIELD_PATCH_OPTIONAL,
FIELD_PATCH_TITLE,
FIELD_TEMPLATE,
FIELD_PATCH,
FIELD_AFTER,
FIELD_MISSING,
FIELD_BEFORE,
FIELD_INSERT_TEMPLATE,
FIELD_COMMAND);
type Command_Loader is record
Command : Command_Access := null;
P : Param;
Info : Patch;
end record;
type Command_Loader_Access is access all Command_Loader;
procedure Set_Member (Closure : in out Command_Loader;
Field : in Command_Fields;
Value : in Util.Beans.Objects.Object);
function To_String (Value : in Util.Beans.Objects.Object) return UString;
-- ------------------------------
-- Convert the object value into a string and trim any space/tab/newlines.
-- ------------------------------
function To_String (Value : in Util.Beans.Objects.Object) return UString is
Result : constant String := Util.Beans.Objects.To_String (Value);
First_Pos : Natural := Result'First;
Last_Pos : Natural := Result'Last;
C : Character;
begin
while First_Pos <= Last_Pos loop
C := Result (First_Pos);
exit when not (C in ' ' | ASCII.LF | ASCII.CR | ASCII.HT);
First_Pos := First_Pos + 1;
end loop;
while Last_Pos >= First_Pos loop
C := Result (Last_Pos);
exit when not (C in ' ' | ASCII.LF | ASCII.CR | ASCII.HT);
Last_Pos := Last_Pos - 1;
end loop;
return To_UString (Result (First_Pos .. Last_Pos));
end To_String;
procedure Set_Member (Closure : in out Command_Loader;
Field : in Command_Fields;
Value : in Util.Beans.Objects.Object) is
use Util.Beans.Objects;
begin
if Field = FIELD_COMMAND then
if Closure.Command /= null then
Log.Info ("Adding command {0}", Closure.Command.Name);
Driver.Add_Command (Name => To_String (Closure.Command.Name),
Command => Closure.Command.all'Access);
Closure.Command := null;
end if;
else
if Closure.Command = null then
Closure.Command := new Gen.Commands.Templates.Command;
end if;
case Field is
when FIELD_NAME =>
Closure.Command.Name := To_String (Value);
when FIELD_TITLE =>
Closure.Command.Title := To_String (Value);
when FIELD_USAGE =>
Closure.Command.Usage := To_String (Value);
when FIELD_HELP =>
Closure.Command.Help_Msg := To_String (Value);
when FIELD_TEMPLATE =>
Closure.Command.Templates.Include (To_String (Value));
when FIELD_PARAM_NAME =>
Closure.P.Name := To_String (Value);
when FIELD_PARAM_OPTIONAL =>
Closure.P.Is_Optional := To_Boolean (Value);
when FIELD_PARAM_ARG =>
Closure.P.Argument := To_String (Value);
when FIELD_PARAM =>
Closure.P.Value := To_String (Value);
Closure.Command.Params.Append (Closure.P);
Closure.P.Name := Ada.Strings.Unbounded.Null_Unbounded_String;
Closure.P.Argument := Ada.Strings.Unbounded.Null_Unbounded_String;
Closure.P.Value := Ada.Strings.Unbounded.Null_Unbounded_String;
Closure.P.Is_Optional := False;
when FIELD_BASEDIR =>
Closure.Command.Base_Dir := To_String (Value);
when FIELD_COMMAND =>
null;
when FIELD_PATCH_OPTIONAL =>
Closure.Info.Optional := Util.Beans.Objects.To_Boolean (Value);
when FIELD_INSERT_TEMPLATE =>
Closure.Info.Template := To_String (Value);
when FIELD_MISSING =>
Closure.Info.Missing.Append (To_String (Value));
when FIELD_AFTER =>
Closure.Info.After.Append (To_String (Value));
when FIELD_BEFORE =>
Closure.Info.Before := To_String (Value);
when FIELD_PATCH_TITLE =>
Closure.Info.Title := To_String (Value);
when FIELD_PATCH =>
Closure.Command.Patches.Append (Closure.Info);
Closure.Info.After.Clear;
Closure.Info.Missing.Clear;
Closure.Info.Optional := False;
Closure.Info.Before := To_UString ("");
Closure.Info.Title := To_UString ("");
end case;
end if;
end Set_Member;
package Command_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Command_Loader,
Element_Type_Access => Command_Loader_Access,
Fields => Command_Fields,
Set_Member => Set_Member);
Cmd_Mapper : aliased Command_Mapper.Mapper;
-- ------------------------------
-- Read the template commands defined in dynamo configuration directory.
-- ------------------------------
procedure Read_Commands (Generator : in out Gen.Generator.Handler) is
procedure Read_Command (Name : in String;
File_Path : in String;
Done : out Boolean);
-- ------------------------------
-- Read the XML command file.
-- ------------------------------
procedure Read_Command (Name : in String;
File_Path : in String;
Done : out Boolean) is
pragma Unreferenced (Name);
Loader : aliased Command_Loader;
Reader : Util.Serialize.IO.XML.Parser;
Mapper : Util.Serialize.Mappers.Processing;
begin
Log.Info ("Reading command file '{0}'", File_Path);
Done := False;
-- Create the mapping to load the XML command file.
Mapper.Add_Mapping ("commands", Cmd_Mapper'Access);
-- Set the context for Set_Member.
Command_Mapper.Set_Context (Mapper, Loader'Unchecked_Access);
-- Read the XML command file.
Reader.Parse (File_Path, Mapper);
exception
when Ada.IO_Exceptions.Name_Error =>
Generator.Error ("Command file {0} does not exist", File_Path);
end Read_Command;
Config_Dir : constant String := Generator.Get_Config_Directory;
Cmd_Dir : constant String := Generator.Get_Parameter ("generator.commands.dir");
Path : constant String := Util.Files.Compose (Config_Dir, Cmd_Dir);
begin
Log.Debug ("Checking commands in {0}", Path);
if Ada.Directories.Exists (Path) then
Util.Files.Iterate_Files_Path (Path => Path,
Pattern => "*.xml",
Process => Read_Command'Access);
end if;
end Read_Commands;
begin
-- Setup the mapper to load XML commands.
Cmd_Mapper.Add_Mapping ("command/name", FIELD_NAME);
Cmd_Mapper.Add_Mapping ("command/title", FIELD_TITLE);
Cmd_Mapper.Add_Mapping ("command/usage", FIELD_USAGE);
Cmd_Mapper.Add_Mapping ("command/help", FIELD_HELP);
Cmd_Mapper.Add_Mapping ("command/basedir", FIELD_BASEDIR);
Cmd_Mapper.Add_Mapping ("command/param", FIELD_PARAM);
Cmd_Mapper.Add_Mapping ("command/param/@name", FIELD_PARAM_NAME);
Cmd_Mapper.Add_Mapping ("command/param/@optional", FIELD_PARAM_OPTIONAL);
Cmd_Mapper.Add_Mapping ("command/param/@arg", FIELD_PARAM_ARG);
Cmd_Mapper.Add_Mapping ("command/patch/@optional", FIELD_PATCH_OPTIONAL);
Cmd_Mapper.Add_Mapping ("command/patch/template", FIELD_INSERT_TEMPLATE);
Cmd_Mapper.Add_Mapping ("command/patch/missing", FIELD_MISSING);
Cmd_Mapper.Add_Mapping ("command/patch/after", FIELD_AFTER);
Cmd_Mapper.Add_Mapping ("command/patch/before", FIELD_BEFORE);
Cmd_Mapper.Add_Mapping ("command/patch/title", FIELD_PATCH_TITLE);
Cmd_Mapper.Add_Mapping ("command/template", FIELD_TEMPLATE);
Cmd_Mapper.Add_Mapping ("command/patch", FIELD_PATCH);
Cmd_Mapper.Add_Mapping ("command", FIELD_COMMAND);
end Gen.Commands.Templates;
|
strenkml/EE368 | Ada | 1,449 | adb |
with Memory.SPM;
with Util; use Util;
separate (Parser)
procedure Parse_SPM(parser : in out Parser_Type;
result : out Memory_Pointer) is
mem : Memory_Pointer := null;
size : Natural := 0;
latency : Time_Type := 2;
begin
while Get_Type(parser) = Open loop
Match(parser, Open);
declare
name : constant String := Get_Value(parser);
begin
Match(parser, Literal);
if name = "memory" then
if mem /= null then
Raise_Error(parser, "memory declared multiple times in spm");
end if;
Parse_Memory(parser, mem);
else
declare
value : constant String := Get_Value(parser);
begin
Match(parser, Literal);
if name = "size" then
size := Natural'Value(value);
elsif name = "latency" then
latency := Time_Type'Value(value);
else
Raise_Error(parser, "invalid spm attribute: " & name);
end if;
end;
end if;
end;
Match(parser, Close);
end loop;
if mem = null then
Raise_Error(parser, "no memory specified in spm");
end if;
result := Memory_Pointer(SPM.Create_SPM(mem, size, latency));
exception
when Data_Error | Constraint_Error =>
Raise_Error(parser, "invalid value in spm");
end Parse_SPM;
|
reznikmm/matreshka | Ada | 3,970 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This is x86_32 specific version of the package.
------------------------------------------------------------------------------
with Matreshka.Internals.Strings.Handlers.X86;
package Matreshka.Internals.Strings.Configuration is
pragma Preelaborate;
String_Handler : not null access
Matreshka.Internals.Strings.Handlers.Abstract_String_Handler'Class
:= Matreshka.Internals.Strings.Handlers.X86.Handler'Access;
-- Platform dependent strings handler to be used for operations on strings.
procedure Initialize;
-- Setup most optimal string handler.
end Matreshka.Internals.Strings.Configuration;
|
AdaCore/training_material | Ada | 3,572 | adb | with System; use System;
with System.Storage_Elements;
with System.Address_To_Access_Conversions;
package body Display.Basic.Utils is
---------------
-- Put_Pixel --
---------------
package Address_To_Pixel is new
System.Address_To_Access_Conversions (SDL_SDL_stdinc_h.Uint32);
function RGBA_To_Uint32(Screen : access SDL_Surface;
Color : RGBA_T) return Uint32 is
begin
return SDL_MapRGBA (Screen.format.all'Address,
unsigned_char (Color.R),
unsigned_char (Color.G),
unsigned_char (Color.B),
unsigned_char (Color.A));
end RGBA_To_Uint32;
procedure Put_Pixel_Slow (Screen : access SDL_Surface;
X, Y : Integer; Color : RGBA_T)
is
begin
-- Just ignore out of screen draws
if
X >= Integer(Screen.w) or else X < 0
or else Y >= Integer(Screen.h) or else Y < 0
then
return;
end if;
declare
use System.Storage_Elements;
Offset : Storage_Offset :=
Storage_Offset ((Y * Integer (Screen.w) + X)
* Integer (Screen.format.BytesPerPixel));
Pixels : System.Address := Screen.pixels + Offset;
begin
Address_To_Pixel.To_Pointer (Pixels).all :=
SDL_MapRGBA (Screen.format.all'Address,
unsigned_char (Color.R),
unsigned_char (Color.G),
unsigned_char (Color.B),
unsigned_char (Color.A));
end;
end Put_Pixel_Slow;
procedure Put_Pixel (Screen : access SDL_Surface;
X, Y : Integer; Color : Uint32)
is
begin
-- Just ignore out of screen draws
if
X >= Integer(Screen.w) or else X < 0
or else Y >= Integer(Screen.h) or else Y < 0
then
return;
end if;
declare
use System.Storage_Elements;
Offset : Storage_Offset :=
Storage_Offset ((Y * Integer (Screen.w) + X)
* Integer (Screen.format.BytesPerPixel));
Pixels : System.Address := Screen.pixels + Offset;
begin
Address_To_Pixel.To_Pointer (Pixels).all := Color;
end;
end Put_Pixel;
Nb_Canvas : Integer := 0;
function Register_SDL_Surface(S : access SDL_Surface) return Canvas_ID is
Current_Id : Canvas_ID;
begin
if Nb_Canvas = Internal_Canvas'Length then
raise Too_Many_Canvas;
end if;
Current_Id := Canvas_ID(Integer(Internal_Canvas'First) + Nb_Canvas);
Internal_Canvas(Current_Id) := T_Internal_Canvas'(Surface => S,
Zoom_Factor => 1.0,
Center => (0, 0));
Nb_Canvas := Nb_Canvas + 1;
return Current_Id;
end Register_SDL_Surface;
function Get_Internal_Canvas(Canvas : Canvas_ID) return T_Internal_Canvas is
begin
return Internal_Canvas (Canvas);
end Get_Internal_Canvas;
procedure Set_Center (Canvas : Canvas_ID; Center : Screen_Point) is
begin
Internal_Canvas(Canvas).Center := Center;
end Set_Center;
function Get_Center (Canvas : Canvas_ID) return Screen_Point is
begin
return Internal_Canvas(Canvas).Center;
end Get_Center;
procedure Set_Zoom_Factor (Canvas : Canvas_ID; ZF : Float) is
begin
Internal_Canvas(Canvas).Zoom_Factor := ZF;
end Set_Zoom_Factor;
end Display.Basic.Utils;
|
reznikmm/matreshka | Ada | 3,865 | ads | ------------------------------------------------------------------------------
-- --
-- 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 Asis;
with Engines.Contexts;
with League.Strings;
package Properties.Expressions.Explicit_Dereference is
function Address
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Text_Property) return League.Strings.Universal_String;
function Code
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Text_Property) return League.Strings.Universal_String;
end Properties.Expressions.Explicit_Dereference;
|
stcarrez/swagger-ada | Ada | 1,204 | ads | -- REST API Validation
-- API to validate
--
-- The version of the OpenAPI document: 1.0.0
-- Contact: [email protected]
--
-- NOTE: This package is auto generated by OpenAPI-Generator 7.0.1-2023-08-27.
-- https://openapi-generator.tech
-- Do not edit the class manually.
with TestBinary.Models;
with Swagger.Clients;
with External;
package TestBinary.Clients is
pragma Style_Checks ("-bmrIu");
type Client_Type is new Swagger.Clients.Client_Type with null record;
-- Get an image
-- Get an image
procedure Do_Get_Image
(Client : in out Client_Type;
Status : in TestBinary.Models.Status_Type;
Owner : in Swagger.Nullable_UString;
Result : out Swagger.Blob_Ref);
-- Get an object
-- Get an object
procedure Do_Get_Object
(Client : in out Client_Type;
Status : in TestBinary.Models.Status_Type;
Owner : in Swagger.Nullable_UString;
Result : out Swagger.Object);
-- Get some stat from external struct
procedure Do_Get_Stats
(Client : in out Client_Type;
Status : in TestBinary.Models.Status_Type;
Result : out External.Stat_Vector);
end TestBinary.Clients;
|
zhmu/ananas | Ada | 5,641 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . S O U R C E _ I N F O --
-- --
-- S p e c --
-- --
-- Copyright (C) 2000-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides some useful utility subprograms that provide access
-- to source code information known at compile time. These subprograms are
-- intrinsic operations that provide information known to the compiler in
-- a form that can be embedded into the source program for identification
-- and logging purposes. For example, an exception handler can print out
-- the name of the source file in which the exception is handled.
package GNAT.Source_Info is
pragma Preelaborate;
-- Note that this unit is Preelaborate, but not Pure, that's because the
-- functions here such as Line are clearly not pure functions, and normally
-- we mark intrinsic functions in a Pure unit as Pure, even though they are
-- imported.
--
-- Historical note: this used to be Pure, but that was when we marked all
-- intrinsics as not Pure, even in Pure units, so no problems arose.
function File return String with
Import, Convention => Intrinsic;
-- Return the name of the current file, not including the path information.
-- The result is considered to be a static string constant.
function Line return Positive with
Import, Convention => Intrinsic;
-- Return the current input line number. The result is considered to be a
-- static expression.
function Source_Location return String with
Import, Convention => Intrinsic;
-- Return a string literal of the form "name:line", where name is the
-- current source file name without path information, and line is the
-- current line number. In the event that instantiations are involved,
-- additional suffixes of the same form are appended after the separating
-- string " instantiated at ". The result is considered to be a static
-- string constant.
function Enclosing_Entity return String with
Import, Convention => Intrinsic;
-- Return the name of the current subprogram, package, task, entry or
-- protected subprogram. The string is in exactly the form used for the
-- declaration of the entity (casing and encoding conventions), and is
-- considered to be a static string constant. The name is fully qualified
-- using periods where possible (this is not always possible, notably in
-- the case of entities appearing in unnamed block statements.)
--
-- Note: if this function is used at the outer level of a generic package,
-- the string returned will be the name of the instance, not the generic
-- package itself. This is useful in identifying and logging information
-- from within generic templates.
function Compilation_ISO_Date return String with
Import, Convention => Intrinsic;
-- Returns date of compilation as a static string "yyyy-mm-dd".
function Compilation_Date return String with
Import, Convention => Intrinsic;
-- Returns date of compilation as a static string "mmm dd yyyy". This is
-- in local time form, and is exactly compatible with C macro __DATE__.
function Compilation_Time return String with
Import, Convention => Intrinsic;
-- Returns GMT time of compilation as a static string "hh:mm:ss". This is
-- in local time form, and is exactly compatible with C macro __TIME__.
end GNAT.Source_Info;
|
sungyeon/drake | Ada | 5,758 | adb | with Ada.Unchecked_Conversion;
with System.Storage_Map;
with C.basetsd;
with C.winternl;
package body System.Native_Tasks is
use type C.char_array;
use type C.windef.DWORD;
use type C.windef.WINBOOL;
use type C.winnt.HANDLE; -- C.void_ptr
type struct_THREAD_BASIC_INFORMATION is record
ExitStatus : C.winternl.NTSTATUS;
TebBaseAddress : C.winnt.struct_TEB_ptr; -- PVOID;
ClientId : C.winternl.CLIENT_ID;
AffinityMask : C.basetsd.KAFFINITY;
Priority : C.winternl.KPRIORITY;
BasePriority : C.winternl.KPRIORITY;
end record
with Convention => C;
pragma Suppress_Initialization (struct_THREAD_BASIC_INFORMATION);
type NtQueryInformationThread_Type is access function (
ThreadHandle : C.winnt.HANDLE;
ThreadInformationClass : C.winternl.THREADINFOCLASS;
ThreadInformation : C.winnt.PVOID;
ThreadInformationLength : C.windef.ULONG;
ReturnLength : access C.windef.ULONG)
return C.winternl.NTSTATUS
with Convention => WINAPI;
NtQueryInformationThread_Name : constant C.char_array (0 .. 24) :=
"NtQueryInformationThread" & C.char'Val (0);
procedure Nop is null;
Installed_Abort_Handler : not null Abort_Handler := Nop'Access;
-- implementation of thread
procedure Create (
Handle : aliased out Handle_Type;
Parameter : Parameter_Type;
Thread_Body : Thread_Body_Type;
Error : out Boolean)
is
Id : aliased C.windef.DWORD;
begin
Handle := C.winbase.CreateThread (
lpThreadAttributes => null,
dwStackSize => 0,
lpStartAddress => Thread_Body,
lpParameter => Parameter,
dwCreationFlags => 0,
lpThreadId => Id'Access);
Error := Handle = C.winbase.INVALID_HANDLE_VALUE;
end Create;
procedure Join (
Handle : Handle_Type;
Current_Abort_Event : access Synchronous_Objects.Event;
Result : aliased out Result_Type;
Error : out Boolean)
is
Signaled : C.windef.DWORD;
begin
Error := False;
if Current_Abort_Event /= null then
declare
Handles : aliased array (0 .. 1) of aliased C.winnt.HANDLE :=
(Handle, Synchronous_Objects.Handle (Current_Abort_Event.all));
begin
Signaled :=
C.winbase.WaitForMultipleObjects (
2,
Handles (0)'Access,
0,
C.winbase.INFINITE);
if Signaled /= C.winbase.WAIT_OBJECT_0 + 1 then
goto Done;
end if;
Installed_Abort_Handler.all; -- may abort child tasks
end;
end if;
Signaled := C.winbase.WaitForSingleObject (Handle, C.winbase.INFINITE);
<<Done>>
case Signaled is
when C.winbase.WAIT_OBJECT_0 =>
if C.winbase.GetExitCodeThread (Handle, Result'Access) =
C.windef.FALSE
then
Error := True;
end if;
when others =>
Error := True;
end case;
if C.winbase.CloseHandle (Handle) = C.windef.FALSE then
Error := True;
end if;
end Join;
procedure Detach (
Handle : in out Handle_Type;
Error : out Boolean) is
begin
Error := False;
if C.winbase.CloseHandle (Handle) = C.windef.FALSE then
Error := True;
else
Handle := C.winbase.GetCurrentThread;
-- magic value meaning current thread
pragma Assert (
Handle = C.winnt.HANDLE (System'To_Address (16#fffffffe#)));
end if;
end Detach;
-- implementation of stack
function Info_Block (Handle : Handle_Type) return C.winnt.struct_TEB_ptr is
function To_NtQueryInformationThread_Type is
new Ada.Unchecked_Conversion (
C.windef.FARPROC,
NtQueryInformationThread_Type);
NtQueryInformationThread : NtQueryInformationThread_Type;
begin
NtQueryInformationThread :=
To_NtQueryInformationThread_Type (
C.winbase.GetProcAddress (
Storage_Map.NTDLL,
NtQueryInformationThread_Name (0)'Access));
if NtQueryInformationThread = null then
return null; -- ???
else
declare
TBI : aliased struct_THREAD_BASIC_INFORMATION;
ReturnLength : aliased C.windef.ULONG;
Dummy_Status : C.winternl.NTSTATUS;
begin
Dummy_Status := NtQueryInformationThread (
Handle,
C.winternl.ThreadBasicInformation,
C.windef.LPVOID (TBI'Address),
struct_THREAD_BASIC_INFORMATION'Size / Standard'Storage_Unit,
ReturnLength'Access);
return TBI.TebBaseAddress;
end;
end if;
end Info_Block;
-- implementation of signals
procedure Install_Abort_Handler (Handler : Abort_Handler) is
begin
Installed_Abort_Handler := Handler;
end Install_Abort_Handler;
procedure Uninstall_Abort_Handler is
begin
Installed_Abort_Handler := Nop'Access;
end Uninstall_Abort_Handler;
procedure Send_Abort_Signal (
Handle : Handle_Type;
Abort_Event : in out Synchronous_Objects.Event;
Error : out Boolean)
is
pragma Unreferenced (Handle);
begin
Synchronous_Objects.Set (Abort_Event);
Error := False;
end Send_Abort_Signal;
procedure Block_Abort_Signal (Abort_Event : Synchronous_Objects.Event) is
begin
-- check aborted
if Synchronous_Objects.Get (Abort_Event) then
Installed_Abort_Handler.all;
end if;
end Block_Abort_Signal;
procedure Yield is
begin
C.winbase.Sleep (0);
end Yield;
end System.Native_Tasks;
|
pauls4GE/RACK | Ada | 106 | ads | procedure Show_Type_Invariant;
-- package Prout is
-- procedure Yolo (A : int; B : int);
-- end Prout;
|
reznikmm/matreshka | Ada | 3,876 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_0028 is
pragma Preelaborate;
Group_0028 : aliased constant Core_Second_Stage
:= (others =>
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Pattern_Syntax
| Grapheme_Base => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_0028;
|
apple-oss-distributions/old_ncurses | Ada | 7,798 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Header_Handler --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer <[email protected]> 1996
-- Version Control
-- $Revision: 1.1.1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Ada.Calendar; use Ada.Calendar;
with Terminal_Interface.Curses.Text_IO.Integer_IO;
with Sample.Manifest; use Sample.Manifest;
-- This package handles the painting of the header line of the screen.
--
package body Sample.Header_Handler is
package Int_IO is new
Terminal_Interface.Curses.Text_IO.Integer_IO (Integer);
use Int_IO;
Header_Window : Window := Null_Window;
Display_Hour : Integer := -1; -- hour last displayed
Display_Min : Integer := -1; -- minute last displayed
Display_Day : Integer := -1; -- day last displayed
Display_Month : Integer := -1; -- month last displayed
-- This is the routine handed over to the curses library to be called
-- as initialization routine when ripping of the header lines from
-- the screen. This routine must follow C conventions.
function Init_Header_Window (Win : Window;
Columns : Column_Count) return Integer;
pragma Convention (C, Init_Header_Window);
procedure Internal_Update_Header_Window (Do_Update : in Boolean);
-- The initialization must be called before Init_Screen. It steals two
-- lines from the top of the screen.
procedure Init_Header_Handler
is
begin
Rip_Off_Lines (2, Init_Header_Window'Access);
end Init_Header_Handler;
procedure N_Out (N : in Integer);
-- Emit a two digit number and ensure that a leading zero is generated if
-- necessary.
procedure N_Out (N : in Integer)
is
begin
if N < 10 then
Add (Header_Window, '0');
Put (Header_Window, N, 1);
else
Put (Header_Window, N, 2);
end if;
end N_Out;
-- Paint the header window. The input parameter is a flag indicating
-- whether or not the screen should be updated physically after painting.
procedure Internal_Update_Header_Window (Do_Update : in Boolean)
is
type Month_Name_Array is
array (Month_Number'First .. Month_Number'Last) of String (1 .. 9);
Month_Names : constant Month_Name_Array :=
("January ",
"February ",
"March ",
"April ",
"May ",
"June ",
"July ",
"August ",
"September",
"October ",
"November ",
"December ");
Now : Time := Clock;
Sec : Integer := Integer (Seconds (Now));
Hour : Integer := Sec / 3600;
Minute : Integer := (Sec - Hour * 3600) / 60;
Mon : Month_Number := Month (Now);
D : Day_Number := Day (Now);
begin
if Header_Window /= Null_Window then
if Minute /= Display_Min or else Hour /= Display_Hour
or else Display_Day /= D or else Display_Month /= Mon then
Move_Cursor (Header_Window, 0, 0);
N_Out (D); Add (Header_Window, '.');
Add (Header_Window, Month_Names (Mon));
Move_Cursor (Header_Window, 1, 0);
N_Out (Hour); Add (Header_Window, ':');
N_Out (Minute);
Display_Min := Minute;
Display_Hour := Hour;
Display_Month := Mon;
Display_Day := D;
Refresh_Without_Update (Header_Window);
if Do_Update then
Update_Screen;
end if;
end if;
end if;
end Internal_Update_Header_Window;
-- This routine is called in the keyboard input timeout handler. So it will
-- periodically update the header line of the screen.
procedure Update_Header_Window
is
begin
Internal_Update_Header_Window (True);
end Update_Header_Window;
function Init_Header_Window (Win : Window;
Columns : Column_Count) return Integer
is
Title : constant String := "Ada 95 ncurses Binding Sample";
Pos : Column_Position;
begin
Header_Window := Win;
if Win /= Null_Window then
if Has_Colors then
Set_Background (Win => Win,
Ch => (Ch => ' ',
Color => Header_Color,
Attr => Normal_Video));
Set_Character_Attributes (Win => Win,
Attr => Normal_Video,
Color => Header_Color);
Erase (Win);
end if;
Leave_Cursor_After_Update (Win, True);
Pos := Columns - Column_Position (Title'Length);
Add (Win, 0, Pos / 2, Title);
-- In this phase we must not allow a physical update, because
-- ncurses isnīt properly initialized at this point.
Internal_Update_Header_Window (False);
return 0;
else
return -1;
end if;
end Init_Header_Window;
end Sample.Header_Handler;
|
zhmu/ananas | Ada | 280 | ads | with Generic_Inst3_Traits.Encodables;
generic
Topic_Name : String;
with package Keys is new Generic_Inst3_Traits.Encodables (<>);
with package Values is new Generic_Inst3_Traits.Encodables (<>);
package Generic_Inst3_Kafka_Lib.Topic is
end Generic_Inst3_Kafka_Lib.Topic;
|
zhmu/ananas | Ada | 4,753 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . S T R I N G S . U N B O U N D E D . T E X T _ I O --
-- --
-- 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.Text_IO; use Ada.Text_IO;
package body Ada.Strings.Unbounded.Text_IO is
--------------
-- Get_Line --
--------------
function Get_Line return Unbounded_String is
Buffer : String (1 .. 1000);
Last : Natural;
Result : Unbounded_String;
begin
Get_Line (Buffer, Last);
Set_Unbounded_String (Result, Buffer (1 .. Last));
while Last = Buffer'Last loop
Get_Line (Buffer, Last);
Append (Result, Buffer (1 .. Last));
end loop;
return Result;
end Get_Line;
function Get_Line (File : Ada.Text_IO.File_Type) return Unbounded_String is
Buffer : String (1 .. 1000);
Last : Natural;
Result : Unbounded_String;
begin
Get_Line (File, Buffer, Last);
Set_Unbounded_String (Result, Buffer (1 .. Last));
while Last = Buffer'Last loop
Get_Line (File, Buffer, Last);
Append (Result, Buffer (1 .. Last));
end loop;
return Result;
end Get_Line;
procedure Get_Line (Item : out Unbounded_String) is
begin
Get_Line (Current_Input, Item);
end Get_Line;
procedure Get_Line
(File : Ada.Text_IO.File_Type;
Item : out Unbounded_String)
is
Buffer : String (1 .. 1000);
Last : Natural;
begin
Get_Line (File, Buffer, Last);
Set_Unbounded_String (Item, Buffer (1 .. Last));
while Last = Buffer'Last loop
Get_Line (File, Buffer, Last);
Append (Item, Buffer (1 .. Last));
end loop;
end Get_Line;
---------
-- Put --
---------
procedure Put (U : Unbounded_String) is
UR : constant Shared_String_Access := U.Reference;
begin
Put (UR.Data (1 .. UR.Last));
end Put;
procedure Put (File : File_Type; U : Unbounded_String) is
UR : constant Shared_String_Access := U.Reference;
begin
Put (File, UR.Data (1 .. UR.Last));
end Put;
--------------
-- Put_Line --
--------------
procedure Put_Line (U : Unbounded_String) is
UR : constant Shared_String_Access := U.Reference;
begin
Put_Line (UR.Data (1 .. UR.Last));
end Put_Line;
procedure Put_Line (File : File_Type; U : Unbounded_String) is
UR : constant Shared_String_Access := U.Reference;
begin
Put_Line (File, UR.Data (1 .. UR.Last));
end Put_Line;
end Ada.Strings.Unbounded.Text_IO;
|
ashleygay/adaboy | Ada | 6,549 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with word_operations_hpp;
limited with processor_hpp;
with Interfaces.C.Extensions;
limited with array_hpp;
package video_hpp is
-- NOTE: There is no difference between read/write for perms
-- If we try to read/write potentially protected memory,
-- we return _accessible otherwise we return true.
-- Change permission on protected memory:
-- VRAM (0x8000-0x9FFF) and OAM (0xFE00-0xFE9F)
-- actually wx - 7
type Video_video_memory_array is array (0 .. 65535) of aliased word_operations_hpp.uint8_t;
package Class_Video is
type Video is limited record
u_proc : aliased access processor_hpp.Class_Processor.Processor; -- ./video.hpp:59
video_memory : aliased Video_video_memory_array; -- ./video.hpp:60
u_OAM_accessible : aliased Extensions.bool; -- ./video.hpp:61
u_VRAM_accessible : aliased Extensions.bool; -- ./video.hpp:62
end record;
pragma Import (CPP, Video);
function New_Video (proc : access processor_hpp.Class_Processor.Processor) return Video; -- ./video.hpp:11
pragma CPP_Constructor (New_Video, "_ZN5VideoC1ER9Processor");
function in_range (this : access Video; address : word_operations_hpp.uint16_t) return Extensions.bool; -- ./video.hpp:13
pragma Import (CPP, in_range, "_ZN5Video8in_rangeEt");
function read (this : access Video; address : word_operations_hpp.uint16_t) return word_operations_hpp.uint8_t; -- ./video.hpp:15
pragma Import (CPP, read, "_ZN5Video4readEt");
procedure write
(this : access Video;
byte : word_operations_hpp.uint8_t;
address : word_operations_hpp.uint16_t); -- ./video.hpp:16
pragma Import (CPP, write, "_ZN5Video5writeEht");
function simple_read (this : access Video; address : word_operations_hpp.uint16_t) return word_operations_hpp.uint8_t; -- ./video.hpp:18
pragma Import (CPP, simple_read, "_ZN5Video11simple_readEt");
procedure simple_write
(this : access Video;
byte : word_operations_hpp.uint8_t;
address : word_operations_hpp.uint16_t); -- ./video.hpp:19
pragma Import (CPP, simple_write, "_ZN5Video12simple_writeEht");
procedure dma_transfer
(this : access Video;
beg_src : word_operations_hpp.uint16_t;
end_src : word_operations_hpp.uint16_t); -- ./video.hpp:21
pragma Import (CPP, dma_transfer, "_ZN5Video12dma_transferEtt");
function is_accessible (this : access Video; address : word_operations_hpp.uint16_t) return Extensions.bool; -- ./video.hpp:26
pragma Import (CPP, is_accessible, "_ZN5Video13is_accessibleEt");
function can_read (this : access Video; address : word_operations_hpp.uint16_t) return Extensions.bool; -- ./video.hpp:28
pragma Import (CPP, can_read, "_ZN5Video8can_readEt");
function can_write (this : access Video; address : word_operations_hpp.uint16_t) return Extensions.bool; -- ./video.hpp:29
pragma Import (CPP, can_write, "_ZN5Video9can_writeEt");
procedure set_VRAM_accessible (this : access Video; accessible : Extensions.bool); -- ./video.hpp:33
pragma Import (CPP, set_VRAM_accessible, "_ZN5Video19set_VRAM_accessibleEb");
procedure set_OAM_accessible (this : access Video; accessible : Extensions.bool); -- ./video.hpp:34
pragma Import (CPP, set_OAM_accessible, "_ZN5Video18set_OAM_accessibleEb");
function get_sprites (this : access Video; sprites : access array_hpp.template_array_Class_Sprite_40.instance) return word_operations_hpp.size_t; -- ./video.hpp:36
pragma Import (CPP, get_sprites, "_ZN5Video11get_spritesERSt5arrayI6SpriteLj40EE");
function get_lcd_control (this : access Video) return word_operations_hpp.uint8_t; -- ./video.hpp:38
pragma Import (CPP, get_lcd_control, "_ZN5Video15get_lcd_controlEv");
function get_lcd_status (this : access Video) return word_operations_hpp.uint8_t; -- ./video.hpp:39
pragma Import (CPP, get_lcd_status, "_ZN5Video14get_lcd_statusEv");
function get_scrolly (this : access Video) return word_operations_hpp.uint8_t; -- ./video.hpp:40
pragma Import (CPP, get_scrolly, "_ZN5Video11get_scrollyEv");
function get_scrollx (this : access Video) return word_operations_hpp.uint8_t; -- ./video.hpp:41
pragma Import (CPP, get_scrollx, "_ZN5Video11get_scrollxEv");
function get_ly (this : access Video) return word_operations_hpp.uint8_t; -- ./video.hpp:42
pragma Import (CPP, get_ly, "_ZN5Video6get_lyEv");
function get_lyc (this : access Video) return word_operations_hpp.uint8_t; -- ./video.hpp:43
pragma Import (CPP, get_lyc, "_ZN5Video7get_lycEv");
function get_wy (this : access Video) return word_operations_hpp.uint8_t; -- ./video.hpp:44
pragma Import (CPP, get_wy, "_ZN5Video6get_wyEv");
function get_wx (this : access Video) return word_operations_hpp.uint8_t; -- ./video.hpp:45
pragma Import (CPP, get_wx, "_ZN5Video6get_wxEv");
function get_bgp (this : access Video) return word_operations_hpp.uint8_t; -- ./video.hpp:46
pragma Import (CPP, get_bgp, "_ZN5Video7get_bgpEv");
function get_obp0 (this : access Video) return word_operations_hpp.uint8_t; -- ./video.hpp:47
pragma Import (CPP, get_obp0, "_ZN5Video8get_obp0Ev");
function get_obp1 (this : access Video) return word_operations_hpp.uint8_t; -- ./video.hpp:48
pragma Import (CPP, get_obp1, "_ZN5Video8get_obp1Ev");
procedure set_lcd_status (this : access Video; status : word_operations_hpp.uint8_t); -- ./video.hpp:50
pragma Import (CPP, set_lcd_status, "_ZN5Video14set_lcd_statusEh");
procedure set_lcd_status_mode (this : access Video; mode : word_operations_hpp.uint8_t); -- ./video.hpp:51
pragma Import (CPP, set_lcd_status_mode, "_ZN5Video19set_lcd_status_modeEh");
procedure set_ly (this : access Video; ly : word_operations_hpp.uint8_t); -- ./video.hpp:52
pragma Import (CPP, set_ly, "_ZN5Video6set_lyEh");
function is_OAM (this : access Video; address : word_operations_hpp.uint16_t) return Extensions.bool; -- ./video.hpp:55
pragma Import (CPP, is_OAM, "_ZN5Video6is_OAMEt");
function is_VRAM (this : access Video; address : word_operations_hpp.uint16_t) return Extensions.bool; -- ./video.hpp:56
pragma Import (CPP, is_VRAM, "_ZN5Video7is_VRAMEt");
end;
use Class_Video;
end video_hpp;
|
AdaCore/libadalang | Ada | 547 | adb | procedure Test is
generic
package Gen_Pkg with Ghost is
end Gen_Pkg;
package Instantiated_Pkg is new Gen_Pkg;
--% node.p_is_ghost_code
generic
procedure Gen_Proc with Ghost;
procedure Gen_Proc is null;
procedure Instantiated_Proc is new Gen_Proc;
--% node.p_is_ghost_code
package Pkg with Ghost is
end Pkg;
package Renamed_Pkg renames Pkg;
--% node.p_is_ghost_code
procedure Proc is null with Ghost;
procedure Renamed_Proc renames Proc;
--% node.p_is_ghost_code
begin
null;
end Test;
|
michalkonecny/polypaver | Ada | 727 | ads | with PolyPaver.Floats;
--# inherit PolyPaver.Exact, PolyPaver.Interval, PolyPaver.Integers, PolyPaver.Floats;
package Riemann is
function erfRiemann(x : Float; n : Integer) return Float;
--# pre PolyPaver.Floats.Is_Range(x, 0.0, 4.0)
--# and PolyPaver.Integers.Is_Range(n, 1, 100);
--# return result =>
--# PolyPaver.Interval.Contained_In(
--# result
--# ,
--# PolyPaver.Exact.Integral(0.0,x,PolyPaver.Exact.Exp(-PolyPaver.Exact.Integration_Variable**2))
--# +
--# PolyPaver.Interval.Hull(
--# - 0.1*Float(n+1)
--# ,
--# (1.0-PolyPaver.Exact.Exp(-x**2))*x/Float(n)
--# + 0.1*Float(n+1)
--# )
--# );
end Riemann; |
gitter-badger/libAnne | Ada | 1,366 | adb | package body Colors.Models.Grayscale is
function Red(Self : Grayscale_Color) return Percent is (Percent(Self.Intensity / Short_Short_Modular'Last));
function Red(Self : Grayscale_Color) return Short_Short_Modular is (Self.Intensity);
function Green(Self : Grayscale_Color) return Percent is (Percent(Self.Intensity / Short_Short_Modular'Last));
function Green(Self : Grayscale_Color) return Short_Short_Modular is (Self.Intensity);
function Blue(Self : Grayscale_Color) return Percent is (Percent(Self.Intensity / Short_Short_Modular'Last));
function Blue(Self : Grayscale_Color) return Short_Short_Modular is (Self.Intensity);
function Chroma(Self : Grayscale_Color) return Percent is (Percent'(0.0));
function Chroma(Self : Grayscale_Color) return Short_Short_Modular is (0);
function Hue(Self : Grayscale_Color) return Angle is (Angle'(0));
function Gray(Intensity : Percent; α : Percent := 100.0) return Grayscale_Color is
I : Short_Short_Modular := Short_Short_Modular(Decimal(Intensity) * 2.55);
A : Short_Short_Modular := Short_Short_Modular(Decimal(α) * 2.55);
begin
return Grayscale_Color'(A, I);
end Gray;
function Gray(Intensity : Short_Short_Modular; α : Short_Short_Modular := Short_Short_Modular'Last) return Grayscale_Color is
begin
return Grayscale_Color'(α, Intensity);
end Gray;
end Colors.Models.Grayscale;
|
reznikmm/matreshka | Ada | 7,120 | 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.Linenumbering_Separator_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Linenumbering_Separator_Element_Node is
begin
return Self : Text_Linenumbering_Separator_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Linenumbering_Separator_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Text_Linenumbering_Separator
(ODF.DOM.Text_Linenumbering_Separator_Elements.ODF_Text_Linenumbering_Separator_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Linenumbering_Separator_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Linenumbering_Separator_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Linenumbering_Separator_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Text_Linenumbering_Separator
(ODF.DOM.Text_Linenumbering_Separator_Elements.ODF_Text_Linenumbering_Separator_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Text_Linenumbering_Separator_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Text_Linenumbering_Separator
(Visitor,
ODF.DOM.Text_Linenumbering_Separator_Elements.ODF_Text_Linenumbering_Separator_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Linenumbering_Separator_Element,
Text_Linenumbering_Separator_Element_Node'Tag);
end Matreshka.ODF_Text.Linenumbering_Separator_Elements;
|
onox/orka | Ada | 7,256 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2018 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with GL.Types;
with GL.Toggles;
with Orka.Cameras.Rotate_Around_Cameras;
with Orka.Contexts.AWT;
with Orka.Rendering.Buffers;
with Orka.Rendering.Drawing;
with Orka.Rendering.Framebuffers;
with Orka.Rendering.Programs.Modules;
with Orka.Rendering.Programs.Uniforms;
with Orka.Resources.Locations.Directories;
with Orka.Transforms.Doubles.Vector_Conversions;
with Orka.Transforms.Singles.Matrices;
with Orka.Types;
with Orka.Windows;
with AWT.Inputs;
-- In this example we render many instances of a cube, each at a different
-- position.
procedure Orka_11_Instancing is
Width : constant := 500;
Height : constant := 500;
Context : constant Orka.Contexts.Context'Class := Orka.Contexts.AWT.Create_Context
(Version => (4, 2), Flags => (Debug => True, others => False));
Window : constant Orka.Windows.Window'Class
:= Orka.Contexts.AWT.Create_Window (Context, Width, Height, Resizable => False);
use Orka.Rendering.Buffers;
use Orka.Rendering.Framebuffers;
use Orka.Rendering.Programs;
use type Orka.Integer_32;
use type Orka.Float_32;
use type Orka.Float_64;
use GL.Types;
Instances_Dimension : constant := 40;
Space_Between_Cubes : constant := 0.2;
function Create_Matrices return Orka.Types.Singles.Matrix4_Array is
package Transforms renames Orka.Transforms.Singles.Matrices;
Distance_Multiplier : constant := 1.0 + Space_Between_Cubes;
Matrices : Orka.Types.Singles.Matrix4_Array (1 .. Instances_Dimension**3);
Index : Int := Matrices'First;
X, Y, Z : Single;
Offset : constant := Instances_Dimension / 2;
begin
for Index_X in 1 .. Instances_Dimension loop
X := Single (Index_X - Offset) * Distance_Multiplier;
for Index_Y in 1 .. Instances_Dimension loop
Y := Single (Index_Y - Offset) * Distance_Multiplier;
for Index_Z in 1 .. Instances_Dimension loop
Z := Single (Index_Z - Offset) * Distance_Multiplier;
Matrices (Index) := Transforms.T (Transforms.Vectors.Point'(X, Y, Z, 1.0));
Index := Index + 1;
end loop;
end loop;
end loop;
return Matrices;
end Create_Matrices;
Indices : constant Orka.Unsigned_32_Array
:= (1, 2, 0, -- Back
0, 2, 3,
1, 0, 5, -- Top
5, 0, 4,
5, 4, 6, -- Front
6, 4, 7,
1, 5, 2, -- Right
2, 5, 6,
7, 4, 3, -- Left
3, 4, 0,
3, 2, 7, -- Bottom
7, 2, 6);
Vertices : constant Orka.Float_32_Array
:= (-0.5, 0.5, -0.5, 1.0, 1.0, 1.0, 1.0, 1.0,
0.5, 0.5, -0.5, 1.0, 0.0, 1.0, 0.0, 1.0,
0.5, -0.5, -0.5, 1.0, 0.0, 0.0, 1.0, 1.0,
-0.5, -0.5, -0.5, 1.0, 1.0, 0.0, 0.0, 1.0,
-0.5, 0.5, 0.5, 1.0, 0.0, 0.0, 1.0, 1.0,
0.5, 0.5, 0.5, 1.0, 1.0, 0.0, 0.0, 1.0,
0.5, -0.5, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0,
-0.5, -0.5, 0.5, 1.0, 0.0, 1.0, 0.0, 1.0);
-- vec4 in_Position
-- vec4 in_Color
Matrices : constant Orka.Types.Singles.Matrix4_Array := Create_Matrices;
-- Create buffers containing attributes and indices
Buffer_1 : constant Buffer := Create_Buffer ((others => False), Vertices);
Buffer_2 : constant Buffer := Create_Buffer ((others => False), Indices);
Buffer_3 : constant Buffer := Create_Buffer ((others => False), Matrices);
use Orka.Resources;
Location_Shaders : constant Locations.Location_Ptr
:= Locations.Directories.Create_Location ("data/shaders");
Program_1 : Program := Create_Program (Modules.Create_Module
(Location_Shaders, VS => "instancing.vert", FS => "instancing.frag"));
Uni_View : constant Uniforms.Uniform := Program_1.Uniform ("view");
Uni_Proj : constant Uniforms.Uniform := Program_1.Uniform ("proj");
FB_D : Framebuffer := Create_Default_Framebuffer (Width, Height);
use Orka.Cameras;
Lens : constant Camera_Lens := Create_Lens (Width, Height, 45.0);
Current_Camera : Rotate_Around_Cameras.Rotate_Around_Camera :=
Rotate_Around_Cameras.Create_Camera (Lens);
begin
declare
Distance_Center : Double := Double (Instances_Dimension);
begin
Distance_Center := Distance_Center + (Distance_Center - 1.0) * Space_Between_Cubes;
Current_Camera.Set_Orientation ((0.0, 0.0, -1.5 * Distance_Center, 0.0));
Current_Camera.Update (0.0);
end;
FB_D.Set_Default_Values ((Color => (0.0, 0.0, 0.0, 1.0), Depth => 0.0, others => <>));
Program_1.Use_Program;
-- Projection matrix
Uni_Proj.Set_Matrix (Current_Camera.Projection_Matrix);
GL.Toggles.Enable (GL.Toggles.Cull_Face);
GL.Toggles.Enable (GL.Toggles.Depth_Test);
Buffer_1.Bind (Shader_Storage, 0);
Buffer_3.Bind (Shader_Storage, 1);
while not Window.Should_Close loop
AWT.Process_Events (0.001);
declare
Pointer : constant AWT.Inputs.Pointer_State := Window.State;
use all type AWT.Inputs.Button_State;
use all type AWT.Inputs.Pointer_Button;
use all type AWT.Inputs.Pointer_Mode;
use all type AWT.Inputs.Dimension;
Rotate_Camera : constant Boolean :=
Pointer.Focused and Pointer.Buttons (Right) = Pressed;
begin
declare
New_Mode : constant AWT.Inputs.Pointer_Mode :=
(if Rotate_Camera then Locked else Visible);
begin
if Pointer.Mode /= New_Mode then
Window.Set_Pointer_Mode (New_Mode);
end if;
end;
Current_Camera.Change_Orientation
(((if Rotate_Camera then Orka.Float_64 (Pointer.Relative (X)) else 0.0),
(if Rotate_Camera then Orka.Float_64 (Pointer.Relative (Y)) else 0.0),
Orka.Float_64 (Pointer.Scroll (Y)),
0.0));
end;
Current_Camera.Update (0.01666);
declare
VP : constant Transforms.Vector4 :=
Orka.Transforms.Doubles.Vector_Conversions.Convert (Current_Camera.View_Position);
use Transforms.Vectors;
use Transforms;
TM : constant Transforms.Matrix4 := T (Vector_Type (Transforms.Zero_Point - Point (VP)));
begin
Uni_View.Set_Matrix (Current_Camera.View_Matrix * TM);
end;
FB_D.Clear ((Color | Depth => True, others => False));
Orka.Rendering.Drawing.Draw_Indexed
(Triangles, Buffer_2, 0, Indices'Length, Matrices'Length);
-- Swap front and back buffers and process events
Window.Swap_Buffers;
end loop;
end Orka_11_Instancing;
|
optikos/oasis | Ada | 1,532 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Type_Definitions;
with Program.Lexical_Elements;
with Program.Elements.Enumeration_Literal_Specifications;
package Program.Elements.Enumeration_Types is
pragma Pure (Program.Elements.Enumeration_Types);
type Enumeration_Type is
limited interface and Program.Elements.Type_Definitions.Type_Definition;
type Enumeration_Type_Access is access all Enumeration_Type'Class
with Storage_Size => 0;
not overriding function Literals
(Self : Enumeration_Type)
return not null Program.Elements.Enumeration_Literal_Specifications
.Enumeration_Literal_Specification_Vector_Access is abstract;
type Enumeration_Type_Text is limited interface;
type Enumeration_Type_Text_Access is access all Enumeration_Type_Text'Class
with Storage_Size => 0;
not overriding function To_Enumeration_Type_Text
(Self : aliased in out Enumeration_Type)
return Enumeration_Type_Text_Access is abstract;
not overriding function Left_Bracket_Token
(Self : Enumeration_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Right_Bracket_Token
(Self : Enumeration_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Enumeration_Types;
|
PThierry/ewok-kernel | Ada | 25 | ads | ../stm32f439/soc-nvic.ads |
reznikmm/matreshka | Ada | 4,583 | 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.Custom3_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Custom3_Attribute_Node is
begin
return Self : Text_Custom3_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_Custom3_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Custom3_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Custom3_Attribute,
Text_Custom3_Attribute_Node'Tag);
end Matreshka.ODF_Text.Custom3_Attributes;
|
reznikmm/matreshka | Ada | 4,623 | 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.String_Value_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_String_Value_Attribute_Node is
begin
return Self : Text_String_Value_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_String_Value_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.String_Value_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.String_Value_Attribute,
Text_String_Value_Attribute_Node'Tag);
end Matreshka.ODF_Text.String_Value_Attributes;
|
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.Elements;
package ODF.DOM.Table_Table_Column_Group_Elements is
pragma Preelaborate;
type ODF_Table_Table_Column_Group is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Table_Table_Column_Group_Access is
access all ODF_Table_Table_Column_Group'Class
with Storage_Size => 0;
end ODF.DOM.Table_Table_Column_Group_Elements;
|
charlie5/aShell | Ada | 460 | ads | package POSIX.Process_Primitives.Extensions is
procedure Start_Process_Search
(Child : out POSIX.Process_Identification.Process_ID;
Filename : in POSIX.Filename;
Working_Directory : in String;
Template : in Process_Template;
Arg_List : in POSIX.POSIX_String_List :=
POSIX.Empty_String_List);
end POSIX.Process_Primitives.Extensions;
|
joakim-strandberg/wayland_ada_binding | Ada | 724 | adb | package body C_Binding.Linux is
use type Ada.Streams.Stream_Element_Offset;
use type Interfaces.C.unsigned;
use type Interfaces.Unsigned_32;
function Convert_Unchecked is new Ada.Unchecked_Conversion
(Source => Interfaces.C.int,
Target => O_FLag);
function Convert_Unchecked is new Ada.Unchecked_Conversion
(Source => O_FLag,
Target => Interfaces.C.int);
procedure Set_File_Descriptor_Flag_Non_Blocking
(File_Descriptor : in out Interfaces.C.int)
is
Temp : O_FLag := Convert_Unchecked (File_Descriptor);
begin
Temp := Temp or O_NONBLOCK;
File_Descriptor := Convert_Unchecked (Temp);
end Set_File_Descriptor_Flag_Non_Blocking;
end C_Binding.Linux;
|
ZinebZaad/ENSEEIHT | Ada | 1,999 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Stocks_Materiel; use Stocks_Materiel;
-- Auteur:
-- Gérer un stock de matériel informatique.
--
procedure Scenario_Stock is
Mon_Stock : T_Stock;
begin
-- Créer un stock vide
Creer (Mon_Stock);
pragma Assert (Nb_Materiels (Mon_Stock) = 0);
-- Enregistrer quelques matériels
Enregistrer (Mon_Stock, 1012, UNITE_CENTRALE, 2016);
pragma Assert (Nb_Materiels (Mon_Stock) = 1);
Enregistrer (Mon_Stock, 2143, ECRAN, 2016);
pragma Assert (Nb_Materiels (Mon_Stock) = 2);
Enregistrer (Mon_Stock, 3001, IMPRIMANTE, 2017);
pragma Assert (Nb_Materiels (Mon_Stock) = 3);
Enregistrer (Mon_Stock, 3012, UNITE_CENTRALE, 2017);
pragma Assert (Nb_Materiels (Mon_Stock) = 4);
-- Nb_Defectueux & Mettre à jour tests.
pragma Assert(Nb_Defectueux(Mon_Stock) = 0);
Mettre_A_Jour(Mon_Stock, 1012, False);
pragma Assert(Nb_Defectueux(Mon_Stock) = 1);
Mettre_A_Jour(Mon_Stock, 3001, False);
pragma Assert(Nb_Defectueux(Mon_Stock) = 2);
Mettre_A_Jour(Mon_Stock, 1012, True);
pragma Assert(Nb_Defectueux(Mon_Stock) = 1);
-- Supprimer tests.
Supprimer(Mon_Stock, 3012);
pragma Assert(Nb_Defectueux(Mon_Stock) = 1);
pragma Assert (Nb_Materiels (Mon_Stock) = 3);
Supprimer(Mon_Stock, 3001);
pragma Assert(Nb_Defectueux(Mon_Stock) = 0);
pragma Assert (Nb_Materiels (Mon_Stock) = 2);
-- Afficher test.
Afficher(Mon_Stock);
-- Nettoyer tests.
Enregistrer (Mon_Stock, 1234, UNITE_CENTRALE, 2017);
Enregistrer (Mon_Stock, 3312, IMPRIMANTE, 2016);
Mettre_A_Jour(Mon_Stock, 3312, False);
Mettre_A_Jour(Mon_Stock, 1012, False);
pragma Assert (Nb_Materiels (Mon_Stock) = 4);
pragma Assert(Nb_Defectueux(Mon_Stock) = 2);
Nettoyer(Mon_Stock);
pragma Assert (Nb_Materiels (Mon_Stock) = 2);
pragma Assert(Nb_Defectueux(Mon_Stock) = 0);
end Scenario_Stock;
|
BrickBot/Bound-T-H8-300 | Ada | 2,574 | adb | -- Arithmetic.Evaluation.Opt (body)
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- 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.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.2 $
-- $Date: 2015/10/24 20:05:44 $
--
-- $Log: arithmetic-evaluation-opt.adb,v $
-- Revision 1.2 2015/10/24 20:05:44 niklas
-- Moved to free licence.
--
-- Revision 1.1 2011-08-31 04:17:12 niklas
-- Added for BT-CH-0222: Option registry. Option -dump. External help files.
--
with Options;
with Options.Groups;
package body Arithmetic.Evaluation.Opt is
begin
Options.Register (
Option => Trace_Refinement_Path_Opt'access,
Name => Options.Trace_Item ("refine_path"),
Group => Options.Groups.Trace);
Options.Register (
Option => Warn_Overflow_Opt'access,
Name => Options.Warn_Item ("overflow"),
Group => Options.Groups.Warn);
end Arithmetic.Evaluation.Opt;
|
thierr26/ada-keystore | Ada | 4,449 | adb | -----------------------------------------------------------------------
-- keystore-passwords-tests -- Tests for Keystore.Passwords
-- 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 Ada.Streams.Stream_IO;
with Util.Test_Caller;
with Util.Encoders.SHA256;
with Util.Encoders.HMAC.SHA256;
with Keystore.Tests;
with Keystore.Passwords.Keys;
with Keystore.Passwords.Files;
package body Keystore.Passwords.Tests is
use type Ada.Streams.Stream_Element_Array;
package Caller is new Util.Test_Caller (Test, "AKT.Passwords");
function Hash (Provider : in Keys.Key_Provider_Access)
return Util.Encoders.SHA256.Hash_Array;
procedure Free is
new Ada.Unchecked_Deallocation (Object => Keys.Key_Provider'Class,
Name => Keys.Key_Provider_Access);
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Keystore.Passwords.Files",
Test_File_Password'Access);
end Add_Tests;
function Hash (Provider : in Keys.Key_Provider_Access)
return Util.Encoders.SHA256.Hash_Array is
Context : Util.Encoders.HMAC.SHA256.Context;
Key : Secret_Key (Length => 32);
IV : Secret_Key (Length => 16);
Sign : Secret_Key (Length => 32);
Result : Util.Encoders.SHA256.Hash_Array;
begin
Provider.Get_Keys (Key, IV, Sign);
Util.Encoders.HMAC.SHA256.Set_Key (Context, Key);
Util.Encoders.HMAC.SHA256.Update (Context, IV);
Util.Encoders.HMAC.SHA256.Update (Context, Sign);
Util.Encoders.HMAC.SHA256.Finish (Context, Result);
return Result;
end Hash;
-- ------------------------------
-- Test the using the Passwords.Files
-- ------------------------------
procedure Test_File_Password (T : in out Test) is
Path : constant String := Util.Tests.Get_Test_Path ("regtests/result/pass/key1.bin");
Provider1 : Keys.Key_Provider_Access;
Provider2 : Keys.Key_Provider_Access;
Hash1 : Util.Encoders.SHA256.Hash_Array;
Hash2 : Util.Encoders.SHA256.Hash_Array;
File : Ada.Streams.Stream_IO.File_Type;
begin
Provider1 := Files.Generate (Path);
Provider2 := Files.Create (Path);
Hash1 := Hash (Provider1);
Hash2 := Hash (Provider2);
T.Assert (Hash1 = Hash2, "Generate and Create are inconsistent");
Free (Provider1);
Provider1 := Files.Generate (Path);
Hash1 := Hash (Provider1);
T.Assert (Hash1 /= Hash2, "Generate and Create are inconsistent");
Free (Provider1);
Free (Provider2);
Ada.Streams.Stream_IO.Create (File, Ada.Streams.Stream_IO.Out_File, Path);
Ada.Streams.Stream_IO.Close (File);
begin
Provider2 := Files.Create (Path);
T.Fail ("No exception raised for an empty file");
exception
when Bad_Password =>
null;
end;
Ada.Streams.Stream_IO.Create (File, Ada.Streams.Stream_IO.Out_File, Path);
for I in 1 .. 200 loop
Ada.Streams.Stream_IO.Write (File, Hash1);
end loop;
Ada.Streams.Stream_IO.Close (File);
begin
Provider2 := Files.Create (Path);
T.Fail ("No exception raised for a big file");
exception
when Bad_Password =>
null;
end;
if not Keystore.Tests.Is_Windows then
begin
Provider2 := Files.Create ("Makefile.conf");
T.Fail ("No exception raised for a file stored in an unprotected dir");
exception
when Bad_Password =>
null;
end;
end if;
end Test_File_Password;
end Keystore.Passwords.Tests;
|
sungyeon/drake | Ada | 914 | ads | pragma License (Unrestricted);
-- extended unit
with Ada.Containers.Access_Holders;
generic
type Base (<>) is abstract tagged limited private;
type Base_Name is access all Base'Class;
with package Base_Holders is
new Access_Holders (Base_Name, Free => <>);
type Derived (<>) is abstract limited new Base with private;
type Derived_Name is access all Derived'Class;
with package Derived_Holders is
new Access_Holders (Derived_Name, Free => <>);
package Ada.Containers.Access_Holders_Derivational_Conversions is
-- It converts reference counted access types from derived to base.
pragma Preelaborate;
procedure Assign (
Target : in out Base_Holders.Holder;
Source : Derived_Holders.Holder);
procedure Move (
Target : in out Base_Holders.Holder;
Source : in out Derived_Holders.Holder);
end Ada.Containers.Access_Holders_Derivational_Conversions;
|
reznikmm/matreshka | Ada | 5,064 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Link_End_Datas.Collections is
pragma Preelaborate;
package UML_Link_End_Data_Collections is
new AMF.Generic_Collections
(UML_Link_End_Data,
UML_Link_End_Data_Access);
type Set_Of_UML_Link_End_Data is
new UML_Link_End_Data_Collections.Set with null record;
Empty_Set_Of_UML_Link_End_Data : constant Set_Of_UML_Link_End_Data;
type Ordered_Set_Of_UML_Link_End_Data is
new UML_Link_End_Data_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Link_End_Data : constant Ordered_Set_Of_UML_Link_End_Data;
type Bag_Of_UML_Link_End_Data is
new UML_Link_End_Data_Collections.Bag with null record;
Empty_Bag_Of_UML_Link_End_Data : constant Bag_Of_UML_Link_End_Data;
type Sequence_Of_UML_Link_End_Data is
new UML_Link_End_Data_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Link_End_Data : constant Sequence_Of_UML_Link_End_Data;
private
Empty_Set_Of_UML_Link_End_Data : constant Set_Of_UML_Link_End_Data
:= (UML_Link_End_Data_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Link_End_Data : constant Ordered_Set_Of_UML_Link_End_Data
:= (UML_Link_End_Data_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Link_End_Data : constant Bag_Of_UML_Link_End_Data
:= (UML_Link_End_Data_Collections.Bag with null record);
Empty_Sequence_Of_UML_Link_End_Data : constant Sequence_Of_UML_Link_End_Data
:= (UML_Link_End_Data_Collections.Sequence with null record);
end AMF.UML.Link_End_Datas.Collections;
|
reznikmm/matreshka | Ada | 3,674 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Text_Change_End_Elements is
pragma Preelaborate;
type ODF_Text_Change_End is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Text_Change_End_Access is
access all ODF_Text_Change_End'Class
with Storage_Size => 0;
end ODF.DOM.Text_Change_End_Elements;
|
reznikmm/matreshka | Ada | 363 | adb | with League.Application;
with Matreshka.CLDR.Collation_Loader;
with Matreshka.Internals.Locales;
procedure MLC is
Locale : constant Matreshka.Internals.Locales.Locale_Data_Access
:= Matreshka.Internals.Locales.Get_Locale;
begin
Matreshka.CLDR.Collation_Loader.Load_Collation_Data
(League.Application.Arguments.Element (1),
Locale);
end MLC;
|
reznikmm/matreshka | Ada | 3,969 | 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.Dr3d_Center_Attributes;
package Matreshka.ODF_Dr3d.Center_Attributes is
type Dr3d_Center_Attribute_Node is
new Matreshka.ODF_Dr3d.Abstract_Dr3d_Attribute_Node
and ODF.DOM.Dr3d_Center_Attributes.ODF_Dr3d_Center_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Dr3d_Center_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Dr3d_Center_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Dr3d.Center_Attributes;
|
notdb/LC-Practice | Ada | 126 | adb | -- We define the Increment function
function Increment (I : Integer) return Integer is
begin
return I + i;
end Increment; |
reznikmm/matreshka | Ada | 7,101 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Style.List_Level_Properties_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Style_List_Level_Properties_Element_Node is
begin
return Self : Style_List_Level_Properties_Element_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Style_List_Level_Properties_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Style_List_Level_Properties
(ODF.DOM.Style_List_Level_Properties_Elements.ODF_Style_List_Level_Properties_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_List_Level_Properties_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.List_Level_Properties_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Style_List_Level_Properties_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Style_List_Level_Properties
(ODF.DOM.Style_List_Level_Properties_Elements.ODF_Style_List_Level_Properties_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Style_List_Level_Properties_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Style_List_Level_Properties
(Visitor,
ODF.DOM.Style_List_Level_Properties_Elements.ODF_Style_List_Level_Properties_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.List_Level_Properties_Element,
Style_List_Level_Properties_Element_Node'Tag);
end Matreshka.ODF_Style.List_Level_Properties_Elements;
|
nerilex/ada-util | Ada | 20,068 | adb | -----------------------------------------------------------------------
-- strings.tests -- Unit tests for strings
-- Copyright (C) 2009, 2010, 2011, 2012, 2015 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings;
with Ada.Strings.Unbounded;
with Ada.Strings.Fixed;
with Ada.Strings.Fixed.Hash;
with Ada.Strings.Unbounded.Hash;
with Ada.Containers;
with Util.Test_Caller;
with Util.Strings.Transforms;
with Util.Strings.Maps;
with Util.Strings.Vectors;
with Util.Perfect_Hash;
with Util.Strings.Tokenizers;
with Ada.Streams;
with Util.Measures;
package body Util.Strings.Tests is
use Ada.Strings.Unbounded;
use Util.Tests;
use Util.Strings.Transforms;
package Caller is new Util.Test_Caller (Test, "Strings");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.Escape_Javascript",
Test_Escape_Javascript'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.Escape_Xml",
Test_Escape_Xml'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.Unescape_Xml",
Test_Unescape_Xml'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.Capitalize",
Test_Capitalize'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.To_Upper_Case",
Test_To_Upper_Case'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.To_Lower_Case",
Test_To_Lower_Case'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.To_Hex",
Test_To_Hex'Access);
Caller.Add_Test (Suite, "Test Measure",
Test_Measure_Copy'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Index",
Test_Index'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Rindex",
Test_Rindex'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Benchmark",
Test_Measure_Hash'Access);
Caller.Add_Test (Suite, "Test Util.Strings.String_Ref",
Test_String_Ref'Access);
Caller.Add_Test (Suite, "Test perfect hash",
Test_Perfect_Hash'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Tokenizers.Iterate_Token",
Test_Iterate_Token'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Vectors perf",
Test_Perf_Vector'Access);
end Add_Tests;
procedure Test_Escape_Javascript (T : in out Test) is
Result : Unbounded_String;
begin
Escape_Javascript (Content => ASCII.LF & " ""a string"" a 'single quote'",
Into => Result);
Assert_Equals (T, "\n \""a string\"" a \'single quote\'", Result);
Result := To_Unbounded_String ("");
Escape_Javascript (Content => ASCII.ESC & "[m " & Character'Val (255),
Into => Result);
Assert_Equals (T, "\u001B[m " & Character'Val (255), Result);
end Test_Escape_Javascript;
procedure Test_Escape_Xml (T : in out Test) is
Result : Unbounded_String;
begin
Escape_Xml (Content => ASCII.LF & " < ""a string"" a 'single quote' >& ",
Into => Result);
Assert_Equals (T, ASCII.LF & " < ""a string"" a 'single quote' >& ",
Result);
Result := To_Unbounded_String ("");
Escape_Xml (Content => ASCII.ESC & "[m " & Character'Val (255),
Into => Result);
Assert_Equals (T, ASCII.ESC & "[m ÿ", Result);
end Test_Escape_Xml;
procedure Test_Unescape_Xml (T : in out Test) is
Result : Unbounded_String;
begin
Unescape_Xml (Content => "<>&" ' A",
Translator => Util.Strings.Transforms.TR.Translate_Xml_Entity'Access,
Into => Result);
Util.Tests.Assert_Equals (T, "<>&"" ' A", Result, "Invalid unescape");
Set_Unbounded_String (Result, "");
Unescape_Xml (Content => "Test Ao~ end",
Translator => Util.Strings.Transforms.TR.Translate_Xml_Entity'Access,
Into => Result);
Util.Tests.Assert_Equals (T, "Test Ao~ end", Result, "Invalid decimal unescape");
Set_Unbounded_String (Result, "");
Unescape_Xml (Content => "Test eÀđĦË end",
Translator => Util.Strings.Transforms.TR.Translate_Xml_Entity'Access,
Into => Result);
Util.Tests.Assert_Equals (T, "Test eÀđĦË end", Result, "Invalid Decimal Unescape");
Unescape_Xml (Content => "&;&#qsf;&qsd;�; )",
Translator => Util.Strings.Transforms.TR.Translate_Xml_Entity'Access,
Into => Result);
end Test_Unescape_Xml;
procedure Test_Capitalize (T : in out Test) is
Result : Unbounded_String;
begin
Assert_Equals (T, "Capitalize_A_String", Capitalize ("capITalIZe_a_strING"));
Capitalize ("CapAS_String", Result);
Assert_Equals (T, "Capas_String", Result);
end Test_Capitalize;
procedure Test_To_Upper_Case (T : in out Test) is
begin
Assert_Equals (T, "UPPERCASE_0123_STR", To_Upper_Case ("upperCase_0123_str"));
end Test_To_Upper_Case;
procedure Test_To_Lower_Case (T : in out Test) is
begin
Assert_Equals (T, "lowercase_0123_str", To_Lower_Case ("LowERCase_0123_STR"));
end Test_To_Lower_Case;
procedure Test_To_Hex (T : in out Test) is
Result : Unbounded_String;
begin
To_Hex (Result, Character'Val (23));
Assert_Equals (T, "\u0017", Result);
To_Hex (Result, Character'Val (31));
Assert_Equals (T, "\u0017\u001F", Result);
To_Hex (Result, Character'Val (255));
Assert_Equals (T, "\u0017\u001F\u00FF", Result);
end Test_To_Hex;
procedure Test_Measure_Copy (T : in out Test) is
pragma Unreferenced (T);
Buf : constant Ada.Streams.Stream_Element_Array (1 .. 10_024) := (others => 23);
pragma Suppress (All_Checks, Buf);
begin
declare
T : Util.Measures.Stamp;
R : Ada.Strings.Unbounded.Unbounded_String;
begin
for I in Buf'Range loop
Append (R, Character'Val (Buf (I)));
end loop;
Util.Measures.Report (T, "Stream transform using Append (1024 bytes)");
end;
declare
T : Util.Measures.Stamp;
R : Ada.Strings.Unbounded.Unbounded_String;
S : String (1 .. 10_024);
pragma Suppress (All_Checks, S);
begin
for I in Buf'Range loop
S (Natural (I)) := Character'Val (Buf (I));
end loop;
Append (R, S);
Util.Measures.Report (T, "Stream transform using temporary string (1024 bytes)");
end;
-- declare
-- T : Util.Measures.Stamp;
-- R : Ada.Strings.Unbounded.Unbounded_String;
-- P : constant Ptr := new String (1 .. Buf'Length);
--
-- pragma Suppress (All_Checks, P);
-- begin
-- for I in P'Range loop
-- P (I) := Character'Val (Buf (Ada.Streams.Stream_Element_Offset (I)));
-- end loop;
-- Ada.Strings.Unbounded.Aux.Set_String (R, P.all'Access);
-- Util.Measures.Report (T, "Stream transform using Aux string (1024 bytes)");
-- end;
declare
T : Util.Measures.Stamp;
H : Ada.Containers.Hash_Type;
pragma Unreferenced (H);
begin
for I in 1 .. 1_000 loop
H := Ada.Strings.Fixed.Hash ("http://code.google.com/p/ada-awa/jsf:wiki");
end loop;
Util.Measures.Report (T, "Ada.Strings.Fixed.Hash");
end;
declare
T : Util.Measures.Stamp;
H : Ada.Containers.Hash_Type;
pragma Unreferenced (H);
begin
for I in 1 .. 1_000 loop
H := Ada.Strings.Fixed.Hash ("http://code.google.com/p/ada-awa/jsf:wiki");
end loop;
Util.Measures.Report (T, "Ada.Strings.Fixed.Hash");
end;
end Test_Measure_Copy;
-- ------------------------------
-- Test the Index operation
-- ------------------------------
procedure Test_Index (T : in out Test) is
Str : constant String := "0123456789abcdefghijklmnopq";
begin
declare
St : Util.Measures.Stamp;
Pos : Integer;
begin
for I in 1 .. 10 loop
Pos := Index (Str, 'q');
end loop;
Util.Measures.Report (St, "Util.Strings.Index");
Assert_Equals (T, 27, Pos, "Invalid index position");
end;
declare
St : Util.Measures.Stamp;
Pos : Integer;
begin
for I in 1 .. 10 loop
Pos := Ada.Strings.Fixed.Index (Str, "q");
end loop;
Util.Measures.Report (St, "Ada.Strings.Fixed.Index");
Assert_Equals (T, 27, Pos, "Invalid index position");
end;
end Test_Index;
-- ------------------------------
-- Test the Rindex operation
-- ------------------------------
procedure Test_Rindex (T : in out Test) is
Str : constant String := "0123456789abcdefghijklmnopq";
begin
declare
St : Util.Measures.Stamp;
Pos : Natural;
begin
for I in 1 .. 10 loop
Pos := Rindex (Str, '0');
end loop;
Util.Measures.Report (St, "Util.Strings.Rindex");
Assert_Equals (T, 1, Pos, "Invalid rindex position");
end;
declare
St : Util.Measures.Stamp;
Pos : Natural;
begin
for I in 1 .. 10 loop
Pos := Ada.Strings.Fixed.Index (Str, "0", Ada.Strings.Backward);
end loop;
Util.Measures.Report (St, "Ada.Strings.Fixed.Rindex");
Assert_Equals (T, 1, Pos, "Invalid rindex position");
end;
end Test_Rindex;
package String_Map is new Ada.Containers.Hashed_Maps
(Key_Type => Unbounded_String,
Element_Type => Unbounded_String,
Hash => Hash,
Equivalent_Keys => "=");
package String_Ref_Map is new Ada.Containers.Hashed_Maps
(Key_Type => String_Ref,
Element_Type => String_Ref,
Hash => Hash,
Equivalent_Keys => Equivalent_Keys);
-- ------------------------------
-- Do some benchmark on String -> X hash mapped.
-- ------------------------------
procedure Test_Measure_Hash (T : in out Test) is
KEY : aliased constant String := "testing";
Str_Map : Util.Strings.Maps.Map;
Ptr_Map : Util.Strings.String_Access_Map.Map;
Ref_Map : String_Ref_Map.Map;
Unb_Map : String_Map.Map;
Name : String_Access := new String '(KEY);
Ref : constant String_Ref := To_String_Ref (KEY);
begin
Str_Map.Insert (Name.all, Name.all);
Ptr_Map.Insert (Name.all'Access, Name.all'Access);
Unb_Map.Insert (To_Unbounded_String (KEY), To_Unbounded_String (KEY));
Ref_Map.Insert (Ref, Ref);
declare
T : Util.Measures.Stamp;
H : Ada.Containers.Hash_Type;
pragma Unreferenced (H);
begin
for I in 1 .. 1_000 loop
H := Ada.Strings.Fixed.Hash ("http://code.google.com/p/ada-awa/jsf:wiki");
end loop;
Util.Measures.Report (T, "Ada.Strings.Fixed.Hash (1000 calls)");
end;
-- Performance of Hashed_Map Name_Access -> Name_Access
-- (the fastest hash)
declare
St : Util.Measures.Stamp;
Pos : constant Strings.String_Access_Map.Cursor := Ptr_Map.Find (KEY'Unchecked_Access);
Val : constant Name_Access := Util.Strings.String_Access_Map.Element (Pos);
begin
Util.Measures.Report (St, "Util.Strings.String_Access_Maps.Find+Element");
Assert_Equals (T, "testing", Val.all, "Invalid value returned");
end;
-- Performance of Hashed_Map String_Ref -> String_Ref
-- (almost same performance as Hashed_Map Name_Access -> Name_Access)
declare
St : Util.Measures.Stamp;
Pos : constant String_Ref_Map.Cursor := Ref_Map.Find (Ref);
Val : constant String_Ref := String_Ref_Map.Element (Pos);
begin
Util.Measures.Report (St, "Util.Strings.String_Ref_Maps.Find+Element");
Assert_Equals (T, "testing", String '(To_String (Val)), "Invalid value returned");
end;
-- Performance of Hashed_Map Unbounded_String -> Unbounded_String
-- (little overhead due to String copy made by Unbounded_String)
declare
St : Util.Measures.Stamp;
Pos : constant String_Map.Cursor := Unb_Map.Find (To_Unbounded_String (KEY));
Val : constant Unbounded_String := String_Map.Element (Pos);
begin
Util.Measures.Report (St, "Hashed_Maps<Unbounded,Unbounded..Find+Element");
Assert_Equals (T, "testing", Val, "Invalid value returned");
end;
-- Performance for Indefinite_Hashed_Map String -> String
-- (the slowest hash, string copy to get the result, pointer to key and element
-- in the hash map implementation)
declare
St : Util.Measures.Stamp;
Pos : constant Util.Strings.Maps.Cursor := Str_Map.Find (KEY);
Val : constant String := Util.Strings.Maps.Element (Pos);
begin
Util.Measures.Report (St, "Util.Strings.Maps.Find+Element");
Assert_Equals (T, "testing", Val, "Invalid value returned");
end;
Free (Name);
end Test_Measure_Hash;
-- ------------------------------
-- Test String_Ref creation
-- ------------------------------
procedure Test_String_Ref (T : in out Test) is
R1 : String_Ref := To_String_Ref ("testing a string");
begin
for I in 1 .. 1_000 loop
declare
S : constant String (1 .. I) := (others => 'x');
R2 : constant String_Ref := To_String_Ref (S);
begin
Assert_Equals (T, S, To_String (R2), "Invalid String_Ref");
T.Assert (R2 = S, "Invalid comparison");
Assert_Equals (T, I, Length (R2), "Invalid length");
R1 := R2;
T.Assert (R1 = R2, "Invalid String_Ref copy");
end;
end loop;
end Test_String_Ref;
-- ------------------------------
-- Test perfect hash (samples/gperfhash)
-- ------------------------------
procedure Test_Perfect_Hash (T : in out Test) is
begin
for I in Util.Perfect_Hash.Keywords'Range loop
declare
K : constant String := Util.Perfect_Hash.Keywords (I).all;
begin
Assert_Equals (T, I, Util.Perfect_Hash.Hash (K),
"Invalid hash");
Assert_Equals (T, I, Util.Perfect_Hash.Hash (To_Lower_Case (K)),
"Invalid hash");
Assert (T, Util.Perfect_Hash.Is_Keyword (K), "Keyword " & K & " is not a keyword");
Assert (T, Util.Perfect_Hash.Is_Keyword (To_Lower_Case (K)),
"Keyword " & K & " is not a keyword");
end;
end loop;
end Test_Perfect_Hash;
-- ------------------------------
-- Benchmark comparison between the use of Iterate vs Query_Element.
-- ------------------------------
procedure Test_Perf_Vector (T : in out Test) is
procedure Iterate_Item (Item : in String);
procedure Iterate (Pos : in Util.Strings.Vectors.Cursor);
List : Util.Strings.Vectors.Vector;
Count : Natural := 0;
Total : Natural := 0;
procedure Iterate_Item (Item : in String) is
begin
Count := Count + 1;
Total := Total + Item'Length;
end Iterate_Item;
procedure Iterate (Pos : in Util.Strings.Vectors.Cursor) is
S : constant String := Util.Strings.Vectors.Element (Pos);
begin
Count := Count + 1;
Total := Total + S'Length;
end Iterate;
begin
for I in 1 .. 100 loop
List.Append ("yet another fixed string with some reasonable content");
end loop;
-- First form of iterate by using the container Iterate procedure.
-- Due to the Cursor usage, this forces a copy of the string to the secondary stack.
declare
St : Util.Measures.Stamp;
begin
List.Iterate (Iterate'Access);
Util.Measures.Report (St, "Util.Strings.Vectors.Iterate (100)");
end;
-- Second form by using the cursor and the Query_Element procedure.
-- We avoid a copy of the string to the secondary stack.
declare
St : Util.Measures.Stamp;
Iter : Util.Strings.Vectors.Cursor := List.First;
begin
while Util.Strings.Vectors.Has_Element (Iter) loop
Util.Strings.Vectors.Query_Element (Iter, Iterate_Item'Access);
Util.Strings.Vectors.Next (Iter);
end loop;
Util.Measures.Report (St, "Util.Strings.Vectors.Query_Element+Cursor (100)");
end;
-- Third form by using a manual index iteration.
-- This is the fastest form of iteration with the current GNAT implementation.
declare
St : Util.Measures.Stamp;
Last : constant Ada.Containers.Count_Type := List.Length;
begin
for I in 1 .. Last loop
List.Query_Element (Positive (I), Iterate_Item'Access);
end loop;
Util.Measures.Report (St, "Util.Strings.Vectors.Query_Element+Index (100)");
end;
end Test_Perf_Vector;
-- ------------------------------
-- Test the token iteration.
-- ------------------------------
procedure Test_Iterate_Token (T : in out Test) is
procedure Process_Token (Token : in String;
Done : out Boolean);
Called : Natural := 0;
procedure Process_Token (Token : in String;
Done : out Boolean) is
begin
T.Assert (Token = "one" or Token = "two" or Token = "three"
or Token = "four five" or Token = "six seven",
"Invalid token: [" & Token & "]");
Called := Called + 1;
Done := False;
end Process_Token;
begin
Util.Strings.Tokenizers.Iterate_Tokens (Content => "one two three",
Pattern => " ",
Process => Process_Token'Access);
Util.Tests.Assert_Equals (T, 3, Called, "Iterate_Tokens calls Process incorrectly");
Util.Strings.Tokenizers.Iterate_Tokens (Content => "one two three",
Pattern => " ",
Process => Process_Token'Access,
Going => Ada.Strings.Backward);
Util.Tests.Assert_Equals (T, 6, Called, "Iterate_Tokens calls Process incorrectly");
Util.Strings.Tokenizers.Iterate_Tokens (Content => "four five blob six seven",
Pattern => " blob ",
Process => Process_Token'Access);
Util.Tests.Assert_Equals (T, 8, Called, "Iterate_Tokens calls Process incorrectly");
end Test_Iterate_Token;
end Util.Strings.Tests;
|
skill-lang/adaCommon | Ada | 6,416 | adb | -- ___ _ ___ _ _ --
-- / __| |/ (_) | | Common SKilL implementation --
-- \__ \ ' <| | | |__ general file interaction --
-- |___/_|\_\_|_|____| by: Timm Felden --
-- --
pragma Ada_2012;
with Ada.Unchecked_Conversion;
with Skill.Errors;
with Skill.Internal.File_Parsers;
with Skill.Streams;
with Skill.Types;
with Skill.Synchronization;
with Skill.Types.Pools;
with Skill.Field_Declarations;
with Skill.Tasks;
with Skill.Internal.File_Writers;
with Skill.Equals;
with Skill.Hashes;
with Ada.Containers.Hashed_Sets;
with Ada.Text_IO;
package body Skill.Files is
package FileParser renames Skill.Internal.File_Parsers;
-- read file closure
type Cl is new Tasks.Closure_T with record
F : Skill.Field_Declarations.Field_Declaration;
CE : Skill.Field_Declarations.Chunk_Entry;
end record;
type Cx is not null access Cl;
function Cast is new Ada.Unchecked_Conversion (Skill.Tasks.Closure, Cx);
function Strings
(This : access File_T'Class) return Skill.String_Pools.Pool
is
begin
return This.Strings;
end Strings;
procedure Delete
(This : access File_T'Class;
Target : access Types.Skill_Object'Class)
is
begin
if null /= Target and then not Target.Is_Deleted then
This.Types_By_Name.Element (Target.Skill_Name).Delete (Target);
end if;
end Delete;
procedure Change_Path (This : access File_T'Class; New_Path : String) is
begin
pragma Assert (This.Mode = Write);
This.Path := new String'(New_Path);
end Change_Path;
procedure Check (This : access File_T'Class) is
P : Skill.Types.Pools.Pool;
F : Skill.Field_Declarations.Field_Declaration;
begin
-- TODO par
-- TODO a more efficient solution would be helpful
-- TODO lacks type restrictions
-- @note this should be more like, each pool is checking its type restriction, aggergating its field restrictions,
-- and if there are any, then they will all be checked using (hopefully) overridden check methods
for I in 1 .. This.Types.Length loop
P := This.Types.Element (I - 1);
for J in 1 .. P.Data_Fields.Length loop
F := P.Data_Fields.Element (J);
if not F.Check then
raise Skill.Errors.Skill_Error
with "check failed in " & P.Skill_Name.all & "." & F.Name.all;
end if;
end loop;
end loop;
null;
end Check;
procedure Flush (This : access File_T'Class) is
type T is access all File_T;
function Cast is new Ada.Unchecked_Conversion (T, File);
begin
case This.Mode is
when Write =>
Skill.Internal.File_Writers.Write
(Cast (T (This)),
Streams.Write (This.Path));
when Append =>
Skill.Internal.File_Writers.Append
(Cast (T (This)),
Streams.Append (This.Path));
when Destroyed =>
raise Skill.Errors.Skill_Error
with "you cannot flush a destroyed state";
end case;
This.Mode := Destroyed;
end Flush;
procedure Finalize_Pools (This : access File_T'Class) is
Read_Barrier : Skill.Synchronization.Barrier;
procedure Finish (F : Skill.Field_Declarations.Field_Declaration) is
procedure Read (C : Skill.Tasks.Closure) is
begin
F.Read (Cast (C).CE);
-- TODO error reporting? (see Java Field.finish)
Read_Barrier.Complete;
exception
when E : others =>
Read_Barrier.Complete;
Ada.Text_IO.Put_Line
(Ada.Text_IO.Current_Error,
"A task crashed during read data: " &
F.Owner.To_String &
"." &
F.Name.all);
-- Skill.Errors.Print_Stacktrace (E);
return;
end Read;
procedure Read_Chunk (CE : Skill.Field_Declarations.Chunk_Entry) is
T : Skill.Tasks.Run (Read'Access);
C : Skill.Tasks.Closure := new Cl'(F => F, CE => CE);
begin
Read_Barrier.Start;
T.Start (C);
end Read_Chunk;
begin
F.Data_Chunks.Foreach (Read_Chunk'Access);
end Finish;
procedure Start_Read (P_Static : Skill.Types.Pools.Pool) is
function Base is new Ada.Unchecked_Conversion
(Skill.Types.Pools.Pool_Dyn,
Skill.Types.Pools.Base_Pool);
use type Types.String_Access;
package A1 is new Ada.Containers.Hashed_Sets
(Element_Type => Types.String_Access,
Hash => Skill.Hashes.Hash,
Equivalent_Elements => Skill.Equals.Equals,
"=" => "=");
P : Skill.Types.Pools.Pool_Dyn := P_Static.Dynamic;
Field_Names : A1.Set;
begin
-- note: this loop must happen in type order!
-- set owner
if P.all in Skill.Types.Pools.Base_Pool_T'Class then
Base (P).Set_Owner (This);
end if;
-- add missing field declarations
Field_Names := A1.Empty_Set;
for I in 1 .. Natural (P.Data_Fields.Length) loop
Field_Names.Insert (P.Data_Fields.Element (I).Name);
end loop;
-- ensure existence of known fields
for N of P.Known_Fields.all loop
if not Field_Names.Contains (N) then
P.Dynamic.Add_Known_Field
(N, This.String_Type, This.Annotation_Type);
end if;
end loop;
-- read known fields
P.Data_Fields.Foreach (Finish'Access);
null;
end Start_Read;
use Skill.Types.Pools;
begin
This.Types.Foreach (Start_Read'Access);
-- fix types in the Annotation-runtime type, because we need it in offset calculation
This.Annotation_Type.Fix_Types;
for P of This.Types_By_Name loop
if null = P.Super then
To_Base_Pool (P).Establish_Next;
end if;
end loop;
-- await async reads
Read_Barrier.Await;
end Finalize_Pools;
end Skill.Files;
|
Fabien-Chouteau/lvgl-ada | Ada | 6,351 | ads | with Lv.Style;
with Lv.Area;
with Lv.Objx.Page;
package Lv.Objx.Ddlist is
subtype Instance is Obj_T;
type Style_T is (Style_Bg, Style_Sel, Style_Sb);
-- Create a drop down list objects
-- @param par pointer to an object, it will be the parent of the new drop down list
-- @param copy pointer to a drop down list object, if not NULL then the new object will be copied from it
-- @return pointer to the created drop down list
function Create (Parent : Obj_T; Copy : Instance) return Instance;
----------------------
-- Setter functions --
----------------------
-- Set the options in a drop down list from a string
-- @param self pointer to drop down list object
-- @param options a string with '\n' separated options. E.g. "One\nTwo\nThree"
procedure Set_Options
(Self : Instance;
Options : C_String_Ptr);
-- Set the selected option
-- @param self pointer to drop down list object
-- @param sel_opt id of the selected option (0 ... number of option - 1);
procedure Set_Selected (Self : Instance; Sel_Opt : Uint16_T);
-- Set a function to call when a new option is chosen
-- @param self pointer to a drop down list
-- @param action pointer to a call back function
procedure Set_Action (Self : Instance; Action : Action_Func_T);
-- Set the fix height for the drop down list
-- If 0 then the opened ddlist will be auto. sized else the set height will be applied.
-- @param self pointer to a drop down list
-- @param h the height when the list is opened (0: auto size)
procedure Set_Fix_Height (Self : Instance; H : Lv.Area.Coord_T);
-- Enable or disable the horizontal fit to the content
-- @param self pointer to a drop down list
-- @param fit en true: enable auto fit; false: disable auto fit
procedure Set_Hor_Fit (Self : Instance; Fit_En : U_Bool);
-- Set the scroll bar mode of a drop down list
-- @param self pointer to a drop down list object
-- @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
procedure Set_Sb_Mode (Self : Instance; Mode : Lv.Objx.Page.Mode_T);
-- Set the open/close animation time.
-- @param self pointer to a drop down list
-- @param anim_time: open/close animation time [ms]
procedure Set_Anim_Time (Self : Instance; Anim_Time : Uint16_T);
-- Set a style of a drop down list
-- @param self pointer to a drop down list object
-- @param type which style should be set
-- @param style pointer to a style
procedure Set_Style
(Self : Instance;
Type_P : Style_T;
Style : Lv.Style.Style);
----------------------
-- Getter functions --
----------------------
-- Get the options of a drop down list
-- @param self pointer to drop down list object
-- @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
function Options
(Self : Instance) return C_String_Ptr;
-- Get the selected option
-- @param self pointer to drop down list object
-- @return id of the selected option (0 ... number of option - 1);
function Selected (Self : Instance) return Uint16_T;
-- Get the current selected option as a string
-- @param self pointer to ddlist object
-- @param buf pointer to an array to store the string
procedure Selected_Str
(Self : Instance;
Buf : C_String_Ptr);
-- Get the "option selected" callback function
-- @param self pointer to a drop down list
-- @return pointer to the call back function
function Action (Self : Instance) return Action_Func_T;
-- Get the fix height value.
-- @param self pointer to a drop down list object
-- @return the height if the ddlist is opened (0: auto size)
function Fix_Height (Self : Instance) return Lv.Area.Coord_T;
-- Get the scroll bar mode of a drop down list
-- @param self pointer to a drop down list object
-- @return scrollbar mode from 'lv_page_sb_mode_t' enum
function Sb_Mode (Self : Instance) return Lv.Objx.Page.Mode_T;
-- Get the open/close animation time.
-- @param self pointer to a drop down list
-- @return open/close animation time [ms]
function Anim_Time (Self : Instance) return Uint16_T;
-- Get a style of a drop down list
-- @param self pointer to a drop down list object
-- @param type which style should be get
-- @return style pointer to a style
function Style
(Self : Instance;
Style : Style_T) return Lv.Style.Style;
---------------------
-- Other functions --
---------------------
-- Open the drop down list with or without animation
-- @param self pointer to drop down list object
-- @param anim_en true: use animation; false: not use animations
procedure Open (Self : Instance; Anim_En : U_Bool);
-- Close (Collapse) the drop down list
-- @param self pointer to drop down list object
-- @param anim true: use animation; false: not use animations
procedure Close (Self : Instance; Anim : U_Bool);
-------------
-- Imports --
-------------
pragma Import (C, Create, "lv_ddlist_create");
pragma Import (C, Set_Options, "lv_ddlist_set_options");
pragma Import (C, Set_Selected, "lv_ddlist_set_selected");
pragma Import (C, Set_Action, "lv_ddlist_set_action");
pragma Import (C, Set_Fix_Height, "lv_ddlist_set_fix_height");
pragma Import (C, Set_Hor_Fit, "lv_ddlist_set_hor_fit");
pragma Import (C, Set_Sb_Mode, "lv_ddlist_set_sb_mode_inline");
pragma Import (C, Set_Anim_Time, "lv_ddlist_set_anim_time");
pragma Import (C, Set_Style, "lv_ddlist_set_style");
pragma Import (C, Options, "lv_ddlist_get_options");
pragma Import (C, Selected, "lv_ddlist_get_selected");
pragma Import (C, Selected_Str, "lv_ddlist_get_selected_str");
pragma Import (C, Action, "lv_ddlist_get_action");
pragma Import (C, Fix_Height, "lv_ddlist_get_fix_height");
pragma Import (C, Sb_Mode, "lv_ddlist_get_sb_mode_inline");
pragma Import (C, Anim_Time, "lv_ddlist_get_anim_time");
pragma Import (C, Style, "lv_ddlist_get_style");
pragma Import (C, Open, "lv_ddlist_open");
pragma Import (C, Close, "lv_ddlist_close");
for Style_T'Size use 8;
for Style_T use (Style_Bg => 0,
Style_Sel => 1,
Style_Sb => 2);
end Lv.Objx.Ddlist;
|
rogermc2/GA_Ada | Ada | 2,405 | ads |
with Interfaces;
with GL.Types;
with Blade;
with Blade_Types;
with E3GA;
with GA_Maths;
with Metric;
with Multivectors;
with Multivector_Type;
package GA_Utilities is
use GA_Maths.Float_Array_Package;
function Multivector_Size (MV : Multivectors.Multivector) return Integer;
procedure Print_Bitmap (Name : String; Bitmap : Interfaces.Unsigned_32);
procedure Print_Blade (Name : String; B : Blade.Basis_Blade);
procedure Print_Blade_List (Name : String; BL : Blade.Blade_List);
procedure Print_Blade_String (Name : String; B : Blade.Basis_Blade;
MV_Names : Blade_Types.Basis_Vector_Names);
procedure Print_Blade_String_Array (Name : String;
BB_Array : Blade.Basis_Blade_Array;
MV_Names : Blade_Types.Basis_Vector_Names);
procedure Print_E3_Vector (Name : String; aVector : E3GA.E3_Vector);
procedure Print_E3_Vector_Array (Name : String;
anArray : GL.Types.Singles.Vector3_Array);
procedure Print_Float_3D (Name : String; aVector : GA_Maths.Float_3D);
procedure Print_Float_Array (Name : String; anArray : GA_Maths.Float_Vector);
procedure Print_Integer_Array (Name : String; anArray : GA_Maths.Integer_Array);
procedure Print_Matrix (Name : String; aMatrix : GA_Maths.GA_Matrix3);
procedure Print_Matrix (Name : String; aMatrix : Real_Matrix);
procedure Print_Matrix (Name : String; aMatrix : Real_Matrix;
Start, Last : GA_Maths.Array_I2);
procedure Print_Metric (Name : String; aMetric : Metric.Metric_Record);
procedure Print_Multivector (Name : String; MV : Multivectors.Multivector);
procedure Print_Multivector_Info (Name : String;
Info : Multivector_Type.MV_Type_Record);
procedure Print_Multivector_List (Name : String;
MV_List : Multivectors.Multivector_List);
procedure Print_Multivector_List_String
(Name : String; MV_List : Multivectors.Multivector_List;
MV_Names : Blade_Types.Basis_Vector_Names);
procedure Print_Multivector_String (Name : String; MV : Multivectors.Multivector;
MV_Names : Blade_Types.Basis_Vector_Names);
procedure Print_Vertex (Name : String; Vertex : Multivectors.M_Vector);
end GA_Utilities;
|
persan/A-gst | Ada | 62,135 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
with System;
-- with GStreamer.GST_Low_Level.glib_2_0_glib_gquark_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttask_h;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h;
with glib;
-- with GStreamer.GST_Low_Level.libxml2_libxml_tree_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h is
-- unsupported macro: GST_TYPE_PAD (gst_pad_get_type ())
-- arg-macro: function GST_IS_PAD (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD);
-- arg-macro: function GST_IS_PAD_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD);
-- arg-macro: function GST_PAD (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad);
-- arg-macro: function GST_PAD_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass);
-- arg-macro: function GST_PAD_CAST (obj)
-- return (GstPad*)(obj);
-- arg-macro: function GST_PAD_LINK_FAILED (ret)
-- return (ret) < GST_PAD_LINK_OK;
-- arg-macro: function GST_PAD_LINK_SUCCESSFUL (ret)
-- return (ret) >= GST_PAD_LINK_OK;
-- arg-macro: function GST_FLOW_IS_FATAL (ret)
-- return (ret) <= GST_FLOW_UNEXPECTED;
-- arg-macro: function GST_FLOW_IS_SUCCESS (ret)
-- return (ret) >= GST_FLOW_OK;
-- unsupported macro: GST_PAD_LINK_CHECK_DEFAULT ((GstPadLinkCheck) (GST_PAD_LINK_CHECK_HIERARCHY | GST_PAD_LINK_CHECK_CAPS))
-- arg-macro: function GST_PAD_MODE_ACTIVATE (mode)
-- return (mode) /= GST_ACTIVATE_NONE;
-- arg-macro: function GST_PAD_NAME (pad)
-- return GST_OBJECT_NAME(pad);
-- arg-macro: function GST_PAD_PARENT (pad)
-- return GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad));
-- arg-macro: function GST_PAD_ELEMENT_PRIVATE (pad)
-- return GST_PAD_CAST(pad).element_private;
-- arg-macro: function GST_PAD_PAD_TEMPLATE (pad)
-- return GST_PAD_CAST(pad).padtemplate;
-- arg-macro: function GST_PAD_DIRECTION (pad)
-- return GST_PAD_CAST(pad).direction;
-- arg-macro: function GST_PAD_TASK (pad)
-- return GST_PAD_CAST(pad).task;
-- arg-macro: function GST_PAD_ACTIVATE_MODE (pad)
-- return GST_PAD_CAST(pad).mode;
-- arg-macro: function GST_PAD_ACTIVATEFUNC (pad)
-- return GST_PAD_CAST(pad).activatefunc;
-- arg-macro: function GST_PAD_ACTIVATEPUSHFUNC (pad)
-- return GST_PAD_CAST(pad).activatepushfunc;
-- arg-macro: function GST_PAD_ACTIVATEPULLFUNC (pad)
-- return GST_PAD_CAST(pad).activatepullfunc;
-- arg-macro: function GST_PAD_CHAINFUNC (pad)
-- return GST_PAD_CAST(pad).chainfunc;
-- arg-macro: function GST_PAD_CHECKGETRANGEFUNC (pad)
-- return GST_PAD_CAST(pad).checkgetrangefunc;
-- arg-macro: function GST_PAD_GETRANGEFUNC (pad)
-- return GST_PAD_CAST(pad).getrangefunc;
-- arg-macro: function GST_PAD_EVENTFUNC (pad)
-- return GST_PAD_CAST(pad).eventfunc;
-- arg-macro: function GST_PAD_QUERYTYPEFUNC (pad)
-- return GST_PAD_CAST(pad).querytypefunc;
-- arg-macro: function GST_PAD_QUERYFUNC (pad)
-- return GST_PAD_CAST(pad).queryfunc;
-- arg-macro: function GST_PAD_INTLINKFUNC (pad)
-- return GST_PAD_CAST(pad).intlinkfunc;
-- arg-macro: function GST_PAD_ITERINTLINKFUNC (pad)
-- return GST_PAD_CAST(pad).iterintlinkfunc;
-- arg-macro: function GST_PAD_PEER (pad)
-- return GST_PAD_CAST(pad).peer;
-- arg-macro: function GST_PAD_LINKFUNC (pad)
-- return GST_PAD_CAST(pad).linkfunc;
-- arg-macro: function GST_PAD_UNLINKFUNC (pad)
-- return GST_PAD_CAST(pad).unlinkfunc;
-- arg-macro: function GST_PAD_CAPS (pad)
-- return GST_PAD_CAST(pad).caps;
-- arg-macro: function GST_PAD_GETCAPSFUNC (pad)
-- return GST_PAD_CAST(pad).getcapsfunc;
-- arg-macro: function GST_PAD_SETCAPSFUNC (pad)
-- return GST_PAD_CAST(pad).setcapsfunc;
-- arg-macro: function GST_PAD_ACCEPTCAPSFUNC (pad)
-- return GST_PAD_CAST(pad).acceptcapsfunc;
-- arg-macro: function GST_PAD_FIXATECAPSFUNC (pad)
-- return GST_PAD_CAST(pad).fixatecapsfunc;
-- arg-macro: function GST_PAD_BUFFERALLOCFUNC (pad)
-- return GST_PAD_CAST(pad).bufferallocfunc;
-- arg-macro: function GST_PAD_DO_BUFFER_SIGNALS (pad)
-- return GST_PAD_CAST(pad).do_buffer_signals;
-- arg-macro: function GST_PAD_DO_EVENT_SIGNALS (pad)
-- return GST_PAD_CAST(pad).do_event_signals;
-- arg-macro: function GST_PAD_IS_LINKED (pad)
-- return GST_PAD_PEER(pad) /= NULL;
-- arg-macro: function GST_PAD_IS_BLOCKED (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKED);
-- arg-macro: function GST_PAD_IS_BLOCKING (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKING);
-- arg-macro: function GST_PAD_IS_FLUSHING (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING);
-- arg-macro: function GST_PAD_IS_IN_GETCAPS (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS);
-- arg-macro: function GST_PAD_IS_IN_SETCAPS (pad)
-- return GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS);
-- arg-macro: function GST_PAD_IS_SRC (pad)
-- return GST_PAD_DIRECTION(pad) = GST_PAD_SRC;
-- arg-macro: function GST_PAD_IS_SINK (pad)
-- return GST_PAD_DIRECTION(pad) = GST_PAD_SINK;
-- arg-macro: function GST_PAD_SET_FLUSHING (pad)
-- return GST_OBJECT_FLAG_SET (pad, GST_PAD_FLUSHING);
-- arg-macro: function GST_PAD_UNSET_FLUSHING (pad)
-- return GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLUSHING);
-- arg-macro: function GST_PAD_GET_STREAM_LOCK (pad)
-- return GST_PAD_CAST(pad).stream_rec_lock;
-- arg-macro: function GST_PAD_STREAM_LOCK (pad)
-- return g_static_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_STREAM_LOCK_FULL (pad, t)
-- return g_static_rec_mutex_lock_full(GST_PAD_GET_STREAM_LOCK(pad), t);
-- arg-macro: function GST_PAD_STREAM_TRYLOCK (pad)
-- return g_static_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_STREAM_UNLOCK (pad)
-- return g_static_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_STREAM_UNLOCK_FULL (pad)
-- return g_static_rec_mutex_unlock_full(GST_PAD_GET_STREAM_LOCK(pad));
-- arg-macro: function GST_PAD_GET_PREROLL_LOCK (pad)
-- return GST_PAD_CAST(pad).preroll_lock;
-- arg-macro: function GST_PAD_PREROLL_LOCK (pad)
-- return g_mutex_lock(GST_PAD_GET_PREROLL_LOCK(pad));
-- arg-macro: function GST_PAD_PREROLL_TRYLOCK (pad)
-- return g_mutex_trylock(GST_PAD_GET_PREROLL_LOCK(pad));
-- arg-macro: function GST_PAD_PREROLL_UNLOCK (pad)
-- return g_mutex_unlock(GST_PAD_GET_PREROLL_LOCK(pad));
-- arg-macro: function GST_PAD_GET_PREROLL_COND (pad)
-- return GST_PAD_CAST(pad).preroll_cond;
-- arg-macro: procedure GST_PAD_PREROLL_WAIT (pad)
-- g_cond_wait (GST_PAD_GET_PREROLL_COND (pad), GST_PAD_GET_PREROLL_LOCK (pad))
-- arg-macro: procedure GST_PAD_PREROLL_TIMED_WAIT (pad, timeval)
-- g_cond_timed_wait (GST_PAD_GET_PREROLL_COND (pad), GST_PAD_GET_PREROLL_LOCK (pad), timeval)
-- arg-macro: procedure GST_PAD_PREROLL_SIGNAL (pad)
-- g_cond_signal (GST_PAD_GET_PREROLL_COND (pad));
-- arg-macro: procedure GST_PAD_PREROLL_BROADCAST (pad)
-- g_cond_broadcast (GST_PAD_GET_PREROLL_COND (pad));
-- arg-macro: function GST_PAD_BLOCK_GET_COND (pad)
-- return GST_PAD_CAST(pad).block_cond;
-- arg-macro: function GST_PAD_BLOCK_WAIT (pad)
-- return g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad));
-- arg-macro: function GST_PAD_BLOCK_SIGNAL (pad)
-- return g_cond_signal(GST_PAD_BLOCK_GET_COND (pad));
-- arg-macro: function GST_PAD_BLOCK_BROADCAST (pad)
-- return g_cond_broadcast(GST_PAD_BLOCK_GET_COND (pad));
-- arg-macro: procedure gst_pad_get_name (pad)
-- gst_object_get_name (GST_OBJECT_CAST (pad))
-- arg-macro: procedure gst_pad_get_parent (pad)
-- gst_object_get_parent (GST_OBJECT_CAST (pad))
-- GStreamer
-- * Copyright (C) 1999,2000 Erik Walthinsen <[email protected]>
-- * 2000 Wim Taymans <[email protected]>
-- *
-- * gstpad.h: Header for GstPad object
-- *
-- * 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.
--
-- * Pad base class
--
type GstPad;
type anon_200;
type anon_201 is record
block_callback_called : aliased GLIB.gboolean; -- gst/gstpad.h:739
priv : System.Address; -- gst/gstpad.h:740
end record;
pragma Convention (C_Pass_By_Copy, anon_201);
type u_GstPad_u_gst_reserved_array is array (0 .. 1) of System.Address;
type anon_200 (discr : unsigned := 0) is record
case discr is
when 0 =>
ABI : aliased anon_201; -- gst/gstpad.h:741
when others =>
u_gst_reserved : u_GstPad_u_gst_reserved_array; -- gst/gstpad.h:742
end case;
end record;
pragma Convention (C_Pass_By_Copy, anon_200);
pragma Unchecked_Union (anon_200);--subtype GstPad is u_GstPad; -- gst/gstpad.h:50
-- skipped empty struct u_GstPadPrivate
-- skipped empty struct GstPadPrivate
type GstPadClass;
type u_GstPadClass_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstPadClass is u_GstPadClass; -- gst/gstpad.h:52
--*
-- * GstPadLinkReturn:
-- * @GST_PAD_LINK_OK : link succeeded
-- * @GST_PAD_LINK_WRONG_HIERARCHY: pads have no common grandparent
-- * @GST_PAD_LINK_WAS_LINKED : pad was already linked
-- * @GST_PAD_LINK_WRONG_DIRECTION: pads have wrong direction
-- * @GST_PAD_LINK_NOFORMAT : pads do not have common format
-- * @GST_PAD_LINK_NOSCHED : pads cannot cooperate in scheduling
-- * @GST_PAD_LINK_REFUSED : refused for some reason
-- *
-- * Result values from gst_pad_link and friends.
--
subtype GstPadLinkReturn is int;
GST_PAD_LINK_OK : constant GstPadLinkReturn := 0;
GST_PAD_LINK_WRONG_HIERARCHY : constant GstPadLinkReturn := -1;
GST_PAD_LINK_WAS_LINKED : constant GstPadLinkReturn := -2;
GST_PAD_LINK_WRONG_DIRECTION : constant GstPadLinkReturn := -3;
GST_PAD_LINK_NOFORMAT : constant GstPadLinkReturn := -4;
GST_PAD_LINK_NOSCHED : constant GstPadLinkReturn := -5;
GST_PAD_LINK_REFUSED : constant GstPadLinkReturn := -6; -- gst/gstpad.h:74
--*
-- * GST_PAD_LINK_FAILED:
-- * @ret: the #GstPadLinkReturn value
-- *
-- * Macro to test if the given #GstPadLinkReturn value indicates a failed
-- * link step.
--
--*
-- * GST_PAD_LINK_SUCCESSFUL:
-- * @ret: the #GstPadLinkReturn value
-- *
-- * Macro to test if the given #GstPadLinkReturn value indicates a successful
-- * link step.
--
--*
-- * GstFlowReturn:
-- * @GST_FLOW_RESEND: Resend buffer, possibly with new caps (not
-- * sent yet) (unused/unimplemented).
-- * @GST_FLOW_OK: Data passing was ok.
-- * @GST_FLOW_NOT_LINKED: Pad is not linked.
-- * @GST_FLOW_WRONG_STATE: Pad is in wrong state.
-- * @GST_FLOW_UNEXPECTED: Did not expect anything, like after EOS.
-- * @GST_FLOW_NOT_NEGOTIATED: Pad is not negotiated.
-- * @GST_FLOW_ERROR: Some (fatal) error occured. Element generating
-- * this error should post an error message with more
-- * details.
-- * @GST_FLOW_NOT_SUPPORTED: This operation is not supported.
-- * @GST_FLOW_CUSTOM_SUCCESS: Elements can use values starting from
-- * this (and higher) to define custom success
-- * codes. Since 0.10.7.
-- * @GST_FLOW_CUSTOM_SUCCESS_1: Pre-defined custom success code (define your
-- * custom success code to this to avoid compiler
-- * warnings). Since 0.10.29.
-- * @GST_FLOW_CUSTOM_SUCCESS_2: Pre-defined custom success code. Since 0.10.29.
-- * @GST_FLOW_CUSTOM_ERROR: Elements can use values starting from
-- * this (and lower) to define custom error codes.
-- * Since 0.10.7.
-- * @GST_FLOW_CUSTOM_ERROR_1: Pre-defined custom error code (define your
-- * custom error code to this to avoid compiler
-- * warnings). Since 0.10.29.
-- * @GST_FLOW_CUSTOM_ERROR_2: Pre-defined custom error code. Since 0.10.29.
-- *
-- * The result of passing data to a pad.
-- *
-- * Note that the custom return values should not be exposed outside of the
-- * element scope and are available since 0.10.7.
--
-- FIXME 0.11: remove custom flow returns
-- custom success starts here
-- core predefined
-- expected failures
-- error cases
-- custom error starts here
subtype GstFlowReturn is int;
GST_FLOW_CUSTOM_SUCCESS_2 : constant GstFlowReturn := 102;
GST_FLOW_CUSTOM_SUCCESS_1 : constant GstFlowReturn := 101;
GST_FLOW_CUSTOM_SUCCESS : constant GstFlowReturn := 100;
GST_FLOW_RESEND : constant GstFlowReturn := 1;
GST_FLOW_OK : constant GstFlowReturn := 0;
GST_FLOW_NOT_LINKED : constant GstFlowReturn := -1;
GST_FLOW_WRONG_STATE : constant GstFlowReturn := -2;
GST_FLOW_UNEXPECTED : constant GstFlowReturn := -3;
GST_FLOW_NOT_NEGOTIATED : constant GstFlowReturn := -4;
GST_FLOW_ERROR : constant GstFlowReturn := -5;
GST_FLOW_NOT_SUPPORTED : constant GstFlowReturn := -6;
GST_FLOW_CUSTOM_ERROR : constant GstFlowReturn := -100;
GST_FLOW_CUSTOM_ERROR_1 : constant GstFlowReturn := -101;
GST_FLOW_CUSTOM_ERROR_2 : constant GstFlowReturn := -102; -- gst/gstpad.h:150
--*
-- * GST_FLOW_IS_FATAL:
-- * @ret: a #GstFlowReturn value
-- *
-- * Macro to test if the given #GstFlowReturn value indicates a fatal
-- * error. This macro is mainly used in elements driving the pipeline to decide
-- * whether an error message should be posted on the bus. Note that such
-- * elements may also need to post an error message in the #GST_FLOW_NOT_LINKED
-- * case which is not caught by this macro.
-- *
-- * Deprecated: This macro is badly named and can't be used in any real
-- * scenarios without additional checks.
--
--*
-- * GST_FLOW_IS_SUCCESS:
-- * @ret: a #GstFlowReturn value
-- *
-- * Macro to test if the given #GstFlowReturn value indicates a
-- * successful result
-- * This macro is mainly used in elements to decide if the processing
-- * of a buffer was successful.
-- *
-- * Since: 0.10.7
-- *
-- * Deprecated: This macro is badly named and can't be used in any real
-- * scenarios without additional checks.
--
function gst_flow_get_name (ret : GstFlowReturn) return access GLIB.gchar; -- gst/gstpad.h:187
pragma Import (C, gst_flow_get_name, "gst_flow_get_name");
function gst_flow_to_quark (ret : GstFlowReturn) return Glib.GQuark; -- gst/gstpad.h:188
pragma Import (C, gst_flow_to_quark, "gst_flow_to_quark");
--*
-- * GstPadLinkCheck:
-- * @GST_PAD_LINK_CHECK_NOTHING: Don't check hierarchy or caps compatibility.
-- * @GST_PAD_LINK_CHECK_HIERARCHY: Check the pads have same parents/grandparents.
-- * Could be omitted if it is already known that the two elements that own the
-- * pads are in the same bin.
-- * @GST_PAD_LINK_CHECK_TEMPLATE_CAPS: Check if the pads are compatible by using
-- * their template caps. This is much faster than @GST_PAD_LINK_CHECK_CAPS, but
-- * would be unsafe e.g. if one pad has %GST_CAPS_ANY.
-- * @GST_PAD_LINK_CHECK_CAPS: Check if the pads are compatible by comparing the
-- * caps returned by gst_pad_get_caps().
-- *
-- * The amount of checking to be done when linking pads. @GST_PAD_LINK_CHECK_CAPS
-- * and @GST_PAD_LINK_CHECK_TEMPLATE_CAPS are mutually exclusive. If both are
-- * specified, expensive but safe @GST_PAD_LINK_CHECK_CAPS are performed.
-- *
-- * <warning><para>
-- * Only disable some of the checks if you are 100% certain you know the link
-- * will not fail because of hierarchy/caps compatibility failures. If uncertain,
-- * use the default checks (%GST_PAD_LINK_CHECK_DEFAULT) or the regular methods
-- * for linking the pads.
-- * </para></warning>
-- *
-- * Since: 0.10.30
--
subtype GstPadLinkCheck is unsigned;
GST_PAD_LINK_CHECK_NOTHING : constant GstPadLinkCheck := 0;
GST_PAD_LINK_CHECK_HIERARCHY : constant GstPadLinkCheck := 1;
GST_PAD_LINK_CHECK_TEMPLATE_CAPS : constant GstPadLinkCheck := 2;
GST_PAD_LINK_CHECK_CAPS : constant GstPadLinkCheck := 4; -- gst/gstpad.h:221
--*
-- * GST_PAD_LINK_CHECK_DEFAULT:
-- *
-- * The default checks done when linking pads (i.e. the ones used by
-- * gst_pad_link()).
-- *
-- * Since: 0.10.30
--
--*
-- * GstActivateMode:
-- * @GST_ACTIVATE_NONE: Pad will not handle dataflow
-- * @GST_ACTIVATE_PUSH: Pad handles dataflow in downstream push mode
-- * @GST_ACTIVATE_PULL: Pad handles dataflow in upstream pull mode
-- *
-- * The status of a GstPad. After activating a pad, which usually happens when the
-- * parent element goes from READY to PAUSED, the GstActivateMode defines if the
-- * pad operates in push or pull mode.
--
type GstActivateMode is
(GST_ACTIVATE_NONE,
GST_ACTIVATE_PUSH,
GST_ACTIVATE_PULL);
pragma Convention (C, GstActivateMode); -- gst/gstpad.h:247
--*
-- * GST_PAD_MODE_ACTIVATE:
-- * @mode: a #GstActivateMode
-- *
-- * Macro to test if the given #GstActivateMode value indicates that datapassing
-- * is possible or not.
--
-- pad states
--*
-- * GstPadActivateFunction:
-- * @pad: a #GstPad
-- *
-- * This function is called when the pad is activated during the element
-- * READY to PAUSED state change. By default this function will call the
-- * activate function that puts the pad in push mode but elements can
-- * override this function to activate the pad in pull mode if they wish.
-- *
-- * Returns: TRUE if the pad could be activated.
--
type GstPadActivateFunction is access function (arg1 : access GstPad) return GLIB.gboolean;
pragma Convention (C, GstPadActivateFunction); -- gst/gstpad.h:270
--*
-- * GstPadActivateModeFunction:
-- * @pad: a #GstPad
-- * @active: activate or deactivate the pad.
-- *
-- * The prototype of the push and pull activate functions.
-- *
-- * Returns: TRUE if the pad could be activated or deactivated.
--
type GstPadActivateModeFunction is access function (arg1 : access GstPad; arg2 : GLIB.gboolean) return GLIB.gboolean;
pragma Convention (C, GstPadActivateModeFunction); -- gst/gstpad.h:280
-- data passing
--*
-- * GstPadChainFunction:
-- * @pad: the sink #GstPad that performed the chain.
-- * @buffer: the #GstBuffer that is chained, not %NULL.
-- *
-- * A function that will be called on sinkpads when chaining buffers.
-- * The function typically processes the data contained in the buffer and
-- * either consumes the data or passes it on to the internally linked pad(s).
-- *
-- * The implementer of this function receives a refcount to @buffer and should
-- * gst_buffer_unref() when the buffer is no longer needed.
-- *
-- * When a chain function detects an error in the data stream, it must post an
-- * error on the bus and return an appropriate #GstFlowReturn value.
-- *
-- * Returns: #GST_FLOW_OK for success
--
type GstPadChainFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GstFlowReturn;
pragma Convention (C, GstPadChainFunction); -- gst/gstpad.h:301
--*
-- * GstPadChainListFunction:
-- * @pad: the sink #GstPad that performed the chain.
-- * @list: the #GstBufferList that is chained, not %NULL.
-- *
-- * A function that will be called on sinkpads when chaining buffer lists.
-- * The function typically processes the data contained in the buffer list and
-- * either consumes the data or passes it on to the internally linked pad(s).
-- *
-- * The implementer of this function receives a refcount to @list and
-- * should gst_buffer_list_unref() when the list is no longer needed.
-- *
-- * When a chainlist function detects an error in the data stream, it must
-- * post an error on the bus and return an appropriate #GstFlowReturn value.
-- *
-- * Returns: #GST_FLOW_OK for success
--
type GstPadChainListFunction is access function (arg1 : access GstPad; arg2 : System.Address) return GstFlowReturn;
pragma Convention (C, GstPadChainListFunction); -- gst/gstpad.h:320
--*
-- * GstPadGetRangeFunction:
-- * @pad: the src #GstPad to perform the getrange on.
-- * @offset: the offset of the range
-- * @length: the length of the range
-- * @buffer: a memory location to hold the result buffer, cannot be NULL.
-- *
-- * This function will be called on source pads when a peer element
-- * request a buffer at the specified @offset and @length. If this function
-- * returns #GST_FLOW_OK, the result buffer will be stored in @buffer. The
-- * contents of @buffer is invalid for any other return value.
-- *
-- * This function is installed on a source pad with
-- * gst_pad_set_getrange_function() and can only be called on source pads after
-- * they are successfully activated with gst_pad_activate_pull().
-- *
-- * @offset and @length are always given in byte units. @offset must normally be a value
-- * between 0 and the length in bytes of the data available on @pad. The
-- * length (duration in bytes) can be retrieved with a #GST_QUERY_DURATION or with a
-- * #GST_QUERY_SEEKING.
-- *
-- * Any @offset larger or equal than the length will make the function return
-- * #GST_FLOW_UNEXPECTED, which corresponds to EOS. In this case @buffer does not
-- * contain a valid buffer.
-- *
-- * The buffer size of @buffer will only be smaller than @length when @offset is
-- * near the end of the stream. In all other cases, the size of @buffer must be
-- * exactly the requested size.
-- *
-- * It is allowed to call this function with a 0 @length and valid @offset, in
-- * which case @buffer will contain a 0-sized buffer and the function returns
-- * #GST_FLOW_OK.
-- *
-- * When this function is called with a -1 @offset, the sequentially next buffer
-- * of length @length in the stream is returned.
-- *
-- * When this function is called with a -1 @length, a buffer with a default
-- * optimal length is returned in @buffer. The length might depend on the value
-- * of @offset.
-- *
-- * Returns: #GST_FLOW_OK for success and a valid buffer in @buffer. Any other
-- * return value leaves @buffer undefined.
--
type GstPadGetRangeFunction is access function
(arg1 : access GstPad;
arg2 : GLIB.guint64;
arg3 : GLIB.guint;
arg4 : System.Address) return GstFlowReturn;
pragma Convention (C, GstPadGetRangeFunction); -- gst/gstpad.h:365
--*
-- * GstPadEventFunction:
-- * @pad: the #GstPad to handle the event.
-- * @event: the #GstEvent to handle.
-- *
-- * Function signature to handle an event for the pad.
-- *
-- * Returns: TRUE if the pad could handle the event.
--
type GstPadEventFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean;
pragma Convention (C, GstPadEventFunction); -- gst/gstpad.h:377
-- FIXME: 0.11: deprecate me, check range should use seeking query
--*
-- * GstPadCheckGetRangeFunction:
-- * @pad: a #GstPad
-- *
-- * Check if @pad can be activated in pull mode.
-- *
-- * This function will be deprecated after 0.10; use the seeking query to check
-- * if a pad can support random access.
-- *
-- * Returns: TRUE if the pad can operate in pull mode.
--
type GstPadCheckGetRangeFunction is access function (arg1 : access GstPad) return GLIB.gboolean;
pragma Convention (C, GstPadCheckGetRangeFunction); -- gst/gstpad.h:392
-- internal links
--*
-- * GstPadIntLinkFunction:
-- * @pad: The #GstPad to query.
-- *
-- * The signature of the internal pad link function.
-- *
-- * Returns: (element-type Gst.Pad) (transfer container): a newly allocated #GList of pads that are linked to the given pad on
-- * the inside of the parent element.
-- *
-- * The caller must call g_list_free() on it after use.
-- *
-- * Deprecated: use the threadsafe #GstPadIterIntLinkFunction instead.
--
type GstPadIntLinkFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList;
pragma Convention (C, GstPadIntLinkFunction); -- gst/gstpad.h:409
--*
-- * GstPadIterIntLinkFunction:
-- * @pad: The #GstPad to query.
-- *
-- * The signature of the internal pad link iterator function.
-- *
-- * Returns: a new #GstIterator that will iterate over all pads that are
-- * linked to the given pad on the inside of the parent element.
-- *
-- * the caller must call gst_iterator_free() after usage.
-- *
-- * Since 0.10.21
--
type GstPadIterIntLinkFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator;
pragma Convention (C, GstPadIterIntLinkFunction); -- gst/gstpad.h:426
-- generic query function
--*
-- * GstPadQueryTypeFunction:
-- * @pad: a #GstPad to query
-- *
-- * The signature of the query types function.
-- *
-- * Returns: a constant array of query types
--
type GstPadQueryTypeFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType;
pragma Convention (C, GstPadQueryTypeFunction); -- gst/gstpad.h:437
--*
-- * GstPadQueryFunction:
-- * @pad: the #GstPad to query.
-- * @query: the #GstQuery object to execute
-- *
-- * The signature of the query function.
-- *
-- * Returns: TRUE if the query could be performed.
--
type GstPadQueryFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean;
pragma Convention (C, GstPadQueryFunction); -- gst/gstpad.h:448
-- linking
--*
-- * GstPadLinkFunction
-- * @pad: the #GstPad that is linked.
-- * @peer: the peer #GstPad of the link
-- *
-- * Function signature to handle a new link on the pad.
-- *
-- * Returns: the result of the link with the specified peer.
--
type GstPadLinkFunction is access function (arg1 : access GstPad; arg2 : access GstPad) return GstPadLinkReturn;
pragma Convention (C, GstPadLinkFunction); -- gst/gstpad.h:461
--*
-- * GstPadUnlinkFunction
-- * @pad: the #GstPad that is linked.
-- *
-- * Function signature to handle a unlinking the pad prom its peer.
--
type GstPadUnlinkFunction is access procedure (arg1 : access GstPad);
pragma Convention (C, GstPadUnlinkFunction); -- gst/gstpad.h:468
-- caps nego
--*
-- * GstPadGetCapsFunction:
-- * @pad: the #GstPad to get the capabilities of.
-- *
-- * Returns a copy of the capabilities of the specified pad. By default this
-- * function will return the pad template capabilities, but can optionally
-- * be overridden by elements.
-- *
-- * Returns: a newly allocated copy #GstCaps of the pad.
--
type GstPadGetCapsFunction is access function (arg1 : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
pragma Convention (C, GstPadGetCapsFunction); -- gst/gstpad.h:482
--*
-- * GstPadSetCapsFunction:
-- * @pad: the #GstPad to set the capabilities of.
-- * @caps: the #GstCaps to set
-- *
-- * Set @caps on @pad. By default this function updates the caps of the
-- * pad but the function can be overriden by elements to perform extra
-- * actions or verifications.
-- *
-- * Returns: TRUE if the caps could be set on the pad.
--
type GstPadSetCapsFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean;
pragma Convention (C, GstPadSetCapsFunction); -- gst/gstpad.h:495
--*
-- * GstPadAcceptCapsFunction:
-- * @pad: the #GstPad to check
-- * @caps: the #GstCaps to check
-- *
-- * Check if @pad can accept @caps. By default this function will see if @caps
-- * intersect with the result from gst_pad_get_caps() by can be overridden to
-- * perform extra checks.
-- *
-- * Returns: TRUE if the caps can be accepted by the pad.
--
type GstPadAcceptCapsFunction is access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean;
pragma Convention (C, GstPadAcceptCapsFunction); -- gst/gstpad.h:507
--*
-- * GstPadFixateCapsFunction:
-- * @pad: a #GstPad
-- * @caps: the #GstCaps to fixate
-- *
-- * Given possibly unfixed caps @caps, let @pad use its default preferred
-- * format to make a fixed caps. @caps should be writable. By default this
-- * function will pick the first value of any ranges or lists in the caps but
-- * elements can override this function to perform other behaviour.
--
type GstPadFixateCapsFunction is access procedure (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps);
pragma Convention (C, GstPadFixateCapsFunction); -- gst/gstpad.h:518
--*
-- * GstPadBufferAllocFunction:
-- * @pad: a sink #GstPad
-- * @offset: the desired offset of the buffer
-- * @size: the desired size of the buffer
-- * @caps: the desired caps of the buffer
-- * @buf: pointer to hold the allocated buffer.
-- *
-- * Ask the sinkpad @pad to allocate a buffer with @offset, @size and @caps.
-- * The result will be stored in @buf.
-- *
-- * The purpose of this function is to allocate a buffer that is optimal to
-- * be processed by @pad. The function is mostly overridden by elements that can
-- * provide a hardware buffer in order to avoid additional memcpy operations.
-- *
-- * The function can return a buffer that has caps different from the requested
-- * @caps, in which case the upstream element requests a format change to this
-- * new caps.
-- * If a format change was requested, the returned buffer will be one to hold
-- * the data of said new caps, so its size might be different from the requested
-- * @size.
-- *
-- * When this function returns anything else than #GST_FLOW_OK, the buffer allocation
-- * failed and @buf does not contain valid data. If the function returns #GST_FLOW_OK and
-- * the @buf is NULL, a #GstBuffer will be created with @caps, @offset and @size.
-- *
-- * By default this function returns a new buffer of @size and with @caps containing
-- * purely malloced data. The buffer should be freed with gst_buffer_unref()
-- * after usage.
-- *
-- * Returns: #GST_FLOW_OK if @buf contains a valid buffer, any other return
-- * value means @buf does not hold a valid buffer.
--
type GstPadBufferAllocFunction is access function
(arg1 : access GstPad;
arg2 : GLIB.guint64;
arg3 : GLIB.guint;
arg4 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
arg5 : System.Address) return GstFlowReturn;
pragma Convention (C, GstPadBufferAllocFunction); -- gst/gstpad.h:552
-- misc
--*
-- * GstPadDispatcherFunction:
-- * @pad: the #GstPad that is dispatched.
-- * @data: the gpointer to optional user data.
-- *
-- * A dispatcher function is called for all internally linked pads, see
-- * gst_pad_dispatcher().
-- *
-- * Returns: TRUE if the dispatching procedure has to be stopped.
--
type GstPadDispatcherFunction is access function (arg1 : access GstPad; arg2 : System.Address) return GLIB.gboolean;
pragma Convention (C, GstPadDispatcherFunction); -- gst/gstpad.h:566
--*
-- * GstPadBlockCallback:
-- * @pad: the #GstPad that is blockend or unblocked.
-- * @blocked: blocking state for the pad
-- * @user_data: the gpointer to optional user data.
-- *
-- * Callback used by gst_pad_set_blocked_async(). Gets called when the blocking
-- * operation succeeds.
--
type GstPadBlockCallback is access procedure
(arg1 : access GstPad;
arg2 : GLIB.gboolean;
arg3 : System.Address);
pragma Convention (C, GstPadBlockCallback); -- gst/gstpad.h:577
--*
-- * GstPadDirection:
-- * @GST_PAD_UNKNOWN: direction is unknown.
-- * @GST_PAD_SRC: the pad is a source pad.
-- * @GST_PAD_SINK: the pad is a sink pad.
-- *
-- * The direction of a pad.
--
type GstPadDirection is
(GST_PAD_UNKNOWN,
GST_PAD_SRC,
GST_PAD_SINK);
pragma Convention (C, GstPadDirection); -- gst/gstpad.h:591
--*
-- * GstPadFlags:
-- * @GST_PAD_BLOCKED: is dataflow on a pad blocked
-- * @GST_PAD_FLUSHING: is pad refusing buffers
-- * @GST_PAD_IN_GETCAPS: GstPadGetCapsFunction() is running now
-- * @GST_PAD_IN_SETCAPS: GstPadSetCapsFunction() is running now
-- * @GST_PAD_BLOCKING: is pad currently blocking on a buffer or event
-- * @GST_PAD_FLAG_LAST: offset to define more flags
-- *
-- * Pad state flags
--
-- padding
type GstPadFlags is new unsigned;
GST_PAD_BLOCKED : constant GstPadFlags := 16;
GST_PAD_FLUSHING : constant GstPadFlags := 32;
GST_PAD_IN_GETCAPS : constant GstPadFlags := 64;
GST_PAD_IN_SETCAPS : constant GstPadFlags := 128;
GST_PAD_BLOCKING : constant GstPadFlags := 256;
GST_PAD_FLAG_LAST : constant GstPadFlags := 4096; -- gst/gstpad.h:612
-- FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h)
-- subtype GstPadTemplate is GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate -- gst/gstpad.h:615
--*
-- * GstPad:
-- * @element_private: private data owned by the parent element
-- * @padtemplate: padtemplate for this pad
-- * @direction: the direction of the pad, cannot change after creating
-- * the pad.
-- * @stream_rec_lock: recursive stream lock of the pad, used to protect
-- * the data used in streaming.
-- * @task: task for this pad if the pad is actively driving dataflow.
-- * @preroll_lock: lock used when prerolling
-- * @preroll_cond: conf to signal preroll
-- * @block_cond: conditional to signal pad block
-- * @block_callback: callback for the pad block if any
-- * @block_data: user data for @block_callback
-- * @caps: the current caps of the pad
-- * @getcapsfunc: function to get caps of the pad
-- * @setcapsfunc: function to set caps on the pad
-- * @acceptcapsfunc: function to check if pad can accept caps
-- * @fixatecapsfunc: function to fixate caps
-- * @activatefunc: pad activation function
-- * @activatepushfunc: function to activate/deactivate pad in push mode
-- * @activatepullfunc: function to activate/deactivate pad in pull mode
-- * @linkfunc: function called when pad is linked
-- * @unlinkfunc: function called when pad is unlinked
-- * @peer: the pad this pad is linked to
-- * @sched_private: private storage for the scheduler
-- * @chainfunc: function to chain buffer to pad
-- * @checkgetrangefunc: function to check if pad can operate in pull mode
-- * @getrangefunc: function to get a range of data from a pad
-- * @eventfunc: function to send an event to a pad
-- * @mode: current activation mode of the pad
-- * @querytypefunc: get list of supported queries
-- * @queryfunc: perform a query on the pad
-- * @intlinkfunc: get the internal links of this pad
-- * @bufferallocfunc: function to allocate a buffer for this pad
-- * @do_buffer_signals: counter counting installed buffer signals
-- * @do_event_signals: counter counting installed event signals
-- * @iterintlinkfunc: get the internal links iterator of this pad
-- * @block_destroy_data: notify function for gst_pad_set_blocked_async_full()
-- *
-- * The #GstPad structure. Use the functions to update the variables.
--
type GstPad is record
object : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObject; -- gst/gstpad.h:660
element_private : System.Address; -- gst/gstpad.h:663
padtemplate : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; -- gst/gstpad.h:665
direction : aliased GstPadDirection; -- gst/gstpad.h:667
stream_rec_lock : access GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h.GStaticRecMutex; -- gst/gstpad.h:671
c_task : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttask_h.GstTask; -- gst/gstpad.h:672
preroll_lock : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GMutex; -- gst/gstpad.h:674
preroll_cond : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/gstpad.h:675
block_cond : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/gstpad.h:679
block_callback : GstPadBlockCallback; -- gst/gstpad.h:680
block_data : System.Address; -- gst/gstpad.h:681
caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:684
getcapsfunc : GstPadGetCapsFunction; -- gst/gstpad.h:685
setcapsfunc : GstPadSetCapsFunction; -- gst/gstpad.h:686
acceptcapsfunc : GstPadAcceptCapsFunction; -- gst/gstpad.h:687
fixatecapsfunc : GstPadFixateCapsFunction; -- gst/gstpad.h:688
activatefunc : GstPadActivateFunction; -- gst/gstpad.h:690
activatepushfunc : GstPadActivateModeFunction; -- gst/gstpad.h:691
activatepullfunc : GstPadActivateModeFunction; -- gst/gstpad.h:692
linkfunc : GstPadLinkFunction; -- gst/gstpad.h:695
unlinkfunc : GstPadUnlinkFunction; -- gst/gstpad.h:696
peer : access GstPad; -- gst/gstpad.h:697
sched_private : System.Address; -- gst/gstpad.h:699
chainfunc : GstPadChainFunction; -- gst/gstpad.h:702
checkgetrangefunc : GstPadCheckGetRangeFunction; -- gst/gstpad.h:703
getrangefunc : GstPadGetRangeFunction; -- gst/gstpad.h:704
eventfunc : GstPadEventFunction; -- gst/gstpad.h:705
mode : aliased GstActivateMode; -- gst/gstpad.h:707
querytypefunc : GstPadQueryTypeFunction; -- gst/gstpad.h:710
queryfunc : GstPadQueryFunction; -- gst/gstpad.h:711
intlinkfunc : GstPadIntLinkFunction; -- gst/gstpad.h:715
bufferallocfunc : GstPadBufferAllocFunction; -- gst/gstpad.h:722
do_buffer_signals : aliased GLIB.gint; -- gst/gstpad.h:726
do_event_signals : aliased GLIB.gint; -- gst/gstpad.h:727
iterintlinkfunc : GstPadIterIntLinkFunction; -- gst/gstpad.h:731
block_destroy_data : GStreamer.GST_Low_Level.glib_2_0_glib_gtypes_h.GDestroyNotify; -- gst/gstpad.h:734
abidata : aliased anon_200; -- gst/gstpad.h:743
end record;
pragma Convention (C_Pass_By_Copy, GstPad); -- gst/gstpad.h:659
--< public >
--< public >
-- with STREAM_LOCK
-- streaming rec_lock
--< public >
-- with PREROLL_LOCK
--< public >
-- with LOCK
-- block cond, mutex is from the object
-- the pad capabilities
-- pad link
-- data transport functions
-- generic query method
-- internal links
-- whether to emit signals for have-data. counts number
-- * of handlers attached.
-- ABI added
-- iterate internal links
-- free block_data
--< private >
type GstPadClass is record
parent_class : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObjectClass; -- gst/gstpad.h:747
linked : access procedure (arg1 : access GstPad; arg2 : access GstPad); -- gst/gstpad.h:750
unlinked : access procedure (arg1 : access GstPad; arg2 : access GstPad); -- gst/gstpad.h:751
request_link : access procedure (arg1 : access GstPad); -- gst/gstpad.h:752
have_data : access function (arg1 : access GstPad; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h.GstMiniObject) return GLIB.gboolean; -- gst/gstpad.h:753
u_gst_reserved : u_GstPadClass_u_gst_reserved_array; -- gst/gstpad.h:756
end record;
pragma Convention (C_Pass_By_Copy, GstPadClass); -- gst/gstpad.h:746
-- signal callbacks
--< private >
--**** helper macros ****
-- GstPad
--*
-- * GST_PAD_CAPS:
-- * @pad: a #GstPad.
-- *
-- * The caps for this pad.
--
--*
-- * GST_PAD_GET_STREAM_LOCK:
-- * @pad: a #GstPad
-- *
-- * Get the stream lock of @pad. The stream lock is protecting the
-- * resources used in the data processing functions of @pad.
--
--*
-- * GST_PAD_STREAM_LOCK:
-- * @pad: a #GstPad
-- *
-- * Lock the stream lock of @pad.
--
--*
-- * GST_PAD_STREAM_LOCK_FULL:
-- * @pad: a #GstPad
-- * @t: the number of times to recursively lock
-- *
-- * Lock the stream lock of @pad @t times.
--
--*
-- * GST_PAD_STREAM_TRYLOCK:
-- * @pad: a #GstPad
-- *
-- * Try to Lock the stream lock of the pad, return TRUE if the lock could be
-- * taken.
--
--*
-- * GST_PAD_STREAM_UNLOCK:
-- * @pad: a #GstPad
-- *
-- * Unlock the stream lock of @pad.
--
--*
-- * GST_PAD_STREAM_UNLOCK_FULL:
-- * @pad: a #GstPad
-- *
-- * Fully unlock the recursive stream lock of @pad, return the number of times
-- * @pad was locked.
--
-- FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h)
function gst_pad_get_type return GLIB.GType; -- gst/gstpad.h:885
pragma Import (C, gst_pad_get_type, "gst_pad_get_type");
-- creating pads
function gst_pad_new (name : access GLIB.gchar; direction : GstPadDirection) return access GstPad; -- gst/gstpad.h:888
pragma Import (C, gst_pad_new, "gst_pad_new");
function gst_pad_new_from_template (templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; name : access GLIB.gchar) return access GstPad; -- gst/gstpad.h:889
pragma Import (C, gst_pad_new_from_template, "gst_pad_new_from_template");
function gst_pad_new_from_static_template (templ : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstStaticPadTemplate; name : access GLIB.gchar) return access GstPad; -- gst/gstpad.h:890
pragma Import (C, gst_pad_new_from_static_template, "gst_pad_new_from_static_template");
--*
-- * gst_pad_get_name:
-- * @pad: the pad to get the name from
-- *
-- * Get a copy of the name of the pad. g_free() after usage.
-- *
-- * MT safe.
--
--*
-- * gst_pad_get_parent:
-- * @pad: the pad to get the parent of
-- *
-- * Get the parent of @pad. This function increases the refcount
-- * of the parent object so you should gst_object_unref() it after usage.
-- * Can return NULL if the pad did not have a parent.
-- *
-- * MT safe.
--
function gst_pad_get_direction (pad : access GstPad) return GstPadDirection; -- gst/gstpad.h:914
pragma Import (C, gst_pad_get_direction, "gst_pad_get_direction");
function gst_pad_set_active (pad : access GstPad; active : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:916
pragma Import (C, gst_pad_set_active, "gst_pad_set_active");
function gst_pad_is_active (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:917
pragma Import (C, gst_pad_is_active, "gst_pad_is_active");
function gst_pad_activate_pull (pad : access GstPad; active : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:918
pragma Import (C, gst_pad_activate_pull, "gst_pad_activate_pull");
function gst_pad_activate_push (pad : access GstPad; active : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:919
pragma Import (C, gst_pad_activate_push, "gst_pad_activate_push");
function gst_pad_set_blocked (pad : access GstPad; blocked : GLIB.gboolean) return GLIB.gboolean; -- gst/gstpad.h:921
pragma Import (C, gst_pad_set_blocked, "gst_pad_set_blocked");
function gst_pad_set_blocked_async
(pad : access GstPad;
blocked : GLIB.gboolean;
callback : GstPadBlockCallback;
user_data : System.Address) return GLIB.gboolean; -- gst/gstpad.h:922
pragma Import (C, gst_pad_set_blocked_async, "gst_pad_set_blocked_async");
function gst_pad_set_blocked_async_full
(pad : access GstPad;
blocked : GLIB.gboolean;
callback : GstPadBlockCallback;
user_data : System.Address;
destroy_data : GStreamer.GST_Low_Level.glib_2_0_glib_gtypes_h.GDestroyNotify) return GLIB.gboolean; -- gst/gstpad.h:924
pragma Import (C, gst_pad_set_blocked_async_full, "gst_pad_set_blocked_async_full");
function gst_pad_is_blocked (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:927
pragma Import (C, gst_pad_is_blocked, "gst_pad_is_blocked");
function gst_pad_is_blocking (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:928
pragma Import (C, gst_pad_is_blocking, "gst_pad_is_blocking");
procedure gst_pad_set_element_private (pad : access GstPad; priv : System.Address); -- gst/gstpad.h:930
pragma Import (C, gst_pad_set_element_private, "gst_pad_set_element_private");
function gst_pad_get_element_private (pad : access GstPad) return System.Address; -- gst/gstpad.h:931
pragma Import (C, gst_pad_get_element_private, "gst_pad_get_element_private");
function gst_pad_get_pad_template (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpadtemplate_h.GstPadTemplate; -- gst/gstpad.h:933
pragma Import (C, gst_pad_get_pad_template, "gst_pad_get_pad_template");
procedure gst_pad_set_bufferalloc_function (pad : access GstPad; bufalloc : GstPadBufferAllocFunction); -- gst/gstpad.h:935
pragma Import (C, gst_pad_set_bufferalloc_function, "gst_pad_set_bufferalloc_function");
function gst_pad_alloc_buffer
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.gint;
caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
buf : System.Address) return GstFlowReturn; -- gst/gstpad.h:936
pragma Import (C, gst_pad_alloc_buffer, "gst_pad_alloc_buffer");
function gst_pad_alloc_buffer_and_set_caps
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.gint;
caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps;
buf : System.Address) return GstFlowReturn; -- gst/gstpad.h:938
pragma Import (C, gst_pad_alloc_buffer_and_set_caps, "gst_pad_alloc_buffer_and_set_caps");
-- data passing setup functions
procedure gst_pad_set_activate_function (pad : access GstPad; activate : GstPadActivateFunction); -- gst/gstpad.h:942
pragma Import (C, gst_pad_set_activate_function, "gst_pad_set_activate_function");
procedure gst_pad_set_activatepull_function (pad : access GstPad; activatepull : GstPadActivateModeFunction); -- gst/gstpad.h:943
pragma Import (C, gst_pad_set_activatepull_function, "gst_pad_set_activatepull_function");
procedure gst_pad_set_activatepush_function (pad : access GstPad; activatepush : GstPadActivateModeFunction); -- gst/gstpad.h:944
pragma Import (C, gst_pad_set_activatepush_function, "gst_pad_set_activatepush_function");
procedure gst_pad_set_chain_function (pad : access GstPad; chain : GstPadChainFunction); -- gst/gstpad.h:945
pragma Import (C, gst_pad_set_chain_function, "gst_pad_set_chain_function");
procedure gst_pad_set_chain_list_function (pad : access GstPad; chainlist : GstPadChainListFunction); -- gst/gstpad.h:946
pragma Import (C, gst_pad_set_chain_list_function, "gst_pad_set_chain_list_function");
procedure gst_pad_set_getrange_function (pad : access GstPad; get : GstPadGetRangeFunction); -- gst/gstpad.h:947
pragma Import (C, gst_pad_set_getrange_function, "gst_pad_set_getrange_function");
procedure gst_pad_set_checkgetrange_function (pad : access GstPad; check : GstPadCheckGetRangeFunction); -- gst/gstpad.h:948
pragma Import (C, gst_pad_set_checkgetrange_function, "gst_pad_set_checkgetrange_function");
procedure gst_pad_set_event_function (pad : access GstPad; event : GstPadEventFunction); -- gst/gstpad.h:949
pragma Import (C, gst_pad_set_event_function, "gst_pad_set_event_function");
-- pad links
procedure gst_pad_set_link_function (pad : access GstPad; link : GstPadLinkFunction); -- gst/gstpad.h:952
pragma Import (C, gst_pad_set_link_function, "gst_pad_set_link_function");
procedure gst_pad_set_unlink_function (pad : access GstPad; unlink : GstPadUnlinkFunction); -- gst/gstpad.h:953
pragma Import (C, gst_pad_set_unlink_function, "gst_pad_set_unlink_function");
function gst_pad_can_link (srcpad : access GstPad; sinkpad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:955
pragma Import (C, gst_pad_can_link, "gst_pad_can_link");
function gst_pad_link (srcpad : access GstPad; sinkpad : access GstPad) return GstPadLinkReturn; -- gst/gstpad.h:956
pragma Import (C, gst_pad_link, "gst_pad_link");
function gst_pad_link_full
(srcpad : access GstPad;
sinkpad : access GstPad;
flags : GstPadLinkCheck) return GstPadLinkReturn; -- gst/gstpad.h:957
pragma Import (C, gst_pad_link_full, "gst_pad_link_full");
function gst_pad_unlink (srcpad : access GstPad; sinkpad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:958
pragma Import (C, gst_pad_unlink, "gst_pad_unlink");
function gst_pad_is_linked (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:959
pragma Import (C, gst_pad_is_linked, "gst_pad_is_linked");
function gst_pad_get_peer (pad : access GstPad) return access GstPad; -- gst/gstpad.h:961
pragma Import (C, gst_pad_get_peer, "gst_pad_get_peer");
-- capsnego functions
procedure gst_pad_set_getcaps_function (pad : access GstPad; getcaps : GstPadGetCapsFunction); -- gst/gstpad.h:964
pragma Import (C, gst_pad_set_getcaps_function, "gst_pad_set_getcaps_function");
procedure gst_pad_set_acceptcaps_function (pad : access GstPad; acceptcaps : GstPadAcceptCapsFunction); -- gst/gstpad.h:965
pragma Import (C, gst_pad_set_acceptcaps_function, "gst_pad_set_acceptcaps_function");
procedure gst_pad_set_fixatecaps_function (pad : access GstPad; fixatecaps : GstPadFixateCapsFunction); -- gst/gstpad.h:966
pragma Import (C, gst_pad_set_fixatecaps_function, "gst_pad_set_fixatecaps_function");
procedure gst_pad_set_setcaps_function (pad : access GstPad; setcaps : GstPadSetCapsFunction); -- gst/gstpad.h:967
pragma Import (C, gst_pad_set_setcaps_function, "gst_pad_set_setcaps_function");
function gst_pad_get_pad_template_caps (pad : access GstPad) return access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:969
pragma Import (C, gst_pad_get_pad_template_caps, "gst_pad_get_pad_template_caps");
-- capsnego function for linked/unlinked pads
function gst_pad_get_caps_reffed (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:972
pragma Import (C, gst_pad_get_caps_reffed, "gst_pad_get_caps_reffed");
function gst_pad_get_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:973
pragma Import (C, gst_pad_get_caps, "gst_pad_get_caps");
procedure gst_pad_fixate_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps); -- gst/gstpad.h:974
pragma Import (C, gst_pad_fixate_caps, "gst_pad_fixate_caps");
function gst_pad_accept_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/gstpad.h:975
pragma Import (C, gst_pad_accept_caps, "gst_pad_accept_caps");
function gst_pad_set_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/gstpad.h:976
pragma Import (C, gst_pad_set_caps, "gst_pad_set_caps");
function gst_pad_peer_get_caps_reffed (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:978
pragma Import (C, gst_pad_peer_get_caps_reffed, "gst_pad_peer_get_caps_reffed");
function gst_pad_peer_get_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:979
pragma Import (C, gst_pad_peer_get_caps, "gst_pad_peer_get_caps");
function gst_pad_peer_accept_caps (pad : access GstPad; caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/gstpad.h:980
pragma Import (C, gst_pad_peer_accept_caps, "gst_pad_peer_accept_caps");
-- capsnego for linked pads
function gst_pad_get_allowed_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:983
pragma Import (C, gst_pad_get_allowed_caps, "gst_pad_get_allowed_caps");
function gst_pad_get_negotiated_caps (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/gstpad.h:984
pragma Import (C, gst_pad_get_negotiated_caps, "gst_pad_get_negotiated_caps");
-- data passing functions to peer
function gst_pad_push (pad : access GstPad; buffer : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GstFlowReturn; -- gst/gstpad.h:987
pragma Import (C, gst_pad_push, "gst_pad_push");
function gst_pad_push_list (pad : access GstPad; list : System.Address) return GstFlowReturn; -- gst/gstpad.h:988
pragma Import (C, gst_pad_push_list, "gst_pad_push_list");
function gst_pad_check_pull_range (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:989
pragma Import (C, gst_pad_check_pull_range, "gst_pad_check_pull_range");
function gst_pad_pull_range
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.guint;
buffer : System.Address) return GstFlowReturn; -- gst/gstpad.h:990
pragma Import (C, gst_pad_pull_range, "gst_pad_pull_range");
function gst_pad_push_event (pad : access GstPad; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstpad.h:992
pragma Import (C, gst_pad_push_event, "gst_pad_push_event");
function gst_pad_event_default (pad : access GstPad; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstpad.h:993
pragma Import (C, gst_pad_event_default, "gst_pad_event_default");
-- data passing functions on pad
function gst_pad_chain (pad : access GstPad; buffer : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GstFlowReturn; -- gst/gstpad.h:996
pragma Import (C, gst_pad_chain, "gst_pad_chain");
function gst_pad_chain_list (pad : access GstPad; list : System.Address) return GstFlowReturn; -- gst/gstpad.h:997
pragma Import (C, gst_pad_chain_list, "gst_pad_chain_list");
function gst_pad_get_range
(pad : access GstPad;
offset : GLIB.guint64;
size : GLIB.guint;
buffer : System.Address) return GstFlowReturn; -- gst/gstpad.h:998
pragma Import (C, gst_pad_get_range, "gst_pad_get_range");
function gst_pad_send_event (pad : access GstPad; event : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent) return GLIB.gboolean; -- gst/gstpad.h:1000
pragma Import (C, gst_pad_send_event, "gst_pad_send_event");
-- pad tasks
function gst_pad_start_task
(pad : access GstPad;
func : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttask_h.GstTaskFunction;
data : System.Address) return GLIB.gboolean; -- gst/gstpad.h:1003
pragma Import (C, gst_pad_start_task, "gst_pad_start_task");
function gst_pad_pause_task (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:1005
pragma Import (C, gst_pad_pause_task, "gst_pad_pause_task");
function gst_pad_stop_task (pad : access GstPad) return GLIB.gboolean; -- gst/gstpad.h:1006
pragma Import (C, gst_pad_stop_task, "gst_pad_stop_task");
-- internal links
procedure gst_pad_set_internal_link_function (pad : access GstPad; intlink : GstPadIntLinkFunction); -- gst/gstpad.h:1010
pragma Import (C, gst_pad_set_internal_link_function, "gst_pad_set_internal_link_function");
function gst_pad_get_internal_links (pad : access GstPad) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstpad.h:1011
pragma Import (C, gst_pad_get_internal_links, "gst_pad_get_internal_links");
function gst_pad_get_internal_links_default (pad : access GstPad) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/gstpad.h:1012
pragma Import (C, gst_pad_get_internal_links_default, "gst_pad_get_internal_links_default");
procedure gst_pad_set_iterate_internal_links_function (pad : access GstPad; iterintlink : GstPadIterIntLinkFunction); -- gst/gstpad.h:1015
pragma Import (C, gst_pad_set_iterate_internal_links_function, "gst_pad_set_iterate_internal_links_function");
function gst_pad_iterate_internal_links (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstpad.h:1017
pragma Import (C, gst_pad_iterate_internal_links, "gst_pad_iterate_internal_links");
function gst_pad_iterate_internal_links_default (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstiterator_h.GstIterator; -- gst/gstpad.h:1018
pragma Import (C, gst_pad_iterate_internal_links_default, "gst_pad_iterate_internal_links_default");
-- generic query function
procedure gst_pad_set_query_type_function (pad : access GstPad; type_func : GstPadQueryTypeFunction); -- gst/gstpad.h:1022
pragma Import (C, gst_pad_set_query_type_function, "gst_pad_set_query_type_function");
function gst_pad_get_query_types (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType; -- gst/gstpad.h:1023
pragma Import (C, gst_pad_get_query_types, "gst_pad_get_query_types");
function gst_pad_get_query_types_default (pad : access GstPad) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQueryType; -- gst/gstpad.h:1024
pragma Import (C, gst_pad_get_query_types_default, "gst_pad_get_query_types_default");
function gst_pad_query (pad : access GstPad; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstpad.h:1026
pragma Import (C, gst_pad_query, "gst_pad_query");
function gst_pad_peer_query (pad : access GstPad; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstpad.h:1027
pragma Import (C, gst_pad_peer_query, "gst_pad_peer_query");
procedure gst_pad_set_query_function (pad : access GstPad; query : GstPadQueryFunction); -- gst/gstpad.h:1028
pragma Import (C, gst_pad_set_query_function, "gst_pad_set_query_function");
function gst_pad_query_default (pad : access GstPad; query : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstquery_h.GstQuery) return GLIB.gboolean; -- gst/gstpad.h:1029
pragma Import (C, gst_pad_query_default, "gst_pad_query_default");
-- misc helper functions
function gst_pad_dispatcher
(pad : access GstPad;
dispatch : GstPadDispatcherFunction;
data : System.Address) return GLIB.gboolean; -- gst/gstpad.h:1032
pragma Import (C, gst_pad_dispatcher, "gst_pad_dispatcher");
procedure gst_pad_load_and_link (self : GStreamer.GST_Low_Level.libxml2_libxml_tree_h.xmlNodePtr; parent : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObject); -- gst/gstpad.h:1036
pragma Import (C, gst_pad_load_and_link, "gst_pad_load_and_link");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
|
stcarrez/dynamo | Ada | 23,873 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A 4 G . D D A _ A U X --
-- --
-- S p e c --
-- --
-- $Revision: 14154 $
-- --
-- Copyright (C) 1999-2001 Ada Core Technologies, 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 2, 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 COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- This package contains auxiliary routines used to support the data
-- decomposition annex. At the level of this package, types and components
-- are represented by their normal Entity_Id values. The corresponding
-- entities have the necessary representation information stored in them.
-- DDA_Aux acts as an interface between the main ASIS routines and all
-- representation issues.
with Asis.Data_Decomposition;
with Repinfo; use Repinfo;
with Types; use Types;
with Uintp; use Uintp;
package A4G.DDA_Aux is
--------------------------------
-- Portable_Data Declarations --
--------------------------------
-- Asis.Data_Decomposition.Portable_Value;
-- Portable values are simply bytes, i.e. defined as mod 256. This is
-- fine for all the byte addressable architectures that GNAT runs on
-- now, and we will worry later about exotic cases (which may well
-- never arise).
-- Portable_Positive is Asis.Data_Decomposition.Portable_Positive;
-- This is simply a synonym for Asis.ASIS_Positive
-- Asis.Data_Decomposition.Portable_Data;
-- This is array (Portable_Positive range <>) of Portable_Data. Thus
-- it is simply an array of bytes. The representation of data in this
-- format is as follows:
--
-- For non-scalar values, the data value is stored at the start of
-- the value, occupying as many bits as needed. If there are padding
-- bits (on the right), they are stored as zero bits when a value is
-- retrieved, and ignored when a value is stored.
--
-- For scalar values, the data value is of length 1, 2, 4, or 8 bytes
-- in proper little-endian or big-endian format with sign or zero
-- bits filling the unused high order bits. For enumeration values,
-- this is the Enum_Rep value, i.e. the actual stored value, not the
-- Pos value. For biased types, the value is unsigned and biased.
---------------------------------
-- Basic Interface Definiitons --
---------------------------------
Variable_Rep_Info : exception;
-- This exception is raised if an attempt is made to access representation
-- information that depends on the value of a variable other than a
-- discriminant for the current record. For example, if the length of
-- a component of subtype String (1 .. N) is requested, and N is not a
-- discriminant or a static constant.
Invalid_Data : exception;
-- Exception raised if an invalid data value is detected. There is no
-- systematic checking for invalid values, but there are some situations
-- in which bad values are detected, and this exception is raised.
No_Component : exception;
-- Exception raised if a request is made to access a component in a
-- variant part of a record when the component does not exist for the
-- particular set of discriminant values present. Also raised if a
-- request is made to access an out of bounds subscript value for an
-- array element.
Null_Discrims : Repinfo.Discrim_List (1 .. 0) := (others => Uint_0);
-- Used as default if no discriminants given
----------------------
-- Utility Routines --
----------------------
function Build_Discrim_List
(Rec : Entity_Id;
Data : Asis.Data_Decomposition.Portable_Data)
return Repinfo.Discrim_List;
-- Given a record entity, and a value of this record type, builds a
-- list of discriminants from the given value and returns it. The
-- portable data value must include at least all the discriminants
-- if the type is for a discriminated record. If Rec is other than
-- a discriminated record type, then Data is ignored and Null_Discrims
-- is returned.
function Eval_Scalar_Node
(N : Node_Id;
Discs : Repinfo.Discrim_List := Null_Discrims)
return Uint;
-- This function is used to get the value of a node representing a value
-- of a scalar type. Evaluation is possible for static expressions and
-- for discriminant values (in the latter case, Discs must be provided
-- and must contain the appropriate list of discriminants). Note that
-- in the case of enumeration values, the result is the Pos value, not
-- the Enum_Rep value for the given enumeration literal.
--
-- Raises Variable_Rep_Info is raised if the expression is other than
-- a discriminant or a static expression, or if it is a discriminant
-- and no discriminant list is provided.
--
-- Note that this functionality is related to that provided by
-- Sem_Eval.Expr_Value, but this unit is not available in ASIS.
function Linear_Index
(Typ : Entity_Id;
Subs : Asis.Data_Decomposition.Dimension_Indexes;
Discs : Repinfo.Discrim_List := Null_Discrims)
return Asis.ASIS_Natural;
-- Given Typ, the entity for a definite array type or subtype, and Subs,
-- a list of 1's origin subscripts (that is, as usual Dimension_Indexes
-- has subscripts that are 1's origin with respect to the declared lower
-- bound), this routine computes the corresponding zero-origin linear
-- index from the start of the array data. The case of Fortran convention
-- (with row major order) is properly handled.
--
-- Raises No_Component if any of the subscripts is out of range (i.e.
-- exceeds the length of the corresponding subscript position).
function UI_From_Aint (A : Asis.ASIS_Integer) return Uint;
-- Converts ASIS_Integer value to Uint
function UI_Is_In_Aint_Range (U : Uint) return Boolean;
-- Determine if a universal integer value U is in range of ASIS_Integer.
-- Returns True iff in range (meaning that UI_To_Aint can be safely used).
function UI_To_Aint (U : Uint) return Asis.ASIS_Integer;
-- Converts Uint value to ASIS_Integer, the result must be in range
-- of ASIS_Integer, or otherwise the exception Invalid_Data is raised.
--------------------------------
-- Universal Integer Encoding --
--------------------------------
-- These routines deal with decoding and encoding scalar values from
-- Uint to portable data format.
function Encode_Scalar_Value
(Typ : Entity_Id;
Val : Uint)
return Asis.Data_Decomposition.Portable_Data;
-- Given Typ, the entity for a scalar type or subtype, this function
-- constructs a portable data valuethat represents a value of this
-- type given by Val. The value of the Uint may not exceed the largest
-- scalar value supported by the implementation. The result will be 1,
-- 2, 4 or 8 bytes long depending on the value of the input, positioned
-- to be intepreted as an integer, and sign or zero extended as needed.
-- For enumeration types, the value is the Enum_Rep value, not the Pos
-- value. For biased types, the bias is NOT present in the Uint value
-- (part of the job of Encode_Scalar_Value is to introduce the bias).
--
-- Raises Invalid_Data if value is out of range of the base type of Typ
function Encode_Scalar_Value
(Typ : Entity_Id;
Val : Asis.ASIS_Integer)
return Asis.Data_Decomposition.Portable_Data;
-- Similar to above function except input is ASIS_Integer instead of Uint
function Decode_Scalar_Value
(Typ : Entity_Id;
Data : Asis.Data_Decomposition.Portable_Data)
return Uint;
-- Given Typ, the entity for a scalar type or subtype, this function
-- takes the portable data value Data, that represents a value of
-- this type, and returns the equivalent Uint value. For enumeration
-- types the value is the Enum_Rep value, not the Pos value. For biased
-- types, the result is unbiased (part of the job of Decode_Scalar_Value
-- is to remove the bias).
--------------------------------
-- Record Discriminant Access --
--------------------------------
function Extract_Discriminant
(Data : Asis.Data_Decomposition.Portable_Data;
Disc : Entity_Id)
return Uint;
-- This function can be used to extract a discriminant value from a
-- record. Data is the portable data value representing the record
-- value, and Disc is the E_Discriminant entity for the discriminant.
function Set_Discriminant
(Data : Asis.Data_Decomposition.Portable_Data;
Disc : Entity_Id;
Val : Uint)
return Asis.Data_Decomposition.Portable_Data;
-- Given Data, a portable data value representing the prefix of a record
-- value which may already have some other discriminant values set, this
-- function creates a new Portable_Data value, increased in length
-- if necessary, in which the discriminant represented by E_Discriminant
-- entity Disc is set to the given value.
--
-- Raises Invalid_Data if the value does not fit in the field
procedure Set_Discriminant
(Data : in out Asis.Data_Decomposition.Portable_Data;
Disc : Entity_Id;
Val : Uint);
-- Similar to the function above, except that the modification is done
-- in place on the given portable data value. In this case, the Data
-- value must be long enough to contain the given discriminant field.
function Set_Discriminant
(Data : Asis.Data_Decomposition.Portable_Data;
Disc : Entity_Id;
Val : Asis.ASIS_Integer)
return Asis.Data_Decomposition.Portable_Data;
-- Similar to function above, but takes argument in ASIS_Integer form
procedure Set_Discriminant
(Data : in out Asis.Data_Decomposition.Portable_Data;
Disc : Entity_Id;
Val : Asis.ASIS_Integer);
-- Similar to function above, but takes argument in ASIS_Integer form
-----------------------------
-- Record Component Access --
-----------------------------
function Component_Present
(Comp : Entity_Id;
Discs : Repinfo.Discrim_List)
return Boolean;
-- Determines if the given component is present or not. For the case
-- where the component is part of a variant of a discriminated record,
-- Discs must contain the full list of discriminants for the record,
-- and the result is True or False depending on whether the variant
-- containing the field is present or not for the given discriminant
-- values. If the component is not part of a variant, including the
-- case where the record is non-discriminated, then Discs is ignored
-- and the result is always True.
function Extract_Record_Component
(Data : Asis.Data_Decomposition.Portable_Data;
Comp : Entity_Id;
Discs : Repinfo.Discrim_List := Null_Discrims)
return Asis.Data_Decomposition.Portable_Data;
-- Given Data, a portable data value representing a record value, this
-- routine extracts the component value corresponding to E_Component
-- entity Comp, and returns a new portable data value corresponding to
-- this component. The Discs parameter supplies the discriminants and
-- must be present in the discriminated record case if the component
-- may depend on discriminants. For scalar types, the result value
-- is 1,2,4, or 8 bytes, properly positioned to be interpreted as an
-- integer, and sign/zero extended as required. For all other types,
-- the value is extended if necessary to be an integral number of
-- bytes by adding zero bits.
--
-- Raises No_Component if an attempt is made to set a component in a
-- non-existent variant.
--
-- Raises No_Component if the specified component is part of a variant
-- that does not exist for the given discriminant values
--
-- Raises Variable_Rep_Info if the size or position of the component
-- depends on a variable other than a discriminant
function Set_Record_Component
(Data : Asis.Data_Decomposition.Portable_Data;
Comp : Entity_Id;
Val : Asis.Data_Decomposition.Portable_Data;
Discs : Repinfo.Discrim_List := Null_Discrims)
return Asis.Data_Decomposition.Portable_Data;
-- Given Data, a portable data value that represents a record value,
-- or a prefix of such a record, sets the component represented by the
-- E_Component entity Comp is set to the value represented by the portable
-- data value Val, and the result is returned as a portable data value,
-- extended in length if necessary to accomodate the newly added entry.
-- The Discs parameter supplies the discriminants and must be present
-- in the discriminated record case if the component may depend on
-- the values of discriminants.
--
-- Raises No_Component if an attempt is made to set a component in a
-- non-existent variant.
--
-- Raises No_Component if the specified component is part of a variant
-- that does not exist for the given discriminant values
--
-- Raises Variable_Rep_Info if the size or position of the component
-- depends on a variable other than a discriminant
--
-- Raises Invalid_Data if the data value is too large to fit.
procedure Set_Record_Component
(Data : in out Asis.Data_Decomposition.Portable_Data;
Comp : Entity_Id;
Val : Asis.Data_Decomposition.Portable_Data;
Discs : Repinfo.Discrim_List := Null_Discrims);
-- Same as the above, but operates in place on the given data value,
-- which must in this case be long enough to contain the component.
----------------------------
-- Array Component Access --
----------------------------
function Extract_Array_Component
(Typ : Entity_Id;
Data : Asis.Data_Decomposition.Portable_Data;
Subs : Asis.Data_Decomposition.Dimension_Indexes;
Discs : Repinfo.Discrim_List := Null_Discrims)
return Asis.Data_Decomposition.Portable_Data;
-- Given Typ, the entity for an array type, and Data, a portable data
-- value representing a value of this array type, this function extracts
-- the array element corresponding to the given list of subscript values.
-- The parameter Discs must be given if any of the bounds of the array
-- may depend on discriminant values, and supplies the corresponding
-- discriminants. For scalar component types, the value is 1,2,4, or 8,
-- properly positioned to be interpreted as an integer, and sign/zero
-- extended as required. For all other types, the value is extended if
-- necessary to be an integral number of bytes by adding zero bits.
--
-- Raises No_Component if any of the subscripts is out of bounds
-- (that is, exceeds the length of the corresponding index).
--
-- Raises Variable_Rep_Info if length of any index depends on a
-- variable other than a discriminant.
--
function Set_Array_Component
(Typ : Entity_Id;
Data : Asis.Data_Decomposition.Portable_Data;
Subs : Asis.Data_Decomposition.Dimension_Indexes;
Val : Asis.Data_Decomposition.Portable_Data;
Discs : Repinfo.Discrim_List := Null_Discrims)
return Asis.Data_Decomposition.Portable_Data;
-- Given a portable data value representing either a value of the array
-- type Typ, or a prefix of such a value, sets the element referenced by
-- the given subscript values in Subs, to the given value Val. The
-- parameter Discs must be given if any of the bounds of the array
-- may depend on discriminant values, and supplies the corresponding
-- discriminants. The returned result is the original portable data
-- value, extended if necessary to include the new element, with the
-- new element value in place.
--
-- Raises No_Component if any of the subscripts is out of bounds
-- (that is, exceeds the length of the corresponding index).
--
-- Raises Variable_Rep_Info if length of any index depends on a
-- variable other than a discriminant.
--
-- Raises Invalid_Data if the data value is too large to fit.
procedure Set_Array_Component
(Typ : Entity_Id;
Data : in out Asis.Data_Decomposition.Portable_Data;
Subs : Asis.Data_Decomposition.Dimension_Indexes;
Val : Asis.Data_Decomposition.Portable_Data;
Discs : Repinfo.Discrim_List := Null_Discrims);
-- Same as above, but operates in place on the given stream. The stream
-- must be long enough to contain the given element in this case.
-------------------------------
-- Representation Parameters --
-------------------------------
-- These routines give direct access to the values of the
-- representation fields stored in the tree, including the
-- proper interpretation of variable values that depend on
-- the values of discriminants.
function Get_Esize
(Comp : Entity_Id;
Discs : Repinfo.Discrim_List := Null_Discrims)
return Uint;
-- Obtains the size (actually the object size, Esize) of any subtype
-- or record component or discriminant. The function can be used for
-- components of discriminanted or non-discriminated records. In the
-- case of components of a discriminated record where the value depends
-- on discriminants, Discs provides the necessary discriminant values.
-- In all other cases, Discs is ignored and can be defaulted.
--
-- Raises Variable_Rep_Info if the size depends on a variable other
-- than a discriminant.
--
-- Raises No_Component if the component is in a variant that does not
-- exist for the given set of discriminant values.
function Get_Component_Bit_Offset
(Comp : Entity_Id;
Discs : Repinfo.Discrim_List := Null_Discrims)
return Uint;
-- Obtains the component first bit value for the specified component or
-- discriminant. This function can be used for discriminanted or non-
-- discriminanted records. In the case of components of a discriminated
-- record where the value depends on discriminants, Discs provides the
-- necessary discriminant values. Otherwise (and in particular in the case
-- of discriminants themselves), Discs is ignored and can be defaulted.
--
-- Raises Variable_Rep_Info if the size depends on a variable other
-- than a discriminant.
--
-- Raises No_Component if the component is in a variant that does not
-- exist for the given set of discriminant values.
function Get_Component_Size
(Typ : Entity_Id)
return Uint;
-- Given an array type or subtype, returns the component size value
function Get_Length
(Typ : Entity_Id;
Sub : Asis.ASIS_Positive;
Discs : Repinfo.Discrim_List := Null_Discrims)
return Asis.ASIS_Natural;
-- Given Typ, the entity for a definite array type or subtype, returns
-- the Length of the subscript designated by Sub (1 = first subscript
-- as in Length attribute). If the bounds of the array may depend on
-- discriminants, then Discs contains the list of discriminant values
-- (e.g. if we have an array field A.B, then the discriminants of A
-- may be needed).
--
-- Raises Variable_Rep_Info if the size depends on a variable other
-- than a discriminant.
-------------------------------
-- Computation of Attributes --
-------------------------------
-- The DDA_Aux package simply provides access to the representation
-- information stored in the tree, as described in Einfo, as refined
-- by the description in Repinfo with regard to the case where some
-- of the values depend on discriminants.
-- The ASIS spec requires that ASIS be able to compute the values of
-- the attributes Position, First_Bit, and Last_Bit.
-- This is done as follows. First compute the Size (with Get_Esize)
-- and the Component_Bit_Offset (with Get_Component_Bit_Offset). In the
-- case of a nested reference, e.g.
-- A.B.C
-- You need to extract the value A.B, and then ask for the
-- size of its component C, and also the component first bit
-- value of this component C.
-- This value gets added to the Component_Bit_Offset value for
-- the B field in A.
-- For arrays, the equivalent of Component_Bit_Offset is computed simply
-- as the zero origin linearized subscript multiplied by the value of
-- Component_Size for the array. As another example, consider:
-- A.B(15)
-- In this case you get the component first bit of the field B in A,
-- using the discriminants of A if there are any. Then you get the
-- component first bit of the 15th element of B, using the discriminants
-- of A (since the bounds of B may depend on them). You then add these
-- two component first bit values.
-- Once you have the aggregated value of the first bit offset (i.e. the
-- sum of the Component_Bit_Offset values and corresponding array offsets
-- for all levels of the access), then the formula is simply:
-- X'Position = First_Bit_Offset / Storage_Unit_Size
-- X'First = First_Bit_Offset mod Storage_Unit_Size
-- X'Last = X'First + component_size - 1
end A4G.DDA_Aux;
|
AdaCore/gpr | Ada | 3,723 | ads | --
-- Copyright (C) 2022, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0
--
-- This package can be used to facilitate GNATCOLL.Projects to GPR2 conversion
-- It provides primitives to emulate:
-- GNATCOLL.Projects.Artifacts_Dir
-- GNATCOLL.Projects.Attribute_Value
-- GNATCOLL.Projects.Create
-- GNATCOLL.Projects.Get_Runtime
-- GNATCOLL.Projects.Get_Target
-- GNATCOLL.Projects.Name
-- GNATCOLL.Projects.Object_Dir
-- GNATCOLL.Projects.Register_New_Attribute
-- The following file path types conversions are provided
-- GNATCOLL.VFS.Filesystem_String / GPR2.Path_Name.Object
-- GNATCOLL.VFS.Virtual_File / GPR2.Path_Name.Object
-- Output_Messages procedure can be used to print info/warnings/error messages
with GNAT.Strings;
with GNATCOLL.VFS;
with GPR2; use GPR2;
with GPR2.Log;
with GPR2.Path_Name;
with GPR2.Project.Tree;
with GPR2.Project.View;
package GPR2_GNATCOLL_Projects is
function Artifacts_Dir
(Project : GPR2.Project.View.Object)
return GNATCOLL.VFS.Virtual_File;
-- GNATCOLL.Projects.Artifacts_Dir (Project : Project_Type) conversion
-- WARNING: this function is handling subdirs.
function Object_Dir
(Project : GPR2.Project.View.Object)
return GNATCOLL.VFS.Virtual_File
is
(if Project.Is_Defined
then GPR2.Path_Name.Virtual_File (Project.Object_Directory)
else GNATCOLL.VFS.No_File);
-- GNATCOLL.Projects.Object_Dir (Project : Project_Type) conversion
-- WARNING: this function is handling subdirs.
function Name
(Project : GPR2.Project.View.Object) return String
is
(if Project.Is_Defined then String (Project.Name) else "default");
-- GNATCOLL.Projects.Name (Project : Project_Type) conversion
function Get_Runtime
(Project : GPR2.Project.View.Object) return String
is
(String (Project.Tree.Runtime (Ada_Language)));
-- GNATCOLL.Projects.Get_Runtime (Project : Project_Type) conversion
function Create
(Self : GPR2.Project.Tree.Object;
Name : GNATCOLL.VFS.Filesystem_String;
Project : GPR2.Project.View.Object'Class :=
GPR2.Project.View.Undefined;
Use_Source_Path : Boolean := True;
Use_Object_Path : Boolean := True)
return GNATCOLL.VFS.Virtual_File;
-- GNATCOLL.Projects.Create function conversion
function Register_New_Attribute
(Name : Q_Attribute_Id;
Is_List : Boolean := False;
Indexed : Boolean := False;
Case_Sensitive_Index : Boolean := False) return String;
-- GNATCOLL.Projects.Register_New_Attribute conversion
function Attribute_Value
(Project : GPR2.Project.View.Object;
Name : Q_Attribute_Id;
Index : String := "";
Default : String := "";
Use_Extended : Boolean := False) return String;
-- GNATCOLL.Projects.Attribute_Value conversion (string attribute)
function Attribute_Value
(Project : GPR2.Project.View.Object;
Name : Q_Attribute_Id;
Index : String := "";
Use_Extended : Boolean := False)
return GNAT.Strings.String_List_Access;
-- GNATCOLL.Projects.Attribute_Value conversion (string list attribute)
procedure Output_Messages
(Log : GPR2.Log.Object;
Output_Warnings : Boolean := True;
Output_Information : Boolean := False);
-- print Log content
function Get_Target
(Tree : GPR2.Project.Tree.Object) return String
is
(if Tree.Add_Tool_Prefix ("x") = "x"
then ""
else String (Tree.Target));
-- GNATCOLL.Projects.Get_Target conversion
end GPR2_GNATCOLL_Projects;
|
optikos/oasis | Ada | 4,466 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Nodes.Record_Types is
function Create
(Abstract_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Tagged_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Limited_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Record_Definition : not null Program.Elements.Definitions
.Definition_Access)
return Record_Type is
begin
return Result : Record_Type :=
(Abstract_Token => Abstract_Token, Tagged_Token => Tagged_Token,
Limited_Token => Limited_Token,
Record_Definition => Record_Definition, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Record_Definition : not null Program.Elements.Definitions
.Definition_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Record_Type is
begin
return Result : Implicit_Record_Type :=
(Record_Definition => Record_Definition,
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 Record_Definition
(Self : Base_Record_Type)
return not null Program.Elements.Definitions.Definition_Access is
begin
return Self.Record_Definition;
end Record_Definition;
overriding function Abstract_Token
(Self : Record_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Abstract_Token;
end Abstract_Token;
overriding function Tagged_Token
(Self : Record_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Tagged_Token;
end Tagged_Token;
overriding function Limited_Token
(Self : Record_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Limited_Token;
end Limited_Token;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Record_Type)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Record_Type)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Record_Type)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
procedure Initialize (Self : aliased in out Base_Record_Type'Class) is
begin
Set_Enclosing_Element (Self.Record_Definition, Self'Unchecked_Access);
null;
end Initialize;
overriding function Is_Record_Type_Element
(Self : Base_Record_Type)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Record_Type_Element;
overriding function Is_Type_Definition_Element
(Self : Base_Record_Type)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Type_Definition_Element;
overriding function Is_Definition_Element
(Self : Base_Record_Type)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Definition_Element;
overriding procedure Visit
(Self : not null access Base_Record_Type;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Record_Type (Self);
end Visit;
overriding function To_Record_Type_Text
(Self : aliased in out Record_Type)
return Program.Elements.Record_Types.Record_Type_Text_Access is
begin
return Self'Unchecked_Access;
end To_Record_Type_Text;
overriding function To_Record_Type_Text
(Self : aliased in out Implicit_Record_Type)
return Program.Elements.Record_Types.Record_Type_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Record_Type_Text;
end Program.Nodes.Record_Types;
|
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.Anchor_Type_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Anchor_Type_Attribute_Node is
begin
return Self : Text_Anchor_Type_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_Anchor_Type_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Anchor_Type_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Anchor_Type_Attribute,
Text_Anchor_Type_Attribute_Node'Tag);
end Matreshka.ODF_Text.Anchor_Type_Attributes;
|
charlie5/aIDE | Ada | 544 | adb | package body AdaM.Assist.Query.find_All.Actuals_for_traversing
is
-------------
-- Post_Op --
-------------
procedure Post_Op
(Element : Asis.Element;
Control : in out Asis.Traverse_Control;
State : in out Traversal_State)
is separate;
------------
-- Pre_Op --
------------
procedure Pre_Op
(Element : Asis.Element;
Control : in out Asis.Traverse_Control;
State : in out Traversal_State)
is separate;
end AdaM.Assist.Query.find_All.Actuals_for_traversing;
|
MinimSecure/unum-sdk | Ada | 887 | adb | -- Copyright 2008-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Types; use Types;
procedure Foo is
R : Rectangle := (1, 2, 3, 4);
S : Object'Class := Ident (R);
begin
Do_Nothing (R); -- STOP
Do_Nothing (S);
end Foo;
|
persan/A-gst | Ada | 7,587 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
-- with GStreamer.GST_Low_Level.glib_2_0_gobject_gobject_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
with System;
with glib;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_base_gstadapter_h is
-- unsupported macro: GST_TYPE_ADAPTER (gst_adapter_get_type())
-- arg-macro: function GST_ADAPTER (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_ADAPTER, GstAdapter);
-- arg-macro: function GST_ADAPTER_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_ADAPTER, GstAdapterClass);
-- arg-macro: function GST_ADAPTER_GET_CLASS (obj)
-- return G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ADAPTER, GstAdapterClass);
-- arg-macro: function GST_IS_ADAPTER (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_ADAPTER);
-- arg-macro: function GST_IS_ADAPTER_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_ADAPTER);
-- GStreamer
-- * Copyright (C) 2004 Benjamin Otte <[email protected]>
-- *
-- * 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.
--
type GstAdapter;
type u_GstAdapter_u_gst_reserved_array is array (0 .. 1) of System.Address;
--subtype GstAdapter is u_GstAdapter; -- gst/base/gstadapter.h:41
type GstAdapterClass;
type u_GstAdapterClass_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstAdapterClass is u_GstAdapterClass; -- gst/base/gstadapter.h:42
-- skipped empty struct u_GstAdapterPrivate
-- skipped empty struct GstAdapterPrivate
--*
-- * GstAdapter:
-- *
-- * The opaque #GstAdapter data structure.
--
type GstAdapter is record
object : aliased GLIB.Object.GObject; -- gst/base/gstadapter.h:51
buflist : access GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h.GSList; -- gst/base/gstadapter.h:54
size : aliased GLIB.guint; -- gst/base/gstadapter.h:55
skip : aliased GLIB.guint; -- gst/base/gstadapter.h:56
assembled_data : access GLIB.guint8; -- gst/base/gstadapter.h:59
assembled_size : aliased GLIB.guint; -- gst/base/gstadapter.h:60
assembled_len : aliased GLIB.guint; -- gst/base/gstadapter.h:61
buflist_end : access GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h.GSList; -- gst/base/gstadapter.h:66
priv : System.Address; -- gst/base/gstadapter.h:68
u_gst_reserved : u_GstAdapter_u_gst_reserved_array; -- gst/base/gstadapter.h:70
end record;
pragma Convention (C_Pass_By_Copy, GstAdapter); -- gst/base/gstadapter.h:50
--< private >
-- we keep state of assembled pieces
-- ABI added
-- Remember where the end of our buffer list is to
-- * speed up the push
type GstAdapterClass is record
parent_class : aliased GLIB.Object.GObject_Class; -- gst/base/gstadapter.h:74
u_gst_reserved : u_GstAdapterClass_u_gst_reserved_array; -- gst/base/gstadapter.h:77
end record;
pragma Convention (C_Pass_By_Copy, GstAdapterClass); -- gst/base/gstadapter.h:73
--< private >
function gst_adapter_get_type return GLIB.GType; -- gst/base/gstadapter.h:80
pragma Import (C, gst_adapter_get_type, "gst_adapter_get_type");
function gst_adapter_new return access GstAdapter; -- gst/base/gstadapter.h:82
pragma Import (C, gst_adapter_new, "gst_adapter_new");
procedure gst_adapter_clear (adapter : access GstAdapter); -- gst/base/gstadapter.h:84
pragma Import (C, gst_adapter_clear, "gst_adapter_clear");
procedure gst_adapter_push (adapter : access GstAdapter; buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer); -- gst/base/gstadapter.h:85
pragma Import (C, gst_adapter_push, "gst_adapter_push");
function gst_adapter_peek (adapter : access GstAdapter; size : GLIB.guint) return access GLIB.guint8; -- gst/base/gstadapter.h:86
pragma Import (C, gst_adapter_peek, "gst_adapter_peek");
procedure gst_adapter_copy
(adapter : access GstAdapter;
dest : access GLIB.guint8;
offset : GLIB.guint;
size : GLIB.guint); -- gst/base/gstadapter.h:87
pragma Import (C, gst_adapter_copy, "gst_adapter_copy");
procedure gst_adapter_flush (adapter : access GstAdapter; flush : GLIB.guint); -- gst/base/gstadapter.h:89
pragma Import (C, gst_adapter_flush, "gst_adapter_flush");
function gst_adapter_take (adapter : access GstAdapter; nbytes : GLIB.guint) return access GLIB.guint8; -- gst/base/gstadapter.h:90
pragma Import (C, gst_adapter_take, "gst_adapter_take");
function gst_adapter_take_buffer (adapter : access GstAdapter; nbytes : GLIB.guint) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/base/gstadapter.h:91
pragma Import (C, gst_adapter_take_buffer, "gst_adapter_take_buffer");
function gst_adapter_take_list (adapter : access GstAdapter; nbytes : GLIB.guint) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/base/gstadapter.h:92
pragma Import (C, gst_adapter_take_list, "gst_adapter_take_list");
function gst_adapter_available (adapter : access GstAdapter) return GLIB.guint; -- gst/base/gstadapter.h:93
pragma Import (C, gst_adapter_available, "gst_adapter_available");
function gst_adapter_available_fast (adapter : access GstAdapter) return GLIB.guint; -- gst/base/gstadapter.h:94
pragma Import (C, gst_adapter_available_fast, "gst_adapter_available_fast");
function gst_adapter_prev_timestamp (adapter : access GstAdapter; distance : access GLIB.guint64) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; -- gst/base/gstadapter.h:96
pragma Import (C, gst_adapter_prev_timestamp, "gst_adapter_prev_timestamp");
function gst_adapter_masked_scan_uint32
(adapter : access GstAdapter;
mask : GLIB.guint32;
pattern : GLIB.guint32;
offset : GLIB.guint;
size : GLIB.guint) return GLIB.guint; -- gst/base/gstadapter.h:98
pragma Import (C, gst_adapter_masked_scan_uint32, "gst_adapter_masked_scan_uint32");
function gst_adapter_masked_scan_uint32_peek
(adapter : access GstAdapter;
mask : GLIB.guint32;
pattern : GLIB.guint32;
offset : GLIB.guint;
size : GLIB.guint;
value : access GLIB.guint32) return GLIB.guint; -- gst/base/gstadapter.h:101
pragma Import (C, gst_adapter_masked_scan_uint32_peek, "gst_adapter_masked_scan_uint32_peek");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_base_gstadapter_h;
|
stcarrez/ada-asf | Ada | 4,957 | ads | -----------------------------------------------------------------------
-- html -- ASF HTML Components
-- Copyright (C) 2009, 2010, 2011, 2017, 2018, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Beans.Objects;
with ASF.Components.Holders;
with ASF.Converters;
-- The <b>Text</b> package implements various components used to print text outputs.
--
-- See JSR 314 - JavaServer Faces Specification 4.1.10 UIOutput
--
-- The <b>UILabel</b> and <b>UIOutputFormat</b> components is ASF implementation of
-- the JavaServer Faces outputLabel and outputFormat components
-- (implemented with UIOutput in Java).
package ASF.Components.Html.Text is
-- ------------------------------
-- Output Component
-- ------------------------------
type UIOutput is new UIHtmlComponent and Holders.Value_Holder with private;
-- Get the local value of the component without evaluating
-- the associated Value_Expression.
overriding
function Get_Local_Value (UI : in UIOutput) return EL.Objects.Object;
-- Get the value of the component. If the component has a local
-- value which is not null, returns it. Otherwise, if we have a Value_Expression
-- evaluate and returns the value.
overriding
function Get_Value (UI : in UIOutput) return EL.Objects.Object;
-- Set the value to write on the output.
overriding
procedure Set_Value (UI : in out UIOutput;
Value : in EL.Objects.Object);
-- Get the converter that is registered on the component.
overriding
function Get_Converter (UI : in UIOutput)
return ASF.Converters.Converter_Access;
-- Set the converter to be used on the component.
overriding
procedure Set_Converter (UI : in out UIOutput;
Converter : in ASF.Converters.Converter_Access;
Release : in Boolean := False);
-- Get the converter associated with the component
function Get_Converter (UI : in UIOutput;
Context : in Faces_Context'Class)
return access ASF.Converters.Converter'Class;
overriding
procedure Finalize (UI : in out UIOutput);
-- Get the value of the component and apply the To_String converter on it if there is one.
function Get_Formatted_Value (UI : in UIOutput;
Context : in Contexts.Faces.Faces_Context'Class) return String;
-- Format the value by applying the To_String converter on it if there is one.
function Get_Formatted_Value (UI : in UIOutput;
Value : in Util.Beans.Objects.Object;
Context : in Contexts.Faces.Faces_Context'Class) return String;
procedure Write_Output (UI : in UIOutput;
Context : in out Contexts.Faces.Faces_Context'Class;
Value : in String);
overriding
procedure Encode_Begin (UI : in UIOutput;
Context : in out Contexts.Faces.Faces_Context'Class);
-- ------------------------------
-- Label Component
-- ------------------------------
type UIOutputLabel is new UIOutput with private;
overriding
procedure Encode_Begin (UI : in UIOutputLabel;
Context : in out Contexts.Faces.Faces_Context'Class);
overriding
procedure Encode_End (UI : in UIOutputLabel;
Context : in out Contexts.Faces.Faces_Context'Class);
-- ------------------------------
-- OutputFormat Component
-- ------------------------------
--
type UIOutputFormat is new UIOutput with private;
overriding
procedure Encode_Begin (UI : in UIOutputFormat;
Context : in out Contexts.Faces.Faces_Context'Class);
private
type UIOutput is new UIHtmlComponent and Holders.Value_Holder with record
Value : EL.Objects.Object;
Converter : ASF.Converters.Converter_Access := null;
Release_Converter : Boolean := False;
end record;
type UIOutputLabel is new UIOutput with null record;
type UIOutputFormat is new UIOutput with null record;
end ASF.Components.Html.Text;
|
zhmu/ananas | Ada | 360 | ads | pragma Restrictions (No_Exception_Propagation);
package Warn31 is
type U16 is mod 2 ** 16;
type U32 is mod 2 ** 32;
type Pair is record
X, Y : U16;
end record;
for Pair'Alignment use U32'Alignment;
Blob : array (1 .. 2) of Pair;
Sum : array (1 .. 2) of U32;
for Sum'Address use Blob'Address;
procedure Dummy;
end Warn31; |
reznikmm/matreshka | Ada | 3,774 | 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.Style_Text_Combine_End_Char_Attributes is
pragma Preelaborate;
type ODF_Style_Text_Combine_End_Char_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Style_Text_Combine_End_Char_Attribute_Access is
access all ODF_Style_Text_Combine_End_Char_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Style_Text_Combine_End_Char_Attributes;
|
persan/protobuf-ada | Ada | 152 | adb | with Protobuf_Unittest.TestExtremeDefaultValues;
procedure Main is
I : Protobuf_Unittest.TestExtremeDefaultValues.Instance;
begin
null;
end main;
|
reznikmm/matreshka | Ada | 4,177 | 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_Second_Light_Direction_Attributes;
package Matreshka.ODF_Draw.Extrusion_Second_Light_Direction_Attributes is
type Draw_Extrusion_Second_Light_Direction_Attribute_Node is
new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node
and ODF.DOM.Draw_Extrusion_Second_Light_Direction_Attributes.ODF_Draw_Extrusion_Second_Light_Direction_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Extrusion_Second_Light_Direction_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Draw_Extrusion_Second_Light_Direction_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Draw.Extrusion_Second_Light_Direction_Attributes;
|
iyan22/AprendeAda | Ada | 1,884 | adb | with Ada.Text_Io; use Ada.Text_Io;
with vectores; use vectores;
with eliminar_tercer_elemento, escribir_vector;
procedure prueba_eliminar_tercer_elemento is
-- este programa hace llamadas al subprograma eliminar_tercer_elemento
-- para comprobar si su funcionamiento es correcto
Lista1: Vector_de_enteros(1..10);
Lista2: Vector_de_enteros(1..2);
begin
Lista1:=(1, 3, 5, 7, 19, 6, 13, 15, 17, 9);
put_line("Caso 1: lista de diez elementos: (1, 3, 5, 7, 19, 6, 13, 15, 17, 9)");
put_line(" la lista inicial es: ");
escribir_vector(Lista1);
new_line;
put_line(" el resultado deberia de ser 1 3 7 19 6 13 15 17 9 -1 <--> SIN IMPORTAR EL ORDEN DE LOS ELEMENTOS");
put_line("y la lista resultado es: ");
eliminar_tercer_elemento(Lista1);
escribir_vector(Lista1);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
-- faltan varios casos de prueba
Lista1:=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
put_line("Caso 2: lista de diez elementos: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)");
put_line(" la lista inicial es: ");
escribir_vector(Lista1);
new_line;
put_line(" el resultado deberia de ser 1 2 4 5 6 7 8 9 -1 <--> SIN IMPORTAR EL ORDEN DE LOS ELEMENTOS");
put_line("y la lista resultado es: ");
eliminar_tercer_elemento(Lista1);
escribir_vector(Lista1);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
Lista2:= (1, 2);
put_line("Caso 2: lista de dos elementos: (1, 2)");
put_line(" la lista inicial es: ");
escribir_vector(Lista2);
new_line;
put_line(" el resultado deberia de ser 1 2 ");
put_line("y la lista resultado es: ");
eliminar_tercer_elemento(Lista2);
escribir_vector(Lista2);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
end prueba_eliminar_tercer_elemento;
|
reznikmm/matreshka | Ada | 4,687 | 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_Draw.Fill_Image_Ref_Point_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Fill_Image_Ref_Point_Attribute_Node is
begin
return Self : Draw_Fill_Image_Ref_Point_Attribute_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Fill_Image_Ref_Point_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Fill_Image_Ref_Point_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Fill_Image_Ref_Point_Attribute,
Draw_Fill_Image_Ref_Point_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Fill_Image_Ref_Point_Attributes;
|
AdaCore/training_material | Ada | 10,795 | adb | ------------------------------------------------------------------------------
-- --
-- Hardware Abstraction Layer for STM32 Targets --
-- --
-- Copyright (C) 2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with STM32F4.RCC; use STM32F4.RCC;
package body STM32F4_Discovery is
All_LEDs : constant GPIO_Pins := LED3 & LED4 & LED5 & LED6;
--------
-- On --
--------
procedure On (This : User_LED) is
begin
Set (GPIO_D, This);
end On;
---------
-- Off --
---------
procedure Off (This : User_LED) is
begin
Clear (GPIO_D, This);
end Off;
------------
-- Toggle --
------------
procedure Toggle (This : User_LED) is
begin
Toggle (GPIO_D, This);
end Toggle;
------------------
-- All_LEDs_Off --
------------------
procedure All_LEDs_Off is
begin
Clear (GPIO_D, All_LEDs);
end All_LEDs_Off;
-----------------
-- All_LEDs_On --
-----------------
procedure All_LEDs_On is
begin
Set (GPIO_D, All_LEDs);
end All_LEDs_On;
---------------------
-- Initialize_LEDs --
---------------------
procedure Initialize_LEDs is
Configuration : GPIO_Port_Configuration;
begin
Enable_Clock (GPIO_D);
Configuration.Mode := Mode_Out;
Configuration.Output_Type := Push_Pull;
Configuration.Speed := Speed_100MHz;
Configuration.Resistors := Floating;
Configure_IO (Port => GPIO_D,
Pins => All_LEDs,
Config => Configuration);
end Initialize_LEDs;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : aliased in out GPIO_Port) is
begin
if This'Address = System'To_Address (GPIOA_Base) then
GPIOA_Clock_Enable;
elsif This'Address = System'To_Address (GPIOB_Base) then
GPIOB_Clock_Enable;
elsif This'Address = System'To_Address (GPIOC_Base) then
GPIOC_Clock_Enable;
elsif This'Address = System'To_Address (GPIOD_Base) then
GPIOD_Clock_Enable;
elsif This'Address = System'To_Address (GPIOE_Base) then
GPIOE_Clock_Enable;
elsif This'Address = System'To_Address (GPIOF_Base) then
GPIOF_Clock_Enable;
elsif This'Address = System'To_Address (GPIOG_Base) then
GPIOG_Clock_Enable;
elsif This'Address = System'To_Address (GPIOH_Base) then
GPIOH_Clock_Enable;
elsif This'Address = System'To_Address (GPIOI_Base) then
GPIOI_Clock_Enable;
else
raise Program_Error;
end if;
end Enable_Clock;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : aliased in out USART) is
begin
if This'Address = System'To_Address (USART1_Base) then
USART1_Clock_Enable;
elsif This'Address = System'To_Address (USART2_Base) then
USART2_Clock_Enable;
elsif This'Address = System'To_Address (USART3_Base) then
USART3_Clock_Enable;
elsif This'Address = System'To_Address (USART6_Base) then
USART6_Clock_Enable;
else
raise Program_Error;
end if;
end Enable_Clock;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : aliased in out DMA_Controller) is
begin
if This'Address = System'To_Address (STM32F4.DMA1_BASE) then
DMA1_Clock_Enable;
elsif This'Address = System'To_Address (STM32F4.DMA2_BASE) then
DMA2_Clock_Enable;
else
raise Program_Error;
end if;
end Enable_Clock;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : aliased in out I2C_Port) is
begin
if This'Address = System'To_Address (I2C1_Base) then
I2C1_Clock_Enable;
elsif This'Address = System'To_Address (I2C2_Base) then
I2C2_Clock_Enable;
elsif This'Address = System'To_Address (I2C3_Base) then
I2C3_Clock_Enable;
else
raise Program_Error;
end if;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : in out I2C_Port) is
begin
if This'Address = System'To_Address (I2C1_Base) then
I2C1_Force_Reset;
I2C1_Release_Reset;
elsif This'Address = System'To_Address (I2C2_Base) then
I2C2_Force_Reset;
I2C2_Release_Reset;
elsif This'Address = System'To_Address (I2C3_Base) then
I2C3_Force_Reset;
I2C3_Release_Reset;
else
raise Program_Error;
end if;
end Reset;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : aliased in out SPI_Port) is
begin
if This'Address = System'To_Address (SPI1_Base) then
SPI1_Force_Reset;
SPI1_Release_Reset;
elsif This'Address = System'To_Address (SPI2_Base) then
SPI2_Force_Reset;
SPI2_Release_Reset;
elsif This'Address = System'To_Address (SPI3_Base) then
SPI3_Force_Reset;
SPI3_Release_Reset;
else
raise Program_Error;
end if;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : in out SPI_Port) is
begin
if This'Address = System'To_Address (SPI1_Base) then
SPI1_Clock_Enable;
elsif This'Address = System'To_Address (SPI2_Base) then
SPI2_Clock_Enable;
elsif This'Address = System'To_Address (SPI3_Base) then
SPI3_Clock_Enable;
else
raise Program_Error;
end if;
end Reset;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : in out Timer) is
begin
if This'Address = System'To_Address (TIM1_Base) then
TIM1_Clock_Enable;
elsif This'Address = System'To_Address (TIM2_Base) then
TIM2_Clock_Enable;
elsif This'Address = System'To_Address (TIM3_Base) then
TIM3_Clock_Enable;
elsif This'Address = System'To_Address (TIM4_Base) then
TIM4_Clock_Enable;
elsif This'Address = System'To_Address (TIM5_Base) then
TIM5_Clock_Enable;
elsif This'Address = System'To_Address (TIM6_Base) then
TIM6_Clock_Enable;
elsif This'Address = System'To_Address (TIM7_Base) then
TIM7_Clock_Enable;
elsif This'Address = System'To_Address (TIM8_Base) then
TIM8_Clock_Enable;
elsif This'Address = System'To_Address (TIM9_Base) then
TIM9_Clock_Enable;
elsif This'Address = System'To_Address (TIM10_Base) then
TIM10_Clock_Enable;
elsif This'Address = System'To_Address (TIM11_Base) then
TIM11_Clock_Enable;
elsif This'Address = System'To_Address (TIM12_Base) then
TIM12_Clock_Enable;
elsif This'Address = System'To_Address (TIM13_Base) then
TIM13_Clock_Enable;
elsif This'Address = System'To_Address (TIM14_Base) then
TIM14_Clock_Enable;
else
raise Program_Error;
end if;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : in out Timer) is
begin
if This'Address = System'To_Address (TIM1_Base) then
TIM1_Force_Reset;
TIM1_Release_Reset;
elsif This'Address = System'To_Address (TIM2_Base) then
TIM2_Force_Reset;
TIM2_Release_Reset;
elsif This'Address = System'To_Address (TIM3_Base) then
TIM3_Force_Reset;
TIM3_Release_Reset;
elsif This'Address = System'To_Address (TIM4_Base) then
TIM4_Force_Reset;
TIM4_Release_Reset;
elsif This'Address = System'To_Address (TIM5_Base) then
TIM5_Force_Reset;
TIM5_Release_Reset;
elsif This'Address = System'To_Address (TIM6_Base) then
TIM6_Force_Reset;
TIM6_Release_Reset;
elsif This'Address = System'To_Address (TIM7_Base) then
TIM7_Force_Reset;
TIM7_Release_Reset;
elsif This'Address = System'To_Address (TIM8_Base) then
TIM8_Force_Reset;
TIM8_Release_Reset;
elsif This'Address = System'To_Address (TIM9_Base) then
TIM9_Force_Reset;
TIM9_Release_Reset;
elsif This'Address = System'To_Address (TIM10_Base) then
TIM10_Force_Reset;
TIM10_Release_Reset;
elsif This'Address = System'To_Address (TIM11_Base) then
TIM11_Force_Reset;
TIM11_Release_Reset;
elsif This'Address = System'To_Address (TIM12_Base) then
TIM12_Force_Reset;
TIM12_Release_Reset;
elsif This'Address = System'To_Address (TIM13_Base) then
TIM13_Force_Reset;
TIM13_Release_Reset;
elsif This'Address = System'To_Address (TIM14_Base) then
TIM14_Force_Reset;
TIM14_Release_Reset;
else
raise Program_Error;
end if;
end Reset;
end STM32F4_Discovery;
|
0siris/carve | Ada | 2,723 | adb | --
-- (c) Copyright 1993,1994,1995,1996 Silicon Graphics, Inc.
-- ALL RIGHTS RESERVED
-- Permission to use, copy, modify, and distribute this software for
-- any purpose and without fee is hereby granted, provided that the above
-- copyright notice appear in all copies and that both the copyright notice
-- and this permission notice appear in supporting documentation, and that
-- the name of Silicon Graphics, Inc. not be used in advertising
-- or publicity pertaining to distribution of the software without specific,
-- written prior permission.
--
-- THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
-- AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
-- INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
-- FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-- GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
-- SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
-- KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
-- LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
-- THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
-- ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
-- ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
-- POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
--
-- US Government Users Restricted Rights
-- Use, duplication, or disclosure by the Government is subject to
-- restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
-- (c)(1)(ii) of the Rights in Technical Data and Computer Software
-- clause at DFARS 252.227-7013 and/or in similar or successor
-- clauses in the FAR or the DOD or NASA FAR Supplement.
-- Unpublished-- rights reserved under the copyright laws of the
-- United States. Contractor/manufacturer is Silicon Graphics,
-- Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
--
-- OpenGL(TM) is a trademark of Silicon Graphics, Inc.
--
with GL; use GL;
with Glut; use Glut;
with Text_IO;
with Cone_Procs; use Cone_Procs;
with Interfaces.C.Strings;
procedure Cone is
package Tio renames Text_IO;
package ICS renames Interfaces.C.Strings;
type chars_ptr_ptr is access ICS.chars_ptr;
argc : aliased integer;
pragma Import (C, argc, "gnat_argc");
argv : chars_ptr_ptr;
pragma Import (C, argv, "gnat_argv");
foobar : Integer;
begin
glutInitWindowSize(500, 500);
glutInit (argc'access, argv);
glutInitDisplayMode(GLUT_RGB or GLUT_DEPTH or GLUT_SINGLE);
foobar := glutCreateWindow ("OpenGL and Ada: cone");
DoInit;
glutReshapeFunc (ReshapeCallback'ACCESS);
glutDisplayFunc (DoDisplay'ACCESS);
glutMainLoop;
end Cone;
|
AdaCore/libadalang | Ada | 56 | ads | with Gen;
package Foo is new Gen.Opt_Types (Integer);
|
zrmyers/VulkanAda | Ada | 7,699 | ads | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2021 Zane Myers
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
with Vulkan.Math.GenFMatrix;
with Vulkan.Math.Vec3;
use Vulkan.Math.GenFMatrix;
use Vulkan.Math.Vec3;
--------------------------------------------------------------------------------
--< @group Vulkan Math Basic Types
--------------------------------------------------------------------------------
--< @summary
--< This package provides a single precision floating point matrix with 3 rows
--< and 3 columns.
--------------------------------------------------------------------------------
package Vulkan.Math.Mat3x3 is
pragma Preelaborate;
pragma Pure;
--< A 3x3 matrix of single-precision floating point numbers.
subtype Vkm_Mat3x3 is Vkm_Mat(
last_row_index => 2, last_column_index => 2);
--< An alternative name for a 3x3 single-precision floating point matrix
subtype Vkm_Mat3 is Vkm_Mat3x3;
----------------------------------------------------------------------------
--< @summary
--< Constructor for Vkm_Mat3x3 type.
--<
--< @description
--< Construct a 3x3 matrix with each component set to the corresponding
--< component in the identity matrix.
--<
--< @return
--< A 3x3 matrix.
----------------------------------------------------------------------------
function Make_Mat3x3 return Vkm_Mat3x3 is
(GFM.Make_GenMatrix(cN => 2, rN => 2, diag => 1.0)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Constructor for Vkm_Mat3x3 type.
--<
--< @description
--< Construct a 3x3 matrix with each component on the diagonal set to a
--< particular value.
--<
--< @param diag
--< The value to set along the diagonal.
--<
--< @return
--< A 3x3 matrix.
----------------------------------------------------------------------------
function Make_Mat3x3 (
diag : in Vkm_Float) return Vkm_Mat3x3 is
(GFM.Make_GenMatrix(cN => 2, rN => 2, diag => diag)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Constructor for Vkm_Mat3x3 type.
--<
--< @description
--< Construct a 3x3 matrix with each component on the diagonal set to a
--< particular value from a vector.
--<
--< @param diag
--< The value to set along the diagonal.
--<
--< @return
--< A 3x3 matrix.
----------------------------------------------------------------------------
function Make_Mat3x3 (
diag : in Vkm_Vec3) return Vkm_Mat3x3 is
(GFM.Make_GenMatrix(cN => 2, rN => 2, diag => diag)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Constructor for Vkm_Mat3x3 type.
--<
--< @description
--< Construct a 3x3 matrix with each component set to a different value.
--<
--< @param value1
--< The first value to set for the matrix.
--<
--< @param value2
--< The second value to set for the matrix.
--<
--< @param value3
--< The third value to set for the matrix.
--<
--< @param value4
--< The fourth value to set for the matrix.
--<
--< @param value5
--< The fifth value to set for the matrix.
--<
--< @param value6
--< The sixth value to set for the matrix.
--<
--< @param value7
--< The seventh value to set for the matrix.
--<
--< @param value8
--< The eighth value to set for the matrix.
--<
--< @param value9
--< The ninth value to set for the matrix.
--<
--< @return
--< A 3x3 matrix.
----------------------------------------------------------------------------
function Make_Mat3x3 (
value1, value2, value3,
value4, value5, value6,
value7, value8, value9 : in Vkm_Float) return Vkm_Mat3x3 is
(GFM.Make_GenMatrix(
cN => 2, rN => 2,
c0r0_val => value1, c0r1_val => value4, c0r2_val => value7,
c1r0_val => value2, c1r1_val => value5, c1r2_val => value8,
c2r0_val => value3, c2r1_val => value6, c2r2_val => value9)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Constructor for Vkm_Mat3x3 type.
--<
--< @description
--< Construct a 3x3 matrix with each column set to the value of a 2 dimmensional
--< vector.
--<
--< @param value1
--< The first value to set for the matrix.
--<
--< @param value2
--< The second value to set for the matrix.
--<
--< @return
--< A 3x3 matrix.
----------------------------------------------------------------------------
function Make_Mat3x3 (
value1, value2, value3 : in Vkm_Vec3) return Vkm_Mat3x3 is
(GFM.Make_GenMatrix(
cN => 2, rN => 2,
c0r0_val => value1.x, c0r1_val => value2.x, c0r2_val => value3.x,
c1r0_val => value1.y, c1r1_val => value2.y, c1r2_val => value3.y,
c2r0_val => value1.z, c2r1_val => value2.z, c2r2_val => value3.z)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Constructor for Vkm_Mat3x3 type.
--<
--< @description
--< Construct a 3x3 matrix using values from an existing matrix.
--<
--< If the provided matrix has dimmensions that are not the same as this
--< matrix, the corresponding element in the 4x4 identity matrix is used for
--< out of bounds accesses.
--<
--< @param value1
--< The submatrix to extract values from.
--<
--< @return
--< A 3x3 matrix.
----------------------------------------------------------------------------
function Make_Mat3x3 (
value1 : in Vkm_Mat) return Vkm_Mat3x3 is
(GFM.Make_GenMatrix(
cN => 2, rN => 2,
c0r0_val => value1.c0r0, c0r1_val => value1.c0r1, c0r2_val => value1.c0r2,
c1r0_val => value1.c1r0, c1r1_val => value1.c1r1, c1r2_val => value1.c1r2,
c2r0_val => value1.c2r0, c2r1_val => value1.c2r1, c2r2_val => value1.c2r2)) with Inline;
end Vulkan.Math.Mat3x3;
|
stcarrez/ada-util | Ada | 1,846 | adb | -----------------------------------------------------------------------
-- cut -- Text Transformations
-- Copyright (C) 2012, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Command_Line;
with Util.Strings;
with Util.Strings.Tokenizers;
procedure Cut is
procedure Print_Token (Token : in String;
Done : out Boolean);
procedure Print_Token (Token : in String;
Done : out Boolean) is
begin
Ada.Text_IO.Put_Line (Token);
Done := False;
end Print_Token;
Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
if Count <= 1 then
Ada.Text_IO.Put_Line ("Usage: cut pattern ...");
Ada.Text_IO.Put_Line ("Example: cut : $PATH");
return;
end if;
declare
Pattern : constant String := Ada.Command_Line.Argument (1);
begin
for I in 2 .. Count loop
Util.Strings.Tokenizers.Iterate_Tokens (Content => Ada.Command_Line.Argument (I),
Pattern => Pattern,
Process => Print_Token'Access);
end loop;
end;
end Cut;
|
AdaCore/libadalang | Ada | 276 | ads | -- We want to check that Libadalang does not complain about a missing body for
-- Pkg. To check that the event handler works correctly, leave a reference to
-- a missing package too.
with Gen_Pkg;
with Missing_Pkg;
package Pkg is new Gen_Pkg (Missing_Pkg.Initial_Value);
|
tum-ei-rcs/StratoX | Ada | 1,871 | ads | package units with SPARK_Mode is
type Unit_Type is new Float with -- As tagged Type? -> Generics with Unit_Type'Class
Dimension_System =>
((Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
(Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
(Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
(Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
(Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
(Unit_Name => Radian, Unit_Symbol => "Rad", Dim_Symbol => "A")),
Default_Value => 0.0;
subtype Angle_Type is Unit_Type with
Dimension => (Symbol => "Rad", Radian => 1, others => 0);
Radian : constant Angle_Type := Angle_Type (1.0);
RADIAN_2PI : constant Angle_Type := 2.0 * Radian;
-- idea: shift range to 0 .. X, wrap with mod, shift back
--function wrap_Angle( angle : Angle_Type; min : Angle_Type; max : Angle_Type) return Angle_Type is
-- ( Angle_Type'Remainder( (angle - min - (max-min)/2.0) , (max-min) ) + (max+min)/2.0 );
-- FIXME: Spark error: unbound symbol 'Floating.remainder_'
-- ( if angle > max then max elsif angle < min then min else angle );
-- with
-- pre => max > min,
-- post => wrap_Angle'Result in min .. max;
-- if angle - min < 0.0 * Degree then Angle_Type'Remainder( (angle - min), (max-min) ) + max else
function wrap_angle2 (angle : Angle_Type; min : Angle_Type; max : Angle_Type) return Angle_Type
with Pre => min <= 0.0 * Radian and then
max >= 0.0 * Radian and then
max > min and then
max < Angle_Type'Last / 2.0 and then
min > Angle_Type'First / 2.0,
Post => wrap_angle2'Result >= min and wrap_angle2'Result <= max;
-- Must make no assumptions on input 'angle' here, otherwise caller might fail if it isn't SPARK.
end units;
|
tum-ei-rcs/StratoX | Ada | 1,576 | adb | -- Institution: Technische Universität München
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: Emanuel Regnath ([email protected])
with STM32.Device;
-- @summary
-- Target-specific mapping for HIL of Clock
package body HIL.Clock with
SPARK_Mode => Off
is
procedure configure is
begin
-- GPIOs
STM32.Device.Enable_Clock(STM32.Device.GPIO_A );
STM32.Device.Enable_Clock(STM32.Device.GPIO_B);
STM32.Device.Enable_Clock(STM32.Device.GPIO_C);
STM32.Device.Enable_Clock(STM32.Device.GPIO_D);
STM32.Device.Enable_Clock(STM32.Device.GPIO_E);
-- SPI
STM32.Device.Enable_Clock(STM32.Device.SPI_2);
-- I2C
--STM32.Device.Enable_Clock( STM32.Device.I2C_1 ); -- I2C
-- USARTs
-- STM32.Device.Enable_Clock( STM32.Device.USART_1 );
-- STM32.Device.Enable_Clock( STM32.Device.USART_2 );
-- STM32.Device.Enable_Clock( STM32.Device.USART_3 );
-- STM32.Device.Enable_Clock( STM32.Device.UART_4 );
STM32.Device.Enable_Clock( STM32.Device.USART_7 );
-- Timers
-- STM32.Device.Enable_Clock (STM32.Device.Timer_2);
-- STM32.Device.Reset (STM32.Device.Timer_2);
end configure;
-- get number of systicks since POR
function getSysTick return Natural is
begin
null;
return 0;
end getSysTick;
-- get system time since POR
function getSysTime return Ada.Real_Time.Time is
begin
return Ada.Real_Time.Clock;
end getSysTime;
end HIL.Clock;
|
godunko/adawebpack | Ada | 2,816 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . I N I T --
-- --
-- S p e c --
-- --
-- Copyright (C) 2020, 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by AdaCore. --
-- --
------------------------------------------------------------------------------
-- This package provides implementation of some builtins functions missing
-- in GNATLLVM compiler, but used by runtime.
with Interfaces;
package System.Builtins is
function Builtin_Inf return Interfaces.IEEE_Float_64
with Export, Convention => C, External_Name => "__builtin_inf";
function Builtin_Inff return Interfaces.IEEE_Float_32
with Export, Convention => C, External_Name => "__builtin_inff";
end System.Builtins;
|
sebsgit/textproc | Ada | 357 | ads | with AUnit; use AUnit;
with AUnit.Test_Cases; use AUnit.Test_Cases;
package DataBatchTests is
type TestCase is new AUnit.Test_Cases.Test_Case with null record;
procedure Register_Tests(T: in out TestCase);
function Name(T: TestCase) return Message_String;
procedure testBasicBatch(T : in out Test_Cases.Test_Case'Class);
end DataBatchTests;
|
reznikmm/matreshka | Ada | 9,607 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Holders;
with SQL.Queries;
with OPM.Stores;
with AWFC.Accounts.Users.Stores;
with Forum.Categories.Objects.Stores;
with Forum.Categories.Category_Identifier_Holders;
with Forum.Topics.Objects.Stores;
with Forum.Posts.Objects.Stores;
package body Forum.Forums is
function Get_Category_Store is new OPM.Engines.Generic_Get_Store
(Object => Standard.Forum.Categories.Objects.Category_Object,
Store => Standard.Forum.Categories.Objects.Stores.Category_Store);
function Get_Topic_Store is new OPM.Engines.Generic_Get_Store
(Object => Standard.Forum.Topics.Objects.Topic_Object,
Store => Standard.Forum.Topics.Objects.Stores.Topic_Store);
function Get_Post_Store is new OPM.Engines.Generic_Get_Store
(Object => Standard.Forum.Posts.Objects.Post_Object,
Store => Standard.Forum.Posts.Objects.Stores.Post_Store);
---------------------
-- Create_Category --
---------------------
function Create_Category
(Self : in out Forum'Class;
Title : League.Strings.Universal_String;
Description : League.Strings.Universal_String)
return Standard.Forum.Categories.References.Category is
begin
return Get_Category_Store (Self.Engine).Create (Title, Description);
end Create_Category;
-----------------
-- Create_Post --
-----------------
function Create_Post
(Self : in out Forum'Class;
User : AWFC.Accounts.Users.User_Access;
Topic : Standard.Forum.Topics.References.Topic;
Text : League.Strings.Universal_String;
Creation_Time : League.Calendars.Date_Time := League.Calendars.Clock)
return Standard.Forum.Posts.References.Post is
begin
return Get_Post_Store (Self.Engine).Create
(User, Topic, Text, Creation_Time);
end Create_Post;
------------------
-- Create_Topic --
------------------
function Create_Topic
(Self : in out Forum'Class;
User : AWFC.Accounts.Users.User_Access;
Category : Standard.Forum.Categories.References.Category;
Title : League.Strings.Universal_String;
Description : League.Strings.Universal_String;
Creation_Time : League.Calendars.Date_Time := League.Calendars.Clock)
return Standard.Forum.Topics.References.Topic is
begin
return Get_Topic_Store (Self.Engine).Create
(User, Category, Title, Description, Creation_Time);
end Create_Topic;
--------------------
-- Get_Categories --
--------------------
function Get_Categories
(Self : in out Forum'Class)
return Standard.Forum.Categories.References.Category_Vector
is
Q : SQL.Queries.SQL_Query
:= Self.Engine.Get_Database.Query
(League.Strings.To_Universal_String
("SELECT category_identifier FROM categories"));
X : Standard.Forum.Categories.References.Category;
R : Standard.Forum.Categories.References.Category_Vector;
begin
Q.Execute;
while Q.Next loop
X.Initialize
(Get_Category_Store (Self.Engine),
Categories.Category_Identifier_Holders.Element (Q.Value (1)));
R.Append (X);
end loop;
return R;
end Get_Categories;
------------------
-- Get_Category --
------------------
procedure Get_Category
(Self : in out Forum'Class;
Identifier : Standard.Forum.Categories.Category_Identifier;
Value : out Standard.Forum.Categories.References.Category;
Found : out Boolean)
is
H : constant League.Holders.Holder :=
Standard.Forum.Categories.Category_Identifier_Holders.To_Holder
(Identifier);
Q : SQL.Queries.SQL_Query
:= Self.Engine.Get_Database.Query
(League.Strings.To_Universal_String
("SELECT 1 FROM categories WHERE"
& " category_identifier=:category_identifier"));
begin
Q.Bind_Value
(League.Strings.To_Universal_String (":category_identifier"), H);
Q.Execute;
if Q.Next then
Value.Initialize (Get_Category_Store (Self.Engine), Identifier);
Found := True;
else
Found := False;
end if;
end Get_Category;
---------------
-- Get_Topic --
---------------
procedure Get_Topic
(Self : in out Forum'Class;
Category : Standard.Forum.Categories.Category_Identifier;
Identifier : Standard.Forum.Topics.Topic_Identifier;
Value : out Standard.Forum.Topics.References.Topic;
Found : out Boolean)
is
C : constant League.Holders.Holder :=
Standard.Forum.Categories.Category_Identifier_Holders.To_Holder
(Category);
T : constant League.Holders.Holder :=
Standard.Forum.Topics.Topic_Identifier_Holders.To_Holder
(Identifier);
Q : SQL.Queries.SQL_Query
:= Self.Engine.Get_Database.Query
(League.Strings.To_Universal_String
("SELECT 1 FROM topics WHERE"
& " category_identifier=:category_identifier"
& " and topic_identifier=:topic_identifier"));
begin
Q.Bind_Value
(League.Strings.To_Universal_String (":category_identifier"), C);
Q.Bind_Value
(League.Strings.To_Universal_String (":topic_identifier"), T);
Q.Execute;
if Q.Next then
Value.Initialize (Get_Topic_Store (Self.Engine), Identifier);
Found := True;
else
Found := False;
end if;
end Get_Topic;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Forum'Class;
Driver : League.Strings.Universal_String;
Options : SQL.Options.SQL_Options)
is
Aux : OPM.Stores.Store_Access;
begin
Self.Engine.Initialize (Driver, Options);
Aux := new Standard.Forum.Categories.Objects.Stores.Category_Store (Self.Engine'Unchecked_Access);
Aux.Initialize;
Aux := new Standard.Forum.Topics.Objects.Stores.Topic_Store (Self.Engine'Unchecked_Access);
Aux.Initialize;
Aux := new Standard.Forum.Posts.Objects.Stores.Post_Store (Self.Engine'Unchecked_Access);
Aux.Initialize;
end Initialize;
end Forum.Forums;
|
AdaCore/libadalang | Ada | 44 | ads | generic
package Pkg5 with Pure is
end Pkg5;
|
stcarrez/ada-asf | Ada | 5,320 | adb | -----------------------------------------------------------------------
-- components-core -- ASF Core Components
-- Copyright (C) 2009, 2010, 2011, 2012, 2018, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body ASF.Components.Core is
use EL.Objects;
-- ------------------------------
-- Return a client-side identifier for this component, generating
-- one if necessary.
-- ------------------------------
overriding
function Get_Client_Id (UI : UIComponentBase) return Unbounded_String is
Id : constant access ASF.Views.Nodes.Tag_Attribute := UI.Get_Attribute ("id");
begin
if Id /= null then
return To_Unbounded_String (Views.Nodes.Get_Value (Id.all, UI.Get_Context.all));
end if;
-- return UI.Id;
return Base.UIComponent (UI).Get_Client_Id;
end Get_Client_Id;
-- ------------------------------
-- Renders the UIText evaluating the EL expressions it may contain.
-- ------------------------------
overriding
procedure Encode_Begin (UI : in UIText;
Context : in out Faces_Context'Class) is
begin
UI.Text.Encode_All (UI.Expr_Table, Context);
end Encode_Begin;
-- ------------------------------
-- Set the expression array that contains reduced expressions.
-- ------------------------------
procedure Set_Expression_Table (UI : in out UIText;
Expr_Table : in Views.Nodes.Expression_Access_Array_Access) is
use type ASF.Views.Nodes.Expression_Access_Array_Access;
begin
if UI.Expr_Table /= null then
UI.Log_Error ("Expression table already initialized");
raise Program_Error with "Expression table already initialized";
end if;
UI.Expr_Table := Expr_Table;
end Set_Expression_Table;
-- ------------------------------
-- Finalize the object.
-- ------------------------------
overriding
procedure Finalize (UI : in out UIText) is
use type ASF.Views.Nodes.Expression_Access_Array_Access;
procedure Free is
new Ada.Unchecked_Deallocation (EL.Expressions.Expression'Class,
EL.Expressions.Expression_Access);
procedure Free is
new Ada.Unchecked_Deallocation (ASF.Views.Nodes.Expression_Access_Array,
ASF.Views.Nodes.Expression_Access_Array_Access);
begin
if UI.Expr_Table /= null then
for I in UI.Expr_Table'Range loop
Free (UI.Expr_Table (I));
end loop;
Free (UI.Expr_Table);
end if;
Base.UIComponent (UI).Finalize;
end Finalize;
function Create_UIText (Tag : ASF.Views.Nodes.Text_Tag_Node_Access)
return UIText_Access is
Result : constant UIText_Access := new UIText;
begin
Result.Text := Tag;
return Result;
end Create_UIText;
-- ------------------------------
-- Get the parameter name
-- ------------------------------
function Get_Name (UI : UIParameter;
Context : Faces_Context'Class) return String is
Name : constant EL.Objects.Object := UI.Get_Attribute (Name => "name",
Context => Context);
begin
return EL.Objects.To_String (Name);
end Get_Name;
-- ------------------------------
-- Get the parameter value
-- ------------------------------
function Get_Value (UI : UIParameter;
Context : Faces_Context'Class) return EL.Objects.Object is
begin
return UI.Get_Attribute (Name => "value", Context => Context);
end Get_Value;
-- ------------------------------
-- Get the list of parameters associated with a component.
-- ------------------------------
function Get_Parameters (UI : Base.UIComponent'Class) return UIParameter_Access_Array is
Result : UIParameter_Access_Array (1 .. UI.Get_Children_Count);
Last : Natural := 0;
procedure Collect (Child : in Base.UIComponent_Access);
pragma Inline (Collect);
procedure Collect (Child : in Base.UIComponent_Access) is
begin
if Child.all in UIParameter'Class then
Last := Last + 1;
Result (Last) := UIParameter (Child.all)'Access;
end if;
end Collect;
procedure Iter is new ASF.Components.Base.Iterate (Process => Collect);
pragma Inline (Iter);
begin
Iter (UI);
return Result (1 .. Last);
end Get_Parameters;
end ASF.Components.Core;
|
stcarrez/ada-enet | Ada | 6,297 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with STM32.GPIO;
with STM32.Device;
with STM32_SVD.RCC;
with STM32_SVD.SYSCFG;
with STM32_SVD.Ethernet; use STM32_SVD.Ethernet;
with Ada.Real_Time;
-- SCz 2016-09-27: this is a stripped down version of stm32-eth.adb where the TX/RX
-- ring initialization is removed as well as the interrupt handler with the Wait_Packet
-- operation. The interrupt handler conflicts with the Net.Interfaces.STM32 driver.
-- I've just re-used the MII initialization as well as the Ethernet descriptor types.
package body STM32.Eth is
---------------------
-- Initialize_RMII --
---------------------
procedure Initialize_RMII
is
use STM32.GPIO;
use STM32.Device;
use STM32_SVD.RCC;
Configuration : GPIO_Port_Configuration;
begin
-- Enable GPIO clocks
Enable_Clock (GPIO_A);
Enable_Clock (GPIO_C);
Enable_Clock (GPIO_G);
-- Enable SYSCFG clock
RCC_Periph.APB2ENR.SYSCFGEN := True;
-- Select RMII (before enabling the clocks)
STM32_SVD.SYSCFG.SYSCFG_Periph.PMC.MII_RMII_SEL := True;
Configure_Alternate_Function (PA1, GPIO_AF_ETH_11); -- RMII_REF_CLK
Configure_Alternate_Function (PA2, GPIO_AF_ETH_11); -- RMII_MDIO
Configure_Alternate_Function (PA7, GPIO_AF_ETH_11); -- RMII_CRS_DV
Configure_Alternate_Function (PC1, GPIO_AF_ETH_11); -- RMII_MDC
Configure_Alternate_Function (PC4, GPIO_AF_ETH_11); -- RMII_RXD0
Configure_Alternate_Function (PC5, GPIO_AF_ETH_11); -- RMII_RXD1
Configure_Alternate_Function (PG2, GPIO_AF_ETH_11); -- RMII_RXER
Configure_Alternate_Function (PG11, GPIO_AF_ETH_11); -- RMII_TX_EN
Configure_Alternate_Function (PG13, GPIO_AF_ETH_11); -- RMII_TXD0
Configure_Alternate_Function (PG14, GPIO_AF_ETH_11); -- RMII_TXD1
Configuration := (Mode => Mode_AF,
AF => GPIO_AF_ETH_11,
AF_Speed => Speed_100MHz,
AF_Output_Type => Push_Pull,
Resistors => Floating);
Configure_IO (PA1, Configuration);
Configure_IO (PA2, Configuration);
Configure_IO (PA7, Configuration);
Configure_IO (PC1, Configuration);
Configure_IO (PC4, Configuration);
Configure_IO (PC5, Configuration);
Configure_IO (PG2, Configuration);
Configure_IO (PG11, Configuration);
Configure_IO (PG13, Configuration);
Configure_IO (PG14, Configuration);
-- Enable clocks
RCC_Periph.AHB1ENR.ETHMACEN := True;
RCC_Periph.AHB1ENR.ETHMACTXEN := True;
RCC_Periph.AHB1ENR.ETHMACRXEN := True;
RCC_Periph.AHB1ENR.ETHMACPTPEN := True;
-- Reset
RCC_Periph.AHB1RSTR.ETHMACRST := True;
RCC_Periph.AHB1RSTR.ETHMACRST := False;
-- Software reset
Ethernet_DMA_Periph.DMABMR.SR := True;
while Ethernet_DMA_Periph.DMABMR.SR loop
null;
end loop;
end Initialize_RMII;
--------------
-- Read_MMI --
--------------
procedure Read_MMI (Reg : UInt5; Val : out Unsigned_16)
is
use Ada.Real_Time;
Pa : constant UInt5 := 0;
Cr : UInt3;
begin
case STM32.Device.System_Clock_Frequencies.HCLK is
when 20e6 .. 35e6 - 1 => Cr := 2#010#;
when 35e6 .. 60e6 - 1 => Cr := 2#011#;
when 60e6 .. 100e6 - 1 => Cr := 2#000#;
when 100e6 .. 150e6 - 1 => Cr := 2#001#;
when 150e6 .. 216e6 => Cr := 2#100#;
when others => raise Constraint_Error;
end case;
Ethernet_MAC_Periph.MACMIIAR :=
(PA => Pa,
MR => Reg,
CR => Cr,
MW => False,
MB => True,
others => <>);
loop
exit when not Ethernet_MAC_Periph.MACMIIAR.MB;
delay until Clock + Milliseconds (1);
end loop;
Val := Unsigned_16 (Ethernet_MAC_Periph.MACMIIDR.TD);
end Read_MMI;
end STM32.Eth;
|
reznikmm/matreshka | Ada | 4,025 | 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_Organizations_Attributes;
package Matreshka.ODF_Text.Organizations_Attributes is
type Text_Organizations_Attribute_Node is
new Matreshka.ODF_Text.Abstract_Text_Attribute_Node
and ODF.DOM.Text_Organizations_Attributes.ODF_Text_Organizations_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Organizations_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Organizations_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Text.Organizations_Attributes;
|
onox/dcf-ada | Ada | 15,375 | adb | -- SPDX-License-Identifier: MIT
--
-- Copyright (c) 2000 - 2018 Gautier de Montmollin
-- SWITZERLAND
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
package body DCF.Zip.Headers is
use Ada.Streams;
-----------------------------------------------------------
-- Byte array <-> various integers, with Intel endianess --
-----------------------------------------------------------
-- Get numbers with correct trucmuche endian, to ensure
-- correct header loading on some non-Intel machines
generic
type Number is mod <>; -- range <> in Ada83 version (fake Interfaces)
function Intel_X86_Number (B : Stream_Element_Array) return Number;
function Intel_X86_Number (B : Stream_Element_Array) return Number is
N : Number := 0;
begin
for I in reverse B'Range loop
N := N * 256 + Number (B (I));
end loop;
return N;
end Intel_X86_Number;
function Intel_Nb is new Intel_X86_Number (Unsigned_16);
function Intel_Nb is new Intel_X86_Number (Unsigned_32);
-- Put numbers with correct endianess as bytes
generic
type Number is mod <>; -- range <> in Ada83 version (fake Interfaces)
Size : Stream_Element_Count;
function Intel_X86_Buffer (N : Number) return Stream_Element_Array;
function Intel_X86_Buffer (N : Number) return Stream_Element_Array is
B : Stream_Element_Array (1 .. Size);
M : Number := N;
begin
for I in B'Range loop
B (I) := Stream_Element (M and 255);
M := M / 256;
end loop;
return B;
end Intel_X86_Buffer;
function Intel_Bf is new Intel_X86_Buffer (Unsigned_16, 2);
function Intel_Bf is new Intel_X86_Buffer (Unsigned_32, 4);
---------------------
-- PK signatures --
---------------------
function Pk_Signature (Buf : Stream_Element_Array; Code : Stream_Element) return Boolean is
begin
return Buf (Buf'First .. Buf'First + 3) = (16#50#, 16#4B#, Code, Code + 1);
-- PK12, PK34, ...
end Pk_Signature;
procedure Pk_Signature (Buf : in out Stream_Element_Array; Code : Stream_Element) is
begin
Buf (1 .. 4) := (16#50#, 16#4B#, Code, Code + 1); -- PK12, PK34, ...
end Pk_Signature;
---------------------------------------------------------
-- PKZIP file header, as in central directory - PK12 --
---------------------------------------------------------
procedure Read_And_Check
(Stream : in out Root_Zipstream_Type'Class;
Header : out Central_File_Header)
is
Chb : Stream_Element_Array (1 .. 46);
begin
Blockread (Stream, Chb);
if not Pk_Signature (Chb, 1) then
raise Bad_Central_Header;
end if;
Header.Made_By_Version := Intel_Nb (Chb (5 .. 6));
Header.Short_Info.Needed_Extract_Version := Intel_Nb (Chb (7 .. 8));
Header.Short_Info.Bit_Flag := Intel_Nb (Chb (9 .. 10));
Header.Short_Info.Zip_Type := Intel_Nb (Chb (11 .. 12));
Header.Short_Info.File_Timedate :=
DCF.Streams.Convert (Unsigned_32'(Intel_Nb (Chb (13 .. 16))));
Header.Short_Info.Dd.Crc_32 := Intel_Nb (Chb (17 .. 20));
Header.Short_Info.Dd.Compressed_Size := Intel_Nb (Chb (21 .. 24));
Header.Short_Info.Dd.Uncompressed_Size := Intel_Nb (Chb (25 .. 28));
Header.Short_Info.Filename_Length := Intel_Nb (Chb (29 .. 30));
Header.Short_Info.Extra_Field_Length := Intel_Nb (Chb (31 .. 32));
Header.Comment_Length := Intel_Nb (Chb (33 .. 34));
Header.Disk_Number_Start := Intel_Nb (Chb (35 .. 36));
Header.Internal_Attributes := Intel_Nb (Chb (37 .. 38));
Header.External_Attributes := Intel_Nb (Chb (39 .. 42));
Header.Local_Header_Offset := Intel_Nb (Chb (43 .. 46));
if not Valid_Version (Header.Short_Info) then
raise Bad_Central_Header with "Archive needs invalid version to extract";
end if;
if Header.Disk_Number_Start /= 0 then
raise Bad_Central_Header with "Archive may not span multiple volumes";
end if;
if not Valid_Bitflag (Header.Short_Info) then
raise Bad_Central_Header with "Archive uses prohibited features";
end if;
end Read_And_Check;
procedure Write (Stream : in out Root_Zipstream_Type'Class; Header : in Central_File_Header) is
Chb : Stream_Element_Array (1 .. 46);
begin
Pk_Signature (Chb, 1);
Chb (5 .. 6) := Intel_Bf (Header.Made_By_Version);
Chb (7 .. 8) := Intel_Bf (Header.Short_Info.Needed_Extract_Version);
Chb (9 .. 10) := Intel_Bf (Header.Short_Info.Bit_Flag);
Chb (11 .. 12) := Intel_Bf (Header.Short_Info.Zip_Type);
Chb (13 .. 16) := Intel_Bf (DCF.Streams.Convert (Header.Short_Info.File_Timedate));
Chb (17 .. 20) := Intel_Bf (Header.Short_Info.Dd.Crc_32);
Chb (21 .. 24) := Intel_Bf (Header.Short_Info.Dd.Compressed_Size);
Chb (25 .. 28) := Intel_Bf (Header.Short_Info.Dd.Uncompressed_Size);
Chb (29 .. 30) := Intel_Bf (Header.Short_Info.Filename_Length);
Chb (31 .. 32) := Intel_Bf (Header.Short_Info.Extra_Field_Length);
Chb (33 .. 34) := Intel_Bf (Header.Comment_Length);
Chb (35 .. 36) := Intel_Bf (Header.Disk_Number_Start);
Chb (37 .. 38) := Intel_Bf (Header.Internal_Attributes);
Chb (39 .. 42) := Intel_Bf (Header.External_Attributes);
Chb (43 .. 46) := Intel_Bf (Header.Local_Header_Offset);
Stream.Write (Chb);
end Write;
-------------------------------------------------------------------------
-- PKZIP local file header, in front of every file in archive - PK34 --
-------------------------------------------------------------------------
procedure Read_And_Check
(Stream : in out Root_Zipstream_Type'Class;
Header : out Local_File_Header)
is
Lhb : Stream_Element_Array (1 .. 30);
begin
Blockread (Stream, Lhb);
if not Pk_Signature (Lhb, 3) then
raise Bad_Local_Header;
end if;
Header.Needed_Extract_Version := Intel_Nb (Lhb (5 .. 6));
Header.Bit_Flag := Intel_Nb (Lhb (7 .. 8));
Header.Zip_Type := Intel_Nb (Lhb (9 .. 10));
Header.File_Timedate :=
DCF.Streams.Convert (Unsigned_32'(Intel_Nb (Lhb (11 .. 14))));
Header.Dd.Crc_32 := Intel_Nb (Lhb (15 .. 18));
Header.Dd.Compressed_Size := Intel_Nb (Lhb (19 .. 22));
Header.Dd.Uncompressed_Size := Intel_Nb (Lhb (23 .. 26));
Header.Filename_Length := Intel_Nb (Lhb (27 .. 28));
Header.Extra_Field_Length := Intel_Nb (Lhb (29 .. 30));
if not Valid_Version (Header) then
raise Bad_Local_Header with "Archived file needs invalid version to extract";
end if;
if not Valid_Bitflag (Header) then
raise Bad_Local_Header with "Archived file uses prohibited features";
end if;
end Read_And_Check;
procedure Write (Stream : in out Root_Zipstream_Type'Class; Header : in Local_File_Header) is
Lhb : Stream_Element_Array (1 .. 30);
begin
Pk_Signature (Lhb, 3);
Lhb (5 .. 6) := Intel_Bf (Header.Needed_Extract_Version);
Lhb (7 .. 8) := Intel_Bf (Header.Bit_Flag);
Lhb (9 .. 10) := Intel_Bf (Header.Zip_Type);
Lhb (11 .. 14) := Intel_Bf (DCF.Streams.Convert (Header.File_Timedate));
Lhb (15 .. 18) := Intel_Bf (Header.Dd.Crc_32);
Lhb (19 .. 22) := Intel_Bf (Header.Dd.Compressed_Size);
Lhb (23 .. 26) := Intel_Bf (Header.Dd.Uncompressed_Size);
Lhb (27 .. 28) := Intel_Bf (Header.Filename_Length);
Lhb (29 .. 30) := Intel_Bf (Header.Extra_Field_Length);
Stream.Write (Lhb);
end Write;
---------------------------------------------
-- PKZIP end-of-central-directory - PK56 --
---------------------------------------------
procedure Copy_And_Check (Buffer : in Stream_Element_Array; The_End : out End_Of_Central_Dir) is
O : constant Stream_Element_Offset := Buffer'First - 1;
begin
if not Pk_Signature (Buffer, 5) then
raise Bad_End;
end if;
The_End.Disknum := Intel_Nb (Buffer (O + 5 .. O + 6));
The_End.Disknum_With_Start := Intel_Nb (Buffer (O + 7 .. O + 8));
The_End.Disk_Total_Entries := Intel_Nb (Buffer (O + 9 .. O + 10));
The_End.Total_Entries := Intel_Nb (Buffer (O + 11 .. O + 12));
The_End.Central_Dir_Size := Intel_Nb (Buffer (O + 13 .. O + 16));
The_End.Central_Dir_Offset := Intel_Nb (Buffer (O + 17 .. O + 20));
The_End.Main_Comment_Length := Intel_Nb (Buffer (O + 21 .. O + 22));
end Copy_And_Check;
procedure Read_And_Check
(Stream : in out Root_Zipstream_Type'Class;
The_End : out End_Of_Central_Dir)
is
Buffer : Stream_Element_Array (1 .. 22);
begin
Blockread (Stream, Buffer);
Copy_And_Check (Buffer, The_End);
end Read_And_Check;
procedure Load (Stream : in out Root_Zipstream_Type'Class; The_End : out End_Of_Central_Dir) is
Min_End_Start : Zs_Index_Type; -- min_end_start >= 1
Max_Comment : constant := 65_535;
-- In appnote.txt :
-- .ZIP file comment length 2 bytes
begin
if Size (Stream) < 22 then
raise Bad_End;
end if;
-- 20-Jun-2001: abandon search below min_end_start.
if Size (Stream) <= Max_Comment then
Min_End_Start := 1;
else
Min_End_Start := Size (Stream) - Max_Comment;
end if;
Set_Index (Stream, Min_End_Start);
declare
-- We copy a large chunk of the zip stream's tail into a buffer.
Large_Buffer : Stream_Element_Array
(0 .. Stream_Element_Count (Size (Stream) - Min_End_Start));
Ilb : Stream_Element_Offset;
X : Zs_Size_Type;
begin
Blockread (Stream, Large_Buffer);
for I in reverse Min_End_Start .. Size (Stream) - 21 loop
-- Yes, we must _search_ for the header...
-- because PKWARE put a variable-size comment _after_ it 8-(
Ilb := Stream_Element_Offset (I - Min_End_Start);
if Pk_Signature (Large_Buffer (Ilb .. Ilb + 3), 5) then
Copy_And_Check (Large_Buffer (Ilb .. Ilb + 21), The_End);
-- At this point, the buffer was successfully read, the_end is
-- is set with its standard contents.
--
-- This is the *real* position of the end-of-central-directory block to begin with:
X := I;
-- We subtract the *theoretical* (stored) position of the end-of-central-directory.
-- The theoretical position is equal to central_dir_offset + central_dir_size.
-- The theoretical position should be smaller or equal than the real position -
-- unless the archive is corrupted.
-- We do it step by step, because ZS_Size_Type was modular until rev. 644.
-- Now it's a signed 64 bits, but we don't want to change anything again...
X := X - 1;
-- i >= 1, so no dragons here. The "- 1" is for adapting
-- from the 1-based Ada index.
-- Fuzzy value, will trigger bad_end
exit when Zs_Size_Type (The_End.Central_Dir_Offset) > X;
-- Fuzzy value, will trigger bad_end
X := X - Zs_Size_Type (The_End.Central_Dir_Offset);
exit when Zs_Size_Type (The_End.Central_Dir_Size) > X;
X := X - Zs_Size_Type (The_End.Central_Dir_Size);
-- Now, x is the difference : real - theoretical.
-- x > 0 if the archive was appended to another file (typically an executable
-- for self-extraction purposes).
-- x = 0 if this is a "pure" Zip archive.
The_End.Offset_Shifting := X;
Set_Index (Stream, I + 22);
return; -- The_End found and filled -> exit
end if;
end loop;
raise Bad_End; -- Definitely no "end-of-central-directory" in this stream
end;
end Load;
procedure Write (Stream : in out Root_Zipstream_Type'Class; The_End : in End_Of_Central_Dir) is
Eb : Stream_Element_Array (1 .. 22);
begin
Pk_Signature (Eb, 5);
Eb (5 .. 6) := Intel_Bf (The_End.Disknum);
Eb (7 .. 8) := Intel_Bf (The_End.Disknum_With_Start);
Eb (9 .. 10) := Intel_Bf (The_End.Disk_Total_Entries);
Eb (11 .. 12) := Intel_Bf (The_End.Total_Entries);
Eb (13 .. 16) := Intel_Bf (The_End.Central_Dir_Size);
Eb (17 .. 20) := Intel_Bf (The_End.Central_Dir_Offset);
Eb (21 .. 22) := Intel_Bf (The_End.Main_Comment_Length);
Stream.Write (Eb);
end Write;
--------------------------------------------------------------------
-- PKZIP data descriptor, after streamed compressed data - PK78 --
--------------------------------------------------------------------
procedure Copy_And_Check
(Buffer : in Stream_Element_Array;
Descriptor : out Data_Descriptor) is
begin
if not Pk_Signature (Buffer, 7) then
raise Bad_Data_Descriptor;
end if;
Descriptor.Crc_32 := Intel_Nb (Buffer (5 .. 8));
Descriptor.Compressed_Size := Intel_Nb (Buffer (9 .. 12));
Descriptor.Uncompressed_Size := Intel_Nb (Buffer (13 .. 16));
end Copy_And_Check;
procedure Read_And_Check
(Stream : in out Root_Zipstream_Type'Class;
Descriptor : out Data_Descriptor)
is
Buffer : Stream_Element_Array (1 .. 16);
begin
Blockread (Stream, Buffer);
Copy_And_Check (Buffer, Descriptor);
end Read_And_Check;
procedure Write
(Stream : in out Root_Zipstream_Type'Class;
Descriptor : in Data_Descriptor)
is
Buffer : Stream_Element_Array (1 .. 16);
begin
Pk_Signature (Buffer, 7);
Buffer (5 .. 8) := Intel_Bf (Descriptor.Crc_32);
Buffer (9 .. 12) := Intel_Bf (Descriptor.Compressed_Size);
Buffer (13 .. 16) := Intel_Bf (Descriptor.Uncompressed_Size);
Stream.Write (Buffer);
end Write;
end DCF.Zip.Headers;
|
sungyeon/drake | Ada | 777 | ads | pragma License (Unrestricted);
package Ada.Decimal is
pragma Pure;
Max_Scale : constant := +18; -- implementation-defined
Min_Scale : constant := -18; -- implementation-defined
Min_Delta : constant := 10.0 ** (-Max_Scale);
Max_Delta : constant := 10.0 ** (-Min_Scale);
Max_Decimal_Digits : constant := 18; -- implementation-defined
generic
type Dividend_Type is delta <> digits <>;
type Divisor_Type is delta <> digits <>;
type Quotient_Type is delta <> digits <>;
type Remainder_Type is delta <> digits <>;
procedure Divide (
Dividend : Dividend_Type;
Divisor : Divisor_Type;
Quotient : out Quotient_Type;
Remainder : out Remainder_Type)
with Import, Convention => Intrinsic;
end Ada.Decimal;
|
zhmu/ananas | Ada | 71 | ads | package Discr28_Pkg is
function N return Natural;
end Discr28_Pkg;
|
Fabien-Chouteau/GESTE-examples | Ada | 5,155 | adb | with SDL;
with SDL.Video.Windows;
with SDL.Video.Windows.Makers;
with SDL.Video.Surfaces;
with SDL.Video.Pixel_Formats;
with SDL.Video.Palettes; use SDL.Video.Palettes;
with SDL.Video.Pixel_Formats; use SDL.Video.Pixel_Formats;
with SDL.Video.Textures; use SDL.Video.Textures;
with SDL.Video.Textures.Makers;
with SDL.Video.Renderers;
with SDL.Video.Renderers.Makers;
use SDL.Video;
with Interfaces.C; use Interfaces.C;
with SDL.Video.Pixels;
with Ada.Unchecked_Conversion;
with System;
package body SDL_Display is
W : SDL.Video.Windows.Window;
Renderer : SDL.Video.Renderers.Renderer;
Texture : SDL.Video.Textures.Texture;
SDL_Pixels : System.Address;
Screen_Offset : GESTE.Pix_Point := (0, 0);
XS, XE, YS, YE : Natural := 0;
X, Y : Natural := 0;
type Texture_2D_Array is array (Natural range <>,
Natural range <>)
of aliased SDL_Pixel;
type Texture_1D_Array is array (Natural range <>)
of aliased SDL_Pixel;
package Texture_2D is new SDL.Video.Pixels.Texture_Data
(Index => Natural,
Element => SDL_Pixel,
Element_Array_1D => Texture_1D_Array,
Element_Array_2D => Texture_2D_Array,
Default_Terminator => 0);
procedure Lock is new SDL.Video.Textures.Lock
(Pixel_Pointer_Type => System.Address);
----------------
-- Initialize --
----------------
procedure Initialize is
begin
if not SDL.Initialise (Flags => SDL.Enable_Screen) then
raise Program_Error with "SDL Video init failed";
end if;
SDL.Video.Windows.Makers.Create
(W, "GESTE Example",
0,
0,
800 * Pixel_Scale,
600 * Pixel_Scale,
Flags => SDL.Video.Windows.Resizable);
SDL.Video.Renderers.Makers.Create (Renderer, W);
SDL.Video.Textures.Makers.Create
(Tex => Texture,
Renderer => Renderer,
Format => SDL.Video.Pixel_Formats.Pixel_Format_RGB_565,
Kind => SDL.Video.Textures.Streaming,
Size => (800 * Pixel_Scale,
600 * Pixel_Scale));
end Initialize;
----------------------
-- Set_Drawing_Area --
----------------------
procedure Set_Drawing_Area (Area : GESTE.Pix_Rect) is
begin
XS := Area.TL.X - Screen_Offset.X;
YS := Area.TL.Y - Screen_Offset.Y;
XE := Area.BR.X - Screen_Offset.X;
YE := Area.BR.Y - Screen_Offset.Y;
X := XS;
Y := YS;
if XS < 0 then
raise Program_Error;
end if;
if YS < 0 then
raise Program_Error;
end if;
if XE >= Width then
raise Program_Error;
end if;
if YE >= Height then
raise Program_Error;
end if;
end Set_Drawing_Area;
-----------------------
-- Set_Screen_Offset --
-----------------------
procedure Set_Screen_Offset (Pt : GESTE.Pix_Point) is
begin
Screen_Offset := Pt;
end Set_Screen_Offset;
------------
-- Update --
------------
procedure Update is
Width : constant Natural := Texture.Get_Size.Width;
Height : constant Natural := Texture.Get_Size.Height;
begin
Renderer.Clear;
Renderer.Copy (Texture, To => (0,
0,
int (Width * Pixel_Scale),
int (Height * Pixel_Scale)));
Renderer.Present;
end Update;
------------------
-- To_SDL_Color --
------------------
function To_SDL_Color (R, G, B : Unsigned_8) return SDL_Pixel is
RB : constant Unsigned_16 :=
Shift_Right (Unsigned_16 (R), 3) and 16#1F#;
GB : constant Unsigned_16 :=
Shift_Right (Unsigned_16 (G), 2) and 16#3F#;
BB : constant Unsigned_16 :=
Shift_Right (Unsigned_16 (B), 3) and 16#1F#;
begin
return (Shift_Left (RB, 11) or Shift_Left (GB, 5) or BB);
end To_SDL_Color;
-----------------
-- Push_Pixels --
-----------------
procedure Push_Pixels (Pixels : GESTE.Output_Buffer) is
function To_Address is
new Ada.Unchecked_Conversion
(Source => SDL.Video.Pixels.ARGB_8888_Access.Pointer,
Target => System.Address);
Width : constant Natural := Texture.Get_Size.Width;
Height : constant Natural := Texture.Get_Size.Height;
begin
Lock (Texture, SDL_Pixels);
declare
Actual_Pixels : Texture_1D_Array (0 .. Natural (Width * Height - 1))
with
Address => SDL_Pixels;
begin
for Pix of Pixels loop
Actual_Pixels (X + Y * Width) := Pix;
if X = XE then
X := XS;
if Y = YE then
Y := YS;
else
Y := Y + 1;
end if;
else
X := X + 1;
end if;
end loop;
end;
Texture.Unlock;
end Push_Pixels;
----------
-- Kill --
----------
procedure Kill is
begin
W.Finalize;
SDL.Finalise;
end Kill;
begin
Initialize;
end SDL_Display;
|
annexi-strayline/AURA | Ada | 17,065 | adb | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Command Line Interface --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020-2021, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Strings.Fixed;
with Platform_Info;
separate (Scheduling)
procedure Initialize_Parameters is
use UBS;
use all type Build.Build_Mode;
use all type Build.Link_Mode;
use all type Build.Compile_Optimization_Mode;
Arg_Count: constant Natural := Ada.Command_Line.Argument_Count;
Options_Start: Positive;
-- Indicates the index into the Arguments vector containing the first
-- option
function Argument (Number: in Positive) return String
renames Ada.Command_Line.Argument;
Arg: Unbounded_String;
procedure Unrecognized_Option is
begin
UI.Put_Fail_Tag;
Put_Line (" Unrecognized option """ & To_String (Arg) & """.");
Command := Help_Command;
end Unrecognized_Option;
function Is_Option (Arg_S: in String) return Boolean is
(Ada.Strings.Fixed.Head (Arg_S, 1) = "-");
procedure Check_Option_Start (Arg_S : in String;
Expected: in String;
After : out Positive)
is
-- If Expected matches the beginning of Arg, then After is the index into
-- Arg which is the first character after Expected. Otherwise, consider
-- the option to be invalid
begin
After := Arg_S'First + Expected'Length;
if Arg_S'Length <= Expected'Length
-- This procuedure is only used for cases where an option has varients,
-- such as -optimize-1 vs -optimize-2, so it must at least be longer
-- than the expected
or else Arg_S(Arg_S'First .. After - 1) /= Expected
then
Unrecognized_Option;
end if;
end Check_Option_Start;
begin
Build.Load_Last_Build_Config (Parameters.Build_Config);
-- Load last configuration (if available)
-- Collect the command, if any
if Arg_Count = 0 then
-- Use the default command
return;
end if;
if not Is_Option (Argument(1)) then
declare
package ACH renames Ada.Characters.Handling;
Command_Text: constant String := ACH.To_Lower (Argument (1));
Bad_Command : Boolean := True;
procedure Check_Command (Expected: in Selected_Command;
Check : in String)
is begin
if Command_Text = Check then
Command := Expected;
Bad_Command := False;
else
Bad_Command := True;
end if;
end;
begin
if Command_Text'Length < 2 then
Bad_Command := True;
else
case Command_Text(Command_Text'First) is
when 'b' => Check_Command (Build_Command, "build" );
when 'c' =>
case Command_Text(Command_Text'First + 1) is
when 'h' => Check_Command (Checkout_Command, "checkout" );
when 'l' => Check_Command (Clean_Command, "clean" );
when 'o' => Check_Command (Compile_Command, "compile" );
when others => Bad_Command := True;
end case;
when 'h' => Check_Command (Help_Command, "help" );
when 'l' => Check_Command (Library_Command, "library" );
when 'r' => Check_Command (Run_Command, "run" );
when 's' => Check_Command (Systemize_Command, "systemize");
when others => Bad_Command := True;
end case;
end if;
if Bad_Command then
UI.Put_Fail_Tag;
Put_Line (" Command """ & Command_Text & """ not recognized.");
Command := Help_Command;
return;
end if;
end;
Options_Start := 2;
else
Options_Start := 1;
end if;
-- Capture the "main unit" if it is defined (only for the relevant commands)
if Command in Build_Command | Run_Command
and then Options_Start <= Arg_Count
and then not Is_Option (Argument(Options_Start))
then
-- We have to assume that this unit name is utf-8 encoded
declare
package UTF renames Ada.Strings.UTF_Encoding;
package WWUTF renames UTF.Wide_Wide_Strings;
WWName: constant Wide_Wide_String
:= WWUTF.Decode (UTF.UTF_8_String'(Argument(Options_Start)));
begin
if Unit_Names.Valid_Unit_Name (WWName) then
Parameters.Main_Unit := Unit_Names.Set_Name (WWName);
Options_Start := Options_Start + 1;
if Parameters.Main_Unit.Is_External_Unit then
UI.Put_Fail_Tag;
Put_Line (" External main units are not supported.");
raise Process_Failed;
end if;
else
UI.Put_Fail_Tag;
Put_Line (" Main Unit Name """ & Argument (Options_Start)
& """ is not a valid Ada unit name.");
raise Process_Failed;
end if;
end;
end if;
-- Process all options, and check against the command
Parameters.Last_Argument := Options_Start;
Option_Iteration:
for I in Options_Start .. Arg_Count loop
Set_Unbounded_String
(Target => Arg,
Source => Ada.Characters.Handling.To_Lower (Argument (I)));
if Element (Arg, 1) /= '-' then
-- End of the options
Parameters.Last_Argument := I - 1;
exit;
end if;
case Element (Arg, 2) is
when 'a' =>
if To_String (Arg) = "-assertions" then
Parameters.Build_Config.All_Assertions := True;
else
Unrecognized_Option;
return;
end if;
when 'd' =>
if To_String (Arg) = "-debug" then
Parameters.Build_Config.Debug_Enabled := True;
else
Unrecognized_Option;
return;
end if;
when 'n' =>
-- Must be -no-pie or -no-pic
if Arg = "-no-pic" or else Arg = "-no-pie"
then
Parameters.Build_Config.Position_Independent := False;
else
Unrecognized_Option;
return;
end if;
when 'o' =>
-- Optimize of some kind
declare
Arg_S: constant String := To_String (Arg);
Diff_Start: Positive;
begin
Check_Option_Start (Arg_S => Arg_S,
Expected => "-optimize-",
After => Diff_Start);
case Arg_S (Diff_Start) is
when '1' => Parameters.Build_Config.Optimization := Level_1;
when '2' => Parameters.Build_Config.Optimization := Level_2;
when '3' => Parameters.Build_Config.Optimization := Level_3;
when 's' => Parameters.Build_Config.Optimization := Size;
when 'd' => Parameters.Build_Config.Optimization := Debug;
when others =>
Unrecognized_Option;
return;
end case;
end;
when 'q' =>
if Arg = "-q" then
Parameters.Output_Style := Quiet;
else
Unrecognized_Option;
return;
end if;
when 'r' =>
declare
Arg_S: constant String := To_String (Arg);
Diff_Start: Positive;
begin
Check_Option_Start (Arg_S => Arg_S,
Expected => "-repo-",
After => Diff_Start);
case Arg_S (Diff_Start) is
when 'a' => Parameters.Systemize_Mode := Add;
when 's' => Parameters.Systemize_Mode := Show;
when others =>
Unrecognized_Option;
return;
end case;
end;
when 's' =>
if Arg = "-static" then
Parameters.Build_Config.Linking := Static;
Parameters.Build_Config.Position_Independent := False;
elsif Arg = "-static-rt" then
Parameters.Build_Config.Linking := Static_RT;
else
Unrecognized_Option;
return;
end if;
when 'v' =>
if Arg = "-v" then
Parameters.Output_Style := Verbose;
else
Unrecognized_Option;
return;
end if;
when 'y' =>
if Arg = "-y" then
UI_Primitives.Auto_Queries := True;
else
Unrecognized_Option;
return;
end if;
when others =>
Unrecognized_Option;
return;
end case;
end loop Option_Iteration;
-- Check library name validity, and determine if it is a static (archive) or
-- dynamic library. We can also alert the user of an override of -static if
-- the library is to be an archive.
--
-- After this, the actual Link_Or_Archive phase can be confident the library
-- name is valid and appropriate for the platform and configuration
if Command = Library_Command then
if Parameters.Last_Argument = Arg_Count then
UI.Put_Fail_Tag;
Put_Line (" Library builds must include a target library output "
& "filename.");
raise Process_Failed;
end if;
-- Extract the extension slice of the expected file name
declare
Output_Name: constant String
:= Argument(Parameters.Last_Argument + 1);
Extension: constant String
:= Ada.Characters.Handling.To_Lower
(Ada.Directories.Extension
(Argument(Parameters.Last_Argument + 1)));
begin
if Extension = "a" then
if Parameters.Build_Config.Linking /= Static then
UI.Put_Info_Tag;
Put_Line (" Archive libraries (.a) imply -static.");
Parameters.Build_Config.Linking := Static;
end if;
elsif Extension = "so" then
if Platform_Info.Platform_Family = "windows" then
UI.Put_Fail_Tag;
Put_Line (" Windows only supports .a and .dll libraries.");
raise Process_Failed;
elsif Platform_Info.Platform_Family = "unix"
and then Platform_Info.Platform_Flavor = "darwin"
then
UI.Put_Fail_Tag;
Put_Line (" Darwin only supports .a and .dylib "
& "libraries.");
raise Process_Failed;
end if;
elsif Extension = "dylib" then
if Platform_Info.Platform_Family /= "unix"
or else Platform_Info.Platform_Flavor /= "darwin"
then
UI.Put_Fail_Tag;
Put_Line (" .dylib libraries are only supported for Darwin "
& "targets.");
raise Process_Failed;
end if;
elsif Extension = "dll" then
if Platform_Info.Platform_Family /= "windows" then
UI.Put_Fail_Tag;
Put_Line (" .dll libraries are only supported for Windows "
& "targets.");
raise Process_Failed;
end if;
else
UI.Put_Fail_Tag;
Put_Line (" Library name must end in a valid extension "
& "(.a/.so/.dylib/.dll)");
raise Process_Failed;
end if;
end;
end if;
-- Systemize is tightly controlled by AURA, so we need to warn the user
-- when they attempt to use invalid options
if Command = Systemize_Command
and then (not Parameters.Build_Config.Position_Independent
or else Parameters.Build_Config.Linking /= Shared)
then
UI.Put_Warn_Tag;
Put_Line (" -no-pie/-no-pic and -static/-static-rt are not relevant when");
Put_Line (" building a System repository.");
Parameters.Build_Config.Position_Independent := True;
Parameters.Build_Config.Linking := Shared;
raise Process_Failed;
end if;
-- Finally set the Build mode
case Command is
when Build_Command | Run_Command =>
Parameters.Build_Config.Mode := Image;
when Library_Command =>
Parameters.Build_Config.Mode := Library;
when Systemize_Command =>
Parameters.Build_Config.Mode := Systemize;
when Checkout_Command | Clean_Command | Compile_Command | Help_Command =>
-- We simply set an arbitrary default in this case, as the build mode
-- won't actually matter in these cases
Parameters.Build_Config.Mode := Image;
end case;
end Initialize_Parameters;
|
flyx/OpenGLAda | Ada | 10,531 | adb | -- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with GL.API.Singles;
with GL.API.Ints;
with GL.API.UInts;
with GL.Low_Level;
package body GL.Uniforms is
procedure Set_Single (Location : Uniform; Value : Single) is
begin
API.Singles.Uniform1 (Location, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; V1, V2 : Single) is
begin
API.Singles.Uniform2 (Location, V1, V2);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Vector2) is
begin
API.Singles.Uniform2v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; V1, V2, V3 : Single) is
begin
API.Singles.Uniform3 (Location, V1, V2, V3);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Vector3) is
begin
API.Singles.Uniform3v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; V1, V2, V3, V4 : Single) is
begin
API.Singles.Uniform4 (Location, V1, V2, V3, V4);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Vector4) is
begin
API.Singles.Uniform4v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Single_Array) is
begin
API.Singles.Uniform1v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Vector2_Array) is
begin
API.Singles.Uniform2v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Vector3_Array) is
begin
API.Singles.Uniform3v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Vector4_Array) is
begin
API.Singles.Uniform4v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Matrix2) is
begin
API.Singles.Uniform_Matrix2 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Matrix3) is
begin
API.Singles.Uniform_Matrix3 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Matrix4) is
begin
API.Singles.Uniform_Matrix4 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Matrix2_Array) is
begin
API.Singles.Uniform_Matrix2
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Matrix3_Array) is
begin
API.Singles.Uniform_Matrix3
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Single (Location : Uniform; Value : Singles.Matrix4_Array) is
begin
API.Singles.Uniform_Matrix4
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Single;
procedure Set_Int (Location : Uniform; Value : Int) is
begin
API.Ints.Uniform1 (Location, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; V1, V2 : Int) is
begin
API.Ints.Uniform2 (Location, V1, V2);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Vector2) is
begin
API.Ints.Uniform2v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; V1, V2, V3 : Int) is
begin
API.Ints.Uniform3 (Location, V1, V2, V3);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Vector3) is
begin
API.Ints.Uniform3v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; V1, V2, V3, V4 : Int) is
begin
API.Ints.Uniform4 (Location, V1, V2, V3, V4);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Vector4) is
begin
API.Ints.Uniform4v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Int_Array) is
begin
API.Ints.Uniform1v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Vector2_Array) is
begin
API.Ints.Uniform2v (Location, Value'Length * 2, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Vector3_Array) is
begin
API.Ints.Uniform3v (Location, Value'Length * 3, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Vector4_Array) is
begin
API.Ints.Uniform4v (Location, Value'Length * 4, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Matrix2) is
begin
API.Ints.Uniform_Matrix2 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Matrix3) is
begin
API.Ints.Uniform_Matrix3 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Matrix4) is
begin
API.Ints.Uniform_Matrix4 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Matrix2_Array) is
begin
API.Ints.Uniform_Matrix2
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Matrix3_Array) is
begin
API.Ints.Uniform_Matrix3
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_Int (Location : Uniform; Value : Ints.Matrix4_Array) is
begin
API.Ints.Uniform_Matrix4
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Int;
procedure Set_UInt (Location : Uniform; Value : UInt) is
begin
API.UInts.Uniform1 (Location, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; V1, V2 : UInt) is
begin
API.UInts.Uniform2 (Location, V1, V2);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Vector2) is
begin
API.UInts.Uniform2v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; V1, V2, V3 : UInt) is
begin
API.UInts.Uniform3 (Location, V1, V2, V3);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Vector3) is
begin
API.UInts.Uniform3v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; V1, V2, V3, V4 : UInt) is
begin
API.UInts.Uniform4 (Location, V1, V2, V3, V4);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Vector4) is
begin
API.UInts.Uniform4v (Location, 1, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInt_Array) is
begin
API.UInts.Uniform1v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Vector2_Array) is
begin
API.UInts.Uniform2v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Vector3_Array) is
begin
API.UInts.Uniform3v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Vector4_Array) is
begin
API.UInts.Uniform4v (Location, Value'Length, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Matrix2) is
begin
API.UInts.Uniform_Matrix2 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Matrix3) is
begin
API.UInts.Uniform_Matrix3 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Matrix4) is
begin
API.UInts.Uniform_Matrix4 (Location, 1, Low_Level.False, (1 => Value));
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Matrix2_Array) is
begin
API.UInts.Uniform_Matrix2
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Matrix3_Array) is
begin
API.UInts.Uniform_Matrix3
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
procedure Set_UInt (Location : Uniform; Value : UInts.Matrix4_Array) is
begin
API.UInts.Uniform_Matrix4
(Location, Value'Length, Low_Level.False, Value);
Raise_Exception_On_OpenGL_Error;
end Set_UInt;
end GL.Uniforms;
|
reznikmm/matreshka | Ada | 16,513 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Characters.Wide_Wide_Latin_1;
with League.Strings;
with AWF.Internals.Java_Script_Registry;
with AWF.Registry;
pragma Elaborate (AWF.Registry);
package body AWF.Internals.AWF_Widgets is
use Ada.Characters.Wide_Wide_Latin_1;
use type AWF.Internals.AWF_Layouts.AWF_Layout_Proxy_Access;
Java_Script_Code : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String
(LF
& "function AWFWidgetOnEvent(element,event)" & LF
& "{" & LF
& " var request = new XMLHttpRequest();" & LF
& " request.onreadystatechange=function()" & LF
& " {" & LF
& " if (request.readyState == 4 && request.status == 200)" & LF
& " {" & LF
& " eval(request.responseText);" & LF
& " }" & LF
& " }" & LF
& " request.open('GET', window.location + '/' + element.id + '/' + event, true);" & LF
& " request.send();" & LF
& "}" & LF);
procedure onkeydown_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure onkeypress_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure onkeyup_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure onclick_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure ondblclick_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure ondrag_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure ondragend_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure ondragenter_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure ondragleave_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure ondragover_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure ondragstart_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure ondrop_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure onmousedown_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure onmousemove_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure onmouseout_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure onmouseover_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure onmouseup_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure onmousewheel_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
procedure onscroll_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access);
--------------------
-- Append_Payload --
--------------------
not overriding procedure Append_Payload
(Self : not null access AWF_Widget_Proxy;
Payload : League.Strings.Universal_String) is
begin
Self.Payload.Append (Payload);
end Append_Payload;
------------------
-- Constructors --
------------------
package body Constructors is
Last_Id : Natural := 0;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : not null access AWF_Widget_Proxy'Class;
Parent : access AWF.Widgets.AWF_Widget'Class := null) is
begin
League.Objects.Impl.Constructors.Initialize (Self, Parent);
-- Allocate number and register widget.
Last_Id := Last_Id + 1;
Self.Id := Last_Id;
AWF.Registry.Register_Widget (Self);
end Initialize;
end Constructors;
-----------------
-- Get_Payload --
-----------------
not overriding function Get_Payload
(Self : not null access AWF_Widget_Proxy)
return League.Strings.Universal_String is
begin
return Payload : League.Strings.Universal_String := Self.Payload do
Self.Payload.Clear;
end return;
end Get_Payload;
--------
-- Id --
--------
function Id
(Self : not null access constant AWF_Widget_Proxy) return Natural is
begin
return Self.Id;
end Id;
---------------------
-- onclick_Handler --
---------------------
procedure onclick_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Click_Event;
end onclick_Handler;
------------------------
-- ondblclick_Handler --
------------------------
procedure ondblclick_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Double_Click_Event;
end ondblclick_Handler;
--------------------
-- ondrag_Handler --
--------------------
procedure ondrag_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Drag_Event;
end ondrag_Handler;
-----------------------
-- ondragend_Handler --
-----------------------
procedure ondragend_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Drag_End_Event;
end ondragend_Handler;
-------------------------
-- ondragenter_Handler --
-------------------------
procedure ondragenter_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Drag_Enter_Event;
end ondragenter_Handler;
-------------------------
-- ondragleave_Handler --
-------------------------
procedure ondragleave_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Drag_Leave_Event;
end ondragleave_Handler;
------------------------
-- ondragover_Handler --
------------------------
procedure ondragover_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Drag_Over_Event;
end ondragover_Handler;
-------------------------
-- ondragstart_Handler --
-------------------------
procedure ondragstart_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Drag_Start_Event;
end ondragstart_Handler;
--------------------
-- ondrop_Handler --
--------------------
procedure ondrop_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Drop_Event;
end ondrop_Handler;
-----------------------
-- onkeydown_Handler --
-----------------------
procedure onkeydown_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Key_Down_Event;
end onkeydown_Handler;
------------------------
-- onkeypress_Handler --
------------------------
procedure onkeypress_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Key_Press_Event;
end onkeypress_Handler;
---------------------
-- onkeyup_Handler --
---------------------
procedure onkeyup_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Key_Up_Event;
end onkeyup_Handler;
-------------------------
-- onmousedown_Handler --
-------------------------
procedure onmousedown_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Mouse_Down_Event;
end onmousedown_Handler;
-------------------------
-- onmousemove_Handler --
-------------------------
procedure onmousemove_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Mouse_Move_Event;
end onmousemove_Handler;
------------------------
-- onmouseout_Handler --
------------------------
procedure onmouseout_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Mouse_Out_Event;
end onmouseout_Handler;
-------------------------
-- onmouseover_Handler --
-------------------------
procedure onmouseover_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Mouse_Over_Event;
end onmouseover_Handler;
-----------------------
-- onmouseup_Handler --
-----------------------
procedure onmouseup_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Mouse_Up_Event;
end onmouseup_Handler;
--------------------------
-- onmousewheel_Handler --
--------------------------
procedure onmousewheel_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Mouse_Wheel_Event;
end onmousewheel_Handler;
----------------------
-- onscroll_Handler --
----------------------
procedure onscroll_Handler
(Widget : not null AWF.Internals.AWF_Widgets.AWF_Widget_Proxy_Access) is
begin
Widget.Scroll_Event;
end onscroll_Handler;
-----------------
-- Render_Body --
-----------------
not overriding procedure Render_Body
(Self : not null access AWF_Widget_Proxy;
Context : in out AWF.HTML_Writers.HTML_Writer'Class) is
begin
if Self.Layout /= null then
Self.Layout.Render_Body (Context);
end if;
end Render_Body;
----------------
-- Set_Layout --
----------------
overriding procedure Set_Layout
(Self : not null access AWF_Widget_Proxy;
Layout : access AWF.Layouts.AWF_Layout'Class) is
begin
if Self.Layout /= null then
raise Program_Error;
end if;
Self.Layout :=
AWF.Internals.AWF_Layouts.AWF_Layout_Proxy_Access (Layout);
Layout.Set_Parent (Self);
end Set_Layout;
begin
-- Register callbacks
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("onkeydown"),
onkeydown_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("onkeypress"),
onkeypress_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("onkeyup"),
onkeyup_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("onclick"),
onclick_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("ondblclick"),
ondblclick_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("ondrag"),
ondrag_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("ondragend"),
ondragend_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("ondragenter"),
ondragenter_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("ondragleave"),
ondragleave_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("ondragover"),
ondragover_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("ondragstart"),
ondragstart_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("ondrop"),
ondrop_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("onmousedown"),
onmousedown_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("onmousemove"),
onmousemove_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("onmouseout"),
onmouseout_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("onmouseover"),
onmouseover_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("onmouseup"),
onmouseup_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("onmousewheel"),
onmousewheel_Handler'Access);
AWF.Registry.Register_Callback
(AWF_Widget_Proxy'Tag,
League.Strings.To_Universal_String ("onscroll"),
onscroll_Handler'Access);
-- Register Java Script code.
AWF.Internals.Java_Script_Registry.Register (Java_Script_Code);
end AWF.Internals.AWF_Widgets;
|
reznikmm/matreshka | Ada | 3,749 | 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.Table_Condition_Source_Attributes is
pragma Preelaborate;
type ODF_Table_Condition_Source_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Table_Condition_Source_Attribute_Access is
access all ODF_Table_Condition_Source_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Table_Condition_Source_Attributes;
|
riccardo-bernardini/eugen | Ada | 1,767 | ads | private
package Tokenize.Private_Token_Lists with SPARK_Mode => On is
type Token_List (<>) is tagged private;
function Create (N : Token_Count) return Token_List
with
Pre'Class => Integer(N) < Positive'Last,
Post => Create'Result.Length = 0 and Create'Result.Capacity = N;
function Capacity (Item : Token_List) return Token_Count;
function Length (Item : Token_List) return Token_Count
with Post => Length'Result <= Item.Capacity;
procedure Append (List : in out Token_List;
What : String)
with Pre'Class => List.Length < List.Capacity,
Post => List.Length = List.Length'Old + 1
and List.Capacity = List.Capacity'Old;
function Element (List : Token_List;
N : Token_Count)
return String
with Pre'Class => List.Length >= N;
private
type Token_List (Length : Token_Count) is tagged
record
Tokens : Token_Array (1 .. Length) := (others => Null_Unbounded_String);
First_Free : Token_Count := 1;
end record
with Predicate => First_Free <= Length + 1
and Tokens'Length = Length;
function Create (N : Token_Count) return Token_List
is (Token_List'(Length => N,
Tokens => (others => Null_Unbounded_String),
First_Free => 1));
function Capacity (Item : Token_List) return Token_Count
is (Item.Tokens'Last);
function Length (Item : Token_List) return Token_Count
is (Item.First_Free - 1);
function Element (List : Token_List;
N : Token_Count)
return String
is (To_String (List.Tokens (N)));
end Tokenize.Private_Token_Lists;
|
skordal/ada-regex | Ada | 2,495 | ads | -- Ada regular expression library
-- (c) Kristian Klomsten Skordal 2020 <[email protected]>
-- Report bugs and issues on <https://github.com/skordal/ada-regex>
with Regex.Syntax_Trees;
with Regex.State_Machines;
private with Ada.Finalization;
package Regex.Regular_Expressions is
-- Regex engine exceptions:
Syntax_Error : exception;
Unsupported_Feature : exception;
-- Regular expression object:
type Regular_Expression is tagged limited private;
-- Creates a regular expression object from a regular expression string:
function Create (Input : in String) return Regular_Expression;
-- Creates a regular expression object from an existing syntax tree:
function Create (Input : in Regex.Syntax_Trees.Syntax_Tree_Node_Access) return Regular_Expression;
-- Gets the syntax tree of a regular expression:
function Get_Syntax_Tree (This : in Regular_Expression)
return Regex.Syntax_Trees.Syntax_Tree_Node_Access with Inline;
-- Gets the state machine generated by a regular expression:
function Get_State_Machine (This : in Regular_Expression)
return Regex.State_Machines.State_Machine_State_Vectors.Vector with Inline;
-- Gets the start state of a regular expression:
function Get_Start_State (This : in Regular_Expression)
return Regex.State_Machines.State_Machine_State_Access with Inline;
private
use Regex.State_Machines;
use Regex.Syntax_Trees;
-- Complete regular expression object type:
type Regular_Expression is new Ada.Finalization.Limited_Controlled with record
Syntax_Tree : Syntax_Tree_Node_Access := null; -- Syntax tree kept around for debugging
Syntax_Tree_Node_Count : Natural := 1; -- Counter used to number nodes and keep count
State_Machine_States : State_Machine_State_Vectors.Vector := State_Machine_State_Vectors.Empty_Vector;
Start_State : State_Machine_State_Access;
end record;
-- Frees a regular expression object:
overriding procedure Finalize (This : in out Regular_Expression);
-- Gets the next node ID:
function Get_Next_Node_Id (This : in out Regular_Expression) return Natural with Inline;
-- Parses a regular expression and constructs a syntax tree:
procedure Parse (Input : in String; Output : in out Regular_Expression);
-- Compiles a regular expression into a state machine:
procedure Compile (Output : in out Regular_Expression);
end Regex.Regular_Expressions;
|
thieryw/snake | Ada | 166 | ads | package display is
type grid is array(1..20,1..70) of boolean ;
screen : grid ;
procedure render(screen : grid) ;
end display ;
|
AdaCore/libadalang | Ada | 156 | adb | separate (Pkg)
--% node.p_parent_basic_decl
package body Inner is
procedure Foo is
begin
null;
end Foo;
end T;
--% node.p_parent_basic_decl
|
AdaCore/libadalang | Ada | 388 | adb | procedure Test is
type Index_T is range 1 .. 5;
subtype Sub_Index_T is Index_T range 2 .. 4;
type A1 is array (Index_T) of Integer;
type A2 is array (Index_T) of A1;
type A3 is array (Index_T) of A2;
V : A1;
X : A3;
Y : Integer;
begin
Y := X (Sub_Index_T) (2) (1 .. 4) (3) (Sub_Index_T range 2 .. 3) (2);
Y := V (Sub_Index_T) (Sub_Index_T)'Size;
end Test;
|
tum-ei-rcs/StratoX | Ada | 55 | ads |
package MPU6000 with SPARK_Mode is
end MPU6000;
|
luisfelipe3d/base-cod-java | Ada | 178 | adb | with Ada.Text_IO; use Ada.Text_IO;
procedure abc is
A : Integer := 7;
B : Integer := 5;
D: Integer := B;
begin
Put_Line("Value of B: " & Integer'Image(B));
end abc;
|
reznikmm/matreshka | Ada | 8,504 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015-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 Asis.Declarations;
with Asis.Expressions;
with Asis.Elements;
package body Properties.Expressions.Selected_Components is
---------------
-- Alignment --
---------------
function Alignment
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Integer_Property) return Integer is
begin
return Engine.Integer.Get_Property
(Asis.Expressions.Selector (Element), Name);
end Alignment;
---------------------
-- Call_Convention --
---------------------
function Call_Convention
(Engine : access Engines.Contexts.Context;
Element : Asis.Declaration;
Name : Engines.Convention_Property)
return Engines.Convention_Kind is
begin
return Engine.Call_Convention.Get_Property
(Asis.Expressions.Selector (Element), Name);
end Call_Convention;
----------
-- Code --
----------
function Code
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Text_Property) return League.Strings.Universal_String
is
Prefix : constant Asis.Expression := Asis.Expressions.Prefix (Element);
Selector : constant Asis.Expression :=
Asis.Expressions.Selector (Element);
Def_Name : constant Asis.Defining_Name :=
Asis.Expressions.Corresponding_Name_Definition (Selector);
Decl : Asis.Declaration;
Kind : Asis.Declaration_Kinds;
begin
if not Asis.Elements.Is_Nil (Def_Name) then
Decl := Asis.Elements.Enclosing_Element (Def_Name);
Kind := Asis.Elements.Declaration_Kind (Decl);
case Kind is
when Asis.A_Component_Declaration |
Asis.A_Discriminant_Specification =>
declare
Left : League.Strings.Universal_String;
Right : League.Strings.Universal_String;
begin
Left := Engine.Text.Get_Property (Prefix, Engines.Code);
-- This causes inop element (A_Component_Decl) in Corresp_Subprogram_Declar
Right := Engine.Text.Get_Property (Selector, Name);
-- Right := Engine.Text.Get_Property (Def_Name, Name);
Left.Append (".");
Left.Append (Right);
return Left;
end;
when Asis.A_Subtype_Declaration =>
return Engine.Text.Get_Property
(Asis.Declarations.Type_Declaration_View (Decl), Name);
when Asis.A_Function_Declaration |
Asis.A_Procedure_Declaration |
Asis.A_Function_Instantiation |
Asis.A_Function_Renaming_Declaration |
Asis.A_Procedure_Instantiation |
Asis.A_Private_Extension_Declaration |
Asis.An_Enumeration_Literal_Specification |
Asis.An_Ordinary_Type_Declaration |
Asis.A_Private_Type_Declaration |
Asis.A_Constant_Declaration |
Asis.A_Deferred_Constant_Declaration |
Asis.A_Variable_Declaration |
Asis.An_Integer_Number_Declaration |
Asis.A_Real_Number_Declaration =>
null;
when others =>
raise Program_Error with
"Unimplemented Selected_Component";
end case;
end if;
return Engine.Text.Get_Property (Selector, Name);
end Code;
--------------------
-- Intrinsic_Name --
--------------------
function Intrinsic_Name
(Engine : access Engines.Contexts.Context;
Element : Asis.Declaration;
Name : Engines.Text_Property)
return League.Strings.Universal_String is
begin
return Engine.Text.Get_Property
(Asis.Expressions.Selector (Element), Name);
end Intrinsic_Name;
function Initialize
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Text_Property) return League.Strings.Universal_String
renames Intrinsic_Name;
function Method_Name
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Text_Property) return League.Strings.Universal_String
renames Intrinsic_Name;
function Typed_Array_Item_Type
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Text_Property) return League.Strings.Universal_String
renames Intrinsic_Name;
function Size
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Text_Property) return League.Strings.Universal_String
renames Intrinsic_Name;
--------------------
-- Is_Dispatching --
--------------------
function Is_Dispatching
(Engine : access Engines.Contexts.Context;
Element : Asis.Declaration;
Name : Engines.Boolean_Property) return Boolean is
begin
return Engine.Boolean.Get_Property
(Asis.Expressions.Selector (Element), Name);
end Is_Dispatching;
end Properties.Expressions.Selected_Components;
|
reznikmm/matreshka | Ada | 3,739 | 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_Extrusion_Depth_Attributes is
pragma Preelaborate;
type ODF_Draw_Extrusion_Depth_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Extrusion_Depth_Attribute_Access is
access all ODF_Draw_Extrusion_Depth_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Extrusion_Depth_Attributes;
|
stcarrez/ada-util | Ada | 1,355 | ads | -----------------------------------------------------------------------
-- util-streams-texts-tr -- Text translation utilities on streams
-- Copyright (C) 2010, 2011, 2012, 2015, 2016, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Texts.Transforms;
with Ada.Characters.Handling;
package Util.Streams.Texts.TR is
new Util.Texts.Transforms (Stream => Print_Stream'Class,
Char => Character,
Input => String,
Put => Write_Char,
To_Upper => Ada.Characters.Handling.To_Upper,
To_Lower => Ada.Characters.Handling.To_Lower);
|
DrenfongWong/tkm-rpc | Ada | 2,097 | adb | --
-- Copyright (C) 2013 Reto Buerki <[email protected]>
-- Copyright (C) 2013 Adrian-Ken Rueegsegger <[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:
-- 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 University 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 REGENTS 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 REGENTS 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.
--
separate (Tkmrpc.Clients.Ees)
procedure Init
(Result : out Results.Result_Type;
Address : Interfaces.C.Strings.chars_ptr)
is
begin
declare
Socket_Address : constant String := Interfaces.C.Strings.Value
(Item => Address);
begin
Transport.Client.Connect (Address => Socket_Address);
Result := Results.Ok;
end;
exception
when others =>
Result := Results.Invalid_Operation;
end Init;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.