当前位置: 首页>>代码示例>>C++>>正文


C++ TypeDesc类代码示例

本文整理汇总了C++中TypeDesc的典型用法代码示例。如果您正苦于以下问题:C++ TypeDesc类的具体用法?C++ TypeDesc怎么用?C++ TypeDesc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TypeDesc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: type_info_get_type

VM_Data_Type type_info_get_type(Type_Info_Handle tih)
{
    assert(tih);
    TypeDesc* td = (TypeDesc*)tih;
    switch (td->get_kind()) {
    case K_S1:               return VM_DATA_TYPE_INT8;
    case K_S2:               return VM_DATA_TYPE_INT16;
    case K_S4:               return VM_DATA_TYPE_INT32;
    case K_S8:               return VM_DATA_TYPE_INT64;
    case K_Sp:               return VM_DATA_TYPE_INTPTR;
    case K_U1:               return VM_DATA_TYPE_UINT8;
    case K_U2:               return VM_DATA_TYPE_UINT16;
    case K_U4:               return VM_DATA_TYPE_UINT32;
    case K_U8:               return VM_DATA_TYPE_UINT64;
    case K_Up:               return VM_DATA_TYPE_UINTPTR;
    case K_F4:               return VM_DATA_TYPE_F4;
    case K_F8:               return VM_DATA_TYPE_F8;
    case K_Char:             return VM_DATA_TYPE_CHAR;
    case K_Boolean:          return VM_DATA_TYPE_BOOLEAN;
    case K_Void:             return VM_DATA_TYPE_VOID;
    case K_Object:           return VM_DATA_TYPE_CLASS;
    case K_Vector:           return VM_DATA_TYPE_ARRAY;
    case K_UnboxedValue:     return VM_DATA_TYPE_VALUE;
    case K_UnmanagedPointer: return VM_DATA_TYPE_UP;
    case K_ManagedPointer:   return VM_DATA_TYPE_MP;
    // The rest are not implemented in the VM_Data_Type scheme
    case K_Array:
    case K_MethodPointer:
    case K_TypedRef:
    default:
        DIE(("Invalid vm data type"));
        return VM_DATA_TYPE_INVALID;
    }
} //type_info_get_type
开发者ID:,项目名称:,代码行数:34,代码来源:

示例2: type_info_is_managed_pointer

BOOLEAN type_info_is_managed_pointer(Type_Info_Handle tih)
{
    assert(tih);
    TypeDesc* td = (TypeDesc*)tih;
    assert(td);
    return td->is_managed_pointer();
} //type_info_is_managed_pointer
开发者ID:,项目名称:,代码行数:7,代码来源:

示例3: spec

bool
RLAOutput::write_scanline (int y, int z, TypeDesc format,
                           const void *data, stride_t xstride)
{
    m_spec.auto_stride (xstride, format, spec().nchannels);
    const void *origdata = data;
    data = to_native_scanline (format, data, xstride, m_scratch);
    if (data == origdata) {
        m_scratch.assign ((unsigned char *)data,
                          (unsigned char *)data+m_spec.scanline_bytes());
        data = &m_scratch[0];
    }
    
    // store the offset to the scanline.  We'll swap_endian if necessary
    // when we go to actually write it.
    m_sot[m_spec.height - y - 1] = (uint32_t)ftell (m_file);

    size_t pixelsize = m_spec.pixel_bytes (true /*native*/);
    int offset = 0;
    for (int c = 0;  c < m_spec.nchannels;  ++c) {
        TypeDesc chantype = m_spec.channelformats.size() ?
            m_spec.channelformats[c] : m_spec.format;
        int bits = (c < m_rla.NumOfColorChannels) ? m_rla.NumOfChannelBits
            : (c < (m_rla.NumOfColorChannels+m_rla.NumOfMatteBits)) ? m_rla.NumOfMatteBits
            : m_rla.NumOfAuxBits;
        if (!encode_channel ((unsigned char *)data + offset, pixelsize,
                             chantype, bits))
            return false;
        offset += chantype.size();
    }

    return true;
}
开发者ID:amanforindia,项目名称:oiio,代码行数:33,代码来源:rlaoutput.cpp

示例4: oiio_attribute_tuple_typed

bool
oiio_attribute_tuple_typed (const std::string &name,
                            TypeDesc type, tuple &obj)
{
    if (type.basetype == TypeDesc::INT) {
        std::vector<int> vals;
        py_to_stdvector (vals, obj);
        if (vals.size() == type.numelements()*type.aggregate)
            return OIIO::attribute (name, type, &vals[0]);
        return false;
    }
    if (type.basetype == TypeDesc::FLOAT) {
        std::vector<float> vals;
        py_to_stdvector (vals, obj);
        if (vals.size() == type.numelements()*type.aggregate)
            return OIIO::attribute (name, type, &vals[0]);
        return false;
    }
    if (type.basetype == TypeDesc::STRING) {
        std::vector<std::string> vals;
        py_to_stdvector (vals, obj);
        if (vals.size() == type.numelements()*type.aggregate) {
            std::vector<ustring> u;
            for (size_t i = 0, e = vals.size(); i < e; ++i)
                u.push_back (ustring(vals[i]));
            return OIIO::attribute (name, type, &u[0]);
        }
        return false;
    }
    return false;
}
开发者ID:Vertexwahn,项目名称:appleseed-deps,代码行数:31,代码来源:py_oiio.cpp

示例5: read_native_scanline

bool 
ImageInput::read_scanline (int y, int z, TypeDesc format, void *data,
                           stride_t xstride)
{
    // native_pixel_bytes is the size of a pixel in the FILE, including
    // the per-channel format.
    stride_t native_pixel_bytes = (stride_t) m_spec.pixel_bytes (true);
    // perchanfile is true if the file has different per-channel formats
    bool perchanfile = m_spec.channelformats.size();
    // native_data is true if the user asking for data in the native format
    bool native_data = (format == TypeDesc::UNKNOWN ||
                        (format == m_spec.format && !perchanfile));
    if (native_data && xstride == AutoStride)
        xstride = native_pixel_bytes;
    else
        m_spec.auto_stride (xstride, format, m_spec.nchannels);
    // Do the strides indicate that the data area is contiguous?
    bool contiguous = (native_data && xstride == native_pixel_bytes) ||
        (!native_data && xstride == (stride_t)m_spec.pixel_bytes(false));

    // If user's format and strides are set up to accept the native data
    // layout, read the scanline directly into the user's buffer.
    if (native_data && contiguous)
        return read_native_scanline (y, z, data);

    // Complex case -- either changing data type or stride
    int scanline_values = m_spec.width * m_spec.nchannels;
    unsigned char *buf = (unsigned char *) alloca (m_spec.scanline_bytes(true));
    bool ok = read_native_scanline (y, z, buf);
    if (! ok)
        return false;
    if (! perchanfile) {
        // No per-channel formats -- do the conversion in one shot
        ok = contiguous 
            ? convert_types (m_spec.format, buf, format, data, scanline_values)
            : convert_image (m_spec.nchannels, m_spec.width, 1, 1, 
                             buf, m_spec.format, AutoStride, AutoStride, AutoStride,
                             data, format, xstride, AutoStride, AutoStride);
    } else {
        // Per-channel formats -- have to convert/copy channels individually
        ASSERT (m_spec.channelformats.size() == (size_t)m_spec.nchannels);
        size_t offset = 0;
        for (int c = 0;  ok && c < m_spec.nchannels;  ++c) {
            TypeDesc chanformat = m_spec.channelformats[c];
            ok = convert_image (1 /* channels */, m_spec.width, 1, 1, 
                                buf+offset, chanformat, 
                                native_pixel_bytes, AutoStride, AutoStride,
                                (char *)data + c*format.size(),
                                format, xstride, AutoStride, AutoStride);
            offset += chanformat.size ();
        }
    }

    if (! ok)
        error ("ImageInput::read_scanline : no support for format %s",
               m_spec.format.c_str());
    return ok;
}
开发者ID:danwexler,项目名称:oiio,代码行数:58,代码来源:imageinput.cpp

示例6: name

void
OSOReaderToMaster::symbol (SymType symtype, TypeSpec typespec, const char *name_)
{
    ustring name(name_);
    Symbol sym (name, typespec, symtype);
    TypeDesc t = typespec.simpletype();
    int nvals = t.aggregate * (t.is_unsized_array() ? 1 : t.numelements());
    if (sym.symtype() == SymTypeParam || sym.symtype() == SymTypeOutputParam) {
        // Skip structs for now, they're just placeholders
        if (typespec.is_structure()) {
        }
        else if (typespec.simpletype().basetype == TypeDesc::FLOAT) {
            sym.dataoffset ((int) m_master->m_fdefaults.size());
            expand (m_master->m_fdefaults, nvals);
        } else if (typespec.simpletype().basetype == TypeDesc::INT) {
            sym.dataoffset ((int) m_master->m_idefaults.size());
            expand (m_master->m_idefaults, nvals);
        } else if (typespec.simpletype().basetype == TypeDesc::STRING) {
            sym.dataoffset ((int) m_master->m_sdefaults.size());
            expand (m_master->m_sdefaults, nvals);
        } else if (typespec.is_closure_based()) {
            // Closures are pointers, so we allocate a string default taking
            // adventage of their default being NULL as well.
            sym.dataoffset ((int) m_master->m_sdefaults.size());
            expand (m_master->m_sdefaults, nvals);
        } else {
            ASSERT (0 && "unexpected type");
        }
    }
    if (sym.symtype() == SymTypeConst) {
        if (typespec.simpletype().basetype == TypeDesc::FLOAT) {
            sym.dataoffset ((int) m_master->m_fconsts.size());
            expand (m_master->m_fconsts, nvals);
        } else if (typespec.simpletype().basetype == TypeDesc::INT) {
            sym.dataoffset ((int) m_master->m_iconsts.size());
            expand (m_master->m_iconsts, nvals);
        } else if (typespec.simpletype().basetype == TypeDesc::STRING) {
            sym.dataoffset ((int) m_master->m_sconsts.size());
            expand (m_master->m_sconsts, nvals);
        } else {
            ASSERT (0 && "unexpected type");
        }
    }
#if 0
    // FIXME -- global_heap_offset is quite broken.  But also not necessary.
    // We made need to fix this later.
    if (sym.symtype() == SymTypeGlobal) {
        sym.dataoffset (m_shadingsys.global_heap_offset (sym.name()));
    }
#endif
    sym.lockgeom (m_shadingsys.lockgeom_default());
    m_master->m_symbols.push_back (sym);
    m_symmap[name] = int(m_master->m_symbols.size()) - 1;
    // Start the index at which we add specified defaults
    m_sym_default_index = 0;
}
开发者ID:ElaraFX,项目名称:OpenShadingLanguage,代码行数:56,代码来源:loadshader.cpp

示例7: type_info_get_class

Class_Handle type_info_get_class(Type_Info_Handle tih)
{
    TypeDesc* td = (TypeDesc*)tih;
    assert(td);
    Class* c = td->load_type_desc();
    if(!c) return NULL;
    if(!c->verify(VM_Global_State::loader_env)) return NULL;
    if(!c->prepare(VM_Global_State::loader_env)) return NULL;
    return c;
} //type_info_get_class
开发者ID:,项目名称:,代码行数:10,代码来源:

示例8: read_native_tile

bool 
ImageInput::read_tile (int x, int y, int z, TypeDesc format, void *data,
                       stride_t xstride, stride_t ystride, stride_t zstride)
{
    stride_t native_pixel_bytes = (stride_t) m_spec.pixel_bytes (true);
    if (format == TypeDesc::UNKNOWN && xstride == AutoStride)
        xstride = native_pixel_bytes;
    m_spec.auto_stride (xstride, ystride, zstride, format, m_spec.nchannels,
                        m_spec.tile_width, m_spec.tile_height);
    bool contiguous = (xstride == native_pixel_bytes &&
                       ystride == xstride*m_spec.tile_width &&
                       (zstride == ystride*m_spec.tile_height || zstride == 0));

    // If user's format and strides are set up to accept the native data
    // layout, read the tile directly into the user's buffer.
    bool rightformat = (format == TypeDesc::UNKNOWN) ||
        (format == m_spec.format && m_spec.channelformats.empty());
    if (rightformat && contiguous)
        return read_native_tile (x, y, z, data);  // Simple case

    // Complex case -- either changing data type or stride
    int tile_values = m_spec.tile_width * m_spec.tile_height * 
                      std::max(1,m_spec.tile_depth) * m_spec.nchannels;

    boost::scoped_array<char> buf (new char [m_spec.tile_bytes(true)]);
    bool ok = read_native_tile (x, y, z, &buf[0]);
    if (! ok)
        return false;
    if (m_spec.channelformats.empty()) {
        // No per-channel formats -- do the conversion in one shot
        ok = contiguous 
            ? convert_types (m_spec.format, &buf[0], format, data, tile_values)
            : convert_image (m_spec.nchannels, m_spec.tile_width, m_spec.tile_height, m_spec.tile_depth, 
                             &buf[0], m_spec.format, AutoStride, AutoStride, AutoStride,
                             data, format, xstride, ystride, zstride);
    } else {
        // Per-channel formats -- have to convert/copy channels individually
        size_t offset = 0;
        for (size_t c = 0;  c < m_spec.channelformats.size();  ++c) {
            TypeDesc chanformat = m_spec.channelformats[c];
            ok = convert_image (1 /* channels */, m_spec.tile_width,
                                m_spec.tile_height, m_spec.tile_depth,
                                &buf[offset], chanformat, 
                                native_pixel_bytes, AutoStride, AutoStride,
                                (char *)data + c*m_spec.format.size(),
                                format, xstride, AutoStride, AutoStride);
            offset += chanformat.size ();
        }
    }

    if (! ok)
        error ("ImageInput::read_tile : no support for format %s",
               m_spec.format.c_str());
    return ok;
}
开发者ID:angeljimenez,项目名称:oiio,代码行数:55,代码来源:imageinput.cpp

示例9: type_desc_create_from_java_descriptor

TypeDesc* type_desc_create_from_java_descriptor(const char* d, ClassLoader* loader)
{
    Global_Env* env = VM_Global_State::loader_env;
    switch (*d) 
    {
    case 'B': return env->bootstrap_class_loader->get_primitive_type(K_S1);
    case 'C': return env->bootstrap_class_loader->get_primitive_type(K_Char);
    case 'D': return env->bootstrap_class_loader->get_primitive_type(K_F8);
    case 'F': return env->bootstrap_class_loader->get_primitive_type(K_F4);
    case 'I': return env->bootstrap_class_loader->get_primitive_type(K_S4);
    case 'J': return env->bootstrap_class_loader->get_primitive_type(K_S8);
    case 'S': return env->bootstrap_class_loader->get_primitive_type(K_S2);
    case 'Z': return env->bootstrap_class_loader->get_primitive_type(K_Boolean);
    case 'V': return env->bootstrap_class_loader->get_primitive_type(K_Void);
    case 'L':
        {
            const char* sn = d+1;
            const char* en = sn;
            while (en[0]!=';') {
                en++;
            }
            unsigned len = (unsigned)(en-sn);
            String* str = env->string_pool.lookup(sn, len);

            assert(loader);
            loader->LockTypesCache();
            TypeDesc** tdres = loader->GetJavaTypes()->Lookup(str);
            if (tdres)
            {
                assert (*tdres);
                loader->UnlockTypesCache();
                return *tdres;
            }
            TypeDesc* td = new TypeDesc(K_Object, NULL, NULL, str, loader, NULL);
            assert(td);
            loader->GetJavaTypes()->Insert(str, td);
            loader->UnlockTypesCache();
            return td;
        }
    case '[':
        {
            // descriptor is checked in recursion
            TypeDesc* et = type_desc_create_from_java_descriptor(d+1, loader);
            if( !et ) {
                return NULL;
            }
            return et->type_desc_create_vector();
        }
    default:
        DIE(("Bad type descriptor"));
        return NULL;
    }
}
开发者ID:,项目名称:,代码行数:53,代码来源:

示例10: memset

bool
SimpleRenderer::get_camera_shutter_close (ShaderGlobals *sg, bool derivs, ustring object,
                                    TypeDesc type, ustring name, void *val)
{
    if (type == TypeDesc::TypeFloat) {
        ((float *)val)[0] = m_shutter[1];
        if (derivs)
            memset ((char *)val+type.size(), 0, 2*type.size());
        return true;
    }
    return false;
}
开发者ID:abergmeier,项目名称:OpenShadingLanguage,代码行数:12,代码来源:simplerend.cpp

示例11: imagesize_t

bool
ImageOutput::copy_to_image_buffer (int xbegin, int xend, int ybegin, int yend,
                                   int zbegin, int zend, TypeDesc format,
                                   const void *data, stride_t xstride,
                                   stride_t ystride, stride_t zstride,
                                   void *image_buffer, TypeDesc buf_format)
{
    const ImageSpec &spec (this->spec());
    if (buf_format == TypeDesc::UNKNOWN)
        buf_format = spec.format;
    spec.auto_stride (xstride, ystride, zstride, format, spec.nchannels,
                      spec.width, spec.height);
    stride_t buf_xstride = spec.nchannels * buf_format.size();
    stride_t buf_ystride = buf_xstride * spec.width;
    stride_t buf_zstride = buf_ystride * spec.height;
    stride_t offset = (xbegin-spec.x)*buf_xstride
                    + (ybegin-spec.y)*buf_ystride
                    + (zbegin-spec.z)*buf_zstride;
    int width = xend-xbegin, height = yend-ybegin, depth = zend-zbegin;
    imagesize_t npixels = imagesize_t(width) * imagesize_t(height) * imagesize_t(depth);

    // Add dither if requested -- requires making a temporary staging area
    boost::scoped_array<float> ditherarea;
    unsigned int dither = spec.get_int_attribute ("oiio:dither", 0);
    if (dither && format.is_floating_point() &&
            buf_format.basetype == TypeDesc::UINT8) {
        stride_t pixelsize = spec.nchannels * sizeof(float);
        ditherarea.reset (new float [pixelsize * npixels]);
        OIIO::convert_image (spec.nchannels, width, height, depth,
                             data, format, xstride, ystride, zstride,
                             ditherarea.get(), TypeDesc::FLOAT,
                             pixelsize, pixelsize*width,
                             pixelsize*width*height);
        data = ditherarea.get();
        format = TypeDesc::FLOAT;
        xstride = pixelsize;
        ystride = xstride * width;
        zstride = ystride * height;
        float ditheramp = spec.get_float_attribute ("oiio:ditheramplitude", 1.0f/255.0f);
        OIIO::add_dither (spec.nchannels, width, height, depth, (float *)data,
                          pixelsize, pixelsize*width, pixelsize*width*height,
                          ditheramp, spec.alpha_channel, spec.z_channel,
                          dither, 0, xbegin, ybegin, zbegin);
    }

    return OIIO::convert_image (spec.nchannels, width, height, depth,
                                data, format, xstride, ystride, zstride,
                                (char *)image_buffer + offset, buf_format,
                                buf_xstride, buf_ystride, buf_zstride);
}
开发者ID:LumaPictures,项目名称:oiio,代码行数:50,代码来源:imageoutput.cpp

示例12: type_info_is_resolved

BOOLEAN type_info_is_resolved(Type_Info_Handle tih) {
    TypeDesc* td = (TypeDesc*)tih;
    switch (td->get_kind()) {
    case K_Vector:
        if (td->get_element_type()->is_primitive()) {
            return true;
        }
        return type_info_is_resolved(td->get_element_type());
    case K_Object:
        return td->is_loaded();
    default:
        LDIE(73, "Unexpected kind");
        return 0;
    }
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例13: type_info_get_num_array_dimensions

U_32 type_info_get_num_array_dimensions(Type_Info_Handle tih) {
    TypeDesc* td = (TypeDesc*)tih;
    if (td->get_kind() == K_Vector) {
        const String* name = td->get_type_name();
        U_32 res = 0;
        if (name == NULL) {
            res = 1 + type_info_get_num_array_dimensions(td->get_element_type());
        } else {
            res = countLeadingChars(name->bytes, '[');
        }
        assert(res<=255);
        return res;
    }
    return 0;
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例14: type_info_get_type_info

Type_Info_Handle type_info_get_type_info(Type_Info_Handle tih)
{
    TypeDesc* td = (TypeDesc*)tih;
    assert(td);
    switch (td->get_kind()) {
    case K_Vector:
    case K_Array:
        return td->get_element_type();
    case K_ManagedPointer:
    case K_UnmanagedPointer:
        return td->get_pointed_to_type();
    default:
        LDIE(73, "Unexpected kind");
        return 0;
    }
} //type_info_get_type_info
开发者ID:,项目名称:,代码行数:16,代码来源:

示例15: object

object
ImageInputWrap::read_tiles (int xbegin, int xend, int ybegin, int yend,
                            int zbegin, int zend, int chbegin, int chend,
                            TypeDesc format)
{
    // Allocate our own temp buffer and try to read the scanline into it.
    // If the read fails, return None.
    const ImageSpec &spec = m_input->spec();
    if (format.basetype == TypeDesc::UNKNOWN)
        format = spec.format;
    chend = clamp (chend, chbegin+1, spec.nchannels);
    int nchans = chend - chbegin;
    size_t size = (size_t) ((xend-xbegin) * (yend-ybegin) * 
                            (zend-zbegin) * nchans * format.size());
    char *data = new char[size];
    bool ok;
    {
        ScopedGILRelease gil;
        ok = m_input->read_tiles (xbegin, xend, ybegin, yend,
                                  zbegin, zend, chbegin, chend, format, data);
    }
    if (! ok) {
        delete [] data;  // never mind
        return object(handle<>(Py_None));
    }

    object array = C_array_to_Python_array (data, format, size);

    // clean up and return the array handle
    delete [] data;
    return array;
}
开发者ID:Vertexwahn,项目名称:appleseed-deps,代码行数:32,代码来源:py_imageinput.cpp


注:本文中的TypeDesc类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。