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

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

#include "SensitiveInfoOnLoad.hpp"

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

#include "JHybridSensitiveInfoSpec.hpp"
#include <NitroModules/DefaultConstructableObject.hpp>

namespace margelo::nitro::sensitiveinfo {

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

struct JHybridSensitiveInfoSpecImpl: public jni::JavaClass<JHybridSensitiveInfoSpecImpl, JHybridSensitiveInfoSpec::JavaPart> {
  static constexpr auto kJavaDescriptor = "Lcom/sensitiveinfo/HybridSensitiveInfo;";
  static std::shared_ptr<JHybridSensitiveInfoSpec> create() {
    static const auto constructorFn = javaClassStatic()->getConstructor<JHybridSensitiveInfoSpecImpl::javaobject()>();
    jni::local_ref<JHybridSensitiveInfoSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
    return javaPart->getJHybridSensitiveInfoSpec();
  }
};

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

  // Register native JNI methods
  margelo::nitro::sensitiveinfo::JHybridSensitiveInfoSpec::CxxPart::registerNatives();

  // Register Nitro Hybrid Objects
  HybridObjectRegistry::registerHybridObjectConstructor(
    "SensitiveInfo",
    []() -> std::shared_ptr<HybridObject> {
      return JHybridSensitiveInfoSpecImpl::create();
    }
  );
}

} // namespace margelo::nitro::sensitiveinfo
