1
0
Fork 0
Commit graph

72 commits

Author SHA1 Message Date
andy
99885791e9 Remove the GUI popup from the screen capture C++ code (a request via
IRC wanted this to be scritable) and add it back (as a tip popup) via
a little nasal in the keyboard handler.  Also put the synthesis of
property nodes back into fgcommand(), because I got cold feet.
2007-06-07 16:57:59 +00:00
andy
b693047703 Allow the second (property node) argument to fgcommand() to be nil or
missing, for sanity.  Note that this will pass the resulting NULL
pointer through into the underlying SGCommand handlers, some of which
may be unprepared for it.  So basically this is now yet another way
you can use Nasal to exercise bugs and hose your sim; no biggie.
2007-06-07 16:17:48 +00:00
curt
738b40158d Ladislav Michnovič: fix a 64bit problem. 2007-05-17 18:43:36 +00:00
mfranz
8eeafbac8e Andy ROSS:
add systime() function for benchmarking purposes. It returns UNIX epoch
time in seconds.
2007-05-14 16:24:41 +00:00
mfranz
76e76bb95d add error messages for invalid args to settimer() 2007-05-12 18:15:45 +00:00
mfranz
1f07903cd6 move the "interpolator" subsystem into the INIT group (same as "nasal"),
because nasal's f_interpolate() may be called in Nasal at times when the
GENERAL subsystem group is being deconstructed; access it by addressing
the group directly, as using globals->get_subsystem() does then not
work any more then; yeah, it's all for a rare border case ...  :-)
2007-05-01 18:06:48 +00:00
mfranz
ac0f49a929 remove util.cxx workaround for listener-call-at-exit-segfault, and make
NasalSys.cxx more robust instead. The reason for the crash was that during
fgfs shutdown destroyed subsystems (GENERAL group) still need Nasal access
(for AI Model destruction listeners), but at that point globals->get_subsystem()
can't even deliver the "nasal" subsystem (INIT group). One way to solve that
problem would have been to replace  globals->get_subsystem("nasal") by
globals->get_subsystem_mgr()->get_group(SGSubsystemMgr::INIT)->get_subsystem("nasal"),
but Andy decided to store a pointer to the active "nasal" subsysten in
NasalSys.cxx instead, as the "nasal" subsystem needs to be accessed in
every single Nasal extension function, and multiple "nasal" subsystems are
out of the question, anyway.
2007-05-01 17:03:50 +00:00
mfranz
922812a913 make listeners aware of their id, and output trigger message in
log levels "debug" and "bulk"
2007-04-27 14:30:05 +00:00
mfranz
8a6c95451b allow AI models to contain <nasal><load> and <nasal><unload> blocks in
their XML wrapper/animation file. They can access their /ai/models node
via cmdarg() function. Example:

  <nasal>
          <load>
                  print("Hi, I'm the Nimitz. My data are under ",
                                  cmdarg().getPath());
          </load>
          <unload>
                  ...
          </unload>
  </nasal>

Note, however, that the <unload> block is only called on exit at the moment,
not when the tile is unloaded.
2007-04-01 12:39:20 +00:00
andy
c30ff46f83 Sync with Nasal CVS (soon to become Nasal 1.1). Notable new features:
Nasal now supports calls to "subcontexts" and errors can be thrown
across them, leading to complete stack traces when call() is used,
instead of the truncated ones we now see.

Vectors can now be concatenated using the ~ operator that used to work
only for strings.

Better runtime error messages in general due to a fancier
naRuntimeError() implementation

A big data size shrink on 64 bit systems; the size of a naRef dropped
by a factor of two.

"Braceless code blocks" have been added to the parser, so you can
write expressions like "if(a) b();" just like in C.  Note that there's
still a parser bug in there that fails when you nest a braced block
within a braceless one.

Character constants that appear in Nasal source code can now be
literal multibyte UTF8 characters (this was always supported for
string literals, but character constants were forced to be a single
byte).

