MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
shcore::polyglot::Polyglot_native_wrapper< T, t > Class Template Referenceabstract

Exposure of C++ objects to the polyglot library is done through the usage of Proxy objects provided by the polyglot library. More...

#include <polyglot_native_wrapper.h>

Public Types

using Collectable_t = Collectable< T, t >
 
using Native_ptr = std::shared_ptr< T >
 

Public Member Functions

 Polyglot_native_wrapper ()=delete
 
 Polyglot_native_wrapper (std::weak_ptr< Polyglot_language > language)
 
 Polyglot_native_wrapper (const Polyglot_native_wrapper &)=delete
 
Polyglot_native_wrapperoperator= (const Polyglot_native_wrapper &)=delete
 
 Polyglot_native_wrapper (Polyglot_native_wrapper &&)=delete
 
Polyglot_native_wrapperoperator= (Polyglot_native_wrapper &&)=delete
 
virtual ~Polyglot_native_wrapper ()=default
 
poly_value wrap (const Native_ptr &native_value) const
 

Static Public Member Functions

static bool unwrap (poly_thread thread, poly_value value, Native_ptr *ret_object)
 

Protected Member Functions

virtual poly_value create_wrapper (poly_thread thread, poly_context context, ICollectable *collectable) const =0
 

Static Protected Member Functions

static poly_value handler_release_collectable (poly_thread thread, poly_callback_info args)
 
template<typename Config >
static poly_value native_handler_no_args (poly_thread thread, poly_callback_info args)
 Generic handler to be used with pure native functions, no interaction with the polyglot library is done: More...
 
template<typename Config >
static poly_value polyglot_handler_no_args (poly_thread thread, poly_callback_info args)
 Generic handler to be used with functions that interact with the polyglot library: More...
 
template<typename Config >
static poly_value native_handler_fixed_args (poly_thread thread, poly_callback_info args)
 Generic handler to be used with pure native functions, no interaction with the polyglot library is done: More...
 
template<typename Config >
static poly_value polyglot_handler_fixed_args (poly_thread thread, poly_callback_info args)
 Generic handler to be used with functions that interact with the polyglot library, this is: More...
 
template<typename Config >
static poly_value native_handler_variable_args (poly_thread thread, poly_callback_info args)
 Generic handler to be used with pure native functions, no interaction with the polyglot library is done: More...
 

Protected Attributes

std::weak_ptr< Polyglot_languagem_language
 

Detailed Description

template<typename T, Collectable_type t>
class shcore::polyglot::Polyglot_native_wrapper< T, t >

Exposure of C++ objects to the polyglot library is done through the usage of Proxy objects provided by the polyglot library.

Those proxy objects implement the needed operations to treat a C++ object as a standard polyglot object, each of those operations require a C++ callback for the execution.

In the C++ side it is needed to create the callbacks required by the proxy objects in the polyglot library, for each C++ object type to be supported there's a wrapper class which provides the needed callbacks.

When a C++ object is given to the polyglot library, 2 things are needed:

  • The registrations of the C++ callbacks
  • The identification of the target C++ instance to be used on the callbacks

Each object wrapper provides the above. For the second item, a Collectable object is created and given to the polyglot proxy object. This Collectable object contains the necessary information to identify the target C++ object on which the operation will be executed.

This class holds general callback function to be used to release the created Collectable objects once the Proxy object is garbage collected in the Polyglot library.

Member Typedef Documentation

◆ Collectable_t

◆ Native_ptr

template<typename T , Collectable_type t>
using shcore::polyglot::Polyglot_native_wrapper< T, t >::Native_ptr = std::shared_ptr<T>

Constructor & Destructor Documentation

◆ Polyglot_native_wrapper() [1/4]

◆ Polyglot_native_wrapper() [2/4]

template<typename T , Collectable_type t>
shcore::polyglot::Polyglot_native_wrapper< T, t >::Polyglot_native_wrapper ( std::weak_ptr< Polyglot_language language)
inlineexplicit

