[pygccxml-commit] SF.net SVN: pygccxml: [934] pyplusplus_dev/pyplusplus
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2007-02-26 21:43:03
|
Revision: 934
http://svn.sourceforge.net/pygccxml/?rev=934&view=rev
Author: roman_yakovenko
Date: 2007-02-26 13:43:00 -0800 (Mon, 26 Feb 2007)
Log Message:
-----------
adding initial support for str( self ) ( operator<< ) support
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/calldef.py
pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
pyplusplus_dev/pyplusplus/module_creator/creator.py
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-02-26 21:28:13 UTC (rev 933)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-02-26 21:43:00 UTC (rev 934)
@@ -1003,8 +1003,13 @@
assert not "Unable to find out boost::python::self position. " + str( self.declaration )
def _create_binary_operator(self):
+ self_identifier = algorithm.create_identifier( self, '::boost::python::self' )
+
+ if self.declaration.symbol == '<<':
+ str_identifier = algorithm.create_identifier( self, '::boost::python::self_ns::str' )
+ return '%s( %s )' % ( str_identifier, self_identifier )
+
answer = [ None, self.declaration.symbol, None ]
- self_identifier = algorithm.create_identifier( self, '::boost::python::self' )
self_position = self._findout_self_position()
if self_position == self.SELF_POSITION.FIRST:
answer[0] = self_identifier
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2007-02-26 21:28:13 UTC (rev 933)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2007-02-26 21:43:00 UTC (rev 934)
@@ -317,7 +317,7 @@
"""helps Py++ to deal with C++ operators"""
inplace = [ '+=', '-=', '*=', '/=', '%=', '>>=', '<<=', '&=', '^=', '|=' ]
comparison = [ '==', '!=', '<', '>', '<=', '>=' ]
- non_member = [ '+', '-', '*', '/', '%', '&', '^', '|' ] #'>>', '<<', not implemented
+ non_member = [ '+', '-', '*', '/', '%', '&', '^', '|', ]
unary = [ '!', '~', '+', '-' ]
all = inplace + comparison + non_member + unary
@@ -328,7 +328,24 @@
if oper.symbol == '*' and len( oper.arguments ) == 0:
#dereference does not make sense
return False
- return oper.symbol in operators_helper.all
+ if oper.symbol != '<<':
+ return oper.symbol in operators_helper.all
+
+ args_len = len( oper.arguments )
+ if isinstance( oper, declarations.member_operator_t ):# and args_len != 1:
+ return False #Boost.Python does not support member operator<< :-(
+ if isinstance( oper, declarations.free_operator_t ) and args_len != 2:
+ return False
+ if not declarations.is_same( oper.return_type, oper.arguments[0].type ):
+ return False
+ type_ = oper.return_type
+ if not declarations.is_reference( type_ ):
+ return False
+ type_ = declarations.remove_reference( type_ )
+ if declarations.is_const( type_ ):
+ return False
+ return declarations.is_std_ostream( type_ ) \
+ or declarations.is_std_wostream( type_ )
@staticmethod
def exportable( oper ):
Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-02-26 21:28:13 UTC (rev 933)
+++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-02-26 21:43:00 UTC (rev 934)
@@ -201,6 +201,10 @@
arg_type = declarations.base_type( operator.arguments[0].type )
if isinstance( arg_type, declarations.fundamental_t ):
arg_type = declarations.base_type( operator.arguments[1].type )
+ elif isinstance( arg_type, declarations.declarated_t ) and arg_type.declaration.ignore:
+ arg_type = declarations.base_type( operator.arguments[1].type )
+ else:
+ pass
assert isinstance( arg_type, declarations.declarated_t )
found = find( lambda decl: arg_type.declaration is decl
, self.__extmodule.body.creators )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|