Menu

#1485 Change COM class implementation from C to C++

Committed
closed
5
2023-05-31
2023-03-27
Zufu Liu
No

I can't find previous discussion (around 2018) for this with the search box.

COM classes (these with VFunction **vtbl; field) inside ScintillaWin.cxx can be changed to C++ class similar to class BlobInline : public IDWriteInlineObject in PlatWin.cxx. I think previous concern about GCC can't generate correct vtable (or class layout?) no longer applies.

Related

Feature Requests: #1565

Discussion

  • Zufu Liu

    Zufu Liu - 2023-03-27

    reinterpret_cast<IXXX> can be removed after implement them with C++ inheritance.

     
  • Zufu Liu

    Zufu Liu - 2023-03-28

    Patch for the changes.

     
  • Neil Hodgson

    Neil Hodgson - 2023-04-08

    Why are the default virtual destructors needed? I expect they can be omitted following rule-of-zero with final added to the classes to show that they can't be derived from:

    class DropSource final : public IDropSource {
    public:
        ScintillaWin *sci = nullptr;
        DropSource() noexcept = default;
    
        // IUnknown
        //...
    };
    
     
  • Zufu Liu

    Zufu Liu - 2023-04-08

    virtual destructor copied from class BlobInline, for these in ScintillaWin.cxx both constructor and destructor can be omitted.

    Patch added final, removed unneeded constructor and destructor.

     
  • Zufu Liu

    Zufu Liu - 2023-04-08

    There are other virtual destructors can also be removed, rg virtual\s*~.

     
    • Neil Hodgson

      Neil Hodgson - 2023-04-09

      Many of these occurrences will be destroyed through deleting a derived class through a base class pointer. COM objects are deleted by calling Release (which calls delete from inside the class) and must never be deleted by other code.

      It may be worthwhile finding other cases for rule-of-zero but that can rely on implementation subtleties. There'll also be linter warnings when defining base classes without virtual destructors as COM -style interfaces are not understood by linters.

       
      • Zufu Liu

        Zufu Liu - 2023-04-09

        It may be worthwhile finding other cases

        What about class CaseConverter in CaseConvert.cxx?

         
        • Neil Hodgson

          Neil Hodgson - 2023-04-10

          OK [58cf34].

          Also changed CharacterIndexer / DocumentIndexer with [fc2f4c] as that is a simple case.

           

          Related

          Commit: [58cf34]
          Commit: [fc2f4c]

  • Neil Hodgson

    Neil Hodgson - 2023-04-09
    • Group: Initial --> Committed
     
  • Neil Hodgson

    Neil Hodgson - 2023-04-09

    Committed with [72cb31] and [074546].

     

    Related

    Commit: [074546]
    Commit: [72cb31]

  • Neil Hodgson

    Neil Hodgson - 2023-05-31
    • status: open --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.