Skip to content

Commit 20cb3ff

Browse files
committed
fix: Xcode 26.4 build
1 parent 217873b commit 20cb3ff

10 files changed

Lines changed: 45 additions & 30 deletions

File tree

NativeScript/inspector/JsV8InspectorClient.mm

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222

2323
namespace v8_inspector {
2424

25+
namespace {
26+
StringView Make8BitStringView(const std::string& value) {
27+
return StringView(reinterpret_cast<const uint8_t*>(value.data()),
28+
value.size());
29+
}
30+
} // namespace
31+
2532
#define NOTIFICATION(name) \
2633
[[NSString stringWithFormat:@"%@:NativeScript.Debug.%s", \
2734
[[NSBundle mainBundle] bundleIdentifier], name] UTF8String]
@@ -257,8 +264,7 @@
257264
}
258265

259266
void JsV8InspectorClient::dispatchMessage(const std::string& message) {
260-
std::vector<uint16_t> vector = tns::ToVector(message);
261-
StringView messageView(vector.data(), vector.size());
267+
StringView messageView = Make8BitStringView(message);
262268
Isolate* isolate = isolate_;
263269
v8::Locker locker(isolate);
264270
Isolate::Scope isolate_scope(isolate);
@@ -343,8 +349,7 @@
343349
auto returnString = GetReturnMessageFromDomainHandlerResult(result, requestId);
344350

345351
if (returnString.size() > 0) {
346-
std::vector<uint16_t> vector = tns::ToVector(returnString);
347-
StringView messageView(vector.data(), vector.size());
352+
StringView messageView = Make8BitStringView(returnString);
348353
auto msg = StringBuffer::create(messageView);
349354
this->sendNotification(std::move(msg));
350355
}
@@ -486,8 +491,7 @@
486491
Local<v8::String> arg = args[0].As<v8::String>();
487492
std::string message = tns::ToString(isolate, arg);
488493

489-
std::vector<uint16_t> vector = tns::ToVector(message);
490-
StringView messageView(vector.data(), vector.size());
494+
StringView messageView = Make8BitStringView(message);
491495
auto msg = StringBuffer::create(messageView);
492496
client->sendNotification(std::move(msg));
493497
}

NativeScript/inspector/src/inspector/string-16.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
namespace v8_inspector {
1919

20-
using UChar = uint16_t;
20+
using UChar = char16_t;
2121

2222
class String16 {
2323
public:

NativeScript/inspector/src/inspector/string-util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class StringUtil {
3030
}
3131

3232
static String fromUTF16LE(const uint16_t* data, size_t length) {
33-
return String16::fromUTF16LE(data, length);
33+
return String16::fromUTF16LE(reinterpret_cast<const UChar*>(data), length);
3434
}
3535

3636
static const uint8_t* CharactersLatin1(const String& s) { return nullptr; }
3737
static const uint8_t* CharactersUTF8(const String& s) { return nullptr; }
3838
static const uint16_t* CharactersUTF16(const String& s) {
39-
return s.characters16();
39+
return reinterpret_cast<const uint16_t*>(s.characters16());
4040
}
4141
static size_t CharacterCount(const String& s) { return s.length(); }
4242
};

NativeScript/inspector/utils.mm

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,16 @@
3535
}
3636

3737
std::string v8_inspector::ToStdString(const StringView& value) {
38-
std::vector<uint16_t> buffer(value.length());
38+
std::u16string value16;
39+
value16.resize(value.length());
3940
for (size_t i = 0; i < value.length(); i++) {
4041
if (value.is8Bit()) {
41-
buffer[i] = value.characters8()[i];
42+
value16[i] = static_cast<char16_t>(value.characters8()[i]);
4243
} else {
43-
buffer[i] = value.characters16()[i];
44+
value16[i] = static_cast<char16_t>(value.characters16()[i]);
4445
}
4546
}
4647

47-
std::u16string value16(buffer.begin(), buffer.end());
48-
4948
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
5049
// FIXME: std::codecvt_utf8_utf16 is deprecated
5150
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;

NativeScript/v8runtime/V8Runtime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ std::shared_ptr<const jsi::PreparedJavaScript> V8Runtime::prepareJavaScript(
431431

432432
jsi::Value V8Runtime::evaluatePreparedJavaScript(
433433
const std::shared_ptr<const jsi::PreparedJavaScript>& js) {
434-
return evaluateJavaScript(nullptr, nullptr);
434+
return evaluateJavaScript(nullptr, "");
435435
}
436436

437437
void V8Runtime::queueMicrotask(const jsi::Function& callback) {
@@ -1586,4 +1586,4 @@ void V8Runtime::OnHostFuncionContainerCallback(
15861586
}
15871587
}
15881588

1589-
} // namespace rnv8
1589+
} // namespace rnv8

download_llvm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33
source "$(dirname "$0")/build_utils.sh"
44

5-
LLVM_VERSION="17.0.6"
5+
LLVM_VERSION="17.0.7"
66

