Пример #1
0
 static std::string format(llvm::StringRef Code, unsigned Offset,
                           unsigned Length, const FormatStyle &Style) {
   DEBUG(llvm::errs() << "---\n");
   DEBUG(llvm::errs() << Code << "\n\n");
   std::vector<tooling::Range> Ranges(1, tooling::Range(Offset, Length));
   tooling::Replacements Replaces = reformat(Style, Code, Ranges);
   std::string Result = applyAllReplacements(Code, Replaces);
   EXPECT_NE("", Result);
   DEBUG(llvm::errs() << "\n" << Result << "\n\n");
   return Result;
 }
Пример #2
0
 static std::string format(llvm::StringRef Code, unsigned Offset,
                           unsigned Length, const FormatStyle &Style) {
   LLVM_DEBUG(llvm::errs() << "---\n");
   LLVM_DEBUG(llvm::errs() << Code << "\n\n");
   std::vector<tooling::Range> Ranges(1, tooling::Range(Offset, Length));
   tooling::Replacements Replaces = reformat(Style, Code, Ranges);
   auto Result = applyAllReplacements(Code, Replaces);
   EXPECT_TRUE(static_cast<bool>(Result));
   LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
   return *Result;
 }
// on "init" you need to initialize your instance
bool LevelSelectMenu::init()
{
	//////////////////////////////
	// 1. super init first
	if (!cocos2d::Layer::init())
	{
		return false;
	}

	cocos2d::Size visibleSize = cocos2d::Director::getInstance()->getVisibleSize();
	cocos2d::Vec2 origin = cocos2d::Director::getInstance()->getVisibleOrigin();

	int numLevels = LevelManager::getInstance().NumLevelsUnlocked();

	m_numOfRanges = (int)std::ceil(numLevels / 10.0);

	m_ranges = new Ranges[m_numOfRanges];

 	for (int i = 0; i < m_numOfRanges - 1; i++)
	{
		m_ranges[i] = Ranges();

		m_ranges[i].m_min = (i * 10) + 1;
		m_ranges[i].m_max = (i + 1) * 10;
	}

	
	m_ranges[m_numOfRanges - 1] = Ranges();

	m_ranges[m_numOfRanges - 1].m_min = (m_numOfRanges - 1) * 10 + 1;
	if (numLevels % 10 != 0)
		m_ranges[m_numOfRanges - 1].m_max = ((m_numOfRanges - 1) * 10) + numLevels % 10;
	else
		m_ranges[m_numOfRanges - 1].m_max = ((m_numOfRanges) * 10);
	
	m_curRange = 0;

	GenerateCurrentMenu();

	return true;
}
Пример #4
0
//******************************************************************************
//Name:  ResizeField                                                           *
//                                                                             *
//Purpose:  set the number of grid points in the field                         *
//                                                                             *
//Takes: a pointer to an int array                                             *
//******************************************************************************
void field::ResizeField(int *num_grid_pts)
{
   int n, *r, i;

   n = NumIndices();
   r = Ranges();

   for(i = 0; i < 3; i++) r[i] = num_grid_pts[i];

   Resize(n, r);

   delete [] r;
}
Пример #5
0
void thPaletteData::Realize()
{
    //! SetPalette() should call this instead of SetColorRange().

    // First set everything to the first color we have, or black.
    COLORREF firstColor = Ranges() ? beginColor[0] : 0;
    SetColorRange(0, 255, firstColor, firstColor, clr);

    for (size_t i = 0; i < begin.GetCount(); i++)
    {
        SetColorRange(begin[i], end[i], beginColor[i], endColor[i], clr);
    }
}
Пример #6
0
//******************************************************************************
//Name:  GetTensor                                                             *
//                                                                             *
//Purpose:  get the tensor portion of the field given the position             *
//                                                                             *
//Takes: position stored as a tensor                                           *
//******************************************************************************
tensor  field::GetTensor(int *indices)
{
   tensor temp;
   int n, *r, new_n, *new_r;
   int i, j, dummy;

   //Get the total number of indices and ranges of the field
   n = NumIndices();
   r = Ranges();

   //Determine the number of indices on the temp tensor
   new_n = n  - 3;

   //Make a new array for resizing temp
   new_r = new int[new_n];

   //Pack the new_r array with the
   for( i = 0; i < new_n; i++ )
    {
      new_r[i] = r[i + 3];
    }

   //Resize the temp tensor
   temp.Resize(new_n, new_r);

   //Let the r array do double duty and pack the first three elements with the
   //values in the indices array
   for( i = 0; i < 3; i++) r[i] = indices[i];

   //now pack temp with the components of the tensor portion of the field
   for( i = 0; i < temp.p->product; i++)
	 {
      //Let the last indices of the r array hold the
      //index structure for the temp tensor
      dummy = 0;
      for( j = 0; j < new_n; j++)
       {
         r[j + 3] = (i - i%temp.p->scales[j] - dummy)/temp.p->scales[j];
         dummy += r[j + 3] * temp.p->scales[j];
       }

       temp.p->m[i] = Val(r);
    }

  //Clean up
  delete [] r;
  delete [] new_r;

  //Return the tensor
  return temp;
}
Пример #7
0
bool thPaletteData::Get(size_t n, int *begin, COLORREF *beginColor, int *end, COLORREF *endColor) const
{
    if (n >= Ranges())
        return false;
    if (begin)
        *begin = this->begin[n];
    if (beginColor)
        *beginColor = this->beginColor[n];
    if (end)
        *end = this->end[n];
    if (endColor)
        *endColor = this->endColor[n];
    return true;
}
Пример #8
0
int thPalette::FindRange(int index) const
{
    // search for selected index in color ranges
    for (int i = Ranges() - 1; i >= 0; i--)
    {
        int b, e;
        Get(i, &b, NULL, &e, NULL);
        if (b > e && e >= 0)
            th_swap(b, e);
        if ((e == -1 && index == b) ||
            (index >= b && index <= e))
            return i;
    }
    return -1;
}
Пример #9
0
 std::string format(llvm::StringRef Code, unsigned Offset, unsigned Length,
                    const FormatStyle &Style) {
   RewriterTestContext Context;
   FileID ID = Context.createInMemoryFile("input.cc", Code);
   SourceLocation Start =
       Context.Sources.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   std::vector<CharSourceRange> Ranges(
       1,
       CharSourceRange::getCharRange(Start, Start.getLocWithOffset(Length)));
   LangOptions LangOpts;
   LangOpts.CPlusPlus = 1;
   Lexer Lex(ID, Context.Sources.getBuffer(ID), Context.Sources, LangOpts);
   tooling::Replacements Replace =
       reformat(Style, Lex, Context.Sources, Ranges);
   EXPECT_TRUE(applyAllReplacements(Replace, Context.Rewrite));
   return Context.getRewrittenText(ID);
 }
