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


C++ EMIT函数代码示例

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


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

示例1: p_bre

/*
 - p_bre - BRE parser top level, anchoring and concatenation
 * Giving end1 as OUT essentially eliminates the end1/end2 check.
 *
 * This implementation is a bit of a kludge, in that a trailing $ is first
 * taken as an ordinary character and then revised to be an anchor.  The
 * only undesirable side effect is that '$' gets included as a character
 * category in such cases.  This is fairly harmless; not worth fixing.
 * The amount of lookahead needed to avoid this kludge is excessive.
 */
static void
p_bre(struct parse *p,
    int end1,		/* first terminating character */
    int end2)		/* second terminating character */
{
	sopno start = HERE();
	int first = 1;			/* first subexpression? */
	int wasdollar = 0;

	if (EAT('^')) {
		EMIT(OBOL, 0);
		p->g->iflags |= USEBOL;
		p->g->nbol++;
	}
	while (MORE() && !SEETWO(end1, end2)) {
		wasdollar = p_simp_re(p, first);
		first = 0;
	}
	if (wasdollar) {	/* oops, that was a trailing anchor */
		DROP(1);
		EMIT(OEOL, 0);
		p->g->iflags |= USEEOL;
		p->g->neol++;
	}

	REQUIRE(HERE() != start, REG_EMPTY);	/* require nonempty */
}
开发者ID:OPSF,项目名称:uClinux,代码行数:37,代码来源:regcomp.c

示例2: join_paths

static size_t join_paths(char *dst, size_t bufsize,
			 const char *s1, const char *s2)
{
    const char *list[2];
    int i;
    char c;
    const char *p;
    char *q  = dst;
    size_t n = 0;
    bool slash = false;
    
    list[0] = s1;
    list[1] = s2;

    for (i = 0; i < 2; i++) {
	p = list[i];

	while ((c = *p++)) {
	    if (c == '/') {
		if (!slash)
		    EMIT(c);
		slash = true;
	    } else {
		EMIT(c);
		slash = false;
	    }
	}
    }

    if (bufsize)
	*q = '\0';

    return n;
}
开发者ID:1stMaster,项目名称:syslinux,代码行数:34,代码来源:chdir.c

示例3: DumpMemory

/***************************************************************
** Diagnostic routine that prints memory in table format.
*/
void DumpMemory( void *addr, int32 cnt)
{
	int32 ln, cn, nlines;
	unsigned char *ptr, *cptr, c;

	nlines = (cnt + 15) / 16;

	ptr = (unsigned char *) addr;

	EMIT_CR;
	
	for (ln=0; ln<nlines; ln++)
	{
		MSG( ConvertNumberToText( (int32) ptr, 16, FALSE, 8 ) );
		MSG(": ");
		cptr = ptr;
		for (cn=0; cn<16; cn++)
		{
			MSG( ConvertNumberToText( (int32) *cptr++, 16, FALSE, 2 ) );
			EMIT(' ');
		}
		EMIT(' ');
		for (cn=0; cn<16; cn++)
		{
			c = *ptr++;
			if ((c < ' ') || (c > '}')) c = '.';
			EMIT(c);
		}
		EMIT_CR;
	}
}
开发者ID:cataska,项目名称:pforth,代码行数:34,代码来源:pf_text.c

示例4: cvt_d

