www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21524] New: [internal] Remove extern(C++) from all dmd


          Issue ID: 21524
           Summary: [internal] Remove extern(C++) from all dmd functions
                    and data structures
           Product: D
           Version: D2
          Hardware: Other
                OS: Other
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

DMD's internal API is unstable and very few people remember there are
downstream C++ users of the compiler who rely on the headers being in sync.

There have been arguments over the best way forward to ensure that all
contributors relieve the burden on gdc and ldc maintainers when making changes
to dmd. 

As a compromise, one proposal would be to remove all use of extern(C++) from
the Compiler API. In its place would be a single module defining a stable
interface for C++.

No attempt is made here to give any idealised view of what such a stable
interface should look like, but to give one style as an example:

extern(C++) struct DMDType(T)
    T impl;  // pointer
    const(char)* toChars() { return impl.toChars(); }
    StorageClass storage_class() { return impl.storage_class; }
    BEtype* ctype() { return impl.ctype; }

Which will also come with helpers to deal with the initial wrapping of AST
nodes from the D types to C++ types.

Jan 04 2021