A binding context implementation for the Duktape Javascript binding engine.
This binding context is responsible for registering You.i Engine bindings with the Duktape engine and managing the creation and lookup of bound objects on the Duktape stack.
#include <binding/YiDTBindingContext.h>

Public Member Functions | |
| CYIDTBindingContext () | |
| virtual | ~CYIDTBindingContext () |
| virtual bool | Init () override |
| virtual bool | ExecuteString (const CYIString &scriptString) override |
| virtual bool | ExecuteScript (const std::shared_ptr< CYIAssetScript > &pScriptAsset) override |
| virtual void | CreateGlobalObject (const CYIString &scriptObjectName, const CYIString &className, CYIScriptableObject *pScriptableObject) override |
| virtual CYIScriptableObject * | NewRootedObject (const CYIRuntimeTypeInfo &enforceClassType, const CYIString &scriptObjectName) override |
| virtual void | DumpToLog () override |
| virtual bool | ConnectDebugger () override |
| void | DumpErrorObject () |
| void | ThrowException (const CYIString &errorMessage, const CYIString &filename, int32_t nLineNumber) CLANG_ANALYZER_NORETURN |
| CYIDTBindingImplementation * | GetBindingImplementationAndPushObjectOnStack (const CYIString &fallbackClassName, const CYIScriptableObject *pScriptableObject) |
| CYIDTBindingImplementation * | GetBindingImplementationAndPushObjectOnStack (const CYIString &fallbackClassName, CYIScriptableObject *pScriptableObject) |
| CYIDTBindingImplementation * | GetBindingImplementationAndPushObjectOnStack (const CYIString &fallbackClassName, const std::shared_ptr< CYIScriptableObject > &pScriptableObject) |
| template<typename T > | |
| CYIDTBindingImplementation * | GetBindingImplementationAndPushObjectOnStack (const CYIString &fallbackClassName, std::unique_ptr< T > &pScriptableObject) |
Public Member Functions inherited from CYIBindingContext | |
| CYIBindingContext () | |
| virtual | ~CYIBindingContext () |
Static Public Member Functions | |
| static CYIDTBindingContext * | GetContextObject (duk_context *pDKContext) |
| static duk_context * | GetNativeContext (CYIBindingContext *pBindingContext) |
Static Public Attributes | |
| static const char *const | BINDING_CONSTRUCTOR_NAMESPACE |
| CYIDTBindingContext::CYIDTBindingContext | ( | ) |
|
virtual |
|
overridevirtual |
Connects the Duktape debugger. The debugger must be running before this is called for the connection to succeeed. Returns true if the debugger was connected and false otherwise. If the debugger is not running when this is called execution will continue. If the debugger is running execution will be halted at the first line of Javascript source code that is executed.
Reimplemented from CYIBindingContext.
|
overridevirtual |
Creates an object that can be accessed globally in script source code with the name scriptObjectName. pScriptableObject is the C++ object that will be accessible in script source and className is its C++ class name.
Implements CYIBindingContext.
| void CYIDTBindingContext::DumpErrorObject | ( | ) |
Dumps the Javascript Error object at the top of the Duktape stack using CYILogger.
|
overridevirtual |
Dumps the Duktape stack for the current execution context using CYILogger.
Implements CYIBindingContext.
|
overridevirtual |
Executes script source from a script asset, pScriptAsset.
Implements CYIBindingContext.
|
overridevirtual |
Executes script source code contained in the string scriptString.
Implements CYIBindingContext.
| CYIDTBindingContext::GetBindingImplementationAndPushObjectOnStack | ( | const CYIString & | fallbackClassName, |
| const CYIScriptableObject * | pScriptableObject | ||
| ) |
Pushes the JavaScript object associated with the C++ pScriptableObject onto the Duktape stack. If there is no JavaScript object associated with pScriptableObject a new object will be created and pushed onto the Duktape stack. The CYIDTBindingImplementation associated with the Javascript object is returned. fallbackClassName is used to create the CYIDTBindingImplementation if pScriptableObject is not a CYIScriptableRTTIObject.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| CYIDTBindingImplementation* CYIDTBindingContext::GetBindingImplementationAndPushObjectOnStack | ( | const CYIString & | fallbackClassName, |
| CYIScriptableObject * | pScriptableObject | ||
| ) |
| CYIDTBindingImplementation* CYIDTBindingContext::GetBindingImplementationAndPushObjectOnStack | ( | const CYIString & | fallbackClassName, |
| const std::shared_ptr< CYIScriptableObject > & | pScriptableObject | ||
| ) |
| CYIDTBindingImplementation * CYIDTBindingContext::GetBindingImplementationAndPushObjectOnStack | ( | const CYIString & | fallbackClassName, |
| std::unique_ptr< T > & | pScriptableObject | ||
| ) |
|
static |
Returns the CYIDTBindingContext associated with the Duktape native context.
|
static |
Returns the Duktape native context associated with the pBindingContext.
|
overridevirtual |
Initializes the binding engine. This registers all You.i Engine bound classes with the binding engine for access in the script source code. Users of this class must register any custom bound classes after calling this method and before executing any scripts. Returns true if initialization was successful.
Implements CYIBindingContext.
|
overridevirtual |
Creates a new instance of the script object with name scriptObjectName and forces the binding engine to keep the script object in memory and not garbage collected.
Implements CYIBindingContext.
| void CYIDTBindingContext::ThrowException | ( | const CYIString & | errorMessage, |
| const CYIString & | filename, | ||
| int32_t | nLineNumber | ||
| ) |
Throws a Duktape exception with errorMessage with the filename and nLineNumber that the exception is coming from.
|
static |
The Javascript namespace which the Javascript constructors are stored under. This namespace is not accesible from Javascript source code.