aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/helpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/bindings/helpers.h')
-rw-r--r--src/bun.js/bindings/helpers.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/bun.js/bindings/helpers.h b/src/bun.js/bindings/helpers.h
index da97b4797..c52c17997 100644
--- a/src/bun.js/bindings/helpers.h
+++ b/src/bun.js/bindings/helpers.h
@@ -78,7 +78,7 @@ namespace Zig {
static const unsigned char* untag(const unsigned char* ptr)
{
return reinterpret_cast<const unsigned char*>(
- ((reinterpret_cast<uintptr_t>(ptr) & ~(static_cast<uint64_t>(1) << 63) & ~(static_cast<uint64_t>(1) << 62)) & ~(static_cast<uint64_t>(1) << 61)));
+ (((reinterpret_cast<uintptr_t>(ptr) & ~(static_cast<uint64_t>(1) << 63) & ~(static_cast<uint64_t>(1) << 62)) & ~(static_cast<uint64_t>(1) << 61)) & ~(static_cast<uint64_t>(1) << 60)));
}
static void* untagVoid(const unsigned char* ptr)
@@ -148,6 +148,26 @@ static const WTF::String toString(ZigString str)
reinterpret_cast<const UChar*>(untag(str.ptr)), str.len));
}
+static const WTF::String toStringStatic(ZigString str)
+{
+ if (str.len == 0 || str.ptr == nullptr) {
+ return WTF::String();
+ }
+ if (UNLIKELY(isTaggedUTF8Ptr(str.ptr))) {
+ abort();
+ }
+
+ if (isTaggedUTF16Ptr(str.ptr)) {
+ return WTF::String(WTF::ExternalStringImpl::createStatic(untag(str.ptr), str.len));
+ }
+
+
+ return WTF::String(WTF::ExternalStringImpl::createStatic(
+ reinterpret_cast<const UChar*>(untag(str.ptr)), str.len));
+
+
+}
+
static WTF::AtomString toAtomString(ZigString str)
{