[pygccxml-commit] SF.net SVN: pygccxml:[1524] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2009-01-04 07:57:52
|
Revision: 1524
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1524&view=rev
Author: roman_yakovenko
Date: 2009-01-04 07:57:47 +0000 (Sun, 04 Jan 2009)
Log Message:
-----------
preparing unittests environment for ctypes testers
Modified Paths:
--------------
pyplusplus_dev/environment.py
pyplusplus_dev/unittests/autoconfig.py
pyplusplus_dev/unittests/ctypes_pof_tester.py
pyplusplus_dev/unittests/data/ctypes_pof/sconscript
pyplusplus_dev/unittests/fundamental_tester_base.py
Added Paths:
-----------
pyplusplus_dev/unittests/data/ctypes_pof/ctypes_pof.cpp
pyplusplus_dev/unittests/data/ctypes_pof/ctypes_pof.h
Removed Paths:
-------------
pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp
pyplusplus_dev/unittests/data/ctypes_pof/mydll.h
Modified: pyplusplus_dev/environment.py
===================================================================
--- pyplusplus_dev/environment.py 2009-01-03 19:48:47 UTC (rev 1523)
+++ pyplusplus_dev/environment.py 2009-01-04 07:57:47 UTC (rev 1524)
@@ -25,15 +25,11 @@
class scons:
suffix = ''
- cmd_build = ''
- cmd_clean = ''
+ cmd_build = 'scons'
+ cmd_clean = 'scons --clean'
ccflags = []
if 'roman' in getpass.getuser():
-
- scons.cmd_build = 'scons --file=%s'
- scons.cmd_clean = 'scons --clean --file=%s'
-
if sys.platform == 'win32':
scons.suffix = '.pyd'
scons.ccflags = ['/MD', '/EHsc', '/GR', '/Zc:wchar_t', '/Zc:forScope', '-DBOOST_PYTHON_NO_PY_SIGNATURES' ]
@@ -50,10 +46,6 @@
boost.include = '/home/roman/boost_svn'
python.include = '/usr/include/python2.5'
elif 'root' == getpass.getuser():
-
- scons.cmd_build = 'scons --file=%s'
- scons.cmd_clean = 'scons --clean --file=%s'
-
if sys.platform == 'win32':
scons.suffix = '.pyd'
scons.ccflags = ['/MD', '/EHsc', '/GR', '/Zc:wchar_t', '/Zc:forScope', '-DBOOST_PYTHON_NO_PY_SIGNATURES' ]
Modified: pyplusplus_dev/unittests/autoconfig.py
===================================================================
--- pyplusplus_dev/unittests/autoconfig.py 2009-01-03 19:48:47 UTC (rev 1523)
+++ pyplusplus_dev/unittests/autoconfig.py 2009-01-04 07:57:47 UTC (rev 1524)
@@ -7,9 +7,8 @@
import os
import sys
import unittest
+import subprocess
-#__pychecker__ = 'limit=1000'
-#import pychecker.checker
this_module_dir_path = os.path.abspath ( os.path.dirname( sys.modules[__name__].__file__) )
@@ -74,61 +73,32 @@
#~ , " env.AddPostAction(t, 'mt.exe -nologo -manifest %(target)s.pyd.manifest -outputresource:%(target)s.pyd;2' )" ]
return os.linesep.join( code )
+ @staticmethod
+ def compile( cmd ) :
+ print '\n', cmd
+ process = subprocess.Popen( args=cmd
+ , shell=True
+ , stdin=subprocess.PIPE
+ , stdout=subprocess.PIPE
+ , stderr=subprocess.STDOUT
+ , cwd=this_module_dir_path )
+ process.stdin.close()
+
+ while process.poll() is None:
+ line = process.stdout.readline()
+ print line.rstrip()
+ for line in process.stdout.readlines():
+ print line.rstrip()
+ if process.returncode:
+ raise RuntimeError( "unable to compile extension. error: %s" % scons_msg )
+
+
#I need this in order to allow Python to load just compiled modules
sys.path.append( build_dir )
os.chdir( build_dir )
-#~ if sys.platform == 'linux2':
- #~ LD_LIBRARY_PATH = 'LD_LIBRARY_PATH'
- #~ if not os.environ.has_key( LD_LIBRARY_PATH ) \
- #~ or not set( scons_config.libpath ).issubset( set( os.environ[LD_LIBRARY_PATH].split(':') ) ):
- #~ #see http://hathawaymix.org/Weblog/2004-12-30
- #~ print 'error: LD_LIBRARY_PATH has not been set'
if sys.platform == 'win32':
PATH = os.environ.get( 'PATH', '' )
PATH=PATH + ';' + ';'.join( scons_config.libpath )
os.environ['PATH'] = PATH
-
-
-#~ try:
- #~ import pydsc
- #~ pydsc.include( r'D:\pygccxml_sources\sources\pyplusplus_dev' )
- #~ pydsc.ignore( [ 'Yakovenko'
- #~ , 'Bierbaum'
- #~ , 'org'
- #~ , 'http'
- #~ , 'bool'
- #~ , 'str'
- #~ , 'www'
- #~ , 'param'
- #~ , 'txt'
- #~ , 'decl'
- #~ , 'decls'
- #~ , 'namespace'
- #~ , 'namespaces'
- #~ , 'enum'
- #~ , 'const'
- #~ , 'GCC'
- #~ , 'xcc'
- #~ , 'TODO'
- #~ , 'typedef'
- #~ , 'os'
- #~ , 'normcase'
- #~ , 'normpath'
- #~ , 'scopedef'
- #~ , 'ira'#part of Matthias mail address
- #~ , 'uka'#part of Matthias mail address
- #~ , 'de'#part of Matthias mail address
- #~ , 'dat'#file extension of directory cache
- #~ , 'config'#parameter description
- #~ , 'gccxml'#parameter description
- #~ , 'Py++'
- #~ , 'pygccxml'
- #~ , 'calldef'
- #~ , 'XXX'
- #~ , 'wstring'
- #~ , 'py'
- #~ ] )
-#~ except ImportError:
- #~ pass
Modified: pyplusplus_dev/unittests/ctypes_pof_tester.py
===================================================================
--- pyplusplus_dev/unittests/ctypes_pof_tester.py 2009-01-03 19:48:47 UTC (rev 1523)
+++ pyplusplus_dev/unittests/ctypes_pof_tester.py 2009-01-04 07:57:47 UTC (rev 1524)
@@ -11,35 +11,52 @@
from pyplusplus.module_builder import ctypes_module_builder_t
class tester_t(unittest.TestCase):
+ _module_ref_ = None
def __init__( self, *args, **keywd ):
unittest.TestCase.__init__( self, *args, **keywd )
- self.project_dir = os.path.join( autoconfig.data_directory, 'ctypes_pof' )
- self.header = os.path.join( self.project_dir, 'mydll.h' )
- self.symbols_file = os.path.join( self.project_dir, 'release', 'mydll.dll' )
- self.module_name = 'ctypes_pof'
+ self.base_name = 'ctypes_pof'
- def test(self):
+ @property
+ def project_dir( self ):
+ return os.path.join( autoconfig.data_directory, self.base_name )
+
+ @property
+ def header( self ):
+ return os.path.join( self.project_dir, self.base_name + '.h' )
+
+ @property
+ def symbols_file( self ):
+ return os.path.join( self.project_dir, 'binaries', self.base_name + '.dll' )
+
+ def setUp( self ):
+ if tester_t._module_ref_:
+ return
+
+ autoconfig.scons_config.compile( autoconfig.scons.cmd_build + ' ctypes_pof' )
mb = ctypes_module_builder_t( [self.header], self.symbols_file, autoconfig.cxx_parsers_cfg.gccxml )
- #~ mb.print_declarations()
mb.build_code_creator( self.symbols_file )
mb.write_module( os.path.join( autoconfig.build_directory, self.module_name + '.py' ) )
- #mb.code_creator.create()
- sys.path.append( autoconfig.build_directory )
- import ctypes_pof
+ tester_t._module_ref_ = __import__( os.path.join( autoconfig.build_directory, self.base_name + '.py' ) )
- #the following code fails - difference in the calling conventions
- #TODO: the following test failes, because of the wrong calling convention used
- #self.failUnless( ctypes_pof.identity_cpp( int(111) ) == 111 )
+ @property
+ def module_ref(self):
+ return self._module_ref_
- #testing constructors
- n0 = ctypes_pof.pof.number_t()
+ def test_constructors(self):
+ n0 = self.module_ref.pof.number_t()
self.failUnless( 0 == n0.get_value() )
- n1 = ctypes_pof.pof.number_t( ctypes.c_long(32) )
+ n1 = self.module_ref.pof.number_t( ctypes.c_long(32) )
self.failUnless( 32 == n1.get_value() )
- n2 = ctypes_pof.pof.number_t( ctypes.pointer(n1) )
+ n2 = self.module_ref.pof.number_t( ctypes.pointer(n1) )
self.failUnless( 32 == n2.get_value() )
- #testing get/set 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() )
@@ -58,12 +75,12 @@
#~ self.fail( obj1.get_value() == obj2.get_value() )
- #~ def test_bsc( self ):
- #~ root = r'E:\Documents and Settings\romany\Desktop\ToInstall\bsckit70\bscsdk'
- #~ mb = ctypes_module_builder_t( [os.path.join( root, 'bsc.h' )]
- #~ , os.path.join( root, 'msbsc70.dll' ), autoconfig.cxx_parsers_cfg.gccxml )
- #~ mb.build_code_creator( self.symbols_file )
- #~ mb.write_module( os.path.join( root, 'bsc.py' ) )
+ def test_bsc( self ):
+ root = r'E:\Documents and Settings\romany\Desktop\ToInstall\bsckit70\bscsdk'
+ mb = ctypes_module_builder_t( [os.path.join( root, 'bsc.h' )]
+ , os.path.join( root, 'msbsc70.dll' ), autoconfig.cxx_parsers_cfg.gccxml )
+ mb.build_code_creator( self.symbols_file )
+ mb.write_module( os.path.join( root, 'bsc.py' ) )
def create_suite():
Copied: pyplusplus_dev/unittests/data/ctypes_pof/ctypes_pof.cpp (from rev 1523, pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp)
===================================================================
--- pyplusplus_dev/unittests/data/ctypes_pof/ctypes_pof.cpp (rev 0)
+++ pyplusplus_dev/unittests/data/ctypes_pof/ctypes_pof.cpp 2009-01-04 07:57:47 UTC (rev 1524)
@@ -0,0 +1,69 @@
+#include "ctypes_pof.h"
+#include "windows.h"
+#include <iostream>
+
+namespace pof{
+
+number_t::number_t()
+: m_value(0)
+{
+// std::cout << "{C++} number_t( 0 )" << std::endl;
+}
+
+
+number_t::number_t(int value)
+: m_value(value)
+{
+// std::cout << "{C++} number_t( " << value << " )" << std::endl;
+}
+
+number_t::~number_t() {
+// std::cout << "{C++} ~number_t()" << std::endl;
+}
+void number_t::print_it() const {
+ std::cout << "{C++} value: " << m_value << std::endl;
+}
+
+int number_t::get_value() const{
+ return m_value;
+}
+
+void number_t::set_value(int x){
+ m_value = x;
+}
+
+number_t number_t::clone() const{
+ return number_t(*this);
+}
+
+std::auto_ptr<number_t> number_t::clone_ptr() const{
+ return std::auto_ptr<number_t>( new number_t( *this ) );
+}
+
+}
+
+using namespace pof;
+
+void do_smth( number_aptr_t& ){
+}
+
+int identity( int some_data){ return some_data;}
+
+int identity_cpp( int data){ return data; }
+
+//~ BOOL APIENTRY DllMain( HMODULE hModule,
+ //~ DWORD ul_reason_for_call,
+ //~ LPVOID lpReserved
+ //~ )
+//~ {
+ //~ switch (ul_reason_for_call)
+ //~ {
+ //~ case DLL_PROCESS_ATTACH:
+ //~ case DLL_THREAD_ATTACH:
+ //~ case DLL_THREAD_DETACH:
+ //~ case DLL_PROCESS_DETACH:
+ //~ break;
+ //~ }
+ //~ return TRUE;
+//~ }
+
Copied: pyplusplus_dev/unittests/data/ctypes_pof/ctypes_pof.h (from rev 1523, pyplusplus_dev/unittests/data/ctypes_pof/mydll.h)
===================================================================
--- pyplusplus_dev/unittests/data/ctypes_pof/ctypes_pof.h (rev 0)
+++ pyplusplus_dev/unittests/data/ctypes_pof/ctypes_pof.h 2009-01-04 07:57:47 UTC (rev 1524)
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <memory>
+
+namespace pof{
+
+class __declspec(dllexport) number_t{
+public:
+ number_t();
+ explicit number_t(int value);
+ virtual ~number_t();
+ virtual void print_it() const;
+ int get_value() const;
+ int get_value(){ return m_value; }
+ void set_value(int x);
+
+ number_t clone() const;
+ std::auto_ptr<number_t> clone_ptr() const;
+private:
+ int m_value;
+};
+
+}
+template class __declspec(dllexport) std::auto_ptr< pof::number_t >;
+
+typedef std::auto_ptr< pof::number_t > number_aptr_t;
+
+void __declspec(dllexport) do_smth( number_aptr_t& );
+
+extern "C"{
+
+int __declspec(dllexport) identity( int );
+
+}
+
+int __declspec(dllexport) identity_cpp( int );
\ No newline at end of file
Deleted: pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp
===================================================================
--- pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp 2009-01-03 19:48:47 UTC (rev 1523)
+++ pyplusplus_dev/unittests/data/ctypes_pof/mydll.cpp 2009-01-04 07:57:47 UTC (rev 1524)
@@ -1,69 +0,0 @@
-#include "mydll.h"
-#include "windows.h"
-#include <iostream>
-
-namespace pof{
-
-number_t::number_t()
-: m_value(0)
-{
-// std::cout << "{C++} number_t( 0 )" << std::endl;
-}
-
-
-number_t::number_t(int value)
-: m_value(value)
-{
-// std::cout << "{C++} number_t( " << value << " )" << std::endl;
-}
-
-number_t::~number_t() {
-// std::cout << "{C++} ~number_t()" << std::endl;
-}
-void number_t::print_it() const {
- std::cout << "{C++} value: " << m_value << std::endl;
-}
-
-int number_t::get_value() const{
- return m_value;
-}
-
-void number_t::set_value(int x){
- m_value = x;
-}
-
-number_t number_t::clone() const{
- return number_t(*this);
-}
-
-std::auto_ptr<number_t> number_t::clone_ptr() const{
- return std::auto_ptr<number_t>( new number_t( *this ) );
-}
-
-}
-
-using namespace pof;
-
-void do_smth( number_aptr_t& ){
-}
-
-int identity( int some_data){ return some_data;}
-
-int identity_cpp( int data){ return data; }
-
-BOOL APIENTRY DllMain( HMODULE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
-{
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
-}
-
Deleted: pyplusplus_dev/unittests/data/ctypes_pof/mydll.h
===================================================================
--- pyplusplus_dev/unittests/data/ctypes_pof/mydll.h 2009-01-03 19:48:47 UTC (rev 1523)
+++ pyplusplus_dev/unittests/data/ctypes_pof/mydll.h 2009-01-04 07:57:47 UTC (rev 1524)
@@ -1,36 +0,0 @@
-#pragma once
-
-#include <memory>
-
-namespace pof{
-
-class __declspec(dllexport) number_t{
-public:
- number_t();
- explicit number_t(int value);
- virtual ~number_t();
- virtual void print_it() const;
- int get_value() const;
- int get_value(){ return m_value; }
- void set_value(int x);
-
- number_t clone() const;
- std::auto_ptr<number_t> clone_ptr() const;
-private:
- int m_value;
-};
-
-}
-template class __declspec(dllexport) std::auto_ptr< pof::number_t >;
-
-typedef std::auto_ptr< pof::number_t > number_aptr_t;
-
-void __declspec(dllexport) do_smth( number_aptr_t& );
-
-extern "C"{
-
-int __declspec(dllexport) identity( int );
-
-}
-
-int __declspec(dllexport) identity_cpp( int );
\ No newline at end of file
Modified: pyplusplus_dev/unittests/data/ctypes_pof/sconscript
===================================================================
--- pyplusplus_dev/unittests/data/ctypes_pof/sconscript 2009-01-03 19:48:47 UTC (rev 1523)
+++ pyplusplus_dev/unittests/data/ctypes_pof/sconscript 2009-01-04 07:57:47 UTC (rev 1524)
@@ -1,6 +1,9 @@
Import('*')
-t = env.SharedLibrary( target=r'mydll'
- , source=[ r'mydll.cpp' ]
- , CCFLAGS=[ r"/MD",r"/EHsc",r"/GR",r"/Zc:wchar_t",r"/Zc:forScope" ]
- , LINKFLAGS=[r"/MAP:${TARGET.base}.map", r"/MAPINFO:EXPORTS"] )
+target_name = 'ctypes_pof'
+shlib = env.SharedLibrary( target=target_name
+ , source=[ target_name + '.cpp' ]
+ , CCFLAGS=[ r"/MD",r"/EHsc",r"/GR",r"/Zc:wchar_t",r"/Zc:forScope" ]
+ , LINKFLAGS=[r"/MAP:${TARGET.base}.map", r"/MAPINFO:EXPORTS"] )
+
+env.Alias( target_name, shlib )
Modified: pyplusplus_dev/unittests/fundamental_tester_base.py
===================================================================
--- pyplusplus_dev/unittests/fundamental_tester_base.py 2009-01-03 19:48:47 UTC (rev 1523)
+++ pyplusplus_dev/unittests/fundamental_tester_base.py 2009-01-04 07:57:47 UTC (rev 1524)
@@ -128,24 +128,6 @@
sconstruct_file.write( sconstruct_script )
sconstruct_file.close()
- def _create_extension(self):
- cmd = autoconfig.scons.cmd_build % self.__generated_scons_file_name
- print cmd
- output = os.popen( cmd )
- scons_reports = []
- while True:
- data = output.readline()
- scons_reports.append( data )
- if not data:
- break
- exit_status = output.close()
- scons_msg = ''.join(scons_reports)
- if scons_msg:
- print os.linesep
- print scons_msg
- if exit_status:
- raise RuntimeError( "unable to compile extension. error: %s" % scons_msg )
-
def _clean_build( self, sconstruct_file ):
cmd = autoconfig.scons.cmd_clean % sconstruct_file
output = os.popen( cmd )
@@ -166,7 +148,7 @@
self._create_extension_source_file()
sources = self.get_source_files()
self._create_sconstruct(sources)
- self._create_extension()
+ autoconfig.scons_config.compile( autoconfig.scons.cmd_build + ' --file=%s' % self.__generated_scons_file_name )
pypp = __import__( self.__module_name )
self.run_tests(pypp)
finally:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|