Files
wengchangcheng 1cc4e3a60e Descriptor: debugger refactor of independent js_runtime [ part-4 ]
details:
1. Add PtBaseReturns::ToJson
2. Add PtBaseEvents::ToJson
issue: https://gitee.com/openharmony/ark_js_runtime/issues/I5C3FS

Signed-off-by: wengchangcheng <wengchangcheng@huawei.com>
Change-Id: Ic8028d79f62b91724f22c63e8062d57367b5f27e
2022-06-15 22:24:45 +08:00

85 lines
2.4 KiB
C++

/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ECMASCRIPT_TOOLING_INTERFACE_FILE_STREAM_H
#define ECMASCRIPT_TOOLING_INTERFACE_FILE_STREAM_H
#include <fstream>
#include "ecmascript/tooling/interface/stream.h"
namespace panda::ecmascript {
class FileStream : public Stream {
public:
FileStream(const std::string &fileName);
~FileStream() override = default;
void EndOfStream() override;
// Get chunk's size
int GetSize() override
{
const static int fileChunkSize = 10240;
return fileChunkSize;
}
// Writes the chunk of data into the stream
bool WriteChunk(char* data, int32_t size) override;
bool Good() override;
void UpdateHeapStats([[maybe_unused]] HeapStat* data, [[maybe_unused]] int32_t count) override
{
}
void UpdateLastSeenObjectId([[maybe_unused]] int32_t lastSeenObjectId) override
{
}
private:
void Initialize(const std::string &fileName);
std::pair<bool, std::string> FilePathValid(const std::string &fileName);
std::fstream fileStream_;
};
class FileDescriptorStream : public Stream {
public:
explicit FileDescriptorStream(int32_t fd): fd_(fd) {}
~FileDescriptorStream() override = default;
void EndOfStream() override;
// Get chunk's size
int GetSize() override
{
const static int fileChunkSize = 10240;
return fileChunkSize;
}
// Writes the chunk of data into the stream
bool WriteChunk(char *data, int32_t size) override;
bool Good() override;
void UpdateHeapStats([[maybe_unused]] HeapStat* data, [[maybe_unused]] int32_t count) override
{
}
void UpdateLastSeenObjectId([[maybe_unused]] int32_t lastSeenObjectId) override
{
}
private:
int32_t fd_;
};
} // namespace panda::ecmascript::tooling
#endif // ECMASCRIPT_TOOLING_INTERFACE_FILE_STREAM_H