Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using ASIS to Generate C++ Bindings

Similar presentations


Presentation on theme: "Using ASIS to Generate C++ Bindings"— Presentation transcript:

1 Using ASIS to Generate C++ Bindings
Gachia - Generating a C++ Header Interface Automatically 11/15/2018 Ausden & Nyberg

2 Background / Motivation
One component (FLTS) of the FAA ERAM (En Route Automation Modernization) ERAM primarily developed in Ada Utilizes components from previous ATC developments, also primarily in Ada Need to provide access / interface for C++ client programs (primarily display interfaces) Rapidly changing Ada API during development – C++ API lagging severely behind Emphasize that this is only ONE component of the overall ERAM project. This effort was therefore somewhat of a prototype / research project, which wasn’t necessarily assured of being any more widely used. It was just that this was a BIG component, still under development and a primary interface to the C++ programs. Other components also had C++ requirements, but these were smaller and / or had already been implemented manually. 11/15/2018 Ausden & Nyberg

3 Approach Use ASIS to generate API headers
Package / File Supporting Utilities (Data Serialization - incomplete) Determine language construct mapping Packaging Types Functions / Procedures Exceptions Integration with other components Mention that because of the pre-existing quantity of code, alternative solutions, such as CORBA, could not be injected into the development at this point in the lifecycle. For data serialization, mention the typing tool and recommend that people see the corresponding presentation tomorrow afternoon. 11/15/2018 Ausden & Nyberg

4 Ada / C++ Language Mapping
Packaging Types Intrinsic Composite / Structured “Abstract” (includes abstract, tagged, variant, discriminant) Functions / Procedures Exceptions Mostly done on the fly, rather than through a studied comparison… 11/15/2018 Ausden & Nyberg

5 Ada / C++ Packaging Ada packages C++ namespaces
Both have “child” capabilities Really straightforward… Ada parent-child.ads, .adb C++ parent-child.h, .cpp 11/15/2018 Ausden & Nyberg

6 Ada / C++ Types Intrinsic Composite / Structured “Abstract” Constants
Enumeration types Integer types Arrays (including strings) Composite / Structured Records / structs “Abstract” Abstract Tagged Variant records Discriminant types Most of these were also pretty straightforward. 11/15/2018 Ausden & Nyberg

7 Intrinsic Constants Enumeration types Integer types
C++ requires unique per namespace Integer types C++ “expansion” to int Arrays (including strings) C++ “0” based 11/15/2018 Ausden & Nyberg

8 Composite / Structured
Records / structs Ada variant C++ union (not addressed) Bit layout issues NOT addressed at this point 11/15/2018 Ausden & Nyberg

9 “Abstract” Types Private Types Mapped to C++ Classes
Interesting issues Variants (often different constructors) Tagged (“protected” rather than “private” data members) 11/15/2018 Ausden & Nyberg

10 Ada / C++ Types (contd) Type Issues Approach Dynamic Types
E.g. C++ vectors, lists Booch Components Approach Use the “natural” C++ style in header Use collections / “type tool” in wrapper implementation (presentation tomorrow by Matt Mark) 11/15/2018 Ausden & Nyberg

11 Ada / C++ Exceptions Defined in base level packages for both languages
Implemented cross-language exception passing in wrappers via an “errno” like approach Another compiler dependent “pop-stack-and-call option” used elsewhere 11/15/2018 Ausden & Nyberg

12 ASIS Overview Abstract interface to underlying compiler’s internal representation of code Tutorial Information on the Web – start at Requires Ada code (specifications on for this project) be compiled Requires ASIS implementation by vendor May require compilation with special flags (e.g., GNAT’s “-gnatt” to retain parse tree) 11/15/2018 Ausden & Nyberg

13 ASIS Components Compilation Unit Declaration Definitions Elements
There are many more components, these are just the primary ones used here 11/15/2018 Ausden & Nyberg

14 ASIS – Compilation Unit
Contains queries about compilation units What declarations are contained Whether in specification or body Private or public (visible) Whether body is required Name 11/15/2018 Ausden & Nyberg

15 ASIS – Declarations Queries for declaration objects
Type (variable, constant, number, package, procedure / function, generic / not, etc.) Name Parameter profile (for functions / procedures) Result (return) profile Visibility 11/15/2018 Ausden & Nyberg

16 ASIS – Definitions Typing Parent type Structure / record components
Enumeration literals Integer / real range constraints Mark Array bounds Discriminants and variants 11/15/2018 Ausden & Nyberg

17 Elements Context (“with”) clauses attached to packages
Function call parameters Type kinds 11/15/2018 Ausden & Nyberg

18 Generated outputs Basic Interface: Support interface:
C++ header file (*.h) Support interface: Ada interface wrapper files (*-w.ad[bs]) C++ wrapper files (*-w.h) C++ skeleton “implementation” (*.cpp) Data Serialization (TBD) 11/15/2018 Ausden & Nyberg

19 Basic Interface Iterate through the package declarations
Recurse through “with’d” packages Generate corresponding intrinsic types Collect functions / procedures for C++ classes Generate C++ class interfaces 11/15/2018 Ausden & Nyberg

20 Support Interface Ada interface wrapper files (*-w.ad[bs])
Pragma export C++ names Create everything procedurally Wrap an “errno” around existing interfaces C++ wrapper files (*-w.h) Use “externs” to limit C++ compiler name mangling C++ skeleton “implementation” (*.cpp) Like a “stubsrc”, to link against Data Serialization (TBD) Again – attend tomorrow’s talk by Matt Mark 11/15/2018 Ausden & Nyberg

21 Integration with other Components
Some other components already had C++ interfaces defined Standard C++ features used in order to be more natural for the C++ programmer Effectively drew a “line in the sand” and implemented with textual substitution and manual editing 11/15/2018 Ausden & Nyberg

22 Limitations Development process required inspection of all code (generated or manual) Some rough edges not completed Ada API included some components not required by C++ clients Optimizations possible when clients access was limited to “reading” the data 11/15/2018 Ausden & Nyberg

23 Results Effective for bulk of header files Not fully implemented
Most simple types Generated classes and methods Created ~ 500 header files for FLTS Not fully implemented Serialization deferred Inherited types incomplete C++ “Bodies” unimplemented 11/15/2018 Ausden & Nyberg

24 Use of ASIS Intuitive interface Straightforward implementation
Reasonable performance (5 – 6 minutes execution time for hundreds / thousands of files) Much nicer to be working in Ada rather than awk, perl, grep, sed, cpp! 11/15/2018 Ausden & Nyberg


Download ppt "Using ASIS to Generate C++ Bindings"

Similar presentations


Ads by Google