Struct jac::ProtoBuilder::Opaque
ClassList > jac > ProtoBuilder > Opaque
A base class for javascript classes with opaque data. More...
#include <class.h>
Public Types
| Type | Name |
|---|---|
| typedef T | OpaqueType |
Public Static Attributes
| Type | Name |
|---|---|
| JSClassID | classId |
Public Static Functions
| Type | Name |
|---|---|
| void | addMethodMember (ContextRef ctx, Object proto, std::string name, PropFlags flags=PropFlags::Default) Add a property to the object prototype from a member function of the wrapped class. |
| void | addPropMember (ContextRef ctx, Object proto, std::string name, PropFlags flags=PropFlags::Default) Add a property to the object prototype from a member variable of the wrapped class. |
| Value | callMember (ContextRef ctx, ValueWeak funcObj, ValueWeak thisVal, std::vector< ValueWeak > argv) Process a call to a member function of the wrapped class. |
| T * | constructOpaque (ContextRef, std::vector< ValueWeak >) Construct a new Opaque object from javascript arguments. |
| void | destroyOpaque (JSRuntime *, T * ptr) noexcept Destroy the Opaque object. |
| T * | getOpaque (ContextRef, ValueWeak thisVal) Get the Opaque object from an instance of the class. |
Detailed Description
The functions constructOpaque and destroyOpaque can be overriden to provide custom construction and destruction of the opaque data.
Template parameters:
TThe type of the opaque data
Public Types Documentation
typedef OpaqueType
Public Static Attributes Documentation
variable classId
Public Static Functions Documentation
function addMethodMember
Add a property to the object prototype from a member function of the wrapped class.
template<typename Sgn, Sgn member>
static inline void jac::ProtoBuilder::Opaque::addMethodMember (
ContextRef ctx,
Object proto,
std::string name,
PropFlags flags=PropFlags::Default
)
Template parameters:
Sgnsignature of the member functionmemberpointer to the member function
Parameters:
ctxcontext to work inprotothe prototype of the classnamename of the propertyflagsflags of the property
function addPropMember
Add a property to the object prototype from a member variable of the wrapped class.
template<typename U, UT::* member>
static inline void jac::ProtoBuilder::Opaque::addPropMember (
ContextRef ctx,
Object proto,
std::string name,
PropFlags flags=PropFlags::Default
)
Template parameters:
Uthe type of the member variableU(T::*member)pointer to the member variable
Parameters:
ctxcontext to work inprotothe prototype of the classnamename of the propertyflagsflags of the property
function callMember
Process a call to a member function of the wrapped class.
template<typename Sgn, Sgn member>
static inline Value jac::ProtoBuilder::Opaque::callMember (
ContextRef ctx,
ValueWeak funcObj,
ValueWeak thisVal,
std::vector< ValueWeak > argv
)
Note:
The arguments and return value are automatically converted to and from javascript values
Template parameters:
Sgnthe signature of the member functionmemberpointer to the member function
Parameters:
ctxcontext to work infuncObjinstance of the classthisValvalue ofthisin the functionargvarguments passed to the function
Returns:
Result of the call
function constructOpaque
Construct a new Opaque object from javascript arguments.
static inline T * jac::ProtoBuilder::Opaque::constructOpaque (
ContextRef,
std::vector< ValueWeak >
)
Note:
This function is only called upon javascript class instantiation
Parameters:
ctxcontext to work inargsarguments passed to the constructor
Returns:
A pointer to the opaque data
function destroyOpaque
Destroy the Opaque object.
Note:
This function is only called when the javascript object is garbage collected
Parameters:
rtruntime to work inptrpointer to the opaque data
function getOpaque
Get the Opaque object from an instance of the class.
Parameters:
ctxcontext to work inthisValthe instance of the class
Returns:
A pointer to the opaque data
The documentation for this class was generated from the following file src/jac/machine/class.h