Commit 137c2ea8 authored by Jacob Potter's avatar Jacob Potter

Add nullability constraints to ObjC generated files.

parent 04da0e9a
......@@ -87,11 +87,15 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
def headerName(ident: String): String = idObjc.ty(ident) + "." + spec.objcHeaderExt
def bodyName(ident: String): String = idObjc.ty(ident) + ".mm" // Must be a Obj-C++ file in case the constants are not compile-time constant expressions
def writeObjcConstVariable(w: IndentWriter, c: Const, s: String): Unit = c.ty.resolved.base match {
// MBinary | MList | MSet | MMap are not allowed for constants.
// Primitives should be `const type`. All others are pointers and should be `type * const`
case t: MPrimitive => w.w(s"const ${marshal.fqFieldType(c.ty)} $s${idObjc.const(c.ident)}")
case _ => w.w(s"${marshal.fqFieldType(c.ty)} const $s${idObjc.const(c.ident)}")
def writeObjcConstVariable(w: IndentWriter, c: Const, s: String): Unit = {
val nullability = marshal.nullability(c.ty.resolved).fold("")(" __" + _)
val td = marshal.fqFieldType(c.ty) + nullability
c.ty.resolved.base match {
// MBinary | MList | MSet | MMap are not allowed for constants.
// Primitives should be `const type`. All others are pointers and should be `type * const`
case t: MPrimitive => w.w(s"const ${td} $s${idObjc.const(c.ident)}")
case _ => w.w(s"${td} const $s${idObjc.const(c.ident)}")
}
}
def generateObjcConstants(w: IndentWriter, consts: Seq[Const], selfName: String) = {
......@@ -219,12 +223,12 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
w.wl(s"@interface $self : NSObject")
// Deep copy construtor
w.wl(s"- (id)${idObjc.method("init_with_" + ident.name)}:($self *)${idObjc.local(ident)};")
w.wl(s"- (nonnull id)${idObjc.method("init_with_" + ident.name)}:(nonnull $self *)${idObjc.local(ident)};")
if (!r.fields.isEmpty) {
val head = r.fields.head
val skipFirst = SkipFirst()
val first = if(r.fields.isEmpty) "" else IdentStyle.camelUpper("with_" + r.fields.head.ident.name)
val decl = s"- (id)init$first"
val decl = s"- (nonnull id)init$first"
writeAlignedObjcCall(w, decl, r.fields, "", f => (idObjc.field(f.ident), s"(${marshal.paramType(f.ty)})${idObjc.local(f.ident)}"))
w.wl(";")
}
......@@ -232,11 +236,12 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
for (f <- r.fields) {
w.wl
writeDoc(w, f.doc)
w.wl(s"@property (nonatomic, readonly) ${marshal.fqFieldType(f.ty)} ${idObjc.field(f.ident)};")
val nullability = marshal.nullability(f.ty.resolved).fold("")(", " + _)
w.wl(s"@property (nonatomic, readonly${nullability}) ${marshal.fqFieldType(f.ty)} ${idObjc.field(f.ident)};")
}
if (r.derivingTypes.contains(DerivingType.Ord)) {
w.wl
w.wl(s"- (NSComparisonResult)compare:($self *)other;")
w.wl(s"- (NSComparisonResult)compare:(nonnull $self *)other;")
}
w.wl
w.wl("@end")
......
......@@ -16,14 +16,29 @@ class ObjcMarshal(spec: Spec) extends Marshal(spec) {
override def fqTypename(tm: MExpr): String = typename(tm)
def fqTypename(name: String, ty: TypeDef): String = typename(name, ty)
override def paramType(tm: MExpr): String = toObjcParamType(tm)
def nullability(tm: MExpr): Option[String] = {
tm.base match {
case MOptional => Some("nullable")
case MPrimitive(_,_,_,_,_,_,_,_) => None
case d: MDef => d.defType match {
case DEnum => None
case DInterface => Some("nullable")
case DRecord => Some("nonnull")
}
case _ => Some("nonnull")
}
}
override def paramType(tm: MExpr): String = {
nullability(tm).fold("")(_ + " ") + toObjcParamType(tm)
}
override def fqParamType(tm: MExpr): String = paramType(tm)
override def returnType(ret: Option[TypeRef]): String = ret.fold("void")(paramType)
override def returnType(ret: Option[TypeRef]): String = ret.fold("void")((t: TypeRef) => nullability(t.resolved).fold("")(_ + " ") + toObjcParamType(t.resolved))
override def fqReturnType(ret: Option[TypeRef]): String = returnType(ret)
override def fieldType(tm: MExpr): String = paramType(tm)
override def fqFieldType(tm: MExpr): String = fqParamType(tm)
override def fieldType(tm: MExpr): String = toObjcParamType(tm)
override def fqFieldType(tm: MExpr): String = toObjcParamType(tm)
override def toCpp(tm: MExpr, expr: String): String = throw new AssertionError("direct objc to cpp conversion not possible")
override def fromCpp(tm: MExpr, expr: String): String = throw new AssertionError("direct cpp to objc conversion not possible")
......
......@@ -4,15 +4,15 @@
#import <Foundation/Foundation.h>
@interface DBAssortedIntegers : NSObject
- (id)initWithAssortedIntegers:(DBAssortedIntegers *)assortedIntegers;
- (id)initWithEight:(int8_t)eight
sixteen:(int16_t)sixteen
thirtytwo:(int32_t)thirtytwo
sixtyfour:(int64_t)sixtyfour
oEight:(NSNumber *)oEight
oSixteen:(NSNumber *)oSixteen
oThirtytwo:(NSNumber *)oThirtytwo
oSixtyfour:(NSNumber *)oSixtyfour;
- (nonnull id)initWithAssortedIntegers:(nonnull DBAssortedIntegers *)assortedIntegers;
- (nonnull id)initWithEight:(int8_t)eight
sixteen:(int16_t)sixteen
thirtytwo:(int32_t)thirtytwo
sixtyfour:(int64_t)sixtyfour
oEight:(nullable NSNumber *)oEight
oSixteen:(nullable NSNumber *)oSixteen
oThirtytwo:(nullable NSNumber *)oThirtytwo
oSixtyfour:(nullable NSNumber *)oSixtyfour;
@property (nonatomic, readonly) int8_t eight;
......@@ -22,12 +22,12 @@
@property (nonatomic, readonly) int64_t sixtyfour;
@property (nonatomic, readonly) NSNumber * oEight;
@property (nonatomic, readonly, nullable) NSNumber * oEight;
@property (nonatomic, readonly) NSNumber * oSixteen;
@property (nonatomic, readonly, nullable) NSNumber * oSixteen;
@property (nonatomic, readonly) NSNumber * oThirtytwo;
@property (nonatomic, readonly, nullable) NSNumber * oThirtytwo;
@property (nonatomic, readonly) NSNumber * oSixtyfour;
@property (nonatomic, readonly, nullable) NSNumber * oSixtyfour;
@end
......@@ -41,10 +41,10 @@
sixteen:(int16_t)sixteen
thirtytwo:(int32_t)thirtytwo
sixtyfour:(int64_t)sixtyfour
oEight:(NSNumber *)oEight
oSixteen:(NSNumber *)oSixteen
oThirtytwo:(NSNumber *)oThirtytwo
oSixtyfour:(NSNumber *)oSixtyfour
oEight:(nullable NSNumber *)oEight
oSixteen:(nullable NSNumber *)oSixteen
oThirtytwo:(nullable NSNumber *)oThirtytwo
oSixtyfour:(nullable NSNumber *)oSixtyfour
{
if (self = [super init]) {
_eight = eight;
......
......@@ -8,8 +8,8 @@
@protocol DBClientInterface
/** Returns record of given string */
- (DBClientReturnedRecord *)getRecord:(int64_t)recordId
utf8string:(NSString *)utf8string
misc:(NSString *)misc;
- (nonnull DBClientReturnedRecord *)getRecord:(int64_t)recordId
utf8string:(nonnull NSString *)utf8string
misc:(nullable NSString *)misc;
@end
......@@ -4,15 +4,15 @@
#import <Foundation/Foundation.h>
@interface DBClientReturnedRecord : NSObject
- (id)initWithClientReturnedRecord:(DBClientReturnedRecord *)clientReturnedRecord;
- (id)initWithRecordId:(int64_t)recordId
content:(NSString *)content
misc:(NSString *)misc;
- (nonnull id)initWithClientReturnedRecord:(nonnull DBClientReturnedRecord *)clientReturnedRecord;
- (nonnull id)initWithRecordId:(int64_t)recordId
content:(nonnull NSString *)content
misc:(nullable NSString *)misc;
@property (nonatomic, readonly) int64_t recordId;
@property (nonatomic, readonly) NSString * content;
@property (nonatomic, readonly, nonnull) NSString * content;
@property (nonatomic, readonly) NSString * misc;
@property (nonatomic, readonly, nullable) NSString * misc;
@end
......@@ -21,8 +21,8 @@
}
- (id)initWithRecordId:(int64_t)recordId
content:(NSString *)content
misc:(NSString *)misc
content:(nonnull NSString *)content
misc:(nullable NSString *)misc
{
if (self = [super init]) {
_recordId = recordId;
......
......@@ -5,13 +5,13 @@
@class DBConstants;
@interface DBConstants : NSObject
- (id)initWithConstants:(DBConstants *)constants;
- (id)initWithSomeInteger:(int32_t)someInteger
someString:(NSString *)someString;
- (nonnull id)initWithConstants:(nonnull DBConstants *)constants;
- (nonnull id)initWithSomeInteger:(int32_t)someInteger
someString:(nonnull NSString *)someString;
@property (nonatomic, readonly) int32_t someInteger;
@property (nonatomic, readonly) NSString * someString;
@property (nonatomic, readonly, nonnull) NSString * someString;
@end
......@@ -21,6 +21,6 @@ extern const int16_t DBConstantsI16Constant;
extern const int32_t DBConstantsI32Constant;
extern const int64_t DBConstantsI64Constant;
extern const double DBConstantsF64Constant;
extern NSString * const DBConstantsStringConstant;
extern NSNumber * const DBConstantsOptionalIntegerConstant;
extern DBConstants * const DBConstantsObjectConstant;
extern NSString * __nonnull const DBConstantsStringConstant;
extern NSNumber * __nullable const DBConstantsOptionalIntegerConstant;
extern DBConstants * __nonnull const DBConstantsObjectConstant;
......@@ -19,11 +19,11 @@ const int64_t DBConstantsI64Constant = 4;
const double DBConstantsF64Constant = 5.0;
NSString * const DBConstantsStringConstant = @"string-constant";
NSString * __nonnull const DBConstantsStringConstant = @"string-constant";
NSNumber * const DBConstantsOptionalIntegerConstant = @1;
NSNumber * __nullable const DBConstantsOptionalIntegerConstant = @1;
DBConstants * const DBConstantsObjectConstant = [[DBConstants alloc] initWithSomeInteger:DBConstantsI32Constant
DBConstants * __nonnull const DBConstantsObjectConstant = [[DBConstants alloc] initWithSomeInteger:DBConstantsI32Constant
someString:DBConstantsStringConstant];
#pragma clang diagnostic pop
......@@ -40,7 +40,7 @@ DBConstants * const DBConstantsObjectConstant = [[DBConstants alloc] initWithSom
}
- (id)initWithSomeInteger:(int32_t)someInteger
someString:(NSString *)someString
someString:(nonnull NSString *)someString
{
if (self = [super init]) {
_someInteger = someInteger;
......
......@@ -9,6 +9,6 @@
- (int32_t)throwAnException;
+ (DBCppException *)get;
+ (nullable DBCppException *)get;
@end
......@@ -56,7 +56,7 @@ auto CppException::fromCpp(const CppType& cpp) -> ObjcType
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (DBCppException *)get {
+ (nullable DBCppException *)get {
try {
auto r = ::CppException::get();
return ::djinni_generated::CppException::fromCpp(r);
......
......@@ -4,9 +4,9 @@
#import <Foundation/Foundation.h>
@interface DBDateRecord : NSObject
- (id)initWithDateRecord:(DBDateRecord *)dateRecord;
- (id)initWithCreatedAt:(NSDate *)createdAt;
- (nonnull id)initWithDateRecord:(nonnull DBDateRecord *)dateRecord;
- (nonnull id)initWithCreatedAt:(nonnull NSDate *)createdAt;
@property (nonatomic, readonly) NSDate * createdAt;
@property (nonatomic, readonly, nonnull) NSDate * createdAt;
@end
......@@ -14,7 +14,7 @@
return self;
}
- (id)initWithCreatedAt:(NSDate *)createdAt
- (id)initWithCreatedAt:(nonnull NSDate *)createdAt
{
if (self = [super init]) {
_createdAt = createdAt;
......
......@@ -4,9 +4,9 @@
#import <Foundation/Foundation.h>
@interface DBMapDateRecord : NSObject
- (id)initWithMapDateRecord:(DBMapDateRecord *)mapDateRecord;
- (id)initWithDatesById:(NSDictionary *)datesById;
- (nonnull id)initWithMapDateRecord:(nonnull DBMapDateRecord *)mapDateRecord;
- (nonnull id)initWithDatesById:(nonnull NSDictionary *)datesById;
@property (nonatomic, readonly) NSDictionary * datesById;
@property (nonatomic, readonly, nonnull) NSDictionary * datesById;
@end
......@@ -22,7 +22,7 @@
return self;
}
- (id)initWithDatesById:(NSDictionary *)datesById
- (id)initWithDatesById:(nonnull NSDictionary *)datesById
{
if (self = [super init]) {
_datesById = datesById;
......
......@@ -4,9 +4,9 @@
#import <Foundation/Foundation.h>
@interface DBMapListRecord : NSObject
- (id)initWithMapListRecord:(DBMapListRecord *)mapListRecord;
- (id)initWithMapList:(NSArray *)mapList;
- (nonnull id)initWithMapListRecord:(nonnull DBMapListRecord *)mapListRecord;
- (nonnull id)initWithMapList:(nonnull NSArray *)mapList;
@property (nonatomic, readonly) NSArray * mapList;
@property (nonatomic, readonly, nonnull) NSArray * mapList;
@end
......@@ -28,7 +28,7 @@
return self;
}
- (id)initWithMapList:(NSArray *)mapList
- (id)initWithMapList:(nonnull NSArray *)mapList
{
if (self = [super init]) {
_mapList = mapList;
......
......@@ -4,9 +4,9 @@
#import <Foundation/Foundation.h>
@interface DBMapRecord : NSObject
- (id)initWithMapRecord:(DBMapRecord *)mapRecord;
- (id)initWithMap:(NSDictionary *)map;
- (nonnull id)initWithMapRecord:(nonnull DBMapRecord *)mapRecord;
- (nonnull id)initWithMap:(nonnull NSDictionary *)map;
@property (nonatomic, readonly) NSDictionary * map;
@property (nonatomic, readonly, nonnull) NSDictionary * map;
@end
......@@ -22,7 +22,7 @@
return self;
}
- (id)initWithMap:(NSDictionary *)map
- (id)initWithMap:(nonnull NSDictionary *)map
{
if (self = [super init]) {
_map = map;
......
......@@ -4,9 +4,9 @@
#import <Foundation/Foundation.h>
@interface DBNestedCollection : NSObject
- (id)initWithNestedCollection:(DBNestedCollection *)nestedCollection;
- (id)initWithSetList:(NSArray *)setList;
- (nonnull id)initWithNestedCollection:(nonnull DBNestedCollection *)nestedCollection;
- (nonnull id)initWithSetList:(nonnull NSArray *)setList;
@property (nonatomic, readonly) NSArray * setList;
@property (nonatomic, readonly, nonnull) NSArray * setList;
@end
......@@ -26,7 +26,7 @@
return self;
}
- (id)initWithSetList:(NSArray *)setList
- (id)initWithSetList:(nonnull NSArray *)setList
{
if (self = [super init]) {
_setList = setList;
......
......@@ -4,9 +4,9 @@
#import <Foundation/Foundation.h>
@interface DBPrimitiveList : NSObject
- (id)initWithPrimitiveList:(DBPrimitiveList *)primitiveList;
- (id)initWithList:(NSArray *)list;
- (nonnull id)initWithPrimitiveList:(nonnull DBPrimitiveList *)primitiveList;
- (nonnull id)initWithList:(nonnull NSArray *)list;
@property (nonatomic, readonly) NSArray * list;
@property (nonatomic, readonly, nonnull) NSArray * list;
@end
......@@ -20,7 +20,7 @@
return self;
}
- (id)initWithList:(NSArray *)list
- (id)initWithList:(nonnull NSArray *)list
{
if (self = [super init]) {
_list = list;
......
......@@ -4,14 +4,14 @@
#import <Foundation/Foundation.h>
@interface DBRecordWithDerivings : NSObject
- (id)initWithRecordWithDerivings:(DBRecordWithDerivings *)recordWithDerivings;
- (id)initWithKey1:(int32_t)key1
key2:(NSString *)key2;
- (nonnull id)initWithRecordWithDerivings:(nonnull DBRecordWithDerivings *)recordWithDerivings;
- (nonnull id)initWithKey1:(int32_t)key1
key2:(nonnull NSString *)key2;
@property (nonatomic, readonly) int32_t key1;
@property (nonatomic, readonly) NSString * key2;
@property (nonatomic, readonly, nonnull) NSString * key2;
- (NSComparisonResult)compare:(DBRecordWithDerivings *)other;
- (NSComparisonResult)compare:(nonnull DBRecordWithDerivings *)other;
@end
......@@ -16,7 +16,7 @@
}
- (id)initWithKey1:(int32_t)key1
key2:(NSString *)key2
key2:(nonnull NSString *)key2
{
if (self = [super init]) {
_key1 = key1;
......
......@@ -5,14 +5,14 @@
@class DBRecordWithDerivings;
@interface DBRecordWithNestedDerivings : NSObject
- (id)initWithRecordWithNestedDerivings:(DBRecordWithNestedDerivings *)recordWithNestedDerivings;
- (id)initWithKey:(int32_t)key
rec:(DBRecordWithDerivings *)rec;
- (nonnull id)initWithRecordWithNestedDerivings:(nonnull DBRecordWithNestedDerivings *)recordWithNestedDerivings;
- (nonnull id)initWithKey:(int32_t)key
rec:(nonnull DBRecordWithDerivings *)rec;
@property (nonatomic, readonly) int32_t key;
@property (nonatomic, readonly) DBRecordWithDerivings * rec;
@property (nonatomic, readonly, nonnull) DBRecordWithDerivings * rec;
- (NSComparisonResult)compare:(DBRecordWithNestedDerivings *)other;
- (NSComparisonResult)compare:(nonnull DBRecordWithNestedDerivings *)other;
@end
......@@ -17,7 +17,7 @@
}
- (id)initWithKey:(int32_t)key
rec:(DBRecordWithDerivings *)rec
rec:(nonnull DBRecordWithDerivings *)rec
{
if (self = [super init]) {
_key = key;
......
......@@ -4,9 +4,9 @@
#import <Foundation/Foundation.h>
@interface DBSetRecord : NSObject
- (id)initWithSetRecord:(DBSetRecord *)setRecord;
- (id)initWithSet:(NSSet *)set;
- (nonnull id)initWithSetRecord:(nonnull DBSetRecord *)setRecord;
- (nonnull id)initWithSet:(nonnull NSSet *)set;
@property (nonatomic, readonly) NSSet * set;
@property (nonatomic, readonly, nonnull) NSSet * set;
@end
......@@ -20,7 +20,7 @@
return self;
}
- (id)initWithSet:(NSSet *)set
- (id)initWithSet:(nonnull NSSet *)set
{
if (self = [super init]) {
_set = set;
......
......@@ -14,49 +14,49 @@
@interface DBTestHelpers : NSObject
+ (DBSetRecord *)getSetRecord;
+ (nonnull DBSetRecord *)getSetRecord;
+ (BOOL)checkSetRecord:(DBSetRecord *)rec;
+ (BOOL)checkSetRecord:(nonnull DBSetRecord *)rec;
+ (DBPrimitiveList *)getPrimitiveList;
+ (nonnull DBPrimitiveList *)getPrimitiveList;
+ (BOOL)checkPrimitiveList:(DBPrimitiveList *)pl;
+ (BOOL)checkPrimitiveList:(nonnull DBPrimitiveList *)pl;
+ (DBNestedCollection *)getNestedCollection;
+ (nonnull DBNestedCollection *)getNestedCollection;
+ (BOOL)checkNestedCollection:(DBNestedCollection *)nc;
+ (BOOL)checkNestedCollection:(nonnull DBNestedCollection *)nc;
+ (NSDictionary *)getMap;
+ (nonnull NSDictionary *)getMap;
+ (BOOL)checkMap:(NSDictionary *)m;
+ (BOOL)checkMap:(nonnull NSDictionary *)m;
+ (NSDictionary *)getEmptyMap;
+ (nonnull NSDictionary *)getEmptyMap;
+ (BOOL)checkEmptyMap:(NSDictionary *)m;
+ (BOOL)checkEmptyMap:(nonnull NSDictionary *)m;
+ (DBMapListRecord *)getMapListRecord;
+ (nonnull DBMapListRecord *)getMapListRecord;
+ (BOOL)checkMapListRecord:(DBMapListRecord *)m;
+ (BOOL)checkMapListRecord:(nonnull DBMapListRecord *)m;
+ (void)checkClientInterfaceAscii:(id<DBClientInterface>)i;
+ (void)checkClientInterfaceAscii:(nullable id<DBClientInterface>)i;
+ (void)checkClientInterfaceNonascii:(id<DBClientInterface>)i;
+ (void)checkClientInterfaceNonascii:(nullable id<DBClientInterface>)i;
+ (void)checkEnumMap:(NSDictionary *)m;
+ (void)checkEnumMap:(nonnull NSDictionary *)m;
+ (void)checkEnum:(DBColor)c;
+ (DBToken *)tokenId:(DBToken *)t;
+ (nullable DBToken *)tokenId:(nullable DBToken *)t;
+ (DBToken *)createCppToken;
+ (nullable DBToken *)createCppToken;
+ (void)checkCppToken:(DBToken *)t;
+ (void)checkCppToken:(nullable DBToken *)t;
+ (int64_t)cppTokenId:(DBToken *)t;
+ (int64_t)cppTokenId:(nullable DBToken *)t;
+ (NSNumber *)returnNone;
+ (nullable NSNumber *)returnNone;
/** Ensures that we generate integer translation code */
+ (DBAssortedIntegers *)assortedIntegersId:(DBAssortedIntegers *)i;
+ (nonnull DBAssortedIntegers *)assortedIntegersId:(nonnull DBAssortedIntegers *)i;
@end
......@@ -55,103 +55,103 @@ auto TestHelpers::fromCpp(const CppType& cpp) -> ObjcType
return self;
}
+ (DBSetRecord *)getSetRecord {
+ (nonnull DBSetRecord *)getSetRecord {
try {
auto r = ::TestHelpers::get_set_record();
return ::djinni_generated::SetRecord::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (BOOL)checkSetRecord:(DBSetRecord *)rec {
+ (BOOL)checkSetRecord:(nonnull DBSetRecord *)rec {
try {
auto r = ::TestHelpers::check_set_record(::djinni_generated::SetRecord::toCpp(rec));
return ::djinni::Bool::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (DBPrimitiveList *)getPrimitiveList {
+ (nonnull DBPrimitiveList *)getPrimitiveList {
try {
auto r = ::TestHelpers::get_primitive_list();
return ::djinni_generated::PrimitiveList::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (BOOL)checkPrimitiveList:(DBPrimitiveList *)pl {
+ (BOOL)checkPrimitiveList:(nonnull DBPrimitiveList *)pl {
try {
auto r = ::TestHelpers::check_primitive_list(::djinni_generated::PrimitiveList::toCpp(pl));
return ::djinni::Bool::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (DBNestedCollection *)getNestedCollection {
+ (nonnull DBNestedCollection *)getNestedCollection {
try {
auto r = ::TestHelpers::get_nested_collection();
return ::djinni_generated::NestedCollection::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (BOOL)checkNestedCollection:(DBNestedCollection *)nc {
+ (BOOL)checkNestedCollection:(nonnull DBNestedCollection *)nc {
try {
auto r = ::TestHelpers::check_nested_collection(::djinni_generated::NestedCollection::toCpp(nc));
return ::djinni::Bool::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (NSDictionary *)getMap {
+ (nonnull NSDictionary *)getMap {
try {
auto r = ::TestHelpers::get_map();
return ::djinni::Map<::djinni::String, ::djinni::I64>::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (BOOL)checkMap:(NSDictionary *)m {
+ (BOOL)checkMap:(nonnull NSDictionary *)m {
try {
auto r = ::TestHelpers::check_map(::djinni::Map<::djinni::String, ::djinni::I64>::toCpp(m));
return ::djinni::Bool::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (NSDictionary *)getEmptyMap {
+ (nonnull NSDictionary *)getEmptyMap {
try {
auto r = ::TestHelpers::get_empty_map();
return ::djinni::Map<::djinni::String, ::djinni::I64>::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (BOOL)checkEmptyMap:(NSDictionary *)m {
+ (BOOL)checkEmptyMap:(nonnull NSDictionary *)m {
try {
auto r = ::TestHelpers::check_empty_map(::djinni::Map<::djinni::String, ::djinni::I64>::toCpp(m));
return ::djinni::Bool::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (DBMapListRecord *)getMapListRecord {
+ (nonnull DBMapListRecord *)getMapListRecord {
try {
auto r = ::TestHelpers::get_map_list_record();
return ::djinni_generated::MapListRecord::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (BOOL)checkMapListRecord:(DBMapListRecord *)m {
+ (BOOL)checkMapListRecord:(nonnull DBMapListRecord *)m {
try {
auto r = ::TestHelpers::check_map_list_record(::djinni_generated::MapListRecord::toCpp(m));
return ::djinni::Bool::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (void)checkClientInterfaceAscii:(id<DBClientInterface>)i {
+ (void)checkClientInterfaceAscii:(nullable id<DBClientInterface>)i {
try {
::TestHelpers::check_client_interface_ascii(::djinni_generated::ClientInterface::toCpp(i));
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (void)checkClientInterfaceNonascii:(id<DBClientInterface>)i {
+ (void)checkClientInterfaceNonascii:(nullable id<DBClientInterface>)i {
try {
::TestHelpers::check_client_interface_nonascii(::djinni_generated::ClientInterface::toCpp(i));
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (void)checkEnumMap:(NSDictionary *)m {
+ (void)checkEnumMap:(nonnull NSDictionary *)m {
try {
::TestHelpers::check_enum_map(::djinni::Map<::djinni::Enum<::color, DBColor>, ::djinni::String>::toCpp(m));
} DJINNI_TRANSLATE_EXCEPTIONS()
......@@ -163,41 +163,41 @@ auto TestHelpers::fromCpp(const CppType& cpp) -> ObjcType
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (DBToken *)tokenId:(DBToken *)t {
+ (nullable DBToken *)tokenId:(nullable DBToken *)t {
try {
auto r = ::TestHelpers::token_id(::djinni_generated::Token::toCpp(t));
return ::djinni_generated::Token::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (DBToken *)createCppToken {
+ (nullable DBToken *)createCppToken {
try {
auto r = ::TestHelpers::create_cpp_token();
return ::djinni_generated::Token::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (void)checkCppToken:(DBToken *)t {
+ (void)checkCppToken:(nullable DBToken *)t {
try {
::TestHelpers::check_cpp_token(::djinni_generated::Token::toCpp(t));
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (int64_t)cppTokenId:(DBToken *)t {
+ (int64_t)cppTokenId:(nullable DBToken *)t {
try {
auto r = ::TestHelpers::cpp_token_id(::djinni_generated::Token::toCpp(t));
return ::djinni::I64::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (NSNumber *)returnNone {
+ (nullable NSNumber *)returnNone {
try {
auto r = ::TestHelpers::return_none();
return ::djinni::Optional<std::experimental::optional, ::djinni::I32>::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (DBAssortedIntegers *)assortedIntegersId:(DBAssortedIntegers *)i {
+ (nonnull DBAssortedIntegers *)assortedIntegersId:(nonnull DBAssortedIntegers *)i {
try {
auto r = ::TestHelpers::assorted_integers_id(::djinni_generated::AssortedIntegers::toCpp(i));
return ::djinni_generated::AssortedIntegers::fromCpp(r);
......
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