|
|
@@ -51,14 +51,12 @@ DWORD_PTR WScriptJsrt::sourceContext = 0;
|
|
|
char *errorMessageNarrow; \
|
|
|
if (FAILED(WideStringToNarrowDynamic(errorMessage, &errorMessageNarrow))) \
|
|
|
{ \
|
|
|
- errorCode = ChakraRTInterface::JsCreateStringUtf8( \
|
|
|
- (const unsigned char*)outOfMemoryString, \
|
|
|
+ errorCode = ChakraRTInterface::JsCreateString(outOfMemoryString, \
|
|
|
strlen(outOfMemoryString), &errorMessageString); \
|
|
|
} \
|
|
|
else \
|
|
|
{ \
|
|
|
- errorCode = ChakraRTInterface::JsCreateStringUtf8( \
|
|
|
- (const unsigned char*)errorMessageNarrow, \
|
|
|
+ errorCode = ChakraRTInterface::JsCreateString(errorMessageNarrow, \
|
|
|
strlen(errorMessageNarrow), &errorMessageString); \
|
|
|
free(errorMessageNarrow); \
|
|
|
} \
|
|
|
@@ -90,8 +88,8 @@ bool WScriptJsrt::CreateArgumentsObject(JsValueRef *argsObject)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
- JsErrorCode errCode = ChakraRTInterface::JsCreateStringUtf8(
|
|
|
- (const unsigned char*)argNarrow,
|
|
|
+ JsErrorCode errCode = ChakraRTInterface::JsCreateString(
|
|
|
+ argNarrow,
|
|
|
strlen(argNarrow), &value);
|
|
|
free(argNarrow);
|
|
|
IfJsrtErrorFail(errCode, false);
|
|
|
@@ -325,8 +323,8 @@ JsErrorCode WScriptJsrt::LoadModuleFromString(LPCSTR fileName, LPCSTR fileConten
|
|
|
if (moduleRecordEntry == moduleRecordMap.end())
|
|
|
{
|
|
|
JsValueRef specifier;
|
|
|
- errorCode = ChakraRTInterface::JsCreateStringUtf8(
|
|
|
- (const unsigned char*)fileName, strlen(fileName), &specifier);
|
|
|
+ errorCode = ChakraRTInterface::JsCreateString(
|
|
|
+ fileName, strlen(fileName), &specifier);
|
|
|
if (errorCode == JsNoError)
|
|
|
{
|
|
|
errorCode = ChakraRTInterface::JsInitializeModuleRecord(
|
|
|
@@ -413,7 +411,7 @@ JsValueRef WScriptJsrt::LoadScript(JsValueRef callee, LPCSTR fileName,
|
|
|
IfJsrtErrorSetGo(ChakraRTInterface::JsCreateExternalArrayBuffer((void*)fileContent,
|
|
|
(unsigned int)strlen(fileContent), nullptr, nullptr, &scriptSource));
|
|
|
JsValueRef fname;
|
|
|
- IfJsrtErrorSetGo(ChakraRTInterface::JsCreateStringUtf8((const unsigned char*)fullPathNarrow,
|
|
|
+ IfJsrtErrorSetGo(ChakraRTInterface::JsCreateString(fullPathNarrow,
|
|
|
strlen(fullPathNarrow), &fname));
|
|
|
errorCode = ChakraRTInterface::JsRun(scriptSource, GetNextSourceContext(),
|
|
|
fname, JsParseScriptAttributeNone, &returnValue);
|
|
|
@@ -446,7 +444,7 @@ JsValueRef WScriptJsrt::LoadScript(JsValueRef callee, LPCSTR fileName,
|
|
|
IfJsrtErrorSetGo(ChakraRTInterface::JsCreateExternalArrayBuffer((void*)fileContent,
|
|
|
(unsigned int)strlen(fileContent), nullptr, nullptr, &scriptSource));
|
|
|
JsValueRef fname;
|
|
|
- IfJsrtErrorSetGo(ChakraRTInterface::JsCreateStringUtf8((const unsigned char*)fullPathNarrow,
|
|
|
+ IfJsrtErrorSetGo(ChakraRTInterface::JsCreateString(fullPathNarrow,
|
|
|
strlen(fullPathNarrow), &fname));
|
|
|
errorCode = ChakraRTInterface::JsRun(scriptSource, GetNextSourceContext(),
|
|
|
fname, JsParseScriptAttributeNone, &returnValue);
|
|
|
@@ -723,8 +721,8 @@ bool WScriptJsrt::CreateNamedFunction(const char* nameString, JsNativeFunction c
|
|
|
JsValueRef* functionVar)
|
|
|
{
|
|
|
JsValueRef nameVar;
|
|
|
- IfJsrtErrorFail(ChakraRTInterface::JsCreateStringUtf8(
|
|
|
- (const unsigned char*)nameString, strlen(nameString), &nameVar), false);
|
|
|
+ IfJsrtErrorFail(ChakraRTInterface::JsCreateString(
|
|
|
+ nameString, strlen(nameString), &nameVar), false);
|
|
|
IfJsrtErrorFail(ChakraRTInterface::JsCreateNamedFunction(nameVar, callback,
|
|
|
nullptr, functionVar), false);
|
|
|
return true;
|
|
|
@@ -851,8 +849,8 @@ bool WScriptJsrt::Initialize()
|
|
|
JsPropertyIdRef archProperty;
|
|
|
IfJsrtErrorFail(CreatePropertyIdFromString("ARCH", &archProperty), false);
|
|
|
JsValueRef archValue;
|
|
|
- IfJsrtErrorFail(ChakraRTInterface::JsCreateStringUtf8(
|
|
|
- (const unsigned char*)CPU_ARCH_TEXT, strlen(CPU_ARCH_TEXT), &archValue), false);
|
|
|
+ IfJsrtErrorFail(ChakraRTInterface::JsCreateString(
|
|
|
+ CPU_ARCH_TEXT, strlen(CPU_ARCH_TEXT), &archValue), false);
|
|
|
IfJsrtErrorFail(ChakraRTInterface::JsSetProperty(platformObject, archProperty,
|
|
|
archValue, true), false);
|
|
|
|
|
|
@@ -865,8 +863,8 @@ bool WScriptJsrt::Initialize()
|
|
|
#else
|
|
|
#define BUILD_TYPE_STRING_CH "Release" // consider Test is also Release build (O3)
|
|
|
#endif
|
|
|
- IfJsrtErrorFail(ChakraRTInterface::JsCreateStringUtf8(
|
|
|
- (const unsigned char*)BUILD_TYPE_STRING_CH, strlen(BUILD_TYPE_STRING_CH), &buildValue), false);
|
|
|
+ IfJsrtErrorFail(ChakraRTInterface::JsCreateString(
|
|
|
+ BUILD_TYPE_STRING_CH, strlen(BUILD_TYPE_STRING_CH), &buildValue), false);
|
|
|
IfJsrtErrorFail(ChakraRTInterface::JsSetProperty(platformObject, buildProperty,
|
|
|
buildValue, true), false);
|
|
|
#undef BUILD_TYPE_STRING_CH
|
|
|
@@ -875,8 +873,8 @@ bool WScriptJsrt::Initialize()
|
|
|
JsPropertyIdRef linkProperty;
|
|
|
IfJsrtErrorFail(CreatePropertyIdFromString("LINK_TYPE", &linkProperty), false);
|
|
|
JsValueRef linkValue;
|
|
|
- IfJsrtErrorFail(ChakraRTInterface::JsCreateStringUtf8(
|
|
|
- (const unsigned char*)LINK_TYPE, strlen(LINK_TYPE), &linkValue), false);
|
|
|
+ IfJsrtErrorFail(ChakraRTInterface::JsCreateString(
|
|
|
+ LINK_TYPE, strlen(LINK_TYPE), &linkValue), false);
|
|
|
IfJsrtErrorFail(ChakraRTInterface::JsSetProperty(platformObject, linkProperty,
|
|
|
linkValue, true), false);
|
|
|
|
|
|
@@ -887,8 +885,8 @@ bool WScriptJsrt::Initialize()
|
|
|
JsPropertyIdRef binaryPathProperty;
|
|
|
IfJsrtErrorFail(CreatePropertyIdFromString("BINARY_PATH", &binaryPathProperty), false);
|
|
|
|
|
|
- IfJsrtErrorFail(ChakraRTInterface::JsCreateStringUtf8(
|
|
|
- (const unsigned char*)CH_BINARY_LOCATION,
|
|
|
+ IfJsrtErrorFail(ChakraRTInterface::JsCreateString(
|
|
|
+ CH_BINARY_LOCATION,
|
|
|
strlen(CH_BINARY_LOCATION), &binaryPathValue), false);
|
|
|
IfJsrtErrorFail(ChakraRTInterface::JsSetProperty(
|
|
|
platformObject, binaryPathProperty, binaryPathValue, true), false);
|
|
|
@@ -897,9 +895,8 @@ bool WScriptJsrt::Initialize()
|
|
|
JsPropertyIdRef osProperty;
|
|
|
IfJsrtErrorFail(CreatePropertyIdFromString("OS", &osProperty), false);
|
|
|
JsValueRef osValue;
|
|
|
- IfJsrtErrorFail(ChakraRTInterface::JsCreateStringUtf8(
|
|
|
- (const unsigned char*)DEST_PLATFORM_TEXT,
|
|
|
- strlen(DEST_PLATFORM_TEXT), &osValue), false);
|
|
|
+ IfJsrtErrorFail(ChakraRTInterface::JsCreateString(
|
|
|
+ DEST_PLATFORM_TEXT, strlen(DEST_PLATFORM_TEXT), &osValue), false);
|
|
|
IfJsrtErrorFail(ChakraRTInterface::JsSetProperty(platformObject, osProperty,
|
|
|
osValue, true), false);
|
|
|
|
|
|
@@ -978,9 +975,8 @@ JsValueRef __stdcall WScriptJsrt::LoadTextFileCallback(JsValueRef callee, bool i
|
|
|
else
|
|
|
{
|
|
|
JsValueRef stringObject;
|
|
|
- IfJsrtErrorSetGo(ChakraRTInterface::JsCreateStringUtf8(
|
|
|
- (const unsigned char*)fileContent,
|
|
|
- lengthBytes, &stringObject));
|
|
|
+ IfJsrtErrorSetGo(ChakraRTInterface::JsCreateString(
|
|
|
+ fileContent, lengthBytes, &stringObject));
|
|
|
return stringObject;
|
|
|
}
|
|
|
}
|
|
|
@@ -1204,7 +1200,7 @@ HRESULT WScriptJsrt::CallbackMessage::CallFunction(LPCSTR fileName)
|
|
|
IfJsrtErrorHR(ChakraRTInterface::JsConvertValueToString(m_function, &stringValue));
|
|
|
|
|
|
JsValueRef fname;
|
|
|
- ChakraRTInterface::JsCreateStringUtf8((const unsigned char*)"", strlen(""), &fname);
|
|
|
+ ChakraRTInterface::JsCreateString("", strlen(""), &fname);
|
|
|
// Run the code
|
|
|
errorCode = ChakraRTInterface::JsRun(stringValue, JS_SOURCE_CONTEXT_NONE,
|
|
|
fname, JsParseScriptAttributeArrayBufferIsUtf16Encoded,
|