File indexing completed on 2025-02-21 10:05:23
0001
0002
0003
0004
0005 #ifndef INCLUDE_V8_EXTENSION_H_
0006 #define INCLUDE_V8_EXTENSION_H_
0007
0008 #include <memory>
0009
0010 #include "v8-local-handle.h" // NOLINT(build/include_directory)
0011 #include "v8-primitive.h" // NOLINT(build/include_directory)
0012 #include "v8config.h" // NOLINT(build/include_directory)
0013
0014 namespace v8 {
0015
0016 class FunctionTemplate;
0017
0018
0019
0020
0021
0022
0023 class V8_EXPORT Extension {
0024 public:
0025
0026
0027 Extension(const char* name, const char* source = nullptr, int dep_count = 0,
0028 const char** deps = nullptr, int source_length = -1);
0029 virtual ~Extension() { delete source_; }
0030 virtual Local<FunctionTemplate> GetNativeFunctionTemplate(
0031 Isolate* isolate, Local<String> name) {
0032 return Local<FunctionTemplate>();
0033 }
0034
0035 const char* name() const { return name_; }
0036 size_t source_length() const { return source_length_; }
0037 const String::ExternalOneByteStringResource* source() const {
0038 return source_;
0039 }
0040 int dependency_count() const { return dep_count_; }
0041 const char** dependencies() const { return deps_; }
0042 void set_auto_enable(bool value) { auto_enable_ = value; }
0043 bool auto_enable() { return auto_enable_; }
0044
0045
0046 Extension(const Extension&) = delete;
0047 void operator=(const Extension&) = delete;
0048
0049 private:
0050 const char* name_;
0051 size_t source_length_;
0052 String::ExternalOneByteStringResource* source_;
0053 int dep_count_;
0054 const char** deps_;
0055 bool auto_enable_;
0056 };
0057
0058 void V8_EXPORT RegisterExtension(std::unique_ptr<Extension>);
0059
0060 }
0061
0062 #endif