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::Object> unused,
24- v8::Local<v8::Object> receiver,
25- const v8::FastOneByteString& input,
26- // NOLINTNEXTLINE(runtime/references) This is V8 api.
27- v8::FastApiCallbackOptions& options);
28- using CFunctionCallbackValueReturnDouble =
29- double (*)(v8::Local<v8::Value> receiver);
30- using CFunctionCallbackValueReturnDoubleUnusedReceiver =
31- double (*)(v8::Local<v8::Value> unused, v8::Local<v8::Value> receiver);
32- using CFunctionCallbackWithInt64 = void (*)(v8::Local<v8::Object> unused,
33- v8::Local<v8::Object> receiver,
34- int64_t );
35- using CFunctionCallbackWithBool = void (*)(v8::Local<v8::Object> unused,
36- v8::Local<v8::Object> receiver,
37- bool );
38- using CFunctionCallbackWithString =
39- bool (*)(v8::Local<v8::Value>, const v8::FastOneByteString& input);
40- using CFunctionCallbackWithStrings =
41- bool (*)(v8::Local<v8::Value>,
42- const v8::FastOneByteString& input,
43- const v8::FastOneByteString& base);
44- using CFunctionCallbackWithTwoUint8Arrays =
45- int32_t (*)(v8::Local<v8::Value>,
46- const v8::FastApiTypedArray<uint8_t >&,
47- const v8::FastApiTypedArray<uint8_t >&);
48- using CFunctionCallbackWithTwoUint8ArraysFallback =
49- bool (*)(v8::Local<v8::Value>,
50- const v8::FastApiTypedArray<uint8_t >&,
51- const v8::FastApiTypedArray<uint8_t >&,
52- v8::FastApiCallbackOptions&);
53- using CFunctionCallbackWithUint8ArrayUint32Int64Bool =
54- int32_t (*)(v8::Local<v8::Value>,
55- const v8::FastApiTypedArray<uint8_t >&,
56- uint32_t ,
57- int64_t ,
58- bool );
59- using CFunctionWithUint32 = uint32_t (*)(v8::Local<v8::Value>,
60- const uint32_t input);
61- using CFunctionWithReturnUint32 = uint32_t (*)(v8::Local<v8::Value>);
62- using CFunctionWithReturnDouble = double (*)(v8::Local<v8::Value>);
63- using CFunctionWithDoubleReturnDouble = double (*)(v8::Local<v8::Value>,
64- v8::Local<v8::Value>,
65- const double );
66- using CFunctionWithInt64Fallback = void (*)(v8::Local<v8::Value>,
67- v8::Local<v8::Value>,
68- const int64_t ,
69- v8::FastApiCallbackOptions&);
70- using CFunctionWithBool = void (*)(v8::Local<v8::Value>,
71- v8::Local<v8::Value>,
72- bool );
73-
74- using CFunctionWriteString =
75- uint32_t (*)(v8::Local<v8::Value> receiver,
76- const v8::FastApiTypedArray<uint8_t >& dst,
77- const v8::FastOneByteString& src,
78- uint32_t offset,
79- uint32_t max_length);
80-
81- using CFunctionBufferCopy =
82- uint32_t (*)(v8::Local<v8::Value> receiver,
83- const v8::FastApiTypedArray<uint8_t >& source,
84- const v8::FastApiTypedArray<uint8_t >& target,
85- uint32_t target_start,
86- uint32_t source_start,
87- uint32_t to_copy);
88-
8913// This class manages the external references from the V8 heap
9014// to the C++ addresses in Node.js.
9115class ExternalReferenceRegistry {
9216 public:
9317 ExternalReferenceRegistry ();
9418
9519#define ALLOWED_EXTERNAL_REFERENCE_TYPES (V ) \
96- V (CFunctionCallback) \
97- V (CFunctionCallbackWithOneByteString) \
98- V (CFunctionCallbackReturnBool) \
99- V (CFunctionCallbackReturnDouble) \
100- V (CFunctionCallbackReturnInt32) \
101- V (CFunctionWithReturnUint32) \
102- V (CFunctionCallbackValueReturnDouble) \
103- V (CFunctionCallbackValueReturnDoubleUnusedReceiver) \
104- V (CFunctionCallbackWithInt64) \
105- V (CFunctionCallbackWithBool) \
106- V (CFunctionCallbackWithString) \
107- V (CFunctionCallbackWithStrings) \
108- V (CFunctionCallbackWithTwoUint8Arrays) \
109- V (CFunctionCallbackWithTwoUint8ArraysFallback) \
110- V (CFunctionCallbackWithUint8ArrayUint32Int64Bool) \
111- V (CFunctionWithUint32) \
112- V (CFunctionWithDoubleReturnDouble) \
113- V (CFunctionWithInt64Fallback) \
114- V (CFunctionWithBool) \
115- V (CFunctionBufferCopy) \
116- V (CFunctionWriteString) \
117- V (const v8::CFunctionInfo*) \
11820 V (v8::FunctionCallback) \
11921 V (v8::AccessorNameGetterCallback) \
12022 V (v8::AccessorNameSetterCallback) \
@@ -136,6 +38,13 @@ class ExternalReferenceRegistry {
13638 ALLOWED_EXTERNAL_REFERENCE_TYPES (V)
13739#undef V
13840
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+
13948 // This can be called only once.
14049 const std::vector<intptr_t >& external_references ();
14150
0 commit comments