Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/nodejs/src/node_process.h
1 #ifndef SRC_NODE_PROCESS_H_ 2 #define SRC_NODE_PROCESS_H_ 3 4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 5 6 #include "node_debug.h" 7 #include "node_snapshotable.h" 8 #include "v8-fast-api-calls.h" 9 #include "v8.h" 10 11 namespace node { 12 13 class Environment; 14 class IsolateData; 15 class MemoryTracker; 16 class ExternalReferenceRegistry; 17 class Realm; 18 19 void CreateEnvProxyTemplate(IsolateData* isolate_data); 20 21 // Most of the time, it's best to use `console.error` to write 22 // to the process.stderr stream. However, in some cases, such as 23 // when debugging the stream.Writable class or the process.nextTick 24 // function, it is useful to bypass JavaScript entirely. 25 void RawDebug(const v8::FunctionCallbackInfo<v8::Value>& args); 26 27 v8::MaybeLocal<v8::Value> ProcessEmit(Environment* env, 28 std::string_view event, 29 v8::Local<v8::Value> message); 30 31 v8::Maybe<bool> ProcessEmitWarningGeneric(Environment* env, 32 std::string_view warning, 33 std::string_view type = "", 34 std::string_view code = ""); 35 36 template <typename... Args> 37 inline v8::Maybe<bool> ProcessEmitWarning(Environment* env, 38 const char* fmt, 39 Args&&... args); 40 41 v8::Maybe<void> ProcessEmitWarningSync(Environment* env, 42 std::string_view message); 43 v8::Maybe<bool> ProcessEmitExperimentalWarning(Environment* env, 44 const std::string& warning); 45 v8::Maybe<bool> ProcessEmitDeprecationWarning( 46 Environment* env, 47 const std::string& warning, 48 std::string_view deprecation_code); 49 50 v8::MaybeLocal<v8::Object> CreateProcessObject(Realm* env); 51 void PatchProcessObject(const v8::FunctionCallbackInfo<v8::Value>& args); 52 53 namespace process { 54 class BindingData : public SnapshotableObject { 55 public: 56 struct InternalFieldInfo : public node::InternalFieldInfoBase { 57 AliasedBufferIndex hrtime_buffer; 58 }; 59 60 static void AddMethods(v8::Isolate* isolate, 61 v8::Local<v8::ObjectTemplate> target); 62 static void RegisterExternalReferences(ExternalReferenceRegistry* registry); 63 64 SERIALIZABLE_OBJECT_METHODS() 65 SET_BINDING_ID(process_binding_data) 66 67 BindingData(Realm* realm, 68 v8::Local<v8::Object> object, 69 InternalFieldInfo* info = nullptr); 70 71 void MemoryInfo(MemoryTracker* tracker) const override; 72 SET_MEMORY_INFO_NAME(BindingData) 73 SET_SELF_SIZE(BindingData) 74 75 static BindingData* FromV8Value(v8::Local<v8::Value> receiver); 76 static void HrtimeImpl(BindingData* receiver); 77 78 static void FastHrtime(v8::Local<v8::Value> receiver) { 79 TRACK_V8_FAST_API_CALL("process.hrtime"); 80 HrtimeImpl(FromV8Value(receiver)); 81 } 82 83 static void SlowHrtime(const v8::FunctionCallbackInfo<v8::Value>& args); 84 85 static void HrtimeBigIntImpl(BindingData* receiver); 86 87 static void FastHrtimeBigInt(v8::Local<v8::Value> receiver) { 88 TRACK_V8_FAST_API_CALL("process.hrtimeBigInt"); 89 HrtimeBigIntImpl(FromV8Value(receiver)); 90 } 91 92 static void SlowHrtimeBigInt(const v8::FunctionCallbackInfo<v8::Value>& args); 93 94 static void LoadEnvFile(const v8::FunctionCallbackInfo<v8::Value>& args); 95 96 private: 97 // Buffer length in uint32. 98 static constexpr size_t kHrTimeBufferLength = 3; 99 AliasedUint32Array hrtime_buffer_; 100 InternalFieldInfo* internal_field_info_ = nullptr; 101 102 // These need to be static so that we have their addresses available to 103 // register as external references in the snapshot at environment creation 104 // time. 105 static v8::CFunction fast_hrtime_; 106 static v8::CFunction fast_hrtime_bigint_; 107 }; 108 109 } // namespace process 110 } // namespace node 111 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 112 #endif // SRC_NODE_PROCESS_H_