From 7dda78ce96139a043eba5b313a3eb94ffdc9a215 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 31 Mar 2013 22:29:49 -0700 Subject: gras: more of that include vs import w/ swig --- include/gras/block.i | 2 +- include/gras/element.i | 22 ++++++++++++---------- include/gras/hier_block.i | 2 +- python/gras/GRAS_Block.i | 1 + python/gras/GRAS_HierBlock.i | 1 + 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/gras/block.i b/include/gras/block.i index 10ef70c..8e1a635 100644 --- a/include/gras/block.i +++ b/include/gras/block.i @@ -7,7 +7,7 @@ #include %} -%include +%import %import %include %import diff --git a/include/gras/element.i b/include/gras/element.i index 1408eac..be3814e 100644 --- a/include/gras/element.i +++ b/include/gras/element.i @@ -34,23 +34,25 @@ //////////////////////////////////////////////////////////////////////// // Operator overloads for Element //////////////////////////////////////////////////////////////////////// -%extend gras::Element +%{ + +inline bool gras_element_equal(const gras::Element &lhs, const gras::Element &rhs) { - std::string __str__(void) const - { - return ($self)->to_string(); - } + return lhs.get() == rhs.get(); +} - bool _equal(const Element &rhs) const - { - return ($self)->get() == rhs.get(); - } +%} +%extend gras::Element +{ %insert("python") %{ def __eq__(self, rhs): if not isinstance(rhs, Element): return False - return self._equal(rhs) + return gras_element_equal(self, rhs) + + def __str__(self): + return self.to_string() %} } diff --git a/include/gras/hier_block.i b/include/gras/hier_block.i index 67cf74e..da57e3d 100644 --- a/include/gras/hier_block.i +++ b/include/gras/hier_block.i @@ -7,7 +7,7 @@ #include %} -%include +%import %include #endif /*INCLUDED_GRAS_HIER_BLOCK_I*/ diff --git a/python/gras/GRAS_Block.i b/python/gras/GRAS_Block.i index 84d6548..82c5d78 100644 --- a/python/gras/GRAS_Block.i +++ b/python/gras/GRAS_Block.i @@ -58,6 +58,7 @@ #include %} +%include %include //////////////////////////////////////////////////////////////////////// diff --git a/python/gras/GRAS_HierBlock.i b/python/gras/GRAS_HierBlock.i index 21d087e..4afe8fe 100644 --- a/python/gras/GRAS_HierBlock.i +++ b/python/gras/GRAS_HierBlock.i @@ -25,6 +25,7 @@ //////////////////////////////////////////////////////////////////////// // pull in hier and top interface //////////////////////////////////////////////////////////////////////// +%include %include %include -- cgit