Update of /cvsroot/pygccxml/source/pyplusplus/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15169/pyplusplus/gui
Modified Files:
ui.py wizard.py
Log Message:
fixing UI & wizard
adding __str__ to call policies
Index: ui.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pyplusplus/gui/ui.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** ui.py 22 Mar 2006 06:35:41 -0000 1.20
--- ui.py 22 Mar 2006 08:05:35 -0000 1.21
***************
*** 292,297 ****
config.include_paths.append( os.path.split( header_file )[0] )
config.working_directory = os.path.split( header_file )[0]
! w = wizard.wizard_t( config, header_file, wizard.FILTER_TYPE.FROM_FILE_AND_DIR )
! self._generated_code.set_generated_code( w.code_advanced() )
def _create_xml( self ):
--- 292,297 ----
config.include_paths.append( os.path.split( header_file )[0] )
config.working_directory = os.path.split( header_file )[0]
! w = wizard.wizard_t( config, header_file )
! self._generated_code.set_generated_code( w.create_code() )
def _create_xml( self ):
Index: wizard.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pyplusplus/gui/wizard.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** wizard.py 24 Jan 2006 05:46:29 -0000 1.2
--- wizard.py 22 Mar 2006 08:05:35 -0000 1.3
***************
*** 1,12 ****
! _ADVANCED_TEMPLATE_ = \
"""
import os
from pygccxml import parser
! from pygccxml import declarations
! from pyplusplus import code_creators
! from pyplusplus import module_creator
! from pyplusplus import file_writers
! #Step 1. Configurate GCC-XML parser
parser_configuration = parser.config_t(
#path to GCC-XML binary
--- 1,10 ----
! CODE_TEMPLATE = \
"""
import os
from pygccxml import parser
! from pyplusplus import module_builder
! #Configurating GCC-XML parser
! #Basically you should copy here your makefile configuration
parser_configuration = parser.config_t(
#path to GCC-XML binary
***************
*** 14,150 ****
, working_directory=r"%(working_dir)s"
, include_paths=%(include_paths)s
! , define_symbols=%(define_symbols)s
! , undefine_symbols=%(undefine_symbols)s )
!
! #Step 2. Create project_reader_t or source_reader_t class instance
! #Later, these instance will be used to read all declarations from source files.
! #more information about project_reader_t or source_reader_t you can find in
! #pygccxml project documentation.
! project_reader = parser.project_reader_t( parser_configuration )
!
! #project_reader_t is able to read declarations from different sources:
! # regular source files
! # GCC-XML created files, if you generate them once you will not pay for
! # compilation process
! # string or text, that contains valid C++ code.
! #You do not have to create file_configuration_t instance for regular source
! #files, you can pass them as is ( path(string) to file ).
! file_configuration = parser.file_configuration_t(
! r"%(file_path)s"
! , content_type=parser.CONTENT_TYPE.STANDARD_SOURCE_FILE )
!
! #Step 3. Read all declarations from source files. As input read_files takes a list
! #that contains file_configuration_t instances and\or strings( paths to files ).
! declarations_all = project_reader.read_files( [ file_configuration ] )
!
! #Step 4. Decide what declarations you want to export. This step is very
! #important, because GCC-XML reads all declarations found in your file and files
! #included from it. You can filter declarations by phisical(files or directories)
! #or logical (namespaces ) locations. Also you can create custom filter.
! to_be_exported = declarations.filtering.by_location( declarations_all, [file_configuration.data] )
!
! #Step 5. Now, after you work so hard, it is the time to give pyplusplus to work.
! #This is the step, where pyplusplus creates "code creators tree". During this
! #step for every declaration will be created one or more code creators.
! extmodule = module_creator.create( decls=to_be_exported, module_name="pyplusplus", recursive=False )
!
! #Step 6. Customization time. Nobody is perfect, pyplusplus too. No it is the time
! #to customize yet generated code. During this step you can change almost every
! #piece of code, that is going to be generated. In my case I add user defined
! #directories, thus allowing pyplusplus to generate nice( shorter ) include
! #directives.
! extmodule.user_defined_directories.extend( parser_configuration.include_paths )
! extmodule.license = "//Boost Software License - Version 1.0 - August 17th, 2003"
!
! #Just printing the code
! print extmodule.create()
! #Step 6. To write all code into files.
! file_writers.write_file( extmodule, 'bindings.cpp' )
! #It is also possible to split extention module source code into multiple files.
! #You can uncomment next line and to see what will happen
! #file_writers.write_multiple_files( extmodule, '.' )
! print 'done'
! """
! _SIMPLE_TEMPLATE_ = \
! """
! import os
! from pygccxml import parser
! from pygccxml import declarations
! from pyplusplus import code_creators
! from pyplusplus import module_creator
! from pyplusplus import file_writers
! #configurating parser
! parser_configuration = parser.config_t(
! #path to GCC-XML binary
! gccxml_path=r"%(gccxml_path)s"
! , working_directory=r"%(working_dir)s"
! , include_paths=%(include_paths)s
! , define_symbols=%(define_symbols)s
! , undefine_symbols=%(undefine_symbols)s )
- #reading all declarations
- decls_all = parser.parse( [r"%(file_path)s"], parser_configuration )
- #filtering declarations
- decls = declarations.filtering.by_location( decls_all, [parser_configuration.working_directory] )
- #creating code creators tree
- extmodule = module_creator.create( decls=decls, module_name="pyplusplus",recursive=False )
- #customazing extmodule
- extmodule.license = "//Boost Software License - Version 1.0 - August 17th, 2003"
- extmodule.user_defined_directories.append( parser_configuration.working_directory )
- print extmodule.create()
- #writing extmodule to single file
- file_writers.write_file( extmodule, 'bindings.cpp' )
- print 'done'
"""
-
- class FILTER_TYPE:
- FROM_FILE_ONLY = "all declarations from header"
- FROM_FILE_AND_DIR = "all declarations from header and it's directory"
- FROM_NAMESPACE = "all declarations from namespace"
-
class wizard_t( object ):
def __init__( self
, parser_configuration
! , source_file
! , filter_type
! , namespace_name=None):
! global _ADVANCED_TEMPLATE_
! global _SIMPLE_TEMPLATE_
object.__init__( self )
- self._advanced_template = _ADVANCED_TEMPLATE_
- self._simple_template = _SIMPLE_TEMPLATE_
self._parser_configuration = parser_configuration
self._source_file = source_file
- self._filter_type = filter_type
- self._namespace_name = namespace_name
- if not self._namespace_name:
- self._namespace_name = ""
! def code_advanced( self ):
! return self._advanced_template % {
! 'gccxml_path' : self._parser_configuration.gccxml_path
! , 'working_dir' : self._parser_configuration.working_directory
! , 'include_paths' : `self._parser_configuration.include_paths`
! , 'define_symbols' : `self._parser_configuration.define_symbols`
! , 'undefine_symbols' : `self._parser_configuration.undefine_symbols`
! , "file_path" : self._source_file
! , "filter_type" : self._filter_type
! , "namespace_name" : self._namespace_name
! }
!
! def code_simple( self ):
! return self._simple_template % {
'gccxml_path' : self._parser_configuration.gccxml_path
, 'working_dir' : self._parser_configuration.working_directory
, 'include_paths' : `self._parser_configuration.include_paths`
, 'define_symbols' : `self._parser_configuration.define_symbols`
- , 'undefine_symbols' : `self._parser_configuration.undefine_symbols`
, "file_path" : self._source_file
- , "namespace_name" : self._namespace_name
}
--- 12,47 ----
, working_directory=r"%(working_dir)s"
, include_paths=%(include_paths)s
! , define_symbols=%(define_symbols)s )
! #Creating an instance of class that will help you to expose your declarations
! mb = module_builder.module_builder_t( [r"%(file_path)s"], parser_configuration )
! #Well, don't you want to see what is going on?
! mb.print_declarations()
! #Creating code creator. After this step you should not modify/customize declarations.
! mb.build_code_creator( module_name='pyplusplus' )
! #Writing code to file.
! mb.write_module( './bindings.cpp' )
"""
class wizard_t( object ):
def __init__( self
, parser_configuration
! , source_file ):
object.__init__( self )
self._parser_configuration = parser_configuration
self._source_file = source_file
! def create_code( self ):
! global CODE_TEMPLATE
! return CODE_TEMPLATE % {
'gccxml_path' : self._parser_configuration.gccxml_path
, 'working_dir' : self._parser_configuration.working_directory
, 'include_paths' : `self._parser_configuration.include_paths`
, 'define_symbols' : `self._parser_configuration.define_symbols`
, "file_path" : self._source_file
}
|