本文整理汇总了C++中type::extended方法的典型用法代码示例。如果您正苦于以下问题:C++ type::extended方法的具体用法?C++ type::extended怎么用?C++ type::extended使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类type
的用法示例。
在下文中一共展示了type::extended方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make_tuple_identical_assignment_kernel
intptr_t ndt::tuple_type::make_assignment_kernel(
void *ckb, intptr_t ckb_offset, const type &dst_tp, const char *dst_arrmeta,
const type &src_tp, const char *src_arrmeta, kernel_request_t kernreq,
const eval::eval_context *ectx) const
{
if (this == dst_tp.extended()) {
if (this == src_tp.extended()) {
return make_tuple_identical_assignment_kernel(
ckb, ckb_offset, dst_tp, dst_arrmeta, src_arrmeta, kernreq, ectx);
} else if (src_tp.get_kind() == tuple_kind ||
src_tp.get_kind() == struct_kind) {
return make_tuple_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta,
src_tp, src_arrmeta, kernreq, ectx);
} else if (src_tp.is_builtin()) {
return make_broadcast_to_tuple_assignment_kernel(
ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq,
ectx);
} else {
return src_tp.extended()->make_assignment_kernel(
ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq,
ectx);
}
}
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
示例2: broadcast_error
intptr_t ndt::fixed_dim_type::make_assignment_kernel(
const arrfunc_type_data *self, const arrfunc_type *af_tp, void *ckb,
intptr_t ckb_offset, const type &dst_tp, const char *dst_arrmeta,
const type &src_tp, const char *src_arrmeta, kernel_request_t kernreq,
const eval::eval_context *ectx, const nd::array &kwds) const
{
if (this == dst_tp.extended()) {
const fixed_dim_type_arrmeta *dst_md =
reinterpret_cast<const fixed_dim_type_arrmeta *>(dst_arrmeta);
intptr_t src_size, src_stride;
type src_el_tp;
const char *src_el_arrmeta;
if (src_tp.get_ndim() < dst_tp.get_ndim()) {
src_stride = 0;
nd::functional::elwise_ck<fixed_dim_type_id, fixed_dim_type_id, 1>::make(
ckb, kernreq, ckb_offset, get_fixed_dim_size(), dst_md->stride,
&src_stride);
return ::make_assignment_kernel(
self, af_tp, ckb, ckb_offset, m_element_tp,
dst_arrmeta + sizeof(fixed_dim_type_arrmeta), src_tp, src_arrmeta,
kernel_request_strided, ectx, kwds);
} else if (src_tp.get_as_strided(src_arrmeta, &src_size, &src_stride,
&src_el_tp, &src_el_arrmeta)) {
nd::functional::elwise_ck<fixed_dim_type_id, fixed_dim_type_id, 1>::make(
ckb, kernreq, ckb_offset, get_fixed_dim_size(), dst_md->stride,
&src_stride);
// Check for a broadcasting error
if (src_size != 1 && get_fixed_dim_size() != src_size) {
throw broadcast_error(dst_tp, dst_arrmeta, src_tp, src_arrmeta);
}
return ::make_assignment_kernel(
self, af_tp, ckb, ckb_offset, m_element_tp,
dst_arrmeta + sizeof(fixed_dim_type_arrmeta), src_el_tp,
src_el_arrmeta, kernel_request_strided, ectx, kwds);
} else if (!src_tp.is_builtin()) {
// Give the src type a chance to make a kernel
return src_tp.extended()->make_assignment_kernel(
self, af_tp, ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp,
src_arrmeta, kernreq, ectx, kwds);
} else {
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
} else if (dst_tp.get_kind() == string_kind) {
return make_any_to_string_assignment_kernel(ckb, ckb_offset, dst_tp,
dst_arrmeta, src_tp,
src_arrmeta, kernreq, ectx);
} else if (dst_tp.get_ndim() < src_tp.get_ndim()) {
throw broadcast_error(dst_tp, dst_arrmeta, src_tp, src_arrmeta);
} else {
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
}
示例3: make_blockref_bytes_assignment_kernel
intptr_t ndt::bytes_type::make_assignment_kernel(void *ckb, intptr_t ckb_offset, const type &dst_tp,
const char *dst_arrmeta, const type &src_tp, const char *src_arrmeta,
kernel_request_t kernreq, const eval::eval_context *ectx) const
{
if (this == dst_tp.extended()) {
switch (src_tp.get_type_id()) {
case bytes_type_id: {
return make_blockref_bytes_assignment_kernel(ckb, ckb_offset, get_data_alignment(), dst_arrmeta,
src_tp.get_data_alignment(), src_arrmeta, kernreq, ectx);
}
case fixed_bytes_type_id: {
return make_fixed_bytes_to_blockref_bytes_assignment_kernel(ckb, ckb_offset, get_data_alignment(), dst_arrmeta,
src_tp.get_data_size(), src_tp.get_data_alignment(),
kernreq, ectx);
}
default: {
if (!src_tp.is_builtin()) {
src_tp.extended()->make_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq,
ectx);
}
break;
}
}
}
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw runtime_error(ss.str());
}
示例4: runtime_error
intptr_t ndt::fixed_bytes_type::make_assignment_kernel(
void *ckb, intptr_t ckb_offset, const type &dst_tp, const char *dst_arrmeta,
const type &src_tp, const char *src_arrmeta, kernel_request_t kernreq,
const eval::eval_context *ectx) const
{
if (this == dst_tp.extended()) {
switch (src_tp.get_type_id()) {
case fixed_bytes_type_id: {
const fixed_bytes_type *src_fs = src_tp.extended<fixed_bytes_type>();
if (get_data_size() != src_fs->get_data_size()) {
throw runtime_error(
"cannot assign to a fixed_bytes type of a different size");
}
return ::make_pod_typed_data_assignment_kernel(
ckb, ckb_offset, get_data_size(),
std::min(get_data_alignment(), src_fs->get_data_alignment()),
kernreq);
}
default: {
return src_tp.extended()->make_assignment_kernel(
ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq,
ectx);
}
}
} else {
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
}
示例5: if
bool ndt::callable_type::is_lossless_assignment(const type &dst_tp, const type &src_tp) const {
if (dst_tp.extended() == this) {
if (src_tp.extended() == this) {
return true;
} else if (src_tp.get_id() == callable_id) {
return *dst_tp.extended() == *src_tp.extended();
}
}
return false;
}
示例6: make_tuple_comparison_kernel
size_t ndt::struct_type::make_comparison_kernel(void *ckb, intptr_t ckb_offset, const type &src0_dt,
const char *src0_arrmeta, const type &src1_dt, const char *src1_arrmeta,
comparison_type_t comptype, const eval::eval_context *ectx) const
{
if (this == src0_dt.extended()) {
if (*this == *src1_dt.extended()) {
return make_tuple_comparison_kernel(ckb, ckb_offset, src0_dt, src0_arrmeta, src1_arrmeta, comptype, ectx);
} else if (src1_dt.get_kind() == struct_kind) {
// TODO
}
}
throw not_comparable_error(src0_dt, src1_dt, comptype);
}
示例7: make_option_assignment_kernel
intptr_t ndt::option_type::make_assignment_kernel(
void *ckb, intptr_t ckb_offset, const type &dst_tp, const char *dst_arrmeta,
const type &src_tp, const char *src_arrmeta, kernel_request_t kernreq,
const eval::eval_context *ectx) const
{
// Let expression types resolve themselves first
if (this == dst_tp.extended() && src_tp.get_kind() == expr_kind) {
return src_tp.extended()->make_assignment_kernel(
ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq,
ectx);
}
return kernels::make_option_assignment_kernel(
ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq, ectx);
}
示例8:
bool ndt::categorical_type::is_lossless_assignment(const type &dst_tp, const type &src_tp) const
{
if (dst_tp.extended() == this) {
if (src_tp.extended() == this) {
// Casting from identical types
return true;
}
else {
return false; // TODO
}
}
else {
return ::is_lossless_assignment(dst_tp, m_category_tp); // TODO
}
}
示例9: make_builtin_type_comparison_kernel
size_t ndt::date_type::make_comparison_kernel(void *ckb, intptr_t ckb_offset, const type &src0_tp,
const char *src0_arrmeta, const type &src1_tp, const char *src1_arrmeta,
comparison_type_t comptype, const eval::eval_context *ectx) const
{
if (this == src0_tp.extended()) {
if (*this == *src1_tp.extended()) {
return make_builtin_type_comparison_kernel(ckb, ckb_offset, int32_type_id, int32_type_id, comptype);
}
else if (!src1_tp.is_builtin()) {
return src1_tp.extended()->make_comparison_kernel(ckb, ckb_offset, src0_tp, src0_arrmeta, src1_tp, src1_arrmeta,
comptype, ectx);
}
}
throw not_comparable_error(src0_tp, src1_tp, comptype);
}
示例10:
bool ndt::option_type::is_lossless_assignment(const type &dst_tp, const type &src_tp) const {
if (dst_tp.extended() == this) {
return ::is_lossless_assignment(m_value_tp, src_tp);
} else {
return ::is_lossless_assignment(dst_tp, m_value_tp);
}
}
示例11:
bool ndt::typevar_type::match(const char *DYND_UNUSED(arrmeta),
const type &candidate_tp,
const char *DYND_UNUSED(candidate_arrmeta),
std::map<std::string, type> &tp_vars) const
{
if (candidate_tp.get_type_id() == typevar_type_id) {
return *this == *candidate_tp.extended();
}
if (candidate_tp.get_ndim() > 0 ||
candidate_tp.get_type_id() == any_kind_type_id) {
return false;
}
type &tv_type = tp_vars[m_name];
if (tv_type.is_null()) {
// This typevar hasn't been seen yet
tv_type = candidate_tp;
return true;
} else {
// Make sure the type matches previous
// instances of the type var
return candidate_tp == tv_type;
}
}
示例12: if
bool ndt::time_type::is_lossless_assignment(const type &dst_tp,
const type &src_tp) const
{
if (dst_tp.extended() == this) {
if (src_tp.extended() == this) {
return true;
} else if (src_tp.get_type_id() == time_type_id) {
// There is only one possibility for the time type (TODO: timezones!)
return true;
} else {
return false;
}
} else {
return false;
}
}
示例13: make_pod_typed_data_assignment_kernel
intptr_t ndt::time_type::make_assignment_kernel(
void *ckb, intptr_t ckb_offset, const type &dst_tp, const char *dst_arrmeta,
const type &src_tp, const char *src_arrmeta, kernel_request_t kernreq,
const eval::eval_context *ectx) const
{
if (this == dst_tp.extended()) {
if (src_tp.get_type_id() == time_type_id) {
return make_pod_typed_data_assignment_kernel(
ckb, ckb_offset, get_data_size(), get_data_alignment(), kernreq);
} else if (src_tp.get_kind() == string_kind) {
// Assignment from strings
typedef nd::assignment_kernel<time_type_id, string_type_id> self_type;
return self_type::instantiate(NULL, 0, NULL, ckb, ckb_offset, dst_tp,
dst_arrmeta, 1, &src_tp, &src_arrmeta,
kernreq, ectx, 0, NULL,
std::map<std::string, ndt::type>());
} else if (src_tp.get_kind() == struct_kind) {
// Convert to struct using the "struct" property
return ::make_assignment_kernel(
ckb, ckb_offset, property_type::make(dst_tp, "struct"), dst_arrmeta,
src_tp, src_arrmeta, kernreq, ectx);
} else if (!src_tp.is_builtin()) {
return src_tp.extended()->make_assignment_kernel(
ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq,
ectx);
}
} else {
if (dst_tp.get_kind() == string_kind) {
// Assignment to strings
typedef nd::assignment_kernel<string_type_id, time_type_id> self_type;
return self_type::instantiate(NULL, 0, NULL, ckb, ckb_offset, dst_tp,
dst_arrmeta, 1, &src_tp, &src_arrmeta,
kernreq, ectx, 0, NULL,
std::map<std::string, ndt::type>());
} else if (dst_tp.get_kind() == struct_kind) {
// Convert to struct using the "struct" property
return ::make_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta,
property_type::make(src_tp, "struct"),
src_arrmeta, kernreq, ectx);
}
// TODO
}
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
示例14: make_broadcast_to_var_dim_assignment_kernel
intptr_t ndt::var_dim_type::make_assignment_kernel(void *ckb, intptr_t ckb_offset, const type &dst_tp,
const char *dst_arrmeta, const type &src_tp, const char *src_arrmeta,
kernel_request_t kernreq, const eval::eval_context *ectx) const
{
if (this == dst_tp.extended()) {
intptr_t src_size, src_stride;
type src_el_tp;
const char *src_el_arrmeta;
if (src_tp.get_ndim() < dst_tp.get_ndim()) {
// If the src has fewer dimensions, broadcast it across this one
return make_broadcast_to_var_dim_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta,
kernreq, ectx);
} else if (src_tp.get_type_id() == var_dim_type_id) {
// var_dim to var_dim
return make_var_dim_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq, ectx);
} else if (src_tp.get_as_strided(src_arrmeta, &src_size, &src_stride, &src_el_tp, &src_el_arrmeta)) {
// strided_dim to var_dim
return make_strided_to_var_dim_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_size, src_stride,
src_el_tp, src_el_arrmeta, kernreq, ectx);
} else if (!src_tp.is_builtin()) {
// Give the src type a chance to make a kernel
return src_tp.extended()->make_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta,
kernreq, ectx);
} else {
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
} else if (dst_tp.get_kind() == string_kind) {
return make_any_to_string_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq,
ectx);
} else if (dst_tp.get_ndim() < src_tp.get_ndim()) {
throw broadcast_error(dst_tp, dst_arrmeta, src_tp, src_arrmeta);
} else {
if (dst_tp.get_type_id() == fixed_dim_type_id) {
// var_dim to fixed_dim
return make_var_to_fixed_dim_assignment_kernel(ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq,
ectx);
} else {
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
}
}
示例15: get_data_size
bool ndt::fixed_bytes_type::is_lossless_assignment(const type &dst_tp,
const type &src_tp) const
{
if (dst_tp.extended() == this) {
if (src_tp.extended() == this) {
return true;
} else if (src_tp.get_type_id() == fixed_bytes_type_id) {
const fixed_bytes_type *src_fs =
static_cast<const fixed_bytes_type *>(src_tp.extended());
return get_data_size() == src_fs->get_data_size();
} else {
return false;
}
} else {
return false;
}
}