Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…o chakra_nuget
  • Loading branch information
pre10der89 committed Jan 4, 2017
2 parents b486c3c + 3f84a23 commit 3a8a9a0
Show file tree
Hide file tree
Showing 101 changed files with 2,269 additions and 1,939 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ install_manifest.txt
*.o
Makefile
pal/src/config.h
DbgController.js.h

# Generated by other tools
*.orig
Expand Down
1 change: 1 addition & 0 deletions bin/ChakraCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ target_include_directories (
#
if(CC_TARGET_OS_ANDROID OR CC_TARGET_OS_LINUX)
set(LINKER_START_GROUP
-fPIC
-Wl,--start-group
-Wl,--whole-archive
)
Expand Down
3 changes: 2 additions & 1 deletion bin/ChakraCore/ChakraCoreShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void DummyJSRTCall()
JsRuntimeHandle *runtime;
JsRuntimeAttributes attr;
JsCreateRuntime(attr, nullptr, runtime);
JsDiagStartDebugging(runtime, nullptr, nullptr);
}
#endif

Expand All @@ -30,4 +31,4 @@ EXTERN_C BOOL WINAPI DllMain(HINSTANCE hmod, DWORD dwReason, PVOID pvReserved)
return TRUE;
}

static_assert(__LINE__ == 33, "You shouldn't add anything to this file or ChakraCoreDllFunc.cpp. Please consider again!");
static_assert(__LINE__ == 34, "You shouldn't add anything to this file or ChakraCoreDllFunc.cpp. Please consider again!");
11 changes: 5 additions & 6 deletions bin/External/catch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1571,8 +1571,8 @@ std::string toString( std::string const& value );
std::string toString( std::wstring const& value );
std::string toString( const char* const value );
std::string toString( char* const value );
std::string toString( const wchar_t* const value );
std::string toString( wchar_t* const value );
std::string toString( const WCHAR* const value );
std::string toString( WCHAR* const value );
std::string toString( int value );
std::string toString( unsigned long value );
std::string toString( unsigned int value );
Expand Down Expand Up @@ -8095,14 +8095,14 @@ std::string toString( char* const value ) {
return Catch::toString( static_cast<const char*>( value ) );
}

std::string toString( const wchar_t* const value )
std::string toString( const WCHAR* const value )
{
return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" );
}

std::string toString( wchar_t* const value )
std::string toString( WCHAR* const value )
{
return Catch::toString( static_cast<const wchar_t*>( value ) );
return Catch::toString( static_cast<const WCHAR*>( value ) );
}

