Skip to content

Commit

Permalink
src: add FileReader and FileWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Jun 10, 2021
1 parent 8834ec9 commit 74f9207
Show file tree
Hide file tree
Showing 4 changed files with 470 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1348,13 +1348,18 @@ std::ostream& operator<<(std::ostream& output,
const std::vector<PropInfo>& vec) {
output << "{\n";
for (const auto& info : vec) {
output << " { \"" << info.name << "\", " << std::to_string(info.id) << ", "
<< std::to_string(info.index) << " },\n";
output << " " << info << ",\n";
}
output << "}";
return output;
}

std::ostream& operator<<(std::ostream& output, const PropInfo& info) {
output << "{ \"" << info.name << "\", " << std::to_string(info.id) << ", "
<< std::to_string(info.index) << " }";
return output;
}

std::ostream& operator<<(std::ostream& output,
const std::vector<std::string>& vec) {
output << "{\n";
Expand Down
5 changes: 5 additions & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -957,9 +957,14 @@ struct EnvSerializeInfo {

struct SnapshotData {
SnapshotData() { blob.data = nullptr; }

static const uint64_t kMagic = 0x143da19;
v8::StartupData blob;
std::vector<size_t> isolate_data_indices;
EnvSerializeInfo env_info;

void ToBlob(FILE* out);
static void FromBlob(SnapshotData* out, FILE* in);
};

class Environment : public MemoryRetainer {
Expand Down
19 changes: 19 additions & 0 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,25 @@ std::string Basename(const std::string& str, const std::string& extension);

node_module napi_module_to_node_module(const napi_module* mod);

std::ostream& operator<<(std::ostream& output,
const std::vector<SnapshotIndex>& v);
std::ostream& operator<<(std::ostream& output,
const std::vector<std::string>& vec);
std::ostream& operator<<(std::ostream& output,
const std::vector<PropInfo>& vec);
std::ostream& operator<<(std::ostream& output, const PropInfo& d);
std::ostream& operator<<(std::ostream& output, const EnvSerializeInfo& d);
std::ostream& operator<<(std::ostream& output,
const ImmediateInfo::SerializeInfo& d);
std::ostream& operator<<(std::ostream& output,
const TickInfo::SerializeInfo& d);
std::ostream& operator<<(std::ostream& output,
const AsyncHooks::SerializeInfo& d);

namespace performance {
std::ostream& operator<<(std::ostream& output,
const PerformanceState::SerializeInfo& d);
}
} // namespace node

#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
Expand Down
Loading

0 comments on commit 74f9207

Please sign in to comment.