[Debian-astro-commits] [gyoto] 154/221: Python: set flags for dlopen in gyoto.py; wrap all Astrobj::Properties members.

Thibaut Jean-Claude Paumard thibaut at moszumanska.debian.org
Fri May 22 20:52:42 UTC 2015


This is an automated email from the git hooks/post-receive script.

thibaut pushed a commit to branch master
in repository gyoto.

commit 506d66f6aa45e3c129cc9893f700d08cec9408af
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date:   Wed Dec 17 19:45:08 2014 +0100

    Python: set flags for dlopen in gyoto.py; wrap all Astrobj::Properties members.
---
 python/Makefile.in |  5 ++++-
 python/gyoto.i     | 36 ++++++++++++++++++++++++------------
 python/header.py   |  4 ++++
 3 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/python/Makefile.in b/python/Makefile.in
index 378856e..704d736 100644
--- a/python/Makefile.in
+++ b/python/Makefile.in
@@ -86,8 +86,11 @@ all: gyoto.py _gyoto$(PYTHON_EXTENSION_SUFFIX)
 _gyoto$(PYTHON_EXTENSION_SUFFIX): $(srcdir)/gyoto.cxx gyoto_wrap.cxx
 	$(PYTHON) $(srcdir)/setup.py build_ext
 
-gyoto.py gyoto_wrap.cxx:
+gyoto.py gyoto_wrap.cxx: gyoto.i header.py
 	swig2.0 -I$(srcdir)/../include -c++ -python  $(srcdir)/gyoto.i
+	mv gyoto.py trailer.py
+	cat header.py trailer.py > gyoto.py
+	rm trailer.py
 
 .PHONY: all install uninstall distclean info install-html html install-pdf pdf install-dvi dvi install-ps ps clean dist check installdirs
 
diff --git a/python/gyoto.i b/python/gyoto.i
index bd8459f..dfbf8e2 100644
--- a/python/gyoto.i
+++ b/python/gyoto.i
@@ -25,11 +25,6 @@ void pyGyotoErrorHandler (const Gyoto::Error e) {
   return;
 }
 
-void AstrobjPropertiesSetIntensity(Gyoto::Astrobj::Properties *p,
-                                    double *invec, int n1, int n2)
-{
-  p->intensity=invec;
-} 
 %}
 
 
@@ -46,11 +41,6 @@ void AstrobjPropertiesSetIntensity(Gyoto::Astrobj::Properties *p,
   import_array();
  }
 
-
-%apply (double* IN_ARRAY2, int DIM1, int DIM2) {(double *invec, int n1, int n2)}
-void AstrobjPropertiesSetIntensity(Gyoto::Astrobj::Properties *p,
-                                   double *invec, int n1, int n2);
-
 %ignore Gyoto::SmartPointee;
 %include "GyotoSmartPointer.h"
 
@@ -65,13 +55,35 @@ void AstrobjPropertiesSetIntensity(Gyoto::Astrobj::Properties *p,
 
 %template(AstrobjPtr) Gyoto::SmartPointer<Gyoto::Astrobj::Generic>;
 %ignore Gyoto::Astrobj::Generic;
-//%ignore Gyoto::Astrobj::Properties;
 %ignore Gyoto::Astrobj::Register_;
 %ignore Gyoto::Astrobj::Register;
 %ignore Gyoto::Astrobj::initRegister;
 %ignore Gyoto::Astrobj::getSubcontractor;
+
 %include "GyotoAstrobj.h"
-%rename(Astrobj) pyGyotoAstrobj;
+
+%define _PAccessor(member, setter)
+  void setter(double *IN_ARRAY2, int DIM1, int DIM2) {
+    $self->member = IN_ARRAY2;
+  }
+%enddef
+
+%extend Gyoto::Astrobj::Properties{
+  _PAccessor(intensity, Intensity)
+  _PAccessor(binspectrum, BinSpectrum)
+  _PAccessor(distance, MinDistance)
+  _PAccessor(first_dmin, FirstDistMin)
+  _PAccessor(impactcoords, ImpactCoords)
+  _PAccessor(redshift, Redshift)
+  _PAccessor(spectrum, Spectrum)
+  _PAccessor(time, EmissionTime)
+  _PAccessor(user1, User1)
+  _PAccessor(user2, User2)
+  _PAccessor(user3, User3)
+  _PAccessor(user4, User4)
+  _PAccessor(user5, User5)
+ };
+
 Gyoto::SmartPointer<Gyoto::Astrobj::Generic> pyGyotoAstrobj(std::string const&);
 
 %template(MetricPtr) Gyoto::SmartPointer<Gyoto::Metric::Generic>;
diff --git a/python/header.py b/python/header.py
new file mode 100644
index 0000000..b0a3a1c
--- /dev/null
+++ b/python/header.py
@@ -0,0 +1,4 @@
+# This is necessary at least on Linux to let the libgyoto symbols be
+# visible from the libgyoto-stdplug (and other plug-ins) symbols.
+import sys, ctypes
+sys.setdlopenflags(sys.getdlopenflags() | ctypes.RTLD_GLOBAL)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-astro/packages/gyoto.git



More information about the Debian-astro-commits mailing list