1 / 21

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. DISCLAIMER.

yetta-owen
Download Presentation

Weaving Ada into the .NET Framework

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. 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

  3. 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

  4. 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

  5. Starting Point • Largely derived from JGNAT, a GNAT port to the JVM Weaving Ada into the .NET Framework Martin Carlisle

  6. 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

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

  8. MSIL2Ada process Weaving Ada into the .NET Framework Martin Carlisle

  9. 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

  10. 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

  11. 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

  12. 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

  13. 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

  14. 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

  15. 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

  16. 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

  17. 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

  18. 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

  19. 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

  20. 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

  21. 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

More Related