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

C++ r_has_type函数代码示例

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

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



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

示例1: charstring_is_notdef_proc

static bool
charstring_is_notdef_proc(const gs_memory_t *mem, const ref *pcstr)
{
    if (r_is_array(pcstr) && r_size(pcstr) == 4) {
        ref elts[4];
        long i;

        for (i = 0; i < 4; ++i)
            array_get(mem, pcstr, i, &elts[i]);
        if (r_has_type(&elts[0], t_name) &&
            r_has_type(&elts[1], t_integer) && elts[1].value.intval == 0 &&
            r_has_type(&elts[2], t_integer) && elts[2].value.intval == 0 &&
            r_has_type(&elts[3], t_name)
            ) {
            ref nref;

            name_enter_string(mem, "pop", &nref);
            if (name_eq(&elts[0], &nref)) {
                name_enter_string(mem, "setcharwidth", &nref);
                if (name_eq(&elts[3], &nref))
                    return true;
            }
        }
    }
    return false;
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:26,代码来源:zcharout.c


示例2: TT_char_code_from_CID_no_subst

/* Convert a CID into TT char code or to TT glyph index. */
static bool
TT_char_code_from_CID_no_subst(const gs_memory_t *mem,
                               const ref *Decoding, const ref *TT_cmap, uint nCID, uint *c)
{   ref *DecodingArray, char_code, char_code1, ih, *glyph_index;
    bool found = false;
    int i = nCID % 256, n;

    make_int(&ih, nCID / 256);
    if (dict_find(Decoding, &ih, &DecodingArray) <= 0 ||
            !r_has_type(DecodingArray, t_array) ||
            array_get(mem, DecodingArray, i, &char_code) < 0)
        return false;
    if (r_has_type(&char_code, t_integer))
        n = 1;
    else if (r_has_type(&char_code, t_array)) {
        DecodingArray = &char_code;
        i = 0;
        n = r_size(DecodingArray);
    } else
        return false; /* Must not happen. */
    for (;n--; i++) {
        if (array_get(mem, DecodingArray, i, &char_code1) < 0 ||
            !r_has_type(&char_code1, t_integer))
            return false; /* Must not happen. */
        if (dict_find(TT_cmap, &char_code1, &glyph_index) >= 0 &&
                r_has_type(glyph_index, t_integer)) {
            *c = glyph_index->value.intval;
            found = true;
            if (*c != 0)
                return true;
        }
    }
    return found;
}
开发者ID:jonathan-mui,项目名称:ruby-ghostscript,代码行数:35,代码来源:zcid.c


示例3: dict_check_uid_param

/* Check that a UID in a dictionary is equal to an existing, valid UID. */
bool
dict_check_uid_param(const ref * pdict, const gs_uid * puid)
{
    ref *puniqueid;

    if (uid_is_XUID(puid)) {
        uint size = uid_XUID_size(puid);
        uint i;

        if (dict_find_string(pdict, "XUID", &puniqueid) <= 0)
            return false;
        if (!r_has_type(puniqueid, t_array) ||
            r_size(puniqueid) != size
            )
            return false;
        for (i = 0; i < size; i++) {
            const ref *pvalue = puniqueid->value.const_refs + i;

            if (!r_has_type(pvalue, t_integer))
                return false;
            if (pvalue->value.intval != uid_XUID_values(puid)[i])
                return false;
        }
        return true;
    } else {
        if (dict_find_string(pdict, "UniqueID", &puniqueid) <= 0)
            return false;
        return (r_has_type(puniqueid, t_integer) &&
                puniqueid->value.intval == puid->id);
    }
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:32,代码来源:idparam.c


示例4: zfor

int
zfor(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    register es_ptr ep;
    int code;
    float params[3];

        /* Mostly undocumented, and somewhat bizarre Adobe behavior discovered	*/
        /* with the CET (28-05) and FTS (124-01) is that the proc is not run	*/
        /* if BOTH the initial value and increment are zero.			*/
    if ((code = float_params(op - 1, 3, params)) < 0)
        return code;
    if ( params[0] == 0.0 && params[1] == 0.0 ) {
        pop(4);		/* don't run the proc */
        return 0;
    }
    check_estack(7);
    ep = esp + 6;
    check_proc(*op);
    /* Push a mark, the control variable set to the initial value, */
    /* the increment, the limit, and the procedure, */
    /* and invoke the continuation operator. */
    if (r_has_type(op - 3, t_integer) &&
        r_has_type(op - 2, t_integer)
        ) {
        make_int(ep - 4, op[-3].value.intval);
        make_int(ep - 3, op[-2].value.intval);
        switch (r_type(op - 1)) {
            case t_integer:
                make_int(ep - 2, op[-1].value.intval);
                break;
            case t_real:
                make_int(ep - 2, (long)op[-1].value.realval);
                break;
            default:
                return_op_typecheck(op - 1);
        }
        if (ep[-3].value.intval >= 0)
            make_op_estack(ep, for_pos_int_continue);
        else
            make_op_estack(ep, for_neg_int_continue);
    } else {
        make_real(ep - 4, params[0]);
        make_real(ep - 3, params[1]);
        make_real(ep - 2, params[2]);
        make_op_estack(ep, for_real_continue);
    }
    make_mark_estack(ep - 5, es_for, no_cleanup);
    ref_assign(ep - 1, op);
    esp = ep;
    pop(4);
    return o_push_estack;
}
开发者ID:jonathan-mui,项目名称:ruby-ghostscript,代码行数:54,代码来源:zcontrol.c


示例5: swap_entry

/*
 * Swap an entry from a higher level dictionary into a base dictionary.
 * elt[0] is the key, elt[1] is the current value in the Level 2 dictionary
 * (*pdict2).
 */
static int
swap_entry(i_ctx_t *i_ctx_p, ref elt[2], ref * pdict, ref * pdict2)
{
    ref *pvalue;
#ifdef PACIFY_VALGRIND
    ref old_value = { 0 };		/* current value in *pdict */
#else
    ref old_value;		/* current value in *pdict */
#endif
    int found = dict_find(pdict, &elt[0], &pvalue);

    switch (found) {
        default:		/* <0, error */
            /*
             * The only possible error here is a dictfull error, which is
             * harmless.
             */
            /* fall through */
        case 0:		/* missing */
            make_null(&old_value);
            break;
        case 1:		/* present */
            old_value = *pvalue;
    }
    /*
     * Temporarily flag the dictionaries as local, so that we don't
     * get invalidaccess errors.  (We know that they are both
     * referenced from systemdict, so they are allowed to reference
     * local objects even if they are global.)
     */
    {
        uint space2 = r_space(pdict2);
        int code;

        r_set_space(pdict2, avm_local);
        idict_put(pdict2, &elt[0], &old_value);
        if (r_has_type(&elt[1], t_null)) {
            code = idict_undef(pdict, &elt[0]);
            if (code == gs_error_undefined &&
                r_has_type(&old_value, t_null)
                )
                code = 0;
        } else {
            uint space = r_space(pdict);

            r_set_space(pdict, avm_local);
            code = idict_put(pdict, &elt[0], &elt[1]);
            r_set_space(pdict, space);
        }
        r_set_space(pdict2, space2);
        return code;
    }
}
开发者ID:computersforpeace,项目名称:ghostpdl,代码行数:58,代码来源:zmisc2.c


示例6: zmakewordimagedevice

/* <matrix> <width> <height> <palette> <word?> makewordimagedevice <device> */
static int
zmakewordimagedevice(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    os_ptr op1 = op - 1;
    gs_matrix imat;
    gx_device *new_dev;
    const byte *colors;
    int colors_size;
    int code;

    check_int_leu(op[-3], max_uint >> 1);	/* width */
    check_int_leu(op[-2], max_uint >> 1);	/* height */
    check_type(*op, t_boolean);
    if (r_has_type(op1, t_null)) {	/* true color */
	colors = 0;
	colors_size = -24;	/* 24-bit true color */
    } else if (r_has_type(op1, t_integer)) {
	/*
	 * We use if/else rather than switch because the value is long,
	 * which is not supported as a switch value in pre-ANSI C.
	 */
	if (op1->value.intval != 16 && op1->value.intval != 24 &&
	    op1->value.intval != 32
	    )
	    return_error(e_rangecheck);
	colors = 0;
	colors_size = -op1->value.intval;
    } else {
	check_type(*op1, t_string);	/* palette */
	if (r_size(op1) > 3 * 256)
	    return_error(e_rangecheck);
	colors = op1->value.bytes;
	colors_size = r_size(op1);
    }
    if ((code = read_matrix(imemory, op - 4, &imat)) < 0)
	return code;
    /* Everything OK, create device */
    code = gs_makewordimagedevice(&new_dev, &imat,
				  (int)op[-3].value.intval,
				  (int)op[-2].value.intval,
				  colors, colors_size,
				  op->value.boolval, true, imemory);
    if (code == 0) {
	new_dev->memory = imemory;
	make_tav(op - 4, t_device, imemory_space(iimemory) | a_all,
		 pdevice, new_dev);
	pop(4);
    }
    return code;
}
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:52,代码来源:zdevice.c


示例7: dict_index_entry

/* If the index designates an unoccupied entry, return gs_error_undefined. */
int
dict_index_entry(const ref * pdref, int index, ref * eltp /* ref eltp[2] */ )
{
    const dict *pdict = pdref->value.pdict;

    array_get(dict_mem(pdict), &pdict->keys, (long)(index + 1), eltp);
    if (r_has_type(eltp, t_name) ||
        (!dict_is_packed(pdict) && !r_has_type(eltp, t_null))
        ) {
        eltp[1] = pdict->values.value.refs[index + 1];
        return 0;
    }
    return gs_error_undefined;
}
开发者ID:computersforpeace,项目名称:ghostpdl,代码行数:15,代码来源:idict.c


示例8: zsetpagedevice

/* <local_dict|null> .setpagedevice - */
static int
zsetpagedevice(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    int code;

/******
    if ( igs->in_cachedevice )
        return_error(e_undefined);
 ******/
    if (r_has_type(op, t_dictionary)) {
        check_dict_read(*op);
#if 0	/****************/
        /*
         * In order to avoid invalidaccess errors on setpagedevice,
         * the dictionary must be allocated in local VM.
         */
        if (!(r_is_local(op)))
            return_error(e_invalidaccess);
#endif	/****************/
        /* Make the dictionary read-only. */
        code = zreadonly(i_ctx_p);
        if (code < 0)
            return code;
    } else {
        check_type(*op, t_null);
    }
    istate->pagedevice = *op;
    pop(1);
    return 0;
}
开发者ID:jonathan-mui,项目名称:ruby-ghostscript,代码行数:32,代码来源:zdevice2.c


示例9: save_page_device

/* Check whether we need to call out to create the page device dictionary. */
static bool
save_page_device(gs_state *pgs)
{
    return
        (r_has_type(&gs_int_gstate(pgs)->pagedevice, t_null) &&
         (*dev_proc(gs_currentdevice(pgs), get_page_device))(gs_currentdevice(pgs)) != 0);
}
开发者ID:jonathan-mui,项目名称:ruby-ghostscript,代码行数:8,代码来源:zdevice2.c


示例10: dict_find

int
dict_find(const ref * pdref, const ref * pkey, ref ** ppvalue)
{
    dict *pdict = pdref->value.pdict;
    int code = real_dict_find(pdref, pkey, ppvalue);

    stats_dict.lookups++;
    if (r_has_type(pkey, t_name) && dict_is_packed(pdict)) {
        uint nidx = name_index(dict_mem(pdict), pkey);
        uint hash =
        dict_hash_mod(dict_name_index_hash(nidx), npairs(pdict)) + 1;

        if (pdict->keys.value.packed[hash] ==
            pt_tag(pt_literal_name) + nidx
            )
            stats_dict.probe1++;
        else if (pdict->keys.value.packed[hash - 1] ==
                 pt_tag(pt_literal_name) + nidx
            )
            stats_dict.probe2++;
    }
    /* Do the cheap flag test before the expensive remainder test. */
    if (gs_debug_c('d') && !(stats_dict.lookups % 1000))
        dlprintf3("[d]lookups=%ld probe1=%ld probe2=%ld\n",
                  stats_dict.lookups, stats_dict.probe1, stats_dict.probe2);
    return code;
}
开发者ID:computersforpeace,项目名称:ghostpdl,代码行数:27,代码来源:idict.c


示例11: process_float_array

/* Get N numeric parameters (as floating point numbers) from an array */
int
process_float_array(const gs_memory_t *mem, const ref * parray, int count, float * pval)
{
    int         code = 0, indx0 = 0;

    /* we assume parray is an array of some type, of adequate length */
    if (r_has_type(parray, t_array))
        return float_params(parray->value.refs + count - 1, count, pval);

    /* short/mixed array; convert the entries to refs */
    while (count > 0 && code >= 0) {
        int     i, subcount;
        ref     ref_buff[20];   /* 20 is arbitrary */

        subcount = (count > countof(ref_buff) ? countof(ref_buff) : count);
        for (i = 0; i < subcount && code >= 0; i++)
            code = array_get(mem, parray, (long)(i + indx0), &ref_buff[i]);
        if (code >= 0)
            code = float_params(ref_buff + subcount - 1, subcount, pval);
        count -= subcount;
        pval += subcount;
        indx0 += subcount;
    }

    return code;
}
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:27,代码来源:iutil.c


示例12: cid_font_data_param

/* Get the additional information for a CIDFontType 0 or 2 CIDFont. */
int
cid_font_data_param(os_ptr op, gs_font_cid_data *pdata, ref *pGlyphDirectory)
{
    int code;
    ref *pgdir;

    check_type(*op, t_dictionary);
    if ((code = cid_font_system_info_param(&pdata->CIDSystemInfo, op)) < 0 ||
            (code = dict_int_param(op, "CIDCount", 0, max_int, -1,
                                   &pdata->CIDCount)) < 0
       )
        return code;
    /*
     * If the font doesn't have a GlyphDirectory, GDBytes is required.
     * If it does have a GlyphDirectory, GDBytes may still be needed for
     * CIDMap: it's up to the client to check this.
     */
    if (dict_find_string(op, "GlyphDirectory", &pgdir) <= 0) {
        /* Standard CIDFont, require GDBytes. */
        make_null(pGlyphDirectory);
        return dict_int_param(op, "GDBytes", 1, MAX_GDBytes, 0,
                              &pdata->GDBytes);
    }
    if (r_has_type(pgdir, t_dictionary) || r_is_array(pgdir)) {
        /* GlyphDirectory, GDBytes is optional. */
        *pGlyphDirectory = *pgdir;
        code = dict_int_param(op, "GDBytes", 0, MAX_GDBytes, 0,
                              &pdata->GDBytes);
        return code;
    } else {
        return_error(e_typecheck);
    }
}
开发者ID:aberg001,项目名称:plan9,代码行数:34,代码来源:zfcid.c


示例13: zsetcacheparams

/* <mark> <size> <lower> <upper> setcacheparams - */
static int
zsetcacheparams(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    uint params[3];
    int i, code;
    os_ptr opp = op;

    for (i = 0; i < 3 && !r_has_type(opp, t_mark); i++, opp--) {
        check_int_leu(*opp, max_uint);
        params[i] = opp->value.intval;
    }
    switch (i) {
        case 3:
            if ((code = gs_setcachesize(igs, ifont_dir, params[2])) < 0)
                return code;
        case 2:
            if ((code = gs_setcachelower(ifont_dir, params[1])) < 0)
                return code;
        case 1:
            if ((code = gs_setcacheupper(ifont_dir, params[0])) < 0)
                return code;
        case 0:;
    }
    return zcleartomark(i_ctx_p);
}
开发者ID:jonathan-mui,项目名称:ruby-ghostscript,代码行数:27,代码来源:zfont.c


示例14: make_initial_dict

/* Create an initial dictionary if necessary. */
static ref *
make_initial_dict(i_ctx_t *i_ctx_p, const char *iname, ref idicts[])
{
    int i;

    /* systemdict was created specially. */
    if (!strcmp(iname, "systemdict"))
	return systemdict;
    for (i = 0; i < countof(initial_dictionaries); i++) {
	const char *dname = initial_dictionaries[i].name;
	const int dsize = initial_dictionaries[i].size;

	if (!strcmp(iname, dname)) {
	    ref *dref = &idicts[i];

	    if (r_has_type(dref, t_null)) {
		gs_ref_memory_t *mem =
		    (initial_dictionaries[i].local ?
		     iimemory_local : iimemory_global);
		int code = dict_alloc(mem, dsize, dref);

		if (code < 0)
		    return 0;	/* disaster */
	    }
	    return dref;
	}
    }

    /*
     * Name mentioned in some op_def, but not in initial_dictionaries.
     * Punt.
     */
    return 0;
}
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:35,代码来源:iinit.c


示例15: font_param

/* Validate a font parameter. */
int
font_param(const ref * pfdict, gs_font ** ppfont)
{	/*
         * Check that pfdict is a read-only dictionary, that it has a FID
         * entry whose value is a fontID, and that the fontID points to a
         * gs_font structure whose associated PostScript dictionary is
         * pfdict.
         */
    ref *pid;
    gs_font *pfont;
    const font_data *pdata;

    check_type(*pfdict, t_dictionary);
    if (dict_find_string(pfdict, "FID", &pid) <= 0 ||
        !r_has_type(pid, t_fontID)
        )
        return_error(e_invalidfont);
    pfont = r_ptr(pid, gs_font);
    if (pfont == 0)
        return_error(e_invalidfont);	/* unregistered font */
    pdata = pfont->client_data;
    if (!obj_eq(pfont->memory, &pdata->dict, pfdict))
        return_error(e_invalidfont);
    *ppfont = pfont;
    return 0;
}
开发者ID:jonathan-mui,项目名称:ruby-ghostscript,代码行数:27,代码来源:zfont.c


示例16: zchar_enumerate_glyph

/*
 * Enumerate the next glyph from a directory.  This is essentially a
 * wrapper around dict_first/dict_next to implement the enumerate_glyph
 * font procedure.
 *
 * Note that *prdict will be null if the font is a subfont of a
 * CIDFontType 0 CIDFont.
 */
int
zchar_enumerate_glyph(const gs_memory_t *mem, const ref *prdict, int *pindex, gs_glyph *pglyph)
{
    int index = *pindex - 1;
    ref elt[2];

    if (!r_has_type(prdict, t_dictionary))
        return 0;		/* *pindex was 0, is still 0 */
    if (index < 0)
        index = dict_first(prdict);
next:
    index = dict_next(prdict, index, elt);
    *pindex = index + 1;
    if (index >= 0) {
        switch (r_type(elt)) {
            case t_integer:
                *pglyph = gs_min_cid_glyph + elt[0].value.intval;
                break;
            case t_name:
                *pglyph = name_index(mem, elt);
                break;
            default:		/* can't handle it */
                goto next;
        }
    }
    return 0;
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:35,代码来源:zcharout.c


示例17: z_jbig2decode

/* <source> <dict> /JBIG2Decode <file> */
static int
z_jbig2decode(i_ctx_t * i_ctx_p)
{
    os_ptr op = osp;
    ref *sop = NULL;
    s_jbig2_global_data_t *gref;
    stream_jbig2decode_state state;

    /* Extract the global context reference, if any, from the parameter
       dictionary and embed it in our stream state. The original object
       ref is under the JBIG2Globals key.
       We expect the postscript code to resolve this and call
       z_jbig2makeglobalctx() below to create an astruct wrapping the
       global decoder data and store it under the .jbig2globalctx key
     */
    s_jbig2decode_set_global_data((stream_state*)&state, NULL);
    if (r_has_type(op, t_dictionary)) {
        check_dict_read(*op);
        if ( dict_find_string(op, ".jbig2globalctx", &sop) > 0) {
            gref = r_ptr(sop, s_jbig2_global_data_t);
            s_jbig2decode_set_global_data((stream_state*)&state, gref);
        }
    }

    /* we pass npop=0, since we've no arguments left to consume */
    return filter_read(i_ctx_p, 0, &s_jbig2decode_template,
                       (stream_state *) & state, (sop ? r_space(sop) : 0));
}
开发者ID:jonathan-mui,项目名称:ruby-ghostscript,代码行数:29,代码来源:zfjbig2.c


示例18: zchar_charstring_data

int
zchar_charstring_data(gs_font *font, const ref *pgref, gs_glyph_data_t *pgd)
{
    ref *pcstr;

    if (dict_find(&pfont_data(font)->CharStrings, pgref, &pcstr) <= 0)
        return_error(e_undefined);
    if (!r_has_type(pcstr, t_string)) {
        /*
         * The ADOBEPS4 Windows driver replaces the .notdef entry of
         * otherwise normal Type 1 fonts with the procedure
         *	{pop 0 0 setcharwidth}
         * To prevent this from making the font unembeddable in PDF files
         * (with our present font-writing code), we recognize this as a
         * special case and return a Type 1 CharString consisting of
         *	0 0 hsbw endchar
         */
        if (font->FontType == ft_encrypted &&
            charstring_is_notdef_proc(font->memory, pcstr)
            )
            return charstring_make_notdef(pgd, font);
        else
            return_error(e_typecheck);
    }
    gs_glyph_data_from_string(pgd, pcstr->value.const_bytes, r_size(pcstr),
                              NULL);
    return 0;
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:28,代码来源:zcharout.c


示例19: lookup_gs_simple_font_encoding

/* Compare the encoding of a simple font with the registered encodings. */
void
lookup_gs_simple_font_encoding(gs_font_base * pfont)
{
    const ref *pfe = &pfont_data(pfont)->Encoding;
    int index = -1;

    pfont->encoding_index = index;
    if (r_type(pfe) == t_array && r_size(pfe) <= 256) {
        /* Look for an encoding that's "close". */
        uint esize = r_size(pfe);
        int near_index = -1;
        uint best = esize / 3;	/* must match at least this many */
        gs_const_string fstrs[256];
        int i;

        /* Get the string names of the glyphs in the font's Encoding. */
        for (i = 0; i < esize; ++i) {
            ref fchar;

            if (array_get(pfont->memory, pfe, (long)i, &fchar) < 0 ||
                !r_has_type(&fchar, t_name)
                )
                fstrs[i].data = 0, fstrs[i].size = 0;
            else {
                ref nsref;

                name_string_ref(pfont->memory, &fchar, &nsref);
                fstrs[i].data = nsref.value.const_bytes;
                fstrs[i].size = r_size(&nsref);
            }
        }
        /* Compare them against the known encodings. */
        for (index = 0; index < NUM_KNOWN_REAL_ENCODINGS; ++index) {
            uint match = esize;

            for (i = esize; --i >= 0;) {
                gs_const_string rstr;

                gs_c_glyph_name(gs_c_known_encode((gs_char)i, index), &rstr);
                if (rstr.size == fstrs[i].size &&
                    !memcmp(rstr.data, fstrs[i].data, rstr.size)
                    )
                    continue;
                if (--match <= best)
                    break;
            }
            if (match > best) {
                best = match;
                near_index = index;
                /* If we have a perfect match, stop now. */
                if (best == esize)
                    break;
            }
        }
        index = near_index;
        if (best == esize)
            pfont->encoding_index = index;
    }
    pfont->nearest_encoding_index = index;
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:61,代码来源:zbfont.c


示例20: zcomputecodes

/* the dictionary parameter for the BoundedHuffman filters. */
static int
zcomputecodes(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    os_ptr op1 = op - 1;
    uint asize;
    hc_definition def;
    ushort *data;
    long *freqs;
    int code = 0;

    check_type(*op, t_integer);
    check_write_type(*op1, t_array);
    asize = r_size(op1);
    if (op->value.intval < 1 || op->value.intval > max_hc_length)
        return_error(e_rangecheck);
    def.num_counts = op->value.intval;
    if (asize < def.num_counts + 2)
        return_error(e_rangecheck);
    def.num_values = asize - (def.num_counts + 1);
    data = (ushort *) gs_alloc_byte_array(imemory, asize, sizeof(ushort),
                                          "zcomputecodes");
    freqs = (long *)gs_alloc_byte_array(imemory, def.num_values,
                                        sizeof(long),
                                        "zcomputecodes(freqs)");

    if (data == 0 || freqs == 0)
        code = gs_note_error(e_VMerror);
    else {
        uint i;

        def.counts = data;
        def.values = data + (def.num_counts + 1);
        for (i = 0; i < def.num_values; i++) {
            const ref *pf = op1->value.const_refs + i + def.num_counts + 1;

            if (!r_has_type(pf, t_integer)) {
                code = gs_note_error(e_typecheck);
                break;
            }
            freqs[i] = pf->value.intval;
        }
        if (!code) {
            code = hc_compute(&def, freqs, imemory);
            if (code >= 0) {
                /* Copy back results. */
                for (i = 0; i < asize; i++)
                    make_int(op1->value.refs + i, data[i]);
            }
        }
    }
    gs_free_object(imemory, freqs, "zcomputecodes(freqs)");
    gs_free_object(imemory, data, "zcomputecodes");
    if (code < 0)
        return code;
    pop(1);
    return code;
}
开发者ID:jonathan-mui,项目名称:ruby-ghostscript,代码行数:59,代码来源:zfilterx.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ r_hex_str2bin函数代码示例发布时间:2022-05-30
下一篇:
C++ r_file_slurp函数代码示例发布时间: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