예제 #1
0
void CSSParserFlexGrow::parse(const std::string &name, const std::vector<CSSToken> &tokens, std::vector<std::unique_ptr<CSSPropertyValue> > &inout_values)
{
	std::unique_ptr<CSSValueFlexGrow> flex_grow(new CSSValueFlexGrow());

	size_t pos = 0;
	CSSToken token = next_token(pos, tokens);
	if (token.type == CSSToken::type_ident && pos == tokens.size())
	{
		if (equals(token.value, "inherit"))
			flex_grow->type = CSSValueFlexGrow::type_inherit;
		else
			return;
	}
	else if (token.type == CSSToken::type_number && pos == tokens.size())
	{
		flex_grow->type = CSSValueFlexGrow::type_number;
		flex_grow->number = StringHelp::text_to_float(token.value);
	}
	else
	{
		return;
	}

	inout_values.push_back(std::move(flex_grow));
}
예제 #2
0
파일: flex.c 프로젝트: enjoylife/DataMonkey
extern inline DSTATUS flex_insert(flex_t flex, index_t requested_index, data_p user_data)
{
    DSTATUS status;
    index_t r,k,b,e,p;
    r = requested_index + 1;
    k = LEADINGBIT(r); // no need for minus 1. already zero indexed 
    b = BITSUBSET(r,k-k/2,k);
    e = BITSUBSET(r,0, CEILING(k,2));
    p = (1 << (k/2 + 1)) - 2 + (k & 1) * (1 << (k/2));
    //log_info("Grow Check P+B:[%ld], index: [%ld]",p+b, flex->index_length);
    //printf("k/2=[%ld], Ceil(k,2)=[%ld]\n",k/2,CEILING(k,2));
    //printf("K: [%ld] is the leading 1 bit\n",k); // printf("B: [%ld]\n",b);
    while(p+b > flex->last_index_occup){ // we have an index which would seg fault
        status = flex_grow(flex);  //flex_debug_out(flex);
        check_alt(status == SUCCESS);    
    }
    //log_info("trying [%ld,%ld]",(p+b),e);
    (flex->index_block[(p+b)][e]) = *user_data;
    return SUCCESS;
error:
    return FAILURE;
}