Skip to content

Commit

Permalink
fix: fix windows build error.
Browse files Browse the repository at this point in the history
  • Loading branch information
andycall committed Nov 18, 2024
1 parent 6131f5e commit 8cbf7a1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions bridge/bindings/qjs/value_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifndef WEBF_BINDINGS_QJS_VALUE_CACHE_H_
#define WEBF_BINDINGS_QJS_VALUE_CACHE_H_

#include <unordered_map>
#include <quickjs/quickjs.h>
#include "foundation/macros.h"
#include "string_impl.h"
Expand Down
1 change: 1 addition & 0 deletions bridge/core/platform/text/text_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@


#include <string>
#include <vector>
#include "foundation/macros.h"

namespace webf {
Expand Down
9 changes: 7 additions & 2 deletions bridge/foundation/atomic_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include "atomic_string_table.h"
#include "core/executing_context.h"

#if defined(_WIN32)
#include <WinSock2.h>
#endif

namespace webf {

namespace {
Expand Down Expand Up @@ -127,10 +131,10 @@ std::unique_ptr<SharedNativeString> AtomicString::ToNativeString() const {
}

if (string_->Is8Bit()) {
uint8_t* buffer;
const uint8_t* p = reinterpret_cast<const uint8_t*>(string_->Characters8());

#if defined(_WIN32)
uint16_t* buffer;
int utf16_str_len = MultiByteToWideChar(CP_ACP, 0, reinterpret_cast<const char*>(p), -1, NULL, 0) - 1;
if (utf16_str_len == -1) {
return nullptr;
Expand All @@ -143,7 +147,8 @@ std::unique_ptr<SharedNativeString> AtomicString::ToNativeString() const {

// Convert the ASCII string to UTF-16
MultiByteToWideChar(CP_ACP, 0, reinterpret_cast<const char*>(p), -1, (WCHAR*)buffer, utf16_str_len + 1);
*length = utf16_str_len;
return std::make_unique<SharedNativeString>(buffer, utf16_str_len);
// *length = utf16_str_len;
#else
uint32_t len = string_->length();
uint16_t* u16_buffer = (uint16_t*)dart_malloc(sizeof(uint16_t) * len);
Expand Down

0 comments on commit 8cbf7a1

Please sign in to comment.