Skip to content

Commit

Permalink
Merge pull request #16 from pfernique/master
Browse files Browse the repository at this point in the history
Add Sublime Text project and unordered_set
  • Loading branch information
pfernique committed Apr 27, 2017
2 parents dd6ede5 + 298b664 commit d85fbc6
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 19 deletions.
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
.sconsign.dblite
doc/html
doc/latex
doc/Doxyfile
build
*.pkl
*.pyc
*.so
*.pyc
*~
.sconsign.dblite
ASG.pkl
.~lock.*
*.sublime-workspace
.coverage
16 changes: 8 additions & 8 deletions src/cpp/AutoWIG.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def controller(asg):
parameter = function.parameters[0].qualified_type.desugared_type
if parameter.is_class:
function.parent = parameter.unqualified_type
for cls in asg['class ::std::vector'].specializations():
for cls in asg['class ::std::vector'].specializations(partial = False):
for method in cls.methods():
if method.localname in ['resize', 'shrink_to_fit', 'operator[]']:
if isinstance(method.boost_python_export, bool):
Expand All @@ -20,7 +20,7 @@ def controller(asg):
if not(constructor.nb_parameters == 0 or constructor.nb_parameters == 1 and constructor.parameters[0].qualified_type.unqualified_type == cls):
if isinstance(constructor.boost_python_export, bool):
constructor.boost_python_export = False
for cls in asg['class ::std::set'].specializations():
for cls in asg['class ::std::set'].specializations(partial = False):
for method in cls.methods():
if method.localname in ['swap', 'key_comp', 'value_comp', 'get_allocator']:
if isinstance(method.boost_python_export, bool):
Expand All @@ -29,18 +29,18 @@ def controller(asg):
if not(constructor.nb_parameters == 0 or constructor.nb_parameters == 1 and constructor.parameters[0].qualified_type.unqualified_type == cls):
if isinstance(constructor.boost_python_export, bool):
constructor.boost_python_export = False
for cls in asg['class ::std::less'].specializations():
for cls in asg['class ::std::less'].specializations(partial = False):
cls.boost_python_export = False
for cls in asg['class ::std::allocator'].specializations():
for cls in asg['class ::std::allocator'].specializations(partial = False):
cls.boost_python_export = False
if 'class ::std::reverse_iterator' in asg:
for cls in asg['class ::std::reverse_iterator'].specializations():
for cls in asg['class ::std::reverse_iterator'].specializations(partial = False):
cls.boost_python_export = False
if 'class ::std::initializer_list' in asg:
for cls in asg['class ::std::initializer_list'].specializations():
for cls in asg['class ::std::initializer_list'].specializations(partial = False):
cls.boost_python_export = False
if 'class ::std::default_delete' in asg:
for cls in asg['class ::std::default_delete'].specializations():
for cls in asg['class ::std::default_delete'].specializations(partial = False):
cls.boost_python_export = False
for mtd in asg['::statiskit::stl::String'].qualified_type.desugared_type.unqualified_type.methods():
#if mtd.localname in ['substr', 'compare']:
Expand All @@ -49,7 +49,7 @@ def controller(asg):

def generator(asg, module, decorator):
autowig.generator.plugin = 'boost_python'
nodes = [typedef.qualified_type.unqualified_type for typedef in asg['::statiskit::stl'].typedefs()] + asg['class ::std::basic_string'].specializations()
nodes = [typedef.qualified_type.unqualified_type for typedef in asg['::statiskit::stl'].typedefs()] + asg['class ::std::basic_string'].specializations(partial = False)
nodes = list(itertools.chain(*[node.bases(inherited=True) for node in nodes])) + nodes + asg['::statiskit::stl'].declarations()
return autowig.generator(asg, nodes, module=module,
decorator=decorator,
Expand Down
27 changes: 20 additions & 7 deletions src/cpp/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ VECTORS = ['Index',
SETS = { 'less': ['Index',
'int',
'double',
'std::string']}
'std::string'],
'none': ['Index']}

