Commit 083ac0eb authored by Jacob Potter's avatar Jacob Potter

Merge branch 'nullability'

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