Skip to content

Commit

Permalink
Add file create function
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiltd committed Jan 9, 2025
1 parent 0a65a1e commit aec58c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions builtins/web/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ bool File::init(JSContext *cx, HandleObject self, HandleValue fileBits, HandleVa
return true;
}

JSObject* File::create(JSContext *cx, HandleValue fileBits, HandleValue fileName, HandleValue opts) {
RootedObject self(cx, JS_NewObjectWithGivenProto(cx, &class_, proto_obj));
if (!self) {
return nullptr;
}

if (!init(cx, self, fileBits, fileName, opts)) {
return nullptr;
}

return self;
}

bool File::constructor(JSContext *cx, unsigned argc, JS::Value *vp) {
CTOR_HEADER("File", 2);

Expand Down
1 change: 1 addition & 0 deletions builtins/web/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class File : public BuiltinImpl<File> {
static const JSFunctionSpec methods[];
static const JSPropertySpec properties[];

static JSObject *create(JSContext *cx, HandleValue fileBits, HandleValue fileName, HandleValue opts);
static bool init(JSContext *cx, HandleObject self, HandleValue fileBits, HandleValue fileName, HandleValue opts);
static bool init_class(JSContext *cx, HandleObject global);
static bool constructor(JSContext *cx, unsigned argc, Value *vp);
Expand Down

0 comments on commit aec58c4

Please sign in to comment.