* Reverted r2535 except for changes to scripts/perl/Makefile.PL

* scripts/openbabel-python.i: Updated SWIG interface file to ignore 21 methods of each std::vector created. This should substantially reduce the size of the wrapper code
This commit is contained in:
Noel O'Boyle
2008-06-17 19:03:50 +00:00
parent 5b53678b4d
commit 625a89e365
8 changed files with 123 additions and 232 deletions

View File

@@ -1,3 +1,10 @@
2008-06-17 Noel O'Boyle <baoilleach@gmail.com>
* Reverted r2535 except for changes to scripts/perl/Makefile.PL
* scripts/openbabel-python.i: Updated SWIG interface file to ignore 21
methods of each std::vector created. This should substantially reduce
the size of the wrapper code.
2008-06-16 Tim Vandermeersch <tim.vandermeersch@gmail.com>
* src/formats/xtcformat.cpp: make confs a std::vector too. Was double

View File

@@ -20,9 +20,8 @@ dist-hook:
if MAINTAINER_MODE
if BUILD_SWIG
BUILT_SOURCES = perl/openbabel_perl.cpp \
java/openbabel_java.cpp csharp/openbabel_csharp.cpp \
python/obcore.cpp python/obconversion.cpp python/obtemplate.cpp
BUILT_SOURCES = perl/openbabel_perl.cpp python/openbabel_python.cpp \
java/openbabel_java.cpp csharp/openbabel_csharp.cpp
script_includes = $(top_srcdir)/include/openbabel
script_headers = $(script_includes)/mol.h $(script_includes)/obconversion.h \
@@ -35,17 +34,19 @@ perl/openbabel_perl.cpp: openbabel-perl.i $(script_headers)
sed -e "s/^@EXPORT.*/& sub dl_load_flags { 0x01 }/" <perl/OpenBabel.pm >perl/OpenBabel.new;
mv perl/OpenBabel.new perl/OpenBabel.pm;
python/obconversion.cpp: openbabel-python2.i $(script_headers)
$(SWIG) -small -O -python -templatereduce -naturalvar \
-c++ -o $@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
python/obtemplate.cpp: openbabel-python3.i $(script_headers)
$(SWIG) -small -O -python -templatereduce -naturalvar \
-c++ -o $@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
python/obcore.cpp: openbabel-python.i $(script_headers)
python/openbabel_python.cpp: openbabel-python.i $(script_headers)
$(SWIG) -small -O -python -templatereduce -naturalvar \
-c++ -o $@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
echo "import sys" >python/ob.py;
echo "if sys.platform.find(\"linux\") != -1:" >>python/ob.py;
echo " try:" >>python/ob.py;
echo " import dl" >>python/ob.py;
echo " except ImportError:" >>python/ob.py;
echo " import DLFCN as dl" >>python/ob.py;
echo " sys.setdlopenflags(sys.getdlopenflags() | dl.RTLD_GLOBAL)" >>python/ob.py;
echo >>python/ob.py;
cat python/openbabel.py >>python/ob.py;
mv python/ob.py python/openbabel.py;
java/openbabel_java.cpp: openbabel-java.i $(script_headers)
$(SWIG) -small -O -java -naturalvar -templatereduce -c++ -o $@ \

View File

@@ -34,12 +34,8 @@ host_triplet = @host@
subdir = scripts
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/autoconf/libtool.m4 \
$(top_srcdir)/autoconf/ltoptions.m4 \
$(top_srcdir)/autoconf/ltsugar.m4 \
$(top_srcdir)/autoconf/ltversion.m4 \
$(top_srcdir)/autoconf/lt~obsolete.m4 \
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -93,7 +89,6 @@ LIBDL = @LIBDL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
@@ -103,8 +98,6 @@ NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
@@ -180,7 +173,6 @@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = openbabel-perl.i perl \
@@ -193,11 +185,9 @@ EXTRA_DIST = openbabel-perl.i perl \
# build the scripting language interfaces if --enable-maintainer-mode was set
# and SWIG is available -- please use the most recent version of SWIG
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@BUILT_SOURCES = perl/openbabel_perl.cpp \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ python/openbabel_python.cpp \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ java/openbabel_java.cpp \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ csharp/openbabel_csharp.cpp \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ python/obcore.cpp \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ python/obconversion.cpp \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ python/obtemplate.cpp \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ $(am__append_1)
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@script_includes = $(top_srcdir)/include/openbabel
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@script_headers = $(script_includes)/mol.h $(script_includes)/obconversion.h \
@@ -396,17 +386,19 @@ dist-hook:
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ sed -e "s/^@EXPORT.*/& sub dl_load_flags { 0x01 }/" <perl/OpenBabel.pm >perl/OpenBabel.new;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ mv perl/OpenBabel.new perl/OpenBabel.pm;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@python/obconversion.cpp: openbabel-python2.i $(script_headers)
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ $(SWIG) -small -O -python -templatereduce -naturalvar \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ -c++ -o $@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@python/obtemplate.cpp: openbabel-python3.i $(script_headers)
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ $(SWIG) -small -O -python -templatereduce -naturalvar \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ -c++ -o $@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@python/obcore.cpp: openbabel-python.i $(script_headers)
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@python/openbabel_python.cpp: openbabel-python.i $(script_headers)
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ $(SWIG) -small -O -python -templatereduce -naturalvar \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ -c++ -o $@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo "import sys" >python/ob.py;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo "if sys.platform.find(\"linux\") != -1:" >>python/ob.py;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo " try:" >>python/ob.py;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo " import dl" >>python/ob.py;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo " except ImportError:" >>python/ob.py;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo " import DLFCN as dl" >>python/ob.py;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo " sys.setdlopenflags(sys.getdlopenflags() | dl.RTLD_GLOBAL)" >>python/ob.py;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo >>python/ob.py;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ cat python/openbabel.py >>python/ob.py;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ mv python/ob.py python/openbabel.py;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@java/openbabel_java.cpp: openbabel-java.i $(script_headers)
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ $(SWIG) -small -O -java -naturalvar -templatereduce -c++ -o $@ \

View File

@@ -1,4 +1,4 @@
%module obcore
%module openbabel
%{
// used to set import/export for Cygwin DLLs
@@ -41,6 +41,79 @@
%}
%include "std_list.i"
%include "std_map.i"
%include "std_vector.i"
%include "std_string.i"
namespace std {
%define VVTEMPLATE_WRAP(name, T)
%feature("ignore") vector< vector<T> >::append;
%feature("ignore") vector< vector<T> >::assign;
%feature("ignore") vector< vector<T> >::back;
%feature("ignore") vector< vector<T> >::begin;
%feature("ignore") vector< vector<T> >::capacity;
%feature("ignore") vector< vector<T> >::clear;
%feature("ignore") vector< vector<T> >::empty;
%feature("ignore") vector< vector<T> >::end;
%feature("ignore") vector< vector<T> >::erase;
%feature("ignore") vector< vector<T> >::front;
%feature("ignore") vector< vector<T> >::get_allocator;
%feature("ignore") vector< vector<T> >::insert;
%feature("ignore") vector< vector<T> >::pop;
%feature("ignore") vector< vector<T> >::pop_back;
%feature("ignore") vector< vector<T> >::push_back;
%feature("ignore") vector< vector<T> >::rbegin;
%feature("ignore") vector< vector<T> >::rend;
%feature("ignore") vector< vector<T> >::reserve;
%feature("ignore") vector< vector<T> >::resize;
%feature("ignore") vector< vector<T> >::size;
%feature("ignore") vector< vector<T> >::swap;
%template(vectorv ## name) vector< vector<T> >;
%enddef
%define VECTORTEMPLATE_WRAP(vectorname, T)
%feature("ignore") vector<T>::append;
%feature("ignore") vector<T>::assign;
%feature("ignore") vector<T>::back;
%feature("ignore") vector<T>::begin;
%feature("ignore") vector<T>::capacity;
%feature("ignore") vector<T>::clear;
%feature("ignore") vector<T>::empty;
%feature("ignore") vector<T>::end;
%feature("ignore") vector<T>::erase;
%feature("ignore") vector<T>::front;
%feature("ignore") vector<T>::get_allocator;
%feature("ignore") vector<T>::insert;
%feature("ignore") vector<T>::pop;
%feature("ignore") vector<T>::pop_back;
%feature("ignore") vector<T>::push_back;
%feature("ignore") vector<T>::rbegin;
%feature("ignore") vector<T>::rend;
%feature("ignore") vector<T>::reserve;
%feature("ignore") vector<T>::resize;
%feature("ignore") vector<T>::size;
%feature("ignore") vector<T>::swap;
%template(vector ## vectorname) vector<T>;
%enddef
VECTORTEMPLATE_WRAP(Int, int)
VECTORTEMPLATE_WRAP(UnsignedInt, unsigned int)
VVTEMPLATE_WRAP(Int, int)
VECTORTEMPLATE_WRAP(Double, double)
VECTORTEMPLATE_WRAP(String, std::string)
VECTORTEMPLATE_WRAP(Vector3, OpenBabel::vector3)
VECTORTEMPLATE_WRAP(OBMol, OpenBabel::OBMol)
VECTORTEMPLATE_WRAP(OBBond, OpenBabel::OBBond)
VECTORTEMPLATE_WRAP(OBResidue, OpenBabel::OBResidue)
VECTORTEMPLATE_WRAP(OBRing, OpenBabel::OBRing)
VECTORTEMPLATE_WRAP(pOBRing, OpenBabel::OBRing*)
VECTORTEMPLATE_WRAP(pOBGenericData, OpenBabel::OBGenericData*)
}
%inline %{
OpenBabel::OBPairData *toPairData(OpenBabel::OBGenericData *data) {
return (OpenBabel::OBPairData *) data;
@@ -73,11 +146,11 @@ OpenBabel::OBUnitCell *toUnitCell(OpenBabel::OBGenericData *data) {
//# %import <openbabel/bitvec.h>
%import <openbabel/typer.h>
%import <openbabel/plugin.h>
%include <openbabel/plugin.h>
%import <openbabel/oberror.h>
%import <openbabel/format.h>
%import <openbabel/obconversion.h>
%include <openbabel/oberror.h>
%include <openbabel/format.h>
%include <openbabel/obconversion.h>
%include <openbabel/residue.h>
%include <openbabel/internalcoord.h>
%include <openbabel/atom.h>
@@ -88,11 +161,11 @@ OpenBabel::OBUnitCell *toUnitCell(OpenBabel::OBGenericData *data) {
%include <openbabel/alias.h>
%include <openbabel/atomclass.h>
%import <openbabel/fingerprint.h>
%import <openbabel/descriptor.h>
%import <openbabel/forcefield.h>
%include <openbabel/fingerprint.h>
%include <openbabel/descriptor.h>
%include <openbabel/forcefield.h>
%import <openbabel/op.h>
%include <openbabel/op.h>
%include <openbabel/bitvec.h>

View File

@@ -1,92 +0,0 @@
%module obconversion
%{
// used to set import/export for Cygwin DLLs
#ifdef WIN32
#define USING_OBDLL
#endif
#include <openbabel/base.h>
#include <openbabel/generic.h>
#include <openbabel/griddata.h>
#include <openbabel/math/vector3.h>
#include <openbabel/bitvec.h>
#include <openbabel/mol.h>
#include <openbabel/obconversion.h>
#include <openbabel/oberror.h>
#include <openbabel/plugin.h>
#include <openbabel/fingerprint.h>
#include <openbabel/descriptor.h>
#include <openbabel/format.h>
#include <openbabel/forcefield.h>
#include <openbabel/op.h>
%}
// These methods are renamed to valid Python method names, as otherwise
// they cannot be used from Python
%rename(inc) *::operator++;
%rename(good) *::operator bool;
%import <openbabel/babelconfig.h>
%import <openbabel/base.h>
%import <openbabel/generic.h>
%import <openbabel/griddata.h>
%import <openbabel/math/vector3.h>
%import <openbabel/bitvec.h>
%import <openbabel/chains.h>
%import <openbabel/typer.h>
%include <openbabel/plugin.h>
%include <openbabel/oberror.h>
%include <openbabel/format.h>
%include <openbabel/obconversion.h>
%import <openbabel/residue.h>
%import <openbabel/internalcoord.h>
%import <openbabel/atom.h>
%import <openbabel/bond.h>
%import <openbabel/mol.h>
%import <openbabel/ring.h>
%import <openbabel/parsmart.h>
%include <openbabel/fingerprint.h>
%include <openbabel/descriptor.h>
%include <openbabel/forcefield.h>
%include <openbabel/op.h>
%include <openbabel/bitvec.h>
%ignore *::operator=;
%include "carrays.i"
%array_class(double, doubleArray)
%pythoncode %{
def double_array(mylist):
"""Create a C array of doubles from a list."""
c = doubleArray(len(mylist))
for i,v in enumerate(mylist):
c[i] = v
return c
%}
# Functions to set the log file to std::cout and std::cerr
%ignore OBForceField::SetLogFile(std::ostream *pos);
%extend OpenBabel::OBForceField {
void SetLogToStdOut()
{
self->SetLogFile(&std::cout);
}
void SetLogToStdErr()
{
self->SetLogFile(&std::cerr);
}
};

View File

@@ -1,65 +0,0 @@
%module obtemplate
%{
// used to set import/export for Cygwin DLLs
#ifdef WIN32
#define USING_OBDLL
#endif
#include <openbabel/base.h>
#include <openbabel/mol.h>
#include <openbabel/atom.h>
#include <openbabel/bond.h>
#include <openbabel/residue.h>
#include <openbabel/ring.h>
%}
%include "std_list.i"
%include "std_map.i"
%include "std_vector.i"
%include "std_string.i"
namespace std {
%template (vectorInt) vector<int>;
%template (vectorUnsignedInt) vector<unsigned int>;
%template (vvInt) vector< vector<int> >;
%template (vectorDouble) vector<double>;
%template (vectorString) vector<std::string>;
%template (vVector3) vector<OpenBabel::vector3>;
%template (vectorMol) vector<OpenBabel::OBMol>;
%template (vectorBond) vector<OpenBabel::OBBond>;
%template (vectorResidue) vector<OpenBabel::OBResidue>;
%template (vectorRing) vector<OpenBabel::OBRing>;
%template (vectorpRing) vector<OpenBabel::OBRing*>;
%template (vectorData) vector<OpenBabel::OBGenericData*>;
}
// These methods are renamed to valid Python method names, as otherwise
// they cannot be used from Python
%rename(inc) *::operator++;
%rename(good) *::operator bool;
%import <openbabel/babelconfig.h>
%import <openbabel/base.h>
%import <openbabel/residue.h>
%import <openbabel/atom.h>
%import <openbabel/bond.h>
%import <openbabel/mol.h>
%import <openbabel/ring.h>
%ignore *::operator=;
%include "carrays.i"
%array_class(double, doubleArray)
%pythoncode %{
def double_array(mylist):
"""Create a C array of doubles from a list."""
c = doubleArray(len(mylist))
for i,v in enumerate(mylist):
c[i] = v
return c
%}

View File

@@ -1,11 +0,0 @@
import sys
if sys.platform.find("linux") != -1:
try:
import dl
except ImportError:
import DLFCN as dl
sys.setdlopenflags(sys.getdlopenflags() | dl.RTLD_GLOBAL)
import obcore
import obconversion
import obtemplate

View File

@@ -60,22 +60,8 @@ def find_likely_directory():
OBinclude,OBlibrary = find_likely_directory()
obCore = Extension('_obcore',
['obcore.cpp'],
include_dirs=OBinclude,
library_dirs=OBlibrary,
libraries=['openbabel']
)
obConversion = Extension('_obconversion',
['obconversion.cpp'],
include_dirs=OBinclude,
library_dirs=OBlibrary,
libraries=['openbabel']
)
obTemplate = Extension('_obtemplate',
['obtemplate.cpp'],
obExtension = Extension('_openbabel',
['openbabel_python.cpp'],
include_dirs=OBinclude,
library_dirs=OBlibrary,
libraries=['openbabel']
@@ -88,7 +74,7 @@ setup(name='openbabel',
url='http://openbabel.sourceforge.net/',
license='http://www.gnu.org/copyleft/gpl.html',
py_modules=['openbabel','pybel'],
ext_modules=[obCore, obConversion, obTemplate],
ext_modules=[obExtension],
description = 'openbabel: Python interface to the Open Babel chemistry library',
classifiers=[
'Development Status :: 5 - Production/Stable',