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

TiCore from WebKit TAG Safari-538.11.1 #11

Merged
merged 8 commits into from
Nov 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
*~
JavaScriptCore*
.DS_Store
project.xcworkspace
xcuserdata
.svn
*.pyc
*.rej
*.orig
Build/*
31 changes: 31 additions & 0 deletions JavaScriptCore-iOS.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Based on JavaScriptCore-iOS-Static.xcconfig file from JavaScriptCore-iOS project
// Header from original file pasted below
//
// JavaScriptCore-iOS-Static.xcconfig
// JavaScriptCore
//
// Created by Martijn The on 1/17/14.
//
//

#include "JavaScriptCore/Configurations/JavaScriptCore.xcconfig"

ONLY_ACTIVE_ARCH = NO;
SDKROOT = iphoneos;
BUILD_VARIANTS = normal;
STRIP_INSTALLED_PRODUCT = YES;
OTHER_LDFLAGS = ;
PRODUCT_NAME = JavaScriptCore;

SECTORDER_FLAGS = ;
SECTORDER_FLAGS_iphoneos = ;

GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_OPTIMIZATION_LEVEL = 3;
GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) HAVE_DTRACE=$(HAVE_DTRACE) WEBKIT_VERSION_MIN_REQUIRED=WEBKIT_VERSION_LATEST HAVE_HEADER_DETECTION_H JSC_OBJC_API_ENABLED=0 JSC_OBJC_API_AVAILABLE_MAC_OS_X_1080 $(FEATURE_DEFINES) $(GCC_PREPROCESSOR_DEFINITIONS) __MAC_OS_X_VERSION_MIN_REQUIRED=0 ENABLE_YARR_JIT=0 ENABLE_YARR_JIT_DEBUG=0 ENABLE_JIT=0;

ENABLE_REMOTE_INSPECTOR = ENABLE_REMOTE_INSPECTOR=0; // Requires XPC

PRIVATE_HEADERS_FOLDER_PATH = PRIVATE_HEADERS;
PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO;

116 changes: 116 additions & 0 deletions JavaScriptCore/API/APICallbackFunction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/**
* Appcelerator Titanium License
* This source code and all modifications done by Appcelerator
* are licensed under the Apache Public License (version 2) and
* are Copyright (c) 2009-2014 by Appcelerator, Inc.
*/

/*
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef APICallbackFunction_h
#define APICallbackFunction_h

#include "APICast.h"
#include "APIShims.h"
#include "Error.h"
#include "JSCallbackConstructor.h"
#include <wtf/Vector.h>

namespace TI {

struct APICallbackFunction {

template <typename T> static EncodedTiValue JSC_HOST_CALL call(ExecState*);
template <typename T> static EncodedTiValue JSC_HOST_CALL construct(ExecState*);

};

template <typename T>
EncodedTiValue JSC_HOST_CALL APICallbackFunction::call(ExecState* exec)
{
TiContextRef execRef = toRef(exec);
TiObjectRef functionRef = toRef(exec->callee());
TiObjectRef thisObjRef = toRef(jsCast<JSObject*>(exec->hostThisValue().toThis(exec, NotStrictMode)));

int argumentCount = static_cast<int>(exec->argumentCount());
Vector<TiValueRef, 16> arguments;
arguments.reserveInitialCapacity(argumentCount);
for (int i = 0; i < argumentCount; i++)
arguments.uncheckedAppend(toRef(exec, exec->uncheckedArgument(i)));

TiValueRef exception = 0;
TiValueRef result;
{
APICallbackShim callbackShim(exec);
result = jsCast<T*>(toJS(functionRef))->functionCallback()(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);
}
if (exception)
exec->vm().throwException(exec, toJS(exec, exception));

// result must be a valid TiValue.
if (!result)
return TiValue::encode(jsUndefined());

return TiValue::encode(toJS(exec, result));
}

template <typename T>
EncodedTiValue JSC_HOST_CALL APICallbackFunction::construct(ExecState* exec)
{
JSObject* constructor = exec->callee();
TiContextRef ctx = toRef(exec);
TiObjectRef constructorRef = toRef(constructor);

TiObjectCallAsConstructorCallback callback = jsCast<T*>(constructor)->constructCallback();
if (callback) {
size_t argumentCount = exec->argumentCount();
Vector<TiValueRef, 16> arguments;
arguments.reserveInitialCapacity(argumentCount);
for (size_t i = 0; i < argumentCount; ++i)
arguments.uncheckedAppend(toRef(exec, exec->uncheckedArgument(i)));

TiValueRef exception = 0;
TiObjectRef result;
{
APICallbackShim callbackShim(exec);
result = callback(ctx, constructorRef, argumentCount, arguments.data(), &exception);
}
if (exception) {
exec->vm().throwException(exec, toJS(exec, exception));
return TiValue::encode(toJS(exec, exception));
}
// result must be a valid TiValue.
if (!result)
return throwVMTypeError(exec);
return TiValue::encode(toJS(result));
}

return TiValue::encode(toJS(TiObjectMake(ctx, jsCast<JSCallbackConstructor*>(constructor)->classRef(), 0)));
}

} // namespace TI

#endif // APICallbackFunction_h
177 changes: 177 additions & 0 deletions JavaScriptCore/API/APICast.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
/**
* Appcelerator Titanium License
* This source code and all modifications done by Appcelerator
* are licensed under the Apache Public License (version 2) and
* are Copyright (c) 2009-2014 by Appcelerator, Inc.
*/

