initial import

This commit is contained in:
Greg Landrum
2006-05-06 22:20:08 +00:00
commit 75a79b6327
2358 changed files with 578190 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
#include <map>
#include <iostream>
#include <string>
#ifndef CLASSA_H
#define CLASSA_H
#ifdef WIN32
#pragma warning (disable: 4786) // warning: long & complicated stl warning
#pragma warning (disable: 4788) // warning: long & complicated stl warning
#pragma warning (disable: 4660)
#pragma warning (disable: 4275) // warning: non dll-interface class used as...
#pragma warning (disable: 4305) // warning: truncation from 'const double' to 'const float'
#endif
class classA {
public:
classA() {
setProp("useless", 10);
};
~classA() {}
void printA() const {
if (hasProp("useless")) {
std::cout << "has useless\n";
}
}
bool hasProp(std::string key) const {
return (dp_props.find(key) != dp_props.end());
}
void setProp(std::string key, int val) {
dp_props[key] = val;
}
private:
std::map<std::string, int> dp_props;
};
#endif

View File

@@ -0,0 +1,54 @@
#include <map>
#include <iostream>
#include <string>
#include <vector>
#ifndef CLASSC_H
#define CLASSC_H
#ifdef WIN32
#pragma warning (disable: 4786) // warning: long & complicated stl warning
#pragma warning (disable: 4788) // warning: long & complicated stl warning
#pragma warning (disable: 4660)
#pragma warning (disable: 4275) // warning: non dll-interface class used as...
#pragma warning (disable: 4305) // warning: truncation from 'const double' to 'const float'
#endif
typedef std::pair<std::string, int> STR_INT;
typedef std::vector<STR_INT> PAIR_VECT;
class classC {
public:
classC() {
setProp("useless", 10);
};
~classC() {}
void printC() const {
if (hasProp("useless")) {
std::cout << "has useless\n";
}
}
bool hasProp(std::string key) const {
PAIR_VECT::const_iterator pvi;
for (pvi = dp_props.begin(); pvi != dp_props.end(); pvi++) {
if (pvi->first == key) {
return true;
}
}
return false;
}
void setProp(std::string key, int val) {
std::pair<std::string, int> newp(key, val);
dp_props.push_back(newp);
}
private:
PAIR_VECT dp_props;
};
#endif

View File

@@ -0,0 +1,68 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "libDatastructs"=..\..\..\DataStructs\libDataStructs.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "moduleB"=.\wrapB.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libDatastructs
End Project Dependency
}}}
###############################################################################
Project: "wrapA"=.\wrapA.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "wrapC"=.\wrapC.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,33 @@
#include <boost/python.hpp>
#include "classA.h"
#include "classC.h"
#include <DataStructs/ExplicitBitVect.h>
namespace python = boost::python;
void testCrossA(classA *A) {
A->printA();
};
void testCrossC(classC *C) {
C->printC();
};
classC *getClassC() {
classC *nc = new classC();
return nc;
}
ExplicitBitVect *getEBV() {
ExplicitBitVect *ebv = new ExplicitBitVect(20);
return ebv;
}
BOOST_PYTHON_MODULE(moduleB)
{
python::def("testCrossA", testCrossA);
python::def("testCrossC", testCrossC);
python::def("GetClassC", getClassC,
python::return_value_policy<python::manage_new_object>());
python::def("GetEBV", getEBV,
python::return_value_policy<python::manage_new_object>());
}

View File

@@ -0,0 +1,66 @@
# Run this with:
# python setup.py install --install-lib=.
from distutils.core import setup,Extension
import RDConfig
# force the use of g++ please
from distutils import sysconfig
save_init_posix = sysconfig._init_posix
def my_init_posix():
print 'my_init_posix: changing gcc to g++'
save_init_posix()
g = sysconfig.get_config_vars()
g['CC'] = 'g++'
g['LDSHARED'] = 'g++ -shared'
g['PY_CFLAGS']= g['PY_CFLAGS'].replace('-O3','')
sysconfig._init_posix = my_init_posix
destDir = RDConfig.RDCodeDir
extDir=RDConfig.RDBaseDir+"/External"
# our stuff
destDir = RDConfig.RDCodeDir
srcDir = RDConfig.RDBaseDir+"/Code"
extDir=RDConfig.RDBaseDir+"/External"
incDirs = [srcDir]
rdbitdir = srcDir + "/DataStructs"
libDirs=[rdbitdir]
libraries=["DataStructs"]
# this is how things are done with BPLv2
boostInc = '-isystem%s'%(extDir+"/boost_1_30_0")
# FIX: there's gotta be a better way of doing this
pyLibDir = '/usr/lib/python2.2/config'
boostLibDir=extDir+"/boost_1_30_0/libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/"
boostLib="boost_python"
libDirs.append(boostLibDir)
libDirs.append(pyLibDir)
libraries.append(boostLib)
libraries.append("python2.2")
compileArgs=['-ftemplate-depth-150',
'-DBOOST_PYTHON_DYNAMIC_LIB',
boostInc,
]
setup(name="crossTest",version="1.0",
ext_modules=[Extension("moduleA",["wrapA.cpp"],
include_dirs=incDirs,
library_dirs=libDirs,
libraries=libraries,
extra_compile_args=compileArgs),
Extension("moduleB",["moduleB.cpp"],
include_dirs=incDirs,
library_dirs=libDirs,
libraries=libraries,
extra_compile_args=compileArgs),
Extension("moduleC",["wrapC.cpp"],
include_dirs=incDirs,
library_dirs=libDirs,
libraries=libraries,
extra_compile_args=compileArgs)])

View File

@@ -0,0 +1,39 @@
#from DataStructs import cDataStructs
from DataStructs import cDataStructs
import moduleA
import moduleB
import moduleC
print "*****************************"
print "Testing self print for classA"
A = moduleA.classA()
A.printA()
print "*****************************"
print
print "*****************************"
print "Testing self print for classC"
C = moduleC.classC()
C.printC()
print "*****************************"
print
print "*****************************"
print "Testing crossing C to B"
moduleB.testCrossC(C)
print "*****************************"
print
cc = moduleB.GetClassC()
cc.printC()
fp = cDataStructs.ExplicitBitVect(20)
print "created fp"
fp = moduleB.GetEBV()
#print "*****************************"
#print "Testing crossing A to B"
#moduleB.testCrossA(A)
#print "*****************************"

View File

@@ -0,0 +1,30 @@
#include "classA.h"
#include <boost/python.hpp>
#ifdef WIN32
#pragma warning (disable: 4786) // warning: long & complicated stl warning
#pragma warning (disable: 4788) // warning: long & complicated stl warning
#pragma warning (disable: 4660)
#pragma warning (disable: 4275) // warning: non dll-interface class used as...
#pragma warning (disable: 4305) // warning: truncation from 'const double' to 'const float'
#endif
namespace python = boost::python;
struct A_wrapper {
static void wrap() {
python::class_<classA>("classA", python::init<>())
.def("printA", &classA::printA)
;
};
};
void wrap_classA() {
A_wrapper::wrap();
}
BOOST_PYTHON_MODULE(moduleA)
{
wrap_classA();
}

View File

@@ -0,0 +1,150 @@
# Microsoft Developer Studio Project File - Name="wrapA" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=wrapA - Win32 DebugPython
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "wrapA.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wrapA.mak" CFG="wrapA - Win32 DebugPython"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "wrapA - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "wrapA - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "wrapA - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "wrapA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "wrapA - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "$(RDBASE)/External/oelib" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /Zm400 /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 boost_python.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib /nologo /subsystem:windows /dll /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"Release/moduleA.dll" /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin/boost_python.dll/msvc/release/runtime-link-dynamic/"
# SUBTRACT LINK32 /verbose /pdb:none /incremental:yes
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=copy dll
PostBuild_Cmds=copy Release\moduleA.dll $(RDBASE)\Python\Chem
# End Special Build Tool
!ELSEIF "$(CFG)" == "wrapA - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "$(RDBASE)/External/oelib" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /GZ /Zm400 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 boost_python_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"moduleA.dll" /pdbtype:sept /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin-stage"
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "wrapA - Win32 DebugPython"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "wrapA_Win32_DebugPython"
# PROP BASE Intermediate_Dir "wrapA_Win32_DebugPython"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "wrapA_Win32_DebugPython"
# PROP Intermediate_Dir "wrapA_Win32_DebugPython"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "$(RDBASE)\external\boost_1_24_0" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /D "BOOST_DEBUG_PYTHON" /FD /GZ /Zm400 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 boost_python.lib, vflib.lib,libDatastructs.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib boost_python.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"DebugPython/moduleA_d.dll" /pdbtype:sept /libpath:"c:\python20\activepython-2.0.0-202\src\core\pcbuild" /libpath:"$(BOOSTBASE)\libs\python\build\bin-stage" /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin-stage"
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=copy dll
PostBuild_Cmds=copy DebugPython\moduleA_d.dll $(RDBASE)\Python\Chem
# End Special Build Tool
!ENDIF
# Begin Target
# Name "wrapA - Win32 Release"
# Name "wrapA - Win32 Debug"
# Name "wrapA - Win32 DebugPython"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\wrapA.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,150 @@
# Microsoft Developer Studio Project File - Name="moduleB" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=moduleB - Win32 DebugPython
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "wrapB.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wrapB.mak" CFG="moduleB - Win32 DebugPython"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "moduleB - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "moduleB - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "moduleB - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "moduleB"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "moduleB - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "$(RDBASE)/External/oelib" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /Zm400 /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 boost_python.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib /nologo /subsystem:windows /dll /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"Release/moduleB.dll" /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin/boost_python.dll/msvc/release/runtime-link-dynamic/"
# SUBTRACT LINK32 /verbose /pdb:none /incremental:yes
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=copy dll
PostBuild_Cmds=copy Release\moduleB.dll $(RDBASE)\Python\Chem
# End Special Build Tool
!ELSEIF "$(CFG)" == "moduleB - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "$(RDBASE)/External/oelib" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /GZ /Zm400 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 boost_python_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"moduleB.dll" /pdbtype:sept /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin-stage"
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "moduleB - Win32 DebugPython"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "moduleB_Win32_DebugPython"
# PROP BASE Intermediate_Dir "moduleB_Win32_DebugPython"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "moduleB_Win32_DebugPython"
# PROP Intermediate_Dir "moduleB_Win32_DebugPython"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "$(RDBASE)\external\boost_1_24_0" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /D "BOOST_DEBUG_PYTHON" /FD /GZ /Zm400 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 boost_python.lib, vflib.lib,libDatastructs.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib boost_python.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"DebugPython/moduleB_d.dll" /pdbtype:sept /libpath:"c:\python20\activepython-2.0.0-202\src\core\pcbuild" /libpath:"$(BOOSTBASE)\libs\python\build\bin-stage" /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin-stage"
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=copy dll
PostBuild_Cmds=copy DebugPython\moduleB_d.dll $(RDBASE)\Python\Chem
# End Special Build Tool
!ENDIF
# Begin Target
# Name "moduleB - Win32 Release"
# Name "moduleB - Win32 Debug"
# Name "moduleB - Win32 DebugPython"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\moduleB.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,31 @@
#ifdef WIN32
#pragma warning (disable: 4786) // warning: long & complicated stl warning
#pragma warning (disable: 4788) // warning: long & complicated stl warning
#pragma warning (disable: 4660)
#pragma warning (disable: 4275) // warning: non dll-interface class used as...
#pragma warning (disable: 4305) // warning: truncation from 'const double' to 'const float'
#endif
#include "classC.h"
#include <boost/python.hpp>
namespace python = boost::python;
struct C_wrapper {
static void wrap() {
python::class_<classC>("classC", python::init<>())
.def("printC", &classC::printC)
;
};
};
void wrap_classC() {
C_wrapper::wrap();
}
BOOST_PYTHON_MODULE(moduleC)
{
wrap_classC();
}

View File

@@ -0,0 +1,150 @@
# Microsoft Developer Studio Project File - Name="wrapC" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=wrapC - Win32 DebugPython
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "wrapC.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wrapC.mak" CFG="wrapC - Win32 DebugPython"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "wrapC - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "wrapC - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "wrapC - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "wrapC"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "wrapC - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "$(RDBASE)/External/oelib" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /Zm400 /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 boost_python.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib /nologo /subsystem:windows /dll /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"Release/moduleC.dll" /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin/boost_python.dll/msvc/release/runtime-link-dynamic/"
# SUBTRACT LINK32 /verbose /pdb:none /incremental:yes
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=copy dll
PostBuild_Cmds=copy Release\moduleC.dll $(RDBASE)\Python\Chem
# End Special Build Tool
!ELSEIF "$(CFG)" == "wrapC - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "$(RDBASE)/External/oelib" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /GZ /Zm400 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 boost_python_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"moduleC.dll" /pdbtype:sept /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin-stage"
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "wrapC - Win32 DebugPython"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "wrapC_Win32_DebugPython"
# PROP BASE Intermediate_Dir "wrapC_Win32_DebugPython"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "wrapC_Win32_DebugPython"
# PROP Intermediate_Dir "wrapC_Win32_DebugPython"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "$(RDBASE)\external\boost_1_24_0" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /D "BOOST_DEBUG_PYTHON" /FD /GZ /Zm400 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 boost_python.lib, vflib.lib,libDatastructs.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib boost_python.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"DebugPython/moduleC_d.dll" /pdbtype:sept /libpath:"c:\python20\activepython-2.0.0-202\src\core\pcbuild" /libpath:"$(BOOSTBASE)\libs\python\build\bin-stage" /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin-stage"
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=copy dll
PostBuild_Cmds=copy DebugPython\moduleC_d.dll $(RDBASE)\Python\Chem
# End Special Build Tool
!ENDIF
# Begin Target
# Name "wrapC - Win32 Release"
# Name "wrapC - Win32 Debug"
# Name "wrapC - Win32 DebugPython"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\wrapC.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,4 @@
CXXFLAGS=-g -I$(RDBASE)/External/$(BOOSTBASE) -I$(RDBASE)/Code/GraphMol
dict.exe: dict.o $(RDBASE)/Code/GraphMol/Invariant/Invariant.o
g++ -o dict.exe $(CFLAGS) dict.o $(RDBASE)/Code/GraphMol/Invariant/Invariant.o

View File

@@ -0,0 +1,103 @@
# Microsoft Developer Studio Project File - Name="any_container_test" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=any_container_test - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "any_container_test.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "any_container_test.mak" CFG="any_container_test - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "any_container_test - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "any_container_test - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "any_container_test - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
LIB32=link.exe -lib
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "$(RDBASE)/External/$(BOOSTBASE)" /I "." /I "$(RDBASE)/Code" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "any_container_test - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "any_container_test___Win32_Debug"
# PROP BASE Intermediate_Dir "any_container_test___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "any_container_test___Win32_Debug"
# PROP Intermediate_Dir "any_container_test___Win32_Debug"
# PROP Target_Dir ""
LIB32=link.exe -lib
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "$(RDBASE)/External/$(BOOSTBASE)" /I "." /I "$(RDBASE)/Code" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "any_container_test - Win32 Release"
# Name "any_container_test - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\any_container_test.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,273 @@
#include <map>
#include <boost/any.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/smart_ptr.hpp>
#include <string>
#include <iostream>
#include <Invariant/Invariant.h>
int idx=0;
class Contained {
public:
Contained() : _idx(idx) {
std::cout << "Contained CTOR:" << _idx << std::endl;
idx++;
}
~Contained() {
std::cout << "Contained DTOR:" << _idx << std::endl;
}
Contained( const Contained &other) : _idx(other._idx) {
std::cout << "Contained Copy CTOR:" << _idx << std::endl;
}
Contained &operator=( const Contained &other) {
_idx = other._idx;
std::cout << "Contained Assign:" << _idx << std::endl;
return *this;
}
int _idx;
};
template <typename T>
struct larger_of {
T operator()(T arg1,T arg2) { return arg1>arg2 ? arg1 : arg2; };
};
struct charptr_functor {
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
};
};
class Dict {
public:
typedef std::map<const char *,boost::any,charptr_functor> DataType;
Dict() {_data.clear();};
Dict(const Dict &other) { _data = other._data; };
Dict &operator=(const Dict &other) {
_data = other._data;
return *this;
};
bool hasVal(const char *what) const {
//DataType::const_iterator i;
//std::cerr << "\t\tpre: ";
//for(i=_data.begin();i!=_data.end();i++){
//std::cerr << (*i).first << " ";
//}
//std::cerr << std::endl;
//std::cerr << "\thasVal: " << what << ": " << _data.count(what) << std::endl;
//std::cerr << "\t\tpost: ";
//for(i=_data.begin();i!=_data.end();i++){
//std::cerr << (*i).first << " ";
//}
//std::cerr << std::endl;
return _data.count(what);
};
bool hasVal(const std::string &what) const {
return hasVal(what.c_str());
};
//
// We're going to try and be somewhat crafty about this getVal stuff to make these
// containers a little bit more generic. The normal behavior here is that the
// value being queried must be directly castable to type T. We'll robustify a
// little bit by trying that and, if the cast fails, attempting a couple of
// other casts, which will then be lexically cast to type T.
//
template <typename T>
void getVal(const char *what,T &res) const {
PRECONDITION(hasVal(what),"getVal called on non-existent key");
const boost::any &val = _data.find(what)->second;
res = boost::any_cast<T>(val);
};
void getVal(const char *what,std::string &res) const {
PRECONDITION(hasVal(what),"getVal called on non-existent key");
const boost::any &val = _data.find(what)->second;
try{
res = boost::any_cast<std::string>(val);
} catch (const boost::bad_any_cast &) {
if(val.type()==typeid(int)){
res = boost::lexical_cast<std::string>(boost::any_cast<int>(val));
} else if(val.type()==typeid(long)){
res = boost::lexical_cast<std::string>(boost::any_cast<long>(val));
} else if(val.type()==typeid(float)){
res = boost::lexical_cast<std::string>(boost::any_cast<float>(val));
} else if(val.type()==typeid(double)){
res = boost::lexical_cast<std::string>(boost::any_cast<double>(val));
} else if(val.type()==typeid(const char *)){
res = std::string(boost::any_cast<const char *>(val));
} else {
throw;
}
}
};
template <typename T>
void getVal(const std::string &what,T &res) const { getVal(what.c_str(),res); };
template <typename T>
void setVal(const char *what,T &val){
_data[what] = boost::any(val);
};
template <typename T>
void setVal(const std::string &what,T &val) { setVal(what.c_str(),val); };
void clearVal(const char *what) { _data.erase(what); };
void reset() { _data.clear(); };
private:
DataType _data;
};
void test1(){
// basic containers
std::cout << "----------- TEST1 -----------" << std::endl;
Contained c;
TEST_ASSERT(c._idx==0);
Contained d(c);
TEST_ASSERT(d._idx==0);
Contained e;
TEST_ASSERT(e._idx==1);
std::cout << "assign" << std::endl;
e=c;
TEST_ASSERT(e._idx==0);
std::cout <<" Done" << std::endl;
}
void test2(){
// shared pointers with containers
std::cout << "----------- TEST2 -----------" << std::endl;
typedef boost::shared_ptr<Contained> CONT_SPTR;
CONT_SPTR s_d(new Contained());
TEST_ASSERT(s_d.use_count()==1);
CONT_SPTR s_e=s_d;
TEST_ASSERT(s_e.use_count()==2);
s_d.reset();
TEST_ASSERT(s_e.use_count()==1);
s_e.reset();
std::cout <<" Done" << std::endl;
}
void test3(){
// basic dict stuff
std::cout << "----------- TEST3 -----------" << std::endl;
Dict dict;
TEST_ASSERT(!dict.hasVal("foo"));
int tmp=4;
dict.setVal("foo",tmp);
TEST_ASSERT(dict.hasVal("foo"));
tmp=0;
dict.getVal("foo",tmp);
TEST_ASSERT(tmp==4);
Dict d2(dict);
TEST_ASSERT(d2.hasVal("foo"));
d2.getVal("foo",tmp);
TEST_ASSERT(tmp==4);
Dict d3;
d3=d2;
TEST_ASSERT(d3.hasVal("foo"));
d3.getVal("foo",tmp);
TEST_ASSERT(tmp==4);
std::cout <<" Done" << std::endl;
}
void test4(){
// dict containing Contained objects
std::cout << "----------- TEST4 -----------" << std::endl;
Dict dict;
TEST_ASSERT(!dict.hasVal("foo"));
Contained tmp;
int hold=tmp._idx;
std::cout << " set" << std::endl;
dict.setVal("foo",tmp);
std::cout << " query" << std::endl;
TEST_ASSERT(dict.hasVal("foo"));
std::cout << " get" << std::endl;
dict.getVal("foo",tmp);
TEST_ASSERT(tmp._idx==hold);
std::cout << " copy" << std::endl;
Dict d2(dict);
TEST_ASSERT(d2.hasVal("foo"));
d2.getVal("foo",tmp);
TEST_ASSERT(tmp._idx==hold);
Dict d3;
d3=d2;
TEST_ASSERT(d3.hasVal("foo"));
d3.getVal("foo",tmp);
TEST_ASSERT(tmp._idx==hold);
std::cout <<" Done" << std::endl;
}
void test5(){
// dict containing sptrs to Contained objects
std::cout << "----------- TEST5 -----------" << std::endl;
typedef boost::shared_ptr<Contained> CONT_SPTR;
Dict dict;
TEST_ASSERT(!dict.hasVal("foo"));
CONT_SPTR tmp(new Contained());
int hold=tmp->_idx;
std::cout << " set" << std::endl;
dict.setVal("foo",tmp);
std::cout << " query" << std::endl;
TEST_ASSERT(dict.hasVal("foo"));
std::cout << " get" << std::endl;
dict.getVal("foo",tmp);
TEST_ASSERT(tmp->_idx==hold);
std::cout << " copy" << std::endl;
Dict d2(dict);
TEST_ASSERT(d2.hasVal("foo"));
d2.getVal("foo",tmp);
TEST_ASSERT(tmp->_idx==hold);
Dict d3;
d3=d2;
TEST_ASSERT(d3.hasVal("foo"));
d3.getVal("foo",tmp);
TEST_ASSERT(tmp->_idx==hold);
std::cout <<" Done" << std::endl;
}
int main(){
test1();
test2();
test3();
test4();
test5();
}

View File

@@ -0,0 +1,42 @@
#include <map>
#include <iostream>
#include <string>
#ifndef CLASSA_H
#define CLASSA_H
#ifdef WIN32
#pragma warning (disable: 4786) // warning: long & complicated stl warning
#pragma warning (disable: 4788) // warning: long & complicated stl warning
#pragma warning (disable: 4660)
#pragma warning (disable: 4275) // warning: non dll-interface class used as...
#pragma warning (disable: 4305) // warning: truncation from 'const double' to 'const float'
#endif
class classA {
public:
classA() {
setProp("useless", 10);
};
~classA() {}
void printA() const {
if (hasProp("useless")) {
std::cout << "has useless\n";
}
}
bool hasProp(std::string key) const {
return (dp_props.find(key) != dp_props.end());
}
void setProp(std::string key, int val) {
dp_props[key] = val;
}
private:
std::map<std::string, int> dp_props;
};
#endif

View File

@@ -0,0 +1,54 @@
#include <map>
#include <iostream>
#include <string>
#include <vector>
#ifndef CLASSC_H
#define CLASSC_H
#ifdef WIN32
#pragma warning (disable: 4786) // warning: long & complicated stl warning
#pragma warning (disable: 4788) // warning: long & complicated stl warning
#pragma warning (disable: 4660)
#pragma warning (disable: 4275) // warning: non dll-interface class used as...
#pragma warning (disable: 4305) // warning: truncation from 'const double' to 'const float'
#endif
typedef std::pair<std::string, int> STR_INT;
typedef std::vector<STR_INT> PAIR_VECT;
class classC {
public:
classC() {
setProp("useless", 10);
};
~classC() {}
void printC() const {
if (hasProp("useless")) {
std::cout << "has useless\n";
}
}
bool hasProp(std::string key) const {
PAIR_VECT::const_iterator pvi;
for (pvi = dp_props.begin(); pvi != dp_props.end(); pvi++) {
if (pvi->first == key) {
return true;
}
}
return false;
}
void setProp(std::string key, int val) {
std::pair<std::string, int> newp(key, val);
dp_props.push_back(newp);
}
private:
PAIR_VECT dp_props;
};
#endif

View File

@@ -0,0 +1,53 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "moduleB"=.\wrapB.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "wrapA"=.\wrapA.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "wrapC"=.\wrapC.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,21 @@
#include <boost/python.hpp>
#include "classA.h"
#include "classC.h"
namespace python = boost::python;
void testCrossA(classA *A) {
A->printA();
};
void testCrossC(classC *C) {
C->printC();
};
BOOST_PYTHON_MODULE(moduleB)
{
python::def("testCrossA", testCrossA);
python::def("testCrossC", testCrossC);
}

View File

@@ -0,0 +1,51 @@
# Run this with:
# python setup.py install --install-lib=.
from distutils.core import setup,Extension
import RDConfig
# force the use of g++ please
from distutils import sysconfig
save_init_posix = sysconfig._init_posix
def my_init_posix():
print 'my_init_posix: changing gcc to g++'
save_init_posix()
g = sysconfig.get_config_vars()
g['CC'] = 'g++'
g['LDSHARED'] = 'g++ -shared'
g['PY_CFLAGS']= g['PY_CFLAGS'].replace('-O3','')
sysconfig._init_posix = my_init_posix
destDir = RDConfig.RDCodeDir
extDir=RDConfig.RDBaseDir+"/External"
# this is how things are done with BPLv2
boostInc = '-isystem%s'%(extDir+"/boost_1_30_0")
incDirs = []
# FIX: there's gotta be a better way of doing this
pyLibDir = '/usr/lib/python2.2/config'
boostLibDir=extDir+"/boost_1_30_0/libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/"
boostLib="boost_python"
libDirs=[boostLibDir,pyLibDir]
libraries=[boostLib,"python2.2"] # have to include g++ here or we get link errors with boost
compileArgs=['-ftemplate-depth-150',
'-DBOOST_PYTHON_DYNAMIC_LIB',
boostInc,
]
setup(name="crossTest",version="1.0",
ext_modules=[Extension("moduleA",["wrapA.cpp"],
include_dirs=incDirs,
library_dirs=libDirs,
libraries=libraries,
extra_compile_args=compileArgs),
Extension("moduleB",["moduleB.cpp"],
include_dirs=incDirs,
library_dirs=libDirs,
libraries=libraries,
extra_compile_args=compileArgs),
Extension("moduleC",["wrapC.cpp"],
include_dirs=incDirs,
library_dirs=libDirs,
libraries=libraries,
extra_compile_args=compileArgs)])

View File

@@ -0,0 +1,28 @@
import moduleA
import moduleB
import moduleC
print "*****************************"
print "Testing self print for classA"
A = moduleA.classA()
A.printA()
print "*****************************"
print
print "*****************************"
print "Testing self print for classC"
C = moduleC.classC()
C.printC()
print "*****************************"
print
print "*****************************"
print "Testing crossing C to B"
moduleB.testCrossC(C)
print "*****************************"
print
print "*****************************"
print "Testing crossing A to B"
moduleB.testCrossA(A)
print "*****************************"

View File

@@ -0,0 +1,30 @@
#include "classA.h"
#include <boost/python.hpp>
#ifdef WIN32
#pragma warning (disable: 4786) // warning: long & complicated stl warning
#pragma warning (disable: 4788) // warning: long & complicated stl warning
#pragma warning (disable: 4660)
#pragma warning (disable: 4275) // warning: non dll-interface class used as...
#pragma warning (disable: 4305) // warning: truncation from 'const double' to 'const float'
#endif
namespace python = boost::python;
struct A_wrapper {
static void wrap() {
python::class_<classA>("classA", python::init<>())
.def("printA", &classA::printA)
;
};
};
void wrap_classA() {
A_wrapper::wrap();
}
BOOST_PYTHON_MODULE(moduleA)
{
wrap_classA();
}

View File

@@ -0,0 +1,150 @@
# Microsoft Developer Studio Project File - Name="wrapA" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=wrapA - Win32 DebugPython
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "wrapA.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wrapA.mak" CFG="wrapA - Win32 DebugPython"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "wrapA - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "wrapA - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "wrapA - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "wrapA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "wrapA - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "$(RDBASE)/External/oelib" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /Zm400 /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 boost_python.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib /nologo /subsystem:windows /dll /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"Release/moduleA.dll" /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin/boost_python.dll/msvc/release/runtime-link-dynamic/"
# SUBTRACT LINK32 /verbose /pdb:none /incremental:yes
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=copy dll
PostBuild_Cmds=copy Release\moduleA.dll $(RDBASE)\Python\Chem
# End Special Build Tool
!ELSEIF "$(CFG)" == "wrapA - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "$(RDBASE)/External/oelib" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /GZ /Zm400 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 boost_python_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"moduleA.dll" /pdbtype:sept /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin-stage"
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "wrapA - Win32 DebugPython"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "wrapA_Win32_DebugPython"
# PROP BASE Intermediate_Dir "wrapA_Win32_DebugPython"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "wrapA_Win32_DebugPython"
# PROP Intermediate_Dir "wrapA_Win32_DebugPython"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "$(RDBASE)\external\boost_1_24_0" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /D "BOOST_DEBUG_PYTHON" /FD /GZ /Zm400 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 boost_python.lib, vflib.lib,libDatastructs.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib boost_python.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"DebugPython/moduleA_d.dll" /pdbtype:sept /libpath:"c:\python20\activepython-2.0.0-202\src\core\pcbuild" /libpath:"$(BOOSTBASE)\libs\python\build\bin-stage" /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin-stage"
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=copy dll
PostBuild_Cmds=copy DebugPython\moduleA_d.dll $(RDBASE)\Python\Chem
# End Special Build Tool
!ENDIF
# Begin Target
# Name "wrapA - Win32 Release"
# Name "wrapA - Win32 Debug"
# Name "wrapA - Win32 DebugPython"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\wrapA.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,150 @@
# Microsoft Developer Studio Project File - Name="moduleB" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=moduleB - Win32 DebugPython
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "wrapB.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wrapB.mak" CFG="moduleB - Win32 DebugPython"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "moduleB - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "moduleB - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "moduleB - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "moduleB"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "moduleB - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "$(RDBASE)/External/oelib" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /Zm400 /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 boost_python.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib /nologo /subsystem:windows /dll /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"Release/moduleB.dll" /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin/boost_python.dll/msvc/release/runtime-link-dynamic/"
# SUBTRACT LINK32 /verbose /pdb:none /incremental:yes
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=copy dll
PostBuild_Cmds=copy Release\moduleB.dll $(RDBASE)\Python\Chem
# End Special Build Tool
!ELSEIF "$(CFG)" == "moduleB - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "$(RDBASE)/External/oelib" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /GZ /Zm400 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 boost_python_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"moduleB.dll" /pdbtype:sept /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin-stage"
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "moduleB - Win32 DebugPython"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "moduleB_Win32_DebugPython"
# PROP BASE Intermediate_Dir "moduleB_Win32_DebugPython"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "moduleB_Win32_DebugPython"
# PROP Intermediate_Dir "moduleB_Win32_DebugPython"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "$(RDBASE)\external\boost_1_24_0" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /D "BOOST_DEBUG_PYTHON" /FD /GZ /Zm400 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 boost_python.lib, vflib.lib,libDatastructs.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib boost_python.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"DebugPython/moduleB_d.dll" /pdbtype:sept /libpath:"c:\python20\activepython-2.0.0-202\src\core\pcbuild" /libpath:"$(BOOSTBASE)\libs\python\build\bin-stage" /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin-stage"
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=copy dll
PostBuild_Cmds=copy DebugPython\moduleB_d.dll $(RDBASE)\Python\Chem
# End Special Build Tool
!ENDIF
# Begin Target
# Name "moduleB - Win32 Release"
# Name "moduleB - Win32 Debug"
# Name "moduleB - Win32 DebugPython"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\moduleB.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,30 @@
#include "classC.h"
#include <boost/python.hpp>
#ifdef WIN32
#pragma warning (disable: 4786) // warning: long & complicated stl warning
#pragma warning (disable: 4788) // warning: long & complicated stl warning
#pragma warning (disable: 4660)
#pragma warning (disable: 4275) // warning: non dll-interface class used as...
#pragma warning (disable: 4305) // warning: truncation from 'const double' to 'const float'
#endif
namespace python = boost::python;
struct C_wrapper {
static void wrap() {
python::class_<classC>("classC", python::init<>())
.def("printC", &classC::printC)
;
};
};
void wrap_classC() {
C_wrapper::wrap();
}
BOOST_PYTHON_MODULE(moduleC)
{
wrap_classC();
}

