[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11625: Rename some AS3 files and cl
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11625: Rename some AS3 files and classes and add some documentation. |
Date: |
Sun, 15 Nov 2009 15:33:03 +0100 |
User-agent: |
Bazaar (1.16.1) |
------------------------------------------------------------
revno: 11625 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Sun 2009-11-15 15:33:03 +0100
message:
Rename some AS3 files and classes and add some documentation.
Start to undo the horrible idea of using string_table::key for ABC resources.
Move callMethod out of as_object class so that it can be used on null objects.
This makes it easier to implement ActionScript in many cases.
renamed:
libcore/asNamespace.cpp => libcore/Namespace.cpp
libcore/asNamespace.h => libcore/Namespace.h
libcore/vm/asName.h => libcore/vm/MultiName.h
modified:
libbase/log.h
libcore/Button.cpp
libcore/Button.h
libcore/ClassHierarchy.cpp
libcore/ClassHierarchy.h
libcore/DisplayObject.cpp
libcore/DisplayObject.h
libcore/Makefile.am
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/MovieLoader.cpp
libcore/TextField.cpp
libcore/TextField.h
libcore/asClass.cpp
libcore/asClass.h
libcore/asException.h
libcore/asMethod.cpp
libcore/asMethod.h
libcore/as_environment.cpp
libcore/as_environment.h
libcore/as_object.cpp
libcore/as_object.h
libcore/as_value.cpp
libcore/as_value.h
libcore/asobj/Array_as.cpp
libcore/asobj/AsBroadcaster.cpp
libcore/asobj/Color_as.cpp
libcore/asobj/Globals.cpp
libcore/asobj/LoadVars_as.cpp
libcore/asobj/LoadableObject.cpp
libcore/asobj/MovieClipLoader.cpp
libcore/asobj/Object.cpp
libcore/asobj/Selection_as.cpp
libcore/asobj/String_as.cpp
libcore/asobj/flash/display/MovieClip_as.cpp
libcore/asobj/flash/media/Camera_as.cpp
libcore/asobj/flash/media/Microphone_as.cpp
libcore/asobj/flash/media/Sound_as.cpp
libcore/asobj/flash/net/NetConnection_as.cpp
libcore/asobj/flash/net/NetStream_as.cpp
libcore/asobj/flash/net/XMLSocket_as.cpp
libcore/asobj/flash/text/TextSnapshot_as.cpp
libcore/asobj/flash/ui/ContextMenu_as.cpp
libcore/asobj/flash/ui/Keyboard_as.cpp
libcore/asobj/flash/xml/XMLDocument_as.cpp
libcore/asobj/flash/xml/XMLNode_as.cpp
libcore/movie_root.cpp
libcore/parser/AbcBlock.cpp
libcore/parser/AbcBlock.h
libcore/swf_function.cpp
libcore/swf_function.h
libcore/vm/ASHandlers.cpp
libcore/vm/ActionExec.cpp
libcore/vm/ActionExec.h
libcore/vm/ExecutableCode.h
libcore/vm/Machine.cpp
libcore/vm/Machine.h
libcore/vm/Makefile.am
libcore/Namespace.cpp
libcore/Namespace.h
libcore/vm/MultiName.h
=== modified file 'libbase/log.h'
--- a/libbase/log.h 2009-08-08 00:55:45 +0000
+++ b/libbase/log.h 2009-11-13 11:55:32 +0000
@@ -314,6 +314,7 @@
/// sequence LOG_TYPES.
BOOST_PP_SEQ_FOR_EACH(GENERATE_LOG_TYPES, _, LOG_TYPES)
+#undef TOKENIZE_ARGS
#undef TOKENIZE_FORMAT
#undef GENERATE_LOG_TYPES
#undef LOG_TEMPLATES
=== modified file 'libcore/Button.cpp'
--- a/libcore/Button.cpp 2009-11-04 18:08:14 +0000
+++ b/libcore/Button.cpp 2009-11-13 14:02:21 +0000
@@ -205,19 +205,15 @@
public:
ButtonActionPusher(movie_root& mr, DisplayObject* this_ptr)
:
- called(false),
_mr(mr),
_tp(this_ptr)
{}
- void operator() (const action_buffer& ab)
+ void operator()(const action_buffer& ab)
{
_mr.pushAction(ab, _tp);
- called = true;
}
- bool called;
-
private:
movie_root& _mr;
DisplayObject* _tp;
@@ -333,30 +329,23 @@
}
-bool
+void
Button::notifyEvent(const event_id& id)
{
- if (unloaded())
- {
+ if (unloaded()) {
// We dont' respond to events while unloaded
// See bug #22982
-#if 0 // debugging..
- log_debug("Button %s received %s event while unloaded: ignored",
- getTarget(), id);
-#endif
- return false;
+ return;
}
// We only respond keypress events
- if ( id.id() != event_id::KEY_PRESS ) return false;
+ if ( id.id() != event_id::KEY_PRESS ) return;
// We only respond to valid key code (should we assert here?)
- if ( id.keyCode() == key::INVALID ) return false;
+ if ( id.keyCode() == key::INVALID ) return;
ButtonActionPusher xec(stage(), this);
_def->forEachTrigger(id, xec);
-
- return xec.called;
}
bool
@@ -575,11 +564,7 @@
mr.pushAction(code, movie_root::apDOACTION);
}
- // Call conventional attached method.
- as_function* method = getUserDefinedEventHandler(event.functionKey());
- if (method) {
- mr.pushAction(method, this, movie_root::apDOACTION);
- }
+ callMethod(getObject(this), event.functionKey());
}
=== modified file 'libcore/Button.h'
--- a/libcore/Button.h 2009-11-04 15:03:15 +0000
+++ b/libcore/Button.h 2009-11-13 12:54:06 +0000
@@ -85,7 +85,7 @@
virtual bool trackAsMenu();
// called from keypress listener only
- bool notifyEvent(const event_id& id);
+ void notifyEvent(const event_id& id);
void display(Renderer& renderer);
=== modified file 'libcore/ClassHierarchy.cpp'
--- a/libcore/ClassHierarchy.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/ClassHierarchy.cpp 2009-11-13 08:19:10 +0000
@@ -236,7 +236,7 @@
{
// AS2 classes should be registered with namespace 0, so they all
// appear in a single global namespace.
- asNamespace *nso = findNamespace(c.namespace_name);
+ Namespace *nso = findNamespace(c.namespace_name);
if (!nso) nso = addNamespace(c.namespace_name);
=== modified file 'libcore/ClassHierarchy.h'
--- a/libcore/ClassHierarchy.h 2009-07-16 08:30:06 +0000
+++ b/libcore/ClassHierarchy.h 2009-11-13 08:19:10 +0000
@@ -26,7 +26,7 @@
#include "as_object.h"
#include "SafeStack.h"
#include "asClass.h"
-#include "asNamespace.h"
+#include "Namespace.h"
#ifdef ENABLE_AVM2
# include "asBoundValues.h"
@@ -160,7 +160,7 @@
/// Get the global namespace. This is not the Global object -- it only
/// contains the classes, not any globally available functions or
anything
/// else.
- asNamespace* getGlobalNs() { return mGlobalNamespace; }
+ Namespace* getGlobalNs() { return mGlobalNamespace; }
// Chad: Document
as_object* newOfType(string_table::key /*whattype*/) { return NULL; }
@@ -169,7 +169,7 @@
///
/// @return
/// The namespace with the given uri or NULL if it doesn't exist.
- asNamespace* findNamespace(string_table::key uri)
+ Namespace* findNamespace(string_table::key uri)
{
namespacesContainer::iterator i;
if (mNamespaces.empty())
@@ -186,10 +186,10 @@
/// can't ever be found. (They must be kept and passed to the
appropriate
/// objects.)
///
- asNamespace* anonNamespace(string_table::key uri)
+ Namespace* anonNamespace(string_table::key uri)
{
mAnonNamespaces.grow(1);
- asNamespace *n = &mAnonNamespaces.top(0);
+ Namespace *n = &mAnonNamespaces.top(0);
n->setURI(uri);
return n;
}
@@ -198,9 +198,9 @@
/// Add a namespace to the set. Don't use to add unnamed namespaces.
/// Will overwrite existing namespaces 'kind' and 'prefix' values.
/// Returns the added space.
- asNamespace* addNamespace(string_table::key uri)
+ Namespace* addNamespace(string_table::key uri)
{
- asNamespace *n = findNamespace(uri);
+ Namespace *n = findNamespace(uri);
if (n) return n;
// The set should create it automatically here. TODO: Make sure
mNamespaces[uri].setURI(uri);
@@ -245,10 +245,10 @@
as_object* mGlobal;
Extension* mExtension;
- typedef std::map<string_table::key, asNamespace> namespacesContainer;
+ typedef std::map<string_table::key, Namespace> namespacesContainer;
namespacesContainer mNamespaces;
- SafeStack<asNamespace> mAnonNamespaces;
- asNamespace* mGlobalNamespace;
+ SafeStack<Namespace> mAnonNamespaces;
+ Namespace* mGlobalNamespace;
SafeStack<asClass> mClassMemory;
#ifdef ENABLE_AVM2
=== modified file 'libcore/DisplayObject.cpp'
--- a/libcore/DisplayObject.cpp 2009-11-09 23:07:58 +0000
+++ b/libcore/DisplayObject.cpp 2009-11-13 13:18:11 +0000
@@ -500,29 +500,14 @@
Events::const_iterator it = _event_handlers.find(id);
if (it != _event_handlers.end()) return true;
- as_function* method = getUserDefinedEventHandler(id.functionKey());
- return (method);
-}
-
-as_function*
-DisplayObject::getUserDefinedEventHandler(const std::string& name) const
-{
- if (!_object) return 0;
- string_table::key key = getStringTable(*_object).find(name);
- return getUserDefinedEventHandler(key);
-}
-
-as_function*
-DisplayObject::getUserDefinedEventHandler(string_table::key key) const
-{
- if (!_object) return 0;
-
- as_value tmp;
-
- if (_object->get_member(key, &tmp)) {
+ if (!_object) return false;
+
+ as_value tmp;
+ if (_object->get_member(id.functionKey(), &tmp)) {
return tmp.to_as_function();
}
- return 0;
+ return false;
+
}
/// Set the real and cached x scale.
=== modified file 'libcore/DisplayObject.h'
--- a/libcore/DisplayObject.h 2009-11-08 13:13:45 +0000
+++ b/libcore/DisplayObject.h 2009-11-13 13:18:11 +0000
@@ -647,13 +647,9 @@
// Return true if this DisplayObject should be rendered
bool visible() const { return _visible; }
- /// ActionScript event handler. Returns true if a handler was called.
- //
- /// Must be overridden or will always return false.
- ///
- virtual bool notifyEvent(const event_id& /* id */)
+ /// Notify clip events (and also user-defined ones).
+ virtual void notifyEvent(const event_id& /*id*/)
{
- return false;
}
/// Queue event in the global action queue.
@@ -1001,30 +997,6 @@
return _event_handlers;
}
- /// Return a user defined event handler, if any
- //
- /// @param name
- /// Function name to fetch. It will be converted to
- /// lowercase if current VM has been initialized against
- /// an SWF version inferior to 7.
- ///
- /// @return
- /// A function if a member with the given name exists and
- /// casts to an as_function. A NULL pointer otherwise.
- ///
- as_function* getUserDefinedEventHandler(const std::string& name) const;
-
- /// Return a user defined event handler, if any
- //
- /// @param key
- /// Function key to fetch.
- ///
- /// @return
- /// A function if a member with the given key exists and
- /// casts to an as_function. A NULL pointer otherwise.
- ///
- as_function* getUserDefinedEventHandler(string_table::key key) const;
-
void set_event_handlers(const Events& copyfrom);
/// Name of this DisplayObject (if any)
=== modified file 'libcore/Makefile.am'
--- a/libcore/Makefile.am 2009-11-13 23:21:54 +0000
+++ b/libcore/Makefile.am 2009-11-15 14:33:03 +0000
@@ -129,9 +129,9 @@
Timers.cpp \
RGBA.cpp \
asClass.cpp \
- asNamespace.cpp \
MovieFactory.cpp \
MovieLoader.cpp \
+ Namespace.cpp \
$(FREETYPE_SOURCES) \
$(NULL)
@@ -265,7 +265,7 @@
Geometry.h \
Video.h \
asClass.h \
- asNamespace.h \
+ Namespace.h \
$(NULL)
# These makefile fragments build the ActionScript library for
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp 2009-11-12 08:04:11 +0000
+++ b/libcore/MovieClip.cpp 2009-11-13 13:14:22 +0000
@@ -620,7 +620,7 @@
}
-bool
+void
MovieClip::notifyEvent(const event_id& id)
{
@@ -629,38 +629,29 @@
#endif
// We do not execute ENTER_FRAME if unloaded
- if ( id.id() == event_id::ENTER_FRAME && unloaded() )
- {
+ if (id.id() == event_id::ENTER_FRAME && unloaded()) {
#ifdef GNASH_DEBUG
log_debug(_("Sprite %s ignored ENTER_FRAME event (is unloaded)"),
getTarget());
#endif
- return false;
+ return;
}
- if ( id.is_button_event() && ! isEnabled() )
- {
+ if (id.is_button_event() && ! isEnabled()) {
#ifdef GNASH_DEBUG
log_debug(_("Sprite %s ignored button-like event %s as not 'enabled'"),
getTarget(), id);
#endif
- return false;
+ return;
}
- bool called = false;
-
- std::auto_ptr<ExecutableCode> code ( get_event_handler(id) );
- if ( code.get() )
- {
+ std::auto_ptr<ExecutableCode> code (get_event_handler(id));
+ if (code.get()) {
// Dispatch.
code->execute();
-
- called = true;
}
// user-defined onInitialize is never called
- if ( id.id() == event_id::INITIALIZE ) {
- return called;
- }
+ if (id.id() == event_id::INITIALIZE) return;
// NOTE: user-defined onLoad is not invoked for static
// clips on which no clip-events are defined.
@@ -676,8 +667,8 @@
//
// TODO: test the case in which it's MovieClip.prototype.onLoad
// defined !
- if ( id.id() == event_id::LOAD )
- {
+ if (id.id() == event_id::LOAD) {
+
// TODO: we're likely making too much noise for nothing here,
// there must be some action-execution-order related problem
instead....
// See testsuite/misc-ming.all/registerClassTest2.swf for an onLoad
@@ -709,22 +700,14 @@
"no registered class and no clip events defined)"),
getTarget(), get_depth());
#endif
- return called;
+ return;
} while (0);
}
// Check for member function.
- if (! id.is_key_event ())
- {
- boost::intrusive_ptr<as_function> method =
- getUserDefinedEventHandler(id.functionKey());
-
- if ( method )
- {
- call_method0(method.get(), _environment, getObject(this));
- called = true;
- }
+ if (!id.is_key_event()) {
+ callMethod(getObject(this), id.functionKey());
}
// TODO: if this was UNLOAD release as much memory as possible ?
@@ -732,7 +715,6 @@
// which unload handlers of parent and childs is performed
// and wheter unload of child can access members of parent.
- return called;
}
as_object*
@@ -1655,14 +1637,7 @@
const event_id &event = EH[i];
// Check event handlers
- if ( get_event_handler(event.id()).get() )
- {
- return true;
- }
-
- // Check user-defined event handlers
- if ( getUserDefinedEventHandler(event.functionKey()) )
- {
+ if (hasEventHandler(event.id())) {
return true;
}
}
=== modified file 'libcore/MovieClip.h'
--- a/libcore/MovieClip.h 2009-11-10 07:52:58 +0000
+++ b/libcore/MovieClip.h 2009-11-13 12:54:06 +0000
@@ -542,7 +542,7 @@
int newdepth, as_object* init_object=NULL);
/// Dispatch event handler(s), if any.
- virtual bool notifyEvent(const event_id& id);
+ virtual void notifyEvent(const event_id& id);
// inherited from DisplayObject class, see dox in DisplayObject.h
as_environment& get_environment() {
=== modified file 'libcore/MovieLoader.cpp'
--- a/libcore/MovieLoader.cpp 2009-11-12 12:13:15 +0000
+++ b/libcore/MovieLoader.cpp 2009-11-15 14:33:03 +0000
@@ -232,7 +232,7 @@
// (supposedly the Adobe mozilla plugin).
as_value arg3(0.0);
- handler->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadError",
+ callMethod(handler, NSV::PROP_BROADCAST_MESSAGE, "onLoadError",
arg1, arg2, arg3);
}
return true; // nothing to do, but completed
@@ -282,7 +282,7 @@
// (0/-1 bytes loaded/total) but still with *new*
// display object as target (ie: the target won't
// contain members set either before or after loadClip.
- handler->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadStart",
+ callMethod(handler, NSV::PROP_BROADCAST_MESSAGE, "onLoadStart",
getObject(targetDO));
// Dispatch onLoadProgress
@@ -291,12 +291,12 @@
//
size_t bytesLoaded = md->get_bytes_loaded();
size_t bytesTotal = md->get_bytes_total();
- handler->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadProgress",
+ callMethod(handler, NSV::PROP_BROADCAST_MESSAGE, "onLoadProgress",
getObject(targetDO), bytesLoaded, bytesTotal);
// Dispatch onLoadComplete
// FIXME: find semantic of last arg
- handler->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadComplete",
+ callMethod(handler, NSV::PROP_BROADCAST_MESSAGE, "onLoadComplete",
getObject(targetDO), as_value(0.0));
=== renamed file 'libcore/asNamespace.cpp' => 'libcore/Namespace.cpp'
--- a/libcore/asNamespace.cpp 2009-07-03 07:49:03 +0000
+++ b/libcore/Namespace.cpp 2009-11-13 14:22:20 +0000
@@ -19,7 +19,7 @@
# include "gnashconfig.h"
#endif
-#include "asNamespace.h"
+#include "Namespace.h"
#include "VM.h"
#include "ClassHierarchy.h"
#include "string_table.h"
@@ -30,7 +30,7 @@
namespace gnash {
void
-asNamespace::stubPrototype(ClassHierarchy& ch, string_table::key name)
+Namespace::stubPrototype(ClassHierarchy& ch, string_table::key name)
{
asClass *pClass = ch.newClass();
pClass->setName(name);
@@ -38,7 +38,7 @@
}
void
-asNamespace::dump(string_table& st)
+Namespace::dump(string_table& st)
{
#if ENABLE_AVM2
std::ostringstream s;
@@ -50,8 +50,8 @@
s << st.value(t) << "(URI: " << t << "), ";
}
- log_debug("Classes in namespace %s (URI: %s, ABC: %s): %s",
- st.value(_uri), _uri, _abcURI, s.str());
+ log_debug("Classes in namespace %s (URI: %s): %s",
+ st.value(_uri), _uri, s.str());
#endif
}
=== renamed file 'libcore/asNamespace.h' => 'libcore/Namespace.h'
--- a/libcore/asNamespace.h 2009-07-02 13:58:17 +0000
+++ b/libcore/Namespace.h 2009-11-13 14:22:20 +0000
@@ -30,18 +30,24 @@
namespace gnash {
-/// Represent an ActionScript namespace
-class asNamespace
+/// Represent an ActionScript Namespace
+//
+/// Namespaces are generally global resources, although private Namespaces
+/// are only visible inside a single AbcBlock.
+//
+/// Because there is no guarantee that a Namespace is private to an AbcBlock,
+/// they must never store any AbcBlock-internal information, particularly
+/// not the AbcURI.
+class Namespace
{
public:
/// Create an empty namespace
- asNamespace()
+ Namespace()
:
_parent(0),
_uri(0),
_prefix(0),
- _abcURI(0),
_classes(),
mRecursePrevent(false),
_private(false),
@@ -52,9 +58,9 @@
void markReachableResources() const { /* TODO */ }
/// Our parent (for protected)
- void setParent(asNamespace* p) { _parent = p; }
+ void setParent(Namespace* p) { _parent = p; }
- asNamespace* getParent() { return _parent; }
+ Namespace* getParent() { return _parent; }
/// Set the uri
void setURI(string_table::key name) { _uri = name; }
@@ -62,9 +68,6 @@
/// What is the Uri of the namespace?
string_table::key getURI() const { return _uri; }
- string_table::key getAbcURI() const {return _abcURI;}
- void setAbcURI(string_table::key n){ _abcURI = n; }
-
/// What is the XML prefix?
string_table::key getPrefix() const { return _prefix; }
@@ -111,12 +114,10 @@
private:
- asNamespace* _parent;
+ Namespace* _parent;
string_table::key _uri;
string_table::key _prefix;
- string_table::key _abcURI;
-
typedef std::map<string_table::key, asClass*> container;
container _classes;
mutable bool mRecursePrevent;
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp 2009-11-07 11:54:50 +0000
+++ b/libcore/TextField.cpp 2009-11-13 12:54:06 +0000
@@ -280,7 +280,7 @@
getObject(this)->set_prototype(proto);
as_object* ar = getGlobal(*getObject(this)).createArray();
- ar->callMethod(NSV::PROP_PUSH, getObject(this));
+ callMethod(ar, NSV::PROP_PUSH, getObject(this));
getObject(this)->set_member(NSV::PROP_uLISTENERS, ar);
#endif
registerTextVariable();
@@ -598,7 +598,7 @@
_selection = std::make_pair(start, end);
}
-bool
+void
TextField::notifyEvent(const event_id& ev)
{
switch (ev.id())
@@ -663,7 +663,7 @@
switch (c)
{
case key::BACKSPACE:
- if (isReadOnly()) return false;
+ if (isReadOnly()) return;
if (m_cursor > 0)
{
s.erase(m_cursor - 1, 1);
@@ -673,7 +673,7 @@
break;
case key::DELETEKEY:
- if (isReadOnly()) return false;
+ if (isReadOnly()) return;
if (_glyphcount > m_cursor)
{
s.erase(m_cursor, 1);
@@ -682,7 +682,7 @@
break;
case key::INSERT: // TODO
- if (isReadOnly()) return false;
+ if (isReadOnly()) return;
break;
case key::HOME:
@@ -799,7 +799,7 @@
break;
case key::ENTER:
- if (isReadOnly()) return false;
+ if (isReadOnly()) return;
if ( !multiline() )
break;
@@ -813,7 +813,7 @@
}
}
- if (isReadOnly()) return false;
+ if (isReadOnly()) return;
wchar_t t = static_cast<wchar_t>(
gnash::key::codeMap[c][key::ASCII]);
if (t != 0)
@@ -846,9 +846,8 @@
}
default:
- return false;
+ return;
};
- return true;
}
InteractiveObject*
@@ -2358,7 +2357,7 @@
// ASSetPropFlags is called on the TextField class.
as_object* null = 0;
- gl.callMethod(NSV::PROP_AS_SET_PROP_FLAGS, cl, null, 131);
+ callMethod(&gl, NSV::PROP_AS_SET_PROP_FLAGS, cl, null, 131);
}
void
@@ -2725,7 +2724,7 @@
TextField::onChanged()
{
as_object* obj = getObject(this);
- obj->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onChanged", obj);
+ callMethod(obj, NSV::PROP_BROADCAST_MESSAGE, "onChanged", obj);
}
/// This is called by movie_root when focus is applied to this TextField.
@@ -3776,7 +3775,7 @@
}
as_object* ar = getGlobal(fn).createArray();
- ar->callMethod(NSV::PROP_PUSH, obj);
+ callMethod(ar, NSV::PROP_PUSH, obj);
obj->set_member(NSV::PROP_uLISTENERS, ar);
return as_value();
}
@@ -3808,7 +3807,7 @@
// Finally ASSetPropFlags is called on the prototype.
Global_as& gl = getGlobal(o);
as_object* null = 0;
- gl.callMethod(NSV::PROP_AS_SET_PROP_FLAGS, &o, null, 131);
+ callMethod(&gl, NSV::PROP_AS_SET_PROP_FLAGS, &o, null, 131);
}
void
=== modified file 'libcore/TextField.h'
--- a/libcore/TextField.h 2009-11-04 20:00:18 +0000
+++ b/libcore/TextField.h 2009-11-13 12:54:06 +0000
@@ -124,7 +124,7 @@
virtual int getDefinitionVersion() const;
/// This function is called as a user-input handler
- bool notifyEvent(const event_id& id);
+ void notifyEvent(const event_id& id);
const std::string& getVariableName() const
{
=== modified file 'libcore/asClass.cpp'
--- a/libcore/asClass.cpp 2009-07-29 14:33:56 +0000
+++ b/libcore/asClass.cpp 2009-11-13 08:19:10 +0000
@@ -25,7 +25,7 @@
#include "VM.h"
#include "namedStrings.h"
#include "as_value.h"
-#include "asNamespace.h"
+#include "Namespace.h"
#include "Global_as.h"
#ifdef ENABLE_AVM2
@@ -37,7 +37,7 @@
#ifdef ENABLE_AVM2
bool
-asClass::addValue(string_table::key name, asNamespace *ns,
+asClass::addValue(string_table::key name, Namespace *ns,
boost::uint32_t slotId, asClass *type, as_value& val, bool isconst,
bool isstatic)
{
@@ -65,14 +65,14 @@
return true;
}
bool
-asClass::addMemberClass(string_table::key name, asNamespace *ns,
+asClass::addMemberClass(string_table::key name, Namespace *ns,
boost::uint32_t slotId, asClass *type, bool isstatic)
{
return addSlot(name, ns, slotId, type, isstatic);
}
bool
-asClass::addSlotFunction(string_table::key name, asNamespace *ns,
+asClass::addSlotFunction(string_table::key name, Namespace *ns,
boost::uint32_t slotId, asMethod *method, bool isstatic)
{
asClass a;
@@ -82,7 +82,7 @@
}
bool
-asClass::addSlot(string_table::key name, asNamespace* ns,
+asClass::addSlot(string_table::key name, Namespace* ns,
boost::uint32_t slotId, asClass* /*type*/, bool /*isstatic*/)
{
string_table::key nsname = ns ? ns->getURI() : 0;
@@ -98,7 +98,7 @@
}
bool
-asClass::addMethod(string_table::key name, asNamespace* /*ns*/,
+asClass::addMethod(string_table::key name, Namespace* /*ns*/,
asMethod* method, bool /*isstatic*/)
{
as_value val = new abc_function(method,
getVM(*_prototype).getMachine());
@@ -113,7 +113,7 @@
bool
-asClass::addGetter(string_table::key name, asNamespace *ns, asMethod *method,
+asClass::addGetter(string_table::key name, Namespace *ns, asMethod *method,
bool isstatic)
{
string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
@@ -134,7 +134,7 @@
}
bool
-asClass::addSetter(string_table::key name, asNamespace *ns, asMethod *method,
+asClass::addSetter(string_table::key name, Namespace *ns, asMethod *method,
bool isstatic)
{
string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
@@ -183,7 +183,7 @@
}
bool
-asClass::addValue(string_table::key name, asNamespace *ns, boost::uint32_t
slotId,
+asClass::addValue(string_table::key name, Namespace *ns, boost::uint32_t
slotId,
asClass *type, as_value& val, bool isconst, bool isstatic,
ClassHierarchy *CH)
{
@@ -196,7 +196,7 @@
}
bool
-asClass::addSlot(string_table::key name, asNamespace *ns, boost::uint32_t
slotId,
+asClass::addSlot(string_table::key name, Namespace *ns, boost::uint32_t slotId,
asClass *type, bool isstatic, ClassHierarchy *CH)
{
asBoundValue *bv = CH->newBoundValue();
@@ -207,7 +207,7 @@
}
bool
-asClass::addMethod(string_table::key name, asNamespace *ns, asMethod *method,
+asClass::addMethod(string_table::key name, Namespace *ns, asMethod *method,
bool isstatic)
{
if (!isstatic)
@@ -217,7 +217,7 @@
}
bool
-asClass::addMemberClass(string_table::key name, asNamespace *ns,
+asClass::addMemberClass(string_table::key name, Namespace *ns,
boost::uint32_t slotId, asClass *type, bool isstatic)
{
if (!isstatic)
@@ -227,7 +227,7 @@
// TODO: Figure out how this differs from addMethod
bool
-asClass::addSlotFunction(string_table::key name, asNamespace *ns,
+asClass::addSlotFunction(string_table::key name, Namespace *ns,
boost::uint32_t slotId, asMethod *method, bool isstatic)
{
if (!isstatic)
=== modified file 'libcore/asClass.h'
--- a/libcore/asClass.h 2009-07-03 08:19:37 +0000
+++ b/libcore/asClass.h 2009-11-13 08:19:10 +0000
@@ -39,7 +39,7 @@
namespace gnash {
class as_function;
-class asNamespace;
+class Namespace;
class asMethod;
class asClass;
typedef Property asBinding;
@@ -47,7 +47,7 @@
class asBoundAccessor;
class ClassHierarchy;
class Property;
-class asName;
+class MultiName;
class Machine;
class abc_function;
@@ -99,27 +99,27 @@
#ifdef ENABLE_AVM2
- bool addValue(string_table::key name, asNamespace *ns,
+ bool addValue(string_table::key name, Namespace *ns,
boost::uint32_t slotID, asClass *type, as_value& val,
bool isconst, bool isstatic);
- bool addSlot(string_table::key name, asNamespace *ns,
+ bool addSlot(string_table::key name, Namespace *ns,
boost::uint32_t slotID, asClass *type, bool isstatic);
- bool addMethod(string_table::key name, asNamespace *ns, asMethod
*method,
- bool isstatic);
-
- bool addGetter(string_table::key name, asNamespace *ns, asMethod
*method,
- bool isstatic);
-
- bool addSetter(string_table::key name, asNamespace *ns, asMethod
*method,
- bool isstatic);
-
- bool addMemberClass(string_table::key name, asNamespace *ns,
+ bool addMethod(string_table::key name, Namespace *ns, asMethod *method,
+ bool isstatic);
+
+ bool addGetter(string_table::key name, Namespace *ns, asMethod *method,
+ bool isstatic);
+
+ bool addSetter(string_table::key name, Namespace *ns, asMethod *method,
+ bool isstatic);
+
+ bool addMemberClass(string_table::key name, Namespace *ns,
boost::uint32_t slotID, asClass *type, bool isstatic);
// TODO: Figure out how this differs from addMethod
- bool addSlotFunction(string_table::key name, asNamespace *ns,
+ bool addSlotFunction(string_table::key name, Namespace *ns,
boost::uint32_t slotID, asMethod *method, bool isstatic);
/// Is the class final?
@@ -162,10 +162,10 @@
bool hasProtectedNs() const { return _protectedNs; }
/// Get the protected namespace.
- asNamespace *getProtectedNs() { return _protectedNs; }
+ Namespace *getProtectedNs() { return _protectedNs; }
/// Set the protected namespace.
- void setProtectedNs(asNamespace *n) { _protectedNs = n; }
+ void setProtectedNs(Namespace *n) { _protectedNs = n; }
string_table::key getName() const { return _name; }
@@ -209,8 +209,8 @@
return &i->second;
}
- asBinding* getGetBinding(as_value& v, asName& n);
- asBinding* getSetBinding(as_value& v, asName& n);
+ asBinding* getGetBinding(as_value& v, MultiName& n);
+ asBinding* getSetBinding(as_value& v, MultiName& n);
std::vector<abc::Trait> _traits;
#endif
@@ -243,7 +243,7 @@
bool _interface;
string_table::key _name;
std::list<asClass*> _interfaces;
- asNamespace* _protectedNs;
+ Namespace* _protectedNs;
asClass* _super;
asMethod* _constructor;
asMethod* _staticConstructor;
=== modified file 'libcore/asException.h'
--- a/libcore/asException.h 2009-05-14 10:30:48 +0000
+++ b/libcore/asException.h 2009-11-13 08:19:10 +0000
@@ -28,7 +28,7 @@
void setCatch(boost::uint32_t i) { mCatch = i; }
void catchAny() { mCatchAny = true; }
void setCatchType(asClass* p) { mCatchType = p; }
- void setNamespace(asNamespace* n) { _namespace = n; }
+ void setNamespace(Namespace* n) { _namespace = n; }
void setName(string_table::key name) { _name = name; }
private:
@@ -37,7 +37,7 @@
boost::uint32_t mCatch;
bool mCatchAny;
asClass *mCatchType;
- asNamespace *_namespace;
+ Namespace *_namespace;
string_table::key _name;
};
=== modified file 'libcore/asMethod.cpp'
--- a/libcore/asMethod.cpp 2009-08-21 12:29:40 +0000
+++ b/libcore/asMethod.cpp 2009-11-13 08:19:10 +0000
@@ -80,7 +80,7 @@
}
bool
-asMethod::addValue(string_table::key name, asNamespace *ns,
+asMethod::addValue(string_table::key name, Namespace *ns,
boost::uint32_t slotId, asClass *type, as_value& val, bool isconst)
{
Global_as* g = VM::get().getGlobal();
@@ -105,7 +105,7 @@
}
bool
-asMethod::addGetter(string_table::key name, asNamespace *ns, asMethod *method)
+asMethod::addGetter(string_table::key name, Namespace *ns, asMethod *method)
{
string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
@@ -123,7 +123,7 @@
}
bool
-asMethod::addSetter(string_table::key name, asNamespace *ns, asMethod *method)
+asMethod::addSetter(string_table::key name, Namespace *ns, asMethod *method)
{
string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
@@ -141,14 +141,14 @@
}
bool
-asMethod::addMemberClass(string_table::key name, asNamespace *ns,
+asMethod::addMemberClass(string_table::key name, Namespace *ns,
boost::uint32_t slotId, asClass *type)
{
return addSlot(name, ns, slotId, type);
}
bool
-asMethod::addSlot(string_table::key name, asNamespace* ns, boost::uint32_t
slotId,
+asMethod::addSlot(string_table::key name, Namespace* ns, boost::uint32_t
slotId,
asClass */*type*/)
{
string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
@@ -159,7 +159,7 @@
}
bool
-asMethod::addSlotFunction(string_table::key name, asNamespace *ns,
+asMethod::addSlotFunction(string_table::key name, Namespace *ns,
boost::uint32_t slotId, asMethod *method)
{
asClass a;
@@ -175,7 +175,7 @@
}
bool
-asMethod::addMethod(string_table::key /*name*/, asNamespace* /*ns*/, asMethod*
+asMethod::addMethod(string_table::key /*name*/, Namespace* /*ns*/, asMethod*
/*method*/)
{
// string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
=== modified file 'libcore/asMethod.h'
--- a/libcore/asMethod.h 2009-07-02 07:39:11 +0000
+++ b/libcore/asMethod.h 2009-11-13 08:19:10 +0000
@@ -120,22 +120,22 @@
CodeStream *getBody() { return _body; }
void setBody(CodeStream *b) { _body = b; }
- bool addValue(string_table::key name, asNamespace *ns,
+ bool addValue(string_table::key name, Namespace *ns,
boost::uint32_t slotID, asClass *type, as_value& val, bool
isconst);
- bool addSlot(string_table::key name, asNamespace *ns,
+ bool addSlot(string_table::key name, Namespace *ns,
boost::uint32_t slotID, asClass *type);
- bool addMethod(string_table::key name, asNamespace *ns, asMethod
*method);
-
- bool addGetter(string_table::key name, asNamespace *ns, asMethod
*method);
-
- bool addSetter(string_table::key name, asNamespace *ns, asMethod
*method);
-
- bool addMemberClass(string_table::key name, asNamespace *ns,
+ bool addMethod(string_table::key name, Namespace *ns, asMethod *method);
+
+ bool addGetter(string_table::key name, Namespace *ns, asMethod *method);
+
+ bool addSetter(string_table::key name, Namespace *ns, asMethod *method);
+
+ bool addMemberClass(string_table::key name, Namespace *ns,
boost::uint32_t slotID, asClass *type);
- bool addSlotFunction(string_table::key name, asNamespace *ns,
+ bool addSlotFunction(string_table::key name, Namespace *ns,
boost::uint32_t slotID, asMethod *method);
/// \brief
=== modified file 'libcore/as_environment.cpp'
--- a/libcore/as_environment.cpp 2009-11-06 07:54:33 +0000
+++ b/libcore/as_environment.cpp 2009-11-13 09:02:34 +0000
@@ -205,8 +205,7 @@
// Check the scope stack.
for (size_t i = scopeStack.size(); i > 0; --i)
{
- // const_cast needed due to non-const as_object::get_member
- as_object* obj = const_cast<as_object*>(scopeStack[i-1].get());
+ as_object* obj = scopeStack[i-1];
if (obj && obj->get_member(key, &val))
{
// Found the var in with context.
@@ -303,8 +302,7 @@
// Check the with-stack.
for (size_t i = scopeStack.size(); i > 0; --i)
{
- // const_cast needed due to non-const as_object::get_member
- as_object* obj = const_cast<as_object*>(scopeStack[i-1].get());
+ as_object* obj = scopeStack[i-1];
if (obj)
{
std::pair<bool,bool> ret = obj->delProperty(varkey);
@@ -350,8 +348,8 @@
std::string path;
std::string var;
//log_debug(_("set_variable(%s, %s)"), varname, val);
- if ( parse_path(varname, path, var) )
- {
+
+ if (parse_path(varname, path, var)) {
target = find_object(path, &scopeStack);
if (target)
{
@@ -385,48 +383,24 @@
}
VM& vm = _vm;
- int swfVersion = vm.getSWFVersion();
string_table& st = vm.getStringTable();
string_table::key varkey = st.find(varname);
- if ( swfVersion < 6 )
- {
- // in SWF5 and lower, scope stack should just contain 'with' elements
-
- // Check the with-stack.
- for (size_t i = scopeStack.size(); i > 0; --i)
- {
- // const_cast needed due to non-const as_object::get_member
- as_object* obj = const_cast<as_object*>(scopeStack[i-1].get());
- if (obj && obj->set_member(varkey, val, 0, true) )
- {
- return;
- }
- }
-
- // Check locals for setting them
- if ( setLocal(varname, val) ) return;
-
- }
- else // SWF >= 6
- {
-
- // Check the scope-stack (would include locals)
- //
- for (size_t i = scopeStack.size(); i > 0; --i)
- {
- // const_cast needed due to non-const as_object::get_member
- as_object* obj = const_cast<as_object*>(scopeStack[i-1].get());
- if (obj && obj->set_member(varkey, val, 0, true))
- {
- return;
- }
- }
-
- }
+ // in SWF5 and lower, scope stack should just contain 'with' elements
+
+ // Check the with-stack.
+ for (size_t i = scopeStack.size(); i > 0; --i)
+ {
+ as_object* obj = scopeStack[i-1];
+ if (obj && obj->set_member(varkey, val, 0, true)) {
+ return;
+ }
+ }
+
+ const int swfVersion = vm.getSWFVersion();
+ if (swfVersion < 6 && setLocal(varname, val)) return;
// TODO: shouldn't m_target be in the scope chain ?
- //assert(m_target);
if (m_target) getObject(m_target)->set_member(varkey, val);
else if (_original_target) {
getObject(_original_target)->set_member(varkey, val);
@@ -699,10 +673,7 @@
if (scopeStack) {
for (size_t i = scopeStack->size(); i > 0; --i)
{
- // const_cast needed due to non-const
- // as_object::get_member
- as_object* obj =
- const_cast<as_object*>((*scopeStack)[i-1].get());
+ as_object* obj = (*scopeStack)[i-1];
element = getElement(obj, subpartKey);
if (element) break;
@@ -893,7 +864,7 @@
const as_value& val)
{
Property* prop =
locals->getOwnProperty(_vm.getStringTable().find(varname));
- if ( ! prop ) return false;
+ if (!prop) return false;
prop->setValue(*locals, val);
return true;
}
=== modified file 'libcore/as_environment.h'
--- a/libcore/as_environment.h 2009-10-23 06:25:25 +0000
+++ b/libcore/as_environment.h 2009-11-13 08:18:42 +0000
@@ -45,7 +45,7 @@
public:
/// A stack of objects used for variables/members lookup
- typedef std::vector< boost::intrusive_ptr<as_object> > ScopeStack;
+ typedef std::vector<as_object*> ScopeStack;
typedef std::vector<as_value> Registers;
=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp 2009-11-04 13:37:17 +0000
+++ b/libcore/as_object.cpp 2009-11-13 12:29:42 +0000
@@ -45,7 +45,6 @@
#include <boost/algorithm/string/case_conv.hpp>
#include <utility> // for std::pair
#include "namedStrings.h"
-#include "asName.h"
#include "asClass.h"
@@ -420,7 +419,7 @@
log_debug("__resolve exists, calling with '%s'", undefinedName);
// TODO: we've found the property, don't search for it again.
- *val = callMethod(NSV::PROP_uuRESOLVE, undefinedName);
+ *val = callMethod(this, NSV::PROP_uuRESOLVE, undefinedName);
return true;
}
@@ -1143,96 +1142,102 @@
}
as_value
-as_object::callMethod(string_table::key methodName)
+callMethod(as_object* obj, string_table::key methodName)
{
+ if (!obj) return as_value();
+
as_value method;
- if (! get_member(methodName, &method))
+ if (!obj->get_member(methodName, &method))
{
return as_value();
}
- as_environment env(_vm);
+ as_environment env(getVM(*obj));
- return call_method0(method, env, this);
+ return call_method0(method, env, obj);
}
as_value
-as_object::callMethod(string_table::key methodName, const as_value& arg0)
+callMethod(as_object* obj, string_table::key methodName, const as_value& arg0)
{
+ if (!obj) return as_value();
as_value method;
- if (!get_member(methodName, &method))
+ if (!obj->get_member(methodName, &method))
{
return as_value();
}
- as_environment env(_vm);
+ as_environment env(getVM(*obj));
fn_call::Args args;
args += arg0;
- return call_method(method, env, this, args);
+ return call_method(method, env, obj, args);
}
as_value
-as_object::callMethod(string_table::key methodName, const as_value& arg0,
+callMethod(as_object* obj, string_table::key methodName, const as_value& arg0,
const as_value& arg1)
{
+ if (!obj) return as_value();
as_value method;
- if (! get_member(methodName, &method))
+ if (!obj->get_member(methodName, &method))
{
return as_value();
}
- as_environment env(_vm);
+ as_environment env(getVM(*obj));
fn_call::Args args;
args += arg0, arg1;
- return call_method(method, env, this, args);
+ return call_method(method, env, obj, args);
}
as_value
-as_object::callMethod(string_table::key methodName,
+callMethod(as_object* obj, string_table::key methodName,
const as_value& arg0, const as_value& arg1, const as_value& arg2)
{
+ if (!obj) return as_value();
as_value ret;
as_value method;
- if (! get_member(methodName, &method))
+ if (!obj->get_member(methodName, &method))
{
return ret;
}
- as_environment env(_vm);
+ as_environment env(getVM(*obj));
fn_call::Args args;
args += arg0, arg1, arg2;
- ret = call_method(method, env, this, args);
+ ret = call_method(method, env, obj, args);
return ret;
}
as_value
-as_object::callMethod(string_table::key methodName, const as_value& arg0,
+callMethod(as_object* obj, string_table::key methodName, const as_value& arg0,
const as_value& arg1, const as_value& arg2, const as_value& arg3)
{
+ if (!obj) return as_value();
as_value method;
- if (! get_member(methodName, &method))
+ if (!obj->get_member(methodName, &method))
{
return as_value();
}
- as_environment env(_vm);
+ as_environment env(getVM(*obj));
fn_call::Args args;
args += arg0, arg1, arg2, arg3;
- return call_method(method, env, this, args);
+ return call_method(method, env, obj, args);
}
=== modified file 'libcore/as_object.h'
--- a/libcore/as_object.h 2009-11-06 07:54:33 +0000
+++ b/libcore/as_object.h 2009-11-13 12:29:42 +0000
@@ -51,7 +51,6 @@
class event_id;
class movie_root;
class asClass;
- class asName;
class RunResources;
class Global_as;
}
@@ -674,29 +673,6 @@
///
as_value getMember(string_table::key name, string_table::key nsname = 0);
- /// Call a method of this object in an AS-compatible way
- //
- /// @param name
- /// Name of the method. Will be converted to lowercase
- /// if the current VM is initialized for a target
- /// up to SWF6.
- ///
- /// @param ...
- /// nargs as_value references
- ///
- /// @return value of the member (possibly undefined),
- /// or undefined if not found. Use get_member if you
- /// need to know wheter it was found or not.
- ///
- as_value callMethod(string_table::key name);
- DSOEXPORT as_value callMethod(string_table::key name, const as_value&
arg0);
- as_value callMethod(string_table::key name, const as_value& arg0,
- const as_value& arg1);
- as_value callMethod(string_table::key name, const as_value& arg0,
- const as_value& arg1, const as_value& arg2);
- as_value callMethod(string_table::key name, const as_value& arg0,
- const as_value& arg1, const as_value& arg2, const as_value& arg3);
-
/// Delete a property of this object, unless protected from deletion.
//
/// This function does *not* recurse in this object's prototype.
@@ -1213,6 +1189,30 @@
return relay;
}
+/// Call a method of this object in an AS-compatible way
+//
+/// @param name
+/// Name of the method. Will be converted to lowercase
+/// if the current VM is initialized for a target
+/// up to SWF6.
+///
+/// @param ...
+/// nargs as_value references
+///
+/// @return value of the member (possibly undefined),
+/// or undefined if not found. Use get_member if you
+/// need to know wheter it was found or not.
+///
+as_value callMethod(as_object* obj, string_table::key name);
+as_value callMethod(as_object* obj, string_table::key name,
+ const as_value& arg0);
+as_value callMethod(as_object* obj, string_table::key name,
+ const as_value& arg0, const as_value& arg1);
+as_value callMethod(as_object* obj, string_table::key name,
+ const as_value& arg0, const as_value& arg1, const as_value& arg2);
+as_value callMethod(as_object* obj, string_table::key name,
+ const as_value& arg0, const as_value& arg1, const as_value& arg2,
+ const as_value& arg3);
/// Get the VM from an as_object
VM& getVM(const as_object& o);
=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp 2009-11-05 18:34:12 +0000
+++ b/libcore/as_value.cpp 2009-11-13 12:29:42 +0000
@@ -1663,11 +1663,6 @@
}
-/// Chad: Document this
-as_value::as_value(asNamespace &)
-{
-}
-
/// Instantiate this value from an AMF element
as_value::as_value(const amf::Element& el)
:
@@ -2026,7 +2021,7 @@
{
return false;
}
- array->callMethod(NSV::PROP_PUSH, arrayElement);
+ callMethod(array, NSV::PROP_PUSH, arrayElement);
}
ret.set_as_object(array);
=== modified file 'libcore/as_value.h'
--- a/libcore/as_value.h 2009-10-14 09:29:00 +0000
+++ b/libcore/as_value.h 2009-11-13 07:50:48 +0000
@@ -50,8 +50,7 @@
class as_function;
class MovieClip;
class DisplayObject;
- class asNamespace;
- class asName;
+ class Namespace;
class SimpleBuffer;
}
namespace amf {
@@ -169,9 +168,6 @@
/// Construct a NUMBER value
as_value(double val);
- /// Chad: Document this
- as_value(asNamespace &);
-
/// Construct a value from an AMF element
as_value(const amf::Element& el);
=== modified file 'libcore/asobj/Array_as.cpp'
--- a/libcore/asobj/Array_as.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/Array_as.cpp 2009-11-13 12:29:42 +0000
@@ -134,7 +134,7 @@
public:
PushToArray(as_object& obj) : _obj(obj) {}
void operator()(const as_value& val) {
- _obj.callMethod(NSV::PROP_PUSH, val);
+ callMethod(&_obj, NSV::PROP_PUSH, val);
}
private:
as_object& _obj;
@@ -985,7 +985,7 @@
// Push removed elements to the new array.
for (size_t i = 0; i < remove; ++i) {
const size_t key = getKey(fn, start + i);
- ret->callMethod(NSV::PROP_PUSH, array->getMember(key));
+ callMethod(ret, NSV::PROP_PUSH, array->getMember(key));
}
// Shift elements in 'this' array by simple assignment, not delete
@@ -1382,7 +1382,7 @@
continue;
}
}
- newarray->callMethod(NSV::PROP_PUSH, fn.arg(i));
+ callMethod(newarray, NSV::PROP_PUSH, fn.arg(i));
}
return as_value(newarray);
@@ -1446,7 +1446,7 @@
// Use the arguments as initializers.
for (size_t i = 0; i < fn.nargs; i++) {
- ao->callMethod(NSV::PROP_PUSH, fn.arg(i));
+ callMethod(ao, NSV::PROP_PUSH, fn.arg(i));
}
@@ -1513,7 +1513,7 @@
{
for (std::vector<indexed_as_value>::const_iterator it = elems.begin();
it != elems.end(); ++it) {
- o.callMethod(NSV::PROP_PUSH, it->vec_index);
+ callMethod(&o, NSV::PROP_PUSH, it->vec_index);
}
}
=== modified file 'libcore/asobj/AsBroadcaster.cpp'
--- a/libcore/asobj/AsBroadcaster.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/AsBroadcaster.cpp 2009-11-13 12:29:42 +0000
@@ -138,7 +138,7 @@
// The function returned by ASnative(101, 12) is attached, even though
// this may not exist (e.g. if _global.ASnative is altered)
- const as_value& asn = gl.callMethod(NSV::PROP_AS_NATIVE, 101, 12);
+ const as_value& asn = callMethod(&gl, NSV::PROP_AS_NATIVE, 101, 12);
o.set_member(NSV::PROP_BROADCAST_MESSAGE, asn);
// This corresponds to "_listeners = [];", which is different from
@@ -236,12 +236,13 @@
as_value
asbroadcaster_addListener(const fn_call& fn)
{
- boost::intrusive_ptr<as_object> obj = fn.this_ptr;
+
+ as_object* obj = ensure<ValidThis>(fn);
as_value newListener; assert(newListener.is_undefined());
if ( fn.nargs ) newListener = fn.arg(0);
- obj->callMethod(NSV::PROP_REMOVE_LISTENER, newListener);
+ callMethod(obj, NSV::PROP_REMOVE_LISTENER, newListener);
as_value listenersValue;
@@ -275,7 +276,7 @@
// We checked is_object() above.
assert(listeners);
- listeners->callMethod(NSV::PROP_PUSH, newListener);
+ callMethod(listeners, NSV::PROP_PUSH, newListener);
return as_value(true);
@@ -313,8 +314,7 @@
return as_value(false); // TODO: check this
}
- boost::intrusive_ptr<as_object> listeners =
- listenersValue.to_object(getGlobal(fn));
+ as_object* listeners = listenersValue.to_object(getGlobal(fn));
assert(listeners);
as_value listenerToRemove;
@@ -335,7 +335,7 @@
as_value el =
listeners->getMember(st.find(s.str()));
if (el.equals(listenerToRemove)) {
- listeners->callMethod(NSV::PROP_SPLICE, s.str(), 1);
+ callMethod(listeners, NSV::PROP_SPLICE, s.str(), 1);
return as_value(true);
}
++i;
=== modified file 'libcore/asobj/Color_as.cpp'
--- a/libcore/asobj/Color_as.cpp 2009-10-27 09:44:54 +0000
+++ b/libcore/asobj/Color_as.cpp 2009-11-13 12:29:42 +0000
@@ -249,7 +249,7 @@
Global_as& gl = getGlobal(fn);
as_object* null = 0;
- gl.callMethod(NSV::PROP_AS_SET_PROP_FLAGS, obj, null, 7);
+ callMethod(&gl, NSV::PROP_AS_SET_PROP_FLAGS, obj, null, 7);
return as_value();
}
=== modified file 'libcore/asobj/Globals.cpp'
--- a/libcore/asobj/Globals.cpp 2009-11-12 10:47:18 +0000
+++ b/libcore/asobj/Globals.cpp 2009-11-13 14:22:50 +0000
@@ -53,6 +53,7 @@
#include "flash/display/DisplayObject_as.h"
#include "flash/display/Stage_as.h"
#include "flash/display/MovieClip_as.h"
+#include "flash/display/Shape_as.h"
#include "flash/display/Sprite_as.h"
#include "flash/display/Bitmap_as.h"
#include "flash/events/Event_as.h"
@@ -589,6 +590,8 @@
NSV::NS_FLASH_SYSTEM, 1))
// Display classes
+ (N(shape_class_init, st.find("Shape"), NSV::CLASS_DISPLAYOBJECT,
+ NSV::NS_FLASH_DISPLAY, 3))
(N(displayobject_class_init, NSV::CLASS_DISPLAYOBJECT,
NSV::CLASS_EVENTDISPATCHER, NSV::NS_FLASH_DISPLAY, 3))
(N(interactiveobject_class_init, NSV::CLASS_INTERACTIVEOBJECT,
=== modified file 'libcore/asobj/LoadVars_as.cpp'
--- a/libcore/asobj/LoadVars_as.cpp 2009-10-23 12:51:22 +0000
+++ b/libcore/asobj/LoadVars_as.cpp 2009-11-13 12:29:42 +0000
@@ -98,7 +98,7 @@
if (src.is_undefined()) {
thisPtr->set_member(NSV::PROP_LOADED, false);
- thisPtr->callMethod(NSV::PROP_ON_LOAD, false);
+ callMethod(thisPtr, NSV::PROP_ON_LOAD, false);
}
else {
VM& vm = getVM(fn);
@@ -106,8 +106,8 @@
string_table::key decodeKey = st.find("decode");
thisPtr->set_member(NSV::PROP_LOADED, true);
- thisPtr->callMethod(decodeKey, src);
- thisPtr->callMethod(NSV::PROP_ON_LOAD, true);
+ callMethod(thisPtr, decodeKey, src);
+ callMethod(thisPtr, NSV::PROP_ON_LOAD, true);
}
return as_value();
@@ -140,9 +140,9 @@
if (it != vars.begin()) o << "&";
const std::string& var =
- global->callMethod(NSV::PROP_ESCAPE, it->first).to_string();
+ callMethod(global, NSV::PROP_ESCAPE, it->first).to_string();
const std::string& val =
- global->callMethod(NSV::PROP_ESCAPE, it->second).to_string();
+ callMethod(global, NSV::PROP_ESCAPE, it->second).to_string();
o << var << "=" << val;
}
return as_value(o.str());
=== modified file 'libcore/asobj/LoadableObject.cpp'
--- a/libcore/asobj/LoadableObject.cpp 2009-11-15 10:22:25 +0000
+++ b/libcore/asobj/LoadableObject.cpp 2009-11-15 14:33:03 +0000
@@ -84,7 +84,7 @@
SimpleBuffer& buf = v.buf;
if (!lt) {
- obj->callMethod(NSV::PROP_ON_DATA, as_value());
+ callMethod(obj, NSV::PROP_ON_DATA, as_value());
return true;
}
@@ -96,7 +96,7 @@
// We must still call onData if the stream is in error condition, e.g.
// when an HTTP 404 error is returned.
if (lt->bad()) {
- obj->callMethod(NSV::PROP_ON_DATA, as_value());
+ callMethod(obj, NSV::PROP_ON_DATA, as_value());
return true;
}
@@ -123,7 +123,7 @@
// got nothing, won't bother BOFs of nulls
if (buf.empty()) {
- obj->callMethod(NSV::PROP_ON_DATA, as_value());
+ callMethod(obj, NSV::PROP_ON_DATA, as_value());
return true;
}
@@ -151,7 +151,7 @@
// destroyed as soon as we return though...
// NOTE: Another data copy here !
- obj->callMethod(NSV::PROP_ON_DATA, dataVal);
+ callMethod(obj, NSV::PROP_ON_DATA, dataVal);
return true;
@@ -211,7 +211,7 @@
// Both elements apparently must be strings, or we move onto the
// next pair.
if (!val.is_string() || !_key.is_string()) return;
- _target.callMethod(NSV::PROP_PUSH, _key, val);
+ callMethod(&_target, NSV::PROP_PUSH, _key, val);
}
private:
@@ -323,7 +323,7 @@
return as_value();
}
- array->callMethod(NSV::PROP_PUSH, name, val);
+ callMethod(array, NSV::PROP_PUSH, name, val);
return as_value();
}
=== modified file 'libcore/asobj/MovieClipLoader.cpp'
--- a/libcore/asobj/MovieClipLoader.cpp 2009-11-10 00:59:35 +0000
+++ b/libcore/asobj/MovieClipLoader.cpp 2009-11-13 12:29:42 +0000
@@ -22,7 +22,6 @@
#endif
#include "smart_ptr.h" // GNASH_USE_GC
-#include "action.h" // for call_method
#include "as_value.h"
#include "as_object.h" // for inheritance
#include "movie_root.h"
@@ -82,7 +81,7 @@
AsBroadcaster::initialize(*proto);
as_object* null = 0;
- gl.callMethod(NSV::PROP_AS_SET_PROP_FLAGS, proto, null, 1027);
+ callMethod(&gl, NSV::PROP_AS_SET_PROP_FLAGS, proto, null, 1027);
where.init_member(getName(uri), cl, as_object::DefaultFlags,
getNamespace(uri));
@@ -158,7 +157,7 @@
Global_as& gl = getGlobal(fn);
as_object* array = gl.createArray();
- array->callMethod(NSV::PROP_PUSH, ptr);
+ callMethod(array, NSV::PROP_PUSH, ptr);
ptr->set_member(NSV::PROP_uLISTENERS, array);
ptr->set_member_flags(NSV::PROP_uLISTENERS, as_object::DefaultFlags);
return as_value();
=== modified file 'libcore/asobj/Object.cpp'
--- a/libcore/asobj/Object.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/Object.cpp 2009-11-13 12:29:42 +0000
@@ -527,8 +527,8 @@
as_value
object_toLocaleString(const fn_call& fn)
{
- boost::intrusive_ptr<as_object> obj = fn.this_ptr;
- return obj->callMethod(NSV::PROP_TO_STRING);
+ as_object* obj = ensure<ValidThis>(fn);
+ return callMethod(obj, NSV::PROP_TO_STRING);
}
} // anonymous namespace
=== modified file 'libcore/asobj/Selection_as.cpp'
--- a/libcore/asobj/Selection_as.cpp 2009-11-04 13:37:17 +0000
+++ b/libcore/asobj/Selection_as.cpp 2009-11-13 12:29:42 +0000
@@ -65,7 +65,7 @@
// All properties are protected using ASSetPropFlags.
Global_as& gl = getGlobal(where);
as_object* null = 0;
- gl.callMethod(NSV::PROP_AS_SET_PROP_FLAGS, o, null, 7);
+ callMethod(&gl, NSV::PROP_AS_SET_PROP_FLAGS, o, null, 7);
}
void
=== modified file 'libcore/asobj/String_as.cpp'
--- a/libcore/asobj/String_as.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/String_as.cpp 2009-11-13 12:29:42 +0000
@@ -245,7 +245,7 @@
if (fn.nargs == 0)
{
// Condition 1:
- array->callMethod(NSV::PROP_PUSH, str);
+ callMethod(array, NSV::PROP_PUSH, str);
return as_value(array);
}
@@ -257,7 +257,7 @@
(version >= 6 && fn.arg(0).is_undefined()))
{
// Condition 2:
- array->callMethod(NSV::PROP_PUSH, str);
+ callMethod(array, NSV::PROP_PUSH, str);
return as_value(array);
}
@@ -281,7 +281,7 @@
{
// Condition 3 (plus a shortcut if the string itself
// is empty).
- array->callMethod(NSV::PROP_PUSH, str);
+ callMethod(array, NSV::PROP_PUSH, str);
return as_value(array);
}
}
@@ -293,7 +293,7 @@
// If the string itself is empty, SWF6 returns a 0-sized
// array only if the delimiter is also empty. Otherwise
// it returns an array with 1 empty element.
- if (delimiterSize) array->callMethod(NSV::PROP_PUSH, str);
+ if (delimiterSize) callMethod(array, NSV::PROP_PUSH, str);
return as_value(array);
}
@@ -314,7 +314,7 @@
if (delim.empty()) {
for (size_t i = 0, e = std::min<size_t>(wstr.size(), max);
i < e; ++i) {
- array->callMethod(NSV::PROP_PUSH,
+ callMethod(array, NSV::PROP_PUSH,
utf8::encodeCanonicalString(wstr.substr(i, 1),
version));
}
return as_value(array);
@@ -328,7 +328,7 @@
while (num < max) {
pos = wstr.find(delim, pos);
- array->callMethod(NSV::PROP_PUSH, utf8::encodeCanonicalString(
+ callMethod(array, NSV::PROP_PUSH, utf8::encodeCanonicalString(
wstr.substr(prevpos, pos - prevpos), version));
if (pos == std::wstring::npos) break;
=== modified file 'libcore/asobj/flash/display/MovieClip_as.cpp'
--- a/libcore/asobj/flash/display/MovieClip_as.cpp 2009-11-09 23:07:58
+0000
+++ b/libcore/asobj/flash/display/MovieClip_as.cpp 2009-11-13 12:29:42
+0000
@@ -905,9 +905,9 @@
as_value val;
if (fn.nargs > 1) {
- val = getObject(dobj)->callMethod(NSV::PROP_METH, fn.arg(1));
+ val = callMethod(getObject(dobj), NSV::PROP_METH, fn.arg(1));
}
- else val = getObject(dobj)->callMethod(NSV::PROP_METH);
+ else val = callMethod(getObject(dobj), NSV::PROP_METH);
if (fn.nargs < 1) // url
{
@@ -967,9 +967,9 @@
as_value val;
if (fn.nargs > 1)
{
- val = obj->callMethod(NSV::PROP_METH, fn.arg(1));
+ val = callMethod(obj, NSV::PROP_METH, fn.arg(1));
}
- else val = obj->callMethod(NSV::PROP_METH);
+ else val = callMethod(obj, NSV::PROP_METH);
if (fn.nargs < 1) // url
{
@@ -1130,9 +1130,9 @@
as_value val;
if (fn.nargs > 2)
{
- val = movieclip->callMethod(NSV::PROP_METH, fn.arg(2));
+ val = callMethod(movieclip, NSV::PROP_METH, fn.arg(2));
}
- else val = movieclip->callMethod(NSV::PROP_METH);
+ else val = callMethod(movieclip, NSV::PROP_METH);
switch (fn.nargs)
{
@@ -1205,7 +1205,7 @@
return as_value(MovieClip::METHOD_NONE);
}
- as_value lc = o->callMethod(NSV::PROP_TO_LOWER_CASE);
+ as_value lc = callMethod(o, NSV::PROP_TO_LOWER_CASE);
std::string s = lc.to_string();
=== modified file 'libcore/asobj/flash/media/Camera_as.cpp'
--- a/libcore/asobj/flash/media/Camera_as.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/flash/media/Camera_as.cpp 2009-11-13 12:29:42 +0000
@@ -536,7 +536,7 @@
as_object* data = gl.createArray();
for (size_t i = 0; i < size; ++i) {
- data->callMethod(NSV::PROP_PUSH, names[i]);
+ callMethod(data, NSV::PROP_PUSH, names[i]);
}
return as_value(data);
=== modified file 'libcore/asobj/flash/media/Microphone_as.cpp'
--- a/libcore/asobj/flash/media/Microphone_as.cpp 2009-10-23 06:25:25
+0000
+++ b/libcore/asobj/flash/media/Microphone_as.cpp 2009-11-13 12:29:42
+0000
@@ -424,7 +424,7 @@
as_object* data = gl.createArray();
for (size_t i=0; i < size; ++i) {
- data->callMethod(NSV::PROP_PUSH, vect[i]);
+ callMethod(data, NSV::PROP_PUSH, vect[i]);
}
if ( fn.nargs == 0 ) // getter
=== modified file 'libcore/asobj/flash/media/Sound_as.cpp'
--- a/libcore/asobj/flash/media/Sound_as.cpp 2009-11-06 07:54:33 +0000
+++ b/libcore/asobj/flash/media/Sound_as.cpp 2009-11-13 12:29:42 +0000
@@ -204,7 +204,7 @@
stopProbeTimer();
// dispatch onSoundComplete
- owner().callMethod(NSV::PROP_ON_SOUND_COMPLETE);
+ callMethod(&owner(), NSV::PROP_ON_SOUND_COMPLETE);
}
}
else
=== modified file 'libcore/asobj/flash/net/NetConnection_as.cpp'
--- a/libcore/asobj/flash/net/NetConnection_as.cpp 2009-10-23 06:25:25
+0000
+++ b/libcore/asobj/flash/net/NetConnection_as.cpp 2009-11-13 12:29:42
+0000
@@ -435,7 +435,7 @@
log_debug("Calling NetConnection.%s(%s)",
headerName, tmp);
#endif
- _nc.owner().callMethod(key, tmp);
+ callMethod(&_nc.owner(), key, tmp);
}
}
}
@@ -517,7 +517,7 @@
reply_start = b - reply.data();
// if actionscript specified a callback object,
call it
- boost::intrusive_ptr<as_object> callback =
pop_callback(id);
+ as_object* callback = pop_callback(id);
if (callback) {
string_table::key methodKey;
@@ -537,7 +537,7 @@
log_debug("calling onResult callback");
#endif
// FIXME check if above line can fail and we
have to react
- callback->callMethod(methodKey,
reply_as_value);
+ callMethod(callback, methodKey,
reply_as_value);
#ifdef GNASH_DEBUG_REMOTING
log_debug("callback called");
#endif
@@ -743,7 +743,7 @@
o->init_member("code", info.first, flags);
o->init_member("level", info.second, flags);
- owner().callMethod(NSV::PROP_ON_STATUS, o);
+ callMethod(&owner(), NSV::PROP_ON_STATUS, o);
}
=== modified file 'libcore/asobj/flash/net/NetStream_as.cpp'
--- a/libcore/asobj/flash/net/NetStream_as.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/flash/net/NetStream_as.cpp 2009-11-13 12:29:42 +0000
@@ -143,7 +143,7 @@
string_table::key func = getStringTable(owner()).find(funcname);
- owner().callMethod(func, as_value(info_obj));
+ callMethod(&owner(), func, as_value(info_obj));
}
@@ -167,7 +167,7 @@
// Must be a new object every time.
as_object* o = getStatusObject(code);
- owner().callMethod(NSV::PROP_ON_STATUS, o);
+ callMethod(&owner(), NSV::PROP_ON_STATUS, o);
}
void
@@ -1913,7 +1913,7 @@
}
log_debug("Calling %s(%s)", funcName, arg);
- thisPtr.callMethod(funcKey, arg);
+ callMethod(&thisPtr, funcKey, arg);
}
} // anonymous namespace
=== modified file 'libcore/asobj/flash/net/XMLSocket_as.cpp'
--- a/libcore/asobj/flash/net/XMLSocket_as.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/flash/net/XMLSocket_as.cpp 2009-11-13 12:29:42 +0000
@@ -304,14 +304,14 @@
// If connection failed, notify onConnect and stop callback.
// This means update() will not be called again until
// XMLSocket.connect() is invoked.
- owner().callMethod(NSV::PROP_ON_CONNECT, false);
+ callMethod(&owner(), NSV::PROP_ON_CONNECT, false);
getRoot(owner()).removeAdvanceCallback(this);
return;
}
// Connection succeeded.
_ready = true;
- owner().callMethod(NSV::PROP_ON_CONNECT, true);
+ callMethod(&owner(), NSV::PROP_ON_CONNECT, true);
}
// Now the connection is established we can receive data.
@@ -554,7 +554,7 @@
// The built-in function calls:
//
// this.onXML(new XML(src));
- fn.this_ptr->callMethod(NSV::PROP_ON_XML, xml);
+ callMethod(fn.this_ptr, NSV::PROP_ON_XML, xml);
return as_value();
}
=== modified file 'libcore/asobj/flash/text/TextSnapshot_as.cpp'
--- a/libcore/asobj/flash/text/TextSnapshot_as.cpp 2009-10-23 06:25:25
+0000
+++ b/libcore/asobj/flash/text/TextSnapshot_as.cpp 2009-11-13 12:29:42
+0000
@@ -302,7 +302,7 @@
el->init_member("matrix_tx", xpos);
el->init_member("matrix_ty", ypos);
- ri.callMethod(NSV::PROP_PUSH, el);
+ callMethod(&ri, NSV::PROP_PUSH, el);
++pos;
x += k->advance;
=== modified file 'libcore/asobj/flash/ui/ContextMenu_as.cpp'
--- a/libcore/asobj/flash/ui/ContextMenu_as.cpp 2009-10-26 08:29:00 +0000
+++ b/libcore/asobj/flash/ui/ContextMenu_as.cpp 2009-11-13 12:29:42 +0000
@@ -68,8 +68,8 @@
void operator()(const as_value& val) {
Global_as& gl = getGlobal(_target);
as_object* obj = val.to_object(gl);
- as_value cp = obj ? obj->callMethod(_c) : as_value();
- _target.callMethod(NSV::PROP_PUSH, cp);
+ as_value cp = callMethod(obj, _c);
+ callMethod(&_target, NSV::PROP_PUSH, cp);
}
private:
const string_table::key _c;
=== modified file 'libcore/asobj/flash/ui/Keyboard_as.cpp'
--- a/libcore/asobj/flash/ui/Keyboard_as.cpp 2009-11-12 10:47:18 +0000
+++ b/libcore/asobj/flash/ui/Keyboard_as.cpp 2009-11-13 12:29:42 +0000
@@ -27,7 +27,6 @@
#include "fn_call.h"
#include "Global_as.h"
#include "movie_root.h"
-#include "action.h" // for call_method
#include "VM.h" // for registerNative
#include "builtin_function.h" // need builtin_function
#include "NativeFunction.h"
@@ -171,7 +170,7 @@
// All properties are protected using ASSetPropFlags.
Global_as& gl = getGlobal(where);
as_object* null = 0;
- gl.callMethod(NSV::PROP_AS_SET_PROP_FLAGS, key, null, 7);
+ callMethod(&gl, NSV::PROP_AS_SET_PROP_FLAGS, key, null, 7);
}
} // gnash namespace
=== modified file 'libcore/asobj/flash/xml/XMLDocument_as.cpp'
--- a/libcore/asobj/flash/xml/XMLDocument_as.cpp 2009-10-23 09:36:32
+0000
+++ b/libcore/asobj/flash/xml/XMLDocument_as.cpp 2009-11-13 12:29:42
+0000
@@ -875,12 +875,12 @@
if (!src.is_undefined()) {
thisPtr->set_member(NSV::PROP_LOADED, true);
- thisPtr->callMethod(NSV::PROP_PARSE_XML, src);
- thisPtr->callMethod(NSV::PROP_ON_LOAD, true);
+ callMethod(thisPtr, NSV::PROP_PARSE_XML, src);
+ callMethod(thisPtr, NSV::PROP_ON_LOAD, true);
}
else {
thisPtr->set_member(NSV::PROP_LOADED, false);
- thisPtr->callMethod(NSV::PROP_ON_LOAD, false);
+ callMethod(thisPtr, NSV::PROP_ON_LOAD, false);
}
return as_value();
=== modified file 'libcore/asobj/flash/xml/XMLNode_as.cpp'
--- a/libcore/asobj/flash/xml/XMLNode_as.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/flash/xml/XMLNode_as.cpp 2009-11-13 12:29:42 +0000
@@ -383,7 +383,7 @@
std::string escaped(nodeValue);
XMLDocument_as::escape(escaped);
const std::string& val = encode ?
- global->callMethod(NSV::PROP_ESCAPE, escaped).to_string() :
+ callMethod(global, NSV::PROP_ESCAPE, escaped).to_string() :
escaped;
xmlout << val;
@@ -932,7 +932,7 @@
it != itEnd; ++it )
{
boost::intrusive_ptr<XMLNode_as> node = *it;
- ary->callMethod(NSV::PROP_PUSH, node.get());
+ callMethod(ary, NSV::PROP_PUSH, node.get());
}
return as_value(ary);
=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp 2009-11-12 21:00:31 +0000
+++ b/libcore/movie_root.cpp 2009-11-15 14:33:03 +0000
@@ -540,7 +540,7 @@
as_object* stage = getBuiltinObject(*this, NSV::PROP_iSTAGE);
if (stage) {
log_debug("notifying Stage listeners about a resize");
- stage->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onResize");
+ callMethod(stage, NSV::PROP_BROADCAST_MESSAGE, "onResize");
}
}
@@ -584,10 +584,10 @@
// A stack limit like that is hardly of any use, but could be used
// maliciously to crash Gnash.
if (down) {
- key->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onKeyDown");
+ callMethod(key, NSV::PROP_BROADCAST_MESSAGE, "onKeyDown");
}
else {
- key->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onKeyUp");
+ callMethod(key, NSV::PROP_BROADCAST_MESSAGE, "onKeyUp");
}
}
catch (ActionLimitException &e)
@@ -1074,7 +1074,7 @@
// Can throw an action limit exception if the stack limit is 0 or
1.
// A stack limit like that is hardly of any use, but could be used
// maliciously to crash Gnash.
- mouseObj->callMethod(NSV::PROP_BROADCAST_MESSAGE,
+ callMethod(mouseObj, NSV::PROP_BROADCAST_MESSAGE,
event.functionName());
}
catch (ActionLimitException &e) {
@@ -1131,14 +1131,14 @@
/// A valid focus must have an associated object.
assert(getObject(from));
- getObject(from)->callMethod(NSV::PROP_ON_KILL_FOCUS, getObject(to));
+ callMethod(getObject(from), NSV::PROP_ON_KILL_FOCUS, getObject(to));
}
_currentFocus = to;
if (to) {
assert(getObject(to));
- getObject(to)->callMethod(NSV::PROP_ON_SET_FOCUS, getObject(from));
+ callMethod(getObject(to), NSV::PROP_ON_SET_FOCUS, getObject(from));
}
as_object* sel = getBuiltinObject(*this, NSV::CLASS_SELECTION);
@@ -1146,7 +1146,7 @@
// Notify Selection listeners with previous and new focus as arguments.
// Either argument may be null.
if (sel) {
- sel->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onSetFocus",
+ callMethod(sel, NSV::PROP_BROADCAST_MESSAGE, "onSetFocus",
getObject(from), getObject(to));
}
@@ -1341,7 +1341,7 @@
as_object* stage = getBuiltinObject(*this, NSV::PROP_iSTAGE);
if (stage) {
log_debug("notifying Stage listeners about a resize");
- stage->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onResize");
+ callMethod(stage, NSV::PROP_BROADCAST_MESSAGE, "onResize");
}
}
}
@@ -1355,7 +1355,7 @@
if (stage) {
log_debug("notifying Stage listeners about fullscreen state");
const bool fs = _displayState == DISPLAYSTATE_FULLSCREEN;
- stage->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onFullScreen", fs);
+ callMethod(stage, NSV::PROP_BROADCAST_MESSAGE, "onFullScreen", fs);
}
if (!_interfaceHandler) return; // No registered callback
@@ -2052,7 +2052,6 @@
}
-
bool
movie_root::isLevelTarget(const std::string& name, unsigned int& levelno)
{
=== modified file 'libcore/parser/AbcBlock.cpp'
--- a/libcore/parser/AbcBlock.cpp 2009-09-29 08:43:51 +0000
+++ b/libcore/parser/AbcBlock.cpp 2009-11-13 14:21:56 +0000
@@ -196,7 +196,7 @@
log_error(_("ABC: Trait name must be fully qualified."));
return false;
}
- asName multiname = pBlock->_multinamePool[name];
+ MultiName multiname = pBlock->_multinamePool[name];
_name = pBlock->_multinamePool[name].getABCName();
_globalName = pBlock->_multinamePool[name].getGlobalName();
_namespace = pBlock->_multinamePool[name].getNamespace();
@@ -388,7 +388,7 @@
}
void
-AbcBlock::setMultinameNames(asName *n, string_table::key ABCName)
+AbcBlock::setMultinameNames(MultiName *n, string_table::key ABCName)
{
n->setABCName(ABCName);
@@ -401,9 +401,8 @@
}
void
-AbcBlock::setNamespaceURI(asNamespace *ns, string_table::key ABCName)
+AbcBlock::setNamespaceURI(Namespace *ns, string_table::key ABCName)
{
- ns->setAbcURI(ABCName);
std::string name = _stringPool[ABCName];
string_table::key global_key = _stringTable->find(name);
ns->setURI(global_key);
@@ -416,7 +415,7 @@
const std::string::size_type pos = className.rfind(".");
- asName a;
+ MultiName a;
const std::string& nsstr = (pos != std::string::npos) ?
className.substr(0, pos) : "";
@@ -426,19 +425,12 @@
a.setGlobalName(_stringTable->find(clstr));
- for (std::vector<asNamespace*>::iterator i = _namespacePool.begin();
+ for (std::vector<Namespace*>::iterator i = _namespacePool.begin();
i != _namespacePool.end(); ++i) {
- 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) {
+ const size_t key = (*i)->getURI();
+
+ if (key == _stringTable->find(nsstr)) {
a.setNamespace(*i);
break;
}
@@ -449,7 +441,7 @@
}
asClass*
-AbcBlock::locateClass(asName& m)
+AbcBlock::locateClass(MultiName& m)
{
asClass* found = 0;
@@ -460,7 +452,7 @@
}
if (m.namespaceSet() && !m.namespaceSet()->empty())
{
- std::vector<asNamespace*>::const_iterator i;
+ std::vector<Namespace*>::const_iterator i;
for (i = m.namespaceSet()->begin(); i !=
m.namespaceSet()->end(); ++i) {
found = (*i)->getClass(m.getGlobalName());
@@ -594,7 +586,7 @@
else
{
string_table::key gn = _stringTable->find(_stringPool[nameIndex]);
- asNamespace *n = mCH->findNamespace(gn);
+ Namespace *n = mCH->findNamespace(gn);
if (!n) n = mCH->addNamespace(gn);
_namespacePool[i] = n;
}
@@ -648,7 +640,7 @@
}
for (unsigned int i = 1; i < count; ++i)
{
- asName::Kind kind = static_cast<asName::Kind>(_stream->read_u8());
+ MultiName::Kind kind =
static_cast<MultiName::Kind>(_stream->read_u8());
boost::uint32_t ns = 0;
boost::uint32_t name = 0;
boost::uint32_t nsset = 0;
@@ -658,8 +650,8 @@
// Read, but don't upper validate until after the switch.
switch (kind)
{
- case asName::KIND_Qname:
- case asName::KIND_QnameA:
+ case MultiName::KIND_Qname:
+ case MultiName::KIND_QnameA:
ns = _stream->read_V32();
check_multiname_namespace(ns);
name = _stream->read_V32();
@@ -668,26 +660,26 @@
ns, name, _stringPool[name]);
break;
- case asName::KIND_RTQname:
- case asName::KIND_RTQnameA:
+ case MultiName::KIND_RTQname:
+ case MultiName::KIND_RTQnameA:
name = _stream->read_V32();
check_multiname_name(name);
break;
- case asName::KIND_RTQnameL:
- case asName::KIND_RTQnameLA:
+ case MultiName::KIND_RTQnameL:
+ case MultiName::KIND_RTQnameLA:
break;
- case asName::KIND_Multiname:
- case asName::KIND_MultinameA:
+ case MultiName::KIND_Multiname:
+ case MultiName::KIND_MultinameA:
name = _stream->read_V32();
check_multiname_name(name);
nsset = _stream->read_V32();
check_multiname_namespaceset(nsset);
break;
- case asName::KIND_MultinameL:
- case asName::KIND_MultinameLA:
+ case MultiName::KIND_MultinameL:
+ case MultiName::KIND_MultinameLA:
nsset = _stream->read_V32();
check_multiname_namespaceset(nsset);
break;
@@ -960,7 +952,7 @@
return false;
}
- asName& multiname = _multinamePool[index];
+ MultiName& multiname = _multinamePool[index];
// This must be a QName.
if (!multiname.isQName()) {
@@ -1390,7 +1382,7 @@
AbcBlock::update_global_name(unsigned int multiname_index)
{
- asName* multiname = &_multinamePool[multiname_index];
+ MultiName* multiname = &_multinamePool[multiname_index];
string_table::key new_key =
_stringTable->find(_stringPool[multiname->getABCName()], false);
multiname->setGlobalName(new_key);
=== modified file 'libcore/parser/AbcBlock.h'
--- a/libcore/parser/AbcBlock.h 2009-07-03 08:19:37 +0000
+++ b/libcore/parser/AbcBlock.h 2009-11-13 08:19:10 +0000
@@ -22,8 +22,8 @@
#define GNASH_ABC_BLOCK_H
#include "string_table.h"
-#include "asName.h"
-#include "asNamespace.h"
+#include "MultiName.h"
+#include "Namespace.h"
#include "as_value.h"
#include <vector>
@@ -68,7 +68,7 @@
as_value _value;
string_table::key _name;
string_table::key _globalName;
- asNamespace* _namespace;
+ Namespace* _namespace;
asMethod* _method;
bool _valueSet;
@@ -224,11 +224,11 @@
POOL_NULL = 0x0C
};
- typedef std::vector<asNamespace*> NamespaceSet;
+ typedef std::vector<Namespace*> NamespaceSet;
AbcBlock();
- asClass* locateClass(asName &m);
+ asClass* locateClass(MultiName &m);
asClass* locateClass(const std::string& className);
@@ -272,7 +272,7 @@
return _methods[i];
}
- asName multinamePoolAt(size_t i) const {
+ MultiName multinamePoolAt(size_t i) const {
checkBounds(i, _multinamePool);
return _multinamePool[i];
}
@@ -282,7 +282,7 @@
return _classes[i];
}
- asNamespace* namespacePoolAt(size_t i) const {
+ Namespace* namespacePoolAt(size_t i) const {
checkBounds(i, _namespacePool);
return _namespacePool[i];
}
@@ -316,19 +316,19 @@
void check_multiname_namespaceset(boost::uint32_t nsset);
- void setMultinameNames(asName *n,string_table::key ABCName);
+ void setMultinameNames(MultiName *n,string_table::key ABCName);
- void setNamespaceURI(asNamespace *ns,string_table::key ABCName);
+ void setNamespaceURI(Namespace *ns,string_table::key ABCName);
std::vector<boost::int32_t> _integerPool;
std::vector<boost::uint32_t> _uIntegerPool;
std::vector<double> _doublePool;
std::vector<std::string> _stringPool;
std::vector<string_table::key> _stringPoolTableIDs;
- std::vector<asNamespace*> _namespacePool;
+ std::vector<Namespace*> _namespacePool;
std::vector<NamespaceSet> _namespaceSetPool;
std::vector<asMethod*> _methods;
- std::vector<asName> _multinamePool;
+ std::vector<MultiName> _multinamePool;
std::vector<asClass*> _classes;
std::vector<asClass*> _scripts;
std::vector<abc::Trait*> _traits;
=== modified file 'libcore/swf_function.cpp'
--- a/libcore/swf_function.cpp 2009-11-06 07:54:33 +0000
+++ b/libcore/swf_function.cpp 2009-11-13 12:29:42 +0000
@@ -49,13 +49,6 @@
as_object* caller);
}
-swf_function::~swf_function()
-{
-#ifndef GNASH_USE_GC
- if ( _properties ) _properties->drop_ref();
-#endif
-}
-
swf_function::swf_function(const action_buffer& ab, as_environment& env,
size_t start, const ScopeStack& scopeStack)
:
@@ -158,7 +151,7 @@
///
TargetGuard targetGuard(m_env, target, orig_target);
- if (m_is_function2 == false)
+ if (!m_is_function2)
{
// Conventional function.
@@ -370,7 +363,7 @@
as_object* arguments = getGlobal(fn).createArray();
for (size_t i = 0; i < fn.nargs; ++i) {
- arguments->callMethod(NSV::PROP_PUSH, fn.arg(i));
+ callMethod(arguments, NSV::PROP_PUSH, fn.arg(i));
}
arguments->init_member(NSV::PROP_CALLEE, &callee);
=== modified file 'libcore/swf_function.h'
--- a/libcore/swf_function.h 2009-10-14 18:14:45 +0000
+++ b/libcore/swf_function.h 2009-11-13 08:19:10 +0000
@@ -42,47 +42,10 @@
class swf_function : public as_function
{
-private:
-
- /// Action buffer containing the function definition
- const action_buffer& m_action_buffer;
-
- /// @@ might need some kind of ref count here, but beware cycles
- as_environment& m_env;
-
- typedef std::vector< boost::intrusive_ptr<as_object> > ScopeStack;
-
- /// Scope stack on function definition.
- ScopeStack _scopeStack;
-
- /// \brief
- /// Offset within the action_buffer where
- /// start of the function is found.
- size_t m_start_pc;
-
- /// Length of the function within the action_buffer
- //
- /// This is currently expressed in bytes as the
- /// action_buffer is just a blog of memory corresponding
- /// to a DoAction block
- size_t m_length;
-
- struct arg_spec
- {
- int m_register;
- std::string m_name;
- };
- std::vector<arg_spec> m_args;
- bool m_is_function2;
- boost::uint8_t m_local_register_count;
-
- /// used by function2 to control implicit arg register assignments
- //
- /// See
http://sswf.sourceforge.net/SWFalexref.html#action_declare_function2
- boost::uint16_t m_function2_flags;
-
public:
+ typedef std::vector<as_object*> ScopeStack;
+
enum SWFDefineFunction2Flags
{
/// Bind one register to "this"
@@ -111,15 +74,14 @@
/// Bind one register to "_global"
//
- /// TODO: check this. See
http://sswf.sourceforge.net/SWFalexref.html#action_declare_function2
+ /// TODO: check this.
+ /// See:
+ ///
http://sswf.sourceforge.net/SWFalexref.html#action_declare_function2
/// Looks like flags would look swapped
PRELOAD_GLOBAL = 256 // 0x100
};
-
- ~swf_function();
-
/// \brief
/// Create an ActionScript function as defined in an
/// action_buffer starting at offset 'start'
@@ -127,6 +89,8 @@
swf_function(const action_buffer& ab, as_environment& env, size_t start,
const ScopeStack& with_stack);
+ virtual ~swf_function() {}
+
const ScopeStack& getScopeStack() const
{
return _scopeStack;
@@ -152,13 +116,19 @@
return m_is_function2;
}
- void set_is_function2() { m_is_function2 = true; }
-
- void set_local_register_count(boost::uint8_t ct) {
assert(m_is_function2); m_local_register_count = ct; }
-
- void set_function2_flags(boost::uint16_t flags) {
assert(m_is_function2); m_function2_flags = flags; }
-
- void add_arg(int arg_register, const char* name)
+ void set_is_function2() { m_is_function2 = true; }
+
+ void set_local_register_count(boost::uint8_t ct) {
+ assert(m_is_function2);
+ m_local_register_count = ct;
+ }
+
+ void set_function2_flags(boost::uint16_t flags) {
+ assert(m_is_function2);
+ m_function2_flags = flags;
+ }
+
+ void add_arg(int arg_register, const char* name)
{
assert(arg_register == 0 || m_is_function2 == true);
m_args.resize(m_args.size() + 1);
@@ -166,12 +136,10 @@
m_args.back().m_name = PROPNAME(name);
}
- void set_length(int len);
+ void set_length(int len);
/// Dispatch.
- as_value operator()(const fn_call& fn);
-
- //void lazy_create_properties();
+ as_value operator()(const fn_call& fn);
#ifdef GNASH_USE_GC
/// Mark reachable resources. Override from as_function.
@@ -181,6 +149,44 @@
///
virtual void markReachableResources() const;
#endif // GNASH_USE_GC
+
+private:
+
+ /// Action buffer containing the function definition
+ const action_buffer& m_action_buffer;
+
+ /// @@ might need some kind of ref count here, but beware cycles
+ as_environment& m_env;
+
+ /// Scope stack on function definition.
+ ScopeStack _scopeStack;
+
+ /// \brief
+ /// Offset within the action_buffer where
+ /// start of the function is found.
+ size_t m_start_pc;
+
+ /// Length of the function within the action_buffer
+ //
+ /// This is currently expressed in bytes as the
+ /// action_buffer is just a blog of memory corresponding
+ /// to a DoAction block
+ size_t m_length;
+
+ struct arg_spec
+ {
+ int m_register;
+ std::string m_name;
+ };
+ std::vector<arg_spec> m_args;
+ bool m_is_function2;
+ boost::uint8_t m_local_register_count;
+
+ /// used by function2 to control implicit arg register assignments
+ //
+ /// See
http://sswf.sourceforge.net/SWFalexref.html#action_declare_function2
+ boost::uint16_t m_function2_flags;
+
};
=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2009-11-04 20:01:38 +0000
+++ b/libcore/vm/ASHandlers.cpp 2009-11-13 13:43:08 +0000
@@ -2614,12 +2614,20 @@
std::string function_name;
// Let's consider it a as a string and lookup the function.
+ //
+ // Note: this produces the correct behaviour: Any as_value, including
+ // null or numbers, are converted to a string and the corresponding
+ // function is called. If it is undefined, nothing happens, even if
+ // there is a function called 'undefined'.
+ //
+ // Using to_string_versioned() would produce the wrong behaviour.
+ //
+ // In all cases, even undefined, the specified number of arguments
+ // is dropped from the stack.
const std::string& funcname = env.pop().to_string();
as_object* this_ptr = thread.getThisPointer();
as_object* super = NULL;
- //log_debug("ActionCallFunction: thread.getThisPointer returned %s @ %p",
typeName(*this_ptr), (void*)this_ptr);
-
as_value function = thread.getVariable(funcname, &this_ptr);
if (!function.is_object()) {
=== modified file 'libcore/vm/ActionExec.cpp'
--- a/libcore/vm/ActionExec.cpp 2009-10-27 09:44:54 +0000
+++ b/libcore/vm/ActionExec.cpp 2009-11-13 08:18:42 +0000
@@ -228,11 +228,10 @@
}
// Cleanup any expired "with" blocks.
- while ( ! _withStack.empty() && pc >= _withStack.back().end_pc() )
- {
+ while (!_withStack.empty() && pc >= _withStack.back().end_pc()) {
// Drop last stack element
- assert(_withStack.back().object() == _scopeStack.back().get());
+ assert(_withStack.back().object() == _scopeStack.back());
_withStack.pop_back();
// hopefully nothing gets after the 'with' stack.
@@ -833,7 +832,7 @@
as_object*
ActionExec::getThisPointer()
{
- return _func ? _this_ptr.get() : getObject(env.get_original_target());
+ return _func ? _this_ptr : getObject(env.get_original_target());
}
} // end of namespace gnash
=== modified file 'libcore/vm/ActionExec.h'
--- a/libcore/vm/ActionExec.h 2009-10-09 06:16:57 +0000
+++ b/libcore/vm/ActionExec.h 2009-11-13 08:18:42 +0000
@@ -180,7 +180,7 @@
const swf_function* _func;
/// The 'this' pointer, if this is a function call
- boost::intrusive_ptr<as_object> _this_ptr;
+ as_object* _this_ptr;
/// Stack size at start of execution
size_t _initialStackSize;
=== modified file 'libcore/vm/ExecutableCode.h'
--- a/libcore/vm/ExecutableCode.h 2009-11-09 23:57:39 +0000
+++ b/libcore/vm/ExecutableCode.h 2009-11-13 12:29:42 +0000
@@ -287,7 +287,7 @@
virtual void execute()
{
- _target->callMethod(_name, _arg1, _arg2);
+ callMethod(_target, _name, _arg1, _arg2);
}
#ifdef GNASH_USE_GC
=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp 2009-10-14 14:41:51 +0000
+++ b/libcore/vm/Machine.cpp 2009-11-13 12:29:42 +0000
@@ -110,7 +110,7 @@
}
}
-inline asNamespace*
+inline Namespace*
pool_namespace(boost::uint32_t index, AbcBlock *pool)
{
if (!pool) throw ASException();
@@ -148,12 +148,12 @@
}
// Don't make this a reference or you'll taint the pool.
-inline asName
+inline MultiName
pool_name(boost::uint32_t index, AbcBlock* pool)
{
if (!pool) throw ASException();
try {
- asName multiname = pool->multinamePoolAt(index);
+ MultiName multiname = pool->multinamePoolAt(index);
return multiname;
}
catch (std::range_error& e) {
@@ -431,7 +431,7 @@
case SWF::ABC_ACTION_GETSUPER:
{
// Get the name.
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
// Finish it, if necessary.
_stack.drop(completeName(a));
// Get the target object.
@@ -462,7 +462,7 @@
case SWF::ABC_ACTION_SETSUPER:
{
// Get and finish the name.
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
as_value vobj = _stack.pop(); // The value
_stack.drop(completeName(a));
@@ -1143,11 +1143,18 @@
/// ns -- Namespace object from namespace_pool[index]
case SWF::ABC_ACTION_PUSHNAMESPACE:
{
- asNamespace *ns = pool_namespace(mStream->read_V32(),
+#if 0
+ Namespace *ns = pool_namespace(mStream->read_V32(),
mPoolObject);
_stack.grow(1);
+
+ // Here we should probably construct a Namespace object,
+ // but there is no need to do it using as_value's
+ // constructor.
+
_stack.top(0) = *ns;
break;
+#endif
}
/// 0x32 ABC_ACTION_HASNEXT2
@@ -1341,7 +1348,7 @@
case SWF::ABC_ACTION_CALLSUPER:
case SWF::ABC_ACTION_CALLSUPERVOID:
{
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
boost::uint32_t argc = mStream->read_V32();
int dropsize = completeName(a);
ENSURE_OBJECT(_stack.top(argc + dropsize));
@@ -1391,7 +1398,7 @@
case SWF::ABC_ACTION_CALLPROPVOID:
{
as_value result;
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
boost::uint32_t argc = mStream->read_V32();
fn_call::Args args;
@@ -1547,7 +1554,7 @@
{
print_stack();
as_environment env = as_environment(_vm);
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
boost::uint32_t argc = mStream->read_V32();
fn_call::Args args;
@@ -1652,7 +1659,7 @@
as_object* arr = _global->createArray();
while (i--) {
- arr->callMethod(NSV::PROP_PUSH, pop_stack());
+ callMethod(arr, NSV::PROP_PUSH, pop_stack());
}
push_stack(as_value(arr));
break;
@@ -1745,7 +1752,7 @@
/// descendants of a class.
case SWF::ABC_ACTION_GETDESCENDANTS:
{
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
//as_value &v = _stack.top(0);
ENSURE_OBJECT(v);
_stack.drop(1);
@@ -1779,7 +1786,7 @@
case SWF::ABC_ACTION_FINDPROPSTRICT:
case SWF::ABC_ACTION_FINDPROPERTY:
{
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
if (a.isRuntime()) {
_stack.drop(completeName(a));
}
@@ -1810,7 +1817,7 @@
/// def -- The definition of the name at name_id.
case SWF::ABC_ACTION_FINDDEF:
{
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
// The name is expected to be complete.
// TODO
break;
@@ -1823,7 +1830,7 @@
/// + 0x66 (ABC_ACTION_GETPROPERTY)
case SWF::ABC_ACTION_GETLEX:
{
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
as_value val = find_prop_strict(a);
@@ -1856,10 +1863,10 @@
string_table::key ns = 0;
string_table::key name = 0;
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
// TODO: If multiname is runtime we need to also pop
// namespace and name values off the stack.
- if (a.flags() == asName::KIND_MultinameL) {
+ if (a.flags() == MultiName::KIND_MultinameL) {
log_abc("SETPROPERTY: name is a late runtime "
"multiname");
as_value nameValue = pop_stack();
@@ -1946,10 +1953,10 @@
{
string_table::key ns = 0;
string_table::key name = 0;
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
// TODO: If multiname is runtime we need to also pop
// namespace and name values of the stack.
- if (a.flags() == asName::KIND_MultinameL) {
+ if (a.flags() == MultiName::KIND_MultinameL) {
as_value nameValue = pop_stack();
name = mST.find(nameValue.to_string());
}
@@ -1998,7 +2005,7 @@
case SWF::ABC_ACTION_INITPROPERTY:
{
boost::uint32_t index = mStream->read_V32();
- asName a = pool_name(index, mPoolObject);
+ MultiName a = pool_name(index, mPoolObject);
as_value v = pop_stack();
// TODO: If multiname is a runtime mutiname we need to also
// pop name and namespace values.
@@ -2025,7 +2032,7 @@
/// else False.
case SWF::ABC_ACTION_DELETEPROPERTY:
{
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
_stack.drop(completeName(a));
as_object* obj = _stack.top(0).to_object(*_global);
@@ -2037,7 +2044,7 @@
}
// Look in the global namespace if there is none specified.
- asNamespace* n = a.getNamespace();
+ Namespace* n = a.getNamespace();
const string_table::key ns = n ? n->getURI() : 0;
const string_table::key prop = a.getGlobalName();
@@ -2266,7 +2273,7 @@
case SWF::ABC_ACTION_COERCE:
{
// TODO: handle runtime names?
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
as_value value = _stack.top(0);
log_abc("COERCE: object for conversion is %s, "
@@ -2322,7 +2329,7 @@
/// otherwise Null
case SWF::ABC_ACTION_ASTYPE:
{
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
as_value value = pop_stack();
//TODO: Make sure the value is of the correct type;
push_stack(value);
@@ -2685,7 +2692,7 @@
/// truth -- Truth of "obj is of the type given in
(resolve)'name_id'"
case SWF::ABC_ACTION_ISTYPE:
{
- asName a = pool_name(mStream->read_V32(), mPoolObject);
+ MultiName a = pool_name(mStream->read_V32(), mPoolObject);
_stack.drop(completeName(a));
// TODO: Implement it.
//_stack.top(0).set_bool(_stack.top(0).conforms_to(a.getABCName()));
@@ -2898,7 +2905,7 @@
}
void
-Machine::getMember(asClass* pDefinition, asName& name,
+Machine::getMember(asClass* pDefinition, MultiName& name,
as_value& instance)
{
if (!instance.is_object())
@@ -2922,7 +2929,7 @@
}
void
-Machine::setMember(asClass *pDefinition, asName& name, as_value& instance,
+Machine::setMember(asClass *pDefinition, MultiName& name, as_value& instance,
as_value& newvalue)
{
if (!instance.is_object())
@@ -2954,7 +2961,7 @@
}
int
-Machine::completeName(asName& name, int offset)
+Machine::completeName(MultiName& name, int offset)
{
// TODO: implement this properly.
@@ -3243,7 +3250,7 @@
}
as_value
-Machine::find_prop_strict(asName multiname)
+Machine::find_prop_strict(MultiName multiname)
{
log_abc("Looking for property %2% in namespace %1%",
=== modified file 'libcore/vm/Machine.h'
--- a/libcore/vm/Machine.h 2009-08-20 06:55:15 +0000
+++ b/libcore/vm/Machine.h 2009-11-13 08:19:10 +0000
@@ -34,7 +34,7 @@
class DisplayObject;
class as_object;
class AbcBlock;
- class asName;
+ class MultiName;
class Property;
class CodeStream;
}
@@ -102,7 +102,7 @@
/// @return
/// The number of stack elements used by the name.
/// At present, always 0, 1, or 2. These are not dropped.
- int completeName(asName& name, int initial = 0);
+ int completeName(MultiName& name, int initial = 0);
/// Given a value v, find the class object of the superclass of v.
///
@@ -132,7 +132,7 @@
/// This returns the value, but on the stack.
/// (Since the return value is not known until after control has left
/// the caller of this, it's impossible to return a meaningful value.
- void getMember(asClass* pDefinition, asName& name, as_value& source);
+ void getMember(asClass* pDefinition, MultiName& name, as_value& source);
/// Set a member in an object.
///
@@ -150,9 +150,9 @@
///
/// @return
/// Nothing.
- void setMember(asClass*, asName&, as_value& target, as_value& val);
+ void setMember(asClass*, MultiName&, as_value& target, as_value& val);
- asBinding* findProperty(asName&) { return NULL; }
+ asBinding* findProperty(MultiName&) { return NULL; }
void execute();
@@ -255,7 +255,7 @@
unsigned int mScopeTotalSize;
bool mReturn;
CodeStream *mStream;
- asNamespace *mDefaultXMLNamespace;
+ Namespace *mDefaultXMLNamespace;
as_object *mCurrentScope;
as_value *mGlobalReturn;
as_object *mThis;
@@ -282,7 +282,7 @@
void saveState();
void restoreState();
- as_value find_prop_strict(asName multiname);
+ as_value find_prop_strict(MultiName multiname);
void print_stack();
@@ -355,7 +355,7 @@
string_table& mST;
- asNamespace* mDefaultXMLNamespace;
+ Namespace* mDefaultXMLNamespace;
as_object* mCurrentScope;
as_object* mGlobalScope;
as_object* mDefaultThis;
=== modified file 'libcore/vm/Makefile.am'
--- a/libcore/vm/Makefile.am 2009-05-24 22:25:59 +0000
+++ b/libcore/vm/Makefile.am 2009-11-13 08:19:10 +0000
@@ -57,7 +57,7 @@
noinst_HEADERS = \
ASHandlers.h \
CodeStream.h \
- asName.h \
+ MultiName.h \
ActionExec.h \
ExecutableCode.h \
action.h \
@@ -74,7 +74,7 @@
if ENABLE_AVM2
noinst_HEADERS += \
- asName.h \
+ MultiName.h \
CodeStream.h \
Machine.h \
$(NULL)
=== renamed file 'libcore/vm/asName.h' => 'libcore/vm/MultiName.h'
--- a/libcore/vm/asName.h 2009-05-14 11:23:13 +0000
+++ b/libcore/vm/MultiName.h 2009-11-13 08:19:10 +0000
@@ -22,10 +22,18 @@
namespace gnash {
class as_object;
-class asNamespace;
+class Namespace;
class Property;
-class asName
+
+/// An MultiName represents a single ABC multiname.
+//
+/// All MultiNames are internal to a single AbcBlock. Most are created during
+/// parsing, though the Machine can also create them for the lifetime of
+/// a single script run (which corresponds to an AbcBlock).
+//
+/// This means it is possible to store internal ABC URI of multiname here.
+class MultiName
{
public:
@@ -43,7 +51,7 @@
KIND_MultinameLA = 0x1C
};
- asName()
+ MultiName()
:
_flags(0),
_namespaceSet(0),
@@ -69,8 +77,8 @@
bool isQName() { return _flags & FLAG_QNAME; }
void setQName() { _flags |= FLAG_QNAME; }
- void setNamespace(asNamespace *ns) { _namespace = ns; }
- asNamespace* getNamespace() const { return _namespace; }
+ void setNamespace(Namespace *ns) { _namespace = ns; }
+ Namespace* getNamespace() const { return _namespace; }
string_table::key getABCName() const { return _abcName; }
void setABCName(string_table::key n) { _abcName = n;}
@@ -84,11 +92,11 @@
Property* findProperty();
- void namespaceSet(std::vector<asNamespace*>* v) {
+ void namespaceSet(std::vector<Namespace*>* v) {
_namespaceSet = v;
}
- const std::vector<asNamespace*>* namespaceSet() const {
+ const std::vector<Namespace*>* namespaceSet() const {
return _namespaceSet;
}
@@ -105,11 +113,11 @@
boost::uint8_t _flags;
- std::vector<asNamespace*>* _namespaceSet;
+ std::vector<Namespace*>* _namespaceSet;
string_table::key _abcName;
string_table::key _globalName;
- asNamespace* _namespace;
+ Namespace* _namespace;
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11625: Rename some AS3 files and classes and add some documentation.,
Benjamin Wolsey <=