From 355ebb0665291ed4c60a3df01afac13af2522e25 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Fri, 18 Jul 2008 14:47:47 +0100 Subject: [PATCH] For examples and unit tests, turn deprecation warnings into exceptions; fix cases where deprecations were being used. --- examples/a/wscript | 24 ++++++++++++++++------ examples/b/wscript | 5 ++++- examples/c/wscript | 5 ++++- examples/d/wscript | 5 ++++- examples/e/wscript | 5 ++++- examples/f/wscript | 5 ++++- examples/g/wscript | 5 ++++- examples/h/wscript | 5 ++++- pybindgen/cppmethod.py | 4 ++-- pybindgen/gccxmlparser.py | 4 +--- tests/wscript | 42 ++++++++++++++++++++++++++------------- 11 files changed, 77 insertions(+), 32 deletions(-) diff --git a/examples/a/wscript b/examples/a/wscript index 3f7527d..ccb08db 100644 --- a/examples/a/wscript +++ b/examples/a/wscript @@ -13,7 +13,10 @@ def build(bld): ## manual code generation using simple pybindgen API calls bindgen = bld.create_obj('command-output') bindgen.stdout = 'amodule.cc' - bindgen.argv = [bindgen.input_file('modulegen.py')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('modulegen.py'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen @@ -32,8 +35,11 @@ def build(bld): ## gccxml direct generation method bindgen = bld.create_obj('command-output') bindgen.stdout = 'a1module.cc' - bindgen.argv = [bindgen.input_file('module-autogen.py'), - bindgen.input_file('a.h')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('module-autogen.py'), + bindgen.input_file('a.h'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen @@ -51,15 +57,21 @@ def build(bld): ## gccxml indirect generation method bindgen = bld.create_obj('command-output') bindgen.stdout = 'a2modulegen.py' - bindgen.argv = [bindgen.input_file('module-autoscan.py'), - bindgen.input_file('a.h')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('module-autoscan.py'), + bindgen.input_file('a.h'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen bindgen = bld.create_obj('command-output') bindgen.stdout = 'a2module.cc' - bindgen.argv = [bindgen.input_file('a2modulegen.py')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('a2modulegen.py'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 56 # must run after the 'py' objects in ../pybindgen diff --git a/examples/b/wscript b/examples/b/wscript index ee2af23..5dd3af2 100644 --- a/examples/b/wscript +++ b/examples/b/wscript @@ -13,7 +13,10 @@ def build(bld): ## manual code generation using simple pybindgen API calls bindgen = bld.create_obj('command-output') bindgen.stdout = 'bmodule.cc' - bindgen.argv = [bindgen.input_file('modulegen.py')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('modulegen.py'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen diff --git a/examples/c/wscript b/examples/c/wscript index a466e82..d937f29 100644 --- a/examples/c/wscript +++ b/examples/c/wscript @@ -13,7 +13,10 @@ def build(bld): ## manual code generation using simple pybindgen API calls bindgen = bld.create_obj('command-output') bindgen.stdout = 'cmodule.cc' - bindgen.argv = [bindgen.input_file('modulegen.py')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('modulegen.py'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen diff --git a/examples/d/wscript b/examples/d/wscript index 46c9612..6667c09 100644 --- a/examples/d/wscript +++ b/examples/d/wscript @@ -13,7 +13,10 @@ def build(bld): ## manual code generation using simple pybindgen API calls bindgen = bld.create_obj('command-output') bindgen.stdout = 'dmodule.cc' - bindgen.argv = [bindgen.input_file('modulegen.py')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('modulegen.py'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen diff --git a/examples/e/wscript b/examples/e/wscript index 39b8ca2..e540a1b 100644 --- a/examples/e/wscript +++ b/examples/e/wscript @@ -13,7 +13,10 @@ def build(bld): ## manual code generation using simple pybindgen API calls bindgen = bld.create_obj('command-output') bindgen.stdout = 'emodule.cc' - bindgen.argv = [bindgen.input_file('modulegen.py')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('modulegen.py'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen diff --git a/examples/f/wscript b/examples/f/wscript index 34d0c14..d20eea7 100644 --- a/examples/f/wscript +++ b/examples/f/wscript @@ -13,7 +13,10 @@ def build(bld): ## manual code generation using simple pybindgen API calls bindgen = bld.create_obj('command-output') bindgen.stdout = 'fmodule.cc' - bindgen.argv = [bindgen.input_file('modulegen.py')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('modulegen.py'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen diff --git a/examples/g/wscript b/examples/g/wscript index 9b63c12..1cd3080 100644 --- a/examples/g/wscript +++ b/examples/g/wscript @@ -13,7 +13,10 @@ def build(bld): ## manual code generation using simple pybindgen API calls bindgen = bld.create_obj('command-output') bindgen.stdout = 'gmodule.cc' - bindgen.argv = [bindgen.input_file('modulegen.py')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('modulegen.py'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen diff --git a/examples/h/wscript b/examples/h/wscript index 37ed8f5..4365d1c 100644 --- a/examples/h/wscript +++ b/examples/h/wscript @@ -13,7 +13,10 @@ def build(bld): ## manual code generation using simple pybindgen API calls bindgen = bld.create_obj('command-output') bindgen.stdout = 'hmodule.cc' - bindgen.argv = [bindgen.input_file('modulegen.py')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('modulegen.py'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen diff --git a/pybindgen/cppmethod.py b/pybindgen/cppmethod.py index a918251..b5cb3da 100644 --- a/pybindgen/cppmethod.py +++ b/pybindgen/cppmethod.py @@ -146,8 +146,8 @@ class CppMethod(ForwardWrapperBase): method wrapper clone contains copies of all parameters, so they can be modified at will. """ - meth = CppMethod(self.return_value, - self.method_name, + meth = CppMethod(self.method_name, + self.return_value, [copy(param) for param in self.parameters], is_static=self.is_static, template_parameters=self.template_parameters, diff --git a/pybindgen/gccxmlparser.py b/pybindgen/gccxmlparser.py index 02f904e..08f98e3 100644 --- a/pybindgen/gccxmlparser.py +++ b/pybindgen/gccxmlparser.py @@ -669,7 +669,7 @@ class ModuleParser(object): self.module.add_include(inc) for pygen_sink in self._get_all_pygen_sinks(): - pygen_sink.writeln("from pybindgen import Module, FileCodeSink, write_preamble, param, retval") + pygen_sink.writeln("from pybindgen import Module, FileCodeSink, param, retval") pygen_sink.writeln() pygen_sink = self._get_main_pygen_sink() @@ -808,7 +808,6 @@ pybindgen.settings.error_handler = ErrorHandler() pygen_sink.writeln("register_types(root_module)") pygen_sink.writeln("register_methods(root_module)") pygen_sink.writeln("register_functions(root_module)") - pygen_sink.writeln("write_preamble(out)") pygen_sink.writeln("root_module.generate(out)") pygen_sink.unindent() pygen_sink.writeln() @@ -1767,7 +1766,6 @@ def _test(): if 0: out = FileCodeSink(sys.stdout) import utils - utils.write_preamble(out) module.generate(out) if __name__ == '__main__': diff --git a/tests/wscript b/tests/wscript index 6c325f3..d7baab5 100644 --- a/tests/wscript +++ b/tests/wscript @@ -37,7 +37,10 @@ def build(bld): ## manual code generation using simple pybindgen API calls bindgen = bld.create_obj('command-output') bindgen.stdout = 'foomodule.cc' - bindgen.argv = [bindgen.input_file('foomodulegen.py')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('foomodulegen.py'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen @@ -56,9 +59,12 @@ def build(bld): ### Same thing, but using gccxml autoscanning bindgen = bld.create_obj('command-output') bindgen.stdout = 'foomodule2.cc' - bindgen.argv = [bindgen.input_file('foomodulegen-auto.py'), - bindgen.input_file('foo.h'), - bindgen.output_file('foomodulegen_generated.py')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('foomodulegen-auto.py'), + bindgen.input_file('foo.h'), + bindgen.output_file('foomodulegen_generated.py'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen @@ -66,8 +72,11 @@ def build(bld): ### Now using the generated python script bindgen = bld.create_obj('command-output') bindgen.stdout = 'foomodule3.cc' - bindgen.argv = [bindgen.input_file('foomodulegen3.py'), - bindgen.output_file('foomodule3.cc')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('foomodulegen3.py'), + bindgen.output_file('foomodule3.cc'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 56 # run after the previous bindgen @@ -89,12 +98,14 @@ def build(bld): ### using gccxml autoscanning, but split the generated python script into modules bindgen = bld.create_obj('command-output') - bindgen.argv = [bindgen.input_file('foomodulegen-auto-split.py'), - bindgen.input_file('foo.h'), - bindgen.output_file('foomodulegen_split.py'), - bindgen.output_file('foomodulegen_module1.py'), - bindgen.output_file('foomodulegen_module2.py'), - ] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('foomodulegen-auto-split.py'), + bindgen.input_file('foo.h'), + bindgen.output_file('foomodulegen_split.py'), + bindgen.output_file('foomodulegen_module1.py'), + bindgen.output_file('foomodulegen_module2.py'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen @@ -110,8 +121,11 @@ def build(bld): ### Run the generated python script with split modules bindgen = bld.create_obj('command-output') - bindgen.argv = [bindgen.input_file('foomodulegen4.py'), - bindgen.output_file('foomodule4.cc')] + bindgen.argv = [ + '-Werror::DeprecationWarning', + bindgen.input_file('foomodulegen4.py'), + bindgen.output_file('foomodule4.cc'), + ] bindgen.command = bindgen.env['PYTHON'] bindgen.command_is_external = True bindgen.prio = 56 # run after the previous bindgen