View File

@@ -0,0 +1,150 @@
# Microsoft Developer Studio Project File - Name="wrapC" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=wrapC - Win32 DebugPython
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "wrapC.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wrapC.mak" CFG="wrapC - Win32 DebugPython"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "wrapC - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "wrapC - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "wrapC - Win32 DebugPython" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "wrapC"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "wrapC - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "$(RDBASE)/External/oelib" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /Zm400 /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 boost_python.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib /nologo /subsystem:windows /dll /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"Release/moduleC.dll" /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin/boost_python.dll/msvc/release/runtime-link-dynamic/"
# SUBTRACT LINK32 /verbose /pdb:none /incremental:yes
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=copy dll
PostBuild_Cmds=copy Release\moduleC.dll $(RDBASE)\Python\Chem
# End Special Build Tool
!ELSEIF "$(CFG)" == "wrapC - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "$(RDBASE)/External/oelib" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /GZ /Zm400 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 boost_python_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"moduleC.dll" /pdbtype:sept /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin-stage"
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "wrapC - Win32 DebugPython"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "wrapC_Win32_DebugPython"
# PROP BASE Intermediate_Dir "wrapC_Win32_DebugPython"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "wrapC_Win32_DebugPython"
# PROP Intermediate_Dir "wrapC_Win32_DebugPython"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GR /GX /Zi /Od /I "$(RDBASE)\external\boost_1_24_0" /I "$(RDBASE)/Code/GraphMol" /I "$(PYTHONHOME)\include" /I "$(RDBASE)/External/$(BOOSTBASE)" /I "$(RDBASE)/Code" /I "$(RDBASE)/External/vflib-2.0/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TEST_EXPORTS" /D "BOOST_DEBUG_PYTHON" /FD /GZ /Zm400 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 boost_python.lib, vflib.lib,libDatastructs.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHONVERS).lib BLAS.lib LAPACK.lib boost_python.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcprtdlib.lib" /out:"DebugPython/moduleC_d.dll" /pdbtype:sept /libpath:"c:\python20\activepython-2.0.0-202\src\core\pcbuild" /libpath:"$(BOOSTBASE)\libs\python\build\bin-stage" /libpath:"$(PYTHONHOME)\libs" /libpath:"$(RDBASE)\External\Lapack\win32" /libpath:"$(RDBASE)/External/$(BOOSTBASE)/libs/python/build/bin-stage"
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=copy dll
PostBuild_Cmds=copy DebugPython\moduleC_d.dll $(RDBASE)\Python\Chem
# End Special Build Tool
!ENDIF
# Begin Target
# Name "wrapC - Win32 Release"
# Name "wrapC - Win32 Debug"
# Name "wrapC - Win32 DebugPython"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\wrapC.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,15 @@
//
// Copyright (C) 2003 Rational Discovery LLC
//
#include "mods.h"
namespace python = boost::python;
BOOST_PYTHON_MODULE(moda)
{
python::class_<ClassA>("ClassA")
.def("Get4",&ClassA::get4)
;
}

View File

@@ -0,0 +1,18 @@
//
// Copyright (C) 2003 Rational Discovery LLC
//
#include "mods.h"
namespace python = boost::python;
BOOST_PYTHON_MODULE(modb)
{
python::class_<ClassB>("ClassB")
.def("Get3",&ClassB::get3)
.def("ReturnOther",&ClassB::returnOther,
python::return_value_policy<python::manage_new_object>())
.def("AcceptOther",&ClassB::acceptOther)
;
}

View File

@@ -0,0 +1,18 @@
//
// Copyright (C) 2003 Rational Discovery LLC
//
#include <boost/python.hpp>
class ClassA{
public:
int get4() { return 4; };
};
class ClassB{
public:
ClassA *returnOther() { return new ClassA; };
int get3() { return 3; };
int acceptOther(ClassA *other) { return other->get4();};
};

View File

@@ -0,0 +1 @@
Demo showing how to deal with BPL-wrapped objects between modules.

View File

@@ -0,0 +1,46 @@
# Run this with:
# python setup.py install --install-lib=.
from distutils.core import setup,Extension
import RDConfig
# force the use of g++ please
from distutils import sysconfig
save_init_posix = sysconfig._init_posix
def my_init_posix():
print 'my_init_posix: changing gcc to g++'
save_init_posix()
g = sysconfig.get_config_vars()
g['CC'] = 'g++'
g['LDSHARED'] = 'g++ -shared'
g['PY_CFLAGS']= g['PY_CFLAGS'].replace('-O3','')
sysconfig._init_posix = my_init_posix
destDir = RDConfig.RDCodeDir
extDir=RDConfig.RDBaseDir+"/External"
# this is how things are done with BPLv2
boostInc = '-isystem%s'%(extDir+"/boost_1_29_0")
incDirs = []
# FIX: there's gotta be a better way of doing this
pyLibDir = '/usr/lib/python2.2/config'
boostLibDir=extDir+"/boost_1_29_0/libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/"
boostLib="boost_python"
libDirs=[boostLibDir,pyLibDir]
libraries=[boostLib,"python2.2"] # have to include g++ here or we get link errors with boost
compileArgs=['-ftemplate-depth-150',
'-DBOOST_PYTHON_DYNAMIC_LIB',
boostInc,
]
setup(name="moda",version="1.0",
ext_modules=[Extension("moda",["moda.cpp"],
include_dirs=incDirs,
library_dirs=libDirs,
libraries=libraries,
extra_compile_args=compileArgs),
Extension("modb",["modb.cpp"],
include_dirs=incDirs,
library_dirs=libDirs,
libraries=libraries,
extra_compile_args=compileArgs)])

View File

@@ -0,0 +1,13 @@
import moda
import modb
ca = moda.ClassA()
print 'ca:',ca.Get4()
cb = modb.ClassB()
print 'cb:',cb.Get3()
newca = cb.ReturnOther()
print 'new:',newca.Get4()
print 'arg:',cb.AcceptOther(newca)

View File

@@ -0,0 +1,42 @@
//
// Copyright (C) 2003 Rational Discovery LLC
//
#include <boost/python.hpp>
#include <boost/python/numeric.hpp>
#define PY_ARRAY_UNIQUE_SYMBOL RD_array_API
#include "Numeric/arrayobject.h"
namespace python = boost::python;
double GetFirstElement(python::numeric::array &x){
PyArrayObject *ptr = (PyArrayObject *)x.ptr();
void* data = ptr->data;
double res=0.0;
switch(ptr->descr->type_num)
{
case PyArray_DOUBLE:
res = ((double *)data)[0];
break;
case PyArray_FLOAT:
res = (double)((float *)data)[0];
break;
case PyArray_LONG:
res = (double)((long *)data)[0];
break;
case PyArray_INT:
res = (double)((int *)data)[0];
break;
}
return res;
}
BOOST_PYTHON_MODULE(linalg)
{
python::def("GetFirstElement",GetFirstElement);
}

