Thread: [pygccxml-commit] SF.net SVN: pygccxml:[1667] pyplusplus_dev (Page 3)
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2009-02-09 14:10:01
|
Revision: 1667 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1667&view=rev Author: roman_yakovenko Date: 2009-02-09 14:09:58 +0000 (Mon, 09 Feb 2009) Log Message: ----------- sphinx Modified Paths: -------------- pygccxml_dev/pygccxml/parser/directory_cache.py pyplusplus_dev/README.txt pyplusplus_dev/docs/documentation/apidocs/messages.rest pyplusplus_dev/docs/documentation/index.rest pyplusplus_dev/pyplusplus/code_creators/smart_pointers.py pyplusplus_dev/pyplusplus/decl_wrappers/algorithm.py pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py pyplusplus_dev/pyplusplus/file_writers/class_multiple_files.py pyplusplus_dev/pyplusplus/function_transformers/transformers.py pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py Modified: pygccxml_dev/pygccxml/parser/directory_cache.py =================================================================== --- pygccxml_dev/pygccxml/parser/directory_cache.py 2009-02-09 11:29:59 UTC (rev 1666) +++ pygccxml_dev/pygccxml/parser/directory_cache.py 2009-02-09 14:09:58 UTC (rev 1667) @@ -112,9 +112,9 @@ :param source_file: a C++ source file name. :type source_file: str :param configuration: configuration object. - :type configuration: :class:config_t + :type configuration: :class:`config_t` :param declarations: declarations contained in the `source_file` - :type declarations: picklable object + :type declarations: pickable object :param included_files: included files :type included_files: list of str """ @@ -260,7 +260,6 @@ :param filename: Output file name :type filename: str :param data: A Python object that will be pickled - :type data: pickable object """ if self.__compression: f = gzip.GzipFile(filename, "wb") Modified: pyplusplus_dev/README.txt =================================================================== --- pyplusplus_dev/README.txt 2009-02-09 11:29:59 UTC (rev 1666) +++ pyplusplus_dev/README.txt 2009-02-09 14:09:58 UTC (rev 1667) @@ -41,8 +41,7 @@ python setup.py doc -In order for this to work you need epydoc (http://epydoc.sourceforge.net) -and pygccxml. +In order for this to work you need Sphinx and pygccxml. -------------------------------------------------------------------------- Modified: pyplusplus_dev/docs/documentation/apidocs/messages.rest =================================================================== --- pyplusplus_dev/docs/documentation/apidocs/messages.rest 2009-02-09 11:29:59 UTC (rev 1666) +++ pyplusplus_dev/docs/documentation/apidocs/messages.rest 2009-02-09 14:09:58 UTC (rev 1667) @@ -1,19 +1,10 @@ -Pyplusplus\Messages Documentation -================================= +=========================== +pyplusplus.messages package +=========================== -This page contains the Pyplusplus\Messages Package documentation. +warnings_ +--------- -The :mod:`messages.warnings_` Modules -------------------------------------- - -.. automodule:: messages.warnings_ +.. automodule:: pyplusplus.messages.warnings_ :members: :show-inheritance: - -The :mod:`pyplusplus\messages` Package --------------------------------------- - -.. automodule:: pyplusplus\messages - :members: - :show-inheritance: - Modified: pyplusplus_dev/docs/documentation/index.rest =================================================================== --- pyplusplus_dev/docs/documentation/index.rest 2009-02-09 11:29:59 UTC (rev 1666) +++ pyplusplus_dev/docs/documentation/index.rest 2009-02-09 14:09:58 UTC (rev 1667) @@ -12,7 +12,7 @@ How can you help? * Lets face it: today it is not possible to use :doc:`Py++ <../pyplusplus>` without eventually - looking into source code. :doc:`Py++ <../pyplusplus>` uses `epydoc`_ to generate documentation + looking into source code. :doc:`Py++ <../pyplusplus>` uses Sphinx to generate documentation from source files. So, if you found some undocumented piece of code and you understand what it does, please write documentation string. @@ -44,7 +44,6 @@ functions/functions.rest how_to/how_to.rest -.. _`epydoc` : http://epydoc.sourceforge.net/ .. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html .. _`Python`: http://www.python.org .. _`GCC-XML`: http://www.gccxml.org Modified: pyplusplus_dev/pyplusplus/code_creators/smart_pointers.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/smart_pointers.py 2009-02-09 11:29:59 UTC (rev 1666) +++ pyplusplus_dev/pyplusplus/code_creators/smart_pointers.py 2009-02-09 14:09:58 UTC (rev 1667) @@ -12,11 +12,14 @@ templates = declarations.templates class held_type_t(object): - """ Helper class that can hold name of `smart_ptr` type and create - identifier for held type from that given a creator. """ + Helper class that can hold smart pointer name and create identifier for the + held type from that given a creator. + """ def __init__( self, smart_ptr ): - """ smart_ptr: string of ptr type. Ex: `boost::shared_ptr`""" + """ + :param smart_ptr: smart pointer type as string + """ object.__init__( self ) self._smart_ptr = smart_ptr Modified: pyplusplus_dev/pyplusplus/decl_wrappers/algorithm.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/algorithm.py 2009-02-09 11:29:59 UTC (rev 1666) +++ pyplusplus_dev/pyplusplus/decl_wrappers/algorithm.py 2009-02-09 14:09:58 UTC (rev 1667) @@ -9,13 +9,14 @@ from pygccxml import declarations def creators_affect_on_me( me ): - """Find all relevant code creators, which influence on code generated by "me". + """ + find all relevant code creators, which influence on code generated by "me". - C++ allows to define aliases to namespaces. `Py++` allows user to define aliases - to the namespace and will take this aliases into account when it generates - the code. + C++ allows to define aliases to namespaces. `Py++` allows user to define + aliases to the namespace and will take this aliases into account when it + generates the code. - Example: + Example: :: [a b c d e f g] | @@ -49,12 +50,13 @@ __RE_VALID_IDENTIFIER = re.compile( r"[_a-z]\w*", re.I | re.L | re.U ) def create_valid_name(name): - """Create valid name\\Python identifier from a string + """ + creates Python identifier from a string - As input this functions takes valid C++ name\identifier and replaces all invalid - characters. + As input this functions takes valid C++ name\\identifier and replaces all + illegal characters. - Invalid characters are introduced by a template instantiation. + Illegal characters are introduced by a template instantiation. """ global __RE_VALID_IDENTIFIER match_found = __RE_VALID_IDENTIFIER.match(name) Modified: pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py 2009-02-09 11:29:59 UTC (rev 1666) +++ pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py 2009-02-09 14:09:58 UTC (rev 1667) @@ -65,18 +65,21 @@ , doc=__call_policies_doc__ ) __use_make_functions_doc__ = \ - """Generate code using make_getter and make_setter functions + """ + Generate code using `make_getter` and `make_setter` functions - Basically you don't need to use this, untill you have one of the next use-cases: - * member variable is smart pointer - in this case Boost.Python has small problem - to expose it right. Using the functions is a work around to the problem. - * member variable defined custom r-value converter - may be you don't know - but the conversion is applied only on functions arguments. So you need to - use make_getter/make_setter in order to allow user to enjoy from the - conversion. + Basically you don't need to use this, untill you have one of the following + use-cases: - Setting "apply_smart_ptr_wa" and/or "use_make_functions" to "True" will tell - `Py++` to generate such code. + * member variable is smart pointer - in this case Boost.Python has small + problem to expose it right. Using get/set functions is a work-around. + + * member variable defined custom r-value converter - may be you don't know + but the conversion is applied only on functions arguments. So you need to + use make_getter/make_setter functions, allow users to enjoy from the conversion. + + Setting :attr:`apply_smart_ptr_wa` and/or :attr:`use_make_functions` to "True" + will tell `Py++` to generate such code. """ def get_apply_smart_ptr_wa( self ): Modified: pyplusplus_dev/pyplusplus/file_writers/class_multiple_files.py =================================================================== --- pyplusplus_dev/pyplusplus/file_writers/class_multiple_files.py 2009-02-09 11:29:59 UTC (rev 1666) +++ pyplusplus_dev/pyplusplus/file_writers/class_multiple_files.py 2009-02-09 14:09:58 UTC (rev 1667) @@ -3,9 +3,10 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -"""defines a class that writes :class:`code_creators.bpmodule_t` to multiple files, the class -also splits huge C++ classes to few source files """ +defines a class that writes :class:`code_creators.bpmodule_t` to multiple files, +the class also splits huge C++ classes to few source files. +""" import os import writer @@ -15,18 +16,21 @@ from pyplusplus import code_creators from pyplusplus import utils as pypp_utils -#TODO: to add namespace_alias_t classes class class_multiple_files_t(multiple_files.multiple_files_t): """ This class will split code, generated for huge classes, to few files. - Next strategy will be used: - 1. New directory with class alias name will be created. - 2. pyplusplus will generate - wrapper header - header that will contain code generated for class wrappers - classes h/cpp - will contain registration code for internal classes - `memfun` h/cpp - will contain registration code for member functions + The following strategy will be used: - alias + _main h/cpp this class will contain main registration function. + * New directory, named after a class alias, will be created. + + * `Py++` will generate + + * wrapper header - header that will contain code generated for class wrappers + * classes h/cpp - will contain registration code for internal classes + * `memfun` h/cpp - will contain registration code for member functions + + The main class registration function will be placed in "%(class alias)s_main" + header and source files. """ def __init__( self Modified: pyplusplus_dev/pyplusplus/function_transformers/transformers.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2009-02-09 11:29:59 UTC (rev 1666) +++ pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2009-02-09 14:09:58 UTC (rev 1667) @@ -428,9 +428,10 @@ class input_c_buffer_t(transformer.transformer_t): - """handles an input of C buffer: + """ + handles an input of C buffer: - void write( byte *buffer, int size ) -> void write( python sequence ) + void write( byte \\*buffer, int size ) -> void write( python sequence ) """ def __init__(self, function, buffer_arg_ref, size_arg_ref): Modified: pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2009-02-09 11:29:59 UTC (rev 1666) +++ pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2009-02-09 14:09:58 UTC (rev 1667) @@ -108,17 +108,18 @@ def register_module_dependency( self, other_module_generated_code_dir ): - """``already_exposed`` solution is pretty good when you mix hand-written + """ + `already_exposed` solution is pretty good when you mix hand-written modules with `Py++` generated. It doesn't work/scale for "true" multi-module development. This is exactly the reason why `Py++` offers "semi automatic" solution. - For every exposed module, `Py++` generates "exposed_decl.pypp.txt" file. + For every exposed module, `Py++` generates `exposed_decl.pypp.txt` file. This file contains the list of all parsed declarations and whether they were included or excluded. Later, when you work on another module, you can tell `Py++` that the current module depends on the previously - generated one. `Py++` will load "exposed_decl.pypp.txt" file and - update the declarations. + generated one. `Py++` will load `exposed_decl.pypp.txt` file and update + the declarations. """ db = utils.exposed_decls_db_t() @@ -269,14 +270,23 @@ self.__registrations_code_head.append( code ) def add_constants( self, **keywds ): - """adds code that exposes some constants to Python. + """ + adds code that exposes some constants to Python. For example: - mb.add_constants( version='"1.2.3"' ) - or - mb.add_constants( **{ version:'"1.2.3"' } ) - will generate next code: - boost::python::scope().attr("version") = "1.2.3"; + .. code-block:: python + + mb.add_constants( version='"1.2.3"' ) + # or + constants = dict( version:'"1.2.3"' ) + mb.add_constants( \\*\\*constants ) + + will generate the following code: + + .. code-block:: c++ + + boost::python::scope().attr("version") = "1.2.3"; + """ tmpl = 'boost::python::scope().attr("%(name)s") = %(value)s;' for name, value in keywds.items(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-02-17 07:16:07
|
Revision: 1687 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1687&view=rev Author: roman_yakovenko Date: 2009-02-17 07:16:05 +0000 (Tue, 17 Feb 2009) Log Message: ----------- fix bug in module_t.update_documentation method Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/module.py pyplusplus_dev/unittests/unicode_bug.py Modified: pyplusplus_dev/pyplusplus/code_creators/module.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/module.py 2009-02-17 06:00:16 UTC (rev 1686) +++ pyplusplus_dev/pyplusplus/code_creators/module.py 2009-02-17 07:16:05 UTC (rev 1687) @@ -81,7 +81,7 @@ if id( cc.declaration ) in visited: continue cc.declaration.documentation = doc_extractor( cc.declaration ) - visited.add( cc.declaration ) + visited.add( id( cc.declaration ) ) class bpmodule_t(module_t): """This class represents the source code for the entire extension module. Modified: pyplusplus_dev/unittests/unicode_bug.py =================================================================== --- pyplusplus_dev/unittests/unicode_bug.py 2009-02-17 06:00:16 UTC (rev 1686) +++ pyplusplus_dev/unittests/unicode_bug.py 2009-02-17 07:16:05 UTC (rev 1687) @@ -13,12 +13,26 @@ from pyplusplus import function_transformers as ft -mb = module_builder.module_builder_t( - [ module_builder.create_text_fc( 'struct x{};' ) ] - , gccxml_path=autoconfig.gccxml.executable - , encoding='UTF-8' - , compiler=autoconfig.cxx_parsers_cfg.gccxml.compiler) +class tester_t( unittest.TestCase ): + def test(self): + mb = module_builder.module_builder_t( + [ module_builder.create_text_fc( 'struct x{};' ) ] + , gccxml_path=autoconfig.gccxml.executable + , encoding='UTF-8' + , compiler=autoconfig.cxx_parsers_cfg.gccxml.compiler) -mb.build_code_creator( module_name='unicode_bug' ) -mb.code_creator.license = "//абвгдеёжзийклмнопрстуфхцчшщъыьэюя" -mb.write_module( os.path.join( autoconfig.build_dir, 'unicode_bug.cpp' ) ) + mb.build_code_creator( module_name='unicode_bug' ) + mb.code_creator.license = "//абвгдеёжзийклмнопрстуфхцчшщъыьэюя" + mb.write_module( os.path.join( autoconfig.build_dir, 'unicode_bug.cpp' ) ) + + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-02-18 13:27:09
|
Revision: 1690 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1690&view=rev Author: roman_yakovenko Date: 2009-02-18 13:27:04 +0000 (Wed, 18 Feb 2009) Log Message: ----------- sphinx Modified Paths: -------------- pygccxml_dev/docs/history/history.rest pygccxml_dev/pygccxml/parser/config.py pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py pyplusplus_dev/pyplusplus/module_builder/module_builder.py pyplusplus_dev/unittests/data/vector3_to_be_exported.hpp pyplusplus_dev/unittests/indexing_suites_v2_bug_tester.py pyplusplus_dev/unittests/vector3_tester.py Modified: pygccxml_dev/docs/history/history.rest =================================================================== --- pygccxml_dev/docs/history/history.rest 2009-02-17 20:29:14 UTC (rev 1689) +++ pygccxml_dev/docs/history/history.rest 2009-02-18 13:27:04 UTC (rev 1690) @@ -32,7 +32,8 @@ 2. Ability to extract different information from binary files ( ``.pdb``, ``.so``, ``.map`` ) and merge it with a declarations tree was added. -3. Ability to load `GCC-XML`_ configuration from ``.ini`` like file was added +3. Ability to load `GCC-XML`_ configuration from ``.ini`` like file was added. + See :func:`pygccxml.parser.config.load_gccxml_configuration` for details. 4. From now on, :doc:`pygccxml <../pygccxml>` will use `Sphinx <http://sphinx.pocoo.org/>`_ for all documentation. Modified: pygccxml_dev/pygccxml/parser/config.py =================================================================== --- pygccxml_dev/pygccxml/parser/config.py 2009-02-17 20:29:14 UTC (rev 1689) +++ pygccxml_dev/pygccxml/parser/config.py 2009-02-18 13:27:04 UTC (rev 1690) @@ -198,7 +198,8 @@ config_t = gccxml_configuration_t #backward computability gccxml_configuration_example = \ -"""[gccxml] +""" +[gccxml] #path to gccxml executable file - optional, if not provided, os.environ['PATH'] #variable is used to find it gccxml_path= @@ -210,24 +211,34 @@ #You can explicitly set what compiler it should emulate. #Valid options are: g++, msvc6, msvc7, msvc71, msvc8, cl. compiler= - -#GCC-XML site: http://gccxml.org/ """ def load_gccxml_configuration( configuration, **defaults ): - """loads GCC-XML configuration from a file + """ + loads GCC-XML configuration from an `.ini` file or any other file class + :class:`ConfigParser.SafeConfigParser` is able to parse. - Configuration file sceleton: + :param configuration: configuration could be string( configuration file path ) + or instance of :class:`ConfigParser.SafeConfigParser` class - >>> start <<< + :rtype: :class:`.gccxml_configuration_t` - %s + Configuration file sceleton:: - >>> end <<< + [gccxml] + #path to gccxml executable file - optional, if not provided, os.environ['PATH'] + #variable is used to find it + gccxml_path= + #gccxml working directory - optional, could be set to your source code directory + working_directory= + #additional include directories, separated by ';' or ':' + include_paths= + #gccxml has a nice algorithms, which selects what C++ compiler to emulate. + #You can explicitly set what compiler it should emulate. + #Valid options are: g++, msvc6, msvc7, msvc71, msvc8, cl. + compiler= - configuration could be string( configuration file path ) or instance of - ConfigParser.SafeConfigParser class - """ % gccxml_configuration_example + """ parser = configuration if isinstance( configuration, types.StringTypes ): from ConfigParser import SafeConfigParser Modified: pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py =================================================================== --- pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py 2009-02-17 20:29:14 UTC (rev 1689) +++ pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py 2009-02-18 13:27:04 UTC (rev 1690) @@ -170,7 +170,9 @@ pass else: assert not "Found %d class code creators" % len(creator) - + import pdb + if '<<' == operator.symbol: + pdb.set_trace() find = code_creators.creator_finder.find_by_declaration if operator.target_class and operator.target_class.ignore == False: found = find( lambda decl: operator.target_class is decl Modified: pyplusplus_dev/pyplusplus/module_builder/module_builder.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/module_builder.py 2009-02-17 20:29:14 UTC (rev 1689) +++ pyplusplus_dev/pyplusplus/module_builder/module_builder.py 2009-02-18 13:27:04 UTC (rev 1690) @@ -131,7 +131,6 @@ """Please see :class:`decl_wrappers.scopedef_t` class documentation""" return self.global_ns.operator( name=name , symbol=symbol - , decl_type=decl_type , return_type=return_type , arg_types=arg_types , header_dir=header_dir @@ -142,7 +141,6 @@ """Please see :class:`decl_wrappers.scopedef_t` class documentation""" return self.global_ns.operators( name=name , symbol=symbol - , decl_type=decl_type , return_type=return_type , arg_types=arg_types , header_dir=header_dir Modified: pyplusplus_dev/unittests/data/vector3_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/vector3_to_be_exported.hpp 2009-02-17 20:29:14 UTC (rev 1689) +++ pyplusplus_dev/unittests/data/vector3_to_be_exported.hpp 2009-02-18 13:27:04 UTC (rev 1690) @@ -6,6 +6,8 @@ #ifndef __vector3_to_be_exported_hpp__ #define __vector3_to_be_exported_hpp__ +#include <iostream> + namespace vector3{ class Vector3 @@ -60,6 +62,11 @@ { } + friend + std::ostream& operator<<(std::ostream& out, const Vector3& v ){ + out << "( " << v.x << "," << v.y << "," << v.z << ")"; + } + inline float operator [] ( const unsigned int i ) const { return *(&x+i); @@ -303,6 +310,7 @@ }; + } #endif//__class_order_to_be_exported_hpp__ \ No newline at end of file Modified: pyplusplus_dev/unittests/indexing_suites_v2_bug_tester.py =================================================================== --- pyplusplus_dev/unittests/indexing_suites_v2_bug_tester.py 2009-02-17 20:29:14 UTC (rev 1689) +++ pyplusplus_dev/unittests/indexing_suites_v2_bug_tester.py 2009-02-18 13:27:04 UTC (rev 1690) @@ -4,35 +4,27 @@ # http://www.boost.org/LICENSE_1_0.txt) import os -import dl import sys import unittest import autoconfig import fundamental_tester_base from pyplusplus import code_creators -sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL) +if 'linux' in sys.platform: + import dl + sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL) - - class tester_t(fundamental_tester_base.fundamental_tester_base_t): def __init__( self, *args ): fundamental_tester_base.fundamental_tester_base_t.__init__( self, self.EXTENSION_NAME, indexing_suite_version=2, *args ) def run_tests(self, module): - try: - v = module.create_vector() - print self.__class__.__name__ - for i in v: - print i - print self.__class__.__name__, ' - done' - print self.__class__.__name__ - for i in v: - print i - print self.__class__.__name__, ' - done(2)' - except Exception, ex: - print 'Error: ', str( ex ) - + v = module.create_vector() + for i in v: + i += 1 + for i in v: + i += 1 + class tester_a_t(tester_t): EXTENSION_NAME = 'indexing_suites_v2_bug_a' def __init__( self, *args ): @@ -44,7 +36,6 @@ def __init__( self, *args ): tester_t.__init__( self, *args ) - def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_a_t)) Modified: pyplusplus_dev/unittests/vector3_tester.py =================================================================== --- pyplusplus_dev/unittests/vector3_tester.py 2009-02-17 20:29:14 UTC (rev 1689) +++ pyplusplus_dev/unittests/vector3_tester.py 2009-02-18 13:27:04 UTC (rev 1690) @@ -11,9 +11,9 @@ class tester_t(fundamental_tester_base.fundamental_tester_base_t): EXTENSION_NAME = 'vector3' - + def __init__( self, *args ): - fundamental_tester_base.fundamental_tester_base_t.__init__( + fundamental_tester_base.fundamental_tester_base_t.__init__( self , tester_t.EXTENSION_NAME , *args ) @@ -26,16 +26,19 @@ vec3.add_registration_code( 'add_property( "x", &vector3::Vector3::x)' ) vec3.add_registration_code( 'add_property( "y", &vector3::Vector3::y)' ) vec3.add_registration_code( 'add_property( "z", &vector3::Vector3::z)' ) + mb.operator( lambda o: o.symbol == '<<' and 'Vector3' in o.decl_string ).include() - def run_tests( self, module): v3 = module.Vector3() self.failUnless( v3.ZERO == v3.do_smth() ) #test copy constructor self.failUnless( module.Vector3(v3.ZERO) == v3.do_smth() ) - + + x = module.Vector3( 1,2,3) + print str(x) + def create_suite(): - suite = unittest.TestSuite() + suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-02-18 21:17:58
|
Revision: 1692 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1692&view=rev Author: roman_yakovenko Date: 2009-02-18 21:17:50 +0000 (Wed, 18 Feb 2009) Log Message: ----------- fix "operator"s bug Modified Paths: -------------- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py pyplusplus_dev/unittests/data/vector3_to_be_exported.hpp pyplusplus_dev/unittests/vector3_tester.py Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2009-02-18 14:18:58 UTC (rev 1691) +++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2009-02-18 21:17:50 UTC (rev 1692) @@ -425,7 +425,11 @@ arg_2_class = find_class( oper.arguments[1].type ) if arg_1_class: - return arg_1_class + if declarations.is_std_ostream( arg_1_class ) or declarations.is_std_wostream( arg_1_class ): + #in most cases users doesn't expose std::ostream class + return arg_2_class + else: + return arg_1_class else: return arg_2_class Modified: pyplusplus_dev/unittests/data/vector3_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/vector3_to_be_exported.hpp 2009-02-18 14:18:58 UTC (rev 1691) +++ pyplusplus_dev/unittests/data/vector3_to_be_exported.hpp 2009-02-18 21:17:50 UTC (rev 1692) @@ -1,316 +1,317 @@ -// Copyright 2004-2008 Roman Yakovenko. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef __vector3_to_be_exported_hpp__ -#define __vector3_to_be_exported_hpp__ - -#include <iostream> - -namespace vector3{ - -class Vector3 -{ -public: - union { - struct { - float x, y, z; - }; - float val[3]; - }; - -public: - inline Vector3() - { - } - - inline Vector3( const float fX, const float fY, const float fZ ) - : x( fX ), y( fY ), z( fZ ) - { - } - - inline explicit Vector3( const float afCoordinate[3] ) - : x( afCoordinate[0] ), - y( afCoordinate[1] ), - z( afCoordinate[2] ) - { - } - - inline explicit Vector3( const int afCoordinate[3] ) - { - x = (float)afCoordinate[0]; - y = (float)afCoordinate[1]; - z = (float)afCoordinate[2]; - } - - inline explicit Vector3( float* const r ) - : x( r[0] ), y( r[1] ), z( r[2] ) - { - } - - inline explicit Vector3( const float scaler ) - : x( scaler ) - , y( scaler ) - , z( scaler ) - { - } - - - inline Vector3( const Vector3& rkVector ) - : x( rkVector.x ), y( rkVector.y ), z( rkVector.z ) - { - } - - friend - std::ostream& operator<<(std::ostream& out, const Vector3& v ){ - out << "( " << v.x << "," << v.y << "," << v.z << ")"; - } - - inline float operator [] ( const unsigned int i ) const - { - return *(&x+i); - } - - inline float& operator [] ( const unsigned int i ) - { - return *(&x+i); - } - - /** Assigns the value of the other vector. - @param - rkVector The other vector - */ - inline Vector3& operator = ( const Vector3& rkVector ) - { - x = rkVector.x; - y = rkVector.y; - z = rkVector.z; - - return *this; - } - - inline Vector3& operator = ( const float fScaler ) - { - x = fScaler; - y = fScaler; - z = fScaler; - - return *this; - } - - inline bool operator == ( const Vector3& rkVector ) const - { - return ( x == rkVector.x && y == rkVector.y && z == rkVector.z ); - } - - inline bool operator != ( const Vector3& rkVector ) const - { - return ( x != rkVector.x || y != rkVector.y || z != rkVector.z ); - } - - // arithmetic operations - inline Vector3 operator + ( const Vector3& rkVector ) const - { - Vector3 kSum; - - kSum.x = x + rkVector.x; - kSum.y = y + rkVector.y; - kSum.z = z + rkVector.z; - - return kSum; - } - - inline Vector3 operator - ( const Vector3& rkVector ) const - { - Vector3 kDiff; - - kDiff.x = x - rkVector.x; - kDiff.y = y - rkVector.y; - kDiff.z = z - rkVector.z; - - return kDiff; - } - - inline Vector3 operator * ( const float fScalar ) const - { - Vector3 kProd; - - kProd.x = fScalar*x; - kProd.y = fScalar*y; - kProd.z = fScalar*z; - - return kProd; - } - - inline Vector3 operator * ( const Vector3& rhs) const - { - Vector3 kProd; - - kProd.x = rhs.x * x; - kProd.y = rhs.y * y; - kProd.z = rhs.z * z; - - return kProd; - } - - inline Vector3 operator / ( const float fScalar ) const - { - Vector3 kDiv; - - float fInv = 1.0 / fScalar; - kDiv.x = x * fInv; - kDiv.y = y * fInv; - kDiv.z = z * fInv; - - return kDiv; - } - - inline Vector3 operator / ( const Vector3& rhs) const - { - Vector3 kDiv; - - kDiv.x = x / rhs.x; - kDiv.y = y / rhs.y; - kDiv.z = z / rhs.z; - - return kDiv; - } - - - inline Vector3 operator - () const - { - Vector3 kNeg; - - kNeg.x = -x; - kNeg.y = -y; - kNeg.z = -z; - - return kNeg; - } - - // overloaded operators to help Vector3 - inline friend Vector3 operator * ( const float fScalar, const Vector3& rkVector ) - { - Vector3 kProd; - - kProd.x = fScalar * rkVector.x; - kProd.y = fScalar * rkVector.y; - kProd.z = fScalar * rkVector.z; - - return kProd; - } - - inline friend Vector3 operator + (const Vector3& lhs, const float rhs) - { - Vector3 ret(rhs); - return ret += lhs; - } - - inline friend Vector3 operator + (const float lhs, const Vector3& rhs) - { - Vector3 ret(lhs); - return ret += rhs; - } - - inline friend Vector3 operator - (const Vector3& lhs, const float rhs) - { - return lhs - Vector3(rhs); - } - - inline friend Vector3 operator - (const float lhs, const Vector3& rhs) - { - Vector3 ret(lhs); - return ret -= rhs; - } - - // arithmetic updates - inline Vector3& operator += ( const Vector3& rkVector ) - { - x += rkVector.x; - y += rkVector.y; - z += rkVector.z; - - return *this; - } - - inline Vector3& operator += ( const float fScalar ) - { - x += fScalar; - y += fScalar; - z += fScalar; - return *this; - } - - inline Vector3& operator -= ( const Vector3& rkVector ) - { - x -= rkVector.x; - y -= rkVector.y; - z -= rkVector.z; - - return *this; - } - - inline Vector3& operator -= ( const float fScalar ) - { - x -= fScalar; - y -= fScalar; - z -= fScalar; - return *this; - } - - inline Vector3& operator *= ( const float fScalar ) - { - x *= fScalar; - y *= fScalar; - z *= fScalar; - return *this; - } - - inline Vector3& operator *= ( const Vector3& rkVector ) - { - x *= rkVector.x; - y *= rkVector.y; - z *= rkVector.z; - - return *this; - } - - inline Vector3& operator /= ( const float fScalar ) - { - float fInv = 1.0 / fScalar; - - x *= fInv; - y *= fInv; - z *= fInv; - - return *this; - } - - inline Vector3& operator /= ( const Vector3& rkVector ) - { - x /= rkVector.x; - y /= rkVector.y; - z /= rkVector.z; - - return *this; - } - - inline float squaredLength () const - { - return x * x + y * y + z * z; - } - +// Copyright 2004-2008 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __vector3_to_be_exported_hpp__ +#define __vector3_to_be_exported_hpp__ + +#include <iostream> + +namespace vector3{ + +class Vector3 +{ +public: + union { + struct { + float x, y, z; + }; + float val[3]; + }; + +public: + inline Vector3() + { + } + + inline Vector3( const float fX, const float fY, const float fZ ) + : x( fX ), y( fY ), z( fZ ) + { + } + + inline explicit Vector3( const float afCoordinate[3] ) + : x( afCoordinate[0] ), + y( afCoordinate[1] ), + z( afCoordinate[2] ) + { + } + + inline explicit Vector3( const int afCoordinate[3] ) + { + x = (float)afCoordinate[0]; + y = (float)afCoordinate[1]; + z = (float)afCoordinate[2]; + } + + inline explicit Vector3( float* const r ) + : x( r[0] ), y( r[1] ), z( r[2] ) + { + } + + inline explicit Vector3( const float scaler ) + : x( scaler ) + , y( scaler ) + , z( scaler ) + { + } + + + inline Vector3( const Vector3& rkVector ) + : x( rkVector.x ), y( rkVector.y ), z( rkVector.z ) + { + } + + friend + std::ostream& operator<<(std::ostream& out, const Vector3& v ){ + out << "( " << v.x << "," << v.y << "," << v.z << " )"; + return out; + } + + inline float operator [] ( const unsigned int i ) const + { + return *(&x+i); + } + + inline float& operator [] ( const unsigned int i ) + { + return *(&x+i); + } + + /** Assigns the value of the other vector. + @param + rkVector The other vector + */ + inline Vector3& operator = ( const Vector3& rkVector ) + { + x = rkVector.x; + y = rkVector.y; + z = rkVector.z; + + return *this; + } + + inline Vector3& operator = ( const float fScaler ) + { + x = fScaler; + y = fScaler; + z = fScaler; + + return *this; + } + + inline bool operator == ( const Vector3& rkVector ) const + { + return ( x == rkVector.x && y == rkVector.y && z == rkVector.z ); + } + + inline bool operator != ( const Vector3& rkVector ) const + { + return ( x != rkVector.x || y != rkVector.y || z != rkVector.z ); + } + + // arithmetic operations + inline Vector3 operator + ( const Vector3& rkVector ) const + { + Vector3 kSum; + + kSum.x = x + rkVector.x; + kSum.y = y + rkVector.y; + kSum.z = z + rkVector.z; + + return kSum; + } + + inline Vector3 operator - ( const Vector3& rkVector ) const + { + Vector3 kDiff; + + kDiff.x = x - rkVector.x; + kDiff.y = y - rkVector.y; + kDiff.z = z - rkVector.z; + + return kDiff; + } + + inline Vector3 operator * ( const float fScalar ) const + { + Vector3 kProd; + + kProd.x = fScalar*x; + kProd.y = fScalar*y; + kProd.z = fScalar*z; + + return kProd; + } + + inline Vector3 operator * ( const Vector3& rhs) const + { + Vector3 kProd; + + kProd.x = rhs.x * x; + kProd.y = rhs.y * y; + kProd.z = rhs.z * z; + + return kProd; + } + + inline Vector3 operator / ( const float fScalar ) const + { + Vector3 kDiv; + + float fInv = 1.0 / fScalar; + kDiv.x = x * fInv; + kDiv.y = y * fInv; + kDiv.z = z * fInv; + + return kDiv; + } + + inline Vector3 operator / ( const Vector3& rhs) const + { + Vector3 kDiv; + + kDiv.x = x / rhs.x; + kDiv.y = y / rhs.y; + kDiv.z = z / rhs.z; + + return kDiv; + } + + + inline Vector3 operator - () const + { + Vector3 kNeg; + + kNeg.x = -x; + kNeg.y = -y; + kNeg.z = -z; + + return kNeg; + } + + // overloaded operators to help Vector3 + inline friend Vector3 operator * ( const float fScalar, const Vector3& rkVector ) + { + Vector3 kProd; + + kProd.x = fScalar * rkVector.x; + kProd.y = fScalar * rkVector.y; + kProd.z = fScalar * rkVector.z; + + return kProd; + } + + inline friend Vector3 operator + (const Vector3& lhs, const float rhs) + { + Vector3 ret(rhs); + return ret += lhs; + } + + inline friend Vector3 operator + (const float lhs, const Vector3& rhs) + { + Vector3 ret(lhs); + return ret += rhs; + } + + inline friend Vector3 operator - (const Vector3& lhs, const float rhs) + { + return lhs - Vector3(rhs); + } + + inline friend Vector3 operator - (const float lhs, const Vector3& rhs) + { + Vector3 ret(lhs); + return ret -= rhs; + } + + // arithmetic updates + inline Vector3& operator += ( const Vector3& rkVector ) + { + x += rkVector.x; + y += rkVector.y; + z += rkVector.z; + + return *this; + } + + inline Vector3& operator += ( const float fScalar ) + { + x += fScalar; + y += fScalar; + z += fScalar; + return *this; + } + + inline Vector3& operator -= ( const Vector3& rkVector ) + { + x -= rkVector.x; + y -= rkVector.y; + z -= rkVector.z; + + return *this; + } + + inline Vector3& operator -= ( const float fScalar ) + { + x -= fScalar; + y -= fScalar; + z -= fScalar; + return *this; + } + + inline Vector3& operator *= ( const float fScalar ) + { + x *= fScalar; + y *= fScalar; + z *= fScalar; + return *this; + } + + inline Vector3& operator *= ( const Vector3& rkVector ) + { + x *= rkVector.x; + y *= rkVector.y; + z *= rkVector.z; + + return *this; + } + + inline Vector3& operator /= ( const float fScalar ) + { + float fInv = 1.0 / fScalar; + + x *= fInv; + y *= fInv; + z *= fInv; + + return *this; + } + + inline Vector3& operator /= ( const Vector3& rkVector ) + { + x /= rkVector.x; + y /= rkVector.y; + z /= rkVector.z; + + return *this; + } + + inline float squaredLength () const + { + return x * x + y * y + z * z; + } + Vector3 do_smth( const Vector3& x = ZERO ){ return x; - } - // special points - static const Vector3 ZERO; - -}; - - - -} - -#endif//__class_order_to_be_exported_hpp__ \ No newline at end of file + } + // special points + static const Vector3 ZERO; + +}; + + + +} + +#endif//__class_order_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/vector3_tester.py =================================================================== --- pyplusplus_dev/unittests/vector3_tester.py 2009-02-18 14:18:58 UTC (rev 1691) +++ pyplusplus_dev/unittests/vector3_tester.py 2009-02-18 21:17:50 UTC (rev 1692) @@ -35,7 +35,7 @@ self.failUnless( module.Vector3(v3.ZERO) == v3.do_smth() ) x = module.Vector3( 1,2,3) - print str(x) + self.failUnless( '( 1,2,3 )' == str(x) ) def create_suite(): suite = unittest.TestSuite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-02-21 12:29:47
|
Revision: 1694 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1694&view=rev Author: roman_yakovenko Date: 2009-02-21 12:29:41 +0000 (Sat, 21 Feb 2009) Log Message: ----------- adding ability to generate code for "included" containers Modified Paths: -------------- pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py pyplusplus_dev/pyplusplus/creators_factory/types_database.py pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py pyplusplus_dev/unittests/indexing_suites2_tester.py Modified: pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py =================================================================== --- pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py 2009-02-19 10:54:51 UTC (rev 1693) +++ pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py 2009-02-21 12:29:41 UTC (rev 1694) @@ -565,6 +565,9 @@ return exposed def visit_class(self ): + if self.curr_decl.indexing_suite: + self.__types_db.update_containers( self.curr_decl ) + return #it will be exposed later, using other code creators self.__dependencies_manager.add_exported( self.curr_decl ) cls_decl = self.curr_decl cls_parent_cc = self.curr_code_creator Modified: pyplusplus_dev/pyplusplus/creators_factory/types_database.py =================================================================== --- pyplusplus_dev/pyplusplus/creators_factory/types_database.py 2009-02-19 10:54:51 UTC (rev 1693) +++ pyplusplus_dev/pyplusplus/creators_factory/types_database.py 2009-02-21 12:29:41 UTC (rev 1694) @@ -20,6 +20,10 @@ self.__normalize_data = [ ',', '<', '>', '*', '&', '(', ')', '::' ] self.__containers = set() + def update_containers( self, decl ): + assert decl.indexing_suite + self.__containers.add( decl ) + def update( self, decl ): if isinstance( decl, declarations.calldef_t ): if not isinstance( decl, declarations.constructor_t ): Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2009-02-19 10:54:51 UTC (rev 1693) +++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2009-02-21 12:29:41 UTC (rev 1694) @@ -642,6 +642,8 @@ return explanation def _readme_impl( self ): + if self.indexing_suite: + return [] explanation = self.is_wrapper_needed() for fc in self.fake_constructors: if fc.ignore: Modified: pyplusplus_dev/unittests/indexing_suites2_tester.py =================================================================== --- pyplusplus_dev/unittests/indexing_suites2_tester.py 2009-02-19 10:54:51 UTC (rev 1693) +++ pyplusplus_dev/unittests/indexing_suites2_tester.py 2009-02-21 12:29:41 UTC (rev 1694) @@ -25,6 +25,7 @@ items = generator.global_ns.typedef( 'items_t' ) items = declarations.remove_declarated( items.type ) items.alias = "items_t" + items.include() strings = generator.global_ns.typedef( 'strings_t' ) strings = declarations.remove_declarated( strings.type ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-02-22 20:23:34
|
Revision: 1696 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1696&view=rev Author: roman_yakovenko Date: 2009-02-22 20:23:32 +0000 (Sun, 22 Feb 2009) Log Message: ----------- adding support for hash_map container Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp pyplusplus_dev/unittests/indexing_suites2_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py 2009-02-22 13:56:26 UTC (rev 1695) +++ pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py 2009-02-22 20:23:32 UTC (rev 1696) @@ -100,7 +100,10 @@ if self.declaration.indexing_suite.use_container_suite: answer.append( bpi + '::container_suite' ) else: - answer.append( bpi + '::' + self.declaration.name.split( '<' )[0] + '_suite' ) + container_name = self.declaration.name.split( '<' )[0] + if container_name.startswith( 'hash_' ): + container_name = container_name[len( 'hash_'):] + answer.append( bpi + '::' + container_name + '_suite' ) answer.append( '< ' ) answer.append( self.decl_identifier ) if self.does_user_disable_methods(): Modified: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py 2009-02-22 13:56:26 UTC (rev 1695) +++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py 2009-02-22 20:23:32 UTC (rev 1696) @@ -40,9 +40,10 @@ , 'map' : "indexing_suite/map.hpp" , 'multimap' : "indexing_suite/multimap.hpp" , 'hash_map' : "indexing_suite/map.hpp" + #, 'hash_multimap' : "indexing_suite/multimap.hpp" , 'set' : "indexing_suite/set.hpp" , 'hash_set' : "indexing_suite/set.hpp" - #TODO: queue, priority, stack, hash_multimap, multiset, hash_multiset + #TODO: queue, priority, stack, multiset, hash_multiset } class indexing_suite2_t( object ): Modified: pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp 2009-02-22 13:56:26 UTC (rev 1695) +++ pyplusplus_dev/unittests/data/indexing_suites2_to_be_exported.hpp 2009-02-22 20:23:32 UTC (rev 1696) @@ -6,7 +6,20 @@ #ifndef __indexing_suites2_to_be_exported_hpp__ #define __indexing_suites2_to_be_exported_hpp__ -#include <hash_map> +#if defined( __GNUC__ ) + #include <ext/hash_set> + #include <ext/hash_map> + #define HASH_XXX_NS __gnu_cxx +#else + #include <hash_set> + #include <hash_map> + #if defined( __GCCXML__ ) && !defined( __PYGCCXML_MSVC9__ ) + #define HASH_XXX_NS std + #else + #define HASH_XXX_NS stdext + #endif//GCCXML +#endif + #include <vector> #include <string> #include <map> @@ -59,10 +72,18 @@ typedef std::vector<float> fvector; fvector empty_fvector(){ return fvector(); } -stdext::hash_map< int, int > get_int_mapping(){ - return stdext::hash_map< int, int >(); +HASH_XXX_NS::hash_map< int, int > get_int_mapping(){ + HASH_XXX_NS::hash_map< int, int > x; + x[ 1 ] = 1; + return x; } +HASH_XXX_NS::hash_multimap< int, int > get_int_multimapping(){ + HASH_XXX_NS::hash_multimap< int, int > x; + x.insert( HASH_XXX_NS::hash_multimap< int, int >::value_type( 1,1) ); + return x; +} + typedef std::map< std::string, std::string > name2value_t; inline std::string get_first_name( name2value_t const * names ){ if( !names ){ Modified: pyplusplus_dev/unittests/indexing_suites2_tester.py =================================================================== --- pyplusplus_dev/unittests/indexing_suites2_tester.py 2009-02-22 13:56:26 UTC (rev 1695) +++ pyplusplus_dev/unittests/indexing_suites2_tester.py 2009-02-22 20:23:32 UTC (rev 1696) @@ -80,6 +80,14 @@ set_of_strings.add("s1") set_of_strings.add("s") + x = module.get_int_mapping() + self.failUnless( x[1] == 1 ) + try: + x = module.get_int_multimapping() + self.failUnless( x[1] == 1 ) + except TypeError: + pass + def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-05-10 20:04:19
|
Revision: 1711 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1711&view=rev Author: roman_yakovenko Date: 2009-05-10 20:04:09 +0000 (Sun, 10 May 2009) Log Message: ----------- fixing unittests Modified Paths: -------------- pyplusplus_dev/pyplusplus/creators_factory/dependencies_manager.py pyplusplus_dev/unittests/fundamental_tester_base.py pyplusplus_dev/unittests/virtual_inheritance_tester.py Modified: pyplusplus_dev/pyplusplus/creators_factory/dependencies_manager.py =================================================================== --- pyplusplus_dev/pyplusplus/creators_factory/dependencies_manager.py 2009-05-10 18:25:05 UTC (rev 1710) +++ pyplusplus_dev/pyplusplus/creators_factory/dependencies_manager.py 2009-05-10 20:04:09 UTC (rev 1711) @@ -1,203 +1,206 @@ -# Copyright 2004-2008 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -"""defines class, which informs user about used, but unexposed declarations""" - -import os -from pyplusplus import utils -from pyplusplus import messages -from pygccxml import declarations -from pyplusplus import decl_wrappers - -class duplicated_names_reporter_t(object): - def __init__( self, decls, value_getter, msg ): - self.decls = decls - self.get_value = value_getter - self.msg = msg - - def __select( self ): - duplicated = {} - for decl in self.decls: - value = self.get_value( decl ) - if not duplicated.has_key( value ): - duplicated[ value ] = set() - duplicated[ value ].add( decl ) - result = duplicated.copy() - for value, buggy_decls in duplicated.items(): - if 1 == len( buggy_decls ): - del result[ value ] - return result - - def __report_single( self, control_decl, duplicated, logger ): - value = self.get_value( control_decl ) - if value not in duplicated: - return - buggy_decls = duplicated[value].copy() - buggy_decls.remove( control_decl ) - warning = self.msg % ( value, os.linesep.join( map( str, buggy_decls ) ) ) - logger.warn( "%s;%s" % ( str( control_decl ), warning ) ) - - def report( self, logger ): - duplicated = self.__select() - for decl in self.decls: - self.__report_single( decl, duplicated, logger ) - -duplicated_aliases_reporter \ - = lambda decls: duplicated_names_reporter_t( decls, lambda d: d.alias, messages.W1047 ) - -duplicated_wrapper_aliases_reporter \ - = lambda decls: duplicated_names_reporter_t( decls, lambda d: d.wrapper_alias, messages.W1065 ) - - -class manager_t( object ): - def __init__( self, logger ): - object.__init__( self ) - self.__exported_decls = [] - self.__logger = logger - - def add_exported( self, decl ): - self.__exported_decls.append( decl ) - - def __is_std_decl( self, decl ): - #Every class under std should be exported by Boost.Python and\\or `Py++` - #Also this is not the case right now, I prefer to hide the warnings - dpath = declarations.declaration_path( decl ) - if len( dpath ) < 3: - return False - if dpath[1] != 'std': - return False - if decl.name.startswith( 'pair<' ): - #special case - return False - return True - - def __build_dependencies( self, decl ): - if self.__is_std_decl( decl ): - #TODO add element_type to the list of dependencies - return [] #std declarations should be exported by `Py++`! - if decl.already_exposed: - return [] - dependencies = decl.i_depend_on_them(recursive=False) - - if isinstance( decl, declarations.class_t ): - dependencies = filter( lambda d: d.access_type != declarations.ACCESS_TYPES.PRIVATE - , dependencies ) - - return dependencies - - def __has_unexposed_dependency( self, exported_ids, depend_on_decl, dependency ): - sptr_traits = declarations.smart_pointer_traits - - if None is depend_on_decl: - return - - if self.__is_std_decl( depend_on_decl ): - return - - if sptr_traits.is_smart_pointer( depend_on_decl ): - try: - value_type = sptr_traits.value_type( depend_on_decl ) - if isinstance( value_type, declarations.type_t ): - value_type = declarations.remove_cv( value_type ) - value_type = declarations.remove_declarated( value_type ) - if isinstance( value_type, declarations.declaration_t ): - return self.__has_unexposed_dependency( exported_ids, value_type, dependency ) - except RuntimeError: - pass - - if isinstance( depend_on_decl, decl_wrappers.decl_wrapper_t ): - if depend_on_decl.already_exposed: - return - if isinstance( depend_on_decl, declarations.class_types ): - if depend_on_decl.opaque: - return - if dependency.hint == "base class": - return #base class for some class don't have to be exported - if isinstance( depend_on_decl, declarations.variable_t ): - if not decl.expose_value: - return - - if isinstance( dependency.decl, declarations.variable_t ): - #the only dependency of the variable is its type - if not dependency.decl.expose_value: - return - - if dependency.hint == "return type": - #in this case we don't check, the return type but the function - if isinstance( dependency.decl, declarations.calldef_t ): - if dependency.decl.return_type and dependency.decl.call_policies \ - and decl_wrappers.is_return_opaque_pointer_policy( dependency.decl.call_policies ): - return - - return id( depend_on_decl ) not in exported_ids - - def __find_out_used_but_not_exported( self ): - used_not_exported = [] - exported_ids = set( map( lambda d: id( d ), self.__exported_decls ) ) - for decl in self.__exported_decls: - for dependency in self.__build_dependencies( decl ): - depend_on_decl = dependency.find_out_depend_on_declaration() - if self.__has_unexposed_dependency( exported_ids, depend_on_decl, dependency ): - if messages.filter_disabled_msgs([messages.W1040], depend_on_decl.disabled_messages ): - #need to report dependency errors - used_not_exported.append(dependency) - return used_not_exported - - def __group_by_unexposed( self, dependencies ): - groups = {} - for dependency in dependencies: - depend_on_decl = dependency.find_out_depend_on_declaration() - if not groups.has_key( id( depend_on_decl ) ): - groups[ id( depend_on_decl ) ] = [] - groups[ id( depend_on_decl ) ].append( dependency ) - return groups - - def __create_dependencies_msg( self, dependencies ): - depend_on_decl = dependencies[0].find_out_depend_on_declaration() - decls = [] - for dependency in dependencies: - decls.append( os.linesep + ' ' + str( dependency.declaration ) ) - return "%s;%s" % ( depend_on_decl, messages.W1040 % ''.join( decls ) ) - - def __report_duplicated_aliases( self ): - decls = filter( lambda decl: isinstance( decl, declarations.class_types ) \ - and isinstance( decl.parent, declarations.namespace_t ) - , self.__exported_decls ) - - dar = duplicated_aliases_reporter( decls ) - dar.report( self.__logger ) - - classes = filter( lambda c: isinstance( c, declarations.class_t ), decls ) - query = lambda decl: isinstance( decl, declarations.class_types ) \ - and decl.ignore == False \ - and decl._already_exposed == False - - for cls in classes: - internal_decls = cls.decls( query, recursive=False, allow_empty=True) - dar = duplicated_aliases_reporter( internal_decls ) - dar.report( self.__logger ) - - def __report_duplicated_wrapper_aliases( self ): - decls = filter( lambda decl: isinstance( decl, declarations.class_t ) \ - and isinstance( decl.parent, declarations.namespace_t ) - , self.__exported_decls ) - - dwar = duplicated_wrapper_aliases_reporter( decls ) - dwar.report( self.__logger ) - - query = lambda decl: decl.ignore == False and decl._already_exposed == False - - for cls in decls: - internal_decls = cls.classes( query, recursive=False, allow_empty=True) - dwar = duplicated_wrapper_aliases_reporter( internal_decls ) - dwar.report( self.__logger ) - - def inform_user( self ): - used_not_exported_decls = self.__find_out_used_but_not_exported() - groups = self.__group_by_unexposed( used_not_exported_decls ) - for group in groups.itervalues(): - self.__logger.warn( self.__create_dependencies_msg( group ) ) - self.__report_duplicated_aliases() - self.__report_duplicated_wrapper_aliases() +# Copyright 2004-2008 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +"""defines class, which informs user about used, but unexposed declarations""" + +import os +from pyplusplus import utils +from pyplusplus import messages +from pygccxml import declarations +from pyplusplus import decl_wrappers + +class duplicated_names_reporter_t(object): + def __init__( self, decls, value_getter, msg ): + self.decls = decls + self.get_value = value_getter + self.msg = msg + + def __select( self ): + duplicated = {} + for decl in self.decls: + value = self.get_value( decl ) + if not duplicated.has_key( value ): + duplicated[ value ] = set() + duplicated[ value ].add( decl ) + result = duplicated.copy() + for value, buggy_decls in duplicated.items(): + if 1 == len( buggy_decls ): + del result[ value ] + return result + + def __report_single( self, control_decl, duplicated, logger ): + value = self.get_value( control_decl ) + if value not in duplicated: + return + buggy_decls = duplicated[value].copy() + buggy_decls.remove( control_decl ) + warning = self.msg % ( value, os.linesep.join( map( str, buggy_decls ) ) ) + logger.warn( "%s;%s" % ( str( control_decl ), warning ) ) + + def report( self, logger ): + duplicated = self.__select() + for decl in self.decls: + self.__report_single( decl, duplicated, logger ) + +duplicated_aliases_reporter \ + = lambda decls: duplicated_names_reporter_t( decls, lambda d: d.alias, messages.W1047 ) + +duplicated_wrapper_aliases_reporter \ + = lambda decls: duplicated_names_reporter_t( decls, lambda d: d.wrapper_alias, messages.W1065 ) + + +class manager_t( object ): + def __init__( self, logger ): + object.__init__( self ) + self.__exported_decls = [] + self.__logger = logger + + def add_exported( self, decl ): + self.__exported_decls.append( decl ) + if isinstance( decl, declarations.class_t ) and decl.indexing_suite: + included_decls = decl.decls( lambda d: d.ignore==False, allow_empty=True, recursive=True ) + map( self.add_exported, included_decls ) + + def __is_std_decl( self, decl ): + #Every class under std should be exported by Boost.Python and\\or `Py++` + #Also this is not the case right now, I prefer to hide the warnings + dpath = declarations.declaration_path( decl ) + if len( dpath ) < 3: + return False + if dpath[1] != 'std': + return False + if decl.name.startswith( 'pair<' ): + #special case + return False + return True + + def __build_dependencies( self, decl ): + if self.__is_std_decl( decl ): + #TODO add element_type to the list of dependencies + return [] #std declarations should be exported by `Py++`! + if decl.already_exposed: + return [] + dependencies = decl.i_depend_on_them(recursive=False) + + if isinstance( decl, declarations.class_t ): + dependencies = filter( lambda d: d.access_type != declarations.ACCESS_TYPES.PRIVATE + , dependencies ) + + return dependencies + + def __has_unexposed_dependency( self, exported_ids, depend_on_decl, dependency ): + sptr_traits = declarations.smart_pointer_traits + + if None is depend_on_decl: + return + + if self.__is_std_decl( depend_on_decl ): + return + + if sptr_traits.is_smart_pointer( depend_on_decl ): + try: + value_type = sptr_traits.value_type( depend_on_decl ) + if isinstance( value_type, declarations.type_t ): + value_type = declarations.remove_cv( value_type ) + value_type = declarations.remove_declarated( value_type ) + if isinstance( value_type, declarations.declaration_t ): + return self.__has_unexposed_dependency( exported_ids, value_type, dependency ) + except RuntimeError: + pass + + if isinstance( depend_on_decl, decl_wrappers.decl_wrapper_t ): + if depend_on_decl.already_exposed: + return + if isinstance( depend_on_decl, declarations.class_types ): + if depend_on_decl.opaque: + return + if dependency.hint == "base class": + return #base class for some class don't have to be exported + if isinstance( depend_on_decl, declarations.variable_t ): + if not decl.expose_value: + return + + if isinstance( dependency.decl, declarations.variable_t ): + #the only dependency of the variable is its type + if not dependency.decl.expose_value: + return + + if dependency.hint == "return type": + #in this case we don't check, the return type but the function + if isinstance( dependency.decl, declarations.calldef_t ): + if dependency.decl.return_type and dependency.decl.call_policies \ + and decl_wrappers.is_return_opaque_pointer_policy( dependency.decl.call_policies ): + return + + return id( depend_on_decl ) not in exported_ids + + def __find_out_used_but_not_exported( self ): + used_not_exported = [] + exported_ids = set( map( lambda d: id( d ), self.__exported_decls ) ) + for decl in self.__exported_decls: + for dependency in self.__build_dependencies( decl ): + depend_on_decl = dependency.find_out_depend_on_declaration() + if self.__has_unexposed_dependency( exported_ids, depend_on_decl, dependency ): + if messages.filter_disabled_msgs([messages.W1040], depend_on_decl.disabled_messages ): + #need to report dependency errors + used_not_exported.append(dependency) + return used_not_exported + + def __group_by_unexposed( self, dependencies ): + groups = {} + for dependency in dependencies: + depend_on_decl = dependency.find_out_depend_on_declaration() + if not groups.has_key( id( depend_on_decl ) ): + groups[ id( depend_on_decl ) ] = [] + groups[ id( depend_on_decl ) ].append( dependency ) + return groups + + def __create_dependencies_msg( self, dependencies ): + depend_on_decl = dependencies[0].find_out_depend_on_declaration() + decls = [] + for dependency in dependencies: + decls.append( os.linesep + ' ' + str( dependency.declaration ) ) + return "%s;%s" % ( depend_on_decl, messages.W1040 % ''.join( decls ) ) + + def __report_duplicated_aliases( self ): + decls = filter( lambda decl: isinstance( decl, declarations.class_types ) \ + and isinstance( decl.parent, declarations.namespace_t ) + , self.__exported_decls ) + + dar = duplicated_aliases_reporter( decls ) + dar.report( self.__logger ) + + classes = filter( lambda c: isinstance( c, declarations.class_t ), decls ) + query = lambda decl: isinstance( decl, declarations.class_types ) \ + and decl.ignore == False \ + and decl._already_exposed == False + + for cls in classes: + internal_decls = cls.decls( query, recursive=False, allow_empty=True) + dar = duplicated_aliases_reporter( internal_decls ) + dar.report( self.__logger ) + + def __report_duplicated_wrapper_aliases( self ): + decls = filter( lambda decl: isinstance( decl, declarations.class_t ) \ + and isinstance( decl.parent, declarations.namespace_t ) + , self.__exported_decls ) + + dwar = duplicated_wrapper_aliases_reporter( decls ) + dwar.report( self.__logger ) + + query = lambda decl: decl.ignore == False and decl._already_exposed == False + + for cls in decls: + internal_decls = cls.classes( query, recursive=False, allow_empty=True) + dwar = duplicated_wrapper_aliases_reporter( internal_decls ) + dwar.report( self.__logger ) + + def inform_user( self ): + used_not_exported_decls = self.__find_out_used_but_not_exported() + groups = self.__group_by_unexposed( used_not_exported_decls ) + for group in groups.itervalues(): + self.__logger.warn( self.__create_dependencies_msg( group ) ) + self.__report_duplicated_aliases() + self.__report_duplicated_wrapper_aliases() Modified: pyplusplus_dev/unittests/fundamental_tester_base.py =================================================================== --- pyplusplus_dev/unittests/fundamental_tester_base.py 2009-05-10 18:25:05 UTC (rev 1710) +++ pyplusplus_dev/unittests/fundamental_tester_base.py 2009-05-10 20:04:09 UTC (rev 1711) @@ -1,158 +1,156 @@ -# Copyright 2004-2008 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import os -import sys -import unittest -import autoconfig -import pygccxml -from pygccxml import parser -from pyplusplus import utils -from pygccxml import declarations -from pyplusplus import module_builder - -LICENSE = """// Copyright 2004-2008 Roman Yakovenko. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt)""" - -class fundamental_tester_base_t( unittest.TestCase ): - SUFFIX_TO_BE_EXPORTED = '_to_be_exported.hpp' - - def __init__(self, module_name, *args, **keywd ): - unittest.TestCase.__init__(self, *args) - self.__module_name = module_name - self.__to_be_exported_header \ - = os.path.join( autoconfig.data_directory - , self.__module_name + self.SUFFIX_TO_BE_EXPORTED ) - - self.__generated_source_file_name = os.path.join( autoconfig.build_dir - , self.__module_name + '.cpp' ) - self.__generated_scons_file_name = os.path.join( autoconfig.build_dir - , self.__module_name + '.scons' ) - - self.__indexing_suite_version = keywd.get( 'indexing_suite_version', 1 ) - - def failIfRaisesAny(self, callableObj, *args, **kwargs): - try: - callableObj(*args, **kwargs) - except Exception, error: - self.fail( 'exception has been raised during execution. exception: ' + str(error) ) - - def failIfNotRaisesAny(self, callableObj, *args, **kwargs): - was_exception = False - try: - callableObj(*args, **kwargs) - except: - was_exception = True - self.failUnless(was_exception, 'exception has not been raised during execution.') - - def __test_already_exposed( self, mb ): - exposed_db = utils.exposed_decls_db_t() - exposed_db.load( autoconfig.build_dir ) - irrelevant_decl_types = ( declarations.typedef_t - , declarations.namespace_t - , declarations.free_operator_t ) - specially_exposed_decls = mb.code_creator.specially_exposed_decls - for d in mb.decls(): - if not d.exportable: - continue - elif isinstance( d, declarations.free_operator_t ): - continue - elif d.ignore: - if d in specially_exposed_decls: - continue - if exposed_db.is_exposed( d ): - i = 0 - self.failUnless( not exposed_db.is_exposed( d ) - , '''Declaration "%s" is NOT exposed, but for some reason it is marked as such.''' - % str( d ) ) - #if d.ignore or not d.exportable or isinstance( d, irrelevant_decl_types ): - #continue - #if d.parent and not d.parent.name: - #continue #unnamed classes - else: - self.failUnless( exposed_db.is_exposed( d ) - , '''Declaration "%s" is exposed, but for some reason it isn't marked as such.''' - % str( d ) ) - - def customize(self, generator): - pass - - def get_source_files( self ): - sources = [ self.__generated_source_file_name ] - to_be_exported_cpp = os.path.splitext( self.__to_be_exported_header )[0] + '.cpp' - if os.path.exists( to_be_exported_cpp ): - sources.append( to_be_exported_cpp ) - return sources - - def generate_source_files( self, mb ): - mb.write_module( self.__generated_source_file_name ) - - def run_tests(self, module): - raise NotImplementedError() - - def _create_extension_source_file(self): - global LICENSE - - mb = module_builder.module_builder_t( [self.__to_be_exported_header] - , gccxml_path=autoconfig.gccxml.executable - , include_paths=[autoconfig.boost.include] - , undefine_symbols=['__MINGW32__'] - , indexing_suite_version=self.__indexing_suite_version - , compiler=autoconfig.cxx_parsers_cfg.gccxml.compiler) - for decl in mb.decls(): - decl.documentation = '"documentation"' - self.customize( mb ) - doc_extractor = lambda decl: decl.documentation - if not mb.has_code_creator(): - mb.build_code_creator( self.__module_name, doc_extractor=doc_extractor ) - mb.code_creator.std_directories.extend( autoconfig.scons_config.cpppath ) - mb.code_creator.user_defined_directories.append( autoconfig.data_directory ) - mb.code_creator.precompiled_header = "boost/python.hpp" - mb.code_creator.license = LICENSE - self.generate_source_files( mb ) - self.__test_already_exposed( mb ) - - def _create_sconstruct(self, sources ): - sources_str = [] - for source in sources: - sources_str.append( "r'%s'" % source ) - sources_str = ','.join( sources_str ) - sconstruct_script = autoconfig.scons_config.create_sconstruct()\ - % { 'target' : self.__module_name - , 'sources' : sources_str } - sconstruct_file = file( self.__generated_scons_file_name, 'w+b' ) - sconstruct_file.write( sconstruct_script ) - sconstruct_file.close() - - def _clean_build( self, sconstruct_file ): - cmd = autoconfig.scons.cmd_clean % sconstruct_file - output = os.popen( cmd ) - scons_reports = [] - while True: - data = output.readline() - scons_reports.append( data ) - if not data: - break - exit_status = output.close() - scons_msg = ''.join(scons_reports) - if exit_status: - raise RuntimeError( "unable to clean extension. error: %s" % scons_msg ) - - def test(self): - pypp = None - try: - self._create_extension_source_file() - sources = self.get_source_files() - self._create_sconstruct(sources) - autoconfig.scons_config.compile( autoconfig.scons.cmd_build + ' --file=%s' % self.__generated_scons_file_name ) - pypp = __import__( self.__module_name ) - self.run_tests(pypp) - finally: - if sys.modules.has_key( self.__module_name ): - del sys.modules[self.__module_name] - del pypp - #self._clean_build(self.__generated_scons_file_name) +# Copyright 2004-2008 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os +import sys +import unittest +import autoconfig +import pygccxml +from pygccxml import parser +from pyplusplus import utils +from pygccxml import declarations +from pyplusplus import module_builder + +LICENSE = """// Copyright 2004-2008 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt)""" + +class fundamental_tester_base_t( unittest.TestCase ): + SUFFIX_TO_BE_EXPORTED = '_to_be_exported.hpp' + + def __init__(self, module_name, *args, **keywd ): + unittest.TestCase.__init__(self, *args) + self.__module_name = module_name + self.__to_be_exported_header \ + = os.path.join( autoconfig.data_directory + , self.__module_name + self.SUFFIX_TO_BE_EXPORTED ) + + self.__generated_source_file_name = os.path.join( autoconfig.build_dir + , self.__module_name + '.cpp' ) + self.__generated_scons_file_name = os.path.join( autoconfig.build_dir + , self.__module_name + '.scons' ) + + self.__indexing_suite_version = keywd.get( 'indexing_suite_version', 1 ) + + def failIfRaisesAny(self, callableObj, *args, **kwargs): + try: + callableObj(*args, **kwargs) + except Exception, error: + self.fail( 'exception has been raised during execution. exception: ' + str(error) ) + + def failIfNotRaisesAny(self, callableObj, *args, **kwargs): + was_exception = False + try: + callableObj(*args, **kwargs) + except: + was_exception = True + self.failUnless(was_exception, 'exception has not been raised during execution.') + + def __test_already_exposed( self, mb ): + exposed_db = utils.exposed_decls_db_t() + exposed_db.load( autoconfig.build_dir ) + irrelevant_decl_types = ( declarations.typedef_t + , declarations.namespace_t + , declarations.free_operator_t ) + specially_exposed_decls = mb.code_creator.specially_exposed_decls + for d in mb.decls(): + if not d.exportable: + continue + elif isinstance( d, declarations.free_operator_t ): + continue + elif d.ignore: + if d in specially_exposed_decls: + continue + if exposed_db.is_exposed( d ): + i = 0 + self.failUnless( not exposed_db.is_exposed( d ) + , '''Declaration "%s" is NOT exposed, but for some reason it is marked as such.''' + % str( d ) ) + elif d.parent \ + and isinstance( d.parent, declarations.class_t ) \ + and d.parent.indexing_suite: + continue + else: + self.failUnless( exposed_db.is_exposed( d ) + , '''Declaration "%s" is exposed, but for some reason it isn't marked as such.''' + % str( d ) ) + + def customize(self, generator): + pass + + def get_source_files( self ): + sources = [ self.__generated_source_file_name ] + to_be_exported_cpp = os.path.splitext( self.__to_be_exported_header )[0] + '.cpp' + if os.path.exists( to_be_exported_cpp ): + sources.append( to_be_exported_cpp ) + return sources + + def generate_source_files( self, mb ): + mb.write_module( self.__generated_source_file_name ) + + def run_tests(self, module): + raise NotImplementedError() + + def _create_extension_source_file(self): + global LICENSE + + mb = module_builder.module_builder_t( [self.__to_be_exported_header] + #, undefine_symbols=['__MINGW32__'] + , indexing_suite_version=self.__indexing_suite_version + , gccxml_config=autoconfig.cxx_parsers_cfg.gccxml) + for decl in mb.decls(): + decl.documentation = '"documentation"' + self.customize( mb ) + doc_extractor = lambda decl: decl.documentation + if not mb.has_code_creator(): + mb.build_code_creator( self.__module_name, doc_extractor=doc_extractor ) + mb.code_creator.std_directories.extend( autoconfig.scons_config.cpppath ) + mb.code_creator.user_defined_directories.append( autoconfig.data_directory ) + mb.code_creator.precompiled_header = "boost/python.hpp" + mb.code_creator.license = LICENSE + self.generate_source_files( mb ) + self.__test_already_exposed( mb ) + + def _create_sconstruct(self, sources ): + sources_str = [] + for source in sources: + sources_str.append( "r'%s'" % source ) + sources_str = ','.join( sources_str ) + sconstruct_script = autoconfig.scons_config.create_sconstruct()\ + % { 'target' : self.__module_name + , 'sources' : sources_str } + sconstruct_file = file( self.__generated_scons_file_name, 'w+b' ) + sconstruct_file.write( sconstruct_script ) + sconstruct_file.close() + + def _clean_build( self, sconstruct_file ): + cmd = autoconfig.scons.cmd_clean % sconstruct_file + output = os.popen( cmd ) + scons_reports = [] + while True: + data = output.readline() + scons_reports.append( data ) + if not data: + break + exit_status = output.close() + scons_msg = ''.join(scons_reports) + if exit_status: + raise RuntimeError( "unable to clean extension. error: %s" % scons_msg ) + + def test(self): + pypp = None + try: + self._create_extension_source_file() + sources = self.get_source_files() + self._create_sconstruct(sources) + autoconfig.scons_config.compile( autoconfig.scons.cmd_build + ' --file=%s' % self.__generated_scons_file_name ) + pypp = __import__( self.__module_name ) + self.run_tests(pypp) + finally: + if sys.modules.has_key( self.__module_name ): + del sys.modules[self.__module_name] + del pypp + #self._clean_build(self.__generated_scons_file_name) Modified: pyplusplus_dev/unittests/virtual_inheritance_tester.py =================================================================== --- pyplusplus_dev/unittests/virtual_inheritance_tester.py 2009-05-10 18:25:05 UTC (rev 1710) +++ pyplusplus_dev/unittests/virtual_inheritance_tester.py 2009-05-10 20:04:09 UTC (rev 1711) @@ -1,35 +1,38 @@ -# Copyright 2004-2008 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import os -import sys -import unittest -import fundamental_tester_base - -class tester_t(fundamental_tester_base.fundamental_tester_base_t): - EXTENSION_NAME = 'virtual_inheritance' - - def __init__( self, *args ): - fundamental_tester_base.fundamental_tester_base_t.__init__( - self - , tester_t.EXTENSION_NAME - , *args ) - - def customize( self, mb ): - mb.classes().always_expose_using_scope = True - - def run_tests( self, module): - pass - -def create_suite(): - suite = unittest.TestSuite() - suite.addTest( unittest.makeSuite(tester_t)) - return suite - -def run_suite(): - unittest.TextTestRunner(verbosity=2).run( create_suite() ) - -if __name__ == "__main__": - run_suite() +# Copyright 2004-2008 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os +import sys +import unittest +import fundamental_tester_base + +EXPECTED_TO_FAIL = True +EXPECTED_TO_FAIL_INFO = "Boost.Python doesn't support virtual inheritance" + +class tester_t(fundamental_tester_base.fundamental_tester_base_t): + EXTENSION_NAME = 'virtual_inheritance' + + def __init__( self, *args ): + fundamental_tester_base.fundamental_tester_base_t.__init__( + self + , tester_t.EXTENSION_NAME + , *args ) + + def customize( self, mb ): + mb.classes().always_expose_using_scope = True + + def run_tests( self, module): + pass + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-05-11 07:44:56
|
Revision: 1713 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1713&view=rev Author: roman_yakovenko Date: 2009-05-11 07:44:51 +0000 (Mon, 11 May 2009) Log Message: ----------- update docs Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/matchers.py pyplusplus_dev/pyplusplus/function_transformers/function_transformation.py pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py pyplusplus_dev/unittests/ctypes_tester.py pyplusplus_dev/unittests/custom_smart_ptr_classes_tester.py pyplusplus_dev/unittests/test_all.py pyplusplus_dev/unittests/virtual_inheritance_tester.py Modified: pygccxml_dev/pygccxml/declarations/matchers.py =================================================================== --- pygccxml_dev/pygccxml/declarations/matchers.py 2009-05-11 07:27:29 UTC (rev 1712) +++ pygccxml_dev/pygccxml/declarations/matchers.py 2009-05-11 07:44:51 UTC (rev 1713) @@ -1,542 +1,545 @@ -# Copyright 2004-2008 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -""" -defines all "built-in" classes that implement declarations compare functionality -according to some criteria -""" - -import os -import re -import types -import algorithm -import variable -import namespace -import calldef -import cpptypes -import templates -import class_declaration -from pygccxml import utils - -class matcher_base_t(object): - """matcher_base_t class defines interface for classes that will implement - compare functionality according to some criteria. - """ - def __init__( self ): - object.__init__( self ) - - def __call__(self, decl): - raise NotImplementedError( "matcher must always implement the __call__() method." ) - - def __invert__(self): - """not-operator (~)""" - return not_matcher_t(self) - - def __and__(self, other): - """and-operator (&)""" - return and_matcher_t([self, other]) - - def __or__(self, other): - """or-operator (|)""" - return or_matcher_t([self, other]) - - def __str__( self ): - return "base class for all matchers" - -class and_matcher_t(matcher_base_t): - """ - Combine several other matchers with "&" (and) operator. - - For example: find all private functions with name XXX - - .. code-block:: python - - matcher = access_type_matcher_t( 'private' ) & calldef_matcher_t( name='XXX' ) - """ - def __init__(self, matchers): - matcher_base_t.__init__(self) - self.matchers = matchers - - def __call__(self, decl): - for matcher in self.matchers: - if not matcher(decl): - return False - return True - - def __str__(self): - return " & ".join( map( lambda x: "(%s)" % str( x ), self.matchers ) ) - - -class or_matcher_t(matcher_base_t): - """Combine several other matchers with "|" (or) operator. - - For example: find all functions and variables with name 'XXX' - - .. code-block:: python - - matcher = variable_matcher_t( name='XXX' ) | calldef_matcher_t( name='XXX' ) - - """ - def __init__(self, matchers): - matcher_base_t.__init__(self) - self.matchers = matchers - - def __call__(self, decl): - for matcher in self.matchers: - if matcher(decl): - return True - return False - - def __str__(self): - return " | ".join( map( lambda x: "(%s)" % str( x ), self.matchers ) ) - - -class not_matcher_t(matcher_base_t): - """ - return the inverse result of a matcher - - For example: find all public and protected declarations - - .. code-block:: python - - matcher = ~access_type_matcher_t( 'private' ) - """ - def __init__(self, matcher): - matcher_base_t.__init__(self) - self.matcher = matcher - - def __call__(self, decl): - return not self.matcher(decl) - - def __str__(self): - return "~(%s)"%str(self.matcher) - -class declaration_matcher_t( matcher_base_t ): - """ - Instance of this class will match declarations by next criteria: - - declaration name, also could be fully qualified name - Example: `wstring` or `::std::wstring` - - declaration type - Example: :class:`class_t`, :class:`namespace_t`, :class:`enumeration_t` - - location within file system ( file or directory ) - """ - def __init__( self, name=None, decl_type=None, header_dir=None, header_file=None ): - """ - :param decl_type: declaration type to match by. For example :class:`enumeration_t`. - :type decl_type: any class that derives from :class:`declaration_t` class - - :param name: declaration name, could be full name. - :type name: str - - :param header_dir: absolute directory path - :type header_dir: str - - :param header_file: absolute file path - :type header_file: str - - """ - #An other option is that pygccxml will create absolute path using - #os.path.abspath function. But I think this is just wrong, because abspath - #builds path using current working directory. This behavior is fragile - #and very difficult to find a bug. - matcher_base_t.__init__( self ) - self.decl_type = decl_type - self.__name = None - self.__opt_is_tmpl_inst = None - self.__opt_tmpl_name = None - self.__opt_is_full_name = None - self.__decl_name_only = None - - self._set_name( name ) - - self.header_dir = header_dir - self.header_file = header_file - - if self.header_dir: - self.header_dir = utils.normalize_path( self.header_dir ) - if not os.path.isabs( self.header_dir ): - raise RuntimeError( "Path to header directory should be absolute!" ) - - if self.header_file: - self.header_file = utils.normalize_path( self.header_file ) - if not os.path.isabs( self.header_file ): - raise RuntimeError( "Path to header file should be absolute!" ) - - def _get_name(self): - return self.__name - - def _set_name( self, name ): - self.__name = name - if not self.__name: - self.__opt_is_tmpl_inst = None - self.__opt_tmpl_name = None - self.__opt_is_full_name = None - self.__decl_name_only = None - else: - self.__opt_is_tmpl_inst = templates.is_instantiation( self.__name ) - self.__opt_tmpl_name = templates.name( self.__name ) - if self.__opt_is_tmpl_inst: - if '::' in self.__opt_tmpl_name: - self.__opt_is_full_name = True - self.__decl_name_only = self.__opt_tmpl_name.split('::')[-1] - else: - self.__opt_is_full_name = False - self.__decl_name_only = self.__opt_tmpl_name - self.__name = templates.normalize( name ) - else: - if '::' in self.__name: - self.__opt_is_full_name = True - self.__decl_name_only = self.__name.split('::')[-1] - else: - self.__opt_is_full_name = False - self.__decl_name_only = self.__name - - - name = property( _get_name, _set_name ) - - def __str__( self ): - msg = [] - if not None is self.decl_type: - msg.append( '(decl type==%s)' % self.decl_type.__name__ ) - if not None is self.name: - msg.append( '(name==%s)' % self.name ) - if not None is self.header_dir: - msg.append( '(header dir==%s)' % self.header_dir ) - if not None is self.header_file: - msg.append( '(header file==%s)' % self.header_file ) - if not msg: - msg.append( 'any' ) - return ' and '.join( msg ) - - def __call__( self, decl ): - if not None is self.decl_type: - if not isinstance( decl, self.decl_type ): - return False - if not None is self.name: - if not self.check_name( decl ): - return False - if not None is self.header_dir: - if decl.location: - decl_dir = os.path.abspath( os.path.dirname( decl.location.file_name ) ) - decl_dir = utils.normalize_path( decl_dir ) - if decl_dir[:len(self.header_dir)] != self.header_dir: - return False - else: - return False - if not None is self.header_file: - if decl.location: - decl_file = os.path.abspath( decl.location.file_name ) - decl_file = utils.normalize_path( decl_file ) - if decl_file != self.header_file: - return False - else: - return False - return True - - def check_name( self, decl ): - assert not None is self.name - if self.__opt_is_tmpl_inst: - if not self.__opt_is_full_name: - if self.name != templates.normalize( decl.name ) \ - and self.name != templates.normalize( decl.partial_name ): - return False - else: - if self.name != templates.normalize( algorithm.full_name( decl, with_defaults=True ) ) \ - and self.name != templates.normalize( algorithm.full_name( decl, with_defaults=False ) ): - return False - else: - if not self.__opt_is_full_name: - if self.name != decl.name and self.name != decl.partial_name: - return False - else: - if self.name != algorithm.full_name( decl, with_defaults=True ) \ - and self.name != algorithm.full_name( decl, with_defaults=False ): - return False - return True - - def is_full_name(self): - return self.__opt_is_full_name - - def _get_decl_name_only(self): - return self.__decl_name_only - decl_name_only = property( _get_decl_name_only ) - -class variable_matcher_t( declaration_matcher_t ): - """ - Instance of this class will match variables by next criteria: - - :class:`declaration_matcher_t` criteria - - variable type. Example: :class:`int_t` or 'int' - """ - def __init__( self, name=None, type=None, header_dir=None, header_file=None ): - """ - :param type: variable type - :type type: string or instance of :class:`type_t` derived class - """ - declaration_matcher_t.__init__( self - , name=name - , decl_type=variable.variable_t - , header_dir=header_dir - , header_file=header_file ) - self.type = type - - def __call__( self, decl ): - if not super( variable_matcher_t, self ).__call__( decl ): - return False - if not None is self.type: - if isinstance( self.type, cpptypes.type_t ): - if self.type != decl.type: - return False - else: - if self.type != decl.type.decl_string: - return False - return True - - def __str__( self ): - msg = [ super( variable_matcher_t, self ).__str__() ] - if msg == [ 'any' ]: - msg = [] - if not None is self.type: - msg.append( '(value type==%s)' % str(self.type) ) - if not msg: - msg.append( 'any' ) - return ' and '.join( msg ) - - -class namespace_matcher_t( declaration_matcher_t ): - """Instance of this class will match namespaces by name.""" - - def __init__( self, name=None ): - declaration_matcher_t.__init__( self, name=name, decl_type=namespace.namespace_t) - - def __call__( self, decl ): - if self.name and decl.name == '': - #unnamed namespace have same name as thier parent, we should prevent - #this happens. The price is: user should search for unnamed namespace - #directly. - return False - return super( namespace_matcher_t, self ).__call__( decl ) - - -class calldef_matcher_t( declaration_matcher_t ): - """ - Instance of this class will match callable by the following criteria: - * :class:`declaration_matcher_t` criteria - * return type. For example: :class:`int_t` or 'int' - * argument types - """ - - def __init__( self, name=None, return_type=None, arg_types=None, decl_type=None, header_dir=None, header_file=None): - """ - :param return_type: callable return type - :type return_type: string or instance of :class:`type_t` derived class - - :param arg_types: list of function argument types. `arg_types` can contain. - Any item within the list could be string or instance of :class:`type_t` derived - class. If you don't want some argument to participate in match you can - put None. For example: - - .. code-block:: python - - calldef_matcher_t( arg_types=[ 'int &', None ] ) - - will match all functions that takes 2 arguments, where the first one is - reference to integer and second any - - :type arg_types: list - """ - if None is decl_type: - decl_type = calldef.calldef_t - declaration_matcher_t.__init__( self - , name=name - , decl_type=decl_type - , header_dir=header_dir - , header_file=header_file ) - - self.return_type = return_type - self.arg_types = arg_types - - def __call__( self, decl ): - if not super( calldef_matcher_t, self ).__call__( decl ): - return False - if not None is self.return_type \ - and not self.__compare_types( self.return_type, decl.return_type ): - return False - if self.arg_types: - if isinstance( self.arg_types, (types.ListType, types.TupleType)): - if len(self.arg_types) != len( decl.arguments ): - return False - for type_or_str, arg in zip( self.arg_types, decl.arguments ): - if None == type_or_str: - continue - else: - if not self.__compare_types( type_or_str, arg.type ): - return False - return True - - def __compare_types( self, type_or_str, type ): - assert type_or_str - if type is None: - return False - if isinstance( type_or_str, cpptypes.type_t ): - if type_or_str != type: - return False - else: - if type_or_str != type.decl_string: - return False - return True - - def __str__( self ): - msg = [ super( calldef_matcher_t, self ).__str__() ] - if msg == [ 'any' ]: - msg = [] - if not None is self.return_type: - msg.append( '(return type==%s)' % str(self.return_type) ) - if self.arg_types: - for i in range( len( self.arg_types ) ): - if self.arg_types[i] is None: - msg.append( '(arg %d type==any)' % i ) - else: - msg.append( '(arg %d type==%s)' % ( i, str( self.arg_types[i] ) ) ) - if not msg: - msg.append( 'any' ) - return ' and '.join( msg ) - - -class operator_matcher_t( calldef_matcher_t ): - """ - Instance of this class will match operators by next criteria: - * :class:`calldef_matcher_t` criteria - * operator symbol: =, !=, (), [] and etc - """ - def __init__( self, name=None, symbol=None, return_type=None, arg_types=None, decl_type=None, header_dir=None, header_file=None): - """ - :param symbol: operator symbol - :type symbol: str - """ - if None is decl_type: - decl_type = calldef.operator_t - calldef_matcher_t.__init__( self - , name=name - , return_type=return_type - , arg_types=arg_types - , decl_type=decl_type - , header_dir=header_dir - , header_file=header_file) - self.symbol = symbol - - def __call__( self, decl ): - if not super( operator_matcher_t, self ).__call__( decl ): - return False - if not None is self.symbol: - if self.symbol != decl.symbol: - return False - return True - - def __str__( self ): - msg = [ super( operator_matcher_t, self ).__str__() ] - if msg == [ 'any' ]: - msg = [] - if not None is self.symbol: - msg.append( '(symbol==%s)' % str(self.symbol) ) - if not msg: - msg.append( 'any' ) - return ' and '.join( msg ) - -class regex_matcher_t( matcher_base_t ): - """ - Instance of this class will match declaration using regular expression. - User should supply a function that will extract from declaration desired - information as string. Later, this matcher will match that string using - user regular expression. - """ - def __init__( self, regex, function=None ): - """ - :param regex: regular expression - :type regex: string, an instance of this class will compile it for you - - :param function: function that will be called to get an information from - declaration as string. As input this function takes 1 argument: reference - to declaration. Return value should be string. If function is None, then - the matcher will use declaration name. - - """ - matcher_base_t.__init__(self) - self.regex = re.compile( regex ) - self.function = function - if None is self.function: - self.function = lambda decl: decl.name - - def __call__( self, decl ): - text = self.function( decl ) - return bool( self.regex.match( text ) ) - - def __str__( self ): - return '(regex=%s)' % self.regex - -class access_type_matcher_t( matcher_base_t ): - """ - Instance of this class will match declaration by its access type: public, - private or protected. If declarations does not have access type, for example - free function, then `False` will be returned. - """ - - def __init__( self, access_type ): - """ - :param access_type: declaration access type, could be "public", "private", "protected" - :type access_type: :class: `str` - """ - matcher_base_t.__init__( self ) - self.access_type = access_type - - def __call__( self, decl ): - if not isinstance( decl.parent, class_declaration.class_t ): - return False - return self.access_type == decl.parent.find_out_member_access_type( decl ) - - def __str__( self ): - return '(access type=%s)' % self.access_type - -class virtuality_type_matcher_t( matcher_base_t ): - """ - Instance of this class will match declaration by its virtual type: not virtual, - virtual or pure virtual. If declarations does not have "virtual" property, - for example free function, then `False` will be returned. - """ - - def __init__( self, virtuality_type ): - """ - :param access_type: declaration access type - :type access_type: :class:VIRTUALITY_TYPES defines few constants for your convenience. - """ - matcher_base_t.__init__( self ) - self.virtuality_type = virtuality_type - - def __call__( self, decl ): - if not isinstance( decl.parent, class_declaration.class_t ): - return False - return self.virtuality_type == decl.virtuality - - def __str__( self ): - return '(virtuality type=%s)' % self.virtuality_type - - -class custom_matcher_t( matcher_base_t ): - """ - Instance of this class will match declaration by user custom criteria. - """ - - def __init__( self, function ): - """ - :param function: callable, that takes single argument - declaration instance - should return True or False - """ - matcher_base_t.__init__( self ) - self.function = function - - def __call__( self, decl ): - return bool( self.function( decl ) ) - - def __str__( self ): - return '(user criteria)' +# Copyright 2004-2008 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +""" +defines all "built-in" classes that implement declarations compare functionality +according to some criteria +""" + +import os +import re +import types +import algorithm +import variable +import namespace +import calldef +import cpptypes +import templates +import class_declaration +from pygccxml import utils + +class matcher_base_t(object): + """matcher_base_t class defines interface for classes that will implement + compare functionality according to some criteria. + """ + def __init__( self ): + object.__init__( self ) + + def __call__(self, decl): + raise NotImplementedError( "matcher must always implement the __call__() method." ) + + def __invert__(self): + """not-operator (~)""" + return not_matcher_t(self) + + def __and__(self, other): + """and-operator (&)""" + return and_matcher_t([self, other]) + + def __or__(self, other): + """or-operator (|)""" + return or_matcher_t([self, other]) + + def __str__( self ): + return "base class for all matchers" + +class and_matcher_t(matcher_base_t): + """ + Combine several other matchers with "&" (and) operator. + + For example: find all private functions with name XXX + + .. code-block:: python + + matcher = access_type_matcher_t( 'private' ) & calldef_matcher_t( name='XXX' ) + """ + def __init__(self, matchers): + matcher_base_t.__init__(self) + self.matchers = matchers + + def __call__(self, decl): + for matcher in self.matchers: + if not matcher(decl): + return False + return True + + def __str__(self): + return " & ".join( map( lambda x: "(%s)" % str( x ), self.matchers ) ) + + +class or_matcher_t(matcher_base_t): + """Combine several other matchers with "|" (or) operator. + + For example: find all functions and variables with name 'XXX' + + .. code-block:: python + + matcher = variable_matcher_t( name='XXX' ) | calldef_matcher_t( name='XXX' ) + + """ + def __init__(self, matchers): + matcher_base_t.__init__(self) + self.matchers = matchers + + def __call__(self, decl): + for matcher in self.matchers: + if matcher(decl): + return True + return False + + def __str__(self): + return " | ".join( map( lambda x: "(%s)" % str( x ), self.matchers ) ) + + +class not_matcher_t(matcher_base_t): + """ + return the inverse result of a matcher + + For example: find all public and protected declarations + + .. code-block:: python + + matcher = ~access_type_matcher_t( 'private' ) + """ + def __init__(self, matcher): + matcher_base_t.__init__(self) + self.matcher = matcher + + def __call__(self, decl): + return not self.matcher(decl) + + def __str__(self): + return "~(%s)"%str(self.matcher) + +class declaration_matcher_t( matcher_base_t ): + """ + Instance of this class will match declarations by next criteria: + - declaration name, also could be fully qualified name + Example: `wstring` or `::std::wstring` + - declaration type + Example: :class:`class_t`, :class:`namespace_t`, :class:`enumeration_t` + - location within file system ( file or directory ) + """ + def __init__( self, name=None, decl_type=None, header_dir=None, header_file=None ): + """ + :param decl_type: declaration type to match by. For example :class:`enumeration_t`. + :type decl_type: any class that derives from :class:`declaration_t` class + + :param name: declaration name, could be full name. + :type name: str + + :param header_dir: absolute directory path + :type header_dir: str + + :param header_file: absolute file path + :type header_file: str + + """ + #An other option is that pygccxml will create absolute path using + #os.path.abspath function. But I think this is just wrong, because abspath + #builds path using current working directory. This behavior is fragile + #and very difficult to find a bug. + matcher_base_t.__init__( self ) + self.decl_type = decl_type + self.__name = None + self.__opt_is_tmpl_inst = None + self.__opt_tmpl_name = None + self.__opt_is_full_name = None + self.__decl_name_only = None + + self._set_name( name ) + + self.header_dir = header_dir + self.header_file = header_file + + if self.header_dir: + self.header_dir = utils.normalize_path( self.header_dir ) + if not os.path.isabs( self.header_dir ): + raise RuntimeError( "Path to header directory should be absolute!" ) + + if self.header_file: + self.header_file = utils.normalize_path( self.header_file ) + if not os.path.isabs( self.header_file ): + raise RuntimeError( "Path to header file should be absolute!" ) + + def _get_name(self): + return self.__name + + def _set_name( self, name ): + self.__name = name + if not self.__name: + self.__opt_is_tmpl_inst = None + self.__opt_tmpl_name = None + self.__opt_is_full_name = None + self.__decl_name_only = None + else: + self.__opt_is_tmpl_inst = templates.is_instantiation( self.__name ) + self.__opt_tmpl_name = templates.name( self.__name ) + if self.__opt_is_tmpl_inst: + if '::' in self.__opt_tmpl_name: + self.__opt_is_full_name = True + self.__decl_name_only = self.__opt_tmpl_name.split('::')[-1] + else: + self.__opt_is_full_name = False + self.__decl_name_only = self.__opt_tmpl_name + self.__name = templates.normalize( name ) + else: + if '::' in self.__name: + self.__opt_is_full_name = True + self.__decl_name_only = self.__name.split('::')[-1] + else: + self.__opt_is_full_name = False + self.__decl_name_only = self.__name + + + name = property( _get_name, _set_name ) + + def __str__( self ): + msg = [] + if not None is self.decl_type: + msg.append( '(decl type==%s)' % self.decl_type.__name__ ) + if not None is self.name: + msg.append( '(name==%s)' % self.name ) + if not None is self.header_dir: + msg.append( '(header dir==%s)' % self.header_dir ) + if not None is self.header_file: + msg.append( '(header file==%s)' % self.header_file ) + if not msg: + msg.append( 'any' ) + return ' and '.join( msg ) + + def __call__( self, decl ): + if not None is self.decl_type: + if not isinstance( decl, self.decl_type ): + return False + if not None is self.name: + if not self.check_name( decl ): + return False + if not None is self.header_dir: + if decl.location: + decl_dir = os.path.abspath( os.path.dirname( decl.location.file_name ) ) + decl_dir = utils.normalize_path( decl_dir ) + if decl_dir[:len(self.header_dir)] != self.header_dir: + return False + else: + return False + if not None is self.header_file: + if decl.location: + decl_file = os.path.abspath( decl.location.file_name ) + decl_file = utils.normalize_path( decl_file ) + if decl_file != self.header_file: + return False + else: + return False + return True + + def check_name( self, decl ): + assert not None is self.name + if self.__opt_is_tmpl_inst: + if not self.__opt_is_full_name: + if self.name != templates.normalize( decl.name ) \ + and self.name != templates.normalize( decl.partial_name ): + return False + else: + if self.name != templates.normalize( algorithm.full_name( decl, with_defaults=True ) ) \ + and self.name != templates.normalize( algorithm.full_name( decl, with_defaults=False ) ): + return False + else: + if not self.__opt_is_full_name: + if self.name != decl.name and self.name != decl.partial_name: + return False + else: + if self.name != algorithm.full_name( decl, with_defaults=True ) \ + and self.name != algorithm.full_name( decl, with_defaults=False ): + return False + return True + + def is_full_name(self): + return self.__opt_is_full_name + + def _get_decl_name_only(self): + return self.__decl_name_only + decl_name_only = property( _get_decl_name_only ) + +class variable_matcher_t( declaration_matcher_t ): + """ + Instance of this class will match variables by next criteria: + - :class:`declaration_matcher_t` criteria + - variable type. Example: :class:`int_t` or 'int' + """ + def __init__( self, name=None, type=None, header_dir=None, header_file=None ): + """ + :param type: variable type + :type type: string or instance of :class:`type_t` derived class + """ + declaration_matcher_t.__init__( self + , name=name + , decl_type=variable.variable_t + , header_dir=header_dir + , header_file=header_file ) + self.type = type + + def __call__( self, decl ): + if not super( variable_matcher_t, self ).__call__( decl ): + return False + if not None is self.type: + if isinstance( self.type, cpptypes.type_t ): + if self.type != decl.type: + return False + else: + if self.type != decl.type.decl_string: + return False + return True + + def __str__( self ): + msg = [ super( variable_matcher_t, self ).__str__() ] + if msg == [ 'any' ]: + msg = [] + if not None is self.type: + msg.append( '(value type==%s)' % str(self.type) ) + if not msg: + msg.append( 'any' ) + return ' and '.join( msg ) + + +class namespace_matcher_t( declaration_matcher_t ): + """Instance of this class will match namespaces by name.""" + + def __init__( self, name=None ): + declaration_matcher_t.__init__( self, name=name, decl_type=namespace.namespace_t) + + def __call__( self, decl ): + if self.name and decl.name == '': + #unnamed namespace have same name as thier parent, we should prevent + #this happens. The price is: user should search for unnamed namespace + #directly. + return False + return super( namespace_matcher_t, self ).__call__( decl ) + + +class calldef_matcher_t( declaration_matcher_t ): + """ + Instance of this class will match callable by the following criteria: + * :class:`declaration_matcher_t` criteria + * return type. For example: :class:`int_t` or 'int' + * argument types + + """ + + def __init__( self, name=None, return_type=None, arg_types=None, decl_type=None, header_dir=None, header_file=None): + """ + :param return_type: callable return type + :type return_type: string or instance of :class:`type_t` derived class + + :type arg_types: list + :param arg_types: list of function argument types. `arg_types` can contain. + Any item within the list could be string or instance + of :class:`type_t` derived class. If you don't want + some argument to participate in match you can put None. + + For example: + + .. code-block:: python + + calldef_matcher_t( arg_types=[ 'int &', None ] ) + + will match all functions that takes 2 arguments, where the first one is + reference to integer and second any + """ + if None is decl_type: + decl_type = calldef.calldef_t + declaration_matcher_t.__init__( self + , name=name + , decl_type=decl_type + , header_dir=header_dir + , header_file=header_file ) + + self.return_type = return_type + self.arg_types = arg_types + + def __call__( self, decl ): + if not super( calldef_matcher_t, self ).__call__( decl ): + return False + if not None is self.return_type \ + and not self.__compare_types( self.return_type, decl.return_type ): + return False + if self.arg_types: + if isinstance( self.arg_types, (types.ListType, types.TupleType)): + if len(self.arg_types) != len( decl.arguments ): + return False + for type_or_str, arg in zip( self.arg_types, decl.arguments ): + if None == type_or_str: + continue + else: + if not self.__compare_types( type_or_str, arg.type ): + return False + return True + + def __compare_types( self, type_or_str, type ): + assert type_or_str + if type is None: + return False + if isinstance( type_or_str, cpptypes.type_t ): + if type_or_str != type: + return False + else: + if type_or_str != type.decl_string: + return False + return True + + def __str__( self ): + msg = [ super( calldef_matcher_t, self ).__str__() ] + if msg == [ 'any' ]: + msg = [] + if not None is self.return_type: + msg.append( '(return type==%s)' % str(self.return_type) ) + if self.arg_types: + for i in range( len( self.arg_types ) ): + if self.arg_types[i] is None: + msg.append( '(arg %d type==any)' % i ) + else: + msg.append( '(arg %d type==%s)' % ( i, str( self.arg_types[i] ) ) ) + if not msg: + msg.append( 'any' ) + return ' and '.join( msg ) + + +class operator_matcher_t( calldef_matcher_t ): + """ + Instance of this class will match operators by next criteria: + * :class:`calldef_matcher_t` criteria + * operator symbol: =, !=, (), [] and etc + """ + def __init__( self, name=None, symbol=None, return_type=None, arg_types=None, decl_type=None, header_dir=None, header_file=None): + """ + :param symbol: operator symbol + :type symbol: str + """ + if None is decl_type: + decl_type = calldef.operator_t + calldef_matcher_t.__init__( self + , name=name + , return_type=return_type + , arg_types=arg_types + , decl_type=decl_type + , header_dir=header_dir + , header_file=header_file) + self.symbol = symbol + + def __call__( self, decl ): + if not super( operator_matcher_t, self ).__call__( decl ): + return False + if not None is self.symbol: + if self.symbol != decl.symbol: + return False + return True + + def __str__( self ): + msg = [ super( operator_matcher_t, self ).__str__() ] + if msg == [ 'any' ]: + msg = [] + if not None is self.symbol: + msg.append( '(symbol==%s)' % str(self.symbol) ) + if not msg: + msg.append( 'any' ) + return ' and '.join( msg ) + +class regex_matcher_t( matcher_base_t ): + """ + Instance of this class will match declaration using regular expression. + User should supply a function that will extract from declaration desired + information as string. Later, this matcher will match that string using + user regular expression. + """ + def __init__( self, regex, function=None ): + """ + :param regex: regular expression + :type regex: string, an instance of this class will compile it for you + + :param function: function that will be called to get an information from + declaration as string. As input this function takes single + argument - reference to a declaration. Return value + should be string. If function is None, then the matcher + will use declaration name. + + """ + matcher_base_t.__init__(self) + self.regex = re.compile( regex ) + self.function = function + if None is self.function: + self.function = lambda decl: decl.name + + def __call__( self, decl ): + text = self.function( decl ) + return bool( self.regex.match( text ) ) + + def __str__( self ): + return '(regex=%s)' % self.regex + +class access_type_matcher_t( matcher_base_t ): + """ + Instance of this class will match declaration by its access type: public, + private or protected. If declarations does not have access type, for example + free function, then `False` will be returned. + """ + + def __init__( self, access_type ): + """ + :param access_type: declaration access type, could be "public", "private", "protected" + :type access_type: :class: `str` + """ + matcher_base_t.__init__( self ) + self.access_type = access_type + + def __call__( self, decl ): + if not isinstance( decl.parent, class_declaration.class_t ): + return False + return self.access_type == decl.parent.find_out_member_access_type( decl ) + + def __str__( self ): + return '(access type=%s)' % self.access_type + +class virtuality_type_matcher_t( matcher_base_t ): + """ + Instance of this class will match declaration by its virtual type: not virtual, + virtual or pure virtual. If declarations does not have "virtual" property, + for example free function, then `False` will be returned. + """ + + def __init__( self, virtuality_type ): + """ + :param access_type: declaration access type + :type access_type: :class:VIRTUALITY_TYPES defines few constants for your convenience. + """ + matcher_base_t.__init__( self ) + self.virtuality_type = virtuality_type + + def __call__( self, decl ): + if not isinstance( decl.parent, class_declaration.class_t ): + return False + return self.virtuality_type == decl.virtuality + + def __str__( self ): + return '(virtuality type=%s)' % self.virtuality_type + + +class custom_matcher_t( matcher_base_t ): + """ + Instance of this class will match declaration by user custom criteria. + """ + + def __init__( self, function ): + """ + :param function: callable, that takes single argument - declaration instance + should return True or False + """ + matcher_base_t.__init__( self ) + self.function = function + + def __call__( self, decl ): + return bool( self.function( decl ) ) + + def __str__( self ): + return '(user criteria)' Modified: pyplusplus_dev/pyplusplus/function_transformers/function_transformation.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/function_transformation.py 2009-05-11 07:27:29 UTC (rev 1712) +++ pyplusplus_dev/pyplusplus/function_transformers/function_transformation.py 2009-05-11 07:44:51 UTC (rev 1713) @@ -1,73 +1,73 @@ -# Copyright 2006 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -"""defines :class:function_transformation_t class""" - -import md5 -import controllers -from pygccxml import declarations -from pyplusplus import code_repository - -class function_transformation_t: - """the class holds function transformation definition - all transformations that should be applied""" - def __init__(self, function, transformer_creator, **keywd): - self.__function = function - self.__controller = None - if isinstance( function.parent, declarations.class_t ): - if declarations.VIRTUALITY_TYPES.NOT_VIRTUAL == function.virtuality: - self.__controller = controllers.mem_fun_controller_t( function ) - elif declarations.VIRTUALITY_TYPES.PURE_VIRTUAL == function.virtuality: - self.__controller = controllers.pure_virtual_mem_fun_controller_t( function ) - else: - self.__controller = controllers.virtual_mem_fun_controller_t( function ) - else: - self.__controller = controllers.free_fun_controller_t( function ) - self.__transformers = map( lambda tr_creator: tr_creator( function ), transformer_creator ) - self.__thread_safe = keywd.get( 'thread_safe', False ) - self.__controller.apply( self.__transformers ) - self.__unique_name = None - self.__alias = keywd.get( 'alias', None ) - - @property - def unique_name( self ): - if None is self.__unique_name: - obj = md5.new() - if self.__function.mangled: # free functions don't have a mangled value - obj.update( self.__function.mangled ) - else: - obj.update( self.__function.decl_string ) - obj.update( self.__function.location.file_name ) - obj.update( str( self.__function.location.line ) ) - self.__unique_name = self.__function.name + '_' + obj.hexdigest () - return self.__unique_name - - @property - def alias( self ): - if None is self.__alias: - if self.__function.overloads: - self.__alias = self.unique_name - else: - self.__alias = self.__function.alias - return self.__alias - - @property - def transformers( self ): - return self.__transformers - - @property - def controller( self ): - return self.__controller - - def required_headers( self ): - headers = [] - map( lambda transformer: headers.extend( transformer.required_headers() ) - , self.transformers ) - if self.__function.call_policies: - headers.append( code_repository.call_policies.file_name ) - return headers - - @property - def thread_safe( self ): - return self.__thread_safe +# Copyright 2006 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +"""defines :class:function_transformation_t class""" + +import hashlib +import controllers +from pygccxml import declarations +from pyplusplus import code_repository + +class function_transformation_t: + """the class holds function transformation definition - all transformations that should be applied""" + def __init__(self, function, transformer_creator, **keywd): + self.__function = function + self.__controller = None + if isinstance( function.parent, declarations.class_t ): + if declarations.VIRTUALITY_TYPES.NOT_VIRTUAL == function.virtuality: + self.__controller = controllers.mem_fun_controller_t( function ) + elif declarations.VIRTUALITY_TYPES.PURE_VIRTUAL == function.virtuality: + self.__controller = controllers.pure_virtual_mem_fun_controller_t( function ) + else: + self.__controller = controllers.virtual_mem_fun_controller_t( function ) + else: + self.__controller = controllers.free_fun_controller_t( function ) + self.__transformers = map( lambda tr_creator: tr_creator( function ), transformer_creator ) + self.__thread_safe = keywd.get( 'thread_safe', False ) + self.__controller.apply( self.__transformers ) + self.__unique_name = None + self.__alias = keywd.get( 'alias', None ) + + @property + def unique_name( self ): + if None is self.__unique_name: + obj = hashlib.md5() + if self.__function.mangled: # free functions don't have a mangled value + obj.update( self.__function.mangled ) + else: + obj.update( self.__function.decl_string ) + obj.update( self.__function.location.file_name ) + obj.update( str( self.__function.location.line ) ) + self.__unique_name = self.__function.name + '_' + obj.hexdigest () + return self.__unique_name + + @property + def alias( self ): + if None is self.__alias: + if self.__function.overloads: + self.__alias = self.unique_name + else: + self.__alias = self.__function.alias + return self.__alias + + @property + def transformers( self ): + return self.__transformers + + @property + def controller( self ): + return self.__controller + + def required_headers( self ): + headers = [] + map( lambda transformer: headers.extend( transformer.required_headers() ) + , self.transformers ) + if self.__function.call_policies: + headers.append( code_repository.call_policies.file_name ) + return headers + + @property + def thread_safe( self ): + return self.__thread_safe Modified: pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2009-05-11 07:27:29 UTC (rev 1712) +++ pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2009-05-11 07:44:51 UTC (rev 1713) @@ -1,424 +1,427 @@ -# Copyright 2004-2008 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import os -import sys -import time -import types -import warnings -import module_builder - -from pygccxml import parser -from pygccxml import utils as pygccxml_utils -from pygccxml import declarations as decls_package - -from pyplusplus import utils -from pyplusplus import _logging_ -from pyplusplus import decl_wrappers -from pyplusplus import file_writers -from pyplusplus import code_creators -from pyplusplus import creators_factory - -class builder_t(module_builder.module_builder_t): - """ - This class provides users with simple and intuitive interface to `Py++` - and/or pygccxml functionality. If this is your first attempt to use `Py++` - consider to read tutorials. You can find them on `web site <http://www.language-binding.net>`_. - """ - - def __init__( self - , files - , gccxml_path='' - , working_directory='.' - , include_paths=None - , define_symbols=None - , undefine_symbols=None - , start_with_declarations=None - , compilation_mode=None - , cache=None - , optimize_queries=True - , ignore_gccxml_output=False - , indexing_suite_version=1 - , cflags="" - , encoding='ascii' - , compiler=None - , gccxml_config=None): - """ - :param files: list of files, declarations from them you want to export - :type files: list of strings or :class:`parser.file_configuration_t` instances - - :param gccxml_path: path to gccxml binary. If you don't pass this argument, - pygccxml parser will try to locate it using you environment PATH variable - :type gccxml_path: str - - :param include_paths: additional header files location. You don't have to - specify system and standard directories. - :type include_paths: list of strings - - :param define_symbols: list of symbols to be defined for preprocessor. - :param define_symbols: list of strings - - :param undefine_symbols: list of symbols to be undefined for preprocessor. - :param undefine_symbols: list of strings - - :param cflags: Raw string to be added to gccxml command line. - - :param gccxml_config: instance of pygccxml.parser.config_t class, holds - gccxml( compiler ) configuration. You can use this argument instead of - passing the compiler configuration separately. - """ - module_builder.module_builder_t.__init__( self, global_ns=None, encoding=encoding ) - - if not gccxml_config: - gccxml_config = parser.config_t( gccxml_path=gccxml_path - , working_directory=working_directory - , include_paths=include_paths - , define_symbols=define_symbols - , undefine_symbols=undefine_symbols - , start_with_declarations=start_with_declarations - , ignore_gccxml_output=ignore_gccxml_output - , cflags=cflags - , compiler=compiler) - - #may be in future I will add those directories to user_defined_directories to self.__code_creator. - self.__parsed_files = map( pygccxml_utils.normalize_path - , parser.project_reader_t.get_os_file_names( files ) ) - tmp = map( lambda file_: os.path.split( file_ )[0], self.__parsed_files ) - self.__parsed_dirs = filter( None, tmp ) - - self.global_ns = self.__parse_declarations( files - , gccxml_config - , compilation_mode - , cache - , indexing_suite_version) - self.global_ns.decls(recursive=True, allow_empty=True)._code_generator = decl_wrappers.CODE_GENERATOR_TYPES.CTYPES - - self.__code_creator = None - if optimize_queries: - self.run_query_optimizer() - - self.__declarations_code_head = [] - self.__declarations_code_tail = [] - - self.__registrations_code_head = [] - self.__registrations_code_tail = [] - - - - def register_module_dependency( self, other_module_generated_code_dir ): - """ - `already_exposed` solution is pretty good when you mix hand-written - modules with `Py++` generated. It doesn't work/scale for "true" - multi-module development. This is exactly the reason why `Py++` - offers "semi automatic" solution. - - For every exposed module, `Py++` generates `exposed_decl.pypp.txt` file. - This file contains the list of all parsed declarations and whether they - were included or excluded. Later, when you work on another module, you - can tell `Py++` that the current module depends on the previously - generated one. `Py++` will load `exposed_decl.pypp.txt` file and update - the declarations. - """ - - db = utils.exposed_decls_db_t() - db.load( other_module_generated_code_dir ) - db.update_decls( self.global_ns ) - - - def __parse_declarations( self, files, gccxml_config, compilation_mode, cache, indexing_suite_version ): - if None is gccxml_config: - gccxml_config = parser.config_t() - if None is compilation_mode: - compilation_mode = parser.COMPILATION_MODE.FILE_BY_FILE - start_time = time.clock() - self.logger.debug( 'parsing files - started' ) - reader = parser.project_reader_t( gccxml_config, cache, decl_wrappers.dwfactory_t() ) - decls = reader.read_files( files, compilation_mode ) - - self.logger.debug( 'parsing files - done( %f seconds )' % ( time.clock() - start_time ) ) - self.logger.debug( 'settings declarations defaults - started' ) - - global_ns = decls_package.matcher.get_single( - decls_package.namespace_matcher_t( name='::' ) - , decls ) - if indexing_suite_version != 1: - for cls in global_ns.classes(): - cls.indexing_suite_version = indexing_suite_version - for cls in global_ns.decls(decl_type=decls_package.class_declaration_t): - cls.indexing_suite_version = indexing_suite_version - - start_time = time.clock() - self.__apply_decls_defaults(decls) - self.logger.debug( 'settings declarations defaults - done( %f seconds )' - % ( time.clock() - start_time ) ) - return global_ns - - def __filter_by_location( self, flatten_decls ): - for decl in flatten_decls: - if not decl.location: - continue - fpath = pygccxml_utils.normalize_path( decl.location.file_name ) - if pygccxml_utils.contains_parent_dir( fpath, self.__parsed_dirs ): - continue - if fpath in self.__parsed_files: - continue - found = False - for pfile in self.__parsed_files: - if fpath.endswith( pfile ): - found = True - break - if not found: - decl.exclude() - - def __apply_decls_defaults(self, decls): - flatten_decls = decls_package.make_flatten( decls ) - self.__filter_by_location( flatten_decls ) - call_policies_resolver = creators_factory.built_in_resolver_t() - calldefs = filter( lambda decl: isinstance( decl, decls_package.calldef_t ) - , flatten_decls ) - map( lambda calldef: calldef.set_call_policies( call_policies_resolver( calldef ) ) - , calldefs ) - mem_vars = filter( lambda decl: isinstance( decl, decls_package.variable_t ) - and isinstance( decl.parent, decls_package.class_t ) - , flatten_decls ) - map( lambda mem_var: mem_var.set_getter_call_policies( call_policies_resolver( mem_var, 'get' ) ) - , mem_vars ) - map( lambda mem_var: mem_var.set_setter_call_policies( call_policies_resolver( mem_var, 'set' ) ) - , mem_vars ) - - @property - def declarations_code_head( self ): - "List of user code, that will be added to the head of the declarations section." - return self.__declarations_code_head - - @property - def declarations_code_tail( self ): - "List of user code, that will be added to the tail of the declarations section." - return self.__declarations_code_tail - - @property - def registrations_code_head( self ): - "List of user code, that will be added to the head of the registrations section." - return self.__registrations_code_head - - @property - def registrations_code_tail( self ): - "List of user code, that will be added to the tail of the registrations section." - return self.__registrations_code_tail - - def build_code_creator( self - , module_name - , boost_python_ns_name='bp' - , call_policies_resolver_=None - , types_db=None - , target_configuration=None - , enable_indexing_suite=True - , doc_extractor=None): - """ - Creates :class:`code_creators.bpmodule_t` code creator. - - :param module_name: module name - :type module_name: str - - :param boost_python_ns_name: boost::python namespace alias, by default it is `bp` - :type boost_python_ns_name: str - - :param call_policies_resolver_: callable, that will be invoked on every calldef object. It should return call policies. - :type call_policies_resolver_: callable - :param doc_extractor: callable, that takes as argument reference to declaration and returns documentation string - :type doc_extractor: callable or None - """ - - creator = creators_factory.bpcreator_t( self.global_ns - , module_name - , boost_python_ns_name - , call_policies_resolver_ - , types_db - , target_configuration - , enable_indexing_suite ) - self.__code_creator = creator.create() - self.__code_creator.replace_included_headers(self.__parsed_files) - self.__code_creator.update_documentation( doc_extractor ) - return self.__code_creator - - @property - def code_creator( self ): - "reference to :class:`code_creators.bpmodule_t` instance" - if not self.__code_creator: - raise RuntimeError( "self.module is equal to None. Did you forget to call build_code_creator function?" ) - return self.__code_creator - - def has_code_creator( self ): - """ - Function, that will return True if build_code_creator function has been - called and False otherwise - """ - return not ( None is self.__code_creator ) - - def add_declaration_code( self, code, tail=True ): - if tail: - self.__declarations_code_tail.append( code ) - else: - self.__declarations_code_head.append( code ) - - def add_registration_code( self, code, tail=True ): - if tail: - self.__registrations_code_tail.append( code ) - else: - self.__registrations_code_head.append( code ) - - def add_constants( self, **keywds ): - """ - adds code that exposes some constants to Python. - - For example: - .. code-block:: python - - mb.add_constants( version='"1.2.3"' ) - # or - constants = dict( version:'"1.2.3"' ) - mb.add_constants( \\*\\*constants ) - - will generate the following code: - - .. code-block:: c++ - - boost::python::scope().attr("version") = "1.2.3"; - - """ - tmpl = 'boost::python::scope().attr("%(name)s") = %(value)s;' - for name, value in keywds.items(): - if not isinstance( value, types.StringTypes ): - value = str( value ) - self.add_regi... [truncated message content] |
From: <rom...@us...> - 2009-05-11 19:15:58
|
Revision: 1722 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1722&view=rev Author: roman_yakovenko Date: 2009-05-11 19:15:45 +0000 (Mon, 11 May 2009) Log Message: ----------- porting few tests to linux Modified Paths: -------------- pyplusplus_dev/environment.py pyplusplus_dev/unittests/custom_smart_ptr_classes_tester.py pyplusplus_dev/unittests/gccxml.cfg Modified: pyplusplus_dev/environment.py =================================================================== --- pyplusplus_dev/environment.py 2009-05-11 19:14:10 UTC (rev 1721) +++ pyplusplus_dev/environment.py 2009-05-11 19:15:45 UTC (rev 1722) @@ -44,7 +44,7 @@ scons.ccflags = ['-DBOOST_PYTHON_NO_PY_SIGNATURES' ] boost.libs = ['/home/roman/include/libs' ] boost.include = '/home/roman/boost_svn' - python.include = '/usr/include/python2.5' + python.include = '/usr/include/python2.6' elif 'root' == getpass.getuser(): if sys.platform == 'win32': scons.suffix = '.pyd' Modified: pyplusplus_dev/unittests/custom_smart_ptr_classes_tester.py =================================================================== --- pyplusplus_dev/unittests/custom_smart_ptr_classes_tester.py 2009-05-11 19:14:10 UTC (rev 1721) +++ pyplusplus_dev/unittests/custom_smart_ptr_classes_tester.py 2009-05-11 19:15:45 UTC (rev 1722) @@ -9,6 +9,7 @@ import fundamental_tester_base EXPECTED_ERROR_INFO = "I don't have time to find out what is going wrong" +EXPECTED_FAILURE_INFO = EXPECTED_ERROR_INFO MODULE_SPTR_DECL_CODE = \ Modified: pyplusplus_dev/unittests/gccxml.cfg =================================================================== --- pyplusplus_dev/unittests/gccxml.cfg 2009-05-11 19:14:10 UTC (rev 1721) +++ pyplusplus_dev/unittests/gccxml.cfg 2009-05-11 19:15:45 UTC (rev 1722) @@ -9,5 +9,5 @@ #gccxml has a nice algorithms, which selects what C++ compiler to emulate. #You can explicitly set what compiler it should emulate. #Valid options are: g++, msvc6, msvc7, msvc71, msvc8, cl. -compiler=msvc9 +compiler= #GCC-XML site: http://gccxml.org/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-08-05 20:13:09
|
Revision: 1741 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1741&view=rev Author: roman_yakovenko Date: 2009-08-05 20:12:45 +0000 (Wed, 05 Aug 2009) Log Message: ----------- adding adaptor for member and free functions Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef.py pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py pyplusplus_dev/unittests/autoconfig.py pyplusplus_dev/unittests/fundamental_tester_base.py Added Paths: ----------- pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp pyplusplus_dev/unittests/function_adaptor_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2009-06-14 04:42:38 UTC (rev 1740) +++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2009-08-05 20:12:45 UTC (rev 1741) @@ -199,12 +199,16 @@ def create_function_ref_code(self, use_function_alias=False): fname = declarations.full_name( self.declaration, with_defaults=False ) + result = '' if use_function_alias: - return '%s( &%s )' % ( self.function_type_alias, fname ) + result = '%s( &%s )' % ( self.function_type_alias, fname ) elif self.declaration.create_with_signature: - return '(%s)( &%s )' % ( self.declaration.function_type().partial_decl_string, fname ) + result = '(%s)( &%s )' % ( self.declaration.function_type().partial_decl_string, fname ) else: - return '&%s' % fname + result = '&%s' % fname + if self.declaration.adaptor: + result = "%s( %s )" % ( self.declaration.adaptor, result ) + return result class mem_fun_t( calldef_t ): def __init__( self, function ): @@ -216,12 +220,16 @@ def create_function_ref_code(self, use_function_alias=False): fname = declarations.full_name( self.declaration, with_defaults=False ) + result = '' if use_function_alias: - return '%s( &%s )' % ( self.function_type_alias, fname ) + result = '%s( &%s )' % ( self.function_type_alias, fname ) elif self.declaration.create_with_signature: - return '(%s)( &%s )' % ( self.declaration.function_type().partial_decl_string, fname ) + result = '(%s)( &%s )' % ( self.declaration.function_type().partial_decl_string, fname ) else: - return '&%s' % fname + result = '&%s' % fname + if hasattr( self.declaration, 'adaptor' ) and self.declaration.adaptor: + result = "%s( %s )" % ( self.declaration.adaptor, result ) + return result class make_constructor_t( calldef_t ): def __init__( self, function ): Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2009-06-14 04:42:38 UTC (rev 1740) +++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2009-08-05 20:12:45 UTC (rev 1741) @@ -247,7 +247,18 @@ self._use_overload_macro = False self._override_precall_code = [] self._default_precall_code = [] + self._adaptor = None + def _get_adaptor(self): + return self._adaptor + def _set_adaptor(self, adaptor): + self._adaptor = adaptor + adaptor = property( _get_adaptor, _set_adaptor + , doc="string, if contains value `Py++` will generate code the following code: " \ + +".def(<name>, <adaptor>(<function reference>), <other args> ) " \ + +". The property is relevant for public, non virtual member functions." ) + + def add_override_precall_code(self, code): """add code, which should be executed, before overridden member function call""" self._override_precall_code.append( code ) @@ -563,7 +574,16 @@ calldef_t.__init__( self ) self._use_overload_macro = False self._declaration_code = [] + self._adaptor = None + def _get_adaptor(self): + return self._adaptor + def _set_adaptor(self, adaptor): + self._adaptor = adaptor + adaptor = property( _get_adaptor, _set_adaptor + , doc="string, if contains value `Py++` will generate code the following code: " \ + +"def(<name>, <adaptor>(<function reference>), <other args> ) " ) + def add_declaration_code( self, code ): """adds the code to the declaration section""" self.declaration_code.append( user_text.user_text_t( code ) ) Modified: pyplusplus_dev/unittests/autoconfig.py =================================================================== --- pyplusplus_dev/unittests/autoconfig.py 2009-06-14 04:42:38 UTC (rev 1740) +++ pyplusplus_dev/unittests/autoconfig.py 2009-08-05 20:12:45 UTC (rev 1741) @@ -92,9 +92,11 @@ while process.poll() is None: line = process.stdout.readline() - print line.rstrip() + if line.strip(): + print line.rstrip() for line in process.stdout.readlines(): - print line.rstrip() + if line.strip(): + print line.rstrip() if process.returncode: raise RuntimeError( "unable to compile extension. See output for the errors." ) Added: pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp (rev 0) +++ pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp 2009-08-05 20:12:45 UTC (rev 1741) @@ -0,0 +1,21 @@ +// Copyright 2004-2008 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __function_adaptor_to_be_exported_hpp__ +#define __function_adaptor_to_be_exported_hpp__ + +//#include <boost/preprocessor/facilities/identity.hpp> +//I need it for BOOST_PP_IDENTITY macro + +#define PYPP_IDENTITY( X ) X + +struct foo_t{ + int get_zero() const{ return 0; } + static int get_two(){ return 2; } +}; + +inline int get_one(){ return 1; } + +#endif//__function_adaptor_to_be_exported_hpp__ Added: pyplusplus_dev/unittests/function_adaptor_tester.py =================================================================== --- pyplusplus_dev/unittests/function_adaptor_tester.py (rev 0) +++ pyplusplus_dev/unittests/function_adaptor_tester.py 2009-08-05 20:12:45 UTC (rev 1741) @@ -0,0 +1,41 @@ +# Copyright 2004-2008 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os +import sys +import unittest +import fundamental_tester_base +from pyplusplus import code_creators + +class tester_t(fundamental_tester_base.fundamental_tester_base_t): + EXTENSION_NAME = 'function_adaptor' + + def __init__( self, *args ): + fundamental_tester_base.fundamental_tester_base_t.__init__( + self + , tester_t.EXTENSION_NAME + , *args ) + + def customize(self, mb ): + for suffix in [ 'zero', 'one', 'two' ]: + mb.calldef( 'get_' + suffix ).adaptor = 'PYPP_IDENTITY' + mb.calldef( 'get_' + suffix ).create_with_signature = False + def run_tests( self, module): + foo = module.foo_t() + self.failUnless( foo.get_zero() == 0 ) + self.failUnless( foo.get_two() == 2 ) + self.failUnless( module.foo_t.get_two() == 2 ) + self.failUnless( module.get_one() == 1 ) + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() Modified: pyplusplus_dev/unittests/fundamental_tester_base.py =================================================================== --- pyplusplus_dev/unittests/fundamental_tester_base.py 2009-06-14 04:42:38 UTC (rev 1740) +++ pyplusplus_dev/unittests/fundamental_tester_base.py 2009-08-05 20:12:45 UTC (rev 1741) @@ -137,6 +137,7 @@ break exit_status = output.close() scons_msg = ''.join(scons_reports) + scons_msg = scons_msg.strip() if exit_status: raise RuntimeError( "unable to clean extension. error: %s" % scons_msg ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-08-06 21:30:43
|
Revision: 1743 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1743&view=rev Author: roman_yakovenko Date: 2009-08-06 21:30:35 +0000 (Thu, 06 Aug 2009) Log Message: ----------- cleaning ctypes builder Modified Paths: -------------- pyplusplus_dev/examples/gmplib_dev/dev/project_env.py pyplusplus_dev/examples/gmplib_dev/pygmplib/__init__.py pyplusplus_dev/pyplusplus/code_creators/__init__.py pyplusplus_dev/pyplusplus/code_creators/calldef_ctypes.py Modified: pyplusplus_dev/examples/gmplib_dev/dev/project_env.py =================================================================== --- pyplusplus_dev/examples/gmplib_dev/dev/project_env.py 2009-08-05 20:25:05 UTC (rev 1742) +++ pyplusplus_dev/examples/gmplib_dev/dev/project_env.py 2009-08-06 21:30:35 UTC (rev 1743) @@ -6,6 +6,6 @@ class gmp: header_file = '/usr/include/gmp.h' - symbols_file = '/usr/lib/libgmp.so.3.4.2' - shared_library_file = '/usr/lib/libgmp.so.3.4.2' + symbols_file = '/usr/lib/libgmp.so.3.4.4' + shared_library_file = '/usr/lib/libgmp.so.3.4.4' generated_code_dir = complete_path( 'pyplusplus_dev', 'examples', 'gmplib_dev', 'pygmplib' ) Modified: pyplusplus_dev/examples/gmplib_dev/pygmplib/__init__.py =================================================================== --- pyplusplus_dev/examples/gmplib_dev/pygmplib/__init__.py 2009-08-05 20:25:05 UTC (rev 1742) +++ pyplusplus_dev/examples/gmplib_dev/pygmplib/__init__.py 2009-08-06 21:30:35 UTC (rev 1743) @@ -4,90 +4,85 @@ import ctypes_utils -libgmp_lib = ctypes.CDLL( r"/usr/lib/libgmp.so.3.4.2" ) +libgmp_lib = ctypes.CDLL( r"/usr/lib/libgmp.so.3.4.4" ) libgmp_lib.undecorated_names = {#mapping between decorated and undecorated names "extern double __gmpf_get_d(mpf_srcptr arg0) [free function]" : "__gmpf_get_d", "extern int __gmpf_cmp_ui(mpf_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpf_cmp_ui", - "extern void __gmpz_mul_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_mul_ui", + "extern void __gmpz_fac_ui(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_fac_ui", "extern void __gmpz_and(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_and", "extern void __gmpf_urandomb(__mpf_struct * arg0, __gmp_randstate_struct * arg1, long unsigned int arg2) [free function]" : "__gmpf_urandomb", - "extern void __gmpz_fib2_ui(mpz_ptr arg0, mpz_ptr arg1, long unsigned int arg2) [free function]" : "__gmpz_fib2_ui", + "extern mp_limb_t __gmpn_mul_1(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, mp_limb_t arg3) [free function]" : "__gmpn_mul_1", "extern void __gmpz_mul_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_mul_2exp", "extern void __gmpz_clrbit(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_clrbit", "extern void __gmpz_cdiv_r_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_cdiv_r_2exp", - "extern int __gmpz_init_set_str(mpz_ptr arg0, char const * arg1, int arg2) [free function]" : "__gmpz_init_set_str", + "extern void __gmpz_lcm(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_lcm", "extern void __gmpz_gcd(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_gcd", - "extern void __gmpq_set_ui(mpq_ptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]" : "__gmpq_set_ui", - "extern int __gmpz_cmp_si(mpz_srcptr arg0, long int arg1) [free function]" : "__gmpz_cmp_si", + "extern int __gmpz_divisible_2exp_p(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_divisible_2exp_p", "extern int __gmpz_congruent_2exp_p(mpz_srcptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_congruent_2exp_p", "extern void __gmpz_pow_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_pow_ui", "void __gmpq_neg(mpq_ptr __gmp_w, mpq_srcptr __gmp_u) [free function]" : "__gmpq_neg", "extern void __gmpz_import(mpz_ptr arg0, size_t arg1, int arg2, size_t arg3, int arg4, size_t arg5, void const * arg6) [free function]" : "__gmpz_import", - "extern void __gmpz_fac_ui(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_fac_ui", + "extern long unsigned int __gmpz_fdiv_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_fdiv_ui", "extern int __gmpz_root(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_root", "extern void __gmpz_fdiv_q(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_fdiv_q", - "extern void __gmpq_div_2exp(mpq_ptr arg0, mpq_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpq_div_2exp", + "extern void __gmpz_fdiv_r(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_fdiv_r", "extern size_t __gmpq_inp_str(mpq_ptr arg0, FILE * arg1, int arg2) [free function]" : "__gmpq_inp_str", "extern int __gmpz_ui_kronecker(long unsigned int arg0, mpz_srcptr arg1) [free function]" : "__gmpz_ui_kronecker", - "extern long unsigned int __gmpz_cdiv_r_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_cdiv_r_ui", "extern long unsigned int __gmpz_remove(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_remove", - "extern void __gmpz_realloc2(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_realloc2", + "extern int __gmpz_tstbit(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_tstbit", "extern void __gmpn_tdiv_qr(mp_ptr arg0, mp_ptr arg1, mp_size_t arg2, mp_srcptr arg3, mp_size_t arg4, mp_srcptr arg5, mp_size_t arg6) [free function]" : "__gmpn_tdiv_qr", "extern void __gmpz_fdiv_r_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_fdiv_r_2exp", "extern void __gmpf_div(mpf_ptr arg0, mpf_srcptr arg1, mpf_srcptr arg2) [free function]" : "__gmpf_div", "extern void __gmpq_div(mpq_ptr arg0, mpq_srcptr arg1, mpq_srcptr arg2) [free function]" : "__gmpq_div", - "extern long unsigned int __gmpf_get_default_prec() [free function]" : "__gmpf_get_default_prec", + "extern void __gmpz_ui_pow_ui(mpz_ptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]" : "__gmpz_ui_pow_ui", "extern void __gmpq_sub(mpq_ptr arg0, mpq_srcptr arg1, mpq_srcptr arg2) [free function]" : "__gmpq_sub", "extern void __gmpf_set_ui(mpf_ptr arg0, long unsigned int arg1) [free function]" : "__gmpf_set_ui", - "mp_limb_t __gmpn_add_1(mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) [free function]" : "__gmpn_add_1", + "extern mp_limb_t __gmpn_lshift(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, unsigned int arg3) [free function]" : "__gmpn_lshift", "extern void __gmpz_add(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_add", "extern void __gmpf_trunc(mpf_ptr arg0, mpf_srcptr arg1) [free function]" : "__gmpf_trunc", "extern void __gmpz_divexact_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_divexact_ui", "extern long unsigned int __gmpz_gcd_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_gcd_ui", - "extern size_t __gmpz_out_raw(FILE * arg0, mpz_srcptr arg1) [free function]" : "__gmpz_out_raw", - "mp_limb_t __gmpn_sub(mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) [free function]" : "__gmpn_sub", + "extern void __gmpz_cdiv_r(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_cdiv_r", + "extern size_t __gmpz_inp_str(mpz_ptr arg0, FILE * arg1, int arg2) [free function]" : "__gmpz_inp_str", + "extern double __gmpq_get_d(mpq_srcptr arg0) [free function]" : "__gmpq_get_d", + "extern int __gmp_sprintf(char * arg0, char const * arg1, ...) [free function]" : "__gmp_sprintf", "extern void __gmpn_random2(mp_ptr arg0, mp_size_t arg1) [free function]" : "__gmpn_random2", "extern void __gmpz_cdiv_q_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_cdiv_q_2exp", "extern int __gmpf_eq(mpf_srcptr arg0, mpf_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpf_eq", "extern mp_limb_t __gmpn_divrem(mp_ptr arg0, mp_size_t arg1, mp_ptr arg2, mp_size_t arg3, mp_srcptr arg4, mp_size_t arg5) [free function]" : "__gmpn_divrem", "extern void __gmpz_cdiv_q(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_cdiv_q", - "extern void __gmpz_init_set(mpz_ptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_init_set", + "void __gmpz_abs(mpz_ptr __gmp_w, mpz_srcptr __gmp_u) [free function]" : "__gmpz_abs", "extern void __gmpz_xor(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_xor", - "extern void __gmpz_sqrt(mpz_ptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_sqrt", "extern void __gmpz_init_set_d(mpz_ptr arg0, double arg1) [free function]" : "__gmpz_init_set_d", "int __gmpz_fits_ushort_p(mpz_srcptr __gmp_z) [free function]" : "__gmpz_fits_ushort_p", - "extern void __gmpz_sub(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_sub", + "extern void __gmpq_set_f(mpq_ptr arg0, mpf_srcptr arg1) [free function]" : "__gmpq_set_f", "extern int __gmpf_fits_ulong_p(mpf_srcptr arg0) [free function]" : "__gmpf_fits_ulong_p", - "extern void __gmpf_random2(mpf_ptr arg0, mp_size_t arg1, mp_exp_t arg2) [free function]" : "__gmpf_random2", "long unsigned int __gmpz_get_ui(mpz_srcptr __gmp_z) [free function]" : "__gmpz_get_ui", + "extern int __gmpz_cmpabs_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_cmpabs_ui", "extern long unsigned int __gmp_urandomm_ui(__gmp_randstate_struct * arg0, long unsigned int arg1) [free function]" : "__gmp_urandomm_ui", "int __gmpz_perfect_square_p(mpz_srcptr __gmp_a) [free function]" : "__gmpz_perfect_square_p", - "extern size_t __gmpn_get_str(unsigned char * arg0, int arg1, mp_ptr arg2, mp_size_t arg3) [free function]" : "__gmpn_get_str", + "extern void __gmpq_set_d(mpq_ptr arg0, double arg1) [free function]" : "__gmpq_set_d", "extern int __gmpz_cmp_d(mpz_srcptr arg0, double arg1) [free function]" : "__gmpz_cmp_d", "extern void __gmpz_cdiv_qr(mpz_ptr arg0, mpz_ptr arg1, mpz_srcptr arg2, mpz_srcptr arg3) [free function]" : "__gmpz_cdiv_qr", "extern void __gmpf_add(mpf_ptr arg0, mpf_srcptr arg1, mpf_srcptr arg2) [free function]" : "__gmpf_add", "extern int __gmpz_probab_prime_p(mpz_srcptr arg0, int arg1) [free function]" : "__gmpz_probab_prime_p", "extern mp_limb_t __gmpn_rshift(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, unsigned int arg3) [free function]" : "__gmpn_rshift", "extern void __gmpz_array_init(mpz_ptr arg0, mp_size_t arg1, mp_size_t arg2) [free function]" : "__gmpz_array_init", - "int __gmpz_fits_uint_p(mpz_srcptr __gmp_z) [free function]" : "__gmpz_fits_uint_p", - "extern void __gmpz_bin_uiui(mpz_ptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]" : "__gmpz_bin_uiui", - "extern long unsigned int __gmpz_tdiv_r_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_tdiv_r_ui", + "extern long unsigned int __gmpf_get_default_prec() [free function]" : "__gmpf_get_default_prec", + "extern void __gmpf_random2(mpf_ptr arg0, mp_size_t arg1, mp_exp_t arg2) [free function]" : "__gmpf_random2", "extern void __gmp_randinit_set(__gmp_randstate_struct * arg0, __gmp_randstate_struct const * arg1) [free function]" : "__gmp_randinit_set", - "extern long unsigned int __gmpz_tdiv_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_tdiv_ui", "extern void __gmpq_inv(mpq_ptr arg0, mpq_srcptr arg1) [free function]" : "__gmpq_inv", "extern mp_size_t __gmpn_set_str(mp_ptr arg0, unsigned char const * arg1, size_t arg2, int arg3) [free function]" : "__gmpn_set_str", - "extern void __gmpz_lcm(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_lcm", - "extern long unsigned int __gmpn_scan0(mp_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpn_scan0", - "extern long unsigned int __gmpn_scan1(mp_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpn_scan1", + "extern void __gmp_randinit(__gmp_randstate_struct * arg0, gmp_randalg_t arg1, ...) [free function]" : "__gmp_randinit", + "extern mp_size_t __gmpn_sqrtrem(mp_ptr arg0, mp_ptr arg1, mp_srcptr arg2, mp_size_t arg3) [free function]" : "__gmpn_sqrtrem", "extern long unsigned int __gmpz_fdiv_qr_ui(mpz_ptr arg0, mpz_ptr arg1, mpz_srcptr arg2, long unsigned int arg3) [free function]" : "__gmpz_fdiv_qr_ui", "extern void __gmpf_init_set_ui(mpf_ptr arg0, long unsigned int arg1) [free function]" : "__gmpf_init_set_ui", "extern void __gmpn_mul_n(mp_ptr arg0, mp_srcptr arg1, mp_srcptr arg2, mp_size_t arg3) [free function]" : "__gmpn_mul_n", "extern int __gmpq_cmp_ui(mpq_srcptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]" : "__gmpq_cmp_ui", "extern void __gmpz_mul_si(mpz_ptr arg0, mpz_srcptr arg1, long int arg2) [free function]" : "__gmpz_mul_si", "extern void __gmpq_set_si(mpq_ptr arg0, long int arg1, long unsigned int arg2) [free function]" : "__gmpq_set_si", - "extern int __gmpz_divisible_2exp_p(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_divisible_2exp_p", - "mp_limb_t __gmpn_add(mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) [free function]" : "__gmpn_add", + "extern void __gmpq_set_ui(mpq_ptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]" : "__gmpq_set_ui", "extern void __gmpf_sqrt_ui(mpf_ptr arg0, long unsigned int arg1) [free function]" : "__gmpf_sqrt_ui", "extern void __gmpz_init_set_ui(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_init_set_ui", "extern int __gmpz_divisible_ui_p(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_divisible_ui_p", @@ -96,101 +91,112 @@ "extern void __gmpz_sub_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_sub_ui", "extern void __gmpz_divexact(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_divexact", "extern void __gmpz_com(mpz_ptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_com", - "extern void __gmpz_ui_sub(mpz_ptr arg0, long unsigned int arg1, mpz_srcptr arg2) [free function]" : "__gmpz_ui_sub", + "extern void __gmpz_ior(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_ior", + "extern void __gmpz_init_set(mpz_ptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_init_set", + "extern long unsigned int __gmpz_cdiv_q_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_cdiv_q_ui", "extern void __gmpz_submul(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_submul", "extern int __gmp_asprintf(char * * arg0, char const * arg1, ...) [free function]" : "__gmp_asprintf", "__gmp_bits_per_limb [variable]" : "__gmp_bits_per_limb", - "extern void __gmpz_tdiv_r_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_tdiv_r_2exp", - "extern void __gmpq_get_num(mpz_ptr arg0, mpq_srcptr arg1) [free function]" : "__gmpq_get_num", + "extern int __gmp_scanf(char const * arg0, ...) [free function]" : "__gmp_scanf", + "extern void __gmpf_set_prec(mpf_ptr arg0, long unsigned int arg1) [free function]" : "__gmpf_set_prec", + "extern int __gmpz_init_set_str(mpz_ptr arg0, char const * arg1, int arg2) [free function]" : "__gmpz_init_set_str", + "mp_limb_t __gmpn_sub_1(mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) [free function]" : "__gmpn_sub_1", "extern int __gmpz_millerrabin(mpz_srcptr arg0, int arg1) [free function]" : "__gmpz_millerrabin", "extern void __gmpz_mod(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_mod", + "extern int __gmpz_invert(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_invert", "extern void __gmpf_set_d(mpf_ptr arg0, double arg1) [free function]" : "__gmpf_set_d", "extern int __gmpf_fits_uint_p(mpf_srcptr arg0) [free function]" : "__gmpf_fits_uint_p", "extern mp_limb_t __gmpn_addmul_1(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, mp_limb_t arg3) [free function]" : "__gmpn_addmul_1", "extern void __gmpf_set_z(mpf_ptr arg0, mpz_srcptr arg1) [free function]" : "__gmpf_set_z", - "extern void __gmpz_ui_pow_ui(mpz_ptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]" : "__gmpz_ui_pow_ui", + "extern void __gmpz_ui_sub(mpz_ptr arg0, long unsigned int arg1, mpz_srcptr arg2) [free function]" : "__gmpz_ui_sub", "extern double __gmpz_get_d(mpz_srcptr arg0) [free function]" : "__gmpz_get_d", "extern void __gmpf_set_prec_raw(mpf_ptr arg0, long unsigned int arg1) [free function]" : "__gmpf_set_prec_raw", "extern int __gmpf_cmp(mpf_srcptr arg0, mpf_srcptr arg1) [free function]" : "__gmpf_cmp", "extern void __gmpz_lucnum_ui(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_lucnum_ui", "extern void __gmpf_set_q(mpf_ptr arg0, mpq_srcptr arg1) [free function]" : "__gmpf_set_q", - "extern long unsigned int __gmpz_fdiv_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_fdiv_ui", + "extern mp_limb_t __gmpn_gcd_1(mp_srcptr arg0, mp_size_t arg1, mp_limb_t arg2) [free function]" : "__gmpn_gcd_1", "extern void __gmpz_tdiv_qr(mpz_ptr arg0, mpz_ptr arg1, mpz_srcptr arg2, mpz_srcptr arg3) [free function]" : "__gmpz_tdiv_qr", - "extern mp_size_t __gmpn_sqrtrem(mp_ptr arg0, mp_ptr arg1, mp_srcptr arg2, mp_size_t arg3) [free function]" : "__gmpn_sqrtrem", "extern int __gmpq_set_str(mpq_ptr arg0, char const * arg1, int arg2) [free function]" : "__gmpq_set_str", "extern int __gmpf_fits_slong_p(mpf_srcptr arg0) [free function]" : "__gmpf_fits_slong_p", "extern void __gmpz_setbit(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_setbit", "extern void __gmp_randinit_lc_2exp(__gmp_randstate_struct * arg0, mpz_srcptr arg1, long unsigned int arg2, long unsigned int arg3) [free function]" : "__gmp_randinit_lc_2exp", "extern int __gmp_randinit_lc_2exp_size(__gmp_randstate_struct * arg0, long unsigned int arg1) [free function]" : "__gmp_randinit_lc_2exp_size", - "extern void __gmpz_set_d(mpz_ptr arg0, double arg1) [free function]" : "__gmpz_set_d", + "extern int __gmpf_cmp_si(mpf_srcptr arg0, long int arg1) [free function]" : "__gmpf_cmp_si", "extern void __gmp_randclear(__gmp_randstate_struct * arg0) [free function]" : "__gmp_randclear", "extern void __gmpz_set_f(mpz_ptr arg0, mpf_srcptr arg1) [free function]" : "__gmpz_set_f", "extern size_t __gmpf_out_str(FILE * arg0, int arg1, size_t arg2, mpf_srcptr arg3) [free function]" : "__gmpf_out_str", "extern int __gmpf_fits_sshort_p(mpf_srcptr arg0) [free function]" : "__gmpf_fits_sshort_p", + "extern void __gmpq_div_2exp(mpq_ptr arg0, mpq_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpq_div_2exp", "extern long unsigned int __gmpf_get_prec(mpf_srcptr arg0) [free function]" : "__gmpf_get_prec", - "extern int __gmp_scanf(char const * arg0, ...) [free function]" : "__gmp_scanf", - "extern void __gmpf_floor(mpf_ptr arg0, mpf_srcptr arg1) [free function]" : "__gmpf_floor", + "extern void __gmpq_init(mpq_ptr arg0) [free function]" : "__gmpq_init", + "extern int __gmpz_kronecker_si(mpz_srcptr arg0, long int arg1) [free function]" : "__gmpz_kronecker_si", + "extern int __gmpz_fits_sint_p(mpz_srcptr arg0) [free function]" : "__gmpz_fits_sint_p", "extern int __gmp_snprintf(char * arg0, size_t arg1, char const * arg2, ...) [free function]" : "__gmp_snprintf", "extern void __gmpz_powm(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2, mpz_srcptr arg3) [free function]" : "__gmpz_powm", "extern long unsigned int __gmpz_hamdist(mpz_srcptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_hamdist", "extern void __gmpz_fib_ui(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_fib_ui", - "extern void __gmpf_set_default_prec(long unsigned int arg0) [free function]" : "__gmpf_set_default_prec", - "extern int __gmpq_cmp(mpq_srcptr arg0, mpq_srcptr arg1) [free function]" : "__gmpq_cmp", + "extern int __gmpz_cmp_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_cmp_ui", + "extern mp_limb_t __gmpn_submul_1(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, mp_limb_t arg3) [free function]" : "__gmpn_submul_1", "extern void __gmpf_init2(mpf_ptr arg0, long unsigned int arg1) [free function]" : "__gmpf_init2", - "extern size_t __gmpz_inp_raw(mpz_ptr arg0, FILE * arg1) [free function]" : "__gmpz_inp_raw", + "extern int __gmpz_cmpabs(mpz_srcptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_cmpabs", + "extern long unsigned int __gmpz_tdiv_q_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_tdiv_q_ui", "extern mp_limb_t __gmpn_mod_1(mp_srcptr arg0, mp_size_t arg1, mp_limb_t arg2) [free function]" : "__gmpn_mod_1", "size_t __gmpz_size(mpz_srcptr __gmp_z) [free function]" : "__gmpz_size", "extern void __gmpq_get_den(mpz_ptr arg0, mpq_srcptr arg1) [free function]" : "__gmpq_get_den", - "extern void __gmpq_set_num(mpq_ptr arg0, mpz_srcptr arg1) [free function]" : "__gmpq_set_num", - "extern int __gmpz_congruent_p(mpz_srcptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_congruent_p", - "extern mp_limb_t __gmpn_gcd_1(mp_srcptr arg0, mp_size_t arg1, mp_limb_t arg2) [free function]" : "__gmpn_gcd_1", - "extern void __gmp_randinit(__gmp_randstate_struct * arg0, gmp_randalg_t arg1, ...) [free function]" : "__gmp_randinit", + "extern mp_limb_t __gmpn_preinv_mod_1(mp_srcptr arg0, mp_size_t arg1, mp_limb_t arg2, mp_limb_t arg3) [free function]" : "__gmpn_preinv_mod_1", + "extern long unsigned int __gmpz_tdiv_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_tdiv_ui", + "int __gmpz_fits_uint_p(mpz_srcptr __gmp_z) [free function]" : "__gmpz_fits_uint_p", "extern void __gmpf_init(mpf_ptr arg0) [free function]" : "__gmpf_init", "extern double __gmpf_get_d_2exp(long int * arg0, mpf_srcptr arg1) [free function]" : "__gmpf_get_d_2exp", "extern void __gmpz_mul(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_mul", "extern void __gmpq_add(mpq_ptr arg0, mpq_srcptr arg1, mpq_srcptr arg2) [free function]" : "__gmpq_add", "extern void __gmpq_set(mpq_ptr arg0, mpq_srcptr arg1) [free function]" : "__gmpq_set", - "extern int __gmpz_fits_sint_p(mpz_srcptr arg0) [free function]" : "__gmpz_fits_sint_p", - "extern long unsigned int __gmpz_cdiv_qr_ui(mpz_ptr arg0, mpz_ptr arg1, mpz_srcptr arg2, long unsigned int arg3) [free function]" : "__gmpz_cdiv_qr_ui", - "extern void __gmpz_clear(mpz_ptr arg0) [free function]" : "__gmpz_clear", - "extern mp_limb_t __gmpn_mul(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, mp_srcptr arg3, mp_size_t arg4) [free function]" : "__gmpn_mul", + "extern long unsigned int __gmpn_scan0(mp_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpn_scan0", + "mp_limb_t __gmpn_sub(mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) [free function]" : "__gmpn_sub", + "extern void __gmpz_fdiv_q_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_fdiv_q_2exp", + "extern void __gmpz_sqrtrem(mpz_ptr arg0, mpz_ptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_sqrtrem", "extern void __gmpz_init_set_si(mpz_ptr arg0, long int arg1) [free function]" : "__gmpz_init_set_si", "extern int __gmpz_divisible_p(mpz_srcptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_divisible_p", "__gmp_errno [variable]" : "__gmp_errno", - "extern void __gmpf_sub_ui(mpf_ptr arg0, mpf_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpf_sub_ui", - "extern int __gmpf_cmp_si(mpf_srcptr arg0, long int arg1) [free function]" : "__gmpf_cmp_si", + "extern void __gmpf_pow_ui(mpf_ptr arg0, mpf_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpf_pow_ui", + "extern void __gmpz_swap(mpz_ptr arg0, mpz_ptr arg1) [free function]" : "__gmpz_swap", "extern int __gmpz_cmp(mpz_srcptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_cmp", "extern void __gmpf_init_set_si(mpf_ptr arg0, long int arg1) [free function]" : "__gmpf_init_set_si", - "extern mp_limb_t __gmpn_lshift(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, unsigned int arg3) [free function]" : "__gmpn_lshift", + "extern long unsigned int __gmpz_tdiv_r_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_tdiv_r_ui", "extern int __gmpq_cmp_si(mpq_srcptr arg0, long int arg1, long unsigned int arg2) [free function]" : "__gmpq_cmp_si", "extern int __gmp_fprintf(FILE * arg0, char const * arg1, ...) [free function]" : "__gmp_fprintf", - "extern void __gmpf_set(mpf_ptr arg0, mpf_srcptr arg1) [free function]" : "__gmpf_set", "extern int __gmpf_fits_sint_p(mpf_srcptr arg0) [free function]" : "__gmpf_fits_sint_p", "extern int __gmpf_cmp_d(mpf_srcptr arg0, double arg1) [free function]" : "__gmpf_cmp_d", - "extern mp_limb_t __gmpn_divexact_by3c(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, mp_limb_t arg3) [free function]" : "__gmpn_divexact_by3c", "extern char * __gmpf_get_str(char * arg0, mp_exp_t * arg1, int arg2, size_t arg3, mpf_srcptr arg4) [free function]" : "__gmpf_get_str", "extern long unsigned int __gmpz_fdiv_q_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_fdiv_q_ui", "extern void __gmpz_urandomb(mpz_ptr arg0, __gmp_randstate_struct * arg1, long unsigned int arg2) [free function]" : "__gmpz_urandomb", "extern char * __gmpz_get_str(char * arg0, int arg1, mpz_srcptr arg2) [free function]" : "__gmpz_get_str", "extern void __gmpz_tdiv_r(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_tdiv_r", "extern void __gmpz_urandomm(mpz_ptr arg0, __gmp_randstate_struct * arg1, mpz_srcptr arg2) [free function]" : "__gmpz_urandomm", - "extern int __gmpz_invert(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_invert", - "mp_limb_t __gmpn_sub_1(mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) [free function]" : "__gmpn_sub_1", + "extern void __gmpq_mul(mpq_ptr arg0, mpq_srcptr arg1, mpq_srcptr arg2) [free function]" : "__gmpq_mul", + "extern void __gmpz_tdiv_q(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_tdiv_q", "extern void __gmpf_sub(mpf_ptr arg0, mpf_srcptr arg1, mpf_srcptr arg2) [free function]" : "__gmpf_sub", - "extern void __gmpz_swap(mpz_ptr arg0, mpz_ptr arg1) [free function]" : "__gmpz_swap", + "extern void __gmpz_set_ui(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_set_ui", + "extern void __gmpz_random(mpz_ptr arg0, mp_size_t arg1) [free function]" : "__gmpz_random", "extern long unsigned int __gmp_urandomb_ui(__gmp_randstate_struct * arg0, long unsigned int arg1) [free function]" : "__gmp_urandomb_ui", - "extern void __gmpz_set_ui(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_set_ui", + "extern void __gmpf_floor(mpf_ptr arg0, mpf_srcptr arg1) [free function]" : "__gmpf_floor", "extern char * __gmpq_get_str(char * arg0, int arg1, mpq_srcptr arg2) [free function]" : "__gmpq_get_str", "extern int __gmpn_perfect_square_p(mp_srcptr arg0, mp_size_t arg1) [free function]" : "__gmpn_perfect_square_p", "extern void __gmpz_addmul(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_addmul", - "extern int __gmp_sprintf(char * arg0, char const * arg1, ...) [free function]" : "__gmp_sprintf", + "extern int __gmpq_cmp(mpq_srcptr arg0, mpq_srcptr arg1) [free function]" : "__gmpq_cmp", + "extern void __gmpz_bin_uiui(mpz_ptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]" : "__gmpz_bin_uiui", "void __gmpz_set_q(mpz_ptr __gmp_w, mpq_srcptr __gmp_u) [free function]" : "__gmpz_set_q", + "extern int __gmpz_congruent_ui_p(mpz_srcptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]" : "__gmpz_congruent_ui_p", "extern void __gmpf_neg(mpf_ptr arg0, mpf_srcptr arg1) [free function]" : "__gmpf_neg", "extern void __gmp_randseed(__gmp_randstate_struct * arg0, mpz_srcptr arg1) [free function]" : "__gmp_randseed", - "extern long unsigned int __gmpz_scan1(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_scan1", + "extern void __gmpz_mul_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_mul_ui", + "extern void __gmpz_init2(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_init2", "extern void __gmpz_nextprime(mpz_ptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_nextprime", + "extern void __gmpz_set_d(mpz_ptr arg0, double arg1) [free function]" : "__gmpz_set_d", + "extern size_t __gmpz_inp_raw(mpz_ptr arg0, FILE * arg1) [free function]" : "__gmpz_inp_raw", + "extern void __gmpz_rrandomb(mpz_ptr arg0, __gmp_randstate_struct * arg1, long unsigned int arg2) [free function]" : "__gmpz_rrandomb", + "extern long unsigned int __gmpz_cdiv_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_cdiv_ui", "extern int __gmpz_si_kronecker(long int arg0, mpz_srcptr arg1) [free function]" : "__gmpz_si_kronecker", - "extern void __gmpf_mul_2exp(mpf_ptr arg0, mpf_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpf_mul_2exp", "extern mp_limb_t __gmpn_divrem_2(mp_ptr arg0, mp_size_t arg1, mp_ptr arg2, mp_size_t arg3, mp_srcptr arg4) [free function]" : "__gmpn_divrem_2", "extern void __gmp_randseed_ui(__gmp_randstate_struct * arg0, long unsigned int arg1) [free function]" : "__gmp_randseed_ui", "extern int __gmpz_kronecker_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_kronecker_ui", @@ -199,18 +205,16 @@ "extern void __gmpz_tdiv_q_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_tdiv_q_2exp", "extern size_t __gmpf_size(mpf_srcptr arg0) [free function]" : "__gmpf_size", "extern void __gmpf_swap(mpf_ptr arg0, mpf_ptr arg1) [free function]" : "__gmpf_swap", - "int __gmpn_cmp(mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) [free function]" : "__gmpn_cmp", - "extern void __gmpf_mul_ui(mpf_ptr arg0, mpf_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpf_mul_ui", + "extern mp_limb_t __gmpn_divrem_1(mp_ptr arg0, mp_size_t arg1, mp_srcptr arg2, mp_size_t arg3, mp_limb_t arg4) [free function]" : "__gmpn_divrem_1", "extern void __gmpq_canonicalize(mpq_ptr arg0) [free function]" : "__gmpq_canonicalize", "long unsigned int __gmpz_popcount(mpz_srcptr __gmp_u) [free function]" : "__gmpz_popcount", "extern void __gmpf_ui_sub(mpf_ptr arg0, long unsigned int arg1, mpf_srcptr arg2) [free function]" : "__gmpf_ui_sub", - "extern void __gmpq_mul_2exp(mpq_ptr arg0, mpq_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpq_mul_2exp", - "extern void __gmpq_mul(mpq_ptr arg0, mpq_srcptr arg1, mpq_srcptr arg2) [free function]" : "__gmpq_mul", + "extern int __gmpz_cmp_si(mpz_srcptr arg0, long int arg1) [free function]" : "__gmpz_cmp_si", "extern int __gmpz_set_str(mpz_ptr arg0, char const * arg1, int arg2) [free function]" : "__gmpz_set_str", - "extern int __gmpz_tstbit(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_tstbit", + "extern void __gmpz_realloc2(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_realloc2", "extern void __gmpz_set_si(mpz_ptr arg0, long int arg1) [free function]" : "__gmpz_set_si", - "extern void __gmpq_init(mpq_ptr arg0) [free function]" : "__gmpq_init", - "extern size_t __gmpz_inp_str(mpz_ptr arg0, FILE * arg1, int arg2) [free function]" : "__gmpz_inp_str", + "int __gmpn_cmp(mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) [free function]" : "__gmpn_cmp", + "extern size_t __gmpz_out_raw(FILE * arg0, mpz_srcptr arg1) [free function]" : "__gmpz_out_raw", "extern int __gmp_sscanf(char const * arg0, char const * arg1, ...) [free function]" : "__gmp_sscanf", "extern int __gmpz_cmpabs_d(mpz_srcptr arg0, double arg1) [free function]" : "__gmpz_cmpabs_d", "extern void * __gmpz_export(void * arg0, size_t * arg1, int arg2, size_t arg3, int arg4, size_t arg5, mpz_srcptr arg6) [free function]" : "__gmpz_export", @@ -221,76 +225,71 @@ "extern size_t __gmpz_sizeinbase(mpz_srcptr arg0, int arg1) [free function]" : "__gmpz_sizeinbase", "extern long unsigned int __gmpz_fdiv_r_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_fdiv_r_ui", "extern void __gmp_randinit_default(__gmp_randstate_struct * arg0) [free function]" : "__gmp_randinit_default", - "mp_limb_t __gmpz_getlimbn(mpz_srcptr __gmp_z, mp_size_t __gmp_n) [free function]" : "__gmpz_getlimbn", "extern long int __gmpf_get_si(mpf_srcptr arg0) [free function]" : "__gmpf_get_si", "extern void __gmpz_init(mpz_ptr arg0) [free function]" : "__gmpz_init", "extern void __gmpf_div_2exp(mpf_ptr arg0, mpf_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpf_div_2exp", - "extern void __gmpz_random(mpz_ptr arg0, mp_size_t arg1) [free function]" : "__gmpz_random", - "extern void __gmpz_tdiv_q(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_tdiv_q", - "extern void __gmpz_ior(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_ior", "extern void __gmpf_set_si(mpf_ptr arg0, long int arg1) [free function]" : "__gmpf_set_si", "extern int __gmpq_equal(mpq_srcptr arg0, mpq_srcptr arg1) [free function]" : "__gmpq_equal", - "extern void __gmpz_rrandomb(mpz_ptr arg0, __gmp_randstate_struct * arg1, long unsigned int arg2) [free function]" : "__gmpz_rrandomb", + "extern void __gmpq_set_num(mpq_ptr arg0, mpz_srcptr arg1) [free function]" : "__gmpq_set_num", "extern void * __gmpz_realloc(mpz_ptr arg0, mp_size_t arg1) [free function]" : "__gmpz_realloc", - "extern long unsigned int __gmpz_tdiv_q_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_tdiv_q_ui", "extern long unsigned int __gmpz_scan0(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_scan0", - "extern void __gmpz_init2(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_init2", + "extern long unsigned int __gmpz_scan1(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_scan1", "extern void __gmpz_random2(mpz_ptr arg0, mp_size_t arg1) [free function]" : "__gmpz_random2", "extern mp_size_t __gmpn_pow_1(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, mp_limb_t arg3, mp_ptr arg4) [free function]" : "__gmpn_pow_1", - "extern long unsigned int __gmpz_cdiv_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_cdiv_ui", - "extern double __gmpq_get_d(mpq_srcptr arg0) [free function]" : "__gmpq_get_d", + "extern void __gmpf_mul_2exp(mpf_ptr arg0, mpf_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpf_mul_2exp", + "extern long unsigned int __gmpn_scan1(mp_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpn_scan1", "extern int __gmpz_fits_slong_p(mpz_srcptr arg0) [free function]" : "__gmpz_fits_slong_p", "extern void __gmpf_mul(mpf_ptr arg0, mpf_srcptr arg1, mpf_srcptr arg2) [free function]" : "__gmpf_mul", - "extern void __gmpz_fdiv_r(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_fdiv_r", "extern void __gmpf_div_ui(mpf_ptr arg0, mpf_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpf_div_ui", - "int __gmpz_fits_ulong_p(mpz_srcptr __gmp_z) [free function]" : "__gmpz_fits_ulong_p", + "extern long unsigned int __gmpn_popcount(mp_srcptr arg0, mp_size_t arg1) [free function]" : "__gmpn_popcount", "extern int __gmpz_fits_sshort_p(mpz_srcptr arg0) [free function]" : "__gmpz_fits_sshort_p", "extern mp_limb_t __gmpn_sub_n(mp_ptr arg0, mp_srcptr arg1, mp_srcptr arg2, mp_size_t arg3) [free function]" : "__gmpn_sub_n", - "extern int __gmpz_cmpabs(mpz_srcptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_cmpabs", - "extern void __gmpz_powm_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2, mpz_srcptr arg3) [free function]" : "__gmpz_powm_ui", + "mp_limb_t __gmpz_getlimbn(mpz_srcptr __gmp_z, mp_size_t __gmp_n) [free function]" : "__gmpz_getlimbn", + "extern void __gmpq_mul_2exp(mpq_ptr arg0, mpq_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpq_mul_2exp", "extern size_t __gmpq_out_str(FILE * arg0, int arg1, mpq_srcptr arg2) [free function]" : "__gmpq_out_str", "void __gmpz_neg(mpz_ptr __gmp_w, mpz_srcptr __gmp_u) [free function]" : "__gmpz_neg", - "extern void __gmpz_sqrtrem(mpz_ptr arg0, mpz_ptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_sqrtrem", "extern long unsigned int __gmpz_tdiv_qr_ui(mpz_ptr arg0, mpz_ptr arg1, mpz_srcptr arg2, long unsigned int arg3) [free function]" : "__gmpz_tdiv_qr_ui", "extern mp_limb_t __gmpn_bdivmod(mp_ptr arg0, mp_ptr arg1, mp_size_t arg2, mp_srcptr arg3, mp_size_t arg4, long unsigned int arg5) [free function]" : "__gmpn_bdivmod", - "extern void __gmpn_random(mp_ptr arg0, mp_size_t arg1) [free function]" : "__gmpn_random", + "extern void __gmpz_powm_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2, mpz_srcptr arg3) [free function]" : "__gmpz_powm_ui", "extern void __gmpq_set_z(mpq_ptr arg0, mpz_srcptr arg1) [free function]" : "__gmpq_set_z", "extern void __gmpz_set(mpz_ptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_set", + "extern void __gmpz_tdiv_r_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_tdiv_r_2exp", "extern long int __gmpz_get_si(mpz_srcptr arg0) [free function]" : "__gmpz_get_si", "extern void __gmpf_init_set(mpf_ptr arg0, mpf_srcptr arg1) [free function]" : "__gmpf_init_set", "extern void __gmpf_init_set_d(mpf_ptr arg0, double arg1) [free function]" : "__gmpf_init_set_d", "extern void __gmpf_reldiff(mpf_ptr arg0, mpf_srcptr arg1, mpf_srcptr arg2) [free function]" : "__gmpf_reldiff", - "extern int __gmpz_cmpabs_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_cmpabs_ui", - "extern long unsigned int __gmpn_popcount(mp_srcptr arg0, mp_size_t arg1) [free function]" : "__gmpn_popcount", + "extern long unsigned int __gmpz_cdiv_r_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_cdiv_r_ui", + "extern void __gmpz_sqrt(mpz_ptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_sqrt", "extern long unsigned int __gmpf_get_ui(mpf_srcptr arg0) [free function]" : "__gmpf_get_ui", - "extern mp_limb_t __gmpn_submul_1(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, mp_limb_t arg3) [free function]" : "__gmpn_submul_1", + "mp_limb_t __gmpn_add_1(mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) [free function]" : "__gmpn_add_1", "extern void __gmp_set_memory_functions(void * (*)( ::size_t ) * arg0, void * (*)( void *,::size_t,::size_t ) * arg1, void (*)( void *,::size_t ) * arg2) [free function]" : "__gmp_set_memory_functions", - "void __gmpz_abs(mpz_ptr __gmp_w, mpz_srcptr __gmp_u) [free function]" : "__gmpz_abs", + "extern void __gmpz_fib2_ui(mpz_ptr arg0, mpz_ptr arg1, long unsigned int arg2) [free function]" : "__gmpz_fib2_ui", "extern int __gmp_printf(char const * arg0, ...) [free function]" : "__gmp_printf", - "extern void __gmpq_set_f(mpq_ptr arg0, mpf_srcptr arg1) [free function]" : "__gmpq_set_f", + "extern void __gmpz_sub(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_sub", "extern void __gmpf_clear(mpf_ptr arg0) [free function]" : "__gmpf_clear", - "extern void __gmpq_set_d(mpq_ptr arg0, double arg1) [free function]" : "__gmpq_set_d", + "extern size_t __gmpn_get_str(unsigned char * arg0, int arg1, mp_ptr arg2, mp_size_t arg3) [free function]" : "__gmpn_get_str", "extern int __gmp_fscanf(FILE * arg0, char const * arg1, ...) [free function]" : "__gmp_fscanf", - "extern mp_limb_t __gmpn_mul_1(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, mp_limb_t arg3) [free function]" : "__gmpn_mul_1", - "extern void __gmpz_cdiv_r(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_cdiv_r", + "mp_limb_t __gmpn_add(mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) [free function]" : "__gmpn_add", + "extern long unsigned int __gmpz_cdiv_qr_ui(mpz_ptr arg0, mpz_ptr arg1, mpz_srcptr arg2, long unsigned int arg3) [free function]" : "__gmpz_cdiv_qr_ui", "extern void __gmpz_bin_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_bin_ui", - "extern mp_limb_t __gmpn_divrem_1(mp_ptr arg0, mp_size_t arg1, mp_srcptr arg2, mp_size_t arg3, mp_limb_t arg4) [free function]" : "__gmpn_divrem_1", - "extern void __gmpz_fdiv_q_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_fdiv_q_2exp", + "extern mp_size_t __gmpn_gcd(mp_ptr arg0, mp_ptr arg1, mp_size_t arg2, mp_ptr arg3, mp_size_t arg4) [free function]" : "__gmpn_gcd", + "extern void __gmpz_clear(mpz_ptr arg0) [free function]" : "__gmpz_clear", "extern void __gmpf_dump(mpf_srcptr arg0) [free function]" : "__gmpf_dump", "extern void __gmp_randinit_mt(__gmp_randstate_struct * arg0) [free function]" : "__gmp_randinit_mt", "extern void __gmpz_submul_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_submul_ui", - "extern long unsigned int __gmpz_cdiv_q_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_cdiv_q_ui", + "extern mp_limb_t __gmpn_divexact_by3c(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, mp_limb_t arg3) [free function]" : "__gmpn_divexact_by3c", "extern void __gmpz_dump(mpz_srcptr arg0) [free function]" : "__gmpz_dump", "extern int __gmpz_jacobi(mpz_srcptr arg0, mpz_srcptr arg1) [free function]" : "__gmpz_jacobi", "__gmp_version [variable]" : "__gmp_version", "extern int __gmpf_integer_p(mpf_srcptr arg0) [free function]" : "__gmpf_integer_p", - "extern int __gmpz_cmp_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]" : "__gmpz_cmp_ui", - "extern int __gmpz_kronecker_si(mpz_srcptr arg0, long int arg1) [free function]" : "__gmpz_kronecker_si", - "extern void __gmpf_pow_ui(mpf_ptr arg0, mpf_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpf_pow_ui", + "extern void __gmpf_set_default_prec(long unsigned int arg0) [free function]" : "__gmpf_set_default_prec", + "extern int __gmpz_congruent_p(mpz_srcptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]" : "__gmpz_congruent_p", + "extern void __gmpn_random(mp_ptr arg0, mp_size_t arg1) [free function]" : "__gmpn_random", + "extern void __gmpf_sub_ui(mpf_ptr arg0, mpf_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpf_sub_ui", "extern void __gmpz_lcm_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_lcm_ui", "extern void __gmpz_rootrem(mpz_ptr arg0, mpz_ptr arg1, mpz_srcptr arg2, long unsigned int arg3) [free function]" : "__gmpz_rootrem", "extern void __gmpz_lucnum2_ui(mpz_ptr arg0, mpz_ptr arg1, long unsigned int arg2) [free function]" : "__gmpz_lucnum2_ui", - "extern int __gmpz_perfect_power_p(mpz_srcptr arg0) [free function]" : "__gmpz_perfect_power_p", + "extern void __gmpf_set(mpf_ptr arg0, mpf_srcptr arg1) [free function]" : "__gmpf_set", "void __gmpq_abs(mpq_ptr __gmp_w, mpq_srcptr __gmp_u) [free function]" : "__gmpq_abs", "extern long unsigned int __gmpn_hamdist(mp_srcptr arg0, mp_srcptr arg1, mp_size_t arg2) [free function]" : "__gmpn_hamdist", "extern int __gmpf_fits_ushort_p(mpf_srcptr arg0) [free function]" : "__gmpf_fits_ushort_p", @@ -299,99 +298,95 @@ "extern void __gmpf_abs(mpf_ptr arg0, mpf_srcptr arg1) [free function]" : "__gmpf_abs", "extern void __gmp_get_memory_functions(void * (*)( ::size_t ) * * arg0, void * (*)( void *,::size_t,::size_t ) * * arg1, void (*)( void *,::size_t ) * * arg2) [free function]" : "__gmp_get_memory_functions", "extern void __gmpf_ui_div(mpf_ptr arg0, long unsigned int arg1, mpf_srcptr arg2) [free function]" : "__gmpf_ui_div", - "extern mp_size_t __gmpn_gcd(mp_ptr arg0, mp_ptr arg1, mp_size_t arg2, mp_ptr arg3, mp_size_t arg4) [free function]" : "__gmpn_gcd", + "extern void __gmpq_get_num(mpz_ptr arg0, mpq_srcptr arg1) [free function]" : "__gmpq_get_num", "extern mp_limb_t __gmpn_add_n(mp_ptr arg0, mp_srcptr arg1, mp_srcptr arg2, mp_size_t arg3) [free function]" : "__gmpn_add_n", - "extern mp_limb_t __gmpn_preinv_mod_1(mp_srcptr arg0, mp_size_t arg1, mp_limb_t arg2, mp_limb_t arg3) [free function]" : "__gmpn_preinv_mod_1", - "extern int __gmpz_congruent_ui_p(mpz_srcptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]" : "__gmpz_congruent_ui_p", + "extern mp_limb_t __gmpn_mul(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, mp_srcptr arg3, mp_size_t arg4) [free function]" : "__gmpn_mul", + "extern int __gmpz_perfect_power_p(mpz_srcptr arg0) [free function]" : "__gmpz_perfect_power_p", + "int __gmpz_fits_ulong_p(mpz_srcptr __gmp_z) [free function]" : "__gmpz_fits_ulong_p", "extern void __gmpq_clear(mpq_ptr arg0) [free function]" : "__gmpq_clear", "extern void __gmpf_ceil(mpf_ptr arg0, mpf_srcptr arg1) [free function]" : "__gmpf_ceil", "extern void __gmpz_fdiv_qr(mpz_ptr arg0, mpz_ptr arg1, mpz_srcptr arg2, mpz_srcptr arg3) [free function]" : "__gmpz_fdiv_qr", - "extern void __gmpf_set_prec(mpf_ptr arg0, long unsigned int arg1) [free function]" : "__gmpf_set_prec", + "extern void __gmpf_mul_ui(mpf_ptr arg0, mpf_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpf_mul_ui", "extern void __gmpz_combit(mpz_ptr arg0, long unsigned int arg1) [free function]" : "__gmpz_combit", "extern void __gmpz_addmul_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]" : "__gmpz_addmul_ui", "extern size_t __gmpf_inp_str(mpf_ptr arg0, FILE * arg1, int arg2) [free function]" : "__gmpf_inp_str", "extern int __gmpf_init_set_str(mpf_ptr arg0, char const * arg1, int arg2) [free function]" : "__gmpf_init_set_str", "__gmpf_get_d" : "extern double __gmpf_get_d(mpf_srcptr arg0) [free function]", "__gmpf_cmp_ui" : "extern int __gmpf_cmp_ui(mpf_srcptr arg0, long unsigned int arg1) [free function]", - "__gmpz_mul_ui" : "extern void __gmpz_mul_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", + "__gmpz_fac_ui" : "extern void __gmpz_fac_ui(mpz_ptr arg0, long unsigned int arg1) [free function]", "__gmpz_and" : "extern void __gmpz_and(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]", "__gmpf_urandomb" : "extern void __gmpf_urandomb(__mpf_struct * arg0, __gmp_randstate_struct * arg1, long unsigned int arg2) [free function]", - "__gmpz_fib2_ui" : "extern void __gmpz_fib2_ui(mpz_ptr arg0, mpz_ptr arg1, long unsigned int arg2) [free function]", + "__gmpn_mul_1" : "extern mp_limb_t __gmpn_mul_1(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, mp_limb_t arg3) [free function]", "__gmpz_mul_2exp" : "extern void __gmpz_mul_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", "__gmpz_clrbit" : "extern void __gmpz_clrbit(mpz_ptr arg0, long unsigned int arg1) [free function]", "__gmpz_cdiv_r_2exp" : "extern void __gmpz_cdiv_r_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", - "__gmpz_init_set_str" : "extern int __gmpz_init_set_str(mpz_ptr arg0, char const * arg1, int arg2) [free function]", + "__gmpz_lcm" : "extern void __gmpz_lcm(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]", "__gmpz_gcd" : "extern void __gmpz_gcd(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]", - "__gmpq_set_ui" : "extern void __gmpq_set_ui(mpq_ptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]", - "__gmpz_cmp_si" : "extern int __gmpz_cmp_si(mpz_srcptr arg0, long int arg1) [free function]", + "__gmpz_divisible_2exp_p" : "extern int __gmpz_divisible_2exp_p(mpz_srcptr arg0, long unsigned int arg1) [free function]", "__gmpz_congruent_2exp_p" : "extern int __gmpz_congruent_2exp_p(mpz_srcptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", "__gmpz_pow_ui" : "extern void __gmpz_pow_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", "__gmpq_neg" : "void __gmpq_neg(mpq_ptr __gmp_w, mpq_srcptr __gmp_u) [free function]", "__gmpz_import" : "extern void __gmpz_import(mpz_ptr arg0, size_t arg1, int arg2, size_t arg3, int arg4, size_t arg5, void const * arg6) [free function]", - "__gmpz_fac_ui" : "extern void __gmpz_fac_ui(mpz_ptr arg0, long unsigned int arg1) [free function]", + "__gmpz_fdiv_ui" : "extern long unsigned int __gmpz_fdiv_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]", "__gmpz_root" : "extern int __gmpz_root(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", "__gmpz_fdiv_q" : "extern void __gmpz_fdiv_q(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]", - "__gmpq_div_2exp" : "extern void __gmpq_div_2exp(mpq_ptr arg0, mpq_srcptr arg1, long unsigned int arg2) [free function]", + "__gmpz_fdiv_r" : "extern void __gmpz_fdiv_r(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]", "__gmpq_inp_str" : "extern size_t __gmpq_inp_str(mpq_ptr arg0, FILE * arg1, int arg2) [free function]", "__gmpz_ui_kronecker" : "extern int __gmpz_ui_kronecker(long unsigned int arg0, mpz_srcptr arg1) [free function]", - "__gmpz_cdiv_r_ui" : "extern long unsigned int __gmpz_cdiv_r_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", "__gmpz_remove" : "extern long unsigned int __gmpz_remove(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]", - "__gmpz_realloc2" : "extern void __gmpz_realloc2(mpz_ptr arg0, long unsigned int arg1) [free function]", + "__gmpz_tstbit" : "extern int __gmpz_tstbit(mpz_srcptr arg0, long unsigned int arg1) [free function]", "__gmpn_tdiv_qr" : "extern void __gmpn_tdiv_qr(mp_ptr arg0, mp_ptr arg1, mp_size_t arg2, mp_srcptr arg3, mp_size_t arg4, mp_srcptr arg5, mp_size_t arg6) [free function]", "__gmpz_fdiv_r_2exp" : "extern void __gmpz_fdiv_r_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", "__gmpf_div" : "extern void __gmpf_div(mpf_ptr arg0, mpf_srcptr arg1, mpf_srcptr arg2) [free function]", "__gmpq_div" : "extern void __gmpq_div(mpq_ptr arg0, mpq_srcptr arg1, mpq_srcptr arg2) [free function]", - "__gmpf_get_default_prec" : "extern long unsigned int __gmpf_get_default_prec() [free function]", + "__gmpz_ui_pow_ui" : "extern void __gmpz_ui_pow_ui(mpz_ptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]", "__gmpq_sub" : "extern void __gmpq_sub(mpq_ptr arg0, mpq_srcptr arg1, mpq_srcptr arg2) [free function]", "__gmpf_set_ui" : "extern void __gmpf_set_ui(mpf_ptr arg0, long unsigned int arg1) [free function]", - "__gmpn_add_1" : "mp_limb_t __gmpn_add_1(mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) [free function]", + "__gmpn_lshift" : "extern mp_limb_t __gmpn_lshift(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, unsigned int arg3) [free function]", "__gmpz_add" : "extern void __gmpz_add(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]", "__gmpf_trunc" : "extern void __gmpf_trunc(mpf_ptr arg0, mpf_srcptr arg1) [free function]", "__gmpz_divexact_ui" : "extern void __gmpz_divexact_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", "__gmpz_gcd_ui" : "extern long unsigned int __gmpz_gcd_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", - "__gmpz_out_raw" : "extern size_t __gmpz_out_raw(FILE * arg0, mpz_srcptr arg1) [free function]", - "__gmpn_sub" : "mp_limb_t __gmpn_sub(mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) [free function]", + "__gmpz_cdiv_r" : "extern void __gmpz_cdiv_r(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]", + "__gmpz_inp_str" : "extern size_t __gmpz_inp_str(mpz_ptr arg0, FILE * arg1, int arg2) [free function]", + "__gmpq_get_d" : "extern double __gmpq_get_d(mpq_srcptr arg0) [free function]", + "__gmp_sprintf" : "extern int __gmp_sprintf(char * arg0, char const * arg1, ...) [free function]", "__gmpn_random2" : "extern void __gmpn_random2(mp_ptr arg0, mp_size_t arg1) [free function]", "__gmpz_cdiv_q_2exp" : "extern void __gmpz_cdiv_q_2exp(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", "__gmpf_eq" : "extern int __gmpf_eq(mpf_srcptr arg0, mpf_srcptr arg1, long unsigned int arg2) [free function]", "__gmpn_divrem" : "extern mp_limb_t __gmpn_divrem(mp_ptr arg0, mp_size_t arg1, mp_ptr arg2, mp_size_t arg3, mp_srcptr arg4, mp_size_t arg5) [free function]", "__gmpz_cdiv_q" : "extern void __gmpz_cdiv_q(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]", - "__gmpz_init_set" : "extern void __gmpz_init_set(mpz_ptr arg0, mpz_srcptr arg1) [free function]", + "__gmpz_abs" : "void __gmpz_abs(mpz_ptr __gmp_w, mpz_srcptr __gmp_u) [free function]", "__gmpz_xor" : "extern void __gmpz_xor(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]", - "__gmpz_sqrt" : "extern void __gmpz_sqrt(mpz_ptr arg0, mpz_srcptr arg1) [free function]", "__gmpz_init_set_d" : "extern void __gmpz_init_set_d(mpz_ptr arg0, double arg1) [free function]", "__gmpz_fits_ushort_p" : "int __gmpz_fits_ushort_p(mpz_srcptr __gmp_z) [free function]", - "__gmpz_sub" : "extern void __gmpz_sub(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]", + "__gmpq_set_f" : "extern void __gmpq_set_f(mpq_ptr arg0, mpf_srcptr arg1) [free function]", "__gmpf_fits_ulong_p" : "extern int __gmpf_fits_ulong_p(mpf_srcptr arg0) [free function]", - "__gmpf_random2" : "extern void __gmpf_random2(mpf_ptr arg0, mp_size_t arg1, mp_exp_t arg2) [free function]", "__gmpz_get_ui" : "long unsigned int __gmpz_get_ui(mpz_srcptr __gmp_z) [free function]", + "__gmpz_cmpabs_ui" : "extern int __gmpz_cmpabs_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]", "__gmp_urandomm_ui" : "extern long unsigned int __gmp_urandomm_ui(__gmp_randstate_struct * arg0, long unsigned int arg1) [free function]", "__gmpz_perfect_square_p" : "int __gmpz_perfect_square_p(mpz_srcptr __gmp_a) [free function]", - "__gmpn_get_str" : "extern size_t __gmpn_get_str(unsigned char * arg0, int arg1, mp_ptr arg2, mp_size_t arg3) [free function]", + "__gmpq_set_d" : "extern void __gmpq_set_d(mpq_ptr arg0, double arg1) [free function]", "__gmpz_cmp_d" : "extern int __gmpz_cmp_d(mpz_srcptr arg0, double arg1) [free function]", "__gmpz_cdiv_qr" : "extern void __gmpz_cdiv_qr(mpz_ptr arg0, mpz_ptr arg1, mpz_srcptr arg2, mpz_srcptr arg3) [free function]", "__gmpf_add" : "extern void __gmpf_add(mpf_ptr arg0, mpf_srcptr arg1, mpf_srcptr arg2) [free function]", "__gmpz_probab_prime_p" : "extern int __gmpz_probab_prime_p(mpz_srcptr arg0, int arg1) [free function]", "__gmpn_rshift" : "extern mp_limb_t __gmpn_rshift(mp_ptr arg0, mp_srcptr arg1, mp_size_t arg2, unsigned int arg3) [free function]", "__gmpz_array_init" : "extern void __gmpz_array_init(mpz_ptr arg0, mp_size_t arg1, mp_size_t arg2) [free function]", - "__gmpz_fits_uint_p" : "int __gmpz_fits_uint_p(mpz_srcptr __gmp_z) [free function]", - "__gmpz_bin_uiui" : "extern void __gmpz_bin_uiui(mpz_ptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]", - "__gmpz_tdiv_r_ui" : "extern long unsigned int __gmpz_tdiv_r_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", + "__gmpf_get_default_prec" : "extern long unsigned int __gmpf_get_default_prec() [free function]", + "__gmpf_random2" : "extern void __gmpf_random2(mpf_ptr arg0, mp_size_t arg1, mp_exp_t arg2) [free function]", "__gmp_randinit_set" : "extern void __gmp_randinit_set(__gmp_randstate_struct * arg0, __gmp_randstate_struct const * arg1) [free function]", - "__gmpz_tdiv_ui" : "extern long unsigned int __gmpz_tdiv_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]", "__gmpq_inv" : "extern void __gmpq_inv(mpq_ptr arg0, mpq_srcptr arg1) [free function]", "__gmpn_set_str" : "extern mp_size_t __gmpn_set_str(mp_ptr arg0, unsigned char const * arg1, size_t arg2, int arg3) [free function]", - "__gmpz_lcm" : "extern void __gmpz_lcm(mpz_ptr arg0, mpz_srcptr arg1, mpz_srcptr arg2) [free function]", - "__gmpn_scan0" : "extern long unsigned int __gmpn_scan0(mp_srcptr arg0, long unsigned int arg1) [free function]", - "__gmpn_scan1" : "extern long unsigned int __gmpn_scan1(mp_srcptr arg0, long unsigned int arg1) [free function]", + "__gmp_randinit" : "extern void __gmp_randinit(__gmp_randstate_struct * arg0, gmp_randalg_t arg1, ...) [free function]", + "__gmpn_sqrtrem" : "extern mp_size_t __gmpn_sqrtrem(mp_ptr arg0, mp_ptr arg1, mp_srcptr arg2, mp_size_t arg3) [free function]", "__gmpz_fdiv_qr_ui" : "extern long unsigned int __gmpz_fdiv_qr_ui(mpz_ptr arg0, mpz_ptr arg1, mpz_srcptr arg2, long unsigned int arg3) [free function]", "__gmpf_init_set_ui" : "extern void __gmpf_init_set_ui(mpf_ptr arg0, long unsigned int arg1) [free function]", "__gmpn_mul_n" : "extern void __gmpn_mul_n(mp_ptr arg0, mp_srcptr arg1, mp_srcptr arg2, mp_size_t arg3) [free function]", "__gmpq_cmp_ui" : "extern int __gmpq_cmp_ui(mpq_srcptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]", "__gmpz_mul_si" : "extern void __gmpz_mul_si(mpz_ptr arg0, mpz_srcptr arg1, long int arg2) [free function]", "__gmpq_set_si" : "extern void __gmpq_set_si(mpq_ptr arg0, long int arg1, long unsigned int arg2) [free function]", - "__gmpz_divisible_2exp_p" : "extern int __gmpz_divisible_2exp_p(mpz_srcptr arg0, long unsigned int arg1) [free function]", - "__gmpn_add" : "mp_limb_t __gmpn_add(mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) [free function]", + "__gmpq_set_ui" : "extern void __gmpq_set_ui(mpq_ptr arg0, long unsigned int arg1, long unsigned int arg2) [free function]", "__gmpf_sqrt_ui" : "extern void __gmpf_sqrt_ui(mpf_ptr arg0, long unsigned int arg1) [free function]", "__gmpz_init_set_ui" : "extern void __gmpz_init_set_ui(mpz_ptr arg0, long unsigned int arg1) [free function]", "__gmpz_divisible_ui_p" : "extern int __gmpz_divisible_ui_p(mpz_srcptr arg0, long unsigned int arg1) [free function]", @@ -400,101 +395,112 @@ "__gmpz_sub_ui" : "extern void __gmpz_sub_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]", "__gmpz_divexact" : "extern void __gmpz_... [truncated message content] |
From: <rom...@us...> - 2009-08-08 19:00:59
|
Revision: 1746 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1746&view=rev Author: roman_yakovenko Date: 2009-08-08 19:00:48 +0000 (Sat, 08 Aug 2009) Log Message: ----------- making ctypes code generator treat right struct dependencies Modified Paths: -------------- pyplusplus_dev/examples/gmplib_dev/pygmplib/__init__.py pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py pyplusplus_dev/pyplusplus/creators_factory/sort_algorithms.py Modified: pyplusplus_dev/examples/gmplib_dev/pygmplib/__init__.py =================================================================== --- pyplusplus_dev/examples/gmplib_dev/pygmplib/__init__.py 2009-08-08 06:08:18 UTC (rev 1745) +++ pyplusplus_dev/examples/gmplib_dev/pygmplib/__init__.py 2009-08-08 19:00:48 UTC (rev 1746) @@ -633,6 +633,9 @@ def __init__( self, *args, **keywd ): raise RuntimeError( "Unable to create instance of opaque type." ) +class __mpz_struct(ctypes.Structure): + """class __mpz_struct""" + class __gmp_randstate_struct(ctypes.Structure): """class __gmp_randstate_struct""" @@ -645,27 +648,12 @@ class __mpq_struct(ctypes.Structure): """class __mpq_struct""" -class __mpz_struct(ctypes.Structure): - """class __mpz_struct""" - -__mpq_struct._fields_ = [ #class __mpq_struct - ("_mp_num", __mpz_struct), - ("_mp_den", __mpz_struct), -] - __mpz_struct._fields_ = [ #class __mpz_struct ("_mp_alloc", ctypes.c_int), ("_mp_size", ctypes.c_int), ("_mp_d", ctypes.POINTER( ctypes.c_ulong )), ] -__mpf_struct._fields_ = [ #class __mpf_struct - ("_mp_prec", ctypes.c_int), - ("_mp_size", ctypes.c_int), - ("_mp_exp", ctypes.c_long), - ("_mp_d", ctypes.POINTER( ctypes.c_ulong )), -] - __gmp_randstate_struct._._fields_ = [ #class __gmp_randstate_struct ("_mp_lc", ctypes.c_void_p), ] @@ -677,6 +665,18 @@ ("_mp_algdata", __gmp_randstate_struct._), ] +__mpf_struct._fields_ = [ #class __mpf_struct + ("_mp_prec", ctypes.c_int), + ("_mp_size", ctypes.c_int), + ("_mp_exp", ctypes.c_long), + ("_mp_d", ctypes.POINTER( ctypes.c_ulong )), +] + +__mpq_struct._fields_ = [ #class __mpq_struct + ("_mp_num", __mpz_struct), + ("_mp_den", __mpz_struct), +] + gmpq_add_type = ctypes.CFUNCTYPE( None, ctypes.POINTER( __mpq_struct ), ctypes.POINTER( __mpq_struct ), ctypes.POINTER( __mpq_struct ) ) gmpq_add = gmpq_add_type( ( libgmp_lib.undecorated_names["extern void __gmpq_add(mpq_ptr arg0, mpq_srcptr arg1, mpq_srcptr arg2) [free function]"], libgmp_lib ) ) Modified: pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py =================================================================== --- pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2009-08-08 06:08:18 UTC (rev 1745) +++ pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2009-08-08 19:00:48 UTC (rev 1746) @@ -70,29 +70,6 @@ return decl in self.__exported_decls return True - #~ def __prepare_decls( self, global_ns ): - #~ to_be_exposed = [] - #~ for decl in declarations.make_flatten( global_ns ): - #~ if decl.ignore: - #~ continue - - #~ if not decl.exportable: - #~ #leave only decls that user wants to export and that could be exported - #~ self.__print_readme( decl ) - #~ continue - - #~ if decl.already_exposed: - #~ #check wether this is already exposed in other module - #~ continue - - #~ if isinstance( decl.parent, declarations.namespace_t ): - #~ #leave only declarations defined under namespace, but remove namespaces - #~ to_be_exposed.append( decl ) - - #~ self.__print_readme( decl ) - - #~ return to_be_exposed - def __contains_exported( self, decl ): return bool( decl.decls( self.__should_generate_code, recursive=True, allow_empty=True ) ) @@ -104,10 +81,13 @@ self.__class2introduction[ class_ ] = ci_creator cc.adopt_creator( ci_creator ) classes = class_.classes( recursive=False, allow_empty=True) - classes = sort_algorithms.sort_classes( classes ) + classes = sort_algorithms.sort_classes( classes, include_vars=True ) for internal_class in classes: self.__add_class_introductions( ci_creator, internal_class ) + if not class_.opaque: + self.__class_defs_ccs.adopt_creator( code_creators.fields_definition_t( class_ ) ) + def create(self ): """ create and return the module for the extension - code creators tree root @@ -134,7 +114,7 @@ f = lambda cls: self.__should_generate_code( cls ) \ and isinstance( cls.parent, declarations.namespace_t ) ns_classes = self.global_ns.classes( f, recursive=True, allow_empty=True) - ns_classes = sort_algorithms.sort_classes( ns_classes ) + ns_classes = sort_algorithms.sort_classes( ns_classes, include_vars=True ) for class_ in ns_classes: self.__add_class_introductions( self.__class_ccs, class_ ) @@ -241,9 +221,6 @@ self.curr_decl = decl declarations.apply_visitor( self, decl ) self.curr_decl = class_ - #fields definition should be recursive using the visitor - #internal classes fields should be defined first - self.__class_defs_ccs.adopt_creator( code_creators.fields_definition_t( self.curr_decl ) ) else: cls_intro_cc = self.__class2introduction[ self.curr_decl ] cls_intro_cc.adopt_creator( code_creators.opaque_init_introduction_t( self.curr_decl ) ) Modified: pyplusplus_dev/pyplusplus/creators_factory/sort_algorithms.py =================================================================== --- pyplusplus_dev/pyplusplus/creators_factory/sort_algorithms.py 2009-08-08 06:08:18 UTC (rev 1745) +++ pyplusplus_dev/pyplusplus/creators_factory/sort_algorithms.py 2009-08-08 19:00:48 UTC (rev 1746) @@ -12,9 +12,10 @@ BLACK = 2 class class_organizer_t(object): - def __init__( self, decls ): + def __init__( self, decls, include_vars=False): object.__init__( self ) + self.__include_vars = include_vars self.__classes = filter( lambda x: isinstance( x, declarations.class_t ) , decls ) self.__classes.sort( lambda cls1, cls2: cmp( cls1.decl_string, cls2.decl_string ) ) @@ -66,6 +67,19 @@ if top_class_inst: i_depend_on_them.add( full_name( top_class_inst ) ) + if self.__include_vars: + vars = filter( lambda decl: isinstance( decl, declarations.variable_t ) + , declarations.make_flatten( class_ )) + for var in vars: + if declarations.is_pointer( var.type ): + continue + base_type = declarations.base_type( var.type ) + if not isinstance( base_type, declarations.declarated_t ): + continue + top_class_inst = self.__get_top_class_inst( base_type.declaration ) + if top_class_inst: + i_depend_on_them.add( full_name( top_class_inst ) ) + for internal_cls in class_.classes(allow_empty=True): internal_cls_dependencies = self.__find_out_class_dependencies( internal_cls ) i_depend_on_them.update( internal_cls_dependencies ) @@ -170,8 +184,8 @@ result = self.__join_groups(groups) return result -def sort_classes( classes ): - organizer = class_organizer_t( classes ) +def sort_classes( classes, include_vars=False ): + organizer = class_organizer_t( classes, include_vars=include_vars ) return organizer.desired_order() def sort_calldefs( decls ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-08-08 19:57:53
|
Revision: 1748 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1748&view=rev Author: roman_yakovenko Date: 2009-08-08 19:57:28 +0000 (Sat, 08 Aug 2009) Log Message: ----------- ctypes code generator cleanup Modified Paths: -------------- pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py pyplusplus_dev/unittests/ctypes_tester.py pyplusplus_dev/unittests/sconstruct Modified: pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py =================================================================== --- pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2009-08-08 19:53:41 UTC (rev 1747) +++ pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2009-08-08 19:57:28 UTC (rev 1748) @@ -131,69 +131,15 @@ return self.module def visit_member_function( self ): - self.__dependencies_manager.add_exported( self.curr_decl ) - md_cc = self.__class2methods_def[ self.curr_decl.parent ] - cls_intro_cc = self.__class2introduction[ self.curr_decl.parent ] - mem_fun_def_cc = code_creators.mem_fun_definition_t( self.curr_decl ) - #TODO: calculate only exported functions - if 0 == len( self.curr_decl.overloads): - #this is the first and the last and the only class constructor - md_cc.adopt_creator( mem_fun_def_cc ) - cls_intro_cc.adopt_creator( code_creators.mem_fun_introduction_t(self.curr_decl) ) - else: - has_introduction = cls_intro_cc.find_by_creator_class( code_creators.mem_fun_introduction_t, unique=False ) - has_introduction = filter( lambda cc: cc.alias == mem_fun_def_cc.alias, has_introduction ) - if not has_introduction: - cls_intro_cc.adopt_creator( code_creators.mem_fun_introduction_t(self.curr_decl) ) - - multi_method_def = md_cc.find_mutli_method( mem_fun_def_cc.alias ) - if not multi_method_def: - multi_method_def = code_creators.multi_method_definition_t () - md_cc.adopt_creator( multi_method_def ) - multi_method_def.adopt_creator( mem_fun_def_cc ) - - #~ if self.curr_decl.virtuality == VIRTUALITY_TYPES.NOT_VIRTUAL: - #~ cls_intro_cc.adopt_creator( code_creators.mem_fun_introduction_t( self.curr_decl ) ) - #~ elif self.curr_decl.virtuality == VIRTUALITY_TYPES.VIRTUAL: - #~ cls_intro_cc.adopt_creator( code_creators.vmem_fun_introduction_t( self.curr_decl ) ) - #~ else: - #~ pass - + pass #c code doesn't have member functions def visit_constructor( self ): - self.__dependencies_manager.add_exported( self.curr_decl ) - md_cc = self.__class2methods_def[ self.curr_decl.parent ] - cls_intro_cc = self.__class2introduction[ self.curr_decl.parent ] - init_def_cc = code_creators.init_definition_t( self.curr_decl ) - #TODO: calculate only exported constructors - if 0 == len( self.curr_decl.overloads): - #this is the first and the last and the only class constructor - md_cc.adopt_creator( init_def_cc ) - cls_intro_cc.adopt_creator( code_creators.init_introduction_t(self.curr_decl) ) - else: - has_constructor = cls_intro_cc.find_by_creator_class( code_creators.init_introduction_t ) - if not has_constructor: - cls_intro_cc.adopt_creator( code_creators.init_introduction_t(self.curr_decl) ) - - multi_method_def = md_cc.find_mutli_method( init_def_cc.alias ) - if not multi_method_def: - multi_method_def = code_creators.multi_method_definition_t () - md_cc.adopt_creator( multi_method_def ) - multi_method_def.adopt_creator( init_def_cc ) - + pass #c code doesn't have member functions def visit_destructor( self ): - self.__dependencies_manager.add_exported( self.curr_decl ) - cls_intro_cc = self.__class2introduction[ self.curr_decl.parent ] - cls_intro_cc.adopt_creator( code_creators.del_introduction_t( self.curr_decl ) ) - - md_cc = self.__class2methods_def[ self.curr_decl.parent ] - md_cc.adopt_creator( code_creators.del_definition_t( self.curr_decl ) ) - + pass #c code doesn't have member functions def visit_member_operator( self ): - self.__dependencies_manager.add_exported( self.curr_decl ) - + pass #c code doesn't have member functions def visit_casting_operator( self ): - self.__dependencies_manager.add_exported( self.curr_decl ) - + pass #c code doesn't have member functions def visit_free_function( self ): self.__dependencies_manager.add_exported( self.curr_decl ) self.curr_code_creator.adopt_creator( code_creators.function_definition_t( self.curr_decl ) ) @@ -208,11 +154,10 @@ def visit_class(self): self.__dependencies_manager.add_exported( self.curr_decl ) - if not self.curr_decl.opaque: - if self.curr_decl.calldefs( self.__should_generate_code, recursive=False, allow_empty=True ): - md_cc = code_creators.methods_definition_t( self.curr_decl ) - self.__class2methods_def[ self.curr_decl ] = md_cc - self.__class_defs_ccs.adopt_creator( md_cc ) + if self.curr_decl.opaque: + cls_intro_cc = self.__class2introduction[ self.curr_decl ] + cls_intro_cc.adopt_creator( code_creators.opaque_init_introduction_t( self.curr_decl ) ) + else: class_ = self.curr_decl for decl in self.curr_decl.decls( recursive=False, allow_empty=True ): if isinstance( decl, declarations.variable_t ): @@ -221,9 +166,6 @@ self.curr_decl = decl declarations.apply_visitor( self, decl ) self.curr_decl = class_ - else: - cls_intro_cc = self.__class2introduction[ self.curr_decl ] - cls_intro_cc.adopt_creator( code_creators.opaque_init_introduction_t( self.curr_decl ) ) def visit_enumeration(self): self.__dependencies_manager.add_exported( self.curr_decl ) Modified: pyplusplus_dev/unittests/ctypes_tester.py =================================================================== --- pyplusplus_dev/unittests/ctypes_tester.py 2009-08-08 19:53:41 UTC (rev 1747) +++ pyplusplus_dev/unittests/ctypes_tester.py 2009-08-08 19:57:28 UTC (rev 1748) @@ -77,43 +77,8 @@ return sys.modules[ self.base_name ] -class pof_tester_t( ctypes_base_tester_t ): - def __init__( self, *args, **keywd ): - ctypes_base_tester_t.__init__( self, 'pof', *args, **keywd ) - def test_constructors(self): - n0 = self.module_ref.pof.number_t() - self.failUnless( 0 == n0.get_value() ) - n1 = self.module_ref.pof.number_t( ctypes.c_long(32) ) - self.failUnless( 32 == n1.get_value() ) - n2 = self.module_ref.pof.number_t( ctypes.pointer(n1) ) - self.failUnless( 32 == n2.get_value() ) - def test_free_functions(self): - #the following code fails - difference in the calling conventions - #TODO: the following test failes, because of the wrong calling convention used - self.failUnless( self.module_ref.identity_cpp( int(111) ) == 111 ) - - def test_get_set_values( self ): - n0 = self.module_ref.pof.number_t() - n0.set_value( 1977 ) - self.failUnless( 1977 == n0.get_value() ) - - #the following functionality is still missing - #~ def test_operator_assign( self ): - #~ obj1 = number_t(1) - #~ obj2 = number_t(2) - #~ x = obj1.operator_assign( obj2 ) - #~ #there are special cases, where ctypes could introduce "optimized" behaviour and not create new python object - #~ self.failUnless( x is obj1 ) - #~ self.failUnless( obj1.m_value == obj2.m_value ) - - #~ def test_clone( self ): - #~ obj1 = number_t(1) - #~ obj2 = obj1.clone() - #~ self.fail( obj1.get_value() == obj2.get_value() ) - - class issues_tester_t( ctypes_base_tester_t ): def __init__( self, *args, **keywd ): ctypes_base_tester_t.__init__( self, 'issues', *args, **keywd ) @@ -208,16 +173,6 @@ def test(self): self.failUnless( 21 == self.module_ref.sum_ints( 3, 5,7,9) ) -class templates_tester_t( ctypes_base_tester_t ): - def __init__( self, *args, **keywd ): - ctypes_base_tester_t.__init__( self, 'templates', *args, **keywd ) - - def customize( self, mb ): - mb.class_( 'value_t<int>' ).alias = 'int_value_t' - - def test(self): - pass - class circular_references_tester_t( ctypes_base_tester_t ): def __init__( self, *args, **keywd ): ctypes_base_tester_t.__init__( self, 'circular_references', *args, **keywd ) @@ -236,17 +191,12 @@ def create_suite(): #part of this functionality is going to be deprecated suite = unittest.TestSuite() - return suite - #~ if 'win' in sys.platform: - #~ suite.addTest( unittest.makeSuite(pof_tester_t)) - #~ suite.addTest( unittest.makeSuite(issues_tester_t)) suite.addTest( unittest.makeSuite(enums_tester_t)) suite.addTest( unittest.makeSuite(opaque_tester_t)) suite.addTest( unittest.makeSuite(include_algorithm_tester_t)) suite.addTest( unittest.makeSuite(anonymous_tester_t)) suite.addTest( unittest.makeSuite(variables_tester_t)) suite.addTest( unittest.makeSuite(varargs_tester_t)) - suite.addTest( unittest.makeSuite(templates_tester_t)) suite.addTest( unittest.makeSuite(circular_references_tester_t)) return suite Modified: pyplusplus_dev/unittests/sconstruct =================================================================== --- pyplusplus_dev/unittests/sconstruct 2009-08-08 19:53:41 UTC (rev 1747) +++ pyplusplus_dev/unittests/sconstruct 2009-08-08 19:57:28 UTC (rev 1748) @@ -25,9 +25,7 @@ env.AppendUnique( CPPPATH=['#data'] ) -scripts = [ 'pof' - , 'issues' - , 'enums' +scripts = [ 'enums' , 'opaque' , 'include_algorithm' , 'anonymous' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-08-17 19:29:37
|
Revision: 1754 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1754&view=rev Author: roman_yakovenko Date: 2009-08-17 19:29:29 +0000 (Mon, 17 Aug 2009) Log Message: ----------- adding few properties to make the life of embedded developers easier Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef.py pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp pyplusplus_dev/unittests/function_adaptor_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2009-08-17 19:26:53 UTC (rev 1753) +++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2009-08-17 19:29:29 UTC (rev 1754) @@ -477,8 +477,12 @@ template.append( os.linesep.join( precall_code ) ) template.append( 'if( %(override)s func_%(alias)s = this->get_override( "%(alias)s" ) )' ) template.append( self.indent('%(return_)sfunc_%(alias)s( %(args)s );') ) - template.append( 'else' ) + template.append( 'else{' ) + native_precall_code = self.declaration.override_native_precall_code + if native_precall_code: + template.append( self.indent( os.linesep.join( native_precall_code ) ) ) template.append( self.indent('%(return_)sthis->%(wrapped_class)s::%(name)s( %(args)s );') ) + template.append( '}' ) template = os.linesep.join( template ) return_ = '' @@ -716,8 +720,12 @@ template.append( 'if( %(override)s func_%(alias)s = this->get_override( "%(alias)s" ) )' ) template.append( self.indent('%(return_)sfunc_%(alias)s( %(args)s );') ) - template.append( 'else' ) + template.append( 'else{' ) + native_precall_code = self.declaration.override_native_precall_code + if native_precall_code: + template.append( self.indent( os.linesep.join( native_precall_code ) ) ) template.append( self.indent('%(return_)sthis->%(wrapped_class)s::%(name)s( %(args)s );') ) + template.append( '}' ) template = os.linesep.join( template ) return_ = '' Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2009-08-17 19:26:53 UTC (rev 1753) +++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2009-08-17 19:29:29 UTC (rev 1754) @@ -246,6 +246,7 @@ calldef_t.__init__( self ) self._use_overload_macro = False self._override_precall_code = [] + self._overide_native_precall_code = [] self._default_precall_code = [] self._adaptor = None @@ -268,6 +269,15 @@ """code, which should be executed, before overrided member function call""" return self._override_precall_code + def add_override_native_precall_code(self, code): + """add code, which should be executed, before native member function call""" + self._overide_native_precall_code.append( code ) + + @property + def override_native_precall_code(self): + """code, which should be executed, before overrided member function call""" + return self._overide_native_precall_code + def add_default_precall_code(self, code): """add code, which should be executed, before this member function call""" self._default_precall_code.append( code ) @@ -452,7 +462,8 @@ calldef_t.__init__( self ) self._override_precall_code = [] self._default_precall_code = [] - + self._overide_native_precall_code = [] + def add_override_precall_code(self, code): self._override_precall_code.append( code ) @@ -467,6 +478,16 @@ def default_precall_code(self): return self._default_precall_code + def add_override_native_precall_code(self, code): + """add code, which should be executed, before native member function call""" + self._overide_native_precall_code.append( code ) + + @property + def override_native_precall_code(self): + """code, which should be executed, before overrided member function call""" + return self._overide_native_precall_code + + def _get_alias( self): alias = super( member_operator_t, self )._get_alias() if alias == self.name: Modified: pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp 2009-08-17 19:26:53 UTC (rev 1753) +++ pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp 2009-08-17 19:29:29 UTC (rev 1754) @@ -18,4 +18,24 @@ inline int get_one(){ return 1; } +struct base_t{ +protected: + virtual int get_zero() const { return 0; } + virtual int get_two() const { return 2; } + +}; + +struct derived_t : public base_t{ +protected: + virtual int get_two() const { return 22; } +}; + + +struct base3_t{ +protected: + virtual int get_zero() const = 0; + +}; + + #endif//__function_adaptor_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/function_adaptor_tester.py =================================================================== --- pyplusplus_dev/unittests/function_adaptor_tester.py 2009-08-17 19:26:53 UTC (rev 1753) +++ pyplusplus_dev/unittests/function_adaptor_tester.py 2009-08-17 19:29:29 UTC (rev 1754) @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright 2004-2008 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at @@ -20,8 +21,15 @@ def customize(self, mb ): for suffix in [ 'zero', 'one', 'two' ]: - mb.calldef( 'get_' + suffix ).adaptor = 'PYPP_IDENTITY' - mb.calldef( 'get_' + suffix ).create_with_signature = False + funs = mb.calldefs( 'get_' + suffix ) + funs.adaptor = 'PYPP_IDENTITY' + funs.create_with_signature = False + mfuns = mb.global_ns.mem_funs( 'get_' + suffix, allow_empty=True ) + mfuns.add_default_precall_code( '//add_default_precall_code' ) + mfuns.add_override_precall_code( '//add_override_precall_code' ) + mfuns.add_override_native_precall_code( '//add_override_native_precall_code' ) + mb.class_('base3_t' ).add_wrapper_code( '//just a comment to force Py++ create wrapper' ) + def run_tests( self, module): foo = module.foo_t() self.failUnless( foo.get_zero() == 0 ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-08-18 18:03:03
|
Revision: 1755 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1755&view=rev Author: roman_yakovenko Date: 2009-08-18 18:02:47 +0000 (Tue, 18 Aug 2009) Log Message: ----------- adding adaptor for pure virtual member functions Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef.py pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp pyplusplus_dev/unittests/function_adaptor_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2009-08-17 19:29:29 UTC (rev 1754) +++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2009-08-18 18:02:47 UTC (rev 1755) @@ -315,20 +315,26 @@ return 'typedef %s;' % ftype.create_typedef( self.function_type_alias, exported_class_alias ) def create_function_ref_code(self, use_function_alias=False): + result = '' fname = declarations.full_name( self.declaration, with_defaults=False ) if use_function_alias: - return '%s( %s(&%s) )' \ + result = '%s( %s(&%s) )' \ % ( self.pure_virtual_identifier() , self.function_type_alias , fname ) elif self.declaration.create_with_signature: - return '%s( (%s)(&%s) )' \ + result = '%s( (%s)(&%s) )' \ % ( self.pure_virtual_identifier() , self.declaration.function_type().partial_decl_string , fname ) else: - return '%s( &%s )' % ( self.pure_virtual_identifier(), fname) + result = '%s( &%s )' % ( self.pure_virtual_identifier(), fname) + if hasattr( self.declaration, 'adaptor' ) and self.declaration.adaptor: + result = "%s( %s )" % ( self.declaration.adaptor, result ) + + return result + class mem_fun_pv_wrapper_t( calldef_wrapper_t ): def __init__( self, function ): calldef_wrapper_t.__init__( self, function=function ) Modified: pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp 2009-08-17 19:29:29 UTC (rev 1754) +++ pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp 2009-08-18 18:02:47 UTC (rev 1755) @@ -37,5 +37,10 @@ }; +struct base4_t{ + virtual int get_zero() const = 0; +}; + + #endif//__function_adaptor_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/function_adaptor_tester.py =================================================================== --- pyplusplus_dev/unittests/function_adaptor_tester.py 2009-08-17 19:29:29 UTC (rev 1754) +++ pyplusplus_dev/unittests/function_adaptor_tester.py 2009-08-18 18:02:47 UTC (rev 1755) @@ -29,6 +29,7 @@ mfuns.add_override_precall_code( '//add_override_precall_code' ) mfuns.add_override_native_precall_code( '//add_override_native_precall_code' ) mb.class_('base3_t' ).add_wrapper_code( '//just a comment to force Py++ create wrapper' ) + mb.mem_fun( '::derived_t::get_two' ).alias = 'get2' def run_tests( self, module): foo = module.foo_t() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-08-24 19:55:22
|
Revision: 1756 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1756&view=rev Author: roman_yakovenko Date: 2009-08-24 19:55:14 +0000 (Mon, 24 Aug 2009) Log Message: ----------- adding ability to override virtual protected member functions from Python Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef.py pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp pyplusplus_dev/unittests/function_adaptor_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2009-08-18 18:02:47 UTC (rev 1755) +++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2009-08-24 19:55:14 UTC (rev 1756) @@ -332,7 +332,7 @@ if hasattr( self.declaration, 'adaptor' ) and self.declaration.adaptor: result = "%s( %s )" % ( self.declaration.adaptor, result ) - + return result class mem_fun_pv_wrapper_t( calldef_wrapper_t ): @@ -530,7 +530,7 @@ def _create_impl(self): answer = [ self.create_function() ] - answer.append( os.linesep ) + answer.append( '' ) answer.append( self.create_default_function() ) return os.linesep.join( answer ) @@ -681,12 +681,12 @@ def create_function_ref_code(self, use_function_alias=False): if use_function_alias: return '%s( &%s )' \ - % ( self.function_type_alias, self.wrapper.full_name() ) + % ( self.function_type_alias, self.wrapper.default_full_name() ) elif self.declaration.create_with_signature: return '(%s)(&%s)' \ - % ( self.wrapper.function_type().partial_decl_string, self.wrapper.full_name() ) + % ( self.wrapper.function_type().partial_decl_string, self.wrapper.default_full_name() ) else: - return '&%s' % self.wrapper.full_name() + return '&%s' % self.wrapper.default_full_name() class mem_fun_protected_v_wrapper_t( calldef_wrapper_t ): def __init__( self, function): @@ -695,6 +695,9 @@ def full_name(self): return self.parent.full_name + '::' + self.declaration.name + def default_full_name(self): + return self.parent.full_name + '::default_' + self.declaration.alias + def function_type(self): return declarations.member_function_type_t( return_type=self.declaration.return_type @@ -729,7 +732,7 @@ template.append( 'else{' ) native_precall_code = self.declaration.override_native_precall_code if native_precall_code: - template.append( self.indent( os.linesep.join( native_precall_code ) ) ) + template.append( self.indent( os.linesep.join( native_precall_code ) ) ) template.append( self.indent('%(return_)sthis->%(wrapped_class)s::%(name)s( %(args)s );') ) template.append( '}' ) template = os.linesep.join( template ) @@ -753,9 +756,31 @@ answer.append( '}' ) return os.linesep.join( answer ) + + def create_default_body(self): + function_call = declarations.call_invocation.join( self.declaration.partial_name + , [ self.function_call_args() ] ) + body = self.wrapped_class_identifier() + '::' + function_call + ';' + if not declarations.is_void( self.declaration.return_type ): + body = 'return ' + body + precall_code = self.declaration.default_precall_code + if precall_code: + body = os.linesep.join( precall_code ) + os.linesep + body + return body + + def create_default_function( self ): + answer = [ self.create_declaration('default_' + self.declaration.alias) + '{' ] + answer.append( self.indent( self.create_default_body() ) ) + answer.append( '}' ) + return os.linesep.join( answer ) + def _create_impl(self): - return self.create_function() + answer = [ self.create_function() ] + answer.append( '' ) + answer.append( self.create_default_function() ) + return os.linesep.join( answer ) + class mem_fun_protected_pv_t( calldef_t ): def __init__( self, function, wrapper ): calldef_t.__init__( self, function=function, wrapper=wrapper ) @@ -1035,7 +1060,7 @@ def __init__( self, constructor ): code_creator.code_creator_t.__init__( self ) declaration_based.declaration_based_t.__init__( self, declaration=constructor ) - + @property def parent_class( self ): return self.declaration.parent @@ -1080,11 +1105,11 @@ def __init__( self, constructor ): code_creator.code_creator_t.__init__( self ) declaration_based.declaration_based_t.__init__( self, declaration=constructor ) - + @property def parent_class( self ): return self.declaration.parent - + def _create_constructor_call( self ): return algorithm.create_identifier( self, self.parent_class.decl_string ) + '()' Modified: pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp 2009-08-18 18:02:47 UTC (rev 1755) +++ pyplusplus_dev/unittests/data/function_adaptor_to_be_exported.hpp 2009-08-24 19:55:14 UTC (rev 1756) @@ -42,5 +42,24 @@ }; +class Foo +{ +public: + Foo() { } + virtual ~Foo() { } +public: + virtual int virtual_public() + { + return 1; + } + int call_virtual_protected(){ + return virtual_protected(); + } +protected: + virtual int virtual_protected() + { + return 2; + } +}; #endif//__function_adaptor_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/function_adaptor_tester.py =================================================================== --- pyplusplus_dev/unittests/function_adaptor_tester.py 2009-08-18 18:02:47 UTC (rev 1755) +++ pyplusplus_dev/unittests/function_adaptor_tester.py 2009-08-24 19:55:14 UTC (rev 1756) @@ -30,7 +30,31 @@ mfuns.add_override_native_precall_code( '//add_override_native_precall_code' ) mb.class_('base3_t' ).add_wrapper_code( '//just a comment to force Py++ create wrapper' ) mb.mem_fun( '::derived_t::get_two' ).alias = 'get2' + Foo = mb.class_('Foo') + for f in [ 'virtual_public', 'virtual_protected' ]: + f = Foo.mem_fun( f ) + f.add_default_precall_code( '//add_default_precall_code' ) + f.add_override_precall_code( '//add_override_precall_code' ) + f.add_override_native_precall_code( '//add_override_native_precall_code' ) + def create_foo_derived(self, module): + class pyfoo( module.Foo ): + def __init__( self ): + module.Foo.__init__( self ) + + def virtual_protected( self ): + return 3 + return pyfoo( ); + + def create_foo_derived2(self, module): + class pyfoo2( module.Foo ): + def __init__( self ): + module.Foo.__init__( self ) + + def virtual_protected( self ): + return module.Foo.virtual_protected( self ) + return pyfoo2( ); + def run_tests( self, module): foo = module.foo_t() self.failUnless( foo.get_zero() == 0 ) @@ -38,6 +62,16 @@ self.failUnless( module.foo_t.get_two() == 2 ) self.failUnless( module.get_one() == 1 ) + pyfoo = self.create_foo_derived( module ) + self.failUnless( pyfoo.virtual_public() == 1 ) + self.failUnless( pyfoo.virtual_protected() == 3 ) + self.failUnless( pyfoo.call_virtual_protected() == 3 ) + + pyfoo2 = self.create_foo_derived2( module ) + self.failUnless( pyfoo2.virtual_public() == 1 ) + self.failUnless( pyfoo2.virtual_protected() == 2 ) + self.failUnless( pyfoo2.call_virtual_protected() == 2 ) + def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-09-19 18:57:56
|
Revision: 1757 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1757&view=rev Author: roman_yakovenko Date: 2009-09-19 18:57:48 +0000 (Sat, 19 Sep 2009) Log Message: ----------- fixing generated call policies for transformed virtual function. Thanks to Pertti Kellom?\195?\164ki for reporting it. Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp pyplusplus_dev/unittests/function_transformations_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2009-08-24 19:55:14 UTC (rev 1756) +++ pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2009-09-19 18:57:48 UTC (rev 1757) @@ -281,6 +281,9 @@ else: return '&%s' % full_name + def create_call_policies( self ): + return '' + class mem_fun_v_transformed_wrapper_t( calldef_wrapper_t ): def __init__( self, function ): calldef_wrapper_t.__init__( self, function=function ) Modified: pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2009-08-24 19:55:14 UTC (rev 1756) +++ pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2009-09-19 18:57:48 UTC (rev 1757) @@ -254,4 +254,26 @@ } +namespace ft_bugs{ + +class C {}; + +class A { +public: + + static const A& get_a(){ static A a; return a; } + +protected: + virtual ~A(){}; +}; + +class B { +public: + virtual C* h(A const & x){ return 0;} // this does not work + //C *h(A const & x); // this works + //virtual C *h(); // and this +}; + +} + #endif//__function_transformations_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/function_transformations_tester.py =================================================================== --- pyplusplus_dev/unittests/function_transformations_tester.py 2009-08-24 19:55:14 UTC (rev 1756) +++ pyplusplus_dev/unittests/function_transformations_tester.py 2009-09-19 18:57:48 UTC (rev 1757) @@ -13,6 +13,14 @@ from pyplusplus.module_builder import call_policies +def remove_const_ref(type): + """Converts "T const&" into "T &" """ + if declarations.type_traits.is_reference(type): + t = declarations.cpptypes.reference_t(declarations.type_traits.remove_const(type.base)) + return t + return type + + class tester_t(fundamental_tester_base.fundamental_tester_base_t): EXTENSION_NAME = 'function_transformations' @@ -94,6 +102,14 @@ render_queue_listener_t = mb.class_( 'render_queue_listener_t' ) render_queue_ended = render_queue_listener_t.mem_fun( 'render_queue_ended' ) render_queue_ended.add_transformation( ft.inout(2) ) + + ft_bugs = mb.namespace( 'ft_bugs' ) + h = ft_bugs.mem_fun( 'h' ) + h.add_transformation( ft.modify_type(0, remove_const_ref ) ) + h.call_policies = call_policies.return_internal_reference() + ft_bugs.class_( 'B' ).always_expose_using_scope = True + ft_bugs.mem_fun( 'get_a' ).call_policies \ + = call_policies.return_value_policy( call_policies.reference_existing_object ) def run_tests(self, module): """Run the actual unit tests. @@ -252,7 +268,9 @@ tmp = module.transfer_ownership_tester_t() resource = tmp.resources_t(); tmp.tester( resource ) - + + b = module.B() + self.failUnless( b.h( module.A.get_a() ) == None ) def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-09-19 19:53:21
|
Revision: 1758 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1758&view=rev Author: roman_yakovenko Date: 2009-09-19 18:59:58 +0000 (Sat, 19 Sep 2009) Log Message: ----------- updating history and fixing few compilation errors in code, found by new gcc Modified Paths: -------------- pyplusplus_dev/docs/history/history.rest pyplusplus_dev/unittests/data/member_variables_to_be_exported.cpp pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp Modified: pyplusplus_dev/docs/history/history.rest =================================================================== --- pyplusplus_dev/docs/history/history.rest 2009-09-19 18:57:48 UTC (rev 1757) +++ pyplusplus_dev/docs/history/history.rest 2009-09-19 18:59:58 UTC (rev 1758) @@ -24,6 +24,7 @@ * Bernd Fritzke * Andrei Vermel * Carsten( spom.spom ) +* Pertti Kellomäki ----------- SVN Version @@ -50,6 +51,8 @@ 6. Support for `std::hash_map<...>` and `std::hash_set<...>` containers was added. +7. The bug related to transformed virtual function was fixed. Many thanks to Pertti Kellomäki. + ----------- Version 1.0 ----------- Modified: pyplusplus_dev/unittests/data/member_variables_to_be_exported.cpp =================================================================== --- pyplusplus_dev/unittests/data/member_variables_to_be_exported.cpp 2009-09-19 18:57:48 UTC (rev 1757) +++ pyplusplus_dev/unittests/data/member_variables_to_be_exported.cpp 2009-09-19 18:59:58 UTC (rev 1758) @@ -7,6 +7,8 @@ namespace member_variables{ +const array_t::variable_t array_t::vars[] = { array_t::variable_t(), array_t::variable_t(), array_t::variable_t() }; + int point::instance_count = 0; const point::color point::default_color = point::red; Modified: pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp 2009-09-19 18:57:48 UTC (rev 1757) +++ pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp 2009-09-19 18:59:58 UTC (rev 1758) @@ -49,7 +49,8 @@ unsigned int get_b(const bit_fields_t& inst); struct array_t{ - array_t(){ + array_t() + { for( int i = 0; i < 10; ++i ){ ivars[i] = -i; } @@ -64,7 +65,7 @@ return ivars[index]; } - const variable_t vars[3]; + static const variable_t vars[3]; int ivars[10]; int ivars2[10]; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-09-21 19:20:32
|
Revision: 1759 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1759&view=rev Author: roman_yakovenko Date: 2009-09-21 19:20:25 +0000 (Mon, 21 Sep 2009) Log Message: ----------- function transformation functionality was fixed for virtual functions, which returns "reference" Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py pyplusplus_dev/pyplusplus/function_transformers/controllers.py pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp pyplusplus_dev/unittests/function_transformations_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2009-09-19 18:59:58 UTC (rev 1758) +++ pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2009-09-21 19:20:25 UTC (rev 1759) @@ -351,7 +351,10 @@ tmpl_values['save_result'] = '' if not declarations.is_void( self.declaration.return_type ): - tmpl_values['save_result'] = '%s = ' % cntrl.result_variable.name + tmpl_tmp = '%(result_var_name)s = ' + if declarations.is_reference( self.declaration.return_type ): + tmpl_tmp = '%(result_var_name)s = &' + tmpl_values['save_result'] = tmpl_tmp % dict( result_var_name=cntrl.result_variable.name ) tmpl_values['function_name'] = self.declaration.name tmpl_values['arg_expressions'] = self.PARAM_SEPARATOR.join( cntrl.arg_expressions ) Modified: pyplusplus_dev/pyplusplus/function_transformers/controllers.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/controllers.py 2009-09-19 18:59:58 UTC (rev 1758) +++ pyplusplus_dev/pyplusplus/function_transformers/controllers.py 2009-09-21 19:20:25 UTC (rev 1759) @@ -131,8 +131,15 @@ controller_base_t.__init__( self, function ) self.__vars_manager = create_variables_manager( function ) self.__wrapper_args = [ arg.clone() for arg in function.arguments ] - self.__result_var = variable_t( self.function.return_type - , self.register_variable_name( 'result' ) ) + + initialize_expr = '' + result_type = self.function.return_type + if declarations.is_reference( self.function.return_type ): + initialize_expr = ' = 0' + result_type = declarations.pointer_t( declarations.remove_reference( self.function.return_type ) ) + self.__result_var = variable_t( result_type + , self.register_variable_name( 'result' ) + , initialize_expr=initialize_expr ) self.__return_variables = [] self.__pre_call = [] self.__post_call = [] Modified: pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2009-09-19 18:59:58 UTC (rev 1758) +++ pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2009-09-21 19:20:25 UTC (rev 1759) @@ -269,9 +269,10 @@ class B { public: - virtual C* h(A const & x){ return 0;} // this does not work - //C *h(A const & x); // this works - //virtual C *h(); // and this + virtual C* h(A const & x){ return 0;} + virtual C& h2(A const & x){ return c;} +private: + C c; }; } Modified: pyplusplus_dev/unittests/function_transformations_tester.py =================================================================== --- pyplusplus_dev/unittests/function_transformations_tester.py 2009-09-19 18:59:58 UTC (rev 1758) +++ pyplusplus_dev/unittests/function_transformations_tester.py 2009-09-21 19:20:25 UTC (rev 1759) @@ -107,6 +107,12 @@ h = ft_bugs.mem_fun( 'h' ) h.add_transformation( ft.modify_type(0, remove_const_ref ) ) h.call_policies = call_policies.return_internal_reference() + + h2 = ft_bugs.mem_fun( 'h2' ) + h2.add_transformation( ft.modify_type(0, remove_const_ref ) ) + h2.call_policies = call_policies.return_internal_reference() + + ft_bugs.class_( 'B' ).always_expose_using_scope = True ft_bugs.mem_fun( 'get_a' ).call_policies \ = call_policies.return_value_policy( call_policies.reference_existing_object ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-09-22 18:41:56
|
Revision: 1760 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1760&view=rev Author: roman_yakovenko Date: 2009-09-22 18:41:38 +0000 (Tue, 22 Sep 2009) Log Message: ----------- function transformation functionality was fixed for regular functions, which returns "reference" Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp pyplusplus_dev/unittests/function_transformations_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2009-09-21 19:20:25 UTC (rev 1759) +++ pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2009-09-22 18:41:38 UTC (rev 1760) @@ -90,11 +90,14 @@ tmpl_values['save_result'] = '' if not declarations.is_void( self.declaration.return_type ): - tmpl_values['save_result'] \ - = '%(type)s %(name)s = ' \ - % { 'type': cntrl.result_variable.type.decl_string - , 'name' : cntrl.result_variable.name } + tmpl_tmp = '%(type)s %(name)s = ' + if declarations.is_reference( self.declaration.return_type ): + tmpl_tmp = tmpl_tmp + '&' + tmpl_values['save_result'] = tmpl_tmp \ + % { 'type': cntrl.result_variable.type.decl_string + , 'name' : cntrl.result_variable.name } + tmpl_values['function_name'] = self.resolve_function_ref() tmpl_values['arg_expressions'] = self.PARAM_SEPARATOR.join( cntrl.arg_expressions ) return_stmt_creator = calldef_utils.return_stmt_creator_t( self @@ -353,7 +356,7 @@ if not declarations.is_void( self.declaration.return_type ): tmpl_tmp = '%(result_var_name)s = ' if declarations.is_reference( self.declaration.return_type ): - tmpl_tmp = '%(result_var_name)s = &' + tmpl_tmp = tmpl_tmp + '&' tmpl_values['save_result'] = tmpl_tmp % dict( result_var_name=cntrl.result_variable.name ) tmpl_values['function_name'] = self.declaration.name Modified: pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2009-09-21 19:20:25 UTC (rev 1759) +++ pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2009-09-22 18:41:38 UTC (rev 1760) @@ -277,4 +277,24 @@ } + +namespace ft_bugs2{ + +class A2 { +protected: + virtual ~A2(){}; +}; + +class B2 {}; + +class C2 { +public: + B2& g(A2 const & x, int n){ return b; } +private: + B2 b; +}; + + +} + #endif//__function_transformations_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/function_transformations_tester.py =================================================================== --- pyplusplus_dev/unittests/function_transformations_tester.py 2009-09-21 19:20:25 UTC (rev 1759) +++ pyplusplus_dev/unittests/function_transformations_tester.py 2009-09-22 18:41:38 UTC (rev 1760) @@ -112,10 +112,15 @@ h2.add_transformation( ft.modify_type(0, remove_const_ref ) ) h2.call_policies = call_policies.return_internal_reference() - ft_bugs.class_( 'B' ).always_expose_using_scope = True ft_bugs.mem_fun( 'get_a' ).call_policies \ = call_policies.return_value_policy( call_policies.reference_existing_object ) + + ft_bugs2 = mb.namespace( 'ft_bugs2' ) + g = ft_bugs2.mem_fun( 'g' ) + g.add_transformation( ft.modify_type(0, remove_const_ref ) ) + g.call_policies = call_policies.return_internal_reference() + def run_tests(self, module): """Run the actual unit tests. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-11-04 22:08:20
|
Revision: 1773 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1773&view=rev Author: roman_yakovenko Date: 2009-11-04 22:08:12 +0000 (Wed, 04 Nov 2009) Log Message: ----------- commit new function transformers from Beno?\195?\174t Leveau Modified Paths: -------------- pyplusplus_dev/docs/history/history.rest pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py pyplusplus_dev/pyplusplus/function_transformers/__init__.py pyplusplus_dev/pyplusplus/function_transformers/transformers.py pyplusplus_dev/unittests/member_variables_tester.py Modified: pyplusplus_dev/docs/history/history.rest =================================================================== --- pyplusplus_dev/docs/history/history.rest 2009-11-04 20:24:32 UTC (rev 1772) +++ pyplusplus_dev/docs/history/history.rest 2009-11-04 22:08:12 UTC (rev 1773) @@ -25,6 +25,7 @@ * Andrei Vermel * Carsten( spom.spom ) * Pertti Kellomäki +* Benoît Leveau ----------- SVN Version @@ -53,6 +54,18 @@ 7. The bug related to transformed virtual function was fixed. Many thanks to Pertti Kellomäki. +8. Thanks to Benoît Leveau, the "Function Transformation" documentation + is much better now. + +9. The following transformers were added: + + * ``inout_static_array`` + * ``input_static_matrix`` + * ``output_static_matrix`` + * ``inout_static_matrix`` + + Many thanks to Benoît Leveau. + ----------- Version 1.0 ----------- Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2009-11-04 20:24:32 UTC (rev 1772) +++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2009-11-04 22:08:12 UTC (rev 1773) @@ -160,6 +160,11 @@ return '' def _exportable_impl( self ): + if self.transformations: + #It is possible that the function asked for the user attention. + #The user paid attention and created a transformation. + #Py++ should be silent in this case. + return '' if not self.parent.name: return messages.W1057 % str( self ) all_types = [ arg.type for arg in self.arguments ] Modified: pyplusplus_dev/pyplusplus/function_transformers/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/__init__.py 2009-11-04 20:24:32 UTC (rev 1772) +++ pyplusplus_dev/pyplusplus/function_transformers/__init__.py 2009-11-04 22:08:12 UTC (rev 1773) @@ -30,7 +30,27 @@ def creator( function ): return transformers.output_static_array_t( function, *args, **keywd ) return creator + +def inout_static_array( *args, **keywd ): + def creator( function ): + return transformers.inout_static_array_t( function, *args, **keywd ) + return creator +def input_static_matrix( *args, **keywd ): + def creator( function ): + return transformers.input_static_matrix_t( function, *args, **keywd ) + return creator + +def output_static_matrix( *args, **keywd ): + def creator( function ): + return transformers.output_static_matrix_t( function, *args, **keywd ) + return creator + +def inout_static_matrix( *args, **keywd ): + def creator( function ): + return transformers.inout_static_matrix_t( function, *args, **keywd ) + return creator + def modify_type( *args, **keywd ): def creator( function ): return transformers.type_modifier_t( function, *args, **keywd ) Modified: pyplusplus_dev/pyplusplus/function_transformers/transformers.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2009-11-04 20:24:32 UTC (rev 1772) +++ pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2009-11-04 22:08:12 UTC (rev 1773) @@ -165,7 +165,7 @@ def __str__(self): return "input(%s)"%(self.arg.name) -# input_t +# from_address_t class from_address_t(type_modifier_t): """Handles a single input variable. @@ -193,6 +193,7 @@ def __str__(self): return "from_address(%s)"%(self.arg.name) +# inout_t class inout_t(transformer.transformer_t): """Handles a single input/output variable. @@ -261,6 +262,10 @@ _arr2seq = string.Template( 'pyplus_conv::copy_container( $native_array, $native_array + $array_size, pyplus_conv::list_inserter( $pylist ) );' ) +_mat2seq = string.Template( + 'for (int i=0; i<$matrix_size1; ++i) { boost::python::list ${pylist}_i; pyplus_conv::copy_container( $native_matrix[i], $native_matrix[i] + $matrix_size2, pyplus_conv::list_inserter( ${pylist}_i ) ); $pylist.append(${pylist}_i); }' ) + + class input_static_array_t(transformer.transformer_t): """Handles an input array with fixed size. @@ -430,7 +435,378 @@ self.__configure_v_mem_fun_override( controller.override_controller ) self.__configure_v_mem_fun_default( controller.default_controller ) +# inout_static_array_t +class inout_static_array_t(transformer.transformer_t): + """Handles an input/output array with fixed size. + void do_something(double* v) -> v2 = do_something(object v2) + + where v2 is a Python sequence + """ + + def __init__(self, function, arg_ref, size): + """Constructor. + + :param arg_ref: Index of the argument that is an input/output array + :type arg_ref: int + :param size: The fixed size of the input/output array + :type size: int + """ + transformer.transformer_t.__init__( self, function ) + + self.arg = self.get_argument( arg_ref ) + self.arg_index = self.function.arguments.index( self.arg ) + + if not is_ptr_or_array( self.arg.type ): + raise ValueError( '%s\nin order to use "inout_array" transformation, argument %s type must be a array or a pointer (got %s).' ) \ + % ( function, self.arg.name, self.arg.type) + + self.array_size = size + self.array_item_type = declarations.remove_const( declarations.array_item_type( self.arg.type ) ) + + def __str__(self): + return "inout_array(%s,%d)"%( self.arg.name, self.array_size) + + def required_headers( self ): + """Returns list of header files that transformer generated code depends on.""" + return [ code_repository.convenience.file_name ] + + def __configure_sealed(self, controller): + global _seq2arr + global _arr2seq + w_arg = controller.find_wrapper_arg( self.arg.name ) + w_arg.type = declarations.dummy_type_t( "boost::python::object" ) + + # Declare a variable that will hold the C array... + native_array = controller.declare_variable( self.array_item_type + , "native_" + self.arg.name + , '[%d]' % self.array_size ) + + copy_pylist2arr = _seq2arr.substitute( type=self.array_item_type + , pylist=w_arg.name + , array_size=self.array_size + , native_array=native_array ) + + controller.add_pre_call_code( copy_pylist2arr ) + controller.modify_arg_expression( self.arg_index, native_array ) + + # Declare a Python list which will receive the output... + pylist = controller.declare_variable( declarations.dummy_type_t( "boost::python::list" ) + , 'py_' + self.arg.name ) + + copy_arr2pylist = _arr2seq.substitute( native_array=native_array + , array_size=self.array_size + , pylist=pylist ) + controller.add_post_call_code( copy_arr2pylist ) + + #adding the variable to return variables list + controller.return_variable( pylist ) + + def __configure_v_mem_fun_default( self, controller ): + self.__configure_sealed( controller ) + + def __configure_v_mem_fun_override( self, controller ): + global _arr2seq + pylist = controller.declare_py_variable( declarations.dummy_type_t( 'boost::python::list' ) + , 'py_' + self.arg.name ) + + copy_arr2pylist = _arr2seq.substitute( native_array=self.arg.name + , array_size=self.array_size + , pylist=pylist ) + + controller.add_py_pre_call_code( copy_arr2pylist ) + + def configure_mem_fun( self, controller ): + self.__configure_sealed( controller ) + + def configure_free_fun(self, controller ): + self.__configure_sealed( controller ) + + def configure_virtual_mem_fun( self, controller ): + self.__configure_v_mem_fun_override( controller.override_controller ) + self.__configure_v_mem_fun_default( controller.default_controller ) + +# input_static_matrix_t +class input_static_matrix_t(transformer.transformer_t): + """Handles an input matrix with fixed size. + + is_identity(double m[3][3]) -> is_identity(object m) + # m must be a sequence of 3 sequences of 3 floats + """ + + def __init__(self, function, arg_ref, size1, size2): + """Constructor. + + :param size1, size2: The fixed size of the input matrix + :type size1, size2: int + """ + transformer.transformer_t.__init__( self, function ) + + self.arg = self.get_argument( arg_ref ) + self.arg_index = self.function.arguments.index( self.arg ) + + if not is_ptr_or_array( self.arg.type ): + raise ValueError( '%s\nin order to use "input_matrix" transformation, argument %s type must be a array or a pointer (got %s).' ) \ + % ( function, self.arg.name, self.arg.type) + + self.matrix_size1 = size1 + self.matrix_size2 = size2 + self.matrix_item_type = declarations.remove_const( declarations.array_item_type( declarations.array_item_type( self.arg.type ) ) ) + + def __str__(self): + return "input_matrix(%s,%d,%d)"%( self.arg.name, self.matrix_size1, self.matrix_size2) + + def required_headers( self ): + """Returns list of header files that transformer generated code depends on.""" + return [ code_repository.convenience.file_name ] + + def __configure_sealed(self, controller): + global _seq2arr + w_arg = controller.find_wrapper_arg( self.arg.name ) + w_arg.type = declarations.dummy_type_t( "boost::python::object" ) + + # Declare a variable that will hold the C matrix... + native_matrix = controller.declare_variable( self.matrix_item_type + , "native_" + self.arg.name + , '[%d][%d]' % (self.matrix_size1, self.matrix_size2) + ) + + pre_call = string.Template('pyplus_conv::ensure_uniform_sequence< $type >( $pylist, $array_size );') + controller.add_pre_call_code(pre_call.substitute(type='boost::python::list', pylist=w_arg.name,array_size=self.matrix_size1)) + + #TODO: may be a better idea is move this loop to the generated code. + for i in range(0,self.matrix_size1): + copy_pylist2arr = _seq2arr.substitute( type=self.matrix_item_type + , pylist=w_arg.name+"["+str(i)+"]" + , array_size=self.matrix_size2 + , native_array=native_matrix+'['+str(i)+']' ) + + controller.add_pre_call_code( copy_pylist2arr ) + + controller.modify_arg_expression( self.arg_index, native_matrix ) + + def __configure_v_mem_fun_default( self, controller ): + self.__configure_sealed( controller ) + + def __configure_v_mem_fun_override( self, controller ): + global _arr2seq + pylist = controller.declare_py_variable( declarations.dummy_type_t( 'boost::python::list' ) + , 'py_' + self.arg.name ) + + #TODO: may be a better idea is move this loop to the generated code. + for i in range(0, self.matrix_size1): + copy_arr2pylist = _arr2seq.substitute( native_array=self.arg.name+'[%d]'%i + , array_size=self.matrix_size2 + , pylist=pylist ) + + controller.add_py_pre_call_code( copy_arr2pylist ) + + def configure_mem_fun( self, controller ): + self.__configure_sealed( controller ) + + def configure_free_fun(self, controller ): + self.__configure_sealed( controller ) + + def configure_virtual_mem_fun( self, controller ): + self.__configure_v_mem_fun_override( controller.override_controller ) + self.__configure_v_mem_fun_default( controller.default_controller ) + +# output_static_matrix_t +class output_static_matrix_t(transformer.transformer_t): + """Handles an output matrix with fixed size. + + get_matrix(double m[3][3]) -> m = get_matrix() + # m will be a sequence of 3 sequences of 3 floats + """ + + def __init__(self, function, arg_ref, size1, size2): + """Constructor. + + :param arg_ref: Index of the argument that is an output matrix + :type arg_ref: int + :param size1, size2: The fixed size of the output matrix + :type size1, size2: int + + """ + transformer.transformer_t.__init__( self, function ) + + self.arg = self.get_argument( arg_ref ) + self.arg_index = self.function.arguments.index( self.arg ) + + if not is_ptr_or_array( self.arg.type ): + raise ValueError( '%s\nin order to use "output_matrix" transformation, argument %s type must be a array or a pointer (got %s).' ) \ + % ( function, self.arg.name, self.arg.type) + + self.matrix_size1 = size1 + self.matrix_size2 = size2 + self.matrix_item_type = declarations.remove_const( declarations.array_item_type( declarations.array_item_type( self.arg.type ) ) ) + + def __str__(self): + return "output_matrix(%s,%d,%d)"%( self.arg.name, self.matrix_size1, self.matrix_size2) + + def required_headers( self ): + """Returns list of header files that transformer generated code depends on.""" + return [ code_repository.convenience.file_name ] + + def __configure_sealed(self, controller): + global _mat2seq + #removing arg from the function wrapper definition + controller.remove_wrapper_arg( self.arg.name ) + + # Declare a variable that will hold the C matrix... + native_matrix = controller.declare_variable( self.matrix_item_type + , "native_" + self.arg.name + , '[%d][%d]' % (self.matrix_size1, self.matrix_size2) + ) + #adding just declared variable to the original function call expression + controller.modify_arg_expression( self.arg_index, native_matrix ) + + # Declare a Python list which will receive the output... + pylist = controller.declare_variable( declarations.dummy_type_t( "boost::python::list" ) + , 'py_' + self.arg.name ) + + copy_mat2pylist = _mat2seq.substitute( native_matrix = native_matrix, + matrix_size1=self.matrix_size1, + matrix_size2=self.matrix_size2, + pylist=pylist) + + controller.add_post_call_code( copy_mat2pylist ) + + #adding the variable to return variables list + controller.return_variable( pylist ) + + def __configure_v_mem_fun_default( self, controller ): + self.__configure_sealed( controller ) + + def __configure_v_mem_fun_override( self, controller ): + global _seq2arr + seq = controller.declare_py_variable( declarations.dummy_type_t( 'boost::python::object' ) + , 'py_' + self.arg.name ) + controller.remove_py_arg( self.arg_index ) + tmpl = string.Template( '$seq = pyplus_conv::get_out_argument( $py_result, "$name" );' ) + get_ref_to_seq = tmpl.substiture( seq=seq + , py_result=controller.py_result_variable_name + , name=self.arg.name ) + controller.add_py_post_call_code( get_ref_to_seq ) + + #TODO: may be a better idea is move this loop to the generated code. + for i in range(0, self.matrix_size1): + copy_pylist2arr = _seq2arr.substitute( type=self.matrix_item_type + , pylist=seq + , array_size=self.matrix_size2 + , native_array=self.arg.name+'[%d]'%i ) + controller.add_py_post_call_code( copy_pylist2arr ) + + def configure_mem_fun( self, controller ): + self.__configure_sealed( controller ) + + def configure_free_fun(self, controller ): + self.__configure_sealed( controller ) + + def configure_virtual_mem_fun( self, controller ): + self.__configure_v_mem_fun_override( controller.override_controller ) + self.__configure_v_mem_fun_default( controller.default_controller ) + +# inout_static_matrix_t +class inout_static_matrix_t(transformer.transformer_t): + """Handles an input/output matrix with fixed size. + + transpose_matrix(double m[3][3]) -> m = transpose_matrix(object m) + # m must be a sequence of 3 sequences of 3 floats + """ + + def __init__(self, function, arg_ref, size1, size2): + """Constructor. + + :param arg_ref: Index of the argument that is an input/output matrix + :type arg_ref: int + :param size1,size2: The fixed size of the input/output matrix + :type size1,size2: int + """ + transformer.transformer_t.__init__( self, function ) + + self.arg = self.get_argument( arg_ref ) + self.arg_index = self.function.arguments.index( self.arg ) + + if not is_ptr_or_array( self.arg.type ): + raise ValueError( '%s\nin order to use "inout_matrix" transformation, argument %s type must be a array or a pointer (got %s).' ) \ + % ( function, self.arg.name, self.arg.type) + + self.matrix_size1 = size1 + self.matrix_size2 = size2 + self.matrix_item_type = declarations.remove_const( declarations.array_item_type( declarations.array_item_type( self.arg.type ) ) ) + + def __str__(self): + return "inout_matrix(%s,%d,%d)"%( self.arg.name, self.matrix_size1, self.matrix_size2) + + def required_headers( self ): + """Returns list of header files that transformer generated code depends on.""" + return [ code_repository.convenience.file_name ] + + def __configure_sealed(self, controller): + global _seq2arr + global _mat2seq + w_arg = controller.find_wrapper_arg( self.arg.name ) + w_arg.type = declarations.dummy_type_t( "boost::python::object" ) + + # Declare a variable that will hold the C matrix... + native_matrix = controller.declare_variable( self.matrix_item_type + , "native_" + self.arg.name + , '[%d][%d]' % (self.matrix_size1, self.matrix_size2) + ) + + pre_call = string.Template('pyplus_conv::ensure_uniform_sequence< $type >( $pylist, $array_size );') + controller.add_pre_call_code(pre_call.substitute(type='boost::python::list', pylist=w_arg.name,array_size=self.matrix_size1)) + + #TODO: may be a better idea is move this loop to the generated code. + for i in range(0,self.matrix_size1): + copy_pylist2arr = _seq2arr.substitute( type=self.matrix_item_type + , pylist=w_arg.name+"["+str(i)+"]" + , array_size=self.matrix_size2 + , native_array=native_matrix+'['+str(i)+']' ) + + controller.add_pre_call_code( copy_pylist2arr ) + + controller.modify_arg_expression( self.arg_index, native_matrix ) + + pylist = controller.declare_variable( declarations.dummy_type_t( "boost::python::list" ) + , 'py_' + self.arg.name ) + copy_mat2pylist = _mat2seq.substitute( native_matrix = native_matrix, + matrix_size1=self.matrix_size1, + matrix_size2=self.matrix_size2, + pylist=pylist) + + controller.add_post_call_code( copy_mat2pylist ) + + #adding the variable to return variables list + controller.return_variable( pylist ) + + def __configure_v_mem_fun_default( self, controller ): + self.__configure_sealed( controller ) + + def __configure_v_mem_fun_override( self, controller ): + global _mat2seq + pylist = controller.declare_py_variable( declarations.dummy_type_t( 'boost::python::list' ) + , 'py_' + self.arg.name ) + + copy_mat2pylist = _mat2seq.substitute( native_matrix=self.arg.name + , matrix_size1=self.matrix_size1 + , matrix_size2=self.matrix_size2 + , pylist=pylist ) + + controller.add_py_pre_call_code( copy_arr2pylist ) + + def configure_mem_fun( self, controller ): + self.__configure_sealed( controller ) + + def configure_free_fun(self, controller ): + self.__configure_sealed( controller ) + + def configure_virtual_mem_fun( self, controller ): + self.__configure_v_mem_fun_override( controller.override_controller ) + self.__configure_v_mem_fun_default( controller.default_controller ) + +# input_c_buffer_t class input_c_buffer_t(transformer.transformer_t): """ handles an input of C buffer: @@ -523,7 +899,6 @@ self.__configure_v_mem_fun_override( controller.override_controller ) self.__configure_v_mem_fun_default( controller.default_controller ) - class transfer_ownership_t(type_modifier_t): """see http://boost.org/libs/python/doc/v2/faq.html#ownership """ Modified: pyplusplus_dev/unittests/member_variables_tester.py =================================================================== --- pyplusplus_dev/unittests/member_variables_tester.py 2009-11-04 20:24:32 UTC (rev 1772) +++ pyplusplus_dev/unittests/member_variables_tester.py 2009-11-04 22:08:12 UTC (rev 1773) @@ -55,23 +55,6 @@ self.failUnless( bf.b == module.get_b( bf ) ) self.failIfNotRaisesAny( lambda: self.set_b( bf, 23 ) ) - array = module.array_t() - self.failUnless( len( array.vars ) == 3 ) - for i in range( len( array.vars ) ): - self.failUnless( array.vars[i].value == -9 ) - self.failUnless( len( array.ivars ) == 10 ) - - ivars = array.ivars - del array #testing call policies - for i in range(20): - for index in range(10): - self.failUnless( ivars[index] == -index ) - - array = module.array_t() - for index in range( len(array.ivars) ): - array.ivars[index] = index * index - self.failUnless( array.get_ivars_item( index ) == index * index ) - tree = module.create_tree() self.failUnless( tree.parent is None ) self.failUnless( tree.data.value == 0 ) @@ -109,6 +92,24 @@ data = data_type.from_address( module.image_t.none_image ) self.failUnless( 1997 == data.contents.value ) + array = module.array_t() + self.failUnless( len( array.ivars ) == 10 ) + + ivars = array.ivars + del array #testing call policies + for i in range(20): + for index in range(10): + self.failUnless( ivars[index] == -index ) + + array = module.array_t() + for index in range( len(array.ivars) ): + array.ivars[index] = index * index + self.failUnless( array.get_ivars_item( index ) == index * index ) + + self.failUnless( len( array.vars ) == 3 ) + for i in range( len( array.vars ) ): + self.failUnless( array.vars[i].value == -9 ) + def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-11-05 22:57:01
|
Revision: 1774 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1774&view=rev Author: roman_yakovenko Date: 2009-11-05 22:56:49 +0000 (Thu, 05 Nov 2009) Log Message: ----------- misc: adding new documentation for from_address transformation Modified Paths: -------------- pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest pyplusplus_dev/unittests/ft_from_address_tester.py pyplusplus_dev/unittests/test_all.py Modified: pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest 2009-11-04 22:08:12 UTC (rev 1773) +++ pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest 2009-11-05 22:56:49 UTC (rev 1774) @@ -94,6 +94,7 @@ output_static_array.rest transfer_ownership.rest input_c_buffer.rest + from_address.rest Modified: pyplusplus_dev/unittests/ft_from_address_tester.py =================================================================== --- pyplusplus_dev/unittests/ft_from_address_tester.py 2009-11-04 22:08:12 UTC (rev 1773) +++ pyplusplus_dev/unittests/ft_from_address_tester.py 2009-11-05 22:56:49 UTC (rev 1774) @@ -51,6 +51,7 @@ self.failUnless( value.contents.value == 5.9 ) dd = double_ptr_type(ctypes.c_double(0.0) ) print dir( ctypes.pointer( dd ).contents ) + ptr.get_v_address( ctypes.pointer( dd ).contents.value ) print ptr.value print dd.contents.value Modified: pyplusplus_dev/unittests/test_all.py =================================================================== --- pyplusplus_dev/unittests/test_all.py 2009-11-04 22:08:12 UTC (rev 1773) +++ pyplusplus_dev/unittests/test_all.py 2009-11-05 22:56:49 UTC (rev 1774) @@ -120,6 +120,7 @@ import function_adaptor_tester import selection_bug_tester #import ogre_generate_tester +import ft_from_address testers = [ algorithms_tester @@ -228,6 +229,7 @@ , return_ref_to_ptr_tester , function_adaptor_tester , selection_bug_tester + , ft_from_address # , ogre_generate_tester too much time ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-11-16 21:15:33
|
Revision: 1779 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1779&view=rev Author: roman_yakovenko Date: 2009-11-16 21:15:20 +0000 (Mon, 16 Nov 2009) Log Message: ----------- adding beginning of "input_static_matrix" tester Modified Paths: -------------- pyplusplus_dev/pyplusplus/function_transformers/transformers.py pyplusplus_dev/unittests/test_all.py Added Paths: ----------- pyplusplus_dev/unittests/data/ft_input_static_matrix_to_be_exported.hpp pyplusplus_dev/unittests/ft_input_static_matrix_tester.py Modified: pyplusplus_dev/pyplusplus/function_transformers/transformers.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2009-11-16 19:44:57 UTC (rev 1778) +++ pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2009-11-16 21:15:20 UTC (rev 1779) @@ -263,9 +263,10 @@ 'pyplus_conv::copy_container( $native_array, $native_array + $array_size, pyplus_conv::list_inserter( $pylist ) );' ) _mat2seq = string.Template( - 'for (int i=0; i<$matrix_size1; ++i) { boost::python::list ${pylist}_i; pyplus_conv::copy_container( $native_matrix[i], $native_matrix[i] + $matrix_size2, pyplus_conv::list_inserter( ${pylist}_i ) ); $pylist.append(${pylist}_i); }' ) + 'for (int i=0; i<$rows; ++i) { boost::python::list ${pylist}_i; pyplus_conv::copy_container( $native_matrix[i], $native_matrix[i] + $columns, pyplus_conv::list_inserter( ${pylist}_i ) ); $pylist.append(${pylist}_i); }' ) + class input_static_array_t(transformer.transformer_t): """Handles an input array with fixed size. @@ -526,6 +527,13 @@ self.__configure_v_mem_fun_override( controller.override_controller ) self.__configure_v_mem_fun_default( controller.default_controller ) +_pymatrix2cmatrix = string.Template( os.linesep.join([ + 'pyplus_conv::ensure_uniform_sequence< boost::python::list >( $pymatrix, $rows );' + , 'for( size_t $row = 0; $row < $rows; ++$row ){' + , ' pyplus_conv::ensure_uniform_sequence< $type >( $pymatrix[$row], $columns );' + , ' pyplus_conv::copy_sequence( $pymatrix[$row], pyplus_conv::array_inserter( $native_matrix[$row], $columns ) );' + , '}'])) + # input_static_matrix_t class input_static_matrix_t(transformer.transformer_t): """Handles an input matrix with fixed size. @@ -534,11 +542,11 @@ # m must be a sequence of 3 sequences of 3 floats """ - def __init__(self, function, arg_ref, size1, size2): + def __init__(self, function, arg_ref, rows, columns): """Constructor. - :param size1, size2: The fixed size of the input matrix - :type size1, size2: int + :param rows, columns: The fixed size of the input matrix + :type rows, columns: int """ transformer.transformer_t.__init__( self, function ) @@ -549,12 +557,12 @@ raise ValueError( '%s\nin order to use "input_matrix" transformation, argument %s type must be a array or a pointer (got %s).' ) \ % ( function, self.arg.name, self.arg.type) - self.matrix_size1 = size1 - self.matrix_size2 = size2 + self.rows = rows + self.columns = columns self.matrix_item_type = declarations.remove_const( declarations.array_item_type( declarations.array_item_type( self.arg.type ) ) ) def __str__(self): - return "input_matrix(%s,%d,%d)"%( self.arg.name, self.matrix_size1, self.matrix_size2) + return "input_matrix(%s,%d,%d)"%( self.arg.name, self.rows, self.columns) def required_headers( self ): """Returns list of header files that transformer generated code depends on.""" @@ -568,21 +576,17 @@ # Declare a variable that will hold the C matrix... native_matrix = controller.declare_variable( self.matrix_item_type , "native_" + self.arg.name - , '[%d][%d]' % (self.matrix_size1, self.matrix_size2) - ) + , '[%d][%d]' % (self.rows, self.columns) ) - pre_call = string.Template('pyplus_conv::ensure_uniform_sequence< $type >( $pylist, $array_size );') - controller.add_pre_call_code(pre_call.substitute(type='boost::python::list', pylist=w_arg.name,array_size=self.matrix_size1)) + conversion_code = _pymatrix2cmatrix.substitute( type=self.matrix_item_type + , pymatrix=w_arg.name + , columns='%d' % self.columns + , row=controller.register_variable_name( "row" ) + , rows='%d' % self.rows + , native_matrix=native_matrix ) - #TODO: may be a better idea is move this loop to the generated code. - for i in range(0,self.matrix_size1): - copy_pylist2arr = _seq2arr.substitute( type=self.matrix_item_type - , pylist=w_arg.name+"["+str(i)+"]" - , array_size=self.matrix_size2 - , native_array=native_matrix+'['+str(i)+']' ) + controller.add_pre_call_code( conversion_code ) - controller.add_pre_call_code( copy_pylist2arr ) - controller.modify_arg_expression( self.arg_index, native_matrix ) def __configure_v_mem_fun_default( self, controller ): @@ -594,9 +598,9 @@ , 'py_' + self.arg.name ) #TODO: may be a better idea is move this loop to the generated code. - for i in range(0, self.matrix_size1): + for i in range(0, self.rows): copy_arr2pylist = _arr2seq.substitute( native_array=self.arg.name+'[%d]'%i - , array_size=self.matrix_size2 + , array_size=self.columns , pylist=pylist ) controller.add_py_pre_call_code( copy_arr2pylist ) @@ -619,13 +623,13 @@ # m will be a sequence of 3 sequences of 3 floats """ - def __init__(self, function, arg_ref, size1, size2): + def __init__(self, function, arg_ref, rows, columns): """Constructor. :param arg_ref: Index of the argument that is an output matrix :type arg_ref: int - :param size1, size2: The fixed size of the output matrix - :type size1, size2: int + :param rows, columns: The fixed size of the output matrix + :type rows, columns: int """ transformer.transformer_t.__init__( self, function ) @@ -637,12 +641,12 @@ raise ValueError( '%s\nin order to use "output_matrix" transformation, argument %s type must be a array or a pointer (got %s).' ) \ % ( function, self.arg.name, self.arg.type) - self.matrix_size1 = size1 - self.matrix_size2 = size2 + self.rows = rows + self.columns = columns self.matrix_item_type = declarations.remove_const( declarations.array_item_type( declarations.array_item_type( self.arg.type ) ) ) def __str__(self): - return "output_matrix(%s,%d,%d)"%( self.arg.name, self.matrix_size1, self.matrix_size2) + return "output_matrix(%s,%d,%d)"%( self.arg.name, self.rows, self.columns) def required_headers( self ): """Returns list of header files that transformer generated code depends on.""" @@ -656,7 +660,7 @@ # Declare a variable that will hold the C matrix... native_matrix = controller.declare_variable( self.matrix_item_type , "native_" + self.arg.name - , '[%d][%d]' % (self.matrix_size1, self.matrix_size2) + , '[%d][%d]' % (self.rows, self.columns) ) #adding just declared variable to the original function call expression controller.modify_arg_expression( self.arg_index, native_matrix ) @@ -666,8 +670,8 @@ , 'py_' + self.arg.name ) copy_mat2pylist = _mat2seq.substitute( native_matrix = native_matrix, - matrix_size1=self.matrix_size1, - matrix_size2=self.matrix_size2, + rows=self.rows, + columns=self.columns, pylist=pylist) controller.add_post_call_code( copy_mat2pylist ) @@ -690,10 +694,10 @@ controller.add_py_post_call_code( get_ref_to_seq ) #TODO: may be a better idea is move this loop to the generated code. - for i in range(0, self.matrix_size1): + for i in range(0, self.rows): copy_pylist2arr = _seq2arr.substitute( type=self.matrix_item_type , pylist=seq - , array_size=self.matrix_size2 + , array_size=self.columns , native_array=self.arg.name+'[%d]'%i ) controller.add_py_post_call_code( copy_pylist2arr ) @@ -711,17 +715,17 @@ class inout_static_matrix_t(transformer.transformer_t): """Handles an input/output matrix with fixed size. - transpose_matrix(double m[3][3]) -> m = transpose_matrix(object m) - # m must be a sequence of 3 sequences of 3 floats + transpose_matrix(double m[2][3]) -> m = transpose_matrix(object m) + # m must be a sequence of 2 sequences of 3 floats """ - def __init__(self, function, arg_ref, size1, size2): + def __init__(self, function, arg_ref, rows, columns): """Constructor. :param arg_ref: Index of the argument that is an input/output matrix :type arg_ref: int - :param size1,size2: The fixed size of the input/output matrix - :type size1,size2: int + :param rows,columns: The fixed size of the input/output matrix + :type rows,columns: int """ transformer.transformer_t.__init__( self, function ) @@ -732,12 +736,12 @@ raise ValueError( '%s\nin order to use "inout_matrix" transformation, argument %s type must be a array or a pointer (got %s).' ) \ % ( function, self.arg.name, self.arg.type) - self.matrix_size1 = size1 - self.matrix_size2 = size2 + self.rows = rows + self.columns = columns self.matrix_item_type = declarations.remove_const( declarations.array_item_type( declarations.array_item_type( self.arg.type ) ) ) def __str__(self): - return "inout_matrix(%s,%d,%d)"%( self.arg.name, self.matrix_size1, self.matrix_size2) + return "inout_matrix(%s,%d,%d)"%( self.arg.name, self.rows, self.columns) def required_headers( self ): """Returns list of header files that transformer generated code depends on.""" @@ -752,17 +756,17 @@ # Declare a variable that will hold the C matrix... native_matrix = controller.declare_variable( self.matrix_item_type , "native_" + self.arg.name - , '[%d][%d]' % (self.matrix_size1, self.matrix_size2) + , '[%d][%d]' % (self.rows, self.columns) ) pre_call = string.Template('pyplus_conv::ensure_uniform_sequence< $type >( $pylist, $array_size );') - controller.add_pre_call_code(pre_call.substitute(type='boost::python::list', pylist=w_arg.name,array_size=self.matrix_size1)) + controller.add_pre_call_code(pre_call.substitute(type='boost::python::list', pylist=w_arg.name,array_size=self.rows)) #TODO: may be a better idea is move this loop to the generated code. - for i in range(0,self.matrix_size1): + for i in range(0,self.rows): copy_pylist2arr = _seq2arr.substitute( type=self.matrix_item_type , pylist=w_arg.name+"["+str(i)+"]" - , array_size=self.matrix_size2 + , array_size=self.columns , native_array=native_matrix+'['+str(i)+']' ) controller.add_pre_call_code( copy_pylist2arr ) @@ -771,10 +775,10 @@ pylist = controller.declare_variable( declarations.dummy_type_t( "boost::python::list" ) , 'py_' + self.arg.name ) - copy_mat2pylist = _mat2seq.substitute( native_matrix = native_matrix, - matrix_size1=self.matrix_size1, - matrix_size2=self.matrix_size2, - pylist=pylist) + copy_mat2pylist = _mat2seq.substitute( native_matrix = native_matrix + , rows=self.rows + , columns=self.columns + , pylist=pylist) controller.add_post_call_code( copy_mat2pylist ) @@ -790,8 +794,8 @@ , 'py_' + self.arg.name ) copy_mat2pylist = _mat2seq.substitute( native_matrix=self.arg.name - , matrix_size1=self.matrix_size1 - , matrix_size2=self.matrix_size2 + , rows=self.rows + , columns=self.columns , pylist=pylist ) controller.add_py_pre_call_code( copy_arr2pylist ) Added: pyplusplus_dev/unittests/data/ft_input_static_matrix_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/ft_input_static_matrix_to_be_exported.hpp (rev 0) +++ pyplusplus_dev/unittests/data/ft_input_static_matrix_to_be_exported.hpp 2009-11-16 21:15:20 UTC (rev 1779) @@ -0,0 +1,27 @@ +// Copyright 2004-2008 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef __ft_input_static_matrix_to_be_exported_hpp__ +#define __ft_input_static_matrix_to_be_exported_hpp__ + +#include <cmath> +#include <string> +#include <iostream> + +namespace ft{ + +int sum( int m[2][3] ){ + int result = 0; + for( int r = 0; r < 2; ++r ){ + for( int c = 0; c < 3; ++c ){ + result += m[r][c]; + } + } + return result; +} + +} + +#endif//__ft_input_static_matrix_to_be_exported_hpp__ Added: pyplusplus_dev/unittests/ft_input_static_matrix_tester.py =================================================================== --- pyplusplus_dev/unittests/ft_input_static_matrix_tester.py (rev 0) +++ pyplusplus_dev/unittests/ft_input_static_matrix_tester.py 2009-11-16 21:15:20 UTC (rev 1779) @@ -0,0 +1,43 @@ +# Copyright 2004-2008 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os +import sys +import math +import unittest +import fundamental_tester_base +from pygccxml import declarations +from pyplusplus import function_transformers as ft +from pyplusplus.module_builder import call_policies + +class tester_t(fundamental_tester_base.fundamental_tester_base_t): + EXTENSION_NAME = 'ft_input_static_matrix' + + def __init__( self, *args ): + fundamental_tester_base.fundamental_tester_base_t.__init__( + self + , tester_t.EXTENSION_NAME + , *args ) + + def customize( self, mb ): + mb.global_ns.calldefs().create_with_signature = True + sum = mb.free_fun( 'sum' ) + sum.add_transformation( ft.input_static_matrix('m', rows=2, columns=3) ) + + def run_tests(self, module): + """Run the actual unit tests""" + m = [ [1, 2, 3], [4,5,6] ] + self.failUnless( 21 == module.sum( m ) ) + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() Modified: pyplusplus_dev/unittests/test_all.py =================================================================== --- pyplusplus_dev/unittests/test_all.py 2009-11-16 19:44:57 UTC (rev 1778) +++ pyplusplus_dev/unittests/test_all.py 2009-11-16 21:15:20 UTC (rev 1779) @@ -122,6 +122,7 @@ #import ogre_generate_tester import ft_from_address import indexing_suites2_support_tester +import ft_input_static_matrix testers = [ algorithms_tester @@ -232,6 +233,7 @@ , selection_bug_tester , ft_from_address , indexing_suites2_support_tester + , ft_input_static_matrix # , ogre_generate_tester too much time ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-12-15 20:47:18
|
Revision: 1781 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1781&view=rev Author: roman_yakovenko Date: 2009-12-15 20:47:10 +0000 (Tue, 15 Dec 2009) Log Message: ----------- a few updates to FT input static matrix functionality Modified Paths: -------------- pyplusplus_dev/pyplusplus/function_transformers/transformers.py pyplusplus_dev/unittests/data/ft_input_static_matrix_to_be_exported.hpp pyplusplus_dev/unittests/ft_input_static_matrix_tester.py Modified: pyplusplus_dev/pyplusplus/function_transformers/transformers.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2009-12-15 20:44:50 UTC (rev 1780) +++ pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2009-12-15 20:47:10 UTC (rev 1781) @@ -569,7 +569,7 @@ return [ code_repository.convenience.file_name ] def __configure_sealed(self, controller): - global _seq2arr + global _pymatrix2cmatrix w_arg = controller.find_wrapper_arg( self.arg.name ) w_arg.type = declarations.dummy_type_t( "boost::python::object" ) @@ -592,7 +592,7 @@ def __configure_v_mem_fun_default( self, controller ): self.__configure_sealed( controller ) - def __configure_v_mem_fun_override( self, controller ): + def __configure_v_mem_fun_override( self, controller ): global _arr2seq pylist = controller.declare_py_variable( declarations.dummy_type_t( 'boost::python::list' ) , 'py_' + self.arg.name ) Modified: pyplusplus_dev/unittests/data/ft_input_static_matrix_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/ft_input_static_matrix_to_be_exported.hpp 2009-12-15 20:44:50 UTC (rev 1780) +++ pyplusplus_dev/unittests/data/ft_input_static_matrix_to_be_exported.hpp 2009-12-15 20:47:10 UTC (rev 1781) @@ -12,16 +12,31 @@ namespace ft{ -int sum( int m[2][3] ){ +template< int rows, int columns > +int sum_impl( const int m[rows][columns] ){ int result = 0; - for( int r = 0; r < 2; ++r ){ - for( int c = 0; c < 3; ++c ){ + for( int r = 0; r < rows; ++r ){ + for( int c = 0; c < columns; ++c ){ result += m[r][c]; } } return result; } +int sum( int m[2][3]){ + return sum_impl<2, 3>( m ); } +int sum_const( int m[2][3]){ + return sum_impl<2, 3>( m ); +} + +struct matrix_sum_t{ + virtual int calculate( const int m[3][5] ) const{ + return sum_impl<3,5>( m ); + } +}; + +} + #endif//__ft_input_static_matrix_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/ft_input_static_matrix_tester.py =================================================================== --- pyplusplus_dev/unittests/ft_input_static_matrix_tester.py 2009-12-15 20:44:50 UTC (rev 1780) +++ pyplusplus_dev/unittests/ft_input_static_matrix_tester.py 2009-12-15 20:47:10 UTC (rev 1781) @@ -23,8 +23,16 @@ def customize( self, mb ): mb.global_ns.calldefs().create_with_signature = True + mb.free_funs( 'sum_impl' ).exclude() + sum = mb.free_fun( 'sum' ) sum.add_transformation( ft.input_static_matrix('m', rows=2, columns=3) ) + + sum = mb.free_funs( lambda d: d.name in ('sum', 'sum_const' ) ) + sum.add_transformation( ft.input_static_matrix('m', rows=2, columns=3) ) + + calculate = mb.mem_fun( 'calculate' ) + calculate.add_transformation( ft.input_static_matrix('m', rows=3, columns=5) ) def run_tests(self, module): """Run the actual unit tests""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-12-23 21:26:05
|
Revision: 1782 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1782&view=rev Author: roman_yakovenko Date: 2009-12-23 21:25:58 +0000 (Wed, 23 Dec 2009) Log Message: ----------- according to MSDN(http://msdn.microsoft.com/en-us/library/s2ff0fz8%28VS.100%29.aspx) conversion constructor is a constructor that could be called with one argument - this change implements this behaviour Modified Paths: -------------- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py pyplusplus_dev/unittests/casting_tester.py pyplusplus_dev/unittests/data/casting_to_be_exported.hpp Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2009-12-15 20:47:10 UTC (rev 1781) +++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2009-12-23 21:25:58 UTC (rev 1782) @@ -341,14 +341,14 @@ For more information see: * http://boost.org/libs/python/doc/v2/implicit.html#implicitly_convertible-spec - * http://msdn2.microsoft.com/en-us/library/h1y7x448.aspx + * http://msdn.microsoft.com/en-us/library/s2ff0fz8%28VS.100%29.aspx """ if self.parent.is_abstract: #user is not able to create an instance of the class return False if self.is_copy_constructor: return False - if 1 != len( self.arguments ): + if 1 != len( self.required_args ): return False if self.parent.find_out_member_access_type( self ) != declarations.ACCESS_TYPES.PUBLIC: return False Modified: pyplusplus_dev/unittests/casting_tester.py =================================================================== --- pyplusplus_dev/unittests/casting_tester.py 2009-12-15 20:47:10 UTC (rev 1781) +++ pyplusplus_dev/unittests/casting_tester.py 2009-12-23 21:25:58 UTC (rev 1782) @@ -28,6 +28,9 @@ self.failUnless( 0 == module.x_value(False) ) fv = module.float_vector( 5.0 ) + cc = module.get_value_a( 78 ); + self.failUnless( cc == -78 ) + def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) Modified: pyplusplus_dev/unittests/data/casting_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/casting_to_be_exported.hpp 2009-12-15 20:47:10 UTC (rev 1781) +++ pyplusplus_dev/unittests/data/casting_to_be_exported.hpp 2009-12-23 21:25:58 UTC (rev 1782) @@ -8,6 +8,20 @@ namespace casting{ +struct conversion_constructor_t{ + conversion_constructor_t( int a, int b=0 ) + : value_a( a* (-1) ), value_b( b * (-1) ) + {} + int value_a; + bool value_b; +}; + +int get_value_a( int a ){ + conversion_constructor_t cc( a ); + return cc.value_a; +} + + struct y{}; struct x{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |