[ci] Fix clang-santisers job for GHA change
[xapian.git] / xapian-bindings / python3 / fixup-swig-py3-wrapper
blob82e5f2ed2f0d1c21bdb28b8bb952acb528784cce
1 #!/usr/bin/perl
2 # Copyright (c) 2016,2019 Olly Betts
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to
6 # deal in the Software without restriction, including without limitation the
7 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 # sell copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 # IN THE SOFTWARE.
22 use strict;
23 use warnings;
25 undef $/;
26 $_ = <>;
28 my ($pos, $find, $replace);
30 s/^try:\n import builtins as __builtin__.*?\n import __builtin__\n//sm or
31 die "Failed to fix up import code";
33 $replace = << '__END__';
34 def _swig_repr(self):
35 strthis = ""
36 if hasattr(self.this, '__repr__'):
37 strthis = "proxy of " + self.this.__repr__()
38 __END__
39 s/^(?:def _swig_setattr_nondynamic\(self.*?\n)?def _swig_repr\(self\):.*?(\n return)/$replace$1/sm or
40 die "Failed to fix up _swig_repr";
42 s/^def _swig_setattr_nondynamic.*?\nclass _SwigNonDynamicMeta\(type\):.*?\n\n//sm or
43 die "Failed to fix up _swig_setattr_nondynamic";
45 /\b__builtin__\b/ and
46 die "Failed to fully fix up __builtin__";
48 /\b_swig_[gs]etattr/ and
49 die "Failed to fully fix up _swig_getattr/_swig_setattr*";
51 print;
53 # Workaround Perl 5.28 -i quirk:
54 <>;