Skip to content

Commit 930ae30

Browse files
committed
In JavaScriptEngineSwitcher.ChakraCore fixed a implementation of the JsSerializedLoadScriptCallback delegate
1 parent b2e5a34 commit 930ae30

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

src/JavaScriptEngineSwitcher.ChakraCore/JavaScriptEngineSwitcher.ChakraCore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ This package does not contain the native implementations of ChakraCore. Therefor
2222
* JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64</Description>
2323
<PackageIconUrl>https://raw.githubusercontent.com/Taritsyn/JavaScriptEngineSwitcher/master/Icons/JavaScriptEngineSwitcher_ChakraCore_Logo128x128.png</PackageIconUrl>
2424
<PackageTags>JavaScriptEngineSwitcher;JavaScript;ECMAScript;ChakraCore</PackageTags>
25-
<PackageReleaseNotes>1. ChakraCore was updated to version 1.8.4;
26-
2. Added a ability to pre-compile scripts.</PackageReleaseNotes>
25+
<PackageReleaseNotes>Fixed a implementation of the `JsSerializedLoadScriptCallback` delegate.</PackageReleaseNotes>
2726
</PropertyGroup>
2827

2928
<Import Project="../../build/common.props" />

src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsContext.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ public static JsValue ParseSerializedScript(string script, byte[] buffer, JsSour
257257
JsSerializedLoadScriptCallback scriptLoadCallback = (JsSourceContext context,
258258
out JsValue value, out JsParseScriptAttributes parseAttributes) =>
259259
{
260-
value = JsValue.FromString(script);
260+
byte[] bytes = Encoding.GetEncoding(0).GetBytes(script);
261+
value = JsValue.CreateExternalArrayBuffer(bytes);
261262
parseAttributes = JsParseScriptAttributes.None;
262263

263264
return true;
@@ -390,7 +391,8 @@ public static JsValue RunSerializedScript(string script, byte[] buffer, JsSource
390391
JsSerializedLoadScriptCallback scriptLoadCallback = (JsSourceContext context,
391392
out JsValue value, out JsParseScriptAttributes parseAttributes) =>
392393
{
393-
value = JsValue.FromString(script);
394+
byte[] bytes = Encoding.GetEncoding(0).GetBytes(script);
395+
value = JsValue.CreateExternalArrayBuffer(bytes);
394396
parseAttributes = JsParseScriptAttributes.None;
395397

396398
return true;

src/JavaScriptEngineSwitcher.ChakraCore/JsRt/JsSerializedLoadScriptCallback.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
/// <summary>
44
/// Called by the runtime to load the source code of the serialized script
55
/// </summary>
6-
/// <param name="sourceContext">The context passed to Js[Parse|Run]Serialized</param>
7-
/// <param name="value">The result of the compiled script</param>
6+
/// <param name="sourceContext">A cookie identifying the script that can be used
7+
/// by debuggable script contexts</param>
8+
/// <param name="value">The script returned</param>
89
/// <param name="parseAttributes">Attribute mask for parsing the script</param>
910
/// <returns>true if the operation succeeded, false otherwise</returns>
1011
internal delegate bool JsSerializedLoadScriptCallback(JsSourceContext sourceContext,

src/JavaScriptEngineSwitcher.ChakraCore/readme.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
=============
3131
RELEASE NOTES
3232
=============
33-
1. ChakraCore was updated to version 1.8.4;
34-
2. Added a ability to pre-compile scripts.
33+
Fixed a implementation of the `JsSerializedLoadScriptCallback` delegate.
3534

3635
=============
3736
DOCUMENTATION

test/JavaScriptEngineSwitcher.Tests/JavaScriptEngineSwitcher.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
</ItemGroup>
6161

6262
<ItemGroup>
63-
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0" />
63+
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
6464
</ItemGroup>
6565

6666
</Project>

0 commit comments

Comments
 (0)