Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/nodejs/src/base_object_types.h
1 #ifndef SRC_BASE_OBJECT_TYPES_H_ 2 #define SRC_BASE_OBJECT_TYPES_H_ 3 4 #include <cinttypes> 5 6 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 7 8 namespace node { 9 // List of internalBinding() data wrappers. The first argument should match 10 // what the class passes to SET_BINDING_ID(), the second argument should match 11 // the C++ class name. 12 #define SERIALIZABLE_BINDING_TYPES(V) \ 13 V(encoding_binding_data, encoding_binding::BindingData) \ 14 V(fs_binding_data, fs::BindingData) \ 15 V(mksnapshot_binding_data, mksnapshot::BindingData) \ 16 V(v8_binding_data, v8_utils::BindingData) \ 17 V(blob_binding_data, BlobBindingData) \ 18 V(process_binding_data, process::BindingData) \ 19 V(timers_binding_data, timers::BindingData) \ 20 V(url_binding_data, url::BindingData) \ 21 V(modules_binding_data, modules::BindingData) 22 23 #define UNSERIALIZABLE_BINDING_TYPES(V) \ 24 V(http2_binding_data, http2::BindingData) \ 25 V(http_parser_binding_data, http_parser::BindingData) \ 26 V(quic_binding_data, quic::BindingData) 27 28 // List of (non-binding) BaseObjects that are serializable in the snapshot. 29 // The first argument should match what the type passes to 30 // SET_OBJECT_ID(), the second argument should match the C++ class 31 // name. 32 #define SERIALIZABLE_NON_BINDING_TYPES(V) 33 34 // Helper list of all binding data wrapper types. 35 #define BINDING_TYPES(V) \ 36 SERIALIZABLE_BINDING_TYPES(V) \ 37 UNSERIALIZABLE_BINDING_TYPES(V) 38 39 // Helper list of all BaseObjects that implement snapshot support. 40 #define SERIALIZABLE_OBJECT_TYPES(V) \ 41 SERIALIZABLE_BINDING_TYPES(V) \ 42 SERIALIZABLE_NON_BINDING_TYPES(V) 43 44 #define V(TypeId, NativeType) k_##TypeId, 45 enum class BindingDataType : uint8_t { BINDING_TYPES(V) kBindingDataTypeCount }; 46 // Make sure that we put the bindings first so that we can also use the enums 47 // for the bindings as index to the binding data store. 48 enum class EmbedderObjectType : uint8_t { 49 BINDING_TYPES(V) SERIALIZABLE_NON_BINDING_TYPES(V) 50 // We do not need to know about all the unserializable non-binding types for 51 // now so we do not list them. 52 kEmbedderObjectTypeCount 53 }; 54 #undef V 55 56 // For now, BaseObjects only need to call this when they implement snapshot 57 // support. 58 #define SET_OBJECT_ID(TypeId) \ 59 static constexpr EmbedderObjectType type_int = EmbedderObjectType::k_##TypeId; 60 61 // Binding data should call this so that they can be looked up from the binding 62 // data store. 63 #define SET_BINDING_ID(TypeId) \ 64 static constexpr BindingDataType binding_type_int = \ 65 BindingDataType::k_##TypeId; \ 66 SET_OBJECT_ID(TypeId) \ 67 static_assert(static_cast<uint8_t>(type_int) == \ 68 static_cast<uint8_t>(binding_type_int)); 69 70 } // namespace node 71 72 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 73 74 #endif // SRC_BASE_OBJECT_TYPES_H_