Skip to content

Commit

Permalink
Merge pull request #31 from pfernique/master
Browse files Browse the repository at this point in the history
Add wrappers
  • Loading branch information
pfernique committed Oct 27, 2017
2 parents 57a7a4c + f383f1b commit c7690a0
Show file tree
Hide file tree
Showing 25 changed files with 1,308 additions and 32 deletions.
12 changes: 6 additions & 6 deletions src/cpp/STL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ namespace statiskit
{
namespace stl
{
SetIndexGenerator generator(const SetIndex& iterable)
{ return SetIndexGenerator(iterable); }

bool insert(SetIndex& iterable, const Index& value)
{ return iterable.insert(value).second; }

SetLessIndexGenerator generator(const SetLessIndex& iterable)
{ return SetLessIndexGenerator(iterable); }

Expand All @@ -28,11 +34,5 @@ namespace statiskit
bool insert(SetLessString& iterable, const std::string& value)
{ return iterable.insert(value).second; }

SetIndexGenerator generator(const SetIndex& iterable)
{ return SetIndexGenerator(iterable); }

bool insert(SetIndex& iterable, const Index& value)
{ return iterable.insert(value).second; }

}
}
8 changes: 4 additions & 4 deletions src/cpp/STL.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ namespace statiskit
typedef std::vector< double > VectorDouble;
typedef std::vector< std::string > VectorString;

typedef std::unordered_set< Index > SetIndex;
typedef Generator< SetIndex > SetIndexGenerator;
STATISKIT_STL_API SetIndexGenerator generator(const SetIndex& iterable);
STATISKIT_STL_API bool insert(SetIndex& iterable, const Index& value);
typedef std::set< Index, std::less< Index >, std::allocator< Index > > SetLessIndex;
typedef Generator< SetLessIndex > SetLessIndexGenerator;
STATISKIT_STL_API SetLessIndexGenerator generator(const SetLessIndex& iterable);
Expand All @@ -96,10 +100,6 @@ namespace statiskit
typedef Generator< SetLessString > SetLessStringGenerator;
STATISKIT_STL_API SetLessStringGenerator generator(const SetLessString& iterable);
STATISKIT_STL_API bool insert(SetLessString& iterable, const std::string& value);
typedef std::unordered_set< Index > SetIndex;
typedef Generator< SetIndex > SetIndexGenerator;
STATISKIT_STL_API SetIndexGenerator generator(const SetIndex& iterable);
STATISKIT_STL_API bool insert(SetIndex& iterable, const Index& value);

}
}
Expand Down
26 changes: 13 additions & 13 deletions src/py/statiskit/stl/_stl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@


# Group template specializations
__stl.statiskit.stl._Generator = (__stl.statiskit.stl._Generator_10b14312eeb655268489cd34090870cf, __stl.statiskit.stl._Generator_3b59a0980c80518c808634f7a84dc3cd, __stl.statiskit.stl._Generator_745e4933f5b250d9bc5232fe864d0cf7, __stl.statiskit.stl._Generator_74bc331707c1505eb2f807cae7c32bbb, __stl.statiskit.stl._Generator_e76a1308464d5a9a837d9a61f942fae7)
__stl.std._BasicString = (__stl.std._BasicString_448c20257e485acda59dc59305fceb58)
__stl.std._EqualTo = (__stl.std._EqualTo_d0ba0922f2505f7b8e291326cad79af5)
__stl.std._Set = (__stl.std._Set_476c1c1f206251dba7af53c48f3f6e42, __stl.std._Set_6436891c9b6854f494789a812891cbe5, __stl.std._Set_858bbf0613575e2ebe4b0e5902107ad6, __stl.std._Set_882a8dd1e64a51b4a9da29ab852a852e)
__stl.std._BinaryFunction = (__stl.std._BinaryFunction_8f249c2863945cb59771b97c53bdafec)
__stl.std._UnorderedSet = (__stl.std._UnorderedSet_d48105936d4f5d09a78d2aa9f878fdb8)
__stl.statiskit.stl._Generator = (__stl.statiskit.stl._Generator_10b14312eeb655268489cd34090870cf, __stl.statiskit.stl._Generator_3b59a0980c80518c808634f7a84dc3cd, __stl.statiskit.stl._Generator_745e4933f5b250d9bc5232fe864d0cf7, __stl.statiskit.stl._Generator_74bc331707c1505eb2f807cae7c32bbb, __stl.statiskit.stl._Generator_e76a1308464d5a9a837d9a61f942fae7)
__stl.std._BinaryFunction = (__stl.std._BinaryFunction_8f249c2863945cb59771b97c53bdafec)
__stl.std._BasicString = (__stl.std._BasicString_448c20257e485acda59dc59305fceb58)
__stl.std._Vector = (__stl.std._Vector_107131f9768c56e794a9b0de728d1738, __stl.std._Vector_6b9ae5eac40858c9a0f5e6e21c15d1d3, __stl.std._Vector_c047f2c3135554ceb57f166fd404cfc8, __stl.std._Vector_dc5522842bc75d8b9ac7b46020c60854)
__stl.std._EqualTo = (__stl.std._EqualTo_d0ba0922f2505f7b8e291326cad79af5)

