You.i Engine
CYIDTBindingContext Class Reference

Detailed Description

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>

Inheritance diagram for CYIDTBindingContext:

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 CYIScriptableObjectNewRootedObject (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
 
CYIDTBindingImplementationGetBindingImplementationAndPushObjectOnStack (const CYIString &fallbackClassName, const CYIScriptableObject *pScriptableObject)
 
CYIDTBindingImplementationGetBindingImplementationAndPushObjectOnStack (const CYIString &fallbackClassName, CYIScriptableObject *pScriptableObject)
 
CYIDTBindingImplementationGetBindingImplementationAndPushObjectOnStack (const CYIString &fallbackClassName, const std::shared_ptr< CYIScriptableObject > &pScriptableObject)
 
template<typename T >
CYIDTBindingImplementationGetBindingImplementationAndPushObjectOnStack (const CYIString &fallbackClassName, std::unique_ptr< T > &pScriptableObject)
 
- Public Member Functions inherited from CYIBindingContext
 CYIBindingContext ()
 
virtual ~CYIBindingContext ()
 

Static Public Member Functions

static CYIDTBindingContextGetContextObject (duk_context *pDKContext)
 
static duk_context * GetNativeContext (CYIBindingContext *pBindingContext)
 

Static Public Attributes

static const char *const BINDING_CONSTRUCTOR_NAMESPACE
 

Constructor & Destructor Documentation

CYIDTBindingContext::CYIDTBindingContext ( )
virtual CYIDTBindingContext::~CYIDTBindingContext ( )
virtual

Member Function Documentation

virtual bool CYIDTBindingContext::ConnectDebugger ( )
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.

virtual void CYIDTBindingContext::CreateGlobalObject ( const CYIString scriptObjectName,
const CYIString className,
CYIScriptableObject pScriptableObject 
)
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.

virtual void CYIDTBindingContext::DumpToLog ( )
overridevirtual

Dumps the Duktape stack for the current execution context using CYILogger.

Implements CYIBindingContext.

virtual bool CYIDTBindingContext::ExecuteScript ( const std::shared_ptr< CYIAssetScript > &  pScriptAsset)
overridevirtual

Executes script source from a script asset, pScriptAsset.

See also
ExecuteString(const CYIString &)

Implements CYIBindingContext.

virtual bool CYIDTBindingContext::ExecuteString ( const CYIString scriptString)
overridevirtual

Executes script source code contained in the string scriptString.

Note
Init() must be called before executing any script source or the user will not have access to You.i Engine bound classes.
See also
Init

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 
)
template<typename T >
CYIDTBindingImplementation * CYIDTBindingContext::GetBindingImplementationAndPushObjectOnStack ( const CYIString fallbackClassName,
std::unique_ptr< T > &  pScriptableObject 
)
static CYIDTBindingContext* CYIDTBindingContext::GetContextObject ( duk_context *  pDKContext)
static

Returns the CYIDTBindingContext associated with the Duktape native context.

static duk_context* CYIDTBindingContext::GetNativeContext ( CYIBindingContext pBindingContext)
static

Returns the Duktape native context associated with the pBindingContext.

virtual bool CYIDTBindingContext::Init ( )
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.

virtual CYIScriptableObject* CYIDTBindingContext::NewRootedObject ( const CYIRuntimeTypeInfo enforceClassType,
const CYIString scriptObjectName 
)
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.

See also
CYIBindingImplementation::SetIsRooted

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.

Member Data Documentation

const char* const CYIDTBindingContext::BINDING_CONSTRUCTOR_NAMESPACE
static

The Javascript namespace which the Javascript constructors are stored under. This namespace is not accesible from Javascript source code.


The documentation for this class was generated from the following file: