1010
1111namespace node {
1212
13- using CFunctionCallbackWithOneByteString =
14- uint32_t (*)(v8::Local<v8::Value>, const v8::FastOneByteString&);
15-
16- using CFunctionCallbackReturnBool = bool (*)(v8::Local<v8::Value> unused,
17- v8::Local<v8::Value> receiver);
18- using CFunctionCallback = void (*)(v8::Local<v8::Value> unused,
19- v8::Local<v8::Value> receiver);
20- using CFunctionCallbackReturnDouble =
21- double (*)(v8::Local<v8::Object> unused, v8::Local<v8::Object> receiver);
22- using CFunctionCallbackReturnInt32 =
23- int32_t (*)(v8::Local<v8::Value> receiver,
24- v8::Local<v8::Value> input,
25- // NOLINTNEXTLINE(runtime/references) This is V8 api.
26- v8::FastApiCallbackOptions& options);
27- using CFunctionCallbackValueReturnDouble =
28- double (*)(v8::Local<v8::Value> receiver);
29- using CFunctionCallbackValueReturnDoubleUnusedReceiver =
30- double (*)(v8::Local<v8::Value> unused, v8::Local<v8::Value> receiver);
31- using CFunctionCallbackWithInt64 = void (*)(v8::Local<v8::Object> unused,
32- v8::Local<v8::Object> receiver,
33- int64_t );
34- using CFunctionCallbackWithBool = void (*)(v8::Local<v8::Object> unused,
35- v8::Local<v8::Object> receiver,
36- bool );
37- using CFunctionCallbackWithString =
38- bool (*)(v8::Local<v8::Value>, const v8::FastOneByteString& input);
39- using CFunctionCallbackWithStrings =
40- bool (*)(v8::Local<v8::Value>,
41- const v8::FastOneByteString& input,
42- const v8::FastOneByteString& base);
43- using CFunctionCallbackWithTwoUint8Arrays =
44- int32_t (*)(v8::Local<v8::Value>,
45- const v8::FastApiTypedArray<uint8_t >&,
46- const v8::FastApiTypedArray<uint8_t >&);
47- using CFunctionCallbackWithTwoUint8ArraysFallback =
48- bool (*)(v8::Local<v8::Value>,
49- const v8::FastApiTypedArray<uint8_t >&,
50- const v8::FastApiTypedArray<uint8_t >&,
51- v8::FastApiCallbackOptions&);
52- using CFunctionCallbackWithUint8ArrayUint32Int64Bool =
53- int32_t (*)(v8::Local<v8::Value>,
54- const v8::FastApiTypedArray<uint8_t >&,
55- uint32_t ,
56- int64_t ,
57- bool );
58- using CFunctionWithUint32 = uint32_t (*)(v8::Local<v8::Value>,
59- const uint32_t input);
60- using CFunctionWithReturnUint32 = uint32_t (*)(v8::Local<v8::Value>);
61- using CFunctionWithReturnDouble = double (*)(v8::Local<v8::Value>);
62- using CFunctionWithDoubleReturnDouble = double (*)(v8::Local<v8::Value>,
63- v8::Local<v8::Value>,
64- const double );
65- using CFunctionWithInt64Fallback = void (*)(v8::Local<v8::Value>,
66- v8::Local<v8::Value>,
67- const int64_t ,
68- v8::FastApiCallbackOptions&);
69- using CFunctionWithBool = void (*)(v8::Local<v8::Value>,
70- v8::Local<v8::Value>,
71- bool );
72-
73- using CFunctionWriteString =
74- uint32_t (*)(v8::Local<v8::Value> receiver,
75- const v8::FastApiTypedArray<uint8_t >& dst,
76- const v8::FastOneByteString& src,
77- uint32_t offset,
78- uint32_t max_length);
79-
80- using CFunctionBufferCopy =
81- uint32_t (*)(v8::Local<v8::Value> receiver,
82- const v8::FastApiTypedArray<uint8_t >& source,
83- const v8::FastApiTypedArray<uint8_t >& target,
84- uint32_t target_start,
85- uint32_t source_start,
86- uint32_t to_copy);
87-
8813// This class manages the external references from the V8 heap
8914// to the C++ addresses in Node.js.
9015class ExternalReferenceRegistry {
9116 public:
9217 ExternalReferenceRegistry ();
9318
9419#define ALLOWED_EXTERNAL_REFERENCE_TYPES (V ) \
95- V (CFunctionCallback) \
96- V (CFunctionCallbackWithOneByteString) \
97- V (CFunctionCallbackReturnBool) \
98- V (CFunctionCallbackReturnDouble) \
99- V (CFunctionCallbackReturnInt32) \
100- V (CFunctionWithReturnUint32) \
101- V (CFunctionCallbackValueReturnDouble) \
102- V (CFunctionCallbackValueReturnDoubleUnusedReceiver) \
103- V (CFunctionCallbackWithInt64) \
104- V (CFunctionCallbackWithBool) \
105- V (CFunctionCallbackWithString) \
106- V (CFunctionCallbackWithStrings) \
107- V (CFunctionCallbackWithTwoUint8Arrays) \
108- V (CFunctionCallbackWithTwoUint8ArraysFallback) \
109- V (CFunctionCallbackWithUint8ArrayUint32Int64Bool) \
110- V (CFunctionWithUint32) \
111- V (CFunctionWithDoubleReturnDouble) \
112- V (CFunctionWithInt64Fallback) \
113- V (CFunctionWithBool) \
114- V (CFunctionBufferCopy) \
115- V (CFunctionWriteString) \
116- V (const v8::CFunctionInfo*) \
11720 V (v8::FunctionCallback) \
11821 V (v8::AccessorNameGetterCallback) \
11922 V (v8::AccessorNameSetterCallback) \
@@ -135,6 +38,13 @@ class ExternalReferenceRegistry {
13538 ALLOWED_EXTERNAL_REFERENCE_TYPES (V)
13639#undef V
13740
41+ // Registers both the underlying function pointer
42+ // and the corresponding CFunctionInfo.
43+ void Register (const v8::CFunction& c_func) {
44+ RegisterT (c_func.GetAddress ());
45+ RegisterT (c_func.GetTypeInfo ());
46+ }
47+
13848 // This can be called only once.
13949 const std::vector<intptr_t >& external_references ();
14050
0 commit comments