Revision: 215
Author: roman_yakovenko
Date: 2006-06-05 12:49:29 -0700 (Mon, 05 Jun 2006)
ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=215&view=rev
Log Message:
-----------
adding indexing suite and few type traits for it
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/type_traits.py
Added Paths:
-----------
pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite.py
Modified: pygccxml_dev/pygccxml/declarations/type_traits.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-05 19:01:29 UTC (rev 214)
+++ pygccxml_dev/pygccxml/declarations/type_traits.py 2006-06-05 19:49:29 UTC (rev 215)
@@ -731,27 +731,27 @@
return __is_noncopyable_single( class_ )
-def is_defined_in_std( cls ):
+def is_defined_in_xxx( xxx, cls ):
if not cls.parent:
return False
if not isinstance( cls.parent, namespace.namespace_t ):
return False
- if 'std' != cls.parent.name:
+ if xxx != cls.parent.name:
return False
- std = cls.parent
- if not std.parent:
+ xxx_ns = cls.parent
+ if not xxx_ns.parent:
return False
- if not isinstance( std.parent, namespace.namespace_t ):
+ if not isinstance( xxx_ns.parent, namespace.namespace_t ):
return False
- if '::' != std.parent.name:
+ if '::' != xxx_ns.parent.name:
return False
- global_ns = std.parent
+ global_ns = xxx_ns.parent
return None is global_ns.parent
class vector_traits:
@@ -772,7 +772,7 @@
if not cls.name.startswith( 'vector<' ):
return
- if not is_defined_in_std( cls ):
+ if not is_defined_in_xxx( 'std', cls ):
return
return cls
@@ -810,6 +810,32 @@
else:
raise RuntimeError( "Unable to find out vector value type. vector class is: %s" % cls.decl_string )
+def is_smart_pointer( type ):
+ type = remove_alias( type )
+ type = remove_cv( type )
+ if not is_defined_in_xxx( 'boost', type ):
+ return False
+ return type.decl_string.startswith( '::boost::shared_ptr<' )
+
+def is_std_string( type ):
+ decl_strings = [
+ '::std::basic_string<char,std::char_traits<char>,std::allocator<char> >'
+ , '::std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
+ , '::std::string' ]
+ type = remove_alias( type )
+ return remove_cv( type ).decl_string in decl_strings
+
+def is_std_wstring( type ):
+ decl_strings = [
+ '::std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >'
+ , '::std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >'
+ , '::std::wstring' ]
+ type = remove_alias( type )
+ return remove_cv( type ).decl_string in decl_strings
+
+
+
+
Added: pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite.py (rev 0)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/indexing_suite.py 2006-06-05 19:49:29 UTC (rev 215)
@@ -0,0 +1,39 @@
+# 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)
+
+from pygccxml import declarations
+
+#NoProxy
+#By default indexed elements have Python reference semantics and are returned by
+#proxy. This can be disabled by supplying true in the NoProxy template parameter.
+#When we want to disable is:
+#1. We deal with immutable objects:
+# 1. fundamental types
+# 2. enum type
+# 3. std::[w]string
+# 4. std::complex
+# 5. shared_ptr
+
+class indexing_suite_t( object ):
+ def __init__( self, no_proxy=None, derived_policies=None ):
+ object.__init__( self )
+ self.__no_proxy = no_proxy
+ self.__derived_policies = None
+
+ def value_type(self):
+ raise NotImplementedError()
+
+ def _get_no_proxy( self ):
+ if self.__no_proxy is None:
+ value_type = self.value_type()
+ if declaration.is_fundamental( value_type ):
+ self.__no_proxy = True
+ elif declarations.is_enum( value_type ):
+ self.__no_proxy = True
+
+
+
+
+
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|