77
function download_llvm() {
88
checkpoint "Downloading llvm (version $LLVM_VERSION)..."

metadata-generator/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cmake_minimum_required(VERSION 3.20)
22
project(MetadataGenerator)
33
include(CheckCCompilerFlag)
4+
include(CheckCXXCompilerFlag)
45

56
#set(CMAKE_VERBOSE_MAKEFILE ON)
67

@@ -13,7 +14,7 @@ if (NOT LIBXML2_FOUND)
1314
message(FATAL_ERROR "libXML2 not found")
1415
endif ()
1516

16-
get_filename_component(LLVM_ROOT "../../llvm/17.0.6" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
17+
get_filename_component(LLVM_ROOT "../../llvm/17.0.7" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
1718
set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0)
1819

1920
set(LLVM_SYSTEM_LIBS "-lz -lcurses -lm -lxml2")
@@ -36,6 +37,18 @@ if (HAS_UNUSED_BUT_SET_VARIABLE)
3637
add_compile_options(-Wno-unused-but-set-variable)
3738
endif()
3839

40+
# LLVM 17.0.7 triggers this diagnostic in Clang's own headers on newer Apple toolchains.
41+
# Keep warnings-as-errors for project code, but don't fail the build on this upstream warning.
42+
check_cxx_compiler_flag(-Wno-error=preferred-type-bitfield-enum-conversion HAS_NO_ERROR_PREFERRED_TYPE_BITFIELD_ENUM_CONVERSION)
43+
if (HAS_NO_ERROR_PREFERRED_TYPE_BITFIELD_ENUM_CONVERSION)
44+
add_compile_options(-Wno-error=preferred-type-bitfield-enum-conversion)
45+
endif()
46+
47+
check_cxx_compiler_flag(-Wno-error=unnecessary-virtual-specifier HAS_NO_ERROR_UNNECESSARY_VIRTUAL_SPECIFIER)
48+
if (HAS_NO_ERROR_UNNECESSARY_VIRTUAL_SPECIFIER)
49+
add_compile_options(-Wno-error=unnecessary-virtual-specifier)
50+
endif()
51+
3952
set(LLVM_LINKER_FLAGS "${LLVM_LINKER_FLAGS} ${LLVM_SYSTEM_LIBS} ${LLVM_LIBS}")
4053

4154
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/lib)

metadata-generator/src/Binary/binarySerializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ static llvm::ErrorOr<bool> isStaticFramework(clang::Module* framework)
254254

255255
if (path.getError()) {
256256
return path.getError();
257-
} else if (path.get().endswith(".tbd")) {
257+
} else if (path.get().ends_with(".tbd")) {
258258
return true;
259259
}
260260

metadata-generator/src/HeadersParser/Parser.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <clang/Tooling/Tooling.h>
77
#include <iostream>
88
#include <sstream>
9+
#include <variant>
910
#include <llvm/ADT/StringSwitch.h>
1011
#include <llvm/Support/Path.h>
1112

@@ -31,9 +32,9 @@ static std::error_code addHeaderInclude(StringRef headerName, std::vector<SmallS
3132
return std::error_code();
3233
}
3334

34-
static std::error_code addHeaderInclude(const FileEntry* header, std::vector<SmallString<256>>& includes)
35+
static std::error_code addHeaderInclude(FileEntryRef header, std::vector<SmallString<256>>& includes)
3536
{
36-
return addHeaderInclude(header->getName(), includes);
37+
return addHeaderInclude(header.getName(), includes);
3738
}
3839

3940
static std::error_code collectModuleHeaderIncludes(FileManager& fileMgr, ModuleMap& modMap, const Module* module, std::vector<SmallString<256>>& includes)
@@ -42,17 +43,15 @@ static std::error_code collectModuleHeaderIncludes(FileManager& fileMgr, ModuleM
4243
if (!module->isAvailable())
4344
return std::error_code();
4445

45-
if (module->Umbrella && module->Umbrella.is<FileEntryRef>()) {
46-
const FileEntry* umbrellaHeader = module->Umbrella.get<FileEntryRef>();
47-
if (std::error_code err = addHeaderInclude(umbrellaHeader, includes))
46+
if (const auto* umbrellaHeader = std::get_if<FileEntryRef>(&module->Umbrella)) {
47+
if (std::error_code err = addHeaderInclude(*umbrellaHeader, includes))
4848
return err;
4949
}
50-
else if (module->Umbrella && module->Umbrella.is<DirectoryEntryRef>()) {
51-
const DirectoryEntryRef umbrellaDir = module->Umbrella.get<DirectoryEntryRef>();
50+
else if (const auto* umbrellaDir = std::get_if<DirectoryEntryRef>(&module->Umbrella)) {
5251
// Add all of the headers we find in this subdirectory.
5352
std::error_code ec;
5453
SmallString<128> dirNative;
55-
path::native(umbrellaDir.getName(), dirNative);
54+
path::native(umbrellaDir->getName(), dirNative);
5655
for (fs::recursive_directory_iterator dir(dirNative.str(), ec), dirEnd; dir != dirEnd && !ec; dir.increment(ec)) {
5756
// Check whether this entry has an extension typically associated with headers.
5857
if (!llvm::StringSwitch<bool>(path::extension(dir->path()))
@@ -77,8 +76,8 @@ static std::error_code collectModuleHeaderIncludes(FileManager& fileMgr, ModuleM
7776
if (ec)
7877
return ec;
7978
} else {
80-
for (auto header : module->Headers[Module::HK_Normal]) {
81-
if (auto err = addHeaderInclude(header.Entry, includes))
79+
for (FileEntryRef header : const_cast<Module*>(module)->getTopHeaders(fileMgr)) {
80+
if (auto err = addHeaderInclude(header, includes))
8281
return err;
8382
}
8483
}

metadata-generator/src/TypeScript/DefinitionWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ std::string DefinitionWriter::writeMethod(MethodMeta* meta, BaseClassMeta* owner
583583
}
584584
}
585585

586-
if ((owner->type == MetaType::Protocol && methodDecl.getImplementationControl() == clang::ObjCMethodDecl::ImplementationControl::Optional) || (owner->is(MetaType::Protocol) && meta->getFlags(MethodIsInitializer))) {
586+
if ((owner->type == MetaType::Protocol && methodDecl.getImplementationControl() == clang::ObjCImplementationControl::Optional) || (owner->is(MetaType::Protocol) && meta->getFlags(MethodIsInitializer))) {
587587
output << "?";
588588
}
589589

0 commit comments

Comments
 (0)