pygccxml-commit Mailing List for C++ Python language bindings (Page 50)
Brought to you by:
mbaas,
roman_yakovenko
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(190) |
Apr
(166) |
May
(170) |
Jun
(75) |
Jul
(105) |
Aug
(131) |
Sep
(99) |
Oct
(84) |
Nov
(67) |
Dec
(54) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(66) |
Feb
(49) |
Mar
(25) |
Apr
(62) |
May
(21) |
Jun
(34) |
Jul
(9) |
Aug
(21) |
Sep
(5) |
Oct
|
Nov
(63) |
Dec
(34) |
| 2008 |
Jan
(10) |
Feb
(42) |
Mar
(26) |
Apr
(25) |
May
(6) |
Jun
(40) |
Jul
(18) |
Aug
(29) |
Sep
(6) |
Oct
(32) |
Nov
(14) |
Dec
(56) |
| 2009 |
Jan
(127) |
Feb
(52) |
Mar
(2) |
Apr
(10) |
May
(29) |
Jun
(3) |
Jul
|
Aug
(16) |
Sep
(4) |
Oct
(11) |
Nov
(8) |
Dec
(14) |
| 2010 |
Jan
(31) |
Feb
(1) |
Mar
(7) |
Apr
(9) |
May
(1) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
(8) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <rom...@us...> - 2006-10-05 06:23:14
|
Revision: 622
http://svn.sourceforge.net/pygccxml/?rev=622&view=rev
Author: roman_yakovenko
Date: 2006-10-04 23:23:06 -0700 (Wed, 04 Oct 2006)
Log Message:
-----------
adding first draft of convenience functions
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_repository/__init__.py
Added Paths:
-----------
pyplusplus_dev/pyplusplus/code_repository/convenience.py
Modified: pyplusplus_dev/pyplusplus/code_repository/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/__init__.py 2006-10-04 13:01:57 UTC (rev 621)
+++ pyplusplus_dev/pyplusplus/code_repository/__init__.py 2006-10-05 06:23:06 UTC (rev 622)
@@ -6,7 +6,7 @@
"""
Code repository package is used as a repository of C++ classes/functions.
Those classes/functions solve problems, that are typical to most projects.
-Right now, this package contains set of classes that help to export one
+Right now, this package contains set of classes that help to export one
dimensional static arrays. For example:
C{char data[23];}
@@ -15,5 +15,9 @@
import array_1
import gil_guard
+import convenience
-all = [ array_1, gil_guard ]
+all = [ array_1, gil_guard, convenience ]
+
+headers = map( lambda f: f.file_name, all )
+
Added: pyplusplus_dev/pyplusplus/code_repository/convenience.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/convenience.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_repository/convenience.py 2006-10-05 06:23:06 UTC (rev 622)
@@ -0,0 +1,79 @@
+# Copyright 2004 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)
+
+"""
+This file contains C++ code needed to export one dimensional static arrays.
+"""
+
+
+namespace = "pyplusplus::convenience"
+
+file_name = "__convenience.pypp.hpp"
+
+code = \
+"""// Copyright 2004 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 __convenience_pyplusplus_hpp__
+#define __convenience_pyplusplus_hpp__
+
+#include "boost/python.hpp"
+
+//1 - dimension
+namespace pyplusplus{ namespace convenience{
+
+void raise_error( PyObject *exception, const char *message ){
+
+ PyErr_SetString(exception, message);
+ boost::python::throw_error_already_set();
+
+}
+
+void ensure_sequence( boost::python::object seq, Py_ssize_t expected_length=-1 ){
+
+ PyObject* seq_impl = seq.ptr();
+
+ if( !PySequence_Check( seq_impl ) ){
+ raise_error( PyExc_TypeError, "Sequence expected" );
+ }
+
+ Py_ssize_t length = PySequence_Length( seq_impl );
+ if( expected_length != -1 && length != expected_length ){
+ std::stringstream err;
+ err << "Expected sequence length is " << expected_length << ". "
+ << "Actual sequence length is " << length << ".";
+ raise_error( PyExc_ValueError, err.str().c_str() );
+ }
+
+}
+
+template< class ExpectedType >
+void ensure_uniform_sequence( boost::python::object seq, Py_ssize_t expected_length=-1 ){
+
+ ensure_sequence( seq, expected_length );
+ Py_ssize_t length = boost::python::len( seq );
+ for( Py_ssize_t index = 0; index < length; ++index ){
+ boost::python::object item = seq[index];
+ boost::python::extract<ExpectedType> type_checker( item );
+ if( type_checker.check() ){
+ const boost::python::type_info expected_type_info( boost::python::type_id<ExpectedType>() );
+ //TODO: How to extract type_info from PyObject?
+ std::stringstream err;
+ err << "Sequence should contain only items with type \"" << expected_type_info.name() << "\". "
+ << "Item at position " << index << " has different type.";
+ raise_error( PyExc_ValueError, err.str().c_str() );
+ }
+ }
+
+}
+
+} /*pyplusplus*/ } /*convenience*/
+
+
+#endif//__convenience_pyplusplus_hpp__
+
+"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mb...@us...> - 2006-10-04 13:02:01
|
Revision: 621
http://svn.sourceforge.net/pygccxml/?rev=621&view=rev
Author: mbaas
Date: 2006-10-04 06:01:57 -0700 (Wed, 04 Oct 2006)
Log Message:
-----------
The wrapper function name now contains the class name if the wrapper is a free function (this will prevent name clashes).
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2006-10-04 12:51:37 UTC (rev 620)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2006-10-04 13:01:57 UTC (rev 621)
@@ -89,7 +89,21 @@
return_type=rettype
, arguments_types=map( lambda arg: arg.type, self.declaration.arguments ) )
+ def wrapper_name(self):
+ """Return the name of the wrapper function.
+
+ This is just the local name without any scope information.
+ """
+ # A list with the individual components of the name
+ components = ["_py"]
+ # Is the wrapper placed outside a wrapper class?
+ if not isinstance(self.parent, class_declaration.class_wrapper_t):
+ # Incorporate the original class name into the name
+ components.append(self.declaration.parent.name)
+ components.append(self.declaration.alias)
+ return "_".join(components)
+
def full_name(self):
"""Return the full name of the wrapper function.
@@ -98,9 +112,9 @@
@rtype: str
"""
if isinstance(self.parent, class_declaration.class_wrapper_t):
- return self.parent.full_name + '::_py_' + self.declaration.alias
+ return self.parent.full_name + '::' + self.wrapper_name()
else:
- return '_py_' + self.declaration.alias
+ return self.wrapper_name()
def create_sig_id(self):
"""Create an ID string that identifies a signature.
@@ -119,7 +133,7 @@
template = self._subst_manager.subst_wrapper(template)
return template % {
- 'name' : "_py_"+name
+ 'name' : self.wrapper_name()
, 'throw' : self.throw_specifier_code()
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-10-04 12:51:44
|
Revision: 620
http://svn.sourceforge.net/pygccxml/?rev=620&view=rev
Author: roman_yakovenko
Date: 2006-10-04 05:51:37 -0700 (Wed, 04 Oct 2006)
Log Message:
-----------
uncommenting set_arguments
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/calldef.py
Modified: pygccxml_dev/pygccxml/declarations/calldef.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/calldef.py 2006-10-04 12:17:55 UTC (rev 619)
+++ pygccxml_dev/pygccxml/declarations/calldef.py 2006-10-04 12:51:37 UTC (rev 620)
@@ -129,9 +129,9 @@
def _get_arguments(self):
return self._arguments
- #~ def _set_arguments(self, arguments):
- #~ self._arguments = arguments
- arguments = property( _get_arguments #, _set_arguments
+ def _set_arguments(self, arguments):
+ self._arguments = arguments
+ arguments = property( _get_arguments , _set_arguments
, doc="""The argument list.
@type: list of L{argument_t}""")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mb...@us...> - 2006-10-04 12:18:00
|
Revision: 619
http://svn.sourceforge.net/pygccxml/?rev=619&view=rev
Author: mbaas
Date: 2006-10-04 05:17:55 -0700 (Wed, 04 Oct 2006)
Log Message:
-----------
Minor bugfix: access_type filtering was constraining the type to METHOD but there are also other member types.
Modified Paths:
--------------
pyplusplus_dev/contrib/pypp_api/pypp_api/decltypes.py
pyplusplus_dev/contrib/pypp_api/pypp_api/declwrapper.py
pyplusplus_dev/contrib/pypp_api/pypp_api/filters.py
Modified: pyplusplus_dev/contrib/pypp_api/pypp_api/decltypes.py
===================================================================
--- pyplusplus_dev/contrib/pypp_api/pypp_api/decltypes.py 2006-10-04 09:53:10 UTC (rev 618)
+++ pyplusplus_dev/contrib/pypp_api/pypp_api/decltypes.py 2006-10-04 12:17:55 UTC (rev 619)
@@ -19,6 +19,7 @@
VARIABLE = 0x40
CALLABLE = METHOD | FUNCTION | CONSTRUCTOR
+CLASS_MEMBER = METHOD | CONSTRUCTOR | VARIABLE | ENUM
# cpp
class cpp:
@@ -70,4 +71,4 @@
elif type(val)==str:
return '"%s"'%val
else:
- return str(val)
\ No newline at end of file
+ return str(val)
Modified: pyplusplus_dev/contrib/pypp_api/pypp_api/declwrapper.py
===================================================================
--- pyplusplus_dev/contrib/pypp_api/pypp_api/declwrapper.py 2006-10-04 09:53:10 UTC (rev 618)
+++ pyplusplus_dev/contrib/pypp_api/pypp_api/declwrapper.py 2006-10-04 12:17:55 UTC (rev 619)
@@ -468,7 +468,7 @@
@type header: str
@param headerdir: Select declarations by the directory in which their header file is located
@type headerdir: str
- @param accesstype: Access type (PUBLIC or PROTECTED). This implies the type flag MEMBER_FUNCTION.
+ @param accesstype: Access type (PUBLIC or PROTECTED). This implies the type flags CLASS_MEMBER.
@param const: Select declarations by their constness.
@type const: bool
@param filter: User defined filter function
@@ -525,7 +525,7 @@
# accesstype filter
if accesstype!=None:
addFilter(accesstype, AccessTypeFilter)
- itype |= METHOD
+ itype |= CLASS_MEMBER
# const filter
if const!=None:
addFilter(const, ConstFilter)
Modified: pyplusplus_dev/contrib/pypp_api/pypp_api/filters.py
===================================================================
--- pyplusplus_dev/contrib/pypp_api/pypp_api/filters.py 2006-10-04 09:53:10 UTC (rev 618)
+++ pyplusplus_dev/contrib/pypp_api/pypp_api/filters.py 2006-10-04 12:17:55 UTC (rev 619)
@@ -429,7 +429,13 @@
return "accesstype==%s"%self.accesstype
def __call__(self, decl):
- at = getattr(decl, "access_type", None)
+ try:
+ at = getattr(decl, "access_type", None)
+ except RuntimeError, e:
+ # Accessing access_type on non-member variables
+ # raises an error
+ at = None
+
if at==None:
return False
return at==self.accesstype
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-10-04 09:53:20
|
Revision: 618
http://svn.sourceforge.net/pygccxml/?rev=618&view=rev
Author: roman_yakovenko
Date: 2006-10-04 02:53:10 -0700 (Wed, 04 Oct 2006)
Log Message:
-----------
adding access_type for variable_t class
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/variable.py
pygccxml_dev/unittests/variable_matcher_tester.py
Modified: pygccxml_dev/pygccxml/declarations/variable.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/variable.py 2006-10-03 22:14:04 UTC (rev 617)
+++ pygccxml_dev/pygccxml/declarations/variable.py 2006-10-04 09:53:10 UTC (rev 618)
@@ -8,6 +8,7 @@
"""
import declaration
+import class_declaration
class variable_t( declaration.declaration_t ):
"""describes C++ global and member variable declaration"""
@@ -60,3 +61,10 @@
self._bits = bits
bits = property( _get_bits, _set_bits
, doc="integer, that contains information about how many bit takes bit field")
+
+ @property
+ def access_type(self):
+ if not isinstance( self.parent, class_declaration.class_t ):
+ raise RuntimeError( "access_type functionality only available on member variables and not on global variables" )
+ return self.parent.find_out_member_access_type( self )
+
Modified: pygccxml_dev/unittests/variable_matcher_tester.py
===================================================================
--- pygccxml_dev/unittests/variable_matcher_tester.py 2006-10-03 22:14:04 UTC (rev 617)
+++ pygccxml_dev/unittests/variable_matcher_tester.py 2006-10-04 09:53:10 UTC (rev 618)
@@ -13,33 +13,35 @@
from pygccxml import declarations
class tester_t( parser_test_case.parser_test_case_t ):
- COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE
+ COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE
def __init__(self, *args ):
parser_test_case.parser_test_case_t.__init__( self, *args )
self.header = 'bit_fields.hpp'
self.declarations = None
-
+
def setUp(self):
if not self.declarations:
self.declarations = parser.parse( [self.header], self.config )
-
- def test( self ):
+
+ def test( self ):
criteria = declarations.variable_matcher_t( name='x', type='unsigned int' )
x = declarations.matcher.get_single( criteria, self.declarations )
-
+
self.failUnless( str(criteria) == '(decl type==variable_t) and (name==x) and (value type==unsigned int)' )
-
- criteria = declarations.variable_matcher_t(
+
+ criteria = declarations.variable_matcher_t(
name='::bit_fields::fields_t::x'
, type=declarations.unsigned_int_t()
, header_dir=os.path.dirname(x.location.file_name)
, header_file=x.location.file_name)
-
+
x = declarations.matcher.get_single( criteria, self.declarations )
self.failUnless( x, "Variable was not found." )
+ self.failUnless( 'public' == x.access_type )
+
def create_suite():
- suite = unittest.TestSuite()
+ suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(tester_t))
return suite
@@ -47,4 +49,4 @@
unittest.TextTestRunner(verbosity=2).run( create_suite() )
if __name__ == "__main__":
- run_suite()
\ No newline at end of file
+ run_suite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-10-04 01:40:24
|
Revision: 613
http://svn.sourceforge.net/pygccxml/?rev=613&view=rev
Author: roman_yakovenko
Date: 2006-10-02 13:45:21 -0700 (Mon, 02 Oct 2006)
Log Message:
-----------
adding small algorithm that will discover class properties
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
pyplusplus_dev/pyplusplus/decl_wrappers/properties.py
pyplusplus_dev/unittests/data/properties_to_be_exported.hpp
pyplusplus_dev/unittests/properties_tester.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-10-01 19:49:39 UTC (rev 612)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-10-02 20:45:21 UTC (rev 613)
@@ -333,6 +333,10 @@
"""
self._properties.append( properties.property_t( name, fget, fset, doc ) )
+ def add_properties( self, recognizer=None, exclude_accessors=False ):
+ props = properties.find_properties( self, recognizer, exclude_accessors )
+ self.properties.extend( props )
+
def add_static_property( self, name, fget, fset=None, doc='' ):
"""adds new static property to the class"""
self._properties.append( properties.property_t( name, fget, fset, doc, True ) )
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/properties.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-10-01 19:49:39 UTC (rev 612)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-10-02 20:45:21 UTC (rev 613)
@@ -43,15 +43,224 @@
desc.append( 'fset=%s' % declarations.full_name( self.fset ) )
return "property [%s]"% ''.join( desc )
-def find_properties( cls ):
- """this function should return a list of possible properties for the class"""
- #get* set*
- #get_* set_*
- #*, set*
- #*, set_*
- #get defined on [derived|base], set defined on [base|derived]
- raise NotImplemented()
+class property_recognizer_i(object):
+ def __init__( self ):
+ object.__init__( self )
+
+ def create_property( self, fget, fset ):
+ raise NotImplementedError()
+ def create_read_only_property( sefl, fget ):
+ raise NotImplementedError()
+
+class name_based_recognizer_t( property_recognizer_i ):
+ def __init__( self ):
+ property_recognizer_i.__init__( self )
+ self.__prefixes = (
+ ( 'is', 'set' )
+ , ( 'get', 'set' )
+ , ( 'has', 'set' )
+ , ( '', 'set' ) )
+ def check_prefix( self, name, prefix ):
+ if len( prefix ) >= len( name ):
+ return False
+ if not name.startswith( prefix ):
+ return False
+ return True
+
+ def check_name_compatibility( self, gname, sname, gprefix, sprefix ):
+ if not self.check_prefix( gname, gprefix ):
+ return False
+ if not self.check_prefix( sname, sprefix ):
+ return False
+ if gname[ len( gprefix ): ] != sname[ len( sprefix ): ]:
+ return False
+ return True
+ def make_std_convention( self, gprefix, sprefix ):
+ convert = lambda x: x + '_'
+ if gprefix:
+ gprefix = convert( gprefix )
+ return ( gprefix, convert( sprefix ) )
+
+ def make_u_camel_convention( self, gprefix, sprefix ):
+ convert = lambda x: x[0].upper() + x[1:]
+ if gprefix:
+ gprefix = convert( gprefix )
+ return ( gprefix, convert( sprefix ) )
+
+ def make_l_camel_convention( self, gprefix, sprefix ):
+ convert = lambda x: x[0].lower() + x[1:]
+ if gprefix:
+ gprefix = convert( gprefix )
+ return ( gprefix, convert( sprefix ) )
+
+ def find_out_prefixes( self, gname, sname ):
+ convention_makers = [
+ self.make_std_convention #longest first
+ , self.make_u_camel_convention
+ , self.make_l_camel_convention ]
+
+ for convention_maker in convention_makers:
+ for g, s in self.__prefixes:
+ gc, sc = convention_maker( g, s )
+ if self.check_name_compatibility( gname, sname, gc, sc ):
+ return ( gc, sc )
+ return None
+
+ def find_out_ro_prefixes( self, gname ):
+ convention_makers = [
+ self.make_std_convention #longest first
+ , self.make_u_camel_convention
+ , self.make_l_camel_convention ]
+
+ for convention_maker in convention_makers:
+ for g, unused in self.__prefixes:
+ gc, unused = convention_maker( g, 'set' )
+ if self.check_prefix( gname, gc ):
+ return gc
+ return None
+
+ def check_type_compatibility( self, fget, fset ):
+ #algorithms allows "const" differences between types
+ t1 = fget.return_type
+ t2 = fset.arguments[0].type
+
+ if declarations.is_same( t1, t2 ):
+ return True
+ elif declarations.is_pointer( t1 ) and declarations.is_pointer( t2 ):
+ t1 = declarations.remove_cv( declarations.remove_pointer( t1 ) )
+ t2 = declarations.remove_cv( declarations.remove_pointer( t2 ) )
+ return declarations.is_same( t1, t2 )
+ elif declarations.is_reference( t1 ) and declarations.is_reference( t2 ):
+ t1 = declarations.remove_cv( declarations.remove_reference( t1 ) )
+ t2 = declarations.remove_cv( declarations.remove_reference( t2 ) )
+ return declarations.is_same( t1, t2 )
+ else:
+ return False
+
+ def create_property( self, fget, fset ):
+ if not self.check_type_compatibility( fget, fset ):
+ return None
+ found = self.find_out_prefixes( fget.name, fset.name )
+ if not found:
+ return None
+ return property_t( fget.name[len(found[0]):], fget, fset )
+
+ def create_read_only_property( self, fget ):
+ found = self.find_out_ro_prefixes( fget.name )
+ if found:
+ return property_t( fget.name[len(found[0]):], fget )
+ else:
+ return None
+
+class properties_finder_t:
+ def __init__( self, cls, recognizer=None, exclude_accessors=False ):
+ self.cls = cls
+ if None is recognizer:
+ recognizer = name_based_recognizer_t()
+ self.recognizer = recognizer
+ self.exclude_accessors = exclude_accessors
+ self.getters, self.setters \
+ = self.__get_accessors( cls.member_functions( recursive=False, allow_empty=True ) )
+
+ inherted_mem_funs = []
+ for hierarchy_info in cls.recursive_bases:
+ if hierarchy_info.related_class.ignore: #don't scan excluded classes
+ continue
+ if 'public' != hierarchy_info.access_type: #don't scan non public hierarchy
+ continue
+ base_cls = hierarchy_info.related_class
+ inherted_mem_funs.extend( base_cls.member_functions( recursive=False, allow_empty=True ) )
+
+ self.inherited_getters, self.inherited_setters \
+ = self.__get_accessors( inherted_mem_funs )
+
+ def __is_getter( self, mem_fun ):
+ if mem_fun.arguments:
+ return False
+ if declarations.is_void( mem_fun.return_type ):
+ return False
+ if not mem_fun.has_const:
+ return False
+ return True
+
+ def __is_setter( self, mem_fun ):
+ if len( mem_fun.arguments ) != 1:
+ return False
+ if not declarations.is_void( mem_fun.return_type ):
+ return False
+ if mem_fun.has_const:
+ return False
+ return True
+
+ def __get_accessors( self, mem_funs ):
+ getters = []
+ setters = []
+ for mem_fun in mem_funs:
+ if mem_fun.ignore:
+ continue
+ elif mem_fun.access_type != 'public':
+ continue
+ elif mem_fun.has_static:
+ continue #TODO: should be supported
+ elif mem_fun.virtuality == declarations.VIRTUALITY_TYPES.PURE_VIRTUAL:
+ continue
+ elif self.__is_getter( mem_fun ):
+ getters.append( mem_fun )
+ elif self.__is_setter( mem_fun ):
+ setters.append( mem_fun )
+ else:
+ continue
+ return ( getters, setters )
+
+ def find_properties( self, getters, setters, used_getters, used_setters ):
+ properties = []
+ for fget in getters:
+ if fget in used_getters:
+ continue
+ for fset in setters:
+ if fset in used_setters:
+ continue
+ property_ = self.recognizer.create_property( fget, fset )
+ if property_:
+ used_getters.add( fget )
+ used_setters.add( fset )
+ properties.append( property_ )
+ break
+ return properties
+
+ def __call__( self ):
+ used_getters = set()
+ used_setters = set()
+ properties = []
+ #this get, this set
+ properties.extend(
+ self.find_properties( self.getters, self.setters, used_getters, used_setters ) )
+ #this get, base set
+ properties.extend(
+ self.find_properties( self.getters, self.inherited_setters, used_getters, used_setters ) )
+ #base get, this set
+ properties.extend(
+ self.find_properties( self.inherited_getters, self.setters, used_getters, used_setters ) )
+
+ for fget in self.getters:
+ if fget in used_getters:
+ continue
+ property_ = self.recognizer.create_read_only_property( fget )
+ if property_:
+ used_getters.add( fget )
+ properties.append( property_ )
+
+ if self.exclude_accessors:
+ map( lambda accessor: accessor.exclude(), used_getters )
+ map( lambda accessor: accessor.exclude(), used_setters )
+
+ return properties
+
+def find_properties( cls, recognizer=None, exclude_accessors=False ):
+ pf = properties_finder_t( cls, recognizer, exclude_accessors )
+ properties = pf()
+ return properties
\ No newline at end of file
Modified: pyplusplus_dev/unittests/data/properties_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/properties_to_be_exported.hpp 2006-10-01 19:49:39 UTC (rev 612)
+++ pyplusplus_dev/unittests/data/properties_to_be_exported.hpp 2006-10-02 20:45:21 UTC (rev 613)
@@ -24,16 +24,31 @@
void set_count( int x )
{ m_count = x; }
- nested& get_nested()
+ const nested& get_nested() const
{ return m_nested; }
void set_nested( nested x )
{ m_nested = x; }
-
+
int m_count;
nested m_nested;
};
+struct properties_finder_tester_t{
+
+ int count() const { return 0; }
+ void set_count( int ){}
+
+ int get_size() const { return 0; }
+ void set_size( int ){}
+
+ int getWidth() const { return 0; }
+ void setWidth(int) {}
+
+ int GetHeight() const { return 0; }
+ void SetHeight(int){}
+
+};
}
Modified: pyplusplus_dev/unittests/properties_tester.py
===================================================================
--- pyplusplus_dev/unittests/properties_tester.py 2006-10-01 19:49:39 UTC (rev 612)
+++ pyplusplus_dev/unittests/properties_tester.py 2006-10-02 20:45:21 UTC (rev 613)
@@ -33,6 +33,10 @@
cls.add_property( "nested_", get_nested, set_nested )
cls.add_property( "nested_ro", get_nested )
+
+ cls = mb.class_( 'properties_finder_tester_t' )
+ cls.add_properties( exclude_accessors=True )
+ self.failUnless( 4 == len( cls.properties ) )
def run_tests(self, module):
pt = module.properties_tester_t()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-10-04 00:48:47
|
Revision: 614
http://svn.sourceforge.net/pygccxml/?rev=614&view=rev
Author: roman_yakovenko
Date: 2006-10-03 00:01:44 -0700 (Tue, 03 Oct 2006)
Log Message:
-----------
fixing bug in add_properties algorithm
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/properties.py
pyplusplus_dev/unittests/data/properties_to_be_exported.hpp
pyplusplus_dev/unittests/properties_tester.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/properties.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-10-02 20:45:21 UTC (rev 613)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-10-03 07:01:44 UTC (rev 614)
@@ -47,17 +47,17 @@
class property_recognizer_i(object):
def __init__( self ):
object.__init__( self )
-
+
def create_property( self, fget, fset ):
raise NotImplementedError()
def create_read_only_property( sefl, fget ):
raise NotImplementedError()
-
+
class name_based_recognizer_t( property_recognizer_i ):
def __init__( self ):
property_recognizer_i.__init__( self )
- self.__prefixes = (
+ self.__prefixes = (
( 'is', 'set' )
, ( 'get', 'set' )
, ( 'has', 'set' )
@@ -69,7 +69,7 @@
if not name.startswith( prefix ):
return False
return True
-
+
def check_name_compatibility( self, gname, sname, gprefix, sprefix ):
if not self.check_prefix( gname, gprefix ):
return False
@@ -84,13 +84,13 @@
if gprefix:
gprefix = convert( gprefix )
return ( gprefix, convert( sprefix ) )
-
+
def make_u_camel_convention( self, gprefix, sprefix ):
convert = lambda x: x[0].upper() + x[1:]
if gprefix:
gprefix = convert( gprefix )
return ( gprefix, convert( sprefix ) )
-
+
def make_l_camel_convention( self, gprefix, sprefix ):
convert = lambda x: x[0].lower() + x[1:]
if gprefix:
@@ -98,7 +98,7 @@
return ( gprefix, convert( sprefix ) )
def find_out_prefixes( self, gname, sname ):
- convention_makers = [
+ convention_makers = [
self.make_std_convention #longest first
, self.make_u_camel_convention
, self.make_l_camel_convention ]
@@ -111,17 +111,19 @@
return None
def find_out_ro_prefixes( self, gname ):
- convention_makers = [
+ convention_makers = [
self.make_std_convention #longest first
, self.make_u_camel_convention
, self.make_l_camel_convention ]
for convention_maker in convention_makers:
for g, unused in self.__prefixes:
+ if not g:
+ continue
gc, unused = convention_maker( g, 'set' )
if self.check_prefix( gname, gc ):
return gc
- return None
+ return ''
def check_type_compatibility( self, fget, fset ):
#algorithms allows "const" differences between types
@@ -140,7 +142,7 @@
return declarations.is_same( t1, t2 )
else:
return False
-
+
def create_property( self, fget, fset ):
if not self.check_type_compatibility( fget, fset ):
return None
@@ -151,10 +153,10 @@
def create_read_only_property( self, fget ):
found = self.find_out_ro_prefixes( fget.name )
- if found:
- return property_t( fget.name[len(found[0]):], fget )
+ if None is found:
+ return None
else:
- return None
+ return property_t( fget.name[len(found):], fget )
class properties_finder_t:
def __init__( self, cls, recognizer=None, exclude_accessors=False ):
@@ -177,7 +179,7 @@
self.inherited_getters, self.inherited_setters \
= self.__get_accessors( inherted_mem_funs )
-
+
def __is_getter( self, mem_fun ):
if mem_fun.arguments:
return False
@@ -186,7 +188,7 @@
if not mem_fun.has_const:
return False
return True
-
+
def __is_setter( self, mem_fun ):
if len( mem_fun.arguments ) != 1:
return False
@@ -195,7 +197,7 @@
if mem_fun.has_const:
return False
return True
-
+
def __get_accessors( self, mem_funs ):
getters = []
setters = []
@@ -231,21 +233,21 @@
properties.append( property_ )
break
return properties
-
+
def __call__( self ):
used_getters = set()
used_setters = set()
properties = []
#this get, this set
- properties.extend(
+ properties.extend(
self.find_properties( self.getters, self.setters, used_getters, used_setters ) )
#this get, base set
- properties.extend(
+ properties.extend(
self.find_properties( self.getters, self.inherited_setters, used_getters, used_setters ) )
#base get, this set
- properties.extend(
+ properties.extend(
self.find_properties( self.inherited_getters, self.setters, used_getters, used_setters ) )
-
+
for fget in self.getters:
if fget in used_getters:
continue
@@ -253,14 +255,14 @@
if property_:
used_getters.add( fget )
properties.append( property_ )
-
+
if self.exclude_accessors:
map( lambda accessor: accessor.exclude(), used_getters )
map( lambda accessor: accessor.exclude(), used_setters )
-
+
return properties
-
+
def find_properties( cls, recognizer=None, exclude_accessors=False ):
pf = properties_finder_t( cls, recognizer, exclude_accessors )
properties = pf()
- return properties
\ No newline at end of file
+ return properties
Modified: pyplusplus_dev/unittests/data/properties_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/properties_to_be_exported.hpp 2006-10-02 20:45:21 UTC (rev 613)
+++ pyplusplus_dev/unittests/data/properties_to_be_exported.hpp 2006-10-03 07:01:44 UTC (rev 614)
@@ -29,7 +29,7 @@
void set_nested( nested x )
{ m_nested = x; }
-
+
int m_count;
nested m_nested;
};
@@ -38,16 +38,18 @@
int count() const { return 0; }
void set_count( int ){}
-
+
int get_size() const { return 0; }
void set_size( int ){}
-
+
int getWidth() const { return 0; }
void setWidth(int) {}
-
+
int GetHeight() const { return 0; }
void SetHeight(int){}
-
+
+ int GetType() const { return 0; }
+
};
}
Modified: pyplusplus_dev/unittests/properties_tester.py
===================================================================
--- pyplusplus_dev/unittests/properties_tester.py 2006-10-02 20:45:21 UTC (rev 613)
+++ pyplusplus_dev/unittests/properties_tester.py 2006-10-03 07:01:44 UTC (rev 614)
@@ -26,17 +26,18 @@
set_count.exclude()
cls.add_property( "count", count, set_count )
cls.add_property( "count_ro", count )
-
+
get_nested = cls.member_function( 'get_nested' )
get_nested.call_policies = call_policies.return_internal_reference()
set_nested = cls.member_function( 'set_nested' )
cls.add_property( "nested_", get_nested, set_nested )
cls.add_property( "nested_ro", get_nested )
-
+
cls = mb.class_( 'properties_finder_tester_t' )
cls.add_properties( exclude_accessors=True )
- self.failUnless( 4 == len( cls.properties ) )
+ print len( cls.properties )
+ self.failUnless( 5 == len( cls.properties ) )
def run_tests(self, module):
pt = module.properties_tester_t()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-10-04 00:48:19
|
Revision: 617
http://svn.sourceforge.net/pygccxml/?rev=617&view=rev
Author: roman_yakovenko
Date: 2006-10-03 15:14:04 -0700 (Tue, 03 Oct 2006)
Log Message:
-----------
array bug fix
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/member_variable.py
pyplusplus_dev/unittests/test_all.py
Added Paths:
-----------
pyplusplus_dev/unittests/arrays_bug_tester.py
pyplusplus_dev/unittests/data/arrays_bug_to_be_exported.hpp
Modified: pyplusplus_dev/pyplusplus/code_creators/member_variable.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2006-10-03 12:34:25 UTC (rev 616)
+++ pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2006-10-03 22:14:04 UTC (rev 617)
@@ -347,35 +347,47 @@
"""
def __init__(self, variable, wrapper ):
member_variable_base_t.__init__( self, variable=variable, wrapper=wrapper )
+ self.works_on_instance = False
- def _create_impl( self ):
- assert isinstance( self.wrapper, array_mv_wrapper_t )
+ def _create_body( self ):
+ answer = []
+ answer.append( 'typedef %s;' % self.wrapper.wrapper_creator_type.create_typedef( 'array_wrapper_creator' ) )
+ answer.append( os.linesep * 2 )
+
doc = ''
if self.declaration.type_qualifiers.has_static:
- answer = [ 'add_static_property' ]
+ answer.append( self.parent.class_var_name + '.add_static_property' )
else:
if self.documentation:
doc = self.documentation
- answer = [ 'add_property' ]
+ answer.append( self.parent.class_var_name + '.add_property' )
answer.append( '( ' )
answer.append('"%s"' % self.declaration.name )
answer.append( os.linesep + self.indent( self.PARAM_SEPARATOR ) )
temp = [ algorithm.create_identifier( self, "::boost::python::make_function" ) ]
temp.append( '( ' )
- temp.append( '(%s)(&%s)'
- % ( self.wrapper.wrapper_creator_type
- , self.wrapper.wrapper_creator_full_name ) )
+ temp.append( 'array_wrapper_creator(&%s)' % self.wrapper.wrapper_creator_full_name )
if not self.declaration.type_qualifiers.has_static:
- temp.append( os.linesep + self.indent( self.PARAM_SEPARATOR, 4 ) )
+ temp.append( os.linesep + self.indent( self.PARAM_SEPARATOR, 6 ) )
temp.append( call_policies.with_custodian_and_ward_postcall( 0, 1 ).create(self) )
temp.append( ' )' )
answer.append( ''.join( temp ) )
if doc:
+ answer.append( os.linesep )
answer.append( self.PARAM_SEPARATOR )
answer.append( doc )
answer.append( ' );' )
return ''.join( answer )
+ def _create_impl( self ):
+ answer = []
+ answer.append( '{ //%s, type=%s' % ( self.declaration, self.declaration.type ) )
+ answer.append( os.linesep * 2 )
+ answer.append( self.indent( self._create_body() ) )
+ answer.append( os.linesep )
+ answer.append( '}' )
+ return ''.join( answer )
+
#TODO: generated fucntion should be static and take instance of the wrapped class
#as first argument.
class array_mv_wrapper_t( code_creator.code_creator_t
@@ -388,49 +400,55 @@
code_creator.code_creator_t.__init__( self )
declaration_based.declaration_based_t.__init__( self, declaration=variable)
- def _get_wrapper_type( self ):
- ns_name = code_repository.array_1.namespace
+ @property
+ def wrapper_type( self ):
+ tmpl = "%(namespace)s::%(constness)sarray_1_t< %(item_type)s, %(array_size)d>"
+
+ constness = ''
if declarations.is_const( self.declaration.type ):
- class_name = 'const_array_1_t'
- else:
- class_name = 'array_1_t'
+ constness = 'const_'
+ result = tmpl % {
+ 'namespace' : code_repository.array_1.namespace
+ , 'constness' : constness
+ , 'item_type' : declarations.array_item_type( self.declaration.type ).decl_string
+ , 'array_size': declarations.array_size( self.declaration.type )
+ }
+ return declarations.dummy_type_t( result )
- decl_string = declarations.templates.join(
- '::'.join( [ns_name, class_name] )
- , [ declarations.array_item_type( self.declaration.type ).decl_string
- , str( declarations.array_size( self.declaration.type ) )
- ])
-
- return declarations.dummy_type_t( decl_string )
- wrapper_type = property( _get_wrapper_type )
-
- def _get_wrapper_creator_type(self):
- return declarations.member_function_type_t.create_decl_string(
+ @property
+ def wrapped_class_type( self ):
+ wrapped_cls_type = declarations.declarated_t( self.declaration.parent )
+ if declarations.is_const( self.declaration.type ):
+ wrapped_cls_type = declarations.const_t( wrapped_cls_type )
+ return declarations.reference_t( wrapped_cls_type )
+
+ @property
+ def wrapper_creator_type(self):
+ return declarations.free_function_type_t(
return_type=self.wrapper_type
- , class_decl_string=self.parent.full_name
- , arguments_types=[]
- , has_const=False )
- wrapper_creator_type = property( _get_wrapper_creator_type )
-
- def _get_wrapper_creator_name(self):
+ , arguments_types=[self.wrapped_class_type] )
+
+ @property
+ def wrapper_creator_name(self):
return '_'.join( ['pyplusplus', self.declaration.name, 'wrapper'] )
- wrapper_creator_name = property( _get_wrapper_creator_name )
- def _get_wrapper_creator_full_name(self):
+ @property
+ def wrapper_creator_full_name(self):
return '::'.join( [self.parent.full_name, self.wrapper_creator_name] )
- wrapper_creator_full_name = property( _get_wrapper_creator_full_name )
def _create_impl( self ):
- answer = [self.wrapper_type.decl_string]
- answer.append( ''.join([ self.wrapper_creator_name, '(){']) )
- temp = ''.join([ 'return '
- , self.wrapper_type.decl_string
- , '( '
- , self.declaration.name
- , ' );'])
- answer.append( self.indent( temp ) )
- answer.append('}')
- return os.linesep.join( answer )
+ tmpl = os.linesep.join([
+ "static %(wrapper_type)s"
+ , "%(wrapper_creator_name)s( %(wrapped_class_type)s inst ){"
+ , self.indent( "return %(wrapper_type)s( inst.%(mem_var_ref)s );" )
+ , "}"
+ ])
+ return tmpl % {
+ 'wrapper_type' : self.wrapper_type.decl_string
+ , 'wrapper_creator_name' : self.wrapper_creator_name
+ , 'wrapped_class_type' : self.wrapped_class_type.decl_string
+ , 'mem_var_ref' : self.declaration.name
+ }
class mem_var_ref_t( member_variable_base_t ):
Added: pyplusplus_dev/unittests/arrays_bug_tester.py
===================================================================
--- pyplusplus_dev/unittests/arrays_bug_tester.py (rev 0)
+++ pyplusplus_dev/unittests/arrays_bug_tester.py 2006-10-03 22:14:04 UTC (rev 617)
@@ -0,0 +1,38 @@
+# Copyright 2004 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 = 'arrays_bug'
+
+ def __init__( self, *args ):
+ fundamental_tester_base.fundamental_tester_base_t.__init__(
+ self
+ , tester_t.EXTENSION_NAME
+ , *args )
+
+ def run_tests( self, module):
+ m = module.arrays_bug
+ c = m.container()
+ x = c.items[0].values[0]
+ c.items[0].values[0] = 1
+ y = c.items[0]
+ c.items[0] = m.item()
+
+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()
\ No newline at end of file
Added: pyplusplus_dev/unittests/data/arrays_bug_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/arrays_bug_to_be_exported.hpp (rev 0)
+++ pyplusplus_dev/unittests/data/arrays_bug_to_be_exported.hpp 2006-10-03 22:14:04 UTC (rev 617)
@@ -0,0 +1,17 @@
+// Copyright 2004 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 __arrays_bug_to_be_exported_hpp__
+#define __arrays_bug_to_be_exported_hpp__
+
+struct arrays_bug{
+
+struct item{ int values[10]; };
+
+struct container{ item items[10]; };
+
+};
+
+#endif//__arrays_bug_to_be_exported_hpp__
Modified: pyplusplus_dev/unittests/test_all.py
===================================================================
--- pyplusplus_dev/unittests/test_all.py 2006-10-03 12:34:25 UTC (rev 616)
+++ pyplusplus_dev/unittests/test_all.py 2006-10-03 22:14:04 UTC (rev 617)
@@ -63,6 +63,7 @@
import overloads_macro_tester
import split_module_tester
import properties_tester
+import arrays_bug_tester
def create_suite(times):
testers = [
@@ -122,6 +123,7 @@
, overloads_macro_tester
, split_module_tester
, properties_tester
+ , arrays_bug_tester
]
main_suite = unittest.TestSuite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-10-04 00:47:05
|
Revision: 610
http://svn.sourceforge.net/pygccxml/?rev=610&view=rev
Author: roman_yakovenko
Date: 2006-10-01 12:20:54 -0700 (Sun, 01 Oct 2006)
Log Message:
-----------
fixing code generation for non-public class hierarchies
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/class_declaration.py
Modified: pyplusplus_dev/pyplusplus/code_creators/class_declaration.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2006-09-29 16:45:03 UTC (rev 609)
+++ pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2006-10-01 19:20:54 UTC (rev 610)
@@ -153,7 +153,7 @@
assert isinstance( self.declaration, declarations.class_t )
for base_desc in self.declaration.bases:
assert isinstance( base_desc, declarations.hierarchy_info_t )
- if base_desc.access == declarations.ACCESS_TYPES.PRIVATE:
+ if base_desc.access != declarations.ACCESS_TYPES.PUBLIC:
continue
if base_creators.has_key( id(base_desc.related_class) ):
bases.append( algorithm.create_identifier( self, base_desc.related_class.decl_string ) )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-10-04 00:43:21
|
Revision: 612
http://svn.sourceforge.net/pygccxml/?rev=612&view=rev
Author: roman_yakovenko
Date: 2006-10-01 12:49:39 -0700 (Sun, 01 Oct 2006)
Log Message:
-----------
adding few test cases for recently reported bugs
Modified Paths:
--------------
pyplusplus_dev/unittests/data/classes_to_be_exported.hpp
pyplusplus_dev/unittests/data/split_module_bug_to_be_exported.hpp
Modified: pyplusplus_dev/unittests/data/classes_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/classes_to_be_exported.hpp 2006-10-01 19:37:00 UTC (rev 611)
+++ pyplusplus_dev/unittests/data/classes_to_be_exported.hpp 2006-10-01 19:49:39 UTC (rev 612)
@@ -1,94 +1,100 @@
-// Copyright 2004 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 __classes_to_be_exported_hpp__
-#define __classes_to_be_exported_hpp__
-
-namespace classes{
-
-namespace fundamentals{
-
-struct fundamental1{};
-
-struct fundamental2{};
-
-}
-
-namespace hierarchical{
-
-struct fruit{};
-
-struct apple : public fruit{};
-
-}
-
-namespace noncopyables{
-
-class noncopyable1{
-public:
- noncopyable1(){}
-private:
- noncopyable1( const noncopyable1& );
-};
-
-}
-
-namespace abstracts{
-
-class abstract{
-public:
- abstract(){}
- abstract(int){}
- abstract(int, double, const abstract&){}
-public:
-
- virtual int pure_virtual(const abstract& ) const = 0;
-
- virtual bool overloaded_virtual(){ return true;}
- virtual bool overloaded_virtual(int){ return true;}
-
- virtual int overloaded_pure_virtual(int) const = 0;
- virtual void overloaded_pure_virtual(double) const = 0;
-
- virtual int some_virtual(){ return 1; }
-};
-
-}
-
-namespace constructors{
-
-struct constructor1{
- constructor1(){}
- constructor1( const constructor1& ){}
- constructor1(int x, int y){}
- constructor1(int y, const constructor1& x ){}
-
- constructor1( const double ){}
- struct internal_data{};
- constructor1( const internal_data ){}
-};
-
-}
-
-namespace scope_based{
-struct scope_based_exposer{
- enum EColor{ red, green, blue };
- scope_based_exposer(){}
-};
-}
-
-namespace protected_static{
-class protected_static_t{
-protected:
- static int identity(int x){ return x; }
-
- int invert_sign(int x){ return -1*x; }
-};
-};
-
-}//classes
-
-#endif//__classes_to_be_exported_hpp__
-
+// Copyright 2004 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 __classes_to_be_exported_hpp__
+#define __classes_to_be_exported_hpp__
+
+namespace classes{
+
+namespace fundamentals{
+
+struct fundamental1{};
+
+struct fundamental2{};
+
+}
+
+namespace hierarchical{
+
+struct fruit{};
+
+struct apple : public fruit{};
+
+}
+
+namespace noncopyables{
+
+class noncopyable1{
+public:
+ noncopyable1(){}
+private:
+ noncopyable1( const noncopyable1& );
+};
+
+}
+
+namespace abstracts{
+
+class abstract{
+public:
+ abstract(){}
+ abstract(int){}
+ abstract(int, double, const abstract&){}
+public:
+
+ virtual int pure_virtual(const abstract& ) const = 0;
+
+ virtual bool overloaded_virtual(){ return true;}
+ virtual bool overloaded_virtual(int){ return true;}
+
+ virtual int overloaded_pure_virtual(int) const = 0;
+ virtual void overloaded_pure_virtual(double) const = 0;
+
+ virtual int some_virtual(){ return 1; }
+};
+
+}
+
+namespace constructors{
+
+struct constructor1{
+ constructor1(){}
+ constructor1( const constructor1& ){}
+ constructor1(int x, int y){}
+ constructor1(int y, const constructor1& x ){}
+
+ constructor1( const double ){}
+ struct internal_data{};
+ constructor1( const internal_data ){}
+};
+
+}
+
+namespace scope_based{
+struct scope_based_exposer{
+ enum EColor{ red, green, blue };
+ scope_based_exposer(EColor c=blue){}
+};
+}
+
+namespace protected_static{
+class protected_static_t{
+protected:
+ static int identity(int x){ return x; }
+
+ int invert_sign(int x){ return -1*x; }
+};
+};
+
+namespace non_public_hierarchy{
+
+struct protected_base{};
+struct protected_derived : protected protected_base{};
+
+}
+
+}//classes
+
+#endif//__classes_to_be_exported_hpp__
Modified: pyplusplus_dev/unittests/data/split_module_bug_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/split_module_bug_to_be_exported.hpp 2006-10-01 19:37:00 UTC (rev 611)
+++ pyplusplus_dev/unittests/data/split_module_bug_to_be_exported.hpp 2006-10-01 19:49:39 UTC (rev 612)
@@ -6,10 +6,14 @@
#ifndef __split_module_bug_to_be_exported_hpp__
#define __split_module_bug_to_be_exported_hpp__
+#include <vector>
+
typedef struct opaque_ *opaque_pointer;
inline opaque_pointer get_opaque(){ return 0; }
inline opaque_pointer get_opaque2(){ return 0; }
+typedef std::vector<int> int_vector;
+inline int_vector get_vector(){ return int_vector(); }
#endif//__split_module_to_be_exported_hpp__
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-10-04 00:40:22
|
Revision: 616
http://svn.sourceforge.net/pygccxml/?rev=616&view=rev
Author: roman_yakovenko
Date: 2006-10-03 05:34:25 -0700 (Tue, 03 Oct 2006)
Log Message:
-----------
fixing bug in calldef compare
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/calldef.py
Modified: pygccxml_dev/pygccxml/declarations/calldef.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/calldef.py 2006-10-03 10:04:38 UTC (rev 615)
+++ pygccxml_dev/pygccxml/declarations/calldef.py 2006-10-03 12:34:25 UTC (rev 616)
@@ -111,7 +111,7 @@
def _get__cmp__items( self ):
"""implementation details"""
- items = [ self._sorted_list( self.arguments )
+ items = [ self.arguments
, self.return_type
, self.has_extern
, self._sorted_list( self.exceptions ) ]
@@ -129,9 +129,9 @@
def _get_arguments(self):
return self._arguments
- def _set_arguments(self, arguments):
- self._arguments = arguments
- arguments = property( _get_arguments, _set_arguments
+ #~ def _set_arguments(self, arguments):
+ #~ self._arguments = arguments
+ arguments = property( _get_arguments #, _set_arguments
, doc="""The argument list.
@type: list of L{argument_t}""")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-10-04 00:39:57
|
Revision: 611
http://svn.sourceforge.net/pygccxml/?rev=611&view=rev
Author: roman_yakovenko
Date: 2006-10-01 12:37:00 -0700 (Sun, 01 Oct 2006)
Log Message:
-----------
Fixing bug ingenerated code for next use case:
struct data{
enum EColor{ red, green, blue };
data(EColor c=blue){}
};
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/calldef.py
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2006-10-01 19:20:54 UTC (rev 610)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2006-10-01 19:37:00 UTC (rev 611)
@@ -55,6 +55,18 @@
def param_sep(self):
return os.linesep + self.indent( self.PARAM_SEPARATOR )
+ def should_use_enum_wa( self, arg ):
+ global use_enum_workaround
+ if not declarations.is_enum( arg.type ):
+ return False
+ if use_enum_workaround:
+ return True
+ #enum belongs to the class we are working on
+ if self.declaration.parent is declarations.enum_declaration( arg.type ).parent \
+ and isinstance( self.declaration, declarations.constructor_t ):
+ return True
+ return False
+
def keywords_args(self):
boost_arg = algorithm.create_identifier( self, '::boost::python::arg' )
boost_obj = algorithm.create_identifier( self, '::boost::python::object' )
@@ -71,7 +83,7 @@
and declarations.is_integral( arg_type_no_alias ) \
and not arg.default_value.startswith( arg_type_no_alias.decl_string ):
result.append( '=(%s)(%s)' % ( arg_type_no_alias.decl_string, arg.default_value ) )
- elif use_enum_workaround and declarations.is_enum( arg.type ):
+ elif self.should_use_enum_wa( arg ):
#Work around for bug/missing functionality in boost.python.
#registration order
result.append( '=(long)(%s)' % arg.default_value )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mb...@us...> - 2006-10-03 10:04:42
|
Revision: 615
http://svn.sourceforge.net/pygccxml/?rev=615&view=rev
Author: mbaas
Date: 2006-10-03 03:04:38 -0700 (Tue, 03 Oct 2006)
Log Message:
-----------
Improved error messages (the declaration that caused the error is now mentioned in the exception description).
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py
Modified: pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py
===================================================================
--- pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py 2006-10-03 07:01:44 UTC (rev 614)
+++ pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py 2006-10-03 10:04:38 UTC (rev 615)
@@ -51,7 +51,7 @@
reftype = arg.type
if not (isinstance(reftype, declarations.reference_t) or
isinstance(reftype, declarations.pointer_t)):
- raise ValueError, 'Output variable %d ("%s") must be a reference or a pointer (got %s)'%(self.idx, arg.name, arg.type)
+ raise ValueError, '%s\nOutput variable %d ("%s") must be a reference or a pointer (got %s)'%(sm.decl, self.idx, arg.name, arg.type)
# Declare a local variable that will receive the output value
self.local_var = sm.wrapper_func.declare_local(arg.name, str(reftype.base))
@@ -106,7 +106,7 @@
reftype = arg.type
if not (isinstance(reftype, declarations.reference_t) or
isinstance(reftype, declarations.pointer_t)):
- raise ValueError, 'Input variable %d ("%s") must be a reference or a pointer (got %s)'%(self.idx, arg.name, arg.type)
+ raise ValueError, '%s\nInput variable %d ("%s") must be a reference or a pointer (got %s)'%(sm.decl, self.idx, arg.name, arg.type)
# Create an equivalent argument that is not a reference type
noref_arg = declarations.argument_t(name=arg.name, type=arg.type.base, default_value=arg.default_value)
@@ -142,7 +142,7 @@
reftype = arg.type
if not (isinstance(reftype, declarations.reference_t) or
isinstance(reftype, declarations.pointer_t)):
- raise ValueError, 'InOut variable %d ("%s") must be a reference or a pointer (got %s)'%(self.idx, arg.name, arg.type)
+ raise ValueError, '%s\nInOut variable %d ("%s") must be a reference or a pointer (got %s)'%(sm.decl, self.idx, arg.name, arg.type)
# Create an equivalent argument that is not a reference type
noref_arg = declarations.argument_t(name=arg.name, type=arg.type.base, default_value=arg.default_value)
@@ -213,7 +213,7 @@
if not (isinstance(arg.type, declarations.pointer_t) or
isinstance(arg.type, declarations.array_t)):
- raise ValueError, "Argument %d (%s) must be a pointer."%(self.idx, arg.name)
+ raise ValueError, "%s\nArgument %d (%s) must be a pointer."%(sm.decl, self.idx, arg.name)
# Declare a variable that will hold the Python list
# (this will be the input of the Python call in the virtual function)
@@ -305,7 +305,7 @@
if not (isinstance(arg.type, declarations.pointer_t) or
isinstance(arg.type, declarations.array_t)):
- raise ValueError, "Argument %d (%s) must be a pointer."%(self.idx, arg.name)
+ raise ValueError, "%s\nArgument %d (%s) must be a pointer."%(sm.decl, self.idx, arg.name)
self.argname = arg.name
self.basetype = str(arg.type.base).replace("const", "").strip()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mb...@us...> - 2006-09-29 16:45:10
|
Revision: 609
http://svn.sourceforge.net/pygccxml/?rev=609&view=rev
Author: mbaas
Date: 2006-09-29 09:45:03 -0700 (Fri, 29 Sep 2006)
Log Message:
-----------
1) Emulate the finalize functionality by modifying the decl_wrappers and post-processing the code creator tree. 2) Activate the extended code creator API. 3) Import all call policies at once instead of importing them one by one. 4) Fixed the Var()/Vars() methods. 5) Bugfix: Some decoration methods weren't returning self.
Modified Paths:
--------------
pyplusplus_dev/contrib/pypp_api/pypp_api/__init__.py
pyplusplus_dev/contrib/pypp_api/pypp_api/declwrapper.py
pyplusplus_dev/contrib/pypp_api/pypp_api/modulebuilder.py
Modified: pyplusplus_dev/contrib/pypp_api/pypp_api/__init__.py
===================================================================
--- pyplusplus_dev/contrib/pypp_api/pypp_api/__init__.py 2006-09-29 16:41:06 UTC (rev 608)
+++ pyplusplus_dev/contrib/pypp_api/pypp_api/__init__.py 2006-09-29 16:45:03 UTC (rev 609)
@@ -50,16 +50,17 @@
# Bring in call policies to use
-from pyplusplus.decl_wrappers import return_self
-from pyplusplus.decl_wrappers import return_internal_reference
-from pyplusplus.decl_wrappers import with_custodian_and_ward
-from pyplusplus.decl_wrappers import copy_const_reference
-from pyplusplus.decl_wrappers import copy_non_const_reference
-from pyplusplus.decl_wrappers import manage_new_object
-from pyplusplus.decl_wrappers import reference_existing_object
-from pyplusplus.decl_wrappers import return_by_value
-from pyplusplus.decl_wrappers import return_opaque_pointer
-from pyplusplus.decl_wrappers import return_value_policy
+from pyplusplus.decl_wrappers.call_policies import *
+#from pyplusplus.decl_wrappers import return_self
+#from pyplusplus.decl_wrappers import return_internal_reference
+#from pyplusplus.decl_wrappers import with_custodian_and_ward
+#from pyplusplus.decl_wrappers import copy_const_reference
+#from pyplusplus.decl_wrappers import copy_non_const_reference
+#from pyplusplus.decl_wrappers import manage_new_object
+#from pyplusplus.decl_wrappers import reference_existing_object
+#from pyplusplus.decl_wrappers import return_by_value
+#from pyplusplus.decl_wrappers import return_opaque_pointer
+#from pyplusplus.decl_wrappers import return_value_policy
from pygccxml.declarations import ACCESS_TYPES
PUBLIC = ACCESS_TYPES.PUBLIC
@@ -75,3 +76,5 @@
from pyplusplus.function_transformers.arg_policies import output_array_t as OutputArray
from modulebuilder import ModuleBuilder
+
+import extendcreators
Modified: pyplusplus_dev/contrib/pypp_api/pypp_api/declwrapper.py
===================================================================
--- pyplusplus_dev/contrib/pypp_api/pypp_api/declwrapper.py 2006-09-29 16:41:06 UTC (rev 608)
+++ pyplusplus_dev/contrib/pypp_api/pypp_api/declwrapper.py 2006-09-29 16:45:03 UTC (rev 609)
@@ -191,13 +191,48 @@
def finalize(self):
"""Finalize virtual member functions or an entire class.
- Prevents the generation of wrappers for virtual member functions.
+ This method can be called on classes or individual member functions
+ to prevent the generation of wrapper classes. This is done by
+ resetting the virtuality attribute of the members to "non-virtual"
+ and by ignoring protected and private member functions.
+ A ValueError exception is raised if the method is called on pure
+ virtual functions because those cannot be wrapped without a wrapper
+ class.
+
+ Even when finalize() was successfully called it is still possible
+ that Py++ generates a wrapper class nevertheless. The presence
+ of virtual member functions is only one part of the test whether
+ a wrapper class has to be generated (member variables can also
+ trigger a wrapper class which is not prevented by this method).
"""
self._checkLock()
+ VIRTUALITY_TYPES = pygccxml.declarations.VIRTUALITY_TYPES
for decl in self._iterContained():
+ # Mark the declaration as being finalized
+ decl._pypp_api_finalized = True
+
+ if not isinstance(decl, pygccxml.declarations.member_calldef_t):
+ continue
+
+ if (isinstance(decl, pyplusplus.decl_wrappers.constructor_t) or
+ isinstance(decl, pyplusplus.decl_wrappers.destructor_t)):
+ continue
+
+ if decl.virtuality==VIRTUALITY_TYPES.PURE_VIRTUAL:
+ raise ValueError, "%s\nMember is pure virtual and cannot be finalized."%decl
+
+ # Pretend that this method is a non-virtual method
+ decl.virtuality = VIRTUALITY_TYPES.NOT_VIRTUAL
+
if decoration_log!=None:
self._logDecoration("finalize", decl)
- decl.finalize()
+# decl.finalize()
+
+ # Ignore protected and private methods as these would trigger
+ # the generation of a wrapper class
+ ACCESS_TYPES = pygccxml.declarations.ACCESS_TYPES
+ self.Methods(accesstype=ACCESS_TYPES.PROTECTED, allow_empty=True).ignore()
+ self.Methods(accesstype=ACCESS_TYPES.PRIVATE, allow_empty=True).ignore()
return self
# setPolicy
@@ -213,6 +248,8 @@
self._logDecoration("setPolicy(...)", decl)
decl.call_policies = policy
+ return self
+
# setHeldType
def setHeldType(self, heldtype):
"""Explicitly set the held type.
@@ -257,6 +294,8 @@
decl.function_transformers.extend(list(policies))
# self.modulebuilder.mArgPolicyManager.setArgPolicy(decl, policies)
+ return self
+
# setAttr
def setAttr(self, attr, value):
"""Set an arbitrary attribute.
@@ -294,7 +333,7 @@
@param impl: The name of the C/C++ function that implements the method.
@type impl: str
"""
- self.cdef(name, impl)
+ return self.cdef(name, impl)
# def
@@ -377,6 +416,7 @@
header=None,
headerdir=None,
accesstype=None,
+ const=None,
filter=None,
recursive=None,
allow_empty=None,
@@ -429,6 +469,8 @@
@param headerdir: Select declarations by the directory in which their header file is located
@type headerdir: str
@param accesstype: Access type (PUBLIC or PROTECTED). This implies the type flag MEMBER_FUNCTION.
+ @param const: Select declarations by their constness.
+ @type const: bool
@param filter: User defined filter function
@type callable
@param recursive: Extend the search to grandchildren? If not specified, a global (customizable) default value is used.
@@ -484,6 +526,9 @@
if accesstype!=None:
addFilter(accesstype, AccessTypeFilter)
itype |= METHOD
+ # const filter
+ if const!=None:
+ addFilter(const, ConstFilter)
# custom filters
if filter!=None:
if _type(filter)==list:
@@ -577,7 +622,7 @@
# Vars
def Vars(self, name=None, type=0, **args):
- return self.Vars(name=name, type=type|VARIABLE, **args)
+ return self.Decls(name=name, type=type|VARIABLE, **args)
# Decl
def Decl(self, name=None, **args):
Modified: pyplusplus_dev/contrib/pypp_api/pypp_api/modulebuilder.py
===================================================================
--- pyplusplus_dev/contrib/pypp_api/pypp_api/modulebuilder.py 2006-09-29 16:41:06 UTC (rev 608)
+++ pyplusplus_dev/contrib/pypp_api/pypp_api/modulebuilder.py 2006-09-29 16:45:03 UTC (rev 609)
@@ -316,6 +316,9 @@
# maker = module_creator.creator_t(self.mFinalDecls, module_name=moduleName)
extmodule = maker.create(decl_headers=self.mHeaderFiles)
+ # Preprocess the tree
+ self._preprocessCreatorTree(extmodule)
+
# Let the arg policy manager update the tree...
self.mArgPolicyManager.updateCreators(extmodule)
@@ -526,6 +529,74 @@
self.mEndCreators.append(creator)
# ---------- Internal helpers ----------- #
+ def _preprocessCreatorTree(self, root):
+ """Preprocess the code creator tree.
+
+ Extends the nodes.
+
+ This method has to be called after the code creator tree was
+ generated by Py++.
+
+ @param root: The root of the code creator tree.
+ @type root: code_creator_t
+ """
+
+ # Iterate over the entire code creator tree...
+ for node in root.iter():
+ # If the code creator is based on a declaration, assign
+ # the code creator to the declaration. This makes it easy
+ # to obtain the corresponding code creator from a given
+ # decl_wrapper.
+ if isinstance(node, code_creators.declaration_based_t):
+ # Assign the code creator to the corresponding decl_wrapper
+ node.declaration.code_creator = node
+
+ # Is this a class wrapper creator? Then remove it if it was
+ # created on a finalized class
+ if isinstance(node, code_creators.class_wrapper_t):
+ finalized = getattr(node.declaration, "_pypp_api_finalized", False)
+ if finalized:
+ self._removeWrapperClass(node)
+
+ def _removeWrapperClass(self, wrappernode):
+ """Remove a wrapper class code creator.
+
+ All transformed member functions are moved out of the class
+ (as they are still needed) and then the wrapper class is removed.
+ """
+ class_creator = wrappernode.class_creator
+
+ # Search for members that have function transformers...
+ # (it is iterated over list(iter) so that the tree can be
+ # modified)
+ for node in list(wrappernode.iter()):
+ # Proceed to the next node if we are not dealing with a member
+ # function
+ if not isinstance(node, code_creators.calldef.calldef_wrapper_t):
+ continue
+
+ # Check if the node has function transformers.
+ # If this is the case we must keep that node and move it outside
+ # the wrapper class.
+ if node.declaration.function_transformers:
+ node.remove()
+ node.insertBefore(wrappernode)
+ class_creator.associated_decl_creators.append(node)
+
+ # Remove the class wrapper creator
+ wrappernode.remove()
+
+ # Remove all references to the wrapper creator (except on member
+ # functions with function transformers)
+ for node in class_creator.iter():
+ if not hasattr(node, "wrapper"):
+ continue
+ if isinstance(node, code_creators.calldef.calldef_t):
+ if node.declaration.function_transformers:
+ continue
+ node.wrapper = None
+
+
def buildTemplateFileContents(self):
""" Build up the contents of a file to instantiate the needed templates.
headerFiles - List of header files for this module.
@@ -719,4 +790,4 @@
self.__print_decl_header()
curr_level = self.level + 1
print ' ' * curr_level * self.INDENT_SIZE, 'type: %s value: %s'%(self.__inst.type.decl_string, self.__inst.value)
-
\ No newline at end of file
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mb...@us...> - 2006-09-29 16:41:10
|
Revision: 608
http://svn.sourceforge.net/pygccxml/?rev=608&view=rev
Author: mbaas
Date: 2006-09-29 09:41:06 -0700 (Fri, 29 Sep 2006)
Log Message:
-----------
Added a module that extends the API of the code creator classes. The extended API simplifies manipulating the code creator tree.
Added Paths:
-----------
pyplusplus_dev/contrib/pypp_api/pypp_api/extendcreators.py
Added: pyplusplus_dev/contrib/pypp_api/pypp_api/extendcreators.py
===================================================================
--- pyplusplus_dev/contrib/pypp_api/pypp_api/extendcreators.py (rev 0)
+++ pyplusplus_dev/contrib/pypp_api/pypp_api/extendcreators.py 2006-09-29 16:41:06 UTC (rev 608)
@@ -0,0 +1,107 @@
+# 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)
+#
+# Initial author: Matthias Baas
+
+"""This module contains the interface for manipulating trees.
+
+Just importing the module will attach new methods to the pyplusplus
+code creator base class.
+The extended interface simplifies iterating over the tree and
+manipulating it.
+"""
+
+import pyplusplus.code_creators
+
+# iter
+def iter(self, includeself=True, recursive=True):
+ """Iterate over the code creator tree.
+
+ @param includeself: Should root also be yielded?
+ @type includeself: bool
+ @param recursive: Iterate over grandchildren?
+ @type recursive: bool
+ """
+ if includeself:
+ yield self
+
+ children = getattr(self, "creators", [])
+ for child in children:
+ yield child
+ if recursive:
+ for node in iter(child, includeself=False):
+ yield node
+
+# iterSiblings
+def iterSiblings():
+ pass
+
+# insertBefore
+def insertBefore(self, node):
+ """Insert self before node.
+
+ self will be a sibling of node.
+ """
+ if not isinstance(self, pyplusplus.code_creators.code_creator_t):
+ raise TypeError, "self must be a code creator node."
+ if self.parent!=None:
+ raise ValueError, "self is already inserted into the tree. Remove it first."
+
+ idx = node.parent.creators.index(node)
+ node.parent.adopt_creator(self, idx)
+
+# insertAfter
+def insertAfter(self, node):
+ """Insert self after node.
+
+ self will be a sibling of node.
+ """
+ if not isinstance(self, pyplusplus.code_creators.code_creator_t):
+ raise TypeError, "self must be a code creator node."
+ if self.parent!=None:
+ raise ValueError, "self is already inserted into the tree. Remove it first."
+
+ idx = node.parent.creators.index(node)
+ node.parent.adopt_creator(self, idx+1)
+
+# insertAsChildOf
+def insertAsChildOf(self, parent, index=None):
+ """Insert self as a children of another node.
+
+ Insert self as a children of parent. By default, self is appended to
+ the list of children of parent.
+
+ @param parent: The parent node.
+ @type parent: compound_t
+ @param index: The desired position of self (or None)
+ @type index: int
+ """
+ if not isinstance(parent, pyplusplus.code_creators.compound_t):
+ raise ValueError, "Leaf nodes cannot have children nodes."
+ if not isinstance(self, pyplusplus.code_creators.code_creator_t):
+ raise TypeError, "self must be a code creator node."
+ if self.parent!=None:
+ raise ValueError, "self is already inserted into the tree. Remove it first."
+
+ parent.adopt_creator(self, index)
+
+# remove
+def remove(self):
+ """Remove this node.
+
+ @return: self
+ """
+ self.parent.remove_creator(self)
+ return self
+
+######################################################################
+
+# Update the code_create_t class
+code_creator_t = pyplusplus.code_creators.code_creator_t
+code_creator_t.iter = iter
+code_creator_t.insertBefore = insertBefore
+code_creator_t.insertAfter = insertAfter
+code_creator_t.insertAsChildOf = insertAsChildOf
+code_creator_t.remove = remove
Property changes on: pyplusplus_dev/contrib/pypp_api/pypp_api/extendcreators.py
___________________________________________________________________
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mb...@us...> - 2006-09-29 16:40:19
|
Revision: 607
http://svn.sourceforge.net/pygccxml/?rev=607&view=rev
Author: mbaas
Date: 2006-09-29 09:40:15 -0700 (Fri, 29 Sep 2006)
Log Message:
-----------
Added the ConstFilter class. Small bugfix on the type filter (variables weren't properly processed).
Modified Paths:
--------------
pyplusplus_dev/contrib/pypp_api/pypp_api/filters.py
Modified: pyplusplus_dev/contrib/pypp_api/pypp_api/filters.py
===================================================================
--- pyplusplus_dev/contrib/pypp_api/pypp_api/filters.py 2006-09-29 16:36:53 UTC (rev 606)
+++ pyplusplus_dev/contrib/pypp_api/pypp_api/filters.py 2006-09-29 16:40:15 UTC (rev 607)
@@ -341,6 +341,8 @@
t.append("CONSTRUCTOR")
if f & ENUM:
t.append("ENUM")
+ if f & VARIABLE:
+ t.append("VARIABLE")
return "type==%s"%("|".join(t))
def __call__(self, decl):
@@ -364,6 +366,8 @@
res |= ENUM
elif isinstance(decl, namespace_t):
res |= NAMESPACE
+ elif isinstance(decl, variable_t):
+ res |= VARIABLE
if isinstance(decl, constructor_t):
res |= CONSTRUCTOR
@@ -430,6 +434,27 @@
return False
return at==self.accesstype
+# ConstFilter
+class ConstFilter(FilterBase):
+ """Filter by constness.
+ """
+
+ def __init__(self, constness):
+ """Constructor.
+
+ constness is a boolean that specifies whether a declaration
+ has to be declared const or not to match the filter.
+ """
+ FilterBase.__init__(self)
+ self.constness = constness
+
+ def __str__(self):
+ return "const==%s"%self.constness
+
+ def __call__(self, decl):
+ const = bool(getattr(decl, "has_const", False))
+ return const==self.constness
+
# CustomFilter
class CustomFilter(FilterBase):
"""Filter by user defined function.
@@ -443,4 +468,4 @@
return "custom"
def __call__(self, decl):
- return self.func(decl)
\ No newline at end of file
+ return self.func(decl)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mb...@us...> - 2006-09-29 16:36:57
|
Revision: 606
http://svn.sourceforge.net/pygccxml/?rev=606&view=rev
Author: mbaas
Date: 2006-09-29 09:36:53 -0700 (Fri, 29 Sep 2006)
Log Message:
-----------
A few minor fixes: Remove references on return types. Use the full name for object types.
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/function_transformers/substitution_manager.py
Modified: pyplusplus_dev/pyplusplus/function_transformers/substitution_manager.py
===================================================================
--- pyplusplus_dev/pyplusplus/function_transformers/substitution_manager.py 2006-09-29 15:57:42 UTC (rev 605)
+++ pyplusplus_dev/pyplusplus/function_transformers/substitution_manager.py 2006-09-29 16:36:53 UTC (rev 606)
@@ -214,8 +214,10 @@
ret_type = None
else:
ret_type = decl.return_type
- self.wrapper_func.result_type = str(ret_type)
+# self.wrapper_func.result_type = str(ret_type)
+ self.wrapper_func.result_type = str(declarations.type_traits.remove_reference(ret_type))
self.wrapper_func.result_var = self.wrapper_func.declare_local("result", self.wrapper_func.result_type)
+# self.wrapper_func.result_var = self.wrapper_func.allocate_local("result")
self.wrapper_func.result_exprs = [self.wrapper_func.result_var]
self.virtual_func.ret_type = ret_type
@@ -231,10 +233,10 @@
clsdecl = self._class_decl(decl)
if clsdecl!=None:
if decl.has_static:
- self.wrapper_func.CALL_FUNC_NAME = "%s::%s"%(clsdecl.name, self.wrapper_func.CALL_FUNC_NAME)
+ self.wrapper_func.CALL_FUNC_NAME = "%s::%s"%(declarations.full_name(clsdecl), self.wrapper_func.CALL_FUNC_NAME)
else:
selfname = self.wrapper_func._make_name_unique("self")
- selfarg = declarations.argument_t(selfname, declarations.dummy_type_t("%s&"%clsdecl.name))
+ selfarg = declarations.argument_t(selfname, declarations.dummy_type_t("%s&"%declarations.full_name(clsdecl)))
self.wrapper_func.arg_list.insert(0, selfarg)
self.wrapper_func.CALL_FUNC_NAME = "%s.%s"%(selfname, self.wrapper_func.CALL_FUNC_NAME)
self._insert_arg_idx_offset = 1
@@ -280,6 +282,7 @@
# inside the virtual function.
if len(self.wrapper_func.result_exprs)>0:
self.virtual_func.result_type = "boost::python::object"
+# self.virtual_func.result_var = self.virtual_func.allocate_local("pyresult")
self.virtual_func.result_var = self.virtual_func.declare_local("pyresult", self.virtual_func.result_type)
# self.virtual_func.result_expr = self.virtual_func.result_var
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mb...@us...> - 2006-09-29 15:57:47
|
Revision: 605
http://svn.sourceforge.net/pygccxml/?rev=605&view=rev
Author: mbaas
Date: 2006-09-29 08:57:42 -0700 (Fri, 29 Sep 2006)
Log Message:
-----------
Small bug fix. local_type_str() was broken.
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/function_transformers/code_manager.py
Modified: pyplusplus_dev/pyplusplus/function_transformers/code_manager.py
===================================================================
--- pyplusplus_dev/pyplusplus/function_transformers/code_manager.py 2006-09-28 20:18:57 UTC (rev 604)
+++ pyplusplus_dev/pyplusplus/function_transformers/code_manager.py 2006-09-29 15:57:42 UTC (rev 605)
@@ -188,7 +188,7 @@
@return: Returns the type of the specified local variable.
@rtype: str
"""
- if name in self._allocated_vars:
+ if name not in self._allocated_vars:
raise ValueError, 'The type of local variable "%s" is unknown.'%name
if name not in self._declared_vars:
raise ValueError, 'Local variable "%s" not found.'%name
@@ -247,6 +247,7 @@
# RESULT_VAR_ASSIGNMENT
if self.result_var!=None:
self.RESULT_VAR_ASSIGNMENT = "%s = "%self.result_var
+# self.RESULT_VAR_ASSIGNMENT = "%s %s = "%(self.result_type, self.result_var)
else:
self.RESULT_VAR_ASSIGNMENT = ""
@@ -331,20 +332,30 @@
# argument_t
else:
result_exprs.append(re.name)
-
- # No output values?
- if len(result_exprs)==0:
- self.ret_type = None
- self.result_expr = None
- # Exactly one output value?
- elif len(result_exprs)==1:
- self.ret_type = "boost::python::object"
- self.result_expr = "boost::python::object(%s)"%result_exprs[0]
- # More than one output value...
- else:
- self.ret_type = "boost::python::object"
- self.result_expr = "boost::python::make_tuple(%s)"%(", ".join(result_exprs))
+ if self.result_expr==None:
+ # No output values?
+ if len(result_exprs)==0:
+ self.ret_type = None
+ self.result_expr = None
+ # Exactly one output value?
+ elif len(result_exprs)==1:
+ self.ret_type = "boost::python::object"
+ self.result_expr = "boost::python::object(%s)"%result_exprs[0]
+## self.result_expr = self.result_exprs[0]
+## try:
+## # Try to determine the type of the result expression
+## # (assuming it's just a local variable)
+## self.ret_type = self.local_type_str(self.result_expr)
+## except:
+## # if the above fails, return a generic Python object
+## self.ret_type = "boost::python::object"
+## self.result_expr = "boost::python::object(%s)"%result_exprs[0]
+ # More than one output value...
+ else:
+ self.ret_type = "boost::python::object"
+ self.result_expr = "boost::python::make_tuple(%s)"%(", ".join(result_exprs))
+
# Invoke the inherited method that sets the actual variables
code_manager_t.init_variables(self)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-09-27 11:27:20
|
Revision: 597
http://svn.sourceforge.net/pygccxml/?rev=597&view=rev
Author: roman_yakovenko
Date: 2006-09-27 04:27:13 -0700 (Wed, 27 Sep 2006)
Log Message:
-----------
adding support for template classes
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/properties.py
Modified: pyplusplus_dev/pyplusplus/code_creators/properties.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/properties.py 2006-09-26 20:36:58 UTC (rev 596)
+++ pyplusplus_dev/pyplusplus/code_creators/properties.py 2006-09-27 11:27:13 UTC (rev 597)
@@ -8,7 +8,6 @@
import registration_based
from pygccxml import declarations
-#I am sure in future I will have to treat template classes
class property_t( registration_based.registration_based_t ):
def __init__(self, property_def, wrapper=None ):
registration_based.registration_based_t.__init__( self )
@@ -60,16 +59,61 @@
else:
return True
+ def is_same_parent( self ):
+ pd = self.property_def
+ if not pd.fset:
+ return False
+ return pd.fget.parent is pd.fset.parent
+
+ def create_class_typedef_on_demand( self, f, prefix='' ):
+ if None is f:
+ return ( None, None )
+ if not isinstance( f.parent, declarations.class_t ):
+ return ( None, None )
+ if not declarations.templates.is_instantiation( f.parent.decl_string ):
+ return ( None, None )
+ cls_name = None
+ cls_identifier = algorithm.create_identifier( self, f.parent.decl_string )
+ if prefix:
+ cls_name = prefix + 'class_t'
+ else:
+ cls_name = 'exported_class_t'
+ return ( 'typedef %s %s;' % ( cls_identifier, cls_name ), cls_name )
+
+
def create_property_code( self ):
result = []
param_sep = ', '
if self.has_long_line():
param_sep = os.linesep + self.indent( param_sep )
- result.append( self.create_function_type_alias_code( self.property_def.fget, 'fget' ) )
+ fget_class_typedef_code, fget_class_alias = None, None
+ fset_class_typedef_code, fset_class_alias = None, None
+ if self.is_same_parent():
+ fget_class_typedef_code, fget_class_alias \
+ = self.create_class_typedef_on_demand( self.property_def.fget )
+ fset_class_alias = fget_class_alias
+ fset_class_typedef_code = fget_class_typedef_code
+ else:
+ fget_class_typedef_code, fget_class_alias \
+ = self.create_class_typedef_on_demand( self.property_def.fget, 'fget_' )
+ fset_class_typedef_code, fset_class_alias \
+ = self.create_class_typedef_on_demand( self.property_def.fset, 'fset_' )
+
+ if fget_class_typedef_code:
+ result.append( fget_class_typedef_code )
+
+ if fset_class_typedef_code and fset_class_typedef_code != fget_class_typedef_code:
+ result.append( os.linesep )
+ result.append( fset_class_typedef_code )
+
+ if result:
+ result.append( 2 * os.linesep )
+
+ result.append( self.create_function_type_alias_code( self.property_def.fget, 'fget', fget_class_alias ) )
if self.property_def.fset:
result.append( os.linesep )
- result.append( self.create_function_type_alias_code( self.property_def.fset, 'fset' ) )
+ result.append( self.create_function_type_alias_code( self.property_def.fset, 'fset', fset_class_alias ) )
result.append( 2 * os.linesep )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-09-26 20:37:03
|
Revision: 596
http://svn.sourceforge.net/pygccxml/?rev=596&view=rev
Author: roman_yakovenko
Date: 2006-09-26 13:36:58 -0700 (Tue, 26 Sep 2006)
Log Message:
-----------
it was a mistake to add this folder to Py++
Removed Paths:
-------------
pyplusplus_dev/unittests/impl_conv/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-09-26 20:34:46
|
Revision: 595
http://svn.sourceforge.net/pygccxml/?rev=595&view=rev
Author: roman_yakovenko
Date: 2006-09-26 13:34:29 -0700 (Tue, 26 Sep 2006)
Log Message:
-----------
fixing bug in property_t code creator
updating unit tests
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/properties.py
pyplusplus_dev/unittests/casting_tester.py
pyplusplus_dev/unittests/data/operators_bug_to_be_exported.hpp
pyplusplus_dev/unittests/impl_conv/sconstruct
pyplusplus_dev/unittests/impl_conv/test.py
pyplusplus_dev/unittests/operators_bug_tester.py
pyplusplus_dev/unittests/properties_tester.py
Modified: pyplusplus_dev/pyplusplus/code_creators/properties.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/properties.py 2006-09-26 18:56:36 UTC (rev 594)
+++ pyplusplus_dev/pyplusplus/code_creators/properties.py 2006-09-26 20:34:29 UTC (rev 595)
@@ -53,7 +53,7 @@
pd = self.property_def
if pd.fget.call_policies and not pd.fget.call_policies.is_default():
return True
- elif pd.fset or pd.fset.call_policies or not pd.fset.call_policies.is_default():
+ elif pd.fset or ( pd.fset and ( pd.fset.call_policies or not pd.fset.call_policies.is_default() ) ):
return True
elif pd.doc:
return True
Modified: pyplusplus_dev/unittests/casting_tester.py
===================================================================
--- pyplusplus_dev/unittests/casting_tester.py 2006-09-26 18:56:36 UTC (rev 594)
+++ pyplusplus_dev/unittests/casting_tester.py 2006-09-26 20:34:29 UTC (rev 595)
@@ -26,11 +26,7 @@
self.failUnless( 25 == module.x_value(25) )
self.failUnless( 1 == module.x_value(True) )
self.failUnless( 0 == module.x_value(False) )
- try:
- fv = module.float_vector( 5.0 )
- self.fail( "TypeError exception was not raised" )
- except TypeError:
- pass
+ fv = module.float_vector( 5.0 )
def create_suite():
suite = unittest.TestSuite()
Modified: pyplusplus_dev/unittests/data/operators_bug_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/operators_bug_to_be_exported.hpp 2006-09-26 18:56:36 UTC (rev 594)
+++ pyplusplus_dev/unittests/data/operators_bug_to_be_exported.hpp 2006-09-26 20:34:29 UTC (rev 595)
@@ -1,40 +1,52 @@
-// Copyright 2004 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 __operators_bug_to_be_exported_hpp__
-#define __operators_bug_to_be_exported_hpp__
-
-namespace operators_bug{
-
-template< typename derived_type, typename value_type >
-struct number{
-
- value_type value;
-
- friend derived_type operator+( const derived_type& y, const derived_type& x ){
- derived_type tmp;
- tmp.value = y.value + x.value;
- return tmp;
- }
-protected:
- bool operator==( const derived_type& other ){ return value == other.value; }
-};
-
-struct integral : public number< integral, int >{
- integral operator+( int x ){
- integral tmp;
- tmp.value = value + x;
- return tmp;
- }
-};
-
-struct integral2 : public number< integral, int >{
- //in this case no operator should be redefined
-};
-
-}
-
-
-#endif//__operators_bug_to_be_exported_hpp__
+// Copyright 2004 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 __operators_bug_to_be_exported_hpp__
+#define __operators_bug_to_be_exported_hpp__
+
+namespace operators_bug{
+
+template< typename derived_type, typename value_type >
+struct number{
+
+ value_type value;
+
+ friend derived_type operator+( const derived_type& y, const derived_type& x ){
+ derived_type tmp;
+ tmp.value = y.value + x.value;
+ return tmp;
+ }
+protected:
+ bool operator==( const derived_type& other ){ return value == other.value; }
+};
+
+struct integral : public number< integral, int >{
+ integral operator+( int x ){
+ integral tmp;
+ tmp.value = value + x;
+ return tmp;
+ }
+};
+
+struct integral2 : public number< integral, int >{
+ //in this case no operator should be redefined
+};
+
+struct vector
+{
+ double x;
+ static const vector one;
+
+ vector(double ax) : x(ax) {}
+ vector operator+(const vector& other) const { return vector(x+other.x); }
+
+ virtual void trigger_wrapper() {}
+};
+
+
+}
+
+
+#endif//__operators_bug_to_be_exported_hpp__
\ No newline at end of file
Modified: pyplusplus_dev/unittests/impl_conv/sconstruct
===================================================================
--- pyplusplus_dev/unittests/impl_conv/sconstruct 2006-09-26 18:56:36 UTC (rev 594)
+++ pyplusplus_dev/unittests/impl_conv/sconstruct 2006-09-26 20:34:29 UTC (rev 595)
@@ -1,5 +1,5 @@
-SharedLibrary( target=r'ic_ext'
- , source=[ r'ic.cpp' ]
+SharedLibrary( target=r'operators_ext'
+ , source=[ r'operators_ext.cpp' ]
, LIBS=[ r"boost_python" ]
, LIBPATH=[ r"/home/roman/boost_cvs/bin",r"" ]
, CPPPATH=[ r"/home/roman/boost_cvs",r"/usr/include/python2.4" ]
Modified: pyplusplus_dev/unittests/impl_conv/test.py
===================================================================
--- pyplusplus_dev/unittests/impl_conv/test.py 2006-09-26 18:56:36 UTC (rev 594)
+++ pyplusplus_dev/unittests/impl_conv/test.py 2006-09-26 20:34:29 UTC (rev 595)
@@ -1,3 +1,11 @@
-import ic_ext
+import operators_ext
-ic_ext.float_vector( 5.0 )
+print 'envoke operator+ using old Boost.Python interface'
+old = operators_ext.vector_old()
+tmp = old + operators_ext.vector_old.v_old
+print 'It works.'
+
+print 'envoke operator+ using new Boost.Python interface'
+new = operators_ext.vector_new()
+tmp = new + operators_ext.vector_new.v_new
+print 'If you see this message than the bug was fixed. Thank you.'
Modified: pyplusplus_dev/unittests/operators_bug_tester.py
===================================================================
--- pyplusplus_dev/unittests/operators_bug_tester.py 2006-09-26 18:56:36 UTC (rev 594)
+++ pyplusplus_dev/unittests/operators_bug_tester.py 2006-09-26 20:34:29 UTC (rev 595)
@@ -22,7 +22,7 @@
mb.classes().redefine_operators = True
mb.add_declaration_code( 'const operators_bug::vector operators_bug::vector::one(1);' )
tg = code_creators.target_configuration_t( )
- tg.boost_python_has_wrapper_held_type = False
+ #tg.boost_python_has_wrapper_held_type = False
mb.build_code_creator( self.EXTENSION_NAME, target_configuration=tg )
def run_tests(self, module):
Modified: pyplusplus_dev/unittests/properties_tester.py
===================================================================
--- pyplusplus_dev/unittests/properties_tester.py 2006-09-26 18:56:36 UTC (rev 594)
+++ pyplusplus_dev/unittests/properties_tester.py 2006-09-26 20:34:29 UTC (rev 595)
@@ -25,7 +25,8 @@
count.exclude()
set_count.exclude()
cls.add_property( "count", count, set_count )
-
+ cls.add_property( "count_ro", count )
+
get_nested = cls.member_function( 'get_nested' )
get_nested.call_policies = call_policies.return_internal_reference()
set_nested = cls.member_function( 'set_nested' )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-09-26 18:56:43
|
Revision: 594
http://svn.sourceforge.net/pygccxml/?rev=594&view=rev
Author: roman_yakovenko
Date: 2006-09-26 11:56:36 -0700 (Tue, 26 Sep 2006)
Log Message:
-----------
porting "add_property" feature to gcc
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/properties.py
Modified: pyplusplus_dev/pyplusplus/code_creators/properties.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/properties.py 2006-09-26 18:49:45 UTC (rev 593)
+++ pyplusplus_dev/pyplusplus/code_creators/properties.py 2006-09-26 18:56:36 UTC (rev 594)
@@ -30,7 +30,7 @@
return 'typedef ' + f.function_type().create_typedef( ftype_alias, exported_class_alias ) + ';'
def create_accessor_code( self, f, ftype_alias ):
- f_ref_code = '%s( %s )' % ( ftype_alias, declarations.full_name( f ) )
+ f_ref_code = '%s( &%s )' % ( ftype_alias, declarations.full_name( f ) )
if f.call_policies and f.call_policies.is_default():
return f_ref_code
result = [ self.make_function_identifier ]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-09-26 18:49:52
|
Revision: 593
http://svn.sourceforge.net/pygccxml/?rev=593&view=rev
Author: roman_yakovenko
Date: 2006-09-26 11:49:45 -0700 (Tue, 26 Sep 2006)
Log Message:
-----------
adding new unit test for FT - class with private
destructor
Modified Paths:
--------------
pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp
pyplusplus_dev/unittests/function_transformations_tester.py
Modified: pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2006-09-26 18:40:19 UTC (rev 592)
+++ pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2006-09-26 18:49:45 UTC (rev 593)
@@ -92,7 +92,13 @@
bool member(int& v) { v=17; return true; }
};
-
+/*
+struct ft_private_destructor_t{
+ static void get_value( int& x ){ x = 21; }
+private:
+ ~ft_private_destructor_t(){}
+};
+*/
}
#endif//__function_transformations_to_be_exported_hpp__
Modified: pyplusplus_dev/unittests/function_transformations_tester.py
===================================================================
--- pyplusplus_dev/unittests/function_transformations_tester.py 2006-09-26 18:40:19 UTC (rev 592)
+++ pyplusplus_dev/unittests/function_transformations_tester.py 2006-09-26 18:49:45 UTC (rev 593)
@@ -32,7 +32,10 @@
cls = mb.class_("no_virtual_members_t")
cls.member_function("member").function_transformers.append(output_t(1))
-
+
+ #cls = mb.class_("ft_private_destructor_t")
+ #cls.member_function("get_value").function_transformers.append(output_t(1))
+
mb.decls(lambda decl: decl.name[0]=="_").exclude()
def run_tests(self, module):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-09-26 18:40:24
|
Revision: 592
http://svn.sourceforge.net/pygccxml/?rev=592&view=rev
Author: roman_yakovenko
Date: 2006-09-26 11:40:19 -0700 (Tue, 26 Sep 2006)
Log Message:
-----------
fixing spelling error
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/module_builder/builder.py
Modified: pyplusplus_dev/pyplusplus/module_builder/builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/builder.py 2006-09-26 10:51:08 UTC (rev 591)
+++ pyplusplus_dev/pyplusplus/module_builder/builder.py 2006-09-26 18:40:19 UTC (rev 592)
@@ -203,7 +203,7 @@
def build_code_creator( self
, module_name
, boost_python_ns_name='bp'
- , create_castinig_constructor=True
+ , create_casting_constructor=True
, call_policies_resolver_=None
, types_db=None
, target_configuration=None
@@ -227,13 +227,13 @@
@type doc_extractor: callable or None
"""
msg = os.linesep.join([
- "create_castinig_constructor argument is deprecated and should not be used."
+ "create_casting_constructor argument is deprecated and should not be used."
, "If you still want Py++ to generate implicitly_convertible code, consider to use allow_implicit_conversion constructor property"
, "mb = module_builder_t(...)"
, "mb.constructors().allow_implicit_conversion = True"])
warnings.warn(msg, DeprecationWarning, stacklevel=2)
- if create_castinig_constructor:
+ if create_casting_constructor:
self.global_ns.constructors(allow_empty=True).allow_implicit_conversion = True
creator = mcreator_package.creator_t( self.global_ns
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2006-09-26 10:51:22
|
Revision: 591
http://svn.sourceforge.net/pygccxml/?rev=591&view=rev
Author: roman_yakovenko
Date: 2006-09-26 03:51:08 -0700 (Tue, 26 Sep 2006)
Log Message:
-----------
adding few missing files and more unit tests
Modified Paths:
--------------
pyplusplus_dev/unittests/data/properties_to_be_exported.hpp
pyplusplus_dev/unittests/properties_tester.py
Added Paths:
-----------
pyplusplus_dev/pyplusplus/code_creators/properties.py
pyplusplus_dev/pyplusplus/decl_wrappers/properties.py
Added: pyplusplus_dev/pyplusplus/code_creators/properties.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/properties.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_creators/properties.py 2006-09-26 10:51:08 UTC (rev 591)
@@ -0,0 +1,125 @@
+# Copyright 2004 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 algorithm
+import registration_based
+from pygccxml import declarations
+
+#I am sure in future I will have to treat template classes
+class property_t( registration_based.registration_based_t ):
+ def __init__(self, property_def, wrapper=None ):
+ registration_based.registration_based_t.__init__( self )
+ self._property_def = property_def
+ self.works_on_instance = False
+ self._make_function = None
+
+ @property
+ def property_def( self ):
+ return self._property_def
+
+ @property
+ def make_function_identifier( self ):
+ if not self._make_function:
+ self._make_function = algorithm.create_identifier( self, '::boost::python::make_function' )
+ return self._make_function
+
+ def create_function_type_alias_code( self, f, ftype_alias, exported_class_alias=None ):
+ return 'typedef ' + f.function_type().create_typedef( ftype_alias, exported_class_alias ) + ';'
+
+ def create_accessor_code( self, f, ftype_alias ):
+ f_ref_code = '%s( %s )' % ( ftype_alias, declarations.full_name( f ) )
+ if f.call_policies and f.call_policies.is_default():
+ return f_ref_code
+ result = [ self.make_function_identifier ]
+ result.append( '( ' )
+ result.append( os.linesep )
+ result.append( self.indent( ' ', 2 ) )
+ result.append( f_ref_code )
+ if f.call_policies:
+ result.append( os.linesep )
+ result.append( self.indent( ', ', 2 ) )
+ result.append( f.call_policies.create( self ) )
+ else:
+ result.append( os.linesep )
+ result.append( self.indent( ' ', 2 ) )
+ result.append( '/* undefined call policies */' )
+ result.append( ' ) ' )
+ return ''.join( result )
+
+ def has_long_line( self ):
+ pd = self.property_def
+ if pd.fget.call_policies and not pd.fget.call_policies.is_default():
+ return True
+ elif pd.fset or pd.fset.call_policies or not pd.fset.call_policies.is_default():
+ return True
+ elif pd.doc:
+ return True
+ else:
+ return True
+
+ def create_property_code( self ):
+ result = []
+ param_sep = ', '
+ if self.has_long_line():
+ param_sep = os.linesep + self.indent( param_sep )
+
+ result.append( self.create_function_type_alias_code( self.property_def.fget, 'fget' ) )
+ if self.property_def.fset:
+ result.append( os.linesep )
+ result.append( self.create_function_type_alias_code( self.property_def.fset, 'fset' ) )
+
+ result.append( 2 * os.linesep )
+
+ add_property = None
+ if self.property_def.is_static:
+ add_property = 'add_static_property'
+ else:
+ add_property = 'add_property'
+
+ class_var_name = self.parent.class_var_name
+ if self.has_long_line():
+ result.append( '%s.%s( ' % ( class_var_name, add_property ) )
+ result.append( os.linesep + self.indent( '"%s"' % self.property_def.name ) )
+ else:
+ result.append( '%s.%s( "%s"' % ( class_var_name, add_property, self.property_def.name ) )
+ result.append( param_sep + self.create_accessor_code( self.property_def.fget, 'fget' ) )
+ if self.property_def.fset:
+ result.append( param_sep + self.create_accessor_code( self.property_def.fset, 'fset' ))
+ if self.property_def.doc:
+ result.append( param_sep + self.property_def.doc)
+ result.append( ' );')
+ return ''.join( result )
+
+ def _create_impl( self ):
+ result = []
+ result.append( '{ //%s' % self.property_def )
+ result.append( '' )
+ result.append( self.indent( self.create_property_code() ) )
+ result.append( '' )
+ result.append( '}' )
+ return os.linesep.join( result )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Added: pyplusplus_dev/pyplusplus/decl_wrappers/properties.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/properties.py (rev 0)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-09-26 10:51:08 UTC (rev 591)
@@ -0,0 +1,57 @@
+# Copyright 2004 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 property_t helper class"
+
+from pygccxml import declarations
+
+class property_t( object ):
+ def __init__( self, name, fget, fset=None, doc='', is_static=False ):
+ self._name = name
+ self._fget = fget
+ self._fset = fset
+ self._doc = doc
+ self._is_static = is_static
+
+ @property
+ def name( self ):
+ return self._name
+
+ @property
+ def fget( self ):
+ return self._fget
+
+ @property
+ def fset( self ):
+ return self._fset
+
+ @property
+ def doc( self ):
+ return self._doc
+
+ @property
+ def is_static( self ):
+ return self._is_static
+
+ def __str__( self ):
+ desc = []
+ desc.append( 'fget=%s' % declarations.full_name( self.fget ) )
+ if self.fset:
+ desc.append( ', ' )
+ desc.append( 'fset=%s' % declarations.full_name( self.fset ) )
+ return "property [%s]"% ''.join( desc )
+
+def find_properties( cls ):
+ """this function should return a list of possible properties for the class"""
+ #get* set*
+ #get_* set_*
+ #*, set*
+ #*, set_*
+ #get defined on [derived|base], set defined on [base|derived]
+
+ raise NotImplemented()
+
+
+
Modified: pyplusplus_dev/unittests/data/properties_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/properties_to_be_exported.hpp 2006-09-26 09:06:43 UTC (rev 590)
+++ pyplusplus_dev/unittests/data/properties_to_be_exported.hpp 2006-09-26 10:51:08 UTC (rev 591)
@@ -9,6 +9,11 @@
namespace properties{
struct properties_tester_t{
+
+ struct nested{
+ int n;
+ };
+
properties_tester_t()
: m_count( 0 )
{}
@@ -19,7 +24,14 @@
void set_count( int x )
{ m_count = x; }
+ nested& get_nested()
+ { return m_nested; }
+
+ void set_nested( nested x )
+ { m_nested = x; }
+
int m_count;
+ nested m_nested;
};
}
Modified: pyplusplus_dev/unittests/properties_tester.py
===================================================================
--- pyplusplus_dev/unittests/properties_tester.py 2006-09-26 09:06:43 UTC (rev 590)
+++ pyplusplus_dev/unittests/properties_tester.py 2006-09-26 10:51:08 UTC (rev 591)
@@ -7,6 +7,7 @@
import sys
import unittest
import fundamental_tester_base
+from pyplusplus.module_builder import call_policies
class tester_t(fundamental_tester_base.fundamental_tester_base_t):
EXTENSION_NAME = 'properties'
@@ -25,9 +26,20 @@
set_count.exclude()
cls.add_property( "count", count, set_count )
+ get_nested = cls.member_function( 'get_nested' )
+ get_nested.call_policies = call_policies.return_internal_reference()
+ set_nested = cls.member_function( 'set_nested' )
+ cls.add_property( "nested_", get_nested, set_nested )
+
+ cls.add_property( "nested_ro", get_nested )
+
def run_tests(self, module):
- pass
+ pt = module.properties_tester_t()
+ self.failUnless( pt.count == 0 )
+ pt.count = 21
+ self.failUnless( pt.m_count == 21 )
+
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.
|