string handing_int(vector<string> p) { if (p.size() == 4) { if (p[2] != ">>" || p[2] != "<<") { Qint int1(p[1], p[0]); Qint int2(p[3], p[0]); if (p[2] == "+") { return (int1 + int2).write(p[0]); } if (p[2] == "-") { return (int1 - int2).write(p[0]); } if (p[2] == "*") { return (int1 * int2).write(p[0]); } if (p[2] == "/") { return (int1 / int2).write(p[0]); } } Qint int1(p[1], p[0]); int tmp = atoi(p[3].c_str()); if (p[2] == ">>") return (int1 >> tmp).write(p[0]); if (p[2] == "<<") return (int1 << tmp).write(p[0]); } if (p.size() == 3) { Qint int1(p[2], p[0]); if (p[1] == "2") return int1.write("2"); if (p[1] == "10") return int1.write("10"); if (p[1] == "16") return int1.write("16"); if (p[1] == "ror") return (int1.ror(1)).write(p[0]); if (p[1] == "rol") return (int1.rol(1)).write(p[0]); if (p[1] == "~") return (~int1).write(p[0]); } return ""; }
int minutes_of_observational_data_cutoff_after_reference_time(unsigned char **sec) { int p; p = GB2_ProdDefTemplateNo(sec); if (p <= 15 || p == 1000 || p == 1001 || p == 1002 || p == 1100 || p == 1101) return int1(sec[4]+16); return -1; }
static void TestCatalog(skiatest::Reporter* reporter) { SkPDFCatalog catalog((SkPDFDocument::Flags)0); SkAutoTUnref<SkPDFInt> int1(new SkPDFInt(1)); SkAutoTUnref<SkPDFInt> int2(new SkPDFInt(2)); SkAutoTUnref<SkPDFInt> int3(new SkPDFInt(3)); int1.get()->ref(); SkAutoTUnref<SkPDFInt> int1Again(int1.get()); catalog.addObject(int1.get(), false); catalog.addObject(int2.get(), false); catalog.addObject(int3.get(), false); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int1.get()) == 3); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int2.get()) == 3); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int3.get()) == 3); SkDynamicMemoryWStream buffer; catalog.emitObjectNumber(&buffer, int1.get()); catalog.emitObjectNumber(&buffer, int2.get()); catalog.emitObjectNumber(&buffer, int3.get()); catalog.emitObjectNumber(&buffer, int1Again.get()); char expectedResult[] = "1 02 03 01 0"; REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult, strlen(expectedResult))); }
void IntegerBasicTest() { Dissent::Crypto::Integer int0(5); Dissent::Crypto::Integer int1(6); EXPECT_NE(int0, int1); EXPECT_EQ(int0, int1 - 1); EXPECT_EQ(int0 + 1, int1); EXPECT_TRUE(int0 < int1); EXPECT_TRUE(int1 > int0); EXPECT_TRUE(int0 <= int1); EXPECT_TRUE(int1 >= int0); EXPECT_TRUE(int0 + 1 <= int1); EXPECT_TRUE(int1 - 1 >= int0); std::swap(int0, int1); EXPECT_NE(int0, int1); EXPECT_EQ(int0, int1 + 1); EXPECT_EQ(int0 - 1, int1); EXPECT_TRUE(int0 > int1); EXPECT_TRUE(int1 < int0); EXPECT_TRUE(int0 >= int1); EXPECT_TRUE(int1 <= int0); EXPECT_TRUE(int0 - 1 >= int1); EXPECT_TRUE(int1 + 1 <= int0); EXPECT_EQ(int0 * int1, Integer(30)); EXPECT_EQ(Integer(30) / int0, int1); EXPECT_EQ(Integer(30) / int1, int0); }
float4 __CGsampler_state::minify(int ndx, float4 strq, float1 lod) { assert(lod > 0); // Otherwise should be in minify switch (minFilter) { default: assert(!"unexpected minification filter"); case GL_NEAREST: return nearestFilter(trueBaseLevel, strq); case GL_NEAREST_MIPMAP_NEAREST: { int level = clamp(int1(trueBaseLevel + round(lod)), trueBaseLevel, effectiveMaxLevel); return nearestFilter(level, strq); } case GL_LINEAR_MIPMAP_NEAREST: { int level = clamp(int1(trueBaseLevel + round(lod)), trueBaseLevel, effectiveMaxLevel); return linearFilter(level, strq); } case GL_NEAREST_MIPMAP_LINEAR: { int level0 = max(trueBaseLevel + int(floor(lod)), effectiveMaxLevel); int level1 = max(level0 + 1, effectiveMaxLevel); float4 tex0 = nearestFilter(level0, strq); float4 tex1 = nearestFilter(level1, strq); return lerp(tex0, tex1, frac(lod)); } case GL_LINEAR_MIPMAP_LINEAR: { int level0 = max(trueBaseLevel + int(floor(lod)), effectiveMaxLevel); int level1 = max(level0 + 1, effectiveMaxLevel); float4 tex0 = linearFilter(level0, strq); float4 tex1 = linearFilter(level1, strq); return lerp(tex0, tex1, frac(lod)); } case GL_LINEAR: return linearFilter(trueBaseLevel, strq); } }
/** * Device autodetection. Scans the given I2C bus for supported accelerometer devices. * if found, constructs an appropriate driver and returns it. * * @param i2c the bus to scan. * @param id the unique EventModel id of this component. Defaults to: MICROBIT_ID_ACCELEROMETER * */ MicroBitAccelerometer& MicroBitAccelerometer::autoDetect(MicroBitI2C &i2c) { if (MicroBitAccelerometer::detectedAccelerometer == NULL) { // Configuration of IRQ lines MicroBitPin int1(MICROBIT_ID_IO_INT1, P0_28, PIN_CAPABILITY_STANDARD); MicroBitPin int2(MICROBIT_ID_IO_INT2, P0_29, PIN_CAPABILITY_STANDARD); MicroBitPin int3(MICROBIT_ID_IO_INT3, P0_27, PIN_CAPABILITY_STANDARD); // All known accelerometer/magnetometer peripherals have the same alignment CoordinateSpace &coordinateSpace = *(new CoordinateSpace(SIMPLE_CARTESIAN, true, COORDINATE_SPACE_ROTATED_0)); // Now, probe for connected peripherals, if none have already been found. if (MMA8653::isDetected(i2c)) MicroBitAccelerometer::detectedAccelerometer = new MMA8653(i2c, int1, coordinateSpace); else if (LSM303Accelerometer::isDetected(i2c)) MicroBitAccelerometer::detectedAccelerometer = new LSM303Accelerometer(i2c, int1, coordinateSpace); else if (FXOS8700::isDetected(i2c)) { FXOS8700 *fxos = new FXOS8700(i2c, int3, coordinateSpace); MicroBitAccelerometer::detectedAccelerometer = fxos; MicroBitCompass::detectedCompass = fxos; } // Insert this case to support FXOS on the microbit1.5-SN //else if (FXOS8700::isDetected(i2c, 0x3A)) //{ // FXOS8700 *fxos = new FXOS8700(i2c, int3, coordinateSpace, 0x3A); // MicroBitAccelerometer::detectedAccelerometer = fxos; // MicroBitCompass::detectedCompass = fxos; //} else { MicroBitAccelerometer *unavailable = new MicroBitAccelerometer(coordinateSpace, MICROBIT_ID_ACCELEROMETER); MicroBitAccelerometer::detectedAccelerometer = unavailable; } } if (MicroBitCompass::detectedCompass) MicroBitCompass::detectedCompass->setAccelerometer(*MicroBitAccelerometer::detectedAccelerometer); return *MicroBitAccelerometer::detectedAccelerometer; }
static void TestObjectRef(skiatest::Reporter* reporter) { SkAutoTUnref<SkPDFInt> int1(new SkPDFInt(1)); SkAutoTUnref<SkPDFInt> int2(new SkPDFInt(2)); SkAutoTUnref<SkPDFObjRef> int2ref(new SkPDFObjRef(int2.get())); SkPDFCatalog catalog((SkPDFDocument::Flags)0); catalog.addObject(int1.get(), false); catalog.addObject(int2.get(), false); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int1.get()) == 3); REPORTER_ASSERT(reporter, catalog.getObjectNumberSize(int2.get()) == 3); char expectedResult[] = "2 0 R"; SkDynamicMemoryWStream buffer; int2ref->emitObject(&buffer, &catalog, false); REPORTER_ASSERT(reporter, buffer.getOffset() == strlen(expectedResult)); REPORTER_ASSERT(reporter, stream_equals(buffer, 0, expectedResult, buffer.getOffset())); }
DEF_TEST(PDFPrimitives, reporter) { SkAutoTUnref<SkPDFInt> int42(new SkPDFInt(42)); SimpleCheckObjectOutput(reporter, int42.get(), "42"); SkAutoTUnref<SkPDFScalar> realHalf(new SkPDFScalar(SK_ScalarHalf)); SimpleCheckObjectOutput(reporter, realHalf.get(), "0.5"); SkAutoTUnref<SkPDFScalar> bigScalar(new SkPDFScalar(110999.75f)); #if !defined(SK_ALLOW_LARGE_PDF_SCALARS) SimpleCheckObjectOutput(reporter, bigScalar.get(), "111000"); #else SimpleCheckObjectOutput(reporter, bigScalar.get(), "110999.75"); SkAutoTUnref<SkPDFScalar> biggerScalar(new SkPDFScalar(50000000.1)); SimpleCheckObjectOutput(reporter, biggerScalar.get(), "50000000"); SkAutoTUnref<SkPDFScalar> smallestScalar(new SkPDFScalar(1.0/65536)); SimpleCheckObjectOutput(reporter, smallestScalar.get(), "0.00001526"); #endif SkAutoTUnref<SkPDFString> stringSimple( new SkPDFString("test ) string ( foo")); SimpleCheckObjectOutput(reporter, stringSimple.get(), "(test \\) string \\( foo)"); SkAutoTUnref<SkPDFString> stringComplex( new SkPDFString("\ttest ) string ( foo")); SimpleCheckObjectOutput(reporter, stringComplex.get(), "<0974657374202920737472696E67202820666F6F>"); SkAutoTUnref<SkPDFName> name(new SkPDFName("Test name\twith#tab")); const char expectedResult[] = "/Test#20name#09with#23tab"; CheckObjectOutput(reporter, name.get(), expectedResult, strlen(expectedResult), false, false); SkAutoTUnref<SkPDFName> escapedName(new SkPDFName("A#/%()<>[]{}B")); const char escapedNameExpected[] = "/A#23#2F#25#28#29#3C#3E#5B#5D#7B#7DB"; CheckObjectOutput(reporter, escapedName.get(), escapedNameExpected, strlen(escapedNameExpected), false, false); // Test that we correctly handle characters with the high-bit set. const unsigned char highBitCString[] = {0xDE, 0xAD, 'b', 'e', 0xEF, 0}; SkAutoTUnref<SkPDFName> highBitName( new SkPDFName((const char*)highBitCString)); const char highBitExpectedResult[] = "/#DE#ADbe#EF"; CheckObjectOutput(reporter, highBitName.get(), highBitExpectedResult, strlen(highBitExpectedResult), false, false); SkAutoTUnref<SkPDFArray> array(new SkPDFArray); SimpleCheckObjectOutput(reporter, array.get(), "[]"); array->append(int42.get()); SimpleCheckObjectOutput(reporter, array.get(), "[42]"); array->append(realHalf.get()); SimpleCheckObjectOutput(reporter, array.get(), "[42 0.5]"); SkAutoTUnref<SkPDFInt> int0(new SkPDFInt(0)); array->append(int0.get()); SimpleCheckObjectOutput(reporter, array.get(), "[42 0.5 0]"); SkAutoTUnref<SkPDFInt> int1(new SkPDFInt(1)); array->setAt(0, int1.get()); SimpleCheckObjectOutput(reporter, array.get(), "[1 0.5 0]"); SkAutoTUnref<SkPDFDict> dict(new SkPDFDict); SimpleCheckObjectOutput(reporter, dict.get(), "<<>>"); SkAutoTUnref<SkPDFName> n1(new SkPDFName("n1")); dict->insert(n1.get(), int42.get()); SimpleCheckObjectOutput(reporter, dict.get(), "<</n1 42\n>>"); SkAutoTUnref<SkPDFName> n2(new SkPDFName("n2")); SkAutoTUnref<SkPDFName> n3(new SkPDFName("n3")); dict->insert(n2.get(), realHalf.get()); dict->insert(n3.get(), array.get()); SimpleCheckObjectOutput(reporter, dict.get(), "<</n1 42\n/n2 0.5\n/n3 [1 0.5 0]\n>>"); TestPDFStream(reporter); TestCatalog(reporter); TestObjectRef(reporter); TestSubstitute(reporter); test_issue1083(); TestImages(reporter); }
void CSL_EfAddInt::Apply(MSL_ExprEnv& aEnv, vector<string>& aArgs, vector<string>::iterator& aArgr, CSL_ExprBase& aArg, CSL_ExprBase*& aRes, const string& aReqType) { CSL_EfAddInt_1 int1(aArg); int1.ApplyArgs(aEnv, aArgs, aArgr, aRes, aReqType); }