Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deprecated): generate language specific deprecation markup #156

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
55 changes: 55 additions & 0 deletions src/it/resources/deprecation.djinni
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 src/it/resources/expected/deprecation/cpp-headers/my_enum.hpp
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 src/it/resources/expected/deprecation/cpp-headers/my_flags.hpp
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 src/it/resources/expected/deprecation/cpp-headers/my_interface.hpp
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 src/it/resources/expected/deprecation/cpp-headers/my_record.hpp
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_))
{}
};
6 changes: 6 additions & 0 deletions src/it/resources/expected/deprecation/cpp/my_interface.cpp
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;
5 changes: 5 additions & 0 deletions src/it/resources/expected/deprecation/generated-files.txt
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
19 changes: 19 additions & 0 deletions src/it/resources/expected/deprecation/java/MyEnum.java
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,
;
}
19 changes: 19 additions & 0 deletions src/it/resources/expected/deprecation/java/MyFlags.java
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 src/it/resources/expected/deprecation/java/MyInterface.java
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);
}
}
Loading
Loading