Commit ba88bbe7 authored by Steven Kabbes's avatar Steven Kabbes Committed by Jacob Potter

Expose record constructors in public ObjC headers

parent 047a3afe
......@@ -7,8 +7,6 @@
@interface TXSItemList ()
- (id)initWithItemList:(TXSItemList *)itemList;
- (id)initWithItems:(NSMutableArray *)items;
- (id)initWithCppItemList:(const ::textsort::ItemList &)itemList;
- (::textsort::ItemList)cppItemList;
......
......@@ -5,6 +5,8 @@
@interface TXSItemList : NSObject
- (id)initWithItemList:(TXSItemList *)itemList;
- (id)initWithItems:(NSMutableArray *)items;
@property (nonatomic, readonly) NSMutableArray *items;
......
......@@ -399,6 +399,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
if (r.ext.objc) {
refs.body.add("#import " + q("../" + headerName(ident)))
refs.privHeader.add("#import " + q("../" + headerName(ident)))
refs.header.add(s"@class ${idObjc.ty(ident.name)};")
}
def checkMutable(tm: MExpr): Boolean = tm.base match {
......@@ -416,6 +417,19 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
}
w.wl
w.wl(s"@interface $self : NSObject")
// Deep copy construtor
w.wl(s"- (id)${idObjc.method("init_with_" + ident.name)}:(${idObjc.ty(ident)} *)${idObjc.field(ident)};")
if (!r.fields.isEmpty) {
val head = r.fields.head
val skipFirst = SkipFirst()
w.w(s"- (id)${idObjc.method("init_with_" + head.ident.name)}:(${toObjcFullType(head.ty)})${idObjc.local(head.ident)}")
for (f <- r.fields) skipFirst {
w.w(s" ${idObjc.field(f.ident)}:(${toObjcFullType(f.ty)})${idObjc.field(f.ident)}")
}
w.wl(";")
}
for (f <- r.fields) {
w.wl
writeDoc(w, f.doc)
......@@ -433,16 +447,6 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
w.wl(s"@interface $self ()")
w.wl
// Deep copy constructor
w.wl(s"- (id)${idObjc.method("init_with_" + ident.name)}:(${idObjc.ty(ident)} *)${idObjc.field(ident)};")
if (!r.fields.isEmpty) {
val head = r.fields.head
val skipFirst = SkipFirst()
w.w(s"- (id)${idObjc.method("init_with_" + head.ident.name)}:(${toObjcFullType(head.ty)})${idObjc.local(head.ident)}")
for (f <- r.fields) skipFirst {
w.w(s" ${idObjc.field(f.ident)}:(${toObjcFullType(f.ty)})${idObjc.field(f.ident)}")
}
w.wl(";")
}
w.wl(s"- (id)${idObjc.method("init_with_cpp_" + ident.name)}:(const $cppSelf &)${idObjc.local(ident)};")
w.wl(s"- ($cppSelf)${idObjc.method("cpp_" + ident.name)};")
w.wl
......@@ -455,7 +459,6 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
w.wl
w.wl(s"@implementation $self")
w.wl
// Deep copy construtor
w.wl(s"- (id)${idObjc.method("init_with_" + ident.name)}:(${idObjc.ty(ident)} *)${idObjc.local(ident)}")
w.braced {
w.w("if (self = [super init])").braced {
......
......@@ -7,8 +7,6 @@
@interface DBClientReturnedRecord ()
- (id)initWithClientReturnedRecord:(DBClientReturnedRecord *)clientReturnedRecord;
- (id)initWithContent:(NSString *)content;
- (id)initWithCppClientReturnedRecord:(const ClientReturnedRecord &)clientReturnedRecord;
- (ClientReturnedRecord)cppClientReturnedRecord;
......
......@@ -5,6 +5,8 @@
@interface DBClientReturnedRecord : NSObject
- (id)initWithClientReturnedRecord:(DBClientReturnedRecord *)clientReturnedRecord;
- (id)initWithContent:(NSString *)content;
@property (nonatomic, readonly) NSString *content;
......
......@@ -7,8 +7,6 @@
@interface DBMapListRecord ()
- (id)initWithMapListRecord:(DBMapListRecord *)mapListRecord;
- (id)initWithMapList:(NSMutableArray *)mapList;
- (id)initWithCppMapListRecord:(const MapListRecord &)mapListRecord;
- (MapListRecord)cppMapListRecord;
......
......@@ -5,6 +5,8 @@
@interface DBMapListRecord : NSObject
- (id)initWithMapListRecord:(DBMapListRecord *)mapListRecord;
- (id)initWithMapList:(NSMutableArray *)mapList;
@property (nonatomic, readonly) NSMutableArray *mapList;
......
......@@ -7,8 +7,6 @@
@interface DBMapRecord ()
- (id)initWithMapRecord:(DBMapRecord *)mapRecord;
- (id)initWithMap:(NSMutableDictionary *)map;
- (id)initWithCppMapRecord:(const MapRecord &)mapRecord;
- (MapRecord)cppMapRecord;
......
......@@ -5,6 +5,8 @@
@interface DBMapRecord : NSObject
- (id)initWithMapRecord:(DBMapRecord *)mapRecord;
- (id)initWithMap:(NSMutableDictionary *)map;
@property (nonatomic, readonly) NSMutableDictionary *map;
......
......@@ -7,8 +7,6 @@
@interface DBNestedCollection ()
- (id)initWithNestedCollection:(DBNestedCollection *)nestedCollection;
- (id)initWithSetList:(NSMutableArray *)setList;
- (id)initWithCppNestedCollection:(const NestedCollection &)nestedCollection;
- (NestedCollection)cppNestedCollection;
......
......@@ -5,6 +5,8 @@
@interface DBNestedCollection : NSObject
- (id)initWithNestedCollection:(DBNestedCollection *)nestedCollection;
- (id)initWithSetList:(NSMutableArray *)setList;
@property (nonatomic, readonly) NSMutableArray *setList;
......
......@@ -7,8 +7,6 @@
@interface DBPrimitiveList ()
- (id)initWithPrimitiveList:(DBPrimitiveList *)primitiveList;
- (id)initWithList:(NSMutableArray *)list;
- (id)initWithCppPrimitiveList:(const PrimitiveList &)primitiveList;
- (PrimitiveList)cppPrimitiveList;
......
......@@ -5,6 +5,8 @@
@interface DBPrimitiveList : NSObject
- (id)initWithPrimitiveList:(DBPrimitiveList *)primitiveList;
- (id)initWithList:(NSMutableArray *)list;
@property (nonatomic, readonly) NSMutableArray *list;
......
......@@ -7,8 +7,6 @@
@interface DBRecordWithDerivings ()
- (id)initWithRecordWithDerivings:(DBRecordWithDerivings *)recordWithDerivings;
- (id)initWithKey1:(int32_t)key1 key2:(NSString *)key2;
- (id)initWithCppRecordWithDerivings:(const RecordWithDerivings &)recordWithDerivings;
- (RecordWithDerivings)cppRecordWithDerivings;
......
......@@ -5,6 +5,8 @@
@interface DBRecordWithDerivings : NSObject
- (id)initWithRecordWithDerivings:(DBRecordWithDerivings *)recordWithDerivings;
- (id)initWithKey1:(int32_t)key1 key2:(NSString *)key2;
@property (nonatomic, readonly) int32_t key1;
......
......@@ -7,8 +7,6 @@
@interface DBRecordWithNestedDerivings ()
- (id)initWithRecordWithNestedDerivings:(DBRecordWithNestedDerivings *)recordWithNestedDerivings;
- (id)initWithKey:(int32_t)key rec:(DBRecordWithDerivings *)rec;
- (id)initWithCppRecordWithNestedDerivings:(const RecordWithNestedDerivings &)recordWithNestedDerivings;
- (RecordWithNestedDerivings)cppRecordWithNestedDerivings;
......
......@@ -6,6 +6,8 @@
@interface DBRecordWithNestedDerivings : NSObject
- (id)initWithRecordWithNestedDerivings:(DBRecordWithNestedDerivings *)recordWithNestedDerivings;
- (id)initWithKey:(int32_t)key rec:(DBRecordWithDerivings *)rec;
@property (nonatomic, readonly) int32_t key;
......
......@@ -7,8 +7,6 @@
@interface DBSetRecord ()
- (id)initWithSetRecord:(DBSetRecord *)setRecord;
- (id)initWithSet:(NSMutableSet *)set;
- (id)initWithCppSetRecord:(const SetRecord &)setRecord;
- (SetRecord)cppSetRecord;
......
......@@ -5,6 +5,8 @@
@interface DBSetRecord : NSObject
- (id)initWithSetRecord:(DBSetRecord *)setRecord;
- (id)initWithSet:(NSMutableSet *)set;
@property (nonatomic, readonly) NSMutableSet *set;
......
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