[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/array.cpp server/as_envi...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/array.cpp server/as_envi... |
Date: |
Tue, 20 Mar 2007 15:01:21 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/03/20 15:01:20
Modified files:
. : ChangeLog
server : array.cpp as_environment.cpp as_function.cpp
as_object.cpp as_object.h as_value.cpp
as_value.h button_character_instance.cpp
character.cpp debugger.cpp
edit_text_character.cpp shm.cpp
sprite_instance.cpp sprite_instance.h
swf_function.cpp swf_function.h textformat.cpp
timers.cpp timers.h video_stream_instance.cpp
video_stream_instance.h
server/asobj : Boolean.cpp ContextMenu.cpp Date.cpp Global.cpp
Key.cpp Key.h LoadVars.cpp LocalConnection.cpp
MovieClipLoader.cpp NetConnection.cpp
NetConnection.h NetStream.cpp NetStream.h
NetStreamGst.cpp Object.cpp Sound.cpp
string.cpp xml.cpp xmlnode.cpp xmlsocket.cpp
server/vm : ASHandlers.cpp fn_call.h with_stack_entry.h
testsuite/server: GetterSetterTest.cpp
Log message:
Reduce use of "dumb" pointers, using intrusive_ptr instead.
A side-effect is the player2.swf premature deletion assertion
is not triggered anymore now.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2642&r2=1.2643
http://cvs.savannah.gnu.org/viewcvs/gnash/server/array.cpp?cvsroot=gnash&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.cpp?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.h?cvsroot=gnash&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/server/debugger.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/gnash/server/shm.cpp?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.197&r2=1.198
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.77&r2=1.78
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf_function.cpp?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf_function.h?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/textformat.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/server/timers.cpp?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/server/timers.h?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/server/video_stream_instance.cpp?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/server/video_stream_instance.h?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Boolean.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/ContextMenu.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Date.cpp?cvsroot=gnash&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.h?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/LoadVars.cpp?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/LocalConnection.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/MovieClipLoader.cpp?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.cpp?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.h?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStream.cpp?cvsroot=gnash&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStream.h?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamGst.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Object.cpp?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Sound.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/string.cpp?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlsocket.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/fn_call.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/with_stack_entry.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/server/GetterSetterTest.cpp?cvsroot=gnash&r1=1.8&r2=1.9
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2642
retrieving revision 1.2643
diff -u -b -r1.2642 -r1.2643
--- ChangeLog 20 Mar 2007 14:55:09 -0000 1.2642
+++ ChangeLog 20 Mar 2007 15:01:19 -0000 1.2643
@@ -1,5 +1,33 @@
2007-03-20 Sandro Santilli <address@hidden>
+ * server/array.cpp, server/as_environment.cpp,
+ server/as_function.cpp, server/as_object.cpp,
+ server/as_object.h, server/as_value.cpp, server/as_value.h,
+ server/button_character_instance.cpp, server/character.cpp,
+ server/debugger.cpp, server/edit_text_character.cpp,
+ server/shm.cpp, server/sprite_instance.cpp,
+ server/sprite_instance.h, server/swf_function.cpp,
+ server/swf_function.h, server/textformat.cpp, server/timers.cpp,
+ server/timers.h, server/video_stream_instance.cpp,
+ server/video_stream_instance.h, server/asobj/Boolean.cpp,
+ server/asobj/ContextMenu.cpp, server/asobj/Date.cpp,
+ server/asobj/Global.cpp, server/asobj/Key.cpp, server/asobj/Key.h,
+ server/asobj/LoadVars.cpp, server/asobj/LocalConnection.cpp,
+ server/asobj/MovieClipLoader.cpp,
+ server/asobj/NetConnection.cpp, server/asobj/NetConnection.h,
+ server/asobj/NetStream.cpp, server/asobj/NetStream.h,
+ server/asobj/NetStreamGst.cpp, server/asobj/Object.cpp,
+ server/asobj/Sound.cpp, server/asobj/string.cpp,
+ server/asobj/xml.cpp, server/asobj/xmlnode.cpp,
+ server/asobj/xmlsocket.cpp, server/vm/ASHandlers.cpp,
+ server/vm/fn_call.h, server/vm/with_stack_entry.h,
+ testsuite/server/GetterSetterTest.cpp:
+ Reduce use of "dumb" pointers, using intrusive_ptr instead.
+ A side-effect is the player2.swf premature deletion assertion
+ is not triggered anymore now.
+
+2007-03-20 Sandro Santilli <address@hidden>
+
* testsuite/actionscript.all/LocalConnection.as: Fix the test to NOT
rely on Gnash extensions. Actually check that the extensions are
*not* there, as we want to be compatible !!
Index: server/array.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/array.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- server/array.cpp 19 Mar 2007 17:11:14 -0000 1.53
+++ server/array.cpp 20 Mar 2007 15:01:20 -0000 1.54
@@ -457,21 +457,10 @@
}
-static as_array_object *
-ensureArray(as_object* obj)
-{
- as_array_object* ret = dynamic_cast<as_array_object*>(obj);
- if ( ! ret )
- {
- throw ActionException("builtin method or gettersetter for Array
objects called against non-Array instance");
- }
- return ret;
-}
-
static as_value
array_splice(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
UNUSED(array);
log_error("FIXME: Array.splice() method not implemented yet!\n");
@@ -481,7 +470,7 @@
static as_value
array_sort(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
uint8_t flags;
@@ -507,7 +496,7 @@
static as_value
array_sortOn(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
UNUSED(array);
log_error("FIXME: Array.sortOn() method not implemented yet!");
@@ -518,7 +507,7 @@
static as_value
array_push(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
IF_VERBOSE_ACTION (
log_action("calling array push, pushing %d values onto back of
array",fn.nargs);
@@ -534,7 +523,7 @@
static as_value
array_unshift(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
IF_VERBOSE_ACTION (
log_action("calling array unshift, pushing %d values onto front of
array",fn.nargs);
@@ -550,7 +539,7 @@
static as_value
array_pop(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
// Get our index, log, then return result
as_value rv = array->pop();
@@ -566,7 +555,7 @@
static as_value
array_shift(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
// Get our index, log, then return result
as_value rv = array->shift();
@@ -582,11 +571,11 @@
static as_value
array_reverse(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
array->reverse();
- as_value rv = as_value(array);
+ as_value rv(array.get());
IF_VERBOSE_ACTION (
log_action("called array reverse, result:%s, new array size:%d",
@@ -599,7 +588,7 @@
static as_value
array_join(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
std::string separator = ",";
@@ -614,7 +603,7 @@
static as_value
array_size(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
return as_value(array->size());
}
@@ -624,7 +613,7 @@
static as_value
array_to_string(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
std::string ret = array->toString();
@@ -632,7 +621,7 @@
(
log_action("array_to_string called, nargs = %d, "
"this_ptr = %p",
- fn.nargs, (void*)fn.this_ptr);
+ fn.nargs, (void*)fn.this_ptr.get());
log_action("to_string result is: %s", ret.c_str());
);
@@ -647,7 +636,7 @@
static as_value
array_concat(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
// use copy ctor
as_array_object* newarray = new as_array_object(*array);
@@ -655,9 +644,9 @@
for (unsigned int i=0; i<fn.nargs; i++)
{
// Array args get concatenated by elements
- if ( as_array_object* other =
dynamic_cast<as_array_object*>(fn.arg(i).to_object()) )
+ boost::intrusive_ptr<as_array_object> other =
boost::dynamic_pointer_cast<as_array_object>(fn.arg(1).to_object());
+ if ( other )
{
- assert(other);
newarray->concat(*other);
}
else
@@ -674,7 +663,7 @@
static as_value
array_slice(const fn_call& fn)
{
- as_array_object* array = ensureArray(fn.this_ptr);
+ boost::intrusive_ptr<as_array_object> array =
ensureType<as_array_object>(fn.this_ptr);
// start and end index of the part we're slicing
int startindex, endindex;
Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- server/as_environment.cpp 19 Mar 2007 17:11:14 -0000 1.59
+++ server/as_environment.cpp 20 Mar 2007 15:01:20 -0000 1.60
@@ -16,7 +16,7 @@
//
-/* $Id: as_environment.cpp,v 1.59 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: as_environment.cpp,v 1.60 2007/03/20 15:01:20 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -427,9 +427,10 @@
if ( val.is_object() )
{
- as_object* obj = val.to_object();
+ boost::intrusive_ptr<as_object> obj = val.to_object();
assert (obj);
- character* s=dynamic_cast<character*>(obj);
+ character* s=dynamic_cast<character*>(obj.get());
+ assert(s->get_ref_count() > 1); // or the intrusive_ptr above
going out-of-scope will kill it
//log_msg("find_target is a character, returning it");
return s; // might be NULL
}
@@ -651,16 +652,18 @@
}
}
- env = tmp.to_object();
-
// Debugging only:
- if ( env == NULL ) {
+ if ( ! tmp.is_object() ) {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("Member %s for object %p found but doesn't cast to
an as_object", subpart.c_str(), env);
);
return NULL;
}
+ env = tmp.to_object().get();
+ assert(env->get_ref_count() > 0); // still alive...
+
+
//@@ _level0 --> root, .. --> parent, . --> this, other == character
if (next_dot == NULL) {
@@ -791,14 +794,14 @@
}
}
- as_object* newenv = tmp.to_object();
// Debugging only:
- if ( newenv == NULL ) {
+ if ( ! tmp.is_object() ) {
log_msg("Member %s for object %p found but doesn't cast
to an as_object", subpart.c_str(), env);
return NULL;
}
- env = newenv;
+ env = tmp.to_object().get();
+ assert(env->get_ref_count() > 0);
}
//@@ _level0 --> root, .. --> parent, . --> this, other == character
Index: server/as_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_function.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/as_function.cpp 19 Mar 2007 17:11:14 -0000 1.22
+++ server/as_function.cpp 20 Mar 2007 15:01:20 -0000 1.23
@@ -142,7 +142,10 @@
get_member("prototype", &proto);
if ( proto.to_object() != _properties.get() )
{
- log_warning("Exported interface of function %p has been
overwritten (from %p to %p)!", this, _properties.get(), proto.to_object());
+ log_warning("Exported interface of function %p "
+ "has been overwritten (from %p to %p)!",
+ this, _properties.get(),
+ (void*)proto.to_object().get());
_properties = proto.to_object();
}
return _properties.get();
@@ -169,26 +172,13 @@
}
-// Wrapper around dynamic_cast to implement user warning.
-// To be used by builtin properties and methods.
-static as_function*
-ensureFunction(as_object* obj)
-{
- as_function* ret = dynamic_cast<as_function*>(obj);
- if ( ! ret )
- {
- throw ActionException("builtin method or gettersetter for
Function objects called against non-Function instance");
- }
- return ret;
-}
-
as_value
function_apply(const fn_call& fn)
{
int pushed=0; // new values we push on the stack
// Get function body
- as_function* function_obj = ensureFunction(fn.this_ptr);
+ boost::intrusive_ptr<as_function> function_obj =
ensureType<as_function>(fn.this_ptr);
// Copy new function call from old one, we'll modify
// the copy only if needed
@@ -204,7 +194,7 @@
else
{
// Get the object to use as 'this' reference
- as_object *this_ptr = fn.arg(0).to_object();
+ boost::intrusive_ptr<as_object> this_ptr =
fn.arg(0).to_object();
if ( this_ptr ) new_fn_call.this_ptr = this_ptr;
// ... or recycle this function's call 'this' pointer
// (most likely the Function instance)
@@ -224,22 +214,20 @@
}
);
- as_object *arg1 = fn.arg(1).to_object();
+ boost::intrusive_ptr<as_object> arg1 =
fn.arg(1).to_object();
if ( ! arg1 )
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("Second arg of
Function.apply"
- " is of type %s, with value %s"
- " (expected array)"
+ " is %s (expected array)"
" - considering as call with no
args",
- fn.arg(1).typeOf(),
- fn.arg(1).to_string());
+
fn.arg(1).to_debug_string().c_str());
);
goto call_it;
}
- as_array_object *arg_array = \
- dynamic_cast<as_array_object*>(arg1);
+ boost::intrusive_ptr<as_array_object> arg_array = \
+
boost::dynamic_pointer_cast<as_array_object>(arg1);
if ( ! arg_array )
{
@@ -273,7 +261,7 @@
call_it:
// Call the function
- as_value rv = (*function_obj)(new_fn_call);
+ as_value rv = function_obj->call(new_fn_call);
// Drop additional values we pushed on the stack
fn.env->drop(pushed);
@@ -286,7 +274,7 @@
{
// Get function body
- as_function* function_obj = ensureFunction(fn.this_ptr);
+ boost::intrusive_ptr<as_function> function_obj =
ensureType<as_function>(fn.this_ptr);
// Copy new function call from old one, we'll modify
// the copy only if needed
@@ -300,7 +288,7 @@
else
{
// Get the object to use as 'this' reference
- as_object *this_ptr = fn.arg(0).to_object();
+ boost::intrusive_ptr<as_object> this_ptr =
fn.arg(0).to_object();
new_fn_call.this_ptr = this_ptr;
new_fn_call.nargs--;
new_fn_call.first_arg_bottom_index--;
Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- server/as_object.cpp 19 Mar 2007 17:11:14 -0000 1.42
+++ server/as_object.cpp 20 Mar 2007 15:01:20 -0000 1.43
@@ -172,7 +172,7 @@
/*protected*/
void
-as_object::set_prototype(as_object* proto)
+as_object::set_prototype(boost::intrusive_ptr<as_object> proto)
{
m_prototype = proto;
}
@@ -392,7 +392,7 @@
return;
}
- as_object* props = props_val.to_object();
+ boost::intrusive_ptr<as_object> props = props_val.to_object();
// Evan: it seems that if set_true == 0 and set_false == 0,
// this function acts as if the parameters were (object, null, 0x1, 0)
@@ -493,6 +493,14 @@
{
}
+as_object::as_object(boost::intrusive_ptr<as_object> proto)
+ :
+ _members(),
+ _vm(VM::get()),
+ m_prototype(proto)
+{
+}
+
as_object::as_object(const as_object& other)
:
ref_counted(),
@@ -535,8 +543,7 @@
as_value
as_object::tostring_method(const fn_call& fn)
{
- assert(dynamic_cast<as_object*>(fn.this_ptr));
- as_object* obj = static_cast<as_object*>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> obj = fn.this_ptr;
const char* text_val = obj->get_text_value();
if ( text_val )
@@ -552,8 +559,7 @@
as_value
as_object::valueof_method(const fn_call& fn)
{
- assert(dynamic_cast<as_object*>(fn.this_ptr));
- as_object* obj = static_cast<as_object*>(fn.this_ptr);
+ boost::intrusive_ptr<as_object> obj = fn.this_ptr;
return obj->get_primitive_value();
}
Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- server/as_object.h 20 Mar 2007 12:37:48 -0000 1.47
+++ server/as_object.h 20 Mar 2007 15:01:20 -0000 1.48
@@ -107,6 +107,9 @@
/// Adds a reference to the prototype, if any.
as_object(as_object* proto);
+ /// Construct an ActionScript object based on the given prototype.
+ as_object(boost::intrusive_ptr<as_object> proto);
+
/// Copy an as_object
//
/// TODO: write more about this, is it allowed ? is it safe ?
@@ -396,7 +399,7 @@
/// public: set_member("__proto__", <anyting>)
/// will do just the same
///
- void set_prototype(as_object* proto);
+ void set_prototype(boost::intrusive_ptr<as_object> proto);
/// @{ Common ActionScript methods for characters
/// TODO: make protected
@@ -504,6 +507,30 @@
return ret;
}
+/// Template which does a dynamic cast for as_object pointers. It throws an
+/// error if the dynamic cast fails.
+/// @param T the class to which the obj pointer should be cast.
+/// @param obj the pointer to be cast.
+/// @return If the cast succeeds, the pointer cast to the requested type.
+/// Otherwise, NULL.
+template <typename T>
+boost::intrusive_ptr<T>
+ensureType (boost::intrusive_ptr<as_object> obj)
+{
+ boost::intrusive_ptr<T> ret = boost::dynamic_pointer_cast<T>(obj);
+
+ // This path is fairly unlikely, so it's a potential __builtin_expect.
+ if (!ret) {
+ std::ostringstream stream;
+ stream << "builtin method or gettersetter for "
+ << typeid(T).name() << " called from "
+ << typeid(obj).name() << " instance.";
+
+ throw ActionException(stream.str());
+ }
+ return ret;
+}
+
} // namespace gnash
Index: server/as_value.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- server/as_value.cpp 20 Mar 2007 09:19:33 -0000 1.29
+++ server/as_value.cpp 20 Mar 2007 15:01:20 -0000 1.30
@@ -464,23 +464,34 @@
}
// Return value as an object.
-as_object*
+boost::intrusive_ptr<as_object>
as_value::to_object() const
{
+ typedef boost::intrusive_ptr<as_object> ptr;
+
switch (m_type)
{
case OBJECT:
case AS_FUNCTION:
- return m_object_value;
+ return ptr(m_object_value);
case MOVIECLIP:
- return to_sprite();
+ // FIXME: update when to_sprite will return
+ // an intrusive_ptr directly
+ return ptr(to_sprite());
case STRING:
- return
init_string_instance(m_string_value.c_str()).release();
+ // FIXME: update when init_whatever_instance will
+ // return an intrusive_ptr directly
+ return
ptr(init_string_instance(m_string_value.c_str()).release());
case NUMBER:
- return init_number_instance(m_number_value).release();
+ // FIXME: update when init_whatever_instance will
+ // return an intrusive_ptr directly
+ return
ptr(init_number_instance(m_number_value).release());
+
+ case BOOLEAN:
+ log_error("FIXME: boolean to Boolean conversion
unimplemented yet");
default:
return NULL;
@@ -598,6 +609,12 @@
}
void
+as_value::set_as_object(boost::intrusive_ptr<as_object> obj)
+{
+ set_as_object(obj.get());
+}
+
+void
as_value::set_as_function(as_function* func)
{
if (m_type != AS_FUNCTION || m_object_value != func) {
@@ -825,6 +842,16 @@
else assert(0);
}
+as_value::as_value(boost::intrusive_ptr<as_object> obj)
+ :
+ // Initialize to non-object type here,
+ // or set_as_object will call
+ // drop_ref on undefined memory !!
+ m_type(UNDEFINED)
+{
+ set_as_object(obj);
+}
+
} // namespace gnash
Index: server/as_value.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- server/as_value.h 20 Mar 2007 09:19:33 -0000 1.35
+++ server/as_value.h 20 Mar 2007 15:01:20 -0000 1.36
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: as_value.h,v 1.35 2007/03/20 09:19:33 strk Exp $ */
+/* $Id: as_value.h,v 1.36 2007/03/20 15:01:20 strk Exp $ */
#ifndef GNASH_AS_VALUE_H
#define GNASH_AS_VALUE_H
@@ -23,13 +23,12 @@
#include "config.h"
#endif
-#include <cmath>
-#include <string>
-
#include "container.h"
#include "tu_config.h"
+#include "smart_ptr.h"
-//#include "resource.h" // for inheritance of as_object
+#include <cmath>
+#include <string>
namespace gnash {
@@ -66,9 +65,12 @@
#endif
-// ActionScript value type.
-
-//No private: ???
+/// ActionScript value type.
+//
+/// Any ActionScript value is stored into an instance of this
+/// class. The instance keeps primitive types by value and
+/// composite types by reference (smart pointer).
+///
class DSOEXPORT as_value
{
public:
@@ -240,6 +242,8 @@
set_as_object(obj);
}
+ as_value(boost::intrusive_ptr<as_object> obj);
+
/// Construct a NULL or AS_FUNCTION value
as_value(as_function* func);
@@ -402,18 +406,18 @@
/// Return value as an object, converting primitive values as needed.
//
- /// Make sure you store the returned pointer in a boost::intrusive_ptr
- /// as it might be a newly allocated one in case of a conversion from
- /// a primitive string, number or boolean value.
+ /// Make sure you don't break the intrusive_ptr chain
+ /// as the returned object might be a newly allocated one in case
+ /// of a conversion from a primitive string, number or boolean value.
///
/// string values will be converted to String objects,
/// numeric values will be converted to Number objects,
- /// boolean values are currently NOT converted...
+ /// boolean values are currently NOT converted, but should (FIXME!)
///
/// If you want to avoid the conversion, check with is_object() before
/// calling this function.
///
- as_object* to_object() const;
+ boost::intrusive_ptr<as_object> to_object() const;
/// Return value as a sprite or NULL if this is not possible.
//
@@ -496,6 +500,8 @@
///
void set_as_object(as_object* obj);
+ void set_as_object(boost::intrusive_ptr<as_object> obj);
+
/// Make this a NULL or AS_FUNCTION value
void set_as_function(as_function* func);
Index: server/button_character_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- server/button_character_instance.cpp 19 Mar 2007 17:11:14 -0000
1.34
+++ server/button_character_instance.cpp 20 Mar 2007 15:01:20 -0000
1.35
@@ -152,6 +152,10 @@
namespace gnash {
+/// A couple of typedefs to make code neater
+typedef button_character_instance Button;
+typedef boost::intrusive_ptr<Button> ButtonPtr;
+
static void
attachButtonInterface(as_object& o)
{
@@ -276,13 +280,7 @@
as_value
button_character_instance::enabled_getset(const fn_call& fn)
{
- button_character_instance* ptr =
- dynamic_cast<button_character_instance*>(fn.this_ptr);
-
- if ( ! ptr )
- {
- throw ActionException("enabled_getset() called against
non-character instance");
- }
+ ButtonPtr ptr = ensureType<Button>(fn.this_ptr);
as_value rv;
Index: server/character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/character.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/character.cpp 19 Mar 2007 17:11:14 -0000 1.25
+++ server/character.cpp 20 Mar 2007 15:01:20 -0000 1.26
@@ -18,7 +18,7 @@
//
//
-/* $Id: character.cpp,v 1.25 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: character.cpp,v 1.26 2007/03/20 15:01:20 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -233,23 +233,10 @@
//
//---------------------------------------------------------------------
-// Wrapper around dynamic_cast to implement user warning.
-// To be used by builtin properties and methods.
-static character*
-ensure_character(as_object* obj)
-{
- character* ret = dynamic_cast<character*>(obj);
- if ( ! ret )
- {
- throw ActionException("builtin method or gettersetter for
character objects called against non-character instance");
- }
- return ret;
-}
-
as_value
character::onrollover_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -267,7 +254,7 @@
as_value
character::onrollout_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -284,7 +271,7 @@
as_value
character::onpress_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -301,7 +288,7 @@
as_value
character::onrelease_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -318,7 +305,7 @@
as_value
character::onreleaseoutside_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -335,7 +322,7 @@
as_value
character::onmouseup_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -352,7 +339,7 @@
as_value
character::onmousedown_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -369,7 +356,7 @@
as_value
character::onmousemove_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -386,7 +373,7 @@
as_value
character::onload_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -403,7 +390,7 @@
as_value
character::x_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -425,7 +412,7 @@
as_value
character::y_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -447,7 +434,7 @@
as_value
character::xscale_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -499,7 +486,7 @@
as_value
character::yscale_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -551,7 +538,7 @@
as_value
character::xmouse_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -581,7 +568,7 @@
as_value
character::ymouse_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -611,7 +598,7 @@
as_value
character::alpha_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -633,7 +620,7 @@
as_value
character::visible_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -652,7 +639,7 @@
as_value
character::width_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -678,7 +665,7 @@
as_value
character::height_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -704,7 +691,7 @@
as_value
character::rotation_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
@@ -738,12 +725,12 @@
as_value
character::parent_getset(const fn_call& fn)
{
- character* ptr = ensure_character(fn.this_ptr);
+ boost::intrusive_ptr<character> ptr =
ensureType<character>(fn.this_ptr);
as_value rv;
if ( fn.nargs == 0 ) // getter
{
- as_object* p = ptr->get_parent();
+ boost::intrusive_ptr<as_object> p = ptr->get_parent();
if ( p )
{
rv = as_value(p);
Index: server/debugger.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/debugger.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/debugger.cpp 6 Mar 2007 08:22:43 -0000 1.13
+++ server/debugger.cpp 20 Mar 2007 15:01:20 -0000 1.14
@@ -580,11 +580,12 @@
// }
cerr << env.m_stack[i].to_string();
if (val.is_object()) {
- string name = this->lookupSymbol(val.to_object());
+ boost::intrusive_ptr<as_object> o = val.to_object();
+ string name = lookupSymbol(o.get());
if (name.size()) {
cerr << " \"" << name << "\"";
}
- cerr << " has #" << val.to_object()->get_ref_count() << "
references";
+ cerr << " has #" << o->get_ref_count() << " references";
}
cerr << endl;
}
Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- server/edit_text_character.cpp 19 Mar 2007 17:11:14 -0000 1.46
+++ server/edit_text_character.cpp 20 Mar 2007 15:01:20 -0000 1.47
@@ -15,7 +15,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: edit_text_character.cpp,v 1.46 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: edit_text_character.cpp,v 1.47 2007/03/20 15:01:20 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -49,8 +49,7 @@
static as_value
textfield_get_variable(const fn_call& fn)
{
- assert( dynamic_cast<edit_text_character*>(fn.this_ptr) );
- edit_text_character* text =
static_cast<edit_text_character*>(fn.this_ptr);
+ boost::intrusive_ptr<edit_text_character> text =
ensureType<edit_text_character>(fn.this_ptr);
return as_value(text->get_variable_name());
@@ -59,8 +58,7 @@
static as_value
textfield_set_variable(const fn_call& fn)
{
- assert( dynamic_cast<edit_text_character*>(fn.this_ptr) );
- edit_text_character* text =
static_cast<edit_text_character*>(fn.this_ptr);
+ boost::intrusive_ptr<edit_text_character> text =
ensureType<edit_text_character>(fn.this_ptr);
assert ( fn.nargs > 0 );
std::string newname = fn.arg(0).to_std_string();
Index: server/shm.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/shm.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- server/shm.cpp 19 Mar 2007 17:11:14 -0000 1.28
+++ server/shm.cpp 20 Mar 2007 15:01:20 -0000 1.29
@@ -1,5 +1,5 @@
//
-// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
//
//
-/* $Id: shm.cpp,v 1.28 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: shm.cpp,v 1.29 2007/03/20 15:01:20 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -500,25 +500,25 @@
// method to see if it worked correctly.
as_value shm_getname(const fn_call& fn)
{
- shm_as_object *ptr = (shm_as_object*)fn.this_ptr;
+ boost::intrusive_ptr<shm_as_object> ptr =
ensureType<shm_as_object>(fn.this_ptr);
assert(ptr);
return as_value(ptr->obj.getName());
}
as_value shm_getsize(const fn_call& fn)
{
- shm_as_object *ptr = (shm_as_object*)fn.this_ptr;
+ boost::intrusive_ptr<shm_as_object> ptr =
ensureType<shm_as_object>(fn.this_ptr);
assert(ptr);
return as_value(ptr->obj.getSize());
}
as_value shm_getallocated(const fn_call& fn)
{
- shm_as_object *ptr = (shm_as_object*)fn.this_ptr;
+ boost::intrusive_ptr<shm_as_object> ptr =
ensureType<shm_as_object>(fn.this_ptr);
assert(ptr);
return as_value(ptr->obj.getAllocated());
}
as_value shm_exists(const fn_call& fn)
{
- shm_as_object *ptr = (shm_as_object*)fn.this_ptr;
+ boost::intrusive_ptr<shm_as_object> ptr =
ensureType<shm_as_object>(fn.this_ptr);
assert(ptr);
return as_value(ptr->obj.exists());
}
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -b -r1.197 -r1.198
--- server/sprite_instance.cpp 19 Mar 2007 17:11:14 -0000 1.197
+++ server/sprite_instance.cpp 20 Mar 2007 15:01:20 -0000 1.198
@@ -109,22 +109,9 @@
}
}
-// Wrapper around dynamic_cast to implement user warning.
-// To be used by builtin properties and methods.
-static sprite_instance*
-ensure_sprite(as_object* obj)
-{
- sprite_instance* ret = dynamic_cast<sprite_instance*>(obj);
- if ( ! ret )
- {
- throw ActionException("builtin method or gettersetter for
sprite objects called against non-sprite instance");
- }
- return ret;
-}
-
static as_value sprite_play(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
sprite->set_play_state(sprite_instance::PLAY);
return as_value();
@@ -132,7 +119,7 @@
static as_value sprite_stop(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
sprite->set_play_state(sprite_instance::STOP);
@@ -152,7 +139,7 @@
//removeMovieClip() : Void
static as_value sprite_remove_movieclip(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
sprite_instance* parent =
dynamic_cast<sprite_instance*>(sprite->get_parent());
if (parent)
@@ -166,7 +153,7 @@
// depth:Number [, initObject:Object]) : MovieClip
static as_value sprite_attach_movie(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
as_value rv;
if (fn.nargs < 3 || fn.nargs > 4)
@@ -210,7 +197,7 @@
// should we support negative depths ?
uint16_t depth_val = uint16_t(fn.arg(2).to_number());
- boost::intrusive_ptr<character> newch =
exported_movie->create_character_instance(sprite, depth_val);
+ boost::intrusive_ptr<character> newch =
exported_movie->create_character_instance(sprite.get(), depth_val);
assert( dynamic_cast<sprite_instance*>(newch.get()) );
assert( newch.get() > (void*)0xFFFF );
assert(newch->get_ref_count() > 0);
@@ -229,7 +216,7 @@
/// Properties must be copied *after* the call to attachCharacter
/// because attachCharacter() will reset matrix !!
if (fn.nargs > 3 ) {
- as_object* initObject = fn.arg(3).to_object();
+ boost::intrusive_ptr<as_object> initObject =
fn.arg(3).to_object();
if ( initObject ) {
log_msg("Initializing properties from object");
newch->copyProperties(*initObject);
@@ -252,7 +239,7 @@
// attachAudio(id:Object) : Void
static as_value sprite_attach_audio(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(sprite);
static bool warned = false;
@@ -268,7 +255,7 @@
//createEmptyMovieClip(name:String, depth:Number) : MovieClip
static as_value sprite_create_empty_movieclip(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
if (fn.nargs != 2)
{
@@ -299,7 +286,7 @@
static as_value sprite_get_depth(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
int n = sprite->get_depth();
@@ -310,7 +297,7 @@
//swapDepths(target:Object) : Void
static as_value sprite_swap_depths(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
as_value rv;
if (fn.nargs < 1)
@@ -321,19 +308,21 @@
return rv;
}
- sprite_instance* target;
+ boost::intrusive_ptr<character> target = NULL;
if (fn.arg(0).is_object() )
{
- target = (sprite_instance*) fn.arg(0).to_object();
+ target =
boost::dynamic_pointer_cast<character>(fn.arg(0).to_object());
}
- else
- if (fn.arg(0).is_number() )
+ else if (fn.arg(0).is_number() )
{
// Macromedia Flash help says: depth starts at -16383 (0x3FFF)
int target_depth = int(fn.arg(0).to_number()) + 16383 + 1;
- sprite_instance* parent = (sprite_instance*)
sprite->get_parent();
- target = (sprite_instance*)
parent->get_character_at_depth(target_depth);
+ boost::intrusive_ptr<sprite_instance> parent =
dynamic_cast<sprite_instance*>(sprite->get_parent());
+ if ( parent )
+ {
+ target = parent->get_character_at_depth(target_depth);
+ }
}
else
{
@@ -357,8 +346,11 @@
target->set_depth(sprite->get_depth());
sprite->set_depth(target_depth);
- sprite_instance* parent = (sprite_instance*)
sprite->get_parent();
- parent->swap_characters(sprite, target);
+ boost::intrusive_ptr<sprite_instance> parent =
dynamic_cast<sprite_instance*>(sprite->get_parent());
+ if ( parent )
+ {
+ parent->swap_characters(sprite.get(), target.get());
+ }
}
else
{
@@ -376,7 +368,7 @@
//duplicateMovieClip(name:String, depth:Number, [initObject:Object]) :
MovieClip
static as_value sprite_duplicate_movieclip(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
if (fn.nargs < 2)
{
@@ -428,7 +420,7 @@
// Copy members from initObject
if (fn.nargs == 3 && ch)
{
- as_object* initObject = fn.arg(2).to_object();
+ boost::intrusive_ptr<as_object> initObject =
fn.arg(2).to_object();
if ( initObject ) ch->copyProperties(*initObject);
}
@@ -438,7 +430,7 @@
static as_value sprite_goto_and_play(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
if (fn.nargs < 1)
{
@@ -457,7 +449,7 @@
static as_value sprite_goto_and_stop(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
if (fn.nargs < 1)
{
@@ -477,7 +469,7 @@
static as_value sprite_next_frame(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
size_t frame_count = sprite->get_frame_count();
size_t current_frame = sprite->get_current_frame();
@@ -491,7 +483,7 @@
static as_value sprite_prev_frame(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
size_t current_frame = sprite->get_current_frame();
if (current_frame > 0)
@@ -504,14 +496,14 @@
static as_value sprite_get_bytes_loaded(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
return as_value(sprite->get_bytes_loaded());
}
static as_value sprite_get_bytes_total(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
// @@ horrible uh ?
return as_value(sprite->get_bytes_total());
@@ -520,7 +512,7 @@
// my_mc.loadMovie(url:String [,variables:String]) : Void
static as_value sprite_load_movie(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(sprite);
if (fn.nargs < 1) // url
@@ -568,7 +560,7 @@
// my_mc.loadVariables(url:String [, variables:String]) : Void
static as_value sprite_load_variables(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(sprite);
if (fn.nargs < 1) // url
@@ -618,7 +610,7 @@
// my_mc.unloadMovie() : Void
static as_value sprite_unload_movie(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(sprite);
// See http://sephiroth.it/reference.php?id=429
@@ -634,7 +626,7 @@
static as_value sprite_hit_test(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(sprite);
static bool warned_1_arg = false;
@@ -704,7 +696,7 @@
static as_value
sprite_create_text_field(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
if (fn.nargs != 6) // name, depth, x, y, width, height
{
@@ -787,7 +779,7 @@
static as_value
sprite_getNextHighestDepth(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
unsigned int nextdepth = sprite->getNextHighestDepth();
return as_value(static_cast<double>(nextdepth));
@@ -797,7 +789,7 @@
static as_value
sprite_getURL(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(sprite);
static bool warned = false;
@@ -813,7 +805,7 @@
static as_value
sprite_getBounds(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
boost::intrusive_ptr<as_object> target;
if ( fn.nargs > 0 )
@@ -850,7 +842,7 @@
static as_value
sprite_globalToLocal(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(sprite);
static bool warned = false;
@@ -865,7 +857,7 @@
static as_value
sprite_endFill(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
sprite->endFill();
return as_value();
}
@@ -873,7 +865,7 @@
static as_value
sprite_lineTo(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
if ( fn.nargs < 2 )
{
@@ -894,7 +886,7 @@
static as_value
sprite_moveTo(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
if ( fn.nargs < 2 )
{
@@ -915,7 +907,7 @@
static as_value
sprite_lineStyle(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
uint16_t thickness = 0;
uint8_t r = 0;
@@ -957,7 +949,7 @@
static as_value
sprite_curveTo(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
if ( fn.nargs < 4 )
{
@@ -980,7 +972,7 @@
static as_value
sprite_clear(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
sprite->clear();
@@ -990,7 +982,7 @@
static as_value
sprite_beginFill(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
uint8_t r = 0;
uint8_t g = 0;
@@ -1017,7 +1009,7 @@
static as_value
sprite_beginGradientFill(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(sprite);
static bool warned = false;
@@ -1034,7 +1026,7 @@
static as_value
sprite_startDrag(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(sprite);
static bool warned = false;
@@ -1050,7 +1042,7 @@
static as_value
sprite_stopDrag(const fn_call& fn)
{
- sprite_instance* sprite = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(sprite);
static bool warned = false;
@@ -1076,7 +1068,7 @@
static as_value
sprite_currentframe_getset(const fn_call& fn)
{
- sprite_instance* ptr = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> ptr =
ensureType<sprite_instance>(fn.this_ptr);
if ( fn.nargs == 0 ) // getter
{
@@ -1095,7 +1087,7 @@
static as_value
sprite_totalframes_getset(const fn_call& fn)
{
- sprite_instance* ptr = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> ptr =
ensureType<sprite_instance>(fn.this_ptr);
if ( fn.nargs == 0 ) // getter
{
@@ -1114,7 +1106,7 @@
static as_value
sprite_framesloaded_getset(const fn_call& fn)
{
- sprite_instance* ptr = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> ptr =
ensureType<sprite_instance>(fn.this_ptr);
if ( fn.nargs == 0 ) // getter
{
@@ -1133,7 +1125,7 @@
static as_value
sprite_target_getset(const fn_call& fn)
{
- sprite_instance* ptr = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> ptr =
ensureType<sprite_instance>(fn.this_ptr);
if ( fn.nargs == 0 ) // getter
{
@@ -1152,7 +1144,7 @@
static as_value
sprite_name_getset(const fn_call& fn)
{
- sprite_instance* ptr = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> ptr =
ensureType<sprite_instance>(fn.this_ptr);
if ( fn.nargs == 0 ) // getter
{
@@ -1181,7 +1173,7 @@
static as_value
sprite_droptarget_getset(const fn_call& fn)
{
- sprite_instance* ptr = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> ptr =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(ptr);
if ( fn.nargs == 0 ) // getter
@@ -1216,7 +1208,7 @@
static as_value
sprite_url_getset(const fn_call& fn)
{
- sprite_instance* ptr = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> ptr =
ensureType<sprite_instance>(fn.this_ptr);
if ( fn.nargs == 0 ) // getter
{
@@ -1235,7 +1227,7 @@
static as_value
sprite_highquality_getset(const fn_call& fn)
{
- sprite_instance* ptr = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> ptr =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(ptr);
if ( fn.nargs == 0 ) // getter
@@ -1258,7 +1250,7 @@
static as_value
sprite_focusrect_getset(const fn_call& fn)
{
- sprite_instance* ptr = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> ptr =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(ptr);
if ( fn.nargs == 0 ) // getter
@@ -1281,7 +1273,7 @@
static as_value
sprite_soundbuftime_getset(const fn_call& fn)
{
- sprite_instance* ptr = ensure_sprite(fn.this_ptr);
+ boost::intrusive_ptr<sprite_instance> ptr =
ensureType<sprite_instance>(fn.this_ptr);
UNUSED(ptr);
if ( fn.nargs == 0 ) // getter
Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- server/sprite_instance.h 15 Mar 2007 22:39:53 -0000 1.77
+++ server/sprite_instance.h 20 Mar 2007 15:01:20 -0000 1.78
@@ -17,7 +17,7 @@
//
//
-/* $Id: sprite_instance.h,v 1.77 2007/03/15 22:39:53 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.78 2007/03/20 15:01:20 strk Exp $ */
// Stateful live Sprite instance
@@ -577,8 +577,8 @@
assert(m_parent == NULL);
as_value obj =
m_as_environment.get_variable(std::string(path_to_object));
- as_object* as_obj = obj.to_object();
- character* ch = dynamic_cast<character*>(as_obj);
+ boost::intrusive_ptr<as_object> as_obj = obj.to_object();
+ boost::intrusive_ptr<character> ch =
boost::dynamic_pointer_cast<character>(as_obj);
if (ch)
{
ch->set_display_callback(callback, user_ptr);
Index: server/swf_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf_function.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- server/swf_function.cpp 19 Mar 2007 17:11:14 -0000 1.24
+++ server/swf_function.cpp 20 Mar 2007 15:01:20 -0000 1.25
@@ -73,11 +73,11 @@
}
/*private static*/
-as_object*
+boost::intrusive_ptr<as_object>
swf_function::getSuper(as_object& obj)
{
// Super class prototype is : obj.__proto__.constructor.prototype
- as_object* proto = obj.get_prototype();
+ boost::intrusive_ptr<as_object> proto = obj.get_prototype();
if ( ! proto )
{
#ifdef GNASH_DEBUG_GETSUPER
@@ -103,7 +103,7 @@
// it is possible that the returned object is NOT the current
// 'prototype' member, as as_function caches it ?
//
- as_object* ctor_obj = ctor.to_object();
+ boost::intrusive_ptr<as_object> ctor_obj = ctor.to_object();
if ( ! ctor_obj )
{
#ifdef GNASH_DEBUG_GETSUPER
@@ -126,7 +126,7 @@
return NULL;
}
- as_object* super = ctor_proto.to_object();
+ boost::intrusive_ptr<as_object> super = ctor_proto.to_object();
if ( ! super )
{
#ifdef GNASH_DEBUG_GETSUPER
@@ -135,7 +135,7 @@
return NULL;
}
- return super;
+ return super; // FIXME: return the intrusive_ptr directly !!
}
@@ -202,8 +202,8 @@
// Add 'super' (SWF6+ only)
if ( swfversion > 5 )
{
- as_object* super = getSuper(*(fn.this_ptr));
- our_env->set_local("super", super);
+ boost::intrusive_ptr<as_object> super =
getSuper(*(fn.this_ptr));
+ our_env->set_local("super", as_value(super));
}
// Add 'arguments'
@@ -323,7 +323,7 @@
// Execute the actions.
//ActionExec exec(*m_action_buffer, *our_env, m_start_pc, m_length,
fn.result, m_with_stack, m_is_function2);
as_value result;
- ActionExec exec(*this, *our_env, &result, fn.this_ptr);
+ ActionExec exec(*this, *our_env, &result, fn.this_ptr.get());
exec();
our_env->popCallFrame();
Index: server/swf_function.h
===================================================================
RCS file: /sources/gnash/gnash/server/swf_function.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/swf_function.h 19 Mar 2007 17:11:14 -0000 1.10
+++ server/swf_function.h 20 Mar 2007 15:01:20 -0000 1.11
@@ -87,7 +87,7 @@
/// parts of it to the as_object class
/// (getConstructor, for example)
///
- static as_object* getSuper(as_object& obj);
+ static boost::intrusive_ptr<as_object> getSuper(as_object& obj);
/// Return an 'arguments' object.
//
Index: server/textformat.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/textformat.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/textformat.cpp 19 Mar 2007 17:11:14 -0000 1.18
+++ server/textformat.cpp 20 Mar 2007 15:01:20 -0000 1.19
@@ -137,14 +137,27 @@
{
as_value method;
//log_msg("%s: args=%d at %p\n", __FUNCTION__, nargs, this_ptr);
-#if 0
- // FIXME: these are only commented out to eliminate compilation warnings.
- textformat_as_object* ptr = (textformat_as_object*) fn.this_ptr;
// tulrich: TODO fix this unsafe cast; see textformat_new().
- assert(ptr);
- double start = fn.arg(0).to_number();
- double end = fn.arg(1).to_number();
-#endif
- textformat_as_object *obj = (textformat_as_object*) fn.arg(2).to_object();
// tulrich: TODO fix this unsafe cast. (need cast_to_textformat())
+
+ boost::intrusive_ptr<textformat_as_object> ptr =
ensureType<textformat_as_object>(fn.this_ptr);
+ //double start = fn.arg(0).to_number();
+ //double end = fn.arg(1).to_number();
+
+ if ( fn.nargs < 3 )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("TextFormat.setFormat() needs at least 3 arguments - ...me
thinks");
+ );
+ return as_value();
+ }
+
+ boost::intrusive_ptr<textformat_as_object> obj =
boost::dynamic_pointer_cast<textformat_as_object>(fn.arg(2).to_object());
+ if ( ! obj )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("Argument 3 given to TextFormat.setFormat() is not a
TextFormat object - ... should it?");
+ );
+ return as_value();
+ }
assert(obj);
//log_msg("Change from %f for %f characters for object at %p\n", start, end,
obj);
Index: server/timers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/timers.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- server/timers.cpp 19 Mar 2007 17:11:14 -0000 1.24
+++ server/timers.cpp 20 Mar 2007 15:01:20 -0000 1.25
@@ -18,7 +18,7 @@
//
//
-/* $Id: timers.cpp,v 1.24 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: timers.cpp,v 1.25 2007/03/20 15:01:20 strk Exp $ */
#include "timers.h"
#include "as_function.h" // for class as_function
@@ -49,7 +49,7 @@
void
- Timer::setInterval(as_function& method, unsigned ms, as_object* this_ptr,
as_environment *env)
+ Timer::setInterval(as_function& method, unsigned ms,
boost::intrusive_ptr<as_object> this_ptr, as_environment *env)
{
_function = &method;
_interval = ms * 1000; // transform to microseconds
Index: server/timers.h
===================================================================
RCS file: /sources/gnash/gnash/server/timers.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- server/timers.h 19 Mar 2007 17:11:14 -0000 1.15
+++ server/timers.h 20 Mar 2007 15:01:20 -0000 1.16
@@ -92,7 +92,7 @@
/// The environment in which the associated function will be run.
/// Not sure we should provide this rather then extracting from
this_ptr...
///
- void setInterval(as_function& method, unsigned ms, as_object* this_ptr,
as_environment *env);
+ void setInterval(as_function& method, unsigned ms,
boost::intrusive_ptr<as_object> this_ptr, as_environment *env);
/// Clear the timer, ready for reuse
//
Index: server/video_stream_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/video_stream_instance.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- server/video_stream_instance.cpp 19 Mar 2007 17:11:14 -0000 1.15
+++ server/video_stream_instance.cpp 20 Mar 2007 15:01:20 -0000 1.16
@@ -15,7 +15,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-// $Id: video_stream_instance.cpp,v 1.15 2007/03/19 17:11:14 bjacques Exp $
+// $Id: video_stream_instance.cpp,v 1.16 2007/03/20 15:01:20 strk Exp $
#include "sprite_instance.h"
#include "video_stream_instance.h"
@@ -32,10 +32,9 @@
static as_value
attach_video(const fn_call& fn)
{
- assert(dynamic_cast<video_stream_instance*>(fn.this_ptr));
- video_stream_instance* video =
static_cast<video_stream_instance*>(fn.this_ptr);
+ boost::intrusive_ptr<video_stream_instance> video =
ensureType<video_stream_instance>(fn.this_ptr);
- if (fn.nargs != 1)
+ if (fn.nargs < 1)
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("attachVideo needs 1 arg");
@@ -43,11 +42,18 @@
return as_value();
}
- NetStream* ns = dynamic_cast<NetStream*>(fn.arg(0).to_object());
+ boost::intrusive_ptr<NetStream> ns =
boost::dynamic_pointer_cast<NetStream>(fn.arg(0).to_object());
if (ns)
{
video->setStream(ns);
}
+ else
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("attachVideo(%s) first arg is not a
NetStream instance.",
+ fn.arg(0).to_debug_string().c_str());
+ );
+ }
return as_value();
}
@@ -81,7 +87,7 @@
// If this is a video from a NetStream object, retrieve a video frame
from there.
if (_ns)
{
- NetStream* nso = _ns;
+ boost::intrusive_ptr<NetStream> nso = _ns;
if (nso->playing())
{
@@ -124,5 +130,11 @@
ranges.add(bounds);
}
+void
+video_stream_instance::setStream(boost::intrusive_ptr<NetStream> ns)
+{
+ _ns = ns;
+}
+
} // end of namespace gnash
Index: server/video_stream_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/video_stream_instance.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- server/video_stream_instance.h 28 Feb 2007 17:25:26 -0000 1.8
+++ server/video_stream_instance.h 20 Mar 2007 15:01:20 -0000 1.9
@@ -15,7 +15,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-// $Id: video_stream_instance.h,v 1.8 2007/02/28 17:25:26 udog Exp $
+// $Id: video_stream_instance.h,v 1.9 2007/03/20 15:01:20 strk Exp $
#ifndef GNASH_VIDEO_STREAM_INSTANCE_H
#define GNASH_VIDEO_STREAM_INSTANCE_H
@@ -55,15 +55,12 @@
void add_invalidated_bounds(InvalidatedRanges& ranges, bool force);
/// Set the input stream for this video
- void setStream(NetStream* ns)
- {
- _ns = ns;
- }
+ void setStream(boost::intrusive_ptr<NetStream> ns);
private:
// Who owns this ? Should it be an intrusive ptr ?
- NetStream* _ns;
+ boost::intrusive_ptr<NetStream> _ns;
embedVideoDecoder* m_decoder;
};
Index: server/asobj/Boolean.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Boolean.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/asobj/Boolean.cpp 20 Mar 2007 09:45:28 -0000 1.9
+++ server/asobj/Boolean.cpp 20 Mar 2007 15:01:20 -0000 1.10
@@ -86,7 +86,7 @@
static char* strtrue = "true";
static char* strfalse = "false";
- boolean_as_object* boolobj = ensureType<boolean_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<boolean_as_object> boolobj =
ensureType<boolean_as_object>(fn.this_ptr);
if (boolobj->val)
@@ -98,7 +98,7 @@
as_value boolean_valueof(const fn_call& fn)
{
- boolean_as_object* boolobj = ensureType<boolean_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<boolean_as_object> boolobj =
ensureType<boolean_as_object>(fn.this_ptr);
return as_value(boolobj->val);
}
Index: server/asobj/ContextMenu.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/ContextMenu.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/asobj/ContextMenu.cpp 20 Mar 2007 10:36:45 -0000 1.10
+++ server/asobj/ContextMenu.cpp 20 Mar 2007 15:01:20 -0000 1.11
@@ -127,7 +127,7 @@
as_value
ContextMenu::copy_method(const fn_call& fn)
{
- ContextMenu* ptr = ensureType<ContextMenu>(fn.this_ptr);
+ boost::intrusive_ptr<ContextMenu> ptr =
ensureType<ContextMenu>(fn.this_ptr);
UNUSED(ptr);
log_warning("%s: unimplemented", __FUNCTION__);
return as_value();
@@ -137,7 +137,7 @@
as_value
ContextMenu::hideBuiltInItems_method(const fn_call& fn)
{
- ContextMenu* ptr = ensureType<ContextMenu>(fn.this_ptr);
+ boost::intrusive_ptr<ContextMenu> ptr =
ensureType<ContextMenu>(fn.this_ptr);
UNUSED(ptr);
log_warning("%s: unimplemented", __FUNCTION__);
return as_value();
Index: server/asobj/Date.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Date.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- server/asobj/Date.cpp 20 Mar 2007 10:36:45 -0000 1.36
+++ server/asobj/Date.cpp 20 Mar 2007 15:01:20 -0000 1.37
@@ -453,7 +453,7 @@
#define date_get_proto(function, timefn, element) \
static as_value function(const fn_call& fn) { \
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
\
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr); \
time_t t = (time_t)(date->value / 1000.0); \
struct tm tm; \
return as_value(_##timefn##_r(&t, &tm)->element); \
@@ -510,7 +510,7 @@
// Also implements Date.getUTCMilliseconds
static as_value date_getmilliseconds(const fn_call& fn) {
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
return as_value((int) std::fmod(date->value, 1000.0));
}
@@ -579,7 +579,7 @@
/// sets a Date in milliseconds after January 1, 1970 00:00 UTC.
/// Returns value is the same aqs the paramemeter.
static as_value date_settime(const fn_call& fn) {
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
// assert(fn.nargs == 1);
if (fn.nargs < 1) {
@@ -623,10 +623,10 @@
// convert flash datestamp (number of milliseconds since the epoch as a double)
// to time structure and remaining milliseconds expressed in localtime.
static void
-local_date_to_tm_msec(date_as_object* &date, struct tm &tm, double &msec)
+local_date_to_tm_msec(date_as_object& date, struct tm &tm, double &msec)
{
- time_t t = (time_t)(date->value / 1000.0);
- msec = std::fmod(date->value, 1000.0);
+ time_t t = (time_t)(date.value / 1000.0);
+ msec = std::fmod(date.value, 1000.0);
_localtime_r(&t, &tm); // break out date/time elements
}
@@ -654,13 +654,13 @@
// gmtime() will split it for us, but mktime() only works in localtime.
static void
-utc_date_to_tm_msec(date_as_object* &date, struct tm &tm, double &msec)
+utc_date_to_tm_msec(date_as_object& date, struct tm &tm, double &msec)
{
#if USE_UTCCONV
- utctime(date->value, &tm, &msec);
+ utctime(date.value, &tm, &msec);
#else
- time_t t = (time_t)(date->value / 1000.0);
- msec = std::fmod(date->value, 1000.0);
+ time_t t = (time_t)(date.value / 1000.0);
+ msec = std::fmod(date.value, 1000.0);
_gmtime_r(&t, &tm);
#endif
}
@@ -692,16 +692,16 @@
// what the customer asked for
static void
-tm_msec_to_date(struct tm &tm, double &msec, date_as_object* &date, bool utc)
+tm_msec_to_date(struct tm &tm, double &msec, date_as_object& date, bool utc)
{
if (utc)
- date->value = utc_tm_msec_to_date(tm, msec);
+ date.value = utc_tm_msec_to_date(tm, msec);
else
- date->value = local_tm_msec_to_date(tm, msec);
+ date.value = local_tm_msec_to_date(tm, msec);
}
static void
-date_to_tm_msec(date_as_object* &date, struct tm &tm, double &msec, bool utc)
+date_to_tm_msec(date_as_object& date, struct tm &tm, double &msec, bool utc)
{
if (utc)
utc_date_to_tm_msec(date, tm, msec);
@@ -748,7 +748,7 @@
// to the day the clocks go forward.
static as_value _date_setfullyear(const fn_call& fn, bool utc) {
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
// assert(fn.nargs >= 1 && fn.nargs <= 3);
if (fn.nargs < 1) {
@@ -758,7 +758,7 @@
} else {
struct tm tm; double msec;
- date_to_tm_msec(date, tm, msec, utc);
+ date_to_tm_msec(*date, tm, msec, utc);
tm.tm_year = (int) fn.arg(0).to_number() - 1900;
if (fn.nargs >= 2)
tm.tm_mon = (int) fn.arg(1).to_number();
@@ -769,7 +769,7 @@
log_aserror("Date.setFullYear was called with more than
three arguments");
)
}
- tm_msec_to_date(tm, msec, date, utc);
+ tm_msec_to_date(tm, msec, *date, utc);
}
return as_value(date->value);
}
@@ -790,7 +790,7 @@
// There is no setUTCYear() function.
static as_value date_setyear(const fn_call& fn) {
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
// assert(fn.nargs == 1);
if (fn.nargs < 1) {
@@ -800,7 +800,7 @@
} else {
struct tm tm; double msec;
- date_to_tm_msec(date, tm, msec, false);
+ date_to_tm_msec(*date, tm, msec, false);
tm.tm_year = (int) fn.arg(0).to_number();
if (tm.tm_year < 100) tm.tm_year += 1900;
if (fn.nargs >= 2)
@@ -812,7 +812,7 @@
log_aserror("Date.setYear was called with more than three
arguments");
)
}
- tm_msec_to_date(tm, msec, date, false);
+ tm_msec_to_date(tm, msec, *date, false);
}
return as_value(date->value);
}
@@ -826,7 +826,7 @@
/// This implementation currently wraps it into the next month, which is wrong.
static as_value _date_setmonth(const fn_call& fn, bool utc) {
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
// assert(fn.nargs >= 1 && fn.nargs <= 2);
if (fn.nargs < 1) {
@@ -836,7 +836,7 @@
} else {
struct tm tm; double msec;
- date_to_tm_msec(date, tm, msec, utc);
+ date_to_tm_msec(*date, tm, msec, utc);
tm.tm_mon = (int) fn.arg(0).to_number();
if (fn.nargs >= 2)
tm.tm_mday = (int) fn.arg(2).to_number();
@@ -845,7 +845,7 @@
log_aserror("Date.setMonth was called with more than three
arguments");
)
}
- tm_msec_to_date(tm, msec, date, utc);
+ tm_msec_to_date(tm, msec, *date, utc);
}
return as_value(date->value);
}
@@ -857,7 +857,7 @@
/// day > 31. Example: setting the 35th in January results in Feb 4th.
static as_value _date_setdate(const fn_call& fn, bool utc) {
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
if (fn.nargs < 1) {
IF_VERBOSE_ASCODING_ERRORS(
@@ -866,9 +866,9 @@
} else {
struct tm tm; double msec;
- date_to_tm_msec(date, tm, msec, utc);
- tm.tm_mday = (int)(fn.arg(0).to_number());
- tm_msec_to_date(tm, msec, date, utc);
+ date_to_tm_msec(*date, tm, msec, utc);
+ tm.tm_mday = int(fn.arg(0).to_number());
+ tm_msec_to_date(tm, msec, *date, utc);
}
if (fn.nargs > 1) {
IF_VERBOSE_ASCODING_ERRORS(
@@ -891,7 +891,7 @@
/// setTime(n) or call the constructor with one argument.
static as_value _date_sethours(const fn_call& fn, bool utc) {
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
// assert(fn.nargs >= 1 && fn.nargs <= 4);
if (fn.nargs < 1) {
@@ -901,7 +901,7 @@
} else {
struct tm tm; double msec;
- date_to_tm_msec(date, tm, msec, utc);
+ date_to_tm_msec(*date, tm, msec, utc);
tm.tm_hour = (int) fn.arg(0).to_number();
if (fn.nargs >= 2)
tm.tm_min = (int) fn.arg(1).to_number();
@@ -914,7 +914,7 @@
log_aserror("Date.setHours was called with more than four
arguments");
)
}
- tm_msec_to_date(tm, msec, date, utc);
+ tm_msec_to_date(tm, msec, *date, utc);
}
return as_value(date->value);
}
@@ -928,7 +928,7 @@
/// Similarly, negative values carry you back into the previous
minute/hour/day.
static as_value _date_setminutes(const fn_call& fn, bool utc) {
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
//assert(fn.nargs >= 1 && fn.nargs <= 3);
if (fn.nargs < 1) {
@@ -938,7 +938,7 @@
} else {
struct tm tm; double msec;
- date_to_tm_msec(date, tm, msec, utc);
+ date_to_tm_msec(*date, tm, msec, utc);
tm.tm_min = (int) fn.arg(0).to_number();
if (fn.nargs >= 2)
tm.tm_sec = (int) fn.arg(1).to_number();
@@ -949,7 +949,7 @@
log_aserror("Date.setMinutes was called with more than
three arguments");
)
}
- tm_msec_to_date(tm, msec, date, utc);
+ tm_msec_to_date(tm, msec, *date, utc);
}
return as_value(date->value);
}
@@ -961,7 +961,7 @@
/// previous minute (or hour or calendar day) or on to the following ones.
static as_value _date_setseconds(const fn_call& fn, bool utc) {
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
// assert(fn.nargs >= 1 && fn.nargs <= 2);
if (fn.nargs < 1) {
@@ -975,7 +975,7 @@
// take account of leap seconds.
struct tm tm; double msec;
- date_to_tm_msec(date, tm, msec, utc);
+ date_to_tm_msec(*date, tm, msec, utc);
tm.tm_sec = (int) fn.arg(0).to_number();
if (fn.nargs >= 2)
msec = (int) fn.arg(1).to_number();
@@ -984,13 +984,13 @@
log_aserror("Date.setMinutes was called with more than
three arguments");
)
}
- tm_msec_to_date(tm, msec, date, utc);
+ tm_msec_to_date(tm, msec, *date, utc);
}
return as_value(date->value);
}
static as_value date_setmilliseconds(const fn_call& fn) {
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
// assert(fn.nargs == 1);
if (fn.nargs < 1) {
@@ -1049,7 +1049,7 @@
{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
char* dayweekname[7] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
time_t t = (time_t) (date->value / 1000.0);
struct tm tm;
@@ -1221,7 +1221,7 @@
// Also used to implement Date.getTime()
static as_value date_valueof(const fn_call& fn) {
- date_as_object* date = ensureType<date_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<date_as_object> date =
ensureType<date_as_object>(fn.this_ptr);
return as_value(date->value);
}
Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- server/asobj/Global.cpp 19 Mar 2007 17:11:14 -0000 1.52
+++ server/asobj/Global.cpp 20 Mar 2007 15:01:20 -0000 1.53
@@ -18,7 +18,7 @@
// Implementation of the Global ActionScript Object
-/* $Id: Global.cpp,v 1.52 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: Global.cpp,v 1.53 2007/03/20 15:01:20 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -319,7 +319,7 @@
// ASSetPropFlags(obj, props, n, allowFalse=false)
// object
- as_object* obj = fn.arg(0).to_object();
+ boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object();
if ( ! obj )
{
log_warning("Invalid call to ASSetPropFlags: "
Index: server/asobj/Key.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Key.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/asobj/Key.cpp 20 Mar 2007 11:36:48 -0000 1.18
+++ server/asobj/Key.cpp 20 Mar 2007 15:01:20 -0000 1.19
@@ -183,7 +183,7 @@
}
void
-key_as_object::add_listener(as_object* listener)
+key_as_object::add_listener(boost::intrusive_ptr<as_object> listener)
{
// Should we bother doing this every time someone calls add_listener(),
@@ -201,7 +201,7 @@
}
void
-key_as_object::remove_listener(as_object* listener)
+key_as_object::remove_listener(boost::intrusive_ptr<as_object> listener)
{
for (std::vector<boost::intrusive_ptr<as_object> >::iterator iter =
m_listeners.begin(); iter != m_listeners.end(); )
@@ -231,14 +231,14 @@
return as_value();
}
- as_object* listener = fn.arg(0).to_object();
+ boost::intrusive_ptr<as_object> listener = fn.arg(0).to_object();
if (listener == NULL)
{
log_error("key_add_listener passed a NULL object; ignored\n");
return as_value();
}
- key_as_object* ko = ensureType<key_as_object>( fn.this_ptr );
+ boost::intrusive_ptr<key_as_object> ko =
ensureType<key_as_object>(fn.this_ptr);
ko->add_listener(listener);
return as_value();
@@ -247,7 +247,7 @@
as_value key_get_ascii(const fn_call& fn)
// Return the ascii value of the last key pressed.
{
- key_as_object* ko = ensureType<key_as_object>( fn.this_ptr );
+ boost::intrusive_ptr<key_as_object> ko =
ensureType<key_as_object>(fn.this_ptr);
int code = ko->get_last_key_pressed();
if (code < 0)
@@ -265,7 +265,7 @@
as_value key_get_code(const fn_call& fn)
// Returns the keycode of the last key pressed.
{
- key_as_object* ko = ensureType<key_as_object>( fn.this_ptr );
+ boost::intrusive_ptr<key_as_object> ko =
ensureType<key_as_object>(fn.this_ptr);
return as_value(ko->get_last_key_pressed());
}
@@ -281,7 +281,7 @@
int code = (int) fn.arg(0).to_number();
- key_as_object* ko = ensureType<key_as_object>( fn.this_ptr );
+ boost::intrusive_ptr<key_as_object> ko =
ensureType<key_as_object>(fn.this_ptr);
return as_value(ko->is_key_down(code));
}
@@ -303,14 +303,14 @@
return as_value();
}
- as_object* listener = fn.arg(0).to_object();
+ boost::intrusive_ptr<as_object> listener = fn.arg(0).to_object();
if (listener == NULL)
{
log_error("key_remove_listener passed a NULL object; ignored\n");
return as_value();
}
- key_as_object* ko = ensureType<key_as_object>( fn.this_ptr );
+ boost::intrusive_ptr<key_as_object> ko =
ensureType<key_as_object>(fn.this_ptr);
ko->remove_listener(listener);
return as_value();
@@ -357,9 +357,9 @@
if ( global->get_member(objName, &kval) )
{
//log_msg("Found member 'Key' in _global: %s",
kval.to_string());
- as_object* obj = kval.to_object();
+ boost::intrusive_ptr<as_object> obj = kval.to_object();
//log_msg("_global.Key to_object() : %s @ %p",
typeid(*obj).name(), obj);
- keyobject = dynamic_cast<key_as_object*>( obj );
+ keyobject = boost::dynamic_pointer_cast<key_as_object>(
obj );
}
}
Index: server/asobj/Key.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Key.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/asobj/Key.h 19 Mar 2007 17:11:14 -0000 1.12
+++ server/asobj/Key.h 20 Mar 2007 15:01:20 -0000 1.13
@@ -16,7 +16,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: Key.h,v 1.12 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: Key.h,v 1.13 2007/03/20 15:01:20 strk Exp $ */
#ifndef __KEY_H__
#define __KEY_H__
@@ -111,9 +111,9 @@
void set_key_up(int code);
- void add_listener(as_object* listener);
+ void add_listener(boost::intrusive_ptr<as_object> listener);
- void remove_listener(as_object* listener);
+ void remove_listener(boost::intrusive_ptr<as_object> listener);
int get_last_key_pressed() const;
};
Index: server/asobj/LoadVars.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/LoadVars.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- server/asobj/LoadVars.cpp 20 Mar 2007 10:36:45 -0000 1.16
+++ server/asobj/LoadVars.cpp 20 Mar 2007 15:01:20 -0000 1.17
@@ -428,7 +428,7 @@
as_value
LoadVars::onLoad_getset(const fn_call& fn)
{
- LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
+ boost::intrusive_ptr<LoadVars> ptr = ensureType<LoadVars>(fn.this_ptr);
if ( fn.nargs == 0 ) // getter
{
@@ -448,7 +448,7 @@
as_value
LoadVars::checkLoads_wrapper(const fn_call& fn)
{
- LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
+ boost::intrusive_ptr<LoadVars> ptr = ensureType<LoadVars>(fn.this_ptr);
ptr->checkLoads();
return as_value();
}
@@ -458,7 +458,7 @@
LoadVars::onData_getset(const fn_call& fn)
{
- LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
+ boost::intrusive_ptr<LoadVars> ptr = ensureType<LoadVars>(fn.this_ptr);
if ( fn.nargs == 0 ) // getter
{
@@ -479,7 +479,7 @@
LoadVars::loaded_getset(const fn_call& fn)
{
- LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
+ boost::intrusive_ptr<LoadVars> ptr = ensureType<LoadVars>(fn.this_ptr);
if ( fn.nargs == 0 ) // getter
{
@@ -498,7 +498,7 @@
static as_value
loadvars_addrequestheader(const fn_call& fn)
{
- LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
+ boost::intrusive_ptr<LoadVars> ptr = ensureType<LoadVars>(fn.this_ptr);
UNUSED(ptr);
log_error("%s: unimplemented", __FUNCTION__);
return as_value();
@@ -507,7 +507,7 @@
static as_value
loadvars_decode(const fn_call& fn)
{
- LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
+ boost::intrusive_ptr<LoadVars> ptr = ensureType<LoadVars>(fn.this_ptr);
UNUSED(ptr);
log_error("%s: unimplemented", __FUNCTION__);
return as_value();
@@ -516,21 +516,21 @@
as_value
LoadVars::getBytesLoaded_method(const fn_call& fn)
{
- LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
+ boost::intrusive_ptr<LoadVars> ptr = ensureType<LoadVars>(fn.this_ptr);
return as_value(ptr->getBytesLoaded());
}
as_value
LoadVars::getBytesTotal_method(const fn_call& fn)
{
- LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
+ boost::intrusive_ptr<LoadVars> ptr = ensureType<LoadVars>(fn.this_ptr);
return as_value(ptr->getBytesTotal());
}
static as_value
loadvars_load(const fn_call& fn)
{
- LoadVars* obj = ensureType<LoadVars>(fn.this_ptr);
+ boost::intrusive_ptr<LoadVars> obj = ensureType<LoadVars>(fn.this_ptr);
if ( fn.nargs < 1 )
{
@@ -557,7 +557,7 @@
static as_value
loadvars_send(const fn_call& fn)
{
- LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
+ boost::intrusive_ptr<LoadVars> ptr = ensureType<LoadVars>(fn.this_ptr);
UNUSED(ptr);
log_error("%s: unimplemented", __FUNCTION__);
return as_value();
@@ -566,7 +566,7 @@
static as_value
loadvars_sendandload(const fn_call& fn)
{
- LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
+ boost::intrusive_ptr<LoadVars> ptr = ensureType<LoadVars>(fn.this_ptr);
if ( fn.nargs < 2 )
{
@@ -585,7 +585,7 @@
return as_value(false);
}
- LoadVars* target = dynamic_cast<LoadVars*>(fn.arg(1).to_object());
+ boost::intrusive_ptr<LoadVars> target =
boost::dynamic_pointer_cast<LoadVars>(fn.arg(1).to_object());
if ( ! target )
{
IF_VERBOSE_ASCODING_ERRORS(
@@ -598,7 +598,7 @@
bool post = true;
if ( fn.nargs > 2 && fn.arg(2).to_std_string() == "GET" ) post = false;
- //log_msg("LoadVars.sendAndLoad(%s, %p) called, and returning TRUE",
urlstr.c_str(), target);
+ //log_msg("LoadVars.sendAndLoad(%s, %p) called, and returning TRUE",
urlstr.c_str(), target.get());
ptr->sendAndLoad(urlstr, *target, post);
return as_value(true);
@@ -607,7 +607,7 @@
static as_value
loadvars_tostring(const fn_call& fn)
{
- LoadVars* ptr = ensureType<LoadVars>(fn.this_ptr);
+ boost::intrusive_ptr<LoadVars> ptr = ensureType<LoadVars>(fn.this_ptr);
UNUSED(ptr);
log_error("%s: unimplemented", __FUNCTION__);
return as_value();
Index: server/asobj/LocalConnection.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/LocalConnection.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/asobj/LocalConnection.cpp 20 Mar 2007 11:36:48 -0000 1.9
+++ server/asobj/LocalConnection.cpp 20 Mar 2007 15:01:20 -0000 1.10
@@ -124,7 +124,7 @@
{
// log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
- localconnection_as_object *ptr =
ensureType<localconnection_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<localconnection_as_object> ptr =
ensureType<localconnection_as_object>(fn.this_ptr);
ptr->obj.close();
return as_value();
@@ -135,7 +135,7 @@
{
// log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
bool ret;
- localconnection_as_object *ptr =
ensureType<localconnection_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<localconnection_as_object> ptr =
ensureType<localconnection_as_object>(fn.this_ptr);
if (fn.nargs != 0) {
ret =
ptr->obj.connect(fn.env->bottom(fn.first_arg_bottom_index).to_string());
@@ -151,7 +151,7 @@
as_value localconnection_domain(const fn_call& fn)
{
// log_msg("%s:\n", __PRETTY_FUNCTION__);
- localconnection_as_object *ptr =
ensureType<localconnection_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<localconnection_as_object> ptr =
ensureType<localconnection_as_object>(fn.this_ptr);
return as_value(ptr->obj.domain().c_str());
}
Index: server/asobj/MovieClipLoader.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/MovieClipLoader.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- server/asobj/MovieClipLoader.cpp 20 Mar 2007 11:36:48 -0000 1.21
+++ server/asobj/MovieClipLoader.cpp 20 Mar 2007 15:01:20 -0000 1.22
@@ -126,9 +126,9 @@
/// This function will call add_ref() on the
/// given object.
///
- void addListener(as_object* listener);
+ void addListener(boost::intrusive_ptr<as_object> listener);
- void removeListener(as_object* listener);
+ void removeListener(boost::intrusive_ptr<as_object> listener);
/// Invoke any listener for the specified event
void dispatchEvent(const std::string& eventName, fn_call& fn);
@@ -137,7 +137,9 @@
private:
- std::set<as_object*> _listeners;
+ typedef std::set< boost::intrusive_ptr<as_object> > Listeners;
+
+ Listeners _listeners;
bool _started;
bool _completed;
tu_string _filespec;
@@ -233,31 +235,20 @@
void
-MovieClipLoader::addListener(as_object* listener)
+MovieClipLoader::addListener(boost::intrusive_ptr<as_object> listener)
{
assert(listener); // caller should check
- if ( _listeners.insert(listener).second )
- {
- // listener inserted
- listener->add_ref();
- }
- else
- {
- // listener already present, no need to
- // increment ref count
- }
-
+ _listeners.insert(listener);
}
void
-MovieClipLoader::removeListener(as_object* listener)
+MovieClipLoader::removeListener(boost::intrusive_ptr<as_object> listener)
{
assert(listener); // caller should check
- std::set<as_object*>::iterator it = _listeners.find(listener);
+ Listeners::iterator it = _listeners.find(listener);
if ( it != _listeners.end() )
{
- (*it)->drop_ref();
_listeners.erase(it);
}
}
@@ -267,7 +258,7 @@
void
MovieClipLoader::dispatchEvent(const std::string& event, fn_call& fn)
{
- typedef std::set<as_object*>::iterator iterator;
+ typedef Listeners::iterator iterator;
#if GNASH_DEBUG
log_msg("Dispatching %s event to " SIZET_FMT " listeners",
@@ -278,7 +269,7 @@
it != itEnd;
++it)
{
- as_object* listener = *it;
+ boost::intrusive_ptr<as_object> listener = *it;
as_value method;
if ( ! listener->get_member(event.c_str(), &method) )
{
@@ -296,7 +287,7 @@
" %s function", event.c_str());
#endif
- call_method(method, fn.env, fn.this_ptr, fn.nargs,
fn.first_arg_bottom_index);
+ call_method(method, fn.env, fn.this_ptr.get(), fn.nargs,
fn.first_arg_bottom_index);
}
}
@@ -308,7 +299,7 @@
//log_msg("%s: nargs = %d\n", __FUNCTION__, fn.nargs);
- MovieClipLoader* ptr = ensureType<MovieClipLoader>(fn.this_ptr);
+ boost::intrusive_ptr<MovieClipLoader> ptr =
ensureType<MovieClipLoader>(fn.this_ptr);
as_value& url_arg = fn.arg(0);
#if 0 // whatever it is, we'll need a string, the check below would only be
worth
@@ -374,26 +365,26 @@
{
//log_msg("%s: nargs = %d\n", __FUNCTION__, nargs);
- MovieClipLoader* ptr = ensureType<MovieClipLoader>(fn.this_ptr);
+ boost::intrusive_ptr<MovieClipLoader> ptr =
ensureType<MovieClipLoader>(fn.this_ptr);
- as_object *target = fn.arg(0).to_object();
+ boost::intrusive_ptr<as_object> target = fn.arg(0).to_object();
- struct mcl *mcl_data = ptr->getProgress(target);
+ struct mcl *mcl_data = ptr->getProgress(target.get());
- mcl_as_object *mcl_obj = new mcl_as_object;
+ boost::intrusive_ptr<mcl_as_object> mcl_obj ( new mcl_as_object );
mcl_obj->init_member("bytesLoaded", mcl_data->bytes_loaded);
mcl_obj->init_member("bytesTotal", mcl_data->bytes_total);
- return as_value(mcl_obj); // will store in a boost::intrusive_ptr
+ return as_value(mcl_obj.get()); // will store in a boost::intrusive_ptr
}
static as_value
moviecliploader_addlistener(const fn_call& fn)
{
- MovieClipLoader* mcl = ensureType<MovieClipLoader>(fn.this_ptr);
+ boost::intrusive_ptr<MovieClipLoader> mcl =
ensureType<MovieClipLoader>(fn.this_ptr);
- as_object *listener = fn.arg(0).to_object();
+ boost::intrusive_ptr<as_object> listener = fn.arg(0).to_object();
if ( ! listener )
{
log_error("ActionScript bug: Listener given to
MovieClipLoader.addListener() is not an object");
@@ -407,9 +398,9 @@
static as_value
moviecliploader_removelistener(const fn_call& fn)
{
- MovieClipLoader* mcl = ensureType<MovieClipLoader>(fn.this_ptr);
+ boost::intrusive_ptr<MovieClipLoader> mcl =
ensureType<MovieClipLoader>(fn.this_ptr);
- as_object *listener = fn.arg(0).to_object();
+ boost::intrusive_ptr<as_object> listener = fn.arg(0).to_object();
if ( ! listener )
{
log_error("ActionScript bug: Listener given to
MovieClipLoader.removeListener() is not an object");
Index: server/asobj/NetConnection.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/asobj/NetConnection.cpp 20 Mar 2007 10:36:45 -0000 1.30
+++ server/asobj/NetConnection.cpp 20 Mar 2007 15:01:20 -0000 1.31
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: NetConnection.cpp,v 1.30 2007/03/20 10:36:45 ann Exp $ */
+/* $Id: NetConnection.cpp,v 1.31 2007/03/20 15:01:20 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -175,7 +175,7 @@
{
GNASH_REPORT_FUNCTION;
- NetConnection *ptr = ensureType<NetConnection>(fn.this_ptr);
+ boost::intrusive_ptr<NetConnection> ptr =
ensureType<NetConnection>(fn.this_ptr);
if (fn.nargs > 0) {
ptr->addToURL(fn.arg(0).to_string());
Index: server/asobj/NetConnection.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/asobj/NetConnection.h 9 Mar 2007 14:38:29 -0000 1.20
+++ server/asobj/NetConnection.h 20 Mar 2007 15:01:20 -0000 1.21
@@ -1,5 +1,5 @@
//
-// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: NetConnection.h,v 1.20 2007/03/09 14:38:29 tgc Exp $ */
+/* $Id: NetConnection.h,v 1.21 2007/03/20 15:01:20 strk Exp $ */
#ifndef __NETCONNECTION_H__
#define __NETCONNECTION_H__
@@ -41,7 +41,7 @@
// Forward declarations
namespace gnash {
- class NetStream;
+ //class NetStream;
}
namespace gnash {
Index: server/asobj/NetStream.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStream.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- server/asobj/NetStream.cpp 20 Mar 2007 10:36:45 -0000 1.31
+++ server/asobj/NetStream.cpp 20 Mar 2007 15:01:20 -0000 1.32
@@ -15,7 +15,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: NetStream.cpp,v 1.31 2007/03/20 10:36:45 ann Exp $ */
+/* $Id: NetStream.cpp,v 1.32 2007/03/20 15:01:20 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -71,7 +71,7 @@
if (fn.nargs > 0)
{
- NetConnection* ns =
dynamic_cast<NetConnection*>(fn.arg(0).to_object());
+ boost::intrusive_ptr<NetConnection> ns =
boost::dynamic_pointer_cast<NetConnection>(fn.arg(0).to_object());
if ( ns )
{
netstream_obj->setNetCon(ns);
@@ -92,14 +92,14 @@
static as_value netstream_close(const fn_call& fn)
{
- NetStream* ns = ensureType<NetStream>(fn.this_ptr);
+ boost::intrusive_ptr<NetStream> ns = ensureType<NetStream>(fn.this_ptr);
ns->close();
return as_value();
}
static as_value netstream_pause(const fn_call& fn)
{
- NetStream* ns = ensureType<NetStream>(fn.this_ptr);
+ boost::intrusive_ptr<NetStream> ns = ensureType<NetStream>(fn.this_ptr);
// mode: -1 ==> toogle, 0==> pause, 1==> play
int mode = -1;
@@ -113,7 +113,7 @@
static as_value netstream_play(const fn_call& fn)
{
- NetStream* ns = ensureType<NetStream>(fn.this_ptr);
+ boost::intrusive_ptr<NetStream> ns = ensureType<NetStream>(fn.this_ptr);
if (fn.nargs < 1)
{
@@ -131,7 +131,7 @@
}
static as_value netstream_seek(const fn_call& fn) {
- NetStream* ns = ensureType<NetStream>(fn.this_ptr);
+ boost::intrusive_ptr<NetStream> ns = ensureType<NetStream>(fn.this_ptr);
double time = 0;
if (fn.nargs > 0)
@@ -143,7 +143,7 @@
return as_value();
}
static as_value netstream_setbuffertime(const fn_call& fn) {
- NetStream* ns = ensureType<NetStream>(fn.this_ptr);
+ boost::intrusive_ptr<NetStream> ns = ensureType<NetStream>(fn.this_ptr);
UNUSED(ns);
log_msg("%s:unimplemented \n", __FUNCTION__);
return as_value();
@@ -154,7 +154,7 @@
netstream_time(const fn_call& fn)
{
- NetStream* ns = ensureType<NetStream>(fn.this_ptr);
+ boost::intrusive_ptr<NetStream> ns = ensureType<NetStream>(fn.this_ptr);
if ( fn.nargs == 0 )
{
@@ -174,7 +174,7 @@
netstream_bytesloaded(const fn_call& fn)
{
- NetStream* ns = ensureType<NetStream>(fn.this_ptr);
+ boost::intrusive_ptr<NetStream> ns = ensureType<NetStream>(fn.this_ptr);
if ( fn.nargs == 0 )
{
@@ -194,7 +194,7 @@
netstream_bytestotal(const fn_call& fn)
{
- NetStream* ns = ensureType<NetStream>(fn.this_ptr);
+ boost::intrusive_ptr<NetStream> ns = ensureType<NetStream>(fn.this_ptr);
if ( fn.nargs == 0 )
{
Index: server/asobj/NetStream.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStream.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/asobj/NetStream.h 9 Mar 2007 14:38:29 -0000 1.22
+++ server/asobj/NetStream.h 20 Mar 2007 15:01:20 -0000 1.23
@@ -1,5 +1,5 @@
//
-// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
//
//
-/* $Id: NetStream.h,v 1.22 2007/03/09 14:38:29 tgc Exp $ */
+/* $Id: NetStream.h,v 1.23 2007/03/20 15:01:20 strk Exp $ */
#ifndef __NETSTREAM_H__
#define __NETSTREAM_H__
@@ -33,10 +33,11 @@
#include "impl.h"
#include "video_stream_instance.h"
+#include "NetConnection.h"
// Forward declarations
namespace gnash {
- class NetConnection;
+ //class NetConnection;
}
namespace gnash {
@@ -46,7 +47,7 @@
protected:
- NetConnection* _netCon;
+ boost::intrusive_ptr<NetConnection> _netCon;
public:
@@ -66,7 +67,7 @@
virtual void set_status(const char* /*code*/){}
- virtual void setNetCon(NetConnection* nc)
+ virtual void setNetCon(boost::intrusive_ptr<NetConnection> nc)
{
_netCon = nc;
}
Index: server/asobj/NetStreamGst.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamGst.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/asobj/NetStreamGst.cpp 4 Mar 2007 21:35:31 -0000 1.13
+++ server/asobj/NetStreamGst.cpp 20 Mar 2007 15:01:20 -0000 1.14
@@ -1,5 +1,5 @@
//
-// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -264,7 +264,7 @@
void
NetStreamGst::startPlayback(NetStreamGst* ns)
{
- NetConnection* nc = ns->_netCon;
+ boost::intrusive_ptr<NetConnection> nc = ns->_netCon;
assert(nc);
// Pass stuff from/to the NetConnection object.
@@ -423,7 +423,7 @@
NetStreamGst* ns = static_cast<NetStreamGst*>(opaque);
- NetConnection* nc = ns->_netCon;
+ boost::intrusive_ptr<NetConnection> nc = ns->_netCon;
size_t ret = nc->read(static_cast<void*>(buf), buf_size);
ns->inputPos += ret;
@@ -436,7 +436,7 @@
NetStreamGst::seekMedia(void *opaque, int offset, int whence){
NetStreamGst* ns = static_cast<NetStreamGst*>(opaque);
- NetConnection* nc = ns->_netCon;
+ boost::intrusive_ptr<NetConnection> nc = ns->_netCon;
bool ret;
Index: server/asobj/Object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Object.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- server/asobj/Object.cpp 19 Mar 2007 17:11:14 -0000 1.19
+++ server/asobj/Object.cpp 20 Mar 2007 15:01:20 -0000 1.20
@@ -18,7 +18,7 @@
//
//
-/* $Id: Object.cpp,v 1.19 2007/03/19 17:11:14 bjacques Exp $ */
+/* $Id: Object.cpp,v 1.20 2007/03/20 15:01:20 strk Exp $ */
// Implementation of ActionScript Object class.
@@ -162,7 +162,7 @@
object_addproperty(const fn_call& fn)
{
assert(fn.this_ptr);
- as_object* obj = fn.this_ptr;
+ boost::intrusive_ptr<as_object> obj = fn.this_ptr;
if ( fn.nargs != 3 )
{
@@ -372,11 +372,11 @@
return as_value(false);
}
- as_object* obj = fn.arg(0).to_object();
+ boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object();
if ( ! obj )
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror("First arg to Object.isPrototypeOf(%s) is not an
object", fn.arg(0).to_string());
+ log_aserror("First arg to Object.isPrototypeOf(%s) is not an
object", fn.arg(0).to_debug_string().c_str());
);
return as_value(false);
}
Index: server/asobj/Sound.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Sound.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/asobj/Sound.cpp 20 Mar 2007 10:36:45 -0000 1.9
+++ server/asobj/Sound.cpp 20 Mar 2007 15:01:20 -0000 1.10
@@ -253,7 +253,7 @@
sound_start(const fn_call& fn)
{
log_action("-- start sound");
- Sound* so = ensureType<Sound>(fn.this_ptr);
+ boost::intrusive_ptr<Sound> so = ensureType<Sound>(fn.this_ptr);
int loop = 0;
int secondOffset = 0;
@@ -276,7 +276,7 @@
sound_stop(const fn_call& fn)
{
log_action("-- stop sound ");
- Sound* so = ensureType<Sound>(fn.this_ptr);
+ boost::intrusive_ptr<Sound> so = ensureType<Sound>(fn.this_ptr);
int si = -1;
@@ -325,7 +325,7 @@
return as_value();
}
- Sound* so = ensureType<Sound>(fn.this_ptr);
+ boost::intrusive_ptr<Sound> so = ensureType<Sound>(fn.this_ptr);
const char* name = fn.arg(0).to_string();
if (!name) {
@@ -418,7 +418,7 @@
sound_getvolume(const fn_call& fn)
{
- Sound* so = ensureType<Sound>(fn.this_ptr);
+ boost::intrusive_ptr<Sound> so = ensureType<Sound>(fn.this_ptr);
int volume = so->getVolume();
@@ -436,7 +436,7 @@
return as_value();
}
- Sound* so = ensureType<Sound>(fn.this_ptr);
+ boost::intrusive_ptr<Sound> so = ensureType<Sound>(fn.this_ptr);
so->loadSound(fn.arg(0).to_std_string(), fn.arg(1).to_bool());
return as_value();
@@ -477,7 +477,7 @@
return as_value();
}
- Sound* so = ensureType<Sound>(fn.this_ptr);
+ boost::intrusive_ptr<Sound> so = ensureType<Sound>(fn.this_ptr);
int volume = (int) fn.arg(0).to_number();
so->setVolume(volume);
@@ -487,7 +487,7 @@
as_value
sound_duration(const fn_call& fn)
{
- Sound* so = ensureType<Sound>(fn.this_ptr);
+ boost::intrusive_ptr<Sound> so = ensureType<Sound>(fn.this_ptr);
if ( fn.nargs == 0 ) {
return as_value(so->getDuration());
} else {
@@ -513,7 +513,7 @@
as_value
sound_position(const fn_call& fn)
{
- Sound* so = ensureType<Sound>(fn.this_ptr);
+ boost::intrusive_ptr<Sound> so = ensureType<Sound>(fn.this_ptr);
if ( fn.nargs == 0 ) {
return as_value(so->getPosition());
} else {
Index: server/asobj/string.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/string.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/asobj/string.cpp 20 Mar 2007 10:36:45 -0000 1.20
+++ server/asobj/string.cpp 20 Mar 2007 15:01:20 -0000 1.21
@@ -1,5 +1,5 @@
//
-// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: string.cpp,v 1.20 2007/03/20 10:36:45 ann Exp $ */
+/* $Id: string.cpp,v 1.21 2007/03/20 15:01:20 strk Exp $ */
// Implementation of ActionScript String class.
@@ -116,7 +116,7 @@
static as_value
string_get_length(const fn_call& fn)
{
- tu_string_as_object* str = ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> str =
ensureType<tu_string_as_object>(fn.this_ptr);
return as_value(str->m_string.utf8_length());
@@ -135,7 +135,7 @@
static as_value
string_concat(const fn_call& fn)
{
- tu_string_as_object* str = ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> str =
ensureType<tu_string_as_object>(fn.this_ptr);
tu_string this_string = str->m_string;
int len = strlen(this_string.c_str());
@@ -161,7 +161,7 @@
static as_value
string_slice(const fn_call& fn)
{
- tu_string_as_object* str = ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> str =
ensureType<tu_string_as_object>(fn.this_ptr);
tu_string this_string = str->m_string;
// Pull a slice out of this_string.
int start = 0;
@@ -194,7 +194,7 @@
static as_value
string_split(const fn_call& fn)
{
- tu_string_as_object* str = ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> str =
ensureType<tu_string_as_object>(fn.this_ptr);
boost::intrusive_ptr<tu_string_as_object> this_string_ptr(str); // why
??
@@ -266,7 +266,7 @@
static as_value
string_last_index_of(const fn_call& fn)
{
- tu_string_as_object* this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
if (fn.nargs < 1)
{
@@ -304,7 +304,7 @@
static as_value
string_sub_str(const fn_call& fn)
{
- tu_string_as_object* this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
tu_string this_string = this_string_ptr->m_string;
// Pull a slice out of this_string.
@@ -330,7 +330,7 @@
static as_value
string_sub_string(const fn_call& fn)
{
- tu_string_as_object* this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
tu_string this_string = this_string_ptr->m_string;
// Pull a slice out of this_string.
int start = 0;
@@ -355,7 +355,7 @@
static as_value
string_index_of(const fn_call& fn)
{
- tu_string_as_object* this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
if (fn.nargs < 1)
{
@@ -384,8 +384,6 @@
static as_value
string_from_char_code(const fn_call& fn)
{
- //tu_string_as_object* this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
-
tu_string result;
for (unsigned int i = 0; i < fn.nargs; i++)
@@ -400,7 +398,7 @@
static as_value
string_char_code_at(const fn_call& fn)
{
- tu_string_as_object* this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
// assert(fn.nargs == 1);
if (fn.nargs < 1) {
@@ -429,7 +427,7 @@
static as_value
string_char_at(const fn_call& fn)
{
- tu_string_as_object* this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
// assert(fn.nargs == 1);
if (fn.nargs < 1) {
@@ -458,7 +456,7 @@
static as_value
string_to_upper_case(const fn_call& fn)
{
- tu_string_as_object* this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
return as_value(this_string_ptr->m_string.utf8_to_upper());
}
@@ -466,7 +464,7 @@
static as_value
string_to_lower_case(const fn_call& fn)
{
- tu_string_as_object* this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
return as_value(this_string_ptr->m_string.utf8_to_lower());
}
@@ -474,7 +472,7 @@
static as_value
string_to_string(const fn_call& fn)
{
- tu_string_as_object* this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<tu_string_as_object> this_string_ptr =
ensureType<tu_string_as_object>(fn.this_ptr);
return as_value(this_string_ptr->m_string);
}
Index: server/asobj/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- server/asobj/xml.cpp 20 Mar 2007 11:36:48 -0000 1.21
+++ server/asobj/xml.cpp 20 Mar 2007 15:01:20 -0000 1.22
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: xml.cpp,v 1.21 2007/03/20 11:36:48 ann Exp $ */
+/* $Id: xml.cpp,v 1.22 2007/03/20 15:01:20 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -53,7 +53,7 @@
DSOEXPORT as_value xml_new(const fn_call& fn);
static as_value xml_load(const fn_call& fn);
-static as_value xml_set_current(const fn_call& fn);
+//static as_value xml_set_current(const fn_call& fn); // UNDEFINED
static as_value xml_addrequestheader(const fn_call& fn);
static as_value xml_appendchild(const fn_call& fn);
@@ -73,7 +73,7 @@
static as_value xml_childnodes(const fn_call& fn);
// These are the event handlers called for this object
-static as_value xml_ondata(const fn_call& fn);
+//static as_value xml_ondata(const fn_call& fn); // UNUSED
static as_value xml_loaded(const fn_call& fn);
// Properties
@@ -768,7 +768,7 @@
//GNASH_REPORT_FUNCTION;
- XML *xml_obj = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> xml_obj = ensureType<XML>(fn.this_ptr);
std::string filespec = fn.arg(0).to_string();
@@ -796,7 +796,7 @@
if (xml_obj->hasChildNodes() == false) {
log_error("%s: No child nodes!\n", __FUNCTION__);
}
- xml_obj->setupFrame(xml_obj, xml_obj->firstChild(), false);
+ xml_obj->setupFrame(xml_obj.get(), xml_obj->firstChild(), false);
#if 1
if (fn.this_ptr->get_member("onLoad", &method)) {
@@ -842,7 +842,7 @@
as_value method;
as_value val;
static bool first = true; // This event handler should only be
executed once.
- XML* ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
if ((ptr->loaded()) && (first)) {
// env->set_variable("success", true, 0);
@@ -857,7 +857,7 @@
if (fn.this_ptr->get_member("onLoad", &method)) {
// log_msg("FIXME: Found onLoad!\n");
- val = call_method(method, fn.env, fn.this_ptr, 0, 0);
+ val = call_method(method, fn.env, fn.this_ptr.get(), 0, 0);
} else {
log_msg("FIXME: Couldn't find onLoad!\n");
}
@@ -867,6 +867,7 @@
}
// This is the default event handler, and is usually redefined in the SWF
script
+#if 0 // UNUSED, it seems
as_value
xml_ondata(const fn_call& fn)
{
@@ -876,7 +877,7 @@
as_value val;
static bool first = true; // FIXME: ugly hack!
- XML* ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
if ((ptr->loaded()) && (first)) {
if (fn.this_ptr->get_member("onData", &method)) {
@@ -892,6 +893,7 @@
//fn.result->set(&val);
return as_value(val.to_bool());
}
+#endif // UNUSED
void
attachXMLInterface(as_object& o)
@@ -947,13 +949,13 @@
xml_new(const fn_call& fn)
{
as_value inum;
- XML *xml_obj;
+ boost::intrusive_ptr<XML> xml_obj;
//const char *data;
// log_msg("%s: nargs=%d\n", __FUNCTION__, fn.nargs);
if (fn.nargs > 0) {
- as_object* obj = fn.env->top(0).to_object();
+ boost::intrusive_ptr<as_object> obj = fn.env->top(0).to_object();
if (! obj ) {
xml_obj = new XML;
@@ -961,21 +963,21 @@
tu_string datain = fn.env->top(0).to_tu_string();
xml_obj->parseXML(datain);
//log_msg("*** Start setting up the stack frames ***\n");
- xml_obj->setupFrame(xml_obj, xml_obj->firstChild(), true);
+ xml_obj->setupFrame(xml_obj.get(), xml_obj->firstChild(), true);
//xml_obj->clear();
//delete xml_obj->firstChild();
} else {
- XML* xml_obj = ensureType<XML>(obj);
+ xml_obj = boost::dynamic_pointer_cast<XML>(obj);
//log_msg("\tCloned the XML object at %p\n", xml_obj);
//result->set(xml_obj);
- return as_value(xml_obj);
+ return as_value(xml_obj.get());
}
} else {
xml_obj = new XML;
//log_msg("\tCreated New XML object at %p\n", xml_obj);
}
- return as_value(xml_obj);
+ return as_value(xml_obj.get());
}
//
@@ -995,7 +997,7 @@
log_msg("%s:\n", __FUNCTION__);
- XML* ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
std::string filespec = fn.arg(0).to_string();
//fn.result->set(ptr->loaded());
return as_value(ptr->loaded());
@@ -1017,13 +1019,23 @@
GNASH_REPORT_FUNCTION;
// log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
if (fn.nargs > 0) {
- XML *ptr = ensureType<XML>(fn.this_ptr);
- XMLNode *xml_obj = dynamic_cast<XMLNode*>(fn.arg(0).to_object());
+
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> xml_obj =
boost::dynamic_pointer_cast<XMLNode>(fn.arg(0).to_object());
+ if ( ! xml_obj )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("First argument to XML::appendChild() is not an
XMLNode");
+ );
+ return as_value();
+ }
+
if (xml_obj->nodeType() == XML_ELEMENT_NODE) {
- ptr->appendChild(xml_obj);
+ ptr->appendChild(xml_obj.get());
} else {
ptr->nodeValueSet(xml_obj->nodeValue());
}
+
} else {
log_msg("ERROR: no child XMLNode paramaters!\\n");
}
@@ -1034,7 +1046,7 @@
{
GNASH_REPORT_FUNCTION;
// log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
XMLNode *xml_obj;
if (fn.nargs > 0) {
@@ -1091,8 +1103,6 @@
{
// GNASH_REPORT_FUNCTION;
- //XML *ptr = ensureType<XML>(fn.this_ptr);
-
XMLNode *xml_obj;
const char *text;
@@ -1111,20 +1121,20 @@
as_value xml_getbytesloaded(const fn_call& fn)
{
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
return as_value(ptr->getBytesLoaded());
}
as_value xml_getbytestotal(const fn_call& fn)
{
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
return as_value(ptr->getBytesTotal());
}
as_value xml_haschildnodes(const fn_call& fn)
{
GNASH_REPORT_FUNCTION;
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
return as_value(ptr->hasChildNodes());
}
@@ -1139,6 +1149,8 @@
as_value xml_insertbefore(const fn_call& fn)
{
GNASH_REPORT_FUNCTION;
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
+ UNUSED(ptr);
// return as_value(ptr->getAllocated());
// ptr->insertBefore();
@@ -1152,12 +1164,12 @@
const char *text;
as_value method;
as_value val;
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
if (fn.nargs > 0) {
text = fn.arg(0).to_string();
if (ptr->parseXML(text)) {
- ptr->setupFrame(ptr, ptr->firstChild(), false);
+ ptr->setupFrame(ptr.get(), ptr->firstChild(), false);
}
}
@@ -1166,7 +1178,7 @@
log_msg("FIXME: Found onLoad!\n");
fn.env->set_variable("success", true); // what is this for ?
fn.arg(0) = true; // what is this for ?
- val = call_method(method, fn.env, fn.this_ptr, 0, 0);
+ val = call_method(method, fn.env, fn.this_ptr.get(), 0, 0);
} else {
log_msg("Couldn't find onLoad event handler, setting up callback\n");
// ptr->set_event_handler(event_id::XML_LOAD,
(as_c_function_ptr)&xml_onload);
@@ -1184,7 +1196,7 @@
as_value xml_removenode(const fn_call& fn)
{
GNASH_REPORT_FUNCTION;
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
// return as_value(ptr->getAllocated());
ptr->removeNode();
@@ -1193,7 +1205,7 @@
as_value xml_send(const fn_call& fn)
{
GNASH_REPORT_FUNCTION;
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
// return as_value(ptr->getAllocated());
ptr->send();
@@ -1202,7 +1214,7 @@
as_value xml_sendandload(const fn_call& fn)
{
GNASH_REPORT_FUNCTION;
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
// return as_value(ptr->getAllocated());
ptr->sendAndLoad();
@@ -1211,7 +1223,7 @@
as_value xml_tostring(const fn_call& fn)
{
// GNASH_REPORT_FUNCTION;
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
// TODO: There is also the "stringify" function to be used here.
// See above. Wot does FlashPlayer return for this call?
@@ -1226,7 +1238,7 @@
xml_nodename(const fn_call& fn)
{
// GNASH_REPORT_FUNCTION;
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
if ( fn.nargs == 0 ) {
const char* val = ptr->nodeName();
@@ -1247,7 +1259,7 @@
{
// GNASH_REPORT_FUNCTION;
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
//log_msg("xml_nodevalue called with %d args against 'this' = %p",
fn.nargs, ptr);
if ( fn.nargs == 0 ) {
@@ -1270,11 +1282,11 @@
xml_firstchild(const fn_call& fn)
{
GNASH_REPORT_FUNCTION;
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
if ( fn.nargs == 0 ) {
//return as_value(ptr->firstChild());
- return as_value(ptr);
+ return as_value(ptr.get());
} else {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("Tried to set read-only property XML.firstChild");
@@ -1288,11 +1300,11 @@
xml_childnodes(const fn_call& fn)
{
GNASH_REPORT_FUNCTION;
- XML *ptr = ensureType<XML>(fn.this_ptr);
+ boost::intrusive_ptr<XML> ptr = ensureType<XML>(fn.this_ptr);
if ( fn.nargs == 0 ) {
//return as_value(ptr->childNodes());
- return as_value(ptr);
+ return as_value(ptr.get());
} else {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("Tried to set read-only property XML.childNodes");
Index: server/asobj/xmlnode.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/asobj/xmlnode.cpp 20 Mar 2007 11:36:48 -0000 1.18
+++ server/asobj/xmlnode.cpp 20 Mar 2007 15:01:20 -0000 1.19
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: xmlnode.cpp,v 1.18 2007/03/20 11:36:48 ann Exp $ */
+/* $Id: xmlnode.cpp,v 1.19 2007/03/20 15:01:20 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -493,12 +493,20 @@
{
// GNASH_REPORT_FUNCTION;
if (fn.nargs > 0) {
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
// log_msg("%s: %p, %d args\n", __PRETTY_FUNCTION__, ptr, fn.nargs);
- XMLNode *xml_obj = dynamic_cast<XMLNode*>(fn.arg(0).to_object());
+ boost::intrusive_ptr<XMLNode> xml_obj =
boost::dynamic_pointer_cast<XMLNode>(fn.arg(0).to_object());
+ if ( ! xml_obj )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("First argument to XMLNode::appendChild() is not an
XMLNode");
+ );
+ return as_value();
+ }
+
if (xml_obj->nodeType() == XML_ELEMENT_NODE) {
- ptr->appendChild(xml_obj);
+ ptr->appendChild(xml_obj.get());
} else {
ptr->nodeValueSet(xml_obj->nodeValue());
}
@@ -514,7 +522,7 @@
// ptr->set_member("nextSibling",
xml_obj->obj.nextSibling(ptr->obj.length()));
}
// The last child in the list is always the one we just appended
- ptr->set_member("lastChild", xml_obj); // FIXME: don't do this, rely on
getter/setter
+ ptr->set_member("lastChild", xml_obj.get()); // FIXME: don't do this,
rely on getter/setter
} else {
log_msg("ERROR: no child XMLNode paramaters!\\n");
}
@@ -526,7 +534,7 @@
{
GNASH_REPORT_FUNCTION;
// log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
XMLNode *xmlnode_obj;
if (fn.nargs > 0) {
@@ -545,7 +553,7 @@
xmlnode_insertbefore(const fn_call& fn)
{
GNASH_REPORT_FUNCTION;
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
// return as_value(ptr->obj.getAllocated());
// ptr->obj.insertBefore();
@@ -557,7 +565,7 @@
xmlnode_removenode(const fn_call& fn)
{
GNASH_REPORT_FUNCTION;
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
// return as_value(ptr->obj.getAllocated());
ptr->removeNode();
@@ -570,7 +578,7 @@
{
// GNASH_REPORT_FUNCTION;
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
return as_value(ptr->toString());
}
@@ -579,7 +587,7 @@
xmlnode_haschildnodes(const fn_call& fn)
{
// GNASH_REPORT_FUNCTION;
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
return as_value(ptr->hasChildNodes());
}
@@ -589,7 +597,7 @@
{
//GNASH_REPORT_FUNCTION;
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
as_value rv;
rv.set_null();
@@ -612,7 +620,7 @@
xmlnode_nodename(const fn_call& fn)
{
// GNASH_REPORT_FUNCTION;
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
as_value rv;
rv.set_null();
@@ -633,7 +641,7 @@
{
// GNASH_REPORT_FUNCTION;
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
if ( fn.nargs == 0 ) {
return as_value(ptr->nodeType());
@@ -650,7 +658,7 @@
xmlnode_firstchild(const fn_call& fn)
{
// GNASH_REPORT_FUNCTION;
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
as_value rv;
rv.set_null();
@@ -676,7 +684,7 @@
xmlnode_lastchild(const fn_call& fn)
{
// GNASH_REPORT_FUNCTION;
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
as_value rv;
rv.set_null();
@@ -711,7 +719,7 @@
return rv;
}
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
XMLNode *node = ptr->nextSibling();
if (node) {
rv = node;
@@ -735,7 +743,7 @@
return rv;
}
- XMLNode *ptr = ensureType<XMLNode>(fn.this_ptr);
+ boost::intrusive_ptr<XMLNode> ptr = ensureType<XMLNode>(fn.this_ptr);
XMLNode *node = ptr->previousSibling();
if (node) {
rv = node;
Index: server/asobj/xmlsocket.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlsocket.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/asobj/xmlsocket.cpp 20 Mar 2007 11:36:48 -0000 1.11
+++ server/asobj/xmlsocket.cpp 20 Mar 2007 15:01:20 -0000 1.12
@@ -378,7 +378,7 @@
}
log_msg("%s: nargs=%d\n", __FUNCTION__, fn.nargs);
- xmlsocket_as_object* ptr = ensureType<xmlsocket_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<xmlsocket_as_object> ptr =
ensureType<xmlsocket_as_object>(fn.this_ptr);
const std::string host =
fn.env->bottom(fn.first_arg_bottom_index).to_string();
std::string port_str =
fn.env->bottom(fn.first_arg_bottom_index-1).to_string();
double port = atof(port_str.c_str());
@@ -398,7 +398,7 @@
if (fn.this_ptr->get_member("onConnect", &method)) {
// log_msg("FIXME: Found onConnect!\n");
first = false; // what is this for ?
- val = call_method0(method, fn.env, fn.this_ptr);
+ val = call_method0(method, fn.env, fn.this_ptr.get());
} else {
//ptr->set_event_handler(event_id::SOCK_CONNECT,
(as_c_function_ptr)&xmlsocket_event_connect);
}
@@ -408,7 +408,7 @@
Timer *timer = new Timer;
boost::intrusive_ptr<builtin_function> ondata_handler = new
builtin_function(
&xmlsocket_event_ondata, NULL);
- timer->setInterval(*ondata_handler, 50, ptr, fn.env);
+ timer->setInterval(*ondata_handler, 50,
boost::dynamic_pointer_cast<as_object>(ptr), fn.env);
VM::get().getRoot().add_interval_timer(*timer);
#endif
@@ -425,7 +425,7 @@
as_value method;
as_value val;
- xmlsocket_as_object* ptr = ensureType<xmlsocket_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<xmlsocket_as_object> ptr =
ensureType<xmlsocket_as_object>(fn.this_ptr);
const std::string object = fn.env->bottom(
fn.first_arg_bottom_index).to_string();
// log_msg("%s: host=%s, port=%g\n", __FUNCTION__, host, port);
return as_value(ptr->obj.send(object));
@@ -438,7 +438,7 @@
as_value method;
as_value val;
- xmlsocket_as_object* ptr = ensureType<xmlsocket_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<xmlsocket_as_object> ptr =
ensureType<xmlsocket_as_object>(fn.this_ptr);
// Since the return code from close() doesn't get used by Shockwave,
// we don't care either.
ptr->obj.close();
@@ -529,7 +529,7 @@
char *messages[200];
int i;
- xmlsocket_as_object* ptr = ensureType<xmlsocket_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<xmlsocket_as_object> ptr =
ensureType<xmlsocket_as_object>(fn.this_ptr);
if (ptr->obj.processingData()) {
log_msg("Still processing data!\n");
return as_value(false);
@@ -555,7 +555,7 @@
#endif
as_environment *env = new as_environment;
env->push(datain);
- val = call_method(method, env, fn.this_ptr, 1, 0);
+ val = call_method(method, env, fn.this_ptr.get(), 1, 0);
env->pop();
delete env;
#ifndef USE_DMALLOC
@@ -609,7 +609,7 @@
return as_value(true);
}
- xmlsocket_as_object* ptr = ensureType<xmlsocket_as_object>(fn.this_ptr);
+ boost::intrusive_ptr<xmlsocket_as_object> ptr =
ensureType<xmlsocket_as_object>(fn.this_ptr);
log_msg("%s: connected = %d\n", __FUNCTION__, ptr->obj.connected());
if ((ptr->obj.connected()) && (first)) {
@@ -618,9 +618,9 @@
//env->bottom(0) = true;
if (fn.this_ptr->get_member("onConnect", &method)) {
- val = call_method0(method, fn.env, fn.this_ptr);
+ val = call_method0(method, fn.env, fn.this_ptr.get());
} else {
- log_msg("FIXME: Couldn't find onConnect!\n");
+ log_msg("FIXME: Couldn't find onConnect!");
}
}
Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- server/vm/ASHandlers.cpp 20 Mar 2007 09:55:08 -0000 1.67
+++ server/vm/ASHandlers.cpp 20 Mar 2007 15:01:20 -0000 1.68
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: ASHandlers.cpp,v 1.67 2007/03/20 09:55:08 bjacques Exp $ */
+/* $Id: ASHandlers.cpp,v 1.68 2007/03/20 15:01:20 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -118,7 +118,7 @@
// won't set __constructor__ to some other value...
if ( VM::get().getSWFVersion() > 5 )
{
- as_object* newobj = new_obj.to_object();
+ boost::intrusive_ptr<as_object> newobj =
new_obj.to_object();
assert(newobj); // we assume builtin functions do return
objects !!
newobj->init_member("__constructor__", constructor);
}
@@ -1026,7 +1026,8 @@
IF_VERBOSE_ACTION
(
- if (top_value.to_object() == NULL) {
+ boost::intrusive_ptr<as_object> obj=top_value.to_object();
+ if (obj == NULL) {
log_action("-- get var: %s=%s",
var_string.c_str(),
top_value.to_debug_string().c_str());
@@ -1034,7 +1035,7 @@
log_action("-- get var: %s=%s at %p",
var_string.c_str(),
top_value.to_tu_string().c_str(),
- (void*)top_value.to_object());
+ (void*)obj.get());
}
);
#ifdef USE_DEBUGGER
@@ -1335,7 +1336,7 @@
as_function* super = env.top(0).to_as_function();
// Get the "instance"
- as_object* instance = env.top(1).to_object();
+ boost::intrusive_ptr<as_object> instance = env.top(1).to_object();
// Invalid args!
if (!super || ! instance)
@@ -2252,7 +2253,14 @@
env.get_top_index());
#ifdef USE_DEBUGGER
- debugger.addSymbol(new_obj.to_object(), classname);
+ // WARNING: new_obj.to_object() can return a newly allocated
+ // thing into the intrusive_ptr, so the debugger
+ // will be left with a deleted object !!
+ // Rob: we don't want to use void pointers here..
+ boost::intrusive_ptr<as_object> o = new_obj.to_object();
+ o->add_ref(); // this will leak, but at least debugger won't end up
+ // with a dandling reference...
+ debugger.addSymbol(o.get(), classname);
#endif
env.drop(nargs);
@@ -2299,7 +2307,7 @@
as_value result;
result = array_new(fn_call(NULL, &env, 0, env.get_top_index()));
- as_object* ao = result.to_object();
+ boost::intrusive_ptr<as_object> ao = result.to_object();
assert(ao);
// Fill the elements with the initial values from the stack.
@@ -2403,7 +2411,7 @@
as_value& var_name = env.top(0);
string var_string = var_name.to_std_string();
as_value variable = thread.getVariable(var_string);
- const as_object* obj = variable.to_object();
+ const boost::intrusive_ptr<as_object> obj = variable.to_object();
// The end of the enumeration, don't set top(0) *before*
// fetching the as_object* obj above or it will get lost
@@ -2540,7 +2548,7 @@
as_value member_name = env.top(0);
as_value target = env.top(1);
- as_object* obj = target.to_object();
+ boost::intrusive_ptr<as_object> obj = target.to_object();
if (!obj) {
// IF_VERBOSE_DEBUG(log_msg("getMember called against "
// "a value that does not cast "
@@ -2552,7 +2560,7 @@
IF_VERBOSE_ACTION (
log_action(" ActionGetMember: target: %s (object %p)",
- target.to_debug_string().c_str(), (void*)obj);
+ target.to_debug_string().c_str(), (void*)obj.get());
);
// Special case: String has a member "length"
@@ -2585,7 +2593,7 @@
thread.ensureStack(3); // value, member, object
- as_object* obj = env.top(2).to_object();
+ boost::intrusive_ptr<as_object> obj = env.top(2).to_object();
string member_name = env.top(1).to_std_string();
const as_value& member_value = env.top(0);
@@ -2675,7 +2683,7 @@
string method_string = method_name.to_std_string();
as_value method_val;
- as_object* obj = obj_value.to_object();
+ boost::intrusive_ptr<as_object> obj = obj_value.to_object();
if ( method_name.is_undefined() || method_string.empty() )
{
@@ -2769,7 +2777,7 @@
}
#endif
- as_value result = call_method(method_val, &env, obj,
+ as_value result = call_method(method_val, &env, obj.get(),
nargs, env.get_top_index()-3);
env.drop(nargs + 2);
@@ -2807,7 +2815,7 @@
nargs = available_args;
}
- as_object* obj = obj_val.to_object();
+ boost::intrusive_ptr<as_object> obj = obj_val.to_object();
if ( ! obj )
{
// SWF integrity check
@@ -2876,7 +2884,7 @@
as_function* super = env.top(0).to_as_function();
// Get the "instance" (but avoid implicit conversion of primitive values!)
- as_object* instance = env.top(1).is_object() ? env.top(1).to_object() :
NULL;
+ boost::intrusive_ptr<as_object> instance = env.top(1).is_object() ?
env.top(1).to_object() : NULL;
// Invalid args!
if (!super || ! instance) {
@@ -2912,7 +2920,7 @@
// as we copied that as_value.
env.top(0).set_null();
- as_object* obj = obj_val.to_object();
+ boost::intrusive_ptr<as_object> obj = obj_val.to_object();
if ( ! obj )
{
IF_VERBOSE_ASCODING_ERRORS(
@@ -3170,7 +3178,14 @@
env.push_val(function_value);
}
#ifdef USE_DEBUGGER
- debugger.addSymbol(function_value.to_object(), name);
+ // WARNING: function_value.to_object() can return a newly allocated
+ // thing into the intrusive_ptr, so the debugger
+ // will be left with a deleted object !!
+ // Rob: we don't want to use void pointers here..
+ boost::intrusive_ptr<as_object> o = function_value.to_object();
+ o->add_ref(); // this will leak, but at least debugger won't end up
+ // with a dandling reference...
+ debugger.addSymbol(o.get(), name);
#endif
}
@@ -3194,7 +3209,7 @@
assert( code[pc] == SWF::ACTION_WITH );
thread.ensureStack(1); // the object
- as_object* with_obj = env.pop().to_object();
+ boost::intrusive_ptr<as_object> with_obj = env.pop().to_object();
const vector<with_stack_entry>& with_stack = thread.getWithStack();
IF_VERBOSE_ACTION (
@@ -3311,7 +3326,14 @@
//env.set_member(name, function_value);
thread.setVariable(name, function_value);
#ifdef USE_DEBUGGER
- debugger.addSymbol(function_value.to_object(), name);
+ // WARNING: new_obj.to_object() can return a newly allocated
+ // thing into the intrusive_ptr, so the debugger
+ // will be left with a deleted object !!
+ // Rob: we don't want to use void pointers here..
+ boost::intrusive_ptr<as_object> o = function_value.to_object();
+ o->add_ref(); // this will leak, but at least debugger won't
end up
+ // with a dandling reference...
+ debugger.addSymbol(o.get(), name);
#endif
}
Index: server/vm/fn_call.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/fn_call.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/vm/fn_call.h 19 Mar 2007 17:11:14 -0000 1.3
+++ server/vm/fn_call.h 20 Mar 2007 15:01:20 -0000 1.4
@@ -43,7 +43,7 @@
class fn_call
{
public:
- as_object* this_ptr;
+ boost::intrusive_ptr<as_object> this_ptr;
as_environment* env;
unsigned int nargs;
int first_arg_bottom_index;
@@ -59,6 +59,17 @@
{
}
+ fn_call(boost::intrusive_ptr<as_object> this_in,
+ as_environment* env_in,
+ int nargs_in, int first_in)
+ :
+ this_ptr(this_in),
+ env(env_in),
+ nargs(nargs_in),
+ first_arg_bottom_index(first_in)
+ {
+ }
+
/// Access a particular argument.
as_value& arg(unsigned int n) const
{
Index: server/vm/with_stack_entry.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/with_stack_entry.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/vm/with_stack_entry.h 20 Feb 2007 20:05:41 -0000 1.3
+++ server/vm/with_stack_entry.h 20 Mar 2007 15:01:20 -0000 1.4
@@ -53,6 +53,13 @@
{
}
+ with_stack_entry(boost::intrusive_ptr<as_object> obj, size_t end)
+ :
+ _object(obj),
+ _block_end_pc(end)
+ {
+ }
+
size_t end_pc()
{
return _block_end_pc;
Index: testsuite/server/GetterSetterTest.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/server/GetterSetterTest.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- testsuite/server/GetterSetterTest.cpp 19 Mar 2007 17:11:15 -0000
1.8
+++ testsuite/server/GetterSetterTest.cpp 20 Mar 2007 15:01:20 -0000
1.9
@@ -33,7 +33,6 @@
#include <string>
#include "check.h"
-#include "check.h"
using namespace std;
using namespace gnash;
@@ -41,7 +40,7 @@
/// return the object's text value
static as_value getter(const fn_call& fn)
{
- as_object* o = fn.this_ptr;
+ boost::intrusive_ptr<as_object> o = fn.this_ptr;
assert(fn.nargs == 0);
const char* txt = o->get_text_value();
return as_value(txt);
@@ -50,10 +49,11 @@
/// set a new member to the object
static as_value setter(const fn_call& fn)
{
- as_object* o = fn.this_ptr;
+ boost::intrusive_ptr<as_object> o = fn.this_ptr;
assert(fn.nargs == 1);
as_value& val = fn.arg(0);
o->set_member(val.to_std_string(), val);
+ return as_value();
}
struct test_object: public as_object {
@@ -82,55 +82,55 @@
dbglogfile.setVerbosity();
boost::intrusive_ptr<movie_definition> md6 ( new
DummyMovieDefinition(6) );
- VM& vm = VM::init(*md6);
+ VM::init(*md6);
- test_object obj("initial text");
- test_object obj2("other obj");
+ boost::intrusive_ptr<test_object> obj(new test_object("initial text"));
+ boost::intrusive_ptr<test_object> obj2(new test_object("other obj"));
- builtin_function* get = new builtin_function(&getter);
- builtin_function* set = new builtin_function(&setter);
+ builtin_function* get = new builtin_function(getter);
+ builtin_function* set = new builtin_function(setter);
GetterSetter getset(*get, *set);
as_value val;
- val = getset.getValue(&obj);
- check_equals(obj.getText(), string("initial text"));
+ val = getset.getValue(obj.get());
+ check_equals(obj->getText(), string("initial text"));
check_equals(val, as_value("initial text"));
val.set_string("second try");
- getset.setValue(&obj, val);
- check_equals(obj.getText(), string("second try"));
+ getset.setValue(obj.get(), val);
+ check_equals(obj->getText(), string("second try"));
val.set_string("");
- val = getset.getValue(&obj);
+ val = getset.getValue(obj.get());
check_equals(val, as_value("second try"));
// Test copy ctor
GetterSetter getset2(getset);
- val = getset2.getValue(&obj2);
- check_equals(obj2.getText(), string("other obj"));
+ val = getset2.getValue(obj2.get());
+ check_equals(obj2->getText(), string("other obj"));
check_equals(val, as_value("other obj"));
val.set_string("second try for other");
- getset2.setValue(&obj2, val);
- check_equals(obj2.getText(), string("second try for other"));
+ getset2.setValue(obj2.get(), val);
+ check_equals(obj2->getText(), string("second try for other"));
val.set_string("");
- val = getset2.getValue(&obj2);
+ val = getset2.getValue(obj2.get());
check_equals(val, as_value("second try for other"));
- val = getset2.getValue(&obj);
+ val = getset2.getValue(obj.get());
check_equals(val, as_value("second try"));
// Test assignment
GetterSetter tmp(getset);
- val = tmp.getValue(&obj);
+ val = tmp.getValue(obj.get());
check_equals(val, as_value("second try"));
tmp = getset2;
- val = tmp.getValue(&obj2);
+ val = tmp.getValue(obj2.get());
check_equals(val, as_value("second try for other"));
}
- [Gnash-commit] gnash ChangeLog server/array.cpp server/as_envi...,
Sandro Santilli <=