Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/nodejs/src/node_sea.h
1 #ifndef SRC_NODE_SEA_H_ 2 #define SRC_NODE_SEA_H_ 3 4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 5 6 #include <cinttypes> 7 #include <optional> 8 #include <string> 9 #include <string_view> 10 #include <tuple> 11 #include <unordered_map> 12 #include <vector> 13 14 #include "node_exit_code.h" 15 16 namespace node { 17 class Environment; 18 namespace sea { 19 // A special number that will appear at the beginning of the single executable 20 // preparation blobs ready to be injected into the binary. We use this to check 21 // that the data given to us are intended for building single executable 22 // applications. 23 const uint32_t kMagic = 0x143da20; 24 25 enum class SeaFlags : uint32_t { 26 kDefault = 0, 27 kDisableExperimentalSeaWarning = 1 << 0, 28 kUseSnapshot = 1 << 1, 29 kUseCodeCache = 1 << 2, 30 kIncludeAssets = 1 << 3, 31 kIncludeExecArgv = 1 << 4, 32 }; 33 34 enum class SeaExecArgvExtension : uint8_t { 35 kNone = 0, 36 kEnv = 1, 37 kCli = 2, 38 }; 39 40 struct SeaResource { 41 SeaFlags flags = SeaFlags::kDefault; 42 SeaExecArgvExtension exec_argv_extension = SeaExecArgvExtension::kEnv; 43 std::string_view code_path; 44 std::string_view main_code_or_snapshot; 45 std::optional<std::string_view> code_cache; 46 std::unordered_map<std::string_view, std::string_view> assets; 47 std::vector<std::string_view> exec_argv; 48 49 bool use_snapshot() const; 50 bool use_code_cache() const; 51 52 static constexpr size_t kHeaderSize = 53 sizeof(kMagic) + sizeof(SeaFlags) + sizeof(SeaExecArgvExtension); 54 }; 55 56 bool IsSingleExecutable(); 57 SeaResource FindSingleExecutableResource(); 58 std::tuple<int, char**> FixupArgsForSEA(int argc, char** argv); 59 node::ExitCode BuildSingleExecutableBlob( 60 const std::string& config_path, 61 const std::vector<std::string>& args, 62 const std::vector<std::string>& exec_args); 63 64 // Try loading the Environment as a single-executable application. 65 // Returns true if it is loaded as a single-executable application. 66 // Otherwise returns false and the caller is expected to call LoadEnvironment() 67 // differently. 68 bool MaybeLoadSingleExecutableApplication(Environment* env); 69 } // namespace sea 70 } // namespace node 71 72 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 73 74 #endif // SRC_NODE_SEA_H_