Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GNASH_EXECUTABLECODE_H
00020 #define GNASH_EXECUTABLECODE_H
00021
00022 #include <vector>
00023 #include <boost/noncopyable.hpp>
00024
00025 #include "smart_ptr.h"
00026 #include "as_function.h"
00027 #include "ActionExec.h"
00028 #include "Global_as.h"
00029 #include "fn_call.h"
00030
00031 namespace gnash {
00032
00034 class ExecutableCode : boost::noncopyable
00035 {
00036
00037 public:
00038
00039 ExecutableCode(DisplayObject* t) : _target(t) {}
00040
00041 virtual void execute()=0;
00042
00043 virtual ~ExecutableCode() {}
00044
00045 virtual void setReachable() const {}
00046
00047 #ifdef GNASH_USE_GC
00048
00049 void markReachableResources() const {
00050 setReachable();
00051 if (_target) _target->setReachable();
00052 }
00053 #endif
00054
00055 DisplayObject* target() const {
00056 return _target;
00057 }
00058
00059 private:
00060
00061 DisplayObject* _target;
00062 };
00063
00065 class GlobalCode : public ExecutableCode {
00066
00067 public:
00068
00069 GlobalCode(const action_buffer& nBuffer, DisplayObject* nTarget)
00070 :
00071 ExecutableCode(nTarget),
00072 buffer(nBuffer)
00073 {}
00074
00075 virtual void execute()
00076 {
00077 if (!target()->unloaded()) {
00078 ActionExec exec(buffer, target()->get_environment());
00079 exec();
00080 }
00081 }
00082
00083 private:
00084
00085 const action_buffer& buffer;
00086
00087 };
00088
00090 class EventCode : public ExecutableCode {
00091
00092 public:
00093
00094 typedef std::vector<const action_buffer*> BufferList;
00095
00096 EventCode(DisplayObject* nTarget)
00097 :
00098 ExecutableCode(nTarget)
00099 {}
00100
00101 EventCode(DisplayObject* nTarget, const BufferList& buffers)
00102 :
00103 ExecutableCode(nTarget),
00104 _buffers(buffers)
00105 {}
00106
00108
00114 void addAction(const action_buffer& buffer)
00115 {
00116
00117
00118 if (!target()->isDestroyed()) {
00119 _buffers.push_back(&buffer);
00120 }
00121 }
00122
00123 virtual void execute()
00124 {
00125 for (BufferList::iterator it=_buffers.begin(), itEnd=_buffers.end();
00126 it != itEnd; ++it)
00127 {
00128
00129
00130 if (target()->isDestroyed()) break;
00131
00132 ActionExec exec(*(*it), target()->get_environment(), false);
00133 exec();
00134 }
00135 }
00136
00137 private:
00138
00139 BufferList _buffers;
00140
00141 };
00142
00144 class QueuedEvent: public ExecutableCode {
00145
00146 public:
00147
00148 QueuedEvent(DisplayObject* nTarget, const event_id& id)
00149 :
00150 ExecutableCode(nTarget),
00151 _eventId(id)
00152 {}
00153
00154 virtual void execute()
00155 {
00156
00157 if (!target()->isDestroyed() )
00158 {
00159 target()->notifyEvent(_eventId);
00160 }
00161 }
00162
00163 private:
00164
00165 const event_id _eventId;
00166
00167 };
00168
00170
00180 class DelayedFunctionCall : public ExecutableCode
00181 {
00182
00183 public:
00184
00185 DelayedFunctionCall(DisplayObject* target,
00186 as_object* obj, string_table::key name,
00187 const as_value& arg1, const as_value& arg2)
00188 :
00189 ExecutableCode(target),
00190 _obj(obj),
00191 _name(name),
00192 _arg1(arg1),
00193 _arg2(arg2)
00194 {}
00195
00196 virtual void execute()
00197 {
00198 callMethod(_obj, _name, _arg1, _arg2);
00199 }
00200
00201 #ifdef GNASH_USE_GC
00202
00203
00207 virtual void setReachable() const
00208 {
00209 _obj->setReachable();
00210 _arg1.setReachable();
00211 _arg2.setReachable();
00212 }
00213 #endif // GNASH_USE_GC
00214
00215 private:
00216
00217 as_object* _obj;
00218 string_table::key _name;
00219 as_value _arg1, _arg2;
00220
00221 };
00222
00223
00224
00225 }
00226
00227 #endif // GNASH_EXECUTABLECODE_H