Skip to content

Commit

Permalink
Merge remote-tracking branch 'nativescript/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	NativeScript/NativeScript-Prefix.pch
#	NativeScript/runtime/Runtime.h
#	NativeScript/runtime/URLImpl.cpp
#	package.json
#	project-template-ios/internal/Swift-ObjC-Bridging-Header.h
  • Loading branch information
farfromrefug committed Jun 26, 2024
2 parents da99046 + 5088f5f commit 6a3aff4
Show file tree
Hide file tree
Showing 29 changed files with 900 additions and 78 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## [8.7.2](https://github.com/NativeScript/ios/compare/v8.7.1...v8.7.2) (2024-05-16)


### Bug Fixes

* **ios:** watchOS embedded apps ([#250](https://github.com/NativeScript/ios/issues/250)) ([1df9ea2](https://github.com/NativeScript/ios/commit/1df9ea20b6bfde5163b0486e444e5471fb8343b2))



## [8.7.1](https://github.com/NativeScript/ios/compare/v8.7.0...v8.7.1) (2024-04-26)


### Bug Fixes

* url href ([#252](https://github.com/NativeScript/ios/issues/252)) ([4a6e9ad](https://github.com/NativeScript/ios/commit/4a6e9adde6950e09ac0c2fd2713e25aa919ad448))
* Xcode 15.3+ not setting TARGET_OS_IOS correctly ([#248](https://github.com/NativeScript/ios/issues/248)) ([74e1444](https://github.com/NativeScript/ios/commit/74e144432bf17cc043d0e64affc9cb1703e80832))



# [8.7.0](https://github.com/NativeScript/ios/compare/v8.6.3...v8.7.0) (2024-04-08)


Expand Down
3 changes: 1 addition & 2 deletions NativeScript/NativeScript-Prefix.pch
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#ifndef NativeScript_Prefix_pch
#define NativeScript_Prefix_pch


#define NATIVESCRIPT_VERSION "8.7.0-1"
#define NATIVESCRIPT_VERSION "8.7.2"

#ifdef DEBUG
#define SIZEOF_OFF_T 8
Expand Down
8 changes: 4 additions & 4 deletions NativeScript/runtime/ConcurrentQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void ConcurrentQueue::Initialize(CFRunLoopRef runLoop, void (*performWork)(void*
CFRunLoopAddSource(this->runLoop_, this->runLoopTasksSource_, kCFRunLoopCommonModes);
}

void ConcurrentQueue::Push(std::string message) {
void ConcurrentQueue::Push(std::shared_ptr<worker::Message> message) {
if (this->runLoopTasksSource_ != nullptr && !CFRunLoopSourceIsValid(this->runLoopTasksSource_)) {
return;
}
Expand All @@ -27,12 +27,12 @@ void ConcurrentQueue::Push(std::string message) {
this->SignalAndWakeUp();
}

std::vector<std::string> ConcurrentQueue::PopAll() {
std::vector<std::shared_ptr<worker::Message>> ConcurrentQueue::PopAll() {
std::unique_lock<std::mutex> mlock(this->mutex_);
std::vector<std::string> messages;
std::vector<std::shared_ptr<worker::Message>> messages;

while (!this->messagesQueue_.empty()) {
std::string message = this->messagesQueue_.front();
std::shared_ptr<worker::Message> message = this->messagesQueue_.front();
this->messagesQueue_.pop();
messages.push_back(message);
}
Expand Down
7 changes: 4 additions & 3 deletions NativeScript/runtime/ConcurrentQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
#include <string>
#include <queue>
#include <mutex>
#include "Message.hpp"

namespace tns {

struct ConcurrentQueue {
public:
void Initialize(CFRunLoopRef runLoop, void (*performWork)(void*), void* info);
void Push(std::string message);
std::vector<std::string> PopAll();
void Push(std::shared_ptr<worker::Message> message);
std::vector<std::shared_ptr<worker::Message>> PopAll();
void Terminate();
private:
std::queue<std::string> messagesQueue_;
std::queue<std::shared_ptr<worker::Message>> messagesQueue_;
CFRunLoopSourceRef runLoopTasksSource_ = nullptr;
CFRunLoopRef runLoop_ = nullptr;
bool terminated = false;
Expand Down
6 changes: 3 additions & 3 deletions NativeScript/runtime/DataWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,12 +654,12 @@ class ExtVectorWrapper: public BaseDataWrapper {

class WorkerWrapper: public BaseDataWrapper {
public:
WorkerWrapper(v8::Isolate* mainIsolate, std::function<void (v8::Isolate*, v8::Local<v8::Object> thiz, std::string)> onMessage);
WorkerWrapper(v8::Isolate* mainIsolate, std::function<void (v8::Isolate*, v8::Local<v8::Object> thiz, std::shared_ptr<worker::Message>)> onMessage);

void Start(std::shared_ptr<v8::Persistent<v8::Value>> poWorker, std::function<v8::Isolate* ()> func);
void CallOnErrorHandlers(v8::TryCatch& tc);
void PassUncaughtExceptionFromWorkerToMain(v8::Local<v8::Context> context, v8::TryCatch& tc, bool async = true);
void PostMessage(std::string message);
void PostMessage(std::shared_ptr<worker::Message> message);
void Close();
void Terminate();

Expand Down Expand Up @@ -691,7 +691,7 @@ class WorkerWrapper: public BaseDataWrapper {
std::atomic<bool> isTerminating_;
bool isDisposed_;
bool isWeak_;
std::function<void (v8::Isolate*, v8::Local<v8::Object> thiz, std::string)> onMessage_;
std::function<void (v8::Isolate*, v8::Local<v8::Object> thiz, std::shared_ptr<worker::Message>)> onMessage_;
std::shared_ptr<v8::Persistent<v8::Value>> poWorker_;
ConcurrentQueue queue_;
static std::atomic<int> nextId_;
Expand Down
51 changes: 51 additions & 0 deletions NativeScript/runtime/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,57 @@ void SetConstructorFunction(v8::Isolate* isolate,
SetConstructorFunctionFlag::SET_CLASS_NAME);


template <int N>
inline v8::Local<v8::String> FIXED_ONE_BYTE_STRING(
v8::Isolate* isolate,
const char(&data)[N]) {
return OneByteString(isolate, data, N - 1);
}

template <std::size_t N>
inline v8::Local<v8::String> FIXED_ONE_BYTE_STRING(
v8::Isolate* isolate,
const std::array<char, N>& arr) {
return OneByteString(isolate, arr.data(), N - 1);
}

class PersistentToLocal {
public:
// If persistent.IsWeak() == false, then do not call persistent.Reset()
// while the returned Local<T> is still in scope, it will destroy the
// reference to the object.
template <class TypeName>
static inline v8::Local<TypeName> Default(
v8::Isolate* isolate,
const v8::PersistentBase<TypeName>& persistent) {
if (persistent.IsWeak()) {
return PersistentToLocal::Weak(isolate, persistent);
} else {
return PersistentToLocal::Strong(persistent);
}
}

// Unchecked conversion from a non-weak Persistent<T> to Local<T>,
// use with care!
//
// Do not call persistent.Reset() while the returned Local<T> is still in
// scope, it will destroy the reference to the object.
template <class TypeName>
static inline v8::Local<TypeName> Strong(
const v8::PersistentBase<TypeName>& persistent) {
// DCHECK(!persistent.IsWeak());
return *reinterpret_cast<v8::Local<TypeName>*>(
const_cast<v8::PersistentBase<TypeName>*>(&persistent));
}

template <class TypeName>
static inline v8::Local<TypeName> Weak(
v8::Isolate* isolate,
const v8::PersistentBase<TypeName>& persistent) {
return v8::Local<TypeName>::New(isolate, persistent);
}
};

}

#endif /* Helpers_h */
Loading

0 comments on commit 6a3aff4

Please sign in to comment.