Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0001a3e
Follow naming convention for parameter names in method docstrings (#352)
louiswins Feb 22, 2018
9463fa9
Generate an XCode like bridging header. (#342)
yageek Mar 2, 2018
a38f5ee
Added support for constexpr for primitives in header files (#354)
alancast May 1, 2018
f207582
Upgrade sbt and scala version dependencies for JDK 9 compatibility (#…
jfirebaugh Jul 16, 2018
2ab4b4e
Separate `constant_enum` to `constant_enum.djinni (#385)
Jul 17, 2018
f29210d
Rename destroy() to __destroy() (#365)
sheldonneuberger Jul 17, 2018
776207c
Improve IDEA plugin (#363)
ice1000 Jul 17, 2018
7941eec
Provides Clang Compatibility (#378)
jonmcclung Jul 17, 2018
e1dd18e
Check for Duplicate Output Paths (#381)
jonmcclung Jul 17, 2018
b4d8d0f
Optionally generate interfaces in Java when possible (#288)
csimmons0 Jul 17, 2018
28b6e91
Update generated source code
Jul 17, 2018
9d11894
Fix run and run-assume-built scripts when CDPATH is set (#358)
jfirebaugh Jul 17, 2018
6986cc4
Fix error ‘constexpr’ needed for in-class initialization of static da…
Jul 18, 2018
a8325df
Add Android Parcelable records documentation (#382)
4brunu Jul 18, 2018
0ee3da6
Implement comments support (#379)
4brunu Jul 18, 2018
d547548
Revert "Implement comments support (#379)"
Jul 19, 2018
35e5961
Improve error message for missing `deriving (...)`
danyowdee Aug 23, 2018
6a4008e
Introduce Record.DerivingType.Show
danyowdee Aug 23, 2018
f54694c
Generate `operator<<` for records deriving show
danyowdee Aug 23, 2018
5ca0b04
Add pretty printing to C++ enums
danyowdee Nov 9, 2018
adc5509
Generate overloads to print collections
danyowdee Nov 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ The complete list of contributors can be identified through
Git history.

- Google Inc.
- Microsoft Corp.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,14 @@ For more informations, take a look at https://github.com/leetal/ios-cmake.

- `ENABLE_BITCODE`: enable/disable the bitcode generation.

## Android Parcelable records

Djinni supports generating records that implements `android.os.parcelable`.

In order to do that, there are two steps needed:
- deriving the records that should be parcelable with the keyword parcelable: `deriving(parcelable)`
- run Djinni with the following flag `--java-implement-android-os-parcelable true`

## Community Links

* Join the discussion with other developers at the [Mobile C++ Slack Community](https://mobilecpp.herokuapp.com/)
Expand Down
6 changes: 6 additions & 0 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ android {
versionCode 1
versionName "1.0"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
release {
minifyEnabled false
Expand Down
11 changes: 11 additions & 0 deletions example/generated-src/cpp/sort_order.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <functional>
#include <ostream>

namespace textsort {

Expand All @@ -13,6 +14,16 @@ enum class sort_order : int {
RANDOM,
};

static inline ::std::ostream& operator<<(::std::ostream& os, sort_order v) {
os << "sort_order::";
switch (v) {
case sort_order::ASCENDING: return os << "ASCENDING";
case sort_order::DESCENDING: return os << "DESCENDING";
case sort_order::RANDOM: return os << "RANDOM";
default: return os << "<Unsupported Value " << static_cast<int>(v) << ">";
}
}

} // namespace textsort

namespace std {
Expand Down
26 changes: 19 additions & 7 deletions example/generated-src/java/com/dropbox/textsort/SortItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

/*package*/ abstract class SortItems {
/*package*/ interface SortItems {
/** For the iOS / Android demo */
public abstract void sort(@Nonnull SortOrder order, @Nonnull ItemList items);
public void sort(@Nonnull SortOrder order, @Nonnull ItemList items);

@CheckForNull
public static native SortItems createWithListener(@CheckForNull TextboxListener listener);
public static SortItems createWithListener(@CheckForNull TextboxListener listener)
{
return CppProxy.createWithListener(listener);
}

/** For the localhost / command-line demo */
@Nonnull
public static native ItemList runSort(@Nonnull ItemList items);
public static ItemList runSort(@Nonnull ItemList items)
{
return CppProxy.runSort(items);
}

private static final class CppProxy extends SortItems
static final class CppProxy implements SortItems
{
private final long nativeRef;
private final AtomicBoolean destroyed = new AtomicBoolean(false);
Expand All @@ -30,14 +36,14 @@ private CppProxy(long nativeRef)
}

private native void nativeDestroy(long nativeRef);
public void destroy()
public void _djinni_private_destroy()
{
boolean destroyed = this.destroyed.getAndSet(true);
if (!destroyed) nativeDestroy(this.nativeRef);
}
protected void finalize() throws java.lang.Throwable
{
destroy();
_djinni_private_destroy();
super.finalize();
}

Expand All @@ -48,5 +54,11 @@ public void sort(SortOrder order, ItemList items)
native_sort(this.nativeRef, order, items);
}
private native void native_sort(long _nativeRef, SortOrder order, ItemList items);

@CheckForNull
public static native SortItems createWithListener(@CheckForNull TextboxListener listener);

@Nonnull
public static native ItemList runSort(@Nonnull ItemList items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

/*package*/ abstract class TextboxListener {
public abstract void update(@Nonnull ItemList items);
/*package*/ interface TextboxListener {
public void update(@Nonnull ItemList items);
}
4 changes: 2 additions & 2 deletions example/generated-src/jni/NativeSortItems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CJNIEXPORT void JNICALL Java_com_dropbox_textsort_SortItems_00024CppProxy_native
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
}

CJNIEXPORT jobject JNICALL Java_com_dropbox_textsort_SortItems_createWithListener(JNIEnv* jniEnv, jobject /*this*/, jobject j_listener)
CJNIEXPORT jobject JNICALL Java_com_dropbox_textsort_SortItems_00024CppProxy_createWithListener(JNIEnv* jniEnv, jobject /*this*/, jobject j_listener)
{
try {
DJINNI_FUNCTION_PROLOGUE0(jniEnv);
Expand All @@ -40,7 +40,7 @@ CJNIEXPORT jobject JNICALL Java_com_dropbox_textsort_SortItems_createWithListene
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */)
}

CJNIEXPORT jobject JNICALL Java_com_dropbox_textsort_SortItems_runSort(JNIEnv* jniEnv, jobject /*this*/, jobject j_items)
CJNIEXPORT jobject JNICALL Java_com_dropbox_textsort_SortItems_00024CppProxy_runSort(JNIEnv* jniEnv, jobject /*this*/, jobject j_items)
{
try {
DJINNI_FUNCTION_PROLOGUE0(jniEnv);
Expand Down
11 changes: 11 additions & 0 deletions example/generated-src/objc/TextSort-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni

// TextSort_Bridging_Header.h
// TextSort_Bridging_Header

#import <Foundation/Foundation.h>

//! Project version number for TextSortBridgingHeader.
FOUNDATION_EXPORT double TextSortBridgingHeaderVersionNumber;

//! Project version string for TextSortBridgingHeader.
FOUNDATION_EXPORT const unsigned char TextSortBridgingHeaderVersionString[];

#import "TXSItemList.h"
#import "TXSSortOrder.h"
#import "TXSSortItems.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import java.util.ArrayList;

public class TextboxListenerImpl extends TextboxListener {
public class TextboxListenerImpl implements TextboxListener {

private EditText mTextArea;

Expand Down
1 change: 1 addition & 0 deletions example/run_djinni.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fi
--java-out "$temp_out/java" \
--java-package $java_package \
--java-class-access-modifier "package" \
--java-generate-interfaces true \
--java-nullable-annotation "javax.annotation.CheckForNull" \
--java-nonnull-annotation "javax.annotation.Nonnull" \
--ident-java-field mFooBar \
Expand Down
3 changes: 3 additions & 0 deletions intellij-plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
out/
*~
resources/META-INF
5 changes: 3 additions & 2 deletions intellij-plugin/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<idea-plugin version="2">
<idea-plugin>
<id>com.dropbox.djinni.ideaplugin</id>
<name>Djinni IDL file support</name>
<version>0.8</version>
<version>0.8.1</version>
<vendor url="https://github.com/dropbox/djinni">Dropbox Djinni Github Project</vendor>

<description><![CDATA[
Expand Down Expand Up @@ -70,6 +70,7 @@
<lang.psiStructureViewFactory language="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniStructureViewFactory"/>
<lang.formatter language="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniFormattingModelBuilder"/>
<lang.commenter language="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniCommenter"/>
<lang.braceMatcher language="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniBraceMatcher"/>
</extensions>

<application-components>
Expand Down
Loading