2019-03-22 08:30:44 +00:00
|
|
|
//
|
2019-03-23 16:24:34 +00:00
|
|
|
// php-armadillo/constants.cc
|
2019-03-22 08:30:44 +00:00
|
|
|
//
|
|
|
|
// @Author CismonX
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "constants.hh"
|
|
|
|
|
|
|
|
#include <tuple>
|
|
|
|
|
|
|
|
namespace php_arma
|
|
|
|
{
|
2019-07-12 17:50:16 +00:00
|
|
|
template <typename F, typename... Ts>
|
2019-03-22 08:30:44 +00:00
|
|
|
zend_always_inline
|
2019-07-12 17:50:16 +00:00
|
|
|
void const_declare(zend_class_entry *ce, F&& func, Ts&&... constants)
|
2019-03-22 08:30:44 +00:00
|
|
|
{
|
2019-06-09 14:47:33 +00:00
|
|
|
for (auto&& [name, val] : { constants... }) {
|
2019-07-12 17:50:16 +00:00
|
|
|
func(ce, name, strlen(name), val);
|
2019-03-22 08:30:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 17:50:16 +00:00
|
|
|
template <typename... Ts>
|
|
|
|
zend_always_inline
|
|
|
|
void long_const_declare(zend_class_entry *ce, Ts&&... constants)
|
|
|
|
{
|
|
|
|
const_declare(ce, zend_declare_class_constant_long, std::forward<Ts>(constants)...);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename... Ts>
|
|
|
|
zend_always_inline
|
|
|
|
void bool_const_declare(zend_class_entry *ce, Ts&&... constants)
|
|
|
|
{
|
|
|
|
const_declare(ce, zend_declare_class_constant_bool, std::forward<Ts>(constants)...);
|
|
|
|
}
|
|
|
|
|
2019-03-22 08:30:44 +00:00
|
|
|
void constants_init()
|
|
|
|
{
|
2019-07-12 17:50:16 +00:00
|
|
|
long_const_declare(fill_ce = abstract_class_register<fill_php_name>(),
|
2019-07-12 16:29:03 +00:00
|
|
|
std::make_tuple("NONE", fill::none),
|
|
|
|
std::make_tuple("ZEROS", fill::zeros),
|
|
|
|
std::make_tuple("ONES", fill::ones),
|
|
|
|
std::make_tuple("EYE", fill::eye),
|
|
|
|
std::make_tuple("RANDU", fill::randu),
|
|
|
|
std::make_tuple("RANDN", fill::randn)
|
2019-03-22 08:30:44 +00:00
|
|
|
);
|
2019-07-12 17:50:16 +00:00
|
|
|
long_const_declare(file_type_ce = abstract_class_register<file_type_php_name>(),
|
2019-07-12 16:29:03 +00:00
|
|
|
std::make_tuple("AUTO_DETECT", file_type::auto_detect),
|
|
|
|
std::make_tuple("ARMA_BINARY", file_type::arma_binary),
|
|
|
|
std::make_tuple("ARMA_ASCII", file_type::arma_ascii),
|
|
|
|
std::make_tuple("RAW_BINARY", file_type::raw_binary),
|
|
|
|
std::make_tuple("RAW_ASCII", file_type::raw_ascii),
|
|
|
|
std::make_tuple("CSV_ASCII", file_type::csv_ascii),
|
|
|
|
std::make_tuple("COORD_ASCII", file_type::coord_ascii),
|
|
|
|
std::make_tuple("PGM_BINARY", file_type::pgm_binary),
|
|
|
|
std::make_tuple("HDF5_BINARY", file_type::hdf5_binary)
|
2019-03-22 08:30:44 +00:00
|
|
|
);
|
2019-07-12 17:50:16 +00:00
|
|
|
long_const_declare(sort_direction_ce = abstract_class_register<sort_direction_php_name>(),
|
2019-07-12 16:29:03 +00:00
|
|
|
std::make_tuple("ASCEND", sort_direction::ascend),
|
|
|
|
std::make_tuple("DESCEND", sort_direction::descend),
|
|
|
|
std::make_tuple("STRICT_ASCEND", sort_direction::strict_ascend),
|
|
|
|
std::make_tuple("STRICT_DESCEND", sort_direction::strict_descend)
|
2019-03-22 08:30:44 +00:00
|
|
|
);
|
2019-05-27 08:51:46 +00:00
|
|
|
#ifdef ARMA_USE_HDF5
|
2019-07-12 17:50:16 +00:00
|
|
|
long_const_declare(hdf5_opts_ce = abstract_class_register<hdf5_opts_php_name>(),
|
2019-07-12 16:29:03 +00:00
|
|
|
std::make_tuple("NONE", hdf5_opts::none),
|
|
|
|
std::make_tuple("TRANS", hdf5_opts::trans),
|
|
|
|
std::make_tuple("APPEND", hdf5_opts::append),
|
|
|
|
std::make_tuple("REPLACE", hdf5_opts::replace)
|
2019-04-04 08:07:37 +00:00
|
|
|
);
|
2019-05-27 08:51:46 +00:00
|
|
|
#endif // ARMA_USE_HDF5
|
2019-07-12 17:50:16 +00:00
|
|
|
bool_const_declare(features_ce = abstract_class_register<features_php_name>(),
|
2019-07-12 16:29:03 +00:00
|
|
|
std::make_tuple("OPERATORS", features::operators),
|
2019-07-12 17:50:16 +00:00
|
|
|
std::make_tuple("HDF5", features::hdf5),
|
|
|
|
std::make_tuple("STREAM_RES", features::stream_res)
|
2019-04-16 11:00:50 +00:00
|
|
|
);
|
2019-03-22 08:30:44 +00:00
|
|
|
}
|
|
|
|
}
|