Commit 449ed7e9 authored by Miro Knejp's avatar Miro Knejp

Generate convenience initializers for Objective-C records

This provides a consistent pair of initializers for all records:
- (nonnull instancetype)initWithArg:(A*)arg;
+ (nonnull instancetype)myRecordWithArg:(A*)arg;

The static convenience initializer is only created for records *without*
the +o extension. This also applies to records with no members. Now even
empty records have a designated initializer.
parent 708d6218
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface TXSItemList : NSObject @interface TXSItemList : NSObject
- (nonnull id)initWithItems:(nonnull NSArray *)items; - (nonnull instancetype)initWithItems:(nonnull NSArray *)items;
+ (nonnull instancetype)itemListWithItems:(nonnull NSArray *)items;
@property (nonatomic, readonly, nonnull) NSArray * items; @property (nonatomic, readonly, nonnull) NSArray * items;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
@implementation TXSItemList @implementation TXSItemList
- (id)initWithItems:(nonnull NSArray *)items - (nonnull instancetype)initWithItems:(nonnull NSArray *)items
{ {
if (self = [super init]) { if (self = [super init]) {
_items = items; _items = items;
...@@ -14,4 +14,9 @@ ...@@ -14,4 +14,9 @@
return self; return self;
} }
+ (nonnull instancetype)itemListWithItems:(nonnull NSArray *)items
{
return [[self alloc] initWithItems:items];
}
@end @end
...@@ -191,19 +191,21 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -191,19 +191,21 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
case _ => false case _ => false
} }
val firstInitializerArg = if(r.fields.isEmpty) "" else IdentStyle.camelUpper("with_" + r.fields.head.ident.name)
writeObjcFile(marshal.headerName(objcName), origin, refs.header, w => { writeObjcFile(marshal.headerName(objcName), origin, refs.header, w => {
writeDoc(w, doc) writeDoc(w, doc)
w.wl(s"@interface $self : NSObject") w.wl(s"@interface $self : NSObject")
if (!r.fields.isEmpty) { def writeInitializer(sign: String, prefix: String) {
val head = r.fields.head val decl = s"$sign (nonnull instancetype)$prefix$firstInitializerArg"
val skipFirst = SkipFirst()
val first = if(r.fields.isEmpty) "" else IdentStyle.camelUpper("with_" + r.fields.head.ident.name)
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(";")
} }
writeInitializer("-", "init")
if (!r.ext.objc) writeInitializer("+", IdentStyle.camelLower(objcName))
for (f <- r.fields) { for (f <- r.fields) {
w.wl w.wl
writeDoc(w, f.doc) writeDoc(w, f.doc)
...@@ -234,22 +236,31 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { ...@@ -234,22 +236,31 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
w.wl(s"@implementation $self") w.wl(s"@implementation $self")
w.wl w.wl
// Constructor from all fields (not copying) // Constructor from all fields (not copying)
if (!r.fields.isEmpty) { val init = s"- (nonnull instancetype)init$firstInitializerArg"
val head = r.fields.head writeAlignedObjcCall(w, init, r.fields, "", f => (idObjc.field(f.ident), s"(${marshal.paramType(f.ty)})${idObjc.local(f.ident)}"))
val skipFirst = SkipFirst() w.wl
val decl = s"- (id)${idObjc.method("init_with_" + head.ident.name)}" w.braced {
w.w("if (self = [super init])").braced {
for (f <- r.fields) {
if (checkMutable(f.ty.resolved))
w.wl(s"_${idObjc.field(f.ident)} = [${idObjc.local(f.ident)} copy];")
else
w.wl(s"_${idObjc.field(f.ident)} = ${idObjc.local(f.ident)};")
}
}
w.wl("return self;")
}
w.wl
// Convenience initializer
if(!r.ext.objc) {
val decl = s"+ (nonnull instancetype)${IdentStyle.camelLower(objcName)}$firstInitializerArg"
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
w.braced { w.braced {
w.w("if (self = [super init])").braced { val call = s"return [[self alloc] init$firstInitializerArg"
for (f <- r.fields) { writeAlignedObjcCall(w, call, r.fields, "", f => (idObjc.field(f.ident), s"${idObjc.local(f.ident)}"))
if (checkMutable(f.ty.resolved)) w.wl("];")
w.wl(s"_${idObjc.field(f.ident)} = [${idObjc.local(f.ident)} copy];")
else
w.wl(s"_${idObjc.field(f.ident)} = ${idObjc.local(f.ident)};")
}
}
w.wl("return self;")
} }
w.wl w.wl
} }
......
...@@ -34,3 +34,7 @@ test_helpers = interface +c { ...@@ -34,3 +34,7 @@ test_helpers = interface +c {
static id_binary(b: binary): binary; static id_binary(b: binary): binary;
} }
empty_record = record {
}
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni
#pragma once
#include <utility>
struct EmptyRecord final {
};
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni
package com.dropbox.djinni.test;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
public final class EmptyRecord {
public EmptyRecord(
) {
}
}
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni
#include "NativeEmptyRecord.hpp" // my header
namespace djinni_generated {
NativeEmptyRecord::NativeEmptyRecord() = default;
NativeEmptyRecord::~NativeEmptyRecord() = default;
auto NativeEmptyRecord::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef<JniType> {
(void)c; // Suppress warnings in release builds for empty records
const auto& data = ::djinni::JniClass<NativeEmptyRecord>::get();
auto r = ::djinni::LocalRef<JniType>{jniEnv->NewObject(data.clazz.get(), data.jconstructor)};
::djinni::jniExceptionCheck(jniEnv);
return r;
}
auto NativeEmptyRecord::toCpp(JNIEnv* jniEnv, JniType j) -> CppType {
::djinni::JniLocalScope jscope(jniEnv, 1);
assert(j != nullptr);
(void)j; // Suppress warnings in release builds for empty records
return {};
}
} // namespace djinni_generated
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni
#pragma once
#include "djinni_support.hpp"
#include "empty_record.hpp"
namespace djinni_generated {
class NativeEmptyRecord final {
public:
using CppType = ::EmptyRecord;
using JniType = jobject;
using Boxed = NativeEmptyRecord;
~NativeEmptyRecord();
static CppType toCpp(JNIEnv* jniEnv, JniType j);
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c);
private:
NativeEmptyRecord();
friend ::djinni::JniClass<NativeEmptyRecord>;
const ::djinni::GlobalRef<jclass> clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/EmptyRecord") };
const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "<init>", "()V") };
};
} // namespace djinni_generated
...@@ -4,20 +4,34 @@ ...@@ -4,20 +4,34 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBAssortedPrimitives : NSObject @interface DBAssortedPrimitives : NSObject
- (nonnull id)initWithB:(BOOL)b - (nonnull instancetype)initWithB:(BOOL)b
eight:(int8_t)eight eight:(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
fthirtytwo:(float)fthirtytwo fthirtytwo:(float)fthirtytwo
fsixtyfour:(double)fsixtyfour fsixtyfour:(double)fsixtyfour
oB:(nullable NSNumber *)oB oB:(nullable NSNumber *)oB
oEight:(nullable NSNumber *)oEight oEight:(nullable NSNumber *)oEight
oSixteen:(nullable NSNumber *)oSixteen oSixteen:(nullable NSNumber *)oSixteen
oThirtytwo:(nullable NSNumber *)oThirtytwo oThirtytwo:(nullable NSNumber *)oThirtytwo
oSixtyfour:(nullable NSNumber *)oSixtyfour oSixtyfour:(nullable NSNumber *)oSixtyfour
oFthirtytwo:(nullable NSNumber *)oFthirtytwo oFthirtytwo:(nullable NSNumber *)oFthirtytwo
oFsixtyfour:(nullable NSNumber *)oFsixtyfour; oFsixtyfour:(nullable NSNumber *)oFsixtyfour;
+ (nonnull instancetype)assortedPrimitivesWithB:(BOOL)b
eight:(int8_t)eight
sixteen:(int16_t)sixteen
thirtytwo:(int32_t)thirtytwo
sixtyfour:(int64_t)sixtyfour
fthirtytwo:(float)fthirtytwo
fsixtyfour:(double)fsixtyfour
oB:(nullable NSNumber *)oB
oEight:(nullable NSNumber *)oEight
oSixteen:(nullable NSNumber *)oSixteen
oThirtytwo:(nullable NSNumber *)oThirtytwo
oSixtyfour:(nullable NSNumber *)oSixtyfour
oFthirtytwo:(nullable NSNumber *)oFthirtytwo
oFsixtyfour:(nullable NSNumber *)oFsixtyfour;
@property (nonatomic, readonly) BOOL b; @property (nonatomic, readonly) BOOL b;
......
...@@ -6,20 +6,20 @@ ...@@ -6,20 +6,20 @@
@implementation DBAssortedPrimitives @implementation DBAssortedPrimitives
- (id)initWithB:(BOOL)b - (nonnull instancetype)initWithB:(BOOL)b
eight:(int8_t)eight eight:(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
fthirtytwo:(float)fthirtytwo fthirtytwo:(float)fthirtytwo
fsixtyfour:(double)fsixtyfour fsixtyfour:(double)fsixtyfour
oB:(nullable NSNumber *)oB oB:(nullable NSNumber *)oB
oEight:(nullable NSNumber *)oEight oEight:(nullable NSNumber *)oEight
oSixteen:(nullable NSNumber *)oSixteen oSixteen:(nullable NSNumber *)oSixteen
oThirtytwo:(nullable NSNumber *)oThirtytwo oThirtytwo:(nullable NSNumber *)oThirtytwo
oSixtyfour:(nullable NSNumber *)oSixtyfour oSixtyfour:(nullable NSNumber *)oSixtyfour
oFthirtytwo:(nullable NSNumber *)oFthirtytwo oFthirtytwo:(nullable NSNumber *)oFthirtytwo
oFsixtyfour:(nullable NSNumber *)oFsixtyfour oFsixtyfour:(nullable NSNumber *)oFsixtyfour
{ {
if (self = [super init]) { if (self = [super init]) {
_b = b; _b = b;
...@@ -40,6 +40,37 @@ ...@@ -40,6 +40,37 @@
return self; return self;
} }
+ (nonnull instancetype)assortedPrimitivesWithB:(BOOL)b
eight:(int8_t)eight
sixteen:(int16_t)sixteen
thirtytwo:(int32_t)thirtytwo
sixtyfour:(int64_t)sixtyfour
fthirtytwo:(float)fthirtytwo
fsixtyfour:(double)fsixtyfour
oB:(nullable NSNumber *)oB
oEight:(nullable NSNumber *)oEight
oSixteen:(nullable NSNumber *)oSixteen
oThirtytwo:(nullable NSNumber *)oThirtytwo
oSixtyfour:(nullable NSNumber *)oSixtyfour
oFthirtytwo:(nullable NSNumber *)oFthirtytwo
oFsixtyfour:(nullable NSNumber *)oFsixtyfour
{
return [[self alloc] initWithB:b
eight:eight
sixteen:sixteen
thirtytwo:thirtytwo
sixtyfour:sixtyfour
fthirtytwo:fthirtytwo
fsixtyfour:fsixtyfour
oB:oB
oEight:oEight
oSixteen:oSixteen
oThirtytwo:oThirtytwo
oSixtyfour:oSixtyfour
oFthirtytwo:oFthirtytwo
oFsixtyfour:oFsixtyfour];
}
- (BOOL)isEqual:(id)other - (BOOL)isEqual:(id)other
{ {
if (![other isKindOfClass:[DBAssortedPrimitives class]]) { if (![other isKindOfClass:[DBAssortedPrimitives class]]) {
......
...@@ -4,9 +4,12 @@ ...@@ -4,9 +4,12 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBClientReturnedRecord : NSObject @interface DBClientReturnedRecord : NSObject
- (nonnull id)initWithRecordId:(int64_t)recordId - (nonnull instancetype)initWithRecordId:(int64_t)recordId
content:(nonnull NSString *)content content:(nonnull NSString *)content
misc:(nullable NSString *)misc; misc:(nullable NSString *)misc;
+ (nonnull instancetype)clientReturnedRecordWithRecordId:(int64_t)recordId
content:(nonnull NSString *)content
misc:(nullable NSString *)misc;
@property (nonatomic, readonly) int64_t recordId; @property (nonatomic, readonly) int64_t recordId;
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
@implementation DBClientReturnedRecord @implementation DBClientReturnedRecord
- (id)initWithRecordId:(int64_t)recordId - (nonnull instancetype)initWithRecordId:(int64_t)recordId
content:(nonnull NSString *)content content:(nonnull NSString *)content
misc:(nullable NSString *)misc misc:(nullable NSString *)misc
{ {
if (self = [super init]) { if (self = [super init]) {
_recordId = recordId; _recordId = recordId;
...@@ -18,4 +18,13 @@ ...@@ -18,4 +18,13 @@
return self; return self;
} }
+ (nonnull instancetype)clientReturnedRecordWithRecordId:(int64_t)recordId
content:(nonnull NSString *)content
misc:(nullable NSString *)misc
{
return [[self alloc] initWithRecordId:recordId
content:content
misc:misc];
}
@end @end
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBConstants : NSObject @interface DBConstants : NSObject
- (nonnull id)initWithSomeInteger:(int32_t)someInteger - (nonnull instancetype)initWithSomeInteger:(int32_t)someInteger
someString:(nonnull NSString *)someString; someString:(nonnull NSString *)someString;
+ (nonnull instancetype)constantsWithSomeInteger:(int32_t)someInteger
someString:(nonnull NSString *)someString;
@property (nonatomic, readonly) int32_t someInteger; @property (nonatomic, readonly) int32_t someInteger;
......
...@@ -31,8 +31,8 @@ DBConstants * __nonnull const DBConstantsObjectConstant = [[DBConstants alloc] i ...@@ -31,8 +31,8 @@ DBConstants * __nonnull const DBConstantsObjectConstant = [[DBConstants alloc] i
@implementation DBConstants @implementation DBConstants
- (id)initWithSomeInteger:(int32_t)someInteger - (nonnull instancetype)initWithSomeInteger:(int32_t)someInteger
someString:(nonnull NSString *)someString someString:(nonnull NSString *)someString
{ {
if (self = [super init]) { if (self = [super init]) {
_someInteger = someInteger; _someInteger = someInteger;
...@@ -41,4 +41,11 @@ DBConstants * __nonnull const DBConstantsObjectConstant = [[DBConstants alloc] i ...@@ -41,4 +41,11 @@ DBConstants * __nonnull const DBConstantsObjectConstant = [[DBConstants alloc] i
return self; return self;
} }
+ (nonnull instancetype)constantsWithSomeInteger:(int32_t)someInteger
someString:(nonnull NSString *)someString
{
return [[self alloc] initWithSomeInteger:someInteger
someString:someString];
}
@end @end
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBDateRecord : NSObject @interface DBDateRecord : NSObject
- (nonnull id)initWithCreatedAt:(nonnull NSDate *)createdAt; - (nonnull instancetype)initWithCreatedAt:(nonnull NSDate *)createdAt;
+ (nonnull instancetype)dateRecordWithCreatedAt:(nonnull NSDate *)createdAt;
@property (nonatomic, readonly, nonnull) NSDate * createdAt; @property (nonatomic, readonly, nonnull) NSDate * createdAt;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
@implementation DBDateRecord @implementation DBDateRecord
- (id)initWithCreatedAt:(nonnull NSDate *)createdAt - (nonnull instancetype)initWithCreatedAt:(nonnull NSDate *)createdAt
{ {
if (self = [super init]) { if (self = [super init]) {
_createdAt = createdAt; _createdAt = createdAt;
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
return self; return self;
} }
+ (nonnull instancetype)dateRecordWithCreatedAt:(nonnull NSDate *)createdAt
{
return [[self alloc] initWithCreatedAt:createdAt];
}
- (BOOL)isEqual:(id)other - (BOOL)isEqual:(id)other
{ {
if (![other isKindOfClass:[DBDateRecord class]]) { if (![other isKindOfClass:[DBDateRecord class]]) {
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni
#import "DBEmptyRecord.h"
#include "empty_record.hpp"
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
@class DBEmptyRecord;
namespace djinni_generated {
struct EmptyRecord
{
using CppType = ::EmptyRecord;
using ObjcType = DBEmptyRecord*;
using Boxed = EmptyRecord;
static CppType toCpp(ObjcType objc);
static ObjcType fromCpp(const CppType& cpp);
};
} // namespace djinni_generated
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni
#import "DBEmptyRecord+Private.h"
#include <cassert>
namespace djinni_generated {
auto EmptyRecord::toCpp(ObjcType obj) -> CppType
{
assert(obj);
(void)obj; // Suppress warnings in relase builds for empty records
return {};
}
auto EmptyRecord::fromCpp(const CppType& cpp) -> ObjcType
{
(void)cpp; // Suppress warnings in relase builds for empty records
return [[DBEmptyRecord alloc] init];
}
} // namespace djinni_generated
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni
#import <Foundation/Foundation.h>
@interface DBEmptyRecord : NSObject
- (nonnull instancetype)init;
+ (nonnull instancetype)emptyRecord;
@end
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni
#import "DBEmptyRecord.h"
@implementation DBEmptyRecord
- (nonnull instancetype)init
{
if (self = [super init]) {
}
return self;
}
+ (nonnull instancetype)emptyRecord
{
return [[self alloc] init];
}
@end
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
/** This file tests YAML dumped by Djinni can be parsed back in */ /** This file tests YAML dumped by Djinni can be parsed back in */
@interface DBExternRecordWithDerivings : NSObject @interface DBExternRecordWithDerivings : NSObject
- (nonnull id)initWithMember:(nonnull DBRecordWithDerivings *)member - (nonnull instancetype)initWithMember:(nonnull DBRecordWithDerivings *)member
e:(DBColor)e; e:(DBColor)e;
+ (nonnull instancetype)externRecordWithDerivingsWithMember:(nonnull DBRecordWithDerivings *)member
e:(DBColor)e;
@property (nonatomic, readonly, nonnull) DBRecordWithDerivings * member; @property (nonatomic, readonly, nonnull) DBRecordWithDerivings * member;
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
@implementation DBExternRecordWithDerivings @implementation DBExternRecordWithDerivings
- (id)initWithMember:(nonnull DBRecordWithDerivings *)member - (nonnull instancetype)initWithMember:(nonnull DBRecordWithDerivings *)member
e:(DBColor)e e:(DBColor)e
{ {
if (self = [super init]) { if (self = [super init]) {
_member = member; _member = member;
...@@ -16,6 +16,13 @@ ...@@ -16,6 +16,13 @@
return self; return self;
} }
+ (nonnull instancetype)externRecordWithDerivingsWithMember:(nonnull DBRecordWithDerivings *)member
e:(DBColor)e
{
return [[self alloc] initWithMember:member
e:e];
}
- (BOOL)isEqual:(id)other - (BOOL)isEqual:(id)other
{ {
if (![other isKindOfClass:[DBExternRecordWithDerivings class]]) { if (![other isKindOfClass:[DBExternRecordWithDerivings class]]) {
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBMapDateRecord : NSObject @interface DBMapDateRecord : NSObject
- (nonnull id)initWithDatesById:(nonnull NSDictionary *)datesById; - (nonnull instancetype)initWithDatesById:(nonnull NSDictionary *)datesById;
+ (nonnull instancetype)mapDateRecordWithDatesById:(nonnull NSDictionary *)datesById;
@property (nonatomic, readonly, nonnull) NSDictionary * datesById; @property (nonatomic, readonly, nonnull) NSDictionary * datesById;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
@implementation DBMapDateRecord @implementation DBMapDateRecord
- (id)initWithDatesById:(nonnull NSDictionary *)datesById - (nonnull instancetype)initWithDatesById:(nonnull NSDictionary *)datesById
{ {
if (self = [super init]) { if (self = [super init]) {
_datesById = datesById; _datesById = datesById;
...@@ -14,4 +14,9 @@ ...@@ -14,4 +14,9 @@
return self; return self;
} }
+ (nonnull instancetype)mapDateRecordWithDatesById:(nonnull NSDictionary *)datesById
{
return [[self alloc] initWithDatesById:datesById];
}
@end @end
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBMapListRecord : NSObject @interface DBMapListRecord : NSObject
- (nonnull id)initWithMapList:(nonnull NSArray *)mapList; - (nonnull instancetype)initWithMapList:(nonnull NSArray *)mapList;
+ (nonnull instancetype)mapListRecordWithMapList:(nonnull NSArray *)mapList;
@property (nonatomic, readonly, nonnull) NSArray * mapList; @property (nonatomic, readonly, nonnull) NSArray * mapList;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
@implementation DBMapListRecord @implementation DBMapListRecord
- (id)initWithMapList:(nonnull NSArray *)mapList - (nonnull instancetype)initWithMapList:(nonnull NSArray *)mapList
{ {
if (self = [super init]) { if (self = [super init]) {
_mapList = mapList; _mapList = mapList;
...@@ -14,4 +14,9 @@ ...@@ -14,4 +14,9 @@
return self; return self;
} }
+ (nonnull instancetype)mapListRecordWithMapList:(nonnull NSArray *)mapList
{
return [[self alloc] initWithMapList:mapList];
}
@end @end
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBMapRecord : NSObject @interface DBMapRecord : NSObject
- (nonnull id)initWithMap:(nonnull NSDictionary *)map - (nonnull instancetype)initWithMap:(nonnull NSDictionary *)map
imap:(nonnull NSDictionary *)imap; imap:(nonnull NSDictionary *)imap;
+ (nonnull instancetype)mapRecordWithMap:(nonnull NSDictionary *)map
imap:(nonnull NSDictionary *)imap;
@property (nonatomic, readonly, nonnull) NSDictionary * map; @property (nonatomic, readonly, nonnull) NSDictionary * map;
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
@implementation DBMapRecord @implementation DBMapRecord
- (id)initWithMap:(nonnull NSDictionary *)map - (nonnull instancetype)initWithMap:(nonnull NSDictionary *)map
imap:(nonnull NSDictionary *)imap imap:(nonnull NSDictionary *)imap
{ {
if (self = [super init]) { if (self = [super init]) {
_map = map; _map = map;
...@@ -16,4 +16,11 @@ ...@@ -16,4 +16,11 @@
return self; return self;
} }
+ (nonnull instancetype)mapRecordWithMap:(nonnull NSDictionary *)map
imap:(nonnull NSDictionary *)imap
{
return [[self alloc] initWithMap:map
imap:imap];
}
@end @end
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBNestedCollection : NSObject @interface DBNestedCollection : NSObject
- (nonnull id)initWithSetList:(nonnull NSArray *)setList; - (nonnull instancetype)initWithSetList:(nonnull NSArray *)setList;
+ (nonnull instancetype)nestedCollectionWithSetList:(nonnull NSArray *)setList;
@property (nonatomic, readonly, nonnull) NSArray * setList; @property (nonatomic, readonly, nonnull) NSArray * setList;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
@implementation DBNestedCollection @implementation DBNestedCollection
- (id)initWithSetList:(nonnull NSArray *)setList - (nonnull instancetype)initWithSetList:(nonnull NSArray *)setList
{ {
if (self = [super init]) { if (self = [super init]) {
_setList = setList; _setList = setList;
...@@ -14,4 +14,9 @@ ...@@ -14,4 +14,9 @@
return self; return self;
} }
+ (nonnull instancetype)nestedCollectionWithSetList:(nonnull NSArray *)setList
{
return [[self alloc] initWithSetList:setList];
}
@end @end
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBPrimitiveList : NSObject @interface DBPrimitiveList : NSObject
- (nonnull id)initWithList:(nonnull NSArray *)list; - (nonnull instancetype)initWithList:(nonnull NSArray *)list;
+ (nonnull instancetype)primitiveListWithList:(nonnull NSArray *)list;
@property (nonatomic, readonly, nonnull) NSArray * list; @property (nonatomic, readonly, nonnull) NSArray * list;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
@implementation DBPrimitiveList @implementation DBPrimitiveList
- (id)initWithList:(nonnull NSArray *)list - (nonnull instancetype)initWithList:(nonnull NSArray *)list
{ {
if (self = [super init]) { if (self = [super init]) {
_list = list; _list = list;
...@@ -14,4 +14,9 @@ ...@@ -14,4 +14,9 @@
return self; return self;
} }
+ (nonnull instancetype)primitiveListWithList:(nonnull NSArray *)list
{
return [[self alloc] initWithList:list];
}
@end @end
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBRecordWithDerivings : NSObject @interface DBRecordWithDerivings : NSObject
- (nonnull id)initWithKey1:(int32_t)key1 - (nonnull instancetype)initWithKey1:(int32_t)key1
key2:(nonnull NSString *)key2; key2:(nonnull NSString *)key2;
+ (nonnull instancetype)recordWithDerivingsWithKey1:(int32_t)key1
key2:(nonnull NSString *)key2;
@property (nonatomic, readonly) int32_t key1; @property (nonatomic, readonly) int32_t key1;
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
@implementation DBRecordWithDerivings @implementation DBRecordWithDerivings
- (id)initWithKey1:(int32_t)key1 - (nonnull instancetype)initWithKey1:(int32_t)key1
key2:(nonnull NSString *)key2 key2:(nonnull NSString *)key2
{ {
if (self = [super init]) { if (self = [super init]) {
_key1 = key1; _key1 = key1;
...@@ -16,6 +16,13 @@ ...@@ -16,6 +16,13 @@
return self; return self;
} }
+ (nonnull instancetype)recordWithDerivingsWithKey1:(int32_t)key1
key2:(nonnull NSString *)key2
{
return [[self alloc] initWithKey1:key1
key2:key2];
}
- (BOOL)isEqual:(id)other - (BOOL)isEqual:(id)other
{ {
if (![other isKindOfClass:[DBRecordWithDerivings class]]) { if (![other isKindOfClass:[DBRecordWithDerivings class]]) {
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBRecordWithDurationAndDerivings : NSObject @interface DBRecordWithDurationAndDerivings : NSObject
- (nonnull id)initWithDt:(NSTimeInterval)dt; - (nonnull instancetype)initWithDt:(NSTimeInterval)dt;
+ (nonnull instancetype)recordWithDurationAndDerivingsWithDt:(NSTimeInterval)dt;
@property (nonatomic, readonly) NSTimeInterval dt; @property (nonatomic, readonly) NSTimeInterval dt;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
@implementation DBRecordWithDurationAndDerivings @implementation DBRecordWithDurationAndDerivings
- (id)initWithDt:(NSTimeInterval)dt - (nonnull instancetype)initWithDt:(NSTimeInterval)dt
{ {
if (self = [super init]) { if (self = [super init]) {
_dt = dt; _dt = dt;
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
return self; return self;
} }
+ (nonnull instancetype)recordWithDurationAndDerivingsWithDt:(NSTimeInterval)dt
{
return [[self alloc] initWithDt:dt];
}
- (BOOL)isEqual:(id)other - (BOOL)isEqual:(id)other
{ {
if (![other isKindOfClass:[DBRecordWithDurationAndDerivings class]]) { if (![other isKindOfClass:[DBRecordWithDurationAndDerivings class]]) {
......
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBRecordWithNestedDerivings : NSObject @interface DBRecordWithNestedDerivings : NSObject
- (nonnull id)initWithKey:(int32_t)key - (nonnull instancetype)initWithKey:(int32_t)key
rec:(nonnull DBRecordWithDerivings *)rec; rec:(nonnull DBRecordWithDerivings *)rec;
+ (nonnull instancetype)recordWithNestedDerivingsWithKey:(int32_t)key
rec:(nonnull DBRecordWithDerivings *)rec;
@property (nonatomic, readonly) int32_t key; @property (nonatomic, readonly) int32_t key;
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
@implementation DBRecordWithNestedDerivings @implementation DBRecordWithNestedDerivings
- (id)initWithKey:(int32_t)key - (nonnull instancetype)initWithKey:(int32_t)key
rec:(nonnull DBRecordWithDerivings *)rec rec:(nonnull DBRecordWithDerivings *)rec
{ {
if (self = [super init]) { if (self = [super init]) {
_key = key; _key = key;
...@@ -16,6 +16,13 @@ ...@@ -16,6 +16,13 @@
return self; return self;
} }
+ (nonnull instancetype)recordWithNestedDerivingsWithKey:(int32_t)key
rec:(nonnull DBRecordWithDerivings *)rec
{
return [[self alloc] initWithKey:key
rec:rec];
}
- (BOOL)isEqual:(id)other - (BOOL)isEqual:(id)other
{ {
if (![other isKindOfClass:[DBRecordWithNestedDerivings class]]) { if (![other isKindOfClass:[DBRecordWithNestedDerivings class]]) {
......
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@interface DBSetRecord : NSObject @interface DBSetRecord : NSObject
- (nonnull id)initWithSet:(nonnull NSSet *)set - (nonnull instancetype)initWithSet:(nonnull NSSet *)set
iset:(nonnull NSSet *)iset; iset:(nonnull NSSet *)iset;
+ (nonnull instancetype)setRecordWithSet:(nonnull NSSet *)set
iset:(nonnull NSSet *)iset;
@property (nonatomic, readonly, nonnull) NSSet * set; @property (nonatomic, readonly, nonnull) NSSet * set;
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
@implementation DBSetRecord @implementation DBSetRecord
- (id)initWithSet:(nonnull NSSet *)set - (nonnull instancetype)initWithSet:(nonnull NSSet *)set
iset:(nonnull NSSet *)iset iset:(nonnull NSSet *)iset
{ {
if (self = [super init]) { if (self = [super init]) {
_set = set; _set = set;
...@@ -16,4 +16,11 @@ ...@@ -16,4 +16,11 @@
return self; return self;
} }
+ (nonnull instancetype)setRecordWithSet:(nonnull NSSet *)set
iset:(nonnull NSSet *)iset
{
return [[self alloc] initWithSet:set
iset:iset];
}
@end @end
...@@ -11,6 +11,7 @@ djinni-output-temp/cpp/constants_interface.cpp ...@@ -11,6 +11,7 @@ djinni-output-temp/cpp/constants_interface.cpp
djinni-output-temp/cpp/assorted_primitives.hpp djinni-output-temp/cpp/assorted_primitives.hpp
djinni-output-temp/cpp/assorted_primitives.cpp djinni-output-temp/cpp/assorted_primitives.cpp
djinni-output-temp/cpp/test_helpers.hpp djinni-output-temp/cpp/test_helpers.hpp
djinni-output-temp/cpp/empty_record.hpp
djinni-output-temp/cpp/token.hpp djinni-output-temp/cpp/token.hpp
djinni-output-temp/cpp/color.hpp djinni-output-temp/cpp/color.hpp
djinni-output-temp/cpp/client_returned_record.hpp djinni-output-temp/cpp/client_returned_record.hpp
...@@ -33,6 +34,7 @@ djinni-output-temp/java/Constants.java ...@@ -33,6 +34,7 @@ djinni-output-temp/java/Constants.java
djinni-output-temp/java/ConstantsInterface.java djinni-output-temp/java/ConstantsInterface.java
djinni-output-temp/java/AssortedPrimitives.java djinni-output-temp/java/AssortedPrimitives.java
djinni-output-temp/java/TestHelpers.java djinni-output-temp/java/TestHelpers.java
djinni-output-temp/java/EmptyRecord.java
djinni-output-temp/java/Token.java djinni-output-temp/java/Token.java
djinni-output-temp/java/Color.java djinni-output-temp/java/Color.java
djinni-output-temp/java/ClientReturnedRecord.java djinni-output-temp/java/ClientReturnedRecord.java
...@@ -61,6 +63,8 @@ djinni-output-temp/jni/NativeAssortedPrimitives.hpp ...@@ -61,6 +63,8 @@ djinni-output-temp/jni/NativeAssortedPrimitives.hpp
djinni-output-temp/jni/NativeAssortedPrimitives.cpp djinni-output-temp/jni/NativeAssortedPrimitives.cpp
djinni-output-temp/jni/NativeTestHelpers.hpp djinni-output-temp/jni/NativeTestHelpers.hpp
djinni-output-temp/jni/NativeTestHelpers.cpp djinni-output-temp/jni/NativeTestHelpers.cpp
djinni-output-temp/jni/NativeEmptyRecord.hpp
djinni-output-temp/jni/NativeEmptyRecord.cpp
djinni-output-temp/jni/NativeToken.hpp djinni-output-temp/jni/NativeToken.hpp
djinni-output-temp/jni/NativeToken.cpp djinni-output-temp/jni/NativeToken.cpp
djinni-output-temp/jni/NativeColor.hpp djinni-output-temp/jni/NativeColor.hpp
...@@ -98,6 +102,8 @@ djinni-output-temp/objc/DBConstantsInterface.mm ...@@ -98,6 +102,8 @@ djinni-output-temp/objc/DBConstantsInterface.mm
djinni-output-temp/objc/DBAssortedPrimitives.h djinni-output-temp/objc/DBAssortedPrimitives.h
djinni-output-temp/objc/DBAssortedPrimitives.mm djinni-output-temp/objc/DBAssortedPrimitives.mm
djinni-output-temp/objc/DBTestHelpers.h djinni-output-temp/objc/DBTestHelpers.h
djinni-output-temp/objc/DBEmptyRecord.h
djinni-output-temp/objc/DBEmptyRecord.mm
djinni-output-temp/objc/DBToken.h djinni-output-temp/objc/DBToken.h
djinni-output-temp/objc/DBColor.h djinni-output-temp/objc/DBColor.h
djinni-output-temp/objc/DBClientReturnedRecord.h djinni-output-temp/objc/DBClientReturnedRecord.h
...@@ -134,6 +140,8 @@ djinni-output-temp/objc/DBAssortedPrimitives+Private.h ...@@ -134,6 +140,8 @@ djinni-output-temp/objc/DBAssortedPrimitives+Private.h
djinni-output-temp/objc/DBAssortedPrimitives+Private.mm djinni-output-temp/objc/DBAssortedPrimitives+Private.mm
djinni-output-temp/objc/DBTestHelpers+Private.h djinni-output-temp/objc/DBTestHelpers+Private.h
djinni-output-temp/objc/DBTestHelpers+Private.mm djinni-output-temp/objc/DBTestHelpers+Private.mm
djinni-output-temp/objc/DBEmptyRecord+Private.h
djinni-output-temp/objc/DBEmptyRecord+Private.mm
djinni-output-temp/objc/DBToken+Private.h djinni-output-temp/objc/DBToken+Private.h
djinni-output-temp/objc/DBToken+Private.mm djinni-output-temp/objc/DBToken+Private.mm
djinni-output-temp/objc/DBClientReturnedRecord+Private.h djinni-output-temp/objc/DBClientReturnedRecord+Private.h
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
- (void)testObjcToCpp - (void)testObjcToCpp
{ {
DBMapRecord *objcMapRecord = [[DBMapRecord alloc] initWithMap:[self getObjcMap] imap:[NSDictionary dictionary]]; DBMapRecord *objcMapRecord = [DBMapRecord mapRecordWithMap:[self getObjcMap] imap:[NSDictionary dictionary]];
MapRecord cppMapRecord = djinni_generated::MapRecord::toCpp(objcMapRecord); MapRecord cppMapRecord = djinni_generated::MapRecord::toCpp(objcMapRecord);
[self checkCppMap:cppMapRecord.map]; [self checkCppMap:cppMapRecord.map];
} }
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
- (void)testObjcToCppEmpty - (void)testObjcToCppEmpty
{ {
DBMapRecord *objcMapRecord = [[DBMapRecord alloc] initWithMap:[NSDictionary dictionary] imap:[NSDictionary dictionary]]; DBMapRecord *objcMapRecord = [DBMapRecord mapRecordWithMap:[NSDictionary dictionary] imap:[NSDictionary dictionary]];
MapRecord cppMapRecord = djinni_generated::MapRecord::toCpp(objcMapRecord); MapRecord cppMapRecord = djinni_generated::MapRecord::toCpp(objcMapRecord);
auto & cppMap = cppMapRecord.map; auto & cppMap = cppMapRecord.map;
XCTAssertEqual(cppMap.size(), (size_t)0, @"Count 0 expected, actual: %zd", cppMap.size()); XCTAssertEqual(cppMap.size(), (size_t)0, @"Count 0 expected, actual: %zd", cppMap.size());
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
- (void)testObjcMapListToCpp - (void)testObjcMapListToCpp
{ {
NSArray *objcMapList = @[ [self getObjcMap] ]; NSArray *objcMapList = @[ [self getObjcMap] ];
DBMapListRecord *objcMapListRecord = [[DBMapListRecord alloc] initWithMapList:objcMapList]; DBMapListRecord *objcMapListRecord = [DBMapListRecord mapListRecordWithMapList:objcMapList];
auto cppMapListRecord = djinni_generated::MapListRecord::toCpp(objcMapListRecord); auto cppMapListRecord = djinni_generated::MapListRecord::toCpp(objcMapListRecord);
auto & cppMapList = cppMapListRecord.map_list; auto & cppMapList = cppMapListRecord.map_list;
XCTAssertEqual(cppMapList.size(), (size_t)1, @"List with 1 map expected, actual no: %zd", cppMapList.size()); XCTAssertEqual(cppMapList.size(), (size_t)1, @"List with 1 map expected, actual no: %zd", cppMapList.size());
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "nested_collection.hpp" #include "nested_collection.hpp"
static NestedCollection cppNestedCollection { { {u8"String1", u8"String2"}, {u8"StringA", u8"StringB"} } }; static NestedCollection cppNestedCollection { { {u8"String1", u8"String2"}, {u8"StringA", u8"StringB"} } };
static DBNestedCollection *objcNestedCollection = [[DBNestedCollection alloc] initWithSetList:@[ static DBNestedCollection *objcNestedCollection = [DBNestedCollection nestedCollectionWithSetList:@[
[NSSet setWithArray:@[ @"String1", @"String2" ]], [NSSet setWithArray:@[ @"String1", @"String2" ]],
[NSSet setWithArray:@[ @"StringA", @"StringB" ]], [NSSet setWithArray:@[ @"StringA", @"StringB" ]],
]]; ]];
......
...@@ -4,11 +4,7 @@ ...@@ -4,11 +4,7 @@
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
static PrimitiveList cppPrimitiveList { { 1, 2, 3 } }; static PrimitiveList cppPrimitiveList { { 1, 2, 3 } };
static DBPrimitiveList *objcPrimitiveList = [[DBPrimitiveList alloc] initWithList: static DBPrimitiveList *objcPrimitiveList = [DBPrimitiveList primitiveListWithList:@[@1, @2, @3]];
[[NSArray alloc] initWithObjects:[NSNumber numberWithLongLong:1],
[NSNumber numberWithLongLong:2],
[NSNumber numberWithLongLong:3],
nil]];
@interface DBPrimitiveListTests : XCTestCase @interface DBPrimitiveListTests : XCTestCase
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#import "DBAssortedPrimitives.h" #import "DBAssortedPrimitives.h"
#import "DBTestHelpers.h" #import "DBTestHelpers.h"
#import "DBEmptyRecord.h"
@interface DBPrimitivesTests : XCTestCase @interface DBPrimitivesTests : XCTestCase
...@@ -23,24 +24,28 @@ ...@@ -23,24 +24,28 @@
- (void)testPrimitives - (void)testPrimitives
{ {
DBAssortedPrimitives * p = [[DBAssortedPrimitives alloc] DBAssortedPrimitives * p = [DBAssortedPrimitives assortedPrimitivesWithB:YES
initWithB:YES eight:(int8_t)123
eight:(int8_t)123 sixteen:(int16_t)20000
sixteen:(int16_t)20000 thirtytwo:(int32_t)1000000000
thirtytwo:(int32_t)1000000000 sixtyfour:(int64_t)1234567890123456789L
sixtyfour:(int64_t)1234567890123456789L fthirtytwo:(float)1.23
fthirtytwo:(float)1.23 fsixtyfour:1.23
fsixtyfour:1.23 oB:[NSNumber numberWithBool:YES]
oB:[NSNumber numberWithBool:YES] oEight:[NSNumber numberWithChar:123]
oEight:[NSNumber numberWithChar:123] oSixteen:[NSNumber numberWithShort:20000]
oSixteen:[NSNumber numberWithShort:20000] oThirtytwo:[NSNumber numberWithInt:1000000000]
oThirtytwo:[NSNumber numberWithInt:1000000000] oSixtyfour:[NSNumber numberWithLongLong:1234567890123456789L]
oSixtyfour:[NSNumber numberWithLongLong:1234567890123456789L] oFthirtytwo:[NSNumber numberWithFloat:(float)123]
oFthirtytwo:[NSNumber numberWithFloat:(float)123] oFsixtyfour:[NSNumber numberWithDouble:123]];
oFsixtyfour:[NSNumber numberWithDouble:123]];
XCTAssertEqualObjects(p, [DBTestHelpers assortedPrimitivesId:p]); XCTAssertEqualObjects(p, [DBTestHelpers assortedPrimitivesId:p]);
} }
- (void)testEmptyRecord
{
(void)[DBEmptyRecord emptyRecord];
}
- (void)testObjcToCppConverter - (void)testObjcToCppConverter
{ {
} }
......
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
static DBRecordWithDerivings *record1 = [[DBRecordWithDerivings alloc] initWithKey1:1 key2:@"String1"]; static DBRecordWithDerivings *record1 = [DBRecordWithDerivings recordWithDerivingsWithKey1:1 key2:@"String1"];
static DBRecordWithDerivings *record1A = [[DBRecordWithDerivings alloc] initWithKey1:1 key2:@"String1"]; static DBRecordWithDerivings *record1A = [DBRecordWithDerivings recordWithDerivingsWithKey1:1 key2:@"String1"];
static DBRecordWithDerivings *record2 = [[DBRecordWithDerivings alloc] initWithKey1:1 key2:@"String2"]; static DBRecordWithDerivings *record2 = [DBRecordWithDerivings recordWithDerivingsWithKey1:1 key2:@"String2"];
static DBRecordWithDerivings *record3 = [[DBRecordWithDerivings alloc] initWithKey1:2 key2:@"String1"]; static DBRecordWithDerivings *record3 = [DBRecordWithDerivings recordWithDerivingsWithKey1:2 key2:@"String1"];
static DBRecordWithNestedDerivings *nestedRecord1 = [[DBRecordWithNestedDerivings alloc] initWithKey:1 rec:record1]; static DBRecordWithNestedDerivings *nestedRecord1 = [DBRecordWithNestedDerivings recordWithNestedDerivingsWithKey:1 rec:record1];
static DBRecordWithNestedDerivings *nestedRecord1A = [[DBRecordWithNestedDerivings alloc] initWithKey:1 rec:record1A]; static DBRecordWithNestedDerivings *nestedRecord1A = [DBRecordWithNestedDerivings recordWithNestedDerivingsWithKey:1 rec:record1A];
static DBRecordWithNestedDerivings *nestedRecord2 = [[DBRecordWithNestedDerivings alloc] initWithKey:1 rec:record2]; static DBRecordWithNestedDerivings *nestedRecord2 = [DBRecordWithNestedDerivings recordWithNestedDerivingsWithKey:1 rec:record2];
@interface DBRecordWithDerivingsObjcTests : XCTestCase @interface DBRecordWithDerivingsObjcTests : XCTestCase
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
- (DBSetRecord *)getObjcSetRecord - (DBSetRecord *)getObjcSetRecord
{ {
NSSet *set = [[NSSet alloc] initWithObjects:@"StringA", @"StringB", @"StringC", nil]; NSSet *set = [NSSet setWithObjects:@"StringA", @"StringB", @"StringC", nil];
DBSetRecord *objcSetRecord = [[DBSetRecord alloc] initWithSet:set iset:[NSSet set]]; DBSetRecord *objcSetRecord = [DBSetRecord setRecordWithSet:set iset:[NSSet set]];
return objcSetRecord; return objcSetRecord;
} }
......
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