コード例 #1
0
            std::pair<I, O>
            operator()(I begin, S end, O result, S2 end_result, BOp bop_ = BOp{},
                       P proj_ = P{}) const
            {
                auto &&bop = as_function(bop_);
                auto &&proj = as_function(proj_);
                using V = iterator_value_t<I>;
                using X = concepts::Callable::result_t<P, V>;
                coerce<V> v;
                coerce<X> x;

                if(begin != end && result != end_result)
                {
                    auto t1(x(proj(v(*begin))));
                    *result = t1;
                    for(++begin, ++result; begin != end && result != end_result;
                        ++begin, ++result)
                    {
                        auto t2(x(proj(v(*begin))));
                        *result = bop(t2, t1);
                        t1 = std::move(t2);
                    }
                }
                return {begin, result};
            }
コード例 #2
0
ファイル: bootstra.c プロジェクト: shuowen/OpenNT
void bootstrap3()
{
    char *p;
    char error_str[80];

    if (getCF())
    {
        /*
             * Write error on PC screen - assumes reset has positioned the
         * cursor for us.  Note that we can call the video using a BOP since
         * the video code does not itself use interrupts.
         */

        sprintf(error_str,"DOS boot error - cannot open hard disk file");
        p = error_str;
        while (*p != '\0')
        {
            setAH(14);
            setAL(*p++);
            bop(BIOS_VIDEO_IO);
        }
    }

    /*
     * enable hardware interrupts before we jump to DOS
     */

    setIF(1);
}
コード例 #3
0
ファイル: main.cpp プロジェクト: drmonkeysee/CppTestArena
void static_func_wrapping()
{
    static_func<one_param> op;
    static_func<no_param> np;
    op(10);
    // this call is static_func<no_param>::operator() which just returns value
    // interferes with implicit conversion to function pointer
    np();
    np()();
    
    auto opf = op.value;
    auto npf = np.value;
    opf(12);
    npf();
    
    better_static_func<one_param> bop;
    better_static_func<no_param> bnp;
    bop(20);
    bnp();
    
    auto bopf = bop.func;
    auto bnpf = bnp.func;
    bopf(22);
    bnpf();
    
    better_static_func<&one_param> bopp;
    bopp(30);
    
    // fails static assert
    //better_static_func<5> badFunc;
}
コード例 #4
0
int main(int argc, const char * argv[]) {
    Number *a = new Number(2);
    Number *b = new Number(2);
    BinaryOperation bop(a, '+', b);

    Expression const * expr = &bop;
    PrintVisitor visitor;
    expr->visit(&visitor);
    return 0;
}
コード例 #5
0
ファイル: partial_sum.hpp プロジェクト: GorNishanov/range-v3
            std::pair<I, O>
            operator()(I begin, S end, O result, BOp bop_ = BOp{},
                       P proj_ = P{}) const
            {
                auto &&bop = invokable(bop_);
                auto &&proj = invokable(proj_);
                using V = iterator_value_t<I>;
                using X = concepts::Invokable::result_t<P, V>;
                coerce<V> v;
                coerce<X> x;

                if(begin != end)
                {
                    auto t(x(proj(v(*begin))));
                    *result = t;
                    for(++begin, ++result; begin != end; ++begin, ++result)
                    {
                        t = bop(t, proj(*begin));
                        *result = t;
                    }
                }
                return {begin, result};
            }
コード例 #6
0
            std::pair<I, O>
            operator()(I begin, S end, O result, BOp bop_ = BOp{}, P proj_ = P{}) const
            {
                // BUGBUG think about the use of coerce here.
                auto &&bop = invokable(bop_);
                auto &&proj = invokable(proj_);
                using V = iterator_value_t<I>;
                using X = concepts::Invokable::result_t<P, V>;
                coerce<V> v;
                coerce<X> x;

                if(begin != end)
                {
                    auto t1(x(proj(v(*begin))));
                    *result = t1;
                    for(++begin, ++result; begin != end; ++begin, ++result)
                    {
                        auto t2(x(proj(v(*begin))));
                        *result = bop(t2, t1);
                        t1 = std::move(t2);
                    }
                }
                return {begin, result};
            }
