Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Jan 9, 2025
1 parent 2d4bb22 commit 123e5ae
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/nitrogen/src/syntax/kotlin/KotlinFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ namespace ${cxxNamespace} {
static auto constexpr kJavaDescriptor = "L${jniInterfaceDescriptor};";
public:
/**
* Invokes the function this \`J${name}\` instance holds through JNI.
*/
${functionType.returnType.getCode('c++')} invoke(${jniParams.join(', ')}) const {
${indent(jniCallBody, ' ')}
}
Expand All @@ -201,6 +204,9 @@ namespace ${cxxNamespace} {
}
public:
/**
* Invokes the C++ \`std::function<...>\` this \`J${name}_cxx\` instance holds.
*/
${bridgedReturn.asJniReferenceType('local')} invoke_cxx(${cppParams.join(', ')}) {
${indent(cppCallBody, ' ')}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ namespace margelo::nitro::image {
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_double__;";

public:
/**
* Invokes the function this `JFunc_std__shared_ptr_Promise_double__` instance holds through JNI.
*/
std::shared_ptr<Promise<double>> invoke() const {
static const auto method = getClass()->getMethod<jni::local_ref<JPromise::javaobject>()>("invoke");
auto __result = method(self());
Expand Down Expand Up @@ -55,6 +58,9 @@ namespace margelo::nitro::image {
}

public:
/**
* Invokes the C++ `std::function<...>` this `JFunc_std__shared_ptr_Promise_double___cxx` instance holds.
*/
jni::local_ref<JPromise::javaobject> invoke_cxx() {
std::shared_ptr<Promise<double>> __result = _func();
return [&]() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ namespace margelo::nitro::image {
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____;";

public:
/**
* Invokes the function this `JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____` instance holds through JNI.
*/
std::shared_ptr<Promise<std::shared_ptr<Promise<double>>>> invoke() const {
static const auto method = getClass()->getMethod<jni::local_ref<JPromise::javaobject>()>("invoke");
auto __result = method(self());
Expand Down Expand Up @@ -66,6 +69,9 @@ namespace margelo::nitro::image {
}

public:
/**
* Invokes the C++ `std::function<...>` this `JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____cxx` instance holds.
*/
jni::local_ref<JPromise::javaobject> invoke_cxx() {
std::shared_ptr<Promise<std::shared_ptr<Promise<double>>>> __result = _func();
return [&]() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ namespace margelo::nitro::image {
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____;";

public:
/**
* Invokes the function this `JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____` instance holds through JNI.
*/
std::shared_ptr<Promise<std::shared_ptr<Promise<std::shared_ptr<ArrayBuffer>>>>> invoke() const {
static const auto method = getClass()->getMethod<jni::local_ref<JPromise::javaobject>()>("invoke");
auto __result = method(self());
Expand Down Expand Up @@ -69,6 +72,9 @@ namespace margelo::nitro::image {
}

public:
/**
* Invokes the C++ `std::function<...>` this `JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______cxx` instance holds.
*/
jni::local_ref<JPromise::javaobject> invoke_cxx() {
std::shared_ptr<Promise<std::shared_ptr<Promise<std::shared_ptr<ArrayBuffer>>>>> __result = _func();
return [&]() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ namespace margelo::nitro::image {
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__string__;";

public:
/**
* Invokes the function this `JFunc_std__shared_ptr_Promise_std__string__` instance holds through JNI.
*/
std::shared_ptr<Promise<std::string>> invoke() const {
static const auto method = getClass()->getMethod<jni::local_ref<JPromise::javaobject>()>("invoke");
auto __result = method(self());
Expand Down Expand Up @@ -56,6 +59,9 @@ namespace margelo::nitro::image {
}

public:
/**
* Invokes the C++ `std::function<...>` this `JFunc_std__shared_ptr_Promise_std__string___cxx` instance holds.
*/
jni::local_ref<JPromise::javaobject> invoke_cxx() {
std::shared_ptr<Promise<std::string>> __result = _func();
return [&]() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ namespace margelo::nitro::image {
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void;";

public:
/**
* Invokes the function this `JFunc_void` instance holds through JNI.
*/
void invoke() const {
static const auto method = getClass()->getMethod<void()>("invoke");
method(self());
Expand All @@ -41,6 +44,9 @@ namespace margelo::nitro::image {
}

public:
/**
* Invokes the C++ `std::function<...>` this `JFunc_void_cxx` instance holds.
*/
void invoke_cxx() {
_func();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ namespace margelo::nitro::image {
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_double;";

public:
/**
* Invokes the function this `JFunc_void_double` instance holds through JNI.
*/
void invoke(double num) const {
static const auto method = getClass()->getMethod<void(double /* num */)>("invoke");
method(self(), num);
Expand All @@ -41,6 +44,9 @@ namespace margelo::nitro::image {
}

public:
/**
* Invokes the C++ `std::function<...>` this `JFunc_void_double_cxx` instance holds.
*/
void invoke_cxx(double num) {
_func(num);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ namespace margelo::nitro::image {
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__optional_double_;";

public:
/**
* Invokes the function this `JFunc_void_std__optional_double_` instance holds through JNI.
*/
void invoke(std::optional<double> maybe) const {
static const auto method = getClass()->getMethod<void(jni::alias_ref<jni::JDouble> /* maybe */)>("invoke");
method(self(), maybe.has_value() ? jni::JDouble::valueOf(maybe.value()) : nullptr);
Expand All @@ -42,6 +45,9 @@ namespace margelo::nitro::image {
}

public:
/**
* Invokes the C++ `std::function<...>` this `JFunc_void_std__optional_double__cxx` instance holds.
*/
void invoke_cxx(jni::alias_ref<jni::JDouble> maybe) {
_func(maybe != nullptr ? std::make_optional(maybe->value()) : std::nullopt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ namespace margelo::nitro::image {
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__string;";

public:
/**
* Invokes the function this `JFunc_void_std__string` instance holds through JNI.
*/
void invoke(const std::string& valueFromJs) const {
static const auto method = getClass()->getMethod<void(jni::alias_ref<jni::JString> /* valueFromJs */)>("invoke");
method(self(), jni::make_jstring(valueFromJs));
Expand All @@ -42,6 +45,9 @@ namespace margelo::nitro::image {
}

public:
/**
* Invokes the C++ `std::function<...>` this `JFunc_void_std__string_cxx` instance holds.
*/
void invoke_cxx(jni::alias_ref<jni::JString> valueFromJs) {
_func(valueFromJs->toStdString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ namespace margelo::nitro::image {
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__vector_Powertrain_;";

public:
/**
* Invokes the function this `JFunc_void_std__vector_Powertrain_` instance holds through JNI.
*/
void invoke(const std::vector<Powertrain>& array) const {
static const auto method = getClass()->getMethod<void(jni::alias_ref<jni::JArrayClass<JPowertrain>> /* array */)>("invoke");
method(self(), [&]() {
Expand All @@ -52,6 +55,9 @@ namespace margelo::nitro::image {
}

public:
/**
* Invokes the C++ `std::function<...>` this `JFunc_void_std__vector_Powertrain__cxx` instance holds.
*/
void invoke_cxx(jni::alias_ref<jni::JArrayClass<JPowertrain>> array) {
_func([&]() {
size_t __size = array->size();
Expand Down

0 comments on commit 123e5ae

Please sign in to comment.