[Debian-astro-commits] [gyoto] 146/221: Yorick: parse Properties in eval, only for Scenery.

Thibaut Jean-Claude Paumard thibaut at moszumanska.debian.org
Fri May 22 20:52:41 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 cc2c3fdfae3cbc6ecf8d0e08b4ec43d15710c5e6
Author: Thibaut Paumard <paumard at users.sourceforge.net>
Date:   Fri Dec 12 14:23:38 2014 +0100

    Yorick: parse Properties in eval, only for Scenery.
---
 yorick/gyoto_Scenery.C | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/yorick/gyoto_Scenery.C b/yorick/gyoto_Scenery.C
index 64762d9..534f93a 100644
--- a/yorick/gyoto_Scenery.C
+++ b/yorick/gyoto_Scenery.C
@@ -50,6 +50,42 @@ extern "C" {
   void gyoto_Scenery_eval(void *obj, int argc) {
     SmartPointer<Scenery> *OBJ_ = &(((gyoto_Scenery*)obj)->smptr);
 
+    { // First look for introspected Properties at the beginning of
+      // the argument list. Only four syntaxes possible for each
+      // property:
+      //   obj, Property=value;
+      //   obj, Property=value, unit="unit";
+      //   obj(Property=);
+      //   obj(Property=, unit="unit");
+
+      long kidx;
+      Property const * prop;
+      std::string pname="", unit="";
+      bool unit_found, prop_pushed=false;
+      ypush_nil(); ++argc;
+      while ( (  argc > 0                 ) &&  
+	      ( (kidx=yarg_key(argc-1)) >=0 ) &&
+	      ( (prop=(*OBJ_)->property(pname=yfind_name(kidx)))) ) {
+	if ( (kidx=yarg_key(argc-3)) >=0 &&
+	     !strcmp(yfind_name(kidx),"unit") ) {
+	  unit=ygets_q(argc-4);
+	  unit_found=true;
+	} else {
+	  unit_found=false;
+	  unit="";
+	}
+	if (yarg_nil(argc-2)) {
+	  if (prop_pushed++) y_error("Can push only one return value");
+	  yarg_drop(1);
+	  ypush_property(*OBJ_, *prop, -1, pname, unit);
+	}
+	else yget_property(*OBJ_, *prop, argc-2, pname, unit);
+	argc -= unit_found?4:2;
+      }
+      if (prop_pushed) return;
+      yarg_drop(1); --argc;
+    }
+
     double * impactcoords = NULL;
     bool precompute = 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