Add method `Subview::getParent()`.
This commit is contained in:
parent
1beaebc9fd
commit
71b8b306ce
|
@ -29,6 +29,7 @@ namespace php_arma
|
|||
PHP_ARMA_FENTRY((base <T, diagonal>::me)),
|
||||
PHP_ARMA_FENTRY((parent_t ::me)),
|
||||
PHP_ARMA_FENTRY((non_resizable<T, diagonal>::me)),
|
||||
PHP_ARMA_FENTRY((subview <T, diagonal>::me)),
|
||||
PHP_ARMA_FENTRY(me)
|
||||
));
|
||||
ce->create_object = object_non_constructible;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
//
|
||||
|
||||
#include "mapval.hh"
|
||||
#include "subview.hh"
|
||||
#include "complex.hh"
|
||||
|
||||
namespace php_arma
|
||||
|
@ -42,7 +43,10 @@ namespace php_arma
|
|||
zend_always_inline
|
||||
void mapval<T, B1, B2>::ce_init(zend_class_entry *parent_ce)
|
||||
{
|
||||
ce = class_register<php_name::val>(parent_ce, me);
|
||||
ce = class_register<php_name::val>(parent_ce, fentry_list_concat(
|
||||
PHP_ARMA_FENTRY((subview<T, mapval>::me)),
|
||||
PHP_ARMA_FENTRY(me)
|
||||
));
|
||||
ce->create_object = object_non_constructible;
|
||||
declare_subview_parent(ce);
|
||||
|
||||
|
@ -67,17 +71,17 @@ namespace php_arma
|
|||
{
|
||||
scalar_ce = interface_register<scalar_php_name>();
|
||||
|
||||
mapval_ce = abstract_class_register<mapval_php_name>(scalar_ce);
|
||||
mapval_ce = abstract_class_register<mapval_php_name>(scalar_ce, subview_ce);
|
||||
mapval_dense<double >::ce_init(mapval_ce);
|
||||
mapval_dense<zend_long>::ce_init(mapval_ce);
|
||||
mapval_dense<cx_double>::ce_init(mapval_ce);
|
||||
|
||||
sp_mapval_ce = abstract_class_register<sp_mapval_php_name>(scalar_ce);
|
||||
sp_mapval_ce = abstract_class_register<sp_mapval_php_name>(scalar_ce, subview_ce);
|
||||
mapval_spmat<double >::ce_init(sp_mapval_ce);
|
||||
mapval_spmat<zend_long>::ce_init(sp_mapval_ce);
|
||||
mapval_spmat<cx_double>::ce_init(sp_mapval_ce);
|
||||
|
||||
spsv_mapval_ce = abstract_class_register<spsv_mapval_php_name>(scalar_ce);
|
||||
spsv_mapval_ce = abstract_class_register<spsv_mapval_php_name>(scalar_ce, subview_ce);
|
||||
mapval_sp_subview<double >::ce_init(spsv_mapval_ce);
|
||||
mapval_sp_subview<zend_long>::ce_init(spsv_mapval_ce);
|
||||
mapval_sp_subview<cx_double>::ce_init(spsv_mapval_ce);
|
||||
|
|
|
@ -5,11 +5,32 @@
|
|||
//
|
||||
|
||||
#include "subview.hh"
|
||||
#include "mapval.hh"
|
||||
#include "subview_mat.hh"
|
||||
#include "diagonal.hh"
|
||||
|
||||
namespace php_arma
|
||||
{
|
||||
template <typename T, typename T1>
|
||||
PHP_ARMA_METHOD(subview, getParent, T, T1)
|
||||
{
|
||||
auto current = Z_OBJ(EX(This));
|
||||
ZVAL_COPY(return_value, OBJ_PROP_NUM(current, 0));
|
||||
}
|
||||
|
||||
template <typename T, typename T1>
|
||||
PHP_ARMA_START_ME(subview, T, T1)
|
||||
PHP_ARMA_ME(getParent, ZEND_ACC_PUBLIC)
|
||||
PHP_ARMA_END_ME();
|
||||
|
||||
void subview_init()
|
||||
{
|
||||
subview_ce = interface_register<subview_php_name>();
|
||||
}
|
||||
|
||||
PHP_ARMA_INSTANTIATE(subview, mapval_dense);
|
||||
PHP_ARMA_INSTANTIATE(subview, mapval_spmat);
|
||||
PHP_ARMA_INSTANTIATE(subview, mapval_sp_subview);
|
||||
PHP_ARMA_INSTANTIATE(subview, subview_mat);
|
||||
PHP_ARMA_INSTANTIATE(subview, diagview);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,17 @@
|
|||
|
||||
namespace php_arma
|
||||
{
|
||||
template <typename T, typename ChildT>
|
||||
struct subview
|
||||
{
|
||||
using native_t = typename ChildT::native_t;
|
||||
|
||||
PHP_ARMA_COMMON_DECLARE();
|
||||
|
||||
private:
|
||||
static PHP_FUNCTION(getParent);
|
||||
};
|
||||
|
||||
void subview_init();
|
||||
|
||||
constexpr const char subview_php_name[] = "Subview";
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace php_arma
|
|||
PHP_ARMA_FENTRY((non_resizable <T, subview_mat>::me)),
|
||||
PHP_ARMA_FENTRY((non_resizable_matrix <T, subview_mat>::me)),
|
||||
PHP_ARMA_FENTRY((dense_non_resizable_matrix<T, subview_mat>::me)),
|
||||
PHP_ARMA_FENTRY((subview <T, subview_mat>::me)),
|
||||
PHP_ARMA_FENTRY(me)
|
||||
));
|
||||
ce->create_object = object_non_constructible;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Arma;
|
|||
*
|
||||
* @package Arma
|
||||
*/
|
||||
abstract class MapVal implements Internal\Scalar
|
||||
abstract class MapVal implements Internal\Scalar, Internal\Subview
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Arma;
|
|||
*
|
||||
* @package Arma
|
||||
*/
|
||||
abstract class SpMapVal implements Internal\Scalar
|
||||
abstract class SpMapVal implements Internal\Scalar, Internal\Subview
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -9,5 +9,10 @@ namespace Arma\Internal;
|
|||
*/
|
||||
interface Subview
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the parent object referenced by current subview.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
function getParent();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ batch_assert('orphaned `SvMat`',
|
|||
[$orphaned_submat->at(0, 0)->val(), 1],
|
||||
[$orphaned_submat->at(1, 0)->val(), 3]
|
||||
);
|
||||
$orphaned_submat->getParent()->rawPrint();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
1 2
|
||||
3 4
|
||||
|
|
Reference in New Issue