Remove support for supportPrint() etc as the tp_print field is being removed from python either in 3.8 or 3.9.
Version: 7.1.2 (4-Mar-2019)
Fix problem with compiling for Python 2 and
the _Py_PackageContext symbol.
Merge Fedora's patch for setup.py
Version: 7.1.1 (18-Feb-2019)
Add exception errorType() and errorValue() function to access
the type and value of an exception.
Version: 7.1.0 (24-August-2018)
Add support for Py_LIMITED_API aka PEP-384
Version: 7.0.3 (23-April-2017)
Update Py::Long to support long long consitently between Python2 and Python3.
Version: 7.0.2 (16-April-2017)
Add Py::Char ord() method to return the long value of a character.
Fix String::size() that could return twice the actual length.
This affected as_ucs4string() which would return a string with
its second half as uninitialised memory.
Fix setup.py for the Demo code to build all the required C++
code.
Version: 7.0.1 (29-Aug-2016)
Add extra methods to Py::String that as needed on Windows to support full unicode range of code points.
On Windows Python defines Py_UNICODE as unsigned short, which is too small to hold all Unicode values.
PyCXX has added to the Py::String API to support creationg from Py_UCS4 strings and converting Py::String() into Py::ucs4string objects.
Fix validate for Bytes to use the correct check function.
Version 7.0.0 (15-Aug-2016)
Warning: This version fixes a number of problems that require source incompatible changes.
However by defining PYCXX_6_2_COMPATIBILITY the V6.2.x API is restored.
This is not recommended for new code.
The first version of python3 that is supported is 3.3.
A special thanks goes to Benjamin Webb, working at the US Army
Engineer Research and Development Center, who has contributed to
the design and testing of this release. 7.0.0 is better for his work.
New source file needs to built: Src/cxx_exceptions.cxx.
This file implements the new exception handling features.
Fix the type used for lengths and sequence indexes to use Py_ssize_t.
This will require sources changes for users of PyCXX.
Implement smart handling of Exceptions between C++ and Python.
You can now catch exceptions in C++ by type that are raised in C++ or Python.
All builtin exceptions are support and are user defined exceptions.
The base exception type is now BaseException not Exception.
To upgrade source code replace all use of Exception with BaseException.
The documentation has been updated to describe the new exception features.
The supportSequence, supportMapping, supportNumber etc functions
now take a bit mask that defines which specific callbacks are handled.
Version 6.2.8 (10-May-2016)
Fix crash when a member function is called via callMemberFunction() and that function raises an expection.
Found in comment on StackOverFlow. Fix memory size allocated for new objects. It used the wrong size calculation, but was big enough to avoid problems.
Version 6.2.7 (28-Apr-2016)
Fix missing ptr__Unicode_Type.
Fixes from learn0more@gmail.com make python2 also remember the m_module and add accessor functions.
Fix for indirection issues from Vivian De Smedt.
Update to work with latest Microsoft Visual C++ for python 2.7. All test run in Win32 and Win64.
PyCXX.html documention has been updated, especially with 2TO3 information.
Use delete[] for objects allocated with new[].
Version 6.2.6 (04-Jan-2015)
Fix build issue with GCC 4.2.1 on FreeBSD and Mac OS X (stop python defining isspace as a macro).
Remove support for python 3.1 (API's are unstable).
Add Python 3.3 support.
Patch from Michael Droettboom to fix compilation issues.
Patch from Michael Droettboom to add buffer interface for python3.
Version 6.2.4 (3-Mar-2012)
Fix memory leak in string encode and decode functions
Fix indirect python loading on windows - Bool_type was missing
Version 6.2.3 (11-Mar-2011)
Version 6.2.2 (26-Dec-2010)
Fix problem compiling against Python 3.1.3
Version 6.2.1 (3-May-2010)
Fix problems with new style classes
Replace all example makefile and project files with setup_makefile.py script.
Add APIs to make calling python functions easier. See TupleN(), callOnSelf(), self()
Version 6.1.1 (26-Sep-2009)
Supports Python 3 starting at Python 3.1 and Python 2
Code clean up to fix compiler warnings reported by gcc 4.2.1 on Mac OS X when building for Python 3.
Version 6.1.0 (19-Jul-2009)
Support Python 3 and Python 2
pycxx-7.1.4/build-limited-api.sh 000755 000765 000024 00000001045 13347675176 017035 0 ustar 00barry staff 000000 000000 #!/bin/bash
set -x
set -e
set -o pipefail
PYTHON=${1? python exe}
API=${2? api version}
case "$( uname )" in
Darwin)
OS=macosx
;;
Linux):
OS=linux
;;
*)
echo Unknown OS assuming Linux
OS=linux
;;
esac
PYTHON_BASE=$(basename ${PYTHON})
${PYTHON} setup_makefile.py ${OS} tmp-${PYTHON_BASE}-limited-api.mak --limited-api=${API}
make -f tmp-${PYTHON_BASE}-limited-api.mak clean 2>&1 | tee tmp-${PYTHON_BASE}-limited-api.log
make -f tmp-${PYTHON_BASE}-limited-api.mak test 2>&1 | tee -a tmp-${PYTHON_BASE}-limited-api.log
pycxx-7.1.4/build-all.sh 000755 000765 000024 00000001005 13305260623 015360 0 ustar 00barry staff 000000 000000 #!/bin/bash
set -x
set -e
set -o pipefail
for PYTHON in \
python2.6 \
python2.7 \
python3.3 \
python3.4 \
python3.5 \
python3.6 \
python3.7 \
python3.8 \
python3.9 \
;
do
if which $PYTHON >/dev/null
then
echo "Info: Found ${PYTHON}"
./build-unlimited-api.sh ${PYTHON}
case "${PYTHON}" in
python3.3)
;;
python3.*)
./build-limited-api.sh ${PYTHON} ${PYTHON#python}
;;
esac
fi
done
pycxx-7.1.4/setup.py 000755 000765 000024 00000004741 13437177573 014724 0 ustar 00barry staff 000000 000000 import os, sys
from glob import glob
from distutils.command.install import install
from distutils.command.install_headers import install_headers
from distutils.core import setup
# either "Python2" or "Python3"
python_ver = "Python" + sys.version[0]
headers = [
(None, glob( os.path.join( "CXX", "*.hxx" ) ) + glob( os.path.join( "CXX", "*.h" ) )),
(python_ver, glob( os.path.join( "CXX", python_ver, "*.hxx" ) ))
]
sources = [
("CXX", glob( os.path.join( "Src", "*.cxx" ) ) + glob( os.path.join( "Src", "*.c" ) )),
(os.path.join( "CXX", python_ver ), glob( os.path.join( "Src", python_ver, "*" ) ))
]
class my_install(install):
def finalize_options( self ):
if not self.install_data or (len(self.install_data) < 8):
self.install_data = "$base/share/python$py_version_short"
install.finalize_options (self)
def run (self):
self.distribution.data_files = sources
self.distribution.headers = headers
install.run( self )
class my_install_headers(install_headers):
def run( self ):
if not self.distribution.headers:
return
for subdir, headers in self.distribution.headers:
try:
dir = os.path.join( self.install_dir, subdir )
except:
dir = self.install_dir
self.mkpath( dir )
for header in headers:
(out, _) = self.copy_file( header, dir )
self.outfiles.append( out )
# read the version from the master file CXX/Version.hxx
v_maj = None
v_min = None
v_pat = None
with open( 'CXX/Version.hxx', 'r' ) as f:
for line in f:
if line.startswith( '#define PYCXX_VERSION_' ):
parts = line.strip().split()
if parts[1] == 'PYCXX_VERSION_MAJOR':
v_maj = parts[2]
elif parts[1] == 'PYCXX_VERSION_MINOR':
v_min = parts[2]
elif parts[1] == 'PYCXX_VERSION_PATCH':
v_pat = parts[2]
setup( name = "CXX",
version = "%s.%s.%s" % (v_maj, v_min, v_pat),
maintainer = "Barry Scott",
maintainer_email = "barry-scott@users.sourceforge.net",
description = "Facility for extending Python with C++",
url = "http://cxx.sourceforge.net",
cmdclass = {'install': my_install,
'install_headers': my_install_headers},
packages = ['CXX'],
package_dir = {'CXX': 'Lib'}
)
pycxx-7.1.4/Lib/ 000755 000765 000024 00000000000 13664720516 013700 5 ustar 00barry staff 000000 000000 pycxx-7.1.4/build-limited-api.cmd 000644 000765 000024 00000003615 13432535510 017146 0 ustar 00barry staff 000000 000000 setlocal
rem Mm e.g. 24 36 etc
set PYTHON_VER=%1
rem win32 or win64
set PYTHON_ARCH=%2
rem 10.0, 14.0
set VC_VER=%3
set API=%4
echo ------------------------------------------------------
echo Testing limited API %4 for python %1 %2 using VC %3
echo ------------------------------------------------------
if %PYTHON_ARCH% == win32 (
if exist "C:\Program Files (x86)\Microsoft Visual Studio %VC_VER%\VC\vcvarsall.bat" (
call "C:\Program Files (x86)\Microsoft Visual Studio %VC_VER%\VC\vcvarsall.bat"
)
if exist "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat" (
call "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
)
)
if %PYTHON_ARCH% == win64 (
if exist "C:\Program Files (x86)\Microsoft Visual Studio %VC_VER%\VC\bin\amd64\vcvars64.bat" (
call "C:\Program Files (x86)\Microsoft Visual Studio %VC_VER%\VC\bin\amd64\vcvars64.bat"
)
if exist "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" (
call "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
)
)
if exist c:\python%PYTHON_VER%.%PYTHON_ARCH%\python.exe (
c:\python%PYTHON_VER%.%PYTHON_ARCH%\python setup_makefile.py %PYTHON_ARCH% tmp-%PYTHON_ARCH%-python%PYTHON_VER%-limited-%API%-build.mak --limited-api=%API%
if errorlevel 1 exit /b 1
nmake -f tmp-%PYTHON_ARCH%-python%PYTHON_VER%-limited-%API%-build.mak clean all 2>&1 | c:\UnxUtils\usr\local\wbin\tee.exe tmp-%PYTHON_ARCH%-python%PYTHON_VER%-limited-%API%-build.log
if not exist obj\pycxx_iter.pyd exit /b 1
nmake -f tmp-%PYTHON_ARCH%-python%PYTHON_VER%-limited-%API%-build.mak test 2>&1 | c:\UnxUtils\usr\local\wbin\tee.exe tmp-%PYTHON_ARCH%-python%PYTHON_VER%-limited-%API%-test.log
echo All done
)
endlocal
pycxx-7.1.4/how_to_release_pycxx.txt 000644 000765 000024 00000001624 13510630011 020144 0 ustar 00barry staff 000000 000000 How to release PyCXX
--------------------
0. Update CXX/Version.hxx with the releases version number
Update README.html, README.txt with change log info
1. Tag the source using tag_pycxx.py (depends on pysvn).
2. Create the source kit using make_src_kit.py
3. Add new File release on sourceforge.
1. http://sourceforge.net/projects/cxx/
2. Select Files tab
3. Open CXX folder
4. Click "Add Folder"
5. Name the Folder PyCXX V.. e.g. PyCXX V6.1.1
7. Upload the source kit and its README.txt
9. Click on the source kit (i) icon and choose Select All platforms. Do not select all for README.txt.
4. Add news about release
1. Click News
2. From side bar choose New Post
3. Add news with release note info - may be need to make it a bigger advert?
5. Email CXX mailing lists
6. Update docs on the PyCXX homepage
1. cd SourceForge
2. ./deploy.sh
pycxx-7.1.4/RegressionTests/ 000755 000765 000024 00000000000 13664720516 016335 5 ustar 00barry staff 000000 000000 pycxx-7.1.4/Doc/ 000755 000765 000024 00000000000 13664720516 013677 5 ustar 00barry staff 000000 000000 pycxx-7.1.4/README.txt 000644 000765 000024 00000000406 13664720236 014667 0 ustar 00barry staff 000000 000000 Version: 7.1.4 (31-May-2020)
Add support for more number methods, like matrix and the inplace versions.
Use IsInstance checking so that derived classes of builtin types can be used.
Update Docs with recent changes.
Add support for python 3.9 beta 1 changes.
pycxx-7.1.4/COPYRIGHT 000644 000765 000024 00000006226 10547732521 014467 0 ustar 00barry staff 000000 000000
Copyright (c) 1998 - 2007
The Regents of the University of California
Produced at the Lawrence Livermore National Laboratory
Written by Geoff Furnish, Paul F. Dubois, Barry A. Scott
UCRL-CODE-227018
All rights reserved.
This file is part of PyCXX. For details, see http://cxx.sourceforge.net.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the disclaimer below.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the disclaimer (as noted below) in the
documentation and/or materials provided with the distribution.
- Neither the name of the UC/LLNL nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF CALIFORNIA,
THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Additional BSD Notice
1. This notice is required to be provided under our contract with the U.S.
Department of Energy (DOE). This work was produced at the University of
California, Lawrence Livermore National Laboratory under Contract No.
W-7405-ENG-48 with the DOE.
2. Neither the United States Government nor the University of California
nor any of their employees, makes any warranty, express or implied, or
assumes any liability or responsibility for the accuracy, completeness,
or usefulness of any information, apparatus, product, or process disclosed,
or represents that its use would not infringe privately-owned rights.
3. Also, reference herein to any specific commercial products, process, or
services by trade name, trademark, manufacturer or otherwise does not
necessarily constitute or imply its endorsement, recommendation, or
favoring by the United States Government or the University of California.
The views and opinions of authors expressed herein do not necessarily
state or reflect those of the United States Government or the University
of California, and shall not be used for advertising or product endorsement
purposes.
pycxx-7.1.4/setup_makefile.py 000644 000765 000024 00000054175 13354735735 016562 0 ustar 00barry staff 000000 000000 #
# Copyright (c) 2010-2011 Barry A. Scott
#
import os
import sys
import distutils
import distutils.sysconfig
import distutils.util
_debug = False
def debug( msg ):
if _debug:
sys.stderr.write( 'Debug: %s\n' % (msg,) )
#--------------------------------------------------------------------------------
class Setup:
def __init__( self, argv ):
args = argv[1:]
if len(args) < 2:
raise ValueError( 'Usage: setup.py win32|win64|macosx|linux> ' )
self.opt_debug = False
self.opt_pycxx_debug = False
self.opt_limited_api = None
self.is_pypy = hasattr( sys, 'pypy_version_info' )
self.platform = args[0]
del args[0]
self.__makefile = open( args[0], 'wt' )
del args[0]
while len(args) > 0:
if args[0] == '--debug':
self.opt_debug = True
del args[0]
elif args[0] == '--pycxx-debug':
self.opt_pycxx_debug = True
del args[0]
elif args[0] == '--limited-api':
self.opt_limited_api = '0x03040000'
del args[0]
elif args[0].startswith( '--limited-api=' ):
api = args[0][len('--limited-api='):]
if api.startswith( '0x' ):
self.opt_limited_api = api
else:
major, minor = [int(s) for s in api.split('.')]
minor *= 0x10000
major *= 0x1000000
self.opt_limited_api = '0x%x' % (major+minor)
del args[0]
else:
raise ValueError( 'Unknown arg %r' % (args[0],) )
self.setupCompile()
def makePrint( self, line ):
self.__makefile.write( line )
self.__makefile.write( '\n' )
def setupCompile( self ):
if self.platform == 'win32':
self.c_utils = Win32CompilerMSVC90( self )
self.c_python_extension = Win32CompilerMSVC90( self )
elif self.platform == 'win64':
self.c_utils = Win32CompilerMSVC90( self )
self.c_python_extension = Win32CompilerMSVC90( self )
elif self.platform == 'macosx':
self.c_utils = MacOsxCompilerGCC( self )
self.c_python_extension = MacOsxCompilerGCC( self )
elif self.platform == 'linux':
self.c_utils = LinuxCompilerGCC( self )
self.c_python_extension = LinuxCompilerGCC( self )
else:
raise ValueError( 'Unknown platform %r' % (self.platform,) )
self.c_python_extension.setupPythonExtension()
self.pycxx_obj_file = [
Source( self.c_python_extension, 'Src/cxxsupport.cxx' ),
Source( self.c_python_extension, 'Src/cxx_extensions.cxx' ),
Source( self.c_python_extension, 'Src/cxx_exceptions.cxx' ),
Source( self.c_python_extension, 'Src/cxxextensions.c' ),
Source( self.c_python_extension, 'Src/IndirectPythonInterface.cxx' ),
]
self.simple_obj_files = [
Source( self.c_python_extension, '%(DEMO_DIR)s/simple.cxx' ),
] + self.pycxx_obj_file
self.example_obj_files = [
Source( self.c_python_extension, '%(DEMO_DIR)s/example.cxx' ),
Source( self.c_python_extension, '%(DEMO_DIR)s/range.cxx' ),
Source( self.c_python_extension, '%(DEMO_DIR)s/rangetest.cxx' ),
] + self.pycxx_obj_file
self.pycxx_iter_obj_files = [
Source( self.c_python_extension, '%(DEMO_DIR)s/pycxx_iter.cxx' ),
] + self.pycxx_obj_file
exe_simple = PythonExtension( self.c_python_extension, 'simple', self.simple_obj_files )
exe_example = PythonExtension( self.c_python_extension, 'example', self.example_obj_files )
exe_pycxx_iter = PythonExtension( self.c_python_extension, 'pycxx_iter', self.pycxx_iter_obj_files )
self.all_exe = [
exe_simple,
exe_example,
exe_pycxx_iter,
]
self.all_test = [
TestPythonExtension( self.c_python_extension, '%(DEMO_DIR)s/test_simple.py', exe_simple ),
TestPythonExtension( self.c_python_extension, '%(DEMO_DIR)s/test_example.py', exe_example ),
TestPythonExtension( self.c_python_extension, '%(DEMO_DIR)s/test_pycxx_iter.py', exe_pycxx_iter ),
]
def generateMakefile( self ):
try:
self.c_python_extension.generateMakefileHeader()
self.makePrint( 'all: %s' % (' '.join( [exe.getTargetFilename() for exe in self.all_exe] )) )
self.makePrint( '' )
for exe in self.all_exe:
exe.generateMakefile()
for test in self.all_test:
test.generateMakefile()
self.__makefile.close()
return 0
except ValueError:
e = sys.exc_info()[1]
sys.stderr.write( 'Error: %s\n' % (e,) )
return 1
#--------------------------------------------------------------------------------
class Compiler:
def __init__( self, setup ):
debug( 'Compiler.__init__()' )
self.setup = setup
self.__variables = {}
self._addVar( 'DEBUG', 'NDEBUG')
def platformFilename( self, filename ):
return filename
def makePrint( self, line ):
self.setup.makePrint( line )
def generateMakefileHeader( self ):
raise NotImplementedError( 'generateMakefileHeader' )
def _addFromEnv( self, name ):
debug( 'Compiler._addFromEnv( %r )' % (name,) )
self._addVar( name, os.environ[ name ] )
def _addVar( self, name, value ):
debug( 'Compiler._addVar( %r, %r )' % (name, value) )
try:
if '%' in value:
value = value % self.__variables
self.__variables[ name ] = value
except TypeError:
raise ValueError( 'Cannot translate name %r value %r' % (name, value) )
except KeyError:
e = sys.exc_info()[1]
raise ValueError( 'Cannot translate name %r value %r - %s' % (name, value, e) )
def expand( self, s ):
try:
return s % self.__variables
except (TypeError, KeyError):
e = sys.exc_info()[1]
print( 'Error: %s' % (e,) )
print( 'String: %s' % (s,) )
print( 'Vairables: %r' % (self.__variables,) )
raise ValueError( 'Cannot translate string (%s)' % (e,) )
# MSVC 9.0 and later versions
class Win32CompilerMSVC90(Compiler):
def __init__( self, setup ):
Compiler.__init__( self, setup )
self._addVar( 'PYTHONDIR', sys.exec_prefix )
if setup.opt_limited_api is None:
self._addVar( 'PYTHON_LIBNAME', 'python%d%d' % (sys.version_info[0], sys.version_info[1]) )
else:
self._addVar( 'PYTHON_LIBNAME', 'python3' )
self._addVar( 'PYTHON_INCLUDE', r'%(PYTHONDIR)s\include' )
self._addVar( 'PYTHON_LIB', r'%(PYTHONDIR)s\libs' )
self._addVar( 'PYTHON', sys.executable )
def platformFilename( self, filename ):
return filename.replace( '/', '\\' )
def getPythonExtensionFileExt( self ):
return '.pyd'
def getProgramExt( self ):
return '.exe'
def generateMakefileHeader( self ):
self.makePrint( '#' )
self.makePrint( '# PyCXX Makefile generated by setup_makefile.py' )
self.makePrint( '#' )
self.makePrint( 'CCC=cl /nologo /W4' )
self.makePrint( 'CC=cl /nologo /W4' )
self.makePrint( '' )
self.makePrint( 'LDSHARED=$(CCC) /LD /Zi /MT /EHsc' )
self.makePrint( 'LDEXE=$(CCC) /Zi /MT /EHsc' )
self.makePrint( '' )
def ruleLinkProgram( self, target ):
pyd_filename = target.getTargetFilename()
pdf_filename = target.getTargetFilename( '.pdf' )
all_objects = [source.getTargetFilename() for source in target.all_sources]
rules = ['']
rules.append( '' )
rules.append( '%s : %s' % (pyd_filename, ' '.join( all_objects )) )
rules.append( '\t@echo Link %s' % (pyd_filename,) )
rules.append( '\t$(LDEXE) %%(CCCFLAGS)s /Fe%s /Fd%s %s Advapi32.lib' %
(pyd_filename, pdf_filename, ' '.join( all_objects )) )
self.makePrint( self.expand( '\n'.join( rules ) ) )
def ruleLinkShared( self, target ):
pyd_filename = target.getTargetFilename()
pdf_filename = target.getTargetFilename( '.pdf' )
all_objects = [source.getTargetFilename() for source in target.all_sources]
rules = ['']
rules.append( '' )
rules.append( '%s : %s' % (pyd_filename, ' '.join( all_objects )) )
rules.append( '\t@echo Link %s' % (pyd_filename,) )
rules.append( '\t$(LDSHARED) %%(CCCFLAGS)s /Fe%s /Fd%s %s %%(PYTHON_LIB)s\%%(PYTHON_LIBNAME)s.lib' %
(pyd_filename, pdf_filename, ' '.join( all_objects )) )
self.makePrint( self.expand( '\n'.join( rules ) ) )
def ruleCxx( self, target ):
obj_filename = target.getTargetFilename()
rules = []
rules.append( '%s: %s %s' % (obj_filename, target.src_filename, ' '.join( target.all_dependencies )) )
rules.append( '\t@echo Compile: %s into %s' % (target.src_filename, target.getTargetFilename()) )
rules.append( '\t$(CCC) /c %%(CCCFLAGS)s /Fo%s /Fd%s %s' % (obj_filename, target.dependent.getTargetFilename( '.pdb' ), target.src_filename) )
self.makePrint( self.expand( '\n'.join( rules ) ) )
def ruleC( self, target ):
# can reuse the C++ rule
self.ruleCxx( target )
def ruleClean( self, filename ):
rules = []
rules.append( 'clean::' )
rules.append( '\tif exist %s del %s' % (filename, filename) )
rules.append( '' )
self.makePrint( self.expand( '\n'.join( rules ) ) )
def setupPythonExtension( self ):
self._addVar( 'PYTHON', sys.executable )
self._addVar( 'OBJ_DIR', 'obj' )
self._addVar( 'PYTHON_VERSION', '%d.%d' % (sys.version_info[0], sys.version_info[1]) )
self._addVar( 'DEMO_DIR', 'Demo\Python%d' % (sys.version_info[0],) )
self._addVar( 'PYCXX_DEBUG', '-DPYCXX_DEBUG=1' if self.setup.opt_pycxx_debug else '' )
self._addVar( 'PYCXX_API', ('-DPy_LIMITED_API=%s' % (self.setup.opt_limited_api,)) if self.setup.opt_limited_api else '' )
self._addVar( 'CCCFLAGS',
r'/Zi /MT /EHsc '
r'-I. -ISrc -I%(PYTHON_INCLUDE)s '
r'-D_CRT_NONSTDC_NO_DEPRECATE '
r'-U_DEBUG '
r'-D%(DEBUG)s '
r'%(PYCXX_DEBUG)s'
r'%(PYCXX_API)s' )
def ruleTest( self, python_test ):
rules = []
rules.append( 'test:: %s %s' % (python_test.getTargetFilename(), python_test.python_extension.getTargetFilename()) )
rules.append( '\tset PYTHONPATH=obj' )
rules.append( '\t%%(PYTHON)s -W default %s' % (python_test.getTargetFilename(),) )
rules.append( '' )
self.makePrint( self.expand( '\n'.join( rules ) ) )
class CompilerGCC(Compiler):
def __init__( self, setup ):
Compiler.__init__( self, setup )
if self.setup.platform == 'macosx':
if sys.version_info[0] == 2:
maxsize = sys.maxint
else:
maxsize = sys.maxsize
if maxsize == (2**31-1):
arch = 'i386'
else:
arch = 'x86_64'
self._addVar( 'CCC', 'g++ -arch %s' % (arch,) )
self._addVar( 'CC', 'gcc -arch %s' % (arch,) )
else:
self._addVar( 'CCC', 'g++' )
self._addVar( 'CC', 'gcc' )
def getPythonExtensionFileExt( self ):
return '.so'
def getProgramExt( self ):
return ''
def generateMakefileHeader( self ):
self.makePrint( '#' )
self.makePrint( '# PyCXX Makefile generated by setup_makefile.py' )
self.makePrint( '#' )
self.makePrint( '' )
def ruleLinkProgram( self, target ):
target_filename = target.getTargetFilename()
all_objects = [source.getTargetFilename() for source in target.all_sources]
rules = []
rules.append( '%s : %s' % (target_filename, ' '.join( all_objects )) )
rules.append( '\t@echo Link %s' % (target_filename,) )
rules.append( '\t%%(LDEXE)s -o %s %%(CCCFLAGS)s %s' % (target_filename, ' '.join( all_objects )) )
self.makePrint( self.expand( '\n'.join( rules ) ) )
def ruleLinkShared( self, target ):
target_filename = target.getTargetFilename()
all_objects = [source.getTargetFilename() for source in target.all_sources]
rules = []
rules.append( '%s : %s' % (target_filename, ' '.join( all_objects )) )
rules.append( '\t@echo Link %s' % (target_filename,) )
rules.append( '\t%%(LDSHARED)s -o %s %%(CCCFLAGS)s %s' % (target_filename, ' '.join( all_objects )) )
self.makePrint( self.expand( '\n'.join( rules ) ) )
def ruleCxx( self, target ):
obj_filename = target.getTargetFilename()
rules = []
rules.append( '%s: %s %s' % (obj_filename, target.src_filename, ' '.join( target.all_dependencies )) )
rules.append( '\t@echo Compile: %s into %s' % (target.src_filename, obj_filename) )
rules.append( '\t%%(CCC)s -c %%(CCCFLAGS)s -o%s %s' % (obj_filename, target.src_filename) )
self.makePrint( self.expand( '\n'.join( rules ) ) )
def ruleC( self, target ):
obj_filename = target.getTargetFilename()
rules = []
rules.append( '%s: %s %s' % (obj_filename, target.src_filename, ' '.join( target.all_dependencies )) )
rules.append( '\t@echo Compile: %s into %s' % (target.src_filename, target) )
rules.append( '\t%%(CC)s -c %%(CCCFLAGS)s -o%s %s' % (obj_filename, target.src_filename) )
self.makePrint( self.expand( '\n'.join( rules ) ) )
def ruleClean( self, filename ):
rules = []
rules.append( 'clean::' )
rules.append( '\trm -f %s' % (filename,) )
rules.append( '' )
self.makePrint( self.expand( '\n'.join( rules ) ) )
def ruleTest( self, python_test ):
rules = []
rules.append( 'test:: %s %s' % (python_test.getTargetFilename(), python_test.python_extension.getTargetFilename()) )
rules.append( '\tPYTHONPATH=obj %%(PYTHON)s -W default %s' % (python_test.getTargetFilename(),) )
rules.append( '' )
self.makePrint( self.expand( '\n'.join( rules ) ) )
class MacOsxCompilerGCC(CompilerGCC):
def __init__( self, setup ):
CompilerGCC.__init__( self, setup )
def setupPythonExtension( self ):
self._addVar( 'PYTHON', sys.executable )
self._addVar( 'OBJ_DIR', 'obj' )
self._addVar( 'PYTHON_VERSION', '%d.%d' % (sys.version_info[0], sys.version_info[1]) )
self._addVar( 'PYTHONDIR', sys.exec_prefix )
self._addVar( 'PYTHON', sys.executable )
if self.setup.is_pypy:
self._addVar( 'PYTHON_INCLUDE', '%(PYTHONDIR)s/include' )
self._addVar( 'PYTHON_FRAMEWORK', '%(PYTHONDIR)s/bin/libpypy-c.dylib' )
else:
self._addVar( 'PYTHON_INCLUDE', '%(PYTHONDIR)s/Headers' )
self._addVar( 'PYTHON_FRAMEWORK', '%(PYTHONDIR)s/Python' )
self._addVar( 'DEMO_DIR', 'Demo/Python%d' % (sys.version_info[0],) )
self._addVar( 'PYCXX_DEBUG', '-DPYCXX_DEBUG=1' if self.setup.opt_pycxx_debug else '' )
self._addVar( 'PYCXX_API', ('-DPy_LIMITED_API=%s' % (self.setup.opt_limited_api,)) if self.setup.opt_limited_api else '' )
self._addVar( 'CCCFLAGS',
'-g '
'-Wall -fPIC -fexceptions -frtti '
'-I. -ISrc -I%(PYTHON_INCLUDE)s '
'-D%(DEBUG)s '
'%(PYCXX_DEBUG)s'
'%(PYCXX_API)s' )
self._addVar( 'LDSHARED', '%(CCC)s -bundle -g '
'-framework System '
'%(PYTHON_FRAMEWORK)s ' )
class LinuxCompilerGCC(CompilerGCC):
def __init__( self, setup ):
CompilerGCC.__init__( self, setup )
def setupPythonExtension( self ):
self._addVar( 'PYTHON', sys.executable )
self._addVar( 'OBJ_DIR', 'obj' )
self._addVar( 'DEMO_DIR', 'Demo/Python%d' % (sys.version_info[0],) )
self._addVar( 'PYTHON_VERSION', '%d.%d' % (sys.version_info[0], sys.version_info[1]) )
self._addVar( 'PYTHON_INCLUDE', distutils.sysconfig.get_python_inc() )
self._addVar( 'PYCXX_DEBUG', '-DPYCXX_DEBUG=1' if self.setup.opt_pycxx_debug else '' )
self._addVar( 'PYCXX_API', ('-DPy_LIMITED_API=%s' % (self.setup.opt_limited_api,)) if self.setup.opt_limited_api else '' )
self._addVar( 'CCCFLAGS',
'-g '
'-Wall -fPIC -fexceptions -frtti '
'-I. -ISrc -I%(PYTHON_INCLUDE)s '
'-D%(DEBUG)s '
'%(PYCXX_DEBUG)s'
'%(PYCXX_API)s' )
self._addVar( 'LDEXE', '%(CCC)s -g' )
self._addVar( 'LDSHARED', '%(CCC)s -shared -g ' )
#--------------------------------------------------------------------------------
class Target:
def __init__( self, compiler, all_sources ):
self.compiler = compiler
self.__generated = False
self.dependent = None
self.all_sources = all_sources
for source in self.all_sources:
source.setDependent( self )
def getTargetFilename( self ):
raise NotImplementedError( '%s.getTargetFilename' % self.__class__.__name__ )
def generateMakefile( self ):
if self.__generated:
return
self.__generated = True
return self._generateMakefile()
def _generateMakefile( self ):
raise NotImplementedError( '_generateMakefile' )
def ruleClean( self, ext=None ):
if ext is None:
target_filename = self.getTargetFilename()
else:
target_filename = self.getTargetFilename( ext )
self.compiler.ruleClean( target_filename )
def setDependent( self, dependent ):
debug( '%r.setDependent( %r )' % (self, dependent,) )
self.dependent = dependent
class TestPythonExtension(Target):
def __init__( self, compiler, test_source, python_extension ):
self.test_source = test_source
self.python_extension = python_extension
Target.__init__( self, compiler, [] )
def __repr__( self ):
return '' % (id(self), self.test_source )
def getTargetFilename( self ):
return self.compiler.platformFilename( self.compiler.expand( self.test_source ) )
def _generateMakefile( self ):
self.compiler.ruleTest( self )
class PythonExtension(Target):
def __init__( self, compiler, output, all_sources ):
self.output = output
Target.__init__( self, compiler, all_sources )
debug( 'PythonExtension:0x%8.8x.__init__( %r, ... )' % (id(self), output,) )
for source in self.all_sources:
source.setDependent( self )
def __repr__( self ):
return '' % (id(self), self.output)
def getTargetFilename( self, ext=None ):
if ext is None:
ext = self.compiler.getPythonExtensionFileExt()
return self.compiler.platformFilename( self.compiler.expand( '%%(OBJ_DIR)s/%s%s' % (self.output, ext) ) )
def _generateMakefile( self ):
debug( 'PythonExtension:0x%8.8x.generateMakefile() for %r' % (id(self), self.output,) )
self.compiler.ruleLinkShared( self )
self.compiler.ruleClean( self.getTargetFilename( '.*' ) )
for source in self.all_sources:
source.generateMakefile()
class Source(Target):
def __init__( self, compiler, src_filename, all_dependencies=None ):
self.src_filename = compiler.platformFilename( compiler.expand( src_filename ) )
Target.__init__( self, compiler, [] )
debug( 'Source:0x%8.8x.__init__( %r, %r )' % (id(self), src_filename, all_dependencies) )
self.all_dependencies = all_dependencies
if self.all_dependencies is None:
self.all_dependencies = []
def __repr__( self ):
return '' % (id(self), self.src_filename)
def getTargetFilename( self ):
#if not os.path.exists( self.src_filename ):
# raise ValueError( 'Cannot find source %s' % (self.src_filename,) )
basename = os.path.basename( self.src_filename )
if basename.endswith( '.cpp' ):
return self.compiler.platformFilename( self.compiler.expand( r'%%(OBJ_DIR)s/%s.obj' % (basename[:-len('.cpp')],) ) )
if basename.endswith( '.cxx' ):
return self.compiler.platformFilename( self.compiler.expand( r'%%(OBJ_DIR)s/%s.obj' % (basename[:-len('.cxx')],) ) )
if basename.endswith( '.c' ):
return self.compiler.platformFilename( self.compiler.expand( r'%%(OBJ_DIR)s/%s.obj' % (basename[:-len('.c')],) ) )
raise ValueError( 'unknown source %r' % (self.src_filename,) )
def _generateMakefile( self ):
debug( 'Source:0x%8.8x.generateMakefile() for %r' % (id(self), self.src_filename,) )
self.compiler.ruleCxx( self )
self.compiler.ruleClean( self.getTargetFilename() )
#--------------------------------------------------------------------------------
def main( argv ):
try:
s = Setup( argv )
s.generateMakefile()
return 0
except ValueError:
e = sys.exc_info()[1]
sys.stderr.write( 'Error: %s\n' % (e,) )
return 1
if __name__ == '__main__':
sys.exit( main( sys.argv ) )
pycxx-7.1.4/run_tests.cmd 000644 000765 000024 00000000473 11146621572 015704 0 ustar 00barry staff 000000 000000 setlocal
set PY_MAJ=2
if not "%1" == "" set PY_MAJ=%1
set PY_MIN=5
if not "%2" == "" set PY_MIN=%2
set PYTHONPATH=pyds%PY_MAJ%%PY_MIN%
c:\python%PY_MAJ%%PY_MIN%\python Demo\test_example.py
if exist pyds%PY_MAJ%%PY_MIN%\pycxx_iter.pyd c:\python%PY_MAJ%%PY_MIN%\python Demo\test_pycxx_iter.py
endlocal
pycxx-7.1.4/Src/ 000755 000765 000024 00000000000 13664720516 013721 5 ustar 00barry staff 000000 000000 pycxx-7.1.4/Src/cxxextensions.c 000644 000765 000024 00000004356 11146072165 017010 0 ustar 00barry staff 000000 000000 //-----------------------------------------------------------------------------
//
// Copyright (c) 1998 - 2007, The Regents of the University of California
// Produced at the Lawrence Livermore National Laboratory
// All rights reserved.
//
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
// full copyright notice is contained in the file COPYRIGHT located at the root
// of the PyCXX distribution.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or materials provided with the distribution.
// - Neither the name of the UC/LLNL nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
//-----------------------------------------------------------------------------
#include "CXX/WrapPython.h"
#if PY_MAJOR_VERSION == 2
#include "Src/Python2/cxxextensions.c"
#else
#include "Src/Python3/cxxextensions.c"
#endif
pycxx-7.1.4/Src/Python3/ 000755 000765 000024 00000000000 13664720516 015265 5 ustar 00barry staff 000000 000000 pycxx-7.1.4/Src/cxxsupport.cxx 000644 000765 000024 00000004354 11146072165 016703 0 ustar 00barry staff 000000 000000 //-----------------------------------------------------------------------------
//
// Copyright (c) 1998 - 2007, The Regents of the University of California
// Produced at the Lawrence Livermore National Laboratory
// All rights reserved.
//
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
// full copyright notice is contained in the file COPYRIGHT located at the root
// of the PyCXX distribution.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or materials provided with the distribution.
// - Neither the name of the UC/LLNL nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
//-----------------------------------------------------------------------------
#include "CXX/WrapPython.h"
#if PY_MAJOR_VERSION == 2
#include "Src/Python2/cxxsupport.cxx"
#else
#include "Src/Python3/cxxsupport.cxx"
#endif
pycxx-7.1.4/Src/Python2/ 000755 000765 000024 00000000000 13664720516 015264 5 ustar 00barry staff 000000 000000 pycxx-7.1.4/Src/cxx_exceptions.cxx 000644 000765 000024 00000000220 12721375410 017472 0 ustar 00barry staff 000000 000000 #include "CXX/WrapPython.h"
#if PY_MAJOR_VERSION == 2
#include "Python2/cxx_exceptions.cxx"
#else
#include "Python3/cxx_exceptions.cxx"
#endif
pycxx-7.1.4/Src/cxx_extensions.cxx 000644 000765 000024 00000004354 11146072165 017525 0 ustar 00barry staff 000000 000000 //-----------------------------------------------------------------------------
//
// Copyright (c) 1998 - 2007, The Regents of the University of California
// Produced at the Lawrence Livermore National Laboratory
// All rights reserved.
//
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
// full copyright notice is contained in the file COPYRIGHT located at the root
// of the PyCXX distribution.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or materials provided with the distribution.
// - Neither the name of the UC/LLNL nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
//-----------------------------------------------------------------------------
#include "CXX/WrapPython.h"
#if PY_MAJOR_VERSION == 2
#include "Python2/cxx_extensions.cxx"
#else
#include "Python3/cxx_extensions.cxx"
#endif
pycxx-7.1.4/Src/IndirectPythonInterface.cxx 000644 000765 000024 00000052641 13561767747 021256 0 ustar 00barry staff 000000 000000 //-----------------------------------------------------------------------------
//
// Copyright (c) 1998 - 2007, The Regents of the University of California
// Produced at the Lawrence Livermore National Laboratory
// All rights reserved.
//
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
// full copyright notice is contained in the file COPYRIGHT located at the root
// of the PyCXX distribution.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or materials provided with the distribution.
// - Neither the name of the UC/LLNL nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
//-----------------------------------------------------------------------------
#include "CXX/IndirectPythonInterface.hxx"
namespace Py
{
static int _IsInstance( PyObject *op, PyTypeObject *type )
{
return PyObject_IsInstance( op, reinterpret_cast( type ) );
}
bool _CFunction_Check( PyObject *op ) { return _IsInstance( op, _CFunction_Type() ) > 0; }
bool _Complex_Check( PyObject *op ) { return _IsInstance( op, _Complex_Type() ) > 0; }
bool _Dict_Check( PyObject *op ) { return _IsInstance( op, _Dict_Type() ) > 0; }
bool _Float_Check( PyObject *op ) { return _IsInstance( op, _Float_Type() ) > 0; }
#if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
bool _Function_Check( PyObject *op ) { return _IsInstance( op, _Function_Type() ) > 0; }
#endif
bool _Boolean_Check( PyObject *op ) { return _IsInstance( op, _Bool_Type() ) > 0; }
bool _List_Check( PyObject *op ) { return _IsInstance( op, _List_Type() ) > 0; }
bool _Long_Check( PyObject *op ) { return _IsInstance( op, _Long_Type() ) > 0; }
#if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
bool _Method_Check( PyObject *op ) { return _IsInstance( op, _Method_Type() ) > 0; }
#endif
bool _Module_Check( PyObject *op ) { return _IsInstance( op, _Module_Type() ) > 0; }
bool _Range_Check( PyObject *op ) { return _IsInstance( op, _Range_Type() ) > 0; }
bool _Slice_Check( PyObject *op ) { return _IsInstance( op, _Slice_Type() ) > 0; }
bool _TraceBack_Check( PyObject *op ) { return _IsInstance( op, _TraceBack_Type() ) > 0; }
bool _Tuple_Check( PyObject *op ) { return _IsInstance( op, _Tuple_Type() ) > 0; }
bool _Type_Check( PyObject *op ) { return _IsInstance( op, _Type_Type() ) > 0; }
bool _Unicode_Check( PyObject *op ) { return _IsInstance( op, _Unicode_Type() ) > 0; }
#if PY_MAJOR_VERSION == 2
bool _String_Check( PyObject *op ) { return _IsInstance( op, _String_Type() ) > 0; }
bool _Int_Check( PyObject *op ) { return _IsInstance( op, _Int_Type() ) > 0; }
bool _CObject_Check( PyObject *op ) { return _IsInstance( op, _CObject_Type() ) > 0; }
#endif
#if PY_MAJOR_VERSION >= 3
bool _Bytes_Check( PyObject *op ) { return _IsInstance( op, _Bytes_Type() ) > 0; }
#endif
#if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL)
# if defined(MS_WINDOWS)
# include
static HMODULE python_dll;
# define PYCXX_STANDARD_EXCEPTION( eclass, bclass ) \
static PyObject *ptr_Exc_##eclass = NULL;
# if PY_MAJOR_VERSION == 2
# include "CXX/Python2/cxx_standard_exceptions.hxx"
# else
# include "CXX/Python3/cxx_standard_exceptions.hxx"
# endif
# undef PYCXX_STANDARD_EXCEPTION
static PyTypeObject *ptr__CFunction_Type = NULL;
static PyTypeObject *ptr__Complex_Type = NULL;
static PyTypeObject *ptr__Dict_Type = NULL;
static PyTypeObject *ptr__Float_Type = NULL;
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
static PyTypeObject *ptr__Function_Type = NULL;
# endif
static PyTypeObject *ptr__Bool_Type = NULL;
static PyTypeObject *ptr__List_Type = NULL;
static PyTypeObject *ptr__Long_Type = NULL;
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
static PyTypeObject *ptr__Method_Type = NULL;
# endif
static PyTypeObject *ptr__Module_Type = NULL;
static PyTypeObject *ptr__Range_Type = NULL;
static PyTypeObject *ptr__Slice_Type = NULL;
static PyTypeObject *ptr__TraceBack_Type = NULL;
static PyTypeObject *ptr__Tuple_Type = NULL;
static PyTypeObject *ptr__Type_Type = NULL;
static PyTypeObject *ptr__Unicode_Type = NULL;
# if PY_MAJOR_VERSION == 2
static PyTypeObject *ptr__Int_Type = NULL;
static PyTypeObject *ptr__String_Type = NULL;
static PyTypeObject *ptr__CObject_Type = NULL;
# endif
# if PY_MAJOR_VERSION >= 3
static PyTypeObject *ptr__Bytes_Type = NULL;
# endif
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
static int *ptr_Py_DebugFlag = NULL;
static int *ptr_Py_InteractiveFlag = NULL;
static int *ptr_Py_OptimizeFlag = NULL;
static int *ptr_Py_NoSiteFlag = NULL;
static int *ptr_Py_VerboseFlag = NULL;
# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
static const char **ptr__Py_PackageContext = NULL;
# else
static char **ptr__Py_PackageContext = NULL;
# endif
# endif
# ifdef Py_REF_DEBUG
int *ptr_Py_RefTotal;
# endif
//--------------------------------------------------------------------------------
class GetAddressException
{
public:
GetAddressException( const char *_name )
: name( _name )
{}
virtual ~GetAddressException() {}
const char *name;
};
//--------------------------------------------------------------------------------
static PyObject *GetPyObjectPointer_As_PyObjectPointer( const char *name )
{
FARPROC addr = GetProcAddress( python_dll, name );
if( addr == NULL )
throw GetAddressException( name );
return *(PyObject **)addr;
}
static PyObject *GetPyObject_As_PyObjectPointer( const char *name )
{
FARPROC addr = GetProcAddress( python_dll, name );
if( addr == NULL )
throw GetAddressException( name );
return (PyObject *)addr;
}
static PyTypeObject *GetPyTypeObjectPointer_As_PyTypeObjectPointer( const char *name )
{
FARPROC addr = GetProcAddress( python_dll, name );
if( addr == NULL )
throw GetAddressException( name );
return *(PyTypeObject **)addr;
}
static PyTypeObject *GetPyTypeObject_As_PyTypeObjectPointer( const char *name )
{
FARPROC addr = GetProcAddress( python_dll, name );
if( addr == NULL )
throw GetAddressException( name );
return (PyTypeObject *)addr;
}
static int *GetInt_as_IntPointer( const char *name )
{
FARPROC addr = GetProcAddress( python_dll, name );
if( addr == NULL )
throw GetAddressException( name );
return (int *)addr;
}
static char **GetCharPointer_as_CharPointerPointer( const char *name )
{
FARPROC addr = GetProcAddress( python_dll, name );
if( addr == NULL )
throw GetAddressException( name );
return (char **)addr;
}
#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
static char **GetConstCharPointer_as_ConstCharPointerPointer( const char *name )
{
FARPROC addr = GetProcAddress( python_dll, name );
if( addr == NULL )
throw GetAddressException( name );
return (const char **)addr;
}
#endif
# ifdef _DEBUG
static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d_D.DLL";
# else
static const char python_dll_name_format[] = "PYTHON%1.1d%1.1d.DLL";
# endif
//--------------------------------------------------------------------------------
bool InitialisePythonIndirectInterface()
{
char python_dll_name[sizeof(python_dll_name_format)];
_snprintf( python_dll_name, sizeof(python_dll_name_format) / sizeof(char) - 1, python_dll_name_format, PY_MAJOR_VERSION, PY_MINOR_VERSION );
python_dll = LoadLibraryA( python_dll_name );
if( python_dll == NULL )
return false;
try
{
# ifdef Py_REF_DEBUG
ptr_Py_RefTotal = GetInt_as_IntPointer( "_Py_RefTotal" );
# endif
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
ptr_Py_DebugFlag = GetInt_as_IntPointer( "Py_DebugFlag" );
ptr_Py_InteractiveFlag = GetInt_as_IntPointer( "Py_InteractiveFlag" );
ptr_Py_OptimizeFlag = GetInt_as_IntPointer( "Py_OptimizeFlag" );
ptr_Py_NoSiteFlag = GetInt_as_IntPointer( "Py_NoSiteFlag" );
ptr_Py_VerboseFlag = GetInt_as_IntPointer( "Py_VerboseFlag" );
# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
ptr__Py_PackageContext = GetConstCharPointer_as_ConstCharPointerPointer( "_Py_PackageContext" );
# else
ptr__Py_PackageContext = GetCharPointer_as_CharPointerPointer( "_Py_PackageContext" );
# endif
# endif
# define PYCXX_STANDARD_EXCEPTION( eclass, bclass )
ptr_Exc_#eclass = GetPyTypeObject_As_PyTypeObjectPointer( "PyExc_" #eclass );
# if PY_MAJOR_VERSION == 2
# include "CXX/Python2/cxx_standard_exceptions.hxx"
# else
# include "CXX/Python3/cxx_standard_exceptions.hxx"
# endif
# undef PYCXX_STANDARD_EXCEPTION
ptr__PyNone = GetPyObject_As_PyObjectPointer( "_Py_NoneStruct" );
# if PY_MAJOR_VERSION == 2
ptr__PyFalse = GetPyObject_As_PyObjectPointer( "_Py_ZeroStruct" );
# else
ptr__PyFalse = GetPyObject_As_PyObjectPointer( "_Py_FalseStruct" );
# endif
ptr__PyTrue = GetPyObject_As_PyObjectPointer( "_Py_TrueStruct" );
ptr__CFunction_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCFunction_Type" );
ptr__Complex_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyComplex_Type" );
ptr__Dict_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyDict_Type" );
ptr__Float_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFloat_Type" );
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
ptr__Function_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyFunction_Type" );
# endif
ptr__Bool_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyBool_Type" );
ptr__List_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyList_Type" );
ptr__Long_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyLong_Type" );
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
ptr__Method_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyMethod_Type" );
# endif
ptr__Module_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyModule_Type" );
ptr__Range_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyRange_Type" );
ptr__Slice_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PySlice_Type" );
ptr__TraceBack_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTraceBack_Type" );
ptr__Tuple_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyTuple_Type" );
ptr__Type_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyType_Type" );
ptr__Unicode_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyUnicode_Type" );
# if PY_MAJOR_VERSION == 2
ptr__String_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyString_Type" );
ptr__Int_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyInt_Type" );
ptr__CObject_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyCObject_Type" );
# endif
# if PY_MAJOR_VERSION >= 3
ptr__Bytes_Type = GetPyTypeObject_As_PyTypeObjectPointer( "PyBytes_Type" );
# endif
}
catch( GetAddressException &e )
{
OutputDebugStringA( python_dll_name );
OutputDebugStringA( " does not contain symbol " );
OutputDebugStringA( e.name );
OutputDebugStringA( "\n" );
return false;
}
return true;
}
//
// Wrap variables as function calls
//
PyObject *_Exc_ArithmeticError() { return ptr__Exc_ArithmeticError; }
PyObject *_Exc_AssertionError() { return ptr__Exc_AssertionError; }
PyObject *_Exc_AttributeError() { return ptr__Exc_AttributeError; }
PyObject *_Exc_EnvironmentError() { return ptr__Exc_EnvironmentError; }
PyObject *_Exc_EOFError() { return ptr__Exc_EOFError; }
PyObject *_Exc_Exception() { return ptr__Exc_Exception; }
PyObject *_Exc_FloatingPointError() { return ptr__Exc_FloatingPointError; }
PyObject *_Exc_ImportError() { return ptr__Exc_ImportError; }
PyObject *_Exc_IndexError() { return ptr__Exc_IndexError; }
PyObject *_Exc_IOError() { return ptr__Exc_IOError; }
PyObject *_Exc_KeyboardInterrupt() { return ptr__Exc_KeyboardInterrupt; }
PyObject *_Exc_KeyError() { return ptr__Exc_KeyError; }
PyObject *_Exc_LookupError() { return ptr__Exc_LookupError; }
PyObject *_Exc_MemoryError() { return ptr__Exc_MemoryError; }
PyObject *_Exc_NameError() { return ptr__Exc_NameError; }
PyObject *_Exc_NotImplementedError() { return ptr__Exc_NotImplementedError; }
PyObject *_Exc_OSError() { return ptr__Exc_OSError; }
PyObject *_Exc_OverflowError() { return ptr__Exc_OverflowError; }
PyObject *_Exc_RuntimeError() { return ptr__Exc_RuntimeError; }
# if PY_MAJOR_VERSION == 2
PyObject *_Exc_StandardError() { return ptr__Exc_StandardError; }
# endif
PyObject *_Exc_SyntaxError() { return ptr__Exc_SyntaxError; }
PyObject *_Exc_SystemError() { return ptr__Exc_SystemError; }
PyObject *_Exc_SystemExit() { return ptr__Exc_SystemExit; }
PyObject *_Exc_TypeError() { return ptr__Exc_TypeError; }
PyObject *_Exc_ValueError() { return ptr__Exc_ValueError; }
# ifdef MS_WINDOWS
PyObject *_Exc_WindowsError() { return ptr__Exc_WindowsError; }
# endif
PyObject *_Exc_ZeroDivisionError() { return ptr__Exc_ZeroDivisionError; }
PyObject *_Exc_IndentationError() { return ptr__Exc_IndentationError; }
PyObject *_Exc_TabError() { return ptr__Exc_TabError; }
PyObject *_Exc_UnboundLocalError() { return ptr__Exc_UnboundLocalError; }
PyObject *_Exc_UnicodeError() { return ptr__Exc_UnicodeError; }
//
// wrap items in Object.h
//
PyObject *_None() { return ptr__PyNone; }
PyObject *_False() { return ptr__PyFalse; }
PyObject *_True() { return ptr__PyTrue; }
PyTypeObject *_CFunction_Type() { return ptr__CFunction_Type; }
PyTypeObject *_Complex_Type() { return ptr__Complex_Type; }
PyTypeObject *_Dict_Type() { return ptr__Dict_Type; }
PyTypeObject *_Float_Type() { return ptr__Float_Type; }
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
PyTypeObject *_Function_Type() { return ptr__Function_Type; }
# endif
PyTypeObject *_Bool_Type() { return ptr__Bool_Type; }
PyTypeObject *_List_Type() { return ptr__List_Type; }
PyTypeObject *_Long_Type() { return ptr__Long_Type; }
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
PyTypeObject *_Method_Type() { return ptr__Method_Type; }
# endif
PyTypeObject *_Module_Type() { return ptr__Module_Type; }
PyTypeObject *_Range_Type() { return ptr__Range_Type; }
PyTypeObject *_Slice_Type() { return ptr__Slice_Type; }
PyTypeObject *_TraceBack_Type() { return ptr__TraceBack_Type; }
PyTypeObject *_Tuple_Type() { return ptr__Tuple_Type; }
PyTypeObject *_Type_Type() { return ptr__Type_Type; }
PyTypeObject *_Unicode_Type() { return ptr__Unicode_Type; }
# if PY_MAJOR_VERSION == 2
PyTypeObject *_String_Type() { return ptr__String_Type; }
PyTypeObject *_Int_Type() { return ptr__Int_Type; }
PyTypeObject *_CObject_Type() { return ptr__CObject_Type; }
# endif
# if PY_MAJOR_VERSION >= 3
PyTypeObject *_Bytes_Type() { return ptr__Bytes_Type; }
# endif
//
// wrap the Python Flag variables
//
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
int &_Py_DebugFlag() { return *ptr_Py_DebugFlag; }
int &_Py_InteractiveFlag() { return *ptr_Py_InteractiveFlag; }
int &_Py_OptimizeFlag() { return *ptr_Py_OptimizeFlag; }
int &_Py_NoSiteFlag() { return *ptr_Py_NoSiteFlag; }
int &_Py_VerboseFlag() { return *ptr_Py_VerboseFlag; }
# endif
# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
const char *__Py_PackageContext() { return *ptr__Py_PackageContext; }
# else
char *__Py_PackageContext() { return *ptr__Py_PackageContext; }
# endif
# if 0
# define Py_INCREF(op) ( \
_Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
((PyObject*)(op))->ob_refcnt++)
# define Py_DECREF(op) \
if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
--((PyObject*)(op))->ob_refcnt != 0) \
_Py_CHECK_REFCNT(op) \
else \
_Py_Dealloc((PyObject *)(op))
# endif
void _XINCREF( PyObject *op )
{
// This function must match the contents of Py_XINCREF(op)
if( op == NULL )
return;
# ifdef Py_REF_DEBUG
(*ptr_Py_RefTotal)++;
# endif
(op)->ob_refcnt++;
}
void _XDECREF( PyObject *op )
{
// This function must match the contents of Py_XDECREF(op);
if( op == NULL )
return;
# ifdef Py_REF_DEBUG
(*ptr_Py_RefTotal)--;
# endif
if (--(op)->ob_refcnt == 0)
_Py_Dealloc((PyObject *)(op));
}
# else
# error "Can only delay load under Win32"
# endif
#else
//================================================================================
//
// Map onto Macros
//
//================================================================================
//
// Wrap variables as function calls
//
# define PYCXX_STANDARD_EXCEPTION( eclass, bclass ) \
PyObject *_Exc_##eclass() { return ::PyExc_##eclass; }
# if PY_MAJOR_VERSION == 2
# include "CXX/Python2/cxx_standard_exceptions.hxx"
# else
# include "CXX/Python3/cxx_standard_exceptions.hxx"
# endif
# undef PYCXX_STANDARD_EXCEPTION
//
// wrap items in Object.h
//
PyObject *_None() { return &::_Py_NoneStruct; }
PyObject *_False() { return Py_False; }
PyObject *_True() { return Py_True; }
PyTypeObject *_CFunction_Type() { return &PyCFunction_Type; }
PyTypeObject *_Complex_Type() { return &PyComplex_Type; }
PyTypeObject *_Dict_Type() { return &PyDict_Type; }
PyTypeObject *_Float_Type() { return &PyFloat_Type; }
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
PyTypeObject *_Function_Type() { return &PyFunction_Type; }
# endif
PyTypeObject *_Bool_Type() { return &PyBool_Type; }
PyTypeObject *_List_Type() { return &PyList_Type; }
PyTypeObject *_Long_Type() { return &PyLong_Type; }
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
PyTypeObject *_Method_Type() { return &PyMethod_Type; }
# endif
PyTypeObject *_Module_Type() { return &PyModule_Type; }
PyTypeObject *_Range_Type() { return &PyRange_Type; }
PyTypeObject *_Slice_Type() { return &PySlice_Type; }
PyTypeObject *_TraceBack_Type() { return &PyTraceBack_Type; }
PyTypeObject *_Tuple_Type() { return &PyTuple_Type; }
PyTypeObject *_Type_Type() { return &PyType_Type; }
PyTypeObject *_Unicode_Type() { return &PyUnicode_Type; }
# if PY_MAJOR_VERSION == 2
PyTypeObject *_String_Type() { return &PyString_Type; }
PyTypeObject *_Int_Type() { return &PyInt_Type; }
PyTypeObject *_CObject_Type() { return &PyCObject_Type; }
# endif
# if PY_MAJOR_VERSION >= 3
PyTypeObject *_Bytes_Type() { return &PyBytes_Type; }
# endif
//
// wrap flags
//
# if PY_MAJOR_VERSION == 2 || !defined( Py_LIMITED_API )
int &_Py_DebugFlag() { return Py_DebugFlag; }
int &_Py_InteractiveFlag() { return Py_InteractiveFlag; }
int &_Py_OptimizeFlag() { return Py_OptimizeFlag; }
int &_Py_NoSiteFlag() { return Py_NoSiteFlag; }
int &_Py_VerboseFlag() { return Py_VerboseFlag; }
# if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7
const char *__Py_PackageContext() { return _Py_PackageContext; }
# else
char *__Py_PackageContext() { return _Py_PackageContext; }
# endif
# endif
//
// Needed to keep the abstactions for delayload interface
//
void _XINCREF( PyObject *op )
{
Py_XINCREF( op );
}
void _XDECREF( PyObject *op )
{
Py_XDECREF( op );
}
#endif
}
pycxx-7.1.4/Src/Python2/cxxextensions.c 000644 000765 000024 00000004370 13662723705 020357 0 ustar 00barry staff 000000 000000 /*----------------------------------------------------------------------------
//
// Copyright (c) 1998 - 2007, The Regents of the University of California
// Produced at the Lawrence Livermore National Laboratory
// All rights reserved.
//
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
// full copyright notice is contained in the file COPYRIGHT located at the root
// of the PyCXX distribution.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or materials provided with the distribution.
// - Neither the name of the UC/LLNL nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
//---------------------------------------------------------------------------*/
#include "CXX/WrapPython.h"
#ifdef __cplusplus
extern "C"
{
#endif
PyObject py_object_initializer = {PyObject_HEAD_INIT(0)};
#ifdef __cplusplus
}
#endif
pycxx-7.1.4/Src/Python2/cxxsupport.cxx 000644 000765 000024 00000012115 13662723705 020250 0 ustar 00barry staff 000000 000000 //-----------------------------------------------------------------------------
//
// Copyright (c) 1998 - 2007, The Regents of the University of California
// Produced at the Lawrence Livermore National Laboratory
// All rights reserved.
//
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
// full copyright notice is contained in the file COPYRIGHT located at the root
// of the PyCXX distribution.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the disclaimer below.
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the disclaimer (as noted below) in the
// documentation and/or materials provided with the distribution.
// - Neither the name of the UC/LLNL nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
// CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
//-----------------------------------------------------------------------------
#include "CXX/Objects.hxx"
namespace Py {
Py_UNICODE unicode_null_string[1] = { 0 };
Type Object::type () const
{
return Type (PyObject_Type (p), true);
}
String Object::str () const
{
return String (PyObject_Str (p), true);
}
String Object::repr () const
{
return String (PyObject_Repr (p), true);
}
std::string Object::as_string() const
{
return static_cast(str());
}
List Object::dir () const
{
return List (PyObject_Dir (p), true);
}
bool Object::isType (const Type& t) const
{
return type ().ptr() == t.ptr();
}
Char::operator String() const
{
return String(ptr());
}
// TMM: non-member operaters for iterators - see above
// I've also made a bug fix in respect to the cxx code
// (dereffed the left.seq and right.seq comparison)
bool operator==(const Sequence::iterator& left, const Sequence::iterator& right)
{
return left.eql( right );
}
bool operator!=(const Sequence::iterator& left, const Sequence::iterator& right)
{
return left.neq( right );
}
bool operator< (const Sequence::iterator& left, const Sequence::iterator& right)
{
return left.lss( right );
}
bool operator> (const Sequence::iterator& left, const Sequence::iterator& right)
{
return left.gtr( right );
}
bool operator<=(const Sequence::iterator& left, const Sequence::iterator& right)
{
return left.leq( right );
}
bool operator>=(const Sequence::iterator& left, const Sequence::iterator& right)
{
return left.geq( right );
}
// now for const_iterator
bool operator==(const Sequence::const_iterator& left, const Sequence::const_iterator& right)
{
return left.eql( right );
}
bool operator!=(const Sequence::const_iterator& left, const Sequence::const_iterator& right)
{
return left.neq( right );
}
bool operator< (const Sequence::const_iterator& left, const Sequence::const_iterator& right)
{
return left.lss( right );
}
bool operator> (const Sequence::const_iterator& left, const Sequence::const_iterator& right)
{
return left.gtr( right );
}
bool operator<=(const Sequence::const_iterator& left, const Sequence::const_iterator& right)
{
return left.leq( right );
}
bool operator>=(const Sequence::const_iterator& left, const Sequence::const_iterator& right)
{
return left.geq( right );
}
// For mappings:
bool operator==(const Mapping::iterator& left, const Mapping::iterator& right)
{
return left.eql( right );
}
bool operator!=(const Mapping::iterator& left, const Mapping::iterator& right)
{
return left.neq( right );
}
// now for const_iterator
bool operator==(const Mapping::const_iterator& left, const Mapping::const_iterator& right)
{
return left.eql( right );
}
bool operator!=(const Mapping::const_iterator& left, const Mapping::const_iterator& right)
{
return left.neq( right );
}
// TMM: 31May'01 - Added the #ifndef so I can exclude iostreams.
#ifndef CXX_NO_IOSTREAMS
// output
std::ostream& operator<< (std::ostream& os, const Object& ob)
{
return (os << static_cast(ob.str()));
}
#endif
} // Py
pycxx-7.1.4/Src/Python2/cxx_exceptions.cxx 000644 000765 000024 00000003231 12733320460 021040 0 ustar 00barry staff 000000 000000 //
// cxx_exceptions.cxx
//
#include
#include
#include