[pygccxml-commit] SF.net SVN: pygccxml: [429] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-08-21 13:42:42
|
Revision: 429 Author: roman_yakovenko Date: 2006-08-21 06:42:15 -0700 (Mon, 21 Aug 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=429&view=rev Log Message: ----------- updating documentation strings Modified Paths: -------------- pyplusplus_dev/docs/documentation/best_practices.rest pyplusplus_dev/docs/documentation/how_to.rest pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper_printer.py pyplusplus_dev/pyplusplus/decl_wrappers/enumeration_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py pyplusplus_dev/pyplusplus/decl_wrappers/namespace_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/scopedef_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/typedef_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/user_text.py pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py pyplusplus_dev/setup.py Modified: pyplusplus_dev/docs/documentation/best_practices.rest =================================================================== --- pyplusplus_dev/docs/documentation/best_practices.rest 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/docs/documentation/best_practices.rest 2006-08-21 13:42:15 UTC (rev 429) @@ -9,7 +9,7 @@ ------------ `Py++`_ has reach interface and a lot of functionality. Sometimes reach -interface helps, but sometimes it can confuse. This document will describe how +interface helps, but sometimes it can confuse. This document will describe how effectively to use `Py++`_. ------------ @@ -19,48 +19,47 @@ Definition ---------- -First of all, let me to define "big project". "Big project" is a project with +First of all, let me to define "big project". "Big project" is a project with few hundred of header files. `Py++`_ was born to create `Python`_ bindings -for such projects. If you take a look `here`__ you will find few such projects, -that use `Py++`_. +for such projects. If you take a look `here`__ you will find few such projects. .. __ : ./../../pygccxml/quotes.html Tips ---- -* Create one header file, which will include all project header files. +* Create one header file, which will include all project header files. - Doing it this way makes it so `GCC-XML`_ is only called once and it reduces the + Doing it this way makes it so `GCC-XML`_ is only called once and it reduces the overhead that would occur if you pass `GCC-XML`_ all the files individually. - Namely `GCC-XML`_ would have to run hundreds of times and each call would - actually end up including quite a bit of common code anyway. This way takes a - `GCC-XML`_ processing time from multiple hours with gigabytes of caches to a + Namely `GCC-XML`_ would have to run hundreds of times and each call would + actually end up including quite a bit of common code anyway. This way takes a + `GCC-XML`_ processing time from multiple hours with gigabytes of caches to a couple minutes with a reasonable cache size. - + You can read more about different caches supported by `pygccxml`_ `here`__. ``module_builder_t.__init__`` methods takes reference to an instance of cache class or ``None``: - + :: - from module_builder import * + from module_builder import * mb = module_builder_t( ..., cache=file_cache_t( path to project cache file ), ... ) - + * Single header file, will also improve performance compiling the generated bindings. - When `Py++`_ generated the bindings, you have a lot of .cpp files to + When `Py++`_ generated the bindings, you have a lot of .cpp files to compile. The project you are working on is big. I am sure it takes a lot of - time to compile projects that depend on it. Generated code also depend on it, - more over this code contains a lot of template instantiations. So it could - take a great deal of time to compile it. Allen Bierbaum investigated this - problem. He found out that most of the time is really spent processing all the - headers, templates, macros from the project and from the boost library. So he + time to compile projects that depend on it. Generated code also depend on it, + more over this code contains a lot of template instantiations. So it could + take a great deal of time to compile it. Allen Bierbaum investigated this + problem. He found out that most of the time is really spent processing all the + headers, templates, macros from the project and from the boost library. So he come to conclusion, that in order to improve compilation speed, user should - be able to control( to be able to generate ) precompiled header file. He + be able to control( to be able to generate ) precompiled header file. He implemented an initial version of the functionality. After small discussion, we agreed on next interface: - + :: class module_builder_t( ... ): @@ -68,17 +67,17 @@ def split_module( self, directory_path, huge_classes=None, precompiled_header=None ): ... ... - - ``precompiled_header`` argument could be ``None`` or string, that contains - name of precompiled header file, which will be created in the directory. - `Py++`_ will add to it header files from `Boost.Python`_ library and - your header files. - + + ``precompiled_header`` argument could be ``None`` or string, that contains + name of precompiled header file, which will be created in the directory. + `Py++`_ will add to it header files from `Boost.Python`_ library and + your header files. + What is ``huge_classes`` argument for? ``huge_classes`` could be ``None`` or - list of references to class declarations. It is there to provide a solution to - `this error`_. `Py++`_ will automatically split generated code for the + list of references to class declarations. It is there to provide a solution to + `this error`_. `Py++`_ will automatically split generated code for the huge classes to few files: - + :: mb = module_builder_t( ... ) @@ -89,9 +88,9 @@ .. _`this error` : http://boost.org/libs/python/doc/v2/faq.html#c1204 .. __ : ./../../pygccxml/design.html - - + + .. _`Py++` : ./../pyplusplus.html .. _`pygccxml` : ./../../pygccxml/pygccxml.html .. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html Modified: pyplusplus_dev/docs/documentation/how_to.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to.rest 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/docs/documentation/how_to.rest 2006-08-21 13:42:15 UTC (rev 429) @@ -20,7 +20,7 @@ :: translate_code = \ - """ + """ void translate(const my_exception &exception){ PyErr_SetString( PyExc_RuntimeError, exception.error().c_str() ); } @@ -48,7 +48,7 @@ mb = module_builder_t( ... ) exception_classes = mb.decls( lambda decl: decl.name.endswith( 'exception' ) ) -Now you can iterate on ``exception_classes``, generate and register translate +Now you can iterate on ``exception_classes``, generate and register translate code for every class. That's all. @@ -64,7 +64,7 @@ ... }; -You can not expose ``get_size`` function as is - ``int`` is immutable type in +You can not expose ``get_size`` function as is - ``int`` is immutable type in Python. So, we need to create a wrapper to the function: :: @@ -81,7 +81,7 @@ ... ; -Now, after you know how this problem is solved. I will show how this solution +Now, after you know how this problem is solved. I will show how this solution could be integrated with `Py++`_. @@ -108,26 +108,25 @@ window.add_wrapper_code( wrapper_code ) window.registration_code( registration_code ) -That's all. +That's all. ------------------------------------------------------------- Fatal error C1204:Compiler limit: internal structure overflow ------------------------------------------------------------- -If you get this error, that the generated file is too big. You will have to split -it to few files. Well, not you but `Py++`_ you will only have to tell that -to it. +If you get this error, than the generated file is too big. You will have to split +it to few files. Well, not you but `Py++`_, you will only have to tell it to do +that. If you are using ``module_builder_t.write_module`` method, consider to switch -to ``module_builder_t.split_module``. +to ``module_builder_t.split_module``. -If you are using ``split_method``, but still generated code for some specific -class could not be compiled because of error, you can ask `Py++`_ to split -class registration code to few cpp files. +If you are using ``split_module``, but still the generated code for some class +could not be compiled, because of the error, you can ask `Py++`_ to split the +code generated for class to be splitted to few cpp files. For more information, please read the documentation. - ------------------------------------------------------ How to automatically export template functions\\class? ------------------------------------------------------ @@ -150,7 +149,7 @@ :: - template <class T> + template <class T> double distance( const point_t<T>& point ){ return sqrt( point.x * point.x + point.y*point.y ); } @@ -167,7 +166,7 @@ * free function invocation causes a compiler to instantiate the function -Lets say that we need to export the class and the function template +Lets say that we need to export the class and the function template instantiations for ``int`` and ``custom_type`` types. There are few ways to do it. Simple and straightforward @@ -191,8 +190,8 @@ } } -Now, you add this file to the list of files you pass as input to -``module_builder_t.__init__`` method and excludes the ``py_details`` namespace +Now, you add this file to the list of files you pass as input to +``module_builder_t.__init__`` method and excludes the ``py_details`` namespace declarations from being exported: :: @@ -203,10 +202,10 @@ "Dynamic" instantiation ----------------------- -Lets say you are less lucky than I, and you have to create ``X`` instantiations +Lets say you are less lucky than I, and you have to create ``X`` instantiations of the class\\function. Obviously, the previous approach will not work for you. -The solution is to build your own code generator, which will generate code similar -to the one, in the previous paragraph. +The solution is to build your own code generator, which will generate code similar +to the one, in the previous paragraph. :: @@ -237,7 +236,7 @@ I understand that the provided solution is not perfect. I understand that something -better and simpler should be done, but a priority of this is low. There are few +better and simpler should be done, but a priority of this is low. There are few tasks, that have much higher priority. Allen Bierbaum wants to fix the situation. He created a `wiki page`_, that discuss possible solutions. Your contribution is welcome too! Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2006-08-21 13:42:15 UTC (rev 429) @@ -3,14 +3,16 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +"""defines class that configure "callable" declaration exposing""" + import os import decl_wrapper from pygccxml import declarations class calldef_t(decl_wrapper.decl_wrapper_t): - + """keeps configur global and member variable exposing""" BOOST_PYTHON_MAX_ARITY = 10 - + def __init__(self, *arguments, **keywords): decl_wrapper.decl_wrapper_t.__init__( self, *arguments, **keywords ) @@ -92,10 +94,10 @@ overridable = property( get_overridable, set_overridable , doc = get_overridable.__doc__ ) - + def _exportable_impl_derived( self ): return '' - + def _exportable_impl( self ): all_types = [ arg.type for arg in self.arguments ] all_types.append( self.return_type ) @@ -117,7 +119,7 @@ no_ptr = declarations.remove_pointer( no_ref ) no_const = declarations.remove_const( no_ptr ) if declarations.is_array( no_const ): - return "Py++ can not expose function that takes as argument/returns C++ arrays. This will be changed in near future." + return "Py++ can not expose function that takes as argument/returns C++ arrays. This will be changed in near future." return self._exportable_impl_derived() def _readme_impl( self ): @@ -136,7 +138,7 @@ tmp.append( "For more information see: http://mail.python.org/pipermail/c++-sig/2002-June/001554.html" ) tmp = ' '.join( tmp ) msgs.append( tmp % ( calldef_t.BOOST_PYTHON_MAX_ARITY, len( self.arguments ) ) ) - + if suspicious_type( self.return_type ) and None is self.call_policies: msgs.append( 'The function "%s" returns non-const reference to C++ fundamental type - value can not be modified from Python.' % str( self ) ) for index, arg in enumerate( self.arguments ): @@ -193,7 +195,7 @@ #dereference does not make sense return False return oper.symbol in operators_helper.all - + @staticmethod def exportable( oper ): if isinstance( oper, declarations.member_operator_t ) and oper.symbol in ( '()', '[]' ): @@ -203,7 +205,7 @@ msg.append( 'See Boost.Python documentation: http://www.boost.org/libs/python/doc/v2/operators.html#introduction.' ) return ' '.join( msg ) return '' - + class member_operator_t( declarations.member_operator_t, calldef_t ): def __init__(self, *arguments, **keywords): declarations.member_operator_t.__init__( self, *arguments, **keywords ) @@ -300,4 +302,4 @@ calldef_t.__init__( self ) def _exportable_impl_derived( self ): - return operators_helper.exportable( self ) \ No newline at end of file + return operators_helper.exportable( self ) Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-08-21 13:42:15 UTC (rev 429) @@ -3,6 +3,9 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +"""defines class that configure class definition and class declaration exposing""" + +import os import user_text import decl_wrapper import scopedef_wrapper @@ -10,7 +13,36 @@ import indexing_suite1 as isuite1 import indexing_suite2 as isuite2 -class class_common_impl_details_t( object ): + +always_expose_using_scope_documentation = \ +"""boolean, configures how Py++ should generate code for class. +Py can generate code using IDL like syntax: + + C{class_< ... >( ... )} + C{.def( ... );} + +Or it can generate code using more complex form: + + C{typedef bp::class_< my_class > my_class_exposer_t;} + C{my_class_exposer_t my_class_exposer = my_class_exposer_t( "my_class" );} + C{boost::python::scope my_class_scope( my_class_exposer );} + C{my_class_exposer.def( ... );} + +Also, the second way is much longer, it solves few problems: + + - you can not expose enums and internal classes defined within the class using first method + - you will get much better compilation errors + - the code looks like regular C++ code after all :-) + +By default, this property is set to False. Also, Py++ knows pretty well +when it have to ignore this property and generate right code +""" + +class class_common_details_t( object ): + """defines few properties that are common to + L{class declaration<pygccxml.declarations.class_declaration_t>} and + L{definition<pygccxml.declarations.class_t>} classes + """ def __init__(self): object.__init__( self ) self._always_expose_using_scope = False @@ -26,18 +58,9 @@ if self._isuite_version != version: self._isuite_version = version self._indexing_suite = None - indexing_suite_version = property( _get_indexing_suite_version, _set_indexing_suite_version ) + indexing_suite_version = property( _get_indexing_suite_version, _set_indexing_suite_version + , doc="indexing suite version") - def _get_always_expose_using_scope( self ): - #I am almost sure this logic should be moved to code_creators - if isinstance( self.indexing_suite, isuite2.indexing_suite2_t ) \ - and ( self.indexing_suite.disable_methods or self.indexing_suite.disabled_methods_groups ): - return True - return self._always_expose_using_scope - def _set_always_expose_using_scope( self, value ): - self._always_expose_using_scope = value - always_expose_using_scope = property( _get_always_expose_using_scope, _set_always_expose_using_scope ) - def _get_indexing_suite( self ): if self._indexing_suite is None: for container_traits in declarations.all_container_traits: @@ -48,8 +71,21 @@ self._indexing_suite = isuite2.indexing_suite2_t( self, container_traits ) break return self._indexing_suite - indexing_suite = property( _get_indexing_suite ) + indexing_suite = property( _get_indexing_suite + , doc="returns reference to indexing suite configuration class. " \ + +"If the class is not STD container, returns None") + def _get_always_expose_using_scope( self ): + #I am almost sure this logic should be moved to code_creators + if isinstance( self.indexing_suite, isuite2.indexing_suite2_t ) \ + and ( self.indexing_suite.disable_methods or self.indexing_suite.disabled_methods_groups ): + return True + return self._always_expose_using_scope + def _set_always_expose_using_scope( self, value ): + self._always_expose_using_scope = value + always_expose_using_scope = property( _get_always_expose_using_scope, _set_always_expose_using_scope + , doc="please see L{always_expose_using_scope_documentation} for documentation." ) + def _get_equality_comparable( self ): if None is self._equality_comparable: self._equality_comparable = declarations.has_public_equal( self ) @@ -72,19 +108,19 @@ #this will only be exported if indexing suite is not None and only when needed -class class_declaration_t( class_common_impl_details_t +class class_declaration_t( class_common_details_t , decl_wrapper.decl_wrapper_t , declarations.class_declaration_t ): def __init__(self, *arguments, **keywords): - class_common_impl_details_t.__init__( self ) + class_common_details_t.__init__( self ) declarations.class_declaration_t.__init__(self, *arguments, **keywords ) decl_wrapper.decl_wrapper_t.__init__( self ) -class class_t( class_common_impl_details_t +class class_t( class_common_details_t , scopedef_wrapper.scopedef_t , declarations.class_t): def __init__(self, *arguments, **keywords): - class_common_impl_details_t.__init__( self ) + class_common_details_t.__init__( self ) declarations.class_t.__init__(self, *arguments, **keywords ) scopedef_wrapper.scopedef_t.__init__( self ) @@ -198,4 +234,4 @@ return '' if not self in self.parent.public_members: return 'Py++ can not expose private class.' - return '' \ No newline at end of file + return '' Modified: pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-08-21 13:42:15 UTC (rev 429) @@ -3,16 +3,13 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +"""defines base class for all classes, that will keep Py++ code generator engine +instructions.""" + import algorithm from pyplusplus import _logging_ from pygccxml import declarations - - -class ERROR_BEHAVIOR: - PRINT = 'print' - RAISE = 'raise' - class decl_wrapper_t(object): """Declaration interface. @@ -22,7 +19,7 @@ this class are never created by the user, instead they are returned by the API. """ - + def __init__(self): object.__init__(self) self._alias = None @@ -30,28 +27,28 @@ self._exportable = None self._exportable_reason = None self._documentation = None - + @property def logger( self ): + """returns reference to L{_logging_.loggers.declarations}""" return _logging_.loggers.declarations def _get_documentation( self ): return self._documentation - def _set_documentation( self, value ): self._documentation = value documentation = property( _get_documentation, _set_documentation - , doc="Using this property you can set documentatio of exported declaration." ) - + , doc="Using this property you can set documentatio of exported declaration." ) + def _generate_valid_name(self, name=None): if name == None: name = self.name return algorithm.create_valid_name( name ) - + def _get_alias(self): if not self._alias: if declarations.templates.is_instantiation( self.name ): - container_aliases = [ 'value_type', 'key_type' ] + container_aliases = [ 'value_type', 'key_type', 'mapped_type' ] if isinstance( self, declarations.class_t ) \ and 1 == len( set( map( lambda typedef: typedef.name, self.aliases ) ) ) \ and self.aliases[0].name not in container_aliases: @@ -61,32 +58,32 @@ else: self._alias = self.name return self._alias - def _set_alias(self, alias): self._alias = alias alias = property( _get_alias, _set_alias , doc="Using this property you can easily change Python name of declaration" ) - + def rename( self, new_name ): + """renames the declaration name, under which it is exposed""" self.alias = new_name - + def _get_ignore( self ): - return self._ignore - + return self._ignore def _set_ignore( self, value ): self._ignore = value ignore = property( _get_ignore, _set_ignore - ,doc="If you set ignore to True then this declaration will not be exported." ) - + ,doc="If you set ignore to True then this declaration will not be exported." ) + def exclude( self ): """Exclude "self" and child declarations from being exposed.""" self.ignore = True - + def include( self ): """Include "self" and child declarations to be exposed.""" self.ignore = False def why_not_exportable( self ): + """returns strings that explains why this declaration could not be exported or None otherwise""" if None is self._exportable_reason: self.get_exportable() return self._exportable_reason @@ -104,16 +101,15 @@ self._exportable_reason = self._exportable_impl( ) self._exportable = not bool( self._exportable_reason ) return self._exportable - def set_exportable( self, exportable ): self._exportable = exportable - + exportable = property( get_exportable, set_exportable , doc="Returns True if declaration could be exported to Python, otherwise False" ) - + def _readme_impl( self ): return [] - + def readme( self ): """This function will returns some hints/tips/description of problems that applied to the declarations. For example function that has argument @@ -123,5 +119,5 @@ text = [] if not self.exportable: text.append( self.why_not_exportable() ) - text.extend( self._readme_impl() ) - return text \ No newline at end of file + text.extend( self._readme_impl() ) + return text Modified: pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper_printer.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper_printer.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper_printer.py 2006-08-21 13:42:15 UTC (rev 429) @@ -3,6 +3,9 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +"""defines class that will print in a user friendly format declarations tree and +declarations Py++ configuration instructions""" + import os import sys from pygccxml import declarations @@ -11,7 +14,7 @@ """ Helper class for printing decl tree. """ JUSTIFY = 20 INDENT_SIZE = 4 - + def __init__( self, level=0, print_details=True, recursive=True, writer=None ): declarations.decl_printer_t.__init__(self, level, print_details, recursive, writer) @@ -20,42 +23,42 @@ if increment_level: level += 1 return decl_wrapper_printer_t(level, self.print_details, self.recursive, self.writer) - - def print_decl_header(self): + + def print_decl_header(self): super( decl_wrapper_printer_t, self ).print_decl_header() if not self.print_details: - return - intend_txt = ' ' * (self.level+1) * self.INDENT_SIZE + return + intend_txt = ' ' * (self.level+1) * self.INDENT_SIZE self.writer( intend_txt + "Alias: " + self.instance.alias + os.linesep ) self.writer( intend_txt + "Ignore: " + str( self.instance.ignore ) + os.linesep ) if not self.instance.ignore: msgs = self.instance.readme() if msgs: self.writer( intend_txt + "ReadMe: " + os.linesep ) - more_intend_txt = ' ' * (self.level+2) * self.INDENT_SIZE + more_intend_txt = ' ' * (self.level+2) * self.INDENT_SIZE for msg in msgs: self.writer( more_intend_txt + msg + os.linesep ) - + def print_calldef_wrapper(self): if not self.print_details: - return - self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + return + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + "Call policies: " + str(self.instance.call_policies) + os.linesep ) - self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + "Use keywords: " + str(self.instance.use_keywords) + os.linesep ) - self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + "Use signature: " + str(self.instance.create_with_signature) + os.linesep ) - self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + "Use default arguments: " + str(self.instance.use_default_arguments) + os.linesep ) - + def visit_member_function( self ): super( decl_wrapper_printer_t, self ).visit_member_function() self.print_calldef_wrapper() - + def visit_constructor( self ): super( decl_wrapper_printer_t, self ).visit_constructor() self.print_calldef_wrapper() - + def visit_destructor( self ): super( decl_wrapper_printer_t, self ).visit_destructor() self.print_calldef_wrapper() @@ -80,23 +83,23 @@ super( decl_wrapper_printer_t, self ).visit_class_declaration() def visit_class(self ): - super( decl_wrapper_printer_t, self ).visit_class() - self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + super( decl_wrapper_printer_t, self ).visit_class() + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + "Expose using scope: " + str(self.instance.always_expose_using_scope) + os.linesep ) - self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + "Redefine operators: " + str(self.instance.redefine_operators) + os.linesep ) - self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + "Held type: " + str(self.instance.held_type) + os.linesep ) - self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + "Use noncopyable: " + str(self.instance.noncopyable) + os.linesep ) - self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + "Class wrapper alias: " + str(self.instance.wrapper_alias) + os.linesep ) def visit_enumeration(self): super( decl_wrapper_printer_t, self ).visit_enumeration() - self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + "Enumeration value aliases: " + str(self.instance.value_aliases) + os.linesep ) - self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + self.writer( ' ' * (self.level+1) * self.INDENT_SIZE + "Enumeration export values: " + str(self.instance.export_values) + os.linesep ) def visit_namespace(self ): @@ -104,7 +107,7 @@ def visit_typedef(self ): super( decl_wrapper_printer_t, self ).visit_typedef() - + def visit_variable(self ): super( decl_wrapper_printer_t, self ).visit_variable() Modified: pyplusplus_dev/pyplusplus/decl_wrappers/enumeration_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/enumeration_wrapper.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/pyplusplus/decl_wrappers/enumeration_wrapper.py 2006-08-21 13:42:15 UTC (rev 429) @@ -3,10 +3,16 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -from pygccxml import declarations +"""defines class that configure enumeration declaration exposing""" + +from pygccxml import declarations import decl_wrapper class enumeration_t(decl_wrapper.decl_wrapper_t, declarations.enumeration_t): + """defines a set of properties, that will instruct Py++ how to expose the enumeration + + By default, Py++ will export all enumeration values. + """ def __init__(self, *arguments, **keywords): declarations.enumeration_t.__init__(self, *arguments, **keywords ) decl_wrapper.decl_wrapper_t.__init__( self ) @@ -48,7 +54,7 @@ if name not in export_values: res.append(name) return res - + def _set_no_export_values(self, no_export_values): all_values = map(lambda x: x[0], self.values) export_values = [] @@ -56,11 +62,11 @@ if name not in no_export_values: export_values.append(name) self.export_values = export_values - + no_export_values = property( _get_no_export_values, _set_export_values, doc= """A list of (C++) enumeration names that should not be exported. @type: list""") - + def _readme_impl( self ): msgs = [] if self.name: @@ -68,5 +74,5 @@ if len( set( name2value.keys() ) ) != len( set( name2value.values() ) ): msgs.append( "Boost.Python does not support enums with duplicate values. " "You can read more about this here: http://boost.org/libs/python/todo.html#support-for-enums-with-duplicate-values . " - "The quick work around is to add new class variable to the exported enum, from Python. " ) + "The quick work around is to add new class variable to the exported enum, from Python. " ) return msgs Modified: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite1.py 2006-08-21 13:42:15 UTC (rev 429) @@ -3,10 +3,12 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +"""defines interface for exposing STD containers, using current version of indexing suite""" + from pygccxml import declarations #NoProxy -#By default indexed elements have Python reference semantics and are returned by +#By default indexed elements have Python reference semantics and are returned by #proxy. This can be disabled by supplying true in the NoProxy template parameter. #When we want to disable is: #1. We deal with immutable objects: @@ -21,24 +23,24 @@ This class helps user to export STD containers, using Boost.Python indexing suite V2. """ - + def __init__( self, container_class, container_traits, no_proxy=None, derived_policies=None ): object.__init__( self ) self.__no_proxy = no_proxy self.__derived_policies = derived_policies self.__container_class = container_class self.__container_traits = container_traits - + def _get_container_class( self ): return self.__container_class container_class = property( _get_container_class , doc="Reference to STD container class" ) - + def _get_element_type(self): return self.__container_traits.element_type( self.container_class ) - element_type = property( _get_element_type - , doc="Reference to container value_type( mapped_type ) type" ) - + element_type = property( _get_element_type + , doc="Reference to container value_type( mapped_type ) type" ) + def _get_no_proxy( self ): if self.__no_proxy is None: element_type = self.element_type @@ -51,16 +53,15 @@ else: self.__no_proxy = False return self.__no_proxy - + def _set_no_proxy( self, no_proxy ): self.__no_proxy = no_proxy - no_proxy = property( _get_no_proxy, _set_no_proxy , doc="NoProxy value, the initial value depends on container" +" element_type( mapped_type ) type. In most cases, " +"Py++ is able to guess this value, right. If you are not " +"lucky, you will have to set the property value.") - + def _get_derived_policies( self ): return self.__derived_policies def _set_derived_policies( self, derived_policies ): @@ -68,4 +69,3 @@ derived_policies = property( _get_derived_policies, _set_derived_policies , doc="This proprty contains DerivedPolicies string. " +"It will be added as is to the generated code.") - \ No newline at end of file Modified: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite2.py 2006-08-21 13:42:15 UTC (rev 429) @@ -2,25 +2,28 @@ # 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 interface for exposing STD containers, using next version of indexing suite""" + from pygccxml import declarations """ -method_len -method_iter -method_getitem -method_getitem_slice -method_index -method_contains -method_count -method_has_key -method_setitem -method_setitem_slice -method_delitem -method_delitem_slice -method_reverse -method_append -method_insert -method_extend +method_len +method_iter +method_getitem +method_getitem_slice +method_index +method_contains +method_count +method_has_key +method_setitem +method_setitem_slice +method_delitem +method_delitem_slice +method_reverse +method_append +method_insert +method_extend method_sort slice_methods = method_getitem_slice | method_setitem_slice | method_delitem_slice @@ -35,14 +38,14 @@ This class helps user to export STD containers, using Boost.Python indexing suite V2. """ - + #List of method names. These method could be excluded from being exposed. METHODS = ( 'len', 'iter', 'getitem', 'getitem_slice', 'index', 'contains' , 'count', 'has_key', 'setitem', 'setitem_slice', 'delitem' , 'delitem_slice', 'reverse', 'append', 'insert', 'extend', 'sort' ) - + #Dictionary of method group names. These method groups could be excluded from - #being exposed. Dictionary key is a method group name. Dictionary value is a + #being exposed. Dictionary key is a method group name. Dictionary value is a #list of all methods, which belong to the group. METHOD_GROUPS = { 'slice' : ( 'method_getitem_slice', 'method_setitem_slice', 'method_delitem_slice' ) @@ -50,7 +53,7 @@ , 'reorder' : ( 'method_sort', 'method_reverse' ) , 'insert' : ( 'method_append', 'method_insert', 'method_extend' ) } - + def __init__( self, container_class, container_traits ): object.__init__( self ) self.__call_policies = None @@ -67,15 +70,15 @@ def _get_container_traits( self ): return self._get_container_traits() - container_traits = property( _get_container_traits + container_traits = property( _get_container_traits , doc="Reference to container traits. See " "pygccxml documentation for STD container traits.") - + def _get_element_type(self): return self.__container_traits.element_type( self.container_class ) element_type = property( _get_element_type - , doc="Reference to container value_type( mapped_type ) type" ) - + , doc="Reference to container value_type( mapped_type ) type" ) + def _get_call_policies( self ): #TODO find out call policies return self.__call_policies @@ -86,26 +89,26 @@ def __apply_defaults_if_needed( self ): if self._default_applied: - return + return self._default_applied = True #find out what operators are supported by element_type and #then configure the _disable_[methods|groups] pass - + def disable_method( self, method_name ): """Disable method from being exposed""" assert method_name in self.METHODS self.__apply_defaults_if_needed() self._disabled_methods.add( method_name ) - + def enable_method( self, method_name ): """Enable method to be exposed""" assert method_name in self.METHODS self.__apply_defaults_if_needed() if method_name in self._disabled_methods: self._disabled_methods.remove( method_name ) - - def _get_disabled_methods( self ): + + def _get_disabled_methods( self ): self.__apply_defaults_if_needed() return self._disabled_methods disable_methods = property( _get_disabled_methods @@ -116,16 +119,16 @@ assert group_name in self.METHOD_GROUPS self.__apply_defaults_if_needed() self._disabled_groups.add( group_name ) - + def enable_methods_group( self, group_name ): """Enable methods group to be exposed""" assert group_name in self.METHOD_GROUPS self.__apply_defaults_if_needed() if group_name in self._disabled_groups: self._disabled_groups.remove( group_name ) - - def _get_disabled_methods_groups( self ): + + def _get_disabled_methods_groups( self ): self.__apply_defaults_if_needed() return self._disabled_groups disabled_methods_groups = property( _get_disabled_methods_groups - , doc="list of all disabled methods group") \ No newline at end of file + , doc="list of all disabled methods group") Modified: pyplusplus_dev/pyplusplus/decl_wrappers/namespace_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/namespace_wrapper.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/pyplusplus/decl_wrappers/namespace_wrapper.py 2006-08-21 13:42:15 UTC (rev 429) @@ -3,11 +3,18 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +"""defines class that configure namespace exposing.""" + import scopedef_wrapper from pygccxml import declarations class namespace_t(scopedef_wrapper.scopedef_t, declarations.namespace_t): + """defines a set of properties, that will instruct Py++ how to expose the namespace + + Today, Py++ does not exposes namespaces, but this could be changed in future. + The future direction I see here, is to expose every namespace as sub-module + of the main one. + """ def __init__(self, *arguments, **keywords): scopedef_wrapper.scopedef_t.__init__( self ) declarations.namespace_t.__init__(self, *arguments, **keywords ) - \ No newline at end of file Modified: pyplusplus_dev/pyplusplus/decl_wrappers/scopedef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/scopedef_wrapper.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/pyplusplus/decl_wrappers/scopedef_wrapper.py 2006-08-21 13:42:15 UTC (rev 429) @@ -3,15 +3,17 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +"""defines base class for L{decl_wrappers.class_t} and L{decl_wrappers.namespace_t} classes""" + import decl_wrapper -class scopedef_t(decl_wrapper.decl_wrapper_t): +class scopedef_t(decl_wrapper.decl_wrapper_t): + """base class for L{decl_wrappers.class_t} and L{decl_wrappers.namespace_t} classes + + It provides convinience functionality: include\\exclude all internal declarations + (not) to be exported. """ - In C++ there are 2 declarations that can contain definition of other - declarations: class and namespace. This class is used as a base class for both - of them. - """ - + def __init__(self): decl_wrapper.decl_wrapper_t.__init__( self ) @@ -19,7 +21,7 @@ """Exclude "self" and child declarations from being exposed.""" self.ignore = True map( lambda decl: decl.exclude(), self.declarations ) - + def include( self ): """Include "self" and child declarations to be exposed.""" self.ignore = False Modified: pyplusplus_dev/pyplusplus/decl_wrappers/typedef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/typedef_wrapper.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/pyplusplus/decl_wrappers/typedef_wrapper.py 2006-08-21 13:42:15 UTC (rev 429) @@ -3,10 +3,19 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -from pygccxml import declarations +"""defines class that configure typedef exposing""" + +from pygccxml import declarations import decl_wrapper class typedef_t(decl_wrapper.decl_wrapper_t, declarations.typedef_t): + """defines a set of properties, that will instruct Py++ how to expose the typedef + + Today, Py++ does not exposes typedefs, but this could be changed in future. + In C++, it is a common practises to give an aliases to the class. May be in + future, Py++ will generate code, that will register all those aliases. + """ + def __init__(self, *arguments, **keywords): declarations.typedef_t.__init__(self, *arguments, **keywords ) - decl_wrapper.decl_wrapper_t.__init__( self ) \ No newline at end of file + decl_wrapper.decl_wrapper_t.__init__( self ) Modified: pyplusplus_dev/pyplusplus/decl_wrappers/user_text.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/user_text.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/pyplusplus/decl_wrappers/user_text.py 2006-08-21 13:42:15 UTC (rev 429) @@ -3,15 +3,19 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +"defines few classes, used by L{decl_wrapper.class_t} class to keep user code" + class user_text_t(object): + "keeps reference to user code that belongs to declaration section" def __init__( self, text ): object.__init__( self ) self.text = text class class_user_text_t( user_text_t ): + "keeps reference to user code that belongs to registration section" def __init__( self, text, works_on_instance=True ): """works_on_instance: If true, the custom code can be applied directly to obj inst. Ex: ObjInst."CustomCode" """ user_text_t.__init__( self, text ) - self.works_on_instance = works_on_instance \ No newline at end of file + self.works_on_instance = works_on_instance Modified: pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py 2006-08-21 13:42:15 UTC (rev 429) @@ -3,29 +3,29 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -from pygccxml import declarations +"""defines class that configure global and member variable exposing""" + +from pygccxml import declarations import decl_wrapper class variable_t(decl_wrapper.decl_wrapper_t, declarations.variable_t): - - """This class helps user to expose member and global variables.""" - + """defines a set of properties, that will instruct Py++ how to expose the variable""" def __init__(self, *arguments, **keywords): declarations.variable_t.__init__(self, *arguments, **keywords ) decl_wrapper.decl_wrapper_t.__init__( self ) self._getter_call_policies = None self._setter_call_policies = None - + __call_policies_doc__ = \ - """There are usecase, when exporting member variable forces Py++ to + """There are usecase, when exporting member variable forces Py++ to create accessors functions. Sometime, those functions requires call policies. To be more specific: when you export member variable that has reference or - pointer type, you need to tell boost.python library how to manage object - life-time. In all cases, Py++ will give reasonable default value. I am - sure, that there are use cases, when you need to change it. You should use this - property to change it. + pointer type, you need to tell Boost.Python library how to manage object + life-time. In all cases, Py++ will give reasonable default value. I am + sure, that there are use cases, when you will have to change it. You should + use this property to change it. """ - + def get_getter_call_policies( self ): return self._getter_call_policies def set_getter_call_policies( self, call_policies ): @@ -52,7 +52,7 @@ return "Py++ can not expose static pointer member variables. This could be changed in future." if declarations.is_fundamental( type_.base ): return "Py++ can not expose pointer to fundamental member variables. This could be changed in future." - + units = declarations.decompose_type( type_ ) ptr2functions = filter( lambda unit: isinstance( unit, declarations.calldef_type_t ) , units ) @@ -65,4 +65,3 @@ if not cls.name: return "Py++ can not expose variables of with unnamed type." return '' - \ No newline at end of file Modified: pyplusplus_dev/setup.py =================================================================== --- pyplusplus_dev/setup.py 2006-08-21 08:29:47 UTC (rev 428) +++ pyplusplus_dev/setup.py 2006-08-21 13:42:15 UTC (rev 429) @@ -50,7 +50,7 @@ print "Generating epydoc files..." - docindex = build_doc_index(['Py++', 'pygccxml']) + docindex = build_doc_index(['pyplusplus', 'pygccxml']) html_writer = HTMLWriter( docindex , prj_name='Py++' , prj_url='http://www.language-binding.net' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |