forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamReader.cpp
More file actions
37 lines (33 loc) · 1.08 KB
/
StreamReader.cpp
File metadata and controls
37 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "SCACorePch.h"
namespace Js
{
void StreamReader::Read(void* pv, size_t cb)
{
Assert(cb < m_length);
// Read from buffer
js_memcpy_s(pv, cb, m_buffer + m_current, cb);
m_current += cb;
}
Var StreamReader::ReadHostObject()
{
Var object = nullptr;
ScriptContext* scriptContext = GetScriptContext();
BEGIN_LEAVE_SCRIPT(scriptContext)
{
object = m_stream->ReadHostObject();
}
END_LEAVE_SCRIPT(scriptContext);
return object;
}
//
// Overload to count for buffer position.
//
scaposition_t StreamReader::GetPosition() const
{
return static_cast<scaposition_t>(m_current);
}
}