Gnash  0.8.11dev
Array_as.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASH_ARRAY_H
20 #define GNASH_ARRAY_H
21 
22 #include "as_object.h"
23 
24 // Forward declarations
25 namespace gnash {
26  class as_value;
27 }
28 
29 namespace gnash {
30 
32 //
35 //
39 size_t arrayLength(as_object& array);
40 
42 //
45 //
48 ObjectURI arrayKey(VM& vm, size_t i);
49 
51 //
55 {
56 public:
57  IsStrictArray(VM& st) : _strict(true), _st(st) {}
58  virtual bool accept(const ObjectURI& uri, const as_value& val);
59 
60  bool strict() const {
61  return _strict;
62  }
63 private:
64  bool _strict;
65  VM& _st;
66 };
67 
68 
70 //
74 void checkArrayLength(as_object& array, const ObjectURI& uri,
75  const as_value& val);
76 
77 template<typename T>
78 void foreachArray(as_object& array, T& pred)
79 {
80  size_t size = arrayLength(array);
81  if (!size) return;
82 
83  VM& vm = getVM(array);
84 
85  for (size_t i = 0; i < static_cast<size_t>(size); ++i) {
86  pred(getOwnProperty(array, arrayKey(vm, i)));
87  }
88 }
89 
91 void array_class_init(as_object& global, const ObjectURI& uri);
92 
93 void registerArrayNative(as_object& global);
94 
95 }
96 
97 #endif
gnash::toNumber
double toNumber(const as_value &v, const VM &vm)
Convert an as_value to a double.
Definition: VM.cpp:451
_zeroCmp
bool(* _zeroCmp)(const int)
Definition: Array_as.cpp:681
gnash::arrayKey
ObjectURI arrayKey(VM &vm, size_t i)
Convert an integral value into an ObjectURI.
Definition: Array_as.cpp:995
_comp
as_function & _comp
Definition: Array_as.cpp:679
name
std::string name
Definition: LocalConnection_as.cpp:149
gnash::isNaN
bool isNaN(const T &num)
Definition: GnashNumeric.h:62
gnash::image::begin
pixel_iterator< T > begin(GnashImage &im)
Definition: ImageIterators.h:191
gnash::toInt
std::int32_t toInt(const as_value &v, const VM &vm)
AS2-compatible conversion to 32bit integer.
Definition: VM.cpp:463
gnash::key::d
@ d
Definition: GnashKey.h:150
gnash::PropertyVisitor
An abstract property visitor.
Definition: PropertyList.h:49
_object
as_object * _object
Definition: Array_as.cpp:680
gnash::as_object
The base class for all ActionScript objects.
Definition: as_object.h:162
as_object.h
gnash::as_object::setRelay
void setRelay(Relay *p)
Set the as_object's Relay object.
Definition: as_object.h:604
gnash::getOwnProperty
as_value getOwnProperty(as_object &o, const ObjectURI &uri)
Get an own member of an object.
Definition: as_object.h:777
gnash::toObject
as_object * toObject(const as_value &v, VM &vm)
Convert an as_value to an object.
Definition: VM.cpp:457
gnash::key::T
@ T
Definition: GnashKey.h:132
gnash::IsStrictArray::IsStrictArray
IsStrictArray(VM &st)
Definition: Array_as.h:57
gnash::key::i
@ i
Definition: GnashKey.h:155
gnash::NSV::PROP_LENGTH
@ PROP_LENGTH
Definition: namedStrings.h:83
_
#define _(String)
Definition: log.h:44
gnash::as_object::init_member
void init_member(const std::string &name, const as_value &val, int flags=DefaultFlags)
Initialize a member value by string.
Definition: as_object.cpp:669
gnash::VM
The AVM1 virtual machine.
Definition: VM.h:72
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
_env
const as_environment & _env
Definition: Array_as.cpp:682
gnash::PropFlags::dontEnum
@ dontEnum
Protect from enumeration.
Definition: PropFlags.h:36
gnash::arrayLength
size_t arrayLength(as_object &array)
Get the length of an object as though it were an array.
Definition: Array_as.cpp:942
gnash::key::s
@ s
Definition: GnashKey.h:165
as_value.h
NativeFunction.h
start
@ start
Definition: klash_part.cpp:330
Global_as.h
gnash::getGlobal
Global_as & getGlobal(const as_environment &env)
Definition: as_environment.cpp:651
gnash::NSV::PROP_CONSTRUCTOR
@ PROP_CONSTRUCTOR
Definition: namedStrings.h:68
gnash::getVM
VM & getVM(const as_environment &env)
Definition: as_environment.h:222
as_function.h
_prps
Props & _prps
Definition: Array_as.cpp:748
gnash::createObject
as_object * createObject(const Global_as &gl)
Definition: Global_as.cpp:303
gnash::NSV::PROP_PUSH
@ PROP_PUSH
Definition: namedStrings.h:88
gnash::callMethod
as_value callMethod(fn_call::Args &args, as_object *obj, const ObjectURI &uri)
Call a member function of this object in an AS-compatible way.
Definition: Global_as.h:219
gnash::fn_call::Args
FunctionArgs< as_value > Args
Definition: fn_call.h:121
gnash::key::a
@ a
Definition: GnashKey.h:147
_cmps
Comps & _cmps
Definition: Array_as.cpp:745
gnash::invoke
DSOEXPORT as_value invoke(const as_value &method, const as_environment &env, as_object *this_ptr, fn_call::Args &args, as_object *super=nullptr, const movie_definition *callerDef=nullptr)
Call an as_value on an as_object.
Definition: Global_as.h:166
IF_VERBOSE_ASCODING_ERRORS
#define IF_VERBOSE_ASCODING_ERRORS(x)
Definition: log.h:397
length
@ length
Definition: klash_part.cpp:329
gnash::array_class_init
void array_class_init(as_object &where, const ObjectURI &uri)
Initialize the global.Array object.
Definition: Array_as.cpp:973
gnash::IsStrictArray::strict
bool strict() const
Definition: Array_as.h:60
gnash::VM::registerNative
void registerNative(as_c_function_ptr fun, unsigned int x, unsigned int y)
Definition: VM.cpp:268
gnash::VM::getNative
NativeFunction * getNative(unsigned int x, unsigned int y) const
Return a native function or null.
Definition: VM.cpp:276
gnash::getClassConstructor
as_function * getClassConstructor(const fn_call &fn, const std::string &s)
Convenience function for finding a class constructor.
Definition: Global_as.h:249
GnashNumeric.h
gnash::as_value
ActionScript value type.
Definition: as_value.h:95
gnash::Global_as::createArray
as_object * createArray()
Construct an Array.
Definition: Global_as.cpp:207
gnash::registerArrayNative
void registerArrayNative(as_object &global)
Definition: Array_as.cpp:954
VM.h
vec_index
int vec_index
Definition: Array_as.cpp:120
gnash::log_aserror
void log_aserror(StringType msg, Args... args)
Definition: log.h:331
log.h
fn_call.h
gnash::ObjectURI::CaseEquals
Definition: ObjectURI.h:147
gnash::checkArrayLength
void checkArrayLength(as_object &array, const ObjectURI &uri, const as_value &val)
Genuine arrays handle the length property in a special way.
Definition: Array_as.cpp:920
gnash::key::f
@ f
Definition: GnashKey.h:152
gnash::image::end
pixel_iterator< T > end(GnashImage &im)
Definition: ImageIterators.h:198
namedStrings.h
gnash::Global_as
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:50
gnash::getSWFVersion
int getSWFVersion(const as_environment &env)
Definition: as_environment.cpp:657
test.uri
uri
Definition: test.py:12
gnash::key::c
@ c
Definition: GnashKey.h:149
gnash::getStringTable
string_table & getStringTable(const as_environment &env)
Definition: as_environment.cpp:639
gnash::getURI
ObjectURI getURI(const VM &vm, const std::string &str, bool lowerCaseHint=false)
Definition: VM.h:290
gnash::IsStrictArray::accept
virtual bool accept(const ObjectURI &uri, const as_value &val)
This function should return false if no further visits are needed.
Definition: Array_as.cpp:911
Array_as.h
gnash::caseless
bool caseless(const as_object &o)
Return whether property matching is caseless.
Definition: as_object.h:924
gnash::renderer::opengl::middle
point middle(const point &a, const point &b)
Definition: Renderer_ogl.cpp:350
gnash::IsStrictArray
A visitor to check whether an array is strict or not.
Definition: Array_as.h:55
gnash::key::o
@ o
Definition: GnashKey.h:161
gnash::foreachArray
void foreachArray(as_object &array, T &pred)
Definition: Array_as.h:78
gnash::log_unimpl
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
gnash::NSV::PROP_PROTOTYPE
@ PROP_PROTOTYPE
Definition: namedStrings.h:87
gnash::ObjectURI
A URI for describing as_objects.
Definition: ObjectURI.h:45
GnashException.h
gnash::key::b
@ b
Definition: GnashKey.h:148
test.v
v
Definition: test.py:11
gnash::key::e
@ e
Definition: GnashKey.h:151