From c9ace98d28c7073e9f16c507b020520230d181cb Mon Sep 17 00:00:00 2001 From: Mike Foster Date: Sat, 5 Mar 2016 09:06:22 -0500 Subject: [PATCH 1/7] Implements interface inheritance in Djinni. Includes: * New 'interface extends' syntax support. * Code generation for interfaces that extend other interfaces. * Proper object conversion from one language to another. No type slicing when referenced as a super interface. --- example/generated-src/cpp/sort_items.hpp | 32 ++++++- .../generated-src/cpp/textbox_listener.hpp | 32 ++++++- .../java/com/dropbox/textsort/SortItems.java | 2 + .../objc/TXSSortItems+Private.mm | 2 + .../generated-src/objc/TXSTextboxListener.h | 2 +- src/source/CppGenerator.scala | 81 ++++++++++++++--- src/source/CppMarshal.scala | 5 ++ src/source/JNIGenerator.scala | 64 +++++++++----- src/source/JavaGenerator.scala | 69 ++++++++++----- src/source/JavaMarshal.scala | 5 ++ src/source/Marshal.scala | 24 ++++++ src/source/ObjcGenerator.scala | 12 ++- src/source/ObjcMarshal.scala | 5 ++ src/source/ObjcppGenerator.scala | 86 ++++++++++++------- src/source/ObjcppMarshal.scala | 2 + src/source/YamlGenerator.scala | 2 +- src/source/ast.scala | 2 +- src/source/generator.scala | 28 +++++- src/source/parser.scala | 19 ++-- src/source/resolver.scala | 21 ++++- support-lib/jni/djinni_support.cpp | 5 +- support-lib/jni/djinni_support.hpp | 78 +++++++++++++---- support-lib/objc/DJICppWrapperCache+Private.h | 5 +- 23 files changed, 453 insertions(+), 130 deletions(-) diff --git a/example/generated-src/cpp/sort_items.hpp b/example/generated-src/cpp/sort_items.hpp index a01d3936c..6ae2a960c 100644 --- a/example/generated-src/cpp/sort_items.hpp +++ b/example/generated-src/cpp/sort_items.hpp @@ -3,18 +3,46 @@ #pragma once +#include "item_list.hpp" +#include "sort_order.hpp" #include +#include namespace textsort { class TextboxListener; -enum class sort_order; -struct ItemList; class SortItems { public: virtual ~SortItems() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/textsort/SortItems$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "TXSSortItems"; } + /** For the iOS / Android demo */ virtual void sort(sort_order order, const ItemList & items) = 0; diff --git a/example/generated-src/cpp/textbox_listener.hpp b/example/generated-src/cpp/textbox_listener.hpp index 5770120d9..f512f7471 100644 --- a/example/generated-src/cpp/textbox_listener.hpp +++ b/example/generated-src/cpp/textbox_listener.hpp @@ -3,14 +3,42 @@ #pragma once -namespace textsort { +#include "item_list.hpp" +#include -struct ItemList; +namespace textsort { class TextboxListener { public: virtual ~TextboxListener() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return nullptr; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "TXSTextboxListener"; } + virtual void update(const ItemList & items) = 0; }; diff --git a/example/generated-src/java/com/dropbox/textsort/SortItems.java b/example/generated-src/java/com/dropbox/textsort/SortItems.java index 51de474ee..6c1df533a 100644 --- a/example/generated-src/java/com/dropbox/textsort/SortItems.java +++ b/example/generated-src/java/com/dropbox/textsort/SortItems.java @@ -41,6 +41,8 @@ protected void finalize() throws java.lang.Throwable super.finalize(); } + // SortItems methods + @Override public void sort(SortOrder order, ItemList items) { diff --git a/example/generated-src/objc/TXSSortItems+Private.mm b/example/generated-src/objc/TXSSortItems+Private.mm index 548b73c3b..10bf6c74e 100644 --- a/example/generated-src/objc/TXSSortItems+Private.mm +++ b/example/generated-src/objc/TXSSortItems+Private.mm @@ -32,6 +32,8 @@ - (id)initWithCpp:(const std::shared_ptr<::textsort::SortItems>&)cppRef return self; } +// TXSSortItems methods + - (void)sort:(TXSSortOrder)order items:(nonnull TXSItemList *)items { try { diff --git a/example/generated-src/objc/TXSTextboxListener.h b/example/generated-src/objc/TXSTextboxListener.h index b57313a8c..f3d8cf426 100644 --- a/example/generated-src/objc/TXSTextboxListener.h +++ b/example/generated-src/objc/TXSTextboxListener.h @@ -5,7 +5,7 @@ #import -@protocol TXSTextboxListener +@protocol TXSTextboxListener - (void)update:(nonnull TXSItemList *)items; diff --git a/src/source/CppGenerator.scala b/src/source/CppGenerator.scala index f7e472da7..4791050d6 100644 --- a/src/source/CppGenerator.scala +++ b/src/source/CppGenerator.scala @@ -27,28 +27,34 @@ import scala.collection.mutable class CppGenerator(spec: Spec) extends Generator(spec) { val marshal = new CppMarshal(spec) + val jniMarshal = new JNIMarshal(spec) + val objcMarshal = new ObjcMarshal(spec) val writeCppFile = writeCppFileGeneric(spec.cppOutFolder.get, spec.cppNamespace, spec.cppFileIdentStyle, spec.cppIncludePrefix) _ def writeHppFile(name: String, origin: String, includes: Iterable[String], fwds: Iterable[String], f: IndentWriter => Unit, f2: IndentWriter => Unit = (w => {})) = writeHppFileGeneric(spec.cppHeaderOutFolder.get, spec.cppNamespace, spec.cppFileIdentStyle)(name, origin, includes, fwds, f, f2) - class CppRefs(name: String) { + class CppRefs(ident: Ident) { var hpp = mutable.TreeSet[String]() var hppFwds = mutable.TreeSet[String]() var cpp = mutable.TreeSet[String]() + def addInclude(ident: Ident) { + hpp.add(s"#include ${marshal.include(ident)}") + } + def find(ty: TypeRef, forwardDeclareOnly: Boolean) { find(ty.resolved, forwardDeclareOnly) } def find(tm: MExpr, forwardDeclareOnly: Boolean) { tm.args.foreach((x) => find(x, forwardDeclareOnly)) find(tm.base, forwardDeclareOnly) } def find(m: Meta, forwardDeclareOnly : Boolean) = { - for(r <- marshal.hppReferences(m, name, forwardDeclareOnly)) r match { + for(r <- marshal.hppReferences(m, ident.name, forwardDeclareOnly)) r match { case ImportRef(arg) => hpp.add("#include " + arg) case DeclRef(decl, Some(spec.cppNamespace)) => hppFwds.add(decl) case DeclRef(_, _) => } - for(r <- marshal.cppReferences(m, name, forwardDeclareOnly)) r match { + for(r <- marshal.cppReferences(m, ident.name, forwardDeclareOnly)) r match { case ImportRef(arg) => cpp.add("#include " + arg) case DeclRef(_, _) => } @@ -56,7 +62,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) { } override def generateEnum(origin: String, ident: Ident, doc: Doc, e: Enum) { - val refs = new CppRefs(ident.name) + val refs = new CppRefs(ident) val self = marshal.typename(ident, e) if (spec.cppEnumHashWorkaround) { @@ -135,7 +141,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) { } override def generateRecord(origin: String, ident: Ident, doc: Doc, params: Seq[TypeParam], r: Record) { - val refs = new CppRefs(ident.name) + val refs = new CppRefs(ident) r.fields.foreach(f => refs.find(f.ty, false)) r.consts.foreach(c => refs.find(c.ty, false)) refs.hpp.add("#include ") // Add for std::move @@ -262,25 +268,75 @@ class CppGenerator(spec: Spec) extends Generator(spec) { } - override def generateInterface(origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { - val refs = new CppRefs(ident.name) + override def generateInterface(idl: Seq[TypeDecl], origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { + val refs = new CppRefs(ident) + if (i.superIdent.isDefined) { + refs.addInclude(i.superIdent.get) + } + + refs.hpp.add("#include ") // needed for std::string jniProxyClassName(); + + // HACK: DISABLES FORWARD DECLARATIONS. + // + // FIXME: Forward declarations break the use of enums as keys in maps. + // + // Passing false instead of true for the find methods forwardDeclareOnly parameter + // disables the use of forward declarations. We'll leave them disabled until + // Dropbox has a solution. i.methods.map(m => { - m.params.map(p => refs.find(p.ty, true)) - m.ret.foreach((x)=>refs.find(x, true)) + m.params.map(p => refs.find(p.ty, false)) + m.ret.foreach((x)=>refs.find(x, false)) }) i.consts.map(c => { - refs.find(c.ty, true) + refs.find(c.ty, false) }) val self = marshal.typename(ident, i) + val superNametype = marshal.superTypename(i) writeHppFile(ident, origin, refs.hpp, refs.hppFwds, w => { + writeDoc(w, doc) writeCppTypeParams(w, typeParams) - w.w(s"class $self").bracedSemi { + + val extendsDef = if (superNametype.isDefined) " : public " + superNametype.get else "" + w.w(s"class $self$extendsDef").bracedSemi { w.wlOutdent("public:") // Destructor w.wl(s"virtual ~$self() {}") + + // Proxy class name + val jniProxyClassName = if (i.ext.cpp) q(jniMarshal.undecoratedTypename(ident, i) + "$CppProxy") else "nullptr" + w.wl + w.wl("/**") + w.wl(" * Defines the name of the JNI C++ proxy class. Used to convert a") + w.wl(" * C++ implemented object to a Java object when the type of the object being") + w.wl(" * converted is unknown to the JniInterface (see djinni_support.hpp).") + w.wl(" * ") + w.wl(" * The proxy class name is only used for converting Djinni interfaces that") + w.wl(" * are implemented in C++. Java implemented interfaces are converted differently.") + w.wl(" * However, the C++ class of an interface implemented in Java must still have a") + w.wl(" * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile.") + w.wl(" * ") + w.wl(" * @return The name of the class's associated JNI proxy class.") + w.wl(" * ") + w.wl(" * @see JniInterface in djinni_support.hpp") + w.wl(" */") + w.wl(s"virtual const std::string jniProxyClassName() { return $jniProxyClassName; }") + + val objcTypeName = q(objcMarshal.typename(ident, i)) + w.wl + w.wl("/**") + w.wl(" * Defines the name of the Objective-C type for the class. Used to convert a") + w.wl(" * C++ object to an Objective-C object when the type of the object being") + w.wl(" * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp).") + w.wl(" * ") + w.wl(" * @return The name of the Objective C type associated with the class.") + w.wl(" * ") + w.wl(" * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp") + w.wl(" */") + w.wl(s"virtual const std::string objcTypeName() { return $objcTypeName; }") + // Constants generateHppConstants(w, i.consts) // Methods @@ -299,7 +355,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) { } }) - // Cpp only generated in need of Constants + // Only generate the cpp file if constants need to be defined. if (i.consts.nonEmpty) { writeCppFile(ident, origin, refs.cpp, w => { generateCppConstants(w, i.consts, self) @@ -312,5 +368,4 @@ class CppGenerator(spec: Spec) extends Generator(spec) { if (params.isEmpty) return w.wl("template " + params.map(p => "typename " + idCpp.typeParam(p.ident)).mkString("<", ", ", ">")) } - } diff --git a/src/source/CppMarshal.scala b/src/source/CppMarshal.scala index 76a0b9b9d..5a885f176 100644 --- a/src/source/CppMarshal.scala +++ b/src/source/CppMarshal.scala @@ -20,6 +20,11 @@ class CppMarshal(spec: Spec) extends Marshal(spec) { case r: Record => withNs(Some(spec.cppNamespace), idCpp.ty(name)) } + def superTypename(ty: TypeDef): Option[String] = ty match { + case i: Interface => if (i.superIdent.isDefined) Some(i.superIdent.get.name) else None + case _ => None + } + override def paramType(tm: MExpr): String = toCppParamType(tm) override def fqParamType(tm: MExpr): String = toCppParamType(tm, Some(spec.cppNamespace)) diff --git a/src/source/JNIGenerator.scala b/src/source/JNIGenerator.scala index 4042f55c2..57e1fb222 100644 --- a/src/source/JNIGenerator.scala +++ b/src/source/JNIGenerator.scala @@ -46,6 +46,10 @@ class JNIGenerator(spec: Spec) extends Generator(spec) { case _ => } + def addHppInclude(name: String): Unit = { + jniHpp.add("#include " + name) + } + def find(ty: TypeRef) { find(ty.resolved) } def find(tm: MExpr) { tm.args.foreach(find) @@ -169,12 +173,21 @@ class JNIGenerator(spec: Spec) extends Generator(spec) { writeJniFiles(origin, params.nonEmpty, ident, refs, writeJniPrototype, writeJniBody) } - override def generateInterface(origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { + override def generateInterface(idl: Seq[TypeDecl], origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { val refs = new JNIRefs(ident.name) + + if (i.superIdent.isDefined) { + refs.addHppInclude(jniMarshal.include(i.superIdent.get.name)) + } + i.methods.foreach(m => { m.params.foreach(p => refs.find(p.ty)) m.ret.foreach(refs.find) }) + getInterfaceSuperMethods(i, idl).foreach(m => { + m.params.foreach(p => refs.find(p.ty)) + m.ret.foreach(refs.find) + }) i.consts.foreach(c => { refs.find(c.ty) }) @@ -336,30 +349,35 @@ class JNIGenerator(spec: Spec) extends Generator(spec) { nativeHook("nativeDestroy", false, Seq.empty, None, { w.wl(s"delete reinterpret_cast*>(nativeRef);") }) - for (m <- i.methods) { - val nativeAddon = if (m.static) "" else "native_" - nativeHook(nativeAddon + idJava.method(m.ident), m.static, m.params, m.ret, { - //w.wl(s"::${spec.jniNamespace}::JniLocalScope jscope(jniEnv, 10);") - if (!m.static) w.wl(s"const auto& ref = ::djinni::objectFromHandleAddress<$cppSelf>(nativeRef);") - m.params.foreach(p => { - if (isInterface(p.ty.resolved) && spec.cppNnCheckExpression.nonEmpty) { - // We have a non-optional interface in nn mode, assert that we're getting a non-null value - val paramName = idJava.local(p.ident) - val javaMethodName = idJava.method(m.ident) - val javaParams = m.params.map(p => javaMarshal.fqParamType(p.ty) + " " + idJava.local(p.ident)) - val javaParamsString: String = javaParams.mkString("(", ", ", ")") - val functionString: String = s"${javaMarshal.fqTypename(ident, i)}#$javaMethodName$javaParamsString" - w.wl( s"""DJINNI_ASSERT_MSG(j_$paramName, jniEnv, "Got unexpected null parameter '$paramName' to function $functionString");""") - } + + def writeJniMethods(w: IndentWriter, methods: Seq[Interface.Method]) { + for (m <- methods) { + val nativeAddon = if (m.static) "" else "native_" + nativeHook(nativeAddon + idJava.method(m.ident), m.static, m.params, m.ret, { + //w.wl(s"::${spec.jniNamespace}::JniLocalScope jscope(jniEnv, 10);") + if (!m.static) w.wl(s"const auto& ref = ::djinni::objectFromHandleAddress<$cppSelf>(nativeRef);") + m.params.foreach(p => { + if (isInterface(p.ty.resolved) && spec.cppNnCheckExpression.nonEmpty) { + // We have a non-optional interface in nn mode, assert that we're getting a non-null value + val paramName = idJava.local(p.ident) + val javaMethodName = idJava.method(m.ident) + val javaParams = m.params.map(p => javaMarshal.fqParamType(p.ty) + " " + idJava.local(p.ident)) + val javaParamsString: String = javaParams.mkString("(", ", ", ")") + val functionString: String = s"${javaMarshal.fqTypename(ident, i)}#$javaMethodName$javaParamsString" + w.wl( s"""DJINNI_ASSERT_MSG(j_$paramName, jniEnv, "Got unexpected null parameter '$paramName' to function $functionString");""") + } + }) + val methodName = idCpp.method(m.ident) + val ret = m.ret.fold("")(r => "auto r = ") + val call = if (m.static) s"$cppSelf::$methodName(" else s"ref->$methodName(" + writeAlignedCall(w, ret + call, m.params, ")", p => jniMarshal.toCpp(p.ty, "j_" + idJava.local(p.ident))) + w.wl(";") + m.ret.fold()(r => w.wl(s"return ::djinni::release(${jniMarshal.fromCpp(r, "r")});")) }) - val methodName = idCpp.method(m.ident) - val ret = m.ret.fold("")(r => "auto r = ") - val call = if (m.static) s"$cppSelf::$methodName(" else s"ref->$methodName(" - writeAlignedCall(w, ret + call, m.params, ")", p => jniMarshal.toCpp(p.ty, "j_" + idJava.local(p.ident))) - w.wl(";") - m.ret.fold()(r => w.wl(s"return ::djinni::release(${jniMarshal.fromCpp(r, "r")});")) - }) + } } + writeJniMethods(w, getInterfaceSuperMethods(i, idl)) + writeJniMethods(w, i.methods) } } diff --git a/src/source/JavaGenerator.scala b/src/source/JavaGenerator.scala index 71e562918..febbbec71 100644 --- a/src/source/JavaGenerator.scala +++ b/src/source/JavaGenerator.scala @@ -119,16 +119,22 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { }) } - override def generateInterface(origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { + override def generateInterface(idl: Seq[TypeDecl], origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { val refs = new JavaRefs() - i.methods.map(m => { - m.params.map(p => refs.find(p.ty)) - m.ret.foreach(refs.find) - }) - i.consts.map(c => { - refs.find(c.ty) - }) + def mapRefs(i: Interface) { + i.methods.map(m => { + m.params.map(p => refs.find(p.ty)) + m.ret.foreach(refs.find) + }) + i.consts.map(c => { + refs.find(c.ty) + }) + } + + marshal.superInterfacesForInterface(i, idl).foreach { mapRefs(_) } + mapRefs(i) + if (i.ext.cpp) { refs.java.add("java.util.concurrent.atomic.AtomicBoolean") } @@ -139,7 +145,12 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { writeDoc(w, doc) javaAnnotationHeader.foreach(w.wl) - w.w(s"public abstract class $javaClass$typeParamList").braced { + + val superTypename = marshal.superTypename(i) + + // In java we need to add an "extends Type" to a class to subclass it. + val extendsDef = if (superTypename.isDefined) " extends " + superTypename.get else "" + w.w(s"public abstract class $javaClass$typeParamList$extendsDef").braced { val skipFirst = SkipFirst() generateJavaConstants(w, i.consts) @@ -187,19 +198,16 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { w.wl("destroy();") w.wl("super.finalize();") } - for (m <- i.methods if !m.static) { // Static methods not in CppProxy - val ret = marshal.returnType(m.ret) - val returnStmt = m.ret.fold("")(_ => "return ") - val params = m.params.map(p => marshal.paramType(p.ty) + " " + idJava.local(p.ident)).mkString(", ") - val args = m.params.map(p => idJava.local(p.ident)).mkString(", ") - val meth = idJava.method(m.ident) - w.wl - w.wl(s"@Override") - w.wl(s"public $ret $meth($params)$throwException").braced { - w.wl("assert !this.destroyed.get() : \"trying to use a destroyed object\";") - w.wl(s"${returnStmt}native_$meth(this.nativeRef${preComma(args)});") - } - w.wl(s"private native $ret native_$meth(long _nativeRef${preComma(params)});") + + // For JNI support, Djinni generates a nested class, called CppProxy, which handles the bridging + // between Java and C++. The super interface methods need to be declared within the proxy. + w.wl; w.wl(s"// $javaClass methods") + writeCppProxyMethods(w, i.methods, throwException) + + val superMethods = getInterfaceSuperMethods(i, idl) + if (!superMethods.isEmpty) { + w.wl; w.wl(s"// ${superTypename.getOrElse("Super")} methods") + writeCppProxyMethods(w, superMethods, throwException) } } } @@ -207,6 +215,23 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { }) } + def writeCppProxyMethods(w: IndentWriter, methods: Seq[Interface.Method], throwException: String) { + for (m <- methods if !m.static) { // Static methods not in CppProxy + val ret = marshal.returnType(m.ret) + val returnStmt = m.ret.fold("")(_ => "return ") + val params = m.params.map(p => marshal.paramType(p.ty) + " " + idJava.local(p.ident)).mkString(", ") + val args = m.params.map(p => idJava.local(p.ident)).mkString(", ") + val meth = idJava.method(m.ident) + w.wl + w.wl(s"@Override") + w.wl(s"public $ret $meth($params)$throwException").braced { + w.wl("assert !this.destroyed.get() : \"trying to use a destroyed object\";") + w.wl(s"${returnStmt}native_$meth(this.nativeRef${preComma(args)});") + } + w.wl(s"private native $ret native_$meth(long _nativeRef${preComma(params)});") + } + } + override def generateRecord(origin: String, ident: Ident, doc: Doc, params: Seq[TypeParam], r: Record) { val refs = new JavaRefs() r.fields.foreach(f => refs.find(f.ty)) diff --git a/src/source/JavaMarshal.scala b/src/source/JavaMarshal.scala index 91d765210..e23813e11 100644 --- a/src/source/JavaMarshal.scala +++ b/src/source/JavaMarshal.scala @@ -12,6 +12,11 @@ class JavaMarshal(spec: Spec) extends Marshal(spec) { override def typename(tm: MExpr): String = toJavaType(tm, None) def typename(name: String, ty: TypeDef): String = idJava.ty(name) + def superTypename(ty: TypeDef): Option[String] = ty match { + case i: Interface => if(i.superIdent.isDefined) Some(idJava.ty(i.superIdent.get.name)) else None + case _ => None + } + override def fqTypename(tm: MExpr): String = toJavaType(tm, spec.javaPackage) def fqTypename(name: String, ty: TypeDef): String = withPackage(spec.javaPackage, idJava.ty(name)) diff --git a/src/source/Marshal.scala b/src/source/Marshal.scala index f4fff656e..96897089a 100644 --- a/src/source/Marshal.scala +++ b/src/source/Marshal.scala @@ -3,6 +3,7 @@ package djinni import djinni.ast._ import djinni.generatorTools._ import djinni.meta._ +import scala.collection.mutable.ListBuffer import scala.language.implicitConversions // Generate code for marshalling a specific type from/to C++ including header and type names. @@ -16,6 +17,8 @@ abstract class Marshal(spec: Spec) { // Same as typename() but always fully namespace or package qualified def fqTypename(tm: MExpr): String def fqTypename(ty: TypeRef): String = fqTypename(ty.resolved) + // Typename string of the interface that the type extends + def superTypename(ty: TypeRef): String = typename(ty.resolved) // Type signature for a function parameter def paramType(tm: MExpr): String def paramType(ty: TypeRef): String = paramType(ty.resolved) @@ -36,6 +39,27 @@ abstract class Marshal(spec: Spec) { def fromCpp(tm: MExpr, expr: String): String = "" def fromCpp(ty: TypeRef, expr: String): String = fromCpp(ty.resolved, expr) + def interfaceForIdent(idl: Seq[TypeDecl], ident: Ident): Interface = { + idl.find(td => td.ident.name == ident.name) match { + case Some(superDec) => superDec.body match { + case i: Interface => i + case _ => throw new AssertionError("Unreachable. The parser throws an exception when extending a non-interface type.") + } + case _ => throw new AssertionError("Unreachable. The parser throws an exception when extending an interface that doesn't exist.") + } + } + + def superInterfacesForInterface(i: Interface, idl: Seq[TypeDecl]): Seq[Interface] = { + val interfaces = ListBuffer[Interface]() + + var interface = i + while (interface.superIdent.isDefined) { + interface = interfaceForIdent(idl, interface.superIdent.get) + interfaces += interface + } + interfaces + } + implicit def identToString(ident: Ident): String = ident.name protected val idCpp = spec.cppIdentStyle protected val idJava = spec.javaIdentStyle diff --git a/src/source/ObjcGenerator.scala b/src/source/ObjcGenerator.scala index becad1378..5f370f635 100644 --- a/src/source/ObjcGenerator.scala +++ b/src/source/ObjcGenerator.scala @@ -117,7 +117,7 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { w.wl("#pragma clang diagnostic pop") } - override def generateInterface(origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { + override def generateInterface(idl: Seq[TypeDecl], origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { val refs = new ObjcRefs() i.methods.map(m => { m.params.map(p => refs.find(p.ty)) @@ -131,6 +131,10 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { refs.header.add("#import ") + if (i.superIdent.isDefined) { + refs.header.add ("#import " + q(spec.objcIncludePrefix + marshal.headerName(i.superIdent.get))) + } + def writeObjcFuncDecl(method: Interface.Method, w: IndentWriter) { val label = if (method.static) "+" else "-" val ret = marshal.returnType(method.ret) @@ -147,7 +151,11 @@ class ObjcGenerator(spec: Spec) extends Generator(spec) { } w.wl writeDoc(w, doc) - if (i.ext.objc) w.wl(s"@protocol $self") else w.wl(s"@interface $self : NSObject") + + // Top level Djinni protocols need to extend NSObject. Without extending NSObject, protocols can't leverage + // methods like respondsToSelector when the instance variable is of the form id ivarName; + val superTypename = marshal.superTypename(i).getOrElse("NSObject") + if (i.ext.objc) w.wl(s"@protocol $self <$superTypename>") else w.wl(s"@interface $self : $superTypename") for (m <- i.methods) { w.wl writeDoc(w, m.doc) diff --git a/src/source/ObjcMarshal.scala b/src/source/ObjcMarshal.scala index 7e7f69400..ddac3af98 100644 --- a/src/source/ObjcMarshal.scala +++ b/src/source/ObjcMarshal.scala @@ -12,6 +12,11 @@ class ObjcMarshal(spec: Spec) extends Marshal(spec) { } def typename(name: String, ty: TypeDef): String = idObjc.ty(name) + def superTypename(ty: TypeDef): Option[String] = ty match { + case i: Interface => if(i.superIdent.isDefined) Some(idObjc.ty(i.superIdent.get.name)) else None + case _ => None + } + override def fqTypename(tm: MExpr): String = typename(tm) def fqTypename(name: String, ty: TypeDef): String = typename(name, ty) diff --git a/src/source/ObjcppGenerator.scala b/src/source/ObjcppGenerator.scala index 350b61fa3..7eef2bd12 100644 --- a/src/source/ObjcppGenerator.scala +++ b/src/source/ObjcppGenerator.scala @@ -57,12 +57,16 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { def nnCheck(expr: String): String = spec.cppNnCheckExpression.fold(expr)(check => s"$check($expr)") - override def generateInterface(origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { + override def generateInterface(idl: Seq[TypeDecl], origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { val refs = new ObjcRefs() i.methods.map(m => { m.params.map(p => refs.find(p.ty)) m.ret.foreach(refs.find) }) + getInterfaceSuperMethods(i, idl).map(m => { + m.params.map(p => refs.find(p.ty)) + m.ret.foreach(refs.find) + }) i.consts.map(c => { refs.find(c.ty) }) @@ -72,6 +76,10 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { refs.privHeader.add("#include ") refs.privHeader.add("!#include " + q(spec.objcppIncludeCppPrefix + spec.cppFileIdentStyle(ident) + "." + spec.cppHeaderExt)) + if (i.superIdent.isDefined) { + refs.privHeader.add("#import " + q(spec.objcppIncludePrefix + objcppMarshal.privateHeaderName(i.superIdent.get.name))); + } + refs.body.add("!#import " + q(spec.objcppIncludeObjcPrefix + headerName(ident))) spec.cppNnHeader match { @@ -79,13 +87,6 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { case _ => } - def writeObjcFuncDecl(method: Interface.Method, w: IndentWriter) { - val label = if (method.static) "+" else "-" - val ret = objcMarshal.fqReturnType(method.ret) - val decl = s"$label ($ret)${idObjc.method(method.ident)}" - writeAlignedObjcCall(w, decl, method.params, "", p => (idObjc.field(p.ident), s"(${objcMarshal.paramType(p.ty)})${idObjc.local(p.ident)}")) - } - val helperClass = objcppMarshal.helperClass(ident) writeObjcFile(objcppMarshal.privateHeaderName(ident.name), origin, refs.privHeader, w => { @@ -159,32 +160,14 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { } w.wl("return self;") } - for (m <- i.methods) { - w.wl - writeObjcFuncDecl(m, w) - w.braced { - w.w("try").bracedEnd(" DJINNI_TRANSLATE_EXCEPTIONS()") { - m.params.foreach(p => { - if (isInterface(p.ty.resolved) && spec.cppNnCheckExpression.nonEmpty) { - // We have a non-optional interface, assert that we're getting a non-null value - val paramName = idObjc.local(p.ident) - val stringWriter = new StringWriter() - writeObjcFuncDecl(m, new IndentWriter(stringWriter)) - val singleLineFunctionDecl = stringWriter.toString.replaceAll("\n *", " ") - val exceptionReason = s"Got unexpected null parameter '$paramName' to function $objcSelf $singleLineFunctionDecl" - w.w(s"if ($paramName == nil)").braced { - w.wl(s"""throw std::invalid_argument("$exceptionReason");""") - } - } - }) - val ret = m.ret.fold("")(_ => "auto r = ") - val call = ret + (if (!m.static) "_cppRefHandle.get()->" else cppSelf + "::") + idCpp.method(m.ident) + "(" - writeAlignedCall(w, call, m.params, ")", p => objcppMarshal.toCpp(p.ty, idObjc.local(p.ident.name))) - w.wl(";") - m.ret.fold()(r => w.wl(s"return ${objcppMarshal.fromCpp(r, "r")};")) - } - } + w.wl; w.wl(s"// $objcSelf methods") + writeCppProxyMethods(w, i.methods, objcSelf, cppSelf) + + val superMethods = getInterfaceSuperMethods(i, idl) + if (!superMethods.isEmpty) { + w.wl; w.wl(s"// ${objcppMarshal.superTypename(i).getOrElse("Super")} methods") + writeCppProxyMethods(w, superMethods, objcSelf, cppSelf) } } @@ -291,6 +274,43 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { }) } + def writeObjcFuncDecl(method: Interface.Method, w: IndentWriter) { + val label = if (method.static) "+" else "-" + val ret = objcMarshal.fqReturnType(method.ret) + val decl = s"$label ($ret)${idObjc.method(method.ident)}" + writeAlignedObjcCall(w, decl, method.params, "", p => (idObjc.field(p.ident), s"(${objcMarshal.paramType(p.ty)})${idObjc.local(p.ident)}")) + } + + def writeCppProxyMethods(w: IndentWriter, methods: Seq[Interface.Method], objcName: String, cppName: String) { + for (m <- methods) { + w.wl + writeObjcFuncDecl(m, w) + w.braced { + w.w("try").bracedEnd(" DJINNI_TRANSLATE_EXCEPTIONS()") { + m.params.foreach(p => { + if (isInterface(p.ty.resolved) && spec.cppNnCheckExpression.nonEmpty) { + // We have a non-optional interface, assert that we're getting a non-null value + val paramName = idObjc.local(p.ident) + val stringWriter = new StringWriter() + writeObjcFuncDecl(m, new IndentWriter(stringWriter)) + val singleLineFunctionDecl = stringWriter.toString.replaceAll("\n *", " ") + val exceptionReason = s"Got unexpected null parameter '$paramName' to function $objcName $singleLineFunctionDecl" + w.w(s"if ($paramName == nil)").braced { + w.wl(s"""throw std::invalid_argument("$exceptionReason");""") + } + } + }) + val ret = m.ret.fold("")(_ => "auto r = ") + val call = ret + (if (!m.static) "_cppRefHandle.get()->" else cppName + "::") + idCpp.method(m.ident) + "(" + writeAlignedCall(w, call, m.params, ")", p => objcppMarshal.toCpp(p.ty, idObjc.local(p.ident.name))) + + w.wl(";") + m.ret.fold()(r => w.wl(s"return ${objcppMarshal.fromCpp(r, "r")};")) + } + } + } + } + override def generateRecord(origin: String, ident: Ident, doc: Doc, params: Seq[TypeParam], r: Record) { val refs = new ObjcRefs() for (c <- r.consts) diff --git a/src/source/ObjcppMarshal.scala b/src/source/ObjcppMarshal.scala index 8541cbc3e..bc0e6c223 100644 --- a/src/source/ObjcppMarshal.scala +++ b/src/source/ObjcppMarshal.scala @@ -11,6 +11,8 @@ class ObjcppMarshal(spec: Spec) extends Marshal(spec) { override def typename(tm: MExpr): String = throw new AssertionError("not applicable") def typename(name: String, ty: TypeDef): String = throw new AssertionError("not applicable") + def superTypename(ty: TypeDef): Option[String] = objcMarshal.superTypename(ty) + override def fqTypename(tm: MExpr): String = throw new AssertionError("not applicable") def fqTypename(name: String, ty: TypeDef): String = throw new AssertionError("not applicable") diff --git a/src/source/YamlGenerator.scala b/src/source/YamlGenerator.scala index 6b6fe8b83..a2288c4f6 100644 --- a/src/source/YamlGenerator.scala +++ b/src/source/YamlGenerator.scala @@ -171,7 +171,7 @@ class YamlGenerator(spec: Spec) extends Generator(spec) { // unused } - override def generateInterface(origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { + override def generateInterface(idl: Seq[TypeDecl], origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) { // unused } diff --git a/src/source/ast.scala b/src/source/ast.scala index 6d2ca62c8..34c0eec5f 100644 --- a/src/source/ast.scala +++ b/src/source/ast.scala @@ -74,7 +74,7 @@ object Record { } } -case class Interface(ext: Ext, methods: Seq[Interface.Method], consts: Seq[Const]) extends TypeDef +case class Interface(superIdent: Option[Ident], ext: Ext, methods: Seq[Interface.Method], consts: Seq[Const]) extends TypeDef object Interface { case class Method(ident: Ident, params: Seq[Field], ret: Option[TypeRef], doc: Doc, static: Boolean, const: Boolean) } diff --git a/src/source/generator.scala b/src/source/generator.scala index f76554fdc..eaa6f7519 100644 --- a/src/source/generator.scala +++ b/src/source/generator.scala @@ -22,6 +22,7 @@ import djinni.generatorTools._ import djinni.meta._ import djinni.syntax.Error import djinni.writer.IndentWriter +import scala.collection.mutable.ListBuffer import scala.language.implicitConversions import scala.collection.mutable @@ -319,13 +320,13 @@ abstract class Generator(spec: Spec) assert(td.params.isEmpty) generateEnum(td.origin, td.ident, td.doc, e) case r: Record => generateRecord(td.origin, td.ident, td.doc, td.params, r) - case i: Interface => generateInterface(td.origin, td.ident, td.doc, td.params, i) + case i: Interface => generateInterface(idl, td.origin, td.ident, td.doc, td.params, i) } } def generateEnum(origin: String, ident: Ident, doc: Doc, e: Enum) def generateRecord(origin: String, ident: Ident, doc: Doc, params: Seq[TypeParam], r: Record) - def generateInterface(origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) + def generateInterface(idl: Seq[TypeDecl], origin: String, ident: Ident, doc: Doc, typeParams: Seq[TypeParam], i: Interface) // -------------------------------------------------------------------------- // Render type expression @@ -375,4 +376,27 @@ abstract class Generator(spec: Spec) w.wl(" */") } } + + // -------------------------------------------------------------------------- + // Interface Inheritance Utils + + def getInterfaceSuperMethods(i: Interface, idl: Seq[TypeDecl]): Seq[Interface.Method] = { + val methods = ListBuffer[Interface.Method](); + + var superIdent = i.superIdent + while (superIdent.isDefined) { + idl.find(td => td.ident.name == superIdent.get.name) match { + case Some(superDec) => superDec.body match { + case i: Interface => { + methods.appendAll(i.methods) + superIdent = i.superIdent + } + case _ => throw new AssertionError("Unreachable. The parser throws an exception when extending a non-interface type.") + } + case _ => throw new AssertionError("Unreachable. The parser throws an exception when extending an interface that doesn't exist.") + } + } + methods.filter(m => !m.static) + } + } diff --git a/src/source/parser.scala b/src/source/parser.scala index 0b1c6cea5..a843368fb 100644 --- a/src/source/parser.scala +++ b/src/source/parser.scala @@ -40,8 +40,8 @@ private object IdlParser extends RegexParsers { def idlFile(origin: String): Parser[IdlFile] = rep(importFile) ~ rep(typeDecl(origin)) ^^ { case imp~types => IdlFile(imp, types) } def importFile: Parser[FileRef] = { - - def fileParent:String = if (fileStack.top.getParent() != null) return fileStack.top.getParent() + "/" else return "" + + def fileParent:String = if (fileStack.top.getParent() != null) return fileStack.top.getParent() + "/" else return "" ("@" ~> directive) ~ ("\"" ~> filePath <~ "\"") ^^ { case "import" ~ x => @@ -90,7 +90,7 @@ private object IdlParser extends RegexParsers { success(Ext(foundJava, foundCpp, foundObjc)) } - def typeDef: Parser[TypeDef] = record | enum | interface + def typeDef: Parser[TypeDef] = record | enum | interface | interfaceExtends def recordHeader = "record" ~> extRecord def record: Parser[Record] = recordHeader ~ bracesList(field | const) ~ opt(deriving) ^^ { @@ -123,14 +123,23 @@ private object IdlParser extends RegexParsers { case ext~items => { val methods = items collect {case m: Method => m} val consts = items collect {case c: Const => c} - Interface(ext, methods, consts) + Interface(None, ext, methods, consts) + } + } + + def interfaceExtendsHeaders = "interface extends" ~> ident + def interfaceExtends: Parser[Interface] = interfaceExtendsHeaders ~ extInterface ~ bracesList(method | const) ^^ { + case ident~ext~items => { + val methods = items collect {case m: Method => m} + val consts = items collect {case c: Const => c} + Interface(Some(ident), ext, methods, consts) } } def externTypeDecl: Parser[TypeDef] = externEnum | externInterface | externRecord def externEnum: Parser[Enum] = enumHeader ^^ { case _ => Enum(List()) } def externRecord: Parser[Record] = recordHeader ~ opt(deriving) ^^ { case ext~deriving => Record(ext, List(), List(), deriving.getOrElse(Set[DerivingType]())) } - def externInterface: Parser[Interface] = interfaceHeader ^^ { case ext => Interface(ext, List(), List()) } + def externInterface: Parser[Interface] = interfaceHeader ^^ { case ext => Interface(None, ext, List(), List()) } def staticLabel: Parser[Boolean] = ("static ".r | "".r) ^^ { case "static " => true diff --git a/src/source/resolver.scala b/src/source/resolver.scala index f5d41c708..26ca62a51 100644 --- a/src/source/resolver.scala +++ b/src/source/resolver.scala @@ -70,7 +70,7 @@ def resolve(metas: Scope, idl: Seq[TypeDecl]): Option[Error] = { scope = scope.updated(typeParam.ident.name, MParam(typeParam.ident.name)) } - resolve(scope, typeDecl.body) + resolve(idl, scope, typeDecl.body) } for (typeDecl <- idl) { @@ -84,11 +84,11 @@ def resolve(metas: Scope, idl: Seq[TypeDecl]): Option[Error] = { None } -private def resolve(scope: Scope, typeDef: TypeDef) { +private def resolve(idl: Seq[TypeDecl], scope: Scope, typeDef: TypeDef) { typeDef match { case e: Enum => resolveEnum(scope, e) case r: Record => resolveRecord(scope, r) - case i: Interface => resolveInterface(scope, i) + case i: Interface => resolveInterface(idl, scope, i) } } @@ -263,7 +263,7 @@ private def resolveRecord(scope: Scope, r: Record) { } } -private def resolveInterface(scope: Scope, i: Interface) { +private def resolveInterface(idl: Seq[TypeDecl], scope: Scope, i: Interface) { // Check for static methods in Java or Objective-C; not allowed if (i.ext.java || i.ext.objc) { for (m <- i.methods) { @@ -273,6 +273,19 @@ private def resolveInterface(scope: Scope, i: Interface) { throw Error(m.ident.loc, "const method not allowed for +j or +o interfaces").toException } } + + // Check that the inherited interface 1) exists, and 2) is in fact an interface + if (i.superIdent.isDefined) { + val superIdent = i.superIdent.get + idl.find(td => td.ident.name == superIdent.name) match { + case Some(superDecl) => superDecl.body match { + case i: Interface => // All good! + case _ => throw Error(superIdent.loc, s"'${superIdent.name}' is not an interface. Interfaces can only extend other interfaces.").toException + } + case None => throw Error(superIdent.loc, s"Unknown interface '${superIdent.name}'").toException + } + } + if (i.ext.cpp) { for (m <- i.methods) { if (m.static && m.const) diff --git a/support-lib/jni/djinni_support.cpp b/support-lib/jni/djinni_support.cpp index 951f04417..644572d92 100644 --- a/support-lib/jni/djinni_support.cpp +++ b/support-lib/jni/djinni_support.cpp @@ -468,12 +468,13 @@ void jniDefaultSetPendingFromCurrent(JNIEnv * env, const char * /*ctx*/) noexcep template class ProxyCache; CppProxyClassInfo::CppProxyClassInfo(const char * className) - : clazz(jniFindClass(className)), + : proxyClassName{std::string(className)}, + clazz(jniFindClass(className)), constructor(jniGetMethodID(clazz.get(), "", "(J)V")), idField(jniGetFieldID(clazz.get(), "nativeRef", "J")) { } -CppProxyClassInfo::CppProxyClassInfo() : constructor{}, idField{} { +CppProxyClassInfo::CppProxyClassInfo() : proxyClassName{}, constructor{}, idField{} { } CppProxyClassInfo::~CppProxyClassInfo() { diff --git a/support-lib/jni/djinni_support.hpp b/support-lib/jni/djinni_support.hpp index 04c327f40..8ef978018 100644 --- a/support-lib/jni/djinni_support.hpp +++ b/support-lib/jni/djinni_support.hpp @@ -362,6 +362,7 @@ static const std::shared_ptr & objectFromHandleAddress(jlong handle) { * here, so this object has an invalid state and default constructor. */ struct CppProxyClassInfo { + const std::string proxyClassName; const GlobalRef clazz; const jmethodID constructor; const jfieldID idField; @@ -413,8 +414,10 @@ class JniInterface { * Given a Java object, find or create a C++ version. The cases here are: * 1. Null * 2. The provided Java object is actually a CppProxy (Java-side proxy for a C++ impl) - * 3. The provided Java object has an existing JavaProxy (C++-side proxy for a Java impl) - * 4. The provided Java object needs a new JavaProxy allocated + * 3. The provided Java object is a CppProxy, but is a proxy for a subclass of the class + * associated with this JniInterface. + * 4. The provided Java object has an existing JavaProxy (C++-side proxy for a Java impl) + * 5. The provided Java object needs a new JavaProxy allocated */ std::shared_ptr _fromJava(JNIEnv* jniEnv, jobject j) const { // Case 1 - null @@ -422,16 +425,44 @@ class JniInterface { return nullptr; } - // Case 2 - already a Java proxy; we just need to pull the C++ impl out. (This case + // Case 2 & 3 - already a Java proxy; we just need to pull the C++ impl out. (This case // is only possible if we were constructed with a cppProxyClassName parameter.) - if (m_cppProxyClass - && jniEnv->IsSameObject(jniEnv->GetObjectClass(j), m_cppProxyClass.clazz.get())) { - jlong handle = jniEnv->GetLongField(j, m_cppProxyClass.idField); - jniExceptionCheck(jniEnv); - return objectFromHandleAddress(handle); + if (m_cppProxyClass) { + if (jniEnv->IsSameObject(jniEnv->GetObjectClass(j), m_cppProxyClass.clazz.get())) { + // Case 2 + // + // The provided Java object's class is the same as the JniInterface proxy's class. + // Use the JniInterface proxy's class to get the C++ object associated with the + // provided Java object. + + jlong handle = jniEnv->GetLongField(j, m_cppProxyClass.idField); + jniExceptionCheck(jniEnv); + return objectFromHandleAddress(handle); + } else { + // Case 3 + // + // The provided Java object and the JniInterface proxy's class should have a super + // class in common. If that's the case, attempt to use the provided Java object + // directly to get its associated C++ object. + + jclass superClazz = jniEnv->GetSuperclass(m_cppProxyClass.clazz.get()); + while(superClazz != nullptr) { + if (jniEnv->IsInstanceOf(j, superClazz)) { + jclass clazz = jniEnv->GetObjectClass(j); + jfieldID idField = jniEnv->GetFieldID(clazz, "nativeRef", "J"); + if (!jniEnv->ExceptionCheck()) { + jlong handle = jniEnv->GetLongField(j, idField); + jniExceptionCheck(jniEnv); + return objectFromHandleAddress(handle); + } + jniEnv->ExceptionClear(); + break; + } + superClazz = jniEnv->GetSuperclass(superClazz); + } + } } - - // Cases 3 and 4 - see _getJavaProxy helper below. JavaProxyCache is responsible for + // Cases 4 and 5 - see _getJavaProxy helper below. JavaProxyCache is responsible for // distinguishing between the two cases. Only possible if Self::JavaProxy exists. return _getJavaProxy(j); } @@ -469,14 +500,31 @@ class JniInterface { static std::pair newCppProxy(const std::shared_ptr & cppObj) { const auto & data = JniClass::get(); const auto & jniEnv = jniGetThreadEnv(); - std::unique_ptr> to_encapsulate( - new CppProxyHandle(std::static_pointer_cast(cppObj))); + + auto castCppObj = std::static_pointer_cast(cppObj); + std::unique_ptr> to_encapsulate(new CppProxyHandle(castCppObj)); jlong handle = static_cast(reinterpret_cast(to_encapsulate.get())); - jobject cppProxy = jniEnv->NewObject(data.m_cppProxyClass.clazz.get(), - data.m_cppProxyClass.constructor, - handle); + + jobject cppProxy = nullptr; + if (data.m_cppProxyClass.proxyClassName != castCppObj->jniProxyClassName()) { + // The cppObj is an instance of a subclass of the class associated with this JniInterface + // instance. Create a proxy object from the proxy class name associated with the + // cppObj object, instead of relying on this JniInterface's proxy class info. + CppProxyClassInfo tempProxyClassInfo{castCppObj->jniProxyClassName().c_str()}; + cppProxy = jniEnv->NewObject(tempProxyClassInfo.clazz.get(), + tempProxyClassInfo.constructor, + handle); + } else { + // Use the JniInterface's proxy class info, since the cppObj is the same type + // as the class associated with this JniInterface instance. + cppProxy = jniEnv->NewObject(data.m_cppProxyClass.clazz.get(), + data.m_cppProxyClass.constructor, + handle); + } + jniExceptionCheck(jniEnv); to_encapsulate.release(); + return { cppProxy, cppObj.get() }; } diff --git a/support-lib/objc/DJICppWrapperCache+Private.h b/support-lib/objc/DJICppWrapperCache+Private.h index 425460970..08cd30e49 100644 --- a/support-lib/objc/DJICppWrapperCache+Private.h +++ b/support-lib/objc/DJICppWrapperCache+Private.h @@ -16,8 +16,8 @@ // This header can only be imported to Objective-C++ source code! -#import #include +#include #include "../proxy_cache_interface.hpp" @@ -44,8 +44,9 @@ ObjcType * get_cpp_proxy_impl(const std::shared_ptr & cppRef) { typeid(cppRef), cppRef, [] (const std::shared_ptr & cppRef) -> std::pair { + auto castCppRef = std::static_pointer_cast(cppRef); return { - [[ObjcType alloc] initWithCpp:std::static_pointer_cast(cppRef)], + [((ObjcType *)[objc_getClass(castCppRef->objcTypeName().c_str()) alloc]) initWithCpp:castCppRef], cppRef.get() }; } From 3b88bc0cabedd3b967545f47302bc8cd4ad1d69c Mon Sep 17 00:00:00 2001 From: Mike Foster Date: Mon, 7 Mar 2016 08:01:11 -0500 Subject: [PATCH 2/7] Fix IdlParser's importFile path resolution. Converts the combination of the import file's parent path and the import string to a canonical File. The result of this is that a Djinni file can be imported by multiple Djinni files that are located in different subdirectories. --- src/source/parser.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/source/parser.scala b/src/source/parser.scala index a843368fb..94e481d61 100644 --- a/src/source/parser.scala +++ b/src/source/parser.scala @@ -41,12 +41,14 @@ private object IdlParser extends RegexParsers { def importFile: Parser[FileRef] = { - def fileParent:String = if (fileStack.top.getParent() != null) return fileStack.top.getParent() + "/" else return "" + def fileParent:String = if (fileStack.top.getParent() != null) return fileStack.top.getParent() + "/" else return "" ("@" ~> directive) ~ ("\"" ~> filePath <~ "\"") ^^ { case "import" ~ x => val newPath = fileParent + x - new IdlFileRef(new File(newPath)) + + def importFile = new File(newPath) + new IdlFileRef(importFile.getCanonicalFile) case "extern" ~ x => val newPath = fileParent + x new ExternFileRef(new File(newPath)) From ba2cdc3c692b1d08e69d0409deaa182fdfa3a58a Mon Sep 17 00:00:00 2001 From: Mike Foster Date: Thu, 24 Mar 2016 12:44:21 -0400 Subject: [PATCH 3/7] Adds interface inheritance support for interfaces implemented in Java and Objective-C. --- .../objc/TXSTextboxListener+Private.mm | 2 + src/source/JNIGenerator.scala | 104 ++++++++++-------- src/source/ObjcppGenerator.scala | 64 ++++++----- 3 files changed, 100 insertions(+), 70 deletions(-) diff --git a/example/generated-src/objc/TXSTextboxListener+Private.mm b/example/generated-src/objc/TXSTextboxListener+Private.mm index 655983807..40ceb14a0 100644 --- a/example/generated-src/objc/TXSTextboxListener+Private.mm +++ b/example/generated-src/objc/TXSTextboxListener+Private.mm @@ -16,6 +16,8 @@ { public: using Handle::Handle; + + // TextboxListener methods void update(const ::textsort::ItemList & c_items) override { @autoreleasepool { diff --git a/src/source/JNIGenerator.scala b/src/source/JNIGenerator.scala index 57e1fb222..7bf22123b 100644 --- a/src/source/JNIGenerator.scala +++ b/src/source/JNIGenerator.scala @@ -239,22 +239,33 @@ class JNIGenerator(spec: Spec) extends Generator(spec) { w.wl(s"JavaProxy(JniType j);") w.wl(s"~JavaProxy();") w.wl - for (m <- i.methods) { - val ret = cppMarshal.fqReturnType(m.ret) - val params = m.params.map(p => cppMarshal.fqParamType(p.ty) + " " + idCpp.local(p.ident)) - w.wl(s"$ret ${idCpp.method(m.ident)}${params.mkString("(", ", ", ")")} override;") + + def writeJavaProxyMethodDecls(w: IndentWriter, methods: Seq[Interface.Method]) { + for (m <- methods) { + val ret = cppMarshal.fqReturnType(m.ret) + val params = m.params.map(p => cppMarshal.fqParamType(p.ty) + " " + idCpp.local(p.ident)) + w.wl(s"$ret ${idCpp.method(m.ident)}${params.mkString("(", ", ", ")")} override;") + } } + writeJavaProxyMethodDecls(w, getInterfaceSuperMethods(i, idl)) + writeJavaProxyMethodDecls(w, i.methods) + w.wl w.wlOutdent(s"private:") w.wl(s"friend ::djinni::JniInterface<$cppSelf, ${withNs(Some(spec.jniNamespace), jniSelf)}>;") } w.wl w.wl(s"const ::djinni::GlobalRef clazz { ::djinni::jniFindClass(${q(classLookup)}) };") - for (m <- i.methods) { - val javaMethodName = idJava.method(m.ident) - val javaMethodSig = q(jniMarshal.javaMethodSignature(m.params, m.ret)) - w.wl(s"const jmethodID method_$javaMethodName { ::djinni::jniGetMethodID(clazz.get(), ${q(javaMethodName)}, $javaMethodSig) };") + + def writeJavaProxyJniMethods(w: IndentWriter, methods: Seq[Interface.Method]) { + for (m <- methods) { + val javaMethodName = idJava.method(m.ident) + val javaMethodSig = q(jniMarshal.javaMethodSignature(m.params, m.ret)) + w.wl(s"const jmethodID method_$javaMethodName { ::djinni::jniGetMethodID(clazz.get(), ${q(javaMethodName)}, $javaMethodSig) };") + } } + writeJavaProxyJniMethods(w, getInterfaceSuperMethods(i, idl)) + writeJavaProxyJniMethods(w, i.methods) } } } @@ -276,46 +287,51 @@ class JNIGenerator(spec: Spec) extends Generator(spec) { writeJniTypeParams(w, typeParams) w.wl(s"$jniSelfWithParams::JavaProxy::~JavaProxy() = default;") w.wl - for (m <- i.methods) { - val ret = cppMarshal.fqReturnType(m.ret) - val params = m.params.map(p => cppMarshal.fqParamType(p.ty) + " c_" + idCpp.local(p.ident)) - writeJniTypeParams(w, typeParams) - val methodNameAndSignature: String = s"${idCpp.method(m.ident)}${params.mkString("(", ", ", ")")}" - w.w(s"$ret $jniSelfWithParams::JavaProxy::$methodNameAndSignature").braced { - w.wl(s"auto jniEnv = ::djinni::jniGetThreadEnv();") - w.wl(s"::djinni::JniLocalScope jscope(jniEnv, 10);") - w.wl(s"const auto& data = ::djinni::JniClass<${withNs(Some(spec.jniNamespace), jniSelf)}>::get();") - val call = m.ret.fold("jniEnv->CallVoidMethod(")(r => "auto jret = " + toJniCall(r, (jt: String) => s"jniEnv->Call${jt}Method(")) - w.w(call) - val javaMethodName = idJava.method(m.ident) - w.w(s"Handle::get().get(), data.method_$javaMethodName") - if(m.params.nonEmpty){ - w.wl(",") - writeAlignedCall(w, " " * call.length(), m.params, ")", p => { - val param = jniMarshal.fromCpp(p.ty, "c_" + idCpp.local(p.ident)) - s"::djinni::get($param)" + + def writeJavaProxyMethodImpls(w: IndentWriter, methods: Seq[Interface.Method]) { + for (m <- methods) { + val ret = cppMarshal.fqReturnType(m.ret) + val params = m.params.map(p => cppMarshal.fqParamType(p.ty) + " c_" + idCpp.local(p.ident)) + writeJniTypeParams(w, typeParams) + val methodNameAndSignature: String = s"${idCpp.method(m.ident)}${params.mkString("(", ", ", ")")}" + w.w(s"$ret $jniSelfWithParams::JavaProxy::$methodNameAndSignature").braced { + w.wl(s"auto jniEnv = ::djinni::jniGetThreadEnv();") + w.wl(s"::djinni::JniLocalScope jscope(jniEnv, 10);") + w.wl(s"const auto& data = ::djinni::JniClass<${withNs(Some(spec.jniNamespace), jniSelf)}>::get();") + val call = m.ret.fold("jniEnv->CallVoidMethod(")(r => "auto jret = " + toJniCall(r, (jt: String) => s"jniEnv->Call${jt}Method(")) + w.w(call) + val javaMethodName = idJava.method(m.ident) + w.w(s"Handle::get().get(), data.method_$javaMethodName") + if(m.params.nonEmpty){ + w.wl(",") + writeAlignedCall(w, " " * call.length(), m.params, ")", p => { + val param = jniMarshal.fromCpp(p.ty, "c_" + idCpp.local(p.ident)) + s"::djinni::get($param)" + }) + } + else + w.w(")") + w.wl(";") + w.wl(s"::djinni::jniExceptionCheck(jniEnv);") + m.ret.fold()(ty => { + (spec.cppNnCheckExpression, isInterface(ty.resolved)) match { + case (Some(check), true) => { + // We have a non-optional interface, assert that we're getting a non-null value + val javaParams = m.params.map(p => javaMarshal.fqParamType(p.ty) + " " + idJava.local(p.ident)) + val javaParamsString: String = javaParams.mkString("(", ",", ")") + val functionString: String = s"${javaMarshal.fqTypename(ident, i)}#$javaMethodName$javaParamsString" + w.wl(s"""DJINNI_ASSERT_MSG(jret, jniEnv, "Got unexpected null return value from function $functionString");""") + w.wl(s"return ${jniMarshal.toCpp(ty, "jret")};") + } + case _ => + } + w.wl(s"return ${jniMarshal.toCpp(ty, "jret")};") }) } - else - w.w(")") - w.wl(";") - w.wl(s"::djinni::jniExceptionCheck(jniEnv);") - m.ret.fold()(ty => { - (spec.cppNnCheckExpression, isInterface(ty.resolved)) match { - case (Some(check), true) => { - // We have a non-optional interface, assert that we're getting a non-null value - val javaParams = m.params.map(p => javaMarshal.fqParamType(p.ty) + " " + idJava.local(p.ident)) - val javaParamsString: String = javaParams.mkString("(", ",", ")") - val functionString: String = s"${javaMarshal.fqTypename(ident, i)}#$javaMethodName$javaParamsString" - w.wl(s"""DJINNI_ASSERT_MSG(jret, jniEnv, "Got unexpected null return value from function $functionString");""") - w.wl(s"return ${jniMarshal.toCpp(ty, "jret")};") - } - case _ => - } - w.wl(s"return ${jniMarshal.toCpp(ty, "jret")};") - }) } } + writeJavaProxyMethodImpls(w, getInterfaceSuperMethods(i, idl)) + writeJavaProxyMethodImpls(w, i.methods) } if (i.ext.cpp) { // Generate CEXPORT functions for JNI to call. diff --git a/src/source/ObjcppGenerator.scala b/src/source/ObjcppGenerator.scala index 7eef2bd12..0a803a7c8 100644 --- a/src/source/ObjcppGenerator.scala +++ b/src/source/ObjcppGenerator.scala @@ -165,7 +165,7 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { writeCppProxyMethods(w, i.methods, objcSelf, cppSelf) val superMethods = getInterfaceSuperMethods(i, idl) - if (!superMethods.isEmpty) { + if (superMethods.nonEmpty) { w.wl; w.wl(s"// ${objcppMarshal.superTypename(i).getOrElse("Super")} methods") writeCppProxyMethods(w, superMethods, objcSelf, cppSelf) } @@ -181,31 +181,14 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { w.bracedSemi { w.wlOutdent("public:") w.wl("using Handle::Handle;") - for (m <- i.methods) { - val ret = cppMarshal.fqReturnType(m.ret) - val params = m.params.map(p => cppMarshal.fqParamType(p.ty) + " c_" + idCpp.local(p.ident)) - w.wl(s"$ret ${idCpp.method(m.ident)}${params.mkString("(", ", ", ")")} override").braced { - w.w("@autoreleasepool").braced { - val ret = m.ret.fold("")(_ => "auto r = ") - val call = s"[Handle::get() ${idObjc.method(m.ident)}" - writeAlignedObjcCall(w, ret + call, m.params, "]", p => (idObjc.field(p.ident), s"(${objcppMarshal.fromCpp(p.ty, "c_" + idCpp.local(p.ident))})")) - w.wl(";") - m.ret.fold()(ty => { - if (spec.cppNnCheckExpression.nonEmpty && isInterface(ty.resolved)) { - // We have a non-optional interface, so assert that we're getting a non-null value - // before putting it into a non-null pointer - val stringWriter = new StringWriter() - writeObjcFuncDecl(m, new IndentWriter(stringWriter)) - val singleLineFunctionDecl = stringWriter.toString.replaceAll("\n *", " ") - val exceptionReason = s"Got unexpected null return value from function $objcSelf $singleLineFunctionDecl" - w.w(s"if (r == nil)").braced { - w.wl(s"""throw std::invalid_argument("$exceptionReason");""") - } - } - w.wl(s"return ${objcppMarshal.toCpp(ty, "r")};") - }) - } - } + + w.wl; w.wl(s"// $helperClass methods") + writeObjcProxyMethods(w, i.methods, objcSelf) + + val superMethods = getInterfaceSuperMethods(i, idl) + if (superMethods.nonEmpty) { + w.wl; w.wl(s"// ${cppMarshal.superTypename(i).getOrElse("Super")} methods") + writeObjcProxyMethods(w, superMethods, objcSelf) } } }) @@ -311,6 +294,35 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { } } + def writeObjcProxyMethods(w: IndentWriter, methods: Seq[Interface.Method], objcName: String) { + for (m <- methods) { + val ret = cppMarshal.fqReturnType(m.ret) + val params = m.params.map(p => cppMarshal.fqParamType(p.ty) + " c_" + idCpp.local(p.ident)) + w.wl(s"$ret ${idCpp.method(m.ident)}${params.mkString("(", ", ", ")")} override").braced { + w.w("@autoreleasepool").braced { + val ret = m.ret.fold("")(_ => "auto r = ") + val call = s"[Handle::get() ${idObjc.method(m.ident)}" + writeAlignedObjcCall(w, ret + call, m.params, "]", p => (idObjc.field(p.ident), s"(${objcppMarshal.fromCpp(p.ty, "c_" + idCpp.local(p.ident))})")) + w.wl(";") + m.ret.fold()(ty => { + if (spec.cppNnCheckExpression.nonEmpty && isInterface(ty.resolved)) { + // We have a non-optional interface, so assert that we're getting a non-null value + // before putting it into a non-null pointer + val stringWriter = new StringWriter() + writeObjcFuncDecl(m, new IndentWriter(stringWriter)) + val singleLineFunctionDecl = stringWriter.toString.replaceAll("\n *", " ") + val exceptionReason = s"Got unexpected null return value from function $objcName $singleLineFunctionDecl" + w.w(s"if (r == nil)").braced { + w.wl(s"""throw std::invalid_argument("$exceptionReason");""") + } + } + w.wl(s"return ${objcppMarshal.toCpp(ty, "r")};") + }) + } + } + } + } + override def generateRecord(origin: String, ident: Ident, doc: Doc, params: Seq[TypeParam], r: Record) { val refs = new ObjcRefs() for (c <- r.consts) From c5056a0c72608ff66740d8fd93c34256e5b028e1 Mon Sep 17 00:00:00 2001 From: Mike Foster Date: Thu, 5 May 2016 13:50:04 -0400 Subject: [PATCH 4/7] Changes the way Objective-C's toCpp methods access the associated cppRef. This is to support interface inheritance. The change ensures the appropriate cppRef is referenced for subtypes. --- Makefile | 2 +- .../objc/TXSSortItems+Private.mm | 7 ++++++- .../objc/TextSort.xcodeproj/project.pbxproj | 5 ++++- .../xcshareddata/xcschemes/TextSort.xcscheme | 19 ++++++++++++------- example/objc/TextSort/TextSort-Info.plist | 2 +- src/source/ObjcppGenerator.scala | 12 +++++++++++- 6 files changed, 35 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index a4068331e..4cffa1427 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ example_ios: ./build_ios/example/libtextsort.xcodeproj -scheme TextSort \ -configuration 'Debug' \ -sdk iphonesimulator \ - -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.2' + -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' # this target implicitly depends on GypAndroid.mk since gradle will try to make it example_android: GypAndroid.mk diff --git a/example/generated-src/objc/TXSSortItems+Private.mm b/example/generated-src/objc/TXSSortItems+Private.mm index 10bf6c74e..407d371e9 100644 --- a/example/generated-src/objc/TXSSortItems+Private.mm +++ b/example/generated-src/objc/TXSSortItems+Private.mm @@ -32,6 +32,11 @@ - (id)initWithCpp:(const std::shared_ptr<::textsort::SortItems>&)cppRef return self; } +- (const std::shared_ptr<::textsort::SortItems>&) cppRef +{ + return _cppRefHandle.get(); +} + // TXSSortItems methods - (void)sort:(TXSSortOrder)order @@ -63,7 +68,7 @@ + (nonnull TXSItemList *)runSort:(nonnull TXSItemList *)items { if (!objc) { return nullptr; } - return objc->_cppRefHandle.get(); + return [objc cppRef]; } auto SortItems::fromCppOpt(const CppOptType& cpp) -> ObjcType diff --git a/example/objc/TextSort.xcodeproj/project.pbxproj b/example/objc/TextSort.xcodeproj/project.pbxproj index 8f534fb5f..f5d1562d3 100644 --- a/example/objc/TextSort.xcodeproj/project.pbxproj +++ b/example/objc/TextSort.xcodeproj/project.pbxproj @@ -150,7 +150,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = TXS; - LastUpgradeCheck = 0510; + LastUpgradeCheck = 0730; ORGANIZATIONNAME = "Dropbox, Inc."; }; buildConfigurationList = 65834DD819AC599E0061AD3F /* Build configuration list for PBXProject "TextSort" */; @@ -236,6 +236,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -301,6 +302,7 @@ GCC_PREFIX_HEADER = "TextSort/TextSort-Prefix.pch"; INFOPLIST_FILE = "TextSort/TextSort-Info.plist"; LIBRARY_SEARCH_PATHS = "$(inherited)"; + PRODUCT_BUNDLE_IDENTIFIER = "Dropbox.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = 1; WRAPPER_EXTENSION = app; @@ -316,6 +318,7 @@ GCC_PREFIX_HEADER = "TextSort/TextSort-Prefix.pch"; INFOPLIST_FILE = "TextSort/TextSort-Info.plist"; LIBRARY_SEARCH_PATHS = "$(inherited)"; + PRODUCT_BUNDLE_IDENTIFIER = "Dropbox.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = 1; WRAPPER_EXTENSION = app; diff --git a/example/objc/TextSort.xcodeproj/xcshareddata/xcschemes/TextSort.xcscheme b/example/objc/TextSort.xcodeproj/xcshareddata/xcschemes/TextSort.xcscheme index f3120ac80..b5c1ee841 100644 --- a/example/objc/TextSort.xcodeproj/xcshareddata/xcschemes/TextSort.xcscheme +++ b/example/objc/TextSort.xcodeproj/xcshareddata/xcschemes/TextSort.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -38,17 +38,21 @@ ReferencedContainer = "container:TextSort.xcodeproj"> + + - + - + CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - Dropbox.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/src/source/ObjcppGenerator.scala b/src/source/ObjcppGenerator.scala index 0a803a7c8..fa8f0f2e3 100644 --- a/src/source/ObjcppGenerator.scala +++ b/src/source/ObjcppGenerator.scala @@ -160,6 +160,11 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { } w.wl("return self;") } + w.wl + w.wl(s"- (const std::shared_ptr<$cppSelf>&) cppRef") + w.braced { + w.wl("return _cppRefHandle.get();") + } w.wl; w.wl(s"// $objcSelf methods") writeCppProxyMethods(w, i.methods, objcSelf, cppSelf) @@ -209,7 +214,12 @@ class ObjcppGenerator(spec: Spec) extends Generator(spec) { if (i.ext.cpp && !i.ext.objc) { // C++ only. In this case we generate a class instead of a protocol, so // we don't have to do any casting at all, just access cppRef directly. - w.wl("return " + nnCheck("objc->_cppRefHandle.get()") + ";") + // + // The cppRef is accessed through a getter to support interface inheritance. + // Accessing the cppRef through a getter ensures that the cppRef of subtypes + // will be returned. Accessing the ivar directly results in accessing the + // supertype's cppRef. + w.wl("return " + nnCheck("[objc cppRef]") + ";") //w.wl(s"return ${spec.cppNnCheckExpression.getOrElse("")}(objc->_cppRefHandle.get());") } else { // ObjC only, or ObjC and C++. From 7fcff60c1a184d01e5fbcee62fc6a4fc59baad23 Mon Sep 17 00:00:00 2001 From: Mike Foster Date: Thu, 28 Jul 2016 15:22:56 -0400 Subject: [PATCH 5/7] Removes the workaround for forward declarations. --- example/generated-src/cpp/sort_items.hpp | 4 ++-- example/generated-src/cpp/textbox_listener.hpp | 3 ++- src/source/CppGenerator.scala | 13 +++---------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/example/generated-src/cpp/sort_items.hpp b/example/generated-src/cpp/sort_items.hpp index 6ae2a960c..329a0023f 100644 --- a/example/generated-src/cpp/sort_items.hpp +++ b/example/generated-src/cpp/sort_items.hpp @@ -3,14 +3,14 @@ #pragma once -#include "item_list.hpp" -#include "sort_order.hpp" #include #include namespace textsort { class TextboxListener; +enum class sort_order; +struct ItemList; class SortItems { public: diff --git a/example/generated-src/cpp/textbox_listener.hpp b/example/generated-src/cpp/textbox_listener.hpp index f512f7471..cd0b93821 100644 --- a/example/generated-src/cpp/textbox_listener.hpp +++ b/example/generated-src/cpp/textbox_listener.hpp @@ -3,11 +3,12 @@ #pragma once -#include "item_list.hpp" #include namespace textsort { +struct ItemList; + class TextboxListener { public: virtual ~TextboxListener() {} diff --git a/src/source/CppGenerator.scala b/src/source/CppGenerator.scala index 99b7821b1..700c30e2a 100644 --- a/src/source/CppGenerator.scala +++ b/src/source/CppGenerator.scala @@ -276,19 +276,12 @@ class CppGenerator(spec: Spec) extends Generator(spec) { refs.hpp.add("#include ") // needed for std::string jniProxyClassName(); - // HACK: DISABLES FORWARD DECLARATIONS. - // - // FIXME: Forward declarations break the use of enums as keys in maps. - // - // Passing false instead of true for the find methods forwardDeclareOnly parameter - // disables the use of forward declarations. We'll leave them disabled until - // Dropbox has a solution. i.methods.map(m => { - m.params.map(p => refs.find(p.ty, false)) - m.ret.foreach((x)=>refs.find(x, false)) + m.params.map(p => refs.find(p.ty, true)) + m.ret.foreach((x)=>refs.find(x, true)) }) i.consts.map(c => { - refs.find(c.ty, false) + refs.find(c.ty, true) }) val self = marshal.typename(ident, i) From 49cab6d9270c0ee07071b7c9ad3ffd6dba829b76 Mon Sep 17 00:00:00 2001 From: Mike Foster Date: Wed, 10 Aug 2016 15:17:57 -0400 Subject: [PATCH 6/7] Merge dropbox/djinni commit '53236b6cde0476a47b851429a55bf5e95edd2c30' into master --- .../java/com/dropbox/textsort/ItemList.java | 2 +- .../java/com/dropbox/textsort/SortItems.java | 2 +- .../java/com/dropbox/textsort/SortOrder.java | 2 +- .../com/dropbox/textsort/TextboxListener.java | 2 +- example/generated-src/jni/NativeSortItems.cpp | 1 - .../objc/TXSSortItems+Private.mm | 12 +- .../generated-src/objc/TXSSortOrder+Private.h | 6 + .../objc/TXSTextboxListener+Private.mm | 1 + example/run_djinni.sh | 1 + src/.idea/encodings.xml | 7 +- src/.idea/sbt.xml | 6 + src/.idea/vcs.xml | 1 - src/source/CppMarshal.scala | 2 +- src/source/JNIMarshal.scala | 2 +- src/source/JavaGenerator.scala | 9 +- src/source/Main.scala | 8 + src/source/ObjcMarshal.scala | 4 +- src/source/ObjcppGenerator.scala | 47 +- src/source/ObjcppMarshal.scala | 11 +- src/source/generator.scala | 22 +- support-lib/jni/Marshal.hpp | 19 + support-lib/jni/djinni_support.cpp | 88 +- support-lib/jni/djinni_support.hpp | 3 + support-lib/objc/DJIError.h | 6 + support-lib/objc/DJIError.mm | 5 + support-lib/objc/DJIMarshal+Private.h | 48 + test-suite/djinni/common.djinni | 1 + test-suite/djinni/enum.djinni | 16 +- .../djinni/single_language_interfaces.djinni | 2 + test-suite/djinni/varnames.djinni | 11 + test-suite/djinni/wchar_test.djinni | 10 + test-suite/generated-src/cpp/Conflict.hpp | 29 + .../generated-src/cpp/_varname_interface_.hpp | 49 + .../generated-src/cpp/_varname_record_.hpp | 24 + .../generated-src/cpp/assorted_primitives.hpp | 2 +- .../generated-src/cpp/client_interface.hpp | 29 +- .../cpp/client_returned_record.hpp | 2 +- .../generated-src/cpp/conflict_user.hpp | 28 + test-suite/generated-src/cpp/constants.hpp | 2 +- .../generated-src/cpp/constants_interface.hpp | 29 +- .../generated-src/cpp/cpp_exception.hpp | 28 + .../cpp/enum_usage_interface.hpp | 58 ++ .../generated-src/cpp/enum_usage_record.hpp | 35 + .../generated-src/cpp/extern_interface_1.hpp | 28 + .../generated-src/cpp/extern_interface_2.hpp | 28 + .../generated-src/cpp/first_listener.hpp | 29 + .../generated-src/cpp/java_only_listener.hpp | 29 + .../generated-src/cpp/listener_caller.hpp | 28 + .../generated-src/cpp/objc_only_listener.hpp | 29 + .../generated-src/cpp/opt_color_record.hpp | 20 - test-suite/generated-src/cpp/return_one.hpp | 28 + test-suite/generated-src/cpp/return_two.hpp | 28 + .../cpp/reverse_client_interface.hpp | 29 +- .../generated-src/cpp/second_listener.hpp | 29 + .../generated-src/cpp/test_duration.hpp | 29 +- test-suite/generated-src/cpp/test_helpers.hpp | 29 +- test-suite/generated-src/cpp/user_token.hpp | 27 + .../cpp/uses_single_language_listeners.hpp | 32 + .../generated-src/cpp/wchar_test_helpers.hpp | 52 + .../generated-src/cpp/wchar_test_rec.hpp | 19 + test-suite/generated-src/inFileList.txt | 41 +- .../com/dropbox/djinni/test/Conflict.java | 2 + .../com/dropbox/djinni/test/ConflictUser.java | 2 + .../djinni/test/ConstantsInterface.java | 2 + .../com/dropbox/djinni/test/CppException.java | 2 + .../djinni/test/EnumUsageInterface.java | 94 ++ .../dropbox/djinni/test/EnumUsageRecord.java | 74 ++ .../dropbox/djinni/test/ExternInterface1.java | 2 + .../dropbox/djinni/test/ListenerCaller.java | 2 + .../dropbox/djinni/test/OptColorRecord.java | 31 - .../com/dropbox/djinni/test/ReturnOne.java | 2 + .../com/dropbox/djinni/test/ReturnTwo.java | 2 + .../djinni/test/ReverseClientInterface.java | 2 + .../com/dropbox/djinni/test/TestDuration.java | 2 + .../com/dropbox/djinni/test/TestHelpers.java | 2 + .../com/dropbox/djinni/test/UserToken.java | 2 + .../test/UsesSingleLanguageListeners.java | 24 + .../dropbox/djinni/test/VarnameInterface.java | 58 ++ .../dropbox/djinni/test/VarnameRecord.java | 35 + .../dropbox/djinni/test/WcharTestHelpers.java | 46 + .../com/dropbox/djinni/test/WcharTestRec.java | 31 + .../jni/NativeClientInterface.cpp | 1 - .../generated-src/jni/NativeCppException.cpp | 1 - .../jni/NativeEnumUsageInterface.cpp | 122 +++ .../jni/NativeEnumUsageInterface.hpp | 54 ++ .../jni/NativeEnumUsageRecord.cpp | 37 + .../jni/NativeEnumUsageRecord.hpp | 36 + .../jni/NativeListenerCaller.cpp | 1 - .../jni/NativeOptColorRecord.cpp | 29 - .../jni/NativeOptColorRecord.hpp | 32 - .../generated-src/jni/NativeReturnOne.cpp | 1 - .../generated-src/jni/NativeReturnTwo.cpp | 1 - .../jni/NativeReverseClientInterface.cpp | 1 - .../jni/NativeUsesSingleLanguageListeners.cpp | 36 + .../jni/NativeUsesSingleLanguageListeners.hpp | 4 + .../jni/NativeVarnameInterface.cpp | 42 + .../jni/NativeVarnameInterface.hpp | 32 + .../generated-src/jni/NativeVarnameRecord.cpp | 28 + .../generated-src/jni/NativeVarnameRecord.hpp | 32 + .../jni/NativeWcharTestHelpers.cpp | 59 ++ .../jni/NativeWcharTestHelpers.hpp | 32 + .../generated-src/jni/NativeWcharTestRec.cpp | 28 + .../generated-src/jni/NativeWcharTestRec.hpp | 32 + .../objc/DBClientInterface+Private.mm | 32 +- .../generated-src/objc/DBClientInterface.h | 2 +- .../generated-src/objc/DBColor+Private.h | 6 + .../generated-src/objc/DBConflict+Private.mm | 10 +- .../objc/DBConflictUser+Private.mm | 18 +- .../objc/DBConstantsInterface+Private.mm | 10 +- .../objc/DBCppException+Private.mm | 19 +- .../objc/DBEnumUsageInterface+Private.h | 31 + .../objc/DBEnumUsageInterface+Private.mm | 152 +++ .../generated-src/objc/DBEnumUsageInterface.h | 20 + ...+Private.h => DBEnumUsageRecord+Private.h} | 14 +- .../objc/DBEnumUsageRecord+Private.mm | 30 + .../generated-src/objc/DBEnumUsageRecord.h | 29 + .../generated-src/objc/DBEnumUsageRecord.mm | 43 + .../objc/DBExtendedRecord+Private.mm | 1 - .../objc/DBExternInterface1+Private.mm | 14 +- .../objc/DBExternInterface2+Private.mm | 7 +- .../generated-src/objc/DBExternInterface2.h | 2 +- .../DBExternRecordWithDerivings+Private.mm | 2 +- .../objc/DBFirstListener+Private.mm | 3 + .../generated-src/objc/DBFirstListener.h | 2 +- .../objc/DBJavaOnlyListener+Private.mm | 7 +- .../objc/DBListenerCaller+Private.mm | 17 +- .../objc/DBObjcOnlyListener+Private.mm | 3 + .../generated-src/objc/DBObjcOnlyListener.h | 2 +- .../objc/DBOptColorRecord+Private.mm | 21 - .../generated-src/objc/DBOptColorRecord.h | 13 - .../generated-src/objc/DBOptColorRecord.mm | 27 - .../generated-src/objc/DBReturnOne+Private.mm | 19 +- .../generated-src/objc/DBReturnTwo+Private.mm | 19 +- .../objc/DBReverseClientInterface+Private.mm | 27 +- .../objc/DBSecondListener+Private.mm | 3 + .../generated-src/objc/DBSecondListener.h | 2 +- .../objc/DBTestDuration+Private.mm | 90 +- .../objc/DBTestHelpers+Private.mm | 83 +- .../generated-src/objc/DBUserToken+Private.mm | 18 +- test-suite/generated-src/objc/DBUserToken.h | 2 +- .../DBUsesSingleLanguageListeners+Private.mm | 40 +- .../objc/DBUsesSingleLanguageListeners.h | 10 +- .../objc/DBVarnameInterface+Private.h | 31 + .../objc/DBVarnameInterface+Private.mm | 74 ++ .../generated-src/objc/DBVarnameInterface.h | 15 + .../objc/DBVarnameRecord+Private.h | 24 + .../objc/DBVarnameRecord+Private.mm | 21 + .../generated-src/objc/DBVarnameRecord.h | 17 + .../generated-src/objc/DBVarnameRecord.mm | 27 + .../objc/DBWcharTestHelpers+Private.h | 31 + .../objc/DBWcharTestHelpers+Private.mm | 89 ++ .../generated-src/objc/DBWcharTestHelpers.h | 18 + .../objc/DBWcharTestRec+Private.h | 24 + .../objc/DBWcharTestRec+Private.mm | 21 + .../generated-src/objc/DBWcharTestRec.h | 12 + .../generated-src/objc/DBWcharTestRec.mm | 27 + test-suite/generated-src/outFileList.txt | 39 +- test-suite/handwritten-src/cpp/optional.hpp | 891 ++++++++++++++++++ .../cpp/wchar_test_helpers.cpp | 30 + .../com/dropbox/djinni/test/AllTests.java | 1 + .../com/dropbox/djinni/test/WcharTest.java | 16 + .../handwritten-src/objc/tests/DBWcharTests.m | 33 + test-suite/java/CMakeLists.txt | 2 +- .../DjinniObjcTest.xcodeproj/project.pbxproj | 176 +++- test-suite/run_djinni.sh | 55 +- 165 files changed, 4333 insertions(+), 455 deletions(-) create mode 100644 example/generated-src/objc/TXSSortOrder+Private.h create mode 100644 test-suite/djinni/varnames.djinni create mode 100644 test-suite/djinni/wchar_test.djinni create mode 100644 test-suite/generated-src/cpp/_varname_interface_.hpp create mode 100644 test-suite/generated-src/cpp/_varname_record_.hpp create mode 100644 test-suite/generated-src/cpp/enum_usage_interface.hpp create mode 100644 test-suite/generated-src/cpp/enum_usage_record.hpp delete mode 100644 test-suite/generated-src/cpp/opt_color_record.hpp create mode 100644 test-suite/generated-src/cpp/wchar_test_helpers.hpp create mode 100644 test-suite/generated-src/cpp/wchar_test_rec.hpp create mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/EnumUsageInterface.java create mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/EnumUsageRecord.java delete mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/OptColorRecord.java create mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/VarnameInterface.java create mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/VarnameRecord.java create mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/WcharTestHelpers.java create mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/WcharTestRec.java create mode 100644 test-suite/generated-src/jni/NativeEnumUsageInterface.cpp create mode 100644 test-suite/generated-src/jni/NativeEnumUsageInterface.hpp create mode 100644 test-suite/generated-src/jni/NativeEnumUsageRecord.cpp create mode 100644 test-suite/generated-src/jni/NativeEnumUsageRecord.hpp delete mode 100644 test-suite/generated-src/jni/NativeOptColorRecord.cpp delete mode 100644 test-suite/generated-src/jni/NativeOptColorRecord.hpp create mode 100644 test-suite/generated-src/jni/NativeVarnameInterface.cpp create mode 100644 test-suite/generated-src/jni/NativeVarnameInterface.hpp create mode 100644 test-suite/generated-src/jni/NativeVarnameRecord.cpp create mode 100644 test-suite/generated-src/jni/NativeVarnameRecord.hpp create mode 100644 test-suite/generated-src/jni/NativeWcharTestHelpers.cpp create mode 100644 test-suite/generated-src/jni/NativeWcharTestHelpers.hpp create mode 100644 test-suite/generated-src/jni/NativeWcharTestRec.cpp create mode 100644 test-suite/generated-src/jni/NativeWcharTestRec.hpp create mode 100644 test-suite/generated-src/objc/DBColor+Private.h create mode 100644 test-suite/generated-src/objc/DBEnumUsageInterface+Private.h create mode 100644 test-suite/generated-src/objc/DBEnumUsageInterface+Private.mm create mode 100644 test-suite/generated-src/objc/DBEnumUsageInterface.h rename test-suite/generated-src/objc/{DBOptColorRecord+Private.h => DBEnumUsageRecord+Private.h} (59%) create mode 100644 test-suite/generated-src/objc/DBEnumUsageRecord+Private.mm create mode 100644 test-suite/generated-src/objc/DBEnumUsageRecord.h create mode 100644 test-suite/generated-src/objc/DBEnumUsageRecord.mm delete mode 100644 test-suite/generated-src/objc/DBOptColorRecord+Private.mm delete mode 100644 test-suite/generated-src/objc/DBOptColorRecord.h delete mode 100644 test-suite/generated-src/objc/DBOptColorRecord.mm create mode 100644 test-suite/generated-src/objc/DBVarnameInterface+Private.h create mode 100644 test-suite/generated-src/objc/DBVarnameInterface+Private.mm create mode 100644 test-suite/generated-src/objc/DBVarnameInterface.h create mode 100644 test-suite/generated-src/objc/DBVarnameRecord+Private.h create mode 100644 test-suite/generated-src/objc/DBVarnameRecord+Private.mm create mode 100644 test-suite/generated-src/objc/DBVarnameRecord.h create mode 100644 test-suite/generated-src/objc/DBVarnameRecord.mm create mode 100644 test-suite/generated-src/objc/DBWcharTestHelpers+Private.h create mode 100644 test-suite/generated-src/objc/DBWcharTestHelpers+Private.mm create mode 100644 test-suite/generated-src/objc/DBWcharTestHelpers.h create mode 100644 test-suite/generated-src/objc/DBWcharTestRec+Private.h create mode 100644 test-suite/generated-src/objc/DBWcharTestRec+Private.mm create mode 100644 test-suite/generated-src/objc/DBWcharTestRec.h create mode 100644 test-suite/generated-src/objc/DBWcharTestRec.mm create mode 100644 test-suite/handwritten-src/cpp/optional.hpp create mode 100644 test-suite/handwritten-src/cpp/wchar_test_helpers.cpp create mode 100644 test-suite/handwritten-src/java/com/dropbox/djinni/test/WcharTest.java create mode 100644 test-suite/handwritten-src/objc/tests/DBWcharTests.m diff --git a/example/generated-src/java/com/dropbox/textsort/ItemList.java b/example/generated-src/java/com/dropbox/textsort/ItemList.java index 41aa543eb..900eaa377 100644 --- a/example/generated-src/java/com/dropbox/textsort/ItemList.java +++ b/example/generated-src/java/com/dropbox/textsort/ItemList.java @@ -7,7 +7,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -public final class ItemList { +/*package*/ final class ItemList { /*package*/ final ArrayList mItems; diff --git a/example/generated-src/java/com/dropbox/textsort/SortItems.java b/example/generated-src/java/com/dropbox/textsort/SortItems.java index 6c1df533a..177389bd1 100644 --- a/example/generated-src/java/com/dropbox/textsort/SortItems.java +++ b/example/generated-src/java/com/dropbox/textsort/SortItems.java @@ -7,7 +7,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -public abstract class SortItems { +/*package*/ abstract class SortItems { /** For the iOS / Android demo */ public abstract void sort(@Nonnull SortOrder order, @Nonnull ItemList items); diff --git a/example/generated-src/java/com/dropbox/textsort/SortOrder.java b/example/generated-src/java/com/dropbox/textsort/SortOrder.java index 28ceb785e..906b9a171 100644 --- a/example/generated-src/java/com/dropbox/textsort/SortOrder.java +++ b/example/generated-src/java/com/dropbox/textsort/SortOrder.java @@ -6,7 +6,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -public enum SortOrder { +/*package*/ enum SortOrder { ASCENDING, DESCENDING, RANDOM, diff --git a/example/generated-src/java/com/dropbox/textsort/TextboxListener.java b/example/generated-src/java/com/dropbox/textsort/TextboxListener.java index 231f15c08..d67afe271 100644 --- a/example/generated-src/java/com/dropbox/textsort/TextboxListener.java +++ b/example/generated-src/java/com/dropbox/textsort/TextboxListener.java @@ -6,6 +6,6 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -public abstract class TextboxListener { +/*package*/ abstract class TextboxListener { public abstract void update(@Nonnull ItemList items); } diff --git a/example/generated-src/jni/NativeSortItems.cpp b/example/generated-src/jni/NativeSortItems.cpp index d612062bb..03162cc5e 100644 --- a/example/generated-src/jni/NativeSortItems.cpp +++ b/example/generated-src/jni/NativeSortItems.cpp @@ -3,7 +3,6 @@ #include "NativeSortItems.hpp" // my header #include "NativeItemList.hpp" -#include "NativeSortItems.hpp" #include "NativeSortOrder.hpp" #include "NativeTextboxListener.hpp" diff --git a/example/generated-src/objc/TXSSortItems+Private.mm b/example/generated-src/objc/TXSSortItems+Private.mm index 407d371e9..dab7da356 100644 --- a/example/generated-src/objc/TXSSortItems+Private.mm +++ b/example/generated-src/objc/TXSSortItems+Private.mm @@ -5,11 +5,11 @@ #import "TXSSortItems.h" #import "DJICppWrapperCache+Private.h" #import "DJIError.h" -#import "DJIMarshal+Private.h" #import "TXSItemList+Private.h" -#import "TXSSortItems+Private.h" +#import "TXSSortOrder+Private.h" #import "TXSTextboxListener+Private.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -49,15 +49,15 @@ - (void)sort:(TXSSortOrder)order + (nullable TXSSortItems *)createWithListener:(nullable id)listener { try { - auto r = ::textsort::SortItems::create_with_listener(::djinni_generated::TextboxListener::toCpp(listener)); - return ::djinni_generated::SortItems::fromCpp(r); + auto objcpp_result_ = ::textsort::SortItems::create_with_listener(::djinni_generated::TextboxListener::toCpp(listener)); + return ::djinni_generated::SortItems::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull TXSItemList *)runSort:(nonnull TXSItemList *)items { try { - auto r = ::textsort::SortItems::run_sort(::djinni_generated::ItemList::toCpp(items)); - return ::djinni_generated::ItemList::fromCpp(r); + auto objcpp_result_ = ::textsort::SortItems::run_sort(::djinni_generated::ItemList::toCpp(items)); + return ::djinni_generated::ItemList::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } diff --git a/example/generated-src/objc/TXSSortOrder+Private.h b/example/generated-src/objc/TXSSortOrder+Private.h new file mode 100644 index 000000000..df2a08421 --- /dev/null +++ b/example/generated-src/objc/TXSSortOrder+Private.h @@ -0,0 +1,6 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from example.djinni + +#include "sort_order.hpp" +#import "DJIMarshal+Private.h" + diff --git a/example/generated-src/objc/TXSTextboxListener+Private.mm b/example/generated-src/objc/TXSTextboxListener+Private.mm index 40ceb14a0..276faac4d 100644 --- a/example/generated-src/objc/TXSTextboxListener+Private.mm +++ b/example/generated-src/objc/TXSTextboxListener+Private.mm @@ -5,6 +5,7 @@ #import "TXSTextboxListener.h" #import "DJIObjcWrapperCache+Private.h" #import "TXSItemList+Private.h" +#include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); diff --git a/example/run_djinni.sh b/example/run_djinni.sh index 61a4e4b04..334d8beeb 100755 --- a/example/run_djinni.sh +++ b/example/run_djinni.sh @@ -53,6 +53,7 @@ fi "$base_dir/../src/run-assume-built" \ --java-out "$temp_out/java" \ --java-package $java_package \ + --java-class-access-modifier "package" \ --java-nullable-annotation "javax.annotation.CheckForNull" \ --java-nonnull-annotation "javax.annotation.Nonnull" \ --ident-java-field mFooBar \ diff --git a/src/.idea/encodings.xml b/src/.idea/encodings.xml index e206d70d8..f75895965 100644 --- a/src/.idea/encodings.xml +++ b/src/.idea/encodings.xml @@ -1,5 +1,6 @@ - - - + + + + \ No newline at end of file diff --git a/src/.idea/sbt.xml b/src/.idea/sbt.xml index 86e0431a5..f79f3f84a 100644 --- a/src/.idea/sbt.xml +++ b/src/.idea/sbt.xml @@ -13,6 +13,12 @@ diff --git a/src/.idea/vcs.xml b/src/.idea/vcs.xml index 075f87f36..6c0b86358 100644 --- a/src/.idea/vcs.xml +++ b/src/.idea/vcs.xml @@ -1,7 +1,6 @@ - \ No newline at end of file diff --git a/src/source/CppMarshal.scala b/src/source/CppMarshal.scala index 797aef792..b7ba214e7 100644 --- a/src/source/CppMarshal.scala +++ b/src/source/CppMarshal.scala @@ -150,7 +150,7 @@ class CppMarshal(spec: Spec) extends Marshal(spec) { } def base(m: Meta): String = m match { case p: MPrimitive => p.cName - case MString => "std::string" + case MString => if (spec.cppUseWideStrings) "std::wstring" else "std::string" case MDate => "std::chrono::system_clock::time_point" case MBinary => "std::vector" case MOptional => spec.cppOptionalTemplate diff --git a/src/source/JNIMarshal.scala b/src/source/JNIMarshal.scala index af6c2d52b..e9aaab342 100644 --- a/src/source/JNIMarshal.scala +++ b/src/source/JNIMarshal.scala @@ -98,7 +98,7 @@ class JNIMarshal(spec: Spec) extends Marshal(spec) { } case MOptional => "Optional" case MBinary => "Binary" - case MString => "String" + case MString => if (spec.cppUseWideStrings) "WString" else "String" case MDate => "Date" case MList => "List" case MSet => "Set" diff --git a/src/source/JavaGenerator.scala b/src/source/JavaGenerator.scala index 6d19dc5b4..5795ed9e4 100644 --- a/src/source/JavaGenerator.scala +++ b/src/source/JavaGenerator.scala @@ -29,6 +29,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { val javaAnnotationHeader = spec.javaAnnotation.map(pkg => '@' + pkg.split("\\.").last) val javaNullableAnnotation = spec.javaNullableAnnotation.map(pkg => '@' + pkg.split("\\.").last) val javaNonnullAnnotation = spec.javaNonnullAnnotation.map(pkg => '@' + pkg.split("\\.").last) + val javaClassAccessModifierString = JavaAccessModifier.getCodeGenerationString(spec.javaClassAccessModifier) val marshal = new JavaMarshal(spec) class JavaRefs() { @@ -109,7 +110,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { writeJavaFile(ident, origin, refs.java, w => { writeDoc(w, doc) javaAnnotationHeader.foreach(w.wl) - w.w(s"public enum ${marshal.typename(ident, e)}").braced { + w.w(s"${javaClassAccessModifierString}enum ${marshal.typename(ident, e)}").braced { for (o <- e.options) { writeDoc(w, o.doc) w.wl(idJava.enum(o.ident) + ",") @@ -150,7 +151,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { // In java we need to add an "extends Type" to a class to subclass it. val extendsDef = if (superTypename.isDefined) " extends " + superTypename.get else "" - w.w(s"public abstract class $javaClass$typeParamList$extendsDef").braced { + w.w(s"${javaClassAccessModifierString}abstract class $javaClass$typeParamList$extendsDef").braced { val skipFirst = SkipFirst() generateJavaConstants(w, i.consts) @@ -237,7 +238,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { r.fields.foreach(f => refs.find(f.ty)) val javaName = if (r.ext.java) (ident.name + "_base") else ident.name - val javaFinal = if (!r.ext.java && spec.javaUseFinalForRecord) " final" else "" + val javaFinal = if (!r.ext.java && spec.javaUseFinalForRecord) "final " else "" writeJavaFile(javaName, origin, refs.java, w => { writeDoc(w, doc) @@ -250,7 +251,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { } else { "" } - w.w(s"public$javaFinal class ${self + javaTypeParams(params)}$comparableFlag").braced { + w.w(s"${javaClassAccessModifierString}${javaFinal}class ${self + javaTypeParams(params)}$comparableFlag").braced { w.wl generateJavaConstants(w, r.consts) // Field definitions. diff --git a/src/source/Main.scala b/src/source/Main.scala index 07ab15810..8932bb7a4 100644 --- a/src/source/Main.scala +++ b/src/source/Main.scala @@ -35,8 +35,10 @@ object Main { var cppNnHeader: Option[String] = None var cppNnType: Option[String] = None var cppNnCheckExpression: Option[String] = None + var cppUseWideStrings: Boolean = false var javaOutFolder: Option[File] = None var javaPackage: Option[String] = None + var javaClassAccessModifier: JavaAccessModifier.Value = JavaAccessModifier.Public var javaCppException: Option[String] = None var javaAnnotation: Option[String] = None var javaNullableAnnotation: Option[String] = None @@ -98,6 +100,8 @@ object Main { .text("The output for the Java files (Generator disabled if unspecified).") opt[String]("java-package").valueName("...").foreach(x => javaPackage = Some(x)) .text("The package name to use for generated Java classes.") + opt[JavaAccessModifier.Value]("java-class-access-modifier").valueName("").foreach(x => javaClassAccessModifier = x) + .text("The access modifier to use for generated Java classes (default: public).") opt[String]("java-cpp-exception").valueName("").foreach(x => javaCppException = Some(x)) .text("The type for translated C++ exceptions in Java (default: java.lang.RuntimeException that is not checked)") opt[String]("java-annotation").valueName("").foreach(x => javaAnnotation = Some(x)) @@ -133,6 +137,8 @@ object Main { .text("The type to use for non-nullable pointers (as a substitute for std::shared_ptr)") opt[String]("cpp-nn-check-expression").valueName("
").foreach(x => cppNnCheckExpression = Some(x)) .text("The expression to use for building non-nullable pointers") + opt[Boolean]( "cpp-use-wide-strings").valueName("").foreach(x => cppUseWideStrings = x) + .text("Use wide strings in C++ code (default: false)") note("") opt[File]("jni-out").valueName("").foreach(x => jniOutFolder = Some(x)) .text("The folder for the JNI C++ output files (Generator disabled if unspecified).") @@ -274,6 +280,7 @@ object Main { val outSpec = Spec( javaOutFolder, javaPackage, + javaClassAccessModifier, javaIdentStyle, javaCppException, javaAnnotation, @@ -293,6 +300,7 @@ object Main { cppNnHeader, cppNnType, cppNnCheckExpression, + cppUseWideStrings, jniOutFolder, jniHeaderOutFolder, jniIncludePrefix, diff --git a/src/source/ObjcMarshal.scala b/src/source/ObjcMarshal.scala index 55d058878..6bdd0ed89 100644 --- a/src/source/ObjcMarshal.scala +++ b/src/source/ObjcMarshal.scala @@ -63,7 +63,7 @@ class ObjcMarshal(spec: Spec) extends Marshal(spec) { List(ImportRef(include(d.name))) case DInterface => val ext = d.body.asInstanceOf[Interface].ext - if (ext.cpp && !ext.objc) { + if (!ext.objc) { List(ImportRef(""), DeclRef(s"@class ${typename(d.name, d.body)};", None)) } else { @@ -124,7 +124,7 @@ class ObjcMarshal(spec: Spec) extends Marshal(spec) { case DRecord => (idObjc.ty(d.name), true) case DInterface => val ext = d.body.asInstanceOf[Interface].ext - if (ext.cpp && !ext.objc) + if (!ext.objc) (idObjc.ty(d.name), true) else (s"id<${idObjc.ty(d.name)}>", false) diff --git a/src/source/ObjcppGenerator.scala b/src/source/ObjcppGenerator.scala index 4972c04e6..e78d2630c 100644 --- a/src/source/ObjcppGenerator.scala +++ b/src/source/ObjcppGenerator.scala @@ -49,7 +49,11 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { private def arcAssert(w: IndentWriter) = w.wl("static_assert(__has_feature(objc_arc), " + q("Djinni requires ARC to be enabled for this file") + ");") override def generateEnum(origin: String, ident: Ident, doc: Doc, e: Enum) { - // No generation required + var imports = mutable.TreeSet[String]() + imports.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJIMarshal+Private.h")) + imports.add("!#include " + q(spec.objcppIncludeCppPrefix + spec.cppFileIdentStyle(ident) + "." + spec.cppHeaderExt)) + + writeObjcFile(objcppMarshal.privateHeaderName(ident.name), origin, imports, w => {} ) } def headerName(ident: String): String = idObjc.ty(ident) + "." + spec.objcHeaderExt @@ -81,6 +85,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { } refs.body.add("!#import " + q(spec.objcppIncludeObjcPrefix + headerName(ident))) + refs.body.add("!#import " + q(spec.objcppIncludePrefix + objcppMarshal.privateHeaderName(ident.name))) spec.cppNnHeader match { case Some(nnHdr) => refs.privHeader.add("#include " + nnHdr) @@ -121,16 +126,21 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { }) if (i.ext.cpp) { - refs.body.add("!#import " + q(spec.objcppIncludePrefix + objcppMarshal.privateHeaderName(ident.name))) refs.body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJICppWrapperCache+Private.h")) refs.body.add("#include ") refs.body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJIError.h")) refs.body.add("#include ") } + if (!spec.cppNnType.isEmpty || !spec.cppNnCheckExpression.nonEmpty) { + refs.body.add("#include ") + } if (i.ext.objc) { refs.body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJIObjcWrapperCache+Private.h")) - refs.body.add("!#import " + q(spec.objcppIncludePrefix + objcppMarshal.privateHeaderName(ident.name))) + } + + if (!i.ext.cpp && !i.ext.objc) { + refs.body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJIError.h")) } writeObjcFile(privateBodyName(ident.name), origin, refs.body, w => { @@ -225,7 +235,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { // supertype's cppRef. w.wl("return " + nnCheck("[objc cppRef]") + ";") //w.wl(s"return ${spec.cppNnCheckExpression.getOrElse("")}(objc->_cppRefHandle.get());") - } else { + } else if (i.ext.cpp || i.ext.objc) { // ObjC only, or ObjC and C++. if (i.ext.cpp) { // If it could be implemented in C++, we might have to unwrap a proxy object. @@ -236,6 +246,9 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { } val getProxyExpr = s"::djinni::get_objc_proxy(objc)" w.wl(s"return ${nnCheck(getProxyExpr)};") + } else { + // Neither ObjC nor C++. Unusable, but generate compilable code. + w.wl("DJINNI_UNIMPLEMENTED(@\"Interface not implementable in any language.\");") } } w.wl @@ -248,7 +261,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { // ObjC only. In this case we *must* unwrap a proxy object - the dynamic_cast will // throw bad_cast if we gave it something of the wrong type. w.wl(s"return dynamic_cast(*cpp).Handle::get();") - } else { + } else if (i.ext.objc || i.ext.cpp) { // C++ only, or C++ and ObjC. if (i.ext.objc) { // If it could be implemented in ObjC, we might have to unwrap a proxy object. @@ -257,6 +270,9 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { } } w.wl(s"return ::djinni::get_cpp_proxy<$objcSelf>(cpp);") + } else { + // Neither ObjC nor C++. Unusable, but generate compilable code. + w.wl("DJINNI_UNIMPLEMENTED(@\"Interface not implementable in any language.\");") } } }) @@ -294,12 +310,12 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { } } }) - val ret = m.ret.fold("")(_ => "auto r = ") + val ret = m.ret.fold("")(_ => "auto objcpp_result_ = ") val call = ret + (if (!m.static) "_cppRefHandle.get()->" else cppName + "::") + idCpp.method(m.ident) + "(" writeAlignedCall(w, call, m.params, ")", p => objcppMarshal.toCpp(p.ty, idObjc.local(p.ident.name))) w.wl(";") - m.ret.fold()(r => w.wl(s"return ${objcppMarshal.fromCpp(r, "r")};")) + m.ret.fold()(r => w.wl(s"return ${objcppMarshal.fromCpp(r, "objcpp_result_")};")) } } } @@ -311,7 +327,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { val params = m.params.map(p => cppMarshal.fqParamType(p.ty) + " c_" + idCpp.local(p.ident)) w.wl(s"$ret ${idCpp.method(m.ident)}${params.mkString("(", ", ", ")")} override").braced { w.w("@autoreleasepool").braced { - val ret = m.ret.fold("")(_ => "auto r = ") + val ret = m.ret.fold("")(_ => "auto objcpp_result_ = ") val call = s"[Handle::get() ${idObjc.method(m.ident)}" writeAlignedObjcCall(w, ret + call, m.params, "]", p => (idObjc.field(p.ident), s"(${objcppMarshal.fromCpp(p.ty, "c_" + idCpp.local(p.ident))})")) w.wl(";") @@ -327,7 +343,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { w.wl(s"""throw std::invalid_argument("$exceptionReason");""") } } - w.wl(s"return ${objcppMarshal.toCpp(ty, "r")};") + w.wl(s"return ${objcppMarshal.toCpp(ty, "objcpp_result_")};") }) } } @@ -408,9 +424,16 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { w.wl("// This file generated by Djinni from " + origin) w.wl if (refs.nonEmpty) { - // Ignore the ! in front of each line; used to put own headers to the top - // according to Objective-C style guide - refs.foreach(s => w.wl(if (s.charAt(0) == '!') s.substring(1) else s)) + var included = mutable.TreeSet[String](); + for (s <- refs) { + // Ignore the ! in front of each line; used to put own headers to the top + // according to Objective-C style guide + val include = if (s.charAt(0) == '!') s.substring(1) else s + if (!included.contains(include)) { + included += include + w.wl(include) + } + } w.wl } f(w) diff --git a/src/source/ObjcppMarshal.scala b/src/source/ObjcppMarshal.scala index bc0e6c223..20dcd4925 100644 --- a/src/source/ObjcppMarshal.scala +++ b/src/source/ObjcppMarshal.scala @@ -36,9 +36,7 @@ class ObjcppMarshal(spec: Spec) extends Marshal(spec) { case o: MOpaque => List(ImportRef(q(spec.objcBaseLibIncludePrefix + "DJIMarshal+Private.h"))) case d: MDef => d.defType match { - case DEnum => - List(ImportRef(q(spec.objcBaseLibIncludePrefix + "DJIMarshal+Private.h"))) - case DInterface => + case DEnum | DInterface => List(ImportRef(include(m))) case DRecord => val r = d.body.asInstanceOf[Record] @@ -50,10 +48,7 @@ class ObjcppMarshal(spec: Spec) extends Marshal(spec) { } def include(m: Meta) = m match { - case d: MDef => d.defType match { - case DEnum => q(spec.objcBaseLibIncludePrefix + "DJIMarshal+Private.h") - case _ => q(spec.objcppIncludePrefix + privateHeaderName(d.name)) - } + case d: MDef => q(spec.objcppIncludePrefix + privateHeaderName(d.name)) case _ => throw new AssertionError("not applicable") } @@ -81,7 +76,7 @@ class ObjcppMarshal(spec: Spec) extends Marshal(spec) { case MOptional => "Optional" case MBinary => "Binary" case MDate => "Date" - case MString => "String" + case MString => if (spec.cppUseWideStrings) "WString" else "String" case MList => "List" case MSet => "Set" case MMap => "Map" diff --git a/src/source/generator.scala b/src/source/generator.scala index 1e78ade2c..5232dd7c9 100644 --- a/src/source/generator.scala +++ b/src/source/generator.scala @@ -31,6 +31,7 @@ package object generatorTools { case class Spec( javaOutFolder: Option[File], javaPackage: Option[String], + javaClassAccessModifier: JavaAccessModifier.Value, javaIdentStyle: JavaIdentStyle, javaCppException: Option[String], javaAnnotation: Option[String], @@ -50,6 +51,7 @@ package object generatorTools { cppNnHeader: Option[String], cppNnType: Option[String], cppNnCheckExpression: Option[String], + cppUseWideStrings: Boolean, jniOutFolder: Option[File], jniHeaderOutFolder: Option[File], jniIncludePrefix: String, @@ -83,7 +85,7 @@ package object generatorTools { if (s.isEmpty) s else ", " + s } def q(s: String) = '"' + s + '"' - def firstUpper(token: String) = token.charAt(0).toUpper + token.substring(1) + def firstUpper(token: String) = if (token.isEmpty()) token else token.charAt(0).toUpper + token.substring(1) type IdentConverter = String => String @@ -138,6 +140,20 @@ package object generatorTools { } } + object JavaAccessModifier extends Enumeration { + val Public = Value("public") + val Package = Value("package") + + def getCodeGenerationString(javaAccessModifier: JavaAccessModifier.Value): String = { + javaAccessModifier match { + case Public => "public " + case Package => "/*package*/ " + } + } + + } + implicit val javaAccessModifierReads: scopt.Read[JavaAccessModifier.Value] = scopt.Read.reads(JavaAccessModifier withName _) + final case class SkipFirst() { private var first = true @@ -309,7 +325,9 @@ abstract class Generator(spec: Spec) w.wl val myHeader = q(includePrefix + fileIdentStyle(name) + "." + spec.cppHeaderExt) w.wl(s"#include $myHeader // my header") - includes.foreach(w.wl(_)) + val myHeaderInclude = s"#include $myHeader" + for (include <- includes if include != myHeaderInclude) + w.wl(include) w.wl wrapNamespace(w, namespace, f) }) diff --git a/support-lib/jni/Marshal.hpp b/support-lib/jni/Marshal.hpp index af44a079c..fcced9be0 100644 --- a/support-lib/jni/Marshal.hpp +++ b/support-lib/jni/Marshal.hpp @@ -178,6 +178,25 @@ namespace djinni } }; + struct WString + { + using CppType = std::wstring; + using JniType = jstring; + + using Boxed = WString; + + static CppType toCpp(JNIEnv* jniEnv, JniType j) + { + assert(j != nullptr); + return jniWStringFromString(jniEnv, j); + } + + static LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) + { + return {jniEnv, jniStringFromWString(jniEnv, c)}; + } + }; + struct Binary { using CppType = std::vector; diff --git a/support-lib/jni/djinni_support.cpp b/support-lib/jni/djinni_support.cpp index 9541d1291..9d85b7a46 100644 --- a/support-lib/jni/djinni_support.cpp +++ b/support-lib/jni/djinni_support.cpp @@ -371,6 +371,46 @@ jstring jniStringFromUTF8(JNIEnv * env, const std::string & str) { return res; } +template +static std::u16string implWStringToUTF16(std::wstring::const_iterator, std::wstring::const_iterator) +{ + static_assert(wcharTypeSize == 2 || wcharTypeSize == 4, "wchar_t must be represented by UTF-16 or UTF-32 encoding"); + return {}; // unreachable +} + +template<> +inline std::u16string implWStringToUTF16<2>(std::wstring::const_iterator begin, std::wstring::const_iterator end) { + // case when wchar_t is represented by utf-16 encoding + return std::u16string(begin, end); +} + +template<> +inline std::u16string implWStringToUTF16<4>(std::wstring::const_iterator begin, std::wstring::const_iterator end) { + // case when wchar_t is represented by utf-32 encoding + std::u16string utf16; + utf16.reserve(std::distance(begin, end)); + for(; begin != end; ++begin) + utf16_encode(static_cast(*begin), utf16); + return utf16; +} + +inline std::u16string wstringToUTF16(const std::wstring & str) { + // hide "defined but not used" warnings + (void)implWStringToUTF16<2>; + (void)implWStringToUTF16<4>; + // Note: The template helper operates on iterators to work around a compiler issue we saw on Mac. + // It triggered undefined symbols if wstring methods were called directly in the template function. + return implWStringToUTF16(str.cbegin(), str.cend()); +} + +jstring jniStringFromWString(JNIEnv * env, const std::wstring & str) { + std::u16string utf16 = wstringToUTF16(str); + jstring res = env->NewString( + reinterpret_cast(utf16.data()), utf16.length()); + DJINNI_ASSERT(res, env); + return res; +} + // UTF-16 decode helpers. static inline bool is_high_surrogate(char16_t c) { return (c >= 0xD800) && (c < 0xDC00); } static inline bool is_low_surrogate(char16_t c) { return (c >= 0xDC00) && (c < 0xE000); } @@ -378,7 +418,7 @@ static inline bool is_low_surrogate(char16_t c) { return (c >= 0xDC00) && (c < /* * Like utf8_decode_check, but for UTF-16. */ -static offset_pt utf16_decode_check(const std::u16string & str, std::u16string::size_type i) { +static offset_pt utf16_decode_check(const char16_t * str, std::u16string::size_type i) { if (is_high_surrogate(str[i]) && is_low_surrogate(str[i+1])) { // High surrogate followed by low surrogate char32_t pt = (((str[i] - 0xD800) << 10) | (str[i+1] - 0xDC00)) + 0x10000; @@ -391,7 +431,7 @@ static offset_pt utf16_decode_check(const std::u16string & str, std::u16string:: } } -static char32_t utf16_decode(const std::u16string & str, std::u16string::size_type & i) { +static char32_t utf16_decode(const char16_t * str, std::u16string::size_type & i) { offset_pt res = utf16_decode_check(str, i); if (res.offset < 0) { i += 1; @@ -437,10 +477,52 @@ std::string jniUTF8FromString(JNIEnv * env, const jstring jstr) { std::string out; out.reserve(str.length() * 3 / 2); // estimate for (std::u16string::size_type i = 0; i < str.length(); ) - utf8_encode(utf16_decode(str, i), out); + utf8_encode(utf16_decode(str.data(), i), out); return out; } +template +static std::wstring implUTF16ToWString(const char16_t * data, size_t length) +{ + static_assert(wcharTypeSize == 2 || wcharTypeSize == 4, "wchar_t must be represented by UTF-16 or UTF-32 encoding"); + return {}; // unreachable +} + +template<> +inline std::wstring implUTF16ToWString<2>(const char16_t * data, size_t length) { + // case when wchar_t is represented by utf-16 encoding + return std::wstring(data, data + length); +} + +template<> +inline std::wstring implUTF16ToWString<4>(const char16_t * data, size_t length) { + // case when wchar_t is represented by utf-32 encoding + std::wstring result; + result.reserve(length); + for (size_t i = 0; i < length; ) + result += static_cast(utf16_decode(data, i)); + return result; +} + +inline std::wstring UTF16ToWString(const char16_t * data, size_t length) { + // hide "defined but not used" warnings + (void)implUTF16ToWString<2>; + (void)implUTF16ToWString<4>; + return implUTF16ToWString(data, length); +} + +std::wstring jniWStringFromString(JNIEnv * env, const jstring jstr) { + DJINNI_ASSERT(jstr, env); + const jsize length = env->GetStringLength(jstr); + jniExceptionCheck(env); + + const auto deleter = [env, jstr] (const jchar * c) { env->ReleaseStringChars(jstr, c); }; + std::unique_ptr ptr(env->GetStringChars(jstr, nullptr), + deleter); + const char16_t * data = reinterpret_cast(ptr.get()); + return UTF16ToWString(data, length); +} + DJINNI_WEAK_DEFINITION void jniSetPendingFromCurrent(JNIEnv * env, const char * ctx) noexcept { jniDefaultSetPendingFromCurrent(env, ctx); diff --git a/support-lib/jni/djinni_support.hpp b/support-lib/jni/djinni_support.hpp index 78a34c69b..7b9e1eb16 100644 --- a/support-lib/jni/djinni_support.hpp +++ b/support-lib/jni/djinni_support.hpp @@ -591,6 +591,9 @@ class JniLocalScope { jstring jniStringFromUTF8(JNIEnv * env, const std::string & str); std::string jniUTF8FromString(JNIEnv * env, const jstring jstr); +jstring jniStringFromWString(JNIEnv * env, const std::wstring & str); +std::wstring jniWStringFromString(JNIEnv * env, const jstring jstr); + class JniEnum { public: /* diff --git a/support-lib/objc/DJIError.h b/support-lib/objc/DJIError.h index 68810b4e2..eeaa90ed8 100644 --- a/support-lib/objc/DJIError.h +++ b/support-lib/objc/DJIError.h @@ -18,11 +18,17 @@ namespace djinni { +// Throws an exception for an unimplemented method call. +[[noreturn]] void throwUnimplemented(const char * ctx, NSString * msg); + // Helper function for exception translation. Do not call directly! [[noreturn]] void throwNSExceptionFromCurrent(const char * ctx); } // namespace djinni +#define DJINNI_UNIMPLEMENTED(msg) \ + ::djinni::throwUnimplemented(__PRETTY_FUNCTION__, msg); + #define DJINNI_TRANSLATE_EXCEPTIONS() \ catch (const std::exception & e) { \ ::djinni::throwNSExceptionFromCurrent(__PRETTY_FUNCTION__); \ diff --git a/support-lib/objc/DJIError.mm b/support-lib/objc/DJIError.mm index 672ef358f..4be648097 100644 --- a/support-lib/objc/DJIError.mm +++ b/support-lib/objc/DJIError.mm @@ -21,6 +21,11 @@ namespace djinni { +[[noreturn]] __attribute__((weak)) void throwUnimplemented(const char * /*ctx*/, NSString * message) { + [NSException raise:NSInternalInconsistencyException format:@"Unimplemented: %@", message]; + __builtin_unreachable(); +} + [[noreturn]] __attribute__((weak)) void throwNSExceptionFromCurrent(const char * /*ctx*/) { try { throw; diff --git a/support-lib/objc/DJIMarshal+Private.h b/support-lib/objc/DJIMarshal+Private.h index e7bac87ce..5d600b33d 100644 --- a/support-lib/objc/DJIMarshal+Private.h +++ b/support-lib/objc/DJIMarshal+Private.h @@ -118,6 +118,54 @@ struct String { } }; +template +static CFStringEncoding getWCharEncoding() +{ + static_assert(wcharTypeSize == 2 || wcharTypeSize == 4, "wchar_t must be represented by UTF-16 or UTF-32 encoding"); + return {}; // unreachable +} + +template<> +inline CFStringEncoding getWCharEncoding<2>() { + // case when wchar_t is represented by utf-16 encoding +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + return NSUTF16BigEndianStringEncoding; +#else + return NSUTF16LittleEndianStringEncoding; +#endif +} + +template<> +inline CFStringEncoding getWCharEncoding<4>() { + // case when wchar_t is represented by utf-32 encoding +#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + return NSUTF32BigEndianStringEncoding; +#else + return NSUTF32LittleEndianStringEncoding; +#endif +} + +struct WString { + using CppType = std::wstring; + using ObjcType = NSString*; + + using Boxed = WString; + + static CppType toCpp(ObjcType string) { + assert(string); + NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(getWCharEncoding()); + NSData* data = [string dataUsingEncoding:encoding]; + return std::wstring((wchar_t*)[data bytes], [data length] / sizeof (wchar_t)); + } + + static ObjcType fromCpp(const CppType& string) { + assert(string.size() <= std::numeric_limits::max()); + return [[NSString alloc] initWithBytes:string.data() + length:string.size() * sizeof(wchar_t) + encoding:getWCharEncoding()]; + } +}; + struct Date { using CppType = std::chrono::system_clock::time_point; using ObjcType = NSDate*; diff --git a/test-suite/djinni/common.djinni b/test-suite/djinni/common.djinni index 61075cb0d..5c165f605 100644 --- a/test-suite/djinni/common.djinni +++ b/test-suite/djinni/common.djinni @@ -13,3 +13,4 @@ @import "multiple_inheritance.djinni" @import "single_language_interfaces.djinni" @import "extended_record.djinni" +@import "varnames.djinni" diff --git a/test-suite/djinni/enum.djinni b/test-suite/djinni/enum.djinni index 03d1e0206..af56c695c 100644 --- a/test-suite/djinni/enum.djinni +++ b/test-suite/djinni/enum.djinni @@ -11,6 +11,18 @@ color = enum { violet; } -opt_color_record = record { - my_color: optional; +enum_usage_record = record { + e: color; + o: optional; + l: list; + s: set; + m: map; +} + +enum_usage_interface = interface +c +j +o { + e(e: color): color; + o(o: optional): optional; + l(l: list): list; + s(s: set): set; + m(m: map): map; } diff --git a/test-suite/djinni/single_language_interfaces.djinni b/test-suite/djinni/single_language_interfaces.djinni index a72445e7d..0f6095790 100644 --- a/test-suite/djinni/single_language_interfaces.djinni +++ b/test-suite/djinni/single_language_interfaces.djinni @@ -5,5 +5,7 @@ java_only_listener = interface +j {} # on references to interfaces they don't need. uses_single_language_listeners = interface +o +j +c { callForObjC(l: objc_only_listener); + returnForObjC(): objc_only_listener; callForJava(l: java_only_listener); + returnForJava(): java_only_listener; } diff --git a/test-suite/djinni/varnames.djinni b/test-suite/djinni/varnames.djinni new file mode 100644 index 000000000..5b3e5e567 --- /dev/null +++ b/test-suite/djinni/varnames.djinni @@ -0,0 +1,11 @@ +# Underscore is used as a separator in Djinni names, so we don't really +# anticipate it to be used as a prefix/suffix. Some name styles behave +# badly when it is. However this test case ensures we at least don't crash. +_varname_record_ = record { + _field_: i8; +} + +_varname_interface_ = interface +c { + _rmethod_(_r_arg_: _varname_record_): _varname_record_; + _imethod_(_i_arg_: _varname_interface_): _varname_interface_; +} diff --git a/test-suite/djinni/wchar_test.djinni b/test-suite/djinni/wchar_test.djinni new file mode 100644 index 000000000..e8bfca675 --- /dev/null +++ b/test-suite/djinni/wchar_test.djinni @@ -0,0 +1,10 @@ +wchar_test_rec = record { + s: string; +} + +wchar_test_helpers = interface +c { + static get_record() : wchar_test_rec; + static get_string() : string; + static check_string(str: string) : bool; + static check_record(rec: wchar_test_rec) : bool; +} diff --git a/test-suite/generated-src/cpp/Conflict.hpp b/test-suite/generated-src/cpp/Conflict.hpp index 1c5e2430b..558baf6fe 100644 --- a/test-suite/generated-src/cpp/Conflict.hpp +++ b/test-suite/generated-src/cpp/Conflict.hpp @@ -3,6 +3,8 @@ #pragma once +#include + namespace testsuite { /** @@ -12,6 +14,33 @@ namespace testsuite { class Conflict { public: virtual ~Conflict() {} + + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/Conflict$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBConflict"; } }; } // namespace testsuite diff --git a/test-suite/generated-src/cpp/_varname_interface_.hpp b/test-suite/generated-src/cpp/_varname_interface_.hpp new file mode 100644 index 000000000..43102206c --- /dev/null +++ b/test-suite/generated-src/cpp/_varname_interface_.hpp @@ -0,0 +1,49 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#pragma once + +#include +#include + +namespace testsuite { + +struct VarnameRecord; + +class VarnameInterface { +public: + virtual ~VarnameInterface() {} + + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/VarnameInterface$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBVarnameInterface"; } + + virtual VarnameRecord _rmethod_(const VarnameRecord & _r_arg_) = 0; + + virtual std::shared_ptr _imethod_(const std::shared_ptr & _i_arg_) = 0; +}; + +} // namespace testsuite diff --git a/test-suite/generated-src/cpp/_varname_record_.hpp b/test-suite/generated-src/cpp/_varname_record_.hpp new file mode 100644 index 000000000..83d01393c --- /dev/null +++ b/test-suite/generated-src/cpp/_varname_record_.hpp @@ -0,0 +1,24 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#pragma once + +#include +#include + +namespace testsuite { + +/** + * Underscore is used as a separator in Djinni names, so we don't really + * anticipate it to be used as a prefix/suffix. Some name styles behave + * badly when it is. However this test case ensures we at least don't crash. + */ +struct VarnameRecord final { + int8_t _field_; + + VarnameRecord(int8_t _field__) + : _field_(std::move(_field__)) + {} +}; + +} // namespace testsuite diff --git a/test-suite/generated-src/cpp/assorted_primitives.hpp b/test-suite/generated-src/cpp/assorted_primitives.hpp index caa67f80b..9db7274e5 100644 --- a/test-suite/generated-src/cpp/assorted_primitives.hpp +++ b/test-suite/generated-src/cpp/assorted_primitives.hpp @@ -3,8 +3,8 @@ #pragma once +#include "../../handwritten-src/cpp/optional.hpp" #include -#include #include namespace testsuite { diff --git a/test-suite/generated-src/cpp/client_interface.hpp b/test-suite/generated-src/cpp/client_interface.hpp index fa2c84410..ec55cd7f5 100644 --- a/test-suite/generated-src/cpp/client_interface.hpp +++ b/test-suite/generated-src/cpp/client_interface.hpp @@ -3,8 +3,8 @@ #pragma once +#include "../../handwritten-src/cpp/optional.hpp" #include -#include #include #include #include @@ -18,6 +18,33 @@ class ClientInterface { public: virtual ~ClientInterface() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return nullptr; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBClientInterface"; } + /** Returns record of given string */ virtual ClientReturnedRecord get_record(int64_t record_id, const std::string & utf8string, const std::experimental::optional & misc) = 0; diff --git a/test-suite/generated-src/cpp/client_returned_record.hpp b/test-suite/generated-src/cpp/client_returned_record.hpp index ac18574e8..4252095e5 100644 --- a/test-suite/generated-src/cpp/client_returned_record.hpp +++ b/test-suite/generated-src/cpp/client_returned_record.hpp @@ -3,8 +3,8 @@ #pragma once +#include "../../handwritten-src/cpp/optional.hpp" #include -#include #include #include diff --git a/test-suite/generated-src/cpp/conflict_user.hpp b/test-suite/generated-src/cpp/conflict_user.hpp index f3eb04432..b1ce0327f 100644 --- a/test-suite/generated-src/cpp/conflict_user.hpp +++ b/test-suite/generated-src/cpp/conflict_user.hpp @@ -4,6 +4,7 @@ #pragma once #include +#include #include namespace testsuite { @@ -14,6 +15,33 @@ class ConflictUser { public: virtual ~ConflictUser() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/ConflictUser$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBConflictUser"; } + virtual std::shared_ptr<::testsuite::Conflict> Conflict() = 0; virtual bool conflict_arg(const std::unordered_set> & cs) = 0; diff --git a/test-suite/generated-src/cpp/constants.hpp b/test-suite/generated-src/cpp/constants.hpp index edd7d5cfa..32b1a0283 100644 --- a/test-suite/generated-src/cpp/constants.hpp +++ b/test-suite/generated-src/cpp/constants.hpp @@ -3,9 +3,9 @@ #pragma once +#include "../../handwritten-src/cpp/optional.hpp" #include "constant_record.hpp" #include -#include #include #include diff --git a/test-suite/generated-src/cpp/constants_interface.hpp b/test-suite/generated-src/cpp/constants_interface.hpp index daa250edc..0216e5281 100644 --- a/test-suite/generated-src/cpp/constants_interface.hpp +++ b/test-suite/generated-src/cpp/constants_interface.hpp @@ -3,8 +3,8 @@ #pragma once +#include "../../handwritten-src/cpp/optional.hpp" #include -#include #include namespace testsuite { @@ -16,6 +16,33 @@ class ConstantsInterface { public: virtual ~ConstantsInterface() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/ConstantsInterface$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBConstantsInterface"; } + static bool const BOOL_CONSTANT; static int8_t const I8_CONSTANT; diff --git a/test-suite/generated-src/cpp/cpp_exception.hpp b/test-suite/generated-src/cpp/cpp_exception.hpp index a8e7e13c4..e9cfa0ac5 100644 --- a/test-suite/generated-src/cpp/cpp_exception.hpp +++ b/test-suite/generated-src/cpp/cpp_exception.hpp @@ -5,6 +5,7 @@ #include #include +#include namespace testsuite { @@ -12,6 +13,33 @@ class CppException { public: virtual ~CppException() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/CppException$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBCppException"; } + virtual int32_t throw_an_exception() = 0; static std::shared_ptr get(); diff --git a/test-suite/generated-src/cpp/enum_usage_interface.hpp b/test-suite/generated-src/cpp/enum_usage_interface.hpp new file mode 100644 index 000000000..98074e648 --- /dev/null +++ b/test-suite/generated-src/cpp/enum_usage_interface.hpp @@ -0,0 +1,58 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#pragma once + +#include "../../handwritten-src/cpp/optional.hpp" +#include +#include +#include +#include + +namespace testsuite { + +enum class color; + +class EnumUsageInterface { +public: + virtual ~EnumUsageInterface() {} + + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/EnumUsageInterface$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBEnumUsageInterface"; } + + virtual color e(color e) = 0; + + virtual std::experimental::optional o(std::experimental::optional o) = 0; + + virtual std::vector l(const std::vector & l) = 0; + + virtual std::unordered_set s(const std::unordered_set & s) = 0; + + virtual std::unordered_map m(const std::unordered_map & m) = 0; +}; + +} // namespace testsuite diff --git a/test-suite/generated-src/cpp/enum_usage_record.hpp b/test-suite/generated-src/cpp/enum_usage_record.hpp new file mode 100644 index 000000000..10d86ebe8 --- /dev/null +++ b/test-suite/generated-src/cpp/enum_usage_record.hpp @@ -0,0 +1,35 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#pragma once + +#include "../../handwritten-src/cpp/optional.hpp" +#include "color.hpp" +#include +#include +#include +#include + +namespace testsuite { + +struct EnumUsageRecord final { + color e; + std::experimental::optional o; + std::vector l; + std::unordered_set s; + std::unordered_map m; + + EnumUsageRecord(color e_, + std::experimental::optional o_, + std::vector l_, + std::unordered_set s_, + std::unordered_map m_) + : e(std::move(e_)) + , o(std::move(o_)) + , l(std::move(l_)) + , s(std::move(s_)) + , m(std::move(m_)) + {} +}; + +} // namespace testsuite diff --git a/test-suite/generated-src/cpp/extern_interface_1.hpp b/test-suite/generated-src/cpp/extern_interface_1.hpp index 5c207ff3e..0e498dc4a 100644 --- a/test-suite/generated-src/cpp/extern_interface_1.hpp +++ b/test-suite/generated-src/cpp/extern_interface_1.hpp @@ -6,10 +6,38 @@ #include "client_interface.hpp" #include "client_returned_record.hpp" #include +#include class ExternInterface1 { public: virtual ~ExternInterface1() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/ExternInterface1$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBExternInterface1"; } + virtual ::testsuite::ClientReturnedRecord foo(const std::shared_ptr<::testsuite::ClientInterface> & i) = 0; }; diff --git a/test-suite/generated-src/cpp/extern_interface_2.hpp b/test-suite/generated-src/cpp/extern_interface_2.hpp index ef055e165..9b07dbece 100644 --- a/test-suite/generated-src/cpp/extern_interface_2.hpp +++ b/test-suite/generated-src/cpp/extern_interface_2.hpp @@ -5,6 +5,7 @@ #include "test_helpers.hpp" #include +#include struct ExternRecordWithDerivings; @@ -12,5 +13,32 @@ class ExternInterface2 { public: virtual ~ExternInterface2() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return nullptr; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBExternInterface2"; } + virtual ExternRecordWithDerivings foo(const std::shared_ptr<::testsuite::TestHelpers> & i) = 0; }; diff --git a/test-suite/generated-src/cpp/first_listener.hpp b/test-suite/generated-src/cpp/first_listener.hpp index 5597c7a3b..38c002b0e 100644 --- a/test-suite/generated-src/cpp/first_listener.hpp +++ b/test-suite/generated-src/cpp/first_listener.hpp @@ -3,6 +3,8 @@ #pragma once +#include + namespace testsuite { /** Used for ObjC multiple inheritance tests */ @@ -10,6 +12,33 @@ class FirstListener { public: virtual ~FirstListener() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return nullptr; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBFirstListener"; } + virtual void first() = 0; }; diff --git a/test-suite/generated-src/cpp/java_only_listener.hpp b/test-suite/generated-src/cpp/java_only_listener.hpp index 4d36febb9..3533a5b69 100644 --- a/test-suite/generated-src/cpp/java_only_listener.hpp +++ b/test-suite/generated-src/cpp/java_only_listener.hpp @@ -3,11 +3,40 @@ #pragma once +#include + namespace testsuite { class JavaOnlyListener { public: virtual ~JavaOnlyListener() {} + + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return nullptr; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBJavaOnlyListener"; } }; } // namespace testsuite diff --git a/test-suite/generated-src/cpp/listener_caller.hpp b/test-suite/generated-src/cpp/listener_caller.hpp index dd403b7a7..38588c372 100644 --- a/test-suite/generated-src/cpp/listener_caller.hpp +++ b/test-suite/generated-src/cpp/listener_caller.hpp @@ -4,6 +4,7 @@ #pragma once #include +#include namespace testsuite { @@ -20,6 +21,33 @@ class ListenerCaller { public: virtual ~ListenerCaller() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/ListenerCaller$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBListenerCaller"; } + static std::shared_ptr init(const std::shared_ptr & first_l, const std::shared_ptr & second_l); virtual void callFirst() = 0; diff --git a/test-suite/generated-src/cpp/objc_only_listener.hpp b/test-suite/generated-src/cpp/objc_only_listener.hpp index 428e4db9e..365a67f53 100644 --- a/test-suite/generated-src/cpp/objc_only_listener.hpp +++ b/test-suite/generated-src/cpp/objc_only_listener.hpp @@ -3,11 +3,40 @@ #pragma once +#include + namespace testsuite { class ObjcOnlyListener { public: virtual ~ObjcOnlyListener() {} + + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return nullptr; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBObjcOnlyListener"; } }; } // namespace testsuite diff --git a/test-suite/generated-src/cpp/opt_color_record.hpp b/test-suite/generated-src/cpp/opt_color_record.hpp deleted file mode 100644 index b07746315..000000000 --- a/test-suite/generated-src/cpp/opt_color_record.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from enum.djinni - -#pragma once - -#include "color.hpp" -#include -#include - -namespace testsuite { - -struct OptColorRecord final { - std::experimental::optional my_color; - - OptColorRecord(std::experimental::optional my_color_) - : my_color(std::move(my_color_)) - {} -}; - -} // namespace testsuite diff --git a/test-suite/generated-src/cpp/return_one.hpp b/test-suite/generated-src/cpp/return_one.hpp index 728071135..10cf1129f 100644 --- a/test-suite/generated-src/cpp/return_one.hpp +++ b/test-suite/generated-src/cpp/return_one.hpp @@ -5,6 +5,7 @@ #include #include +#include namespace testsuite { @@ -13,6 +14,33 @@ class ReturnOne { public: virtual ~ReturnOne() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/ReturnOne$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBReturnOne"; } + static std::shared_ptr get_instance(); virtual int8_t return_one() = 0; diff --git a/test-suite/generated-src/cpp/return_two.hpp b/test-suite/generated-src/cpp/return_two.hpp index abb41f9f0..8051eaa7f 100644 --- a/test-suite/generated-src/cpp/return_two.hpp +++ b/test-suite/generated-src/cpp/return_two.hpp @@ -5,6 +5,7 @@ #include #include +#include namespace testsuite { @@ -13,6 +14,33 @@ class ReturnTwo { public: virtual ~ReturnTwo() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/ReturnTwo$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBReturnTwo"; } + static std::shared_ptr get_instance(); virtual int8_t return_two() = 0; diff --git a/test-suite/generated-src/cpp/reverse_client_interface.hpp b/test-suite/generated-src/cpp/reverse_client_interface.hpp index 372af04b4..f75c616ad 100644 --- a/test-suite/generated-src/cpp/reverse_client_interface.hpp +++ b/test-suite/generated-src/cpp/reverse_client_interface.hpp @@ -3,7 +3,7 @@ #pragma once -#include +#include "../../handwritten-src/cpp/optional.hpp" #include #include @@ -13,6 +13,33 @@ class ReverseClientInterface { public: virtual ~ReverseClientInterface() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/ReverseClientInterface$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBReverseClientInterface"; } + virtual std::string return_str() const = 0; virtual std::string meth_taking_interface(const std::shared_ptr & i) = 0; diff --git a/test-suite/generated-src/cpp/second_listener.hpp b/test-suite/generated-src/cpp/second_listener.hpp index 10ed57b81..d05581463 100644 --- a/test-suite/generated-src/cpp/second_listener.hpp +++ b/test-suite/generated-src/cpp/second_listener.hpp @@ -3,6 +3,8 @@ #pragma once +#include + namespace testsuite { /** Used for ObjC multiple inheritance tests */ @@ -10,6 +12,33 @@ class SecondListener { public: virtual ~SecondListener() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return nullptr; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBSecondListener"; } + virtual void second() = 0; }; diff --git a/test-suite/generated-src/cpp/test_duration.hpp b/test-suite/generated-src/cpp/test_duration.hpp index 1010e7c7f..55d0241ac 100644 --- a/test-suite/generated-src/cpp/test_duration.hpp +++ b/test-suite/generated-src/cpp/test_duration.hpp @@ -3,9 +3,9 @@ #pragma once +#include "../../handwritten-src/cpp/optional.hpp" #include #include -#include #include namespace testsuite { @@ -14,6 +14,33 @@ class TestDuration { public: virtual ~TestDuration() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/TestDuration$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBTestDuration"; } + static std::string hoursString(std::chrono::duration> dt); static std::string minutesString(std::chrono::duration> dt); diff --git a/test-suite/generated-src/cpp/test_helpers.hpp b/test-suite/generated-src/cpp/test_helpers.hpp index 849fb1b5c..ee54b2a73 100644 --- a/test-suite/generated-src/cpp/test_helpers.hpp +++ b/test-suite/generated-src/cpp/test_helpers.hpp @@ -3,8 +3,8 @@ #pragma once +#include "../../handwritten-src/cpp/optional.hpp" #include -#include #include #include #include @@ -30,6 +30,33 @@ class TestHelpers { public: virtual ~TestHelpers() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/TestHelpers$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBTestHelpers"; } + /** Method with documentation */ static SetRecord get_set_record(); diff --git a/test-suite/generated-src/cpp/user_token.hpp b/test-suite/generated-src/cpp/user_token.hpp index 2bbfa57f9..4b135f950 100644 --- a/test-suite/generated-src/cpp/user_token.hpp +++ b/test-suite/generated-src/cpp/user_token.hpp @@ -11,6 +11,33 @@ class UserToken { public: virtual ~UserToken() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/UserToken$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBUserToken"; } + virtual std::string whoami() = 0; }; diff --git a/test-suite/generated-src/cpp/uses_single_language_listeners.hpp b/test-suite/generated-src/cpp/uses_single_language_listeners.hpp index 082c6dc2b..9cf704ad8 100644 --- a/test-suite/generated-src/cpp/uses_single_language_listeners.hpp +++ b/test-suite/generated-src/cpp/uses_single_language_listeners.hpp @@ -4,6 +4,7 @@ #pragma once #include +#include namespace testsuite { @@ -18,9 +19,40 @@ class UsesSingleLanguageListeners { public: virtual ~UsesSingleLanguageListeners() {} + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/UsesSingleLanguageListeners$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBUsesSingleLanguageListeners"; } + virtual void callForObjC(const std::shared_ptr & l) = 0; + virtual std::shared_ptr returnForObjC() = 0; + virtual void callForJava(const std::shared_ptr & l) = 0; + + virtual std::shared_ptr returnForJava() = 0; }; } // namespace testsuite diff --git a/test-suite/generated-src/cpp/wchar_test_helpers.hpp b/test-suite/generated-src/cpp/wchar_test_helpers.hpp new file mode 100644 index 000000000..0120e3160 --- /dev/null +++ b/test-suite/generated-src/cpp/wchar_test_helpers.hpp @@ -0,0 +1,52 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#pragma once + +#include + +namespace testsuite { + +struct WcharTestRec; + +class WcharTestHelpers { +public: + virtual ~WcharTestHelpers() {} + + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/WcharTestHelpers$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcTypeName() { return "DBWcharTestHelpers"; } + + static WcharTestRec get_record(); + + static std::wstring get_string(); + + static bool check_string(const std::wstring & str); + + static bool check_record(const WcharTestRec & rec); +}; + +} // namespace testsuite diff --git a/test-suite/generated-src/cpp/wchar_test_rec.hpp b/test-suite/generated-src/cpp/wchar_test_rec.hpp new file mode 100644 index 000000000..23a732dd6 --- /dev/null +++ b/test-suite/generated-src/cpp/wchar_test_rec.hpp @@ -0,0 +1,19 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#pragma once + +#include +#include + +namespace testsuite { + +struct WcharTestRec final { + std::wstring s; + + WcharTestRec(std::wstring s_) + : s(std::move(s_)) + {} +}; + +} // namespace testsuite diff --git a/test-suite/generated-src/inFileList.txt b/test-suite/generated-src/inFileList.txt index 6cd5682fe..f69dd259e 100644 --- a/test-suite/generated-src/inFileList.txt +++ b/test-suite/generated-src/inFileList.txt @@ -1,21 +1,22 @@ djinni/all.djinni -djinni/common.djinni -djinni/set.djinni -djinni/derivings.djinni -djinni/nested_collection.djinni -djinni/map.djinni -djinni/primitive_list.djinni -djinni/exception.djinni -djinni/client_interface.djinni -djinni/enum.djinni -djinni/user_token.djinni -djinni/test.djinni -djinni/primtypes.djinni -djinni/constants.djinni -djinni/multiple_inheritance.djinni -djinni/single_language_interfaces.djinni -djinni/extended_record.djinni -djinni/date.djinni -djinni/date.yaml -djinni/duration.djinni -djinni/duration.yaml +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/common.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/set.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/derivings.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/nested_collection.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/map.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/primitive_list.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/exception.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/client_interface.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/enum.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/user_token.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/test.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/primtypes.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/constants.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/multiple_inheritance.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/single_language_interfaces.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/extended_record.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/varnames.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/date.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/date.yaml +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/duration.djinni +/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/duration.yaml diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/Conflict.java b/test-suite/generated-src/java/com/dropbox/djinni/test/Conflict.java index fbd6ce640..757c3511d 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/Conflict.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/Conflict.java @@ -35,5 +35,7 @@ protected void finalize() throws java.lang.Throwable destroy(); super.finalize(); } + + // Conflict methods } } diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/ConflictUser.java b/test-suite/generated-src/java/com/dropbox/djinni/test/ConflictUser.java index 7169b30ff..39c33ac03 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/ConflictUser.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/ConflictUser.java @@ -37,6 +37,8 @@ protected void finalize() throws java.lang.Throwable super.finalize(); } + // ConflictUser methods + @Override public Conflict Conflict() { diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/ConstantsInterface.java b/test-suite/generated-src/java/com/dropbox/djinni/test/ConstantsInterface.java index 2c38a374f..c5f4208e0 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/ConstantsInterface.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/ConstantsInterface.java @@ -97,6 +97,8 @@ protected void finalize() throws java.lang.Throwable super.finalize(); } + // ConstantsInterface methods + @Override public void dummy() { diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/CppException.java b/test-suite/generated-src/java/com/dropbox/djinni/test/CppException.java index 362dbb0f5..8d1a01830 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/CppException.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/CppException.java @@ -36,6 +36,8 @@ protected void finalize() throws java.lang.Throwable super.finalize(); } + // CppException methods + @Override public int throwAnException() { diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/EnumUsageInterface.java b/test-suite/generated-src/java/com/dropbox/djinni/test/EnumUsageInterface.java new file mode 100644 index 000000000..679805c5f --- /dev/null +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/EnumUsageInterface.java @@ -0,0 +1,94 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +package com.dropbox.djinni.test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.concurrent.atomic.AtomicBoolean; +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +public abstract class EnumUsageInterface { + @Nonnull + public abstract Color e(@Nonnull Color e); + + @CheckForNull + public abstract Color o(@CheckForNull Color o); + + @Nonnull + public abstract ArrayList l(@Nonnull ArrayList l); + + @Nonnull + public abstract HashSet s(@Nonnull HashSet s); + + @Nonnull + public abstract HashMap m(@Nonnull HashMap m); + + private static final class CppProxy extends EnumUsageInterface + { + 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(); + } + + // EnumUsageInterface methods + + @Override + public Color e(Color e) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_e(this.nativeRef, e); + } + private native Color native_e(long _nativeRef, Color e); + + @Override + public Color o(Color o) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_o(this.nativeRef, o); + } + private native Color native_o(long _nativeRef, Color o); + + @Override + public ArrayList l(ArrayList l) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_l(this.nativeRef, l); + } + private native ArrayList native_l(long _nativeRef, ArrayList l); + + @Override + public HashSet s(HashSet s) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_s(this.nativeRef, s); + } + private native HashSet native_s(long _nativeRef, HashSet s); + + @Override + public HashMap m(HashMap m) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_m(this.nativeRef, m); + } + private native HashMap native_m(long _nativeRef, HashMap m); + } +} diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/EnumUsageRecord.java b/test-suite/generated-src/java/com/dropbox/djinni/test/EnumUsageRecord.java new file mode 100644 index 000000000..5d52bbde2 --- /dev/null +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/EnumUsageRecord.java @@ -0,0 +1,74 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +package com.dropbox.djinni.test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +public class EnumUsageRecord { + + + /*package*/ final Color mE; + + /*package*/ final Color mO; + + /*package*/ final ArrayList mL; + + /*package*/ final HashSet mS; + + /*package*/ final HashMap mM; + + public EnumUsageRecord( + @Nonnull Color e, + @CheckForNull Color o, + @Nonnull ArrayList l, + @Nonnull HashSet s, + @Nonnull HashMap m) { + this.mE = e; + this.mO = o; + this.mL = l; + this.mS = s; + this.mM = m; + } + + @Nonnull + public Color getE() { + return mE; + } + + @CheckForNull + public Color getO() { + return mO; + } + + @Nonnull + public ArrayList getL() { + return mL; + } + + @Nonnull + public HashSet getS() { + return mS; + } + + @Nonnull + public HashMap getM() { + return mM; + } + + @Override + public String toString() { + return "EnumUsageRecord{" + + "mE=" + mE + + "," + "mO=" + mO + + "," + "mL=" + mL + + "," + "mS=" + mS + + "," + "mM=" + mM + + "}"; + } + +} diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/ExternInterface1.java b/test-suite/generated-src/java/com/dropbox/djinni/test/ExternInterface1.java index 01c0dbf94..e5cc981b6 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/ExternInterface1.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/ExternInterface1.java @@ -31,6 +31,8 @@ protected void finalize() throws java.lang.Throwable super.finalize(); } + // ExternInterface1 methods + @Override public com.dropbox.djinni.test.ClientReturnedRecord foo(com.dropbox.djinni.test.ClientInterface i) { diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/ListenerCaller.java b/test-suite/generated-src/java/com/dropbox/djinni/test/ListenerCaller.java index 934a11b8c..75d0c8dab 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/ListenerCaller.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/ListenerCaller.java @@ -44,6 +44,8 @@ protected void finalize() throws java.lang.Throwable super.finalize(); } + // ListenerCaller methods + @Override public void callFirst() { diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/OptColorRecord.java b/test-suite/generated-src/java/com/dropbox/djinni/test/OptColorRecord.java deleted file mode 100644 index 0f84baeee..000000000 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/OptColorRecord.java +++ /dev/null @@ -1,31 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from enum.djinni - -package com.dropbox.djinni.test; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -public class OptColorRecord { - - - /*package*/ final Color mMyColor; - - public OptColorRecord( - @CheckForNull Color myColor) { - this.mMyColor = myColor; - } - - @CheckForNull - public Color getMyColor() { - return mMyColor; - } - - @Override - public String toString() { - return "OptColorRecord{" + - "mMyColor=" + mMyColor + - "}"; - } - -} diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/ReturnOne.java b/test-suite/generated-src/java/com/dropbox/djinni/test/ReturnOne.java index a973cd87e..49a58a969 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/ReturnOne.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/ReturnOne.java @@ -37,6 +37,8 @@ protected void finalize() throws java.lang.Throwable super.finalize(); } + // ReturnOne methods + @Override public byte returnOne() { diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/ReturnTwo.java b/test-suite/generated-src/java/com/dropbox/djinni/test/ReturnTwo.java index 5e3ed043c..4509dd4ee 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/ReturnTwo.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/ReturnTwo.java @@ -37,6 +37,8 @@ protected void finalize() throws java.lang.Throwable super.finalize(); } + // ReturnTwo methods + @Override public byte returnTwo() { diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/ReverseClientInterface.java b/test-suite/generated-src/java/com/dropbox/djinni/test/ReverseClientInterface.java index 9dea77f2a..66c32ad67 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/ReverseClientInterface.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/ReverseClientInterface.java @@ -43,6 +43,8 @@ protected void finalize() throws java.lang.Throwable super.finalize(); } + // ReverseClientInterface methods + @Override public String returnStr() { diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/TestDuration.java b/test-suite/generated-src/java/com/dropbox/djinni/test/TestDuration.java index 4331dde0d..c7a080167 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/TestDuration.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/TestDuration.java @@ -89,5 +89,7 @@ protected void finalize() throws java.lang.Throwable destroy(); super.finalize(); } + + // TestDuration methods } } diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/TestHelpers.java b/test-suite/generated-src/java/com/dropbox/djinni/test/TestHelpers.java index 052461154..52f2c5e1f 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/TestHelpers.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/TestHelpers.java @@ -104,5 +104,7 @@ protected void finalize() throws java.lang.Throwable destroy(); super.finalize(); } + + // TestHelpers methods } } diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/UserToken.java b/test-suite/generated-src/java/com/dropbox/djinni/test/UserToken.java index 659e8b58f..58206a08c 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/UserToken.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/UserToken.java @@ -34,6 +34,8 @@ protected void finalize() throws java.lang.Throwable super.finalize(); } + // UserToken methods + @Override public String whoami() { diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/UsesSingleLanguageListeners.java b/test-suite/generated-src/java/com/dropbox/djinni/test/UsesSingleLanguageListeners.java index dbe872699..17565fd4e 100644 --- a/test-suite/generated-src/java/com/dropbox/djinni/test/UsesSingleLanguageListeners.java +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/UsesSingleLanguageListeners.java @@ -14,8 +14,14 @@ public abstract class UsesSingleLanguageListeners { public abstract void callForObjC(@CheckForNull ObjcOnlyListener l); + @CheckForNull + public abstract ObjcOnlyListener returnForObjC(); + public abstract void callForJava(@CheckForNull JavaOnlyListener l); + @CheckForNull + public abstract JavaOnlyListener returnForJava(); + private static final class CppProxy extends UsesSingleLanguageListeners { private final long nativeRef; @@ -39,6 +45,8 @@ protected void finalize() throws java.lang.Throwable super.finalize(); } + // UsesSingleLanguageListeners methods + @Override public void callForObjC(ObjcOnlyListener l) { @@ -47,6 +55,14 @@ public void callForObjC(ObjcOnlyListener l) } private native void native_callForObjC(long _nativeRef, ObjcOnlyListener l); + @Override + public ObjcOnlyListener returnForObjC() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_returnForObjC(this.nativeRef); + } + private native ObjcOnlyListener native_returnForObjC(long _nativeRef); + @Override public void callForJava(JavaOnlyListener l) { @@ -54,5 +70,13 @@ public void callForJava(JavaOnlyListener l) native_callForJava(this.nativeRef, l); } private native void native_callForJava(long _nativeRef, JavaOnlyListener l); + + @Override + public JavaOnlyListener returnForJava() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_returnForJava(this.nativeRef); + } + private native JavaOnlyListener native_returnForJava(long _nativeRef); } } diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/VarnameInterface.java b/test-suite/generated-src/java/com/dropbox/djinni/test/VarnameInterface.java new file mode 100644 index 000000000..73d461253 --- /dev/null +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/VarnameInterface.java @@ -0,0 +1,58 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +package com.dropbox.djinni.test; + +import java.util.concurrent.atomic.AtomicBoolean; +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +public abstract class VarnameInterface { + @Nonnull + public abstract VarnameRecord Rmethod(@Nonnull VarnameRecord RArg); + + @CheckForNull + public abstract VarnameInterface Imethod(@CheckForNull VarnameInterface IArg); + + private static final class CppProxy extends VarnameInterface + { + 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(); + } + + // VarnameInterface methods + + @Override + public VarnameRecord Rmethod(VarnameRecord RArg) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_Rmethod(this.nativeRef, RArg); + } + private native VarnameRecord native_Rmethod(long _nativeRef, VarnameRecord RArg); + + @Override + public VarnameInterface Imethod(VarnameInterface IArg) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_Imethod(this.nativeRef, IArg); + } + private native VarnameInterface native_Imethod(long _nativeRef, VarnameInterface IArg); + } +} diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/VarnameRecord.java b/test-suite/generated-src/java/com/dropbox/djinni/test/VarnameRecord.java new file mode 100644 index 000000000..19a0a898d --- /dev/null +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/VarnameRecord.java @@ -0,0 +1,35 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +package com.dropbox.djinni.test; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +/** + * Underscore is used as a separator in Djinni names, so we don't really + * anticipate it to be used as a prefix/suffix. Some name styles behave + * badly when it is. However this test case ensures we at least don't crash. + */ +public class VarnameRecord { + + + /*package*/ final byte mField; + + public VarnameRecord( + byte Field) { + this.mField = Field; + } + + public byte getField() { + return mField; + } + + @Override + public String toString() { + return "VarnameRecord{" + + "mField=" + mField + + "}"; + } + +} diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/WcharTestHelpers.java b/test-suite/generated-src/java/com/dropbox/djinni/test/WcharTestHelpers.java new file mode 100644 index 000000000..2bcea2037 --- /dev/null +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/WcharTestHelpers.java @@ -0,0 +1,46 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +package com.dropbox.djinni.test; + +import java.util.concurrent.atomic.AtomicBoolean; +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +public abstract class WcharTestHelpers { + @Nonnull + public static native WcharTestRec getRecord(); + + @Nonnull + public static native String getString(); + + public static native boolean checkString(@Nonnull String str); + + public static native boolean checkRecord(@Nonnull WcharTestRec rec); + + private static final class CppProxy extends WcharTestHelpers + { + 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(); + } + + // WcharTestHelpers methods + } +} diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/WcharTestRec.java b/test-suite/generated-src/java/com/dropbox/djinni/test/WcharTestRec.java new file mode 100644 index 000000000..4b064cbc1 --- /dev/null +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/WcharTestRec.java @@ -0,0 +1,31 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +package com.dropbox.djinni.test; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +public class WcharTestRec { + + + /*package*/ final String mS; + + public WcharTestRec( + @Nonnull String s) { + this.mS = s; + } + + @Nonnull + public String getS() { + return mS; + } + + @Override + public String toString() { + return "WcharTestRec{" + + "mS=" + mS + + "}"; + } + +} diff --git a/test-suite/generated-src/jni/NativeClientInterface.cpp b/test-suite/generated-src/jni/NativeClientInterface.cpp index 3c7ac5f86..16f9c9b5f 100644 --- a/test-suite/generated-src/jni/NativeClientInterface.cpp +++ b/test-suite/generated-src/jni/NativeClientInterface.cpp @@ -3,7 +3,6 @@ #include "NativeClientInterface.hpp" // my header #include "Marshal.hpp" -#include "NativeClientInterface.hpp" #include "NativeClientReturnedRecord.hpp" namespace djinni_generated { diff --git a/test-suite/generated-src/jni/NativeCppException.cpp b/test-suite/generated-src/jni/NativeCppException.cpp index c5a724f34..dc7cfe0a1 100644 --- a/test-suite/generated-src/jni/NativeCppException.cpp +++ b/test-suite/generated-src/jni/NativeCppException.cpp @@ -3,7 +3,6 @@ #include "NativeCppException.hpp" // my header #include "Marshal.hpp" -#include "NativeCppException.hpp" namespace djinni_generated { diff --git a/test-suite/generated-src/jni/NativeEnumUsageInterface.cpp b/test-suite/generated-src/jni/NativeEnumUsageInterface.cpp new file mode 100644 index 000000000..4e84735d3 --- /dev/null +++ b/test-suite/generated-src/jni/NativeEnumUsageInterface.cpp @@ -0,0 +1,122 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#include "NativeEnumUsageInterface.hpp" // my header +#include "Marshal.hpp" +#include "NativeColor.hpp" + +namespace djinni_generated { + +NativeEnumUsageInterface::NativeEnumUsageInterface() : ::djinni::JniInterface<::testsuite::EnumUsageInterface, NativeEnumUsageInterface>("com/dropbox/djinni/test/EnumUsageInterface$CppProxy") {} + +NativeEnumUsageInterface::~NativeEnumUsageInterface() = default; + +NativeEnumUsageInterface::JavaProxy::JavaProxy(JniType j) : Handle(::djinni::jniGetThreadEnv(), j) { } + +NativeEnumUsageInterface::JavaProxy::~JavaProxy() = default; + +::testsuite::color NativeEnumUsageInterface::JavaProxy::e(::testsuite::color c_e) { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeEnumUsageInterface>::get(); + auto jret = jniEnv->CallObjectMethod(Handle::get().get(), data.method_e, + ::djinni::get(::djinni_generated::NativeColor::fromCpp(jniEnv, c_e))); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni_generated::NativeColor::toCpp(jniEnv, jret); +} +std::experimental::optional<::testsuite::color> NativeEnumUsageInterface::JavaProxy::o(std::experimental::optional<::testsuite::color> c_o) { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeEnumUsageInterface>::get(); + auto jret = jniEnv->CallObjectMethod(Handle::get().get(), data.method_o, + ::djinni::get(::djinni::Optional::fromCpp(jniEnv, c_o))); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni::Optional::toCpp(jniEnv, jret); +} +std::vector<::testsuite::color> NativeEnumUsageInterface::JavaProxy::l(const std::vector<::testsuite::color> & c_l) { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeEnumUsageInterface>::get(); + auto jret = jniEnv->CallObjectMethod(Handle::get().get(), data.method_l, + ::djinni::get(::djinni::List<::djinni_generated::NativeColor>::fromCpp(jniEnv, c_l))); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni::List<::djinni_generated::NativeColor>::toCpp(jniEnv, jret); +} +std::unordered_set<::testsuite::color> NativeEnumUsageInterface::JavaProxy::s(const std::unordered_set<::testsuite::color> & c_s) { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeEnumUsageInterface>::get(); + auto jret = jniEnv->CallObjectMethod(Handle::get().get(), data.method_s, + ::djinni::get(::djinni::Set<::djinni_generated::NativeColor>::fromCpp(jniEnv, c_s))); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni::Set<::djinni_generated::NativeColor>::toCpp(jniEnv, jret); +} +std::unordered_map<::testsuite::color, ::testsuite::color> NativeEnumUsageInterface::JavaProxy::m(const std::unordered_map<::testsuite::color, ::testsuite::color> & c_m) { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeEnumUsageInterface>::get(); + auto jret = jniEnv->CallObjectMethod(Handle::get().get(), data.method_m, + ::djinni::get(::djinni::Map<::djinni_generated::NativeColor, ::djinni_generated::NativeColor>::fromCpp(jniEnv, c_m))); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni::Map<::djinni_generated::NativeColor, ::djinni_generated::NativeColor>::toCpp(jniEnv, jret); +} + +CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_EnumUsageInterface_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + delete reinterpret_cast<::djinni::CppProxyHandle<::testsuite::EnumUsageInterface>*>(nativeRef); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_EnumUsageInterface_00024CppProxy_native_1e(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_e) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::EnumUsageInterface>(nativeRef); + auto r = ref->e(::djinni_generated::NativeColor::toCpp(jniEnv, j_e)); + return ::djinni::release(::djinni_generated::NativeColor::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_EnumUsageInterface_00024CppProxy_native_1o(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_o) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::EnumUsageInterface>(nativeRef); + auto r = ref->o(::djinni::Optional::toCpp(jniEnv, j_o)); + return ::djinni::release(::djinni::Optional::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_EnumUsageInterface_00024CppProxy_native_1l(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_l) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::EnumUsageInterface>(nativeRef); + auto r = ref->l(::djinni::List<::djinni_generated::NativeColor>::toCpp(jniEnv, j_l)); + return ::djinni::release(::djinni::List<::djinni_generated::NativeColor>::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_EnumUsageInterface_00024CppProxy_native_1s(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_s) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::EnumUsageInterface>(nativeRef); + auto r = ref->s(::djinni::Set<::djinni_generated::NativeColor>::toCpp(jniEnv, j_s)); + return ::djinni::release(::djinni::Set<::djinni_generated::NativeColor>::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_EnumUsageInterface_00024CppProxy_native_1m(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_m) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::EnumUsageInterface>(nativeRef); + auto r = ref->m(::djinni::Map<::djinni_generated::NativeColor, ::djinni_generated::NativeColor>::toCpp(jniEnv, j_m)); + return ::djinni::release(::djinni::Map<::djinni_generated::NativeColor, ::djinni_generated::NativeColor>::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeEnumUsageInterface.hpp b/test-suite/generated-src/jni/NativeEnumUsageInterface.hpp new file mode 100644 index 000000000..9710b002b --- /dev/null +++ b/test-suite/generated-src/jni/NativeEnumUsageInterface.hpp @@ -0,0 +1,54 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "enum_usage_interface.hpp" + +namespace djinni_generated { + +class NativeEnumUsageInterface final : ::djinni::JniInterface<::testsuite::EnumUsageInterface, NativeEnumUsageInterface> { +public: + using CppType = std::shared_ptr<::testsuite::EnumUsageInterface>; + using CppOptType = std::shared_ptr<::testsuite::EnumUsageInterface>; + using JniType = jobject; + + using Boxed = NativeEnumUsageInterface; + + ~NativeEnumUsageInterface(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeEnumUsageInterface(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::testsuite::EnumUsageInterface, NativeEnumUsageInterface>; + + class JavaProxy final : ::djinni::JavaProxyHandle, public ::testsuite::EnumUsageInterface + { + public: + JavaProxy(JniType j); + ~JavaProxy(); + + ::testsuite::color e(::testsuite::color e) override; + std::experimental::optional<::testsuite::color> o(std::experimental::optional<::testsuite::color> o) override; + std::vector<::testsuite::color> l(const std::vector<::testsuite::color> & l) override; + std::unordered_set<::testsuite::color> s(const std::unordered_set<::testsuite::color> & s) override; + std::unordered_map<::testsuite::color, ::testsuite::color> m(const std::unordered_map<::testsuite::color, ::testsuite::color> & m) override; + + private: + friend ::djinni::JniInterface<::testsuite::EnumUsageInterface, ::djinni_generated::NativeEnumUsageInterface>; + }; + + const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/EnumUsageInterface") }; + const jmethodID method_e { ::djinni::jniGetMethodID(clazz.get(), "e", "(Lcom/dropbox/djinni/test/Color;)Lcom/dropbox/djinni/test/Color;") }; + const jmethodID method_o { ::djinni::jniGetMethodID(clazz.get(), "o", "(Lcom/dropbox/djinni/test/Color;)Lcom/dropbox/djinni/test/Color;") }; + const jmethodID method_l { ::djinni::jniGetMethodID(clazz.get(), "l", "(Ljava/util/ArrayList;)Ljava/util/ArrayList;") }; + const jmethodID method_s { ::djinni::jniGetMethodID(clazz.get(), "s", "(Ljava/util/HashSet;)Ljava/util/HashSet;") }; + const jmethodID method_m { ::djinni::jniGetMethodID(clazz.get(), "m", "(Ljava/util/HashMap;)Ljava/util/HashMap;") }; +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeEnumUsageRecord.cpp b/test-suite/generated-src/jni/NativeEnumUsageRecord.cpp new file mode 100644 index 000000000..0460969ac --- /dev/null +++ b/test-suite/generated-src/jni/NativeEnumUsageRecord.cpp @@ -0,0 +1,37 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#include "NativeEnumUsageRecord.hpp" // my header +#include "Marshal.hpp" +#include "NativeColor.hpp" + +namespace djinni_generated { + +NativeEnumUsageRecord::NativeEnumUsageRecord() = default; + +NativeEnumUsageRecord::~NativeEnumUsageRecord() = default; + +auto NativeEnumUsageRecord::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef { + const auto& data = ::djinni::JniClass::get(); + auto r = ::djinni::LocalRef{jniEnv->NewObject(data.clazz.get(), data.jconstructor, + ::djinni::get(::djinni_generated::NativeColor::fromCpp(jniEnv, c.e)), + ::djinni::get(::djinni::Optional::fromCpp(jniEnv, c.o)), + ::djinni::get(::djinni::List<::djinni_generated::NativeColor>::fromCpp(jniEnv, c.l)), + ::djinni::get(::djinni::Set<::djinni_generated::NativeColor>::fromCpp(jniEnv, c.s)), + ::djinni::get(::djinni::Map<::djinni_generated::NativeColor, ::djinni_generated::NativeColor>::fromCpp(jniEnv, c.m)))}; + ::djinni::jniExceptionCheck(jniEnv); + return r; +} + +auto NativeEnumUsageRecord::toCpp(JNIEnv* jniEnv, JniType j) -> CppType { + ::djinni::JniLocalScope jscope(jniEnv, 6); + assert(j != nullptr); + const auto& data = ::djinni::JniClass::get(); + return {::djinni_generated::NativeColor::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mE)), + ::djinni::Optional::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mO)), + ::djinni::List<::djinni_generated::NativeColor>::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mL)), + ::djinni::Set<::djinni_generated::NativeColor>::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mS)), + ::djinni::Map<::djinni_generated::NativeColor, ::djinni_generated::NativeColor>::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mM))}; +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeEnumUsageRecord.hpp b/test-suite/generated-src/jni/NativeEnumUsageRecord.hpp new file mode 100644 index 000000000..fbc3bbfbd --- /dev/null +++ b/test-suite/generated-src/jni/NativeEnumUsageRecord.hpp @@ -0,0 +1,36 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "enum_usage_record.hpp" + +namespace djinni_generated { + +class NativeEnumUsageRecord final { +public: + using CppType = ::testsuite::EnumUsageRecord; + using JniType = jobject; + + using Boxed = NativeEnumUsageRecord; + + ~NativeEnumUsageRecord(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j); + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c); + +private: + NativeEnumUsageRecord(); + friend ::djinni::JniClass; + + const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/EnumUsageRecord") }; + const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "", "(Lcom/dropbox/djinni/test/Color;Lcom/dropbox/djinni/test/Color;Ljava/util/ArrayList;Ljava/util/HashSet;Ljava/util/HashMap;)V") }; + const jfieldID field_mE { ::djinni::jniGetFieldID(clazz.get(), "mE", "Lcom/dropbox/djinni/test/Color;") }; + const jfieldID field_mO { ::djinni::jniGetFieldID(clazz.get(), "mO", "Lcom/dropbox/djinni/test/Color;") }; + const jfieldID field_mL { ::djinni::jniGetFieldID(clazz.get(), "mL", "Ljava/util/ArrayList;") }; + const jfieldID field_mS { ::djinni::jniGetFieldID(clazz.get(), "mS", "Ljava/util/HashSet;") }; + const jfieldID field_mM { ::djinni::jniGetFieldID(clazz.get(), "mM", "Ljava/util/HashMap;") }; +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeListenerCaller.cpp b/test-suite/generated-src/jni/NativeListenerCaller.cpp index c8b10f0d2..ea5b2de3e 100644 --- a/test-suite/generated-src/jni/NativeListenerCaller.cpp +++ b/test-suite/generated-src/jni/NativeListenerCaller.cpp @@ -3,7 +3,6 @@ #include "NativeListenerCaller.hpp" // my header #include "NativeFirstListener.hpp" -#include "NativeListenerCaller.hpp" #include "NativeSecondListener.hpp" namespace djinni_generated { diff --git a/test-suite/generated-src/jni/NativeOptColorRecord.cpp b/test-suite/generated-src/jni/NativeOptColorRecord.cpp deleted file mode 100644 index d351766ed..000000000 --- a/test-suite/generated-src/jni/NativeOptColorRecord.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from enum.djinni - -#include "NativeOptColorRecord.hpp" // my header -#include "Marshal.hpp" -#include "NativeColor.hpp" - -namespace djinni_generated { - -NativeOptColorRecord::NativeOptColorRecord() = default; - -NativeOptColorRecord::~NativeOptColorRecord() = default; - -auto NativeOptColorRecord::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef { - const auto& data = ::djinni::JniClass::get(); - auto r = ::djinni::LocalRef{jniEnv->NewObject(data.clazz.get(), data.jconstructor, - ::djinni::get(::djinni::Optional::fromCpp(jniEnv, c.my_color)))}; - ::djinni::jniExceptionCheck(jniEnv); - return r; -} - -auto NativeOptColorRecord::toCpp(JNIEnv* jniEnv, JniType j) -> CppType { - ::djinni::JniLocalScope jscope(jniEnv, 2); - assert(j != nullptr); - const auto& data = ::djinni::JniClass::get(); - return {::djinni::Optional::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mMyColor))}; -} - -} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeOptColorRecord.hpp b/test-suite/generated-src/jni/NativeOptColorRecord.hpp deleted file mode 100644 index c01c9f83e..000000000 --- a/test-suite/generated-src/jni/NativeOptColorRecord.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from enum.djinni - -#pragma once - -#include "djinni_support.hpp" -#include "opt_color_record.hpp" - -namespace djinni_generated { - -class NativeOptColorRecord final { -public: - using CppType = ::testsuite::OptColorRecord; - using JniType = jobject; - - using Boxed = NativeOptColorRecord; - - ~NativeOptColorRecord(); - - static CppType toCpp(JNIEnv* jniEnv, JniType j); - static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c); - -private: - NativeOptColorRecord(); - friend ::djinni::JniClass; - - const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/OptColorRecord") }; - const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "", "(Lcom/dropbox/djinni/test/Color;)V") }; - const jfieldID field_mMyColor { ::djinni::jniGetFieldID(clazz.get(), "mMyColor", "Lcom/dropbox/djinni/test/Color;") }; -}; - -} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeReturnOne.cpp b/test-suite/generated-src/jni/NativeReturnOne.cpp index bd5fdb3cb..8b2690b53 100644 --- a/test-suite/generated-src/jni/NativeReturnOne.cpp +++ b/test-suite/generated-src/jni/NativeReturnOne.cpp @@ -3,7 +3,6 @@ #include "NativeReturnOne.hpp" // my header #include "Marshal.hpp" -#include "NativeReturnOne.hpp" namespace djinni_generated { diff --git a/test-suite/generated-src/jni/NativeReturnTwo.cpp b/test-suite/generated-src/jni/NativeReturnTwo.cpp index 2c3f5cb3f..0697e2983 100644 --- a/test-suite/generated-src/jni/NativeReturnTwo.cpp +++ b/test-suite/generated-src/jni/NativeReturnTwo.cpp @@ -3,7 +3,6 @@ #include "NativeReturnTwo.hpp" // my header #include "Marshal.hpp" -#include "NativeReturnTwo.hpp" namespace djinni_generated { diff --git a/test-suite/generated-src/jni/NativeReverseClientInterface.cpp b/test-suite/generated-src/jni/NativeReverseClientInterface.cpp index 16cbef876..013ab8e14 100644 --- a/test-suite/generated-src/jni/NativeReverseClientInterface.cpp +++ b/test-suite/generated-src/jni/NativeReverseClientInterface.cpp @@ -3,7 +3,6 @@ #include "NativeReverseClientInterface.hpp" // my header #include "Marshal.hpp" -#include "NativeReverseClientInterface.hpp" namespace djinni_generated { diff --git a/test-suite/generated-src/jni/NativeUsesSingleLanguageListeners.cpp b/test-suite/generated-src/jni/NativeUsesSingleLanguageListeners.cpp index 9ccb1d199..dd909ac1b 100644 --- a/test-suite/generated-src/jni/NativeUsesSingleLanguageListeners.cpp +++ b/test-suite/generated-src/jni/NativeUsesSingleLanguageListeners.cpp @@ -23,6 +23,14 @@ void NativeUsesSingleLanguageListeners::JavaProxy::callForObjC(const std::shared ::djinni::get(::djinni_generated::NativeObjcOnlyListener::fromCpp(jniEnv, c_l))); ::djinni::jniExceptionCheck(jniEnv); } +std::shared_ptr<::testsuite::ObjcOnlyListener> NativeUsesSingleLanguageListeners::JavaProxy::returnForObjC() { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeUsesSingleLanguageListeners>::get(); + auto jret = jniEnv->CallObjectMethod(Handle::get().get(), data.method_returnForObjC); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni_generated::NativeObjcOnlyListener::toCpp(jniEnv, jret); +} void NativeUsesSingleLanguageListeners::JavaProxy::callForJava(const std::shared_ptr<::testsuite::JavaOnlyListener> & c_l) { auto jniEnv = ::djinni::jniGetThreadEnv(); ::djinni::JniLocalScope jscope(jniEnv, 10); @@ -31,6 +39,14 @@ void NativeUsesSingleLanguageListeners::JavaProxy::callForJava(const std::shared ::djinni::get(::djinni_generated::NativeJavaOnlyListener::fromCpp(jniEnv, c_l))); ::djinni::jniExceptionCheck(jniEnv); } +std::shared_ptr<::testsuite::JavaOnlyListener> NativeUsesSingleLanguageListeners::JavaProxy::returnForJava() { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeUsesSingleLanguageListeners>::get(); + auto jret = jniEnv->CallObjectMethod(Handle::get().get(), data.method_returnForJava); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni_generated::NativeJavaOnlyListener::toCpp(jniEnv, jret); +} CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_UsesSingleLanguageListeners_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) { @@ -49,6 +65,16 @@ CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_UsesSingleLanguageListeners } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) } +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_UsesSingleLanguageListeners_00024CppProxy_native_1returnForObjC(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::UsesSingleLanguageListeners>(nativeRef); + auto r = ref->returnForObjC(); + return ::djinni::release(::djinni_generated::NativeObjcOnlyListener::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_UsesSingleLanguageListeners_00024CppProxy_native_1callForJava(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_l) { try { @@ -58,4 +84,14 @@ CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_UsesSingleLanguageListeners } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) } +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_UsesSingleLanguageListeners_00024CppProxy_native_1returnForJava(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::UsesSingleLanguageListeners>(nativeRef); + auto r = ref->returnForJava(); + return ::djinni::release(::djinni_generated::NativeJavaOnlyListener::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + } // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeUsesSingleLanguageListeners.hpp b/test-suite/generated-src/jni/NativeUsesSingleLanguageListeners.hpp index 86b30aaf5..75c639c79 100644 --- a/test-suite/generated-src/jni/NativeUsesSingleLanguageListeners.hpp +++ b/test-suite/generated-src/jni/NativeUsesSingleLanguageListeners.hpp @@ -34,7 +34,9 @@ class NativeUsesSingleLanguageListeners final : ::djinni::JniInterface<::testsui ~JavaProxy(); void callForObjC(const std::shared_ptr<::testsuite::ObjcOnlyListener> & l) override; + std::shared_ptr<::testsuite::ObjcOnlyListener> returnForObjC() override; void callForJava(const std::shared_ptr<::testsuite::JavaOnlyListener> & l) override; + std::shared_ptr<::testsuite::JavaOnlyListener> returnForJava() override; private: friend ::djinni::JniInterface<::testsuite::UsesSingleLanguageListeners, ::djinni_generated::NativeUsesSingleLanguageListeners>; @@ -42,7 +44,9 @@ class NativeUsesSingleLanguageListeners final : ::djinni::JniInterface<::testsui const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/UsesSingleLanguageListeners") }; const jmethodID method_callForObjC { ::djinni::jniGetMethodID(clazz.get(), "callForObjC", "(Lcom/dropbox/djinni/test/ObjcOnlyListener;)V") }; + const jmethodID method_returnForObjC { ::djinni::jniGetMethodID(clazz.get(), "returnForObjC", "()Lcom/dropbox/djinni/test/ObjcOnlyListener;") }; const jmethodID method_callForJava { ::djinni::jniGetMethodID(clazz.get(), "callForJava", "(Lcom/dropbox/djinni/test/JavaOnlyListener;)V") }; + const jmethodID method_returnForJava { ::djinni::jniGetMethodID(clazz.get(), "returnForJava", "()Lcom/dropbox/djinni/test/JavaOnlyListener;") }; }; } // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeVarnameInterface.cpp b/test-suite/generated-src/jni/NativeVarnameInterface.cpp new file mode 100644 index 000000000..ff5eb5038 --- /dev/null +++ b/test-suite/generated-src/jni/NativeVarnameInterface.cpp @@ -0,0 +1,42 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#include "NativeVarnameInterface.hpp" // my header +#include "NativeVarnameRecord.hpp" + +namespace djinni_generated { + +NativeVarnameInterface::NativeVarnameInterface() : ::djinni::JniInterface<::testsuite::VarnameInterface, NativeVarnameInterface>("com/dropbox/djinni/test/VarnameInterface$CppProxy") {} + +NativeVarnameInterface::~NativeVarnameInterface() = default; + + +CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_VarnameInterface_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + delete reinterpret_cast<::djinni::CppProxyHandle<::testsuite::VarnameInterface>*>(nativeRef); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_VarnameInterface_00024CppProxy_native_1Rmethod(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_RArg) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::VarnameInterface>(nativeRef); + auto r = ref->_rmethod_(::djinni_generated::NativeVarnameRecord::toCpp(jniEnv, j_RArg)); + return ::djinni::release(::djinni_generated::NativeVarnameRecord::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_VarnameInterface_00024CppProxy_native_1Imethod(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_IArg) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::VarnameInterface>(nativeRef); + auto r = ref->_imethod_(::djinni_generated::NativeVarnameInterface::toCpp(jniEnv, j_IArg)); + return ::djinni::release(::djinni_generated::NativeVarnameInterface::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeVarnameInterface.hpp b/test-suite/generated-src/jni/NativeVarnameInterface.hpp new file mode 100644 index 000000000..1b2845cab --- /dev/null +++ b/test-suite/generated-src/jni/NativeVarnameInterface.hpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#pragma once + +#include "_varname_interface_.hpp" +#include "djinni_support.hpp" + +namespace djinni_generated { + +class NativeVarnameInterface final : ::djinni::JniInterface<::testsuite::VarnameInterface, NativeVarnameInterface> { +public: + using CppType = std::shared_ptr<::testsuite::VarnameInterface>; + using CppOptType = std::shared_ptr<::testsuite::VarnameInterface>; + using JniType = jobject; + + using Boxed = NativeVarnameInterface; + + ~NativeVarnameInterface(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeVarnameInterface(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::testsuite::VarnameInterface, NativeVarnameInterface>; + +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeVarnameRecord.cpp b/test-suite/generated-src/jni/NativeVarnameRecord.cpp new file mode 100644 index 000000000..4d3e34293 --- /dev/null +++ b/test-suite/generated-src/jni/NativeVarnameRecord.cpp @@ -0,0 +1,28 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#include "NativeVarnameRecord.hpp" // my header +#include "Marshal.hpp" + +namespace djinni_generated { + +NativeVarnameRecord::NativeVarnameRecord() = default; + +NativeVarnameRecord::~NativeVarnameRecord() = default; + +auto NativeVarnameRecord::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef { + const auto& data = ::djinni::JniClass::get(); + auto r = ::djinni::LocalRef{jniEnv->NewObject(data.clazz.get(), data.jconstructor, + ::djinni::get(::djinni::I8::fromCpp(jniEnv, c._field_)))}; + ::djinni::jniExceptionCheck(jniEnv); + return r; +} + +auto NativeVarnameRecord::toCpp(JNIEnv* jniEnv, JniType j) -> CppType { + ::djinni::JniLocalScope jscope(jniEnv, 2); + assert(j != nullptr); + const auto& data = ::djinni::JniClass::get(); + return {::djinni::I8::toCpp(jniEnv, jniEnv->GetByteField(j, data.field_mField))}; +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeVarnameRecord.hpp b/test-suite/generated-src/jni/NativeVarnameRecord.hpp new file mode 100644 index 000000000..0462273b7 --- /dev/null +++ b/test-suite/generated-src/jni/NativeVarnameRecord.hpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#pragma once + +#include "_varname_record_.hpp" +#include "djinni_support.hpp" + +namespace djinni_generated { + +class NativeVarnameRecord final { +public: + using CppType = ::testsuite::VarnameRecord; + using JniType = jobject; + + using Boxed = NativeVarnameRecord; + + ~NativeVarnameRecord(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j); + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c); + +private: + NativeVarnameRecord(); + friend ::djinni::JniClass; + + const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/VarnameRecord") }; + const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "", "(B)V") }; + const jfieldID field_mField { ::djinni::jniGetFieldID(clazz.get(), "mField", "B") }; +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeWcharTestHelpers.cpp b/test-suite/generated-src/jni/NativeWcharTestHelpers.cpp new file mode 100644 index 000000000..19dd54fae --- /dev/null +++ b/test-suite/generated-src/jni/NativeWcharTestHelpers.cpp @@ -0,0 +1,59 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#include "NativeWcharTestHelpers.hpp" // my header +#include "Marshal.hpp" +#include "NativeWcharTestRec.hpp" + +namespace djinni_generated { + +NativeWcharTestHelpers::NativeWcharTestHelpers() : ::djinni::JniInterface<::testsuite::WcharTestHelpers, NativeWcharTestHelpers>("com/dropbox/djinni/test/WcharTestHelpers$CppProxy") {} + +NativeWcharTestHelpers::~NativeWcharTestHelpers() = default; + + +CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_WcharTestHelpers_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + delete reinterpret_cast<::djinni::CppProxyHandle<::testsuite::WcharTestHelpers>*>(nativeRef); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_WcharTestHelpers_getRecord(JNIEnv* jniEnv, jobject /*this*/) +{ + try { + DJINNI_FUNCTION_PROLOGUE0(jniEnv); + auto r = ::testsuite::WcharTestHelpers::get_record(); + return ::djinni::release(::djinni_generated::NativeWcharTestRec::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jstring JNICALL Java_com_dropbox_djinni_test_WcharTestHelpers_getString(JNIEnv* jniEnv, jobject /*this*/) +{ + try { + DJINNI_FUNCTION_PROLOGUE0(jniEnv); + auto r = ::testsuite::WcharTestHelpers::get_string(); + return ::djinni::release(::djinni::WString::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jboolean JNICALL Java_com_dropbox_djinni_test_WcharTestHelpers_checkString(JNIEnv* jniEnv, jobject /*this*/, jstring j_str) +{ + try { + DJINNI_FUNCTION_PROLOGUE0(jniEnv); + auto r = ::testsuite::WcharTestHelpers::check_string(::djinni::WString::toCpp(jniEnv, j_str)); + return ::djinni::release(::djinni::Bool::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jboolean JNICALL Java_com_dropbox_djinni_test_WcharTestHelpers_checkRecord(JNIEnv* jniEnv, jobject /*this*/, jobject j_rec) +{ + try { + DJINNI_FUNCTION_PROLOGUE0(jniEnv); + auto r = ::testsuite::WcharTestHelpers::check_record(::djinni_generated::NativeWcharTestRec::toCpp(jniEnv, j_rec)); + return ::djinni::release(::djinni::Bool::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeWcharTestHelpers.hpp b/test-suite/generated-src/jni/NativeWcharTestHelpers.hpp new file mode 100644 index 000000000..922c4ee5a --- /dev/null +++ b/test-suite/generated-src/jni/NativeWcharTestHelpers.hpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "wchar_test_helpers.hpp" + +namespace djinni_generated { + +class NativeWcharTestHelpers final : ::djinni::JniInterface<::testsuite::WcharTestHelpers, NativeWcharTestHelpers> { +public: + using CppType = std::shared_ptr<::testsuite::WcharTestHelpers>; + using CppOptType = std::shared_ptr<::testsuite::WcharTestHelpers>; + using JniType = jobject; + + using Boxed = NativeWcharTestHelpers; + + ~NativeWcharTestHelpers(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeWcharTestHelpers(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::testsuite::WcharTestHelpers, NativeWcharTestHelpers>; + +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeWcharTestRec.cpp b/test-suite/generated-src/jni/NativeWcharTestRec.cpp new file mode 100644 index 000000000..ee981e5b2 --- /dev/null +++ b/test-suite/generated-src/jni/NativeWcharTestRec.cpp @@ -0,0 +1,28 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#include "NativeWcharTestRec.hpp" // my header +#include "Marshal.hpp" + +namespace djinni_generated { + +NativeWcharTestRec::NativeWcharTestRec() = default; + +NativeWcharTestRec::~NativeWcharTestRec() = default; + +auto NativeWcharTestRec::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef { + const auto& data = ::djinni::JniClass::get(); + auto r = ::djinni::LocalRef{jniEnv->NewObject(data.clazz.get(), data.jconstructor, + ::djinni::get(::djinni::WString::fromCpp(jniEnv, c.s)))}; + ::djinni::jniExceptionCheck(jniEnv); + return r; +} + +auto NativeWcharTestRec::toCpp(JNIEnv* jniEnv, JniType j) -> CppType { + ::djinni::JniLocalScope jscope(jniEnv, 2); + assert(j != nullptr); + const auto& data = ::djinni::JniClass::get(); + return {::djinni::WString::toCpp(jniEnv, (jstring)jniEnv->GetObjectField(j, data.field_mS))}; +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeWcharTestRec.hpp b/test-suite/generated-src/jni/NativeWcharTestRec.hpp new file mode 100644 index 000000000..efa42ef40 --- /dev/null +++ b/test-suite/generated-src/jni/NativeWcharTestRec.hpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "wchar_test_rec.hpp" + +namespace djinni_generated { + +class NativeWcharTestRec final { +public: + using CppType = ::testsuite::WcharTestRec; + using JniType = jobject; + + using Boxed = NativeWcharTestRec; + + ~NativeWcharTestRec(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j); + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c); + +private: + NativeWcharTestRec(); + friend ::djinni::JniClass; + + const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/WcharTestRec") }; + const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "", "(Ljava/lang/String;)V") }; + const jfieldID field_mS { ::djinni::jniGetFieldID(clazz.get(), "mS", "Ljava/lang/String;") }; +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBClientInterface+Private.mm b/test-suite/generated-src/objc/DBClientInterface+Private.mm index 95f1bfad9..e6c41a554 100644 --- a/test-suite/generated-src/objc/DBClientInterface+Private.mm +++ b/test-suite/generated-src/objc/DBClientInterface+Private.mm @@ -3,10 +3,10 @@ #import "DBClientInterface+Private.h" #import "DBClientInterface.h" -#import "DBClientInterface+Private.h" #import "DBClientReturnedRecord+Private.h" #import "DJIMarshal+Private.h" #import "DJIObjcWrapperCache+Private.h" +#include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -18,43 +18,45 @@ { public: using Handle::Handle; + + // ClientInterface methods ::testsuite::ClientReturnedRecord get_record(int64_t c_record_id, const std::string & c_utf8string, const std::experimental::optional & c_misc) override { @autoreleasepool { - auto r = [Handle::get() getRecord:(::djinni::I64::fromCpp(c_record_id)) - utf8string:(::djinni::String::fromCpp(c_utf8string)) - misc:(::djinni::Optional::fromCpp(c_misc))]; - return ::djinni_generated::ClientReturnedRecord::toCpp(r); + auto objcpp_result_ = [Handle::get() getRecord:(::djinni::I64::fromCpp(c_record_id)) + utf8string:(::djinni::String::fromCpp(c_utf8string)) + misc:(::djinni::Optional::fromCpp(c_misc))]; + return ::djinni_generated::ClientReturnedRecord::toCpp(objcpp_result_); } } double identifier_check(const std::vector & c_data, int32_t c_r, int64_t c_jret) override { @autoreleasepool { - auto r = [Handle::get() identifierCheck:(::djinni::Binary::fromCpp(c_data)) - r:(::djinni::I32::fromCpp(c_r)) - jret:(::djinni::I64::fromCpp(c_jret))]; - return ::djinni::F64::toCpp(r); + auto objcpp_result_ = [Handle::get() identifierCheck:(::djinni::Binary::fromCpp(c_data)) + r:(::djinni::I32::fromCpp(c_r)) + jret:(::djinni::I64::fromCpp(c_jret))]; + return ::djinni::F64::toCpp(objcpp_result_); } } std::string return_str() override { @autoreleasepool { - auto r = [Handle::get() returnStr]; - return ::djinni::String::toCpp(r); + auto objcpp_result_ = [Handle::get() returnStr]; + return ::djinni::String::toCpp(objcpp_result_); } } 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); + auto objcpp_result_ = [Handle::get() methTakingInterface:(::djinni_generated::ClientInterface::fromCpp(c_i))]; + return ::djinni::String::toCpp(objcpp_result_); } } std::string meth_taking_optional_interface(const std::shared_ptr<::testsuite::ClientInterface> & c_i) override { @autoreleasepool { - auto r = [Handle::get() methTakingOptionalInterface:(::djinni::Optional::fromCpp(c_i))]; - return ::djinni::String::toCpp(r); + auto objcpp_result_ = [Handle::get() methTakingOptionalInterface:(::djinni::Optional::fromCpp(c_i))]; + return ::djinni::String::toCpp(objcpp_result_); } } }; diff --git a/test-suite/generated-src/objc/DBClientInterface.h b/test-suite/generated-src/objc/DBClientInterface.h index 73c7a883f..00b8f795b 100644 --- a/test-suite/generated-src/objc/DBClientInterface.h +++ b/test-suite/generated-src/objc/DBClientInterface.h @@ -7,7 +7,7 @@ /** Client interface */ -@protocol DBClientInterface +@protocol DBClientInterface /** Returns record of given string */ - (nonnull DBClientReturnedRecord *)getRecord:(int64_t)recordId diff --git a/test-suite/generated-src/objc/DBColor+Private.h b/test-suite/generated-src/objc/DBColor+Private.h new file mode 100644 index 000000000..018fa9ff0 --- /dev/null +++ b/test-suite/generated-src/objc/DBColor+Private.h @@ -0,0 +1,6 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#include "color.hpp" +#import "DJIMarshal+Private.h" + diff --git a/test-suite/generated-src/objc/DBConflict+Private.mm b/test-suite/generated-src/objc/DBConflict+Private.mm index 46d0b9459..69ea9eae4 100644 --- a/test-suite/generated-src/objc/DBConflict+Private.mm +++ b/test-suite/generated-src/objc/DBConflict+Private.mm @@ -6,6 +6,7 @@ #import "DJICppWrapperCache+Private.h" #import "DJIError.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -28,6 +29,13 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::Conflict>&)cppRef return self; } +- (const std::shared_ptr<::testsuite::Conflict>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBConflict methods + namespace djinni_generated { auto Conflict::toCpp(ObjcType objc) -> CppType @@ -35,7 +43,7 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::Conflict>&)cppRef if (!objc) { return nullptr; } - return objc->_cppRefHandle.get(); + return [objc cppRef]; } auto Conflict::fromCppOpt(const CppOptType& cpp) -> ObjcType diff --git a/test-suite/generated-src/objc/DBConflictUser+Private.mm b/test-suite/generated-src/objc/DBConflictUser+Private.mm index a17ed6909..069e69ed6 100644 --- a/test-suite/generated-src/objc/DBConflictUser+Private.mm +++ b/test-suite/generated-src/objc/DBConflictUser+Private.mm @@ -8,6 +8,7 @@ #import "DJIError.h" #import "DJIMarshal+Private.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -30,17 +31,24 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::ConflictUser>&)cppRef return self; } +- (const std::shared_ptr<::testsuite::ConflictUser>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBConflictUser methods + - (nullable DBConflict *)Conflict { try { - auto r = _cppRefHandle.get()->Conflict(); - return ::djinni_generated::Conflict::fromCpp(r); + auto objcpp_result_ = _cppRefHandle.get()->Conflict(); + return ::djinni_generated::Conflict::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } - (BOOL)conflictArg:(nonnull NSSet *)cs { try { - auto r = _cppRefHandle.get()->conflict_arg(::djinni::Set<::djinni_generated::Conflict>::toCpp(cs)); - return ::djinni::Bool::fromCpp(r); + auto objcpp_result_ = _cppRefHandle.get()->conflict_arg(::djinni::Set<::djinni_generated::Conflict>::toCpp(cs)); + return ::djinni::Bool::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -51,7 +59,7 @@ - (BOOL)conflictArg:(nonnull NSSet *)cs { if (!objc) { return nullptr; } - return objc->_cppRefHandle.get(); + return [objc cppRef]; } auto ConflictUser::fromCppOpt(const CppOptType& cpp) -> ObjcType diff --git a/test-suite/generated-src/objc/DBConstantsInterface+Private.mm b/test-suite/generated-src/objc/DBConstantsInterface+Private.mm index 28d34f0cd..52950b879 100644 --- a/test-suite/generated-src/objc/DBConstantsInterface+Private.mm +++ b/test-suite/generated-src/objc/DBConstantsInterface+Private.mm @@ -8,6 +8,7 @@ #import "DJIError.h" #import "DJIMarshal+Private.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -30,6 +31,13 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::ConstantsInterface>&)cppRe return self; } +- (const std::shared_ptr<::testsuite::ConstantsInterface>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBConstantsInterface methods + - (void)dummy { try { _cppRefHandle.get()->dummy(); @@ -93,7 +101,7 @@ + (DBConstantRecord * __nonnull)objectConstant if (!objc) { return nullptr; } - return objc->_cppRefHandle.get(); + return [objc cppRef]; } auto ConstantsInterface::fromCppOpt(const CppOptType& cpp) -> ObjcType diff --git a/test-suite/generated-src/objc/DBCppException+Private.mm b/test-suite/generated-src/objc/DBCppException+Private.mm index d64717f03..08f779a1a 100644 --- a/test-suite/generated-src/objc/DBCppException+Private.mm +++ b/test-suite/generated-src/objc/DBCppException+Private.mm @@ -3,11 +3,11 @@ #import "DBCppException+Private.h" #import "DBCppException.h" -#import "DBCppException+Private.h" #import "DJICppWrapperCache+Private.h" #import "DJIError.h" #import "DJIMarshal+Private.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -30,17 +30,24 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::CppException>&)cppRef return self; } +- (const std::shared_ptr<::testsuite::CppException>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBCppException methods + - (int32_t)throwAnException { try { - auto r = _cppRefHandle.get()->throw_an_exception(); - return ::djinni::I32::fromCpp(r); + auto objcpp_result_ = _cppRefHandle.get()->throw_an_exception(); + return ::djinni::I32::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nullable DBCppException *)get { try { - auto r = ::testsuite::CppException::get(); - return ::djinni_generated::CppException::fromCpp(r); + auto objcpp_result_ = ::testsuite::CppException::get(); + return ::djinni_generated::CppException::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -51,7 +58,7 @@ + (nullable DBCppException *)get { if (!objc) { return nullptr; } - return objc->_cppRefHandle.get(); + return [objc cppRef]; } auto CppException::fromCppOpt(const CppOptType& cpp) -> ObjcType diff --git a/test-suite/generated-src/objc/DBEnumUsageInterface+Private.h b/test-suite/generated-src/objc/DBEnumUsageInterface+Private.h new file mode 100644 index 000000000..80debb368 --- /dev/null +++ b/test-suite/generated-src/objc/DBEnumUsageInterface+Private.h @@ -0,0 +1,31 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#include "enum_usage_interface.hpp" +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@protocol DBEnumUsageInterface; + +namespace djinni_generated { + +class EnumUsageInterface +{ +public: + using CppType = std::shared_ptr<::testsuite::EnumUsageInterface>; + using CppOptType = std::shared_ptr<::testsuite::EnumUsageInterface>; + using ObjcType = id; + + using Boxed = EnumUsageInterface; + + 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 + diff --git a/test-suite/generated-src/objc/DBEnumUsageInterface+Private.mm b/test-suite/generated-src/objc/DBEnumUsageInterface+Private.mm new file mode 100644 index 000000000..7e3e69658 --- /dev/null +++ b/test-suite/generated-src/objc/DBEnumUsageInterface+Private.mm @@ -0,0 +1,152 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#import "DBEnumUsageInterface+Private.h" +#import "DBEnumUsageInterface.h" +#import "DBColor+Private.h" +#import "DJICppWrapperCache+Private.h" +#import "DJIError.h" +#import "DJIMarshal+Private.h" +#import "DJIObjcWrapperCache+Private.h" +#include +#include +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@interface DBEnumUsageInterfaceCppProxy : NSObject + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::EnumUsageInterface>&)cppRef; + +@end + +@implementation DBEnumUsageInterfaceCppProxy { + ::djinni::CppProxyCache::Handle> _cppRefHandle; +} + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::EnumUsageInterface>&)cppRef +{ + if (self = [super init]) { + _cppRefHandle.assign(cppRef); + } + return self; +} + +- (const std::shared_ptr<::testsuite::EnumUsageInterface>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBEnumUsageInterfaceCppProxy methods + +- (DBColor)e:(DBColor)e { + try { + auto objcpp_result_ = _cppRefHandle.get()->e(::djinni::Enum<::testsuite::color, DBColor>::toCpp(e)); + return ::djinni::Enum<::testsuite::color, DBColor>::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (nullable NSNumber *)o:(nullable NSNumber *)o { + try { + auto objcpp_result_ = _cppRefHandle.get()->o(::djinni::Optional>::toCpp(o)); + return ::djinni::Optional>::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (nonnull NSArray *)l:(nonnull NSArray *)l { + try { + auto objcpp_result_ = _cppRefHandle.get()->l(::djinni::List<::djinni::Enum<::testsuite::color, DBColor>>::toCpp(l)); + return ::djinni::List<::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (nonnull NSSet *)s:(nonnull NSSet *)s { + try { + auto objcpp_result_ = _cppRefHandle.get()->s(::djinni::Set<::djinni::Enum<::testsuite::color, DBColor>>::toCpp(s)); + return ::djinni::Set<::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (nonnull NSDictionary *)m:(nonnull NSDictionary *)m { + try { + auto objcpp_result_ = _cppRefHandle.get()->m(::djinni::Map<::djinni::Enum<::testsuite::color, DBColor>, ::djinni::Enum<::testsuite::color, DBColor>>::toCpp(m)); + return ::djinni::Map<::djinni::Enum<::testsuite::color, DBColor>, ::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +namespace djinni_generated { + +class EnumUsageInterface::ObjcProxy final +: public ::testsuite::EnumUsageInterface +, public ::djinni::ObjcProxyCache::Handle +{ +public: + using Handle::Handle; + + // EnumUsageInterface methods + ::testsuite::color e(::testsuite::color c_e) override + { + @autoreleasepool { + auto objcpp_result_ = [Handle::get() e:(::djinni::Enum<::testsuite::color, DBColor>::fromCpp(c_e))]; + return ::djinni::Enum<::testsuite::color, DBColor>::toCpp(objcpp_result_); + } + } + std::experimental::optional<::testsuite::color> o(std::experimental::optional<::testsuite::color> c_o) override + { + @autoreleasepool { + auto objcpp_result_ = [Handle::get() o:(::djinni::Optional>::fromCpp(c_o))]; + return ::djinni::Optional>::toCpp(objcpp_result_); + } + } + std::vector<::testsuite::color> l(const std::vector<::testsuite::color> & c_l) override + { + @autoreleasepool { + auto objcpp_result_ = [Handle::get() l:(::djinni::List<::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(c_l))]; + return ::djinni::List<::djinni::Enum<::testsuite::color, DBColor>>::toCpp(objcpp_result_); + } + } + std::unordered_set<::testsuite::color> s(const std::unordered_set<::testsuite::color> & c_s) override + { + @autoreleasepool { + auto objcpp_result_ = [Handle::get() s:(::djinni::Set<::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(c_s))]; + return ::djinni::Set<::djinni::Enum<::testsuite::color, DBColor>>::toCpp(objcpp_result_); + } + } + std::unordered_map<::testsuite::color, ::testsuite::color> m(const std::unordered_map<::testsuite::color, ::testsuite::color> & c_m) override + { + @autoreleasepool { + auto objcpp_result_ = [Handle::get() m:(::djinni::Map<::djinni::Enum<::testsuite::color, DBColor>, ::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(c_m))]; + return ::djinni::Map<::djinni::Enum<::testsuite::color, DBColor>, ::djinni::Enum<::testsuite::color, DBColor>>::toCpp(objcpp_result_); + } + } +}; + +} // namespace djinni_generated + +namespace djinni_generated { + +auto EnumUsageInterface::toCpp(ObjcType objc) -> CppType +{ + if (!objc) { + return nullptr; + } + if ([(id)objc isKindOfClass:[DBEnumUsageInterfaceCppProxy class]]) { + return ((DBEnumUsageInterfaceCppProxy*)objc)->_cppRefHandle.get(); + } + return ::djinni::get_objc_proxy(objc); +} + +auto EnumUsageInterface::fromCppOpt(const CppOptType& cpp) -> ObjcType +{ + if (!cpp) { + return nil; + } + if (auto cppPtr = dynamic_cast(cpp.get())) { + return cppPtr->Handle::get(); + } + return ::djinni::get_cpp_proxy(cpp); +} + +} // namespace djinni_generated + +@end diff --git a/test-suite/generated-src/objc/DBEnumUsageInterface.h b/test-suite/generated-src/objc/DBEnumUsageInterface.h new file mode 100644 index 000000000..e7ecea940 --- /dev/null +++ b/test-suite/generated-src/objc/DBEnumUsageInterface.h @@ -0,0 +1,20 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#import "DBColor.h" +#import + + +@protocol DBEnumUsageInterface + +- (DBColor)e:(DBColor)e; + +- (nullable NSNumber *)o:(nullable NSNumber *)o; + +- (nonnull NSArray *)l:(nonnull NSArray *)l; + +- (nonnull NSSet *)s:(nonnull NSSet *)s; + +- (nonnull NSDictionary *)m:(nonnull NSDictionary *)m; + +@end diff --git a/test-suite/generated-src/objc/DBOptColorRecord+Private.h b/test-suite/generated-src/objc/DBEnumUsageRecord+Private.h similarity index 59% rename from test-suite/generated-src/objc/DBOptColorRecord+Private.h rename to test-suite/generated-src/objc/DBEnumUsageRecord+Private.h index 91b0fdd87..49168caca 100644 --- a/test-suite/generated-src/objc/DBOptColorRecord+Private.h +++ b/test-suite/generated-src/objc/DBEnumUsageRecord+Private.h @@ -1,21 +1,21 @@ // AUTOGENERATED FILE - DO NOT MODIFY! // This file generated by Djinni from enum.djinni -#import "DBOptColorRecord.h" -#include "opt_color_record.hpp" +#import "DBEnumUsageRecord.h" +#include "enum_usage_record.hpp" static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); -@class DBOptColorRecord; +@class DBEnumUsageRecord; namespace djinni_generated { -struct OptColorRecord +struct EnumUsageRecord { - using CppType = ::testsuite::OptColorRecord; - using ObjcType = DBOptColorRecord*; + using CppType = ::testsuite::EnumUsageRecord; + using ObjcType = DBEnumUsageRecord*; - using Boxed = OptColorRecord; + using Boxed = EnumUsageRecord; static CppType toCpp(ObjcType objc); static ObjcType fromCpp(const CppType& cpp); diff --git a/test-suite/generated-src/objc/DBEnumUsageRecord+Private.mm b/test-suite/generated-src/objc/DBEnumUsageRecord+Private.mm new file mode 100644 index 000000000..2f21a3b69 --- /dev/null +++ b/test-suite/generated-src/objc/DBEnumUsageRecord+Private.mm @@ -0,0 +1,30 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#import "DBEnumUsageRecord+Private.h" +#import "DBColor+Private.h" +#import "DJIMarshal+Private.h" +#include + +namespace djinni_generated { + +auto EnumUsageRecord::toCpp(ObjcType obj) -> CppType +{ + assert(obj); + return {::djinni::Enum<::testsuite::color, DBColor>::toCpp(obj.e), + ::djinni::Optional>::toCpp(obj.o), + ::djinni::List<::djinni::Enum<::testsuite::color, DBColor>>::toCpp(obj.l), + ::djinni::Set<::djinni::Enum<::testsuite::color, DBColor>>::toCpp(obj.s), + ::djinni::Map<::djinni::Enum<::testsuite::color, DBColor>, ::djinni::Enum<::testsuite::color, DBColor>>::toCpp(obj.m)}; +} + +auto EnumUsageRecord::fromCpp(const CppType& cpp) -> ObjcType +{ + return [[DBEnumUsageRecord alloc] initWithE:(::djinni::Enum<::testsuite::color, DBColor>::fromCpp(cpp.e)) + o:(::djinni::Optional>::fromCpp(cpp.o)) + l:(::djinni::List<::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(cpp.l)) + s:(::djinni::Set<::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(cpp.s)) + m:(::djinni::Map<::djinni::Enum<::testsuite::color, DBColor>, ::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(cpp.m))]; +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBEnumUsageRecord.h b/test-suite/generated-src/objc/DBEnumUsageRecord.h new file mode 100644 index 000000000..cbc7f0952 --- /dev/null +++ b/test-suite/generated-src/objc/DBEnumUsageRecord.h @@ -0,0 +1,29 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#import "DBColor.h" +#import + +@interface DBEnumUsageRecord : NSObject +- (nonnull instancetype)initWithE:(DBColor)e + o:(nullable NSNumber *)o + l:(nonnull NSArray *)l + s:(nonnull NSSet *)s + m:(nonnull NSDictionary *)m; ++ (nonnull instancetype)enumUsageRecordWithE:(DBColor)e + o:(nullable NSNumber *)o + l:(nonnull NSArray *)l + s:(nonnull NSSet *)s + m:(nonnull NSDictionary *)m; + +@property (nonatomic, readonly) DBColor e; + +@property (nonatomic, readonly, nullable) NSNumber * o; + +@property (nonatomic, readonly, nonnull) NSArray * l; + +@property (nonatomic, readonly, nonnull) NSSet * s; + +@property (nonatomic, readonly, nonnull) NSDictionary * m; + +@end diff --git a/test-suite/generated-src/objc/DBEnumUsageRecord.mm b/test-suite/generated-src/objc/DBEnumUsageRecord.mm new file mode 100644 index 000000000..94a311561 --- /dev/null +++ b/test-suite/generated-src/objc/DBEnumUsageRecord.mm @@ -0,0 +1,43 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from enum.djinni + +#import "DBEnumUsageRecord.h" + + +@implementation DBEnumUsageRecord + +- (nonnull instancetype)initWithE:(DBColor)e + o:(nullable NSNumber *)o + l:(nonnull NSArray *)l + s:(nonnull NSSet *)s + m:(nonnull NSDictionary *)m +{ + if (self = [super init]) { + _e = e; + _o = o; + _l = [l copy]; + _s = [s copy]; + _m = [m copy]; + } + return self; +} + ++ (nonnull instancetype)enumUsageRecordWithE:(DBColor)e + o:(nullable NSNumber *)o + l:(nonnull NSArray *)l + s:(nonnull NSSet *)s + m:(nonnull NSDictionary *)m +{ + return [[self alloc] initWithE:e + o:o + l:l + s:s + m:m]; +} + +- (NSString *)description +{ + return [NSString stringWithFormat:@"<%@ %p e:%@ o:%@ l:%@ s:%@ m:%@>", self.class, (void *)self, @(self.e), self.o, self.l, self.s, self.m]; +} + +@end diff --git a/test-suite/generated-src/objc/DBExtendedRecord+Private.mm b/test-suite/generated-src/objc/DBExtendedRecord+Private.mm index ab10e1f25..69413f8d6 100644 --- a/test-suite/generated-src/objc/DBExtendedRecord+Private.mm +++ b/test-suite/generated-src/objc/DBExtendedRecord+Private.mm @@ -1,7 +1,6 @@ // AUTOGENERATED FILE - DO NOT MODIFY! // This file generated by Djinni from extended_record.djinni -#import "DBExtendedRecord+Private.h" #import "DBExtendedRecord+Private.h" #import "DJIMarshal+Private.h" #include diff --git a/test-suite/generated-src/objc/DBExternInterface1+Private.mm b/test-suite/generated-src/objc/DBExternInterface1+Private.mm index 34c07564c..d118b48c1 100644 --- a/test-suite/generated-src/objc/DBExternInterface1+Private.mm +++ b/test-suite/generated-src/objc/DBExternInterface1+Private.mm @@ -8,6 +8,7 @@ #import "DJICppWrapperCache+Private.h" #import "DJIError.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -30,10 +31,17 @@ - (id)initWithCpp:(const std::shared_ptr<::ExternInterface1>&)cppRef return self; } +- (const std::shared_ptr<::ExternInterface1>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBExternInterface1 methods + - (nonnull DBClientReturnedRecord *)foo:(nullable id)i { try { - auto r = _cppRefHandle.get()->foo(::djinni_generated::ClientInterface::toCpp(i)); - return ::djinni_generated::ClientReturnedRecord::fromCpp(r); + auto objcpp_result_ = _cppRefHandle.get()->foo(::djinni_generated::ClientInterface::toCpp(i)); + return ::djinni_generated::ClientReturnedRecord::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -44,7 +52,7 @@ - (nonnull DBClientReturnedRecord *)foo:(nullable id)i { if (!objc) { return nullptr; } - return objc->_cppRefHandle.get(); + return [objc cppRef]; } auto ExternInterface1::fromCppOpt(const CppOptType& cpp) -> ObjcType diff --git a/test-suite/generated-src/objc/DBExternInterface2+Private.mm b/test-suite/generated-src/objc/DBExternInterface2+Private.mm index 6e3c4e461..98ce0cdb3 100644 --- a/test-suite/generated-src/objc/DBExternInterface2+Private.mm +++ b/test-suite/generated-src/objc/DBExternInterface2+Private.mm @@ -6,6 +6,7 @@ #import "DBExternRecordWithDerivings+Private.h" #import "DBTestHelpers+Private.h" #import "DJIObjcWrapperCache+Private.h" +#include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -17,11 +18,13 @@ { public: using Handle::Handle; + + // ExternInterface2 methods ::ExternRecordWithDerivings foo(const std::shared_ptr<::testsuite::TestHelpers> & c_i) override { @autoreleasepool { - auto r = [Handle::get() foo:(::djinni_generated::TestHelpers::fromCpp(c_i))]; - return ::djinni_generated::ExternRecordWithDerivings::toCpp(r); + auto objcpp_result_ = [Handle::get() foo:(::djinni_generated::TestHelpers::fromCpp(c_i))]; + return ::djinni_generated::ExternRecordWithDerivings::toCpp(objcpp_result_); } } }; diff --git a/test-suite/generated-src/objc/DBExternInterface2.h b/test-suite/generated-src/objc/DBExternInterface2.h index e027ebcff..2a19a8ae5 100644 --- a/test-suite/generated-src/objc/DBExternInterface2.h +++ b/test-suite/generated-src/objc/DBExternInterface2.h @@ -6,7 +6,7 @@ #import -@protocol DBExternInterface2 +@protocol DBExternInterface2 - (nonnull DBExternRecordWithDerivings *)foo:(nullable DBTestHelpers *)i; diff --git a/test-suite/generated-src/objc/DBExternRecordWithDerivings+Private.mm b/test-suite/generated-src/objc/DBExternRecordWithDerivings+Private.mm index 6d3cd729d..cbb9559c9 100644 --- a/test-suite/generated-src/objc/DBExternRecordWithDerivings+Private.mm +++ b/test-suite/generated-src/objc/DBExternRecordWithDerivings+Private.mm @@ -2,8 +2,8 @@ // This file generated by Djinni from yaml-test.djinni #import "DBExternRecordWithDerivings+Private.h" +#import "DBColor+Private.h" #import "DBRecordWithDerivings+Private.h" -#import "DJIMarshal+Private.h" #include namespace djinni_generated { diff --git a/test-suite/generated-src/objc/DBFirstListener+Private.mm b/test-suite/generated-src/objc/DBFirstListener+Private.mm index 6e1a33b39..2d00bdde9 100644 --- a/test-suite/generated-src/objc/DBFirstListener+Private.mm +++ b/test-suite/generated-src/objc/DBFirstListener+Private.mm @@ -4,6 +4,7 @@ #import "DBFirstListener+Private.h" #import "DBFirstListener.h" #import "DJIObjcWrapperCache+Private.h" +#include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -15,6 +16,8 @@ { public: using Handle::Handle; + + // FirstListener methods void first() override { @autoreleasepool { diff --git a/test-suite/generated-src/objc/DBFirstListener.h b/test-suite/generated-src/objc/DBFirstListener.h index d5da0c67c..76ca07df2 100644 --- a/test-suite/generated-src/objc/DBFirstListener.h +++ b/test-suite/generated-src/objc/DBFirstListener.h @@ -5,7 +5,7 @@ /** Used for ObjC multiple inheritance tests */ -@protocol DBFirstListener +@protocol DBFirstListener - (void)first; diff --git a/test-suite/generated-src/objc/DBJavaOnlyListener+Private.mm b/test-suite/generated-src/objc/DBJavaOnlyListener+Private.mm index d9d73715c..bfce2c889 100644 --- a/test-suite/generated-src/objc/DBJavaOnlyListener+Private.mm +++ b/test-suite/generated-src/objc/DBJavaOnlyListener+Private.mm @@ -1,7 +1,10 @@ // AUTOGENERATED FILE - DO NOT MODIFY! // This file generated by Djinni from single_language_interfaces.djinni +#import "DBJavaOnlyListener+Private.h" #import "DBJavaOnlyListener.h" +#import "DJIError.h" +#include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -12,7 +15,7 @@ if (!objc) { return nullptr; } - return ::djinni::get_objc_proxy(objc); + DJINNI_UNIMPLEMENTED(@"Interface not implementable in any language."); } auto JavaOnlyListener::fromCppOpt(const CppOptType& cpp) -> ObjcType @@ -20,7 +23,7 @@ if (!cpp) { return nil; } - return ::djinni::get_cpp_proxy(cpp); + DJINNI_UNIMPLEMENTED(@"Interface not implementable in any language."); } } // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBListenerCaller+Private.mm b/test-suite/generated-src/objc/DBListenerCaller+Private.mm index 855fe17c5..4fd1e18da 100644 --- a/test-suite/generated-src/objc/DBListenerCaller+Private.mm +++ b/test-suite/generated-src/objc/DBListenerCaller+Private.mm @@ -4,11 +4,11 @@ #import "DBListenerCaller+Private.h" #import "DBListenerCaller.h" #import "DBFirstListener+Private.h" -#import "DBListenerCaller+Private.h" #import "DBSecondListener+Private.h" #import "DJICppWrapperCache+Private.h" #import "DJIError.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -31,12 +31,19 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::ListenerCaller>&)cppRef return self; } +- (const std::shared_ptr<::testsuite::ListenerCaller>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBListenerCaller methods + + (nullable DBListenerCaller *)init:(nullable id)firstL secondL:(nullable id)secondL { try { - auto r = ::testsuite::ListenerCaller::init(::djinni_generated::FirstListener::toCpp(firstL), - ::djinni_generated::SecondListener::toCpp(secondL)); - return ::djinni_generated::ListenerCaller::fromCpp(r); + auto objcpp_result_ = ::testsuite::ListenerCaller::init(::djinni_generated::FirstListener::toCpp(firstL), + ::djinni_generated::SecondListener::toCpp(secondL)); + return ::djinni_generated::ListenerCaller::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -59,7 +66,7 @@ - (void)callSecond { if (!objc) { return nullptr; } - return objc->_cppRefHandle.get(); + return [objc cppRef]; } auto ListenerCaller::fromCppOpt(const CppOptType& cpp) -> ObjcType diff --git a/test-suite/generated-src/objc/DBObjcOnlyListener+Private.mm b/test-suite/generated-src/objc/DBObjcOnlyListener+Private.mm index 3002520f6..6ebe49cb3 100644 --- a/test-suite/generated-src/objc/DBObjcOnlyListener+Private.mm +++ b/test-suite/generated-src/objc/DBObjcOnlyListener+Private.mm @@ -4,6 +4,7 @@ #import "DBObjcOnlyListener+Private.h" #import "DBObjcOnlyListener.h" #import "DJIObjcWrapperCache+Private.h" +#include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -15,6 +16,8 @@ { public: using Handle::Handle; + + // ObjcOnlyListener methods }; } // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBObjcOnlyListener.h b/test-suite/generated-src/objc/DBObjcOnlyListener.h index e79cd9c57..cae84c18d 100644 --- a/test-suite/generated-src/objc/DBObjcOnlyListener.h +++ b/test-suite/generated-src/objc/DBObjcOnlyListener.h @@ -4,6 +4,6 @@ #import -@protocol DBObjcOnlyListener +@protocol DBObjcOnlyListener @end diff --git a/test-suite/generated-src/objc/DBOptColorRecord+Private.mm b/test-suite/generated-src/objc/DBOptColorRecord+Private.mm deleted file mode 100644 index 1ab0d4a09..000000000 --- a/test-suite/generated-src/objc/DBOptColorRecord+Private.mm +++ /dev/null @@ -1,21 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from enum.djinni - -#import "DBOptColorRecord+Private.h" -#import "DJIMarshal+Private.h" -#include - -namespace djinni_generated { - -auto OptColorRecord::toCpp(ObjcType obj) -> CppType -{ - assert(obj); - return {::djinni::Optional>::toCpp(obj.myColor)}; -} - -auto OptColorRecord::fromCpp(const CppType& cpp) -> ObjcType -{ - return [[DBOptColorRecord alloc] initWithMyColor:(::djinni::Optional>::fromCpp(cpp.my_color))]; -} - -} // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBOptColorRecord.h b/test-suite/generated-src/objc/DBOptColorRecord.h deleted file mode 100644 index a8e16a476..000000000 --- a/test-suite/generated-src/objc/DBOptColorRecord.h +++ /dev/null @@ -1,13 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from enum.djinni - -#import "DBColor.h" -#import - -@interface DBOptColorRecord : NSObject -- (nonnull instancetype)initWithMyColor:(nullable NSNumber *)myColor; -+ (nonnull instancetype)optColorRecordWithMyColor:(nullable NSNumber *)myColor; - -@property (nonatomic, readonly, nullable) NSNumber * myColor; - -@end diff --git a/test-suite/generated-src/objc/DBOptColorRecord.mm b/test-suite/generated-src/objc/DBOptColorRecord.mm deleted file mode 100644 index c2643beda..000000000 --- a/test-suite/generated-src/objc/DBOptColorRecord.mm +++ /dev/null @@ -1,27 +0,0 @@ -// AUTOGENERATED FILE - DO NOT MODIFY! -// This file generated by Djinni from enum.djinni - -#import "DBOptColorRecord.h" - - -@implementation DBOptColorRecord - -- (nonnull instancetype)initWithMyColor:(nullable NSNumber *)myColor -{ - if (self = [super init]) { - _myColor = myColor; - } - return self; -} - -+ (nonnull instancetype)optColorRecordWithMyColor:(nullable NSNumber *)myColor -{ - return [[self alloc] initWithMyColor:myColor]; -} - -- (NSString *)description -{ - return [NSString stringWithFormat:@"<%@ %p myColor:%@>", self.class, (void *)self, self.myColor]; -} - -@end diff --git a/test-suite/generated-src/objc/DBReturnOne+Private.mm b/test-suite/generated-src/objc/DBReturnOne+Private.mm index ebacf8025..eaa7479d7 100644 --- a/test-suite/generated-src/objc/DBReturnOne+Private.mm +++ b/test-suite/generated-src/objc/DBReturnOne+Private.mm @@ -3,11 +3,11 @@ #import "DBReturnOne+Private.h" #import "DBReturnOne.h" -#import "DBReturnOne+Private.h" #import "DJICppWrapperCache+Private.h" #import "DJIError.h" #import "DJIMarshal+Private.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -30,17 +30,24 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::ReturnOne>&)cppRef return self; } +- (const std::shared_ptr<::testsuite::ReturnOne>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBReturnOne methods + + (nullable DBReturnOne *)getInstance { try { - auto r = ::testsuite::ReturnOne::get_instance(); - return ::djinni_generated::ReturnOne::fromCpp(r); + auto objcpp_result_ = ::testsuite::ReturnOne::get_instance(); + return ::djinni_generated::ReturnOne::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } - (int8_t)returnOne { try { - auto r = _cppRefHandle.get()->return_one(); - return ::djinni::I8::fromCpp(r); + auto objcpp_result_ = _cppRefHandle.get()->return_one(); + return ::djinni::I8::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -51,7 +58,7 @@ - (int8_t)returnOne { if (!objc) { return nullptr; } - return objc->_cppRefHandle.get(); + return [objc cppRef]; } auto ReturnOne::fromCppOpt(const CppOptType& cpp) -> ObjcType diff --git a/test-suite/generated-src/objc/DBReturnTwo+Private.mm b/test-suite/generated-src/objc/DBReturnTwo+Private.mm index ca6201a39..9c3d20439 100644 --- a/test-suite/generated-src/objc/DBReturnTwo+Private.mm +++ b/test-suite/generated-src/objc/DBReturnTwo+Private.mm @@ -3,11 +3,11 @@ #import "DBReturnTwo+Private.h" #import "DBReturnTwo.h" -#import "DBReturnTwo+Private.h" #import "DJICppWrapperCache+Private.h" #import "DJIError.h" #import "DJIMarshal+Private.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -30,17 +30,24 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::ReturnTwo>&)cppRef return self; } +- (const std::shared_ptr<::testsuite::ReturnTwo>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBReturnTwo methods + + (nullable DBReturnTwo *)getInstance { try { - auto r = ::testsuite::ReturnTwo::get_instance(); - return ::djinni_generated::ReturnTwo::fromCpp(r); + auto objcpp_result_ = ::testsuite::ReturnTwo::get_instance(); + return ::djinni_generated::ReturnTwo::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } - (int8_t)returnTwo { try { - auto r = _cppRefHandle.get()->return_two(); - return ::djinni::I8::fromCpp(r); + auto objcpp_result_ = _cppRefHandle.get()->return_two(); + return ::djinni::I8::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -51,7 +58,7 @@ - (int8_t)returnTwo { if (!objc) { return nullptr; } - return objc->_cppRefHandle.get(); + return [objc cppRef]; } auto ReturnTwo::fromCppOpt(const CppOptType& cpp) -> ObjcType diff --git a/test-suite/generated-src/objc/DBReverseClientInterface+Private.mm b/test-suite/generated-src/objc/DBReverseClientInterface+Private.mm index 391059729..229740d1a 100644 --- a/test-suite/generated-src/objc/DBReverseClientInterface+Private.mm +++ b/test-suite/generated-src/objc/DBReverseClientInterface+Private.mm @@ -3,11 +3,11 @@ #import "DBReverseClientInterface+Private.h" #import "DBReverseClientInterface.h" -#import "DBReverseClientInterface+Private.h" #import "DJICppWrapperCache+Private.h" #import "DJIError.h" #import "DJIMarshal+Private.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -30,31 +30,38 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::ReverseClientInterface>&)c return self; } +- (const std::shared_ptr<::testsuite::ReverseClientInterface>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBReverseClientInterface methods + - (nonnull NSString *)returnStr { try { - auto r = _cppRefHandle.get()->return_str(); - return ::djinni::String::fromCpp(r); + auto objcpp_result_ = _cppRefHandle.get()->return_str(); + return ::djinni::String::fromCpp(objcpp_result_); } 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); + auto objcpp_result_ = _cppRefHandle.get()->meth_taking_interface(::djinni_generated::ReverseClientInterface::toCpp(i)); + return ::djinni::String::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } - (nonnull NSString *)methTakingOptionalInterface:(nullable DBReverseClientInterface *)i { try { - auto r = _cppRefHandle.get()->meth_taking_optional_interface(::djinni::Optional::toCpp(i)); - return ::djinni::String::fromCpp(r); + auto objcpp_result_ = _cppRefHandle.get()->meth_taking_optional_interface(::djinni::Optional::toCpp(i)); + return ::djinni::String::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nullable DBReverseClientInterface *)create { try { - auto r = ::testsuite::ReverseClientInterface::create(); - return ::djinni_generated::ReverseClientInterface::fromCpp(r); + auto objcpp_result_ = ::testsuite::ReverseClientInterface::create(); + return ::djinni_generated::ReverseClientInterface::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -65,7 +72,7 @@ + (nullable DBReverseClientInterface *)create { if (!objc) { return nullptr; } - return objc->_cppRefHandle.get(); + return [objc cppRef]; } auto ReverseClientInterface::fromCppOpt(const CppOptType& cpp) -> ObjcType diff --git a/test-suite/generated-src/objc/DBSecondListener+Private.mm b/test-suite/generated-src/objc/DBSecondListener+Private.mm index 83ed60720..a896d1bde 100644 --- a/test-suite/generated-src/objc/DBSecondListener+Private.mm +++ b/test-suite/generated-src/objc/DBSecondListener+Private.mm @@ -4,6 +4,7 @@ #import "DBSecondListener+Private.h" #import "DBSecondListener.h" #import "DJIObjcWrapperCache+Private.h" +#include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -15,6 +16,8 @@ { public: using Handle::Handle; + + // SecondListener methods void second() override { @autoreleasepool { diff --git a/test-suite/generated-src/objc/DBSecondListener.h b/test-suite/generated-src/objc/DBSecondListener.h index 28a03a42d..3f99836f9 100644 --- a/test-suite/generated-src/objc/DBSecondListener.h +++ b/test-suite/generated-src/objc/DBSecondListener.h @@ -5,7 +5,7 @@ /** Used for ObjC multiple inheritance tests */ -@protocol DBSecondListener +@protocol DBSecondListener - (void)second; diff --git a/test-suite/generated-src/objc/DBTestDuration+Private.mm b/test-suite/generated-src/objc/DBTestDuration+Private.mm index b0d597746..36c9aa922 100644 --- a/test-suite/generated-src/objc/DBTestDuration+Private.mm +++ b/test-suite/generated-src/objc/DBTestDuration+Private.mm @@ -8,6 +8,7 @@ #import "DJIMarshal+Private.h" #import "Duration-objc.hpp" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -30,143 +31,150 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::TestDuration>&)cppRef return self; } +- (const std::shared_ptr<::testsuite::TestDuration>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBTestDuration methods + + (nonnull NSString *)hoursString:(NSTimeInterval)dt { try { - auto r = ::testsuite::TestDuration::hoursString(::djinni::Duration<::djinni::I32, ::djinni::Duration_h>::toCpp(dt)); - return ::djinni::String::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::hoursString(::djinni::Duration<::djinni::I32, ::djinni::Duration_h>::toCpp(dt)); + return ::djinni::String::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull NSString *)minutesString:(NSTimeInterval)dt { try { - auto r = ::testsuite::TestDuration::minutesString(::djinni::Duration<::djinni::I32, ::djinni::Duration_min>::toCpp(dt)); - return ::djinni::String::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::minutesString(::djinni::Duration<::djinni::I32, ::djinni::Duration_min>::toCpp(dt)); + return ::djinni::String::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull NSString *)secondsString:(NSTimeInterval)dt { try { - auto r = ::testsuite::TestDuration::secondsString(::djinni::Duration<::djinni::I32, ::djinni::Duration_s>::toCpp(dt)); - return ::djinni::String::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::secondsString(::djinni::Duration<::djinni::I32, ::djinni::Duration_s>::toCpp(dt)); + return ::djinni::String::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull NSString *)millisString:(NSTimeInterval)dt { try { - auto r = ::testsuite::TestDuration::millisString(::djinni::Duration<::djinni::I32, ::djinni::Duration_ms>::toCpp(dt)); - return ::djinni::String::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::millisString(::djinni::Duration<::djinni::I32, ::djinni::Duration_ms>::toCpp(dt)); + return ::djinni::String::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull NSString *)microsString:(NSTimeInterval)dt { try { - auto r = ::testsuite::TestDuration::microsString(::djinni::Duration<::djinni::I32, ::djinni::Duration_us>::toCpp(dt)); - return ::djinni::String::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::microsString(::djinni::Duration<::djinni::I32, ::djinni::Duration_us>::toCpp(dt)); + return ::djinni::String::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull NSString *)nanosString:(NSTimeInterval)dt { try { - auto r = ::testsuite::TestDuration::nanosString(::djinni::Duration<::djinni::I32, ::djinni::Duration_ns>::toCpp(dt)); - return ::djinni::String::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::nanosString(::djinni::Duration<::djinni::I32, ::djinni::Duration_ns>::toCpp(dt)); + return ::djinni::String::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (NSTimeInterval)hours:(int32_t)count { try { - auto r = ::testsuite::TestDuration::hours(::djinni::I32::toCpp(count)); - return ::djinni::Duration<::djinni::I32, ::djinni::Duration_h>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::hours(::djinni::I32::toCpp(count)); + return ::djinni::Duration<::djinni::I32, ::djinni::Duration_h>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (NSTimeInterval)minutes:(int32_t)count { try { - auto r = ::testsuite::TestDuration::minutes(::djinni::I32::toCpp(count)); - return ::djinni::Duration<::djinni::I32, ::djinni::Duration_min>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::minutes(::djinni::I32::toCpp(count)); + return ::djinni::Duration<::djinni::I32, ::djinni::Duration_min>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (NSTimeInterval)seconds:(int32_t)count { try { - auto r = ::testsuite::TestDuration::seconds(::djinni::I32::toCpp(count)); - return ::djinni::Duration<::djinni::I32, ::djinni::Duration_s>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::seconds(::djinni::I32::toCpp(count)); + return ::djinni::Duration<::djinni::I32, ::djinni::Duration_s>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (NSTimeInterval)millis:(int32_t)count { try { - auto r = ::testsuite::TestDuration::millis(::djinni::I32::toCpp(count)); - return ::djinni::Duration<::djinni::I32, ::djinni::Duration_ms>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::millis(::djinni::I32::toCpp(count)); + return ::djinni::Duration<::djinni::I32, ::djinni::Duration_ms>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (NSTimeInterval)micros:(int32_t)count { try { - auto r = ::testsuite::TestDuration::micros(::djinni::I32::toCpp(count)); - return ::djinni::Duration<::djinni::I32, ::djinni::Duration_us>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::micros(::djinni::I32::toCpp(count)); + return ::djinni::Duration<::djinni::I32, ::djinni::Duration_us>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (NSTimeInterval)nanos:(int32_t)count { try { - auto r = ::testsuite::TestDuration::nanos(::djinni::I32::toCpp(count)); - return ::djinni::Duration<::djinni::I32, ::djinni::Duration_ns>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::nanos(::djinni::I32::toCpp(count)); + return ::djinni::Duration<::djinni::I32, ::djinni::Duration_ns>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (NSTimeInterval)hoursf:(double)count { try { - auto r = ::testsuite::TestDuration::hoursf(::djinni::F64::toCpp(count)); - return ::djinni::Duration<::djinni::F64, ::djinni::Duration_h>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::hoursf(::djinni::F64::toCpp(count)); + return ::djinni::Duration<::djinni::F64, ::djinni::Duration_h>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (NSTimeInterval)minutesf:(double)count { try { - auto r = ::testsuite::TestDuration::minutesf(::djinni::F64::toCpp(count)); - return ::djinni::Duration<::djinni::F64, ::djinni::Duration_min>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::minutesf(::djinni::F64::toCpp(count)); + return ::djinni::Duration<::djinni::F64, ::djinni::Duration_min>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (NSTimeInterval)secondsf:(double)count { try { - auto r = ::testsuite::TestDuration::secondsf(::djinni::F64::toCpp(count)); - return ::djinni::Duration<::djinni::F64, ::djinni::Duration_s>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::secondsf(::djinni::F64::toCpp(count)); + return ::djinni::Duration<::djinni::F64, ::djinni::Duration_s>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (NSTimeInterval)millisf:(double)count { try { - auto r = ::testsuite::TestDuration::millisf(::djinni::F64::toCpp(count)); - return ::djinni::Duration<::djinni::F64, ::djinni::Duration_ms>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::millisf(::djinni::F64::toCpp(count)); + return ::djinni::Duration<::djinni::F64, ::djinni::Duration_ms>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (NSTimeInterval)microsf:(double)count { try { - auto r = ::testsuite::TestDuration::microsf(::djinni::F64::toCpp(count)); - return ::djinni::Duration<::djinni::F64, ::djinni::Duration_us>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::microsf(::djinni::F64::toCpp(count)); + return ::djinni::Duration<::djinni::F64, ::djinni::Duration_us>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (NSTimeInterval)nanosf:(double)count { try { - auto r = ::testsuite::TestDuration::nanosf(::djinni::F64::toCpp(count)); - return ::djinni::Duration<::djinni::F64, ::djinni::Duration_ns>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::nanosf(::djinni::F64::toCpp(count)); + return ::djinni::Duration<::djinni::F64, ::djinni::Duration_ns>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nullable NSNumber *)box:(int64_t)count { try { - auto r = ::testsuite::TestDuration::box(::djinni::I64::toCpp(count)); - return ::djinni::Optional>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::box(::djinni::I64::toCpp(count)); + return ::djinni::Optional>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (int64_t)unbox:(nullable NSNumber *)dt { try { - auto r = ::testsuite::TestDuration::unbox(::djinni::Optional>::toCpp(dt)); - return ::djinni::I64::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestDuration::unbox(::djinni::Optional>::toCpp(dt)); + return ::djinni::I64::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -177,7 +185,7 @@ + (int64_t)unbox:(nullable NSNumber *)dt { if (!objc) { return nullptr; } - return objc->_cppRefHandle.get(); + return [objc cppRef]; } auto TestDuration::fromCppOpt(const CppOptType& cpp) -> ObjcType diff --git a/test-suite/generated-src/objc/DBTestHelpers+Private.mm b/test-suite/generated-src/objc/DBTestHelpers+Private.mm index f51065b7f..93ad92d93 100644 --- a/test-suite/generated-src/objc/DBTestHelpers+Private.mm +++ b/test-suite/generated-src/objc/DBTestHelpers+Private.mm @@ -5,6 +5,7 @@ #import "DBTestHelpers.h" #import "DBAssortedPrimitives+Private.h" #import "DBClientInterface+Private.h" +#import "DBColor+Private.h" #import "DBMapListRecord+Private.h" #import "DBNestedCollection+Private.h" #import "DBPrimitiveList+Private.h" @@ -14,6 +15,7 @@ #import "DJIError.h" #import "DJIMarshal+Private.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -36,87 +38,94 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::TestHelpers>&)cppRef return self; } +- (const std::shared_ptr<::testsuite::TestHelpers>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBTestHelpers methods + + (nonnull DBSetRecord *)getSetRecord { try { - auto r = ::testsuite::TestHelpers::get_set_record(); - return ::djinni_generated::SetRecord::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::get_set_record(); + return ::djinni_generated::SetRecord::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (BOOL)checkSetRecord:(nonnull DBSetRecord *)rec { try { - auto r = ::testsuite::TestHelpers::check_set_record(::djinni_generated::SetRecord::toCpp(rec)); - return ::djinni::Bool::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::check_set_record(::djinni_generated::SetRecord::toCpp(rec)); + return ::djinni::Bool::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull DBPrimitiveList *)getPrimitiveList { try { - auto r = ::testsuite::TestHelpers::get_primitive_list(); - return ::djinni_generated::PrimitiveList::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::get_primitive_list(); + return ::djinni_generated::PrimitiveList::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (BOOL)checkPrimitiveList:(nonnull DBPrimitiveList *)pl { try { - auto r = ::testsuite::TestHelpers::check_primitive_list(::djinni_generated::PrimitiveList::toCpp(pl)); - return ::djinni::Bool::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::check_primitive_list(::djinni_generated::PrimitiveList::toCpp(pl)); + return ::djinni::Bool::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull DBNestedCollection *)getNestedCollection { try { - auto r = ::testsuite::TestHelpers::get_nested_collection(); - return ::djinni_generated::NestedCollection::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::get_nested_collection(); + return ::djinni_generated::NestedCollection::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (BOOL)checkNestedCollection:(nonnull DBNestedCollection *)nc { try { - auto r = ::testsuite::TestHelpers::check_nested_collection(::djinni_generated::NestedCollection::toCpp(nc)); - return ::djinni::Bool::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::check_nested_collection(::djinni_generated::NestedCollection::toCpp(nc)); + return ::djinni::Bool::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull NSDictionary *)getMap { try { - auto r = ::testsuite::TestHelpers::get_map(); - return ::djinni::Map<::djinni::String, ::djinni::I64>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::get_map(); + return ::djinni::Map<::djinni::String, ::djinni::I64>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (BOOL)checkMap:(nonnull NSDictionary *)m { try { - auto r = ::testsuite::TestHelpers::check_map(::djinni::Map<::djinni::String, ::djinni::I64>::toCpp(m)); - return ::djinni::Bool::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::check_map(::djinni::Map<::djinni::String, ::djinni::I64>::toCpp(m)); + return ::djinni::Bool::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull NSDictionary *)getEmptyMap { try { - auto r = ::testsuite::TestHelpers::get_empty_map(); - return ::djinni::Map<::djinni::String, ::djinni::I64>::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::get_empty_map(); + return ::djinni::Map<::djinni::String, ::djinni::I64>::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (BOOL)checkEmptyMap:(nonnull NSDictionary *)m { try { - auto r = ::testsuite::TestHelpers::check_empty_map(::djinni::Map<::djinni::String, ::djinni::I64>::toCpp(m)); - return ::djinni::Bool::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::check_empty_map(::djinni::Map<::djinni::String, ::djinni::I64>::toCpp(m)); + return ::djinni::Bool::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull DBMapListRecord *)getMapListRecord { try { - auto r = ::testsuite::TestHelpers::get_map_list_record(); - return ::djinni_generated::MapListRecord::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::get_map_list_record(); + return ::djinni_generated::MapListRecord::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (BOOL)checkMapListRecord:(nonnull DBMapListRecord *)m { try { - auto r = ::testsuite::TestHelpers::check_map_list_record(::djinni_generated::MapListRecord::toCpp(m)); - return ::djinni::Bool::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::check_map_list_record(::djinni_generated::MapListRecord::toCpp(m)); + return ::djinni::Bool::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -152,15 +161,15 @@ + (void)checkEnum:(DBColor)c { + (nullable id)tokenId:(nullable id)t { try { - auto r = ::testsuite::TestHelpers::token_id(::djinni_generated::UserToken::toCpp(t)); - return ::djinni_generated::UserToken::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::token_id(::djinni_generated::UserToken::toCpp(t)); + return ::djinni_generated::UserToken::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nullable id)createCppToken { try { - auto r = ::testsuite::TestHelpers::create_cpp_token(); - return ::djinni_generated::UserToken::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::create_cpp_token(); + return ::djinni_generated::UserToken::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -172,8 +181,8 @@ + (void)checkCppToken:(nullable id)t { + (int64_t)cppTokenId:(nullable id)t { try { - auto r = ::testsuite::TestHelpers::cpp_token_id(::djinni_generated::UserToken::toCpp(t)); - return ::djinni::I64::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::cpp_token_id(::djinni_generated::UserToken::toCpp(t)); + return ::djinni::I64::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -187,22 +196,22 @@ + (void)checkTokenType:(nullable id)t + (nullable NSNumber *)returnNone { try { - auto r = ::testsuite::TestHelpers::return_none(); - return ::djinni::Optional::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::return_none(); + return ::djinni::Optional::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull DBAssortedPrimitives *)assortedPrimitivesId:(nonnull DBAssortedPrimitives *)i { try { - auto r = ::testsuite::TestHelpers::assorted_primitives_id(::djinni_generated::AssortedPrimitives::toCpp(i)); - return ::djinni_generated::AssortedPrimitives::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::assorted_primitives_id(::djinni_generated::AssortedPrimitives::toCpp(i)); + return ::djinni_generated::AssortedPrimitives::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } + (nonnull NSData *)idBinary:(nonnull NSData *)b { try { - auto r = ::testsuite::TestHelpers::id_binary(::djinni::Binary::toCpp(b)); - return ::djinni::Binary::fromCpp(r); + auto objcpp_result_ = ::testsuite::TestHelpers::id_binary(::djinni::Binary::toCpp(b)); + return ::djinni::Binary::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -213,7 +222,7 @@ + (nonnull NSData *)idBinary:(nonnull NSData *)b { if (!objc) { return nullptr; } - return objc->_cppRefHandle.get(); + return [objc cppRef]; } auto TestHelpers::fromCppOpt(const CppOptType& cpp) -> ObjcType diff --git a/test-suite/generated-src/objc/DBUserToken+Private.mm b/test-suite/generated-src/objc/DBUserToken+Private.mm index 51e8c012d..6d3750fbf 100644 --- a/test-suite/generated-src/objc/DBUserToken+Private.mm +++ b/test-suite/generated-src/objc/DBUserToken+Private.mm @@ -8,6 +8,7 @@ #import "DJIMarshal+Private.h" #import "DJIObjcWrapperCache+Private.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -30,10 +31,17 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::UserToken>&)cppRef return self; } +- (const std::shared_ptr<::testsuite::UserToken>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBUserTokenCppProxy methods + - (nonnull NSString *)whoami { try { - auto r = _cppRefHandle.get()->whoami(); - return ::djinni::String::fromCpp(r); + auto objcpp_result_ = _cppRefHandle.get()->whoami(); + return ::djinni::String::fromCpp(objcpp_result_); } DJINNI_TRANSLATE_EXCEPTIONS() } @@ -45,11 +53,13 @@ - (nonnull NSString *)whoami { { public: using Handle::Handle; + + // UserToken methods std::string whoami() override { @autoreleasepool { - auto r = [Handle::get() whoami]; - return ::djinni::String::toCpp(r); + auto objcpp_result_ = [Handle::get() whoami]; + return ::djinni::String::toCpp(objcpp_result_); } } }; diff --git a/test-suite/generated-src/objc/DBUserToken.h b/test-suite/generated-src/objc/DBUserToken.h index 82c9f3f7c..6cd587b29 100644 --- a/test-suite/generated-src/objc/DBUserToken.h +++ b/test-suite/generated-src/objc/DBUserToken.h @@ -4,7 +4,7 @@ #import -@protocol DBUserToken +@protocol DBUserToken - (nonnull NSString *)whoami; diff --git a/test-suite/generated-src/objc/DBUsesSingleLanguageListeners+Private.mm b/test-suite/generated-src/objc/DBUsesSingleLanguageListeners+Private.mm index fbf6bed7c..0bb1848d0 100644 --- a/test-suite/generated-src/objc/DBUsesSingleLanguageListeners+Private.mm +++ b/test-suite/generated-src/objc/DBUsesSingleLanguageListeners+Private.mm @@ -9,6 +9,7 @@ #import "DJIError.h" #import "DJIObjcWrapperCache+Private.h" #include +#include #include static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); @@ -31,18 +32,39 @@ - (id)initWithCpp:(const std::shared_ptr<::testsuite::UsesSingleLanguageListener return self; } +- (const std::shared_ptr<::testsuite::UsesSingleLanguageListeners>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBUsesSingleLanguageListenersCppProxy methods + - (void)callForObjC:(nullable id)l { try { _cppRefHandle.get()->callForObjC(::djinni_generated::ObjcOnlyListener::toCpp(l)); } DJINNI_TRANSLATE_EXCEPTIONS() } -- (void)callForJava:(nullable id)l { +- (nullable id)returnForObjC { + try { + auto objcpp_result_ = _cppRefHandle.get()->returnForObjC(); + return ::djinni_generated::ObjcOnlyListener::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (void)callForJava:(nullable DBJavaOnlyListener *)l { try { _cppRefHandle.get()->callForJava(::djinni_generated::JavaOnlyListener::toCpp(l)); } DJINNI_TRANSLATE_EXCEPTIONS() } +- (nullable DBJavaOnlyListener *)returnForJava { + try { + auto objcpp_result_ = _cppRefHandle.get()->returnForJava(); + return ::djinni_generated::JavaOnlyListener::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + namespace djinni_generated { class UsesSingleLanguageListeners::ObjcProxy final @@ -51,18 +73,34 @@ - (void)callForJava:(nullable id)l { { public: using Handle::Handle; + + // UsesSingleLanguageListeners methods void callForObjC(const std::shared_ptr<::testsuite::ObjcOnlyListener> & c_l) override { @autoreleasepool { [Handle::get() callForObjC:(::djinni_generated::ObjcOnlyListener::fromCpp(c_l))]; } } + std::shared_ptr<::testsuite::ObjcOnlyListener> returnForObjC() override + { + @autoreleasepool { + auto objcpp_result_ = [Handle::get() returnForObjC]; + return ::djinni_generated::ObjcOnlyListener::toCpp(objcpp_result_); + } + } void callForJava(const std::shared_ptr<::testsuite::JavaOnlyListener> & c_l) override { @autoreleasepool { [Handle::get() callForJava:(::djinni_generated::JavaOnlyListener::fromCpp(c_l))]; } } + std::shared_ptr<::testsuite::JavaOnlyListener> returnForJava() override + { + @autoreleasepool { + auto objcpp_result_ = [Handle::get() returnForJava]; + return ::djinni_generated::JavaOnlyListener::toCpp(objcpp_result_); + } + } }; } // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBUsesSingleLanguageListeners.h b/test-suite/generated-src/objc/DBUsesSingleLanguageListeners.h index e36040803..a60bbc5cc 100644 --- a/test-suite/generated-src/objc/DBUsesSingleLanguageListeners.h +++ b/test-suite/generated-src/objc/DBUsesSingleLanguageListeners.h @@ -2,7 +2,7 @@ // This file generated by Djinni from single_language_interfaces.djinni #import -@protocol DBJavaOnlyListener; +@class DBJavaOnlyListener; @protocol DBObjcOnlyListener; @@ -10,10 +10,14 @@ * Generating and compiling this makes sure other languages don't break * on references to interfaces they don't need. */ -@protocol DBUsesSingleLanguageListeners +@protocol DBUsesSingleLanguageListeners - (void)callForObjC:(nullable id)l; -- (void)callForJava:(nullable id)l; +- (nullable id)returnForObjC; + +- (void)callForJava:(nullable DBJavaOnlyListener *)l; + +- (nullable DBJavaOnlyListener *)returnForJava; @end diff --git a/test-suite/generated-src/objc/DBVarnameInterface+Private.h b/test-suite/generated-src/objc/DBVarnameInterface+Private.h new file mode 100644 index 000000000..ce03e6180 --- /dev/null +++ b/test-suite/generated-src/objc/DBVarnameInterface+Private.h @@ -0,0 +1,31 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#include "_varname_interface_.hpp" +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@class DBVarnameInterface; + +namespace djinni_generated { + +class VarnameInterface +{ +public: + using CppType = std::shared_ptr<::testsuite::VarnameInterface>; + using CppOptType = std::shared_ptr<::testsuite::VarnameInterface>; + using ObjcType = DBVarnameInterface*; + + using Boxed = VarnameInterface; + + 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 + diff --git a/test-suite/generated-src/objc/DBVarnameInterface+Private.mm b/test-suite/generated-src/objc/DBVarnameInterface+Private.mm new file mode 100644 index 000000000..ad0674e54 --- /dev/null +++ b/test-suite/generated-src/objc/DBVarnameInterface+Private.mm @@ -0,0 +1,74 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#import "DBVarnameInterface+Private.h" +#import "DBVarnameInterface.h" +#import "DBVarnameRecord+Private.h" +#import "DJICppWrapperCache+Private.h" +#import "DJIError.h" +#include +#include +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@interface DBVarnameInterface () + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::VarnameInterface>&)cppRef; + +@end + +@implementation DBVarnameInterface { + ::djinni::CppProxyCache::Handle> _cppRefHandle; +} + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::VarnameInterface>&)cppRef +{ + if (self = [super init]) { + _cppRefHandle.assign(cppRef); + } + return self; +} + +- (const std::shared_ptr<::testsuite::VarnameInterface>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBVarnameInterface methods + +- (nonnull DBVarnameRecord *)Rmethod:(nonnull DBVarnameRecord *)RArg { + try { + auto objcpp_result_ = _cppRefHandle.get()->_rmethod_(::djinni_generated::VarnameRecord::toCpp(RArg)); + return ::djinni_generated::VarnameRecord::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (nullable DBVarnameInterface *)Imethod:(nullable DBVarnameInterface *)IArg { + try { + auto objcpp_result_ = _cppRefHandle.get()->_imethod_(::djinni_generated::VarnameInterface::toCpp(IArg)); + return ::djinni_generated::VarnameInterface::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +namespace djinni_generated { + +auto VarnameInterface::toCpp(ObjcType objc) -> CppType +{ + if (!objc) { + return nullptr; + } + return [objc cppRef]; +} + +auto VarnameInterface::fromCppOpt(const CppOptType& cpp) -> ObjcType +{ + if (!cpp) { + return nil; + } + return ::djinni::get_cpp_proxy(cpp); +} + +} // namespace djinni_generated + +@end diff --git a/test-suite/generated-src/objc/DBVarnameInterface.h b/test-suite/generated-src/objc/DBVarnameInterface.h new file mode 100644 index 000000000..ec27c0279 --- /dev/null +++ b/test-suite/generated-src/objc/DBVarnameInterface.h @@ -0,0 +1,15 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#import "DBVarnameRecord.h" +#import +@class DBVarnameInterface; + + +@interface DBVarnameInterface : NSObject + +- (nonnull DBVarnameRecord *)Rmethod:(nonnull DBVarnameRecord *)RArg; + +- (nullable DBVarnameInterface *)Imethod:(nullable DBVarnameInterface *)IArg; + +@end diff --git a/test-suite/generated-src/objc/DBVarnameRecord+Private.h b/test-suite/generated-src/objc/DBVarnameRecord+Private.h new file mode 100644 index 000000000..b1c1ee563 --- /dev/null +++ b/test-suite/generated-src/objc/DBVarnameRecord+Private.h @@ -0,0 +1,24 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#import "DBVarnameRecord.h" +#include "_varname_record_.hpp" + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@class DBVarnameRecord; + +namespace djinni_generated { + +struct VarnameRecord +{ + using CppType = ::testsuite::VarnameRecord; + using ObjcType = DBVarnameRecord*; + + using Boxed = VarnameRecord; + + static CppType toCpp(ObjcType objc); + static ObjcType fromCpp(const CppType& cpp); +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBVarnameRecord+Private.mm b/test-suite/generated-src/objc/DBVarnameRecord+Private.mm new file mode 100644 index 000000000..fd1325418 --- /dev/null +++ b/test-suite/generated-src/objc/DBVarnameRecord+Private.mm @@ -0,0 +1,21 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#import "DBVarnameRecord+Private.h" +#import "DJIMarshal+Private.h" +#include + +namespace djinni_generated { + +auto VarnameRecord::toCpp(ObjcType obj) -> CppType +{ + assert(obj); + return {::djinni::I8::toCpp(obj.Field)}; +} + +auto VarnameRecord::fromCpp(const CppType& cpp) -> ObjcType +{ + return [[DBVarnameRecord alloc] initWithField:(::djinni::I8::fromCpp(cpp._field_))]; +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBVarnameRecord.h b/test-suite/generated-src/objc/DBVarnameRecord.h new file mode 100644 index 000000000..5c20f1175 --- /dev/null +++ b/test-suite/generated-src/objc/DBVarnameRecord.h @@ -0,0 +1,17 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#import + +/** + * Underscore is used as a separator in Djinni names, so we don't really + * anticipate it to be used as a prefix/suffix. Some name styles behave + * badly when it is. However this test case ensures we at least don't crash. + */ +@interface DBVarnameRecord : NSObject +- (nonnull instancetype)initWithField:(int8_t)Field; ++ (nonnull instancetype)VarnameRecordWithField:(int8_t)Field; + +@property (nonatomic, readonly) int8_t Field; + +@end diff --git a/test-suite/generated-src/objc/DBVarnameRecord.mm b/test-suite/generated-src/objc/DBVarnameRecord.mm new file mode 100644 index 000000000..4cd8f7244 --- /dev/null +++ b/test-suite/generated-src/objc/DBVarnameRecord.mm @@ -0,0 +1,27 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from varnames.djinni + +#import "DBVarnameRecord.h" + + +@implementation DBVarnameRecord + +- (nonnull instancetype)initWithField:(int8_t)Field +{ + if (self = [super init]) { + _Field = Field; + } + return self; +} + ++ (nonnull instancetype)VarnameRecordWithField:(int8_t)Field +{ + return [[self alloc] initWithField:Field]; +} + +- (NSString *)description +{ + return [NSString stringWithFormat:@"<%@ %p Field:%@>", self.class, (void *)self, @(self.Field)]; +} + +@end diff --git a/test-suite/generated-src/objc/DBWcharTestHelpers+Private.h b/test-suite/generated-src/objc/DBWcharTestHelpers+Private.h new file mode 100644 index 000000000..94292faaa --- /dev/null +++ b/test-suite/generated-src/objc/DBWcharTestHelpers+Private.h @@ -0,0 +1,31 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#include "wchar_test_helpers.hpp" +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@class DBWcharTestHelpers; + +namespace djinni_generated { + +class WcharTestHelpers +{ +public: + using CppType = std::shared_ptr<::testsuite::WcharTestHelpers>; + using CppOptType = std::shared_ptr<::testsuite::WcharTestHelpers>; + using ObjcType = DBWcharTestHelpers*; + + using Boxed = WcharTestHelpers; + + 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 + diff --git a/test-suite/generated-src/objc/DBWcharTestHelpers+Private.mm b/test-suite/generated-src/objc/DBWcharTestHelpers+Private.mm new file mode 100644 index 000000000..29243ef29 --- /dev/null +++ b/test-suite/generated-src/objc/DBWcharTestHelpers+Private.mm @@ -0,0 +1,89 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#import "DBWcharTestHelpers+Private.h" +#import "DBWcharTestHelpers.h" +#import "DBWcharTestRec+Private.h" +#import "DJICppWrapperCache+Private.h" +#import "DJIError.h" +#import "DJIMarshal+Private.h" +#include +#include +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@interface DBWcharTestHelpers () + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::WcharTestHelpers>&)cppRef; + +@end + +@implementation DBWcharTestHelpers { + ::djinni::CppProxyCache::Handle> _cppRefHandle; +} + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::WcharTestHelpers>&)cppRef +{ + if (self = [super init]) { + _cppRefHandle.assign(cppRef); + } + return self; +} + +- (const std::shared_ptr<::testsuite::WcharTestHelpers>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBWcharTestHelpers methods + ++ (nonnull DBWcharTestRec *)getRecord { + try { + auto objcpp_result_ = ::testsuite::WcharTestHelpers::get_record(); + return ::djinni_generated::WcharTestRec::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + ++ (nonnull NSString *)getString { + try { + auto objcpp_result_ = ::testsuite::WcharTestHelpers::get_string(); + return ::djinni::WString::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + ++ (BOOL)checkString:(nonnull NSString *)str { + try { + auto objcpp_result_ = ::testsuite::WcharTestHelpers::check_string(::djinni::WString::toCpp(str)); + return ::djinni::Bool::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + ++ (BOOL)checkRecord:(nonnull DBWcharTestRec *)rec { + try { + auto objcpp_result_ = ::testsuite::WcharTestHelpers::check_record(::djinni_generated::WcharTestRec::toCpp(rec)); + return ::djinni::Bool::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +namespace djinni_generated { + +auto WcharTestHelpers::toCpp(ObjcType objc) -> CppType +{ + if (!objc) { + return nullptr; + } + return [objc cppRef]; +} + +auto WcharTestHelpers::fromCppOpt(const CppOptType& cpp) -> ObjcType +{ + if (!cpp) { + return nil; + } + return ::djinni::get_cpp_proxy(cpp); +} + +} // namespace djinni_generated + +@end diff --git a/test-suite/generated-src/objc/DBWcharTestHelpers.h b/test-suite/generated-src/objc/DBWcharTestHelpers.h new file mode 100644 index 000000000..781158f20 --- /dev/null +++ b/test-suite/generated-src/objc/DBWcharTestHelpers.h @@ -0,0 +1,18 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#import "DBWcharTestRec.h" +#import + + +@interface DBWcharTestHelpers : NSObject + ++ (nonnull DBWcharTestRec *)getRecord; + ++ (nonnull NSString *)getString; + ++ (BOOL)checkString:(nonnull NSString *)str; + ++ (BOOL)checkRecord:(nonnull DBWcharTestRec *)rec; + +@end diff --git a/test-suite/generated-src/objc/DBWcharTestRec+Private.h b/test-suite/generated-src/objc/DBWcharTestRec+Private.h new file mode 100644 index 000000000..0ca19f149 --- /dev/null +++ b/test-suite/generated-src/objc/DBWcharTestRec+Private.h @@ -0,0 +1,24 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#import "DBWcharTestRec.h" +#include "wchar_test_rec.hpp" + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@class DBWcharTestRec; + +namespace djinni_generated { + +struct WcharTestRec +{ + using CppType = ::testsuite::WcharTestRec; + using ObjcType = DBWcharTestRec*; + + using Boxed = WcharTestRec; + + static CppType toCpp(ObjcType objc); + static ObjcType fromCpp(const CppType& cpp); +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBWcharTestRec+Private.mm b/test-suite/generated-src/objc/DBWcharTestRec+Private.mm new file mode 100644 index 000000000..9d7f2e979 --- /dev/null +++ b/test-suite/generated-src/objc/DBWcharTestRec+Private.mm @@ -0,0 +1,21 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#import "DBWcharTestRec+Private.h" +#import "DJIMarshal+Private.h" +#include + +namespace djinni_generated { + +auto WcharTestRec::toCpp(ObjcType obj) -> CppType +{ + assert(obj); + return {::djinni::WString::toCpp(obj.s)}; +} + +auto WcharTestRec::fromCpp(const CppType& cpp) -> ObjcType +{ + return [[DBWcharTestRec alloc] initWithS:(::djinni::WString::fromCpp(cpp.s))]; +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBWcharTestRec.h b/test-suite/generated-src/objc/DBWcharTestRec.h new file mode 100644 index 000000000..2a652e147 --- /dev/null +++ b/test-suite/generated-src/objc/DBWcharTestRec.h @@ -0,0 +1,12 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#import + +@interface DBWcharTestRec : NSObject +- (nonnull instancetype)initWithS:(nonnull NSString *)s; ++ (nonnull instancetype)wcharTestRecWithS:(nonnull NSString *)s; + +@property (nonatomic, readonly, nonnull) NSString * s; + +@end diff --git a/test-suite/generated-src/objc/DBWcharTestRec.mm b/test-suite/generated-src/objc/DBWcharTestRec.mm new file mode 100644 index 000000000..c06ef0d9e --- /dev/null +++ b/test-suite/generated-src/objc/DBWcharTestRec.mm @@ -0,0 +1,27 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from wchar_test.djinni + +#import "DBWcharTestRec.h" + + +@implementation DBWcharTestRec + +- (nonnull instancetype)initWithS:(nonnull NSString *)s +{ + if (self = [super init]) { + _s = [s copy]; + } + return self; +} + ++ (nonnull instancetype)wcharTestRecWithS:(nonnull NSString *)s +{ + return [[self alloc] initWithS:s]; +} + +- (NSString *)description +{ + return [NSString stringWithFormat:@"<%@ %p s:%@>", self.class, (void *)self, self.s]; +} + +@end diff --git a/test-suite/generated-src/outFileList.txt b/test-suite/generated-src/outFileList.txt index d6b91678e..3f28125dc 100644 --- a/test-suite/generated-src/outFileList.txt +++ b/test-suite/generated-src/outFileList.txt @@ -4,6 +4,8 @@ djinni-output-temp/cpp/record_with_duration_and_derivings.cpp djinni-output-temp/cpp/date_record.hpp djinni-output-temp/cpp/date_record.cpp djinni-output-temp/cpp/map_date_record.hpp +djinni-output-temp/cpp/_varname_record_.hpp +djinni-output-temp/cpp/_varname_interface_.hpp djinni-output-temp/cpp/extended_record_base.hpp djinni-output-temp/cpp/extended_record_base.cpp djinni-output-temp/cpp/objc_only_listener.hpp @@ -27,7 +29,8 @@ djinni-output-temp/cpp/Conflict.hpp djinni-output-temp/cpp/conflict_user.hpp djinni-output-temp/cpp/user_token.hpp djinni-output-temp/cpp/color.hpp -djinni-output-temp/cpp/opt_color_record.hpp +djinni-output-temp/cpp/enum_usage_record.hpp +djinni-output-temp/cpp/enum_usage_interface.hpp djinni-output-temp/cpp/client_returned_record.hpp djinni-output-temp/cpp/client_interface.hpp djinni-output-temp/cpp/reverse_client_interface.hpp @@ -45,6 +48,8 @@ djinni-output-temp/java/TestDuration.java djinni-output-temp/java/RecordWithDurationAndDerivings.java djinni-output-temp/java/DateRecord.java djinni-output-temp/java/MapDateRecord.java +djinni-output-temp/java/VarnameRecord.java +djinni-output-temp/java/VarnameInterface.java djinni-output-temp/java/ExtendedRecord.java djinni-output-temp/java/ObjcOnlyListener.java djinni-output-temp/java/JavaOnlyListener.java @@ -64,7 +69,8 @@ djinni-output-temp/java/Conflict.java djinni-output-temp/java/ConflictUser.java djinni-output-temp/java/UserToken.java djinni-output-temp/java/Color.java -djinni-output-temp/java/OptColorRecord.java +djinni-output-temp/java/EnumUsageRecord.java +djinni-output-temp/java/EnumUsageInterface.java djinni-output-temp/java/ClientReturnedRecord.java djinni-output-temp/java/ClientInterface.java djinni-output-temp/java/ReverseClientInterface.java @@ -84,6 +90,10 @@ djinni-output-temp/jni/NativeDateRecord.hpp djinni-output-temp/jni/NativeDateRecord.cpp djinni-output-temp/jni/NativeMapDateRecord.hpp djinni-output-temp/jni/NativeMapDateRecord.cpp +djinni-output-temp/jni/NativeVarnameRecord.hpp +djinni-output-temp/jni/NativeVarnameRecord.cpp +djinni-output-temp/jni/NativeVarnameInterface.hpp +djinni-output-temp/jni/NativeVarnameInterface.cpp djinni-output-temp/jni/NativeExtendedRecord.hpp djinni-output-temp/jni/NativeExtendedRecord.cpp djinni-output-temp/jni/NativeObjcOnlyListener.hpp @@ -121,8 +131,10 @@ djinni-output-temp/jni/NativeConflictUser.cpp djinni-output-temp/jni/NativeUserToken.hpp djinni-output-temp/jni/NativeUserToken.cpp djinni-output-temp/jni/NativeColor.hpp -djinni-output-temp/jni/NativeOptColorRecord.hpp -djinni-output-temp/jni/NativeOptColorRecord.cpp +djinni-output-temp/jni/NativeEnumUsageRecord.hpp +djinni-output-temp/jni/NativeEnumUsageRecord.cpp +djinni-output-temp/jni/NativeEnumUsageInterface.hpp +djinni-output-temp/jni/NativeEnumUsageInterface.cpp djinni-output-temp/jni/NativeClientReturnedRecord.hpp djinni-output-temp/jni/NativeClientReturnedRecord.cpp djinni-output-temp/jni/NativeClientInterface.hpp @@ -152,6 +164,9 @@ djinni-output-temp/objc/DBDateRecord.h djinni-output-temp/objc/DBDateRecord.mm djinni-output-temp/objc/DBMapDateRecord.h djinni-output-temp/objc/DBMapDateRecord.mm +djinni-output-temp/objc/DBVarnameRecord.h +djinni-output-temp/objc/DBVarnameRecord.mm +djinni-output-temp/objc/DBVarnameInterface.h djinni-output-temp/objc/DBExtendedRecord.h djinni-output-temp/objc/DBExtendedRecord.mm djinni-output-temp/objc/DBObjcOnlyListener.h @@ -177,8 +192,9 @@ djinni-output-temp/objc/DBConflict.h djinni-output-temp/objc/DBConflictUser.h djinni-output-temp/objc/DBUserToken.h djinni-output-temp/objc/DBColor.h -djinni-output-temp/objc/DBOptColorRecord.h -djinni-output-temp/objc/DBOptColorRecord.mm +djinni-output-temp/objc/DBEnumUsageRecord.h +djinni-output-temp/objc/DBEnumUsageRecord.mm +djinni-output-temp/objc/DBEnumUsageInterface.h djinni-output-temp/objc/DBClientReturnedRecord.h djinni-output-temp/objc/DBClientReturnedRecord.mm djinni-output-temp/objc/DBClientInterface.h @@ -206,6 +222,10 @@ djinni-output-temp/objc/DBDateRecord+Private.h djinni-output-temp/objc/DBDateRecord+Private.mm djinni-output-temp/objc/DBMapDateRecord+Private.h djinni-output-temp/objc/DBMapDateRecord+Private.mm +djinni-output-temp/objc/DBVarnameRecord+Private.h +djinni-output-temp/objc/DBVarnameRecord+Private.mm +djinni-output-temp/objc/DBVarnameInterface+Private.h +djinni-output-temp/objc/DBVarnameInterface+Private.mm djinni-output-temp/objc/DBExtendedRecord+Private.h djinni-output-temp/objc/DBExtendedRecord+Private.mm djinni-output-temp/objc/DBObjcOnlyListener+Private.h @@ -242,8 +262,11 @@ djinni-output-temp/objc/DBConflictUser+Private.h djinni-output-temp/objc/DBConflictUser+Private.mm djinni-output-temp/objc/DBUserToken+Private.h djinni-output-temp/objc/DBUserToken+Private.mm -djinni-output-temp/objc/DBOptColorRecord+Private.h -djinni-output-temp/objc/DBOptColorRecord+Private.mm +djinni-output-temp/objc/DBColor+Private.h +djinni-output-temp/objc/DBEnumUsageRecord+Private.h +djinni-output-temp/objc/DBEnumUsageRecord+Private.mm +djinni-output-temp/objc/DBEnumUsageInterface+Private.h +djinni-output-temp/objc/DBEnumUsageInterface+Private.mm djinni-output-temp/objc/DBClientReturnedRecord+Private.h djinni-output-temp/objc/DBClientReturnedRecord+Private.mm djinni-output-temp/objc/DBClientInterface+Private.h diff --git a/test-suite/handwritten-src/cpp/optional.hpp b/test-suite/handwritten-src/cpp/optional.hpp new file mode 100644 index 000000000..bf6ea67cd --- /dev/null +++ b/test-suite/handwritten-src/cpp/optional.hpp @@ -0,0 +1,891 @@ +// Copyright (C) 2011 - 2012 Andrzej Krzemienski. +// +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0, as follows: +// +// Boost Software License - Version 1.0 - August 17th, 2003 +// +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// The idea and interface is based on Boost.Optional library +// authored by Fernando Luis Cacciola Carballal + +# ifndef ___OPTIONAL_HPP___ +# define ___OPTIONAL_HPP___ + +# include +# include +# include +# include +# include +# include +# include + +# define REQUIRES(...) typename enable_if<__VA_ARGS__::value, bool>::type = false + +# if defined __clang__ +# if (__clang_major__ > 2) || (__clang_major__ == 2) && (__clang_minor__ >= 9) +# define OPTIONAL_HAS_THIS_RVALUE_REFS 1 +# else +# define OPTIONAL_HAS_THIS_RVALUE_REFS 0 +# endif +# else +# define OPTIONAL_HAS_THIS_RVALUE_REFS 0 +# endif + + +namespace std{ + +namespace experimental{ + + +// 20.5.4, optional for object types +template class optional; + +// 20.5.5, optional for lvalue reference types +template class optional; + + +// workaround: std utility functions aren't constexpr yet +template inline constexpr T&& constexpr_forward(typename std::remove_reference::type& t) noexcept +{ + return static_cast(t); +} + +template inline constexpr T&& constexpr_forward(typename std::remove_reference::type&& t) noexcept +{ + static_assert(!std::is_lvalue_reference::value, "!!"); + return static_cast(t); +} + +template inline constexpr typename std::remove_reference::type&& constexpr_move(T&& t) noexcept +{ + return static_cast::type&&>(t); +} + +template inline constexpr _Ty * constexpr_addressof(_Ty& _Val) +{ + return ((_Ty *) &(char&)_Val); +} + + +#if defined NDEBUG +# define ASSERTED_EXPRESSION(CHECK, EXPR) (EXPR) +#else +# define ASSERTED_EXPRESSION(CHECK, EXPR) ((CHECK) ? (EXPR) : ([]{assert(#CHECK && false);}(), (EXPR))) +#endif + + +template +struct has_overloaded_addressof +{ + template + static constexpr bool has_overload(...) { return false; } + + template ().operator&()) > + static constexpr bool has_overload(bool) { return true; } + + constexpr static bool value = has_overload(true); +}; + + + +template )> +constexpr T* static_addressof(T& ref) +{ + return &ref; +} + +template )> +T* static_addressof(T& ref) +{ + return std::addressof(ref); +} + + + +template +struct is_not_optional +{ + constexpr static bool value = true; +}; + +template +struct is_not_optional> +{ + constexpr static bool value = false; +}; + + +constexpr struct trivial_init_t{} trivial_init{}; + + +// 20.5.6, In-place construction +constexpr struct in_place_t{} in_place{}; + + +// 20.5.7, Disengaged state indicator +struct nullopt_t +{ + struct init{}; + constexpr nullopt_t(init){}; +}; +constexpr nullopt_t nullopt{nullopt_t::init()}; + + +// 20.5.8, class bad_optional_access +class bad_optional_access : public logic_error { +public: + explicit bad_optional_access(const string& what_arg) : logic_error{what_arg} {} + explicit bad_optional_access(const char* what_arg) : logic_error{what_arg} {} +}; + + +template +union storage_t +{ + unsigned char dummy_; + T value_; + + constexpr storage_t( trivial_init_t ) noexcept : dummy_() {}; + + template + constexpr storage_t( Args&&... args ) : value_(constexpr_forward(args)...) {} + + ~storage_t(){} +}; + + +template +union constexpr_storage_t +{ + unsigned char dummy_; + T value_; + + constexpr constexpr_storage_t( trivial_init_t ) noexcept : dummy_() {}; + + template + constexpr constexpr_storage_t( Args&&... args ) : value_(constexpr_forward(args)...) {} + + ~constexpr_storage_t() = default; +}; + + +constexpr struct only_set_initialized_t{} only_set_initialized{}; + + +template +struct optional_base +{ + bool init_; + storage_t storage_; + + constexpr optional_base() noexcept : init_(false), storage_(trivial_init) {}; + + constexpr explicit optional_base(only_set_initialized_t, bool init) noexcept : init_(init), storage_(trivial_init) {}; + + explicit constexpr optional_base(const T& v) : init_(true), storage_(v) {} + + explicit constexpr optional_base(T&& v) : init_(true), storage_(constexpr_move(v)) {} + + template explicit optional_base(in_place_t, Args&&... args) + : init_(true), storage_(constexpr_forward(args)...) {} + + template >)> + explicit optional_base(in_place_t, std::initializer_list il, Args&&... args) + : init_(true), storage_(il, std::forward(args)...) {} + + ~optional_base() { if (init_) storage_.value_.T::~T(); } +}; + + +template +struct constexpr_optional_base +{ + bool init_; + constexpr_storage_t storage_; + + constexpr constexpr_optional_base() noexcept : init_(false), storage_(trivial_init) {}; + + constexpr explicit constexpr_optional_base(only_set_initialized_t, bool init) noexcept : init_(init), storage_(trivial_init) {}; + + explicit constexpr constexpr_optional_base(const T& v) : init_(true), storage_(v) {} + + explicit constexpr constexpr_optional_base(T&& v) : init_(true), storage_(constexpr_move(v)) {} + + template explicit constexpr constexpr_optional_base(in_place_t, Args&&... args) + : init_(true), storage_(constexpr_forward(args)...) {} + + template >)> + explicit constexpr_optional_base(in_place_t, std::initializer_list il, Args&&... args) + : init_(true), storage_(il, std::forward(args)...) {} + + ~constexpr_optional_base() = default; +}; + +template +using OptionalBase = typename std::conditional< + std::is_trivially_destructible::value, + constexpr_optional_base, + optional_base +>::type; + +template +constexpr bool is_nothrow_swappable_() { + using std::swap; + return noexcept(swap(std::declval(), std::declval())); +} + +template +class optional : private OptionalBase +{ + static_assert( !std::is_same::type, nullopt_t>::value, "bad T" ); + static_assert( !std::is_same::type, in_place_t>::value, "bad T" ); + + + constexpr bool initialized() const noexcept { return OptionalBase::init_; } + T* dataptr() { return std::addressof(OptionalBase::storage_.value_); } + constexpr const T* dataptr() const { return static_addressof(OptionalBase::storage_.value_); } + +# if OPTIONAL_HAS_THIS_RVALUE_REFS == 1 + constexpr const T& contained_val() const& { return OptionalBase::storage_.value_; } + T& contained_val() & { return OptionalBase::storage_.value_; } + T&& contained_val() && { return std::move(OptionalBase::storage_.value_); } +# else + constexpr const T& contained_val() const { return OptionalBase::storage_.value_; } + T& contained_val() { return OptionalBase::storage_.value_; } +# endif + + void clear() noexcept { + if (initialized()) dataptr()->T::~T(); + OptionalBase::init_ = false; + } + + template + void initialize(Args&&... args) noexcept(noexcept(T(std::forward(args)...))) + { + assert(!OptionalBase::init_); + new (dataptr()) T(std::forward(args)...); + OptionalBase::init_ = true; + } + + template + void initialize(std::initializer_list il, Args&&... args) noexcept(noexcept(T(il, std::forward(args)...))) + { + assert(!OptionalBase::init_); + new (dataptr()) T(il, std::forward(args)...); + OptionalBase::init_ = true; + } + +public: + typedef T value_type; + + // 20.5.5.1, constructors + constexpr optional() noexcept : OptionalBase() {}; + constexpr optional(nullopt_t) noexcept : OptionalBase() {}; + + optional(const optional& rhs) + : OptionalBase(only_set_initialized, rhs.initialized()) + { + if (rhs.initialized()) new (dataptr()) T(*rhs); + } + + optional(optional&& rhs) noexcept(std::is_nothrow_move_constructible::value) + : OptionalBase(only_set_initialized, rhs.initialized()) + { + if (rhs.initialized()) new (dataptr()) T(std::move(*rhs)); + } + + constexpr optional(const T& v) : OptionalBase(v) {} + + constexpr optional(T&& v) : OptionalBase(constexpr_move(v)) {} + + template + constexpr explicit optional(in_place_t, Args&&... args) + : OptionalBase(in_place_t{}, constexpr_forward(args)...) {} + + template >)> + explicit optional(in_place_t, std::initializer_list il, Args&&... args) + : OptionalBase(in_place_t{}, il, constexpr_forward(args)...) {} + + // 20.5.4.2 Destructor + ~optional() = default; + + // 20.5.4.3, assignment + optional& operator=(nullopt_t) noexcept + { + clear(); + return *this; + } + + optional& operator=(const optional& rhs) + { + if (initialized() == true && rhs.initialized() == false) clear(); + else if (initialized() == false && rhs.initialized() == true) initialize(*rhs); + else if (initialized() == true && rhs.initialized() == true) contained_val() = *rhs; + return *this; + } + + optional& operator=(optional&& rhs) + noexcept(std::is_nothrow_move_assignable::value && std::is_nothrow_move_constructible::value) + { + if (initialized() == true && rhs.initialized() == false) clear(); + else if (initialized() == false && rhs.initialized() == true) initialize(std::move(*rhs)); + else if (initialized() == true && rhs.initialized() == true) contained_val() = std::move(*rhs); + return *this; + } + + template + auto operator=(U&& v) + -> typename enable_if + < + is_same::type, T>::value, + optional& + >::type + { + if (initialized()) { contained_val() = std::forward(v); } + else { initialize(std::forward(v)); } + return *this; + } + + + template + optional& emplace(Args&&... args) + { + clear(); + initialize(std::forward(args)...); + return *this; + } + + template + optional& emplace(initializer_list il, Args&&... args) + { + clear(); + initialize(il, std::forward(args)...); + return *this; + } + + // 20.5.4.4 Swap + void swap(optional& rhs) noexcept(is_nothrow_move_constructible::value && is_nothrow_swappable_()) + { + if (initialized() == true && rhs.initialized() == false) { rhs.initialize(std::move(**this)); clear(); } + else if (initialized() == false && rhs.initialized() == true) { initialize(std::move(*rhs)); rhs.clear(); } + else if (initialized() == true && rhs.initialized() == true) { using std::swap; swap(**this, *rhs); } + } + + // 20.5.4.5 Observers + constexpr T const* operator ->() const { + return ASSERTED_EXPRESSION(initialized(), dataptr()); + } + + T* operator ->() { + assert (initialized()); + return dataptr(); + } + + constexpr T const& operator *() const { + return ASSERTED_EXPRESSION(initialized(), contained_val()); + } + + T& operator *() { + assert (initialized()); + return contained_val(); + } + + constexpr T const& value() const { + return initialized() ? contained_val() : (throw bad_optional_access("bad optional access"), contained_val()); + } + + T& value() { + return initialized() ? contained_val() : (throw bad_optional_access("bad optional access"), contained_val()); + } + + constexpr explicit operator bool() const noexcept { return initialized(); } + +# if OPTIONAL_HAS_THIS_RVALUE_REFS == 1 + + template + constexpr T value_or(V&& v) const& + { + return *this ? **this : static_cast(constexpr_forward(v)); + } + + template + T value_or(V&& v) && + { + return *this ? std::move(const_cast&>(*this).contained_val()) : static_cast(constexpr_forward(v)); + } + +# else + + template + constexpr T value_or(V&& v) const + { + return *this ? **this : static_cast(constexpr_forward(v)); + } + +# endif + +}; + + +template +class optional +{ + static_assert( !std::is_same::value, "bad T" ); + static_assert( !std::is_same::value, "bad T" ); + T* ref; + +public: + + // 20.5.5.1, construction/destruction + constexpr optional() noexcept : ref(nullptr) {} + + constexpr optional(nullopt_t) noexcept : ref(nullptr) {} + + constexpr optional(T& v) noexcept : ref(static_addressof(v)) {} + + optional(T&&) = delete; + + constexpr optional(const optional& rhs) noexcept : ref(rhs.ref) {} + + explicit constexpr optional(in_place_t, T& v) noexcept : ref(static_addressof(v)) {} + + explicit optional(in_place_t, T&&) = delete; + + ~optional() = default; + + // 20.5.5.2, mutation + optional& operator=(nullopt_t) noexcept { + ref = nullptr; + return *this; + } + + // optional& operator=(const optional& rhs) noexcept { + // ref = rhs.ref; + // return *this; + // } + + // optional& operator=(optional&& rhs) noexcept { + // ref = rhs.ref; + // return *this; + // } + + template + auto operator=(U&& rhs) noexcept + -> typename enable_if + < + is_same::type, optional>::value, + optional& + >::type + { + ref = rhs.ref; + return *this; + } + + template + auto operator=(U&& rhs) noexcept + -> typename enable_if + < + !is_same::type, optional>::value, + optional& + >::type + = delete; + + optional& emplace(T& v) noexcept { + ref = static_addressof(v); + return *this; + } + + optional& emplace(T&&) = delete; + + + void swap(optional& rhs) noexcept + { + std::swap(ref, rhs.ref); + } + + // 20.5.5.3, observers + constexpr T* operator->() const { + return ASSERTED_EXPRESSION(ref, ref); + } + + constexpr T& operator*() const { + return ASSERTED_EXPRESSION(ref, *ref); + } + + constexpr T& value() const { + return ref ? *ref : (throw bad_optional_access("bad optional access"), *ref); + } + + explicit constexpr operator bool() const noexcept { + return ref != nullptr; + } + + template + constexpr typename decay::type value_or(V&& v) const + { + return *this ? **this : static_cast::type>(constexpr_forward(v)); + } +}; + + +template +class optional +{ + static_assert( sizeof(T) == 0, "optional rvalue referencs disallowed" ); +}; + + +// 20.5.8, Relational operators +template constexpr bool operator==(const optional& x, const optional& y) +{ + return bool(x) != bool(y) ? false : bool(x) == false ? true : *x == *y; +} + +template constexpr bool operator!=(const optional& x, const optional& y) +{ + return !(x == y); +} + +template constexpr bool operator<(const optional& x, const optional& y) +{ + return (!y) ? false : (!x) ? true : *x < *y; +} + +template constexpr bool operator>(const optional& x, const optional& y) +{ + return (y < x); +} + +template constexpr bool operator<=(const optional& x, const optional& y) +{ + return !(y < x); +} + +template constexpr bool operator>=(const optional& x, const optional& y) +{ + return !(x < y); +} + + +// 20.5.9 Comparison with nullopt +template constexpr bool operator==(const optional& x, nullopt_t) noexcept +{ + return (!x); +} + +template constexpr bool operator==(nullopt_t, const optional& x) noexcept +{ + return (!x); +} + +template constexpr bool operator!=(const optional& x, nullopt_t) noexcept +{ + return bool(x); +} + +template constexpr bool operator!=(nullopt_t, const optional& x) noexcept +{ + return bool(x); +} + +template constexpr bool operator<(const optional&, nullopt_t) noexcept +{ + return false; +} + +template constexpr bool operator<(nullopt_t, const optional& x) noexcept +{ + return bool(x); +} + +template constexpr bool operator<=(const optional& x, nullopt_t) noexcept +{ + return (!x); +} + +template constexpr bool operator<=(nullopt_t, const optional&) noexcept +{ + return true; +} + +template constexpr bool operator>(const optional& x, nullopt_t) noexcept +{ + return bool(x); +} + +template constexpr bool operator>(nullopt_t, const optional&) noexcept +{ + return false; +} + +template constexpr bool operator>=(const optional&, nullopt_t) noexcept +{ + return true; +} + +template constexpr bool operator>=(nullopt_t, const optional& x) noexcept +{ + return (!x); +} + + + +// 20.5.10, Comparison with T +template constexpr bool operator==(const optional& x, const T& v) +{ + return bool(x) ? *x == v : false; +} + +template constexpr bool operator==(const T& v, const optional& x) +{ + return bool(x) ? v == *x : false; +} + +template constexpr bool operator!=(const optional& x, const T& v) +{ + return bool(x) ? *x != v : true; +} + +template constexpr bool operator!=(const T& v, const optional& x) +{ + return bool(x) ? v != *x : true; +} + +template constexpr bool operator<(const optional& x, const T& v) +{ + return bool(x) ? *x < v : true; +} + +template constexpr bool operator>(const T& v, const optional& x) +{ + return bool(x) ? v > *x : true; +} + +template constexpr bool operator>(const optional& x, const T& v) +{ + return bool(x) ? *x > v : false; +} + +template constexpr bool operator<(const T& v, const optional& x) +{ + return bool(x) ? v < *x : false; +} + +template constexpr bool operator>=(const optional& x, const T& v) +{ + return bool(x) ? *x >= v : false; +} + +template constexpr bool operator<=(const T& v, const optional& x) +{ + return bool(x) ? v <= *x : false; +} + +template constexpr bool operator<=(const optional& x, const T& v) +{ + return bool(x) ? *x <= v : true; +} + +template constexpr bool operator>=(const T& v, const optional& x) +{ + return bool(x) ? v >= *x : true; +} + + +// Comparison of optionsl with T +template constexpr bool operator==(const optional& x, const T& v) +{ + return bool(x) ? *x == v : false; +} + +template constexpr bool operator==(const T& v, const optional& x) +{ + return bool(x) ? v == *x : false; +} + +template constexpr bool operator!=(const optional& x, const T& v) +{ + return bool(x) ? *x != v : true; +} + +template constexpr bool operator!=(const T& v, const optional& x) +{ + return bool(x) ? v != *x : true; +} + +template constexpr bool operator<(const optional& x, const T& v) +{ + return bool(x) ? *x < v : true; +} + +template constexpr bool operator>(const T& v, const optional& x) +{ + return bool(x) ? v > *x : true; +} + +template constexpr bool operator>(const optional& x, const T& v) +{ + return bool(x) ? *x > v : false; +} + +template constexpr bool operator<(const T& v, const optional& x) +{ + return bool(x) ? v < *x : false; +} + +template constexpr bool operator>=(const optional& x, const T& v) +{ + return bool(x) ? *x >= v : false; +} + +template constexpr bool operator<=(const T& v, const optional& x) +{ + return bool(x) ? v <= *x : false; +} + +template constexpr bool operator<=(const optional& x, const T& v) +{ + return bool(x) ? *x <= v : true; +} + +template constexpr bool operator>=(const T& v, const optional& x) +{ + return bool(x) ? v >= *x : true; +} + +// Comparison of optionsl with T +template constexpr bool operator==(const optional& x, const T& v) +{ + return bool(x) ? *x == v : false; +} + +template constexpr bool operator==(const T& v, const optional& x) +{ + return bool(x) ? v == *x : false; +} + +template constexpr bool operator!=(const optional& x, const T& v) +{ + return bool(x) ? *x != v : true; +} + +template constexpr bool operator!=(const T& v, const optional& x) +{ + return bool(x) ? v != *x : true; +} + +template constexpr bool operator<(const optional& x, const T& v) +{ + return bool(x) ? *x < v : true; +} + +template constexpr bool operator>(const T& v, const optional& x) +{ + return bool(x) ? v > *x : true; +} + +template constexpr bool operator>(const optional& x, const T& v) +{ + return bool(x) ? *x > v : false; +} + +template constexpr bool operator<(const T& v, const optional& x) +{ + return bool(x) ? v < *x : false; +} + +template constexpr bool operator>=(const optional& x, const T& v) +{ + return bool(x) ? *x >= v : false; +} + +template constexpr bool operator<=(const T& v, const optional& x) +{ + return bool(x) ? v <= *x : false; +} + +template constexpr bool operator<=(const optional& x, const T& v) +{ + return bool(x) ? *x <= v : true; +} + +template constexpr bool operator>=(const T& v, const optional& x) +{ + return bool(x) ? v >= *x : true; +} + + +// 20.5.12 Specialized algorithms +template +void swap(optional& x, optional& y) noexcept(noexcept(x.swap(y))) +{ + x.swap(y); +} + + +template +constexpr optional::type> make_optional(T&& v) +{ + return optional::type>(constexpr_forward(v)); +} + +template +constexpr optional make_optional(reference_wrapper v) +{ + return optional(v.get()); +} + + +} // namespace experimental +} // namespace std + +namespace std +{ + template + struct hash> + { + typedef typename hash::result_type result_type; + typedef std::experimental::optional argument_type; + + constexpr result_type operator()(argument_type const& arg) const { + return arg ? std::hash{}(*arg) : result_type{}; + } + }; + + template + struct hash> + { + typedef typename hash::result_type result_type; + typedef std::experimental::optional argument_type; + + constexpr result_type operator()(argument_type const& arg) const { + return arg ? std::hash{}(*arg) : result_type{}; + } + }; +} + + + +# endif //___OPTIONAL_HPP___ diff --git a/test-suite/handwritten-src/cpp/wchar_test_helpers.cpp b/test-suite/handwritten-src/cpp/wchar_test_helpers.cpp new file mode 100644 index 000000000..8d4d8a208 --- /dev/null +++ b/test-suite/handwritten-src/cpp/wchar_test_helpers.cpp @@ -0,0 +1,30 @@ +#include "wchar_test_helpers.hpp" +#include "wchar_test_rec.hpp" + +namespace testsuite { + +static const wchar_t s1[] = L"some string with unicode \u0000, \u263A, \U0001F4A9 symbols"; +static const std::wstring str1(s1, sizeof(s1) / sizeof(*s1) - 1); +static const std::wstring str2 = L"another string with unicode \u263B, \U0001F4A8 symbols"; + +WcharTestRec WcharTestHelpers::get_record() +{ + return WcharTestRec(str1); +} + +std::wstring WcharTestHelpers::get_string() +{ + return str2; +} + +bool WcharTestHelpers::check_string(const std::wstring & s) +{ + return s == str2; +} + +bool WcharTestHelpers::check_record(const WcharTestRec & r) +{ + return r.s == str1; +} + +} // namespace testsuite diff --git a/test-suite/handwritten-src/java/com/dropbox/djinni/test/AllTests.java b/test-suite/handwritten-src/java/com/dropbox/djinni/test/AllTests.java index 56f90947b..b9239f958 100644 --- a/test-suite/handwritten-src/java/com/dropbox/djinni/test/AllTests.java +++ b/test-suite/handwritten-src/java/com/dropbox/djinni/test/AllTests.java @@ -22,6 +22,7 @@ public static Test suite() { mySuite.addTestSuite(TokenTest.class); mySuite.addTestSuite(DurationTest.class); mySuite.addTestSuite(MockRecordTest.class); + mySuite.addTestSuite(WcharTest.class); return mySuite; } diff --git a/test-suite/handwritten-src/java/com/dropbox/djinni/test/WcharTest.java b/test-suite/handwritten-src/java/com/dropbox/djinni/test/WcharTest.java new file mode 100644 index 000000000..50bf06741 --- /dev/null +++ b/test-suite/handwritten-src/java/com/dropbox/djinni/test/WcharTest.java @@ -0,0 +1,16 @@ +package com.dropbox.djinni.test; + +import junit.framework.TestCase; + +public class WcharTest extends TestCase { + + private static final String STR1 = "some string with unicode \u0000, \u263A, \uD83D\uDCA9 symbols"; + private static final String STR2 = "another string with unicode \u263B, \uD83D\uDCA8 symbols"; + + public void test() { + assertEquals(WcharTestHelpers.getRecord().getS(), STR1); + assertEquals(WcharTestHelpers.getString(), STR2); + assertEquals(WcharTestHelpers.checkString(STR2), true); + assertEquals(WcharTestHelpers.checkRecord(new WcharTestRec(STR1)), true); + } +} diff --git a/test-suite/handwritten-src/objc/tests/DBWcharTests.m b/test-suite/handwritten-src/objc/tests/DBWcharTests.m new file mode 100644 index 000000000..3f0ad7874 --- /dev/null +++ b/test-suite/handwritten-src/objc/tests/DBWcharTests.m @@ -0,0 +1,33 @@ +#import +#import "DBWcharTestHelpers.h" +#import "DBWcharTestRec.h" +#import + +@interface DBWcharTests : XCTestCase + +@end + +@implementation DBWcharTests + +- (void)setUp +{ + [super setUp]; +} + +- (void)tearDown +{ + [super tearDown]; +} + +- (void)test +{ + NSString *str1 = @"some string with unicode \0, \u263A, \U0001F4A9 symbols"; + NSString *str2 = @"another string with unicode \u263B, \U0001F4A8 symbols"; + + XCTAssertEqualObjects([[DBWcharTestHelpers getRecord] s], str1); + XCTAssertEqualObjects([DBWcharTestHelpers getString], str2); + XCTAssertTrue([DBWcharTestHelpers checkString:str2]); + XCTAssertTrue([DBWcharTestHelpers checkRecord:[[DBWcharTestRec alloc] initWithS:str1]]); +} + +@end diff --git a/test-suite/java/CMakeLists.txt b/test-suite/java/CMakeLists.txt index 1bb317296..4466cd21e 100644 --- a/test-suite/java/CMakeLists.txt +++ b/test-suite/java/CMakeLists.txt @@ -37,7 +37,7 @@ file( ../generated-src/cpp/*.cpp ../handwritten-src/cpp/*.cpp) -set(test_suite_common_flags "-g -Wall -Werror -std=c++1y") +set(test_suite_common_flags "-g -Wall -Werror -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${test_suite_common_flags}") if(UNIX OR APPLE) diff --git a/test-suite/objc/DjinniObjcTest.xcodeproj/project.pbxproj b/test-suite/objc/DjinniObjcTest.xcodeproj/project.pbxproj index 3c3c76b7f..d4e54ea11 100644 --- a/test-suite/objc/DjinniObjcTest.xcodeproj/project.pbxproj +++ b/test-suite/objc/DjinniObjcTest.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 5AEA68151D38F4A40083D770 /* DBWcharTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 728E11201D37DE27005A554D /* DBWcharTests.m */; }; 650CA05A1C2AB48E007ADDDB /* DBListenerCaller+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = 650CA0571C2AB48E007ADDDB /* DBListenerCaller+Private.mm */; }; 650CA05E1C2AB5AB007ADDDB /* ListenerCaller.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 650CA05D1C2AB5AB007ADDDB /* ListenerCaller.cpp */; }; 650CA0601C2AB6DB007ADDDB /* DBMultipleInheritanceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 650CA05B1C2AB524007ADDDB /* DBMultipleInheritanceTests.m */; }; @@ -32,8 +33,6 @@ 65868B621989FE4200D60EEE /* libDjinniObjcTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 65868B4A1989FE4200D60EEE /* libDjinniObjcTest.a */; }; 6D66A8A91A3B09F000B312E8 /* DBConstantTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6D66A8A81A3B09F000B312E8 /* DBConstantTests.mm */; }; A20094101B06982F00EF8D9B /* DBTokenTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = A200940E1B0697D300EF8D9B /* DBTokenTests.mm */; }; - A209B5791BBA2A0A0070C310 /* DBOptColorRecord.mm in Sources */ = {isa = PBXBuildFile; fileRef = A209B5761BBA2A0A0070C310 /* DBOptColorRecord.mm */; }; - A209B57A1BBA2A0A0070C310 /* DBOptColorRecord+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = A209B5781BBA2A0A0070C310 /* DBOptColorRecord+Private.mm */; }; A238CA8E1AF84B7100CDDCE5 /* DBClientReturnedRecord+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = A238CA761AF84B7100CDDCE5 /* DBClientReturnedRecord+Private.mm */; }; A238CA901AF84B7100CDDCE5 /* DBConstants+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = A238CA781AF84B7100CDDCE5 /* DBConstants+Private.mm */; }; A238CA921AF84B7100CDDCE5 /* DBDateRecord+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = A238CA7A1AF84B7100CDDCE5 /* DBDateRecord+Private.mm */; }; @@ -62,6 +61,15 @@ A278D45319BA3601006FD937 /* test_helpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A278D45219BA3601006FD937 /* test_helpers.cpp */; }; A2AE38491BB3074800B7A0C9 /* DJIProxyCaches.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6536CD6C19A6C82200DD7715 /* DJIProxyCaches.mm */; }; A2CB54B419BA6E6000A9E600 /* DJIError.mm in Sources */ = {isa = PBXBuildFile; fileRef = A2CB54B319BA6E6000A9E600 /* DJIError.mm */; }; + B5153F931D54283700012654 /* DBWcharTestRec+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5153F891D54283700012654 /* DBWcharTestRec+Private.mm */; }; + B5153F941D54283700012654 /* DBWcharTestRec.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5153F8B1D54283700012654 /* DBWcharTestRec.mm */; }; + B5153F961D54283700012654 /* DBUsesSingleLanguageListeners+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5153F901D54283700012654 /* DBUsesSingleLanguageListeners+Private.mm */; }; + B5153F9A1D54284100012654 /* DBJavaOnlyListener+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5153F971D54284100012654 /* DBJavaOnlyListener+Private.mm */; }; + B51911181D542A7000772DFE /* DBWcharTestHelpers+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B51911151D542A7000772DFE /* DBWcharTestHelpers+Private.mm */; }; + B519111B1D542B0700772DFE /* wchar_test_helpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B519111A1D542B0700772DFE /* wchar_test_helpers.cpp */; }; + B51911501D555EE900772DFE /* DBVarnameRecord+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B51911491D555EE900772DFE /* DBVarnameRecord+Private.mm */; }; + B51911511D555EE900772DFE /* DBVarnameRecord.mm in Sources */ = {isa = PBXBuildFile; fileRef = B519114B1D555EE900772DFE /* DBVarnameRecord.mm */; }; + B51911521D555EE900772DFE /* DBVarnameInterface+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B519114D1D555EE900772DFE /* DBVarnameInterface+Private.mm */; }; B52DA5681B103F72005CE75F /* DBAssortedPrimitives.mm in Sources */ = {isa = PBXBuildFile; fileRef = B52DA5651B103F6D005CE75F /* DBAssortedPrimitives.mm */; }; B52DA5691B103F72005CE75F /* DBAssortedPrimitives.mm in Sources */ = {isa = PBXBuildFile; fileRef = B52DA5651B103F6D005CE75F /* DBAssortedPrimitives.mm */; }; B52DA56A1B103F75005CE75F /* DBAssortedPrimitives+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B52DA5671B103F6D005CE75F /* DBAssortedPrimitives+Private.mm */; }; @@ -72,6 +80,16 @@ B5D8FC371C23E2F40045ADCF /* DBConstantRecord+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5D8FC351C23E2F40045ADCF /* DBConstantRecord+Private.mm */; }; 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 */; }; + B5F06A6D1D497396005BE736 /* extended_record_base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5F06A681D497396005BE736 /* extended_record_base.cpp */; }; + B5F06A851D4973BD005BE736 /* DBConflict+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5F06A701D4973BD005BE736 /* DBConflict+Private.mm */; }; + B5F06A861D4973BD005BE736 /* DBConflictUser+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5F06A731D4973BD005BE736 /* DBConflictUser+Private.mm */; }; + B5F06A891D4973BD005BE736 /* DBExtendedRecord.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5F06A791D4973BD005BE736 /* DBExtendedRecord.mm */; }; + B5F06A8A1D4973BD005BE736 /* DBExtendedRecord+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5F06A7B1D4973BD005BE736 /* DBExtendedRecord+Private.mm */; }; + B5F06A8C1D4973BD005BE736 /* DBObjcOnlyListener+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5F06A811D4973BD005BE736 /* DBObjcOnlyListener+Private.mm */; }; + B5F06A9A1D497A66005BE736 /* extended_record.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5F06A971D497A66005BE736 /* extended_record.cpp */; }; + B5F06AA51D4987EF005BE736 /* DBEnumUsageInterface+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5F06AA01D4987EF005BE736 /* DBEnumUsageInterface+Private.mm */; }; + B5F06AA61D4987EF005BE736 /* DBEnumUsageRecord.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5F06AA21D4987EF005BE736 /* DBEnumUsageRecord.mm */; }; + B5F06AA71D4987EF005BE736 /* DBEnumUsageRecord+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = B5F06AA41D4987EF005BE736 /* DBEnumUsageRecord+Private.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 */; }; CFC5D9D01B15105100BF2DF8 /* extern_record_with_derivings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CFC5D9CE1B15105100BF2DF8 /* extern_record_with_derivings.cpp */; }; @@ -182,12 +200,8 @@ 65868B5B1989FE4200D60EEE /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 65868B5E1989FE4200D60EEE /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; 6D66A8A81A3B09F000B312E8 /* DBConstantTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBConstantTests.mm; sourceTree = ""; }; + 728E11201D37DE27005A554D /* DBWcharTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBWcharTests.m; sourceTree = ""; }; A200940E1B0697D300EF8D9B /* DBTokenTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBTokenTests.mm; sourceTree = ""; }; - A209B5751BBA2A0A0070C310 /* DBOptColorRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBOptColorRecord.h; sourceTree = ""; }; - A209B5761BBA2A0A0070C310 /* DBOptColorRecord.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBOptColorRecord.mm; sourceTree = ""; }; - A209B5771BBA2A0A0070C310 /* DBOptColorRecord+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBOptColorRecord+Private.h"; sourceTree = ""; }; - A209B5781BBA2A0A0070C310 /* DBOptColorRecord+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBOptColorRecord+Private.mm"; sourceTree = ""; }; - A209B57B1BBA2A180070C310 /* opt_color_record.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = opt_color_record.hpp; sourceTree = ""; }; A238CA761AF84B7100CDDCE5 /* DBClientReturnedRecord+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBClientReturnedRecord+Private.mm"; sourceTree = ""; }; A238CA781AF84B7100CDDCE5 /* DBConstants+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBConstants+Private.mm"; sourceTree = ""; }; A238CA7A1AF84B7100CDDCE5 /* DBDateRecord+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBDateRecord+Private.mm"; sourceTree = ""; }; @@ -263,6 +277,31 @@ A278D45219BA3601006FD937 /* test_helpers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_helpers.cpp; sourceTree = ""; }; A2CB54B319BA6E6000A9E600 /* DJIError.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DJIError.mm; sourceTree = ""; }; A2CCB9411AF80DFC00E6230A /* DBClientInterface+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBClientInterface+Private.h"; sourceTree = ""; }; + B5153F871D54282C00012654 /* wchar_test_rec.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = wchar_test_rec.hpp; sourceTree = ""; }; + B5153F891D54283700012654 /* DBWcharTestRec+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBWcharTestRec+Private.mm"; sourceTree = ""; }; + B5153F8A1D54283700012654 /* DBWcharTestRec+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBWcharTestRec+Private.h"; sourceTree = ""; }; + B5153F8B1D54283700012654 /* DBWcharTestRec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBWcharTestRec.mm; sourceTree = ""; }; + B5153F8C1D54283700012654 /* DBWcharTestRec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBWcharTestRec.h; sourceTree = ""; }; + B5153F901D54283700012654 /* DBUsesSingleLanguageListeners+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBUsesSingleLanguageListeners+Private.mm"; sourceTree = ""; }; + B5153F911D54283700012654 /* DBUsesSingleLanguageListeners+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBUsesSingleLanguageListeners+Private.h"; sourceTree = ""; }; + B5153F921D54283700012654 /* DBUsesSingleLanguageListeners.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBUsesSingleLanguageListeners.h; sourceTree = ""; }; + B5153F971D54284100012654 /* DBJavaOnlyListener+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBJavaOnlyListener+Private.mm"; sourceTree = ""; }; + B5153F981D54284100012654 /* DBJavaOnlyListener+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBJavaOnlyListener+Private.h"; sourceTree = ""; }; + B5153F991D54284100012654 /* DBJavaOnlyListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBJavaOnlyListener.h; sourceTree = ""; }; + B51911151D542A7000772DFE /* DBWcharTestHelpers+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBWcharTestHelpers+Private.mm"; sourceTree = ""; }; + B51911161D542A7000772DFE /* DBWcharTestHelpers+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBWcharTestHelpers+Private.h"; sourceTree = ""; }; + B51911171D542A7000772DFE /* DBWcharTestHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBWcharTestHelpers.h; sourceTree = ""; }; + B51911191D542AEC00772DFE /* wchar_test_helpers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = wchar_test_helpers.hpp; sourceTree = ""; }; + B519111A1D542B0700772DFE /* wchar_test_helpers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wchar_test_helpers.cpp; sourceTree = ""; }; + B51911471D555EDC00772DFE /* _varname_record_.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = _varname_record_.hpp; sourceTree = ""; }; + B51911481D555EDC00772DFE /* _varname_interface_.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = _varname_interface_.hpp; sourceTree = ""; }; + B51911491D555EE900772DFE /* DBVarnameRecord+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBVarnameRecord+Private.mm"; sourceTree = ""; }; + B519114A1D555EE900772DFE /* DBVarnameRecord+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBVarnameRecord+Private.h"; sourceTree = ""; }; + B519114B1D555EE900772DFE /* DBVarnameRecord.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBVarnameRecord.mm; sourceTree = ""; }; + B519114C1D555EE900772DFE /* DBVarnameRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBVarnameRecord.h; sourceTree = ""; }; + B519114D1D555EE900772DFE /* DBVarnameInterface+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBVarnameInterface+Private.mm"; sourceTree = ""; }; + B519114E1D555EE900772DFE /* DBVarnameInterface+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBVarnameInterface+Private.h"; sourceTree = ""; }; + B519114F1D555EE900772DFE /* DBVarnameInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBVarnameInterface.h; sourceTree = ""; }; B52DA5641B103F6D005CE75F /* DBAssortedPrimitives.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DBAssortedPrimitives.h; sourceTree = ""; }; B52DA5651B103F6D005CE75F /* DBAssortedPrimitives.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DBAssortedPrimitives.mm; sourceTree = ""; }; B52DA5661B103F6D005CE75F /* DBAssortedPrimitives+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DBAssortedPrimitives+Private.h"; sourceTree = ""; }; @@ -281,6 +320,39 @@ B5E9C93D1C1F9E9E0073C123 /* DBReverseClientInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBReverseClientInterface.h; sourceTree = ""; }; B5E9C93E1C1F9E9E0073C123 /* DBReverseClientInterface+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBReverseClientInterface+Private.h"; sourceTree = ""; }; B5E9C93F1C1F9E9E0073C123 /* DBReverseClientInterface+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBReverseClientInterface+Private.mm"; sourceTree = ""; }; + B5F06A651D497396005BE736 /* conflict_user.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = conflict_user.hpp; sourceTree = ""; }; + B5F06A661D497396005BE736 /* Conflict.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Conflict.hpp; sourceTree = ""; }; + B5F06A681D497396005BE736 /* extended_record_base.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = extended_record_base.cpp; sourceTree = ""; }; + B5F06A691D497396005BE736 /* extended_record_base.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = extended_record_base.hpp; sourceTree = ""; }; + B5F06A6A1D497396005BE736 /* java_only_listener.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = java_only_listener.hpp; sourceTree = ""; }; + B5F06A6B1D497396005BE736 /* objc_only_listener.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = objc_only_listener.hpp; sourceTree = ""; }; + B5F06A6C1D497396005BE736 /* uses_single_language_listeners.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = uses_single_language_listeners.hpp; sourceTree = ""; }; + B5F06A6E1D4973BD005BE736 /* DBConflict.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBConflict.h; sourceTree = ""; }; + B5F06A6F1D4973BD005BE736 /* DBConflict+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBConflict+Private.h"; sourceTree = ""; }; + B5F06A701D4973BD005BE736 /* DBConflict+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBConflict+Private.mm"; sourceTree = ""; }; + B5F06A711D4973BD005BE736 /* DBConflictUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBConflictUser.h; sourceTree = ""; }; + B5F06A721D4973BD005BE736 /* DBConflictUser+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBConflictUser+Private.h"; sourceTree = ""; }; + B5F06A731D4973BD005BE736 /* DBConflictUser+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBConflictUser+Private.mm"; sourceTree = ""; }; + B5F06A781D4973BD005BE736 /* DBExtendedRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBExtendedRecord.h; sourceTree = ""; }; + B5F06A791D4973BD005BE736 /* DBExtendedRecord.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBExtendedRecord.mm; sourceTree = ""; }; + B5F06A7A1D4973BD005BE736 /* DBExtendedRecord+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBExtendedRecord+Private.h"; sourceTree = ""; }; + B5F06A7B1D4973BD005BE736 /* DBExtendedRecord+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBExtendedRecord+Private.mm"; sourceTree = ""; }; + B5F06A7F1D4973BD005BE736 /* DBObjcOnlyListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBObjcOnlyListener.h; sourceTree = ""; }; + B5F06A801D4973BD005BE736 /* DBObjcOnlyListener+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBObjcOnlyListener+Private.h"; sourceTree = ""; }; + B5F06A811D4973BD005BE736 /* DBObjcOnlyListener+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBObjcOnlyListener+Private.mm"; sourceTree = ""; }; + B5F06A971D497A66005BE736 /* extended_record.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = extended_record.cpp; sourceTree = ""; }; + B5F06A981D497A66005BE736 /* extended_record.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = extended_record.hpp; sourceTree = ""; }; + B5F06A991D497A66005BE736 /* optional.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = optional.hpp; sourceTree = ""; }; + B5F06A9B1D4987C7005BE736 /* enum_usage_interface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = enum_usage_interface.hpp; sourceTree = ""; }; + B5F06A9C1D4987C7005BE736 /* enum_usage_record.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = enum_usage_record.hpp; sourceTree = ""; }; + B5F06A9D1D4987EF005BE736 /* DBColor+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBColor+Private.h"; sourceTree = ""; }; + B5F06A9E1D4987EF005BE736 /* DBEnumUsageInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBEnumUsageInterface.h; sourceTree = ""; }; + B5F06A9F1D4987EF005BE736 /* DBEnumUsageInterface+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBEnumUsageInterface+Private.h"; sourceTree = ""; }; + B5F06AA01D4987EF005BE736 /* DBEnumUsageInterface+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBEnumUsageInterface+Private.mm"; sourceTree = ""; }; + B5F06AA11D4987EF005BE736 /* DBEnumUsageRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBEnumUsageRecord.h; sourceTree = ""; }; + B5F06AA21D4987EF005BE736 /* DBEnumUsageRecord.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBEnumUsageRecord.mm; sourceTree = ""; }; + B5F06AA31D4987EF005BE736 /* DBEnumUsageRecord+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBEnumUsageRecord+Private.h"; sourceTree = ""; }; + B5F06AA41D4987EF005BE736 /* DBEnumUsageRecord+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBEnumUsageRecord+Private.mm"; sourceTree = ""; }; CFAED8711B54291900E3B8A3 /* DBEmptyRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBEmptyRecord.h; sourceTree = ""; }; CFAED8721B54291900E3B8A3 /* DBEmptyRecord.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBEmptyRecord.mm; sourceTree = ""; }; CFAED8731B54291900E3B8A3 /* DBEmptyRecord+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBEmptyRecord+Private.h"; sourceTree = ""; }; @@ -378,6 +450,10 @@ 6536CD7519A6C98800DD7715 /* handwritten-cpp */ = { isa = PBXGroup; children = ( + B519111A1D542B0700772DFE /* wchar_test_helpers.cpp */, + B5F06A971D497A66005BE736 /* extended_record.cpp */, + B5F06A981D497A66005BE736 /* extended_record.hpp */, + B5F06A991D497A66005BE736 /* optional.hpp */, B5E9C9391C1F9D9D0073C123 /* reverse_client_interface_impl.cpp */, B5E9C93A1C1F9D9D0073C123 /* reverse_client_interface_impl.hpp */, 6536CD7619A6C98800DD7715 /* cpp_exception_impl.cpp */, @@ -396,6 +472,7 @@ 6536CD7919A6C99800DD7715 /* Tests */ = { isa = PBXGroup; children = ( + 728E11201D37DE27005A554D /* DBWcharTests.m */, 6536CD7A19A6C99800DD7715 /* DBClientInterfaceTests.mm */, 6D66A8A81A3B09F000B312E8 /* DBConstantTests.mm */, 6536CD7B19A6C99800DD7715 /* DBCppExceptionTests.mm */, @@ -453,6 +530,47 @@ A24249181AF192E0003BF8F0 /* generated-objc */ = { isa = PBXGroup; children = ( + B51911491D555EE900772DFE /* DBVarnameRecord+Private.mm */, + B519114A1D555EE900772DFE /* DBVarnameRecord+Private.h */, + B519114B1D555EE900772DFE /* DBVarnameRecord.mm */, + B519114C1D555EE900772DFE /* DBVarnameRecord.h */, + B519114D1D555EE900772DFE /* DBVarnameInterface+Private.mm */, + B519114E1D555EE900772DFE /* DBVarnameInterface+Private.h */, + B519114F1D555EE900772DFE /* DBVarnameInterface.h */, + B51911151D542A7000772DFE /* DBWcharTestHelpers+Private.mm */, + B51911161D542A7000772DFE /* DBWcharTestHelpers+Private.h */, + B51911171D542A7000772DFE /* DBWcharTestHelpers.h */, + B5153F971D54284100012654 /* DBJavaOnlyListener+Private.mm */, + B5153F981D54284100012654 /* DBJavaOnlyListener+Private.h */, + B5153F991D54284100012654 /* DBJavaOnlyListener.h */, + B5153F891D54283700012654 /* DBWcharTestRec+Private.mm */, + B5153F8A1D54283700012654 /* DBWcharTestRec+Private.h */, + B5153F8B1D54283700012654 /* DBWcharTestRec.mm */, + B5153F8C1D54283700012654 /* DBWcharTestRec.h */, + B5153F901D54283700012654 /* DBUsesSingleLanguageListeners+Private.mm */, + B5153F911D54283700012654 /* DBUsesSingleLanguageListeners+Private.h */, + B5153F921D54283700012654 /* DBUsesSingleLanguageListeners.h */, + B5F06A9D1D4987EF005BE736 /* DBColor+Private.h */, + B5F06A9E1D4987EF005BE736 /* DBEnumUsageInterface.h */, + B5F06A9F1D4987EF005BE736 /* DBEnumUsageInterface+Private.h */, + B5F06AA01D4987EF005BE736 /* DBEnumUsageInterface+Private.mm */, + B5F06AA11D4987EF005BE736 /* DBEnumUsageRecord.h */, + B5F06AA21D4987EF005BE736 /* DBEnumUsageRecord.mm */, + B5F06AA31D4987EF005BE736 /* DBEnumUsageRecord+Private.h */, + B5F06AA41D4987EF005BE736 /* DBEnumUsageRecord+Private.mm */, + B5F06A6E1D4973BD005BE736 /* DBConflict.h */, + B5F06A6F1D4973BD005BE736 /* DBConflict+Private.h */, + B5F06A701D4973BD005BE736 /* DBConflict+Private.mm */, + B5F06A711D4973BD005BE736 /* DBConflictUser.h */, + B5F06A721D4973BD005BE736 /* DBConflictUser+Private.h */, + B5F06A731D4973BD005BE736 /* DBConflictUser+Private.mm */, + B5F06A781D4973BD005BE736 /* DBExtendedRecord.h */, + B5F06A791D4973BD005BE736 /* DBExtendedRecord.mm */, + B5F06A7A1D4973BD005BE736 /* DBExtendedRecord+Private.h */, + B5F06A7B1D4973BD005BE736 /* DBExtendedRecord+Private.mm */, + B5F06A7F1D4973BD005BE736 /* DBObjcOnlyListener.h */, + B5F06A801D4973BD005BE736 /* DBObjcOnlyListener+Private.h */, + B5F06A811D4973BD005BE736 /* DBObjcOnlyListener+Private.mm */, B5D8FC321C23E2F40045ADCF /* DBConstantRecord.h */, B5D8FC331C23E2F40045ADCF /* DBConstantRecord.mm */, B5D8FC341C23E2F40045ADCF /* DBConstantRecord+Private.h */, @@ -460,10 +578,6 @@ B5E9C93D1C1F9E9E0073C123 /* DBReverseClientInterface.h */, B5E9C93E1C1F9E9E0073C123 /* DBReverseClientInterface+Private.h */, B5E9C93F1C1F9E9E0073C123 /* DBReverseClientInterface+Private.mm */, - A209B5751BBA2A0A0070C310 /* DBOptColorRecord.h */, - A209B5761BBA2A0A0070C310 /* DBOptColorRecord.mm */, - A209B5771BBA2A0A0070C310 /* DBOptColorRecord+Private.h */, - A209B5781BBA2A0A0070C310 /* DBOptColorRecord+Private.mm */, B52DA5641B103F6D005CE75F /* DBAssortedPrimitives.h */, B52DA5651B103F6D005CE75F /* DBAssortedPrimitives.mm */, B52DA5661B103F6D005CE75F /* DBAssortedPrimitives+Private.h */, @@ -573,9 +687,21 @@ A242495D1AF192FC003BF8F0 /* generated-cpp */ = { isa = PBXGroup; children = ( + B51911471D555EDC00772DFE /* _varname_record_.hpp */, + B51911481D555EDC00772DFE /* _varname_interface_.hpp */, + B51911191D542AEC00772DFE /* wchar_test_helpers.hpp */, + B5153F871D54282C00012654 /* wchar_test_rec.hpp */, + B5F06A9B1D4987C7005BE736 /* enum_usage_interface.hpp */, + B5F06A9C1D4987C7005BE736 /* enum_usage_record.hpp */, + B5F06A651D497396005BE736 /* conflict_user.hpp */, + B5F06A661D497396005BE736 /* Conflict.hpp */, + B5F06A681D497396005BE736 /* extended_record_base.cpp */, + B5F06A691D497396005BE736 /* extended_record_base.hpp */, + B5F06A6A1D497396005BE736 /* java_only_listener.hpp */, + B5F06A6B1D497396005BE736 /* objc_only_listener.hpp */, + B5F06A6C1D497396005BE736 /* uses_single_language_listeners.hpp */, B5D8FC381C23E30D0045ADCF /* constant_record.hpp */, B5E9C93C1C1F9DCA0073C123 /* reverse_client_interface.hpp */, - A209B57B1BBA2A180070C310 /* opt_color_record.hpp */, B52DA56C1B103FBE005CE75F /* assorted_primitives.cpp */, B52DA56D1B103FBE005CE75F /* assorted_primitives.hpp */, A24249601AF192FC003BF8F0 /* client_interface.hpp */, @@ -699,6 +825,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + B5F06AA61D4987EF005BE736 /* DBEnumUsageRecord.mm in Sources */, A238CA981AF84B7100CDDCE5 /* DBMapRecord+Private.mm in Sources */, CFC5D9E81B1513E800BF2DF8 /* DBExternInterface1+Private.mm in Sources */, B5D8FC361C23E2F40045ADCF /* DBConstantRecord.mm in Sources */, @@ -713,6 +840,8 @@ A24850291AF96EBC00AFE907 /* DBDateRecord.mm in Sources */, A278D45319BA3601006FD937 /* test_helpers.cpp in Sources */, 6551684C1C4050A4003682A4 /* DBReturnOne+Private.mm in Sources */, + B51911501D555EE900772DFE /* DBVarnameRecord+Private.mm in Sources */, + B5F06AA51D4987EF005BE736 /* DBEnumUsageInterface+Private.mm in Sources */, CFFD588D1B019E79001E10B6 /* DBCppException+Private.mm in Sources */, A238CA921AF84B7100CDDCE5 /* DBDateRecord+Private.mm in Sources */, A248502B1AF96EBC00AFE907 /* DBMapListRecord.mm in Sources */, @@ -722,11 +851,12 @@ CFF89B931B5D2CC7007F6EC2 /* date_record.cpp in Sources */, A24850301AF96EBC00AFE907 /* DBRecordWithNestedDerivings.mm in Sources */, CFFD58B11B041BD9001E10B6 /* DBConstantsInterface.mm in Sources */, - A209B5791BBA2A0A0070C310 /* DBOptColorRecord.mm in Sources */, B52DA56E1B103FC5005CE75F /* assorted_primitives.cpp in Sources */, CFFD58B31B041BD9001E10B6 /* DBConstantsInterface+Private.mm in Sources */, CFC5D9FC1B152E4300BF2DF8 /* TranslateDuration.cpp in Sources */, + B51911511D555EE900772DFE /* DBVarnameRecord.mm in Sources */, A248502F1AF96EBC00AFE907 /* DBRecordWithDerivings.mm in Sources */, + B5F06A851D4973BD005BE736 /* DBConflict+Private.mm in Sources */, A24249741AF192FC003BF8F0 /* constants.cpp in Sources */, CFFD588B1B019E79001E10B6 /* DBClientInterface+Private.mm in Sources */, B52DA5691B103F72005CE75F /* DBAssortedPrimitives.mm in Sources */, @@ -736,14 +866,18 @@ CFAED8751B54291900E3B8A3 /* DBEmptyRecord.mm in Sources */, A238CA9A1AF84B7100CDDCE5 /* DBNestedCollection+Private.mm in Sources */, CFFD58911B019E79001E10B6 /* DBUserToken+Private.mm in Sources */, + B5153F9A1D54284100012654 /* DBJavaOnlyListener+Private.mm in Sources */, + B5F06A9A1D497A66005BE736 /* extended_record.cpp in Sources */, A2CB54B419BA6E6000A9E600 /* DJIError.mm in Sources */, B5E9C9401C1F9E9E0073C123 /* DBReverseClientInterface+Private.mm in Sources */, + B5F06A891D4973BD005BE736 /* DBExtendedRecord.mm in Sources */, A238CA961AF84B7100CDDCE5 /* DBMapListRecord+Private.mm in Sources */, A238CA9C1AF84B7100CDDCE5 /* DBPrimitiveList+Private.mm in Sources */, 650CA05A1C2AB48E007ADDDB /* DBListenerCaller+Private.mm in Sources */, A24249761AF192FC003BF8F0 /* record_with_nested_derivings.cpp in Sources */, CFC5DA081B1532F600BF2DF8 /* DBRecordWithDurationAndDerivings.mm in Sources */, A248502D1AF96EBC00AFE907 /* DBNestedCollection.mm in Sources */, + B5F06A861D4973BD005BE736 /* DBConflictUser+Private.mm in Sources */, B5E9C93B1C1F9D9D0073C123 /* reverse_client_interface_impl.cpp in Sources */, CFC5D9D81B15106400BF2DF8 /* DBExternRecordWithDerivings+Private.mm in Sources */, A238CAA21AF84B7100CDDCE5 /* DBSetRecord+Private.mm in Sources */, @@ -752,17 +886,26 @@ 6551684F1C40511C003682A4 /* return_one_two.cpp in Sources */, A24249751AF192FC003BF8F0 /* record_with_derivings.cpp in Sources */, CFC5D9D01B15105100BF2DF8 /* extern_record_with_derivings.cpp in Sources */, + B51911181D542A7000772DFE /* DBWcharTestHelpers+Private.mm in Sources */, A238CA901AF84B7100CDDCE5 /* DBConstants+Private.mm in Sources */, + B51911521D555EE900772DFE /* DBVarnameInterface+Private.mm in Sources */, CFC5D9EA1B1513E800BF2DF8 /* DBExternInterface2+Private.mm in Sources */, CFC5DA011B15318B00BF2DF8 /* DBTestDuration+Private.mm in Sources */, 650CA05E1C2AB5AB007ADDDB /* ListenerCaller.cpp in Sources */, A248502A1AF96EBC00AFE907 /* DBMapDateRecord.mm in Sources */, + B5F06A6D1D497396005BE736 /* extended_record_base.cpp in Sources */, A238CA8E1AF84B7100CDDCE5 /* DBClientReturnedRecord+Private.mm in Sources */, + B5F06A8A1D4973BD005BE736 /* DBExtendedRecord+Private.mm in Sources */, 6551684D1C4050A4003682A4 /* DBReturnTwo+Private.mm in Sources */, + B5F06AA71D4987EF005BE736 /* DBEnumUsageRecord+Private.mm in Sources */, B52DA56B1B103F75005CE75F /* DBAssortedPrimitives+Private.mm in Sources */, + B5153F941D54283700012654 /* DBWcharTestRec.mm in Sources */, + B5153F931D54283700012654 /* DBWcharTestRec+Private.mm in Sources */, A248502E1AF96EBC00AFE907 /* DBPrimitiveList.mm in Sources */, - A209B57A1BBA2A0A0070C310 /* DBOptColorRecord+Private.mm in Sources */, + B5F06A8C1D4973BD005BE736 /* DBObjcOnlyListener+Private.mm in Sources */, + B5153F961D54283700012654 /* DBUsesSingleLanguageListeners+Private.mm in Sources */, B5D8FC371C23E2F40045ADCF /* DBConstantRecord+Private.mm in Sources */, + B519111B1D542B0700772DFE /* wchar_test_helpers.cpp in Sources */, A238CAA01AF84B7100CDDCE5 /* DBRecordWithNestedDerivings+Private.mm in Sources */, CFC5DA0A1B1532F600BF2DF8 /* DBRecordWithDurationAndDerivings+Private.mm in Sources */, ); @@ -772,6 +915,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5AEA68151D38F4A40083D770 /* DBWcharTests.m in Sources */, CFC5D9D11B15105100BF2DF8 /* extern_record_with_derivings.cpp in Sources */, 6D66A8A91A3B09F000B312E8 /* DBConstantTests.mm in Sources */, 6536CD9219A6C9A800DD7715 /* DBRecordWithDerivingsCppTests.mm in Sources */, @@ -833,7 +977,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; @@ -877,7 +1021,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; diff --git a/test-suite/run_djinni.sh b/test-suite/run_djinni.sh index 89ef14051..68d7d274d 100755 --- a/test-suite/run_djinni.sh +++ b/test-suite/run_djinni.sh @@ -17,12 +17,14 @@ base_dir=$(cd "`dirname "$loc"`" && pwd) temp_out="$base_dir/djinni-output-temp" in="$base_dir/djinni/all.djinni" +wchar_in="$base_dir/djinni/wchar_test.djinni" # Relative version of in and temp_out are used for Djinni call below so that # generated lists of infiles/outfiles are not machine-dependent. This # is an artifact of the test suite, where we want the genereated files # to be in git for examination. in_relative="djinni/all.djinni" +wchar_in_relative="djinni/wchar_test.djinni" temp_out_relative="djinni-output-temp" cpp_out="$base_dir/generated-src/cpp" @@ -55,8 +57,10 @@ elif [ $# -eq 1 ]; then exit fi -# Build Djinni. +# Build Djinni "$base_dir/../src/build" + +# Run Djinni generation [ ! -e "$temp_out" ] || rm -r "$temp_out" (cd "$base_dir" && \ "$base_dir/../src/run-assume-built" \ @@ -71,7 +75,36 @@ fi --cpp-namespace testsuite \ --ident-cpp-enum-type foo_bar \ --cpp-optional-template "std::experimental::optional" \ - --cpp-optional-header "" \ + --cpp-optional-header "\"../../handwritten-src/cpp/optional.hpp\"" \ + --cpp-extended-record-include-prefix "../../handwritten-src/cpp/" \ + --cpp-use-wide-strings true \ + \ + --jni-out "$temp_out_relative/jni" \ + --ident-jni-class NativeFooBar \ + --ident-jni-file NativeFooBar \ + \ + --objc-out "$temp_out_relative/objc" \ + --objcpp-out "$temp_out_relative/objc" \ + --objc-type-prefix DB \ + \ + --yaml-out "$temp_out_relative/yaml" \ + --yaml-out-file "yaml-test.yaml" \ + --yaml-prefix "test_" \ + \ + --idl "$wchar_in_relative" && \ +"$base_dir/../src/run-assume-built" \ + --java-out "$temp_out_relative/java" \ + --java-package $java_package \ + --java-nullable-annotation "javax.annotation.CheckForNull" \ + --java-nonnull-annotation "javax.annotation.Nonnull" \ + --java-use-final-for-record false \ + --ident-java-field mFooBar \ + \ + --cpp-out "$temp_out_relative/cpp" \ + --cpp-namespace testsuite \ + --ident-cpp-enum-type foo_bar \ + --cpp-optional-template "std::experimental::optional" \ + --cpp-optional-header "\"../../handwritten-src/cpp/optional.hpp\"" \ --cpp-extended-record-include-prefix "../../handwritten-src/cpp/" \ \ --jni-out "$temp_out_relative/jni" \ @@ -94,27 +127,29 @@ fi # Make sure we can parse back our own generated YAML file cp "$base_dir/djinni/yaml-test.djinni" "$temp_out/yaml" +(cd "$base_dir" && \ "$base_dir/../src/run-assume-built" \ - --java-out "$temp_out/java" \ + --java-out "$temp_out_relative/java" \ --java-package $java_package \ --ident-java-field mFooBar \ \ - --cpp-out "$temp_out/cpp" \ + --cpp-out "$temp_out_relative/cpp" \ --ident-cpp-enum-type foo_bar \ --cpp-optional-template "std::experimental::optional" \ - --cpp-optional-header "" \ + --cpp-optional-header "\"../../handwritten-src/cpp/optional.hpp\"" \ \ - --jni-out "$temp_out/jni" \ + --jni-out "$temp_out_relative/jni" \ --ident-jni-class NativeFooBar \ --ident-jni-file NativeFooBar \ \ - --objc-out "$temp_out/objc" \ - --objcpp-out "$temp_out/objc" \ + --objc-out "$temp_out_relative/objc" \ + --objcpp-out "$temp_out_relative/objc" \ --objc-type-prefix DB \ \ - --idl "$temp_out/yaml/yaml-test.djinni" + --idl "$temp_out_relative/yaml/yaml-test.djinni" \ +) -# Copy changes from "$temp_output" to final dir. +# Copy changes from "$temp_out" to final dir. mirror() { local prefix="$1" ; shift From 6e5ff73d824f19e2f2f70edc57556f5d7cc6d8e7 Mon Sep 17 00:00:00 2001 From: Mike Foster Date: Thu, 11 Aug 2016 08:24:27 -0400 Subject: [PATCH 7/7] Interface Inheritance test cases for iOS and Android. Also addresses a few defects with the interface inheritance implementation that were found while writing the test cases. --- example/generated-src/cpp/sort_items.hpp | 2 +- .../generated-src/cpp/textbox_listener.hpp | 2 +- src/source/CppGenerator.scala | 6 +- src/source/CppMarshal.scala | 2 +- src/source/ast.scala | 8 + src/source/resolver.scala | 26 ++-- support-lib/objc/DJICppWrapperCache+Private.h | 2 +- test-suite/djinni/common.djinni | 1 + .../djinni/interface_inheritance.djinni | 44 ++++++ test-suite/generated-src/cpp/Conflict.hpp | 2 +- .../generated-src/cpp/_varname_interface_.hpp | 2 +- .../cpp/base_cpp_interface_inheritance.hpp | 49 ++++++ .../base_objc_java_interface_inheritance.hpp | 46 ++++++ .../generated-src/cpp/client_interface.hpp | 2 +- .../generated-src/cpp/conflict_user.hpp | 2 +- .../generated-src/cpp/constants_interface.hpp | 2 +- .../generated-src/cpp/cpp_exception.hpp | 2 +- .../cpp/enum_usage_interface.hpp | 2 +- .../generated-src/cpp/extern_interface_1.hpp | 2 +- .../generated-src/cpp/extern_interface_2.hpp | 2 +- .../generated-src/cpp/first_listener.hpp | 2 +- .../cpp/interface_encapsulator.hpp | 65 ++++++++ .../cpp/interface_inheritance_constant.cpp | 16 ++ .../cpp/interface_inheritance_constant.hpp | 50 +++++++ .../generated-src/cpp/java_only_listener.hpp | 2 +- .../generated-src/cpp/listener_caller.hpp | 2 +- .../generated-src/cpp/objc_only_listener.hpp | 2 +- test-suite/generated-src/cpp/return_one.hpp | 2 +- test-suite/generated-src/cpp/return_two.hpp | 2 +- .../cpp/reverse_client_interface.hpp | 2 +- .../generated-src/cpp/second_listener.hpp | 2 +- .../cpp/sub_cpp_interface_inheritance.hpp | 48 ++++++ .../sub_objc_java_interface_inheritance.hpp | 45 ++++++ .../generated-src/cpp/test_duration.hpp | 2 +- test-suite/generated-src/cpp/test_helpers.hpp | 2 +- test-suite/generated-src/cpp/user_token.hpp | 2 +- .../cpp/uses_single_language_listeners.hpp | 2 +- .../generated-src/cpp/wchar_test_helpers.hpp | 2 +- test-suite/generated-src/inFileList.txt | 43 +++--- .../test/BaseCppInterfaceInheritance.java | 61 ++++++++ .../BaseObjcJavaInterfaceInheritance.java | 15 ++ .../djinni/test/InterfaceEncapsulator.java | 107 ++++++++++++++ .../test/InterfaceInheritanceConstant.java | 49 ++++++ .../test/SubCppInterfaceInheritance.java | 68 +++++++++ .../test/SubObjcJavaInterfaceInheritance.java | 12 ++ .../jni/NativeBaseCppInterfaceInheritance.cpp | 51 +++++++ .../jni/NativeBaseCppInterfaceInheritance.hpp | 32 ++++ ...NativeBaseObjcJavaInterfaceInheritance.cpp | 34 +++++ ...NativeBaseObjcJavaInterfaceInheritance.hpp | 48 ++++++ .../jni/NativeInterfaceEncapsulator.cpp | 91 ++++++++++++ .../jni/NativeInterfaceEncapsulator.hpp | 32 ++++ .../NativeInterfaceInheritanceConstant.cpp | 26 ++++ .../NativeInterfaceInheritanceConstant.hpp | 44 ++++++ .../jni/NativeSubCppInterfaceInheritance.cpp | 61 ++++++++ .../jni/NativeSubCppInterfaceInheritance.hpp | 33 +++++ .../NativeSubObjcJavaInterfaceInheritance.cpp | 42 ++++++ .../NativeSubObjcJavaInterfaceInheritance.hpp | 51 +++++++ .../DBBaseCppInterfaceInheritance+Private.h | 31 ++++ .../DBBaseCppInterfaceInheritance+Private.mm | 81 ++++++++++ .../objc/DBBaseCppInterfaceInheritance.h | 16 ++ ...BaseObjcJavaInterfaceInheritance+Private.h | 31 ++++ ...aseObjcJavaInterfaceInheritance+Private.mm | 58 ++++++++ .../objc/DBBaseObjcJavaInterfaceInheritance.h | 13 ++ .../objc/DBInterfaceEncapsulator+Private.h | 31 ++++ .../objc/DBInterfaceEncapsulator+Private.mm | 109 ++++++++++++++ .../objc/DBInterfaceEncapsulator.h | 31 ++++ .../DBInterfaceInheritanceConstant+Private.h | 31 ++++ .../DBInterfaceInheritanceConstant+Private.mm | 82 +++++++++++ .../objc/DBInterfaceInheritanceConstant.h | 13 ++ .../objc/DBInterfaceInheritanceConstant.mm | 13 ++ .../DBSubCppInterfaceInheritance+Private.h | 32 ++++ .../DBSubCppInterfaceInheritance+Private.mm | 90 ++++++++++++ .../objc/DBSubCppInterfaceInheritance.h | 15 ++ ...BSubObjcJavaInterfaceInheritance+Private.h | 32 ++++ ...SubObjcJavaInterfaceInheritance+Private.mm | 67 +++++++++ .../objc/DBSubObjcJavaInterfaceInheritance.h | 12 ++ test-suite/generated-src/outFileList.txt | 44 ++++++ .../base_cpp_interface_inheritance_impl.cpp | 18 +++ .../base_cpp_interface_inheritance_impl.hpp | 15 ++ .../cpp/interface_encapsulator_impl.cpp | 45 ++++++ .../cpp/interface_encapsulator_impl.hpp | 28 ++++ .../sub_cpp_interface_inheritance_impl.cpp | 26 ++++ .../sub_cpp_interface_inheritance_impl.hpp | 20 +++ .../com/dropbox/djinni/test/AllTests.java | 1 + .../BaseObjcJavaInterfaceInheritanceImpl.java | 17 +++ .../djinni/test/InterfaceInheritanceTest.java | 104 +++++++++++++ .../SubObjcJavaInterfaceInheritanceImpl.java | 25 ++++ .../DBBaseObjcJavaInterfaceInheritanceImpl.h | 7 + .../DBBaseObjcJavaInterfaceInheritanceImpl.m | 17 +++ .../DBSubObjcJavaInterfaceInheritanceImpl.h | 7 + .../DBSubObjcJavaInterfaceInheritanceImpl.m | 38 +++++ .../objc/tests/DBInterfaceInheritanceTests.mm | 139 ++++++++++++++++++ .../DjinniObjcTest.xcodeproj/project.pbxproj | 103 +++++++++++++ 93 files changed, 2737 insertions(+), 61 deletions(-) create mode 100644 test-suite/djinni/interface_inheritance.djinni create mode 100644 test-suite/generated-src/cpp/base_cpp_interface_inheritance.hpp create mode 100644 test-suite/generated-src/cpp/base_objc_java_interface_inheritance.hpp create mode 100644 test-suite/generated-src/cpp/interface_encapsulator.hpp create mode 100644 test-suite/generated-src/cpp/interface_inheritance_constant.cpp create mode 100644 test-suite/generated-src/cpp/interface_inheritance_constant.hpp create mode 100644 test-suite/generated-src/cpp/sub_cpp_interface_inheritance.hpp create mode 100644 test-suite/generated-src/cpp/sub_objc_java_interface_inheritance.hpp create mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/BaseCppInterfaceInheritance.java create mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/BaseObjcJavaInterfaceInheritance.java create mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/InterfaceEncapsulator.java create mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/InterfaceInheritanceConstant.java create mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/SubCppInterfaceInheritance.java create mode 100644 test-suite/generated-src/java/com/dropbox/djinni/test/SubObjcJavaInterfaceInheritance.java create mode 100644 test-suite/generated-src/jni/NativeBaseCppInterfaceInheritance.cpp create mode 100644 test-suite/generated-src/jni/NativeBaseCppInterfaceInheritance.hpp create mode 100644 test-suite/generated-src/jni/NativeBaseObjcJavaInterfaceInheritance.cpp create mode 100644 test-suite/generated-src/jni/NativeBaseObjcJavaInterfaceInheritance.hpp create mode 100644 test-suite/generated-src/jni/NativeInterfaceEncapsulator.cpp create mode 100644 test-suite/generated-src/jni/NativeInterfaceEncapsulator.hpp create mode 100644 test-suite/generated-src/jni/NativeInterfaceInheritanceConstant.cpp create mode 100644 test-suite/generated-src/jni/NativeInterfaceInheritanceConstant.hpp create mode 100644 test-suite/generated-src/jni/NativeSubCppInterfaceInheritance.cpp create mode 100644 test-suite/generated-src/jni/NativeSubCppInterfaceInheritance.hpp create mode 100644 test-suite/generated-src/jni/NativeSubObjcJavaInterfaceInheritance.cpp create mode 100644 test-suite/generated-src/jni/NativeSubObjcJavaInterfaceInheritance.hpp create mode 100644 test-suite/generated-src/objc/DBBaseCppInterfaceInheritance+Private.h create mode 100644 test-suite/generated-src/objc/DBBaseCppInterfaceInheritance+Private.mm create mode 100644 test-suite/generated-src/objc/DBBaseCppInterfaceInheritance.h create mode 100644 test-suite/generated-src/objc/DBBaseObjcJavaInterfaceInheritance+Private.h create mode 100644 test-suite/generated-src/objc/DBBaseObjcJavaInterfaceInheritance+Private.mm create mode 100644 test-suite/generated-src/objc/DBBaseObjcJavaInterfaceInheritance.h create mode 100644 test-suite/generated-src/objc/DBInterfaceEncapsulator+Private.h create mode 100644 test-suite/generated-src/objc/DBInterfaceEncapsulator+Private.mm create mode 100644 test-suite/generated-src/objc/DBInterfaceEncapsulator.h create mode 100644 test-suite/generated-src/objc/DBInterfaceInheritanceConstant+Private.h create mode 100644 test-suite/generated-src/objc/DBInterfaceInheritanceConstant+Private.mm create mode 100644 test-suite/generated-src/objc/DBInterfaceInheritanceConstant.h create mode 100644 test-suite/generated-src/objc/DBInterfaceInheritanceConstant.mm create mode 100644 test-suite/generated-src/objc/DBSubCppInterfaceInheritance+Private.h create mode 100644 test-suite/generated-src/objc/DBSubCppInterfaceInheritance+Private.mm create mode 100644 test-suite/generated-src/objc/DBSubCppInterfaceInheritance.h create mode 100644 test-suite/generated-src/objc/DBSubObjcJavaInterfaceInheritance+Private.h create mode 100644 test-suite/generated-src/objc/DBSubObjcJavaInterfaceInheritance+Private.mm create mode 100644 test-suite/generated-src/objc/DBSubObjcJavaInterfaceInheritance.h create mode 100644 test-suite/handwritten-src/cpp/base_cpp_interface_inheritance_impl.cpp create mode 100644 test-suite/handwritten-src/cpp/base_cpp_interface_inheritance_impl.hpp create mode 100644 test-suite/handwritten-src/cpp/interface_encapsulator_impl.cpp create mode 100644 test-suite/handwritten-src/cpp/interface_encapsulator_impl.hpp create mode 100644 test-suite/handwritten-src/cpp/sub_cpp_interface_inheritance_impl.cpp create mode 100644 test-suite/handwritten-src/cpp/sub_cpp_interface_inheritance_impl.hpp create mode 100644 test-suite/handwritten-src/java/com/dropbox/djinni/test/BaseObjcJavaInterfaceInheritanceImpl.java create mode 100644 test-suite/handwritten-src/java/com/dropbox/djinni/test/InterfaceInheritanceTest.java create mode 100644 test-suite/handwritten-src/java/com/dropbox/djinni/test/SubObjcJavaInterfaceInheritanceImpl.java create mode 100644 test-suite/handwritten-src/objc/impl/DBBaseObjcJavaInterfaceInheritanceImpl.h create mode 100644 test-suite/handwritten-src/objc/impl/DBBaseObjcJavaInterfaceInheritanceImpl.m create mode 100644 test-suite/handwritten-src/objc/impl/DBSubObjcJavaInterfaceInheritanceImpl.h create mode 100644 test-suite/handwritten-src/objc/impl/DBSubObjcJavaInterfaceInheritanceImpl.m create mode 100644 test-suite/handwritten-src/objc/tests/DBInterfaceInheritanceTests.mm diff --git a/example/generated-src/cpp/sort_items.hpp b/example/generated-src/cpp/sort_items.hpp index 329a0023f..687b8249e 100644 --- a/example/generated-src/cpp/sort_items.hpp +++ b/example/generated-src/cpp/sort_items.hpp @@ -41,7 +41,7 @@ class SortItems { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "TXSSortItems"; } + virtual const std::string objcProxyClassName() { return "TXSSortItems"; } /** For the iOS / Android demo */ virtual void sort(sort_order order, const ItemList & items) = 0; diff --git a/example/generated-src/cpp/textbox_listener.hpp b/example/generated-src/cpp/textbox_listener.hpp index cd0b93821..dcc1cb9ee 100644 --- a/example/generated-src/cpp/textbox_listener.hpp +++ b/example/generated-src/cpp/textbox_listener.hpp @@ -38,7 +38,7 @@ class TextboxListener { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "TXSTextboxListener"; } + virtual const std::string objcProxyClassName() { return "TXSTextboxListener"; } virtual void update(const ItemList & items) = 0; }; diff --git a/src/source/CppGenerator.scala b/src/source/CppGenerator.scala index 700c30e2a..298bb1ff5 100644 --- a/src/source/CppGenerator.scala +++ b/src/source/CppGenerator.scala @@ -318,7 +318,9 @@ class CppGenerator(spec: Spec) extends Generator(spec) { w.wl(" */") w.wl(s"virtual const std::string jniProxyClassName() { return $jniProxyClassName; }") - val objcTypeName = q(objcMarshal.typename(ident, i)) + val objcTypeName = objcMarshal.typename(ident, i) + val objcProxyClassName = q(if (i.ext.objc && i.ext.cpp) objcTypeName + "CppProxy" else objcTypeName) + w.wl w.wl("/**") w.wl(" * Defines the name of the Objective-C type for the class. Used to convert a") @@ -329,7 +331,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) { w.wl(" * ") w.wl(" * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp") w.wl(" */") - w.wl(s"virtual const std::string objcTypeName() { return $objcTypeName; }") + w.wl(s"virtual const std::string objcProxyClassName() { return $objcProxyClassName; }") // Constants generateHppConstants(w, i.consts) diff --git a/src/source/CppMarshal.scala b/src/source/CppMarshal.scala index b7ba214e7..53cd05f34 100644 --- a/src/source/CppMarshal.scala +++ b/src/source/CppMarshal.scala @@ -27,7 +27,7 @@ class CppMarshal(spec: Spec) extends Marshal(spec) { } def superTypename(ty: TypeDef): Option[String] = ty match { - case i: Interface => if (i.superIdent.isDefined) Some(i.superIdent.get.name) else None + case i: Interface => if (i.superIdent.isDefined) Some(idCpp.ty(i.superIdent.get.name)) else None case _ => None } diff --git a/src/source/ast.scala b/src/source/ast.scala index 34c0eec5f..cf6699e1b 100644 --- a/src/source/ast.scala +++ b/src/source/ast.scala @@ -50,6 +50,14 @@ case class Ext(java: Boolean, cpp: Boolean, objc: Boolean) { def any(): Boolean = { java || cpp || objc } + + override def equals(that: Any): Boolean = that match { + case that: Ext => that.java == this.java && that.objc == this.objc && that.cpp == this.cpp + case _ => false + } + override def hashCode:Int = { + (if (java) 1 << 0 else 0) | (if (cpp) 1 << 1 else 0) | (if (objc) 1 << 2 else 0) + } } case class TypeRef(expr: TypeExpr) { diff --git a/src/source/resolver.scala b/src/source/resolver.scala index f47ad9099..209b904e6 100644 --- a/src/source/resolver.scala +++ b/src/source/resolver.scala @@ -264,28 +264,30 @@ private def resolveRecord(scope: Scope, r: Record) { } private def resolveInterface(idl: Seq[TypeDecl], scope: Scope, i: Interface) { - // Const and static methods are only allowed on +c (only) interfaces - if (i.ext.java || i.ext.objc) { - for (m <- i.methods) { - if (m.static) - throw Error(m.ident.loc, "static not allowed for +j or +o interfaces").toException - if (m.const) - throw Error(m.ident.loc, "const method not allowed for +j or +o +p interfaces").toException - } - } - - // Check that the inherited interface 1) exists, and 2) is in fact an interface + // Check that the inherited interface 1) exists, 2) is in fact an interface, and 3) is implemented in the same language if (i.superIdent.isDefined) { val superIdent = i.superIdent.get idl.find(td => td.ident.name == superIdent.name) match { case Some(superDecl) => superDecl.body match { - case i: Interface => // All good! + case si: Interface => + if (!si.ext.equals(i.ext)) + throw Error(superIdent.loc, "Sub-interface implementation declarations (+j +o +c) must match super-interface.").toException + else None // All good! case _ => throw Error(superIdent.loc, s"'${superIdent.name}' is not an interface. Interfaces can only extend other interfaces.").toException } case None => throw Error(superIdent.loc, s"Unknown interface '${superIdent.name}'").toException } } + // Const and static methods are only allowed on +c (only) interfaces + if (i.ext.java || i.ext.objc) { + for (m <- i.methods) { + if (m.static) + throw Error(m.ident.loc, "static not allowed for +j or +o interfaces").toException + if (m.const) + throw Error(m.ident.loc, "const method not allowed for +j or +o +p interfaces").toException + } + } // Static+const isn't valid if (i.ext.cpp) { diff --git a/support-lib/objc/DJICppWrapperCache+Private.h b/support-lib/objc/DJICppWrapperCache+Private.h index 08cd30e49..bc0a79594 100644 --- a/support-lib/objc/DJICppWrapperCache+Private.h +++ b/support-lib/objc/DJICppWrapperCache+Private.h @@ -46,7 +46,7 @@ ObjcType * get_cpp_proxy_impl(const std::shared_ptr & cppRef) { [] (const std::shared_ptr & cppRef) -> std::pair { auto castCppRef = std::static_pointer_cast(cppRef); return { - [((ObjcType *)[objc_getClass(castCppRef->objcTypeName().c_str()) alloc]) initWithCpp:castCppRef], + [((ObjcType *)[objc_getClass(castCppRef->objcProxyClassName().c_str()) alloc]) initWithCpp:castCppRef], cppRef.get() }; } diff --git a/test-suite/djinni/common.djinni b/test-suite/djinni/common.djinni index 5c165f605..9185082f5 100644 --- a/test-suite/djinni/common.djinni +++ b/test-suite/djinni/common.djinni @@ -14,3 +14,4 @@ @import "single_language_interfaces.djinni" @import "extended_record.djinni" @import "varnames.djinni" +@import "interface_inheritance.djinni" diff --git a/test-suite/djinni/interface_inheritance.djinni b/test-suite/djinni/interface_inheritance.djinni new file mode 100644 index 000000000..cb48751ec --- /dev/null +++ b/test-suite/djinni/interface_inheritance.djinni @@ -0,0 +1,44 @@ +interface_inheritance_constant = interface { + const base_method_return_value: string = "base_method"; + const base_override_method_return_value: string = "override_method"; + + const sub_method_return_value: string = "sub_method"; + const sub_override_method_return_value: string = "sub_override_method"; +} + +base_cpp_interface_inheritance = interface +c { + base_method(): string; + override_method(): string; + + static create(): base_cpp_interface_inheritance; +} + +sub_cpp_interface_inheritance = interface extends base_cpp_interface_inheritance +c { + sub_method(): string; + + static create(): sub_cpp_interface_inheritance; +} + +base_objc_java_interface_inheritance = interface +o +j { + base_method(): string; + override_method(): string; +} + +sub_objc_java_interface_inheritance = interface extends base_objc_java_interface_inheritance +o +j { + sub_method(): string; +} + +interface_encapsulator = interface +c { + set_cpp_object(object: base_cpp_interface_inheritance); + get_cpp_object(): base_cpp_interface_inheritance; + sub_cpp_as_base_cpp(): base_cpp_interface_inheritance; + + set_objc_java_object(object: base_objc_java_interface_inheritance); + get_objc_java_object(): base_objc_java_interface_inheritance; + + # Takes a sub interface object through a base interface argument, then cast the argument back to + # the sub interface. Returning null signifies failure. + cast_base_arg_to_sub(subAsBase: base_objc_java_interface_inheritance): sub_objc_java_interface_inheritance; + + static create(): interface_encapsulator; +} diff --git a/test-suite/generated-src/cpp/Conflict.hpp b/test-suite/generated-src/cpp/Conflict.hpp index 558baf6fe..f081201f4 100644 --- a/test-suite/generated-src/cpp/Conflict.hpp +++ b/test-suite/generated-src/cpp/Conflict.hpp @@ -40,7 +40,7 @@ class Conflict { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBConflict"; } + virtual const std::string objcProxyClassName() { return "DBConflict"; } }; } // namespace testsuite diff --git a/test-suite/generated-src/cpp/_varname_interface_.hpp b/test-suite/generated-src/cpp/_varname_interface_.hpp index 43102206c..6b5685a37 100644 --- a/test-suite/generated-src/cpp/_varname_interface_.hpp +++ b/test-suite/generated-src/cpp/_varname_interface_.hpp @@ -39,7 +39,7 @@ class VarnameInterface { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBVarnameInterface"; } + virtual const std::string objcProxyClassName() { return "DBVarnameInterface"; } virtual VarnameRecord _rmethod_(const VarnameRecord & _r_arg_) = 0; diff --git a/test-suite/generated-src/cpp/base_cpp_interface_inheritance.hpp b/test-suite/generated-src/cpp/base_cpp_interface_inheritance.hpp new file mode 100644 index 000000000..0125d5095 --- /dev/null +++ b/test-suite/generated-src/cpp/base_cpp_interface_inheritance.hpp @@ -0,0 +1,49 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#pragma once + +#include +#include + +namespace testsuite { + +class BaseCppInterfaceInheritance { +public: + virtual ~BaseCppInterfaceInheritance() {} + + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/BaseCppInterfaceInheritance$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcProxyClassName() { return "DBBaseCppInterfaceInheritance"; } + + virtual std::string base_method() = 0; + + virtual std::string override_method() = 0; + + static std::shared_ptr create(); +}; + +} // namespace testsuite diff --git a/test-suite/generated-src/cpp/base_objc_java_interface_inheritance.hpp b/test-suite/generated-src/cpp/base_objc_java_interface_inheritance.hpp new file mode 100644 index 000000000..e3ca2a2d7 --- /dev/null +++ b/test-suite/generated-src/cpp/base_objc_java_interface_inheritance.hpp @@ -0,0 +1,46 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#pragma once + +#include + +namespace testsuite { + +class BaseObjcJavaInterfaceInheritance { +public: + virtual ~BaseObjcJavaInterfaceInheritance() {} + + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return nullptr; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcProxyClassName() { return "DBBaseObjcJavaInterfaceInheritance"; } + + virtual std::string base_method() = 0; + + virtual std::string override_method() = 0; +}; + +} // namespace testsuite diff --git a/test-suite/generated-src/cpp/client_interface.hpp b/test-suite/generated-src/cpp/client_interface.hpp index ec55cd7f5..78299eeac 100644 --- a/test-suite/generated-src/cpp/client_interface.hpp +++ b/test-suite/generated-src/cpp/client_interface.hpp @@ -43,7 +43,7 @@ class ClientInterface { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBClientInterface"; } + virtual const std::string objcProxyClassName() { return "DBClientInterface"; } /** Returns record of given string */ virtual ClientReturnedRecord get_record(int64_t record_id, const std::string & utf8string, const std::experimental::optional & misc) = 0; diff --git a/test-suite/generated-src/cpp/conflict_user.hpp b/test-suite/generated-src/cpp/conflict_user.hpp index b1ce0327f..7d8451e78 100644 --- a/test-suite/generated-src/cpp/conflict_user.hpp +++ b/test-suite/generated-src/cpp/conflict_user.hpp @@ -40,7 +40,7 @@ class ConflictUser { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBConflictUser"; } + virtual const std::string objcProxyClassName() { return "DBConflictUser"; } virtual std::shared_ptr<::testsuite::Conflict> Conflict() = 0; diff --git a/test-suite/generated-src/cpp/constants_interface.hpp b/test-suite/generated-src/cpp/constants_interface.hpp index 0216e5281..9472d938e 100644 --- a/test-suite/generated-src/cpp/constants_interface.hpp +++ b/test-suite/generated-src/cpp/constants_interface.hpp @@ -41,7 +41,7 @@ class ConstantsInterface { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBConstantsInterface"; } + virtual const std::string objcProxyClassName() { return "DBConstantsInterface"; } static bool const BOOL_CONSTANT; diff --git a/test-suite/generated-src/cpp/cpp_exception.hpp b/test-suite/generated-src/cpp/cpp_exception.hpp index e9cfa0ac5..afe3b26a6 100644 --- a/test-suite/generated-src/cpp/cpp_exception.hpp +++ b/test-suite/generated-src/cpp/cpp_exception.hpp @@ -38,7 +38,7 @@ class CppException { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBCppException"; } + virtual const std::string objcProxyClassName() { return "DBCppException"; } virtual int32_t throw_an_exception() = 0; diff --git a/test-suite/generated-src/cpp/enum_usage_interface.hpp b/test-suite/generated-src/cpp/enum_usage_interface.hpp index 98074e648..d3b1343c2 100644 --- a/test-suite/generated-src/cpp/enum_usage_interface.hpp +++ b/test-suite/generated-src/cpp/enum_usage_interface.hpp @@ -42,7 +42,7 @@ class EnumUsageInterface { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBEnumUsageInterface"; } + virtual const std::string objcProxyClassName() { return "DBEnumUsageInterfaceCppProxy"; } virtual color e(color e) = 0; diff --git a/test-suite/generated-src/cpp/extern_interface_1.hpp b/test-suite/generated-src/cpp/extern_interface_1.hpp index 0e498dc4a..67311487a 100644 --- a/test-suite/generated-src/cpp/extern_interface_1.hpp +++ b/test-suite/generated-src/cpp/extern_interface_1.hpp @@ -37,7 +37,7 @@ class ExternInterface1 { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBExternInterface1"; } + virtual const std::string objcProxyClassName() { return "DBExternInterface1"; } virtual ::testsuite::ClientReturnedRecord foo(const std::shared_ptr<::testsuite::ClientInterface> & i) = 0; }; diff --git a/test-suite/generated-src/cpp/extern_interface_2.hpp b/test-suite/generated-src/cpp/extern_interface_2.hpp index 9b07dbece..dcf70706a 100644 --- a/test-suite/generated-src/cpp/extern_interface_2.hpp +++ b/test-suite/generated-src/cpp/extern_interface_2.hpp @@ -38,7 +38,7 @@ class ExternInterface2 { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBExternInterface2"; } + virtual const std::string objcProxyClassName() { return "DBExternInterface2"; } virtual ExternRecordWithDerivings foo(const std::shared_ptr<::testsuite::TestHelpers> & i) = 0; }; diff --git a/test-suite/generated-src/cpp/first_listener.hpp b/test-suite/generated-src/cpp/first_listener.hpp index 38c002b0e..3f14441cb 100644 --- a/test-suite/generated-src/cpp/first_listener.hpp +++ b/test-suite/generated-src/cpp/first_listener.hpp @@ -37,7 +37,7 @@ class FirstListener { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBFirstListener"; } + virtual const std::string objcProxyClassName() { return "DBFirstListener"; } virtual void first() = 0; }; diff --git a/test-suite/generated-src/cpp/interface_encapsulator.hpp b/test-suite/generated-src/cpp/interface_encapsulator.hpp new file mode 100644 index 000000000..04b3a24d5 --- /dev/null +++ b/test-suite/generated-src/cpp/interface_encapsulator.hpp @@ -0,0 +1,65 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#pragma once + +#include +#include + +namespace testsuite { + +class BaseCppInterfaceInheritance; +class BaseObjcJavaInterfaceInheritance; +class SubObjcJavaInterfaceInheritance; + +class InterfaceEncapsulator { +public: + virtual ~InterfaceEncapsulator() {} + + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/InterfaceEncapsulator$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcProxyClassName() { return "DBInterfaceEncapsulator"; } + + virtual void set_cpp_object(const std::shared_ptr & object) = 0; + + virtual std::shared_ptr get_cpp_object() = 0; + + virtual std::shared_ptr sub_cpp_as_base_cpp() = 0; + + virtual void set_objc_java_object(const std::shared_ptr & object) = 0; + + virtual std::shared_ptr get_objc_java_object() = 0; + + /** + * Takes a sub interface object through a base interface argument, then cast the argument back to + * the sub interface. Returning null signifies failure. + */ + virtual std::shared_ptr cast_base_arg_to_sub(const std::shared_ptr & subAsBase) = 0; + + static std::shared_ptr create(); +}; + +} // namespace testsuite diff --git a/test-suite/generated-src/cpp/interface_inheritance_constant.cpp b/test-suite/generated-src/cpp/interface_inheritance_constant.cpp new file mode 100644 index 000000000..1cdc18e99 --- /dev/null +++ b/test-suite/generated-src/cpp/interface_inheritance_constant.cpp @@ -0,0 +1,16 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "interface_inheritance_constant.hpp" // my header + +namespace testsuite { + +std::string const InterfaceInheritanceConstant::BASE_METHOD_RETURN_VALUE = {"base_method"}; + +std::string const InterfaceInheritanceConstant::BASE_OVERRIDE_METHOD_RETURN_VALUE = {"override_method"}; + +std::string const InterfaceInheritanceConstant::SUB_METHOD_RETURN_VALUE = {"sub_method"}; + +std::string const InterfaceInheritanceConstant::SUB_OVERRIDE_METHOD_RETURN_VALUE = {"sub_override_method"}; + +} // namespace testsuite diff --git a/test-suite/generated-src/cpp/interface_inheritance_constant.hpp b/test-suite/generated-src/cpp/interface_inheritance_constant.hpp new file mode 100644 index 000000000..0c33cd1e4 --- /dev/null +++ b/test-suite/generated-src/cpp/interface_inheritance_constant.hpp @@ -0,0 +1,50 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#pragma once + +#include + +namespace testsuite { + +class InterfaceInheritanceConstant { +public: + virtual ~InterfaceInheritanceConstant() {} + + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/InterfaceInheritanceConstant$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcProxyClassName() { return "DBInterfaceInheritanceConstantCppProxy"; } + + static std::string const BASE_METHOD_RETURN_VALUE; + + static std::string const BASE_OVERRIDE_METHOD_RETURN_VALUE; + + static std::string const SUB_METHOD_RETURN_VALUE; + + static std::string const SUB_OVERRIDE_METHOD_RETURN_VALUE; +}; + +} // namespace testsuite diff --git a/test-suite/generated-src/cpp/java_only_listener.hpp b/test-suite/generated-src/cpp/java_only_listener.hpp index 3533a5b69..474d87349 100644 --- a/test-suite/generated-src/cpp/java_only_listener.hpp +++ b/test-suite/generated-src/cpp/java_only_listener.hpp @@ -36,7 +36,7 @@ class JavaOnlyListener { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBJavaOnlyListener"; } + virtual const std::string objcProxyClassName() { return "DBJavaOnlyListener"; } }; } // namespace testsuite diff --git a/test-suite/generated-src/cpp/listener_caller.hpp b/test-suite/generated-src/cpp/listener_caller.hpp index 38588c372..fdccf41d5 100644 --- a/test-suite/generated-src/cpp/listener_caller.hpp +++ b/test-suite/generated-src/cpp/listener_caller.hpp @@ -46,7 +46,7 @@ class ListenerCaller { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBListenerCaller"; } + virtual const std::string objcProxyClassName() { return "DBListenerCaller"; } static std::shared_ptr init(const std::shared_ptr & first_l, const std::shared_ptr & second_l); diff --git a/test-suite/generated-src/cpp/objc_only_listener.hpp b/test-suite/generated-src/cpp/objc_only_listener.hpp index 365a67f53..a0c0d6e99 100644 --- a/test-suite/generated-src/cpp/objc_only_listener.hpp +++ b/test-suite/generated-src/cpp/objc_only_listener.hpp @@ -36,7 +36,7 @@ class ObjcOnlyListener { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBObjcOnlyListener"; } + virtual const std::string objcProxyClassName() { return "DBObjcOnlyListener"; } }; } // namespace testsuite diff --git a/test-suite/generated-src/cpp/return_one.hpp b/test-suite/generated-src/cpp/return_one.hpp index 10cf1129f..ea0b25e8e 100644 --- a/test-suite/generated-src/cpp/return_one.hpp +++ b/test-suite/generated-src/cpp/return_one.hpp @@ -39,7 +39,7 @@ class ReturnOne { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBReturnOne"; } + virtual const std::string objcProxyClassName() { return "DBReturnOne"; } static std::shared_ptr get_instance(); diff --git a/test-suite/generated-src/cpp/return_two.hpp b/test-suite/generated-src/cpp/return_two.hpp index 8051eaa7f..1f9773feb 100644 --- a/test-suite/generated-src/cpp/return_two.hpp +++ b/test-suite/generated-src/cpp/return_two.hpp @@ -39,7 +39,7 @@ class ReturnTwo { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBReturnTwo"; } + virtual const std::string objcProxyClassName() { return "DBReturnTwo"; } static std::shared_ptr get_instance(); diff --git a/test-suite/generated-src/cpp/reverse_client_interface.hpp b/test-suite/generated-src/cpp/reverse_client_interface.hpp index f75c616ad..031bc5cf2 100644 --- a/test-suite/generated-src/cpp/reverse_client_interface.hpp +++ b/test-suite/generated-src/cpp/reverse_client_interface.hpp @@ -38,7 +38,7 @@ class ReverseClientInterface { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBReverseClientInterface"; } + virtual const std::string objcProxyClassName() { return "DBReverseClientInterface"; } virtual std::string return_str() const = 0; diff --git a/test-suite/generated-src/cpp/second_listener.hpp b/test-suite/generated-src/cpp/second_listener.hpp index d05581463..3f9d9b3a2 100644 --- a/test-suite/generated-src/cpp/second_listener.hpp +++ b/test-suite/generated-src/cpp/second_listener.hpp @@ -37,7 +37,7 @@ class SecondListener { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBSecondListener"; } + virtual const std::string objcProxyClassName() { return "DBSecondListener"; } virtual void second() = 0; }; diff --git a/test-suite/generated-src/cpp/sub_cpp_interface_inheritance.hpp b/test-suite/generated-src/cpp/sub_cpp_interface_inheritance.hpp new file mode 100644 index 000000000..0bcf7edf1 --- /dev/null +++ b/test-suite/generated-src/cpp/sub_cpp_interface_inheritance.hpp @@ -0,0 +1,48 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#pragma once + +#include "base_cpp_interface_inheritance.hpp" +#include +#include + +namespace testsuite { + +class SubCppInterfaceInheritance : public BaseCppInterfaceInheritance { +public: + virtual ~SubCppInterfaceInheritance() {} + + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return "com/dropbox/djinni/test/SubCppInterfaceInheritance$CppProxy"; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcProxyClassName() { return "DBSubCppInterfaceInheritance"; } + + virtual std::string sub_method() = 0; + + static std::shared_ptr create(); +}; + +} // namespace testsuite diff --git a/test-suite/generated-src/cpp/sub_objc_java_interface_inheritance.hpp b/test-suite/generated-src/cpp/sub_objc_java_interface_inheritance.hpp new file mode 100644 index 000000000..b70c52d35 --- /dev/null +++ b/test-suite/generated-src/cpp/sub_objc_java_interface_inheritance.hpp @@ -0,0 +1,45 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#pragma once + +#include "base_objc_java_interface_inheritance.hpp" +#include + +namespace testsuite { + +class SubObjcJavaInterfaceInheritance : public BaseObjcJavaInterfaceInheritance { +public: + virtual ~SubObjcJavaInterfaceInheritance() {} + + /** + * Defines the name of the JNI C++ proxy class. Used to convert a + * C++ implemented object to a Java object when the type of the object being + * converted is unknown to the JniInterface (see djinni_support.hpp). + * + * The proxy class name is only used for converting Djinni interfaces that + * are implemented in C++. Java implemented interfaces are converted differently. + * However, the C++ class of an interface implemented in Java must still have a + * jniProxyClassName method in order for Djinni's JniInterface::fromCpp method to compile. + * + * @return The name of the class's associated JNI proxy class. + * + * @see JniInterface in djinni_support.hpp + */ + virtual const std::string jniProxyClassName() { return nullptr; } + + /** + * Defines the name of the Objective-C type for the class. Used to convert a + * C++ object to an Objective-C object when the type of the object being + * converted is unknown to the C++ wrapper cache (see DJICppWrapperCache+Private.hpp). + * + * @return The name of the Objective C type associated with the class. + * + * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp + */ + virtual const std::string objcProxyClassName() { return "DBSubObjcJavaInterfaceInheritance"; } + + virtual std::string sub_method() = 0; +}; + +} // namespace testsuite diff --git a/test-suite/generated-src/cpp/test_duration.hpp b/test-suite/generated-src/cpp/test_duration.hpp index 55d0241ac..e6e36b4df 100644 --- a/test-suite/generated-src/cpp/test_duration.hpp +++ b/test-suite/generated-src/cpp/test_duration.hpp @@ -39,7 +39,7 @@ class TestDuration { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBTestDuration"; } + virtual const std::string objcProxyClassName() { return "DBTestDuration"; } static std::string hoursString(std::chrono::duration> dt); diff --git a/test-suite/generated-src/cpp/test_helpers.hpp b/test-suite/generated-src/cpp/test_helpers.hpp index ee54b2a73..031c54dbd 100644 --- a/test-suite/generated-src/cpp/test_helpers.hpp +++ b/test-suite/generated-src/cpp/test_helpers.hpp @@ -55,7 +55,7 @@ class TestHelpers { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBTestHelpers"; } + virtual const std::string objcProxyClassName() { return "DBTestHelpers"; } /** Method with documentation */ static SetRecord get_set_record(); diff --git a/test-suite/generated-src/cpp/user_token.hpp b/test-suite/generated-src/cpp/user_token.hpp index 4b135f950..4266ce254 100644 --- a/test-suite/generated-src/cpp/user_token.hpp +++ b/test-suite/generated-src/cpp/user_token.hpp @@ -36,7 +36,7 @@ class UserToken { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBUserToken"; } + virtual const std::string objcProxyClassName() { return "DBUserTokenCppProxy"; } virtual std::string whoami() = 0; }; diff --git a/test-suite/generated-src/cpp/uses_single_language_listeners.hpp b/test-suite/generated-src/cpp/uses_single_language_listeners.hpp index 9cf704ad8..cf475b7e3 100644 --- a/test-suite/generated-src/cpp/uses_single_language_listeners.hpp +++ b/test-suite/generated-src/cpp/uses_single_language_listeners.hpp @@ -44,7 +44,7 @@ class UsesSingleLanguageListeners { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBUsesSingleLanguageListeners"; } + virtual const std::string objcProxyClassName() { return "DBUsesSingleLanguageListenersCppProxy"; } virtual void callForObjC(const std::shared_ptr & l) = 0; diff --git a/test-suite/generated-src/cpp/wchar_test_helpers.hpp b/test-suite/generated-src/cpp/wchar_test_helpers.hpp index 0120e3160..04a750f34 100644 --- a/test-suite/generated-src/cpp/wchar_test_helpers.hpp +++ b/test-suite/generated-src/cpp/wchar_test_helpers.hpp @@ -38,7 +38,7 @@ class WcharTestHelpers { * * @see get_cpp_proxy function in DJICppWrapperCache+Private.hpp */ - virtual const std::string objcTypeName() { return "DBWcharTestHelpers"; } + virtual const std::string objcProxyClassName() { return "DBWcharTestHelpers"; } static WcharTestRec get_record(); diff --git a/test-suite/generated-src/inFileList.txt b/test-suite/generated-src/inFileList.txt index f69dd259e..54b57e1b0 100644 --- a/test-suite/generated-src/inFileList.txt +++ b/test-suite/generated-src/inFileList.txt @@ -1,22 +1,23 @@ djinni/all.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/common.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/set.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/derivings.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/nested_collection.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/map.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/primitive_list.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/exception.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/client_interface.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/enum.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/user_token.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/test.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/primtypes.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/constants.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/multiple_inheritance.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/single_language_interfaces.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/extended_record.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/varnames.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/date.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/date.yaml -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/duration.djinni -/Users/mfoster/Workspace/Aspen/public.djinni/test-suite/djinni/duration.yaml +djinni/common.djinni +djinni/set.djinni +djinni/derivings.djinni +djinni/nested_collection.djinni +djinni/map.djinni +djinni/primitive_list.djinni +djinni/exception.djinni +djinni/client_interface.djinni +djinni/enum.djinni +djinni/user_token.djinni +djinni/test.djinni +djinni/primtypes.djinni +djinni/constants.djinni +djinni/multiple_inheritance.djinni +djinni/single_language_interfaces.djinni +djinni/extended_record.djinni +djinni/varnames.djinni +djinni/interface_inheritance.djinni +djinni/date.djinni +djinni/date.yaml +djinni/duration.djinni +djinni/duration.yaml diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/BaseCppInterfaceInheritance.java b/test-suite/generated-src/java/com/dropbox/djinni/test/BaseCppInterfaceInheritance.java new file mode 100644 index 000000000..108e65804 --- /dev/null +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/BaseCppInterfaceInheritance.java @@ -0,0 +1,61 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +package com.dropbox.djinni.test; + +import java.util.concurrent.atomic.AtomicBoolean; +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +public abstract class BaseCppInterfaceInheritance { + @Nonnull + public abstract String baseMethod(); + + @Nonnull + public abstract String overrideMethod(); + + @CheckForNull + public static native BaseCppInterfaceInheritance create(); + + private static final class CppProxy extends BaseCppInterfaceInheritance + { + 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(); + } + + // BaseCppInterfaceInheritance methods + + @Override + public String baseMethod() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_baseMethod(this.nativeRef); + } + private native String native_baseMethod(long _nativeRef); + + @Override + public String overrideMethod() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_overrideMethod(this.nativeRef); + } + private native String native_overrideMethod(long _nativeRef); + } +} diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/BaseObjcJavaInterfaceInheritance.java b/test-suite/generated-src/java/com/dropbox/djinni/test/BaseObjcJavaInterfaceInheritance.java new file mode 100644 index 000000000..9a1b240eb --- /dev/null +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/BaseObjcJavaInterfaceInheritance.java @@ -0,0 +1,15 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +package com.dropbox.djinni.test; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +public abstract class BaseObjcJavaInterfaceInheritance { + @Nonnull + public abstract String baseMethod(); + + @Nonnull + public abstract String overrideMethod(); +} diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/InterfaceEncapsulator.java b/test-suite/generated-src/java/com/dropbox/djinni/test/InterfaceEncapsulator.java new file mode 100644 index 000000000..4e3c16c13 --- /dev/null +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/InterfaceEncapsulator.java @@ -0,0 +1,107 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +package com.dropbox.djinni.test; + +import java.util.concurrent.atomic.AtomicBoolean; +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +public abstract class InterfaceEncapsulator { + public abstract void setCppObject(@CheckForNull BaseCppInterfaceInheritance object); + + @CheckForNull + public abstract BaseCppInterfaceInheritance getCppObject(); + + @CheckForNull + public abstract BaseCppInterfaceInheritance subCppAsBaseCpp(); + + public abstract void setObjcJavaObject(@CheckForNull BaseObjcJavaInterfaceInheritance object); + + @CheckForNull + public abstract BaseObjcJavaInterfaceInheritance getObjcJavaObject(); + + /** + * Takes a sub interface object through a base interface argument, then cast the argument back to + * the sub interface. Returning null signifies failure. + */ + @CheckForNull + public abstract SubObjcJavaInterfaceInheritance castBaseArgToSub(@CheckForNull BaseObjcJavaInterfaceInheritance subAsBase); + + @CheckForNull + public static native InterfaceEncapsulator create(); + + private static final class CppProxy extends InterfaceEncapsulator + { + 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(); + } + + // InterfaceEncapsulator methods + + @Override + public void setCppObject(BaseCppInterfaceInheritance object) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + native_setCppObject(this.nativeRef, object); + } + private native void native_setCppObject(long _nativeRef, BaseCppInterfaceInheritance object); + + @Override + public BaseCppInterfaceInheritance getCppObject() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_getCppObject(this.nativeRef); + } + private native BaseCppInterfaceInheritance native_getCppObject(long _nativeRef); + + @Override + public BaseCppInterfaceInheritance subCppAsBaseCpp() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_subCppAsBaseCpp(this.nativeRef); + } + private native BaseCppInterfaceInheritance native_subCppAsBaseCpp(long _nativeRef); + + @Override + public void setObjcJavaObject(BaseObjcJavaInterfaceInheritance object) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + native_setObjcJavaObject(this.nativeRef, object); + } + private native void native_setObjcJavaObject(long _nativeRef, BaseObjcJavaInterfaceInheritance object); + + @Override + public BaseObjcJavaInterfaceInheritance getObjcJavaObject() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_getObjcJavaObject(this.nativeRef); + } + private native BaseObjcJavaInterfaceInheritance native_getObjcJavaObject(long _nativeRef); + + @Override + public SubObjcJavaInterfaceInheritance castBaseArgToSub(BaseObjcJavaInterfaceInheritance subAsBase) + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_castBaseArgToSub(this.nativeRef, subAsBase); + } + private native SubObjcJavaInterfaceInheritance native_castBaseArgToSub(long _nativeRef, BaseObjcJavaInterfaceInheritance subAsBase); + } +} diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/InterfaceInheritanceConstant.java b/test-suite/generated-src/java/com/dropbox/djinni/test/InterfaceInheritanceConstant.java new file mode 100644 index 000000000..7f71d1367 --- /dev/null +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/InterfaceInheritanceConstant.java @@ -0,0 +1,49 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +package com.dropbox.djinni.test; + +import java.util.concurrent.atomic.AtomicBoolean; +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +public abstract class InterfaceInheritanceConstant { + @Nonnull + public static final String BASE_METHOD_RETURN_VALUE = "base_method"; + + @Nonnull + public static final String BASE_OVERRIDE_METHOD_RETURN_VALUE = "override_method"; + + @Nonnull + public static final String SUB_METHOD_RETURN_VALUE = "sub_method"; + + @Nonnull + public static final String SUB_OVERRIDE_METHOD_RETURN_VALUE = "sub_override_method"; + + + private static final class CppProxy extends InterfaceInheritanceConstant + { + 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(); + } + + // InterfaceInheritanceConstant methods + } +} diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/SubCppInterfaceInheritance.java b/test-suite/generated-src/java/com/dropbox/djinni/test/SubCppInterfaceInheritance.java new file mode 100644 index 000000000..788b2f75f --- /dev/null +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/SubCppInterfaceInheritance.java @@ -0,0 +1,68 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +package com.dropbox.djinni.test; + +import java.util.concurrent.atomic.AtomicBoolean; +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +public abstract class SubCppInterfaceInheritance extends BaseCppInterfaceInheritance { + @Nonnull + public abstract String subMethod(); + + @CheckForNull + public static native SubCppInterfaceInheritance create(); + + private static final class CppProxy extends SubCppInterfaceInheritance + { + 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(); + } + + // SubCppInterfaceInheritance methods + + @Override + public String subMethod() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_subMethod(this.nativeRef); + } + private native String native_subMethod(long _nativeRef); + + // BaseCppInterfaceInheritance methods + + @Override + public String baseMethod() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_baseMethod(this.nativeRef); + } + private native String native_baseMethod(long _nativeRef); + + @Override + public String overrideMethod() + { + assert !this.destroyed.get() : "trying to use a destroyed object"; + return native_overrideMethod(this.nativeRef); + } + private native String native_overrideMethod(long _nativeRef); + } +} diff --git a/test-suite/generated-src/java/com/dropbox/djinni/test/SubObjcJavaInterfaceInheritance.java b/test-suite/generated-src/java/com/dropbox/djinni/test/SubObjcJavaInterfaceInheritance.java new file mode 100644 index 000000000..e4a499e5f --- /dev/null +++ b/test-suite/generated-src/java/com/dropbox/djinni/test/SubObjcJavaInterfaceInheritance.java @@ -0,0 +1,12 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +package com.dropbox.djinni.test; + +import javax.annotation.CheckForNull; +import javax.annotation.Nonnull; + +public abstract class SubObjcJavaInterfaceInheritance extends BaseObjcJavaInterfaceInheritance { + @Nonnull + public abstract String subMethod(); +} diff --git a/test-suite/generated-src/jni/NativeBaseCppInterfaceInheritance.cpp b/test-suite/generated-src/jni/NativeBaseCppInterfaceInheritance.cpp new file mode 100644 index 000000000..862f81a29 --- /dev/null +++ b/test-suite/generated-src/jni/NativeBaseCppInterfaceInheritance.cpp @@ -0,0 +1,51 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "NativeBaseCppInterfaceInheritance.hpp" // my header +#include "Marshal.hpp" + +namespace djinni_generated { + +NativeBaseCppInterfaceInheritance::NativeBaseCppInterfaceInheritance() : ::djinni::JniInterface<::testsuite::BaseCppInterfaceInheritance, NativeBaseCppInterfaceInheritance>("com/dropbox/djinni/test/BaseCppInterfaceInheritance$CppProxy") {} + +NativeBaseCppInterfaceInheritance::~NativeBaseCppInterfaceInheritance() = default; + + +CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_BaseCppInterfaceInheritance_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + delete reinterpret_cast<::djinni::CppProxyHandle<::testsuite::BaseCppInterfaceInheritance>*>(nativeRef); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jstring JNICALL Java_com_dropbox_djinni_test_BaseCppInterfaceInheritance_00024CppProxy_native_1baseMethod(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::BaseCppInterfaceInheritance>(nativeRef); + auto r = ref->base_method(); + 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_BaseCppInterfaceInheritance_00024CppProxy_native_1overrideMethod(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::BaseCppInterfaceInheritance>(nativeRef); + auto r = ref->override_method(); + 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_BaseCppInterfaceInheritance_create(JNIEnv* jniEnv, jobject /*this*/) +{ + try { + DJINNI_FUNCTION_PROLOGUE0(jniEnv); + auto r = ::testsuite::BaseCppInterfaceInheritance::create(); + return ::djinni::release(::djinni_generated::NativeBaseCppInterfaceInheritance::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeBaseCppInterfaceInheritance.hpp b/test-suite/generated-src/jni/NativeBaseCppInterfaceInheritance.hpp new file mode 100644 index 000000000..48d5d02c4 --- /dev/null +++ b/test-suite/generated-src/jni/NativeBaseCppInterfaceInheritance.hpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#pragma once + +#include "base_cpp_interface_inheritance.hpp" +#include "djinni_support.hpp" + +namespace djinni_generated { + +class NativeBaseCppInterfaceInheritance final : ::djinni::JniInterface<::testsuite::BaseCppInterfaceInheritance, NativeBaseCppInterfaceInheritance> { +public: + using CppType = std::shared_ptr<::testsuite::BaseCppInterfaceInheritance>; + using CppOptType = std::shared_ptr<::testsuite::BaseCppInterfaceInheritance>; + using JniType = jobject; + + using Boxed = NativeBaseCppInterfaceInheritance; + + ~NativeBaseCppInterfaceInheritance(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeBaseCppInterfaceInheritance(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::testsuite::BaseCppInterfaceInheritance, NativeBaseCppInterfaceInheritance>; + +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeBaseObjcJavaInterfaceInheritance.cpp b/test-suite/generated-src/jni/NativeBaseObjcJavaInterfaceInheritance.cpp new file mode 100644 index 000000000..15ef025b4 --- /dev/null +++ b/test-suite/generated-src/jni/NativeBaseObjcJavaInterfaceInheritance.cpp @@ -0,0 +1,34 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "NativeBaseObjcJavaInterfaceInheritance.hpp" // my header +#include "Marshal.hpp" + +namespace djinni_generated { + +NativeBaseObjcJavaInterfaceInheritance::NativeBaseObjcJavaInterfaceInheritance() : ::djinni::JniInterface<::testsuite::BaseObjcJavaInterfaceInheritance, NativeBaseObjcJavaInterfaceInheritance>() {} + +NativeBaseObjcJavaInterfaceInheritance::~NativeBaseObjcJavaInterfaceInheritance() = default; + +NativeBaseObjcJavaInterfaceInheritance::JavaProxy::JavaProxy(JniType j) : Handle(::djinni::jniGetThreadEnv(), j) { } + +NativeBaseObjcJavaInterfaceInheritance::JavaProxy::~JavaProxy() = default; + +std::string NativeBaseObjcJavaInterfaceInheritance::JavaProxy::base_method() { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeBaseObjcJavaInterfaceInheritance>::get(); + auto jret = (jstring)jniEnv->CallObjectMethod(Handle::get().get(), data.method_baseMethod); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni::String::toCpp(jniEnv, jret); +} +std::string NativeBaseObjcJavaInterfaceInheritance::JavaProxy::override_method() { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeBaseObjcJavaInterfaceInheritance>::get(); + auto jret = (jstring)jniEnv->CallObjectMethod(Handle::get().get(), data.method_overrideMethod); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni::String::toCpp(jniEnv, jret); +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeBaseObjcJavaInterfaceInheritance.hpp b/test-suite/generated-src/jni/NativeBaseObjcJavaInterfaceInheritance.hpp new file mode 100644 index 000000000..7889de98f --- /dev/null +++ b/test-suite/generated-src/jni/NativeBaseObjcJavaInterfaceInheritance.hpp @@ -0,0 +1,48 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#pragma once + +#include "base_objc_java_interface_inheritance.hpp" +#include "djinni_support.hpp" + +namespace djinni_generated { + +class NativeBaseObjcJavaInterfaceInheritance final : ::djinni::JniInterface<::testsuite::BaseObjcJavaInterfaceInheritance, NativeBaseObjcJavaInterfaceInheritance> { +public: + using CppType = std::shared_ptr<::testsuite::BaseObjcJavaInterfaceInheritance>; + using CppOptType = std::shared_ptr<::testsuite::BaseObjcJavaInterfaceInheritance>; + using JniType = jobject; + + using Boxed = NativeBaseObjcJavaInterfaceInheritance; + + ~NativeBaseObjcJavaInterfaceInheritance(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeBaseObjcJavaInterfaceInheritance(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::testsuite::BaseObjcJavaInterfaceInheritance, NativeBaseObjcJavaInterfaceInheritance>; + + class JavaProxy final : ::djinni::JavaProxyHandle, public ::testsuite::BaseObjcJavaInterfaceInheritance + { + public: + JavaProxy(JniType j); + ~JavaProxy(); + + std::string base_method() override; + std::string override_method() override; + + private: + friend ::djinni::JniInterface<::testsuite::BaseObjcJavaInterfaceInheritance, ::djinni_generated::NativeBaseObjcJavaInterfaceInheritance>; + }; + + const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/BaseObjcJavaInterfaceInheritance") }; + const jmethodID method_baseMethod { ::djinni::jniGetMethodID(clazz.get(), "baseMethod", "()Ljava/lang/String;") }; + const jmethodID method_overrideMethod { ::djinni::jniGetMethodID(clazz.get(), "overrideMethod", "()Ljava/lang/String;") }; +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeInterfaceEncapsulator.cpp b/test-suite/generated-src/jni/NativeInterfaceEncapsulator.cpp new file mode 100644 index 000000000..7608a5f1d --- /dev/null +++ b/test-suite/generated-src/jni/NativeInterfaceEncapsulator.cpp @@ -0,0 +1,91 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "NativeInterfaceEncapsulator.hpp" // my header +#include "NativeBaseCppInterfaceInheritance.hpp" +#include "NativeBaseObjcJavaInterfaceInheritance.hpp" +#include "NativeSubObjcJavaInterfaceInheritance.hpp" + +namespace djinni_generated { + +NativeInterfaceEncapsulator::NativeInterfaceEncapsulator() : ::djinni::JniInterface<::testsuite::InterfaceEncapsulator, NativeInterfaceEncapsulator>("com/dropbox/djinni/test/InterfaceEncapsulator$CppProxy") {} + +NativeInterfaceEncapsulator::~NativeInterfaceEncapsulator() = default; + + +CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_InterfaceEncapsulator_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + delete reinterpret_cast<::djinni::CppProxyHandle<::testsuite::InterfaceEncapsulator>*>(nativeRef); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_InterfaceEncapsulator_00024CppProxy_native_1setCppObject(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_object) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::InterfaceEncapsulator>(nativeRef); + ref->set_cpp_object(::djinni_generated::NativeBaseCppInterfaceInheritance::toCpp(jniEnv, j_object)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_InterfaceEncapsulator_00024CppProxy_native_1getCppObject(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::InterfaceEncapsulator>(nativeRef); + auto r = ref->get_cpp_object(); + return ::djinni::release(::djinni_generated::NativeBaseCppInterfaceInheritance::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_InterfaceEncapsulator_00024CppProxy_native_1subCppAsBaseCpp(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::InterfaceEncapsulator>(nativeRef); + auto r = ref->sub_cpp_as_base_cpp(); + return ::djinni::release(::djinni_generated::NativeBaseCppInterfaceInheritance::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_InterfaceEncapsulator_00024CppProxy_native_1setObjcJavaObject(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_object) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::InterfaceEncapsulator>(nativeRef); + ref->set_objc_java_object(::djinni_generated::NativeBaseObjcJavaInterfaceInheritance::toCpp(jniEnv, j_object)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_InterfaceEncapsulator_00024CppProxy_native_1getObjcJavaObject(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::InterfaceEncapsulator>(nativeRef); + auto r = ref->get_objc_java_object(); + return ::djinni::release(::djinni_generated::NativeBaseObjcJavaInterfaceInheritance::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_InterfaceEncapsulator_00024CppProxy_native_1castBaseArgToSub(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_subAsBase) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::InterfaceEncapsulator>(nativeRef); + auto r = ref->cast_base_arg_to_sub(::djinni_generated::NativeBaseObjcJavaInterfaceInheritance::toCpp(jniEnv, j_subAsBase)); + return ::djinni::release(::djinni_generated::NativeSubObjcJavaInterfaceInheritance::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_InterfaceEncapsulator_create(JNIEnv* jniEnv, jobject /*this*/) +{ + try { + DJINNI_FUNCTION_PROLOGUE0(jniEnv); + auto r = ::testsuite::InterfaceEncapsulator::create(); + return ::djinni::release(::djinni_generated::NativeInterfaceEncapsulator::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeInterfaceEncapsulator.hpp b/test-suite/generated-src/jni/NativeInterfaceEncapsulator.hpp new file mode 100644 index 000000000..3615c2fca --- /dev/null +++ b/test-suite/generated-src/jni/NativeInterfaceEncapsulator.hpp @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "interface_encapsulator.hpp" + +namespace djinni_generated { + +class NativeInterfaceEncapsulator final : ::djinni::JniInterface<::testsuite::InterfaceEncapsulator, NativeInterfaceEncapsulator> { +public: + using CppType = std::shared_ptr<::testsuite::InterfaceEncapsulator>; + using CppOptType = std::shared_ptr<::testsuite::InterfaceEncapsulator>; + using JniType = jobject; + + using Boxed = NativeInterfaceEncapsulator; + + ~NativeInterfaceEncapsulator(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeInterfaceEncapsulator(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::testsuite::InterfaceEncapsulator, NativeInterfaceEncapsulator>; + +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeInterfaceInheritanceConstant.cpp b/test-suite/generated-src/jni/NativeInterfaceInheritanceConstant.cpp new file mode 100644 index 000000000..92cab3445 --- /dev/null +++ b/test-suite/generated-src/jni/NativeInterfaceInheritanceConstant.cpp @@ -0,0 +1,26 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "NativeInterfaceInheritanceConstant.hpp" // my header +#include "Marshal.hpp" + +namespace djinni_generated { + +NativeInterfaceInheritanceConstant::NativeInterfaceInheritanceConstant() : ::djinni::JniInterface<::testsuite::InterfaceInheritanceConstant, NativeInterfaceInheritanceConstant>("com/dropbox/djinni/test/InterfaceInheritanceConstant$CppProxy") {} + +NativeInterfaceInheritanceConstant::~NativeInterfaceInheritanceConstant() = default; + +NativeInterfaceInheritanceConstant::JavaProxy::JavaProxy(JniType j) : Handle(::djinni::jniGetThreadEnv(), j) { } + +NativeInterfaceInheritanceConstant::JavaProxy::~JavaProxy() = default; + + +CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_InterfaceInheritanceConstant_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + delete reinterpret_cast<::djinni::CppProxyHandle<::testsuite::InterfaceInheritanceConstant>*>(nativeRef); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeInterfaceInheritanceConstant.hpp b/test-suite/generated-src/jni/NativeInterfaceInheritanceConstant.hpp new file mode 100644 index 000000000..7edb1b60d --- /dev/null +++ b/test-suite/generated-src/jni/NativeInterfaceInheritanceConstant.hpp @@ -0,0 +1,44 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#pragma once + +#include "djinni_support.hpp" +#include "interface_inheritance_constant.hpp" + +namespace djinni_generated { + +class NativeInterfaceInheritanceConstant final : ::djinni::JniInterface<::testsuite::InterfaceInheritanceConstant, NativeInterfaceInheritanceConstant> { +public: + using CppType = std::shared_ptr<::testsuite::InterfaceInheritanceConstant>; + using CppOptType = std::shared_ptr<::testsuite::InterfaceInheritanceConstant>; + using JniType = jobject; + + using Boxed = NativeInterfaceInheritanceConstant; + + ~NativeInterfaceInheritanceConstant(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeInterfaceInheritanceConstant(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::testsuite::InterfaceInheritanceConstant, NativeInterfaceInheritanceConstant>; + + class JavaProxy final : ::djinni::JavaProxyHandle, public ::testsuite::InterfaceInheritanceConstant + { + public: + JavaProxy(JniType j); + ~JavaProxy(); + + + private: + friend ::djinni::JniInterface<::testsuite::InterfaceInheritanceConstant, ::djinni_generated::NativeInterfaceInheritanceConstant>; + }; + + const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/InterfaceInheritanceConstant") }; +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeSubCppInterfaceInheritance.cpp b/test-suite/generated-src/jni/NativeSubCppInterfaceInheritance.cpp new file mode 100644 index 000000000..154942274 --- /dev/null +++ b/test-suite/generated-src/jni/NativeSubCppInterfaceInheritance.cpp @@ -0,0 +1,61 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "NativeSubCppInterfaceInheritance.hpp" // my header +#include "Marshal.hpp" + +namespace djinni_generated { + +NativeSubCppInterfaceInheritance::NativeSubCppInterfaceInheritance() : ::djinni::JniInterface<::testsuite::SubCppInterfaceInheritance, NativeSubCppInterfaceInheritance>("com/dropbox/djinni/test/SubCppInterfaceInheritance$CppProxy") {} + +NativeSubCppInterfaceInheritance::~NativeSubCppInterfaceInheritance() = default; + + +CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_SubCppInterfaceInheritance_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + delete reinterpret_cast<::djinni::CppProxyHandle<::testsuite::SubCppInterfaceInheritance>*>(nativeRef); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jstring JNICALL Java_com_dropbox_djinni_test_SubCppInterfaceInheritance_00024CppProxy_native_1baseMethod(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::SubCppInterfaceInheritance>(nativeRef); + auto r = ref->base_method(); + 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_SubCppInterfaceInheritance_00024CppProxy_native_1overrideMethod(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::SubCppInterfaceInheritance>(nativeRef); + auto r = ref->override_method(); + 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_SubCppInterfaceInheritance_00024CppProxy_native_1subMethod(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); + const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::SubCppInterfaceInheritance>(nativeRef); + auto r = ref->sub_method(); + 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_SubCppInterfaceInheritance_create(JNIEnv* jniEnv, jobject /*this*/) +{ + try { + DJINNI_FUNCTION_PROLOGUE0(jniEnv); + auto r = ::testsuite::SubCppInterfaceInheritance::create(); + return ::djinni::release(::djinni_generated::NativeSubCppInterfaceInheritance::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeSubCppInterfaceInheritance.hpp b/test-suite/generated-src/jni/NativeSubCppInterfaceInheritance.hpp new file mode 100644 index 000000000..046849d7e --- /dev/null +++ b/test-suite/generated-src/jni/NativeSubCppInterfaceInheritance.hpp @@ -0,0 +1,33 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#pragma once + +#include "NativeBaseCppInterfaceInheritance.hpp" +#include "djinni_support.hpp" +#include "sub_cpp_interface_inheritance.hpp" + +namespace djinni_generated { + +class NativeSubCppInterfaceInheritance final : ::djinni::JniInterface<::testsuite::SubCppInterfaceInheritance, NativeSubCppInterfaceInheritance> { +public: + using CppType = std::shared_ptr<::testsuite::SubCppInterfaceInheritance>; + using CppOptType = std::shared_ptr<::testsuite::SubCppInterfaceInheritance>; + using JniType = jobject; + + using Boxed = NativeSubCppInterfaceInheritance; + + ~NativeSubCppInterfaceInheritance(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeSubCppInterfaceInheritance(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::testsuite::SubCppInterfaceInheritance, NativeSubCppInterfaceInheritance>; + +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeSubObjcJavaInterfaceInheritance.cpp b/test-suite/generated-src/jni/NativeSubObjcJavaInterfaceInheritance.cpp new file mode 100644 index 000000000..3f2eba23e --- /dev/null +++ b/test-suite/generated-src/jni/NativeSubObjcJavaInterfaceInheritance.cpp @@ -0,0 +1,42 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "NativeSubObjcJavaInterfaceInheritance.hpp" // my header +#include "Marshal.hpp" + +namespace djinni_generated { + +NativeSubObjcJavaInterfaceInheritance::NativeSubObjcJavaInterfaceInheritance() : ::djinni::JniInterface<::testsuite::SubObjcJavaInterfaceInheritance, NativeSubObjcJavaInterfaceInheritance>() {} + +NativeSubObjcJavaInterfaceInheritance::~NativeSubObjcJavaInterfaceInheritance() = default; + +NativeSubObjcJavaInterfaceInheritance::JavaProxy::JavaProxy(JniType j) : Handle(::djinni::jniGetThreadEnv(), j) { } + +NativeSubObjcJavaInterfaceInheritance::JavaProxy::~JavaProxy() = default; + +std::string NativeSubObjcJavaInterfaceInheritance::JavaProxy::base_method() { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeSubObjcJavaInterfaceInheritance>::get(); + auto jret = (jstring)jniEnv->CallObjectMethod(Handle::get().get(), data.method_baseMethod); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni::String::toCpp(jniEnv, jret); +} +std::string NativeSubObjcJavaInterfaceInheritance::JavaProxy::override_method() { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeSubObjcJavaInterfaceInheritance>::get(); + auto jret = (jstring)jniEnv->CallObjectMethod(Handle::get().get(), data.method_overrideMethod); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni::String::toCpp(jniEnv, jret); +} +std::string NativeSubObjcJavaInterfaceInheritance::JavaProxy::sub_method() { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeSubObjcJavaInterfaceInheritance>::get(); + auto jret = (jstring)jniEnv->CallObjectMethod(Handle::get().get(), data.method_subMethod); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni::String::toCpp(jniEnv, jret); +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/jni/NativeSubObjcJavaInterfaceInheritance.hpp b/test-suite/generated-src/jni/NativeSubObjcJavaInterfaceInheritance.hpp new file mode 100644 index 000000000..96b96b260 --- /dev/null +++ b/test-suite/generated-src/jni/NativeSubObjcJavaInterfaceInheritance.hpp @@ -0,0 +1,51 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#pragma once + +#include "NativeBaseObjcJavaInterfaceInheritance.hpp" +#include "djinni_support.hpp" +#include "sub_objc_java_interface_inheritance.hpp" + +namespace djinni_generated { + +class NativeSubObjcJavaInterfaceInheritance final : ::djinni::JniInterface<::testsuite::SubObjcJavaInterfaceInheritance, NativeSubObjcJavaInterfaceInheritance> { +public: + using CppType = std::shared_ptr<::testsuite::SubObjcJavaInterfaceInheritance>; + using CppOptType = std::shared_ptr<::testsuite::SubObjcJavaInterfaceInheritance>; + using JniType = jobject; + + using Boxed = NativeSubObjcJavaInterfaceInheritance; + + ~NativeSubObjcJavaInterfaceInheritance(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeSubObjcJavaInterfaceInheritance(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::testsuite::SubObjcJavaInterfaceInheritance, NativeSubObjcJavaInterfaceInheritance>; + + class JavaProxy final : ::djinni::JavaProxyHandle, public ::testsuite::SubObjcJavaInterfaceInheritance + { + public: + JavaProxy(JniType j); + ~JavaProxy(); + + std::string base_method() override; + std::string override_method() override; + std::string sub_method() override; + + private: + friend ::djinni::JniInterface<::testsuite::SubObjcJavaInterfaceInheritance, ::djinni_generated::NativeSubObjcJavaInterfaceInheritance>; + }; + + const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/SubObjcJavaInterfaceInheritance") }; + const jmethodID method_baseMethod { ::djinni::jniGetMethodID(clazz.get(), "baseMethod", "()Ljava/lang/String;") }; + const jmethodID method_overrideMethod { ::djinni::jniGetMethodID(clazz.get(), "overrideMethod", "()Ljava/lang/String;") }; + const jmethodID method_subMethod { ::djinni::jniGetMethodID(clazz.get(), "subMethod", "()Ljava/lang/String;") }; +}; + +} // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBBaseCppInterfaceInheritance+Private.h b/test-suite/generated-src/objc/DBBaseCppInterfaceInheritance+Private.h new file mode 100644 index 000000000..cf9c759ab --- /dev/null +++ b/test-suite/generated-src/objc/DBBaseCppInterfaceInheritance+Private.h @@ -0,0 +1,31 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "base_cpp_interface_inheritance.hpp" +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@class DBBaseCppInterfaceInheritance; + +namespace djinni_generated { + +class BaseCppInterfaceInheritance +{ +public: + using CppType = std::shared_ptr<::testsuite::BaseCppInterfaceInheritance>; + using CppOptType = std::shared_ptr<::testsuite::BaseCppInterfaceInheritance>; + using ObjcType = DBBaseCppInterfaceInheritance*; + + using Boxed = BaseCppInterfaceInheritance; + + 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 + diff --git a/test-suite/generated-src/objc/DBBaseCppInterfaceInheritance+Private.mm b/test-suite/generated-src/objc/DBBaseCppInterfaceInheritance+Private.mm new file mode 100644 index 000000000..1420f1b38 --- /dev/null +++ b/test-suite/generated-src/objc/DBBaseCppInterfaceInheritance+Private.mm @@ -0,0 +1,81 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import "DBBaseCppInterfaceInheritance+Private.h" +#import "DBBaseCppInterfaceInheritance.h" +#import "DJICppWrapperCache+Private.h" +#import "DJIError.h" +#import "DJIMarshal+Private.h" +#include +#include +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@interface DBBaseCppInterfaceInheritance () + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::BaseCppInterfaceInheritance>&)cppRef; + +@end + +@implementation DBBaseCppInterfaceInheritance { + ::djinni::CppProxyCache::Handle> _cppRefHandle; +} + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::BaseCppInterfaceInheritance>&)cppRef +{ + if (self = [super init]) { + _cppRefHandle.assign(cppRef); + } + return self; +} + +- (const std::shared_ptr<::testsuite::BaseCppInterfaceInheritance>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBBaseCppInterfaceInheritance methods + +- (nonnull NSString *)baseMethod { + try { + auto objcpp_result_ = _cppRefHandle.get()->base_method(); + return ::djinni::String::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (nonnull NSString *)overrideMethod { + try { + auto objcpp_result_ = _cppRefHandle.get()->override_method(); + return ::djinni::String::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + ++ (nullable DBBaseCppInterfaceInheritance *)create { + try { + auto objcpp_result_ = ::testsuite::BaseCppInterfaceInheritance::create(); + return ::djinni_generated::BaseCppInterfaceInheritance::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +namespace djinni_generated { + +auto BaseCppInterfaceInheritance::toCpp(ObjcType objc) -> CppType +{ + if (!objc) { + return nullptr; + } + return [objc cppRef]; +} + +auto BaseCppInterfaceInheritance::fromCppOpt(const CppOptType& cpp) -> ObjcType +{ + if (!cpp) { + return nil; + } + return ::djinni::get_cpp_proxy(cpp); +} + +} // namespace djinni_generated + +@end diff --git a/test-suite/generated-src/objc/DBBaseCppInterfaceInheritance.h b/test-suite/generated-src/objc/DBBaseCppInterfaceInheritance.h new file mode 100644 index 000000000..4ee113942 --- /dev/null +++ b/test-suite/generated-src/objc/DBBaseCppInterfaceInheritance.h @@ -0,0 +1,16 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import +@class DBBaseCppInterfaceInheritance; + + +@interface DBBaseCppInterfaceInheritance : NSObject + +- (nonnull NSString *)baseMethod; + +- (nonnull NSString *)overrideMethod; + ++ (nullable DBBaseCppInterfaceInheritance *)create; + +@end diff --git a/test-suite/generated-src/objc/DBBaseObjcJavaInterfaceInheritance+Private.h b/test-suite/generated-src/objc/DBBaseObjcJavaInterfaceInheritance+Private.h new file mode 100644 index 000000000..d6b5a828d --- /dev/null +++ b/test-suite/generated-src/objc/DBBaseObjcJavaInterfaceInheritance+Private.h @@ -0,0 +1,31 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "base_objc_java_interface_inheritance.hpp" +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@protocol DBBaseObjcJavaInterfaceInheritance; + +namespace djinni_generated { + +class BaseObjcJavaInterfaceInheritance +{ +public: + using CppType = std::shared_ptr<::testsuite::BaseObjcJavaInterfaceInheritance>; + using CppOptType = std::shared_ptr<::testsuite::BaseObjcJavaInterfaceInheritance>; + using ObjcType = id; + + using Boxed = BaseObjcJavaInterfaceInheritance; + + 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 + diff --git a/test-suite/generated-src/objc/DBBaseObjcJavaInterfaceInheritance+Private.mm b/test-suite/generated-src/objc/DBBaseObjcJavaInterfaceInheritance+Private.mm new file mode 100644 index 000000000..7a342ca14 --- /dev/null +++ b/test-suite/generated-src/objc/DBBaseObjcJavaInterfaceInheritance+Private.mm @@ -0,0 +1,58 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import "DBBaseObjcJavaInterfaceInheritance+Private.h" +#import "DBBaseObjcJavaInterfaceInheritance.h" +#import "DJIMarshal+Private.h" +#import "DJIObjcWrapperCache+Private.h" +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +namespace djinni_generated { + +class BaseObjcJavaInterfaceInheritance::ObjcProxy final +: public ::testsuite::BaseObjcJavaInterfaceInheritance +, public ::djinni::ObjcProxyCache::Handle +{ +public: + using Handle::Handle; + + // BaseObjcJavaInterfaceInheritance methods + std::string base_method() override + { + @autoreleasepool { + auto objcpp_result_ = [Handle::get() baseMethod]; + return ::djinni::String::toCpp(objcpp_result_); + } + } + std::string override_method() override + { + @autoreleasepool { + auto objcpp_result_ = [Handle::get() overrideMethod]; + return ::djinni::String::toCpp(objcpp_result_); + } + } +}; + +} // namespace djinni_generated + +namespace djinni_generated { + +auto BaseObjcJavaInterfaceInheritance::toCpp(ObjcType objc) -> CppType +{ + if (!objc) { + return nullptr; + } + return ::djinni::get_objc_proxy(objc); +} + +auto BaseObjcJavaInterfaceInheritance::fromCppOpt(const CppOptType& cpp) -> ObjcType +{ + if (!cpp) { + return nil; + } + return dynamic_cast(*cpp).Handle::get(); +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBBaseObjcJavaInterfaceInheritance.h b/test-suite/generated-src/objc/DBBaseObjcJavaInterfaceInheritance.h new file mode 100644 index 000000000..3b9c69a81 --- /dev/null +++ b/test-suite/generated-src/objc/DBBaseObjcJavaInterfaceInheritance.h @@ -0,0 +1,13 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import + + +@protocol DBBaseObjcJavaInterfaceInheritance + +- (nonnull NSString *)baseMethod; + +- (nonnull NSString *)overrideMethod; + +@end diff --git a/test-suite/generated-src/objc/DBInterfaceEncapsulator+Private.h b/test-suite/generated-src/objc/DBInterfaceEncapsulator+Private.h new file mode 100644 index 000000000..674bc403c --- /dev/null +++ b/test-suite/generated-src/objc/DBInterfaceEncapsulator+Private.h @@ -0,0 +1,31 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "interface_encapsulator.hpp" +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@class DBInterfaceEncapsulator; + +namespace djinni_generated { + +class InterfaceEncapsulator +{ +public: + using CppType = std::shared_ptr<::testsuite::InterfaceEncapsulator>; + using CppOptType = std::shared_ptr<::testsuite::InterfaceEncapsulator>; + using ObjcType = DBInterfaceEncapsulator*; + + using Boxed = InterfaceEncapsulator; + + 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 + diff --git a/test-suite/generated-src/objc/DBInterfaceEncapsulator+Private.mm b/test-suite/generated-src/objc/DBInterfaceEncapsulator+Private.mm new file mode 100644 index 000000000..be3635894 --- /dev/null +++ b/test-suite/generated-src/objc/DBInterfaceEncapsulator+Private.mm @@ -0,0 +1,109 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import "DBInterfaceEncapsulator+Private.h" +#import "DBInterfaceEncapsulator.h" +#import "DBBaseCppInterfaceInheritance+Private.h" +#import "DBBaseObjcJavaInterfaceInheritance+Private.h" +#import "DBSubObjcJavaInterfaceInheritance+Private.h" +#import "DJICppWrapperCache+Private.h" +#import "DJIError.h" +#include +#include +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@interface DBInterfaceEncapsulator () + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::InterfaceEncapsulator>&)cppRef; + +@end + +@implementation DBInterfaceEncapsulator { + ::djinni::CppProxyCache::Handle> _cppRefHandle; +} + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::InterfaceEncapsulator>&)cppRef +{ + if (self = [super init]) { + _cppRefHandle.assign(cppRef); + } + return self; +} + +- (const std::shared_ptr<::testsuite::InterfaceEncapsulator>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBInterfaceEncapsulator methods + +- (void)setCppObject:(nullable DBBaseCppInterfaceInheritance *)object { + try { + _cppRefHandle.get()->set_cpp_object(::djinni_generated::BaseCppInterfaceInheritance::toCpp(object)); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (nullable DBBaseCppInterfaceInheritance *)getCppObject { + try { + auto objcpp_result_ = _cppRefHandle.get()->get_cpp_object(); + return ::djinni_generated::BaseCppInterfaceInheritance::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (nullable DBBaseCppInterfaceInheritance *)subCppAsBaseCpp { + try { + auto objcpp_result_ = _cppRefHandle.get()->sub_cpp_as_base_cpp(); + return ::djinni_generated::BaseCppInterfaceInheritance::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (void)setObjcJavaObject:(nullable id)object { + try { + _cppRefHandle.get()->set_objc_java_object(::djinni_generated::BaseObjcJavaInterfaceInheritance::toCpp(object)); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (nullable id)getObjcJavaObject { + try { + auto objcpp_result_ = _cppRefHandle.get()->get_objc_java_object(); + return ::djinni_generated::BaseObjcJavaInterfaceInheritance::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (nullable id)castBaseArgToSub:(nullable id)subAsBase { + try { + auto objcpp_result_ = _cppRefHandle.get()->cast_base_arg_to_sub(::djinni_generated::BaseObjcJavaInterfaceInheritance::toCpp(subAsBase)); + return ::djinni_generated::SubObjcJavaInterfaceInheritance::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + ++ (nullable DBInterfaceEncapsulator *)create { + try { + auto objcpp_result_ = ::testsuite::InterfaceEncapsulator::create(); + return ::djinni_generated::InterfaceEncapsulator::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +namespace djinni_generated { + +auto InterfaceEncapsulator::toCpp(ObjcType objc) -> CppType +{ + if (!objc) { + return nullptr; + } + return [objc cppRef]; +} + +auto InterfaceEncapsulator::fromCppOpt(const CppOptType& cpp) -> ObjcType +{ + if (!cpp) { + return nil; + } + return ::djinni::get_cpp_proxy(cpp); +} + +} // namespace djinni_generated + +@end diff --git a/test-suite/generated-src/objc/DBInterfaceEncapsulator.h b/test-suite/generated-src/objc/DBInterfaceEncapsulator.h new file mode 100644 index 000000000..72eac16bf --- /dev/null +++ b/test-suite/generated-src/objc/DBInterfaceEncapsulator.h @@ -0,0 +1,31 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import +@class DBBaseCppInterfaceInheritance; +@class DBInterfaceEncapsulator; +@protocol DBBaseObjcJavaInterfaceInheritance; +@protocol DBSubObjcJavaInterfaceInheritance; + + +@interface DBInterfaceEncapsulator : NSObject + +- (void)setCppObject:(nullable DBBaseCppInterfaceInheritance *)object; + +- (nullable DBBaseCppInterfaceInheritance *)getCppObject; + +- (nullable DBBaseCppInterfaceInheritance *)subCppAsBaseCpp; + +- (void)setObjcJavaObject:(nullable id)object; + +- (nullable id)getObjcJavaObject; + +/** + * Takes a sub interface object through a base interface argument, then cast the argument back to + * the sub interface. Returning null signifies failure. + */ +- (nullable id)castBaseArgToSub:(nullable id)subAsBase; + ++ (nullable DBInterfaceEncapsulator *)create; + +@end diff --git a/test-suite/generated-src/objc/DBInterfaceInheritanceConstant+Private.h b/test-suite/generated-src/objc/DBInterfaceInheritanceConstant+Private.h new file mode 100644 index 000000000..41ffa23c3 --- /dev/null +++ b/test-suite/generated-src/objc/DBInterfaceInheritanceConstant+Private.h @@ -0,0 +1,31 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "interface_inheritance_constant.hpp" +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@protocol DBInterfaceInheritanceConstant; + +namespace djinni_generated { + +class InterfaceInheritanceConstant +{ +public: + using CppType = std::shared_ptr<::testsuite::InterfaceInheritanceConstant>; + using CppOptType = std::shared_ptr<::testsuite::InterfaceInheritanceConstant>; + using ObjcType = id; + + using Boxed = InterfaceInheritanceConstant; + + 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 + diff --git a/test-suite/generated-src/objc/DBInterfaceInheritanceConstant+Private.mm b/test-suite/generated-src/objc/DBInterfaceInheritanceConstant+Private.mm new file mode 100644 index 000000000..0d6b23369 --- /dev/null +++ b/test-suite/generated-src/objc/DBInterfaceInheritanceConstant+Private.mm @@ -0,0 +1,82 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import "DBInterfaceInheritanceConstant+Private.h" +#import "DBInterfaceInheritanceConstant.h" +#import "DJICppWrapperCache+Private.h" +#import "DJIError.h" +#import "DJIMarshal+Private.h" +#import "DJIObjcWrapperCache+Private.h" +#include +#include +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@interface DBInterfaceInheritanceConstantCppProxy : NSObject + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::InterfaceInheritanceConstant>&)cppRef; + +@end + +@implementation DBInterfaceInheritanceConstantCppProxy { + ::djinni::CppProxyCache::Handle> _cppRefHandle; +} + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::InterfaceInheritanceConstant>&)cppRef +{ + if (self = [super init]) { + _cppRefHandle.assign(cppRef); + } + return self; +} + +- (const std::shared_ptr<::testsuite::InterfaceInheritanceConstant>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBInterfaceInheritanceConstantCppProxy methods + + +namespace djinni_generated { + +class InterfaceInheritanceConstant::ObjcProxy final +: public ::testsuite::InterfaceInheritanceConstant +, public ::djinni::ObjcProxyCache::Handle +{ +public: + using Handle::Handle; + + // InterfaceInheritanceConstant methods +}; + +} // namespace djinni_generated + +namespace djinni_generated { + +auto InterfaceInheritanceConstant::toCpp(ObjcType objc) -> CppType +{ + if (!objc) { + return nullptr; + } + if ([(id)objc isKindOfClass:[DBInterfaceInheritanceConstantCppProxy class]]) { + return ((DBInterfaceInheritanceConstantCppProxy*)objc)->_cppRefHandle.get(); + } + return ::djinni::get_objc_proxy(objc); +} + +auto InterfaceInheritanceConstant::fromCppOpt(const CppOptType& cpp) -> ObjcType +{ + if (!cpp) { + return nil; + } + if (auto cppPtr = dynamic_cast(cpp.get())) { + return cppPtr->Handle::get(); + } + return ::djinni::get_cpp_proxy(cpp); +} + +} // namespace djinni_generated + +@end diff --git a/test-suite/generated-src/objc/DBInterfaceInheritanceConstant.h b/test-suite/generated-src/objc/DBInterfaceInheritanceConstant.h new file mode 100644 index 000000000..a441f9b00 --- /dev/null +++ b/test-suite/generated-src/objc/DBInterfaceInheritanceConstant.h @@ -0,0 +1,13 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import + +extern NSString * __nonnull const DBInterfaceInheritanceConstantBaseMethodReturnValue; +extern NSString * __nonnull const DBInterfaceInheritanceConstantBaseOverrideMethodReturnValue; +extern NSString * __nonnull const DBInterfaceInheritanceConstantSubMethodReturnValue; +extern NSString * __nonnull const DBInterfaceInheritanceConstantSubOverrideMethodReturnValue; + +@protocol DBInterfaceInheritanceConstant + +@end diff --git a/test-suite/generated-src/objc/DBInterfaceInheritanceConstant.mm b/test-suite/generated-src/objc/DBInterfaceInheritanceConstant.mm new file mode 100644 index 000000000..bf53c4e99 --- /dev/null +++ b/test-suite/generated-src/objc/DBInterfaceInheritanceConstant.mm @@ -0,0 +1,13 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import "DBInterfaceInheritanceConstant.h" + + +NSString * __nonnull const DBInterfaceInheritanceConstantBaseMethodReturnValue = @"base_method"; + +NSString * __nonnull const DBInterfaceInheritanceConstantBaseOverrideMethodReturnValue = @"override_method"; + +NSString * __nonnull const DBInterfaceInheritanceConstantSubMethodReturnValue = @"sub_method"; + +NSString * __nonnull const DBInterfaceInheritanceConstantSubOverrideMethodReturnValue = @"sub_override_method"; diff --git a/test-suite/generated-src/objc/DBSubCppInterfaceInheritance+Private.h b/test-suite/generated-src/objc/DBSubCppInterfaceInheritance+Private.h new file mode 100644 index 000000000..d1ae55bf6 --- /dev/null +++ b/test-suite/generated-src/objc/DBSubCppInterfaceInheritance+Private.h @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "sub_cpp_interface_inheritance.hpp" +#import "DBBaseCppInterfaceInheritance+Private.h" +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@class DBSubCppInterfaceInheritance; + +namespace djinni_generated { + +class SubCppInterfaceInheritance +{ +public: + using CppType = std::shared_ptr<::testsuite::SubCppInterfaceInheritance>; + using CppOptType = std::shared_ptr<::testsuite::SubCppInterfaceInheritance>; + using ObjcType = DBSubCppInterfaceInheritance*; + + using Boxed = SubCppInterfaceInheritance; + + 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 + diff --git a/test-suite/generated-src/objc/DBSubCppInterfaceInheritance+Private.mm b/test-suite/generated-src/objc/DBSubCppInterfaceInheritance+Private.mm new file mode 100644 index 000000000..980182136 --- /dev/null +++ b/test-suite/generated-src/objc/DBSubCppInterfaceInheritance+Private.mm @@ -0,0 +1,90 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import "DBSubCppInterfaceInheritance+Private.h" +#import "DBSubCppInterfaceInheritance.h" +#import "DJICppWrapperCache+Private.h" +#import "DJIError.h" +#import "DJIMarshal+Private.h" +#include +#include +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@interface DBSubCppInterfaceInheritance () + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::SubCppInterfaceInheritance>&)cppRef; + +@end + +@implementation DBSubCppInterfaceInheritance { + ::djinni::CppProxyCache::Handle> _cppRefHandle; +} + +- (id)initWithCpp:(const std::shared_ptr<::testsuite::SubCppInterfaceInheritance>&)cppRef +{ + if (self = [super init]) { + _cppRefHandle.assign(cppRef); + } + return self; +} + +- (const std::shared_ptr<::testsuite::SubCppInterfaceInheritance>&) cppRef +{ + return _cppRefHandle.get(); +} + +// DBSubCppInterfaceInheritance methods + +- (nonnull NSString *)subMethod { + try { + auto objcpp_result_ = _cppRefHandle.get()->sub_method(); + return ::djinni::String::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + ++ (nullable DBSubCppInterfaceInheritance *)create { + try { + auto objcpp_result_ = ::testsuite::SubCppInterfaceInheritance::create(); + return ::djinni_generated::SubCppInterfaceInheritance::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +// DBBaseCppInterfaceInheritance methods + +- (nonnull NSString *)baseMethod { + try { + auto objcpp_result_ = _cppRefHandle.get()->base_method(); + return ::djinni::String::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (nonnull NSString *)overrideMethod { + try { + auto objcpp_result_ = _cppRefHandle.get()->override_method(); + return ::djinni::String::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +namespace djinni_generated { + +auto SubCppInterfaceInheritance::toCpp(ObjcType objc) -> CppType +{ + if (!objc) { + return nullptr; + } + return [objc cppRef]; +} + +auto SubCppInterfaceInheritance::fromCppOpt(const CppOptType& cpp) -> ObjcType +{ + if (!cpp) { + return nil; + } + return ::djinni::get_cpp_proxy(cpp); +} + +} // namespace djinni_generated + +@end diff --git a/test-suite/generated-src/objc/DBSubCppInterfaceInheritance.h b/test-suite/generated-src/objc/DBSubCppInterfaceInheritance.h new file mode 100644 index 000000000..a2c1f892b --- /dev/null +++ b/test-suite/generated-src/objc/DBSubCppInterfaceInheritance.h @@ -0,0 +1,15 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import "DBBaseCppInterfaceInheritance.h" +#import +@class DBSubCppInterfaceInheritance; + + +@interface DBSubCppInterfaceInheritance : DBBaseCppInterfaceInheritance + +- (nonnull NSString *)subMethod; + ++ (nullable DBSubCppInterfaceInheritance *)create; + +@end diff --git a/test-suite/generated-src/objc/DBSubObjcJavaInterfaceInheritance+Private.h b/test-suite/generated-src/objc/DBSubObjcJavaInterfaceInheritance+Private.h new file mode 100644 index 000000000..323f54954 --- /dev/null +++ b/test-suite/generated-src/objc/DBSubObjcJavaInterfaceInheritance+Private.h @@ -0,0 +1,32 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#include "sub_objc_java_interface_inheritance.hpp" +#import "DBBaseObjcJavaInterfaceInheritance+Private.h" +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@protocol DBSubObjcJavaInterfaceInheritance; + +namespace djinni_generated { + +class SubObjcJavaInterfaceInheritance +{ +public: + using CppType = std::shared_ptr<::testsuite::SubObjcJavaInterfaceInheritance>; + using CppOptType = std::shared_ptr<::testsuite::SubObjcJavaInterfaceInheritance>; + using ObjcType = id; + + using Boxed = SubObjcJavaInterfaceInheritance; + + 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 + diff --git a/test-suite/generated-src/objc/DBSubObjcJavaInterfaceInheritance+Private.mm b/test-suite/generated-src/objc/DBSubObjcJavaInterfaceInheritance+Private.mm new file mode 100644 index 000000000..64d85bf7b --- /dev/null +++ b/test-suite/generated-src/objc/DBSubObjcJavaInterfaceInheritance+Private.mm @@ -0,0 +1,67 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import "DBSubObjcJavaInterfaceInheritance+Private.h" +#import "DBSubObjcJavaInterfaceInheritance.h" +#import "DJIMarshal+Private.h" +#import "DJIObjcWrapperCache+Private.h" +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +namespace djinni_generated { + +class SubObjcJavaInterfaceInheritance::ObjcProxy final +: public ::testsuite::SubObjcJavaInterfaceInheritance +, public ::djinni::ObjcProxyCache::Handle +{ +public: + using Handle::Handle; + + // SubObjcJavaInterfaceInheritance methods + std::string sub_method() override + { + @autoreleasepool { + auto objcpp_result_ = [Handle::get() subMethod]; + return ::djinni::String::toCpp(objcpp_result_); + } + } + + // BaseObjcJavaInterfaceInheritance methods + std::string base_method() override + { + @autoreleasepool { + auto objcpp_result_ = [Handle::get() baseMethod]; + return ::djinni::String::toCpp(objcpp_result_); + } + } + std::string override_method() override + { + @autoreleasepool { + auto objcpp_result_ = [Handle::get() overrideMethod]; + return ::djinni::String::toCpp(objcpp_result_); + } + } +}; + +} // namespace djinni_generated + +namespace djinni_generated { + +auto SubObjcJavaInterfaceInheritance::toCpp(ObjcType objc) -> CppType +{ + if (!objc) { + return nullptr; + } + return ::djinni::get_objc_proxy(objc); +} + +auto SubObjcJavaInterfaceInheritance::fromCppOpt(const CppOptType& cpp) -> ObjcType +{ + if (!cpp) { + return nil; + } + return dynamic_cast(*cpp).Handle::get(); +} + +} // namespace djinni_generated diff --git a/test-suite/generated-src/objc/DBSubObjcJavaInterfaceInheritance.h b/test-suite/generated-src/objc/DBSubObjcJavaInterfaceInheritance.h new file mode 100644 index 000000000..27b066f6f --- /dev/null +++ b/test-suite/generated-src/objc/DBSubObjcJavaInterfaceInheritance.h @@ -0,0 +1,12 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file generated by Djinni from interface_inheritance.djinni + +#import "DBBaseObjcJavaInterfaceInheritance.h" +#import + + +@protocol DBSubObjcJavaInterfaceInheritance + +- (nonnull NSString *)subMethod; + +@end diff --git a/test-suite/generated-src/outFileList.txt b/test-suite/generated-src/outFileList.txt index 3f28125dc..78791ccc8 100644 --- a/test-suite/generated-src/outFileList.txt +++ b/test-suite/generated-src/outFileList.txt @@ -4,6 +4,13 @@ djinni-output-temp/cpp/record_with_duration_and_derivings.cpp djinni-output-temp/cpp/date_record.hpp djinni-output-temp/cpp/date_record.cpp djinni-output-temp/cpp/map_date_record.hpp +djinni-output-temp/cpp/interface_inheritance_constant.hpp +djinni-output-temp/cpp/interface_inheritance_constant.cpp +djinni-output-temp/cpp/base_cpp_interface_inheritance.hpp +djinni-output-temp/cpp/sub_cpp_interface_inheritance.hpp +djinni-output-temp/cpp/base_objc_java_interface_inheritance.hpp +djinni-output-temp/cpp/sub_objc_java_interface_inheritance.hpp +djinni-output-temp/cpp/interface_encapsulator.hpp djinni-output-temp/cpp/_varname_record_.hpp djinni-output-temp/cpp/_varname_interface_.hpp djinni-output-temp/cpp/extended_record_base.hpp @@ -48,6 +55,12 @@ djinni-output-temp/java/TestDuration.java djinni-output-temp/java/RecordWithDurationAndDerivings.java djinni-output-temp/java/DateRecord.java djinni-output-temp/java/MapDateRecord.java +djinni-output-temp/java/InterfaceInheritanceConstant.java +djinni-output-temp/java/BaseCppInterfaceInheritance.java +djinni-output-temp/java/SubCppInterfaceInheritance.java +djinni-output-temp/java/BaseObjcJavaInterfaceInheritance.java +djinni-output-temp/java/SubObjcJavaInterfaceInheritance.java +djinni-output-temp/java/InterfaceEncapsulator.java djinni-output-temp/java/VarnameRecord.java djinni-output-temp/java/VarnameInterface.java djinni-output-temp/java/ExtendedRecord.java @@ -90,6 +103,18 @@ djinni-output-temp/jni/NativeDateRecord.hpp djinni-output-temp/jni/NativeDateRecord.cpp djinni-output-temp/jni/NativeMapDateRecord.hpp djinni-output-temp/jni/NativeMapDateRecord.cpp +djinni-output-temp/jni/NativeInterfaceInheritanceConstant.hpp +djinni-output-temp/jni/NativeInterfaceInheritanceConstant.cpp +djinni-output-temp/jni/NativeBaseCppInterfaceInheritance.hpp +djinni-output-temp/jni/NativeBaseCppInterfaceInheritance.cpp +djinni-output-temp/jni/NativeSubCppInterfaceInheritance.hpp +djinni-output-temp/jni/NativeSubCppInterfaceInheritance.cpp +djinni-output-temp/jni/NativeBaseObjcJavaInterfaceInheritance.hpp +djinni-output-temp/jni/NativeBaseObjcJavaInterfaceInheritance.cpp +djinni-output-temp/jni/NativeSubObjcJavaInterfaceInheritance.hpp +djinni-output-temp/jni/NativeSubObjcJavaInterfaceInheritance.cpp +djinni-output-temp/jni/NativeInterfaceEncapsulator.hpp +djinni-output-temp/jni/NativeInterfaceEncapsulator.cpp djinni-output-temp/jni/NativeVarnameRecord.hpp djinni-output-temp/jni/NativeVarnameRecord.cpp djinni-output-temp/jni/NativeVarnameInterface.hpp @@ -164,6 +189,13 @@ djinni-output-temp/objc/DBDateRecord.h djinni-output-temp/objc/DBDateRecord.mm djinni-output-temp/objc/DBMapDateRecord.h djinni-output-temp/objc/DBMapDateRecord.mm +djinni-output-temp/objc/DBInterfaceInheritanceConstant.h +djinni-output-temp/objc/DBInterfaceInheritanceConstant.mm +djinni-output-temp/objc/DBBaseCppInterfaceInheritance.h +djinni-output-temp/objc/DBSubCppInterfaceInheritance.h +djinni-output-temp/objc/DBBaseObjcJavaInterfaceInheritance.h +djinni-output-temp/objc/DBSubObjcJavaInterfaceInheritance.h +djinni-output-temp/objc/DBInterfaceEncapsulator.h djinni-output-temp/objc/DBVarnameRecord.h djinni-output-temp/objc/DBVarnameRecord.mm djinni-output-temp/objc/DBVarnameInterface.h @@ -222,6 +254,18 @@ djinni-output-temp/objc/DBDateRecord+Private.h djinni-output-temp/objc/DBDateRecord+Private.mm djinni-output-temp/objc/DBMapDateRecord+Private.h djinni-output-temp/objc/DBMapDateRecord+Private.mm +djinni-output-temp/objc/DBInterfaceInheritanceConstant+Private.h +djinni-output-temp/objc/DBInterfaceInheritanceConstant+Private.mm +djinni-output-temp/objc/DBBaseCppInterfaceInheritance+Private.h +djinni-output-temp/objc/DBBaseCppInterfaceInheritance+Private.mm +djinni-output-temp/objc/DBSubCppInterfaceInheritance+Private.h +djinni-output-temp/objc/DBSubCppInterfaceInheritance+Private.mm +djinni-output-temp/objc/DBBaseObjcJavaInterfaceInheritance+Private.h +djinni-output-temp/objc/DBBaseObjcJavaInterfaceInheritance+Private.mm +djinni-output-temp/objc/DBSubObjcJavaInterfaceInheritance+Private.h +djinni-output-temp/objc/DBSubObjcJavaInterfaceInheritance+Private.mm +djinni-output-temp/objc/DBInterfaceEncapsulator+Private.h +djinni-output-temp/objc/DBInterfaceEncapsulator+Private.mm djinni-output-temp/objc/DBVarnameRecord+Private.h djinni-output-temp/objc/DBVarnameRecord+Private.mm djinni-output-temp/objc/DBVarnameInterface+Private.h diff --git a/test-suite/handwritten-src/cpp/base_cpp_interface_inheritance_impl.cpp b/test-suite/handwritten-src/cpp/base_cpp_interface_inheritance_impl.cpp new file mode 100644 index 000000000..255ce13e2 --- /dev/null +++ b/test-suite/handwritten-src/cpp/base_cpp_interface_inheritance_impl.cpp @@ -0,0 +1,18 @@ +#include "base_cpp_interface_inheritance_impl.hpp" +#include "interface_inheritance_constant.hpp" + +namespace testsuite { + +std::string BaseCppInterfaceInheritanceImpl::base_method() { + return InterfaceInheritanceConstant::BASE_METHOD_RETURN_VALUE; +} + +std::string BaseCppInterfaceInheritanceImpl::override_method() { + return InterfaceInheritanceConstant::BASE_OVERRIDE_METHOD_RETURN_VALUE; +} + +std::shared_ptr BaseCppInterfaceInheritance::create() { + return std::make_shared(); +} + +} // namespace testsuite diff --git a/test-suite/handwritten-src/cpp/base_cpp_interface_inheritance_impl.hpp b/test-suite/handwritten-src/cpp/base_cpp_interface_inheritance_impl.hpp new file mode 100644 index 000000000..305d0ed4e --- /dev/null +++ b/test-suite/handwritten-src/cpp/base_cpp_interface_inheritance_impl.hpp @@ -0,0 +1,15 @@ +#include "base_cpp_interface_inheritance.hpp" + +namespace testsuite { + +class BaseCppInterfaceInheritanceImpl : public BaseCppInterfaceInheritance { +public: + BaseCppInterfaceInheritanceImpl() {} + virtual ~BaseCppInterfaceInheritanceImpl() {} + + virtual std::string base_method() override; + + virtual std::string override_method() override; +}; + +} // namespace testsuite diff --git a/test-suite/handwritten-src/cpp/interface_encapsulator_impl.cpp b/test-suite/handwritten-src/cpp/interface_encapsulator_impl.cpp new file mode 100644 index 000000000..659b9b230 --- /dev/null +++ b/test-suite/handwritten-src/cpp/interface_encapsulator_impl.cpp @@ -0,0 +1,45 @@ +#include "interface_encapsulator_impl.hpp" + +#include "base_cpp_interface_inheritance_impl.hpp" +#include "sub_cpp_interface_inheritance_impl.hpp" +#include "base_objc_java_interface_inheritance.hpp" +#include "sub_objc_java_interface_inheritance.hpp" + +namespace testsuite { + +void InterfaceEncapsulatorImpl::set_cpp_object(const std::shared_ptr & object) { + mCppObject = object; +} + +std::shared_ptr InterfaceEncapsulatorImpl::get_cpp_object() { + return mCppObject; +} + +std::shared_ptr InterfaceEncapsulatorImpl::sub_cpp_as_base_cpp() { + return std::make_shared(); +} + +void InterfaceEncapsulatorImpl::set_objc_java_object(const std::shared_ptr & object) { + mObjcJavaObject = object; +} + +std::shared_ptr InterfaceEncapsulatorImpl::get_objc_java_object() { + return mObjcJavaObject; +} + +std::shared_ptr InterfaceEncapsulator::create() { + return std::make_shared(); +} + +std::shared_ptr InterfaceEncapsulatorImpl::cast_base_arg_to_sub(const std::shared_ptr & subAsBase) { + auto subAsSub = std::dynamic_pointer_cast(subAsBase); + return subAsSub; +} + + +} // namespace testsuite + + + + + diff --git a/test-suite/handwritten-src/cpp/interface_encapsulator_impl.hpp b/test-suite/handwritten-src/cpp/interface_encapsulator_impl.hpp new file mode 100644 index 000000000..73296aec2 --- /dev/null +++ b/test-suite/handwritten-src/cpp/interface_encapsulator_impl.hpp @@ -0,0 +1,28 @@ +#include "interface_encapsulator.hpp" + +namespace testsuite { + +class InterfaceEncapsulatorImpl : public InterfaceEncapsulator { +public: + InterfaceEncapsulatorImpl() {} + virtual ~InterfaceEncapsulatorImpl() {} + + virtual void set_cpp_object(const std::shared_ptr & object) override; + + virtual std::shared_ptr get_cpp_object() override; + + virtual std::shared_ptr sub_cpp_as_base_cpp() override; + + virtual void set_objc_java_object(const std::shared_ptr & object) override; + + virtual std::shared_ptr get_objc_java_object() override; + + virtual std::shared_ptr cast_base_arg_to_sub(const std::shared_ptr & subAsBase) override; + +private: + + std::shared_ptr mCppObject; + std::shared_ptr mObjcJavaObject; +}; + +} // namespace testsuite diff --git a/test-suite/handwritten-src/cpp/sub_cpp_interface_inheritance_impl.cpp b/test-suite/handwritten-src/cpp/sub_cpp_interface_inheritance_impl.cpp new file mode 100644 index 000000000..cc47c1232 --- /dev/null +++ b/test-suite/handwritten-src/cpp/sub_cpp_interface_inheritance_impl.cpp @@ -0,0 +1,26 @@ +#include "sub_cpp_interface_inheritance_impl.hpp" +#include "base_cpp_interface_inheritance_impl.hpp" +#include "interface_inheritance_constant.hpp" + +namespace testsuite { + +SubCppInterfaceInheritanceImpl::SubCppInterfaceInheritanceImpl() + : mSuper{std::make_shared()} {}; + +std::string SubCppInterfaceInheritanceImpl::base_method() { + return mSuper->base_method(); +} + +std::string SubCppInterfaceInheritanceImpl::override_method() { + return InterfaceInheritanceConstant::SUB_OVERRIDE_METHOD_RETURN_VALUE; +} + +std::string SubCppInterfaceInheritanceImpl::sub_method() { + return InterfaceInheritanceConstant::SUB_METHOD_RETURN_VALUE; +} + +std::shared_ptr SubCppInterfaceInheritance::create() { + return std::make_shared(); +} + +} // namespace testsuite diff --git a/test-suite/handwritten-src/cpp/sub_cpp_interface_inheritance_impl.hpp b/test-suite/handwritten-src/cpp/sub_cpp_interface_inheritance_impl.hpp new file mode 100644 index 000000000..a454af86a --- /dev/null +++ b/test-suite/handwritten-src/cpp/sub_cpp_interface_inheritance_impl.hpp @@ -0,0 +1,20 @@ +#include "sub_cpp_interface_inheritance.hpp" + +namespace testsuite { + +class SubCppInterfaceInheritanceImpl : public SubCppInterfaceInheritance { +public: + SubCppInterfaceInheritanceImpl(); + virtual ~SubCppInterfaceInheritanceImpl() {} + + virtual std::string base_method() override; + + virtual std::string override_method() override; + + virtual std::string sub_method() override; + +private: + std::shared_ptr mSuper; +}; + +} // namespace testsuite diff --git a/test-suite/handwritten-src/java/com/dropbox/djinni/test/AllTests.java b/test-suite/handwritten-src/java/com/dropbox/djinni/test/AllTests.java index b9239f958..895026844 100644 --- a/test-suite/handwritten-src/java/com/dropbox/djinni/test/AllTests.java +++ b/test-suite/handwritten-src/java/com/dropbox/djinni/test/AllTests.java @@ -23,6 +23,7 @@ public static Test suite() { mySuite.addTestSuite(DurationTest.class); mySuite.addTestSuite(MockRecordTest.class); mySuite.addTestSuite(WcharTest.class); + mySuite.addTestSuite(InterfaceInheritanceTest.class); return mySuite; } diff --git a/test-suite/handwritten-src/java/com/dropbox/djinni/test/BaseObjcJavaInterfaceInheritanceImpl.java b/test-suite/handwritten-src/java/com/dropbox/djinni/test/BaseObjcJavaInterfaceInheritanceImpl.java new file mode 100644 index 000000000..a22b3aae3 --- /dev/null +++ b/test-suite/handwritten-src/java/com/dropbox/djinni/test/BaseObjcJavaInterfaceInheritanceImpl.java @@ -0,0 +1,17 @@ +package com.dropbox.djinni.test; + +import javax.annotation.Nonnull; + +public class BaseObjcJavaInterfaceInheritanceImpl extends BaseObjcJavaInterfaceInheritance { + @Nonnull + @Override + public String baseMethod() { + return InterfaceInheritanceConstant.BASE_METHOD_RETURN_VALUE; + } + + @Nonnull + @Override + public String overrideMethod() { + return InterfaceInheritanceConstant.BASE_OVERRIDE_METHOD_RETURN_VALUE; + } +} diff --git a/test-suite/handwritten-src/java/com/dropbox/djinni/test/InterfaceInheritanceTest.java b/test-suite/handwritten-src/java/com/dropbox/djinni/test/InterfaceInheritanceTest.java new file mode 100644 index 000000000..c79601a6e --- /dev/null +++ b/test-suite/handwritten-src/java/com/dropbox/djinni/test/InterfaceInheritanceTest.java @@ -0,0 +1,104 @@ +package com.dropbox.djinni.test; + +import junit.framework.TestCase; + +public class InterfaceInheritanceTest extends TestCase { + public void testCppBaseClass() { + BaseCppInterfaceInheritance base = BaseCppInterfaceInheritance.create(); + + assertNotNull(base); + assertTrue(base instanceof BaseCppInterfaceInheritance); + + assertTrue(base.baseMethod().equals(InterfaceInheritanceConstant.BASE_METHOD_RETURN_VALUE)); + assertTrue(base.overrideMethod().equals(InterfaceInheritanceConstant.BASE_OVERRIDE_METHOD_RETURN_VALUE)); + } + + public void testCppSubClassInheritance() { + SubCppInterfaceInheritance sub = SubCppInterfaceInheritance.create(); + + assertNotNull(sub); + assertTrue(sub instanceof SubCppInterfaceInheritance); + assertTrue(sub instanceof BaseCppInterfaceInheritance); + + assertTrue(sub.baseMethod().equals(InterfaceInheritanceConstant.BASE_METHOD_RETURN_VALUE)); + assertTrue(sub.overrideMethod().equals(InterfaceInheritanceConstant.SUB_OVERRIDE_METHOD_RETURN_VALUE)); + assertTrue(sub.subMethod().equals(InterfaceInheritanceConstant.SUB_METHOD_RETURN_VALUE)); + + BaseCppInterfaceInheritance subAsBase = (BaseCppInterfaceInheritance)sub; + assertTrue(subAsBase.baseMethod().equals(InterfaceInheritanceConstant.BASE_METHOD_RETURN_VALUE)); + assertTrue(subAsBase.overrideMethod().equals(InterfaceInheritanceConstant.SUB_OVERRIDE_METHOD_RETURN_VALUE)); + } + + public void testCppSubClassEncapsulation() { + InterfaceEncapsulator encapsulator = InterfaceEncapsulator.create(); + + BaseCppInterfaceInheritance base = BaseCppInterfaceInheritance.create(); + encapsulator.setCppObject(base); + assertTrue(encapsulator.getCppObject() instanceof BaseCppInterfaceInheritance); + + SubCppInterfaceInheritance sub = SubCppInterfaceInheritance.create(); + encapsulator.setCppObject(sub); + assertTrue(encapsulator.getCppObject() instanceof SubCppInterfaceInheritance); + assertTrue(encapsulator.subCppAsBaseCpp() instanceof SubCppInterfaceInheritance); + } + + public void testJavaBaseClass() { + BaseObjcJavaInterfaceInheritance base = new BaseObjcJavaInterfaceInheritanceImpl(); + + assertNotNull(base); + assertTrue(base instanceof BaseObjcJavaInterfaceInheritance); + + assertTrue(base.baseMethod().equals(InterfaceInheritanceConstant.BASE_METHOD_RETURN_VALUE)); + assertTrue(base.overrideMethod().equals(InterfaceInheritanceConstant.BASE_OVERRIDE_METHOD_RETURN_VALUE)); + } + + public void testJavaSubClassInheritance() { + SubObjcJavaInterfaceInheritance sub = new SubObjcJavaInterfaceInheritanceImpl(); + + assertNotNull(sub); + assertTrue(sub instanceof SubObjcJavaInterfaceInheritance); + assertTrue(sub instanceof BaseObjcJavaInterfaceInheritance); + + assertTrue(sub.baseMethod().equals(InterfaceInheritanceConstant.BASE_METHOD_RETURN_VALUE)); + assertTrue(sub.overrideMethod().equals(InterfaceInheritanceConstant.SUB_OVERRIDE_METHOD_RETURN_VALUE)); + assertTrue(sub.subMethod().equals(InterfaceInheritanceConstant.SUB_METHOD_RETURN_VALUE)); + } + + public void testJavaSubClassEncapsulation() { + InterfaceEncapsulator encapsulator = InterfaceEncapsulator.create(); + + BaseObjcJavaInterfaceInheritance base = new BaseObjcJavaInterfaceInheritanceImpl(); + encapsulator.setObjcJavaObject(base); + + BaseObjcJavaInterfaceInheritance encappedBase = encapsulator.getObjcJavaObject(); + assertTrue(encappedBase instanceof BaseObjcJavaInterfaceInheritance); + assertTrue(encappedBase instanceof BaseObjcJavaInterfaceInheritanceImpl); + + SubObjcJavaInterfaceInheritance sub = new SubObjcJavaInterfaceInheritanceImpl(); + encapsulator.setObjcJavaObject(sub); + + BaseObjcJavaInterfaceInheritance encappedSub = encapsulator.getObjcJavaObject(); + assertTrue(encappedSub instanceof BaseObjcJavaInterfaceInheritance); + assertTrue(encappedSub instanceof SubObjcJavaInterfaceInheritance); + assertTrue(encappedSub instanceof SubObjcJavaInterfaceInheritanceImpl); + assertFalse(encappedSub instanceof BaseObjcJavaInterfaceInheritanceImpl); + } + + public void testJavaSubClassCasting() { + InterfaceEncapsulator encapsulator = InterfaceEncapsulator.create(); + + BaseObjcJavaInterfaceInheritance base = new BaseObjcJavaInterfaceInheritanceImpl(); + Object castBase = encapsulator.castBaseArgToSub(base); + assertNull(castBase); + + // FIXME: This test will fail. When castBaseArgToSub is called, a C++ object will be created to + // represent the Java object. Since castBaseArgToSub takes a DBBaseObjJavaInterfaceInheritance + // argument, the C++ object that is created will be BaseObjcJavaInterfaceInheritance object, + // slicing off all the additional members of the subtype and making it impossible to cast + // back to the provided subtype. + // SubObjcJavaInterfaceInheritance sub = new SubObjcJavaInterfaceInheritanceImpl(); + // Object castSub = encapsulator.castBaseArgToSub(sub); + // assertNotNull(castSub); + // assertTrue(castSub instanceof SubObjcJavaInterfaceInheritance); + } +} \ No newline at end of file diff --git a/test-suite/handwritten-src/java/com/dropbox/djinni/test/SubObjcJavaInterfaceInheritanceImpl.java b/test-suite/handwritten-src/java/com/dropbox/djinni/test/SubObjcJavaInterfaceInheritanceImpl.java new file mode 100644 index 000000000..9d3ae3833 --- /dev/null +++ b/test-suite/handwritten-src/java/com/dropbox/djinni/test/SubObjcJavaInterfaceInheritanceImpl.java @@ -0,0 +1,25 @@ +package com.dropbox.djinni.test; + +import javax.annotation.Nonnull; + +public class SubObjcJavaInterfaceInheritanceImpl extends SubObjcJavaInterfaceInheritance { + private BaseObjcJavaInterfaceInheritance superImpl = new BaseObjcJavaInterfaceInheritanceImpl(); + + @Nonnull + @Override + public String baseMethod() { + return superImpl.baseMethod(); + } + + @Nonnull + @Override + public String subMethod() { + return InterfaceInheritanceConstant.SUB_METHOD_RETURN_VALUE; + } + + @Nonnull + @Override + public String overrideMethod() { + return InterfaceInheritanceConstant.SUB_OVERRIDE_METHOD_RETURN_VALUE; + } +} diff --git a/test-suite/handwritten-src/objc/impl/DBBaseObjcJavaInterfaceInheritanceImpl.h b/test-suite/handwritten-src/objc/impl/DBBaseObjcJavaInterfaceInheritanceImpl.h new file mode 100644 index 000000000..eb9827f34 --- /dev/null +++ b/test-suite/handwritten-src/objc/impl/DBBaseObjcJavaInterfaceInheritanceImpl.h @@ -0,0 +1,7 @@ +#import + +#import "DBBaseObjcJavaInterfaceInheritance.h" + +@interface DBBaseObjcJavaInterfaceInheritanceImpl : NSObject + +@end diff --git a/test-suite/handwritten-src/objc/impl/DBBaseObjcJavaInterfaceInheritanceImpl.m b/test-suite/handwritten-src/objc/impl/DBBaseObjcJavaInterfaceInheritanceImpl.m new file mode 100644 index 000000000..96cef87fe --- /dev/null +++ b/test-suite/handwritten-src/objc/impl/DBBaseObjcJavaInterfaceInheritanceImpl.m @@ -0,0 +1,17 @@ +#import "DBBaseObjcJavaInterfaceInheritanceImpl.h" + +#import "DBInterfaceInheritanceConstant.h" + +@implementation DBBaseObjcJavaInterfaceInheritanceImpl + +- (nonnull NSString *)baseMethod +{ + return DBInterfaceInheritanceConstantBaseMethodReturnValue; +} + +- (nonnull NSString *)overrideMethod +{ + return DBInterfaceInheritanceConstantBaseOverrideMethodReturnValue; +} + +@end diff --git a/test-suite/handwritten-src/objc/impl/DBSubObjcJavaInterfaceInheritanceImpl.h b/test-suite/handwritten-src/objc/impl/DBSubObjcJavaInterfaceInheritanceImpl.h new file mode 100644 index 000000000..283875308 --- /dev/null +++ b/test-suite/handwritten-src/objc/impl/DBSubObjcJavaInterfaceInheritanceImpl.h @@ -0,0 +1,7 @@ +#import + +#import "DBSubObjcJavaInterfaceInheritance.h" + +@interface DBSubObjcJavaInterfaceInheritanceImpl : NSObject + +@end diff --git a/test-suite/handwritten-src/objc/impl/DBSubObjcJavaInterfaceInheritanceImpl.m b/test-suite/handwritten-src/objc/impl/DBSubObjcJavaInterfaceInheritanceImpl.m new file mode 100644 index 000000000..76840cf59 --- /dev/null +++ b/test-suite/handwritten-src/objc/impl/DBSubObjcJavaInterfaceInheritanceImpl.m @@ -0,0 +1,38 @@ +#import "DBSubObjcJavaInterfaceInheritanceImpl.h" + +#import "DBInterfaceInheritanceConstant.h" +#import "DBBaseObjcJavaInterfaceInheritanceImpl.h" + +@interface DBSubObjcJavaInterfaceInheritanceImpl () + +@property (nonnull, readonly, strong) DBBaseObjcJavaInterfaceInheritanceImpl *superImpl; + +@end + +@implementation DBSubObjcJavaInterfaceInheritanceImpl + +@synthesize superImpl = _superImpl; +- (DBBaseObjcJavaInterfaceInheritanceImpl *)superImpl +{ + if (!_superImpl) { + _superImpl = [[DBBaseObjcJavaInterfaceInheritanceImpl alloc] init]; + } + return _superImpl; +} + +- (nonnull NSString *)baseMethod +{ + return [self.superImpl baseMethod]; +} + +- (nonnull NSString *)overrideMethod +{ + return DBInterfaceInheritanceConstantSubOverrideMethodReturnValue; +} + +- (nonnull NSString *)subMethod +{ + return DBInterfaceInheritanceConstantSubMethodReturnValue; +} + +@end diff --git a/test-suite/handwritten-src/objc/tests/DBInterfaceInheritanceTests.mm b/test-suite/handwritten-src/objc/tests/DBInterfaceInheritanceTests.mm new file mode 100644 index 000000000..61e148a44 --- /dev/null +++ b/test-suite/handwritten-src/objc/tests/DBInterfaceInheritanceTests.mm @@ -0,0 +1,139 @@ +#import + +#import "DBInterfaceInheritanceConstant.h" +#import "DBInterfaceEncapsulator.h" + +#import "DBBaseCppInterfaceInheritance.h" +#import "DBSubCppInterfaceInheritance.h" + +#import "DBBaseObjcJavaInterfaceInheritanceImpl.h" +#import "DBSubObjcJavaInterfaceInheritanceImpl.h" + +@interface DBInterfaceInheritanceTests : XCTestCase + +@end + +@implementation DBInterfaceInheritanceTests + +- (void)setUp +{ + [super setUp]; +} + +- (void)tearDown +{ + [super tearDown]; +} + +#pragma mark - C++ Inheritance Test Cases + +- (void)testCppBaseClass +{ + DBBaseCppInterfaceInheritance *base = [DBBaseCppInterfaceInheritance create]; + + XCTAssertNotNil(base); + XCTAssertTrue([base isKindOfClass:[DBBaseCppInterfaceInheritance class]]); + + XCTAssertTrue([[base baseMethod] isEqualToString:DBInterfaceInheritanceConstantBaseMethodReturnValue]); + XCTAssertTrue([[base overrideMethod] isEqualToString:DBInterfaceInheritanceConstantBaseOverrideMethodReturnValue]); +} + +- (void)testCppSubClassInheritance +{ + DBSubCppInterfaceInheritance *sub = [DBSubCppInterfaceInheritance create]; + XCTAssertNotNil(sub); + XCTAssertTrue([sub isKindOfClass:[DBSubCppInterfaceInheritance class]]); + XCTAssertTrue([sub isKindOfClass:[DBBaseCppInterfaceInheritance class]]); + + XCTAssertTrue([[sub baseMethod] isEqualToString:DBInterfaceInheritanceConstantBaseMethodReturnValue]); + XCTAssertTrue([[sub overrideMethod] isEqualToString:DBInterfaceInheritanceConstantSubOverrideMethodReturnValue]); + XCTAssertTrue([[sub subMethod] isEqualToString:DBInterfaceInheritanceConstantSubMethodReturnValue]); + + DBBaseCppInterfaceInheritance *subAsBase = (DBBaseCppInterfaceInheritance *)sub; + XCTAssertTrue([[subAsBase baseMethod] isEqualToString:DBInterfaceInheritanceConstantBaseMethodReturnValue]); + XCTAssertTrue([[subAsBase overrideMethod] isEqualToString:DBInterfaceInheritanceConstantSubOverrideMethodReturnValue]); +} + +- (void)testCppSubClassEncapsulation +{ + DBInterfaceEncapsulator *encapsulator = [DBInterfaceEncapsulator create]; + + DBBaseCppInterfaceInheritance *base = [DBBaseCppInterfaceInheritance create]; + [encapsulator setCppObject:base]; + XCTAssertTrue([[encapsulator getCppObject] isKindOfClass:[DBBaseCppInterfaceInheritance class]]); + + DBSubCppInterfaceInheritance *sub = [DBSubCppInterfaceInheritance create]; + [encapsulator setCppObject:sub]; + XCTAssertTrue([[encapsulator getCppObject] isKindOfClass:[DBSubCppInterfaceInheritance class]]); + XCTAssertTrue([[encapsulator subCppAsBaseCpp] isKindOfClass:[DBSubCppInterfaceInheritance class]]); +} + +#pragma mark - Objective-C Inheritance Test Cases + +- (void)testObjcBaseClass +{ + id base = [[DBBaseObjcJavaInterfaceInheritanceImpl alloc] init]; + + XCTAssertNotNil(base); + XCTAssertTrue([base conformsToProtocol:@protocol(DBBaseObjcJavaInterfaceInheritance)]); + + XCTAssertTrue([[base baseMethod] isEqualToString:DBInterfaceInheritanceConstantBaseMethodReturnValue]); + XCTAssertTrue([[base overrideMethod] isEqualToString:DBInterfaceInheritanceConstantBaseOverrideMethodReturnValue]); +} + +- (void)testObjcSubClassInheritance +{ + id sub = [[DBSubObjcJavaInterfaceInheritanceImpl alloc] init]; + XCTAssertNotNil(sub); + XCTAssertTrue([sub conformsToProtocol:@protocol(DBSubObjcJavaInterfaceInheritance)]); + XCTAssertTrue([sub conformsToProtocol:@protocol(DBBaseObjcJavaInterfaceInheritance)]); + + XCTAssertTrue([[sub baseMethod] isEqualToString:DBInterfaceInheritanceConstantBaseMethodReturnValue]); + XCTAssertTrue([[sub overrideMethod] isEqualToString:DBInterfaceInheritanceConstantSubOverrideMethodReturnValue]); + XCTAssertTrue([[sub subMethod] isEqualToString:DBInterfaceInheritanceConstantSubMethodReturnValue]); + + id subAsBase = (id)sub; + XCTAssertTrue([[subAsBase baseMethod] isEqualToString:DBInterfaceInheritanceConstantBaseMethodReturnValue]); + XCTAssertTrue([[subAsBase overrideMethod] isEqualToString:DBInterfaceInheritanceConstantSubOverrideMethodReturnValue]); +} + +- (void)testObjcSubClassEncapsulation +{ + DBInterfaceEncapsulator *encapsulator = [DBInterfaceEncapsulator create]; + + id base = [[DBBaseObjcJavaInterfaceInheritanceImpl alloc] init]; + [encapsulator setObjcJavaObject:base]; + + id encappedBase = [encapsulator getObjcJavaObject]; + XCTAssertTrue([encappedBase conformsToProtocol:@protocol(DBBaseObjcJavaInterfaceInheritance)]); + XCTAssertTrue([encappedBase isKindOfClass:[DBBaseObjcJavaInterfaceInheritanceImpl class]]); + + id sub = [[DBSubObjcJavaInterfaceInheritanceImpl alloc] init]; + [encapsulator setObjcJavaObject:sub]; + + id encappedSub = [encapsulator getObjcJavaObject]; + XCTAssertTrue([encappedSub conformsToProtocol:@protocol(DBBaseObjcJavaInterfaceInheritance)]); + XCTAssertTrue([encappedSub conformsToProtocol:@protocol(DBSubObjcJavaInterfaceInheritance)]); + XCTAssertTrue([encappedSub isKindOfClass:[DBSubObjcJavaInterfaceInheritanceImpl class]]); + XCTAssertFalse([encappedSub isKindOfClass:[DBBaseObjcJavaInterfaceInheritanceImpl class]]); +} + +- (void) testObjcSubClassCasting +{ + DBInterfaceEncapsulator *encapsulator = [DBInterfaceEncapsulator create]; + + id base = [[DBBaseObjcJavaInterfaceInheritanceImpl alloc] init]; + id castBase = [encapsulator castBaseArgToSub:base]; + XCTAssertNil(castBase); + + // FIXME: This test will fail. When castBaseArgToSub is called, a C++ object will be created to + // represent the Objective-C object. Since castBaseArgToSub takes a DBBaseObjJavaInterfaceInheritance + // argument, the C++ object that is created will be BaseObjcJavaInterfaceInheritance object, + // slicing off all the additional members of the subtype and making it impossible to cast + // back to the provided subtype. + // id sub = [[DBSubObjcJavaInterfaceInheritanceImpl alloc] init]; + // id castSub = [encapsulator castBaseArgToSub:sub]; + // XCTAssertNotNil(castSub); +} + +@end diff --git a/test-suite/objc/DjinniObjcTest.xcodeproj/project.pbxproj b/test-suite/objc/DjinniObjcTest.xcodeproj/project.pbxproj index d4e54ea11..5a06556f8 100644 --- a/test-suite/objc/DjinniObjcTest.xcodeproj/project.pbxproj +++ b/test-suite/objc/DjinniObjcTest.xcodeproj/project.pbxproj @@ -128,6 +128,20 @@ CFFD58B41B041BD9001E10B6 /* DBConstantsInterface+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = CFFD58B01B041BD9001E10B6 /* DBConstantsInterface+Private.mm */; }; CFFD58B71B041BFD001E10B6 /* constants_interface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CFFD58B51B041BFD001E10B6 /* constants_interface.cpp */; }; CFFD58B81B041BFD001E10B6 /* constants_interface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CFFD58B51B041BFD001E10B6 /* constants_interface.cpp */; }; + E07CADE91D58D44200567C5B /* base_cpp_interface_inheritance_impl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E07CADE71D58D44200567C5B /* base_cpp_interface_inheritance_impl.cpp */; }; + E07CADEC1D58D55800567C5B /* sub_cpp_interface_inheritance_impl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E07CADEA1D58D55800567C5B /* sub_cpp_interface_inheritance_impl.cpp */; }; + E0EFF6C51D58F68A003F6C91 /* DBInterfaceInheritanceTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = E0EFF6C41D58F68A003F6C91 /* DBInterfaceInheritanceTests.mm */; }; + E0EFF6CE1D590681003F6C91 /* DBInterfaceInheritanceConstant.mm in Sources */ = {isa = PBXBuildFile; fileRef = E0EFF6CB1D590681003F6C91 /* DBInterfaceInheritanceConstant.mm */; }; + E0EFF6CF1D590681003F6C91 /* DBInterfaceInheritanceConstant+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = E0EFF6CD1D590681003F6C91 /* DBInterfaceInheritanceConstant+Private.mm */; }; + E0EFF6D21D5906A2003F6C91 /* interface_encapsulator_impl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E0EFF6D01D5906A2003F6C91 /* interface_encapsulator_impl.cpp */; }; + E0EFF6D61D59070E003F6C91 /* interface_inheritance_constant.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E0EFF6D41D59070E003F6C91 /* interface_inheritance_constant.cpp */; }; + E0EFF6E01D5A02B5003F6C91 /* DBBaseCppInterfaceInheritance+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = E0EFF6D91D5A02B5003F6C91 /* DBBaseCppInterfaceInheritance+Private.mm */; }; + E0EFF6E21D5A02B5003F6C91 /* DBSubCppInterfaceInheritance+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = E0EFF6DF1D5A02B5003F6C91 /* DBSubCppInterfaceInheritance+Private.mm */; }; + E0EFF6EF1D5A07B7003F6C91 /* DBBaseObjcJavaInterfaceInheritance+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = E0EFF6E81D5A07B7003F6C91 /* DBBaseObjcJavaInterfaceInheritance+Private.mm */; }; + E0EFF6F01D5A07B7003F6C91 /* DBInterfaceEncapsulator+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = E0EFF6EB1D5A07B7003F6C91 /* DBInterfaceEncapsulator+Private.mm */; }; + E0EFF6F11D5A07B7003F6C91 /* DBSubObjcJavaInterfaceInheritance+Private.mm in Sources */ = {isa = PBXBuildFile; fileRef = E0EFF6EE1D5A07B7003F6C91 /* DBSubObjcJavaInterfaceInheritance+Private.mm */; }; + E0EFF6F71D5A09D8003F6C91 /* DBBaseObjcJavaInterfaceInheritanceImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = E0EFF6F61D5A09D8003F6C91 /* DBBaseObjcJavaInterfaceInheritanceImpl.m */; }; + E0EFF6FA1D5A0ACF003F6C91 /* DBSubObjcJavaInterfaceInheritanceImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = E0EFF6F91D5A0ACF003F6C91 /* DBSubObjcJavaInterfaceInheritanceImpl.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -398,6 +412,43 @@ CFFD58B01B041BD9001E10B6 /* DBConstantsInterface+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBConstantsInterface+Private.mm"; sourceTree = ""; }; CFFD58B51B041BFD001E10B6 /* constants_interface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = constants_interface.cpp; sourceTree = ""; }; CFFD58B61B041BFD001E10B6 /* constants_interface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = constants_interface.hpp; sourceTree = ""; }; + E07CADE71D58D44200567C5B /* base_cpp_interface_inheritance_impl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = base_cpp_interface_inheritance_impl.cpp; sourceTree = ""; }; + E07CADE81D58D44200567C5B /* base_cpp_interface_inheritance_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = base_cpp_interface_inheritance_impl.hpp; sourceTree = ""; }; + E07CADEA1D58D55800567C5B /* sub_cpp_interface_inheritance_impl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sub_cpp_interface_inheritance_impl.cpp; sourceTree = ""; }; + E07CADEB1D58D55800567C5B /* sub_cpp_interface_inheritance_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = sub_cpp_interface_inheritance_impl.hpp; sourceTree = ""; }; + E0EFF6C41D58F68A003F6C91 /* DBInterfaceInheritanceTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBInterfaceInheritanceTests.mm; sourceTree = ""; }; + E0EFF6CA1D590681003F6C91 /* DBInterfaceInheritanceConstant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBInterfaceInheritanceConstant.h; sourceTree = ""; }; + E0EFF6CB1D590681003F6C91 /* DBInterfaceInheritanceConstant.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DBInterfaceInheritanceConstant.mm; sourceTree = ""; }; + E0EFF6CC1D590681003F6C91 /* DBInterfaceInheritanceConstant+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBInterfaceInheritanceConstant+Private.h"; sourceTree = ""; }; + E0EFF6CD1D590681003F6C91 /* DBInterfaceInheritanceConstant+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBInterfaceInheritanceConstant+Private.mm"; sourceTree = ""; }; + E0EFF6D01D5906A2003F6C91 /* interface_encapsulator_impl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = interface_encapsulator_impl.cpp; sourceTree = ""; }; + E0EFF6D11D5906A2003F6C91 /* interface_encapsulator_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = interface_encapsulator_impl.hpp; sourceTree = ""; }; + E0EFF6D41D59070E003F6C91 /* interface_inheritance_constant.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = interface_inheritance_constant.cpp; sourceTree = ""; }; + E0EFF6D51D59070E003F6C91 /* interface_inheritance_constant.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = interface_inheritance_constant.hpp; sourceTree = ""; }; + E0EFF6D71D5A02B5003F6C91 /* DBBaseCppInterfaceInheritance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBBaseCppInterfaceInheritance.h; sourceTree = ""; }; + E0EFF6D81D5A02B5003F6C91 /* DBBaseCppInterfaceInheritance+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBBaseCppInterfaceInheritance+Private.h"; sourceTree = ""; }; + E0EFF6D91D5A02B5003F6C91 /* DBBaseCppInterfaceInheritance+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBBaseCppInterfaceInheritance+Private.mm"; sourceTree = ""; }; + E0EFF6DD1D5A02B5003F6C91 /* DBSubCppInterfaceInheritance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBSubCppInterfaceInheritance.h; sourceTree = ""; }; + E0EFF6DE1D5A02B5003F6C91 /* DBSubCppInterfaceInheritance+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBSubCppInterfaceInheritance+Private.h"; sourceTree = ""; }; + E0EFF6DF1D5A02B5003F6C91 /* DBSubCppInterfaceInheritance+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBSubCppInterfaceInheritance+Private.mm"; sourceTree = ""; }; + E0EFF6E31D5A02D5003F6C91 /* base_cpp_interface_inheritance.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = base_cpp_interface_inheritance.hpp; sourceTree = ""; }; + E0EFF6E51D5A02D5003F6C91 /* sub_cpp_interface_inheritance.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = sub_cpp_interface_inheritance.hpp; sourceTree = ""; }; + E0EFF6E61D5A07B7003F6C91 /* DBBaseObjcJavaInterfaceInheritance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBBaseObjcJavaInterfaceInheritance.h; sourceTree = ""; }; + E0EFF6E71D5A07B7003F6C91 /* DBBaseObjcJavaInterfaceInheritance+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBBaseObjcJavaInterfaceInheritance+Private.h"; sourceTree = ""; }; + E0EFF6E81D5A07B7003F6C91 /* DBBaseObjcJavaInterfaceInheritance+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBBaseObjcJavaInterfaceInheritance+Private.mm"; sourceTree = ""; }; + E0EFF6E91D5A07B7003F6C91 /* DBInterfaceEncapsulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBInterfaceEncapsulator.h; sourceTree = ""; }; + E0EFF6EA1D5A07B7003F6C91 /* DBInterfaceEncapsulator+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBInterfaceEncapsulator+Private.h"; sourceTree = ""; }; + E0EFF6EB1D5A07B7003F6C91 /* DBInterfaceEncapsulator+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBInterfaceEncapsulator+Private.mm"; sourceTree = ""; }; + E0EFF6EC1D5A07B7003F6C91 /* DBSubObjcJavaInterfaceInheritance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBSubObjcJavaInterfaceInheritance.h; sourceTree = ""; }; + E0EFF6ED1D5A07B7003F6C91 /* DBSubObjcJavaInterfaceInheritance+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DBSubObjcJavaInterfaceInheritance+Private.h"; sourceTree = ""; }; + E0EFF6EE1D5A07B7003F6C91 /* DBSubObjcJavaInterfaceInheritance+Private.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "DBSubObjcJavaInterfaceInheritance+Private.mm"; sourceTree = ""; }; + E0EFF6F21D5A07CC003F6C91 /* base_objc_java_interface_inheritance.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = base_objc_java_interface_inheritance.hpp; sourceTree = ""; }; + E0EFF6F31D5A07CC003F6C91 /* interface_encapsulator.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = interface_encapsulator.hpp; sourceTree = ""; }; + E0EFF6F41D5A07CC003F6C91 /* sub_objc_java_interface_inheritance.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = sub_objc_java_interface_inheritance.hpp; sourceTree = ""; }; + E0EFF6F51D5A09D8003F6C91 /* DBBaseObjcJavaInterfaceInheritanceImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBBaseObjcJavaInterfaceInheritanceImpl.h; sourceTree = ""; }; + E0EFF6F61D5A09D8003F6C91 /* DBBaseObjcJavaInterfaceInheritanceImpl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBBaseObjcJavaInterfaceInheritanceImpl.m; sourceTree = ""; }; + E0EFF6F81D5A0ACF003F6C91 /* DBSubObjcJavaInterfaceInheritanceImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBSubObjcJavaInterfaceInheritanceImpl.h; sourceTree = ""; }; + E0EFF6F91D5A0ACF003F6C91 /* DBSubObjcJavaInterfaceInheritanceImpl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBSubObjcJavaInterfaceInheritanceImpl.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -442,6 +493,10 @@ children = ( 6536CD7119A6C96C00DD7715 /* DBClientInterfaceImpl.h */, 6536CD7219A6C96C00DD7715 /* DBClientInterfaceImpl.mm */, + E0EFF6F51D5A09D8003F6C91 /* DBBaseObjcJavaInterfaceInheritanceImpl.h */, + E0EFF6F61D5A09D8003F6C91 /* DBBaseObjcJavaInterfaceInheritanceImpl.m */, + E0EFF6F81D5A0ACF003F6C91 /* DBSubObjcJavaInterfaceInheritanceImpl.h */, + E0EFF6F91D5A0ACF003F6C91 /* DBSubObjcJavaInterfaceInheritanceImpl.m */, ); name = "handwritten-objc"; path = "../handwritten-src/objc/impl"; @@ -464,6 +519,12 @@ A278D45219BA3601006FD937 /* test_helpers.cpp */, CFC5D9FB1B152E4300BF2DF8 /* TranslateDuration.cpp */, 6551684E1C40511C003682A4 /* return_one_two.cpp */, + E07CADE71D58D44200567C5B /* base_cpp_interface_inheritance_impl.cpp */, + E07CADE81D58D44200567C5B /* base_cpp_interface_inheritance_impl.hpp */, + E07CADEA1D58D55800567C5B /* sub_cpp_interface_inheritance_impl.cpp */, + E07CADEB1D58D55800567C5B /* sub_cpp_interface_inheritance_impl.hpp */, + E0EFF6D01D5906A2003F6C91 /* interface_encapsulator_impl.cpp */, + E0EFF6D11D5906A2003F6C91 /* interface_encapsulator_impl.hpp */, ); name = "handwritten-cpp"; path = "../handwritten-src/cpp"; @@ -489,6 +550,7 @@ A200940E1B0697D300EF8D9B /* DBTokenTests.mm */, 6536CD8419A6C99800DD7715 /* DjinniObjcTestTests-Info.plist */, 6536CD8219A6C99800DD7715 /* InfoPlist.strings */, + E0EFF6C41D58F68A003F6C91 /* DBInterfaceInheritanceTests.mm */, ); name = Tests; path = "../handwritten-src/objc/tests"; @@ -571,6 +633,25 @@ B5F06A7F1D4973BD005BE736 /* DBObjcOnlyListener.h */, B5F06A801D4973BD005BE736 /* DBObjcOnlyListener+Private.h */, B5F06A811D4973BD005BE736 /* DBObjcOnlyListener+Private.mm */, + E0EFF6E61D5A07B7003F6C91 /* DBBaseObjcJavaInterfaceInheritance.h */, + E0EFF6E71D5A07B7003F6C91 /* DBBaseObjcJavaInterfaceInheritance+Private.h */, + E0EFF6E81D5A07B7003F6C91 /* DBBaseObjcJavaInterfaceInheritance+Private.mm */, + E0EFF6E91D5A07B7003F6C91 /* DBInterfaceEncapsulator.h */, + E0EFF6EA1D5A07B7003F6C91 /* DBInterfaceEncapsulator+Private.h */, + E0EFF6EB1D5A07B7003F6C91 /* DBInterfaceEncapsulator+Private.mm */, + E0EFF6EC1D5A07B7003F6C91 /* DBSubObjcJavaInterfaceInheritance.h */, + E0EFF6ED1D5A07B7003F6C91 /* DBSubObjcJavaInterfaceInheritance+Private.h */, + E0EFF6EE1D5A07B7003F6C91 /* DBSubObjcJavaInterfaceInheritance+Private.mm */, + E0EFF6D71D5A02B5003F6C91 /* DBBaseCppInterfaceInheritance.h */, + E0EFF6D81D5A02B5003F6C91 /* DBBaseCppInterfaceInheritance+Private.h */, + E0EFF6D91D5A02B5003F6C91 /* DBBaseCppInterfaceInheritance+Private.mm */, + E0EFF6DD1D5A02B5003F6C91 /* DBSubCppInterfaceInheritance.h */, + E0EFF6DE1D5A02B5003F6C91 /* DBSubCppInterfaceInheritance+Private.h */, + E0EFF6DF1D5A02B5003F6C91 /* DBSubCppInterfaceInheritance+Private.mm */, + E0EFF6CA1D590681003F6C91 /* DBInterfaceInheritanceConstant.h */, + E0EFF6CB1D590681003F6C91 /* DBInterfaceInheritanceConstant.mm */, + E0EFF6CC1D590681003F6C91 /* DBInterfaceInheritanceConstant+Private.h */, + E0EFF6CD1D590681003F6C91 /* DBInterfaceInheritanceConstant+Private.mm */, B5D8FC321C23E2F40045ADCF /* DBConstantRecord.h */, B5D8FC331C23E2F40045ADCF /* DBConstantRecord.mm */, B5D8FC341C23E2F40045ADCF /* DBConstantRecord+Private.h */, @@ -700,6 +781,13 @@ B5F06A6A1D497396005BE736 /* java_only_listener.hpp */, B5F06A6B1D497396005BE736 /* objc_only_listener.hpp */, B5F06A6C1D497396005BE736 /* uses_single_language_listeners.hpp */, + E0EFF6F21D5A07CC003F6C91 /* base_objc_java_interface_inheritance.hpp */, + E0EFF6F31D5A07CC003F6C91 /* interface_encapsulator.hpp */, + E0EFF6F41D5A07CC003F6C91 /* sub_objc_java_interface_inheritance.hpp */, + E0EFF6E31D5A02D5003F6C91 /* base_cpp_interface_inheritance.hpp */, + E0EFF6E51D5A02D5003F6C91 /* sub_cpp_interface_inheritance.hpp */, + E0EFF6D41D59070E003F6C91 /* interface_inheritance_constant.cpp */, + E0EFF6D51D59070E003F6C91 /* interface_inheritance_constant.hpp */, B5D8FC381C23E30D0045ADCF /* constant_record.hpp */, B5E9C93C1C1F9DCA0073C123 /* reverse_client_interface.hpp */, B52DA56C1B103FBE005CE75F /* assorted_primitives.cpp */, @@ -833,9 +921,11 @@ CFAED8761B54291900E3B8A3 /* DBEmptyRecord+Private.mm in Sources */, 655168421C404B81003682A4 /* DBFirstListener+Private.mm in Sources */, A24850271AF96EBC00AFE907 /* DBClientReturnedRecord.mm in Sources */, + E0EFF6FA1D5A0ACF003F6C91 /* DBSubObjcJavaInterfaceInheritanceImpl.m in Sources */, CFC5D9D61B15106400BF2DF8 /* DBExternRecordWithDerivings.mm in Sources */, CFC5DA0E1B15330000BF2DF8 /* record_with_duration_and_derivings.cpp in Sources */, A238CA941AF84B7100CDDCE5 /* DBMapDateRecord+Private.mm in Sources */, + E0EFF6D21D5906A2003F6C91 /* interface_encapsulator_impl.cpp in Sources */, CFFD588F1B019E79001E10B6 /* DBTestHelpers+Private.mm in Sources */, A24850291AF96EBC00AFE907 /* DBDateRecord.mm in Sources */, A278D45319BA3601006FD937 /* test_helpers.cpp in Sources */, @@ -862,8 +952,11 @@ B52DA5691B103F72005CE75F /* DBAssortedPrimitives.mm in Sources */, A24850281AF96EBC00AFE907 /* DBConstants.mm in Sources */, 655168431C404B81003682A4 /* DBSecondListener+Private.mm in Sources */, + E0EFF6E01D5A02B5003F6C91 /* DBBaseCppInterfaceInheritance+Private.mm in Sources */, CFFD58B71B041BFD001E10B6 /* constants_interface.cpp in Sources */, CFAED8751B54291900E3B8A3 /* DBEmptyRecord.mm in Sources */, + E07CADEC1D58D55800567C5B /* sub_cpp_interface_inheritance_impl.cpp in Sources */, + E0EFF6EF1D5A07B7003F6C91 /* DBBaseObjcJavaInterfaceInheritance+Private.mm in Sources */, A238CA9A1AF84B7100CDDCE5 /* DBNestedCollection+Private.mm in Sources */, CFFD58911B019E79001E10B6 /* DBUserToken+Private.mm in Sources */, B5153F9A1D54284100012654 /* DBJavaOnlyListener+Private.mm in Sources */, @@ -880,6 +973,7 @@ B5F06A861D4973BD005BE736 /* DBConflictUser+Private.mm in Sources */, B5E9C93B1C1F9D9D0073C123 /* reverse_client_interface_impl.cpp in Sources */, CFC5D9D81B15106400BF2DF8 /* DBExternRecordWithDerivings+Private.mm in Sources */, + E0EFF6CF1D590681003F6C91 /* DBInterfaceInheritanceConstant+Private.mm in Sources */, A238CAA21AF84B7100CDDCE5 /* DBSetRecord+Private.mm in Sources */, A2AE38491BB3074800B7A0C9 /* DJIProxyCaches.mm in Sources */, A238CA9E1AF84B7100CDDCE5 /* DBRecordWithDerivings+Private.mm in Sources */, @@ -894,6 +988,7 @@ 650CA05E1C2AB5AB007ADDDB /* ListenerCaller.cpp in Sources */, A248502A1AF96EBC00AFE907 /* DBMapDateRecord.mm in Sources */, B5F06A6D1D497396005BE736 /* extended_record_base.cpp in Sources */, + E0EFF6F71D5A09D8003F6C91 /* DBBaseObjcJavaInterfaceInheritanceImpl.m in Sources */, A238CA8E1AF84B7100CDDCE5 /* DBClientReturnedRecord+Private.mm in Sources */, B5F06A8A1D4973BD005BE736 /* DBExtendedRecord+Private.mm in Sources */, 6551684D1C4050A4003682A4 /* DBReturnTwo+Private.mm in Sources */, @@ -904,9 +999,16 @@ A248502E1AF96EBC00AFE907 /* DBPrimitiveList.mm in Sources */, B5F06A8C1D4973BD005BE736 /* DBObjcOnlyListener+Private.mm in Sources */, B5153F961D54283700012654 /* DBUsesSingleLanguageListeners+Private.mm in Sources */, + E07CADE91D58D44200567C5B /* base_cpp_interface_inheritance_impl.cpp in Sources */, + A209B57A1BBA2A0A0070C310 /* DBOptColorRecord+Private.mm in Sources */, B5D8FC371C23E2F40045ADCF /* DBConstantRecord+Private.mm in Sources */, B519111B1D542B0700772DFE /* wchar_test_helpers.cpp in Sources */, + E0EFF6D61D59070E003F6C91 /* interface_inheritance_constant.cpp in Sources */, + E0EFF6E21D5A02B5003F6C91 /* DBSubCppInterfaceInheritance+Private.mm in Sources */, + E0EFF6F01D5A07B7003F6C91 /* DBInterfaceEncapsulator+Private.mm in Sources */, A238CAA01AF84B7100CDDCE5 /* DBRecordWithNestedDerivings+Private.mm in Sources */, + E0EFF6F11D5A07B7003F6C91 /* DBSubObjcJavaInterfaceInheritance+Private.mm in Sources */, + E0EFF6CE1D590681003F6C91 /* DBInterfaceInheritanceConstant.mm in Sources */, CFC5DA0A1B1532F600BF2DF8 /* DBRecordWithDurationAndDerivings+Private.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -945,6 +1047,7 @@ CFC5D9F31B15276900BF2DF8 /* DBDurationTests.m in Sources */, CFC5D9EB1B1513E800BF2DF8 /* DBExternInterface2+Private.mm in Sources */, CFC5DA0B1B1532F600BF2DF8 /* DBRecordWithDurationAndDerivings+Private.mm in Sources */, + E0EFF6C51D58F68A003F6C91 /* DBInterfaceInheritanceTests.mm in Sources */, CFC5D9E91B1513E800BF2DF8 /* DBExternInterface1+Private.mm in Sources */, 6536CD9419A6C9A800DD7715 /* DBSetRecordTests.mm in Sources */, CFC5D9D91B15106400BF2DF8 /* DBExternRecordWithDerivings+Private.mm in Sources */,