pygccxml-commit Mailing List for C++ Python language bindings (Page 38)
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...> - 2007-02-26 21:28:14
|
Revision: 933
http://svn.sourceforge.net/pygccxml/?rev=933&view=rev
Author: roman_yakovenko
Date: 2007-02-26 13:28:13 -0800 (Mon, 26 Feb 2007)
Log Message:
-----------
adding 2 new type traits and unit tests is_std_[w]ostream
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/__init__.py
pygccxml_dev/pygccxml/declarations/type_traits.py
pygccxml_dev/unittests/data/type_traits.hpp
pygccxml_dev/unittests/type_traits_tester.py
Modified: pygccxml_dev/pygccxml/declarations/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/__init__.py 2007-02-25 12:31:52 UTC (rev 932)
+++ pygccxml_dev/pygccxml/declarations/__init__.py 2007-02-26 21:28:13 UTC (rev 933)
@@ -134,6 +134,8 @@
from type_traits import is_noncopyable
from type_traits import is_std_string
from type_traits import is_std_wstring
+from type_traits import is_std_ostream
+from type_traits import is_std_wostream
from type_traits import is_unary_operator
from type_traits import is_binary_operator
Modified: pygccxml_dev/pygccxml/declarations/type_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/type_traits.py 2007-02-25 12:31:52 UTC (rev 932)
+++ pygccxml_dev/pygccxml/declarations/type_traits.py 2007-02-26 21:28:13 UTC (rev 933)
@@ -1008,7 +1008,30 @@
type = remove_alias( type )
return remove_cv( type ).decl_string in decl_strings
+def is_std_ostream( type ):
+ """returns True, if type represents C++ std::string, False otherwise"""
+ decl_strings = [
+ '::std::basic_ostream<char, std::char_traits<char> >'
+ , '::std::basic_ostream<char,std::char_traits<char> >'
+ , '::std::ostream' ]
+ if isinstance( type, types.StringTypes ):
+ return type in decl_strings
+ else:
+ type = remove_alias( type )
+ return remove_cv( type ).decl_string in decl_strings
+
+def is_std_wostream( type ):
+ """returns True, if type represents C++ std::string, False otherwise"""
+ decl_strings = [
+ '::std::basic_ostream<wchar_t, std::char_traits<wchar_t> >'
+ , '::std::basic_ostream<wchar_t,std::char_traits<wchar_t> >'
+ , '::std::wostream' ]
+ if isinstance( type, types.StringTypes ):
+ return type in decl_strings
+ else:
+ type = remove_alias( type )
+ return remove_cv( type ).decl_string in decl_strings
@@ -1017,4 +1040,3 @@
-
Modified: pygccxml_dev/unittests/data/type_traits.hpp
===================================================================
--- pygccxml_dev/unittests/data/type_traits.hpp 2007-02-25 12:31:52 UTC (rev 932)
+++ pygccxml_dev/unittests/data/type_traits.hpp 2007-02-26 21:28:13 UTC (rev 933)
@@ -7,6 +7,7 @@
//from boost.type_traits (http://www.boost.org) library.
#include <string>
+#include <iostream>
#define TYPE_PERMUTATION( BASE, NAME ) \
typedef BASE NAME##_t; \
@@ -18,6 +19,25 @@
int member;
};
+namespace is_std_ostream{
+namespace yes{
+ typedef std::ostream ostream_type;
+}
+namespace no{
+ typedef int int__;
+}
+}
+
+namespace is_std_wostream{
+namespace yes{
+ typedef std::wostream wostream_type;
+}
+namespace no{
+ typedef int int__;
+}
+}
+
+
struct incomplete_type;
namespace is_void{
Modified: pygccxml_dev/unittests/type_traits_tester.py
===================================================================
--- pygccxml_dev/unittests/type_traits_tester.py 2007-02-25 12:31:52 UTC (rev 932)
+++ pygccxml_dev/unittests/type_traits_tester.py 2007-02-26 21:28:13 UTC (rev 933)
@@ -105,6 +105,12 @@
def test_is_noncopyable(self):
self.__test_type_category( 'is_noncopyable', declarations.is_noncopyable )
+ def test_is_std_ostream(self):
+ self.__test_type_category( 'is_std_ostream', declarations.is_std_ostream )
+
+ def test_is_std_wostream(self):
+ self.__test_type_category( 'is_std_wostream', declarations.is_std_wostream )
+
def test_has_trivial_constructor(self):
self.__test_type_category( 'has_trivial_constructor', declarations.has_trivial_constructor )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-25 12:31:56
|
Revision: 932
http://svn.sourceforge.net/pygccxml/?rev=932&view=rev
Author: roman_yakovenko
Date: 2007-02-25 04:31:52 -0800 (Sun, 25 Feb 2007)
Log Message:
-----------
fixing bug, which will prevent creation of __call_policies.hpp file
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/module_creator/creator.py
Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-02-25 11:08:58 UTC (rev 931)
+++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-02-25 12:31:52 UTC (rev 932)
@@ -349,7 +349,10 @@
def __on_demand_include_call_policies( self, call_policy ):
if self.__custom_call_policies_included:
return
-
+
+ if not call_policy:
+ return
+
if call_policy.is_predefined():
return
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-25 11:08:58
|
Revision: 931
http://svn.sourceforge.net/pygccxml/?rev=931&view=rev
Author: roman_yakovenko
Date: 2007-02-25 03:08:58 -0800 (Sun, 25 Feb 2007)
Log Message:
-----------
removing constness from "input" type
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/function_transformers/transformers.py
Modified: pyplusplus_dev/pyplusplus/function_transformers/transformers.py
===================================================================
--- pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2007-02-25 11:04:28 UTC (rev 930)
+++ pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2007-02-25 11:08:58 UTC (rev 931)
@@ -260,7 +260,7 @@
% ( function, self.arg.name, self.arg.type)
self.array_size = size
- self.array_item_type = declarations.array_item_type( self.arg.type )
+ self.array_item_type = declarations.remove_const( declarations.array_item_type( self.arg.type ) )
def __str__(self):
return "input_array(%s,%d)"%( self.arg.name, self.array_size)
@@ -432,7 +432,7 @@
raise ValueError( '%s\nin order to use "input_c_buffer" transformation, "size" argument %s type must be an integral type (got %s).' ) \
% ( function, self.size_arg.name, self.size_arg.type)
- self.buffer_item_type = declarations.array_item_type( self.buffer_arg.type )
+ self.buffer_item_type = declarations.remove_const( declarations.array_item_type( self.buffer_arg.type ) )
def __str__(self):
return "input_c_buffer(buffer arg=%s, size arg=%s)" \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-25 11:04:28
|
Revision: 930
http://svn.sourceforge.net/pygccxml/?rev=930&view=rev
Author: roman_yakovenko
Date: 2007-02-25 03:04:28 -0800 (Sun, 25 Feb 2007)
Log Message:
-----------
fixing bug, which will prevent creation of __call_policies.hpp file
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py
pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py
pyplusplus_dev/pyplusplus/module_creator/creator.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2007-02-25 09:13:50 UTC (rev 929)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2007-02-25 11:04:28 UTC (rev 930)
@@ -84,7 +84,6 @@
from call_policies import return_value_policy
from call_policies import return_pointee_value
from call_policies import is_return_opaque_pointer_policy
-from call_policies import is_return_pointee_value_policy
from call_policies import custom_call_policies_t
from call_policies import custom_call_policies
from call_policies import convert_array_to_tuple_t
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py 2007-02-25 09:13:50 UTC (rev 929)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py 2007-02-25 11:04:28 UTC (rev 930)
@@ -50,6 +50,10 @@
#Small hack that allows to write nicer code
return False
+ def is_predefined( self ):
+ """Returns True if call policy is defined in Boost.Python library, False otherwise"""
+ return True
+
def _create_impl( self, function_creator ):
raise NotImplementedError()
@@ -214,6 +218,16 @@
else:
return [self.result_converter_generator]
+ def is_predefined( self ):
+ """Returns True if call policy is defined in Boost.Python library, False otherwise"""
+ global return_pointee_value
+ if self.result_converter_generator == return_pointee_value:
+ return False
+ else:
+ return True
+
+
+
copy_const_reference = '::boost::python::copy_const_reference'
copy_non_const_reference = '::boost::python::copy_non_const_reference'
manage_new_object = '::boost::python::manage_new_object'
@@ -230,12 +244,6 @@
return isinstance( policy, return_value_policy_t ) \
and policy.result_converter_generator == return_opaque_pointer
-def is_return_pointee_value_policy( policy ):
- """returns True is policy represents return_value_policy<return_pointee_value>, False otherwise"""
- return isinstance( policy, return_value_policy_t ) \
- and policy.result_converter_generator == return_pointee_value
-
-
class custom_call_policies_t(call_policy_t):
"""implementation for user defined call policies"""
def __init__( self, call_policies ):
@@ -271,6 +279,10 @@
self._memory_manager = memory_manager
self._make_objec_call_policies = make_object_call_policies
+ def is_predefined( self ):
+ """Returns True if call policy is defined in Boost.Python library, False otherwise"""
+ return False
+
def _get_array_size( self ):
return self._array_size
def _set_array_size( self, new_array_size):
@@ -315,6 +327,10 @@
self._get_size_class = get_size_class
self._value_policies = value_policies
+ def is_predefined( self ):
+ """Returns True if call policy is defined in Boost.Python library, False otherwise"""
+ return False
+
def _get_get_size_class( self ):
return self._get_size_class
def _set_get_size_class( self, new_get_size_class):
Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-02-25 09:13:50 UTC (rev 929)
+++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-02-25 11:04:28 UTC (rev 930)
@@ -127,7 +127,7 @@
self.__free_operators = []
self.__exposed_free_fun_overloads = set()
self.__opaque_types_manager = opaque_types_manager.manager_t( self.__extmodule )
- self.__return_pointee_value_exists = False
+ self.__custom_call_policies_included = False
self.__dependencies_manager = dependencies_manager.manager_t(self.decl_logger)
@@ -347,13 +347,16 @@
self.__module_body.adopt_creators( creators, 0 )
def __on_demand_include_call_policies( self, call_policy ):
- if not self.__return_pointee_value_exists \
- and decl_wrappers.is_return_pointee_value_policy( call_policy ):
- self.__return_pointee_value_exists = True
- self.__extmodule.add_include( code_repository.call_policies.file_name )
- self.__extmodule.add_system_header( code_repository.call_policies.file_name )
+ if self.__custom_call_policies_included:
+ return
+ if call_policy.is_predefined():
+ return
+ self.__custom_call_policies_included = True
+ self.__extmodule.add_include( code_repository.call_policies.file_name )
+ self.__extmodule.add_system_header( code_repository.call_policies.file_name )
+
def create(self, decl_headers=None):
"""Create and return the module for the extension.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-25 09:13:50
|
Revision: 929
http://svn.sourceforge.net/pygccxml/?rev=929&view=rev
Author: roman_yakovenko
Date: 2007-02-25 01:13:50 -0800 (Sun, 25 Feb 2007)
Log Message:
-----------
adding small work-around to bug in GCCXML
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/type_traits.py
Modified: pygccxml_dev/pygccxml/declarations/type_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/type_traits.py 2007-02-24 22:10:41 UTC (rev 928)
+++ pygccxml_dev/pygccxml/declarations/type_traits.py 2007-02-25 09:13:50 UTC (rev 929)
@@ -802,8 +802,13 @@
"""implementation details"""
#It is not enough to check base classes, we should also to check
#member variables.
- #if is_std_string( class_ ) or is_std_wstring( class_ ):
- # return False
+
+ if has_trivial_copy( class_ ) \
+ and has_public_constructor( class_ ) \
+ and has_public_assign( class_ ) \
+ and has_public_destructor( class_ ):
+ return False
+
mvars = filter( lambda x: isinstance( x, variable.variable_t )
, class_.declarations )
for mvar in mvars:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <al...@us...> - 2007-02-24 22:10:41
|
Revision: 928
http://svn.sourceforge.net/pygccxml/?rev=928&view=rev
Author: allenb
Date: 2007-02-24 14:10:41 -0800 (Sat, 24 Feb 2007)
Log Message:
-----------
Add documentation and fix up the protected method handling.
Modified Paths:
--------------
pyplusplus_dev/contrib/goodies/goodie_utils.py
Modified: pyplusplus_dev/contrib/goodies/goodie_utils.py
===================================================================
--- pyplusplus_dev/contrib/goodies/goodie_utils.py 2007-02-24 22:09:52 UTC (rev 927)
+++ pyplusplus_dev/contrib/goodies/goodie_utils.py 2007-02-24 22:10:41 UTC (rev 928)
@@ -86,7 +86,7 @@
def exclude_protected(cls):
""" Exclude all protected declarations. """
- cls.decls(pd.access_type_matcher_t('protected'),allow_empty=True).exclude()
+ cls.decls(pd.access_type_matcher_t(pd.ACCESS_TYPES.PROTECTED),allow_empty=True).exclude()
def wrap_const_ref_params(cls):
""" Find all member functions of cls and if they take a const& to a class
@@ -160,6 +160,8 @@
""" Proxy for a template instance. Returned from the TemplateBuilder
to allow access to the template at a later time.
+ NOTE: DO NOT USE DIRECTLY. ONLY USE AS RETURNED FROM TEMPLATE BUILDER.
+
TODO: If used a form that allowed multiple templates to be specified
ex: TemplateWrapper("OSG::vector", arguments=[["float","3"],["int","4"]]
then how would we handle naming? Automatic or must be specified?
@@ -211,7 +213,9 @@
tb = TemplateBuilder()
vec3f_t = tb.Template("OSG::vector<float,3>")
- # Add autogen code to a header that is included
+ header_contents = tb.buildAutogenContents()
+ # Add contents to some file that is included by module builder
+
mb = moduble_builder_t([myheaders])
tb.process(mb)
@@ -229,6 +233,7 @@
def Template(self, *args, **kw):
"""Create and add a template wrapper.
+ Returns a template wrapper that can be used to get the decl later.
"""
temp_wrapper = TemplateWrapper(*args, **kw)
self.mTemplates.append(temp_wrapper)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <al...@us...> - 2007-02-24 22:09:53
|
Revision: 927
http://svn.sourceforge.net/pygccxml/?rev=927&view=rev
Author: allenb
Date: 2007-02-24 14:09:52 -0800 (Sat, 24 Feb 2007)
Log Message:
-----------
Disable good perf overrides. These seemed like a good idea at the time, but they are just too fragile.
Modified Paths:
--------------
pyplusplus_dev/contrib/goodies/__init__.py
Modified: pyplusplus_dev/contrib/goodies/__init__.py
===================================================================
--- pyplusplus_dev/contrib/goodies/__init__.py 2007-02-24 19:21:35 UTC (rev 926)
+++ pyplusplus_dev/contrib/goodies/__init__.py 2007-02-24 22:09:52 UTC (rev 927)
@@ -7,7 +7,7 @@
# Allen Bierbaum
#
-import goodie_perf_overrides
+#import goodie_perf_overrides
import goodie_overrides
from goodie_utils import (set_recursive_default, set_allow_empty_mdecl_default,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-24 19:21:39
|
Revision: 926
http://svn.sourceforge.net/pygccxml/?rev=926&view=rev
Author: roman_yakovenko
Date: 2007-02-24 11:21:35 -0800 (Sat, 24 Feb 2007)
Log Message:
-----------
fixing treatment of documentation strings
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/module_creator/creator.py
Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-02-24 19:11:16 UTC (rev 925)
+++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-02-24 19:21:35 UTC (rev 926)
@@ -151,14 +151,8 @@
#if isinstance( decl, declarations.variable_t ):
#self.__types_db.update( decl )
-
if doc_extractor and decl.exportable:
- if decl.documentation:
- extracted_doc = doc_extractor( decl )
- if extracted_doc != decl.documentation:
- decl.documentation = decl.documentation + extracted_doc
- else:
- decl.documentation = doc_extractor( decl )
+ decl.documentation = doc_extractor( decl )
readme = decl.readme()
if not readme:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-24 19:11:18
|
Revision: 925
http://svn.sourceforge.net/pygccxml/?rev=925&view=rev
Author: roman_yakovenko
Date: 2007-02-24 11:11:16 -0800 (Sat, 24 Feb 2007)
Log Message:
-----------
adding functionality necessary to implement correct "transfer_ownership" behaviour - adding tester
Modified Paths:
--------------
pyplusplus_dev/unittests/data/transfer_ownership_to_be_exported.hpp
pyplusplus_dev/unittests/transfer_ownership_tester.py
Modified: pyplusplus_dev/unittests/data/transfer_ownership_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/transfer_ownership_to_be_exported.hpp 2007-02-24 19:09:22 UTC (rev 924)
+++ pyplusplus_dev/unittests/data/transfer_ownership_to_be_exported.hpp 2007-02-24 19:11:16 UTC (rev 925)
@@ -3,11 +3,16 @@
struct event_t
{
+ virtual ~event_t(){}
+ void invoke(){
+ notify();
+ }
+protected:
virtual void notify() = 0;
- virtual ~event_t(){}
};
struct do_nothing_t : event_t{
+protected:
virtual void notify(){};
};
@@ -18,7 +23,7 @@
};
void run() {
- m_event->notify();
+ m_event->invoke();
delete m_event;
m_event = 0;
};
Modified: pyplusplus_dev/unittests/transfer_ownership_tester.py
===================================================================
--- pyplusplus_dev/unittests/transfer_ownership_tester.py 2007-02-24 19:09:22 UTC (rev 924)
+++ pyplusplus_dev/unittests/transfer_ownership_tester.py 2007-02-24 19:11:16 UTC (rev 925)
@@ -77,8 +77,7 @@
self.container = container
def notify( self ):
- print 1
- #self.container.append( 1 )
+ self.container.append( 1 )
print '1'
notify_data = []
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-24 19:09:21
|
Revision: 924
http://svn.sourceforge.net/pygccxml/?rev=924&view=rev
Author: roman_yakovenko
Date: 2007-02-24 11:09:22 -0800 (Sat, 24 Feb 2007)
Log Message:
-----------
adding functionality necessary to implement correct "transfer_ownership" behaviour
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/calldef.py
pyplusplus_dev/unittests/member_functions_tester.py
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-02-24 18:39:53 UTC (rev 923)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-02-24 19:09:22 UTC (rev 924)
@@ -600,6 +600,11 @@
def create_virtual_body(self):
template = []
+
+ precall_code = self.declaration.override_precall_code
+ if precall_code:
+ template.append( os.linesep.join( precall_code ) )
+
template.append( 'if( %(override)s func_%(alias)s = this->get_override( "%(alias)s" ) )' )
template.append( self.indent('%(return_)sfunc_%(alias)s( %(args)s );') )
template.append( 'else' )
@@ -680,6 +685,11 @@
return self.unoverriden_function_body()
template = []
+
+ precall_code = self.declaration.override_precall_code
+ if precall_code:
+ template.append( os.linesep.join( precall_code ) )
+
template.append( '%(override)s func_%(alias)s = this->get_override( "%(alias)s" );' )
template.append( '%(return_)sfunc_%(alias)s( %(args)s );')
template = os.linesep.join( template )
@@ -735,6 +745,11 @@
return self.unoverriden_function_body()
template = []
+
+ precall_code = self.declaration.override_precall_code
+ if precall_code:
+ template.append( os.linesep.join( precall_code ) )
+
template.append( '%(override)s func_%(alias)s = this->get_override( "%(alias)s" );' )
template.append( '%(return_)sfunc_%(alias)s( %(args)s );')
template = os.linesep.join( template )
Modified: pyplusplus_dev/unittests/member_functions_tester.py
===================================================================
--- pyplusplus_dev/unittests/member_functions_tester.py 2007-02-24 18:39:53 UTC (rev 923)
+++ pyplusplus_dev/unittests/member_functions_tester.py 2007-02-24 19:09:22 UTC (rev 924)
@@ -45,6 +45,9 @@
mb.class_('mem_fun_constness_t' ).always_expose_using_scope = True
+ mb.mem_funs().add_override_precall_code( '/*override precall code*/' )
+ mb.mem_funs().add_default_precall_code( '/*default precall code*/' )
+
def create_py_immutable_by_ref( self, module ):
class py_immutable_by_ref( module.immutable_by_ref_t ):
def __init__( self ):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-24 18:40:04
|
Revision: 923
http://svn.sourceforge.net/pygccxml/?rev=923&view=rev
Author: roman_yakovenko
Date: 2007-02-24 10:39:53 -0800 (Sat, 24 Feb 2007)
Log Message:
-----------
adding possible patch to is_noncopyable type traits
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/type_traits.py
Modified: pygccxml_dev/pygccxml/declarations/type_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/type_traits.py 2007-02-24 18:37:52 UTC (rev 922)
+++ pygccxml_dev/pygccxml/declarations/type_traits.py 2007-02-24 18:39:53 UTC (rev 923)
@@ -802,6 +802,8 @@
"""implementation details"""
#It is not enough to check base classes, we should also to check
#member variables.
+ #if is_std_string( class_ ) or is_std_wstring( class_ ):
+ # return False
mvars = filter( lambda x: isinstance( x, variable.variable_t )
, class_.declarations )
for mvar in mvars:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-24 18:37:52
|
Revision: 922
http://svn.sourceforge.net/pygccxml/?rev=922&view=rev
Author: roman_yakovenko
Date: 2007-02-24 10:37:52 -0800 (Sat, 24 Feb 2007)
Log Message:
-----------
adding new test case for free functions name mangling
Modified Paths:
--------------
pygccxml_dev/unittests/data/demangled.hpp
pygccxml_dev/unittests/demangled_tester.py
Modified: pygccxml_dev/unittests/data/demangled.hpp
===================================================================
--- pygccxml_dev/unittests/data/demangled.hpp 2007-02-23 18:21:40 UTC (rev 921)
+++ pygccxml_dev/unittests/data/demangled.hpp 2007-02-24 18:37:52 UTC (rev 922)
@@ -24,4 +24,6 @@
}
+void set_a();
+
#endif//__demangled_hpp
\ No newline at end of file
Modified: pygccxml_dev/unittests/demangled_tester.py
===================================================================
--- pygccxml_dev/unittests/demangled_tester.py 2007-02-23 18:21:40 UTC (rev 921)
+++ pygccxml_dev/unittests/demangled_tester.py 2007-02-24 18:37:52 UTC (rev 922)
@@ -41,6 +41,12 @@
cls = demangled.class_( "item_t<25214903917l, 11l, 2147483648l>" )
self.failUnless( cls._name == 'item_t<25214903917,11,2147483648>' )
+ def test_free_function( self ):
+ f = self.global_ns.free_functions('set_a', allow_empty=True)
+ if not f:
+ return
+ f = f[0]
+ self.failUnless( f.mangled )
class tester_32_t( tester_impl_t ):
def __init__(self, *args):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-23 18:21:39
|
Revision: 921
http://svn.sourceforge.net/pygccxml/?rev=921&view=rev
Author: roman_yakovenko
Date: 2007-02-23 10:21:40 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
fixing broken repository by adding missing properties to the member_operator_t
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2007-02-22 19:04:04 UTC (rev 920)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2007-02-23 18:21:40 UTC (rev 921)
@@ -344,7 +344,23 @@
def __init__(self, *arguments, **keywords):
declarations.member_operator_t.__init__( self, *arguments, **keywords )
calldef_t.__init__( self )
+ self._override_precall_code = []
+ self._default_precall_code = []
+ def add_override_precall_code(self, code):
+ self._override_precall_code.append( code )
+
+ @property
+ def override_precall_code(self):
+ return self._override_precall_code
+
+ def add_default_precall_code(self, code):
+ self._default_precall_code.append( code )
+
+ @property
+ def default_precall_code(self):
+ return self._default_precall_code
+
def _get_alias( self):
alias = super( member_operator_t, self )._get_alias()
if alias == self.name:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-22 19:04:07
|
Revision: 920
http://svn.sourceforge.net/pygccxml/?rev=920&view=rev
Author: roman_yakovenko
Date: 2007-02-22 11:04:04 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
adding new unittest - is_noncopyable
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/type_traits.py
pygccxml_dev/unittests/data/type_traits.hpp
pygccxml_dev/unittests/type_traits_tester.py
Modified: pygccxml_dev/pygccxml/declarations/type_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/type_traits.py 2007-02-22 12:19:27 UTC (rev 919)
+++ pygccxml_dev/pygccxml/declarations/type_traits.py 2007-02-22 19:04:04 UTC (rev 920)
@@ -823,6 +823,8 @@
def is_noncopyable( class_ ):
"""returns True, if class is noncopyable, False otherwise"""
+ class_ = class_traits.get_declaration( class_ )
+
if class_.class_type == class_declaration.CLASS_TYPES.UNION:
return False
for base_desc in class_.recursive_bases:
Modified: pygccxml_dev/unittests/data/type_traits.hpp
===================================================================
--- pygccxml_dev/unittests/data/type_traits.hpp 2007-02-22 12:19:27 UTC (rev 919)
+++ pygccxml_dev/unittests/data/type_traits.hpp 2007-02-22 19:04:04 UTC (rev 920)
@@ -6,6 +6,8 @@
//Almost all test cases have been taken
//from boost.type_traits (http://www.boost.org) library.
+#include <string>
+
#define TYPE_PERMUTATION( BASE, NAME ) \
typedef BASE NAME##_t; \
typedef BASE const NAME##_const_t; \
@@ -33,6 +35,24 @@
typedef void (some_struct_t::*member_function_t)();
} }
+namespace is_noncopyable{
+
+namespace detail{
+ struct x{
+ private:
+ x( const x& );
+ x& operator=(const x& );
+ };
+}
+
+namespace yes{
+ typedef detail::x x;
+}
+namespace no{
+ typedef std::string string_type;
+}
+}
+
namespace is_integral{
namespace yes{
Modified: pygccxml_dev/unittests/type_traits_tester.py
===================================================================
--- pygccxml_dev/unittests/type_traits_tester.py 2007-02-22 12:19:27 UTC (rev 919)
+++ pygccxml_dev/unittests/type_traits_tester.py 2007-02-22 19:04:04 UTC (rev 920)
@@ -101,7 +101,10 @@
def test_is_fundamental(self):
self.__test_type_category( 'is_fundamental', declarations.is_fundamental )
-
+
+ def test_is_noncopyable(self):
+ self.__test_type_category( 'is_noncopyable', declarations.is_noncopyable )
+
def test_has_trivial_constructor(self):
self.__test_type_category( 'has_trivial_constructor', declarations.has_trivial_constructor )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-22 12:19:30
|
Revision: 919
http://svn.sourceforge.net/pygccxml/?rev=919&view=rev
Author: roman_yakovenko
Date: 2007-02-22 04:19:27 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
adding functionality necessary to implement correct "transfer_ownership" behaviour
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/calldef.py
pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
pyplusplus_dev/pyplusplus/module_creator/creator.py
Added Paths:
-----------
pyplusplus_dev/unittests/data/transfer_ownership_to_be_exported.hpp
pyplusplus_dev/unittests/transfer_ownership_tester.py
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-02-20 19:41:57 UTC (rev 918)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-02-22 12:19:27 UTC (rev 919)
@@ -260,6 +260,9 @@
if not self.declaration.overridable:
return self.unoverriden_function_body()
template = []
+ precall_code = self.declaration.override_precall_code
+ if precall_code:
+ template.append( os.linesep.join( precall_code ) )
template.append( '%(override)s func_%(alias)s = this->get_override( "%(alias)s" );' )
template.append( '%(return_)sfunc_%(alias)s( %(args)s );')
template = os.linesep.join( template )
@@ -360,6 +363,9 @@
def create_virtual_body(self):
template = []
+ precall_code = self.declaration.override_precall_code
+ if precall_code:
+ template.append( os.linesep.join( precall_code ) )
template.append( 'if( %(override)s func_%(alias)s = this->get_override( "%(alias)s" ) )' )
template.append( self.indent('%(return_)sfunc_%(alias)s( %(args)s );') )
template.append( 'else' )
@@ -385,8 +391,12 @@
body = self.wrapped_class_identifier() + '::' + function_call + ';'
if not declarations.is_void( self.declaration.return_type ):
body = 'return ' + body
+ precall_code = self.declaration.default_precall_code
+ if precall_code:
+ body = os.linesep.join( precall_code ) + os.linesep + body
return body
+
def create_function(self):
answer = [ self.create_declaration(self.declaration.name) + '{' ]
answer.append( self.indent( self.create_virtual_body() ) )
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2007-02-20 19:41:57 UTC (rev 918)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2007-02-22 12:19:27 UTC (rev 919)
@@ -215,7 +215,23 @@
declarations.member_function_t.__init__( self, *arguments, **keywords )
calldef_t.__init__( self )
self._use_overload_macro = False
+ self._override_precall_code = []
+ self._default_precall_code = []
+ def add_override_precall_code(self, code):
+ self._override_precall_code.append( code )
+
+ @property
+ def override_precall_code(self):
+ return self._override_precall_code
+
+ def add_default_precall_code(self, code):
+ self._default_precall_code.append( code )
+
+ @property
+ def default_precall_code(self):
+ return self._default_precall_code
+
def get_use_overload_macro(self):
return self._use_overload_macro
def set_use_overload_macro(self, use_macro):
Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-02-20 19:41:57 UTC (rev 918)
+++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-02-22 12:19:27 UTC (rev 919)
@@ -154,7 +154,9 @@
if doc_extractor and decl.exportable:
if decl.documentation:
- decl.documentation = decl.documentation + doc_extractor( decl )
+ extracted_doc = doc_extractor( decl )
+ if extracted_doc != decl.documentation:
+ decl.documentation = decl.documentation + extracted_doc
else:
decl.documentation = doc_extractor( decl )
Added: pyplusplus_dev/unittests/data/transfer_ownership_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/transfer_ownership_to_be_exported.hpp (rev 0)
+++ pyplusplus_dev/unittests/data/transfer_ownership_to_be_exported.hpp 2007-02-22 12:19:27 UTC (rev 919)
@@ -0,0 +1,31 @@
+#ifndef __transfer_ownership_to_be_exported_hpp__
+#define __transfer_ownership_to_be_exported_hpp__
+
+struct event_t
+{
+ virtual void notify() = 0;
+ virtual ~event_t(){}
+};
+
+struct do_nothing_t : event_t{
+ virtual void notify(){};
+};
+
+struct simulator_t{
+
+ void schedule(event_t *event) {
+ m_event = event;
+ };
+
+ void run() {
+ m_event->notify();
+ delete m_event;
+ m_event = 0;
+ };
+
+private:
+ event_t* m_event;
+};
+
+
+#endif//__transfer_ownership_to_be_exported_hpp__
Added: pyplusplus_dev/unittests/transfer_ownership_tester.py
===================================================================
--- pyplusplus_dev/unittests/transfer_ownership_tester.py (rev 0)
+++ pyplusplus_dev/unittests/transfer_ownership_tester.py 2007-02-22 12:19:27 UTC (rev 919)
@@ -0,0 +1,107 @@
+# 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
+from pyplusplus import function_transformers as ft
+
+decref_code = \
+"""
+virtual ~%(cls)s(){
+ if (this->m_pyobj) {
+ //Py_DECREF(this->m_pyobj);
+ this->m_pyobj = 0;
+ }
+}
+"""
+
+incref_code = \
+"""
+if( !this->m_pyobj) {
+ this->m_pyobj = boost::python::detail::wrapper_base_::get_owner(*this);
+ Py_INCREF(this->m_pyobj);
+}
+"""
+
+impl_conv_code = \
+"""
+boost::python::implicitly_convertible< std::auto_ptr< %(from)s >, std::auto_ptr< %(to)s > >();
+"""
+
+class tester_t(fundamental_tester_base.fundamental_tester_base_t):
+ EXTENSION_NAME = 'transfer_ownership'
+
+ def __init__( self, *args ):
+ fundamental_tester_base.fundamental_tester_base_t.__init__(
+ self
+ , tester_t.EXTENSION_NAME
+ , *args )
+
+ def customize( self, mb ):
+ event_clss = mb.classes( lambda cls: cls.name in ( 'event_t', 'do_nothing_t' ) )
+ for cls in event_clss:
+ cls.add_wrapper_code( decref_code % { 'cls' : cls.wrapper_alias } )
+ cls.add_wrapper_code( 'PyObject* m_pyobj;' )
+ cls.set_constructors_body( 'm_pyobj=0;' )
+ cls.mem_fun( 'notify' ).add_override_precall_code( incref_code )
+ cls.mem_fun( 'notify' ).add_default_precall_code( incref_code )
+
+ cls.held_type = 'std::auto_ptr< %s >' % cls.wrapper_alias
+ cls.add_registration_code( impl_conv_code % { 'from' : cls.wrapper_alias
+ , 'to' : cls.decl_string }
+ , False)
+ for base in cls.recursive_bases:
+ if base.access_type == 'public':
+ cls.add_registration_code( #from class to its base
+ impl_conv_code % { 'from' : cls.decl_string
+ , 'to' : base.related_class.decl_string }
+ , False)
+
+ cls.add_registration_code( #from wrapper to clas base class
+ impl_conv_code % { 'from' : cls.wrapper_alias
+ , 'to' : base.related_class.decl_string }
+ , False)
+
+ schedule = mb.mem_fun( 'schedule' )
+ schedule.add_transformation( ft.transfer_ownership(0), alias='schedule' )
+
+ def run_tests( self, module):
+ class py_event_t( module.event_t ):
+ def __init__( self, container ):
+ module.event_t.__init__( self )
+ self.container = container
+
+ def notify( self ):
+ print 1
+ #self.container.append( 1 )
+
+ print '1'
+ notify_data = []
+ simulator = module.simulator_t()
+ print '2'
+ event = py_event_t( notify_data )
+ print '3'
+ simulator.schedule( event )
+ print 'refcount: ', sys.getrefcount( event )
+ print '4'
+ del event
+ print '5'
+ simulator.run()
+ print '6'
+ self.failUnless( notify_data[0] == 1 )
+
+def create_suite():
+ suite = unittest.TestSuite()
+ suite.addTest( unittest.makeSuite(tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-20 19:42:04
|
Revision: 917
http://svn.sourceforge.net/pygccxml/?rev=917&view=rev
Author: roman_yakovenko
Date: 2007-02-20 11:41:19 -0800 (Tue, 20 Feb 2007)
Log Message:
-----------
rallback some changes, which were done while I wrote documentation
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 2007-02-20 11:04:51 UTC (rev 916)
+++ pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2007-02-20 19:41:19 UTC (rev 917)
@@ -231,21 +231,20 @@
};
-
-}
-
-struct resource_t{
- resource_t(){
- std::cout << "created";
+struct transfer_ownership_tester_t{
+ struct resources_t{
+ resources_t(){
+ std::cout << "created";
+ }
+ ~resources_t(){
+ std::cout << "destroyed";
+ }
+ };
+ void tester(resources_t* r){
+ delete r;
}
- ~resource_t(){
- std::cout << "destroyed";
- }
};
-void do_smth(resource_t* r){
-
}
-
#endif//__function_transformations_to_be_exported_hpp__
Modified: pyplusplus_dev/unittests/function_transformations_tester.py
===================================================================
--- pyplusplus_dev/unittests/function_transformations_tester.py 2007-02-20 11:04:51 UTC (rev 916)
+++ pyplusplus_dev/unittests/function_transformations_tester.py 2007-02-20 19:41:19 UTC (rev 917)
@@ -85,10 +85,11 @@
write_s = cls.mem_fun( 'write_s' )
write_s.add_transformation( ft.input_c_buffer( 'buffer', 'size' ) )
- resource = mb.class_( 'resource_t' )
+ resource = mb.class_( 'resources_t' )
resource.held_type = 'std::auto_ptr< %s >' % resource.decl_string
- do_smth = mb.free_fun( 'do_smth' )
- do_smth.add_transformation( ft.transfer_ownership( 0 ) )
+ transfer_ownership_tester = mb.class_( 'transfer_ownership_tester_t' )
+ tester = transfer_ownership_tester.mem_fun( 'tester' )
+ tester.add_transformation( ft.transfer_ownership( 0 ) )
def run_tests(self, module):
"""Run the actual unit tests.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-20 19:41:58
|
Revision: 918
http://svn.sourceforge.net/pygccxml/?rev=918&view=rev
Author: roman_yakovenko
Date: 2007-02-20 11:41:57 -0800 (Tue, 20 Feb 2007)
Log Message:
-----------
Adding more information to some warnings
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
pyplusplus_dev/pyplusplus/messages/warnings_.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2007-02-20 19:41:19 UTC (rev 917)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2007-02-20 19:41:57 UTC (rev 918)
@@ -184,11 +184,12 @@
if ft.alias == ft.unique_name:
msgs.append( messages.W1044 % ft.alias )
return msgs
-
+
if suspicious_type( self.return_type ) and None is self.call_policies:
msgs.append( messages.W1008 )
- if is_double_ptr( self.return_type ) and None is self.call_policies:
+ if ( declarations.is_pointer( self.return_type ) or is_double_ptr( self.return_type ) ) \
+ and None is self.call_policies:
msgs.append( messages.W1050 % str(self.return_type) )
for index, arg in enumerate( self.arguments ):
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2007-02-20 19:41:19 UTC (rev 917)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2007-02-20 19:41:57 UTC (rev 918)
@@ -484,30 +484,32 @@
if self.copy_constructor_body:
explanation.append( messages.W1022 )
- if self.redefined_funcs():
- explanation.append( messages.W1023 )
+ redefined_funcs = self.redefined_funcs()
+ if redefined_funcs:
+ funcs = map( lambda f: f.name, redefined_funcs )
+ explanation.append( messages.W1023 % ', '.join(funcs) )
for member in self.get_exportable_members():
if isinstance( member, declarations.destructor_t ):
continue
if isinstance( member, declarations.variable_t ):
if member.bits:
- explanation.append( messages.W1024 )
+ explanation.append( messages.W1024 % member.name )
if declarations.is_pointer( member.type ):
- explanation.append( messages.W1025 )
+ explanation.append( messages.W1025 % member.name )
if declarations.is_reference( member.type ):
- explanation.append( messages.W1026 )
+ explanation.append( messages.W1026 % member.name )
if declarations.is_array( member.type ):
- explanation.append( messages.W1027 )
+ explanation.append( messages.W1027 % member.name)
if isinstance( member, declarations.class_t ) and member.is_wrapper_needed():
- explanation.append( messages.W1028 )
+ explanation.append( messages.W1028 % member.name)
if isinstance( member, declarations.calldef_t ):
if isinstance( member, declarations.constructor_t ) and member.body:
explanation.append( messages.W1029 )
if member.virtuality != VIRTUALITY_TYPES.NOT_VIRTUAL:
- explanation.append( messages.W1030 )
+ explanation.append( messages.W1030 % member.name )
if member.access_type in ( ACCESS_TYPES.PROTECTED, ACCESS_TYPES.PRIVATE ):
- explanation.append( messages.W1031 )
+ explanation.append( messages.W1031 % member.name)
return explanation
def _readme_impl( self ):
Modified: pyplusplus_dev/pyplusplus/messages/warnings_.py
===================================================================
--- pyplusplus_dev/pyplusplus/messages/warnings_.py 2007-02-20 19:41:19 UTC (rev 917)
+++ pyplusplus_dev/pyplusplus/messages/warnings_.py 2007-02-20 19:41:57 UTC (rev 918)
@@ -73,23 +73,24 @@
W1022 = "Py++ will generate class wrapper - hand written code should be added to the wrapper class copy constructor body"
-W1023 = "Py++ will generate class wrapper - there are few functions that should be redefined in class wrapper"
+W1023 = "Py++ will generate class wrapper - there are few functions that should be redefined in class wrapper. " \
+ "The functions are: %s."
-W1024 = "Py++ will generate class wrapper - class contains bit field member variable"
+W1024 = 'Py++ will generate class wrapper - class contains "%s" - bit field member variable'
-W1025 = "Py++ will generate class wrapper - class contains T* member variable"
+W1025 = 'Py++ will generate class wrapper - class contains "%s" - T* member variable'
-W1026 = "Py++ will generate class wrapper - class contains T& member variable"
+W1026 = 'Py++ will generate class wrapper - class contains "%s" - T& member variable'
-W1027 = "Py++ will generate class wrapper - class contains array member variable"
+W1027 = 'Py++ will generate class wrapper - class contains "%s" - array member variable'
-W1028 = "Py++ will generate class wrapper - class contains definition of nested class that requires wrapper class"
+W1028 = 'Py++ will generate class wrapper - class contains definition of nested class "%s", which requires wrapper class'
W1029 = "Py++ will generate class wrapper - hand written code should be added to the wrapper class constructor body"
-W1030 = "Py++ will generate class wrapper - class contains definition of virtual or pure virtual member function"
+W1030 = 'Py++ will generate class wrapper - class contains "%s" - [pure] virtual member function'
-W1031 = "Py++ will generate class wrapper - user asked to expose non - public member function"
+W1031 = 'Py++ will generate class wrapper - user asked to expose non - public member function "%s"'
W1032 = "Boost.Python library does not support enums with duplicate values. " \
"You can read more about this here: " \
@@ -148,7 +149,9 @@
W1049 = 'This method could not be overriden in Python - method returns reference ' \
'to local variable!'
-W1050 = 'The function returns "%s" type. You have to specify a call policies.'
+W1050 = 'The function returns "%s" type. You have to specify a call policies.' \
+ 'Be sure to take a look on Py++ defined call policies: ' \
+ 'http://language-binding.net/pyplusplus/documentation/functions/call_policies.html#py-defined-call-policies'
W1051 = 'The function takes as argument (name=%s, pos=%d) "%s" type. ' \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-20 11:04:53
|
Revision: 916
http://svn.sourceforge.net/pygccxml/?rev=916&view=rev
Author: roman_yakovenko
Date: 2007-02-20 03:04:51 -0800 (Tue, 20 Feb 2007)
Log Message:
-----------
updating documentation
Modified Paths:
--------------
pyplusplus_dev/docs/documentation/functions/call_policies.rest
pyplusplus_dev/docs/documentation/functions/transformation/built_in/built_in.rest
pyplusplus_dev/docs/documentation/functions/transformation/built_in/modify_type.rest
pyplusplus_dev/unittests/call_policies_tester.py
pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp
pyplusplus_dev/unittests/function_transformations_tester.py
website/site_creator/page_creator.py
Modified: pyplusplus_dev/docs/documentation/functions/call_policies.rest
===================================================================
--- pyplusplus_dev/docs/documentation/functions/call_policies.rest 2007-02-19 19:33:01 UTC (rev 915)
+++ pyplusplus_dev/docs/documentation/functions/call_policies.rest 2007-02-20 11:04:51 UTC (rev 916)
@@ -246,13 +246,13 @@
struct vector3{
...
- float* clone_row_data() const{
+ float* clone_raw_data() const{
float* values = new float[3];
//copy values
return values;
}
- const flow* get_row_data() const{
+ const flow* get_raw_data() const{
return m_values;
}
@@ -264,11 +264,11 @@
namespace pypp_cp = pyplusplus::call_policies;
BOOST_PYTHON_MODULE(my_module){
bpl::class_< vector3 >( "vector3" )
- .def( "clone_row_data"
- , &::vector3::clone_row_data
+ .def( "clone_raw_data"
+ , &::vector3::clone_raw_data
, bpl::return_value_policy< pypp_cp::arrays::as_tuple< 3, pypp_cp::memory_managers::delete_ > >() )
- .def( "get_row_data"
- , &::vector3::get_row_data
+ .def( "get_raw_data"
+ , &::vector3::get_raw_data
, bpl::return_value_policy< pypp_cp::arrays::as_tuple< 3, pypp_cp::memory_managers::none > >() ) );
}
@@ -295,14 +295,230 @@
from pyplusplus.module_builder import call_policies
mb = module_builder.module_builder_t( ... )
- mb.member_function( 'clone_row_data' ).call_policies \
+ mb.member_function( 'clone_raw_data' ).call_policies \
= call_policies.convert_array_to_tuple( 3, call_policies.memory_managers.delete_ )
- mb.member_function( 'get_row_data' ).call_policies \
+ mb.member_function( 'get_raw_data' ).call_policies \
= call_policies.convert_array_to_tuple( 3, call_policies.memory_managers.none )
+return_range
+------------
+Class ``return_range`` is a model of `CallPolicies`_, which can be used to wrap
+C++ functions that return a pointer to some array. The new call policy constructs
+object, which provides a regular `Python`_ `sequence`_ interface.
+.. _`sequence` : http://docs.python.org/lib/typesseq.html
+
+
+Example
+~~~~~~~
+
+.. code-block:: C++
+
+ struct image_t{
+
+ ...
+
+ const unsigned char* get_data() const{
+ return m_raw_data;
+ }
+
+ ssize_t get_width() const{
+ return m_width;
+ }
+
+ ssize_t get_height() const{
+ return m_height;
+ }
+
+ private:
+ unsigned long m_width;
+ unsigned long m_height;
+ unsigned char* m_raw_data;
+ };
+
+Before introducing the whole solution, I would like to describe "return_range"
+interface.
+
+``return_range`` definition
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: C++
+
+ template < typename TGetSize
+ , typename TValueType
+ , typename TValuePolicies=boost::python::default_call_policies >
+ struct return_range : boost::python::default_call_policies
+ { ... };
+
+`Boost.Python`_ call policies are stateless classes, which do not care any
+information about the invoked function or object. In out case we have to pass
+next information:
+
+* the size of array
+
+* array type
+
+* "__getitem__" call policies for array elements
+
+
+``TGetSize`` parameter
+++++++++++++++++++++++
+
+``TGetSize`` is a class, which is responsible to find out the size of the returned
+array.
+
+``TGetSize`` class must have:
+
+* default constructor
+
+* call operator with next signature:
+
+ .. code-block:: C++
+
+ ssize_t operator()( boost::python::tuple args );
+
+ ``args`` is a tuple of arguments, the function was called with.
+
+ Pay attention: this operator will be invoked **after** the function. This
+ call policy is **not thread-safe**!
+
+For our case, next class could be defined:
+
+.. code-block:: C++
+
+ struct image_data_size_t{
+ ssize_t operator()( boost::python::tuple args ){
+ namespace bpl = boost::python;
+ bpl::object self = args[0];
+ image_t& img = bpl::extract< image_t& >( self );
+ return img.get_width() * img.get_height();
+ }
+ };
+
+Passing all arguments, instead of single "self" argument gives you an ability
+to treat functions, where the user asked to get access to the part of the array.
+
+.. code-block:: C++
+
+ struct image_t{
+ ...
+ const unsigned char* get_data(ssize_t offset) const{
+ //check that offset represents a legal value
+ ...
+ return &m_raw_data[offset];
+ }
+ ...
+ };
+
+Next "get size" class treats this situation:
+
+.. code-block:: C++
+
+ struct image_data_size_t{
+ ssize_t operator()( boost::python::tuple args ){
+ namespace bpl = boost::python;
+ bpl::object self = args[0];
+ image_t& img = bpl::extract< image_t& >( self );
+ bpl::object offset_obj = args[1];
+ ssize_t offset = bpl::extract< ssize_t >( offset_obj );
+ return img.get_width() * img.get_height() - offset;
+ }
+ };
+
+
+``TValueType`` parameter
+++++++++++++++++++++++++
+
+``TValueType`` is a type of array element. In our case it is ``unsigned char``.
+
+``TValuePolicies`` parameter
+++++++++++++++++++++++++++++
+
+``TValuePolicies`` is a "call policy" class, which will be applied when the array
+element is returned to `Python`_. This is a call policy for "__getitem__" function.
+
+``unsigned char`` is mapped to immutable type in `Python`_, so I have to use
+``default_call_policies``. ``default_call_policies`` is a default value for
+``TValuePolicies`` parameter.
+
+
+I think, now you are ready to see the whole solution:
+
+.. code-block:: C++
+
+ namespace bpl = boost::python;
+ namespace ppc = pyplusplus::call_policies;
+
+ BOOST_PYTHON_MODULE(my_module){
+ bpl::class_< image_t >( "image_t" )
+ .def( "get_width", &image_t::get_width )
+ .def( "get_height", &image_t::get_height )
+ .def( "get_raw_data", ppc::return_range< image_size_t, unsigned char >() );
+ }
+
+Py++ integration
+~~~~~~~~~~~~~~~~
+
+The `Py++`_ code is not that different from what you already know:
+
+.. code-block:: Python
+
+ from pyplusplus import module_builder
+ from pyplusplus.module_builder import call_policies
+
+ image_size_code = \
+ """
+ struct image_data_size_t{
+ ssize_t operator()( boost::python::tuple args ){
+ namespace bpl = boost::python;
+ bpl::object self = args[0];
+ image_t& img = bpl::extract< image_t& >( self );
+ return img.get_width() * img.get_height();
+ }
+ };
+ """
+
+ mb = module_builder.module_builder_t( ... )
+ image = mb.class_( 'image_t' )
+ image.add_declaration_code( image_size_code )
+ get_raw_data = image.mem_fun( 'get_raw_data' )
+ get_raw_data.call_policies \
+ = call_policies.return_range( get_raw_data, "image_data_size_t" )
+
+call_policies.return_range arguments:
+
+1. A reference to function. `Py++`_ will extract by itself the type of the array
+ element.
+
+2. A name of "get size" class.
+
+3. A call policies for "__getitem__" function. `Py++`_ will analyze the array
+ element type. If the type is mapped to immutable type, than ``default_call_policies``
+ is used, otherwise you have to specify call policies.
+
+
+Python usage code:
+
+.. code-block:: Python
+
+ from my_module import *
+
+ img = image_t(...)
+ for p in img.get_raw_data():
+ print p
+
+Dependencies
+~~~~~~~~~~~~
+
+The new call policy depends on `new indexing suite`_ and `Py++`_ :-). But if you
+want you can extract the relevant piece of code from `this file`_.
+
+.. _`new indexing suite` : ./../containers.html
+.. _`this file` : http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/pyplusplus/code_repository/call_policies.py?view=markup
+
.. _`ResultConverterGenerator` : http://boost.org/libs/python/doc/v2/ResultConverter.html#ResultConverterGenerator-concept
+.. _`CallPolicies` : http://www.boost.org/libs/python/doc/v2/CallPolicies.html#CallPolicies-concept
.. _`Py++` : ./../pyplusplus.html
.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html
Modified: pyplusplus_dev/docs/documentation/functions/transformation/built_in/built_in.rest
===================================================================
--- pyplusplus_dev/docs/documentation/functions/transformation/built_in/built_in.rest 2007-02-19 19:33:01 UTC (rev 915)
+++ pyplusplus_dev/docs/documentation/functions/transformation/built_in/built_in.rest 2007-02-20 11:04:51 UTC (rev 916)
@@ -24,6 +24,8 @@
* ``input_c_buffer``
+* ``transfer_ownership``
+
The set doesn't cover all common use cases, but it will grow with every new
version of `Py++`_. If you created your own transformer consider to contribute
it to the project.
Modified: pyplusplus_dev/docs/documentation/functions/transformation/built_in/modify_type.rest
===================================================================
--- pyplusplus_dev/docs/documentation/functions/transformation/built_in/modify_type.rest 2007-02-19 19:33:01 UTC (rev 915)
+++ pyplusplus_dev/docs/documentation/functions/transformation/built_in/modify_type.rest 2007-02-20 11:04:51 UTC (rev 916)
@@ -18,10 +18,11 @@
New in version grater than 0.8.5.
-Known limits
-------------
+Pay attention!
+--------------
-Implicit conversion should exist between new type and the old one.
+If implicit conversion between new type and the old one does not exist
+"reinterpret_cast" will be used.
-------
Example
Modified: pyplusplus_dev/unittests/call_policies_tester.py
===================================================================
--- pyplusplus_dev/unittests/call_policies_tester.py 2007-02-19 19:33:01 UTC (rev 915)
+++ pyplusplus_dev/unittests/call_policies_tester.py 2007-02-20 11:04:51 UTC (rev 916)
@@ -22,7 +22,8 @@
get_size_code = """
struct raw_data_size_t{
ssize_t
- operator()( boost::python::object self ){
+ operator()( boost::python::tuple args ){
+ boost::python::object self = args[0];
call_policies::return_range_image_t& image
= boost::python::extract<call_policies::return_range_image_t&>( self );
return image.raw_data.size();
Modified: pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2007-02-19 19:33:01 UTC (rev 915)
+++ pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2007-02-20 11:04:51 UTC (rev 916)
@@ -231,20 +231,21 @@
};
-struct transfer_ownership_tester_t{
- struct resources_t{
- resources_t(){
- std::cout << "created";
- }
- ~resources_t(){
- std::cout << "destroyed";
- }
- };
- void tester(resources_t* r){
- delete r;
+
+}
+
+struct resource_t{
+ resource_t(){
+ std::cout << "created";
}
+ ~resource_t(){
+ std::cout << "destroyed";
+ }
};
+void do_smth(resource_t* r){
+
}
+
#endif//__function_transformations_to_be_exported_hpp__
Modified: pyplusplus_dev/unittests/function_transformations_tester.py
===================================================================
--- pyplusplus_dev/unittests/function_transformations_tester.py 2007-02-19 19:33:01 UTC (rev 915)
+++ pyplusplus_dev/unittests/function_transformations_tester.py 2007-02-20 11:04:51 UTC (rev 916)
@@ -85,11 +85,10 @@
write_s = cls.mem_fun( 'write_s' )
write_s.add_transformation( ft.input_c_buffer( 'buffer', 'size' ) )
- resource = mb.class_( 'resources_t' )
+ resource = mb.class_( 'resource_t' )
resource.held_type = 'std::auto_ptr< %s >' % resource.decl_string
- transfer_ownership_tester = mb.class_( 'transfer_ownership_tester_t' )
- tester = transfer_ownership_tester.mem_fun( 'tester' )
- tester.add_transformation( ft.transfer_ownership( 0 ) )
+ do_smth = mb.free_fun( 'do_smth' )
+ do_smth.add_transformation( ft.transfer_ownership( 0 ) )
def run_tests(self, module):
"""Run the actual unit tests.
Modified: website/site_creator/page_creator.py
===================================================================
--- website/site_creator/page_creator.py 2007-02-19 19:33:01 UTC (rev 915)
+++ website/site_creator/page_creator.py 2007-02-20 11:04:51 UTC (rev 916)
@@ -42,15 +42,20 @@
language = options['language']
if content and 'source-file' in options:
- error = state_machine.reporter.error( "You cannot both specify a source-file and include code directly.",
- docutils.nodes.literal_block(block_text,block_text), line=lineno)
+ error = state_machine.reporter.error( "You cannot both specify a source-file and include code directly."
+ , docutils.nodes.literal_block(block_text,block_text), line=lineno)
return [error]
source_code = None
if content:
source_code = os.linesep.join( map( lambda s: s.rstrip(), content ) )
else:
- source_code = file( options['source-file'] ).read()
+ try:
+ source_code = file( options['source-file'] ).read()
+ except Exception, err:
+ error = state_machine.reporter.error( "Exception: " + str( err )
+ , docutils.nodes.literal_block(block_text,block_text), line=lineno)
+ return [error]
html = pykleur.highlight( source_code
, pykleur.lexers.get_lexer_by_name( language.lower() )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-19 19:33:02
|
Revision: 915
http://svn.sourceforge.net/pygccxml/?rev=915&view=rev
Author: roman_yakovenko
Date: 2007-02-19 11:33:01 -0800 (Mon, 19 Feb 2007)
Log Message:
-----------
changing "TGetSize" interface to get all arguments
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_repository/call_policies.py
pyplusplus_dev/pyplusplus/module_creator/creator.py
Modified: pyplusplus_dev/pyplusplus/code_repository/call_policies.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/call_policies.py 2007-02-18 20:04:59 UTC (rev 914)
+++ pyplusplus_dev/pyplusplus/code_repository/call_policies.py 2007-02-19 19:33:01 UTC (rev 915)
@@ -195,13 +195,12 @@
value_type* raw_data = reinterpret_cast<value_type*>( PyCObject_AsVoidPtr( result ) );
Py_DECREF(result);//we don't need result anymore
- PyObject* self_impl = bpl::detail::get(boost::mpl::int_<0>(),args);
- bpl::object self( bpl::handle<>( bpl::borrowed( self_impl ) ) );
+ bpl::tuple args_w( bpl::handle<>( bpl::borrowed( args ) ) );
register_range_class_on_demand();
get_size_type get_size;
- range_type the_range( raw_data, raw_data + get_size( self ) );
+ range_type the_range( raw_data, raw_data + get_size( args_w ) );
bpl::object range_obj( the_range );
Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-02-18 20:04:59 UTC (rev 914)
+++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-02-19 19:33:01 UTC (rev 915)
@@ -153,7 +153,10 @@
#self.__types_db.update( decl )
if doc_extractor and decl.exportable:
- decl.documentation = doc_extractor( decl )
+ if decl.documentation:
+ decl.documentation = decl.documentation + doc_extractor( decl )
+ else:
+ decl.documentation = doc_extractor( decl )
readme = decl.readme()
if not readme:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-18 20:05:03
|
Revision: 914
http://svn.sourceforge.net/pygccxml/?rev=914&view=rev
Author: roman_yakovenko
Date: 2007-02-18 12:04:59 -0800 (Sun, 18 Feb 2007)
Log Message:
-----------
adding tester to return_range call policies
Modified Paths:
--------------
pyplusplus_dev/unittests/call_policies_tester.py
pyplusplus_dev/unittests/data/call_policies_to_be_exported.hpp
Modified: pyplusplus_dev/unittests/call_policies_tester.py
===================================================================
--- pyplusplus_dev/unittests/call_policies_tester.py 2007-02-18 18:54:27 UTC (rev 913)
+++ pyplusplus_dev/unittests/call_policies_tester.py 2007-02-18 20:04:59 UTC (rev 914)
@@ -30,6 +30,15 @@
};
"""
+get_create_images_size = """
+struct get_create_images_size_t{
+ ssize_t
+ operator()( boost::python::object self ){
+ return 3;
+ }
+};
+"""
+
class tester_t(fundamental_tester_base.fundamental_tester_base_t):
EXTENSION_NAME = 'call_policies'
@@ -58,16 +67,20 @@
= call_policies.convert_array_to_tuple( 3, call_policies.memory_managers.delete_ )
image = mb.class_('return_range_image_t')
- #image.exclude()
image.add_declaration_code( get_size_code )
+ image.add_declaration_code( get_create_images_size )
get_raw_data = image.mem_fun( 'get_raw_data' )
get_raw_data.call_policies \
= call_policies.return_range( get_raw_data, 'raw_data_size_t' )
get_raw_data_const = image.mem_fun( 'get_raw_data_const' )
get_raw_data_const.call_policies \
= call_policies.return_range( get_raw_data_const, 'raw_data_size_t' )
+ create_images = image.mem_fun( 'create_images' )
+ create_images.call_policies \
+ = call_policies.return_range( create_images
+ , 'get_create_images_size_t'
+ , call_policies.return_value_policy(call_policies.reference_existing_object) )
-
def run_tests(self, module):
self.failUnless( module.compare( module.my_address() ) )
@@ -102,6 +115,8 @@
self.failUnless( ['1', '\0', '2']==list( raw_data ) )
raw_data[1] = 'x'
self.failUnless( raw_data[1] == image.raw_data[1] )
+ for index, img in enumerate( image.create_images() ):
+ print index, img
def create_suite():
suite = unittest.TestSuite()
Modified: pyplusplus_dev/unittests/data/call_policies_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/call_policies_to_be_exported.hpp 2007-02-18 18:54:27 UTC (rev 913)
+++ pyplusplus_dev/unittests/data/call_policies_to_be_exported.hpp 2007-02-18 20:04:59 UTC (rev 914)
@@ -94,6 +94,8 @@
raw_data += '\0';
raw_data += '2';
}
+
+ ~return_range_image_t(){}
std::string raw_data;
@@ -104,9 +106,22 @@
char* get_raw_data(){
return &raw_data.at(0);
}
-
+
+ return_range_image_t* create_images(){
+ return_range_image_t* images = new return_range_image_t[3];
+ return_range_image_t x;
+ x.raw_data = "0";
+ images[0] = x;
+ return_range_image_t y;
+ y.raw_data = "1";
+ images[1] = y;
+ return_range_image_t z;
+ z.raw_data = "2";
+ images[2] = z;
+ return images;
+ }
};
-}
+}
#endif//__call_policies_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...> - 2007-02-18 18:54:29
|
Revision: 913
http://svn.sourceforge.net/pygccxml/?rev=913&view=rev
Author: roman_yakovenko
Date: 2007-02-18 10:54:27 -0800 (Sun, 18 Feb 2007)
Log Message:
-----------
adding transfer ownership transformation
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/function_transformers/__init__.py
pyplusplus_dev/pyplusplus/function_transformers/transformers.py
pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp
pyplusplus_dev/unittests/function_transformations_tester.py
pyplusplus_dev/unittests/fundamental_tester_base.py
Modified: pyplusplus_dev/pyplusplus/function_transformers/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/function_transformers/__init__.py 2007-02-17 19:25:02 UTC (rev 912)
+++ pyplusplus_dev/pyplusplus/function_transformers/__init__.py 2007-02-18 18:54:27 UTC (rev 913)
@@ -54,3 +54,8 @@
def creator( function ):
return transformers.input_c_buffer_t( function, *args, **keywd )
return creator
+
+def transfer_ownership( *args, **keywd ):
+ def creator( function ):
+ return transformers.transfer_ownership_t( function, *args, **keywd )
+ return creator
Modified: pyplusplus_dev/pyplusplus/function_transformers/transformers.py
===================================================================
--- pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2007-02-17 19:25:02 UTC (rev 912)
+++ pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2007-02-18 18:54:27 UTC (rev 913)
@@ -495,3 +495,38 @@
self.__configure_v_mem_fun_override( controller.override_controller )
self.__configure_v_mem_fun_default( controller.default_controller )
+
+class transfer_ownership_t(type_modifier_t):
+ """see http://boost.org/libs/python/doc/v2/faq.html#ownership
+ """
+ def __init__(self, function, arg_ref):
+ """Constructor."""
+ transformer.transformer_t.__init__( self, function )
+ self.arg = self.get_argument( arg_ref )
+ self.arg_index = self.function.arguments.index( self.arg )
+ if not declarations.is_pointer( self.arg.type ):
+ raise ValueError( '%s\nin order to use "transfer ownership" transformation, argument %s type must be a pointer (got %s).' ) \
+ % ( function, self.arg_ref.name, arg.type)
+
+ def __str__(self):
+ return "transfer_ownership(%s)" % self.arg.name
+
+ def __configure_sealed( self, controller ):
+ w_arg = controller.find_wrapper_arg( self.arg.name )
+ naked_type = declarations.remove_pointer( self.arg.type )
+ naked_type = declarations.remove_declarated( naked_type )
+ w_arg.type = declarations.dummy_type_t( 'std::auto_ptr< %s >' % naked_type.decl_string )
+ controller.modify_arg_expression(self.arg_index, w_arg.name + '.release()' )
+
+ def __configure_v_mem_fun_default( self, controller ):
+ self.__configure_sealed( controller )
+
+ def configure_mem_fun( self, controller ):
+ self.__configure_sealed( controller )
+
+ def configure_free_fun(self, controller ):
+ self.__configure_sealed( controller )
+
+ def configure_virtual_mem_fun( self, controller ):
+ raise NotImplementedError()
+
Modified: pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2007-02-17 19:25:02 UTC (rev 912)
+++ pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2007-02-18 18:54:27 UTC (rev 913)
@@ -231,6 +231,20 @@
};
+struct transfer_ownership_tester_t{
+ struct resources_t{
+ resources_t(){
+ std::cout << "created";
+ }
+ ~resources_t(){
+ std::cout << "destroyed";
+ }
+ };
+ void tester(resources_t* r){
+ delete r;
+ }
+};
+
}
#endif//__function_transformations_to_be_exported_hpp__
Modified: pyplusplus_dev/unittests/function_transformations_tester.py
===================================================================
--- pyplusplus_dev/unittests/function_transformations_tester.py 2007-02-17 19:25:02 UTC (rev 912)
+++ pyplusplus_dev/unittests/function_transformations_tester.py 2007-02-18 18:54:27 UTC (rev 913)
@@ -85,6 +85,12 @@
write_s = cls.mem_fun( 'write_s' )
write_s.add_transformation( ft.input_c_buffer( 'buffer', 'size' ) )
+ resource = mb.class_( 'resources_t' )
+ resource.held_type = 'std::auto_ptr< %s >' % resource.decl_string
+ transfer_ownership_tester = mb.class_( 'transfer_ownership_tester_t' )
+ tester = transfer_ownership_tester.mem_fun( 'tester' )
+ tester.add_transformation( ft.transfer_ownership( 0 ) )
+
def run_tests(self, module):
"""Run the actual unit tests.
"""
@@ -238,6 +244,10 @@
dummy = 11
self.failUnless( 'hello world' == tmp.write( list( hw ), dummy ) )
self.failUnless( 'hello world' == tmp.write_s( dummy, tuple( list( hw ) ) ) )
+
+ tmp = module.transfer_ownership_tester_t()
+ resource = tmp.resources_t();
+ tmp.tester( resource )
def create_suite():
suite = unittest.TestSuite()
Modified: pyplusplus_dev/unittests/fundamental_tester_base.py
===================================================================
--- pyplusplus_dev/unittests/fundamental_tester_base.py 2007-02-17 19:25:02 UTC (rev 912)
+++ pyplusplus_dev/unittests/fundamental_tester_base.py 2007-02-18 18:54:27 UTC (rev 913)
@@ -65,11 +65,12 @@
def _create_extension_source_file(self):
global LICENSE
- xml_file = os.path.split( self.__to_be_exported_header )[1]
- xml_file = os.path.join( autoconfig.build_dir, xml_file + '.xml' )
- xml_cached_fc = parser.create_cached_source_fc( self.__to_be_exported_header, xml_file )
+ #xml_file = os.path.split( self.__to_be_exported_header )[1]
+ #xml_file = os.path.join( autoconfig.build_dir, xml_file + '.xml' )
+ #xml_cached_fc = parser.create_cached_source_fc( self.__to_be_exported_header, xml_file )
- mb = module_builder.module_builder_t( [xml_cached_fc]
+ #mb = module_builder.module_builder_t( [xml_cached_fc]
+ mb = module_builder.module_builder_t( [self.__to_be_exported_header]
, gccxml_path=autoconfig.gccxml.executable
, include_paths=[autoconfig.boost.include]
, undefine_symbols=['__MINGW32__']
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-17 19:25:14
|
Revision: 912
http://svn.sourceforge.net/pygccxml/?rev=912&view=rev
Author: roman_yakovenko
Date: 2007-02-17 11:25:02 -0800 (Sat, 17 Feb 2007)
Log Message:
-----------
adding ability to use return_range call policy for classes
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_repository/call_policies.py
Modified: pyplusplus_dev/pyplusplus/code_repository/call_policies.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/call_policies.py 2007-02-17 11:54:13 UTC (rev 911)
+++ pyplusplus_dev/pyplusplus/code_repository/call_policies.py 2007-02-17 19:25:02 UTC (rev 912)
@@ -184,24 +184,6 @@
typedef bpl::indexing::iterator_range<value_type*> range_type;
- static void register_range_class_on_demand(){
- //Check the registry. If the class doesn't exist, register it.
- bpl::handle<> class_obj(
- bpl::objects::registered_class_object(bpl::type_id<range_type>()));
-
- if (class_obj.get() == 0){
- bpl::class_<range_type> registrator( "_impl_details_range_iterator_", bpl::init<value_type*, value_type*>() );
- if( boost::is_same< bpl::default_call_policies, value_policies_type>::value ){
- registrator.def(bpl::indexing::container_suite<range_type>() );
- }
- else{
- //I need to find out why this code does not compiles
- //typedef bpl::indexing::iterator_range_suite< range_type > suite_type;
- //registrator.def(suite_type::with_policies( value_policies_type() ) );
- }
- }
- }
-
template <class ArgumentPackage>
static PyObject* postcall(ArgumentPackage const& args, PyObject* result){
if( result == bpl::detail::none() ){
@@ -225,6 +207,35 @@
return bpl::incref( range_obj.ptr() );
}
+private:
+
+ static void register_range_class( boost::mpl::true_ ){
+ //register range class with default call policies
+ bpl::class_<range_type>( "_impl_details_range_iterator_", bpl::init<value_type*, value_type*>() )
+ .def(bpl::indexing::container_suite<range_type>() );
+ }
+
+ static void register_range_class( boost::mpl::false_ ){
+ //register range class with non default call policies
+ unsigned long const methods_mask
+ = bpl::indexing::all_methods
+ & ~( bpl::indexing::reorder_methods | bpl::indexing::search_methods ) ;
+
+ typedef bpl::indexing::iterator_range_suite< range_type, methods_mask > suite_type;
+ bpl::class_<range_type>( "_impl_details_range_iterator_", bpl::init<value_type*, value_type*>() )
+ .def( suite_type::with_policies( value_policies_type() ) );
+ }
+
+ static void register_range_class_on_demand(){
+ //Check the registry. If the class doesn't exist, register it.
+ bpl::handle<> class_obj(
+ bpl::objects::registered_class_object(bpl::type_id<range_type>()));
+
+ if( class_obj.get() == 0 ){
+ register_range_class( boost::is_same< bpl::default_call_policies, value_policies_type>() );
+ }
+ }
+
};
} /*pyplusplus*/ } /*call_policies*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2007-02-17 11:54:13
|
Revision: 911
http://svn.sourceforge.net/pygccxml/?rev=911&view=rev
Author: roman_yakovenko
Date: 2007-02-17 03:54:13 -0800 (Sat, 17 Feb 2007)
Log Message:
-----------
adding return_range call policy
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_repository/call_policies.py
pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py
pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py
pyplusplus_dev/pyplusplus/module_builder/call_policies.py
pyplusplus_dev/unittests/call_policies_tester.py
pyplusplus_dev/unittests/data/call_policies_to_be_exported.hpp
Modified: pyplusplus_dev/pyplusplus/code_repository/call_policies.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/call_policies.py 2007-02-17 11:53:00 UTC (rev 910)
+++ pyplusplus_dev/pyplusplus/code_repository/call_policies.py 2007-02-17 11:54:13 UTC (rev 911)
@@ -26,7 +26,7 @@
#include "boost/function.hpp"
#include "boost/python/suite/indexing/iterator_range.hpp"
#include "boost/python/object/class_detail.hpp"
-
+#include "boost/type_traits/is_same.hpp"
namespace pyplusplus{ namespace call_policies{
namespace bpl = boost::python;
@@ -169,33 +169,41 @@
} //detail
-template < typename ValueType, typename SizeGetter, typename GetItemCallPolicies=bpl::default_call_policies >
-struct return_range : bpl::default_call_policies
-{
- typedef return_range< ValueType, SizeGetter, GetItemCallPolicies > this_type;
+template < typename TGetSize, typename TValueType, typename TValuePolicies=bpl::default_call_policies >
+struct return_range : bpl::default_call_policies{
+
+ typedef return_range< TGetSize, TValueType, TValuePolicies > this_type;
+
public:
- //result converter generator should return PyCObject instance
- //postcall will destruct it
+
typedef typename detail::return_raw_data_ref result_converter;
- typedef GetItemCallPolicies get_item_call_policies;
- typedef ValueType value_type;
+
+ typedef TValueType value_type;
+ typedef TGetSize get_size_type;
+ typedef TValuePolicies value_policies_type;
+
typedef bpl::indexing::iterator_range<value_type*> range_type;
static void register_range_class_on_demand(){
-
- // Check the registry. If one is already registered, return it.
+ //Check the registry. If the class doesn't exist, register it.
bpl::handle<> class_obj(
bpl::objects::registered_class_object(bpl::type_id<range_type>()));
if (class_obj.get() == 0){
- bpl::class_<range_type>( "_range_iterator_", bpl::init<value_type*, value_type*>() )
- .def(bpl::indexing::container_suite<range_type>() );
+ bpl::class_<range_type> registrator( "_impl_details_range_iterator_", bpl::init<value_type*, value_type*>() );
+ if( boost::is_same< bpl::default_call_policies, value_policies_type>::value ){
+ registrator.def(bpl::indexing::container_suite<range_type>() );
+ }
+ else{
+ //I need to find out why this code does not compiles
+ //typedef bpl::indexing::iterator_range_suite< range_type > suite_type;
+ //registrator.def(suite_type::with_policies( value_policies_type() ) );
+ }
}
}
template <class ArgumentPackage>
- static PyObject* postcall(ArgumentPackage const& args, PyObject* result)
- {
+ static PyObject* postcall(ArgumentPackage const& args, PyObject* result){
if( result == bpl::detail::none() ){
return result;
}
@@ -210,9 +218,9 @@
register_range_class_on_demand();
- SizeGetter get_size;
- ssize_t size = get_size( self );
- range_type the_range( raw_data, raw_data+size );
+ get_size_type get_size;
+ range_type the_range( raw_data, raw_data + get_size( self ) );
+
bpl::object range_obj( the_range );
return bpl::incref( range_obj.ptr() );
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2007-02-17 11:53:00 UTC (rev 910)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2007-02-17 11:54:13 UTC (rev 911)
@@ -90,6 +90,8 @@
from call_policies import convert_array_to_tuple_t
from call_policies import convert_array_to_tuple
from call_policies import memory_managers
+from call_policies import return_range
+from call_policies import return_range_t
from decl_wrapper_printer import decl_wrapper_printer_t
from decl_wrapper_printer import print_declarations
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py 2007-02-17 11:53:00 UTC (rev 910)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py 2007-02-17 11:54:13 UTC (rev 911)
@@ -11,8 +11,9 @@
convinience function.
"""
+import algorithm
+import python_traits
from pygccxml import declarations
-import algorithm
class CREATION_POLICY:
"""Implementation details"""
@@ -24,9 +25,6 @@
def __init__(self):
object.__init__(self)
- def create_type(self):
- return self.create( None, CREATION_POLICY.AS_TEMPLATE_ARGUMENT )
-
def create(self, function_creator, creation_policy=CREATION_POLICY.AS_INSTANCE):
"""Creates code from the call policies class instance.
@param function_creator: parent code creator
@@ -41,6 +39,9 @@
code = code + '()'
return code
+ def create_type(self):
+ return self.create( None, CREATION_POLICY.AS_TEMPLATE_ARGUMENT )
+
def create_template_arg( self, function_creator ):
return self.create( function_creator, CREATION_POLICY.AS_TEMPLATE_ARGUMENT )
@@ -305,4 +306,51 @@
return [ declarations.templates.join( as_tuple, as_tuple_args ) ]
def convert_array_to_tuple( array_size, memory_manager, make_object_call_policies=None, base=None ):
- return convert_array_to_tuple_t( array_size, memory_manager, make_object_call_policies, base )
\ No newline at end of file
+ return convert_array_to_tuple_t( array_size, memory_manager, make_object_call_policies, base )
+
+class return_range_t( call_policy_t ):
+ def __init__( self, get_size_class, value_type, value_policies):
+ call_policy_t.__init__( self )
+ self._value_type = value_type
+ self._get_size_class = get_size_class
+ self._value_policies = value_policies
+
+ def _get_get_size_class( self ):
+ return self._get_size_class
+ def _set_get_size_class( self, new_get_size_class):
+ self._get_size_class = new_get_size_class
+ get_size_class = property( _get_get_size_class, _set_get_size_class )
+
+ def _get_value_type( self ):
+ return self._value_type
+ def _set_value_type( self, new_value_type):
+ self._value_type = new_value_type
+ value_type = property( _get_value_type, _set_value_type )
+
+ def _get_value_policies( self ):
+ return self._value_policies
+ def _set_value_policies( self, new_value_policies):
+ self._value_policies = new_value_policies
+ value_policies = property( _get_value_policies, _set_value_policies )
+
+ def _create_impl(self, function_creator ):
+ name = algorithm.create_identifier( function_creator, '::pyplusplus::call_policies::return_range' )
+ args = [ self.get_size_class, self.value_type.decl_string ]
+ if not self.value_policies.is_default():
+ args.append( self.value_policies.create_type() )
+ return declarations.templates.join( name, args )
+
+def return_range( function, get_size_class, value_policies=None ):
+ r_type = function.return_type
+ if not declarations.is_pointer( r_type ):
+ raise TypeError( 'Function "%s" return type should be pointer, got "%s"'
+ % r_type.decl_string )
+
+ value_type = declarations.remove_pointer( r_type )
+ if None is value_policies:
+ if python_traits.is_immutable( value_type ):
+ value_policies = default_call_policies()
+ else:
+ raise RuntimeError( "return_range call policies requieres specification of value_policies" )
+ return return_range_t( get_size_class, value_type, value_policies )
+
Modified: pyplusplus_dev/pyplusplus/module_builder/call_policies.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/call_policies.py 2007-02-17 11:53:00 UTC (rev 910)
+++ pyplusplus_dev/pyplusplus/module_builder/call_policies.py 2007-02-17 11:54:13 UTC (rev 911)
@@ -21,3 +21,5 @@
from pyplusplus.decl_wrappers import custom_call_policies
from pyplusplus.decl_wrappers import convert_array_to_tuple
from pyplusplus.decl_wrappers import memory_managers
+from pyplusplus.decl_wrappers import return_range
+from pyplusplus.decl_wrappers import return_range_t
Modified: pyplusplus_dev/unittests/call_policies_tester.py
===================================================================
--- pyplusplus_dev/unittests/call_policies_tester.py 2007-02-17 11:53:00 UTC (rev 910)
+++ pyplusplus_dev/unittests/call_policies_tester.py 2007-02-17 11:54:13 UTC (rev 911)
@@ -9,6 +9,27 @@
import fundamental_tester_base
from pyplusplus.module_builder import call_policies
+get_size_code = """
+struct raw_data_size_t{
+ ssize_t
+ operator()( boost::python::object self ){
+ boost::python::object raw_data = self.attr( "raw_data" );
+ return boost::python::len( raw_data );
+ }
+};
+"""
+
+get_size_code = """
+struct raw_data_size_t{
+ ssize_t
+ operator()( boost::python::object self ){
+ call_policies::return_range_image_t& image
+ = boost::python::extract<call_policies::return_range_image_t&>( self );
+ return image.raw_data.size();
+ }
+};
+"""
+
class tester_t(fundamental_tester_base.fundamental_tester_base_t):
EXTENSION_NAME = 'call_policies'
@@ -36,6 +57,17 @@
mb.calldef( 'create_arr_3' ).call_policies \
= call_policies.convert_array_to_tuple( 3, call_policies.memory_managers.delete_ )
+ image = mb.class_('return_range_image_t')
+ #image.exclude()
+ image.add_declaration_code( get_size_code )
+ get_raw_data = image.mem_fun( 'get_raw_data' )
+ get_raw_data.call_policies \
+ = call_policies.return_range( get_raw_data, 'raw_data_size_t' )
+ get_raw_data_const = image.mem_fun( 'get_raw_data_const' )
+ get_raw_data_const.call_policies \
+ = call_policies.return_range( get_raw_data_const, 'raw_data_size_t' )
+
+
def run_tests(self, module):
self.failUnless( module.compare( module.my_address() ) )
@@ -64,6 +96,12 @@
for i in range( 4 ):
arr3 = x.create_arr_3()
self.failUnless( arr3 == (0,1,2) )
+
+ image = module.return_range_image_t()
+ raw_data = image.get_raw_data()
+ self.failUnless( ['1', '\0', '2']==list( raw_data ) )
+ raw_data[1] = 'x'
+ self.failUnless( raw_data[1] == image.raw_data[1] )
def create_suite():
suite = unittest.TestSuite()
Modified: pyplusplus_dev/unittests/data/call_policies_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/call_policies_to_be_exported.hpp 2007-02-17 11:53:00 UTC (rev 910)
+++ pyplusplus_dev/unittests/data/call_policies_to_be_exported.hpp 2007-02-17 11:54:13 UTC (rev 911)
@@ -6,6 +6,8 @@
#ifndef __call_policies_to_be_exported_hpp__
#define __call_policies_to_be_exported_hpp__
+#include <string>
+
namespace call_policies{
struct dummy{
@@ -84,6 +86,27 @@
}
};
+struct return_range_image_t{
+ return_range_image_t()
+ : raw_data( "" )
+ {
+ raw_data += '1';
+ raw_data += '\0';
+ raw_data += '2';
+ }
+
+ std::string raw_data;
+
+ const char* get_raw_data_const() const{
+ return raw_data.c_str();
+ }
+
+ char* get_raw_data(){
+ return &raw_data.at(0);
+ }
+
+};
+
}
#endif//__call_policies_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...> - 2007-02-17 11:53:01
|
Revision: 910
http://svn.sourceforge.net/pygccxml/?rev=910&view=rev
Author: roman_yakovenko
Date: 2007-02-17 03:53:00 -0800 (Sat, 17 Feb 2007)
Log Message:
-----------
fixing few regression failures, caused by some changes in gccxml
Modified Paths:
--------------
pygccxml_dev/unittests/data/patcher.hpp
pygccxml_dev/unittests/demangled_tester.py
Modified: pygccxml_dev/unittests/data/patcher.hpp
===================================================================
--- pygccxml_dev/unittests/data/patcher.hpp 2007-02-16 21:59:29 UTC (rev 909)
+++ pygccxml_dev/unittests/data/patcher.hpp 2007-02-17 11:53:00 UTC (rev 910)
@@ -6,6 +6,7 @@
#ifndef __patcher_hpp__
#define __patcher_hpp__
+#include <string>
#include <vector>
namespace ns1{ namespace ns2{
Modified: pygccxml_dev/unittests/demangled_tester.py
===================================================================
--- pygccxml_dev/unittests/demangled_tester.py 2007-02-16 21:59:29 UTC (rev 909)
+++ pygccxml_dev/unittests/demangled_tester.py 2007-02-17 11:53:00 UTC (rev 910)
@@ -36,7 +36,7 @@
demangled = self.global_ns.namespace( 'demangled' )
if 32 == self.architecture:
cls = demangled.class_( 'item_t<3740067437l, 11l, 2147483648l>' )
- self.failUnless( cls._name == 'item_t<0deece66d,11,080000000>' )
+ self.failUnless( cls._name == 'item_t<0x0deece66d,11,0x080000000>' )
else:
cls = demangled.class_( "item_t<25214903917l, 11l, 2147483648l>" )
self.failUnless( cls._name == 'item_t<25214903917,11,2147483648>' )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <al...@us...> - 2007-02-16 21:59:29
|
Revision: 909
http://svn.sourceforge.net/pygccxml/?rev=909&view=rev
Author: allenb
Date: 2007-02-16 13:59:29 -0800 (Fri, 16 Feb 2007)
Log Message:
-----------
Fix up the finalize method.
Modified Paths:
--------------
pyplusplus_dev/contrib/goodies/goodie_utils.py
Modified: pyplusplus_dev/contrib/goodies/goodie_utils.py
===================================================================
--- pyplusplus_dev/contrib/goodies/goodie_utils.py 2007-02-16 20:41:45 UTC (rev 908)
+++ pyplusplus_dev/contrib/goodies/goodie_utils.py 2007-02-16 21:59:29 UTC (rev 909)
@@ -25,7 +25,6 @@
def set_allow_empty_mdecl_default(val):
pd.scopedef_t.ALLOW_EMPTY_MDECL_WRAPPER = val
-
def decl_from_typedef(decl):
""" decl: decl or mdecl with typedef. Return the "real" decl. """
typedef_decl = decl
@@ -35,7 +34,7 @@
return typedef_decl.type.declaration
-def finalize(cls):
+def finalize(cls, finalize_pure_virtuals=False):
""" Attempt to finalize a class by not exposing virtual methods.
Still exposes in the case of pure virtuals otherwise the class
could not be instantiated.
@@ -44,10 +43,22 @@
for x in cls:
finalize(x)
else:
- members = cls.decls( pd.virtuality_type_matcher( pd.VIRTUALITY_TYPES.VIRTUAL )
- , decl_type=pd.member_calldef_t
- , allow_empty=True)
+ matcher = pd.virtuality_type_matcher( pd.VIRTUALITY_TYPES.VIRTUAL )
+ if finalize_pure_virtuals:
+ matcher = matcher | pd.virtuality_type_matcher( pd.VIRTUALITY_TYPES.PURE_VIRTUAL)
+ members = cls.decls( matcher,
+ decl_type=pd.member_calldef_t,
+ allow_empty=True)
members.set_virtuality( pd.VIRTUALITY_TYPES.NOT_VIRTUAL )
+
+ cls.decls(pd.access_type_matcher_t(pd.ACCESS_TYPES.PROTECTED),allow_empty=True).exclude()
+ cls.decls(pd.access_type_matcher_t(pd.ACCESS_TYPES.PRIVATE),allow_empty=True).exclude()
+
+ wrapper_needs = cls.is_wrapper_needed()
+ if len(wrapper_needs):
+ print "Finalize failed for: ", cls.name
+ for x in wrapper_needs:
+ print " ", x
def add_member_function(cls, methodName, newMethod):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|