Struct jac::ProtoBuilder::Opaque
template <typename T>
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:
T
The 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:
Sgn
signature of the member functionmember
pointer to the member function
Parameters:
ctx
context to work inproto
the prototype of the classname
name of the propertyflags
flags 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:
U
the type of the member variableU(T::*member)
pointer to the member variable
Parameters:
ctx
context to work inproto
the prototype of the classname
name of the propertyflags
flags 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:
Sgn
the signature of the member functionmember
pointer to the member function
Parameters:
ctx
context to work infuncObj
instance of the classthisVal
value ofthis
in the functionargv
arguments 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:
ctx
context to work inargs
arguments 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:
rt
runtime to work inptr
pointer to the opaque data
function getOpaque
Get the Opaque object from an instance of the class.
Parameters:
ctx
context to work inthisVal
the 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