]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scripting/NasalSys.hxx
- Added ultra-light traffic is now a separate traffic class that can have its
[flightgear.git] / src / Scripting / NasalSys.hxx
index 06551e160dcbb33a4f5efbf16e72f2f38e37b172..a68317570842fd9fcae58f6b78488c5e701491ce 100644 (file)
@@ -5,6 +5,7 @@
 #include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/nasal/nasal.h>
 #include <simgear/scene/model/model.hxx>
+#include <simgear/xml/easyxml.hxx>
 
 #include <map>
 SG_USING_STD(map);
@@ -40,7 +41,7 @@ public:
     FGNasalScript* parseScript(const char* src, const char* name=0);
 
     // Implementation of the settimer extension function
-    void setTimer(int argc, naRef* args);
+    void setTimer(naContext c, int argc, naRef* args);
 
     // Implementation of the setlistener extension function
     naRef setListener(naContext c, int argc, naRef* args);
@@ -131,7 +132,7 @@ private:
 class FGNasalListener : public SGPropertyChangeListener {
 public:
     FGNasalListener(SGPropertyNode_ptr node, naRef handler,
-                    FGNasalSys* nasal, int key);
+                    FGNasalSys* nasal, int key, int id);
 
     ~FGNasalListener();
     void valueChanged(SGPropertyNode* node);
@@ -141,6 +142,7 @@ private:
     SGPropertyNode_ptr _node;
     naRef _handler;
     int _gcKey;
+    int _id;
     FGNasalSys* _nas;
     unsigned int _active;
     bool _dead;
@@ -149,13 +151,33 @@ private:
 
 class FGNasalModelData : public SGModelData {
 public:
-    FGNasalModelData() : _unload(0) {}
+    FGNasalModelData(SGPropertyNode *props = 0) : _props(props), _unload(0) {}
     ~FGNasalModelData();
     void modelLoaded(const string& path, SGPropertyNode *prop, osg::Node *);
 
 private:
     string _module;
+    SGPropertyNode_ptr _props;
     SGConstPropertyNode_ptr _unload;
 };
 
+
+class NasalXMLVisitor : public XMLVisitor {
+public:
+    NasalXMLVisitor(naContext c, int argc, naRef* args);
+    virtual ~NasalXMLVisitor() { naFreeContext(_c); }
+
+    virtual void startElement(const char* tag, const XMLAttributes& a);
+    virtual void endElement(const char* tag);
+    virtual void data(const char* str, int len);
+    virtual void pi(const char* target, const char* data);
+
+private:
+    void call(naRef func, int num, naRef a = naNil(), naRef b = naNil());
+    naRef make_string(const char* s, int n = -1);
+
+    naContext _c;
+    naRef _start_element, _end_element, _data, _pi;
+};
+
 #endif // __NASALSYS_HXX