Commit 63a573db authored by Miro Knejp's avatar Miro Knejp Committed by Jacob Potter

Generate Obj-C @interface for +c interfaces instead of @protocol

This not only reduces the number of public files exposed to users down to one, it also makes
things safer. It is no longer possible to pass something to a +c interface from Obj-C that is
not compatible and it allows one to directly call static class methods on the generated types
instead of going through the CppProxy type.
parent 263e774d
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
// This file generated by Djinni from example.djinni // This file generated by Djinni from example.djinni
#import "TXSSortItems.h" #import "TXSSortItems.h"
#import "TXSSortItemsCppProxy.h"
#include "sort_items.hpp" #include "sort_items.hpp"
#import "DJICppWrapperCache+Private.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#include <memory> #include <memory>
@interface TXSSortItemsCppProxy () @interface TXSSortItems ()
@property (nonatomic, readonly) std::shared_ptr<::textsort::SortItems> cppRef; @property (nonatomic, readonly) std::shared_ptr<::textsort::SortItems> cppRef;
......
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from example.djinni // This file generated by Djinni from example.djinni
#import "TXSSortItems.h"
#import "TXSSortOrder.h" #import "TXSSortOrder.h"
#import "TXSTextboxListener.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@class TXSItemList; @class TXSItemList;
@class TXSSortItems;
@protocol TXSTextboxListener;
@protocol TXSSortItems @interface TXSSortItems : NSObject
- (void)sort:(TXSSortOrder)order items:(TXSItemList *)items; - (void)sort:(TXSSortOrder)order items:(TXSItemList *)items;
+ (id <TXSSortItems>)createWithListener:(id <TXSTextboxListener>)listener; + (TXSSortItems*)createWithListener:(id<TXSTextboxListener>)listener;
@end @end
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from example.djinni // This file generated by Djinni from example.djinni
#import "TXSSortItemsCppProxy+Private.h" #import "TXSSortItems+Private.h"
#import "DJICppWrapperCache+Private.h"
#import "DJIDate.h" #import "DJIDate.h"
#import "DJIError.h" #import "DJIError.h"
#import "TXSItemList+Private.h" #import "TXSItemList+Private.h"
#import "TXSSortItems+Private.h"
#import "TXSSortItems.h" #import "TXSSortItems.h"
#import "TXSSortItemsCppProxy+Private.h"
#import "TXSSortOrder.h" #import "TXSSortOrder.h"
#import "TXSSortOrderTranslator+Private.h" #import "TXSSortOrderTranslator+Private.h"
#import "TXSTextboxListenerObjcProxy+Private.h" #import "TXSTextboxListenerObjcProxy+Private.h"
...@@ -16,11 +17,11 @@ ...@@ -16,11 +17,11 @@
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
@interface TXSSortItemsCppProxy () @interface TXSSortItems ()
@property (nonatomic, readonly) std::shared_ptr<djinni::DbxCppWrapperCache<::textsort::SortItems>> cache; @property (nonatomic, readonly) std::shared_ptr<djinni::DbxCppWrapperCache<::textsort::SortItems>> cache;
@end @end
@implementation TXSSortItemsCppProxy @implementation TXSSortItems
- (id)initWithCpp:(const std::shared_ptr<::textsort::SortItems> &)cppRef cache:(const std::shared_ptr<djinni::DbxCppWrapperCache<::textsort::SortItems>> &)cache - (id)initWithCpp:(const std::shared_ptr<::textsort::SortItems> &)cppRef cache:(const std::shared_ptr<djinni::DbxCppWrapperCache<::textsort::SortItems>> &)cache
{ {
...@@ -50,11 +51,11 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th ...@@ -50,11 +51,11 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
+ (id <TXSSortItems>)createWithListener:(id <TXSTextboxListener>)listener { + (TXSSortItems*)createWithListener:(id<TXSTextboxListener>)listener {
try { try {
std::shared_ptr<::textsort::TextboxListener> cppListener = ::djinni_generated::TextboxListenerObjcProxy::textbox_listener_with_objc(listener); std::shared_ptr<::textsort::TextboxListener> cppListener = ::djinni_generated::TextboxListenerObjcProxy::textbox_listener_with_objc(listener);
std::shared_ptr<::textsort::SortItems> cppRet = ::textsort::SortItems::create_with_listener(std::move(cppListener)); std::shared_ptr<::textsort::SortItems> cppRet = ::textsort::SortItems::create_with_listener(std::move(cppListener));
id <TXSSortItems> objcRet = [TXSSortItemsCppProxy sortItemsWithCpp:cppRet]; TXSSortItems* objcRet = [TXSSortItems sortItemsWithCpp:cppRet];
return objcRet; return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from example.djinni
#import "TXSSortItems.h"
#import <Foundation/Foundation.h>
@interface TXSSortItemsCppProxy : NSObject <TXSSortItems>
@end
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from example.djinni // This file generated by Djinni from example.djinni
#import <Foundation/Foundation.h>
@class TXSItemList; @class TXSItemList;
......
...@@ -17,7 +17,7 @@ class TextboxListenerObjcProxy final : public ::textsort::TextboxListener ...@@ -17,7 +17,7 @@ class TextboxListenerObjcProxy final : public ::textsort::TextboxListener
explicit TextboxListenerObjcProxy (id objcRef); explicit TextboxListenerObjcProxy (id objcRef);
virtual ~TextboxListenerObjcProxy () override; virtual ~TextboxListenerObjcProxy () override;
static std::shared_ptr<::textsort::TextboxListener> textbox_listener_with_objc (id objcRef); static std::shared_ptr<::textsort::TextboxListener> textbox_listener_with_objc (id<TXSTextboxListener> objcRef);
virtual void update (const ::textsort::ItemList & items) override; virtual void update (const ::textsort::ItemList & items) override;
}; };
......
#import "TXSItemList+Private.h" #import "TXSItemList.h"
#import "TXSSortItemsCppProxy+Private.h" #import "TXSSortItems.h"
#import "TXSTextboxListenerImpl.h" #import "TXSTextboxListenerImpl.h"
#import "TXSViewController.h" #import "TXSViewController.h"
#import "TXSTextboxListenerObjcProxy+Private.h" #import "TXSTextboxListener.h"
#import <QuartzCore/QuartzCore.h> #import <QuartzCore/QuartzCore.h>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
@end @end
@implementation TXSViewController { @implementation TXSViewController {
id <TXSSortItems> _sortItemInterface; TXSSortItems* _sortItemInterface;
id <TXSTextboxListener> _textboxListener; id <TXSTextboxListener> _textboxListener;
} }
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
// Create the Objective-C TXSTextboxListener // Create the Objective-C TXSTextboxListener
_textboxListener = [[TXSTextboxListenerImpl alloc] initWithUITextView:self.textView]; _textboxListener = [[TXSTextboxListenerImpl alloc] initWithUITextView:self.textView];
_sortItemInterface = [TXSSortItemsCppProxy createWithListener:_textboxListener]; _sortItemInterface = [TXSSortItems createWithListener:_textboxListener];
} }
- (IBAction)sort:(id)sender - (IBAction)sort:(id)sender
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
B003051919B70561008E1F67 /* libdjinni_objc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B003051819B70561008E1F67 /* libdjinni_objc.a */; }; B003051919B70561008E1F67 /* libdjinni_objc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B003051819B70561008E1F67 /* libdjinni_objc.a */; };
B05863941A7980CD00C2CFF5 /* DJIDate.mm in Sources */ = {isa = PBXBuildFile; fileRef = B05863931A7980CD00C2CFF5 /* DJIDate.mm */; }; B05863941A7980CD00C2CFF5 /* DJIDate.mm in Sources */ = {isa = PBXBuildFile; fileRef = B05863931A7980CD00C2CFF5 /* DJIDate.mm */; };
B097B6BC19B1C07E0047653A /* libtextsort_objc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B097B6BB19B1C07E0047653A /* libtextsort_objc.a */; }; B097B6BC19B1C07E0047653A /* libtextsort_objc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B097B6BB19B1C07E0047653A /* libtextsort_objc.a */; };
CF8788ED1A24D32D0058F854 /* TXSSortItems.mm in Sources */ = {isa = PBXBuildFile; fileRef = CF8788EB1A24D32D0058F854 /* TXSSortItems.mm */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
...@@ -38,9 +39,6 @@ ...@@ -38,9 +39,6 @@
65834E1E19AC5C9B0061AD3F /* TXSItemList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TXSItemList.h; sourceTree = "<group>"; }; 65834E1E19AC5C9B0061AD3F /* TXSItemList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TXSItemList.h; sourceTree = "<group>"; };
65834E1F19AC5C9B0061AD3F /* TXSItemList.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TXSItemList.mm; sourceTree = "<group>"; }; 65834E1F19AC5C9B0061AD3F /* TXSItemList.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TXSItemList.mm; sourceTree = "<group>"; };
65834E2019AC5C9B0061AD3F /* TXSSortItems.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TXSSortItems.h; sourceTree = "<group>"; }; 65834E2019AC5C9B0061AD3F /* TXSSortItems.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TXSSortItems.h; sourceTree = "<group>"; };
65834E2119AC5C9B0061AD3F /* TXSSortItemsCppProxy+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TXSSortItemsCppProxy+Private.h"; sourceTree = "<group>"; };
65834E2219AC5C9B0061AD3F /* TXSSortItemsCppProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TXSSortItemsCppProxy.h; sourceTree = "<group>"; };
65834E2319AC5C9B0061AD3F /* TXSSortItemsCppProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TXSSortItemsCppProxy.mm; sourceTree = "<group>"; };
65834E2419AC5C9B0061AD3F /* TXSTextboxListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TXSTextboxListener.h; sourceTree = "<group>"; }; 65834E2419AC5C9B0061AD3F /* TXSTextboxListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TXSTextboxListener.h; sourceTree = "<group>"; };
65834E2519AC5C9B0061AD3F /* TXSTextboxListenerObjcProxy+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TXSTextboxListenerObjcProxy+Private.h"; sourceTree = "<group>"; }; 65834E2519AC5C9B0061AD3F /* TXSTextboxListenerObjcProxy+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TXSTextboxListenerObjcProxy+Private.h"; sourceTree = "<group>"; };
65834E2619AC5C9B0061AD3F /* TXSTextboxListenerObjcProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TXSTextboxListenerObjcProxy.mm; sourceTree = "<group>"; }; 65834E2619AC5C9B0061AD3F /* TXSTextboxListenerObjcProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TXSTextboxListenerObjcProxy.mm; sourceTree = "<group>"; };
...@@ -66,6 +64,8 @@ ...@@ -66,6 +64,8 @@
B05863921A7980CD00C2CFF5 /* DJIDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DJIDate.h; sourceTree = "<group>"; }; B05863921A7980CD00C2CFF5 /* DJIDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DJIDate.h; sourceTree = "<group>"; };
B05863931A7980CD00C2CFF5 /* DJIDate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DJIDate.mm; sourceTree = "<group>"; }; B05863931A7980CD00C2CFF5 /* DJIDate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DJIDate.mm; sourceTree = "<group>"; };
B097B6BB19B1C07E0047653A /* libtextsort_objc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtextsort_objc.a; path = "../../build/Debug-iphoneos/libtextsort_objc.a"; sourceTree = "<group>"; }; B097B6BB19B1C07E0047653A /* libtextsort_objc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtextsort_objc.a; path = "../../build/Debug-iphoneos/libtextsort_objc.a"; sourceTree = "<group>"; };
CF8788EB1A24D32D0058F854 /* TXSSortItems.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TXSSortItems.mm; sourceTree = "<group>"; };
CF8788EC1A24D32D0058F854 /* TXSSortItems+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TXSSortItems+Private.h"; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -141,16 +141,15 @@ ...@@ -141,16 +141,15 @@
65834E1919AC5C9B0061AD3F /* generated-objc */ = { 65834E1919AC5C9B0061AD3F /* generated-objc */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
65834E1D19AC5C9B0061AD3F /* TXSItemList+Private.h */,
65834E1E19AC5C9B0061AD3F /* TXSItemList.h */, 65834E1E19AC5C9B0061AD3F /* TXSItemList.h */,
65834E1F19AC5C9B0061AD3F /* TXSItemList.mm */, 65834E1F19AC5C9B0061AD3F /* TXSItemList.mm */,
65834E1D19AC5C9B0061AD3F /* TXSItemList+Private.h */,
65834E2019AC5C9B0061AD3F /* TXSSortItems.h */, 65834E2019AC5C9B0061AD3F /* TXSSortItems.h */,
65834E2119AC5C9B0061AD3F /* TXSSortItemsCppProxy+Private.h */, CF8788EB1A24D32D0058F854 /* TXSSortItems.mm */,
65834E2219AC5C9B0061AD3F /* TXSSortItemsCppProxy.h */, CF8788EC1A24D32D0058F854 /* TXSSortItems+Private.h */,
65834E2319AC5C9B0061AD3F /* TXSSortItemsCppProxy.mm */,
65834E2419AC5C9B0061AD3F /* TXSTextboxListener.h */, 65834E2419AC5C9B0061AD3F /* TXSTextboxListener.h */,
65834E2519AC5C9B0061AD3F /* TXSTextboxListenerObjcProxy+Private.h */,
65834E2619AC5C9B0061AD3F /* TXSTextboxListenerObjcProxy.mm */, 65834E2619AC5C9B0061AD3F /* TXSTextboxListenerObjcProxy.mm */,
65834E2519AC5C9B0061AD3F /* TXSTextboxListenerObjcProxy+Private.h */,
); );
name = "generated-objc"; name = "generated-objc";
path = "../generated-src/objc"; path = "../generated-src/objc";
...@@ -281,6 +280,7 @@ ...@@ -281,6 +280,7 @@
65D7FDFD19AD0CDF0038F82F /* TXSViewController.mm in Sources */, 65D7FDFD19AD0CDF0038F82F /* TXSViewController.mm in Sources */,
A29DB13119BCB94300BFC38D /* DJIWeakPtrWrapper.mm in Sources */, A29DB13119BCB94300BFC38D /* DJIWeakPtrWrapper.mm in Sources */,
65D7FDFA19AD0CDF0038F82F /* main.m in Sources */, 65D7FDFA19AD0CDF0038F82F /* main.m in Sources */,
CF8788ED1A24D32D0058F854 /* TXSSortItems.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
......
...@@ -46,10 +46,15 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -46,10 +46,15 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
header.add("#import " + q(spec.objcIncludePrefix + headerName(d.name))) header.add("#import " + q(spec.objcIncludePrefix + headerName(d.name)))
case DInterface => case DInterface =>
header.add("#import <Foundation/Foundation.h>") header.add("#import <Foundation/Foundation.h>")
header.add("#import " + q(spec.objcIncludePrefix + headerName(d.name)))
val ext = d.body.asInstanceOf[Interface].ext val ext = d.body.asInstanceOf[Interface].ext
if (ext.cpp) body.add("#import " + q(spec.objcIncludePrivatePrefix + privateHeaderName(d.name + "_cpp_proxy"))) if (ext.cpp) {
if (ext.objc) body.add("#import " + q(spec.objcIncludePrivatePrefix + privateHeaderName(d.name + "_objc_proxy"))) header.add("@class " + idObjc.ty(d.name) + ";")
body.add("#import " + q(spec.objcIncludePrivatePrefix + privateHeaderName(d.name)))
}
if (ext.objc) {
header.add("@protocol " + idObjc.ty(d.name) + ";")
body.add("#import " + q(spec.objcIncludePrivatePrefix + privateHeaderName(d.name + "_objc_proxy")))
}
case DRecord => case DRecord =>
val r = d.body.asInstanceOf[Record] val r = d.body.asInstanceOf[Record]
val prefix = if (r.ext.objc) "../" else "" val prefix = if (r.ext.objc) "../" else ""
...@@ -186,6 +191,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -186,6 +191,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
val self = idObjc.ty(ident) val self = idObjc.ty(ident)
refs.header.add("#import <Foundation/Foundation.h>")
refs.privHeader.add("#import <Foundation/Foundation.h>") refs.privHeader.add("#import <Foundation/Foundation.h>")
refs.privHeader.add("#include <memory>") refs.privHeader.add("#include <memory>")
refs.privHeader.add("!#import " + q(spec.objcIncludePrefix + headerName(ident))) refs.privHeader.add("!#import " + q(spec.objcIncludePrefix + headerName(ident)))
...@@ -211,7 +217,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -211,7 +217,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
w.wl(s";") w.wl(s";")
} }
w.wl w.wl
w.wl(s"@protocol $self") if (i.ext.cpp) w.wl(s"@interface $self : NSObject") else w.wl(s"@protocol $self")
for (m <- i.methods) { for (m <- i.methods) {
w.wl w.wl
writeDoc(w, m.doc) writeDoc(w, m.doc)
...@@ -235,24 +241,15 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -235,24 +241,15 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
val cppExtSelf = idObjc.ty(cppExtName) val cppExtSelf = idObjc.ty(cppExtName)
val cppName = withNs(spec.cppNamespace, idCpp.ty(ident)) val cppName = withNs(spec.cppNamespace, idCpp.ty(ident))
if (i.ext.cpp) { if (i.ext.cpp) {
refs.privHeader.add("!#import " + q(spec.objcIncludePrefix + headerName(cppExtName))) refs.body.add("!#import " + q(spec.objcIncludePrivatePrefix + privateHeaderName(ident.name)))
refs.privHeader.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJICppWrapperCache+Private.h")) refs.body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJICppWrapperCache+Private.h"))
refs.body.add("#include <utility>") refs.body.add("#include <utility>")
refs.body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJIError.h")) refs.body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJIError.h"))
refs.body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJIDate.h")) refs.body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJIDate.h"))
refs.body.add("#include <exception>") refs.body.add("#include <exception>")
refs.body.add("!#import " + q(spec.objcIncludePrivatePrefix + privateHeaderName(cppExtName)))
writePublicObjcFile(headerName(cppExtName), origin, mutable.TreeSet[String](), w => { writePrivateObjcFile(privateHeaderName(ident.name), origin, refs.privHeader, w => {
w.wl("#import " + q(spec.objcIncludePrefix + headerName(ident))) w.wl(s"@interface $self ()")
w.wl("#import <Foundation/Foundation.h>")
w.wl
w.wl(s"@interface $cppExtSelf : NSObject <$self>")
w.wl("@end")
})
writePrivateObjcFile(privateHeaderName(cppExtName), origin, refs.privHeader, w => {
w.wl(s"@interface $cppExtSelf ()")
w.wl w.wl
w.wl(s"@property (nonatomic, readonly) std::shared_ptr<$cppName> cppRef;") w.wl(s"@property (nonatomic, readonly) std::shared_ptr<$cppName> cppRef;")
w.wl w.wl
...@@ -261,14 +258,14 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -261,14 +258,14 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
w.wl("@end") w.wl("@end")
}) })
writePrivateObjcFile(bodyName(cppExtName), origin, refs.body, w => { writePrivateObjcFile(bodyName(ident.name), origin, refs.body, w => {
w.wl(s"static_assert(__has_feature(objc_arc), " + q("Djinni requires ARC to be enabled for this file") + ");" ) w.wl(s"static_assert(__has_feature(objc_arc), " + q("Djinni requires ARC to be enabled for this file") + ");" )
w.wl w.wl
w.wl(s"@interface $cppExtSelf ()") w.wl(s"@interface $self ()")
w.wl(s"@property (nonatomic, readonly) std::shared_ptr<djinni::DbxCppWrapperCache<$cppName>> cache;") w.wl(s"@property (nonatomic, readonly) std::shared_ptr<djinni::DbxCppWrapperCache<$cppName>> cache;")
w.wl("@end") w.wl("@end")
w.wl w.wl
w.wl(s"@implementation $cppExtSelf") w.wl(s"@implementation $self")
w.wl w.wl
w.wl(s"- (id)initWithCpp:(const std::shared_ptr<$cppName> &)cppRef cache:(const std::shared_ptr<djinni::DbxCppWrapperCache<$cppName>> &)cache") w.wl(s"- (id)initWithCpp:(const std::shared_ptr<$cppName> &)cppRef cache:(const std::shared_ptr<djinni::DbxCppWrapperCache<$cppName>> &)cache")
w.braced { w.braced {
...@@ -330,7 +327,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -330,7 +327,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
w.wl w.wl
w.wl(s"explicit $objcExtSelf (id objcRef);") w.wl(s"explicit $objcExtSelf (id objcRef);")
w.wl(s"virtual ~$objcExtSelf () override;") w.wl(s"virtual ~$objcExtSelf () override;")
w.wl(s"static std::shared_ptr<${withNs(spec.cppNamespace, idCpp.ty(ident.name))}> ${idCpp.method(ident.name + "_with_objc")} (id objcRef);") w.wl(s"static std::shared_ptr<${withNs(spec.cppNamespace, idCpp.ty(ident.name))}> ${idCpp.method(ident.name + "_with_objc")} (id<$self> objcRef);")
for (m <- i.methods) { for (m <- i.methods) {
val ret = m.ret.fold("void")(toCppType(_, spec.cppNamespace)) val ret = m.ret.fold("void")(toCppType(_, spec.cppNamespace))
val params = m.params.map(p => toCppParamType(p, spec.cppNamespace)) val params = m.params.map(p => toCppParamType(p, spec.cppNamespace))
...@@ -813,8 +810,8 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -813,8 +810,8 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
(ext.cpp, ext.objc) match { (ext.cpp, ext.objc) match {
case (true, true) => throw new AssertionError("Function implemented on both sides") case (true, true) => throw new AssertionError("Function implemented on both sides")
case (false, false) => throw new AssertionError("Function not implemented") case (false, false) => throw new AssertionError("Function not implemented")
case (true, false) => w.wl(s"$objcType$objcIdent = [${idObjc.ty(d.name + "_cpp_proxy")} ${idObjc.method(d.name + "_with_cpp")}:$cppIdent];") case (true, false) => w.wl(s"$objcType$objcIdent = [${idObjc.ty(d.name)} ${idObjc.method(d.name + "_with_cpp")}:$cppIdent];")
case (false, true) => w.wl(s"$objcType$objcIdent = std::static_pointer_cast<$objcProxy>($cppIdent)->_objcRef;") case (false, true) => w.wl(s"$objcType$objcIdent = std::static_pointer_cast<$objcProxy>($cppIdent)->objcRef;")
} }
} }
} }
...@@ -909,7 +906,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -909,7 +906,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
(ext.cpp, ext.objc) match { (ext.cpp, ext.objc) match {
case (true, true) => throw new AssertionError("Function implemented on both sides") case (true, true) => throw new AssertionError("Function implemented on both sides")
case (false, false) => throw new AssertionError("Function not implemented") case (false, false) => throw new AssertionError("Function not implemented")
case (true, false) => w.wl(s"$cppType $cppIdent = [(${idObjc.ty(d.name + "_cpp_proxy")} *)$objcIdent cppRef];") case (true, false) => w.wl(s"$cppType $cppIdent = $objcIdent.cppRef;")
case (false, true) => w.wl(s"$cppType $cppIdent = ${withNs(Some(spec.objcppNamespace), idCpp.ty(d.name + "_objc_proxy"))}" + case (false, true) => w.wl(s"$cppType $cppIdent = ${withNs(Some(spec.objcppNamespace), idCpp.ty(d.name + "_objc_proxy"))}" +
s"::${idCpp.method(d.name + "_with_objc")}($objcIdent);") s"::${idCpp.method(d.name + "_with_objc")}($objcIdent);")
} }
...@@ -950,7 +947,9 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -950,7 +947,9 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
case d: MDef => d.defType match { case d: MDef => d.defType match {
case DEnum => if (needRef) ("NSNumber", true) else (idObjc.ty(d.name), false) case DEnum => if (needRef) ("NSNumber", true) else (idObjc.ty(d.name), false)
case DRecord => (idObjc.ty(d.name), true) case DRecord => (idObjc.ty(d.name), true)
case DInterface => (s"id <${idObjc.ty(d.name)}>", false) case DInterface =>
val ext = d.body.asInstanceOf[Interface].ext
if (ext.cpp) (s"${idObjc.ty(d.name)}*", false) else (s"id<${idObjc.ty(d.name)}>", false)
} }
case p: MParam => throw new AssertionError("Parameter should not happen at Obj-C top level") case p: MParam => throw new AssertionError("Parameter should not happen at Obj-C top level")
} }
......
...@@ -17,7 +17,7 @@ class ClientInterfaceObjcProxy final : public ClientInterface ...@@ -17,7 +17,7 @@ class ClientInterfaceObjcProxy final : public ClientInterface
explicit ClientInterfaceObjcProxy (id objcRef); explicit ClientInterfaceObjcProxy (id objcRef);
virtual ~ClientInterfaceObjcProxy () override; virtual ~ClientInterfaceObjcProxy () override;
static std::shared_ptr<ClientInterface> client_interface_with_objc (id objcRef); static std::shared_ptr<ClientInterface> client_interface_with_objc (id<DBClientInterface> objcRef);
virtual ClientReturnedRecord get_record (int64_t record_id, const std::string & utf8string) override; virtual ClientReturnedRecord get_record (int64_t record_id, const std::string & utf8string) override;
}; };
......
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
// This file generated by Djinni from exception.djinni // This file generated by Djinni from exception.djinni
#import "DBCppException.h" #import "DBCppException.h"
#import "DBCppExceptionCppProxy.h"
#include "cpp_exception.hpp" #include "cpp_exception.hpp"
#import "DJICppWrapperCache+Private.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#include <memory> #include <memory>
@interface DBCppExceptionCppProxy () @interface DBCppException ()
@property (nonatomic, readonly) std::shared_ptr<CppException> cppRef; @property (nonatomic, readonly) std::shared_ptr<CppException> cppRef;
......
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from exception.djinni // This file generated by Djinni from exception.djinni
#import "DBCppException.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@class DBCppException;
@protocol DBCppException @interface DBCppException : NSObject
- (int32_t)throwAnException; - (int32_t)throwAnException;
+ (id <DBCppException>)get; + (DBCppException*)get;
@end @end
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from exception.djinni // This file generated by Djinni from exception.djinni
#import "DBCppExceptionCppProxy+Private.h" #import "DBCppException+Private.h"
#import "DBCppException+Private.h"
#import "DBCppException.h" #import "DBCppException.h"
#import "DBCppExceptionCppProxy+Private.h" #import "DJICppWrapperCache+Private.h"
#import "DJIDate.h" #import "DJIDate.h"
#import "DJIError.h" #import "DJIError.h"
#include <exception> #include <exception>
...@@ -12,11 +13,11 @@ ...@@ -12,11 +13,11 @@
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
@interface DBCppExceptionCppProxy () @interface DBCppException ()
@property (nonatomic, readonly) std::shared_ptr<djinni::DbxCppWrapperCache<CppException>> cache; @property (nonatomic, readonly) std::shared_ptr<djinni::DbxCppWrapperCache<CppException>> cache;
@end @end
@implementation DBCppExceptionCppProxy @implementation DBCppException
- (id)initWithCpp:(const std::shared_ptr<CppException> &)cppRef cache:(const std::shared_ptr<djinni::DbxCppWrapperCache<CppException>> &)cache - (id)initWithCpp:(const std::shared_ptr<CppException> &)cppRef cache:(const std::shared_ptr<djinni::DbxCppWrapperCache<CppException>> &)cache
{ {
...@@ -46,10 +47,10 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th ...@@ -46,10 +47,10 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
+ (id <DBCppException>)get { + (DBCppException*)get {
try { try {
std::shared_ptr<CppException> cppRet = CppException::get(); std::shared_ptr<CppException> cppRet = CppException::get();
id <DBCppException> objcRet = [DBCppExceptionCppProxy cppExceptionWithCpp:cppRet]; DBCppException* objcRet = [DBCppException cppExceptionWithCpp:cppRet];
return objcRet; return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from exception.djinni
#import "DBCppException.h"
#import <Foundation/Foundation.h>
@interface DBCppExceptionCppProxy : NSObject <DBCppException>
@end
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
// This file generated by Djinni from test.djinni // This file generated by Djinni from test.djinni
#import "DBTestHelpers.h" #import "DBTestHelpers.h"
#import "DBTestHelpersCppProxy.h"
#include "test_helpers.hpp" #include "test_helpers.hpp"
#import "DJICppWrapperCache+Private.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#include <memory> #include <memory>
@interface DBTestHelpersCppProxy () @interface DBTestHelpers ()
@property (nonatomic, readonly) std::shared_ptr<TestHelpers> cppRef; @property (nonatomic, readonly) std::shared_ptr<TestHelpers> cppRef;
......
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni // This file generated by Djinni from test.djinni
#import "DBClientInterface.h"
#import "DBColor.h" #import "DBColor.h"
#import "DBToken.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@class DBAssortedIntegers; @class DBAssortedIntegers;
@class DBMapListRecord; @class DBMapListRecord;
@class DBNestedCollection; @class DBNestedCollection;
@class DBPrimitiveList; @class DBPrimitiveList;
@class DBSetRecord; @class DBSetRecord;
@class DBToken;
@protocol DBClientInterface;
@protocol DBTestHelpers @interface DBTestHelpers : NSObject
+ (DBSetRecord *)getSetRecord; + (DBSetRecord *)getSetRecord;
...@@ -38,19 +38,19 @@ ...@@ -38,19 +38,19 @@
+ (BOOL)checkMapListRecord:(DBMapListRecord *)m; + (BOOL)checkMapListRecord:(DBMapListRecord *)m;
+ (void)checkClientInterfaceAscii:(id <DBClientInterface>)i; + (void)checkClientInterfaceAscii:(id<DBClientInterface>)i;
+ (void)checkClientInterfaceNonascii:(id <DBClientInterface>)i; + (void)checkClientInterfaceNonascii:(id<DBClientInterface>)i;
+ (void)checkEnumMap:(NSDictionary *)m; + (void)checkEnumMap:(NSDictionary *)m;
+ (id <DBToken>)tokenId:(id <DBToken>)t; + (DBToken*)tokenId:(DBToken*)t;
+ (id <DBToken>)createCppToken; + (DBToken*)createCppToken;
+ (void)checkCppToken:(id <DBToken>)t; + (void)checkCppToken:(DBToken*)t;
+ (int64_t)cppTokenId:(id <DBToken>)t; + (int64_t)cppTokenId:(DBToken*)t;
+ (NSNumber *)returnNone; + (NSNumber *)returnNone;
......
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni // This file generated by Djinni from test.djinni
#import "DBTestHelpersCppProxy+Private.h" #import "DBTestHelpers+Private.h"
#import "DBAssortedIntegers+Private.h" #import "DBAssortedIntegers+Private.h"
#import "DBClientInterfaceObjcProxy+Private.h" #import "DBClientInterfaceObjcProxy+Private.h"
#import "DBColor.h" #import "DBColor.h"
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
#import "DBPrimitiveList+Private.h" #import "DBPrimitiveList+Private.h"
#import "DBSetRecord+Private.h" #import "DBSetRecord+Private.h"
#import "DBTestHelpers.h" #import "DBTestHelpers.h"
#import "DBTokenCppProxy+Private.h" #import "DBToken+Private.h"
#import "DJICppWrapperCache+Private.h"
#import "DJIDate.h" #import "DJIDate.h"
#import "DJIError.h" #import "DJIError.h"
#include <exception> #include <exception>
...@@ -20,11 +21,11 @@ ...@@ -20,11 +21,11 @@
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
@interface DBTestHelpersCppProxy () @interface DBTestHelpers ()
@property (nonatomic, readonly) std::shared_ptr<djinni::DbxCppWrapperCache<TestHelpers>> cache; @property (nonatomic, readonly) std::shared_ptr<djinni::DbxCppWrapperCache<TestHelpers>> cache;
@end @end
@implementation DBTestHelpersCppProxy @implementation DBTestHelpers
- (id)initWithCpp:(const std::shared_ptr<TestHelpers> &)cppRef cache:(const std::shared_ptr<djinni::DbxCppWrapperCache<TestHelpers>> &)cache - (id)initWithCpp:(const std::shared_ptr<TestHelpers> &)cppRef cache:(const std::shared_ptr<djinni::DbxCppWrapperCache<TestHelpers>> &)cache
{ {
...@@ -182,14 +183,14 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th ...@@ -182,14 +183,14 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
+ (void)checkClientInterfaceAscii:(id <DBClientInterface>)i { + (void)checkClientInterfaceAscii:(id<DBClientInterface>)i {
try { try {
std::shared_ptr<ClientInterface> cppI = ::djinni_generated::ClientInterfaceObjcProxy::client_interface_with_objc(i); std::shared_ptr<ClientInterface> cppI = ::djinni_generated::ClientInterfaceObjcProxy::client_interface_with_objc(i);
TestHelpers::check_client_interface_ascii(std::move(cppI)); TestHelpers::check_client_interface_ascii(std::move(cppI));
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
+ (void)checkClientInterfaceNonascii:(id <DBClientInterface>)i { + (void)checkClientInterfaceNonascii:(id<DBClientInterface>)i {
try { try {
std::shared_ptr<ClientInterface> cppI = ::djinni_generated::ClientInterfaceObjcProxy::client_interface_with_objc(i); std::shared_ptr<ClientInterface> cppI = ::djinni_generated::ClientInterfaceObjcProxy::client_interface_with_objc(i);
TestHelpers::check_client_interface_nonascii(std::move(cppI)); TestHelpers::check_client_interface_nonascii(std::move(cppI));
...@@ -208,33 +209,33 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th ...@@ -208,33 +209,33 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
+ (id <DBToken>)tokenId:(id <DBToken>)t { + (DBToken*)tokenId:(DBToken*)t {
try { try {
std::shared_ptr<Token> cppT = [(DBTokenCppProxy *)t cppRef]; std::shared_ptr<Token> cppT = t.cppRef;
std::shared_ptr<Token> cppRet = TestHelpers::token_id(std::move(cppT)); std::shared_ptr<Token> cppRet = TestHelpers::token_id(std::move(cppT));
id <DBToken> objcRet = [DBTokenCppProxy tokenWithCpp:cppRet]; DBToken* objcRet = [DBToken tokenWithCpp:cppRet];
return objcRet; return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
+ (id <DBToken>)createCppToken { + (DBToken*)createCppToken {
try { try {
std::shared_ptr<Token> cppRet = TestHelpers::create_cpp_token(); std::shared_ptr<Token> cppRet = TestHelpers::create_cpp_token();
id <DBToken> objcRet = [DBTokenCppProxy tokenWithCpp:cppRet]; DBToken* objcRet = [DBToken tokenWithCpp:cppRet];
return objcRet; return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
+ (void)checkCppToken:(id <DBToken>)t { + (void)checkCppToken:(DBToken*)t {
try { try {
std::shared_ptr<Token> cppT = [(DBTokenCppProxy *)t cppRef]; std::shared_ptr<Token> cppT = t.cppRef;
TestHelpers::check_cpp_token(std::move(cppT)); TestHelpers::check_cpp_token(std::move(cppT));
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
+ (int64_t)cppTokenId:(id <DBToken>)t { + (int64_t)cppTokenId:(DBToken*)t {
try { try {
std::shared_ptr<Token> cppT = [(DBTokenCppProxy *)t cppRef]; std::shared_ptr<Token> cppT = t.cppRef;
int64_t cppRet = TestHelpers::cpp_token_id(std::move(cppT)); int64_t cppRet = TestHelpers::cpp_token_id(std::move(cppT));
int64_t objcRet = cppRet; int64_t objcRet = cppRet;
return objcRet; return objcRet;
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni
#import "DBTestHelpers.h"
#import <Foundation/Foundation.h>
@interface DBTestHelpersCppProxy : NSObject <DBTestHelpers>
@end
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
// This file generated by Djinni from token.djinni // This file generated by Djinni from token.djinni
#import "DBToken.h" #import "DBToken.h"
#import "DBTokenCppProxy.h"
#include "token.hpp" #include "token.hpp"
#import "DJICppWrapperCache+Private.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#include <memory> #include <memory>
@interface DBTokenCppProxy () @interface DBToken ()
@property (nonatomic, readonly) std::shared_ptr<Token> cppRef; @property (nonatomic, readonly) std::shared_ptr<Token> cppRef;
......
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from token.djinni // This file generated by Djinni from token.djinni
#import <Foundation/Foundation.h>
@protocol DBToken
@interface DBToken : NSObject
@end @end
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from token.djinni // This file generated by Djinni from token.djinni
#import "DBTokenCppProxy+Private.h" #import "DBToken+Private.h"
#import "DBToken.h" #import "DBToken.h"
#import "DJICppWrapperCache+Private.h"
#import "DJIDate.h" #import "DJIDate.h"
#import "DJIError.h" #import "DJIError.h"
#include <exception> #include <exception>
...@@ -11,11 +12,11 @@ ...@@ -11,11 +12,11 @@
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
@interface DBTokenCppProxy () @interface DBToken ()
@property (nonatomic, readonly) std::shared_ptr<djinni::DbxCppWrapperCache<Token>> cache; @property (nonatomic, readonly) std::shared_ptr<djinni::DbxCppWrapperCache<Token>> cache;
@end @end
@implementation DBTokenCppProxy @implementation DBToken
- (id)initWithCpp:(const std::shared_ptr<Token> &)cppRef cache:(const std::shared_ptr<djinni::DbxCppWrapperCache<Token>> &)cache - (id)initWithCpp:(const std::shared_ptr<Token> &)cppRef cache:(const std::shared_ptr<djinni::DbxCppWrapperCache<Token>> &)cache
{ {
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from token.djinni
#import "DBToken.h"
#import <Foundation/Foundation.h>
@interface DBTokenCppProxy : NSObject <DBToken>
@end
#import "DBClientInterfaceImpl.h" #import "DBClientInterfaceImpl.h"
#import "DBClientInterfaceObjcProxy+Private.h" #import "DBClientInterfaceObjcProxy+Private.h"
#import "DBTestHelpersCppProxy.h" #import "DBTestHelpers.h"
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
@interface DBClientInterfaceTests : XCTestCase @interface DBClientInterfaceTests : XCTestCase
...@@ -21,12 +21,12 @@ ...@@ -21,12 +21,12 @@
- (void)testCppString - (void)testCppString
{ {
[DBTestHelpersCppProxy checkClientInterfaceAscii:[[DBClientInterfaceImpl alloc] init]]; [DBTestHelpers checkClientInterfaceAscii:[[DBClientInterfaceImpl alloc] init]];
} }
- (void)testCppUTF8String - (void)testCppUTF8String
{ {
[DBTestHelpersCppProxy checkClientInterfaceNonascii:[[DBClientInterfaceImpl alloc] init]]; [DBTestHelpers checkClientInterfaceNonascii:[[DBClientInterfaceImpl alloc] init]];
} }
- (void)testObjcInterfaceWrapper - (void)testObjcInterfaceWrapper
......
#import "DBCppExceptionCppProxy+Private.h" #import "DBCppException+Private.h"
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#include "cpp_exception_impl.hpp" #include "cpp_exception_impl.hpp"
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
} }
- (void)testThrown { - (void)testThrown {
id <DBCppException> objcInterface = [DBCppExceptionCppProxy cppExceptionWithCpp:(std::make_shared<CppExceptionImpl>())]; DBCppException* objcInterface = [DBCppException cppExceptionWithCpp:(std::make_shared<CppExceptionImpl>())];
NSString *exceptionName = nil; NSString *exceptionName = nil;
@try { @try {
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
std::shared_ptr<CppException> cppInterface = std::make_shared<CppExceptionImpl>(); std::shared_ptr<CppException> cppInterface = std::make_shared<CppExceptionImpl>();
std::weak_ptr<CppException> weakCppInterface(cppInterface); std::weak_ptr<CppException> weakCppInterface(cppInterface);
@autoreleasepool { @autoreleasepool {
id <DBCppException> objcInterface1 = [DBCppExceptionCppProxy cppExceptionWithCpp:cppInterface]; DBCppException* objcInterface1 = [DBCppException cppExceptionWithCpp:cppInterface];
id <DBCppException> objcInterface2 = [DBCppExceptionCppProxy cppExceptionWithCpp:cppInterface]; DBCppException* objcInterface2 = [DBCppException cppExceptionWithCpp:cppInterface];
XCTAssertEqual(objcInterface1, objcInterface2, @"The same wrapper should be returned"); XCTAssertEqual(objcInterface1, objcInterface2, @"The same wrapper should be returned");
cppInterface.reset(); cppInterface.reset();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment