You.i Engine
CYIDTBindingImplementation Class Reference

Detailed Description

This is the base class for binding implementations between C++ and Javascript using the Duktape binding engine.

This class contains data and functionality that is required to bind C++ to Javascript using Duktape. The binding generation tools provided in the You.i Engine SDK package create subclasses of this class which implement the binding for each class which is bound for use in Javascript.

See Binding for more information regarding creating custom bindings.

#include <binding/YiDTBindingImplementation.h>

Inheritance diagram for CYIDTBindingImplementation:

Classes

struct  ConstructorData
 
struct  PropertyData
 
struct  SignalData
 

Public Member Functions

 CYIDTBindingImplementation ()
 
 CYIDTBindingImplementation (const std::vector< SignalData > &signalData)
 
virtual ~CYIDTBindingImplementation ()
 
virtual void CreateNewScriptObject (CYIBindingContext *pBindingContext, CYIScriptableObject *pScriptableObject, void *pScriptObjectPointer) override
 
virtual void CreateNewScriptObject (CYIBindingContext *pBindingContext, std::shared_ptr< CYIScriptableObject > pScriptableObject, void *pScriptObjectPointer) override
 
virtual void SetIsRooted (bool bIsRooted) overridefinal
 
void InitConstructor (CYIScriptableObject *pScriptableObject)
 
void PushOnStack ()
 
- Public Member Functions inherited from CYIBindingImplementation
 CYIBindingImplementation ()
 
virtual ~CYIBindingImplementation ()
 
virtual bool IsRooted () const
 
void BreakObjectLink ()
 
CYIScriptableObjectGetScriptableObject ()
 
const std::shared_ptr< CYIScriptableObject > & GetSharedPtr ()
 
std::unique_ptr< CYIScriptableObjectTakeUniquePtr ()
 
void * GetScriptObject ()
 
CYIBindingContextGetBindingContext ()
 
void SetBindingContext (CYIBindingContext *pBindingContext)
 
void SetIsStrongLink (bool bIsStrong)
 
bool IsStrongLink () const
 
- Public Member Functions inherited from CYISignalHandler
 CYISignalHandler ()
 
 CYISignalHandler (const CYISignalHandler &rSignalHandler)
 
virtual ~CYISignalHandler ()
 
CYISignalHandleroperator= (const CYISignalHandler &rSignalHandler)
 
void MoveToThread (CYIThread *pThread)
 This function allows the user to override the default thread affinity to any CYIThread that may or may not be running. More...
 
CYIThreadHandle GetThreadAffinity () const
 
void SetThreadAffinity (const CYIThreadHandle &rThreadAffinity)
 
virtual bool IsConnected () const
 
virtual bool IsConnected (const CYISignalBase &rSignal) const
 
void Disconnect (CYISignalBase &rSignal)
 
void DisconnectFromAllSignals ()
 
- Public Member Functions inherited from CYIThread::Listener
 Listener ()
 
virtual ~Listener ()
 
virtual void OnThreadStarted (CYIThread *)
 
virtual void OnThreadTerminated (CYIThread *)
 
virtual void OnThreadFinished (CYIThread *)
 

Static Public Member Functions

static duk_ret_t JSDestructor (duk_context *pDKContext)
 
static duk_ret_t JSShallowConstructor (duk_context *pDKContext)
 
static CYIDTBindingImplementationGetInstanceFromStack (duk_context *pDKContext, duk_idx_t nIndex)
 

Static Protected Member Functions

static void CreateTemplateOnStack (duk_context *pDKContext, CYIString templateNamespace, CYIString templateName, CYIString parentNameSpace, CYIString parentName, const ConstructorData &constructorData, const duk_function_list_entry *pMethodList, const duk_function_list_entry *pStaticMethodList, const std::vector< PropertyData > &propertyData, const std::vector< PropertyData > &staticPropertyData)
 

Protected Attributes

const std::vector< SignalData > & m_signalData
 
- Protected Attributes inherited from CYIBindingImplementation
CYIString m_TemplateName
 
CYIString m_TemplateNamespace
 
CYIBindingContextm_pBindingContext
 
void * m_pScriptObjectPointer
 
CYIScriptableObjectm_pScriptableObject
 
std::shared_ptr< CYIScriptableObjectm_pScriptableObjectSharedPtr
 

Constructor & Destructor Documentation

CYIDTBindingImplementation::CYIDTBindingImplementation ( )
CYIDTBindingImplementation::CYIDTBindingImplementation ( const std::vector< SignalData > &  signalData)
virtual CYIDTBindingImplementation::~CYIDTBindingImplementation ( )
virtual

Member Function Documentation

virtual void CYIDTBindingImplementation::CreateNewScriptObject ( CYIBindingContext pContext,
CYIScriptableObject pScriptableObject,
void *  pScriptObjectPointer 
)
overridevirtual

Creates a new script object if pScriptObjectPointer is null. pScriptObjectPointer is the pointer to the script object in memory that is managed by the binding engine. The script object is then associated with the C++ object, pScriptableObject, so that it accessible when receiving calls from the script layer.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note
This class will hold a reference to pScriptableObject until pScriptObjectPointer is destroyed by the binding engine.

Implements CYIBindingImplementation.

virtual void CYIDTBindingImplementation::CreateNewScriptObject ( CYIBindingContext pBindingContext,
std::shared_ptr< CYIScriptableObject pScriptableObject,
void *  pScriptObjectPointer 
)
overridevirtual
static void CYIDTBindingImplementation::CreateTemplateOnStack ( duk_context *  pDKContext,
CYIString  templateNamespace,
CYIString  templateName,
CYIString  parentNameSpace,
CYIString  parentName,
const ConstructorData constructorData,
const duk_function_list_entry *  pMethodList,
const duk_function_list_entry *  pStaticMethodList,
const std::vector< PropertyData > &  propertyData,
const std::vector< PropertyData > &  staticPropertyData 
)
staticprotected

Creates the template for the Javascript object and pushes it onto the Duktape stack so that the object with name templateName is available in Javascript source.

static CYIDTBindingImplementation* CYIDTBindingImplementation::GetInstanceFromStack ( duk_context *  pDKContext,
duk_idx_t  nIndex 
)
static

Returns the binding implementation instance for the Javascript object on the Duktape stack at nIndex.

void CYIDTBindingImplementation::InitConstructor ( CYIScriptableObject pScriptableObject)

Initializes the binding implementation when a new Javascript object is from Javascript source. Associates the Javascript object and C++ pScriptableObject with the binding implementation. Assumes that the new Javascript object is at the top of the Duktape stack.

See also
CreateNewScriptObject
static duk_ret_t CYIDTBindingImplementation::JSDestructor ( duk_context *  pDKContext)
static

Callback called by Duktape when a Javascript object is destroyed. This cleans up the binding implementation which is associated with the Javascript object that was destroyed.

static duk_ret_t CYIDTBindingImplementation::JSShallowConstructor ( duk_context *  pDKContext)
static

Callback called by Duktape when creating a Javascript object for an object that already exists in C++. This pushes the Javascript object onto the Duktape stack without creating a new CYIBindingImplementation or CYIScriptableObject.

void CYIDTBindingImplementation::PushOnStack ( )

Pushes the Javascript object associated with this binding implementation onto the Duktape stack.

virtual void CYIDTBindingImplementation::SetIsRooted ( bool  bIsRooted)
finaloverridevirtual

Sets the script object associated with this binding implementation to rooted. If bIsRooted is true the script object will be kept in memory until set to false, the associated CYIBindingContext is destroyed, or the associated CYIScriptableObject is destroyed. If bIsRooted is false the script object will be destroyed as soon as the script object goes out of scope in the script source code. When the script object is destroyed this binding implementation will be destroyed.

Defaults to false.

See also
CYIBindingContext::NewRootedObject

Reimplemented from CYIBindingImplementation.

Member Data Documentation

const std::vector<SignalData>& CYIDTBindingImplementation::m_signalData
protected

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