[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/as_object.cpp server/as_...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/as_object.cpp server/as_... |
Date: |
Sat, 06 Oct 2007 09:54:55 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/10/06 09:54:55
Modified files:
. : ChangeLog
server : as_object.cpp as_object.h
server/asobj : AsBroadcaster.cpp
Log message:
* server/as_object.{cpp,h}: add init_member and init_property
based on string_table::key
* server/asobj/AsBroadcaster.cpp (initialize): use string_table
keys when already available.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4555&r2=1.4556
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.73&r2=1.74
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/AsBroadcaster.cpp?cvsroot=gnash&r1=1.7&r2=1.8
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4555
retrieving revision 1.4556
diff -u -b -r1.4555 -r1.4556
--- ChangeLog 6 Oct 2007 09:53:44 -0000 1.4555
+++ ChangeLog 6 Oct 2007 09:54:54 -0000 1.4556
@@ -1,3 +1,10 @@
+2007-10-06 Sandro Santilli <address@hidden>
+
+ * server/as_object.{cpp,h}: add init_member and init_property
+ based on string_table::key
+ * server/asobj/AsBroadcaster.cpp (initialize): use string_table
+ keys when already available.
+
2007-10-06 Tomas Groth Christensen <address@hidden>
* libmedia/sdl/AudioDecoderFfmpeg.cpp: Release allocate data on errors.
Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- server/as_object.cpp 2 Oct 2007 12:17:46 -0000 1.67
+++ server/as_object.cpp 6 Oct 2007 09:54:54 -0000 1.68
@@ -240,68 +240,72 @@
void
as_object::init_member(const std::string& key1, const as_value& val, int flags)
{
-
- //log_msg(_("Setting member %s (SWF version:%d)"), key.c_str(),
vm.getSWFVersion());
-
- VM& vm = _vm;
-
- if ( vm.getSWFVersion() < 7 )
+ if ( _vm.getSWFVersion() < 7 )
{
std::string keylower = key1;
- boost::to_lower(keylower, vm.getLocale());
+ boost::to_lower(keylower, _vm.getLocale());
+
+ init_member(_vm.getStringTable().find(keylower), val, flags);
- // Set (or create) a SimpleProperty
- if (! _members.setValue(_vm.getStringTable().find(keylower),
val, *this) )
- {
- log_error(_("Attempt to initialize read-only property
``%s''"
- " (%s) on object ``%p'' twice"),
- keylower.c_str(), key1.c_str(), (void*)this);
- // We shouldn't attempt to initialize a member twice,
should we ?
- assert(0);
- }
- // TODO: optimize this, don't scan again !
- _members.setFlags(_vm.getStringTable().find(keylower), flags,
0);
}
else
{
+ init_member(_vm.getStringTable().find(key1), val, flags);
+ }
+}
+
+void
+as_object::init_member(string_table::key key, const as_value& val, int flags)
+{
+ //log_debug(_("Initializing member %s for object %p"),
_vm.getStringTable().value(key).c_str(), (void*) this);
+
// Set (or create) a SimpleProperty
- if ( ! _members.setValue(_vm.getStringTable().find(key1), val,
*this) )
+ if (! _members.setValue(key, val, *this) )
{
log_error(_("Attempt to initialize read-only property
``%s''"
" on object ``%p'' twice"),
- key1.c_str(), (void*)this);
+ _vm.getStringTable().value(key).c_str(), (void*)this);
// We shouldn't attempt to initialize a member twice,
should we ?
assert(0);
}
// TODO: optimize this, don't scan again !
- _members.setFlags(_vm.getStringTable().find(key1), flags, 0);
- }
+ _members.setFlags(key, flags, 0);
}
void
as_object::init_property(const std::string& key, as_function& getter,
as_function& setter, int flags)
{
- bool success;
if ( _vm.getSWFVersion() < 7 )
{
std::string name = key;
boost::to_lower(name, _vm.getLocale());
- success =
_members.addGetterSetter(_vm.getStringTable().find(name), getter, setter);
- //log_msg(_("Initialized property '%s'"), name.c_str());
- // TODO: optimize this, don't scan again !
- _members.setFlags(_vm.getStringTable().find(name), flags, 0);
+ string_table::key k = _vm.getStringTable().find(name);
+ init_property(k, getter, setter, flags);
}
else
{
- success =
_members.addGetterSetter(_vm.getStringTable().find(key), getter, setter);
- //log_msg(_("Initialized property '%s'"), key.c_str());
- // TODO: optimize this, don't scan again !
- _members.setFlags(_vm.getStringTable().find(key), flags, 0);
+ string_table::key k = _vm.getStringTable().find(key);
+ init_property(k, getter, setter, flags);
}
+}
+
+void
+as_object::init_property(string_table::key key, as_function& getter,
+ as_function& setter, int flags)
+{
+ bool success;
+ success = _members.addGetterSetter(key, getter, setter);
+
// We shouldn't attempt to initialize a property twice, should we ?
assert(success);
+
+ //log_msg(_("Initialized property '%s'"), name.c_str());
+
+ // TODO: optimize this, don't scan again !
+ _members.setFlags(key, flags, 0);
+
}
bool
Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -b -r1.73 -r1.74
--- server/as_object.h 27 Sep 2007 22:20:06 -0000 1.73
+++ server/as_object.h 6 Oct 2007 09:54:54 -0000 1.74
@@ -194,19 +194,16 @@
{
return set_member_default(name, val);
}
+
#ifdef NEW_KEY_LISTENER_LIST_DESIGN
virtual bool on_event(const event_id& id );
#endif
- /// Initialize a member value
+
+ /// Initialize a member value by string
//
- /// This method has to be used by built-in classes initialization
- /// (VM initialization in general) as will avoid to scan the
- /// inheritance chain and perform lowercase conversion when
- /// VM version is initialized at versions < 7.
- ///
- /// By dedfault, members initialized by calling this function will
- /// be protected from deletion and not shown in enumeration.
- /// These flags can be explicitly set using the third argument.
+ /// This is just a wrapper around the other init_member method
+ /// used as a trampoline to avoid changing all classes to
+ /// use string_table::key directly.
///
/// @param name
/// Name of the member.
@@ -221,13 +218,34 @@
///
void init_member(const std::string& name, const as_value& val, int
flags=as_prop_flags::dontDelete|as_prop_flags::dontEnum);
- /// \brief
- /// Initialize a getter/setter property
+ /// Initialize a member value by key
//
/// This method has to be used by built-in classes initialization
/// (VM initialization in general) as will avoid to scan the
- /// inheritance chain and perform lowercase conversion when
- /// VM version is initialized at versions < 7.
+ /// inheritance chain.
+ ///
+ /// By default, members initialized by calling this function will
+ /// be protected from deletion and not shown in enumeration.
+ /// These flags can be explicitly set using the third argument.
+ ///
+ /// @param key
+ /// Member key.
+ ///
+ /// @param val
+ /// Value to assign to the member.
+ ///
+ /// @param flags
+ /// Flags for the new member. By default dontDelete and dontEnum.
+ /// See as_prop_flags::Flags.
+ ///
+ void init_member(string_table::key key, const as_value& val, int
flags=as_prop_flags::dontDelete|as_prop_flags::dontEnum);
+
+ /// \brief
+ /// Initialize a getter/setter property by name
+ //
+ /// This is just a wrapper around the other init_property method
+ /// used as a trampoline to avoid changing all classes to
+ /// use string_table::key directly.
///
/// @param key
/// Name of the property.
@@ -249,6 +267,32 @@
as_function& setter, int
flags=as_prop_flags::dontDelete|as_prop_flags::dontEnum);
/// \brief
+ /// Initialize a getter/setter property by key
+ //
+ /// This method has to be used by built-in classes initialization
+ /// (VM initialization in general) as will avoid to scan the
+ /// inheritance chain.
+ ///
+ /// @param key
+ /// Key of the property.
+ ///
+ /// @param getter
+ /// A function to invoke when this property value is requested.
+ /// add_ref will be called on the function.
+ ///
+ /// @param setter
+ /// A function to invoke when setting this property's value.
+ /// add_ref will be called on the function.
+ ///
+ /// @param flags
+ /// Flags for the new member. By default dontDelete and dontEnum.
+ /// See as_prop_flags::Flags.
+ ///
+ void init_property(string_table::key key, as_function& getter,
+ as_function& setter, int
flags=as_prop_flags::dontDelete|as_prop_flags::dontEnum);
+
+
+ /// \brief
/// Initialize a destructive getter/setter property
///
/// A destructive getter/setter can be used as a place holder for the
real
Index: server/asobj/AsBroadcaster.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/AsBroadcaster.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- server/asobj/AsBroadcaster.cpp 5 Oct 2007 22:17:54 -0000 1.7
+++ server/asobj/AsBroadcaster.cpp 6 Oct 2007 09:54:54 -0000 1.8
@@ -405,10 +405,15 @@
VM::get().addStatic(obj.get()); // correct ?
if ( swfVersion >= 6 )
{
+ // NOTE: we may add NSV::PROP_INITIALIZE, unavailable
at time of writing.
+ // anyway, since AsBroadcaster is the only class
we know using an 'initialize'
+ // method we might as well save the string_table
size in case we'll not load
+ // the class.
obj->init_member("initialize", new
builtin_function(AsBroadcaster::initialize_method));
- obj->init_member("addListener", new
builtin_function(AsBroadcaster::addListener_method));
- obj->init_member("removeListener", new
builtin_function(AsBroadcaster::removeListener_method));
- obj->init_member("broadcastMessage", new
builtin_function(AsBroadcaster::broadcastMessage_method));
+
+ obj->init_member(NSV::PROP_ADD_LISTENER, new
builtin_function(AsBroadcaster::addListener_method));
+ obj->init_member(NSV::PROP_REMOVE_LISTENER, new
builtin_function(AsBroadcaster::removeListener_method));
+ obj->init_member(NSV::PROP_BROADCAST_MESSAGE, new
builtin_function(AsBroadcaster::broadcastMessage_method));
}
}
- [Gnash-commit] gnash ChangeLog server/as_object.cpp server/as_...,
Sandro Santilli <=