Cleanup.
This commit is contained in:
parent
e2e1faa225
commit
bdfbef41c6
3 changed files with 2 additions and 42 deletions
|
@ -1,40 +0,0 @@
|
||||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE.chromium file.
|
|
||||||
|
|
||||||
#include "native_mate/constructor.h"
|
|
||||||
|
|
||||||
#include "base/bind.h"
|
|
||||||
#include "base/strings/string_piece.h"
|
|
||||||
#include "native_mate/arguments.h"
|
|
||||||
#include "native_mate/function_template.h"
|
|
||||||
|
|
||||||
namespace mate {
|
|
||||||
|
|
||||||
Constructor::Constructor(const base::StringPiece& name,
|
|
||||||
const WrappableFactoryFunction& factory)
|
|
||||||
: name_(name), factory_(factory) {
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Constructor::~Constructor() {
|
|
||||||
constructor_.Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
v8::Handle<v8::FunctionTemplate> Constructor::GetFunctionTemplate(
|
|
||||||
v8::Isolate* isolate) {
|
|
||||||
if (constructor_.IsEmpty()) {
|
|
||||||
v8::Local<v8::FunctionTemplate> constructor = CreateFunctionTemplate(
|
|
||||||
isolate, base::Bind(&Constructor::New, base::Unretained(this)));
|
|
||||||
constructor->InstanceTemplate()->SetInternalFieldCount(1);
|
|
||||||
constructor->SetClassName(StringToV8(isolate, name_));
|
|
||||||
constructor_.Reset(isolate, constructor);
|
|
||||||
}
|
|
||||||
|
|
||||||
return MATE_PERSISTENT_TO_LOCAL(v8::FunctionTemplate, isolate, constructor_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Constructor::New(mate::Arguments* args) {
|
|
||||||
MATE_SET_INTERNAL_FIELD_POINTER(args->GetThis(), 0, factory_.Run());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace mate
|
|
|
@ -7,9 +7,7 @@
|
||||||
|
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/strings/string_piece.h"
|
|
||||||
#include "native_mate/function_template.h"
|
#include "native_mate/function_template.h"
|
||||||
#include "v8/include/v8.h"
|
|
||||||
|
|
||||||
namespace mate {
|
namespace mate {
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,8 @@ class RefCountedPersistent : public ScopedPersistent<T>,
|
||||||
DISALLOW_COPY_AND_ASSIGN(RefCountedPersistent);
|
DISALLOW_COPY_AND_ASSIGN(RefCountedPersistent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef scoped_refptr<RefCountedPersistent<v8::Object>> RefCountedV8Object;
|
||||||
|
|
||||||
} // namespace mate
|
} // namespace mate
|
||||||
|
|
||||||
#endif // NATIVE_MATE_SCOPED_PERSISTENT_H_
|
#endif // NATIVE_MATE_SCOPED_PERSISTENT_H_
|
||||||
|
|
Loading…
Reference in a new issue