Rename JSBigMmapString -> JSBigOptimizedBundleString

Summary:
`JSBigMmapString` needs to know too much about the details of the "optimized bundle" format. In honour of this fact, I'm renaming it to `JSBigOptimizedBundleString`. In a following diff, I will introduce a new class just for File-backed Strings, whose only responsibility is dealing with an mmaped region.

This diff already pulls in some fixes for formatting reference and pointer declarations from the linter.

Reviewed By: michalgr

Differential Revision: D4189391

fbshipit-source-id: b376c2a8d9ae5b83575da8457e607bbbfc648ebd
This commit is contained in:
Ashok Menon
2016-11-16 15:08:41 -08:00
committed by Facebook Github Bot
parent 89d81b34db
commit 79fa6d41a1
3 changed files with 14 additions and 16 deletions

View File

@@ -18,26 +18,26 @@ void JSExecutor::loadApplicationScript(std::string bundlePath, std::string sourc
throw std::runtime_error("No unpacked js source file");
}
return loadApplicationScript(
JSBigMmapString::fromOptimizedBundle(bundlePath),
JSBigOptimizedBundleString::fromOptimizedBundle(bundlePath),
std::move(sourceURL));
}
static JSBigMmapString::Encoding encodingFromByte(uint8_t byte) {
static JSBigOptimizedBundleString::Encoding encodingFromByte(uint8_t byte) {
switch (byte) {
case 0:
return JSBigMmapString::Encoding::Unknown;
return JSBigOptimizedBundleString::Encoding::Unknown;
case 1:
return JSBigMmapString::Encoding::Ascii;
return JSBigOptimizedBundleString::Encoding::Ascii;
case 2:
return JSBigMmapString::Encoding::Utf8;
return JSBigOptimizedBundleString::Encoding::Utf8;
case 3:
return JSBigMmapString::Encoding::Utf16;
return JSBigOptimizedBundleString::Encoding::Utf16;
default:
throw std::invalid_argument("Unknown bundle encoding");
}
}
std::unique_ptr<const JSBigMmapString> JSBigMmapString::fromOptimizedBundle(
std::unique_ptr<const JSBigOptimizedBundleString> JSBigOptimizedBundleString::fromOptimizedBundle(
const std::string& bundlePath) {
uint8_t sha1[20];
uint8_t encoding;
@@ -62,7 +62,7 @@ std::unique_ptr<const JSBigMmapString> JSBigMmapString::fromOptimizedBundle(
folly::checkUnixError(::fstat(fd, &fileInfo), "fstat on js bundle failed.");
return folly::make_unique<const JSBigMmapString>(
return folly::make_unique<const JSBigOptimizedBundleString>(
fd,
fileInfo.st_size,
sha1,