-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deprecated): generate language specific deprecation markup from @…
…deprecated text in comments (#156) If @deprecated is present in a comment, a deprecation marker will be generated. @deprecated is expected to be at the start of a line, any text following it on the same line is added as the ‘message’ text where supported This applies to records/attributes/constants, interfaces/methods/constants, enums/values, flags/values Supports C++, Java and ObjC generators
- Loading branch information
Showing
21 changed files
with
711 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
# enum comment | ||
# | ||
# @deprecated Use something else | ||
my_enum = enum { | ||
# @deprecated Use something else | ||
option1; | ||
# not deprecated | ||
option2; | ||
} | ||
|
||
# flags comment | ||
# | ||
# @deprecated Use someother flags | ||
my_flags = flags { | ||
# @deprecated Use someother flag | ||
flag1; | ||
# not deprecated | ||
flag2; | ||
} | ||
|
||
# record comment | ||
# | ||
# @deprecated Use someother record | ||
my_record = record { | ||
# @deprecated Use someother attribute | ||
attribute: string; | ||
# not deprecated | ||
another: string; | ||
# @deprecated Use someother attribute | ||
again: string; | ||
|
||
# @deprecated Use someother constant | ||
const version: i32 = 1; | ||
} | ||
|
||
# interface comment | ||
# | ||
# @deprecated Use someother interface | ||
my_interface = interface +c { | ||
# @deprecated Use someother method | ||
method_a(value:i32); | ||
# @deprecated Use someother method | ||
const method_b(value:i32); | ||
# @deprecated Use someother method | ||
static method_c(value:i32); | ||
# not deprecated | ||
method_d(); | ||
|
||
# really im not | ||
method_e(); | ||
|
||
# @deprecated Use someother constant | ||
const version: i32 = 1; | ||
} |
29 changes: 29 additions & 0 deletions
29
src/it/resources/expected/deprecation/cpp-headers/my_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,29 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file was generated by Djinni from deprecation.djinni | ||
|
||
#pragma once | ||
|
||
#include <functional> | ||
|
||
/** | ||
* enum comment | ||
* | ||
* @deprecated Use something else | ||
*/ | ||
enum class [[deprecated("Use something else")]] MyEnum : int { | ||
/** @deprecated Use something else */ | ||
OPTION1, | ||
/** not deprecated */ | ||
OPTION2, | ||
}; | ||
|
||
namespace std { | ||
|
||
template <> | ||
struct hash<::MyEnum> { | ||
size_t operator()(::MyEnum type) const { | ||
return std::hash<int>()(static_cast<int>(type)); | ||
} | ||
}; | ||
|
||
} // namespace std |
50 changes: 50 additions & 0 deletions
50
src/it/resources/expected/deprecation/cpp-headers/my_flags.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,50 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file was generated by Djinni from deprecation.djinni | ||
|
||
#pragma once | ||
|
||
#include <functional> | ||
|
||
/** | ||
* flags comment | ||
* | ||
* @deprecated Use someother flags | ||
*/ | ||
enum class [[deprecated("Use someother flags")]] MyFlags : unsigned { | ||
/** @deprecated Use someother flag */ | ||
FLAG1 = 1u << 0, | ||
/** not deprecated */ | ||
FLAG2 = 1u << 1, | ||
}; | ||
constexpr MyFlags operator|(MyFlags lhs, MyFlags rhs) noexcept { | ||
return static_cast<MyFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); | ||
} | ||
inline MyFlags& operator|=(MyFlags& lhs, MyFlags rhs) noexcept { | ||
return lhs = lhs | rhs; | ||
} | ||
constexpr MyFlags operator&(MyFlags lhs, MyFlags rhs) noexcept { | ||
return static_cast<MyFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); | ||
} | ||
inline MyFlags& operator&=(MyFlags& lhs, MyFlags rhs) noexcept { | ||
return lhs = lhs & rhs; | ||
} | ||
constexpr MyFlags operator^(MyFlags lhs, MyFlags rhs) noexcept { | ||
return static_cast<MyFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); | ||
} | ||
inline MyFlags& operator^=(MyFlags& lhs, MyFlags rhs) noexcept { | ||
return lhs = lhs ^ rhs; | ||
} | ||
constexpr MyFlags operator~(MyFlags x) noexcept { | ||
return static_cast<MyFlags>(~static_cast<unsigned>(x)); | ||
} | ||
|
||
namespace std { | ||
|
||
template <> | ||
struct hash<::MyFlags> { | ||
size_t operator()(::MyFlags type) const { | ||
return std::hash<unsigned>()(static_cast<unsigned>(type)); | ||
} | ||
}; | ||
|
||
} // namespace std |
38 changes: 38 additions & 0 deletions
38
src/it/resources/expected/deprecation/cpp-headers/my_interface.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,38 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file was generated by Djinni from deprecation.djinni | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
/** | ||
* interface comment | ||
* | ||
* @deprecated Use someother interface | ||
*/ | ||
class [[deprecated("Use someother interface")]] MyInterface { | ||
public: | ||
virtual ~MyInterface() {} | ||
|
||
/** @deprecated Use someother constant */ | ||
[[deprecated("Use someother constant")]] | ||
static constexpr int32_t VERSION = 1; | ||
|
||
/** @deprecated Use someother method */ | ||
[[deprecated("Use someother method")]] | ||
virtual void method_a(int32_t value) = 0; | ||
|
||
/** @deprecated Use someother method */ | ||
[[deprecated("Use someother method")]] | ||
virtual void method_b(int32_t value) const = 0; | ||
|
||
/** @deprecated Use someother method */ | ||
[[deprecated("Use someother method")]] | ||
static void method_c(int32_t value); | ||
|
||
/** not deprecated */ | ||
virtual void method_d() = 0; | ||
|
||
/** really im not */ | ||
virtual void method_e() = 0; | ||
}; |
36 changes: 36 additions & 0 deletions
36
src/it/resources/expected/deprecation/cpp-headers/my_record.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,36 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file was generated by Djinni from deprecation.djinni | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <string> | ||
#include <utility> | ||
|
||
/** | ||
* record comment | ||
* | ||
* @deprecated Use someother record | ||
*/ | ||
struct [[deprecated("Use someother record")]] MyRecord final { | ||
|
||
/** @deprecated Use someother constant */ | ||
[[deprecated("Use someother constant")]] | ||
static constexpr int32_t VERSION = 1; | ||
/** @deprecated Use someother attribute */ | ||
[[deprecated("Use someother attribute")]] | ||
std::string attribute; | ||
/** not deprecated */ | ||
std::string another; | ||
/** @deprecated Use someother attribute */ | ||
[[deprecated("Use someother attribute")]] | ||
std::string again; | ||
|
||
MyRecord(std::string attribute_, | ||
std::string another_, | ||
std::string again_) | ||
: attribute(std::move(attribute_)) | ||
, another(std::move(another_)) | ||
, again(std::move(again_)) | ||
{} | ||
}; |
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,6 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file was generated by Djinni from deprecation.djinni | ||
|
||
#include "my_interface.hpp" // my header | ||
|
||
int32_t constexpr MyInterface::VERSION; |
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,5 @@ | ||
src/it/resources/result/deprecation/cpp-headers/my_enum.hpp | ||
src/it/resources/result/deprecation/cpp-headers/my_flags.hpp | ||
src/it/resources/result/deprecation/cpp-headers/my_record.hpp | ||
src/it/resources/result/deprecation/cpp-headers/my_interface.hpp | ||
src/it/resources/result/deprecation/cpp/my_interface.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,19 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file was generated by Djinni from deprecation.djinni | ||
|
||
package djinni.it; | ||
|
||
/** | ||
* enum comment | ||
* | ||
* @deprecated Use something else | ||
*/ | ||
@Deprecated | ||
public enum MyEnum { | ||
/** @deprecated Use something else */ | ||
@Deprecated | ||
OPTION1, | ||
/** not deprecated */ | ||
OPTION2, | ||
; | ||
} |
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,19 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file was generated by Djinni from deprecation.djinni | ||
|
||
package djinni.it; | ||
|
||
/** | ||
* flags comment | ||
* | ||
* @deprecated Use someother flags | ||
*/ | ||
@Deprecated | ||
public enum MyFlags { | ||
/** @deprecated Use someother flag */ | ||
@Deprecated | ||
FLAG1, | ||
/** not deprecated */ | ||
FLAG2, | ||
; | ||
} |
98 changes: 98 additions & 0 deletions
98
src/it/resources/expected/deprecation/java/MyInterface.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,98 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file was generated by Djinni from deprecation.djinni | ||
|
||
package djinni.it; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
/** | ||
* interface comment | ||
* | ||
* @deprecated Use someother interface | ||
*/ | ||
@Deprecated | ||
public abstract class MyInterface { | ||
/** @deprecated Use someother constant */ | ||
@Deprecated | ||
public static final int VERSION = 1; | ||
|
||
/** @deprecated Use someother method */ | ||
@Deprecated | ||
public abstract void methodA(int value); | ||
|
||
/** @deprecated Use someother method */ | ||
@Deprecated | ||
public abstract void methodB(int value); | ||
|
||
/** not deprecated */ | ||
public abstract void methodD(); | ||
|
||
/** really im not */ | ||
public abstract void methodE(); | ||
|
||
/** @deprecated Use someother method */ | ||
@Deprecated | ||
public static void methodC(int value) | ||
{ | ||
CppProxy.methodC(value); | ||
} | ||
|
||
private static final class CppProxy extends MyInterface | ||
{ | ||
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 _djinni_private_destroy() | ||
{ | ||
boolean destroyed = this.destroyed.getAndSet(true); | ||
if (!destroyed) nativeDestroy(this.nativeRef); | ||
} | ||
@SuppressWarnings("deprecation") | ||
protected void finalize() throws java.lang.Throwable | ||
{ | ||
_djinni_private_destroy(); | ||
super.finalize(); | ||
} | ||
|
||
@Override | ||
public void methodA(int value) | ||
{ | ||
assert !this.destroyed.get() : "trying to use a destroyed object"; | ||
native_methodA(this.nativeRef, value); | ||
} | ||
private native void native_methodA(long _nativeRef, int value); | ||
|
||
@Override | ||
public void methodB(int value) | ||
{ | ||
assert !this.destroyed.get() : "trying to use a destroyed object"; | ||
native_methodB(this.nativeRef, value); | ||
} | ||
private native void native_methodB(long _nativeRef, int value); | ||
|
||
@Override | ||
public void methodD() | ||
{ | ||
assert !this.destroyed.get() : "trying to use a destroyed object"; | ||
native_methodD(this.nativeRef); | ||
} | ||
private native void native_methodD(long _nativeRef); | ||
|
||
@Override | ||
public void methodE() | ||
{ | ||
assert !this.destroyed.get() : "trying to use a destroyed object"; | ||
native_methodE(this.nativeRef); | ||
} | ||
private native void native_methodE(long _nativeRef); | ||
|
||
public static native void methodC(int value); | ||
} | ||
} |
Oops, something went wrong.