New modules: "bits", "thread", "utf8" and (gulp...) "io".  The bits
library might be useful to FlightGear, the utf8 one probably not as
Plib does not support wide character text rendering.  The thread
library will work fine for spawning threads to do Nasal stuff, but
obviously contact with the rest of FlightGear must be
hand-synchronized as FlightGear isn't threadsafe.  The io library is
no doubt the most useful, as it exposes all the basic stdio.h
facilities; it's also frighteningly dangerous when combined with
networked code...
2007-03-29 18:50:28 +00:00
mfranz
937ec42fda revert condition() patch. This can as easily be done in pure Nasal. 2007-03-18 10:52:11 +00:00
mfranz
8c7c217037 set module namespace in globals, otherwise two subsequent calls can't share
variables, which makes the whole module kind-of pointless
2007-03-17 20:51:06 +00:00
mfranz
cc30d4d80e New Nasal command _condition(p) where p is a property node containing
a condition as described in $FG_ROOT/Docs/README.condition. Returns 1 if
condition is true, 0 if false, and nil on error.
2007-03-17 15:58:15 +00:00
mfranz
862196a3ab - add two error messages to setlistener() (invalid property or func object)
- adapt last changes to Style Of The Tile
2007-02-03 16:46:39 +00:00
fredb
17957439a1 simplify and fix 2007-01-29 07:53:42 +00:00
mfranz
b73bd53744 this should now really be correct; nothing for a beauty contest, though 2007-01-28 22:55:37 +00:00
mfranz
c5cc84baeb make sure entries are actually erased :-) 2007-01-28 20:59:47 +00:00
frohlich
227e96afa6 Modified Files:
src/Scripting/NasalSys.cxx: make sure iterators stay valid
2007-01-28 20:02:49 +00:00
mfranz
978b7145b1 don't truncate strings output by print() to 1024 bytes. This was apparently
done for performance reasons, but print() should be able to output any
valid string, and when SG_LOG uses strings and streams already, then we
can use that here, too. (Not discussed with Andy yet.)
2007-01-28 12:16:37 +00:00
mfranz
22421f6687 allow listeners to remove themselves. This is done by marking them
dead and letting the next NasalSys::update() remove all dead listeners.
2007-01-23 16:47:04 +00:00
mfranz
016750c865 - remove "nasal-dir-initialized" signal node after use. This code is executed
before the property tree is stored away for reinit, so the signal would
  be emitted again on reset.
