Commit aec43dad authored by Miro Knejp's avatar Miro Knejp Committed by Jacob Potter

Extract primitive translation into a predefined support lib helper class

parent 051a36f8
......@@ -8,6 +8,6 @@
- (id)initWithItemList:(TXSItemList *)itemList;
- (id)initWithItems:(NSArray *)items;
@property (nonatomic, readonly) NSArray *items;
@property (nonatomic, readonly) NSArray * items;
@end
......@@ -3,6 +3,7 @@
#import "TXSItemList+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......
......@@ -43,6 +43,7 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
tm.base match {
case o: MOpaque =>
header.add("#import <Foundation/Foundation.h>")
body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJIMarshal+Private.h"))
case d: MDef => d.defType match {
case DEnum =>
body.add("#import " + q(spec.objcIncludePrefix + headerName(d.name)))
......@@ -652,20 +653,15 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
}
case o => o match {
case p: MPrimitive =>
if (needRef)
p.idlName match {
case "i8" => w.wl(s"$objcType$objcIdent = [NSNumber numberWithChar:$cppIdent];")
case "i16" => w.wl(s"$objcType$objcIdent = [NSNumber numberWithShort:$cppIdent];")
case "i32" => w.wl(s"$objcType$objcIdent = [NSNumber numberWithInt:$cppIdent];")
case "i64" => w.wl(s"$objcType$objcIdent = [NSNumber numberWithLongLong:$cppIdent];")
case "f64" => w.wl(s"$objcType$objcIdent = [NSNumber numberWithDouble:$cppIdent];")
case "bool" => w.wl(s"$objcType$objcIdent = [NSNumber numberWithBool:(($cppIdent) ? YES : NO)];")
}
else
p.idlName match {
case "bool" => w.wl(s"$objcType$objcIdent = ($cppIdent) ? YES : NO;")
case _ => w.wl(s"$objcType$objcIdent = $cppIdent;")
}
val boxed = if(needRef) "::Boxed" else ""
p.idlName match {
case "i8" => w.wl(s"$objcType$objcIdent = ::djinni::I8$boxed::fromCpp($cppIdent);")
case "i16" => w.wl(s"$objcType$objcIdent = ::djinni::I16$boxed::fromCpp($cppIdent);")
case "i32" => w.wl(s"$objcType$objcIdent = ::djinni::I32$boxed::fromCpp($cppIdent);")
case "i64" => w.wl(s"$objcType$objcIdent = ::djinni::I64$boxed::fromCpp($cppIdent);")
case "f64" => w.wl(s"$objcType$objcIdent = ::djinni::F64$boxed::fromCpp($cppIdent);")
case "bool" => w.wl(s"$objcType$objcIdent = ::djinni::Bool$boxed::fromCpp($cppIdent);")
}
case MString => w.wl(s"$objcType$objcIdent = [[NSString alloc] initWithBytes:$cppIdent.data()").nestedN(2) {
w.wl(s"length:$cppIdent.length()")
w.wl("encoding:NSUTF8StringEncoding];")
......@@ -771,17 +767,15 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
}
case o => o match {
case p: MPrimitive =>
if (needRef)
p.idlName match {
case "i8" => w.wl(s"$cppType $cppIdent = [$objcIdent charValue];")
case "i16" => w.wl(s"$cppType $cppIdent = [$objcIdent shortValue];")
case "i32" => w.wl(s"$cppType $cppIdent = [$objcIdent intValue];")
case "i64" => w.wl(s"$cppType $cppIdent = [$objcIdent longLongValue];")
case "f64" => w.wl(s"$cppType $cppIdent = [$objcIdent doubleValue];")
case "bool" => w.wl(s"$cppType $cppIdent = [$objcIdent boolValue];")
}
else
w.wl(s"$cppType $cppIdent = $objcIdent;")
val boxed = if(needRef) "::Boxed" else ""
p.idlName match {
case "i8" => w.wl(s"$cppType $cppIdent = ::djinni::I8$boxed::toCpp($objcIdent);")
case "i16" => w.wl(s"$cppType $cppIdent = ::djinni::I16$boxed::toCpp($objcIdent);")
case "i32" => w.wl(s"$cppType $cppIdent = ::djinni::I32$boxed::toCpp($objcIdent);")
case "i64" => w.wl(s"$cppType $cppIdent = ::djinni::I64$boxed::toCpp($objcIdent);")
case "f64" => w.wl(s"$cppType $cppIdent = ::djinni::F64$boxed::toCpp($objcIdent);")
case "bool" => w.wl(s"$cppType $cppIdent = ::djinni::Bool$boxed::toCpp($objcIdent);")
}
case MString => w.wl(s"$cppType $cppIdent([$objcIdent UTF8String], [$objcIdent lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);")
case MDate => w.wl(s"$cppType $cppIdent = ::djinni::convert_date([$objcIdent timeIntervalSince1970]);")
case MBinary =>
......
//
// DJIMarshal+Private.h
// Djinni
//
// Created by knejp on 20.3.15.
// Copyright (c) 2015 Dropbox. All rights reserved.
//
#pragma once
#import <Foundation/Foundation.h>
#include <cstdint>
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
namespace djinni {
struct Bool {
using CppType = bool;
using ObjcType = BOOL;
static CppType toCpp(ObjcType x) noexcept { return x ? true : false; }
static ObjcType fromCpp(CppType x) noexcept { return x ? YES : NO; }
struct Boxed {
using ObjcType = NSNumber*;
static CppType toCpp(ObjcType x) noexcept { return [x boolValue] ? true : false; }
static ObjcType fromCpp(CppType x) noexcept { return [NSNumber numberWithChar:x ? YES : NO]; }
};
};
template<class T>
struct Primitive {
using CppType = T;
using ObjcType = T;
static CppType toCpp(ObjcType x) noexcept { return x; }
static ObjcType fromCpp(CppType x) noexcept { return x; }
};
struct I8 : public Primitive<int8_t> {
struct Boxed {
using ObjcType = NSNumber*;
static CppType toCpp(ObjcType x) noexcept { return [x charValue]; }
static ObjcType fromCpp(CppType x) noexcept { return [NSNumber numberWithChar:x]; }
};
};
struct I16 : public Primitive<int16_t> {
struct Boxed {
using ObjcType = NSNumber*;
static CppType toCpp(ObjcType x) noexcept { return [x shortValue]; }
static ObjcType fromCpp(CppType x) noexcept { return [NSNumber numberWithShort:x]; }
};
};
struct I32 : public Primitive<int32_t> {
struct Boxed {
using ObjcType = NSNumber*;
static CppType toCpp(ObjcType x) noexcept { return [x intValue]; }
static ObjcType fromCpp(CppType x) noexcept { return [NSNumber numberWithInt:x]; }
};
};
struct I64 : public Primitive<int64_t> {
struct Boxed {
using ObjcType = NSNumber*;
static CppType toCpp(ObjcType x) noexcept { return [x longLongValue]; }
static ObjcType fromCpp(CppType x) noexcept { return [NSNumber numberWithLongLong:x]; }
};
};
struct F64 : public Primitive<double> {
struct Boxed {
using ObjcType = NSNumber*;
static CppType toCpp(ObjcType x) noexcept { return [x doubleValue]; }
static ObjcType fromCpp(CppType x) noexcept { return [NSNumber numberWithDouble:x]; }
};
};
} // namespace djinni
......@@ -16,12 +16,12 @@
@property (nonatomic, readonly) int64_t sixtyfour;
@property (nonatomic, readonly) NSNumber *oEight;
@property (nonatomic, readonly) NSNumber * oEight;
@property (nonatomic, readonly) NSNumber *oSixteen;
@property (nonatomic, readonly) NSNumber * oSixteen;
@property (nonatomic, readonly) NSNumber *oThirtytwo;
@property (nonatomic, readonly) NSNumber * oThirtytwo;
@property (nonatomic, readonly) NSNumber *oSixtyfour;
@property (nonatomic, readonly) NSNumber * oSixtyfour;
@end
......@@ -3,6 +3,7 @@
#import "DBAssortedIntegers+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......@@ -60,27 +61,27 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (id)initWithCppAssortedIntegers:(const AssortedIntegers &)assortedIntegers
{
if (self = [super init]) {
_eight = assortedIntegers.eight;
_sixteen = assortedIntegers.sixteen;
_thirtytwo = assortedIntegers.thirtytwo;
_sixtyfour = assortedIntegers.sixtyfour;
_eight = ::djinni::I8::fromCpp(assortedIntegers.eight);
_sixteen = ::djinni::I16::fromCpp(assortedIntegers.sixteen);
_thirtytwo = ::djinni::I32::fromCpp(assortedIntegers.thirtytwo);
_sixtyfour = ::djinni::I64::fromCpp(assortedIntegers.sixtyfour);
if (assortedIntegers.o_eight) {
_oEight = [NSNumber numberWithChar:(*(assortedIntegers.o_eight))];
_oEight = ::djinni::I8::Boxed::fromCpp((*(assortedIntegers.o_eight)));
} else {
_oEight = nil;
}
if (assortedIntegers.o_sixteen) {
_oSixteen = [NSNumber numberWithShort:(*(assortedIntegers.o_sixteen))];
_oSixteen = ::djinni::I16::Boxed::fromCpp((*(assortedIntegers.o_sixteen)));
} else {
_oSixteen = nil;
}
if (assortedIntegers.o_thirtytwo) {
_oThirtytwo = [NSNumber numberWithInt:(*(assortedIntegers.o_thirtytwo))];
_oThirtytwo = ::djinni::I32::Boxed::fromCpp((*(assortedIntegers.o_thirtytwo)));
} else {
_oThirtytwo = nil;
}
if (assortedIntegers.o_sixtyfour) {
_oSixtyfour = [NSNumber numberWithLongLong:(*(assortedIntegers.o_sixtyfour))];
_oSixtyfour = ::djinni::I64::Boxed::fromCpp((*(assortedIntegers.o_sixtyfour)));
} else {
_oSixtyfour = nil;
}
......@@ -90,28 +91,28 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (AssortedIntegers)cppAssortedIntegers
{
int8_t eight = _eight;
int16_t sixteen = _sixteen;
int32_t thirtytwo = _thirtytwo;
int64_t sixtyfour = _sixtyfour;
int8_t eight = ::djinni::I8::toCpp(_eight);
int16_t sixteen = ::djinni::I16::toCpp(_sixteen);
int32_t thirtytwo = ::djinni::I32::toCpp(_thirtytwo);
int64_t sixtyfour = ::djinni::I64::toCpp(_sixtyfour);
std::experimental::optional<int8_t> oEight;
if (_oEight != nil) {
int8_t optValue = [_oEight charValue];
int8_t optValue = ::djinni::I8::Boxed::toCpp(_oEight);
oEight = optValue;
}
std::experimental::optional<int16_t> oSixteen;
if (_oSixteen != nil) {
int16_t optValue = [_oSixteen shortValue];
int16_t optValue = ::djinni::I16::Boxed::toCpp(_oSixteen);
oSixteen = optValue;
}
std::experimental::optional<int32_t> oThirtytwo;
if (_oThirtytwo != nil) {
int32_t optValue = [_oThirtytwo intValue];
int32_t optValue = ::djinni::I32::Boxed::toCpp(_oThirtytwo);
oThirtytwo = optValue;
}
std::experimental::optional<int64_t> oSixtyfour;
if (_oSixtyfour != nil) {
int64_t optValue = [_oSixtyfour longLongValue];
int64_t optValue = ::djinni::I64::Boxed::toCpp(_oSixtyfour);
oSixtyfour = optValue;
}
return AssortedIntegers(
......
......@@ -4,6 +4,7 @@
#import "DBClientInterfaceObjcProxy+Private.h"
#import "DBClientInterface.h"
#import "DBClientReturnedRecord+Private.h"
#import "DJIMarshal+Private.h"
#include <vector>
namespace djinni_generated {
......@@ -26,11 +27,11 @@ std::shared_ptr<ClientInterface> ClientInterfaceObjcProxy::client_interface_with
ClientReturnedRecord ClientInterfaceObjcProxy::get_record (int64_t record_id, const std::string & utf8string)
{
@autoreleasepool {
int64_t cpp_record_id = record_id;
int64_t cpp_record_id = ::djinni::I64::fromCpp(record_id);
NSString *cpp_utf8string = [[NSString alloc] initWithBytes:utf8string.data()
length:utf8string.length()
encoding:NSUTF8StringEncoding];
DBClientReturnedRecord *objcRet = [_objcRef getRecord:cpp_record_id utf8string:cpp_utf8string];
DBClientReturnedRecord * objcRet = [_objcRef getRecord:cpp_record_id utf8string:cpp_utf8string];
ClientReturnedRecord cppRet = std::move([objcRet cppClientReturnedRecord]);
return cppRet;
}
......
......@@ -10,6 +10,6 @@
@property (nonatomic, readonly) int64_t recordId;
@property (nonatomic, readonly) NSString *content;
@property (nonatomic, readonly) NSString * content;
@end
......@@ -3,6 +3,7 @@
#import "DBClientReturnedRecord+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......@@ -32,7 +33,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (id)initWithCppClientReturnedRecord:(const ClientReturnedRecord &)clientReturnedRecord
{
if (self = [super init]) {
_recordId = clientReturnedRecord.record_id;
_recordId = ::djinni::I64::fromCpp(clientReturnedRecord.record_id);
_content = [[NSString alloc] initWithBytes:clientReturnedRecord.content.data()
length:clientReturnedRecord.content.length()
encoding:NSUTF8StringEncoding];
......@@ -42,7 +43,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (ClientReturnedRecord)cppClientReturnedRecord
{
int64_t recordId = _recordId;
int64_t recordId = ::djinni::I64::toCpp(_recordId);
std::string content([_content UTF8String], [_content lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
return ClientReturnedRecord(
std::move(recordId),
......
......@@ -20,6 +20,6 @@ extern DBConstants * const DBConstantsObjectConstant;
@property (nonatomic, readonly) int32_t someInteger;
@property (nonatomic, readonly) NSString *someString;
@property (nonatomic, readonly) NSString * someString;
@end
......@@ -4,6 +4,7 @@
#import "DBConstants+Private.h"
#import "DBConstants+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......@@ -56,7 +57,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (id)initWithCppConstants:(const Constants &)constants
{
if (self = [super init]) {
_someInteger = constants.some_integer;
_someInteger = ::djinni::I32::fromCpp(constants.some_integer);
_someString = [[NSString alloc] initWithBytes:constants.some_string.data()
length:constants.some_string.length()
encoding:NSUTF8StringEncoding];
......@@ -66,7 +67,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (Constants)cppConstants
{
int32_t someInteger = _someInteger;
int32_t someInteger = ::djinni::I32::toCpp(_someInteger);
std::string someString([_someString UTF8String], [_someString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
return Constants(
std::move(someInteger),
......
......@@ -7,6 +7,7 @@
#import "DJICppWrapperCache+Private.h"
#import "DJIDate.h"
#import "DJIError.h"
#import "DJIMarshal+Private.h"
#include <exception>
#include <utility>
#include <vector>
......@@ -42,7 +43,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (int32_t)throwAnException {
try {
int32_t cppRet = _cppRef->throw_an_exception();
int32_t objcRet = cppRet;
int32_t objcRet = ::djinni::I32::fromCpp(cppRet);
return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS()
}
......
......@@ -8,6 +8,6 @@
- (id)initWithDateRecord:(DBDateRecord *)dateRecord;
- (id)initWithCreatedAt:(NSDate *)createdAt;
@property (nonatomic, readonly) NSDate *createdAt;
@property (nonatomic, readonly) NSDate * createdAt;
@end
......@@ -3,6 +3,7 @@
#import "DBDateRecord+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......
......@@ -8,6 +8,6 @@
- (id)initWithMapDateRecord:(DBMapDateRecord *)mapDateRecord;
- (id)initWithDatesById:(NSDictionary *)datesById;
@property (nonatomic, readonly) NSDictionary *datesById;
@property (nonatomic, readonly) NSDictionary * datesById;
@end
......@@ -3,6 +3,7 @@
#import "DBMapDateRecord+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......
......@@ -8,6 +8,6 @@
- (id)initWithMapListRecord:(DBMapListRecord *)mapListRecord;
- (id)initWithMapList:(NSArray *)mapList;
@property (nonatomic, readonly) NSArray *mapList;
@property (nonatomic, readonly) NSArray * mapList;
@end
......@@ -3,6 +3,7 @@
#import "DBMapListRecord+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......@@ -59,7 +60,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
NSString *objcKey_1 = [[NSString alloc] initWithBytes:cppPair_1.first.data()
length:cppPair_1.first.length()
encoding:NSUTF8StringEncoding];
NSNumber *objcValue_1 = [NSNumber numberWithLongLong:cppPair_1.second];
NSNumber *objcValue_1 = ::djinni::I64::Boxed::fromCpp(cppPair_1.second);
objcValue_0TempKeyVector.push_back(objcKey_1);
objcValue_0TempValueVector.push_back(objcValue_1);
}
......@@ -79,7 +80,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
std::unordered_map<std::string, int64_t> cppValue_0;
for (id objcKey_1 in objcValue_0) {
std::string cppKey_1([objcKey_1 UTF8String], [objcKey_1 lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
int64_t cppValue_1 = [[objcValue_0 objectForKey:objcKey_1] longLongValue];
int64_t cppValue_1 = ::djinni::I64::Boxed::toCpp([objcValue_0 objectForKey:objcKey_1]);
cppValue_0.emplace(std::move(cppKey_1), std::move(cppValue_1));
}
mapList.push_back(std::move(cppValue_0));
......
......@@ -8,6 +8,6 @@
- (id)initWithMapRecord:(DBMapRecord *)mapRecord;
- (id)initWithMap:(NSDictionary *)map;
@property (nonatomic, readonly) NSDictionary *map;
@property (nonatomic, readonly) NSDictionary * map;
@end
......@@ -3,6 +3,7 @@
#import "DBMapRecord+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......@@ -49,7 +50,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
NSString *objcKey_0 = [[NSString alloc] initWithBytes:cppPair_0.first.data()
length:cppPair_0.first.length()
encoding:NSUTF8StringEncoding];
NSNumber *objcValue_0 = [NSNumber numberWithLongLong:cppPair_0.second];
NSNumber *objcValue_0 = ::djinni::I64::Boxed::fromCpp(cppPair_0.second);
_mapTempKeyVector.push_back(objcKey_0);
_mapTempValueVector.push_back(objcValue_0);
}
......@@ -63,7 +64,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
std::unordered_map<std::string, int64_t> map;
for (id objcKey_0 in _map) {
std::string cppKey_0([objcKey_0 UTF8String], [objcKey_0 lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
int64_t cppValue_0 = [[_map objectForKey:objcKey_0] longLongValue];
int64_t cppValue_0 = ::djinni::I64::Boxed::toCpp([_map objectForKey:objcKey_0]);
map.emplace(std::move(cppKey_0), std::move(cppValue_0));
}
return MapRecord(
......
......@@ -8,6 +8,6 @@
- (id)initWithNestedCollection:(DBNestedCollection *)nestedCollection;
- (id)initWithSetList:(NSArray *)setList;
@property (nonatomic, readonly) NSArray *setList;
@property (nonatomic, readonly) NSArray * setList;
@end
......@@ -3,6 +3,7 @@
#import "DBNestedCollection+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......
......@@ -8,6 +8,6 @@
- (id)initWithPrimitiveList:(DBPrimitiveList *)primitiveList;
- (id)initWithList:(NSArray *)list;
@property (nonatomic, readonly) NSArray *list;
@property (nonatomic, readonly) NSArray * list;
@end
......@@ -3,6 +3,7 @@
#import "DBPrimitiveList+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......@@ -40,7 +41,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
std::vector<NSNumber *> _listTempVector;
_listTempVector.reserve(primitiveList.list.size());
for (const auto & cppValue_0 : primitiveList.list) {
NSNumber *objcValue_0 = [NSNumber numberWithLongLong:cppValue_0];
NSNumber *objcValue_0 = ::djinni::I64::Boxed::fromCpp(cppValue_0);
_listTempVector.push_back(objcValue_0);
}
_list = [NSArray arrayWithObjects:&_listTempVector[0] count:_listTempVector.size()];
......@@ -53,7 +54,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
std::vector<int64_t> list;
list.reserve([_list count]);
for (NSNumber *objcValue_0 in _list) {
int64_t cppValue_0 = [objcValue_0 longLongValue];
int64_t cppValue_0 = ::djinni::I64::Boxed::toCpp(objcValue_0);
list.push_back(std::move(cppValue_0));
}
return PrimitiveList(
......
......@@ -10,7 +10,7 @@
@property (nonatomic, readonly) int32_t key1;
@property (nonatomic, readonly) NSString *key2;
@property (nonatomic, readonly) NSString * key2;
- (NSComparisonResult)compare:(DBRecordWithDerivings *)other;
......
......@@ -3,6 +3,7 @@
#import "DBRecordWithDerivings+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......@@ -32,7 +33,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (id)initWithCppRecordWithDerivings:(const RecordWithDerivings &)recordWithDerivings
{
if (self = [super init]) {
_key1 = recordWithDerivings.key1;
_key1 = ::djinni::I32::fromCpp(recordWithDerivings.key1);
_key2 = [[NSString alloc] initWithBytes:recordWithDerivings.key2.data()
length:recordWithDerivings.key2.length()
encoding:NSUTF8StringEncoding];
......@@ -42,7 +43,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (RecordWithDerivings)cppRecordWithDerivings
{
int32_t key1 = _key1;
int32_t key1 = ::djinni::I32::toCpp(_key1);
std::string key2([_key2 UTF8String], [_key2 lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
return RecordWithDerivings(
std::move(key1),
......
......@@ -11,7 +11,7 @@
@property (nonatomic, readonly) int32_t key;
@property (nonatomic, readonly) DBRecordWithDerivings *rec;
@property (nonatomic, readonly) DBRecordWithDerivings * rec;
- (NSComparisonResult)compare:(DBRecordWithNestedDerivings *)other;
......
......@@ -4,6 +4,7 @@
#import "DBRecordWithNestedDerivings+Private.h"
#import "DBRecordWithDerivings+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......@@ -33,7 +34,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (id)initWithCppRecordWithNestedDerivings:(const RecordWithNestedDerivings &)recordWithNestedDerivings
{
if (self = [super init]) {
_key = recordWithNestedDerivings.key;
_key = ::djinni::I32::fromCpp(recordWithNestedDerivings.key);
_rec = [[DBRecordWithDerivings alloc] initWithCppRecordWithDerivings:recordWithNestedDerivings.rec];
}
return self;
......@@ -41,7 +42,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (RecordWithNestedDerivings)cppRecordWithNestedDerivings
{
int32_t key = _key;
int32_t key = ::djinni::I32::toCpp(_key);
RecordWithDerivings rec = std::move([_rec cppRecordWithDerivings]);
return RecordWithNestedDerivings(
std::move(key),
......
......@@ -8,6 +8,6 @@
- (id)initWithSetRecord:(DBSetRecord *)setRecord;
- (id)initWithSet:(NSSet *)set;
@property (nonatomic, readonly) NSSet *set;
@property (nonatomic, readonly) NSSet * set;
@end
......@@ -3,6 +3,7 @@
#import "DBSetRecord+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>
......
......@@ -15,6 +15,7 @@
#import "DJICppWrapperCache+Private.h"
#import "DJIDate.h"
#import "DJIError.h"
#import "DJIMarshal+Private.h"
#include <exception>
#include <utility>
#include <vector>
......@@ -59,7 +60,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
try {
SetRecord cppRec = std::move([rec cppSetRecord]);
bool cppRet = TestHelpers::check_set_record(std::move(cppRec));
BOOL objcRet = (cppRet) ? YES : NO;
BOOL objcRet = ::djinni::Bool::fromCpp(cppRet);
return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS()
}
......@@ -76,7 +77,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
try {
PrimitiveList cppPl = std::move([pl cppPrimitiveList]);
bool cppRet = TestHelpers::check_primitive_list(std::move(cppPl));
BOOL objcRet = (cppRet) ? YES : NO;
BOOL objcRet = ::djinni::Bool::fromCpp(cppRet);
return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS()
}
......@@ -93,7 +94,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
try {
NestedCollection cppNc = std::move([nc cppNestedCollection]);
bool cppRet = TestHelpers::check_nested_collection(std::move(cppNc));
BOOL objcRet = (cppRet) ? YES : NO;
BOOL objcRet = ::djinni::Bool::fromCpp(cppRet);
return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS()
}
......@@ -109,7 +110,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
NSString *objcKey_0 = [[NSString alloc] initWithBytes:cppPair_0.first.data()
length:cppPair_0.first.length()
encoding:NSUTF8StringEncoding];
NSNumber *objcValue_0 = [NSNumber numberWithLongLong:cppPair_0.second];
NSNumber *objcValue_0 = ::djinni::I64::Boxed::fromCpp(cppPair_0.second);
objcRetTempKeyVector.push_back(objcKey_0);
objcRetTempValueVector.push_back(objcValue_0);
}
......@@ -123,11 +124,11 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
std::unordered_map<std::string, int64_t> cppM;
for (id objcKey_0 in m) {
std::string cppKey_0([objcKey_0 UTF8String], [objcKey_0 lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
int64_t cppValue_0 = [[m objectForKey:objcKey_0] longLongValue];
int64_t cppValue_0 = ::djinni::I64::Boxed::toCpp([m objectForKey:objcKey_0]);
cppM.emplace(std::move(cppKey_0), std::move(cppValue_0));
}
bool cppRet = TestHelpers::check_map(std::move(cppM));
BOOL objcRet = (cppRet) ? YES : NO;
BOOL objcRet = ::djinni::Bool::fromCpp(cppRet);
return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS()
}
......@@ -143,7 +144,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
NSString *objcKey_0 = [[NSString alloc] initWithBytes:cppPair_0.first.data()
length:cppPair_0.first.length()
encoding:NSUTF8StringEncoding];
NSNumber *objcValue_0 = [NSNumber numberWithLongLong:cppPair_0.second];
NSNumber *objcValue_0 = ::djinni::I64::Boxed::fromCpp(cppPair_0.second);
objcRetTempKeyVector.push_back(objcKey_0);
objcRetTempValueVector.push_back(objcValue_0);
}
......@@ -157,11 +158,11 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
std::unordered_map<std::string, int64_t> cppM;
for (id objcKey_0 in m) {
std::string cppKey_0([objcKey_0 UTF8String], [objcKey_0 lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
int64_t cppValue_0 = [[m objectForKey:objcKey_0] longLongValue];
int64_t cppValue_0 = ::djinni::I64::Boxed::toCpp([m objectForKey:objcKey_0]);
cppM.emplace(std::move(cppKey_0), std::move(cppValue_0));
}
bool cppRet = TestHelpers::check_empty_map(std::move(cppM));
BOOL objcRet = (cppRet) ? YES : NO;
BOOL objcRet = ::djinni::Bool::fromCpp(cppRet);
return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS()
}
......@@ -178,7 +179,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
try {
MapListRecord cppM = std::move([m cppMapListRecord]);
bool cppRet = TestHelpers::check_map_list_record(std::move(cppM));
BOOL objcRet = (cppRet) ? YES : NO;
BOOL objcRet = ::djinni::Bool::fromCpp(cppRet);
return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS()
}
......@@ -237,7 +238,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
try {
std::shared_ptr<Token> cppT = t.cppRef;
int64_t cppRet = TestHelpers::cpp_token_id(std::move(cppT));
int64_t objcRet = cppRet;
int64_t objcRet = ::djinni::I64::fromCpp(cppRet);
return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS()
}
......@@ -247,7 +248,7 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
std::experimental::optional<int32_t> cppRet = TestHelpers::return_none();
NSNumber *objcRet;
if (cppRet) {
objcRet = [NSNumber numberWithInt:(*(cppRet))];
objcRet = ::djinni::I32::Boxed::fromCpp((*(cppRet)));
} else {
objcRet = nil;
}
......
......@@ -24,6 +24,7 @@
65868B5F1989FE4200D60EEE /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65868B5E1989FE4200D60EEE /* UIKit.framework */; };
65868B621989FE4200D60EEE /* libDjinniObjcTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 65868B4A1989FE4200D60EEE /* libDjinniObjcTest.a */; };
6D66A8A91A3B09F000B312E8 /* DBConstantTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6D66A8A81A3B09F000B312E8 /* DBConstantTests.mm */; };
A239F37A1AF400C600DF27C8 /* DJIDate.mm in Sources */ = {isa = PBXBuildFile; fileRef = A239F3781AF400C600DF27C8 /* DJIDate.mm */; };
A242494C1AF192E0003BF8F0 /* DBAssortedIntegers.mm in Sources */ = {isa = PBXBuildFile; fileRef = A242491B1AF192E0003BF8F0 /* DBAssortedIntegers.mm */; };
A242494D1AF192E0003BF8F0 /* DBClientInterfaceObjcProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = A242491E1AF192E0003BF8F0 /* DBClientInterfaceObjcProxy.mm */; };
A242494E1AF192E0003BF8F0 /* DBClientReturnedRecord.mm in Sources */ = {isa = PBXBuildFile; fileRef = A24249211AF192E0003BF8F0 /* DBClientReturnedRecord.mm */; };
......@@ -98,6 +99,9 @@
65868B5B1989FE4200D60EEE /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
65868B5E1989FE4200D60EEE /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
6D66A8A81A3B09F000B312E8 /* DBConstantTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBConstantTests.mm; sourceTree = "<group>"; };
A239F3771AF400C600DF27C8 /* DJIDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DJIDate.h; sourceTree = "<group>"; };
A239F3781AF400C600DF27C8 /* DJIDate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DJIDate.mm; sourceTree = "<group>"; };
A239F3791AF400C600DF27C8 /* DJIMarshal+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DJIMarshal+Private.h"; sourceTree = "<group>"; };
A24249191AF192E0003BF8F0 /* DBAssortedIntegers+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBAssortedIntegers+Private.h"; sourceTree = "<group>"; };
A242491A1AF192E0003BF8F0 /* DBAssortedIntegers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBAssortedIntegers.h; sourceTree = "<group>"; };
A242491B1AF192E0003BF8F0 /* DBAssortedIntegers.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBAssortedIntegers.mm; sourceTree = "<group>"; };
......@@ -202,6 +206,9 @@
6536CD6919A6C82200DD7715 /* objc-support-lib */ = {
isa = PBXGroup;
children = (
A239F3771AF400C600DF27C8 /* DJIDate.h */,
A239F3781AF400C600DF27C8 /* DJIDate.mm */,
A239F3791AF400C600DF27C8 /* DJIMarshal+Private.h */,
A2A162D01AF190D200C0B00A /* DJIDate.h */,
A2A162D11AF190D200C0B00A /* DJIDate.mm */,
A2CB54B319BA6E6000A9E600 /* DJIError.mm */,
......@@ -466,7 +473,6 @@
A278D45319BA3601006FD937 /* test_helpers.cpp in Sources */,
6536CD7819A6C98800DD7715 /* cpp_exception_impl.cpp in Sources */,
6536CD7419A6C96C00DD7715 /* DBClientInterfaceImpl.mm in Sources */,
6D66A8AD1A3B0A3200B312E8 /* DBConstants.mm in Sources */,
A242494E1AF192E0003BF8F0 /* DBClientReturnedRecord.mm in Sources */,
A242494C1AF192E0003BF8F0 /* DBAssortedIntegers.mm in Sources */,
A2A162D21AF190D200C0B00A /* DJIDate.mm in Sources */,
......@@ -481,6 +487,7 @@
A24249591AF192E0003BF8F0 /* DBRecordWithNestedDerivings.mm in Sources */,
A24249751AF192FC003BF8F0 /* record_with_derivings.cpp in Sources */,
A24249541AF192E0003BF8F0 /* DBMapListRecord.mm in Sources */,
A239F37A1AF400C600DF27C8 /* DJIDate.mm in Sources */,
A242494D1AF192E0003BF8F0 /* DBClientInterfaceObjcProxy.mm in Sources */,
A24249731AF192FC003BF8F0 /* assorted_integers.cpp in Sources */,
A24249561AF192E0003BF8F0 /* DBNestedCollection.mm in Sources */,
......
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