Commit 4ce26966 authored by j4cbo's avatar j4cbo

Merge pull request #175 from dropbox/atwyman/optional-interface

Fix optional interface arguments when not using nn
parents 163fbe4d aad78a00
...@@ -32,7 +32,8 @@ example_ios: ./build_ios/example/libtextsort.xcodeproj ...@@ -32,7 +32,8 @@ example_ios: ./build_ios/example/libtextsort.xcodeproj
xcodebuild -workspace example/objc/TextSort.xcworkspace \ xcodebuild -workspace example/objc/TextSort.xcworkspace \
-scheme TextSort \ -scheme TextSort \
-configuration 'Debug' \ -configuration 'Debug' \
-sdk iphonesimulator -sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.2'
# this target implicitly depends on GypAndroid.mk since gradle will try to make it # this target implicitly depends on GypAndroid.mk since gradle will try to make it
example_android: GypAndroid.mk example_android: GypAndroid.mk
......
...@@ -11,6 +11,7 @@ namespace djinni_generated { ...@@ -11,6 +11,7 @@ namespace djinni_generated {
class NativeSortItems final : ::djinni::JniInterface<::textsort::SortItems, NativeSortItems> { class NativeSortItems final : ::djinni::JniInterface<::textsort::SortItems, NativeSortItems> {
public: public:
using CppType = std::shared_ptr<::textsort::SortItems>; using CppType = std::shared_ptr<::textsort::SortItems>;
using CppOptType = std::shared_ptr<::textsort::SortItems>;
using JniType = jobject; using JniType = jobject;
using Boxed = NativeSortItems; using Boxed = NativeSortItems;
...@@ -18,7 +19,8 @@ public: ...@@ -18,7 +19,8 @@ public:
~NativeSortItems(); ~NativeSortItems();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeSortItems>::get()._fromJava(jniEnv, j); } static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeSortItems>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return {jniEnv, ::djinni::JniClass<NativeSortItems>::get()._toJava(jniEnv, c)}; } static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeSortItems>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private: private:
NativeSortItems(); NativeSortItems();
......
...@@ -11,6 +11,7 @@ namespace djinni_generated { ...@@ -11,6 +11,7 @@ namespace djinni_generated {
class NativeTextboxListener final : ::djinni::JniInterface<::textsort::TextboxListener, NativeTextboxListener> { class NativeTextboxListener final : ::djinni::JniInterface<::textsort::TextboxListener, NativeTextboxListener> {
public: public:
using CppType = std::shared_ptr<::textsort::TextboxListener>; using CppType = std::shared_ptr<::textsort::TextboxListener>;
using CppOptType = std::shared_ptr<::textsort::TextboxListener>;
using JniType = jobject; using JniType = jobject;
using Boxed = NativeTextboxListener; using Boxed = NativeTextboxListener;
...@@ -18,7 +19,8 @@ public: ...@@ -18,7 +19,8 @@ public:
~NativeTextboxListener(); ~NativeTextboxListener();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeTextboxListener>::get()._fromJava(jniEnv, j); } static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeTextboxListener>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return {jniEnv, ::djinni::JniClass<NativeTextboxListener>::get()._toJava(jniEnv, c)}; } static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeTextboxListener>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private: private:
NativeTextboxListener(); NativeTextboxListener();
......
...@@ -14,12 +14,14 @@ class SortItems ...@@ -14,12 +14,14 @@ class SortItems
{ {
public: public:
using CppType = std::shared_ptr<::textsort::SortItems>; using CppType = std::shared_ptr<::textsort::SortItems>;
using CppOptType = std::shared_ptr<::textsort::SortItems>;
using ObjcType = TXSSortItems*; using ObjcType = TXSSortItems*;
using Boxed = SortItems; using Boxed = SortItems;
static CppType toCpp(ObjcType objc); static CppType toCpp(ObjcType objc);
static ObjcType fromCpp(const CppType& cpp); static ObjcType fromCppOpt(const CppOptType& cpp);
static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }
private: private:
class ObjcProxy; class ObjcProxy;
......
...@@ -64,7 +64,7 @@ auto SortItems::toCpp(ObjcType objc) -> CppType ...@@ -64,7 +64,7 @@ auto SortItems::toCpp(ObjcType objc) -> CppType
return objc->_cppRefHandle.get(); return objc->_cppRefHandle.get();
} }
auto SortItems::fromCpp(const CppType& cpp) -> ObjcType auto SortItems::fromCppOpt(const CppOptType& cpp) -> ObjcType
{ {
if (!cpp) { if (!cpp) {
return nil; return nil;
......
...@@ -14,12 +14,14 @@ class TextboxListener ...@@ -14,12 +14,14 @@ class TextboxListener
{ {
public: public:
using CppType = std::shared_ptr<::textsort::TextboxListener>; using CppType = std::shared_ptr<::textsort::TextboxListener>;
using CppOptType = std::shared_ptr<::textsort::TextboxListener>;
using ObjcType = id<TXSTextboxListener>; using ObjcType = id<TXSTextboxListener>;
using Boxed = TextboxListener; using Boxed = TextboxListener;
static CppType toCpp(ObjcType objc); static CppType toCpp(ObjcType objc);
static ObjcType fromCpp(const CppType& cpp); static ObjcType fromCppOpt(const CppOptType& cpp);
static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }
private: private:
class ObjcProxy; class ObjcProxy;
......
...@@ -36,7 +36,7 @@ auto TextboxListener::toCpp(ObjcType objc) -> CppType ...@@ -36,7 +36,7 @@ auto TextboxListener::toCpp(ObjcType objc) -> CppType
return ::djinni::get_objc_proxy<ObjcProxy>(objc); return ::djinni::get_objc_proxy<ObjcProxy>(objc);
} }
auto TextboxListener::fromCpp(const CppType& cpp) -> ObjcType auto TextboxListener::fromCppOpt(const CppOptType& cpp) -> ObjcType
{ {
if (!cpp) { if (!cpp) {
return nil; return nil;
......
...@@ -195,6 +195,7 @@ class JNIGenerator(spec: Spec) extends Generator(spec) { ...@@ -195,6 +195,7 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
w.wl(s"using CppOptType = std::shared_ptr<$cppSelf>;") w.wl(s"using CppOptType = std::shared_ptr<$cppSelf>;")
case _ => case _ =>
w.wl(s"using CppType = std::shared_ptr<$cppSelf>;") w.wl(s"using CppType = std::shared_ptr<$cppSelf>;")
w.wl(s"using CppOptType = std::shared_ptr<$cppSelf>;")
} }
w.wl(s"using JniType = jobject;") w.wl(s"using JniType = jobject;")
w.wl w.wl
...@@ -208,12 +209,11 @@ class JNIGenerator(spec: Spec) extends Generator(spec) { ...@@ -208,12 +209,11 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
w.wl(s"""DJINNI_ASSERT_MSG(j, jniEnv, "$jniSelf::fromCpp requires a non-null Java object");""") w.wl(s"""DJINNI_ASSERT_MSG(j, jniEnv, "$jniSelf::fromCpp requires a non-null Java object");""")
w.wl(s"""return ${nnCheck(s"::djinni::JniClass<$jniSelf>::get()._fromJava(jniEnv, j)")};""") w.wl(s"""return ${nnCheck(s"::djinni::JniClass<$jniSelf>::get()._fromJava(jniEnv, j)")};""")
} }
w.wl(s"static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<$jniSelf>::get()._toJava(jniEnv, c)}; }")
w.wl(s"static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }")
} else { } else {
w.wl(s"static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<$jniSelf>::get()._fromJava(jniEnv, j); }") w.wl(s"static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<$jniSelf>::get()._fromJava(jniEnv, j); }")
w.wl(s"static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return {jniEnv, ::djinni::JniClass<$jniSelf>::get()._toJava(jniEnv, c)}; }")
} }
w.wl(s"static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<$jniSelf>::get()._toJava(jniEnv, c)}; }")
w.wl(s"static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }")
w.wl w.wl
w.wlOutdent("private:") w.wlOutdent("private:")
w.wl(s"$jniSelf();") w.wl(s"$jniSelf();")
......
...@@ -102,18 +102,15 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { ...@@ -102,18 +102,15 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
w.wl(s"using CppOptType = std::shared_ptr<$cppSelf>;") w.wl(s"using CppOptType = std::shared_ptr<$cppSelf>;")
case _ => case _ =>
w.wl(s"using CppType = std::shared_ptr<$cppSelf>;") w.wl(s"using CppType = std::shared_ptr<$cppSelf>;")
w.wl(s"using CppOptType = std::shared_ptr<$cppSelf>;")
} }
w.wl("using ObjcType = " + (if(i.ext.objc) s"id<$self>" else s"$self*") + ";"); w.wl("using ObjcType = " + (if(i.ext.objc) s"id<$self>" else s"$self*") + ";");
w.wl w.wl
w.wl(s"using Boxed = $helperClass;") w.wl(s"using Boxed = $helperClass;")
w.wl w.wl
w.wl(s"static CppType toCpp(ObjcType objc);") w.wl(s"static CppType toCpp(ObjcType objc);")
if (spec.cppNnType.nonEmpty) { w.wl(s"static ObjcType fromCppOpt(const CppOptType& cpp);")
w.wl(s"static ObjcType fromCppOpt(const CppOptType& cpp);") w.wl(s"static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }")
w.wl(s"static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }")
} else {
w.wl(s"static ObjcType fromCpp(const CppType& cpp);")
}
w.wl w.wl
w.wlOutdent("private:") w.wlOutdent("private:")
w.wl("class ObjcProxy;") w.wl("class ObjcProxy;")
...@@ -263,9 +260,7 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { ...@@ -263,9 +260,7 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) {
} }
} }
w.wl w.wl
val fromCppFunc = if (spec.cppNnType.isEmpty) "fromCpp(const CppType& cpp)" w.wl(s"auto $helperClass::fromCppOpt(const CppOptType& cpp) -> ObjcType").braced {
else "fromCppOpt(const CppOptType& cpp)"
w.wl(s"auto $helperClass::$fromCppFunc -> ObjcType").braced {
// Handle null // Handle null
w.w("if (!cpp)").braced { w.w("if (!cpp)").braced {
w.wl("return nil;") w.wl("return nil;")
......
.PHONY: all objc java linux_docker .PHONY: all djinni objc java linux_docker
FORCE_DJINNI := $(shell ./run_djinni.sh >&2)
all: objc java all: objc java
objc: djinni:
cd objc; xcodebuild -sdk iphonesimulator -project DjinniObjcTest.xcodeproj -scheme DjinniObjcTest test ./run_djinni.sh
objc: djinni
cd objc; xcodebuild -sdk iphonesimulator -project DjinniObjcTest.xcodeproj -scheme DjinniObjcTest test -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.2'
java: java: djinni
cd java && ant compile test cd java && ant compile test
linux_docker: linux_docker: djinni
cd ..; ./test-suite/java/docker/run_dockerized_test.sh cd ..; ./test-suite/java/docker/run_dockerized_test.sh
...@@ -11,4 +11,16 @@ client_interface = interface +j +o { ...@@ -11,4 +11,16 @@ client_interface = interface +j +o {
get_record(record_id: i64, utf8string: string, misc: optional<string>): client_returned_record; get_record(record_id: i64, utf8string: string, misc: optional<string>): client_returned_record;
identifier_check(data: binary, r: i32, jret: i64): f64; identifier_check(data: binary, r: i32, jret: i64): f64;
return_str(): string; return_str(): string;
meth_taking_interface(i: client_interface): string;
meth_taking_optional_interface(i: optional<client_interface>): string;
}
reverse_client_interface = interface +c {
return_str(): string;
meth_taking_interface(i: reverse_client_interface): string;
meth_taking_optional_interface(i: optional<reverse_client_interface>): string;
static create(): reverse_client_interface;
} }
...@@ -24,6 +24,7 @@ test_helpers = interface +c { ...@@ -24,6 +24,7 @@ test_helpers = interface +c {
static check_client_interface_ascii(i: client_interface); static check_client_interface_ascii(i: client_interface);
static check_client_interface_nonascii(i: client_interface); static check_client_interface_nonascii(i: client_interface);
static check_client_interface_args(i: client_interface);
static check_enum_map(m: map<color, string>); static check_enum_map(m: map<color, string>);
static check_enum(c: color); static check_enum(c: color);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <cstdint> #include <cstdint>
#include <experimental/optional> #include <experimental/optional>
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -23,6 +24,10 @@ public: ...@@ -23,6 +24,10 @@ public:
virtual double identifier_check(const std::vector<uint8_t> & data, int32_t r, int64_t jret) = 0; virtual double identifier_check(const std::vector<uint8_t> & data, int32_t r, int64_t jret) = 0;
virtual std::string return_str() = 0; virtual std::string return_str() = 0;
virtual std::string meth_taking_interface(const std::shared_ptr<ClientInterface> & i) = 0;
virtual std::string meth_taking_optional_interface(const std::shared_ptr<ClientInterface> & i) = 0;
}; };
} // namespace testsuite } // namespace testsuite
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from client_interface.djinni
#pragma once
#include <experimental/optional>
#include <memory>
#include <string>
namespace testsuite {
class ReverseClientInterface {
public:
virtual ~ReverseClientInterface() {}
virtual std::string return_str() = 0;
virtual std::string meth_taking_interface(const std::shared_ptr<ReverseClientInterface> & i) = 0;
virtual std::string meth_taking_optional_interface(const std::shared_ptr<ReverseClientInterface> & i) = 0;
static std::shared_ptr<ReverseClientInterface> create();
};
} // namespace testsuite
...@@ -64,6 +64,8 @@ public: ...@@ -64,6 +64,8 @@ public:
static void check_client_interface_nonascii(const std::shared_ptr<ClientInterface> & i); static void check_client_interface_nonascii(const std::shared_ptr<ClientInterface> & i);
static void check_client_interface_args(const std::shared_ptr<ClientInterface> & i);
static void check_enum_map(const std::unordered_map<color, std::string> & m); static void check_enum_map(const std::unordered_map<color, std::string> & m);
static void check_enum(color c); static void check_enum(color c);
......
...@@ -16,4 +16,10 @@ public abstract class ClientInterface { ...@@ -16,4 +16,10 @@ public abstract class ClientInterface {
@Nonnull @Nonnull
public abstract String returnStr(); public abstract String returnStr();
@Nonnull
public abstract String methTakingInterface(@CheckForNull ClientInterface i);
@Nonnull
public abstract String methTakingOptionalInterface(@CheckForNull ClientInterface i);
} }
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from client_interface.djinni
package com.dropbox.djinni.test;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
public abstract class ReverseClientInterface {
@Nonnull
public abstract String returnStr();
@Nonnull
public abstract String methTakingInterface(@CheckForNull ReverseClientInterface i);
@Nonnull
public abstract String methTakingOptionalInterface(@CheckForNull ReverseClientInterface i);
@CheckForNull
public static native ReverseClientInterface create();
private static final class CppProxy extends ReverseClientInterface
{
private final long nativeRef;
private final AtomicBoolean destroyed = new AtomicBoolean(false);
private CppProxy(long nativeRef)
{
if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
this.nativeRef = nativeRef;
}
private native void nativeDestroy(long nativeRef);
public void destroy()
{
boolean destroyed = this.destroyed.getAndSet(true);
if (!destroyed) nativeDestroy(this.nativeRef);
}
protected void finalize() throws java.lang.Throwable
{
destroy();
super.finalize();
}
@Override
public String returnStr()
{
assert !this.destroyed.get() : "trying to use a destroyed object";
return native_returnStr(this.nativeRef);
}
private native String native_returnStr(long _nativeRef);
@Override
public String methTakingInterface(ReverseClientInterface i)
{
assert !this.destroyed.get() : "trying to use a destroyed object";
return native_methTakingInterface(this.nativeRef, i);
}
private native String native_methTakingInterface(long _nativeRef, ReverseClientInterface i);
@Override
public String methTakingOptionalInterface(ReverseClientInterface i)
{
assert !this.destroyed.get() : "trying to use a destroyed object";
return native_methTakingOptionalInterface(this.nativeRef, i);
}
private native String native_methTakingOptionalInterface(long _nativeRef, ReverseClientInterface i);
}
}
...@@ -54,6 +54,8 @@ public abstract class TestHelpers { ...@@ -54,6 +54,8 @@ public abstract class TestHelpers {
public static native void checkClientInterfaceNonascii(@CheckForNull ClientInterface i); public static native void checkClientInterfaceNonascii(@CheckForNull ClientInterface i);
public static native void checkClientInterfaceArgs(@CheckForNull ClientInterface i);
public static native void checkEnumMap(@Nonnull HashMap<Color, String> m); public static native void checkEnumMap(@Nonnull HashMap<Color, String> m);
public static native void checkEnum(@Nonnull Color c); public static native void checkEnum(@Nonnull Color c);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "NativeClientInterface.hpp" // my header #include "NativeClientInterface.hpp" // my header
#include "Marshal.hpp" #include "Marshal.hpp"
#include "NativeClientInterface.hpp"
#include "NativeClientReturnedRecord.hpp" #include "NativeClientReturnedRecord.hpp"
namespace djinni_generated { namespace djinni_generated {
...@@ -45,5 +46,23 @@ std::string NativeClientInterface::JavaProxy::return_str() { ...@@ -45,5 +46,23 @@ std::string NativeClientInterface::JavaProxy::return_str() {
::djinni::jniExceptionCheck(jniEnv); ::djinni::jniExceptionCheck(jniEnv);
return ::djinni::String::toCpp(jniEnv, jret); return ::djinni::String::toCpp(jniEnv, jret);
} }
std::string NativeClientInterface::JavaProxy::meth_taking_interface(const std::shared_ptr<::testsuite::ClientInterface> & c_i) {
auto jniEnv = ::djinni::jniGetThreadEnv();
::djinni::JniLocalScope jscope(jniEnv, 10);
const auto& data = ::djinni::JniClass<::djinni_generated::NativeClientInterface>::get();
auto jret = (jstring)jniEnv->CallObjectMethod(Handle::get().get(), data.method_methTakingInterface,
::djinni::get(::djinni_generated::NativeClientInterface::fromCpp(jniEnv, c_i)));
::djinni::jniExceptionCheck(jniEnv);
return ::djinni::String::toCpp(jniEnv, jret);
}
std::string NativeClientInterface::JavaProxy::meth_taking_optional_interface(const std::shared_ptr<::testsuite::ClientInterface> & c_i) {
auto jniEnv = ::djinni::jniGetThreadEnv();
::djinni::JniLocalScope jscope(jniEnv, 10);
const auto& data = ::djinni::JniClass<::djinni_generated::NativeClientInterface>::get();
auto jret = (jstring)jniEnv->CallObjectMethod(Handle::get().get(), data.method_methTakingOptionalInterface,
::djinni::get(::djinni::Optional<std::experimental::optional, ::djinni_generated::NativeClientInterface>::fromCpp(jniEnv, c_i)));
::djinni::jniExceptionCheck(jniEnv);
return ::djinni::String::toCpp(jniEnv, jret);
}
} // namespace djinni_generated } // namespace djinni_generated
...@@ -11,6 +11,7 @@ namespace djinni_generated { ...@@ -11,6 +11,7 @@ namespace djinni_generated {
class NativeClientInterface final : ::djinni::JniInterface<::testsuite::ClientInterface, NativeClientInterface> { class NativeClientInterface final : ::djinni::JniInterface<::testsuite::ClientInterface, NativeClientInterface> {
public: public:
using CppType = std::shared_ptr<::testsuite::ClientInterface>; using CppType = std::shared_ptr<::testsuite::ClientInterface>;
using CppOptType = std::shared_ptr<::testsuite::ClientInterface>;
using JniType = jobject; using JniType = jobject;
using Boxed = NativeClientInterface; using Boxed = NativeClientInterface;
...@@ -18,7 +19,8 @@ public: ...@@ -18,7 +19,8 @@ public:
~NativeClientInterface(); ~NativeClientInterface();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeClientInterface>::get()._fromJava(jniEnv, j); } static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeClientInterface>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return {jniEnv, ::djinni::JniClass<NativeClientInterface>::get()._toJava(jniEnv, c)}; } static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeClientInterface>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private: private:
NativeClientInterface(); NativeClientInterface();
...@@ -34,6 +36,8 @@ private: ...@@ -34,6 +36,8 @@ private:
::testsuite::ClientReturnedRecord get_record(int64_t record_id, const std::string & utf8string, const std::experimental::optional<std::string> & misc) override; ::testsuite::ClientReturnedRecord get_record(int64_t record_id, const std::string & utf8string, const std::experimental::optional<std::string> & misc) override;
double identifier_check(const std::vector<uint8_t> & data, int32_t r, int64_t jret) override; double identifier_check(const std::vector<uint8_t> & data, int32_t r, int64_t jret) override;
std::string return_str() override; std::string return_str() override;
std::string meth_taking_interface(const std::shared_ptr<::testsuite::ClientInterface> & i) override;
std::string meth_taking_optional_interface(const std::shared_ptr<::testsuite::ClientInterface> & i) override;
private: private:
friend ::djinni::JniInterface<::testsuite::ClientInterface, ::djinni_generated::NativeClientInterface>; friend ::djinni::JniInterface<::testsuite::ClientInterface, ::djinni_generated::NativeClientInterface>;
...@@ -43,6 +47,8 @@ private: ...@@ -43,6 +47,8 @@ private:
const jmethodID method_getRecord { ::djinni::jniGetMethodID(clazz.get(), "getRecord", "(JLjava/lang/String;Ljava/lang/String;)Lcom/dropbox/djinni/test/ClientReturnedRecord;") }; const jmethodID method_getRecord { ::djinni::jniGetMethodID(clazz.get(), "getRecord", "(JLjava/lang/String;Ljava/lang/String;)Lcom/dropbox/djinni/test/ClientReturnedRecord;") };
const jmethodID method_identifierCheck { ::djinni::jniGetMethodID(clazz.get(), "identifierCheck", "([BIJ)D") }; const jmethodID method_identifierCheck { ::djinni::jniGetMethodID(clazz.get(), "identifierCheck", "([BIJ)D") };
const jmethodID method_returnStr { ::djinni::jniGetMethodID(clazz.get(), "returnStr", "()Ljava/lang/String;") }; const jmethodID method_returnStr { ::djinni::jniGetMethodID(clazz.get(), "returnStr", "()Ljava/lang/String;") };
const jmethodID method_methTakingInterface { ::djinni::jniGetMethodID(clazz.get(), "methTakingInterface", "(Lcom/dropbox/djinni/test/ClientInterface;)Ljava/lang/String;") };
const jmethodID method_methTakingOptionalInterface { ::djinni::jniGetMethodID(clazz.get(), "methTakingOptionalInterface", "(Lcom/dropbox/djinni/test/ClientInterface;)Ljava/lang/String;") };
}; };
} // namespace djinni_generated } // namespace djinni_generated
...@@ -11,6 +11,7 @@ namespace djinni_generated { ...@@ -11,6 +11,7 @@ namespace djinni_generated {
class NativeConstantsInterface final : ::djinni::JniInterface<::testsuite::ConstantsInterface, NativeConstantsInterface> { class NativeConstantsInterface final : ::djinni::JniInterface<::testsuite::ConstantsInterface, NativeConstantsInterface> {
public: public:
using CppType = std::shared_ptr<::testsuite::ConstantsInterface>; using CppType = std::shared_ptr<::testsuite::ConstantsInterface>;
using CppOptType = std::shared_ptr<::testsuite::ConstantsInterface>;
using JniType = jobject; using JniType = jobject;
using Boxed = NativeConstantsInterface; using Boxed = NativeConstantsInterface;
...@@ -18,7 +19,8 @@ public: ...@@ -18,7 +19,8 @@ public:
~NativeConstantsInterface(); ~NativeConstantsInterface();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeConstantsInterface>::get()._fromJava(jniEnv, j); } static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeConstantsInterface>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return {jniEnv, ::djinni::JniClass<NativeConstantsInterface>::get()._toJava(jniEnv, c)}; } static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeConstantsInterface>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private: private:
NativeConstantsInterface(); NativeConstantsInterface();
......
...@@ -11,6 +11,7 @@ namespace djinni_generated { ...@@ -11,6 +11,7 @@ namespace djinni_generated {
class NativeCppException final : ::djinni::JniInterface<::testsuite::CppException, NativeCppException> { class NativeCppException final : ::djinni::JniInterface<::testsuite::CppException, NativeCppException> {
public: public:
using CppType = std::shared_ptr<::testsuite::CppException>; using CppType = std::shared_ptr<::testsuite::CppException>;
using CppOptType = std::shared_ptr<::testsuite::CppException>;
using JniType = jobject; using JniType = jobject;
using Boxed = NativeCppException; using Boxed = NativeCppException;
...@@ -18,7 +19,8 @@ public: ...@@ -18,7 +19,8 @@ public:
~NativeCppException(); ~NativeCppException();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeCppException>::get()._fromJava(jniEnv, j); } static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeCppException>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return {jniEnv, ::djinni::JniClass<NativeCppException>::get()._toJava(jniEnv, c)}; } static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeCppException>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private: private:
NativeCppException(); NativeCppException();
......
...@@ -11,6 +11,7 @@ namespace djinni_generated { ...@@ -11,6 +11,7 @@ namespace djinni_generated {
class NativeExternInterface1 final : ::djinni::JniInterface<::ExternInterface1, NativeExternInterface1> { class NativeExternInterface1 final : ::djinni::JniInterface<::ExternInterface1, NativeExternInterface1> {
public: public:
using CppType = std::shared_ptr<::ExternInterface1>; using CppType = std::shared_ptr<::ExternInterface1>;
using CppOptType = std::shared_ptr<::ExternInterface1>;
using JniType = jobject; using JniType = jobject;
using Boxed = NativeExternInterface1; using Boxed = NativeExternInterface1;
...@@ -18,7 +19,8 @@ public: ...@@ -18,7 +19,8 @@ public:
~NativeExternInterface1(); ~NativeExternInterface1();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeExternInterface1>::get()._fromJava(jniEnv, j); } static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeExternInterface1>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return {jniEnv, ::djinni::JniClass<NativeExternInterface1>::get()._toJava(jniEnv, c)}; } static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeExternInterface1>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private: private:
NativeExternInterface1(); NativeExternInterface1();
......
...@@ -11,6 +11,7 @@ namespace djinni_generated { ...@@ -11,6 +11,7 @@ namespace djinni_generated {
class NativeExternInterface2 final : ::djinni::JniInterface<::ExternInterface2, NativeExternInterface2> { class NativeExternInterface2 final : ::djinni::JniInterface<::ExternInterface2, NativeExternInterface2> {
public: public:
using CppType = std::shared_ptr<::ExternInterface2>; using CppType = std::shared_ptr<::ExternInterface2>;
using CppOptType = std::shared_ptr<::ExternInterface2>;
using JniType = jobject; using JniType = jobject;
using Boxed = NativeExternInterface2; using Boxed = NativeExternInterface2;
...@@ -18,7 +19,8 @@ public: ...@@ -18,7 +19,8 @@ public:
~NativeExternInterface2(); ~NativeExternInterface2();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeExternInterface2>::get()._fromJava(jniEnv, j); } static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeExternInterface2>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return {jniEnv, ::djinni::JniClass<NativeExternInterface2>::get()._toJava(jniEnv, c)}; } static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeExternInterface2>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private: private:
NativeExternInterface2(); NativeExternInterface2();
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from client_interface.djinni
#include "NativeReverseClientInterface.hpp" // my header
#include "Marshal.hpp"
#include "NativeReverseClientInterface.hpp"
namespace djinni_generated {
NativeReverseClientInterface::NativeReverseClientInterface() : ::djinni::JniInterface<::testsuite::ReverseClientInterface, NativeReverseClientInterface>("com/dropbox/djinni/test/ReverseClientInterface$CppProxy") {}
NativeReverseClientInterface::~NativeReverseClientInterface() = default;
CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_ReverseClientInterface_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
delete reinterpret_cast<djinni::CppProxyHandle<::testsuite::ReverseClientInterface>*>(nativeRef);
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
}
CJNIEXPORT jstring JNICALL Java_com_dropbox_djinni_test_ReverseClientInterface_00024CppProxy_native_1returnStr(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::ReverseClientInterface>(nativeRef);
auto r = ref->return_str();
return ::djinni::release(::djinni::String::fromCpp(jniEnv, r));
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */)
}
CJNIEXPORT jstring JNICALL Java_com_dropbox_djinni_test_ReverseClientInterface_00024CppProxy_native_1methTakingInterface(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_i)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::ReverseClientInterface>(nativeRef);
auto r = ref->meth_taking_interface(::djinni_generated::NativeReverseClientInterface::toCpp(jniEnv, j_i));
return ::djinni::release(::djinni::String::fromCpp(jniEnv, r));
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */)
}
CJNIEXPORT jstring JNICALL Java_com_dropbox_djinni_test_ReverseClientInterface_00024CppProxy_native_1methTakingOptionalInterface(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_i)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::ReverseClientInterface>(nativeRef);
auto r = ref->meth_taking_optional_interface(::djinni::Optional<std::experimental::optional, ::djinni_generated::NativeReverseClientInterface>::toCpp(jniEnv, j_i));
return ::djinni::release(::djinni::String::fromCpp(jniEnv, r));
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */)
}
CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_ReverseClientInterface_create(JNIEnv* jniEnv, jobject /*this*/)
{
try {
DJINNI_FUNCTION_PROLOGUE0(jniEnv);
auto r = ::testsuite::ReverseClientInterface::create();
return ::djinni::release(::djinni_generated::NativeReverseClientInterface::fromCpp(jniEnv, r));
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */)
}
} // namespace djinni_generated
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from client_interface.djinni
#pragma once
#include "djinni_support.hpp"
#include "reverse_client_interface.hpp"
namespace djinni_generated {
class NativeReverseClientInterface final : ::djinni::JniInterface<::testsuite::ReverseClientInterface, NativeReverseClientInterface> {
public:
using CppType = std::shared_ptr<::testsuite::ReverseClientInterface>;
using CppOptType = std::shared_ptr<::testsuite::ReverseClientInterface>;
using JniType = jobject;
using Boxed = NativeReverseClientInterface;
~NativeReverseClientInterface();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeReverseClientInterface>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeReverseClientInterface>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private:
NativeReverseClientInterface();
friend ::djinni::JniClass<NativeReverseClientInterface>;
friend ::djinni::JniInterface<::testsuite::ReverseClientInterface, NativeReverseClientInterface>;
};
} // namespace djinni_generated
...@@ -11,6 +11,7 @@ namespace djinni_generated { ...@@ -11,6 +11,7 @@ namespace djinni_generated {
class NativeTestDuration final : ::djinni::JniInterface<::testsuite::TestDuration, NativeTestDuration> { class NativeTestDuration final : ::djinni::JniInterface<::testsuite::TestDuration, NativeTestDuration> {
public: public:
using CppType = std::shared_ptr<::testsuite::TestDuration>; using CppType = std::shared_ptr<::testsuite::TestDuration>;
using CppOptType = std::shared_ptr<::testsuite::TestDuration>;
using JniType = jobject; using JniType = jobject;
using Boxed = NativeTestDuration; using Boxed = NativeTestDuration;
...@@ -18,7 +19,8 @@ public: ...@@ -18,7 +19,8 @@ public:
~NativeTestDuration(); ~NativeTestDuration();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeTestDuration>::get()._fromJava(jniEnv, j); } static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeTestDuration>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return {jniEnv, ::djinni::JniClass<NativeTestDuration>::get()._toJava(jniEnv, c)}; } static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeTestDuration>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private: private:
NativeTestDuration(); NativeTestDuration();
......
...@@ -151,6 +151,14 @@ CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_TestHelpers_checkClientInte ...@@ -151,6 +151,14 @@ CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_TestHelpers_checkClientInte
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
} }
CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_TestHelpers_checkClientInterfaceArgs(JNIEnv* jniEnv, jobject /*this*/, jobject j_i)
{
try {
DJINNI_FUNCTION_PROLOGUE0(jniEnv);
::testsuite::TestHelpers::check_client_interface_args(::djinni_generated::NativeClientInterface::toCpp(jniEnv, j_i));
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
}
CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_TestHelpers_checkEnumMap(JNIEnv* jniEnv, jobject /*this*/, jobject j_m) CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_TestHelpers_checkEnumMap(JNIEnv* jniEnv, jobject /*this*/, jobject j_m)
{ {
try { try {
......
...@@ -11,6 +11,7 @@ namespace djinni_generated { ...@@ -11,6 +11,7 @@ namespace djinni_generated {
class NativeTestHelpers final : ::djinni::JniInterface<::testsuite::TestHelpers, NativeTestHelpers> { class NativeTestHelpers final : ::djinni::JniInterface<::testsuite::TestHelpers, NativeTestHelpers> {
public: public:
using CppType = std::shared_ptr<::testsuite::TestHelpers>; using CppType = std::shared_ptr<::testsuite::TestHelpers>;
using CppOptType = std::shared_ptr<::testsuite::TestHelpers>;
using JniType = jobject; using JniType = jobject;
using Boxed = NativeTestHelpers; using Boxed = NativeTestHelpers;
...@@ -18,7 +19,8 @@ public: ...@@ -18,7 +19,8 @@ public:
~NativeTestHelpers(); ~NativeTestHelpers();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeTestHelpers>::get()._fromJava(jniEnv, j); } static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeTestHelpers>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return {jniEnv, ::djinni::JniClass<NativeTestHelpers>::get()._toJava(jniEnv, c)}; } static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeTestHelpers>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private: private:
NativeTestHelpers(); NativeTestHelpers();
......
...@@ -11,6 +11,7 @@ namespace djinni_generated { ...@@ -11,6 +11,7 @@ namespace djinni_generated {
class NativeUserToken final : ::djinni::JniInterface<::testsuite::UserToken, NativeUserToken> { class NativeUserToken final : ::djinni::JniInterface<::testsuite::UserToken, NativeUserToken> {
public: public:
using CppType = std::shared_ptr<::testsuite::UserToken>; using CppType = std::shared_ptr<::testsuite::UserToken>;
using CppOptType = std::shared_ptr<::testsuite::UserToken>;
using JniType = jobject; using JniType = jobject;
using Boxed = NativeUserToken; using Boxed = NativeUserToken;
...@@ -18,7 +19,8 @@ public: ...@@ -18,7 +19,8 @@ public:
~NativeUserToken(); ~NativeUserToken();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeUserToken>::get()._fromJava(jniEnv, j); } static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeUserToken>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return {jniEnv, ::djinni::JniClass<NativeUserToken>::get()._toJava(jniEnv, c)}; } static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeUserToken>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private: private:
NativeUserToken(); NativeUserToken();
......
...@@ -14,12 +14,14 @@ class ClientInterface ...@@ -14,12 +14,14 @@ class ClientInterface
{ {
public: public:
using CppType = std::shared_ptr<::testsuite::ClientInterface>; using CppType = std::shared_ptr<::testsuite::ClientInterface>;
using CppOptType = std::shared_ptr<::testsuite::ClientInterface>;
using ObjcType = id<DBClientInterface>; using ObjcType = id<DBClientInterface>;
using Boxed = ClientInterface; using Boxed = ClientInterface;
static CppType toCpp(ObjcType objc); static CppType toCpp(ObjcType objc);
static ObjcType fromCpp(const CppType& cpp); static ObjcType fromCppOpt(const CppOptType& cpp);
static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }
private: private:
class ObjcProxy; class ObjcProxy;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#import "DBClientInterface+Private.h" #import "DBClientInterface+Private.h"
#import "DBClientInterface.h" #import "DBClientInterface.h"
#import "DBClientInterface+Private.h"
#import "DBClientReturnedRecord+Private.h" #import "DBClientReturnedRecord+Private.h"
#import "DJIMarshal+Private.h" #import "DJIMarshal+Private.h"
#import "DJIObjcWrapperCache+Private.h" #import "DJIObjcWrapperCache+Private.h"
...@@ -42,6 +43,20 @@ public: ...@@ -42,6 +43,20 @@ public:
return ::djinni::String::toCpp(r); return ::djinni::String::toCpp(r);
} }
} }
std::string meth_taking_interface(const std::shared_ptr<::testsuite::ClientInterface> & c_i) override
{
@autoreleasepool {
auto r = [Handle::get() methTakingInterface:(::djinni_generated::ClientInterface::fromCpp(c_i))];
return ::djinni::String::toCpp(r);
}
}
std::string meth_taking_optional_interface(const std::shared_ptr<::testsuite::ClientInterface> & c_i) override
{
@autoreleasepool {
auto r = [Handle::get() methTakingOptionalInterface:(::djinni::Optional<std::experimental::optional, ::djinni_generated::ClientInterface>::fromCpp(c_i))];
return ::djinni::String::toCpp(r);
}
}
}; };
} // namespace djinni_generated } // namespace djinni_generated
...@@ -56,7 +71,7 @@ auto ClientInterface::toCpp(ObjcType objc) -> CppType ...@@ -56,7 +71,7 @@ auto ClientInterface::toCpp(ObjcType objc) -> CppType
return ::djinni::get_objc_proxy<ObjcProxy>(objc); return ::djinni::get_objc_proxy<ObjcProxy>(objc);
} }
auto ClientInterface::fromCpp(const CppType& cpp) -> ObjcType auto ClientInterface::fromCppOpt(const CppOptType& cpp) -> ObjcType
{ {
if (!cpp) { if (!cpp) {
return nil; return nil;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#import "DBClientReturnedRecord.h" #import "DBClientReturnedRecord.h"
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@protocol DBClientInterface;
/** Client interface */ /** Client interface */
...@@ -19,4 +20,8 @@ ...@@ -19,4 +20,8 @@
- (nonnull NSString *)returnStr; - (nonnull NSString *)returnStr;
- (nonnull NSString *)methTakingInterface:(nullable id<DBClientInterface>)i;
- (nonnull NSString *)methTakingOptionalInterface:(nullable id<DBClientInterface>)i;
@end @end
...@@ -14,12 +14,14 @@ class ConstantsInterface ...@@ -14,12 +14,14 @@ class ConstantsInterface
{ {
public: public:
using CppType = std::shared_ptr<::testsuite::ConstantsInterface>; using CppType = std::shared_ptr<::testsuite::ConstantsInterface>;
using CppOptType = std::shared_ptr<::testsuite::ConstantsInterface>;
using ObjcType = DBConstantsInterface*; using ObjcType = DBConstantsInterface*;
using Boxed = ConstantsInterface; using Boxed = ConstantsInterface;
static CppType toCpp(ObjcType objc); static CppType toCpp(ObjcType objc);
static ObjcType fromCpp(const CppType& cpp); static ObjcType fromCppOpt(const CppOptType& cpp);
static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }
private: private:
class ObjcProxy; class ObjcProxy;
......
...@@ -45,7 +45,7 @@ auto ConstantsInterface::toCpp(ObjcType objc) -> CppType ...@@ -45,7 +45,7 @@ auto ConstantsInterface::toCpp(ObjcType objc) -> CppType
return objc->_cppRefHandle.get(); return objc->_cppRefHandle.get();
} }
auto ConstantsInterface::fromCpp(const CppType& cpp) -> ObjcType auto ConstantsInterface::fromCppOpt(const CppOptType& cpp) -> ObjcType
{ {
if (!cpp) { if (!cpp) {
return nil; return nil;
......
...@@ -14,12 +14,14 @@ class CppException ...@@ -14,12 +14,14 @@ class CppException
{ {
public: public:
using CppType = std::shared_ptr<::testsuite::CppException>; using CppType = std::shared_ptr<::testsuite::CppException>;
using CppOptType = std::shared_ptr<::testsuite::CppException>;
using ObjcType = DBCppException*; using ObjcType = DBCppException*;
using Boxed = CppException; using Boxed = CppException;
static CppType toCpp(ObjcType objc); static CppType toCpp(ObjcType objc);
static ObjcType fromCpp(const CppType& cpp); static ObjcType fromCppOpt(const CppOptType& cpp);
static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }
private: private:
class ObjcProxy; class ObjcProxy;
......
...@@ -54,7 +54,7 @@ auto CppException::toCpp(ObjcType objc) -> CppType ...@@ -54,7 +54,7 @@ auto CppException::toCpp(ObjcType objc) -> CppType
return objc->_cppRefHandle.get(); return objc->_cppRefHandle.get();
} }
auto CppException::fromCpp(const CppType& cpp) -> ObjcType auto CppException::fromCppOpt(const CppOptType& cpp) -> ObjcType
{ {
if (!cpp) { if (!cpp) {
return nil; return nil;
......
...@@ -14,12 +14,14 @@ class ExternInterface1 ...@@ -14,12 +14,14 @@ class ExternInterface1
{ {
public: public:
using CppType = std::shared_ptr<::ExternInterface1>; using CppType = std::shared_ptr<::ExternInterface1>;
using CppOptType = std::shared_ptr<::ExternInterface1>;
using ObjcType = DBExternInterface1*; using ObjcType = DBExternInterface1*;
using Boxed = ExternInterface1; using Boxed = ExternInterface1;
static CppType toCpp(ObjcType objc); static CppType toCpp(ObjcType objc);
static ObjcType fromCpp(const CppType& cpp); static ObjcType fromCppOpt(const CppOptType& cpp);
static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }
private: private:
class ObjcProxy; class ObjcProxy;
......
...@@ -47,7 +47,7 @@ auto ExternInterface1::toCpp(ObjcType objc) -> CppType ...@@ -47,7 +47,7 @@ auto ExternInterface1::toCpp(ObjcType objc) -> CppType
return objc->_cppRefHandle.get(); return objc->_cppRefHandle.get();
} }
auto ExternInterface1::fromCpp(const CppType& cpp) -> ObjcType auto ExternInterface1::fromCppOpt(const CppOptType& cpp) -> ObjcType
{ {
if (!cpp) { if (!cpp) {
return nil; return nil;
......
...@@ -14,12 +14,14 @@ class ExternInterface2 ...@@ -14,12 +14,14 @@ class ExternInterface2
{ {
public: public:
using CppType = std::shared_ptr<::ExternInterface2>; using CppType = std::shared_ptr<::ExternInterface2>;
using CppOptType = std::shared_ptr<::ExternInterface2>;
using ObjcType = id<DBExternInterface2>; using ObjcType = id<DBExternInterface2>;
using Boxed = ExternInterface2; using Boxed = ExternInterface2;
static CppType toCpp(ObjcType objc); static CppType toCpp(ObjcType objc);
static ObjcType fromCpp(const CppType& cpp); static ObjcType fromCppOpt(const CppOptType& cpp);
static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }
private: private:
class ObjcProxy; class ObjcProxy;
......
...@@ -38,7 +38,7 @@ auto ExternInterface2::toCpp(ObjcType objc) -> CppType ...@@ -38,7 +38,7 @@ auto ExternInterface2::toCpp(ObjcType objc) -> CppType
return ::djinni::get_objc_proxy<ObjcProxy>(objc); return ::djinni::get_objc_proxy<ObjcProxy>(objc);
} }
auto ExternInterface2::fromCpp(const CppType& cpp) -> ObjcType auto ExternInterface2::fromCppOpt(const CppOptType& cpp) -> ObjcType
{ {
if (!cpp) { if (!cpp) {
return nil; return nil;
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from client_interface.djinni
#include "reverse_client_interface.hpp"
#include <memory>
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
@class DBReverseClientInterface;
namespace djinni_generated {
class ReverseClientInterface
{
public:
using CppType = std::shared_ptr<::testsuite::ReverseClientInterface>;
using CppOptType = std::shared_ptr<::testsuite::ReverseClientInterface>;
using ObjcType = DBReverseClientInterface*;
using Boxed = ReverseClientInterface;
static CppType toCpp(ObjcType objc);
static ObjcType fromCppOpt(const CppOptType& cpp);
static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }
private:
class ObjcProxy;
};
} // namespace djinni_generated
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from client_interface.djinni
#import "DBReverseClientInterface+Private.h"
#import "DBReverseClientInterface.h"
#import "DBReverseClientInterface+Private.h"
#import "DJICppWrapperCache+Private.h"
#import "DJIError.h"
#import "DJIMarshal+Private.h"
#include <exception>
#include <utility>
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
@interface DBReverseClientInterface ()
- (id)initWithCpp:(const std::shared_ptr<::testsuite::ReverseClientInterface>&)cppRef;
@end
@implementation DBReverseClientInterface {
::djinni::CppProxyCache::Handle<std::shared_ptr<::testsuite::ReverseClientInterface>> _cppRefHandle;
}
- (id)initWithCpp:(const std::shared_ptr<::testsuite::ReverseClientInterface>&)cppRef
{
if (self = [super init]) {
_cppRefHandle.assign(cppRef);
}
return self;
}
- (nonnull NSString *)returnStr {
try {
auto r = _cppRefHandle.get()->return_str();
return ::djinni::String::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
- (nonnull NSString *)methTakingInterface:(nullable DBReverseClientInterface *)i {
try {
auto r = _cppRefHandle.get()->meth_taking_interface(::djinni_generated::ReverseClientInterface::toCpp(i));
return ::djinni::String::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
- (nonnull NSString *)methTakingOptionalInterface:(nullable DBReverseClientInterface *)i {
try {
auto r = _cppRefHandle.get()->meth_taking_optional_interface(::djinni::Optional<std::experimental::optional, ::djinni_generated::ReverseClientInterface>::toCpp(i));
return ::djinni::String::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (nullable DBReverseClientInterface *)create {
try {
auto r = ::testsuite::ReverseClientInterface::create();
return ::djinni_generated::ReverseClientInterface::fromCpp(r);
} DJINNI_TRANSLATE_EXCEPTIONS()
}
namespace djinni_generated {
auto ReverseClientInterface::toCpp(ObjcType objc) -> CppType
{
if (!objc) {
return nullptr;
}
return objc->_cppRefHandle.get();
}
auto ReverseClientInterface::fromCppOpt(const CppOptType& cpp) -> ObjcType
{
if (!cpp) {
return nil;
}
return ::djinni::get_cpp_proxy<DBReverseClientInterface>(cpp);
}
} // namespace djinni_generated
@end
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from client_interface.djinni
#import <Foundation/Foundation.h>
@class DBReverseClientInterface;
@interface DBReverseClientInterface : NSObject
- (nonnull NSString *)returnStr;
- (nonnull NSString *)methTakingInterface:(nullable DBReverseClientInterface *)i;
- (nonnull NSString *)methTakingOptionalInterface:(nullable DBReverseClientInterface *)i;
+ (nullable DBReverseClientInterface *)create;
@end
...@@ -14,12 +14,14 @@ class TestDuration ...@@ -14,12 +14,14 @@ class TestDuration
{ {
public: public:
using CppType = std::shared_ptr<::testsuite::TestDuration>; using CppType = std::shared_ptr<::testsuite::TestDuration>;
using CppOptType = std::shared_ptr<::testsuite::TestDuration>;
using ObjcType = DBTestDuration*; using ObjcType = DBTestDuration*;
using Boxed = TestDuration; using Boxed = TestDuration;
static CppType toCpp(ObjcType objc); static CppType toCpp(ObjcType objc);
static ObjcType fromCpp(const CppType& cpp); static ObjcType fromCppOpt(const CppOptType& cpp);
static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }
private: private:
class ObjcProxy; class ObjcProxy;
......
...@@ -180,7 +180,7 @@ auto TestDuration::toCpp(ObjcType objc) -> CppType ...@@ -180,7 +180,7 @@ auto TestDuration::toCpp(ObjcType objc) -> CppType
return objc->_cppRefHandle.get(); return objc->_cppRefHandle.get();
} }
auto TestDuration::fromCpp(const CppType& cpp) -> ObjcType auto TestDuration::fromCppOpt(const CppOptType& cpp) -> ObjcType
{ {
if (!cpp) { if (!cpp) {
return nil; return nil;
......
...@@ -14,12 +14,14 @@ class TestHelpers ...@@ -14,12 +14,14 @@ class TestHelpers
{ {
public: public:
using CppType = std::shared_ptr<::testsuite::TestHelpers>; using CppType = std::shared_ptr<::testsuite::TestHelpers>;
using CppOptType = std::shared_ptr<::testsuite::TestHelpers>;
using ObjcType = DBTestHelpers*; using ObjcType = DBTestHelpers*;
using Boxed = TestHelpers; using Boxed = TestHelpers;
static CppType toCpp(ObjcType objc); static CppType toCpp(ObjcType objc);
static ObjcType fromCpp(const CppType& cpp); static ObjcType fromCppOpt(const CppOptType& cpp);
static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }
private: private:
class ObjcProxy; class ObjcProxy;
......
...@@ -132,6 +132,12 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th ...@@ -132,6 +132,12 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
+ (void)checkClientInterfaceArgs:(nullable id<DBClientInterface>)i {
try {
::testsuite::TestHelpers::check_client_interface_args(::djinni_generated::ClientInterface::toCpp(i));
} DJINNI_TRANSLATE_EXCEPTIONS()
}
+ (void)checkEnumMap:(nonnull NSDictionary<NSNumber *, NSString *> *)m { + (void)checkEnumMap:(nonnull NSDictionary<NSNumber *, NSString *> *)m {
try { try {
::testsuite::TestHelpers::check_enum_map(::djinni::Map<::djinni::Enum<::testsuite::color, DBColor>, ::djinni::String>::toCpp(m)); ::testsuite::TestHelpers::check_enum_map(::djinni::Map<::djinni::Enum<::testsuite::color, DBColor>, ::djinni::String>::toCpp(m));
...@@ -210,7 +216,7 @@ auto TestHelpers::toCpp(ObjcType objc) -> CppType ...@@ -210,7 +216,7 @@ auto TestHelpers::toCpp(ObjcType objc) -> CppType
return objc->_cppRefHandle.get(); return objc->_cppRefHandle.get();
} }
auto TestHelpers::fromCpp(const CppType& cpp) -> ObjcType auto TestHelpers::fromCppOpt(const CppOptType& cpp) -> ObjcType
{ {
if (!cpp) { if (!cpp) {
return nil; return nil;
......
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
+ (void)checkClientInterfaceNonascii:(nullable id<DBClientInterface>)i; + (void)checkClientInterfaceNonascii:(nullable id<DBClientInterface>)i;
+ (void)checkClientInterfaceArgs:(nullable id<DBClientInterface>)i;
+ (void)checkEnumMap:(nonnull NSDictionary<NSNumber *, NSString *> *)m; + (void)checkEnumMap:(nonnull NSDictionary<NSNumber *, NSString *> *)m;
+ (void)checkEnum:(DBColor)c; + (void)checkEnum:(DBColor)c;
......
...@@ -14,12 +14,14 @@ class UserToken ...@@ -14,12 +14,14 @@ class UserToken
{ {
public: public:
using CppType = std::shared_ptr<::testsuite::UserToken>; using CppType = std::shared_ptr<::testsuite::UserToken>;
using CppOptType = std::shared_ptr<::testsuite::UserToken>;
using ObjcType = id<DBUserToken>; using ObjcType = id<DBUserToken>;
using Boxed = UserToken; using Boxed = UserToken;
static CppType toCpp(ObjcType objc); static CppType toCpp(ObjcType objc);
static ObjcType fromCpp(const CppType& cpp); static ObjcType fromCppOpt(const CppOptType& cpp);
static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }
private: private:
class ObjcProxy; class ObjcProxy;
......
...@@ -69,7 +69,7 @@ auto UserToken::toCpp(ObjcType objc) -> CppType ...@@ -69,7 +69,7 @@ auto UserToken::toCpp(ObjcType objc) -> CppType
return ::djinni::get_objc_proxy<ObjcProxy>(objc); return ::djinni::get_objc_proxy<ObjcProxy>(objc);
} }
auto UserToken::fromCpp(const CppType& cpp) -> ObjcType auto UserToken::fromCppOpt(const CppOptType& cpp) -> ObjcType
{ {
if (!cpp) { if (!cpp) {
return nil; return nil;
......
...@@ -17,6 +17,7 @@ djinni-output-temp/cpp/color.hpp ...@@ -17,6 +17,7 @@ djinni-output-temp/cpp/color.hpp
djinni-output-temp/cpp/opt_color_record.hpp djinni-output-temp/cpp/opt_color_record.hpp
djinni-output-temp/cpp/client_returned_record.hpp djinni-output-temp/cpp/client_returned_record.hpp
djinni-output-temp/cpp/client_interface.hpp djinni-output-temp/cpp/client_interface.hpp
djinni-output-temp/cpp/reverse_client_interface.hpp
djinni-output-temp/cpp/cpp_exception.hpp djinni-output-temp/cpp/cpp_exception.hpp
djinni-output-temp/cpp/primitive_list.hpp djinni-output-temp/cpp/primitive_list.hpp
djinni-output-temp/cpp/map_record.hpp djinni-output-temp/cpp/map_record.hpp
...@@ -41,6 +42,7 @@ djinni-output-temp/java/Color.java ...@@ -41,6 +42,7 @@ djinni-output-temp/java/Color.java
djinni-output-temp/java/OptColorRecord.java djinni-output-temp/java/OptColorRecord.java
djinni-output-temp/java/ClientReturnedRecord.java djinni-output-temp/java/ClientReturnedRecord.java
djinni-output-temp/java/ClientInterface.java djinni-output-temp/java/ClientInterface.java
djinni-output-temp/java/ReverseClientInterface.java
djinni-output-temp/java/CppException.java djinni-output-temp/java/CppException.java
djinni-output-temp/java/PrimitiveList.java djinni-output-temp/java/PrimitiveList.java
djinni-output-temp/java/MapRecord.java djinni-output-temp/java/MapRecord.java
...@@ -76,6 +78,8 @@ djinni-output-temp/jni/NativeClientReturnedRecord.hpp ...@@ -76,6 +78,8 @@ djinni-output-temp/jni/NativeClientReturnedRecord.hpp
djinni-output-temp/jni/NativeClientReturnedRecord.cpp djinni-output-temp/jni/NativeClientReturnedRecord.cpp
djinni-output-temp/jni/NativeClientInterface.hpp djinni-output-temp/jni/NativeClientInterface.hpp
djinni-output-temp/jni/NativeClientInterface.cpp djinni-output-temp/jni/NativeClientInterface.cpp
djinni-output-temp/jni/NativeReverseClientInterface.hpp
djinni-output-temp/jni/NativeReverseClientInterface.cpp
djinni-output-temp/jni/NativeCppException.hpp djinni-output-temp/jni/NativeCppException.hpp
djinni-output-temp/jni/NativeCppException.cpp djinni-output-temp/jni/NativeCppException.cpp
djinni-output-temp/jni/NativePrimitiveList.hpp djinni-output-temp/jni/NativePrimitiveList.hpp
...@@ -115,6 +119,7 @@ djinni-output-temp/objc/DBOptColorRecord.mm ...@@ -115,6 +119,7 @@ djinni-output-temp/objc/DBOptColorRecord.mm
djinni-output-temp/objc/DBClientReturnedRecord.h djinni-output-temp/objc/DBClientReturnedRecord.h
djinni-output-temp/objc/DBClientReturnedRecord.mm djinni-output-temp/objc/DBClientReturnedRecord.mm
djinni-output-temp/objc/DBClientInterface.h djinni-output-temp/objc/DBClientInterface.h
djinni-output-temp/objc/DBReverseClientInterface.h
djinni-output-temp/objc/DBCppException.h djinni-output-temp/objc/DBCppException.h
djinni-output-temp/objc/DBPrimitiveList.h djinni-output-temp/objc/DBPrimitiveList.h
djinni-output-temp/objc/DBPrimitiveList.mm djinni-output-temp/objc/DBPrimitiveList.mm
...@@ -156,6 +161,8 @@ djinni-output-temp/objc/DBClientReturnedRecord+Private.h ...@@ -156,6 +161,8 @@ djinni-output-temp/objc/DBClientReturnedRecord+Private.h
djinni-output-temp/objc/DBClientReturnedRecord+Private.mm djinni-output-temp/objc/DBClientReturnedRecord+Private.mm
djinni-output-temp/objc/DBClientInterface+Private.h djinni-output-temp/objc/DBClientInterface+Private.h
djinni-output-temp/objc/DBClientInterface+Private.mm djinni-output-temp/objc/DBClientInterface+Private.mm
djinni-output-temp/objc/DBReverseClientInterface+Private.h
djinni-output-temp/objc/DBReverseClientInterface+Private.mm
djinni-output-temp/objc/DBCppException+Private.h djinni-output-temp/objc/DBCppException+Private.h
djinni-output-temp/objc/DBCppException+Private.mm djinni-output-temp/objc/DBCppException+Private.mm
djinni-output-temp/objc/DBPrimitiveList+Private.h djinni-output-temp/objc/DBPrimitiveList+Private.h
......
#include "reverse_client_interface_impl.hpp"
namespace testsuite {
std::string ReverseClientInterfaceImpl::return_str() {
return "test";
}
std::string ReverseClientInterfaceImpl::meth_taking_interface(const std::shared_ptr<ReverseClientInterface> & i) {
if (i) {
return i->return_str();
} else {
return {};
}
}
std::string ReverseClientInterfaceImpl::meth_taking_optional_interface(const std::shared_ptr<ReverseClientInterface> & i) {
if (i) {
return i->return_str();
} else {
return {};
}
}
std::shared_ptr<ReverseClientInterface> ReverseClientInterface::create() {
return std::make_shared<ReverseClientInterfaceImpl>();
}
} // namespace testsuite
#include "reverse_client_interface.hpp"
namespace testsuite {
class ReverseClientInterfaceImpl : public ReverseClientInterface {
public:
ReverseClientInterfaceImpl() {}
virtual ~ReverseClientInterfaceImpl() {}
virtual std::string return_str() override;
virtual std::string meth_taking_interface(const std::shared_ptr<ReverseClientInterface> & i) override;
virtual std::string meth_taking_optional_interface(const std::shared_ptr<ReverseClientInterface> & i) override;
static std::shared_ptr<ReverseClientInterface> create();
};
} // namespace testsuite
...@@ -94,6 +94,20 @@ void TestHelpers::check_client_interface_nonascii(const std::shared_ptr<ClientIn ...@@ -94,6 +94,20 @@ void TestHelpers::check_client_interface_nonascii(const std::shared_ptr<ClientIn
} }
} }
void TestHelpers::check_client_interface_args(const std::shared_ptr<ClientInterface> & i) {
const std::string returned1 = i->meth_taking_interface(i);
if ("test" != returned1) {
std::string error_msg = "Expected String: 'test' Actual: '" + returned1 + "'";
throw std::invalid_argument(error_msg);
}
const std::string returned2 = i->meth_taking_optional_interface(i);
if ("test" != returned2) {
std::string error_msg = "Expected String: 'test' Actual: '" + returned2 + "'";
throw std::invalid_argument(error_msg);
}
}
std::shared_ptr<UserToken> TestHelpers::token_id(const std::shared_ptr<UserToken> & in) { std::shared_ptr<UserToken> TestHelpers::token_id(const std::shared_ptr<UserToken> & in) {
return in; return in;
} }
......
package com.dropbox.djinni.test; package com.dropbox.djinni.test;
import javax.annotation.CheckForNull;
public class ClientInterfaceImpl extends ClientInterface { public class ClientInterfaceImpl extends ClientInterface {
@Override @Override
public ClientReturnedRecord getRecord(long id, String utf8string, String misc) { public ClientReturnedRecord getRecord(long id, String utf8string, String misc) {
...@@ -17,4 +19,14 @@ public class ClientInterfaceImpl extends ClientInterface { ...@@ -17,4 +19,14 @@ public class ClientInterfaceImpl extends ClientInterface {
public String returnStr() { public String returnStr() {
return "test"; return "test";
} }
@Override
public String methTakingInterface(@CheckForNull ClientInterface i) {
if (i != null) { return i.returnStr(); } else { return ""; }
}
@Override
public String methTakingOptionalInterface(@CheckForNull ClientInterface i) {
if (i != null) { return i.returnStr(); } else { return ""; }
}
} }
...@@ -18,4 +18,15 @@ public class ClientInterfaceTest extends TestCase { ...@@ -18,4 +18,15 @@ public class ClientInterfaceTest extends TestCase {
public void testClientReturnUTF8() { public void testClientReturnUTF8() {
TestHelpers.checkClientInterfaceNonascii(jClientInterface); TestHelpers.checkClientInterfaceNonascii(jClientInterface);
} }
public void testClientInterfaceArgs() {
TestHelpers.checkClientInterfaceArgs(jClientInterface);
}
public void testReverseClientInterfaceArgs() {
ReverseClientInterface i = ReverseClientInterface.create();
assertEquals(i.methTakingInterface(i), "test");
assertEquals(i.methTakingOptionalInterface(i), "test");
}
} }
...@@ -25,4 +25,20 @@ static NSString *DBNonAscii = @"Non-ASCII / 非 ASCII 字符"; ...@@ -25,4 +25,20 @@ static NSString *DBNonAscii = @"Non-ASCII / 非 ASCII 字符";
return @"test"; return @"test";
} }
- (nonnull NSString *)methTakingInterface:(nullable id<DBClientInterface>)i {
if (i) {
return [i returnStr];
} else {
return @"";
}
}
- (nonnull NSString *)methTakingOptionalInterface:(nullable id<DBClientInterface>)i {
if (i) {
return [i returnStr];
} else {
return @"";
}
}
@end @end
#import "DBClientInterfaceImpl.h" #import "DBClientInterfaceImpl.h"
#import "DBClientInterface+Private.h" #import "DBClientInterface+Private.h"
#import "DBReverseClientInterface.h"
#import "DBTestHelpers.h" #import "DBTestHelpers.h"
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
...@@ -31,6 +32,19 @@ using namespace testsuite; ...@@ -31,6 +32,19 @@ using namespace testsuite;
[DBTestHelpers checkClientInterfaceNonascii:[[DBClientInterfaceImpl alloc] init]]; [DBTestHelpers checkClientInterfaceNonascii:[[DBClientInterfaceImpl alloc] init]];
} }
- (void)testClientInterfaceArgs
{
[DBTestHelpers checkClientInterfaceArgs:[[DBClientInterfaceImpl alloc] init]];
}
- (void)testReverseClientInterfaceArgs
{
DBReverseClientInterface * i = [DBReverseClientInterface create];
XCTAssertEqualObjects([i methTakingInterface:i], @"test");
XCTAssertEqualObjects([i methTakingOptionalInterface:i], @"test");
}
- (void)testObjcInterfaceWrapper - (void)testObjcInterfaceWrapper
{ {
__weak id <DBClientInterface> objcClientInterfaceWeak; __weak id <DBClientInterface> objcClientInterfaceWeak;
......
...@@ -60,6 +60,8 @@ ...@@ -60,6 +60,8 @@
B52DA56B1B103F75005CE75F /* DBAssortedPrimitives+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B52DA5671B103F6D005CE75F /* DBAssortedPrimitives+Private.mm */; }; B52DA56B1B103F75005CE75F /* DBAssortedPrimitives+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B52DA5671B103F6D005CE75F /* DBAssortedPrimitives+Private.mm */; };
B52DA56E1B103FC5005CE75F /* assorted_primitives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B52DA56C1B103FBE005CE75F /* assorted_primitives.cpp */; }; B52DA56E1B103FC5005CE75F /* assorted_primitives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B52DA56C1B103FBE005CE75F /* assorted_primitives.cpp */; };
B52DA5701B104025005CE75F /* DBPrimitivesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B52DA56F1B104025005CE75F /* DBPrimitivesTests.m */; }; B52DA5701B104025005CE75F /* DBPrimitivesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B52DA56F1B104025005CE75F /* DBPrimitivesTests.m */; };
B5E9C93B1C1F9D9D0073C123 /* reverse_client_interface_impl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5E9C9391C1F9D9D0073C123 /* reverse_client_interface_impl.cpp */; };
B5E9C9401C1F9E9E0073C123 /* DBReverseClientInterface+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5E9C93F1C1F9E9E0073C123 /* DBReverseClientInterface+Private.mm */; };
CFAED8751B54291900E3B8A3 /* DBEmptyRecord.mm in Sources */ = {isa = PBXBuildFile; fileRef = CFAED8721B54291900E3B8A3 /* DBEmptyRecord.mm */; }; CFAED8751B54291900E3B8A3 /* DBEmptyRecord.mm in Sources */ = {isa = PBXBuildFile; fileRef = CFAED8721B54291900E3B8A3 /* DBEmptyRecord.mm */; };
CFAED8761B54291900E3B8A3 /* DBEmptyRecord+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = CFAED8741B54291900E3B8A3 /* DBEmptyRecord+Private.mm */; }; CFAED8761B54291900E3B8A3 /* DBEmptyRecord+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = CFAED8741B54291900E3B8A3 /* DBEmptyRecord+Private.mm */; };
CFC5D9D01B15105100BF2DF8 /* extern_record_with_derivings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CFC5D9CE1B15105100BF2DF8 /* extern_record_with_derivings.cpp */; }; CFC5D9D01B15105100BF2DF8 /* extern_record_with_derivings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CFC5D9CE1B15105100BF2DF8 /* extern_record_with_derivings.cpp */; };
...@@ -235,6 +237,12 @@ ...@@ -235,6 +237,12 @@
B52DA56C1B103FBE005CE75F /* assorted_primitives.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = assorted_primitives.cpp; sourceTree = "<group>"; }; B52DA56C1B103FBE005CE75F /* assorted_primitives.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = assorted_primitives.cpp; sourceTree = "<group>"; };
B52DA56D1B103FBE005CE75F /* assorted_primitives.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = assorted_primitives.hpp; sourceTree = "<group>"; }; B52DA56D1B103FBE005CE75F /* assorted_primitives.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = assorted_primitives.hpp; sourceTree = "<group>"; };
B52DA56F1B104025005CE75F /* DBPrimitivesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBPrimitivesTests.m; sourceTree = "<group>"; }; B52DA56F1B104025005CE75F /* DBPrimitivesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBPrimitivesTests.m; sourceTree = "<group>"; };
B5E9C9391C1F9D9D0073C123 /* reverse_client_interface_impl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = reverse_client_interface_impl.cpp; sourceTree = "<group>"; };
B5E9C93A1C1F9D9D0073C123 /* reverse_client_interface_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = reverse_client_interface_impl.hpp; sourceTree = "<group>"; };
B5E9C93C1C1F9DCA0073C123 /* reverse_client_interface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = reverse_client_interface.hpp; sourceTree = "<group>"; };
B5E9C93D1C1F9E9E0073C123 /* DBReverseClientInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBReverseClientInterface.h; sourceTree = "<group>"; };
B5E9C93E1C1F9E9E0073C123 /* DBReverseClientInterface+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBReverseClientInterface+Private.h"; sourceTree = "<group>"; };
B5E9C93F1C1F9E9E0073C123 /* DBReverseClientInterface+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBReverseClientInterface+Private.mm"; sourceTree = "<group>"; };
CFAED8711B54291900E3B8A3 /* DBEmptyRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBEmptyRecord.h; sourceTree = "<group>"; }; CFAED8711B54291900E3B8A3 /* DBEmptyRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBEmptyRecord.h; sourceTree = "<group>"; };
CFAED8721B54291900E3B8A3 /* DBEmptyRecord.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBEmptyRecord.mm; sourceTree = "<group>"; }; CFAED8721B54291900E3B8A3 /* DBEmptyRecord.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBEmptyRecord.mm; sourceTree = "<group>"; };
CFAED8731B54291900E3B8A3 /* DBEmptyRecord+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBEmptyRecord+Private.h"; sourceTree = "<group>"; }; CFAED8731B54291900E3B8A3 /* DBEmptyRecord+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBEmptyRecord+Private.h"; sourceTree = "<group>"; };
...@@ -332,6 +340,8 @@ ...@@ -332,6 +340,8 @@
6536CD7519A6C98800DD7715 /* handwritten-cpp */ = { 6536CD7519A6C98800DD7715 /* handwritten-cpp */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
B5E9C9391C1F9D9D0073C123 /* reverse_client_interface_impl.cpp */,
B5E9C93A1C1F9D9D0073C123 /* reverse_client_interface_impl.hpp */,
6536CD7619A6C98800DD7715 /* cpp_exception_impl.cpp */, 6536CD7619A6C98800DD7715 /* cpp_exception_impl.cpp */,
6536CD7719A6C98800DD7715 /* cpp_exception_impl.hpp */, 6536CD7719A6C98800DD7715 /* cpp_exception_impl.hpp */,
CFC5DA101B15B5FB00BF2DF8 /* Duration-jni.hpp */, CFC5DA101B15B5FB00BF2DF8 /* Duration-jni.hpp */,
...@@ -402,6 +412,9 @@ ...@@ -402,6 +412,9 @@
A24249181AF192E0003BF8F0 /* generated-objc */ = { A24249181AF192E0003BF8F0 /* generated-objc */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
B5E9C93D1C1F9E9E0073C123 /* DBReverseClientInterface.h */,
B5E9C93E1C1F9E9E0073C123 /* DBReverseClientInterface+Private.h */,
B5E9C93F1C1F9E9E0073C123 /* DBReverseClientInterface+Private.mm */,
A209B5751BBA2A0A0070C310 /* DBOptColorRecord.h */, A209B5751BBA2A0A0070C310 /* DBOptColorRecord.h */,
A209B5761BBA2A0A0070C310 /* DBOptColorRecord.mm */, A209B5761BBA2A0A0070C310 /* DBOptColorRecord.mm */,
A209B5771BBA2A0A0070C310 /* DBOptColorRecord+Private.h */, A209B5771BBA2A0A0070C310 /* DBOptColorRecord+Private.h */,
...@@ -500,6 +513,7 @@ ...@@ -500,6 +513,7 @@
A242495D1AF192FC003BF8F0 /* generated-cpp */ = { A242495D1AF192FC003BF8F0 /* generated-cpp */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
B5E9C93C1C1F9DCA0073C123 /* reverse_client_interface.hpp */,
A209B57B1BBA2A180070C310 /* opt_color_record.hpp */, A209B57B1BBA2A180070C310 /* opt_color_record.hpp */,
B52DA56C1B103FBE005CE75F /* assorted_primitives.cpp */, B52DA56C1B103FBE005CE75F /* assorted_primitives.cpp */,
B52DA56D1B103FBE005CE75F /* assorted_primitives.hpp */, B52DA56D1B103FBE005CE75F /* assorted_primitives.hpp */,
...@@ -653,11 +667,13 @@ ...@@ -653,11 +667,13 @@
A238CA9A1AF84B7100CDDCE5 /* DBNestedCollection+Private.mm in Sources */, A238CA9A1AF84B7100CDDCE5 /* DBNestedCollection+Private.mm in Sources */,
CFFD58911B019E79001E10B6 /* DBUserToken+Private.mm in Sources */, CFFD58911B019E79001E10B6 /* DBUserToken+Private.mm in Sources */,
A2CB54B419BA6E6000A9E600 /* DJIError.mm in Sources */, A2CB54B419BA6E6000A9E600 /* DJIError.mm in Sources */,
B5E9C9401C1F9E9E0073C123 /* DBReverseClientInterface+Private.mm in Sources */,
A238CA961AF84B7100CDDCE5 /* DBMapListRecord+Private.mm in Sources */, A238CA961AF84B7100CDDCE5 /* DBMapListRecord+Private.mm in Sources */,
A238CA9C1AF84B7100CDDCE5 /* DBPrimitiveList+Private.mm in Sources */, A238CA9C1AF84B7100CDDCE5 /* DBPrimitiveList+Private.mm in Sources */,
A24249761AF192FC003BF8F0 /* record_with_nested_derivings.cpp in Sources */, A24249761AF192FC003BF8F0 /* record_with_nested_derivings.cpp in Sources */,
CFC5DA081B1532F600BF2DF8 /* DBRecordWithDurationAndDerivings.mm in Sources */, CFC5DA081B1532F600BF2DF8 /* DBRecordWithDurationAndDerivings.mm in Sources */,
A248502D1AF96EBC00AFE907 /* DBNestedCollection.mm in Sources */, A248502D1AF96EBC00AFE907 /* DBNestedCollection.mm in Sources */,
B5E9C93B1C1F9D9D0073C123 /* reverse_client_interface_impl.cpp in Sources */,
CFC5D9D81B15106400BF2DF8 /* DBExternRecordWithDerivings+Private.mm in Sources */, CFC5D9D81B15106400BF2DF8 /* DBExternRecordWithDerivings+Private.mm in Sources */,
A238CAA21AF84B7100CDDCE5 /* DBSetRecord+Private.mm in Sources */, A238CAA21AF84B7100CDDCE5 /* DBSetRecord+Private.mm in Sources */,
A2AE38491BB3074800B7A0C9 /* DJIProxyCaches.mm in Sources */, A2AE38491BB3074800B7A0C9 /* DJIProxyCaches.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