///
/// nitrofetchOnLoad.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#ifndef BUILDING_NITROFETCH_WITH_GENERATED_CMAKE_PROJECT
#error nitrofetchOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
#endif

#include "nitrofetchOnLoad.hpp"

#include <jni.h>
#include <fbjni/fbjni.h>
#include <NitroModules/HybridObjectRegistry.hpp>

#include "JHybridUrlRequestSpec.hpp"
#include "JHybridUrlRequestBuilderSpec.hpp"
#include "JFunc_void_UrlResponseInfo.hpp"
#include "JFunc_void_std__optional_UrlResponseInfo__RequestException.hpp"
#include "JFunc_void_std__optional_UrlResponseInfo_.hpp"
#include "JFunc_void_UrlResponseInfo_std__string.hpp"
#include "JFunc_void_UrlResponseInfo_std__shared_ptr_ArrayBuffer__double.hpp"
#include "JHybridNitroCronetSpec.hpp"
#include "JHybridNitroFetchClientSpec.hpp"
#include "JHybridNitroFetchSpec.hpp"
#include "JHybridNativeStorageSpec.hpp"
#include <NitroModules/DefaultConstructableObject.hpp>

namespace margelo::nitro::nitrofetch {

int initialize(JavaVM* vm) {
  return facebook::jni::initialize(vm, []() {
    ::margelo::nitro::nitrofetch::registerAllNatives();
  });
}

struct JHybridNitroFetchSpecImpl: public jni::JavaClass<JHybridNitroFetchSpecImpl, JHybridNitroFetchSpec::JavaPart> {
  static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrofetch/NitroFetch;";
  static std::shared_ptr<JHybridNitroFetchSpec> create() {
    static const auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroFetchSpecImpl::javaobject()>();
    jni::local_ref<JHybridNitroFetchSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
    return javaPart->getJHybridNitroFetchSpec();
  }
};
struct JHybridNitroFetchClientSpecImpl: public jni::JavaClass<JHybridNitroFetchClientSpecImpl, JHybridNitroFetchClientSpec::JavaPart> {
  static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrofetch/NitroFetchClient;";
  static std::shared_ptr<JHybridNitroFetchClientSpec> create() {
    static const auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroFetchClientSpecImpl::javaobject()>();
    jni::local_ref<JHybridNitroFetchClientSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
    return javaPart->getJHybridNitroFetchClientSpec();
  }
};
struct JHybridNativeStorageSpecImpl: public jni::JavaClass<JHybridNativeStorageSpecImpl, JHybridNativeStorageSpec::JavaPart> {
  static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrofetch/NativeStorage;";
  static std::shared_ptr<JHybridNativeStorageSpec> create() {
    static const auto constructorFn = javaClassStatic()->getConstructor<JHybridNativeStorageSpecImpl::javaobject()>();
    jni::local_ref<JHybridNativeStorageSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
    return javaPart->getJHybridNativeStorageSpec();
  }
};
struct JHybridNitroCronetSpecImpl: public jni::JavaClass<JHybridNitroCronetSpecImpl, JHybridNitroCronetSpec::JavaPart> {
  static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrofetch/NitroCronet;";
  static std::shared_ptr<JHybridNitroCronetSpec> create() {
    static const auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroCronetSpecImpl::javaobject()>();
    jni::local_ref<JHybridNitroCronetSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
    return javaPart->getJHybridNitroCronetSpec();
  }
};

void registerAllNatives() {
  using namespace margelo::nitro;
  using namespace margelo::nitro::nitrofetch;

  // Register native JNI methods
  margelo::nitro::nitrofetch::JHybridUrlRequestSpec::CxxPart::registerNatives();
  margelo::nitro::nitrofetch::JHybridUrlRequestBuilderSpec::CxxPart::registerNatives();
  margelo::nitro::nitrofetch::JFunc_void_UrlResponseInfo_cxx::registerNatives();
  margelo::nitro::nitrofetch::JFunc_void_std__optional_UrlResponseInfo__RequestException_cxx::registerNatives();
  margelo::nitro::nitrofetch::JFunc_void_std__optional_UrlResponseInfo__cxx::registerNatives();
  margelo::nitro::nitrofetch::JFunc_void_UrlResponseInfo_std__string_cxx::registerNatives();
  margelo::nitro::nitrofetch::JFunc_void_UrlResponseInfo_std__shared_ptr_ArrayBuffer__double_cxx::registerNatives();
  margelo::nitro::nitrofetch::JHybridNitroCronetSpec::CxxPart::registerNatives();
  margelo::nitro::nitrofetch::JHybridNitroFetchClientSpec::CxxPart::registerNatives();
  margelo::nitro::nitrofetch::JHybridNitroFetchSpec::CxxPart::registerNatives();
  margelo::nitro::nitrofetch::JHybridNativeStorageSpec::CxxPart::registerNatives();

  // Register Nitro Hybrid Objects
  HybridObjectRegistry::registerHybridObjectConstructor(
    "NitroFetch",
    []() -> std::shared_ptr<HybridObject> {
      return JHybridNitroFetchSpecImpl::create();
    }
  );
  HybridObjectRegistry::registerHybridObjectConstructor(
    "NitroFetchClient",
    []() -> std::shared_ptr<HybridObject> {
      return JHybridNitroFetchClientSpecImpl::create();
    }
  );
  HybridObjectRegistry::registerHybridObjectConstructor(
    "NativeStorage",
    []() -> std::shared_ptr<HybridObject> {
      return JHybridNativeStorageSpecImpl::create();
    }
  );
  HybridObjectRegistry::registerHybridObjectConstructor(
    "NitroCronet",
    []() -> std::shared_ptr<HybridObject> {
      return JHybridNitroCronetSpecImpl::create();
    }
  );
}

} // namespace margelo::nitro::nitrofetch
