Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:05:23

0001 // Copyright 2021 the V8 project authors. All rights reserved.
0002 // Use of this source code is governed by a BSD-style license that can be
0003 // found in the LICENSE file.
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 // --- Extensions ---
0019 
0020 /**
0021  * Ignore
0022  */
0023 class V8_EXPORT Extension {
0024  public:
0025   // Note that the strings passed into this constructor must live as long
0026   // as the Extension itself.
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   // Disallow copying and assigning.
0046   Extension(const Extension&) = delete;
0047   void operator=(const Extension&) = delete;
0048 
0049  private:
0050   const char* name_;
0051   size_t source_length_;  // expected to initialize before source_
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 }  // namespace v8
0061 
0062 #endif  // INCLUDE_V8_EXTENSION_H_