std::string LispPrinter::PrintToString(LispInterpreter *L, LispObjectPtr obj) { switch (L->TypeOf(obj)) { case LispObjectType::Null: return "nil"; case LispObjectType::Number: { std::ostringstream s; s << L->NumVal(obj); return s.str(); } case LispObjectType::Symbol: return L->SymbolName(obj); case LispObjectType::Cons: { if (L->Eq(L->Car(obj), L->SymbolRef("quote"))) { return "'" + PrintToString(L, L->Cadr(obj)); } else { std::string s("("); LispObjectPtr n = obj; while (!L->Null(n)) { s.append(PrintToString(L, L->Car(n))); n = L->Cdr(n); if (!L->Null(n) && L->Atom(n)) { s.append(" . "); s.append(PrintToString(L, n)); n = L->Nil; } if (!L->Null(n)) { s.append(" "); } } s.append(")"); return s; } } case LispObjectType::CFunction: return "<CFunction>"; case LispObjectType::Boolean: return L->BoolVal(obj) ? "true" : "false"; case LispObjectType::String: return "\"" + L->StringVal(obj) + "\""; case LispObjectType::Eof: return "<Eof>"; default: return ""; } }
TEST_F(AnimationAnimatableValueTestHelperTest, PrintTo) { EXPECT_THAT( PrintToString(AnimatableClipPathOperation::create(ShapeClipPathOperation::create(BasicShapeCircle::create()).get())), testing::StartsWith("AnimatableClipPathOperation") ); EXPECT_EQ( ::std::string("AnimatableColor(rgba(0, 0, 0, 0), #ff0000)"), PrintToString(AnimatableColor::create(Color(0x000000FF), Color(0xFFFF0000)))); EXPECT_THAT( PrintToString(AnimatableValue::neutralValue().get()), testing::StartsWith("AnimatableNeutral@")); EXPECT_THAT( PrintToString(AnimatableShapeValue::create(ShapeValue::createShapeValue(BasicShapeCircle::create(), ContentBox))), testing::StartsWith("AnimatableShapeValue@")); RefPtr<SVGDashArray> l2 = SVGDashArray::create(); l2->append(Length(1, blink::Fixed)); l2->append(Length(2, blink::Percent)); EXPECT_EQ( ::std::string("AnimatableStrokeDasharrayList(1+0%, 0+2%)"), PrintToString(AnimatableStrokeDasharrayList::create(l2, 1))); EXPECT_EQ( ::std::string("AnimatableUnknown(none)"), PrintToString(AnimatableUnknown::create(CSSPrimitiveValue::createIdentifier(CSSValueNone)))); EXPECT_EQ( ::std::string("AnimatableVisibility(VISIBLE)"), PrintToString(AnimatableVisibility::create(VISIBLE))); }
void RenderFramesPerSecond(int frameNumber) { struct RastPort *rastPort = GetCurrentRastPort(); int fps = (int)(100 * CalculateFramesPerSecond(frameNumber)); int width = rastPort->BitMap->BytesPerRow * 8; char text[6]; PrintToString(text, sizeof(text), "%2ld.%02ld", fps / 100, fps % 100); RenderText(text, width - (2 + 8 * 5), 8); }
void RenderTime(int frameNumber, float beatsPerFrame) { char text[20]; int min = (frameNumber / FRAMERATE) / 60; int sec = (frameNumber / FRAMERATE) % 60; float beat = truncf((float)frameNumber / beatsPerFrame);; PrintToString(text, sizeof(text), "%4ldf %ldm%02lds %ldb", frameNumber, min, sec, (int)beat); RenderText(text, 2, 8); }
AssertionResult assertMatNear(const char* expr1, const char* expr2, const char* eps_expr, InputArray m1_, InputArray m2_, double eps) { Mat m1 = getMat(m1_); Mat m2 = getMat(m2_); if (m1.size() != m2.size()) { return AssertionFailure() << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different sizes : \"" << expr1 << "\" [" << PrintToString(m1.size()) << "] vs \"" << expr2 << "\" [" << PrintToString(m2.size()) << "]"; } if (m1.type() != m2.type()) { return AssertionFailure() << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different types : \"" << expr1 << "\" [" << PrintToString(MatType(m1.type())) << "] vs \"" << expr2 << "\" [" << PrintToString(MatType(m2.type())) << "]"; } Mat diff; absdiff(m1.reshape(1), m2.reshape(1), diff); double maxVal = 0.0; Point maxLoc; minMaxLocGold(diff, 0, &maxVal, 0, &maxLoc); if (maxVal > eps) { return AssertionFailure() << "The max difference between matrices \"" << expr1 << "\" and \"" << expr2 << "\" is " << maxVal << " at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ")" << ", which exceeds \"" << eps_expr << "\", where \"" << expr1 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m1, maxLoc) << ", \"" << expr2 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m2, maxLoc) << ", \"" << eps_expr << "\" evaluates to " << eps; } return AssertionSuccess(); }
std::ostream& operator<<( std::ostream& os, const CharacterSequence &characters ) { os << PrintToString( characters ); return os; }
std::ostream& operator<<( std::ostream& os, const TextCodePointPair &pair ) { os << "{ " << PrintToString( pair.text ) << ", " << PrintToString( pair.code_point_tuple ) << " }"; return os; }
void Node::Print() const { std::cout << PrintToString() << std::endl; }
void RenderFrameNumber(int frameNumber) { char text[5]; PrintToString(text, sizeof(text), "%04ld", frameNumber); RenderText(text, 2, 8); }