IDL to C++11
                   Revised submission

                      OMG document mars/2012-03-32




Copyright © 2012                                     Page 1
Document numbers

         mars/12-03-05 (Updated IDL to C++11 Language Mapping
         revised submission with errata applied - changebar)
         mars/12-03-06 (Updated IDL to C++11 Language Mapping
         revised submission with errata applied - clean)
         mars/12-03-07 (Errata)
         mars/12-03-08 (Revised submission - inventory file)
         mars/12-01-02 (IDL to C++1 Language Mapping revised
         submission)




Copyright © 2012                                                Page 2
RFP asks for

        The new mapping should be functionally equivalent to the existing
        IDL to C++ mapping. While the syntax may change, an application
        should be able to implement functionality identical to that which can
        be achieved with the current IDL to C++ mapping.
        Applications programmed using alternative language mappings
        should inter operate transparently. An application utilizing this new
        language mapping should have no awareness, other than
        informational, of what language mapping a peer application is using.
        The new language mapping should be designed to co-exist with
        other technologies. Specifically, it should not interfere with the
        namespaces used by other OMG specifications, or commonly used
        packages.
        Interoperability between the IDL to C++ and IDL to C++11 mapping
        in the same compilation unit is not required.
Copyright © 2012                                                          Page 3
C++11

        C++11 was unanimously approved August 12 th
        2011
        Is now formally available as ISO/IEC 14882:2011




Copyright © 2012                                      Page 4
Goal of IDL to C++11

        Simplified mapping for C++11
        Make use of the new C++11 features to
          –   Gain performance
          –   Reduce coding errors
          –   Reduce amount of code
          –   No need to create conversion between STL/C++
              types and IDL based types




Copyright © 2012                                             Page 5
Enum mapping

        IDL enum is mapped to the new C++11 enum
        class
  // IDL
  enum Color { red, green, blue };


  // C++
  enum class Color : uint32_t { red, green, blue };




Copyright © 2012                                      Page 6
C++11 type mapping

        Map basic types to their C++ counterparts
        IDL (w)string maps to std::(w)string
        IDL sequence maps to std::vector
        IDL array maps to std::array
        IDL fixed maps to CORBA::Fixed




Copyright © 2012                                    Page 7
Reference types

        Reference types are used for
          –   Object reference
          –   Valuetypes
          –   Typecodes
        Strong references behave as std::shared_ptr
        Weak references behave as std::weak_ptr
        References can only be created using
        CORBA::make_reference<>
        No C++ pointers can be passed to the API
Copyright © 2012                                      Page 8
Client interface mapping

        When defining interface Foo, than
        CORBA::object_traits<Foo>::ref_type (aka
        CORBA::object_reference<Foo>, aka
        Foo::_ref_type) is the object reference type
        C++ traits are used to determine types, no
        naming rules to be remembered by the user
        Narrowing using the narrow method (with
        CORBA could trigger a remote call)



Copyright © 2012                                       Page 9
Servant interface mapping

        When defining interface Foo, than
        CORBA::servant_traits<Foo>::base_type is the
        base class for the user servant class
        Servant references are available as
        CORBA::servant_traits<Foo>::ref_type (aka
        CORBA::servant_reference<Foo>)
        C++ traits are used to determine types, no
        naming rules to be remembered by the user



Copyright © 2012                                       Page 10
Nil references

        C++11 has a new type for a nil pointer: nullptr_t
        References can be checked for nil by
        comparing them with nullptr
        Explicit bool conversion operators for usage in
        for example if statements




Copyright © 2012                                            Page 11
Argument passing



        Argument passing for   Argument passing for
        basic types, and       complex types:
        reference types
          –   in: T            –   in: const T&
          –   inout: T&        –   inout: T&
          –   out: T&          –   out: T&
          –   return: T        –   return: T


Copyright © 2012                                      Page 12
Struct/union

         Struct and union now both map to a C++ class
         Providing constructor(s), copy and move
         operators
         Set of accessors for each member:
      void A (T);              void A (const T&);
      T A (void) const;        void A (T&&);
      T& A (void);             const T& A (void) const;
                               T& A (void);

Copyright © 2012                                          Page 13
Proof of concept

        New language binding for TAO: IDL2C++11
        Delivers new IDL compiler
        Adds support libraries to use TAO with C++11
        More details on http://osportal.remedy.nl and
        http://www.orbzone.org




