Remove old PSL support and put our eggs into the Nasal basket.
This commit is contained in:
parent
d3181fb437
commit
d1360d26d0
3 changed files with 1 additions and 263 deletions
|
@ -4,12 +4,6 @@ else
|
|||
WEATHER_DIR = Environment
|
||||
endif
|
||||
|
||||
if HAVE_PLIB_PSL
|
||||
SCRIPTING_DIRS = Scripting
|
||||
else
|
||||
SCRIPTING_DIRS =
|
||||
endif
|
||||
|
||||
if ENABLE_MPLAYER_AS
|
||||
MPLAYER_DIRS = MultiPlayer
|
||||
else
|
||||
|
@ -35,7 +29,7 @@ SUBDIRS = \
|
|||
Objects \
|
||||
Replay \
|
||||
Scenery \
|
||||
$(SCRIPTING_DIRS) \
|
||||
Scripting \
|
||||
Sound \
|
||||
Systems \
|
||||
Time \
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
// scriptmgr.cxx - run user scripts
|
||||
// Written by David Megginson, started 2002.
|
||||
//
|
||||
// This file is in the Public Domain, and comes with no warranty.
|
||||
|
||||
|
||||
#include "scriptmgr.hxx"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <plib/psl.h>
|
||||
|
||||
#include <Main/globals.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
|
||||
SG_USING_STD(cout);
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Extensions.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static pslValue
|
||||
do_print (int argc, pslValue * argv, pslProgram * p)
|
||||
{
|
||||
for (int i = 0; i < argc; i++) {
|
||||
switch(argv[i].getType()) {
|
||||
case PSL_INT:
|
||||
cout << argv[i].getInt();
|
||||
break;
|
||||
case PSL_FLOAT:
|
||||
cout << argv[i].getFloat();
|
||||
break;
|
||||
case PSL_STRING:
|
||||
cout << argv[i].getString();
|
||||
break;
|
||||
case PSL_VOID:
|
||||
cout << "(void)";
|
||||
break;
|
||||
default:
|
||||
cout << "(**bad value**)";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pslValue result;
|
||||
result.set();
|
||||
return result;
|
||||
}
|
||||
|
||||
static pslValue
|
||||
do_get_property (int argc, pslValue * argv, pslProgram * p)
|
||||
{
|
||||
pslValue result;
|
||||
SGPropertyNode * prop = fgGetNode(argv[0].getString());
|
||||
if (prop != 0) {
|
||||
switch (prop->getType()) {
|
||||
case SGPropertyNode::BOOL:
|
||||
case SGPropertyNode::INT:
|
||||
case SGPropertyNode::LONG:
|
||||
result.set(prop->getIntValue());
|
||||
break;
|
||||
case SGPropertyNode::FLOAT:
|
||||
case SGPropertyNode::DOUBLE:
|
||||
result.set(prop->getFloatValue());
|
||||
break;
|
||||
case SGPropertyNode::STRING:
|
||||
case SGPropertyNode::UNSPECIFIED:
|
||||
result.set(prop->getStringValue());
|
||||
break;
|
||||
default:
|
||||
// DO SOMETHING
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
result.set();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static pslValue
|
||||
do_set_property (int argc, pslValue * argv, pslProgram * p)
|
||||
{
|
||||
pslValue result;
|
||||
SGPropertyNode * prop = fgGetNode(argv[0].getString(), true);
|
||||
switch (argv[1].getType()) {
|
||||
case PSL_INT:
|
||||
prop->setIntValue(argv[1].getInt());
|
||||
break;
|
||||
case PSL_FLOAT:
|
||||
prop->setFloatValue(argv[1].getFloat());
|
||||
break;
|
||||
case PSL_STRING:
|
||||
prop->setStringValue(argv[1].getString());
|
||||
break;
|
||||
case PSL_VOID:
|
||||
prop->setUnspecifiedValue("");
|
||||
break;
|
||||
default:
|
||||
// TODO: report an error.
|
||||
break;
|
||||
}
|
||||
|
||||
result.set();
|
||||
return result;
|
||||
}
|
||||
|
||||
static pslExtension
|
||||
extensions[] = { {"print", -1, do_print},
|
||||
{"get_property", 1, do_get_property},
|
||||
{"set_property", 2, do_set_property},
|
||||
{0, 0, 0} };
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of FGScriptMgr.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FGScriptMgr::FGScriptMgr ()
|
||||
{
|
||||
}
|
||||
|
||||
FGScriptMgr::~FGScriptMgr ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
FGScriptMgr::init ()
|
||||
{
|
||||
pslInit();
|
||||
}
|
||||
|
||||
void
|
||||
FGScriptMgr::update (double delta_time_sec)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
FGScriptMgr::run (const char * script) const
|
||||
{
|
||||
// FIXME: detect and report errors
|
||||
pslProgram program(extensions);
|
||||
if (program.compile(script, globals->get_fg_root().c_str()) > 0)
|
||||
return false;
|
||||
while (program.step() != PSL_PROGRAM_END)
|
||||
;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
FGScriptMgr::run_inline (const char * script) const
|
||||
{
|
||||
string s = "int main () {\n";
|
||||
s += script;
|
||||
s += "\n return 0;\n}\n";
|
||||
return run(s.c_str());
|
||||
}
|
||||
|
||||
|
||||
// end of scriptmgr.cxx
|
|
@ -1,93 +0,0 @@
|
|||
// scriptmgr.hxx - run user scripts
|
||||
// Written by David Megginson, started 2002.
|
||||
//
|
||||
// This file is in the Public Domain, and comes with no warranty.
|
||||
|
||||
#ifndef __SCRIPTMGR_HXX
|
||||
#define __SCRIPTMGR_HXX
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h> // for SG_USING_STD
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
class pslExtension;
|
||||
|
||||
|
||||
/**
|
||||
* Manager for user scripts in PSL (PLIB's scripting language).
|
||||
*
|
||||
* The initial draft of this subsystem does nothing on update, and
|
||||
* simply executes scripts on demand from various input bindings, but
|
||||
* I plan to merge in code from Erik Hofman for events and scheduled
|
||||
* tasks.
|
||||
*
|
||||
* Right now, there are three extension commands for
|
||||
* FlightGear:
|
||||
*
|
||||
* print(...) - prints all of its arguments to standard output.
|
||||
* get_property(name) - get a property value
|
||||
* set_property(name, value) - set a property value
|
||||
*/
|
||||
class FGScriptMgr : public SGSubsystem
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
FGScriptMgr ();
|
||||
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~FGScriptMgr ();
|
||||
|
||||
|
||||
/**
|
||||
* Initialize PSL.
|
||||
*/
|
||||
virtual void init ();
|
||||
|
||||
|
||||
/**
|
||||
* Update (no-op for now).
|
||||
*/
|
||||
virtual void update (double delta_time_sec);
|
||||
|
||||
|
||||
/**
|
||||
* Run an in-memory user script.
|
||||
*
|
||||
* Any included files are referenced relative to $FG_ROOT. This
|
||||
* is not very efficient right now, since it recompiles the script
|
||||
* every time it runs. The script must have a main() function.
|
||||
*
|
||||
* @param script A string containing the script.
|
||||
* @return true if the script compiled properly, false otherwise.
|
||||
* @see #run_inline
|
||||
*/
|
||||
virtual bool run (const char * script) const;
|
||||
|
||||
|
||||
/**
|
||||
* Run an inline in-memory user script.
|
||||
*
|
||||
* The script is executed as if it were surrounded by a main()
|
||||
* function, so it cannot contain any top-level constructions like
|
||||
* #include statements or function declarations. This is useful
|
||||
* for quick one-liners.
|
||||
*
|
||||
* @param script A string containing the inline script.
|
||||
* @return true if the script compiled properly, false otherwise.
|
||||
* @see #run
|
||||
*/
|
||||
virtual bool run_inline (const char * script) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __SCRIPTMGR_HXX
|
Loading…
Add table
Reference in a new issue