This repository has been archived by the owner on Mar 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate
constant_enum
to `constant_enum.djinni (#385)
Separate constant_enum to constant_enum.djinni, to exclude it from common.djinni, so that it wouldn’t be picked up by Python in python branch. Otherwise it causes failure in python branch since constant enum feature is not implemented for Python.
- Loading branch information
Xianwen Chen
committed
Jul 17, 2018
1 parent
f207582
commit 2ab4b4e
Showing
40 changed files
with
479 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
@import "common.djinni" | ||
|
||
@import "enum_flags.djinni" | ||
@import "constant_enum.djinni" | ||
|
||
@import "vendor/third-party/date.djinni" | ||
@import "third-party/duration.djinni" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# enum for use in constants | ||
constant_enum = enum { | ||
some_value; | ||
some_other_value; | ||
} | ||
|
||
# Record containing enum constant | ||
constant_with_enum = record { | ||
const const_enum: constant_enum = constant_enum::some_value; | ||
} | ||
|
||
# Interface containing enum constant | ||
constant_interface_with_enum = interface +c { | ||
const const_enum: constant_enum = constant_enum::some_value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test-suite/generated-src/cpp/constant_interface_with_enum.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni from constant_enum.djinni | ||
|
||
#include "constant_interface_with_enum.hpp" // my header | ||
#include "constant_enum.hpp" | ||
|
||
namespace testsuite { | ||
|
||
constant_enum const ConstantInterfaceWithEnum::CONST_ENUM = constant_enum::SOME_VALUE; | ||
|
||
} // namespace testsuite |
18 changes: 18 additions & 0 deletions
18
test-suite/generated-src/cpp/constant_interface_with_enum.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni from constant_enum.djinni | ||
|
||
#pragma once | ||
|
||
namespace testsuite { | ||
|
||
enum class constant_enum; | ||
|
||
/** Interface containing enum constant */ | ||
class ConstantInterfaceWithEnum { | ||
public: | ||
virtual ~ConstantInterfaceWithEnum() {} | ||
|
||
static constant_enum const CONST_ENUM; | ||
}; | ||
|
||
} // namespace testsuite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni from constant_enum.djinni | ||
|
||
#include "constant_with_enum.hpp" // my header | ||
|
||
namespace testsuite { | ||
|
||
constant_enum const ConstantWithEnum::CONST_ENUM = constant_enum::SOME_VALUE; | ||
|
||
} // namespace testsuite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni from constant_enum.djinni | ||
|
||
#pragma once | ||
|
||
#include "constant_enum.hpp" | ||
#include <utility> | ||
|
||
namespace testsuite { | ||
|
||
/** Record containing enum constant */ | ||
struct ConstantWithEnum final { | ||
|
||
static constant_enum const CONST_ENUM; | ||
}; | ||
|
||
} // namespace testsuite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test-suite/generated-src/java/com/dropbox/djinni/test/ConstantEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
test-suite/generated-src/java/com/dropbox/djinni/test/ConstantInterfaceWithEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni from constant_enum.djinni | ||
|
||
package com.dropbox.djinni.test; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
import javax.annotation.CheckForNull; | ||
import javax.annotation.Nonnull; | ||
|
||
/** Interface containing enum constant */ | ||
public abstract class ConstantInterfaceWithEnum { | ||
@Nonnull | ||
public static final ConstantEnum CONST_ENUM = ConstantEnum.SOME_VALUE; | ||
|
||
|
||
private static final class CppProxy extends ConstantInterfaceWithEnum | ||
{ | ||
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(); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
test-suite/generated-src/java/com/dropbox/djinni/test/ConstantWithEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni from constant_enum.djinni | ||
|
||
package com.dropbox.djinni.test; | ||
|
||
import javax.annotation.CheckForNull; | ||
import javax.annotation.Nonnull; | ||
|
||
/** Record containing enum constant */ | ||
public class ConstantWithEnum { | ||
|
||
@Nonnull | ||
public static final ConstantEnum CONST_ENUM = ConstantEnum.SOME_VALUE; | ||
|
||
|
||
public ConstantWithEnum( | ||
) { | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ConstantWithEnum{" + | ||
"}"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
test-suite/generated-src/jni/NativeConstantInterfaceWithEnum.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni from constant_enum.djinni | ||
|
||
#include "NativeConstantInterfaceWithEnum.hpp" // my header | ||
#include "NativeConstantEnum.hpp" | ||
|
||
namespace djinni_generated { | ||
|
||
NativeConstantInterfaceWithEnum::NativeConstantInterfaceWithEnum() : ::djinni::JniInterface<::testsuite::ConstantInterfaceWithEnum, NativeConstantInterfaceWithEnum>("com/dropbox/djinni/test/ConstantInterfaceWithEnum$CppProxy") {} | ||
|
||
NativeConstantInterfaceWithEnum::~NativeConstantInterfaceWithEnum() = default; | ||
|
||
|
||
CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_ConstantInterfaceWithEnum_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) | ||
{ | ||
try { | ||
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef); | ||
delete reinterpret_cast<::djinni::CppProxyHandle<::testsuite::ConstantInterfaceWithEnum>*>(nativeRef); | ||
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) | ||
} | ||
|
||
} // namespace djinni_generated |
32 changes: 32 additions & 0 deletions
32
test-suite/generated-src/jni/NativeConstantInterfaceWithEnum.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni from constant_enum.djinni | ||
|
||
#pragma once | ||
|
||
#include "constant_interface_with_enum.hpp" | ||
#include "djinni_support.hpp" | ||
|
||
namespace djinni_generated { | ||
|
||
class NativeConstantInterfaceWithEnum final : ::djinni::JniInterface<::testsuite::ConstantInterfaceWithEnum, NativeConstantInterfaceWithEnum> { | ||
public: | ||
using CppType = std::shared_ptr<::testsuite::ConstantInterfaceWithEnum>; | ||
using CppOptType = std::shared_ptr<::testsuite::ConstantInterfaceWithEnum>; | ||
using JniType = jobject; | ||
|
||
using Boxed = NativeConstantInterfaceWithEnum; | ||
|
||
~NativeConstantInterfaceWithEnum(); | ||
|
||
static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeConstantInterfaceWithEnum>::get()._fromJava(jniEnv, j); } | ||
static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeConstantInterfaceWithEnum>::get()._toJava(jniEnv, c)}; } | ||
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } | ||
|
||
private: | ||
NativeConstantInterfaceWithEnum(); | ||
friend ::djinni::JniClass<NativeConstantInterfaceWithEnum>; | ||
friend ::djinni::JniInterface<::testsuite::ConstantInterfaceWithEnum, NativeConstantInterfaceWithEnum>; | ||
|
||
}; | ||
|
||
} // namespace djinni_generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni from constant_enum.djinni | ||
|
||
#include "NativeConstantWithEnum.hpp" // my header | ||
|
||
namespace djinni_generated { | ||
|
||
NativeConstantWithEnum::NativeConstantWithEnum() = default; | ||
|
||
NativeConstantWithEnum::~NativeConstantWithEnum() = default; | ||
|
||
auto NativeConstantWithEnum::fromCpp(JNIEnv* jniEnv, const CppType& c) -> ::djinni::LocalRef<JniType> { | ||
(void)c; // Suppress warnings in release builds for empty records | ||
const auto& data = ::djinni::JniClass<NativeConstantWithEnum>::get(); | ||
auto r = ::djinni::LocalRef<JniType>{jniEnv->NewObject(data.clazz.get(), data.jconstructor)}; | ||
::djinni::jniExceptionCheck(jniEnv); | ||
return r; | ||
} | ||
|
||
auto NativeConstantWithEnum::toCpp(JNIEnv* jniEnv, JniType j) -> CppType { | ||
::djinni::JniLocalScope jscope(jniEnv, 1); | ||
assert(j != nullptr); | ||
(void)j; // Suppress warnings in release builds for empty records | ||
return {}; | ||
} | ||
|
||
} // namespace djinni_generated |
Oops, something went wrong.