2012-04-15 23:28:46 -04:00
|
|
|
// Copyright (C) 2011, 2012 Strahinja Val Markovic <val@markovic.io>
|
2012-04-15 19:57:10 -04:00
|
|
|
//
|
|
|
|
// This file is part of YouCompleteMe.
|
|
|
|
//
|
|
|
|
// YouCompleteMe is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// YouCompleteMe is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2012-07-11 02:13:12 -04:00
|
|
|
#include "IdentifierCompleter.h"
|
2012-05-06 02:48:22 -04:00
|
|
|
#include "Future.h"
|
2012-08-17 16:32:42 -04:00
|
|
|
|
2013-01-12 19:38:00 -05:00
|
|
|
#ifdef USE_CLANG_COMPLETER
|
2012-08-17 16:32:42 -04:00
|
|
|
# include "ClangCompleter.h"
|
|
|
|
# include "CompletionData.h"
|
|
|
|
# include "Diagnostic.h"
|
|
|
|
# include "UnsavedFile.h"
|
2013-01-18 20:22:36 -05:00
|
|
|
# include "CompilationDatabase.h"
|
2013-01-12 19:38:00 -05:00
|
|
|
#endif // USE_CLANG_COMPLETER
|
2012-04-15 19:57:10 -04:00
|
|
|
|
|
|
|
#include <boost/python.hpp>
|
2012-05-06 02:48:22 -04:00
|
|
|
#include <boost/utility.hpp>
|
2012-07-08 18:34:44 -04:00
|
|
|
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
|
2012-04-15 19:57:10 -04:00
|
|
|
|
2013-01-13 23:56:10 -05:00
|
|
|
bool HasClangSupport()
|
|
|
|
{
|
|
|
|
#ifdef USE_CLANG_COMPLETER
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif // USE_CLANG_COMPLETER
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-04 21:59:22 -04:00
|
|
|
BOOST_PYTHON_MODULE(ycm_core)
|
2012-04-15 19:57:10 -04:00
|
|
|
{
|
2012-04-29 22:51:20 -04:00
|
|
|
using namespace boost::python;
|
|
|
|
using namespace YouCompleteMe;
|
2012-04-15 19:57:10 -04:00
|
|
|
|
2013-01-13 23:56:10 -05:00
|
|
|
def( "HasClangSupport", HasClangSupport );
|
|
|
|
|
2012-08-17 16:32:42 -04:00
|
|
|
class_< IdentifierCompleter, boost::noncopyable >( "IdentifierCompleter" )
|
|
|
|
.def( "EnableThreading", &IdentifierCompleter::EnableThreading )
|
|
|
|
.def( "AddCandidatesToDatabase",
|
|
|
|
&IdentifierCompleter::AddCandidatesToDatabase )
|
|
|
|
.def( "AddCandidatesToDatabaseFromBufferAsync",
|
|
|
|
&IdentifierCompleter::AddCandidatesToDatabaseFromBufferAsync )
|
|
|
|
.def( "CandidatesForQueryAndTypeAsync",
|
|
|
|
&IdentifierCompleter::CandidatesForQueryAndTypeAsync );
|
2012-07-28 18:27:30 -04:00
|
|
|
|
2012-08-17 16:32:42 -04:00
|
|
|
// TODO: rename these *Vec classes to *Vector; don't forget the python file
|
|
|
|
class_< std::vector< std::string >,
|
|
|
|
boost::shared_ptr< std::vector< std::string > > >( "StringVec" )
|
|
|
|
.def( vector_indexing_suite< std::vector< std::string > >() );
|
2012-07-28 18:27:30 -04:00
|
|
|
|
2012-07-30 22:42:41 -04:00
|
|
|
class_< Future< AsyncResults > >( "FutureResults" )
|
2012-07-15 23:49:56 -04:00
|
|
|
.def( "ResultsReady", &Future< AsyncResults >::ResultsReady )
|
|
|
|
.def( "GetResults", &Future< AsyncResults >::GetResults );
|
2012-05-06 02:48:22 -04:00
|
|
|
|
2012-08-12 17:36:36 -04:00
|
|
|
class_< Future< void > >( "FutureVoid" )
|
|
|
|
.def( "ResultsReady", &Future< void >::ResultsReady )
|
|
|
|
.def( "GetResults", &Future< void >::GetResults );
|
|
|
|
|
2013-01-12 19:38:00 -05:00
|
|
|
#ifdef USE_CLANG_COMPLETER
|
2012-08-17 16:32:42 -04:00
|
|
|
class_< Future< AsyncCompletions > >( "FutureCompletions" )
|
|
|
|
.def( "ResultsReady", &Future< AsyncCompletions >::ResultsReady )
|
|
|
|
.def( "GetResults", &Future< AsyncCompletions >::GetResults );
|
2012-07-08 18:34:44 -04:00
|
|
|
|
2013-01-23 20:23:51 -05:00
|
|
|
class_< Future< AsyncCompilationInfoForFile > >(
|
|
|
|
"FutureCompilationInfoForFile" )
|
|
|
|
.def( "ResultsReady",
|
|
|
|
&Future< AsyncCompilationInfoForFile >::ResultsReady )
|
|
|
|
.def( "GetResults",
|
|
|
|
&Future< AsyncCompilationInfoForFile >::GetResults );
|
|
|
|
|
2012-07-10 18:26:07 -04:00
|
|
|
// CAREFUL HERE! For filename and contents we are referring directly to
|
|
|
|
// Python-allocated and -managed memory since we are accepting pointers to
|
|
|
|
// data members of python objects. We need to ensure that those objects
|
|
|
|
// outlive our UnsavedFile objects.
|
2012-08-17 16:32:42 -04:00
|
|
|
class_< UnsavedFile >( "UnsavedFile" )
|
2012-07-10 18:26:07 -04:00
|
|
|
.add_property( "filename_",
|
|
|
|
make_getter( &UnsavedFile::filename_ ),
|
|
|
|
make_setter( &UnsavedFile::filename_,
|
|
|
|
return_value_policy< reference_existing_object >() ) )
|
|
|
|
.add_property( "contents_",
|
|
|
|
make_getter( &UnsavedFile::contents_ ),
|
|
|
|
make_setter( &UnsavedFile::contents_,
|
|
|
|
return_value_policy< reference_existing_object >() ) )
|
|
|
|
.def_readwrite( "length_", &UnsavedFile::length_ );
|
|
|
|
|
2013-01-18 20:22:36 -05:00
|
|
|
class_< std::vector< UnsavedFile > >( "UnsavedFileVec" )
|
|
|
|
.def( vector_indexing_suite< std::vector< UnsavedFile > >() );
|
2012-07-10 18:26:07 -04:00
|
|
|
|
2012-07-11 02:28:58 -04:00
|
|
|
class_< ClangCompleter, boost::noncopyable >( "ClangCompleter" )
|
2012-07-15 23:49:56 -04:00
|
|
|
.def( "EnableThreading", &ClangCompleter::EnableThreading )
|
2012-07-28 18:27:30 -04:00
|
|
|
.def( "DiagnosticsForFile", &ClangCompleter::DiagnosticsForFile )
|
2012-07-26 23:50:56 -04:00
|
|
|
.def( "UpdatingTranslationUnit", &ClangCompleter::UpdatingTranslationUnit )
|
|
|
|
.def( "UpdateTranslationUnitAsync",
|
|
|
|
&ClangCompleter::UpdateTranslationUnitAsync )
|
2012-07-15 23:49:56 -04:00
|
|
|
.def( "CandidatesForQueryAndLocationInFileAsync",
|
|
|
|
&ClangCompleter::CandidatesForQueryAndLocationInFileAsync );
|
2012-08-17 16:32:42 -04:00
|
|
|
|
|
|
|
class_< CompletionData >( "CompletionData" )
|
|
|
|
.def( "TextToInsertInBuffer", &CompletionData::TextToInsertInBuffer )
|
|
|
|
.def( "MainCompletionText", &CompletionData::MainCompletionText )
|
|
|
|
.def( "ExtraMenuInfo", &CompletionData::ExtraMenuInfo )
|
|
|
|
.def( "DetailedInfoForPreviewWindow",
|
|
|
|
&CompletionData::DetailedInfoForPreviewWindow )
|
|
|
|
.def_readonly( "kind_", &CompletionData::kind_ );
|
|
|
|
|
|
|
|
class_< std::vector< CompletionData >,
|
|
|
|
boost::shared_ptr< std::vector< CompletionData > > >(
|
|
|
|
"CompletionVec" )
|
|
|
|
.def( vector_indexing_suite< std::vector< CompletionData > >() );
|
|
|
|
|
|
|
|
class_< Diagnostic >( "Diagnostic" )
|
|
|
|
.def_readonly( "line_number_", &Diagnostic::line_number_ )
|
|
|
|
.def_readonly( "column_number_", &Diagnostic::column_number_ )
|
|
|
|
.def_readonly( "kind_", &Diagnostic::kind_ )
|
|
|
|
.def_readonly( "filename_", &Diagnostic::filename_ )
|
|
|
|
.def_readonly( "text_", &Diagnostic::text_ )
|
|
|
|
.def_readonly( "long_formatted_text_", &Diagnostic::long_formatted_text_ );
|
|
|
|
|
|
|
|
class_< std::vector< Diagnostic > >( "DiagnosticVec" )
|
|
|
|
.def( vector_indexing_suite< std::vector< Diagnostic > >() );
|
|
|
|
|
2013-01-18 20:22:36 -05:00
|
|
|
class_< CompilationDatabase, boost::noncopyable >(
|
|
|
|
"CompilationDatabase", init< std::string >() )
|
2013-01-23 20:23:51 -05:00
|
|
|
.def( "EnableThreading", &CompilationDatabase::EnableThreading )
|
2013-01-18 20:22:36 -05:00
|
|
|
.def( "FlagsForFile", &CompilationDatabase::FlagsForFile )
|
|
|
|
.def( "DatabaseSuccessfullyLoaded",
|
|
|
|
&CompilationDatabase::DatabaseSuccessfullyLoaded )
|
|
|
|
.def( "CompileCommandWorkingDirectoryForFile",
|
2013-01-23 20:23:51 -05:00
|
|
|
&CompilationDatabase::CompileCommandWorkingDirectoryForFile )
|
|
|
|
.def( "GetCompilationInfoForFile",
|
|
|
|
&CompilationDatabase::GetCompilationInfoForFile )
|
|
|
|
.def( "GetCompilationInfoForFileAsync",
|
|
|
|
&CompilationDatabase::GetCompilationInfoForFileAsync );
|
|
|
|
|
|
|
|
class_< CompilationInfoForFile,
|
|
|
|
boost::shared_ptr< CompilationInfoForFile > >(
|
|
|
|
"CompilationInfoForFile", no_init )
|
|
|
|
.def_readonly( "compiler_working_dir_",
|
|
|
|
&CompilationInfoForFile::compiler_working_dir_ )
|
|
|
|
.def_readonly( "compiler_flags_",
|
|
|
|
&CompilationInfoForFile::compiler_flags_ );
|
2013-01-18 20:22:36 -05:00
|
|
|
|
2013-01-12 19:38:00 -05:00
|
|
|
#endif // USE_CLANG_COMPLETER
|
2012-04-15 19:57:10 -04:00
|
|
|
}
|