Revision: 1614
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1614&view=rev
Author: roman_yakovenko
Date: 2009-01-26 06:55:33 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
merging ctypes and boost.python code creators into single file
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/__init__.py
pyplusplus_dev/pyplusplus/code_creators/class_declaration.py
Removed Paths:
-------------
pyplusplus_dev/pyplusplus/code_creators/class_introduction.py
Modified: pyplusplus_dev/pyplusplus/code_creators/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/__init__.py 2009-01-26 06:49:48 UTC (rev 1613)
+++ pyplusplus_dev/pyplusplus/code_creators/__init__.py 2009-01-26 06:55:33 UTC (rev 1614)
@@ -45,6 +45,7 @@
from namespace import namespace_as_pyclass_t
from enum import enum_t
+from enum import pyenum_t
from calldef import free_function_t
from calldef import mem_fun_t
@@ -98,6 +99,7 @@
from global_variable import array_gv_t
from global_variable import array_gv_wrapper_t
from global_variable import global_variable_addressof_t
+from global_variable import global_variable_reference_t
from member_variable import member_variable_base_t
from member_variable import member_variable_t
@@ -113,6 +115,8 @@
from class_declaration import class_t
from class_declaration import class_wrapper_t
from class_declaration import class_declaration_t
+from class_declaration import class_introduction_t
+from class_declaration import class_declaration_introduction_t
from instruction import instruction_t
@@ -150,8 +154,6 @@
#pure ctypes
from library_reference import library_reference_t
from name_mappings import name_mappings_t
-from class_introduction import class_introduction_t
-from class_introduction import class_declaration_introduction_t
from mem_fun_introduction import mem_fun_introduction_t
from mem_fun_introduction import vmem_fun_introduction_t
from mem_fun_introduction import init_introduction_t
@@ -159,7 +161,6 @@
from mem_fun_introduction import del_introduction_t
from fields_definition import fields_definition_t
-from embedded_code_repository import embedded_code_repository_t
from methods_definition import methods_definition_t
from function_definition import function_definition_t
from function_definition import init_definition_t
@@ -167,5 +168,6 @@
from function_definition import del_definition_t
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
+
+
+from embedded_code_repository import embedded_code_repository_t
Modified: pyplusplus_dev/pyplusplus/code_creators/class_declaration.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2009-01-26 06:49:48 UTC (rev 1613)
+++ pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2009-01-26 06:55:33 UTC (rev 1614)
@@ -7,7 +7,9 @@
import types
import scoped
import calldef
+import compound
import algorithm
+import code_creator
import smart_pointers
import declaration_based
import registration_based
@@ -150,7 +152,7 @@
def _generate_noncopyable(self):
noncopyable_vars = self.declaration.find_noncopyable_vars()
copy_constr = self.declaration.find_copy_constructor()
-
+
if self.declaration.noncopyable \
or copy_constr and copy_constr.is_artificial and noncopyable_vars:
return algorithm.create_identifier( self, '::boost::noncopyable' )
@@ -198,7 +200,7 @@
args.append( self.wrapper.full_name )
else:
args.append( self.decl_identifier )
-
+
bases = self._generate_bases(base_creators)
if bases:
args.append( bases )
@@ -217,10 +219,10 @@
if self.documentation:
result.append( ', %s' % self.documentation )
used_init = None
- inits = filter( lambda x: isinstance( x, calldef.constructor_t ), self.creators )
+ inits = filter( lambda x: isinstance( x, calldef.constructor_t ), self.creators )
trivial_constructor = self.declaration.find_trivial_constructor()
-
+
if self.declaration.no_init:
result.append( ", " )
result.append( algorithm.create_identifier( self, '::boost::python::no_init' ) )
@@ -254,7 +256,7 @@
@property
def class_var_name(self):
return self.declaration.class_var_name
-
+
@property
def typedef_name( self ):
return self.class_var_name + '_t'
@@ -319,7 +321,7 @@
return self._generate_code_with_scope()
else:
return self._generate_code_no_scope()
-
+
def _get_system_files_impl( self ):
return []
@@ -340,7 +342,7 @@
self.declaration.wrapper_alias = walias
wrapper_alias = property( _get_wrapper_alias, _set_wrapper_alias )
- @property
+ @property
def base_wrappers( self ):
if self.declaration.is_abstract and not self._base_wrappers:
bases = [ hi.related_class for hi in self.declaration.bases ]
@@ -397,3 +399,60 @@
def _get_system_files_impl( self ):
return []
+
+
+ctypes_base_classes = {
+ declarations.CLASS_TYPES.CLASS : 'Structure'
+ , declarations.CLASS_TYPES.UNION : 'Union'
+ , declarations.CLASS_TYPES.STRUCT : 'Structure'
+}
+
+class class_introduction_t(compound.compound_t, declaration_based.declaration_based_t):
+ def __init__( self, class_ ):
+ compound.compound_t.__init__(self)
+ declaration_based.declaration_based_t.__init__( self, class_ )
+
+ @property
+ def ctypes_base_class( self ):
+ global ctypes_base_classes
+ return ctypes_base_classes[ self.declaration.class_type ]
+
+ def _create_impl(self):
+ result = []
+ result.append( "class %(alias)s(ctypes.%(base)s):"
+ % dict( alias=self.alias, base=self.ctypes_base_class ) )
+ result.append( self.indent( '"""class %s"""' % self.decl_identifier ) )
+ if self.creators:
+ result.append( self.indent( '' ) )
+ result.append( compound.compound_t.create_internal_code( self.creators ) )
+
+ if isinstance( self.declaration.parent, declarations.namespace_t ) \
+ and self.declaration.parent is not self.declaration.top_parent: #not a global namespace
+ result.append("")
+ result.append( '%(ns_full_name)s = %(name)s'
+ % dict( ns_full_name=self.complete_py_name, name=self.alias ))
+ return os.linesep.join( result )
+
+ def _get_system_files_impl( self ):
+ return []
+
+
+class class_declaration_introduction_t(code_creator.code_creator_t, declaration_based.declaration_based_t):
+ def __init__( self, class_declaration ):
+ code_creator.code_creator_t.__init__(self)
+ declaration_based.declaration_based_t.__init__( self, class_declaration )
+
+ def _create_impl(self):
+ result = []
+ result.append( "class %s(ctypes.Structure):" % self.alias )
+ result.append( self.indent( '"""class declaration %s"""' % self.decl_identifier ) )
+ result.append( self.indent( '_fields_ = []' ) )
+
+ if isinstance( self.declaration.parent, declarations.namespace_t ) \
+ and self.declaration.parent is not self.declaration.top_parent: #not a global namespace
+ result.append( '%(ns_full_name)s = %(name)s'
+ % dict( ns_full_name=self.complete_py_name, name=self.alias ))
+ return os.linesep.join( result )
+
+ def _get_system_files_impl( self ):
+ return []
Deleted: pyplusplus_dev/pyplusplus/code_creators/class_introduction.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/class_introduction.py 2009-01-26 06:49:48 UTC (rev 1613)
+++ pyplusplus_dev/pyplusplus/code_creators/class_introduction.py 2009-01-26 06:55:33 UTC (rev 1614)
@@ -1,66 +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 compound
-import code_creator
-import declaration_based
-from pygccxml import declarations
-
-ctypes_base_classes = {
- declarations.CLASS_TYPES.CLASS : 'Structure'
- , declarations.CLASS_TYPES.UNION : 'Union'
- , declarations.CLASS_TYPES.STRUCT : 'Structure'
-}
-
-class class_introduction_t(compound.compound_t, declaration_based.declaration_based_t):
- def __init__( self, class_ ):
- compound.compound_t.__init__(self)
- declaration_based.declaration_based_t.__init__( self, class_ )
-
- @property
- def ctypes_base_class( self ):
- global ctypes_base_classes
- return ctypes_base_classes[ self.declaration.class_type ]
-
- def _create_impl(self):
- result = []
- result.append( "class %(alias)s(ctypes.%(base)s):"
- % dict( alias=self.alias, base=self.ctypes_base_class ) )
- result.append( self.indent( '"""class %s"""' % self.decl_identifier ) )
- if self.creators:
- result.append( self.indent( '' ) )
- result.append( compound.compound_t.create_internal_code( self.creators ) )
-
- if isinstance( self.declaration.parent, declarations.namespace_t ) \
- and self.declaration.parent is not self.declaration.top_parent: #not a global namespace
- result.append("")
- result.append( '%(ns_full_name)s = %(name)s'
- % dict( ns_full_name=self.complete_py_name, name=self.alias ))
- return os.linesep.join( result )
-
- def _get_system_files_impl( self ):
- return []
-
-
-class class_declaration_introduction_t(code_creator.code_creator_t, declaration_based.declaration_based_t):
- def __init__( self, class_declaration ):
- code_creator.code_creator_t.__init__(self)
- declaration_based.declaration_based_t.__init__( self, class_declaration )
-
- def _create_impl(self):
- result = []
- result.append( "class %s(ctypes.Structure):" % self.alias )
- result.append( self.indent( '"""class declaration %s"""' % self.decl_identifier ) )
- result.append( self.indent( '_fields_ = []' ) )
-
- if isinstance( self.declaration.parent, declarations.namespace_t ) \
- and self.declaration.parent is not self.declaration.top_parent: #not a global namespace
- result.append( '%(ns_full_name)s = %(name)s'
- % dict( ns_full_name=self.complete_py_name, name=self.alias ))
- return os.linesep.join( result )
-
- def _get_system_files_impl( self ):
- return []
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|