| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -247,78 +247,78 @@ void ClearFatalExceptionHandlers(Environment* env); | |||
| 247 | 247 | enum NodeInstanceType { MAIN, WORKER }; | |
| 248 | 248 | ||
| 249 | 249 | class NodeInstanceData { | |
| 250 | - public: | ||
| 251 | - NodeInstanceData(NodeInstanceType node_instance_type, | ||
| 252 | - uv_loop_t* event_loop, | ||
| 253 | - int argc, | ||
| 254 | - const char** argv, | ||
| 255 | - int exec_argc, | ||
| 256 | - const char** exec_argv, | ||
| 257 | - bool use_debug_agent_flag) | ||
| 258 | - : node_instance_type_(node_instance_type), | ||
| 259 | - exit_code_(1), | ||
| 260 | - event_loop_(event_loop), | ||
| 261 | - argc_(argc), | ||
| 262 | - argv_(argv), | ||
| 263 | - exec_argc_(exec_argc), | ||
| 264 | - exec_argv_(exec_argv), | ||
| 265 | - use_debug_agent_flag_(use_debug_agent_flag) { | ||
| 266 | - CHECK_NE(event_loop_, nullptr); | ||
| 267 | - } | ||
| 268 | - | ||
| 269 | - uv_loop_t* event_loop() const { | ||
| 270 | - return event_loop_; | ||
| 271 | - } | ||
| 272 | - | ||
| 273 | - int exit_code() { | ||
| 274 | - CHECK(is_main()); | ||
| 275 | - return exit_code_; | ||
| 276 | - } | ||
| 277 | - | ||
| 278 | - void set_exit_code(int exit_code) { | ||
| 279 | - CHECK(is_main()); | ||
| 280 | - exit_code_ = exit_code; | ||
| 281 | - } | ||
| 282 | - | ||
| 283 | - bool is_main() { | ||
| 284 | - return node_instance_type_ == MAIN; | ||
| 285 | - } | ||
| 286 | - | ||
| 287 | - bool is_worker() { | ||
| 288 | - return node_instance_type_ == WORKER; | ||
| 289 | - } | ||
| 290 | - | ||
| 291 | - int argc() { | ||
| 292 | - return argc_; | ||
| 293 | - } | ||
| 294 | - | ||
| 295 | - const char** argv() { | ||
| 296 | - return argv_; | ||
| 297 | - } | ||
| 298 | - | ||
| 299 | - int exec_argc() { | ||
| 300 | - return exec_argc_; | ||
| 301 | - } | ||
| 302 | - | ||
| 303 | - const char** exec_argv() { | ||
| 304 | - return exec_argv_; | ||
| 305 | - } | ||
| 306 | - | ||
| 307 | - bool use_debug_agent() { | ||
| 308 | - return is_main() && use_debug_agent_flag_; | ||
| 309 | - } | ||
| 310 | - | ||
| 311 | - private: | ||
| 312 | - const NodeInstanceType node_instance_type_; | ||
| 313 | - int exit_code_; | ||
| 314 | - uv_loop_t* const event_loop_; | ||
| 315 | - const int argc_; | ||
| 316 | - const char** argv_; | ||
| 317 | - const int exec_argc_; | ||
| 318 | - const char** exec_argv_; | ||
| 319 | - const bool use_debug_agent_flag_; | ||
| 320 | - | ||
| 321 | - DISALLOW_COPY_AND_ASSIGN(NodeInstanceData); | ||
| 250 | + public: | ||
| 251 | + NodeInstanceData(NodeInstanceType node_instance_type, | ||
| 252 | + uv_loop_t* event_loop, | ||
| 253 | + int argc, | ||
| 254 | + const char** argv, | ||
| 255 | + int exec_argc, | ||
| 256 | + const char** exec_argv, | ||
| 257 | + bool use_debug_agent_flag) | ||
| 258 | + : node_instance_type_(node_instance_type), | ||
| 259 | + exit_code_(1), | ||
| 260 | + event_loop_(event_loop), | ||
| 261 | + argc_(argc), | ||
| 262 | + argv_(argv), | ||
| 263 | + exec_argc_(exec_argc), | ||
| 264 | + exec_argv_(exec_argv), | ||
| 265 | + use_debug_agent_flag_(use_debug_agent_flag) { | ||
| 266 | + CHECK_NE(event_loop_, nullptr); | ||
| 267 | + } | ||
| 268 | + | ||
| 269 | + uv_loop_t* event_loop() const { | ||
| 270 | + return event_loop_; | ||
| 271 | + } | ||
| 272 | + | ||
| 273 | + int exit_code() { | ||
| 274 | + CHECK(is_main()); | ||
| 275 | + return exit_code_; | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + void set_exit_code(int exit_code) { | ||
| 279 | + CHECK(is_main()); | ||
| 280 | + exit_code_ = exit_code; | ||
| 281 | + } | ||
| 282 | + | ||
| 283 | + bool is_main() { | ||
| 284 | + return node_instance_type_ == MAIN; | ||
| 285 | + } | ||
| 286 | + | ||
| 287 | + bool is_worker() { | ||
| 288 | + return node_instance_type_ == WORKER; | ||
| 289 | + } | ||
| 290 | + | ||
| 291 | + int argc() { | ||
| 292 | + return argc_; | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | + const char** argv() { | ||
| 296 | + return argv_; | ||
| 297 | + } | ||
| 298 | + | ||
| 299 | + int exec_argc() { | ||
| 300 | + return exec_argc_; | ||
| 301 | + } | ||
| 302 | + | ||
| 303 | + const char** exec_argv() { | ||
| 304 | + return exec_argv_; | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + bool use_debug_agent() { | ||
| 308 | + return is_main() && use_debug_agent_flag_; | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + private: | ||
| 312 | + const NodeInstanceType node_instance_type_; | ||
| 313 | + int exit_code_; | ||
| 314 | + uv_loop_t* const event_loop_; | ||
| 315 | + const int argc_; | ||
| 316 | + const char** argv_; | ||
| 317 | + const int exec_argc_; | ||
| 318 | + const char** exec_argv_; | ||
| 319 | + const bool use_debug_agent_flag_; | ||
| 320 | + | ||
| 321 | + DISALLOW_COPY_AND_ASSIGN(NodeInstanceData); | ||
| 322 | 322 | }; | |
| 323 | 323 | ||
| 324 | 324 | namespace Buffer { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,75 +27,75 @@ using v8::MaybeLocal; | |||
| 27 | 27 | ||
| 28 | 28 | template <typename ResourceType, typename TypeName> | |
| 29 | 29 | class ExternString: public ResourceType { | |
| 30 | - public: | ||
| 31 | - ~ExternString() override { | ||
| 32 | - free(const_cast<TypeName*>(data_)); | ||
| 33 | - isolate()->AdjustAmountOfExternalAllocatedMemory(-byte_length()); | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - const TypeName* data() const override { | ||
| 37 | - return data_; | ||
| 38 | - } | ||
| 30 | + public: | ||
| 31 | + ~ExternString() override { | ||
| 32 | + free(const_cast<TypeName*>(data_)); | ||
| 33 | + isolate()->AdjustAmountOfExternalAllocatedMemory(-byte_length()); | ||
| 34 | + } | ||
| 39 | 35 | ||
| 40 | - size_t length() const override { | ||
| 41 | - return length_; | ||
| 42 | - } | ||
| 36 | + const TypeName* data() const override { | ||
| 37 | + return data_; | ||
| 38 | + } | ||
| 43 | 39 | ||
| 44 | - int64_t byte_length() const { | ||
| 45 | - return length() * sizeof(*data()); | ||
| 46 | - } | ||
| 40 | + size_t length() const override { | ||
| 41 | + return length_; | ||
| 42 | + } | ||
| 47 | 43 | ||
| 48 | - static Local<String> NewFromCopy(Isolate* isolate, | ||
| 49 | - const TypeName* data, | ||
| 50 | - size_t length) { | ||
| 51 | - EscapableHandleScope scope(isolate); | ||
| 44 | + int64_t byte_length() const { | ||
| 45 | + return length() * sizeof(*data()); | ||
| 46 | + } | ||
| 52 | 47 | ||
| 53 | - if (length == 0) | ||
| 54 | - return scope.Escape(String::Empty(isolate)); | ||
| 48 | + static Local<String> NewFromCopy(Isolate* isolate, | ||
| 49 | + const TypeName* data, | ||
| 50 | + size_t length) { | ||
| 51 | + EscapableHandleScope scope(isolate); | ||
| 55 | 52 | ||
| 56 | - TypeName* new_data = | ||
| 57 | - static_cast<TypeName*>(malloc(length * sizeof(*new_data))); | ||
| 58 | - if (new_data == nullptr) { | ||
| 59 | - return Local<String>(); | ||
| 60 | - } | ||
| 61 | - memcpy(new_data, data, length * sizeof(*new_data)); | ||
| 53 | + if (length == 0) | ||
| 54 | + return scope.Escape(String::Empty(isolate)); | ||
| 62 | 55 | ||
| 63 | - return scope.Escape(ExternString<ResourceType, TypeName>::New(isolate, | ||
| 64 | - new_data, | ||
| 65 | - length)); | ||
| 56 | + TypeName* new_data = | ||
| 57 | + static_cast<TypeName*>(malloc(length * sizeof(*new_data))); | ||
| 58 | + if (new_data == nullptr) { | ||
| 59 | + return Local<String>(); | ||
| 66 | 60 | } | |
| 61 | + memcpy(new_data, data, length * sizeof(*new_data)); | ||
| 67 | 62 | ||
| 68 | - // uses "data" for external resource, and will be free'd on gc | ||
| 69 | - static Local<String> New(Isolate* isolate, | ||
| 70 | - const TypeName* data, | ||
| 71 | - size_t length) { | ||
| 72 | - EscapableHandleScope scope(isolate); | ||
| 63 | + return scope.Escape(ExternString<ResourceType, TypeName>::New(isolate, | ||
| 64 | + new_data, | ||
| 65 | + length)); | ||
| 66 | + } | ||
| 73 | 67 | ||
| 74 | - if (length == 0) | ||
| 75 | - return scope.Escape(String::Empty(isolate)); | ||
| 68 | + // uses "data" for external resource, and will be free'd on gc | ||
| 69 | + static Local<String> New(Isolate* isolate, | ||
| 70 | + const TypeName* data, | ||
| 71 | + size_t length) { | ||
| 72 | + EscapableHandleScope scope(isolate); | ||
| 73 | + if (length == 0) | ||
| 74 | + return scope.Escape(String::Empty(isolate)); | ||
| 76 | 75 | ||
| 77 | - ExternString* h_str = new ExternString<ResourceType, TypeName>(isolate, | ||
| 78 | - data, | ||
| 79 | - length); | ||
| 80 | - MaybeLocal<String> str = String::NewExternal(isolate, h_str); | ||
| 81 | - isolate->AdjustAmountOfExternalAllocatedMemory(h_str->byte_length()); | ||
| 76 | + ExternString* h_str = new ExternString<ResourceType, TypeName>(isolate, | ||
| 77 | + data, | ||
| 78 | + length); | ||
| 79 | + MaybeLocal<String> str = String::NewExternal(isolate, h_str); | ||
| 80 | + isolate->AdjustAmountOfExternalAllocatedMemory(h_str->byte_length()); | ||
| 82 | 81 | ||
| 83 | - if (str.IsEmpty()) { | ||
| 84 | - delete h_str; | ||
| 85 | - return Local<String>(); | ||
| 86 | - } | ||
| 87 | 82 | ||
| 88 | - return scope.Escape(str.ToLocalChecked()); | ||
| 83 | + if (str.IsEmpty()) { | ||
| 84 | + delete h_str; | ||
| 85 | + return Local<String>(); | ||
| 89 | 86 | } | |
| 90 | 87 | ||
| 91 | - inline Isolate* isolate() const { return isolate_; } | ||
| 88 | + return scope.Escape(str.ToLocalChecked()); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + inline Isolate* isolate() const { return isolate_; } | ||
| 92 | 92 | ||
| 93 | - private: | ||
| 94 | - ExternString(Isolate* isolate, const TypeName* data, size_t length) | ||
| 95 | - : isolate_(isolate), data_(data), length_(length) { } | ||
| 96 | - Isolate* isolate_; | ||
| 97 | - const TypeName* data_; | ||
| 98 | - size_t length_; | ||
| 93 | + private: | ||
| 94 | + ExternString(Isolate* isolate, const TypeName* data, size_t length) | ||
| 95 | + : isolate_(isolate), data_(data), length_(length) { } | ||
| 96 | + Isolate* isolate_; | ||
| 97 | + const TypeName* data_; | ||
| 98 | + size_t length_; | ||
| 99 | 99 | }; | |
| 100 | 100 | ||
| 101 | 101 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments