Commit 3af6aaf2 authored by Kenny Kaye's avatar Kenny Kaye

Merge remote-tracking branch 'upstream/master' into kkaye/include-paths

parents d6ce6382 96d8b444
...@@ -45,7 +45,7 @@ example_ios: ./build_ios/example/libtextsort.xcodeproj ...@@ -45,7 +45,7 @@ example_ios: ./build_ios/example/libtextsort.xcodeproj
-scheme TextSort \ -scheme TextSort \
-configuration 'Debug' \ -configuration 'Debug' \
-sdk iphonesimulator \ -sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.1'
# this target implicitly depends on GypAndroid.mk since gradle will try to make it # this target implicitly depends on GypAndroid.mk since gradle will try to make it
example_android: GypAndroid.mk example_android: GypAndroid.mk
......
...@@ -428,7 +428,6 @@ Run `make test` to invoke the test suite, found in the test-suite subdirectory. ...@@ -428,7 +428,6 @@ Run `make test` to invoke the test suite, found in the test-suite subdirectory.
* [Slides](https://bit.ly/djinnitalk2) and [video](https://bit.ly/djinnivideo2) from the CppCon 2015 about Djinni implementatino techniques, and the addition of Python. * [Slides](https://bit.ly/djinnitalk2) and [video](https://bit.ly/djinnivideo2) from the CppCon 2015 about Djinni implementatino techniques, and the addition of Python.
* You can see a [CppCon 2014 talk](https://www.youtube.com/watch?v=5AZMEm3rZ2Y) by app developers at Dropbox about their cross-platform experiences. * You can see a [CppCon 2014 talk](https://www.youtube.com/watch?v=5AZMEm3rZ2Y) by app developers at Dropbox about their cross-platform experiences.
## Authors ## Authors
- Kannan Goundan - Kannan Goundan
- Tony Grue - Tony Grue
...@@ -439,5 +438,5 @@ Run `make test` to invoke the test suite, found in the test-suite subdirectory. ...@@ -439,5 +438,5 @@ Run `make test` to invoke the test suite, found in the test-suite subdirectory.
- Andrew Twyman - Andrew Twyman
## Contacts ## Contacts
- Jacob Potter - `djinni@j4cbo.com`
- Andrew Twyman - `atwyman@dropbox.com` - Andrew Twyman - `atwyman@dropbox.com`
- Jacob Potter - `djinni@j4cbo.com`
...@@ -7,7 +7,7 @@ import java.util.ArrayList; ...@@ -7,7 +7,7 @@ import java.util.ArrayList;
import javax.annotation.CheckForNull; import javax.annotation.CheckForNull;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public final class ItemList { /*package*/ final class ItemList {
/*package*/ final ArrayList<String> mItems; /*package*/ final ArrayList<String> mItems;
......
...@@ -7,7 +7,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -7,7 +7,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.CheckForNull; import javax.annotation.CheckForNull;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public abstract class SortItems { /*package*/ abstract class SortItems {
/** For the iOS / Android demo */ /** For the iOS / Android demo */
public abstract void sort(@Nonnull SortOrder order, @Nonnull ItemList items); public abstract void sort(@Nonnull SortOrder order, @Nonnull ItemList items);
......
...@@ -6,7 +6,7 @@ package com.dropbox.textsort; ...@@ -6,7 +6,7 @@ package com.dropbox.textsort;
import javax.annotation.CheckForNull; import javax.annotation.CheckForNull;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public enum SortOrder { /*package*/ enum SortOrder {
ASCENDING, ASCENDING,
DESCENDING, DESCENDING,
RANDOM, RANDOM,
......
...@@ -6,6 +6,6 @@ package com.dropbox.textsort; ...@@ -6,6 +6,6 @@ package com.dropbox.textsort;
import javax.annotation.CheckForNull; import javax.annotation.CheckForNull;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public abstract class TextboxListener { /*package*/ abstract class TextboxListener {
public abstract void update(@Nonnull ItemList items); public abstract void update(@Nonnull ItemList items);
} }
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "NativeSortItems.hpp" // my header #include "NativeSortItems.hpp" // my header
#include "NativeItemList.hpp" #include "NativeItemList.hpp"
#include "NativeSortItems.hpp"
#include "NativeSortOrder.hpp" #include "NativeSortOrder.hpp"
#include "NativeTextboxListener.hpp" #include "NativeTextboxListener.hpp"
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
#import "TXSSortItems.h" #import "TXSSortItems.h"
#import "DJICppWrapperCache+Private.h" #import "DJICppWrapperCache+Private.h"
#import "DJIError.h" #import "DJIError.h"
#import "DJIMarshal+Private.h"
#import "TXSItemList+Private.h" #import "TXSItemList+Private.h"
#import "TXSSortItems+Private.h" #import "TXSSortOrder+Private.h"
#import "TXSTextboxListener+Private.h" #import "TXSTextboxListener+Private.h"
#include <exception> #include <exception>
#include <stdexcept>
#include <utility> #include <utility>
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
...@@ -42,15 +42,15 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th ...@@ -42,15 +42,15 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
+ (nullable TXSSortItems *)createWithListener:(nullable id<TXSTextboxListener>)listener { + (nullable TXSSortItems *)createWithListener:(nullable id<TXSTextboxListener>)listener {
try { try {
auto r = ::textsort::SortItems::create_with_listener(::djinni_generated::TextboxListener::toCpp(listener)); auto objcpp_result_ = ::textsort::SortItems::create_with_listener(::djinni_generated::TextboxListener::toCpp(listener));
return ::djinni_generated::SortItems::fromCpp(r); return ::djinni_generated::SortItems::fromCpp(objcpp_result_);
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
+ (nonnull TXSItemList *)runSort:(nonnull TXSItemList *)items { + (nonnull TXSItemList *)runSort:(nonnull TXSItemList *)items {
try { try {
auto r = ::textsort::SortItems::run_sort(::djinni_generated::ItemList::toCpp(items)); auto objcpp_result_ = ::textsort::SortItems::run_sort(::djinni_generated::ItemList::toCpp(items));
return ::djinni_generated::ItemList::fromCpp(r); return ::djinni_generated::ItemList::fromCpp(objcpp_result_);
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from example.djinni
#include "sort_order.hpp"
#import "DJIMarshal+Private.h"
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "TXSTextboxListener.h" #import "TXSTextboxListener.h"
#import "DJIObjcWrapperCache+Private.h" #import "DJIObjcWrapperCache+Private.h"
#import "TXSItemList+Private.h" #import "TXSItemList+Private.h"
#include <stdexcept>
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
......
...@@ -53,6 +53,7 @@ fi ...@@ -53,6 +53,7 @@ fi
"$base_dir/../src/run-assume-built" \ "$base_dir/../src/run-assume-built" \
--java-out "$temp_out/java" \ --java-out "$temp_out/java" \
--java-package $java_package \ --java-package $java_package \
--java-class-access-modifier "package" \
--java-nullable-annotation "javax.annotation.CheckForNull" \ --java-nullable-annotation "javax.annotation.CheckForNull" \
--java-nonnull-annotation "javax.annotation.Nonnull" \ --java-nonnull-annotation "javax.annotation.Nonnull" \
--ident-java-field mFooBar \ --ident-java-field mFooBar \
......
...@@ -15,12 +15,28 @@ ...@@ -15,12 +15,28 @@
--> -->
<idea-plugin version="2"> <idea-plugin version="2">
<id>com.dropbox.djinni.ideaplugin</id> <id>com.dropbox.djinni.ideaplugin</id>
<name>Djinni interface definition language file support</name> <name>Djinni IDL file support</name>
<version>0.8</version> <version>0.8</version>
<vendor email="jaetzold@dropbox.com" url="http://www.dropbox.com">Dropbox</vendor> <vendor url="https://github.com/dropbox/djinni">Dropbox Djinni Github Project</vendor>
<description><![CDATA[ <description><![CDATA[
Add some basic navigation, code-completion and error highlighting support to .djinni files. Add some basic navigation, code-completion and error highlighting support to .djinni files.
<h4>License</h4>
Copyright 2015-2016 Dropbox, Inc.<br/>
<br/>
Licensed under the Apache License, Version 2.0 (the "License");<br/>
you may not use this file except in compliance with the License.<br/>
You may obtain a copy of the License at<br/>
<br/>
&nbsp;&nbsp;<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a><br/>
<br/>
Unless required by applicable law or agreed to in writing, software<br/>
distributed under the License is distributed on an "AS IS" BASIS,<br/>
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br/>
See the License for the specific language governing permissions and<br/>
limitations under the License.
]]></description> ]]></description>
<change-notes><![CDATA[ <change-notes><![CDATA[
...@@ -29,7 +45,7 @@ ...@@ -29,7 +45,7 @@
</change-notes> </change-notes>
<!-- please see https://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description --> <!-- please see https://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
<idea-version since-build="131"/> <idea-version since-build="139"/>
<!-- please see https://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products <!-- please see https://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
on how to target different products --> on how to target different products -->
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
<file url="PROJECT" charset="UTF-8" />
</component>
</project> </project>
\ No newline at end of file
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
<option name="sbtVersion" value="0.13.5" /> <option name="sbtVersion" value="0.13.5" />
<option name="useAutoImport" value="true" /> <option name="useAutoImport" value="true" />
<option name="useOurOwnAutoImport" value="true" /> <option name="useOurOwnAutoImport" value="true" />
<option name="myModules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/project" />
</set>
</option>
</SbtProjectSettings> </SbtProjectSettings>
</option> </option>
</component> </component>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" /> <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -59,18 +59,18 @@ class CppMarshal(spec: Spec) extends Marshal(spec) { ...@@ -59,18 +59,18 @@ class CppMarshal(spec: Spec) extends Marshal(spec) {
case MList => List(ImportRef("<vector>")) case MList => List(ImportRef("<vector>"))
case MSet => List(ImportRef("<unordered_set>")) case MSet => List(ImportRef("<unordered_set>"))
case MMap => List(ImportRef("<unordered_map>")) case MMap => List(ImportRef("<unordered_map>"))
case d: MDef => d.defType match { case d: MDef => d.body match {
case DRecord => case r: Record =>
if (d.name != exclude) { if (d.name != exclude) {
if (forwardDeclareOnly) { if (forwardDeclareOnly) {
List(DeclRef(s"struct ${typename(d.name, d.body)};", Some(spec.cppNamespace))) List(DeclRef(s"struct ${typename(d.name, d.body)};", Some(spec.cppNamespace)))
} else { } else {
List(ImportRef(include(d.name))) List(ImportRef(include(d.name, r.ext.cpp)))
} }
} else { } else {
List() List()
} }
case DEnum => case e: Enum =>
if (d.name != exclude) { if (d.name != exclude) {
if (forwardDeclareOnly) { if (forwardDeclareOnly) {
List(DeclRef(s"enum class ${typename(d.name, d.body)};", Some(spec.cppNamespace))) List(DeclRef(s"enum class ${typename(d.name, d.body)};", Some(spec.cppNamespace)))
...@@ -80,7 +80,7 @@ class CppMarshal(spec: Spec) extends Marshal(spec) { ...@@ -80,7 +80,7 @@ class CppMarshal(spec: Spec) extends Marshal(spec) {
} else { } else {
List() List()
} }
case DInterface => case i: Interface =>
val base = if (d.name != exclude) { val base = if (d.name != exclude) {
List(ImportRef("<memory>"), DeclRef(s"class ${typename(d.name, d.body)};", Some(spec.cppNamespace))) List(ImportRef("<memory>"), DeclRef(s"class ${typename(d.name, d.body)};", Some(spec.cppNamespace)))
} else { } else {
...@@ -106,14 +106,14 @@ class CppMarshal(spec: Spec) extends Marshal(spec) { ...@@ -106,14 +106,14 @@ class CppMarshal(spec: Spec) extends Marshal(spec) {
List() List()
} else { } else {
m match { m match {
case d: MDef => d.defType match { case d: MDef => d.body match {
case DRecord => case r: Record =>
if (d.name != exclude) { if (d.name != exclude) {
List(ImportRef(include(d.name))) List(ImportRef(include(d.name, r.ext.cpp)))
} else { } else {
List() List()
} }
case DEnum => case e: Enum =>
if (d.name != exclude) { if (d.name != exclude) {
List(ImportRef(include(d.name))) List(ImportRef(include(d.name)))
} else { } else {
...@@ -126,7 +126,10 @@ class CppMarshal(spec: Spec) extends Marshal(spec) { ...@@ -126,7 +126,10 @@ class CppMarshal(spec: Spec) extends Marshal(spec) {
} }
} }
def include(ident: String): String = q(spec.cppIncludePrefix + spec.cppFileIdentStyle(ident) + "." + spec.cppHeaderExt) def include(ident: String, isExtendedRecord: Boolean = false): String = {
val prefix = if (isExtendedRecord) spec.cppExtendedRecordIncludePrefix else spec.cppIncludePrefix
q(prefix + spec.cppFileIdentStyle (ident) + "." + spec.cppHeaderExt)
}
private def toCppType(ty: TypeRef, namespace: Option[String] = None, scopeSymbols: Seq[String] = Seq()): String = private def toCppType(ty: TypeRef, namespace: Option[String] = None, scopeSymbols: Seq[String] = Seq()): String =
toCppType(ty.resolved, namespace, scopeSymbols) toCppType(ty.resolved, namespace, scopeSymbols)
...@@ -145,7 +148,7 @@ class CppMarshal(spec: Spec) extends Marshal(spec) { ...@@ -145,7 +148,7 @@ class CppMarshal(spec: Spec) extends Marshal(spec) {
} }
def base(m: Meta): String = m match { def base(m: Meta): String = m match {
case p: MPrimitive => p.cName 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 MDate => "std::chrono::system_clock::time_point"
case MBinary => "std::vector<uint8_t>" case MBinary => "std::vector<uint8_t>"
case MOptional => spec.cppOptionalTemplate case MOptional => spec.cppOptionalTemplate
......
...@@ -35,11 +35,12 @@ class JNIGenerator(spec: Spec) extends Generator(spec) { ...@@ -35,11 +35,12 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
def writeJniHppFile(name: String, origin: String, includes: Iterable[String], fwds: Iterable[String], f: IndentWriter => Unit, f2: IndentWriter => Unit = (w => {})) = def writeJniHppFile(name: String, origin: String, includes: Iterable[String], fwds: Iterable[String], f: IndentWriter => Unit, f2: IndentWriter => Unit = (w => {})) =
writeHppFileGeneric(spec.jniHeaderOutFolder.get, spec.jniNamespace, spec.jniFileIdentStyle)(name, origin, includes, fwds, f, f2) writeHppFileGeneric(spec.jniHeaderOutFolder.get, spec.jniNamespace, spec.jniFileIdentStyle)(name, origin, includes, fwds, f, f2)
class JNIRefs(name: String) { class JNIRefs(name: String, cppPrefixOverride: Option[String]=None) {
var jniHpp = mutable.TreeSet[String]() var jniHpp = mutable.TreeSet[String]()
var jniCpp = mutable.TreeSet[String]() var jniCpp = mutable.TreeSet[String]()
jniHpp.add("#include " + q(spec.jniIncludeCppPrefix + spec.cppFileIdentStyle(name) + "." + spec.cppHeaderExt)) val cppPrefix = cppPrefixOverride.getOrElse(spec.jniIncludeCppPrefix)
jniHpp.add("#include " + q(cppPrefix + spec.cppFileIdentStyle(name) + "." + spec.cppHeaderExt))
jniHpp.add("#include " + q(spec.jniBaseLibIncludePrefix + "djinni_support.hpp")) jniHpp.add("#include " + q(spec.jniBaseLibIncludePrefix + "djinni_support.hpp"))
spec.cppNnHeader match { spec.cppNnHeader match {
case Some(nnHdr) => jniHpp.add("#include " + nnHdr) case Some(nnHdr) => jniHpp.add("#include " + nnHdr)
...@@ -82,7 +83,12 @@ class JNIGenerator(spec: Spec) extends Generator(spec) { ...@@ -82,7 +83,12 @@ class JNIGenerator(spec: Spec) extends Generator(spec) {
} }
override def generateRecord(origin: String, ident: Ident, doc: Doc, params: Seq[TypeParam], r: Record) { override def generateRecord(origin: String, ident: Ident, doc: Doc, params: Seq[TypeParam], r: Record) {
val refs = new JNIRefs(ident.name) val prefixOverride: Option[String] = if (r.ext.cpp) {
Some(spec.cppExtendedRecordIncludePrefix)
} else {
None
}
val refs = new JNIRefs(ident.name, prefixOverride)
r.fields.foreach(f => refs.find(f.ty)) r.fields.foreach(f => refs.find(f.ty))
val jniHelper = jniMarshal.helperClass(ident) val jniHelper = jniMarshal.helperClass(ident)
......
...@@ -98,7 +98,7 @@ class JNIMarshal(spec: Spec) extends Marshal(spec) { ...@@ -98,7 +98,7 @@ class JNIMarshal(spec: Spec) extends Marshal(spec) {
} }
case MOptional => "Optional" case MOptional => "Optional"
case MBinary => "Binary" case MBinary => "Binary"
case MString => "String" case MString => if (spec.cppUseWideStrings) "WString" else "String"
case MDate => "Date" case MDate => "Date"
case MList => "List" case MList => "List"
case MSet => "Set" case MSet => "Set"
......
...@@ -29,6 +29,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { ...@@ -29,6 +29,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) {
val javaAnnotationHeader = spec.javaAnnotation.map(pkg => '@' + pkg.split("\\.").last) val javaAnnotationHeader = spec.javaAnnotation.map(pkg => '@' + pkg.split("\\.").last)
val javaNullableAnnotation = spec.javaNullableAnnotation.map(pkg => '@' + pkg.split("\\.").last) val javaNullableAnnotation = spec.javaNullableAnnotation.map(pkg => '@' + pkg.split("\\.").last)
val javaNonnullAnnotation = spec.javaNonnullAnnotation.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) val marshal = new JavaMarshal(spec)
class JavaRefs() { class JavaRefs() {
...@@ -109,7 +110,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { ...@@ -109,7 +110,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) {
writeJavaFile(ident, origin, refs.java, w => { writeJavaFile(ident, origin, refs.java, w => {
writeDoc(w, doc) writeDoc(w, doc)
javaAnnotationHeader.foreach(w.wl) 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) { for (o <- e.options) {
writeDoc(w, o.doc) writeDoc(w, o.doc)
w.wl(idJava.enum(o.ident) + ",") w.wl(idJava.enum(o.ident) + ",")
...@@ -139,7 +140,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { ...@@ -139,7 +140,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) {
writeDoc(w, doc) writeDoc(w, doc)
javaAnnotationHeader.foreach(w.wl) javaAnnotationHeader.foreach(w.wl)
w.w(s"public abstract class $javaClass$typeParamList").braced { w.w(s"${javaClassAccessModifierString}abstract class $javaClass$typeParamList").braced {
val skipFirst = SkipFirst() val skipFirst = SkipFirst()
generateJavaConstants(w, i.consts) generateJavaConstants(w, i.consts)
...@@ -212,7 +213,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { ...@@ -212,7 +213,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) {
r.fields.foreach(f => refs.find(f.ty)) r.fields.foreach(f => refs.find(f.ty))
val javaName = if (r.ext.java) (ident.name + "_base") else ident.name 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 => { writeJavaFile(javaName, origin, refs.java, w => {
writeDoc(w, doc) writeDoc(w, doc)
...@@ -225,7 +226,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) { ...@@ -225,7 +226,7 @@ class JavaGenerator(spec: Spec) extends Generator(spec) {
} else { } 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 w.wl
generateJavaConstants(w, r.consts) generateJavaConstants(w, r.consts)
// Field definitions. // Field definitions.
......
...@@ -36,8 +36,10 @@ object Main { ...@@ -36,8 +36,10 @@ object Main {
var cppNnHeader: Option[String] = None var cppNnHeader: Option[String] = None
var cppNnType: Option[String] = None var cppNnType: Option[String] = None
var cppNnCheckExpression: Option[String] = None var cppNnCheckExpression: Option[String] = None
var cppUseWideStrings: Boolean = false
var javaOutFolder: Option[File] = None var javaOutFolder: Option[File] = None
var javaPackage: Option[String] = None var javaPackage: Option[String] = None
var javaClassAccessModifier: JavaAccessModifier.Value = JavaAccessModifier.Public
var javaCppException: Option[String] = None var javaCppException: Option[String] = None
var javaAnnotation: Option[String] = None var javaAnnotation: Option[String] = None
var javaNullableAnnotation: Option[String] = None var javaNullableAnnotation: Option[String] = None
...@@ -101,6 +103,8 @@ object Main { ...@@ -101,6 +103,8 @@ object Main {
.text("The output for the Java files (Generator disabled if unspecified).") .text("The output for the Java files (Generator disabled if unspecified).")
opt[String]("java-package").valueName("...").foreach(x => javaPackage = Some(x)) opt[String]("java-package").valueName("...").foreach(x => javaPackage = Some(x))
.text("The package name to use for generated Java classes.") .text("The package name to use for generated Java classes.")
opt[JavaAccessModifier.Value]("java-class-access-modifier").valueName("<public/package>").foreach(x => javaClassAccessModifier = x)
.text("The access modifier to use for generated Java classes (default: public).")
opt[String]("java-cpp-exception").valueName("<exception-class>").foreach(x => javaCppException = Some(x)) opt[String]("java-cpp-exception").valueName("<exception-class>").foreach(x => javaCppException = Some(x))
.text("The type for translated C++ exceptions in Java (default: java.lang.RuntimeException that is not checked)") .text("The type for translated C++ exceptions in Java (default: java.lang.RuntimeException that is not checked)")
opt[String]("java-annotation").valueName("<annotation-class>").foreach(x => javaAnnotation = Some(x)) opt[String]("java-annotation").valueName("<annotation-class>").foreach(x => javaAnnotation = Some(x))
...@@ -136,6 +140,8 @@ object Main { ...@@ -136,6 +140,8 @@ object Main {
.text("The type to use for non-nullable pointers (as a substitute for std::shared_ptr)") .text("The type to use for non-nullable pointers (as a substitute for std::shared_ptr)")
opt[String]("cpp-nn-check-expression").valueName("<header>").foreach(x => cppNnCheckExpression = Some(x)) opt[String]("cpp-nn-check-expression").valueName("<header>").foreach(x => cppNnCheckExpression = Some(x))
.text("The expression to use for building non-nullable pointers") .text("The expression to use for building non-nullable pointers")
opt[Boolean]( "cpp-use-wide-strings").valueName("<true/false>").foreach(x => cppUseWideStrings = x)
.text("Use wide strings in C++ code (default: false)")
note("") note("")
opt[File]("jni-out").valueName("<out-folder>").foreach(x => jniOutFolder = Some(x)) opt[File]("jni-out").valueName("<out-folder>").foreach(x => jniOutFolder = Some(x))
.text("The folder for the JNI C++ output files (Generator disabled if unspecified).") .text("The folder for the JNI C++ output files (Generator disabled if unspecified).")
...@@ -238,6 +244,7 @@ object Main { ...@@ -238,6 +244,7 @@ object Main {
// Parse IDL file. // Parse IDL file.
System.out.println("Parsing...") System.out.println("Parsing...")
val inFileListWriter = if (inFileListPath.isDefined) { val inFileListWriter = if (inFileListPath.isDefined) {
if (inFileListPath.get.getParentFile != null)
createFolder("input file list", inFileListPath.get.getParentFile) createFolder("input file list", inFileListPath.get.getParentFile)
Some(new BufferedWriter(new FileWriter(inFileListPath.get))) Some(new BufferedWriter(new FileWriter(inFileListPath.get)))
} else { } else {
...@@ -268,6 +275,7 @@ object Main { ...@@ -268,6 +275,7 @@ object Main {
System.out.println("Generating...") System.out.println("Generating...")
val outFileListWriter = if (outFileListPath.isDefined) { val outFileListWriter = if (outFileListPath.isDefined) {
if (outFileListPath.get.getParentFile != null)
createFolder("output file list", outFileListPath.get.getParentFile) createFolder("output file list", outFileListPath.get.getParentFile)
Some(new BufferedWriter(new FileWriter(outFileListPath.get))) Some(new BufferedWriter(new FileWriter(outFileListPath.get)))
} else { } else {
...@@ -277,6 +285,7 @@ object Main { ...@@ -277,6 +285,7 @@ object Main {
val outSpec = Spec( val outSpec = Spec(
javaOutFolder, javaOutFolder,
javaPackage, javaPackage,
javaClassAccessModifier,
javaIdentStyle, javaIdentStyle,
javaCppException, javaCppException,
javaAnnotation, javaAnnotation,
...@@ -296,6 +305,7 @@ object Main { ...@@ -296,6 +305,7 @@ object Main {
cppNnHeader, cppNnHeader,
cppNnType, cppNnType,
cppNnCheckExpression, cppNnCheckExpression,
cppUseWideStrings,
jniOutFolder, jniOutFolder,
jniHeaderOutFolder, jniHeaderOutFolder,
jniIncludePrefix, jniIncludePrefix,
......
...@@ -58,7 +58,7 @@ class ObjcMarshal(spec: Spec) extends Marshal(spec) { ...@@ -58,7 +58,7 @@ class ObjcMarshal(spec: Spec) extends Marshal(spec) {
List(ImportRef(include(d.name))) List(ImportRef(include(d.name)))
case DInterface => case DInterface =>
val ext = d.body.asInstanceOf[Interface].ext val ext = d.body.asInstanceOf[Interface].ext
if (ext.cpp && !ext.objc) { if (!ext.objc) {
List(ImportRef("<Foundation/Foundation.h>"), DeclRef(s"@class ${typename(d.name, d.body)};", None)) List(ImportRef("<Foundation/Foundation.h>"), DeclRef(s"@class ${typename(d.name, d.body)};", None))
} }
else { else {
...@@ -119,7 +119,7 @@ class ObjcMarshal(spec: Spec) extends Marshal(spec) { ...@@ -119,7 +119,7 @@ class ObjcMarshal(spec: Spec) extends Marshal(spec) {
case DRecord => (idObjc.ty(d.name), true) case DRecord => (idObjc.ty(d.name), true)
case DInterface => case DInterface =>
val ext = d.body.asInstanceOf[Interface].ext val ext = d.body.asInstanceOf[Interface].ext
if (ext.cpp && !ext.objc) if (!ext.objc)
(idObjc.ty(d.name), true) (idObjc.ty(d.name), true)
else else
(s"id<${idObjc.ty(d.name)}>", false) (s"id<${idObjc.ty(d.name)}>", false)
......
...@@ -49,7 +49,11 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { ...@@ -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") + ");") 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) { 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 def headerName(ident: String): String = idObjc.ty(ident) + "." + spec.objcHeaderExt
...@@ -73,6 +77,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { ...@@ -73,6 +77,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) {
refs.privHeader.add("#include <memory>") refs.privHeader.add("#include <memory>")
refs.privHeader.add("!#include " + q(spec.objcppIncludeCppPrefix + spec.cppFileIdentStyle(ident) + "." + spec.cppHeaderExt)) refs.privHeader.add("!#include " + q(spec.objcppIncludeCppPrefix + spec.cppFileIdentStyle(ident) + "." + spec.cppHeaderExt))
refs.body.add("!#import " + q(spec.objcppIncludeObjcPrefix + headerName(ident))) refs.body.add("!#import " + q(spec.objcppIncludeObjcPrefix + headerName(ident)))
refs.body.add("!#import " + q(spec.objcppIncludePrefix + objcppMarshal.privateHeaderName(ident.name)))
spec.cppNnHeader match { spec.cppNnHeader match {
case Some(nnHdr) => refs.privHeader.add("#include " + nnHdr) case Some(nnHdr) => refs.privHeader.add("#include " + nnHdr)
...@@ -120,16 +125,21 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { ...@@ -120,16 +125,21 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) {
}) })
if (i.ext.cpp) { 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("#import " + q(spec.objcBaseLibIncludePrefix + "DJICppWrapperCache+Private.h"))
refs.body.add("#include <utility>") refs.body.add("#include <utility>")
refs.body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJIError.h")) refs.body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJIError.h"))
refs.body.add("#include <exception>") refs.body.add("#include <exception>")
} }
if (!spec.cppNnType.isEmpty || !spec.cppNnCheckExpression.nonEmpty) {
refs.body.add("#include <stdexcept>")
}
if (i.ext.objc) { if (i.ext.objc) {
refs.body.add("#import " + q(spec.objcBaseLibIncludePrefix + "DJIObjcWrapperCache+Private.h")) 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 => { writeObjcFile(privateBodyName(ident.name), origin, refs.body, w => {
...@@ -177,12 +187,12 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { ...@@ -177,12 +187,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 cppSelf + "::") + idCpp.method(m.ident) + "(" 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))) writeAlignedCall(w, call, m.params, ")", p => objcppMarshal.toCpp(p.ty, idObjc.local(p.ident.name)))
w.wl(";") 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_")};"))
} }
} }
} }
...@@ -207,7 +217,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { ...@@ -207,7 +217,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) {
val params = m.params.map(p => cppMarshal.fqParamType(p.ty) + " c_" + idCpp.local(p.ident)) 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.wl(s"$ret ${idCpp.method(m.ident)}${params.mkString("(", ", ", ")")} override").braced {
w.w("@autoreleasepool").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)}" 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))})")) writeAlignedObjcCall(w, ret + call, m.params, "]", p => (idObjc.field(p.ident), s"(${objcppMarshal.fromCpp(p.ty, "c_" + idCpp.local(p.ident))})"))
w.wl(";") w.wl(";")
...@@ -219,11 +229,11 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { ...@@ -219,11 +229,11 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) {
writeObjcFuncDecl(m, new IndentWriter(stringWriter)) writeObjcFuncDecl(m, new IndentWriter(stringWriter))
val singleLineFunctionDecl = stringWriter.toString.replaceAll("\n *", " ") val singleLineFunctionDecl = stringWriter.toString.replaceAll("\n *", " ")
val exceptionReason = s"Got unexpected null return value from function $objcSelf $singleLineFunctionDecl" val exceptionReason = s"Got unexpected null return value from function $objcSelf $singleLineFunctionDecl"
w.w(s"if (r == nil)").braced { w.w(s"if (objcpp_result_ == nil)").braced {
w.wl(s"""throw std::invalid_argument("$exceptionReason");""") 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_")};")
}) })
} }
} }
...@@ -249,7 +259,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { ...@@ -249,7 +259,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) {
// we don't have to do any casting at all, just access cppRef directly. // we don't have to do any casting at all, just access cppRef directly.
w.wl("return " + nnCheck("objc->_cppRefHandle.get()") + ";") w.wl("return " + nnCheck("objc->_cppRefHandle.get()") + ";")
//w.wl(s"return ${spec.cppNnCheckExpression.getOrElse("")}(objc->_cppRefHandle.get());") //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++. // ObjC only, or ObjC and C++.
if (i.ext.cpp) { if (i.ext.cpp) {
// If it could be implemented in C++, we might have to unwrap a proxy object. // If it could be implemented in C++, we might have to unwrap a proxy object.
...@@ -260,6 +270,9 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { ...@@ -260,6 +270,9 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) {
} }
val getProxyExpr = s"::djinni::get_objc_proxy<ObjcProxy>(objc)" val getProxyExpr = s"::djinni::get_objc_proxy<ObjcProxy>(objc)"
w.wl(s"return ${nnCheck(getProxyExpr)};") 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 w.wl
...@@ -272,7 +285,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { ...@@ -272,7 +285,7 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) {
// ObjC only. In this case we *must* unwrap a proxy object - the dynamic_cast will // 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. // throw bad_cast if we gave it something of the wrong type.
w.wl(s"return dynamic_cast<ObjcProxy&>(*cpp).Handle::get();") w.wl(s"return dynamic_cast<ObjcProxy&>(*cpp).Handle::get();")
} else { } else if (i.ext.objc || i.ext.cpp) {
// C++ only, or C++ and ObjC. // C++ only, or C++ and ObjC.
if (i.ext.objc) { if (i.ext.objc) {
// If it could be implemented in ObjC, we might have to unwrap a proxy object. // If it could be implemented in ObjC, we might have to unwrap a proxy object.
...@@ -281,6 +294,9 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { ...@@ -281,6 +294,9 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) {
} }
} }
w.wl(s"return ::djinni::get_cpp_proxy<$objcSelf>(cpp);") 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.\");")
} }
} }
}) })
...@@ -366,9 +382,16 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) { ...@@ -366,9 +382,16 @@ class ObjcppGenerator(spec: Spec) extends BaseObjcGenerator(spec) {
w.wl("// This file generated by Djinni from " + origin) w.wl("// This file generated by Djinni from " + origin)
w.wl w.wl
if (refs.nonEmpty) { if (refs.nonEmpty) {
var included = mutable.TreeSet[String]();
for (s <- refs) {
// Ignore the ! in front of each line; used to put own headers to the top // Ignore the ! in front of each line; used to put own headers to the top
// according to Objective-C style guide // according to Objective-C style guide
refs.foreach(s => w.wl(if (s.charAt(0) == '!') s.substring(1) else s)) val include = if (s.charAt(0) == '!') s.substring(1) else s
if (!included.contains(include)) {
included += include
w.wl(include)
}
}
w.wl w.wl
} }
f(w) f(w)
......
...@@ -34,9 +34,7 @@ class ObjcppMarshal(spec: Spec) extends Marshal(spec) { ...@@ -34,9 +34,7 @@ class ObjcppMarshal(spec: Spec) extends Marshal(spec) {
case o: MOpaque => case o: MOpaque =>
List(ImportRef(q(spec.objcBaseLibIncludePrefix + "DJIMarshal+Private.h"))) List(ImportRef(q(spec.objcBaseLibIncludePrefix + "DJIMarshal+Private.h")))
case d: MDef => d.defType match { case d: MDef => d.defType match {
case DEnum => case DEnum | DInterface =>
List(ImportRef(q(spec.objcBaseLibIncludePrefix + "DJIMarshal+Private.h")))
case DInterface =>
List(ImportRef(include(m))) List(ImportRef(include(m)))
case DRecord => case DRecord =>
val r = d.body.asInstanceOf[Record] val r = d.body.asInstanceOf[Record]
...@@ -48,10 +46,7 @@ class ObjcppMarshal(spec: Spec) extends Marshal(spec) { ...@@ -48,10 +46,7 @@ class ObjcppMarshal(spec: Spec) extends Marshal(spec) {
} }
def include(m: Meta) = m match { def include(m: Meta) = m match {
case d: MDef => d.defType match { case d: MDef => q(spec.objcppIncludePrefix + privateHeaderName(d.name))
case DEnum => q(spec.objcBaseLibIncludePrefix + "DJIMarshal+Private.h")
case _ => q(spec.objcppIncludePrefix + privateHeaderName(d.name))
}
case _ => throw new AssertionError("not applicable") case _ => throw new AssertionError("not applicable")
} }
...@@ -79,7 +74,7 @@ class ObjcppMarshal(spec: Spec) extends Marshal(spec) { ...@@ -79,7 +74,7 @@ class ObjcppMarshal(spec: Spec) extends Marshal(spec) {
case MOptional => "Optional" case MOptional => "Optional"
case MBinary => "Binary" case MBinary => "Binary"
case MDate => "Date" case MDate => "Date"
case MString => "String" case MString => if (spec.cppUseWideStrings) "WString" else "String"
case MList => "List" case MList => "List"
case MSet => "Set" case MSet => "Set"
case MMap => "Map" case MMap => "Map"
......
...@@ -30,6 +30,7 @@ package object generatorTools { ...@@ -30,6 +30,7 @@ package object generatorTools {
case class Spec( case class Spec(
javaOutFolder: Option[File], javaOutFolder: Option[File],
javaPackage: Option[String], javaPackage: Option[String],
javaClassAccessModifier: JavaAccessModifier.Value,
javaIdentStyle: JavaIdentStyle, javaIdentStyle: JavaIdentStyle,
javaCppException: Option[String], javaCppException: Option[String],
javaAnnotation: Option[String], javaAnnotation: Option[String],
...@@ -49,6 +50,7 @@ package object generatorTools { ...@@ -49,6 +50,7 @@ package object generatorTools {
cppNnHeader: Option[String], cppNnHeader: Option[String],
cppNnType: Option[String], cppNnType: Option[String],
cppNnCheckExpression: Option[String], cppNnCheckExpression: Option[String],
cppUseWideStrings: Boolean,
jniOutFolder: Option[File], jniOutFolder: Option[File],
jniHeaderOutFolder: Option[File], jniHeaderOutFolder: Option[File],
jniIncludePrefix: String, jniIncludePrefix: String,
...@@ -82,7 +84,7 @@ package object generatorTools { ...@@ -82,7 +84,7 @@ package object generatorTools {
if (s.isEmpty) s else ", " + s if (s.isEmpty) s else ", " + s
} }
def q(s: String) = '"' + 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 type IdentConverter = String => String
...@@ -137,6 +139,20 @@ package object generatorTools { ...@@ -137,6 +139,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() { final case class SkipFirst() {
private var first = true private var first = true
...@@ -308,7 +324,9 @@ abstract class Generator(spec: Spec) ...@@ -308,7 +324,9 @@ abstract class Generator(spec: Spec)
w.wl w.wl
val myHeader = q(includePrefix + fileIdentStyle(name) + "." + spec.cppHeaderExt) val myHeader = q(includePrefix + fileIdentStyle(name) + "." + spec.cppHeaderExt)
w.wl(s"#include $myHeader // my header") 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 w.wl
wrapNamespace(w, namespace, f) wrapNamespace(w, namespace, f)
}) })
......
...@@ -285,31 +285,37 @@ def parseExternFile(externFile: File, inFileListWriter: Option[Writer]) : Seq[Ty ...@@ -285,31 +285,37 @@ def parseExternFile(externFile: File, inFileListWriter: Option[Writer]) : Seq[Ty
} }
} }
def normalizePath(path: File) : File = {
return new File(java.nio.file.Paths.get(path.toString()).normalize().toString())
}
def parseFile(idlFile: File, inFileListWriter: Option[Writer]): Seq[TypeDecl] = { def parseFile(idlFile: File, inFileListWriter: Option[Writer]): Seq[TypeDecl] = {
val normalizedIdlFile = normalizePath(idlFile)
if (inFileListWriter.isDefined) { if (inFileListWriter.isDefined) {
inFileListWriter.get.write(idlFile + "\n") inFileListWriter.get.write(normalizedIdlFile + "\n")
} }
visitedFiles.add(idlFile) visitedFiles.add(normalizedIdlFile)
fileStack.push(idlFile) fileStack.push(normalizedIdlFile)
val fin = new FileInputStream(idlFile) val fin = new FileInputStream(normalizedIdlFile)
try { try {
parse(idlFile.getName, new InputStreamReader(fin, "UTF-8")) match { parse(normalizedIdlFile.getName, new InputStreamReader(fin, "UTF-8")) match {
case Left(err) => case Left(err) =>
System.err.println(err) System.err.println(err)
System.exit(1); return null; System.exit(1); return null;
case Right(idl) => { case Right(idl) => {
var types = idl.typeDecls var types = idl.typeDecls
idl.imports.foreach(x => { idl.imports.foreach(x => {
if (fileStack.contains(x.file)) { val normalized = normalizePath(x.file)
if (fileStack.contains(normalized)) {
throw new AssertionError("Circular import detected!") throw new AssertionError("Circular import detected!")
} }
if (!visitedFiles.contains(x.file)) { if (!visitedFiles.contains(normalized)) {
x match { x match {
case IdlFileRef(file) => case IdlFileRef(file) =>
types = parseFile(file, inFileListWriter) ++ types types = parseFile(normalized, inFileListWriter) ++ types
case ExternFileRef(file) => case ExternFileRef(file) =>
types = parseExternFile(file, inFileListWriter) ++ types types = parseExternFile(normalized, inFileListWriter) ++ types
} }
} }
}) })
......
...@@ -174,7 +174,26 @@ namespace djinni ...@@ -174,7 +174,26 @@ namespace djinni
static LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) static LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c)
{ {
return {jniEnv, jniStringFromUTF8(jniEnv, c.c_str())}; return {jniEnv, jniStringFromUTF8(jniEnv, c)};
}
};
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<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c)
{
return {jniEnv, jniStringFromWString(jniEnv, c)};
} }
}; };
......
...@@ -371,6 +371,46 @@ jstring jniStringFromUTF8(JNIEnv * env, const std::string & str) { ...@@ -371,6 +371,46 @@ jstring jniStringFromUTF8(JNIEnv * env, const std::string & str) {
return res; return res;
} }
template<int wcharTypeSize>
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<char32_t>(*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<sizeof(wchar_t)>(str.cbegin(), str.cend());
}
jstring jniStringFromWString(JNIEnv * env, const std::wstring & str) {
std::u16string utf16 = wstringToUTF16(str);
jstring res = env->NewString(
reinterpret_cast<const jchar *>(utf16.data()), utf16.length());
DJINNI_ASSERT(res, env);
return res;
}
// UTF-16 decode helpers. // UTF-16 decode helpers.
static inline bool is_high_surrogate(char16_t c) { return (c >= 0xD800) && (c < 0xDC00); } 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); } 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 < ...@@ -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. * 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])) { if (is_high_surrogate(str[i]) && is_low_surrogate(str[i+1])) {
// High surrogate followed by low surrogate // High surrogate followed by low surrogate
char32_t pt = (((str[i] - 0xD800) << 10) | (str[i+1] - 0xDC00)) + 0x10000; 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:: ...@@ -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); offset_pt res = utf16_decode_check(str, i);
if (res.offset < 0) { if (res.offset < 0) {
i += 1; i += 1;
...@@ -437,10 +477,52 @@ std::string jniUTF8FromString(JNIEnv * env, const jstring jstr) { ...@@ -437,10 +477,52 @@ std::string jniUTF8FromString(JNIEnv * env, const jstring jstr) {
std::string out; std::string out;
out.reserve(str.length() * 3 / 2); // estimate out.reserve(str.length() * 3 / 2); // estimate
for (std::u16string::size_type i = 0; i < str.length(); ) 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; return out;
} }
template<int wcharTypeSize>
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<wchar_t>(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<sizeof(wchar_t)>(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<const jchar, decltype(deleter)> ptr(env->GetStringChars(jstr, nullptr),
deleter);
const char16_t * data = reinterpret_cast<const char16_t *>(ptr.get());
return UTF16ToWString(data, length);
}
DJINNI_WEAK_DEFINITION DJINNI_WEAK_DEFINITION
void jniSetPendingFromCurrent(JNIEnv * env, const char * ctx) noexcept { void jniSetPendingFromCurrent(JNIEnv * env, const char * ctx) noexcept {
jniDefaultSetPendingFromCurrent(env, ctx); jniDefaultSetPendingFromCurrent(env, ctx);
......
...@@ -543,6 +543,9 @@ private: ...@@ -543,6 +543,9 @@ private:
jstring jniStringFromUTF8(JNIEnv * env, const std::string & str); jstring jniStringFromUTF8(JNIEnv * env, const std::string & str);
std::string jniUTF8FromString(JNIEnv * env, const jstring jstr); 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 { class JniEnum {
public: public:
/* /*
......
...@@ -18,11 +18,17 @@ ...@@ -18,11 +18,17 @@
namespace djinni { 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! // Helper function for exception translation. Do not call directly!
[[noreturn]] void throwNSExceptionFromCurrent(const char * ctx); [[noreturn]] void throwNSExceptionFromCurrent(const char * ctx);
} // namespace djinni } // namespace djinni
#define DJINNI_UNIMPLEMENTED(msg) \
::djinni::throwUnimplemented(__PRETTY_FUNCTION__, msg);
#define DJINNI_TRANSLATE_EXCEPTIONS() \ #define DJINNI_TRANSLATE_EXCEPTIONS() \
catch (const std::exception & e) { \ catch (const std::exception & e) { \
::djinni::throwNSExceptionFromCurrent(__PRETTY_FUNCTION__); \ ::djinni::throwNSExceptionFromCurrent(__PRETTY_FUNCTION__); \
......
...@@ -21,6 +21,11 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th ...@@ -21,6 +21,11 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
namespace djinni { 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*/) { [[noreturn]] __attribute__((weak)) void throwNSExceptionFromCurrent(const char * /*ctx*/) {
try { try {
throw; throw;
......
...@@ -118,6 +118,54 @@ struct String { ...@@ -118,6 +118,54 @@ struct String {
} }
}; };
template<int wcharTypeSize>
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<sizeof(wchar_t)>());
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<NSUInteger>::max());
return [[NSString alloc] initWithBytes:string.data()
length:string.size() * sizeof(wchar_t)
encoding:getWCharEncoding<sizeof(wchar_t)>()];
}
};
struct Date { struct Date {
using CppType = std::chrono::system_clock::time_point; using CppType = std::chrono::system_clock::time_point;
using ObjcType = NSDate*; using ObjcType = NSDate*;
......
...@@ -6,7 +6,7 @@ djinni: ...@@ -6,7 +6,7 @@ djinni:
./run_djinni.sh ./run_djinni.sh
objc: djinni objc: djinni
cd objc; xcodebuild -sdk iphonesimulator -project DjinniObjcTest.xcodeproj -scheme DjinniObjcTest test -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' cd objc; xcodebuild -sdk iphonesimulator -project DjinniObjcTest.xcodeproj -scheme DjinniObjcTest test -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.1'
java: djinni java: djinni
cd java && ant compile test cd java && ant compile test
......
...@@ -13,3 +13,5 @@ ...@@ -13,3 +13,5 @@
@import "multiple_inheritance.djinni" @import "multiple_inheritance.djinni"
@import "single_language_interfaces.djinni" @import "single_language_interfaces.djinni"
@import "extended_record.djinni" @import "extended_record.djinni"
@import "varnames.djinni"
@import "relative_paths.djinni"
...@@ -11,6 +11,18 @@ color = enum { ...@@ -11,6 +11,18 @@ color = enum {
violet; violet;
} }
opt_color_record = record { enum_usage_record = record {
my_color: optional<color>; e: color;
o: optional<color>;
l: list<color>;
s: set<color>;
m: map<color, color>;
}
enum_usage_interface = interface +c +j +o {
e(e: color): color;
o(o: optional<color>): optional<color>;
l(l: list<color>): list<color>;
s(s: set<color>): set<color>;
m(m: map<color, color>): map<color, color>;
} }
# Extended record # Extended record
extended_record = record +c { extended_record = record +c {
foo: bool; foo: bool;
const extended_record_const: extended_record = {foo=true}; const extended_record_const: extended_record = { foo = true };
}
record_using_extended_record = record {
er: extended_record;
const cr: record_using_extended_record = {er = { foo = false } };
}
interface_using_extended_record = interface +c {
meth(er: extended_record): extended_record;
const cr: record_using_extended_record = {er = { foo = false } };
} }
@import "./vendor/third-party/date.djinni"
@import "../djinni/vendor/third-party/date.djinni"
@extern "./vendor/third-party/date.yaml"
...@@ -5,5 +5,7 @@ java_only_listener = interface +j {} ...@@ -5,5 +5,7 @@ java_only_listener = interface +j {}
# on references to interfaces they don't need. # on references to interfaces they don't need.
uses_single_language_listeners = interface +o +j +c { uses_single_language_listeners = interface +o +j +c {
callForObjC(l: objc_only_listener); callForObjC(l: objc_only_listener);
returnForObjC(): objc_only_listener;
callForJava(l: java_only_listener); callForJava(l: java_only_listener);
returnForJava(): java_only_listener;
} }
# 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_;
}
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;
}
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from varnames.djinni
#pragma once
#include <memory>
namespace testsuite {
struct VarnameRecord;
class VarnameInterface {
public:
virtual ~VarnameInterface() {}
virtual VarnameRecord _rmethod_(const VarnameRecord & _r_arg_) = 0;
virtual std::shared_ptr<VarnameInterface> _imethod_(const std::shared_ptr<VarnameInterface> & _i_arg_) = 0;
};
} // namespace testsuite
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from varnames.djinni
#pragma once
#include <cstdint>
#include <utility>
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
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
#pragma once #pragma once
#include "../../handwritten-src/cpp/optional.hpp"
#include <cstdint> #include <cstdint>
#include <experimental/optional>
#include <utility> #include <utility>
namespace testsuite { namespace testsuite {
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
#pragma once #pragma once
#include "../../handwritten-src/cpp/optional.hpp"
#include <cstdint> #include <cstdint>
#include <experimental/optional>
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
#pragma once #pragma once
#include "../../handwritten-src/cpp/optional.hpp"
#include <cstdint> #include <cstdint>
#include <experimental/optional>
#include <string> #include <string>
#include <utility> #include <utility>
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
#pragma once #pragma once
#include "../../handwritten-src/cpp/optional.hpp"
#include "constant_record.hpp" #include "constant_record.hpp"
#include <cstdint> #include <cstdint>
#include <experimental/optional>
#include <string> #include <string>
#include <utility> #include <utility>
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
#pragma once #pragma once
#include "../../handwritten-src/cpp/optional.hpp"
#include <cstdint> #include <cstdint>
#include <experimental/optional>
#include <string> #include <string>
namespace testsuite { namespace testsuite {
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from enum.djinni
#pragma once
#include "../../handwritten-src/cpp/optional.hpp"
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace testsuite {
enum class color;
class EnumUsageInterface {
public:
virtual ~EnumUsageInterface() {}
virtual color e(color e) = 0;
virtual std::experimental::optional<color> o(std::experimental::optional<color> o) = 0;
virtual std::vector<color> l(const std::vector<color> & l) = 0;
virtual std::unordered_set<color> s(const std::unordered_set<color> & s) = 0;
virtual std::unordered_map<color, color> m(const std::unordered_map<color, color> & m) = 0;
};
} // namespace testsuite
// 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 <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
namespace testsuite {
struct EnumUsageRecord final {
color e;
std::experimental::optional<color> o;
std::vector<color> l;
std::unordered_set<color> s;
std::unordered_map<color, color> m;
EnumUsageRecord(color e_,
std::experimental::optional<color> o_,
std::vector<color> l_,
std::unordered_set<color> s_,
std::unordered_map<color, color> m_)
: e(std::move(e_))
, o(std::move(o_))
, l(std::move(l_))
, s(std::move(s_))
, m(std::move(m_))
{}
};
} // namespace testsuite
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from extended_record.djinni
#include "interface_using_extended_record.hpp" // my header
#include "../../handwritten-src/cpp/extended_record.hpp"
#include "record_using_extended_record.hpp"
namespace testsuite {
RecordUsingExtendedRecord const InterfaceUsingExtendedRecord::CR = RecordUsingExtendedRecord(
ExtendedRecord(
false /* foo */ ) /* er */ );
} // namespace testsuite
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from extended_record.djinni
#pragma once
namespace testsuite {
struct ExtendedRecord;
struct RecordUsingExtendedRecord;
class InterfaceUsingExtendedRecord {
public:
virtual ~InterfaceUsingExtendedRecord() {}
static RecordUsingExtendedRecord const CR;
virtual ExtendedRecord meth(const ExtendedRecord & er) = 0;
};
} // namespace testsuite
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from extended_record.djinni
#include "record_using_extended_record.hpp" // my header
namespace testsuite {
RecordUsingExtendedRecord const RecordUsingExtendedRecord::CR = RecordUsingExtendedRecord(
ExtendedRecord(
false /* foo */ ) /* er */ );
} // namespace testsuite
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from extended_record.djinni
#pragma once
#include "../../handwritten-src/cpp/extended_record.hpp"
#include <utility>
namespace testsuite {
struct RecordUsingExtendedRecord final {
static RecordUsingExtendedRecord const CR;
ExtendedRecord er;
RecordUsingExtendedRecord(ExtendedRecord er_)
: er(std::move(er_))
{}
};
} // namespace testsuite
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#pragma once #pragma once
#include <experimental/optional> #include "../../handwritten-src/cpp/optional.hpp"
#include <memory> #include <memory>
#include <string> #include <string>
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
#pragma once #pragma once
#include "../../handwritten-src/cpp/optional.hpp"
#include <chrono> #include <chrono>
#include <cstdint> #include <cstdint>
#include <experimental/optional>
#include <string> #include <string>
namespace testsuite { namespace testsuite {
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
#pragma once #pragma once
#include "../../handwritten-src/cpp/optional.hpp"
#include <cstdint> #include <cstdint>
#include <experimental/optional>
#include <memory> #include <memory>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
......
...@@ -20,7 +20,11 @@ public: ...@@ -20,7 +20,11 @@ public:
virtual void callForObjC(const std::shared_ptr<ObjcOnlyListener> & l) = 0; virtual void callForObjC(const std::shared_ptr<ObjcOnlyListener> & l) = 0;
virtual std::shared_ptr<ObjcOnlyListener> returnForObjC() = 0;
virtual void callForJava(const std::shared_ptr<JavaOnlyListener> & l) = 0; virtual void callForJava(const std::shared_ptr<JavaOnlyListener> & l) = 0;
virtual std::shared_ptr<JavaOnlyListener> returnForJava() = 0;
}; };
} // namespace testsuite } // namespace testsuite
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from wchar_test.djinni
#pragma once
#include <string>
namespace testsuite {
struct WcharTestRec;
class WcharTestHelpers {
public:
virtual ~WcharTestHelpers() {}
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
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from enum.djinni // This file generated by Djinni from wchar_test.djinni
#pragma once #pragma once
#include "color.hpp" #include <string>
#include <experimental/optional>
#include <utility> #include <utility>
namespace testsuite { namespace testsuite {
struct OptColorRecord final { struct WcharTestRec final {
std::experimental::optional<color> my_color; std::wstring s;
OptColorRecord(std::experimental::optional<color> my_color_) WcharTestRec(std::wstring s_)
: my_color(std::move(my_color_)) : s(std::move(s_))
{} {}
}; };
......
...@@ -15,6 +15,8 @@ djinni/constants.djinni ...@@ -15,6 +15,8 @@ djinni/constants.djinni
djinni/multiple_inheritance.djinni djinni/multiple_inheritance.djinni
djinni/single_language_interfaces.djinni djinni/single_language_interfaces.djinni
djinni/extended_record.djinni djinni/extended_record.djinni
djinni/varnames.djinni
djinni/relative_paths.djinni
djinni/vendor/third-party/date.djinni djinni/vendor/third-party/date.djinni
djinni/vendor/third-party/date.yaml djinni/vendor/third-party/date.yaml
djinni/vendor/third-party/duration.djinni djinni/vendor/third-party/duration.djinni
......
// 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<Color> l(@Nonnull ArrayList<Color> l);
@Nonnull
public abstract HashSet<Color> s(@Nonnull HashSet<Color> s);
@Nonnull
public abstract HashMap<Color, Color> m(@Nonnull HashMap<Color, Color> 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();
}
@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<Color> l(ArrayList<Color> l)
{
assert !this.destroyed.get() : "trying to use a destroyed object";
return native_l(this.nativeRef, l);
}
private native ArrayList<Color> native_l(long _nativeRef, ArrayList<Color> l);
@Override
public HashSet<Color> s(HashSet<Color> s)
{
assert !this.destroyed.get() : "trying to use a destroyed object";
return native_s(this.nativeRef, s);
}
private native HashSet<Color> native_s(long _nativeRef, HashSet<Color> s);
@Override
public HashMap<Color, Color> m(HashMap<Color, Color> m)
{
assert !this.destroyed.get() : "trying to use a destroyed object";
return native_m(this.nativeRef, m);
}
private native HashMap<Color, Color> native_m(long _nativeRef, HashMap<Color, Color> m);
}
}
// 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<Color> mL;
/*package*/ final HashSet<Color> mS;
/*package*/ final HashMap<Color, Color> mM;
public EnumUsageRecord(
@Nonnull Color e,
@CheckForNull Color o,
@Nonnull ArrayList<Color> l,
@Nonnull HashSet<Color> s,
@Nonnull HashMap<Color, Color> 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<Color> getL() {
return mL;
}
@Nonnull
public HashSet<Color> getS() {
return mS;
}
@Nonnull
public HashMap<Color, Color> getM() {
return mM;
}
@Override
public String toString() {
return "EnumUsageRecord{" +
"mE=" + mE +
"," + "mO=" + mO +
"," + "mL=" + mL +
"," + "mS=" + mS +
"," + "mM=" + mM +
"}";
}
}
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from extended_record.djinni
package com.dropbox.djinni.test;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
public abstract class InterfaceUsingExtendedRecord {
@Nonnull
public static final RecordUsingExtendedRecord CR = new RecordUsingExtendedRecord(
new ExtendedRecord(
false /* mFoo */ ) /* mEr */ );
@Nonnull
public abstract ExtendedRecord meth(@Nonnull ExtendedRecord er);
private static final class CppProxy extends InterfaceUsingExtendedRecord
{
private final long nativeRef;
private final AtomicBoolean destroyed = new AtomicBoolean(false);
private CppProxy(long nativeRef)
{
if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
this.nativeRef = nativeRef;
}
private native void nativeDestroy(long nativeRef);
public void destroy()
{
boolean destroyed = this.destroyed.getAndSet(true);
if (!destroyed) nativeDestroy(this.nativeRef);
}
protected void finalize() throws java.lang.Throwable
{
destroy();
super.finalize();
}
@Override
public ExtendedRecord meth(ExtendedRecord er)
{
assert !this.destroyed.get() : "trying to use a destroyed object";
return native_meth(this.nativeRef, er);
}
private native ExtendedRecord native_meth(long _nativeRef, ExtendedRecord er);
}
}
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from extended_record.djinni
package com.dropbox.djinni.test;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
public class RecordUsingExtendedRecord {
@Nonnull
public static final RecordUsingExtendedRecord CR = new RecordUsingExtendedRecord(
new ExtendedRecord(
false /* mFoo */ ) /* mEr */ );
/*package*/ final ExtendedRecord mEr;
public RecordUsingExtendedRecord(
@Nonnull ExtendedRecord er) {
this.mEr = er;
}
@Nonnull
public ExtendedRecord getEr() {
return mEr;
}
@Override
public String toString() {
return "RecordUsingExtendedRecord{" +
"mEr=" + mEr +
"}";
}
}
...@@ -14,8 +14,14 @@ import javax.annotation.Nonnull; ...@@ -14,8 +14,14 @@ import javax.annotation.Nonnull;
public abstract class UsesSingleLanguageListeners { public abstract class UsesSingleLanguageListeners {
public abstract void callForObjC(@CheckForNull ObjcOnlyListener l); public abstract void callForObjC(@CheckForNull ObjcOnlyListener l);
@CheckForNull
public abstract ObjcOnlyListener returnForObjC();
public abstract void callForJava(@CheckForNull JavaOnlyListener l); public abstract void callForJava(@CheckForNull JavaOnlyListener l);
@CheckForNull
public abstract JavaOnlyListener returnForJava();
private static final class CppProxy extends UsesSingleLanguageListeners private static final class CppProxy extends UsesSingleLanguageListeners
{ {
private final long nativeRef; private final long nativeRef;
...@@ -47,6 +53,14 @@ public abstract class UsesSingleLanguageListeners { ...@@ -47,6 +53,14 @@ public abstract class UsesSingleLanguageListeners {
} }
private native void native_callForObjC(long _nativeRef, 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 @Override
public void callForJava(JavaOnlyListener l) public void callForJava(JavaOnlyListener l)
{ {
...@@ -54,5 +68,13 @@ public abstract class UsesSingleLanguageListeners { ...@@ -54,5 +68,13 @@ public abstract class UsesSingleLanguageListeners {
native_callForJava(this.nativeRef, l); native_callForJava(this.nativeRef, l);
} }
private native void native_callForJava(long _nativeRef, JavaOnlyListener 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);
} }
} }
// 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();
}
@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);
}
}
// 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 +
"}";
}
}
// 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();
}
}
}
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from enum.djinni // This file generated by Djinni from wchar_test.djinni
package com.dropbox.djinni.test; package com.dropbox.djinni.test;
import javax.annotation.CheckForNull; import javax.annotation.CheckForNull;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public class OptColorRecord { public class WcharTestRec {
/*package*/ final Color mMyColor; /*package*/ final String mS;
public OptColorRecord( public WcharTestRec(
@CheckForNull Color myColor) { @Nonnull String s) {
this.mMyColor = myColor; this.mS = s;
} }
@CheckForNull @Nonnull
public Color getMyColor() { public String getS() {
return mMyColor; return mS;
} }
@Override @Override
public String toString() { public String toString() {
return "OptColorRecord{" + return "WcharTestRec{" +
"mMyColor=" + mMyColor + "mS=" + mS +
"}"; "}";
} }
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "NativeClientInterface.hpp" // my header #include "NativeClientInterface.hpp" // my header
#include "Marshal.hpp" #include "Marshal.hpp"
#include "NativeClientInterface.hpp"
#include "NativeClientReturnedRecord.hpp" #include "NativeClientReturnedRecord.hpp"
namespace djinni_generated { namespace djinni_generated {
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "NativeCppException.hpp" // my header #include "NativeCppException.hpp" // my header
#include "Marshal.hpp" #include "Marshal.hpp"
#include "NativeCppException.hpp"
namespace djinni_generated { namespace djinni_generated {
......
// 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<std::experimental::optional, ::djinni_generated::NativeColor>::fromCpp(jniEnv, c_o)));
::djinni::jniExceptionCheck(jniEnv);
return ::djinni::Optional<std::experimental::optional, ::djinni_generated::NativeColor>::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<std::experimental::optional, ::djinni_generated::NativeColor>::toCpp(jniEnv, j_o));
return ::djinni::release(::djinni::Optional<std::experimental::optional, ::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_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
// 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<NativeEnumUsageInterface>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeEnumUsageInterface>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private:
NativeEnumUsageInterface();
friend ::djinni::JniClass<NativeEnumUsageInterface>;
friend ::djinni::JniInterface<::testsuite::EnumUsageInterface, NativeEnumUsageInterface>;
class JavaProxy final : ::djinni::JavaProxyHandle<JavaProxy>, 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<jclass> 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
// 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<JniType> {
const auto& data = ::djinni::JniClass<NativeEnumUsageRecord>::get();
auto r = ::djinni::LocalRef<JniType>{jniEnv->NewObject(data.clazz.get(), data.jconstructor,
::djinni::get(::djinni_generated::NativeColor::fromCpp(jniEnv, c.e)),
::djinni::get(::djinni::Optional<std::experimental::optional, ::djinni_generated::NativeColor>::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<NativeEnumUsageRecord>::get();
return {::djinni_generated::NativeColor::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mE)),
::djinni::Optional<std::experimental::optional, ::djinni_generated::NativeColor>::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
// 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<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c);
private:
NativeEnumUsageRecord();
friend ::djinni::JniClass<NativeEnumUsageRecord>;
const ::djinni::GlobalRef<jclass> clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/EnumUsageRecord") };
const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "<init>", "(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
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
#pragma once #pragma once
#include "../../handwritten-src/cpp/extended_record.hpp"
#include "djinni_support.hpp" #include "djinni_support.hpp"
#include "extended_record.hpp"
namespace djinni_generated { namespace djinni_generated {
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from extended_record.djinni
#include "NativeInterfaceUsingExtendedRecord.hpp" // my header
#include "NativeExtendedRecord.hpp"
#include "NativeRecordUsingExtendedRecord.hpp"
namespace djinni_generated {
NativeInterfaceUsingExtendedRecord::NativeInterfaceUsingExtendedRecord() : ::djinni::JniInterface<::testsuite::InterfaceUsingExtendedRecord, NativeInterfaceUsingExtendedRecord>("com/dropbox/djinni/test/InterfaceUsingExtendedRecord$CppProxy") {}
NativeInterfaceUsingExtendedRecord::~NativeInterfaceUsingExtendedRecord() = default;
CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_InterfaceUsingExtendedRecord_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
delete reinterpret_cast<::djinni::CppProxyHandle<::testsuite::InterfaceUsingExtendedRecord>*>(nativeRef);
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
}
CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_InterfaceUsingExtendedRecord_00024CppProxy_native_1meth(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_er)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::InterfaceUsingExtendedRecord>(nativeRef);
auto r = ref->meth(::djinni_generated::NativeExtendedRecord::toCpp(jniEnv, j_er));
return ::djinni::release(::djinni_generated::NativeExtendedRecord::fromCpp(jniEnv, r));
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */)
}
} // namespace djinni_generated
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from extended_record.djinni
#pragma once
#include "djinni_support.hpp"
#include "interface_using_extended_record.hpp"
namespace djinni_generated {
class NativeInterfaceUsingExtendedRecord final : ::djinni::JniInterface<::testsuite::InterfaceUsingExtendedRecord, NativeInterfaceUsingExtendedRecord> {
public:
using CppType = std::shared_ptr<::testsuite::InterfaceUsingExtendedRecord>;
using CppOptType = std::shared_ptr<::testsuite::InterfaceUsingExtendedRecord>;
using JniType = jobject;
using Boxed = NativeInterfaceUsingExtendedRecord;
~NativeInterfaceUsingExtendedRecord();
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeInterfaceUsingExtendedRecord>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeInterfaceUsingExtendedRecord>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private:
NativeInterfaceUsingExtendedRecord();
friend ::djinni::JniClass<NativeInterfaceUsingExtendedRecord>;
friend ::djinni::JniInterface<::testsuite::InterfaceUsingExtendedRecord, NativeInterfaceUsingExtendedRecord>;
};
} // namespace djinni_generated
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "NativeListenerCaller.hpp" // my header #include "NativeListenerCaller.hpp" // my header
#include "NativeFirstListener.hpp" #include "NativeFirstListener.hpp"
#include "NativeListenerCaller.hpp"
#include "NativeSecondListener.hpp" #include "NativeSecondListener.hpp"
namespace djinni_generated { namespace djinni_generated {
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from extended_record.djinni
#include "NativeRecordUsingExtendedRecord.hpp" // my header
#include "NativeExtendedRecord.hpp"
namespace djinni_generated {
NativeRecordUsingExtendedRecord::NativeRecordUsingExtendedRecord() = default;
NativeRecordUsingExtendedRecord::~NativeRecordUsingExtendedRecord() = default;
auto NativeRecordUsingExtendedRecord::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef<JniType> {
const auto& data = ::djinni::JniClass<NativeRecordUsingExtendedRecord>::get();
auto r = ::djinni::LocalRef<JniType>{jniEnv->NewObject(data.clazz.get(), data.jconstructor,
::djinni::get(::djinni_generated::NativeExtendedRecord::fromCpp(jniEnv, c.er)))};
::djinni::jniExceptionCheck(jniEnv);
return r;
}
auto NativeRecordUsingExtendedRecord::toCpp(JNIEnv* jniEnv, JniType j) -> CppType {
::djinni::JniLocalScope jscope(jniEnv, 2);
assert(j != nullptr);
const auto& data = ::djinni::JniClass<NativeRecordUsingExtendedRecord>::get();
return {::djinni_generated::NativeExtendedRecord::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mEr))};
}
} // namespace djinni_generated
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from extended_record.djinni
#pragma once
#include "djinni_support.hpp"
#include "record_using_extended_record.hpp"
namespace djinni_generated {
class NativeRecordUsingExtendedRecord final {
public:
using CppType = ::testsuite::RecordUsingExtendedRecord;
using JniType = jobject;
using Boxed = NativeRecordUsingExtendedRecord;
~NativeRecordUsingExtendedRecord();
static CppType toCpp(JNIEnv* jniEnv, JniType j);
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c);
private:
NativeRecordUsingExtendedRecord();
friend ::djinni::JniClass<NativeRecordUsingExtendedRecord>;
const ::djinni::GlobalRef<jclass> clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/RecordUsingExtendedRecord") };
const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "<init>", "(Lcom/dropbox/djinni/test/ExtendedRecord;)V") };
const jfieldID field_mEr { ::djinni::jniGetFieldID(clazz.get(), "mEr", "Lcom/dropbox/djinni/test/ExtendedRecord;") };
};
} // namespace djinni_generated
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "NativeReturnOne.hpp" // my header #include "NativeReturnOne.hpp" // my header
#include "Marshal.hpp" #include "Marshal.hpp"
#include "NativeReturnOne.hpp"
namespace djinni_generated { namespace djinni_generated {
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "NativeReturnTwo.hpp" // my header #include "NativeReturnTwo.hpp" // my header
#include "Marshal.hpp" #include "Marshal.hpp"
#include "NativeReturnTwo.hpp"
namespace djinni_generated { namespace djinni_generated {
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "NativeReverseClientInterface.hpp" // my header #include "NativeReverseClientInterface.hpp" // my header
#include "Marshal.hpp" #include "Marshal.hpp"
#include "NativeReverseClientInterface.hpp"
namespace djinni_generated { namespace djinni_generated {
......
...@@ -23,6 +23,14 @@ void NativeUsesSingleLanguageListeners::JavaProxy::callForObjC(const std::shared ...@@ -23,6 +23,14 @@ void NativeUsesSingleLanguageListeners::JavaProxy::callForObjC(const std::shared
::djinni::get(::djinni_generated::NativeObjcOnlyListener::fromCpp(jniEnv, c_l))); ::djinni::get(::djinni_generated::NativeObjcOnlyListener::fromCpp(jniEnv, c_l)));
::djinni::jniExceptionCheck(jniEnv); ::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) { void NativeUsesSingleLanguageListeners::JavaProxy::callForJava(const std::shared_ptr<::testsuite::JavaOnlyListener> & c_l) {
auto jniEnv = ::djinni::jniGetThreadEnv(); auto jniEnv = ::djinni::jniGetThreadEnv();
::djinni::JniLocalScope jscope(jniEnv, 10); ::djinni::JniLocalScope jscope(jniEnv, 10);
...@@ -31,6 +39,14 @@ void NativeUsesSingleLanguageListeners::JavaProxy::callForJava(const std::shared ...@@ -31,6 +39,14 @@ void NativeUsesSingleLanguageListeners::JavaProxy::callForJava(const std::shared
::djinni::get(::djinni_generated::NativeJavaOnlyListener::fromCpp(jniEnv, c_l))); ::djinni::get(::djinni_generated::NativeJavaOnlyListener::fromCpp(jniEnv, c_l)));
::djinni::jniExceptionCheck(jniEnv); ::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) 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 ...@@ -49,6 +65,16 @@ CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_UsesSingleLanguageListeners
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) } 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) CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_UsesSingleLanguageListeners_00024CppProxy_native_1callForJava(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_l)
{ {
try { try {
...@@ -58,4 +84,14 @@ CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_UsesSingleLanguageListeners ...@@ -58,4 +84,14 @@ CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_UsesSingleLanguageListeners
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) } 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 } // namespace djinni_generated
...@@ -34,7 +34,9 @@ private: ...@@ -34,7 +34,9 @@ private:
~JavaProxy(); ~JavaProxy();
void callForObjC(const std::shared_ptr<::testsuite::ObjcOnlyListener> & l) override; 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; void callForJava(const std::shared_ptr<::testsuite::JavaOnlyListener> & l) override;
std::shared_ptr<::testsuite::JavaOnlyListener> returnForJava() override;
private: private:
friend ::djinni::JniInterface<::testsuite::UsesSingleLanguageListeners, ::djinni_generated::NativeUsesSingleLanguageListeners>; friend ::djinni::JniInterface<::testsuite::UsesSingleLanguageListeners, ::djinni_generated::NativeUsesSingleLanguageListeners>;
...@@ -42,7 +44,9 @@ private: ...@@ -42,7 +44,9 @@ private:
const ::djinni::GlobalRef<jclass> clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/UsesSingleLanguageListeners") }; const ::djinni::GlobalRef<jclass> 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_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_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 } // namespace djinni_generated
// 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
// 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<NativeVarnameInterface>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeVarnameInterface>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private:
NativeVarnameInterface();
friend ::djinni::JniClass<NativeVarnameInterface>;
friend ::djinni::JniInterface<::testsuite::VarnameInterface, NativeVarnameInterface>;
};
} // namespace djinni_generated
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from enum.djinni // This file generated by Djinni from varnames.djinni
#include "NativeOptColorRecord.hpp" // my header #include "NativeVarnameRecord.hpp" // my header
#include "Marshal.hpp" #include "Marshal.hpp"
#include "NativeColor.hpp"
namespace djinni_generated { namespace djinni_generated {
NativeOptColorRecord::NativeOptColorRecord() = default; NativeVarnameRecord::NativeVarnameRecord() = default;
NativeOptColorRecord::~NativeOptColorRecord() = default; NativeVarnameRecord::~NativeVarnameRecord() = default;
auto NativeOptColorRecord::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef<JniType> { auto NativeVarnameRecord::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef<JniType> {
const auto& data = ::djinni::JniClass<NativeOptColorRecord>::get(); const auto& data = ::djinni::JniClass<NativeVarnameRecord>::get();
auto r = ::djinni::LocalRef<JniType>{jniEnv->NewObject(data.clazz.get(), data.jconstructor, auto r = ::djinni::LocalRef<JniType>{jniEnv->NewObject(data.clazz.get(), data.jconstructor,
::djinni::get(::djinni::Optional<std::experimental::optional, ::djinni_generated::NativeColor>::fromCpp(jniEnv, c.my_color)))}; ::djinni::get(::djinni::I8::fromCpp(jniEnv, c._field_)))};
::djinni::jniExceptionCheck(jniEnv); ::djinni::jniExceptionCheck(jniEnv);
return r; return r;
} }
auto NativeOptColorRecord::toCpp(JNIEnv* jniEnv, JniType j) -> CppType { auto NativeVarnameRecord::toCpp(JNIEnv* jniEnv, JniType j) -> CppType {
::djinni::JniLocalScope jscope(jniEnv, 2); ::djinni::JniLocalScope jscope(jniEnv, 2);
assert(j != nullptr); assert(j != nullptr);
const auto& data = ::djinni::JniClass<NativeOptColorRecord>::get(); const auto& data = ::djinni::JniClass<NativeVarnameRecord>::get();
return {::djinni::Optional<std::experimental::optional, ::djinni_generated::NativeColor>::toCpp(jniEnv, jniEnv->GetObjectField(j, data.field_mMyColor))}; return {::djinni::I8::toCpp(jniEnv, jniEnv->GetByteField(j, data.field_mField))};
} }
} // namespace djinni_generated } // namespace djinni_generated
// AUTOGENERATED FILE - DO NOT MODIFY! // AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from enum.djinni // This file generated by Djinni from varnames.djinni
#pragma once #pragma once
#include "_varname_record_.hpp"
#include "djinni_support.hpp" #include "djinni_support.hpp"
#include "opt_color_record.hpp"
namespace djinni_generated { namespace djinni_generated {
class NativeOptColorRecord final { class NativeVarnameRecord final {
public: public:
using CppType = ::testsuite::OptColorRecord; using CppType = ::testsuite::VarnameRecord;
using JniType = jobject; using JniType = jobject;
using Boxed = NativeOptColorRecord; using Boxed = NativeVarnameRecord;
~NativeOptColorRecord(); ~NativeVarnameRecord();
static CppType toCpp(JNIEnv* jniEnv, JniType j); static CppType toCpp(JNIEnv* jniEnv, JniType j);
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c); static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c);
private: private:
NativeOptColorRecord(); NativeVarnameRecord();
friend ::djinni::JniClass<NativeOptColorRecord>; friend ::djinni::JniClass<NativeVarnameRecord>;
const ::djinni::GlobalRef<jclass> clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/OptColorRecord") }; const ::djinni::GlobalRef<jclass> clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/VarnameRecord") };
const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "<init>", "(Lcom/dropbox/djinni/test/Color;)V") }; const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "<init>", "(B)V") };
const jfieldID field_mMyColor { ::djinni::jniGetFieldID(clazz.get(), "mMyColor", "Lcom/dropbox/djinni/test/Color;") }; const jfieldID field_mField { ::djinni::jniGetFieldID(clazz.get(), "mField", "B") };
}; };
} // namespace djinni_generated } // namespace djinni_generated
// 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
// 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<NativeWcharTestHelpers>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeWcharTestHelpers>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }
private:
NativeWcharTestHelpers();
friend ::djinni::JniClass<NativeWcharTestHelpers>;
friend ::djinni::JniInterface<::testsuite::WcharTestHelpers, NativeWcharTestHelpers>;
};
} // namespace djinni_generated
// 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<JniType> {
const auto& data = ::djinni::JniClass<NativeWcharTestRec>::get();
auto r = ::djinni::LocalRef<JniType>{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<NativeWcharTestRec>::get();
return {::djinni::WString::toCpp(jniEnv, (jstring)jniEnv->GetObjectField(j, data.field_mS))};
}
} // namespace djinni_generated
// 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<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c);
private:
NativeWcharTestRec();
friend ::djinni::JniClass<NativeWcharTestRec>;
const ::djinni::GlobalRef<jclass> clazz { ::djinni::jniFindClass("com/dropbox/djinni/test/WcharTestRec") };
const jmethodID jconstructor { ::djinni::jniGetMethodID(clazz.get(), "<init>", "(Ljava/lang/String;)V") };
const jfieldID field_mS { ::djinni::jniGetFieldID(clazz.get(), "mS", "Ljava/lang/String;") };
};
} // namespace djinni_generated
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
#import "DBClientInterface+Private.h" #import "DBClientInterface+Private.h"
#import "DBClientInterface.h" #import "DBClientInterface.h"
#import "DBClientInterface+Private.h"
#import "DBClientReturnedRecord+Private.h" #import "DBClientReturnedRecord+Private.h"
#import "DJIMarshal+Private.h" #import "DJIMarshal+Private.h"
#import "DJIObjcWrapperCache+Private.h" #import "DJIObjcWrapperCache+Private.h"
#include <stdexcept>
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
...@@ -21,40 +21,40 @@ public: ...@@ -21,40 +21,40 @@ public:
::testsuite::ClientReturnedRecord get_record(int64_t c_record_id, const std::string & c_utf8string, const std::experimental::optional<std::string> & c_misc) override ::testsuite::ClientReturnedRecord get_record(int64_t c_record_id, const std::string & c_utf8string, const std::experimental::optional<std::string> & c_misc) override
{ {
@autoreleasepool { @autoreleasepool {
auto r = [Handle::get() getRecord:(::djinni::I64::fromCpp(c_record_id)) auto objcpp_result_ = [Handle::get() getRecord:(::djinni::I64::fromCpp(c_record_id))
utf8string:(::djinni::String::fromCpp(c_utf8string)) utf8string:(::djinni::String::fromCpp(c_utf8string))
misc:(::djinni::Optional<std::experimental::optional, ::djinni::String>::fromCpp(c_misc))]; misc:(::djinni::Optional<std::experimental::optional, ::djinni::String>::fromCpp(c_misc))];
return ::djinni_generated::ClientReturnedRecord::toCpp(r); return ::djinni_generated::ClientReturnedRecord::toCpp(objcpp_result_);
} }
} }
double identifier_check(const std::vector<uint8_t> & c_data, int32_t c_r, int64_t c_jret) override double identifier_check(const std::vector<uint8_t> & c_data, int32_t c_r, int64_t c_jret) override
{ {
@autoreleasepool { @autoreleasepool {
auto r = [Handle::get() identifierCheck:(::djinni::Binary::fromCpp(c_data)) auto objcpp_result_ = [Handle::get() identifierCheck:(::djinni::Binary::fromCpp(c_data))
r:(::djinni::I32::fromCpp(c_r)) r:(::djinni::I32::fromCpp(c_r))
jret:(::djinni::I64::fromCpp(c_jret))]; jret:(::djinni::I64::fromCpp(c_jret))];
return ::djinni::F64::toCpp(r); return ::djinni::F64::toCpp(objcpp_result_);
} }
} }
std::string return_str() override std::string return_str() override
{ {
@autoreleasepool { @autoreleasepool {
auto r = [Handle::get() returnStr]; auto objcpp_result_ = [Handle::get() returnStr];
return ::djinni::String::toCpp(r); return ::djinni::String::toCpp(objcpp_result_);
} }
} }
std::string meth_taking_interface(const std::shared_ptr<::testsuite::ClientInterface> & c_i) override std::string meth_taking_interface(const std::shared_ptr<::testsuite::ClientInterface> & c_i) override
{ {
@autoreleasepool { @autoreleasepool {
auto r = [Handle::get() methTakingInterface:(::djinni_generated::ClientInterface::fromCpp(c_i))]; auto objcpp_result_ = [Handle::get() methTakingInterface:(::djinni_generated::ClientInterface::fromCpp(c_i))];
return ::djinni::String::toCpp(r); return ::djinni::String::toCpp(objcpp_result_);
} }
} }
std::string meth_taking_optional_interface(const std::shared_ptr<::testsuite::ClientInterface> & c_i) override std::string meth_taking_optional_interface(const std::shared_ptr<::testsuite::ClientInterface> & c_i) override
{ {
@autoreleasepool { @autoreleasepool {
auto r = [Handle::get() methTakingOptionalInterface:(::djinni::Optional<std::experimental::optional, ::djinni_generated::ClientInterface>::fromCpp(c_i))]; auto objcpp_result_ = [Handle::get() methTakingOptionalInterface:(::djinni::Optional<std::experimental::optional, ::djinni_generated::ClientInterface>::fromCpp(c_i))];
return ::djinni::String::toCpp(r); return ::djinni::String::toCpp(objcpp_result_);
} }
} }
}; };
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from enum.djinni
#include "color.hpp"
#import "DJIMarshal+Private.h"
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#import "DJICppWrapperCache+Private.h" #import "DJICppWrapperCache+Private.h"
#import "DJIError.h" #import "DJIError.h"
#include <exception> #include <exception>
#include <stdexcept>
#include <utility> #include <utility>
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import "DJIError.h" #import "DJIError.h"
#import "DJIMarshal+Private.h" #import "DJIMarshal+Private.h"
#include <exception> #include <exception>
#include <stdexcept>
#include <utility> #include <utility>
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
...@@ -32,15 +33,15 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th ...@@ -32,15 +33,15 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (nullable DBConflict *)Conflict { - (nullable DBConflict *)Conflict {
try { try {
auto r = _cppRefHandle.get()->Conflict(); auto objcpp_result_ = _cppRefHandle.get()->Conflict();
return ::djinni_generated::Conflict::fromCpp(r); return ::djinni_generated::Conflict::fromCpp(objcpp_result_);
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
- (BOOL)conflictArg:(nonnull NSSet<DBConflict *> *)cs { - (BOOL)conflictArg:(nonnull NSSet<DBConflict *> *)cs {
try { try {
auto r = _cppRefHandle.get()->conflict_arg(::djinni::Set<::djinni_generated::Conflict>::toCpp(cs)); auto objcpp_result_ = _cppRefHandle.get()->conflict_arg(::djinni::Set<::djinni_generated::Conflict>::toCpp(cs));
return ::djinni::Bool::fromCpp(r); return ::djinni::Bool::fromCpp(objcpp_result_);
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import "DJIError.h" #import "DJIError.h"
#import "DJIMarshal+Private.h" #import "DJIMarshal+Private.h"
#include <exception> #include <exception>
#include <stdexcept>
#include <utility> #include <utility>
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
#import "DBCppException+Private.h" #import "DBCppException+Private.h"
#import "DBCppException.h" #import "DBCppException.h"
#import "DBCppException+Private.h"
#import "DJICppWrapperCache+Private.h" #import "DJICppWrapperCache+Private.h"
#import "DJIError.h" #import "DJIError.h"
#import "DJIMarshal+Private.h" #import "DJIMarshal+Private.h"
#include <exception> #include <exception>
#include <stdexcept>
#include <utility> #include <utility>
static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");
...@@ -32,15 +32,15 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th ...@@ -32,15 +32,15 @@ static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for th
- (int32_t)throwAnException { - (int32_t)throwAnException {
try { try {
auto r = _cppRefHandle.get()->throw_an_exception(); auto objcpp_result_ = _cppRefHandle.get()->throw_an_exception();
return ::djinni::I32::fromCpp(r); return ::djinni::I32::fromCpp(objcpp_result_);
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
+ (nullable DBCppException *)get { + (nullable DBCppException *)get {
try { try {
auto r = ::testsuite::CppException::get(); auto objcpp_result_ = ::testsuite::CppException::get();
return ::djinni_generated::CppException::fromCpp(r); return ::djinni_generated::CppException::fromCpp(objcpp_result_);
} DJINNI_TRANSLATE_EXCEPTIONS() } DJINNI_TRANSLATE_EXCEPTIONS()
} }
......
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from enum.djinni
#include "enum_usage_interface.hpp"
#include <memory>
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<DBEnumUsageInterface>;
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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment