-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathhex.i
More file actions
105 lines (94 loc) · 2.89 KB
/
hex.i
File metadata and controls
105 lines (94 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* Package : libhex
* hex.i Created : 2007/11/04
* Author : Alex Tingle
*
* Copyright (C) 2007-2008, Alex Tingle.
*
* This file is part of the libhex application.
*
* libhex is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* libhex is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
%module hex
%{
/* Includes the header in the wrapper code */
#include "hex.h"
#include "hexsvg.h"
#include "hexmove.h"
#include <sstream>
%}
%include <std_common.i>
%include <std_list.i>
%include <std_set.i>
%include <std_map.i>
%include <std_pair.i>
%include <std_except.i>
//%include <std_iostream.i>
%include <std_string.i>
/* Useful???
%include <exception.i>
%exception {
try {
$action
} catch (const std::exception& e) {
SWIG_exception(SWIG_RuntimeError, e.what());
}
}
*/
namespace std {
%template(Style) std::map<std::string,std::string>;
%template(StringList) std::list<std::string>;
%template(Set) std::set<hex::Hex*>;
%template(HexList) std::list<hex::Hex*>;
%template(EdgeList) std::list<hex::Edge*>;
%template(AreaList) std::list<hex::Area>;
%template(PathList) std::list<hex::Path>;
%template(PointList) std::list<hex::Point>;
%template(BoundaryList) std::list<hex::Boundary>;
}
%ignore FIRETREE__HEX_H;
%ignore M_SQRT3;
%ignore hex::operator++;
%ignore hex::operator--;
%ignore hex::operator<<;
%ignore FIRETREE__HEXSVG_H;
%ignore hex::svg::operator<<;
%extend hex::Hex
{
// Ensures that the == operator works correctly in Python.
%pythoncode %{
def __cmp__(self,other):
return cmp( self.__hash__(), other.__hash__() )
def __hash__(self):
return (self.i << 14) | (self.j)
%}
};
%extend hex::Edge
{
// Ensures that the == operator works correctly in Python.
%pythoncode %{
def __cmp__(self,other):
return cmp( self.__hash__(), other.__hash__() )
def __hash__(self):
return (hash(self.hex()) << 3) | self.direction()
%}
};
// Lots of classes have str() member functions. This renames them so they work
// with the Python str operator.
%rename(__str__) str;
%feature("autodoc","1");
/* Parse the header file to generate wrappers */
%include "hex.h"
%include "hexsvg.h"
%include "hexmove.h"