From: Diane Trout Date: Thu, 27 Jul 2006 00:33:30 +0000 (+0000) Subject: fix problems instantiating mussa.GlSequence X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=commitdiff_plain;h=ea6f1b2bf051ee2444c76c23241b019694c4f8c0 fix problems instantiating mussa.GlSequence with the switch to shared_ptr in the C++ code the original boost::python GlSequence was wrong--it needed to be updated from references to shared_ptrs and boost::python needed to be told that it's ok to have shared_ptrs to Sequence and AnnotationColors. And I also needed to tell boost::python about AnnotationColors, not that I defined enough of a wrapper to use it. --- diff --git a/py/CMakeLists.txt b/py/CMakeLists.txt index 02ad969..58a3f60 100644 --- a/py/CMakeLists.txt +++ b/py/CMakeLists.txt @@ -12,6 +12,7 @@ INCLUDE( ${QT_USE_FILE} ) IF(BOOST_PYTHON_LIBRARY) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH} ${QT_INCLUDES}) SET(SOURCES + annotation_colors.cpp conserved_path.cpp glsequence.cpp module.cpp diff --git a/py/annotation_colors.cpp b/py/annotation_colors.cpp new file mode 100644 index 0000000..259e809 --- /dev/null +++ b/py/annotation_colors.cpp @@ -0,0 +1,19 @@ +#include +#include +using namespace boost::python; + +#include + +#include "alg/annotation_colors.hpp" + +void export_annotation_colors() +{ + class_("AnnotationColors") + .def("clear", &AnnotationColors::clear) + .add_property("color", &AnnotationColors::color, + &AnnotationColors::setColor, + "access default color for this color mapper") + ; + + register_ptr_to_python< boost::shared_ptr >(); +} diff --git a/py/glsequence.cpp b/py/glsequence.cpp index 811e0dc..f40efa3 100644 --- a/py/glsequence.cpp +++ b/py/glsequence.cpp @@ -1,5 +1,6 @@ #include using namespace boost::python; +#include #include "alg/annotation_colors.hpp" #include "alg/glsequence.hpp" @@ -7,8 +8,11 @@ using namespace boost::python; void export_glsequence() { - /* - class_("GlSequence", init()) + class_("GlSequence", + init< + boost::shared_ptr, + boost::shared_ptr + >()) .def(init()) .def("draw", &GlSequence::draw) .def("sequence", &GlSequence::sequence, @@ -17,5 +21,4 @@ void export_glsequence() .add_property("y", &GlSequence::y, &GlSequence::setY) .add_property("length", &GlSequence::length) ; - */ } diff --git a/py/module.cpp b/py/module.cpp index 448b523..632b117 100644 --- a/py/module.cpp +++ b/py/module.cpp @@ -1,6 +1,7 @@ #include using namespace boost::python; +void export_annotation_colors(); void export_conserved_path(); void export_glsequence(); void export_mussa(); @@ -10,6 +11,7 @@ void export_mussa_window(); BOOST_PYTHON_MODULE(mussa) { + export_annotation_colors(); export_conserved_path(); export_glsequence(); export_mussa(); diff --git a/py/sequence.cpp b/py/sequence.cpp index 695a8ea..2bb10ab 100644 --- a/py/sequence.cpp +++ b/py/sequence.cpp @@ -3,8 +3,11 @@ #include #include #include +#include using namespace boost::python; +#include + #include #include "alg/glsequence.hpp" @@ -23,4 +26,6 @@ void export_sequence() .add_property("species", &Sequence::get_species, &Sequence::set_species) .def("rcseq", &Sequence::rev_comp, return_value_policy()) ; + + register_ptr_to_python< boost::shared_ptr >(); }