[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11526: Move Relay classes into a se
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11526: Move Relay classes into a separate file. |
Date: |
Tue, 29 Sep 2009 14:06:24 +0200 |
User-agent: |
Bazaar (1.16.1) |
------------------------------------------------------------
revno: 11526 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2009-09-29 14:06:24 +0200
message:
Move Relay classes into a separate file.
Implement all flash.geom classes and flash.display.BitmapData using either
a Relay or a simple as_object. Drop unnecessary types and all static
prototypes and constructors.
Passes in swfdec and actionscript.all testsuites.
added:
libcore/Relay.cpp
libcore/Relay.h
modified:
libcore/Bitmap.cpp
libcore/Bitmap.h
libcore/Makefile.am
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/as_object.cpp
libcore/as_object.h
libcore/asobj/Global_as.h
libcore/asobj/flash/display/BitmapData_as.cpp
libcore/asobj/flash/display/BitmapData_as.h
libcore/asobj/flash/display/MovieClip_as.cpp
libcore/asobj/flash/filters/BitmapFilter_as.cpp
libcore/asobj/flash/filters/BitmapFilter_as.h
libcore/asobj/flash/geom/Matrix_as.cpp
libcore/asobj/flash/geom/Point_as.cpp
libcore/asobj/flash/geom/Point_as.h
libcore/asobj/flash/geom/Rectangle_as.cpp
libcore/asobj/flash/geom/Transform_as.cpp
libcore/asobj/flash/geom/geom_pkg.cpp
libcore/asobj/flash/geom/geom_pkg.h
libcore/asobj/flash/net/FileReferenceList_as.cpp
libcore/parser/AbcBlock.cpp
testsuite/actionscript.all/Transform.as
testsuite/swfdec/PASSING
=== modified file 'libcore/Bitmap.cpp'
--- a/libcore/Bitmap.cpp 2009-07-14 06:01:56 +0000
+++ b/libcore/Bitmap.cpp 2009-09-29 12:06:24 +0000
@@ -28,7 +28,7 @@
namespace gnash {
-Bitmap::Bitmap(boost::intrusive_ptr<BitmapData_as> bd, DisplayObject* parent,
+Bitmap::Bitmap(BitmapData_as* bd, DisplayObject* parent,
int id)
:
DisplayObject(parent, id),
@@ -45,6 +45,7 @@
:
DisplayObject(parent, id),
_def(def),
+ _bitmapData(0),
_bitmapInfo(0),
_width(twipsToPixels(def->get_frame_size().width())),
_height(twipsToPixels(def->get_frame_size().height()))
=== modified file 'libcore/Bitmap.h'
--- a/libcore/Bitmap.h 2009-07-13 07:07:26 +0000
+++ b/libcore/Bitmap.h 2009-09-29 11:09:52 +0000
@@ -45,7 +45,7 @@
{
public:
- Bitmap(boost::intrusive_ptr<BitmapData_as> bd, DisplayObject* parent,
+ Bitmap(BitmapData_as* bd, DisplayObject* parent,
int id);
Bitmap(const BitmapMovieDefinition* const def, DisplayObject* parent,
@@ -101,7 +101,7 @@
const boost::intrusive_ptr<const BitmapMovieDefinition> _def;
- boost::intrusive_ptr<BitmapData_as> _bitmapData;
+ BitmapData_as* _bitmapData;
/// The current bitmap information is stored here.
boost::intrusive_ptr<BitmapInfo> _bitmapInfo;
=== modified file 'libcore/Makefile.am'
--- a/libcore/Makefile.am 2009-09-09 19:50:57 +0000
+++ b/libcore/Makefile.am 2009-09-29 08:44:54 +0000
@@ -59,6 +59,7 @@
ClassHierarchy.cpp \
as_environment.cpp \
as_function.cpp \
+ Relay.cpp \
as_object.cpp \
as_value.cpp \
DisplayObjectContainer.cpp \
@@ -216,6 +217,7 @@
endif
EXTENSIONS_API = \
+ Relay.h \
as_object.h \
Property.h \
PropertyList.h \
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp 2009-08-27 15:17:51 +0000
+++ b/libcore/MovieClip.cpp 2009-09-29 11:09:52 +0000
@@ -1397,7 +1397,7 @@
}
void
-MovieClip::attachBitmap(boost::intrusive_ptr<BitmapData_as> bd, int depth)
+MovieClip::attachBitmap(BitmapData_as* bd, int depth)
{
DisplayObject* ch = new Bitmap(bd, this, 0);
attachCharacter(*ch, depth, 0);
=== modified file 'libcore/MovieClip.h'
--- a/libcore/MovieClip.h 2009-08-27 15:17:51 +0000
+++ b/libcore/MovieClip.h 2009-09-29 11:09:52 +0000
@@ -648,7 +648,7 @@
void removeMovieClip();
/// Create a Bitmap DisplayObject at the specified depth.
- void attachBitmap(boost::intrusive_ptr<BitmapData_as> bd, int depth);
+ void attachBitmap(BitmapData_as* bd, int depth);
/// Render this MovieClip to a GnashImage using the passed transform
//
=== added file 'libcore/Relay.cpp'
--- a/libcore/Relay.cpp 1970-01-01 00:00:00 +0000
+++ b/libcore/Relay.cpp 2009-09-29 08:45:42 +0000
@@ -0,0 +1,39 @@
+//
+// Copyright (C) 2005, 2006, 2007, 2008, 2009 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 3 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
+
+#include "movie_root.h"
+#include "as_object.h"
+#include "Relay.h"
+
+namespace gnash {
+
+
+/// Destructor of ActiveRelay needs definition of movie_root.
+ActiveRelay::~ActiveRelay()
+{
+ getRoot(*_owner).removeAdvanceCallback(this);
+}
+
+
+void
+ActiveRelay::setReachable()
+{
+ markReachableResources();
+ _owner->setReachable();
+}
+
+}
=== added file 'libcore/Relay.h'
--- a/libcore/Relay.h 1970-01-01 00:00:00 +0000
+++ b/libcore/Relay.h 2009-09-29 08:44:29 +0000
@@ -0,0 +1,89 @@
+//
+// Copyright (C) 2005, 2006, 2007, 2008, 2009 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 3 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_RELAY_H
+#define GNASH_RELAY_H
+
+namespace gnash {
+ class as_object;
+}
+
+namespace gnash {
+
+/// This is the base class for type-specific object data.
+//
+/// ActionScript classes with particular type restrictions or type traits
+/// should set the Object's _relay member to a subclass of this class.
+//
+/// The simplest native types, such as Boolean or String, inherit from this
+/// type.
+class Relay
+{
+public:
+ virtual ~Relay() {};
+
+ /// A Relay itself is not a GC object, but may point to GC resources.
+ virtual void setReachable() {}
+};
+
+
+/// A type that requires periodic updates from the core (movie_root).
+//
+/// Objects with this type of relay can be registered with movie_root, and
+/// recieve a callback on every advance.
+//
+/// This type of Proxy holds a reference to its parent as_object (owner).
+/// If a reference to this ActiveRelay is held by another object,
+/// it must be marked reachable so that its owner is not deleted by the GC.
+class ActiveRelay : public Relay
+{
+public:
+ ActiveRelay(as_object* owner)
+ :
+ _owner(owner)
+ {}
+
+ /// Make sure we are removed from the list of callbacks on destruction.
+ virtual ~ActiveRelay();
+
+ /// ActiveRelay objects must have an advanceState method.
+ virtual void update() = 0;
+
+ /// Mark any other reachable resources, and finally mark our owner
+ virtual void setReachable();
+
+ as_object& owner() const {
+ return *_owner;
+ }
+
+protected:
+
+ virtual void markReachableResources() const {}
+
+private:
+
+ /// The as_object that owns this Proxy.
+ //
+ /// Because we are deleted on destruction of the owner, this pointer will
+ /// never be invalid as long as 'this' is valid.
+ as_object* _owner;
+
+};
+
+} // namespace gnash
+
+#endif
=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp 2009-08-21 07:28:09 +0000
+++ b/libcore/as_object.cpp 2009-09-29 08:44:54 +0000
@@ -213,12 +213,6 @@
} // end of anonymous namespace
-/// Destructor of ActiveRelay needs definition of movie_root.
-ActiveRelay::~ActiveRelay()
-{
- getRoot(*_owner).removeAdvanceCallback(this);
-}
-
const int as_object::DefaultFlags;
=== modified file 'libcore/as_object.h'
--- a/libcore/as_object.h 2009-08-26 08:47:23 +0000
+++ b/libcore/as_object.h 2009-09-29 08:44:54 +0000
@@ -31,6 +31,7 @@
#include "smart_ptr.h"
#include "PropFlags.h" // for enum
#include "GnashException.h"
+#include "Relay.h"
#include <cmath>
#include <utility> // for std::pair
@@ -152,23 +153,6 @@
};
-/// This is the base class for type-specific object data.
-//
-/// ActionScript classes with particular type restrictions or type traits
-/// should set the Object's _relay member to a subclass of this class.
-//
-/// The simplest native types, such as Boolean or String, inherit from this
-/// type.
-class Relay
-{
-public:
- virtual ~Relay() {};
-
- /// A Relay itself is not a GC object, but may point to GC resources.
- virtual void setReachable() {}
-};
-
-
/// \brief
/// A generic bag of attributes. Base class for all ActionScript-able objects.
@@ -1174,51 +1158,6 @@
return o.ns;
}
-/// A type that requires periodic updates from the core (movie_root).
-//
-/// Objects with this type of relay can be registered with movie_root, and
-/// recieve a callback on every advance.
-//
-/// This type of Proxy holds a reference to its parent as_object (owner).
-/// If a reference to this ActiveRelay is held by another object,
-/// it must be marked reachable so that its owner is not deleted by the GC.
-class ActiveRelay : public Relay
-{
-public:
- ActiveRelay(as_object* owner)
- :
- _owner(owner)
- {}
-
- /// Make sure we are removed from the list of callbacks on destruction.
- virtual ~ActiveRelay();
-
- /// ActiveRelay objects must have an advanceState method.
- virtual void update() = 0;
-
- /// Mark any other reachable resources, and finally mark our owner
- virtual void setReachable() {
- markReachableResources();
- _owner->setReachable();
- }
-
- as_object& owner() const {
- return *_owner;
- }
-
-protected:
-
- virtual void markReachableResources() const {}
-
-private:
-
- /// The as_object that owns this Proxy.
- //
- /// Because we are deleted on destruction of the owner, this pointer will
- /// never be invalid.
- as_object* _owner;
-
-};
/// Template which does a dynamic cast for as_object pointers.
//
=== modified file 'libcore/asobj/Global_as.h'
--- a/libcore/asobj/Global_as.h 2009-08-27 06:30:05 +0000
+++ b/libcore/asobj/Global_as.h 2009-09-29 09:56:55 +0000
@@ -21,6 +21,7 @@
#include "as_object.h" // for inheritance
#include "Object.h"
+#include "fn_call.h"
// Forward declarations
namespace gnash {
@@ -28,7 +29,6 @@
class Machine;
class as_value;
class VM;
- class fn_call;
class ClassHierarchy;
}
@@ -47,6 +47,7 @@
public:
typedef as_value(*ASFunction)(const fn_call& fn);
+ typedef void(*Properties)(as_object&);
virtual const ClassHierarchy& classHierarchy() const = 0;
virtual ClassHierarchy& classHierarchy() = 0;
@@ -101,7 +102,6 @@
virtual VM& getVM() const = 0;
};
-typedef void(*Properties)(as_object&);
/// Register a built-in object
//
@@ -120,7 +120,8 @@
/// created object.
/// @return the built-in object with properties attached.
inline as_object*
-registerBuiltinObject(as_object& where, Properties p, const ObjectURI& uri)
+registerBuiltinObject(as_object& where, Global_as::Properties p,
+ const ObjectURI& uri)
{
// This is going to be the global Mouse "class"/"function"
@@ -153,7 +154,7 @@
/// @return the built-in class with prototype and properties attached.
inline as_object*
registerBuiltinClass(as_object& where, Global_as::ASFunction ctor,
- Properties p, Properties c, const ObjectURI& uri)
+ Global_as::Properties p, Global_as::Properties c, const ObjectURI& uri)
{
Global_as* gl = getGlobal(where);
as_object* proto = gl->createObject();
@@ -171,6 +172,17 @@
return cl;
}
+
+/// Convenience function for finding a class constructor.
+//
+/// Only currently useful in AS2.
+inline as_function*
+getClassConstructor(const fn_call& fn, const std::string& s)
+{
+ const as_value ctor(fn.env().find_object(s));
+ return ctor.to_as_function();
+}
+
} // namespace gnash
#endif
=== modified file 'libcore/asobj/flash/display/BitmapData_as.cpp'
--- a/libcore/asobj/flash/display/BitmapData_as.cpp 2009-08-20 06:55:15
+0000
+++ b/libcore/asobj/flash/display/BitmapData_as.cpp 2009-09-29 11:09:52
+0000
@@ -44,48 +44,47 @@
namespace {
- as_value BitmapData_applyFilter(const fn_call& fn);
- as_value BitmapData_clone(const fn_call& fn);
- as_value BitmapData_colorTransform(const fn_call& fn);
- as_value BitmapData_copyChannel(const fn_call& fn);
- as_value BitmapData_copyPixels(const fn_call& fn);
- as_value BitmapData_dispose(const fn_call& fn);
- as_value BitmapData_draw(const fn_call& fn);
- as_value BitmapData_fillRect(const fn_call& fn);
- as_value BitmapData_floodFill(const fn_call& fn);
- as_value BitmapData_generateFilterRect(const fn_call& fn);
- as_value BitmapData_getColorBoundsRect(const fn_call& fn);
- as_value BitmapData_getPixel(const fn_call& fn);
- as_value BitmapData_getPixel32(const fn_call& fn);
- as_value BitmapData_hitTest(const fn_call& fn);
- as_value BitmapData_merge(const fn_call& fn);
- as_value BitmapData_noise(const fn_call& fn);
- as_value BitmapData_paletteMap(const fn_call& fn);
- as_value BitmapData_perlinNoise(const fn_call& fn);
- as_value BitmapData_pixelDissolve(const fn_call& fn);
- as_value BitmapData_scroll(const fn_call& fn);
- as_value BitmapData_setPixel(const fn_call& fn);
- as_value BitmapData_setPixel32(const fn_call& fn);
- as_value BitmapData_threshold(const fn_call& fn);
- as_value BitmapData_height(const fn_call& fn);
- as_value BitmapData_rectangle(const fn_call& fn);
- as_value BitmapData_transparent(const fn_call& fn);
- as_value BitmapData_width(const fn_call& fn);
- as_value BitmapData_loadBitmap(const fn_call& fn);
- as_value BitmapData_ctor(const fn_call& fn);
+ as_value bitmapdata_applyFilter(const fn_call& fn);
+ as_value bitmapdata_clone(const fn_call& fn);
+ as_value bitmapdata_colorTransform(const fn_call& fn);
+ as_value bitmapdata_copyChannel(const fn_call& fn);
+ as_value bitmapdata_copyPixels(const fn_call& fn);
+ as_value bitmapdata_dispose(const fn_call& fn);
+ as_value bitmapdata_draw(const fn_call& fn);
+ as_value bitmapdata_fillRect(const fn_call& fn);
+ as_value bitmapdata_floodFill(const fn_call& fn);
+ as_value bitmapdata_generateFilterRect(const fn_call& fn);
+ as_value bitmapdata_getColorBoundsRect(const fn_call& fn);
+ as_value bitmapdata_getPixel(const fn_call& fn);
+ as_value bitmapdata_getPixel32(const fn_call& fn);
+ as_value bitmapdata_hitTest(const fn_call& fn);
+ as_value bitmapdata_merge(const fn_call& fn);
+ as_value bitmapdata_noise(const fn_call& fn);
+ as_value bitmapdata_paletteMap(const fn_call& fn);
+ as_value bitmapdata_perlinNoise(const fn_call& fn);
+ as_value bitmapdata_pixelDissolve(const fn_call& fn);
+ as_value bitmapdata_scroll(const fn_call& fn);
+ as_value bitmapdata_setPixel(const fn_call& fn);
+ as_value bitmapdata_setPixel32(const fn_call& fn);
+ as_value bitmapdata_threshold(const fn_call& fn);
+ as_value bitmapdata_height(const fn_call& fn);
+ as_value bitmapdata_rectangle(const fn_call& fn);
+ as_value bitmapdata_transparent(const fn_call& fn);
+ as_value bitmapdata_width(const fn_call& fn);
+ as_value bitmapdata_loadBitmap(const fn_call& fn);
+ as_value bitmapdata_ctor(const fn_call& fn);
void attachBitmapDataInterface(as_object& o);
void attachBitmapDataStaticProperties(as_object& o);
- as_object* getBitmapDataInterface();
as_value get_flash_display_bitmap_data_constructor(const fn_call& fn);
}
-BitmapData_as::BitmapData_as(size_t width, size_t height,
- bool transparent, boost::uint32_t fillColor)
- :
- as_object(getBitmapDataInterface()),
+BitmapData_as::BitmapData_as(as_object* owner, size_t width, size_t height,
+ bool transparent, boost::uint32_t fillColor)
+ :
+ _owner(owner),
_width(width),
_height(height),
_transparent(transparent),
@@ -94,11 +93,11 @@
}
void
-BitmapData_as::markReachableResources() const
+BitmapData_as::setReachable()
{
std::for_each(_attachedBitmaps.begin(), _attachedBitmaps.end(),
std::mem_fun(&DisplayObject::setReachable));
- markAsObjectReachable();
+ _owner->setReachable();
}
@@ -239,67 +238,64 @@
namespace {
as_value
-BitmapData_applyFilter(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_clone(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_colorTransform(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_copyChannel(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_copyPixels(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_dispose(const fn_call& fn)
+bitmapdata_applyFilter(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_clone(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_colorTransform(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_copyChannel(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_copyPixels(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_dispose(const fn_call& fn)
{
// Should free the memory storing the bitmap.
// All properties afterwards are -1 (even the rectangle)
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
ptr->dispose();
return as_value();
}
as_value
-BitmapData_draw(const fn_call& fn)
+bitmapdata_draw(const fn_call& fn)
{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
std::ostringstream os;
fn.dump_args(os);
@@ -339,10 +335,9 @@
}
as_value
-BitmapData_fillRect(const fn_call& fn)
+bitmapdata_fillRect(const fn_call& fn)
{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
if (fn.nargs < 2) return as_value();
@@ -381,37 +376,36 @@
// Fills the bitmap with a colour starting at point x, y.
as_value
-BitmapData_floodFill(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_generateFilterRect(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_getColorBoundsRect(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_getPixel(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+bitmapdata_floodFill(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_generateFilterRect(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_getColorBoundsRect(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_getPixel(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
if (fn.nargs < 2)
{
@@ -427,10 +421,9 @@
}
as_value
-BitmapData_getPixel32(const fn_call& fn)
+bitmapdata_getPixel32(const fn_call& fn)
{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
if (fn.nargs < 2)
{
@@ -447,73 +440,72 @@
as_value
-BitmapData_hitTest(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_merge(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_noise(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_paletteMap(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_perlinNoise(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_pixelDissolve(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_scroll(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-BitmapData_setPixel(const fn_call& fn)
-{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+bitmapdata_hitTest(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_merge(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_noise(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_paletteMap(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_perlinNoise(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_pixelDissolve(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_scroll(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
+ UNUSED(ptr);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+bitmapdata_setPixel(const fn_call& fn)
+{
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
if (fn.nargs < 3) {
return as_value();
@@ -535,10 +527,9 @@
}
as_value
-BitmapData_setPixel32(const fn_call& fn)
+bitmapdata_setPixel32(const fn_call& fn)
{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
if (fn.nargs < 3) {
return as_value();
@@ -560,20 +551,18 @@
}
as_value
-BitmapData_threshold(const fn_call& fn)
+bitmapdata_threshold(const fn_call& fn)
{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
as_value
-BitmapData_height(const fn_call& fn)
+bitmapdata_height(const fn_call& fn)
{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
// Read-only
if (fn.nargs) return as_value();
@@ -585,10 +574,9 @@
}
as_value
-BitmapData_rectangle(const fn_call& fn)
+bitmapdata_rectangle(const fn_call& fn)
{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
// Returns the immutable rectangle of the bitmap or -1 if dispose()
// has been called.
@@ -613,10 +601,9 @@
}
as_value
-BitmapData_transparent(const fn_call& fn)
+bitmapdata_transparent(const fn_call& fn)
{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
// Read-only
if (fn.nargs) return as_value();
@@ -627,10 +614,9 @@
}
as_value
-BitmapData_width(const fn_call& fn)
+bitmapdata_width(const fn_call& fn)
{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
// Read-only
if (fn.nargs) return as_value();
@@ -643,10 +629,9 @@
as_value
-BitmapData_loadBitmap(const fn_call& fn)
+bitmapdata_loadBitmap(const fn_call& fn)
{
- boost::intrusive_ptr<BitmapData_as> ptr =
- ensureType<BitmapData_as>(fn.this_ptr);
+ BitmapData_as* ptr = ensureNativeType<BitmapData_as>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
@@ -658,16 +643,17 @@
{
log_debug("Loading flash.display.BitmapData class");
Global_as* gl = getGlobal(fn);
- as_object* proto = getBitmapDataInterface();
- as_object* cl = gl->createClass(&BitmapData_ctor, proto);
+ as_object* proto = gl->createObject();
+ attachBitmapDataInterface(*proto);
+ as_object* cl = gl->createClass(&bitmapdata_ctor, proto);
attachBitmapDataStaticProperties(*cl);
return cl;
}
as_value
-BitmapData_ctor(const fn_call& fn)
+bitmapdata_ctor(const fn_call& fn)
{
-
+ as_object* ptr = ensureType<as_object>(fn.this_ptr).get();
if (fn.nargs < 2) {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("BitmapData constructor requires at least two "
@@ -704,48 +690,48 @@
throw ActionTypeError();
}
- boost::intrusive_ptr<BitmapData_as> obj =
- new BitmapData_as(width, height, transparent, fillColor);
+ ptr->setRelay(
+ new BitmapData_as(ptr, width, height, transparent, fillColor));
- return as_value(obj.get()); // will keep alive
+ return as_value();
}
void
attachBitmapDataInterface(as_object& o)
{
Global_as* gl = getGlobal(o);
- o.init_member("applyFilter", gl->createFunction(BitmapData_applyFilter));
- o.init_member("clone", gl->createFunction(BitmapData_clone));
+ o.init_member("applyFilter", gl->createFunction(bitmapdata_applyFilter));
+ o.init_member("clone", gl->createFunction(bitmapdata_clone));
o.init_member("colorTransform", gl->createFunction(
- BitmapData_colorTransform));
- o.init_member("copyChannel", gl->createFunction(BitmapData_copyChannel));
- o.init_member("copyPixels", gl->createFunction(BitmapData_copyPixels));
- o.init_member("dispose", gl->createFunction(BitmapData_dispose));
- o.init_member("draw", gl->createFunction(BitmapData_draw));
- o.init_member("fillRect", gl->createFunction(BitmapData_fillRect));
- o.init_member("floodFill", gl->createFunction(BitmapData_floodFill));
+ bitmapdata_colorTransform));
+ o.init_member("copyChannel", gl->createFunction(bitmapdata_copyChannel));
+ o.init_member("copyPixels", gl->createFunction(bitmapdata_copyPixels));
+ o.init_member("dispose", gl->createFunction(bitmapdata_dispose));
+ o.init_member("draw", gl->createFunction(bitmapdata_draw));
+ o.init_member("fillRect", gl->createFunction(bitmapdata_fillRect));
+ o.init_member("floodFill", gl->createFunction(bitmapdata_floodFill));
o.init_member("generateFilterRect", gl->createFunction(
- BitmapData_generateFilterRect));
+ bitmapdata_generateFilterRect));
o.init_member("getColorBoundsRect", gl->createFunction(
- BitmapData_getColorBoundsRect));
- o.init_member("getPixel", gl->createFunction(BitmapData_getPixel));
- o.init_member("getPixel32", gl->createFunction(BitmapData_getPixel32));
- o.init_member("hitTest", gl->createFunction(BitmapData_hitTest));
- o.init_member("merge", gl->createFunction(BitmapData_merge));
- o.init_member("noise", gl->createFunction(BitmapData_noise));
- o.init_member("paletteMap", gl->createFunction(BitmapData_paletteMap));
- o.init_member("perlinNoise", gl->createFunction(BitmapData_perlinNoise));
+ bitmapdata_getColorBoundsRect));
+ o.init_member("getPixel", gl->createFunction(bitmapdata_getPixel));
+ o.init_member("getPixel32", gl->createFunction(bitmapdata_getPixel32));
+ o.init_member("hitTest", gl->createFunction(bitmapdata_hitTest));
+ o.init_member("merge", gl->createFunction(bitmapdata_merge));
+ o.init_member("noise", gl->createFunction(bitmapdata_noise));
+ o.init_member("paletteMap", gl->createFunction(bitmapdata_paletteMap));
+ o.init_member("perlinNoise", gl->createFunction(bitmapdata_perlinNoise));
o.init_member("pixelDissolve", gl->createFunction(
- BitmapData_pixelDissolve));
- o.init_member("scroll", gl->createFunction(BitmapData_scroll));
- o.init_member("setPixel", gl->createFunction(BitmapData_setPixel));
- o.init_member("setPixel32", gl->createFunction(BitmapData_setPixel32));
- o.init_member("threshold", gl->createFunction(BitmapData_threshold));
- o.init_property("height", BitmapData_height, BitmapData_height);
- o.init_property("rectangle", BitmapData_rectangle, BitmapData_rectangle);
- o.init_property("transparent", BitmapData_transparent,
- BitmapData_transparent);
- o.init_property("width", BitmapData_width, BitmapData_width);
+ bitmapdata_pixelDissolve));
+ o.init_member("scroll", gl->createFunction(bitmapdata_scroll));
+ o.init_member("setPixel", gl->createFunction(bitmapdata_setPixel));
+ o.init_member("setPixel32", gl->createFunction(bitmapdata_setPixel32));
+ o.init_member("threshold", gl->createFunction(bitmapdata_threshold));
+ o.init_property("height", bitmapdata_height, bitmapdata_height);
+ o.init_property("rectangle", bitmapdata_rectangle, bitmapdata_rectangle);
+ o.init_property("transparent", bitmapdata_transparent,
+ bitmapdata_transparent);
+ o.init_property("width", bitmapdata_width, bitmapdata_width);
}
@@ -753,22 +739,7 @@
attachBitmapDataStaticProperties(as_object& o)
{
Global_as* gl = getGlobal(o);
- o.init_member("loadBitmap", gl->createFunction(BitmapData_loadBitmap));
-}
-
-as_object*
-getBitmapDataInterface()
-{
- static boost::intrusive_ptr<as_object> o;
-
- if (!o) {
- o = new as_object(getObjectInterface());
- VM::get().addStatic(o.get());
-
- attachBitmapDataInterface(*o);
- }
-
- return o.get();
+ o.init_member("loadBitmap", gl->createFunction(bitmapdata_loadBitmap));
}
} // anonymous namespace
=== modified file 'libcore/asobj/flash/display/BitmapData_as.h'
--- a/libcore/asobj/flash/display/BitmapData_as.h 2009-07-28 11:58:27
+0000
+++ b/libcore/asobj/flash/display/BitmapData_as.h 2009-09-29 11:09:52
+0000
@@ -35,7 +35,7 @@
class Bitmap;
-class BitmapData_as: public as_object
+class BitmapData_as : public Relay
{
public:
@@ -45,7 +45,7 @@
// The constructor sets the fill colour and the
// immutable size of the bitmap, as well as whether
// it can handle transparency or not.
- BitmapData_as(size_t width, size_t height,
+ BitmapData_as(as_object* owner, size_t width, size_t height,
bool transparent, boost::uint32_t fillColor);
size_t getWidth() const { return _width; }
@@ -91,14 +91,16 @@
_attachedBitmaps.push_back(bitmap);
}
-protected:
-
- void markReachableResources() const;
+ /// Overrides Relay::setReachable().
+ virtual void setReachable();
private:
void updateAttachedBitmaps();
+ /// The object to which this native type class belongs to.
+ as_object* _owner;
+
// The width of the image, max 2880. This is immutable.
const size_t _width;
=== modified file 'libcore/asobj/flash/display/MovieClip_as.cpp'
--- a/libcore/asobj/flash/display/MovieClip_as.cpp 2009-08-27 15:41:32
+0000
+++ b/libcore/asobj/flash/display/MovieClip_as.cpp 2009-09-29 11:09:52
+0000
@@ -2506,9 +2506,9 @@
}
as_object* obj = fn.arg(0).to_object(*getGlobal(fn)).get();
- boost::intrusive_ptr<BitmapData_as> bd = dynamic_cast<BitmapData_as*>(obj);
+ BitmapData_as* bd;
- if (!bd) {
+ if (!isNativeType(obj, bd)) {
IF_VERBOSE_ASCODING_ERRORS(
log_debug("MovieClip.attachBitmap: first argument should be a "
"BitmapData", fn.arg(1));
=== modified file 'libcore/asobj/flash/filters/BitmapFilter_as.cpp'
--- a/libcore/asobj/flash/filters/BitmapFilter_as.cpp 2009-09-22 09:08:40
+0000
+++ b/libcore/asobj/flash/filters/BitmapFilter_as.cpp 2009-09-29 09:56:29
+0000
@@ -69,7 +69,7 @@
void
registerBitmapClass(as_object& where, Global_as::ASFunction ctor,
- Properties p, const ObjectURI& uri)
+ Global_as::Properties p, const ObjectURI& uri)
{
Global_as* gl = getGlobal(where);
=== modified file 'libcore/asobj/flash/filters/BitmapFilter_as.h'
--- a/libcore/asobj/flash/filters/BitmapFilter_as.h 2009-09-22 08:09:17
+0000
+++ b/libcore/asobj/flash/filters/BitmapFilter_as.h 2009-09-29 09:55:53
+0000
@@ -35,8 +35,13 @@
void registerBitmapFilterNative(as_object& global);
+
+/// Convenience function only for BitmapFilter subclasses.
+//
+/// This implements the AS code necessary for defining subclasses of
+/// BitmapFilter in AS2.
void registerBitmapClass(as_object& where, Global_as::ASFunction ctor,
- Properties p, const ObjectURI& uri);
+ Global_as::Properties p, const ObjectURI& uri);
} // end of gnash namespace
=== modified file 'libcore/asobj/flash/geom/Matrix_as.cpp'
--- a/libcore/asobj/flash/geom/Matrix_as.cpp 2009-08-20 06:55:15 +0000
+++ b/libcore/asobj/flash/geom/Matrix_as.cpp 2009-09-29 10:06:20 +0000
@@ -27,7 +27,6 @@
#include "GnashException.h" // for ActionException
#include "Object.h" // for AS inheritance
#include "VM.h"
-#include "Point_as.h"
#include <cmath>
#include <boost/numeric/ublas/matrix.hpp> // boost matrix
@@ -66,86 +65,82 @@
namespace gnash {
-typedef boost::numeric::ublas::c_matrix<double, 3, 3> MatrixType;
-typedef boost::numeric::ublas::c_vector<double, 2> PointType;
// Forward declarations
-static as_value Matrix_clone(const fn_call& fn);
-static as_value Matrix_concat(const fn_call& fn);
-static as_value Matrix_createBox(const fn_call& fn);
-static as_value Matrix_createGradientBox(const fn_call& fn);
-static as_value Matrix_deltaTransformPoint(const fn_call& fn);
-static as_value Matrix_identity(const fn_call& fn);
-static as_value Matrix_invert(const fn_call& fn);
-static as_value Matrix_rotate(const fn_call& fn);
-static as_value Matrix_scale(const fn_call& fn);
-static as_value Matrix_toString(const fn_call& fn);
-static as_value Matrix_transformPoint(const fn_call& fn);
-static as_value Matrix_translate(const fn_call& fn);
-static void fillMatrix(MatrixType& matrix, as_object& matrixObject);
-static PointType transformPoint(as_object* const pointObject, as_object* const
matrixObject);
-
-as_value Matrix_ctor(const fn_call& fn);
-
-static void
+namespace {
+
+ typedef boost::numeric::ublas::c_matrix<double, 3, 3> MatrixType;
+ typedef boost::numeric::ublas::c_vector<double, 2> PointType;
+
+ as_value matrix_clone(const fn_call& fn);
+ as_value matrix_concat(const fn_call& fn);
+ as_value matrix_createBox(const fn_call& fn);
+ as_value matrix_createGradientBox(const fn_call& fn);
+ as_value matrix_deltaTransformPoint(const fn_call& fn);
+ as_value matrix_identity(const fn_call& fn);
+ as_value matrix_invert(const fn_call& fn);
+ as_value matrix_rotate(const fn_call& fn);
+ as_value matrix_scale(const fn_call& fn);
+ as_value matrix_toString(const fn_call& fn);
+ as_value matrix_transformPoint(const fn_call& fn);
+ as_value matrix_translate(const fn_call& fn);
+ void fillMatrix(MatrixType& matrix, as_object& matrixObject);
+ PointType transformPoint(as_object* const pointObject,
+ as_object* const matrixObject);
+
+ as_value get_flash_geom_matrix_constructor(const fn_call& fn);
+ as_value matrix_ctor(const fn_call& fn);
+ as_object* instanceOfMatrix(const fn_call& fn);
+}
+
+void
+matrix_class_init(as_object& where, const ObjectURI& uri)
+{
+ // TODO: this may not be correct, but it should be enumerable.
+ const int flags = 0;
+ where.init_destructive_property(getName(uri),
+ get_flash_geom_matrix_constructor, flags, getNamespace(uri));
+}
+
+
+namespace {
+
+void
attachMatrixInterface(as_object& o)
{
int fl = 0;
Global_as* gl = getGlobal(o);
- o.init_member("clone", gl->createFunction(Matrix_clone), fl);
- o.init_member("concat", gl->createFunction(Matrix_concat), fl);
- o.init_member("createBox", gl->createFunction(Matrix_createBox), fl);
+ o.init_member("clone", gl->createFunction(matrix_clone), fl);
+ o.init_member("concat", gl->createFunction(matrix_concat), fl);
+ o.init_member("createBox", gl->createFunction(matrix_createBox), fl);
o.init_member("createGradientBox",
- gl->createFunction(Matrix_createGradientBox), fl);
+ gl->createFunction(matrix_createGradientBox), fl);
o.init_member("deltaTransformPoint",
- gl->createFunction(Matrix_deltaTransformPoint), fl);
- o.init_member("identity", gl->createFunction(Matrix_identity), fl);
- o.init_member("invert", gl->createFunction(Matrix_invert), fl);
- o.init_member("rotate", gl->createFunction(Matrix_rotate), fl);
- o.init_member("scale", gl->createFunction(Matrix_scale), fl);
- o.init_member("toString", gl->createFunction(Matrix_toString), fl);
+ gl->createFunction(matrix_deltaTransformPoint), fl);
+ o.init_member("identity", gl->createFunction(matrix_identity), fl);
+ o.init_member("invert", gl->createFunction(matrix_invert), fl);
+ o.init_member("rotate", gl->createFunction(matrix_rotate), fl);
+ o.init_member("scale", gl->createFunction(matrix_scale), fl);
+ o.init_member("toString", gl->createFunction(matrix_toString), fl);
o.init_member("transformPoint",
- gl->createFunction(Matrix_transformPoint), fl);
- o.init_member("translate", gl->createFunction(Matrix_translate), fl);
-}
-
-
-static as_object*
-getMatrixInterface()
-{
- static boost::intrusive_ptr<as_object> o;
-
- if ( ! o )
- {
- // Inherits from Object.
- o = new as_object(getObjectInterface());
- VM::get().addStatic(o.get());
-
- attachMatrixInterface(*o);
-
- }
-
- return o.get();
-}
-
-class Matrix_as: public as_object
-{
-
-public:
-
- Matrix_as()
- :
- as_object(getMatrixInterface())
- {
- }
-
-};
-
+ gl->createFunction(matrix_transformPoint), fl);
+ o.init_member("translate", gl->createFunction(matrix_translate), fl);
+}
+
+as_object*
+instanceOfMatrix(const fn_call& fn)
+{
+ boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+
+ as_function* ctor = getClassConstructor(fn, "flash.geom.Matrix");
+ if (obj->instanceOf(ctor)) return obj.get();
+ return 0;
+}
/// Return an exact copy of the matrix.
-static as_value
-Matrix_clone(const fn_call& fn)
+as_value
+matrix_clone(const fn_call& fn)
{
// It doesn't matter whether it is a matrix or not; a new Matrix
// is created using any Matrix properties the object may have.
@@ -159,20 +154,24 @@
ptr->get_member(NSV::PROP_TX, &tx);
ptr->get_member(NSV::PROP_TY, &ty);
- boost::intrusive_ptr<as_object> ret = new Matrix_as;
- ret->set_member(NSV::PROP_A, a);
- ret->set_member(NSV::PROP_B, b);
- ret->set_member(NSV::PROP_C, c);
- ret->set_member(NSV::PROP_D, d);
- ret->set_member(NSV::PROP_TX, tx);
- ret->set_member(NSV::PROP_TY, ty);
-
- return as_value(ret.get());
+ fn_call::Args args;
+ args += a, b, c, d, tx, ty;
+
+ as_value matrixClass(fn.env().find_object("flash.geom.Matrix"));
+
+ as_function* ctor = matrixClass.to_as_function();
+ if (!ctor) {
+ return as_value();
+ }
+
+ as_object* o = ctor->constructInstance(fn.env(), args).get();
+
+ return as_value(o);
}
// A full, normal concatenation, so use full 3x3 matrices.
-static as_value
-Matrix_concat(const fn_call& fn)
+as_value
+matrix_concat(const fn_call& fn)
{
// Doesn't have to be a Matrix.
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
@@ -239,8 +238,8 @@
/// The translation values can be any as_value; the others (because
mathematical
/// operations are applied to them), result in NaN if anything other than a
number
/// is passed, so we treat them as doubles from the beginning.
-static as_value
-Matrix_createBox(const fn_call& fn)
+as_value
+matrix_createBox(const fn_call& fn)
{
// Doesn't have to be a Matrix
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
@@ -298,17 +297,19 @@
// Like createBox, but with strange offsets applied.
-static as_value
-Matrix_createGradientBox(const fn_call& fn)
+as_value
+matrix_createGradientBox(const fn_call& fn)
{
- boost::intrusive_ptr<Matrix_as> ptr = ensureType<Matrix_as>(fn.this_ptr);
+ as_object* ptr = instanceOfMatrix(fn);
+ if (!ptr) return as_value();
if (fn.nargs < 2)
{
IF_VERBOSE_ASCODING_ERRORS(
std::ostringstream ss;
fn.dump_args(ss);
- log_aserror("Matrix.createGradientBox(%s): needs at least two
arguments", ss.str());
+ log_aserror("Matrix.createGradientBox(%s): needs at least "
+ "two arguments", ss.str());
);
return as_value();
}
@@ -371,8 +372,8 @@
/// elements (tx, ty) do not have any effect.
///
/// Returns a new Point, leaving the object passed untouched.
-static as_value
-Matrix_deltaTransformPoint(const fn_call& fn)
+as_value
+matrix_deltaTransformPoint(const fn_call& fn)
{
// Doesn't have to be a Matrix
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
@@ -434,8 +435,8 @@
/// | 0 1 0 |
///(| 0 0 1 |)
/// Returns void.
-static as_value
-Matrix_identity(const fn_call& fn)
+as_value
+matrix_identity(const fn_call& fn)
{
// Doesn't have to be a Matrix
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
@@ -451,14 +452,14 @@
}
-static inline double
+inline double
getMinorDeterminant(const MatrixType& m)
{
return m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0);
}
-static as_value
-Matrix_invert(const fn_call& fn)
+as_value
+matrix_invert(const fn_call& fn)
{
// Doesn't have to be a Matrix
@@ -505,11 +506,12 @@
}
-static as_value
-Matrix_rotate(const fn_call& fn)
+as_value
+matrix_rotate(const fn_call& fn)
{
// Apparently has to be a Matrix.
- boost::intrusive_ptr<Matrix_as> ptr = ensureType<Matrix_as>(fn.this_ptr);
+ as_object* ptr = instanceOfMatrix(fn);
+ if (!ptr) return as_value();
if (fn.nargs < 1)
{
@@ -578,11 +580,12 @@
return as_value();
}
-static as_value
-Matrix_scale(const fn_call& fn)
+as_value
+matrix_scale(const fn_call& fn)
{
// Apparently does have to be a Matrix.
- boost::intrusive_ptr<Matrix_as> ptr = ensureType<Matrix_as>(fn.this_ptr);
+ as_object* ptr = instanceOfMatrix(fn);
+ if (!ptr) return as_value();
if (fn.nargs < 2)
{
@@ -646,8 +649,8 @@
return as_value();
}
-static as_value
-Matrix_toString(const fn_call& fn)
+as_value
+matrix_toString(const fn_call& fn)
{
// Doesn't have to be a Matrix
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
@@ -675,8 +678,8 @@
return as_value(ss.str());
}
-static as_value
-Matrix_transformPoint(const fn_call& fn)
+as_value
+matrix_transformPoint(const fn_call& fn)
{
// Doesn't have to be a Matrix
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
@@ -706,7 +709,7 @@
as_object* obj = arg.to_object(*getGlobal(fn)).get();
assert(obj);
- if (!obj->instanceOf(getFlashGeomPointConstructor(fn))) {
+ if (!obj->instanceOf(getClassConstructor(fn, "flash.geom.Point"))) {
/// Isn't a point.
IF_VERBOSE_ASCODING_ERRORS(
std::ostringstream ss;
@@ -741,8 +744,8 @@
return as_value(ret);
}
-static as_value
-Matrix_translate(const fn_call& fn)
+as_value
+matrix_translate(const fn_call& fn)
{
// Doesn't have to be a Matrix
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
@@ -778,7 +781,7 @@
// after which the translation can be applied if necessary
// (transformPoint) or not if not (deltaTransformPoint). Just
// make sure the objects are what they're supposed to be.
-static PointType
+PointType
transformPoint(as_object* const pointObject, as_object* const matrixObject)
{
// Get the point co-ordinates.
@@ -824,7 +827,7 @@
}
// A helper function to create a boost matrix from a Matrix object
-static void fillMatrix(MatrixType& matrix,
+void fillMatrix(MatrixType& matrix,
as_object& matrixObject)
{
@@ -860,9 +863,9 @@
// If at least one argument is passed, any missing arguments are undefined.
// Extra arguments are discarded
as_value
-Matrix_ctor(const fn_call& fn)
+matrix_ctor(const fn_call& fn)
{
- boost::intrusive_ptr<as_object> obj = new Matrix_as;
+ boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
as_value a, b, c, d, tx, ty;
@@ -909,26 +912,19 @@
obj->set_member(NSV::PROP_B, b);
obj->set_member(NSV::PROP_A, a);
- return as_value(obj.get()); // will keep alive
+ return as_value();
}
-static as_value
+as_value
get_flash_geom_matrix_constructor(const fn_call& fn)
{
log_debug("Loading flash.geom.Matrix class");
- as_object* proto = getMatrixInterface();
Global_as* gl = getGlobal(fn);
- return gl->createClass(&Matrix_ctor, proto);
-}
-
-// extern
-void matrix_class_init(as_object& where, const ObjectURI& uri)
-{
- // TODO: this may not be correct, but it should be enumerable.
- const int flags = 0;
- where.init_destructive_property(getName(uri),
- get_flash_geom_matrix_constructor, flags, getNamespace(uri));
-}
-
+ as_object* proto = gl->createObject();
+ attachMatrixInterface(*proto);
+ return gl->createClass(&matrix_ctor, proto);
+}
+
+} // anonymous namespace
} // end of gnash namespace
=== modified file 'libcore/asobj/flash/geom/Point_as.cpp'
--- a/libcore/asobj/flash/geom/Point_as.cpp 2009-07-29 05:56:36 +0000
+++ b/libcore/asobj/flash/geom/Point_as.cpp 2009-09-29 10:06:30 +0000
@@ -33,79 +33,76 @@
namespace gnash {
-static as_value Point_add(const fn_call& fn);
-static as_value Point_clone(const fn_call& fn);
-static as_value Point_equals(const fn_call& fn);
-static as_value Point_normalize(const fn_call& fn);
-static as_value Point_offset(const fn_call& fn);
-static as_value Point_subtract(const fn_call& fn);
-static as_value Point_toString(const fn_call& fn);
-static as_value Point_length_getset(const fn_call& fn);
-
-static as_value Point_distance(const fn_call& fn);
-static as_value Point_interpolate(const fn_call& fn);
-static as_value Point_polar(const fn_call& fn);
-
-as_value Point_ctor(const fn_call& fn);
-
-static void
+namespace {
+
+ as_value point_add(const fn_call& fn);
+ as_value point_clone(const fn_call& fn);
+ as_value point_equals(const fn_call& fn);
+ as_value point_normalize(const fn_call& fn);
+ as_value point_offset(const fn_call& fn);
+ as_value point_subtract(const fn_call& fn);
+ as_value point_toString(const fn_call& fn);
+ as_value point_length(const fn_call& fn);
+ as_value point_distance(const fn_call& fn);
+ as_value point_interpolate(const fn_call& fn);
+ as_value point_polar(const fn_call& fn);
+ as_value point_ctor(const fn_call& fn);
+
+ as_value get_flash_geom_point_constructor(const fn_call& fn);
+
+}
+
+void
+point_class_init(as_object& where, const ObjectURI& uri)
+{
+ // TODO: this may not be correct, but it should be enumerable.
+ const int flags = 0;
+ where.init_destructive_property(getName(uri),
+ get_flash_geom_point_constructor, flags, getNamespace(uri));
+}
+
+namespace {
+
+as_value
+constructPoint(const fn_call& fn, const as_value& x, const as_value& y)
+{
+ as_function* ctor = getClassConstructor(fn, "flash.geom.Point");
+ if (!ctor) return as_value();
+
+ fn_call::Args args;
+ args += x, y;
+
+ return ctor->constructInstance(fn.env(), args).get();
+}
+
+void
attachPointInterface(as_object& o)
{
- int fl=0; // flags...
+ const int fl = 0;
Global_as* gl = getGlobal(o);
- o.init_member("add", gl->createFunction(Point_add), fl);
- o.init_member("clone", gl->createFunction(Point_clone), fl);
- o.init_member("equals", gl->createFunction(Point_equals), fl);
- o.init_member("normalize", gl->createFunction(Point_normalize), fl);
- o.init_member("offset", gl->createFunction(Point_offset), fl);
- o.init_member("subtract", gl->createFunction(Point_subtract), fl);
- o.init_member("toString", gl->createFunction(Point_toString), fl);
- o.init_property("length", Point_length_getset, Point_length_getset, fl);
+ o.init_member("add", gl->createFunction(point_add), fl);
+ o.init_member("clone", gl->createFunction(point_clone), fl);
+ o.init_member("equals", gl->createFunction(point_equals), fl);
+ o.init_member("normalize", gl->createFunction(point_normalize), fl);
+ o.init_member("offset", gl->createFunction(point_offset), fl);
+ o.init_member("subtract", gl->createFunction(point_subtract), fl);
+ o.init_member("toString", gl->createFunction(point_toString), fl);
+ o.init_property("length", point_length, point_length, fl);
}
-static void
+void
attachPointStaticProperties(as_object& o)
{
Global_as* gl = getGlobal(o);
- o.init_member("distance", gl->createFunction(Point_distance), 0);
- o.init_member("interpolate", gl->createFunction(Point_interpolate), 0);
- o.init_member("polar", gl->createFunction(Point_polar), 0);
-}
-
-static as_object*
-getPointInterface()
-{
- static boost::intrusive_ptr<as_object> o;
-
- if ( ! o )
- {
- // TODO: check if this class should inherit from Object
- // or from a different class
- o = new as_object(getObjectInterface());
- VM::get().addStatic(o.get());
-
- attachPointInterface(*o);
-
- }
-
- return o.get();
-}
-
-
-class Point_as: public as_object
-{
-public:
- Point_as()
- :
- as_object(getPointInterface())
- {}
-
-};
-
-
-static as_value
-Point_add(const fn_call& fn)
+ o.init_member("distance", gl->createFunction(point_distance), 0);
+ o.init_member("interpolate", gl->createFunction(point_interpolate), 0);
+ o.init_member("polar", gl->createFunction(point_polar), 0);
+}
+
+
+as_value
+point_add(const fn_call& fn)
{
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
@@ -163,15 +160,11 @@
x.newAdd(x1);
y.newAdd(y1);
- boost::intrusive_ptr<as_object> ret = new Point_as;
- ret->set_member(NSV::PROP_X, x);
- ret->set_member(NSV::PROP_Y, y);
-
- return as_value(ret.get());
+ return constructPoint(fn, x, y);
}
-static as_value
-Point_clone(const fn_call& fn)
+as_value
+point_clone(const fn_call& fn)
{
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
@@ -179,15 +172,11 @@
ptr->get_member(NSV::PROP_X, &x);
ptr->get_member(NSV::PROP_Y, &y);
- boost::intrusive_ptr<as_object> ret = new Point_as;
- ret->set_member(NSV::PROP_X, x);
- ret->set_member(NSV::PROP_Y, y);
-
- return as_value(ret.get());
+ return constructPoint(fn, x, y);
}
-static as_value
-Point_equals(const fn_call& fn)
+as_value
+point_equals(const fn_call& fn)
{
boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
@@ -211,7 +200,7 @@
}
as_object* o = arg1.to_object(*getGlobal(fn)).get();
assert(o);
- if ( ! o->instanceOf(getFlashGeomPointConstructor(fn)) )
+ if (!o->instanceOf(getClassConstructor(fn, "flash.geom.Point")))
{
IF_VERBOSE_ASCODING_ERRORS(
std::stringstream ss; fn.dump_args(ss);
@@ -232,10 +221,10 @@
return as_value(x.equals(x1) && y.equals(y1));
}
-static as_value
-Point_normalize(const fn_call& fn)
+as_value
+point_normalize(const fn_call& fn)
{
- boost::intrusive_ptr<Point_as> ptr = ensureType<Point_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
as_value argval;
@@ -286,10 +275,10 @@
return as_value();
}
-static as_value
-Point_offset(const fn_call& fn)
+as_value
+point_offset(const fn_call& fn)
{
- boost::intrusive_ptr<Point_as> ptr = ensureType<Point_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
as_value x, y;
ptr->get_member(NSV::PROP_X, &x);
@@ -311,10 +300,10 @@
return as_value();
}
-static as_value
-Point_subtract(const fn_call& fn)
+as_value
+point_subtract(const fn_call& fn)
{
- boost::intrusive_ptr<Point_as> ptr = ensureType<Point_as>(fn.this_ptr);
+ as_object* ptr = ensureType<as_object>(fn.this_ptr).get();
as_value x, y;
ptr->get_member(NSV::PROP_X, &x);
@@ -370,17 +359,13 @@
x.set_double(x.to_number() - x1.to_number());
y.set_double(y.to_number() - y1.to_number());
- boost::intrusive_ptr<as_object> ret = new Point_as;
- ret->set_member(NSV::PROP_X, x);
- ret->set_member(NSV::PROP_Y, y);
-
- return as_value(ret.get());
+ return constructPoint(fn, x, y);
}
-static as_value
-Point_toString(const fn_call& fn)
+as_value
+point_toString(const fn_call& fn)
{
- boost::intrusive_ptr<Point_as> ptr = ensureType<Point_as>(fn.this_ptr);
+ as_object* ptr = ensureType<as_object>(fn.this_ptr).get();
as_value x, y;
ptr->get_member(NSV::PROP_X, &x);
@@ -396,10 +381,10 @@
return as_value(ss.str());
}
-static as_value
-Point_length_getset(const fn_call& fn)
+as_value
+point_length(const fn_call& fn)
{
- boost::intrusive_ptr<Point_as> ptr = ensureType<Point_as>(fn.this_ptr);
+ as_object* ptr = ensureType<as_object>(fn.this_ptr).get();
if ( ! fn.nargs ) // getter
{
@@ -412,18 +397,19 @@
double l = std::sqrt(x*x+y*y);
return as_value(l);
}
- else // setter
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Attempt to set read-only property %s"), "Point.length");
- );
- return as_value();
- }
+
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("Attempt to set read-only property %s"), "Point.length");
+ );
+ return as_value();
}
-static as_value
-Point_distance(const fn_call& fn)
+
+/// Static member function.
+as_value
+point_distance(const fn_call& fn)
{
+
if ( fn.nargs < 2 )
{
IF_VERBOSE_ASCODING_ERRORS(
@@ -452,7 +438,7 @@
}
as_object* o1 = arg1.to_object(*getGlobal(fn)).get();
assert(o1);
- if ( ! o1->instanceOf(getFlashGeomPointConstructor(fn)) )
+ if (!o1->instanceOf(getClassConstructor(fn, "flash.geom.Point")))
{
IF_VERBOSE_ASCODING_ERRORS(
std::stringstream ss; fn.dump_args(ss);
@@ -495,8 +481,8 @@
return as_value(dist);
}
-static as_value
-Point_interpolate(const fn_call& fn)
+as_value
+point_interpolate(const fn_call& fn)
{
as_value x0val;
as_value y0val;
@@ -561,29 +547,22 @@
double y1 = y1val.to_number();
double mu = muval.to_number();
- // newX = b.x + ( muval * (a.x - b.x) );
- // newY = b.y + ( muval * (a.y - b.y) );
-
as_value xoff = mu * (x0 - x1);
as_value yoff = mu * (y0 - y1);
- //log_debug("xoff:%s, yoff:%s, x1val:%s, y1val:%s", xoff, yoff, x1val,
y1val);
-
as_value x = x1val; // copy to avoid changing stack value
x.newAdd(xoff);
as_value y = y1val; // copy to avoid changing stack value
y.newAdd(yoff);
- boost::intrusive_ptr<as_object> ret = new Point_as;
- ret->set_member(NSV::PROP_X, as_value(x));
- ret->set_member(NSV::PROP_Y, as_value(y));
-
- return as_value(ret.get());
+ return constructPoint(fn, x, y);
}
-static as_value
-Point_polar(const fn_call& fn)
+/// Static member function.
+as_value
+point_polar(const fn_call& fn)
{
+
as_value lval; // length
as_value aval; // angle (radians)
@@ -615,19 +594,15 @@
as_value xval(x);
as_value yval(y);
- boost::intrusive_ptr<as_object> obj = new Point_as;
-
- obj->set_member(NSV::PROP_X, x);
- obj->set_member(NSV::PROP_Y, y);
-
- return as_value(obj.get());
+ return constructPoint(fn, x, y);
}
as_value
-Point_ctor(const fn_call& fn)
+point_ctor(const fn_call& fn)
{
- boost::intrusive_ptr<as_object> obj = new Point_as;
+
+ as_object* obj = ensureType<as_object>(fn.this_ptr).get();
as_value x;
as_value y;
@@ -655,36 +630,22 @@
obj->set_member(NSV::PROP_X, x);
obj->set_member(NSV::PROP_Y, y);
- return as_value(obj.get()); // will keep alive
-}
-
-// extern
-as_function*
-getFlashGeomPointConstructor(const fn_call& fn)
-{
- as_value point(fn.env().find_object("flash.geom.Point"));
- return point.to_as_function();
-}
-
-static
-as_value get_flash_geom_point_constructor(const fn_call& fn)
+ return as_value();
+}
+
+
+as_value
+get_flash_geom_point_constructor(const fn_call& fn)
{
log_debug("Loading flash.geom.Point class");
Global_as* gl = getGlobal(fn);
- as_object* proto = getPointInterface();
- as_object* cl = gl->createClass(&Point_ctor, proto);
+ as_object* proto = gl->createObject();
+ as_object* cl = gl->createClass(&point_ctor, proto);
+ attachPointInterface(*proto);
attachPointStaticProperties(*cl);
return cl;
}
-// extern
-void
-point_class_init(as_object& where, const ObjectURI& uri)
-{
- // TODO: this may not be correct, but it should be enumerable.
- const int flags = 0;
- where.init_destructive_property(getName(uri),
- get_flash_geom_point_constructor, flags, getNamespace(uri));
}
} // end of gnash namespace
=== modified file 'libcore/asobj/flash/geom/Point_as.h'
--- a/libcore/asobj/flash/geom/Point_as.h 2009-07-29 06:12:04 +0000
+++ b/libcore/asobj/flash/geom/Point_as.h 2009-09-29 10:06:30 +0000
@@ -36,9 +36,6 @@
/// Initialize the global Point class
void point_class_init(as_object& where, const ObjectURI& uri);
-/// Return the Point constructor, for use by Rectangle
-as_function* getFlashGeomPointConstructor(const fn_call& fn);
-
} // end of gnash namespace
#endif
=== modified file 'libcore/asobj/flash/geom/Rectangle_as.cpp'
--- a/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-08-20 06:55:15 +0000
+++ b/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-09-29 10:29:08 +0000
@@ -39,44 +39,62 @@
namespace gnash {
-static as_value Rectangle_clone(const fn_call& fn);
-static as_value Rectangle_contains(const fn_call& fn);
-static as_value Rectangle_containsPoint(const fn_call& fn);
-static as_value Rectangle_containsRectangle(const fn_call& fn);
-static as_value Rectangle_equals(const fn_call& fn);
-static as_value Rectangle_inflate(const fn_call& fn);
-static as_value Rectangle_inflatePoint(const fn_call& fn);
-static as_value Rectangle_intersection(const fn_call& fn);
-static as_value Rectangle_intersects(const fn_call& fn);
-static as_value Rectangle_isEmpty(const fn_call& fn);
-static as_value Rectangle_offset(const fn_call& fn);
-static as_value Rectangle_offsetPoint(const fn_call& fn);
-static as_value Rectangle_setEmpty(const fn_call& fn);
-static as_value Rectangle_toString(const fn_call& fn);
-static as_value Rectangle_union(const fn_call& fn);
-static as_value Rectangle_bottom_getset(const fn_call& fn);
-static as_value Rectangle_bottomRight_getset(const fn_call& fn);
-static as_value Rectangle_left_getset(const fn_call& fn);
-static as_value Rectangle_right_getset(const fn_call& fn);
-static as_value Rectangle_size_getset(const fn_call& fn);
-static as_value Rectangle_top_getset(const fn_call& fn);
-static as_value Rectangle_topLeft_getset(const fn_call& fn);
-
-
-as_value Rectangle_ctor(const fn_call& fn);
-
-static void
+namespace {
+ as_value Rectangle_clone(const fn_call& fn);
+ as_value Rectangle_contains(const fn_call& fn);
+ as_value Rectangle_containsPoint(const fn_call& fn);
+ as_value Rectangle_containsRectangle(const fn_call& fn);
+ as_value Rectangle_equals(const fn_call& fn);
+ as_value Rectangle_inflate(const fn_call& fn);
+ as_value Rectangle_inflatePoint(const fn_call& fn);
+ as_value Rectangle_intersection(const fn_call& fn);
+ as_value Rectangle_intersects(const fn_call& fn);
+ as_value Rectangle_isEmpty(const fn_call& fn);
+ as_value Rectangle_offset(const fn_call& fn);
+ as_value Rectangle_offsetPoint(const fn_call& fn);
+ as_value Rectangle_setEmpty(const fn_call& fn);
+ as_value Rectangle_toString(const fn_call& fn);
+ as_value Rectangle_union(const fn_call& fn);
+ as_value Rectangle_bottom(const fn_call& fn);
+ as_value Rectangle_bottomRight(const fn_call& fn);
+ as_value Rectangle_left(const fn_call& fn);
+ as_value Rectangle_right(const fn_call& fn);
+ as_value Rectangle_size(const fn_call& fn);
+ as_value Rectangle_top(const fn_call& fn);
+ as_value Rectangle_topLeft(const fn_call& fn);
+ as_value Rectangle_ctor(const fn_call& fn);
+ as_value get_flash_geom_rectangle_constructor(const fn_call& fn);
+
+}
+
+void
+rectangle_class_init(as_object& where, const ObjectURI& uri)
+{
+ // TODO: this may not be correct, but it should be enumerable.
+ const int flags = 0;
+ where.init_destructive_property(getName(uri),
+ get_flash_geom_rectangle_constructor, flags, getNamespace(uri));
+}
+
+
+namespace {
+
+void
attachRectangleInterface(as_object& o)
{
Global_as* gl = getGlobal(o);
o.init_member("clone", gl->createFunction(Rectangle_clone), 0);
o.init_member("contains", gl->createFunction(Rectangle_contains), 0);
- o.init_member("containsPoint",
gl->createFunction(Rectangle_containsPoint), 0);
- o.init_member("containsRectangle",
gl->createFunction(Rectangle_containsRectangle), 0);
+ o.init_member("containsPoint",
+ gl->createFunction(Rectangle_containsPoint), 0);
+ o.init_member("containsRectangle",
+ gl->createFunction(Rectangle_containsRectangle), 0);
o.init_member("equals", gl->createFunction(Rectangle_equals), 0);
o.init_member("inflate", gl->createFunction(Rectangle_inflate), 0);
- o.init_member("inflatePoint", gl->createFunction(Rectangle_inflatePoint),
0);
- o.init_member("intersection", gl->createFunction(Rectangle_intersection),
0);
+ o.init_member("inflatePoint",
+ gl->createFunction(Rectangle_inflatePoint), 0);
+ o.init_member("intersection",
+ gl->createFunction(Rectangle_intersection), 0);
o.init_member("intersects", gl->createFunction(Rectangle_intersects), 0);
o.init_member("isEmpty", gl->createFunction(Rectangle_isEmpty), 0);
o.init_member("offset", gl->createFunction(Rectangle_offset), 0);
@@ -84,51 +102,24 @@
o.init_member("setEmpty", gl->createFunction(Rectangle_setEmpty), 0);
o.init_member("toString", gl->createFunction(Rectangle_toString), 0);
o.init_member("union", gl->createFunction(Rectangle_union), 0);
- o.init_property("bottom", Rectangle_bottom_getset,
Rectangle_bottom_getset, 0);
- o.init_property("bottomRight", Rectangle_bottomRight_getset,
- Rectangle_bottomRight_getset, 0);
- o.init_property("left", Rectangle_left_getset,
- Rectangle_left_getset, 0);
- o.init_property("right", Rectangle_right_getset,
- Rectangle_right_getset, 0);
- o.init_property("size", Rectangle_size_getset,
- Rectangle_size_getset, 0);
- o.init_property("top", Rectangle_top_getset,
- Rectangle_top_getset, 0);
- o.init_property("topLeft", Rectangle_topLeft_getset,
- Rectangle_topLeft_getset, 0);
-}
-
-
-static as_object*
-getRectangleInterface()
-{
- static boost::intrusive_ptr<as_object> o;
-
- if ( ! o )
- {
- o = new as_object(getObjectInterface());
- VM::get().addStatic(o.get());
-
- attachRectangleInterface(*o);
- }
-
- return o.get();
-}
-
-class Rectangle_as: public as_object
-{
-
-public:
-
- Rectangle_as()
- :
- as_object(getRectangleInterface())
- {}
-};
-
-
-static as_value
+ o.init_property("bottom",
+ Rectangle_bottom, Rectangle_bottom, 0);
+ o.init_property("bottomRight", Rectangle_bottomRight,
+ Rectangle_bottomRight, 0);
+ o.init_property("left", Rectangle_left,
+ Rectangle_left, 0);
+ o.init_property("right", Rectangle_right,
+ Rectangle_right, 0);
+ o.init_property("size", Rectangle_size,
+ Rectangle_size, 0);
+ o.init_property("top", Rectangle_top,
+ Rectangle_top, 0);
+ o.init_property("topLeft", Rectangle_topLeft,
+ Rectangle_topLeft, 0);
+}
+
+
+as_value
Rectangle_clone(const fn_call& fn)
{
// The object will be interpreted as a rectangle. Any Rectangle
@@ -142,23 +133,22 @@
ptr->get_member(NSV::PROP_WIDTH, &w);
ptr->get_member(NSV::PROP_HEIGHT, &h);
- boost::intrusive_ptr<as_object> obj = new Rectangle_as;
-
- obj->set_member(NSV::PROP_X, x);
- obj->set_member(NSV::PROP_Y, y);
- obj->set_member(NSV::PROP_WIDTH, w);
- obj->set_member(NSV::PROP_HEIGHT, h);
-
- return as_value(obj.get()); // will keep alive
+ as_function* ctor = getClassConstructor(fn, "flash.geom.Rectangle");
+ if (!ctor) return as_value();
+
+ fn_call::Args args;
+ args += x, y, w, h;
+
+ return ctor->constructInstance(fn.env(), args).get();
}
-static as_value
+as_value
Rectangle_contains(const fn_call& fn)
{
//fn.arg(0) => x coordinate
//fn.arg(1) => y coordinate
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
as_value rect_x_as, rect_width_as, rect_y_as, rect_height_as;
@@ -236,73 +226,73 @@
}
-static as_value
+as_value
Rectangle_containsPoint(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
-static as_value
+as_value
Rectangle_containsRectangle(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
-static as_value
+as_value
Rectangle_equals(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
-static as_value
+as_value
Rectangle_inflate(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
-static as_value
+as_value
Rectangle_inflatePoint(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
-static as_value
+as_value
Rectangle_intersection(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
-static as_value
+as_value
Rectangle_intersects(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
-static as_value
+as_value
Rectangle_isEmpty(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
as_value w;
ptr->get_member(NSV::PROP_WIDTH, &w);
@@ -323,37 +313,37 @@
return as_value(false);
}
-static as_value
+as_value
Rectangle_offset(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
-static as_value
+as_value
Rectangle_offsetPoint(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
-static as_value
+as_value
Rectangle_setEmpty(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
-static as_value
+as_value
Rectangle_toString(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
as_value x, y, w, h;
@@ -372,19 +362,19 @@
return as_value(ss.str());
}
-static as_value
+as_value
Rectangle_union(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
-static as_value
-Rectangle_bottom_getset(const fn_call& fn)
+as_value
+Rectangle_bottom(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
as_value ret;
@@ -408,11 +398,11 @@
return ret;
}
-static as_value
-Rectangle_bottomRight_getset(const fn_call& fn)
+as_value
+Rectangle_bottomRight(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
- ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr =
+ ensureType<as_object>(fn.this_ptr);
if (!fn.nargs) {
@@ -449,10 +439,10 @@
}
-static as_value
-Rectangle_left_getset(const fn_call& fn)
+as_value
+Rectangle_left(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
as_value ret;
@@ -478,10 +468,10 @@
return ret;
}
-static as_value
-Rectangle_right_getset(const fn_call& fn)
+as_value
+Rectangle_right(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
as_value ret;
@@ -505,10 +495,10 @@
return ret;
}
-static as_value
-Rectangle_size_getset(const fn_call& fn)
+as_value
+Rectangle_size(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
as_value ret;
@@ -518,10 +508,7 @@
ptr->get_member(NSV::PROP_WIDTH, &w);
ptr->get_member(NSV::PROP_HEIGHT, &h);
- as_value point(fn.env().find_object("flash.geom.Point"));
-
- boost::intrusive_ptr<as_function> pointCtor = point.to_as_function();
-
+ as_function* pointCtor = getClassConstructor(fn, "flash.geom.Point");
if (!pointCtor) {
log_error("Failed to construct flash.geom.Point!");
return as_value();
@@ -542,10 +529,10 @@
return ret;
}
-static as_value
-Rectangle_top_getset(const fn_call& fn)
+as_value
+Rectangle_top(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
as_value ret;
@@ -571,10 +558,10 @@
return ret;
}
-static as_value
-Rectangle_topLeft_getset(const fn_call& fn)
+as_value
+Rectangle_topLeft(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
as_value ret;
@@ -584,10 +571,7 @@
ptr->get_member(NSV::PROP_X, &x);
ptr->get_member(NSV::PROP_Y, &y);
- as_value point(fn.env().find_object("flash.geom.Point"));
-
- boost::intrusive_ptr<as_function> pointCtor = point.to_as_function();
-
+ as_function* pointCtor = getClassConstructor(fn, "flash.geom.Point");
if (!pointCtor) {
log_error("Failed to construct flash.geom.Point!");
return as_value();
@@ -613,7 +597,8 @@
as_value
Rectangle_ctor(const fn_call& fn)
{
- boost::intrusive_ptr<as_object> obj = new Rectangle_as;
+
+ as_object* obj = ensureType<as_object>(fn.this_ptr).get();
as_value x;
as_value y;
@@ -651,27 +636,17 @@
obj->set_member(NSV::PROP_WIDTH, w);
obj->set_member(NSV::PROP_HEIGHT, h);
- return as_value(obj.get()); // will keep alive
+ return as_value();
}
-static as_value
+as_value
get_flash_geom_rectangle_constructor(const fn_call& fn)
{
log_debug("Loading flash.geom.Rectangle class");
-
- as_object* proto = getRectangleInterface();
Global_as* gl = getGlobal(fn);
+ as_object* proto = gl->createObject();
+ attachRectangleInterface(*proto);
return gl->createClass(&Rectangle_ctor, proto);
}
-
-// extern
-void
-rectangle_class_init(as_object& where, const ObjectURI& uri)
-{
- // TODO: this may not be correct, but it should be enumerable.
- const int flags = 0;
- where.init_destructive_property(getName(uri),
- get_flash_geom_rectangle_constructor, flags, getNamespace(uri));
-}
-
+} // anonymous namespace
} // end of gnash namespace
=== modified file 'libcore/asobj/flash/geom/Transform_as.cpp'
--- a/libcore/asobj/flash/geom/Transform_as.cpp 2009-08-27 07:55:02 +0000
+++ b/libcore/asobj/flash/geom/Transform_as.cpp 2009-09-29 10:36:57 +0000
@@ -42,29 +42,41 @@
namespace {
- as_value Transform_colorTransform(const fn_call& fn);
- as_value Transform_concatenatedColorTransform(const fn_call& fn);
- as_value Transform_concatenatedMatrix(const fn_call& fn);
- as_value Transform_matrix(const fn_call& fn);
- as_value Transform_pixelBounds(const fn_call& fn);
- as_value Transform_ctor(const fn_call& fn);
+ as_value transform_colorTransform(const fn_call& fn);
+ as_value transform_concatenatedColorTransform(const fn_call& fn);
+ as_value transform_concatenatedMatrix(const fn_call& fn);
+ as_value transform_matrix(const fn_call& fn);
+ as_value transform_pixelBounds(const fn_call& fn);
+ as_value transform_ctor(const fn_call& fn);
void attachTransformInterface(as_object& o);
as_object* getTransformInterface();
as_value get_flash_geom_transform_constructor(const fn_call& fn);
+
+ // Handle overflows from AS ColorTransform double.
+ inline boost::int16_t
+ truncateDouble(double d)
+ {
+
+ if (d > std::numeric_limits<boost::int16_t>::max() ||
+ d < std::numeric_limits<boost::int16_t>::min())
+ {
+ return std::numeric_limits<boost::int16_t>::min();
+ }
+ return static_cast<boost::int16_t>(d);
+ }
}
-class Transform_as: public as_object
+class Transform_as : public Relay
{
public:
- Transform_as(MovieClip& movieClip)
- :
- as_object(getTransformInterface()),
- _movieClip(movieClip)
- {}
+ Transform_as(MovieClip& movieClip)
+ :
+ _movieClip(movieClip)
+ {}
const SWFMatrix& getMatrix() const { return _movieClip.getMatrix(); }
const cxform& getColorTransform() const { return _movieClip.get_cxform(); }
@@ -73,10 +85,9 @@
protected:
- void markReachableResources() const
+ virtual void markReachableResources() const
{
_movieClip.setReachable();
- markAsObjectReachable();
}
private:
@@ -85,20 +96,6 @@
};
-// Handle overflows from AS ColorTransform double. Doubtful
-// whether it will really be inlined, but that's the compiler's
-// business.
-static inline boost::int16_t
-truncateDouble(double d)
-{
-
- if (d > std::numeric_limits<boost::int16_t>::max() ||
- d < std::numeric_limits<boost::int16_t>::min())
- {
- return std::numeric_limits<boost::int16_t>::min();
- }
- return static_cast<boost::int16_t>(d);
-}
// extern
void
@@ -107,20 +104,19 @@
// TODO: this may not be correct, but it should be enumerable.
const int flags = 0;
where.init_destructive_property(getName(uri),
- get_flash_geom_transform_constructor, flags,
getNamespace(uri));
+ get_flash_geom_transform_constructor, flags, getNamespace(uri));
}
namespace {
as_value
-Transform_colorTransform(const fn_call& fn)
+transform_colorTransform(const fn_call& fn)
{
const double factor = 256.0;
- boost::intrusive_ptr<Transform_as> ptr =
- ensureType<Transform_as>(fn.this_ptr);
+ Transform_as* relay = ensureNativeType<Transform_as>(fn.this_ptr);
if (!fn.nargs) {
@@ -136,7 +132,7 @@
}
// Construct a ColorTransform from the sprite cxform.
- const cxform& c = ptr->getColorTransform();
+ const cxform& c = relay->getColorTransform();
fn_call::Args args;
args += c.ra / factor, c.ga / factor, c.ba / factor, c.aa / factor,
@@ -197,33 +193,31 @@
c.bb = truncateDouble(transform->getBlueOffset());
c.ab = truncateDouble(transform->getAlphaOffset());
- ptr->setColorTransform(c);
+ relay->setColorTransform(c);
return as_value();
}
as_value
-Transform_concatenatedColorTransform(const fn_call& fn)
-{
- boost::intrusive_ptr<Transform_as> ptr =
- ensureType<Transform_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-Transform_concatenatedMatrix(const fn_call& fn)
-{
- boost::intrusive_ptr<Transform_as> ptr =
- ensureType<Transform_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-as_value
-Transform_matrix(const fn_call& fn)
+transform_concatenatedColorTransform(const fn_call& fn)
+{
+ Transform_as* relay = ensureNativeType<Transform_as>(fn.this_ptr);
+ UNUSED(relay);
+ LOG_ONCE(log_unimpl (__FUNCTION__));
+ return as_value();
+}
+
+as_value
+transform_concatenatedMatrix(const fn_call& fn)
+{
+ Transform_as* relay = ensureNativeType<Transform_as>(fn.this_ptr);
+ UNUSED(relay);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+transform_matrix(const fn_call& fn)
{
const double factor = 65536.0;
@@ -233,8 +227,7 @@
// would that work?)?
// This should work by passing a new matrix, in which case we should just
// set our _movieClip's matrix from the AS matrix.
- boost::intrusive_ptr<Transform_as> ptr =
- ensureType<Transform_as>(fn.this_ptr);
+ Transform_as* relay = ensureNativeType<Transform_as>(fn.this_ptr);
if (!fn.nargs)
{
@@ -249,7 +242,7 @@
return as_value();
}
- const SWFMatrix& m = ptr->getMatrix();
+ const SWFMatrix& m = relay->getMatrix();
fn_call::Args args;
args += m.sx / factor,
@@ -308,27 +301,25 @@
m.set_x_translation(pixelsToTwips(tx.to_number()));
m.set_y_translation(pixelsToTwips(ty.to_number()));
- ptr->setMatrix(m);
+ relay->setMatrix(m);
return as_value();
}
as_value
-Transform_pixelBounds(const fn_call& fn)
+transform_pixelBounds(const fn_call& fn)
{
- boost::intrusive_ptr<Transform_as> ptr =
- ensureType<Transform_as>(fn.this_ptr);
-
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
+ Transform_as* relay = ensureNativeType<Transform_as>(fn.this_ptr);
+ UNUSED(relay);
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
}
as_value
-Transform_ctor(const fn_call& fn)
+transform_ctor(const fn_call& fn)
{
if (!fn.nargs) {
@@ -339,26 +330,25 @@
log_aserror("flash.geom.Transform(%s): needs one argument",
ss.str());
);
- return as_value();
+ throw ActionTypeError();
}
// TODO: what about more than one argument?
- if (fn.nargs > 1) {
- std::stringstream ss;
- fn.dump_args(ss);
- LOG_ONCE(log_unimpl("Transform(%s): %s", ss.str(),
+ if (fn.nargs > 1) {
+ std::stringstream ss;
+ fn.dump_args(ss);
+ LOG_ONCE(log_unimpl("Transform(%s): %s", ss.str(),
_("arguments discarded")) );
- }
+ }
// TODO: does this have to be a MovieClip or can it be any DisplayObject?
boost::intrusive_ptr<MovieClip> mc =
ensureType<MovieClip>(fn.arg(0).to_object(*getGlobal(fn)));
- boost::intrusive_ptr<as_object> obj = new Transform_as(*mc);
+ as_object* obj = ensureType<as_object>(fn.this_ptr).get();
+ obj->setRelay(new Transform_as(*mc));
- // We have a movie clip. Do we construct the various properties, or are
they
- // constructed on demand?
- return as_value(obj.get()); // will keep alive
+ return as_value();
}
as_value
@@ -366,26 +356,9 @@
{
log_debug("Loading flash.geom.Transform class");
Global_as* gl = getGlobal(fn);
- return gl->createClass(&Transform_ctor, getTransformInterface());
-}
-
-as_object*
-getTransformInterface()
-{
- static boost::intrusive_ptr<as_object> o;
-
- if (!o) {
-
- // TODO: check if this class should inherit from Object
- // or from a different class
- o = new as_object(getObjectInterface());
- VM::get().addStatic(o.get());
-
- attachTransformInterface(*o);
-
- }
-
- return o.get();
+ as_object* proto = gl->createObject();
+ attachTransformInterface(*proto);
+ return gl->createClass(&transform_ctor, proto);
}
void
@@ -393,17 +366,17 @@
{
const int protectedFlags = PropFlags::isProtected;
- o.init_property("matrix", Transform_matrix, Transform_matrix,
+ o.init_property("matrix", transform_matrix, transform_matrix,
protectedFlags);
- o.init_property("concatenatedMatrix", Transform_concatenatedMatrix,
- Transform_concatenatedMatrix, protectedFlags);
- o.init_property("colorTransform", Transform_colorTransform,
- Transform_colorTransform, protectedFlags);
+ o.init_property("concatenatedMatrix", transform_concatenatedMatrix,
+ transform_concatenatedMatrix, protectedFlags);
+ o.init_property("colorTransform", transform_colorTransform,
+ transform_colorTransform, protectedFlags);
o.init_property("concatenatedColorTransform",
- Transform_concatenatedColorTransform,
- Transform_concatenatedColorTransform, protectedFlags);
- o.init_property("pixelBounds", Transform_pixelBounds,
- Transform_pixelBounds, protectedFlags);
+ transform_concatenatedColorTransform,
+ transform_concatenatedColorTransform, protectedFlags);
+ o.init_property("pixelBounds", transform_pixelBounds,
+ transform_pixelBounds, protectedFlags);
}
} // anonymous namespace
=== modified file 'libcore/asobj/flash/geom/geom_pkg.cpp'
--- a/libcore/asobj/flash/geom/geom_pkg.cpp 2009-08-27 07:04:35 +0000
+++ b/libcore/asobj/flash/geom/geom_pkg.cpp 2009-09-29 10:36:57 +0000
@@ -33,7 +33,9 @@
namespace gnash {
-static as_value
+namespace {
+
+as_value
get_flash_geom_package(const fn_call& fn)
{
log_debug("Loading flash.geom package");
@@ -54,6 +56,8 @@
return pkg;
}
+}
+
void
flash_geom_package_init(as_object& where, const ObjectURI& uri)
{
=== modified file 'libcore/asobj/flash/geom/geom_pkg.h'
--- a/libcore/asobj/flash/geom/geom_pkg.h 2009-07-16 08:30:06 +0000
+++ b/libcore/asobj/flash/geom/geom_pkg.h 2009-09-29 10:07:42 +0000
@@ -21,11 +21,9 @@
namespace gnash {
class as_object;
-
void flash_geom_package_init(as_object& pkg, const ObjectURI& uri);
-} // end of gnash namespace
+} // gnash namespace
-// __FLASH_GEOM_PACKAGE_H__
#endif
=== modified file 'libcore/asobj/flash/net/FileReferenceList_as.cpp'
--- a/libcore/asobj/flash/net/FileReferenceList_as.cpp 2009-08-20 08:57:16
+0000
+++ b/libcore/asobj/flash/net/FileReferenceList_as.cpp 2009-09-29 10:05:48
+0000
@@ -58,11 +58,6 @@
o.init_property("fileList", filereferencelist_fileList_getset,
filereferencelist_fileList_getset);
}
-static void
-attachFileReferenceListStaticProperties(as_object& /*o*/)
-{
-
-}
static as_value
filereferencelist_addListener(const fn_call& /*fn*/)
=== modified file 'libcore/parser/AbcBlock.cpp'
--- a/libcore/parser/AbcBlock.cpp 2009-07-14 13:40:32 +0000
+++ b/libcore/parser/AbcBlock.cpp 2009-09-29 08:43:51 +0000
@@ -428,7 +428,17 @@
for (std::vector<asNamespace*>::iterator i = _namespacePool.begin();
i != _namespacePool.end(); ++i) {
- if (_stringPool[(*i)->getAbcURI()] == nsstr) {
+
+ const size_t key = (*i)->getAbcURI();
+
+ log_abc("Namespace ABC uri: %s; global URI: %s, string: %s, "
+ "pool size: %s",
+ key, (*i)->getURI(), _stringTable->value((*i)->getURI()),
+ _stringPool.size());
+
+ assert(key < _stringPool.size());
+
+ if (_stringPool[key] == nsstr) {
a.setNamespace(*i);
break;
}
@@ -513,9 +523,9 @@
{
boost::uint32_t count = _stream->read_V32();
_doublePool.resize(count);
- if (count)
- _doublePool[0] = 0.0;
- for (unsigned int i = 1; i < count; ++i)
+ if (count) _doublePool[0] = 0.0;
+
+ for (size_t i = 1; i < count; ++i)
{
_doublePool[i] = _stream->read_d64();
log_abc("Double %u=%lf", i, _doublePool[i]);
@@ -532,16 +542,17 @@
log_abc("There are %u string constants.", count);
_stringPool.resize(count);
_stringPoolTableIDs.resize(count);
- if (count)
- {
+
+ if (count) {
_stringPool[0] = "";
_stringPoolTableIDs[0] = 0;
}
- for (unsigned int i = 1; i < count; ++i)
- {
+
+ for (size_t i = 1; i < count; ++i) {
boost::uint32_t length = _stream->read_V32();
_stream->read_string_with_length(length, _stringPool[i]);
- log_abc("Adding string constant to string pool: index=%u %s",
i, _stringPool[i]);
+ log_abc("Adding string constant to string pool: index=%u %s",
+ i, _stringPool[i]);
_stringPoolTableIDs[i] = 0;
}
return true;
@@ -557,11 +568,11 @@
boost::uint32_t count = _stream->read_V32();
log_abc("There are %u namespaces.", count);
_namespacePool.resize(count);
- if (count)
- {
+ if (count) {
_namespacePool[0] = mCH->getGlobalNs();
}
- for (unsigned int i = 1; i < count; ++i)
+
+ for (size_t i = 1; i < count; ++i)
{
NamespaceConstant kind =
static_cast<NamespaceConstant>(_stream->read_u8());
=== modified file 'testsuite/actionscript.all/Transform.as'
--- a/testsuite/actionscript.all/Transform.as 2009-02-25 22:33:03 +0000
+++ b/testsuite/actionscript.all/Transform.as 2009-09-29 10:10:20 +0000
@@ -48,7 +48,7 @@
// Cannot be instantiated without MovieClip argument.
t = new Transform;
-xcheck_equals(t, undefined);
+check_equals(t, undefined);
t = Transform();
check_equals(t, undefined);
=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING 2009-09-22 09:19:00 +0000
+++ b/testsuite/swfdec/PASSING 2009-09-29 10:30:54 +0000
@@ -913,6 +913,9 @@
point-8.swf:71eaa77c0f2140096edda7522da49f99
point-properties-5.swf:2b1071acd6c53d5342c1946214a3b3df
point-properties-5.swf:c3439d59fa29fb709630ee3a3ad230b0
+point-properties-6.swf:e3b094aebc412bf8f1e2b14d7752fd74
+point-properties-7.swf:6e12378e222bf1a1e8ec6f7dca1f26ee
+point-properties-8.swf:879a47904470c9d9ddd75f97dbe1979d
preload.swf:2fd2da9440e29289e83dadd1ed9c99c4
previousframe-stop.swf:b4bdd96832fc4b7e60f774fa042ae1a0
print-job-init-5.swf:22889777e5e8230cee8c760c0930b5db
@@ -965,6 +968,8 @@
rectangle-construct-5.swf:346164542dbfc9715da30ee9ea011373
rectangle-equals-5.swf:a32beb36b2e690320c9d88e3130cb600
rectangle-properties-5.swf:b9926dc51714320ff06eddb544ae9260
+rectangle-properties-7.swf:48616a870f18a7f29553a3579db8a19f
+rectangle-properties-8.swf:652bab2e912331a19008c5ccb96ebe4d
registerclass-previous.swf:7ea3d590fa576190bda56996ff0fa768
registerclass-properties.swf:9deba9b328c2e4af1c1eb98a62d4e355
register-count.swf:861abb623a228e4152df92896ee807f0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11526: Move Relay classes into a separate file.,
Benjamin Wolsey <=