Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions NativeScript/inspector/JsV8InspectorClient.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@

namespace v8_inspector {

namespace {
// Build an 8-bit `StringView` directly over a `std::string`'s storage.
// V8 inspector messages on this side are ASCII/UTF-8 JSON, so the
// previous `std::string -> std::vector<uint16_t> -> StringView` path
// inflated each byte to two and then handed it to a 16-bit constructor.
// Going straight through the 8-bit constructor avoids that doubling AND
// dodges the libc++ deprecation that prompted the inspector's
// `UChar = uint16_t -> char16_t` switch.
StringView Make8BitStringView(const std::string& value) {
return StringView(reinterpret_cast<const uint8_t*>(value.data()),
value.size());
}
} // namespace

#define NOTIFICATION(name) \
[[NSString stringWithFormat:@"%@:NativeScript.Debug.%s", \
[[NSBundle mainBundle] bundleIdentifier], name] UTF8String]
Expand Down Expand Up @@ -257,8 +271,7 @@
}

void JsV8InspectorClient::dispatchMessage(const std::string& message) {
std::vector<uint16_t> vector = tns::ToVector(message);
StringView messageView(vector.data(), vector.size());
StringView messageView = Make8BitStringView(message);
Isolate* isolate = isolate_;
v8::Locker locker(isolate);
Isolate::Scope isolate_scope(isolate);
Expand Down Expand Up @@ -343,8 +356,7 @@
auto returnString = GetReturnMessageFromDomainHandlerResult(result, requestId);

if (returnString.size() > 0) {
std::vector<uint16_t> vector = tns::ToVector(returnString);
StringView messageView(vector.data(), vector.size());
StringView messageView = Make8BitStringView(returnString);
auto msg = StringBuffer::create(messageView);
this->sendNotification(std::move(msg));
}
Expand Down Expand Up @@ -486,8 +498,7 @@
Local<v8::String> arg = args[0].As<v8::String>();
std::string message = tns::ToString(isolate, arg);

std::vector<uint16_t> vector = tns::ToVector(message);
StringView messageView(vector.data(), vector.size());
StringView messageView = Make8BitStringView(message);
auto msg = StringBuffer::create(messageView);
client->sendNotification(std::move(msg));
}
Expand Down
8 changes: 7 additions & 1 deletion NativeScript/inspector/src/inspector/string-16.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@

namespace v8_inspector {

using UChar = uint16_t;
// Xcode 26.x libc++ deprecates `std::basic_string<unsigned short>`
// (and any `char_traits<T>` specialization for non-standard char types).
// Switch to `char16_t` so `std::basic_string<UChar>` resolves to the
// fully supported `std::u16string`. The V8 inspector public API still
// takes `uint16_t*`, so call sites that cross that boundary now use
// `reinterpret_cast` (see string-util.h).
using UChar = char16_t;

class String16 {
public:
Expand Down
8 changes: 6 additions & 2 deletions NativeScript/inspector/src/inspector/string-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ class StringUtil {
}

static String fromUTF16LE(const uint16_t* data, size_t length) {
return String16::fromUTF16LE(data, length);
// V8 inspector protocol passes `uint16_t*` over its public API but
// `String16` is now backed by `std::u16string` (UChar = char16_t).
// The two are bit-identical 16-bit codepoints, so a reinterpret_cast
// is sound at the API boundary.
return String16::fromUTF16LE(reinterpret_cast<const UChar*>(data), length);
}

static const uint8_t* CharactersLatin1(const String& s) { return nullptr; }
static const uint8_t* CharactersUTF8(const String& s) { return nullptr; }
static const uint16_t* CharactersUTF16(const String& s) {
return s.characters16();
return reinterpret_cast<const uint16_t*>(s.characters16());
}
static size_t CharacterCount(const String& s) { return s.length(); }
};
Expand Down
15 changes: 10 additions & 5 deletions NativeScript/inspector/utils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,22 @@
}

std::string v8_inspector::ToStdString(const StringView& value) {
std::vector<uint16_t> buffer(value.length());
// Build the std::u16string directly. The previous version went via
// std::vector<uint16_t> + a copy-construct into u16string, which on
// Xcode 26.x's libc++ tripped the `char_traits<unsigned short>`
// deprecation through the construct-from-iterator path. Writing
// char16_t straight into the destination avoids the
// non-standard char-traits specialization entirely.
std::u16string value16;
value16.resize(value.length());
for (size_t i = 0; i < value.length(); i++) {
if (value.is8Bit()) {
buffer[i] = value.characters8()[i];
value16[i] = static_cast<char16_t>(value.characters8()[i]);
} else {
buffer[i] = value.characters16()[i];
value16[i] = static_cast<char16_t>(value.characters16()[i]);
}
}

std::u16string value16(buffer.begin(), buffer.end());

#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
// FIXME: std::codecvt_utf8_utf16 is deprecated
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
Expand Down
7 changes: 6 additions & 1 deletion NativeScript/v8runtime/V8Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,12 @@ std::shared_ptr<const jsi::PreparedJavaScript> V8Runtime::prepareJavaScript(

jsi::Value V8Runtime::evaluatePreparedJavaScript(
const std::shared_ptr<const jsi::PreparedJavaScript>& js) {
return evaluateJavaScript(nullptr, nullptr);
// The second arg is a `std::string` sourceURL; newer Clang (Xcode 26.x)
// enforces `-Wnonnull` on its non-null `const char*` constructor, so we
// can no longer pass `nullptr`. Empty string is the documented "unknown
// source URL" value and matches the existing `prepareJavaScript` no-op
// (which already returns nullptr above).
return evaluateJavaScript(nullptr, "");
}

void V8Runtime::queueMicrotask(const jsi::Function& callback) {
Expand Down
18 changes: 18 additions & 0 deletions metadata-generator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.20)
project(MetadataGenerator)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)

#set(CMAKE_VERBOSE_MAKEFILE ON)

Expand Down Expand Up @@ -36,6 +37,23 @@ if (HAS_UNUSED_BUT_SET_VARIABLE)
add_compile_options(-Wno-unused-but-set-variable)
endif()

# Newer Apple toolchains (Xcode 26.x with Clang 17+) emit two diagnostics
# inside LLVM 17.0.6's own headers (e.g. `-Wunnecessary-virtual-specifier`
# on `virtual void anchor()` in classes declared `final` in
# `clang/AST/Decl.h`, and `-Wpreferred-type-bitfield-enum-conversion` on
# bitfield-to-enum stores). These are upstream-known issues that don't
# affect generator behavior. Keep `-Werror` for *our* code, but downgrade
# these two to warnings so the build succeeds without bumping LLVM.
check_cxx_compiler_flag(-Wno-error=preferred-type-bitfield-enum-conversion HAS_NO_ERROR_PREFERRED_TYPE_BITFIELD_ENUM_CONVERSION)
if (HAS_NO_ERROR_PREFERRED_TYPE_BITFIELD_ENUM_CONVERSION)
add_compile_options(-Wno-error=preferred-type-bitfield-enum-conversion)
endif()

check_cxx_compiler_flag(-Wno-error=unnecessary-virtual-specifier HAS_NO_ERROR_UNNECESSARY_VIRTUAL_SPECIFIER)
if (HAS_NO_ERROR_UNNECESSARY_VIRTUAL_SPECIFIER)
add_compile_options(-Wno-error=unnecessary-virtual-specifier)
endif()

set(LLVM_LINKER_FLAGS "${LLVM_LINKER_FLAGS} ${LLVM_SYSTEM_LIBS} ${LLVM_LIBS}")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/lib)
Expand Down
Loading