refactor: rename the atom directory to shell
This commit is contained in:
parent
4575a4aae3
commit
d7f07e8a80
631 changed files with 0 additions and 0 deletions
34
shell/common/api/constructor.h
Normal file
34
shell/common/api/constructor.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_COMMON_API_CONSTRUCTOR_H_
|
||||
#define ATOM_COMMON_API_CONSTRUCTOR_H_
|
||||
|
||||
#include "native_mate/constructor.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
// Create a FunctionTemplate that can be "new"ed in JavaScript.
|
||||
// It is user's responsibility to ensure this function is called for one type
|
||||
// only ONCE in the program's whole lifetime, otherwise we would have memory
|
||||
// leak.
|
||||
template <typename T, typename Sig>
|
||||
v8::Local<v8::Function> CreateConstructor(
|
||||
v8::Isolate* isolate,
|
||||
const base::RepeatingCallback<Sig>& func) {
|
||||
#ifndef NDEBUG
|
||||
static bool called = false;
|
||||
CHECK(!called) << "CreateConstructor can only be called for one type once";
|
||||
called = true;
|
||||
#endif
|
||||
v8::Local<v8::FunctionTemplate> templ = CreateFunctionTemplate(
|
||||
isolate, base::BindRepeating(&mate::internal::InvokeNew<Sig>, func));
|
||||
templ->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
T::BuildPrototype(isolate, templ);
|
||||
return templ->GetFunction(isolate->GetCurrentContext()).ToLocalChecked();
|
||||
}
|
||||
|
||||
} // namespace mate
|
||||
|
||||
#endif // ATOM_COMMON_API_CONSTRUCTOR_H_
|
Loading…
Add table
Add a link
Reference in a new issue