Copyright © 2012                                        Page 14
Next steps



        Vote 2 Vote
        AB
        FTF phase




Copyright © 2012                   Page 15

IDL to C++11 revised submission presentation

  • 1.
    IDL to C++11 Revised submission OMG document mars/2012-03-32 Copyright © 2012 Page 1
  • 2.
    Document numbers mars/12-03-05 (Updated IDL to C++11 Language Mapping revised submission with errata applied - changebar) mars/12-03-06 (Updated IDL to C++11 Language Mapping revised submission with errata applied - clean) mars/12-03-07 (Errata) mars/12-03-08 (Revised submission - inventory file) mars/12-01-02 (IDL to C++1 Language Mapping revised submission) Copyright © 2012 Page 2
  • 3.
    RFP asks for The new mapping should be functionally equivalent to the existing IDL to C++ mapping. While the syntax may change, an application should be able to implement functionality identical to that which can be achieved with the current IDL to C++ mapping. Applications programmed using alternative language mappings should inter operate transparently. An application utilizing this new language mapping should have no awareness, other than informational, of what language mapping a peer application is using. The new language mapping should be designed to co-exist with other technologies. Specifically, it should not interfere with the namespaces used by other OMG specifications, or commonly used packages. Interoperability between the IDL to C++ and IDL to C++11 mapping in the same compilation unit is not required. Copyright © 2012 Page 3
  • 4.
    C++11 C++11 was unanimously approved August 12 th 2011 Is now formally available as ISO/IEC 14882:2011 Copyright © 2012 Page 4
  • 5.
    Goal of IDLto C++11 Simplified mapping for C++11 Make use of the new C++11 features to – Gain performance – Reduce coding errors – Reduce amount of code – No need to create conversion between STL/C++ types and IDL based types Copyright © 2012 Page 5
  • 6.
    Enum mapping IDL enum is mapped to the new C++11 enum class // IDL enum Color { red, green, blue }; // C++ enum class Color : uint32_t { red, green, blue }; Copyright © 2012 Page 6
  • 7.
    C++11 type mapping Map basic types to their C++ counterparts IDL (w)string maps to std::(w)string IDL sequence maps to std::vector IDL array maps to std::array IDL fixed maps to CORBA::Fixed Copyright © 2012 Page 7
  • 8.
    Reference types Reference types are used for – Object reference – Valuetypes – Typecodes Strong references behave as std::shared_ptr Weak references behave as std::weak_ptr References can only be created using CORBA::make_reference<> No C++ pointers can be passed to the API Copyright © 2012 Page 8
  • 9.
    Client interface mapping When defining interface Foo, than CORBA::object_traits<Foo>::ref_type (aka CORBA::object_reference<Foo>, aka Foo::_ref_type) is the object reference type C++ traits are used to determine types, no naming rules to be remembered by the user Narrowing using the narrow method (with CORBA could trigger a remote call) Copyright © 2012 Page 9
  • 10.
    Servant interface mapping When defining interface Foo, than CORBA::servant_traits<Foo>::base_type is the base class for the user servant class Servant references are available as CORBA::servant_traits<Foo>::ref_type (aka CORBA::servant_reference<Foo>) C++ traits are used to determine types, no naming rules to be remembered by the user Copyright © 2012 Page 10
  • 11.
    Nil references C++11 has a new type for a nil pointer: nullptr_t References can be checked for nil by comparing them with nullptr Explicit bool conversion operators for usage in for example if statements Copyright © 2012 Page 11
  • 12.
    Argument passing Argument passing for Argument passing for basic types, and complex types: reference types – in: T – in: const T& – inout: T& – inout: T& – out: T& – out: T& – return: T – return: T Copyright © 2012 Page 12
  • 13.
    Struct/union Struct and union now both map to a C++ class Providing constructor(s), copy and move operators Set of accessors for each member: void A (T); void A (const T&); T A (void) const; void A (T&&); T& A (void); const T& A (void) const; T& A (void); Copyright © 2012 Page 13
  • 14.
    Proof of concept New language binding for TAO: IDL2C++11 Delivers new IDL compiler Adds support libraries to use TAO with C++11 More details on http://osportal.remedy.nl and http://www.orbzone.org Copyright © 2012 Page 14
  • 15.
    Next steps Vote 2 Vote AB FTF phase Copyright © 2012 Page 15