Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update v8 to 5.2.361 #530

Closed
wants to merge 5 commits into from
Closed
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
2 changes: 1 addition & 1 deletion runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ model {

ldLibs.addAll(["android", "dl", "log", "atomic", "z"])

stl = "stlport_static"
stl = "c++_static"

abiFilters.addAll(["armeabi-v7a", "x86", "arm64-v8a"])
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/main/jni/ArgConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ void ArgConverter::NativeScriptLongFunctionCallback(const v8::FunctionCallbackIn
auto isolate = args.GetIsolate();
auto thiz = args.This();
auto cache = GetCache(isolate);
thiz->SetHiddenValue(V8StringConstants::GetJavaLong(), Boolean::New(isolate, true));
NumericCasts::MarkAsLong(thiz, args[0]);
thiz->SetPrivate(isolate->GetCurrentContext(), Private::New(isolate, V8StringConstants::GetJavaLong()), Boolean::New(isolate, true));
NumericCasts::MarkAsLong(isolate, thiz, args[0]);
thiz->SetPrototype(Local<NumberObject>::New(isolate, *cache->NanNumberObject));
}
catch (NativeScriptException& e)
Expand Down
20 changes: 14 additions & 6 deletions runtime/src/main/jni/JsArgConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,15 @@ bool JsArgConverter::ConvertArg(const Local<Value>& arg, int index)
jlong javaLongValue;
auto jsObject = arg->ToObject();

auto castType = NumericCasts::GetCastType(jsObject);
auto castType = NumericCasts::GetCastType(m_isolate, jsObject);

Local<Value> castValue;
JniLocalRef obj;

auto runtime = Runtime::GetRuntime(m_isolate);
auto objectManager = runtime->GetObjectManager();
MaybeLocal<Value> maybeCastValue;
Local<Value> valFromMaybe;

switch (castType)
{
Expand Down Expand Up @@ -267,11 +269,17 @@ bool JsArgConverter::ConvertArg(const Local<Value>& arg, int index)
case CastType::None:
obj = objectManager->GetJavaObjectByJsObject(jsObject);

castValue = jsObject->GetHiddenValue(ConvertToV8String(V8StringConstants::NULL_NODE_NAME));
if(!castValue.IsEmpty()) {
SetConvertedObject(index, nullptr);
success = true;
break;
maybeCastValue = jsObject->GetPrivate(m_isolate->GetCurrentContext(), Private::New(m_isolate, ConvertToV8String(V8StringConstants::NULL_NODE_NAME)));

if(!maybeCastValue.IsEmpty()) {
maybeCastValue.FromMaybe(valFromMaybe);

if(!valFromMaybe.IsEmpty())
{
SetConvertedObject(index, nullptr);
success = true;
break;
}
}

success = !obj.IsNull();
Expand Down
1 change: 1 addition & 0 deletions runtime/src/main/jni/JsArgConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "JEnv.h"
#include "v8.h"
#include "MetadataEntry.h"
#include "include/v8.h"

namespace tns
{
Expand Down
62 changes: 35 additions & 27 deletions runtime/src/main/jni/JsArgToArrayConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ bool JsArgToArrayConverter::ConvertArg(const Local<Value>& arg, int index)
{
auto jsObj = arg->ToObject();

auto castType = NumericCasts::GetCastType(jsObj);
auto castType = NumericCasts::GetCastType(m_isolate, jsObj);
Local<Value> castValue;
jchar charValue;
jbyte byteValue;
Expand All @@ -196,6 +196,10 @@ bool JsArgToArrayConverter::ConvertArg(const Local<Value>& arg, int index)
auto runtime = Runtime::GetRuntime(m_isolate);
auto objectManager = runtime->GetObjectManager();

// TODO: Pete:
MaybeLocal<Value> maybeCastValue;
Local<Value> valFromMaybe;

switch (castType)
{
case CastType::Char:
Expand Down Expand Up @@ -294,38 +298,42 @@ bool JsArgToArrayConverter::ConvertArg(const Local<Value>& arg, int index)

case CastType::None:
obj = objectManager->GetJavaObjectByJsObject(jsObj);

castValue = jsObj->GetHiddenValue(V8StringConstants::GetNullNodeName());

if(!castValue.IsEmpty()) {
auto node = reinterpret_cast<MetadataNode*>(castValue.As<External>()->Value());
maybeCastValue = jsObj->GetPrivate(m_isolate->GetCurrentContext(), Private::New(m_isolate, V8StringConstants::GetNullNodeName()));

if(node == nullptr) {
s << "Cannot get type of the null argument at index " << index;
success = false;
break;
}
if(!maybeCastValue.IsEmpty()) {
maybeCastValue.FromMaybe(valFromMaybe);

auto type = node->GetName();
auto nullObjName = "com/tns/NullObject";
auto nullObjCtorSig = "(Ljava/lang/Class;)V";
if(!valFromMaybe.IsEmpty()) {
auto node = reinterpret_cast<MetadataNode*>(valFromMaybe.As<External>()->Value());

jclass nullClazz = env.FindClass(nullObjName);
jmethodID ctor = env.GetMethodID(nullClazz, "<init>", nullObjCtorSig);
jclass clazzToNull = env.FindClass(type.c_str());
jobject nullObjType = env.NewObject(nullClazz, ctor, clazzToNull);
if(node == nullptr) {
s << "Cannot get type of the null argument at index " << index;
success = false;
break;
}

if(nullObjType != nullptr)
{
SetConvertedObject(env, index, nullObjType, false);
}
else
{
SetConvertedObject(env, index, nullptr);
}
auto type = node->GetName();
auto nullObjName = "com/tns/NullObject";
auto nullObjCtorSig = "(Ljava/lang/Class;)V";

success = true;
return success;
jclass nullClazz = env.FindClass(nullObjName);
jmethodID ctor = env.GetMethodID(nullClazz, "<init>", nullObjCtorSig);
jclass clazzToNull = env.FindClass(type.c_str());
jobject nullObjType = env.NewObject(nullClazz, ctor, clazzToNull);

if(nullObjType != nullptr)
{
SetConvertedObject(env, index, nullObjType, false);
}
else
{
SetConvertedObject(env, index, nullptr);
}

success = true;
return success;
}
}

success = !obj.IsNull();
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/main/jni/LRUCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace tns
typedef std::list<key_type> key_tracker_type;

// Key to value and key history iterator
typedef std::tr1::unordered_map< key_type, std::pair<value_type, typename key_tracker_type::iterator> > key_to_value_type;
typedef std::unordered_map< key_type, std::pair<value_type, typename key_tracker_type::iterator> > key_to_value_type;

// Constuctor specifies the cached function and
// the maximum number of records to be stored
Expand Down
Loading