예제 #1
0
파일: Cursor.cpp 프로젝트: aandahl/rstudio
bool Cursor::isNull() const
{
   if (! pCursor_)
      return true;
   else
      return (clang().equalCursors(cursor(), clang().getNullCursor()));
}
예제 #2
0
boost::shared_ptr<CodeCompleteResults> TranslationUnit::codeCompleteAt(
                                            const std::string& filename,
                                            unsigned line,
                                            unsigned column) const
{
   CXCodeCompleteResults* pResults = clang().codeCompleteAt(
                                 tu_,
                                 filename.c_str(),
                                 line,
                                 column,
                                 pUnsavedFiles_->unsavedFilesArray(),
                                 pUnsavedFiles_->numUnsavedFiles(),
                                 clang().defaultCodeCompleteOptions());

   if (pResults != nullptr)
   {
      clang().sortCodeCompletionResults(pResults->Results,
                                        pResults->NumResults);

      return boost::shared_ptr<CodeCompleteResults>(
                                    new CodeCompleteResults(pResults));
   }
   else
   {
      return boost::shared_ptr<CodeCompleteResults>(new CodeCompleteResults());
   }
}
예제 #3
0
void TranslationUnit::printResourceUsage(std::ostream& ostr, bool detailed) const
{
   CXTUResourceUsage usage = clang().getCXTUResourceUsage(tu_);

   unsigned long totalBytes = 0;
   for (unsigned i = 0; i < usage.numEntries; i++)
   {
      CXTUResourceUsageEntry entry = usage.entries[i];

      if (detailed)
      {
         ostr << clang().getTUResourceUsageName(entry.kind) << ": "
              << formatBytes(entry.amount) << std::endl;
      }

      if (entry.kind >= CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN &&
          entry.kind <= CXTUResourceUsage_MEMORY_IN_BYTES_END)
      {
         totalBytes += entry.amount;
      }
   }
   ostr << "TOTAL MEMORY: " << formatBytes(totalBytes)
        << " (" << FilePath(getSpelling()).filename() << ")" << std::endl;

   clang().disposeCXTUResourceUsage(usage);
}
예제 #4
0
void SourceLocation::getExpansionLocation(std::string* pFile,
                                          unsigned* pLine,
                                          unsigned* pColumn,
                                          unsigned* pOffset) const
{
   CXFile file;
   clang().getExpansionLocation(location_, &file, pLine, pColumn, pOffset);

   CXString filename = clang().getFileName(file);
   *pFile = toStdString(filename);
}
예제 #5
0
파일: Utils.cpp 프로젝트: AlanCal/rstudio
// note that this function disposes the underlying CXString so it
// shouldn't be used after this call
std::string toStdString(CXString cxStr)
{
   const char* str = clang().getCString(cxStr);
   if (str != NULL)
   {
      std::string stdString(str);
      clang().disposeString(cxStr);
      return stdString;
   }
   else
   {
      return std::string();
   }
}
예제 #6
0
CXFile TranslationUnit::getFile(const std::string& filename) const
{
   std::string targetFile = filename;
   if (targetFile.empty())
      targetFile = filename_;

   return clang().getFile(tu_, targetFile.c_str());
}
예제 #7
0
bool SourceLocation::getSpellingLocation(std::string* pFile,
                                         unsigned* pLine,
                                         unsigned* pColumn,
                                         unsigned* pOffset) const
{
   if (!empty())
   {
      CXFile file;
      clang().getSpellingLocation(location_, &file, pLine, pColumn, pOffset);

      CXString filename = clang().getFileName(file);
      *pFile = toStdString(filename);
      return true;
   }
   else
   {
      return false;
   }
}
예제 #8
0
void SourceIndex::removeTranslationUnit(const std::string& filename)
{
    TranslationUnits::iterator it = translationUnits_.find(filename);
    if (it != translationUnits_.end())
    {
        if (verbose_ > 0)
            std::cerr << "CLANG REMOVE INDEX: " << it->first << std::endl;
        clang().disposeTranslationUnit(it->second.tu);
        translationUnits_.erase(it->first);
    }
}
예제 #9
0
CXResult TranslationUnit::findReferencesInFile(
                              Cursor cursor,
                              CXCursorAndRangeVisitor visitor,
                              const std::string& filename) const
{
   CXFile file = getFile(filename);
   if (file == nullptr)
      return CXResult_Invalid;

   return clang().findReferencesInFile(cursor.getCXCursor(), file, visitor);
}
예제 #10
0
Cursor TranslationUnit::getCursor(const std::string& filename,
                                  unsigned line,
                                  unsigned column) const
{
   // get the file
   CXFile file = clang().getFile(tu_, filename.c_str());
   if (file == nullptr)
      return Cursor();

   // get the source location
   CXSourceLocation sourceLoc = clang().getLocation(tu_, file, line, column);

   // get the cursor
   CXCursor cursor = clang().getCursor(tu_, sourceLoc);
   if (clang().equalCursors(cursor, clang().getNullCursor()))
      return Cursor();

   // return it
   return Cursor(cursor);
}
예제 #11
0
void SourceIndex::removeAllTranslationUnits()
{
    for(TranslationUnits::const_iterator it = translationUnits_.begin();
            it != translationUnits_.end(); ++it)
    {
        if (verbose_ > 0)
            std::cerr << "CLANG REMOVE INDEX: " << it->first << std::endl;

        clang().disposeTranslationUnit(it->second.tu);
    }

    translationUnits_.clear();
}
예제 #12
0
/* Parse initialize message */
void parse_initialize_message(char *recvbuf){
  char mode[100];
  if ( !(strncmp(recvbuf,"(init",4)) ) {
    /* It's an init msg */
    sscanf(recvbuf,"(init %c %d %[^)]",&Mem->MySide, &Mem->MyNumber, mode);
    Mem->ServerAlive = TRUE;
  }
  else if ( !(strncmp(recvbuf,"(reconnect",4)) ) {
    /* It's a reconnect msg */
    sscanf(recvbuf,"(reconnect %c %[^)]",&Mem->MySide, mode);
    Mem->MyNumber = Mem->IP_reconnect;
    printf("reconnecting to %d on side %c!\n",Mem->MyNumber,Mem->MySide);
    Mem->ServerAlive = TRUE;
  }
  else {
    my_error("Didn't get an init message: '%s'",recvbuf);
    Mem->ServerAlive = FALSE;
  }

  if ( Mem->CP_goalie && Mem->FP_goalie_number != Mem->MyNumber )
    my_error("goalie number inconsistent with me being goalie");

  if ( !Mem->CP_goalie && Mem->FP_goalie_number == Mem->MyNumber )
    my_error("I should be the goalie");
  
  if ( mode[0] == 'b' ){ /* Before_kick_off */ 
    if (Mem->IP_reconnect != 0) {
      Mem->SetPlayMode(PM_Half_Time);
      Mem->SetPlayMode(PM_Before_Kick_Off);
      if ( Mem->MySide == 'l' )
	Mem->KickOffMode = KO_Theirs;
      else 
	Mem->KickOffMode = KO_Mine;
    } else {
      Mem->SetPlayMode(PM_Before_Kick_Off);
      if ( Mem->MySide == 'l' )
	Mem->KickOffMode = KO_Mine;
      else 
	Mem->KickOffMode = KO_Theirs;
    }
  }
  else                  /* Act as if the game's in progress */
    Mem->SetPlayMode(PM_Play_On);

  clang(8,8);  /* support clang messages version 8 */
}
예제 #13
0
CompilerPtr CompilerLocatorCLANG::Locate(const wxString& folder)
{
    m_compilers.clear();
    wxFileName clang(folder, "clang");
#ifdef __WXMSW__
    clang.SetExt("exe");
#endif
    bool found = clang.FileExists();
    if ( ! found ) {
        // try to see if we have a bin folder here
        clang.AppendDir("bin");
        found = clang.FileExists();
    }
    
    if ( found ) {
        CompilerPtr compiler( new Compiler(NULL) );
        compiler->SetCompilerFamily(COMPILER_FAMILY_CLANG);
        // get the compiler version
        compiler->SetName( GetCompilerFullName(clang.GetFullPath() ) );
        compiler->SetGenerateDependeciesFile(true);
        m_compilers.push_back( compiler );
        clang.RemoveLastDir();
        AddTools(compiler, clang.GetPath());
        
        // Update the toolchain (if Windows)
#ifdef __WXMSW__
        CompilerPtr defaultMinGWCmp = BuildSettingsConfigST::Get()->GetDefaultCompiler(COMPILER_FAMILY_MINGW);
        if ( defaultMinGWCmp ) {
            compiler->SetTool("MAKE", defaultMinGWCmp->GetTool("MAKE"));
            compiler->SetTool("ResourceCompiler", defaultMinGWCmp->GetTool("ResourceCompiler"));
            
            // Update the include paths
            IncludePathLocator locator(NULL);
            wxArrayString includePaths, excludePaths;
            locator.Locate(includePaths, excludePaths, false, defaultMinGWCmp->GetTool("CXX"));
            
            // Convert the include paths to semi colon separated list
            wxString mingwIncludePaths = wxJoin(includePaths, ';');
            compiler->SetGlobalIncludePath( mingwIncludePaths );
        }
#endif
        return compiler;
    }
    return NULL;
}
예제 #14
0
bool CompilerLocatorCLANG::Locate()
{
    m_compilers.clear();
    MSWLocate();

    // POSIX locate
    wxFileName clang("/usr/bin", "clang");
    if ( clang.FileExists() ) {
        CompilerPtr compiler( new Compiler(NULL) );
        compiler->SetCompilerFamily(COMPILER_FAMILY_CLANG);
        // get the compiler version
        compiler->SetName( GetCompilerFullName(clang.GetFullPath() ) );
        compiler->SetGenerateDependeciesFile(true);
        m_compilers.push_back( compiler );
        clang.RemoveLastDir();
        AddTools(compiler, clang.GetPath());
    }
    return true;
}
예제 #15
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
bool Cursor::isUnexposed() const
{
   return clang().isUnexposed(getKind());
}
예제 #16
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
bool Cursor::isPreprocessing() const
{
   return clang().isPreprocessing(getKind());
}
예제 #17
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
bool Cursor::isTranslationUnit() const
{
   return clang().isTranslationUnit(getKind());
}
예제 #18
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
bool Cursor::isInvalid() const
{
   return clang().isInvalid(getKind());
}
예제 #19
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
bool Cursor::isAttribute() const
{
   return clang().isAttribute(getKind());
}
예제 #20
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
Cursor Cursor::getDefinition() const
{
   return Cursor(clang().getCursorDefinition(cursor_));
}
예제 #21
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
bool Cursor::isReference() const
{
   return clang().isReference(getKind());
}
예제 #22
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
bool Cursor::isDeclaration() const
{
   return clang().isDeclaration(getKind());
}
예제 #23
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
CXCursorKind Cursor::getKind() const
{
   return clang().getCursorKind(cursor_);
}
예제 #24
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
std::string Cursor::spelling() const
{
   return toStdString(clang().getCursorSpelling(cursor_));
}
예제 #25
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
Cursor::Cursor()
   : cursor_(clang().getNullCursor())
{
}
예제 #26
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
bool Cursor::isDefinition() const
{
   return clang().isCursorDefinition(cursor_) != 0;
}
예제 #27
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
Cursor Cursor::getReferenced() const
{
   return Cursor(clang().getCursorReferenced(cursor_));
}
예제 #28
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
bool Cursor::isExpression() const
{
   return clang().isExpression(getKind());
}
예제 #29
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
std::string Cursor::displayName() const
{
   return toStdString(clang().getCursorDisplayName(cursor_));
}
예제 #30
0
파일: Cursor.cpp 프로젝트: AlanCal/rstudio
bool Cursor::isStatement() const
{
   return clang().isStatement(getKind());
}