1414#include < unordered_map>
1515#include < vector>
1616
17- using v8::Context;
18- using v8::Function;
19- using v8::FunctionCallbackInfo;
20- using v8::FunctionTemplate;
21- using v8::Global;
22- using v8::Isolate;
23- using v8::Local;
24- using v8::Object;
25- using v8::String;
26- using v8::Value;
27- using v8::WeakCallbackInfo;
28-
2917namespace node ::ffi {
3018
3119class DynamicLibrary ;
@@ -37,21 +25,23 @@ bool IsFFINarrowUnsignedInteger(ffi_type* type);
3725
3826bool IsFFINarrowInteger (ffi_type* type);
3927
40- bool HasProperty (Local<Context> context,
41- Local<Object> object,
42- Local<String> key,
28+ bool HasProperty (v8:: Local<v8:: Context> context,
29+ v8:: Local<v8:: Object> object,
30+ v8:: Local<v8:: String> key,
4331 bool * out);
4432
45- bool GetStrictSignedInteger (Local<Value> value,
33+ bool GetStrictSignedInteger (v8:: Local<v8:: Value> value,
4634 int64_t min,
4735 int64_t max,
4836 int64_t * out);
4937
50- bool GetStrictUnsignedInteger (Local<Value> value, uint64_t max, uint64_t * out);
38+ bool GetStrictUnsignedInteger (v8::Local<v8::Value> value,
39+ uint64_t max,
40+ uint64_t * out);
5141
5242bool ParseFunctionSignature (Environment* env,
5343 const std::string& name,
54- Local<Object> signature,
44+ v8:: Local<v8:: Object> signature,
5545 ffi_type** return_type,
5646 std::vector<ffi_type*>* args);
5747
@@ -64,59 +54,63 @@ bool ToFFIType(Environment* env, const std::string& type_str, ffi_type** ret);
6454uint8_t ToFFIArgument (Environment* env,
6555 unsigned int index,
6656 ffi_type* type,
67- Local<Value> arg,
57+ v8:: Local<v8:: Value> arg,
6858 void * ret);
6959
70- Local<Value> ToJSArgument (Isolate* isolate, ffi_type* type, void * data);
60+ v8::Local<v8::Value> ToJSArgument (v8::Isolate* isolate,
61+ ffi_type* type,
62+ void * data);
7163
7264bool ToJSReturnValue (Environment* env,
73- const FunctionCallbackInfo<Value>& args,
65+ const v8:: FunctionCallbackInfo<v8:: Value>& args,
7466 ffi_type* type,
7567 void * result);
7668
77- bool ToFFIReturnValue (Local<Value> result, ffi_type* type, void * ret);
69+ bool ToFFIReturnValue (v8:: Local<v8:: Value> result, ffi_type* type, void * ret);
7870
7971size_t GetFFIReturnValueStorageSize (ffi_type* type);
8072
8173bool GetValidatedSize (Environment* env,
82- Local<Value> value,
74+ v8:: Local<v8:: Value> value,
8375 const char * label,
8476 size_t * out);
8577
8678bool GetValidatedPointerAddress (Environment* env,
87- Local<Value> value,
79+ v8:: Local<v8:: Value> value,
8880 const char * label,
8981 uintptr_t * out);
9082
9183bool GetValidatedSignedInt (Environment* env,
92- Local<Value> value,
84+ v8:: Local<v8:: Value> value,
9385 int64_t min,
9486 int64_t max,
9587 const char * type_name,
9688 int64_t * out);
9789
9890bool GetValidatedUnsignedInt (Environment* env,
99- Local<Value> value,
91+ v8:: Local<v8:: Value> value,
10092 uint64_t max,
10193 const char * type_name,
10294 uint64_t * out);
10395
104- bool GetValidatedPointerAndOffset (Environment* env,
105- const FunctionCallbackInfo<Value>& args,
106- uint8_t ** ptr,
107- size_t * offset);
96+ bool GetValidatedPointerAndOffset (
97+ Environment* env,
98+ const v8::FunctionCallbackInfo<v8::Value>& args,
99+ uint8_t ** ptr,
100+ size_t * offset);
108101
109- bool GetValidatedPointerValueAndOffset (Environment* env,
110- const FunctionCallbackInfo<Value>& args,
111- uint8_t ** ptr,
112- Local<Value>* value,
113- size_t * offset);
102+ bool GetValidatedPointerValueAndOffset (
103+ Environment* env,
104+ const v8::FunctionCallbackInfo<v8::Value>& args,
105+ uint8_t ** ptr,
106+ v8::Local<v8::Value>* value,
107+ size_t * offset);
114108
115109template <typename T>
116- void GetValue (const FunctionCallbackInfo<Value>& args);
110+ void GetValue (const v8:: FunctionCallbackInfo<v8:: Value>& args);
117111
118112template <typename T>
119- void SetValue (const FunctionCallbackInfo<Value>& args);
113+ void SetValue (const v8:: FunctionCallbackInfo<v8:: Value>& args);
120114
121115struct FFIFunction {
122116 bool closed;
@@ -129,14 +123,14 @@ struct FFIFunction {
129123
130124struct FFIFunctionInfo {
131125 std::shared_ptr<FFIFunction> fn;
132- Global<Function> self;
126+ v8:: Global<v8:: Function> self;
133127};
134128
135129struct FFICallback {
136130 DynamicLibrary* owner;
137131 Environment* env;
138132 std::thread::id thread_id;
139- Global<Function> fn;
133+ v8:: Global<v8:: Function> fn;
140134 ffi_closure* closure;
141135
142136 void * ptr;
@@ -158,30 +152,32 @@ struct FFICallback {
158152
159153class DynamicLibrary : public BaseObject {
160154 public:
161- DynamicLibrary (Environment* env, Local<Object> object);
155+ DynamicLibrary (Environment* env, v8:: Local<v8:: Object> object);
162156 ~DynamicLibrary () override ;
163157
164158 void MemoryInfo (MemoryTracker* tracker) const override ;
165159
166- static Local<FunctionTemplate> GetConstructorTemplate (Environment* env);
167- static void New (const FunctionCallbackInfo<Value>& args);
168- static void Close (const FunctionCallbackInfo<Value>& args);
169- static void InvokeFunction (const FunctionCallbackInfo<Value>& args);
160+ static v8::Local<v8::FunctionTemplate> GetConstructorTemplate (
161+ Environment* env);
162+ static void New (const v8::FunctionCallbackInfo<v8::Value>& args);
163+ static void Close (const v8::FunctionCallbackInfo<v8::Value>& args);
164+ static void InvokeFunction (const v8::FunctionCallbackInfo<v8::Value>& args);
170165 static void InvokeCallback (ffi_cif* cif,
171166 void * ret,
172167 void ** args,
173168 void * user_data);
174169
175- static void GetPath (const FunctionCallbackInfo<Value>& args);
176- static void GetFunction (const FunctionCallbackInfo<Value>& args);
177- static void GetFunctions (const FunctionCallbackInfo<Value>& args);
178- static void GetSymbol (const FunctionCallbackInfo<Value>& args);
179- static void GetSymbols (const FunctionCallbackInfo<Value>& args);
170+ static void GetPath (const v8:: FunctionCallbackInfo<v8:: Value>& args);
171+ static void GetFunction (const v8:: FunctionCallbackInfo<v8:: Value>& args);
172+ static void GetFunctions (const v8:: FunctionCallbackInfo<v8:: Value>& args);
173+ static void GetSymbol (const v8:: FunctionCallbackInfo<v8:: Value>& args);
174+ static void GetSymbols (const v8:: FunctionCallbackInfo<v8:: Value>& args);
180175
181- static void RegisterCallback (const FunctionCallbackInfo<Value>& args);
182- static void UnregisterCallback (const FunctionCallbackInfo<Value>& args);
183- static void RefCallback (const FunctionCallbackInfo<Value>& args);
184- static void UnrefCallback (const FunctionCallbackInfo<Value>& args);
176+ static void RegisterCallback (const v8::FunctionCallbackInfo<v8::Value>& args);
177+ static void UnregisterCallback (
178+ const v8::FunctionCallbackInfo<v8::Value>& args);
179+ static void RefCallback (const v8::FunctionCallbackInfo<v8::Value>& args);
180+ static void UnrefCallback (const v8::FunctionCallbackInfo<v8::Value>& args);
185181
186182 SET_MEMORY_INFO_NAME (DynamicLibrary)
187183 SET_SELF_SIZE (DynamicLibrary)
@@ -193,13 +189,14 @@ class DynamicLibrary : public BaseObject {
193189 void ** ptr);
194190 bool FindOrCreateFunction (Environment* env,
195191 const std::string& name,
196- Local<Object> signature,
192+ v8:: Local<v8:: Object> signature,
197193 std::shared_ptr<FFIFunction>* ret);
198- Local<Function> CreateFunction (Environment* env,
199- const std::string& name,
200- const std::shared_ptr<FFIFunction>& fn);
194+ v8::Local<v8::Function> CreateFunction (
195+ Environment* env,
196+ const std::string& name,
197+ const std::shared_ptr<FFIFunction>& fn);
201198 static void CleanupFunctionInfo (
202- const WeakCallbackInfo<FFIFunctionInfo>& data);
199+ const v8:: WeakCallbackInfo<FFIFunctionInfo>& data);
203200
204201 uv_lib_t lib_;
205202 void * handle_;
@@ -209,31 +206,31 @@ class DynamicLibrary : public BaseObject {
209206 std::unordered_map<void *, std::unique_ptr<FFICallback>> callbacks_;
210207};
211208
212- void GetInt8 (const FunctionCallbackInfo<Value>& args);
213- void GetUint8 (const FunctionCallbackInfo<Value>& args);
214- void GetInt16 (const FunctionCallbackInfo<Value>& args);
215- void GetUint16 (const FunctionCallbackInfo<Value>& args);
216- void GetInt32 (const FunctionCallbackInfo<Value>& args);
217- void GetUint32 (const FunctionCallbackInfo<Value>& args);
218- void GetInt64 (const FunctionCallbackInfo<Value>& args);
219- void GetUint64 (const FunctionCallbackInfo<Value>& args);
220- void GetFloat32 (const FunctionCallbackInfo<Value>& args);
221- void GetFloat64 (const FunctionCallbackInfo<Value>& args);
222-
223- void SetInt8 (const FunctionCallbackInfo<Value>& args);
224- void SetUint8 (const FunctionCallbackInfo<Value>& args);
225- void SetInt16 (const FunctionCallbackInfo<Value>& args);
226- void SetUint16 (const FunctionCallbackInfo<Value>& args);
227- void SetInt32 (const FunctionCallbackInfo<Value>& args);
228- void SetUint32 (const FunctionCallbackInfo<Value>& args);
229- void SetInt64 (const FunctionCallbackInfo<Value>& args);
230- void SetUint64 (const FunctionCallbackInfo<Value>& args);
231- void SetFloat32 (const FunctionCallbackInfo<Value>& args);
232- void SetFloat64 (const FunctionCallbackInfo<Value>& args);
233-
234- void ToString (const FunctionCallbackInfo<Value>& args);
235- void ToBuffer (const FunctionCallbackInfo<Value>& args);
236- void ToArrayBuffer (const FunctionCallbackInfo<Value>& args);
209+ void GetInt8 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
210+ void GetUint8 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
211+ void GetInt16 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
212+ void GetUint16 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
213+ void GetInt32 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
214+ void GetUint32 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
215+ void GetInt64 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
216+ void GetUint64 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
217+ void GetFloat32 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
218+ void GetFloat64 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
219+
220+ void SetInt8 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
221+ void SetUint8 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
222+ void SetInt16 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
223+ void SetUint16 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
224+ void SetInt32 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
225+ void SetUint32 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
226+ void SetInt64 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
227+ void SetUint64 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
228+ void SetFloat32 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
229+ void SetFloat64 (const v8:: FunctionCallbackInfo<v8:: Value>& args);
230+
231+ void ToString (const v8:: FunctionCallbackInfo<v8:: Value>& args);
232+ void ToBuffer (const v8:: FunctionCallbackInfo<v8:: Value>& args);
233+ void ToArrayBuffer (const v8:: FunctionCallbackInfo<v8:: Value>& args);
237234
238235} // namespace node::ffi
239236
0 commit comments