42
Code/Demos/boost/numpy/setup.py Executable file
View File

@@ -0,0 +1,42 @@
# Run this with:
# python setup.py install --install-lib=.
from distutils.core import setup,Extension
import RDConfig
# force the use of g++ please
from distutils import sysconfig
save_init_posix = sysconfig._init_posix
def my_init_posix():
print 'my_init_posix: changing gcc to g++'
save_init_posix()
g = sysconfig.get_config_vars()
g['CC'] = 'g++'
g['LDSHARED'] = 'g++ -shared'
g['PY_CFLAGS']= g['PY_CFLAGS'].replace('-O3','')
sysconfig._init_posix = my_init_posix
destDir = RDConfig.RDCodeDir
extDir=RDConfig.RDBaseDir+"/External"
# this is how things are done with BPLv2
boostInc = '-isystem%s'%(extDir+"/boost_1_29_0")
incDirs = []
# FIX: there's gotta be a better way of doing this
pyLibDir = '/usr/lib/python2.2/config'
boostLibDir=extDir+"/boost_1_29_0/libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/"
boostLib="boost_python"
libDirs=[boostLibDir,pyLibDir]
libraries=[boostLib,"python2.2"] # have to include g++ here or we get link errors with boost
compileArgs=['-ftemplate-depth-150',
'-DBOOST_PYTHON_DYNAMIC_LIB',
boostInc,
]
setup(name="demo",version="1.0",
ext_modules=[Extension("linalg",["linalg.cpp"],
include_dirs=incDirs,
library_dirs=libDirs,
libraries=libraries,
extra_compile_args=compileArgs)])

7
Code/Demos/boost/numpy/test.py Executable file
View File

@@ -0,0 +1,7 @@
from Numeric import *
import linalg
print linalg.GetFirstElement(array([1,0,2],Int))
print linalg.GetFirstElement(array([1,0,2],Float))
print linalg.GetFirstElement(array([1,0,2],Float64))
print linalg.GetFirstElement(array([1,0,2],Complex)) # will be zero

View File

@@ -0,0 +1,48 @@
//
// Copyright (C) 2003 Rational Discovery LLC
//
#include <boost/python.hpp>
namespace python = boost::python;
// ------
//
// This one is relatively easy:
// expose a function with a default argument
//
// ------
int func2(int v1,int plus=3);
int func2(int v1,int plus) {return v1+plus;};
BOOST_PYTHON_FUNCTION_OVERLOADS(f2_overloads, func2, 1, 2)
// ------
//
// More complex:
// expose a templated function with a default argument
//
// ------
template <typename T>
T func(T v1,int plus=3);
template <typename T>
T func(T v1,int plus) {
return v1+plus;
}
int (*f1_int)(int,int=3)=func; // gotta love that syntax!
BOOST_PYTHON_FUNCTION_OVERLOADS(f1_int_overloads, f1_int, 1, 2)
float (*f1_float)(float,int=3)=func;
BOOST_PYTHON_FUNCTION_OVERLOADS(f1_float_overloads, f1_float, 1, 2)
BOOST_PYTHON_MODULE(overloads)
{
python::def("f2",func2,f2_overloads(python::args("v1","plus")));
python::def("f1",f1_int,f1_int_overloads(python::args("v1","plus")));
python::def("f1",f1_float,f1_float_overloads(python::args("v1","plus")));
}

View File

@@ -0,0 +1,42 @@
# Run this with:
# python setup.py install --install-lib=.
from distutils.core import setup,Extension
import RDConfig
# force the use of g++ please
from distutils import sysconfig
save_init_posix = sysconfig._init_posix
def my_init_posix():
print 'my_init_posix: changing gcc to g++'
save_init_posix()
g = sysconfig.get_config_vars()
g['CC'] = 'g++'
g['LDSHARED'] = 'g++ -shared'
g['PY_CFLAGS']= g['PY_CFLAGS'].replace('-O3','')
sysconfig._init_posix = my_init_posix
destDir = RDConfig.RDCodeDir
extDir=RDConfig.RDBaseDir+"/External"
# this is how things are done with BPLv2
boostInc = '-isystem%s'%(extDir+"/boost_1_29_0")
incDirs = []
# FIX: there's gotta be a better way of doing this
pyLibDir = '/usr/lib/python2.2/config'
boostLibDir=extDir+"/boost_1_29_0/libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/"
boostLib="boost_python"
libDirs=[boostLibDir,pyLibDir]
libraries=[boostLib,"python2.2"] # have to include g++ here or we get link errors with boost
compileArgs=['-ftemplate-depth-150',
'-DBOOST_PYTHON_DYNAMIC_LIB',
boostInc,
]
setup(name="overloads",version="1.0",
ext_modules=[Extension("overloads",["overloads.cpp"],
include_dirs=incDirs,
library_dirs=libDirs,
libraries=libraries,
extra_compile_args=compileArgs)])

View File

@@ -0,0 +1,12 @@
import overloads
assert overloads.f1(1)==4
assert overloads.f1(1,4)==5
assert overloads.f1(1.)==4.
assert overloads.f1(1.,5)==6.
assert overloads.f2(1)==4
assert overloads.f2(1,12)==13

View File

@@ -0,0 +1,34 @@
//
// Copyright (C) 2003 Rational Discovery LLC
//
#include <boost/python.hpp>
#include <boost/python/detail/api_placeholder.hpp>
namespace python = boost::python;
// ----------
//
// In both cases here, the restriction on the object passed in is
// solely that it support the functions used.
//
// ----------
int seq_len(python::object seq){
return python::len(seq);
}
int sum_first2(python::object seq){
int sum;
sum = python::extract<int>(seq[0]) + python::extract<int>(seq[1]);
return sum;
}
BOOST_PYTHON_MODULE(python_objs)
{
python::def("seq_len",seq_len);
python::def("sum_first2",sum_first2);
}

View File

