You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Merge pull request #321 from ferdnyc/map-dicts
WIP: Towards a more Pythonic openshot.Fraction
This commit is contained in:
@@ -123,6 +123,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Instantiate the required template specializations */
|
||||
%template() std::map<std::string, int>;
|
||||
|
||||
/* Make openshot.Fraction more Pythonic */
|
||||
%extend openshot::Fraction {
|
||||
%{
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
%}
|
||||
double __float__() {
|
||||
return $self->ToDouble();
|
||||
}
|
||||
int __int__() {
|
||||
return $self->ToInt();
|
||||
}
|
||||
std::map<std::string, int> GetMap() {
|
||||
std::map<std::string, int> map1;
|
||||
map1.insert({"num", $self->num});
|
||||
map1.insert({"den", $self->den});
|
||||
return map1;
|
||||
}
|
||||
std::string __repr__() {
|
||||
std::ostringstream result;
|
||||
result << $self->num << ":" << $self->den;
|
||||
return result.str();
|
||||
}
|
||||
}
|
||||
|
||||
%extend openshot::OpenShotVersion {
|
||||
// Give the struct a string representation
|
||||
const std::string __str__() {
|
||||
|
||||
Reference in New Issue
Block a user