Commit 556e802e authored by Jacob Potter's avatar Jacob Potter

Add support for byte (i8) and short (i16) to Java wrappers

parent ba88bbe7
......@@ -540,7 +540,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
case df: MDef if df.defType == DEnum =>
w.w(s"self.${idObjc.field(f.ident)} == typedOther.${idObjc.field(f.ident)}")
case _ =>
w.w(s"((self.${idObjc.field(f.ident)} == nil && typedOther.${idObjc.field(f.ident)}] == nil) || ")
w.w(s"((self.${idObjc.field(f.ident)} == nil && typedOther.${idObjc.field(f.ident)} == nil) || ")
w.w(s"(self.${idObjc.field(f.ident)} != nil && [self.${idObjc.field(f.ident)} isEqual:typedOther.${idObjc.field(f.ident)}]))")
}
case MString => w.w(s"[self.${idObjc.field(f.ident)} isEqualToString:typedOther.${idObjc.field(f.ident)}]")
......@@ -796,7 +796,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) {
arg.base match {
case MOptional => throw new AssertionError("nested optional?")
case m =>
w.wl(s"$cppType $cppIdent = nullopt;")
w.wl(s"$cppType $cppIdent;")
m match {
case d: MDef if d.defType == DEnum =>
val enumVal = if (needRef) objcIdent else s"static_cast<${idObjc.ty(d.name)}>([$objcIdent intValue])"
......
//
// Copyright 2014 Dropbox, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#pragma once
#include "Primitive.hpp"
namespace djinni {
class HI16 : public Primitive<HI16, int16_t, jshort> {
HI16() : Primitive("java/lang/Short",
"valueOf", "(S)Ljava/lang/Short;",
"shortValue", "()S") {}
friend class JniClass<HI16>;
};
} // namespace djinni
//
// Copyright 2014 Dropbox, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#pragma once
#include "Primitive.hpp"
namespace djinni {
class HI8 : public Primitive<HI8, int8_t, jbyte> {
HI8() : Primitive("java/lang/Byte",
"valueOf", "(B)Ljava/lang/Byte;",
"byteValue", "()B") {}
friend class JniClass<HI8>;
};
} // namespace djinni
......@@ -74,6 +74,22 @@ private:
const jmethodID method_unbox;
};
template <>
inline
jbyte jniUnboxMethodCall<jbyte>(JNIEnv* jniEnv, jmethodID method, jobject thiz) {
jbyte ret = jniEnv->CallByteMethod(thiz, method);
jniExceptionCheck(jniEnv);
return ret;
}
template <>
inline
jshort jniUnboxMethodCall<jshort>(JNIEnv* jniEnv, jmethodID method, jobject thiz) {
jshort ret = jniEnv->CallShortMethod(thiz, method);
jniExceptionCheck(jniEnv);
return ret;
}
template <>
inline
jint jniUnboxMethodCall<jint>(JNIEnv* jniEnv, jmethodID method, jobject thiz) {
......
......@@ -7,3 +7,4 @@
@import "client_interface.djinni"
@import "enum.djinni"
@import "test.djinni"
@import "inttypes.djinni"
assorted_integers = record {
eight: i8;
sixteen: i16;
thirtytwo: i32;
sixtyfour: i64;
o_eight: optional<i8>;
o_sixteen: optional<i16>;
o_thirtytwo: optional<i32>;
o_sixtyfour: optional<i64>;
} deriving (eq)
......@@ -21,4 +21,7 @@ test_helpers = interface +c {
static check_enum_map(m: map<color, string>);
static return_none(): optional<i32>;
# Ensures that we generate integer translation code
static assorted_integers_id(i: assorted_integers): assorted_integers;
}
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from inttypes.djinni
#include "assorted_integers.hpp" // my header
bool AssortedIntegers::operator==(const AssortedIntegers & other) const {
return eight == other.eight &&
sixteen == other.sixteen &&
thirtytwo == other.thirtytwo &&
sixtyfour == other.sixtyfour &&
o_eight == other.o_eight &&
o_sixteen == other.o_sixteen &&
o_thirtytwo == other.o_thirtytwo &&
o_sixtyfour == other.o_sixtyfour;
}
bool AssortedIntegers::operator!=(const AssortedIntegers & other) const {
return !(*this == other);
}
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from inttypes.djinni
#pragma once
#include <cstdint>
#include <experimental/optional>
#include <utility>
struct AssortedIntegers final {
int8_t eight;
int16_t sixteen;
int32_t thirtytwo;
int64_t sixtyfour;
std::experimental::optional<int8_t> o_eight;
std::experimental::optional<int16_t> o_sixteen;
std::experimental::optional<int32_t> o_thirtytwo;
std::experimental::optional<int64_t> o_sixtyfour;
bool operator==(const AssortedIntegers & other) const;
bool operator!=(const AssortedIntegers & other) const;
AssortedIntegers(
int8_t eight,
int16_t sixteen,
int32_t thirtytwo,
int64_t sixtyfour,
std::experimental::optional<int8_t> o_eight,
std::experimental::optional<int16_t> o_sixteen,
std::experimental::optional<int32_t> o_thirtytwo,
std::experimental::optional<int64_t> o_sixtyfour) :
eight(std::move(eight)),
sixteen(std::move(sixteen)),
thirtytwo(std::move(thirtytwo)),
sixtyfour(std::move(sixtyfour)),
o_eight(std::move(o_eight)),
o_sixteen(std::move(o_sixteen)),
o_thirtytwo(std::move(o_thirtytwo)),
o_sixtyfour(std::move(o_sixtyfour)) {
}
};
......@@ -3,6 +3,7 @@
#pragma once
#include "assorted_integers.hpp"
#include "color.hpp"
#include "map_list_record.hpp"
#include "nested_collection.hpp"
......@@ -51,4 +52,7 @@ public:
static void check_enum_map(const std::unordered_map<color, std::string> & m);
static std::experimental::optional<int32_t> return_none();
/** Ensures that we generate integer translation code */
static AssortedIntegers assorted_integers_id(const AssortedIntegers & i);
};
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from inttypes.djinni
package com.dropbox.djinni.test;
public final class AssortedIntegers {
/*package*/ final byte mEight;
/*package*/ final short mSixteen;
/*package*/ final int mThirtytwo;
/*package*/ final long mSixtyfour;
/*package*/ final Byte mOEight;
/*package*/ final Short mOSixteen;
/*package*/ final Integer mOThirtytwo;
/*package*/ final Long mOSixtyfour;
public AssortedIntegers(
byte eight,
short sixteen,
int thirtytwo,
long sixtyfour,
Byte oEight,
Short oSixteen,
Integer oThirtytwo,
Long oSixtyfour) {
this.mEight = eight;
this.mSixteen = sixteen;
this.mThirtytwo = thirtytwo;
this.mSixtyfour = sixtyfour;
this.mOEight = oEight;
this.mOSixteen = oSixteen;
this.mOThirtytwo = oThirtytwo;
this.mOSixtyfour = oSixtyfour;
}
public byte getEight() {
return mEight;
}
public short getSixteen() {
return mSixteen;
}
public int getThirtytwo() {
return mThirtytwo;
}
public long getSixtyfour() {
return mSixtyfour;
}
public Byte getOEight() {
return mOEight;
}
public Short getOSixteen() {
return mOSixteen;
}
public Integer getOThirtytwo() {
return mOThirtytwo;
}
public Long getOSixtyfour() {
return mOSixtyfour;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof AssortedIntegers)) {
return false;
}
AssortedIntegers other = (AssortedIntegers) obj;
return this.mEight == other.mEight &&
this.mSixteen == other.mSixteen &&
this.mThirtytwo == other.mThirtytwo &&
this.mSixtyfour == other.mSixtyfour &&
((this.mOEight == null && other.mOEight == null) || (this.mOEight != null && this.mOEight.equals(other.mOEight))) &&
((this.mOSixteen == null && other.mOSixteen == null) || (this.mOSixteen != null && this.mOSixteen.equals(other.mOSixteen))) &&
((this.mOThirtytwo == null && other.mOThirtytwo == null) || (this.mOThirtytwo != null && this.mOThirtytwo.equals(other.mOThirtytwo))) &&
((this.mOSixtyfour == null && other.mOSixtyfour == null) || (this.mOSixtyfour != null && this.mOSixtyfour.equals(other.mOSixtyfour)));
}
}
......@@ -39,6 +39,9 @@ public abstract class TestHelpers {
public static native Integer returnNone();
/** Ensures that we generate integer translation code */
public static native AssortedIntegers assortedIntegersId(AssortedIntegers i);
public static final class NativeProxy extends TestHelpers
{
private final long nativeRef;
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from inttypes.djinni
#include "NativeAssortedIntegers.hpp" // my header
#include "HI16.hpp"
#include "HI32.hpp"
#include "HI64.hpp"
#include "HI8.hpp"
#include "HOptional.hpp"
namespace djinni_generated {
jobject NativeAssortedIntegers::toJava(JNIEnv* jniEnv, AssortedIntegers c) {
jbyte j_eight = ::djinni::HI8::Unboxed::toJava(jniEnv, c.eight);
jshort j_sixteen = ::djinni::HI16::Unboxed::toJava(jniEnv, c.sixteen);
jint j_thirtytwo = ::djinni::HI32::Unboxed::toJava(jniEnv, c.thirtytwo);
jlong j_sixtyfour = ::djinni::HI64::Unboxed::toJava(jniEnv, c.sixtyfour);
djinni::LocalRef<jobject> j_o_eight(jniEnv, ::djinni::HOptional<std::experimental::optional, ::djinni::HI8>::toJava(jniEnv, c.o_eight));
djinni::LocalRef<jobject> j_o_sixteen(jniEnv, ::djinni::HOptional<std::experimental::optional, ::djinni::HI16>::toJava(jniEnv, c.o_sixteen));
djinni::LocalRef<jobject> j_o_thirtytwo(jniEnv, ::djinni::HOptional<std::experimental::optional, ::djinni::HI32>::toJava(jniEnv, c.o_thirtytwo));
djinni::LocalRef<jobject> j_o_sixtyfour(jniEnv, ::djinni::HOptional<std::experimental::optional, ::djinni::HI64>::toJava(jniEnv, c.o_sixtyfour));
const auto & data = djinni::JniClass<::djinni_generated::NativeAssortedIntegers>::get();
jobject r = jniEnv->NewObject(data.clazz.get(), data.jconstructor, j_eight, j_sixteen, j_thirtytwo, j_sixtyfour, j_o_eight.get(), j_o_sixteen.get(), j_o_thirtytwo.get(), j_o_sixtyfour.get());
djinni::jniExceptionCheck(jniEnv);
return r;
}
AssortedIntegers NativeAssortedIntegers::fromJava(JNIEnv* jniEnv, jobject j) {
assert(j != nullptr);
const auto & data = djinni::JniClass<::djinni_generated::NativeAssortedIntegers>::get();
return AssortedIntegers(
::djinni::HI8::Unboxed::fromJava(jniEnv, jniEnv->GetByteField(j, data.field_mEight)),
::djinni::HI16::Unboxed::fromJava(jniEnv, jniEnv->GetShortField(j, data.field_mSixteen)),
::djinni::HI32::Unboxed::fromJava(jniEnv, jniEnv->GetIntField(j, data.field_mThirtytwo)),
::djinni::HI64::Unboxed::fromJava(jniEnv, jniEnv->GetLongField(j, data.field_mSixtyfour)),
::djinni::HOptional<std::experimental::optional, ::djinni::HI8>::fromJava(jniEnv, djinni::LocalRef<jobject>(jniEnv, jniEnv->GetObjectField(j, data.field_mOEight)).get()),
::djinni::HOptional<std::experimental::optional, ::djinni::HI16>::fromJava(jniEnv, djinni::LocalRef<jobject>(jniEnv, jniEnv->GetObjectField(j, data.field_mOSixteen)).get()),
::djinni::HOptional<std::experimental::optional, ::djinni::HI32>::fromJava(jniEnv, djinni::LocalRef<jobject>(jniEnv, jniEnv->GetObjectField(j, data.field_mOThirtytwo)).get()),
::djinni::HOptional<std::experimental::optional, ::djinni::HI64>::fromJava(jniEnv, djinni::LocalRef<jobject>(jniEnv, jniEnv->GetObjectField(j, data.field_mOSixtyfour)).get()));
}
} // namespace djinni_generated
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from inttypes.djinni
#pragma once
#include "assorted_integers.hpp"
#include "djinni_support.hpp"
namespace djinni_generated {
class NativeAssortedIntegers final {
public:
using CppType = AssortedIntegers;
using JniType = jobject;
static jobject toJava(JNIEnv*, AssortedIntegers);
static AssortedIntegers fromJava(JNIEnv*, jobject);
const djinni::GlobalRef<jclass> clazz { djinni::jniFindClass("com/dropbox/djinni/test/AssortedIntegers") };
const jmethodID jconstructor { djinni::jniGetMethodID(clazz.get(), "<init>", "(BSIJLjava/lang/Byte;Ljava/lang/Short;Ljava/lang/Integer;Ljava/lang/Long;)V") };
const jfieldID field_mEight { djinni::jniGetFieldID(clazz.get(), "mEight", "B") };
const jfieldID field_mSixteen { djinni::jniGetFieldID(clazz.get(), "mSixteen", "S") };
const jfieldID field_mThirtytwo { djinni::jniGetFieldID(clazz.get(), "mThirtytwo", "I") };
const jfieldID field_mSixtyfour { djinni::jniGetFieldID(clazz.get(), "mSixtyfour", "J") };
const jfieldID field_mOEight { djinni::jniGetFieldID(clazz.get(), "mOEight", "Ljava/lang/Byte;") };
const jfieldID field_mOSixteen { djinni::jniGetFieldID(clazz.get(), "mOSixteen", "Ljava/lang/Short;") };
const jfieldID field_mOThirtytwo { djinni::jniGetFieldID(clazz.get(), "mOThirtytwo", "Ljava/lang/Integer;") };
const jfieldID field_mOSixtyfour { djinni::jniGetFieldID(clazz.get(), "mOSixtyfour", "Ljava/lang/Long;") };
private:
NativeAssortedIntegers() {}
friend class djinni::JniClass<::djinni_generated::NativeAssortedIntegers>;
};
} // namespace djinni_generated
......@@ -8,6 +8,7 @@
#include "HMap.hpp"
#include "HOptional.hpp"
#include "HString.hpp"
#include "NativeAssortedIntegers.hpp"
#include "NativeClientInterface.hpp"
#include "NativeColor.hpp"
#include "NativeMapListRecord.hpp"
......@@ -208,4 +209,16 @@ CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_TestHelpers_returnNone(J
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */ )
}
CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_TestHelpers_assortedIntegersId(JNIEnv* jniEnv, jobject /*this*/, jobject j_i)
{
try {
DJINNI_FUNCTION_PROLOGUE0(jniEnv);
AssortedIntegers c_i = NativeAssortedIntegers::fromJava(jniEnv, j_i);
AssortedIntegers cr = TestHelpers::assorted_integers_id(c_i);
return NativeAssortedIntegers::toJava(jniEnv, cr);
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */ )
}
} // namespace djinni_generated
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from inttypes.djinni
#import "DBAssortedIntegers.h"
#include "assorted_integers.hpp"
#import <Foundation/Foundation.h>
@interface DBAssortedIntegers ()
- (id)initWithCppAssortedIntegers:(const AssortedIntegers &)assortedIntegers;
- (AssortedIntegers)cppAssortedIntegers;
@end
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from inttypes.djinni
#import <Foundation/Foundation.h>
@interface DBAssortedIntegers : NSObject
- (id)initWithAssortedIntegers:(DBAssortedIntegers *)assortedIntegers;
- (id)initWithEight:(int8_t)eight sixteen:(int16_t)sixteen thirtytwo:(int32_t)thirtytwo sixtyfour:(int64_t)sixtyfour oEight:(NSNumber *)oEight oSixteen:(NSNumber *)oSixteen oThirtytwo:(NSNumber *)oThirtytwo oSixtyfour:(NSNumber *)oSixtyfour;
@property (nonatomic, readonly) int8_t eight;
@property (nonatomic, readonly) int16_t sixteen;
@property (nonatomic, readonly) int32_t thirtytwo;
@property (nonatomic, readonly) int64_t sixtyfour;
@property (nonatomic, readonly) NSNumber *oEight;
@property (nonatomic, readonly) NSNumber *oSixteen;
@property (nonatomic, readonly) NSNumber *oThirtytwo;
@property (nonatomic, readonly) NSNumber *oSixtyfour;
@end
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from inttypes.djinni
#import "DBAssortedIntegers+Private.h"
#import <Foundation/Foundation.h>
#include <utility>
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
@implementation DBAssortedIntegers
- (id)initWithAssortedIntegers:(DBAssortedIntegers *)assortedIntegers
{
if (self = [super init]) {
_eight = assortedIntegers.eight;
_sixteen = assortedIntegers.sixteen;
_thirtytwo = assortedIntegers.thirtytwo;
_sixtyfour = assortedIntegers.sixtyfour;
if (assortedIntegers.oEight == nil) {
_oEight = nil;
} else {
_oEight = assortedIntegers.oEight;
}
if (assortedIntegers.oSixteen == nil) {
_oSixteen = nil;
} else {
_oSixteen = assortedIntegers.oSixteen;
}
if (assortedIntegers.oThirtytwo == nil) {
_oThirtytwo = nil;
} else {
_oThirtytwo = assortedIntegers.oThirtytwo;
}
if (assortedIntegers.oSixtyfour == nil) {
_oSixtyfour = nil;
} else {
_oSixtyfour = assortedIntegers.oSixtyfour;
}
}
return self;
}
- (id)initWithEight:(int8_t)eight sixteen:(int16_t)sixteen thirtytwo:(int32_t)thirtytwo sixtyfour:(int64_t)sixtyfour oEight:(NSNumber *)oEight oSixteen:(NSNumber *)oSixteen oThirtytwo:(NSNumber *)oThirtytwo oSixtyfour:(NSNumber *)oSixtyfour
{
if (self = [super init]) {
_eight = eight;
_sixteen = sixteen;
_thirtytwo = thirtytwo;
_sixtyfour = sixtyfour;
_oEight = oEight;
_oSixteen = oSixteen;
_oThirtytwo = oThirtytwo;
_oSixtyfour = oSixtyfour;
}
return self;
}
- (id)initWithCppAssortedIntegers:(const AssortedIntegers &)assortedIntegers
{
if (self = [super init]) {
_eight = assortedIntegers.eight;
_sixteen = assortedIntegers.sixteen;
_thirtytwo = assortedIntegers.thirtytwo;
_sixtyfour = assortedIntegers.sixtyfour;
if (assortedIntegers.o_eight) {
_oEight = [NSNumber numberWithChar:(*(assortedIntegers.o_eight))];
} else {
_oEight = nil;
}
if (assortedIntegers.o_sixteen) {
_oSixteen = [NSNumber numberWithShort:(*(assortedIntegers.o_sixteen))];
} else {
_oSixteen = nil;
}
if (assortedIntegers.o_thirtytwo) {
_oThirtytwo = [NSNumber numberWithInt:(*(assortedIntegers.o_thirtytwo))];
} else {
_oThirtytwo = nil;
}
if (assortedIntegers.o_sixtyfour) {
_oSixtyfour = [NSNumber numberWithLongLong:(*(assortedIntegers.o_sixtyfour))];
} else {
_oSixtyfour = nil;
}
}
return self;
}
- (AssortedIntegers)cppAssortedIntegers
{
int8_t eight = _eight;
int16_t sixteen = _sixteen;
int32_t thirtytwo = _thirtytwo;
int64_t sixtyfour = _sixtyfour;
std::experimental::optional<int8_t> oEight;
if (_oEight != nil) {
int8_t optValue = [_oEight charValue];
oEight = optValue;
}
std::experimental::optional<int16_t> oSixteen;
if (_oSixteen != nil) {
int16_t optValue = [_oSixteen shortValue];
oSixteen = optValue;
}
std::experimental::optional<int32_t> oThirtytwo;
if (_oThirtytwo != nil) {
int32_t optValue = [_oThirtytwo intValue];
oThirtytwo = optValue;
}
std::experimental::optional<int64_t> oSixtyfour;
if (_oSixtyfour != nil) {
int64_t optValue = [_oSixtyfour longLongValue];
oSixtyfour = optValue;
}
return AssortedIntegers(
std::move(eight),
std::move(sixteen),
std::move(thirtytwo),
std::move(sixtyfour),
std::move(oEight),
std::move(oSixteen),
std::move(oThirtytwo),
std::move(oSixtyfour));
}
- (BOOL)isEqual:(id)other
{
if (![other isKindOfClass:[DBAssortedIntegers class]]) {
return NO;
}
DBAssortedIntegers *typedOther = (DBAssortedIntegers *)other;
return self.eight == typedOther.eight &&
self.sixteen == typedOther.sixteen &&
self.thirtytwo == typedOther.thirtytwo &&
self.sixtyfour == typedOther.sixtyfour &&
((self.oEight == nil && typedOther.oEight == nil) || (self.oEight != nil && [self.oEight isEqual:typedOther.oEight])) &&
((self.oSixteen == nil && typedOther.oSixteen == nil) || (self.oSixteen != nil && [self.oSixteen isEqual:typedOther.oSixteen])) &&
((self.oThirtytwo == nil && typedOther.oThirtytwo == nil) || (self.oThirtytwo != nil && [self.oThirtytwo isEqual:typedOther.oThirtytwo])) &&
((self.oSixtyfour == nil && typedOther.oSixtyfour == nil) || (self.oSixtyfour != nil && [self.oSixtyfour isEqual:typedOther.oSixtyfour]));
}
@end
......@@ -4,6 +4,7 @@
#import "DBClientInterface.h"
#import "DBColor.h"
#import <Foundation/Foundation.h>
@class DBAssortedIntegers;
@class DBMapListRecord;
@class DBNestedCollection;
@class DBPrimitiveList;
......@@ -44,4 +45,7 @@
+ (NSNumber *)returnNone;
/** Ensures that we generate integer translation code */
+ (DBAssortedIntegers *)assortedIntegersId:(DBAssortedIntegers *)i;
@end
......@@ -2,6 +2,7 @@
// This file generated by Djinni from test.djinni
#import "DBTestHelpersCppProxy+Private.h"
#import "DBAssortedIntegers+Private.h"
#import "DBClientInterfaceObjcProxy+Private.h"
#import "DBColor.h"
#import "DBColorTranslator+Private.h"
......@@ -203,4 +204,13 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (DBAssortedIntegers *)assortedIntegersId:(DBAssortedIntegers *)i {
try {
AssortedIntegers cppI = std::move([i cppAssortedIntegers]);
AssortedIntegers cppRet = TestHelpers::assorted_integers_id(std::move(cppI));
DBAssortedIntegers *objcRet = [[DBAssortedIntegers alloc] initWithCppAssortedIntegers:cppRet];
return objcRet;
} DJINNI_TRANSLATE_EXCEPTIONS()
}
@end
......@@ -104,3 +104,7 @@ void TestHelpers::check_enum_map(const std::unordered_map<color, std::string> &
throw std::invalid_argument("map mismatch");
}
}
AssortedIntegers TestHelpers::assorted_integers_id(const AssortedIntegers & i) {
return i;
}
......@@ -15,6 +15,7 @@ public class AllTests extends TestSuite {
mySuite.addTestSuite(CppExceptionTest.class);
mySuite.addTestSuite(ClientInterfaceTest.class);
mySuite.addTestSuite(EnumTest.class);
mySuite.addTestSuite(IntegerTest.class);
return mySuite;
}
......
package com.dropbox.djinni.test;
import junit.framework.TestCase;
public class IntegerTest extends TestCase {
public void testIntegers() {
AssortedIntegers i = new AssortedIntegers((byte)123, (short)20000, 1000000000, 1234567890123456789L,
(byte)123, (short)20000, 1000000000, 1234567890123456789L);
assertEquals(i, TestHelpers.assortedIntegersId(i));
}
}
......@@ -36,6 +36,8 @@
65BAE70D19A6C7100035F775 /* DBRecordWithNestedDerivings.mm in Sources */ = {isa = PBXBuildFile; fileRef = 65BAE6FF19A6C7100035F775 /* DBRecordWithNestedDerivings.mm */; };
65BAE70E19A6C7100035F775 /* DBSetRecord.mm in Sources */ = {isa = PBXBuildFile; fileRef = 65BAE70219A6C7100035F775 /* DBSetRecord.mm */; };
A2059B6219DF7DDE006A2896 /* DBColorTranslator.mm in Sources */ = {isa = PBXBuildFile; fileRef = A2059B6019DF7DDE006A2896 /* DBColorTranslator.mm */; };
A227B6A91A0D79F10003BBAC /* assorted_integers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A227B6A71A0D79F10003BBAC /* assorted_integers.cpp */; };
A227B6AD1A0D7A290003BBAC /* DBAssortedIntegers.mm in Sources */ = {isa = PBXBuildFile; fileRef = A227B6AB1A0D7A290003BBAC /* DBAssortedIntegers.mm */; };
A278D45019BA33CB006FD937 /* DBTestHelpersCppProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = A278D44E19BA33CB006FD937 /* DBTestHelpersCppProxy.mm */; };
A278D45319BA3601006FD937 /* test_helpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A278D45219BA3601006FD937 /* test_helpers.cpp */; };
A2CB54B419BA6E6000A9E600 /* DJIError.mm in Sources */ = {isa = PBXBuildFile; fileRef = A2CB54B319BA6E6000A9E600 /* DJIError.mm */; };
......@@ -135,6 +137,11 @@
A2059B5F19DF7DDE006A2896 /* DBColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBColor.h; sourceTree = "<group>"; };
A2059B6019DF7DDE006A2896 /* DBColorTranslator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBColorTranslator.mm; sourceTree = "<group>"; };
A2059B6119DF7DDE006A2896 /* DBColorTranslator+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBColorTranslator+Private.h"; sourceTree = "<group>"; };
A227B6A71A0D79F10003BBAC /* assorted_integers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = assorted_integers.cpp; sourceTree = "<group>"; };
A227B6A81A0D79F10003BBAC /* assorted_integers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = assorted_integers.hpp; sourceTree = "<group>"; };
A227B6AA1A0D7A290003BBAC /* DBAssortedIntegers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBAssortedIntegers.h; sourceTree = "<group>"; };
A227B6AB1A0D7A290003BBAC /* DBAssortedIntegers.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBAssortedIntegers.mm; sourceTree = "<group>"; };
A227B6AC1A0D7A290003BBAC /* DBAssortedIntegers+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBAssortedIntegers+Private.h"; sourceTree = "<group>"; };
A278D44C19BA33CB006FD937 /* DBTestHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBTestHelpers.h; sourceTree = "<group>"; };
A278D44D19BA33CB006FD937 /* DBTestHelpersCppProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBTestHelpersCppProxy.h; sourceTree = "<group>"; };
A278D44E19BA33CB006FD937 /* DBTestHelpersCppProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBTestHelpersCppProxy.mm; sourceTree = "<group>"; };
......@@ -256,6 +263,8 @@
65BAE6D619A6C7100035F775 /* generated-cpp */ = {
isa = PBXGroup;
children = (
A227B6A71A0D79F10003BBAC /* assorted_integers.cpp */,
A227B6A81A0D79F10003BBAC /* assorted_integers.hpp */,
A2059B5E19DF7DBA006A2896 /* color.hpp */,
A278D45119BA3428006FD937 /* test_helpers.hpp */,
65BAE6D719A6C7100035F775 /* client_interface.hpp */,
......@@ -278,6 +287,9 @@
65BAE6E319A6C7100035F775 /* generated-objc */ = {
isa = PBXGroup;
children = (
A227B6AA1A0D7A290003BBAC /* DBAssortedIntegers.h */,
A227B6AB1A0D7A290003BBAC /* DBAssortedIntegers.mm */,
A227B6AC1A0D7A290003BBAC /* DBAssortedIntegers+Private.h */,
A2059B5F19DF7DDE006A2896 /* DBColor.h */,
A2059B6019DF7DDE006A2896 /* DBColorTranslator.mm */,
A2059B6119DF7DDE006A2896 /* DBColorTranslator+Private.h */,
......@@ -420,7 +432,9 @@
65BAE70419A6C7100035F775 /* record_with_nested_derivings.cpp in Sources */,
A2CB54B419BA6E6000A9E600 /* DJIError.mm in Sources */,
A278D45019BA33CB006FD937 /* DBTestHelpersCppProxy.mm in Sources */,
A227B6AD1A0D7A290003BBAC /* DBAssortedIntegers.mm in Sources */,
65BAE70519A6C7100035F775 /* DBClientInterfaceObjcProxy.mm in Sources */,
A227B6A91A0D79F10003BBAC /* assorted_integers.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
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