-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: new gen fix: enums wip feat: generate kotlin fix: make ios work
- Loading branch information
Showing
51 changed files
with
2,625 additions
and
1,468 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
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
86 changes: 86 additions & 0 deletions
86
packages/npm/send/nitrogen/generated/android/c++/JCode.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,86 @@ | ||
/// | ||
/// JCode.hpp | ||
/// Fri Aug 30 2024 | ||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. | ||
/// https://github.com/mrousavy/nitro | ||
/// Copyright © 2024 Marc Rousavy @ Margelo | ||
/// | ||
|
||
#pragma once | ||
|
||
#include <fbjni/fbjni.h> | ||
#include "Code.hpp" | ||
|
||
namespace margelo::nitro::send { | ||
|
||
using namespace facebook; | ||
|
||
/** | ||
* The C++ JNI bridge between the C++ enum "Code" and the the Kotlin enum "Code". | ||
*/ | ||
struct JCode final: public jni::JavaClass<JCode> { | ||
public: | ||
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/candlefinance_send/Code;"; | ||
|
||
public: | ||
/** | ||
* Convert this Java/Kotlin-based enum to the C++ enum Code. | ||
*/ | ||
[[maybe_unused]] | ||
Code toCpp() const { | ||
static const auto clazz = javaClassStatic(); | ||
static const auto fieldOrdinal = clazz->getField<int>("ordinal"); | ||
int ordinal = this->getFieldValue(fieldOrdinal); | ||
return static_cast<Code>(ordinal); | ||
} | ||
|
||
public: | ||
/** | ||
* Create a Java/Kotlin-based enum with the given C++ enum's value. | ||
*/ | ||
[[maybe_unused]] | ||
static jni::alias_ref<JCode> fromCpp(Code value) { | ||
static const auto clazz = javaClassStatic(); | ||
static const auto fieldRESPONSE_INVALID = clazz->getStaticField<JCode>("RESPONSE_INVALID"); | ||
static const auto fieldREQUEST_INVALID = clazz->getStaticField<JCode>("REQUEST_INVALID"); | ||
static const auto fieldNETWORK_ERROR = clazz->getStaticField<JCode>("NETWORK_ERROR"); | ||
static const auto fieldNO_RESPONSE = clazz->getStaticField<JCode>("NO_RESPONSE"); | ||
static const auto fieldNON_UTF8_RESPONSE_BODY = clazz->getStaticField<JCode>("NON_UTF8_RESPONSE_BODY"); | ||
static const auto fieldNON_UTF8_REQUEST_BODY = clazz->getStaticField<JCode>("NON_UTF8_REQUEST_BODY"); | ||
static const auto fieldINVALID_REQUEST_PATH_OR_QUERY_PARAMETERS = clazz->getStaticField<JCode>("INVALID_REQUEST_PATH_OR_QUERY_PARAMETERS"); | ||
static const auto fieldINVALID_REQUEST_BASE_URL = clazz->getStaticField<JCode>("INVALID_REQUEST_BASE_URL"); | ||
static const auto fieldNON_BASE64_REQUEST_BODY = clazz->getStaticField<JCode>("NON_BASE64_REQUEST_BODY"); | ||
static const auto fieldINVALID_RESPONSE_HEADER_PARAMETERS = clazz->getStaticField<JCode>("INVALID_RESPONSE_HEADER_PARAMETERS"); | ||
static const auto fieldUNEXPECTED = clazz->getStaticField<JCode>("UNEXPECTED"); | ||
|
||
switch (value) { | ||
case Code::RESPONSE_INVALID: | ||
return clazz->getStaticFieldValue(fieldRESPONSE_INVALID); | ||
case Code::REQUEST_INVALID: | ||
return clazz->getStaticFieldValue(fieldREQUEST_INVALID); | ||
case Code::NETWORK_ERROR: | ||
return clazz->getStaticFieldValue(fieldNETWORK_ERROR); | ||
case Code::NO_RESPONSE: | ||
return clazz->getStaticFieldValue(fieldNO_RESPONSE); | ||
case Code::NON_UTF8_RESPONSE_BODY: | ||
return clazz->getStaticFieldValue(fieldNON_UTF8_RESPONSE_BODY); | ||
case Code::NON_UTF8_REQUEST_BODY: | ||
return clazz->getStaticFieldValue(fieldNON_UTF8_REQUEST_BODY); | ||
case Code::INVALID_REQUEST_PATH_OR_QUERY_PARAMETERS: | ||
return clazz->getStaticFieldValue(fieldINVALID_REQUEST_PATH_OR_QUERY_PARAMETERS); | ||
case Code::INVALID_REQUEST_BASE_URL: | ||
return clazz->getStaticFieldValue(fieldINVALID_REQUEST_BASE_URL); | ||
case Code::NON_BASE64_REQUEST_BODY: | ||
return clazz->getStaticFieldValue(fieldNON_BASE64_REQUEST_BODY); | ||
case Code::INVALID_RESPONSE_HEADER_PARAMETERS: | ||
return clazz->getStaticFieldValue(fieldINVALID_RESPONSE_HEADER_PARAMETERS); | ||
case Code::UNEXPECTED: | ||
return clazz->getStaticFieldValue(fieldUNEXPECTED); | ||
default: | ||
std::string stringValue = std::to_string(static_cast<int>(value)); | ||
throw std::runtime_error("Invalid enum value (" + stringValue + "!"); | ||
} | ||
} | ||
}; | ||
|
||
} // namespace margelo::nitro::send |
85 changes: 85 additions & 0 deletions
85
packages/npm/send/nitrogen/generated/android/c++/JHybridSendSpec.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,85 @@ | ||
/// | ||
/// JHybridSendSpec.cpp | ||
/// Fri Aug 30 2024 | ||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. | ||
/// https://github.com/mrousavy/nitro | ||
/// Copyright © 2024 Marc Rousavy @ Margelo | ||
/// | ||
|
||
#include "JHybridSendSpec.hpp" | ||
|
||
// Forward declaration of `SendResult` to properly resolve imports. | ||
namespace margelo::nitro::send { struct SendResult; } | ||
// Forward declaration of `Response` to properly resolve imports. | ||
namespace margelo::nitro::send { struct Response; } | ||
// Forward declaration of `Parameters` to properly resolve imports. | ||
namespace margelo::nitro::send { struct Parameters; } | ||
// Forward declaration of `SendError` to properly resolve imports. | ||
namespace margelo::nitro::send { struct SendError; } | ||
// Forward declaration of `Code` to properly resolve imports. | ||
namespace margelo::nitro::send { enum class Code; } | ||
// Forward declaration of `Request` to properly resolve imports. | ||
namespace margelo::nitro::send { struct Request; } | ||
// Forward declaration of `Method` to properly resolve imports. | ||
namespace margelo::nitro::send { enum class Method; } | ||
|
||
#include <future> | ||
#include "SendResult.hpp" | ||
#include <NitroModules/JPromise.hpp> | ||
#include "JSendResult.hpp" | ||
#include <optional> | ||
#include "Response.hpp" | ||
#include "JResponse.hpp" | ||
#include "Parameters.hpp" | ||
#include "JParameters.hpp" | ||
#include <unordered_map> | ||
#include <string> | ||
#include "SendError.hpp" | ||
#include "JSendError.hpp" | ||
#include "Code.hpp" | ||
#include "JCode.hpp" | ||
#include "Request.hpp" | ||
#include "JRequest.hpp" | ||
#include "Method.hpp" | ||
#include "JMethod.hpp" | ||
#include <vector> | ||
|
||
namespace margelo::nitro::send { | ||
|
||
jni::local_ref<JHybridSendSpec::jhybriddata> JHybridSendSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) { | ||
return makeCxxInstance(jThis); | ||
} | ||
|
||
void JHybridSendSpec::registerNatives() { | ||
registerHybrid({ | ||
makeNativeMethod("initHybrid", JHybridSendSpec::initHybrid), | ||
}); | ||
} | ||
|
||
size_t JHybridSendSpec::getExternalMemorySize() noexcept { | ||
static const auto method = _javaPart->getClass()->getMethod<jlong()>("getMemorySize"); | ||
return method(_javaPart); | ||
} | ||
|
||
// Properties | ||
|
||
|
||
// Methods | ||
std::future<SendResult> JHybridSendSpec::send(const Request& request) { | ||
static const auto method = _javaPart->getClass()->getMethod<jni::alias_ref<JPromise::javaobject>(jni::alias_ref<JRequest> /* request */)>("send"); | ||
auto result = method(_javaPart, JRequest::fromCpp(request)); | ||
return [&]() { | ||
auto promise = std::make_shared<std::promise<SendResult>>(); | ||
result->cthis()->addOnResolvedListener([=](const jni::global_ref<jni::JObject>& boxedResult) { | ||
auto result = jni::static_ref_cast<JSendResult>(boxedResult); | ||
promise->set_value(result->toCpp()); | ||
}); | ||
result->cthis()->addOnRejectedListener([=](const jni::global_ref<jni::JString>& message) { | ||
std::runtime_error error(message->toStdString()); | ||
promise->set_exception(std::make_exception_ptr(error)); | ||
}); | ||
return promise->get_future(); | ||
}(); | ||
} | ||
|
||
} // namespace margelo::nitro::send |
Oops, something went wrong.