- fix inconsistent style that sneaked in with a previous patch
2007-01-23 15:53:04 +00:00
mfranz
2af373e13a raise signal "/sim/signals/nasal-dir-initialized" when all Nasal files
in $FG_ROOT/Nasal/* were loaded and executed, and thus all Nasal library
functions are available. This was in the past only done with settimer(..., 0),
constructions, but suchlike triggered timer functions are executed
*after* aircraft specific Nasal files were loaded, so they can't be
used for internal library initialization, where e.g. props.Node() is
already needed.
2007-01-21 19:52:49 +00:00
mfranz
e37b255095 - don't allow removal of active listener (prevents crash)
- error message if removelistener() is called with invalid or no id
2007-01-17 13:56:22 +00:00
mfranz
b1fad7d98e let Nasal's fgcommand() return C++ return value (0 -> failure, 1 -> success) 2007-01-13 19:18:03 +00:00
frohlich
b0f9d24f9d Modified Files:
configure.ac src/AIModel/AIAircraft.cxx src/AIModel/AIBase.cxx
 	src/AIModel/AIBase.hxx src/AIModel/AICarrier.cxx
 	src/AIModel/AICarrier.hxx src/AIModel/AIManager.cxx
 	src/AIModel/AIManager.hxx src/ATC/AIEntity.cxx
 	src/ATC/AIEntity.hxx src/ATC/AIMgr.cxx src/ATC/AIMgr.hxx
 	src/ATC/ATCdisplay.cxx src/ATC/ATCdisplay.hxx
 	src/Cockpit/cockpit.cxx src/Cockpit/cockpit.hxx
 	src/Cockpit/hud.cxx src/Cockpit/hud.hxx
 	src/Cockpit/hud_rwy.cxx src/Cockpit/panel.cxx
 	src/Cockpit/panel.hxx src/Cockpit/built_in/FGMagRibbon.cxx
 	src/Cockpit/built_in/FGMagRibbon.hxx src/FDM/flight.cxx
 	src/FDM/groundcache.cxx src/FDM/groundcache.hxx
 	src/GUI/gui_funcs.cxx src/Input/input.cxx
 	src/Instrumentation/od_gauge.cxx
 	src/Instrumentation/od_gauge.hxx
 	src/Instrumentation/render_area_2d.cxx
 	src/Instrumentation/render_area_2d.hxx
 	src/Instrumentation/wxradar.cxx
 	src/Instrumentation/wxradar.hxx
 	src/Instrumentation/HUD/HUD.cxx
 	src/Instrumentation/HUD/HUD.hxx
 	src/Instrumentation/HUD/HUD_runway.cxx src/Main/Makefile.am
 	src/Main/main.cxx src/Main/renderer.cxx src/Main/renderer.hxx
 	src/Main/viewmgr.cxx src/Model/acmodel.cxx
 	src/Model/acmodel.hxx src/Model/model_panel.cxx
 	src/Model/model_panel.hxx src/Model/modelmgr.cxx
 	src/Model/modelmgr.hxx src/Model/panelnode.cxx
 	src/Model/panelnode.hxx src/Navaids/awynet.cxx
 	src/Scenery/Makefile.am src/Scenery/hitlist.cxx
 	src/Scenery/hitlist.hxx src/Scenery/newcache.cxx
 	src/Scenery/scenery.cxx src/Scenery/scenery.hxx
 	src/Scenery/tileentry.cxx src/Scenery/tileentry.hxx
 	src/Scenery/tilemgr.cxx src/Scripting/NasalSys.cxx
 	src/Scripting/NasalSys.hxx src/Time/light.cxx
	Big BLOB on the way to OSG.
2006-10-29 19:30:21 +00:00
andy
3362ea2447 A bug was discovered on IRC where an errant script was setting a nil
value on a property.  This becomes a NaN when converted to a numeric
value, which then percolated into the C++ world where it ultimately
caused a crash in YASim's turbulence code.  While converting nil to
NaN isn't *strictly* wrong, it's dangerous for this reason.  Toss a
Nasal exception instead.  Hopefully this won't break too much
preexisting code.
2006-10-17 19:58:33 +00:00
andy
503cc54a93 Rework the naModLock()/naModUnlock() semantics to be more
maintainable.  The rules are simple (extension functions are called
*with* the lock, which must be dropped before calling naCall(), which
grabs it) but the tracking of when the lock was held was getting a
little confused.  Keep a "nasal call depth" count in the subsystem to
figure out whether we are making a sub-call and thus hold the lock.
2006-07-19 19:46:53 +00:00
mfranz
4914844c31 ... but then again: it's only a rumor that listeners on tied properties
don't work. And like most rumors, it's untrue. So just output a debug
message.
2006-07-16 11:48:22 +00:00
mfranz
1841bd7343 - complain about attempts to attach a listener to a tied node
- do *not* complain about a listener writing to its own node, but don't
  enter recursion either
2006-07-16 11:30:33 +00:00
mfranz
00f3d1db80 - remove listener in ~FGNasalListener(), not FGNasalSys::removelistener
- delete all listeners in ~FGNasalSys()
2006-06-10 22:21:22 +00:00
mfranz
e0b1d12a60 don't abort fgfs only because a nasal script called a property function
with an invalid path, as in getprop("/sim/model/737") or x.getNode("f:1").
Forward sg's error message to the Nasal runtime error function instead, so
you get something like:

  Nasal runtime error: name must begin with alpha or '_'
    at /home/m/fgfs/Base.local/Nasal/props.nas, line 30

Unfortunately, the location points to the line where the ghost wrapper
sits, rather than the offending script line.
2006-05-23 18:55:38 +00:00
mfranz
2ae061c9c3 explain createModule()'s optional SGPropertyNode argument 2006-04-27 16:40:04 +00:00
mfranz
52306b9093 add optional SGPropertyNode* argument to NasalSys::createModule. This is
used in dialog.cxx to allow XML dialogs access to their own prop tree via
Nasal's cmdarg(). That way dialogs can generate dynamic content, such as
list entries.
2006-04-27 15:56:51 +00:00
mfranz
7845f33c74 a bool isn't safe enough here, but a mutex shouldn't be necessary 2006-03-20 11:01:16 +00:00
mfranz
4c5e96f730 - disallow listener re-entry to prevent crash/runaway process
- move FGNasalListener function bodies to NasalSys.cxx (has become too big)
2006-03-20 07:13:10 +00:00
andy
8ca3e913ad Add a (commented out) line enabling the "bits" library for testing. 2006-03-15 19:43:09 +00:00
andy
a9ea522388 Add the I/O library, but comment it out until we figure out how to do this securely 2006-03-15 18:10:29 +00:00
mfranz
5f339a4e83 close Nasal/ dir after reading *.nas files 2006-03-13 19:47:22 +00:00
mfranz
31d3fd0209 add alert message 2006-03-09 17:32:24 +00:00
mfranz
b9d3c3ccb6 check if the "nasal" subsystem is still there, and only call <unload> then.
This isn't the case if the model is destroyed on fgfs exit. To make <unload>
work under these circumstances, one would have to reorder subsystem removal,
but this doesn't seem overly useful, so we'll do it when we really need it.
2006-03-09 13:30:28 +00:00
mfranz
83b64b0140 remove leftover #include; changed comment 2006-03-09 11:05:32 +00:00
mfranz
2796f3f4a5 NasalSys.[ch]xx:
implement FGNasalModelData class for execution of XML <load> and <unload>
  scripts. modelLoaded() is called by the model loader, and the destructor
  on branch removal.

modelmgr.cxx:
tilemgr.cxx:
tileentry.[ch]xx:
  make scenery and custom objects run their Nasal scripts on loading
  and unloading. Let OBJECT_STATIC object not be cached.
2006-03-09 09:04:03 +00:00
mfranz
6867462210 crashfix: handleCommand() is called from other modules (input callbacks,
fgcommands from C++ or GUI), so we need a separate context here. (See
also solution in FGNasalListener::valueChanged)
2006-03-08 16:06:32 +00:00
mfranz
77de0c8e09 add deleteModule() method 2006-03-08 10:35:20 +00:00
mfranz
dcffb9d335 let removelistener() return the number of remaining Nasal listeners. (We
need to return nil for errors and something else for success, so we can
as well return something (remotely) useful.)
2006-03-02 10:41:48 +00:00
mfranz
55cde5f160 - assign unique id to listeners
- let setlistener return id
- add removelistener(id) command
2006-02-28 14:55:37 +00:00
fredb
36e4045810 Add missing include files needed by the new math code under windows 2006-02-18 13:58:09 +00:00
mfranz
034e39dba5 screenPrint() is obsolete. Use screen.log.write() for the same purpose,
or write to the color properties in /sim/screen/. If this Nasal/GUI
implementation turns out to be too slow, we'll write a generic OpenGL/plib
version simliar to the ATCdisplay code.  (OK'ed by Andy and Stuart)
2006-02-13 20:08:04 +00:00
mfranz
d1fa3f9c7e store garbage collector id (again) in the listener class, and free the
handler on destruction. There's no explicit Nasal command for removing
a listener, but deleting the node should fully remove them.
2006-02-04 16:37:25 +00:00
mfranz
9efe35b86a support optional setlistener() arg to fire callback function initially 2006-01-30 12:29:58 +00:00