gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/Boolean.cpp server...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/Boolean.cpp server...
Date: Mon, 20 Nov 2006 11:40:47 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/11/20 11:40:47

Modified files:
        .              : ChangeLog 
        server/asobj   : Boolean.cpp Boolean.h Global.cpp 

Log message:
        Patch by Michael Meier <address@hidden>:
        
                * server/asobj: Global.cpp, Boolean.cpp, Boolean.h:
                  implemented Boolean ActionScript class.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1667&r2=1.1668
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Boolean.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Boolean.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.18&r2=1.19

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1667
retrieving revision 1.1668
diff -u -b -r1.1667 -r1.1668
--- ChangeLog   19 Nov 2006 22:24:09 -0000      1.1667
+++ ChangeLog   20 Nov 2006 11:40:47 -0000      1.1668
@@ -1,3 +1,8 @@
+2006-11-20 Michael Meier <address@hidden>
+
+       * server/asobj: Global.cpp, Boolean.cpp, Boolean.h:
+         implemented Boolean ActionScript class.
+
 2006-11-19  Rob Savoye  <address@hidden>
 
        * backend/render_handler_ogl.cpp: Include glx.h so

Index: server/asobj/Boolean.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Boolean.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/asobj/Boolean.cpp    29 Oct 2006 18:34:12 -0000      1.2
+++ server/asobj/Boolean.cpp    20 Nov 2006 11:40:47 -0000      1.3
@@ -10,58 +10,126 @@
 // 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 "Boolean.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 {
 
-Boolean::Boolean() {
-}
+void boolean_tostring(const fn_call& fn);
+void boolean_valueof(const fn_call& fn);
+void boolean_ctor(const fn_call& fn);
 
-Boolean::~Boolean() {
+static void
+attachBooleanInterface(as_object& o)
+{
+       o.set_member("tostring", &boolean_tostring);
+       o.set_member("valueof", &boolean_valueof);
 }
 
+static as_object*
+getBooleanInterface()
+{
+       static boost::intrusive_ptr<as_object> o;
+       if ( ! o )
+       {
+               o = new as_object();
+               attachBooleanInterface(*o);
+       }
+       return o.get();
+}
 
-void
-Boolean::toString()
+class boolean_as_object: public as_object
 {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+
+public:
+
+       boolean_as_object()
+               :
+               as_object(getBooleanInterface())
+       {}
+
+       boolean_as_object(bool _val)
+               :
+               as_object(getBooleanInterface())
+       {
+               val = _val;
+       }
+       
+       // override from as_object ?
+       //const char* get_text_value() const { return "Boolean"; }
+
+       // override from as_object ?
+       //double get_numeric_value() const { return 0; }        
+       
+       bool val;
+       
+};
+
+void boolean_tostring(const fn_call& fn) {
+
+       static char* strtrue = "true";
+       static char* strfalse = "false";
+
+       boolean_as_object* boolobj = (boolean_as_object*) (as_object*) 
fn.this_ptr;
+       
+       if (boolobj->val) 
+               fn.result->set_string(strtrue);
+       else
+               fn.result->set_string(strfalse);
+}
+void boolean_valueof(const fn_call& fn) {
+    boolean_as_object* boolobj = (boolean_as_object*) (as_object*) fn.this_ptr;
+    
+    fn.result->set_bool(boolobj->val);
 }
 
 void
-Boolean::valueOf()
+boolean_ctor(const fn_call& fn)
 {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+       bool val = false;
+       if (fn.nargs > 0)
+       {
+               val = fn.arg(0).to_bool();
+       }
+       boost::intrusive_ptr<as_object> obj = new boolean_as_object(val);
+
+       fn.result->set_as_object(obj.get()); // will keep alive
 }
-void
-boolean_new(const fn_call& fn)
+
+// extern (used by Global.cpp)
+void boolean_class_init(as_object& global)
 {
-    boolean_as_object *boolean_obj = new boolean_as_object;
+       // This is going to be the global Boolean "class"/"function"
+       static boost::intrusive_ptr<builtin_function> cl;
 
-    boolean_obj->set_member("tostring", &boolean_tostring);
-    boolean_obj->set_member("valueof", &boolean_valueof);
+       if ( cl == NULL )
+       {
+               cl=new builtin_function(&boolean_ctor, getBooleanInterface());
+               // replicate all interface to class, to be able to access
+               // all methods as static functions
+               attachBooleanInterface(*cl);
+                    
+       }
+
+       // Register _global.Boolean
+       global.set_member("Boolean", cl.get());
 
-    fn.result->set_as_object(boolean_obj);
-}
-void boolean_tostring(const fn_call& /* fn */) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
-}
-void boolean_valueof(const fn_call& /* fn */) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
 }
 
-} // end of gnaash namespace
+
+} // end of gnash namespace
 

Index: server/asobj/Boolean.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Boolean.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/Boolean.h      29 Oct 2006 18:34:12 -0000      1.4
+++ server/asobj/Boolean.h      20 Nov 2006 11:40:47 -0000      1.5
@@ -10,46 +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 __BOOLEAN_H__
-#define __BOOLEAN_H__
+#ifndef __GNASH_ASOBJ_BOOLEAN_H__
+#define __GNASH_ASOBJ_BOOLEAN_H__
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include "impl.h"
+#include <memory> // for auto_ptr
 
 namespace gnash {
   
-class Boolean {
-public:
-    Boolean();
-    ~Boolean();
-   void toString();
-   void valueOf();
-private:
-};
-
-class boolean_as_object : public as_object
-{
-public:
-    Boolean obj;
-};
-
-void boolean_new(const fn_call& fn);
-void boolean_tostring(const fn_call& fn);
-void boolean_valueof(const fn_call& fn);
+class as_object;
+
+/// Initialize the global Boolean class
+void boolean_class_init(as_object& global);
+
+/// Return a Boolean instance (in case the core lib needs it)
+//std::auto_ptr<as_object> init_boolean_instance();
 
 } // end of gnash namespace
 
-// __BOOLEAN_H__
+// __GNASH_ASOBJ_BOOLEAN_H__
 #endif
 

Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/asobj/Global.cpp     31 Oct 2006 14:34:07 -0000      1.18
+++ server/asobj/Global.cpp     20 Nov 2006 11:40:47 -0000      1.19
@@ -18,7 +18,7 @@
 
 // Implementation of the Global ActionScript Object
 
-/* $Id: Global.cpp,v 1.18 2006/10/31 14:34:07 strk Exp $ */
+/* $Id: Global.cpp,v 1.19 2006/11/20 11:40:47 strk Exp $ */
 
 #include "as_object.h"
 #include "as_prop_flags.h"
@@ -411,7 +411,6 @@
        //set_member("String", as_value(string_ctor));
        // This next set are all the unimplemented classes whose
        // code was machine generated.
-       set_member("Boolean", as_value(boolean_new));
        set_member("Camera", as_value(camera_new));
        set_member("Color", as_value(color_new));
        set_member("ContextMenu", as_value(contextmenu_new));
@@ -443,6 +442,7 @@
        // isFinite
        set_member("isFinite", as_global_isfinite);
 
+       boolean_class_init(*this);
        moviecliploader_class_init(*this);
        object_class_init(*this);
        number_class_init(*this); 




reply via email to

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