@@ -31,53 +31,24 @@ void ClangClassTypePrinter::printClassTypeDecl(
3131 os << " ;\n " ;
3232 });
3333
34+ StringRef baseClassName = " RefCountedClass" ;
35+ StringRef baseClassQualifiedName = " swift::_impl::RefCountedClass" ;
36+
3437 os << " class " ;
3538 printer.printBaseName (typeDecl);
3639 // FIXME: Add support for inherintance.
37- os << " final" ;
40+ os << " final : " << baseClassQualifiedName ;
3841 os << " {\n " ;
3942 os << " public:\n " ;
4043
41- // Destructor releases the object.
42- os << " inline ~" ;
43- printer.printBaseName (typeDecl);
44- os << " () { swift::" << cxx_synthesis::getCxxImplNamespaceName ()
45- << " ::swift_release(_opaquePointer); }\n " ;
46-
47- os << " inline " ;
48- printer.printBaseName (typeDecl);
49- os << " (const " ;
50- printer.printBaseName (typeDecl);
51- os << " & other) noexcept : _opaquePointer(other._opaquePointer) { swift::"
52- << cxx_synthesis::getCxxImplNamespaceName ()
53- << " ::swift_retain(_opaquePointer); }\n " ;
54-
55- os << " inline " ;
56- printer.printBaseName (typeDecl);
57- os << " & operator=(const " ;
58- printer.printBaseName (typeDecl);
59- os << " & other) noexcept {\n swift::"
60- << cxx_synthesis::getCxxImplNamespaceName ()
61- << " ::swift_retain(other._opaquePointer);\n " ;
62- os << " swift::" << cxx_synthesis::getCxxImplNamespaceName ()
63- << " ::swift_release(_opaquePointer);\n " ;
64- os << " _opaquePointer = other._opaquePointer;\n " ;
65- os << " return *this;\n " ;
66- os << " }\n " ;
67-
68- // FIXME: move semantics should be restricted?
69- os << " inline " ;
70- printer.printBaseName (typeDecl);
71- os << " (" ;
72- printer.printBaseName (typeDecl);
73- os << " &&) noexcept = default;\n " ;
44+ os << " using " << baseClassName << " ::" << baseClassName << " ;\n " ;
45+ os << " using " << baseClassName << " ::operator=;\n " ;
7446
7547 os << " private:\n " ;
7648 os << " inline " ;
7749 printer.printBaseName (typeDecl);
78- os << " (void * _Nonnull ptr) noexcept : _opaquePointer(ptr) {}\n " ;
79- os << " \n void * _Nonnull _opaquePointer;\n " ;
80- os << " friend class " << cxx_synthesis::getCxxImplNamespaceName () << " ::" ;
50+ os << " (void * _Nonnull ptr) noexcept : " << baseClassName << " (ptr) {}\n " ;
51+ os << " \n friend class " << cxx_synthesis::getCxxImplNamespaceName () << " ::" ;
8152 printCxxImplClassName (os, typeDecl);
8253 os << " ;\n " ;
8354 os << " };\n\n " ;
0 commit comments