示例#1
0
 void CheckGetSized(int destsize,
                    int valsize,
                    int correct_retval,
                    const unsigned char* correct_result)
 {
     llvm::APFloat flt(llvm::APFloat::x87DoubleExtended, GetParam().ascii);
     yasm::Bytes result;
     result.resize(destsize);
     result.setLittleEndian();
     yasm::NumericOutput num_out(result);
     num_out.setSize(valsize);
     num_out.OutputFloat(flt);
     for (int i=0; i<destsize; ++i)
         EXPECT_EQ(correct_result[i], result[i]);
 }
void asl_cel_format::handle_atom(stream_type& os, bool is_push) {
    const format_element_t& top(stack_top());
    name_t parent(stack_depth() >= 2 ? stack_n(1).tag() : name_t());
    name_t grandparent(stack_depth() >= 3 ? stack_n(2).tag() : name_t());
    const any_regular_t& value(top.value());
    bool outputting_bag(parent == seq_name_g && grandparent == bag_name_g);
    std::size_t& num_out(outputting_bag ? stack_n(2).num_out_m : stack_n(1).num_out_m);
    bool named_argument(outputting_bag && (num_out & 0x1) == 0);

    if (is_push) {
        // if this is not the first item in the element, add a comma and set up a newline
        if (num_out > 0) {
            if (!outputting_bag) {
                os << ", ";
            } else if (named_argument) {
                os << ",\n" << indents(depth());
            }
        } else if (outputting_bag) {
            os << '\n' << indents(depth());
        }

        if (value.type_info() == typeid(string)) {
            bool escape(needs_entity_escape(value.cast<string>()));

            if (escape_m && escape)
                os << "xml_unescape(";

            os << '\"'
               << (escape_m && escape ? entity_escape(value.cast<string>()) : value.cast<string>())
               << '\"';

            if (escape_m && escape)
                os << ")";
        } else if (value.type_info() == typeid(name_t)) {
            if (!named_argument)
                os << '@';

            os << value.cast<name_t>();

            if (outputting_bag && named_argument)
                os << ": ";
        } else if (value.type_info() == typeid(bool)) {
            os << (value.cast<bool>() ? "true" : "false");
        } else if (value.type_info() == typeid(double)) {
            double dbl_val(value.cast<double>());
            boost::int64_t int_val(static_cast<boost::int64_t>(dbl_val));

            if (dbl_val == int_val) {
                os << int_val;
            } else {
                // For asl_cel, we want to output floating-point values in decimal-based
                // fixed-point notation (asl_cel doesn't support any other format) with
                // a very high precision for accceptable roundtrip values.

                os.setf(std::ios_base::dec, std::ios_base::basefield);
                os.setf(std::ios_base::fixed, std::ios_base::floatfield);
                os.precision(16);

                os << dbl_val;
            }
        } else if (value.type_info() == typeid(empty_t)) {
            os << value.cast<empty_t>();
        } else if (value.type_info() == typeid(dictionary_t)) {
            os << value.cast<dictionary_t>();
        } else if (value.type_info() == typeid(array_t)) {
            os << value.cast<array_t>();
        } else {
            os << "'" << value.type_info().name() << "'";
        }
    } else {
        // up the number of outputted items for the parent to this atom
        ++num_out;
    }
}
示例#3
0
文件: graph.c 项目: ofilin/remcam2
void graph(HDC dc, int x, int y, graph_style *style, graph_data *data, 
	int range, int current, char *title, char *descr)
{
	int step, pos, val, ypos, i;

	//background
	SelectObject(dc, style->bgnd);
	PatBlt(dc, x, y, WIDTH, HEIGHT, PATCOPY);

	//graph title
	SelectObject(dc, style->font);
	SetTextColor(dc, style->fgnd);
	SetBkMode(dc, TRANSPARENT);
	TextOut(dc, x+5, y, title, (int)strlen(title));

	//current value
	SelectObject(dc, style->fgndbr);
	num_out(dc, x+5, y+CAPT+GRAPH_H, style->mask, current, descr);

	//grid
	SelectObject(dc, style->grid);
	for(pos = 0; pos < WIDTH; pos += CELL_W)
	{
		MoveToEx(dc, x+pos, y+CAPT, NULL);
		LineTo(dc, x+pos, y+HEIGHT-CAPT);
	}
	for(pos = CAPT; pos < HEIGHT-CAPT; pos += CELL_H)
	{
		MoveToEx(dc, x, y+pos, NULL);
		LineTo(dc, x+WIDTH, y+pos);
	}

	//graph
	step = WIDTH / (GRAPH_BUF - 1);
	SelectObject(dc, style->fgndpen);
	pos = (GRAPH_BUF - data->count) * step;
	for(i = 0; i < data->count; ++i)
	{
		val = data->values[(i + data->offset) % GRAPH_BUF];
		if(val < 0) val = 0;
		if(val > range) val = range;
		ypos = GRAPH_H - (val * GRAPH_H / range);
		if(i == 0)
			MoveToEx(dc, pos+x, ypos+y+CAPT, NULL);
		else
			LineTo(dc, pos+x, ypos+y+CAPT);
		pos += step;
	}

	//outline
	SelectObject(dc, style->outl);
	MoveToEx(dc, x, y, NULL);
	LineTo(dc, x+WIDTH-1, y);
	LineTo(dc, x+WIDTH-1, y+HEIGHT-1);
	LineTo(dc, x, y+HEIGHT-1);
	LineTo(dc, x, y);
	MoveToEx(dc, x, y+CAPT, NULL);
	LineTo(dc, x+WIDTH-1, y+CAPT);
	MoveToEx(dc, x, y+CAPT+GRAPH_H, NULL);
	LineTo(dc, x+WIDTH-1, y+CAPT+GRAPH_H);

}
示例#4
0
void pdf_format::handle_atom(stream_type& os, bool is_push)
{
    const format_element_t& top(stack_top());
    name_t                  self(top.tag());
    name_t                  parent(stack_depth() >= 2 ? stack_n(1).tag() : name_t());
    name_t                  grandparent(stack_depth() >= 3 ? stack_n(2).tag() : name_t());
    const any_regular_t&    value(top.value());
    bool                    outputting_bag(parent == seq_name_g && grandparent == bag_name_g);
    std::size_t&            num_out(outputting_bag ? stack_n(2).num_out_m : stack_n(1).num_out_m);
    bool                    named_argument(outputting_bag && num_out % 2 == 0);

    if (is_push)
    {
        // if this is not the first item in the element, add a comma and set up a newline
        if (num_out > 0)
        {
            if (!outputting_bag)
            {
                os << ' ';
            }
            else if (named_argument)
            {
                os << '\n' << indents(depth());
            }
        }
        else if (outputting_bag)
        {
            os << '\n' << indents(depth());
        }

        if (value.type_info() == adobe::type_info<string_t>())
        {
            os << '(' << value.cast<string_t>() << ')';
        }
        else if (value.type_info() == adobe::type_info<name_t>())
        {
            os << '/' << value.cast<name_t>();

            if (outputting_bag && named_argument)
                os << " ";
        }
        else if (value.type_info() == adobe::type_info<bool>())
        {
            os << (value.cast<bool>() ? "true" : "false");
        }
        else if (value.type_info() == adobe::type_info<double>())
        {
            double         dbl_val(value.cast<double>());
            boost::int64_t int_val(static_cast<boost::int64_t>(dbl_val));

            if (dbl_val == int_val)
            {
                os << int_val;
            }
            else
            {
                // For pdf, we want to output floating-point values in decimal-based
                // fixed-point notation (asl_cel doesn't support any other format) with
                // a very high precision for accceptable roundtrip values.
    
                os.setf(std::ios_base::dec, std::ios_base::basefield);
                os.setf(std::ios_base::fixed, std::ios_base::floatfield);
                os.precision(16);

                os << dbl_val;
            }
        }
        else if (value.type_info() == adobe::type_info<empty_t>())
        {
            os << "null";
        }
        else if (value.type_info() == adobe::type_info<dictionary_t>())
        {
            os << value.cast<dictionary_t>();
        }
        else if (value.type_info() == adobe::type_info<array_t>())
        {
            os << value.cast<array_t>();
        }
        else
        {
            os << "(pdf_unknown: " << value.type_info().name() << ")";
        }
    }
    else
    {
        // up the number of outputted items for the parent to this atom
        ++num_out;
    }
}