Skip to content

Commit

Permalink
Sequence: renamed operators in bindings
Browse files Browse the repository at this point in the history
Instead of redefine them in Python, and ignore them in Java.
  • Loading branch information
Clement Champetier committed May 24, 2016
1 parent a20b707 commit cb6ba7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
2 changes: 0 additions & 2 deletions src/sequenceParser/Sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ class Sequence

EPattern checkPattern( const std::string& pattern, const EDetection detectionOptions );

#ifndef SWIG
bool operator<(const Sequence& other ) const
{
return getFilenameWithStandardPattern() < other.getFilenameWithStandardPattern();
Expand All @@ -201,7 +200,6 @@ class Sequence
{
return !operator==( other );
}
#endif

/**
* @brief Partial initialization, using only pattern informations.
Expand Down
29 changes: 14 additions & 15 deletions src/sequenceParser/Sequence.i
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@ namespace std {
%template(FrameRangeVector) vector< sequenceParser::FrameRange >;
}

%include "Sequence.hpp"
#ifdef SWIGJAVA

#ifdef SWIGPYTHON

%extend sequenceParser::Sequence
{
%pythoncode
{
def __str__(self):
return self.string()
def __lt__(self, other):
return self.getFilenameWithStandardPattern() < other.getFilenameWithStandardPattern()
def __eq__(self, other):
return self._prefix == other._prefix and self._suffix == other._suffix and self._maxPadding == other._maxPadding and self._fixedPadding == other._fixedPadding and self._ranges == other._ranges
}
}
%rename (toString) sequenceParser::Sequence::string;
%rename (equals) sequenceParser::Sequence::operator==;
%ignore sequenceParser::Sequence::operator!=;
%ignore sequenceParser::Sequence::operator<;

#elif SWIGPYTHON

%rename(__str__) sequenceParser::Sequence::string;
%rename(__eq__) sequenceParser::Sequence::operator==;
%rename(__ne__) sequenceParser::Sequence::operator!=;
%rename(__lt__) sequenceParser::Sequence::operator<;

#endif

%include "Sequence.hpp"

0 comments on commit cb6ba7e

Please sign in to comment.