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


C++ EnumMember::toPrettyChars方法代码示例

本文整理汇总了C++中EnumMember::toPrettyChars方法的典型用法代码示例。如果您正苦于以下问题:C++ EnumMember::toPrettyChars方法的具体用法?C++ EnumMember::toPrettyChars怎么用?C++ EnumMember::toPrettyChars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EnumMember的用法示例。


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

示例1: cv4_Denum

unsigned cv4_Denum(EnumDeclaration *e)
{
    debtyp_t *d,*dt;
    unsigned nfields,fnamelen;
    unsigned len;
    unsigned property;
    unsigned attribute;
    int i;
    const char *id;
    idx_t typidx;

    //dbg_printf("cv4_Denum(%s)\n", e->toChars());
    property = 0;
    if (!e->members || !e->memtype)
	property |= 0x80;		// enum is forward referenced

    id = e->toPrettyChars();
    len = 10;
    d = debtyp_alloc(len + cv_stringbytes(id));
    TOWORD(d->data,LF_ENUM);
    TOWORD(d->data + 4,e->memtype ? cv4_typidx(e->memtype->toCtype()) : 0);
    TOWORD(d->data + 8,property);
    len += cv_namestring(d->data + len,id);

    d->length = 0;			// so cv_debtyp() will allocate new
    typidx = cv_debtyp(d);
    d->length = len;			// restore length

    // Compute the number of fields, and the length of the fieldlist record
    nfields = 0;
    fnamelen = 2;
    if (e->members)
    {
	for (i = 0; i < e->members->dim; i++)
	{   EnumMember *sf = ((Dsymbol *)e->members->data[i])->isEnumMember();
	    dinteger_t value;

	    if (sf)
	    {
		value = sf->value->toInteger();
		unsigned fnamelen1 = fnamelen;
		fnamelen += 4 + cv4_numericbytes(value) + cv_stringbytes(sf->toPrettyChars());

		/* Optlink dies on longer ones, so just truncate
		 */
		if (fnamelen > 0xB000)		// 0xB000 found by trial and error
		{   fnamelen = fnamelen1;	// back up
		    break;			// and skip the rest
		}

		nfields++;
	    }
	}
    }

    TOWORD(d->data + 2,nfields);

    // If forward reference, then field list is 0
    if (!e->members)
    {
	TOWORD(d->data + 6,0);
	return typidx;
    }

    // Generate fieldlist type record
    dt = debtyp_alloc(fnamelen);
    TOWORD(dt->data,LF_FIELDLIST);

    // And fill it in
    int j = 2;
    int fieldi = 0;
    for (i = 0; i < e->members->dim; i++)
    {   EnumMember *sf = ((Dsymbol *)e->members->data[i])->isEnumMember();
	dinteger_t value;

	if (sf)
	{
	    fieldi++;
	    if (fieldi > nfields)
		break;			// chop off the rest

	    value = sf->value->toInteger();
	    TOWORD(dt->data + j,LF_ENUMERATE);
	    attribute = 0;
	    TOWORD(dt->data + j + 2,attribute);
	    cv4_storenumeric(dt->data + j + 4,value);
	    j += 4 + cv4_numericbytes(value);
	    j += cv_namestring(dt->data + j, sf->toPrettyChars());

	    // If enum is not a member of a class, output enum members as constants
//	    if (!isclassmember(s))
//	    {
//		cv4_outsym(sf);
//	    }
	}
    }
    assert(j == fnamelen);
    TOWORD(d->data + 6,cv_debtyp(dt));

//    cv4_outsym(s);
//.........这里部分代码省略.........
开发者ID:Geod24,项目名称:dnet,代码行数:101,代码来源:tocvdebug.c


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