-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of multiple RAM bundles registry
Differential Revision: D5850963 fbshipit-source-id: e1bd6d74953872d38e73a20f6d054905a7e4c80c
- Loading branch information
1 parent
da2ea26
commit 2f952fb
Showing
6 changed files
with
75 additions
and
9 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
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,23 @@ | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
#include "RAMBundleRegistry.h" | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
constexpr uint32_t RAMBundleRegistry::MAIN_BUNDLE_ID; | ||
|
||
RAMBundleRegistry::RAMBundleRegistry(std::unique_ptr<JSModulesUnbundle> mainBundle) { | ||
m_bundles.emplace(MAIN_BUNDLE_ID, std::move(mainBundle)); | ||
} | ||
|
||
JSModulesUnbundle::Module RAMBundleRegistry::getModule(uint32_t bundleId, uint32_t moduleId) { | ||
return getBundle(bundleId)->getModule(moduleId); | ||
} | ||
|
||
JSModulesUnbundle *RAMBundleRegistry::getBundle(uint32_t bundleId) const { | ||
return m_bundles.at(bundleId).get(); | ||
} | ||
|
||
} // namespace react | ||
} // namespace facebook |
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,28 @@ | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <memory> | ||
#include <unordered_map> | ||
#include <utility> | ||
|
||
#include <cxxreact/JSModulesUnbundle.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
class RAMBundleRegistry { | ||
public: | ||
constexpr static uint32_t MAIN_BUNDLE_ID = 0; | ||
|
||
explicit RAMBundleRegistry(std::unique_ptr<JSModulesUnbundle> mainBundle); | ||
JSModulesUnbundle::Module getModule(uint32_t bundleId, uint32_t moduleId); | ||
private: | ||
JSModulesUnbundle *getBundle(uint32_t bundleId) const; | ||
|
||
std::unordered_map<uint32_t, std::unique_ptr<JSModulesUnbundle>> m_bundles; | ||
}; | ||
|
||
} // namespace react | ||
} // namespace facebook |