コード例 #7
0
    // Processor boundaries from split cyclics
    forAll(patches, patchi)
    {
        if (isA<cyclicPolyPatch>(patches[patchi]))
        {
            const cyclicPolyPatch& pp = refCast<const cyclicPolyPatch>
            (
                patches[patchi]
            );

            if (pp.owner() != owner)
            {
                continue;
            }

            // cyclic: check opposite side on this processor
            const labelUList& patchFaceCells = pp.faceCells();
            const labelUList& nbrPatchFaceCells =
                pp.neighbPatch().faceCells();

            // Store old sizes. Used to detect which inter-proc patches
            // have been added to.
            labelListList oldInterfaceSizes(nProcs_);
            forAll(oldInterfaceSizes, proci)
            {
                labelList& curOldSizes = oldInterfaceSizes[proci];

                curOldSizes.setSize(interPatchFaces[proci].size());
                forAll(curOldSizes, interI)
                {
                    curOldSizes[interI] =
                        interPatchFaces[proci][interI].size();
                }
            }

            // Add faces with different owner and neighbour processors
            forAll(patchFaceCells, facei)
            {
                const label ownerProc = cellToProc_[patchFaceCells[facei]];
                const label nbrProc = cellToProc_[nbrPatchFaceCells[facei]];
                if (bop(ownerProc, nbrProc))
                {
                    // inter - processor patch face found.
                    addInterProcFace
                    (
                        pp.start()+facei,
                        ownerProc,
                        nbrProc,
                        procNbrToInterPatch,
                        interPatchFaces
                    );
                }
            }

            // 1. Check if any faces added to existing interfaces
            forAll(oldInterfaceSizes, proci)
            {
                const labelList& curOldSizes = oldInterfaceSizes[proci];

                forAll(curOldSizes, interI)
                {
                    label oldSz = curOldSizes[interI];
                    if (interPatchFaces[proci][interI].size() > oldSz)
                    {
                        // Added faces to this interface. Add an entry
                        append(subPatchIDs[proci][interI], patchi);
                        append(subPatchStarts[proci][interI], oldSz);
                    }
                }
            }
コード例 #8
0
ファイル: Song.cpp プロジェクト: mrchay/rejuce
int Song::tick(MidiMessageCollector* pCollector)
{
	int ret = _clock;

	if (_state==SONG_PLAYING ||
		_state==SONG_RECORDING)
	{
		// only pass on ticks if we are not in 'countdown' mode
		bool bTick = false;
		if (_state==SONG_PLAYING)
		{
			bTick = true;
		}
		else if (_state==SONG_RECORDING)
		{
			if (_metronomeBars!=0)
			{
				if (_countInClockPos > _countInClockMax)
				{
					bTick=true;
				}
				else
				{
					printf("pos %d\n",_countInClockPos);
					_countInClockPos++;
				}
			}
			else
			{
				bTick=true;
			}
		}

		if (bTick)
			_pCurrentSection->tick(pCollector);

		ret = _clock;

		// metronome
		if (_metronomeState!=METRONOME_OFF &&
				( (_state==SONG_RECORDING) || (_state==SONG_PLAYING && _metronomeState==METRONOME_PLAY) ) )
		{
			if (_clock % PHRASE_CLOCKS == 0)
			{
				if (_clock == 0)
				{
					MidiMessage bip(0xf2,0x00,Time::getMillisecondCounterHiRes()/1000.0f);
					pCollector->addMessageToQueue(bip);
				}
				else
				{
					MidiMessage bop(0xf2,0x01,Time::getMillisecondCounterHiRes()/1000.0f);
					pCollector->addMessageToQueue(bop);
				}
			}
		}

		// pulse play light in time with beats
		if (_clock % PHRASE_CLOCKS == 0)
		{
			HostEvent h = HostEventFactory::event(HC_OUT_BEAT);
			_pHostEventListener->onHostEvent(h);
		}

		// inc clock
		if (_clock < _currentPatternLengthClocks-1)
		{
			_clock++;
		}
		else
		{
			// should we quantise?
			if (_autoQuant)
			{
				quantisePhrase();
			}

			// we might need to change pattern.
			if (_currentSection != _nextSection)
			{
				_pCurrentSection->stop();

				_currentSection = _nextSection;
				_pCurrentSection = _sections[_nextSection];

				_currentPatternLengthClocks = _pCurrentSection->getLengthClocks();

				HostEvent h = HostEventFactory::event(HC_OUT_SECTION_CHANGE,_currentSection);
				_pHostEventListener->onHostEvent(h);
			}

			_clock=0;
		}

	}

	return ret;
}
コード例 #9
0
ファイル: arith.c プロジェクト: BRAINSia/teem
int
nrrdArithIterBinaryOpSelect(Nrrd *nout, int op,
                            NrrdIter *inA, NrrdIter *inB,
                            unsigned int which) {
  static const char me[]="nrrdArithIterBinaryOpSelect";
  char *contA, *contB;
  size_t N, I, size[NRRD_DIM_MAX];
  int type;
  double (*insert)(void *v, size_t I, double d),
    (*bop)(double a, double b), valA, valB;
  const Nrrd *nin;

  if (!(nout && inA && inB)) {
    biffAddf(NRRD, "%s: got NULL pointer", me);
    return 1;
  }
  if (airEnumValCheck(nrrdBinaryOp, op)) {
    biffAddf(NRRD, "%s: binary op %d invalid", me, op);
    return 1;
  }
  if (!( 0 == which || 1 == which )) {
    biffAddf(NRRD, "%s: which %u not 0 or 1", me, which);
    return 1;
  }
  nin = (0 == which
         ? _NRRD_ITER_NRRD(inA)
         : _NRRD_ITER_NRRD(inB));
  if (!nin) {
    biffAddf(NRRD, "%s: selected input %u is a fixed value", me, which);
    return 1;
  }
  type = nin->type;
  nrrdAxisInfoGet_nva(nin, nrrdAxisInfoSize, size);

  if (_nrrdMaybeAllocMaybeZero_nva(nout, type, nin->dim, size,
                                   AIR_FALSE /* zero when no realloc */)) {
    biffAddf(NRRD, "%s: couldn't allocate output nrrd", me);
    return 1;
  }
  nrrdBasicInfoCopy(nout, nin, (NRRD_BASIC_INFO_DATA_BIT
                                | NRRD_BASIC_INFO_TYPE_BIT
                                | NRRD_BASIC_INFO_DIMENSION_BIT
                                | NRRD_BASIC_INFO_CONTENT_BIT
                                | NRRD_BASIC_INFO_COMMENTS_BIT
                                | (nrrdStateKeyValuePairsPropagate
                                   ? 0
                                   : NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT)));
  nrrdBasicInfoInit(nout,
                    NRRD_BASIC_INFO_ALL ^ (NRRD_BASIC_INFO_OLDMIN_BIT
                                           | NRRD_BASIC_INFO_OLDMAX_BIT));
  bop = _nrrdBinaryOp[op];

  /*
  fprintf(stderr, "%s: inA->left = %d, inB->left = %d\n", me,
          (int)(inA->left), (int)(inB->left));
  */
  N = nrrdElementNumber(nin);
  insert = nrrdDInsert[type];
  for (I=0; I<N; I++) {
    /* HEY: there is a loss of precision issue here with 64-bit ints */
    valA = nrrdIterValue(inA);
    valB = nrrdIterValue(inB);
    insert(nout->data, I, bop(valA, valB));
  }
  contA = nrrdIterContent(inA);
  contB = nrrdIterContent(inB);
  if (_nrrdContentSet_va(nout, airEnumStr(nrrdBinaryOp, op),
                         contA, "%s", contB)) {
    biffAddf(NRRD, "%s:", me);
    free(contA); free(contB); return 1;
  }
  if (nout != nin) {
    nrrdAxisInfoCopy(nout, nin, NULL, NRRD_AXIS_INFO_NONE);
  }
  free(contA);
  free(contB);
  return 0;
}
コード例 #10
0
ファイル: arith.c プロジェクト: BRAINSia/teem
/*
******** nrrdArithBinaryOp
**
** this is a simplified version of nrrdArithIterBinaryOp, written after
** that, in a hurry, to operate directly on two nrrds, instead with
** the NrrdIter nonsense
*/
int
nrrdArithBinaryOp(Nrrd *nout, int op, const Nrrd *ninA, const Nrrd *ninB) {
  static const char me[]="nrrdArithBinaryOp";
  char *contA, *contB;
  size_t N, I, size[NRRD_DIM_MAX];
  double (*ins)(void *v, size_t I, double d),
    (*lupA)(const void *v, size_t I), (*lupB)(const void *v, size_t I),
    (*bop)(double a, double b), valA, valB;

  if (!( nout && !nrrdCheck(ninA) && !nrrdCheck(ninB) )) {
    biffAddf(NRRD, "%s: NULL pointer or invalid args", me);
    return 1;
  }
  if (nrrdTypeBlock == ninA->type || nrrdTypeBlock == ninB->type) {
    biffAddf(NRRD, "%s: can't operate on type %s", me,
             airEnumStr(nrrdType, nrrdTypeBlock));
    return 1;
  }
  if (!nrrdSameSize(ninA, ninB, AIR_TRUE)) {
    biffAddf(NRRD, "%s: size mismatch between arguments", me);
    return 1;
  }
  if (airEnumValCheck(nrrdBinaryOp, op)) {
    biffAddf(NRRD, "%s: binary op %d invalid", me, op);
    return 1;
  }

  nrrdAxisInfoGet_nva(ninA, nrrdAxisInfoSize, size);
  if (!( nout == ninA || nout == ninB)) {
    if (_nrrdMaybeAllocMaybeZero_nva(nout, ninA->type, ninA->dim, size,
                                     AIR_FALSE /* zero when no realloc */)) {
      biffAddf(NRRD, "%s: couldn't allocate output nrrd", me);
      return 1;
    }
    if (nrrdAxisInfoCopy(nout, ninA, NULL, NRRD_AXIS_INFO_NONE)) {
      biffAddf(NRRD, "%s:", me);
      return 1;
    }
    nrrdBasicInfoCopy(nout, ninA, (NRRD_BASIC_INFO_DATA_BIT
                                   | NRRD_BASIC_INFO_TYPE_BIT
                                   | NRRD_BASIC_INFO_DIMENSION_BIT
                                   | NRRD_BASIC_INFO_CONTENT_BIT
                                   | NRRD_BASIC_INFO_COMMENTS_BIT
                                   | (nrrdStateKeyValuePairsPropagate
                                      ? 0
                                      : NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT)));
  }
  nrrdBasicInfoInit(nout,
                    NRRD_BASIC_INFO_ALL ^ (NRRD_BASIC_INFO_OLDMIN_BIT
                                           | NRRD_BASIC_INFO_OLDMAX_BIT));
  bop = _nrrdBinaryOp[op];

  N = nrrdElementNumber(ninA);
  lupA = nrrdDLookup[ninA->type];
  lupB = nrrdDLookup[ninB->type];
  ins = nrrdDInsert[nout->type];
  for (I=0; I<N; I++) {
    /* HEY: there is a loss of precision issue here with 64-bit ints */
    valA = lupA(ninA->data, I);
    valB = lupB(ninB->data, I);
    ins(nout->data, I, bop(valA, valB));
  }

  contA = _nrrdContentGet(ninA);
  contB = _nrrdContentGet(ninB);
  if (_nrrdContentSet_va(nout, airEnumStr(nrrdBinaryOp, op),
                         contA, "%s", contB)) {
    biffAddf(NRRD, "%s:", me);
    free(contA); free(contB); return 1;
  }
  free(contA);
  free(contB);
  return 0;
}
コード例 #11
0
ファイル: inline12.C プロジェクト: VargMon/dd-wrt
void
xSh::uff()
{
  static const udword halfudword = 0x80000000;
  xUff aGah((udword)0);
  udword diagonal = halfudword + (udword) aGah;
  xUff aGeh(diagonal - 1);
  xUff aGoh(diagonal + 1);
  (bop()->shWw ((aGah.operator <=(aGah)), ("foo"), ( ""), 118, "foo"));
  (bop()->shWw ((aGah.operator >=(aGah)), ("foo"), ( ""), 119, "foo"));
  (bop()->shWw ((!(aGah.operator <(aGah))), ("foo"), ( ""), 120, "foo"));
  (bop()->shWw ((!(aGah.operator >(aGah))), ("foo"), ( ""), 121, "foo"));
  (bop()->shWw ((aGah.operator <(aGeh)), ("foo"), ( ""), 124, "foo"));
  (bop()->shWw ((aGah.operator <=(aGeh)), ("foo"), ( ""), 125, "foo"));
  (bop()->shWw ((!(aGah.operator >(aGeh))), ("foo"), ( ""), 126, "foo"));
  (bop()->shWw ((!(aGah.operator >=(aGeh))), ("foo"), ( ""), 127, "foo"));
  (bop()->shWw ((aGeh.operator >(aGah)), ("foo"), ( ""), 130, "foo"));
  (bop()->shWw ((aGeh.operator >=(aGah)), ("foo"), ( ""), 131, "foo"));
  (bop()->shWw ((!(aGeh.operator <(aGah))), ("foo"), ( ""), 132, "foo"));
  (bop()->shWw ((!(aGeh.operator <=(aGah))), ("foo"), ( ""), 133, "foo"));
  (bop()->shWw ((aGeh.operator <(aGoh)), ("foo"), ( ""), 136, "foo"));
  (bop()->shWw ((aGeh.operator <=(aGoh)), ("foo"), ( ""), 137, "foo"));
  (bop()->shWw ((!(aGeh.operator >(aGoh))), ("foo"), ( ""), 138, "foo"));
  (bop()->shWw ((!(aGeh.operator >=(aGoh))), ("foo"), ( ""), 139, "foo"));
  (bop()->shWw ((aGoh.operator >(aGeh)), ("foo"), ( ""), 142, "foo"));
  (bop()->shWw ((aGoh.operator >=(aGeh)), ("foo"), ( ""), 143, "foo"));
  (bop()->shWw ((!(aGoh.operator <(aGeh))), ("foo"), ( ""), 144, "foo"));
  (bop()->shWw ((!(aGoh.operator <=(aGeh))), ("foo"), ( ""), 145, "foo"));
  (bop()->shWw ((aGah.operator >(aGoh)), ("foo"), ( ""), 152, "foo"));
  (bop()->shWw ((aGah.operator >=(aGoh)), ("foo"), ( ""), 153, "foo"));
  (bop()->shWw ((!(aGah.operator <(aGoh))), ("foo"), ( ""), 154, "foo"));
  (bop()->shWw ((!(aGah.operator <=(aGoh))), ("foo"), ( ""), 155, "foo"));
  (bop()->shWw ((aGoh.operator <(aGah)), ("foo"), ( ""), 158, "foo"));
  (bop()->shWw ((aGoh.operator <=(aGah)), ("foo"), ( ""), 159, "foo"));
  (bop()->shWw ((!(aGoh.operator >(aGah))), ("foo"), ( ""), 160, "foo"));
  (bop()->shWw ((!(aGoh.operator >=(aGah))), ("foo"), ( ""), 161, "foo"));
}