@@ -0,0 +1,42 @@
# Run this with:
# python setup.py install --install-lib=.
from distutils.core import setup,Extension
import RDConfig
# force the use of g++ please
from distutils import sysconfig
save_init_posix = sysconfig._init_posix
def my_init_posix():
print 'my_init_posix: changing gcc to g++'
save_init_posix()
g = sysconfig.get_config_vars()
g['CC'] = 'g++'
g['LDSHARED'] = 'g++ -shared'
g['PY_CFLAGS']= g['PY_CFLAGS'].replace('-O3','')
sysconfig._init_posix = my_init_posix
destDir = RDConfig.RDCodeDir
extDir=RDConfig.RDBaseDir+"/External"
# this is how things are done with BPLv2
boostInc = '-isystem%s'%(extDir+"/boost_1_29_0")
incDirs = []
# FIX: there's gotta be a better way of doing this
pyLibDir = '/usr/lib/python2.2/config'
boostLibDir=extDir+"/boost_1_29_0/libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/"
boostLib="boost_python"
libDirs=[boostLibDir,pyLibDir]
libraries=[boostLib,"python2.2"] # have to include g++ here or we get link errors with boost
compileArgs=['-ftemplate-depth-150',
'-DBOOST_PYTHON_DYNAMIC_LIB',
boostInc,
]
setup(name="python_objs",version="1.0",
ext_modules=[Extension("python_objs",["python_objs.cpp"],
include_dirs=incDirs,
library_dirs=libDirs,
libraries=libraries,
extra_compile_args=compileArgs)])

View File

@@ -0,0 +1,47 @@
import python_objs
def lentest():
assert python_objs.seq_len([1,2])==2
assert python_objs.seq_len((1,2))==2
assert python_objs.seq_len("fooo")==4
try:
python_objs.seq_len(1)
except TypeError:
pass
except:
assert 0,'wrong exception type'
else:
assert 0,'no exception'
def sumtest():
assert python_objs.sum_first2([1,2])==3
assert python_objs.sum_first2((1,3))==4
try:
python_objs.sum_first2((1.,3.))
except TypeError:
pass
except:
assert 0,'wrong exception type'
else:
assert 0,'no exception'
try:
python_objs.sum_first2('foo')
except TypeError:
pass
except:
assert 0,'wrong exception type'
else:
assert 0,'no exception'
try:
python_objs.sum_first2(1)
except TypeError:
pass
except:
assert 0,'wrong exception type'
else:
assert 0,'no exception'
lentest()
sumtest()

View File

@@ -0,0 +1,103 @@
// Copyright Rational Discovery LLC 2005.
// 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)
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include <boost/shared_ptr.hpp>
#include <vector>
namespace python = boost::python;
class DemoKlass {
public:
explicit DemoKlass(int v) : val_(v) {};
int getVal() const { return val_; };
private:
int val_;
};
typedef boost::shared_ptr<DemoKlass> DemoKlassSPtr;
typedef std::vector<DemoKlass*> DemoKlassPtrVect;
typedef std::vector<DemoKlassSPtr> DemoKlassSPtrVect;
DemoKlass *buildPtr(int v) {
return new DemoKlass(v);
}
DemoKlassSPtr buildSPtr(int v) {
return DemoKlassSPtr(new DemoKlass(v));
}
DemoKlassPtrVect buildPtrVector(unsigned int sz){
DemoKlassPtrVect res;
for(unsigned int i=0;i<sz;i++){
res.push_back(new DemoKlass(i));
}
return res;
}
DemoKlassSPtrVect buildSPtrVector(unsigned int sz){
DemoKlassSPtrVect res;
for(unsigned int i=0;i<sz;i++){
res.push_back(DemoKlassSPtr(new DemoKlass(i)));
}
return res;
}
class DemoContainer {
public:
typedef DemoKlassSPtrVect::iterator iterator;
typedef DemoKlassSPtrVect::const_iterator const_iterator;
explicit DemoContainer(unsigned int sz) {
vect_ = buildSPtrVector(sz);
}
iterator begin() {
return vect_.begin();
}
iterator end() {
return vect_.end();
}
const_iterator begin() const {
return vect_.begin();
}
const_iterator end() const {
return vect_.end();
}
private:
DemoKlassSPtrVect vect_;
};
BOOST_PYTHON_MODULE(SPtrTestModule)
{
python::class_<DemoKlass,DemoKlassSPtr >("DemoKlass","demo class",python::init<int>())
.def("GetVal",&DemoKlass::getVal)
;
python::def("buildPtr",buildPtr,python::return_value_policy<python::manage_new_object>());
python::def("buildSPtr",buildSPtr);
python::class_<DemoKlassPtrVect>("DemoKlassPtrVec")
.def(python::vector_indexing_suite<DemoKlassPtrVect>())
;
python::def("buildPtrVector",buildPtrVector);
python::class_<DemoKlassSPtrVect>("DemoKlassSPtrVec")
.def(python::vector_indexing_suite<DemoKlassSPtrVect,true>())
;
python::def("buildSPtrVector",buildSPtrVector);
python::class_<DemoContainer>("DemoContainer","demo container",python::init<unsigned int>())
.def("__iter__",python::iterator<DemoContainer>())
;
}

View File

@@ -0,0 +1,13 @@
# Run this with:
# python setup.py install --install-lib=.
from RDBuild import *
from distutils.core import setup,Extension
setup(name="SPtrTestModule",version="1.0",
ext_modules=[Extension("SPtrTestModule",["module.cpp"],
library_dirs=libDirs,
libraries=libraries,
extra_link_args=linkArgs,
extra_compile_args=compileArgs)])

View File

@@ -0,0 +1,51 @@
# Copyright Rational Discovery LLC 2005
# 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 SPtrTestModule as TestModule
import unittest
class TestCase(unittest.TestCase):
def setUp(self):
pass
def test1(self):
obj = TestModule.DemoKlass(3);
self.failUnless(obj.GetVal()==3)
def test2(self):
obj = TestModule.buildPtr(3);
self.failUnless(obj.GetVal()==3)
def test3(self):
obj = TestModule.buildSPtr(3);
self.failUnless(obj.GetVal()==3)
def test4(self):
sz = 5
vect = TestModule.buildPtrVector(sz)
self.failUnless(len(vect)==sz)
for i in range(sz):
self.failUnless(vect[i].GetVal()==i)
def test5(self):
sz = 5
vect = TestModule.buildSPtrVector(sz)
self.failUnless(len(vect)==sz)
for i in range(sz):
self.failUnless(vect[i].GetVal()==i)
def test5b(self):
sz = 5
vect = TestModule.buildSPtrVector(sz)
self.failUnless(len(vect)==sz)
p = 0
for itm in vect:
self.failUnless(itm.GetVal()==p)
p+=1
def test6(self):
sz = 5
cont = TestModule.DemoContainer(sz)
p = 0
for itm in cont:
self.failUnless(itm.GetVal()==p)
p+=1
self.failUnless(p==sz)
if __name__ == '__main__':
unittest.main()