doc_id
stringlengths
36
36
metadata
dict
input
stringlengths
28
4.3k
output
stringlengths
11
5.45k
0bff38bc-bb53-47ca-a484-64d24da860bd
{ "language": "ABAP" }
```abap *&---------------------------------------------------------------------* *& Report ZUSR_LISP_REPL *& https://github.com/mydoghasworms/abap-lisp *& Simple REPL for Lisp Interpreter written in ABAP *& Martin Ceronio, June 2015 *& [email protected] *&---------------------------------------------------------------------* report zusr_lisp_repl line-size 999. include zlib_lisp. data: lr_int type ref to lcl_lisp_interpreter. "The Lisp interpreter parameters: input type string lower case. parameters: output type string lower case. at selection-screen output. * Make result field output-only loop at screen. if screen-name = 'OUTPUT'. screen-input = 0. modify screen. endif. endloop. at selection-screen. * Initialize interpreter if not done yet if lr_int is not bound. create object lr_int. endif. * Evaluate given code output = lr_int->eval_source( input ). clear input. load-of-program. * Hitting execute gets us back to this event and initializes the interpreter, * so we preferably want to avoid that happening inadvertently: perform insert_into_excl(rsdbrunt) using: 'ONLI', 'SPOS', 'PRIN', 'SJOB'.``` Add runtime measurement to REPL
```abap *&---------------------------------------------------------------------* *& Report ZUSR_LISP_REPL *& https://github.com/mydoghasworms/abap-lisp *& Simple REPL for Lisp Interpreter written in ABAP *& Martin Ceronio, June 2015 *& [email protected] *&---------------------------------------------------------------------* report zusr_lisp_repl line-size 999. include zlib_lisp. data: lr_int type ref to lcl_lisp_interpreter. "The Lisp interpreter data: rt_begin type i. data: rt_end type i. parameters: input type string lower case. parameters: output type string lower case. parameters: runtime type string lower case. at selection-screen output. * Make result field output-only loop at screen. if screen-name = 'OUTPUT' or screen-name = 'RUNTIME'. screen-input = 0. if screen-name = 'RUNTIME'. screen-display_3d = 0. endif. modify screen. endif. endloop. at selection-screen. * Initialize interpreter if not done yet if lr_int is not bound. create object lr_int. endif. * Evaluate given code get RUN TIME FIELD rt_begin. output = lr_int->eval_source( input ). get RUN TIME FIELD rt_end. clear input. runtime = |{ rt_end - rt_begin } microseconds|. load-of-program. * Hitting execute gets us back to this event and initializes the interpreter, * so we preferably want to avoid that happening inadvertently: perform insert_into_excl(rsdbrunt) using: 'ONLI', 'SPOS', 'PRIN', 'SJOB'.```
ba9d1535-10d1-4824-8ff1-3ce77d19a61a
{ "language": "ActionScript" }
```actionscript package { import stdio.Sprite [SWF(width=0, height=0)] public class flash_test extends Sprite { public function main(): void { test_body() } } } ``` Add colors to Flash test to ease debugging.
```actionscript package { import stdio.Sprite [SWF(width=100, height=100)] public class flash_test extends Sprite { public function flash_test(): void { graphics.beginFill(0xff0000) graphics.drawRect(10, 10, 80, 80) graphics.endFill() } public function main(): void { graphics.beginFill(0x0000ff) graphics.drawRect(30, 30, 40, 40) graphics.endFill() test_body() } } } ```
0c15c298-39eb-4d09-a9d0-16f9e064f004
{ "language": "ActionScript" }
```actionscript /* # # Copyright (c) 2009 rPath, Inc. # # This program is distributed under the terms of the MIT License as found # in a file called LICENSE. If it is not present, the license # is always available at http://www.opensource.org/licenses/mit-license.php. # # This program is distributed in the hope that it will be useful, but # without any warranty; without even the implied warranty of merchantability # or fitness for a particular purpose. See the MIT License for full details. */ package com.rpath.raf.views { import mx.core.UIComponent; import mx.events.ValidationResultEvent; import spark.components.Group; public class CompoundInputItem extends Group { public function CompoundInputItem() { super(); // force height computation minHeight = 0; } [Bindable] public var inputFields:Array; public override function validationResultHandler(event:ValidationResultEvent):void { // let our specific input controls mark themselves appropriately for each (var elem:UIComponent in inputFields) { elem.validationResultHandler(event); } // propagate events beyond ourselves super.validationResultHandler(event); } } }``` Handle null in validation elem iteration
```actionscript /* # # Copyright (c) 2009 rPath, Inc. # # This program is distributed under the terms of the MIT License as found # in a file called LICENSE. If it is not present, the license # is always available at http://www.opensource.org/licenses/mit-license.php. # # This program is distributed in the hope that it will be useful, but # without any warranty; without even the implied warranty of merchantability # or fitness for a particular purpose. See the MIT License for full details. */ package com.rpath.raf.views { import mx.core.UIComponent; import mx.events.ValidationResultEvent; import spark.components.Group; public class CompoundInputItem extends Group { public function CompoundInputItem() { super(); // force height computation minHeight = 0; } [Bindable] public var inputFields:Array; public override function validationResultHandler(event:ValidationResultEvent):void { // let our specific input controls mark themselves appropriately for each (var elem:UIComponent in inputFields) { if (elem) elem.validationResultHandler(event); } // propagate events beyond ourselves super.validationResultHandler(event); } } }```
077979a5-f824-4a44-bc19-f292ead05ec1
{ "language": "ActionScript" }
```actionscript package io.github.jwhile.impetus { import flash.media.Sound; import flash.media.SoundChannel; public class ImpetusSound { private var url:String; private var sound:Sound; private var channels:Vector.<SoundChannel>; public function ImpetusSound(url:String):void { this.url = url; this.sound = new Sound(); this.channels = new Vector.<SoundChannel>; } } } ``` Load sound directly on constructor
```actionscript package io.github.jwhile.impetus { import flash.media.Sound; import flash.media.SoundChannel; import flash.net.URLRequest; public class ImpetusSound { private var sound:Sound; private var channels:Vector.<SoundChannel>; public function ImpetusSound(url:String):void { this.sound = new Sound(); this.channels = new Vector.<SoundChannel>; this.sound.load(new URLRequest(url)); } } } ```
0235b687-f244-43f3-8008-ddaea90dfe92
{ "language": "ActionScript" }
```actionscript package org.flexunit.experimental.theories.internals.cases { import org.flexunit.Assert; import org.flexunit.experimental.theories.internals.ParameterizedAssertionError; public class ParameterizedAssertionErrorCase { //TODO: Ensure that these tests and this test case are being implemented correctly. //It is currently impossible to test the stringValueOf function. [Test(description="Ensure that the ParameterizedAssertionError constructor is correctly assigning parameter values")] public function constructorTest():void { var targetException:Error = new Error(); var methodName:String = "methodName"; var params:Array = new Array("valueOne", "valueTwo"); var parameterizedAssertionError:ParameterizedAssertionError = new ParameterizedAssertionError(targetException, methodName, "valueOne", "valueTwo"); var message:String = methodName + " " + params.join( ", " ); Assert.assertEquals( message, parameterizedAssertionError.message); Assert.assertEquals( targetException, parameterizedAssertionError.targetException ); } [Test(description="Ensure that the join function is correctly joining the delimiter to the other parameters")] public function joinTest():void { var delimiter:String = ", "; var params:Array = new Array("valueOne", "valueTwo", "valueThree"); var message:String = params.join( delimiter ); Assert.assertEquals( message, ParameterizedAssertionError.join(delimiter, "valueOne", "valueTwo", "valueThree") ); } } }``` Set test to ignore while stack trace is still under investigation
```actionscript package org.flexunit.experimental.theories.internals.cases { import org.flexunit.Assert; import org.flexunit.experimental.theories.internals.ParameterizedAssertionError; public class ParameterizedAssertionErrorCase { //TODO: Ensure that these tests and this test case are being implemented correctly. //It is currently impossible to test the stringValueOf function. [Ignore("Currently Ignoring Test as this functionality is under investigation due to Max stack overflow issue")] [Test(description="Ensure that the ParameterizedAssertionError constructor is correctly assigning parameter values")] public function constructorTest():void { var targetException:Error = new Error(); var methodName:String = "methodName"; var params:Array = new Array("valueOne", "valueTwo"); var parameterizedAssertionError:ParameterizedAssertionError = new ParameterizedAssertionError(targetException, methodName, "valueOne", "valueTwo"); var message:String = methodName + " " + params.join( ", " ); Assert.assertEquals( message, parameterizedAssertionError.message); Assert.assertEquals( targetException, parameterizedAssertionError.targetException ); } [Test(description="Ensure that the join function is correctly joining the delimiter to the other parameters")] public function joinTest():void { var delimiter:String = ", "; var params:Array = new Array("valueOne", "valueTwo", "valueThree"); var message:String = params.join( delimiter ); Assert.assertEquals( message, ParameterizedAssertionError.join(delimiter, "valueOne", "valueTwo", "valueThree") ); } } }```
05461e39-8bad-4e2f-8f2f-db308a3da44b
{ "language": "ActionScript" }
```actionscript import Drawable; import Lobe; import Core; class Brain{ static var brain = new Array(); var mSelectionManager:SelectionManager; static function makenewlobe(){ var newmov=(new Lobe(_root,_root.getNextHighestDepth())); var topleft = new Point(100,40); var botright = new Point(200,140); newmov.commitBox(topleft, botright, 0); var keyListener = {}; keyListener.onKeyDown = function() { var k = Key.getCode(); if(k == Key.DELETEKEY){ Brain.makenewlobe(); } }; } function Brain (root_mc:MovieClip) { mSelectionManager = new SelectionManager(root_mc); } } ``` Delete is now a non-core function
```actionscript import Drawable; import Lobe; import Core; class Brain{ static var brain = new Array(); var mSelectionManager:SelectionManager; static function makenewlobe(){ var newmov=(new Lobe(_root,_root.getNextHighestDepth())); var topleft = new Point(100,40); var botright = new Point(200,140); newmov.commitBox(topleft, botright, 0); } function Brain (root_mc:MovieClip) { mSelectionManager = new SelectionManager(root_mc); var keyListener = {}; keyListener.onKeyDown = function() { var k = Key.getCode(); if(k == Key.DELETEKEY){ Brain.makenewlobe(); } }; Key.addListener( keyListener ); } } ```
80f13bbe-60ff-4003-8b24-240cd7cbfb91
{ "language": "ActionScript" }
```actionscript ``` Add a roadmap (of sorts)
```actionscript // [ ] Variable declaration let name: type = expression; // [ ] Basic types (arrow) /* byte (8-bit, unsigned) bool (1-bit[*]) int8 int16 int32 int64 int128 uint8 uint16 uint32 uint64 uint128 intptr (size of a pointer, signed) uintptr (size of a pointer, unsigned) char (32-bit, unsigned) float16 float32 float64 float128 */ // [ ] Expressions // [ ] - Add // [ ] - Subtract // [ ] - Multiply // [ ] - Divide // [ ] - Modulo // [ ] - Logical And // [ ] - Logical Or // [ ] - Logical Not // [ ] - Relational GT // [ ] - Relational GE // [ ] - Relational LT // [ ] - Relational LE // [ ] - Relational And // [ ] - Relational Or // [ ] - Bitwise And // [ ] - Bitwise Or // [ ] - Bitwise Xor // [ ] - Bitwise Not // [ ] Pointers // [ ] - Type // [ ] - Address Of // [ ] - Dereference // [ ] Cast // [ ] Function declaration def main() { } // [ ] Extern function declaration extern def puts(s: *byte); // [ ] Extern function declaration w/ABI extern "stdcall" def CreateWindowExA(); // [ ] Function call (extern AND local) main(); puts("Hello"); // [ ] Extern import extern import "stdint.h"; // [ ] Module (namespace) module cstdint { extern import "stdint.h"; } // [ ] c module (built-in) import "c"; /* // [ ] Basic types (in C) c.char c.uchar c.schar c.int c.uint c.short c.ushort c.long c.ulong c.float c.double c.ldouble */ // [ ] BigInt int // (∞-bit, signed) ```
2141180a-7f2b-4e06-bf21-df3e079f63e2
{ "language": "ActionScript" }
```actionscript // // $Id$ // // Narya library - tools for developing networked games // Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved // http://www.threerings.net/code/narya/ // // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation; either version 2.1 of the License, or // (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA package com.threerings.crowd.data { public class ManagerCaller { public function ManagerCaller (plobj :PlaceObject) { _plobj = plobj; } /** * Called to call a method on the manager. */ public function invoke (method :String, args :Array = null) :void { _plobj.postMessage(method, args); } /** The place object we're thingy-ing for. */ protected var _plobj :PlaceObject; } } ``` Change this instance back. Varargs are still a nightmare and should generally be avoided, but nobody's going to override this method and we're always calling a regular method on the server, not a varargs method.
```actionscript // // $Id$ // // Narya library - tools for developing networked games // Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved // http://www.threerings.net/code/narya/ // // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation; either version 2.1 of the License, or // (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA package com.threerings.crowd.data { public class ManagerCaller { public function ManagerCaller (plobj :PlaceObject) { _plobj = plobj; } /** * Called to call a method on the manager. */ public function invoke (method :String, ... args) :void { _plobj.postMessage(method, args); } /** The place object we're thingy-ing for. */ protected var _plobj :PlaceObject; } } ```
a7cc2552-a887-45db-b838-84826fbc178f
{ "language": "ActionScript" }
```actionscript package com.threerings.flex { import mx.containers.HBox; import mx.controls.Label; import mx.controls.sliderClasses.Slider; import mx.events.SliderEvent; /** * A simple component that displays a label to the left of a slider. */ public class LabeledSlider extends HBox { /** The slider, all public and accessable. Don't fuck it up! */ public var slider :Slider; /** * Create a LabeledSlider holding the specified slider. */ public function LabeledSlider (slider :Slider) { _label = new Label(); _label.text = String(slider.value); addChild(_label); this.slider = slider; slider.showDataTip = false; // because we do it... addChild(slider); slider.addEventListener(SliderEvent.CHANGE, handleSliderChange, false, 0, true); } protected function handleSliderChange (event :SliderEvent) :void { _label.text = String(event.value); } protected var _label :Label; } } ``` Clean up my comment, this is in a public API (and my comment wasn't helpful).
```actionscript package com.threerings.flex { import mx.containers.HBox; import mx.controls.Label; import mx.controls.sliderClasses.Slider; import mx.events.SliderEvent; /** * A simple component that displays a label to the left of a slider. */ public class LabeledSlider extends HBox { /** The actual slider. */ public var slider :Slider; /** * Create a LabeledSlider holding the specified slider. */ public function LabeledSlider (slider :Slider) { _label = new Label(); _label.text = String(slider.value); addChild(_label); this.slider = slider; slider.showDataTip = false; // because we do it... addChild(slider); slider.addEventListener(SliderEvent.CHANGE, handleSliderChange, false, 0, true); } protected function handleSliderChange (event :SliderEvent) :void { _label.text = String(event.value); } protected var _label :Label; } } ```
fffbafc4-6033-4f3d-9a02-cec0393e4ffc
{ "language": "ActionScript" }
```actionscript package org.denivip.osmf.utils { import org.osmf.utils.URL; public class Utils { public static function createFullUrl(rootUrl:String, url:String):String{ if(url.search(/(ftp|file|https?):\/\/\/?/) == 0) return url; // other manipulations :) if(url.charAt(0) == '/'){ return URL.getRootUrl(rootUrl) + url; } if(rootUrl.lastIndexOf('/') != rootUrl.length) rootUrl += '/'; return rootUrl + url; } } }``` Fix issue where check for final slash was comparing zero-based index with length
```actionscript package org.denivip.osmf.utils { import org.osmf.utils.URL; public class Utils { public static function createFullUrl(rootUrl:String, url:String):String { if(url.search(/(ftp|file|https?):\/\/\/?/) == 0) return url; // other manipulations :) if(url.charAt(0) == '/'){ return URL.getRootUrl(rootUrl) + url; } if(rootUrl.lastIndexOf('/') != rootUrl.length - 1) rootUrl += '/'; return rootUrl + url; } } }```
9b8191e7-e2d7-4d15-8e5c-dec651ba5a0b
{ "language": "ActionScript" }
```actionscript package com.threerings.util { import flash.net.URLRequest; //import flash.net.navigateToURL; // function import public class NetUtil { /** * Convenience method to load a web page in the browser window without * having to worry about SecurityErrors in various conditions. */ public static function navigateToURL ( url :String, preferSameWindowOrTab :Boolean = true) :void { var ureq :URLRequest = new URLRequest(url); if (preferSameWindowOrTab) { try { flash.net.navigateToURL(ureq, "_self"); return; } catch (err :SecurityError) { // ignore; fall back to using a blank window, below... } } // open in a blank window try { flash.net.navigateToURL(ureq); } catch (err :SecurityError) { Log.getLog(NetUtil).warning( "Unable to navigate to URL [e=" + err + "]."); } } } } ``` Return true if we succeeded.
```actionscript package com.threerings.util { import flash.net.URLRequest; //import flash.net.navigateToURL; // function import public class NetUtil { /** * Convenience method to load a web page in the browser window without * having to worry about SecurityErrors in various conditions. * * @return true if the url was unable to be loaded. */ public static function navigateToURL ( url :String, preferSameWindowOrTab :Boolean = true) :Boolean { var ureq :URLRequest = new URLRequest(url); if (preferSameWindowOrTab) { try { flash.net.navigateToURL(ureq, "_self"); return true; } catch (err :SecurityError) { // ignore; fall back to using a blank window, below... } } // open in a blank window try { flash.net.navigateToURL(ureq); return true; } catch (err :SecurityError) { Log.getLog(NetUtil).warning( "Unable to navigate to URL [e=" + err + "]."); } return false; // failure! } } } ```
2dd74d66-7ae0-4f68-93f9-623fdb972fc3
{ "language": "ActionScript" }
```actionscript package laml.display { import flash.display.DisplayObject; import flash.display.Sprite; public class Skin extends Sprite implements ISkin { public function getBitmapByName(alias:String):DisplayObject { if(hasOwnProperty(alias)) { return new this[alias]() as DisplayObject; } return null; } } }``` Put MX dependencies in skin
```actionscript package laml.display { import flash.display.DisplayObject; import flash.display.Sprite; import mx.core.BitmapAsset; import mx.core.FontAsset; import mx.core.IFlexAsset; import mx.core.IFlexDisplayObject; import mx.core.SpriteAsset; public class Skin extends Sprite implements ISkin { private var bitmapAsset:BitmapAsset; private var fontAsset:FontAsset; private var iFlexAsset:IFlexAsset; private var iFlexDisplayObject:IFlexDisplayObject; private var spriteAsset:SpriteAsset; public function getBitmapByName(alias:String):DisplayObject { if(hasOwnProperty(alias)) { return new this[alias]() as DisplayObject; } return null; } } }```
9fe8b35a-e78c-4ca4-ad8b-7c980b33da89
{ "language": "ActionScript" }
```actionscript package Components { [Bindable] public class Association { public var associatedNode:String; public var associatedLink:String; public var operatorIndex:int; public function Association(associatedNode:String,associatedLink:String,operatorIndex:int) { this.associatedLink = associatedLink; this.associatedNode = associatedNode; this.operatorIndex = operatorIndex; } } }``` Order vairable added todecide order of association
```actionscript package Components { [Bindable] public class Association { public var associatedNode:String; public var associatedLink:String; public var operatorIndex:int; public var order:int=0; public function Association(associatedNode:String,associatedLink:String,operatorIndex:int,order:int) { this.associatedLink = associatedLink; this.associatedNode = associatedNode; this.operatorIndex = operatorIndex; this.order=order; } } }```
afc24d9a-1822-4195-b21c-dc6bece1fb46
{ "language": "ActionScript" }
```actionscript package org.osflash.signals { import asunit4.ui.MinimalRunnerUI; import org.osflash.signals.AllTests; public class AllTestsRunner extends MinimalRunnerUI { public function AllTestsRunner() { run(org.osflash.signals.AllTests); } } } ``` Put [SWF] tag in test runner app.
```actionscript package org.osflash.signals { import asunit4.ui.MinimalRunnerUI; import org.osflash.signals.AllTests; [SWF(width='1000', height='800', backgroundColor='#333333', frameRate='31')] public class AllTestsRunner extends MinimalRunnerUI { public function AllTestsRunner() { run(org.osflash.signals.AllTests); } } } ```
1c8b9b02-f55c-4c0c-a6cd-d23fcfc2acb0
{ "language": "ActionScript" }
```actionscript package com.axis.rtspclient { import flash.events.Event; import flash.external.ExternalInterface; import flash.utils.ByteArray; public class NALU extends Event { public static const NEW_NALU:String = "NEW_NALU"; private var data:ByteArray; public var ntype:uint; public var nri:uint; public var timestamp:uint; public var bodySize:uint; public function NALU(ntype:uint, nri:uint, data:ByteArray, timestamp:uint) { super(NEW_NALU); this.data = data; this.ntype = ntype; this.nri = nri; this.timestamp = timestamp; this.bodySize = data.bytesAvailable; } public function appendData(idata:ByteArray):void { ByteArrayUtils.appendByteArray(data, idata); this.bodySize = data.bytesAvailable; } public function isIDR():Boolean { return (5 === ntype); } public function writeSize():uint { return 2 + 2 + 1 + data.bytesAvailable; } public function writeStream(output:ByteArray):void { output.writeUnsignedInt(data.bytesAvailable + 1); // NALU length + header output.writeByte((0x0 & 0x80) | (nri & 0x60) | (ntype & 0x1F)); // NAL header output.writeBytes(data, data.position); } } } ``` Implement getPayload() method to extract SPS/PPS bytes
```actionscript package com.axis.rtspclient { import flash.events.Event; import flash.external.ExternalInterface; import flash.utils.ByteArray; public class NALU extends Event { public static const NEW_NALU:String = "NEW_NALU"; private var data:ByteArray; public var ntype:uint; public var nri:uint; public var timestamp:uint; public var bodySize:uint; public function NALU(ntype:uint, nri:uint, data:ByteArray, timestamp:uint) { super(NEW_NALU); this.data = data; this.ntype = ntype; this.nri = nri; this.timestamp = timestamp; this.bodySize = data.bytesAvailable; } public function appendData(idata:ByteArray):void { ByteArrayUtils.appendByteArray(data, idata); this.bodySize = data.bytesAvailable; } public function isIDR():Boolean { return (5 === ntype); } public function writeSize():uint { return 2 + 2 + 1 + data.bytesAvailable; } public function writeStream(output:ByteArray):void { output.writeUnsignedInt(data.bytesAvailable + 1); // NALU length + header output.writeByte((0x0 & 0x80) | (nri & 0x60) | (ntype & 0x1F)); // NAL header output.writeBytes(data, data.position); } public function getPayload():ByteArray { var payload:ByteArray = new ByteArray(); data.position -= 1; data.readBytes(payload, 0, data.bytesAvailable); return payload; } } } ```
f0553c91-4005-4992-913a-1fea0c49d008
{ "language": "ActionScript" }
```actionscript package { import stdio.flash.Sprite import stdio.process import stdio.Interactive [SWF(width=0, height=0)] public class test_readline_flash extends Sprite implements Interactive { public function main(): void { process.prompt = "What’s your name? " process.gets(function (name: String): void { process.puts("Hello, " + name + "!") process.prompt = "Favorite color? " process.gets(function (color: String): void { process.puts("I like " + color + " too!") process.exit() }) }) } } } ``` Use `colorize` in readline test.
```actionscript package { import stdio.colorize import stdio.flash.Sprite import stdio.process import stdio.Interactive [SWF(width=0, height=0)] public class test_readline_flash extends Sprite implements Interactive { public function main(): void { process.prompt = "What’s your name? " process.gets(function (name: String): void { process.puts("Hello, " + name + "!") process.prompt = "What’s your favorite color? " process.gets(function (color: String): void { color = color.toLowerCase() process.puts( "I like " + colorize( "%{bold}%{" + color + "}" + color + "%{none}" ) + " too!" ) process.exit() }) }) } } } ```
8721bdc4-e423-4e9f-a346-ecd449938ce7
{ "language": "ActionScript" }
```actionscript package org.openforis.collect.i18n { import mx.resources.ResourceManager; /** * @author Mino Togna * */ public class Message { public function Message() { } public static function get(resource:String, parameters:Array=null, bundle:String="messages"):String { return ResourceManager.getInstance().getString(bundle, resource, parameters); } } }``` Return resource name instead of null if not found
```actionscript package org.openforis.collect.i18n { import mx.resources.ResourceManager; /** * @author Mino Togna * @author S. Ricci * */ public class Message { public function Message() { } public static function get(resource:String, parameters:Array=null, bundle:String="messages"):String { var message:String = ResourceManager.getInstance().getString(bundle, resource, parameters); if(message != null) { return message; } else { return resource; } } } }```
e670c6a6-e0aa-42b9-8d90-95f3fd9c1100
{ "language": "ActionScript" }
```actionscript package dolly.data { public class PropertyLevelCopyableClass { [Copyable] public static var staticProperty1:String = "Value of first-level static property 1."; public static var staticProperty2:String = "Value of first-level static property 2."; [Cloneable] private var _writableField1:String = "Value of first-level writable field."; [Cloneable] public var property1:String = "Value of first-level public property 1."; public var property2:String = "Value of first-level public property 2."; public function PropertyLevelCopyableClass() { } [Copyable] public function get writableField1():String { return _writableField1; } public function set writableField1(value:String):void { _writableField1 = value; } [Copyable] public function get readOnlyField1():String { return "Value of first-level read-only field."; } } } ``` Fix stupid mistake with metadata names.
```actionscript package dolly.data { public class PropertyLevelCopyableClass { [Copyable] public static var staticProperty1:String = "Value of first-level static property 1."; public static var staticProperty2:String = "Value of first-level static property 2."; [Copyable] private var _writableField1:String = "Value of first-level writable field."; [Copyable] public var property1:String = "Value of first-level public property 1."; public var property2:String = "Value of first-level public property 2."; public function PropertyLevelCopyableClass() { } [Copyable] public function get writableField1():String { return _writableField1; } public function set writableField1(value:String):void { _writableField1 = value; } [Copyable] public function get readOnlyField1():String { return "Value of first-level read-only field."; } } } ```
bb3b5d76-c7a7-44d4-96fe-aebd8f185997
{ "language": "ActionScript" }
```actionscript package { import asunit.framework.TestSuite; public class Suite extends TestSuite { public function Suite() { super(); addTest(new PlayerTest("testPass")); } } } ``` Add URI tests to the asunit test suite
```actionscript package { import asunit.framework.TestSuite; public class Suite extends TestSuite { public function Suite() { super(); addTest(new PlayerTest("testPass")); addTest(new UriTest("test_isSafe")); } } } ```
1168a0f5-7261-45f4-b1a3-1b621adb8c7e
{ "language": "ActionScript" }
```actionscript package { import flash.media.Sound; import flash.net.URLRequest; public class ImpetusSound { private var sound:Sound; private var channels:Vector.<ImpetusChannel>; public function ImpetusSound(url:String):void { this.sound = new Sound(); this.channels = new Vector.<ImpetusChannel>; this.sound.load(new URLRequest(url)); } public function playNew():ImpetusChannel { var c:ImpetusChannel = new ImpetusChannel(this.sound.play(0)); channels.push(c); return c; } public function stopAll():void { var len:int = this.channels.length; for(var i:int; i < len; i++) { this.channels[i].stop(); } } } } ``` Store url & add getUrl() getter
```actionscript package { import flash.media.Sound; import flash.net.URLRequest; public class ImpetusSound { private var url:String; private var sound:Sound; private var channels:Vector.<ImpetusChannel>; public function ImpetusSound(url:String):void { this.url = url; this.sound = new Sound(); this.channels = new Vector.<ImpetusChannel>; this.sound.load(new URLRequest(url)); } public function get getUrl():String { return this.url } public function playNew():ImpetusChannel { var c:ImpetusChannel = new ImpetusChannel(this.sound.play(0)); channels.push(c); return c; } public function stopAll():void { var len:int = this.channels.length; for(var i:int; i < len; i++) { this.channels[i].stop(); } } } } ```
63106c3e-3873-4673-a7c2-80a21447c547
{ "language": "ActionScript" }
```actionscript package { class ClassA { public function ClassA() { trace('A'); } protected function foo() : void { trace('a'); } protected function bar() : void { trace('b'); } } class ClassC extends ClassA { public function ClassC() { trace('> C'); super(); foo(); bar(); trace('< C'); } override protected function bar() : void { super.bar(); trace('override b'); } } class ClassE extends ClassC { public function ClassE() { trace('> E'); super(); foo(); bar(); trace('< E'); } override protected function bar() : void { super.bar(); trace('override b again'); } } // var c = new ClassC(); // var e = new ClassE(); class X { protected var } trace("--"); } ``` Fix call super test case.
```actionscript package { class ClassA { public function ClassA() { trace('A'); } protected function foo() : void { trace('a'); } protected function bar() : void { trace('b'); } } class ClassC extends ClassA { public function ClassC() { trace('> C'); super(); foo(); bar(); trace('< C'); } override protected function bar() : void { super.bar(); trace('override b'); } } class ClassE extends ClassC { public function ClassE() { trace('> E'); super(); foo(); bar(); trace('< E'); } override protected function bar() : void { super.bar(); trace('override b again'); } } trace("--"); } ```
77d7a1b5-43c1-4086-94b4-8c3a087e4c55
{ "language": "ActionScript" }
```actionscript package flails.mxml { import com.asfusion.mate.actions.AbstractServiceInvoker; import com.asfusion.mate.actionLists.IScope; import com.asfusion.mate.actions.IAction; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import flails.request.RequestPipe; import flails.resource.Resources; import flails.resource.Resource; public class ResourcefulServiceInvoker extends AbstractServiceInvoker implements IAction { public var resource:Resource; public var data:Array; public var type:String; public var id:String; public var parent:Object; [Bindable] public var result:Object; public function ResourcefulServiceInvoker() { currentInstance = this; } override protected function prepare(scope:IScope):void { super.prepare(scope); } override protected function run(scope:IScope):void { trace ("Using resource " + resource); var rp:RequestPipe = resource.newRequestPipe(); innerHandlersDispatcher = rp; if (resultHandlers && resultHandlers.length > 0) { createInnerHandlers(scope, ResultEvent.RESULT, resultHandlers); } if (faultHandlers && faultHandlers.length > 0) { createInnerHandlers(scope, FaultEvent.FAULT, faultHandlers); } trace("calling " + type + "()"); rp[type].apply(rp, data); } } }``` Set currentInstance on prepare, not on instantiation time.
```actionscript package flails.mxml { import com.asfusion.mate.actions.AbstractServiceInvoker; import com.asfusion.mate.actionLists.IScope; import com.asfusion.mate.actions.IAction; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import flails.request.RequestPipe; import flails.resource.Resources; import flails.resource.Resource; public class ResourcefulServiceInvoker extends AbstractServiceInvoker implements IAction { private var _data:Array; public var resource:Resource; public var type:String; public var id:String; public var parent:Object; [Bindable] public var result:Object; public function set data(args:Object):void { trace("setting data"); if (args is Array) _data = args as Array; else _data = [args]; } override protected function prepare(scope:IScope):void { currentInstance = this; super.prepare(scope); } override protected function run(scope:IScope):void { trace ("Using resource " + resource); var rp:RequestPipe = resource.newRequestPipe(); innerHandlersDispatcher = rp; if (resultHandlers && resultHandlers.length > 0) { createInnerHandlers(scope, ResultEvent.RESULT, resultHandlers); } if (faultHandlers && faultHandlers.length > 0) { createInnerHandlers(scope, FaultEvent.FAULT, faultHandlers); } trace("calling " + type + "() with " + _data); rp[type].apply(rp, _data); } } }```
439c36c2-69f5-4fda-bedf-6fd7453066a0
{ "language": "ActionScript" }
```actionscript /** * Generated by Gas3 v2.3.0 (Granite Data Services). * * NOTE: this file is only generated if it does not exist. You may safely put * your custom code here. */ package org.openforis.collect.metamodel.proxy { import mx.collections.IList; import org.openforis.collect.util.CollectionUtil; [Bindable] [RemoteClass(alias="org.openforis.collect.metamodel.proxy.UITabSetProxy")] public class UITabSetProxy extends UITabSetProxyBase { public function getTab(name:String):UITabProxy { var stack:Array = new Array(); stack.push(tabs); while (stack.length > 0) { var tabs:IList = stack.pop(); for each(var tab:UITabProxy in tabs) { if(tab.name == name) { return tab; } if ( CollectionUtil.isNotEmpty(tab.tabs) ) { stack.push(tab.tabs); } } } return null; } } }``` Fix unexpected behavior with nested tabs
```actionscript /** * Generated by Gas3 v2.3.0 (Granite Data Services). * * NOTE: this file is only generated if it does not exist. You may safely put * your custom code here. */ package org.openforis.collect.metamodel.proxy { import mx.collections.IList; import org.openforis.collect.util.CollectionUtil; [Bindable] [RemoteClass(alias="org.openforis.collect.metamodel.proxy.UITabSetProxy")] public class UITabSetProxy extends UITabSetProxyBase { public function getTab(name:String):UITabProxy { var stack:Array = new Array(); stack.push(this.tabs); while (stack.length > 0) { var currentTabs:IList = stack.pop(); for each(var tab:UITabProxy in currentTabs) { if(tab.name == name) { return tab; } if ( CollectionUtil.isNotEmpty(tab.tabs) ) { stack.push(tab.tabs); } } } return null; } } }```
98611f9c-ebdb-49d3-9e3c-a3c3ba426d9a
{ "language": "ActionScript" }
```actionscript package laml.display { import flash.display.DisplayObject; import flash.display.Sprite; public class Skin extends Sprite implements ISkin { public function getBitmapByName(alias:String):DisplayObject { if(hasOwnProperty(alias)) { return new this[alias]() as DisplayObject; } return null; } } }``` Put MX dependencies in skin
```actionscript package laml.display { import flash.display.DisplayObject; import flash.display.Sprite; import mx.core.BitmapAsset; import mx.core.FontAsset; import mx.core.IFlexAsset; import mx.core.IFlexDisplayObject; import mx.core.SpriteAsset; public class Skin extends Sprite implements ISkin { private var bitmapAsset:BitmapAsset; private var fontAsset:FontAsset; private var iFlexAsset:IFlexAsset; private var iFlexDisplayObject:IFlexDisplayObject; private var spriteAsset:SpriteAsset; public function getBitmapByName(alias:String):DisplayObject { if(hasOwnProperty(alias)) { return new this[alias]() as DisplayObject; } return null; } } }```
e74b2bdb-bcc0-4de8-8950-554741d97d15
{ "language": "ActionScript" }
```actionscript /** * Copyright (c) 2009 Lance Carlson * See LICENSE for full license information. */ package flails.resource { import flails.request.RequestPipe; import flails.request.HTTPClient; import flails.request.ResourcePathBuilder; import flails.request.JSONFilter; import flash.utils.getQualifiedClassName; import mx.core.IMXMLObject; public class Resource { public var name:String; public var instanceClass:Class; public function Resource() {} public function initialized(parent:Object, id:String):void { } public function index(resultHandler:Function, errorHandler:Function = null):void { requestPipe(resultHandler, errorHandler).index(); } public function show(id:Number, resultHandler:Function, errorHandler:Function = null):void { requestPipe(resultHandler, errorHandler).show(id); } public function requestPipe(resultHandler:Function, errorHandler:Function):RequestPipe { // TODO: The pluralization obviously needs to be taken care of var pipe:RequestPipe = new HTTPClient(new ResourcePathBuilder(name), new JSONFilter(instanceClass)); pipe.addEventListener("result", resultHandler); return pipe; } } } ``` Implement IMXMLObject. Some defaults and checks.
```actionscript /** * Copyright (c) 2009 Lance Carlson * See LICENSE for full license information. */ package flails.resource { import flails.request.RequestPipe; import flails.request.HTTPClient; import flails.request.ResourcePathBuilder; import flails.request.JSONFilter; import mx.core.IMXMLObject; public class Resource implements IMXMLObject { public var name:String; public var instanceClass:Class; public function Resource() {} public function initialized(parent:Object, id:String):void { if (name == null) throw new Error("Name not set for resource."); if (instanceClass == null) instanceClass = Record; } public function index(resultHandler:Function, errorHandler:Function = null):void { requestPipe(resultHandler, errorHandler).index(); } public function show(id:Number, resultHandler:Function, errorHandler:Function = null):void { requestPipe(resultHandler, errorHandler).show(id); } public function requestPipe(resultHandler:Function, errorHandler:Function):RequestPipe { // TODO: The pluralization obviously needs to be taken care of var pipe:RequestPipe = new HTTPClient(new ResourcePathBuilder(name), new JSONFilter(instanceClass)); pipe.addEventListener("result", resultHandler); return pipe; } } } ```
d938f49f-b887-4894-b3c6-0d633ece1be1
{ "language": "ActionScript" }
```actionscript package dolly { import dolly.core.dolly_internal; import dolly.data.CompositeCloneableClass; import org.as3commons.reflect.Type; use namespace dolly_internal; public class CloningOfCompositeCloneableClassTest { private var compositeCloneableClass:CompositeCloneableClass; private var compositeCloneableClassType:Type; [Before] public function before():void { compositeCloneableClass = new CompositeCloneableClass(); compositeCloneableClassType = Type.forInstance(compositeCloneableClass); } [After] public function after():void { compositeCloneableClass = null; compositeCloneableClassType = null; } } } ``` Test for calculation of cloneable fields in CompositeCloneableClass.
```actionscript package dolly { import dolly.core.dolly_internal; import dolly.data.CompositeCloneableClass; import org.as3commons.reflect.Field; import org.as3commons.reflect.Type; import org.flexunit.asserts.assertEquals; import org.flexunit.asserts.assertNotNull; use namespace dolly_internal; public class CloningOfCompositeCloneableClassTest { private var compositeCloneableClass:CompositeCloneableClass; private var compositeCloneableClassType:Type; [Before] public function before():void { compositeCloneableClass = new CompositeCloneableClass(); compositeCloneableClassType = Type.forInstance(compositeCloneableClass); } [After] public function after():void { compositeCloneableClass = null; compositeCloneableClassType = null; } [Test] public function findingAllWritableFieldsForType():void { const writableFields:Vector.<Field> = Cloner.findAllWritableFieldsForType(compositeCloneableClassType); assertNotNull(writableFields); assertEquals(4, writableFields.length); } } } ```
ab4c1403-f118-4865-aab2-3d93530f2111
{ "language": "ActionScript" }
```actionscript package dolly { import dolly.core.dolly_internal; import dolly.data.CompositeCloneableClass; import org.as3commons.reflect.Field; import org.as3commons.reflect.Type; import org.flexunit.asserts.assertEquals; import org.flexunit.asserts.assertNotNull; use namespace dolly_internal; public class CloningOfCompositeCloneableClassTest { private var compositeCloneableClass:CompositeCloneableClass; private var compositeCloneableClassType:Type; [Before] public function before():void { compositeCloneableClass = new CompositeCloneableClass(); compositeCloneableClassType = Type.forInstance(compositeCloneableClass); } [After] public function after():void { compositeCloneableClass = null; compositeCloneableClassType = null; } [Test] public function findingAllWritableFieldsForType():void { const writableFields:Vector.<Field> = Cloner.findAllWritableFieldsForType(compositeCloneableClassType); assertNotNull(writableFields); assertEquals(4, writableFields.length); } } } ``` Test for cloning array in CompositeCloneableClass.
```actionscript package dolly { import dolly.core.dolly_internal; import dolly.data.CompositeCloneableClass; import org.as3commons.reflect.Field; import org.as3commons.reflect.Type; import org.flexunit.asserts.assertEquals; import org.flexunit.asserts.assertFalse; import org.flexunit.asserts.assertNotNull; import org.hamcrest.assertThat; import org.hamcrest.collection.array; import org.hamcrest.collection.arrayWithSize; import org.hamcrest.collection.everyItem; import org.hamcrest.core.isA; import org.hamcrest.object.equalTo; use namespace dolly_internal; public class CloningOfCompositeCloneableClassTest { private var compositeCloneableClass:CompositeCloneableClass; private var compositeCloneableClassType:Type; [Before] public function before():void { compositeCloneableClass = new CompositeCloneableClass(); compositeCloneableClassType = Type.forInstance(compositeCloneableClass); } [After] public function after():void { compositeCloneableClass = null; compositeCloneableClassType = null; } [Test] public function findingAllWritableFieldsForType():void { const writableFields:Vector.<Field> = Cloner.findAllWritableFieldsForType(compositeCloneableClassType); assertNotNull(writableFields); assertEquals(4, writableFields.length); } [Test] public function cloningOfArray():void { const clone:CompositeCloneableClass = Cloner.clone(compositeCloneableClass); assertNotNull(clone.array); assertThat(clone.array, arrayWithSize(5)); assertThat(clone.array, compositeCloneableClass.array); assertFalse(clone.array == compositeCloneableClass.array); assertThat(clone.array, everyItem(isA(Number))); assertThat(clone.array, array(equalTo(0), equalTo(1), equalTo(2), equalTo(3), equalTo(4))); } } } ```
624cf402-c0ac-4ed6-8bea-8c10136eff0d
{ "language": "ActionScript" }
```actionscript package org.flexunit.events { import flash.events.ErrorEvent; import flash.events.Event; public class UnknownError extends Error { public function UnknownError( event:Event ) { var error:Error; if ( event.hasOwnProperty( "error" ) ) { var errorGeneric:* = event[ "error" ]; if ( errorGeneric is Error ) { error = errorGeneric as Error; } else if ( errorGeneric is ErrorEvent ) { var errorEvent:ErrorEvent = errorGeneric as ErrorEvent; error = new Error( "Top Level Error", errorEvent.errorID ); } } super( error.message, error.errorID ); } } }``` Fix for build issue around unknown error
```actionscript package org.flexunit.events { import flash.events.ErrorEvent; import flash.events.Event; public class UnknownError extends Error { public function UnknownError( event:Event ) { var error:Error; if ( event.hasOwnProperty( "error" ) ) { var errorGeneric:* = event[ "error" ]; if ( errorGeneric is Error ) { error = errorGeneric as Error; } else if ( errorGeneric is ErrorEvent ) { var errorEvent:ErrorEvent = errorGeneric as ErrorEvent; error = new Error( "Top Level Error", Object(errorEvent).errorID ); } } super( error.message, error.errorID ); } } }```
13a155c1-13b4-4fa4-9c62-9bb5e51bde48
{ "language": "ActionScript" }
```actionscript package com.kaltura.kdpfl.plugin { import org.osmf.traits.LoaderBase; public class WVLoader extends LoaderBase { public function WVLoader() { super(); } } }``` Fix a bug that caused "ChangeMedia" to fail
```actionscript package com.kaltura.kdpfl.plugin { import flash.external.ExternalInterface; import org.osmf.media.MediaResourceBase; import org.osmf.traits.LoaderBase; public class WVLoader extends LoaderBase { public function WVLoader() { super(); } override public function canHandleResource(resource:MediaResourceBase):Boolean { if (resource.hasOwnProperty("url") && resource["url"].toString().indexOf(".wvm") > -1 ) { try { ExternalInterface.call("mediaURL" , resource["url"].toString()); } catch(error:Error) { trace("Failed to call external interface"); } return true; } return false; } } }```
249133d3-e291-4bb7-96b1-e0a4c714ab1f
{ "language": "ActionScript" }
```actionscript package goplayer { import flash.display.Loader import flash.events.Event import flash.events.IOErrorEvent import flash.net.URLRequest import flash.system.ApplicationDomain import flash.system.LoaderContext import flash.system.SecurityDomain public class FlashContentLoadAttempt { private const loader : Loader = new Loader private var url : String private var listener : FlashContentLoaderListener public function FlashContentLoadAttempt (url : String, listener : FlashContentLoaderListener) { this.url = url, this.listener = listener loader.contentLoaderInfo.addEventListener (Event.COMPLETE, handleContentLoaded) loader.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, handleIOError) } public function execute() : void { loader.load(new URLRequest(url)) } private function handleContentLoaded(event : Event) : void { listener.handleContentLoaded(loader.contentLoaderInfo) } private function handleIOError(event : IOErrorEvent) : void { debug("Failed to load <" + url + ">: " + event.text) } } } ``` Improve error handling of external content loading.
```actionscript package goplayer { import flash.display.Loader import flash.events.Event import flash.events.IOErrorEvent import flash.net.URLRequest import flash.system.ApplicationDomain import flash.system.LoaderContext import flash.system.SecurityDomain public class FlashContentLoadAttempt { private const loader : Loader = new Loader private var url : String private var listener : FlashContentLoaderListener public function FlashContentLoadAttempt (url : String, listener : FlashContentLoaderListener) { this.url = url, this.listener = listener loader.contentLoaderInfo.addEventListener (Event.COMPLETE, handleContentLoaded) loader.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, handleIOError) } public function execute() : void { loader.load(new URLRequest(url)) } private function handleContentLoaded(event : Event) : void { listener.handleContentLoaded(loader.contentLoaderInfo) } private function handleIOError(event : IOErrorEvent) : void { const code : String = event.text.match(/^Error #(\d+)/)[1] const message : String = code == "2035" ? "Not found" : event.text debug("Error: Failed to load <" + url + ">: " + message) } } } ```
346ae0d7-d6af-4908-bdca-3a2638898fa6
{ "language": "ActionScript" }
```actionscript package aerys.minko.render.effect.vertex { import aerys.minko.render.RenderTarget; import aerys.minko.render.effect.basic.BasicProperties; import aerys.minko.render.effect.basic.BasicShader; import aerys.minko.render.shader.SFloat; import aerys.minko.type.stream.format.VertexComponent; public class VertexUVShader extends BasicShader { public function VertexUVShader(target : RenderTarget = null, priority : Number = 0) { super(target, priority); } override protected function getPixelColor() : SFloat { var uv : SFloat = getVertexAttribute(VertexComponent.UV); if (meshBindings.propertyExists(BasicProperties.DIFFUSE_UV_SCALE)) uv.scaleBy(meshBindings.getParameter(BasicProperties.DIFFUSE_UV_SCALE, 2)); if (meshBindings.propertyExists(BasicProperties.DIFFUSE_UV_OFFSET)) uv.incrementBy(meshBindings.getParameter(BasicProperties.DIFFUSE_UV_OFFSET, 2)); var interpolatedUv : SFloat = fractional(interpolate(uv)); return float4(interpolatedUv.x, interpolatedUv.y, 0, 1); } } }``` Optimize uv shader for limit values
```actionscript package aerys.minko.render.effect.vertex { import aerys.minko.render.RenderTarget; import aerys.minko.render.effect.basic.BasicProperties; import aerys.minko.render.effect.basic.BasicShader; import aerys.minko.render.shader.SFloat; import aerys.minko.type.stream.format.VertexComponent; public class VertexUVShader extends BasicShader { public function VertexUVShader(target : RenderTarget = null, priority : Number = 0) { super(target, priority); } override protected function getPixelColor() : SFloat { var uv : SFloat = getVertexAttribute(VertexComponent.UV); if (meshBindings.propertyExists(BasicProperties.DIFFUSE_UV_SCALE)) uv.scaleBy(meshBindings.getParameter(BasicProperties.DIFFUSE_UV_SCALE, 2)); if (meshBindings.propertyExists(BasicProperties.DIFFUSE_UV_OFFSET)) uv.incrementBy(meshBindings.getParameter(BasicProperties.DIFFUSE_UV_OFFSET, 2)); uv = interpolate(uv); var fractional : SFloat = fractional(uv); var fractionalIsZero : SFloat = equal(fractional, float2(0, 0)); var interpolatedUv : SFloat = add( multiply(not(fractionalIsZero), fractional), multiply(fractionalIsZero, saturate(uv)) ); return float4(interpolatedUv.x, interpolatedUv.y, 0, 1); } } }```
62232652-63a1-4449-813d-bd2cec107a7a
{ "language": "ActionScript" }
```actionscript package dolly { public class ClassWithSomeCopyableFields { public static var staticProperty1:String; [Cloneable] public static var staticProperty2:String; [Cloneable] public static var staticProperty3:String; private var _writableField:String; private var _readOnlyField:String = "read-only field value"; public var property1:String; [Cloneable] public var property2:String; [Cloneable] public var property3:String; public function ClassWithSomeCopyableFields() { } [Cloneable] public function get writableField():String { return _writableField; } public function set writableField(value:String):void { _writableField = value; } [Cloneable] public function get readOnlyField():String { return _readOnlyField; } } } ``` Change metadata tags to Copyable in test data class.
```actionscript package dolly { public class ClassWithSomeCopyableFields { public static var staticProperty1:String; [Copyable] public static var staticProperty2:String; [Copyable] public static var staticProperty3:String; private var _writableField:String; private var _readOnlyField:String = "read-only field value"; public var property1:String; [Copyable] public var property2:String; [Copyable] public var property3:String; public function ClassWithSomeCopyableFields() { } [Copyable] public function get writableField():String { return _writableField; } public function set writableField(value:String):void { _writableField = value; } [Copyable] public function get readOnlyField():String { return _readOnlyField; } } } ```
f448557c-6514-4b30-8b7c-9977958a6c81
{ "language": "ActionScript" }
```actionscript package goplayer { import flash.display.Loader import flash.events.Event import flash.events.IOErrorEvent import flash.net.URLRequest import flash.system.ApplicationDomain import flash.system.LoaderContext import flash.system.SecurityDomain public class FlashContentLoadAttempt { private const loader : Loader = new Loader private var url : String private var listener : FlashContentLoaderListener public function FlashContentLoadAttempt (url : String, listener : FlashContentLoaderListener) { this.url = url, this.listener = listener loader.contentLoaderInfo.addEventListener (Event.COMPLETE, handleContentLoaded) loader.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, handleIOError) } public function execute() : void { loader.load(new URLRequest(url)) } private function get loaderContext() : LoaderContext { const result : LoaderContext = new LoaderContext(false, new ApplicationDomain(ApplicationDomain.currentDomain)) result.securityDomain = SecurityDomain.currentDomain return result } private function handleContentLoaded(event : Event) : void { listener.handleContentLoaded(loader.contentLoaderInfo) } private function handleIOError(event : IOErrorEvent) : void { debug("Failed to load <" + url + ">: " + event.text) } } } ``` Remove custom LoaderContext creation code.
```actionscript package goplayer { import flash.display.Loader import flash.events.Event import flash.events.IOErrorEvent import flash.net.URLRequest import flash.system.ApplicationDomain import flash.system.LoaderContext import flash.system.SecurityDomain public class FlashContentLoadAttempt { private const loader : Loader = new Loader private var url : String private var listener : FlashContentLoaderListener public function FlashContentLoadAttempt (url : String, listener : FlashContentLoaderListener) { this.url = url, this.listener = listener loader.contentLoaderInfo.addEventListener (Event.COMPLETE, handleContentLoaded) loader.contentLoaderInfo.addEventListener (IOErrorEvent.IO_ERROR, handleIOError) } public function execute() : void { loader.load(new URLRequest(url)) } private function handleContentLoaded(event : Event) : void { listener.handleContentLoaded(loader.contentLoaderInfo) } private function handleIOError(event : IOErrorEvent) : void { debug("Failed to load <" + url + ">: " + event.text) } } } ```
30e6c78f-99f6-44a2-9582-b84d3285448c
{ "language": "ActionScript" }
```actionscript // // Flump - Copyright 2012 Three Rings Design package flump.export { import flash.display.DisplayObject; import flash.display.Sprite; import flash.geom.Point; import flash.geom.Rectangle; import flump.xfl.XflTexture; public class PackedTexture { public const holder :Sprite = new Sprite(); public var tex :XflTexture; public var offset :Point; public var w :int, h :int, a :int; public var atlasX :int, atlasY :int; public var atlasRotated :Boolean; public function PackedTexture (tex :XflTexture, image :DisplayObject) { this.tex = tex; holder.addChild(image); const bounds :Rectangle = image.getBounds(holder); offset = new Point(bounds.x, bounds.y); w = Math.ceil(bounds.width); h = Math.ceil(bounds.height); a = w * h; } public function toString () :String { return "a " + a + " w " + w + " h " + h + " atlas " + atlasX + ", " + atlasY; } } } ``` Move the images by their offset
```actionscript // // Flump - Copyright 2012 Three Rings Design package flump.export { import flash.display.DisplayObject; import flash.display.Sprite; import flash.geom.Point; import flash.geom.Rectangle; import flump.xfl.XflTexture; public class PackedTexture { public const holder :Sprite = new Sprite(); public var tex :XflTexture; public var offset :Point; public var w :int, h :int, a :int; public var atlasX :int, atlasY :int; public var atlasRotated :Boolean; public function PackedTexture (tex :XflTexture, image :DisplayObject) { this.tex = tex; holder.addChild(image); const bounds :Rectangle = image.getBounds(holder); image.x = -bounds.x; image.y = -bounds.y; offset = new Point(bounds.x, bounds.y); w = Math.ceil(bounds.width); h = Math.ceil(bounds.height); a = w * h; } public function toString () :String { return "a " + a + " w " + w + " h " + h + " atlas " + atlasX + ", " + atlasY; } } } ```
9af3f023-8ebd-4d45-a0a3-3e01b74e284e
{ "language": "ActionScript" }
```actionscript // // $Id$ // // Nenya library - tools for developing networked games // Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved // http://www.threerings.net/code/nenya/ // // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation; either version 2.1 of the License, or // (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA package com.threerings.flex { import flash.display.DisplayObject; import mx.core.UIComponent; /** * Wraps a non-Flex component for use in Flex. */ public class FlexWrapper extends UIComponent { public function FlexWrapper (object :DisplayObject) { // don't capture mouse events in this wrapper mouseEnabled = false; addChild(object); width = object.width; height = object.height; } } } ``` Make this optional, and not the default. Turns out a bunch of shit makes the wrapper size a little bigger, and some things seem to freak out when the wrapper has a size, even when includeInLayout=false. Flex you very much.
```actionscript // // $Id$ // // Nenya library - tools for developing networked games // Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved // http://www.threerings.net/code/nenya/ // // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation; either version 2.1 of the License, or // (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA package com.threerings.flex { import flash.display.DisplayObject; import mx.core.UIComponent; /** * Wraps a non-Flex component for use in Flex. */ public class FlexWrapper extends UIComponent { public function FlexWrapper (object :DisplayObject, inheritSize :Boolean = false) { // don't capture mouse events in this wrapper mouseEnabled = false; addChild(object); if (inheritSize) { width = object.width; height = object.height; } } } } ```
3c16188b-8e47-4ca3-8e8b-50ca357f0c8c
{ "language": "ActionScript" }
```actionscript package stdio { import flash.display.* import flash.utils.getQualifiedClassName import flash.utils.setTimeout public class Sprite extends flash.display.Sprite { public function Sprite() { stage.scaleMode = StageScaleMode.NO_SCALE stage.align = StageAlign.TOP_LEFT // Let the subclass constructor run first. setTimeout(initialize, 0) } private function initialize(): void { setup(loaderInfo, this, start) } private function start(): void { if ("main" in this && this["main"].length === 0) { this["main"]() } else { warn("Please write your main method like this:") warn("public function main(): void {}") process.exit(1) } } private function warn(message: String): void { process.warn(getQualifiedClassName(this) + ": " + message) } } } ``` Fix bug preventing running processes recursively.
```actionscript package stdio { import flash.display.* import flash.utils.getQualifiedClassName import flash.utils.setTimeout public class Sprite extends flash.display.Sprite { public function Sprite() { if (stage) { stage.scaleMode = StageScaleMode.NO_SCALE stage.align = StageAlign.TOP_LEFT } // Let the subclass constructor run first. setTimeout(initialize, 0) } private function initialize(): void { setup(loaderInfo, this, start) } private function start(): void { if ("main" in this && this["main"].length === 0) { this["main"]() } else { warn("Please write your main method like this:") warn("public function main(): void {}") process.exit(1) } } private function warn(message: String): void { process.warn(getQualifiedClassName(this) + ": " + message) } } } ```
b5b824ce-454d-45d6-a7e6-52cc0974d83a
{ "language": "ActionScript" }
```actionscript Scene@ newScene_; Scene@ scene_; Camera@ camera_; void Start() { StartScene("Scenes/Level1.xml"); SubscribeToEvent("LevelComplete", "HandleLevelComplete"); } void Stop() { } void HandleLevelComplete(StringHash type, VariantMap& data) { log.Debug("Level Complete. I should be loading "+data["NextLevel"].GetString()); StartScene(data["NextLevel"].GetString()); } void StartScene(String scene) { newScene_ = Scene(); newScene_.LoadAsyncXML(cache.GetFile(scene)); SubscribeToEvent("AsyncLoadFinished", "HandleAsyncLoadFinished"); } void HandleAsyncLoadFinished(StringHash type, VariantMap& data) { UnsubscribeFromEvent("AsyncLoadFinished"); newScene_ = data["Scene"].GetPtr(); SubscribeToEvent("Update", "HandleDelayedStart"); } void HandleDelayedStart(StringHash type, VariantMap& data) { UnsubscribeFromEvent("Update"); Node@ cameraNode = newScene_.GetChild("Camera", true); Camera@ newCamera = cameraNode.CreateComponent("Camera"); Viewport@ viewport = Viewport(newScene_, cameraNode.GetComponent("Camera")); renderer.viewports[0] = viewport; scene_ = newScene_; camera_ = newCamera; newScene_ = null; } ``` Add a level timer to the main procedure
```actionscript Scene@ newScene_; Scene@ scene_; Camera@ camera_; Timer timer_; void Start() { StartScene("Scenes/Level1.xml"); SubscribeToEvent("LevelComplete", "HandleLevelComplete"); } void Stop() { } void HandleLevelComplete(StringHash type, VariantMap& data) { log.Debug("Level Complete. I should be loading "+data["NextLevel"].GetString()); float timeTaken = timer_.GetMSec(false); log.Debug("You took " + timeTaken / 1000.f + " seconds to solve the level"); StartScene(data["NextLevel"].GetString()); } void StartScene(String scene) { newScene_ = Scene(); newScene_.LoadAsyncXML(cache.GetFile(scene)); SubscribeToEvent("AsyncLoadFinished", "HandleAsyncLoadFinished"); } void HandleAsyncLoadFinished(StringHash type, VariantMap& data) { UnsubscribeFromEvent("AsyncLoadFinished"); newScene_ = data["Scene"].GetPtr(); SubscribeToEvent("Update", "HandleDelayedStart"); } void HandleDelayedStart(StringHash type, VariantMap& data) { UnsubscribeFromEvent("Update"); Node@ cameraNode = newScene_.GetChild("Camera", true); Camera@ newCamera = cameraNode.CreateComponent("Camera"); Viewport@ viewport = Viewport(newScene_, cameraNode.GetComponent("Camera")); renderer.viewports[0] = viewport; scene_ = newScene_; camera_ = newCamera; newScene_ = null; timer_.Reset(); } ```
97512c71-5403-4c0c-a068-909afbb425af
{ "language": "ActionScript" }
```actionscript // // $Id$ package com.threerings.flash { import flash.display.Sprite; import flash.events.Event; /** * Convenience superclass to use for sprites that need to update every frame. * (One must be very careful to remove all ENTER_FRAME listeners when not needed, as they * will prevent an object from being garbage collected!) */ public class FrameSprite extends Sprite { public function FrameSprite () { addEventListener(Event.ADDED_TO_STAGE, handleAdded); addEventListener(Event.REMOVED_FROM_STAGE, handleRemoved); } /** * Called when we're added to the stage. */ protected function handleAdded (... ignored) :void { addEventListener(Event.ENTER_FRAME, handleFrame); handleFrame(); // update immediately } /** * Called when we're added to the stage. */ protected function handleRemoved (... ignored) :void { removeEventListener(Event.ENTER_FRAME, handleFrame); } /** * Called to update our visual appearance prior to each frame. */ protected function handleFrame (... ignored) :void { // nothing here. Override in yor subclass. } } } ``` Allow subclasses to choose not to call handleFrame() when ADDED_TO_STAGE is received.
```actionscript // // $Id$ package com.threerings.flash { import flash.display.Sprite; import flash.events.Event; /** * Convenience superclass to use for sprites that need to update every frame. * (One must be very careful to remove all ENTER_FRAME listeners when not needed, as they * will prevent an object from being garbage collected!) */ public class FrameSprite extends Sprite { /** * @param renderFrameUponAdding if true, the handleFrame() method * is called whenever an ADDED_TO_STAGE event is received. */ public function FrameSprite (renderFrameUponAdding :Boolean = true) { _renderOnAdd = renderFrameUponAdding; addEventListener(Event.ADDED_TO_STAGE, handleAdded); addEventListener(Event.REMOVED_FROM_STAGE, handleRemoved); } /** * Called when we're added to the stage. */ protected function handleAdded (... ignored) :void { addEventListener(Event.ENTER_FRAME, handleFrame); if (_renderOnAdd) { handleFrame(); // update immediately } } /** * Called when we're added to the stage. */ protected function handleRemoved (... ignored) :void { removeEventListener(Event.ENTER_FRAME, handleFrame); } /** * Called to update our visual appearance prior to each frame. */ protected function handleFrame (... ignored) :void { // nothing here. Override in yor subclass. } /** Should we call handleFrame() when we get ADDED_TO_STAGE? */ protected var _renderOnAdd :Boolean; } } ```
eb437f96-32bb-42f8-b6d7-4e43e68008c6
{ "language": "ActionScript" }
```actionscript package org.servebox.cafe.core.application { import org.servebox.cafe.core.spring.ApplicationContext; import spark.components.Application; public class Application extends spark.components.Application implements CafeApplication { private var _context : ApplicationContext; public function Application() { super(); ApplicationInitializer.prepare( this ); _context = ApplicationInitializer.getDefaultContext(); } public function getContext():ApplicationContext { return null; } } }``` Fix bug on getContext() null
```actionscript package org.servebox.cafe.core.application { import org.servebox.cafe.core.spring.ApplicationContext; import spark.components.Application; public class Application extends spark.components.Application implements CafeApplication { private var _context : ApplicationContext; public function Application() { super(); ApplicationInitializer.prepare( this ); _context = ApplicationInitializer.getDefaultContext(); } public function getContext():ApplicationContext { return _context; } } }```
4cbdba3e-635a-4177-b5e8-ebbfb2436a99
{ "language": "ActionScript" }
```actionscript ``` Add bead to draw solid background
```actionscript //////////////////////////////////////////////////////////////////////////////// // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You 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 org.apache.flex.html.staticControls.beads { import flash.display.Graphics; import flash.events.Event; import flash.events.IEventDispatcher; import org.apache.flex.core.IBead; import org.apache.flex.core.IStrand; import org.apache.flex.core.UIBase; public class SolidBackgroundBead implements IBead { public function SolidBackgroundBead() { } private var _strand:IStrand; public function get strand():IStrand { return _strand; } public function set strand(value:IStrand):void { _strand = value; IEventDispatcher(value).addEventListener("heightChanged", changeHandler); IEventDispatcher(value).addEventListener("widthChanged", changeHandler); } private var _backgroundColor:uint; public function get backgroundColor():uint { return _backgroundColor; } public function set backgroundColor(value:uint):void { _backgroundColor = value; if (_strand) changeHandler(null); } private function changeHandler(event:Event):void { var host:UIBase = UIBase(_strand); var g:Graphics = host.graphics; var w:Number = host.width; var h:Number = host.height; g.clear(); g.beginFill(backgroundColor); g.drawRect(0, 0, w, h); g.endFill(); } } }```
48576f57-7002-43d2-b95a-99782054c393
{ "language": "ActionScript" }
```actionscript ``` Add template for writing SWF unit tests
```actionscript /* -*- Mode: java; indent-tabs-mode: nil -*- */ /* Compiled with: java -jar utils/asc.jar -import playerglobal.abc -swf Template,100,100,10 test/swfs/test_TemplateTest.as This template is for writing test SWFs using pure AS3. It allows for testing UI events, screen and program state using the Shumway test harness. */ package { import flash.display.Sprite; import flash.events.Event; public class TemplateTest extends Sprite { public var loader; public function TemplateTest() { var child = new TestObject(); addChild(child); addEventListener(Event.ENTER_FRAME, child.enterFrameHandler); } } } import flash.display.*; import flash.events.*; import flash.net.*; class TestObject extends Sprite { private var color: uint = 0xFFCC00; private var pos: uint = 10; private var size: uint = 80; /* In the constructor, install event listeners for testing events, and construct and add child objects. */ public function TestObject() { } private var frameCount = 0; /* In the enterFrameHandler, make API calls per frame to test both screen and program side-effects. */ function enterFrameHandler(event:Event):void { frameCount++; var target = event.target; var loader = target.loader; switch (frameCount) { case 1: (function () { /* Log test results in the standard format shown here to allow for easy linking with monitor programs. */ var result = true ? "PASS" : "FAIL"; trace(result + ": test::Template/method ()"); trace(result + ": test::Template/get name ()"); trace(result + ": test::Template/set name ()"); })(); break; default: /* Remove enterFrameHandler when done. */ parent.removeEventListener(Event.ENTER_FRAME, enterFrameHandler); break; } } } ```
28b438de-c338-4a04-be1f-95fa4f5f5766
{ "language": "ActionScript" }
```actionscript ``` Create a dummy textbox class for the sole purpose of writing the XML loader
```actionscript package Classes { public class Textbox { public var contents:String; public function Textbox() { contents=""; } public function Textbox(text) { contents=text; } public setContents(text) { contents=text; } } }```
f774d37a-b3fb-44bb-a0ae-48ef03d29984
{ "language": "ActionScript" }
```actionscript ``` Add AngelScript Http Request demo sample.
```actionscript // Http request example. // This example demonstrates: // - How to use Http request API #include "Scripts/Utilities/Sample.as" String message; Text@ text; HttpRequest@ httpRequest; void Start() { // Execute the common startup for samples SampleStart(); // Create the user interface CreateUI(); // Set the mouse mode to use in the sample SampleInitMouseMode(MM_FREE); // Subscribe to basic events such as update SubscribeToEvents(); } void CreateUI() { // Construct new Text object text = Text(); // Set font and text color text.SetFont(cache.GetResource("Font", "Fonts/Anonymous Pro.ttf"), 15); text.color = Color(1.0f, 1.0f, 0.0f); // Align Text center-screen text.horizontalAlignment = HA_CENTER; text.verticalAlignment = VA_CENTER; // Add Text instance to the UI root element ui.root.AddChild(text); } void SubscribeToEvents() { // Subscribe HandleUpdate() function for processing HTTP request SubscribeToEvent("Update", "HandleUpdate"); } void HandleUpdate(StringHash eventType, VariantMap& eventData) { // Create HTTP request if (httpRequest is null) httpRequest = network.MakeHttpRequest("http://httpbin.org/ip", "GET"); else { // Initializing HTTP request if (httpRequest.state == HTTP_INITIALIZING) return; // An error has occured else if (httpRequest.state == HTTP_ERROR) { text.text = "An error has occured."; UnsubscribeFromEvent("Update"); } // Get message data else { if (httpRequest.availableSize > 0) message += httpRequest.ReadLine(); else { text.text = "Processing..."; JSONFile@ json = JSONFile(); json.FromString(message); JSONValue val = json.GetRoot().Get("origin"); if (val.isNull) text.text = "Invalid string."; else text.text = "Your IP is: " + val.GetString(); UnsubscribeFromEvent("Update"); } } } } // Create XML patch instructions for screen joystick layout specific to this sample app String patchInstructions = "<patch>" + " <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">" + " <attribute name=\"Is Visible\" value=\"false\" />" + " </add>" + "</patch>"; ```
6799172e-1ae0-456c-b5b7-b0f3e8bb70d1
{ "language": "ActionScript" }
```actionscript ``` Add a simple terminal-like output.
```actionscript package { import flash.display.Sprite; import flash.text.TextField; import flash.net.XMLSocket; public class swfcat extends Sprite { private var output_text:TextField; private function puts(s:String):void { output_text.appendText(s + "\n"); } public function swfcat() { output_text = new TextField(); output_text.width = 400; output_text.height = 300; output_text.background = true; output_text.backgroundColor = 0x001f0f; output_text.textColor = 0x44CC44; addChild(output_text); } } } ```
ea845e7e-5c35-4ccb-8b94-3bb9d9f47a30
{ "language": "ActionScript" }
```actionscript ``` Test case base class -- all AS test classes extend this.
```actionscript /* Copyright 2009, Matthew Eernisse ([email protected]) and Slide, Inc. 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 org.windmill { import flash.display.Sprite; import flash.display.Stage; import org.windmill.WMAssert; public class TestCase extends Sprite { public var asserts:* = WMAssert; // Get a reference to the Stage in the base class // before the tests actually load so tests can all // reference it private var fakeStage:Stage = Windmill.getStage(); override public function get stage():Stage { return fakeStage; } } } ```
586dae08-ef62-4d86-89b7-c1208725b2ca
{ "language": "ActionScript" }
```actionscript ``` Add stub class for Equivalence class testing
```actionscript package unittests { public class TestEquivalence { [Before] public function setUp():void { } [After] public function tearDown():void { } [BeforeClass] public static function setUpBeforeClass():void { } [AfterClass] public static function tearDownAfterClass():void { } } }```
4302384e-392e-49d0-a838-95419197b839
{ "language": "ActionScript" }
```actionscript ``` Add VertexUvShader (vertex streams must have an uv component)
```actionscript package aerys.minko.render.effect.vertex { import aerys.minko.render.RenderTarget; import aerys.minko.render.effect.basic.BasicShader; import aerys.minko.render.shader.SFloat; import aerys.minko.type.stream.format.VertexComponent; public class VertexUVShader extends BasicShader { public function VertexUVShader(target : RenderTarget = null, priority : Number = 0) { super(target, priority); } override protected function getPixelColor() : SFloat { var uv : SFloat = getVertexAttribute(VertexComponent.UV); var interpolatedUv : SFloat = normalize(interpolate(uv)); return float4(interpolatedUv.x, interpolatedUv.y, 0, 1); } } }```
bf352493-4454-4de4-ab23-47ca1b9f0890
{ "language": "ActionScript" }
```actionscript ``` Add empty test for PropertyUtil class.
```actionscript package dolly.utils { import dolly.core.dolly_internal; import mx.collections.ArrayCollection; import mx.collections.ArrayList; use namespace dolly_internal; public class PropertyUtilTests { private var sourceObj:Object; private var targetObj:Object; [Before] public function before():void { sourceObj = {}; sourceObj.array = [0, 1, 2, 3, 4]; sourceObj.arrayList = new ArrayList([0, 1, 2, 3, 4]); sourceObj.arrayCollection = new ArrayCollection([0, 1, 2, 3, 4]); targetObj = {}; } [After] public function after():void { sourceObj = targetObj = null; } } } ```
95405165-afbd-465f-8400-a223b9b24a85
{ "language": "ActionScript" }
```actionscript ``` Fix 525654 - added test for runtime Vector specialization
```actionscript /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is [Open Source Virtual Machine.]. * * The Initial Developer of the Original Code is * Adobe System Incorporated. * Portions created by the Initial Developer are Copyright (C) 2007-2008 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Adobe AS3 Team * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ /** Description: Runtime specialization Specialization of the Vector type can be done at runtime instead of at compile time. */ function getVector() { return Vector; } var CODE = 1007; // Instantiation attempted on a non-constructor. startTest(); var TITLE="Runtime specialization"; writeHeaderToLog(TITLE); var x = getVector().<int>; y = new x(); y.push(1); y.push(2); y.push(3); AddTestCase( "Vector constructed via runtime specialization", 3, y.length); AddTestCase( "Vector constructed via runtime specialization", 2, y[1]); var neg_result = "Failed to catch invalid construct"; try { unspecialized = getVector(); var z = new unspecialized(); } catch ( ex ) { neg_result = String(ex); } AddTestCase ( "Invalid use of unspecialized type in constructor", TYPEERROR + CODE, typeError(neg_result)); test(); ```
d40949f6-87cf-45dc-ae35-171b4159cbad
{ "language": "ActionScript" }
```actionscript ``` Test class for cloning of PropertyLevelCopyableCloneableClass.
```actionscript package dolly { import dolly.core.dolly_internal; import dolly.data.PropertyLevelCopyableCloneableClass; import org.as3commons.reflect.Type; use namespace dolly_internal; public class CloningOfPropertyLevelCopyableCloneableClassTest { private var propertyLevelCopyableCloneable:PropertyLevelCopyableCloneableClass; private var propertyLevelCopyableCloneableType:Type; [Before] public function before():void { propertyLevelCopyableCloneable = new PropertyLevelCopyableCloneableClass(); propertyLevelCopyableCloneable.property1 = "property1 value"; propertyLevelCopyableCloneable.writableField1 = "writableField1 value"; propertyLevelCopyableCloneableType = Type.forInstance(propertyLevelCopyableCloneable); } [After] public function after():void { propertyLevelCopyableCloneable = null; propertyLevelCopyableCloneableType = null; } /** * <code>Cloner.findingAllWritableFieldsForType()</code> method will throw <code>CloningError</code> in this case * because <code>PropertyLevelCopyableCloneableClass</code> class is not cloneable indeed. */ [Test(expects="dolly.core.errors.CloningError")] public function findingAllWritableFieldsForType():void { Cloner.findAllWritableFieldsForType(propertyLevelCopyableCloneableType); } /** * <code>Cloner.clone()</code> method will throw <code>CloningError</code> in this case * because <code>PropertyLevelCopyableCloneableClass</code> class is not cloneable indeed. */ [Test(expects="dolly.core.errors.CloningError")] public function cloningByCloner():void { Cloner.clone(propertyLevelCopyableCloneable); } /** * Method <code>clone()</code> will throw <code>CloningError</code> in this case * because <code>PropertyLevelCopyableCloneableClass</code> class is not cloneable indeed. */ [Test(expects="dolly.core.errors.CloningError")] public function cloningByCloneFunction():void { clone(propertyLevelCopyableCloneable); } } } ```
e3ba8118-68e4-4e42-aef6-fe705faeb2d1
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- util-events -- Events -- Copyright (C) 2001, 2002, 2003, 2009, 2010 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Calendar; 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 ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Calendar; 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; ```
18109fd3-6279-4758-adfc-e4935bb1e59b
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- gen-commands-info -- Collect and give information about the project -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package 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. 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.Info; ``` Update to use the new command implementation
```ada ----------------------------------------------------------------------- -- gen-commands-info -- Collect and give information about the project -- Copyright (C) 2011, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- 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 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.Info; ```
48b6939a-7d65-4582-85a3-07d847bdbb75
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- gen-commands-docs -- Extract and generate documentation for the project -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package Gen.Commands.Docs is -- ------------------------------ -- Documentation Command -- ------------------------------ -- This command extracts documentation from the project files and collect them -- together to build the project documentation. 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.Docs; ``` Update to use the new command implementation
```ada ----------------------------------------------------------------------- -- gen-commands-docs -- Extract and generate documentation for the project -- Copyright (C) 2012, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package Gen.Commands.Docs is -- ------------------------------ -- Documentation Command -- ------------------------------ -- This command extracts documentation from the project files and collect them -- together to build the project documentation. 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.Docs; ```
94da1bcc-3760-4726-a18d-33c020330a30
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- gen-commands-page -- Page creation command for dynamo -- Copyright (C) 2011, 2017, 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package Gen.Commands.Page is -- ------------------------------ -- Page Creation Command -- ------------------------------ -- This command adds a XHTML page 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.Page; ``` Add Name parameter to the Help procedure
```ada ----------------------------------------------------------------------- -- gen-commands-page -- Page creation command for dynamo -- Copyright (C) 2011, 2017, 2018, 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package Gen.Commands.Page is -- ------------------------------ -- Page Creation Command -- ------------------------------ -- This command adds a XHTML page 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.Page; ```
d385c9dd-b2d8-4325-be9a-937209b45f77
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- awa-questions-services-tests -- Unit tests for question service -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with 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 ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with 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; ```
8a15e2b2-2cd3-4416-aef4-0938c0811f06
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- gen-commands-layout -- Layout creation command for dynamo -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package 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. 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.Layout; ``` Update to use the new command implementation
```ada ----------------------------------------------------------------------- -- gen-commands-layout -- Layout creation command for dynamo -- Copyright (C) 2011, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- 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 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.Layout; ```
adb7ffcc-138f-4b04-8d2a-2f04879e51fe
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- mat-readers-files -- Reader for files -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Streams.Buffered; with Util.Streams.Files; package MAT.Readers.Files is type File_Reader_Type is new Manager_Base with private; -- Open the file. procedure Open (Reader : in out File_Reader_Type; Path : in String); procedure Read_All (Reader : in out File_Reader_Type); private type File_Reader_Type is new Manager_Base with record File : aliased Util.Streams.Files.File_Stream; Stream : Util.Streams.Buffered.Buffered_Stream; end record; end MAT.Readers.Files; ``` Use the MAT.Readers.Streams package for the file reader implementation
```ada ----------------------------------------------------------------------- -- mat-readers-files -- Reader for files -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Streams.Buffered; with Util.Streams.Files; with MAT.Readers.Streams; package MAT.Readers.Files is type File_Reader_Type is new MAT.Readers.Streams.Stream_Reader_Type with private; -- Open the file. procedure Open (Reader : in out File_Reader_Type; Path : in String); private type File_Reader_Type is new MAT.Readers.Streams.Stream_Reader_Type with record File : aliased Util.Streams.Files.File_Stream; end record; end MAT.Readers.Files; ```
0e069df0-379c-46f3-8eb8-b80681a6c825
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- ado-drivers-tests -- Unit tests for database drivers -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package ADO.Drivers.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test the Get_Config operation. procedure Test_Get_Config (T : in out Test); -- Test the Get_Driver operation. procedure Test_Get_Driver (T : in out Test); -- Test loading some invalid database driver. procedure Test_Load_Invalid_Driver (T : in out Test); -- Test the Get_Driver_Index operation. procedure Test_Get_Driver_Index (T : in out Test); end ADO.Drivers.Tests; ``` Declare the Test_Set_Connection_Error test procedure
```ada ----------------------------------------------------------------------- -- ado-drivers-tests -- Unit tests for database drivers -- Copyright (C) 2014, 2015 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package ADO.Drivers.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test the Get_Config operation. procedure Test_Get_Config (T : in out Test); -- Test the Get_Driver operation. procedure Test_Get_Driver (T : in out Test); -- Test loading some invalid database driver. procedure Test_Load_Invalid_Driver (T : in out Test); -- Test the Get_Driver_Index operation. procedure Test_Get_Driver_Index (T : in out Test); -- Test the Set_Connection procedure with several error cases. procedure Test_Set_Connection_Error (T : in out Test); end ADO.Drivers.Tests; ```
51279b01-96b5-4fd1-a1b9-ae43cba0e73b
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- druss-commands-status -- Druss status commands -- Copyright (C) 2017, 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package Druss.Commands.Status is type Command_Type is new Druss.Commands.Drivers.Command_Type with null record; procedure Do_Status (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 out 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.Status; ``` Change Help command to accept in out command
```ada ----------------------------------------------------------------------- -- druss-commands-status -- Druss status commands -- Copyright (C) 2017, 2018, 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package Druss.Commands.Status is type Command_Type is new Druss.Commands.Drivers.Command_Type with null record; procedure Do_Status (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 out 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 out Command_Type; Context : in out Context_Type); end Druss.Commands.Status; ```
93b44a2d-a7de-4d9f-9dbd-0f05a8f063a5
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- mat-readers-streams -- Reader for streams -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Streams.Buffered; package MAT.Readers.Streams is type Stream_Reader_Type is new Manager_Base with private; -- Read the events from the stream and stop when the end of the stream is reached. procedure Read_All (Reader : in out Stream_Reader_Type); -- Read a message from the stream. overriding procedure Read_Message (Reader : in out Stream_Reader_Type; Msg : in out Message); private type Stream_Reader_Type is new Manager_Base with record Stream : Util.Streams.Buffered.Buffered_Stream; end record; end MAT.Readers.Streams; ``` Add the data buffer in the Stream_Reader_Type type
```ada ----------------------------------------------------------------------- -- mat-readers-streams -- Reader for streams -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Streams.Buffered; package MAT.Readers.Streams is type Stream_Reader_Type is new Manager_Base with private; -- Read the events from the stream and stop when the end of the stream is reached. procedure Read_All (Reader : in out Stream_Reader_Type); -- Read a message from the stream. overriding procedure Read_Message (Reader : in out Stream_Reader_Type; Msg : in out Message); private type Stream_Reader_Type is new Manager_Base with record Stream : Util.Streams.Buffered.Buffered_Stream; Data : Util.Streams.Buffered.Buffer_Access; end record; end MAT.Readers.Streams; ```
7e7158d6-06f3-4438-9604-eed8e4ec856b
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- AWA - Unit tests -- Copyright (C) 2009, 2010, 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with 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 ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with 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; ```
d529fde5-154c-44cf-8037-67616c417a7d
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- mat-testsuite - MAT Testsuite -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with MAT.Readers.Tests; with MAT.Targets.Tests; with MAT.Frames.Tests; with MAT.Memory.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.Memory.Tests.Add_Tests (Result); MAT.Readers.Tests.Add_Tests (Result); MAT.Targets.Tests.Add_Tests (Result); return Result; end Suite; end MAT.Testsuite; ``` Add the new unit tests
```ada ----------------------------------------------------------------------- -- mat-testsuite - MAT Testsuite -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with MAT.Readers.Tests; with MAT.Targets.Tests; with MAT.Frames.Tests; with MAT.Memory.Tests; with MAT.Expressions.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.Expressions.Tests.Add_Tests (Result); MAT.Frames.Tests.Add_Tests (Result); MAT.Memory.Tests.Add_Tests (Result); MAT.Readers.Tests.Add_Tests (Result); MAT.Targets.Tests.Add_Tests (Result); return Result; end Suite; end MAT.Testsuite; ```
75b25783-b064-4778-97d5-be435a029437
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- locales.tests -- Unit tests for Locales -- Copyright (C) 2009, 2010, 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Util.Locales.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; procedure Test_Get_Locale (T : in out Test); procedure Test_Hash_Locale (T : in out Test); procedure Test_Compare_Locale (T : in out Test); procedure Test_Get_Locales (T : in out Test); end Util.Locales.Tests; ``` Declare the new Test_Null_Locale procedure
```ada ----------------------------------------------------------------------- -- util-locales-tests -- Unit tests for Locales -- Copyright (C) 2009, 2010, 2011, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Util.Locales.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; procedure Test_Get_Locale (T : in out Test); procedure Test_Hash_Locale (T : in out Test); procedure Test_Compare_Locale (T : in out Test); procedure Test_Get_Locales (T : in out Test); procedure Test_Null_Locale (T : in out Test); end Util.Locales.Tests; ```
a84c3cf5-01e4-47c1-be59-b1ac5eb9c5a9
{ "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 := "21"; 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; ``` Upgrade version 1.21 => 1.22
```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 := "22"; 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; ```
45db441d-3e1b-46d8-80fb-5c28918badd9
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- awa-commands-tests -- Test the AWA.Commands -- Copyright (C) 2020 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with Ada.Strings.Unbounded; package AWA.Commands.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test start and stop command. procedure Test_Start_Stop (T : in out Test); procedure Execute (T : in out Test; Command : in String; Input : in String; Output : in String; Result : out Ada.Strings.Unbounded.Unbounded_String; Status : in Natural := 0); end AWA.Commands.Tests; ``` Declare the Test_List_Tables procedure to test the 'list -t' command
```ada ----------------------------------------------------------------------- -- awa-commands-tests -- Test the AWA.Commands -- Copyright (C) 2020 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with Ada.Strings.Unbounded; package AWA.Commands.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test start and stop command. procedure Test_Start_Stop (T : in out Test); procedure Test_List_Tables (T : in out Test); procedure Execute (T : in out Test; Command : in String; Input : in String; Output : in String; Result : out Ada.Strings.Unbounded.Unbounded_String; Status : in Natural := 0); end AWA.Commands.Tests; ```
a88f44c3-0731-42ab-b854-3382fa312cce
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- Security testsuite - Ada Security Test suite -- Copyright (C) 2011, 2012, 2013 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Security.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; ``` Add the new unit tests
```ada ----------------------------------------------------------------------- -- Security testsuite - Ada Security Test suite -- Copyright (C) 2011, 2012, 2013 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Security.OpenID.Tests; with Security.Permissions.Tests; with Security.Policies.Tests; with Security.OAuth.JWT.Tests; with Security.OAuth.Clients.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); Security.OAuth.Clients.Tests.Add_Tests (Ret); return Ret; end Suite; end Security.Testsuite; ```
15ee4d6e-abed-4bae-8d73-36a0f21e0a70
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- mat-testsuite - MAT Testsuite -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with MAT.Readers.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); return Result; end Suite; end MAT.Testsuite; ``` Add the new unit tests
```ada ----------------------------------------------------------------------- -- mat-testsuite - MAT Testsuite -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with 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; ```
6f64b82a-2b32-465d-8aba-dc3c2a94f7cd
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- Util -- Utilities -- Copyright (C) 2009, 2010 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Testsuite; with Util.Tests; procedure Util_Harness is procedure Harness is new Util.Tests.Harness (Util.Testsuite.Suite); begin Harness ("util-tests.xml"); end Util_Harness; ``` Fix running the testsuite with AUnit: create the 'regtests/result' directory if it does not exist
```ada ----------------------------------------------------------------------- -- Util -- Utilities -- Copyright (C) 2009, 2010 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; with Util.Testsuite; with Util.Tests; with Util.Properties; procedure Util_Harness is procedure Initialize (Props : in Util.Properties.Manager); procedure Harness is new Util.Tests.Harness (Util.Testsuite.Suite, Initialize); procedure Initialize (Props : in Util.Properties.Manager) is pragma Unreferenced (Props); Path : constant String := Util.Tests.Get_Test_Path ("regtests/result"); begin if not Ada.Directories.Exists (Path) then Ada.Directories.Create_Directory (Path); end if; end Initialize; begin Harness ("util-tests.xml"); end Util_Harness; ```
192be3f1-885f-4ab9-9d98-25f2c88da942
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- Security-permissions-tests - Unit tests for Security.Permissions -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Security.Permissions.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test Add_Permission and Get_Permission_Index procedure Test_Add_Permission (T : in out Test); end Security.Permissions.Tests; ``` Add new unit tests to check the Permissions.Definition package
```ada ----------------------------------------------------------------------- -- Security-permissions-tests - Unit tests for Security.Permissions -- Copyright (C) 2011, 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Security.Permissions.Tests is package P_Admin is new Permissions.Definition ("admin"); package P_Create is new Permissions.Definition ("create"); package P_Update is new Permissions.Definition ("update"); package P_Delete is new Permissions.Definition ("delete"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test Add_Permission and Get_Permission_Index procedure Test_Add_Permission (T : in out Test); -- Test the permission created by the Definition package. procedure Test_Define_Permission (T : in out Test); -- Test Get_Permission on invalid permission name. procedure Test_Get_Invalid_Permission (T : in out Test); end Security.Permissions.Tests; ```
e7b7e655-38eb-40d6-8b42-79510ce93fb0
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- awa-workspaces -- Module workspaces -- Copyright (C) 2011, 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- -- == 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 ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- -- == 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; ```
3cce35d8-b017-4126-b770-a1a6f2a50fe9
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- gen-commands -- Commands for dynamo -- Copyright (C) 2011, 2012, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.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 usage procedure Usage; -- Print dynamo short usage. procedure Short_Help_Usage; end Gen.Commands; ``` Remove the declaration of Usage procedure
```ada ----------------------------------------------------------------------- -- gen-commands -- Commands for dynamo -- Copyright (C) 2011, 2012, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.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; ```
791cb44d-7da4-453a-a384-b8bfdb0a0e70
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- util-commands -- Support to make command line tools -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Strings.Vectors; package Util.Commands is subtype Argument_List is Util.Strings.Vectors.Vector; end Util.Commands; ``` Change the Argument_List to an interface with a Get_Count and Get_Argument operation
```ada ----------------------------------------------------------------------- -- util-commands -- Support to make command line tools -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- 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; ```
ceb8bb79-f46f-4fd8-a3e9-7e3a59ef05e7
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- awa-wikis-modules-tests -- Unit tests for wikis service -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with AWA.Tests; package AWA.Wikis.Modules.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new AWA.Tests.Test with record Manager : AWA.Wikis.Modules.Wiki_Module_Access; end record; -- Test creation of a wiki space. procedure Test_Create_Wiki_Space (T : in out Test); -- Test creation of a wiki page. procedure Test_Create_Wiki_Page (T : in out Test); end AWA.Wikis.Modules.Tests; ``` Add the Test_Create_Wiki_Content unit test
```ada ----------------------------------------------------------------------- -- awa-wikis-modules-tests -- Unit tests for wikis service -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with AWA.Tests; package AWA.Wikis.Modules.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new AWA.Tests.Test with record Manager : AWA.Wikis.Modules.Wiki_Module_Access; end record; -- Test creation of a wiki space. procedure Test_Create_Wiki_Space (T : in out Test); -- Test creation of a wiki page. procedure Test_Create_Wiki_Page (T : in out Test); -- Test creation of a wiki page content. procedure Test_Create_Wiki_Content (T : in out Test); end AWA.Wikis.Modules.Tests; ```
2c787f3e-1240-4a52-9a2a-1fa4d7cab002
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- awa-changelogs-tests -- Tests for changelogs -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package AWA.Changelogs.Modules.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; procedure Test_Add_Log (T : in out Test); end AWA.Changelogs.Modules.Tests; ``` Fix the unit test to use AWA.Tests.Test for the correct test setup
```ada ----------------------------------------------------------------------- -- awa-changelogs-tests -- Tests for changelogs -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with AWA.Tests; package AWA.Changelogs.Modules.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new AWA.Tests.Test with null record; procedure Test_Add_Log (T : in out Test); end AWA.Changelogs.Modules.Tests; ```
e96c4b9c-3c4f-486c-a19d-32577c0b32ca
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- awa-sysadmin -- -- Copyright (C) 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package AWA.Sysadmin is pragma Pure; end AWA.Sysadmin; ``` Fix style warnings: add missing overriding and update and then/or else conditions
```ada ----------------------------------------------------------------------- -- awa-sysadmin -- sysadmin module -- Copyright (C) 2019, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package AWA.Sysadmin is pragma Pure; end AWA.Sysadmin; ```
4836d0e1-582c-4a6e-8009-43f61f08790f
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- AUnit utils - Helper for writing unit tests -- Copyright (C) 2009, 2010, 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Util.Test_Caller is procedure Add_Test (Suite : in Util.Tests.Access_Test_Suite; Test_Name : in String; Method : in Caller.Test_Method) is begin Suite.Add_Test (Caller.Create (Test_Name, Method)); end Add_Test; end Util.Test_Caller; ``` Use the Is_Test_Enabled function to ignore or take into account the test when it is added in the testsuite.
```ada ----------------------------------------------------------------------- -- AUnit utils - Helper for writing unit tests -- Copyright (C) 2009, 2010, 2011, 2013 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Util.Test_Caller is procedure Add_Test (Suite : in Util.Tests.Access_Test_Suite; Test_Name : in String; Method : in Caller.Test_Method) is begin if Util.Tests.Is_Test_Enabled (Test_Name) then Suite.Add_Test (Caller.Create (Test_Name, Method)); end if; end Add_Test; end Util.Test_Caller; ```
4e280e18-5e00-4e51-b1da-089cb0803b97
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- gen-commands-propset -- Set a property on dynamo project -- Copyright (C) 2011, 2017, 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package 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; ``` Add Name parameter to the Help procedure
```ada ----------------------------------------------------------------------- -- gen-commands-propset -- Set a property on dynamo project -- Copyright (C) 2011, 2017, 2018, 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- 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; Name : in String; Generator : in out Gen.Generator.Handler); end Gen.Commands.Propset; ```
b022cd5f-0510-4cb0-8f03-04e9e73a782f
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- Gen -- Code Generator -- Copyright (C) 2009, 2010, 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package Gen is -- Library SVN identification SVN_URL : constant String := "https://ada-gen.googlecode.com/svn/trunk"; -- Revision used (must run 'make version' to update) SVN_REV : constant Positive := 1095; end Gen; ``` Declare the UString subtype to simplify the implementation and use of Unbounded_String
```ada ----------------------------------------------------------------------- -- gen -- Code Generator -- Copyright (C) 2009, 2010, 2011, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; package Gen is -- Library SVN identification SVN_URL : constant String := "https://ada-gen.googlecode.com/svn/trunk"; -- Revision used (must run 'make version' to update) SVN_REV : constant Positive := 1095; subtype UString is Ada.Strings.Unbounded.Unbounded_String; function To_UString (Value : in String) return UString renames Ada.Strings.Unbounded.To_Unbounded_String; function To_String (Value : in UString) return String renames Ada.Strings.Unbounded.To_String; function Length (Value : in UString) return Natural renames Ada.Strings.Unbounded.Length; function "=" (Left, Right : in UString) return Boolean renames Ada.Strings.Unbounded."="; function "=" (Left : in UString; Right : in String) return Boolean renames Ada.Strings.Unbounded."="; end Gen; ```
2c755047-23ae-4f8d-aa46-786407a91f66
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- mat-formats - Format various types for the console or GUI interface -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with 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; end MAT.Formats; ``` Declare the Location function to format a file,line,function code location
```ada ----------------------------------------------------------------------- -- mat-formats - Format various types for the console or GUI interface -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.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; ```
04ee5238-fa4f-47b4-8161-14198597caea
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- mat-formats - Format various types for the console or GUI interface -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body MAT.Formats is -- ------------------------------ -- Format the address into a string. -- ------------------------------ function Addr (Value : in MAT.Types.Target_Addr) return String is Hex : constant String := MAT.Types.Hex_Image (Value); begin return Hex; end Addr; end MAT.Formats; ``` Implement the Size function to format sizes
```ada ----------------------------------------------------------------------- -- mat-formats - Format various types for the console or GUI interface -- Copyright (C) 2015 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body MAT.Formats is -- ------------------------------ -- Format the address into a string. -- ------------------------------ function Addr (Value : in MAT.Types.Target_Addr) return String is Hex : constant String := MAT.Types.Hex_Image (Value); begin return Hex; end Addr; -- ------------------------------ -- Format the size into a string. -- ------------------------------ function Size (Value : in MAT.Types.Target_Size) return String is Result : constant String := MAT.Types.Target_Size'Image (Value); begin if Result (Result'First) = ' ' then return Result (Result'First + 1 .. Result'Last); else return Result; end if; end Size; end MAT.Formats; ```
9f019000-4ae3-46c6-ad26-be18775af6a0
{ "language": "Ada" }
```ada ----------------------------------------------------------------------- -- mat-types -- Global types -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.IO_Exceptions; with Readline; with MAT.Commands; with MAT.Targets; procedure Matp is procedure Interactive_Loop is Target : MAT.Targets.Target_Type; begin loop declare Line : constant String := Readline.Get_Line ("matp>"); begin MAT.Commands.Execute (Target, Line); exception when MAT.Commands.Stop_Interp => return; end; end loop; exception when Ada.IO_Exceptions.End_Error => return; end Interactive_Loop; begin Interactive_Loop; end Matp; ``` Use Util.Log.Loggers.Initialize to configure the loggers
```ada ----------------------------------------------------------------------- -- mat-types -- Global types -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.IO_Exceptions; with Readline; with MAT.Commands; with MAT.Targets; with Util.Log.Loggers; procedure Matp is procedure Interactive_Loop is Target : MAT.Targets.Target_Type; begin loop declare Line : constant String := Readline.Get_Line ("matp>"); begin MAT.Commands.Execute (Target, Line); exception when MAT.Commands.Stop_Interp => return; end; end loop; exception when Ada.IO_Exceptions.End_Error => return; end Interactive_Loop; begin Util.Log.Loggers.Initialize ("matp.properties"); Interactive_Loop; end Matp; ```
README.md exists but content is empty.
Downloads last month
870

Collection including stallone/CommitPackFT