nsIScriptContext.h (2555B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef nsIScriptContext_h__ 8 #define nsIScriptContext_h__ 9 10 #include "js/experimental/JSStencil.h" 11 #include "jspubtd.h" 12 #include "nsCOMPtr.h" 13 #include "nsISupports.h" 14 #include "nsString.h" 15 #include "nscore.h" 16 17 class nsIScriptGlobalObject; 18 19 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs 20 #define NS_ISCRIPTCONTEXT_IID \ 21 {0x54cbe9cf, 0x7282, 0x421a, {0x91, 0x6f, 0xd0, 0x70, 0x73, 0xde, 0xb8, 0xc0}} 22 23 class nsIOffThreadScriptReceiver; 24 25 /** 26 * It is used by the application to initialize a runtime and run scripts. 27 * A script runtime would implement this interface. 28 */ 29 class nsIScriptContext : public nsISupports { 30 public: 31 NS_INLINE_DECL_STATIC_IID(NS_ISCRIPTCONTEXT_IID) 32 33 /** 34 * Return the global object. 35 * 36 **/ 37 virtual nsIScriptGlobalObject* GetGlobalObject() = 0; 38 39 // SetProperty is suspect and jst believes should not be needed. Currenly 40 // used only for "arguments". 41 virtual nsresult SetProperty(JS::Handle<JSObject*> aTarget, 42 const char* aPropName, nsISupports* aVal) = 0; 43 /** 44 * Called to set/get information if the script context is 45 * currently processing a script tag 46 */ 47 virtual bool GetProcessingScriptTag() = 0; 48 virtual void SetProcessingScriptTag(bool aResult) = 0; 49 50 /** 51 * Initialize DOM classes on aGlobalObj. 52 */ 53 virtual nsresult InitClasses(JS::Handle<JSObject*> aGlobalObj) = 0; 54 55 /** 56 * Access the Window Proxy. The setter should only be called by 57 * nsGlobalWindow. 58 */ 59 virtual void SetWindowProxy(JS::Handle<JSObject*> aWindowProxy) = 0; 60 virtual JSObject* GetWindowProxy() = 0; 61 }; 62 63 #define NS_IOFFTHREADSCRIPTRECEIVER_IID \ 64 {0x3a980010, 0x878d, 0x46a9, {0x93, 0xad, 0xbc, 0xfd, 0xd3, 0x8e, 0xa0, 0xc2}} 65 66 class nsIOffThreadScriptReceiver : public nsISupports { 67 public: 68 NS_INLINE_DECL_STATIC_IID(NS_IOFFTHREADSCRIPTRECEIVER_IID) 69 70 /** 71 * Notify this object that a previous Compile call specifying this as 72 * aOffThreadReceiver has completed. The script being passed in must be 73 * rooted before any call which could trigger GC. 74 */ 75 NS_IMETHOD OnScriptCompileComplete(JS::Stencil* aStencil, 76 nsresult aStatus) = 0; 77 }; 78 79 #endif // nsIScriptContext_h__