# Define aliases
__stl.std._Set_6436891c9b6854f494789a812891cbe5.KeyType = __stl.std._BasicString_448c20257e485acda59dc59305fceb58
__stl.std._Set_6436891c9b6854f494789a812891cbe5.ValueType = __stl.std._BasicString_448c20257e485acda59dc59305fceb58
__stl.std._UnorderedSet_d48105936d4f5d09a78d2aa9f878fdb8.KeyEqual = __stl.std._EqualTo_d0ba0922f2505f7b8e291326cad79af5
__stl.statiskit.stl.VectorInt = __stl.std._Vector_6b9ae5eac40858c9a0f5e6e21c15d1d3
__stl.statiskit.stl.VectorDouble = __stl.std._Vector_107131f9768c56e794a9b0de728d1738
__stl.statiskit.stl.VectorString = __stl.std._Vector_c047f2c3135554ceb57f166fd404cfc8
__stl.statiskit.stl.SetIndexGenerator = __stl.statiskit.stl._Generator_3b59a0980c80518c808634f7a84dc3cd
__stl.statiskit.stl.SetLessStringGenerator = __stl.statiskit.stl._Generator_745e4933f5b250d9bc5232fe864d0cf7
__stl.statiskit.stl.SetLessIndex = __stl.std._Set_476c1c1f206251dba7af53c48f3f6e42
__stl.statiskit.stl.SetLessDoubleGenerator = __stl.statiskit.stl._Generator_74bc331707c1505eb2f807cae7c32bbb
__stl.statiskit.stl.SetIndex = __stl.std._UnorderedSet_d48105936d4f5d09a78d2aa9f878fdb8
__stl.statiskit.stl.String = __stl.std._BasicString_448c20257e485acda59dc59305fceb58
__stl.statiskit.stl.VectorInt = __stl.std._Vector_6b9ae5eac40858c9a0f5e6e21c15d1d3
__stl.statiskit.stl.SetLessString = __stl.std._Set_6436891c9b6854f494789a812891cbe5
__stl.statiskit.stl.VectorIndex = __stl.std._Vector_dc5522842bc75d8b9ac7b46020c60854
__stl.statiskit.stl.SetLessIndexGenerator = __stl.statiskit.stl._Generator_10b14312eeb655268489cd34090870cf
__stl.statiskit.stl.SetLessDouble = __stl.std._Set_858bbf0613575e2ebe4b0e5902107ad6
__stl.statiskit.stl.VectorString = __stl.std._Vector_c047f2c3135554ceb57f166fd404cfc8
__stl.statiskit.stl.SetLessIndex = __stl.std._Set_476c1c1f206251dba7af53c48f3f6e42
__stl.statiskit.stl.SetLessInt = __stl.std._Set_882a8dd1e64a51b4a9da29ab852a852e
__stl.statiskit.stl.SetLessDoubleGenerator = __stl.statiskit.stl._Generator_74bc331707c1505eb2f807cae7c32bbb
__stl.statiskit.stl.SetLessIndexGenerator = __stl.statiskit.stl._Generator_10b14312eeb655268489cd34090870cf
__stl.statiskit.stl.String = __stl.std._BasicString_448c20257e485acda59dc59305fceb58
__stl.statiskit.stl.SetLessIntGenerator = __stl.statiskit.stl._Generator_e76a1308464d5a9a837d9a61f942fae7
__stl.statiskit.stl.SetLessDouble = __stl.std._Set_858bbf0613575e2ebe4b0e5902107ad6
__stl.statiskit.stl.SetLessStringGenerator = __stl.statiskit.stl._Generator_745e4933f5b250d9bc5232fe864d0cf7
__stl.statiskit.stl.SetIndexGenerator = __stl.statiskit.stl._Generator_3b59a0980c80518c808634f7a84dc3cd
__stl.statiskit.Indices = __stl.std._Set_476c1c1f206251dba7af53c48f3f6e42
__stl.std._Vector_c047f2c3135554ceb57f166fd404cfc8.ValueType = __stl.std._BasicString_448c20257e485acda59dc59305fceb58
26 changes: 17 additions & 9 deletions src/py/statiskit/stl/generator.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
from . import _stl
from . import __stl

