Update of /cvsroot/pygccxml/source/pyplusplus/code_creators
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18736/pyplusplus/code_creators
Modified Files:
class_declaration.py
Log Message:
pyplusplus now wraps hierarchy of abstract classes right.
Next code will give you some idea:
class base{
public:
base(){}
virtual ~base(){}
virtual int get_value() const = 0;
private:
base( const base& );
base& operator=( const base& );
};
class middle : public base{
public:
virtual void set_value(int) = 0;
};
class final : public middle{
public:
virtual int get_value() const{ return m_value; }
virtual void set_value(int v){ m_value = v; }
private:
int m_value;
};
Index: class_declaration.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pyplusplus/code_creators/class_declaration.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** class_declaration.py 28 Feb 2006 07:31:32 -0000 1.36
--- class_declaration.py 5 Mar 2006 05:50:25 -0000 1.37
***************
*** 114,136 ****
def _generate_noncopyable(self):
! is_derived_from_noncopyable = False
! for base_desc in self.declaration.bases:
! assert isinstance( base_desc, declarations.hierarchy_info_t )
! if base_desc.related_class.decl_string in ('::boost::noncopyable', '::boost::noncopyable_::noncopyable' ):
! is_derived_from_noncopyable = True
! break
! if not declarations.has_trivial_copy( base_desc.related_class ):
! is_derived_from_noncopyable = True
! break
!
! if not declarations.has_trivial_copy( self.declaration ) \
! or not declarations.has_public_constructor( self.declaration )\
! or self.declaration.is_abstract \
! or ( declarations.has_destructor( self.declaration ) and
! not declarations.has_public_destructor( self.declaration ) )\
! or is_derived_from_noncopyable:
return algorithm.create_identifier( self, '::boost::noncopyable' )
- else:
- return None
def _generate_bases(self, base_creators):
--- 114,119 ----
def _generate_noncopyable(self):
! if declarations.is_noncopyable( self.declaration ):
return algorithm.create_identifier( self, '::boost::noncopyable' )
def _generate_bases(self, base_creators):
***************
*** 300,303 ****
--- 283,287 ----
, declaration=declaration )
self._class_creator = class_creator
+ self._base_wrappers = []
def _get_wrapper_alias( self ):
***************
*** 307,310 ****
--- 291,305 ----
wrapper_alias = property( _get_wrapper_alias, _set_wrapper_alias )
+ def _get_base_wrappers( self ):
+ if self.declaration.is_abstract and not self._base_wrappers:
+ bases = [ hi.related_class for hi in self.declaration.bases ]
+ creators_before_me = algorithm.creators_affect_on_me( self )
+ self._base_wrappers \
+ = filter( lambda creator: isinstance( creator, class_wrapper_t )
+ and creator.declaration in bases
+ , creators_before_me )
+ return self._base_wrappers
+ base_wrappers = property( _get_base_wrappers )
+
def _get_exposed_identifier(self):
return algorithm.create_identifier( self, self.declaration.decl_string )
***************
*** 339,348 ****
def _create_bases(self):
! return ', '.join( [ self.exposed_identifier, self.boost_wrapper_identifier ] )
def _create_impl(self):
answer = ['struct %s : %s {' % ( self.wrapper_alias, self._create_bases() )]
answer.append( '' )
! answer.append( self.create_internal_code( self.creators ) )
answer.append( '' )
answer.append( '};' )
--- 334,360 ----
def _create_bases(self):
! return ', '.join( [self.exposed_identifier, self.boost_wrapper_identifier] )
+ def _get_pure_virtual_function_creators( self ):
+ creators = []
+ for base_wrapper in self.base_wrappers:
+ for creator in base_wrapper.creators:
+ if not isinstance( creator, declaration_based.declaration_based_t ):
+ continue
+ if not isinstance( creator.declaration, declarations.member_calldef_t ):
+ continue
+ if creator.declaration.virtuality != declarations.VIRTUALITY_TYPES.PURE_VIRTUAL:
+ continue
+ creators.append( creator )
+ return creators
+
def _create_impl(self):
answer = ['struct %s : %s {' % ( self.wrapper_alias, self._create_bases() )]
answer.append( '' )
! answer.append( self.create_internal_code( self.creators ) )
! pvcreators = self._get_pure_virtual_function_creators()
! if pvcreators:
! answer.append( '' )
! answer.append( self.create_internal_code( pvcreators ) )
answer.append( '' )
answer.append( '};' )
|