Skip to content

Commit

Permalink
Merge pull request #536 from NativeScript/plamen5kov/refactored_5.2.361
Browse files Browse the repository at this point in the history
Plamen5kov/refactored 5.2.361
  • Loading branch information
petekanev committed Sep 26, 2016
2 parents 9366650 + f7a4144 commit de156ec
Show file tree
Hide file tree
Showing 58 changed files with 1,558 additions and 592 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
env:
global:
- NDK_VERSION=r11c
- NDK_VERSION=r12b
- DATE=$(date +%Y-%m-%d)
- PACKAGE_VERSION=next-$DATE-$TRAVIS_BUILD_NUMBER
- PACKAGE_NAME=tns-android
sudo: false
sudo: true
language: android
jdk:
- oraclejdk8
Expand Down Expand Up @@ -39,7 +39,8 @@ script:
- echo no | android create avd --force -n Arm21 -t android-21 -b armeabi-v7a -c 12M
- emulator -avd Arm21 -no-skin -no-audio -no-window &
- android-wait-for-emulator
- "cd test-app && ./gradlew runtest -PembedBindingGenerator=true --stacktrace"
- "cd test-app && ./gradlew assembleDebug runtests -PembedBindingGenerator=true --stacktrace"
- adb -e logcat -d 300
- cd ..
before_deploy:
- FULL_PACKAGE_VERSION=`sed -n 's/\s*"version":\s*"\([a-zA-Z0-9\.]*\)"\s*,*/\1/p' dist/package.json`
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
13 changes: 10 additions & 3 deletions runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.7.0-beta3'
classpath 'com.android.tools.build:gradle-experimental:0.8.0-beta2'
}
}

Expand Down Expand Up @@ -59,9 +59,16 @@ model {

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

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

abiFilters.addAll(["armeabi-v7a", "x86", "arm64-v8a"])
if (ndkDebuggable)
{
abiFilters.addAll(["armeabi-v7a"])
}
else
{
abiFilters.addAll(["armeabi-v7a", "x86", "arm64-v8a"])
}
}

