gc-extension.h 1.03 KB
Newer Older
1
// Copyright 2010 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4 5 6 7

#ifndef V8_EXTENSIONS_GC_EXTENSION_H_
#define V8_EXTENSIONS_GC_EXTENSION_H_

8 9
#include "include/v8.h"
#include "src/utils.h"
10 11 12 13 14 15

namespace v8 {
namespace internal {

class GCExtension : public v8::Extension {
 public:
16 17 18
  explicit GCExtension(const char* fun_name)
      : v8::Extension("v8/gc",
                      BuildSource(buffer_, sizeof(buffer_), fun_name)) {}
19 20
  virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
      v8::Isolate* isolate, v8::Local<v8::String> name);
21
  static void GC(const v8::FunctionCallbackInfo<v8::Value>& args);
22 23 24

 private:
  static const char* BuildSource(char* buf, size_t size, const char* fun_name) {
25 26
    SNPrintF(Vector<char>(buf, static_cast<int>(size)),
             "native function %s();", fun_name);
27 28 29 30
    return buf;
  }

  char buffer_[50];
31 32
};

33 34
}  // namespace internal
}  // namespace v8
35 36

#endif  // V8_EXTENSIONS_GC_EXTENSION_H_