void MemberAccessOperator::doPrint(PrintContext &context) const {
    bool braces = compound()->is<UnaryOperator>() ||
                  compound()->is<BinaryOperator>() ||
                  compound()->is<Typecast>();

    if (braces) {
        context.out() << "(";
    }
    compound_->print(context);
    if (braces) {
        context.out() << ")";
    }

    switch (accessKind()) {
        case ARROW:
            context.out() << "->";
            break;
        case DOT:
            context.out() << '.';
            break;
        default:
            unreachable();
            break;
    }
    
    context.out() << member_->identifier();
}
static void draw_page(GtkPrintOperation* op, GtkPrintContext* context, gint page_nr, gpointer user_data)
{
    PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data);

    cairo_t* cr = gtk_print_context_get_cairo_context(context);
    GraphicsContext ctx(cr);
    float width = gtk_print_context_get_width(context);
    printContext->spoolPage(ctx, page_nr, width);
}
Beispiel #3
0
void IntegerConstant::doPrint(PrintContext &context) const {
    SignedConstantValue val = value().size() > 1 ? value().signedValue() : value().value();

    if ((0 <= val && val <= 100) || (-100 <= val && val < 0 && !type()->isUnsigned())) {
        context.out() << val;
    } else {
        context.out() << hex << "0x" << value().value() << dec;
    }
}
Beispiel #4
0
void Typecast::doPrint(PrintContext &context) const {
    context.out() << '(' << *type() << ')';
    bool braces = operand()->is<BinaryOperator>();
    if (braces) {
        context.out() << '(';
    }
    operand()->print(context);
    if (braces) {
        context.out() << ')';
    }
}
Beispiel #5
0
void UnaryOperator::doPrint(PrintContext &context) const {
    switch (operatorKind()) {
        case DEREFERENCE:
            context.out() << '*';
            break;
        case REFERENCE:
            context.out() << '&';
            break;
        case BITWISE_NOT:
            context.out() << '~';
            break;
        case LOGICAL_NOT:
            context.out() << '!';
            break;
        case NEGATION:
            context.out() << '-';
            break;
        case PREFIX_INCREMENT:
            context.out() << "++";
            break;
        case PREFIX_DECREMENT:
            context.out() << "--";
            break;
        default:
            unreachable();
            break;
    }

    int precedence = this->precedence();
    int operandPrecedence = operand()->precedence();

    int absPrecedence = abs(precedence);
    int absOperandPrecedence = abs(operandPrecedence);

    bool operandInBraces = absOperandPrecedence > absPrecedence;

    /* Avoid too many minuses in a row. */
    if (operatorKind() == NEGATION || operatorKind() == PREFIX_DECREMENT) {
        if (auto unary = operand()->as<UnaryOperator>()) {
            if (unary->operatorKind() == NEGATION || unary->operatorKind() == PREFIX_DECREMENT) {
                operandInBraces = true;
            }
        }
    }

    if (operandInBraces) {
        context.out() << '(';
    }
    operand()->print(context);
    if (operandInBraces) {
        context.out() << ')';
    }
}
Beispiel #6
0
static void probe_object_header(const char *name)
{
    if (octx.print_object_header)
        octx.print_object_header(name);

    probe_group_enter(name, OBJECT);
}
Beispiel #7
0
static void probe_array_header(const char *name, int plain_values)
{
    if (octx.print_array_header)
        octx.print_array_header(name, plain_values);

    probe_group_enter(name, ARRAY);
}
Beispiel #8
0
static void begin_print_callback(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data)
{
    PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data);

    float width = gtk_print_context_get_width(context);
    float height = gtk_print_context_get_height(context);
    FloatRect printRect = FloatRect(0, 0, width, height);

    printContext->begin(width);

    // TODO: Margin adjustments and header/footer support
    float headerHeight = 0;
    float footerHeight = 0;
    float pageHeight; // height of the page adjusted by margins
    printContext->computePageRects(printRect, headerHeight, footerHeight, 1.0, pageHeight);
    gtk_print_operation_set_n_pages(op, printContext->pageCount());
}
void FunctionDeclaration::printSignature(PrintContext &context) const {
    context.out() << *type()->returnType() << ' ';
    functionIdentifier()->print(context);
    context.out() << '(';

    bool comma = false;
    foreach (const auto &argument, arguments_) {
        if (comma) {
            context.out() << ", ";
        } else {
            comma = true;
        }
        argument->print(context);
    }

    if (type()->variadic()) {
        if (comma) {
            context.out() << ", ";
        }
        context.out() << "...";
    }
    
    context.out() << ')';
}
Beispiel #10
0
void ExpressionStatement::doPrint(PrintContext &context) const {
    expression_->print(context);
    context.out() << ';';
}
Beispiel #11
0
int CLabelView::GrindOutPrintJob(PrintContext& pc)
{
/*
// Print our document(s).
*/

	CLabelPrintDialog* pDialog = (CLabelPrintDialog*)pc.m_pPD;

	CPmwDoc* pDoc = GetDocument();

	pDialog->ComputeTotals();

/* Extract the name list. */

	CStdMacroServer* pMacroServer = pDoc->GetMacroServer();
	NameListRecord* pNameList = pMacroServer->GetNameList();

	BOOL fMergePrint = FALSE;

	int nNames = pNameList->Names();

	int nTotalPages = pDialog->m_nTotalPages;
	int nError = FALSE;

	BOOL fOldShow = pMacroServer->ShowMacroValues();

	StorageFile* pDatabaseFile = NULL;
	CFlatFileDatabase* pDatabase = NULL;
	CFlatFileDatabaseCursor* pCursor = NULL;

	if (GetConfiguration()->SupportsAddressBook(FALSE))
	{
		// get sender values for address book.	
		pMacroServer->BindSender();
	}

	if (!fOldShow)
	{
		pMacroServer->ShowMacroValues(TRUE);
		pDoc->ReflowMacros();
	}

	pc.m_pCursor = NULL;

	PPNT dims = pDoc->get_dimensions();
	pc.m_source.x0 = 0;
	pc.m_source.y0 = 0;
	pc.m_source.x1 = dims.x;
	pc.m_source.y1 = dims.y;

/*
// Set the printing conditions.
*/

	pc.m_nBoundName = -1;
	pc.m_nCurrentName = (nNames == 0) ? -1 : 0;
	pc.m_nCurrentCopy = 0;

	CString csFullName;
	TRY
	{
		csFullName = pDoc->GetPathManager()->LocatePath(pNameList->AddressBookName());
		TRACE("Open database %s for data!\r\n", (LPCSTR)csFullName);

		if (nNames != 0)
		{
			ERRORCODE Error = CAddressBook::OpenAddressBookDatabase(csFullName, pDatabaseFile, pDatabase, FALSE);
			if (Error != ERRORCODE_None)
			{
				ThrowErrorcodeException(Error);
			}

			// Create a cursor on the database.
			pCursor = new CFlatFileDatabaseCursor;
			pCursor->Attach(pDatabase);

			pc.m_pCursor = pCursor;
		}

		int nFromPage = pc.m_pInfo->GetFromPage();
		int nToPage = pc.m_pInfo->GetToPage();

		int nError = 0;
		pc.SaveStartOfBand();

		for (;;)
		{
			if (pc.m_fDoubleSided && (nFromPage != nToPage))
			{
				//
				// 1. Put up the dialog telling the user we are about to begin.
				//

				CPmwDialog BeginDialog(IDD_DOUBLE_SIDED_BEGIN);
				if (BeginDialog.DoModal() != IDOK)
				{
					nError = -1;
					break;
				}

				// We need to do the double-sided thing.
				//
				// 2. Print the first half of the document.
				//

				// Print the key sheet now if it goes first.
				if ((pc.m_wDoubleSidedType & DBLPRN_FRONTKEYMASK) == DBLPRN_FrontKeyFirst)
				{
					if ((nError = PrintKeySheetFront(pc)) != 0)
					{
						break;
					}
				}

				// Print the document pages.
				pc.ToStartOfBand();
				if ((nError = PrintLabelsFront(pc)) != 0)
				{
					break;
				}

				// Print the key sheet now if it goes last.
				if ((pc.m_wDoubleSidedType & DBLPRN_FRONTKEYMASK) == DBLPRN_FrontKeyLast)
				{
					if ((nError = PrintKeySheetFront(pc)) != 0)
					{
						break;
					}
				}

				// End the first print job.
				EndPrintDoc(pc, 0);

				//
				// 3. Put up the dialog telling the user to re-insert the stack.
				//

				CPmwDialog NotifyDialog(IDD_DOUBLE_SIDED_NOTIFY);
				if (NotifyDialog.DoModal() != IDOK)
				{
					nError = -1;
					break;
				}

				//
				// 4. Print the second half of the document.
				//

				// Start up the second print job.
				if ((nError = StartPrintDoc(pc)) != 0)
				{
					break;
				}

				// Print the key sheet now if it goes first.
				if ((pc.m_wDoubleSidedType & DBLPRN_BACKKEYMASK) == DBLPRN_BackKeyFirst)
				{
					if ((nError = PrintKeySheetBack(pc)) != 0)
					{
						break;
					}
				}

				// Print the document pages.
				pc.ToStartOfBand();
				if ((nError = PrintLabelsBack(pc)) != 0)
				{
					break;
				}

				// Print the key sheet now if it goes last.
				if ((pc.m_wDoubleSidedType & DBLPRN_BACKKEYMASK) == DBLPRN_BackKeyLast)
				{
					if ((nError = PrintKeySheetBack(pc)) != 0)
					{
						break;
					}
				}
			}
			else
			{
				// Not double-sided. See what page(s) to print.
				//
				// Here are the cases:
				// From == 1, To == 1 (Front only)
				// From == 2, To == 2 (Back only)
				// From == 1, To == 2 (Both pages)
				//
				// So, we print page 1 if "from" is 1, and we print page 2 if "to" is 2.

				if (nFromPage == 1)
				{
					// Print the fronts in forward order.
					pc.ToStartOfBand();
					if ((nError = PrintLabelsForward(pc, 0)) != 0)
					{
						break;
					}
				}
				if (nToPage == 2)
				{
					// Print the backs in forward order.
					pc.ToStartOfBand();
					if ((nError = PrintLabelsForward(pc, 1)) != 0)
					{
						break;
					}
				}
			}
			// Done. Always leave!
			break;
		}
	}
	END_TRY

	BOOL fReflow = !fOldShow;
	pMacroServer->ShowMacroValues(fOldShow);
	if (nNames != 0 && pc.m_nCurrentName > 0)
	{
	/* Go back to the first name. */
		if (pCursor != NULL)
		{
			pMacroServer->BindToRecord(pCursor, pNameList->Name(0));
		}
		fReflow = TRUE;
	}

	if (fReflow)
	{
		pDoc->ReflowMacros();
	}

	delete pCursor;
	pCursor = NULL;
	CAddressBook::CloseAddressBookDatabase(pDatabaseFile, pDatabase);

	return nError;
}
Beispiel #12
0
void While::doPrint(PrintContext &context) const {
    context.out() << "while (";
    condition()->print(context);
    context.out() << ") ";
    printNestedStatement(body(), context);
}
Beispiel #13
0
void LabelIdentifier::doPrint(PrintContext &context) const {
    context.out() << declaration_->identifier();
}
void FunctionDeclaration::doPrint(PrintContext &context) const {
    printComment(context);
    printSignature(context);
    context.out() << ';';
}
Beispiel #15
0
static void probe_str(const char *key, const char *value)
{
    octx.print_string(key, value);
    octx.prefix[octx.level -1].nb_elems++;
}
Beispiel #16
0
static void probe_int(const char *key, int64_t value)
{
    octx.print_integer(key, value);
    octx.prefix[octx.level -1].nb_elems++;
}
Beispiel #17
0
static void probe_object_footer(const char *name)
{
    probe_group_leave();
    if (octx.print_object_footer)
        octx.print_object_footer(name);
}
Beispiel #18
0
void InlineAssembly::doPrint(PrintContext &context) const {
    context.out() << "__asm__(\"" << code() << "\")";
}
Beispiel #19
0
void Goto::doPrint(PrintContext &context) const {
    context.out() << "goto ";
    destination_->print(context);
    context.out() << ';';
}
Beispiel #20
0
static void probe_footer(void)
{
    if (octx.print_footer)
        octx.print_footer();
    probe_group_leave();
}
Beispiel #21
0
static void probe_header(void)
{
    if (octx.print_header)
        octx.print_header();
    probe_group_enter("root", OBJECT);
}
Beispiel #22
0
void Switch::doPrint(PrintContext &context) const {
    context.out() << "switch (";
    expression()->print(context);
    context.out() << ") ";
    printNestedStatement(body(), context);
}
Beispiel #23
0
static void end_print_callback(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data)
{
    PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data);
    printContext->end();
}
Beispiel #24
0
static void probe_array_footer(const char *name, int plain_values)
{
    probe_group_leave();
    if (octx.print_array_footer)
        octx.print_array_footer(name, plain_values);
}