gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/vm/Makefile.am server/vm...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/vm/Makefile.am server/vm...
Date: Fri, 24 Nov 2006 11:49:18 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/11/24 11:49:18

Modified files:
        .              : ChangeLog 
        server/vm      : Makefile.am 
Added files:
        server/vm      : VM.cpp VM.h 

Log message:
                * server/vm/: Makefile.am, VM.{cpp,h}: new class aimed at
                  holding VM-related globals.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1738&r2=1.1739
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/Makefile.am?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/VM.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/VM.h?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1738
retrieving revision 1.1739
diff -u -b -r1.1738 -r1.1739
--- ChangeLog   24 Nov 2006 10:37:31 -0000      1.1738
+++ ChangeLog   24 Nov 2006 11:49:17 -0000      1.1739
@@ -1,3 +1,8 @@
+2006-11-24 Sandro Santilli <address@hidden>
+
+       * server/vm/: Makefile.am, VM.{cpp,h}: new class aimed at
+         holding VM-related globals.
+
 2006-11-24 Vitaly Alexeev <address@hidden>
 
        * backend\render_handler_ogl.cpp: added "class YUV_video_ogl_NV"

Index: server/vm/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/vm/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/vm/Makefile.am       24 Nov 2006 09:04:25 -0000      1.1
+++ server/vm/Makefile.am       24 Nov 2006 11:49:18 -0000      1.2
@@ -18,7 +18,7 @@
 # 
 #
 
-# $Id: Makefile.am,v 1.1 2006/11/24 09:04:25 strk Exp $
+# $Id: Makefile.am,v 1.2 2006/11/24 11:49:18 strk Exp $
 
 AUTOMAKE_OPTIONS = 
 
@@ -45,12 +45,14 @@
 libgnashvm_la_SOURCES = \
        ASHandlers.cpp \
        ActionExec.cpp \
+       VM.cpp          \
         action.cpp \
        $(NULL)
 
 noinst_HEADERS =               \
        ASHandlers.h            \
        ActionExec.h            \
+       VM.h                    \
        action.h                \
        fn_call.h               \
        with_stack_entry.h      \

Index: server/vm/VM.cpp
===================================================================
RCS file: server/vm/VM.cpp
diff -N server/vm/VM.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ server/vm/VM.cpp    24 Nov 2006 11:49:18 -0000      1.1
@@ -0,0 +1,109 @@
+// 
+//   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// 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
+
+//
+
+/* $Id: VM.cpp,v 1.1 2006/11/24 11:49:18 strk Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "VM.h"
+#include "movie_definition.h"
+#include "sprite_instance.h"
+
+#include <memory>
+
+
+namespace gnash {
+
+// Pointer to our singleton
+std::auto_ptr<VM> VM::_singleton;
+
+VM&
+VM::init(movie_definition& movie)
+{
+       // Don't call more then once !
+       assert(!_singleton.get());
+
+       _singleton.reset(new VM(movie));
+
+       _singleton->setRoot(movie.create_instance());
+
+       assert(_singleton.get());
+       return *_singleton;
+}
+
+VM&
+VM::get()
+{
+       // Did you call VM::init ?
+       assert(_singleton.get());
+       return *_singleton;
+}
+
+VM::VM(movie_definition& topmovie)
+       :
+       _swfversion(topmovie.get_version())
+{
+}
+
+VM::~VM()
+{
+       // nothing to do atm, but we'll likely
+       // have to deregister lots of stuff when
+       // things are setup
+}
+
+std::locale&
+VM::getLocale() const
+{
+       // TODO: some research about what we should be using.
+       //       IIRC older SWF contained some tags for this,
+       //       while new SWF uses UNICODE...
+       static std::locale loc("C");
+       return loc;
+}
+
+int
+VM::getSWFVersion() const
+{
+       return _swfversion;
+}
+
+sprite_instance*
+VM::getRoot() const
+{
+       return _root_movie.get();
+}
+
+/*private*/
+void
+VM::setRoot(sprite_instance* inst)
+{
+       assert(!_root_movie);
+       _root_movie = inst;
+}
+
+
+} // end of namespace gnash
+
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:

Index: server/vm/VM.h
===================================================================
RCS file: server/vm/VM.h
diff -N server/vm/VM.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ server/vm/VM.h      24 Nov 2006 11:49:18 -0000      1.1
@@ -0,0 +1,136 @@
+// 
+//   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// 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 GNASH_VM_H
+#define GNASH_VM_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <smart_ptr.h> // for boost::intrusive_ptr
+
+#include <memory> // for auto_ptr
+#include <locale>
+
+// Forward declarations
+namespace gnash {
+       class movie_definition;
+       class sprite_instance;
+}
+
+namespace gnash {
+
+/// The virtual machine
+//
+/// This is the machine that executes all actions in the 
+/// main movie, including the actions in movies loaded by
+/// it.
+///
+/// Note that the target SWF version of the "main" movie
+/// (the first movie loaded, the 'root' movie) drives
+/// the operation, as depending on that version the Virtual
+/// Machine acts differently, for backward compatibility.
+/// 
+/// The VM is initialized once for each *main* movie.
+/// Gnash currently only supports a *single* VM as it uses
+/// gloabls a lot. Definition of this class is aimed at
+/// grouping the globals into a specific VM instance that
+/// we might pass around in the future to allow multiple
+/// movies runs.
+/// For the moment, it will be a singleton, providing one-time
+/// initialization.
+///
+class VM {
+
+       /// Use VM::get() to access the singleton
+       VM(movie_definition& movie);
+
+       /// Don't copy
+       VM(const VM&);
+
+       /// Don't assign
+       VM& operator=(const VM&);
+
+       ~VM();
+
+       // We use an auto_ptr here to allow constructing
+       // the singleton when the init() function is called.
+       friend class std::auto_ptr<VM>;
+       static std::auto_ptr<VM> _singleton;
+
+       /// \brief
+       /// Root movie, will be instanciated from the definition
+       /// given to the init() function.
+       boost::intrusive_ptr<sprite_instance> _root_movie;
+
+       /// Target SWF version
+       int _swfversion;
+
+       /// Set the current Root movie.
+       //
+       /// Will be called by the init() function
+       /// 
+       void setRoot(sprite_instance*);
+
+public:
+
+       /// \brief
+       /// Initialize the virtual machine singleton with the given
+       /// movie definition and return a reference to it.
+       //
+       /// An instance of the given movie will become the absolute
+       /// root of the application (ActionScript's _level0)
+       ///
+       /// Don't call this function twice, and make sure you have
+       /// called this *before* you call VM::get()
+       ///
+       /// @param movie
+       ///     The definition for the root movie.
+       ///
+       static VM& init(movie_definition& movie);
+
+       /// Get the singleton instance of the virtual machine
+       //
+       /// Make sure you called VM::init() before trying to
+       /// get the singleton (an assertion would fail otherwise)
+       ///
+       static VM& get();
+
+       /// Get version of the SWF movie used to initialize this VM
+       //
+       /// This information will drive operations of the virtual machine
+       ///
+       int getSWFVersion() const;
+
+       /// Get a pointer to the current Root movie 
+       sprite_instance* getRoot() const;
+
+       /// Get the SWF locale to use 
+       std::locale& getLocale() const;
+
+};
+
+} // namespace gnash
+
+#endif // GNASH_VM_H
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:




reply via email to

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