42 lines
1014 B
C++
42 lines
1014 B
C++
//
|
|
// php-armadillo/instantiable.hh
|
|
//
|
|
// @Author CismonX
|
|
//
|
|
|
|
#ifndef PHP_ARMA_INSTANTIABLE_HH
|
|
#define PHP_ARMA_INSTANTIABLE_HH
|
|
|
|
#include "php_arma.hh"
|
|
|
|
namespace php_arma
|
|
{
|
|
template <typename ChildT, bool IsSubview> struct instantiable;
|
|
|
|
template <typename ChildT>
|
|
struct instantiable<ChildT, false>
|
|
{
|
|
template <typename... Ts>
|
|
zend_always_inline
|
|
static zend_object *create(Ts&&... args)
|
|
{
|
|
return object_create_ctor<typename ChildT::native_t>(ChildT::ce, &ChildT::handlers, args...);
|
|
}
|
|
};
|
|
|
|
template <typename ChildT>
|
|
struct instantiable<ChildT, true>
|
|
{
|
|
template <typename... Ts>
|
|
zend_always_inline
|
|
static zend_object *create(zval *parent, Ts&&... args)
|
|
{
|
|
auto zobj = object_create_ctor<typename ChildT::native_t>(ChildT::ce, &ChildT::handlers, args...);
|
|
object_set_property(zobj, 0, parent);
|
|
return zobj;
|
|
}
|
|
};
|
|
}
|
|
|
|
#endif // !PHP_ARMA_INSTANTIABLE_HH
|