2016-10-11 14:19:31 +00:00
|
|
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
2017-02-15 17:49:07 +00:00
|
|
|
#include <folly/Optional.h>
|
2016-11-01 18:38:43 +00:00
|
|
|
#include <jschelpers/Value.h>
|
|
|
|
|
2016-10-11 14:19:31 +00:00
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
2018-05-10 05:01:53 +00:00
|
|
|
class ModuleRegistry;
|
|
|
|
|
2016-10-11 14:19:31 +00:00
|
|
|
/**
|
|
|
|
* Holds and creates JS representations of the modules in ModuleRegistry
|
|
|
|
*/
|
|
|
|
class JSCNativeModules {
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit JSCNativeModules(std::shared_ptr<ModuleRegistry> moduleRegistry);
|
|
|
|
JSValueRef getModule(JSContextRef context, JSStringRef name);
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
private:
|
|
|
|
folly::Optional<Object> m_genNativeModuleJS;
|
|
|
|
std::shared_ptr<ModuleRegistry> m_moduleRegistry;
|
|
|
|
std::unordered_map<std::string, Object> m_objects;
|
|
|
|
|
|
|
|
folly::Optional<Object> createModule(const std::string& name, JSContextRef context);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|