/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef APICast_h
#define APICast_h

#include "JSAPIValueWrapper.h"
#include "JSCTiValue.h"
#include "JSCTiValueInlines.h"
#include "JSGlobalObject.h"

namespace TI {
class ExecState;
class PropertyNameArray;
class VM;
class JSObject;
class TiValue;
}

typedef const struct OpaqueTiContextGroup* TiContextGroupRef;
typedef const struct OpaqueTiContext* TiContextRef;
typedef struct OpaqueTiContext* TiGlobalContextRef;
typedef struct OpaqueTiPropertyNameAccumulator* TiPropertyNameAccumulatorRef;
typedef const struct OpaqueTiValue* TiValueRef;
typedef struct OpaqueTiValue* TiObjectRef;

/* Opaque typing convenience methods */

inline TI::ExecState* toJS(TiContextRef c)
{
ASSERT(c);
return reinterpret_cast<TI::ExecState*>(const_cast<OpaqueTiContext*>(c));
}

inline TI::ExecState* toJS(TiGlobalContextRef c)
{
ASSERT(c);
return reinterpret_cast<TI::ExecState*>(c);
}

inline TI::TiValue toJS(TI::ExecState* exec, TiValueRef v)
{
ASSERT_UNUSED(exec, exec);
#if USE(JSVALUE32_64)
TI::JSCell* jsCell = reinterpret_cast<TI::JSCell*>(const_cast<OpaqueTiValue*>(v));
if (!jsCell)
return TI::jsNull();
TI::TiValue result;
if (jsCell->isAPIValueWrapper())
result = TI::jsCast<TI::JSAPIValueWrapper*>(jsCell)->value();
else
result = jsCell;
#else
TI::TiValue result = TI::TiValue::decode(reinterpret_cast<TI::EncodedTiValue>(const_cast<OpaqueTiValue*>(v)));
#endif
if (!result)
return TI::jsNull();
if (result.isCell())
RELEASE_ASSERT(result.asCell()->methodTable());
return result;
}

inline TI::TiValue toJSForGC(TI::ExecState* exec, TiValueRef v)
{
ASSERT_UNUSED(exec, exec);
#if USE(JSVALUE32_64)
TI::JSCell* jsCell = reinterpret_cast<TI::JSCell*>(const_cast<OpaqueTiValue*>(v));
if (!jsCell)
return TI::TiValue();
TI::TiValue result = jsCell;
#else
TI::TiValue result = TI::TiValue::decode(reinterpret_cast<TI::EncodedTiValue>(const_cast<OpaqueTiValue*>(v)));
#endif
if (result && result.isCell())
RELEASE_ASSERT(result.asCell()->methodTable());
return result;
}

// Used in TiObjectGetPrivate as that may be called during finalization
inline TI::JSObject* uncheckedToJS(TiObjectRef o)
{
return reinterpret_cast<TI::JSObject*>(o);
}

inline TI::JSObject* toJS(TiObjectRef o)
{
TI::JSObject* object = uncheckedToJS(o);
if (object)
RELEASE_ASSERT(object->methodTable());
return object;
}

inline TI::PropertyNameArray* toJS(TiPropertyNameAccumulatorRef a)
{
return reinterpret_cast<TI::PropertyNameArray*>(a);
}

inline TI::VM* toJS(TiContextGroupRef g)
{
return reinterpret_cast<TI::VM*>(const_cast<OpaqueTiContextGroup*>(g));
}

inline TiValueRef toRef(TI::ExecState* exec, TI::TiValue v)
{
#if USE(JSVALUE32_64)
if (!v)
return 0;
if (!v.isCell())
return reinterpret_cast<TiValueRef>(TI::jsAPIValueWrapper(exec, v).asCell());
return reinterpret_cast<TiValueRef>(v.asCell());
#else
UNUSED_PARAM(exec);
return reinterpret_cast<TiValueRef>(TI::TiValue::encode(v));
#endif
}

inline TiObjectRef toRef(TI::JSObject* o)
{
return reinterpret_cast<TiObjectRef>(o);
}

inline TiObjectRef toRef(const TI::JSObject* o)
{
return reinterpret_cast<TiObjectRef>(const_cast<TI::JSObject*>(o));
}

inline TiContextRef toRef(TI::ExecState* e)
{
return reinterpret_cast<TiContextRef>(e);
}

inline TiGlobalContextRef toGlobalRef(TI::ExecState* e)
{
ASSERT(e == e->lexicalGlobalObject()->globalExec());
return reinterpret_cast<TiGlobalContextRef>(e);
}

inline TiPropertyNameAccumulatorRef toRef(TI::PropertyNameArray* l)
{
return reinterpret_cast<TiPropertyNameAccumulatorRef>(l);
}

inline TiContextGroupRef toRef(TI::VM* g)
{
return reinterpret_cast<TiContextGroupRef>(g);
}

#endif // APICast_h