⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 v8.h.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
 * Ignore */class EXPORT DeclareExtension { public:  inline DeclareExtension(Extension* extension) {    RegisterExtension(extension);  }};// --- S t a t i c s ---Handle<Primitive> EXPORT Undefined();Handle<Primitive> EXPORT Null();Handle<Boolean> EXPORT True();Handle<Boolean> EXPORT False();/** * A set of constraints that specifies the limits of the runtime's * memory use. */class EXPORT ResourceConstraints { public:  ResourceConstraints();  int max_young_space_size() { return max_young_space_size_; }  void set_max_young_space_size(int value) { max_young_space_size_ = value; }  int max_old_space_size() { return max_old_space_size_; }  void set_max_old_space_size(int value) { max_old_space_size_ = value; }  uint32_t* stack_limit() { return stack_limit_; }  void set_stack_limit(uint32_t* value) { stack_limit_ = value; } private:  int max_young_space_size_;  int max_old_space_size_;  uint32_t* stack_limit_;};bool SetResourceConstraints(ResourceConstraints* constraints);// --- E x c e p t i o n s ---typedef void (*FatalErrorCallback)(const char* location, const char* message);typedef void (*MessageCallback)(Handle<Message> message, Handle<Value> data);/** * Schedules an exception to be thrown when returning to JavaScript.  When an * exception has been scheduled it is illegal to invoke any JavaScript * operation; the caller must return immediately and only after the exception * has been handled does it become legal to invoke JavaScript operations. */Handle<Value> EXPORT ThrowException(Handle<Value> exception);/** * Create new error objects by calling the corresponding error object * constructor with the message. */class EXPORT Exception { public:  static Local<Value> RangeError(Handle<String> message);  static Local<Value> ReferenceError(Handle<String> message);  static Local<Value> SyntaxError(Handle<String> message);  static Local<Value> TypeError(Handle<String> message);  static Local<Value> Error(Handle<String> message);};// --- C o u n t e r s  C a l l b a c k stypedef int* (*CounterLookupCallback)(const wchar_t* name);// --- F a i l e d A c c e s s C h e c k C a l l b a c k ---typedef void (*FailedAccessCheckCallback)(Local<Object> target,                                          AccessType type,                                          Local<Value> data);// --- G a r b a g e C o l l e c t i o n  C a l l b a c k s/** * Applications can register a callback function which is called * before and after a major garbage collection.  Allocations are not * allowed in the callback function, you therefore cannot manipulate * objects (set or delete properties for example) since it is possible * such operations will result in the allocation of objects. */typedef void (*GCCallback)();//  --- C o n t e x t  G e n e r a t o r/** * Applications must provide a callback function which is called to generate * a context if a context was not deserialized from the snapshot. */typedef Persistent<Context> (*ContextGenerator)();/** * Container class for static utility functions. */class EXPORT V8 { public:  /** Set the callback to invoke in case of fatal errors. */  static void SetFatalErrorHandler(FatalErrorCallback that);  /**   * Ignore out-of-memory exceptions.   *   * V8 running out of memory is treated as a fatal error by default.   * This means that the fatal error handler is called and that V8 is   * terminated.   *   * IgnoreOutOfMemoryException can be used to not treat a   * out-of-memory situation as a fatal error.  This way, the contexts   * that did not cause the out of memory problem might be able to   * continue execution.   */  static void IgnoreOutOfMemoryException();  /**   * Check if V8 is dead and therefore unusable.  This is the case after   * fatal errors such as out-of-memory situations.   */  static bool IsDead();  /**   * Adds a message listener.   *   * The same message listener can be added more than once and it that   * case it will be called more than once for each message.   */  static bool AddMessageListener(MessageCallback that,                                 Handle<Value> data = Handle<Value>());  /**   * Remove all message listeners from the specified callback function.   */  static void RemoveMessageListeners(MessageCallback that);  /**   * Sets V8 flags from a string.   */  static void SetFlagsFromString(const char* str, int length);  /**   * Sets V8 flags from the command line.   */  static void SetFlagsFromCommandLine(int* argc,                                      char** argv,                                      bool remove_flags);  /** Get the version string. */  static const char* GetVersion();  /**   * Enables the host application to provide a mechanism for recording   * statistics counters.   */  static void SetCounterFunction(CounterLookupCallback);  /**   * Enables the computation of a sliding window of states. The sliding   * window information is recorded in statistics counters.   */  static void EnableSlidingStateWindow();  /** Callback function for reporting failed access checks.*/  static void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback);  /**   * Enables the host application to receive a notification before a   * major garbage colletion.  Allocations are not allowed in the   * callback function, you therefore cannot manipulate objects (set   * or delete properties for example) since it is possible such   * operations will result in the allocation of objects.   */  static void SetGlobalGCPrologueCallback(GCCallback);  /**   * Enables the host application to receive a notification after a   * major garbage collection.  Allocations are not allowed in the   * callback function, you therefore cannot manipulate objects (set   * or delete properties for example) since it is possible such   * operations will result in the allocation of objects.   */  static void SetGlobalGCEpilogueCallback(GCCallback);  /**   * Allows the host application to group objects together. If one   * object in the group is alive, all objects in the group are alive.   * After each garbage collection, object groups are removed. It is   * intended to be used in the before-garbage-collection callback   * function for istance to simulate DOM tree connections among JS   * wrapper objects.   */  static void AddObjectToGroup(void* id, Persistent<Object> obj);  /**   * Initializes from snapshot if possible. Otherwise, attempts to   * initialize from scratch.   */  static bool Initialize();  /**   * Adjusts the amount of registered external memory.  Used to give   * V8 an indication of the amount of externally allocated memory   * that is kept alive by JavaScript objects.  V8 uses this to decide   * when to perform global garbage collections.  Registering   * externally allocated memory will trigger global garbage   * collections more often than otherwise in an attempt to garbage   * collect the JavaScript objects keeping the externally allocated   * memory alive.   *   * \param change_in_bytes the change in externally allocated memory   *   that is kept alive by JavaScript objects.   * \returns the adjusted value.   */  static int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes); private:  V8();  static void** GlobalizeReference(void** handle);  static void DisposeGlobal(void** global_handle);  static void MakeWeak(void** global_handle, void* data, WeakReferenceCallback);  static void ClearWeak(void** global_handle);  static bool IsGlobalNearDeath(void** global_handle);  static bool IsGlobalWeak(void** global_handle);  template <class T> friend class Handle;  template <class T> friend class Local;  template <class T> friend class Persistent;  friend class Context;};/** * An external exception handler. */class EXPORT TryCatch { public:  /**   * Creates a new try/catch block and registers it with v8.   */  TryCatch();  /**   * Unregisters and deletes this try/catch block.   */  ~TryCatch();  /**   * Returns true if an exception has been caught by this try/catch block.   */  bool HasCaught();  /**   * Returns the exception caught by this try/catch block.  If no exception has   * been caught an empty handle is returned.   *   * The returned handle is valid until this TryCatch block has been destroyed.   */  Local<Value> Exception();  /**   * Returns the message associated with this exception.  If there is   * no message associated an empty handle is returned.   *   * The returned handle is valid until this TryCatch block has been   * destroyed.   */  Local<v8::Message> Message();  /**   * Clears any exceptions that may have been caught by this try/catch block.   * After this method has been called, HasCaught() will return false.   *   * It is not necessary to clear a try/catch block before using it again; if   * another exception is thrown the previously caught exception will just be   * overwritten.  However, it is often a good idea since it makes it easier   * to determine which operation threw a given exception.   */  void Reset();  /**   * Set verbosity of the external exception handler.   *   * By default, exceptions that are caught by an external exception   * handler are not reported.  Call SetVerbose with true on an   * external exception handler to have exceptions caught by the   * handler reported as if they were not caught.   */  void SetVerbose(bool value);  /**   * Set whether or not this TryCatch should capture a Message object   * which holds source information about where the exception   * occurred.  True by default.   */  void SetCaptureMessage(bool value); public:  TryCatch* next_;  void* exception_;  void* message_;  bool is_verbose_;  bool capture_message_;};// --- C o n t e x t ---/** * Ignore */class EXPORT ExtensionConfiguration { public:  ExtensionConfiguration(int name_count, const char* names[])      : name_count_(name_count), names_(names) { } private:  friend class ImplementationUtilities;  int name_count_;  const char** names_;};/** * A sandboxed execution context with its own set of built-in objects * and functions. */class EXPORT Context { public:  Local<Object> Global();  /** Creates a new context. */  static Persistent<Context> New(      ExtensionConfiguration* extensions = 0,      Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),      Handle<Value> global_object = Handle<Value>());  /** Returns the last entered context. */  static Local<Context> GetEntered();  /** Returns the context that is on the top of the stack. */  static Local<Context> GetCurrent();  /** Returns the security context that is currently used. */  static Local<Context> GetCurrentSecurityContext();  /**   * Sets the security token for the context.  To access an object in   * another context, the security tokens must match.   */  void SetSecurityToken(Handle<Value> token);  /** Returns the security token of this context.*/  Handle<Value> GetSecurityToken();  /**   * Enter this context.  After entering a context, all code compiled   * and run is compiled and run in this context.  If another context   * is already entered, this old context is saved so it can be   * restored when the new context is exited.   */  void Enter();  /**   * Exit this context.  Exiting the current context restores the   * context that was in place when entering the current context.   */  void Exit();  /** Returns true if the context has experienced an out of memory situation. */  bool HasOutOfMemoryException();  /** Returns true if V8 has a current context. */  static bool InContext();  /** Returns true if V8 has a current security context. */  static bool InSecurityContext();  /**   * Stack-allocated class which sets the execution context for all   * operations executed within a local scope.   */  class EXPORT Scope {   public:    inline Scope(Handle<Context> context) : context_(context) {      context_->Enter();    }    inline ~Scope() { context_->Exit(); }   private:    Handle<Context> context_;  }; private:  friend class Value;  friend class Script;  friend class Object;  friend class Function;};/** * Multiple threads in V8 are allowed, but only one thread at a time * is allowed to use V8.  The definition of 'using V8' includes * accessing handles or holding onto object pointers obtained from V8 * handles.  It is up to the user of V8 to ensure (perhaps with * locking) that this constraint is not violated. * * If you wish to start using V8 in a thread you can 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -