• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ r_type函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_font_name

/* If the font name isn't a name or a string, return an empty string. */
void
get_font_name(const gs_memory_t *mem, ref * pfname, const ref * op)
{
    switch (r_type(op)) {
        case t_string:
            *pfname = *op;
            break;
        case t_name:
            name_string_ref(mem, op, pfname);
            break;
        default:
            /* This is weird, but legal.... */
            make_empty_string(pfname, a_readonly);
    }
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:16,代码来源:zbfont.c


示例2: gs_font_map_glyph_by_dict

static gs_char
gs_font_map_glyph_by_dict(const gs_memory_t *mem, const ref *map, gs_glyph glyph)
{
    ref *v, n;
    if (glyph >= gs_min_cid_glyph) {
        uint cid = glyph - gs_min_cid_glyph;

        if (dict_find_string(map, "CIDCount", &v) > 0) {
            /* This is a CIDDEcoding resource. */
            make_int(&n, cid / 256);
            if (dict_find(map, &n, &v) > 0) {
                ref vv;

                if (array_get(mem, v, cid % 256, &vv) == 0 && r_type(&vv) == t_integer)
                    return vv.value.intval;
            }
            return GS_NO_CHAR; /* Absent in the map. */
        }
        /* This is GlyphNames2Unicode dictionary. */
        make_int(&n, cid);
    } else
        name_index_ref(mem, glyph, &n);
     if (dict_find(map, &n, &v) > 0) {
        if (r_has_type(v, t_string)) {
            int i, l = r_size(v);
            gs_char c = 0;

            for (i = 0; i < l; i++)
                c = (c << 8) | v->value.const_bytes[i];
            return c;
        }
        if (r_type(v) == t_integer)
            return v->value.intval;
    }
    return GS_NO_CHAR; /* Absent in the map. */
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:36,代码来源:zbfont.c


示例3: test_sra

void test_sra()
{
	printf("===test SRA===\n");
	struct cpu_struct cpu;
	memset(&cpu, 0, sizeof(cpu));
	cpu.current_ins.rt = 1;
	cpu.current_ins.rd = 2;
	cpu.current_ins.shamt = 3;
	cpu.current_ins.funct = 0x03;
	cpu.reg[1] = 0x80000000;
	r_type(&cpu);
	printf("%s\n", word_to_binary(cpu.reg[1], 0, 31));
	printf("%s\n", word_to_binary(cpu.reg[2], 0, 31));
	assert(cpu.reg[2] == 0xf0000000);
	printf("pass\n\n");
}
开发者ID:ChienYuLu,项目名称:archi_project,代码行数:16,代码来源:test_r_type.c


示例4: real_param

/* If an error is returned, the return value is not updated. */
int
real_param(const ref * op, double *pparam)
{
    switch (r_type(op)) {
	case t_integer:
	    *pparam = op->value.intval;
	    break;
	case t_real:
	    *pparam = op->value.realval;
	    break;
        case t__invalid:
	    return_error(e_stackunderflow);
	default:
	    return_error(e_typecheck);
    }
    return 0;
}
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:18,代码来源:iutil.c


示例5: znot

/* <int> not <int> */
int
znot(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;

    switch (r_type(op)) {
	case t_boolean:
	    op->value.boolval = !op->value.boolval;
	    break;
	case t_integer:
	    op->value.intval = ~op->value.intval;
	    break;
	default:
	    return_op_typecheck(op);
    }
    return 0;
}
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:18,代码来源:zrelbit.c


示例6: float_params

/* float_params doesn't bother to keep track of the mask. */
int
float_params(const ref * op, int count, float *pval)
{
    for (pval += count; --count >= 0; --op)
	switch (r_type(op)) {
	    case t_real:
		*--pval = op->value.realval;
		break;
	    case t_integer:
		*--pval = (float)op->value.intval;
		break;
	    case t__invalid:
		return_error(e_stackunderflow);
	    default:
		return_error(e_typecheck);
	}
    return 0;
}
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:19,代码来源:iutil.c


示例7: zfont_encode_char

/* Encode a character. */
gs_glyph
zfont_encode_char(gs_font *pfont, gs_char chr, gs_glyph_space_t gspace)
{
    font_data *pdata = pfont_data(pfont);
    const ref *pencoding = &pdata->Encoding;
    ulong index = chr;	/* work around VAX widening bug */
    ref cname;
    int code = array_get(pfont->memory, pencoding, (long)index, &cname);

    if (code < 0 || !r_has_type(&cname, t_name))
        return gs_no_glyph;
    if (pfont->FontType == ft_user_defined && r_type(&pdata->BuildGlyph) == t_null) {
        ref nsref, tname;

        name_string_ref(pfont->memory, &cname, &nsref);
        if (r_size(&nsref) == 7 &&
            !memcmp(nsref.value.const_bytes, ".notdef", r_size(&nsref))) {
            /* A special support for high level devices.
               They need a glyph name but the font doesn't provide one
               due to an instandard BuildChar.
               Such fonts don't conform to PLRM section 5.3.7,
               but we've got real examples that we want to handle (Bug 686982).
               Construct a name here.
               Low level devices don't pass here, because regular PS interpretation
               doesn't need such names.
            */
            char buf[20];
            int code;

            if (gspace == GLYPH_SPACE_NOGEN)
                return gs_no_glyph;
            sprintf(buf, "j%ld", chr); /* 'j' is arbutrary. */
            code = name_ref(pfont->memory, (const byte *)buf, strlen(buf), &tname, 1);
            if (code < 0) {
                /* Can't propagate the error due to interface limitation,
                   return with .notdef */
            } else
                cname = tname;
        }
    }
    return (gs_glyph)name_index(pfont->memory, &cname);
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:43,代码来源:zbfont.c


示例8: dict_int_null_param

/* a missing value will return e_undefined rather than 1. */
int
dict_int_null_param(const ref * pdict, const char *kstr, int minval,
                    int maxval, int defaultval, int *pvalue)
{
    ref *pdval;
    int code, ival;

    if (pdict == 0 || dict_find_string(pdict, kstr, &pdval) <= 0) {
        ival = defaultval;
        code = 1;
    } else {
        switch (r_type(pdval)) {
            case t_integer:
                ival = pdval->value.intval;
                break;
            case t_real:
                /* Allow an integral real, because Fontographer */
                /* (which violates the Adobe specs in other ways */
                /* as well) sometimes generates output that */
                /* needs this. */
                if (pdval->value.realval < minval || pdval->value.realval > maxval)
                    return_error(e_rangecheck);
                ival = (long)pdval->value.realval;
                if (ival != pdval->value.realval)
                    return_error(e_rangecheck);
                break;
            case t_null:
                return 2;
            default:
                return_error(e_typecheck);
        }
        code = 0;
    }
    if (ival < minval || ival > maxval) {
        if (code == 1)
            return_error(e_undefined);
        else
            return_error(e_rangecheck);
    }
    *pvalue = (int)ival;
    return code;
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:43,代码来源:idparam.c


示例9: zxor

/* <int1> <int2> xor <int> */
int
zxor(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;

    switch (r_type(op)) {
	case t_boolean:
	    check_type(op[-1], t_boolean);
	    op[-1].value.boolval ^= op->value.boolval;
	    break;
	case t_integer:
	    check_type(op[-1], t_integer);
	    op[-1].value.intval ^= op->value.intval;
	    break;
	default:
	    return_op_typecheck(op);
    }
    pop(1);
    return 0;
}
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:21,代码来源:zrelbit.c


示例10: dict_float_param

/* Return 0 if found, 1 if defaulted, <0 if wrong type. */
int
dict_float_param(const ref * pdict, const char *kstr,
                 floatp defaultval, float *pvalue)
{
    ref *pdval;

    if (pdict == 0 || dict_find_string(pdict, kstr, &pdval) <= 0) {
        *pvalue = defaultval;
        return 1;
    }
    switch (r_type(pdval)) {
        case t_integer:
            *pvalue = (float)pdval->value.intval;
            return 0;
        case t_real:
            *pvalue = pdval->value.realval;
            return 0;
    }
    return_error(e_typecheck);
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:21,代码来源:idparam.c


示例11: dict_int_array_check_param

/* See idparam.h for specification. */
int
dict_int_array_check_param(const gs_memory_t *mem, const ref * pdict,
   const char *kstr, uint len, int *ivec, int under_error, int over_error)
{
    ref pa, *pdval;
    uint size;
    int i, code;

    if (pdict == 0 || dict_find_string(pdict, kstr, &pdval) <= 0)
        return 0;
    if (!r_is_array(pdval))
        return_error(e_typecheck);
    size = r_size(pdval);
    if (size > len)
        return_error(over_error);
    for (i = 0; i < size; i++) {
        code = array_get(mem, pdval, i, &pa);
        if (code < 0)
            return code;
        /* See dict_int_param above for why we allow reals here. */
        switch (r_type(&pa)) {
            case t_integer:
                if (pa.value.intval != (int)pa.value.intval)
                    return_error(e_rangecheck);
                ivec[i] = (int)pa.value.intval;
                break;
            case t_real:
                if (pa.value.realval < min_int ||
                    pa.value.realval > max_int ||
                    pa.value.realval != (int)pa.value.realval
                    )
                    return_error(e_rangecheck);
                ivec[i] = (int)pa.value.realval;
                break;
            default:
                return_error(e_typecheck);
        }
    }
    return (size == len || under_error >= 0 ? size :
            gs_note_error(under_error));
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:42,代码来源:idparam.c


示例12: refs_clear_reloc

/* Clear the relocation for a ref object. */
static void
refs_clear_reloc(obj_header_t *hdr, uint size)
{
    ref_packed *rp = (ref_packed *) (hdr + 1);
    ref_packed *end = (ref_packed *) ((byte *) rp + size);

    while (rp < end) {
	if (r_is_packed(rp))
	    rp++;
	else {
	    /* Full-size ref.  Store the relocation here if possible. */
	    ref *const pref = (ref *)rp;

	    if (!ref_type_uses_size_or_null(r_type(pref))) {
		if_debug1('8', "  [8]clearing reloc at 0x%lx\n", (ulong) rp);
		r_set_size(pref, 0);
	    }
	    rp += packed_per_ref;
	}
    }
}
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:22,代码来源:igcref.c


示例13: obj_string_data

/*
 * Set *pchars and *plen to point to the data of a name or string, and
 * return 0.  If the object isn't a name or string, return e_typecheck.
 * If the object is a string without read access, return e_invalidaccess.
 */
int
obj_string_data(const gs_memory_t *mem, const ref *op, const byte **pchars, uint *plen)
{
    switch (r_type(op)) {
    case t_name: {
	ref nref;

	name_string_ref(mem, op, &nref);
	*pchars = nref.value.bytes;
	*plen = r_size(&nref);
	return 0;
    }
    case t_string:
	check_read(*op);
	*pchars = op->value.bytes;
	*plen = r_size(op);
	return 0;
    default:
	return_error(e_typecheck);
    }
}
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:26,代码来源:iutil.c


示例14: test_add

void test_add()
{
	printf("===test ADD===\n");
	struct cpu_struct cpu;
	memset(&cpu, 0, sizeof(cpu));
	cpu.current_ins.rs = 1;
	cpu.current_ins.rt = 2;
	cpu.current_ins.rd = 3;
	cpu.current_ins.funct = 0x20;
	int i;
	for (i = 0; i < 100; i++) {
		int a = rand();
		int b = rand();
		cpu.reg[1] = a;
		cpu.reg[2] = b;
		r_type(&cpu);
		printf("%d + %d: %d\n", a, b, cpu.reg[3]);
		assert(cpu.reg[3] == a+b);
	}
	printf("pass\n\n");
}
开发者ID:ChienYuLu,项目名称:archi_project,代码行数:21,代码来源:test_r_type.c


示例15: num_array_get

/* or an error if the format is invalid. */
int
num_array_get(const ref *op, int format, uint index, ref *np)
{	if ( format == num_array )
	  {	int code = array_get(op, (long)index, np);
		if ( code < 0 )
		  return t_null;
		switch ( r_type(np) )
		  {
		  case t_integer:
			return t_integer;
		  case t_real:
			return t_real;
		  default:
			return_error(e_rangecheck);
		  }
	  }
	else
	  {	uint nbytes = encoded_number_bytes(format);
		if ( index >= (r_size(op) - 4) / nbytes )
		  return t_null;
		return sdecode_number(op->value.bytes + 4 + index * nbytes,
				      format, np);
	  }
}
开发者ID:BoxianLai,项目名称:moxiedev,代码行数:25,代码来源:ibnum.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rad函数代码示例发布时间:2022-05-30
下一篇:
C++ r_sys_getenv函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap