本文整理汇总了C++中ndt::type::is_builtin方法的典型用法代码示例。如果您正苦于以下问题:C++ type::is_builtin方法的具体用法?C++ type::is_builtin怎么用?C++ type::is_builtin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ndt::type
的用法示例。
在下文中一共展示了type::is_builtin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make_assignment_kernel
size_t string_type::make_assignment_kernel(
ckernel_builder *out, size_t offset_out,
const ndt::type& dst_tp, const char *dst_metadata,
const ndt::type& src_tp, const char *src_metadata,
kernel_request_t kernreq, assign_error_mode errmode,
const eval::eval_context *ectx) const
{
if (this == dst_tp.extended()) {
switch (src_tp.get_type_id()) {
case string_type_id: {
return make_blockref_string_assignment_kernel(out, offset_out,
dst_metadata, get_encoding(),
src_metadata, static_cast<const base_string_type *>(src_tp.extended())->get_encoding(),
kernreq, errmode, ectx);
}
case fixedstring_type_id: {
return make_fixedstring_to_blockref_string_assignment_kernel(out, offset_out,
dst_metadata, get_encoding(),
src_tp.get_data_size(),
static_cast<const base_string_type *>(src_tp.extended())->get_encoding(),
kernreq, errmode, ectx);
}
default: {
if (!src_tp.is_builtin()) {
return src_tp.extended()->make_assignment_kernel(out, offset_out,
dst_tp, dst_metadata,
src_tp, src_metadata,
kernreq, errmode, ectx);
} else {
return make_builtin_to_string_assignment_kernel(out, offset_out,
dst_tp, dst_metadata,
src_tp.get_type_id(),
kernreq, errmode, ectx);
}
}
}
} else {
if (dst_tp.is_builtin()) {
return make_string_to_builtin_assignment_kernel(out, offset_out,
dst_tp.get_type_id(),
src_tp, src_metadata,
kernreq, errmode, ectx);
} else {
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
}
}
示例2: make_assignment_kernel
size_t cstruct_type::make_assignment_kernel(
ckernel_builder *out, size_t offset_out,
const ndt::type& dst_tp, const char *dst_metadata,
const ndt::type& src_tp, const char *src_metadata,
kernel_request_t kernreq, assign_error_mode errmode,
const eval::eval_context *ectx) const
{
if (this == dst_tp.extended()) {
if (this == src_tp.extended()) {
return make_struct_identical_assignment_kernel(out, offset_out,
dst_tp,
dst_metadata, src_metadata,
kernreq, errmode, ectx);
} else if (src_tp.get_kind() == struct_kind) {
return make_struct_assignment_kernel(out, offset_out,
dst_tp, dst_metadata,
src_tp, src_metadata,
kernreq, errmode, ectx);
} else if (!src_tp.is_builtin()) {
return src_tp.extended()->make_assignment_kernel(out, offset_out,
dst_tp, dst_metadata,
src_tp, src_metadata,
kernreq, errmode, ectx);
}
}
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw runtime_error(ss.str());
}
示例3: make_comparison_kernel
size_t string_type::make_comparison_kernel(
ckernel_builder *out, size_t offset_out,
const ndt::type& src0_dt, const char *src0_metadata,
const ndt::type& src1_dt, const char *src1_metadata,
comparison_type_t comptype,
const eval::eval_context *ectx) const
{
if (this == src0_dt.extended()) {
if (*this == *src1_dt.extended()) {
return make_string_comparison_kernel(out, offset_out,
m_encoding,
comptype, ectx);
} else if (src1_dt.get_kind() == string_kind) {
return make_general_string_comparison_kernel(out, offset_out,
src0_dt, src0_metadata,
src1_dt, src1_metadata,
comptype, ectx);
} else if (!src1_dt.is_builtin()) {
return src1_dt.extended()->make_comparison_kernel(out, offset_out,
src0_dt, src0_metadata,
src1_dt, src1_metadata,
comptype, ectx);
}
}
throw not_comparable_error(src0_dt, src1_dt, comptype);
}
示例4: make_cuda_from_device_builtin_type_assignment_kernel
intptr_t dynd::make_cuda_from_device_builtin_type_assignment_kernel(
const callable_type_data *DYND_UNUSED(self),
const ndt::callable_type *DYND_UNUSED(af_tp), char *DYND_UNUSED(data),
void *ckb, intptr_t ckb_offset, const ndt::type &dst_tp,
const char *DYND_UNUSED(dst_arrmeta), intptr_t DYND_UNUSED(nsrc),
const ndt::type *src_tp, const char *const *DYND_UNUSED(src_arrmeta),
kernel_request_t kernreq, const eval::eval_context *ectx,
const nd::array &DYND_UNUSED(kwds),
const std::map<std::string, ndt::type> &DYND_UNUSED(tp_vars))
{
assign_error_mode errmode = ectx->errmode;
if (errmode != assign_error_nocheck &&
is_lossless_assignment(dst_tp, *src_tp)) {
errmode = assign_error_nocheck;
}
if (!dst_tp.is_builtin() || !src_tp->is_builtin() ||
errmode == assign_error_default) {
stringstream ss;
ss << "cannot assign from CUDA device with types " << *src_tp << " to "
<< dst_tp;
throw type_error(ss.str());
}
nd::cuda_device_to_host_assign_ck::make(ckb, kernreq, ckb_offset,
src_tp->get_data_size());
return make_builtin_type_assignment_kernel(
ckb, ckb_offset, dst_tp.without_memory_type().get_type_id(),
src_tp->without_memory_type().get_type_id(), kernel_request_single,
errmode);
}
示例5: make_assignment_kernel
size_t cfixed_dim_type::make_assignment_kernel(
ckernel_builder *ckb, intptr_t ckb_offset, const ndt::type &dst_tp,
const char *dst_arrmeta, const ndt::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;
ndt::type src_el_tp;
const char *src_el_arrmeta;
if (src_tp.get_ndim() < dst_tp.get_ndim()) {
kernels::strided_assign_ck *self =
kernels::strided_assign_ck::create(ckb, kernreq, ckb_offset);
self->m_size = get_fixed_dim_size();
self->m_dst_stride = get_fixed_stride();
// If the src has fewer dimensions, broadcast it across this one
self->m_src_stride = 0;
return ::make_assignment_kernel(
ckb, ckb_offset, m_element_tp,
dst_arrmeta + sizeof(cfixed_dim_type_arrmeta), src_tp, src_arrmeta,
kernel_request_strided, ectx);
} else if (src_tp.get_as_strided(src_arrmeta, &src_size, &src_stride,
&src_el_tp, &src_el_arrmeta)) {
kernels::strided_assign_ck *self =
kernels::strided_assign_ck::create(ckb, kernreq, ckb_offset);
self->m_size = get_fixed_dim_size();
self->m_dst_stride = get_fixed_stride();
self->m_src_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(
ckb, ckb_offset, m_element_tp,
dst_arrmeta + sizeof(cfixed_dim_type_arrmeta), src_el_tp,
src_el_arrmeta, kernel_request_strided, 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 {
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw dynd::type_error(ss.str());
}
}
示例6: get_dynamic_array_functions
void get_dynamic_array_functions(
const std::pair<std::string, gfunc::callable> **out_functions,
size_t *out_count) const
{
if (!m_value_type.is_builtin()) {
m_value_type.extended()->get_dynamic_array_functions(out_functions, out_count);
}
}
示例7: type_error
byteswap_type::byteswap_type(const ndt::type& value_type)
: base_expr_type(byteswap_type_id, expr_kind, value_type.get_data_size(),
value_type.get_data_alignment(), type_flag_scalar, 0),
m_value_type(value_type),
m_operand_type(ndt::make_fixedbytes(value_type.get_data_size(), value_type.get_data_alignment()))
{
if (!value_type.is_builtin()) {
throw dynd::type_error("byteswap_type: Only built-in types are supported presently");
}
}
示例8:
std::string pydynd::make_pep3118_format(intptr_t &out_itemsize, const ndt::type &tp, const char *arrmeta)
{
std::stringstream result;
// Specify native alignment/storage if it's a builtin scalar type
if (tp.is_builtin()) {
result << "@";
}
append_pep3118_format(out_itemsize, tp, arrmeta, result);
return result.str();
}
示例9: parse_json
nd::array dynd::parse_json(const ndt::type &tp, const char *json_begin, const char *json_end,
const eval::eval_context *ectx)
{
nd::array result;
result = nd::empty(tp);
parse_json(result, json_begin, json_end, ectx);
if (!tp.is_builtin()) {
tp.extended()->arrmeta_finalize_buffers(result.get()->metadata());
}
return result;
}
示例10: make_assignment_kernel
size_t dynd::make_assignment_kernel(
ckernel_builder *out, size_t offset_out,
const ndt::type& dst_tp, const char *dst_metadata,
const ndt::type& src_tp, const char *src_metadata,
kernel_request_t kernreq, assign_error_mode errmode,
const eval::eval_context *ectx)
{
if (errmode == assign_error_default && ectx != NULL) {
errmode = ectx->default_errmode;
}
if (dst_tp.is_builtin()) {
if (src_tp.is_builtin()) {
// If the casting can be done losslessly, disable the error check to find faster code paths
if (errmode != assign_error_none && is_lossless_assignment(dst_tp, src_tp)) {
errmode = assign_error_none;
}
if (dst_tp.extended() == src_tp.extended()) {
return make_pod_typed_data_assignment_kernel(out, offset_out,
dst_tp.get_data_size(), dst_tp.get_data_alignment(),
kernreq);
} else {
return make_builtin_type_assignment_kernel(out, offset_out,
dst_tp.get_type_id(), src_tp.get_type_id(),
kernreq, errmode);
}
} else {
return src_tp.extended()->make_assignment_kernel(out, offset_out,
dst_tp, dst_metadata,
src_tp, src_metadata,
kernreq, errmode, ectx);
}
} else {
return dst_tp.extended()->make_assignment_kernel(out, offset_out,
dst_tp, dst_metadata,
src_tp, src_metadata,
kernreq, errmode, ectx);
}
}
示例11: make_value_to_pointer_assignment_kernel
size_t dynd::make_value_to_pointer_assignment_kernel(void *ckb,
intptr_t ckb_offset,
const ndt::type &tp,
kernel_request_t kernreq)
{
if (tp.is_builtin()) {
return make_builtin_value_to_pointer_assignment_kernel(
ckb, ckb_offset, tp.get_type_id(), kernreq);
}
stringstream ss;
ss << "make_value_to_pointer_assignment_kernel: unrecognized type " << tp;
throw runtime_error(ss.str());
}
示例12: make_assignment_kernel
intptr_t dynd::make_assignment_kernel(
void *ckb, intptr_t ckb_offset, const ndt::type &dst_tp,
const char *dst_arrmeta, const ndt::type &src_tp, const char *src_arrmeta,
kernel_request_t kernreq, const eval::eval_context *ectx)
{
if (dst_tp.is_builtin()) {
if (src_tp.is_builtin()) {
nd::callable &child = nd::assign::overload(dst_tp, src_tp);
return child.get()->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 {
return src_tp.extended()->make_assignment_kernel(
ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq,
ectx);
}
} else {
return dst_tp.extended()->make_assignment_kernel(
ckb, ckb_offset, dst_tp, dst_arrmeta, src_tp, src_arrmeta, kernreq,
ectx);
}
}
示例13: make_strided_dim
ndt::type ndt::make_strided_dim(const ndt::type& element_tp)
{
// Static instances of the types, which have a reference
// count > 0 for the lifetime of the program. This static
// construction is inside a function to ensure correct creation
// order during startup.
static static_strided_dims ssd;
if (element_tp.is_builtin()) {
return ssd.static_builtins_instance[element_tp.get_type_id()];
} else {
return ndt::type(new strided_dim_type(element_tp), false);
}
}
示例14: make_assignment_kernel
size_t datetime_type::make_assignment_kernel(
ckernel_builder *out, size_t offset_out,
const ndt::type& dst_tp, const char *dst_metadata,
const ndt::type& src_tp, const char *src_metadata,
kernel_request_t kernreq, assign_error_mode errmode,
const eval::eval_context *ectx) const
{
if (this == dst_tp.extended()) {
if (src_tp == dst_tp) {
return make_pod_typed_data_assignment_kernel(out, offset_out,
get_data_size(), get_data_alignment(), kernreq);
} else if (src_tp.get_kind() == string_kind) {
// Assignment from strings
return make_string_to_datetime_assignment_kernel(out, offset_out,
dst_tp, dst_metadata,
src_tp, src_metadata,
kernreq, errmode, ectx);
} else if (src_tp.get_kind() == struct_kind) {
// Convert to struct using the "struct" property
return ::make_assignment_kernel(out, offset_out,
ndt::make_property(dst_tp, "struct"), dst_metadata,
src_tp, src_metadata,
kernreq, errmode, ectx);
} else if (!src_tp.is_builtin()) {
return src_tp.extended()->make_assignment_kernel(out, offset_out,
dst_tp, dst_metadata,
src_tp, src_metadata,
kernreq, errmode, ectx);
}
} else {
if (dst_tp.get_kind() == string_kind) {
// Assignment to strings
return make_datetime_to_string_assignment_kernel(out, offset_out,
dst_tp, dst_metadata,
src_tp, src_metadata,
kernreq, errmode, ectx);
} else if (dst_tp.get_kind() == struct_kind) {
// Convert to struct using the "struct" property
return ::make_assignment_kernel(out, offset_out,
dst_tp, dst_metadata,
ndt::make_property(src_tp, "struct"), src_metadata,
kernreq, errmode, ectx);
}
// TODO
}
stringstream ss;
ss << "Cannot assign from " << src_tp << " to " << dst_tp;
throw runtime_error(ss.str());
}
示例15: parse_json
nd::array dynd::parse_json(const ndt::type &tp, const char *json_begin,
const char *json_end, const eval::eval_context *ectx)
{
nd::array result;
if (tp.get_data_size() != 0) {
result = nd::empty(tp);
parse_json(result, json_begin, json_end, ectx);
if (!tp.is_builtin()) {
tp.extended()->metadata_finalize_buffers(result.get_ndo_meta());
}
result.flag_as_immutable();
return result;
} else {
stringstream ss;
ss << "The dynd type provided to parse_json, " << tp << ", cannot be used because it requires additional shape information";
throw runtime_error(ss.str());
}
}