import six
from functools import wraps

__all__ = []

def generator_decoration(cls):

def next(self):
if self.is_valid():
value = self.value()
self.__next__()
return value
else:
raise StopIteration()

cls.next = next
def wrapper___next__(f):
@wraps(f)
def __next__(self):
if self.is_valid():
value = self.value()
f(self)
return value
else:
raise StopIteration()
return __next__

cls.__next__ = wrapper___next__(cls.__next__)

if six.PY2:
cls.next = cls.__next__
del cls.__next__

def __iter__(self):
return self
Expand Down
46 changes: 46 additions & 0 deletions src/py/wrapper/_stl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "_stl.h"

void wrapper_10b14312eeb655268489cd34090870cf();
void wrapper_3b59a0980c80518c808634f7a84dc3cd();
void wrapper_448c20257e485acda59dc59305fceb58();
void wrapper_476c1c1f206251dba7af53c48f3f6e42();
void wrapper_6436891c9b6854f494789a812891cbe5();
void wrapper_745e4933f5b250d9bc5232fe864d0cf7();
void wrapper_74bc331707c1505eb2f807cae7c32bbb();
void wrapper_858bbf0613575e2ebe4b0e5902107ad6();
void wrapper_882a8dd1e64a51b4a9da29ab852a852e();
void wrapper_8f249c2863945cb59771b97c53bdafec();
void wrapper_d48105936d4f5d09a78d2aa9f878fdb8();
void wrapper_e76a1308464d5a9a837d9a61f942fae7();
void wrapper_f1ab29faa1815285a06ca52391d1425f();
void wrapper_fa414b05d29e5f4ea0b6d6cb5cf81b01();
void wrapper_107131f9768c56e794a9b0de728d1738();
void wrapper_6b9ae5eac40858c9a0f5e6e21c15d1d3();
void wrapper_c047f2c3135554ceb57f166fd404cfc8();
void wrapper_d0ba0922f2505f7b8e291326cad79af5();
void wrapper_dc5522842bc75d8b9ac7b46020c60854();

boost::python::docstring_options docstring_options(1, 0, 0);

BOOST_PYTHON_MODULE(__stl)
{
wrapper_10b14312eeb655268489cd34090870cf();
wrapper_3b59a0980c80518c808634f7a84dc3cd();
wrapper_448c20257e485acda59dc59305fceb58();
wrapper_476c1c1f206251dba7af53c48f3f6e42();
wrapper_6436891c9b6854f494789a812891cbe5();
wrapper_745e4933f5b250d9bc5232fe864d0cf7();
wrapper_74bc331707c1505eb2f807cae7c32bbb();
wrapper_858bbf0613575e2ebe4b0e5902107ad6();
wrapper_882a8dd1e64a51b4a9da29ab852a852e();
wrapper_8f249c2863945cb59771b97c53bdafec();
wrapper_d48105936d4f5d09a78d2aa9f878fdb8();
wrapper_e76a1308464d5a9a837d9a61f942fae7();
wrapper_f1ab29faa1815285a06ca52391d1425f();
wrapper_fa414b05d29e5f4ea0b6d6cb5cf81b01();
wrapper_107131f9768c56e794a9b0de728d1738();
wrapper_6b9ae5eac40858c9a0f5e6e21c15d1d3();
wrapper_c047f2c3135554ceb57f166fd404cfc8();
wrapper_d0ba0922f2505f7b8e291326cad79af5();
wrapper_dc5522842bc75d8b9ac7b46020c60854();
}
17 changes: 17 additions & 0 deletions src/py/wrapper/_stl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef AUTOWIG__STL
#define AUTOWIG__STL

#include <boost/python.hpp>
#include <type_traits>
#include <statiskit/stl/STL.h>
#include <memory>

namespace autowig
{
template<class T> struct Held {
typedef std::shared_ptr< T > Type;
static bool const is_class = true;
};
}

#endif

0 comments on commit c7690a0

Please sign in to comment.