◆ Polyglot_native_wrapper() [3/4]

◆ Polyglot_native_wrapper() [4/4]

◆ ~Polyglot_native_wrapper()

template<typename T , Collectable_type t>
virtual shcore::polyglot::Polyglot_native_wrapper< T, t >::~Polyglot_native_wrapper ( )
virtualdefault

Member Function Documentation

◆ create_wrapper()

◆ handler_release_collectable()

template<typename T , Collectable_type t>
static poly_value shcore::polyglot::Polyglot_native_wrapper< T, t >::handler_release_collectable ( poly_thread  thread,
poly_callback_info  args 
)
inlinestaticprotected

◆ native_handler_fixed_args()

template<typename T , Collectable_type t>
template<typename Config >
static poly_value shcore::polyglot::Polyglot_native_wrapper< T, t >::native_handler_fixed_args ( poly_thread  thread,
poly_callback_info  args 
)
inlinestaticprotected

Generic handler to be used with pure native functions, no interaction with the polyglot library is done:

  • Receive a vector of Values as arguments
  • Return a Value as result

◆ native_handler_no_args()

template<typename T , Collectable_type t>
template<typename Config >
static poly_value shcore::polyglot::Polyglot_native_wrapper< T, t >::native_handler_no_args ( poly_thread  thread,
poly_callback_info  args 
)
inlinestaticprotected

Generic handler to be used with pure native functions, no interaction with the polyglot library is done:

  • Receive no arguments
  • Return a Value as result

◆ native_handler_variable_args()

template<typename T , Collectable_type t>
template<typename Config >
static poly_value shcore::polyglot::Polyglot_native_wrapper< T, t >::native_handler_variable_args ( poly_thread  thread,
poly_callback_info  args 
)
inlinestaticprotected

Generic handler to be used with pure native functions, no interaction with the polyglot library is done:

  • Receive a vector of Values as arguments
  • Return a Value as result

◆ operator=() [1/2]

template<typename T , Collectable_type t>
Polyglot_native_wrapper & shcore::polyglot::Polyglot_native_wrapper< T, t >::operator= ( const Polyglot_native_wrapper< T, t > &  )
delete

◆ operator=() [2/2]

template<typename T , Collectable_type t>
Polyglot_native_wrapper & shcore::polyglot::Polyglot_native_wrapper< T, t >::operator= ( Polyglot_native_wrapper< T, t > &&  )
delete

◆ polyglot_handler_fixed_args()

template<typename T , Collectable_type t>
template<typename Config >
static poly_value shcore::polyglot::Polyglot_native_wrapper< T, t >::polyglot_handler_fixed_args ( poly_thread  thread,
poly_callback_info  args 
)
inlinestaticprotected

Generic handler to be used with functions that interact with the polyglot library, this is:

  • Require the language instance for the execution
  • Receive a vector of polyglot values as arguments
  • Return a polyglot value as result

◆ polyglot_handler_no_args()

template<typename T , Collectable_type t>
template<typename Config >
static poly_value shcore::polyglot::Polyglot_native_wrapper< T, t >::polyglot_handler_no_args ( poly_thread  thread,
poly_callback_info  args 
)
inlinestaticprotected

Generic handler to be used with functions that interact with the polyglot library:

  • Receive no arguments
  • Return a poly_value as result

◆ unwrap()

template<typename T , Collectable_type t>
static bool shcore::polyglot::Polyglot_native_wrapper< T, t >::unwrap ( poly_thread  thread,
poly_value  value,
Native_ptr ret_object 
)
inlinestatic

◆ wrap()

template<typename T , Collectable_type t>
poly_value shcore::polyglot::Polyglot_native_wrapper< T, t >::wrap ( const Native_ptr native_value) const
inline

Member Data Documentation

◆ m_language

template<typename T , Collectable_type t>
std::weak_ptr<Polyglot_language> shcore::polyglot::Polyglot_native_wrapper< T, t >::m_language
protected

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