Пример #10
0
wxString thPaletteData::GetPalette() const
{
    // at each index:
    //   if i > 0 "; "
    //   search where (end == -1) and (bc is same); "n n n (clr)"
    //   search where (bc is same) and (ec is same) and ((end - begin) is same); "n n (clr) - n n (clr)"
    //   search where (begin == le) and (bc == lec); "n (clr) - n (clr) - ..."

    wxString ret, tmp;
    int lb = -1, le = -1;
    COLORREF lbc = -1, lec = -1;
    size_t count, count2;
    for (size_t i = 0; i < Ranges(); i += count * count2)
    {
        if (i > 0)
            ret += _T("; ");

        if (end[i] == -1)
        {
            count2 = 1;
            for (count = 1; i + count < Ranges(); count++)
            {
                if (end[i + count] >= 0 ||
                    beginColor[i + count] != beginColor[i])
                    break;
            }
            for (size_t j = 0; j < count; j++)
                ret += wxString::Format(_T("%d "), begin[i + j]);
            ret += (wxChar)'(' + FormatColour(beginColor[i]) + (wxChar)')';
        }
        else
        {
            // count how many ranges are being set at once
            for (count2 = 1; i + count2 < Ranges(); count2++)
            {
                if (end[i + count2] - begin[i + count2] != end[i] - begin[i] ||
                    beginColor[i + count2] != beginColor[i] ||
                    endColor[i + count2] != endColor[i])
                    break;
            }

            // count how many points are in each range
            for (count = 1; ; count++)
            {
                size_t k = i + (count * count2);
                size_t l = i + ((count - 1) * count2);
                if (k >= Ranges())
                    break;
                if (begin[k] != end[l] ||
                    beginColor[k] != endColor[l])
                    break;
                // make sure each range in the second group uses the same colors and distance
                for (size_t j = 1; j < count2; j++)
                {
                    if (k + j >= Ranges() ||
                        end[k + j] - begin[k + j] != end[k] - begin[k] ||
                        beginColor[k + j] != beginColor[k] ||
                        endColor[k + j] != endColor[k])
                        goto break_break;
                }
            }
break_break:
            for (size_t j = 0; j < count; j++)
            {
                for (size_t k = 0; k < count2; k++)
                    ret += wxString::Format(_T("%d "), begin[i + j * count2 + k]);
                ret += (wxChar)'(' + FormatColour(beginColor[i + j * count2]) + _T(") - ");
            }
            for (size_t k = 0; k < count2; k++)
                ret += wxString::Format(_T("%d "), end[i + (count - 1) * count2 + k]);
            ret += (wxChar)'(' + FormatColour(endColor[i + (count - 1) * count2]) + (wxChar)')';
        }
    }
    return ret;
}