[Debian-astro-commits] [gyoto] 202/221: * Expose MinimumTime as a property in Worldline; * yorick: + support setting Properties in the generic way for Photon; + support setting Properties of object kind (Astrobj, Metric)... to 0. * gyotoy: make gyotoy_warning an alias to error (it was undefined).

Thibaut Jean-Claude Paumard thibaut at moszumanska.debian.org
Fri May 22 20:52:46 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 6d80547e5b7f145afddfae05bd3df3bc5b238735
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date:   Tue Feb 17 16:40:10 2015 +0100

    * Expose MinimumTime as a property in Worldline;
    * yorick:
      + support setting Properties in the generic way for Photon;
      + support setting Properties of object kind (Astrobj, Metric)... to 0.
    * gyotoy: make gyotoy_warning an alias to error (it was undefined).
---
 include/GyotoPhoton.h    |  1 -
 include/GyotoWorldline.h |  9 +++++++++
 lib/Photon.C             |  7 +------
 lib/Scenery.C            |  1 -
 yorick/gyoto_Photon.C    | 22 ++++------------------
 yorick/gyoto_utils.C     | 25 ++++++++++++++++++++-----
 yorick/gyotoy.i          |  8 ++++++++
 yorick/ygyoto.h          | 43 ++++++++++++++++++++++---------------------
 8 files changed, 64 insertions(+), 52 deletions(-)

diff --git a/include/GyotoPhoton.h b/include/GyotoPhoton.h
index 058a23d..25cb030 100644
--- a/include/GyotoPhoton.h
+++ b/include/GyotoPhoton.h
@@ -229,7 +229,6 @@ class Gyoto::Photon
 
 #ifdef GYOTO_USE_XERCES
   virtual void setParameters(FactoryMessenger *fmp) ;
-  virtual void fillElement(Gyoto::FactoryMessenger *fmp) const ;
   static SmartPointer<Photon> Subcontractor(Gyoto::FactoryMessenger*);
 #endif
 
diff --git a/include/GyotoWorldline.h b/include/GyotoWorldline.h
index bfce881..4b06984 100644
--- a/include/GyotoWorldline.h
+++ b/include/GyotoWorldline.h
@@ -64,6 +64,7 @@ namespace Gyoto {
   GYOTO_PROPERTY_STRING(c, Integrator, _integrator)			\
   GYOTO_PROPERTY_SIZE_T(c, MaxIter, _maxiter)				\
   GYOTO_PROPERTY_BOOL(c, Adaptive, NonAdaptive, _adaptive)		\
+  GYOTO_PROPERTY_DOUBLE_UNIT(c, MinimumTime, _tMin)			\
   GYOTO_PROPERTY_DOUBLE_UNIT(c, Delta, _delta)				\
   GYOTO_PROPERTY_VECTOR_DOUBLE(c, InitCoord, _initCoord)		\
   GYOTO_PROPERTY_METRIC(c, Metric, _metric)
@@ -102,6 +103,10 @@ namespace Gyoto {
   double c::_delta()const{return delta();}				\
   void c::_delta(double f, std::string const &u){delta(f, u);}		\
   double c::_delta(std::string const &u)const{return delta(u);}		\
+  void c::_tMin(double f){tMin(f);}					\
+  double c::_tMin()const{return tMin();}				\
+  void c::_tMin(double f, std::string const &u){tMin(f, u);}		\
+  double c::_tMin(std::string const &u)const{return tMin(u);}		\
   void c::_maxiter(size_t f){maxiter(f);}				\
   size_t c::_maxiter()const{return maxiter();}				\
   void c::_integrator(std::string const &f){integrator(f);}		\
@@ -136,6 +141,10 @@ namespace Gyoto {
   void _delta(double, const std::string &unit);		\
   double _delta() const ;				\
   double _delta(const std::string &unit) const ;	\
+  void _tMin(const double tmin);			\
+  void _tMin(double, const std::string &unit);		\
+  double _tMin() const ;				\
+  double _tMin(const std::string &unit) const ;		\
   void _adaptive (bool mode) ;				\
   bool _adaptive () const ;				\
   void _secondary (bool sec) ;				\
diff --git a/lib/Photon.C b/lib/Photon.C
index 2410fce..e159134 100644
--- a/lib/Photon.C
+++ b/lib/Photon.C
@@ -42,6 +42,7 @@ using namespace std;
 using namespace Gyoto;
 
 GYOTO_PROPERTY_START(Photon)
+GYOTO_PROPERTY_ASTROBJ(Photon, Astrobj, astrobj)
 GYOTO_WORLDLINE_PROPERTY_END(Photon, Object::properties)
 
 Photon::Photon() :
@@ -576,15 +577,9 @@ void Photon::Refined::transmit(size_t i, double t) {
 
 
 #ifdef GYOTO_USE_XERCES
-void Photon::fillElement(FactoryMessenger *fmp) const {
-  if (object_)    fmp -> astrobj (object_) ;
-  Object::fillElement(fmp);
-}
-
 void Photon::setParameters(FactoryMessenger* fmp) {
   wait_pos_ = 1;
   metric(fmp->metric());
-  astrobj( fmp->astrobj() );
   Object::setParameters(fmp);
   wait_pos_ = 0;
   if (init_vel_) {
diff --git a/lib/Scenery.C b/lib/Scenery.C
index 07e573f..17b6d95 100644
--- a/lib/Scenery.C
+++ b/lib/Scenery.C
@@ -56,7 +56,6 @@ GYOTO_PROPERTY_START(Scenery)
 GYOTO_PROPERTY_METRIC(Scenery, Metric, metric)
 GYOTO_PROPERTY_SCREEN(Scenery, Screen, screen)
 GYOTO_PROPERTY_ASTROBJ(Scenery, Astrobj, astrobj)
-GYOTO_PROPERTY_DOUBLE_UNIT(Scenery, MinimumTime, tMin)
 GYOTO_PROPERTY_SIZE_T(Scenery, NThreads, nThreads)
 GYOTO_PROPERTY_SIZE_T(Scenery, NProcesses, nProcesses)
 GYOTO_PROPERTY_STRING(Scenery, Quantities, requestedQuantitiesString)
diff --git a/yorick/gyoto_Photon.C b/yorick/gyoto_Photon.C
index d890a94..0c29d34 100644
--- a/yorick/gyoto_Photon.C
+++ b/yorick/gyoto_Photon.C
@@ -273,29 +273,15 @@ extern "C" {
       return;
     }
 
-    SmartPointer<Photon> *ph = &(((gyoto_Photon*)obj)->smptr);
+    SmartPointer<Photon> *ph_ = &(((gyoto_Photon*)obj)->smptr);
 
     static char const * knames[]={
       YGYOTO_PHOTON_GENERIC_KW, 0
     };
-    static long kglobs[YGYOTO_PHOTON_GENERIC_KW_N+1];
-    int kiargs[YGYOTO_PHOTON_GENERIC_KW_N];
-    int piargs[]={-1,-1,-1,-1,-1};
-    // push default return value: the photon itsef
-    *ypush_Photon() = *ph;
-    yarg_kw_init(const_cast<char**>(knames), kglobs, kiargs);
-   
-    int iarg=argc, parg=0;
-    while (iarg>=1) {
-      iarg = yarg_kw(iarg, kglobs, kiargs);
-      if (iarg>=1) {
-	if (parg<5) piargs[parg++]=iarg--;
-	else y_error("gyoto_Photon takes at most 5 positional arguments");
-      }
-    }
 
-    int rvset[1]={0}, paUsed[1]={0};
-    ygyoto_Photon_generic_eval(ph, kiargs, piargs, rvset, paUsed);
+    YGYOTO_WORKER_INIT1(Photon, Photon, knames, YGYOTO_PHOTON_GENERIC_KW_N);
+   
+    ygyoto_Photon_generic_eval(ph_, kiargs, piargs, rvset, paUsed);
 
   }
 
diff --git a/yorick/gyoto_utils.C b/yorick/gyoto_utils.C
index d6b5198..7907644 100644
--- a/yorick/gyoto_utils.C
+++ b/yorick/gyoto_utils.C
@@ -499,19 +499,34 @@ void yget_property(Gyoto::SmartPointer<Gyoto::SmartPointee> ptr,
     }
     break;
   case Gyoto::Property::metric_t:
-    val = *yget_Metric(iarg);
+    if (yarg_number(iarg) && ygets_l(iarg)==0)
+      val=(Gyoto::SmartPointer<Gyoto::Metric::Generic>(NULL));
+    else
+      val = *yget_Metric(iarg);
     break;
   case Gyoto::Property::astrobj_t:
-    val = *yget_Astrobj(iarg);
+    if (yarg_number(iarg) && ygets_l(iarg)==0)
+      val=(Gyoto::SmartPointer<Gyoto::Astrobj::Generic>(NULL));
+    else
+      val = *yget_Astrobj(iarg);
     break;
   case Gyoto::Property::spectrum_t:
-    val = *yget_Spectrum(iarg);
+    if (yarg_number(iarg) && ygets_l(iarg)==0)
+      val=(Gyoto::SmartPointer<Gyoto::Spectrum::Generic>(NULL));
+    else
+      val = *yget_Spectrum(iarg);
     break;
   case Gyoto::Property::spectrometer_t:
-    val = *yget_Spectrometer(iarg);
+    if (yarg_number(iarg) && ygets_l(iarg)==0)
+      val=(Gyoto::SmartPointer<Gyoto::Spectrometer::Generic>(NULL));
+    else
+      val = *yget_Spectrometer(iarg);
     break;
   case Gyoto::Property::screen_t:
-    val = *yget_Screen(iarg);
+    if (yarg_number(iarg) && ygets_l(iarg)==0)
+      val=(Gyoto::SmartPointer<Gyoto::Screen>(NULL));
+    else
+      val = *yget_Screen(iarg);
     break;
   default:
     y_error("Property type unimplemented in yget_property()");
diff --git a/yorick/gyotoy.i b/yorick/gyotoy.i
index 1d447e5..63eb48f 100644
--- a/yorick/gyotoy.i
+++ b/yorick/gyotoy.i
@@ -174,11 +174,15 @@ func gyotoy_set_metric(fname, void)
     fname = gy.Gtk.FileChooser(fname).get_filename();
   if (is_string(fname)) metric=gyoto_Metric(fname);
   if (typeof(metric)!="gyoto_Metric") gyotoy_warning, "Failed to set metric";
+  prev_metric=_gyotoy_metric;
   _gyotoy_metric=metric;
   _gyotoy_metric_file=fname;
   if (catch(0x08)) {
     // avoid breaking in case of v>c or other problem
     gyotoy_warning, "metric loaded but orbit computation failed";
+    _gyotoy_metric=prev_metric;
+    _gyotoy_particle,metric=_gyotoy_metric,
+      initcoord=_gyotoy_initcoord(1:4), _gyotoy_initcoord(5:7);
     return;
   }
   _gyotoy_particle,metric=_gyotoy_metric,
@@ -910,6 +914,10 @@ func _gyotoy_unlimit(wdg, data)
   limits;
 }
 
+
+extern gyotoy_warning;
+gyotoy_warning=error;
+
 extern _pyk_proc, _gyotoy_stand_alone;
 if (is_void(_gyotoy.yid)) _gyotoy,yid=0;
 gyotoy_args=get_argv();
diff --git a/yorick/ygyoto.h b/yorick/ygyoto.h
index 2534cb8..531aaad 100644
--- a/yorick/ygyoto.h
+++ b/yorick/ygyoto.h
@@ -287,17 +287,17 @@ void ygyoto_Spectrometer_generic_eval
     (Gyoto::SmartPointer<CLASS> *)YGYOTO_CAT(OBJ, _);			\
   static long kglobs[NKW+1];						\
   int kiargs[NKW];							\
-  int piargs[]={-1,-1,-1,-1};						\
+  int piargs[]={-1,-1,-1,-1,-1};					\
   yarg_kw_init(const_cast<char**>(KNAMES), kglobs, kiargs);		\
   int iarg=argc, parg=0;						\
   while (iarg>=1) {							\
     iarg = yarg_kw(iarg, kglobs, kiargs);				\
     if (iarg>=1) {							\
-      if (parg<4) piargs[parg++]=iarg--;				\
-      else y_error( #CLASS " worker takes at most 4 positional arguments"); \
+      if (parg<5) piargs[parg++]=iarg--;				\
+      else y_error( #CLASS " worker takes at most 5 positional arguments"); \
     }									\
   }									\
-  GYOTO_DEBUG_ARRAY(piargs, 4);						\
+  GYOTO_DEBUG_ARRAY(piargs, 5);						\
   GYOTO_DEBUG_ARRAY(kiargs, NKW);					\
   int k=-1;								\
   char const * rmsg="Cannot set return value more than once";		\
@@ -406,31 +406,32 @@ void ygyoto_Spectrometer_generic_eval
 	(*OBJ) -> MEMBER (ygets_l(iarg));		   \
     }
 
-#define YGYOTO_WORKER_GETSET_OBJECT(MEMBER)			   \
+#define YGYOTO_WORKER_GETSET_OBJECT0(SETMEMBER,GETMEMBER,YMEMBER)   \
   if ((iarg=kiargs[++k])>=0) {					   \
     iarg+=*rvset;						   \
     if (yarg_nil(iarg)) {					   \
-      GYOTO_DEBUG << "pushing " #MEMBER << std::endl;		   \
+      GYOTO_DEBUG << "pushing " #YMEMBER << std::endl;		   \
       if ((*rvset)++) y_error("Only one return value possible");   \
-      *ypush_##MEMBER () = (*OBJ) -> get##MEMBER ();		   \
+      void * tmp = (*OBJ) -> GETMEMBER ();			   \
+      if (tmp)							   \
+	*ypush_##YMEMBER () = (*OBJ) -> GETMEMBER ();		   \
+      else ypush_long(0);					   \
     } else {							   \
-      GYOTO_DEBUG << "setting " #MEMBER << std::endl;		   \
-      (*OBJ) -> set##MEMBER (*yget_##MEMBER (kiargs[k]));	   \
+      GYOTO_DEBUG << "setting " #YMEMBER << std::endl;		   \
+      if (yarg_number(iarg)) {					   \
+        if (ygets_l(iarg) != 0)					   \
+	  y_error("Argument should be a " #YMEMBER " or 0");	   \
+	(*OBJ) -> SETMEMBER (0);				   \
+      } else							   \
+	(*OBJ) -> SETMEMBER (*yget_##YMEMBER (kiargs[k]));	   \
     }								   \
   }
 
-#define YGYOTO_WORKER_GETSET_OBJECT2(MEMBER,YMEMBER)			   \
-  if ((iarg=kiargs[++k])>=0) {					   \
-    iarg+=*rvset;						   \
-    if (yarg_nil(iarg)) {					   \
-      GYOTO_DEBUG << "pushing " #MEMBER << std::endl;		   \
-      if ((*rvset)++) y_error("Only one return value possible");   \
-      *ypush_##YMEMBER () = (*OBJ) -> MEMBER ();		   \
-    } else {							   \
-      GYOTO_DEBUG << "setting " #MEMBER << std::endl;		   \
-      (*OBJ) -> MEMBER (*yget_##YMEMBER (kiargs[k]));	   \
-    }								   \
-  }
+#define YGYOTO_WORKER_GETSET_OBJECT(MEMBER)			   \
+  YGYOTO_WORKER_GETSET_OBJECT0(set##MEMBER,get##MEMBER,MEMBER)
+
+#define YGYOTO_WORKER_GETSET_OBJECT2(MEMBER,YMEMBER)		   \
+  YGYOTO_WORKER_GETSET_OBJECT0(MEMBER,MEMBER,YMEMBER)
 
 #define YGYOTO_WORKER_SET_UNIT		 \
   if ((iarg=kiargs[++k])>=0) {		 \

-- 
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