pygccxml-commit Mailing List for C++ Python language bindings (Page 11)
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...> - 2009-01-21 20:07:45
|
Revision: 1607
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1607&view=rev
Author: roman_yakovenko
Date: 2009-01-21 20:07:41 +0000 (Wed, 21 Jan 2009)
Log Message:
-----------
fix few bugs, related to code_repository functionality
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/bpmodule.py
pyplusplus_dev/pyplusplus/code_creators/code_creator.py
pyplusplus_dev/pyplusplus/code_creators/compound.py
pyplusplus_dev/pyplusplus/code_creators/ctypes_module.py
pyplusplus_dev/pyplusplus/code_creators/module.py
pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py
pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py
pyplusplus_dev/pyplusplus/file_writers/writer.py
pyplusplus_dev/unittests/ctypes_tester.py
Modified: pyplusplus_dev/pyplusplus/code_creators/bpmodule.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/bpmodule.py 2009-01-21 14:42:56 UTC (rev 1606)
+++ pyplusplus_dev/pyplusplus/code_creators/bpmodule.py 2009-01-21 20:07:41 UTC (rev 1607)
@@ -11,9 +11,7 @@
import compound
import algorithm
import module_body
-import declaration_based
import include_directories
-from pygccxml import utils
class bpmodule_t(module.module_t):
"""This class represents the source code for the entire extension module.
@@ -23,7 +21,7 @@
def __init__(self, global_ns):
"""Constructor.
"""
- module.module_t.__init__(self, global_ns)
+ module.module_t.__init__(self, global_ns, bpmodule_t.CODE_GENERATOR_TYPES.BOOST_PYTHON)
self.__body = None
def _get_include_dirs(self):
@@ -157,19 +155,3 @@
def add_declaration_code( self, code, position ):
self.adopt_declaration_creator( custom.custom_text_t( code ) )
-
- @utils.cached
- def specially_exposed_decls(self):
- """list of exposed declarations, which were not ``included``, but still
- were exposed. For example, std containers.
- """
- decls = set()
- #select all declaration based code creators
- ccs = filter( lambda cc: isinstance( cc, declaration_based.declaration_based_t )
- , algorithm.make_flatten_list( self ) )
- #leave only "ignored"
- ccs = filter( lambda cc: cc.declaration.ignore == True, ccs )
-
- decls = map( lambda cc: cc.declaration, ccs )
-
- return set( decls )
Modified: pyplusplus_dev/pyplusplus/code_creators/code_creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2009-01-21 14:42:56 UTC (rev 1606)
+++ pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2009-01-21 20:07:41 UTC (rev 1607)
@@ -41,6 +41,8 @@
@property
def code_generator( self ):
+ if self._code_generator is None:
+ self._code_generator = self.top_parent.code_generator
return self._code_generator
def _get_works_on_instance(self):
Modified: pyplusplus_dev/pyplusplus/code_creators/compound.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/compound.py 2009-01-21 14:42:56 UTC (rev 1606)
+++ pyplusplus_dev/pyplusplus/code_creators/compound.py 2009-01-21 20:07:41 UTC (rev 1607)
@@ -78,8 +78,7 @@
return os.linesep.join( internals )
def get_system_files( self, recursive=False, unique=False, language='any' ):
- files = [ "boost/python.hpp" ]
- files.extend( self._get_system_files_impl() )
+ files = super( compound_t, self ).get_system_files(recursive, unique=False, language=language)
if recursive:
for creator in self._creators:
files.extend( creator.get_system_files(recursive, unique=False, language=language) )
Modified: pyplusplus_dev/pyplusplus/code_creators/ctypes_module.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/ctypes_module.py 2009-01-21 14:42:56 UTC (rev 1606)
+++ pyplusplus_dev/pyplusplus/code_creators/ctypes_module.py 2009-01-21 20:07:41 UTC (rev 1607)
@@ -17,7 +17,7 @@
def __init__(self, global_ns):
"""Constructor.
"""
- module.module_t.__init__(self, global_ns)
+ module.module_t.__init__(self, global_ns, ctypes_module_t.CODE_GENERATOR_TYPES.CTYPES)
def _create_impl(self):
return self.create_internal_code( self.creators, indent_code=False )
Modified: pyplusplus_dev/pyplusplus/code_creators/module.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/module.py 2009-01-21 14:42:56 UTC (rev 1606)
+++ pyplusplus_dev/pyplusplus/code_creators/module.py 2009-01-21 20:07:41 UTC (rev 1607)
@@ -7,18 +7,22 @@
import license
import include
import compound
+import algorithm
+import declaration_based
+from pygccxml import utils
class module_t(compound.compound_t):
"""This class represents the source code for the entire extension module.
The root of the code creator tree is always a module_t object.
"""
- def __init__(self, global_ns):
+ def __init__(self, global_ns, code_generator_type):
"""Constructor.
"""
compound.compound_t.__init__(self)
self.__global_ns = global_ns
-
+ self._code_generator = code_generator_type
+
@property
def global_ns(self):
"reference to global_ns ( namespace_t ) declaration"
@@ -43,3 +47,20 @@
def _get_system_files_impl( self ):
return []
+
+ @utils.cached
+ def specially_exposed_decls(self):
+ """list of exposed declarations, which were not ``included``, but still
+ were exposed. For example, std containers.
+ """
+ decls = set()
+ #select all declaration based code creators
+ ccs = filter( lambda cc: isinstance( cc, declaration_based.declaration_based_t )
+ , algorithm.make_flatten_list( self ) )
+ #leave only "ignored"
+ ccs = filter( lambda cc: cc.declaration.ignore == True, ccs )
+
+ decls = map( lambda cc: cc.declaration, ccs )
+
+ return set( decls )
+
Modified: pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py
===================================================================
--- pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py 2009-01-21 14:42:56 UTC (rev 1606)
+++ pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py 2009-01-21 20:07:41 UTC (rev 1607)
@@ -81,6 +81,7 @@
self.__types_db = types_database.types_database_t()
global_ns = declarations.get_global_namespace(decls)
+
self.__extmodule = code_creators.bpmodule_t( global_ns )
if boost_python_ns_name:
bp_ns_alias = code_creators.namespace_alias_t( alias=boost_python_ns_name
@@ -353,9 +354,6 @@
self.__dependencies_manager.inform_user()
- for cc in code_creators.make_flatten( self.__extmodule ):
- cc._code_generator = decl_wrappers.CODE_GENERATOR_TYPES.BOOST_PYTHON
-
return self.__extmodule
def visit_member_function( self ):
Modified: pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2009-01-21 14:42:56 UTC (rev 1606)
+++ pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2009-01-21 20:07:41 UTC (rev 1607)
@@ -152,9 +152,6 @@
self.__dependencies_manager.inform_user()
- for cc in code_creators.make_flatten( self.module ):
- cc._code_generator = decl_wrappers.CODE_GENERATOR_TYPES.CTYPES
-
return self.module
def visit_member_function( self ):
Modified: pyplusplus_dev/pyplusplus/file_writers/writer.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/writer.py 2009-01-21 14:42:56 UTC (rev 1606)
+++ pyplusplus_dev/pyplusplus/file_writers/writer.py 2009-01-21 20:07:41 UTC (rev 1607)
@@ -32,9 +32,8 @@
if None is files_sum_repository:
self.__files_sum_repository = md5sum_repository.dummy_repository_t()
self.__exposed_decls_db = utils.exposed_decls_db_t()
- if isinstance( self.__extmodule, code_creators.bpmodule_t ):
- self.__exposed_decls_db.register_decls( extmodule.global_ns
- , extmodule.specially_exposed_decls )
+ self.__exposed_decls_db.register_decls( extmodule.global_ns
+ , extmodule.specially_exposed_decls )
def makedirs_for_file( self, file_path ):
destination_dir = os.path.dirname( file_path )
Modified: pyplusplus_dev/unittests/ctypes_tester.py
===================================================================
--- pyplusplus_dev/unittests/ctypes_tester.py 2009-01-21 14:42:56 UTC (rev 1606)
+++ pyplusplus_dev/unittests/ctypes_tester.py 2009-01-21 20:07:41 UTC (rev 1607)
@@ -6,6 +6,7 @@
import os
import sys
import ctypes
+import shutil
import unittest
import autoconfig
from pyplusplus.module_builder import ctypes_module_builder_t
@@ -58,6 +59,11 @@
if self.base_name in sys.modules:
return sys.modules[ self.base_name ]
+ binaries_dir = os.path.dirname( self.symbols_file )
+ if os.path.exists( binaries_dir ):
+ print '\nrmdir ', binaries_dir
+ shutil.rmtree( binaries_dir )
+
autoconfig.scons_config.compile( self.__build_scons_cmd(), cwd=autoconfig.this_module_dir_path )
mb = ctypes_module_builder_t( [self.header], self.symbols_file, autoconfig.cxx_parsers_cfg.gccxml )
self.customize( mb )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-21 14:43:00
|
Revision: 1606
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1606&view=rev
Author: roman_yakovenko
Date: 2009-01-21 14:42:56 +0000 (Wed, 21 Jan 2009)
Log Message:
-----------
remove hard coded string
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/code_creator.py
Modified: pyplusplus_dev/pyplusplus/code_creators/code_creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2009-01-20 12:33:42 UTC (rev 1605)
+++ pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2009-01-21 14:42:56 UTC (rev 1606)
@@ -128,7 +128,7 @@
files.append( "boost/python.hpp" )
files.append( code_repository.named_tuple.file_name )
else:
- files.append( 'ctypes_utils.py' )
+ files.append( code_repository.ctypes_utils.file_name )
files.extend( self._get_system_files_impl() )
files = filter( None, files)
if unique:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-20 12:33:52
|
Revision: 1605
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1605&view=rev
Author: roman_yakovenko
Date: 2009-01-20 12:33:42 +0000 (Tue, 20 Jan 2009)
Log Message:
-----------
bsc and mspdb packages were deprecated
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/scanner.py
pygccxml_dev/setup.py
Added Paths:
-----------
pygccxml_dev/deprecated/
pygccxml_dev/deprecated/bsc/
pygccxml_dev/deprecated/mspdb/
Removed Paths:
-------------
pygccxml_dev/pygccxml/binary_parsers/bsc/
pygccxml_dev/pygccxml/binary_parsers/mspdb/
Modified: pygccxml_dev/pygccxml/parser/scanner.py
===================================================================
--- pygccxml_dev/pygccxml/parser/scanner.py 2009-01-20 12:25:25 UTC (rev 1604)
+++ pygccxml_dev/pygccxml/parser/scanner.py 2009-01-20 12:33:42 UTC (rev 1605)
@@ -530,18 +530,18 @@
def __read_version(self, attrs):
logger = utils.loggers.cxx_parser
-
- version = float( attrs.get(XML_AN_CVS_REVISION, 0.6) )
+ version_str = attrs.get(XML_AN_CVS_REVISION, 0.6)
+ version = float( version_str )
if version is None:
logger.info ( 'GCCXML version - 0.6' )
self.__compiler = compilers.GCC_XML_06
elif version <= 1.114:
logger.info ( 'GCCXML version - 0.7' )
self.__compiler = compilers.GCC_XML_07
- elif version in ( 1.115, 1.116, 1.117, 1.118, 1.119, 1.120, 1.121 ):
- logger.info ( 'GCCXML version - 0.9 BUGGY' )
+ elif 1.115 <= version <= 1.126:
+ logger.info ( 'GCCXML version - 0.9 BUGGY( %s )', version_str )
self.__compiler = compilers.GCC_XML_09_BUGGY
else:
- logger.info ( 'GCCXML version - 0.9' )
+ logger.info ( 'GCCXML version - 0.9( %s )', version_str )
self.__compiler = compilers.GCC_XML_09
Modified: pygccxml_dev/setup.py
===================================================================
--- pygccxml_dev/setup.py 2009-01-20 12:25:25 UTC (rev 1604)
+++ pygccxml_dev/setup.py 2009-01-20 12:33:42 UTC (rev 1605)
@@ -61,8 +61,9 @@
'pygccxml.declarations',
'pygccxml.parser',
'pygccxml.binary_parsers',
- 'pygccxml.binary_parsers.bsc',
- 'pygccxml.binary_parsers.mspdb',
+ #~ deprecated
+ #~ 'pygccxml.binary_parsers.bsc',
+ #~ 'pygccxml.binary_parsers.mspdb',
'pygccxml.utils' ],
cmdclass = {"doc" : doc_cmd}
)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-20 12:25:34
|
Revision: 1604
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1604&view=rev
Author: roman_yakovenko
Date: 2009-01-20 12:25:25 +0000 (Tue, 20 Jan 2009)
Log Message:
-----------
remove relative imports
Modified Paths:
--------------
pygccxml_dev/pygccxml/binary_parsers/config.py
pygccxml_dev/pygccxml/binary_parsers/parsers.py
Modified: pygccxml_dev/pygccxml/binary_parsers/config.py
===================================================================
--- pygccxml_dev/pygccxml/binary_parsers/config.py 2009-01-20 10:02:37 UTC (rev 1603)
+++ pygccxml_dev/pygccxml/binary_parsers/config.py 2009-01-20 12:25:25 UTC (rev 1604)
@@ -1,7 +1,7 @@
import os
import sys
import comtypes
-from .. import utils
+from pygccxml import utils
import comtypes.client
import _winreg as win_registry
from distutils import msvccompiler
Modified: pygccxml_dev/pygccxml/binary_parsers/parsers.py
===================================================================
--- pygccxml_dev/pygccxml/binary_parsers/parsers.py 2009-01-20 10:02:37 UTC (rev 1603)
+++ pygccxml_dev/pygccxml/binary_parsers/parsers.py 2009-01-20 12:25:25 UTC (rev 1604)
@@ -19,7 +19,7 @@
import warnings
import exceptions
import subprocess
-from .. import declarations
+from pygccxml import declarations
class LicenseWarning( exceptions.UserWarning ):
def __init__( self, *args, **keywd ):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-20 10:02:42
|
Revision: 1603
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1603&view=rev
Author: roman_yakovenko
Date: 2009-01-20 10:02:37 +0000 (Tue, 20 Jan 2009)
Log Message:
-----------
adding missing package to setup.py file
Modified Paths:
--------------
pyplusplus_dev/setup.py
Modified: pyplusplus_dev/setup.py
===================================================================
--- pyplusplus_dev/setup.py 2009-01-20 07:55:16 UTC (rev 1602)
+++ pyplusplus_dev/setup.py 2009-01-20 10:02:37 UTC (rev 1603)
@@ -102,6 +102,7 @@
'pyplusplus.code_creators',
'pyplusplus.creators_factory',
'pyplusplus.code_repository',
+ 'pyplusplus.code_repository.indexing_suite',
'pyplusplus.decl_wrappers',
'pyplusplus.module_builder',
'pyplusplus.utils',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-20 07:55:21
|
Revision: 1602
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1602&view=rev
Author: roman_yakovenko
Date: 2009-01-20 07:55:16 +0000 (Tue, 20 Jan 2009)
Log Message:
-----------
rename ctypes_pof_tester.py to ctypes_tester.py
Modified Paths:
--------------
pyplusplus_dev/unittests/test_all.py
Added Paths:
-----------
pyplusplus_dev/unittests/ctypes_tester.py
Removed Paths:
-------------
pyplusplus_dev/unittests/ctypes_pof_tester.py
Deleted: pyplusplus_dev/unittests/ctypes_pof_tester.py
===================================================================
--- pyplusplus_dev/unittests/ctypes_pof_tester.py 2009-01-20 07:53:01 UTC (rev 1601)
+++ pyplusplus_dev/unittests/ctypes_pof_tester.py 2009-01-20 07:55:16 UTC (rev 1602)
@@ -1,222 +0,0 @@
-# Copyright 2004-2008 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 ctypes
-import unittest
-import autoconfig
-from pyplusplus.module_builder import ctypes_module_builder_t
-
-class ctypes_base_tester_t(unittest.TestCase):
-
- _module_ref_ = None
- def __init__( self, base_name, *args, **keywd ):
- unittest.TestCase.__init__( self, *args, **keywd )
- self.__base_name = base_name
-
- @property
- def base_name( self ):
- return self.__base_name
-
- @property
- def project_dir( self ):
- return os.path.join( autoconfig.data_directory, 'ctypes', self.base_name )
-
- @property
- def header( self ):
- return os.path.join( self.project_dir, self.base_name + '.h' )
-
- @property
- def symbols_file( self ):
- ext = '.so'
- prefix = 'lib'
- if 'win32' in sys.platform:
- prefix = ''
- ext = '.map'
- return os.path.join( self.project_dir, 'binaries', prefix + self.base_name + ext )
-
- @property
- def library_file( self ):
- if 'win32' in sys.platform:
- return os.path.join( self.project_dir, 'binaries', self.base_name + '.dll' )
- else:
- return self.symbols_file
-
- def customize(self, mb ):
- pass
-
- def __build_scons_cmd( self ):
- cmd = autoconfig.scons.cmd_build + ' ' + self.base_name
- if autoconfig.cxx_parsers_cfg.gccxml.compiler == 'msvc71':
- cmd = cmd + ' use_msvc71=True'
- return cmd
-
- def setUp( self ):
- if self.base_name in sys.modules:
- return sys.modules[ self.base_name ]
-
- autoconfig.scons_config.compile( self.__build_scons_cmd(), cwd=autoconfig.this_module_dir_path )
- mb = ctypes_module_builder_t( [self.header], self.symbols_file, autoconfig.cxx_parsers_cfg.gccxml )
- self.customize( mb )
- mb.build_code_creator( self.library_file )
- mb.write_module( os.path.join( self.project_dir, 'binaries', self.base_name + '.py' ) )
- sys.path.insert( 0, os.path.join( self.project_dir, 'binaries' ) )
- __import__( self.base_name )
-
- @property
- def module_ref(self):
- return sys.modules[ self.base_name ]
-
-
-class pof_tester_t( ctypes_base_tester_t ):
- def __init__( self, *args, **keywd ):
- ctypes_base_tester_t.__init__( self, 'pof', *args, **keywd )
-
- def test_constructors(self):
- n0 = self.module_ref.pof.number_t()
- self.failUnless( 0 == n0.get_value() )
- n1 = self.module_ref.pof.number_t( ctypes.c_long(32) )
- self.failUnless( 32 == n1.get_value() )
- n2 = self.module_ref.pof.number_t( ctypes.pointer(n1) )
- self.failUnless( 32 == n2.get_value() )
-
- def test_free_functions(self):
- #the following code fails - difference in the calling conventions
- #TODO: the following test failes, because of the wrong calling convention used
- self.failUnless( self.module_ref.identity_cpp( int(111) ) == 111 )
-
- def test_get_set_values( self ):
- n0 = self.module_ref.pof.number_t()
- n0.set_value( 1977 )
- self.failUnless( 1977 == n0.get_value() )
-
- #the following functionality is still missing
- #~ def test_operator_assign( self ):
- #~ obj1 = number_t(1)
- #~ obj2 = number_t(2)
- #~ x = obj1.operator_assign( obj2 )
- #~ #there are special cases, where ctypes could introduce "optimized" behaviour and not create new python object
- #~ self.failUnless( x is obj1 )
- #~ self.failUnless( obj1.m_value == obj2.m_value )
-
- #~ def test_clone( self ):
- #~ obj1 = number_t(1)
- #~ obj2 = obj1.clone()
- #~ self.fail( obj1.get_value() == obj2.get_value() )
-
-
-class issues_tester_t( ctypes_base_tester_t ):
- def __init__( self, *args, **keywd ):
- ctypes_base_tester_t.__init__( self, 'issues', *args, **keywd )
-
- def test_return_by_value(self):
- x = self.module_ref.return_by_value_t()
- result = x.add( 32, 2 ).result
- self.failUnless( 34 == result, "Expected result 34, got %d" % result)
-
- def test_free_fun_add( self ):
- self.failUnless( 1977 == self.module_ref.add( 77, 1900 ) )
-
-
-class enums_tester_t( ctypes_base_tester_t ):
- def __init__( self, *args, **keywd ):
- ctypes_base_tester_t.__init__( self, 'enums', *args, **keywd )
-
- def customize( self, mb ):
- mb.enums().include()
-
- def test(self):
- self.failUnless( self.module_ref.Chisla.nol == 0 )
- self.failUnless( self.module_ref.Chisla.odin == 1 )
- self.failUnless( self.module_ref.Chisla.dva == 2 )
- self.failUnless( self.module_ref.Chisla.tri == 3 )
-
-class opaque_tester_t( ctypes_base_tester_t ):
- def __init__( self, *args, **keywd ):
- ctypes_base_tester_t.__init__( self, 'opaque', *args, **keywd )
-
- def customize( self, mb ):
- mb.class_( 'user_data_t' ).opaque = True
-
- def test(self):
- self.failUnlessRaises( RuntimeError, self.module_ref.user_data_t )
- udt = self.module_ref.create()
- self.failUnless( 1977 == self.module_ref.read_user_data(udt) )
- self.module_ref.destroy( udt )
-
-class include_algorithm_tester_t( ctypes_base_tester_t ):
- def __init__( self, *args, **keywd ):
- ctypes_base_tester_t.__init__( self, 'include_algorithm', *args, **keywd )
-
- def customize( self, mb ):
- self.failUnless( mb.global_ns.class_( 'io_marker_t' ).ignore == False )
-
- def test(self):
- self.failUnless( self.module_ref.io_marker_t )
-
-class anonymous_tester_t( ctypes_base_tester_t ):
- def __init__( self, *args, **keywd ):
- ctypes_base_tester_t.__init__( self, 'anonymous', *args, **keywd )
-
- def customize( self, mb ):
- mb.class_( 'rgbai' ).include()
-
- def test(self):
- c = self.module_ref.color()
- c.r
- c.val
-
-class variables_tester_t( ctypes_base_tester_t ):
- def __init__( self, *args, **keywd ):
- ctypes_base_tester_t.__init__( self, 'variables', *args, **keywd )
-
- def customize( self, mb ):
- pass
-
- def test(self):
- self.module_ref.init()
- self.failUnless( self.module_ref.j.value == 87 )
- self.failUnless( self.module_ref.data.i == 1900 )
- self.failUnless( self.module_ref.data_ptr.contents.i == 11 )
-
- self.module_ref.j.value = 78
- self.failUnless( self.module_ref.get_value_j() == 78 )
-
- self.module_ref.data.i = 987
- self.failUnless( self.module_ref.get_value_data() == 987 )
-
- self.module_ref.data_ptr.contents.i = 34
- self.failUnless( self.module_ref.get_value_data_p() == 34 )
-
-
-class varargs_tester_t( ctypes_base_tester_t ):
- def __init__( self, *args, **keywd ):
- ctypes_base_tester_t.__init__( self, 'varargs', *args, **keywd )
-
- def customize( self, mb ):
- pass
-
- def test(self):
- self.failUnless( 21 == self.module_ref.sum_ints( 3, 5,7,9) )
-
-def create_suite():
- suite = unittest.TestSuite()
- #~ if 'win' in sys.platform:
- #~ suite.addTest( unittest.makeSuite(pof_tester_t))
- #~ suite.addTest( unittest.makeSuite(issues_tester_t))
- suite.addTest( unittest.makeSuite(enums_tester_t))
- suite.addTest( unittest.makeSuite(opaque_tester_t))
- suite.addTest( unittest.makeSuite(include_algorithm_tester_t))
- suite.addTest( unittest.makeSuite(anonymous_tester_t))
- suite.addTest( unittest.makeSuite(variables_tester_t))
- suite.addTest( unittest.makeSuite(varargs_tester_t))
- return suite
-
-def run_suite():
- unittest.TextTestRunner(verbosity=2).run( create_suite() )
-
-if __name__ == "__main__":
- run_suite()
Copied: pyplusplus_dev/unittests/ctypes_tester.py (from rev 1595, pyplusplus_dev/unittests/ctypes_pof_tester.py)
===================================================================
--- pyplusplus_dev/unittests/ctypes_tester.py (rev 0)
+++ pyplusplus_dev/unittests/ctypes_tester.py 2009-01-20 07:55:16 UTC (rev 1602)
@@ -0,0 +1,222 @@
+# Copyright 2004-2008 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 ctypes
+import unittest
+import autoconfig
+from pyplusplus.module_builder import ctypes_module_builder_t
+
+class ctypes_base_tester_t(unittest.TestCase):
+
+ _module_ref_ = None
+ def __init__( self, base_name, *args, **keywd ):
+ unittest.TestCase.__init__( self, *args, **keywd )
+ self.__base_name = base_name
+
+ @property
+ def base_name( self ):
+ return self.__base_name
+
+ @property
+ def project_dir( self ):
+ return os.path.join( autoconfig.data_directory, 'ctypes', self.base_name )
+
+ @property
+ def header( self ):
+ return os.path.join( self.project_dir, self.base_name + '.h' )
+
+ @property
+ def symbols_file( self ):
+ ext = '.so'
+ prefix = 'lib'
+ if 'win32' in sys.platform:
+ prefix = ''
+ ext = '.map'
+ return os.path.join( self.project_dir, 'binaries', prefix + self.base_name + ext )
+
+ @property
+ def library_file( self ):
+ if 'win32' in sys.platform:
+ return os.path.join( self.project_dir, 'binaries', self.base_name + '.dll' )
+ else:
+ return self.symbols_file
+
+ def customize(self, mb ):
+ pass
+
+ def __build_scons_cmd( self ):
+ cmd = autoconfig.scons.cmd_build + ' ' + self.base_name
+ if autoconfig.cxx_parsers_cfg.gccxml.compiler == 'msvc71':
+ cmd = cmd + ' use_msvc71=True'
+ return cmd
+
+ def setUp( self ):
+ if self.base_name in sys.modules:
+ return sys.modules[ self.base_name ]
+
+ autoconfig.scons_config.compile( self.__build_scons_cmd(), cwd=autoconfig.this_module_dir_path )
+ mb = ctypes_module_builder_t( [self.header], self.symbols_file, autoconfig.cxx_parsers_cfg.gccxml )
+ self.customize( mb )
+ mb.build_code_creator( self.library_file )
+ mb.write_module( os.path.join( self.project_dir, 'binaries', self.base_name + '.py' ) )
+ sys.path.insert( 0, os.path.join( self.project_dir, 'binaries' ) )
+ __import__( self.base_name )
+
+ @property
+ def module_ref(self):
+ return sys.modules[ self.base_name ]
+
+
+class pof_tester_t( ctypes_base_tester_t ):
+ def __init__( self, *args, **keywd ):
+ ctypes_base_tester_t.__init__( self, 'pof', *args, **keywd )
+
+ def test_constructors(self):
+ n0 = self.module_ref.pof.number_t()
+ self.failUnless( 0 == n0.get_value() )
+ n1 = self.module_ref.pof.number_t( ctypes.c_long(32) )
+ self.failUnless( 32 == n1.get_value() )
+ n2 = self.module_ref.pof.number_t( ctypes.pointer(n1) )
+ self.failUnless( 32 == n2.get_value() )
+
+ def test_free_functions(self):
+ #the following code fails - difference in the calling conventions
+ #TODO: the following test failes, because of the wrong calling convention used
+ self.failUnless( self.module_ref.identity_cpp( int(111) ) == 111 )
+
+ def test_get_set_values( self ):
+ n0 = self.module_ref.pof.number_t()
+ n0.set_value( 1977 )
+ self.failUnless( 1977 == n0.get_value() )
+
+ #the following functionality is still missing
+ #~ def test_operator_assign( self ):
+ #~ obj1 = number_t(1)
+ #~ obj2 = number_t(2)
+ #~ x = obj1.operator_assign( obj2 )
+ #~ #there are special cases, where ctypes could introduce "optimized" behaviour and not create new python object
+ #~ self.failUnless( x is obj1 )
+ #~ self.failUnless( obj1.m_value == obj2.m_value )
+
+ #~ def test_clone( self ):
+ #~ obj1 = number_t(1)
+ #~ obj2 = obj1.clone()
+ #~ self.fail( obj1.get_value() == obj2.get_value() )
+
+
+class issues_tester_t( ctypes_base_tester_t ):
+ def __init__( self, *args, **keywd ):
+ ctypes_base_tester_t.__init__( self, 'issues', *args, **keywd )
+
+ def test_return_by_value(self):
+ x = self.module_ref.return_by_value_t()
+ result = x.add( 32, 2 ).result
+ self.failUnless( 34 == result, "Expected result 34, got %d" % result)
+
+ def test_free_fun_add( self ):
+ self.failUnless( 1977 == self.module_ref.add( 77, 1900 ) )
+
+
+class enums_tester_t( ctypes_base_tester_t ):
+ def __init__( self, *args, **keywd ):
+ ctypes_base_tester_t.__init__( self, 'enums', *args, **keywd )
+
+ def customize( self, mb ):
+ mb.enums().include()
+
+ def test(self):
+ self.failUnless( self.module_ref.Chisla.nol == 0 )
+ self.failUnless( self.module_ref.Chisla.odin == 1 )
+ self.failUnless( self.module_ref.Chisla.dva == 2 )
+ self.failUnless( self.module_ref.Chisla.tri == 3 )
+
+class opaque_tester_t( ctypes_base_tester_t ):
+ def __init__( self, *args, **keywd ):
+ ctypes_base_tester_t.__init__( self, 'opaque', *args, **keywd )
+
+ def customize( self, mb ):
+ mb.class_( 'user_data_t' ).opaque = True
+
+ def test(self):
+ self.failUnlessRaises( RuntimeError, self.module_ref.user_data_t )
+ udt = self.module_ref.create()
+ self.failUnless( 1977 == self.module_ref.read_user_data(udt) )
+ self.module_ref.destroy( udt )
+
+class include_algorithm_tester_t( ctypes_base_tester_t ):
+ def __init__( self, *args, **keywd ):
+ ctypes_base_tester_t.__init__( self, 'include_algorithm', *args, **keywd )
+
+ def customize( self, mb ):
+ self.failUnless( mb.global_ns.class_( 'io_marker_t' ).ignore == False )
+
+ def test(self):
+ self.failUnless( self.module_ref.io_marker_t )
+
+class anonymous_tester_t( ctypes_base_tester_t ):
+ def __init__( self, *args, **keywd ):
+ ctypes_base_tester_t.__init__( self, 'anonymous', *args, **keywd )
+
+ def customize( self, mb ):
+ mb.class_( 'rgbai' ).include()
+
+ def test(self):
+ c = self.module_ref.color()
+ c.r
+ c.val
+
+class variables_tester_t( ctypes_base_tester_t ):
+ def __init__( self, *args, **keywd ):
+ ctypes_base_tester_t.__init__( self, 'variables', *args, **keywd )
+
+ def customize( self, mb ):
+ pass
+
+ def test(self):
+ self.module_ref.init()
+ self.failUnless( self.module_ref.j.value == 87 )
+ self.failUnless( self.module_ref.data.i == 1900 )
+ self.failUnless( self.module_ref.data_ptr.contents.i == 11 )
+
+ self.module_ref.j.value = 78
+ self.failUnless( self.module_ref.get_value_j() == 78 )
+
+ self.module_ref.data.i = 987
+ self.failUnless( self.module_ref.get_value_data() == 987 )
+
+ self.module_ref.data_ptr.contents.i = 34
+ self.failUnless( self.module_ref.get_value_data_p() == 34 )
+
+
+class varargs_tester_t( ctypes_base_tester_t ):
+ def __init__( self, *args, **keywd ):
+ ctypes_base_tester_t.__init__( self, 'varargs', *args, **keywd )
+
+ def customize( self, mb ):
+ pass
+
+ def test(self):
+ self.failUnless( 21 == self.module_ref.sum_ints( 3, 5,7,9) )
+
+def create_suite():
+ suite = unittest.TestSuite()
+ #~ if 'win' in sys.platform:
+ #~ suite.addTest( unittest.makeSuite(pof_tester_t))
+ #~ suite.addTest( unittest.makeSuite(issues_tester_t))
+ suite.addTest( unittest.makeSuite(enums_tester_t))
+ suite.addTest( unittest.makeSuite(opaque_tester_t))
+ suite.addTest( unittest.makeSuite(include_algorithm_tester_t))
+ suite.addTest( unittest.makeSuite(anonymous_tester_t))
+ suite.addTest( unittest.makeSuite(variables_tester_t))
+ suite.addTest( unittest.makeSuite(varargs_tester_t))
+ return suite
+
+def run_suite():
+ unittest.TextTestRunner(verbosity=2).run( create_suite() )
+
+if __name__ == "__main__":
+ run_suite()
Modified: pyplusplus_dev/unittests/test_all.py
===================================================================
--- pyplusplus_dev/unittests/test_all.py 2009-01-20 07:53:01 UTC (rev 1601)
+++ pyplusplus_dev/unittests/test_all.py 2009-01-20 07:55:16 UTC (rev 1602)
@@ -111,7 +111,7 @@
import cp_return_addressof_tester
import make_constructor_tester
import return_auto_ptr_tester
-import ctypes_pof_tester
+import ctypes_tester
import refee_refer_tester
#import ogre_generate_tester
@@ -211,7 +211,7 @@
, make_constructor_tester
, return_auto_ptr_tester
, protected_bug_tester
- , ctypes_pof_tester
+ , ctypes_tester
, refee_refer_tester
# , ogre_generate_tester too much time
]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-20 07:53:05
|
Revision: 1601
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1601&view=rev
Author: roman_yakovenko
Date: 2009-01-20 07:53:01 +0000 (Tue, 20 Jan 2009)
Log Message:
-----------
removing temp directory
Modified Paths:
--------------
pyplusplus_dev/unittests/autoconfig.py
Removed Paths:
-------------
pyplusplus_dev/unittests/temp/
Modified: pyplusplus_dev/unittests/autoconfig.py
===================================================================
--- pyplusplus_dev/unittests/autoconfig.py 2009-01-20 07:40:31 UTC (rev 1600)
+++ pyplusplus_dev/unittests/autoconfig.py 2009-01-20 07:53:01 UTC (rev 1601)
@@ -16,6 +16,9 @@
build_directory = os.path.join( this_module_dir_path, 'temp' )
build_dir = build_directory
+if not os.path.exists( build_dir ):
+ os.mkdir( build_dir )
+
sys.path.append( os.path.dirname( this_module_dir_path ) )
from environment import scons, boost, python, gccxml, indexing_suite
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-20 07:40:36
|
Revision: 1600
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1600&view=rev
Author: roman_yakovenko
Date: 2009-01-20 07:40:31 +0000 (Tue, 20 Jan 2009)
Log Message:
-----------
adding new unit test that checks code generation for references
Modified Paths:
--------------
pyplusplus_dev/unittests/test_all.py
Added Paths:
-----------
pyplusplus_dev/unittests/data/refee_refer_to_be_exported.hpp
pyplusplus_dev/unittests/refee_refer_tester.py
Added: pyplusplus_dev/unittests/data/refee_refer_to_be_exported.hpp
===================================================================
--- pyplusplus_dev/unittests/data/refee_refer_to_be_exported.hpp (rev 0)
+++ pyplusplus_dev/unittests/data/refee_refer_to_be_exported.hpp 2009-01-20 07:40:31 UTC (rev 1600)
@@ -0,0 +1,24 @@
+// Copyright 2004-2008 Roman Yakovenko.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef __refee_refer_to_be_exported_hpp__
+#define __refee_refer_to_be_exported_hpp__
+
+#include <memory>
+
+struct refee_t{
+ int i;
+};
+
+struct refer_t{
+ refee_t& refee;
+};
+
+inline std::auto_ptr<refer_t> make_refer(refee_t* refee){
+ refer_t tmp = { *refee };
+ return std::auto_ptr<refer_t>(new refer_t(tmp));
+}
+
+#endif//__refee_refer_to_be_exported_hpp__
Added: pyplusplus_dev/unittests/refee_refer_tester.py
===================================================================
--- pyplusplus_dev/unittests/refee_refer_tester.py (rev 0)
+++ pyplusplus_dev/unittests/refee_refer_tester.py 2009-01-20 07:40:31 UTC (rev 1600)
@@ -0,0 +1,37 @@
+# Copyright 2004-2008 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 pygccxml import declarations
+
+class tester_t(fundamental_tester_base.fundamental_tester_base_t):
+ EXTENSION_NAME = 'refee_refer'
+
+ def __init__( self, *args ):
+ fundamental_tester_base.fundamental_tester_base_t.__init__(
+ self
+ , tester_t.EXTENSION_NAME
+ , *args )
+
+ def run_tests(self, module):
+ refee = module.refee_t();
+ refee.i = 19888
+
+ refer = module.make_refer( refee )
+ self.failUnless( refer.get_refee().i == 19888 )
+
+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()
Modified: pyplusplus_dev/unittests/test_all.py
===================================================================
--- pyplusplus_dev/unittests/test_all.py 2009-01-20 06:16:27 UTC (rev 1599)
+++ pyplusplus_dev/unittests/test_all.py 2009-01-20 07:40:31 UTC (rev 1600)
@@ -112,6 +112,7 @@
import make_constructor_tester
import return_auto_ptr_tester
import ctypes_pof_tester
+import refee_refer_tester
#import ogre_generate_tester
testers = [
@@ -211,6 +212,7 @@
, return_auto_ptr_tester
, protected_bug_tester
, ctypes_pof_tester
+ , refee_refer_tester
# , ogre_generate_tester too much time
]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-20 06:16:38
|
Revision: 1599
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1599&view=rev
Author: roman_yakovenko
Date: 2009-01-20 06:16:27 +0000 (Tue, 20 Jan 2009)
Log Message:
-----------
improve unit tests - better tests of code repository functionality
Modified Paths:
--------------
pyplusplus_dev/unittests/test_all.py
Modified: pyplusplus_dev/unittests/test_all.py
===================================================================
--- pyplusplus_dev/unittests/test_all.py 2009-01-20 05:51:06 UTC (rev 1598)
+++ pyplusplus_dev/unittests/test_all.py 2009-01-20 06:16:27 UTC (rev 1599)
@@ -7,6 +7,7 @@
import re
import sys
import time
+import shutil
import autoconfig
@@ -311,7 +312,8 @@
for index, tester in enumerate( self.__m_runners ):
print '\n\n{[<@>]}running tests complition: %d%%' % int( index * 100.0 // len(self.__m_runners) )
print '--------------------------------^^^^^\n\n'
- ( index, len(self.__m_runners) )
+ if os.path.exists( os.path.join( autoconfig.build_directory, 'indexing_suite' ) ):
+ shutil.rmtree( os.path.join( autoconfig.build_directory, 'indexing_suite' ) )
tester()
self.__total_time = time.time() - start_time
self.__dump_statistics()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-20 05:51:10
|
Revision: 1598
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1598&view=rev
Author: roman_yakovenko
Date: 2009-01-20 05:51:06 +0000 (Tue, 20 Jan 2009)
Log Message:
-----------
adding missing dependency
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_repository/__init__.py
Modified: pyplusplus_dev/pyplusplus/code_repository/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/__init__.py 2009-01-20 05:47:57 UTC (rev 1597)
+++ pyplusplus_dev/pyplusplus/code_repository/__init__.py 2009-01-20 05:51:06 UTC (rev 1598)
@@ -42,5 +42,7 @@
result = indexing_suite.all[:]
del result[ indexing_suite.headers.index( fname ) ]
return result
+ elif fname == return_range.file_name:
+ return indexing_suite.all[:]
else:
return []
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-20 05:48:07
|
Revision: 1597
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1597&view=rev
Author: roman_yakovenko
Date: 2009-01-20 05:47:57 +0000 (Tue, 20 Jan 2009)
Log Message:
-----------
fixing small bug, reported by Maik
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2009-01-19 22:15:33 UTC (rev 1596)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2009-01-20 05:47:57 UTC (rev 1597)
@@ -207,7 +207,7 @@
class constructor.
"""
if isinstance( f, declarations.calldef_t ):
- self._fake_constructors.add( f )
+ self._fake_constructors.append( f )
else:
self._fake_constructors.extend( f )
@@ -299,7 +299,7 @@
if c:
return c.body
else:
- return ''
+ return ''
def _set_null_constructor_body(self, body):
c = self.find_trivial_constructor()
if c:
@@ -312,7 +312,7 @@
if c:
return c.body
else:
- return ''
+ return ''
def _set_copy_constructor_body(self, body):
c = self.find_copy_constructor()
@@ -702,16 +702,16 @@
#select all public constructors and exclude copy constructor
cs = self.constructors( lambda c: not c.is_copy_constructor and c.access_type == 'public'
, recursive=False, allow_empty=True )
-
+
has_suitable_constructor = bool( cs )
if cs and len(cs) == 1 and cs[0].is_trivial_constructor and self.find_noncopyable_vars():
has_suitable_constructor = False
-
+
has_nonpublic_destructor = declarations.has_destructor( self ) \
and not declarations.has_public_destructor( self )
-
+
trivial_constructor = self.find_trivial_constructor()
-
+
if has_nonpublic_destructor \
or ( self.is_abstract and not self.is_wrapper_needed() ) \
or not has_suitable_constructor:
@@ -728,6 +728,6 @@
return self._no_init
def _set_no_init( self, value ):
self._no_init = value
-
+
no_init = property( _get_no_init, _set_no_init
, doc="If True, class will be registered with 'boost::python::no_init'" )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-19 22:29:18
|
Revision: 1596
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1596&view=rev
Author: roman_yakovenko
Date: 2009-01-19 22:15:33 +0000 (Mon, 19 Jan 2009)
Log Message:
-----------
embedding indexing suite into Py++
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/file_writers/writer.py
pyplusplus_dev/unittests/autoconfig.py
Modified: pyplusplus_dev/pyplusplus/file_writers/writer.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/writer.py 2009-01-19 21:57:33 UTC (rev 1595)
+++ pyplusplus_dev/pyplusplus/file_writers/writer.py 2009-01-19 22:15:33 UTC (rev 1596)
@@ -36,6 +36,11 @@
self.__exposed_decls_db.register_decls( extmodule.global_ns
, extmodule.specially_exposed_decls )
+ def makedirs_for_file( self, file_path ):
+ destination_dir = os.path.dirname( file_path )
+ if not os.path.exists( destination_dir ):
+ os.makedirs( destination_dir )
+
@property
def encoding( self ):
"""encoding name used to write generated code to files"""
@@ -75,12 +80,16 @@
if cr.file_name in visited:
continue
- self.write_file( os.path.join( dir, cr.file_name ), cr.code )
+ destination_path = os.path.normpath( os.path.join( dir, cr.file_name ) )
+ self.makedirs_for_file( destination_path )
+ self.write_file( destination_path, cr.code )
visited.add( cr.file_name )
for fdepend in code_repository.i_depend_on_them( cr.file_name ):
if fdepend.file_name not in visited:
- self.write_file( os.path.join( dir, fdepend.file_name ), fdepend.code )
+ destination_path = os.path.normpath( os.path.join( dir, fdepend.file_name ) )
+ self.makedirs_for_file( destination_path )
+ self.write_file( destination_path, fdepend.code )
visited.add( fdepend.file_name )
@staticmethod
Modified: pyplusplus_dev/unittests/autoconfig.py
===================================================================
--- pyplusplus_dev/unittests/autoconfig.py 2009-01-19 21:57:33 UTC (rev 1595)
+++ pyplusplus_dev/unittests/autoconfig.py 2009-01-19 22:15:33 UTC (rev 1596)
@@ -41,7 +41,7 @@
class scons_config:
libs = []
libpath = [ python.libs ] + boost.libs
- cpppath = [ boost.include, python.include, indexing_suite.include ]
+ cpppath = [ boost.include, python.include, build_directory ] #indexing_suite.include ]
include_dirs = cpppath + [data_directory]
@staticmethod
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-19 22:29:18
|
Revision: 1594
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1594&view=rev
Author: roman_yakovenko
Date: 2009-01-19 21:55:39 +0000 (Mon, 19 Jan 2009)
Log Message:
-----------
small refactoring, which improves code repository files handling
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/code_creator.py
Modified: pyplusplus_dev/pyplusplus/code_creators/code_creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2009-01-19 20:27:59 UTC (rev 1593)
+++ pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2009-01-19 21:55:39 UTC (rev 1594)
@@ -138,7 +138,8 @@
if language == 'python':
selector = lambda f: os.path.splitext( f )[1] in ( '.py' )
elif language == 'c++':
- selector = lambda f: os.path.splitext( f )[1] in ( '.h', '.hpp', '.cpp' )
+ selector = lambda f: ( f.startswith( '<' ) and f.endswith('>') ) \
+ or os.path.splitext( f )[1] in ( '.h', '.hpp', '.cpp' )
else:
selector = None
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-19 22:29:16
|
Revision: 1595
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1595&view=rev
Author: roman_yakovenko
Date: 2009-01-19 21:57:33 +0000 (Mon, 19 Jan 2009)
Log Message:
-----------
embedding indexing suite v2
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_repository/__init__.py
pyplusplus_dev/pyplusplus/file_writers/writer.py
Added Paths:
-----------
pyplusplus_dev/indexing_suite_v2/update_code_repository.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/__init__.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/algorithms_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/container_proxy_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/container_suite_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/container_traits_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/deque_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/element_proxy_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/element_proxy_traits_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/int_slice_helper_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/iterator_range_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/iterator_traits_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/list_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/map_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/methods_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/multimap_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/pair_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/proxy_iterator_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/python_iterator_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/set_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/shared_proxy_impl_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/slice_handler_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/slice_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/suite_utils_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/value_traits_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/vector_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/visitor_header.py
pyplusplus_dev/pyplusplus/code_repository/indexing_suite/workaround_header.py
Added: pyplusplus_dev/indexing_suite_v2/update_code_repository.py
===================================================================
--- pyplusplus_dev/indexing_suite_v2/update_code_repository.py (rev 0)
+++ pyplusplus_dev/indexing_suite_v2/update_code_repository.py 2009-01-19 21:57:33 UTC (rev 1595)
@@ -0,0 +1,79 @@
+# Copyright 2004-2008 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)
+
+"""updates code repository"""
+
+import os
+import sys
+
+header_tmpl = \
+'''# Copyright 2004-2008 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+"""
+This file contains indexing suite v2 code
+"""
+
+file_name = "%(file_path)s"
+
+code = \
+"""%(code)s
+
+"""
+'''
+
+init_code = [
+'''# Copyright 2004-2008 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)
+
+"""
+code repository for Indexing Suite V2 - std containers wrappers
+"""
+
+all = []
+''']
+
+pyplusplus_dev_root = os.path.dirname( os.path.dirname( os.path.abspath( __file__ ) ) )
+source_dir = os.path.join( pyplusplus_dev_root, 'indexing_suite_v2', 'indexing_suite' )
+target_dir = os.path.join( pyplusplus_dev_root, 'pyplusplus', 'code_repository', 'indexing_suite' )
+
+if not os.path.exists( target_dir ):
+ os.mkdir( target_dir )
+
+for f in os.listdir( source_dir ):
+ name, ext = os.path.splitext( f )
+ if ext != '.hpp':
+ print 'file "%s" was skipped' % f
+ continue
+ else:
+ print 'converting file "%s"' % f
+ file_path = 'indexing_suite/' + f
+ code = file( os.path.join( source_dir, f ), 'r' ).read()
+ py_name = name + '_header'
+ py_file = file( os.path.join( target_dir, py_name + '.py' ), 'w+' )
+ py_file.write( header_tmpl % dict( file_path=file_path, code=code ) )
+ py_file.close()
+ init_code.append( 'import %s' % py_name )
+ init_code.append( 'all.append( %s )' % py_name )
+ init_code.append( '' )
+
+init_code.append( 'headers = map( lambda f: f.file_name, all )' )
+
+print 'creating __init__.py file'
+
+init_file = file( os.path.join( target_dir, '__init__.py' ), 'w+' )
+init_file.write( '\n'.join( init_code ) )
+init_file.close()
+
+
+
+
+
+
+
Modified: pyplusplus_dev/pyplusplus/code_repository/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/__init__.py 2009-01-19 21:55:39 UTC (rev 1594)
+++ pyplusplus_dev/pyplusplus/code_repository/__init__.py 2009-01-19 21:57:33 UTC (rev 1595)
@@ -18,8 +18,9 @@
import named_tuple
import convenience
import return_range
+import ctypes_utils
import call_policies
-import ctypes_utils
+import indexing_suite
import ctypes_integration
all = [ array_1
@@ -31,5 +32,15 @@
, ctypes_utils
, ctypes_integration ]
+all.extend( indexing_suite.all )
+
headers = map( lambda f: f.file_name, all )
+def i_depend_on_them( fname ):
+ """returns list of files, the file fname depends on"""
+ if fname in indexing_suite.headers:
+ result = indexing_suite.all[:]
+ del result[ indexing_suite.headers.index( fname ) ]
+ return result
+ else:
+ return []
Added: pyplusplus_dev/pyplusplus/code_repository/indexing_suite/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/indexing_suite/__init__.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_repository/indexing_suite/__init__.py 2009-01-19 21:57:33 UTC (rev 1595)
@@ -0,0 +1,91 @@
+# Copyright 2004-2008 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)
+
+"""
+code repository for Indexing Suite V2 - std containers wrappers
+"""
+
+all = []
+
+import algorithms_header
+all.append( algorithms_header )
+
+import container_proxy_header
+all.append( container_proxy_header )
+
+import container_suite_header
+all.append( container_suite_header )
+
+import container_traits_header
+all.append( container_traits_header )
+
+import deque_header
+all.append( deque_header )
+
+import element_proxy_header
+all.append( element_proxy_header )
+
+import element_proxy_traits_header
+all.append( element_proxy_traits_header )
+
+import int_slice_helper_header
+all.append( int_slice_helper_header )
+
+import iterator_range_header
+all.append( iterator_range_header )
+
+import iterator_traits_header
+all.append( iterator_traits_header )
+
+import list_header
+all.append( list_header )
+
+import map_header
+all.append( map_header )
+
+import methods_header
+all.append( methods_header )
+
+import multimap_header
+all.append( multimap_header )
+
+import pair_header
+all.append( pair_header )
+
+import proxy_iterator_header
+all.append( proxy_iterator_header )
+
+import python_iterator_header
+all.append( python_iterator_header )
+
+import set_header
+all.append( set_header )
+
+import shared_proxy_impl_header
+all.append( shared_proxy_impl_header )
+
+import slice_header
+all.append( slice_header )
+
+import slice_handler_header
+all.append( slice_handler_header )
+
+import suite_utils_header
+all.append( suite_utils_header )
+
+import value_traits_header
+all.append( value_traits_header )
+
+import vector_header
+all.append( vector_header )
+
+import visitor_header
+all.append( visitor_header )
+
+import workaround_header
+all.append( workaround_header )
+
+headers = map( lambda f: f.file_name, all )
+
Added: pyplusplus_dev/pyplusplus/code_repository/indexing_suite/algorithms_header.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/indexing_suite/algorithms_header.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_repository/indexing_suite/algorithms_header.py 2009-01-19 21:57:33 UTC (rev 1595)
@@ -0,0 +1,578 @@
+# Copyright 2004-2008 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+"""
+This file contains indexing suite v2 code
+"""
+
+file_name = "indexing_suite/algorithms.hpp"
+
+code = """// Header file algorithms.hpp
+//
+// Uniform interface layer for all containers.
+//
+// Copyright (c) 2003 Raoul M. Gough
+//
+// Use, modification and distribution is subject to 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)
+//
+// History
+// =======
+// 2003/ 9/11 rmg File creation from suite_utils.hpp
+// 2003/10/28 rmg Split container-specific versions into separate headers
+// 2006/10/25 Roman Adding keys function to assoc_algorithms class
+// 2008/12/08 Roman Change indexing suite layout
+//
+// $Id: algorithms.hpp,v 1.1.2.15 2004/02/08 18:57:42 raoulgough Exp $
+//
+
+#ifndef BOOST_PYTHON_INDEXING_ALGORITHMS_HPP
+#define BOOST_PYTHON_INDEXING_ALGORITHMS_HPP
+
+#include <indexing_suite/suite_utils.hpp>
+
+#include <boost/type_traits.hpp>
+#include <boost/python/errors.hpp>
+#include <indexing_suite/int_slice_helper.hpp>
+#include <indexing_suite/slice.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/limits.hpp>
+#include <algorithm>
+#include <functional>
+#include <stdexcept>
+#include <string>
+#include <set>
+
+namespace boost { namespace python { namespace indexing {
+ template<typename ContainerTraits, typename Ovr = detail::no_override>
+ class default_algorithms
+ {
+ typedef default_algorithms<ContainerTraits, Ovr> self_type;
+ typedef typename detail::maybe_override<self_type, Ovr>
+ ::type most_derived;
+
+ public:
+ typedef ContainerTraits container_traits;
+
+ // Import typedefs from the container_traits for convenience
+ typedef typename ContainerTraits::container container;
+ typedef typename ContainerTraits::iterator iterator;
+ typedef typename ContainerTraits::reference reference;
+ typedef typename ContainerTraits::size_type size_type;
+ typedef typename ContainerTraits::value_type value_type;
+ typedef typename ContainerTraits::value_param value_param;
+ typedef typename ContainerTraits::index_param index_param;
+ typedef typename ContainerTraits::key_param key_param;
+
+ // Defer selection of supported_methods to the ContainerTraits
+ // template argument. This makes sense because default_algorithms
+ // derives all of its other information from this argument, and
+ // can't decide which of the static member functions will
+ // instantiate successfully for the container. Obviously a
+ // custom-written Algorithms implementation could choose to
+ // provide the supported_methods directly.
+
+ BOOST_STATIC_CONSTANT(
+ method_set_type,
+ supported_methods = ContainerTraits::supported_methods);
+
+ static size_type size (container &);
+ static iterator find (container &, key_param);
+ static size_type get_index (container &, key_param);
+ static size_type count (container &, key_param);
+ static bool contains (container &, key_param);
+ static void reverse (container &);
+ static reference get (container &, index_param);
+ static void assign (container &, index_param, value_param);
+ static void insert (container &, index_param, value_param);
+ static void erase_one (container &, index_param);
+ static void erase_range(container &, index_param, index_param);
+ static void push_back (container &, value_param);
+ static void sort (container &);
+ // static void sort (container &, PyObject *);
+
+ static iterator begin (container &c) { return c.begin(); }
+ static iterator end (container &c) { return c.end(); }
+
+ // Reasonable defaults for slice handling
+ typedef int_slice_helper<self_type, integer_slice> slice_helper;
+
+ static slice_helper make_slice_helper (container &c, slice const &);
+
+ // Default visit_container_class
+ template<typename PythonClass, typename Policy>
+ static void visit_container_class(
+ PythonClass &pyClass, Policy const &policy)
+ {
+ container_traits::visit_container_class (pyClass, policy);
+ }
+
+#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
+ // MSVC6 and 7.0 seem to complain about most_derived::bounds_check
+ // for an instantiation of list_algorithms.
+ public:
+#else
+ private:
+#endif
+ static size_type bounds_check(
+ container &, index_param, char const *msg,
+ bool one_past = false,
+ bool truncate = false);
+ // Throws std::out_of_range if necessary. If one_past is set, then
+ // indexes up to container.size() *inclusive* are allowed. If
+ // truncate is set, then out of bounds values are reset to the
+ // nearest in-bound value (and if none exists, throws an
+ // exception). If truncate is *not* set, then negative values index
+ // from the upper bound backwards and are bounds-checked.
+ };
+
+ /////////////////////////////////////////////////////////////////////////
+ // Base class for associative containers
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr = detail::no_override>
+ class assoc_algorithms
+ : public default_algorithms
+ <ContainerTraits,
+ BOOST_DEDUCED_TYPENAME detail::maybe_override
+ <assoc_algorithms<ContainerTraits, Ovr>, Ovr>
+ ::type>
+ {
+ typedef assoc_algorithms<ContainerTraits, Ovr> self_type;
+ typedef typename detail::maybe_override<self_type, Ovr>
+ ::type most_derived;
+ typedef default_algorithms<ContainerTraits, most_derived> Parent;
+
+ public:
+ typedef typename Parent::iterator iterator;
+ typedef typename Parent::size_type size_type;
+ typedef typename Parent::container container;
+ typedef typename Parent::reference reference;
+ typedef typename Parent::key_param key_param;
+ typedef typename Parent::value_param value_param;
+ typedef typename Parent::index_param index_param;
+
+ static reference get (container &, index_param);
+
+ // Use member functions for the following (hiding base class versions)
+ static void erase_one (container &, key_param);
+ static iterator find (container &, key_param);
+ static size_type count (container &, key_param);
+ static bool contains (container &, key_param);
+
+ // Default visit_container_class
+ template<typename PythonClass, typename Policy>
+ static void visit_container_class( PythonClass &pyClass, Policy const &policy)
+ {
+ ContainerTraits::visit_container_class (pyClass, policy);
+ }
+
+
+ protected:
+ static iterator find_or_throw (container &, index_param);
+ };
+
+ /////////////////////////////////////////////////////////////////////////
+ // Get the size of a container
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ BOOST_DEDUCED_TYPENAME default_algorithms<ContainerTraits, Ovr>::size_type
+ default_algorithms<ContainerTraits, Ovr>::size (container &c)
+ {
+ return c.size();
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Range check an index and throw out_of_range if necessary
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ BOOST_DEDUCED_TYPENAME default_algorithms<ContainerTraits, Ovr>::size_type
+ default_algorithms<ContainerTraits, Ovr>::bounds_check(
+ container &c,
+ index_param ix,
+ char const *msg,
+ bool one_past,
+ bool truncate)
+ {
+ size_type bound = most_derived::size(c) + (one_past ? 1 : 0);
+ size_type result;
+
+ if (truncate)
+ {
+ if (ix < 0)
+ {
+ result = 0;
+ }
+
+ else
+ {
+ result = ix;
+
+ if ((result >= bound) && (bound > 0))
+ {
+ result = bound - 1;
+ }
+ }
+ }
+
+ else if (ix < 0)
+ {
+ if (size_type(-ix) > bound)
+ {
+ throw std::out_of_range (msg);
+ }
+
+ result = bound + ix;
+ }
+
+ else
+ {
+ result = ix;
+ }
+
+ if (result >= bound)
+ {
+ throw std::out_of_range (msg);
+ }
+
+ return result;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Find an element in a container (std algorithm version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ BOOST_DEDUCED_TYPENAME default_algorithms<ContainerTraits, Ovr>::iterator
+ default_algorithms<ContainerTraits, Ovr>::find(
+ container &c, key_param key)
+ {
+ typedef typename container_traits::value_traits_type vtraits;
+ typedef typename vtraits::equal_to comparison;
+
+ return std::find_if(
+ most_derived::begin(c),
+ most_derived::end(c),
+ std::bind1st (comparison(), key));
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Find an element and return its index (std algorithm version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ BOOST_DEDUCED_TYPENAME default_algorithms<ContainerTraits, Ovr>::size_type
+ default_algorithms<ContainerTraits, Ovr>::get_index(
+ container &c, key_param key)
+ {
+ iterator found (most_derived::find (c, key));
+
+ if (found == most_derived::end(c))
+ {
+ PyErr_SetString(
+ PyExc_ValueError, "get_index: element not found");
+
+ boost::python::throw_error_already_set ();
+ }
+
+ iterator start (most_derived::begin (c));
+ return std::distance (start, found);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Count occurances of an element in a container (std algorithm version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ BOOST_DEDUCED_TYPENAME default_algorithms<ContainerTraits, Ovr>::size_type
+ default_algorithms<ContainerTraits, Ovr>::count(
+ container &c, key_param key)
+ {
+ typedef typename container_traits::value_traits_type vtraits;
+ typedef typename vtraits::equal_to comparison;
+
+ return std::count_if(
+ most_derived::begin(c),
+ most_derived::end(c),
+ std::bind1st (comparison(), key));
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Check whether a container contains the given element (std algo ver)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ bool
+ default_algorithms<ContainerTraits, Ovr>::contains(
+ container &c, key_param key)
+ {
+ return most_derived::find (c, key) != most_derived::end(c);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Index into a container (generic version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ BOOST_DEDUCED_TYPENAME default_algorithms<ContainerTraits, Ovr>::reference
+ default_algorithms<ContainerTraits, Ovr>::get(
+ container &c, index_param ix)
+ {
+ return c[most_derived::bounds_check (c, ix, "get")];
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Assign a value at a particular index (generic version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ void
+ default_algorithms<ContainerTraits, Ovr>::assign(
+ container &c, index_param ix, value_param val)
+ {
+ c[most_derived::bounds_check (c, ix, "assign")] = val;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Insert at end of a container (generic version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ void
+ default_algorithms<ContainerTraits, Ovr>::push_back(
+ container &c, value_param v)
+ {
+ c.push_back (v);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Insert at an index in the container (generic version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ void
+ default_algorithms<ContainerTraits, Ovr>::insert(
+ container &c, index_param i, value_param v)
+ {
+ iterator insert_pos (most_derived::begin(c));
+
+ // Index may range up to c.size() inclusive to allow inserting at end
+ std::advance(
+ insert_pos, most_derived::bounds_check (c, i, "insert", true, true));
+
+ c.insert (insert_pos, v);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Erase between given indexes in the container (generic version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ void
+ default_algorithms<ContainerTraits, Ovr>::erase_range(
+ container &c, index_param from, index_param to)
+ {
+ iterator start (most_derived::begin(c));
+ iterator finish (most_derived::begin(c));
+
+ // Start index must be properly in bounds
+ std::advance
+ (start, most_derived::bounds_check (c, from, "erase_range (from)"));
+
+ // End index is one-past-the-end, so may range up to c.size() inclusive
+ std::advance
+ (finish, most_derived::bounds_check (c, to, "erase_range (to)", true));
+
+ c.erase (start, finish);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Erase one element at the given index in the container (generic version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ void
+ default_algorithms<ContainerTraits, Ovr>::erase_one(
+ container &c, index_param ix)
+ {
+ iterator iter (most_derived::begin(c));
+ std::advance (iter, most_derived::bounds_check (c, ix, "erase_one"));
+ c.erase (iter);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Reverse the contents of a container (std algorithm version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ void default_algorithms<ContainerTraits, Ovr>::reverse (container &c)
+ {
+ std::reverse (most_derived::begin(c), most_derived::end(c));
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Sort the contents of a container (std algorithm version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ void default_algorithms<ContainerTraits, Ovr>::sort (container &c)
+ {
+ typedef typename container_traits::value_traits_type vtraits;
+ typedef typename vtraits::less comparison;
+ std::sort (most_derived::begin(c), most_derived::end(c), comparison());
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // slice_helper factory function (default version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ BOOST_DEDUCED_TYPENAME default_algorithms<ContainerTraits, Ovr>::slice_helper
+ default_algorithms<ContainerTraits, Ovr>
+ ::make_slice_helper (container &c, slice const &sl)
+ {
+ return slice_helper (c, integer_slice (sl, most_derived::size (c)));
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Index into a container (associative version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ BOOST_DEDUCED_TYPENAME assoc_algorithms<ContainerTraits, Ovr>::reference
+ assoc_algorithms<ContainerTraits, Ovr>::get (container &c, index_param ix)
+ {
+ return *most_derived::find_or_throw (c, ix);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Erase elements with the given key (associative version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ void
+ assoc_algorithms<ContainerTraits, Ovr>::erase_one(
+ container &c, key_param key)
+ {
+ if (c.erase (key) == 0)
+ {
+ PyErr_SetString(
+ PyExc_ValueError, "Container does not hold value to be erased");
+
+ boost::python::throw_error_already_set ();
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Find an element in an associative container
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ BOOST_DEDUCED_TYPENAME assoc_algorithms<ContainerTraits, Ovr>::iterator
+ assoc_algorithms<ContainerTraits, Ovr>
+ ::find (container &c, key_param key)
+ {
+ return c.find (key);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Find an element in an associative container
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ bool
+ assoc_algorithms<ContainerTraits, Ovr>::contains(
+ container &c, key_param key)
+ {
+ return most_derived::find (c, key) != most_derived::end(c);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Find an element in an associative container - throw an exception if
+ // not found
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ BOOST_DEDUCED_TYPENAME assoc_algorithms<ContainerTraits, Ovr>::iterator
+ assoc_algorithms<ContainerTraits, Ovr>::find_or_throw(
+ container &c, index_param ix)
+ {
+ iterator iter = most_derived::find (c, ix);
+
+ if (iter == most_derived::end(c))
+ {
+ PyErr_SetString(
+ PyExc_ValueError, "associative container: key not found");
+
+ boost::python::throw_error_already_set ();
+ }
+
+ return iter;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Count occurances of an element in a container (associative version)
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename ContainerTraits, typename Ovr>
+ BOOST_DEDUCED_TYPENAME assoc_algorithms<ContainerTraits, Ovr>::size_type
+ assoc_algorithms<ContainerTraits, Ovr>::count(
+ container &c, key_param key)
+ {
+ return c.count (key);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Some meta-information to select algorithms for const and
+ // non-const qualified containers. All algorithms_selector specializations
+ // include two publically accessible typedefs, called
+ // mutable_algorithms and const_algorithms. This saves having to
+ // have separate partial specializations of algorithms for
+ // const and non-const containers. Client code should probably
+ // specialize algorithms directly.
+ /////////////////////////////////////////////////////////////////////////
+
+ namespace detail {
+ template<typename Container> class algorithms_selector
+# if defined(BOOST_MPL_MSVC_ETI_BUG)
+ {
+ // Bogus types to prevent compile errors due to ETI
+ typedef algorithms_selector<Container> mutable_algorithms;
+ typedef algorithms_selector<Container> const_algorithms;
+ }
+# endif
+ ;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Algorithms selection for mutable containers
+ /////////////////////////////////////////////////////////////////////////
+
+ template<class Container>
+ struct algorithms
+ : public detail::algorithms_selector<Container>::mutable_algorithms
+ {
+ };
+
+# if !defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
+ /////////////////////////////////////////////////////////////////////////
+ // Algorithms selection for const-qualified containers
+ /////////////////////////////////////////////////////////////////////////
+
+ template<class Container>
+ struct algorithms<Container const>
+ : public detail::algorithms_selector<Container>::const_algorithms
+ {
+ };
+# endif
+} } }
+
+#endif // BOOST_PYTHON_INDEXING_ALGORITHMS_HPP
+
+
+"""
Added: pyplusplus_dev/pyplusplus/code_repository/indexing_suite/container_proxy_header.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/indexing_suite/container_proxy_header.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_repository/indexing_suite/container_proxy_header.py 2009-01-19 21:57:33 UTC (rev 1595)
@@ -0,0 +1,752 @@
+# Copyright 2004-2008 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+"""
+This file contains indexing suite v2 code
+"""
+
+file_name = "indexing_suite/container_proxy.hpp"
+
+code = """// Copyright (c) 2003 Raoul M. Gough
+//
+// Use, modification and distribution is subject to 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)
+//
+// Header file container_proxy.hpp
+//
+// A container-wrapper that provides Python-style reference semantics
+// for values stored in vector-like containers via element proxies.
+//
+// Class invariant:
+// size() == m_proxies.size()
+// for 0 <= i < size()
+// m_proxies[i].get() != 0
+// m_proxies[i]->owner() == this
+// m_proxies[i]->index() == i
+// m_proxies[i]->m_element_ptr.get() == 0
+//
+// History
+// =======
+// 2003/ 8/26 rmg File creation
+// 2003/10/23 rmg Change pointer container from map to sequence
+// 2008/12/08 Roman Change indexing suite layout
+//
+// $Id: container_proxy.hpp,v 1.1.2.28 2004/02/08 18:57:42 raoulgough Exp $
+//
+
+#ifndef BOOST_PYTHON_INDEXING_CONTAINER_PROXY_HPP
+#define BOOST_PYTHON_INDEXING_CONTAINER_PROXY_HPP
+
+#include <indexing_suite/proxy_iterator.hpp>
+#include <indexing_suite/shared_proxy_impl.hpp>
+#include <indexing_suite/element_proxy.hpp>
+#include <indexing_suite/element_proxy_traits.hpp>
+#include <indexing_suite/workaround.hpp>
+#include <indexing_suite/methods.hpp>
+
+#include <vector>
+#include <cassert>
+#include <boost/shared_ptr.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <indexing_suite/container_traits.hpp>
+#include <indexing_suite/container_suite.hpp>
+#include <indexing_suite/algorithms.hpp>
+
+namespace boost { namespace python { namespace indexing {
+
+ template<typename T> struct identity {
+ typedef T held_type;
+
+ static T & get(T & obj) { return obj; }
+ static T const & get(T const & obj) { return obj; }
+
+ static T create () { return T(); }
+ static T copy (T const ©) { return copy; }
+ static void assign (T &to, T const &from) { to = from; }
+ static void pre_destruction (T &) { }
+ static void swap (T &one, T &two) { std::swap (one, two); }
+ };
+
+ template<typename P> struct deref {
+ typedef P held_type;
+
+ typedef typename boost::iterator_value<P>::type value;
+
+ static value & get (P & ptr) { return *ptr; }
+ static value const & get (P const & ptr) { return *ptr; }
+
+ static P create () { return P(); }
+ static P copy (P const ©) { return copy; }
+ static void assign (P &to, P const &from) { to = from; }
+ static void pre_destruction (P &) { }
+ static void swap (P &one, P &two) { std::swap (one, two); }
+ };
+
+ struct vector_generator {
+ // Generates vector type for any element type with default allocator
+ template<typename Element> struct apply {
+ typedef std::vector<Element> type;
+ };
+ };
+
+#if BOOST_WORKAROUND (BOOST_MSVC, == 1200)
+ // Early template instantiation (ETI) workaround
+ namespace detail {
+ template<typename Container> struct msvc6_iterator {
+ typedef Container::iterator type;
+ };
+
+ template<> struct msvc6_iterator<int> {
+ typedef int *type;
+ };
+ }
+#endif
+
+ template<class Container,
+ class Holder = identity<Container>,
+ class Generator = vector_generator>
+ class container_proxy
+ {
+ typedef container_proxy<Container, Holder, Generator> self_type;
+ typedef typename Container::iterator raw_iterator;
+ typedef ::boost::detail::iterator_traits<raw_iterator> raw_iterator_traits;
+
+#if !defined (BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
+ template<class C> friend class shared_proxy_impl;
+ template<class C, typename E, typename T, typename S, typename I>
+ friend class proxy_iterator;
+#endif
+
+ public:
+ typedef typename Holder::held_type held_type;
+
+ typedef typename Container::size_type size_type;
+ typedef typename Container::difference_type difference_type;
+
+ typedef shared_proxy_impl<self_type> shared_proxy;
+
+ typedef typename Container::value_type raw_value_type;
+
+ typedef element_proxy<self_type> value_type;
+ typedef value_type reference; // Already has ref. semantics
+
+ typedef const_element_proxy<self_type> const_value_type;
+ typedef const_value_type const_reference; // Ref. semantics
+
+ typedef proxy_iterator <self_type, value_type, raw_iterator_traits,
+ size_type, raw_iterator> iterator;
+ typedef iterator const_iterator; // No const_iterator yet implemented
+
+ public:
+ // Constructors
+ template<typename Iter> container_proxy (Iter start, Iter finish)
+ // Define inline for MSVC6 compatibility
+ : m_held_obj (Holder::create()),
+ m_proxies ()
+ {
+ insert (begin(), start, finish);
+ }
+
+ container_proxy ();
+ explicit container_proxy (held_type const &h);
+
+ container_proxy (container_proxy const &);
+ container_proxy &operator= (container_proxy const &);
+ ~container_proxy ();
+
+ Container const &raw_container() const; // OK to expose const reference
+
+ reference at (size_type index);
+ const_reference at (size_type index) const;
+
+ reference operator[] (size_type index) { return at(index); }
+ const_reference operator[] (size_type index) const { return at(index); }
+
+ size_type size () const { return raw_container().size(); }
+ size_type capacity () const { return raw_container().capacity(); }
+ void reserve (size_type s);
+
+ public:
+ iterator begin() { return iterator (this, static_cast<size_type>(0)); }
+ iterator end() { return iterator (this, raw_container().size()); }
+
+ iterator erase (iterator);
+ iterator erase (iterator, iterator);
+ iterator insert (iterator, raw_value_type const &);
+
+ template<typename Iter> void insert (iterator iter, Iter from, Iter to)
+ // Define here for MSVC6 compatibility
+ {
+ // Forward insertion to the right overloaded version
+ typedef typename BOOST_ITERATOR_CATEGORY<Iter>::type category;
+ insert (iter, from, to, category());
+ }
+
+ void push_back (raw_value_type const ©) { insert (end(), copy); }
+
+ value_type pop_back () {
+ value_type result = at (size() - 1);
+ erase (end() - 1);
+ return result;
+ }
+
+ public:
+ // These functions are useful only when client code has direct
+ // non-const acccess to the raw container (e.g. via an indirect
+ // holder supplied to our constructor). Any code that directly
+ // modifies the contents of the raw container (by replacing,
+ // inserting or erasing elements) must notify the container_proxy.
+
+ void detach_proxy (size_type index);
+ void detach_proxies (size_type from, size_type to);
+ // Call before overwriting element(s) in the raw container
+
+ void prepare_erase (size_type from, size_type to);
+ // Call before erasing elements directly from the raw container
+
+ void notify_insertion (size_type from, size_type to);
+ // Call after inserting elements directly into the raw container
+
+ public:
+ // Convenient replacement of elements (automatic proxy detachment)
+ void replace (size_type index, raw_value_type const &);
+ // template<typename Iter> void replace (size_type index, Iter, Iter);
+
+ void swap_elements (size_type index1, size_type index2);
+
+ bool is_valid () const; // Check the class invariant (for testing purposes)
+
+ private:
+ // Overloads for insertions with/without useful std::distance
+ template<typename Iter>
+ void insert (iterator iter, Iter from, Iter to, std::forward_iterator_tag)
+ // Define here for MSVC6 compatibility
+ {
+ assert (iter.ptr == this);
+ size_type count = std::distance (from, to);
+
+ // Add empty proxy pointers for the new value(s) (could throw)
+ m_proxies.insert (m_proxies.begin() + iter.index, count, pointer_impl());
+
+ try
+ {
+ // Insert the new element(s) into the real container (could throw)
+ raw_container().insert(
+ raw_container().begin() + iter.index,
+ from,
+ to);
+
+ try
+ {
+ // Create new proxies for the new elements (could throw)
+ write_proxies (iter.index, iter.index + count);
+ }
+
+ catch (...)
+ {
+ raw_container().erase(
+ raw_container().begin() + iter.index,
+ raw_container().begin() + iter.index + count);
+
+ throw;
+ }
+ }
+
+ catch (...)
+ {
+ m_proxies.erase(
+ m_proxies.begin() + iter.index,
+ m_proxies.begin() + iter.index + count);
+
+ throw;
+ }
+
+ // Adjust any proxies after the inserted elements (nothrow)
+ adjust_proxies(
+ m_proxies.begin() + iter.index + count,
+ m_proxies.end(),
+ static_cast<difference_type> (count));
+ }
+
+ template<typename Iter>
+ void insert (iterator iter, Iter from, Iter to, std::input_iterator_tag)
+ // Define here for MSVC6 compatibility
+ {
+ // insert overload for iterators where we *can't* get distance()
+ // so just insert elements one at a time
+ while (from != to)
+ {
+ iter = insert (iter, *from++) + 1;
+ }
+ }
+
+ private:
+ typedef boost::shared_ptr<shared_proxy> pointer_impl;
+
+ typedef typename mpl::apply1<Generator, pointer_impl>::type
+ pointer_container;
+
+#if BOOST_WORKAROUND (BOOST_MSVC, == 1200)
+ typedef detail::msvc6_iterator<pointer_container>::type pointer_iterator;
+#else
+ typedef typename pointer_container::iterator pointer_iterator;
+#endif
+
+#if defined (BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
+ // Proxies need mutable access, and can't be friends with MSVC6
+ public:
+#endif
+ Container &raw_container();
+
+ private:
+ void adjust_proxies (pointer_iterator, pointer_iterator, difference_type);
+ void write_proxies (size_type, size_type);
+ bool clear_proxy (pointer_impl &); // detach and do not reset
+ void clear_proxies (size_type, size_type); // detach and do not reset
+ void claim_all_proxies (); // Makes all proxies point at this object
+
+ private:
+ held_type m_held_obj;
+ pointer_container m_proxies;
+ };
+
+ template<class Container, class Holder, class Generator>
+ container_proxy<Container, Holder, Generator>
+ ::container_proxy ()
+ : m_held_obj (Holder::create()),
+ m_proxies ()
+ {
+ // Container is empty - no further processing
+ }
+
+ template<class Container, class Holder, class Generator>
+ container_proxy<Container, Holder, Generator>
+ ::container_proxy (held_type const &held)
+ : m_held_obj (Holder::copy (held)),
+ m_proxies (size())
+ {
+ write_proxies (0, size());
+ }
+
+ template<class Container, class Holder, class Generator>
+ container_proxy<Container, Holder, Generator>
+ ::container_proxy (container_proxy const ©)
+ : m_held_obj (Holder::copy (copy.m_held_obj)),
+ m_proxies (size())
+ {
+ write_proxies (0, size()); // Create our own proxies for the copied values
+ }
+
+ template<class Container, class Holder, class Generator>
+ container_proxy<Container, Holder, Generator> &
+ container_proxy<Container, Holder, Generator>
+ ::operator= (container_proxy const ©)
+ {
+ container_proxy<Container, Holder, Generator> temp (copy);
+ // This could throw, but none of the remaining operations can
+
+ Holder::swap (m_held_obj, temp.m_held_obj);
+ std::swap (m_proxies, temp.m_proxies);
+
+ claim_all_proxies ();
+ temp.claim_all_proxies (); // Prepare for detach
+
+ return *this;
+ // temp destruction detaches any proxies that used to belong to us
+ }
+
+ template<class Container, class Holder, class Generator>
+ container_proxy<Container, Holder, Generator>
+ ::~container_proxy ()
+ {
+ // Copy original values into any proxies being shared by external pointers
+ clear_proxies (0, size());
+ Holder::pre_destruction (m_held_obj);
+ }
+
+ template<class Container, class Holder, class Generator>
+ Container &
+ container_proxy<Container, Holder, Generator>
+ ::raw_container ()
+ {
+ return Holder::get (m_held_obj);
+ }
+
+ template<class Container, class Holder, class Generator>
+ Container const &
+ container_proxy<Container, Holder, Generator>
+ ::raw_container () const
+ {
+ return Holder::get (m_held_obj);
+ }
+
+ template<class Container, class Holder, class Generator>
+ void container_proxy<Container, Holder, Generator>::reserve (size_type size)
+ {
+ raw_container().reserve (size);
+ m_proxies.reserve (size);
+ }
+
+ template<class Container, class Holder, class Generator>
+ BOOST_DEDUCED_TYPENAME container_proxy<Container, Holder, Generator>::reference
+ container_proxy<Container, Holder, Generator>
+ ::at (size_type index)
+ {
+ pointer_impl const &ptr = m_proxies.BOOST_PYTHON_INDEXING_AT (index);
+ assert (ptr->owner() == this);
+ assert (ptr->index() == index);
+ return reference (ptr);
+ }
+
+ template<class Container, class Holder, class Generator>
+ BOOST_DEDUCED_TYPENAME container_proxy<Container, Holder, Generator>::const_reference
+ container_proxy<Container, Holder, Generator>
+ ::at (size_type index) const
+ {
+ pointer_impl const &ptr = m_proxies.BOOST_PYTHON_INDEXING_AT (index);
+ assert (ptr->owner() == this);
+ assert (ptr->index() == index);
+ return const_reference (ptr);
+ }
+
+ template<class Container, class Holder, class Generator>
+ void
+ container_proxy<Container, Holder, Generator>
+ ::replace (size_type index, raw_value_type const ©)
+ {
+ detach_proxy (index);
+ raw_container().BOOST_PYTHON_INDEXING_AT (index) = copy;
+ write_proxies (index, index + 1);
+ }
+
+ template<class Container, class Holder, class Generator>
+ void
+ container_proxy<Container, Holder, Generator>
+ ::swap_elements (size_type index1, size_type index2)
+ {
+ pointer_impl &ptr1 = m_proxies[index1];
+ pointer_impl &ptr2 = m_proxies[index2];
+
+ assert (ptr1->owner() == this);
+ assert (ptr2->owner() == this);
+ assert (ptr1->index() == index1);
+ assert (ptr2->index() == index2);
+
+ // Swap produces the diagrammed transformation. Any external
+ // pointers that refer to proxy1 or proxy2 will end up still
+ // pointing to their original (now relocated) values.
+ //
+ // .. ptr1 .. ptr2 .. .. ptr1 .. ptr2 .. (m_proxies)
+ // | | \ /
+ // | | \/
+ // | | /\.
+ // V V / \.
+ // proxy1 proxy2 --> proxy1 proxy2
+ // | | \ /
+ // | | \/
+ // | | /\.
+ // V V / \.
+ // .. v1 ... v2 .. .. v2 .. v1 .. (raw_container)
+
+ std::swap (ptr1->m_index, ptr2->m_index);
+ std::swap (ptr1, ptr2);
+ std::swap (raw_container()[index1], raw_container()[index2]);
+
+ assert (m_proxies[index1]->index() == index1);
+ assert (m_proxies[index2]->index() == index2);
+ }
+
+ template<class Container, class Holder, class Generator>
+ BOOST_DEDUCED_TYPENAME container_proxy<Container, Holder, Generator>::iterator
+ container_proxy<Container, Holder, Generator>::erase (iterator iter)
+ {
+ return erase (iter, iter + 1);
+ }
+
+ template<class Container, class Holder, class Generator>
+ BOOST_DEDUCED_TYPENAME container_proxy<Container, Holder, Generator>::iterator
+ container_proxy<Container, Holder, Generator>::erase(
+ iterator from, iterator to)
+ {
+ assert (from.ptr == this);
+ assert (to.ptr == this);
+
+ // Detach and remove the proxies for the about-to-be-erased elements
+ prepare_erase (from.index, to.index);
+
+ // Erase the elements from the real container
+ raw_iterator result
+ = raw_container().erase(
+ raw_container().begin() + from.index,
+ raw_container().begin() + to.index);
+
+ return iterator (this, result);
+ }
+
+ template<class Container, class Holder, class Generator>
+ BOOST_DEDUCED_TYPENAME container_proxy<Container, Holder, Generator>::iterator
+ container_proxy<Container, Holder, Generator>::insert(
+ iterator iter, raw_value_type const ©)
+ {
+ // Use the iterator-based version by treating the value as an
+ // array of size one (see section 5.7/4 of the C++98 standard)
+ insert (iter, ©, (©) + 1, std::random_access_iterator_tag());
+
+ return iter;
+ }
+
+ template<class Container, class Holder, class Generator>
+ bool container_proxy<Container, Holder, Generator>::clear_proxy(
+ pointer_impl &ptr)
+ {
+ // Warning - this can break the class invariant. Use only when the
+ // pointer is about to be overwritten or removed from m_proxies
+
+ assert (ptr->owner() == this);
+
+ if (!ptr.unique())
+ {
+ ptr->detach (); // Cause proxy to copy element value
+ return true;
+ }
+
+ else
+ {
+ // If the pointer isn't shared, don't bother causing a copy of
+ // the container element, since the proxy is about to be
+ // deleted or reused.
+ return false;
+ }
+ }
+
+ template<class Container, class Holder, class Generator>
+ void container_proxy<Container, Holder, Generator>::clear_proxies(
+ size_type from_index, size_type to_index)
+ {
+ while (from_index != to_index)
+ {
+ clear_proxy (m_proxies[from_index]);
+ ++from_index;
+ }
+ }
+
+ template<class Container, class Holder, class Generator>
+ void container_proxy<Container, Holder, Generator>
+ ::detach_proxy (size_type index)
+ {
+ pointer_impl &ptr = m_proxies[index];
+
+ assert (ptr->index() == index);
+
+ if (clear_proxy (ptr))
+ {
+ // To maintain class invariant
+ ptr.reset (new shared_proxy (this, index));
+ }
+ }
+
+ template<class Container, class Holder, class Generator>
+ void container_proxy<Container, Holder, Generator>::detach_proxies(
+ size_type from_index, size_type to_index)
+ {
+ while (from_index != to_index)
+ {
+ detach_proxy (from_index);
+ ++from_index;
+ }
+ }
+
+ template<class Container, class Holder, class Generator>
+ void container_proxy<Container, Holder, Generator>
+ ::prepare_erase (size_type from_index, size_type to_index)
+ {
+ difference_type deleting = to_index - from_index;
+ pointer_iterator erase_begin = m_proxies.begin() + from_index;
+ pointer_iterator erase_end = m_proxies.begin() + to_index;
+
+ // Adjust the indexes of any trailing proxies
+ adjust_proxies (erase_end, m_proxies.end(), -deleting);
+
+ // Detach any proxies without updating our pointers to them
+ clear_proxies (from_index, to_index);
+
+ // Remove the pointers
+ m_proxies.erase (erase_begin, erase_end);
+ }
+
+ template<class Container, class Holder, class Generator>
+ void container_proxy<Container, Holder, Generator>::notify_insertion(
+ size_type from_index, size_type to_index)
+ {
+ size_type count = to_index - from_index;
+
+ m_proxies.insert(
+ m_proxies.begin() + from_index, count, pointer_impl());
+
+ try
+ {
+ write_proxies (from_index, to_index); // Could throw
+ }
+
+ catch (...)
+ {
+ m_proxies.erase(
+ m_proxies.begin() + from_index,
+ m_proxies.begin() + to_index);
+
+ throw;
+ }
+
+ // Adjust any proxies after the inserted elements (nothrow)
+ adjust_proxies(
+ m_proxies.begin() + to_index,
+ m_proxies.end(),
+ static_cast<difference_type> (count));
+ }
+
+ template<class Container, class Holder, class Generator>
+ void container_proxy<Container, Holder, Generator>::adjust_proxies(
+ pointer_iterator from,
+ pointer_iterator to,
+ difference_type offset)
+ {
+ while (from != to)
+ {
+ (*from)->m_index += offset;
+ ++from;
+ }
+ }
+
+ template<class Container, class Holder, class Generator>
+ void container_proxy<Container, Holder, Generator>::write_proxies(
+ size_type from, size_type to)
+ {
+ // (over)write proxy pointers in the given range. Re-uses existing
+ // shared_proxy objects where possible. Does not call detach_proxy
+ // since it is assumed that the original values could have already
+ // been modified and copying them now would be wrong.
+
+ while (from != to)
+ {
+ pointer_impl &ptr = m_proxies[from];
+
+ if ((ptr.get() == 0) || (!ptr.unique()))
+ {
+ // Either no proxy yet allocated here, or there is one
+ // but it is being shared by an external pointer.
+ ptr.reset (new shared_proxy (this, from));
+ }
+
+ else
+ {
+ // Re-use the existing object since we have the only pointer to it
+ assert (ptr->owner() == this);
+ ptr->m_index = from;
+ }
+
+ ++from;
+ }
+ }
+
+ template<class Container, class Holder, class Generator>
+ void container_proxy<Container, Holder, Generator>::claim_all_proxies ()
+ {
+ for (pointer_iterator iter = m_proxies.begin();
+ iter != m_proxies.end();
+ ++iter)
+ {
+ (*iter)->m_owner_ptr = this;
+ }
+ }
+
+ template<class Container, class Holder, class Generator>
+ bool container_proxy<Container, Holder, Generator>::is_valid () const
+ {
+ bool ok = size() == m_proxies.size(); // Sizes must match
+
+ for (size_type count = 0; ok && (count < size()); ++count)
+ {
+ pointer_impl const &ptr = m_proxies[count];
+
+ ok = ptr.get() && (ptr->owner() == this) && (ptr->index() == count)
+ && !ptr->m_element_ptr.get();
+ }
+
+ return ok;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // ContainerTraits implementation for container_proxy instances
+ /////////////////////////////////////////////////////////////////////////
+
+ template<typename Container>
+ struct container_proxy_traits : random_access_sequence_traits<Container>
+ {
+ typedef Container container;
+ typedef typename container::raw_value_type value_type; // insert, ...
+ typedef typename container::raw_value_type key_type; // find, count, ...
+ typedef typename container::reference reference; // return values
+
+ typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS <value_type>::param_type
+ value_param;
+ typedef typename BOOST_PYTHON_INDEXING_CALL_TRAITS <key_type>::param_type
+ key_param;
+
+#if defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
+ // value_traits for the reference type (i.e. our element_proxy
+ // instance) supplies a custom visit_container_class. Compilers
+ // without partial specialization need help here.
+
+ typedef element_proxy_traits<Container> value_traits_type;
+
+ // Hide base class visit_container_class, which would call the
+ // unspecialized value_traits version
+ template<typename PythonClass, typename Policy>
+ static void visit_container_class(
+ PythonClass &pyClass, Policy const &policy)
+ {
+ value_traits_type::visit_container_class (pyClass, policy);
+ }
+#endif
+ };
+
+#if !defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
+ namespace detail {
+ ///////////////////////////////////////////////////////////////////////
+ // algorithms support for container_proxy instances
+ ///////////////////////////////////////////////////////////////////////
+
+ template <typename RawContainer, typename Holder, typename Generator>
+ class algorithms_selector<container_proxy<RawContainer, Holder, Generator> >
+ {
+ typedef container_proxy<RawContainer, Holder, Generator> Container;
+
+ typedef container_proxy_traits<Container> mutable_traits;
+ typedef container_proxy_traits<Container const> const_traits;
+
+ public:
+ typedef default_algorithms<mutable_traits> mutable_algorithms;
+ typedef default_algorithms<const_traits> const_algorithms;
+ };
+ }
+#endif
+ template<
+ class Container,
+ method_set_type MethodMask = all_methods,
+ class Traits = container_proxy_traits<Container>
+ >
+ struct container_proxy_suite
+ : container_suite<Container, MethodMask, default_algorithms<Traits> >
+ {
+ };
+
+} } }
+
+#endif // BOOST_PYTHON_INDEXING_CONTAINER_PROXY_HPP
+
+
+"""
Added: pyplusplus_dev/pyplusplus/code_repository/indexing_suite/container_suite_header.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/indexing_suite/container_suite_header.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_repository/indexing_suite/container_suite_header.py 2009-01-19 21:57:33 UTC (rev 1595)
@@ -0,0 +1,68 @@
+# Copyright 2004-2008 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+"""
+This file contains indexing suite v2 code
+"""
+
+file_name = "indexing_suite/container_suite.hpp"
+
+code = """// Copyright (c) 2003 Raoul M. Gough
+//
+// Use, modification and distribution is subject to 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)
+//
+// Header file container_suite.hpp
+//
+// Top-level interface to the container suite.
+//
+// History
+// =======
+// 2003/ 8/23 rmg File creation
+// 2003/ 9/ 8 rmg Extracted trait facilities into container_traits.hpp
+// 2008/12/08 Roman Change indexing suite layout
+//
+// $Id: container_suite.hpp,v 1.1.2.7 2004/02/08 18:57:42 raoulgough Exp $
+//
+
+#ifndef BOOST_PYTHON_INDEXING_CONTAINER_SUITE_HPP
+#define BOOST_PYTHON_INDEXING_CONTAINER_SUITE_HPP
+
+#include <indexing_suite/methods.hpp>
+#include <indexing_suite/algorithms.hpp>
+#include <indexing_suite/visitor.hpp>
+
+#include <boost/python/return_by_value.hpp>
+#include <boost/python/return_value_policy.hpp>
+
+namespace boost { namespace python { namespace indexing {
+ typedef boost::python::return_value_policy<boost::python::return_by_value>
+ default_container_policies;
+
+ template<
+ class Container,
+ method_set_type MethodMask = all_methods, // All supported by algorithms
+ class Algorithms
+ = algorithms<Container>
+ >
+ struct container_suite
+ : public visitor<Algorithms, default_container_policies, MethodMask>
+ {
+ typedef Algorithms algorithms;
+
+ template<typename Policy>
+ static visitor<Algorithms, Policy, MethodMask>
+ with_policies (Policy const &policy)
+ {
+ return visitor <Algorithms, Policy, MethodMask> (policy);
+ }
+ };
+} } }
+
+#endif // BOOST_PYTHON_INDEXING_CONTAINER_SUITE_HPP
+
+
+"""
Added: pyplusplus_dev/pyplusplus/code_repository/indexing_suite/container_traits_header.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_repository/indexing_suite/container_traits_header.py (rev 0)
+++ pyplusplus_dev/pyplusplus/code_repository/indexing_suite/container_traits_header.py 2009-01-19 21:57:33 UTC (rev 1595)
@@ -0,0 +1,174 @@
+# Copyright 2004-2008 Roman Yakovenko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+"""
+This file contains indexing suite v2 code
+"""
+
+file_name = "indexing_suite/container_traits.hpp"
+
+code = """// Copyright (c) 2003 Raoul M. Gough
+//
+// Use, modification and distribution is subject to 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)
+//
+// Header file container_traits.hpp
+//
+// Traits information about entire containers for use in determining
+// what Python methods to provide.
+//
+// History
+// =======
+// 2003/ 8/23 rmg File creation as container_suite.hpp
+// 2003/ 9/ 8 rmg Renamed container_traits.hpp
+// 2003/10/28 rmg Split container-specific versions into separate headers
+// 2004/ 1/28 rmg Convert to bitset-based feature selection
+// 2008/12/08 Roman Change indexing suite layout
+//
+// $Id: container_traits.hpp,v 1.1.2.15 2004/02/08 18:57:42 raoulgough Exp $
+//
+
+#ifndef BOOST_PYTHON_INDEXING_CONTAINER_TRAITS_HPP
+#define BOOST_PYTHON_INDEXING_CONTAINER_TRAITS_HPP
+
+#include <indexing_suite/suite_utils.hpp>
+#include <indexing_suite/methods.hpp>
+#include <indexing_suite/value_traits.hpp>
+
+#include <boost/type_traits.hpp>
+#include <boost/call_traits.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits/ice.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+
+namespace boost { namespace python { namespace indexing {
+#if BOOST_WORKAROUND (BOOST_MSVC, <= 1200)
+ // MSVC6 has problems with get_signature if parameter types have
+ // top-level const qualification (e.g. int const). Unfortunately,
+ // this is exactly what happens with boost::call_traits, so we
+ // substitute a really dumb version of it instead.
+
+ template<typename T> struct broken_call_traits {
+ typedef T const & param_type;
+ };
+# define BOOST_PYTHON_INDEXING_CALL_TRAITS broken_cal...
[truncated message content] |
|
From: <rom...@us...> - 2009-01-19 20:28:09
|
Revision: 1593
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1593&view=rev
Author: roman_yakovenko
Date: 2009-01-19 20:27:59 +0000 (Mon, 19 Jan 2009)
Log Message:
-----------
small refactoring, which improves code repository files handling
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/compound.py
Modified: pyplusplus_dev/pyplusplus/code_creators/compound.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/compound.py 2009-01-19 20:13:07 UTC (rev 1592)
+++ pyplusplus_dev/pyplusplus/code_creators/compound.py 2009-01-19 20:27:59 UTC (rev 1593)
@@ -77,12 +77,12 @@
internals[index] = internals[index] + os.linesep
return os.linesep.join( internals )
- def get_system_files( self, recursive=False, unique=False ):
+ def get_system_files( self, recursive=False, unique=False, language='any' ):
files = [ "boost/python.hpp" ]
files.extend( self._get_system_files_impl() )
if recursive:
for creator in self._creators:
- files.extend( creator.get_system_files(recursive, unique=False) )
+ files.extend( creator.get_system_files(recursive, unique=False, language=language) )
files = filter( None, files )
if unique:
files = self.unique_headers( files )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-19 20:13:18
|
Revision: 1592
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1592&view=rev
Author: roman_yakovenko
Date: 2009-01-19 20:13:07 +0000 (Mon, 19 Jan 2009)
Log Message:
-----------
small refactoring, which improves code repository files handling
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/array_1_registrator.py
pyplusplus_dev/pyplusplus/code_creators/bookmark.py
pyplusplus_dev/pyplusplus/code_creators/calldef.py
pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py
pyplusplus_dev/pyplusplus/code_creators/class_declaration.py
pyplusplus_dev/pyplusplus/code_creators/class_introduction.py
pyplusplus_dev/pyplusplus/code_creators/code_creator.py
pyplusplus_dev/pyplusplus/code_creators/compound.py
pyplusplus_dev/pyplusplus/code_creators/ctypes_integration_creators.py
pyplusplus_dev/pyplusplus/code_creators/custom.py
pyplusplus_dev/pyplusplus/code_creators/embedded_code_repository.py
pyplusplus_dev/pyplusplus/code_creators/enum.py
pyplusplus_dev/pyplusplus/code_creators/exception_translator.py
pyplusplus_dev/pyplusplus/code_creators/fields_definition.py
pyplusplus_dev/pyplusplus/code_creators/function_definition.py
pyplusplus_dev/pyplusplus/code_creators/global_variable.py
pyplusplus_dev/pyplusplus/code_creators/import_.py
pyplusplus_dev/pyplusplus/code_creators/include.py
pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py
pyplusplus_dev/pyplusplus/code_creators/instruction.py
pyplusplus_dev/pyplusplus/code_creators/library_reference.py
pyplusplus_dev/pyplusplus/code_creators/license.py
pyplusplus_dev/pyplusplus/code_creators/mem_fun_introduction.py
pyplusplus_dev/pyplusplus/code_creators/member_variable.py
pyplusplus_dev/pyplusplus/code_creators/methods_definition.py
pyplusplus_dev/pyplusplus/code_creators/module.py
pyplusplus_dev/pyplusplus/code_creators/module_body.py
pyplusplus_dev/pyplusplus/code_creators/name_mappings.py
pyplusplus_dev/pyplusplus/code_creators/namespace.py
pyplusplus_dev/pyplusplus/code_creators/namespace_as_pyclass.py
pyplusplus_dev/pyplusplus/code_creators/opaque_type_registrator.py
pyplusplus_dev/pyplusplus/code_creators/properties.py
pyplusplus_dev/pyplusplus/code_creators/smart_pointers.py
pyplusplus_dev/pyplusplus/code_creators/typedef_as_pyvar.py
pyplusplus_dev/pyplusplus/code_creators/unnamed_enum.py
pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py
pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py
pyplusplus_dev/pyplusplus/file_writers/multiple_files.py
pyplusplus_dev/pyplusplus/file_writers/writer.py
pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py
Modified: pyplusplus_dev/pyplusplus/code_creators/array_1_registrator.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/array_1_registrator.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/array_1_registrator.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -65,5 +65,5 @@
fn_def = templates.join( '::'.join( [ns_name, fn_name] ), fn_def_tmpl_args )
return call_invocation.join( fn_def, [ '"%s"' % self._create_name() ] ) + ';'
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return [code_repository.array_1.file_name]
Modified: pyplusplus_dev/pyplusplus/code_creators/bookmark.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/bookmark.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/bookmark.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -14,5 +14,5 @@
def _create_impl(self):
return compound.compound_t.create_internal_code( self.creators, indent_code=False )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -136,7 +136,7 @@
return ''.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
files = []
if self.declaration.call_policies:
files.append( self.declaration.call_policies.header_file )
@@ -176,7 +176,7 @@
else:
return ' throw()'
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
files = []
if self.declaration.transformations:
ft = self.declaration.transformations[0]
@@ -950,7 +950,7 @@
def _create_impl( self ):
return 'staticmethod( "%s" )' % self.function_code_creator.alias
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class constructor_wrapper_t( calldef_wrapper_t ):
@@ -1047,7 +1047,7 @@
answer.append( '}' )
return os.linesep.join( answer )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class null_constructor_wrapper_t( code_creator.code_creator_t
@@ -1079,7 +1079,7 @@
answer.append( '}' )
return os.linesep.join( answer )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
#in python all operators are members of class, while in C++
@@ -1163,7 +1163,7 @@
code = self._create_unary_operator()
return 'def( %s )' % code
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class casting_operator_t( registration_based.registration_based_t
@@ -1188,7 +1188,7 @@
, [ from_arg , to_arg ] ) \
+ '();'
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class casting_member_operator_t( registration_based.registration_based_t
@@ -1225,7 +1225,7 @@
, 'doc' : doc
}
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class casting_constructor_t( registration_based.registration_based_t
@@ -1250,7 +1250,7 @@
return declarations.templates.join(implicitly_convertible, [from_arg, to_arg ]) \
+ '();'
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class destructor_wrapper_t( code_creator.code_creator_t
@@ -1268,7 +1268,7 @@
answer.append( '}' )
return os.linesep.join( answer )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
@@ -1342,7 +1342,7 @@
, 'max' : max_
}
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class free_fun_overloads_class_t( calldef_overloads_class_t ):
@@ -1363,7 +1363,7 @@
, 'max' : max_
}
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class calldef_overloads_t( registration_based.registration_based_t ):
@@ -1450,7 +1450,7 @@
return ''.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class mem_fun_overloads_t( calldef_overloads_t ):
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -417,8 +417,8 @@
def _create_impl(self):
return os.linesep.join([ self.create_override(), '', self.create_default() ])
- def _get_system_headers_impl( self ):
- files = super( mem_fun_v_transformed_wrapper_t, self )._get_system_headers_impl()
+ def _get_system_files_impl( self ):
+ files = super( mem_fun_v_transformed_wrapper_t, self )._get_system_files_impl()
files.append( code_repository.convenience.file_name )
return files
Modified: pyplusplus_dev/pyplusplus/code_creators/class_declaration.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -82,7 +82,7 @@
else:
return self._generate_code_no_scope()
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class class_t( scoped.scoped_t, registration_based.registration_based_t ):
@@ -320,7 +320,7 @@
else:
return self._generate_code_no_scope()
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
#open question: should I put class wrapper under some specifiec namespace?
@@ -395,5 +395,5 @@
answer.append( '};' )
return os.linesep.join( answer )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/class_introduction.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/class_introduction.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/class_introduction.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -41,7 +41,7 @@
% dict( ns_full_name=self.complete_py_name, name=self.alias ))
return os.linesep.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
@@ -62,5 +62,5 @@
% dict( ns_full_name=self.complete_py_name, name=self.alias ))
return os.linesep.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/code_creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/code_creator.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -5,6 +5,8 @@
import os
import types
+from pyplusplus import decl_wrappers
+from pyplusplus import code_repository
class code_creator_t(object):
"""
@@ -23,6 +25,8 @@
__INDENTATION = ' '
LINE_LENGTH = 80
PARAM_SEPARATOR = ', '
+ CODE_GENERATOR_TYPES = decl_wrappers.CODE_GENERATOR_TYPES
+
def __init__(self):
"""Constructor.
@@ -33,7 +37,11 @@
self._parent = None
self._target_configuration = None
self._works_on_instance = True
+ self._code_generator = None
+ @property
+ def code_generator( self ):
+ return self._code_generator
def _get_works_on_instance(self):
return self._works_on_instance
@@ -110,18 +118,32 @@
uheaders.append( h )
return uheaders
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
"""Return list of system header files the generated code depends on"""
raise NotImplementedError(self.__class__.__name__)
- def get_system_headers( self, recursive=False, unique=False ):
- files = [ "boost/python.hpp" ]
- files.extend( self._get_system_headers_impl() )
+ def get_system_files( self, recursive=False, unique=False, language='any' ):
+ files = []
+ if self.code_generator == self.CODE_GENERATOR_TYPES.BOOST_PYTHON:
+ files.append( "boost/python.hpp" )
+ files.append( code_repository.named_tuple.file_name )
+ else:
+ files.append( 'ctypes_utils.py' )
+ files.extend( self._get_system_files_impl() )
files = filter( None, files)
if unique:
files = self.unique_headers( files )
- return files
+ language = language.lower()
+ if language == 'python':
+ selector = lambda f: os.path.splitext( f )[1] in ( '.py' )
+ elif language == 'c++':
+ selector = lambda f: os.path.splitext( f )[1] in ( '.h', '.hpp', '.cpp' )
+ else:
+ selector = None
+
+ return filter( selector, files )
+
def beautify( self, code ):
"""
function that returns code without leading and trailing whitespaces.
@@ -205,5 +227,5 @@
def _create_impl(self):
return self.__code
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/compound.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/compound.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/compound.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -77,12 +77,12 @@
internals[index] = internals[index] + os.linesep
return os.linesep.join( internals )
- def get_system_headers( self, recursive=False, unique=False ):
+ def get_system_files( self, recursive=False, unique=False ):
files = [ "boost/python.hpp" ]
- files.extend( self._get_system_headers_impl() )
+ files.extend( self._get_system_files_impl() )
if recursive:
for creator in self._creators:
- files.extend( creator.get_system_headers(recursive, unique=False) )
+ files.extend( creator.get_system_files(recursive, unique=False) )
files = filter( None, files )
if unique:
files = self.unique_headers( files )
Modified: pyplusplus_dev/pyplusplus/code_creators/ctypes_integration_creators.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/ctypes_integration_creators.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/ctypes_integration_creators.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -35,7 +35,7 @@
return ''.join( answer )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return [code_repository.ctypes_integration.file_name]
class expose_sizeof_t( registration_based.registration_based_t
@@ -51,5 +51,5 @@
def _create_impl(self):
return 'def( pyplus_conv::register_sizeof( boost::type< %s >() ) )' % self.decl_identifier
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return [code_repository.ctypes_integration.file_name]
Modified: pyplusplus_dev/pyplusplus/code_creators/custom.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/custom.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/custom.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -17,7 +17,7 @@
def _create_impl(self):
raise NotImplementedError()
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class custom_text_t(custom_t):
@@ -34,5 +34,5 @@
def _create_impl(self):
return self.text
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/embedded_code_repository.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/embedded_code_repository.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/embedded_code_repository.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -14,5 +14,5 @@
def _create_impl(self):
return self.__code
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/enum.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/enum.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/enum.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -65,7 +65,7 @@
values = self.indent( os.linesep.join( values ) )
return bpl_enum + os.linesep + values
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
@@ -80,5 +80,5 @@
result.append( self.indent( '%(name)s = %(value)s' % dict( name=name, value=value ) ) )
return os.linesep.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/exception_translator.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/exception_translator.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/exception_translator.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -32,7 +32,7 @@
, 'cls_name' : self.decl_identifier
, 'arg_name' : self.declaration.exception_argument_name }
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
@@ -53,6 +53,6 @@
, 'cls' : self.decl_identifier
, 'translator' : self.translator.translator_name }
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
\ No newline at end of file
Modified: pyplusplus_dev/pyplusplus/code_creators/fields_definition.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/fields_definition.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/fields_definition.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -59,5 +59,5 @@
result.append( ']' )
return os.linesep.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/function_definition.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/function_definition.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/function_definition.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -84,7 +84,7 @@
args = map( ctypes_formatter.as_ctype, self.ftype.arguments_types )
return self.join_arguments( args, group_in_list )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
@@ -217,7 +217,7 @@
result.append( self.indent( '.finalize(),', 4 ) )
return os.linesep.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/global_variable.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/global_variable.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/global_variable.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -31,7 +31,7 @@
self._wrapper = new_wrapper
wrapper = property( _get_wrapper, _set_wrapper )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class global_variable_t( global_variable_base_t ):
@@ -69,7 +69,7 @@
def __init__(self, variable, wrapper ):
global_variable_base_t.__init__( self, variable=variable, wrapper=wrapper )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
def _create_impl( self ):
@@ -156,7 +156,7 @@
answer.append( '}' * len( self._create_namespaces() ) )
return os.linesep.join( answer )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return [code_repository.array_1.file_name]
class global_variable_addressof_t( global_variable_base_t ):
@@ -181,7 +181,7 @@
result.append( ' = size_t( boost::addressof( %s ) );' % self.decl_identifier )
return ''.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return [code_repository.ctypes_integration.file_name]
class global_variable_reference_t( code_creator.code_creator_t, declaration_based.declaration_based_t ):
@@ -196,5 +196,5 @@
, library_var_name=self.top_parent.library_var_name
, undecorated_decl_name=self.undecorated_decl_name )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/import_.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/import_.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/import_.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -17,5 +17,5 @@
def _create_impl(self):
return 'import %(module)s' % dict( module=os.path.splitext(self._module_name)[0] )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/include.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/include.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/include.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -58,5 +58,5 @@
self.__created_code = self._create_include_directive_code()
return self.__created_code
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/indexing_suites.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -49,7 +49,7 @@
def _create_impl(self):
return "def( %s() )" % self._create_suite_declaration()
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return self.configuration.include_files
class indexing_suite2_t( registration_based.registration_based_t
@@ -118,7 +118,7 @@
answer.append( ';' )
return ''.join( answer )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return self.declaration.indexing_suite.include_files
class value_traits_t( code_creator.code_creator_t
@@ -176,5 +176,5 @@
#the value_type
return self.generate_value_traits()
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return ['indexing_suite/value_traits.hpp']
Modified: pyplusplus_dev/pyplusplus/code_creators/instruction.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/instruction.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/instruction.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -37,5 +37,5 @@
def _generate_description(self):
raise NotImplementedError()
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/library_reference.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/library_reference.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/library_reference.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -46,7 +46,7 @@
, loader='CDLL'
, path=self._library_path )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
if __name__ == '__main__':
Modified: pyplusplus_dev/pyplusplus/code_creators/license.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/license.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/license.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -20,7 +20,7 @@
self._text = new_text
text = property( _get_text, _set_text )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
def _create_impl(self):
Modified: pyplusplus_dev/pyplusplus/code_creators/mem_fun_introduction.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/mem_fun_introduction.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/mem_fun_introduction.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -20,7 +20,7 @@
return os.linesep.join( tmpl ) \
% dict( alias=self.declaration.alias, name=self.undecorated_decl_name )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class vmem_fun_introduction_t(code_creator.code_creator_t, declaration_based.declaration_based_t):
@@ -37,7 +37,7 @@
, name=self.undecorated_decl_name
, ordinal=0)
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class init_introduction_t(code_creator.code_creator_t, declaration_based.declaration_based_t):
@@ -52,7 +52,7 @@
return os.linesep.join( tmpl ) \
% dict( alias=self.declaration.alias, name=self.undecorated_decl_name )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class opaque_init_introduction_t(code_creator.code_creator_t, declaration_based.declaration_based_t):
@@ -65,7 +65,7 @@
tmpl.append( self.indent('raise RuntimeError( "Unable to create instance of opaque type." )') )
return os.linesep.join( tmpl )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class del_introduction_t(code_creator.code_creator_t, declaration_based.declaration_based_t):
@@ -80,5 +80,5 @@
return os.linesep.join( tmpl ) \
% dict( name=self.undecorated_decl_name )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/member_variable.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -31,7 +31,7 @@
self._wrapper = new_wrapper
wrapper = property( _get_wrapper, _set_wrapper )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
files = []
if self.declaration.getter_call_policies:
files.append( self.declaration.getter_call_policies.header_file )
@@ -269,7 +269,7 @@
, 'cls_type' : self.inst_arg_type( has_const=False ) })
return os.linesep.join( answer )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class bit_field_t( member_variable_base_t ):
@@ -376,7 +376,7 @@
answer.append( self.BF_SET_TEMPLATE % substitutions )
return os.linesep.join( answer )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class array_mv_t( member_variable_base_t ):
@@ -426,7 +426,7 @@
answer.append( '}' )
return ''.join( answer )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
@@ -492,7 +492,7 @@
, 'mem_var_ref' : self.declaration.name
}
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return [code_repository.array_1.file_name]
@@ -642,7 +642,7 @@
answer.append( self.SET_TEMPLATE % substitutions )
return os.linesep.join( answer )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class member_variable_addressof_t( member_variable_base_t ):
@@ -692,5 +692,5 @@
return self._create_s_var()
else:
return self._create_m_var()
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return [code_repository.ctypes_integration.file_name]
Modified: pyplusplus_dev/pyplusplus/code_creators/methods_definition.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/methods_definition.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/methods_definition.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -54,5 +54,5 @@
result.append( 'del %s' % self.mem_fun_factory_var_name )
return os.linesep.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/module.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/module.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/module.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -41,5 +41,5 @@
The license text will always be the first children node.
@type: str or L{license_t}""")
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/module_body.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/module_body.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/module_body.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -22,5 +22,5 @@
result.append( "}" )
return os.linesep.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/name_mappings.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/name_mappings.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/name_mappings.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -32,7 +32,7 @@
result.append( '}' )
return os.linesep.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/namespace.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/namespace.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/namespace.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -31,7 +31,7 @@
self.__created_code = 'namespace %s = %s;' % ( self.alias, self.full_namespace_name )
return self.__created_code
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class namespace_using_t(code_creator.code_creator_t):
@@ -53,5 +53,5 @@
self.__created_code = 'using namespace %s;' % self.namespace_name
return self.__created_code
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/namespace_as_pyclass.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/namespace_as_pyclass.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/namespace_as_pyclass.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -21,5 +21,5 @@
result.append( compound.compound_t.create_internal_code( self.creators ) )
return os.linesep.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/opaque_type_registrator.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/opaque_type_registrator.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/opaque_type_registrator.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -20,5 +20,5 @@
def _create_impl(self):
return 'BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID( %s )' % self.decl_identifier
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/properties.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/properties.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/properties.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -145,7 +145,7 @@
result.append( '}' )
return os.linesep.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/smart_pointers.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/smart_pointers.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/smart_pointers.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -74,7 +74,7 @@
held_type = held_type_t(self.smart_ptr).create( self )
return templates.join( rptp, [ held_type ] ) + '();'
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
class smart_pointers_converter_t( registration_based.registration_based_t
@@ -115,6 +115,6 @@
to_arg = self._instantiate_smart_ptr( self.target )
return templates.join(implicitly_convertible, [ from_arg, to_arg ] ) + '();'
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
\ No newline at end of file
Modified: pyplusplus_dev/pyplusplus/code_creators/typedef_as_pyvar.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/typedef_as_pyvar.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/typedef_as_pyvar.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -18,5 +18,5 @@
% dict( complete_py_name=self.complete_py_name
, type=ctypes_formatter.as_ctype( self.declaration.type ) )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
Modified: pyplusplus_dev/pyplusplus/code_creators/unnamed_enum.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/unnamed_enum.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/code_creators/unnamed_enum.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -34,6 +34,6 @@
, algorithm.create_identifier( self, full_name + '::' + name ) ) )
return os.linesep.join( result )
- def _get_system_headers_impl( self ):
+ def _get_system_files_impl( self ):
return []
\ No newline at end of file
Modified: pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py
===================================================================
--- pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/creators_factory/bpcreator.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -126,7 +126,7 @@
if isinstance( decl, declarations.namespace_t ):
continue
-
+
if isinstance( decl, declarations.class_types ):
if decl.opaque:
continue
@@ -342,7 +342,7 @@
add_include = self.__extmodule.add_include
#add system headers
- system_headers = self.__extmodule.get_system_headers( recursive=True, unique=True )
+ system_headers = self.__extmodule.get_system_files( recursive=True, unique=True, language='c++' )
map( lambda header: add_include( header, user_defined=False, system=True )
, system_headers )
#add user defined header files
@@ -353,6 +353,9 @@
self.__dependencies_manager.inform_user()
+ for cc in code_creators.make_flatten( self.__extmodule ):
+ cc._code_generator = decl_wrappers.CODE_GENERATOR_TYPES.BOOST_PYTHON
+
return self.__extmodule
def visit_member_function( self ):
Modified: pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -152,6 +152,9 @@
self.__dependencies_manager.inform_user()
+ for cc in code_creators.make_flatten( self.module ):
+ cc._code_generator = decl_wrappers.CODE_GENERATOR_TYPES.CTYPES
+
return self.module
def visit_member_function( self ):
@@ -240,18 +243,18 @@
class_ = self.curr_decl
for decl in self.curr_decl.decls( recursive=False, allow_empty=True ):
if isinstance( decl, declarations.variable_t ):
- continue #fields_definition_t class treats them
+ continue #fields_definition_t class treats them
if self.__should_generate_code( decl ):
self.curr_decl = decl
declarations.apply_visitor( self, decl )
self.curr_decl = class_
#fields definition should be recursive using the visitor
#internal classes fields should be defined first
- self.__class_defs_ccs.adopt_creator( code_creators.fields_definition_t( self.curr_decl ) )
+ self.__class_defs_ccs.adopt_creator( code_creators.fields_definition_t( self.curr_decl ) )
else:
cls_intro_cc = self.__class2introduction[ self.curr_decl ]
cls_intro_cc.adopt_creator( code_creators.opaque_init_introduction_t( self.curr_decl ) )
-
+
def visit_enumeration(self):
self.__dependencies_manager.add_exported( self.curr_decl )
paretn_cc = None
@@ -268,7 +271,7 @@
def visit_variable(self):
self.__dependencies_manager.add_exported( self.curr_decl )
self.curr_code_creator.adopt_creator( code_creators.global_variable_reference_t( self.curr_decl ) )
-
+
def visit_namespace(self ):
if not self.__contains_exported( self.curr_decl ):
return
Modified: pyplusplus_dev/pyplusplus/file_writers/multiple_files.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/multiple_files.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/file_writers/multiple_files.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -179,7 +179,7 @@
dependend_on_headers = []
for creator in creators:
- dependend_on_headers.extend( creator.get_system_headers( recursive=True ) )
+ dependend_on_headers.extend( creator.get_system_files( recursive=True, language='C++' ) )
dependend_on_headers = unique_headers( map( normalize, dependend_on_headers ) )
Modified: pyplusplus_dev/pyplusplus/file_writers/writer.py
===================================================================
--- pyplusplus_dev/pyplusplus/file_writers/writer.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/file_writers/writer.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -66,18 +66,11 @@
def write_code_repository(self, dir):
"""creates files defined in L{code_repository} package"""
- system_headers = self.extmodule.get_system_headers( recursive=True )
+ system_files = self.extmodule.get_system_files( recursive=True )
for cr in code_repository.all:
- if cr.file_name in system_headers:
+ if cr.file_name in system_files:
#check whether file from code repository is used
self.write_file( os.path.join( dir, cr.file_name ), cr.code )
- #Python files are a special case
- if isinstance( self.extmodule, code_creators.bpmodule_t ):
- self.write_file( os.path.join( dir, code_repository.named_tuple.file_name )
- , code_repository.named_tuple.code )
- else:
- self.write_file( os.path.join( dir, code_repository.ctypes_utils.file_name )
- , code_repository.ctypes_utils.code )
@staticmethod
def write_file( fpath, content, files_sum_repository=None, encoding='ascii' ):
Modified: pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2009-01-19 19:09:33 UTC (rev 1591)
+++ pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2009-01-19 20:13:07 UTC (rev 1592)
@@ -86,6 +86,8 @@
, compilation_mode
, cache
, indexing_suite_version)
+ self.global_ns.decls(recursive=True, allow_empty=True)._code_generator = decl_wrappers.CODE_GENERATOR_TYPES.CTYPES
+
self.__code_creator = None
if optimize_queries:
self.run_query_optimizer()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-19 19:09:38
|
Revision: 1591
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1591&view=rev
Author: roman_yakovenko
Date: 2009-01-19 19:09:33 +0000 (Mon, 19 Jan 2009)
Log Message:
-----------
adding code generator type
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py
pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py
pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2009-01-19 12:39:54 UTC (rev 1590)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2009-01-19 19:09:33 UTC (rev 1591)
@@ -12,6 +12,7 @@
import algorithm
+from decl_wrapper import CODE_GENERATOR_TYPES
from decl_wrapper import decl_wrapper_t
from calldef_wrapper import calldef_t
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2009-01-19 12:39:54 UTC (rev 1590)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2009-01-19 19:09:33 UTC (rev 1591)
@@ -10,12 +10,17 @@
from pygccxml import declarations
from pyplusplus import messages
+class CODE_GENERATOR_TYPES:
+ BOOST_PYTHON = 'Boost.Python'
+ CTYPES = 'ctypes'
+ all = [ BOOST_PYTHON, CTYPES ]
+
class decl_wrapper_t(object):
"""code generator declaration configuration base class
This class contains configuration that could be applied to all declarations.
"""
-
+
SPECIAL_TYPEDEF_PICK_ANY = True
def __init__(self):
@@ -28,8 +33,14 @@
self._documentation = None
self.__msgs_to_ignore = set()
self._include_files = []
+ self._code_generator = None
@property
+ def code_generator( self ):
+ """code generator type, could be Boost.Python or ctypes"""
+ return self._code_generator
+
+ @property
def logger( self ):
"""reference to L{_logging_.loggers.declarations}"""
return _logging_.loggers.declarations
@@ -46,7 +57,7 @@
name = self.name
return algorithm.create_valid_name( name )
- def __select_alias_directives( self, be_smart ):
+ def __select_alias_directives( self, be_smart ):
if not isinstance( self, declarations.class_types ):
return []
typedefs = list( set( filter( lambda typedef: typedef.is_directive, self.aliases ) ) )
@@ -92,7 +103,7 @@
def rename( self, new_name ):
"""give new name to the declaration, under which Python will know the declaration
-
+
Code generators: ctypes, Boost.Python
"""
self.alias = new_name
@@ -113,25 +124,25 @@
def exclude( self, compilation_errors=False ):
"""exclude "self" and child declarations from being exposed.
-
+
If compile_time_errors is True, than only declarations, which will cause
compilation error will be excluded
-
+
Code generators: ctypes, Boost.Python
"""
self.ignore = True
def include( self, already_exposed=False ):
"""include "self" and child declarations to be exposed.
-
+
Code generators: ctypes, Boost.Python.
"""
self.ignore = False
self.already_exposed = already_exposed
-
+
def why_not_exportable( self ):
"""return the reason( string ) that explains why this declaration could not be exported
-
+
If declaration could be exported, than method will return None
"""
if None is self._exportable_reason:
@@ -157,8 +168,8 @@
return self._exportable
def set_exportable( self, exportable ):
"""change "exportable" status
-
- This function should be use in case Py++ made a mistake and signed the
+
+ This function should be use in case Py++ made a mistake and signed the
declaration as unexportable."""
self._exportable = exportable
@@ -178,18 +189,18 @@
msgs = []
if not self.exportable:
msgs.append( self.why_not_exportable() )
-
+
if declarations.templates.is_instantiation( self.name ) \
and self.alias == self._generate_valid_name():
msgs.append( messages.W1043 % self.alias )
-
+
directives = self.__select_alias_directives(be_smart=False)
- if 1 < len( directives ):
- msgs.append( messages.W1048
+ if 1 < len( directives ):
+ msgs.append( messages.W1048
% ( self.alias, ', '.join( map( lambda typedef: typedef.name, directives ) ) ) )
- msgs.extend( self._readme_impl() )
-
+ msgs.extend( self._readme_impl() )
+
return messages.filter_disabled_msgs( msgs, self.__msgs_to_ignore )
@property
@@ -197,10 +208,10 @@
"""list of messages to ignore"""
return self.__msgs_to_ignore
disabled_messaged = disabled_messages
-
+
def disable_messages( self, *args ):
"""set messages, which should not be reported to you
-
+
Usage example: decl.disable_messages( messages.W1001, messages.W1040 )
"""
for msg in args:
Modified: pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2009-01-19 12:39:54 UTC (rev 1590)
+++ pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2009-01-19 19:09:33 UTC (rev 1591)
@@ -57,6 +57,7 @@
module_builder.module_builder_t.__init__( self, global_ns=None, encoding=encoding )
self.global_ns = self.__parse_declarations( files, gccxml_config )
+ self.global_ns.decls(recursive=True, allow_empty=True)._code_generator = decl_wrappers.CODE_GENERATOR_TYPES.CTYPES
self.__blob2decl = binary_parsers.merge_information( self.global_ns, exported_symbols_file )
self.__apply_defaults()
@@ -79,7 +80,7 @@
return decls_package.matcher.get_single( decls_package.namespace_matcher_t( name='::' )
, decls )
-
+
def __include_declarations( self ):
self.global_ns.exclude()
#include exported declarations
@@ -87,13 +88,13 @@
to_be_included = ctypes_decls_dependencies.find_out_dependencies( included_decls )
to_be_included.update( included_decls )
map( lambda d: d.include(), to_be_included )
-
+
def __apply_defaults( self ):
- self.__include_declarations()
+ self.__include_declarations()
anonymous_classes = self.global_ns.classes( '', recursive=True, allow_empty=True )
anonymous_classes.alias = '_'
#TODO: check whether the anonymous class unique or not
- #if 1 == len( anonymous.parent.classes( '', recursive=False ) ):
+ #if 1 == len( anonymous.parent.classes( '', recursive=False ) ):
anonymous_vars = self.global_ns.vars( '', recursive=True, allow_empty=True )
anonymous_vars.alias = '_'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-19 12:40:04
|
Revision: 1590
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1590&view=rev
Author: roman_yakovenko
Date: 2009-01-19 12:39:54 +0000 (Mon, 19 Jan 2009)
Log Message:
-----------
adding ability to create stand-alone executable for windows
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/etree_scanner.py
Added Paths:
-----------
pyplusplus_dev/scripts/freeze.py
Modified: pygccxml_dev/pygccxml/parser/etree_scanner.py
===================================================================
--- pygccxml_dev/pygccxml/parser/etree_scanner.py 2009-01-19 12:38:29 UTC (rev 1589)
+++ pygccxml_dev/pygccxml/parser/etree_scanner.py 2009-01-19 12:39:54 UTC (rev 1590)
@@ -4,6 +4,10 @@
# http://www.boost.org/LICENSE_1_0.txt)
import scanner
+
+#keep py2exe happy
+import xml.etree.ElementTree
+
import xml.etree.cElementTree as ElementTree
class etree_saxifier_t(object):
Added: pyplusplus_dev/scripts/freeze.py
===================================================================
--- pyplusplus_dev/scripts/freeze.py (rev 0)
+++ pyplusplus_dev/scripts/freeze.py 2009-01-19 12:39:54 UTC (rev 1590)
@@ -0,0 +1,36 @@
+import os
+import sys
+#~ from cx_Freeze import setup, Executable
+
+sys.path.append( '..' )
+sys.path.append( '../../pygccxml_dev' )
+
+import pygccxml
+import pyplusplus
+
+#~ import encodings
+#~ encodings_modules = os.listdir( os.path.dirname( encodings.__file__ ) )
+#~ encodings_modules = set([ os.path.splitext( m )[0] for m in encodings_modules ])
+#~ encodings_modules = map( lambda m: 'encodings.%s.py' % m, encodings_modules )
+
+#~ executable = Executable( "wrap_library.py"
+ #~ , path=['../../pygccxml_dev', '..' ]
+ #~ , includes=encodings_modules
+ #~ , packages=['pygccxml','pyplusplus','encodings'] + encodings_modules )
+
+#~ setup( name = "wrap_library",
+ #~ version = "0.1",
+ #~ description=r"generates ctypes code from the .dll\.so files",
+ #~ executables=[executable] )
+
+ #~ import modulefinder
+ #~ import win32com
+ #~ root = os.path.dirname( sys.executable )
+ #~ modulefinder.AddPackagePath("win32com", os.path.join(root, 'Lib', 'site-packages', 'win32com' ) )
+ #~ modulefinder.AddPackagePath("win32com", os.path.join(root, 'Lib', 'site-packages', 'win32comext' ) )
+
+
+from distutils.core import setup
+import py2exe
+setup( console=["wrap_library.py"] )
+#print py2exe cmd: python freeze.py py2exe
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-19 12:38:39
|
Revision: 1589
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1589&view=rev
Author: roman_yakovenko
Date: 2009-01-19 12:38:29 +0000 (Mon, 19 Jan 2009)
Log Message:
-----------
fixing performance issue
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/patcher.py
pygccxml_dev/pygccxml/parser/scanner.py
pygccxml_dev/pygccxml/parser/source_reader.py
Modified: pygccxml_dev/pygccxml/parser/patcher.py
===================================================================
--- pygccxml_dev/pygccxml/parser/patcher.py 2009-01-18 21:12:45 UTC (rev 1588)
+++ pygccxml_dev/pygccxml/parser/patcher.py 2009-01-19 12:38:29 UTC (rev 1589)
@@ -11,7 +11,7 @@
def __init__( self, enums ):
object.__init__( self )
self.__enums = enums
-
+
def __call__(self, decl):
for arg in decl.arguments:
if not arg.default_value:
@@ -26,7 +26,7 @@
elif self.__is_unqualified_enum( func, arg ):
return self.__fix_unqualified_enum
elif self.__is_double_call( func, arg ):
- return self.__fix_double_call
+ return self.__fix_double_call
elif self.__is_invalid_integral( func, arg ):
return self.__fix_invalid_integral
elif self.__is_constructor_call( func, arg ):
@@ -39,9 +39,9 @@
return '::' + suffix
else:
return prefix + '::' + suffix
-
+
def __is_unqualified_enum(self, func, arg):
- type_ = declarations.remove_reference( declarations.remove_cv( arg.type ) )
+ type_ = declarations.remove_reference( declarations.remove_cv( arg.type ) )
if not declarations.is_enum( type_ ):
return False
enum_type = declarations.enum_declaration( type_ )
@@ -53,7 +53,7 @@
return self.__join_names( enum_type.parent.decl_string, arg.default_value )
def __is_invalid_integral(self, func, arg):
- type_ = declarations.remove_reference( declarations.remove_cv( arg.type ) )
+ type_ = declarations.remove_reference( declarations.remove_cv( arg.type ) )
if not declarations.is_integral( type_ ):
return False
try:
@@ -68,7 +68,7 @@
return arg.default_value
except:
pass
-
+
try:
int( arg.default_value, 16 )
if 64 == utils.get_architecture():
@@ -83,7 +83,7 @@
return '0x' + default_value
except:
pass
-
+
#may be we deal with enum
parent = func.parent
while parent:
@@ -103,7 +103,7 @@
#this algorithm could be improved: it could take into account
#1. unnamed namespaced
#2. location within files
-
+
for enum in self.__enums:
if enum.parent is scope and enum.has_value_name( default_value ):
return enum
@@ -121,7 +121,7 @@
args1 = call_invocation.args( dv[ found1[0] : found1[1] + 1 ] )
args2 = call_invocation.args( dv[ found2[0] : found2[1] + 1 ] )
return len(args1) == len(args2)
-
+
def __fix_double_call( self, func, arg ):
call_invocation = declarations.call_invocation
dv = arg.default_value
@@ -167,7 +167,7 @@
, decl.name )
else:
f_q_name = self.__join_names( declarations.full_name( decl.parent ), name )
-
+
return call_invocation.join( f_q_name, args )
class casting_operator_patcher_t( object ):
@@ -186,9 +186,3 @@
default_arg_patcher( decl )
if isinstance( decl, declarations.casting_operator_t):
_casting_oper_patcher_( decl )
-
-def fix_mangled( decls ):
- suffix = ' *INTERNAL* '
- for d in decls:
- if d.mangled and d.mangled.endswith( suffix ):
- d.mangled = d.mangled[:-len( suffix )]
Modified: pygccxml_dev/pygccxml/parser/scanner.py
===================================================================
--- pygccxml_dev/pygccxml/parser/scanner.py 2009-01-18 21:12:45 UTC (rev 1588)
+++ pygccxml_dev/pygccxml/parser/scanner.py 2009-01-19 12:38:29 UTC (rev 1589)
@@ -149,9 +149,11 @@
self.__inst = None
#mapping from id to members
self.__members = {}
-
self.__compiler = None
+ self.__mangled_suffix = ' *INTERNAL* '
+ self.__mangled_suffix_len = len( self.__mangled_suffix )
+
def read( self ):
xml.sax.parse( self.gccxml_file, self )
@@ -257,7 +259,11 @@
decl.is_artificial = attrs.get( XML_AN_ARTIFICIAL, False )
def __read_mangled( self, decl, attrs ):
- decl.mangled = attrs.get( XML_AN_MANGLED, None )
+ mangled = attrs.get( XML_AN_MANGLED, None )
+ #the following patch is defined here for performance reasons
+ if isinstance( mangled, types.StringType ) and mangled.endswith( self.__mangled_suffix ):
+ mangled = mangled[:self.__mangled_suffix_len]
+ decl.mangled = mangled
def __read_demangled( self, decl, attrs ):
decl.demangled = attrs.get( XML_AN_DEMANGLED, None )
Modified: pygccxml_dev/pygccxml/parser/source_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/source_reader.py 2009-01-18 21:12:45 UTC (rev 1588)
+++ pygccxml_dev/pygccxml/parser/source_reader.py 2009-01-19 12:38:29 UTC (rev 1589)
@@ -316,7 +316,6 @@
#void ddd(){ typedef typename X::Y YY;}
#if I will fail on this bug next time, the right way to fix it may be different
patcher.fix_calldef_decls( scanner_.calldefs(), scanner_.enums() )
- patcher.fix_mangled( decls.itervalues() )
decls = filter( lambda inst: isinstance( inst, namespace_t ) and not inst.parent
, decls.itervalues() )
return ( decls, files.values() )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-18 21:12:47
|
Revision: 1588
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1588&view=rev
Author: roman_yakovenko
Date: 2009-01-18 21:12:45 +0000 (Sun, 18 Jan 2009)
Log Message:
-----------
adding command line utility to generate ctypes wrapper from .dll or .so file
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/__init__.py
pygccxml_dev/pygccxml/parser/config.py
pygccxml_dev/pygccxml/utils/__init__.py
Added Paths:
-----------
pyplusplus_dev/scripts/wrap_library.py
Modified: pygccxml_dev/pygccxml/parser/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/parser/__init__.py 2009-01-18 07:40:49 UTC (rev 1587)
+++ pygccxml_dev/pygccxml/parser/__init__.py 2009-01-18 21:12:45 UTC (rev 1588)
@@ -9,6 +9,7 @@
from config import config_t
from config import gccxml_configuration_t
from config import load_gccxml_configuration
+from config import gccxml_configuration_example
from project_reader import COMPILATION_MODE
from project_reader import project_reader_t
Modified: pygccxml_dev/pygccxml/parser/config.py
===================================================================
--- pygccxml_dev/pygccxml/parser/config.py 2009-01-18 07:40:49 UTC (rev 1587)
+++ pygccxml_dev/pygccxml/parser/config.py 2009-01-18 21:12:45 UTC (rev 1588)
@@ -196,35 +196,37 @@
config_t = gccxml_configuration_t #backward computability
+gccxml_configuration_example = \
+"""[gccxml]
+#path to gccxml executable file - optional, if not provided, os.environ['PATH']
+#variable is used to find it
+gccxml_path=
+#gccxml working directory - optional, could be set to your source code directory
+working_directory=
+#additional include directories, separated by ';' or ':'
+include_paths=
+#gccxml has a nice algorithms, which selects what C++ compiler to emulate.
+#You can explicitly set what compiler it should emulate.
+#Valid options are: g++, msvc6, msvc7, msvc71, msvc8, cl.
+compiler=
+#GCC-XML site: http://gccxml.org/
+"""
+
def load_gccxml_configuration( configuration, **defaults ):
"""loads GCC-XML configuration from a file
Configuration file sceleton:
>>> start <<<
-
- [gccxml]
- #path to gccxml executable file - optional, if not provided, os.environ['PATH']
- #variable is used to find it
- gccxml_path=
- #gccxml working directory - optional, could be set to your source code directory
- working_directory=
- #additional include directories, separated by ';' or ':'
- include_paths=
- #gccxml has a nice algorithms, which selects what C++ compiler to emulate.
- #You can explicitly set what compiler it should emulate.
- #Valid options are: g++, msvc6, msvc7, msvc71, msvc8, cl.
- compiler=
-
- #GCC-XML site: http://gccxml.org/
-
+
+ %s
+
>>> end <<<
-
configuration could be string( configuration file path ) or instance of
ConfigParser.SafeConfigParser class
- """
+ """ % gccxml_configuration_example
parser = configuration
if isinstance( configuration, types.StringTypes ):
from ConfigParser import SafeConfigParser
Modified: pygccxml_dev/pygccxml/utils/__init__.py
===================================================================
--- pygccxml_dev/pygccxml/utils/__init__.py 2009-01-18 07:40:49 UTC (rev 1587)
+++ pygccxml_dev/pygccxml/utils/__init__.py 2009-01-18 21:12:45 UTC (rev 1588)
@@ -162,8 +162,9 @@
def get_version():
if 'win' not in sys.platform:
return None #not implemented yet
- from distutils import msvccompiler
- return ( 'msvc', str( msvccompiler.get_build_version() ) )
+ else:
+ from distutils import msvccompiler
+ return ( 'msvc', str( msvccompiler.get_build_version() ) )
@staticmethod
def get_gccxml_compiler():
Added: pyplusplus_dev/scripts/wrap_library.py
===================================================================
--- pyplusplus_dev/scripts/wrap_library.py (rev 0)
+++ pyplusplus_dev/scripts/wrap_library.py 2009-01-18 21:12:45 UTC (rev 1588)
@@ -0,0 +1,86 @@
+import os
+import sys
+import types
+
+try:
+ import pygccxml
+except ImportError, err:
+ sys.path.append( '../../pygccxml_dev' )
+ import pygccxml
+
+try:
+ import pyplusplus
+except ImportError, err:
+ sys.path.append( '..' )
+ import pyplusplus
+
+import optparse
+
+parser = optparse.OptionParser()
+parser.add_option( '-c'
+ , '--compiler-config'
+ , dest="compiler_config"
+ , help="pygccxml configuration file for GCCXML"
+ , type="string"
+ , action="store"
+ , default=os.path.abspath( os.path.join( os.curdir, 'gccxml.cfg' ) ) )
+
+parser.add_option( '-g'
+ , '--generate-config'
+ , dest="generate_config"
+ , help="generates an example of the compiler configuration file (gccxml.cfg) in the current working directory"
+ , action="store_true"
+ , default=False )
+
+parser.add_option( '-s'
+ , '--source-file'
+ , dest="source_file"
+ , help="source file name - should be specified"
+ , type="string"
+ , action="store" )
+
+parser.add_option( '-d'
+ , '--shared-library'
+ , dest="shared_library"
+ , help=r"shared\dynamic library file name - should be specified"
+ , type="string"
+ , action="store" )
+
+parser.add_option( '-o'
+ , '--output-file'
+ , dest="output_file"
+ , help="output file name, if not specified stdout will be used"
+ , type="string"
+ , action="store"
+ , default=sys.stdout )
+
+def generate_code( options ):
+ gccxml = pygccxml.parser.load_gccxml_configuration( options.compiler_config )
+ #~ import pdb
+ #~ pdb.set_trace()
+ fc = pygccxml.parser.create_source_fc( options.source_file )
+ mb = pyplusplus.module_builder.ctypes_module_builder_t( [ fc ], options.shared_library, gccxml )
+ mb.build_code_creator( options.shared_library )
+ if isinstance( options.output_file, types.StringTypes ):
+ mb.write_module( options.output_file )
+ else:
+ print mb.code_creator.create()
+
+if __name__ == '__main__':
+ options, unused = parser.parse_args(sys.argv[1:])
+
+ if options.generate_config:
+ f_path = os.path.abspath( os.path.join( os.curdir, 'gccxml.cfg' ) )
+ f = file( f_path, 'w+' )
+ f.write( pygccxml.parser.gccxml_configuration_example )
+ f.close()
+ print 'file: "%s" was generated' % f_path
+ else:
+ if None is options.source_file:
+ parser.error("You have to specify source file")
+ if None is options.shared_library:
+ parser.error(r"You have to specify shared\dynamic library file")
+ else:
+ generate_code( options )
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-18 07:40:58
|
Revision: 1587
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1587&view=rev
Author: roman_yakovenko
Date: 2009-01-18 07:40:49 +0000 (Sun, 18 Jan 2009)
Log Message:
-----------
porting code to Windows
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/global_variable.py
Modified: pyplusplus_dev/pyplusplus/code_creators/global_variable.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/global_variable.py 2009-01-18 07:15:23 UTC (rev 1586)
+++ pyplusplus_dev/pyplusplus/code_creators/global_variable.py 2009-01-18 07:40:49 UTC (rev 1587)
@@ -188,13 +188,13 @@
def __init__( self, var ):
code_creator.code_creator_t.__init__( self )
declaration_based.declaration_based_t.__init__( self, var )
-
+
def _create_impl( self ):
- return '%(alias)s = %(type)s.in_dll( %(library_var_name)s, "%(name)s" )' \
+ return '%(alias)s = %(type)s.in_dll( %(library_var_name)s, %(library_var_name)s.undecorated_names["%(undecorated_decl_name)s"] )' \
% dict( alias=self.alias
, type=ctypes_formatter.as_ctype( self.declaration.type )
, library_var_name=self.top_parent.library_var_name
- , name=self.declaration.name )
-
+ , undecorated_decl_name=self.undecorated_decl_name )
+
def _get_system_headers_impl( self ):
return []
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-18 07:15:29
|
Revision: 1586
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1586&view=rev
Author: roman_yakovenko
Date: 2009-01-18 07:15:23 +0000 (Sun, 18 Jan 2009)
Log Message:
-----------
adding ability to expose function with variable number of arguments
Modified Paths:
--------------
pygccxml_dev/pygccxml/declarations/type_visitor.py
pyplusplus_dev/pyplusplus/code_creators/ctypes_formatter.py
pyplusplus_dev/pyplusplus/code_creators/function_definition.py
pyplusplus_dev/unittests/ctypes_pof_tester.py
pyplusplus_dev/unittests/sconstruct
Added Paths:
-----------
pyplusplus_dev/unittests/data/ctypes/varargs/
pyplusplus_dev/unittests/data/ctypes/varargs/sconscript
pyplusplus_dev/unittests/data/ctypes/varargs/varargs.cpp
pyplusplus_dev/unittests/data/ctypes/varargs/varargs.h
Modified: pygccxml_dev/pygccxml/declarations/type_visitor.py
===================================================================
--- pygccxml_dev/pygccxml/declarations/type_visitor.py 2009-01-18 06:14:01 UTC (rev 1585)
+++ pygccxml_dev/pygccxml/declarations/type_visitor.py 2009-01-18 07:15:23 UTC (rev 1586)
@@ -10,7 +10,7 @@
class type_visitor_t(object):
"""
types visitor interface
-
+
All functions within this class should be redefined in derived classes.
"""
def __init__(self):
@@ -18,55 +18,55 @@
def visit_void( self ):
raise NotImplementedError()
-
+
def visit_char( self ):
raise NotImplementedError()
-
+
def visit_unsigned_char( self ):
raise NotImplementedError()
def visit_signed_char( self ):
raise NotImplementedError()
-
+
def visit_wchar( self ):
raise NotImplementedError()
-
+
def visit_short_int( self ):
raise NotImplementedError()
-
+
def visit_short_unsigned_int( self ):
raise NotImplementedError()
-
+
def visit_bool( self ):
raise NotImplementedError()
-
+
def visit_int( self ):
raise NotImplementedError()
-
+
def visit_unsigned_int( self ):
raise NotImplementedError()
-
+
def visit_long_int( self ):
raise NotImplementedError()
-
+
def visit_long_unsigned_int( self ):
raise NotImplementedError()
-
+
def visit_long_long_int( self ):
raise NotImplementedError()
-
+
def visit_long_long_unsigned_int( self ):
raise NotImplementedError()
-
+
def visit_float( self ):
raise NotImplementedError()
-
+
def visit_double( self ):
raise NotImplementedError()
-
+
def visit_long_double( self ):
raise NotImplementedError()
-
+
def visit_complex_long_double(self):
raise NotImplementedError()
@@ -75,58 +75,60 @@
def visit_complex_float(self):
raise NotImplementedError()
-
+
def visit_jbyte(self):
raise NotImplementedError()
-
+
def visit_jshort(self):
raise NotImplementedError()
-
+
def visit_jint(self):
raise NotImplementedError()
-
+
def visit_jlong(self):
raise NotImplementedError()
-
+
def visit_jfloat(self):
raise NotImplementedError()
-
+
def visit_jdouble(self):
raise NotImplementedError()
-
+
def visit_jchar(self):
raise NotImplementedError()
-
+
def visit_jboolean(self):
raise NotImplementedError()
-
+
def visit_volatile( self ):
raise NotImplementedError()
-
+
def visit_const( self ):
raise NotImplementedError()
-
+
def visit_pointer( self ):
raise NotImplementedError()
-
+
def visit_reference( self ):
raise NotImplementedError()
-
+
def visit_array( self ):
raise NotImplementedError()
-
+
def visit_free_function_type( self ):
raise NotImplementedError()
-
+
def visit_member_function_type( self ):
raise NotImplementedError()
-
+
def visit_member_variable_type( self ):
raise NotImplementedError()
-
+
def visit_declarated( self ):
raise NotImplementedError()
def visit_restrict( self ):
raise NotImplementedError()
-
\ No newline at end of file
+
+ def visit_ellipsis( self ):
+ raise NotImplementedError()
Modified: pyplusplus_dev/pyplusplus/code_creators/ctypes_formatter.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/ctypes_formatter.py 2009-01-18 06:14:01 UTC (rev 1585)
+++ pyplusplus_dev/pyplusplus/code_creators/ctypes_formatter.py 2009-01-18 07:15:23 UTC (rev 1586)
@@ -144,6 +144,9 @@
base_visitor = type_converter_t( self.user_type.base, self.decl_formatter )
return declarations.apply_visitor( base_visitor, base_visitor.user_type )
+ def visit_ellipsis( self ):
+ return ''
+
def as_ctype( type_, decl_formatter=algorithm.complete_py_name ):
v = type_converter_t( type_, decl_formatter )
return declarations.apply_visitor( v, type_ )
Modified: pyplusplus_dev/pyplusplus/code_creators/function_definition.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/function_definition.py 2009-01-18 06:14:01 UTC (rev 1585)
+++ pyplusplus_dev/pyplusplus/code_creators/function_definition.py 2009-01-18 07:15:23 UTC (rev 1586)
@@ -61,6 +61,8 @@
args_str = ' ' + args[0] + ' '
else:
args_str = ' ' + arg_separator.join( args ) + ' '
+ if args_str.endswith( ' ' ):
+ args_str = args_str[:-1]
if group_in_list:
return '[%s]' % args_str
else:
Modified: pyplusplus_dev/unittests/ctypes_pof_tester.py
===================================================================
--- pyplusplus_dev/unittests/ctypes_pof_tester.py 2009-01-18 06:14:01 UTC (rev 1585)
+++ pyplusplus_dev/unittests/ctypes_pof_tester.py 2009-01-18 07:15:23 UTC (rev 1586)
@@ -184,23 +184,35 @@
self.module_ref.j.value = 78
self.failUnless( self.module_ref.get_value_j() == 78 )
-
+
self.module_ref.data.i = 987
self.failUnless( self.module_ref.get_value_data() == 987 )
-
+
self.module_ref.data_ptr.contents.i = 34
self.failUnless( self.module_ref.get_value_data_p() == 34 )
+
+class varargs_tester_t( ctypes_base_tester_t ):
+ def __init__( self, *args, **keywd ):
+ ctypes_base_tester_t.__init__( self, 'varargs', *args, **keywd )
+
+ def customize( self, mb ):
+ pass
+
+ def test(self):
+ self.failUnless( 21 == self.module_ref.sum_ints( 3, 5,7,9) )
+
def create_suite():
suite = unittest.TestSuite()
- if 'win' in sys.platform:
- suite.addTest( unittest.makeSuite(pof_tester_t))
- suite.addTest( unittest.makeSuite(issues_tester_t))
+ #~ if 'win' in sys.platform:
+ #~ suite.addTest( unittest.makeSuite(pof_tester_t))
+ #~ suite.addTest( unittest.makeSuite(issues_tester_t))
suite.addTest( unittest.makeSuite(enums_tester_t))
suite.addTest( unittest.makeSuite(opaque_tester_t))
suite.addTest( unittest.makeSuite(include_algorithm_tester_t))
suite.addTest( unittest.makeSuite(anonymous_tester_t))
suite.addTest( unittest.makeSuite(variables_tester_t))
+ suite.addTest( unittest.makeSuite(varargs_tester_t))
return suite
def run_suite():
Added: pyplusplus_dev/unittests/data/ctypes/varargs/sconscript
===================================================================
--- pyplusplus_dev/unittests/data/ctypes/varargs/sconscript (rev 0)
+++ pyplusplus_dev/unittests/data/ctypes/varargs/sconscript 2009-01-18 07:15:23 UTC (rev 1586)
@@ -0,0 +1,7 @@
+Import('*')
+
+target_name = 'varargs'
+shlib = env.SharedLibrary( target=target_name
+ , source=[ target_name + '.cpp' ]
+ , CPPPATH=['#data'] )
+env.Alias( target_name, shlib )
Added: pyplusplus_dev/unittests/data/ctypes/varargs/varargs.cpp
===================================================================
--- pyplusplus_dev/unittests/data/ctypes/varargs/varargs.cpp (rev 0)
+++ pyplusplus_dev/unittests/data/ctypes/varargs/varargs.cpp 2009-01-18 07:15:23 UTC (rev 1586)
@@ -0,0 +1,15 @@
+#include "varargs.h"
+#include <stdio.h>
+#include <stdarg.h>
+
+EXPORT_SYMBOL unsigned long sum_ints( int count, ... ){
+ va_list vl;
+ unsigned long result = 0;
+ va_start( vl, count );
+ // Step through the list.
+ for( int i = 0; i < count; ++i ){
+ result += va_arg( vl, int );
+ }
+ va_end( vl );
+ return result;
+}
Added: pyplusplus_dev/unittests/data/ctypes/varargs/varargs.h
===================================================================
--- pyplusplus_dev/unittests/data/ctypes/varargs/varargs.h (rev 0)
+++ pyplusplus_dev/unittests/data/ctypes/varargs/varargs.h 2009-01-18 07:15:23 UTC (rev 1586)
@@ -0,0 +1,3 @@
+#include "libconfig.h"
+
+EXPORT_SYMBOL unsigned long sum_ints( int count, ... );
Modified: pyplusplus_dev/unittests/sconstruct
===================================================================
--- pyplusplus_dev/unittests/sconstruct 2009-01-18 06:14:01 UTC (rev 1585)
+++ pyplusplus_dev/unittests/sconstruct 2009-01-18 07:15:23 UTC (rev 1586)
@@ -31,7 +31,8 @@
, 'opaque'
, 'include_algorithm'
, 'anonymous'
- , 'variables' ]
+ , 'variables'
+ , 'varargs']
for s in scripts:
SConscript( 'data/ctypes/%s/sconscript' % s
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-18 06:14:06
|
Revision: 1585
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1585&view=rev
Author: roman_yakovenko
Date: 2009-01-18 06:14:01 +0000 (Sun, 18 Jan 2009)
Log Message:
-----------
adding ability to configure compiler settings from the web UI
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/config.py
ui/web/code_generator.py
ui/web/config.py
ui/web/form_processor.py
Modified: pygccxml_dev/pygccxml/parser/config.py
===================================================================
--- pygccxml_dev/pygccxml/parser/config.py 2009-01-17 20:37:23 UTC (rev 1584)
+++ pygccxml_dev/pygccxml/parser/config.py 2009-01-18 06:14:01 UTC (rev 1585)
@@ -92,6 +92,9 @@
cflags = property( __get_cflags, __set_cflags
, doc="additional flags to pass to compiler" )
+ def append_cflags( self, val ):
+ self.__cflags = self.__cflags + ' ' + val
+
def __ensure_dir_exists( self, dir_path, meaning ):
if os.path.isdir( dir_path ):
return
@@ -232,7 +235,7 @@
values = defaults
if not values:
values = {}
-
+
if parser.has_section( 'gccxml' ):
for name, value in parser.items( 'gccxml' ):
if value.strip():
Modified: ui/web/code_generator.py
===================================================================
--- ui/web/code_generator.py 2009-01-17 20:37:23 UTC (rev 1584)
+++ ui/web/code_generator.py 2009-01-18 06:14:01 UTC (rev 1585)
@@ -11,9 +11,9 @@
def __init__( self ):
pass
- def show_xml( self, file_configuration ):
+ def show_xml( self, file_configuration, compiler_config ):
try:
- reader = parser.project_reader_t( config=config.gccxml )
+ reader = parser.project_reader_t( config=compiler_config )
content = reader.read_xml( file_configuration )
return content, ''
#return xml.sax.saxutils.escape( content ), ''
@@ -23,9 +23,9 @@
user_msg.append( str( error ) )
return '', '\n'.join( user_msg )
- def show_declarations( self, file_configuration ):
+ def show_declarations( self, file_configuration, compiler_config ):
try:
- reader = parser.project_reader_t( config=config.gccxml )
+ reader = parser.project_reader_t( config=compiler_config )
decls = reader.read_files( [file_configuration] )
global_ns = declarations.get_global_namespace( decls )
tmp = []
@@ -37,13 +37,13 @@
user_msg.append( str( error ) )
return '', '\n'.join( user_msg )
- def generate_bpl_code( self, file_configuration ):
+ def generate_bpl_code( self, file_configuration, compiler_config ):
try:
_logging_.loggers.make_inmemory()
mb = module_builder.module_builder_t( [ file_configuration ]
- , gccxml_path=config.gccxml.gccxml_path
- , compiler=config.gccxml.compiler)
+ , gccxml_path=compiler_config.gccxml_path
+ , compiler=compiler_config.compiler)
mb.decls( header_dir=config.temp_dir ).include()
mb.build_code_creator( "pyplusplus" )
code = mb.code_creator.create()
@@ -58,10 +58,10 @@
user_msg.append( str( error ) )
return '', '\n'.join( user_msg )
- def generate_ctypes_code( self, file_configuration, symbols_file ):
+ def generate_ctypes_code( self, file_configuration, symbols_file, compiler_config ):
try:
_logging_.loggers.make_inmemory()
- mb = ctypes_module_builder_t( [ file_configuration ], symbols_file, config.gccxml )
+ mb = ctypes_module_builder_t( [ file_configuration ], symbols_file, compiler_config )
mb.build_code_creator( symbols_file )
code = mb.code_creator.create()
code = code.replace( '\n\r', '\n' )
@@ -74,11 +74,3 @@
user_msg.append( 'Error:' )
user_msg.append( str( error ) )
return '', '\n'.join( user_msg )
-
-
-
-
-if __name__ == '__main__':
- m = manager_t()
- m.generate_bpl_code( 'int do_smth( int &);int do_smth( int, int);' )
-
Modified: ui/web/config.py
===================================================================
--- ui/web/config.py 2009-01-17 20:37:23 UTC (rev 1584)
+++ ui/web/config.py 2009-01-18 06:14:01 UTC (rev 1585)
@@ -6,7 +6,7 @@
this_module_dir_path = os.path.abspath ( os.path.dirname( sys.modules[__name__].__file__) )
projects_root_dir = os.path.dirname( os.path.dirname( this_module_dir_path ) )
-sys.path.insert( 0, os.path.join( this_module_dir_path, 'web.zip' ) )
+#~ sys.path.insert( 0, os.path.join( this_module_dir_path, 'web.zip' ) )
if os.path.exists( os.path.join( projects_root_dir, 'pygccxml_dev' ) ):
sys.path.append( os.path.join( projects_root_dir, 'pygccxml_dev' ) )
@@ -14,13 +14,10 @@
sys.path.append( os.path.join( projects_root_dir, 'pyplusplus_dev' ) )
#else use installed modules
-from pygccxml import parser
-from pyplusplus import module_builder
+import pygccxml
-gccxml_path = os.path.join( projects_root_dir, 'gccxml_bin', 'v09', sys.platform, 'bin' )
-if os.path.exists( gccxml_path ):
- gccxml = parser.config_t( gccxml_path=gccxml_path )
-else: #use gccxml from PATH
- gccxml = parser.config_t()
+gccxml = pygccxml.parser.load_gccxml_configuration( os.path.join( this_module_dir_path, 'gccxml.cfg' )
+ , gccxml_path=os.path.join( projects_root_dir, 'gccxml_bin', 'v09', sys.platform, 'bin' )
+ , compiler=pygccxml.utils.native_compiler.get_gccxml_compiler() )
temp_dir = tempfile.gettempdir()
Modified: ui/web/form_processor.py
===================================================================
--- ui/web/form_processor.py 2009-01-17 20:37:23 UTC (rev 1584)
+++ ui/web/form_processor.py 2009-01-18 06:14:01 UTC (rev 1585)
@@ -25,30 +25,45 @@
else:
return parser.create_source_fc( self.__input[ file_key ] )
+ def __create_gccxml_cfg( self ):
+ #in real web mode this functionality should be disabled
+ cfg = config.gccxml.clone()
+
+ include_dirs = self.__input['COMPILER_INCLUDE_DIRECTORIES']
+ include_dirs = include_dirs.split('\n')
+ cfg.include_paths.extend([ idir.strip() for idir in include_dirs ])
+
+ preprocessor_defs = self.__input['COMPILER_PREPROCESSOR_DEFINITIONS']
+ cfg.append_cflags( preprocessor_defs.replace( '\n', ' ' ) )
+
+ additional_args = self.__input['COMPILER_CMD_ARGS']
+ cfg.append_cflags( additional_args.replace( '\n', ' ' ) )
+ return cfg
+
def on_view_xml( self ):
fc = self.__create_fc( 'GCCXML' )
- decls_tree, warnings = self.__code_generator.show_xml( fc )
+ decls_tree, warnings = self.__code_generator.show_xml( fc, compiler_config=self.__create_gccxml_cfg() )
return decls_tree, warnings
def on_view_decls( self ):
fc = self.__create_fc( 'GCCXML' )
- decls_tree, warnings = self.__code_generator.show_declarations( fc )
+ decls_tree, warnings = self.__code_generator.show_declarations( fc, compiler_config=self.__create_gccxml_cfg() )
return decls_tree, warnings
def on_generate_bpl_code( self ):
fc = self.__create_fc( 'BPL' )
- code, warnings = self.__code_generator.generate_bpl_code( fc )
+ code, warnings = self.__code_generator.generate_bpl_code( fc, compiler_config=self.__create_gccxml_cfg() )
return code, warnings
def on_generate_bpl_pypp_code( self ):
w = wizard.wizard_t()
- code = w.create_bpl_code( config.gccxml, self.__create_fc( 'BPL' ) )
+ code = w.create_bpl_code( self.__create_gccxml_cfg(), self.__create_fc( 'BPL' ) )
return code, ''
def on_generate_ctypes_code( self ):
fc = parser.create_source_fc( self.__input[ "CTYPES_FILE_NAME" ] )
symbols_file = self.__input[ "CTYPES_SHLIB_FILE_NAME" ]
- code, warnings = self.__code_generator.generate_ctypes_code( fc, symbols_file )
+ code, warnings = self.__code_generator.generate_ctypes_code( fc, symbols_file, compiler_config=self.__create_gccxml_cfg() )
return code, warnings
def on_generate_ctypes_pypp_code( self ):
@@ -67,16 +82,3 @@
def process( self ):
handler = self.__select_handler()
return handler()
-
-
- #~ source_code = request_data[ self.__source_code.name]
- #~ if self.__show_decls.name in request_data:
- #~ generated = self.__code_generator.show_declarations( source_code )
- #~ elif self.__generate_pypp_code.name in request_data:
- #~ generated = self.__code_generator.generate_pypp_code( source_code )
- #~ elif self.__generate_bpl_code.name in request_data:
- #~ generated, warnings = self.__code_generator.generate_bpl_code( source_code )
- #~ else:
- #~ generated = 'error - unknown submit action'
- #~ return generated, warnings
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-17 20:37:27
|
Revision: 1584
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1584&view=rev
Author: roman_yakovenko
Date: 2009-01-17 20:37:23 +0000 (Sat, 17 Jan 2009)
Log Message:
-----------
adding global variables
Modified Paths:
--------------
pyplusplus_dev/examples/gmplib_dev/dev/generate_code.py
pyplusplus_dev/examples/gmplib_dev/pygmplib/__init__.py
pyplusplus_dev/examples/gmplib_dev/test.py
Modified: pyplusplus_dev/examples/gmplib_dev/dev/generate_code.py
===================================================================
--- pyplusplus_dev/examples/gmplib_dev/dev/generate_code.py 2009-01-17 20:24:45 UTC (rev 1583)
+++ pyplusplus_dev/examples/gmplib_dev/dev/generate_code.py 2009-01-17 20:37:23 UTC (rev 1584)
@@ -24,6 +24,9 @@
for f in mb.calldefs( lambda x: x.name.startswith('__gmp') ):
f.alias = f.name[2:]
+for v in mb.vars( lambda x: x.name.startswith( '__gmp' ) ):
+ v.alias = v.name[2:]
+
#those structs are private implementation of FILE
mb.class_( '_IO_FILE' ).opaque = True
mb.class_( '_IO_marker' ).opaque = True
Modified: pyplusplus_dev/examples/gmplib_dev/pygmplib/__init__.py
===================================================================
--- pyplusplus_dev/examples/gmplib_dev/pygmplib/__init__.py 2009-01-17 20:24:45 UTC (rev 1583)
+++ pyplusplus_dev/examples/gmplib_dev/pygmplib/__init__.py 2009-01-17 20:37:23 UTC (rev 1584)
@@ -725,6 +725,8 @@
gmpf_sqrt_type = ctypes.CFUNCTYPE( None, ctypes.POINTER( __mpf_struct ), ctypes.POINTER( __mpf_struct ) )
gmpf_sqrt = gmpf_sqrt_type( ( libgmp_lib.undecorated_names["extern void __gmpf_sqrt(mpf_ptr arg0, mpf_srcptr arg1) [free function]"], libgmp_lib ) )
+gmp_errno = ctypes.c_int.in_dll( libgmp_lib, "__gmp_errno" )
+
gmpz_cdiv_q_ui_type = ctypes.CFUNCTYPE( ctypes.c_ulong, ctypes.POINTER( __mpz_struct ), ctypes.POINTER( __mpz_struct ), ctypes.c_ulong )
gmpz_cdiv_q_ui = gmpz_cdiv_q_ui_type( ( libgmp_lib.undecorated_names["extern long unsigned int __gmpz_cdiv_q_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]"], libgmp_lib ) )
@@ -791,6 +793,8 @@
gmpz_inp_raw_type = ctypes.CFUNCTYPE( ctypes.c_uint, ctypes.POINTER( __mpz_struct ), ctypes.POINTER( _IO_FILE ) )
gmpz_inp_raw = gmpz_inp_raw_type( ( libgmp_lib.undecorated_names["extern size_t __gmpz_inp_raw(mpz_ptr arg0, FILE * arg1) [free function]"], libgmp_lib ) )
+gmp_version = ctypes.c_char_p.in_dll( libgmp_lib, "__gmp_version" )
+
gmpz_tdiv_ui_type = ctypes.CFUNCTYPE( ctypes.c_ulong, ctypes.POINTER( __mpz_struct ), ctypes.c_ulong )
gmpz_tdiv_ui = gmpz_tdiv_ui_type( ( libgmp_lib.undecorated_names["extern long unsigned int __gmpz_tdiv_ui(mpz_srcptr arg0, long unsigned int arg1) [free function]"], libgmp_lib ) )
@@ -914,6 +918,8 @@
gmpz_sub_ui_type = ctypes.CFUNCTYPE( None, ctypes.POINTER( __mpz_struct ), ctypes.POINTER( __mpz_struct ), ctypes.c_ulong )
gmpz_sub_ui = gmpz_sub_ui_type( ( libgmp_lib.undecorated_names["extern void __gmpz_sub_ui(mpz_ptr arg0, mpz_srcptr arg1, long unsigned int arg2) [free function]"], libgmp_lib ) )
+gmp_bits_per_limb = ctypes.c_int.in_dll( libgmp_lib, "__gmp_bits_per_limb" )
+
gmpz_rrandomb_type = ctypes.CFUNCTYPE( None, ctypes.POINTER( __mpz_struct ), ctypes.POINTER( __gmp_randstate_struct ), ctypes.c_ulong )
gmpz_rrandomb = gmpz_rrandomb_type( ( libgmp_lib.undecorated_names["extern void __gmpz_rrandomb(mpz_ptr arg0, __gmp_randstate_struct * arg1, long unsigned int arg2) [free function]"], libgmp_lib ) )
Modified: pyplusplus_dev/examples/gmplib_dev/test.py
===================================================================
--- pyplusplus_dev/examples/gmplib_dev/test.py 2009-01-17 20:24:45 UTC (rev 1583)
+++ pyplusplus_dev/examples/gmplib_dev/test.py 2009-01-17 20:37:23 UTC (rev 1584)
@@ -1,6 +1,8 @@
import ctypes
import pygmplib as gmp
+print 'gmp version: ', gmp.gmp_version.value
+
integ1 = ctypes.pointer( gmp.__mpz_struct() )
integ2 = ctypes.pointer( gmp.__mpz_struct() )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rom...@us...> - 2009-01-17 20:24:55
|
Revision: 1583
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1583&view=rev
Author: roman_yakovenko
Date: 2009-01-17 20:24:45 +0000 (Sat, 17 Jan 2009)
Log Message:
-----------
adding support for global variables
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/__init__.py
pyplusplus_dev/pyplusplus/code_creators/global_variable.py
pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py
pyplusplus_dev/unittests/ctypes_pof_tester.py
pyplusplus_dev/unittests/sconstruct
Added Paths:
-----------
pyplusplus_dev/unittests/data/ctypes/variables/
pyplusplus_dev/unittests/data/ctypes/variables/sconscript
pyplusplus_dev/unittests/data/ctypes/variables/variables.cpp
pyplusplus_dev/unittests/data/ctypes/variables/variables.h
Modified: pyplusplus_dev/pyplusplus/code_creators/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/__init__.py 2009-01-17 09:29:36 UTC (rev 1582)
+++ pyplusplus_dev/pyplusplus/code_creators/__init__.py 2009-01-17 20:24:45 UTC (rev 1583)
@@ -167,3 +167,4 @@
from function_definition import mem_fun_definition_t
from typedef_as_pyvar import typedef_as_pyvar_t
from enum import pyenum_t
+from global_variable import global_variable_reference_t
Modified: pyplusplus_dev/pyplusplus/code_creators/global_variable.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/global_variable.py 2009-01-17 09:29:36 UTC (rev 1582)
+++ pyplusplus_dev/pyplusplus/code_creators/global_variable.py 2009-01-17 20:24:45 UTC (rev 1583)
@@ -7,6 +7,7 @@
import pygccxml
import algorithm
import code_creator
+import ctypes_formatter
import declaration_based
import registration_based
from pygccxml import declarations
@@ -182,3 +183,18 @@
def _get_system_headers_impl( self ):
return [code_repository.ctypes_integration.file_name]
+
+class global_variable_reference_t( code_creator.code_creator_t, declaration_based.declaration_based_t ):
+ def __init__( self, var ):
+ code_creator.code_creator_t.__init__( self )
+ declaration_based.declaration_based_t.__init__( self, var )
+
+ def _create_impl( self ):
+ return '%(alias)s = %(type)s.in_dll( %(library_var_name)s, "%(name)s" )' \
+ % dict( alias=self.alias
+ , type=ctypes_formatter.as_ctype( self.declaration.type )
+ , library_var_name=self.top_parent.library_var_name
+ , name=self.declaration.name )
+
+ def _get_system_headers_impl( self ):
+ return []
Modified: pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2009-01-17 09:29:36 UTC (rev 1582)
+++ pyplusplus_dev/pyplusplus/creators_factory/ctypes_creator.py 2009-01-17 20:24:45 UTC (rev 1583)
@@ -39,8 +39,6 @@
self.__class_defs_ccs = code_creators.bookmark_t()
#bookmark for typedef definitions
self.__typedefs_ccs = code_creators.bookmark_t()
- #~ prepared_decls = self.__prepare_decls( global_ns, doc_extractor )
- #~ self.__decls = sort_algorithms.sort( prepared_decls )
self.curr_decl = global_ns
self.curr_code_creator = self.module
#mapping between class declaration and class introduction code creator
@@ -49,9 +47,6 @@
self.__class2methods_def = {}
#mapping between namespace and its code creator
self.__namespace2pyclass = {}
- #set of all included namespaces
- #~ self.__included_nss = set()
- #~ for decl in self.global_ns
def __print_readme( self, decl ):
readme = decl.readme()
@@ -71,6 +66,9 @@
return False
if isinstance( decl, declarations.calldef_t ):
return decl in self.__exported_decls
+ if isinstance( decl, declarations.variable_t ):
+ if isinstance( decl.parent, declarations.namespace_t ):
+ return decl in self.__exported_decls
return True
#~ def __prepare_decls( self, global_ns, doc_extractor ):
@@ -241,6 +239,8 @@
self.__class_defs_ccs.adopt_creator( md_cc )
class_ = self.curr_decl
for decl in self.curr_decl.decls( recursive=False, allow_empty=True ):
+ if isinstance( decl, declarations.variable_t ):
+ continue #fields_definition_t class treats them
if self.__should_generate_code( decl ):
self.curr_decl = decl
declarations.apply_visitor( self, decl )
@@ -267,7 +267,8 @@
def visit_variable(self):
self.__dependencies_manager.add_exported( self.curr_decl )
-
+ self.curr_code_creator.adopt_creator( code_creators.global_variable_reference_t( self.curr_decl ) )
+
def visit_namespace(self ):
if not self.__contains_exported( self.curr_decl ):
return
Modified: pyplusplus_dev/unittests/ctypes_pof_tester.py
===================================================================
--- pyplusplus_dev/unittests/ctypes_pof_tester.py 2009-01-17 09:29:36 UTC (rev 1582)
+++ pyplusplus_dev/unittests/ctypes_pof_tester.py 2009-01-17 20:24:45 UTC (rev 1583)
@@ -169,6 +169,28 @@
c.r
c.val
+class variables_tester_t( ctypes_base_tester_t ):
+ def __init__( self, *args, **keywd ):
+ ctypes_base_tester_t.__init__( self, 'variables', *args, **keywd )
+
+ def customize( self, mb ):
+ pass
+
+ def test(self):
+ self.module_ref.init()
+ self.failUnless( self.module_ref.j.value == 87 )
+ self.failUnless( self.module_ref.data.i == 1900 )
+ self.failUnless( self.module_ref.data_ptr.contents.i == 11 )
+
+ self.module_ref.j.value = 78
+ self.failUnless( self.module_ref.get_value_j() == 78 )
+
+ self.module_ref.data.i = 987
+ self.failUnless( self.module_ref.get_value_data() == 987 )
+
+ self.module_ref.data_ptr.contents.i = 34
+ self.failUnless( self.module_ref.get_value_data_p() == 34 )
+
def create_suite():
suite = unittest.TestSuite()
if 'win' in sys.platform:
@@ -178,6 +200,7 @@
suite.addTest( unittest.makeSuite(opaque_tester_t))
suite.addTest( unittest.makeSuite(include_algorithm_tester_t))
suite.addTest( unittest.makeSuite(anonymous_tester_t))
+ suite.addTest( unittest.makeSuite(variables_tester_t))
return suite
def run_suite():
Added: pyplusplus_dev/unittests/data/ctypes/variables/sconscript
===================================================================
--- pyplusplus_dev/unittests/data/ctypes/variables/sconscript (rev 0)
+++ pyplusplus_dev/unittests/data/ctypes/variables/sconscript 2009-01-17 20:24:45 UTC (rev 1583)
@@ -0,0 +1,7 @@
+Import('*')
+
+target_name = 'variables'
+shlib = env.SharedLibrary( target=target_name
+ , source=[ target_name + '.cpp' ]
+ , CPPPATH=['#data'] )
+env.Alias( target_name, shlib )
Added: pyplusplus_dev/unittests/data/ctypes/variables/variables.cpp
===================================================================
--- pyplusplus_dev/unittests/data/ctypes/variables/variables.cpp (rev 0)
+++ pyplusplus_dev/unittests/data/ctypes/variables/variables.cpp 2009-01-17 20:24:45 UTC (rev 1583)
@@ -0,0 +1,22 @@
+#include "variables.h"
+
+EXPORT_SYMBOL void init(){
+ data.i = 1900;
+ data_ptr = new data_t();
+ data_ptr->i = 11;
+ j = 87;
+}
+
+EXPORT_SYMBOL int get_value_j(){
+ return j;
+}
+
+EXPORT_SYMBOL int get_value_data(){
+ return data.i;
+}
+
+EXPORT_SYMBOL int get_value_data_p(){
+ return data_ptr->i;
+}
+
+
Added: pyplusplus_dev/unittests/data/ctypes/variables/variables.h
===================================================================
--- pyplusplus_dev/unittests/data/ctypes/variables/variables.h (rev 0)
+++ pyplusplus_dev/unittests/data/ctypes/variables/variables.h 2009-01-17 20:24:45 UTC (rev 1583)
@@ -0,0 +1,16 @@
+#include "libconfig.h"
+
+struct EXPORT_SYMBOL data_t{
+ int i;
+};
+
+EXPORT_SYMBOL int j;
+EXPORT_SYMBOL data_t data;
+EXPORT_SYMBOL data_t* data_ptr;
+
+EXPORT_SYMBOL void init();
+EXPORT_SYMBOL int get_value_j();
+EXPORT_SYMBOL int get_value_data();
+EXPORT_SYMBOL int get_value_data_p();
+
+
Modified: pyplusplus_dev/unittests/sconstruct
===================================================================
--- pyplusplus_dev/unittests/sconstruct 2009-01-17 09:29:36 UTC (rev 1582)
+++ pyplusplus_dev/unittests/sconstruct 2009-01-17 20:24:45 UTC (rev 1583)
@@ -25,7 +25,14 @@
env.AppendUnique( CPPPATH=['#data'] )
-scripts = [ 'pof', 'issues', 'enums', 'opaque', 'include_algorithm', 'anonymous' ]
+scripts = [ 'pof'
+ , 'issues'
+ , 'enums'
+ , 'opaque'
+ , 'include_algorithm'
+ , 'anonymous'
+ , 'variables' ]
+
for s in scripts:
SConscript( 'data/ctypes/%s/sconscript' % s
, variant_dir='data/ctypes/%s/binaries' % s
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|