of 21/21
11 December 2002 Weaving Ada into the .NET Framework Martin Carlisle 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

  • View

  • Download

Embed Size (px)


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. - PowerPoint PPT Presentation

Text of Weaving Ada into the .NET Framework

  • Weaving Ada into the .NET Framework

    Martin C. Carlisle, Ricky E. SwardJeffrey W. HumphriesUnited States Air Force AcademyDepartment of Computer Science

  • DISCLAIMEROpinions 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.

  • What is .NET?Microsofts answer to JavaLanguage independent runtime Microsoft Intermediate Language (MSIL)JIT compiledLarge collection of classes (CoreEE)Flagship language is C#

  • Our ObjectivesBe able to write Ada code that compiles to a .NET executableBe able to use .NET classes from within AdaBe able to use Ada components in other .NET languages

  • Starting PointLargely derived from JGNAT, a GNAT port to the JVM

  • Provided ToolsMSIL2AdaExtract Ada specifications from .NET DLLsMGNATCompiles Ada to MSILRAPIDPorted to A# (Ada for .NET)AdaGIDE allows targeting .NEThttp://www.usafa.af.mil/dfcs/bios/mcc_html/a_sharp.html

  • MSIL2Ada ProcessDisassemble .NET DLL using ILDASM (from .NET Framework SDK)Run MSIL2Ada on resultant text fileMSIL2Ada based on AdaGOOP

  • MSIL2Ada process

  • MSIL2Ada Outputpackage 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);

  • MSIL2Ada Output - Interfacestype 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

  • MSIL2Ada Output - Constructorpragma 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;

  • MSIL2Ada Output - ValueTypeUnlike Java, .NET has ValueTypes, which are passed by copyIntroduce ValueType reserved word types with this name follow this calling conventionExample: Point record (X,Y)

  • 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

  • Compiling to MSILGoal to simplify use of .NET classes and provide a stronger OO feel to AdaResult: added object.method calling syntax to MGNAT

  • Object.Method syntaxC#: Window1.ResetSecurityTip(true);Ada:MSSyst.Windows.Forms.ResetSecurityTip(This => Window1,modalOnly => True);A#: Window1.ResetSecurityTip(modalOnly => True);

  • Object.Method syntaxAlso 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

  • Implicit string conversionsTo simplify calling .NET libraries, implicitly convert from Ada string to MSSyst.String.RefOnly if use MSSyst.StringE.g. Console.Writeline(Hello Ada);

  • RAPIDPorted RAPID to .NET platformIn general easier than JGNAT port, butNo bellCant group radio buttons without GroupBoxCan only attach menubar to window

  • New since paperAda projects for Visual Studio .NETCompiled Ada libraries using MGNATNo dependence on J#Demonstrates interoperability of C# and A#

  • Possible future workContinue development for Ada for Visual Studio .NETRewrite MSIL2Ada using ReflectionEliminates need for .NET Framework SDKChange .NET enumerations to named constants

  • ConclusionsA# project provides a clean interface to allow interoperability between Ada and other .NET languagesHuge .NET libraries now available to Ada programmers