diff options
-rw-r--r-- | include/gras/block.i | 2 | ||||
-rw-r--r-- | include/gras/element.i | 22 | ||||
-rw-r--r-- | include/gras/hier_block.i | 2 | ||||
-rw-r--r-- | python/gras/GRAS_Block.i | 1 | ||||
-rw-r--r-- | 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 <gras/block.hpp> %} -%include <gras/element.i> +%import <gras/element.i> %import <gras/tags.i> %include <gras/tag_iter.i> %import <gras/sbuffer.i> 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 <gras/hier_block.hpp> %} -%include <gras/element.i> +%import <gras/element.i> %include <gras/hier_block.hpp> #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 <iostream> %} +%include <gras/element.i> %include <gras/block.i> //////////////////////////////////////////////////////////////////////// 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 <gras/element.i> %include <gras/hier_block.i> %include <gras/top_block.hpp> |