| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ff5c6dc commit d0f8af0
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -221,7 +221,7 @@ inline MaybeLocal<Promise> FileHandle::ClosePromise() { | |||
| 221 | 221 | closing_ = true; | |
| 222 | 222 | CloseReq* req = new CloseReq(env(), promise, object()); | |
| 223 | 223 | auto AfterClose = uv_fs_callback_t{[](uv_fs_t* req) { | |
| 224 | - CloseReq* close = static_cast<CloseReq*>(req->data); | ||
| 224 | + CloseReq* close = CloseReq::from_req(req); | ||
| 225 | 225 | CHECK_NOT_NULL(close); | |
| 226 | 226 | close->file_handle()->AfterClose(); | |
| 227 | 227 | Isolate* isolate = close->env()->isolate(); | |
@@ -475,15 +475,15 @@ bool FSReqAfterScope::Proceed() { | |||
| 475 | 475 | } | |
| 476 | 476 | ||
| 477 | 477 | void AfterNoArgs(uv_fs_t* req) { | |
| 478 | - FSReqBase* req_wrap = static_cast<FSReqBase*>(req->data); | ||
| 478 | + FSReqBase* req_wrap = FSReqBase::from_req(req); | ||
| 479 | 479 | FSReqAfterScope after(req_wrap, req); | |
| 480 | 480 | ||
| 481 | 481 | if (after.Proceed()) | |
| 482 | 482 | req_wrap->Resolve(Undefined(req_wrap->env()->isolate())); | |
| 483 | 483 | } | |
| 484 | 484 | ||
| 485 | 485 | void AfterStat(uv_fs_t* req) { | |
| 486 | - FSReqBase* req_wrap = static_cast<FSReqBase*>(req->data); | ||
| 486 | + FSReqBase* req_wrap = FSReqBase::from_req(req); | ||
| 487 | 487 | FSReqAfterScope after(req_wrap, req); | |
| 488 | 488 | ||
| 489 | 489 | if (after.Proceed()) { | |
@@ -492,15 +492,15 @@ void AfterStat(uv_fs_t* req) { | |||
| 492 | 492 | } | |
| 493 | 493 | ||
| 494 | 494 | void AfterInteger(uv_fs_t* req) { | |
| 495 | - FSReqBase* req_wrap = static_cast<FSReqBase*>(req->data); | ||
| 495 | + FSReqBase* req_wrap = FSReqBase::from_req(req); | ||
| 496 | 496 | FSReqAfterScope after(req_wrap, req); | |
| 497 | 497 | ||
| 498 | 498 | if (after.Proceed()) | |
| 499 | 499 | req_wrap->Resolve(Integer::New(req_wrap->env()->isolate(), req->result)); | |
| 500 | 500 | } | |
| 501 | 501 | ||
| 502 | 502 | void AfterOpenFileHandle(uv_fs_t* req) { | |
| 503 | - FSReqWrap* req_wrap = static_cast<FSReqWrap*>(req->data); | ||
| 503 | + FSReqBase* req_wrap = FSReqBase::from_req(req); | ||
| 504 | 504 | FSReqAfterScope after(req_wrap, req); | |
| 505 | 505 | ||
| 506 | 506 | if (after.Proceed()) { | |
@@ -510,7 +510,7 @@ void AfterOpenFileHandle(uv_fs_t* req) { | |||
| 510 | 510 | } | |
| 511 | 511 | ||
| 512 | 512 | void AfterStringPath(uv_fs_t* req) { | |
| 513 | - FSReqBase* req_wrap = static_cast<FSReqBase*>(req->data); | ||
| 513 | + FSReqBase* req_wrap = FSReqBase::from_req(req); | ||
| 514 | 514 | FSReqAfterScope after(req_wrap, req); | |
| 515 | 515 | ||
| 516 | 516 | MaybeLocal<Value> link; | |
@@ -529,7 +529,7 @@ void AfterStringPath(uv_fs_t* req) { | |||
| 529 | 529 | } | |
| 530 | 530 | ||
| 531 | 531 | void AfterStringPtr(uv_fs_t* req) { | |
| 532 | - FSReqBase* req_wrap = static_cast<FSReqBase*>(req->data); | ||
| 532 | + FSReqBase* req_wrap = FSReqBase::from_req(req); | ||
| 533 | 533 | FSReqAfterScope after(req_wrap, req); | |
| 534 | 534 | ||
| 535 | 535 | MaybeLocal<Value> link; | |
@@ -548,7 +548,7 @@ void AfterStringPtr(uv_fs_t* req) { | |||
| 548 | 548 | } | |
| 549 | 549 | ||
| 550 | 550 | void AfterScanDir(uv_fs_t* req) { | |
| 551 | - FSReqBase* req_wrap = static_cast<FSReqBase*>(req->data); | ||
| 551 | + FSReqBase* req_wrap = FSReqBase::from_req(req); | ||
| 552 | 552 | FSReqAfterScope after(req_wrap, req); | |
| 553 | 553 | ||
| 554 | 554 | if (after.Proceed()) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,6 +68,10 @@ class FSReqBase : public ReqWrap<uv_fs_t> { | |||
| 68 | 68 | ||
| 69 | 69 | bool use_bigint() const { return use_bigint_; } | |
| 70 | 70 | ||
| 71 | + static FSReqBase* from_req(uv_fs_t* req) { | ||
| 72 | + return static_cast<FSReqBase*>(ReqWrap::from_req(req)); | ||
| 73 | + } | ||
| 74 | + | ||
| 71 | 75 | private: | |
| 72 | 76 | enum encoding encoding_ = UTF8; | |
| 73 | 77 | bool has_data_ = false; | |
@@ -284,6 +288,10 @@ class FileHandle : public AsyncWrap, public StreamBase { | |||
| 284 | 288 | ||
| 285 | 289 | void Reject(Local<Value> reason); | |
| 286 | 290 | ||
| 291 | + static CloseReq* from_req(uv_fs_t* req) { | ||
| 292 | + return static_cast<CloseReq*>(ReqWrap::from_req(req)); | ||
| 293 | + } | ||
| 294 | + | ||
| 287 | 295 | private: | |
| 288 | 296 | Persistent<Promise> promise_; | |
| 289 | 297 | Persistent<Value> ref_; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments