]> git.mxchange.org Git - flightgear.git/commitdiff
Update for nasal::Ghost changes
authorThomas Geymayer <tomgey@gmail.com>
Sun, 3 Mar 2013 14:27:06 +0000 (15:27 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Sun, 3 Mar 2013 18:30:16 +0000 (19:30 +0100)
src/GUI/FileDialog.cxx
src/GUI/FileDialog.hxx
src/Scripting/NasalCanvas.cxx

index c6a1c321fd6673dc03609946c6f614de212e69fa..33f10838b907f8b06daa32d2201b2b859da0855e 100644 (file)
@@ -86,18 +86,6 @@ void FGFileDialog::setShowHidden(bool show)
     _showHidden = show;
 }
 
-naRef FGFileDialog::openFromNasal(const nasal::CallContext& ctx)
-{
-    exec();
-    return naNil();
-}
-
-naRef FGFileDialog::closeFromNasal(const nasal::CallContext& ctx)
-{
-    close();
-    return naNil();
-}
-
 class NasalCallback : public FGFileDialog::Callback
 {
 public:
@@ -133,21 +121,20 @@ private:
     int _gcKeys[2];
 };
 
-naRef FGFileDialog::setCallbackFromNasal(const nasal::CallContext& ctx)
+void FGFileDialog::setCallbackFromNasal(const nasal::CallContext& ctx)
 {
     // wrap up the naFunc in our callback type
     naRef func = ctx.requireArg<naRef>(0);
     naRef object = ctx.getArg<naRef>(1, naNil());
     
     setCallback(new NasalCallback(func, object));
-    return naNil();
 }
 
 typedef boost::shared_ptr<FGFileDialog> FileDialogPtr;
 typedef nasal::Ghost<FileDialogPtr> NasalFileDialog;
 
 /**
- * Create new Canvas and get ghost for it.
+ * Create new FGFileDialog and get ghost for it.
  */
 static naRef f_createFileDialog(naContext c, naRef me, int argc, naRef* args)
 {
@@ -172,9 +159,9 @@ void postinitNasalGUI(naRef globals, naContext c)
     .member("show_hidden", &FGFileDialog::showHidden, &FGFileDialog::setShowHidden)
     .member("placeholder", &FGFileDialog::getPlaceholder, &FGFileDialog::setPlaceholderName)
     .member("pattern", &FGFileDialog::filterPatterns, &FGFileDialog::setFilterPatterns)
-    .method<&FGFileDialog::openFromNasal>("open")
-    .method<&FGFileDialog::closeFromNasal>("close")
-    .method<&FGFileDialog::setCallbackFromNasal>("setCallback");
+    .method("open", &FGFileDialog::exec)
+    .method("close", &FGFileDialog::close)
+    .method("setCallback", &FGFileDialog::setCallbackFromNasal);
 
     nasal::Hash guiModule = nasal::Hash(globals, c).get<nasal::Hash>("gui");
     
index 57fd89103cdae21f9b7259648b415e467ec635f5..3479f8004cf3dc4da93d36bb39d5cee07644dd0e 100644 (file)
@@ -57,21 +57,19 @@ public:
      */
     virtual ~FGFileDialog ();
 
-     virtual void exec() = 0;
-     virtual void close() = 0;
+    virtual void exec() = 0;
+    virtual void close() = 0;
     
-     class Callback
-     {
-     public:
-         virtual ~Callback() { }
-         virtual void onFileDialogDone(FGFileDialog* ins, const SGPath& result) = 0;
-     };
+    class Callback
+    {
+      public:
+        virtual ~Callback() { }
+        virtual void onFileDialogDone(FGFileDialog* ins, const SGPath& result) = 0;
+    };
 
-     virtual void setCallback(Callback* aCB);
+    virtual void setCallback(Callback* aCB);
 
-    naRef openFromNasal(const nasal::CallContext& ctx);
-    naRef closeFromNasal(const nasal::CallContext& ctx);
-    naRef setCallbackFromNasal(const nasal::CallContext& ctx);
+    void setCallbackFromNasal(const nasal::CallContext& ctx);
 protected:
     FGFileDialog(Usage use);
     
index f349dadb5bf502070c597cfeda85678415dd6618..fbb548b4f3aecf52b87d2409d3100537db84393e 100644 (file)
@@ -178,13 +178,9 @@ naRef f_eventGetTarget(naContext c, sc::Event& event)
   return NasalElement::create(c, event.getTarget().lock());
 }
 
-// TODO allow directly exposing functions without parameters and return type
-naRef f_eventStopPropagation(sc::Event& event, const nasal::CallContext& ctx)
+void f_eventStopPropagation(sc::Event& event)
 {
-  if( ctx.argc != 0 )
-    naRuntimeError(ctx.c, "Event::stopPropagation no argument expected");
   event.stopPropagation();
-  return naNil();
 }
 
 naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
@@ -192,7 +188,7 @@ naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
   NasalEvent::init("canvas.Event")
     .member("type", &sc::Event::getTypeString)
     .member("target", &f_eventGetTarget)
-    .method_func<&f_eventStopPropagation>("stopPropagation");
+    .method("stopPropagation", &f_eventStopPropagation);
   NasalMouseEvent::init("canvas.MouseEvent")
     .bases<NasalEvent>()
     .member("screenX", &sc::MouseEvent::getScreenX)
@@ -206,20 +202,20 @@ naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
     .member("_node_ghost", &elementGetNode<sc::Canvas>)
     .member("size_x", &sc::Canvas::getSizeX)
     .member("size_y", &sc::Canvas::getSizeY)
-    .method_func<&f_canvasCreateGroup>("_createGroup")
-    .method<&sc::Canvas::addEventListener>("addEventListener");
+    .method("_createGroup", &f_canvasCreateGroup)
+    .method("addEventListener", &sc::Canvas::addEventListener);
   NasalElement::init("canvas.Element")
     .member("_node_ghost", &elementGetNode<sc::Element>)
-    .method<&sc::Element::addEventListener>("addEventListener")
-    .method_func<&f_elementGetTransformedBounds>("getTransformedBounds");
+    .method("addEventListener", &sc::Element::addEventListener)
+    .method("getTransformedBounds", &f_elementGetTransformedBounds);
   NasalGroup::init("canvas.Group")
     .bases<NasalElement>()
-    .method_func<&f_groupCreateChild>("_createChild")
-    .method_func<&f_groupGetChild>("_getChild")
-    .method_func<&f_groupGetElementById>("_getElementById");
+    .method("_createChild", &f_groupCreateChild)
+    .method("_getChild", &f_groupGetChild)
+    .method("_getElementById", &f_groupGetElementById);
   NasalText::init("canvas.Text")
     .bases<NasalElement>()
-    .method_func<&f_textGetNearestCursor>("getNearestCursor");
+    .method("getNearestCursor", &f_textGetNearestCursor);
 
   nasal::Hash globals_module(globals, c),
               canvas_module = globals_module.createHash("canvas");