Gems in categories Mixed Language

  • Gem #116: Ada and C++ Exceptions

    One of the main issues raised by interfacing Ada and C++ is propagation of exceptions from one environment to the other. In this Gem, we’ll demonstrate how the new exception mechanism implemented in GNAT allows catching Ada exceptions in C++, and vice versa. Note that the following code will work starting with GNAT Pro 7. Continue Reading in Ada Answers »

    Quentin Ochem
    AdaCore
  • Gem #108: Gprbuild and Configuration Files—Part 2

    In this second of a series of three Gems about gprbuild, we explain in more detail how to configure the tool, again with the help of configuration files.

    Continue Reading in Ada Answers »

    Johannes Kanig
    AdaCore
  • Gem #106: Lady Ada Kisses Python—Part 2

    This series of two Gems explains how to use the GNAT Components Collection to interface your Ada code with Python. The first Gem described what benefits this could bring to your application, and the difficulties there would be in interfacing directly to the Python library. The second Gem shows how to get started with GNATCOLL to make the interfacing much easier.

    Continue Reading in Ada Answers »

    Emmanuel Briot
    AdaCore
  • Gem #105: Lady Ada Kisses Python—Part 1

    This series of two Gems explains how to use the GNAT Components Collection to interface your Ada code with Python. The first Gem describes the benefits this could bring to your application as well as the difficulties there would be in interfacing directly to the Python library. The second Gem will show how to get started with GNATCOLL to greatly simplify the interfacing process.

    Continue Reading in Ada Answers »

    Emmanuel Briot
    AdaCore
  • Gem #104: Gprbuild and Configuration Files—Part 1

    In this first of a series of three Gems about configuration capabilities of gprbuild, we explain how to configure gprbuild to use a custom compiler, with the help of configuration files.

    Continue Reading in Ada Answers »

    Johannes Kanig
    AdaCore
  • Gem #102: SOAP/WSDL client part

    In this Gem we will use web services as described in a WSDL document.

    Continue Reading in Ada Answers »

    Pascal Obry
    EDF R&D
  • Gem #65: gprbuild

    Ada Gem #65 — gprbuild is a new program builder, superseding gnatmake. It supports multiple languages, automatically manages source dependencies, and reduces the need for recompilation. This Gem describes a high-level view of how gprbuild works. Continue Reading in Ada Answers »

    Emmanuel Briot
    AdaCore
  • Gem #62: C++ constructors and Ada 2005

    Ada Gem #62 — In the previous Gem, we explored how to interface and make simple use of C++ constructors on the Ada side.

    In this Gem, we detail more advanced constructs related to Ada 2005 and C++ constructors.

    Continue Reading in Ada Answers »

    Javier Miranda
    AdaCore
    Arnaud Charlet
    AdaCore
  • Gem #61: Interfacing with C++ constructors

    Ada Gem #61 — In the previous Gem about generating bindings from C++ headers, we mentioned, without going into details, how to interface with C++ constructors in Ada using the CPP_Constructor pragma.

    In this Gem we present some common uses of C++ constructors in mixed-language programs in GNAT, and in the next Gem, we will show the use of some powerful Ada 2005 features in conjunction with C++ constructors.

    Continue Reading in Ada Answers »

    Javier Miranda
    AdaCore
    Arnaud Charlet
    AdaCore
  • Gem #60: Generating Ada bindings for C++ headers

    Ada Gem #60 — In Gem #59 we saw how simple it is to automatically generate Ada bindings for C header files. In this Gem, we will see that, similarly, it's now also possible to generate Ada bindings for C++ header files. Continue Reading in Ada Answers »

    Arnaud Charlet
    AdaCore
  • Gem #59: Generating Ada bindings for C headers

    Ada Gem #59 — One of the delicate areas of Ada that is often unfamiliar to developers is how to intermix Ada code with other programming languages. While Ada provides very powerful and complete capabilities to interface with other compiled languages such as C, C++, and Fortran, writing the Ada glue code that enables a programmer to use complex and large APIs can be tedious and error-prone.
    In this Gem, we will explore a new tool provided by AdaCore to automate the interface generation of C header files through the compiler. Continue Reading in Ada Answers »

    Arnaud Charlet
    AdaCore
  • Gem #58: Ada / Java exception handling

    Ada Gem #58 — Ada and Java are two languages that rely heavily on exceptions. A large part of the Ada data model is based on the fact that data is checked at run time, and will raise various kinds of exceptions such as Constraint_Error when constraints are violated. Similarly, there are many cases where Java performs checks that can raise exceptions, among the most common being checks on casts and null dereferences. It is therefore extremely important to support exceptions that are properly propagated from one language to the other and even potentially caught/handled, without having to worry about the language of origin. Continue Reading in Ada Answers »

    Quentin Ochem
    AdaCore
  • Gem #57: Ada / Java cross dispatching

    Ada Gem #57 — In the preceding Ada/Java interfacing Gem, we saw how to create calls from Ada to Java using ada2java and callbacks. We’re now going to go one step further, and discuss a cross-language dispatching mechanism that supports extension of an Ada tagged type in Java, allowing the possibility of making dispatching calls equally well from either side. Continue Reading in Ada Answers »

    Quentin Ochem
    AdaCore
  • Gem #56: Creating Ada to Java calls using GNAT-AJIS

    Ada Gem #56 — In a previous Gem we introduced ada2java, which maps an Ada specification to a Java specification, to support calls from Java to Ada. Even though ada2java doesn't support creating Ada bindings of Java specs, it’s still possible to use it to support calls from Ada to Java. In this Gem we’ll look at a first possibility of doing this, using callbacks (in Ada terms, access-to-subprogram calls). Continue Reading in Ada Answers »

    Quentin Ochem
    AdaCore
  • Gem #55: Introduction to Ada / Java Interfacing

    Interfacing Ada and Java is a very tricky problem. As opposed to C, C++, or Fortran, the two languages execute on two different environments, Java on the JVM and Ada directly on the underlying OS. For this reason, it is not possible to directly bind Java functions to natively compiled Ada through a pragma Import. Two solutions are offered to the developer: either compiling the code directly to Java bytecode, using GNAT for the JVM, or using the Java Native Interface (JNI), allowing communication between the native and JVM environments. In this Gem we will take a look at the latter.

    Using this JNI layer manually is very error-prone and tedious. Fortunately, AdaCore provides a set of tools for automating the interface generation, through GNAT-AJIS. This Gem is the first of a series showing how this toolset can be used to create a mixed Ada / Java application. Continue Reading in Ada Answers »

    Quentin Ochem
    AdaCore