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-07-11 02:28:58 -04:00
|
|
|
#include "ClangCompleter.h"
|
2012-05-06 02:48:22 -04:00
|
|
|
#include "Future.h"
|
2012-07-20 00:17:39 -04:00
|
|
|
#include "CompletionData.h"
|
2012-07-28 18:27:30 -04:00
|
|
|
#include "Diagnostic.h"
|
2012-07-21 12:09:29 -04:00
|
|
|
#include "UnsavedFile.h"
|
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
|
|
|
|
|
|
|
BOOST_PYTHON_MODULE(indexer)
|
|
|
|
{
|
2012-04-29 22:51:20 -04:00
|
|
|
using namespace boost::python;
|
|
|
|
using namespace YouCompleteMe;
|
2012-04-15 19:57:10 -04:00
|
|
|
|
2012-07-20 00:17:39 -04:00
|
|
|
// TODO: rename these *Vec classes to *Vector; don't forget the python file
|
2012-07-15 23:49:56 -04:00
|
|
|
class_< std::vector< std::string >,
|
|
|
|
boost::shared_ptr< std::vector< std::string > > >( "StringVec" )
|
2012-07-10 18:26:07 -04:00
|
|
|
.def( vector_indexing_suite< std::vector< std::string > >() );
|
|
|
|
|
2012-07-20 00:17:39 -04:00
|
|
|
class_< CompletionData >( "CompletionData" )
|
|
|
|
.def( "TextToInsertInBuffer", &CompletionData::TextToInsertInBuffer )
|
|
|
|
.def_readonly( "detailed_info_", &CompletionData::detailed_info_ )
|
|
|
|
.def_readonly( "extra_menu_info_", &CompletionData::extra_menu_info_ )
|
|
|
|
.def_readonly( "kind_", &CompletionData::kind_ )
|
|
|
|
.def_readonly( "original_string_", &CompletionData::original_string_ );
|
|
|
|
|
|
|
|
class_< std::vector< CompletionData >,
|
|
|
|
boost::shared_ptr< std::vector< CompletionData > > >(
|
|
|
|
"CompletionVec" )
|
|
|
|
.def( vector_indexing_suite< std::vector< CompletionData > >() );
|
|
|
|
|
2012-07-28 18:27:30 -04:00
|
|
|
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_ );
|
|
|
|
|
|
|
|
class_< std::vector< Diagnostic > >( "DiagnosticVec" )
|
|
|
|
.def( vector_indexing_suite< std::vector< Diagnostic > >() );
|
|
|
|
|
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-07-30 22:42:41 -04:00
|
|
|
class_< Future< AsyncCompletions > >( "FutureCompletions" )
|
2012-07-20 00:17:39 -04:00
|
|
|
.def( "ResultsReady", &Future< AsyncCompletions >::ResultsReady )
|
|
|
|
.def( "GetResults", &Future< AsyncCompletions >::GetResults );
|
|
|
|
|
2012-07-11 02:13:12 -04:00
|
|
|
class_< IdentifierCompleter, boost::noncopyable >( "IdentifierCompleter" )
|
|
|
|
.def( "EnableThreading", &IdentifierCompleter::EnableThreading )
|
|
|
|
.def( "AddCandidatesToDatabase",
|
|
|
|
&IdentifierCompleter::AddCandidatesToDatabase )
|
2012-07-24 23:09:09 -04:00
|
|
|
.def( "AddCandidatesToDatabaseFromBufferAsync",
|
|
|
|
&IdentifierCompleter::AddCandidatesToDatabaseFromBufferAsync )
|
2012-05-06 02:48:22 -04:00
|
|
|
.def( "CandidatesForQueryAndTypeAsync",
|
2012-07-11 02:13:12 -04:00
|
|
|
&IdentifierCompleter::CandidatesForQueryAndTypeAsync );
|
2012-07-08 18:34:44 -04:00
|
|
|
|
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.
|
|
|
|
class_< UnsavedFile >( "UnsavedFile" )
|
|
|
|
.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_ );
|
|
|
|
|
|
|
|
class_< std::vector< UnsavedFile > >( "UnsavedFileVec" )
|
|
|
|
.def( vector_indexing_suite< std::vector< UnsavedFile > >() );
|
|
|
|
|
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 )
|
2012-07-30 01:08:02 -04:00
|
|
|
.def( "UpdateTranslationUnit", &ClangCompleter::UpdateTranslationUnit )
|
2012-07-26 23:50:56 -04:00
|
|
|
.def( "UpdateTranslationUnitAsync",
|
|
|
|
&ClangCompleter::UpdateTranslationUnitAsync )
|
2012-07-15 23:49:56 -04:00
|
|
|
.def( "CandidatesForQueryAndLocationInFileAsync",
|
|
|
|
&ClangCompleter::CandidatesForQueryAndLocationInFileAsync );
|
2012-04-15 19:57:10 -04:00
|
|
|
}
|