Loading...
Searching...
No Matches
by::tbridger< T, isBaseObj > Class Template Reference

C++ to byeol bridge builder. More...

#include <tbridger.hpp>

Public Member Functions

static me func _get ())
 
static me func (name, *bridgeFunc)
 
static me _get ())
 
static me func _get ())
 
static me func _get ())
 
static me func _get ())
 
static me funcNonConst _get ())
 
static me funcConst _get ())
 
static me genericFunc _get ())
 
static me genericFunc _get ())
 
static me genericFuncNonConst _get ())
 
static me genericFuncConst _get ())
 
static me closure _get ())
 
static me closure _get ())
 

Static Public Member Functions

static scopesubs ()
 
static me & extend (const scope &src)
 
static me & func (const std::string &name, const baseFunc &bridgeFunc)
 
static me & func (const std::string *name, const baseFunc &bridgeFunc) BY_SIDE_FUNC(name
 
static me & func (const std::string &name, const baseFunc *bridgeFunc) BY_SIDE_FUNC(bridgeFunc
 
static me & func (const std::string *name, const baseFunc *bridgeFunc) BY_SIDE_FUNC(name &&bridgeFunc
 
template<typename... Args>
static me & ctor ()
 
template<typename Ret , typename... Args>
static me & func (const std::string &name, Ret(T::*fptr)(Args...))
 
template<typename Ret , typename... Args>
static me & func (const std::string *name, Ret(T::*fptr)(Args...)) BY_SIDE_FUNC(name
 
template<typename Ret , typename... Args>
static me & func (const std::string &name, Ret(T::*fptr)(Args...) const)
 
template<typename Ret , typename... Args>
static me & func (const std::string *name, Ret(T::*fptr)(Args...) const) BY_SIDE_FUNC(name
 
template<typename Ret , typename... Args>
static me & funcNonConst (const std::string &name, Ret(T::*fptr)(Args...))
 
template<typename Ret , typename... Args>
static me & funcNonConst (const std::string *name, Ret(T::*fptr)(Args...)) BY_SIDE_FUNC(name
 
template<typename Ret , typename... Args>
static me & funcConst (const std::string &name, Ret(T::*fptr)(Args...) const)
 
template<typename Ret , typename... Args>
static me & funcConst (const std::string *name, Ret(T::*fptr)(Args...) const) BY_SIDE_FUNC(name
 
static me & genericCtor ()
 
template<typename... Args>
static me & genericCtor ()
 
template<typename Ret , typename... Args>
static me & genericFunc (const std::string &name, Ret(T::*fptr)(Args...))
 
template<typename Ret , typename... Args>
static me & genericFunc (const std::string *name, Ret(T::*fptr)(Args...)) BY_SIDE_FUNC(name
 
template<typename Ret , typename... Args>
static me & genericFunc (const std::string &name, Ret(T::*fptr)(Args...) const)
 
template<typename Ret , typename... Args>
static me & genericFunc (const std::string *name, Ret(T::*fptr)(Args...) const) BY_SIDE_FUNC(name
 
template<typename Ret , typename... Args>
static me & genericFuncNonConst (const std::string &name, Ret(T::*fptr)(Args...))
 
template<typename Ret , typename... Args>
static me & genericFuncNonConst (const std::string *name, Ret(T::*fptr)(Args...)) BY_SIDE_FUNC(name
 
template<typename Ret , typename... Args>
static me & genericFuncConst (const std::string &name, Ret(T::*fptr)(Args...) const)
 
template<typename Ret , typename... Args>
static me & genericFuncConst (const std::string *name, Ret(T::*fptr)(Args...) const) BY_SIDE_FUNC(name
 
template<typename Ret , typename T1 = T, typename... Args>
static me & closure (const std::string &name, std::function< Ret(T1 &, Args...)> c)
 
template<typename Ret , typename T1 = T, typename... Args>
static me & closure (const std::string *name, std::function< Ret(T1 &, Args...)> c) BY_SIDE_FUNC(name
 
template<typename Ret , typename T1 = T>
static me & closure (const std::string &name, std::function< Ret(T1 &)> c)
 
template<typename Ret , typename T1 = T>
static me & closure (const std::string *name, std::function< Ret(T1 &)> c) BY_SIDE_FUNC(name
 
static tbridge< T > * make (T *real)
 

Public Attributes

static me func name
 
static me funcNonConst name
 
static me funcConst name
 
static me genericFunc name
 
static me genericFuncNonConst name
 
static me genericFuncConst name
 
static me closure name
 

Detailed Description

template<typename T, nbool isBaseObj = tifSub<typename tadaptiveSuper<T>::super, baseObj>::is>
class by::tbridger< T, isBaseObj >

C++ to byeol bridge builder.

As the name suggests, tbridger handles the bridge role between C++ native environment and byeol byeol runtime environment. Specifically, tbridger handles the cpp <--> byeol bridge. The goal is to easily expose natively defined functions or classes as scripted types or functions with just a few lines of C++ code.

Remarks
tbridge is designed as a component unit rather than a single class. If you just use it, there's no big problem, but if you try to understand the code without experience in this area, it might be confusing. So let's look at basic usage first to get a feel, then examine the detailed structure.
It's recommended to review baseObj or obj first.

Basic Usage

See baseObj for a complete usage example with nStr. The key is that tbridger can very easily expose native-written functions to script code.

Design Structure

Brief introduction to core classes in the bridge component. See each class for detailed operation methods and algorithms.

  • tbridger is the entry point for the bridge component, performing a Facade role. tbridger is a class template that takes each C++ class as a type parameter. Through functions like func(), it stores externally defined functions in static variable subs().
  • tbridge is a baseObj created using subs registered in tbridger as origin. Internally it defines origin as tbaseObjOrigin<tbridger<T>>, so after filling subs() through tbridger and calling tbridge::getOrigin(), the tbridge object possesses those functions through origin.
  • tbridgeFunc creates a byeol runtime environment baseFunc instance that redirects general C++ member function pointers. Calling tbridger::func() internally creates a tbridgeFunc instance like tbridgerFunc<....>(). tbridgeFunc internally applies marshaling to convert C++ native types (node*, int, etc.) to appropriate script types (str, nInt). The same marshaling applies when exporting return values.
  • tmarshaling handles the marshaling mentioned above.
  • tbridgeCtor represents functions for constructors. ctor in byeol runtime environment is just a constructor function and doesn't participate in object creation. This separates the roles of instance creation and constructor invocation, making logic for calling parent class constructors in inheritance relationships concise. However, tbridgeCtor must represent constructors according to C++ syntax, making it difficult to separately split object creation through new and constructor invocation. Therefore, tbridgeCtor handles both constructor function redirection and object creation through the new keyword.
  • tbridgeClosure helps expose C++ lambda functions through tbridger. The principle itself isn't much different from tbridgeFunc. It just handles lambdas as std::function instead of function pointers.

The documentation for this class was generated from the following files:
to Top