]> git.mxchange.org Git - flightgear.git/commitdiff
while abort() is really only useful for listeners (in all other cases
authormfranz <mfranz>
Thu, 19 Jun 2008 17:18:42 +0000 (17:18 +0000)
committermfranz <mfranz>
Thu, 19 Jun 2008 17:18:42 +0000 (17:18 +0000)
we know the stack trace), it's better to use a separate function for
it, as this can be used conditionally, as in:

  setlistener("/the/property", func(n) {
      if (n.getValue() < 0) # who's writing negative numbers to /the/property?!
          abort();          # let's check the backtrace ...
  });

src/Scripting/NasalSys.cxx

index a37c40b35d87f82260f6a3bf7ca826d0b82a59f9..7b9933627dc4f06355c48d4e57a6ffe5f3e3e65b 100644 (file)
@@ -347,6 +347,12 @@ static naRef f_srand(naContext c, naRef me, int argc, naRef* args)
     return naNum(0);
 }
 
+static naRef f_abort(naContext c, naRef me, int argc, naRef* args)
+{
+    abort();
+    return naNil();
+}
+
 // Return an array listing of all files in a directory
 static naRef f_directory(naContext c, naRef me, int argc, naRef* args)
 {
@@ -597,6 +603,7 @@ static struct { const char* name; naCFunction func; } funcs[] = {
     { "_interpolate",  f_interpolate },
     { "rand",  f_rand },
     { "srand",  f_srand },
+    { "abort", f_abort },
     { "directory", f_directory },
     { "parsexml", f_parsexml },
     { "systime", f_systime },
@@ -1023,7 +1030,6 @@ void FGNasalListener::valueChanged(SGPropertyNode* node)
     if(_type < 2 && node != _node) return;   // skip child events
     if(_type > 0 || changed(_node) || _first_call)
         call(node, naNum(0));
-    if(_type == -1) abort();
 
     _first_call = false;
 }