std::string toString( int value ) {
Expand Down Expand Up @@ -10506,4 +10506,3 @@ int main (int argc, char * const argv[]) {
using Catch::Detail::Approx;

#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED

26 changes: 13 additions & 13 deletions bin/NativeTests/JsRTApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace JsRTApiTest
REQUIRE(JsCreateObject(&object) == JsNoError);

JsPropertyIdRef name1 = JS_INVALID_REFERENCE;
const wchar_t* name = nullptr;
const WCHAR* name = nullptr;
REQUIRE(JsGetPropertyIdFromName(_u("stringProperty1"), &name1) == JsNoError);
REQUIRE(JsGetPropertyNameFromId(name1, &name) == JsNoError);
CHECK(!wcscmp(name, _u("stringProperty1")));
Expand Down Expand Up @@ -582,7 +582,7 @@ namespace JsRTApiTest
JsValueRef CALLBACK ExternalFunctionPreScriptAbortionCallback(JsValueRef /* function */, bool /* isConstructCall */, JsValueRef * args /* args */, USHORT /* cargs */, void * /* callbackState */)
{
JsValueRef result = JS_INVALID_REFERENCE;
const wchar_t *scriptText = nullptr;
const WCHAR *scriptText = nullptr;
size_t scriptTextLen;

REQUIRE(JsStringToPointer(args[0], &scriptText, &scriptTextLen) == JsNoError);
Expand All @@ -593,7 +593,7 @@ namespace JsRTApiTest
JsValueRef CALLBACK ExternalFunctionPostScriptAbortionCallback(JsValueRef /* function */, bool /* isConstructCall */, JsValueRef * args /* args */, USHORT /* cargs */, void * /* callbackState */)
{
JsValueRef result = JS_INVALID_REFERENCE;
const wchar_t *scriptText = nullptr;
const WCHAR *scriptText = nullptr;
size_t scriptTextLen;

REQUIRE(JsStringToPointer(args[0], &scriptText, &scriptTextLen) == JsNoError);
Expand Down Expand Up @@ -656,7 +656,7 @@ namespace JsRTApiTest
REQUIRE(JsCreateFunction(ExternalFunctionCallback, nullptr, &function) == JsNoError);
testConstructorName(function, _u(""), 0);

wchar_t name[] = _u("FooName");
WCHAR name[] = _u("FooName");
JsValueRef nameString = JS_INVALID_REFERENCE;
REQUIRE(JsPointerToString(name, _countof(name) - 1, &nameString) == JsNoError);
REQUIRE(JsCreateNamedFunction(nameString, ExternalFunctionCallback, nullptr, &function) == JsNoError);
Expand Down Expand Up @@ -688,7 +688,7 @@ namespace JsRTApiTest

JsValueRef args[] = { GetUndefined() };

// throw from script, handle in host
// throw from script, handle in host
REQUIRE(JsGetPropertyIdFromName(_u("throwAtHost"), &name) == JsNoError);
REQUIRE(JsGetProperty(global, name, &function) == JsNoError);
REQUIRE(JsCallFunction(function, args, _countof(args), &result) == JsErrorScriptException);
Expand All @@ -701,12 +701,12 @@ namespace JsRTApiTest
REQUIRE(JsGetPropertyIdFromName(_u("callHost"), &name) == JsNoError);
REQUIRE(JsSetProperty(global, name, result, true) == JsNoError);

// throw from host callback, catch in script
// throw from host callback, catch in script
REQUIRE(JsGetPropertyIdFromName(_u("callHostWithTryCatch"), &name) == JsNoError);
REQUIRE(JsGetProperty(global, name, &function) == JsNoError);
REQUIRE(JsCallFunction(function, args, _countof(args), &result) == JsNoError);

// throw from host callback, through script, handle in host
// throw from host callback, through script, handle in host
REQUIRE(JsGetPropertyIdFromName(_u("callHostWithNoTryCatch"), &name) == JsNoError);
REQUIRE(JsGetProperty(global, name, &function) == JsNoError);
REQUIRE(JsCallFunction(function, args, _countof(args), &result) == JsErrorScriptException);
Expand Down Expand Up @@ -855,7 +855,7 @@ namespace JsRTApiTest
JsValueRef nameValue = JS_INVALID_REFERENCE;
REQUIRE(JsGetIndexedProperty(propertyNames, indexValue, &nameValue) == JsNoError);

const wchar_t *name = nullptr;
const WCHAR *name = nullptr;
size_t length;
REQUIRE(JsStringToPointer(nameValue, &name, &length) == JsNoError);

Expand All @@ -879,7 +879,7 @@ namespace JsRTApiTest
JsPropertyIdRef propertyId = JS_INVALID_REFERENCE;
JsValueRef outValue = JS_INVALID_REFERENCE;
JsValueRef propertySymbols = JS_INVALID_REFERENCE;
const wchar_t* name = nullptr;
const WCHAR* name = nullptr;
JsPropertyIdType propertyIdType;

REQUIRE(JsCreateObject(&object) == JsNoError);
Expand Down Expand Up @@ -1003,7 +1003,7 @@ namespace JsRTApiTest
bool boolValue;
BYTE *compiledScript = nullptr;
unsigned int scriptSize = 0;
const wchar_t *stringValue;
const WCHAR *stringValue;
size_t stringLength;
ByteCodeCallbackTracker tracker = {};

Expand All @@ -1030,7 +1030,7 @@ namespace JsRTApiTest

tracker.script = script;
REQUIRE(JsRunSerializedScriptWithCallback(
[](JsSourceContext sourceContext, const wchar_t** scriptBuffer)
[](JsSourceContext sourceContext, const WCHAR** scriptBuffer)
{
((ByteCodeCallbackTracker*)sourceContext)->loadedScript = true;
*scriptBuffer = ((ByteCodeCallbackTracker*)sourceContext)->script;
Expand Down Expand Up @@ -1079,7 +1079,7 @@ namespace JsRTApiTest
REQUIRE(oldProtect == PAGE_READWRITE);
tracker.script = scriptFnToString;
REQUIRE(JsRunSerializedScriptWithCallback(
[](JsSourceContext sourceContext, const wchar_t** scriptBuffer)
[](JsSourceContext sourceContext, const WCHAR** scriptBuffer)
{
((ByteCodeCallbackTracker*)sourceContext)->loadedScript = true;
*scriptBuffer = ((ByteCodeCallbackTracker*)sourceContext)->script;
Expand Down Expand Up @@ -1619,7 +1619,7 @@ namespace JsRTApiTest
REQUIRE(JsCreateFunction(ExternalFunctionPostScriptAbortionCallback, nullptr, &postScriptAbortFunction) == JsNoError);
JsValueRef scriptTextArg = JS_INVALID_REFERENCE;

wchar_t *scriptText = const_cast<wchar_t *>(terminationTests[i]);
WCHAR *scriptText = const_cast<WCHAR *>(terminationTests[i]);
REQUIRE(JsPointerToString(scriptText, wcslen(scriptText), &scriptTextArg) == JsNoError);
JsValueRef args[] = { scriptTextArg };

Expand Down
9 changes: 7 additions & 2 deletions bin/ch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ target_include_directories (ch

if(STATIC_LIBRARY)
if(CC_TARGET_OS_ANDROID OR CC_TARGET_OS_LINUX)
set(LINKER_START_GROUP -Wl,--start-group)
set(LINKER_END_GROUP -Wl,--end-group -static-libstdc++)
set(LINKER_START_GROUP -pie -Wl,--start-group)
set(LINKER_END_GROUP -Wl,--end-group)
if (CC_TARGET_OS_LINUX) # do not embed libstdc++ statically on Android
set(LINKER_END_GROUP "${LINKER_END_GROUP} -static-libstdc++")
else()
set(LINKER_END_GROUP "${LINKER_END_GROUP} -llog")
endif()
elseif(CC_TARGET_OS_OSX)
set(LINKER_START_GROUP -Wl,-force_load,)
endif()
Expand Down
6 changes: 3 additions & 3 deletions bin/ch/ChakraRtInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ bool ChakraRTInterface::LoadChakraDll(ArgInfo* argInfo, HINSTANCE *outLibrary)
m_jsApiHooks.pfJsrtParse = (JsAPIHooks::JsrtParse)GetChakraCoreSymbol(library, "JsParse");
m_jsApiHooks.pfJsrtSerialize = (JsAPIHooks::JsrtSerialize)GetChakraCoreSymbol(library, "JsSerialize");
m_jsApiHooks.pfJsrtRunSerialized = (JsAPIHooks::JsrtRunSerialized)GetChakraCoreSymbol(library, "JsRunSerialized");
m_jsApiHooks.pfJsrtCreateStringUtf8 = (JsAPIHooks::JsrtCreateStringUtf8)GetChakraCoreSymbol(library, "JsCreateStringUtf8");
m_jsApiHooks.pfJsrtCopyStringUtf8 = (JsAPIHooks::JsrtCopyStringUtf8)GetChakraCoreSymbol(library, "JsCopyStringUtf8");
m_jsApiHooks.pfJsrtCreatePropertyIdUtf8= (JsAPIHooks::JsrtCreatePropertyIdUtf8)GetChakraCoreSymbol(library, "JsCreatePropertyIdUtf8");
m_jsApiHooks.pfJsrtCreateString = (JsAPIHooks::JsrtCreateString)GetChakraCoreSymbol(library, "JsCreateString");
m_jsApiHooks.pfJsrtCopyString = (JsAPIHooks::JsrtCopyString)GetChakraCoreSymbol(library, "JsCopyString");
m_jsApiHooks.pfJsrtCreatePropertyId = (JsAPIHooks::JsrtCreatePropertyId)GetChakraCoreSymbol(library, "JsCreatePropertyId");
m_jsApiHooks.pfJsrtCreateExternalArrayBuffer = (JsAPIHooks::JsrtCreateExternalArrayBuffer)GetChakraCoreSymbol(library, "JsCreateExternalArrayBuffer");

m_jsApiHooks.pfJsrtTTDCreateRecordRuntime = (JsAPIHooks::JsrtTTDCreateRecordRuntimePtr)GetChakraCoreSymbol(library, "JsTTDCreateRecordRuntime");
Expand Down
18 changes: 9 additions & 9 deletions bin/ch/ChakraRtInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ struct JsAPIHooks
typedef JsErrorCode(WINAPI *JsrtParse)(JsValueRef script, JsSourceContext sourceContext, JsValueRef sourceUrl, JsParseScriptAttributes parseAttributes, JsValueRef *result);
typedef JsErrorCode(WINAPI *JsrtSerialize)(JsValueRef script, JsValueRef *buffer, JsParseScriptAttributes parseAttributes);
typedef JsErrorCode(WINAPI *JsrtRunSerialized)(JsValueRef buffer, JsSerializedLoadScriptCallback scriptLoadCallback, JsSourceContext sourceContext, JsValueRef sourceUrl, JsValueRef * result);
typedef JsErrorCode(WINAPI *JsrtCopyStringUtf8)(JsValueRef value, unsigned char* buffer, size_t bufferSize, size_t* written);
typedef JsErrorCode(WINAPI *JsrtCreateStringUtf8)(const unsigned char *content, size_t length, JsValueRef *value);
typedef JsErrorCode(WINAPI *JsrtCopyString)(JsValueRef value, char* buffer, size_t bufferSize, size_t* written);
typedef JsErrorCode(WINAPI *JsrtCreateString)(const char *content, size_t length, JsValueRef *value);
typedef JsErrorCode(WINAPI *JsrtCreateExternalArrayBuffer)(void *data, unsigned int byteLength, JsFinalizeCallback finalizeCallback, void *callbackState, JsValueRef *result);
typedef JsErrorCode(WINAPI *JsrtCreatePropertyIdUtf8)(const char *name, size_t length, JsPropertyIdRef *propertyId);
typedef JsErrorCode(WINAPI *JsrtCreatePropertyId)(const char *name, size_t length, JsPropertyIdRef *propertyId);

typedef JsErrorCode(WINAPI *JsrtTTDCreateRecordRuntimePtr)(JsRuntimeAttributes attributes, const byte* infoUri, size_t infoUriCount, size_t snapInterval, size_t snapHistoryLength, JsTTDInitializeForWriteLogStreamCallback writeInitializeFunction, TTDOpenResourceStreamCallback openResourceStream, JsTTDReadBytesFromStreamCallback readBytesFromStream, JsTTDWriteBytesToStreamCallback writeBytesToStream, JsTTDFlushAndCloseStreamCallback flushAndCloseStream, JsThreadServiceCallback threadService, JsRuntimeHandle *runtime);
typedef JsErrorCode(WINAPI *JsrtTTDCreateReplayRuntimePtr)(JsRuntimeAttributes attributes, const byte* infoUri, size_t infoUriCount, bool enableDebugging, JsTTDInitializeForWriteLogStreamCallback writeInitializeFunction, TTDOpenResourceStreamCallback openResourceStream, JsTTDReadBytesFromStreamCallback readBytesFromStream, JsTTDWriteBytesToStreamCallback writeBytesToStream, JsTTDFlushAndCloseStreamCallback flushAndCloseStream, JsThreadServiceCallback threadService, JsRuntimeHandle *runtime);
Expand Down Expand Up @@ -164,9 +164,9 @@ struct JsAPIHooks
JsrtParse pfJsrtParse;
JsrtSerialize pfJsrtSerialize;
JsrtRunSerialized pfJsrtRunSerialized;
JsrtCreateStringUtf8 pfJsrtCreateStringUtf8;
JsrtCopyStringUtf8 pfJsrtCopyStringUtf8;
JsrtCreatePropertyIdUtf8 pfJsrtCreatePropertyIdUtf8;
JsrtCreateString pfJsrtCreateString;
JsrtCopyString pfJsrtCopyString;
JsrtCreatePropertyId pfJsrtCreatePropertyId;
JsrtCreateExternalArrayBuffer pfJsrtCreateExternalArrayBuffer;

JsrtTTDCreateRecordRuntimePtr pfJsrtTTDCreateRecordRuntime;
Expand Down Expand Up @@ -368,9 +368,9 @@ class ChakraRTInterface
static JsErrorCode WINAPI JsParse(JsValueRef script, JsSourceContext sourceContext, JsValueRef sourceUrl, JsParseScriptAttributes parseAttributes, JsValueRef *result) { return HOOK_JS_API(Parse(script, sourceContext, sourceUrl, parseAttributes, result)); }
static JsErrorCode WINAPI JsSerialize(JsValueRef script, JsValueRef *buffer, JsParseScriptAttributes parseAttributes) { return HOOK_JS_API(Serialize(script, buffer, parseAttributes)); }
static JsErrorCode WINAPI JsRunSerialized(JsValueRef buffer, JsSerializedLoadScriptCallback scriptLoadCallback, JsSourceContext sourceContext, JsValueRef sourceUrl, JsValueRef * result) { return HOOK_JS_API(RunSerialized(buffer, scriptLoadCallback, sourceContext, sourceUrl, result)); }
static JsErrorCode WINAPI JsCopyStringUtf8(JsValueRef value, unsigned char* buffer, size_t bufferSize, size_t* written) { return HOOK_JS_API(CopyStringUtf8(value, buffer, bufferSize, written)); }
static JsErrorCode WINAPI JsCreateStringUtf8(const unsigned char *content, size_t length, JsValueRef *value) { return HOOK_JS_API(CreateStringUtf8(content, length, value)); }
static JsErrorCode WINAPI JsCreatePropertyIdUtf8(const char *name, size_t length, JsPropertyIdRef *propertyId) { return HOOK_JS_API(CreatePropertyIdUtf8(name, length, propertyId)); }
static JsErrorCode WINAPI JsCopyString(JsValueRef value, char* buffer, size_t bufferSize, size_t* written) { return HOOK_JS_API(CopyString(value, buffer, bufferSize, written)); }
static JsErrorCode WINAPI JsCreateString(const char *content, size_t length, JsValueRef *value) { return HOOK_JS_API(CreateString(content, length, value)); }
static JsErrorCode WINAPI JsCreatePropertyId(const char *name, size_t length, JsPropertyIdRef *propertyId) { return HOOK_JS_API(CreatePropertyId(name, length, propertyId)); }
static JsErrorCode WINAPI JsCreateExternalArrayBuffer(void *data, unsigned int byteLength, JsFinalizeCallback finalizeCallback, void *callbackState, JsValueRef *result) { return HOOK_JS_API(CreateExternalArrayBuffer(data, byteLength, finalizeCallback, callbackState, result)); }
};

Expand Down
8 changes: 4 additions & 4 deletions bin/ch/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ bool Debugger::Initialize()
(void*)controllerScript, (unsigned int)strlen(controllerScript),
nullptr, nullptr, &scriptSource));
JsValueRef fname;
ChakraRTInterface::JsCreateStringUtf8(
(const unsigned char*)"DbgController.js", strlen("DbgController.js"), &fname);
ChakraRTInterface::JsCreateString(
"DbgController.js", strlen("DbgController.js"), &fname);
IfJsrtErrorFailLogAndRetFalse(ChakraRTInterface::JsParse(scriptSource,
JS_SOURCE_CONTEXT_NONE, fname, JsParseScriptAttributeLibraryCode,
&globalFunc));
Expand Down Expand Up @@ -323,8 +323,8 @@ bool Debugger::SetBaseline()
script[numChars] = '\0';

JsValueRef wideScriptRef;
IfJsrtErrorFailLogAndRetFalse(ChakraRTInterface::JsCreateStringUtf8(
(const unsigned char*)script, strlen(script), &wideScriptRef));
IfJsrtErrorFailLogAndRetFalse(ChakraRTInterface::JsCreateString(
script, strlen(script), &wideScriptRef));

this->CallFunctionNoResult("SetBaseline", wideScriptRef);
}
Expand Down
4 changes: 2 additions & 2 deletions bin/ch/Debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ static const char controllerScript[] = {
'\0'
};
#else
static const char controllerScript[] = { '\0' };
#include "DbgController.js.h"
#endif

class Debugger
{
public:
Expand Down
Loading

0 comments on commit 3a8a9a0

Please sign in to comment.