Skip to content

Commit

Permalink
fix: Use getFunction()
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Dec 30, 2024
1 parent f927558 commit bbd746e
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ export class KotlinCxxBridgedType implements BridgedType<'kotlin', 'c++'> {
case 'function': {
switch (language) {
case 'c++':
return `${parameterName}->cthis()->toCpp()`
return `${parameterName}->cthis()->getFunction()`
default:
return parameterName
}
Expand Down
5 changes: 5 additions & 0 deletions packages/nitrogen/src/syntax/kotlin/KotlinFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ namespace ${cxxNamespace} {
${indent(callBody, ' ')}
}
public:
inline const ${typename}& getFunction() const {
return _func;
}
public:
static auto constexpr kJavaDescriptor = "L${jniClassDescriptor};";
static void registerNatives() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ namespace margelo::nitro::image {
}();
}

public:
inline const std::function<std::shared_ptr<Promise<double>>()>& getFunction() const {
return _func;
}

public:
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_double__;";
static void registerNatives() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ namespace margelo::nitro::image {
}();
}

public:
inline const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<double>>>>()>& getFunction() const {
return _func;
}

public:
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____;";
static void registerNatives() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ namespace margelo::nitro::image {
}();
}

public:
inline const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<std::shared_ptr<ArrayBuffer>>>>>()>& getFunction() const {
return _func;
}

public:
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____;";
static void registerNatives() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ namespace margelo::nitro::image {
}();
}

public:
inline const std::function<std::shared_ptr<Promise<std::string>>()>& getFunction() const {
return _func;
}

public:
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_std__shared_ptr_Promise_std__string__;";
static void registerNatives() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ namespace margelo::nitro::image {
_func();
}

public:
inline const std::function<void()>& getFunction() const {
return _func;
}

public:
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void;";
static void registerNatives() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ namespace margelo::nitro::image {
_func(num);
}

public:
inline const std::function<void(double /* num */)>& getFunction() const {
return _func;
}

public:
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_double;";
static void registerNatives() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ namespace margelo::nitro::image {
_func(maybe != nullptr ? std::make_optional(maybe->value()) : std::nullopt);
}

public:
inline const std::function<void(std::optional<double> /* maybe */)>& getFunction() const {
return _func;
}

public:
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__optional_double_;";
static void registerNatives() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ namespace margelo::nitro::image {
_func(valueFromJs->toStdString());
}

public:
inline const std::function<void(const std::string& /* valueFromJs */)>& getFunction() const {
return _func;
}

public:
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__string;";
static void registerNatives() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ namespace margelo::nitro::image {
}());
}

public:
inline const std::function<void(const std::vector<Powertrain>& /* array */)>& getFunction() const {
return _func;
}

public:
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/image/Func_void_std__vector_Powertrain_;";
static void registerNatives() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace margelo::nitro::image {
jni::local_ref<JFunc_void_double::javaobject> onChanged = this->getFieldValue(fieldOnChanged);
return JsStyleStruct(
value,
onChanged->cthis()->toCpp()
onChanged->cthis()->getFunction()
);
}

Expand Down

0 comments on commit bbd746e

Please sign in to comment.