doc_id
stringlengths 36
36
| metadata
dict | input
stringlengths 28
4.3k
| output
stringlengths 11
5.45k
|
---|---|---|---|
8dc224a4-3b81-4768-a5fd-bf2dbec9eb7f | {
"language": "Ada"
} | ```ada
-- Copyright 2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
name = "DuckDuckGo"
type = "scrape"
function start()
setratelimit(1)
end
function vertical(ctx, domain)
scrape(ctx, {['url']="https://html.duckduckgo.com/html/?q=site:" .. domain})
end
```
Exclude www from DuckDuckGo search result | ```ada
-- Copyright 2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
name = "DuckDuckGo"
type = "scrape"
function start()
setratelimit(1)
end
function vertical(ctx, domain)
scrape(ctx, {['url']=buildurl(domain)})
end
function buildurl(domain)
return "https://html.duckduckgo.com/html/?q=site:" .. domain .. " -site:www." .. domain
end
``` |
00a1268d-ca7d-4263-b8a0-b0c86582eabd | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-info -- Collect and give information about the project
-- Copyright (C) 2011, 2017, 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.
-----------------------------------------------------------------------
package Gen.Commands.Info is
-- ------------------------------
-- Project Information Command
-- ------------------------------
-- This command collects information about the project and print it.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Info;
```
Add Name parameter to the Help procedure | ```ada
-----------------------------------------------------------------------
-- gen-commands-info -- Collect and give information about the project
-- Copyright (C) 2011, 2017, 2018, 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 Gen.Commands.Info is
-- ------------------------------
-- Project Information Command
-- ------------------------------
-- This command collects information about the project and print it.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Name : in String;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Info;
``` |
25229d4b-7602-4d38-bdda-b891edaf5cc4 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-mail-module-tests -- Unit tests for Mail module
-- 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 Util.Tests;
with AWA.Tests;
package AWA.Mail.Modules.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new AWA.Tests.Test with null record;
-- Create an email message and verify its content.
procedure Test_Create_Message (T : in out Test);
end AWA.Mail.Modules.Tests;
```
Add new tests for mail Cc and Bcc | ```ada
-----------------------------------------------------------------------
-- awa-mail-module-tests -- Unit tests for Mail module
-- Copyright (C) 2012, 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 AWA.Tests;
package AWA.Mail.Modules.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new AWA.Tests.Test with null record;
-- Create an email message with the given template and verify its content.
procedure Test_Mail_Message (T : in out Test;
Name : in String);
-- Create an email message and verify its content.
procedure Test_Create_Message (T : in out Test);
-- Create an email message with Cc: and verify its content.
procedure Test_Cc_Message (T : in out Test);
-- Create an email message with Bcc: and verify its content.
procedure Test_Bcc_Message (T : in out Test);
end AWA.Mail.Modules.Tests;
``` |
3d5135e6-f653-4d24-8298-fc1dcf2adefa | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-counters-definition -- Counter 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.
-----------------------------------------------------------------------
-- The <tt>AWA.Counters.Definition</tt> package is instantiated for each counter definition.
generic
Table : ADO.Schemas.Class_Mapping_Access;
Field : String;
package AWA.Counters.Definition is
Def_Name : aliased constant String := Field;
-- Get the counter definition index.
function Index return Counter_Index_Type;
private
package Def is new Counter_Arrays.Definition (Counter_Def '(Table, Def_Name'Access));
-- Get the counter definition index.
function Index return Counter_Index_Type renames Def.Kind;
end AWA.Counters.Definition;
```
Change the Field parameter to be optional | ```ada
-----------------------------------------------------------------------
-- awa-counters-definition -- Counter 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.
-----------------------------------------------------------------------
-- The <tt>AWA.Counters.Definition</tt> package is instantiated for each counter definition.
generic
Table : ADO.Schemas.Class_Mapping_Access;
Field : String := "";
package AWA.Counters.Definition is
Def_Name : aliased constant String := Field;
-- Get the counter definition index.
function Index return Counter_Index_Type;
private
package Def is new Counter_Arrays.Definition (Counter_Def '(Table, Def_Name'Access));
-- Get the counter definition index.
function Index return Counter_Index_Type renames Def.Kind;
end AWA.Counters.Definition;
``` |
fe063295-ce23-48b1-b6f6-fc7ba9263702 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- mat-types -- Global types
-- 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.IO_Exceptions;
with MAT.Commands;
with MAT.Targets;
with MAT.Consoles.Text;
with MAT.Readers.Streams.Sockets;
procedure Matp is
Target : MAT.Targets.Target_Type;
Options : MAT.Commands.Options_Type;
Console : aliased MAT.Consoles.Text.Console_Type;
Server : MAT.Readers.Streams.Sockets.Socket_Listener_Type;
begin
Target.Console (Console'Unchecked_Access);
MAT.Commands.Initialize_Options (Target, Options);
Server.Start (Options.Address);
MAT.Commands.Interactive (Target);
Server.Stop;
exception
when Ada.IO_Exceptions.End_Error | MAT.Commands.Usage_Error =>
Server.Stop;
end Matp;
```
Load the MAT files passed in the command line argument | ```ada
-----------------------------------------------------------------------
-- mat-types -- Global types
-- 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.IO_Exceptions;
with MAT.Commands;
with MAT.Targets;
with MAT.Consoles.Text;
with MAT.Readers.Streams.Sockets;
procedure Matp is
Target : MAT.Targets.Target_Type;
Options : MAT.Commands.Options_Type;
Console : aliased MAT.Consoles.Text.Console_Type;
Server : MAT.Readers.Streams.Sockets.Socket_Listener_Type;
begin
Target.Console (Console'Unchecked_Access);
MAT.Commands.Initialize_Options (Target, Options);
MAT.Commands.Initialize_Files (Target);
Server.Start (Options.Address);
MAT.Commands.Interactive (Target);
Server.Stop;
exception
when Ada.IO_Exceptions.End_Error | MAT.Commands.Usage_Error =>
Server.Stop;
end Matp;
``` |
3f8f5e3c-5598-4a2c-8427-7f3726ced254 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- 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.
-----------------------------------------------------------------------
package Util.Commands is
-- The argument list interface that gives access to command arguments.
type Argument_List is limited interface;
-- Get the number of arguments available.
function Get_Count (List : in Argument_List) return Natural is abstract;
-- Get the argument at the given position.
function Get_Argument (List : in Argument_List;
Pos : in Positive) return String is abstract;
end Util.Commands;
```
Declare the Default_Argument_List and override the Get_Count and Get_Argument operations | ```ada
-----------------------------------------------------------------------
-- 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.
-----------------------------------------------------------------------
package Util.Commands is
-- The argument list interface that gives access to command arguments.
type Argument_List is limited interface;
-- Get the number of arguments available.
function Get_Count (List : in Argument_List) return Natural is abstract;
-- Get the argument at the given position.
function Get_Argument (List : in Argument_List;
Pos : in Positive) return String is abstract;
type Default_Argument_List (Offset : Natural) is new Argument_List with null record;
-- Get the number of arguments available.
overriding
function Get_Count (List : in Default_Argument_List) return Natural;
-- Get the argument at the given position.
overriding
function Get_Argument (List : in Default_Argument_List;
Pos : in Positive) return String;
end Util.Commands;
``` |
0faf527d-1705-46e8-aad3-a4ec0ad0d395 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- asf-lifecycles-default -- Default Lifecycle handler
-- 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.
-----------------------------------------------------------------------
package ASF.Lifecycles.Default is
type Lifecycle is new ASF.Lifecycles.Lifecycle with null record;
-- Creates the phase controllers by invoking the <b>Set_Controller</b>
-- procedure for each phase. This is called by <b>Initialize</b> to build
-- the lifecycle handler.
procedure Create_Phase_Controllers (Controller : in out Lifecycle);
-- Initialize the the lifecycle handler.
overriding
procedure Initialize (Controller : in out Lifecycle;
App : access ASF.Applications.Main.Application'Class);
end ASF.Lifecycles.Default;
```
Update Initialize to use a ASF.Applications.Views.View_Handler'Class | ```ada
-----------------------------------------------------------------------
-- asf-lifecycles-default -- Default Lifecycle handler
-- Copyright (C) 2010, 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.
-----------------------------------------------------------------------
package ASF.Lifecycles.Default is
type Lifecycle is new ASF.Lifecycles.Lifecycle with null record;
-- Creates the phase controllers by invoking the <b>Set_Controller</b>
-- procedure for each phase. This is called by <b>Initialize</b> to build
-- the lifecycle handler.
procedure Create_Phase_Controllers (Controller : in out Lifecycle);
-- Initialize the the lifecycle handler.
overriding
procedure Initialize (Controller : in out Lifecycle;
Views : access ASF.Applications.Views.View_Handler'Class);
end ASF.Lifecycles.Default;
``` |
01220960-f071-4900-8466-a74a38f3de5a | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- util-dates-tests - Test for dates
-- Copyright (C) 2018, 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.Dates.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test converting a date in ISO8601.
procedure Test_ISO8601_Image (T : in out Test);
-- Test converting a string in ISO8601 into a date.
procedure Test_ISO8601_Value (T : in out Test);
-- Test value convertion errors.
procedure Test_ISO8601_Error (T : in out Test);
end Util.Dates.Tests;
```
Add Test_Is_Same_Day to check the Is_Same_Day operation | ```ada
-----------------------------------------------------------------------
-- util-dates-tests - Test for dates
-- Copyright (C) 2018, 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.Dates.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test converting a date in ISO8601.
procedure Test_ISO8601_Image (T : in out Test);
-- Test converting a string in ISO8601 into a date.
procedure Test_ISO8601_Value (T : in out Test);
-- Test value convertion errors.
procedure Test_ISO8601_Error (T : in out Test);
-- Test Is_Same_Day operation.
procedure Test_Is_Same_Day (T : in out Test);
end Util.Dates.Tests;
``` |
fb9b16d8-0a2a-487c-b528-96884d5cbe57 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-project -- Project creation command for dynamo
-- 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.
-----------------------------------------------------------------------
package Gen.Commands.Project is
-- ------------------------------
-- Generator Command
-- ------------------------------
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
procedure Execute (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Project;
```
Update to use the new command implementation | ```ada
-----------------------------------------------------------------------
-- gen-commands-project -- Project creation command for dynamo
-- Copyright (C) 2011, 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 Gen.Commands.Project is
-- ------------------------------
-- Generator Command
-- ------------------------------
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Project;
``` |
2fba86d4-ada1-42c0-b2e5-39a83fcddee3 | {
"language": "Ada"
} | ```ada
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
package Definitions is
pragma Pure;
synth_version_major : constant String := "1";
synth_version_minor : constant String := "02";
copyright_years : constant String := "2015-2016";
host_localbase : constant String := "/usr/local";
host_pkg8 : constant String := host_localbase & "/sbin/pkg";
jobs_per_cpu : constant := 2;
type cpu_range is range 1 .. 32;
type scanners is range cpu_range'First .. cpu_range'Last;
type builders is range cpu_range'First .. cpu_range'Last * jobs_per_cpu;
end Definitions;
```
Bump to version 1.03 (term/dtrace fixes self-confirmed) | ```ada
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
package Definitions is
pragma Pure;
synth_version_major : constant String := "1";
synth_version_minor : constant String := "03";
copyright_years : constant String := "2015-2016";
host_localbase : constant String := "/usr/local";
host_pkg8 : constant String := host_localbase & "/sbin/pkg";
jobs_per_cpu : constant := 2;
type cpu_range is range 1 .. 32;
type scanners is range cpu_range'First .. cpu_range'Last;
type builders is range cpu_range'First .. cpu_range'Last * jobs_per_cpu;
end Definitions;
``` |
bcd66fd0-acd7-40d5-96a7-04e75f9cd59f | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- Security testsuite - Ada Security Test suite
-- 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 Security.OpenID.Tests;
with Security.Permissions.Tests;
with Security.Policies.Tests;
package body Security.Testsuite is
Tests : aliased Util.Tests.Test_Suite;
function Suite return Util.Tests.Access_Test_Suite is
Ret : constant Util.Tests.Access_Test_Suite := Tests'Access;
begin
Security.OpenID.Tests.Add_Tests (Ret);
Security.Permissions.Tests.Add_Tests (Ret);
Security.Policies.Tests.Add_Tests (Ret);
return Ret;
end Suite;
end Security.Testsuite;
```
Add the new unit tests | ```ada
-----------------------------------------------------------------------
-- Security testsuite - Ada Security Test suite
-- Copyright (C) 2011, 2012, 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.OpenID.Tests;
with Security.Permissions.Tests;
with Security.Policies.Tests;
with Security.OAuth.JWT.Tests;
package body Security.Testsuite is
Tests : aliased Util.Tests.Test_Suite;
function Suite return Util.Tests.Access_Test_Suite is
Ret : constant Util.Tests.Access_Test_Suite := Tests'Access;
begin
Security.OAuth.JWT.Tests.Add_Tests (Ret);
Security.OpenID.Tests.Add_Tests (Ret);
Security.Permissions.Tests.Add_Tests (Ret);
Security.Policies.Tests.Add_Tests (Ret);
return Ret;
end Suite;
end Security.Testsuite;
``` |
fe5986c8-b8a6-4cfe-80a6-9e6b748bb67e | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-tags -- Tags management
-- 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The <b>Tags</b> module allows to associate general purpose tags to any database entity.
--
-- == Model ==
-- [http://ada-awa.googlecode.com/svn/wiki/awa_tags_model.png]
--
-- @include awa-tags-modules.ads
package AWA.Tags is
pragma Pure;
end AWA.Tags;
```
Document the Tags plugin in AWA | ```ada
-----------------------------------------------------------------------
-- awa-tags -- Tags management
-- 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The <b>Tags</b> module allows to associate general purpose tags to any database entity.
-- It provides a JSF component that allows to insert easily a list of tags in a page and
-- in a form. An application can use the bean types defined in <tt>AWA.Tags.Beans</tt>
-- to define the tags and it will use the <tt>awa:tagList</tt> component to display them.
--
-- == Model ==
-- [http://ada-awa.googlecode.com/svn/wiki/awa_tags_model.png]
--
-- @include awa-tags-modules.ads
-- @include awa-tags-beans.ads
-- @include awa-tags-components.ads
--
package AWA.Tags is
pragma Pure;
end AWA.Tags;
``` |
20877cc4-d83d-4936-96ec-0766add3d6ca | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- asf-requests-tests - Unit tests for requests
-- 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 Util.Tests;
package ASF.Requests.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test the Split_Header procedure.
procedure Test_Split_Header (T : in out Test);
-- Test the Accept_Locales procedure.
procedure Test_Accept_Locales (T : in out Test);
end ASF.Requests.Tests;
```
Declare the Test_Set_Attribute procedure to check the Set/Get/Remove attribute | ```ada
-----------------------------------------------------------------------
-- asf-requests-tests - Unit tests for requests
-- Copyright (C) 2012, 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 ASF.Requests.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test the Split_Header procedure.
procedure Test_Split_Header (T : in out Test);
-- Test the Accept_Locales procedure.
procedure Test_Accept_Locales (T : in out Test);
-- Test the Set_Attribute procedure.
procedure Test_Set_Attribute (T : in out Test);
end ASF.Requests.Tests;
``` |
4a21b23e-3c24-4a52-b84d-bea90cef941b | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- util-processes-tools -- System specific and low level operations
-- 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.Strings.Vectors;
package Util.Processes.Tools is
-- Execute the command and append the output in the vector array.
-- The program output is read line by line and the standard input is closed.
-- Return the program exit status.
procedure Execute (Command : in String;
Output : in out Util.Strings.Vectors.Vector;
Status : out Integer);
end Util.Processes.Tools;
```
Declare more Execute procedures as helper to launch a command and get the output | ```ada
-----------------------------------------------------------------------
-- util-processes-tools -- System specific and low level operations
-- 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.Strings.Vectors;
with Util.Streams.Pipes;
package Util.Processes.Tools is
-- Execute the command and append the output in the vector array.
-- The program output is read line by line and the standard input is closed.
-- Return the program exit status.
procedure Execute (Command : in String;
Output : in out Util.Strings.Vectors.Vector;
Status : out Integer);
procedure Execute (Command : in String;
Input_Path : in String;
Output : in out Util.Strings.Vectors.Vector;
Status : out Integer);
procedure Execute (Command : in String;
Process : in out Util.Streams.Pipes.Pipe_Stream;
Output : in out Util.Strings.Vectors.Vector;
Status : out Integer);
end Util.Processes.Tools;
``` |
9a1bfa50-db67-4992-b27e-44408ed4cefb | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-blogs-tests -- Unit tests for blogs module
-- 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 Util.Tests;
package AWA.Blogs.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test creation of blog by simulating web requests.
procedure Test_Create_Blog (T : in out Test);
end AWA.Blogs.Tests;
```
Declare two new unit tests Test_Update_Post and Test_Anonymous_Access | ```ada
-----------------------------------------------------------------------
-- awa-blogs-tests -- Unit tests for blogs module
-- 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 Ada.Strings.Unbounded;
package AWA.Blogs.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with record
Blog_Ident : Ada.Strings.Unbounded.Unbounded_String;
Post_Ident : Ada.Strings.Unbounded.Unbounded_String;
Post_Uri : Ada.Strings.Unbounded.Unbounded_String;
end record;
-- Get some access on the blog as anonymous users.
procedure Verify_Anonymous (T : in out Test;
Post : in String);
-- Test access to the blog as anonymous user.
procedure Test_Anonymous_Access (T : in out Test);
-- Test creation of blog by simulating web requests.
procedure Test_Create_Blog (T : in out Test);
-- Test updating a post by simulating web requests.
procedure Test_Update_Post (T : in out Test);
end AWA.Blogs.Tests;
``` |
66c175db-1425-4994-8b73-06c55a2818d7 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- ado-mysql -- Database Drivers
-- 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.
-----------------------------------------------------------------------
with ADO.Configs;
with ADO.Connections.Mysql;
package body ADO.Mysql is
-- ------------------------------
-- Initialize the drivers and the library by reading the property file
-- and configure the runtime with it.
-- ------------------------------
procedure Initialize (Config : in String) is
begin
ADO.Configs.Initialize (Config);
ADO.Connections.Mysql.Initialize;
end Initialize;
-- ------------------------------
-- Initialize the drivers and the library and configure the runtime with the given properties.
-- ------------------------------
procedure Initialize (Config : in Util.Properties.Manager'Class) is
begin
ADO.Configs.Initialize (Config);
ADO.Connections.Mysql.Initialize;
end Initialize;
end ADO.Mysql;
```
Implement the Initialize procedure and use it | ```ada
-----------------------------------------------------------------------
-- ado-mysql -- Database Drivers
-- 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.
-----------------------------------------------------------------------
with ADO.Configs;
with ADO.Connections.Mysql;
package body ADO.Mysql is
-- ------------------------------
-- Initialize the Mysql driver.
-- ------------------------------
procedure Initialize is
begin
ADO.Connections.Mysql.Initialize;
end Initialize;
-- ------------------------------
-- Initialize the drivers and the library by reading the property file
-- and configure the runtime with it.
-- ------------------------------
procedure Initialize (Config : in String) is
begin
ADO.Configs.Initialize (Config);
Initialize;
end Initialize;
-- ------------------------------
-- Initialize the drivers and the library and configure the runtime with the given properties.
-- ------------------------------
procedure Initialize (Config : in Util.Properties.Manager'Class) is
begin
ADO.Configs.Initialize (Config);
Initialize;
end Initialize;
end ADO.Mysql;
``` |
f96bd243-ff7c-45f6-bbe0-d613728fd438 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- AWA - Unit tests
-- Copyright (C) 2009, 2010, 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 AWA.Testsuite;
with Util.Tests;
with AWA.Tests;
procedure AWA_Harness is
procedure Harness is new Util.Tests.Harness (AWA.Testsuite.Suite,
AWA.Tests.Initialize);
begin
Harness ("awa-tests.xml");
end AWA_Harness;
```
Call the Finish procedure after executing the testsuite Finish will destroy the AWA application that was allocated dynamically | ```ada
-----------------------------------------------------------------------
-- AWA - Unit tests
-- Copyright (C) 2009, 2010, 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 AWA.Testsuite;
with Util.Tests;
with AWA.Tests;
procedure AWA_Harness is
procedure Harness is new Util.Tests.Harness (AWA.Testsuite.Suite,
AWA.Tests.Initialize,
AWA.Tests.Finish);
begin
Harness ("awa-tests.xml");
end AWA_Harness;
``` |
840a6a71-5885-4916-81e0-8865402b43e7 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- Security testsuite - Ada Security Test suite
-- 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 Security.OpenID.Tests;
with Security.Permissions.Tests;
with Security.Policies.Tests;
package body Security.Testsuite is
Tests : aliased Util.Tests.Test_Suite;
function Suite return Util.Tests.Access_Test_Suite is
Ret : constant Util.Tests.Access_Test_Suite := Tests'Access;
begin
Security.OpenID.Tests.Add_Tests (Ret);
Security.Permissions.Tests.Add_Tests (Ret);
Security.Policies.Tests.Add_Tests (Ret);
return Ret;
end Suite;
end Security.Testsuite;
```
Add the new unit tests | ```ada
-----------------------------------------------------------------------
-- Security testsuite - Ada Security Test suite
-- Copyright (C) 2011, 2012, 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.OpenID.Tests;
with Security.Permissions.Tests;
with Security.Policies.Tests;
with Security.OAuth.JWT.Tests;
package body Security.Testsuite is
Tests : aliased Util.Tests.Test_Suite;
function Suite return Util.Tests.Access_Test_Suite is
Ret : constant Util.Tests.Access_Test_Suite := Tests'Access;
begin
Security.OAuth.JWT.Tests.Add_Tests (Ret);
Security.OpenID.Tests.Add_Tests (Ret);
Security.Permissions.Tests.Add_Tests (Ret);
Security.Policies.Tests.Add_Tests (Ret);
return Ret;
end Suite;
end Security.Testsuite;
``` |
2a5a42f5-f29d-44a0-b02f-694650b658a4 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- mat-formats - Format various types for the console or GUI interface
-- 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 MAT.Types;
package MAT.Formats is
-- Format the address into a string.
function Addr (Value : in MAT.Types.Target_Addr) return String;
-- Format the size into a string.
function Size (Value : in MAT.Types.Target_Size) return String;
-- Format a file, line, function information into a string.
function Location (File : in Ada.Strings.Unbounded.Unbounded_String;
Line : in Natural;
Func : in Ada.Strings.Unbounded.Unbounded_String) return String;
end MAT.Formats;
```
Declare the Event function to format an event in a printable short description | ```ada
-----------------------------------------------------------------------
-- mat-formats - Format various types for the console or GUI interface
-- 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 MAT.Types;
with MAT.Events.Targets;
package MAT.Formats is
-- Format the address into a string.
function Addr (Value : in MAT.Types.Target_Addr) return String;
-- Format the size into a string.
function Size (Value : in MAT.Types.Target_Size) return String;
-- Format a file, line, function information into a string.
function Location (File : in Ada.Strings.Unbounded.Unbounded_String;
Line : in Natural;
Func : in Ada.Strings.Unbounded.Unbounded_String) return String;
-- Format a short description of the event.
function Event (Item : in MAT.Events.Targets.Probe_Event_Type;
Related : in MAT.Events.Targets.Target_Event_Vector) return String;
end MAT.Formats;
``` |
0d88bf8e-8dc2-4bf7-81dd-b7e9b823248f | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-distrib -- Distrib command for dynamo
-- 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.Commands.Distrib is
-- ------------------------------
-- Distrib Command
-- ------------------------------
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
procedure Execute (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Distrib;
```
Update to use the new command implementation | ```ada
-----------------------------------------------------------------------
-- gen-commands-distrib -- Distrib command for dynamo
-- Copyright (C) 2012, 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 Gen.Commands.Distrib is
-- ------------------------------
-- Distrib Command
-- ------------------------------
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Distrib;
``` |
934496c7-9d30-466b-8764-104f2a9f6090 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands -- Commands for dynamo
-- Copyright (C) 2011, 2012, 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.Commands.Drivers;
with Gen.Generator;
package Gen.Commands is
package Drivers is
new Util.Commands.Drivers (Context_Type => Gen.Generator.Handler,
Driver_Name => "gen-commands");
subtype Command is Drivers.Command_Type;
subtype Command_Access is Drivers.Command_Access;
subtype Argument_List is Util.Commands.Argument_List;
Driver : Drivers.Driver_Type;
-- Print dynamo short usage.
procedure Short_Help_Usage;
end Gen.Commands;
```
Update to use the No_Parser for commands | ```ada
-----------------------------------------------------------------------
-- gen-commands -- Commands for dynamo
-- Copyright (C) 2011, 2012, 2017, 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.Commands.Drivers;
with Util.Commands.Parsers;
with Gen.Generator;
package Gen.Commands is
package Drivers is
new Util.Commands.Drivers (Context_Type => Gen.Generator.Handler,
Config_Parser => Util.Commands.Parsers.No_Parser,
Driver_Name => "gen-commands");
subtype Command is Drivers.Command_Type;
subtype Command_Access is Drivers.Command_Access;
subtype Argument_List is Util.Commands.Argument_List;
Driver : Drivers.Driver_Type;
-- Print dynamo short usage.
procedure Short_Help_Usage;
end Gen.Commands;
``` |
c07b6d08-ce79-4a14-97a5-18aa58e8a95d | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-workspaces -- Module workspaces
-- 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The *workspaces* plugin defines a workspace area for other plugins.
--
-- == Data Model ==
-- @include Workspace.hbm.xml
--
package AWA.Workspaces is
end AWA.Workspaces;
```
Add the Ada beans in the workspace documentation | ```ada
-----------------------------------------------------------------------
-- awa-workspaces -- Module workspaces
-- 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The *workspaces* plugin defines a workspace area for other plugins.
--
-- == Ada Beans ==
-- @include workspaces.xml
--
-- == Data Model ==
-- @include Workspace.hbm.xml
--
package AWA.Workspaces is
end AWA.Workspaces;
``` |
16240f6c-cff6-4f05-9edb-47c5853d5053 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- Util.Beans.Objects.Time -- Helper conversion for Ada Calendar Time
-- 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 Ada.Calendar;
package Util.Beans.Objects.Time is
-- Create an object from the given value.
function To_Object (Value : in Ada.Calendar.Time) return Object;
-- Convert the object into a time.
-- Raises Constraint_Error if the object cannot be converter to the target type.
function To_Time (Value : in Object) return Ada.Calendar.Time;
-- Force the object to be a time.
function Cast_Time (Value : Object) return Object;
end Util.Beans.Objects.Time;
```
Add To_Object and To_Time with a Nullable_Time type | ```ada
-----------------------------------------------------------------------
-- util-beans-objects-time -- Helper conversion for Ada Calendar Time
-- Copyright (C) 2010, 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.
-----------------------------------------------------------------------
with Ada.Calendar;
with Util.Nullables;
package Util.Beans.Objects.Time is
-- Create an object from the given value.
function To_Object (Value : in Ada.Calendar.Time) return Object;
function To_Object (Value : in Nullables.Nullable_Time) return Object;
-- Convert the object into a time.
-- Raises Constraint_Error if the object cannot be converter to the target type.
function To_Time (Value : in Object) return Ada.Calendar.Time;
function To_Time (Value : in Object) return Nullables.Nullable_Time;
-- Force the object to be a time.
function Cast_Time (Value : Object) return Object;
end Util.Beans.Objects.Time;
``` |
08338c6c-f859-4939-ad45-deada46edba0 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-tags -- Tags management
-- 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The <b>Tags</b> module allows to associate general purpose tags to any database entity.
--
-- == Model ==
-- [http://ada-awa.googlecode.com/svn/wiki/awa_tags_model.png]
--
-- @include awa-tags-modules.ads
package AWA.Tags is
pragma Pure;
end AWA.Tags;
```
Document the Tags plugin in AWA | ```ada
-----------------------------------------------------------------------
-- awa-tags -- Tags management
-- 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The <b>Tags</b> module allows to associate general purpose tags to any database entity.
-- It provides a JSF component that allows to insert easily a list of tags in a page and
-- in a form. An application can use the bean types defined in <tt>AWA.Tags.Beans</tt>
-- to define the tags and it will use the <tt>awa:tagList</tt> component to display them.
--
-- == Model ==
-- [http://ada-awa.googlecode.com/svn/wiki/awa_tags_model.png]
--
-- @include awa-tags-modules.ads
-- @include awa-tags-beans.ads
-- @include awa-tags-components.ads
--
package AWA.Tags is
pragma Pure;
end AWA.Tags;
``` |
31b3ddaa-0526-4a54-b258-005c94faf036 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-database -- Database creation from application model
-- 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.
-----------------------------------------------------------------------
package Gen.Commands.Database is
-- ------------------------------
-- Database Creation Command
-- ------------------------------
-- This command creates the database for the application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
procedure Execute (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Database;
```
Update to use the new command implementation | ```ada
-----------------------------------------------------------------------
-- gen-commands-database -- Database creation from application model
-- Copyright (C) 2011, 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 Gen.Commands.Database is
-- ------------------------------
-- Database Creation Command
-- ------------------------------
-- This command creates the database for the application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Database;
``` |
5950d1f4-7e77-42ce-80d7-04f19781cab2 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-propset -- Set a property on dynamo project
-- 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.
-----------------------------------------------------------------------
package Gen.Commands.Propset is
-- ------------------------------
-- Propset Command
-- ------------------------------
-- This command sets a property in the dynamo project configuration.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
procedure Execute (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Propset;
```
Update to use the new command implementation | ```ada
-----------------------------------------------------------------------
-- gen-commands-propset -- Set a property on dynamo project
-- Copyright (C) 2011, 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 Gen.Commands.Propset is
-- ------------------------------
-- Propset Command
-- ------------------------------
-- This command sets a property in the dynamo project configuration.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Propset;
``` |
96723308-da86-4e4c-acd9-b80e64b1e35f | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- druss-commands-devices -- Print information about the devices
-- 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.Devices is
type Command_Type is new Druss.Commands.Drivers.Command_Type with null record;
procedure Do_List (Command : in Command_Type;
Args : in Argument_List'Class;
Context : in out Context_Type);
-- Execute a status command to report information about the Bbox.
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.Devices;
```
Add a device selector to the Do_List procedure | ```ada
-----------------------------------------------------------------------
-- druss-commands-devices -- Print information about the devices
-- 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.Devices is
type Command_Type is new Druss.Commands.Drivers.Command_Type with null record;
procedure Do_List (Command : in Command_Type;
Args : in Argument_List'Class;
Selector : in Device_Selector_Type;
Context : in out Context_Type);
-- Execute a status command to report information about the Bbox.
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.Devices;
``` |
17b12e9f-24e8-45b6-bdf4-c0ed003264f3 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- ado-schemas-databases -- Database creation
-- 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.Strings.Vectors;
with ADO.Sessions;
with ADO.Configs;
package ADO.Schemas.Databases is
-- Create the database and initialize it with the schema SQL file.
procedure Create_Database (Session : in out Sessions.Master_Session;
Config : in Configs.Configuration'Class;
Schema_Path : in String;
Messages : out Util.Strings.Vectors.Vector);
end ADO.Schemas.Databases;
```
Update the Create_Database to use a Data_Source as configuration parameters | ```ada
-----------------------------------------------------------------------
-- ado-schemas-databases -- Database creation
-- 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.Strings.Vectors;
with ADO.Sessions.Sources;
package ADO.Schemas.Databases is
-- Create the database and initialize it with the schema SQL file.
-- The `Admin` parameter describes the database connection with administrator access.
-- The `Config` parameter describes the target database connection: this is the
-- database that must be created and configured. The `Schema_Path` is the path
-- of the SQL file that can be used to populate the database with the schema.
-- The `Messages` vector will contain the messages produced during the setup and
-- configuration of the database.
--
-- For the `sqlite` driver, the `Admin` parameter is not used.
procedure Create_Database (Admin : in ADO.Sessions.Sources.Data_Source'Class;
Config : in ADO.Sessions.Sources.Data_Source'Class;
Schema_Path : in String;
Messages : out Util.Strings.Vectors.Vector);
end ADO.Schemas.Databases;
``` |
dcd18e53-3168-4952-a85a-69425239edfe | {
"language": "Ada"
} | ```ada
-- Copyright 2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
name = "GitLab"
type = "api"
function start()
set_rate_limit(1)
end
function check()
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c ~= nil and c.key ~= nil and c.key ~= "") then
return true
end
return false
end
function vertical(ctx, domain)
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c == nil or c.key == nil or c.key == "") then
return
end
local scopes = {"issues", "blobs", "notes"}
for _, s in pairs(scopes) do
scrape(ctx, {
url=build_url(domain, s),
headers={['PRIVATE-TOKEN']=c.key},
})
end
end
function build_url(domain, scope)
return "https://gitlab.com/api/v4/search?scope=" .. scope .. "&search=" .. domain
end
```
Fix Gitlab data source script | ```ada
-- Copyright 2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
name = "GitLab"
type = "api"
function start()
set_rate_limit(1)
end
function check()
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c ~= nil and c.key ~= nil and c.key ~= "") then
return true
end
return false
end
function vertical(ctx, domain)
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c == nil or c.key == nil or c.key == "") then
return
end
local scopes = {"issues", "blobs", "notes"}
for _, s in pairs(scopes) do
scrape(ctx, {
url=build_url(domain, s),
headers={['PRIVATE-TOKEN']=c.key},
})
end
end
function build_url(domain, scope)
return "https://gitlab.com/api/v4/search?scope=" .. scope .. "&search=" .. domain:gsub("%.", "[.]")
end
``` |
79eb3ad0-c0e2-41ce-a080-581d726aa900 | {
"language": "Ada"
} | ```ada
-- @file coverage_for_ada_task.adb
-- @date 28 May 2022
-- @author Chester Gillon
-- @brief Example program to test getting coverage for an Ada task
with Ada.Text_IO;
procedure Coverage_For_Ada_Task is
task Print_Task is
entry Print;
end Print_Task;
task body Print_Task is
begin
loop
select
accept Print do
Ada.Text_IO.Put_Line ("In task Print_Task");
end Print;
or
terminate;
end select;
end loop;
end Print_Task;
begin
for index in 1..3
loop
Print_Task.Print;
end loop;
Ada.Text_IO.Put_Line ("In main");
end Coverage_For_Ada_Task;
```
Add coverage test for simple generic package | ```ada
-- @file coverage_for_ada_task.adb
-- @date 28 May 2022
-- @author Chester Gillon
-- @brief Example program to test getting coverage for an Ada task
with Ada.Text_IO;
procedure Coverage_For_Ada_Task is
generic
Name : String;
package Generic_Name is
procedure Display_Name;
end Generic_Name;
package body Generic_Name is
procedure Display_Name is
begin
Ada.Text_IO.Put_Line ("My name is " & Name);
end Display_Name;
end Generic_Name;
task Print_Task is
entry Print;
end Print_Task;
task body Print_Task is
begin
loop
select
accept Print do
Ada.Text_IO.Put_Line ("In task Print_Task");
end Print;
or
terminate;
end select;
end loop;
end Print_Task;
package Package_A is new Generic_Name ("A");
package Package_B is new Generic_Name ("B");
begin
Package_A.Display_Name;
for index in 1..3
loop
Print_Task.Print;
end loop;
Package_B.Display_Name;
Ada.Text_IO.Put_Line ("In main");
end Coverage_For_Ada_Task;
``` |
576a278c-50ee-45cc-af9d-4a0ed0589a3f | {
"language": "Ada"
} | ```ada
-- t0032.adb - Tue Jan 14 20:20:46 2014
--
-- (c) Warren W. Gay VE3WWG ve3wwg@gmail.com
--
-- Protected under the following license:
-- GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999
with Ada.Text_IO;
with Posix;
use Posix;
procedure T0032 is
use Ada.Text_IO;
Res : s_rusage;
Error : errno_t;
pragma Volatile(Error);
begin
Put_Line("Test 0032 - Getrlimit/Setrlimit");
Error := 0;
for X in 0..999999 loop
if Error < 32000 then
Error := Error + 1;
else
Error := 0;
end if;
end loop;
Getrusage(RUSAGE_SELF,Res,Error);
pragma Assert(Error = 0);
pragma Assert(Res.ru_utime.tv_sec >= 0);
pragma Assert(Res.ru_utime.tv_usec > 0 or else Res.ru_utime.tv_sec > 0);
Put_Line("Test 0032 Passed.");
end T0032;
```
Increase loop for FreeBSD test | ```ada
-- t0032.adb - Tue Jan 14 20:20:46 2014
--
-- (c) Warren W. Gay VE3WWG ve3wwg@gmail.com
--
-- Protected under the following license:
-- GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999
with Ada.Text_IO;
with Posix;
use Posix;
procedure T0032 is
use Ada.Text_IO;
Res : s_rusage;
Error : errno_t;
pragma Volatile(Error);
begin
Put_Line("Test 0032 - Getrlimit/Setrlimit");
Error := 0;
for X in 0..9999999 loop
if Error < 32000 then
Error := Error + 1;
else
Error := 0;
end if;
end loop;
Getrusage(RUSAGE_SELF,Res,Error);
pragma Assert(Error = 0);
pragma Assert(Res.ru_utime.tv_sec >= 0);
pragma Assert(Res.ru_utime.tv_usec > 0 or else Res.ru_utime.tv_sec > 0);
Put_Line("Test 0032 Passed.");
end T0032;
``` |
3d319486-06ad-4fed-b403-365149d92d49 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- asf-security -- ASF Security
-- 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 EL.Functions;
package ASF.Security is
-- EL function name exposed by Set_Functions.
HAS_PERMISSION_FN : constant String := "hasPermission";
-- URI for the EL functions exposed by the security package (See Set_Functions).
AUTH_NAMESPACE_URI : constant String := "http://code.google.com/p/ada-asf/auth";
-- Register a set of functions in the namespace
-- xmlns:fn="http://code.google.com/p/ada-asf/auth"
-- Functions:
-- hasPermission(NAME) -- Returns True if the permission NAME is granted
procedure Set_Functions (Mapper : in out EL.Functions.Function_Mapper'Class);
end ASF.Security;
```
Package ASF.Security moved to Servlet.Security | ```ada
-----------------------------------------------------------------------
-- asf-security -- ASF Security
-- 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 EL.Functions;
package ASF.Security is
-- EL function name exposed by Set_Functions.
HAS_PERMISSION_FN : constant String := "hasPermission";
-- URI for the EL functions exposed by the security package (See Set_Functions).
AUTH_NAMESPACE_URI : constant String := "http://code.google.com/p/ada-asf/auth";
-- Register a set of functions in the namespace
-- xmlns:fn="http://code.google.com/p/ada-asf/auth"
-- Functions:
-- hasPermission(NAME) -- Returns True if the permission NAME is granted
procedure Set_Functions (Mapper : in out EL.Functions.Function_Mapper'Class);
end ASF.Security;
``` |
313df414-f7e0-4e06-8d76-0fce1c71a2fe | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-blogs -- Blogs module
-- 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The *blogs* plugin is a small blog application which allows users to publish articles.
--
-- @include blogs.xml
--
-- == Model ==
-- [http://ada-awa.googlecode.com/svn/wiki/awa_blogs_model.png]
--
-- @include Blog.hbm.xml
--
package AWA.Blogs is
end AWA.Blogs;
```
Add the specific queries and Ada beans in the documentation | ```ada
-----------------------------------------------------------------------
-- awa-blogs -- Blogs module
-- 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The *blogs* plugin is a small blog application which allows users to publish articles.
--
-- == Ada Beans ==
-- @include blogs.xml
--
-- == Queries ==
-- @include blog-admin-post-list.xml
-- @include blog-post-list.xml
-- @include blog-list.xml
--
-- == Model ==
-- [http://ada-awa.googlecode.com/svn/wiki/awa_blogs_model.png]
--
-- @include Blog.hbm.xml
--
package AWA.Blogs is
end AWA.Blogs;
``` |
4698e7b7-3a38-40da-9a95-f23356d66cb7 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-blogs -- Blogs module
-- 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The *blogs* plugin is a small blog application which allows users to publish articles.
--
-- @include blogs.xml
--
-- == Model ==
-- [http://ada-awa.googlecode.com/svn/wiki/awa_blogs_model.png]
--
-- @include Blog.hbm.xml
--
package AWA.Blogs is
end AWA.Blogs;
```
Add the specific queries and Ada beans in the documentation | ```ada
-----------------------------------------------------------------------
-- awa-blogs -- Blogs module
-- 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The *blogs* plugin is a small blog application which allows users to publish articles.
--
-- == Ada Beans ==
-- @include blogs.xml
--
-- == Queries ==
-- @include blog-admin-post-list.xml
-- @include blog-post-list.xml
-- @include blog-list.xml
--
-- == Model ==
-- [http://ada-awa.googlecode.com/svn/wiki/awa_blogs_model.png]
--
-- @include Blog.hbm.xml
--
package AWA.Blogs is
end AWA.Blogs;
``` |
011da1af-9281-40be-a205-83910c495024 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-storages -- Storage module
-- 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The <b>Storages</b> module provides a set of storage services allowing an application
-- to store data files, documents, images in a persistent area.
--
-- == Data Model ==
-- @include Storages.hbm.xml
package AWA.Storages is
end AWA.Storages;
```
Add the Ada beans in the Storages plugin documentation | ```ada
-----------------------------------------------------------------------
-- awa-storages -- Storage module
-- 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The <b>Storages</b> module provides a set of storage services allowing an application
-- to store data files, documents, images in a persistent area.
--
-- == Ada Beans ==
-- @include storages.xml
--
-- == Data Model ==
-- @include Storages.hbm.xml
package AWA.Storages is
end AWA.Storages;
``` |
bf14b982-fca1-4115-afa3-a89270403094 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- druss-commands-wifi -- Wifi related commands
-- 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.Wifi is
type Command_Type is new Druss.Commands.Drivers.Command_Type with null record;
-- Execute a command to control or get status about the Wifi.
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.Wifi;
```
Declare the Set_Enable and Do_Status operations | ```ada
-----------------------------------------------------------------------
-- druss-commands-wifi -- Wifi related commands
-- 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.Wifi is
type Command_Type is new Druss.Commands.Drivers.Command_Type with null record;
-- Enable or disable with wifi radio.
procedure Set_Enable (Command : in Command_Type;
Args : in Argument_List'Class;
Value : in String;
Context : in out Context_Type);
-- Execute the wifi 'status' command to print the Wifi current status.
procedure Do_Status (Command : in Command_Type;
Args : in Argument_List'Class;
Context : in out Context_Type);
-- Execute a command to control or get status about the Wifi.
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.Wifi;
``` |
dfc2096a-f158-4cda-bb63-d23712adaaf1 | {
"language": "Ada"
} | ```ada
-- 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;
```
Check that accessing a struct field that occurs before the start of the struct (!) works correctly. | ```ada
-- 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;
procedure Q (P : String_Pointer) is
begin
P (1) := 'Z';
end;
begin
P := new String (1 .. N);
Q (P);
end;
``` |
161fbaf8-d458-4df8-a89e-51d86b99021b | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- security -- Security
-- Copyright (C) 2010, 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.
-----------------------------------------------------------------------
-- == Introduction ==
--
--
-- @include security-contexts.ads
-- @include security-controllers.ads
package Security is
end Security;
```
Add the permission in the documentation | ```ada
-----------------------------------------------------------------------
-- security -- Security
-- Copyright (C) 2010, 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.
-----------------------------------------------------------------------
-- == Introduction ==
-- The <tt>Security</tt> package provides security frameworks that allows
-- an application to use OpenID or OAuth security frameworks. This security
-- framework was first developed within the Ada Server Faces project.
--
-- @include security-permissions.ads
-- @include security-openid.ads
-- @include security-oauth.ads
-- @include security-contexts.ads
-- @include security-controllers.ads
package Security is
end Security;
``` |
e773512c-7ff7-4362-9b1f-dd0c61ec0417 | {
"language": "Ada"
} | ```ada
#if MCU="ATMEGA2560" then
with AVR.USART;
with AVR.INTERRUPTS;
#end if;
procedure Main is
-- Out_Flag_Char : Character;
begin
#if MCU="ATMEGA2560" then
AVR.INTERRUPTS.Disable;
AVR.USART.Initialize
(In_Port => AVR.USART.USART1,
In_Setup =>
(Sync_Mode => AVR.USART.ASYNCHRONOUS,
Double_Speed => True,
Baud_Rate => 9600,
Data_Bits => AVR.USART.BITS_8,
Parity => AVR.USART.NONE,
Stop_Bits => 1,
Model => AVR.USART.INTERRUPTIVE));
AVR.USART.Put_Line
(Port => AVR.USART.USART1,
Data => "#### Initialization ok. ####");
AVR.INTERRUPTS.Enable;
loop
-- Out_Flag_Char := AVR.USART.Get;
-- AVR.USART.Put
-- (Port => AVR.USART.USART1,
-- Data => Out_Flag_Char);
null;
end loop;
#else
null;
#end if;
end Main;
```
Read from usart1 in interruptive mode. | ```ada
#if MCU="ATMEGA2560" then
with AVR.USART;
with AVR.INTERRUPTS;
#end if;
procedure Main is
Counter : Long_Integer := 0;
Out_Buffer : AVR.USART.Buffer_64_Type;
begin
#if MCU="ATMEGA2560" then
AVR.INTERRUPTS.Disable;
AVR.USART.Initialize
(In_Port => AVR.USART.USART1,
In_Setup =>
(Sync_Mode => AVR.USART.ASYNCHRONOUS,
Double_Speed => True,
Baud_Rate => 9600,
Data_Bits => AVR.USART.BITS_8,
Parity => AVR.USART.NONE,
Stop_Bits => 1,
Model => AVR.USART.INTERRUPTIVE));
AVR.USART.Put_Line
(Port => AVR.USART.USART1,
Data => "#### Initialization ok. ####");
AVR.INTERRUPTS.Enable;
loop
Counter := Counter + 1;
if AVR.USART.Get_Raw_Buffer
(In_Port => AVR.USART.USART1,
Out_Data => Out_Buffer)
then
AVR.USART.Put_Buffer (In_Port => AVR.USART.USART1);
end if;
end loop;
#else
null;
#end if;
end Main;
``` |
73897951-f6fd-4737-9875-6b2044a81c41 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- babel-base -- File filters
-- 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 Babel.Base is
end Babel.Base;
```
Define the abstract Database type to represent the database of backup files | ```ada
-----------------------------------------------------------------------
-- babel-base -- Database for files
-- 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.Finalization;
with ADO;
package Babel.Base is
type Database is abstract new Ada.Finalization.Limited_Controlled with private;
private
type Database is abstract new Ada.Finalization.Limited_Controlled with record
Name : Integer;
end record;
end Babel.Base;
``` |
d1413278-14d7-4ac3-8229-851a19159b18 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-tests-helpers - Helpers for AWA unit tests
-- Copyright (C) 2011, 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.Responses.Mockup;
with Ada.Strings.Unbounded;
package AWA.Tests.Helpers is
-- Extract from the Location header the part that is after the given base string.
-- If the Location header does not start with the base string, returns the empty
-- string.
function Extract_Redirect (Reply : in ASF.Responses.Mockup.Response'Class;
Base : in String) return String;
function Extract_Redirect (Reply : in ASF.Responses.Mockup.Response'Class;
Base : in String) return Ada.Strings.Unbounded.Unbounded_String;
end AWA.Tests.Helpers;
```
Declare the Extract_Link function to extract a href from a HTML response | ```ada
-----------------------------------------------------------------------
-- awa-tests-helpers - Helpers for AWA unit tests
-- Copyright (C) 2011, 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.Responses.Mockup;
with Ada.Strings.Unbounded;
package AWA.Tests.Helpers is
-- Extract from the Location header the part that is after the given base string.
-- If the Location header does not start with the base string, returns the empty
-- string.
function Extract_Redirect (Reply : in ASF.Responses.Mockup.Response'Class;
Base : in String) return String;
function Extract_Redirect (Reply : in ASF.Responses.Mockup.Response'Class;
Base : in String) return Ada.Strings.Unbounded.Unbounded_String;
-- Extract from the response content a link with a given title.
function Extract_Link (Content : in String;
Title : in String) return String;
end AWA.Tests.Helpers;
``` |
dba3ab64-177d-444c-a916-f21ee5ad9135 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- components-ajax-factory -- Factory for AJAX Components
-- 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 ASF.Factory;
package ASF.Components.Ajax.Factory is
use ASF;
-- Get the Ajax component factory.
function Definition return ASF.Factory.Factory_Bindings_Access;
end ASF.Components.Ajax.Factory;
```
Change the Definition function into a Register procedure | ```ada
-----------------------------------------------------------------------
-- components-ajax-factory -- Factory for AJAX Components
-- Copyright (C) 2011, 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 ASF.Factory;
package ASF.Components.Ajax.Factory is
-- Register the Ajax component factory.
procedure Register (Factory : in out ASF.Factory.Component_Factory);
end ASF.Components.Ajax.Factory;
``` |
79cde733-6bd1-484e-88dd-7067d3d4fffa | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-votes-modules-tests -- Unit tests for vote service
-- 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;
with AWA.Tests;
package AWA.Votes.Modules.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new AWA.Tests.Test with record
Manager : AWA.Votes.Modules.Vote_Module_Access;
end record;
-- Test vote.
procedure Test_Vote_Up (T : in out Test);
end AWA.Votes.Modules.Tests;
```
Add unit test for undo vote | ```ada
-----------------------------------------------------------------------
-- awa-votes-modules-tests -- Unit tests for vote service
-- 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;
with AWA.Tests;
package AWA.Votes.Modules.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new AWA.Tests.Test with record
Manager : AWA.Votes.Modules.Vote_Module_Access;
end record;
-- Test vote.
procedure Test_Vote_Up (T : in out Test);
-- Test vote.
procedure Test_Vote_Undo (T : in out Test);
end AWA.Votes.Modules.Tests;
``` |
f38be493-2a49-4213-af56-5aaae143020f | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- Targets - Representation of target information
-- 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 MAT.Types;
with Ada.Strings.Unbounded;
with MAT.Memory.Targets;
with MAT.Readers;
package MAT.Targets is
type Target_Type is tagged limited private;
type Target_Type_Access is access all Target_Type'Class;
-- Initialize the target object to manage the memory slots, the stack frames
-- and setup the reader to analyze the memory and other events.
procedure Initialize (Target : in out Target_Type;
Reader : in out MAT.Readers.Manager_Base'Class);
private
type Target_Type is tagged limited record
Memory : MAT.Memory.Targets.Target_Memory;
end record;
end MAT.Targets;
```
Add the symbols in the target object | ```ada
-----------------------------------------------------------------------
-- Targets - Representation of target information
-- 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 MAT.Types;
with Ada.Strings.Unbounded;
with MAT.Memory.Targets;
with MAT.Symbols.Targets;
with MAT.Readers;
package MAT.Targets is
-- type Target_Type is tagged limited private;
type Target_Type is tagged limited record
Memory : MAT.Memory.Targets.Target_Memory;
Symbols : MAT.Symbols.Targets.Target_Symbols;
end record;
type Target_Type_Access is access all Target_Type'Class;
-- Initialize the target object to manage the memory slots, the stack frames
-- and setup the reader to analyze the memory and other events.
procedure Initialize (Target : in out Target_Type;
Reader : in out MAT.Readers.Manager_Base'Class);
--
-- private
--
-- type Target_Type is tagged limited record
-- Memory : MAT.Memory.Targets.Target_Memory;
-- end record;
end MAT.Targets;
``` |
bbed3af4-19e9-44e2-97b6-1e29aa39a233 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- util-streams-tests -- Unit tests for encoding buffered streams
-- Copyright (C) 2017, 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.
-----------------------------------------------------------------------
with Util.Tests;
with Util.Encoders.AES;
package Util.Streams.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_AES (T : in out Test;
Item : in String;
Count : in Positive;
Mode : in Util.Encoders.AES.AES_Mode;
Label : in String);
procedure Test_Base64_Stream (T : in out Test);
end Util.Streams.Tests;
```
Declare the Test_Copy_Stream procedure to test the Util.Streams.Copy procedures | ```ada
-----------------------------------------------------------------------
-- util-streams-tests -- Unit tests for encoding buffered streams
-- Copyright (C) 2017, 2019, 2021 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.Encoders.AES;
package Util.Streams.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_AES (T : in out Test;
Item : in String;
Count : in Positive;
Mode : in Util.Encoders.AES.AES_Mode;
Label : in String);
procedure Test_Base64_Stream (T : in out Test);
procedure Test_Copy_Stream (T : in out Test);
end Util.Streams.Tests;
``` |
a6cd41f0-1d29-4f0b-a8f2-9caf6cd78c1c | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-counters-definition -- Counter 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.
-----------------------------------------------------------------------
-- The <tt>AWA.Counters.Definition</tt> package is instantiated for each counter definition.
generic
Table : ADO.Schemas.Class_Mapping_Access;
Field : String;
package AWA.Counters.Definition is
Def_Name : aliased constant String := Field;
package Def is new Counter_Arrays.Definition (Counter_Def '(Table, Def_Name'Access));
-- Get the counter definition index.
function Index return Counter_Index_Type renames Def.Kind;
end AWA.Counters.Definition;
```
Move the Counter_Arrays.Definition package instantiation in the private part | ```ada
-----------------------------------------------------------------------
-- awa-counters-definition -- Counter 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.
-----------------------------------------------------------------------
-- The <tt>AWA.Counters.Definition</tt> package is instantiated for each counter definition.
generic
Table : ADO.Schemas.Class_Mapping_Access;
Field : String;
package AWA.Counters.Definition is
Def_Name : aliased constant String := Field;
-- Get the counter definition index.
function Index return Counter_Index_Type;
private
package Def is new Counter_Arrays.Definition (Counter_Def '(Table, Def_Name'Access));
-- Get the counter definition index.
function Index return Counter_Index_Type renames Def.Kind;
end AWA.Counters.Definition;
``` |
dec9d0e4-048f-4057-a3ce-be5488c7743e | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- ado-sqlite -- SQLite Database Drivers
-- 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.
-----------------------------------------------------------------------
with ADO.Configs;
with ADO.Connections.Sqlite;
package body ADO.Sqlite is
-- ------------------------------
-- Initialize the drivers and the library by reading the property file
-- and configure the runtime with it.
-- ------------------------------
procedure Initialize (Config : in String) is
begin
ADO.Configs.Initialize (Config);
ADO.Connections.Sqlite.Initialize;
end Initialize;
-- ------------------------------
-- Initialize the drivers and the library and configure the runtime with the given properties.
-- ------------------------------
procedure Initialize (Config : in Util.Properties.Manager'Class) is
begin
ADO.Configs.Initialize (Config);
ADO.Connections.Sqlite.Initialize;
end Initialize;
end ADO.Sqlite;
```
Implement the Initialize procedure and use it | ```ada
-----------------------------------------------------------------------
-- ado-sqlite -- SQLite Database Drivers
-- 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.
-----------------------------------------------------------------------
with ADO.Configs;
with ADO.Connections.Sqlite;
package body ADO.Sqlite is
-- ------------------------------
-- Initialize the SQLite driver.
-- ------------------------------
procedure Initialize is
begin
ADO.Connections.Sqlite.Initialize;
end Initialize;
-- ------------------------------
-- Initialize the drivers and the library by reading the property file
-- and configure the runtime with it.
-- ------------------------------
procedure Initialize (Config : in String) is
begin
ADO.Configs.Initialize (Config);
Initialize;
end Initialize;
-- ------------------------------
-- Initialize the drivers and the library and configure the runtime with the given properties.
-- ------------------------------
procedure Initialize (Config : in Util.Properties.Manager'Class) is
begin
ADO.Configs.Initialize (Config);
Initialize;
end Initialize;
end ADO.Sqlite;
``` |
f131eca5-f0d9-4980-978a-fce2d4609167 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- babel-base -- Database for files
-- 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.Finalization;
with ADO;
with Babel.Files;
package Babel.Base is
type Database is abstract new Ada.Finalization.Limited_Controlled with private;
type Database_Access is access all Database'Class;
-- Insert the file in the database.
procedure Insert (Into : in out Database;
File : in Babel.Files.File_Type) is abstract;
private
type Database is abstract new Ada.Finalization.Limited_Controlled with record
Name : Integer;
end record;
end Babel.Base;
```
Declare the Iterate and Copy procedures | ```ada
-----------------------------------------------------------------------
-- babel-base -- Database for files
-- 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.Finalization;
with ADO;
with Babel.Files;
package Babel.Base is
type Database is abstract new Ada.Finalization.Limited_Controlled with private;
type Database_Access is access all Database'Class;
-- Insert the file in the database.
procedure Insert (Into : in out Database;
File : in Babel.Files.File_Type) is abstract;
procedure Iterate (From : in Database;
Process : not null access
procedure (File : in Babel.Files.File_Type)) is abstract;
procedure Copy (Into : in out Database'Class;
From : in Database'Class);
private
type Database is abstract new Ada.Finalization.Limited_Controlled with record
Name : Integer;
end record;
end Babel.Base;
``` |
5235122d-a4ef-464c-8877-218228707b52 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-model -- Model creation command for dynamo
-- 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.
-----------------------------------------------------------------------
package Gen.Commands.Model is
-- ------------------------------
-- Model Creation Command
-- ------------------------------
-- This command adds a model file to the web application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
procedure Execute (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Model;
```
Update to use the new command implementation | ```ada
-----------------------------------------------------------------------
-- gen-commands-model -- Model creation command for dynamo
-- Copyright (C) 2011, 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 Gen.Commands.Model is
-- ------------------------------
-- Model Creation Command
-- ------------------------------
-- This command adds a model file to the web application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Model;
``` |
a4df562c-8ec8-4372-a43d-8272799c67f5 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- schemas Tests -- Test loading of database schema
-- Copyright (C) 2009, 2010, 2011, 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 ADO.Schemas.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test reading the entity cache and the Find_Entity_Type operation
procedure Test_Find_Entity_Type (T : in out Test);
-- Test calling Find_Entity_Type with an invalid table.
procedure Test_Find_Entity_Type_Error (T : in out Test);
-- Test the Load_Schema operation and check the result schema.
procedure Test_Load_Schema (T : in out Test);
end ADO.Schemas.Tests;
```
Declare Test_Table_Iterator procedure to test the table iterator | ```ada
-----------------------------------------------------------------------
-- schemas Tests -- Test loading of database schema
-- Copyright (C) 2009, 2010, 2011, 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 ADO.Schemas.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test reading the entity cache and the Find_Entity_Type operation
procedure Test_Find_Entity_Type (T : in out Test);
-- Test calling Find_Entity_Type with an invalid table.
procedure Test_Find_Entity_Type_Error (T : in out Test);
-- Test the Load_Schema operation and check the result schema.
procedure Test_Load_Schema (T : in out Test);
-- Test the Table_Cursor operations and check the result schema.
procedure Test_Table_Iterator (T : in out Test);
end ADO.Schemas.Tests;
``` |
7c35978b-28a7-44be-a7e7-4cb914027f7f | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- asf-streams-json -- JSON Print streams for servlets
-- 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.Serialize.IO.JSON;
package body ASF.Streams.JSON is
-- ------------------------------
-- Initialize the stream
-- ------------------------------
procedure Initialize (Stream : in out Print_Stream;
To : in ASF.Streams.Print_Stream'Class) is
begin
Stream.Initialize (To.Target);
end Initialize;
end ASF.Streams.JSON;
```
Remove unused with clause Util.Serialize.IO.JSON | ```ada
-----------------------------------------------------------------------
-- asf-streams-json -- JSON Print streams for servlets
-- Copyright (C) 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.
-----------------------------------------------------------------------
package body ASF.Streams.JSON is
-- ------------------------------
-- Initialize the stream
-- ------------------------------
procedure Initialize (Stream : in out Print_Stream;
To : in ASF.Streams.Print_Stream'Class) is
begin
Stream.Initialize (To.Target);
end Initialize;
end ASF.Streams.JSON;
``` |
5b2a1f8c-788b-409f-96b4-67a5b8643f14 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- 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 Util.Properties;
with Druss.Gateways;
package Druss.Config is
-- Initialize the configuration.
procedure Initialize;
-- Get the configuration parameter.
function Get (Name : in String) return String;
-- Initalize the list of gateways from the configuration file.
procedure Get_Gateways (List : in out Druss.Gateways.Gateway_Vector);
end Druss.Config;
```
Add a Path parameter to the Initialize procedure | ```ada
-----------------------------------------------------------------------
-- 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 Druss.Gateways;
package Druss.Config is
-- Initialize the configuration.
procedure Initialize (Path : in String);
-- Get the configuration parameter.
function Get (Name : in String) return String;
-- Initalize the list of gateways from the configuration file.
procedure Get_Gateways (List : in out Druss.Gateways.Gateway_Vector);
end Druss.Config;
``` |
cb772b63-ecfb-44df-a1b9-f318f668a1d1 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-database -- Database creation from application model
-- Copyright (C) 2011, 2017, 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.
-----------------------------------------------------------------------
package Gen.Commands.Database is
-- ------------------------------
-- Database Creation Command
-- ------------------------------
-- This command creates the database for the application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Database;
```
Add Name parameter to the Help procedure | ```ada
-----------------------------------------------------------------------
-- gen-commands-database -- Database creation from application model
-- Copyright (C) 2011, 2017, 2018, 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 Gen.Commands.Database is
-- ------------------------------
-- Database Creation Command
-- ------------------------------
-- This command creates the database for the application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Name : in String;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Database;
``` |
9674ac9c-39a2-4497-bc42-c13802377b2b | {
"language": "Ada"
} | ```ada
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 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.
package Orka.Atomics is
pragma Pure;
protected type Counter (Initial_Value : Natural) is
procedure Add (Addition : Natural);
procedure Increment;
procedure Decrement (Zero : out Boolean);
procedure Reset;
function Count return Natural;
private
Value : Natural := Initial_Value;
end Counter;
end Orka.Atomics;
```
Make protected type Counter lock free | ```ada
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 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.
package Orka.Atomics is
pragma Pure;
protected type Counter (Initial_Value : Natural) is
pragma Lock_Free;
procedure Add (Addition : Natural);
procedure Increment;
procedure Decrement (Zero : out Boolean);
procedure Reset;
function Count return Natural;
private
Value : Natural := Initial_Value;
end Counter;
end Orka.Atomics;
``` |
c32db417-5523-4ed6-aae4-d8bfdd10a48b | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-propset -- Set a property on dynamo project
-- Copyright (C) 2011, 2017, 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.
-----------------------------------------------------------------------
package Gen.Commands.Propset is
-- ------------------------------
-- Propset Command
-- ------------------------------
-- This command sets a property in the dynamo project configuration.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Propset;
```
Update to use an in out parameter for Help procedure | ```ada
-----------------------------------------------------------------------
-- gen-commands-propset -- Set a property on dynamo project
-- Copyright (C) 2011, 2017, 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.
-----------------------------------------------------------------------
package Gen.Commands.Propset is
-- ------------------------------
-- Propset Command
-- ------------------------------
-- This command sets a property in the dynamo project configuration.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Propset;
``` |
47d2e757-9560-46d6-b240-b3b156464deb | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- wiki-parsers-markdown -- Markdown parser operations
-- Copyright (C) 2016 - 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.
-----------------------------------------------------------------------
private package Wiki.Parsers.Markdown is
pragma Preelaborate;
subtype Parser_Type is Parser;
-- Parse a markdown table/column.
-- Example:
-- | col1 | col2 | ... | colN |
procedure Parse_Table (P : in out Parser;
Token : in Wiki.Strings.WChar);
procedure Parse_Line (Parser : in out Parser_Type;
Text : in Wiki.Buffers.Buffer_Access);
procedure Parse_Inline_Text (Parser : in out Parser_Type;
Text : in Wiki.Buffers.Buffer_Access);
end Wiki.Parsers.Markdown;
```
Remove declaration of internal Parse_Table procedure | ```ada
-----------------------------------------------------------------------
-- wiki-parsers-markdown -- Markdown parser operations
-- Copyright (C) 2016 - 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.
-----------------------------------------------------------------------
private package Wiki.Parsers.Markdown is
pragma Preelaborate;
subtype Parser_Type is Parser;
procedure Parse_Line (Parser : in out Parser_Type;
Text : in Wiki.Buffers.Buffer_Access);
procedure Parse_Inline_Text (Parser : in out Parser_Type;
Text : in Wiki.Buffers.Buffer_Access);
end Wiki.Parsers.Markdown;
``` |
95f4a8d9-a9db-474e-9c7b-f0d64c83e8a5 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-generate -- Generate command for dynamo
-- 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.
-----------------------------------------------------------------------
package Gen.Commands.Generate is
-- ------------------------------
-- Generator Command
-- ------------------------------
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
procedure Execute (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Generate;
```
Update to use the new command implementation | ```ada
-----------------------------------------------------------------------
-- gen-commands-generate -- Generate command for dynamo
-- Copyright (C) 2011, 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 Gen.Commands.Generate is
-- ------------------------------
-- Generator Command
-- ------------------------------
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Generate;
``` |
035e112f-5b63-4b85-baef-8151a1eda647 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- wiki-helpers-parser -- Generic procedure for the wiki parser
-- 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;
with Wiki.Documents;
with Wiki.Streams;
generic
type Engine_Type is limited private;
type Element_Type is limited private;
with function Element (Item : in Element_Type;
Pos : in Natural) return Wiki.Strings.WChar is <>;
with function Length (Item : in Element_Type) return Natural is <>;
with procedure Parse (Engine : in out Engine_Type;
Stream : in Wiki.Streams.Input_Stream_Access;
Doc : in out Wiki.Documents.Document) is <>;
procedure Wiki.Helpers.Parser (Engine : in out Engine_Type;
Content : in Element_Type;
Doc : in out Wiki.Documents.Document);
pragma Preelaborate (Wiki.Helpers.Parser);
```
Change the Element operation to a procedure that gets and updates the position | ```ada
-----------------------------------------------------------------------
-- wiki-helpers-parser -- Generic procedure for the wiki parser
-- 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;
with Wiki.Documents;
with Wiki.Streams;
generic
type Engine_Type is limited private;
type Element_Type (<>) is limited private;
with procedure Element (Item : in Element_Type;
Pos : in out Natural;
Char : out Wiki.Strings.WChar) is <>;
with function Length (Item : in Element_Type) return Natural is <>;
with procedure Parse (Engine : in out Engine_Type;
Stream : in Wiki.Streams.Input_Stream_Access;
Doc : in out Wiki.Documents.Document) is <>;
procedure Wiki.Helpers.Parser (Engine : in out Engine_Type;
Content : in Element_Type;
Doc : in out Wiki.Documents.Document);
pragma Preelaborate (Wiki.Helpers.Parser);
``` |
4adc08ec-3b7a-4845-9648-15a50123bbe3 | {
"language": "Ada"
} | ```ada
with STM32.LTDC;
with STM32.LCDInit;
package STM32.LCD is new
STM32.LTDC (LCD_Width => 480,
LCD_Height => 272,
LCD_HSync => 41,
LCD_HBP => 13,
LCD_HFP => 32,
LCD_VSYNC => 10,
LCD_VBP => 2,
LCD_VFP => 2,
PLLSAI_N => 429,
PLLSAI_R => 5,
DivR => 2,
Pre_LTDC_Initialize => STM32.LCDInit.Initialize,
Post_LTDC_Initialize => STM32.LCDInit.Post_Init);
```
Fix LCD too slow on the STM32F7-Disco. | ```ada
with STM32.LTDC;
with STM32.LCDInit;
package STM32.LCD is new
STM32.LTDC (LCD_Width => 480,
LCD_Height => 272,
LCD_HSync => 41,
LCD_HBP => 13,
LCD_HFP => 32,
LCD_VSYNC => 10,
LCD_VBP => 2,
LCD_VFP => 2,
PLLSAI_N => 200,
PLLSAI_R => 5,
DivR => 2,
Pre_LTDC_Initialize => STM32.LCDInit.Initialize,
Post_LTDC_Initialize => STM32.LCDInit.Post_Init);
``` |
ac3f8c2a-67ac-41ff-b622-f2dcfc984745 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- asf-helpers-beans -- Helper packages to write ASF applications
-- 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 Util.Beans.Basic;
package ASF.Helpers.Beans is
-- Get a bean instance associated under the given name from the current faces context.
-- A null value is returned if the bean does not exist or is not of the good type.
generic
type Element_Type is new Util.Beans.Basic.Readonly_Bean with private;
type Element_Access is access all Element_Type'Class;
function Get_Bean (Name : in String) return Element_Access;
end ASF.Helpers.Beans;
```
Declare the Get_Request_Bean generic function | ```ada
-----------------------------------------------------------------------
-- asf-helpers-beans -- Helper packages to write ASF applications
-- Copyright (C) 2012, 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.Beans.Basic;
with ASF.Requests;
package ASF.Helpers.Beans is
-- Get a bean instance associated under the given name from the current faces context.
-- A null value is returned if the bean does not exist or is not of the good type.
generic
type Element_Type is new Util.Beans.Basic.Readonly_Bean with private;
type Element_Access is access all Element_Type'Class;
function Get_Bean (Name : in String) return Element_Access;
-- Get a bean instance associated under the given name from the request.
-- A null value is returned if the bean does not exist or is not of the good type.
generic
type Element_Type is new Util.Beans.Basic.Readonly_Bean with private;
type Element_Access is access all Element_Type'Class;
function Get_Request_Bean (Request : in ASF.Requests.Request'Class;
Name : in String) return Element_Access;
end ASF.Helpers.Beans;
``` |
f80235dd-5d35-4572-a01e-7ee774e569ad | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-layout -- Layout creation command for dynamo
-- Copyright (C) 2011, 2017, 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.
-----------------------------------------------------------------------
package Gen.Commands.Layout is
-- ------------------------------
-- Layout Creation Command
-- ------------------------------
-- This command adds a XHTML layout to the web application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Layout;
```
Add Name parameter to the Help procedure | ```ada
-----------------------------------------------------------------------
-- gen-commands-layout -- Layout creation command for dynamo
-- Copyright (C) 2011, 2017, 2018, 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 Gen.Commands.Layout is
-- ------------------------------
-- Layout Creation Command
-- ------------------------------
-- This command adds a XHTML layout to the web application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Name : in String;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Layout;
``` |
c1bc014c-ca13-4443-b72f-3199cd5da620 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-plugins -- Plugin creation and management commands for dynamo
-- Copyright (C) 2012, 2017, 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.
-----------------------------------------------------------------------
package Gen.Commands.Plugins is
-- ------------------------------
-- Generator Command
-- ------------------------------
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Plugins;
```
Add Name parameter to the Help procedure | ```ada
-----------------------------------------------------------------------
-- gen-commands-plugins -- Plugin creation and management commands for dynamo
-- Copyright (C) 2012, 2017, 2018, 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 Gen.Commands.Plugins is
-- ------------------------------
-- Generator Command
-- ------------------------------
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Name : in String;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Plugins;
``` |
72a0befb-660f-43ef-9d44-691a176a5470 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- babel-base -- Database for files
-- 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.Finalization;
with ADO;
package Babel.Base is
type Database is abstract new Ada.Finalization.Limited_Controlled with private;
private
type Database is abstract new Ada.Finalization.Limited_Controlled with record
Name : Integer;
end record;
end Babel.Base;
```
Define the Insert operation on the Database abstract type | ```ada
-----------------------------------------------------------------------
-- babel-base -- Database for files
-- 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.Finalization;
with ADO;
with Babel.Files;
package Babel.Base is
type Database is abstract new Ada.Finalization.Limited_Controlled with private;
-- Insert the file in the database.
procedure Insert (Into : in out Database;
File : in Babel.Files.File_Type) is abstract;
private
type Database is abstract new Ada.Finalization.Limited_Controlled with record
Name : Integer;
end record;
end Babel.Base;
``` |
6798182a-26bb-4875-8333-2854aa55aee2 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- 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;
```
Add a device selector to the Do_Ping procedure | ```ada
-----------------------------------------------------------------------
-- 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;
Selector : in Device_Selector_Type;
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;
``` |
81102437-d4b6-4cf9-83b9-04f67aac8f45 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-generate -- Generate command for dynamo
-- Copyright (C) 2011, 2017, 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.
-----------------------------------------------------------------------
package Gen.Commands.Generate is
-- ------------------------------
-- Generator Command
-- ------------------------------
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Generate;
```
Add Name parameter to the Help procedure | ```ada
-----------------------------------------------------------------------
-- gen-commands-generate -- Generate command for dynamo
-- Copyright (C) 2011, 2017, 2018, 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 Gen.Commands.Generate is
-- ------------------------------
-- Generator Command
-- ------------------------------
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Name : in String;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Generate;
``` |
bbbb3ea7-4d87-413a-9810-a8c6e12a0b1f | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- gen-commands-model -- Model creation command for dynamo
-- Copyright (C) 2011, 2017, 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.
-----------------------------------------------------------------------
package Gen.Commands.Model is
-- ------------------------------
-- Model Creation Command
-- ------------------------------
-- This command adds a model file to the web application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Model;
```
Add Name parameter to the Help procedure | ```ada
-----------------------------------------------------------------------
-- gen-commands-model -- Model creation command for dynamo
-- Copyright (C) 2011, 2017, 2018, 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 Gen.Commands.Model is
-- ------------------------------
-- Model Creation Command
-- ------------------------------
-- This command adds a model file to the web application.
type Command is new Gen.Commands.Command with null record;
-- Execute the command with the arguments.
overriding
procedure Execute (Cmd : in out Command;
Name : in String;
Args : in Argument_List'Class;
Generator : in out Gen.Generator.Handler);
-- Write the help associated with the command.
overriding
procedure Help (Cmd : in out Command;
Name : in String;
Generator : in out Gen.Generator.Handler);
end Gen.Commands.Model;
``` |
e9aab3d2-844a-479e-83d3-66e561113417 | {
"language": "Ada"
} | ```ada
-- Lumen -- A simple graphical user interface library based on OpenGL
--
-- Chip Richards, NiEstu, Phoenix AZ, Spring 2010
-- Lumen would not be possible without the support and contributions of a cast
-- of thousands, including and primarily Rod Kay.
-- This code is covered by the ISC License:
--
-- Copyright (c) 2010, NiEstu
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-- SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
-- IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package Lumen is
pragma Pure (Lumen);
end Lumen;
```
Change license text to mixed case instead of SHOUTING it | ```ada
-- Lumen -- A simple graphical user interface library based on OpenGL
--
-- Chip Richards, NiEstu, Phoenix AZ, Spring 2010
-- Lumen would not be possible without the support and contributions of a cast
-- of thousands, including and primarily Rod Kay.
-- This code is covered by the ISC License:
--
-- Copyright (c) 2010, NiEstu
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- The software is provided "as is" and the author disclaims all warranties
-- with regard to this software including all implied warranties of
-- merchantability and fitness. In no event shall the author be liable for any
-- special, direct, indirect, or consequential damages or any damages
-- whatsoever resulting from loss of use, data or profits, whether in an
-- action of contract, negligence or other tortious action, arising out of or
-- in connection with the use or performance of this software.
package Lumen is
pragma Pure (Lumen);
end Lumen;
``` |
07bb96f1-1634-4f95-bc78-a7cd8c8288c0 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- html-factory -- Factory for HTML UI Components
-- Copyright (C) 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 ASF.Factory;
package ASF.Components.Html.Factory is
use ASF;
-- Get the HTML component factory.
function Definition return ASF.Factory.Factory_Bindings_Access;
end ASF.Components.Html.Factory;
```
Change the Definition function into a Register procedure | ```ada
-----------------------------------------------------------------------
-- html-factory -- Factory for HTML UI Components
-- Copyright (C) 2009, 2010, 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 ASF.Factory;
package ASF.Components.Html.Factory is
-- Register the HTML component factory.
procedure Register (Factory : in out ASF.Factory.Component_Factory);
end ASF.Components.Html.Factory;
``` |
f33372ce-970b-4713-ba94-f74059957d74 | {
"language": "Ada"
} | ```ada
-- Generated by utildgen.c from system includes
with Interfaces.C;
package Util.Systems.Constants is
pragma Pure;
-- Flags used when opening a file with open/creat.
O_RDONLY : constant Interfaces.C.int := 8#000000#;
O_WRONLY : constant Interfaces.C.int := 8#000001#;
O_RDWR : constant Interfaces.C.int := 8#000002#;
O_CREAT : constant Interfaces.C.int := 8#000400#;
O_EXCL : constant Interfaces.C.int := 8#002000#;
O_TRUNC : constant Interfaces.C.int := 8#001000#;
O_APPEND : constant Interfaces.C.int := 8#000010#;
DLL_OPTIONS : constant String := "";
SYMBOL_PREFIX : constant String := "";
end Util.Systems.Constants;
```
Fix O_CLOEXEC undefined in keystore-io-files.adb (win32) | ```ada
-- Generated by utildgen.c from system includes
with Interfaces.C;
package Util.Systems.Constants is
pragma Pure;
-- Flags used when opening a file with open/creat.
O_RDONLY : constant Interfaces.C.int := 8#000000#;
O_WRONLY : constant Interfaces.C.int := 8#000001#;
O_RDWR : constant Interfaces.C.int := 8#000002#;
O_CREAT : constant Interfaces.C.int := 8#000400#;
O_EXCL : constant Interfaces.C.int := 8#002000#;
O_TRUNC : constant Interfaces.C.int := 8#001000#;
O_APPEND : constant Interfaces.C.int := 8#000010#;
O_CLOEXEC : constant Interfaces.C.int := 0;
O_SYNC : constant Interfaces.C.int := 0;
O_DIRECT : constant Interfaces.C.int := 0;
DLL_OPTIONS : constant String := "";
SYMBOL_PREFIX : constant String := "";
end Util.Systems.Constants;
``` |
cdb7c8f7-c39f-4b32-9636-fe736f68907f | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- util-dates-iso8601 -- ISO8601 dates
-- Copyright (C) 2011, 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 Ada.Calendar;
package Util.Dates.ISO8601 is
-- Parses an ISO8601 date and return it as a calendar time.
-- Raises Constraint_Error if the date format is not recognized.
function Value (Date : in String) return Ada.Calendar.Time;
-- Return the ISO8601 date.
function Image (Date : in Ada.Calendar.Time) return String;
function Image (Date : in Date_Record) return String;
end Util.Dates.ISO8601;
```
Declare Precision_Type enumeration Declare new Image function | ```ada
-----------------------------------------------------------------------
-- util-dates-iso8601 -- ISO8601 dates
-- Copyright (C) 2011, 2013, 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.Calendar;
package Util.Dates.ISO8601 is
type Precision_Type is (YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, SUBSECOND);
-- Parses an ISO8601 date and return it as a calendar time.
-- Raises Constraint_Error if the date format is not recognized.
function Value (Date : in String) return Ada.Calendar.Time;
-- Return the ISO8601 date.
function Image (Date : in Ada.Calendar.Time) return String;
function Image (Date : in Date_Record) return String;
function Image (Date : in Ada.Calendar.Time;
Precision : in Precision_Type) return String;
function Image (Date : in Date_Record;
Precision : in Precision_Type) return String;
end Util.Dates.ISO8601;
``` |
ece883fa-dcae-4b2c-af08-fcd07c9555aa | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa -- Ada Web Application
-- Copyright (C) 2009 - 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.
-----------------------------------------------------------------------
-- = AWA Core ==
--
-- @include awa-applications.ads
-- @include awa-modules.ads
-- @include awa-permissions.ads
-- @include awa-events.ads
-- @include awa.xml
package AWA is
pragma Pure;
end AWA;
```
Include the AWA commands documentation | ```ada
-----------------------------------------------------------------------
-- awa -- Ada Web Application
-- Copyright (C) 2009 - 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.
-----------------------------------------------------------------------
-- = AWA Core ==
--
-- @include awa-applications.ads
-- @include awa-modules.ads
-- @include awa-permissions.ads
-- @include awa-events.ads
-- @include awa-commands.ads
-- @include awa.xml
package AWA is
pragma Pure;
end AWA;
``` |
9b04c754-a87f-46d1-9823-f54eabdcc280 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- util-events -- Events
-- Copyright (C) 2001, 2002, 2003, 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 Ada.Calendar;
package Util.Events is
type Event is tagged private;
-- Get the time identifying when the event was created.
function Get_Time (Ev : Event) return Ada.Calendar.Time;
type Event_Listener is limited interface;
private
type Event is tagged record
Date : Ada.Calendar.Time := Ada.Calendar.Clock;
end record;
end Util.Events;
```
Change the Event type to a limited type | ```ada
-----------------------------------------------------------------------
-- util-events -- Events
-- Copyright (C) 2001, 2002, 2003, 2009, 2010, 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.Calendar;
package Util.Events is
type Event is tagged limited private;
-- Get the time identifying when the event was created.
function Get_Time (Ev : Event) return Ada.Calendar.Time;
type Event_Listener is limited interface;
private
type Event is tagged limited record
Date : Ada.Calendar.Time := Ada.Calendar.Clock;
end record;
end Util.Events;
``` |
e479a07c-29bd-447a-8b21-c845c7a438da | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-votes-modules-tests -- Unit tests for vote service
-- 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;
with AWA.Tests;
package AWA.Votes.Modules.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new AWA.Tests.Test with record
Manager : AWA.Votes.Modules.Vote_Module_Access;
end record;
-- Test vote.
procedure Test_Vote_Up (T : in out Test);
end AWA.Votes.Modules.Tests;
```
Add unit test for undo vote | ```ada
-----------------------------------------------------------------------
-- awa-votes-modules-tests -- Unit tests for vote service
-- 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;
with AWA.Tests;
package AWA.Votes.Modules.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new AWA.Tests.Test with record
Manager : AWA.Votes.Modules.Vote_Module_Access;
end record;
-- Test vote.
procedure Test_Vote_Up (T : in out Test);
-- Test vote.
procedure Test_Vote_Undo (T : in out Test);
end AWA.Votes.Modules.Tests;
``` |
9d704fb1-7624-4bba-9377-3d435a1e49ce | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- core-factory -- Factory for UI Core Components
-- Copyright (C) 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 ASF.Factory;
package ASF.Components.Core.Factory is
use ASF;
-- Get the Core component factory.
function Definition return ASF.Factory.Factory_Bindings_Access;
end ASF.Components.Core.Factory;
```
Change the Definition function into a Register procedure | ```ada
-----------------------------------------------------------------------
-- core-factory -- Factory for UI Core Components
-- Copyright (C) 2009, 2010, 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 ASF.Factory;
package ASF.Components.Core.Factory is
-- Register the Core component factory.
procedure Register (Factory : in out ASF.Factory.Component_Factory);
end ASF.Components.Core.Factory;
``` |
0dbb46d2-a9da-4bc8-a744-34551b0ccbe5 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- serialize-io-json-tests -- Unit tests for JSON parser
-- 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 Util.Tests;
package Util.Serialize.IO.JSON.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Parse_Error (T : in out Test);
procedure Test_Parser (T : in out Test);
end Util.Serialize.IO.JSON.Tests;
```
Declare Test_Output and Write_Stream procedures | ```ada
-----------------------------------------------------------------------
-- serialize-io-json-tests -- Unit tests for JSON parser
-- Copyright (C) 2011, 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 Util.Serialize.IO.JSON.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Parse_Error (T : in out Test);
procedure Test_Parser (T : in out Test);
-- Generate some output stream for the test.
procedure Write_Stream (Stream : in out Util.Serialize.IO.Output_Stream'Class);
-- Test the JSON output stream generation.
procedure Test_Output (T : in out Test);
end Util.Serialize.IO.JSON.Tests;
``` |
781da78d-9709-42d4-9aaa-8bf3f52b5e1e | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- mat-types -- Global types
-- 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.IO_Exceptions;
with MAT.Commands;
with MAT.Targets;
with MAT.Consoles.Text;
with MAT.Readers.Streams.Sockets;
procedure Matp is
Target : MAT.Targets.Target_Type;
Console : aliased MAT.Consoles.Text.Console_Type;
Server : MAT.Readers.Streams.Sockets.Socket_Listener_Type;
begin
Target.Console (Console'Unchecked_Access);
Target.Initialize_Options;
MAT.Commands.Initialize_Files (Target);
Server.Start (Options.Address);
MAT.Commands.Interactive (Target);
Server.Stop;
exception
when Ada.IO_Exceptions.End_Error | MAT.Targets.Usage_Error =>
Server.Stop;
end Matp;
```
Update to call the target Start procedure | ```ada
-----------------------------------------------------------------------
-- mat-types -- Global types
-- 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.IO_Exceptions;
with MAT.Commands;
with MAT.Targets;
with MAT.Consoles.Text;
with MAT.Readers.Streams.Sockets;
procedure Matp is
Target : MAT.Targets.Target_Type;
Console : aliased MAT.Consoles.Text.Console_Type;
Server : MAT.Readers.Streams.Sockets.Socket_Listener_Type;
begin
Target.Console (Console'Unchecked_Access);
Target.Initialize_Options;
MAT.Commands.Initialize_Files (Target);
Target.Start;
MAT.Commands.Interactive (Target);
Server.Stop;
exception
when Ada.IO_Exceptions.End_Error | MAT.Targets.Usage_Error =>
Server.Stop;
end Matp;
``` |
fa8f21bc-491d-41c7-ad1f-5ca6ed850828 | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- awa-questions-services-tests -- Unit tests for question service
-- 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;
with AWA.Tests;
package AWA.Questions.Services.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new AWA.Tests.Test with record
Manager : AWA.Questions.Services.Question_Service_Access;
end record;
-- Test creation of a question.
procedure Test_Create_Question (T : in out Test);
-- Test list of questions.
procedure Test_List_Questions (T : in out Test);
end AWA.Questions.Services.Tests;
```
Add unit tests for the questionVote bean | ```ada
-----------------------------------------------------------------------
-- awa-questions-services-tests -- Unit tests for question service
-- 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;
with AWA.Tests;
package AWA.Questions.Services.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new AWA.Tests.Test with record
Manager : AWA.Questions.Services.Question_Service_Access;
end record;
-- Test creation of a question.
procedure Test_Create_Question (T : in out Test);
-- Test list of questions.
procedure Test_List_Questions (T : in out Test);
-- Test anonymous user voting for a question.
procedure Test_Question_Vote_Anonymous (T : in out Test);
-- Test voting for a question.
procedure Test_Question_Vote (T : in out Test);
private
-- Do a vote on a question through the question vote bean.
procedure Do_Vote (T : in out Test);
end AWA.Questions.Services.Tests;
``` |
0621e46a-d32b-4a87-873b-52ecbb7ca72a | {
"language": "Ada"
} | ```ada
-----------------------------------------------------------------------
-- mat-testsuite - MAT Testsuite
-- 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 MAT.Readers.Tests;
with MAT.Targets.Tests;
package body MAT.Testsuite is
Tests : aliased Util.Tests.Test_Suite;
function Suite return Util.Tests.Access_Test_Suite is
Result : constant Util.Tests.Access_Test_Suite := Tests'Access;
begin
MAT.Readers.Tests.Add_Tests (Result);
MAT.Targets.Tests.Add_Tests (Result);
return Result;
end Suite;
end MAT.Testsuite;
```
Add the stack frames unit tests | ```ada
-----------------------------------------------------------------------
-- mat-testsuite - MAT Testsuite
-- 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 MAT.Readers.Tests;
with MAT.Targets.Tests;
with MAT.Frames.Tests;
package body MAT.Testsuite is
Tests : aliased Util.Tests.Test_Suite;
function Suite return Util.Tests.Access_Test_Suite is
Result : constant Util.Tests.Access_Test_Suite := Tests'Access;
begin
MAT.Frames.Tests.Add_Tests (Result);
MAT.Readers.Tests.Add_Tests (Result);
MAT.Targets.Tests.Add_Tests (Result);
return Result;
end Suite;
end MAT.Testsuite;
``` |
2a8f14c0-aa14-4e71-9306-214dc4705cfd | {
"language": "Ada"
} | ```ada
```
Define a targets package for the Gtk UI | ```ada
-----------------------------------------------------------------------
-- mat-targets-gtkmat - Gtk target management
-- 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 Gtk.Widget;
with Gtkada.Builder;
package MAT.Targets.Gtkmat is
type Target_Type is new MAT.Targets.Target_Type with private;
-- Initialize the widgets and create the Gtk gui.
procedure Initialize_Widget (Target : in out Target_Type;
Widget : out Gtk.Widget.Gtk_Widget);
-- Create a process instance to hold and keep track of memory and other information about
-- the given process ID.
overriding
procedure Create_Process (Target : in out Target_Type;
Pid : in MAT.Types.Target_Process_Ref;
Path : in Ada.Strings.Unbounded.Unbounded_String;
Process : out Target_Process_Type_Access);
private
type Target_Type is new MAT.Targets.Target_Type with record
Builder : Gtkada.Builder.Gtkada_Builder;
end record;
end MAT.Targets.Gtkmat;
``` |
13db09d4-4e5a-4397-8a05-2521e0ffd366 | {
"language": "Ada"
} | ```ada
```
Implement the unit test on datasets | ```ada
-----------------------------------------------------------------------
-- 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;
``` |
c5bef43b-2193-4d19-bdbe-02259ffe5bab | {
"language": "Ada"
} | ```ada
```
Implement the Has_Directory and Peek_Directory operation for the Directory_Queue | ```ada
-----------------------------------------------------------------------
-- babel-files-queues -- File and directory queues
-- 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.Strings.Unbounded;
with Ada.Calendar;
with Ada.Directories;
with Ada.Containers.Vectors;
with Util.Encoders.SHA1;
with Util.Concurrent.Fifos;
with Util.Strings.Vectors;
with ADO;
with Babel.Base.Models;
package body Babel.Files.Queues is
-- ------------------------------
-- Returns true if there is a directory in the queue.
-- ------------------------------
function Has_Directory (Queue : in Directory_Queue) return Boolean is
begin
return not Queue.Directories.Is_Empty;
end Has_Directory;
-- ------------------------------
-- Get the next directory from the queue.
-- ------------------------------
procedure Peek_Directory (Queue : in out Directory_Queue;
Directory : out Directory_Type) is
begin
Directory := Queue.Directories.Last_Element;
Queue.Directories.Delete_Last;
end Peek_Directory;
end Babel.Files.Queues;
``` |
620b0cce-b8b5-4fdf-a86b-77edb0daf79b | {
"language": "Ada"
} | ```ada
```
Implement the generic procedure Wiki.Helpers.Parser to allow easily provide a Parser with various content types | ```ada
-----------------------------------------------------------------------
-- wiki-helpers-parser -- Generic procedure for the wiki parser
-- 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.Helpers;
with Wiki.Streams;
procedure Wiki.Helpers.Parser (Engine : in out Engine_Type;
Content : in Element_Type;
Doc : in out Wiki.Documents.Document) is
use type Wiki.Streams.Input_Stream_Access;
type Wide_Input is new Wiki.Streams.Input_Stream with record
Pos : Positive;
Len : Natural;
end record;
overriding
procedure Read (Buf : in out Wide_Input;
Token : out Wiki.Strings.WChar;
Is_Eof : out Boolean);
procedure Read (Buf : in out Wide_Input;
Token : out Wiki.Strings.WChar;
Is_Eof : out Boolean) is
begin
if Buf.Pos > Buf.Len then
Is_Eof := True;
Token := Wiki.Helpers.CR;
else
Token := Element (Content, Buf.Pos);
Buf.Pos := Buf.Pos + 1;
Is_Eof := False;
end if;
end Read;
Buffer : aliased Wide_Input;
begin
Buffer.Pos := 1;
Buffer.Len := Length (Content);
Parse (Engine, Buffer'Unchecked_Access, Doc);
end Wiki.Helpers.Parser;
``` |
1f3adc7d-d9bc-468c-9699-169c710209c0 | {
"language": "Ada"
} | ```ada
```
Change the UICounter to use the UIHtmlComponent base type | ```ada
-----------------------------------------------------------------------
-- awa-counters-components -- Counter UI component
-- 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 ASF.Factory;
with ASF.Contexts.Faces;
with ASF.Components.Html;
-- == Counter Component ==
--
package AWA.Counters.Components is
type UICounter is new ASF.Components.Html.UIHtmlComponent with private;
-- Render the counter component. Starts the DL/DD list and write the input
-- component with the possible associated error message.
overriding
procedure Encode_Begin (UI : in UICounter;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
-- Get the AWA Counter component factory.
function Definition return ASF.Factory.Factory_Bindings_Access;
private
type UICounter is new ASF.Components.Html.UIHtmlComponent with null record;
end AWA.Counters.Components;
``` |
15102544-0bbc-4791-b6b0-0845b05f5293 | {
"language": "Ada"
} | ```ada
```
Add the ASIS file $i | ```ada
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . I T E S T S --
-- --
-- S p e c --
-- --
-- Copyright (c) 1995-1999, 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 defines tests for defining if an Element based on the
-- given node should test Is_Implicit, Is_Inherited and Is_From_Instance
with Types; use Types;
package A4G.Itests is
function Is_Inherited_Discriminant (N : Node_Id) return Boolean;
-- Tests if N corresponds to the defining occurrence of an inherited
-- discriminant. N should be of N_Defining_Identifier kind
--
-- INCOMPLETE and INRELIABLE for now!
function Is_From_Instance (N : Node_Id) return Boolean;
-- Tests if N corresponds to an implicit or explicit construction from
-- the result of some generic instantiation (that is, from an expanded
-- generic template)
end A4G.Itests;
``` |
3f14c517-33b0-427f-b96f-4222e4c11213 | {
"language": "Ada"
} | ```ada
```
Refactor the HTML Text_IO stream into a generic package | ```ada
-----------------------------------------------------------------------
-- wiki-streams-html-stream -- Generic Wiki HTML output stream
-- Copyright (C) 2016, 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 Wiki.Strings;
generic
type Output_Stream is limited new Wiki.Streams.Output_Stream with private;
package Wiki.Streams.Html.Stream is
type Html_Output_Stream is limited new Output_Stream
and Html.Html_Output_Stream with private;
-- 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_Stream;
Name : in String;
Content : in Wiki.Strings.UString);
-- 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_Stream;
Name : in String;
Content : in Wide_Wide_String);
-- Start an XML element with the given name.
overriding
procedure Start_Element (Stream : in out Html_Output_Stream;
Name : in String);
-- Closes an XML element of the given name.
overriding
procedure End_Element (Stream : in out Html_Output_Stream;
Name : in String);
-- Write a text escaping any character as necessary.
overriding
procedure Write_Wide_Text (Stream : in out Html_Output_Stream;
Content : in Wiki.Strings.WString);
private
type Html_Output_Stream is limited new Output_Stream
and 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.Stream;
``` |
04cb6d99-9ec4-45fa-96bf-377abc206343 | {
"language": "Ada"
} | ```ada
```
Define the Readline package with the Get_Line operation | ```ada
-----------------------------------------------------------------------
-- readline -- A simple readline binding
-- 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 Interfaces;
package Readline is
-- Print the prompt and a read a line from the terminal.
-- Raise the Ada.IO_Exceptions.End_Error when the EOF is reached.
function Get_Line (Prompt : in String) return String;
end Readline;
``` |
7cc7cf1f-3fc7-4af2-82ec-61ef7162b8a3 | {
"language": "Ada"
} | ```ada
```
Add the ASIS file $i | ```ada
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT INTERFACE COMPONENTS --
-- --
-- A S I S . E X C E P T I O N 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. --
-- --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- 5 package Asis.Exceptions
------------------------------------------------------------------------------
------------------------------------------------------------------------------
package Asis.Exceptions is
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- ASIS exceptions are:
ASIS_Inappropriate_Context : exception;
------------------------------------------------------------------------------
-- Raised when ASIS is passed a Context value that is not appropriate for the
-- operation. This exception will typically indicate that a user error
-- has occurred within the application.
------------------------------------------------------------------------------
ASIS_Inappropriate_Container : exception;
------------------------------------------------------------------------------
-- Raised when ASIS is passed a Container value that is not appropriate for
-- the operation. This exception will typically indicate that a user error
-- has occurred within the application.
------------------------------------------------------------------------------
ASIS_Inappropriate_Compilation_Unit : exception;
------------------------------------------------------------------------------
-- Raised when ASIS is passed a Compilation_Unit value that is not
-- appropriate. This exception will typically indicate that a user
-- error has occurred within the application.
------------------------------------------------------------------------------
ASIS_Inappropriate_Element : exception;
------------------------------------------------------------------------------
-- Raised when ASIS is given an Element value that is not appropriate. This
-- exception will typically indicate that a user error has occurred within
-- the application.
------------------------------------------------------------------------------
ASIS_Inappropriate_Line : exception;
------------------------------------------------------------------------------
-- Raised when ASIS is given a Line value that is not appropriate.
------------------------------------------------------------------------------
ASIS_Inappropriate_Line_Number : exception;
------------------------------------------------------------------------------
-- Raised when ASIS is given a Line_Number value that is not appropriate.
-- This exception will typically indicate that a user error has occurred
-- within the application.
------------------------------------------------------------------------------
ASIS_Failed : exception;
------------------------------------------------------------------------------
-- This is a catch-all exception that may be raised for different reasons
-- in different ASIS implementations. All ASIS routines may raise ASIS_Failed
-- whenever they cannot normally complete their operation. This exception
-- will typically indicate a failure of the underlying ASIS implementation.
------------------------------------------------------------------------------
end Asis.Exceptions;
``` |
21bd88fb-1493-465e-b760-0db5b3224a70 | {
"language": "Ada"
} | ```ada
```
Implement the SIGINT interrupt handler with operations to install, check and clear the interrupt flag | ```ada
-----------------------------------------------------------------------
-- mat-interrupts - SIGINT management to stop long running commands
-- 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.Interrupts;
with Ada.Interrupts.Names;
with Util.Log.Loggers;
package body MAT.Interrupts is
pragma Interrupt_State (Name => Ada.Interrupts.Names.SIGINT,
State => USER);
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("MAT.Interrupts");
protected Interrupts is
procedure Interrupt;
pragma Interrupt_Handler (Interrupt);
function Is_Interrupted return Boolean;
procedure Clear;
private
Interrupted : Boolean;
end Interrupts;
protected body Interrupts is
function Is_Interrupted return Boolean is
begin
return Interrupted;
end Is_Interrupted;
procedure Clear is
begin
Interrupted := False;
end Clear;
procedure Interrupt is
begin
Interrupted := True;
Log.Info ("SIGINT signal received");
end Interrupt;
end Interrupts;
-- ------------------------------
-- Install the SIGINT handler.
-- ------------------------------
procedure Install is
begin
Ada.Interrupts.Attach_Handler (Interrupts.Interrupt'Access,
Ada.Interrupts.Names.SIGINT);
Log.Info ("Interrupt handler for SIGINT is installed");
end Install;
-- ------------------------------
-- Reset the interrupted flag.
-- ------------------------------
procedure Clear is
begin
Interrupts.Clear;
end Clear;
-- ------------------------------
-- Check if we have been interrupted.
-- ------------------------------
function Is_Interrupted return Boolean is
begin
return Interrupts.Is_Interrupted;
end Is_Interrupted;
end MAT.Interrupts;
``` |
e4252c9e-673d-4b27-8273-7eed1083eee5 | {
"language": "Ada"
} | ```ada
```
Implement the variables plugin to set variables from wiki text | ```ada
-----------------------------------------------------------------------
-- wiki-plugins-variables -- Variables plugin
-- 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 Wiki.Filters.Variables;
package body Wiki.Plugins.Variables is
-- ------------------------------
-- Set or update a variable in the `Wiki.Filters.Variable` filter.
-- ------------------------------
overriding
procedure Expand (Plugin : in out Variable_Plugin;
Document : in out Wiki.Documents.Document;
Params : in out Wiki.Attributes.Attribute_List;
Context : in Plugin_Context) is
pragma Unreferenced (Plugin, Document);
begin
if Wiki.Attributes.Length (Params) >= 3 then
declare
First : Wiki.Attributes.Cursor := Wiki.Attributes.First (Params);
Second : Wiki.Attributes.Cursor;
begin
Wiki.Attributes.Next (First);
Second := First;
Wiki.Attributes.Next (Second);
Wiki.Filters.Variables.Add_Variable (Context.Filters,
Wiki.Attributes.Get_Wide_Value (First),
Wiki.Attributes.Get_Wide_Value (Second));
end;
end if;
end Expand;
end Wiki.Plugins.Variables;
``` |
08db2a7a-b39b-41da-bc3b-f6de12822885 | {
"language": "Ada"
} | ```ada
```
Add navigation rule unit test | ```ada
-----------------------------------------------------------------------
-- 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;
``` |
a7a244af-23c5-46d9-8d90-bb26226b2656 | {
"language": "Ada"
} | ```ada
```
Implement new test for Parse_Form and register it for execution | ```ada
-----------------------------------------------------------------------
-- util-properties-form-tests -- Test reading JSON 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.Test_Caller;
with Util.Files;
package body Util.Properties.Form.Tests is
package Caller is new Util.Test_Caller (Test, "Properties.Properties.Form");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Properties.Form.Parse_Form",
Test_Parse_Form'Access);
end Add_Tests;
-- Test loading a JSON file into a properties object.
procedure Test_Parse_Form (T : in out Test) is
procedure Check (Name : in String;
Value : in String);
P : Util.Properties.Manager;
procedure Check (Name : in String;
Value : in String) is
begin
T.Assert (P.Exists (Name), "Missing property: " & Name);
Util.Tests.Assert_Equals (T, Value, String '(P.Get (Name)),
"Invalid property: " & Name);
end Check;
Path : constant String := Util.Tests.Get_Test_Path ("regtests/files/test-1.form");
S : Ada.Strings.Unbounded.Unbounded_String;
begin
Util.Files.Read_File (Path, S);
Util.Properties.Form.Parse_Form (P, Ada.Strings.Unbounded.To_String (S));
Check ("access_token", "97356");
Check ("token_type", "bearer");
Check ("refresh_token_expires_in", "15724800");
Check ("refresh_token", "r1.714b6");
Check ("scope", "");
Check ("scope", "");
end Test_Parse_Form;
end Util.Properties.Form.Tests;
``` |
8fe3d8ac-2067-417f-8289-90ba1450bb3b | {
"language": "Ada"
} | ```ada
```
Implement a simple unit test for the Find operation | ```ada
-----------------------------------------------------------------------
-- babel-base-users-tests - Unit tests for babel users
-- 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.Test_Caller;
package body Babel.Base.Users.Tests is
use type Util.Strings.Name_Access;
package Caller is new Util.Test_Caller (Test, "Base.Users");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Babel.Base.Users.Find",
Test_Find'Access);
end Add_Tests;
-- ------------------------------
-- Test the Find function resolving some existing user.
-- ------------------------------
procedure Test_Find (T : in out Test) is
Db : Babel.Base.Users.Database;
User : User_Type;
begin
User := Db.Find (0, 0);
T.Assert (User.Name /= null, "User uid=0 was not found");
T.Assert (User.Group /= null, "User gid=0 was not found");
Util.Tests.Assert_Equals (T, "root", User.Name.all, "Invalid root user name");
Util.Tests.Assert_Equals (T, "root", User.Group.all, "Invalid root group name");
end Test_Find;
end Babel.Base.Users.Tests;
``` |
6219d82e-c174-4435-b502-4f3ba691d43e | {
"language": "Ada"
} | ```ada
```
Implement the widget component factory | ```ada
-----------------------------------------------------------------------
-- 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.Views.Nodes;
with ASF.Components.Base;
with ASF.Components.Widgets.Inputs;
package body ASF.Components.Widgets.Factory is
use ASF.Components.Base;
function Create_Input return UIComponent_Access;
-- -------------------------
-- ------------------------------
-- Create a UIFile component
-- ------------------------------
function Create_Input return UIComponent_Access is
begin
return new ASF.Components.Widgets.Inputs.UIInput;
end Create_Input;
use ASF.Views.Nodes;
URI : aliased constant String := "http://code.google.com/p/ada-asf/widget";
INPUT_TEXT_TAG : aliased constant String := "inputText";
Widget_Bindings : aliased constant ASF.Factory.Binding_Array
:= (1 => (Name => INPUT_TEXT_TAG'Access,
Component => Create_Input'Access,
Tag => Create_Component_Node'Access)
);
Core_Factory : aliased constant ASF.Factory.Factory_Bindings
:= (URI => URI'Access, Bindings => Widget_Bindings'Access);
-- ------------------------------
-- Get the widget component factory.
-- ------------------------------
function Definition return ASF.Factory.Factory_Bindings_Access is
begin
return Core_Factory'Access;
end Definition;
end ASF.Components.Widgets.Factory;
``` |
78aba574-dd8d-4b67-bf2c-0f5ebd99e003 | {
"language": "Ada"
} | ```ada
```
Implement the MAT.Events.Tools package with the Find operation | ```ada
-----------------------------------------------------------------------
-- mat-events-tools - Profiler Events Description
-- 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 MAT.Events.Tools is
-- ------------------------------
-- Find in the list the first event with the given type.
-- Raise <tt>Not_Found</tt> if the list does not contain such event.
-- ------------------------------
function Find (List : in Target_Event_Vector;
Kind : in Probe_Index_Type) return Target_Event_Type is
Iter : Target_Event_Cursor := List.First;
Event : Target_Event_Type;
begin
while Target_Event_Vectors.Has_Element (Iter) loop
Event := Target_Event_Vectors.Element (Iter);
if Event.Index = Kind then
return Event;
end if;
Target_Event_Vectors.Next (Iter);
end loop;
raise Not_Found;
end Find;
end MAT.Events.Tools;
``` |
cc256a7d-d416-4e81-a8c8-04fd431df917 | {
"language": "Ada"
} | ```ada
```
Package to read the memory events | ```ada
-----------------------------------------------------------------------
-- Memory Events - Definition and Analysis of memory 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 MAT.Types;
with MAT.Events;
-- with MAT.Ipc;
with Util.Events;
with MAT.Readers;
with MAT.Memory.Targets;
-- with MAT.Memory.Clients;
-- with MAT.Ipc.Clients;
-- with MAT.Events; use MAT.Events;
package MAT.Memory.Readers is
type Memory_Servant is new MAT.Readers.Reader_Base with record
Data : MAT.Memory.Targets.Client_Memory;
-- Slots : Client_Memory_Ref;
-- Impl : Client_Memory_Ref;
end record;
-- The memory servant is a proxy for the generic communication
-- channel to process incomming events (such as memory allocations).
overriding
procedure Dispatch (For_Servant : in out Memory_Servant;
Id : in MAT.Events.Internal_Reference;
Params : in MAT.Events.Const_Attribute_Table_Access;
Msg : in out MAT.Readers.Message);
procedure Bind (For_Servant : in out Memory_Servant);
-- Bind the servant with the object adapter to register the
-- events it recognizes.
end MAT.Memory.Readers;
``` |
c408e0c5-9318-430e-ba72-65658b9807af | {
"language": "Ada"
} | ```ada
```
Implement the Rest definition package to dispatch the request to the API handler | ```ada
-----------------------------------------------------------------------
-- 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.Definition is
overriding
procedure Dispatch (Handler : in Descriptor;
Req : in out ASF.Rest.Request'Class;
Reply : in out ASF.Rest.Response'Class) is
Object : Object_Type;
begin
Handler.Handler (Object, Req, Reply);
end Dispatch;
package body Definition is
P : aliased String := Pattern;
begin
Instance.Method := Method;
Instance.Permission := Permission;
Instance.Handler := Handler;
Instance.Pattern := P'Access;
ASF.Rest.Register (Entries, Instance'Access);
end Definition;
end ASF.Rest.Definition;
``` |
3d6a3f85-2a4c-49dd-ad74-d812d59ffbbc | {
"language": "Ada"
} | ```ada
```
Add unit tests for MAT.Expressions | ```ada
-----------------------------------------------------------------------
-- mat-expressions-tests -- Unit tests for MAT expressions
-- 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 MAT.Expressions.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Parse_Expression (T : in out Test);
end MAT.Expressions.Tests;
``` |
bd15024a-c375-4485-83bf-0377597caecc | {
"language": "Ada"
} | ```ada
```
Define the generic package for a counter definition | ```ada
-----------------------------------------------------------------------
-- awa-counters-definition -- Counter 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.
-----------------------------------------------------------------------
-- The <tt>AWA.Counters.Definition</tt> package is instantiated for each counter definition.
generic
Table : ADO.Schemas.Class_Mapping_Access;
Field : String;
package AWA.Counters.Definition is
Def_Name : aliased constant String := Field;
package Def is new Counter_Arrays.Definition (Counter_Def '(Table, Def_Name'Access));
-- Get the counter definition index.
function Index return Counter_Index_Type renames Def.Kind;
end AWA.Counters.Definition;
``` |
760ead7a-3c8a-4b70-81d9-7fe2a55185aa | {
"language": "Ada"
} | ```ada
```
Test that the size of a view converted object is determined by the target type, not the source type. | ```ada
-- RUN: %llvmgcc -c %s -o /dev/null
procedure VCE is
S : String (1 .. 2);
B : Character := 'B';
begin
S := 'A' & B;
end;
``` |
f41312e2-e6ca-4f33-8e8f-483f7bee83af | {
"language": "Ada"
} | ```ada
```
Define the gravatar UI component | ```ada
-----------------------------------------------------------------------
-- components-widgets-gravatars -- Gravatar 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.Components.Html;
with ASF.Contexts.Faces;
package ASF.Components.Widgets.Gravatars is
-- Given an Email address, return the Gravatar link to the user image.
-- (See http://en.gravatar.com/site/implement/hash/ and
-- http://en.gravatar.com/site/implement/images/)
function Get_Link (Email : in String;
Secure : in Boolean := False) return String;
-- ------------------------------
-- UIGravatar
-- ------------------------------
-- The <b>UIGravatar</b> component displays a small image whose link is created
-- from a user email address.
type UIGravatar is new ASF.Components.Html.UIHtmlComponent with null record;
-- Render an image with the source link created from an email address to the Gravatars service.
overriding
procedure Encode_Begin (UI : in UIGravatar;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
end ASF.Components.Widgets.Gravatars;
``` |