static void cvt_d(fmt_code_info_t *info) {
	/* declare buf and p, initialize p */

	char buf[200];
	char *p = buf + sizeof(buf);

#define EMIT(m) do {				\
	if(val == INT_MIN)			\
		m = INT_MAX + 1U;		\
	else if(val < 0)			\
		m = -val;			\
	else					\
		m = val;			\
						\
	do 					\
		*--p = (char)(m % 10 + '0');		\
	while((m /= 10) > 0);			\
						\
	if(val < 0)				\
		*--p = '-';			\
	} while(0)				

	if(info->flags['L']) {
		int64_t val = va_arg(*info->app, int64_t);
		int64_t m;

		EMIT(m);
	} else if(info->flags['l']) {
		long val = va_arg(*info->app, long);
		long m;

		EMIT(m);
	} else if(info->flags['h']) {
开发者ID:duper,项目名称:blackbag,代码行数:33,代码来源:fmt.c

示例5: onVisitNode

void BytecodeTranslatorVisitor::visitUnaryOpNode(UnaryOpNode* node) {
    onVisitNode(node);

    VISIT(node->operand());

    switch (node->kind()) {
    case tNOT: {
        ensureTopType(VT_INT); /* if (!3.14) should fail */
        Label L_True(bytecode());
        Label L_End(bytecode());
        EMIT(BC_ILOAD0);
        EMIT_BRANCH(BC_IFICMPE, L_True);
        EMIT(BC_ILOAD0);
        EMIT_BRANCH(BC_JA, L_End);
        EMIT_BIND(L_True);
        EMIT(BC_ILOAD1);
        EMIT_BIND(L_End);
        break;
    }
    case tSUB:
        ensureTopIsNumeric();
        EMIT(TYPED(NEG));
        break;
    default:
        ERROR("Unknown unary op");
    }
}
开发者ID:kamanov,项目名称:Shared,代码行数:27,代码来源:bytecode_translator.cpp

示例6: emit_quoted_scalar

bool emit_quoted_scalar(const node *each)
{
    EMIT("'");
    if(!emit_raw_scalar(each))
    {
        log_error("shell", "uh oh! couldn't emit quoted scalar");
        return false;
    }
    EMIT("'");

    return true;
}
开发者ID:kazufusa,项目名称:kanabo,代码行数:12,代码来源:shell.c

示例7: emit_json_quoted_scalar

static bool emit_json_quoted_scalar(const Scalar *each)
{
    EMIT("\"");
    if(!emit_json_raw_scalar(each))
    {
        log_error(component, "uh oh! couldn't emit quoted scalar");
        return false;
    }
    EMIT("\"");

    return true;
}
开发者ID:kevinbirch,项目名称:kanabo,代码行数:12,代码来源:json.c

示例8: quote_c_style_counted

/*
 * C-style name quoting.
 *
 * (1) if sb and fp are both NULL, inspect the input name and counts the
 *     number of bytes that are needed to hold c_style quoted version of name,
 *     counting the double quotes around it but not terminating NUL, and
 *     returns it.
 *     However, if name does not need c_style quoting, it returns 0.
 *
 * (2) if sb or fp are not NULL, it emits the c_style quoted version
 *     of name, enclosed with double quotes if asked and needed only.
 *     Return value is the same as in (1).
 */
static size_t quote_c_style_counted(const char *name, ssize_t maxlen,
				    struct strbuf *sb, FILE *fp, int no_dq)
{
#undef EMIT
#define EMIT(c)                                 \
	do {                                        \
		if (sb) strbuf_addch(sb, (c));          \
		if (fp) fputc((c), fp);                 \
		count++;                                \
	} while (0)
#define EMITBUF(s, l)                           \
	do {                                        \
		if (sb) strbuf_add(sb, (s), (l));       \
		if (fp) fwrite((s), (l), 1, fp);        \
		count += (l);                           \
	} while (0)

	size_t len, count = 0;
	const char *p = name;

	for (;;) {
		int ch;

		len = next_quote_pos(p, maxlen);
		if (len == maxlen || (maxlen < 0 && !p[len]))
			break;

		if (!no_dq && p == name)
			EMIT('"');

		EMITBUF(p, len);
		EMIT('\\');
		p += len;
		ch = (unsigned char)*p++;
		if (maxlen >= 0)
			maxlen -= len + 1;
		if (sq_lookup[ch] >= ' ') {
			EMIT(sq_lookup[ch]);
		} else {
			EMIT(((ch >> 6) & 03) + '0');
			EMIT(((ch >> 3) & 07) + '0');
			EMIT(((ch >> 0) & 07) + '0');
		}
	}

	EMITBUF(p, len);
	if (p == name)   /* no ending quote needed */
		return 0;

	if (!no_dq)
		EMIT('"');
	return count;
}
开发者ID:Noffica,项目名称:git,代码行数:66,代码来源:quote.c

示例9: castTopsToCommonType

void BytecodeTranslatorVisitor::processNumericOperation(TokenKind op) {
    castTopsToCommonType();

    switch (op) {
    case tADD: EMIT(TYPED(ADD)); break;
    case tSUB: EMIT(TYPED(SUB)); break;
    case tMUL: EMIT(TYPED(MUL)); break;
    default  : EMIT(TYPED(DIV)); break;
    }

    popType();
    ensureTopIsNumeric();
}
开发者ID:kamanov,项目名称:Shared,代码行数:13,代码来源:bytecode_translator.cpp

示例10: emit_json_mapping_item

static bool emit_json_mapping_item(Node *key, Node *value, void *context)
{
    log_trace(component, "emitting mapping item");
    size_t *count = (size_t *)context;
    if(0 != (*count)++)
    {
        EMIT(",");
    }
    if(!emit_json_quoted_scalar(scalar(key)))
    {
        return false;
    }
    EMIT(":");
    return emit_json_node(value, NULL);
}
开发者ID:kevinbirch,项目名称:kanabo,代码行数:15,代码来源:json.c

示例11: ffDotS

/* ( ... --- ... , print stack ) */
void ffDotS( void )
{
	cell *sp;
	int32 i, Depth;

	MSG("Stack<");
	MSG( ConvertNumberToText( gVarBase, 10, TRUE, 1 ) ); /* Print base in decimal. */
	MSG("> ");
	
	Depth = gCurrentTask->td_StackBase - gCurrentTask->td_StackPtr;
	sp = gCurrentTask->td_StackBase;
	
	if( Depth < 0 )
	{
		MSG("UNDERFLOW!");
	}
	else
	{
		for( i=0; i<Depth; i++ )
		{
/* Print as unsigned if not base 10. */
			MSG( ConvertNumberToText( *(--sp), gVarBase, (gVarBase == 10), 1 ) );
			EMIT(' ');
		}
	}
	MSG("\n");
}
开发者ID:cataska,项目名称:pforth,代码行数:28,代码来源:pf_words.c

示例12: doinsert

/*
 - doinsert - insert a sop into the strip
 */
static void
doinsert(struct parse *p, sop op, size_t opnd, sopno pos)
{
	sopno sn;
	sop s;
	int i;

	/* avoid making error situations worse */
	if (p->error != 0)
		return;

	sn = HERE();
	EMIT(op, opnd);		/* do checks, ensure space */
	assert(HERE() == sn+1);
	s = p->strip[sn];

	/* adjust paren pointers */
	assert(pos > 0);
	for (i = 1; i < NPAREN; i++) {
		if (p->pbegin[i] >= pos) {
			p->pbegin[i]++;
		}
		if (p->pend[i] >= pos) {
			p->pend[i]++;
		}
	}

	memmove((char *)&p->strip[pos+1], (char *)&p->strip[pos],
						(HERE()-pos-1)*sizeof(sop));
	p->strip[pos] = s;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:34,代码来源:regcomp.c

示例13: FIND_ATTACHED_STREAM_INFO

void Recorder::onRecord(XnUInt32 nodeId, XnCodecBase* pCodec, const OniFrame* pFrame, XnUInt32 frameId, XnUInt64 timestamp)
{
    if (0 == nodeId || NULL == pFrame)
    {
        return;
    }

    FIND_ATTACHED_STREAM_INFO(nodeId)
    if (!pInfo) return;

    Memento undoPoint(this);

    if (NULL != pCodec)
    {
        XnUInt32 bufferSize_bytes32 = pFrame->dataSize * 2 + pCodec->GetOverheadSize();
        XnUInt8* buffer             = XN_NEW_ARR(XnUInt8, bufferSize_bytes32);

        XnStatus status = pCodec->Compress(reinterpret_cast<const XnUChar*>(pFrame->data), 
                pFrame->dataSize, buffer, &bufferSize_bytes32);
                XnSizeT  bufferSize_bytes = bufferSize_bytes32;
        if (XN_STATUS_OK == status)
        {
            EMIT(RECORD_NEW_DATA(
                    nodeId,
                    pInfo->lastNewDataRecordPosition,
                    timestamp,
                    frameId,
                    buffer,
                    bufferSize_bytes))
        }
        XN_DELETE_ARR(buffer);
    }
开发者ID:Arkapravo,项目名称:OpenNI2,代码行数:32,代码来源:OniRecorder.cpp

示例14: irc_status_busy

void
irc_status_busy(connection_t *c, int on, char *msg)
{
	c->status &= ~STATUS_MASK;

	if (on) {
		c->status |= STATUS_BUSY;

		if (msg != NULL) {
			IRC(c)->away = a_strdup(c->area, msg);

			PDEBUG("vado in away: %s", IRC(c)->away);
		}
	} else {
		c->status |= STATUS_AVAILABLE;

		if (IRC(c)->away != NULL) {
			a_free(c->area, IRC(c)->away);
			IRC(c)->away = NULL;
		}
	}

	EMIT(c, "send status");

	IRC_SEND_SRVMODE(c, c->nick, c->nick, (on) ? "+a" : "-a");
}
开发者ID:BackupTheBerlios,项目名称:irci6,代码行数:26,代码来源:status.c

示例15: popType

void BytecodeTranslatorVisitor::castTopsToCommonType() {
    VarType hi = popType();
    VarType lo = popType();

    if (hi != lo) {
        if (hi == VT_DOUBLE) {
            EMIT(BC_SWAP);
            EMIT(BC_I2D);
            EMIT(BC_SWAP);
        } else {
            EMIT(BC_I2D);
        }
        hi = VT_DOUBLE;
    }

    pushType(hi);
    pushType(hi);
}
开发者ID:kamanov,项目名称:Shared,代码行数:18,代码来源:bytecode_translator.cpp


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