This repository has been archived on 2020-06-07. You can view files and clone it, but cannot push or open issues or pull requests.
php-armadillo/src/constants.hh
2019-05-29 23:45:04 +08:00

144 lines
4.3 KiB
C++

//
// php-armadillo/constants.hh
//
// @Author CismonX
//
#ifndef PHP_ARMA_CONSTANTS_HH
#define PHP_ARMA_CONSTANTS_HH
#include "php_arma.hh"
#include <armadillo>
namespace php_arma
{
struct fill
{
static constexpr auto none = 0;
static constexpr auto zeros = 1;
static constexpr auto ones = 2;
static constexpr auto eye = 3;
static constexpr auto randu = 4;
static constexpr auto randn = 5;
template <typename T>
zend_always_inline
static void invoke(T *obj, zend_long val)
{
switch (val) {
case fill::none:
break;
case fill::zeros:
obj->zeros();
break;
case fill::ones:
obj->ones();
break;
case fill::eye:
obj->eye();
break;
case fill::randu:
obj->randu();
break;
case fill::randn:
obj->randn();
break;
default:
zend_throw_exception(zend_ce_error, "bad fill type", 0);
}
}
};
constexpr const char fill_php_name[] = "Fill";
inline zend_class_entry *fill_ce;
struct file_type
{
static constexpr auto auto_detect = 0;
static constexpr auto arma_binary = 1;
static constexpr auto arma_ascii = 2;
static constexpr auto raw_binary = 3;
static constexpr auto raw_ascii = 4;
static constexpr auto csv_ascii = 5;
static constexpr auto coord_ascii = 6;
static constexpr auto pgm_binary = 7;
static constexpr auto hdf5_binary = 8;
zend_always_inline
static arma::file_type native(zend_long val)
{
switch (val) {
case file_type::auto_detect:
return arma::file_type::auto_detect;
case file_type::arma_binary:
return arma::file_type::arma_binary;
case file_type::arma_ascii:
return arma::file_type::arma_ascii;
case file_type::raw_binary:
return arma::file_type::raw_binary;
case file_type::csv_ascii:
return arma::file_type::csv_ascii;
case file_type::coord_ascii:
return arma::file_type::coord_ascii;
case file_type::pgm_binary:
return arma::file_type::pgm_binary;
#ifdef ARMA_USE_HDF5
case file_type::hdf5_binary:
return arma::file_type::hdf5_binary;
#endif // ARMA_USE_HDF5
default:
return arma::file_type::file_type_unknown;
}
}
};
constexpr const char file_type_php_name[] = "FileType";
inline zend_class_entry *file_type_ce;
struct sort_direction
{
static constexpr auto ascend = 0;
static constexpr auto descend = 1;
static constexpr auto strict_ascend = 2;
static constexpr auto strict_descend = 3;
};
constexpr const char sort_direction_php_name[] = "SortDirection";
inline zend_class_entry *sort_direction_ce;
#ifdef ARMA_USE_HDF5
struct hdf5_opts
{
static constexpr auto none = 0u;
static constexpr auto trans = 1u << 0;
static constexpr auto append = 1u << 1;
static constexpr auto replace = 1u << 2;
};
constexpr const char hdf5_opts_php_name[] = "HDF5Opts";
inline zend_class_entry *hdf5_opts_ce;
#endif // ARMA_USE_HDF5
struct features
{
#ifdef PHP_ARMA_OPERATORS
static constexpr auto operators = true;
#else
static constexpr auto operators = false;
#endif // PHP_ARMA_OPERATORS
#ifdef ARMA_USE_HDF5
static constexpr auto hdf5 = true;
#else
static constexpr auto hdf5 = false;
#endif // ARMA_USE_HDF5
};
constexpr const char features_php_name[] = "Features";
inline zend_class_entry *features_ce;
void constants_init();
}
#endif //!PHP_ARMA_CONSTANTS_HH