diff options
author | Olly Betts <olly@survex.com> | 2015-03-20 13:45:19 +1300 |
---|---|---|
committer | Olly Betts <olly@survex.com> | 2015-03-20 13:45:19 +1300 |
commit | c8a7322a4de42ecd099c96e5dcad6b6db74d1c71 (patch) | |
tree | 97cbd52aa6fb8f1bb6bbc6c25da93557d2ddc90c | |
parent | 3bc5348bd26cefbb12a6ea04f5300c47c3f2b589 (diff) | |
download | swig-c8a7322a4de42ecd099c96e5dcad6b6db74d1c71.tar.gz |
Use %{ %} instead of { } after %pythoncode
Simpler and safer change to address PR#357.
-rw-r--r-- | Lib/python/pyabc.i | 2 | ||||
-rw-r--r-- | Lib/python/pycontainer.swg | 4 | ||||
-rw-r--r-- | Lib/python/pyiterators.swg | 4 | ||||
-rw-r--r-- | Lib/python/std_map.i | 16 | ||||
-rw-r--r-- | Lib/python/std_pair.i | 4 | ||||
-rw-r--r-- | Lib/python/std_unordered_map.i | 16 |
6 files changed, 23 insertions, 23 deletions
diff --git a/Lib/python/pyabc.i b/Lib/python/pyabc.i index 3da06b5a9..12ce65985 100644 --- a/Lib/python/pyabc.i +++ b/Lib/python/pyabc.i @@ -1,7 +1,7 @@ %define %pythonabc(Type, Abc) %feature("python:abc", #Abc) Type; %enddef -%pythoncode {import collections}; +%pythoncode %{import collections%} %pythonabc(std::vector, collections.MutableSequence); %pythonabc(std::list, collections.MutableSequence); %pythonabc(std::map, collections.MutableMapping); diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index e5543cd6b..7168862f5 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -710,8 +710,8 @@ namespace swig #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "tp_iter", functype="getiterfunc") iterator; #else - %pythoncode {def __iter__(self): - return self.iterator()} + %pythoncode %{def __iter__(self): + return self.iterator()%} #endif } diff --git a/Lib/python/pyiterators.swg b/Lib/python/pyiterators.swg index 110c431fe..8fbb31226 100644 --- a/Lib/python/pyiterators.swg +++ b/Lib/python/pyiterators.swg @@ -344,8 +344,8 @@ namespace swig %feature("python:slot", "tp_iternext", functype="iternextfunc") SwigPyIterator::__next__; #else %extend SwigPyIterator { - %pythoncode {def __iter__(self): - return self} + %pythoncode %{def __iter__(self): + return self%} } #endif diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index 58902bca4..454e821a5 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -176,14 +176,14 @@ #else %extend { - %pythoncode {def __iter__(self): - return self.key_iterator()} - %pythoncode {def iterkeys(self): - return self.key_iterator()} - %pythoncode {def itervalues(self): - return self.value_iterator()} - %pythoncode {def iteritems(self): - return self.iterator()} + %pythoncode %{def __iter__(self): + return self.key_iterator()%} + %pythoncode %{def iterkeys(self): + return self.key_iterator()%} + %pythoncode %{def itervalues(self): + return self.value_iterator()%} + %pythoncode %{def iteritems(self): + return self.iterator()%} } #endif diff --git a/Lib/python/std_pair.i b/Lib/python/std_pair.i index 73d47e198..5694e7e09 100644 --- a/Lib/python/std_pair.i +++ b/Lib/python/std_pair.i @@ -176,7 +176,7 @@ SwigPython_std_pair_setitem (PyObject *a, Py_ssize_t b, PyObject *c) %define %swig_pair_methods(pair...) #if !defined(SWIGPYTHON_BUILTIN) %extend { -%pythoncode {def __len__(self): +%pythoncode %{def __len__(self): return 2 def __repr__(self): return str((self.first, self.second)) @@ -189,7 +189,7 @@ def __setitem__(self, index, val): if not (index % 2): self.first = val else: - self.second = val} + self.second = val%} } #endif %enddef diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index 737468234..e58a4e927 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -231,14 +231,14 @@ return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } - %pythoncode {def __iter__(self): - return self.key_iterator()} - %pythoncode {def iterkeys(self): - return self.key_iterator()} - %pythoncode {def itervalues(self): - return self.value_iterator()} - %pythoncode {def iteritems(self): - return self.iterator()} + %pythoncode %{def __iter__(self): + return self.key_iterator()%} + %pythoncode %{def iterkeys(self): + return self.key_iterator()%} + %pythoncode %{def itervalues(self): + return self.value_iterator()%} + %pythoncode %{def iteritems(self): + return self.iterator()%} } %enddef |