gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/asobj/Date.h server/asob...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/Date.h server/asob...
Date: Mon, 20 Nov 2006 21:28:58 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/11/20 21:28:58

Modified files:
        .              : ChangeLog 
        server/asobj   : Date.h Global.cpp Camera.h Camera.cpp Color.cpp 
                         Color.h ContextMenu.cpp ContextMenu.h 
                         CustomActions.cpp CustomActions.h 

Log message:
                * server/asobj/Date.h: streamlined headers inclusion.
                * server/asobj: Global.cpp, Camera.{h,cpp}, Color.{cpp,h},
                  ContextMenu.{h,cpp}, CustomActions.{cpp,h}:
                  ported ActionScript class stubs to new layout.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1677&r2=1.1678
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Date.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Camera.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Camera.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Color.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Color.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/ContextMenu.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/ContextMenu.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/CustomActions.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/CustomActions.h?cvsroot=gnash&r1=1.4&r2=1.5

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1677
retrieving revision 1.1678
diff -u -b -r1.1677 -r1.1678
--- ChangeLog   20 Nov 2006 17:12:07 -0000      1.1677
+++ ChangeLog   20 Nov 2006 21:28:58 -0000      1.1678
@@ -1,5 +1,9 @@
 2006-11-20 Sandro Santilli <address@hidden>
 
+       * server/asobj/Date.h: streamlined headers inclusion.
+       * server/asobj: Global.cpp, Camera.{h,cpp}, Color.{cpp,h},
+         ContextMenu.{h,cpp}, CustomActions.{cpp,h}:
+         ported ActionScript class stubs to new layout.
        * doc/C/gnashrc.xml: fixed description of whitelist/blacklist 
          settings.
 

Index: server/asobj/Date.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Date.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/Date.h 29 Oct 2006 18:34:12 -0000      1.4
+++ server/asobj/Date.h 20 Nov 2006 21:28:58 -0000      1.5
@@ -24,7 +24,10 @@
 #include "config.h"
 #endif
 
-#include "impl.h"
+#include "as_object.h" // for inheritance
+#include "fn_call.h" // for inheritance
+
+/// TODO: port Date class to new layout
 
 namespace gnash {
   

Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- server/asobj/Global.cpp     20 Nov 2006 11:40:47 -0000      1.19
+++ server/asobj/Global.cpp     20 Nov 2006 21:28:58 -0000      1.20
@@ -18,7 +18,7 @@
 
 // Implementation of the Global ActionScript Object
 
-/* $Id: Global.cpp,v 1.19 2006/11/20 11:40:47 strk Exp $ */
+/* $Id: Global.cpp,v 1.20 2006/11/20 21:28:58 strk Exp $ */
 
 #include "as_object.h"
 #include "as_prop_flags.h"
@@ -411,10 +411,6 @@
        //set_member("String", as_value(string_ctor));
        // This next set are all the unimplemented classes whose
        // code was machine generated.
-       set_member("Camera", as_value(camera_new));
-       set_member("Color", as_value(color_new));
-       set_member("ContextMenu", as_value(contextmenu_new));
-       set_member("CustomActions", as_value(customactions_new));
        set_member("Date", as_value(date_new));
        set_member("Error", as_value(error_new));
        set_member("LoadVars", as_value(loadvars_new));
@@ -442,6 +438,10 @@
        // isFinite
        set_member("isFinite", as_global_isfinite);
 
+       customactions_class_init(*this);
+       contextmenu_class_init(*this);
+       color_class_init(*this);
+       camera_class_init(*this);
        boolean_class_init(*this);
        moviecliploader_class_init(*this);
        object_class_init(*this);

Index: server/asobj/Camera.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Camera.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/Camera.h       29 Oct 2006 18:34:12 -0000      1.4
+++ server/asobj/Camera.h       20 Nov 2006 21:28:58 -0000      1.5
@@ -10,65 +10,33 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
+//
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-// 
-//
 //
 
-#ifndef __CAMERA_H__
-#define __CAMERA_H__
+#ifndef __GNASH_ASOBJ_CAMERA_H__
+#define __GNASH_ASOBJ_CAMERA_H__
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include "impl.h"
+#include <memory> // for auto_ptr
 
 namespace gnash {
   
-class Camera {
-public:
-    Camera();
-    ~Camera();
-   void get();
-   void setMode();
-   void setMotionLevel();
-   void setQuality();
-private:
-    bool _activityLevel;
-    bool _bandwidth;
-    bool _currentFps;
-    bool _fps;
-    bool _height;
-    bool _index;
-    bool _motionLevel;
-    bool _motionTimeOut;
-    bool _muted;
-    bool _name;
-    bool _names;
-    bool _onActivity;
-    bool _onStatus;
-    bool _quality;
-    bool _width;
-};
-
-class camera_as_object : public as_object
-{
-public:
-    Camera obj;
-};
-
-void camera_new(const fn_call& fn);
-void camera_get(const fn_call& fn);
-void camera_setmode(const fn_call& fn);
-void camera_setmotionlevel(const fn_call& fn);
-void camera_setquality(const fn_call& fn);
+class as_object;
+
+/// Initialize the global Camera class
+void camera_class_init(as_object& global);
+
+/// Return a Camera instance (in case the core lib needs it)
+//std::auto_ptr<as_object> init_camera_instance();
 
 } // end of gnash namespace
 
-// __CAMERA_H__
+// __GNASH_ASOBJ_CAMERA_H__
 #endif
 

Index: server/asobj/Camera.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Camera.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/asobj/Camera.cpp     29 Oct 2006 18:34:12 -0000      1.2
+++ server/asobj/Camera.cpp     20 Nov 2006 21:28:58 -0000      1.3
@@ -10,78 +10,110 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
+//
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-// 
-//
 //
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include "log.h"
 #include "Camera.h"
+#include "as_object.h" // for inheritance
+#include "log.h"
 #include "fn_call.h"
+#include "smart_ptr.h" // for boost intrusive_ptr
+#include "builtin_function.h" // need builtin_function
 
 namespace gnash {
 
-Camera::Camera() {
-}
-
-Camera::~Camera() {
-}
+void camera_get(const fn_call& fn);
+void camera_setmode(const fn_call& fn);
+void camera_setmotionlevel(const fn_call& fn);
+void camera_setquality(const fn_call& fn);
+void camera_ctor(const fn_call& fn);
 
-
-void
-Camera::get()
+static void
+attachCameraInterface(as_object& o)
 {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+       o.set_member("get", &camera_get);
+       o.set_member("setmode", &camera_setmode);
+       o.set_member("setmotionlevel", &camera_setmotionlevel);
+       o.set_member("setquality", &camera_setquality);
 }
 
-void
-Camera::setMode()
+static as_object*
+getCameraInterface()
 {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+       static boost::intrusive_ptr<as_object> o;
+       if ( ! o )
+       {
+               o = new as_object();
+               attachCameraInterface(*o);
+       }
+       return o.get();
 }
 
-void
-Camera::setMotionLevel()
+class camera_as_object: public as_object
 {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
 
-void
-Camera::setQuality()
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-void
-camera_new(const fn_call& fn)
-{
-    camera_as_object *camera_obj = new camera_as_object;
+public:
 
-    camera_obj->set_member("get", &camera_get);
-    camera_obj->set_member("setmode", &camera_setmode);
-    camera_obj->set_member("setmotionlevel", &camera_setmotionlevel);
-    camera_obj->set_member("setquality", &camera_setquality);
+       camera_as_object()
+               :
+               as_object(getCameraInterface())
+       {}
+
+       // override from as_object ?
+       //const char* get_text_value() const { return "Camera"; }
+
+       // override from as_object ?
+       //double get_numeric_value() const { return 0; }
+};
 
-    fn.result->set_as_object(camera_obj);
-}
 void camera_get(const fn_call& /*fn*/) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+    log_warning("%s: unimplemented \n", __FUNCTION__);
 }
 void camera_setmode(const fn_call& /*fn*/) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+    log_warning("%s: unimplemented \n", __FUNCTION__);
 }
 void camera_setmotionlevel(const fn_call& /*fn*/) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+    log_warning("%s: unimplemented \n", __FUNCTION__);
 }
 void camera_setquality(const fn_call& /*fn*/) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+    log_warning("%s: unimplemented \n", __FUNCTION__);
+}
+
+void
+camera_ctor(const fn_call& fn)
+{
+       boost::intrusive_ptr<as_object> obj = new camera_as_object;
+       
+       fn.result->set_as_object(obj.get()); // will keep alive
 }
 
-} // end of gnaash namespace
+// extern (used by Global.cpp)
+void camera_class_init(as_object& global)
+{
+       // This is going to be the global Camera "class"/"function"
+       static boost::intrusive_ptr<builtin_function> cl;
+
+       if ( cl == NULL )
+       {
+               cl=new builtin_function(&camera_ctor, getCameraInterface());
+               // replicate all interface to class, to be able to access
+               // all methods as static functions
+               attachCameraInterface(*cl);
+                    
+       }
+
+       // Register _global.Camera
+       global.set_member("Camera", cl.get());
+
+}
+
+
+} // end of gnash namespace
 

Index: server/asobj/Color.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Color.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/asobj/Color.cpp      29 Oct 2006 18:34:12 -0000      1.2
+++ server/asobj/Color.cpp      20 Nov 2006 21:28:58 -0000      1.3
@@ -10,78 +10,110 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
+//
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-// 
-//
 //
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include "log.h"
 #include "Color.h"
+#include "as_object.h" // for inheritance
+#include "log.h"
 #include "fn_call.h"
+#include "smart_ptr.h" // for boost intrusive_ptr
+#include "builtin_function.h" // need builtin_function
 
 namespace gnash {
 
-Color::Color() {
-}
-
-Color::~Color() {
-}
+void color_getrgb(const fn_call& fn);
+void color_gettransform(const fn_call& fn);
+void color_setrgb(const fn_call& fn);
+void color_settransform(const fn_call& fn);
+void color_ctor(const fn_call& fn);
 
-
-void
-Color::getRGB()
+static void
+attachColorInterface(as_object& o)
 {
-    log_warning("%s: unimplemented \n", __PRETTY_FUNCTION__);
+       o.set_member("getrgb", &color_getrgb);
+       o.set_member("gettransform", &color_gettransform);
+       o.set_member("setrgb", &color_setrgb);
+       o.set_member("settransform", &color_settransform);
 }
 
-void
-Color::getTransform()
+static as_object*
+getColorInterface()
 {
-    log_warning("%s: unimplemented \n", __PRETTY_FUNCTION__);
+       static boost::intrusive_ptr<as_object> o;
+       if ( ! o )
+       {
+               o = new as_object();
+               attachColorInterface(*o);
+       }
+       return o.get();
 }
 
-void
-Color::setRGB()
+class color_as_object: public as_object
 {
-    log_warning("%s: unimplemented \n", __PRETTY_FUNCTION__);
-}
 
-void
-Color::setTransform()
-{
-    log_warning("%s: unimplemented \n", __PRETTY_FUNCTION__);
-}
-void
-color_new(const fn_call& fn)
-{
-    color_as_object *color_obj = new color_as_object;
+public:
 
-    color_obj->set_member("getrgb", &color_getrgb);
-    color_obj->set_member("gettransform", &color_gettransform);
-    color_obj->set_member("setrgb", &color_setrgb);
-    color_obj->set_member("settransform", &color_settransform);
+       color_as_object()
+               :
+               as_object(getColorInterface())
+       {}
+
+       // override from as_object ?
+       //const char* get_text_value() const { return "Color"; }
+
+       // override from as_object ?
+       //double get_numeric_value() const { return 0; }
+};
 
-    fn.result->set_as_object(color_obj);
-}
 void color_getrgb(const fn_call& /*fn*/) {
-    log_warning("%s: unimplemented \n", __PRETTY_FUNCTION__);
+    log_warning("%s: unimplemented \n", __FUNCTION__);
 }
 void color_gettransform(const fn_call& /*fn*/) {
-    log_warning("%s: unimplemented \n", __PRETTY_FUNCTION__);
+    log_warning("%s: unimplemented \n", __FUNCTION__);
 }
 void color_setrgb(const fn_call& /*fn*/) {
-    log_warning("%s: unimplemented \n", __PRETTY_FUNCTION__);
+    log_warning("%s: unimplemented \n", __FUNCTION__);
 }
 void color_settransform(const fn_call& /*fn*/) {
-    log_warning("%s: unimplemented \n", __PRETTY_FUNCTION__);
+    log_warning("%s: unimplemented \n", __FUNCTION__);
+}
+
+void
+color_ctor(const fn_call& fn)
+{
+       boost::intrusive_ptr<as_object> obj = new color_as_object;
+       
+       fn.result->set_as_object(obj.get()); // will keep alive
 }
 
-} // end of gnaash namespace
+// extern (used by Global.cpp)
+void color_class_init(as_object& global)
+{
+       // This is going to be the global Color "class"/"function"
+       static boost::intrusive_ptr<builtin_function> cl;
+
+       if ( cl == NULL )
+       {
+               cl=new builtin_function(&color_ctor, getColorInterface());
+               // replicate all interface to class, to be able to access
+               // all methods as static functions
+               attachColorInterface(*cl);
+                    
+       }
+
+       // Register _global.Color
+       global.set_member("Color", cl.get());
+
+}
+
+
+} // end of gnash namespace
 

Index: server/asobj/Color.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Color.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/Color.h        29 Oct 2006 18:34:12 -0000      1.4
+++ server/asobj/Color.h        20 Nov 2006 21:28:58 -0000      1.5
@@ -10,50 +10,33 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
+//
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-// 
-//
 //
 
-#ifndef __COLOR_H__
-#define __COLOR_H__
+#ifndef __GNASH_ASOBJ_COLOR_H__
+#define __GNASH_ASOBJ_COLOR_H__
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include "impl.h"
+#include <memory> // for auto_ptr
 
 namespace gnash {
   
-class Color {
-public:
-    Color();
-    ~Color();
-   void getRGB();
-   void getTransform();
-   void setRGB();
-   void setTransform();
-private:
-};
-
-class color_as_object : public as_object
-{
-public:
-    Color obj;
-};
-
-void color_new(const fn_call& fn);
-void color_getrgb(const fn_call& fn);
-void color_gettransform(const fn_call& fn);
-void color_setrgb(const fn_call& fn);
-void color_settransform(const fn_call& fn);
+class as_object;
+
+/// Initialize the global Color class
+void color_class_init(as_object& global);
+
+/// Return a Color instance (in case the core lib needs it)
+//std::auto_ptr<as_object> init_color_instance();
 
 } // end of gnash namespace
 
-// __COLOR_H__
+// __GNASH_ASOBJ_COLOR_H__
 #endif
 

Index: server/asobj/ContextMenu.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/ContextMenu.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/asobj/ContextMenu.cpp        29 Oct 2006 18:34:12 -0000      1.3
+++ server/asobj/ContextMenu.cpp        20 Nov 2006 21:28:58 -0000      1.4
@@ -10,58 +10,100 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
+//
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-// 
-//
 //
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include "log.h"
 #include "ContextMenu.h"
+#include "as_object.h" // for inheritance
+#include "log.h"
 #include "fn_call.h"
+#include "smart_ptr.h" // for boost intrusive_ptr
+#include "builtin_function.h" // need builtin_function
 
 namespace gnash {
 
-ContextMenu::ContextMenu() {
-}
+void contextmenu_copy(const fn_call& fn);
+void contextmenu_hidebuiltinitems(const fn_call& fn);
+void contextmenu_ctor(const fn_call& fn);
 
-ContextMenu::~ContextMenu() {
+static void
+attachContextMenuInterface(as_object& o)
+{
+       o.set_member("copy", &contextmenu_copy);
+       o.set_member("hidebuiltinitems", &contextmenu_hidebuiltinitems);
 }
 
+static as_object*
+getContextMenuInterface()
+{
+       static boost::intrusive_ptr<as_object> o;
+       if ( ! o )
+       {
+               o = new as_object();
+               attachContextMenuInterface(*o);
+       }
+       return o.get();
+}
 
-void
-ContextMenu::copy()
+class contextmenu_as_object: public as_object
 {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+
+public:
+
+       contextmenu_as_object()
+               :
+               as_object(getContextMenuInterface())
+       {}
+
+       // override from as_object ?
+       //const char* get_text_value() const { return "ContextMenu"; }
+
+       // override from as_object ?
+       //double get_numeric_value() const { return 0; }
+};
+
+void contextmenu_copy(const fn_call& /*fn*/) {
+    log_warning("%s: unimplemented \n", __FUNCTION__);
+}
+void contextmenu_hidebuiltinitems(const fn_call& /*fn*/) {
+    log_warning("%s: unimplemented \n", __FUNCTION__);
 }
 
 void
-ContextMenu::hideBuiltInItems()
+contextmenu_ctor(const fn_call& fn)
 {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+       boost::intrusive_ptr<as_object> obj = new contextmenu_as_object;
+       
+       fn.result->set_as_object(obj.get()); // will keep alive
 }
-void
-contextmenu_new(const fn_call& fn)
+
+// extern (used by Global.cpp)
+void contextmenu_class_init(as_object& global)
 {
-    contextmenu_as_object *contextmenu_obj = new contextmenu_as_object;
+       // This is going to be the global ContextMenu "class"/"function"
+       static boost::intrusive_ptr<builtin_function> cl;
 
-    contextmenu_obj->set_member("copy", &contextmenu_copy);
-    contextmenu_obj->set_member("hidebuiltinitems", 
&contextmenu_hidebuiltinitems);
+       if ( cl == NULL )
+       {
+               cl=new builtin_function(&contextmenu_ctor, 
getContextMenuInterface());
+               // replicate all interface to class, to be able to access
+               // all methods as static functions
+               attachContextMenuInterface(*cl);
+                    
+       }
+
+       // Register _global.ContextMenu
+       global.set_member("ContextMenu", cl.get());
 
-    fn.result->set_as_object(contextmenu_obj);
-}
-void contextmenu_copy(const fn_call& /*fn*/) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-void contextmenu_hidebuiltinitems(const fn_call& /*fn*/) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
 }
 
-} // end of gnaash namespace
+
+} // end of gnash namespace
 

Index: server/asobj/ContextMenu.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/ContextMenu.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/ContextMenu.h  29 Oct 2006 18:34:12 -0000      1.4
+++ server/asobj/ContextMenu.h  20 Nov 2006 21:28:58 -0000      1.5
@@ -10,49 +10,33 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
+//
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-// 
-//
 //
 
-#ifndef __CONTEXTMENU_H__
-#define __CONTEXTMENU_H__
+#ifndef __GNASH_ASOBJ_CONTEXTMENU_H__
+#define __GNASH_ASOBJ_CONTEXTMENU_H__
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include "impl.h"
+#include <memory> // for auto_ptr
 
 namespace gnash {
   
-class ContextMenu {
-public:
-    ContextMenu();
-    ~ContextMenu();
-   void copy();
-   void hideBuiltInItems();
-private:
-    bool _builtInItems;
-    bool _customItems;
-    bool _onSelect;
-};
-
-class contextmenu_as_object : public as_object
-{
-public:
-    ContextMenu obj;
-};
-
-void contextmenu_new(const fn_call& fn);
-void contextmenu_copy(const fn_call& fn);
-void contextmenu_hidebuiltinitems(const fn_call& fn);
+class as_object;
+
+/// Initialize the global ContextMenu class
+void contextmenu_class_init(as_object& global);
+
+/// Return a ContextMenu instance (in case the core lib needs it)
+//std::auto_ptr<as_object> init_contextmenu_instance();
 
 } // end of gnash namespace
 
-// __CONTEXTMENU_H__
+// __GNASH_ASOBJ_CONTEXTMENU_H__
 #endif
 

Index: server/asobj/CustomActions.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/CustomActions.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/asobj/CustomActions.cpp      29 Oct 2006 18:34:12 -0000      1.2
+++ server/asobj/CustomActions.cpp      20 Nov 2006 21:28:58 -0000      1.3
@@ -10,78 +10,110 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
+//
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-// 
-//
 //
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include "log.h"
 #include "CustomActions.h"
+#include "as_object.h" // for inheritance
+#include "log.h"
 #include "fn_call.h"
+#include "smart_ptr.h" // for boost intrusive_ptr
+#include "builtin_function.h" // need builtin_function
 
 namespace gnash {
 
-CustomActions::CustomActions() {
-}
-
-CustomActions::~CustomActions() {
-}
+void customactions_get(const fn_call& fn);
+void customactions_install(const fn_call& fn);
+void customactions_list(const fn_call& fn);
+void customactions_uninstall(const fn_call& fn);
+void customactions_ctor(const fn_call& fn);
 
-
-void
-CustomActions::get()
+static void
+attachCustomActionsInterface(as_object& o)
 {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+       o.set_member("get", &customactions_get);
+       o.set_member("install", &customactions_install);
+       o.set_member("list", &customactions_list);
+       o.set_member("uninstall", &customactions_uninstall);
 }
 
-void
-CustomActions::install()
+static as_object*
+getCustomActionsInterface()
 {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+       static boost::intrusive_ptr<as_object> o;
+       if ( ! o )
+       {
+               o = new as_object();
+               attachCustomActionsInterface(*o);
+       }
+       return o.get();
 }
 
-void
-CustomActions::list()
+class customactions_as_object: public as_object
 {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
 
-void
-CustomActions::uninstall()
-{
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-void
-customactions_new(const fn_call& fn)
-{
-    customactions_as_object *customactions_obj = new customactions_as_object;
+public:
 
-    customactions_obj->set_member("get", &customactions_get);
-    customactions_obj->set_member("install", &customactions_install);
-    customactions_obj->set_member("list", &customactions_list);
-    customactions_obj->set_member("uninstall", &customactions_uninstall);
+       customactions_as_object()
+               :
+               as_object(getCustomActionsInterface())
+       {}
+
+       // override from as_object ?
+       //const char* get_text_value() const { return "CustomActions"; }
+
+       // override from as_object ?
+       //double get_numeric_value() const { return 0; }
+};
 
-    fn.result->set_as_object(customactions_obj);
-}
 void customactions_get(const fn_call& /*fn*/) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+    log_warning("%s: unimplemented \n", __FUNCTION__);
 }
 void customactions_install(const fn_call& /*fn*/) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+    log_warning("%s: unimplemented \n", __FUNCTION__);
 }
 void customactions_list(const fn_call& /*fn*/) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+    log_warning("%s: unimplemented \n", __FUNCTION__);
 }
 void customactions_uninstall(const fn_call& /*fn*/) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+    log_warning("%s: unimplemented \n", __FUNCTION__);
+}
+
+void
+customactions_ctor(const fn_call& fn)
+{
+       boost::intrusive_ptr<as_object> obj = new customactions_as_object;
+       
+       fn.result->set_as_object(obj.get()); // will keep alive
 }
 
-} // end of gnaash namespace
+// extern (used by Global.cpp)
+void customactions_class_init(as_object& global)
+{
+       // This is going to be the global CustomActions "class"/"function"
+       static boost::intrusive_ptr<builtin_function> cl;
+
+       if ( cl == NULL )
+       {
+               cl=new builtin_function(&customactions_ctor, 
getCustomActionsInterface());
+               // replicate all interface to class, to be able to access
+               // all methods as static functions
+               attachCustomActionsInterface(*cl);
+                    
+       }
+
+       // Register _global.CustomActions
+       global.set_member("CustomActions", cl.get());
+
+}
+
+
+} // end of gnash namespace
 

Index: server/asobj/CustomActions.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/CustomActions.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/CustomActions.h        29 Oct 2006 18:34:12 -0000      1.4
+++ server/asobj/CustomActions.h        20 Nov 2006 21:28:58 -0000      1.5
@@ -10,50 +10,33 @@
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
+//
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-// 
-//
 //
 
-#ifndef __CUSTOMACTIONS_H__
-#define __CUSTOMACTIONS_H__
+#ifndef __GNASH_ASOBJ_CUSTOMACTIONS_H__
+#define __GNASH_ASOBJ_CUSTOMACTIONS_H__
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include "impl.h"
+#include <memory> // for auto_ptr
 
 namespace gnash {
   
-class CustomActions {
-public:
-    CustomActions();
-    ~CustomActions();
-   void get();
-   void install();
-   void list();
-   void uninstall();
-private:
-};
-
-class customactions_as_object : public as_object
-{
-public:
-    CustomActions obj;
-};
-
-void customactions_new(const fn_call& fn);
-void customactions_get(const fn_call& fn);
-void customactions_install(const fn_call& fn);
-void customactions_list(const fn_call& fn);
-void customactions_uninstall(const fn_call& fn);
+class as_object;
+
+/// Initialize the global CustomActions class
+void customactions_class_init(as_object& global);
+
+/// Return a CustomActions instance (in case the core lib needs it)
+//std::auto_ptr<as_object> init_customactions_instance();
 
 } // end of gnash namespace
 
-// __CUSTOMACTIONS_H__
+// __GNASH_ASOBJ_CUSTOMACTIONS_H__
 #endif
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]