Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Declare the method binding types
----------------------------------------------------------------------- -- EL.Beans.Methods -- Bean methods -- Copyright (C) 2010 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Strings; package EL.Beans.Methods is pragma Preelaborate; type Method_Binding is tagged limited record Name : Util.Strings.Name_Access; end record; type Method_Binding_Access is access constant Method_Binding'Class; type Method_Binding_Array is array (Natural range <>) of Method_Binding_Access; type Method_Binding_Array_Access is access constant Method_Binding_Array; type Method_Bean is limited Interface; type Method_Bean_Access is access all Method_Bean'Class; function Get_Method_Bindings (From : in Method_Bean) return Method_Binding_Array_Access is abstract; end EL.Beans.Methods;
Define the set of string package
----------------------------------------------------------------------- -- Util-strings-sets -- Set of strings -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Hash; with Ada.Containers.Indefinite_Hashed_Sets; -- The <b>Util.Strings.Sets</b> package provides an instantiation -- of a hashed set with Strings. package Util.Strings.Sets is new Ada.Containers.Indefinite_Hashed_Sets (Element_Type => String, Hash => Ada.Strings.Hash, Equivalent_Elements => "=");
Define the ASF.Routes.Servlets.Rest package for the REST route
----------------------------------------------------------------------- -- asf-reoutes-servlets-rest -- Route for the REST API -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ASF.Rest; package ASF.Routes.Servlets.Rest is type Descriptor_Array is array (ASF.Rest.Method_Type) of ASF.Rest.Descriptor_Access; -- The route has one descriptor for each REST method. type API_Route_Type is new ASF.Routes.Servlets.Servlet_Route_Type with record Descriptors : Descriptor_Array; end record; end ASF.Routes.Servlets.Rest;
Declare the Wiki.Plugins.Templates package with the Template_Plugin type
----------------------------------------------------------------------- -- wiki-plugins-template -- Template Plugin -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 Wiki.Strings; -- === Template Plugins === -- The <b>Wiki.Plugins.Templates</b> package defines an abstract template plugin. -- To use the template plugin, the <tt>Get_Template</tt> procedure must be implemented. -- It is responsible for getting the template content according to the plugin parameters. -- package Wiki.Plugins.Templates is pragma Preelaborate; type Template_Plugin is abstract new Wiki_Plugin with null record; -- Get the template content for the plugin evaluation. procedure Get_Template (Plugin : in out Template_Plugin; Params : in out Wiki.Attributes.Attribute_List; Template : out Wiki.Strings.UString) is abstract; -- Expand the template configured with the parameters for the document. -- The <tt>Get_Template</tt> operation is called and the template content returned -- by that operation is parsed in the current document. Template parameters are passed -- in the <tt>Context</tt> instance and they can be evaluated within the template -- while parsing the template content. overriding procedure Expand (Plugin : in out Template_Plugin; Document : in out Wiki.Documents.Document; Params : in out Wiki.Attributes.Attribute_List; Context : in Plugin_Context); end Wiki.Plugins.Templates;
Test that a VIEW_CONVERT_EXPR used as an lvalue has the right type.
-- RUN: %llvmgcc -c %s -o /dev/null procedure VCE_LV is type P is access String ; type T is new P (5 .. 7); subtype U is String (5 .. 7); X : T := new U'(others => 'A'); begin null; end;
Refactor Buffered_Stream and Print_Stream - move the WTR package instantiation in a separate file
----------------------------------------------------------------------- -- util-streams-texts-tr -- Text translation utilities on streams -- Copyright (C) 2010, 2011, 2012, 2015, 2016, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Wide_Wide_Characters.Handling; package Util.Streams.Texts.WTR is new Util.Texts.Transforms (Stream => Print_Stream'Class, Char => Wide_Wide_Character, Input => Wide_Wide_String, Put => Write_Char, To_Upper => Ada.Wide_Wide_Characters.Handling.To_Upper, To_Lower => Ada.Wide_Wide_Characters.Handling.To_Lower);
Define a simple HTML parser that can be used to parse HTML text embedded in wiki text
----------------------------------------------------------------------- -- wiki-parsers-html -- Wiki HTML parser -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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. ----------------------------------------------------------------------- -- This is a small HTML parser that is called to deal with embedded HTML in wiki text. -- The parser is intended to handle incorrect HTML and clean the result as much as possible. -- We cannot use a real XML/Sax parser (such as XML/Ada) because we must handle errors and -- backtrack from HTML parsing to wiki or raw text parsing. -- -- When parsing HTML content, we call the <tt>Start_Element</tt> or <tt>End_Element</tt> -- operations. The renderer is then able to handle the HTML tag according to its needs. private package Wiki.Parsers.Html is pragma Preelaborate; -- Parse a HTML element <XXX attributes> -- or parse an end of HTML element </XXX> procedure Parse_Element (P : in out Parser); end Wiki.Parsers.Html;
Define the OAuth security filter for AWA applications
----------------------------------------------------------------------- -- awa-oauth-filters -- OAuth filter -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with ASF.Requests; with ASF.Responses; with ASF.Sessions; with ASF.Principals; with ASF.Filters; with ASF.Servlets; with ASF.Security.Filters; with AWA.Users.Principals; with AWA.OAuth.Services; package AWA.OAuth.Filters is -- ------------------------------ -- OAuth Authentication filter -- ------------------------------ -- The <b>Auth_Filter</b> verifies that the access token passed for the OAuth -- operation is valid and it extracts the user to configure the request principal. type Auth_Filter is new ASF.Filters.Filter with private; -- Initialize the filter. overriding procedure Initialize (Filter : in out Auth_Filter; Config : in ASF.Servlets.Filter_Config); -- The Do_Filter method of the Filter is called by the container each time -- a request/response pair is passed through the chain due to a client request -- for a resource at the end of the chain. The Filter_Chain passed in to this -- method allows the Filter to pass on the request and response to the next -- entity in the chain. -- -- Before passing the control to the next filter, initialize the service -- context to give access to the current application, current user and -- manage possible transaction rollbacks. overriding procedure Do_Filter (F : in Auth_Filter; Request : in out ASF.Requests.Request'Class; Response : in out ASF.Responses.Response'Class; Chain : in out ASF.Servlets.Filter_Chain); private use Ada.Strings.Unbounded; type Auth_Filter is new ASF.Filters.Filter with record Realm : AWA.OAuth.Services.Auth_Manager_Access; end record; end AWA.OAuth.Filters;
Add tests for the Util.Commands.Drivers package
----------------------------------------------------------------------- -- util-commands-tests - Test for commands -- Copyright (C) 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Util.Commands.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Tests when the execution of commands. procedure Test_Execute (T : in out Test); -- Test execution of help. procedure Test_Help (T : in out Test); -- Test usage operation. procedure Test_Usage (T : in out Test); end Util.Commands.Tests;
Define the ping command to ask the Bbox to ping the known devices
----------------------------------------------------------------------- -- druss-commands-ping -- Ping devices from the gateway -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package Druss.Commands.Ping is type Command_Type is new Druss.Commands.Drivers.Command_Type with null record; procedure Do_Ping (Command : in Command_Type; Args : in Argument_List'Class; Context : in out Context_Type); -- Execute a ping from the gateway to each device. overriding procedure Execute (Command : in Command_Type; Name : in String; Args : in Argument_List'Class; Context : in out Context_Type); -- Write the help associated with the command. overriding procedure Help (Command : in Command_Type; Context : in out Context_Type); end Druss.Commands.Ping;
Implement the Get_Count and Get_Argument operations
----------------------------------------------------------------------- -- util-commands -- Support to make command line tools -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Command_Line; package body Util.Commands is -- ------------------------------ -- Get the number of arguments available. -- ------------------------------ overriding function Get_Count (List : in Default_Argument_List) return Natural is begin return Ada.Command_Line.Argument_Count - List.Offset; end Get_Count; -- ------------------------------ -- Get the argument at the given position. -- ------------------------------ overriding function Get_Argument (List : in Default_Argument_List; Pos : in Positive) return String is begin return Ada.Command_Line.Argument (Pos - List.Offset); end Get_Argument; end Util.Commands;
Implement the package to read the begin/end events and create the process instance
----------------------------------------------------------------------- -- mat-targets-readers - Definition and Analysis of process start events -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Log.Loggers; package body MAT.Targets.Readers is -- The logger Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("MAT.Targets.Readers"); MSG_BEGIN : constant MAT.Events.Internal_Reference := 0; MSG_END : constant MAT.Events.Internal_Reference := 1; M_PID : constant MAT.Events.Internal_Reference := 1; M_EXE : constant MAT.Events.Internal_Reference := 2; PID_NAME : aliased constant String := "pid"; EXE_NAME : aliased constant String := "exe"; Process_Attributes : aliased constant MAT.Events.Attribute_Table := (1 => (Name => PID_NAME'Access, Size => 0, Kind => MAT.Events.T_SIZE_T, Ref => M_PID), 2 => (Name => EXE_NAME'Access, Size => 0, Kind => MAT.Events.T_FRAME, Ref => M_EXE)); procedure Create_Process (For_Servant : in out Process_Servant; Pid : in MAT.Types.Target_Process_Ref) is begin MAT.Memory.Targets.Initialize (Memory => For_Servant.Process.Memory, Reader => For_Servant.Reader.all); end Create_Process; overriding procedure Dispatch (For_Servant : in out Process_Servant; Id : in MAT.Events.Internal_Reference; Params : in MAT.Events.Const_Attribute_Table_Access; Frame : in MAT.Events.Frame_Info; Msg : in out MAT.Readers.Message) is begin case Id is when MSG_BEGIN => null; when MSG_END => null; when others => null; end case; end Dispatch; -- Register the reader to extract and analyze process events. procedure Register (Into : in out MAT.Readers.Manager_Base'Class; Reader : in Process_Reader_Access) is begin Into.Register_Reader (Reader.all'Access, "begin", MSG_BEGIN, Process_Attributes'Access); Into.Register_Reader (Reader.all'Access, "end", MSG_END, Process_Attributes'Access); end Register; end MAT.Targets.Readers;
Add very simple examples for Objects
with Ada.Text_IO; with Ada.Command_Line; with Util.Beans.Objects; procedure ObjCalc is package UBO renames Util.Beans.Objects; use type UBO.Object; Value : UBO.Object := UBO.To_Object (Integer (0)); begin Value := Value + UBO.To_Object (Integer (123)); Value := Value - UBO.To_Object (String '("12")); -- Should print '111' Ada.Text_IO.Put_Line (UBO.To_String (Value)); end ObjCalc;
Implement a simple unit test for MAT.Targets package
----------------------------------------------------------------------- -- mat-readers-tests -- Unit tests for MAT readers -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; with Util.Test_Caller; with MAT.Readers.Files; package body MAT.Targets.Tests is use Util.Tests; package Caller is new Util.Test_Caller (Test, "Files"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test MAT.Targets.Read_File", Test_Read_File'Access); end Add_Tests; -- ------------------------------ -- Test reading a file into a string -- Reads this ada source file and checks we have read it correctly -- ------------------------------ procedure Test_Read_File (T : in out Test) is Path : constant String := Util.Tests.Get_Test_Path ("regtests/files/file-v1.dat"); Target : MAT.Targets.Target_Type; Reader : MAT.Readers.Files.File_Reader_Type; begin Target.Initialize (Reader); Reader.Open (Path); Reader.Read_All; end Test_Read_File; end MAT.Targets.Tests;
Add new unit tests for the timer management package
----------------------------------------------------------------------- -- util-events-timers-tests -- Unit tests for timers -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Util.Events.Timers.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test and Util.Events.Timers.Timer with record Count : Natural := 0; end record; overriding procedure Time_Handler (Sub : in out Test; Event : in out Timer_Ref'Class); procedure Test_Timer_Event (T : in out Test); end Util.Events.Timers.Tests;
Add the ASIS file $i
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A 4 G . A _ S T A N D -- -- -- -- S p e c -- -- -- -- $Revision: 15117 $ -- -- -- Copyright (c) 2002, Free Software Foundation, Inc. -- -- -- -- ASIS-for-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 -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY 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 ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 59 Temple Place -- -- - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by Ada Core Technologies Inc -- -- (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ -- We need this renaming because the GNAT Stand package and the ASIS A4G.Stand -- package conflict if mentioned in the same context clause. This renaming -- seems to be the cheapest way to correct the old bad choice of the name -- of the ASIS package (A4G.Stand) with A4G.Stand; package A4G.A_Stand renames A4G.Stand;
Implement the Initialize procedure with SSL support (AWS version starting from gnat-2015)
----------------------------------------------------------------------- -- awa-mail-clients-aws_smtp-initialize -- Initialize SMTP client with SSL support -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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. ----------------------------------------------------------------------- separate (AWA.Mail.Clients.AWS_SMTP) procedure Initialize (Client : in out AWS_Mail_Manager'Class; Props : in Util.Properties.Manager'Class) is Server : constant String := Props.Get (Name => "smtp.host", Default => "localhost"); User : constant String := Props.Get (Name => "smtp.user", Default => ""); Passwd : constant String := Props.Get (Name => "smtp.password", Default => ""); Secure : constant String := Props.Get (Name => "smtp.ssl", Default => "0"); begin Client.Secure := Secure = "1" or Secure = "yes" or Secure = "true"; if User'Length > 0 then Client.Creds := AWS.SMTP.Authentication.Plain.Initialize (User, Passwd); Client.Server := AWS.SMTP.Client.Initialize (Server_Name => Server, Port => Client.Port, Secure => Client.Secure, Credential => Client.Creds'Access); else Client.Server := AWS.SMTP.Client.Initialize (Server_Name => Server, Port => Client.Port, Secure => Client.Secure); end if; end Initialize;
Add the package to build the generated Ada packages (UML packages test)
----------------------------------------------------------------------- -- Test -- Test the code generation -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package Gen.Tests.Packages is end Gen.Tests.Packages;
Define the Facebook authentication by using OAuth and Facebook Graph API
----------------------------------------------------------------------- -- security-auth-oauth-facebook -- Facebook OAuth based authentication -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Security.OAuth.Clients; package Security.Auth.OAuth.Facebook is -- ------------------------------ -- OAuth Manager -- ------------------------------ -- The <b>Manager</b> provides the core operations for the OAuth authorization process. type Manager is new Security.Auth.OAuth.Manager with private; -- Verify the OAuth access token and retrieve information about the user. overriding procedure Verify_Access_Token (Realm : in Manager; Assoc : in Association; Request : in Parameters'Class; Token : in Security.OAuth.Clients.Access_Token_Access; Result : in out Authentication); private type Manager is new Security.Auth.OAuth.Manager with null record; end Security.Auth.OAuth.Facebook;
Add test for YAML model support
----------------------------------------------------------------------- -- gen-artifacts-yaml-tests -- Tests for YAML model files -- Copyright (C) 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Util.Test_Caller; with Gen.Configs; with Gen.Generator; package body Gen.Artifacts.Yaml.Tests is use Ada.Strings.Unbounded; package Caller is new Util.Test_Caller (Test, "Gen.Yaml"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Gen.Yaml.Read_Model", Test_Read_Yaml'Access); end Add_Tests; -- ------------------------------ -- Test reading the YAML files defines in regression tests. -- ------------------------------ procedure Test_Read_Yaml (T : in out Test) is A : Artifact; G : Gen.Generator.Handler; C : constant String := Util.Tests.Get_Parameter ("config_dir", "config"); Path : constant String := Util.Tests.Get_Path ("regtests/files/users.yaml"); Model : Gen.Model.Packages.Model_Definition; Iter : Gen.Model.Packages.Package_Cursor; Cnt : Natural := 0; begin Gen.Generator.Initialize (G, Ada.Strings.Unbounded.To_Unbounded_String (C), False); A.Read_Model (Path, Model, G); Iter := Model.First; while Gen.Model.Packages.Has_Element (Iter) loop Cnt := Cnt + 1; Gen.Model.Packages.Next (Iter); end loop; Util.Tests.Assert_Equals (T, 1, Cnt, "Missing some packages"); end Test_Read_Yaml; end Gen.Artifacts.Yaml.Tests;
Add simple example for text transformations
----------------------------------------------------------------------- -- escape -- Text Transformations -- Copyright (C) 2001, 2002, 2003, 2006, 2008, 2009, 2010 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Strings.Transforms; with Ada.Strings.Unbounded; with Ada.Text_IO; with Ada.Command_Line; procedure Escape is use Ada.Strings.Unbounded; Count : constant Natural := Ada.Command_Line.Argument_Count; begin if Count = 0 then Ada.Text_IO.Put_Line ("Usage: escape string..."); return; end if; for I in 1 .. Count loop declare S : constant String := Ada.Command_Line.Argument (I); begin Ada.Text_IO.Put_Line ("Escape javascript : " & Util.Strings.Transforms.Escape_Javascript (S)); Ada.Text_IO.Put_Line ("Escape XML : " & Util.Strings.Transforms.Escape_Xml (S)); end; end loop; end Escape;
Implement a new test to verify the Base64 encoding stream
----------------------------------------------------------------------- -- util-streams-buffered-encoders-tests -- Unit tests for encoding buffered streams -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Test_Caller; with Util.Streams.Files; with Util.Streams.Texts; with Util.Files; with Ada.Streams.Stream_IO; package body Util.Streams.Buffered.Encoders.Tests is use Util.Tests; use Util.Streams.Files; use Ada.Streams.Stream_IO; package Caller is new Util.Test_Caller (Test, "Streams.Buffered.Encoders"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Streams.Buffered.Encoders.Write, Read", Test_Base64_Stream'Access); end Add_Tests; procedure Test_Base64_Stream (T : in out Test) is Stream : aliased File_Stream; Buffer : aliased Util.Streams.Buffered.Encoders.Encoding_Stream; Print : Util.Streams.Texts.Print_Stream; Path : constant String := Util.Tests.Get_Test_Path ("regtests/result/test-stream.b64"); Expect : constant String := Util.Tests.Get_Path ("regtests/expect/test-stream.b64"); begin Print.Initialize (Output => Buffer'Unchecked_Access, Size => 5); Buffer.Initialize (Output => Stream'Unchecked_Access, Size => 1024, Format => Util.Encoders.BASE_64); Stream.Create (Mode => Out_File, Name => Path); for I in 1 .. 32 loop Print.Write ("abcd"); Print.Write (" fghij"); Print.Write (ASCII.LF); end loop; Print.Flush; Stream.Close; Util.Tests.Assert_Equal_Files (T => T, Expect => Expect, Test => Path, Message => "Base64 stream"); end Test_Base64_Stream; end Util.Streams.Buffered.Encoders.Tests;
Implement the operations for the SHA256 package
----------------------------------------------------------------------- -- util-encoders-sha256 -- Compute SHA-1 hash -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Encoders.Base64; package body Util.Encoders.SHA256 is -- ------------------------------ -- Computes the SHA256 hash and returns the raw binary hash in <b>Hash</b>. -- ------------------------------ procedure Finish (E : in out Context; Hash : out Hash_Array) is begin Hash := GNAT.SHA256.Digest (E); E := GNAT.SHA256.Initial_Context; end Finish; -- ------------------------------ -- Computes the SHA256 hash and returns the hexadecimal hash in <b>Hash</b>. -- ------------------------------ procedure Finish (E : in out Context; Hash : out Digest) is begin Hash := GNAT.SHA256.Digest (E); E := GNAT.SHA256.Initial_Context; end Finish; -- ------------------------------ -- Computes the SHA256 hash and returns the base64 hash in <b>Hash</b>. -- ------------------------------ procedure Finish_Base64 (E : in out Context; Hash : out Base64_Digest) is Buf : Ada.Streams.Stream_Element_Array (1 .. Hash'Length); for Buf'Address use Hash'Address; pragma Import (Ada, Buf); H : Hash_Array; B : Util.Encoders.Base64.Encoder; Last : Ada.Streams.Stream_Element_Offset; Encoded : Ada.Streams.Stream_Element_Offset; begin Finish (E, H); E := GNAT.SHA256.Initial_Context; B.Transform (Data => H, Into => Buf, Last => Last, Encoded => Encoded); end Finish_Base64; end Util.Encoders.SHA256;
Add missing ads file for package Orka.SIMD.AVX.Longs.Convert
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2021 onox <denkpadje@gmail.com> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Orka.SIMD.AVX.Doubles; package Orka.SIMD.AVX.Longs.Convert is pragma Pure; use SIMD.AVX.Doubles; function Convert (Elements : m256d) return m256l with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_cvtpd2dq256"; function Convert (Elements : m256l) return m256d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_cvtdq2pd256"; end Orka.SIMD.AVX.Longs.Convert;
Define the Cache_Control package with Cache_Control_Filter type to add a Cache-Control, Vary headers in the HTTP response
----------------------------------------------------------------------- -- asf-filters-cache_control -- HTTP response Cache-Control settings -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with ASF.Requests; with ASF.Responses; with ASF.Servlets; -- The <b>ASF.Filters.Cache_Control</b> package implements a servlet filter to add -- cache control headers in a response. -- package ASF.Filters.Cache_Control is -- Filter configuration parameter, when not empty, add a Vary header in the response. VARY_HEADER_PARAM : constant String := "header.vary"; -- Filter configuration parameter, defines the expiration date in seconds relative -- to the current date. When 0, disable browser caching. CACHE_CONTROL_PARAM : constant String := "header.cache-control"; type Cache_Control_Filter is new ASF.Filters.Filter with record Vary : Ada.Strings.Unbounded.Unbounded_String; Cache_Control_Header : Ada.Strings.Unbounded.Unbounded_String; end record; -- The Do_Filter method of the Filter is called by the container each time -- a request/response pair is passed through the chain due to a client request -- for a resource at the end of the chain. The <b>Cache_Control</b> filter adds -- a <tt>Cache-Control</tt>, <tt>Expires</tt>, <tt>Pragma</tt> and optionally a -- <tt>Vary</tt> header in the HTTP response. overriding procedure Do_Filter (F : in Cache_Control_Filter; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class; Chain : in out ASF.Servlets.Filter_Chain); -- Called by the servlet container to indicate to a filter that the filter -- instance is being placed into service. procedure Initialize (Server : in out Cache_Control_Filter; Config : in ASF.Servlets.Filter_Config); end ASF.Filters.Cache_Control;
Implement the Get_Value procedure for the Counter_Bean
----------------------------------------------------------------------- -- awa-counters-beans -- Counter bean definition -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body AWA.Counters.Beans is -- ------------------------------ -- Get the value identified by the name. -- ------------------------------ overriding function Get_Value (From : in Counter_Bean; Name : in String) return Util.Beans.Objects.Object is begin return Util.Beans.Objects.To_Object (From.Value); end Get_Value; end AWA.Counters.Beans;
Implement the Initialize procedure for AWS version before gnat-2015 (aws 3.1)
----------------------------------------------------------------------- -- awa-mail-clients-aws_smtp-initialize -- Initialize SMTP client without SSL support -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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. ----------------------------------------------------------------------- separate (AWA.Mail.Clients.AWS_SMTP) procedure Initialize (Client : in out AWS_Mail_Manager'Class; Props : in Util.Properties.Manager'Class) is Server : constant String := Props.Get (Name => "smtp.host", Default => "localhost"); User : constant String := Props.Get (Name => "smtp.user", Default => ""); Passwd : constant String := Props.Get (Name => "smtp.password", Default => ""); begin if User'Length > 0 then Client.Creds := AWS.SMTP.Authentication.Plain.Initialize (User, Passwd); Client.Server := AWS.SMTP.Client.Initialize (Server_Name => Server, Port => Client.Port, Credential => Client.Creds'Access); else Client.Server := AWS.SMTP.Client.Initialize (Server_Name => Server, Port => Client.Port); end if; end Initialize;
Add the ASIS file $i
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A 4 G . A _ S E M -- -- -- -- S p e c -- -- -- -- Copyright (C) 1995-2012, Free Software Foundation, Inc. -- -- -- -- ASIS-for-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 -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY 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 ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 59 Temple Place -- -- - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by Ada Core Technologies Inc -- -- (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ -- This package is the root of the ASIS-for-GNAT implementation hierarchy. -- All the implementation components, except Asis.Set_Get and -- Asis.Text.Set_Get (which need access to the private parts of the -- corresponding ASIS interface packages), are children or grandchildren of -- A4G. (A4G stands for Asis For GNAT). -- -- The primary aim of this package is to constrain the pollution of the user -- namespace when using the ASIS library to create ASIS applications, by -- children of A4G. package A4G is pragma Pure (A4G); end A4G;
Define the Facebook authentication by using OAuth and Facebook Graph API
----------------------------------------------------------------------- -- security-auth-oauth-facebook -- Facebook OAuth based authentication -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Security.OAuth.Clients; package Security.Auth.OAuth.Facebook is -- ------------------------------ -- OAuth Manager -- ------------------------------ -- The <b>Manager</b> provides the core operations for the OAuth authorization process. type Manager is new Security.Auth.OAuth.Manager with private; -- Verify the OAuth access token and retrieve information about the user. overriding procedure Verify_Access_Token (Realm : in Manager; Assoc : in Association; Request : in Parameters'Class; Token : in Security.OAuth.Clients.Access_Token_Access; Result : in out Authentication); private type Manager is new Security.Auth.OAuth.Manager with null record; end Security.Auth.OAuth.Facebook;
Implement the new unit tests for the timer management
----------------------------------------------------------------------- -- util-events-timers-tests -- Unit tests for timers -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with Util.Test_Caller; package body Util.Events.Timers.Tests is use Util.Tests; use type Ada.Real_Time.Time; package Caller is new Util.Test_Caller (Test, "Events.Timers"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Events.Channels.Post_Event", Test_Timer_Event'Access); end Add_Tests; overriding procedure Time_Handler (Sub : in out Test; Event : in out Timer_Ref'Class) is begin Sub.Count := Sub.Count + 1; end Time_Handler; procedure Test_Timer_Event (T : in out Test) is M : Timer_List; R : Timer_Ref; Start : Ada.Real_Time.Time := Ada.Real_Time.Clock; Deadline : Ada.Real_Time.Time; Now : Ada.Real_Time.Time; begin T.Assert (not R.Is_Scheduled, "Empty timer should not be scheduled"); for Retry in 1 .. 10 loop M.Set_Timer (T'Unchecked_Access, R, Start + Ada.Real_Time.Milliseconds (10)); M.Process (Deadline); Now := Ada.Real_Time.Clock; exit when Now < Deadline; end loop; T.Assert (Now < Deadline, "The timer deadline is not correct"); delay until Deadline; M.Process (Deadline); Assert_Equals (T, 1, T.Count, "The timer handler was not called"); end Test_Timer_Event; end Util.Events.Timers.Tests;
Declare the Conditions package with the Condition_Plugin type for the support of conditional inclusion in wiki text
----------------------------------------------------------------------- -- wiki-plugins-conditions -- Condition Plugin -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 Wiki.Strings; -- === Conditions Plugins === -- The <b>Wiki.Plugins.Conditions</b> package defines a set of conditional plugins -- to show or hide wiki content according to some conditions evaluated during the parsing phase. -- package Wiki.Plugins.Conditions is MAX_CONDITION_DEPTH : constant Natural := 31; type Condition_Depth is new Natural range 0 .. MAX_CONDITION_DEPTH; type Condition_Type is (CONDITION_IF, CONDITION_ELSIF, CONDITION_ELSE, CONDITION_END); type Condition_Plugin is new Wiki_Plugin with private; -- Evaluate the condition and return it as a boolean status. function Evaluate (Plugin : in Condition_Plugin; Params : in Wiki.Attributes.Attribute_List) return Boolean; -- Get the type of condition (IF, ELSE, ELSIF, END) represented by the plugin. function Get_Condition_Kind (Plugin : in Condition_Plugin; Params : in Wiki.Attributes.Attribute_List) return Condition_Type; -- Evaluate the condition described by the parameters and hide or show the wiki -- content. overriding procedure Expand (Plugin : in out Condition_Plugin; Document : in out Wiki.Documents.Document; Params : in out Wiki.Attributes.Attribute_List; Context : in Plugin_Context); -- Append the attribute name/value to the condition plugin parameter list. procedure Append (Plugin : in out Condition_Plugin; Name : in Wiki.Strings.WString; Value : in Wiki.Strings.WString); private type Boolean_Array is array (Condition_Depth) of Boolean; pragma Pack (Boolean_Array); type Condition_Plugin is new Wiki_Plugin with record Depth : Condition_Depth := 1; Values : Boolean_Array := (others => False); Params : Wiki.Attributes.Attribute_List; end record; end Wiki.Plugins.Conditions;
Implement the Get_Permission and Register operations
----------------------------------------------------------------------- -- asf-rest -- REST Support -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body ASF.Rest is -- ------------------------------ -- Get the permission index associated with the REST operation. -- ------------------------------ function Get_Permission (Handler : in Descriptor) return Security.Permissions.Permission_Index is begin return Handler.Permission; end Get_Permission; -- ------------------------------ -- Register the API descriptor in a list. -- ------------------------------ procedure Register (List : in out Descriptor_Access; Item : in Descriptor_Access) is begin Item.Next := Item; List := Item; end Register; end ASF.Rest;
Define some new tests for the database drivers support
----------------------------------------------------------------------- -- ado-drivers-tests -- Unit tests for database drivers -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package ADO.Drivers.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test the Get_Config operation. procedure Test_Get_Config (T : in out Test); -- Test the Get_Driver operation. procedure Test_Get_Driver (T : in out Test); -- Test loading some invalid database driver. procedure Test_Load_Invalid_Driver (T : in out Test); -- Test the Get_Driver_Index operation. procedure Test_Get_Driver_Index (T : in out Test); end ADO.Drivers.Tests;
Add the new tests for Headers package
----------------------------------------------------------------------- -- util-http-headers-tests - Unit tests for Headers -- Copyright (C) 2022 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Test_Caller; package body Util.Http.Headers.Tests is use Util.Tests; package Caller is new Util.Test_Caller (Test, "Headers"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Http.Headers.Get_Accepted", Test_Get_Accepted'Access); end Add_Tests; -- ------------------------------ -- Test the Get_Accepted function. -- ------------------------------ procedure Test_Get_Accepted (T : in out Test) is use type Mimes.Mime_Access; M : Mimes.Mime_Access; begin M := Get_Accepted ("image/gif", Mimes.Images); T.Assert (M /= null, "Null mime returned"); T.Assert_Equals (M.all, Mimes.Gif, "Bad accept"); M := Get_Accepted ("image/*", Mimes.Images); T.Assert (M /= null, "Null mime returned"); T.Assert_Equals (M.all, Mimes.Jpg, "Bad accept"); M := Get_Accepted ("image/* q=0.2, image/svg+xml", Mimes.Images); T.Assert (M /= null, "Null mime returned"); T.Assert_Equals (M.all, Mimes.Svg, "Bad accept"); M := Get_Accepted ("image/* q=0.2, image/svg+xml", Mimes.Api); T.Assert (M = null, "Should not match"); end Test_Get_Accepted; end Util.Http.Headers.Tests;
Define the store interface to support several storage services (file, database, Amazon)
----------------------------------------------------------------------- -- awa-storages-stores -- The storage interface -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 ADO.Sessions; with AWA.Storages.Models; package AWA.Storages.Stores is -- ------------------------------ -- Store Service -- ------------------------------ type Store is limited interface; type Store_Access is access all Store'Class; procedure Save (Storage : in Store; Into : in out AWA.Storages.Models.Storage_Ref'Class; Path : in String) is abstract; procedure Load (Storage : in Store; From : in AWA.Storages.Models.Storage_Ref'Class; Into : in String) is abstract; end AWA.Storages.Stores;
Add the ASIS file $i
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A 4 G . A _ S E M -- -- -- -- S p e c -- -- -- -- Copyright (C) 1995-2012, Free Software Foundation, Inc. -- -- -- -- ASIS-for-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 -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY 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 ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 59 Temple Place -- -- - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by Ada Core Technologies Inc -- -- (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ -- This package is the root of the ASIS-for-GNAT implementation hierarchy. -- All the implementation components, except Asis.Set_Get and -- Asis.Text.Set_Get (which need access to the private parts of the -- corresponding ASIS interface packages), are children or grandchildren of -- A4G. (A4G stands for Asis For GNAT). -- -- The primary aim of this package is to constrain the pollution of the user -- namespace when using the ASIS library to create ASIS applications, by -- children of A4G. package A4G is pragma Pure (A4G); end A4G;
Implement a test filter that counts the number of times it is traversed
----------------------------------------------------------------------- -- Filters Tests - Unit tests for ASF.Filters -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body ASF.Filters.Tests is -- ------------------------------ -- Increment the counter each time Do_Filter is called. -- ------------------------------ procedure Do_Filter (F : in Test_Filter; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class; Chain : in out ASF.Servlets.Filter_Chain) is begin F.Count.all := F.Count.all + 1; ASF.Servlets.Do_Filter (Chain => Chain, Request => Request, Response => Response); end Do_Filter; -- ------------------------------ -- Initialize the test filter. -- ------------------------------ overriding procedure Initialize (Server : in out Test_Filter; Context : in ASF.Servlets.Servlet_Registry'Class) is pragma Unreferenced (Context); begin Server.Count := Server.Counter'Unchecked_Access; end Initialize; end ASF.Filters.Tests;
Define the OAuth based authorization
----------------------------------------------------------------------- -- security-auth-oauth -- OAuth based authentication -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Security.OAuth.Clients; private package Security.Auth.OAuth is -- ------------------------------ -- OAuth Manager -- ------------------------------ -- The <b>Manager</b> provides the core operations for the OAuth authorization process. type Manager is abstract new Security.Auth.Manager with private; -- Initialize the authentication realm. overriding procedure Initialize (Realm : in out Manager; Params : in Parameters'Class; Provider : in String := PROVIDER_OPENID); -- Discover the OpenID provider that must be used to authenticate the user. -- The <b>Name</b> can be an URL or an alias that identifies the provider. -- A cached OpenID provider can be returned. -- Read the XRDS document from the URI and initialize the OpenID provider end point. -- (See OpenID Section 7.3 Discovery) overriding procedure Discover (Realm : in out Manager; Name : in String; Result : out End_Point); -- Associate the application (relying party) with the OpenID provider. -- The association can be cached. -- (See OpenID Section 8 Establishing Associations) overriding procedure Associate (Realm : in out Manager; OP : in End_Point; Result : out Association); overriding function Get_Authentication_URL (Realm : in Manager; OP : in End_Point; Assoc : in Association) return String; -- Verify the authentication result overriding procedure Verify (Realm : in out Manager; Assoc : in Association; Request : in Parameters'Class; Result : out Authentication); -- Verify the OAuth access token and retrieve information about the user. procedure Verify_Access_Token (Realm : in Manager; Assoc : in Association; Request : in Parameters'Class; Token : in Security.OAuth.Clients.Access_Token_Access; Result : in out Authentication) is abstract; private type Manager is abstract new Security.Auth.Manager with record Return_To : Unbounded_String; Realm : Unbounded_String; Scope : Unbounded_String; App : Security.OAuth.Clients.Application; end record; end Security.Auth.OAuth;
Define a method and binding for an Ada bean to receive an uploaded file
----------------------------------------------------------------------- -- asf-parts -- ASF Parts -- Copyright (C) 2011, 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 EL.Methods.Proc_In; package ASF.Parts.Upload_Method is new EL.Methods.Proc_In (Param1_Type => ASF.Parts.Part'Class);
Declare the Wiki.Streams.Html.Builders package for the HTML output stream
----------------------------------------------------------------------- -- wiki-streams-html-builders -- Wiki writer to a string builder -- Copyright (C) 2011, 2012, 2013, 2015, 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 Wiki.Streams.Builders; -- == Writer interfaces == -- The <tt>Wiki.Writers</tt> package defines the interfaces used by the renderer to write -- their outputs. -- package Wiki.Streams.Html.Builders is type Html_Output_Builder_Stream is limited new Wiki.Streams.Builders.Output_Builder_Stream and Wiki.Streams.Html.Html_Output_Stream with private; type Html_Output_Builder_Stream_Access is access all Html_Output_Builder_Stream'Class; overriding procedure Write_Wide_Element (Stream : in out Html_Output_Builder_Stream; Name : in String; Content : in Wiki.Strings.WString); overriding procedure Write_Wide_Attribute (Stream : in out Html_Output_Builder_Stream; Name : in String; Content : in Unbounded_Wide_Wide_String); -- Write an XML attribute within an XML element. -- The attribute value is escaped according to the XML escape rules. overriding procedure Write_Wide_Attribute (Stream : in out Html_Output_Builder_Stream; Name : in String; Content : in Wiki.Strings.WString); overriding procedure Start_Element (Stream : in out Html_Output_Builder_Stream; Name : in String); overriding procedure End_Element (Stream : in out Html_Output_Builder_Stream; Name : in String); overriding procedure Write_Wide_Text (Stream : in out Html_Output_Builder_Stream; Content : in Wiki.Strings.WString); private type Html_Output_Builder_Stream is limited new Wiki.Streams.Builders.Output_Builder_Stream and Wiki.Streams.Html.Html_Output_Stream with record -- Whether an XML element must be closed (that is a '>' is necessary) Close_Start : Boolean := False; end record; end Wiki.Streams.Html.Builders;
Declare the method binding types
----------------------------------------------------------------------- -- EL.Beans.Methods -- Bean methods -- Copyright (C) 2010 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Strings; package EL.Beans.Methods is pragma Preelaborate; type Method_Binding is tagged limited record Name : Util.Strings.Name_Access; end record; type Method_Binding_Access is access constant Method_Binding'Class; type Method_Binding_Array is array (Natural range <>) of Method_Binding_Access; type Method_Binding_Array_Access is access constant Method_Binding_Array; type Method_Bean is limited Interface; type Method_Bean_Access is access all Method_Bean'Class; function Get_Method_Bindings (From : in Method_Bean) return Method_Binding_Array_Access is abstract; end EL.Beans.Methods;
Implement To_Identifier and To_Object operations
----------------------------------------------------------------------- -- ado-utils -- Utility operations for ADO -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body ADO.Utils is -- ------------------------------ -- Build a bean object from the identifier. -- ------------------------------ function To_Object (Id : in ADO.Identifier) return Util.Beans.Objects.Object is begin if Id = ADO.NO_IDENTIFIER then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Long_Long_Integer (Id)); end if; end To_Object; -- ------------------------------ -- Build the identifier from the bean object. -- ------------------------------ function To_Identifier (Value : in Util.Beans.Objects.Object) return ADO.Identifier is begin if Util.Beans.Objects.Is_Null (Value) then return ADO.NO_IDENTIFIER; else return ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); end if; end To_Identifier; end ADO.Utils;
Declare the AWA.OAuth.Services package with the Auth_Manager
----------------------------------------------------------------------- -- awa-oauth-services -- OAuth Server Side -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Security.OAuth.Servers; package AWA.OAuth.Services is type Auth_Manager is new Security.OAuth.Servers.Auth_Manager with private; type Auth_Manager_Access is access all Auth_Manager'Class; private type Auth_Manager is new Security.OAuth.Servers.Auth_Manager with record N : Natural; end record; end AWA.OAuth.Services;
Implement the Initialize, Get and Get_Gateways operations
----------------------------------------------------------------------- -- druss-config -- Configuration management for Druss -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Environment_Variables; with Ada.Directories; with Util.Files; package body Druss.Config is Cfg : Util.Properties.Manager; -- ------------------------------ -- Initialize the configuration. -- ------------------------------ procedure Initialize is Home : constant String := Ada.Environment_Variables.Value ("HOME"); Path : constant String := Util.Files.Compose (Home, ".config/druss/druss.properties"); begin if Ada.Directories.Exists (Path) then Cfg.Load_Properties (Path); end if; end Initialize; -- ------------------------------ -- Get the configuration parameter. -- ------------------------------ function Get (Name : in String) return String is begin return Cfg.Get (Name); end Get; -- ------------------------------ -- Initalize the list of gateways from the configuration file. -- ------------------------------ procedure Get_Gateways (List : in out Druss.Gateways.Gateway_Vector) is begin Druss.Gateways.Initialize (Cfg, List); end Get_Gateways; end Druss.Config;
Add package AWA.Commands.Info to report configuration information
----------------------------------------------------------------------- -- akt-commands-info -- Info command to describe the current configuration -- Copyright (C) 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 GNAT.Command_Line; with AWA.Commands.Drivers; with AWA.Applications; with AWA.Modules; with ASF.Locales; generic with package Command_Drivers is new AWA.Commands.Drivers (<>); package AWA.Commands.Info is type Command_Type is new Command_Drivers.Application_Command_Type with record Bundle : ASF.Locales.Bundle; Long_List : aliased Boolean := False; Value_Length : Positive := 50; end record; -- Print the configuration about the application. overriding procedure Execute (Command : in out Command_Type; Application : in out AWA.Applications.Application'Class; Args : in Argument_List'Class; Context : in out Context_Type); -- Setup the command before parsing the arguments and executing it. overriding procedure Setup (Command : in out Command_Type; Config : in out GNAT.Command_Line.Command_Line_Configuration; Context : in out Context_Type); -- Write the help associated with the command. overriding procedure Help (Command : in out Command_Type; Name : in String; Context : in out Context_Type); -- Print the configuration identified by the given name. procedure Print (Command : in out Command_Type; Name : in String; Value : in String; Default : in String; Context : in out Context_Type); procedure Print (Command : in out Command_Type; Application : in out AWA.Applications.Application'Class; Name : in String; Default : in String; Context : in out Context_Type); procedure Print (Command : in out Command_Type; Module : in AWA.Modules.Module'Class; Name : in String; Default : in String; Context : in out Context_Type); Command : aliased Command_Type; end AWA.Commands.Info;
Implement the GNAT_Parser package to parse arguments using GNAT Getopt
----------------------------------------------------------------------- -- util-commands-parsers.gnat_parser -- GNAT command line parser for command drivers -- Copyright (C) 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 GNAT.OS_Lib; package body Util.Commands.Parsers.GNAT_Parser is function To_OS_Lib_Argument_List (Args : in Argument_List'Class) return GNAT.OS_Lib.Argument_List_Access; function To_OS_Lib_Argument_List (Args : in Argument_List'Class) return GNAT.OS_Lib.Argument_List_Access is Count : constant Natural := Args.Get_Count; New_Arg : GNAT.OS_Lib.Argument_List (1 .. Count); begin for I in 1 .. Count loop New_Arg (I) := new String '(Args.Get_Argument (I)); end loop; return new GNAT.OS_Lib.Argument_List '(New_Arg); end To_OS_Lib_Argument_List; procedure Execute (Config : in out Config_Type; Args : in Util.Commands.Argument_List'Class; Process : access procedure (Cmd_Args : in Commands.Argument_List'Class)) is Parser : GNAT.Command_Line.Opt_Parser; Cmd_Args : Dynamic_Argument_List; Params : GNAT.OS_Lib.Argument_List_Access := To_OS_Lib_Argument_List (Args); begin GNAT.Command_Line.Initialize_Option_Scan (Parser, Params); GNAT.Command_Line.Getopt (Config => Config, Parser => Parser); loop declare S : constant String := GNAT.Command_Line.Get_Argument (Parser => Parser); begin exit when S'Length = 0; Cmd_Args.List.Append (S); end; end loop; Process (Cmd_Args); GNAT.OS_Lib.Free (Params); exception when others => GNAT.OS_Lib.Free (Params); raise; end Execute; end Util.Commands.Parsers.GNAT_Parser;
Implement the unit test on datasets
----------------------------------------------------------------------- -- ado-datasets-tests -- Test executing queries and using datasets -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Test_Caller; with Util.Properties; with Regtests.Simple.Model; with ADO.Queries.Loaders; package body ADO.Datasets.Tests is package Caller is new Util.Test_Caller (Test, "ADO.Datasets"); package User_List_Query_File is new ADO.Queries.Loaders.File (Path => "regtests/files/user-list.xml", Sha1 => ""); package User_List_Query is new ADO.Queries.Loaders.Query (Name => "user-list", File => User_List_Query_File.File'Access); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test ADO.Datasets.List", Test_List'Access); end Add_Tests; procedure Test_List (T : in out Test) is DB : ADO.Sessions.Master_Session := Regtests.Get_Master_Database; Query : ADO.Queries.Context; Data : ADO.Datasets.Dataset; Props : constant Util.Properties.Manager := Util.Tests.Get_Properties; begin -- Configure the XML query loader. ADO.Queries.Loaders.Initialize (Props.Get ("ado.queries.paths", ".;db"), Props.Get ("ado.queries.load", "false") = "true"); for I in 1 .. 100 loop declare User : Regtests.Simple.Model.User_Ref; begin User.Set_Name ("John " & Integer'Image (I)); User.Set_Select_Name ("test-list"); User.Set_Value (ADO.Identifier (I)); User.Save (DB); end; end loop; DB.Commit; Query.Set_Query (User_List_Query.Query'Access); Query.Bind_Param ("filter", String '("test-list")); ADO.Datasets.List (Data, DB, Query); Util.Tests.Assert_Equals (T, 100, Data.Get_Count, "Invalid dataset size"); end Test_List; end ADO.Datasets.Tests;
Add a new set of unit tests for the date converter
----------------------------------------------------------------------- -- asf-converters-tests - Unit tests for ASF.Converters -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with ASF.Contexts.Faces.Tests; package ASF.Converters.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new ASF.Contexts.Faces.Tests.Test with null record; -- Test the date short converter. procedure Test_Date_Short_Converter (T : in out Test); -- Test the date medium converter. procedure Test_Date_Medium_Converter (T : in out Test); -- Test the date long converter. procedure Test_Date_Long_Converter (T : in out Test); -- Test the date full converter. procedure Test_Date_Full_Converter (T : in out Test); -- Test the time short converter. procedure Test_Time_Short_Converter (T : in out Test); -- Test the time short converter. procedure Test_Time_Medium_Converter (T : in out Test); -- Test the time long converter. procedure Test_Time_Long_Converter (T : in out Test); end ASF.Converters.Tests;
Implement the Frames_Types package to protect the frame creation in multi-threaded contexts
----------------------------------------------------------------------- -- mat-frames-targets - Representation of stack frames -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body MAT.Frames.Targets is -- ------------------------------ -- Insert in the frame tree the new stack frame represented by <tt>Pc</tt>. -- If the frame is already known, the frame reference counter is incremented. -- The frame represented by <tt>Pc</tt> is returned in <tt>Result</tt>. -- ------------------------------ procedure Insert (Frame : in out Target_Frames; Pc : in Frame_Table; Result : out Frame_Type) is begin Frame.Frames.Insert (Pc, Result); end Insert; protected body Frames_Type is -- ------------------------------ -- Insert in the frame tree the new stack frame represented by <tt>Pc</tt>. -- If the frame is already known, the frame reference counter is incremented. -- The frame represented by <tt>Pc</tt> is returned in <tt>Result</tt>. -- ------------------------------ procedure Insert (Pc : in Frame_Table; Result : out Frame_Type) is begin MAT.Frames.Insert (Root, Pc, Result); end Insert; -- ------------------------------ -- Clear and destroy all the frame instances. -- ------------------------------ procedure Clear is begin Destroy (Root); end Clear; end Frames_Type; -- ------------------------------ -- Release all the stack frames. -- ------------------------------ overriding procedure Finalize (Frames : in out Target_Frames) is begin Frames.Frames.Clear; end Finalize; end MAT.Frames.Targets;
Implement the operations for the <mail:attachment> component
----------------------------------------------------------------------- -- awa-mail-components-attachments -- Mail UI Attachments -- Copyright (C) 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Util.Beans.Objects; package body AWA.Mail.Components.Attachments is use Ada.Strings.Unbounded; -- ------------------------------ -- Render the mail subject and initializes the message with its content. -- ------------------------------ overriding procedure Encode_Children (UI : in UIMailAttachment; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is procedure Process (Content : in Unbounded_String); Content_Type : Util.Beans.Objects.Object; File_Name : Util.Beans.Objects.Object; Id : constant Unbounded_String := UI.Get_Client_Id; procedure Process (Content : in Unbounded_String) is Msg : constant AWA.Mail.Clients.Mail_Message_Access := UI.Get_Message; Typ : constant String := (if Util.Beans.Objects.Is_Empty (Content_Type) then "" else Util.Beans.Objects.To_String (Content_Type)); begin Msg.Add_Attachment (Content, To_String (Id), Typ); end Process; begin Content_Type := UI.Get_Attribute (Name => "contentType", Context => Context); File_Name := UI.Get_Attribute (Name => "fileName", Context => Context); UI.Wrap_Encode_Children (Context, Process'Access); end Encode_Children; end AWA.Mail.Components.Attachments;
Add navigation rule unit test
----------------------------------------------------------------------- -- asf-navigations-tests - Tests for ASF navigation -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package ASF.Navigations.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Initialize the test application overriding procedure Set_Up (T : in out Test); -- Test a form navigation with an exact match (view, outcome, action). procedure Test_Exact_Navigation (T : in out Test); -- Test a form navigation with a partial match (view, outcome). procedure Test_Partial_Navigation (T : in out Test); -- Test a form navigation with a exception match (view, outcome). procedure Test_Exception_Navigation (T : in out Test); -- Check the navigation for an URI and expect the result to match the regular expression. procedure Check_Navigation (T : in out Test; Name : in String; Match : in String; Raise_Flag : in Boolean := False); end ASF.Navigations.Tests;
Add a unit test for the babel stream compositions
----------------------------------------------------------------------- -- babel-streams-tests - Unit tests for babel streams -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Babel.Streams.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test the Find function resolving some existing user. procedure Test_Stream_Composition (T : in out Test); end Babel.Streams.Tests;
Add the package to build the generated Ada packages (UML packages test)
----------------------------------------------------------------------- -- Test -- Test the code generation -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package Gen.Tests.Packages is end Gen.Tests.Packages;
Define a vectors of objects
----------------------------------------------------------------------- -- Util.Beans.Objects.Vectors -- Object vectors -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Containers.Vectors; package Util.Beans.Objects.Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Object);
Add the ASIS file $i
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A 4 G . A _ S T A N D -- -- -- -- S p e c -- -- -- -- $Revision: 15117 $ -- -- -- Copyright (c) 2002, Free Software Foundation, Inc. -- -- -- -- ASIS-for-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 -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY 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 ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 59 Temple Place -- -- - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by Ada Core Technologies Inc -- -- (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ -- We need this renaming because the GNAT Stand package and the ASIS A4G.Stand -- package conflict if mentioned in the same context clause. This renaming -- seems to be the cheapest way to correct the old bad choice of the name -- of the ASIS package (A4G.Stand) with A4G.Stand; package A4G.A_Stand renames A4G.Stand;
Package ASF.Servlets.Files renames Servlet.Core.Files but make it obscolesent (provided as backward compatibility)
----------------------------------------------------------------------- -- asf-servlets-files -- Files servlet -- Copyright (C) 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 Servlet.Core.Files; package ASF.Servlets.Files renames Servlet.Core.Files; pragma Obsolescent ("use the 'Servlet.Core.Files' package");
Add unit tests for OAuth package and Create_Nonce operation
----------------------------------------------------------------------- -- Security-oauth-clients-tests - Unit tests for OAuth -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Test_Caller; with Util.Measures; with Util.Strings.Sets; package body Security.OAuth.Clients.Tests is package Caller is new Util.Test_Caller (Test, "Security.OAuth.Clients"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Security.OAuth.Clients.Create_Nonce", Test_Create_Nonce'Access); end Add_Tests; -- ------------------------------ -- Test Create_Nonce operation. -- ------------------------------ procedure Test_Create_Nonce (T : in out Test) is Nonces : Util.Strings.Sets.Set; begin for I in 1 .. 1_000 loop for I in 32 .. 734 loop declare S : constant String := Create_Nonce (I * 3); begin T.Assert (not Nonces.Contains (S), "Nonce was not unique: " & S); Nonces.Include (S); end; end loop; end loop; declare S : Util.Measures.Stamp; begin for I in 1 .. 1_000 loop declare Nonce : constant String := Create_Nonce (128); pragma Unreferenced (Nonce); begin null; end; end loop; Util.Measures.Report (S, "128 bits nonce generation (1000 calls)"); end; end Test_Create_Nonce; end Security.OAuth.Clients.Tests;
Define the OAuth based authorization
----------------------------------------------------------------------- -- security-auth-oauth -- OAuth based authentication -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Security.OAuth.Clients; private package Security.Auth.OAuth is -- ------------------------------ -- OAuth Manager -- ------------------------------ -- The <b>Manager</b> provides the core operations for the OAuth authorization process. type Manager is abstract new Security.Auth.Manager with private; -- Initialize the authentication realm. overriding procedure Initialize (Realm : in out Manager; Params : in Parameters'Class; Provider : in String := PROVIDER_OPENID); -- Discover the OpenID provider that must be used to authenticate the user. -- The <b>Name</b> can be an URL or an alias that identifies the provider. -- A cached OpenID provider can be returned. -- Read the XRDS document from the URI and initialize the OpenID provider end point. -- (See OpenID Section 7.3 Discovery) overriding procedure Discover (Realm : in out Manager; Name : in String; Result : out End_Point); -- Associate the application (relying party) with the OpenID provider. -- The association can be cached. -- (See OpenID Section 8 Establishing Associations) overriding procedure Associate (Realm : in out Manager; OP : in End_Point; Result : out Association); overriding function Get_Authentication_URL (Realm : in Manager; OP : in End_Point; Assoc : in Association) return String; -- Verify the authentication result overriding procedure Verify (Realm : in out Manager; Assoc : in Association; Request : in Parameters'Class; Result : out Authentication); -- Verify the OAuth access token and retrieve information about the user. procedure Verify_Access_Token (Realm : in Manager; Assoc : in Association; Request : in Parameters'Class; Token : in Security.OAuth.Clients.Access_Token_Access; Result : in out Authentication) is abstract; private type Manager is abstract new Security.Auth.Manager with record Return_To : Unbounded_String; Realm : Unbounded_String; Scope : Unbounded_String; App : Security.OAuth.Clients.Application; end record; end Security.Auth.OAuth;
Implement the Set_Buffer and Finalize procedures
----------------------------------------------------------------------- -- babel-Streams -- Stream management -- Copyright (C) 2014, 2015 Stephane.Carrez -- Written by Stephane.Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Babel.Streams is -- ------------------------------ -- Set the internal buffer that the stream can use. -- ------------------------------ procedure Set_Buffer (Stream : in out Stream_Type; Buffer : in Babel.Files.Buffers.Buffer_Access) is begin Stream.Buffer := Buffer; end Set_Buffer; -- ------------------------------ -- Release the stream buffer if there is one. -- ------------------------------ overriding procedure Finalize (Stream : in out Stream_Type) is use type Babel.Files.Buffers.Buffer_Access; begin if Stream.Buffer /= null then Babel.Files.Buffers.Release (Stream.Buffer); end if; end Finalize; end Babel.Streams;
Implement the Cache_Control_Filter to add a Cache-Control and Vary header in the HTTP response
----------------------------------------------------------------------- -- asf-filters-cache_control -- HTTP response Cache-Control settings -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body ASF.Filters.Cache_Control is -- ------------------------------ -- The Do_Filter method of the Filter is called by the container each time -- a request/response pair is passed through the chain due to a client request -- for a resource at the end of the chain. The <b>Cache_Control</b> filter adds -- a <tt>Cache-Control</tt>, <tt>Expires</tt>, <tt>Pragma</tt> and optionally a -- <tt>Vary</tt> header in the HTTP response. -- ------------------------------ overriding procedure Do_Filter (F : in Cache_Control_Filter; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class; Chain : in out ASF.Servlets.Filter_Chain) is use Ada.Strings.Unbounded; begin if Length (F.Cache_Control_Header) > 0 then Response.Add_Header ("Cache-Control", To_String (F.Cache_Control_Header)); end if; if Length (F.Vary) > 0 then Response.Add_Header ("Vary", To_String (F.Vary)); end if; ASF.Servlets.Do_Filter (Chain => Chain, Request => Request, Response => Response); end Do_Filter; -- ------------------------------ -- Called by the servlet container to indicate to a filter that the filter -- instance is being placed into service. -- ------------------------------ procedure Initialize (Server : in out Cache_Control_Filter; Config : in ASF.Servlets.Filter_Config) is begin Server.Vary := Servlets.Get_Init_Parameter (Config, VARY_HEADER_PARAM); Server.Cache_Control_Header := Servlets.Get_Init_Parameter (Config, CACHE_CONTROL_PARAM); end Initialize; end ASF.Filters.Cache_Control;
Add the ASIS file $i
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT INTERFACE COMPONENTS -- -- -- -- A S I S . E R R O R S -- -- -- -- S p e c -- -- -- -- $Revision: 14416 $ -- -- -- This specification is adapted from the Ada Semantic Interface -- -- Specification Standard (ISO/IEC 15291) for use with GNAT. In accordance -- -- with the copyright of that document, you can freely copy and modify this -- -- specification, provided that if you redistribute a modified version, any -- -- changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 4 package Asis.Errors ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ package Asis.Errors is ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- -- ASIS reports all operational errors by raising an exception. Whenever an -- ASIS implementation raises one of the exceptions declared in package -- Asis.Exceptions, it will previously have set the values returned by the -- Status and Diagnosis queries to indicate the cause of the error. The -- possible values for Status are indicated in the definition of Error_Kinds -- below, with suggestions for the associated contents of the Diagnosis -- string as a comment. -- -- The Diagnosis and Status queries are provided in the Asis.Implementation -- package to supply more information about the reasons for raising any -- exception. -- -- ASIS applications are encouraged to follow this same convention whenever -- they explicitly raise any ASIS exception--always record a Status and -- Diagnosis prior to raising the exception. ------------------------------------------------------------------------------ -- 4.1 type Error_Kinds ------------------------------------------------------------------------------ -- This enumeration type describes the various kinds of errors. -- type Error_Kinds is ( Not_An_Error, -- No error is presently recorded Value_Error, -- Routine argument value invalid Initialization_Error, -- ASIS is uninitialized Environment_Error, -- ASIS could not initialize Parameter_Error, -- Bad Parameter given to Initialize Capacity_Error, -- Implementation overloaded Name_Error, -- Context/unit not found Use_Error, -- Context/unit not use/open-able Data_Error, -- Context/unit bad/invalid/corrupt Text_Error, -- The program text cannot be located Storage_Error, -- Storage_Error suppressed Obsolete_Reference_Error, -- Argument or result is invalid due to -- and inconsistent compilation unit Unhandled_Exception_Error, -- Unexpected exception suppressed Not_Implemented_Error, -- Functionality not implemented Internal_Error); -- Implementation internal failure end Asis.Errors;
Declare the AWA.Images.Servlets package with the Image_Servlet type
----------------------------------------------------------------------- -- awa-images-servlets -- Serve images saved in the storage service -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Calendar; with ASF.Requests; with AWA.Storages.Servlets; with ADO; package AWA.Images.Servlets is -- The <b>Image_Servlet</b> represents the component that will handle -- an HTTP request received by the server. type Image_Servlet is new AWA.Storages.Servlets.Storage_Servlet with private; -- Load the data content that correspond to the GET request and get the name as well -- as mime-type and date. overriding procedure Load (Server : in Image_Servlet; Request : in out ASF.Requests.Request'Class; Name : out Ada.Strings.Unbounded.Unbounded_String; Mime : out Ada.Strings.Unbounded.Unbounded_String; Date : out Ada.Calendar.Time; Data : out ADO.Blob_Ref); private type Image_Servlet is new AWA.Storages.Servlets.Storage_Servlet with null record; end AWA.Images.Servlets;
Define ASF.Rest package for the server-side API REST support
----------------------------------------------------------------------- -- asf-rest -- REST Support -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Strings; with ASF.Requests; with ASF.Responses; with Security.Permissions; -- == REST == -- The <tt>ASF.Rest</tt> package provides support to implement easily some RESTful API. package ASF.Rest is type Request is abstract new ASF.Requests.Request with null record; type Response is abstract new ASF.Responses.Response with null record; -- The HTTP rest method. type Method_Type is (GET, HEAD, POST, PUT, DELETE, OPTIONS); type Descriptor is abstract tagged limited private; type Descriptor_Access is access all Descriptor'Class; -- Get the permission index associated with the REST operation. function Get_Permission (Handler : in Descriptor) return Security.Permissions.Permission_Index; -- Dispatch the request to the API handler. procedure Dispatch (Handler : in Descriptor; Req : in out ASF.Rest.Request'Class; Reply : in out ASF.Rest.Response'Class) is abstract; private type Descriptor is abstract tagged limited record Next : Descriptor_Access; Method : Method_Type; Pattern : Util.Strings.Name_Access; Permission : Security.Permissions.Permission_Index := 0; end record; -- Register the API descriptor in a list. procedure Register (List : in out Descriptor_Access; Item : in Descriptor_Access); end ASF.Rest;
Add unit tests for JWT
----------------------------------------------------------------------- -- Security-oayth-jwt-tests - Unit tests for JSON Web Token -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Security.OAuth.JWT.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test Decode operation with errors. procedure Test_Decode_Error (T : in out Test); generic with function Get (From : in Token) return String; Value : String; procedure Test_Operation (T : in out Test); generic with function Get (From : in Token) return Ada.Calendar.Time; Value : String; procedure Test_Time_Operation (T : in out Test); end Security.OAuth.JWT.Tests;
Package to implement the Load_Schema procedure
----------------------------------------------------------------------- -- ado-schemas-sqlite -- SQLite Database Schemas -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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 ADO.Drivers.Connections; package ADO.Schemas.Sqlite is -- Load the database schema procedure Load_Schema (C : in ADO.Drivers.Connections.Database_Connection'Class; Schema : out Schema_Definition); end ADO.Schemas.Sqlite;
Refactor Buffered_Stream and Print_Stream - move the TR package instantiation in a separate file
----------------------------------------------------------------------- -- util-streams-texts-tr -- Text translation utilities on streams -- Copyright (C) 2010, 2011, 2012, 2015, 2016, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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);
Implement operations to set the key and IV for AES-128/196/256 encryption and decryption streams
----------------------------------------------------------------------- -- util-streams-aes -- AES encoding and decoding streams -- Copyright (C) 2019 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Util.Streams.AES is -- ----------------------- -- Set the encryption key and mode to be used. -- ----------------------- procedure Set_Key (Stream : in out Encoding_Stream; Data : in Ada.Streams.Stream_Element_Array; Mode : in Util.Encoders.AES.AES_Mode := Util.Encoders.AES.CBC) is begin Stream.Transform.Set_Key (Data, Mode); end Set_Key; -- ----------------------- -- Set the encryption initialization vector before starting the encryption. -- ----------------------- procedure Set_IV (Stream : in out Encoding_Stream; IV : in Util.Encoders.AES.Word_Block_Type) is begin Stream.Transform.Set_IV (IV); end Set_IV; -- ----------------------- -- Set the encryption key and mode to be used. -- ----------------------- procedure Set_Key (Stream : in out Decoding_Stream; Data : in Ada.Streams.Stream_Element_Array; Mode : in Util.Encoders.AES.AES_Mode := Util.Encoders.AES.CBC) is begin Stream.Transform.Set_Key (Data, Mode); end Set_Key; -- ----------------------- -- Set the encryption initialization vector before starting the encryption. -- ----------------------- procedure Set_IV (Stream : in out Decoding_Stream; IV : in Util.Encoders.AES.Word_Block_Type) is begin Stream.Transform.Set_IV (IV); end Set_IV; end Util.Streams.AES;
Implement the Print_Field procedure for addresses
----------------------------------------------------------------------- -- mat-consoles - Console interface -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body MAT.Consoles is -- ------------------------------ -- Format the address and print it for the given field. -- ------------------------------ procedure Print_Field (Console : in out Console_Type; Field : in Field_Type; Addr : in MAT.Types.Target_Addr) is Value : constant String := MAT.Types.Hex_Image (Addr); begin Console_Type'Class (Console).Print_Field (Field, Value); end Print_Field; end MAT.Consoles;
Add Split_Header (moved from Ada Server Faces)
----------------------------------------------------------------------- -- util-http-headers -- HTTP Headers -- Copyright (C) 2022 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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.Fixed; with Util.Strings.Tokenizers; package body Util.Http.Headers is -- Split an accept like header into multiple tokens and a quality value. -- Invoke the `Process` procedure for each token. Example: -- -- Accept-Language: de, en;q=0.7, jp, fr;q=0.8, ru -- -- The `Process` will be called for "de", "en" with quality 0.7, -- and "jp", "fr" with quality 0.8 and then "ru" with quality 1.0. procedure Split_Header (Header : in String; Process : access procedure (Item : in String; Quality : in Quality_Type)) is use Util.Strings; procedure Process_Token (Token : in String; Done : out Boolean); Quality : Quality_Type := 1.0; procedure Process_Token (Token : in String; Done : out Boolean) is Name : constant String := Ada.Strings.Fixed.Trim (Token, Ada.Strings.Both); begin Process (Name, Quality); Done := False; end Process_Token; Q, N, Pos : Natural; Last : Natural := Header'First; begin while Last < Header'Last loop Quality := 1.0; Pos := Index (Header, ';', Last); if Pos > 0 then N := Index (Header, ',', Pos); if N = 0 then N := Header'Last + 1; end if; Q := Pos + 1; while Q < N loop if Header (Q .. Q + 1) = "q=" then begin Quality := Quality_Type'Value (Header (Q + 2 .. N - 1)); exception when others => null; end; exit; elsif Header (Q) /= ' ' then exit; end if; Q := Q + 1; end loop; Util.Strings.Tokenizers.Iterate_Tokens (Content => Header (Last .. Pos - 1), Pattern => ",", Process => Process_Token'Access); Last := N + 1; else Util.Strings.Tokenizers.Iterate_Tokens (Content => Header (Last .. Header'Last), Pattern => ",", Process => Process_Token'Access); return; end if; end loop; end Split_Header; end Util.Http.Headers;
Test handling of record fields with negative offsets.
-- RUN: %llvmgcc -c %s with System; procedure Negative_Field_Offset (N : Integer) is type String_Pointer is access String; -- Force use of a thin pointer. for String_Pointer'Size use System.Word_Size; P : String_Pointer; begin P := new String (1 .. N); end;
Test handling of ARRAY_REF when the component type is of unknown size.
-- RUN: %llvmgcc -c %s -o /dev/null procedure Array_Ref is type A is array (Natural range <>, Natural range <>) of Boolean; type A_Access is access A; function Get (X : A_Access) return Boolean is begin return X (0, 0); end; begin null; end;
Implement the implicit object 'requestScope'
----------------------------------------------------------------------- -- asf-beans-requests -- Bean giving access to the request object -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ASF.Contexts.Faces; with ASF.Requests; package body ASF.Beans.Requests is Bean : aliased Request_Bean; -- ------------------------------ -- Get from the request object the value identified by the given name. -- Returns Null_Object if the request does not define such name. -- ------------------------------ overriding function Get_Value (Bean : in Request_Bean; Name : in String) return Util.Beans.Objects.Object is pragma Unreferenced (Bean); use type ASF.Contexts.Faces.Faces_Context_Access; Ctx : constant ASF.Contexts.Faces.Faces_Context_Access := ASF.Contexts.Faces.Current; begin if Ctx = null then return Util.Beans.Objects.Null_Object; end if; declare Req : constant ASF.Requests.Request_Access := Ctx.Get_Request; begin return Req.Get_Attribute (Name); end; end Get_Value; -- ------------------------------ -- Return the Request_Bean instance. -- ------------------------------ function Instance return Util.Beans.Objects.Object is begin return Util.Beans.Objects.To_Object (Bean'Access, Util.Beans.Objects.STATIC); end Instance; end ASF.Beans.Requests;
Implement the Insert and Get_Event_Counter operations
----------------------------------------------------------------------- -- mat-events-targets - Events received and collected from a target -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body MAT.Events.Targets is -- ------------------------------ -- Add the event in the list of events and increment the event counter. -- ------------------------------ procedure Insert (Target : in out Target_Events; Event : in MAT.Types.Uint16; Frame : in MAT.Events.Frame_Info) is begin Target.Events.Insert (Event, Frame); Util.Concurrent.Counters.Increment (Target.Event_Count); end Insert; -- ------------------------------ -- Get the current event counter. -- ------------------------------ function Get_Event_Counter (Target : in Target_Events) return Integer is begin return Util.Concurrent.Counters.Value (Target.Event_Count); end Get_EVent_Counter; protected body Event_Collector is -- ------------------------------ -- Add the event in the list of events. -- ------------------------------ procedure Insert (Event : in MAT.Types.Uint16; Frame : in MAT.Events.Frame_Info) is begin null; end Insert; end Event_Collector; end MAT.Events.Targets;
Define a set of interface to send an email and have several possible implementations
----------------------------------------------------------------------- -- awa-mail-client -- Mail client interface -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- 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. ----------------------------------------------------------------------- -- The <b>AWA.Mail.Clients</b> package defines a mail client API used by the mail module. -- It defines two interfaces that must be implemented. This allows to have an implementation -- based on an external application such as <tt>sendmail</tt> and other implementation that -- use an SMTP connection. package AWA.Mail.Clients is type Recipient_Type is (TO, CC, BCC); -- ------------------------------ -- Mail Message -- ------------------------------ -- The <b>Mail_Message</b> represents an abstract mail message that can be initialized -- before being sent. type Mail_Message is limited interface; type Mail_Message_Access is access all Mail_Message'Class; -- Set the <tt>From</tt> part of the message. procedure Set_From (Message : in out Mail_Message; Name : in String; Address : in String) is abstract; -- Add a recipient for the message. procedure Add_Recipient (Message : in out Mail_Message; Kind : in Recipient_Type; Name : in String; Address : in String) is abstract; -- Set the subject of the message. procedure Set_Subject (Message : in out Mail_Message; Subject : in String) is abstract; -- Set the body of the message. procedure Set_Body (Message : in out Mail_Message; Content : in String) is abstract; -- Send the email message. procedure Send (Message : in out Mail_Message) is abstract; -- ------------------------------ -- Mail Manager -- ------------------------------ -- The <b>Mail_Manager</b> is the entry point to create a new mail message -- and be able to send it. type Mail_Manager is limited interface; type Mail_Manager_Access is access all Mail_Manager'Class; -- Create a new mail message. function Create_Message (Manager : in Mail_Manager) return Mail_Message_Access is abstract; end AWA.Mail.Clients;
Add unit test for Parse_Form procedure
----------------------------------------------------------------------- -- util-properties-form-tests -- Test reading form file into properties -- Copyright (C) 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Util.Properties.Form.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test loading a form file into a properties object. procedure Test_Parse_Form (T : in out Test); end Util.Properties.Form.Tests;
Add unit tests for local store and Read_File/Write_File operations
----------------------------------------------------------------------- -- babel-stores-local-tests - Unit tests for babel streams -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Babel.Stores.Local.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test the Read_File and Write_File operations. procedure Test_Read_File (T : in out Test); end Babel.Stores.Local.Tests;
Add blog servlets definition with Image_Servlet type
----------------------------------------------------------------------- -- awa-blogs-servlets -- Serve files saved in the storage service -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Calendar; with ADO; with ASF.Requests; with AWA.Storages.Servlets; package AWA.Blogs.Servlets is -- The <b>Storage_Servlet</b> represents the component that will handle -- an HTTP request received by the server. type Image_Servlet is new AWA.Storages.Servlets.Storage_Servlet with private; -- Load the data content that correspond to the GET request and get the name as well -- as mime-type and date. procedure Load (Server : in Image_Servlet; Request : in out ASF.Requests.Request'Class; Name : out Ada.Strings.Unbounded.Unbounded_String; Mime : out Ada.Strings.Unbounded.Unbounded_String; Date : out Ada.Calendar.Time; Data : out ADO.Blob_Ref); private type Image_Servlet is new AWA.Storages.Servlets.Storage_Servlet with null record; end AWA.Blogs.Servlets;
Define the factory for the creation of widget components
----------------------------------------------------------------------- -- widgets-factory -- Factory for widget Components -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ASF.Factory; package ASF.Components.Widgets.Factory is -- Get the widget component factory. function Definition return ASF.Factory.Factory_Bindings_Access; end ASF.Components.Widgets.Factory;
Move function-specific comment right before function
module Base.Change.Context {Type : Set} (ΔType : Type → Type) where -- Transform a context of values into a context of values and -- changes. open import Base.Syntax.Context Type ΔContext : Context → Context ΔContext ∅ = ∅ ΔContext (τ • Γ) = ΔType τ • τ • ΔContext Γ -- like ΔContext, but ΔType τ and τ are swapped ΔContext′ : Context → Context ΔContext′ ∅ = ∅ ΔContext′ (τ • Γ) = τ • ΔType τ • ΔContext′ Γ Γ≼ΔΓ : ∀ {Γ} → Γ ≼ ΔContext Γ Γ≼ΔΓ {∅} = ∅ Γ≼ΔΓ {τ • Γ} = drop ΔType τ • keep τ • Γ≼ΔΓ
module Base.Change.Context {Type : Set} (ΔType : Type → Type) where open import Base.Syntax.Context Type -- Transform a context of values into a context of values and -- changes. ΔContext : Context → Context ΔContext ∅ = ∅ ΔContext (τ • Γ) = ΔType τ • τ • ΔContext Γ -- like ΔContext, but ΔType τ and τ are swapped ΔContext′ : Context → Context ΔContext′ ∅ = ∅ ΔContext′ (τ • Γ) = τ • ΔType τ • ΔContext′ Γ Γ≼ΔΓ : ∀ {Γ} → Γ ≼ ΔContext Γ Γ≼ΔΓ {∅} = ∅ Γ≼ΔΓ {τ • Γ} = drop ΔType τ • keep τ • Γ≼ΔΓ
Add Any predicate for binary tree
{-# OPTIONS --without-K #-} open import Type hiding (★) module Data.Tree.Binary where data BinTree {a} (A : ★ a) : ★ a where empty : BinTree A leaf : A → BinTree A fork : (ℓ r : BinTree A) → BinTree A
{-# OPTIONS --without-K #-} open import Type hiding (★) open import Level open import Data.Zero open import Data.Sum module Data.Tree.Binary where data BinTree {a} (A : ★ a) : ★ a where empty : BinTree A leaf : A → BinTree A fork : (ℓ r : BinTree A) → BinTree A Any : ∀ {a p}{A : ★ a}(P : A → ★ p) → BinTree A → ★ p Any P empty = Lift 𝟘 Any P (leaf x) = P x Any P (fork ts ts₁) = Any P ts ⊎ Any P ts₁
Add alternative defintion for IND CPA
{-# OPTIONS --without-K #-} open import Type open import Data.Product open import Data.Bit module Game.IND-CPA-alt (PubKey : ★) (SecKey : ★) (Message : ★) (CipherText : ★) -- randomness supply for: encryption, key-generation, adversary, extensions (Rₑ Rₖ Rₐ : ★) (KeyGen : Rₖ → PubKey × SecKey) (Enc : PubKey → Message → Rₑ → CipherText) where M² = Bit → Message -- IND-CPA adversary in two parts Adv : ★ Adv = Rₐ → PubKey → (M² × (CipherText → Bit)) -- IND-CPA randomness supply R : ★ R = (Rₐ × Rₖ × Rₑ) -- IND-CPA games: -- * input: adversary and randomness supply -- * output b: adversary claims we are in game ⅁ b Game : ★ Game = Adv → R → Bit -- The game step by step: -- (pk) key-generation, only the public-key is needed -- (mb) send randomness, public-key and bit -- receive which message to encrypt -- (c) encrypt the message -- (b′) send randomness, public-key and ciphertext -- receive the guess from the adversary ⅁ : Bit → Game ⅁ b m (rₐ , rₖ , rₑ) = b′ where pk = proj₁ (KeyGen rₖ) ad = m rₐ pk mb = proj₁ ad b c = Enc pk mb rₑ b′ = proj₂ ad c ⅁₀ ⅁₁ : Game ⅁₀ = ⅁ 0b ⅁₁ = ⅁ 1b
Add incomplete note on co-inductive natural numbers.
------------------------------------------------------------------------------ -- Definition of FOTC Conat using Agda's co-inductive combinators ------------------------------------------------------------------------------ {-# OPTIONS --allow-unsolved-metas #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.Conat.ConatSL where open import FOTC.Base open import Coinduction ------------------------------------------------------------------------------ data Conat : D → Set where cozero : Conat zero cosucc : ∀ {n} → (∞ (Conat n)) → Conat (succ₁ n) Conat-unf : ∀ {n} → Conat n → n ≡ zero ∨ (∃[ n' ] Conat n' ∧ n ≡ succ₁ n') Conat-unf cozero = inj₁ refl Conat-unf (cosucc {n} Cn) = inj₂ (n , ♭ Cn , refl) Conat-pre-fixed : ∀ {n} → (n ≡ zero ∨ (∃[ n' ] Conat n' ∧ n ≡ succ₁ n')) → Conat n Conat-pre-fixed (inj₁ h) = subst Conat (sym h) cozero Conat-pre-fixed (inj₂ (n , Cn , h)) = subst Conat (sym h) (cosucc (♯ Cn)) Conat-coind : ∀ (A : D → Set) {n} → (A n → n ≡ zero ∨ (∃[ n' ] A n' ∧ n ≡ succ₁ n')) → A n → Conat n Conat-coind A h An = {!!}
Move function-specific comment right before function
module Base.Change.Context {Type : Set} (ΔType : Type → Type) where -- Transform a context of values into a context of values and -- changes. open import Base.Syntax.Context Type ΔContext : Context → Context ΔContext ∅ = ∅ ΔContext (τ • Γ) = ΔType τ • τ • ΔContext Γ -- like ΔContext, but ΔType τ and τ are swapped ΔContext′ : Context → Context ΔContext′ ∅ = ∅ ΔContext′ (τ • Γ) = τ • ΔType τ • ΔContext′ Γ Γ≼ΔΓ : ∀ {Γ} → Γ ≼ ΔContext Γ Γ≼ΔΓ {∅} = ∅ Γ≼ΔΓ {τ • Γ} = drop ΔType τ • keep τ • Γ≼ΔΓ
module Base.Change.Context {Type : Set} (ΔType : Type → Type) where open import Base.Syntax.Context Type -- Transform a context of values into a context of values and -- changes. ΔContext : Context → Context ΔContext ∅ = ∅ ΔContext (τ • Γ) = ΔType τ • τ • ΔContext Γ -- like ΔContext, but ΔType τ and τ are swapped ΔContext′ : Context → Context ΔContext′ ∅ = ∅ ΔContext′ (τ • Γ) = τ • ΔType τ • ΔContext′ Γ Γ≼ΔΓ : ∀ {Γ} → Γ ≼ ΔContext Γ Γ≼ΔΓ {∅} = ∅ Γ≼ΔΓ {τ • Γ} = drop ΔType τ • keep τ • Γ≼ΔΓ
Improve printing of resolved overloading.
module meaning where open import Level record Meaning (Syntax : Set) {ℓ : Level} : Set (suc ℓ) where constructor meaning field {Semantics} : Set ℓ ⟦_⟧ : Syntax → Semantics open Meaning {{...}} public
module meaning where open import Level record Meaning (Syntax : Set) {ℓ : Level} : Set (suc ℓ) where constructor meaning field {Semantics} : Set ℓ ⟨_⟩⟦_⟧ : Syntax → Semantics open Meaning {{...}} public renaming (⟨_⟩⟦_⟧ to ⟦_⟧) open Meaning public using (⟨_⟩⟦_⟧)
Add Any predicate for binary tree
{-# OPTIONS --without-K #-} open import Type hiding (★) module Data.Tree.Binary where data BinTree {a} (A : ★ a) : ★ a where empty : BinTree A leaf : A → BinTree A fork : (ℓ r : BinTree A) → BinTree A
{-# OPTIONS --without-K #-} open import Type hiding (★) open import Level open import Data.Zero open import Data.Sum module Data.Tree.Binary where data BinTree {a} (A : ★ a) : ★ a where empty : BinTree A leaf : A → BinTree A fork : (ℓ r : BinTree A) → BinTree A Any : ∀ {a p}{A : ★ a}(P : A → ★ p) → BinTree A → ★ p Any P empty = Lift 𝟘 Any P (leaf x) = P x Any P (fork ts ts₁) = Any P ts ⊎ Any P ts₁
Add alternative defintion for IND CPA
{-# OPTIONS --without-K #-} open import Type open import Data.Product open import Data.Bit module Game.IND-CPA-alt (PubKey : ★) (SecKey : ★) (Message : ★) (CipherText : ★) -- randomness supply for: encryption, key-generation, adversary, extensions (Rₑ Rₖ Rₐ : ★) (KeyGen : Rₖ → PubKey × SecKey) (Enc : PubKey → Message → Rₑ → CipherText) where M² = Bit → Message -- IND-CPA adversary in two parts Adv : ★ Adv = Rₐ → PubKey → (M² × (CipherText → Bit)) -- IND-CPA randomness supply R : ★ R = (Rₐ × Rₖ × Rₑ) -- IND-CPA games: -- * input: adversary and randomness supply -- * output b: adversary claims we are in game ⅁ b Game : ★ Game = Adv → R → Bit -- The game step by step: -- (pk) key-generation, only the public-key is needed -- (mb) send randomness, public-key and bit -- receive which message to encrypt -- (c) encrypt the message -- (b′) send randomness, public-key and ciphertext -- receive the guess from the adversary ⅁ : Bit → Game ⅁ b m (rₐ , rₖ , rₑ) = b′ where pk = proj₁ (KeyGen rₖ) ad = m rₐ pk mb = proj₁ ad b c = Enc pk mb rₑ b′ = proj₂ ad c ⅁₀ ⅁₁ : Game ⅁₀ = ⅁ 0b ⅁₁ = ⅁ 1b
Add incomplete note on co-inductive natural numbers.
------------------------------------------------------------------------------ -- Definition of FOTC Conat using Agda's co-inductive combinators ------------------------------------------------------------------------------ {-# OPTIONS --allow-unsolved-metas #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.Conat.ConatSL where open import FOTC.Base open import Coinduction ------------------------------------------------------------------------------ data Conat : D → Set where cozero : Conat zero cosucc : ∀ {n} → (∞ (Conat n)) → Conat (succ₁ n) Conat-unf : ∀ {n} → Conat n → n ≡ zero ∨ (∃[ n' ] Conat n' ∧ n ≡ succ₁ n') Conat-unf cozero = inj₁ refl Conat-unf (cosucc {n} Cn) = inj₂ (n , ♭ Cn , refl) Conat-pre-fixed : ∀ {n} → (n ≡ zero ∨ (∃[ n' ] Conat n' ∧ n ≡ succ₁ n')) → Conat n Conat-pre-fixed (inj₁ h) = subst Conat (sym h) cozero Conat-pre-fixed (inj₂ (n , Cn , h)) = subst Conat (sym h) (cosucc (♯ Cn)) Conat-coind : ∀ (A : D → Set) {n} → (A n → n ≡ zero ∨ (∃[ n' ] A n' ∧ n ≡ succ₁ n')) → A n → Conat n Conat-coind A h An = {!!}
Update grammar for our Workflow Catalog Query Language (WCQL)
grammar WorkflowCatalogQueryLanguage; @header { package org.ow2.proactive.workflow_catalog.rest.query; } clause: ATTRIBUTE OPERATOR VALUE ; clauses: clause ( CONJUNCTION clause )* ; statement: '(' clauses ')' | clauses ; ATTRIBUTE: ([a-z] | [A-Z])+ ([_.]+ ([a-z] | [A-Z] | [0-9])*)* ; CONJUNCTION: 'AND' | 'OR' ; OPERATOR: '!=' | '=' ; VALUE: '"' (~[\t\n])* '"' ; WHITESPACE: [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines
grammar WorkflowCatalogQueryLanguage; @header { package org.ow2.proactive.workflow_catalog.rest.query; } // PARSER expression : and_expression ; and_expression : or_expression (AND or_expression)* ; or_expression : clause (OR clause)* ; clause : (AttributeLiteral COMPARE_OPERATOR StringLiteral) | LPAREN and_expression RPAREN ; // LEXER AND : 'AND' | '&&' ; OR : 'OR' | '||' ; COMPARE_OPERATOR : '!=' | '=' ; LPAREN : '(' ; RPAREN : ')' ; StringLiteral : '"' (~["\\\r\n] | '\\' (. | EOF))* '"' ; AttributeLiteral : LETTER (LETTER | DIGIT | '_' | '.')* ; WS : [ \t\r\n]+ -> skip ; fragment DIGIT: [0-9]; fragment LETTER: LOWERCASE | UPPERCASE; fragment LOWERCASE: [a-z]; fragment UPPERCASE: [A-Z];
Make investment size spec optional
grammar InvestmentSize; import Tokens; @header { import com.github.robozonky.strategy.natural.*; } investmentSizeExpression returns [Collection<InvestmentSize> result]: { Collection<InvestmentSize> result = new LinkedHashSet<>(); } (i=investmentSizeRatingExpression { result.add($i.result); })+ { $result = result; } ; investmentSizeRatingExpression returns [InvestmentSize result] : 'Do úvěrů v ratingu ' r=ratingExpression ' investovat' i=investmentSizeRatingSubExpression { $result = new InvestmentSize($r.result, $i.result); } ;
grammar InvestmentSize; import Tokens; @header { import com.github.robozonky.strategy.natural.*; } investmentSizeExpression returns [Collection<InvestmentSize> result]: { Collection<InvestmentSize> result = new LinkedHashSet<>(); } (i=investmentSizeRatingExpression { result.add($i.result); })* { $result = result; } ; investmentSizeRatingExpression returns [InvestmentSize result] : 'Do úvěrů v ratingu ' r=ratingExpression ' investovat' i=investmentSizeRatingSubExpression { $result = new InvestmentSize($r.result, $i.result); } ;
Add joinExpression to the relationalExpression
grammar Relational; relationalExpression : unionExpression ; unionExpression : 'union' '(' datasetExpression (',' datasetExpression )* ')' ; datasetExpression : 'datasetExpr' NUM+; NUM : '0'..'9' ; WS : [ \t\n\t] -> skip ;
grammar Relational; relationalExpression : unionExpression | joinExpression ; unionExpression : 'union' '(' datasetExpression (',' datasetExpression )* ')' ; datasetExpression : 'datasetExpr' NUM+; joinExpression : '[' (INNER | OUTER | CROSS ) datasetExpression (',' datasetExpression )* ']' joinClause (',' joinClause)* ; joinClause : joinCalc | joinFilter | joinKeep | joinRename ; // | joinDrop // | joinUnfold // | joinFold ; joinCalc : 'TODO' ; joinFilter : 'TODO' ; joinKeep : 'TODO' ; joinRename : 'TODO' ; INNER : 'inner' ; OUTER : 'outer' ; CROSS : 'cross' ; NUM : '0'..'9' ; WS : [ \t\n\t] -> skip ;
Change antler grammar to support new type API
grammar Type; CT : [A-Z][a-z]+ ; VT : [a-z]+ ; WS : [ \t\r\n]+ -> skip ; type : functionType | compoundType; // function type functionType : compoundType ('->' type)+ ; compoundType : concreteType | tupleType | listType | parenType ; tupleType : '(' type (',' type)+ ')' ; // tuple type, k>=2 listType : '[' type ']' ; // list type parenType : '(' type ')' ; // parenthesised constructor concreteType : constantType | variableType ; constantType : CT ; variableType : VT ;
grammar Type; CT : [A-Z][a-z]+ ; VT : [a-z]+ ; WS : [ \t\r\n]+ -> skip ; type : functionType | compoundType ; // function type functionType : compoundType '->' type ; compoundType : constantType | variableType | tupleType | listType | parenType ; tupleType : '(' type (',' type)+ ')' ; // tuple type, k>=2 listType : '[' type ']' ; // list type parenType : '(' type ')' ; // type with parentheses constantType : CT ; variableType : VT ;
Allow numeric digits also in the identifier names.
grammar Expression; expression : sign = ('-' | '+') expression | subExpresion | left = expression op = POW right = expression | left = expression op = ( MULT | DIV ) right = expression | left = expression op = ( ADD | SUB ) right = expression | function | value = ( IDENT | CONST ) ; subExpresion : LPAREN expression RPAREN ; function : name = IDENT LPAREN paramFirst = expression ( ',' paramRest += expression )* RPAREN ; CONST : INTEGER | DECIMAL; INTEGER : [0-9]+; DECIMAL : [0-9]+'.'[0-9]+; IDENT : [_A-Za-z#][_.A-Za-z#]*; LPAREN : '('; RPAREN : ')'; MULT : '*'; DIV : '/'; ADD : '+'; SUB : '-'; POW : '^'; WS : [ \r\t\u000C\n]+ -> skip ;
grammar Expression; expression : sign = ('-' | '+') expression | subExpresion | left = expression op = POW right = expression | left = expression op = ( MULT | DIV ) right = expression | left = expression op = ( ADD | SUB ) right = expression | function | value = ( IDENT | CONST ) ; subExpresion : LPAREN expression RPAREN ; function : name = IDENT LPAREN paramFirst = expression ( ',' paramRest += expression )* RPAREN ; CONST : INTEGER | DECIMAL; INTEGER : [0-9]+; DECIMAL : [0-9]+'.'[0-9]+; IDENT : [_#A-Za-z][_#.A-Za-z0-9]*; LPAREN : '('; RPAREN : ')'; MULT : '*'; DIV : '/'; ADD : '+'; SUB : '-'; POW : '^'; WS : [ \r\t\u000C\n]+ -> skip ;
Add comment to the parser grammar
/*- * #%L * Java VTL * %% * Copyright (C) 2016 Hadrien Kohl * %% * 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. * #L% */ grammar VTL; import Atoms, Clauses, Conditional, Relational; start : statement+ EOF; /* Assignment */ statement : variableRef ':=' datasetExpression; exprMember : datasetExpression ('#' componentID)? ; /* Expressions */ datasetExpression : <assoc=right>datasetExpression clauseExpression #withClause | relationalExpression #withRelational | getExpression #withGet | putExpression #withPut | exprAtom #withAtom ; componentID : IDENTIFIER; getExpression : 'get' '(' datasetId ')'; putExpression : 'put(todo)'; datasetId : STRING_CONSTANT ; WS : [ \n\r\t\u000C] -> skip ;
/*- * #%L * Java VTL * %% * Copyright (C) 2016 Hadrien Kohl * %% * 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. * #L% */ grammar VTL; import Atoms, Clauses, Conditional, Relational; start : statement+ EOF; /* Assignment */ statement : variableRef ':=' datasetExpression; exprMember : datasetExpression ('#' componentID)? ; /* Expressions */ datasetExpression : <assoc=right>datasetExpression clauseExpression #withClause | relationalExpression #withRelational | getExpression #withGet | putExpression #withPut | exprAtom #withAtom ; componentID : IDENTIFIER; getExpression : 'get' '(' datasetId ')'; putExpression : 'put(todo)'; datasetId : STRING_CONSTANT ; WS : [ \n\r\t\u000C] -> skip ; COMMENT : '/*' .*? '*/' -> skip;
Fix issue with lexing type classes with an uppercase character after the first position
grammar Type; CT : [A-Z][a-z]+ ; VT : [a-z]+ ; WS : [ \t\r\n]+ -> skip ; type : typeClasses ? innerType ; innerType : functionType | compoundType ; // function type functionType : compoundType '->' innerType ; compoundType : constantType | variableType | tupleType | listType | parenType ; tupleType : '(' innerType (',' innerType)+ ')' ; // tuple type, k>=2 listType : '[' innerType ']' ; // list type parenType : '(' innerType ')' ; // type with parentheses constantType : typeConstructor (WS* innerType)* ; typeConstructor : CT ; variableType : VT ; typeClasses : '(' typeWithClass (',' typeWithClass)* ')' '=>' | typeWithClass '=>' ; typeWithClass : typeClass WS* classedType ; classedType : VT ; typeClass : CT ;
grammar Type; CT : [A-Z][A-Za-z]+ ; VT : [a-z]+ ; WS : [ \t\r\n]+ -> skip ; type : (typeClasses '=>')? innerType ; innerType : functionType | compoundType ; // function type functionType : compoundType '->' innerType ; compoundType : constantType | variableType | tupleType | listType | parenType ; tupleType : '(' innerType (',' innerType)+ ')' ; // tuple type, k>=2 listType : '[' innerType ']' ; // list type parenType : '(' innerType ')' ; // type with parentheses constantType : typeConstructor (innerType)* ; typeConstructor : CT ; variableType : VT ; typeClasses : '(' typeWithClass (',' typeWithClass)* ')' | typeWithClass ; typeWithClass : typeClass classedType ; classedType : VT ; typeClass : CT ;
Fix bug in Antlr grammar
grammar Type; CT : [A-Z][a-z]+ ; VT : [a-z]+ ; WS : [ \t\r\n]+ -> skip ; baseType : typeClasses ? type ; type : functionType | compoundType ; // function type functionType : compoundType '->' type ; compoundType : constantType | variableType | tupleType | listType | parenType ; tupleType : '(' type (',' type)+ ')' ; // tuple type, k>=2 listType : '[' type ']' ; // list type parenType : '(' type ')' ; // type with parentheses constantType : typeConstructor (WS* type)* ; typeConstructor : CT ; variableType : VT ; typeClasses : '(' typeWithClass (',' typeWithClass)* ')' '=>' ; typeWithClass : typeClass WS* classedType ; classedType : VT ; typeClass : CT ;
grammar Type; CT : [A-Z][a-z]+ ; VT : [a-z]+ ; WS : [ \t\r\n]+ -> skip ; type : typeClasses ? innerType ; innerType : functionType | compoundType ; // function type functionType : compoundType '->' innerType ; compoundType : constantType | variableType | tupleType | listType | parenType ; tupleType : '(' innerType (',' innerType)+ ')' ; // tuple type, k>=2 listType : '[' innerType ']' ; // list type parenType : '(' innerType ')' ; // type with parentheses constantType : typeConstructor (WS* innerType)* ; typeConstructor : CT ; variableType : VT ; typeClasses : '(' typeWithClass (',' typeWithClass)* ')' '=>' ; typeWithClass : typeClass WS* classedType ; classedType : VT ; typeClass : CT ;
Add comments to input grammar.
grammar PTP; @header { package pt.up.fe.iart.proj1.parser; } map : stmt+ ; stmt : node_stmt #node | edge_stmt #edge ; edge_stmt : 'Edge' '(' from=node_stmt ',' to=node_stmt ',' weight=(INT|REAL) ')'; node_stmt : 'GasStation' '(' position ')' #GasStation | 'GenericLocation' '(' position ')' #GenericLocation | 'PatientLocation' '(' position ')' #PatientLocation | 'Filiation' '(' position ',' bool ')' #Filiation ; position : '(' x=INT ',' y=INT ')' ; bool : 'true' | 'false' ; INT: [0-9]+ ; REAL: [0-9]+ '.' [0-9]* ; WS : [ \t\r\n]+ -> skip;
grammar PTP; @header { package pt.up.fe.iart.proj1.parser; } map : stmt+ ; stmt : node_stmt #node | edge_stmt #edge ; edge_stmt : 'Edge' '(' from=node_stmt ',' to=node_stmt ',' weight=(INT|REAL) ')'; node_stmt : 'GasStation' '(' position ')' #GasStation | 'GenericLocation' '(' position ')' #GenericLocation | 'PatientLocation' '(' position ')' #PatientLocation | 'Filiation' '(' position ',' bool ')' #Filiation ; position : '(' x=INT ',' y=INT ')' ; bool : 'true' | 'false' ; INT: [0-9]+ ; REAL: [0-9]+ '.' [0-9]* ; WS : [ \t\r\n]+ -> skip; COMMENT : '/*' .*? '*/' -> skip ; LINE_COMMENT : '//' .*? '\r'? '\n' -> skip ;
Add single type class notation to type parser
grammar Type; CT : [A-Z][a-z]+ ; VT : [a-z]+ ; WS : [ \t\r\n]+ -> skip ; type : typeClasses ? innerType ; innerType : functionType | compoundType ; // function type functionType : compoundType '->' innerType ; compoundType : constantType | variableType | tupleType | listType | parenType ; tupleType : '(' innerType (',' innerType)+ ')' ; // tuple type, k>=2 listType : '[' innerType ']' ; // list type parenType : '(' innerType ')' ; // type with parentheses constantType : typeConstructor (WS* innerType)* ; typeConstructor : CT ; variableType : VT ; typeClasses : '(' typeWithClass (',' typeWithClass)* ')' '=>' ; typeWithClass : typeClass WS* classedType ; classedType : VT ; typeClass : CT ;
grammar Type; CT : [A-Z][a-z]+ ; VT : [a-z]+ ; WS : [ \t\r\n]+ -> skip ; type : typeClasses ? innerType ; innerType : functionType | compoundType ; // function type functionType : compoundType '->' innerType ; compoundType : constantType | variableType | tupleType | listType | parenType ; tupleType : '(' innerType (',' innerType)+ ')' ; // tuple type, k>=2 listType : '[' innerType ']' ; // list type parenType : '(' innerType ')' ; // type with parentheses constantType : typeConstructor (WS* innerType)* ; typeConstructor : CT ; variableType : VT ; typeClasses : '(' typeWithClass (',' typeWithClass)* ')' '=>' | typeWithClass '=>' ; typeWithClass : typeClass WS* classedType ; classedType : VT ; typeClass : CT ;
Add first attempt at track grammar
grammar Track; track: track_decl decl* ; track_decl: 'track' '{' IDENT+ '}' ; decl: block_decl | channel_decl ; block_decl: IDENT '::' 'block' '{' block_body '}' ; block_body: (note)+ ; note: NOTENAME OCTAVE? LENGTH? ; channel_decl: IDENT '::' 'channel' WAVE '{' channel_body '}' ; channel_body: (block_name)+ ; block_name: IDENT ; NOTENAME: 'Ab' | 'A' | 'A#' | 'Bb' | 'B' | 'C' | 'C#' | 'Db' | 'D' | 'D#' | 'Eb' | 'E' | 'F' | 'F#' | 'Gb' | 'G' | 'G#' | 'R' ; OCTAVE: [0-9] | '10' ; LENGTH: [-+.]+ ; WAVE: 'triangle' | 'square' | 'sawtooth' | 'noise' ; IDENT: [a-zA-Z][a-zA-Z0-9_]+ ; WS: [\t\r\n ]+ -> skip ;
Add grammar in ANTLR 4 format
grammar Viper; tokens { NAME , NEWLINE , INDENT , DEDENT , NUMBER , STRING } func_def: 'def' func_name parameters '->' func_type ':' suite ; func_name: NAME ; func_type: type_expr ; parameters: '(' params_list? ')' ; params_list: argless_parameter parameter* ; parameter: arg_label? argless_parameter ; argless_parameter: param_name ':' param_type ; arg_label: NAME ; param_name: NAME ; param_type: type_expr ; type_expr: NAME ; suite: ( simple_stmt | NEWLINE INDENT stmt+ DEDENT ) ; stmt: ( simple_stmt | compound_stmt ) ; simple_stmt: expr_stmt NEWLINE ; expr_stmt: ( expr_list | 'pass' | 'return' expr_list? ) ; expr_list: expr (',' expr)* ; expr: atom_expr ; atom_expr: atom trailer* ; atom: ( '(' expr_list? ')' | NAME | NUMBER | STRING | '...' | 'Zilch' | 'True' | 'False' ) ; trailer: ( '(' arg_list? ')' | '.' NAME ) ; compound_stmt: ( func_def | object_def | data_def ) ; object_def: ( class_def | interface_def | implementation_def ) ; class_def: 'class' common_def ; interface_def: 'interface' common_def ; implementation_def: NAME common_def ; data_def: 'data' common_def ; common_def: NAME ('(' arg_list? ')')? ':' suite ; arg_list: argument (',' argument)* ; argument: expr ;
Remove .php extensions from url
server { server_name default; root /var/www/public; index main.php; client_max_body_size 100M; fastcgi_read_timeout 1800; location / { try_files $uri $uri/ /index.php$is_args$args; } location /status { access_log off; allow 172.17.0.0/16; deny all; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME /status; fastcgi_pass unix:/var/run/php5-fpm.sock; } location /ping { access_log off; allow all; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /ping; fastcgi_pass unix:/Var/run/php5-fpm.sock; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; access_log off; } location ~ \.php$ { try_files $uri =404; include fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/var/run/php5-fpm.sock; } }
server { server_name default; root /var/www/public; index main.php; client_max_body_size 100M; fastcgi_read_timeout 1800; location / { try_files $uri $uri.html $uri/ @extensionless-php; } location @extensionless-php { rewrite ^(.*)$ $1.php last; } location /status { access_log off; allow 172.17.0.0/16; deny all; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME /status; fastcgi_pass unix:/var/run/php5-fpm.sock; } location /ping { access_log off; allow all; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /ping; fastcgi_pass unix:/Var/run/php5-fpm.sock; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; access_log off; } location ~ \.php$ { try_files $uri =404; include fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/var/run/php5-fpm.sock; } }