Skip to content

Commit a7ba104

Browse files
Version 5.4.9: Enabled V8 snapshot feature to accelerate V8ScriptEngine initialization; overhauled V8 interface, eliminating deprecated API usage and fixing Issue ClearFoundry#116. Tested with V8 5.5.372.40.
1 parent 5ebc1dd commit a7ba104

File tree

22 files changed

+1338
-878
lines changed

22 files changed

+1338
-878
lines changed

ClearScript/Exports/VersionSymbols.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@
6363

6464
#pragma once
6565

66-
#define CLEARSCRIPT_VERSION_STRING "5.4.8.0"
67-
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 5,4,8,0
66+
#define CLEARSCRIPT_VERSION_STRING "5.4.9.0"
67+
#define CLEARSCRIPT_VERSION_COMMA_SEPARATED 5,4,9,0

ClearScript/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@
7575
[assembly: InternalsVisibleTo("ClearScriptTest")]
7676

7777
[assembly: ComVisible(false)]
78-
[assembly: AssemblyVersion("5.4.8.0")]
79-
[assembly: AssemblyFileVersion("5.4.8.0")]
78+
[assembly: AssemblyVersion("5.4.9.0")]
79+
[assembly: AssemblyFileVersion("5.4.9.0")]

ClearScript/ScriptEngine.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,11 @@ internal string GetCommandResultString(object result)
12841284
return marshaledResult.ToString();
12851285
}
12861286

1287+
if (marshaledResult is ScriptItem)
1288+
{
1289+
return "[ScriptObject]";
1290+
}
1291+
12871292
return result.ToString();
12881293
}
12891294

ClearScript/V8/ClearScriptV8/CommonPlatform.h

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,29 @@
121121
{
122122

123123
#define END_COMPOUND_MACRO \
124-
__pragma(warning(push)) \
125-
__pragma(warning(disable:4127)) \
124+
__pragma(warning(disable:4127)) /* conditional expression is constant */ \
126125
} \
127126
while (false) \
128-
__pragma(warning(pop))
127+
__pragma(warning(default:4127))
128+
129+
//-----------------------------------------------------------------------------
130+
// global helper functions
131+
//-----------------------------------------------------------------------------
132+
133+
template <typename TFlag>
134+
inline TFlag CombineFlags(TFlag flag1, TFlag flag2)
135+
{
136+
using TUnderlying = std::underlying_type_t<TFlag>;
137+
return static_cast<TFlag>(static_cast<TUnderlying>(flag1) | static_cast<TUnderlying>(flag2));
138+
}
139+
140+
//-----------------------------------------------------------------------------
141+
142+
template <typename TFlag, typename... TOthers>
143+
inline TFlag CombineFlags(TFlag flag1, TFlag flag2, TOthers... others)
144+
{
145+
return CombineFlags(flag1, CombineFlags(flag2, others...));
146+
}
129147

130148
//-----------------------------------------------------------------------------
131149
// PulseValueScope
@@ -160,9 +178,11 @@ class PulseValueScope
160178
//-----------------------------------------------------------------------------
161179

162180
#define BEGIN_PULSE_VALUE_SCOPE(ADDRESS, VALUE) \
163-
{ \
164-
PulseValueScope<std::remove_reference<decltype(*(ADDRESS))>::type> t_PulseValueScope((ADDRESS), (VALUE));
181+
{ \
182+
__pragma(warning(disable:4456)) /* declaration hides previous local declaration */ \
183+
PulseValueScope<std::remove_reference<decltype(*(ADDRESS))>::type> t_PulseValueScope((ADDRESS), (VALUE)); \
184+
__pragma(warning(default:4456))
165185

166186
#define END_PULSE_VALUE_SCOPE \
167-
IGNORE_UNUSED(t_PulseValueScope); \
168-
}
187+
IGNORE_UNUSED(t_PulseValueScope); \
188+
}

ClearScript/V8/ClearScriptV8/ManagedPlatform.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ using namespace Microsoft::ClearScript::Util;
9696

9797
#define BEGIN_LOCK_SCOPE(OBJECT) \
9898
{ \
99-
msclr::lock t_Lock(OBJECT);
99+
__pragma(warning(disable:4456)) /* declaration hides previous local declaration */ \
100+
msclr::lock t_Lock(OBJECT); \
101+
__pragma(warning(default:4456))
100102

101103
#define END_LOCK_SCOPE \
102104
IGNORE_UNUSED(t_Lock); \

ClearScript/V8/ClearScriptV8/Mutex.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ template <class TMutex> class MutexLock
166166

167167
#define BEGIN_MUTEX_SCOPE(MUTEX) \
168168
{ \
169-
MutexLock<decltype(MUTEX)> t_MutexLock(MUTEX);
169+
__pragma(warning(disable:4456)) /* declaration hides previous local declaration */ \
170+
MutexLock<decltype(MUTEX)> t_MutexLock(MUTEX); \
171+
__pragma(warning(default:4456))
170172

171173
#define END_MUTEX_SCOPE \
172174
IGNORE_UNUSED(t_MutexLock); \

ClearScript/V8/ClearScriptV8/SharedPtr.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ class SharedPtrTarget
121121

122122
#define BEGIN_ADDREF_SCOPE \
123123
{ \
124-
AddRefScope t_AddRefScope(GetRefCount());
124+
__pragma(warning(disable:4456)) /* declaration hides previous local declaration */ \
125+
AddRefScope t_AddRefScope(GetRefCount()); \
126+
__pragma(warning(default:4456))
125127

126128
#define END_ADDREF_SCOPE \
127129
IGNORE_UNUSED(t_AddRefScope); \

ClearScript/V8/ClearScriptV8/StdString.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,17 +273,17 @@ class StdString
273273
{
274274
}
275275

276-
v8::Local<v8::String> ToV8String(v8::Isolate* pIsolate) const
276+
v8::MaybeLocal<v8::String> ToV8String(v8::Isolate* pIsolate) const
277277
{
278-
return v8::String::NewFromTwoByte(pIsolate, reinterpret_cast<const uint16_t*>(ToCString()), v8::String::kNormalString, GetLength());
278+
return v8::String::NewFromTwoByte(pIsolate, reinterpret_cast<const uint16_t*>(ToCString()), v8::NewStringType::kNormal, GetLength());
279279
}
280280

281281
private:
282282

283283
static std::wstring GetValue(v8::Local<v8::Value> hValue)
284284
{
285285
v8::String::Value value(hValue);
286-
return std::wstring(*value, value.length());
286+
return std::wstring(EnsureNonNull(*value), value.length());
287287
}
288288

289289
#endif // !_M_CEE

0 commit comments

Comments
 (0)