Revision: 208
Author: roman_yakovenko
Date: 2006-06-04 20:57:03 -0700 (Sun, 04 Jun 2006)
ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=208&view=rev
Log Message:
-----------
updating examples
Modified Paths:
--------------
pyplusplus_dev/examples/custom_code_creator/generate_code.py
pyplusplus_dev/examples/custom_code_creator/sconstruct
pyplusplus_dev/examples/pyboost_dev/sconstruct
Added Paths:
-----------
pyplusplus_dev/examples/custom_code_creator/generated/properties.py.cpp
Removed Paths:
-------------
pyplusplus_dev/examples/custom_code_creator/environment.py
Deleted: pyplusplus_dev/examples/custom_code_creator/environment.py
===================================================================
--- pyplusplus_dev/examples/custom_code_creator/environment.py 2006-06-05 03:36:47 UTC (rev 207)
+++ pyplusplus_dev/examples/custom_code_creator/environment.py 2006-06-05 03:57:03 UTC (rev 208)
@@ -1,57 +0,0 @@
-#! /usr/bin/python
-# Copyright 2004 Roman Yakovenko.
-# Distributed under the Boost Software License, Version 1.0. (See
-# accompanying file LICENSE_1_0.txt or copy at
-# http://www.boost.org/LICENSE_1_0.txt)
-
-import sys
-
-class settings:
- module_name = 'properties'
- boost_path = ''
- boost_libs_path = ''
- gccxml_path = ''
- pygccxml_path = ''
- pyplusplus_path = ''
- sources_path = ''
- python_libs_path = ''
- python_include_path = ''
- working_dir = ''
- generated_files_dir = ''
- unittests_dir = ''
-
- def setup_environment():
- sys.path.append( settings.pygccxml_path )
- sys.path.append( settings.pyplusplus_path )
- setup_environment = staticmethod(setup_environment)
-
-if sys.platform == 'linux2':
- settings.boost_path = '/home/roman/boost_cvs'
- settings.boost_libs_path = '/home/roman/boost_cvs/bin'
- settings.gccxml_path = '/home/roman/gccxml/bin/gccxml'
- settings.pygccxml_path = '/home/roman/pygccxml_sources/source'
- settings.pyplusplus_path = '/home/roman/pygccxml_sources/source'
- settings.python_include_path = '/usr/include/python2.3'
-
- settings.sources_path = '/home/roman/pygccxml_sources/source/pyplusplus/examples/custom_code_creator'
- settings.working_dir = '/home/roman/pygccxml_sources/source/pyplusplus/examples/custom_code_creator'
- settings.generated_files_dir = '/home/roman/pygccxml_sources/source/pyplusplus/examples/custom_code_creator/generated'
- settings.unittests_dir = '/home/roman/pygccxml_sources/source/pyplusplus/examples/custom_code_creator/unittests'
-elif sys.platform == 'win32':
- settings.boost_path = 'd:/boost_cvs'
- settings.boost_libs_path = 'd:/boost_cvs/bin'
- settings.gccxml_path = 'c:/tools/gcc_xml/bin'
- settings.pygccxml_path = 'd:/pygccxml_sources/source'
- settings.pyplusplus_path = 'd:/pygccxml_sources/source'
- settings.python_libs_path = 'c:/python/libs'
- settings.python_include_path = 'c:/python/include'
-
- settings.sources_path = 'd:/pygccxml_sources/source/pyplusplus/examples/custom_code_creator'
- settings.working_dir = 'd:/pygccxml_sources/source/pyplusplus/examples/custom_code_creator'
- settings.generated_files_dir = 'd:/pygccxml_sources/source/pyplusplus/examples/custom_code_creator/generated'
- settings.unittests_dir = 'd:/pygccxml_sources/source/pyplusplus/examples/custom_code_creator/unittests'
-
-else:
- raise RuntimeError( 'There is no configuration for "%s" platform.' % sys.platform )
-
-settings.setup_environment()
\ No newline at end of file
Modified: pyplusplus_dev/examples/custom_code_creator/generate_code.py
===================================================================
--- pyplusplus_dev/examples/custom_code_creator/generate_code.py 2006-06-05 03:36:47 UTC (rev 207)
+++ pyplusplus_dev/examples/custom_code_creator/generate_code.py 2006-06-05 03:57:03 UTC (rev 208)
@@ -16,8 +16,10 @@
reference to parent code creator ( we can safely omit this argument )
"""
-import os
-from environment import settings
+import os
+import sys
+sys.path.append( '../..' )
+from environment import gccxml
from pygccxml import declarations
from pyplusplus import code_creators
from pyplusplus import module_builder
@@ -71,14 +73,14 @@
prop_creator = property_creator_t( get_creator.declaration, set_creator.declaration )
class_creator.adopt_creator( prop_creator )
-if __name__ == '__main__':
+if __name__ == '__main__':
+ module_name = 'properties'
#1. creating module builder
- mb = module_builder.module_builder_t( files=['properties.hpp']
- , gccxml_path=settings.gccxml_path
- , working_directory=settings.sources_path )
+ mb = module_builder.module_builder_t( files=['properties.hpp']
+ , gccxml_path=gccxml.executable )
#2. creating module code creator
- mb.build_code_creator( module_name=settings.module_name )
- mb.code_creator.user_defined_directories.append( settings.working_dir )
+ mb.build_code_creator( module_name=module_name )
+ mb.code_creator.user_defined_directories.append( os.path.abspath( '.' ) )
#3. replacing get/set code creators with property code creator
classes = filter( lambda creator: isinstance( creator, code_creators.class_t )
@@ -86,6 +88,6 @@
map( replace_functions, classes )
#4. writing module to disk
- mb.write_module( os.path.join( settings.generated_files_dir, settings.module_name + '.py.cpp') )
+ mb.write_module( os.path.join( os.path.abspath( '.' ), 'generated', module_name + '.py.cpp') )
print 'done'
\ No newline at end of file
Added: pyplusplus_dev/examples/custom_code_creator/generated/properties.py.cpp
===================================================================
--- pyplusplus_dev/examples/custom_code_creator/generated/properties.py.cpp (rev 0)
+++ pyplusplus_dev/examples/custom_code_creator/generated/properties.py.cpp 2006-06-05 03:57:03 UTC (rev 208)
@@ -0,0 +1,23 @@
+// This file has been generated by pyplusplus.
+
+#include "boost/python.hpp"
+
+#include "properties.hpp"
+
+namespace bp = boost::python;
+
+BOOST_PYTHON_MODULE(properties){
+ bp::class_< geometry::point_t >( "point_t", bp::init< bp::optional< int, int > >(( bp::arg("x")=0, bp::arg("y")=0 ))[bp::default_call_policies()] )
+ .add_property( "y", &::geometry::point_t::get_y, &::geometry::point_t::set_y )
+ .add_property( "x", &::geometry::point_t::get_x, &::geometry::point_t::set_x );
+
+ bp::def("extract_y"
+ , &::geometry::extract_y
+ , ( bp::arg("pt") )
+ , bp::default_call_policies() );
+
+ bp::def("extract_x"
+ , &::geometry::extract_x
+ , ( bp::arg("pt") )
+ , bp::default_call_policies() );
+}
Modified: pyplusplus_dev/examples/custom_code_creator/sconstruct
===================================================================
--- pyplusplus_dev/examples/custom_code_creator/sconstruct 2006-06-05 03:36:47 UTC (rev 207)
+++ pyplusplus_dev/examples/custom_code_creator/sconstruct 2006-06-05 03:57:03 UTC (rev 208)
@@ -3,35 +3,27 @@
# 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
-from environment import settings
+import sys
+sys.path.append( './../..' )
+import environment
-def get_shlibsuffix():
- if sys.platform == 'win32':
- return '.pyd'
- else:
- return '.so'
+env = Environment(
+ LIBS=['boost_python']
+ , LIBPATH=[ environment.boost.libs, environment.python.libs ]
+ , CPPPATH=[ environment.boost.include, environment.python.include, '#.' ]
+ , SHLIBPREFIX=''
+ , SHLIBSUFFIX=environment.scons.suffix
+)
+
+if sys.platform == 'win32':
+ env.Replace( no_import_lib=1 )
+ env.Append( CCFLAGS='/EHsc' )
+else:
+ env.Append( CCFLAGS=' -Os -fPIC -fvisibility=hidden' )
-def get_ccflags():
- if sys.platform == 'win32':
- return ['/MD', '/EHsc' , '/GR' ]
- else:
- return []
-
-def get_target():
- return os.path.join( settings.unittests_dir, settings.module_name + get_shlibsuffix() )
-
-SharedLibrary( target=get_target()
- , source=[ 'generated/properties.py.cpp' ]
- , LIBS=[ 'boost_python', ]
- , LIBPATH=[ settings.boost_libs_path, settings.python_libs_path ]
- , CPPPATH=[ settings.boost_path
- , settings.working_dir
- , settings.sources_path
- , settings.python_include_path ]
- , CCFLAGS=get_ccflags()
- , SHLIBPREFIX=''
- , SHLIBSUFFIX=get_shlibsuffix()
-)
+properties = env.SharedLibrary( target='properties'
+ , source=[ 'generated/properties.py.cpp' ] )
+
+env.Install( '#unittests', properties )
\ No newline at end of file
Modified: pyplusplus_dev/examples/pyboost_dev/sconstruct
===================================================================
--- pyplusplus_dev/examples/pyboost_dev/sconstruct 2006-06-05 03:36:47 UTC (rev 207)
+++ pyplusplus_dev/examples/pyboost_dev/sconstruct 2006-06-05 03:57:03 UTC (rev 208)
@@ -18,6 +18,7 @@
if sys.platform == 'win32':
env.Replace( no_import_lib=1 )
+ env.Append( CCFLAGS='/EHsc' )
else:
env.Append( CCFLAGS=' -Os -fPIC -fvisibility=hidden' )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|