HEADER = """\
#ifndef STATISKIT_STL_H
#define STATISKIT_STL_H
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#if defined WIN32 || defined _WIN32 || defined __CYGWIN__
Expand Down Expand Up @@ -43,6 +45,7 @@ HEADER = """\
namespace statiskit
{
typedef unsigned long int Index;
typedef std::set< Index > Indices;
namespace stl
{
Expand Down Expand Up @@ -98,19 +101,29 @@ with open('STL.h', 'w') as filehandler:
filehandler.write('\n')
for sort in SETS:
for T in SETS[sort]:
SET = 'Set' + sort.capitalize() + capitalize(T)
filehandler.write('\t\ttypedef std::set< ' + T + ', std::' + sort + '< ' + T + ' >, std::allocator< ' + T + ' > > ' + SET + ';\n')
GENERATOR = SET + 'Generator'
filehandler.write('\t\ttypedef Generator< ' + SET + ' > ' + GENERATOR + ';\n')
filehandler.write('\t\tSTATISKIT_STL_API ' + GENERATOR + ' generator(const ' + SET + '& iterable);\n')
filehandler.write('\t\tSTATISKIT_STL_API bool insert(' + SET + '& iterable, const ' + T + '& value);\n')
if sort == 'none':
SET = 'Set' + capitalize(T)
filehandler.write('\t\ttypedef std::unordered_set< ' + T + ' > ' + SET + ';\n')
GENERATOR = SET + 'Generator'
filehandler.write('\t\ttypedef Generator< ' + SET + ' > ' + GENERATOR + ';\n')
filehandler.write('\t\tSTATISKIT_STL_API ' + GENERATOR + ' generator(const ' + SET + '& iterable);\n')
filehandler.write('\t\tSTATISKIT_STL_API bool insert(' + SET + '& iterable, const ' + T + '& value);\n')
else:
SET = 'Set' + sort.capitalize() + capitalize(T)
filehandler.write('\t\ttypedef std::set< ' + T + ', std::' + sort + '< ' + T + ' >, std::allocator< ' + T + ' > > ' + SET + ';\n')
GENERATOR = SET + 'Generator'
filehandler.write('\t\ttypedef Generator< ' + SET + ' > ' + GENERATOR + ';\n')
filehandler.write('\t\tSTATISKIT_STL_API ' + GENERATOR + ' generator(const ' + SET + '& iterable);\n')
filehandler.write('\t\tSTATISKIT_STL_API bool insert(' + SET + '& iterable, const ' + T + '& value);\n')
filehandler.write('\n')
filehandler.write('\t}\n}\n\n\n#endif')

with open('STL.cpp', 'w') as filehandler:
filehandler.write('#include "STL.h"\n\nnamespace statiskit\n{\n\tnamespace stl\n\t{\n')
for sort in SETS:
for T in SETS[sort]:
if sort == 'none':
sort = ''
SET = 'Set' + sort.capitalize() + capitalize(T)
GENERATOR = SET + 'Generator'
filehandler.write('\t\t' + GENERATOR +' generator(const ' + SET + '& iterable)\n')
Expand Down
6 changes: 6 additions & 0 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 Down
6 changes: 6 additions & 0 deletions src/cpp/STL.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <vector>
#include <set>
#include <unordered_set>
#include <string>

#if defined WIN32 || defined _WIN32 || defined __CYGWIN__
Expand Down Expand Up @@ -30,6 +31,7 @@
namespace statiskit
{
typedef unsigned long int Index;
typedef std::set< Index > Indices;

namespace stl
{
Expand Down Expand Up @@ -78,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 Down
4 changes: 4 additions & 0 deletions src/py/_stl.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#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_d48105936d4f5d09a78d2aa9f878fdb8();
void wrapper_e76a1308464d5a9a837d9a61f942fae7();
void wrapper_f1ab29faa1815285a06ca52391d1425f();
void wrapper_107131f9768c56e794a9b0de728d1738();
Expand All @@ -20,13 +22,15 @@ 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_d48105936d4f5d09a78d2aa9f878fdb8();
wrapper_e76a1308464d5a9a837d9a61f942fae7();
wrapper_f1ab29faa1815285a06ca52391d1425f();
wrapper_107131f9768c56e794a9b0de728d1738();
Expand Down
5 changes: 4 additions & 1 deletion src/py/statiskit/stl/_stl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@


# Group template specializations
__stl.statiskit.stl._Generator = (__stl.statiskit.stl._Generator_10b14312eeb655268489cd34090870cf, __stl.statiskit.stl._Generator_745e4933f5b250d9bc5232fe864d0cf7, __stl.statiskit.stl._Generator_74bc331707c1505eb2f807cae7c32bbb, __stl.statiskit.stl._Generator_e76a1308464d5a9a837d9a61f942fae7)
__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._Vector = (__stl.std._Vector_107131f9768c56e794a9b0de728d1738, __stl.std._Vector_6b9ae5eac40858c9a0f5e6e21c15d1d3, __stl.std._Vector_c047f2c3135554ceb57f166fd404cfc8, __stl.std._Vector_dc5522842bc75d8b9ac7b46020c60854)
__stl.std._UnorderedSet = (__stl.std._UnorderedSet_d48105936d4f5d09a78d2aa9f878fdb8)
__stl.std._Set = (__stl.std._Set_476c1c1f206251dba7af53c48f3f6e42, __stl.std._Set_6436891c9b6854f494789a812891cbe5, __stl.std._Set_858bbf0613575e2ebe4b0e5902107ad6, __stl.std._Set_882a8dd1e64a51b4a9da29ab852a852e)

# Define aliases
Expand All @@ -17,6 +18,7 @@
__stl.statiskit.stl.VectorInt = __stl.std._Vector_6b9ae5eac40858c9a0f5e6e21c15d1d3
__stl.statiskit.stl.VectorDouble = __stl.std._Vector_107131f9768c56e794a9b0de728d1738
__stl.statiskit.stl.SetLessDoubleGenerator = __stl.statiskit.stl._Generator_74bc331707c1505eb2f807cae7c32bbb
__stl.statiskit.stl.SetIndex = __stl.std._UnorderedSet_d48105936d4f5d09a78d2aa9f878fdb8
__stl.statiskit.stl.SetLessString = __stl.std._Set_6436891c9b6854f494789a812891cbe5
__stl.statiskit.stl.VectorIndex = __stl.std._Vector_dc5522842bc75d8b9ac7b46020c60854
__stl.statiskit.stl.SetLessDouble = __stl.std._Set_858bbf0613575e2ebe4b0e5902107ad6
Expand All @@ -27,4 +29,5 @@
__stl.statiskit.stl.String = __stl.std._BasicString_448c20257e485acda59dc59305fceb58
__stl.statiskit.stl.SetLessIntGenerator = __stl.statiskit.stl._Generator_e76a1308464d5a9a837d9a61f942fae7
__stl.statiskit.stl.SetLessStringGenerator = __stl.statiskit.stl._Generator_745e4933f5b250d9bc5232fe864d0cf7
__stl.statiskit.stl.SetIndexGenerator = __stl.statiskit.stl._Generator_3b59a0980c80518c808634f7a84dc3cd
__stl.std._Vector_c047f2c3135554ceb57f166fd404cfc8.ValueType = __stl.std._BasicString_448c20257e485acda59dc59305fceb58
44 changes: 44 additions & 0 deletions src/py/wrapper_3b59a0980c80518c808634f7a84dc3cd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "_stl.h"



namespace autowig
{

void method_decorator_03b285991d1f51b1a7d55a3416478017(class ::statiskit::stl::Generator< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > > & instance, class ::statiskit::stl::Generator< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > > & param_out) { instance.operator++() = param_out; }
}

#if defined(_MSC_VER)
#if (_MSC_VER == 1900)
namespace boost
{
template <> class ::statiskit::stl::Generator< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > > const volatile * get_pointer<class ::statiskit::stl::Generator< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > > const volatile >(class ::statiskit::stl::Generator< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > > const volatile *c) { return c; }
}
#endif
#endif



void wrapper_3b59a0980c80518c808634f7a84dc3cd()
{

std::string name_fa414b05d29e5f4ea0b6d6cb5cf81b01 = boost::python::extract< std::string >(boost::python::scope().attr("__name__") + ".statiskit");
boost::python::object module_fa414b05d29e5f4ea0b6d6cb5cf81b01(boost::python::handle< >(boost::python::borrowed(PyImport_AddModule(name_fa414b05d29e5f4ea0b6d6cb5cf81b01.c_str()))));
boost::python::scope().attr("statiskit") = module_fa414b05d29e5f4ea0b6d6cb5cf81b01;
boost::python::scope scope_fa414b05d29e5f4ea0b6d6cb5cf81b01 = module_fa414b05d29e5f4ea0b6d6cb5cf81b01;
std::string name_f1ab29faa1815285a06ca52391d1425f = boost::python::extract< std::string >(boost::python::scope().attr("__name__") + ".stl");
boost::python::object module_f1ab29faa1815285a06ca52391d1425f(boost::python::handle< >(boost::python::borrowed(PyImport_AddModule(name_f1ab29faa1815285a06ca52391d1425f.c_str()))));
boost::python::scope().attr("stl") = module_f1ab29faa1815285a06ca52391d1425f;
boost::python::scope scope_f1ab29faa1815285a06ca52391d1425f = module_f1ab29faa1815285a06ca52391d1425f;
bool (::statiskit::stl::Generator< ::std::unordered_set< unsigned long int, ::std::hash< unsigned long int >, ::std::equal_to< unsigned long int >, ::std::allocator< unsigned long int > > >::*method_pointer_f217f1ea6c09549cb7b59cc38a74d19e)() const = &::statiskit::stl::Generator< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > >::is_valid;
class ::statiskit::stl::Generator< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > > & (::statiskit::stl::Generator< ::std::unordered_set< unsigned long int, ::std::hash< unsigned long int >, ::std::equal_to< unsigned long int >, ::std::allocator< unsigned long int > > >::*method_pointer_03b285991d1f51b1a7d55a3416478017)() = &::statiskit::stl::Generator< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > >::operator++;
unsigned long int (::statiskit::stl::Generator< ::std::unordered_set< unsigned long int, ::std::hash< unsigned long int >, ::std::equal_to< unsigned long int >, ::std::allocator< unsigned long int > > >::*method_pointer_622d5f3583fc559fbc94aa6460932250)() const = &::statiskit::stl::Generator< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > >::value;
boost::python::class_< class ::statiskit::stl::Generator< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > >, autowig::Held< class ::statiskit::stl::Generator< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > > >::Type > class_3b59a0980c80518c808634f7a84dc3cd("_Generator_3b59a0980c80518c808634f7a84dc3cd", "", boost::python::no_init);
class_3b59a0980c80518c808634f7a84dc3cd.def(boost::python::init< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > const & >(""));
class_3b59a0980c80518c808634f7a84dc3cd.def(boost::python::init< class ::statiskit::stl::Generator< class ::std::unordered_set< unsigned long int, struct ::std::hash< unsigned long int >, struct ::std::equal_to< unsigned long int >, class ::std::allocator< unsigned long int > > > const & >(""));
class_3b59a0980c80518c808634f7a84dc3cd.def("is_valid", method_pointer_f217f1ea6c09549cb7b59cc38a74d19e, "");
class_3b59a0980c80518c808634f7a84dc3cd.def("__next__", method_pointer_03b285991d1f51b1a7d55a3416478017, boost::python::return_internal_reference<>(), "");
class_3b59a0980c80518c808634f7a84dc3cd.def("__next__", autowig::method_decorator_03b285991d1f51b1a7d55a3416478017);
class_3b59a0980c80518c808634f7a84dc3cd.def("value", method_pointer_622d5f3583fc559fbc94aa6460932250, "");

}

0 comments on commit d85fbc6

Please sign in to comment.