00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GNASH_ABC_BLOCK_H
00022 #define GNASH_ABC_BLOCK_H
00023
00024 #include <vector>
00025 #include <string>
00026 #include <boost/scoped_array.hpp>
00027
00028 #include "gnash.h"
00029 #include "stream.h"
00030 #include "string_table.h"
00031 #include "asClass.h"
00032 #include "asName.h"
00033
00034 namespace gnash {
00035
00036 typedef std::vector<asNamespace *> abcNamespaceSet;
00037
00038 class abc_block;
00039 class ClassHierarchy;
00040
00041 namespace abc_parsing {
00042
00043 class abc_Trait;
00044
00045 class abc_Trait
00046 {
00047 public:
00048 typedef enum
00049 {
00050 KIND_SLOT = 0,
00051 KIND_CONST = 6,
00052 KIND_METHOD = 1,
00053 KIND_GETTER = 2,
00054 KIND_SETTER = 3,
00055 KIND_CLASS = 4,
00056 KIND_FUNCTION = 5
00057 } kinds;
00058
00059 bool mHasValue;
00060 kinds mKind;
00061 boost::uint32_t mSlotId;
00062 boost::uint32_t mTypeIndex;
00063 boost::uint32_t mClassInfoIndex;
00064 as_value mValue;
00065 string_table::key mName;
00066 asNamespace *mNamespace;
00067 asMethod *mMethod;
00068 bool mValueSet;
00069
00070 asClass *mCTarget;
00071 asMethod *mMTarget;
00072 bool mStatic;
00073
00074 abc_Trait() : mHasValue(false), mKind(KIND_SLOT), mSlotId(0),
00075 mTypeIndex(0), mClassInfoIndex(0), mValue(), mName(0),
00076 mNamespace(NULL), mMethod(NULL), mValueSet(false)
00077 {}
00078
00079 bool read(stream* in, abc_block *pBlock);
00080 bool finalize(abc_block *pBlock, asClass *pClass, bool do_static);
00081 bool finalize_mbody(abc_block *pBlock, asMethod *pMethod);
00082
00083 void set_target(asClass *pClass, bool do_static)
00084 { mCTarget = pClass; mStatic = do_static; }
00085 void set_target(asMethod *pMethod)
00086 { mCTarget = NULL; mMTarget = pMethod; }
00087
00088 bool finalize(abc_block *pBlock)
00089 {
00090 if (mCTarget)
00091 return finalize(pBlock, mCTarget, mStatic);
00092 return finalize_mbody(pBlock, mMTarget);
00093 }
00094 };
00095
00096 }
00097
00098 typedef std::vector<asNamespace*> NamespaceSet;
00099
00100 class abc_block
00101 {
00102 public:
00103 typedef enum
00104 {
00105 PRIVATE_NS = 0x05,
00106 PROTECTED_NS = 0x18,
00107 METHOD_ARGS = 0x01,
00108 METHOD_ACTIVATION = 0x02,
00109 METHOD_MORE = 0x04,
00110 METHOD_OPTIONAL_ARGS = 0x08,
00111 METHOD_IGNORE = 0x10,
00112 METHOD_NATIVE = 0x20,
00113 METHOD_DEFAULT_NS = 0x40,
00114 METHOD_ARG_NAMES = 0x80,
00115 INSTANCE_SEALED = 0x01,
00116 INSTANCE_FINAL = 0x02,
00117 INSTANCE_INTERFACE = 0x04,
00118 INSTANCE_DYNAMIC = 0x00,
00119 INSTANCE_PROTECTED_NS = 0x08,
00120 POOL_STRING = 0x01,
00121 POOL_INTEGER = 0x03,
00122 POOL_UINTEGER = 0x04,
00123 POOL_DOUBLE = 0x06,
00124 POOL_NAMESPACE = 0x08,
00125 POOL_FALSE = 0x0A,
00126 POOL_TRUE = 0x0B,
00127 POOL_NULL = 0x0C
00128 } constants;
00129
00130 std::vector<boost::int32_t> mIntegerPool;
00131 std::vector<boost::uint32_t> mUIntegerPool;
00132 std::vector<double> mDoublePool;
00133 std::vector<std::string> mStringPool;
00134 std::vector<string_table::key> mStringPoolTableIds;
00135 std::vector<asNamespace*> mNamespacePool;
00136 std::vector<NamespaceSet> mNamespaceSetPool;
00137 std::vector<asMethod*> mMethods;
00138 std::vector<asName> mMultinamePool;
00139 std::vector<asClass*> mClasses;
00140 std::vector<asClass*> mScripts;
00141 std::vector<abc_parsing::abc_Trait*> mTraits;
00142
00143 string_table* mStringTable;
00144 stream *mS;
00145
00146 asClass *mTheObject;
00147 ClassHierarchy *mCH;
00148
00149 boost::uint32_t mVersion;
00150
00151 asClass *locateClass(asName &m);
00152
00153 abc_parsing::abc_Trait &newTrait()
00154 {
00155 abc_parsing::abc_Trait *p = new abc_parsing::abc_Trait;
00156 mTraits.push_back(p);
00157 return *p;
00158 }
00159
00160 public:
00161 bool read_version();
00162 bool read_integer_constants();
00163 bool read_unsigned_integer_constants();
00164 bool read_double_constants();
00165 bool read_string_constants();
00166 bool read_namespaces();
00167 bool read_namespace_sets();
00168 bool read_multinames();
00169 bool read_method_infos();
00170 bool skip_metadata();
00171 bool read_instances();
00172 bool read_classes();
00173 bool read_scripts();
00174 bool read_method_bodies();
00175
00176 bool read(stream* in);
00177
00178 bool pool_value(boost::uint32_t index, boost::uint8_t type, as_value &v);
00179
00180 abc_block();
00181 };
00182
00183 }
00184
00185 #endif
00186