weaving ada into the net framework
Download
Skip this Video
Download Presentation
Weaving Ada into the .NET Framework

Loading in 2 Seconds...

play fullscreen
1 / 21

Weaving Ada into the .NET Framework - PowerPoint PPT Presentation


  • 95 Views
  • Uploaded on

Weaving Ada into the .NET Framework. Martin C. Carlisle, Ricky E. Sward Jeffrey W. Humphries United States Air Force Academy Department of Computer Science. DISCLAIMER.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Weaving Ada into the .NET Framework' - yetta-owen


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
weaving ada into the net framework
Weaving Ada into the .NET Framework

Martin C. Carlisle, Ricky E. Sward

Jeffrey W. Humphries

United States Air Force Academy

Department of Computer Science

Weaving Ada into the .NET Framework

Martin Carlisle

disclaimer
DISCLAIMER
  • Opinions in this talk are those of the speaker and not necessarily those of the US Air Force Academy, US Air Force, US Department of Defense, or US Government.

Weaving Ada into the .NET Framework

Martin Carlisle

what is net
What is .NET?
  • Microsoft’s answer to Java
    • Language independent runtime
    • Microsoft Intermediate Language (MSIL)
      • JIT compiled
    • Large collection of classes (CoreEE)
    • Flagship language is C#

Weaving Ada into the .NET Framework

Martin Carlisle

our objectives
Our Objectives
  • Be able to write Ada code that compiles to a .NET executable
  • Be able to use .NET classes from within Ada
  • Be able to use Ada components in other .NET languages

Weaving Ada into the .NET Framework

Martin Carlisle

starting point
Starting Point
  • Largely derived from JGNAT, a GNAT port to the JVM

Weaving Ada into the .NET Framework

Martin Carlisle

provided tools
Provided Tools
  • MSIL2Ada
    • Extract Ada specifications from .NET DLLs
  • MGNAT
    • Compiles Ada to MSIL
  • RAPID
    • Ported to A# (Ada for .NET)
  • AdaGIDE allows targeting .NET
  • http://www.usafa.af.mil/dfcs/bios/mcc_html/

a_sharp.html

Weaving Ada into the .NET Framework

Martin Carlisle

msil2ada process
MSIL2Ada Process
  • Disassemble .NET DLL using ILDASM (from .NET Framework SDK)
  • Run MSIL2Ada on resultant text file
    • MSIL2Ada based on AdaGOOP

Weaving Ada into the .NET Framework

Martin Carlisle

msil2ada process1
MSIL2Ada process

Weaving Ada into the .NET Framework

Martin Carlisle

msil2ada output
MSIL2Ada Output

package TimeLibrary.Time3 is

type Typ is new MSSyst.Object.Typ with null record;

type Ref is access all Typ\'Class;

function new_Time3 (

This : Ref := null;

hour : Integer;

minute : Integer) return Ref; -- constructor for Time3

function get_Hour (This : access Typ) return Integer;

procedure set_Hour (

This : access Typ;

value : Integer);

Weaving Ada into the .NET Framework

Martin Carlisle

msil2ada output interfaces
MSIL2Ada Output - Interfaces

type Typ(

I_IContainerControl : IContainerControl.Ref;

I_ISynchronizeInvoke : ISynchronizeInvoke.Ref)

is new ContainerControl.Typ(

I_IContainerControl => I_IContainerControl) with null record;

-- Use X.I_IContainerControl to cast X as the IContainerControl interface

Weaving Ada into the .NET Framework

Martin Carlisle

msil2ada output constructor
MSIL2Ada Output - Constructor

pragma MSIL_Constructor(new_MenuItem);

function New_MenuItem(This : Ref := null)

return Ref is

Super : MenuItem.Ref :=

MenuItem.New_MenuItem(MenuItem.Ref(This));

begin

return This; -- note Super is never used! (compiler magic)

end New_MenuItem;

Weaving Ada into the .NET Framework

Martin Carlisle

msil2ada output valuetype
MSIL2Ada Output - ValueType
  • Unlike Java, .NET has ValueTypes, which are passed by copy
  • Introduce ValueType reserved word – types with this name follow this calling convention
  • Example: Point record (X,Y)

Weaving Ada into the .NET Framework

Martin Carlisle

msil2ada output enumerations
MSIL2Ada Output - Enumerations
  • .NET also provides enumerations (children of ValueType)
  • Mapped to Ada enumerations, although they are not true enumerations! (Bold+Italic)
  • Add function “+” to Ada spec to allow combination

Weaving Ada into the .NET Framework

Martin Carlisle

compiling to msil
Compiling to MSIL
  • Goal to simplify use of .NET classes and provide a stronger OO feel to Ada
  • Result: added object.method calling syntax to MGNAT

Weaving Ada into the .NET Framework

Martin Carlisle

object method syntax
Object.Method syntax

C#:

Window1.ResetSecurityTip(true);

Ada:

MSSyst.Windows.Forms.ResetSecurityTip(

This => Window1,

modalOnly => True);

A#:

Window1.ResetSecurityTip(modalOnly => True);

Weaving Ada into the .NET Framework

Martin Carlisle

object method syntax1
Object.Method syntax
  • Also incorporated into GNAT 3.15 for Windows (local version only)
  • 127 non-blank, non-comment lines of Ada code to make this change.
  • Recommend allowing as an option in Ada 0X.
  • Support traditional Ada syntax also

Weaving Ada into the .NET Framework

Martin Carlisle

implicit string conversions
Implicit string conversions
  • To simplify calling .NET libraries, implicitly convert from Ada string to MSSyst.String.Ref
  • Only if “use MSSyst.String”
  • E.g. Console.Writeline(“Hello Ada”);

Weaving Ada into the .NET Framework

Martin Carlisle

rapid
RAPID
  • Ported RAPID to .NET platform
  • In general easier than JGNAT port, but
    • No bell
    • Can’t group radio buttons without GroupBox
    • Can only attach menubar to window

Weaving Ada into the .NET Framework

Martin Carlisle

new since paper
New since paper
  • Ada projects for Visual Studio .NET
  • Compiled Ada libraries using MGNAT
    • No dependence on J#
    • Demonstrates interoperability of C# and A#

Weaving Ada into the .NET Framework

Martin Carlisle

possible future work
Possible future work
  • Continue development for Ada for Visual Studio .NET
  • Rewrite MSIL2Ada using Reflection
    • Eliminates need for .NET Framework SDK
  • Change .NET enumerations to named constants

Weaving Ada into the .NET Framework

Martin Carlisle

conclusions
Conclusions
  • A# project provides a clean interface to allow interoperability between Ada and other .NET languages
  • Huge .NET libraries now available to Ada programmers

Weaving Ada into the .NET Framework

Martin Carlisle

ad