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 2, 2021
1 parent 7b9d49c commit abe40e8
Show file tree
Hide file tree
Showing 4 changed files with 474 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 @@ -1341,13 +1341,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 @@ -945,9 +945,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 @@ -406,6 +406,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 abe40e8

Please sign in to comment.