Closed
Bug 779347
Opened 12 years ago
Closed 12 years ago
wrap OpenFile and ReadCompleteFile in a nice RAII interface
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla17
People
(Reporter: Benjamin, Assigned: Benjamin)
Details
Attachments
(1 file)
3.64 KB,
patch
|
jimb
:
review+
|
Details | Diff | Splinter Review |
(Bug 779038 followup) This patch provides a class that automatically handles the closing (or not closing of stdin) of FILE* jsapi creates.
Assignee | ||
Comment 1•12 years ago
|
||
Assignee: general → bpeterson
Attachment #647749 -
Flags: review?(jimb)
Comment 2•12 years ago
|
||
Comment on attachment 647749 [details] [diff] [review] add FileWrapper Review of attachment 647749 [details] [diff] [review]: ----------------------------------------------------------------- Hurrah! Some comments; see what you think. ::: js/src/jsapi.cpp @@ +5057,5 @@ > > return true; > } > > +class FileWrapper It's my impression that classes intended mostly to guarantee cleanup from some local scope get names beginning with "Auto". @@ +5085,5 @@ > * Open a source file for reading. Supports "-" and NULL to mean stdin. The > * return value must be fclosed unless it is stdin. > */ > +static bool > +OpenFile(JSContext *cx, const char *filename, FileWrapper &fw) I think OpenFile would work nicely as a member function of FileWrapper. @@ +5669,5 @@ > + { > + FileWrapper fw; > + if (!OpenFile(cx, filename, fw)) > + return NULL; > + bool ok = fw.readAll(cx, buffer); There's no need for 'ok' any more, since the fclose is gone.
Attachment #647749 -
Flags: review?(jimb) → review+
Assignee | ||
Comment 3•12 years ago
|
||
I - zapped ok - renamed FileWrapper -> AutoFile - OpenFile -> AutoFile::open https://hg.mozilla.org/integration/mozilla-inbound/rev/162b401d8774
Comment 4•12 years ago
|
||
Yeah, that's the stuff.
Comment 5•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/162b401d8774
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in
before you can comment on or make changes to this bug.
Description
•