android.sources {
Expand Down
2 changes: 1 addition & 1 deletion runtime/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 changes: 5 additions & 2 deletions runtime/src/main/java/com/tns/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ public class Runtime

private native void passUncaughtExceptionToJsNative(int runtimeId, Throwable ex, String stackTrace);

private native void ClearStartupData(int runtimeId);
private native void clearStartupData(int runtimeId);

// Used to determine the bitness of the current process (32 vs 64)
public static native int getPointerSize();

void passUncaughtExceptionToJs(Throwable ex, String stackTrace)
{
Expand Down Expand Up @@ -231,7 +234,7 @@ private void init(Logger logger, Debugger debugger, String appName, File runtime
jsDebugger.start();
}

ClearStartupData(getRuntimeId()); // It's safe to delete the data after the V8 debugger is initialized
clearStartupData(getRuntimeId()); // It's safe to delete the data after the V8 debugger is initialized

if (logger.isEnabled())
{
Expand Down
8 changes: 4 additions & 4 deletions runtime/src/main/jni/ArgConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "NativeScriptException.h"
#include "NumericCasts.h"
#include "Runtime.h"
#include "V8GlobalHelpers.h"
#include <sstream>

using namespace v8;
Expand Down Expand Up @@ -78,8 +79,8 @@ void ArgConverter::NativeScriptLongFunctionCallback(const v8::FunctionCallbackIn
auto isolate = args.GetIsolate();
auto thiz = args.This();
auto cache = GetTypeLongCache(isolate);
thiz->SetHiddenValue(V8StringConstants::GetJavaLong(isolate), Boolean::New(isolate, true));
NumericCasts::MarkAsLong(thiz, args[0]);
V8SetPrivateValue(isolate, thiz, V8StringConstants::GetJavaLong(isolate), Boolean::New(isolate, true));
NumericCasts::MarkAsLong(isolate, thiz, args[0]);
thiz->SetPrototype(Local<NumberObject>::New(isolate, *cache->NanNumberObject));
}
catch (NativeScriptException& e)
Expand Down Expand Up @@ -329,8 +330,7 @@ Local<String> ArgConverter::ConvertToV8String(Isolate *isolate, const jchar* dat

Local<String> ArgConverter::ConvertToV8String(Isolate *isolate, const string& s)
{
Local<String> str;
String::NewFromUtf8(isolate, s.c_str(), NewStringType::kNormal, s.length()).ToLocal(&str);
Local<String> str = String::NewFromUtf8(isolate, s.c_str(), NewStringType::kNormal, s.length()).ToLocalChecked();
return str;
}

Expand Down
11 changes: 8 additions & 3 deletions runtime/src/main/jni/CallbackHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,11 +814,13 @@ Local<Value> CallbackHandlers::CallJSMethod(Isolate *isolate, JNIEnv *_env,
auto jsArgs = ArgConverter::ConvertJavaArgsToJsArgs(isolate, args);
int argc = jsArgs->Length();

Local<Value> arguments[argc];
for (int i = 0; i < argc; i++) {
Local<Value>* arguments = new Local<Value>[argc];
for (int i = 0; i < argc; i++)
{
arguments[i] = jsArgs->Get(i);
}


DEBUG_WRITE("implementationObject->GetIdentityHash()=%d", jsObject->GetIdentityHash());

TryCatch tc;
Expand All @@ -828,9 +830,12 @@ Local<Value> CallbackHandlers::CallJSMethod(Isolate *isolate, JNIEnv *_env,
jsResult = jsMethod->Call(jsObject, argc, argc == 0 ? nullptr : arguments);
}

delete [] arguments;

//TODO: if javaResult is a pure js object create a java object that represents this object in java land

if (tc.HasCaught()) {
if (tc.HasCaught())
{
stringstream ss;
ss << "Calling js method " << methodName << " failed";
string exceptionMessage = ss.str();
Expand Down
7 changes: 5 additions & 2 deletions runtime/src/main/jni/JsArgConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "NumericCasts.h"
#include "NativeScriptException.h"
#include "Runtime.h"
#include "V8GlobalHelpers.h"
#include <cstdlib>

using namespace v8;
using namespace std;
Expand Down Expand Up @@ -126,7 +128,7 @@ bool JsArgConverter::ConvertArg(const Local<Value>& arg, int index)
{
auto jsObject = arg->ToObject();

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

Local<Value> castValue;
JniLocalRef obj;
Expand Down Expand Up @@ -218,7 +220,8 @@ bool JsArgConverter::ConvertArg(const Local<Value>& arg, int index)
case CastType::None:
obj = objectManager->GetJavaObjectByJsObject(jsObject);

castValue = jsObject->GetHiddenValue(ArgConverter::ConvertToV8String(m_isolate, V8StringConstants::NULL_NODE_NAME));
V8GetPrivateValue(m_isolate, jsObject, ArgConverter::ConvertToV8String(m_isolate, V8StringConstants::NULL_NODE_NAME), castValue);

if(!castValue.IsEmpty()) {
SetConvertedObject(index, nullptr);
success = true;
Expand Down
6 changes: 4 additions & 2 deletions runtime/src/main/jni/JsArgToArrayConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "NativeScriptException.h"
#include "Runtime.h"
#include "MetadataNode.h"
#include "V8GlobalHelpers.h"

using namespace v8;
using namespace std;
Expand Down Expand Up @@ -155,7 +156,8 @@ 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 Down Expand Up @@ -268,7 +270,7 @@ bool JsArgToArrayConverter::ConvertArg(const Local<Value>& arg, int index)
case CastType::None:
obj = objectManager->GetJavaObjectByJsObject(jsObj);

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

if(!castValue.IsEmpty()) {
auto node = reinterpret_cast<MetadataNode*>(castValue.As<External>()->Value());
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

0 comments on commit de156ec

Please sign in to comment.