Projects
Essentials
lightspark
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 104
View file
lightspark.spec
Changed
@@ -20,7 +20,7 @@ %bcond_without librtmp Name: lightspark -Version: 0.7.2.99+git20160311.1829 +Version: 0.7.2.99+git20160410.1631 Release: 0 Summary: Modern, free, open-source flash player implementation License: LGPL-3.0+
View file
0001-s-PIX_FMT_YUV420P-AV_PIX_FMT_YUV420P-compatibility.patch
Changed
@@ -1,4 +1,4 @@ -From 0071cb20db3166dbef561ef4007158b13c5c68af Mon Sep 17 00:00:00 2001 +From 4b64069813a87df922235582eb71ea82ca6afd9e Mon Sep 17 00:00:00 2001 From: Johannes Obermayr <johannesobermayr@gmx.de> Date: Mon, 21 Mar 2016 22:34:36 +0100 Subject: [PATCH 1/2] s/PIX_FMT_YUV420P/AV_PIX_FMT_YUV420P + compatibility. @@ -41,5 +41,5 @@ if(status==INIT && fillDataAndCheckValidity()) status=VALID; -- -2.7.3 +2.8.1
View file
0002-Fix-build-with-newer-LLVM.patch
Changed
@@ -1,6 +1,6 @@ -From c7e27875f28fc5a716c1fa83cff89860569554be Mon Sep 17 00:00:00 2001 +From 43638ba6183f984c200e207565bd10a5ab15bd53 Mon Sep 17 00:00:00 2001 From: Johannes Obermayr <johannesobermayr@gmx.de> -Date: Tue, 22 Mar 2016 21:37:43 +0100 +Date: Mon, 11 Apr 2016 13:58:43 +0200 Subject: [PATCH 2/2] Fix build with newer LLVM. --- @@ -9,7 +9,7 @@ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt -index 0b9790d..06d9a23 100644 +index 0b9790d..93c0829 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,6 +250,17 @@ ENDIF(NOT (${LLVM_STRING_VERSION} VERSION_LESS 3.6)) @@ -18,9 +18,9 @@ ENDIF(NOT ${LLVM_STRING_VERSION} VERSION_LESS 3.7) + +INCLUDE(CheckCXXSourceCompiles) -+SET(CMAKE_REQUIRED_FLAGS ${LLVM_COMPILE_FLAGS}) ++SET(CMAKE_REQUIRED_FLAGS "-std=c++11 -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS") +SET(CMAKE_REQUIRED_INCLUDES ${LLVM_INCLUDE_DIR}) -+CHECK_CXX_SOURCE_COMPILES("#include <llvm/ExecutionEngine/ExecutionEngine.h>\nbool main() { return DL.isLittleEndian(); }" EXECUTIONENGINE_OWNING_DATALAYOUT) ++CHECK_CXX_SOURCE_COMPILES("#include <llvm/ExecutionEngine/ExecutionEngine.h>\nint main() { llvm::ExecutionEngine* ex; return ex->getDataLayout().isLittleEndian(); }" EXECUTIONENGINE_OWNING_DATALAYOUT) +IF(EXECUTIONENGINE_OWNING_DATALAYOUT) + ADD_DEFINITIONS(-DEXECUTIONENGINE_OWNING_DATALAYOUT) +ENDIF(EXECUTIONENGINE_OWNING_DATALAYOUT) @@ -31,7 +31,7 @@ INCLUDE(FindFreetype REQUIRED) IF(NOT(ENABLE_GLES2)) diff --git a/src/scripting/abc_codesynt.cpp b/src/scripting/abc_codesynt.cpp -index d07ccd6..0cb6581 100644 +index 42a0f9c..d0c8c13 100644 --- a/src/scripting/abc_codesynt.cpp +++ b/src/scripting/abc_codesynt.cpp @@ -294,11 +294,15 @@ void ABCVm::registerFunctions() @@ -48,19 +48,19 @@ #endif +#endif //Pointer to 8 bit type, needed for pointer arithmetic - voidptr_type=llvm::IntegerType::get(getVm()->llvm_context(),8)->getPointerTo(); + voidptr_type=llvm::IntegerType::get(llvm_context(),8)->getPointerTo(); number_type=llvm::Type::getDoubleTy(llvm_context()); -@@ -1883,9 +1887,8 @@ SyntheticFunction::synt_function method_info::synt_method() +@@ -1883,9 +1887,8 @@ SyntheticFunction::synt_function method_info::synt_method(SystemState* sys) constant = llvm::ConstantInt::get(ptr_type, (uintptr_t)this); llvm::Value* th = llvm::ConstantExpr::getIntToPtr(constant, voidptr_type); - llvm::Function::ArgumentListType::iterator it=llvmf->getArgumentList().begin(); //The first and only argument to this function is the call_context* - llvm::Value* context=it; -+ llvm::Value* context=llvmf->getArgumentList().begin(); ++ llvm::Value* context = (llvm::Value*)llvmf->getArgumentList().begin(); //let's give access to local data storage value=Builder.CreateStructGEP( -- -2.7.3 +2.8.1
View file
lightspark.tar.xz/src/asobject.cpp
Changed
@@ -71,7 +71,7 @@ if (this->proxyMultiName) this->proxyMultiName->ns.clear(); else - this->proxyMultiName = new (getVm()->vmDataMemory) multiname(getVm()->vmDataMemory); + this->proxyMultiName = new (getVm(getSystemState())->vmDataMemory) multiname(getVm(getSystemState())->vmDataMemory); this->proxyMultiName->isAttribute = name.isAttribute; this->proxyMultiName->ns.reserve(name.ns.size()); for(unsigned int i=0;i<name.ns.size();i++) @@ -180,7 +180,7 @@ { assert_and_throw(implEnable); - return _MR(abstract_s(getNameAt(index-1))); + return _MR(abstract_s(getSystemState(),getNameAt(index-1))); } _R<ASObject> ASObject::nextValue(uint32_t index) @@ -192,16 +192,16 @@ void ASObject::sinit(Class_base* c) { - c->setDeclaredMethodByQName("hasOwnProperty",AS3,Class<IFunction>::getFunction(hasOwnProperty),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setPropertyIsEnumerable",AS3,Class<IFunction>::getFunction(setPropertyIsEnumerable),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("hasOwnProperty",AS3,Class<IFunction>::getFunction(c->getSystemState(),hasOwnProperty),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setPropertyIsEnumerable",AS3,Class<IFunction>::getFunction(c->getSystemState(),setPropertyIsEnumerable),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toLocaleString","",Class<IFunction>::getFunction(_toLocaleString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(valueOf),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("hasOwnProperty","",Class<IFunction>::getFunction(hasOwnProperty),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("isPrototypeOf","",Class<IFunction>::getFunction(isPrototypeOf),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("propertyIsEnumerable","",Class<IFunction>::getFunction(propertyIsEnumerable),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setPropertyIsEnumerable","",Class<IFunction>::getFunction(setPropertyIsEnumerable),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toLocaleString","",Class<IFunction>::getFunction(c->getSystemState(),_toLocaleString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(c->getSystemState(),valueOf),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("hasOwnProperty","",Class<IFunction>::getFunction(c->getSystemState(),hasOwnProperty),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("isPrototypeOf","",Class<IFunction>::getFunction(c->getSystemState(),isPrototypeOf),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("propertyIsEnumerable","",Class<IFunction>::getFunction(c->getSystemState(),propertyIsEnumerable),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setPropertyIsEnumerable","",Class<IFunction>::getFunction(c->getSystemState(),setPropertyIsEnumerable),DYNAMIC_TRAIT); } @@ -323,9 +323,9 @@ { multiname valueOfName(NULL); valueOfName.name_type=multiname::NAME_STRING; - valueOfName.name_s_id=getSys()->getUniqueStringId("valueOf"); - valueOfName.ns.emplace_back("",NAMESPACE); - valueOfName.ns.emplace_back(AS3,NAMESPACE); + valueOfName.name_s_id=getSystemState()->getUniqueStringId("valueOf"); + valueOfName.ns.emplace_back(getSystemState(),"",NAMESPACE); + valueOfName.ns.emplace_back(getSystemState(),AS3,NAMESPACE); valueOfName.isAttribute = false; return hasPropertyByMultiname(valueOfName, true, true); } @@ -337,15 +337,15 @@ { multiname valueOfName(NULL); valueOfName.name_type=multiname::NAME_STRING; - valueOfName.name_s_id=getSys()->getUniqueStringId("valueOf"); - valueOfName.ns.emplace_back("",NAMESPACE); - valueOfName.ns.emplace_back(AS3,NAMESPACE); + valueOfName.name_s_id=getSystemState()->getUniqueStringId("valueOf"); + valueOfName.ns.emplace_back(getSystemState(),"",NAMESPACE); + valueOfName.ns.emplace_back(getSystemState(),AS3,NAMESPACE); valueOfName.isAttribute = false; assert_and_throw(hasPropertyByMultiname(valueOfName, true, true)); _NR<ASObject> o=getVariableByMultiname(valueOfName,SKIP_IMPL); if (!o->is<IFunction>()) - throwError<TypeError>(kCallOfNonFunctionError, valueOfName.normalizedNameUnresolved()); + throwError<TypeError>(kCallOfNonFunctionError, valueOfName.normalizedNameUnresolved(getSystemState())); IFunction* f=o->as<IFunction>(); incRef(); @@ -357,9 +357,9 @@ { multiname toStringName(NULL); toStringName.name_type=multiname::NAME_STRING; - toStringName.name_s_id=getSys()->getUniqueStringId("toString"); - toStringName.ns.emplace_back("",NAMESPACE); - toStringName.ns.emplace_back(AS3,NAMESPACE); + toStringName.name_s_id=getSystemState()->getUniqueStringId("toString"); + toStringName.ns.emplace_back(getSystemState(),"",NAMESPACE); + toStringName.ns.emplace_back(getSystemState(),AS3,NAMESPACE); toStringName.isAttribute = false; return ASObject::hasPropertyByMultiname(toStringName, true, true); } @@ -371,9 +371,9 @@ { multiname toStringName(NULL); toStringName.name_type=multiname::NAME_STRING; - toStringName.name_s_id=getSys()->getUniqueStringId("toString"); - toStringName.ns.emplace_back("",NAMESPACE); - toStringName.ns.emplace_back(AS3,NAMESPACE); + toStringName.name_s_id=getSystemState()->getUniqueStringId("toString"); + toStringName.ns.emplace_back(getSystemState(),"",NAMESPACE); + toStringName.ns.emplace_back(getSystemState(),AS3,NAMESPACE); toStringName.isAttribute = false; assert(ASObject::hasPropertyByMultiname(toStringName, true, true)); @@ -392,9 +392,9 @@ ok = false; multiname toJSONName(NULL); toJSONName.name_type=multiname::NAME_STRING; - toJSONName.name_s_id=getSys()->getUniqueStringId("toJSON"); - toJSONName.ns.emplace_back("",NAMESPACE); - toJSONName.ns.emplace_back(AS3,NAMESPACE); + toJSONName.name_s_id=getSystemState()->getUniqueStringId("toJSON"); + toJSONName.ns.emplace_back(getSystemState(),"",NAMESPACE); + toJSONName.ns.emplace_back(getSystemState(),AS3,NAMESPACE); toJSONName.isAttribute = false; if (!ASObject::hasPropertyByMultiname(toJSONName, true, true)) return res; @@ -464,20 +464,19 @@ if(considerDynamic) validTraits|=DYNAMIC_TRAIT; - if(Variables.findObjVar(name, NO_CREATE_TRAIT, validTraits)!=NULL) + if(Variables.findObjVar(getSystemState(),name, validTraits)!=NULL) return true; - if(classdef && classdef->borrowedVariables.findObjVar(name, NO_CREATE_TRAIT, DECLARED_TRAIT)!=NULL) + if(classdef && classdef->borrowedVariables.findObjVar(getSystemState(),name, DECLARED_TRAIT)!=NULL) return true; - NS_KIND nskind; //Check prototype inheritance chain if(getClass() && considerPrototype) { Prototype* proto = getClass()->prototype.getPtr(); while(proto) { - if(proto->getObj()->findGettable(name,nskind) != NULL) + if(proto->getObj()->findGettable(name) != NULL) return true; proto=proto->prevPrototype.getPtr(); } @@ -489,12 +488,12 @@ void ASObject::setDeclaredMethodByQName(const tiny_string& name, const tiny_string& ns, IFunction* o, METHOD_TYPE type, bool isBorrowed) { - setDeclaredMethodByQName(name, nsNameAndKind(ns, NAMESPACE), o, type, isBorrowed); + setDeclaredMethodByQName(name, nsNameAndKind(getSystemState(),ns, NAMESPACE), o, type, isBorrowed); } void ASObject::setDeclaredMethodByQName(const tiny_string& name, const nsNameAndKind& ns, IFunction* o, METHOD_TYPE type, bool isBorrowed) { - setDeclaredMethodByQName(getSys()->getUniqueStringId(name), ns, o, type, isBorrowed); + setDeclaredMethodByQName(getSystemState()->getUniqueStringId(name), ns, o, type, isBorrowed); } void ASObject::setDeclaredMethodByQName(uint32_t nameId, const nsNameAndKind& ns, IFunction* o, METHOD_TYPE type, bool isBorrowed) @@ -552,7 +551,7 @@ bool ASObject::deleteVariableByMultiname(const multiname& name) { - variable* obj=Variables.findObjVar(name,NO_CREATE_TRAIT,DYNAMIC_TRAIT|DECLARED_TRAIT); + variable* obj=Variables.findObjVar(getSystemState(),name,NO_CREATE_TRAIT,DYNAMIC_TRAIT|DECLARED_TRAIT); if(obj==NULL) { @@ -575,7 +574,7 @@ obj->var->decRef(); //Now kill the variable - Variables.killObjVar(name); + Variables.killObjVar(getSystemState(),name); return true; } @@ -583,12 +582,12 @@ void ASObject::setVariableByMultiname_i(const multiname& name, int32_t value) { check(); - setVariableByMultiname(name,abstract_i(value),CONST_NOT_ALLOWED); + setVariableByMultiname(name,abstract_i(this->getSystemState(),value),CONST_NOT_ALLOWED); } -variable* ASObject::findSettableImpl(variables_map& map, const multiname& name, bool* has_getter) +variable* ASObject::findSettableImpl(SystemState* sys,variables_map& map, const multiname& name, bool* has_getter) { - variable* ret=map.findObjVar(name,NO_CREATE_TRAIT,DECLARED_TRAIT|DYNAMIC_TRAIT); + variable* ret=map.findObjVar(sys,name,NO_CREATE_TRAIT,DECLARED_TRAIT|DYNAMIC_TRAIT); if(ret) { //It seems valid for a class to redefine only the getter, so if we can't find @@ -605,7 +604,7 @@ variable* ASObject::findSettable(const multiname& name, bool* has_getter) { - return findSettableImpl(Variables, name, has_getter); + return findSettableImpl(getSystemState(),Variables, name, has_getter); } @@ -619,7 +618,7 @@ if (obj && (obj->kind == CONSTANT_TRAIT && allowConst==CONST_NOT_ALLOWED)) { - throwError<ReferenceError>(kConstWriteError, name.normalizedNameUnresolved(), classdef->as<Class_base>()->getQualifiedClassName()); + throwError<ReferenceError>(kConstWriteError, name.normalizedNameUnresolved(getSystemState()), classdef->as<Class_base>()->getQualifiedClassName()); } if(!obj && cls) { @@ -630,7 +629,7 @@ obj=cls->findBorrowedSettable(name,&has_getter); if(obj && (cls->isFinal || cls->isSealed) && !obj->setter) { - throwError<ReferenceError>(kCannotAssignToMethodError, name.normalizedNameUnresolved(), cls ? cls->getQualifiedClassName() : ""); + throwError<ReferenceError>(kCannotAssignToMethodError, name.normalizedNameUnresolved(getSystemState()), cls ? cls->getQualifiedClassName() : ""); } } @@ -645,7 +644,7 @@ ((protoObj->var && protoObj->var->is<Function>()) || protoObj->setter)) { - throwError<ReferenceError>(kCannotAssignToMethodError, name.normalizedNameUnresolved(), cls ? cls->getQualifiedClassName() : ""); + throwError<ReferenceError>(kCannotAssignToMethodError, name.normalizedNameUnresolved(getSystemState()), cls ? cls->getQualifiedClassName() : ""); } } @@ -653,20 +652,20 @@ { if(has_getter) // Is this a read-only property? { - throwError<ReferenceError>(kConstWriteError, name.normalizedNameUnresolved(), cls ? cls->getQualifiedClassName() : ""); + throwError<ReferenceError>(kConstWriteError, name.normalizedNameUnresolved(getSystemState()), cls ? cls->getQualifiedClassName() : ""); } // Properties can not be added to a sealed class - if (cls && cls->isSealed && getVm()->currentCallContext) + if (cls && cls->isSealed && getVm(getSystemState())->currentCallContext) { - const Type* type = Type::getTypeFromMultiname(&name,getVm()->currentCallContext->context); + const Type* type = Type::getTypeFromMultiname(&name,getVm(getSystemState())->currentCallContext->context); if (type) - throwError<ReferenceError>(kConstWriteError, name.normalizedNameUnresolved(), cls ? cls->getQualifiedClassName() : ""); - throwError<ReferenceError>(kWriteSealedError, name.normalizedNameUnresolved(), cls->getQualifiedClassName()); + throwError<ReferenceError>(kConstWriteError, name.normalizedNameUnresolved(getSystemState()), cls ? cls->getQualifiedClassName() : ""); + throwError<ReferenceError>(kWriteSealedError, name.normalizedNameUnresolved(getSystemState()), cls->getQualifiedClassName()); } //Create a new dynamic variable - obj=Variables.findObjVar(name,DYNAMIC_TRAIT,DYNAMIC_TRAIT); + obj=Variables.findObjVar(getSystemState(),name,DYNAMIC_TRAIT,DYNAMIC_TRAIT); } if(obj->setter) @@ -691,13 +690,13 @@ void ASObject::setVariableByQName(const tiny_string& name, const tiny_string& ns, ASObject* o, TRAIT_KIND traitKind) { - const nsNameAndKind tmpns(ns, NAMESPACE); + const nsNameAndKind tmpns(getSystemState(),ns, NAMESPACE); setVariableByQName(name, tmpns, o, traitKind); } void ASObject::setVariableByQName(const tiny_string& name, const nsNameAndKind& ns, ASObject* o, TRAIT_KIND traitKind) { - setVariableByQName(getSys()->getUniqueStringId(name), ns, o, traitKind); + setVariableByQName(getSystemState()->getUniqueStringId(name), ns, o, traitKind); } void ASObject::setVariableByQName(uint32_t nameId, const nsNameAndKind& ns, ASObject* o, TRAIT_KIND traitKind) @@ -746,9 +745,9 @@ //Resolve the typename if we have one //currentCallContext may be NULL when inserting legacy //children, which is done outisde any ABC context - if(!(traitState&TYPE_RESOLVED) && traitTypemname && getVm()->currentCallContext) + if(!(traitState&TYPE_RESOLVED) && traitTypemname && getVm(v->getSystemState())->currentCallContext) { - type = Type::getTypeFromMultiname(traitTypemname, getVm()->currentCallContext->context); + type = Type::getTypeFromMultiname(traitTypemname, getVm(v->getSystemState())->currentCallContext->context); assert(type); traitState=TYPE_RESOLVED; } @@ -768,9 +767,9 @@ var=v; } -void variables_map::killObjVar(const multiname& mname) +void variables_map::killObjVar(SystemState* sys,const multiname& mname) { - uint32_t name=mname.normalizedNameId(); + uint32_t name=mname.normalizedNameId(sys); //The namespaces in the multiname are ordered. So it's possible to use lower_bound //to find the first candidate one and move from it assert(!mname.ns.empty()); @@ -799,9 +798,9 @@ throw RunTimeException("Variable to kill not found"); } -variable* variables_map::findObjVar(const multiname& mname, TRAIT_KIND createKind, uint32_t traitKinds) +variable* variables_map::findObjVar(SystemState* sys,const multiname& mname, TRAIT_KIND createKind, uint32_t traitKinds) { - uint32_t name=mname.normalizedNameId(); + uint32_t name=mname.normalizedNameId(sys); assert(!mname.ns.empty()); var_iterator ret=Variables.lower_bound(varName(name,mname.ns.front())); @@ -846,42 +845,6 @@ return &inserted->second; } -const variable* variables_map::findObjVar(const multiname& mname, uint32_t traitKinds, NS_KIND &nskind) const -{ - if (mname.isEmpty()) - return NULL; - uint32_t name=mname.normalizedNameId(); - assert(!mname.ns.empty()); - - const_var_iterator ret=Variables.lower_bound(varName(name,mname.ns.front())); - auto nsIt=mname.ns.begin(); - - //Find the namespace - while(ret!=Variables.end() && ret->first.nameId==name) - { - //breaks when the namespace is not found - const nsNameAndKind& ns=ret->first.ns; - if(ns==*nsIt) - { - nskind = ns.getImpl().kind; - if(ret->second.kind & traitKinds) - return &ret->second; - else - return NULL; - } - else if(*nsIt<ns) - { - ++nsIt; - if(nsIt==mname.ns.end()) - break; - } - else if(ns<*nsIt) - ++ret; - } - - return NULL; -} - void variables_map::initializeVar(const multiname& mname, ASObject* obj, multiname* typemname, ABCContext* context, TRAIT_KIND traitKind, ASObject* mainObj) { const Type* type = NULL; @@ -896,7 +859,7 @@ { if (obj == NULL) // create dynamic object { - obj = getSys()->getUndefinedRef(); + obj = mainObj->getSystemState()->getUndefinedRef(); } else { @@ -906,7 +869,7 @@ //Casting undefined to an object (of unknown class) //results in Null obj->decRef(); - obj = getSys()->getNullRef(); + obj = mainObj->getSystemState()->getNullRef(); } } } @@ -925,18 +888,18 @@ v.traitKind = traitKind; v.typemname = typemname; //context->addUninitializedVar(v); - obj = getSys()->getUndefinedRef(); + obj = mainObj->getSystemState()->getUndefinedRef(); obj = type->coerce(obj); } else if(mainObj->is<Class_base>() && - mainObj->as<Class_base>()->class_name.getQualifiedName() == typemname->qualifiedString()) + mainObj->as<Class_base>()->class_name.getQualifiedName() == typemname->qualifiedString(mainObj->getSystemState())) { // avoid recursive construction - //obj = getSys()->getNullRef(); - obj = getSys()->getUndefinedRef(); + //obj = mainObj->getSystemState()->getNullRef(); + obj = mainObj->getSystemState()->getUndefinedRef(); } - else if (type != Class_object::getClass() && - dynamic_cast<const Class_base*>(type)) + else if (dynamic_cast<const Class_base*>(type) + && type != Class_object::getClass(dynamic_cast<const Class_base*>(type)->getSystemState())) { //if (!((Class_base*)type)->super) { @@ -949,8 +912,8 @@ v.traitKind = traitKind; v.typemname = typemname; //context->addUninitializedVar(v); - obj = getSys()->getUndefinedRef(); - //obj = getSys()->getNullRef(); + obj = mainObj->getSystemState()->getUndefinedRef(); + //obj = mainObj->getSystemState()->getNullRef(); obj = type->coerce(obj); } //else @@ -958,14 +921,14 @@ } else { - obj = getSys()->getUndefinedRef(); + obj = mainObj->getSystemState()->getUndefinedRef(); obj = type->coerce(obj); } } } assert(traitKind==DECLARED_TRAIT || traitKind==CONSTANT_TRAIT || traitKind == INSTANCE_TRAIT); - uint32_t name=mname.normalizedNameId(); + uint32_t name=mname.normalizedNameId(mainObj->getSystemState()); Variables.insert(make_pair(varName(name, mname.ns[0]), variable(traitKind, obj, typemname, type))); } @@ -979,7 +942,7 @@ return args[0]; } else - return Class<ASObject>::getInstanceS(); + return Class<ASObject>::getInstanceS(getSys()); } ASFUNCTIONBODY(ASObject,_toString) @@ -1000,15 +963,15 @@ else ret="[object Object]"; - return abstract_s(ret); + return abstract_s(obj->getSystemState(),ret); } ASFUNCTIONBODY(ASObject,_toLocaleString) { multiname toStringName(NULL); toStringName.name_type=multiname::NAME_STRING; - toStringName.name_s_id=getSys()->getUniqueStringId("toString"); - toStringName.ns.emplace_back("",NAMESPACE); + toStringName.name_s_id=obj->getSystemState()->getUniqueStringId("toString"); + toStringName.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); toStringName.isAttribute = false; if (obj->hasPropertyByMultiname(toStringName, true, false)) { @@ -1028,11 +991,11 @@ assert_and_throw(argslen==1); multiname name(NULL); name.name_type=multiname::NAME_STRING; - name.name_s_id=getSys()->getUniqueStringId(args[0]->toString()); - name.ns.emplace_back("",NAMESPACE); + name.name_s_id=obj->getSystemState()->getUniqueStringId(args[0]->toString()); + name.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); name.isAttribute=false; bool ret=obj->hasPropertyByMultiname(name, true, false); - return abstract_b(ret); + return abstract_b(obj->getSystemState(),ret); } ASFUNCTIONBODY(ASObject,valueOf) @@ -1059,33 +1022,33 @@ break; cls = clsparent; } - return abstract_b(ret); + return abstract_b(obj->getSystemState(),ret); } ASFUNCTIONBODY(ASObject,propertyIsEnumerable) { if (argslen == 0) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); multiname name(NULL); name.name_type=multiname::NAME_STRING; - name.name_s_id=getSys()->getUniqueStringId(args[0]->toString()); - name.ns.emplace_back("",NAMESPACE); + name.name_s_id=obj->getSystemState()->getUniqueStringId(args[0]->toString()); + name.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); name.isAttribute=false; if (obj->is<Array>()) // propertyIsEnumerable(index) isn't mentioned in the ECMA specs but is tested for { Array* a = static_cast<Array*>(obj); unsigned int index = 0; - if (a->isValidMultiname(name,index)) + if (a->isValidMultiname(obj->getSystemState(),name,index)) { - return abstract_b(index < (unsigned int)a->size()); + return abstract_b(obj->getSystemState(),index < (unsigned int)a->size()); } } - variable* v = obj->Variables.findObjVar(name, NO_CREATE_TRAIT,DYNAMIC_TRAIT); + variable* v = obj->Variables.findObjVar(obj->getSystemState(),name, NO_CREATE_TRAIT,DYNAMIC_TRAIT); if (v) - return abstract_b(v->isenumerable); + return abstract_b(obj->getSystemState(),v->isenumerable); if (obj->hasPropertyByMultiname(name,true,false)) - return abstract_b(true); - return abstract_b(false); + return abstract_b(obj->getSystemState(),true); + return abstract_b(obj->getSystemState(),false); } ASFUNCTIONBODY(ASObject,setPropertyIsEnumerable) { @@ -1094,22 +1057,18 @@ ARG_UNPACK(propname) (isEnum, true); multiname name(NULL); name.name_type=multiname::NAME_STRING; - name.name_s_id=getSys()->getUniqueStringId(args[0]->toString()); - name.ns.emplace_back("",NAMESPACE); + name.name_s_id=obj->getSystemState()->getUniqueStringId(args[0]->toString()); + name.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); name.isAttribute=false; obj->setIsEnumerable(name, isEnum); return NULL; } void ASObject::setIsEnumerable(const multiname &name, bool isEnum) { - variable* v = Variables.findObjVar(name, NO_CREATE_TRAIT,DYNAMIC_TRAIT); + variable* v = Variables.findObjVar(getSystemState(),name, NO_CREATE_TRAIT,DYNAMIC_TRAIT); if (v) v->isenumerable = isEnum; } -void ASObject::destroyContents() -{ - Variables.destroyContents(); -} ASFUNCTIONBODY(ASObject,_constructor) { @@ -1140,33 +1099,15 @@ return ret->toInt(); } -const variable* ASObject::findGettableImpl(const variables_map& map, const multiname& name, NS_KIND &nskind) -{ - const variable* ret=map.findObjVar(name,DECLARED_TRAIT|DYNAMIC_TRAIT,nskind); - if(ret) - { - //It seems valid for a class to redefine only the setter, so if we can't find - //something to get, it's ok - if(!(ret->getter || ret->var)) - ret=NULL; - } - return ret; -} - -const variable* ASObject::findGettable(const multiname& name, NS_KIND &nskind) const -{ - return findGettableImpl(Variables,name,nskind); -} - -const variable* ASObject::findVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt, Class_base* cls, NS_KIND &nskind) const +const variable* ASObject::findVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt, Class_base* cls, uint32_t *nsRealID) const { //Get from the current object without considering borrowed properties - const variable* var=findGettable(name,nskind); + const variable* var=findGettable(name,nsRealID); if(!var && cls) { //Look for borrowed traits before - var=cls->findBorrowedGettable(name,nskind); + var=cls->findBorrowedGettable(name,nsRealID); } if(!var && cls) @@ -1175,7 +1116,7 @@ Prototype* proto = cls->prototype.getPtr(); while(proto) { - var = proto->getObj()->findGettable(name,nskind); + var = proto->getObj()->findGettable(name,nsRealID); if(var) break; proto = proto->prevPrototype.getPtr(); @@ -1188,8 +1129,42 @@ { check(); assert(!cls || classdef->isSubClass(cls)); - NS_KIND nskind; - const variable* obj=findVariableByMultiname(name, opt, cls,nskind); + uint32_t nsRealId; + + const variable* obj=Variables.findObjVar(getSystemState(),name,DECLARED_TRAIT|DYNAMIC_TRAIT,&nsRealId); + if(obj) + { + //It seems valid for a class to redefine only the setter, so if we can't find + //something to get, it's ok + if(!(obj->getter || obj->var)) + obj=NULL; + } + + if(!obj && cls) + { + //Look for borrowed traits before + obj=cls->findBorrowedGettable(name,&nsRealId); + } + + if(!obj && cls) + { + //Check prototype chain + Prototype* proto = cls->prototype.getPtr(); + while(proto) + { + obj=proto->getObj()->Variables.findObjVar(getSystemState(),name,DECLARED_TRAIT|DYNAMIC_TRAIT,&nsRealId); + if(obj) + { + //It seems valid for a class to redefine only the setter, so if we can't find + //something to get, it's ok + if(!(obj->getter || obj->var)) + obj=NULL; + } + if(obj) + break; + proto = proto->prevPrototype.getPtr(); + } + } if(!obj) return NullRef; @@ -1198,10 +1173,9 @@ obj->var->getObjectType() == T_UNDEFINED || obj->var->getObjectType() == T_NULL)) { - LOG(LOG_CALLS,"accessing class:"<<name<<" "<< this->as<Class_base>()->getQualifiedClassName()<<" "<<nskind); if (obj->kind == INSTANCE_TRAIT && - nskind != STATIC_PROTECTED_NAMESPACE) - throwError<TypeError>(kCallOfNonFunctionError,name.normalizedNameUnresolved()); + getSystemState()->getNamespaceFromUniqueId(nsRealId).kind != STATIC_PROTECTED_NAMESPACE) + throwError<TypeError>(kCallOfNonFunctionError,name.normalizedNameUnresolved(getSystemState())); } if(obj->getter) @@ -1245,9 +1219,9 @@ { multiname varName(NULL); varName.name_type=multiname::NAME_STRING; - varName.name_s_id=getSys()->getUniqueStringId(name); + varName.name_s_id=getSystemState()->getUniqueStringId(name); for (auto ns=namespaces.begin(); ns!=namespaces.end(); ns++) - varName.ns.emplace_back(*ns,NAMESPACE); + varName.ns.emplace_back(getSystemState(),*ns,NAMESPACE); varName.isAttribute = false; return getVariableByMultiname(varName,SKIP_IMPL); @@ -1349,8 +1323,8 @@ void variables_map::destroyContents() { - var_iterator it=Variables.begin(); - for(;it!=Variables.end();++it) + const_var_iterator it=Variables.begin(); + while(it!=Variables.end()) { if(it->second.var) it->second.var->decRef(); @@ -1358,21 +1332,12 @@ it->second.setter->decRef(); if(it->second.getter) it->second.getter->decRef(); + it = Variables.erase(it); } - Variables.clear(); } -ASObject::ASObject(MemoryAccount* m):Variables(m),classdef(NULL),proxyMultiName(NULL), - type(T_OBJECT),traitsInitialized(false),constructIndicator(false),constructorCallComplete(false),implEnable(true) -{ -#ifndef NDEBUG - //Stuff only used in debugging - initialized=false; -#endif -} - -ASObject::ASObject(Class_base* c):Variables((c)?c->memoryAccount:NULL),classdef(NULL),proxyMultiName(NULL), - type(T_OBJECT),traitsInitialized(false),constructIndicator(false),constructorCallComplete(false),implEnable(true) +ASObject::ASObject(Class_base* c):Variables((c)?c->memoryAccount:NULL),classdef(NULL),proxyMultiName(NULL),sys(c?c->sys:NULL), + type(T_OBJECT),traitsInitialized(false),constructIndicator(false),constructorCallComplete(false),reusableListNumber(0),implEnable(true) { setClass(c); #ifndef NDEBUG @@ -1381,8 +1346,8 @@ #endif } -ASObject::ASObject(const ASObject& o):Variables((o.classdef)?o.classdef->memoryAccount:NULL),classdef(NULL),proxyMultiName(NULL), - type(o.type),traitsInitialized(false),constructIndicator(false),constructorCallComplete(false),implEnable(true) +ASObject::ASObject(const ASObject& o):Variables((o.classdef)?o.classdef->memoryAccount:NULL),classdef(NULL),proxyMultiName(NULL),sys(o.classdef? o.classdef->sys : NULL), + type(o.type),traitsInitialized(false),constructIndicator(false),constructorCallComplete(false),reusableListNumber(0),implEnable(true) { if(o.classdef) setClass(o.classdef); @@ -1409,6 +1374,7 @@ { classdef->acquireObject(this); classdef->incRef(); + this->sys = c->sys; } } @@ -1422,14 +1388,6 @@ } } -void ASObject::finalize() -{ -} - -ASObject::~ASObject() -{ - destroy(); -} void ASObject::destruct() { finalize(); @@ -1532,7 +1490,7 @@ } } -tiny_string variables_map::getNameAt(unsigned int index) const +tiny_string variables_map::getNameAt(SystemState *sys, unsigned int index) const { //TODO: CHECK behaviour on overridden methods if(index<Variables.size()) @@ -1542,7 +1500,7 @@ for(unsigned int i=0;i<index;i++) ++it; - return getSys()->getStringFromUniqueId(it->first.nameId); + return sys->getStringFromUniqueId(it->first.nameId); } else throw RunTimeException("getNameAt out of bounds"); @@ -1553,10 +1511,6 @@ return Variables.size(); } -void ASObject::constructionComplete() -{ -} - void ASObject::serializeDynamicProperties(ByteArray* out, std::map<tiny_string, uint32_t>& stringMap, std::map<const ASObject*, uint32_t>& objMap, std::map<const Class_base*, uint32_t> traitsMap) const @@ -1578,9 +1532,9 @@ //Dynamic traits always have empty namespace assert(it->first.ns.hasEmptyName()); if (amf0) - out->writeStringAMF0(getSys()->getStringFromUniqueId(it->first.nameId)); + out->writeStringAMF0(out->getSystemState()->getStringFromUniqueId(it->first.nameId)); else - out->writeStringVR(stringMap,getSys()->getStringFromUniqueId(it->first.nameId)); + out->writeStringVR(stringMap,out->getSystemState()->getStringFromUniqueId(it->first.nameId)); it->second.var->serialize(out, stringMap, objMap, traitsMap); } //The empty string closes the object @@ -1618,8 +1572,8 @@ assert_and_throw(type); //Check if an alias is registered - auto aliasIt=getSys()->aliasMap.begin(); - const auto aliasEnd=getSys()->aliasMap.end(); + auto aliasIt=getSystemState()->aliasMap.begin(); + const auto aliasEnd=getSystemState()->aliasMap.end(); //Linear search for alias tiny_string alias; for(;aliasIt!=aliasEnd;++aliasIt) @@ -1632,7 +1586,7 @@ } bool serializeTraits = alias.empty()==false; - if(type->isSubClass(InterfaceClass<IExternalizable>::getClass())) + if(type->isSubClass(InterfaceClass<IExternalizable>::getClass(getSystemState()))) { //Custom serialization necessary if(!serializeTraits) @@ -1650,8 +1604,8 @@ //Invoke writeExternal multiname writeExternalName(NULL); writeExternalName.name_type=multiname::NAME_STRING; - writeExternalName.name_s_id=getSys()->getUniqueStringId("writeExternal"); - writeExternalName.ns.emplace_back("",NAMESPACE); + writeExternalName.name_s_id=getSystemState()->getUniqueStringId("writeExternal"); + writeExternalName.ns.emplace_back(getSystemState(),"",NAMESPACE); writeExternalName.isAttribute = false; _NR<ASObject> o=getVariableByMultiname(writeExternalName,SKIP_IMPL); @@ -1689,7 +1643,7 @@ //Skip variable with a namespace, like protected ones continue; } - out->writeStringAMF0(getSys()->getStringFromUniqueId(varIt->first.nameId)); + out->writeStringAMF0(getSystemState()->getStringFromUniqueId(varIt->first.nameId)); varIt->second.var->serialize(out, stringMap, objMap, traitsMap); } } @@ -1730,7 +1684,7 @@ //Skip variable with a namespace, like protected ones continue; } - out->writeStringVR(stringMap, getSys()->getStringFromUniqueId(varIt->first.nameId)); + out->writeStringVR(stringMap, getSystemState()->getStringFromUniqueId(varIt->first.nameId)); } } } @@ -1887,30 +1841,30 @@ res += ","; res += newline+spaces; res += "\""; - res += getSys()->getStringFromUniqueId(varIt->first.nameId); + res += getSystemState()->getStringFromUniqueId(varIt->first.nameId); res += "\""; res += ":"; if (!spaces.empty()) res += " "; ASObject* params[2]; - params[0] = abstract_s(getSys()->getStringFromUniqueId(varIt->first.nameId)); + params[0] = abstract_s(getSystemState(),getSystemState()->getStringFromUniqueId(varIt->first.nameId)); params[1] = varIt->second.var; params[1]->incRef(); - ASObject *funcret=replacer->call(getSys()->getNullRef(), params, 2); + ASObject *funcret=replacer->call(getSystemState()->getNullRef(), params, 2); if (funcret) res += funcret->toString(); else res += varIt->second.var->toJSON(path,replacer,spaces+spaces,filter); bfirst = false; } - else if (filter.empty() || filter.find(tiny_string(" ")+getSys()->getStringFromUniqueId(varIt->first.nameId)+" ") != tiny_string::npos) + else if (filter.empty() || filter.find(tiny_string(" ")+getSystemState()->getStringFromUniqueId(varIt->first.nameId)+" ") != tiny_string::npos) { if (!bfirst) res += ","; res += newline+spaces; res += "\""; - res += getSys()->getStringFromUniqueId(varIt->first.nameId); + res += getSystemState()->getStringFromUniqueId(varIt->first.nameId); res += "\""; res += ":"; if (!spaces.empty()) @@ -1954,16 +1908,16 @@ multiname prototypeName(NULL); prototypeName.name_type=multiname::NAME_STRING; - prototypeName.name_s_id=getSys()->getUniqueStringId("prototype"); - prototypeName.ns.emplace_back("",NAMESPACE); + prototypeName.name_s_id=getSystemState()->getUniqueStringId("prototype"); + prototypeName.ns.emplace_back(getSystemState(),"",NAMESPACE); bool has_getter = false; variable* ret=findSettable(prototypeName,&has_getter); if(!ret && has_getter) throwError<ReferenceError>(kConstWriteError, - prototypeName.normalizedNameUnresolved(), + prototypeName.normalizedNameUnresolved(getSystemState()), classdef ? classdef->as<Class_base>()->getQualifiedClassName() : ""); if(!ret) - ret = Variables.findObjVar(prototypeName,DYNAMIC_TRAIT,DECLARED_TRAIT|DYNAMIC_TRAIT); + ret = Variables.findObjVar(getSystemState(),prototypeName,DYNAMIC_TRAIT,DECLARED_TRAIT|DYNAMIC_TRAIT); if(ret->setter) { this->incRef();
View file
lightspark.tar.xz/src/asobject.h
Changed
@@ -65,23 +65,23 @@ ASObject* c::_getter_##name(ASObject* obj, ASObject* const* args, const unsigned int argslen) \ { \ if(!obj->is<c>()) \ - throw Class<ArgumentError>::getInstanceS("Function applied to wrong object"); \ + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Function applied to wrong object"); \ c* th = obj->as<c>(); \ if(argslen != 0) \ - throw Class<ArgumentError>::getInstanceS("Arguments provided in getter"); \ - return ArgumentConversion<decltype(th->name)>::toAbstract(th->name); \ + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Arguments provided in getter"); \ + return ArgumentConversion<decltype(th->name)>::toAbstract(obj->getSystemState(),th->name); \ } #define ASFUNCTIONBODY_GETTER_NOT_IMPLEMENTED(c,name) \ ASObject* c::_getter_##name(ASObject* obj, ASObject* const* args, const unsigned int argslen) \ { \ if(!obj->is<c>()) \ - throw Class<ArgumentError>::getInstanceS("Function applied to wrong object"); \ + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Function applied to wrong object"); \ c* th = obj->as<c>(); \ if(argslen != 0) \ - throw Class<ArgumentError>::getInstanceS("Arguments provided in getter"); \ + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Arguments provided in getter"); \ LOG(LOG_NOT_IMPLEMENTED,obj->getClassName() <<"."<< #name << " getter is not implemented"); \ - return ArgumentConversion<decltype(th->name)>::toAbstract(th->name); \ + return ArgumentConversion<decltype(th->name)>::toAbstract(obj->getSystemState(),th->name); \ } /* full body for a getter declared by ASPROPERTY_SETTER or ASFUNCTION_SETTER */ @@ -89,10 +89,10 @@ ASObject* c::_setter_##name(ASObject* obj, ASObject* const* args, const unsigned int argslen) \ { \ if(!obj->is<c>()) \ - throw Class<ArgumentError>::getInstanceS("Function applied to wrong object"); \ + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Function applied to wrong object"); \ c* th = obj->as<c>(); \ if(argslen != 1) \ - throw Class<ArgumentError>::getInstanceS("Wrong number of arguments in setter"); \ + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Wrong number of arguments in setter"); \ th->name = ArgumentConversion<decltype(th->name)>::toConcrete(args[0]); \ return NULL; \ } @@ -101,10 +101,10 @@ ASObject* c::_setter_##name(ASObject* obj, ASObject* const* args, const unsigned int argslen) \ { \ if(!obj->is<c>()) \ - throw Class<ArgumentError>::getInstanceS("Function applied to wrong object"); \ + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Function applied to wrong object"); \ c* th = obj->as<c>(); \ if(argslen != 1) \ - throw Class<ArgumentError>::getInstanceS("Wrong number of arguments in setter"); \ + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Wrong number of arguments in setter"); \ LOG(LOG_NOT_IMPLEMENTED,obj->getClassName() <<"."<< #name << " setter is not implemented"); \ th->name = ArgumentConversion<decltype(th->name)>::toConcrete(args[0]); \ return NULL; \ @@ -117,10 +117,10 @@ ASObject* c::_setter_##name(ASObject* obj, ASObject* const* args, const unsigned int argslen) \ { \ if(!obj->is<c>()) \ - throw Class<ArgumentError>::getInstanceS("Function applied to wrong object"); \ + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Function applied to wrong object"); \ c* th = obj->as<c>(); \ if(argslen != 1) \ - throw Class<ArgumentError>::getInstanceS("Wrong number of arguments in setter"); \ + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Wrong number of arguments in setter"); \ decltype(th->name) oldValue = th->name; \ th->name = ArgumentConversion<decltype(th->name)>::toConcrete(args[0]); \ th->callback(oldValue); \ @@ -142,10 +142,10 @@ /* registers getter/setter with Class_base. To be used in ::sinit()-functions */ #define REGISTER_GETTER(c,name) \ - c->setDeclaredMethodByQName(#name,"",Class<IFunction>::getFunction(_getter_##name),GETTER_METHOD,true) + c->setDeclaredMethodByQName(#name,"",Class<IFunction>::getFunction(c->getSystemState(),_getter_##name),GETTER_METHOD,true) #define REGISTER_SETTER(c,name) \ - c->setDeclaredMethodByQName(#name,"",Class<IFunction>::getFunction(_setter_##name),SETTER_METHOD,true) + c->setDeclaredMethodByQName(#name,"",Class<IFunction>::getFunction(c->getSystemState(),_setter_##name),SETTER_METHOD,true) #define REGISTER_GETTER_SETTER(c,name) \ REGISTER_GETTER(c,name); \ @@ -157,18 +157,18 @@ // TODO: Every class should have a constructor #define CLASS_SETUP_NO_CONSTRUCTOR(c, superClass, attributes) \ - c->setSuper(Class<superClass>::getRef()); \ + c->setSuper(Class<superClass>::getRef(c->getSystemState())); \ c->setConstructor(NULL); \ c->isFinal = ((attributes) & CLASS_FINAL) != 0; \ c->isSealed = ((attributes) & CLASS_SEALED) != 0 #define CLASS_SETUP(c, superClass, constructor, attributes) \ CLASS_SETUP_NO_CONSTRUCTOR(c, superClass, attributes); \ - c->setConstructor(Class<IFunction>::getFunction(constructor)); + c->setConstructor(Class<IFunction>::getFunction(c->getSystemState(),constructor)); #define CLASS_SETUP_CONSTRUCTOR_LENGTH(c, superClass, constructor, ctorlength, attributes) \ CLASS_SETUP_NO_CONSTRUCTOR(c, superClass, attributes); \ - c->setConstructor(Class<IFunction>::getFunction((constructor), (ctorlength))); + c->setConstructor(Class<IFunction>::getFunction(c->getSystemState(),(constructor), (ctorlength))); namespace lightspark { @@ -181,7 +181,9 @@ class Loader; class Type; class ABCContext; +class SystemState; +extern SystemState* getSys(); enum TRAIT_KIND { NO_CREATE_TRAIT=0, DECLARED_TRAIT=1, DYNAMIC_TRAIT=2, INSTANCE_TRAIT=5, CONSTANT_TRAIT=9 /* constants are also declared traits */ }; enum TRAIT_STATE { NO_STATE=0, HAS_GETTER_SETTER=1, TYPE_RESOLVED=2 }; @@ -246,14 +248,50 @@ @param traitKinds Bitwise OR of accepted trait kinds */ variable* findObjVar(uint32_t nameId, const nsNameAndKind& ns, TRAIT_KIND createKind, uint32_t traitKinds); - variable* findObjVar(const multiname& mname, TRAIT_KIND createKind, uint32_t traitKinds); + variable* findObjVar(SystemState* sys,const multiname& mname, TRAIT_KIND createKind, uint32_t traitKinds); /** * Const version of findObjVar, useful when looking for getters */ - const variable* findObjVar(const multiname& mname, uint32_t traitKinds, NS_KIND &nskind) const; + inline const variable* findObjVar(SystemState* sys,const multiname& mname, uint32_t traitKinds, uint32_t* nsRealId = NULL) const + { + if (mname.isEmpty()) + return NULL; + uint32_t name=mname.name_type == multiname::NAME_STRING ? mname.name_s_id : mname.normalizedNameId(sys); + assert(!mname.ns.empty()); + + const_var_iterator ret=Variables.lower_bound(varName(name,mname.ns.front())); + auto nsIt=mname.ns.cbegin(); + + //Find the namespace + while(ret!=Variables.cend() && ret->first.nameId==name) + { + //breaks when the namespace is not found + const nsNameAndKind& ns=ret->first.ns; + if(ns==*nsIt) + { + if (nsRealId) + *nsRealId = ns.nsRealId; + if(ret->second.kind & traitKinds) + return &ret->second; + else + return NULL; + } + else if(*nsIt<ns) + { + ++nsIt; + if(nsIt==mname.ns.cend()) + break; + } + else if(ns<*nsIt) + ++ret; + } + + return NULL; + } + //Initialize a new variable specifying the type (TODO: add support for const) void initializeVar(const multiname& mname, ASObject* obj, multiname *typemname, ABCContext* context, TRAIT_KIND traitKind, ASObject* mainObj); - void killObjVar(const multiname& mname); + void killObjVar(SystemState* sys, const multiname& mname); ASObject* getSlot(unsigned int n) { assert_and_throw(n > 0 && n<=slots_vars.size()); @@ -278,7 +316,7 @@ { return Variables.size(); } - tiny_string getNameAt(unsigned int i) const; + tiny_string getNameAt(SystemState* sys,unsigned int i) const; variable* getValueAt(unsigned int i); int getNextEnumerable(unsigned int i) const; ~variables_map(); @@ -299,28 +337,68 @@ friend class ABCVm; friend class ABCContext; friend class Class_base; //Needed for forced cleanup +friend class Class_inherit; friend void lookupAndLink(Class_base* c, const tiny_string& name, const tiny_string& interfaceNs); friend class IFunction; //Needed for clone private: variables_map Variables; Class_base* classdef; - const variable* findGettable(const multiname& name, NS_KIND &nskind) const DLL_LOCAL; + inline const variable* findGettable(const multiname& name, uint32_t* nsRealId = NULL) const DLL_LOCAL + { + const variable* ret=Variables.findObjVar(getSystemState(),name,DECLARED_TRAIT|DYNAMIC_TRAIT,nsRealId); + if(ret) + { + //It seems valid for a class to redefine only the setter, so if we can't find + //something to get, it's ok + if(!(ret->getter || ret->var)) + ret=NULL; + } + return ret; + } + variable* findSettable(const multiname& name, bool* has_getter=NULL) DLL_LOCAL; multiname* proxyMultiName; + SystemState* sys; protected: - ASObject(MemoryAccount* m); + ASObject(MemoryAccount* m):Variables(m),classdef(NULL),proxyMultiName(NULL),sys(NULL), + type(T_OBJECT),traitsInitialized(false),constructIndicator(false),constructorCallComplete(false),reusableListNumber(0),implEnable(true) + { +#ifndef NDEBUG + //Stuff only used in debugging + initialized=false; +#endif + } + ASObject(const ASObject& o); - virtual ~ASObject(); + virtual ~ASObject() + { + destroy(); + } SWFOBJECT_TYPE type; bool traitsInitialized:1; bool constructIndicator:1; bool constructorCallComplete:1; // indicates that the constructor including all super constructors has been called + // indicates which reusable list to use for classes with several subclasses + // currently only used for IFunction (Function/SyntheticFunction) + int reusableListNumber; void serializeDynamicProperties(ByteArray* out, std::map<tiny_string, uint32_t>& stringMap, std::map<const ASObject*, uint32_t>& objMap, std::map<const Class_base*, uint32_t> traitsMap) const; void setClass(Class_base* c); - static variable* findSettableImpl(variables_map& map, const multiname& name, bool* has_getter); - static const variable* findGettableImpl(const variables_map& map, const multiname& name, NS_KIND &nskind); + static variable* findSettableImpl(SystemState* sys,variables_map& map, const multiname& name, bool* has_getter); + inline static const variable* findGettableImpl(SystemState* sys,const variables_map& map, const multiname& name, uint32_t* nsRealId = NULL) + { + const variable* ret=map.findObjVar(sys,name,DECLARED_TRAIT|DYNAMIC_TRAIT,nsRealId); + if(ret) + { + //It seems valid for a class to redefine only the setter, so if we can't find + //something to get, it's ok + if(!(ret->getter || ret->var)) + ret=NULL; + } + return ret; + } + //overridden from RefCountable void destruct(); // called when object is really destroyed @@ -364,10 +442,9 @@ It should be implemented in all derived class. It should decRef all referenced objects. It has to reset all data to their default state. - that will happen on the object after finalization are decRef and delete. The finalize method must be callable multiple time with the same effects (no double frees). */ - virtual void finalize(); + inline virtual void finalize() {} enum GET_VARIABLE_OPTION {NONE=0x00, SKIP_IMPL=0x01, XML_STRICT=0x02}; @@ -379,7 +456,7 @@ * Helper method using the get the raw variable struct instead of calling the getter. * It is used by getVariableByMultiname and by early binding code */ - const variable* findVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt, Class_base* cls, NS_KIND &nskind) const; + const variable* findVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt, Class_base* cls, uint32_t* nsRealID = NULL) const; /* * Gets a variable of this object. It looks through all classes (beginning at cls), * then the prototype chain, and then instance variables. @@ -445,13 +522,23 @@ unsigned int numVariables() const; tiny_string getNameAt(int i) const { - return Variables.getNameAt(i); + return Variables.getNameAt(sys,i); } _R<ASObject> getValueAt(int i); SWFOBJECT_TYPE getObjectType() const { return type; } + SystemState* getSystemState() const + { + assert_and_throw(sys); + return sys; + } + void setSystemState(SystemState* s) + { + sys = s; + } + /* Implements ECMA's 9.8 ToString operation, but returns the concrete value */ tiny_string toString(); tiny_string toLocaleString(); @@ -459,7 +546,7 @@ virtual uint32_t toUInt(); uint16_t toUInt16(); /* Implements ECMA's 9.3 ToNumber operation, but returns the concrete value */ - number_t toNumber(); + virtual number_t toNumber(); /* Implements ECMA's ToPrimitive (9.1) and [[DefaultValue]] (8.6.2.6) */ _R<ASObject> toPrimitive(TP_HINT hint = NO_HINT); bool isPrimitive() const; @@ -500,7 +587,9 @@ virtual _R<ASObject> nextValue(uint32_t index); //Called when the object construction is completed. Used by MovieClip implementation - virtual void constructionComplete(); + inline virtual void constructionComplete() + { + } /** Serialization interface @@ -532,11 +621,16 @@ void dumpVariables() const; - void setConstructIndicator() { constructIndicator = true; } - void setConstructorCallComplete() { constructorCallComplete = true; } + inline void setConstructIndicator() { constructIndicator = true; } + inline void setConstructorCallComplete() { constructorCallComplete = true; } + inline void setIsInitialized() { traitsInitialized=true;} void setIsEnumerable(const multiname& name, bool isEnum); - void destroyContents(); + inline void destroyContents() + { + Variables.destroyContents(); + } + }; class Number; @@ -545,16 +639,20 @@ class Boolean; class Template_base; class ASString; +class IFunction; class Function; class Array; class Null; class Undefined; class Type; +class ASQName; +class Namespace; template<> inline bool ASObject::is<Number>() const { return type==T_NUMBER; } template<> inline bool ASObject::is<Integer>() const { return type==T_INTEGER; } template<> inline bool ASObject::is<UInteger>() const { return type==T_UINTEGER; } template<> inline bool ASObject::is<Boolean>() const { return type==T_BOOLEAN; } template<> inline bool ASObject::is<ASString>() const { return type==T_STRING; } +template<> inline bool ASObject::is<IFunction>() const { return type==T_FUNCTION; } template<> inline bool ASObject::is<Function>() const { return type==T_FUNCTION; } template<> inline bool ASObject::is<Undefined>() const { return type==T_UNDEFINED; } template<> inline bool ASObject::is<Null>() const { return type==T_NULL; } @@ -562,5 +660,7 @@ template<> inline bool ASObject::is<Class_base>() const { return type==T_CLASS; } template<> inline bool ASObject::is<Template_base>() const { return type==T_TEMPLATE; } template<> inline bool ASObject::is<Type>() const { return type==T_CLASS; } +template<> inline bool ASObject::is<ASQName>() const { return type==T_QNAME; } +template<> inline bool ASObject::is<Namespace>() const { return type==T_NAMESPACE; } } #endif /* ASOBJECT_H */
View file
lightspark.tar.xz/src/backends/extscriptobject.cpp
Changed
@@ -252,16 +252,16 @@ switch(getType()) { case EV_STRING: - asobj = Class<ASString>::getInstanceS(getString().c_str()); + asobj = abstract_s(getSys(),getString().c_str()); break; case EV_INT32: - asobj = abstract_i(getInt()); + asobj = abstract_i(getSys(),getInt()); break; case EV_DOUBLE: - asobj = abstract_d(getDouble()); + asobj = abstract_d(getSys(),getDouble()); break; case EV_BOOLEAN: - asobj = abstract_b(getBoolean()); + asobj = abstract_b(getSys(),getBoolean()); break; case EV_OBJECT: { @@ -279,7 +279,7 @@ // We are converting an array, so lets set indexes if(objValue->getType() == ExtObject::EO_ARRAY) { - asobj = Class<Array>::getInstanceS(); + asobj = Class<Array>::getInstanceS(getSys()); objectsMap[objValue] = asobj; count = objValue->getLength(); @@ -293,7 +293,7 @@ // We are converting an object, so lets set variables else { - asobj = Class<ASObject>::getInstanceS(); + asobj = Class<ASObject>::getInstanceS(getSys()); objectsMap[objValue] = asobj; ExtIdentifier** ids; @@ -373,7 +373,7 @@ func->incRef(); funcEvent = _MR(new (getSys()->unaccountedMemory) ExternalCallEvent(_MR(func), asArgs, argc, &result, &exceptionThrown, &exception)); // Add the callback function event to the VM event queue - funcWasCalled=getVm()->addEvent(NullRef,funcEvent); + funcWasCalled=getVm(getSys())->addEvent(NullRef,funcEvent); if(!funcWasCalled) funcEvent = NullRef; }
View file
lightspark.tar.xz/src/backends/input.cpp
Changed
@@ -175,7 +175,7 @@ return NullRef; } assert(selected); /* atleast we hit the stage */ - assert_and_throw(selected->getClass()->isSubClass(Class<InteractiveObject>::getClass())); + assert_and_throw(selected->getClass()->isSubClass(Class<InteractiveObject>::getClass(m_sys))); return selected; } @@ -188,7 +188,7 @@ number_t localX, localY; selected->globalToLocal(x,y,localX,localY); m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS("mouseDown",localX,localY,true,buttonState))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseDown",localX,localY,true,buttonState))); lastMouseDownTarget=selected; } @@ -201,7 +201,7 @@ number_t localX, localY; selected->globalToLocal(x,y,localX,localY); m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS("doubleClick",localX,localY,true,buttonState))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"doubleClick",localX,localY,true,buttonState))); } void InputThread::handleMouseUp(uint32_t x, uint32_t y, unsigned int buttonState) @@ -213,12 +213,12 @@ number_t localX, localY; selected->globalToLocal(x,y,localX,localY); m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS("mouseUp",localX,localY,true,buttonState))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseUp",localX,localY,true,buttonState))); if(lastMouseDownTarget==selected) { //Also send the click event m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS("click",localX,localY,true,buttonState))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"click",localX,localY,true,buttonState))); } lastMouseDownTarget=NullRef; } @@ -256,7 +256,7 @@ selected->globalToLocal(x,y,localX,localY); if(currentMouseOver == selected) m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS("mouseMove",localX,localY,true,buttonState))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseMove",localX,localY,true,buttonState))); else { if(!currentMouseOver.isNull()) @@ -264,14 +264,14 @@ number_t clocalX, clocalY; currentMouseOver->globalToLocal(x,y,clocalX,clocalY); m_sys->currentVm->addEvent(currentMouseOver, - _MR(Class<MouseEvent>::getInstanceS("mouseOut",clocalX,clocalY,true,buttonState,selected))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseOut",clocalX,clocalY,true,buttonState,selected))); m_sys->currentVm->addEvent(currentMouseOver, - _MR(Class<MouseEvent>::getInstanceS("rollOut",clocalX,clocalY,true,buttonState,selected))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"rollOut",clocalX,clocalY,true,buttonState,selected))); } m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS("mouseOver",localX,localY,true,buttonState,currentMouseOver))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseOver",localX,localY,true,buttonState,currentMouseOver))); m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS("rollOver",localX,localY,true,buttonState,currentMouseOver))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"rollOver",localX,localY,true,buttonState,currentMouseOver))); currentMouseOver = selected; } } @@ -295,7 +295,7 @@ number_t localX, localY; selected->globalToLocal(x,y,localX,localY); m_sys->currentVm->addEvent(selected, - _MR(Class<MouseEvent>::getInstanceS("mouseWheel",localX,localY,true,buttonState,NullRef,delta))); + _MR(Class<MouseEvent>::getInstanceS(m_sys,"mouseWheel",localX,localY,true,buttonState,NullRef,delta))); } void InputThread::handleMouseLeave() @@ -306,7 +306,7 @@ _NR<Stage> stage = m_sys->mainClip->getStage(); stage->incRef(); m_sys->currentVm->addEvent(stage, - _MR(Class<Event>::getInstanceS("mouseLeave"))); + _MR(Class<Event>::getInstanceS(m_sys,"mouseLeave"))); } void InputThread::initKeyTable() @@ -418,7 +418,7 @@ target->incRef(); m_sys->currentVm->addEvent(target, - _MR(Class<KeyboardEvent>::getInstanceS(type, charcode, keyevent->hardware_keycode, keyevent->state))); + _MR(Class<KeyboardEvent>::getInstanceS(m_sys,type, charcode, keyevent->hardware_keycode, keyevent->state))); } void InputThread::addListener(InteractiveObject* ob)
View file
lightspark.tar.xz/src/backends/netutils.cpp
Changed
@@ -822,13 +822,13 @@ if(checkPolicyFile) { SecurityManager::EVALUATIONRESULT evaluationResult = \ - getSys()->securityManager->evaluatePoliciesURL(url, true); + dispatcher->getSystemState()->securityManager->evaluatePoliciesURL(url, true); if(threadAborting) return false; if(evaluationResult == SecurityManager::NA_CROSSDOMAIN_POLICY) { dispatcher->incRef(); - getVm()->addEvent(dispatcher,_MR(Class<SecurityErrorEvent>::getInstanceS("SecurityError: " + getVm(dispatcher->getSystemState())->addEvent(dispatcher,_MR(Class<SecurityErrorEvent>::getInstanceS(dispatcher->getSystemState(),"SecurityError: " "connection to domain not allowed by securityManager"))); return false; } @@ -841,11 +841,11 @@ if(postData.empty()) { //This is a GET request - downloader=getSys()->downloadManager->download(url, cache, owner); + downloader=dispatcher->getSystemState()->downloadManager->download(url, cache, owner); } else { - downloader=getSys()->downloadManager->downloadWithData(url, cache, postData, requestHeaders, owner); + downloader=dispatcher->getSystemState()->downloadManager->downloadWithData(url, cache, postData, requestHeaders, owner); } return true;
View file
lightspark.tar.xz/src/backends/rendering.cpp
Changed
@@ -869,7 +869,7 @@ if(!diff.negative()) /* is one seconds elapsed? */ { time_s=time_d; - LOG(LOG_INFO,_("FPS: ") << dec << frameCount<<" "<<getVm()->getEventQueueSize()); + LOG(LOG_INFO,_("FPS: ") << dec << frameCount<<" "<<getVm(getSys())->getEventQueueSize()); frameCount=0; secsCount++; }
View file
lightspark.tar.xz/src/backends/security.cpp
Changed
@@ -483,17 +483,17 @@ allowedSandboxesLocal, restrictLocalDirectory); //Network sandboxes can't access local files (this should be a SecurityErrorEvent) if(evaluationResult == SecurityManager::NA_REMOTE_SANDBOX) - throw Class<SecurityError>::getInstanceS("SecurityError: " + throw Class<SecurityError>::getInstanceS(getSys(),"SecurityError: " "connect to network"); //Local-with-filesystem sandbox can't access network else if(evaluationResult == SecurityManager::NA_LOCAL_SANDBOX) - throw Class<SecurityError>::getInstanceS("SecurityError: " + throw Class<SecurityError>::getInstanceS(getSys(),"SecurityError: " "connect to local file"); else if(evaluationResult == SecurityManager::NA_PORT) - throw Class<SecurityError>::getInstanceS("SecurityError: " + throw Class<SecurityError>::getInstanceS(getSys(),"SecurityError: " "connect to restricted port"); else if(evaluationResult == SecurityManager::NA_RESTRICT_LOCAL_DIRECTORY) - throw Class<SecurityError>::getInstanceS("SecurityError: " + throw Class<SecurityError>::getInstanceS(getSys(),"SecurityError: " "not allowed to navigate up for local files"); }
View file
lightspark.tar.xz/src/parsing/amf3_generator.cpp
Changed
@@ -47,7 +47,7 @@ uint32_t tmp; if(!input->readU29(tmp)) throw ParseException("Not enough data to parse integer"); - return _MR(abstract_i(tmp)); + return _MR(abstract_i(input->getSystemState(),tmp)); } _R<ASObject> Amf3Deserializer::parseDouble() const @@ -65,7 +65,7 @@ throw ParseException("Not enough data to parse double"); } tmp.dummy=GINT64_FROM_BE(tmp.dummy); - return _MR(abstract_d(tmp.val)); + return _MR(abstract_d(input->getSystemState(),tmp.val)); } _R<ASObject> Amf3Deserializer::parseDate() const @@ -83,7 +83,7 @@ throw ParseException("Not enough data to parse date"); } tmp.dummy=GINT64_FROM_BE(tmp.dummy); - Date* dt = Class<Date>::getInstanceS(); + Date* dt = Class<Date>::getInstanceS(input->getSystemState()); dt->MakeDateFromMilliseconds((int64_t)tmp.val); return _MR(dt); } @@ -135,7 +135,7 @@ return _MR(ret); } - _R<lightspark::Array> ret=_MR(Class<lightspark::Array>::getInstanceS()); + _R<lightspark::Array> ret=_MR(Class<lightspark::Array>::getInstanceS(input->getSystemState())); //Add object to the map objMap.push_back(ret.getPtr()); @@ -186,13 +186,13 @@ switch (marker) { case vector_int_marker: - type = Class<Integer>::getClass(); + type = Class<Integer>::getClass(input->getSystemState()); break; case vector_uint_marker: - type = Class<UInteger>::getClass(); + type = Class<UInteger>::getClass(input->getSystemState()); break; case vector_double_marker: - type = Class<Number>::getClass(); + type = Class<Number>::getClass(input->getSystemState()); break; case vector_object_marker: { @@ -200,14 +200,14 @@ vectypename = parseStringVR(stringMap); multiname m(NULL); m.name_type=multiname::NAME_STRING; - m.name_s_id=getSys()->getUniqueStringId(vectypename); - m.ns.push_back(nsNameAndKind("",NAMESPACE)); + m.name_s_id=input->getSystemState()->getUniqueStringId(vectypename); + m.ns.push_back(nsNameAndKind(input->getSystemState(),"",NAMESPACE)); m.isAttribute = false; - type = Type::getTypeFromMultiname(&m,getVm()->currentCallContext->context); + type = Type::getTypeFromMultiname(&m,getVm(input->getSystemState())->currentCallContext->context); if (type == NULL) { LOG(LOG_ERROR,"unknown vector type during deserialization:"<<m); - type = Class<ASObject>::getClass(); + type = Class<ASObject>::getClass(input->getSystemState()); } break; } @@ -216,7 +216,7 @@ throw ParseException("invalid marker in AMF3 vector"); } - _R<lightspark::Vector> ret=_MR(Template<Vector>::getInstanceS(type,ABCVm::getCurrentApplicationDomain(getVm()->currentCallContext))); + _R<lightspark::Vector> ret=_MR(Template<Vector>::getInstanceS(input->getSystemState(),type,ABCVm::getCurrentApplicationDomain(getVm(input->getSystemState())->currentCallContext))); //Add object to the map objMap.push_back(ret.getPtr()); @@ -232,7 +232,7 @@ uint32_t value = 0; if (!input->readUnsignedInt(value)) throw ParseException("Not enough data to parse AMF3 vector"); - ret->append(abstract_i(value)); + ret->append(abstract_i(input->getSystemState(),value)); break; } case vector_uint_marker: @@ -240,7 +240,7 @@ uint32_t value = 0; if (!input->readUnsignedInt(value)) throw ParseException("Not enough data to parse AMF3 vector"); - ret->append(abstract_ui(value)); + ret->append(abstract_ui(input->getSystemState(),value)); break; } case vector_double_marker: @@ -288,7 +288,7 @@ throw ParseException("Not enough data to parse AMF3 vector"); if (weakkeys) LOG(LOG_NOT_IMPLEMENTED,"handling of weak keys in Dictionary"); - _R<Dictionary> ret=_MR(Class<Dictionary>::getInstanceS()); + _R<Dictionary> ret=_MR(Class<Dictionary>::getInstanceS(input->getSystemState())); //Add object to the map objMap.push_back(ret.getPtr()); @@ -302,7 +302,7 @@ multiname name(NULL); name.name_type=multiname::NAME_OBJECT; name.name_o = key.getPtr(); - name.ns.push_back(nsNameAndKind("",NAMESPACE)); + name.ns.push_back(nsNameAndKind(input->getSystemState(),"",NAMESPACE)); key->incRef(); value->incRef(); ret->setVariableByMultiname(name,value.getPtr(),ASObject::CONST_ALLOWED); @@ -328,7 +328,7 @@ return _MR(ret); } - _R<ByteArray> ret=_MR(Class<ByteArray>::getInstanceS()); + _R<ByteArray> ret=_MR(Class<ByteArray>::getInstanceS(input->getSystemState())); //Add object to the map objMap.push_back(ret.getPtr()); @@ -367,8 +367,8 @@ //Custom serialization const tiny_string& className=parseStringVR(stringMap); assert_and_throw(!className.empty()); - const auto it=getSys()->aliasMap.find(className); - assert_and_throw(it!=getSys()->aliasMap.end()); + const auto it=input->getSystemState()->aliasMap.find(className); + assert_and_throw(it!=input->getSystemState()->aliasMap.end()); Class_base* type=it->second.getPtr(); traitsMap.push_back(TraitsRef(type)); @@ -377,8 +377,8 @@ //Invoke readExternal multiname readExternalName(NULL); readExternalName.name_type=multiname::NAME_STRING; - readExternalName.name_s_id=getSys()->getUniqueStringId("readExternal"); - readExternalName.ns.push_back(nsNameAndKind("",NAMESPACE)); + readExternalName.name_s_id=input->getSystemState()->getUniqueStringId("readExternal"); + readExternalName.ns.push_back(nsNameAndKind(input->getSystemState(),"",NAMESPACE)); readExternalName.isAttribute = false; _NR<ASObject> o=ret->getVariableByMultiname(readExternalName,ASObject::SKIP_IMPL); @@ -408,14 +408,14 @@ for(uint32_t i=0;i<traitsCount;i++) traits.traitsNames.emplace_back(parseStringVR(stringMap)); - const auto it=getSys()->aliasMap.find(className); - if(it!=getSys()->aliasMap.end()) + const auto it=input->getSystemState()->aliasMap.find(className); + if(it!=input->getSystemState()->aliasMap.end()) traits.type=it->second.getPtr(); traitsMap.emplace_back(traits); } _R<ASObject> ret=_MR((traits.type)?traits.type->getInstance(true, NULL, 0): - Class<ASObject>::getInstanceS()); + Class<ASObject>::getInstanceS(input->getSystemState())); //Add object to the map objMap.push_back(ret.getPtr()); @@ -426,8 +426,8 @@ multiname name(NULL); name.name_type=multiname::NAME_STRING; - name.name_s_id=getSys()->getUniqueStringId(traits.traitsNames[i]); - name.ns.push_back(nsNameAndKind("",NAMESPACE)); + name.name_s_id=input->getSystemState()->getUniqueStringId(traits.traitsNames[i]); + name.ns.push_back(nsNameAndKind(input->getSystemState(),"",NAMESPACE)); name.isAttribute=false; ret->setVariableByMultiname(name,value.getPtr(),ASObject::CONST_ALLOWED,traits.type); @@ -474,9 +474,9 @@ ASObject *xmlObj; if(legacyXML) - xmlObj=Class<XMLDocument>::getInstanceS(xmlStr); + xmlObj=Class<XMLDocument>::getInstanceS(input->getSystemState(),xmlStr); else - xmlObj=XML::createFromString(xmlStr); + xmlObj=XML::createFromString(input->getSystemState(),xmlStr); objMap.push_back(xmlObj); return _MR(xmlObj); } @@ -495,13 +495,13 @@ switch(marker) { case null_marker: - return _MR(getSys()->getNullRef()); + return _MR(input->getSystemState()->getNullRef()); case undefined_marker: - return _MR(getSys()->getUndefinedRef()); + return _MR(input->getSystemState()->getUndefinedRef()); case false_marker: - return _MR(abstract_b(false)); + return _MR(abstract_b(input->getSystemState(),false)); case true_marker: - return _MR(abstract_b(true)); + return _MR(abstract_b(input->getSystemState(),true)); case integer_marker: return parseInteger(); case double_marker: @@ -509,7 +509,7 @@ case date_marker: return parseDate(); case string_marker: - return _MR(Class<ASString>::getInstanceS(parseStringVR(stringMap))); + return _MR(abstract_s(input->getSystemState(),parseStringVR(stringMap))); case xml_doc_marker: return parseXML(objMap, true); case array_marker: @@ -540,15 +540,15 @@ case amf0_number_marker: return parseDouble(); case amf0_boolean_marker: - return _MR(abstract_b(input->readByte(marker))); + return _MR(abstract_b(input->getSystemState(), input->readByte(marker))); case amf0_string_marker: - return _MR(Class<ASString>::getInstanceS(parseStringAMF0())); + return _MR(abstract_s(input->getSystemState(),parseStringAMF0())); case amf0_object_marker: return parseObjectAMF0(stringMap,objMap,traitsMap); case amf0_null_marker: - return _MR(getSys()->getNullRef()); + return _MR(input->getSystemState()->getNullRef()); case amf0_undefined_marker: - return _MR(getSys()->getUndefinedRef()); + return _MR(input->getSystemState()->getUndefinedRef()); case amf0_reference_marker: LOG(LOG_ERROR,"unimplemented marker " << (uint32_t)marker); throw UnsupportedException("unimplemented marker"); @@ -600,7 +600,7 @@ if(!input->readUnsignedInt(count)) throw ParseException("Not enough data to parse AMF3 array"); - _R<ASObject> ret=_MR(Class<ASObject>::getInstanceS()); + _R<ASObject> ret=_MR(Class<ASObject>::getInstanceS(input->getSystemState())); //Read name, value pairs while(true) @@ -628,7 +628,7 @@ if(!input->readUnsignedInt(count)) throw ParseException("Not enough data to parse AMF3 strict array"); - _R<lightspark::Array> ret=_MR(Class<lightspark::Array>::getInstanceS()); + _R<lightspark::Array> ret=_MR(Class<lightspark::Array>::getInstanceS(input->getSystemState())); //Add object to the map objMap.push_back(ret.getPtr()); @@ -646,7 +646,7 @@ std::vector<ASObject*>& objMap, std::vector<TraitsRef>& traitsMap) const { - _R<ASObject> ret=_MR(Class<ASObject>::getInstanceS()); + _R<ASObject> ret=_MR(Class<ASObject>::getInstanceS(input->getSystemState())); while (true) { @@ -664,6 +664,6 @@ ret->setVariableByQName(varName,"",value.getPtr(),DYNAMIC_TRAIT); } - return _R<ASObject>(getSys()->getUndefinedRef()); + return _R<ASObject>(input->getSystemState()->getUndefinedRef()); }
View file
lightspark.tar.xz/src/parsing/flv.cpp
Changed
@@ -96,7 +96,7 @@ if (dataSize > 0) { - _R<ByteArray> b = _NR<ByteArray>(Class<ByteArray>::getInstanceS()); + _R<ByteArray> b = _NR<ByteArray>(Class<ByteArray>::getInstanceS(getSys())); uint8_t* data =b->getBuffer(dataSize,true); s.read((char*)data,dataSize); b->setObjectEncoding(ObjectEncoding::AMF0);
View file
lightspark.tar.xz/src/parsing/streams.cpp
Changed
@@ -27,6 +27,9 @@ #include <cstring> #include <assert.h> + +extern lightspark::SystemState* getSys(); + #define LZMA_PROP_LENGTH 5 using namespace std; @@ -206,120 +209,7 @@ return sizeof(buffer) - strm.avail_out; } -memorystream::memorystream(const char* const b, unsigned int l) - : code(b), len(l), pos(0), read_past_end(false) -{ -} - -unsigned int memorystream::tellg() const -{ - return pos; -} - -void memorystream::seekg(unsigned int offset) -{ - if (offset > len) - pos = len; - else - pos = offset; -} - -unsigned int memorystream::size() const -{ - return len; -} - -void memorystream::read(char *out, unsigned int nbytes) -{ - if ((nbytes == 1) && (pos+1 > len)) - { - // fastpath for one bytes reads - *out = code[pos]; - pos++; - } - else if (pos+nbytes > len) - { - memcpy(out, code+pos, len-pos); - pos = len; - read_past_end = true; - } - else - { - memcpy(out, code+pos, nbytes); - pos += nbytes; - } -} -uint8_t memorystream::readbyte() -{ - if (pos < len) - { - pos++; - return code[pos-1]; - } - else - { - pos = len; - read_past_end = true; - return 0; - } -} -bool memorystream::eof() const -{ - return read_past_end; -} - -memorystream& lightspark::operator>>(memorystream& in, lightspark::u8& v) -{ - uint8_t t = in.readbyte(); - v.val= t; - return in; -} - -memorystream& lightspark::operator>>(memorystream& in, lightspark::s24& v) -{ - uint32_t ret=0; - in.read((char*)&ret,3); - v.val=LittleEndianToSignedHost24(ret); - return in; -} - -memorystream& lightspark::operator>>(memorystream& in, lightspark::u30& v) -{ - lightspark::u32 vv; - in >> vv; - uint32_t val = vv; - if(val&0xc0000000) - throw lightspark::Class<lightspark::VerifyError>::getInstanceS("Invalid u30"); - v.val = val; - return in; -} - -memorystream& lightspark::operator>>(memorystream& in, lightspark::u32& v) +void memorystream::handleError(const char* msg) { - int i=0; - uint32_t val=0; - uint8_t t; - do - { - t = in.readbyte(); - //No more than 5 bytes should be read - if(i==28) - { - //Only the first 4 bits should be used to reach 32 bits - if((t&0xf0)) - LOG(LOG_ERROR,"Error in u32"); - uint8_t t2=(t&0xf); - val|=(t2<<i); - break; - } - else - { - uint8_t t2=(t&0x7f); - val|=(t2<<i); - i+=7; - } - } - while(t&0x80); - v.val=val; - return in; + throw lightspark::Class<lightspark::VerifyError>::getInstanceS(lightspark::getSys(),msg); }
View file
lightspark.tar.xz/src/parsing/streams.h
Changed
@@ -102,23 +102,121 @@ unsigned int len; unsigned int pos; bool read_past_end; + lightspark::method_body_info_cache* codecache; public: // Create a stream from a buffer b. // // The buffer is not copied, so b must continue to exists for // the life-time of this memorystream instance. - memorystream(const char* const b, unsigned int l); - unsigned int size() const; - unsigned int tellg() const; - void seekg(unsigned int offset); - void read(char *out, unsigned int nbytes); - uint8_t readbyte(); - bool eof() const; + memorystream(const char* const b, unsigned int l,lightspark::method_body_info_cache* cc): code(b), len(l), pos(0), read_past_end(false),codecache(cc) {}; + static void handleError(const char *msg); + inline unsigned int size() const + { + return len; + } + + inline unsigned int tellg() const + { + return pos; + } + + inline void seekg(unsigned int offset) + { + if (offset > len) + pos = len; + else + pos = offset; + } + + inline void read(char *out, unsigned int nbytes) + { + if (pos+nbytes > len) + { + memcpy(out, code+pos, len-pos); + pos = len; + read_past_end = true; + } + else + { + memcpy(out, code+pos, nbytes); + pos += nbytes; + } + } + + inline uint8_t readbyte() + { + if (pos < len) + { + pos++; + return code[pos-1]; + } + else + { + pos = len; + read_past_end = true; + return 0; + } + } + inline uint32_t readu30() + { + unsigned int currpos = pos; + if (codecache[currpos].iscached) + { + pos = codecache[currpos].nextpos; + if (pos >= len) + { + pos = len; + read_past_end = true; + } + return codecache[currpos].value; + } + uint32_t val = readu32(); + if(val&0xc0000000) + memorystream::handleError("Invalid u30"); + return val; + } + inline uint32_t readu32() + { + unsigned int currpos = pos; + + int i=0; + uint32_t val=0; + uint8_t t; + do + { + t = readbyte(); + //No more than 5 bytes should be read + if(i==28) + { + //Only the first 4 bits should be used to reach 32 bits + if((t&0xf0)) + LOG(LOG_ERROR,"Error in u32"); + val|=((t&0xf)<<i); + break; + } + else + { + val|=((t&0x7f)<<i); + i+=7; + } + } + while(t&0x80); + codecache[currpos].iscached = true; + codecache[currpos].value = val; + codecache[currpos].nextpos = pos; + return val; + } + inline int32_t reads24() + { + uint32_t val=0; + read((char*)&val,3); + return LittleEndianToSignedHost24(val); + } + + inline bool eof() const + { + return read_past_end; + } + }; - -memorystream& lightspark::operator>>(memorystream& in, lightspark::u8& v); -memorystream& lightspark::operator>>(memorystream& in, lightspark::s24& v); -memorystream& lightspark::operator>>(memorystream& in, lightspark::u30& v); -memorystream& lightspark::operator>>(memorystream& in, lightspark::u32& v); - #endif /* PARSING_STREAMS_H */
View file
lightspark.tar.xz/src/parsing/tags.cpp
Changed
@@ -347,7 +347,7 @@ ASObject* DefineEditTextTag::instance(Class_base* c) const { if(c==NULL) - c=Class<TextField>::getClass(); + c=Class<TextField>::getClass(loadedFrom->getSystemState()); //TODO: check assert_and_throw(bindedTo==NULL); TextField* ret=new (c->memoryAccount) TextField(c, textData, !NoSelect, ReadOnly); @@ -437,7 +437,7 @@ else if(bindedTo) retClass=bindedTo; else - retClass=Class<MovieClip>::getClass(); + retClass=Class<MovieClip>::getClass(loadedFrom->getSystemState()); return new (retClass->memoryAccount) MovieClip(retClass, *this, true); } @@ -484,7 +484,7 @@ else if(bindedTo) retClass=bindedTo; else - retClass=Class<ASFont>::getClass(); + retClass=Class<ASFont>::getClass(loadedFrom->getSystemState()); ASFont* ret=new (retClass->memoryAccount) ASFont(retClass); LOG(LOG_NOT_IMPLEMENTED,"DefineFontTag::instance doesn't handle all font properties"); @@ -589,7 +589,7 @@ else if(bindedTo) retClass=bindedTo; else - retClass=Class<ASFont>::getClass(); + retClass=Class<ASFont>::getClass(loadedFrom->getSystemState()); ASFont* ret=new (retClass->memoryAccount) ASFont(retClass); LOG(LOG_NOT_IMPLEMENTED,"DefineFont2Tag::instance doesn't handle all font properties"); @@ -721,7 +721,7 @@ else if(bindedTo) retClass=bindedTo; else - retClass=Class<ASFont>::getClass(); + retClass=Class<ASFont>::getClass(loadedFrom->getSystemState()); ASFont* ret=new (retClass->memoryAccount) ASFont(retClass); LOG(LOG_NOT_IMPLEMENTED,"DefineFont3Tag::instance doesn't handle all font properties"); @@ -807,7 +807,7 @@ else if(bindedTo) retClass=bindedTo; else - retClass=Class<ASFont>::getClass(); + retClass=Class<ASFont>::getClass(loadedFrom->getSystemState()); ASFont* ret=new (retClass->memoryAccount) ASFont(retClass); LOG(LOG_NOT_IMPLEMENTED,"DefineFont4Tag::instance doesn't handle all font properties"); @@ -815,7 +815,7 @@ return ret; } -BitmapTag::BitmapTag(RECORDHEADER h,RootMovieClip* root):DictionaryTag(h,root),bitmap(_MR(new BitmapContainer(getSys()->tagsMemory))) +BitmapTag::BitmapTag(RECORDHEADER h,RootMovieClip* root):DictionaryTag(h,root),bitmap(_MR(new BitmapContainer(root->getSystemState()->tagsMemory))) { } @@ -895,19 +895,19 @@ //Also BitmapData is used in the wild though, so support both cases Class_base* realClass=(c)?c:bindedTo; - Class_base* classRet = Class<BitmapData>::getClass(); + Class_base* classRet = Class<BitmapData>::getClass(loadedFrom->getSystemState()); if(!realClass) return new (classRet->memoryAccount) BitmapData(classRet, bitmap); - if(realClass->isSubClass(Class<Bitmap>::getClass())) + if(realClass->isSubClass(Class<Bitmap>::getClass(realClass->getSystemState()))) { BitmapData* ret=new (classRet->memoryAccount) BitmapData(classRet, bitmap); Bitmap* bitmapRet=new (realClass->memoryAccount) Bitmap(realClass,_MR(ret)); return bitmapRet; } - if(realClass->isSubClass(Class<BitmapData>::getClass())) + if(realClass->isSubClass(Class<BitmapData>::getClass(realClass->getSystemState()))) { classRet = realClass; } @@ -916,7 +916,7 @@ } DefineTextTag::DefineTextTag(RECORDHEADER h, istream& in, RootMovieClip* root,int v):DictionaryTag(h,root), - tokens(reporter_allocator<GeomToken>(getSys()->tagsMemory)),version(v) + tokens(reporter_allocator<GeomToken>(loadedFrom->getSystemState()->tagsMemory)),version(v) { in >> CharacterId >> TextBounds >> TextMatrix >> GlyphBits >> AdvanceBits; assert(v==1 || v==2); @@ -944,7 +944,7 @@ computeCached(); if(c==NULL) - c=Class<StaticText>::getClass(); + c=Class<StaticText>::getClass(loadedFrom->getSystemState()); StaticText* ret=new (c->memoryAccount) StaticText(c, tokens); return ret; @@ -1026,12 +1026,12 @@ } DefineShapeTag::DefineShapeTag(RECORDHEADER h,int v,RootMovieClip* root):DictionaryTag(h,root),Shapes(v), - tokens(reporter_allocator<GeomToken>(getSys()->tagsMemory)) + tokens(reporter_allocator<GeomToken>(root->getSystemState()->tagsMemory)) { } DefineShapeTag::DefineShapeTag(RECORDHEADER h, std::istream& in,RootMovieClip* root):DictionaryTag(h,root),Shapes(1), - tokens(reporter_allocator<GeomToken>(getSys()->tagsMemory)) + tokens(reporter_allocator<GeomToken>(root->getSystemState()->tagsMemory)) { LOG(LOG_TRACE,_("DefineShapeTag")); in >> ShapeId >> ShapeBounds >> Shapes; @@ -1085,9 +1085,9 @@ { assert_and_throw(bindedTo==NULL); if(c==NULL) - c=Class<MorphShape>::getClass(); + c=Class<MorphShape>::getClass(loadedFrom->getSystemState()); LOG(LOG_NOT_IMPLEMENTED, _("MorphShape not really supported")); - return Class<MorphShape>::getInstanceS(c); + return Class<MorphShape>::getInstanceS(c->getSystemState(),c); } DefineMorphShape2Tag::DefineMorphShape2Tag(RECORDHEADER h, std::istream& in, RootMovieClip* root):DefineMorphShapeTag(h, root, 2) @@ -1512,7 +1512,7 @@ { if(!isSprite[j]) { - Sprite* spr = Class<Sprite>::getInstanceS(); + Sprite* spr = Class<Sprite>::getInstanceS(loadedFrom->getSystemState()); spr->insertLegacyChildAt(curDepth[j],states[j]); states[j] = spr; //spr->name = "Button_spr"; @@ -1526,7 +1526,7 @@ Class_base* realClass=(c)?c:bindedTo; if(realClass==NULL) - realClass=Class<SimpleButton>::getClass(); + realClass=Class<SimpleButton>::getClass(loadedFrom->getSystemState()); SimpleButton* ret=new (realClass->memoryAccount) SimpleButton(realClass, states[0], states[1], states[2], states[3]); return ret; } @@ -1550,7 +1550,7 @@ else if(bindedTo) classRet=bindedTo; else - classRet=Class<Video>::getClass(); + classRet=Class<Video>::getClass(loadedFrom->getSystemState()); Video* ret=new (classRet->memoryAccount) Video(classRet, Width, Height); return ret; @@ -1578,7 +1578,7 @@ else if(bindedTo) classRet=bindedTo; else - classRet=Class<ByteArray>::getClass(); + classRet=Class<ByteArray>::getClass(loadedFrom->getSystemState()); ByteArray* ret=new (classRet->memoryAccount) ByteArray(classRet, b, len); return ret; @@ -1625,7 +1625,7 @@ else if(bindedTo) retClass=bindedTo; else - retClass=Class<Sound>::getClass(); + retClass=Class<Sound>::getClass(loadedFrom->getSystemState()); return new (retClass->memoryAccount) Sound(retClass, SoundData, AudioFormat(getAudioCodec(), getSampleRate(), getChannels())); @@ -1694,7 +1694,7 @@ void StartSoundTag::play(const DefineSoundTag *soundTag) const { - SoundChannel *schannel = Class<SoundChannel>::getInstanceS( + SoundChannel *schannel = Class<SoundChannel>::getInstanceS(soundTag->loadedFrom->getSystemState(), soundTag->getSoundData(), AudioFormat(soundTag->getAudioCodec(), soundTag->getSampleRate(),
View file
lightspark.tar.xz/src/parsing/tags.h
Changed
@@ -121,7 +121,7 @@ ASObject* instance(Class_base* c=NULL) const { if(c==NULL) - c=Class<Shape>::getClass(); + c=Class<Shape>::getClass(loadedFrom->getSystemState()); Shape* ret=new (c->memoryAccount) Shape(c, tokens, 1.0f/20.0f); return ret; }
View file
lightspark.tar.xz/src/scripting/abc.cpp
Changed
@@ -29,6 +29,7 @@ #include <llvm/PassManager.h> #else #include "llvm/IR/LegacyPassManager.h" +#include "llvm/ExecutionEngine/MCJIT.h" #endif #ifdef HAVE_IR_DATALAYOUT_H # include <llvm/IR/Module.h> @@ -142,7 +143,7 @@ RootMovieClip* root=getParseThread()->getRootMovie(); root->incRef(); - context=new ABCContext(_MR(root), in, getVm()); + context=new ABCContext(_MR(root), in, getVm(root->getSystemState())); int pos=in.tellg(); if(dest!=pos) @@ -152,11 +153,11 @@ } } -void DoABCTag::execute(RootMovieClip*) const +void DoABCTag::execute(RootMovieClip* root) const { LOG(LOG_CALLS,_("ABC Exec")); /* currentVM will free the context*/ - getVm()->addEvent(NullRef,_MR(new (getSys()->unaccountedMemory) ABCContextInitEvent(context,false))); + getVm(root->getSystemState())->addEvent(NullRef,_MR(new (root->getSystemState()->unaccountedMemory) ABCContextInitEvent(context,false))); } DoABCDefineTag::DoABCDefineTag(RECORDHEADER h, std::istream& in):ControlTag(h) @@ -168,7 +169,7 @@ RootMovieClip* root=getParseThread()->getRootMovie(); root->incRef(); - context=new ABCContext(_MR(root), in, getVm()); + context=new ABCContext(_MR(root), in, getVm(root->getSystemState())); int pos=in.tellg(); if(dest!=pos) @@ -178,11 +179,11 @@ } } -void DoABCDefineTag::execute(RootMovieClip*) const +void DoABCDefineTag::execute(RootMovieClip* root) const { LOG(LOG_CALLS,_("ABC Exec ") << Name); /* currentVM will free the context*/ - getVm()->addEvent(NullRef,_MR(new (getSys()->unaccountedMemory) ABCContextInitEvent(context,((int32_t)Flags)&1))); + getVm(root->getSystemState())->addEvent(NullRef,_MR(new (root->getSystemState()->unaccountedMemory) ABCContextInitEvent(context,((int32_t)Flags)&1))); } SymbolClassTag::SymbolClassTag(RECORDHEADER h, istream& in):ControlTag(h) @@ -208,7 +209,7 @@ if(Tags[i]==0) { root->incRef(); - getVm()->addEvent(NullRef, _MR(new (getSys()->unaccountedMemory) BindClassEvent(_MR(root),className))); + getVm(root->getSystemState())->addEvent(NullRef, _MR(new (root->getSystemState()->unaccountedMemory) BindClassEvent(_MR(root),className))); } else @@ -220,377 +221,347 @@ void ScriptLimitsTag::execute(RootMovieClip* root) const { - getVm()->limits.max_recursion = MaxRecursionDepth; - getVm()->limits.script_timeout = ScriptTimeoutSeconds; + getVm(root->getSystemState())->limits.max_recursion = MaxRecursionDepth; + getVm(root->getSystemState())->limits.script_timeout = ScriptTimeoutSeconds; } void ABCVm::registerClasses() { - Global* builtin=Class<Global>::getInstanceS((ABCContext*)NULL, 0); + Global* builtin=Class<Global>::getInstanceS(m_sys,(ABCContext*)NULL, 0); //Register predefined types, ASObject are enough for not implemented classes - builtin->registerBuiltin("Object","",Class<ASObject>::getRef()); - builtin->registerBuiltin("Class","",Class_object::getRef()); - builtin->registerBuiltin("Number","",Class<Number>::getRef()); - builtin->registerBuiltin("Boolean","",Class<Boolean>::getRef()); - builtin->registerBuiltin("NaN","",_MR(abstract_d(numeric_limits<double>::quiet_NaN()))); - builtin->registerBuiltin("Infinity","",_MR(abstract_d(numeric_limits<double>::infinity()))); - builtin->registerBuiltin("String","",Class<ASString>::getRef()); - builtin->registerBuiltin("Array","",Class<Array>::getRef()); - builtin->registerBuiltin("Function","",Class<IFunction>::getRef()); - builtin->registerBuiltin("undefined","",_MR(getSys()->getUndefinedRef())); - builtin->registerBuiltin("Math","",Class<Math>::getRef()); - builtin->registerBuiltin("Namespace","",Class<Namespace>::getRef()); - builtin->registerBuiltin("AS3","",_MR(Class<Namespace>::getInstanceS(AS3))); - builtin->registerBuiltin("Date","",Class<Date>::getRef()); - builtin->registerBuiltin("JSON","",Class<JSON>::getRef()); - builtin->registerBuiltin("RegExp","",Class<RegExp>::getRef()); - builtin->registerBuiltin("QName","",Class<ASQName>::getRef()); - builtin->registerBuiltin("uint","",Class<UInteger>::getRef()); - builtin->registerBuiltin("Vector","__AS3__.vec",_MR(Template<Vector>::getTemplate())); - builtin->registerBuiltin("Error","",Class<ASError>::getRef()); - builtin->registerBuiltin("SecurityError","",Class<SecurityError>::getRef()); - builtin->registerBuiltin("ArgumentError","",Class<ArgumentError>::getRef()); - builtin->registerBuiltin("DefinitionError","",Class<DefinitionError>::getRef()); - builtin->registerBuiltin("EvalError","",Class<EvalError>::getRef()); - builtin->registerBuiltin("RangeError","",Class<RangeError>::getRef()); - builtin->registerBuiltin("ReferenceError","",Class<ReferenceError>::getRef()); - builtin->registerBuiltin("SyntaxError","",Class<SyntaxError>::getRef()); - builtin->registerBuiltin("TypeError","",Class<TypeError>::getRef()); - builtin->registerBuiltin("URIError","",Class<URIError>::getRef()); - builtin->registerBuiltin("UninitializedError","",Class<UninitializedError>::getRef()); - builtin->registerBuiltin("VerifyError","",Class<VerifyError>::getRef()); - builtin->registerBuiltin("XML","",Class<XML>::getRef()); - builtin->registerBuiltin("XMLList","",Class<XMLList>::getRef()); - builtin->registerBuiltin("int","",Class<Integer>::getRef()); - - builtin->registerBuiltin("eval","",_MR(Class<IFunction>::getFunction(eval))); - builtin->registerBuiltin("print","",_MR(Class<IFunction>::getFunction(print))); - builtin->registerBuiltin("trace","",_MR(Class<IFunction>::getFunction(trace))); - builtin->registerBuiltin("parseInt","",_MR(Class<IFunction>::getFunction(parseInt,2))); - builtin->registerBuiltin("parseFloat","",_MR(Class<IFunction>::getFunction(parseFloat,1))); - builtin->registerBuiltin("encodeURI","",_MR(Class<IFunction>::getFunction(encodeURI))); - builtin->registerBuiltin("decodeURI","",_MR(Class<IFunction>::getFunction(decodeURI))); - builtin->registerBuiltin("encodeURIComponent","",_MR(Class<IFunction>::getFunction(encodeURIComponent))); - builtin->registerBuiltin("decodeURIComponent","",_MR(Class<IFunction>::getFunction(decodeURIComponent))); - builtin->registerBuiltin("escape","",_MR(Class<IFunction>::getFunction(escape,1))); - builtin->registerBuiltin("unescape","",_MR(Class<IFunction>::getFunction(unescape,1))); - builtin->registerBuiltin("toString","",_MR(Class<IFunction>::getFunction(ASObject::_toString))); - - builtin->registerBuiltin("AccessibilityProperties","flash.accessibility",Class<AccessibilityProperties>::getRef()); - builtin->registerBuiltin("AccessibilityImplementation","flash.accessibility",Class<AccessibilityImplementation>::getRef()); - builtin->registerBuiltin("Accessibility","flash.accessibility",Class<Accessibility>::getRef()); - - builtin->registerBuiltin("Mutex","flash.concurrent",Class<ASMutex>::getRef()); - builtin->registerBuiltin("Condition","flash.concurrent",Class<ASCondition>::getRef()); - - builtin->registerBuiltin("MovieClip","flash.display",Class<MovieClip>::getRef()); - builtin->registerBuiltin("DisplayObject","flash.display",Class<DisplayObject>::getRef()); - builtin->registerBuiltin("Loader","flash.display",Class<Loader>::getRef()); - builtin->registerBuiltin("LoaderInfo","flash.display",Class<LoaderInfo>::getRef()); - builtin->registerBuiltin("SimpleButton","flash.display",Class<SimpleButton>::getRef()); - builtin->registerBuiltin("InteractiveObject","flash.display",Class<InteractiveObject>::getRef()); - builtin->registerBuiltin("DisplayObjectContainer","flash.display",Class<DisplayObjectContainer>::getRef()); - builtin->registerBuiltin("Sprite","flash.display",Class<Sprite>::getRef()); - builtin->registerBuiltin("Shape","flash.display",Class<Shape>::getRef()); - builtin->registerBuiltin("Stage","flash.display",Class<Stage>::getRef()); - builtin->registerBuiltin("Graphics","flash.display",Class<Graphics>::getRef()); - builtin->registerBuiltin("GraphicsBitmapFill","flash.display",Class<GraphicsBitmapFill>::getRef()); - builtin->registerBuiltin("GraphicsEndFill","flash.display",Class<GraphicsEndFill>::getRef()); - builtin->registerBuiltin("GraphicsGradientFill","flash.display",Class<GraphicsGradientFill>::getRef()); - builtin->registerBuiltin("GraphicsPath","flash.display",Class<GraphicsPath>::getRef()); - builtin->registerBuiltin("GraphicsPathCommand","flash.display",Class<GraphicsPathCommand>::getRef()); - builtin->registerBuiltin("GraphicsPathWinding","flash.display",Class<GraphicsPathWinding>::getRef()); - builtin->registerBuiltin("GraphicsShaderFill","flash.display",Class<GraphicsShaderFill>::getRef()); - builtin->registerBuiltin("GraphicsSolidFill","flash.display",Class<GraphicsSolidFill>::getRef()); - builtin->registerBuiltin("GraphicsStroke","flash.display",Class<GraphicsStroke>::getRef()); - builtin->registerBuiltin("GraphicsTrianglePath","flash.display",Class<GraphicsTrianglePath>::getRef()); - builtin->registerBuiltin("IGraphicsData","flash.display",InterfaceClass<IGraphicsData>::getRef()); - builtin->registerBuiltin("IGraphicsFill","flash.display",InterfaceClass<IGraphicsFill>::getRef()); - builtin->registerBuiltin("IGraphicsPath","flash.display",InterfaceClass<IGraphicsPath>::getRef()); - builtin->registerBuiltin("IGraphicsStroke","flash.display",InterfaceClass<IGraphicsStroke>::getRef()); - builtin->registerBuiltin("GradientType","flash.display",Class<GradientType>::getRef()); - builtin->registerBuiltin("BlendMode","flash.display",Class<BlendMode>::getRef()); - builtin->registerBuiltin("LineScaleMode","flash.display",Class<LineScaleMode>::getRef()); - builtin->registerBuiltin("StageScaleMode","flash.display",Class<StageScaleMode>::getRef()); - builtin->registerBuiltin("StageAlign","flash.display",Class<StageAlign>::getRef()); - builtin->registerBuiltin("StageQuality","flash.display",Class<StageQuality>::getRef()); - builtin->registerBuiltin("StageDisplayState","flash.display",Class<StageDisplayState>::getRef()); - builtin->registerBuiltin("BitmapData","flash.display",Class<BitmapData>::getRef()); - builtin->registerBuiltin("Bitmap","flash.display",Class<Bitmap>::getRef()); - builtin->registerBuiltin("IBitmapDrawable","flash.display",InterfaceClass<IBitmapDrawable>::getRef()); - builtin->registerBuiltin("MorphShape","flash.display",Class<MorphShape>::getRef()); - builtin->registerBuiltin("SpreadMethod","flash.display",Class<SpreadMethod>::getRef()); - builtin->registerBuiltin("InterpolationMethod","flash.display",Class<InterpolationMethod>::getRef()); - builtin->registerBuiltin("FrameLabel","flash.display",Class<FrameLabel>::getRef()); - builtin->registerBuiltin("Scene","flash.display",Class<Scene>::getRef()); - builtin->registerBuiltin("AVM1Movie","flash.display",Class<AVM1Movie>::getRef()); - builtin->registerBuiltin("Shader","flash.display",Class<Shader>::getRef()); - builtin->registerBuiltin("BitmapDataChannel","flash.display",Class<BitmapDataChannel>::getRef()); - builtin->registerBuiltin("PixelSnapping","flash.display",Class<PixelSnapping>::getRef()); - - builtin->registerBuiltin("BitmapFilter","flash.filters",Class<BitmapFilter>::getRef()); - builtin->registerBuiltin("BitmapFilterQuality","flash.filters",Class<BitmapFilterQuality>::getRef()); - builtin->registerBuiltin("DropShadowFilter","flash.filters",Class<DropShadowFilter>::getRef()); - builtin->registerBuiltin("GlowFilter","flash.filters",Class<GlowFilter>::getRef()); - builtin->registerBuiltin("GradientGlowFilter","flash.filters",Class<GradientGlowFilter>::getRef()); - builtin->registerBuiltin("BevelFilter","flash.filters",Class<BevelFilter>::getRef()); - builtin->registerBuiltin("ColorMatrixFilter","flash.filters",Class<ColorMatrixFilter>::getRef()); - builtin->registerBuiltin("BlurFilter","flash.filters",Class<BlurFilter>::getRef()); - builtin->registerBuiltin("ConvolutionFilter","flash.filters",Class<ConvolutionFilter>::getRef()); - builtin->registerBuiltin("DisplacementMapFilter","flash.filters",Class<DisplacementMapFilter>::getRef()); - builtin->registerBuiltin("GradientBevelFilter","flash.filters",Class<GradientBevelFilter>::getRef()); - builtin->registerBuiltin("ShaderFilter","flash.filters",Class<ShaderFilter>::getRef()); - - builtin->registerBuiltin("AntiAliasType","flash.text",Class<AntiAliasType>::getRef()); - builtin->registerBuiltin("Font","flash.text",Class<ASFont>::getRef()); - builtin->registerBuiltin("FontStyle","flash.text",Class<FontStyle>::getRef()); - builtin->registerBuiltin("FontType","flash.text",Class<FontType>::getRef()); - builtin->registerBuiltin("GridFitType","flash.text",Class<GridFitType>::getRef()); - builtin->registerBuiltin("StyleSheet","flash.text",Class<StyleSheet>::getRef()); - builtin->registerBuiltin("TextColorType","flash.text",Class<TextColorType>::getRef()); - builtin->registerBuiltin("TextDisplayMode","flash.text",Class<TextDisplayMode>::getRef()); - builtin->registerBuiltin("TextField","flash.text",Class<TextField>::getRef()); - builtin->registerBuiltin("TextFieldType","flash.text",Class<TextFieldType>::getRef()); - builtin->registerBuiltin("TextFieldAutoSize","flash.text",Class<TextFieldAutoSize>::getRef()); - builtin->registerBuiltin("TextFormat","flash.text",Class<TextFormat>::getRef()); - builtin->registerBuiltin("TextFormatAlign","flash.text",Class<TextFormatAlign>::getRef()); - builtin->registerBuiltin("TextLineMetrics","flash.text",Class<TextLineMetrics>::getRef()); - builtin->registerBuiltin("TextInteractionMode","flash.text",Class<TextInteractionMode>::getRef()); - builtin->registerBuiltin("StaticText","flash.text",Class<StaticText>::getRef()); - - builtin->registerBuiltin("ContentElement","flash.text.engine",Class<ContentElement>::getRef()); - builtin->registerBuiltin("ElementFormat","flash.text.engine",Class<ElementFormat>::getRef()); - builtin->registerBuiltin("FontDescription","flash.text.engine",Class<FontDescription>::getRef()); - builtin->registerBuiltin("FontMetrics","flash.text.engine",Class<FontMetrics>::getRef()); - builtin->registerBuiltin("FontLookup","flash.text.engine",Class<FontLookup>::getRef()); - builtin->registerBuiltin("FontPosture","flash.text.engine",Class<FontPosture>::getRef()); - builtin->registerBuiltin("FontWeight","flash.text.engine",Class<FontWeight>::getRef()); - builtin->registerBuiltin("Kerning","flash.text.engine",Class<Kerning>::getRef()); - builtin->registerBuiltin("LineJustification","flash.text.engine",Class<LineJustification>::getRef()); - builtin->registerBuiltin("TextBaseline","flash.text.engine",Class<TextBaseline>::getRef()); - builtin->registerBuiltin("TextBlock","flash.text.engine",Class<TextBlock>::getRef()); - builtin->registerBuiltin("TextElement","flash.text.engine",Class<TextElement>::getRef()); - builtin->registerBuiltin("TextLine","flash.text.engine",Class<TextLine>::getRef()); - builtin->registerBuiltin("TextLineValidity","flash.text.engine",Class<TextLineValidity>::getRef()); - builtin->registerBuiltin("TextJustifier","flash.text.engine",Class<TextJustifier>::getRef()); - builtin->registerBuiltin("SpaceJustifier","flash.text.engine",Class<SpaceJustifier>::getRef()); - builtin->registerBuiltin("EastAsianJustifier","flash.text.engine",Class<EastAsianJustifier>::getRef()); - - builtin->registerBuiltin("XMLDocument","flash.xml",Class<XMLDocument>::getRef()); - builtin->registerBuiltin("XMLNode","flash.xml",Class<XMLNode>::getRef()); - - builtin->registerBuiltin("ExternalInterface","flash.external",Class<ExternalInterface>::getRef()); - - builtin->registerBuiltin("Endian","flash.utils",Class<Endian>::getRef()); - builtin->registerBuiltin("ByteArray","flash.utils",Class<ByteArray>::getRef()); - builtin->registerBuiltin("CompressionAlgorithm","flash.utils",Class<CompressionAlgorithm>::getRef()); - builtin->registerBuiltin("Dictionary","flash.utils",Class<Dictionary>::getRef()); - builtin->registerBuiltin("Proxy","flash.utils",Class<Proxy>::getRef()); - builtin->registerBuiltin("Timer","flash.utils",Class<Timer>::getRef()); - builtin->registerBuiltin("getQualifiedClassName","flash.utils",_MR(Class<IFunction>::getFunction(getQualifiedClassName))); - builtin->registerBuiltin("getQualifiedSuperclassName","flash.utils",_MR(Class<IFunction>::getFunction(getQualifiedSuperclassName))); - builtin->registerBuiltin("getDefinitionByName","flash.utils",_MR(Class<IFunction>::getFunction(getDefinitionByName))); - builtin->registerBuiltin("getTimer","flash.utils",_MR(Class<IFunction>::getFunction(getTimer))); - builtin->registerBuiltin("setInterval","flash.utils",_MR(Class<IFunction>::getFunction(setInterval))); - builtin->registerBuiltin("setTimeout","flash.utils",_MR(Class<IFunction>::getFunction(setTimeout))); - builtin->registerBuiltin("clearInterval","flash.utils",_MR(Class<IFunction>::getFunction(clearInterval))); - builtin->registerBuiltin("clearTimeout","flash.utils",_MR(Class<IFunction>::getFunction(clearTimeout))); - builtin->registerBuiltin("describeType","flash.utils",_MR(Class<IFunction>::getFunction(describeType))); - builtin->registerBuiltin("escapeMultiByte","flash.utils",_MR(Class<IFunction>::getFunction(escapeMultiByte))); - builtin->registerBuiltin("unescapeMultiByte","flash.utils",_MR(Class<IFunction>::getFunction(unescapeMultiByte))); - builtin->registerBuiltin("IExternalizable","flash.utils",InterfaceClass<IExternalizable>::getRef()); - builtin->registerBuiltin("IDataInput","flash.utils",InterfaceClass<IDataInput>::getRef()); - builtin->registerBuiltin("IDataOutput","flash.utils",InterfaceClass<IDataOutput>::getRef()); - - builtin->registerBuiltin("ColorTransform","flash.geom",Class<ColorTransform>::getRef()); - builtin->registerBuiltin("Rectangle","flash.geom",Class<Rectangle>::getRef()); - builtin->registerBuiltin("Matrix","flash.geom",Class<Matrix>::getRef()); - builtin->registerBuiltin("Transform","flash.geom",Class<Transform>::getRef()); - builtin->registerBuiltin("Point","flash.geom",Class<Point>::getRef()); - builtin->registerBuiltin("Vector3D","flash.geom",Class<Vector3D>::getRef()); - builtin->registerBuiltin("Matrix3D","flash.geom",Class<Matrix3D>::getRef()); - builtin->registerBuiltin("PerspectiveProjection","flash.geom",Class<PerspectiveProjection>::getRef()); - - builtin->registerBuiltin("EventDispatcher","flash.events",Class<EventDispatcher>::getRef()); - builtin->registerBuiltin("Event","flash.events",Class<Event>::getRef()); - builtin->registerBuiltin("EventPhase","flash.events",Class<EventPhase>::getRef()); - builtin->registerBuiltin("MouseEvent","flash.events",Class<MouseEvent>::getRef()); - builtin->registerBuiltin("ProgressEvent","flash.events",Class<ProgressEvent>::getRef()); - builtin->registerBuiltin("TimerEvent","flash.events",Class<TimerEvent>::getRef()); - builtin->registerBuiltin("IOErrorEvent","flash.events",Class<IOErrorEvent>::getRef()); - builtin->registerBuiltin("ErrorEvent","flash.events",Class<ErrorEvent>::getRef()); - builtin->registerBuiltin("SecurityErrorEvent","flash.events",Class<SecurityErrorEvent>::getRef()); - builtin->registerBuiltin("AsyncErrorEvent","flash.events",Class<AsyncErrorEvent>::getRef()); - builtin->registerBuiltin("FullScreenEvent","flash.events",Class<FullScreenEvent>::getRef()); - builtin->registerBuiltin("TextEvent","flash.events",Class<TextEvent>::getRef()); - builtin->registerBuiltin("IEventDispatcher","flash.events",InterfaceClass<IEventDispatcher>::getRef()); - builtin->registerBuiltin("FocusEvent","flash.events",Class<FocusEvent>::getRef()); - builtin->registerBuiltin("NetStatusEvent","flash.events",Class<NetStatusEvent>::getRef()); - builtin->registerBuiltin("HTTPStatusEvent","flash.events",Class<HTTPStatusEvent>::getRef()); - builtin->registerBuiltin("KeyboardEvent","flash.events",Class<KeyboardEvent>::getRef()); - builtin->registerBuiltin("StatusEvent","flash.events",Class<StatusEvent>::getRef()); - builtin->registerBuiltin("DataEvent","flash.events",Class<DataEvent>::getRef()); - builtin->registerBuiltin("DRMErrorEvent","flash.events",Class<DRMErrorEvent>::getRef()); - builtin->registerBuiltin("DRMStatusEvent","flash.events",Class<DRMStatusEvent>::getRef()); - builtin->registerBuiltin("StageVideoEvent","flash.events",Class<StageVideoEvent>::getRef()); - builtin->registerBuiltin("StageVideoAvailabilityEvent","flash.events",Class<StageVideoAvailabilityEvent>::getRef()); - builtin->registerBuiltin("TouchEvent","flash.events",Class<TouchEvent>::getRef()); - builtin->registerBuiltin("GestureEvent","flash.events",Class<GestureEvent>::getRef()); - builtin->registerBuiltin("PressAndTapGestureEvent","flash.events",Class<PressAndTapGestureEvent>::getRef()); - builtin->registerBuiltin("TransformGestureEvent","flash.events",Class<TransformGestureEvent>::getRef()); - builtin->registerBuiltin("ContextMenuEvent","flash.events",Class<ContextMenuEvent>::getRef()); - builtin->registerBuiltin("UncaughtErrorEvent","flash.events",Class<UncaughtErrorEvent>::getRef()); - builtin->registerBuiltin("UncaughtErrorEvents","flash.events",Class<UncaughtErrorEvents>::getRef()); - builtin->registerBuiltin("VideoEvent","flash.events",Class<VideoEvent>::getRef()); - - builtin->registerBuiltin("navigateToURL","flash.net",_MR(Class<IFunction>::getFunction(navigateToURL))); - builtin->registerBuiltin("sendToURL","flash.net",_MR(Class<IFunction>::getFunction(sendToURL))); - builtin->registerBuiltin("LocalConnection","flash.net",Class<LocalConnection>::getRef()); - builtin->registerBuiltin("NetConnection","flash.net",Class<NetConnection>::getRef()); - builtin->registerBuiltin("NetGroup","flash.net",Class<NetGroup>::getRef()); - builtin->registerBuiltin("NetStream","flash.net",Class<NetStream>::getRef()); - builtin->registerBuiltin("NetStreamAppendBytesAction","flash.net",Class<NetStreamAppendBytesAction>::getRef()); - builtin->registerBuiltin("NetStreamInfo","flash.net",Class<NetStreamInfo>::getRef()); - builtin->registerBuiltin("NetStreamPlayOptions","flash.net",Class<NetStreamPlayOptions>::getRef()); - builtin->registerBuiltin("NetStreamPlayTransitions","flash.net",Class<NetStreamPlayTransitions>::getRef()); - builtin->registerBuiltin("URLLoader","flash.net",Class<URLLoader>::getRef()); - builtin->registerBuiltin("URLStream","flash.net",Class<URLStream>::getRef()); - builtin->registerBuiltin("URLLoaderDataFormat","flash.net",Class<URLLoaderDataFormat>::getRef()); - builtin->registerBuiltin("URLRequest","flash.net",Class<URLRequest>::getRef()); - builtin->registerBuiltin("URLRequestHeader","flash.net",Class<URLRequestHeader>::getRef()); - builtin->registerBuiltin("URLRequestMethod","flash.net",Class<URLRequestMethod>::getRef()); - builtin->registerBuiltin("URLVariables","flash.net",Class<URLVariables>::getRef()); - builtin->registerBuiltin("SharedObject","flash.net",Class<SharedObject>::getRef()); - builtin->registerBuiltin("SharedObjectFlushStatus","flash.net",Class<SharedObjectFlushStatus>::getRef()); - builtin->registerBuiltin("ObjectEncoding","flash.net",Class<ObjectEncoding>::getRef()); - builtin->registerBuiltin("Socket","flash.net",Class<ASSocket>::getRef()); - builtin->registerBuiltin("Responder","flash.net",Class<Responder>::getRef()); - builtin->registerBuiltin("XMLSocket","flash.net",Class<XMLSocket>::getRef()); - builtin->registerBuiltin("registerClassAlias","flash.net",_MR(Class<IFunction>::getFunction(registerClassAlias))); - builtin->registerBuiltin("getClassByAlias","flash.net",_MR(Class<IFunction>::getFunction(getClassByAlias))); - - builtin->registerBuiltin("DRMManager","flash.net.drm",Class<DRMManager>::getRef()); - - - builtin->registerBuiltin("fscommand","flash.system",_MR(Class<IFunction>::getFunction(fscommand))); - builtin->registerBuiltin("Capabilities","flash.system",Class<Capabilities>::getRef()); - builtin->registerBuiltin("Security","flash.system",Class<Security>::getRef()); - builtin->registerBuiltin("ApplicationDomain","flash.system",Class<ApplicationDomain>::getRef()); - builtin->registerBuiltin("SecurityDomain","flash.system",Class<SecurityDomain>::getRef()); - builtin->registerBuiltin("LoaderContext","flash.system",Class<LoaderContext>::getRef()); - builtin->registerBuiltin("System","flash.system",Class<System>::getRef()); - builtin->registerBuiltin("Worker","flash.system",Class<ASWorker>::getRef()); - builtin->registerBuiltin("ImageDecodingPolicy","flash.system",Class<ImageDecodingPolicy>::getRef()); + builtin->registerBuiltin("Object","",Class<ASObject>::getRef(m_sys)); + builtin->registerBuiltin("Class","",Class_object::getRef(m_sys)); + builtin->registerBuiltin("Number","",Class<Number>::getRef(m_sys)); + builtin->registerBuiltin("Boolean","",Class<Boolean>::getRef(m_sys)); + builtin->registerBuiltin("NaN","",_MR(abstract_d(m_sys,numeric_limits<double>::quiet_NaN()))); + builtin->registerBuiltin("Infinity","",_MR(abstract_d(m_sys,numeric_limits<double>::infinity()))); + builtin->registerBuiltin("String","",Class<ASString>::getRef(m_sys)); + builtin->registerBuiltin("Array","",Class<Array>::getRef(m_sys)); + builtin->registerBuiltin("Function","",Class<IFunction>::getRef(m_sys)); + builtin->registerBuiltin("undefined","",_MR(m_sys->getUndefinedRef())); + builtin->registerBuiltin("Math","",Class<Math>::getRef(m_sys)); + builtin->registerBuiltin("Namespace","",Class<Namespace>::getRef(m_sys)); + builtin->registerBuiltin("AS3","",_MR(Class<Namespace>::getInstanceS(m_sys,AS3))); + builtin->registerBuiltin("Date","",Class<Date>::getRef(m_sys)); + builtin->registerBuiltin("JSON","",Class<JSON>::getRef(m_sys)); + builtin->registerBuiltin("RegExp","",Class<RegExp>::getRef(m_sys)); + builtin->registerBuiltin("QName","",Class<ASQName>::getRef(m_sys)); + builtin->registerBuiltin("uint","",Class<UInteger>::getRef(m_sys)); + builtin->registerBuiltin("Vector","__AS3__.vec",_MR(Template<Vector>::getTemplate(m_sys))); + builtin->registerBuiltin("Error","",Class<ASError>::getRef(m_sys)); + builtin->registerBuiltin("SecurityError","",Class<SecurityError>::getRef(m_sys)); + builtin->registerBuiltin("ArgumentError","",Class<ArgumentError>::getRef(m_sys)); + builtin->registerBuiltin("DefinitionError","",Class<DefinitionError>::getRef(m_sys)); + builtin->registerBuiltin("EvalError","",Class<EvalError>::getRef(m_sys)); + builtin->registerBuiltin("RangeError","",Class<RangeError>::getRef(m_sys)); + builtin->registerBuiltin("ReferenceError","",Class<ReferenceError>::getRef(m_sys)); + builtin->registerBuiltin("SyntaxError","",Class<SyntaxError>::getRef(m_sys)); + builtin->registerBuiltin("TypeError","",Class<TypeError>::getRef(m_sys)); + builtin->registerBuiltin("URIError","",Class<URIError>::getRef(m_sys)); + builtin->registerBuiltin("UninitializedError","",Class<UninitializedError>::getRef(m_sys)); + builtin->registerBuiltin("VerifyError","",Class<VerifyError>::getRef(m_sys)); + builtin->registerBuiltin("XML","",Class<XML>::getRef(m_sys)); + builtin->registerBuiltin("XMLList","",Class<XMLList>::getRef(m_sys)); + builtin->registerBuiltin("int","",Class<Integer>::getRef(m_sys)); + + builtin->registerBuiltin("eval","",_MR(Class<IFunction>::getFunction(m_sys,eval))); + builtin->registerBuiltin("print","",_MR(Class<IFunction>::getFunction(m_sys,print))); + builtin->registerBuiltin("trace","",_MR(Class<IFunction>::getFunction(m_sys,trace))); + builtin->registerBuiltin("parseInt","",_MR(Class<IFunction>::getFunction(m_sys,parseInt,2))); + builtin->registerBuiltin("parseFloat","",_MR(Class<IFunction>::getFunction(m_sys,parseFloat,1))); + builtin->registerBuiltin("encodeURI","",_MR(Class<IFunction>::getFunction(m_sys,encodeURI))); + builtin->registerBuiltin("decodeURI","",_MR(Class<IFunction>::getFunction(m_sys,decodeURI))); + builtin->registerBuiltin("encodeURIComponent","",_MR(Class<IFunction>::getFunction(m_sys,encodeURIComponent))); + builtin->registerBuiltin("decodeURIComponent","",_MR(Class<IFunction>::getFunction(m_sys,decodeURIComponent))); + builtin->registerBuiltin("escape","",_MR(Class<IFunction>::getFunction(m_sys,escape,1))); + builtin->registerBuiltin("unescape","",_MR(Class<IFunction>::getFunction(m_sys,unescape,1))); + builtin->registerBuiltin("toString","",_MR(Class<IFunction>::getFunction(m_sys,ASObject::_toString))); + + builtin->registerBuiltin("AccessibilityProperties","flash.accessibility",Class<AccessibilityProperties>::getRef(m_sys)); + builtin->registerBuiltin("AccessibilityImplementation","flash.accessibility",Class<AccessibilityImplementation>::getRef(m_sys)); + builtin->registerBuiltin("Accessibility","flash.accessibility",Class<Accessibility>::getRef(m_sys)); + + builtin->registerBuiltin("Mutex","flash.concurrent",Class<ASMutex>::getRef(m_sys)); + builtin->registerBuiltin("Condition","flash.concurrent",Class<ASCondition>::getRef(m_sys)); + + builtin->registerBuiltin("MovieClip","flash.display",Class<MovieClip>::getRef(m_sys)); + builtin->registerBuiltin("DisplayObject","flash.display",Class<DisplayObject>::getRef(m_sys)); + builtin->registerBuiltin("Loader","flash.display",Class<Loader>::getRef(m_sys)); + builtin->registerBuiltin("LoaderInfo","flash.display",Class<LoaderInfo>::getRef(m_sys)); + builtin->registerBuiltin("SimpleButton","flash.display",Class<SimpleButton>::getRef(m_sys)); + builtin->registerBuiltin("InteractiveObject","flash.display",Class<InteractiveObject>::getRef(m_sys)); + builtin->registerBuiltin("DisplayObjectContainer","flash.display",Class<DisplayObjectContainer>::getRef(m_sys)); + builtin->registerBuiltin("Sprite","flash.display",Class<Sprite>::getRef(m_sys)); + builtin->registerBuiltin("Shape","flash.display",Class<Shape>::getRef(m_sys)); + builtin->registerBuiltin("Stage","flash.display",Class<Stage>::getRef(m_sys)); + builtin->registerBuiltin("Graphics","flash.display",Class<Graphics>::getRef(m_sys)); + builtin->registerBuiltin("GraphicsBitmapFill","flash.display",Class<GraphicsBitmapFill>::getRef(m_sys)); + builtin->registerBuiltin("GraphicsEndFill","flash.display",Class<GraphicsEndFill>::getRef(m_sys)); + builtin->registerBuiltin("GraphicsGradientFill","flash.display",Class<GraphicsGradientFill>::getRef(m_sys)); + builtin->registerBuiltin("GraphicsPath","flash.display",Class<GraphicsPath>::getRef(m_sys)); + builtin->registerBuiltin("GraphicsPathCommand","flash.display",Class<GraphicsPathCommand>::getRef(m_sys)); + builtin->registerBuiltin("GraphicsPathWinding","flash.display",Class<GraphicsPathWinding>::getRef(m_sys)); + builtin->registerBuiltin("GraphicsShaderFill","flash.display",Class<GraphicsShaderFill>::getRef(m_sys)); + builtin->registerBuiltin("GraphicsSolidFill","flash.display",Class<GraphicsSolidFill>::getRef(m_sys)); + builtin->registerBuiltin("GraphicsStroke","flash.display",Class<GraphicsStroke>::getRef(m_sys)); + builtin->registerBuiltin("GraphicsTrianglePath","flash.display",Class<GraphicsTrianglePath>::getRef(m_sys)); + builtin->registerBuiltin("IGraphicsData","flash.display",InterfaceClass<IGraphicsData>::getRef(m_sys)); + builtin->registerBuiltin("IGraphicsFill","flash.display",InterfaceClass<IGraphicsFill>::getRef(m_sys)); + builtin->registerBuiltin("IGraphicsPath","flash.display",InterfaceClass<IGraphicsPath>::getRef(m_sys)); + builtin->registerBuiltin("IGraphicsStroke","flash.display",InterfaceClass<IGraphicsStroke>::getRef(m_sys)); + builtin->registerBuiltin("GradientType","flash.display",Class<GradientType>::getRef(m_sys)); + builtin->registerBuiltin("BlendMode","flash.display",Class<BlendMode>::getRef(m_sys)); + builtin->registerBuiltin("LineScaleMode","flash.display",Class<LineScaleMode>::getRef(m_sys)); + builtin->registerBuiltin("StageScaleMode","flash.display",Class<StageScaleMode>::getRef(m_sys)); + builtin->registerBuiltin("StageAlign","flash.display",Class<StageAlign>::getRef(m_sys)); + builtin->registerBuiltin("StageQuality","flash.display",Class<StageQuality>::getRef(m_sys)); + builtin->registerBuiltin("StageDisplayState","flash.display",Class<StageDisplayState>::getRef(m_sys)); + builtin->registerBuiltin("BitmapData","flash.display",Class<BitmapData>::getRef(m_sys)); + builtin->registerBuiltin("Bitmap","flash.display",Class<Bitmap>::getRef(m_sys)); + builtin->registerBuiltin("IBitmapDrawable","flash.display",InterfaceClass<IBitmapDrawable>::getRef(m_sys)); + builtin->registerBuiltin("MorphShape","flash.display",Class<MorphShape>::getRef(m_sys)); + builtin->registerBuiltin("SpreadMethod","flash.display",Class<SpreadMethod>::getRef(m_sys)); + builtin->registerBuiltin("InterpolationMethod","flash.display",Class<InterpolationMethod>::getRef(m_sys)); + builtin->registerBuiltin("FrameLabel","flash.display",Class<FrameLabel>::getRef(m_sys)); + builtin->registerBuiltin("Scene","flash.display",Class<Scene>::getRef(m_sys)); + builtin->registerBuiltin("AVM1Movie","flash.display",Class<AVM1Movie>::getRef(m_sys)); + builtin->registerBuiltin("Shader","flash.display",Class<Shader>::getRef(m_sys)); + builtin->registerBuiltin("BitmapDataChannel","flash.display",Class<BitmapDataChannel>::getRef(m_sys)); + builtin->registerBuiltin("PixelSnapping","flash.display",Class<PixelSnapping>::getRef(m_sys)); + + builtin->registerBuiltin("BitmapFilter","flash.filters",Class<BitmapFilter>::getRef(m_sys)); + builtin->registerBuiltin("BitmapFilterQuality","flash.filters",Class<BitmapFilterQuality>::getRef(m_sys)); + builtin->registerBuiltin("DropShadowFilter","flash.filters",Class<DropShadowFilter>::getRef(m_sys)); + builtin->registerBuiltin("GlowFilter","flash.filters",Class<GlowFilter>::getRef(m_sys)); + builtin->registerBuiltin("GradientGlowFilter","flash.filters",Class<GradientGlowFilter>::getRef(m_sys)); + builtin->registerBuiltin("BevelFilter","flash.filters",Class<BevelFilter>::getRef(m_sys)); + builtin->registerBuiltin("ColorMatrixFilter","flash.filters",Class<ColorMatrixFilter>::getRef(m_sys)); + builtin->registerBuiltin("BlurFilter","flash.filters",Class<BlurFilter>::getRef(m_sys)); + builtin->registerBuiltin("ConvolutionFilter","flash.filters",Class<ConvolutionFilter>::getRef(m_sys)); + builtin->registerBuiltin("DisplacementMapFilter","flash.filters",Class<DisplacementMapFilter>::getRef(m_sys)); + builtin->registerBuiltin("GradientBevelFilter","flash.filters",Class<GradientBevelFilter>::getRef(m_sys)); + builtin->registerBuiltin("ShaderFilter","flash.filters",Class<ShaderFilter>::getRef(m_sys)); + + builtin->registerBuiltin("AntiAliasType","flash.text",Class<AntiAliasType>::getRef(m_sys)); + builtin->registerBuiltin("Font","flash.text",Class<ASFont>::getRef(m_sys)); + builtin->registerBuiltin("FontStyle","flash.text",Class<FontStyle>::getRef(m_sys)); + builtin->registerBuiltin("FontType","flash.text",Class<FontType>::getRef(m_sys)); + builtin->registerBuiltin("GridFitType","flash.text",Class<GridFitType>::getRef(m_sys)); + builtin->registerBuiltin("StyleSheet","flash.text",Class<StyleSheet>::getRef(m_sys)); + builtin->registerBuiltin("TextColorType","flash.text",Class<TextColorType>::getRef(m_sys)); + builtin->registerBuiltin("TextDisplayMode","flash.text",Class<TextDisplayMode>::getRef(m_sys)); + builtin->registerBuiltin("TextField","flash.text",Class<TextField>::getRef(m_sys)); + builtin->registerBuiltin("TextFieldType","flash.text",Class<TextFieldType>::getRef(m_sys)); + builtin->registerBuiltin("TextFieldAutoSize","flash.text",Class<TextFieldAutoSize>::getRef(m_sys)); + builtin->registerBuiltin("TextFormat","flash.text",Class<TextFormat>::getRef(m_sys)); + builtin->registerBuiltin("TextFormatAlign","flash.text",Class<TextFormatAlign>::getRef(m_sys)); + builtin->registerBuiltin("TextLineMetrics","flash.text",Class<TextLineMetrics>::getRef(m_sys)); + builtin->registerBuiltin("TextInteractionMode","flash.text",Class<TextInteractionMode>::getRef(m_sys)); + builtin->registerBuiltin("StaticText","flash.text",Class<StaticText>::getRef(m_sys)); + + builtin->registerBuiltin("ContentElement","flash.text.engine",Class<ContentElement>::getRef(m_sys)); + builtin->registerBuiltin("ElementFormat","flash.text.engine",Class<ElementFormat>::getRef(m_sys)); + builtin->registerBuiltin("FontDescription","flash.text.engine",Class<FontDescription>::getRef(m_sys)); + builtin->registerBuiltin("FontMetrics","flash.text.engine",Class<FontMetrics>::getRef(m_sys)); + builtin->registerBuiltin("FontLookup","flash.text.engine",Class<FontLookup>::getRef(m_sys)); + builtin->registerBuiltin("FontPosture","flash.text.engine",Class<FontPosture>::getRef(m_sys)); + builtin->registerBuiltin("FontWeight","flash.text.engine",Class<FontWeight>::getRef(m_sys)); + builtin->registerBuiltin("Kerning","flash.text.engine",Class<Kerning>::getRef(m_sys)); + builtin->registerBuiltin("LineJustification","flash.text.engine",Class<LineJustification>::getRef(m_sys)); + builtin->registerBuiltin("TextBaseline","flash.text.engine",Class<TextBaseline>::getRef(m_sys)); + builtin->registerBuiltin("TextBlock","flash.text.engine",Class<TextBlock>::getRef(m_sys)); + builtin->registerBuiltin("TextElement","flash.text.engine",Class<TextElement>::getRef(m_sys)); + builtin->registerBuiltin("TextLine","flash.text.engine",Class<TextLine>::getRef(m_sys)); + builtin->registerBuiltin("TextLineValidity","flash.text.engine",Class<TextLineValidity>::getRef(m_sys)); + builtin->registerBuiltin("TextJustifier","flash.text.engine",Class<TextJustifier>::getRef(m_sys)); + builtin->registerBuiltin("SpaceJustifier","flash.text.engine",Class<SpaceJustifier>::getRef(m_sys)); + builtin->registerBuiltin("EastAsianJustifier","flash.text.engine",Class<EastAsianJustifier>::getRef(m_sys)); + + builtin->registerBuiltin("XMLDocument","flash.xml",Class<XMLDocument>::getRef(m_sys)); + builtin->registerBuiltin("XMLNode","flash.xml",Class<XMLNode>::getRef(m_sys)); + + builtin->registerBuiltin("ExternalInterface","flash.external",Class<ExternalInterface>::getRef(m_sys)); + + builtin->registerBuiltin("Endian","flash.utils",Class<Endian>::getRef(m_sys)); + builtin->registerBuiltin("ByteArray","flash.utils",Class<ByteArray>::getRef(m_sys)); + builtin->registerBuiltin("CompressionAlgorithm","flash.utils",Class<CompressionAlgorithm>::getRef(m_sys)); + builtin->registerBuiltin("Dictionary","flash.utils",Class<Dictionary>::getRef(m_sys)); + builtin->registerBuiltin("Proxy","flash.utils",Class<Proxy>::getRef(m_sys)); + builtin->registerBuiltin("Timer","flash.utils",Class<Timer>::getRef(m_sys)); + builtin->registerBuiltin("getQualifiedClassName","flash.utils",_MR(Class<IFunction>::getFunction(m_sys,getQualifiedClassName))); + builtin->registerBuiltin("getQualifiedSuperclassName","flash.utils",_MR(Class<IFunction>::getFunction(m_sys,getQualifiedSuperclassName))); + builtin->registerBuiltin("getDefinitionByName","flash.utils",_MR(Class<IFunction>::getFunction(m_sys,getDefinitionByName))); + builtin->registerBuiltin("getTimer","flash.utils",_MR(Class<IFunction>::getFunction(m_sys,getTimer))); + builtin->registerBuiltin("setInterval","flash.utils",_MR(Class<IFunction>::getFunction(m_sys,setInterval))); + builtin->registerBuiltin("setTimeout","flash.utils",_MR(Class<IFunction>::getFunction(m_sys,setTimeout))); + builtin->registerBuiltin("clearInterval","flash.utils",_MR(Class<IFunction>::getFunction(m_sys,clearInterval))); + builtin->registerBuiltin("clearTimeout","flash.utils",_MR(Class<IFunction>::getFunction(m_sys,clearTimeout))); + builtin->registerBuiltin("describeType","flash.utils",_MR(Class<IFunction>::getFunction(m_sys,describeType))); + builtin->registerBuiltin("escapeMultiByte","flash.utils",_MR(Class<IFunction>::getFunction(m_sys,escapeMultiByte))); + builtin->registerBuiltin("unescapeMultiByte","flash.utils",_MR(Class<IFunction>::getFunction(m_sys,unescapeMultiByte))); + builtin->registerBuiltin("IExternalizable","flash.utils",InterfaceClass<IExternalizable>::getRef(m_sys)); + builtin->registerBuiltin("IDataInput","flash.utils",InterfaceClass<IDataInput>::getRef(m_sys)); + builtin->registerBuiltin("IDataOutput","flash.utils",InterfaceClass<IDataOutput>::getRef(m_sys)); + + builtin->registerBuiltin("ColorTransform","flash.geom",Class<ColorTransform>::getRef(m_sys)); + builtin->registerBuiltin("Rectangle","flash.geom",Class<Rectangle>::getRef(m_sys)); + builtin->registerBuiltin("Matrix","flash.geom",Class<Matrix>::getRef(m_sys)); + builtin->registerBuiltin("Transform","flash.geom",Class<Transform>::getRef(m_sys)); + builtin->registerBuiltin("Point","flash.geom",Class<Point>::getRef(m_sys)); + builtin->registerBuiltin("Vector3D","flash.geom",Class<Vector3D>::getRef(m_sys)); + builtin->registerBuiltin("Matrix3D","flash.geom",Class<Matrix3D>::getRef(m_sys)); + builtin->registerBuiltin("PerspectiveProjection","flash.geom",Class<PerspectiveProjection>::getRef(m_sys)); + + builtin->registerBuiltin("EventDispatcher","flash.events",Class<EventDispatcher>::getRef(m_sys)); + builtin->registerBuiltin("Event","flash.events",Class<Event>::getRef(m_sys)); + builtin->registerBuiltin("EventPhase","flash.events",Class<EventPhase>::getRef(m_sys)); + builtin->registerBuiltin("MouseEvent","flash.events",Class<MouseEvent>::getRef(m_sys)); + builtin->registerBuiltin("ProgressEvent","flash.events",Class<ProgressEvent>::getRef(m_sys)); + builtin->registerBuiltin("TimerEvent","flash.events",Class<TimerEvent>::getRef(m_sys)); + builtin->registerBuiltin("IOErrorEvent","flash.events",Class<IOErrorEvent>::getRef(m_sys)); + builtin->registerBuiltin("ErrorEvent","flash.events",Class<ErrorEvent>::getRef(m_sys)); + builtin->registerBuiltin("SecurityErrorEvent","flash.events",Class<SecurityErrorEvent>::getRef(m_sys)); + builtin->registerBuiltin("AsyncErrorEvent","flash.events",Class<AsyncErrorEvent>::getRef(m_sys)); + builtin->registerBuiltin("FullScreenEvent","flash.events",Class<FullScreenEvent>::getRef(m_sys)); + builtin->registerBuiltin("TextEvent","flash.events",Class<TextEvent>::getRef(m_sys)); + builtin->registerBuiltin("IEventDispatcher","flash.events",InterfaceClass<IEventDispatcher>::getRef(m_sys)); + builtin->registerBuiltin("FocusEvent","flash.events",Class<FocusEvent>::getRef(m_sys)); + builtin->registerBuiltin("NetStatusEvent","flash.events",Class<NetStatusEvent>::getRef(m_sys)); + builtin->registerBuiltin("HTTPStatusEvent","flash.events",Class<HTTPStatusEvent>::getRef(m_sys)); + builtin->registerBuiltin("KeyboardEvent","flash.events",Class<KeyboardEvent>::getRef(m_sys)); + builtin->registerBuiltin("StatusEvent","flash.events",Class<StatusEvent>::getRef(m_sys)); + builtin->registerBuiltin("DataEvent","flash.events",Class<DataEvent>::getRef(m_sys)); + builtin->registerBuiltin("DRMErrorEvent","flash.events",Class<DRMErrorEvent>::getRef(m_sys)); + builtin->registerBuiltin("DRMStatusEvent","flash.events",Class<DRMStatusEvent>::getRef(m_sys)); + builtin->registerBuiltin("StageVideoEvent","flash.events",Class<StageVideoEvent>::getRef(m_sys)); + builtin->registerBuiltin("StageVideoAvailabilityEvent","flash.events",Class<StageVideoAvailabilityEvent>::getRef(m_sys)); + builtin->registerBuiltin("TouchEvent","flash.events",Class<TouchEvent>::getRef(m_sys)); + builtin->registerBuiltin("GestureEvent","flash.events",Class<GestureEvent>::getRef(m_sys)); + builtin->registerBuiltin("PressAndTapGestureEvent","flash.events",Class<PressAndTapGestureEvent>::getRef(m_sys)); + builtin->registerBuiltin("TransformGestureEvent","flash.events",Class<TransformGestureEvent>::getRef(m_sys)); + builtin->registerBuiltin("ContextMenuEvent","flash.events",Class<ContextMenuEvent>::getRef(m_sys)); + builtin->registerBuiltin("UncaughtErrorEvent","flash.events",Class<UncaughtErrorEvent>::getRef(m_sys)); + builtin->registerBuiltin("UncaughtErrorEvents","flash.events",Class<UncaughtErrorEvents>::getRef(m_sys)); + builtin->registerBuiltin("VideoEvent","flash.events",Class<VideoEvent>::getRef(m_sys)); + + builtin->registerBuiltin("navigateToURL","flash.net",_MR(Class<IFunction>::getFunction(m_sys,navigateToURL))); + builtin->registerBuiltin("sendToURL","flash.net",_MR(Class<IFunction>::getFunction(m_sys,sendToURL))); + builtin->registerBuiltin("LocalConnection","flash.net",Class<LocalConnection>::getRef(m_sys)); + builtin->registerBuiltin("NetConnection","flash.net",Class<NetConnection>::getRef(m_sys)); + builtin->registerBuiltin("NetGroup","flash.net",Class<NetGroup>::getRef(m_sys)); + builtin->registerBuiltin("NetStream","flash.net",Class<NetStream>::getRef(m_sys)); + builtin->registerBuiltin("NetStreamAppendBytesAction","flash.net",Class<NetStreamAppendBytesAction>::getRef(m_sys)); + builtin->registerBuiltin("NetStreamInfo","flash.net",Class<NetStreamInfo>::getRef(m_sys)); + builtin->registerBuiltin("NetStreamPlayOptions","flash.net",Class<NetStreamPlayOptions>::getRef(m_sys)); + builtin->registerBuiltin("NetStreamPlayTransitions","flash.net",Class<NetStreamPlayTransitions>::getRef(m_sys)); + builtin->registerBuiltin("URLLoader","flash.net",Class<URLLoader>::getRef(m_sys)); + builtin->registerBuiltin("URLStream","flash.net",Class<URLStream>::getRef(m_sys)); + builtin->registerBuiltin("URLLoaderDataFormat","flash.net",Class<URLLoaderDataFormat>::getRef(m_sys)); + builtin->registerBuiltin("URLRequest","flash.net",Class<URLRequest>::getRef(m_sys)); + builtin->registerBuiltin("URLRequestHeader","flash.net",Class<URLRequestHeader>::getRef(m_sys)); + builtin->registerBuiltin("URLRequestMethod","flash.net",Class<URLRequestMethod>::getRef(m_sys)); + builtin->registerBuiltin("URLVariables","flash.net",Class<URLVariables>::getRef(m_sys)); + builtin->registerBuiltin("SharedObject","flash.net",Class<SharedObject>::getRef(m_sys)); + builtin->registerBuiltin("SharedObjectFlushStatus","flash.net",Class<SharedObjectFlushStatus>::getRef(m_sys)); + builtin->registerBuiltin("ObjectEncoding","flash.net",Class<ObjectEncoding>::getRef(m_sys)); + builtin->registerBuiltin("Socket","flash.net",Class<ASSocket>::getRef(m_sys)); + builtin->registerBuiltin("Responder","flash.net",Class<Responder>::getRef(m_sys)); + builtin->registerBuiltin("XMLSocket","flash.net",Class<XMLSocket>::getRef(m_sys)); + builtin->registerBuiltin("registerClassAlias","flash.net",_MR(Class<IFunction>::getFunction(m_sys,registerClassAlias))); + builtin->registerBuiltin("getClassByAlias","flash.net",_MR(Class<IFunction>::getFunction(m_sys,getClassByAlias))); + + builtin->registerBuiltin("DRMManager","flash.net.drm",Class<DRMManager>::getRef(m_sys)); + + + builtin->registerBuiltin("fscommand","flash.system",_MR(Class<IFunction>::getFunction(m_sys,fscommand))); + builtin->registerBuiltin("Capabilities","flash.system",Class<Capabilities>::getRef(m_sys)); + builtin->registerBuiltin("Security","flash.system",Class<Security>::getRef(m_sys)); + builtin->registerBuiltin("ApplicationDomain","flash.system",Class<ApplicationDomain>::getRef(m_sys)); + builtin->registerBuiltin("SecurityDomain","flash.system",Class<SecurityDomain>::getRef(m_sys)); + builtin->registerBuiltin("LoaderContext","flash.system",Class<LoaderContext>::getRef(m_sys)); + builtin->registerBuiltin("System","flash.system",Class<System>::getRef(m_sys)); + builtin->registerBuiltin("Worker","flash.system",Class<ASWorker>::getRef(m_sys)); + builtin->registerBuiltin("ImageDecodingPolicy","flash.system",Class<ImageDecodingPolicy>::getRef(m_sys)); - builtin->registerBuiltin("SoundTransform","flash.media",Class<SoundTransform>::getRef()); - builtin->registerBuiltin("Video","flash.media",Class<Video>::getRef()); - builtin->registerBuiltin("Sound","flash.media",Class<Sound>::getRef()); - builtin->registerBuiltin("SoundLoaderContext","flash.media",Class<SoundLoaderContext>::getRef()); - builtin->registerBuiltin("SoundChannel","flash.media",Class<SoundChannel>::getRef()); - builtin->registerBuiltin("StageVideo","flash.media",Class<StageVideo>::getRef()); - builtin->registerBuiltin("StageVideoAvailability","flash.media",Class<StageVideoAvailability>::getRef()); - builtin->registerBuiltin("VideoStatus","flash.media",Class<VideoStatus>::getRef()); - - builtin->registerBuiltin("Keyboard","flash.ui",Class<Keyboard>::getRef()); - builtin->registerBuiltin("KeyboardType","flash.ui",Class<KeyboardType>::getRef()); - builtin->registerBuiltin("KeyLocation","flash.ui",Class<KeyLocation>::getRef()); - builtin->registerBuiltin("ContextMenu","flash.ui",Class<ContextMenu>::getRef()); - builtin->registerBuiltin("ContextMenuItem","flash.ui",Class<ContextMenuItem>::getRef()); - builtin->registerBuiltin("ContextMenuBuiltInItems","flash.ui",Class<ContextMenuBuiltInItems>::getRef()); - builtin->registerBuiltin("Mouse","flash.ui",Class<Mouse>::getRef()); - builtin->registerBuiltin("Multitouch","flash.ui",Class<Multitouch>::getRef()); - - builtin->registerBuiltin("Accelerometer", "flash.sensors",Class<Accelerometer>::getRef()); - - builtin->registerBuiltin("IOError","flash.errors",Class<IOError>::getRef()); - builtin->registerBuiltin("EOFError","flash.errors",Class<EOFError>::getRef()); - builtin->registerBuiltin("IllegalOperationError","flash.errors",Class<IllegalOperationError>::getRef()); - builtin->registerBuiltin("InvalidSWFError","flash.errors",Class<InvalidSWFError>::getRef()); - builtin->registerBuiltin("MemoryError","flash.errors",Class<MemoryError>::getRef()); - builtin->registerBuiltin("ScriptTimeoutError","flash.errors",Class<ScriptTimeoutError>::getRef()); - builtin->registerBuiltin("StackOverflowError","flash.errors",Class<StackOverflowError>::getRef()); - - builtin->registerBuiltin("PrintJob","flash.printing",Class<PrintJob>::getRef()); - builtin->registerBuiltin("PrintJobOptions","flash.printing",Class<PrintJobOptions>::getRef()); - builtin->registerBuiltin("PrintJobOrientation","flash.printing",Class<PrintJobOrientation>::getRef()); - - builtin->registerBuiltin("isNaN","",_MR(Class<IFunction>::getFunction(isNaN,1))); - builtin->registerBuiltin("isFinite","",_MR(Class<IFunction>::getFunction(isFinite,1))); - builtin->registerBuiltin("isXMLName","",_MR(Class<IFunction>::getFunction(_isXMLName))); + builtin->registerBuiltin("SoundTransform","flash.media",Class<SoundTransform>::getRef(m_sys)); + builtin->registerBuiltin("Video","flash.media",Class<Video>::getRef(m_sys)); + builtin->registerBuiltin("Sound","flash.media",Class<Sound>::getRef(m_sys)); + builtin->registerBuiltin("SoundLoaderContext","flash.media",Class<SoundLoaderContext>::getRef(m_sys)); + builtin->registerBuiltin("SoundChannel","flash.media",Class<SoundChannel>::getRef(m_sys)); + builtin->registerBuiltin("StageVideo","flash.media",Class<StageVideo>::getRef(m_sys)); + builtin->registerBuiltin("StageVideoAvailability","flash.media",Class<StageVideoAvailability>::getRef(m_sys)); + builtin->registerBuiltin("VideoStatus","flash.media",Class<VideoStatus>::getRef(m_sys)); + + builtin->registerBuiltin("Keyboard","flash.ui",Class<Keyboard>::getRef(m_sys)); + builtin->registerBuiltin("KeyboardType","flash.ui",Class<KeyboardType>::getRef(m_sys)); + builtin->registerBuiltin("KeyLocation","flash.ui",Class<KeyLocation>::getRef(m_sys)); + builtin->registerBuiltin("ContextMenu","flash.ui",Class<ContextMenu>::getRef(m_sys)); + builtin->registerBuiltin("ContextMenuItem","flash.ui",Class<ContextMenuItem>::getRef(m_sys)); + builtin->registerBuiltin("ContextMenuBuiltInItems","flash.ui",Class<ContextMenuBuiltInItems>::getRef(m_sys)); + builtin->registerBuiltin("Mouse","flash.ui",Class<Mouse>::getRef(m_sys)); + builtin->registerBuiltin("Multitouch","flash.ui",Class<Multitouch>::getRef(m_sys)); + + builtin->registerBuiltin("Accelerometer", "flash.sensors",Class<Accelerometer>::getRef(m_sys)); + + builtin->registerBuiltin("IOError","flash.errors",Class<IOError>::getRef(m_sys)); + builtin->registerBuiltin("EOFError","flash.errors",Class<EOFError>::getRef(m_sys)); + builtin->registerBuiltin("IllegalOperationError","flash.errors",Class<IllegalOperationError>::getRef(m_sys)); + builtin->registerBuiltin("InvalidSWFError","flash.errors",Class<InvalidSWFError>::getRef(m_sys)); + builtin->registerBuiltin("MemoryError","flash.errors",Class<MemoryError>::getRef(m_sys)); + builtin->registerBuiltin("ScriptTimeoutError","flash.errors",Class<ScriptTimeoutError>::getRef(m_sys)); + builtin->registerBuiltin("StackOverflowError","flash.errors",Class<StackOverflowError>::getRef(m_sys)); + + builtin->registerBuiltin("PrintJob","flash.printing",Class<PrintJob>::getRef(m_sys)); + builtin->registerBuiltin("PrintJobOptions","flash.printing",Class<PrintJobOptions>::getRef(m_sys)); + builtin->registerBuiltin("PrintJobOrientation","flash.printing",Class<PrintJobOrientation>::getRef(m_sys)); + + builtin->registerBuiltin("isNaN","",_MR(Class<IFunction>::getFunction(m_sys,isNaN,1))); + builtin->registerBuiltin("isFinite","",_MR(Class<IFunction>::getFunction(m_sys,isFinite,1))); + builtin->registerBuiltin("isXMLName","",_MR(Class<IFunction>::getFunction(m_sys,_isXMLName))); //If needed add AIR definitions - if(getSys()->flashMode==SystemState::AIR) + if(m_sys->flashMode==SystemState::AIR) { - builtin->registerBuiltin("NativeApplication","flash.desktop",Class<NativeApplication>::getRef()); + builtin->registerBuiltin("NativeApplication","flash.desktop",Class<NativeApplication>::getRef(m_sys)); - builtin->registerBuiltin("InvokeEvent","flash.events",Class<InvokeEvent>::getRef()); + builtin->registerBuiltin("InvokeEvent","flash.events",Class<InvokeEvent>::getRef(m_sys)); - builtin->registerBuiltin("FileStream","flash.filesystem",Class<FileStream>::getRef()); + builtin->registerBuiltin("FileStream","flash.filesystem",Class<FileStream>::getRef(m_sys)); } // if needed add AVMPLUS definitions - if(getSys()->flashMode==SystemState::AVMPLUS) + if(m_sys->flashMode==SystemState::AVMPLUS) { - builtin->registerBuiltin("getQualifiedClassName","avmplus",_MR(Class<IFunction>::getFunction(getQualifiedClassName))); - builtin->registerBuiltin("getQualifiedSuperclassName","avmplus",_MR(Class<IFunction>::getFunction(getQualifiedSuperclassName))); - builtin->registerBuiltin("getTimer","",_MR(Class<IFunction>::getFunction(getTimer))); - builtin->registerBuiltin("FLASH10_FLAGS","avmplus",_MR(abstract_ui(0x7FF))); - builtin->registerBuiltin("describeType","avmplus",_MR(Class<IFunction>::getFunction(describeType))); - - builtin->registerBuiltin("System","avmplus",Class<avmplusSystem>::getRef()); - builtin->registerBuiltin("Domain","avmplus",Class<avmplusDomain>::getRef()); - builtin->registerBuiltin("File","avmplus",Class<avmplusFile>::getRef()); - - builtin->registerBuiltin("AbstractBase","avmshell",Class<ASObject>::getRef()); - builtin->registerBuiltin("AbstractRestrictedBase","avmshell",Class<ASObject>::getRef()); - builtin->registerBuiltin("NativeBase","avmshell",Class<ASObject>::getRef()); - builtin->registerBuiltin("NativeBaseAS3","avmshell",Class<ASObject>::getRef()); - builtin->registerBuiltin("NativeSubclassOfAbstractBase","avmshell",Class<ASObject>::getRef()); - builtin->registerBuiltin("NativeSubclassOfAbstractRestrictedBase","avmshell",Class<ASObject>::getRef()); - builtin->registerBuiltin("NativeSubclassOfRestrictedBase","avmshell",Class<ASObject>::getRef()); - builtin->registerBuiltin("RestrictedBase","avmshell",Class<ASObject>::getRef()); - builtin->registerBuiltin("SubclassOfAbstractBase","avmshell",Class<ASObject>::getRef()); - builtin->registerBuiltin("SubclassOfAbstractRestrictedBase","avmshell",Class<ASObject>::getRef()); - builtin->registerBuiltin("SubclassOfRestrictedBase","avmshell",Class<ASObject>::getRef()); + builtin->registerBuiltin("getQualifiedClassName","avmplus",_MR(Class<IFunction>::getFunction(m_sys,getQualifiedClassName))); + builtin->registerBuiltin("getQualifiedSuperclassName","avmplus",_MR(Class<IFunction>::getFunction(m_sys,getQualifiedSuperclassName))); + builtin->registerBuiltin("getTimer","",_MR(Class<IFunction>::getFunction(m_sys,getTimer))); + builtin->registerBuiltin("FLASH10_FLAGS","avmplus",_MR(abstract_ui(m_sys,0x7FF))); + builtin->registerBuiltin("describeType","avmplus",_MR(Class<IFunction>::getFunction(m_sys,describeType))); + + builtin->registerBuiltin("System","avmplus",Class<avmplusSystem>::getRef(m_sys)); + builtin->registerBuiltin("Domain","avmplus",Class<avmplusDomain>::getRef(m_sys)); + builtin->registerBuiltin("File","avmplus",Class<avmplusFile>::getRef(m_sys)); + + builtin->registerBuiltin("AbstractBase","avmshell",Class<ASObject>::getRef(m_sys)); + builtin->registerBuiltin("AbstractRestrictedBase","avmshell",Class<ASObject>::getRef(m_sys)); + builtin->registerBuiltin("NativeBase","avmshell",Class<ASObject>::getRef(m_sys)); + builtin->registerBuiltin("NativeBaseAS3","avmshell",Class<ASObject>::getRef(m_sys)); + builtin->registerBuiltin("NativeSubclassOfAbstractBase","avmshell",Class<ASObject>::getRef(m_sys)); + builtin->registerBuiltin("NativeSubclassOfAbstractRestrictedBase","avmshell",Class<ASObject>::getRef(m_sys)); + builtin->registerBuiltin("NativeSubclassOfRestrictedBase","avmshell",Class<ASObject>::getRef(m_sys)); + builtin->registerBuiltin("RestrictedBase","avmshell",Class<ASObject>::getRef(m_sys)); + builtin->registerBuiltin("SubclassOfAbstractBase","avmshell",Class<ASObject>::getRef(m_sys)); + builtin->registerBuiltin("SubclassOfAbstractRestrictedBase","avmshell",Class<ASObject>::getRef(m_sys)); + builtin->registerBuiltin("SubclassOfRestrictedBase","avmshell",Class<ASObject>::getRef(m_sys)); } - Class_object::getRef()->getClass()->prototype = _MNR(new_objectPrototype()); - Class_object::getRef()->getClass()->initStandardProps(); + Class_object::getRef(m_sys)->getClass(m_sys)->prototype = _MNR(new_objectPrototype(m_sys)); + Class_object::getRef(m_sys)->getClass(m_sys)->initStandardProps(); - getSys()->systemDomain->registerGlobalScope(builtin); + m_sys->systemDomain->registerGlobalScope(builtin); } -/* This function determines how many stack values are needed for - * resolving the multiname at index mi - */ -int ABCContext::getMultinameRTData(int mi) const -{ - if(mi==0) - return 0; - - const multiname_info* m=&constant_pool.multinames[mi]; - switch(m->kind) - { - case 0x07: //QName - case 0x0d: //QNameA - case 0x09: //Multiname - case 0x0e: //MultinameA - case 0x1d: //Templated name - return 0; - case 0x0f: //RTQName - case 0x10: //RTQNameA - case 0x1b: //MultinameL - case 0x1c: //MultinameLA - return 1; - case 0x11: //RTQNameL - case 0x12: //RTQNameLA - return 2; - default: - LOG(LOG_ERROR,_("getMultinameRTData not yet implemented for this kind ") << hex << m->kind); - throw UnsupportedException("kind not implemented for getMultinameRTData"); - } -} //Pre: we already know that n is not zero and that we are going to use an RT multiname from getMultinameRTData multiname* ABCContext::s_getMultiname_d(call_context* th, number_t rtd, int n) @@ -601,7 +572,7 @@ multiname_info* m=&th->context->constant_pool.multinames[n]; if(m->cached==NULL) { - m->cached=new (getVm()->vmDataMemory) multiname(getVm()->vmDataMemory); + m->cached=new (getVm(th->context->root->getSystemState())->vmDataMemory) multiname(getVm(th->context->root->getSystemState())->vmDataMemory); ret=m->cached; ret->isAttribute=m->isAttributeName(); switch(m->kind) @@ -653,7 +624,7 @@ multiname_info* m=&th->context->constant_pool.multinames[n]; if(m->cached==NULL) { - m->cached=new (getVm()->vmDataMemory) multiname(getVm()->vmDataMemory); + m->cached=new (getVm(th->context->root->getSystemState())->vmDataMemory) multiname(getVm(th->context->root->getSystemState())->vmDataMemory); ret=m->cached; ret->isAttribute=m->isAttributeName(); switch(m->kind) @@ -745,13 +716,13 @@ /* If this multiname is not cached, resolve its static parts */ if(m->cached==NULL) { - m->cached=new (getVm()->vmDataMemory) multiname(getVm()->vmDataMemory); + m->cached=new (getVm(root->getSystemState())->vmDataMemory) multiname(getVm(root->getSystemState())->vmDataMemory); ret=m->cached; if(midx==0) { - ret->name_s_id=getSys()->getUniqueStringId("any"); + ret->name_s_id=root->getSystemState()->getUniqueStringId("any"); ret->name_type=multiname::NAME_STRING; - ret->ns.emplace_back("",NAMESPACE); + ret->ns.emplace_back(root->getSystemState(),"",NAMESPACE); ret->isAttribute=false; return ret; } @@ -764,7 +735,7 @@ ret->ns.emplace_back(this, m->ns); if (m->name) { - ret->name_s_id=getSys()->getUniqueStringId(getString(m->name)); + ret->name_s_id=root->getSystemState()->getUniqueStringId(getString(m->name)); ret->name_type=multiname::NAME_STRING; } break; @@ -782,7 +753,7 @@ if (m->name) { - ret->name_s_id=getSys()->getUniqueStringId(getString(m->name)); + ret->name_s_id=root->getSystemState()->getUniqueStringId(getString(m->name)); ret->name_type=multiname::NAME_STRING; } break; @@ -803,7 +774,7 @@ case 0x10: //RTQNameA { ret->name_type=multiname::NAME_STRING; - ret->name_s_id=getSys()->getUniqueStringId(getString(m->name)); + ret->name_s_id=root->getSystemState()->getUniqueStringId(getString(m->name)); break; } case 0x11: //RTQNameL @@ -835,7 +806,7 @@ name += getString(p->name); } ret->ns.emplace_back(this, td->ns); - ret->name_s_id=getSys()->getUniqueStringId(name); + ret->name_s_id=root->getSystemState()->getUniqueStringId(name); ret->name_type=multiname::NAME_STRING; break; } @@ -873,11 +844,11 @@ ASQName *qname = n->as<ASQName>(); // don't overwrite any static parts if (!m->dynamic) - m->dynamic=new (getVm()->vmDataMemory) multiname(getVm()->vmDataMemory); + m->dynamic=new (getVm(root->getSystemState())->vmDataMemory) multiname(getVm(root->getSystemState())->vmDataMemory); ret=m->dynamic; ret->isAttribute=m->cached->isAttribute; ret->ns.clear(); - ret->ns.emplace_back(qname->getURI(),NAMESPACE); + ret->ns.emplace_back(n->getSystemState(),qname->getURI(),NAMESPACE); } else n->applyProxyProperty(*ret); @@ -889,10 +860,10 @@ case 0x10: //RTQNameA { assert(n && !n2); - assert_and_throw(n->classdef==Class<Namespace>::getClass()); + assert_and_throw(n->classdef==Class<Namespace>::getClass(n->getSystemState())); Namespace* tmpns=static_cast<Namespace*>(n); ret->ns.clear(); - ret->ns.emplace_back(tmpns->uri,tmpns->nskind); + ret->ns.emplace_back(n->getSystemState(),tmpns->uri,tmpns->nskind); n->decRef(); break; } @@ -900,10 +871,10 @@ case 0x12: //RTQNameLA { assert(n && n2); - assert_and_throw(n2->classdef==Class<Namespace>::getClass()); + assert_and_throw(n2->classdef==Class<Namespace>::getClass(n->getSystemState())); Namespace* tmpns=static_cast<Namespace*>(n2); ret->ns.clear(); - ret->ns.emplace_back(tmpns->uri,tmpns->nskind); + ret->ns.emplace_back(n->getSystemState(),tmpns->uri,tmpns->nskind); ret->setName(n); n->decRef(); n2->decRef(); @@ -994,7 +965,7 @@ hasRunScriptInit.resize(scripts.size(),false); #ifdef PROFILING_SUPPORT - getSys()->contextes.push_back(this); + root->getSystemState()->contextes.push_back(this); #endif } @@ -1109,7 +1080,7 @@ bool doTarget = true; //capture phase - if(dispatcher->classdef->isSubClass(Class<DisplayObject>::getClass())) + if(dispatcher->classdef->isSubClass(Class<DisplayObject>::getClass(dispatcher->getSystemState()))) { event->eventPhase = EventPhase::CAPTURING_PHASE; dispatcher->incRef(); @@ -1273,7 +1244,7 @@ ExternalCallEvent* ev=static_cast<ExternalCallEvent*>(e.second.getPtr()); try { - *(ev->result) = ev->f->call(getSys()->getNullRef(),ev->args,ev->numArgs); + *(ev->result) = ev->f->call(m_sys->getNullRef(),ev->args,ev->numArgs); } catch(ASObject* exception) { @@ -1441,35 +1412,6 @@ throw UnsupportedException("Not implemented opcode"); } -void call_context::runtime_stack_clear() -{ - while(stack_index > 0) - stack[--stack_index]->decRef(); -} -void call_context::runtime_stack_push(ASObject* s) -{ - if(stack_index>=max_stack) - throwError<ASError>(kStackOverflowError); - stack[stack_index++]=s; -} -ASObject* call_context::runtime_stack_pop() -{ - if(stack_index==0) - throwError<ASError>(kStackUnderflowError); - - ASObject* ret=stack[--stack_index]; - return ret; -} -ASObject* call_context::runtime_stack_peek() -{ - if(stack_index==0) - { - LOG(LOG_ERROR,_("Empty stack")); - return NULL; - } - return stack[stack_index-1]; -} - call_context::~call_context() { //The stack may be not clean, is this a programmer/compiler error? @@ -1490,12 +1432,17 @@ } } +void call_context::handleError(int errorcode) +{ + throwError<ASError>(errorcode); +} + bool ABCContext::isinstance(ASObject* obj, multiname* name) { LOG(LOG_CALLS, _("isinstance ") << *name); //TODO: Should check against multiname index being 0, not the name! - if(name->qualifiedString() == "any") + if(name->qualifiedString(obj->getSystemState()) == "any") return true; ASObject* target; @@ -1513,7 +1460,7 @@ //Special case numeric types if(obj->getObjectType()==T_INTEGER || obj->getObjectType()==T_UINTEGER || obj->getObjectType()==T_NUMBER) { - real_ret=(c==Class<Integer>::getClass() || c==Class<Number>::getClass() || c==Class<UInteger>::getClass()); + real_ret=(c==Class<Integer>::getClass(obj->getSystemState()) || c==Class<Number>::getClass(obj->getSystemState()) || c==Class<UInteger>::getClass(obj->getSystemState())); LOG(LOG_CALLS,_("Numeric type is ") << ((real_ret)?"_(":")not _(") << ")subclass of " << c->class_name); return real_ret; } @@ -1547,7 +1494,7 @@ LOG(LOG_CALLS, _("Script N: ") << i ); //Creating a new global for this script - Global* global=Class<Global>::getInstanceS(this, i); + Global* global=Class<Global>::getInstanceS(root->getSystemState(),this, i); #ifndef NDEBUG global->initialized=false; #endif @@ -1568,7 +1515,7 @@ //The last script entry has to be run LOG(LOG_CALLS, _("Last script (Entry Point)")); //Creating a new global for the last script - Global* global=Class<Global>::getInstanceS(this, i); + Global* global=Class<Global>::getInstanceS(root->getSystemState(),this, i); #ifndef NDEBUG global->initialized=false; #endif @@ -1598,7 +1545,7 @@ hasRunScriptInit[i] = true; method_info* m=get_method(scripts[i].init); - SyntheticFunction* entry=Class<IFunction>::getSyntheticFunction(m); + SyntheticFunction* entry=Class<IFunction>::getSyntheticFunction(g->getSystemState(),m); g->incRef(); entry->addToScope(scope_entry(_MR(g),false)); @@ -1630,7 +1577,7 @@ { //Spin wait until the VM is aknowledged by the SystemState setTLSSys(th->m_sys); - while(getVm()!=th); + while(getVm(th->m_sys)!=th); /* set TLS variable for isVmThread() */ tls_set(&is_vm_thread, GINT_TO_POINTER(1)); @@ -1660,11 +1607,15 @@ llvm::EngineBuilder eb(th->module); #endif eb.setEngineKind(llvm::EngineKind::JIT); + std::string errStr; + eb.setErrorStr(&errStr); #ifdef LLVM_31 eb.setTargetOptions(Opts); #endif eb.setOptLevel(llvm::CodeGenOpt::Default); th->ex=eb.create(); + if (th->ex == NULL) + LOG(LOG_ERROR,"could not create llvm engine:"<<errStr); assert_and_throw(th->ex); #ifdef LLVM_36 @@ -1814,11 +1765,11 @@ //invoked on the client object multiname headerName(NULL); headerName.name_type=multiname::NAME_STRING; - headerName.ns.emplace_back("",NAMESPACE); + headerName.ns.emplace_back(m_sys,"",NAMESPACE); tiny_string headerNameString; if(!message->readUTF(headerNameString)) return; - headerName.name_s_id=getSys()->getUniqueStringId(headerNameString); + headerName.name_s_id=m_sys->getUniqueStringId(headerNameString); //Read the must understand flag uint8_t mustUnderstand; if(!message->readByte(mustUnderstand)) @@ -1880,8 +1831,8 @@ { multiname onResultName(NULL); onResultName.name_type=multiname::NAME_STRING; - onResultName.name_s_id=getSys()->getUniqueStringId("onResult"); - onResultName.ns.emplace_back("",NAMESPACE); + onResultName.name_s_id=m_sys->getUniqueStringId("onResult"); + onResultName.ns.emplace_back(m_sys,"",NAMESPACE); _NR<ASObject> callback = responder->getVariableByMultiname(onResultName); if(!callback.isNull() && callback->getObjectType() == T_FUNCTION) { @@ -1955,7 +1906,7 @@ throw ParseException("Interface trait has to be a NULL body"); variable* var=NULL; - var = c->borrowedVariables.findObjVar(nameId,nsNameAndKind("",NAMESPACE),NO_CREATE_TRAIT,DECLARED_TRAIT); + var = c->borrowedVariables.findObjVar(nameId,nsNameAndKind(c->getSystemState(),"",NAMESPACE),NO_CREATE_TRAIT,DECLARED_TRAIT); if(var && var->var) { assert_and_throw(var->var && var->var->getObjectType()==T_FUNCTION); @@ -1980,7 +1931,7 @@ throw ParseException("Interface trait has to be a NULL body"); variable* var=NULL; - var=c->borrowedVariables.findObjVar(nameId,nsNameAndKind("",NAMESPACE),NO_CREATE_TRAIT,DECLARED_TRAIT); + var=c->borrowedVariables.findObjVar(nameId,nsNameAndKind(c->getSystemState(),"",NAMESPACE),NO_CREATE_TRAIT,DECLARED_TRAIT); if(var && var->getter) { assert_and_throw(var->getter); @@ -2004,7 +1955,7 @@ throw ParseException("Interface trait has to be a NULL body"); variable* var=NULL; - var=c->borrowedVariables.findObjVar(nameId,nsNameAndKind("",NAMESPACE),NO_CREATE_TRAIT,DECLARED_TRAIT); + var=c->borrowedVariables.findObjVar(nameId,nsNameAndKind(c->getSystemState(),"",NAMESPACE),NO_CREATE_TRAIT,DECLARED_TRAIT); if(var && var->setter) { assert_and_throw(var->setter); @@ -2034,27 +1985,27 @@ switch(kind) { case 0x00: //Undefined - return getSys()->getUndefinedRef(); + return root->getSystemState()->getUndefinedRef(); case 0x01: //String - return abstract_s(constant_pool.strings[index]); + return abstract_s(root->getSystemState(),constant_pool.strings[index]); case 0x03: //Int - return abstract_i(constant_pool.integer[index]); + return abstract_i(root->getSystemState(),constant_pool.integer[index]); case 0x06: //Double - return abstract_d(constant_pool.doubles[index]); + return abstract_d(root->getSystemState(),constant_pool.doubles[index]); case 0x08: //Namespace { assert_and_throw(constant_pool.namespaces[index].name); - Namespace* ret = Class<Namespace>::getInstanceS(getString(constant_pool.namespaces[index].name)); + Namespace* ret = Class<Namespace>::getInstanceS(root->getSystemState(),getString(constant_pool.namespaces[index].name)); if (constant_pool.namespaces[index].kind != 0) ret->nskind =(NS_KIND)(int)(constant_pool.namespaces[index].kind); return ret; } case 0x0a: //False - return abstract_b(false); + return abstract_b(root->getSystemState(),false); case 0x0b: //True - return abstract_b(true); + return abstract_b(root->getSystemState(),true); case 0x0c: //Null - return getSys()->getNullRef(); + return root->getSystemState()->getNullRef(); default: { LOG(LOG_ERROR,_("Constant kind ") << hex << kind); @@ -2110,15 +2061,15 @@ return; ASObject* ret; - QName className(getSys()->getStringFromUniqueId(mname->name_s_id),mname->ns[0].getImpl().name); + QName className(obj->getSystemState()->getStringFromUniqueId(mname->name_s_id),mname->ns[0].getImpl(obj->getSystemState()).name); //check if this class has the 'interface' flag, i.e. it is an interface if((instances[t->classi].flags)&0x04) { - MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(className.name); - Class_inherit* ci=new (getSys()->unaccountedMemory) Class_inherit(className, memoryAccount); + MemoryAccount* memoryAccount = obj->getSystemState()->allocateMemoryAccount(className.name); + Class_inherit* ci=new (obj->getSystemState()->unaccountedMemory) Class_inherit(className, memoryAccount); ci->isInterface = true; - ci->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(Class_base::_toString),NORMAL_METHOD,false); + ci->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(obj->getSystemState(),Class_base::_toString),NORMAL_METHOD,false); LOG(LOG_CALLS,_("Building class traits")); for(unsigned int i=0;i<classes[t->classi].trait_count;i++) buildTrait(ci,&classes[t->classi].traits[i],false); @@ -2170,8 +2121,8 @@ } else { - MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(className.name); - Class_inherit* c=new (getSys()->unaccountedMemory) Class_inherit(className, memoryAccount); + MemoryAccount* memoryAccount = obj->getSystemState()->allocateMemoryAccount(className.name); + Class_inherit* c=new (obj->getSystemState()->unaccountedMemory) Class_inherit(className, memoryAccount); c->context = this; if(instances[t->classi].supername) @@ -2209,7 +2160,7 @@ else if(kind == traits_info::Method) LOG(LOG_CALLS,"Method trait: " << *mname << _(" #") << t->method); method_info* m=&methods[t->method]; - SyntheticFunction* f=Class<IFunction>::getSyntheticFunction(m); + SyntheticFunction* f=Class<IFunction>::getSyntheticFunction(obj->getSystemState(),m); #ifdef PROFILING_SUPPORT if(!m->validProfName) @@ -2260,7 +2211,7 @@ if(t->vindex) ret=getConstant(t->vkind,t->vindex); else - ret=getSys()->getUndefinedRef(); + ret=obj->getSystemState()->getUndefinedRef(); LOG(LOG_CALLS,_("Const ") << *mname <<_(" type ")<< *tname<< " = " << ret->toDebugString()); @@ -2303,7 +2254,7 @@ } default: LOG(LOG_ERROR,_("Trait not supported ") << *mname << _(" ") << t->kind); - obj->setVariableByMultiname(*mname, getSys()->getUndefinedRef(), ASObject::CONST_NOT_ALLOWED); + obj->setVariableByMultiname(*mname, obj->getSystemState()->getUndefinedRef(), ASObject::CONST_NOT_ALLOWED); } }
View file
lightspark.tar.xz/src/scripting/abc.h
Changed
@@ -103,7 +103,7 @@ SyntheticFunction::synt_function f; ABCContext* context; method_body_info* body; - SyntheticFunction::synt_function synt_method(); + SyntheticFunction::synt_function synt_method(SystemState* sys); bool needsArgs() { return info.needsArgs(); } bool needsActivation() { return info.needsActivation(); } bool needsRest() { return info.needsRest(); } @@ -204,7 +204,38 @@ void linkTrait(Class_base* obj, const traits_info* t); void getOptionalConstant(const option_detail& opt); - int getMultinameRTData(int n) const; + + /* This function determines how many stack values are needed for + * resolving the multiname at index mi + */ + inline int getMultinameRTData(int mi) const + { + if(mi==0) + return 0; + + const multiname_info* m=&constant_pool.multinames[mi]; + switch(m->kind) + { + case 0x07: //QName + case 0x0d: //QNameA + case 0x09: //Multiname + case 0x0e: //MultinameA + case 0x1d: //Templated name + return 0; + case 0x0f: //RTQName + case 0x10: //RTQNameA + case 0x1b: //MultinameL + case 0x1c: //MultinameLA + return 1; + case 0x11: //RTQNameL + case 0x12: //RTQNameLA + return 2; + default: + LOG(LOG_ERROR,_("getMultinameRTData not yet implemented for this kind ") << m->kind); + throw UnsupportedException("kind not implemented for getMultinameRTData"); + } + } + multiname* getMultiname(unsigned int m, call_context* th); multiname* getMultinameImpl(ASObject* rt1, ASObject* rt2, unsigned int m); void buildInstanceTraits(ASObject* obj, int class_index); @@ -248,7 +279,7 @@ arg1->decRef(); _R<ApplicationDomain> appDomain = getCurrentApplicationDomain(th); T ret=appDomain->readFromDomainMemory<T>(addr); - th->runtime_stack_push(abstract_i(ret)); + th->runtime_stack_push(abstract_i(arg1->getSystemState(),ret)); } template<class T> static void storeIntN(call_context* th) @@ -269,7 +300,7 @@ arg1->decRef(); _R<ApplicationDomain> appDomain = getCurrentApplicationDomain(th); number_t ret=appDomain->readFromDomainMemory<float>(addr); - th->runtime_stack_push(abstract_d(ret)); + th->runtime_stack_push(abstract_d(arg1->getSystemState(),ret)); } static void loadDouble(call_context* th) @@ -279,7 +310,7 @@ arg1->decRef(); _R<ApplicationDomain> appDomain = getCurrentApplicationDomain(th); number_t ret=appDomain->readFromDomainMemory<double>(addr); - th->runtime_stack_push(abstract_d(ret)); + th->runtime_stack_push(abstract_d(arg1->getSystemState(),ret)); } static void storeFloat(call_context* th) { @@ -597,9 +628,9 @@ ASObject* undefinedFunction(ASObject* obj,ASObject* const* args, const unsigned int argslen); -inline ABCVm* getVm() +inline ABCVm* getVm(SystemState* sys) { - return getSys()->currentVm; + return sys->currentVm; } std::istream& operator>>(std::istream& in, method_info& v);
View file
lightspark.tar.xz/src/scripting/abc_codesynt.cpp
Changed
@@ -226,10 +226,10 @@ {"add_od",(void*)&ABCVm::add_od,ARGS_OBJ_NUMBER}, {"nextName",(void*)&ABCVm::nextName,ARGS_OBJ_OBJ}, {"nextValue",(void*)&ABCVm::nextValue,ARGS_OBJ_OBJ}, - {"abstract_d",(void*)&abstract_d,ARGS_NUMBER}, - {"abstract_i",(void*)&abstract_i,ARGS_INT}, - {"abstract_ui",(void*)&abstract_ui,ARGS_INT}, - {"abstract_b",(void*)&abstract_b,ARGS_BOOL}, +// {"abstract_d",(void*)&abstract_d,ARGS_OBJ_NUMBER}, +// {"abstract_i",(void*)&abstract_i,ARGS_OBJ_INT}, +// {"abstract_ui",(void*)&abstract_ui,ARGS_OBJ_INT}, +// {"abstract_b",(void*)&abstract_b,ARGS_BOOL}, {"pushNaN",(void*)&ABCVm::pushNaN,ARGS_NONE}, {"pushNull",(void*)&ABCVm::pushNull,ARGS_NONE}, {"pushUndefined",(void*)&ABCVm::pushUndefined,ARGS_NONE}, @@ -300,13 +300,13 @@ ptr_type=ex->getTargetData()->getIntPtrType(llvm_context()); #endif //Pointer to 8 bit type, needed for pointer arithmetic - voidptr_type=llvm::IntegerType::get(getVm()->llvm_context(),8)->getPointerTo(); + voidptr_type=llvm::IntegerType::get(llvm_context(),8)->getPointerTo(); number_type=llvm::Type::getDoubleTy(llvm_context()); numberptr_type=llvm::Type::getDoublePtrTy(llvm_context()); bool_type=llvm::IntegerType::get(llvm_context(),1); boolptr_type=bool_type->getPointerTo(); void_type=llvm::Type::getVoidTy(llvm_context()); - int_type=llvm::IntegerType::get(getVm()->llvm_context(),32); + int_type=llvm::IntegerType::get(llvm_context(),32); intptr_type=int_type->getPointerTo(); //All the opcodes needs a pointer to the context @@ -575,7 +575,7 @@ { //decrement stack index llvm::Value* index=builder.CreateLoad(dynamic_stack_index); - llvm::Constant* constant = llvm::ConstantInt::get(llvm::IntegerType::get(getVm()->llvm_context(),32), 1); + llvm::Constant* constant = llvm::ConstantInt::get(llvm::IntegerType::get(getVm(getSys())->llvm_context(),32), 1); llvm::Value* index2=builder.CreateSub(index,constant); builder.CreateStore(index2,dynamic_stack_index); @@ -586,7 +586,7 @@ static llvm::Value* llvm_stack_peek(llvm::IRBuilder<>& builder,llvm::Value* dynamic_stack,llvm::Value* dynamic_stack_index) { llvm::Value* index=builder.CreateLoad(dynamic_stack_index); - llvm::Constant* constant = llvm::ConstantInt::get(llvm::IntegerType::get(getVm()->llvm_context(),32), 1); + llvm::Constant* constant = llvm::ConstantInt::get(llvm::IntegerType::get(getVm(getSys())->llvm_context(),32), 1); llvm::Value* index2=builder.CreateSub(index,constant); llvm::Value* dest=builder.CreateGEP(dynamic_stack,index2); return builder.CreateLoad(dest); @@ -600,7 +600,7 @@ builder.CreateStore(val,dest); //increment stack index - llvm::Constant* constant = llvm::ConstantInt::get(llvm::IntegerType::get(getVm()->llvm_context(),32), 1); + llvm::Constant* constant = llvm::ConstantInt::get(llvm::IntegerType::get(getVm(getSys())->llvm_context(),32), 1); llvm::Value* index2=builder.CreateAdd(index,constant); builder.CreateStore(index2,dynamic_stack_index); } @@ -714,7 +714,7 @@ //dest_block does not expect us to transfer locals, //so just write them to call_context->locals, overwriting (and decRef'ing) the old contents of call_context->locals assert(dest_block.locals_start[i] == STACK_NONE); - llvm::Value* constant = llvm::ConstantInt::get(llvm::IntegerType::get(getVm()->llvm_context(),32), i); + llvm::Value* constant = llvm::ConstantInt::get(llvm::IntegerType::get(getVm(getSys())->llvm_context(),32), i); llvm::Value* t=builder.CreateGEP(locals,constant); llvm::Value* old=builder.CreateLoad(t); if(static_locals[i].second==STACK_OBJECT) @@ -878,7 +878,7 @@ block_info::block_info(const method_info* mi, const char* blockName) { - BB=llvm::BasicBlock::Create(getVm()->llvm_context(), blockName, mi->llvmf); + BB=llvm::BasicBlock::Create(getVm(getSys())->llvm_context(), blockName, mi->llvmf); locals_start.resize(mi->body->local_count,STACK_NONE); locals_reset.resize(mi->body->local_count,false); locals_used.resize(mi->body->local_count,false); @@ -1852,7 +1852,7 @@ } } -SyntheticFunction::synt_function method_info::synt_method() +SyntheticFunction::synt_function method_info::synt_method(SystemState* sys) { if(f) return f; @@ -1864,10 +1864,10 @@ LOG(LOG_CALLS,_("Method ") << method_name << _(" should be intrinsic"));; return NULL; } - llvm::ExecutionEngine* ex=getVm()->ex; - llvm::LLVMContext& llvm_context=getVm()->llvm_context(); + llvm::ExecutionEngine* ex=getVm(sys)->ex; + llvm::LLVMContext& llvm_context=getVm(sys)->llvm_context(); llvm::FunctionType* method_type=synt_method_prototype(ex); - llvmf=llvm::Function::Create(method_type,llvm::Function::ExternalLinkage,method_name,getVm()->module); + llvmf=llvm::Function::Create(method_type,llvm::Function::ExternalLinkage,method_name,getVm(sys)->module); llvm::BasicBlock *BB = llvm::BasicBlock::Create(llvm_context,"entry", llvmf); llvm::IRBuilder<> Builder(llvm_context); @@ -1949,7 +1949,7 @@ for(unsigned i=0;i<paramTypes.size();++i) { - if(paramTypes[i] == Class<Number>::getClass()) + if(paramTypes[i] == Class<Number>::getClass(sys)) { /* yield t = locals[i+1] */ LOAD_LOCALPTR @@ -1961,7 +1961,7 @@ blocks[0].locals_start_obj[i+1] = t; LOG(LOG_TRACE,"found STACK_NUMBER parameter for local " << i+1); } - else if(paramTypes[i] == Class<Integer>::getClass()) + else if(paramTypes[i] == Class<Integer>::getClass(sys)) { /* yield t = locals[i+1] */ LOAD_LOCALPTR @@ -1972,7 +1972,7 @@ //locals_start_obj should hold the pointer to the local's value blocks[0].locals_start_obj[i+1] = t; } - else if(paramTypes[i] == Class<UInteger>::getClass()) + else if(paramTypes[i] == Class<UInteger>::getClass(sys)) { /* yield t = locals[i+1] */ LOAD_LOCALPTR @@ -1983,7 +1983,7 @@ //locals_start_obj should hold the pointer to the local's value blocks[0].locals_start_obj[i+1] = t; } - else if(paramTypes[i] == Class<Boolean>::getClass()) + else if(paramTypes[i] == Class<Boolean>::getClass(sys)) { /* yield t = locals[i+1] */ LOAD_LOCALPTR @@ -4656,7 +4656,7 @@ Builder.CreateCall(ex->FindFunctionNamed("not_impl"), constant); Builder.CreateRetVoid(); - f=(SyntheticFunction::synt_function)getVm()->ex->getPointerToFunction(llvmf); + f=(SyntheticFunction::synt_function)getVm(sys)->ex->getPointerToFunction(llvmf); return f; } } @@ -4672,8 +4672,8 @@ } //llvmf->dump(); //dump before optimization - getVm()->FPM->run(*llvmf); - f=(SyntheticFunction::synt_function)getVm()->ex->getPointerToFunction(llvmf); + getVm(sys)->FPM->run(*llvmf); + f=(SyntheticFunction::synt_function)getVm(sys)->ex->getPointerToFunction(llvmf); //llvmf->dump(); //dump after optimization body->codeStatus = method_body_info::JITTED; return f;
View file
lightspark.tar.xz/src/scripting/abc_fast_interpreter.cpp
Changed
@@ -128,7 +128,7 @@ instructionPointer+=4; assert_and_throw(context->locals[t]); context->locals[t]->decRef(); - context->locals[t]=getSys()->getUndefinedRef(); + context->locals[t]=function->getSystemState()->getUndefinedRef(); break; } case 0x0c: @@ -424,7 +424,7 @@ //pushbyte int8_t t=code[instructionPointer]; instructionPointer++; - context->runtime_stack_push(abstract_i(t)); + context->runtime_stack_push(abstract_i(function->getSystemState(),t)); pushByte(t); break; } @@ -435,20 +435,20 @@ // see https://bugs.adobe.com/jira/browse/ASC-4181 uint32_t t=data->uints[0]; instructionPointer+=4; - context->runtime_stack_push(abstract_i(t)); + context->runtime_stack_push(abstract_i(function->getSystemState(),t)); pushShort(t); break; } case 0x26: { //pushtrue - context->runtime_stack_push(abstract_b(pushTrue())); + context->runtime_stack_push(abstract_b(function->getSystemState(),pushTrue())); break; } case 0x27: { //pushfalse - context->runtime_stack_push(abstract_b(pushFalse())); + context->runtime_stack_push(abstract_b(function->getSystemState(),pushFalse())); break; } case 0x28: @@ -499,7 +499,7 @@ int32_t t=data->ints[0]; instructionPointer+=4; pushInt(context, t); - ASObject* i=abstract_i(t); + ASObject* i=abstract_i(function->getSystemState(),t); context->runtime_stack_push(i); break; } @@ -510,7 +510,7 @@ instructionPointer+=4; pushUInt(context, t); - ASObject* i=abstract_ui(t); + ASObject* i=abstract_ui(function->getSystemState(),t); context->runtime_stack_push(i); break; } @@ -521,7 +521,7 @@ instructionPointer+=8; pushDouble(context, t); - ASObject* d=abstract_d(t); + ASObject* d=abstract_d(function->getSystemState(),t); context->runtime_stack_push(d); break; } @@ -546,7 +546,7 @@ instructionPointer+=8; bool ret=hasNext2(context,t,t2); - context->runtime_stack_push(abstract_b(ret)); + context->runtime_stack_push(abstract_b(function->getSystemState(),ret)); break; } //Alchemy opcodes @@ -761,7 +761,7 @@ ASObject* arg1=context->runtime_stack_pop(); int32_t ret=arg1->toUInt() & 0x1; arg1->decRef(); - context->runtime_stack_push(abstract_i(ret)); + context->runtime_stack_push(abstract_i(function->getSystemState(),ret)); break; } case 0x51: @@ -771,7 +771,7 @@ ASObject* arg1=context->runtime_stack_pop(); int32_t ret=(int8_t)arg1->toUInt(); arg1->decRef(); - context->runtime_stack_push(abstract_i(ret)); + context->runtime_stack_push(abstract_i(function->getSystemState(),ret)); break; } case 0x52: @@ -781,7 +781,7 @@ ASObject* arg1=context->runtime_stack_pop(); int32_t ret=(int16_t)arg1->toUInt(); arg1->decRef(); - context->runtime_stack_push(abstract_i(ret)); + context->runtime_stack_push(abstract_i(function->getSystemState(),ret)); break; } case 0x53: @@ -859,7 +859,7 @@ instructionPointer+=4; multiname* name=context->context->getMultiname(t,context); LOG(LOG_NOT_IMPLEMENTED,"opcode 0x5f (finddef) not implemented:"<< *name); - context->runtime_stack_push(getSys()->getNullRef()); + context->runtime_stack_push(function->getSystemState()->getNullRef()); name->resetNameIfObject(); break; } @@ -894,7 +894,7 @@ if (!context->locals[i]) { LOG(LOG_CALLS, _("getLocal ") << i << " not set, pushing Undefined"); - context->runtime_stack_push(getSys()->getUndefinedRef()); + context->runtime_stack_push(function->getSystemState()->getUndefinedRef()); break; } context->locals[i]->incRef(); @@ -968,7 +968,7 @@ ASObject* obj=context->runtime_stack_pop(); bool ret = deleteProperty(obj,name); name->resetNameIfObject(); - context->runtime_stack_push(abstract_b(ret)); + context->runtime_stack_push(abstract_b(function->getSystemState(),ret)); break; } case 0x6c: @@ -1039,7 +1039,7 @@ if (val->is<Integer>()) context->runtime_stack_push(val); else - context->runtime_stack_push(abstract_i(convert_i(val))); + context->runtime_stack_push(abstract_i(function->getSystemState(),convert_i(val))); break; } case 0x74: @@ -1049,7 +1049,7 @@ if (val->is<UInteger>()) context->runtime_stack_push(val); else - context->runtime_stack_push(abstract_ui(convert_u(val))); + context->runtime_stack_push(abstract_ui(function->getSystemState(),convert_u(val))); break; } case 0x75: @@ -1059,7 +1059,7 @@ if (val->is<Number>()) context->runtime_stack_push(val); else - context->runtime_stack_push(abstract_d(convert_d(val))); + context->runtime_stack_push(abstract_d(function->getSystemState(),convert_d(val))); break; } case 0x76: @@ -1069,7 +1069,7 @@ if (val->is<Boolean>()) context->runtime_stack_push(val); else - context->runtime_stack_push(abstract_b(convert_b(val))); + context->runtime_stack_push(abstract_b(function->getSystemState(),convert_b(val))); break; } case 0x77: @@ -1160,7 +1160,7 @@ { //negate ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_d(negate(val)); + ASObject* ret=abstract_d(function->getSystemState(),negate(val)); context->runtime_stack_push(ret); break; } @@ -1168,7 +1168,7 @@ { //increment ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_d(increment(val)); + ASObject* ret=abstract_d(function->getSystemState(),increment(val)); context->runtime_stack_push(ret); break; } @@ -1184,7 +1184,7 @@ { //decrement ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_d(decrement(val)); + ASObject* ret=abstract_d(function->getSystemState(),decrement(val)); context->runtime_stack_push(ret); break; } @@ -1208,7 +1208,7 @@ { //not ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_b(_not(val)); + ASObject* ret=abstract_b(function->getSystemState(),_not(val)); context->runtime_stack_push(ret); break; } @@ -1216,7 +1216,7 @@ { //bitnot ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_i(bitNot(val)); + ASObject* ret=abstract_i(function->getSystemState(),bitNot(val)); context->runtime_stack_push(ret); break; } @@ -1237,7 +1237,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_d(subtract(v2, v1)); + ASObject* ret=abstract_d(function->getSystemState(),subtract(v2, v1)); context->runtime_stack_push(ret); break; } @@ -1247,7 +1247,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_d(multiply(v2, v1)); + ASObject* ret=abstract_d(function->getSystemState(),multiply(v2, v1)); context->runtime_stack_push(ret); break; } @@ -1257,7 +1257,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_d(divide(v2, v1)); + ASObject* ret=abstract_d(function->getSystemState(),divide(v2, v1)); context->runtime_stack_push(ret); break; } @@ -1267,7 +1267,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_d(modulo(v1, v2)); + ASObject* ret=abstract_d(function->getSystemState(),modulo(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1277,7 +1277,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_i(lShift(v1, v2)); + ASObject* ret=abstract_i(function->getSystemState(),lShift(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1287,7 +1287,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_i(rShift(v1, v2)); + ASObject* ret=abstract_i(function->getSystemState(),rShift(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1297,7 +1297,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_i(urShift(v1, v2)); + ASObject* ret=abstract_i(function->getSystemState(),urShift(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1307,7 +1307,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_i(bitAnd(v1, v2)); + ASObject* ret=abstract_i(function->getSystemState(),bitAnd(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1317,7 +1317,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_i(bitOr(v1, v2)); + ASObject* ret=abstract_i(function->getSystemState(),bitOr(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1327,7 +1327,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_i(bitXor(v1, v2)); + ASObject* ret=abstract_i(function->getSystemState(),bitXor(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1337,7 +1337,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(equals(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),equals(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1347,7 +1347,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(strictEquals(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),strictEquals(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1357,7 +1357,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(lessThan(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),lessThan(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1367,7 +1367,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(lessEquals(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),lessEquals(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1377,7 +1377,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(greaterThan(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),greaterThan(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1387,7 +1387,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(greaterEquals(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),greaterEquals(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1397,7 +1397,7 @@ ASObject* type=context->runtime_stack_pop(); ASObject* value=context->runtime_stack_pop(); bool ret=instanceOf(value, type); - context->runtime_stack_push(abstract_b(ret)); + context->runtime_stack_push(abstract_b(function->getSystemState(),ret)); break; } case 0xb2: @@ -1409,7 +1409,7 @@ ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(isType(context->context, v1, name)); + ASObject* ret=abstract_b(function->getSystemState(),isType(context->context, v1, name)); context->runtime_stack_push(ret); break; } @@ -1419,7 +1419,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_b(isTypelate(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),isTypelate(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1429,7 +1429,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_b(in(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),in(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1437,7 +1437,7 @@ { //increment_i ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_i(increment_i(val)); + ASObject* ret=abstract_i(function->getSystemState(),increment_i(val)); context->runtime_stack_push(ret); break; } @@ -1445,7 +1445,7 @@ { //decrement_i ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_i(decrement_i(val)); + ASObject* ret=abstract_i(function->getSystemState(),decrement_i(val)); context->runtime_stack_push(ret); break; } @@ -1469,7 +1469,7 @@ { //negate_i ASObject *val=context->runtime_stack_pop(); - ASObject* ret=abstract_i(negate_i(val)); + ASObject* ret=abstract_i(function->getSystemState(),negate_i(val)); context->runtime_stack_push(ret); break; } @@ -1479,7 +1479,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_i(add_i(v2, v1)); + ASObject* ret=abstract_i(function->getSystemState(),add_i(v2, v1)); context->runtime_stack_push(ret); break; } @@ -1489,7 +1489,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_i(subtract_i(v2, v1)); + ASObject* ret=abstract_i(function->getSystemState(),subtract_i(v2, v1)); context->runtime_stack_push(ret); break; } @@ -1499,7 +1499,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_i(multiply_i(v2, v1)); + ASObject* ret=abstract_i(function->getSystemState(),multiply_i(v2, v1)); context->runtime_stack_push(ret); break; } @@ -1513,7 +1513,7 @@ if (!context->locals[i]) { LOG(LOG_CALLS, _("getLocal ") << i << " not set, pushing Undefined"); - context->runtime_stack_push(getSys()->getUndefinedRef()); + context->runtime_stack_push(function->getSystemState()->getUndefinedRef()); break; } LOG(LOG_CALLS, "getLocal " << i << ": " << context->locals[i]->toDebugString() );
View file
lightspark.tar.xz/src/scripting/abc_interpreter.cpp
Changed
@@ -41,7 +41,7 @@ method_info* mi=function->mi; const int code_len=mi->body->code.size(); - memorystream code(mi->body->code.data(), code_len); + memorystream code(mi->body->code.data(), code_len,mi->body->codecache); //This may be non-zero and point to the position of an exception handler code.seekg(context->exec_pos); @@ -65,7 +65,7 @@ #ifdef PROFILING_SUPPORT uint32_t instructionPointer=code.tellg(); #endif - code >> opcode; + opcode = code.readbyte(); if(code.eof()) throw ParseException("End of code in interpreter"); @@ -93,24 +93,21 @@ case 0x04: { //getsuper - u30 t; - code >> t; + uint32_t t = code.readu30(); getSuper(context,t); break; } case 0x05: { //setsuper - u30 t; - code >> t; + uint32_t t = code.readu30(); setSuper(context,t); break; } case 0x06: { //dxns - u30 t; - code >> t; + uint32_t t = code.readu30(); dxns(context,t); break; } @@ -124,12 +121,11 @@ case 0x08: { //kill - u30 t; - code >> t; + uint32_t t = code.readu30(); LOG(LOG_CALLS, "kill " << t); assert_and_throw(context->locals[t]); context->locals[t]->decRef(); - context->locals[t]=getSys()->getUndefinedRef(); + context->locals[t]=function->getSystemState()->getUndefinedRef(); break; } case 0x09: @@ -140,8 +136,7 @@ case 0x0c: { //ifnlt - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); bool cond=ifNLT(v1, v2); @@ -160,8 +155,7 @@ case 0x0d: { //ifnle - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); bool cond=ifNLE(v1, v2); @@ -180,8 +174,7 @@ case 0x0e: { //ifngt - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); bool cond=ifNGT(v1, v2); @@ -200,8 +193,7 @@ case 0x0f: { //ifnge - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); bool cond=ifNGE(v1, v2); @@ -220,8 +212,7 @@ case 0x10: { //jump - s24 t; - code >> t; + int32_t t = code.reads24(); int here=code.tellg(); int dest=here+t; @@ -235,8 +226,7 @@ case 0x11: { //iftrue - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); bool cond=ifTrue(v1); @@ -255,8 +245,7 @@ case 0x12: { //iffalse - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); bool cond=ifFalse(v1); @@ -275,8 +264,7 @@ case 0x13: { //ifeq - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); @@ -296,8 +284,7 @@ case 0x14: { //ifne - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); @@ -317,8 +304,7 @@ case 0x15: { //iflt - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); @@ -338,8 +324,7 @@ case 0x16: { //ifle - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); @@ -359,8 +344,7 @@ case 0x17: { //ifgt - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); @@ -380,8 +364,7 @@ case 0x18: { //ifge - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); @@ -401,8 +384,7 @@ case 0x19: { //ifstricteq - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); @@ -422,8 +404,7 @@ case 0x1a: { //ifstrictne - s24 t; - code >> t; + int32_t t = code.reads24(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); @@ -444,16 +425,14 @@ { //lookupswitch int here=int(code.tellg())-1; //Base for the jumps is the instruction itself for the switch - s24 t; - code >> t; + int32_t t = code.reads24(); int defaultdest=here+t; LOG(LOG_CALLS,_("Switch default dest ") << defaultdest); - u30 count; - code >> count; - s24* offsets=g_newa(s24, count+1); + uint32_t count = code.readu30(); + int32_t* offsets=g_newa(int32_t, count+1); for(unsigned int i=0;i<count+1;i++) { - code >> offsets[i]; + offsets[i] = code.reads24(); LOG(LOG_CALLS,_("Switch dest ") << i << ' ' << offsets[i]); } @@ -515,7 +494,7 @@ { //pushbyte int8_t t = code.readbyte(); - context->runtime_stack_push(abstract_i(t)); + context->runtime_stack_push(abstract_i(function->getSystemState(),t)); pushByte(t); break; } @@ -524,22 +503,21 @@ //pushshort // specs say pushshort is a u30, but it's really a u32 // see https://bugs.adobe.com/jira/browse/ASC-4181 - u32 t; - code >> t; - context->runtime_stack_push(abstract_i(t)); + uint32_t t = code.readu32(); + context->runtime_stack_push(abstract_i(function->getSystemState(),t)); pushShort(t); break; } case 0x26: { //pushtrue - context->runtime_stack_push(abstract_b(pushTrue())); + context->runtime_stack_push(abstract_b(function->getSystemState(),pushTrue())); break; } case 0x27: { //pushfalse - context->runtime_stack_push(abstract_b(pushFalse())); + context->runtime_stack_push(abstract_b(function->getSystemState(),pushFalse())); break; } case 0x28: @@ -580,44 +558,40 @@ case 0x2c: { //pushstring - u30 t; - code >> t; + uint32_t t = code.readu30(); context->runtime_stack_push(pushString(context,t)); break; } case 0x2d: { //pushint - u30 t; - code >> t; + uint32_t t = code.readu30(); s32 val=context->context->constant_pool.integer[t]; pushInt(context, val); - ASObject* i=abstract_i(val); + ASObject* i=abstract_i(function->getSystemState(),val); context->runtime_stack_push(i); break; } case 0x2e: { //pushuint - u30 t; - code >> t; + uint32_t t = code.readu30(); u32 val=context->context->constant_pool.uinteger[t]; pushUInt(context, val); - ASObject* i=abstract_ui(val); + ASObject* i=abstract_ui(function->getSystemState(),val); context->runtime_stack_push(i); break; } case 0x2f: { //pushdouble - u30 t; - code >> t; + uint32_t t = code.readu30(); d64 val=context->context->constant_pool.doubles[t]; pushDouble(context, val); - ASObject* d=abstract_d(val); + ASObject* d=abstract_d(function->getSystemState(),val); context->runtime_stack_push(d); break; } @@ -630,20 +604,18 @@ case 0x31: { //pushnamespace - u30 t; - code >> t; + uint32_t t = code.readu30(); context->runtime_stack_push( pushNamespace(context, t) ); break; } case 0x32: { //hasnext2 - u30 t,t2; - code >> t; - code >> t2; + uint32_t t = code.readu30(); + uint32_t t2 = code.readu30(); bool ret=hasNext2(context,t,t2); - context->runtime_stack_push(abstract_b(ret)); + context->runtime_stack_push(abstract_b(function->getSystemState(),ret)); break; } //Alchemy opcodes @@ -720,16 +692,14 @@ case 0x40: { //newfunction - u30 t; - code >> t; + uint32_t t = code.readu30(); context->runtime_stack_push(newFunction(context,t)); break; } case 0x41: { //call - u30 t; - code >> t; + uint32_t t = code.readu30(); method_info* called_mi=NULL; PROF_ACCOUNT_TIME(mi->profTime[instructionPointer],profilingCheckpoint(startTime)); call(context,t,&called_mi); @@ -742,17 +712,15 @@ case 0x42: { //construct - u30 t; - code >> t; + uint32_t t = code.readu30(); construct(context,t); break; } case 0x44: { //callstatic - u30 t,t2; - code >> t; - code >> t2; + uint32_t t = code.readu30(); + uint32_t t2 = code.readu30(); method_info* called_mi=NULL; PROF_ACCOUNT_TIME(mi->profTime[instructionPointer],profilingCheckpoint(startTime)); callStatic(context,t,t2,&called_mi,true); @@ -765,9 +733,8 @@ case 0x45: { //callsuper - u30 t,t2; - code >> t; - code >> t2; + uint32_t t = code.readu30(); + uint32_t t2 = code.readu30(); method_info* called_mi=NULL; PROF_ACCOUNT_TIME(mi->profTime[instructionPointer],profilingCheckpoint(startTime)); callSuper(context,t,t2,&called_mi,true); @@ -781,9 +748,8 @@ case 0x4c: //callproplex seems to be exactly like callproperty { //callproperty - u30 t,t2; - code >> t; - code >> t2; + uint32_t t = code.readu30(); + uint32_t t2 = code.readu30(); method_info* called_mi=NULL; PROF_ACCOUNT_TIME(mi->profTime[instructionPointer],profilingCheckpoint(startTime)); callProperty(context,t,t2,&called_mi,true); @@ -811,26 +777,23 @@ case 0x49: { //constructsuper - u30 t; - code >> t; + uint32_t t = code.readu30(); constructSuper(context,t); break; } case 0x4a: { //constructprop - u30 t,t2; - code >> t; - code >> t2; + uint32_t t = code.readu30(); + uint32_t t2 = code.readu30(); constructProp(context,t,t2); break; } case 0x4e: { //callsupervoid - u30 t,t2; - code >> t; - code >> t2; + uint32_t t = code.readu30(); + uint32_t t2 = code.readu30(); method_info* called_mi=NULL; PROF_ACCOUNT_TIME(mi->profTime[instructionPointer],profilingCheckpoint(startTime)); callSuper(context,t,t2,&called_mi,false); @@ -843,9 +806,8 @@ case 0x4f: { //callpropvoid - u30 t,t2; - code >> t; - code >> t2; + uint32_t t = code.readu30(); + uint32_t t2 = code.readu30(); method_info* called_mi=NULL; PROF_ACCOUNT_TIME(mi->profTime[instructionPointer],profilingCheckpoint(startTime)); callProperty(context,t,t2,&called_mi,false); @@ -862,7 +824,7 @@ ASObject* arg1=context->runtime_stack_pop(); int32_t ret=arg1->toUInt() >>31; arg1->decRef(); - context->runtime_stack_push(abstract_i(ret)); + context->runtime_stack_push(abstract_i(function->getSystemState(),ret)); break; } case 0x51: @@ -872,7 +834,7 @@ ASObject* arg1=context->runtime_stack_pop(); int32_t ret=(int8_t)arg1->toUInt(); arg1->decRef(); - context->runtime_stack_push(abstract_i(ret)); + context->runtime_stack_push(abstract_i(function->getSystemState(),ret)); break; } case 0x52: @@ -882,30 +844,27 @@ ASObject* arg1=context->runtime_stack_pop(); int32_t ret=(int16_t)arg1->toUInt(); arg1->decRef(); - context->runtime_stack_push(abstract_i(ret)); + context->runtime_stack_push(abstract_i(function->getSystemState(),ret)); break; } case 0x53: { //constructgenerictype - u30 t; - code >> t; + uint32_t t = code.readu30(); constructGenericType(context, t); break; } case 0x55: { //newobject - u30 t; - code >> t; + uint32_t t = code.readu30(); newObject(context,t); break; } case 0x56: { //newarray - u30 t; - code >> t; + uint32_t t = code.readu30(); newArray(context,t); break; } @@ -918,32 +877,28 @@ case 0x58: { //newclass - u30 t; - code >> t; + uint32_t t = code.readu30(); newClass(context,t); break; } case 0x59: { //getdescendants - u30 t; - code >> t; + uint32_t t = code.readu30(); getDescendants(context, t); break; } case 0x5a: { //newcatch - u30 t; - code >> t; + uint32_t t = code.readu30(); context->runtime_stack_push(newCatch(context,t)); break; } case 0x5d: { //findpropstrict - u30 t; - code >> t; + uint32_t t = code.readu30(); multiname* name=context->context->getMultiname(t,context); context->runtime_stack_push(findPropStrict(context,name)); name->resetNameIfObject(); @@ -952,8 +907,7 @@ case 0x5e: { //findproperty - u30 t; - code >> t; + uint32_t t = code.readu30(); multiname* name=context->context->getMultiname(t,context); context->runtime_stack_push(findProperty(context,name)); name->resetNameIfObject(); @@ -962,27 +916,24 @@ case 0x5f: { //finddef - u30 t; - code >> t; + uint32_t t = code.readu30(); multiname* name=context->context->getMultiname(t,context); LOG(LOG_NOT_IMPLEMENTED,"opcode 0x5f (finddef) not implemented:"<<*name); - context->runtime_stack_push(getSys()->getNullRef()); + context->runtime_stack_push(function->getSystemState()->getNullRef()); name->resetNameIfObject(); break; } case 0x60: { //getlex - u30 t; - code >> t; + uint32_t t = code.readu30(); getLex(context,t); break; } case 0x61: { //setproperty - u30 t; - code >> t; + uint32_t t = code.readu30(); ASObject* value=context->runtime_stack_pop(); multiname* name=context->context->getMultiname(t,context); @@ -996,12 +947,11 @@ case 0x62: { //getlocal - u30 i; - code >> i; + uint32_t i = code.readu30(); if (!context->locals[i]) { LOG(LOG_CALLS, _("getLocal ") << i << " not set, pushing Undefined"); - context->runtime_stack_push(getSys()->getUndefinedRef()); + context->runtime_stack_push(function->getSystemState()->getUndefinedRef()); break; } context->locals[i]->incRef(); @@ -1012,8 +962,7 @@ case 0x63: { //setlocal - u30 i; - code >> i; + uint32_t i = code.readu30(); LOG(LOG_CALLS, _("setLocal ") << i ); ASObject* obj=context->runtime_stack_pop(); assert_and_throw(obj); @@ -1034,16 +983,14 @@ case 0x65: { //getscopeobject - u30 t; - code >> t; + uint32_t t = code.readu30(); context->runtime_stack_push(getScopeObject(context,t)); break; } case 0x66: { //getproperty - u30 t; - code >> t; + uint32_t t = code.readu30(); multiname* name=context->context->getMultiname(t,context); ASObject* obj=context->runtime_stack_pop(); @@ -1057,8 +1004,7 @@ case 0x68: { //initproperty - u30 t; - code >> t; + uint32_t t = code.readu30(); ASObject* value=context->runtime_stack_pop(); multiname* name=context->context->getMultiname(t,context); ASObject* obj=context->runtime_stack_pop(); @@ -1069,20 +1015,18 @@ case 0x6a: { //deleteproperty - u30 t; - code >> t; + uint32_t t = code.readu30(); multiname* name = context->context->getMultiname(t,context); ASObject* obj=context->runtime_stack_pop(); bool ret = deleteProperty(obj,name); name->resetNameIfObject(); - context->runtime_stack_push(abstract_b(ret)); + context->runtime_stack_push(abstract_b(function->getSystemState(),ret)); break; } case 0x6c: { //getslot - u30 t; - code >> t; + uint32_t t = code.readu30(); ASObject* obj=context->runtime_stack_pop(); ASObject* ret=getSlot(obj, t); context->runtime_stack_push(ret); @@ -1091,9 +1035,7 @@ case 0x6d: { //setslot - u30 t; - code >> t; - + uint32_t t = code.readu30(); ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); @@ -1103,8 +1045,7 @@ case 0x6e: { //getglobalSlot - u30 t; - code >> t; + uint32_t t = code.readu30(); Global* globalscope = getGlobalScope(context); context->runtime_stack_push(globalscope->getSlot(t)); @@ -1113,8 +1054,7 @@ case 0x6f: { //setglobalSlot - u30 t; - code >> t; + uint32_t t = code.readu30(); Global* globalscope = getGlobalScope(context); ASObject* obj=context->runtime_stack_pop(); @@ -1146,7 +1086,7 @@ if (val->is<Integer>()) context->runtime_stack_push(val); else - context->runtime_stack_push(abstract_i(convert_i(val))); + context->runtime_stack_push(abstract_i(function->getSystemState(),convert_i(val))); break; } case 0x74: @@ -1156,7 +1096,7 @@ if (val->is<UInteger>()) context->runtime_stack_push(val); else - context->runtime_stack_push(abstract_ui(convert_u(val))); + context->runtime_stack_push(abstract_ui(function->getSystemState(),convert_u(val))); break; } case 0x75: @@ -1166,7 +1106,7 @@ if (val->is<Number>()) context->runtime_stack_push(val); else - context->runtime_stack_push(abstract_d(convert_d(val))); + context->runtime_stack_push(abstract_d(function->getSystemState(),convert_d(val))); break; } case 0x76: @@ -1176,7 +1116,7 @@ if (val->is<Boolean>()) context->runtime_stack_push(val); else - context->runtime_stack_push(abstract_b(convert_b(val))); + context->runtime_stack_push(abstract_b(function->getSystemState(),convert_b(val))); break; } case 0x77: @@ -1207,8 +1147,7 @@ case 0x80: { //coerce - u30 t; - code >> t; + uint32_t t = code.readu30(); coerce(context, t); break; } @@ -1231,8 +1170,7 @@ case 0x86: { //astype - u30 t; - code >> t; + uint32_t t = code.readu30(); multiname* name=context->context->getMultiname(t,NULL); ASObject* v1=context->runtime_stack_pop(); @@ -1255,7 +1193,7 @@ { //negate ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_d(negate(val)); + ASObject* ret=abstract_d(function->getSystemState(),negate(val)); context->runtime_stack_push(ret); break; } @@ -1263,15 +1201,14 @@ { //increment ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_d(increment(val)); + ASObject* ret=abstract_d(function->getSystemState(),increment(val)); context->runtime_stack_push(ret); break; } case 0x92: { //inclocal - u30 t; - code >> t; + uint32_t t = code.readu30(); incLocal(context, t); break; } @@ -1279,15 +1216,14 @@ { //decrement ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_d(decrement(val)); + ASObject* ret=abstract_d(function->getSystemState(),decrement(val)); context->runtime_stack_push(ret); break; } case 0x94: { //declocal - u30 t; - code >> t; + uint32_t t = code.readu30(); decLocal(context, t); break; } @@ -1303,7 +1239,7 @@ { //not ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_b(_not(val)); + ASObject* ret=abstract_b(function->getSystemState(),_not(val)); context->runtime_stack_push(ret); break; } @@ -1311,7 +1247,7 @@ { //bitnot ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_i(bitNot(val)); + ASObject* ret=abstract_i(function->getSystemState(),bitNot(val)); context->runtime_stack_push(ret); break; } @@ -1332,7 +1268,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_d(subtract(v2, v1)); + ASObject* ret=abstract_d(function->getSystemState(),subtract(v2, v1)); context->runtime_stack_push(ret); break; } @@ -1342,7 +1278,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_d(multiply(v2, v1)); + ASObject* ret=abstract_d(function->getSystemState(),multiply(v2, v1)); context->runtime_stack_push(ret); break; } @@ -1352,7 +1288,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_d(divide(v2, v1)); + ASObject* ret=abstract_d(function->getSystemState(),divide(v2, v1)); context->runtime_stack_push(ret); break; } @@ -1362,7 +1298,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_d(modulo(v1, v2)); + ASObject* ret=abstract_d(function->getSystemState(),modulo(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1372,7 +1308,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_i(lShift(v1, v2)); + ASObject* ret=abstract_i(function->getSystemState(),lShift(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1382,7 +1318,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_i(rShift(v1, v2)); + ASObject* ret=abstract_i(function->getSystemState(),rShift(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1392,7 +1328,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_ui(urShift(v1, v2)); + ASObject* ret=abstract_ui(function->getSystemState(),urShift(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1402,7 +1338,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_i(bitAnd(v1, v2)); + ASObject* ret=abstract_i(function->getSystemState(),bitAnd(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1412,7 +1348,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_i(bitOr(v1, v2)); + ASObject* ret=abstract_i(function->getSystemState(),bitOr(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1422,7 +1358,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_i(bitXor(v1, v2)); + ASObject* ret=abstract_i(function->getSystemState(),bitXor(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1432,7 +1368,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(equals(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),equals(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1442,7 +1378,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(strictEquals(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),strictEquals(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1452,7 +1388,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(lessThan(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),lessThan(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1462,7 +1398,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(lessEquals(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),lessEquals(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1472,7 +1408,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(greaterThan(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),greaterThan(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1482,7 +1418,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(greaterEquals(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),greaterEquals(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1492,19 +1428,18 @@ ASObject* type=context->runtime_stack_pop(); ASObject* value=context->runtime_stack_pop(); bool ret=instanceOf(value, type); - context->runtime_stack_push(abstract_b(ret)); + context->runtime_stack_push(abstract_b(function->getSystemState(),ret)); break; } case 0xb2: { //istype - u30 t; - code >> t; + uint32_t t = code.readu30(); multiname* name=context->context->getMultiname(t,NULL); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_b(isType(context->context, v1, name)); + ASObject* ret=abstract_b(function->getSystemState(),isType(context->context, v1, name)); context->runtime_stack_push(ret); break; } @@ -1514,7 +1449,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_b(isTypelate(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),isTypelate(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1524,7 +1459,7 @@ ASObject* v1=context->runtime_stack_pop(); ASObject* v2=context->runtime_stack_pop(); - ASObject* ret=abstract_b(in(v1, v2)); + ASObject* ret=abstract_b(function->getSystemState(),in(v1, v2)); context->runtime_stack_push(ret); break; } @@ -1532,7 +1467,7 @@ { //increment_i ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_i(increment_i(val)); + ASObject* ret=abstract_i(function->getSystemState(),increment_i(val)); context->runtime_stack_push(ret); break; } @@ -1540,23 +1475,21 @@ { //decrement_i ASObject* val=context->runtime_stack_pop(); - ASObject* ret=abstract_i(decrement_i(val)); + ASObject* ret=abstract_i(function->getSystemState(),decrement_i(val)); context->runtime_stack_push(ret); break; } case 0xc2: { //inclocal_i - u30 t; - code >> t; + uint32_t t = code.readu30(); incLocal_i(context, t); break; } case 0xc3: { //declocal_i - u30 t; - code >> t; + uint32_t t = code.readu30(); decLocal_i(context, t); break; } @@ -1564,7 +1497,7 @@ { //negate_i ASObject *val=context->runtime_stack_pop(); - ASObject* ret=abstract_i(negate_i(val)); + ASObject* ret=abstract_i(function->getSystemState(),negate_i(val)); context->runtime_stack_push(ret); break; } @@ -1574,7 +1507,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_i(add_i(v2, v1)); + ASObject* ret=abstract_i(function->getSystemState(),add_i(v2, v1)); context->runtime_stack_push(ret); break; } @@ -1584,7 +1517,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_i(subtract_i(v2, v1)); + ASObject* ret=abstract_i(function->getSystemState(),subtract_i(v2, v1)); context->runtime_stack_push(ret); break; } @@ -1594,7 +1527,7 @@ ASObject* v2=context->runtime_stack_pop(); ASObject* v1=context->runtime_stack_pop(); - ASObject* ret=abstract_i(multiply_i(v2, v1)); + ASObject* ret=abstract_i(function->getSystemState(),multiply_i(v2, v1)); context->runtime_stack_push(ret); break; } @@ -1608,7 +1541,7 @@ if (!context->locals[i]) { LOG(LOG_CALLS, _("getLocal ") << i << " not set, pushing Undefined"); - context->runtime_stack_push(getSys()->getUndefinedRef()); + context->runtime_stack_push(function->getSystemState()->getUndefinedRef()); break; } LOG(LOG_CALLS, _("getLocal ") << i << _(": ") << context->locals[i]->toDebugString() ); @@ -1637,36 +1570,31 @@ { //debug LOG(LOG_CALLS, _("debug") ); - u30 index; - u30 extra; code.readbyte(); - code >> index; + code.readu30(); code.readbyte(); - code >> extra; + code.readu30(); break; } case 0xf0: { //debugline LOG(LOG_CALLS, _("debugline") ); - u30 t; - code >> t; + code.readu30(); break; } case 0xf1: { //debugfile LOG(LOG_CALLS, _("debugfile") ); - u30 t; - code >> t; + code.readu30(); break; } case 0xf2: { //bkptline LOG(LOG_CALLS, _("bkptline") ); - u30 t; - code >> t; + code.readu30(); break; } case 0xf3:
View file
lightspark.tar.xz/src/scripting/abc_opcodes.cpp
Changed
@@ -125,7 +125,7 @@ ASObject* ret=o; if(o->getObjectType()!=T_STRING) { - ret=abstract_s(o->toString()); + ret=abstract_s(o->getSystemState(),o->toString()); o->decRef(); } return ret; @@ -168,7 +168,7 @@ ASObject* ABCVm::coerce_s(ASObject* o) { - return Class<ASString>::getClass()->coerce(o); + return Class<ASString>::getClass(o->getSystemState())->coerce(o); } void ABCVm::coerce(call_context* th, int n) @@ -347,8 +347,8 @@ //Check if there is a custom caller defined, skipping implementation to avoid recursive calls multiname callPropertyName(NULL); callPropertyName.name_type=multiname::NAME_STRING; - callPropertyName.name_s_id=getSys()->getUniqueStringId("callProperty"); - callPropertyName.ns.emplace_back(flash_proxy,NAMESPACE); + callPropertyName.name_s_id=obj->getSystemState()->getUniqueStringId("callProperty"); + callPropertyName.ns.emplace_back(th->context->root->getSystemState(),flash_proxy,NAMESPACE); _NR<ASObject> oproxy=obj->getVariableByMultiname(callPropertyName,ASObject::SKIP_IMPL); if(!oproxy.isNull()) @@ -364,7 +364,7 @@ IFunction* f=static_cast<IFunction*>(oproxy.getPtr()); //Create a new array ASObject** proxyArgs=g_newa(ASObject*, m+1); - ASObject* namearg = abstract_s(name->normalizedName()); + ASObject* namearg = abstract_s(f->getSystemState(),name->normalizedName(f->getSystemState())); namearg->setProxyProperty(*name); proxyArgs[0]=namearg; for(int i=0;i<m;i++) @@ -404,30 +404,30 @@ { tiny_string clsname = obj->getClass()->getQualifiedClassName(); obj->decRef(); - throwError<ReferenceError>(kWriteOnlyError, name->normalizedName(), clsname); + throwError<ReferenceError>(kWriteOnlyError, name->normalizedName(th->context->root->getSystemState()), clsname); } if (obj->getClass() && obj->getClass()->isSealed) { tiny_string clsname = obj->getClass()->getQualifiedClassName(); obj->decRef(); - throwError<ReferenceError>(kReadSealedError, name->normalizedName(), clsname); + throwError<ReferenceError>(kReadSealedError, name->normalizedName(th->context->root->getSystemState()), clsname); } if (obj->is<Class_base>()) { tiny_string clsname = obj->as<Class_base>()->class_name.getQualifiedName(); obj->decRef(); - throwError<TypeError>(kCallNotFoundError, name->qualifiedString(), clsname); + throwError<TypeError>(kCallNotFoundError, name->qualifiedString(th->context->root->getSystemState()), clsname); } else { tiny_string clsname = obj->getClassName(); obj->decRef(); - throwError<TypeError>(kCallNotFoundError, name->qualifiedString(), clsname); + throwError<TypeError>(kCallNotFoundError, name->qualifiedString(th->context->root->getSystemState()), clsname); } obj->decRef(); if(keepReturn) - th->runtime_stack_push(getSys()->getUndefinedRef()); + th->runtime_stack_push(th->context->root->getSystemState()->getUndefinedRef()); } LOG(LOG_CALLS,_("End of calling ") << *name); @@ -441,7 +441,7 @@ !obj->is<Function_object>() && !obj->is<Class_base>() && obj->getClass() && - (obj->getClass() != Class_object::getClass())) + (obj->getClass() != Class_object::getClass(obj->getSystemState()))) obj->getClass()->setupDeclaredTraits(obj); } @@ -468,14 +468,14 @@ if(prop.isNull()) { if (obj->getClass() && obj->getClass()->isSealed) - throwError<ReferenceError>(kReadSealedError, name->normalizedNameUnresolved(), obj->getClass()->getQualifiedClassName()); + throwError<ReferenceError>(kReadSealedError, name->normalizedNameUnresolved(obj->getSystemState()), obj->getClass()->getQualifiedClassName()); if (name->isEmpty()) - throwError<ReferenceError>(kReadSealedErrorNs, name->normalizedNameUnresolved(), obj->getClassName()); + throwError<ReferenceError>(kReadSealedErrorNs, name->normalizedNameUnresolved(obj->getSystemState()), obj->getClassName()); if (obj->is<Undefined>()) throwError<TypeError>(kConvertUndefinedToObjectError); if (Log::getLevel() >= LOG_NOT_IMPLEMENTED && (!obj->getClass() || obj->getClass()->isSealed)) - LOG(LOG_NOT_IMPLEMENTED,"getProperty: " << name->normalizedNameUnresolved() << " not found on " << obj->toDebugString() << " "<<obj->getClassName()); - ret = getSys()->getUndefinedRef(); + LOG(LOG_NOT_IMPLEMENTED,"getProperty: " << name->normalizedNameUnresolved(obj->getSystemState()) << " not found on " << obj->toDebugString() << " "<<obj->getClassName()); + ret = obj->getSystemState()->getUndefinedRef(); } else { @@ -649,7 +649,7 @@ LOG(LOG_CALLS, _("incLocal ") << n ); number_t tmp=th->locals[n]->toNumber(); th->locals[n]->decRef(); - th->locals[n]=abstract_d(tmp+1); + th->locals[n]=abstract_d(th->locals[n]->getSystemState(),tmp+1); } void ABCVm::incLocal_i(call_context* th, int n) @@ -657,7 +657,7 @@ LOG(LOG_CALLS, _("incLocal_i ") << n ); int32_t tmp=th->locals[n]->toInt(); th->locals[n]->decRef(); - th->locals[n]=abstract_i(tmp+1); + th->locals[n]=abstract_i(th->locals[n]->getSystemState(),tmp+1); } void ABCVm::decLocal(call_context* th, int n) @@ -665,7 +665,7 @@ LOG(LOG_CALLS, _("decLocal ") << n ); number_t tmp=th->locals[n]->toNumber(); th->locals[n]->decRef(); - th->locals[n]=abstract_d(tmp-1); + th->locals[n]=abstract_d(th->locals[n]->getSystemState(),tmp-1); } void ABCVm::decLocal_i(call_context* th, int n) @@ -673,7 +673,7 @@ LOG(LOG_CALLS, _("decLocal_i ") << n ); int32_t tmp=th->locals[n]->toInt(); th->locals[n]->decRef(); - th->locals[n]=abstract_i(tmp-1); + th->locals[n]=abstract_i(th->locals[n]->getSystemState(),tmp-1); } /* This is called for expressions like @@ -787,7 +787,7 @@ { LOG(LOG_NOT_IMPLEMENTED, "constructGenericType of " << obj->getObjectType()); obj->decRef(); - obj = getSys()->getUndefinedRef(); + obj = obj->getSystemState()->getUndefinedRef(); th->runtime_stack_push(obj); for(int i=0;i<m;i++) args[i]->decRef(); @@ -806,7 +806,7 @@ else if(args[i]->is<Null>()) t[i] = Type::anyType; else - throw Class<TypeError>::getInstanceS("Wrong type in applytype"); + throw Class<TypeError>::getInstanceS(obj->getSystemState(),"Wrong type in applytype"); } Class_base* o_class = o_template->applyType(t,th->context->root->applicationDomain); @@ -818,7 +818,7 @@ if (!global->hasPropertyByMultiname(qname, false, false)) { o_class->incRef(); - global->setVariableByQName(qname.name,nsNameAndKind(qname.ns,NAMESPACE),o_class,DECLARED_TRAIT); + global->setVariableByQName(qname.name,nsNameAndKind(global->getSystemState(),qname.ns,NAMESPACE),o_class,DECLARED_TRAIT); } for(int i=0;i<m;++i) @@ -868,7 +868,7 @@ assert_and_throw(false); } obj->decRef(); - return abstract_s(ret); + return abstract_s(obj->getSystemState(),ret); } void ABCVm::jump(int offset) @@ -992,7 +992,7 @@ LOG(LOG_CALLS,"addN " << num1 << '+' << num2); val1->decRef(); val2->decRef(); - return abstract_d(num1+num2); + return abstract_d(val1->getSystemState(), num1+num2); } else if(val1->is<ASString>() || val2->is<ASString>()) { @@ -1001,14 +1001,14 @@ LOG(LOG_CALLS,"add " << a << '+' << b); val1->decRef(); val2->decRef(); - return abstract_s(a + b); + return abstract_s(val1->getSystemState(),a + b); } else if( (val1->is<XML>() || val1->is<XMLList>()) && (val2->is<XML>() || val2->is<XMLList>()) ) { //Check if the objects are both XML or XMLLists - Class_base* xmlClass=Class<XML>::getClass(); + Class_base* xmlClass=Class<XML>::getClass(val1->getSystemState()); - XMLList* newList=Class<XMLList>::getInstanceS(true); + XMLList* newList=Class<XMLList>::getInstanceS(val1->getSystemState(),true); if(val1->getClass()==xmlClass) newList->append(_MR(static_cast<XML*>(val1))); else //if(val1->getClass()==xmlListClass) @@ -1034,7 +1034,7 @@ string a(val1p->toString().raw_buf()); string b(val2p->toString().raw_buf()); LOG(LOG_CALLS,"add " << a << '+' << b); - return abstract_s(a+b); + return abstract_s(val1->getSystemState(),a+b); } else {//Convert both to numbers and add @@ -1042,7 +1042,7 @@ number_t num2=val2p->toNumber(); LOG(LOG_CALLS,"addN " << num1 << '+' << num2); number_t result = num1 + num2; - return abstract_d(result); + return abstract_d(val1->getSystemState(), result); } } @@ -1076,7 +1076,7 @@ int32_t num1=val1; val2->decRef(); LOG(LOG_CALLS,_("add ") << num1 << '+' << num2); - return abstract_i(num1+num2); + return abstract_i(val2->getSystemState(),num1+num2); } else if(val2->getObjectType()==T_NUMBER) { @@ -1084,7 +1084,7 @@ double num1=val1; val2->decRef(); LOG(LOG_CALLS,_("add ") << num1 << '+' << num2); - return abstract_d(num1+num2); + return abstract_d(val2->getSystemState(),num1+num2); } else if(val2->getObjectType()==T_STRING) { @@ -1093,11 +1093,11 @@ const tiny_string& b=val2->toString(); val2->decRef(); LOG(LOG_CALLS,_("add ") << a << '+' << b); - return abstract_s(a+b); + return abstract_s(val2->getSystemState(), a+b); } else { - return add(val2,abstract_i(val1)); + return add(val2,abstract_i(val2->getSystemState(),val1)); } } @@ -1111,7 +1111,7 @@ double num1=val1; val2->decRef(); LOG(LOG_CALLS,_("add ") << num1 << '+' << num2); - return abstract_d(num1+num2); + return abstract_d(val2->getSystemState(),num1+num2); } else if(val2->getObjectType()==T_INTEGER) { @@ -1119,7 +1119,7 @@ double num1=val1; val2->decRef(); LOG(LOG_CALLS,_("add ") << num1 << '+' << num2); - return abstract_d(num1+num2); + return abstract_d(val2->getSystemState(),num1+num2); } else if(val2->getObjectType()==T_STRING) { @@ -1127,11 +1127,11 @@ const tiny_string& b=val2->toString(); val2->decRef(); LOG(LOG_CALLS,_("add ") << a << '+' << b); - return abstract_s(a+b); + return abstract_s(val2->getSystemState(),a+b); } else { - return add(val2,abstract_d(val1)); + return add(val2,abstract_d(val2->getSystemState(),val1)); } } @@ -1271,7 +1271,7 @@ ASObject* ABCVm::pushNaN() { LOG(LOG_CALLS, _("pushNaN") ); - return abstract_d(Number::NaN); + return abstract_d(getSys(),Number::NaN); } bool ABCVm::ifGT(ASObject* obj2, ASObject* obj1) @@ -1388,7 +1388,7 @@ _NR<ASObject> ret = obj->getVariableByMultiname(*name,ASObject::NONE,cls); if (ret.isNull()) - throwError<ReferenceError>(kCallOfNonFunctionError,name->normalizedNameUnresolved()); + throwError<ReferenceError>(kCallOfNonFunctionError,name->normalizedNameUnresolved(obj->getSystemState())); name->resetNameIfObject(); @@ -1437,8 +1437,8 @@ if(o==NULL) { LOG(LOG_NOT_IMPLEMENTED,"getLex: " << *name<< " not found"); - throwError<ReferenceError>(kUndefinedVarError,name->normalizedNameUnresolved()); - th->runtime_stack_push(getSys()->getUndefinedRef()); + throwError<ReferenceError>(kUndefinedVarError,name->normalizedNameUnresolved(th->context->root->getSystemState())); + th->runtime_stack_push(th->context->root->getSystemState()->getUndefinedRef()); name->resetNameIfObject(); return; } @@ -1536,16 +1536,15 @@ _R<ASObject> r = it->object; if (!r->is<Class_base>()) continue; - NS_KIND nskind; - if (r->as<Class_base>()->findBorrowedGettable(*name,nskind)) + if (r->as<Class_base>()->findBorrowedGettable(*name)) { if (!r->as<Class_base>()->isSealed) break; - throwError<TypeError>(kCallOfNonFunctionError,name->normalizedNameUnresolved()); + throwError<TypeError>(kCallOfNonFunctionError,name->normalizedNameUnresolved(th->context->root->getSystemState())); } } - throwError<ReferenceError>(kUndefinedVarError,name->normalizedNameUnresolved()); - return getSys()->getUndefinedRef(); + throwError<ReferenceError>(kUndefinedVarError,name->normalizedNameUnresolved(th->context->root->getSystemState())); + return th->context->root->getSystemState()->getUndefinedRef(); } } @@ -1616,7 +1615,7 @@ } method_info* mi = th->context->get_method(n); assert_and_throw(mi); - SyntheticFunction* f=Class<IFunction>::getSyntheticFunction(mi); + SyntheticFunction* f=Class<IFunction>::getSyntheticFunction(obj->getSystemState(),mi); if(f) { @@ -1630,7 +1629,7 @@ args[i]->decRef(); throwError<ReferenceError>(kCallNotFoundError, "?", obj->getClassName()); if(keepReturn) - th->runtime_stack_push(getSys()->getUndefinedRef()); + th->runtime_stack_push(obj->getSystemState()->getUndefinedRef()); } LOG(LOG_CALLS,"End of callStatic "); } @@ -1673,10 +1672,10 @@ obj->decRef(); for(int i=0;i<m;i++) args[i]->decRef(); - //LOG(LOG_ERROR,_("Calling an undefined function ") << getSys()->getStringFromUniqueId(name->name_s_id)); - throwError<ReferenceError>(kCallNotFoundError, name->qualifiedString(), clsname); + //LOG(LOG_ERROR,_("Calling an undefined function ") << th->context->root->getSystemState()->getStringFromUniqueId(name->name_s_id)); + throwError<ReferenceError>(kCallNotFoundError, name->qualifiedString(th->context->root->getSystemState()), clsname); if(keepReturn) - th->runtime_stack_push(getSys()->getUndefinedRef()); + th->runtime_stack_push(th->context->root->getSystemState()->getUndefinedRef()); } LOG(LOG_CALLS,_("End of callSuper ") << *name); } @@ -1726,11 +1725,11 @@ //Special case numeric types if(obj->getObjectType()==T_INTEGER || obj->getObjectType()==T_UINTEGER || obj->getObjectType()==T_NUMBER) { - if(c==Class<Number>::getClass() || c==Class<ASObject>::getClass()) + if(c==Class<Number>::getClass(c->getSystemState()) || c==Class<ASObject>::getClass(c->getSystemState())) real_ret=true; - else if(c==Class<Integer>::getClass()) + else if(c==Class<Integer>::getClass(c->getSystemState())) real_ret=(obj->toNumber()==obj->toInt()); - else if(c==Class<UInteger>::getClass()) + else if(c==Class<UInteger>::getClass(c->getSystemState())) real_ret=(obj->toNumber()==obj->toUInt()); else real_ret=false; @@ -1773,7 +1772,7 @@ else { obj->decRef(); - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); } } @@ -1793,11 +1792,11 @@ if(obj->getObjectType()==T_INTEGER || obj->getObjectType()==T_UINTEGER || obj->getObjectType()==T_NUMBER) { bool real_ret; - if(c==Class<Number>::getClass() || c==Class<ASObject>::getClass()) + if(c==Class<Number>::getClass(c->getSystemState()) || c==Class<ASObject>::getClass(c->getSystemState())) real_ret=true; - else if(c==Class<Integer>::getClass()) + else if(c==Class<Integer>::getClass(c->getSystemState())) real_ret=(obj->toNumber()==obj->toInt()); - else if(c==Class<UInteger>::getClass()) + else if(c==Class<UInteger>::getClass(c->getSystemState())) real_ret=(obj->toNumber()==obj->toUInt()); else real_ret=false; @@ -1808,7 +1807,7 @@ else { obj->decRef(); - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); } } @@ -1819,7 +1818,7 @@ { obj->decRef(); type->decRef(); - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); } bool real_ret=objc->isSubClass(c); @@ -1831,7 +1830,7 @@ else { obj->decRef(); - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); } } @@ -1874,7 +1873,7 @@ name.name_type=multiname::NAME_OBJECT; //Acquire the reference name.name_o=val1; - name.ns.emplace_back("",NAMESPACE); + name.ns.emplace_back(val2->getSystemState(),"",NAMESPACE); bool ret=val2->hasPropertyByMultiname(name, true, true); name.name_o=NULL; val1->decRef(); @@ -1916,7 +1915,7 @@ if (obj->isPrimitive()) throwError<TypeError>(kConstructOfNonFunctionError); - throwError<ReferenceError>(kUndefinedVarError, name->normalizedNameUnresolved()); + throwError<ReferenceError>(kUndefinedVarError, name->normalizedNameUnresolved(th->context->root->getSystemState())); } name->resetNameIfObject(); @@ -1941,7 +1940,7 @@ { LOG(LOG_CALLS,_("Exception during object construction. Returning Undefined")); //Handle eventual exceptions from the constructor, to fix the stack - th->runtime_stack_push(getSys()->getUndefinedRef()); + th->runtime_stack_push(obj->getSystemState()->getUndefinedRef()); obj->decRef(); throw; } @@ -1965,11 +1964,11 @@ uint32_t newIndex=obj->nextNameIndex(curIndex); th->locals[m]->decRef(); - th->locals[m]=abstract_i(newIndex); + th->locals[m]=abstract_i(th->context->root->getSystemState(),newIndex); if(newIndex==0) { th->locals[n]->decRef(); - th->locals[n]=getSys()->getNullRef(); + th->locals[n]=th->context->root->getSystemState()->getNullRef(); return false; } return true; @@ -1978,16 +1977,16 @@ void ABCVm::newObject(call_context* th, int n) { LOG(LOG_CALLS,_("newObject ") << n); - ASObject* ret=Class<ASObject>::getInstanceS(); + ASObject* ret=Class<ASObject>::getInstanceS(th->context->root->getSystemState()); //Duplicated keys overwrite the previous value multiname propertyName(NULL); propertyName.name_type=multiname::NAME_STRING; - propertyName.ns.emplace_back("",NAMESPACE); + propertyName.ns.emplace_back(th->context->root->getSystemState(),"",NAMESPACE); for(int i=0;i<n;i++) { ASObject* value=th->runtime_stack_pop(); ASObject* name=th->runtime_stack_pop(); - propertyName.name_s_id=getSys()->getUniqueStringId(name->toString()); + propertyName.name_s_id=ret->getSystemState()->getUniqueStringId(name->toString()); name->decRef(); ret->setVariableByMultiname(propertyName, value, ASObject::CONST_NOT_ALLOWED); } @@ -2002,38 +2001,38 @@ LOG(LOG_CALLS,"getDescendants " << *name << " " <<name->isAttribute<< " "<<obj->getClassName()); XML::XMLVector ret; XMLList* targetobject = NULL; - if(obj->getClass()==Class<XML>::getClass()) + if(obj->getClass()==Class<XML>::getClass(obj->getSystemState())) { XML* xmlObj=Class<XML>::cast(obj); targetobject = xmlObj->getChildrenlist(); tiny_string ns_uri = ""; if (name->ns.size() > 0) { - ns_uri = name->ns[0].getImpl().name; + ns_uri = name->ns[0].getImpl(th->context->root->getSystemState()).name; if (ns_uri.empty() && name->ns.size() == 1) ns_uri="*"; } - xmlObj->getDescendantsByQName(name->normalizedName(), ns_uri,name->isAttribute, ret); + xmlObj->getDescendantsByQName(name->normalizedName(th->context->root->getSystemState()), ns_uri,name->isAttribute, ret); } - else if(obj->getClass()==Class<XMLList>::getClass()) + else if(obj->getClass()==Class<XMLList>::getClass(th->context->root->getSystemState())) { XMLList* xmlObj=Class<XMLList>::cast(obj); tiny_string ns_uri = ""; if (name->ns.size() > 0) { - ns_uri = name->ns[0].getImpl().name; + ns_uri = name->ns[0].getImpl(th->context->root->getSystemState()).name; if (ns_uri.empty() && name->ns.size() == 1) ns_uri="*"; } targetobject = xmlObj; - xmlObj->getDescendantsByQName(name->normalizedName(), ns_uri,name->isAttribute, ret); + xmlObj->getDescendantsByQName(name->normalizedName(th->context->root->getSystemState()), ns_uri,name->isAttribute, ret); } else if(obj->getClass()->isProxy) { multiname callPropertyName(NULL); callPropertyName.name_type=multiname::NAME_STRING; - callPropertyName.name_s_id=getSys()->getUniqueStringId("getDescendants"); - callPropertyName.ns.emplace_back(flash_proxy,NAMESPACE); + callPropertyName.name_s_id=obj->getSystemState()->getUniqueStringId("getDescendants"); + callPropertyName.ns.emplace_back(th->context->root->getSystemState(),flash_proxy,NAMESPACE); _NR<ASObject> o=obj->getVariableByMultiname(callPropertyName,ASObject::SKIP_IMPL); if(!o.isNull()) @@ -2043,7 +2042,7 @@ IFunction* f=static_cast<IFunction*>(o.getPtr()); //Create a new array ASObject** proxyArgs=g_newa(ASObject*, 1); - ASObject* namearg = abstract_s(name->normalizedName()); + ASObject* namearg = abstract_s(f->getSystemState(), name->normalizedName(th->context->root->getSystemState())); namearg->setProxyProperty(*name); proxyArgs[0]=namearg; @@ -2072,7 +2071,7 @@ obj->decRef(); throwError<TypeError>(kDescendentsError, objName); } - XMLList* retObj=Class<XMLList>::getInstanceS(ret,targetobject,*name); + XMLList* retObj=Class<XMLList>::getInstanceS(th->context->root->getSystemState(),ret,targetobject,*name); th->runtime_stack_push(retObj); obj->decRef(); } @@ -2168,13 +2167,13 @@ ASObject* baseClass=th->runtime_stack_pop(); assert_and_throw(mname->ns.size()==1); - QName className(getSys()->getStringFromUniqueId(mname->name_s_id),mname->ns[0].getImpl().name); + QName className(th->context->root->getSystemState()->getStringFromUniqueId(mname->name_s_id),mname->ns[0].getImpl(th->context->root->getSystemState()).name); Class_inherit* ret = NULL; auto i = th->context->root->applicationDomain->classesBeingDefined.cbegin(); while (i != th->context->root->applicationDomain->classesBeingDefined.cend()) { - if(i->first->qualifiedString() == mname->qualifiedString()) + if(i->first->name_s_id == mname->name_s_id && i->first->ns[0].nsRealId == mname->ns[0].nsRealId) { ret = (Class_inherit*)i->second; ret->incRef(); @@ -2201,8 +2200,8 @@ return; } - MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(className.name); - ret=new (getSys()->unaccountedMemory) Class_inherit(className, memoryAccount); + MemoryAccount* memoryAccount = th->context->root->applicationDomain->getSystemState()->allocateMemoryAccount(className.name); + ret=new (th->context->root->applicationDomain->getSystemState()->unaccountedMemory) Class_inherit(className, memoryAccount); LOG(LOG_CALLS,"add classes defined:"<<*mname<<" "<<th->context); //Add the class to the ones being currently defined in this context @@ -2222,7 +2221,13 @@ assert_and_throw(baseClass->is<Class_base>()); Class_base* base = baseClass->as<Class_base>(); assert(!base->isFinal); - ret->setSuper(_MR(base)); + if (ret->super.isNull()) + ret->setSuper(_MR(base)); + else if (base != ret->super.getPtr()) + { + LOG(LOG_ERROR,"resetting super class from "<<ret->super->toDebugString() <<" to "<< base->toDebugString()); + ret->setSuper(_MR(base)); + } i = th->context->root->applicationDomain->classesBeingDefined.cbegin(); while (i != th->context->root->applicationDomain->classesBeingDefined.cend()) { @@ -2245,7 +2250,7 @@ ret->initializeProtectedNamespace(th->context->getString(ns_info.name),ns_info); } - ret->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(Class_base::_toString),NORMAL_METHOD,false); + ret->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(ret->getSystemState(),Class_base::_toString),NORMAL_METHOD,false); ret->class_scope=th->scope_stack; @@ -2273,7 +2278,7 @@ constructor->validProfName=true; } #endif - SyntheticFunction* constructorFunc=Class<IFunction>::getSyntheticFunction(constructor); + SyntheticFunction* constructorFunc=Class<IFunction>::getSyntheticFunction(ret->getSystemState(),constructor); constructorFunc->acquireScope(ret->class_scope); ret->incRef(); constructorFunc->addToScope(scope_entry(_MR(ret),false)); @@ -2285,7 +2290,7 @@ th->context->root->bindClass(className,ret); //Add prototype variable - ret->prototype = _MNR(new_objectPrototype()); + ret->prototype = _MNR(new_objectPrototype(ret->getSystemState())); //Add the constructor variable to the class prototype ret->incRef(); ret->prototype->setVariableByQName("constructor","",ret, DECLARED_TRAIT); @@ -2333,7 +2338,7 @@ ret->incRef(); //Class init functions are called with global as this method_info* m=&th->context->methods[th->context->classes[n].cinit]; - SyntheticFunction* cinit=Class<IFunction>::getSyntheticFunction(m); + SyntheticFunction* cinit=Class<IFunction>::getSyntheticFunction(ret->getSystemState(),m); //cinit must inherit the current scope cinit->acquireScope(th->scope_stack); ASObject* ret2=NULL; @@ -2345,7 +2350,7 @@ { LOG(LOG_CALLS,_("Exception during class initialization. Returning Undefined")); //Handle eventual exceptions from the constructor, to fix the stack - th->runtime_stack_push(getSys()->getUndefinedRef()); + th->runtime_stack_push(th->context->root->applicationDomain->getSystemState()->getUndefinedRef()); cinit->decRef(); //Remove the class to the ones being currently defined in this context @@ -2390,7 +2395,7 @@ act->incRef(); } else - act = Class<ASObject>::getInstanceS(); + act = Class<ASObject>::getInstanceS(th->context->root->getSystemState()); #ifndef NDEBUG act->initialized=false; #endif @@ -2498,13 +2503,13 @@ LOG(LOG_CALLS,_("newFunction ") << n); method_info* m=&th->context->methods[n]; - SyntheticFunction* f=Class<IFunction>::getSyntheticFunction(m); + SyntheticFunction* f=Class<IFunction>::getSyntheticFunction(th->context->root->applicationDomain->getSystemState(),m); f->func_scope=th->scope_stack; //Bind the function to null, as this is not a class method f->bind(NullRef,-1); //Create the prototype object - f->prototype = _MR(new_asobject()); + f->prototype = _MR(new_asobject(f->getSystemState())); return f; } @@ -2520,15 +2525,15 @@ { const tiny_string s=th->context->getString(n); LOG(LOG_CALLS, _("pushString ") << s ); - return abstract_s(s); + return abstract_s(th->context->root->applicationDomain->getSystemState(),s); } ASObject* ABCVm::newCatch(call_context* th, int n) { - ASObject* catchScope = Class<ASObject>::getInstanceS(); + ASObject* catchScope = Class<ASObject>::getInstanceS(th->context->root->getSystemState()); assert_and_throw(n >= 0 && (unsigned int)n < th->mi->body->exceptions.size()); multiname* name = th->context->getMultiname(th->mi->body->exceptions[n].var_name, NULL); - catchScope->setVariableByMultiname(*name, getSys()->getUndefinedRef(),ASObject::CONST_NOT_ALLOWED); + catchScope->setVariableByMultiname(*name, th->context->root->getSystemState()->getUndefinedRef(),ASObject::CONST_NOT_ALLOWED); catchScope->initSlot(1, *name); return catchScope; } @@ -2536,7 +2541,7 @@ void ABCVm::newArray(call_context* th, int n) { LOG(LOG_CALLS, _("newArray ") << n ); - Array* ret=Class<Array>::getInstanceS(); + Array* ret=Class<Array>::getInstanceS(th->context->root->getSystemState()); ret->resize(n); for(int i=0;i<n;i++) ret->set(n-i-1,_MR(th->runtime_stack_pop())); @@ -2554,7 +2559,7 @@ else t = XML::encodeToXML(o->toString(),true); o->decRef(); - return abstract_s(t); + return abstract_s(o->getSystemState(),t); } ASObject* ABCVm::esc_xelem(ASObject* o) @@ -2567,7 +2572,7 @@ else t = XML::encodeToXML(o->toString(),false); o->decRef(); - return abstract_s(t); + return abstract_s(o->getSystemState(),t); } /* This should walk prototype chain of value, trying to find type. See ECMA. @@ -2601,8 +2606,8 @@ if(value->is<Class_base>()) // Classes are instance of Class and Object but not // itself or super classes - return type == Class_object::getClass() || - type == Class<ASObject>::getClass(); + return type == Class_object::getClass(type->getSystemState()) || + type == Class<ASObject>::getClass(type->getSystemState()); else return value->getClass() && value->getClass()->isSubClass(type->as<Class_base>(), false); } @@ -2612,24 +2617,24 @@ const namespace_info& ns_info=th->context->constant_pool.namespaces[n]; assert(ns_info.kind == NAMESPACE); LOG(LOG_CALLS, _("pushNamespace ") << th->context->getString(ns_info.name) ); - return Class<Namespace>::getInstanceS(th->context->getString(ns_info.name)); + return Class<Namespace>::getInstanceS(th->context->root->getSystemState(),th->context->getString(ns_info.name)); } /* @spec-checked avm2overview */ void ABCVm::dxns(call_context* th, int n) { if(!th->mi->hasDXNS()) - throw Class<VerifyError>::getInstanceS("dxns without SET_DXNS"); + throw Class<VerifyError>::getInstanceS(th->context->root->getSystemState(),"dxns without SET_DXNS"); - th->defaultNamespaceUri = _NR<ASString>(abstract_s(th->context->getString(n))); + th->defaultNamespaceUri = _NR<ASString>(abstract_s(th->context->root->applicationDomain->getSystemState(),th->context->getString(n))); } /* @spec-checked avm2overview */ void ABCVm::dxnslate(call_context* th, ASObject* o) { if(!th->mi->hasDXNS()) - throw Class<VerifyError>::getInstanceS("dxnslate without SET_DXNS"); + throw Class<VerifyError>::getInstanceS(th->context->root->getSystemState(),"dxnslate without SET_DXNS"); - th->defaultNamespaceUri = _NR<ASString>(abstract_s(o->toString())); + th->defaultNamespaceUri = _NR<ASString>(abstract_s(th->context->root->applicationDomain->getSystemState(),o->toString())); o->decRef(); }
View file
lightspark.tar.xz/src/scripting/abc_optimizer.cpp
Changed
@@ -179,8 +179,7 @@ return CANNOT_BIND; } - NS_KIND nskind; - const variable* var=it->object->findVariableByMultiname(*name, ASObject::XML_STRICT, it->object->getClass(),nskind); + const variable* var=it->object->findVariableByMultiname(*name, ASObject::XML_STRICT, it->object->getClass()); if(var) { found=true; @@ -240,7 +239,7 @@ ASObject* target; //Now we should serach in the applicationDomain. The system domain is the first one searched. We can safely //early bind for it, but not for custom domains, since we may change the expected order of evaluation - ASObject* o=getSys()->systemDomain->getVariableAndTargetByMultiname(*name, target); + ASObject* o=f->getSystemState()->systemDomain->getVariableAndTargetByMultiname(*name, target); if(o) { //Output a special opcode @@ -702,7 +701,7 @@ case 0x20: { //pushnull - ASObject* ret=getSys()->getNullRef(); + ASObject* ret=function->getSystemState()->getNullRef(); //We don't really need a reference to it ret->decRef(); curBlock->pushStack(InferenceData(ret)); @@ -731,7 +730,7 @@ code.read((char*)&t,1); out << (uint8_t)opcode; out << t; - curBlock->pushStack(Class<Integer>::getClass()); + curBlock->pushStack(Class<Integer>::getClass(function->getSystemState())); break; } case 0x25: @@ -743,21 +742,21 @@ code >> t; out << (uint8_t)opcode; writeInt32(out, t); - curBlock->pushStack(Class<Integer>::getClass()); + curBlock->pushStack(Class<Integer>::getClass(function->getSystemState())); break; } case 0x26: { //pushtrue out << (uint8_t)opcode; - curBlock->pushStack(Class<Boolean>::getClass()); + curBlock->pushStack(Class<Boolean>::getClass(function->getSystemState())); break; } case 0x27: { //pushfalse out << (uint8_t)opcode; - curBlock->pushStack(Class<Boolean>::getClass()); + curBlock->pushStack(Class<Boolean>::getClass(function->getSystemState())); break; } case 0x28: @@ -812,7 +811,7 @@ s32 val=mi->context->constant_pool.integer[t]; out << (uint8_t)opcode; writeInt32(out, val); - curBlock->pushStack(Class<Integer>::getClass()); + curBlock->pushStack(Class<Integer>::getClass(function->getSystemState())); break; } case 0x2e: @@ -823,7 +822,7 @@ u32 val=mi->context->constant_pool.uinteger[t]; out << (uint8_t)opcode; writeInt32(out, val); - curBlock->pushStack(Class<Integer>::getClass()); + curBlock->pushStack(Class<Integer>::getClass(function->getSystemState())); break; } case 0x2f: @@ -834,7 +833,7 @@ double val=mi->context->constant_pool.doubles[t]; out << (uint8_t)opcode; writeDouble(out, val); - curBlock->pushStack(Class<Number>::getClass()); + curBlock->pushStack(Class<Number>::getClass(function->getSystemState())); break; } case 0x30: @@ -865,7 +864,7 @@ out << (uint8_t)opcode; writeInt32(out,t); writeInt32(out,t2); - curBlock->pushStack(Class<Boolean>::getClass()); + curBlock->pushStack(Class<Boolean>::getClass(function->getSystemState())); break; } //Alchemy opcodes @@ -878,7 +877,7 @@ //li32 out << (uint8_t)opcode; curBlock->popStack(1); - curBlock->pushStack(Class<Integer>::getClass()); + curBlock->pushStack(Class<Integer>::getClass(function->getSystemState())); break; } case 0x3a: @@ -965,8 +964,7 @@ const Class_base* objType=dynamic_cast<const Class_base*>(baseData.type); if(objType) { - NS_KIND nskind; - const variable* var=objType->findBorrowedGettable(*name,nskind); + const variable* var=objType->findBorrowedGettable(*name); if(var && var->var && var->var->getObjectType()==T_FUNCTION) { SyntheticFunction* calledFunc=dynamic_cast<SyntheticFunction*>(var->var); @@ -1258,7 +1256,7 @@ int numRT=mi->context->getMultinameRTData(t); curBlock->popStack(numRT+1); - curBlock->pushStack(Class<Boolean>::getClass()); + curBlock->pushStack(Class<Boolean>::getClass(function->getSystemState())); break; } case 0x6c: @@ -1322,7 +1320,7 @@ out << (uint8_t)opcode; curBlock->popStack(1); - curBlock->pushStack(Class<ASString>::getClass()); + curBlock->pushStack(Class<ASString>::getClass(function->getSystemState())); break; } case 0x73: @@ -1331,7 +1329,7 @@ out << (uint8_t)opcode; curBlock->popStack(1); - curBlock->pushStack(Class<Integer>::getClass()); + curBlock->pushStack(Class<Integer>::getClass(function->getSystemState())); break; } case 0x74: @@ -1340,7 +1338,7 @@ out << (uint8_t)opcode; curBlock->popStack(1); - curBlock->pushStack(Class<UInteger>::getClass()); + curBlock->pushStack(Class<UInteger>::getClass(function->getSystemState())); break; } case 0x75: @@ -1349,7 +1347,7 @@ out << (uint8_t)opcode; curBlock->popStack(1); - curBlock->pushStack(Class<Number>::getClass()); + curBlock->pushStack(Class<Number>::getClass(function->getSystemState())); break; } case 0x76: @@ -1358,7 +1356,7 @@ out << (uint8_t)opcode; curBlock->popStack(1); - curBlock->pushStack(Class<Boolean>::getClass()); + curBlock->pushStack(Class<Boolean>::getClass(function->getSystemState())); break; } case 0x78: @@ -1451,7 +1449,7 @@ //decrement out << (uint8_t)opcode; curBlock->popStack(1); - curBlock->pushStack(Class<Number>::getClass()); + curBlock->pushStack(Class<Number>::getClass(function->getSystemState())); break; } case 0x92: @@ -1470,7 +1468,7 @@ //not out << (uint8_t)opcode; curBlock->popStack(1); - curBlock->pushStack(Class<Boolean>::getClass()); + curBlock->pushStack(Class<Boolean>::getClass(function->getSystemState())); break; } case 0x97: @@ -1484,7 +1482,7 @@ //negate_i out << (uint8_t)opcode; curBlock->popStack(1); - curBlock->pushStack(Class<Integer>::getClass()); + curBlock->pushStack(Class<Integer>::getClass(function->getSystemState())); break; } case 0xa0: @@ -1507,7 +1505,7 @@ //modulo out << (uint8_t)opcode; curBlock->popStack(2); - curBlock->pushStack(Class<Number>::getClass()); + curBlock->pushStack(Class<Number>::getClass(function->getSystemState())); break; } case 0xa5: @@ -1531,7 +1529,7 @@ //multiply_i out << (uint8_t)opcode; curBlock->popStack(2); - curBlock->pushStack(Class<Integer>::getClass()); + curBlock->pushStack(Class<Integer>::getClass(function->getSystemState())); break; } case 0xab: @@ -1555,7 +1553,7 @@ //in out << (uint8_t)opcode; curBlock->popStack(2); - curBlock->pushStack(Class<Boolean>::getClass()); + curBlock->pushStack(Class<Boolean>::getClass(function->getSystemState())); break; } case 0xb2: @@ -1570,7 +1568,7 @@ if(numRT) throw ParseException("Bad code in optimizer"); curBlock->popStack(1); - curBlock->pushStack(Class<Boolean>::getClass()); + curBlock->pushStack(Class<Boolean>::getClass(function->getSystemState())); break; } case 0xc2:
View file
lightspark.tar.xz/src/scripting/abctypes.cpp
Changed
@@ -165,7 +165,8 @@ in >> v.method >> v.max_stack >> v.local_count >> v.init_scope_depth >> v.max_scope_depth >> code_length; v.code.resize(code_length); in.read(&v.code[0],code_length); - + v.codecache = new method_body_info_cache[code_length]; + memset(v.codecache,0,code_length*sizeof(method_body_info_cache)); u30 exception_count; in >> exception_count; v.exceptions.resize(exception_count);
View file
lightspark.tar.xz/src/scripting/abctypes.h
Changed
@@ -245,10 +245,17 @@ std::vector<option_detail> options; std::vector<u30> param_names; }; +struct method_body_info_cache +{ + bool iscached; + uint32_t value; + uint32_t nextpos; +}; struct method_body_info { method_body_info():hit_count(0),codeStatus(ORIGINAL){} + ~method_body_info() { delete[] codecache; } u30 method; u30 max_stack; u30 local_count; @@ -263,6 +270,7 @@ //The code status enum CODE_STATUS { ORIGINAL = 0, USED, OPTIMIZED, JITTED }; CODE_STATUS codeStatus; + method_body_info_cache* codecache; }; std::istream& operator>>(std::istream& in, u8& v);
View file
lightspark.tar.xz/src/scripting/abcutils.h
Changed
@@ -21,6 +21,7 @@ #define SCRIPTING_ABCUTILS_H 1 #include "smartrefs.h" +#include "errorconstants.h" namespace lightspark { @@ -66,10 +67,34 @@ _NR<ASString> defaultNamespaceUri; int initialScopeStack; ~call_context(); - void runtime_stack_clear(); - void runtime_stack_push(ASObject* s); - ASObject* runtime_stack_pop(); - ASObject* runtime_stack_peek(); + static void handleError(int errorcode); + inline void runtime_stack_clear() + { + while(stack_index > 0) + stack[--stack_index]->decRef(); + } + inline void runtime_stack_push(ASObject* s) + { + if(stack_index>=max_stack) + handleError(kStackOverflowError); + stack[stack_index++]=s; + } + inline ASObject* runtime_stack_pop() + { + if(stack_index==0) + handleError(kStackUnderflowError); + ASObject* ret=stack[--stack_index]; + return ret; + } + inline ASObject* runtime_stack_peek() + { + if(stack_index==0) + { + LOG(LOG_ERROR,_("Empty stack")); + return NULL; + } + return stack[stack_index-1]; + } }; }
View file
lightspark.tar.xz/src/scripting/argconv.h
Changed
@@ -54,7 +54,7 @@ { public: static T toConcrete(ASObject* obj); - static ASObject* toAbstract(const T& val); + static ASObject* toAbstract(SystemState* sys,const T& val); }; template<class T> @@ -67,11 +67,11 @@ if(!o) throwError<ArgumentError>(kCheckTypeFailedError, obj->getClassName(), - Class<T>::getClass()->getQualifiedClassName()); + Class<T>::getClass(obj->getSystemState())->getQualifiedClassName()); o->incRef(); return _MR(o); } - static ASObject* toAbstract(const Ref<T>& val) + static ASObject* toAbstract(SystemState* /*sys*/,const Ref<T>& val) { val->incRef(); return val.getPtr(); @@ -95,14 +95,14 @@ if(!o) throwError<ArgumentError>(kCheckTypeFailedError, obj->getClassName(), - Class<T>::getClass()->getQualifiedClassName()); + Class<T>::getClass(obj->getSystemState())->getQualifiedClassName()); o->incRef(); return _MNR(o); } - static ASObject* toAbstract(const NullableRef<T>& val) + static ASObject* toAbstract(SystemState* sys,const NullableRef<T>& val) { if(val.isNull()) - return getSys()->getNullRef(); + return sys->getNullRef(); val->incRef(); return val.getPtr(); } @@ -121,10 +121,10 @@ obj->incRef(); return _MNR(obj); } - static ASObject* toAbstract(const NullableRef<ASObject>& val) + static ASObject* toAbstract(SystemState* sys,const NullableRef<ASObject>& val) { if(val.isNull()) - return getSys()->getNullRef(); + return sys->getNullRef(); val->incRef(); return val.getPtr(); } @@ -174,45 +174,45 @@ } template<> -inline ASObject* lightspark::ArgumentConversion<int32_t>::toAbstract(const int32_t& val) +inline ASObject* lightspark::ArgumentConversion<int32_t>::toAbstract(SystemState* sys,const int32_t& val) { - return abstract_i(val); + return abstract_i(sys,val); } template<> -inline ASObject* lightspark::ArgumentConversion<uint32_t>::toAbstract(const uint32_t& val) +inline ASObject* lightspark::ArgumentConversion<uint32_t>::toAbstract(SystemState* sys,const uint32_t& val) { - return abstract_ui(val); + return abstract_ui(sys,val); } template<> -inline ASObject* lightspark::ArgumentConversion<number_t>::toAbstract(const number_t& val) +inline ASObject* lightspark::ArgumentConversion<number_t>::toAbstract(SystemState* sys,const number_t& val) { - return abstract_d(val); + return abstract_d(sys,val); } template<> -inline ASObject* lightspark::ArgumentConversion<bool>::toAbstract(const bool& val) +inline ASObject* lightspark::ArgumentConversion<bool>::toAbstract(SystemState* sys,const bool& val) { - return abstract_b(val); + return abstract_b(sys,val); } template<> -inline ASObject* lightspark::ArgumentConversion<tiny_string>::toAbstract(const tiny_string& val) +inline ASObject* lightspark::ArgumentConversion<tiny_string>::toAbstract(SystemState* sys,const tiny_string& val) { - return Class<ASString>::getInstanceS(val); + return abstract_s(sys,val); } template<> -inline ASObject* lightspark::ArgumentConversion<std::string>::toAbstract(const std::string& val) +inline ASObject* lightspark::ArgumentConversion<std::string>::toAbstract(SystemState* sys,const std::string& val) { - return Class<ASString>::getInstanceS(val); + return abstract_s(sys,val); } template<> -inline ASObject* lightspark::ArgumentConversion<RGB>::toAbstract(const RGB& val) +inline ASObject* lightspark::ArgumentConversion<RGB>::toAbstract(SystemState* sys,const RGB& val) { - return abstract_ui(val.toUInt()); + return abstract_ui(sys,val.toUInt()); } #define ARG_UNPACK ArgUnpack(args,argslen,false)
View file
lightspark.tar.xz/src/scripting/avmplus/avmplus.cpp
Changed
@@ -32,11 +32,11 @@ void avmplusFile::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED); - c->setDeclaredMethodByQName("exists","",Class<IFunction>::getFunction(exists),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("read","",Class<IFunction>::getFunction(read),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("write","",Class<IFunction>::getFunction(write),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("readByteArray","",Class<IFunction>::getFunction(readByteArray),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("writeByteArray","",Class<IFunction>::getFunction(writeByteArray),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("exists","",Class<IFunction>::getFunction(c->getSystemState(),exists),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("read","",Class<IFunction>::getFunction(c->getSystemState(),read),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("write","",Class<IFunction>::getFunction(c->getSystemState(),write),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("readByteArray","",Class<IFunction>::getFunction(c->getSystemState(),readByteArray),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("writeByteArray","",Class<IFunction>::getFunction(c->getSystemState(),writeByteArray),NORMAL_METHOD,false); } ASFUNCTIONBODY(avmplusFile,exists) @@ -61,7 +61,7 @@ ARG_UNPACK(filename); LOG(LOG_NOT_IMPLEMENTED, _("avmplus.File.readByteArray is unimplemented.")); - return Class<ByteArray>::getInstanceS(); + return Class<ByteArray>::getInstanceS(obj->getSystemState()); } ASFUNCTIONBODY(avmplusFile,writeByteArray) { @@ -77,34 +77,34 @@ void avmplusSystem::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED); - c->setDeclaredMethodByQName("getFeatures","",Class<IFunction>::getFunction(getFeatures),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("queueCollection","",Class<IFunction>::getFunction(queueCollection),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("forceFullCollection","",Class<IFunction>::getFunction(forceFullCollection),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("getAvmplusVersion","",Class<IFunction>::getFunction(getAvmplusVersion),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("pauseForGCIfCollectionImminent","",Class<IFunction>::getFunction(pauseForGCIfCollectionImminent),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("getRunmode","",Class<IFunction>::getFunction(getRunmode),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("isDebugger","",Class<IFunction>::getFunction(isDebugger),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("isGlobal","",Class<IFunction>::getFunction(isGlobal),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("freeMemory","",Class<IFunction>::getFunction(_freeMemory),GETTER_METHOD,false); - c->setDeclaredMethodByQName("totalMemory","",Class<IFunction>::getFunction(_totalMemory),GETTER_METHOD,false); - c->setDeclaredMethodByQName("privateMemory","",Class<IFunction>::getFunction(_privateMemory),GETTER_METHOD,false); - c->setDeclaredMethodByQName("argv","",Class<IFunction>::getFunction(argv),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("exec","",Class<IFunction>::getFunction(exec),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("write","",Class<IFunction>::getFunction(write),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("exit","",Class<IFunction>::getFunction(exit),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("trace","",Class<IFunction>::getFunction(lightspark::trace),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("canonicalizeNumber","",Class<IFunction>::getFunction(canonicalizeNumber),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("getFeatures","",Class<IFunction>::getFunction(c->getSystemState(),getFeatures),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("queueCollection","",Class<IFunction>::getFunction(c->getSystemState(),queueCollection),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("forceFullCollection","",Class<IFunction>::getFunction(c->getSystemState(),forceFullCollection),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("getAvmplusVersion","",Class<IFunction>::getFunction(c->getSystemState(),getAvmplusVersion),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("pauseForGCIfCollectionImminent","",Class<IFunction>::getFunction(c->getSystemState(),pauseForGCIfCollectionImminent),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("getRunmode","",Class<IFunction>::getFunction(c->getSystemState(),getRunmode),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("isDebugger","",Class<IFunction>::getFunction(c->getSystemState(),isDebugger),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("isGlobal","",Class<IFunction>::getFunction(c->getSystemState(),isGlobal),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("freeMemory","",Class<IFunction>::getFunction(c->getSystemState(),_freeMemory),GETTER_METHOD,false); + c->setDeclaredMethodByQName("totalMemory","",Class<IFunction>::getFunction(c->getSystemState(),_totalMemory),GETTER_METHOD,false); + c->setDeclaredMethodByQName("privateMemory","",Class<IFunction>::getFunction(c->getSystemState(),_privateMemory),GETTER_METHOD,false); + c->setDeclaredMethodByQName("argv","",Class<IFunction>::getFunction(c->getSystemState(),argv),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("exec","",Class<IFunction>::getFunction(c->getSystemState(),exec),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("write","",Class<IFunction>::getFunction(c->getSystemState(),write),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("exit","",Class<IFunction>::getFunction(c->getSystemState(),exit),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("trace","",Class<IFunction>::getFunction(c->getSystemState(),lightspark::trace),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("canonicalizeNumber","",Class<IFunction>::getFunction(c->getSystemState(),canonicalizeNumber),NORMAL_METHOD,false); } ASFUNCTIONBODY(avmplusSystem,getFeatures) { LOG(LOG_NOT_IMPLEMENTED, _("avmplus.System.getFeatures is unimplemented.")); - return Class<ASString>::getInstanceS(""); + return abstract_s(getSys(),""); } ASFUNCTIONBODY(avmplusSystem,getRunmode) { LOG(LOG_NOT_IMPLEMENTED, _("avmplus.System.getRunmode is unimplemented.")); - return Class<ASString>::getInstanceS("jit"); + return abstract_s(getSys(),"jit"); } ASFUNCTIONBODY(avmplusSystem,queueCollection) @@ -122,7 +122,7 @@ ASFUNCTIONBODY(avmplusSystem,getAvmplusVersion) { LOG(LOG_NOT_IMPLEMENTED, _("avmplus.System.getAvmplusVersion is unimplemented.")); - return Class<ASString>::getInstanceS("0"); + return abstract_s(getSys(),"0"); } ASFUNCTIONBODY(avmplusSystem,pauseForGCIfCollectionImminent) { @@ -133,32 +133,32 @@ ASFUNCTIONBODY(avmplusSystem,isDebugger) { LOG(LOG_NOT_IMPLEMENTED, _("avmplus.System.isDebugger is unimplemented.")); - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); } ASFUNCTIONBODY(avmplusSystem,isGlobal) { LOG(LOG_NOT_IMPLEMENTED, _("avmplus.System.isDebugger is unimplemented.")); - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); } ASFUNCTIONBODY(avmplusSystem,_freeMemory) { LOG(LOG_NOT_IMPLEMENTED, _("avmplus.System.freeMemory is unimplemented.")); - return abstract_d(1024); + return abstract_d(obj->getSystemState(),1024); } ASFUNCTIONBODY(avmplusSystem,_totalMemory) { LOG(LOG_NOT_IMPLEMENTED, _("avmplus.System.totalMemory is unimplemented.")); - return abstract_d(1024); + return abstract_d(obj->getSystemState(),1024); } ASFUNCTIONBODY(avmplusSystem,_privateMemory) { LOG(LOG_NOT_IMPLEMENTED, _("avmplus.System.privateMemory is unimplemented.")); - return abstract_d(1024); + return abstract_d(obj->getSystemState(),1024); } ASFUNCTIONBODY(avmplusSystem,argv) { LOG(LOG_NOT_IMPLEMENTED, _("avmplus.System.argv is unimplemented.")); - return Class<Array>::getInstanceS(); + return Class<Array>::getInstanceS(getSys()); } ASFUNCTIONBODY(avmplusSystem,exec) { @@ -193,11 +193,11 @@ void avmplusDomain::sinit(Class_base* c) { CLASS_SETUP(c, ApplicationDomain,_constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("currentDomain","",Class<IFunction>::getFunction(_getCurrentDomain),GETTER_METHOD,false); - c->setDeclaredMethodByQName("MIN_DOMAIN_MEMORY_LENGTH","",Class<IFunction>::getFunction(_getMinDomainMemoryLength),GETTER_METHOD,false); - c->setDeclaredMethodByQName("load","",Class<IFunction>::getFunction(load),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("loadBytes","",Class<IFunction>::getFunction(load),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getClass","",Class<IFunction>::getFunction(getClass),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("currentDomain","",Class<IFunction>::getFunction(c->getSystemState(),_getCurrentDomain),GETTER_METHOD,false); + c->setDeclaredMethodByQName("MIN_DOMAIN_MEMORY_LENGTH","",Class<IFunction>::getFunction(c->getSystemState(),_getMinDomainMemoryLength),GETTER_METHOD,false); + c->setDeclaredMethodByQName("load","",Class<IFunction>::getFunction(c->getSystemState(),load),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("loadBytes","",Class<IFunction>::getFunction(c->getSystemState(),load),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getClass","",Class<IFunction>::getFunction(c->getSystemState(),getClass),NORMAL_METHOD,true); } ASFUNCTIONBODY(avmplusDomain,_constructor) { @@ -219,5 +219,5 @@ ASFUNCTIONBODY(avmplusDomain,getClass) { LOG(LOG_NOT_IMPLEMENTED, _("avmplus.Domain.getClass is unimplemented.")); - return Class<ASObject>::getRef()->getClass(); + return Class<ASObject>::getRef(obj->getSystemState())->getClass(obj->getSystemState()); }
View file
lightspark.tar.xz/src/scripting/class.cpp
Changed
@@ -24,15 +24,15 @@ using namespace lightspark; -ASObject* lightspark::new_asobject() +ASObject* lightspark::new_asobject(SystemState* sys) { - return Class<ASObject>::getInstanceS(); + return Class<ASObject>::getInstanceS(sys); } -Prototype* lightspark::new_objectPrototype() +Prototype* lightspark::new_objectPrototype(SystemState* sys) { //Create a Prototype object, the class should be ASObject - Class_base* c=Class<ASObject>::getClass(); + Class_base* c=Class<ASObject>::getClass(sys); return new (c->memoryAccount) ObjectPrototype(c); } @@ -44,7 +44,7 @@ Function_object* lightspark::new_functionObject(_NR<ASObject> p) { - Class_base* c=Class<ASObject>::getClass(); + Class_base* c=Class<ASObject>::getClass(p->getSystemState()); return new (c->memoryAccount) Function_object(c, p); } @@ -61,8 +61,9 @@ #ifndef NDEBUG bool ret= #endif - getSys()->customClasses.insert(this).second; + this->getSystemState()->customClasses.insert(this).second; assert(ret); + isReusable = true; } void Class_inherit::finalize() @@ -93,6 +94,14 @@ handleConstruction(ret,args,argslen,true); return ret; } +void Class_inherit::recursiveBuild(ASObject* target) const +{ + if(super && super->is<Class_inherit>()) + super->as<Class_inherit>()->recursiveBuild(target); + + buildInstanceTraits(target); +} + void Class_inherit::buildInstanceTraits(ASObject* o) const { @@ -105,6 +114,28 @@ context->buildInstanceTraits(o,class_index); } +void Class_inherit::setupDeclaredTraits(ASObject *target) const +{ + if (!target->traitsInitialized) + { + #ifndef NDEBUG + assert_and_throw(!target->initialized); + #endif + //HACK: suppress implementation handling of variables just now + bool bak=target->implEnable; + target->implEnable=false; + recursiveBuild(target); + + //And restore it + target->implEnable=bak; + + #ifndef NDEBUG + target->initialized=true; + #endif + target->traitsInitialized = true; + } +} + template<> Global* Class<Global>::getInstance(bool construct, ASObject* const* args, const unsigned int argslen, Class_base* realClass) @@ -120,7 +151,7 @@ //Find the origin while(cur) { - var=cur->borrowedVariables.findObjVar(getSys()->getUniqueStringId(name),nsNameAndKind("",NAMESPACE),NO_CREATE_TRAIT,DECLARED_TRAIT); + var=cur->borrowedVariables.findObjVar(c->getSystemState()->getUniqueStringId(name),nsNameAndKind(c->getSystemState(),"",NAMESPACE),NO_CREATE_TRAIT,DECLARED_TRAIT); if(var) break; cur=cur->super.getPtr(); @@ -151,21 +182,21 @@ ASObject* Class<ASObject>::getInstance(bool construct, ASObject* const* args, const unsigned int argslen, Class_base* realClass) { - if (construct && args && argslen == 1 && this == Class<ASObject>::getClass()) + if (construct && args && argslen == 1 && this == Class<ASObject>::getClass(this->getSystemState())) { // Construction according to ECMA 15.2.2.1 switch(args[0]->getObjectType()) { case T_BOOLEAN: - return abstract_b(Boolean_concrete(args[0])); + return abstract_b(this->getSystemState(),Boolean_concrete(args[0])); case T_NUMBER: - return abstract_d(args[0]->toNumber()); + return abstract_d(this->getSystemState(),args[0]->toNumber()); case T_INTEGER: - return abstract_i(args[0]->toInt()); + return abstract_i(this->getSystemState(),args[0]->toInt()); case T_UINTEGER: - return abstract_ui(args[0]->toUInt()); + return abstract_ui(this->getSystemState(),args[0]->toUInt()); case T_STRING: - return abstract_s(args[0]->toString()); + return abstract_s(this->getSystemState(),args[0]->toString()); case T_FUNCTION: case T_OBJECT: args[0]->incRef(); @@ -181,20 +212,22 @@ handleConstruction(ret,args,argslen,true); return ret; } -Class<ASObject>* Class<ASObject>::getClass() +Class<ASObject>* Class<ASObject>::getClass(SystemState* sys) { uint32_t classId=ClassName<ASObject>::id; Class<ASObject>* ret=NULL; - Class_base** retAddr=&getSys()->builtinClasses[classId]; + SystemState* s = sys == NULL ? getSys() : sys; + Class_base** retAddr=&s->builtinClasses[classId]; if(*retAddr==NULL) { //Create the class QName name(ClassName<ASObject>::name,ClassName<ASObject>::ns); - MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(name.name); - ret=new (getSys()->unaccountedMemory) Class<ASObject>(name, memoryAccount); + MemoryAccount* memoryAccount = s->allocateMemoryAccount(name.name); + ret=new (s->unaccountedMemory) Class<ASObject>(name, memoryAccount); + ret->setSystemState(s); ret->incRef(); *retAddr=ret; - ret->prototype = _MNR(new_objectPrototype()); + ret->prototype = _MNR(new_objectPrototype(sys)); ASObject::sinit(ret); ret->initStandardProps(); }
View file
lightspark.tar.xz/src/scripting/class.h
Changed
@@ -48,10 +48,12 @@ ASObject* getInstance(bool construct, ASObject* const* args, const unsigned int argslen, Class_base* realClass); DictionaryTag const* tag; bool bindedToRoot; + void recursiveBuild(ASObject* target) const; public: Class_inherit(const QName& name, MemoryAccount* m); void finalize(); void buildInstanceTraits(ASObject* o) const; + void setupDeclaredTraits(ASObject *target) const; void bindToTag(DictionaryTag const* t) { tag=t; @@ -69,8 +71,8 @@ }; /* helper function: does Class<ASObject>::getInstances(), but solves forward declaration problem */ -ASObject* new_asobject(); -Prototype* new_objectPrototype(); +ASObject* new_asobject(SystemState *sys); +Prototype* new_objectPrototype(SystemState *sys); Prototype* new_functionPrototype(Class_base* functionClass, _NR<Prototype> p); Function_object* new_functionObject(_NR<ASObject> p); ObjectConstructor* new_objectConstructor(Class_base* cls,uint32_t length); @@ -140,9 +142,11 @@ } */ template<typename... Args> - static T* getInstanceS(Args&&... args) + static T* getInstanceS(SystemState* sys, Args&&... args) { - Class<T>* c=Class<T>::getClass(); + Class<T>* c=static_cast<Class<T>*>(sys->builtinClasses[ClassName<T>::id]); + if (!c) + c = getClass(sys); T* ret=newWithOptionalClass<T, sizeof...(Args)>::doNew(c, std::forward<Args>(args)...); c->setupDeclaredTraits(ret); ret->constructionComplete(); @@ -150,33 +154,36 @@ return ret; } // constructor without arguments - static T* getInstanceSNoArgs() + inline static T* getInstanceSNoArgs(SystemState* sys) { - Class<T>* c=Class<T>::getClass(); + Class<T>* c=static_cast<Class<T>*>(sys->builtinClasses[ClassName<T>::id]); + if (!c) + c = getClass(sys); T* ret = c->getObjectFromFreeList()->as<T>(); if (!ret) { ret=new (c->memoryAccount) T(c); } - c->setupDeclaredTraits(ret); + ret->setIsInitialized(); ret->constructionComplete(); ret->setConstructIndicator(); return ret; } - static Class<T>* getClass() + inline static Class<T>* getClass(SystemState* sys) { uint32_t classId=ClassName<T>::id; Class<T>* ret=NULL; - Class_base** retAddr=&getSys()->builtinClasses[classId]; + Class_base** retAddr= &sys->builtinClasses[classId]; if(*retAddr==NULL) { //Create the class QName name(ClassName<T>::name,ClassName<T>::ns); - MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(name.name); - ret=new (getSys()->unaccountedMemory) Class<T>(name, memoryAccount); + MemoryAccount* memoryAccount = sys->allocateMemoryAccount(name.name); + ret=new (sys->unaccountedMemory) Class<T>(name, memoryAccount); + ret->setSystemState(sys); ret->incRef(); *retAddr=ret; - ret->prototype = _MNR(new_objectPrototype()); + ret->prototype = _MNR(new_objectPrototype(sys)); T::sinit(ret); ret->initStandardProps(); @@ -186,9 +193,9 @@ return ret; } - static _R<Class<T>> getRef() + static _R<Class<T>> getRef(SystemState* sys) { - Class<T>* ret = getClass(); + Class<T>* ret = getClass(sys); ret->incRef(); return _MR(ret); } @@ -225,7 +232,7 @@ { number_t n = o->toNumber(); o->decRef(); - return abstract_d(n); + return abstract_d(o->getSystemState(),n); } template<> @@ -233,7 +240,7 @@ { uint32_t n = o->toUInt(); o->decRef(); - return abstract_ui(n); + return abstract_ui(o->getSystemState(),n); } template<> @@ -241,7 +248,7 @@ { int32_t n = o->toInt(); o->decRef(); - return abstract_i(n); + return abstract_i(o->getSystemState(),n); } template<> @@ -249,7 +256,7 @@ { bool n = Boolean_concrete(o); o->decRef(); - return abstract_b(n); + return abstract_b(o->getSystemState(),n); } template<> @@ -260,9 +267,9 @@ //This function is instantiated always because of inheritance ASObject* getInstance(bool construct, ASObject* const* args, const unsigned int argslen, Class_base* realClass=NULL); public: - static ASObject* getInstanceS() + static ASObject* getInstanceS(SystemState* sys) { - Class<ASObject>* c=Class<ASObject>::getClass(); + Class<ASObject>* c=Class<ASObject>::getClass(sys); ASObject* ret = c->getObjectFromFreeList(); if (!ret) ret=new (c->memoryAccount) ASObject(c); @@ -273,10 +280,10 @@ //return c->getInstance(true,NULL,0); } - static Class<ASObject>* getClass(); - static _R<Class<ASObject>> getRef() + static Class<ASObject>* getClass(SystemState* sys); + static _R<Class<ASObject>> getRef(SystemState* sys) { - Class<ASObject>* ret = getClass(); + Class<ASObject>* ret = getClass(sys); ret->incRef(); return _MR(ret); } @@ -292,7 +299,7 @@ { ASObject *ret; if(argslen==0 || args[0]->is<Null>() || args[0]->is<Undefined>()) - ret=Class<ASObject>::getInstanceS(); + ret=Class<ASObject>::getInstanceS(getSys()); else { args[0]->incRef(); @@ -330,17 +337,17 @@ } InterfaceClass(const QName& name, MemoryAccount* m):Class_base(name, m) { } public: - static InterfaceClass<T>* getClass() + static InterfaceClass<T>* getClass(SystemState* sys) { uint32_t classId=ClassName<T>::id; InterfaceClass<T>* ret=NULL; - Class_base** retAddr=&getSys()->builtinClasses[classId]; + Class_base** retAddr=&sys->builtinClasses[classId]; if(*retAddr==NULL) { //Create the class QName name(ClassName<T>::name,ClassName<T>::ns); - MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(name.name); - ret=new (getSys()->unaccountedMemory) InterfaceClass<T>(name, memoryAccount); + MemoryAccount* memoryAccount = sys->allocateMemoryAccount(name.name); + ret=new (sys->unaccountedMemory) InterfaceClass<T>(name, memoryAccount); ret->isInterface = true; ret->incRef(); *retAddr=ret; @@ -350,9 +357,9 @@ return ret; } - static _R<InterfaceClass<T>> getRef() + static _R<InterfaceClass<T>> getRef(SystemState* sys) { - InterfaceClass<T>* ret = getClass(); + InterfaceClass<T>* ret = getClass(sys); ret->incRef(); return _MR(ret); } @@ -417,7 +424,7 @@ if (o->is<Undefined>()) { o->decRef(); - return getSys()->getNullRef(); + return o->getSystemState()->getNullRef(); } else if ((o->is<Vector>() && o->as<Vector>()->sameType(this)) || o->is<Null>()) @@ -469,10 +476,10 @@ Class<T>* ret=NULL; if(it==appdomain->instantiatedTemplates.end()) //This class is not yet in the map, create it { - MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(instantiatedQName.name); - ret=new (getSys()->unaccountedMemory) TemplatedClass<T>(instantiatedQName,types,this,memoryAccount); + MemoryAccount* memoryAccount = appdomain->getSystemState()->allocateMemoryAccount(instantiatedQName.name); + ret=new (appdomain->getSystemState()->unaccountedMemory) TemplatedClass<T>(instantiatedQName,types,this,memoryAccount); appdomain->instantiatedTemplates.insert(std::make_pair(instantiatedQName,ret)); - ret->prototype = _MNR(new_objectPrototype()); + ret->prototype = _MNR(new_objectPrototype(appdomain->getSystemState())); T::sinit(ret); if(ret->super) ret->prototype->prevPrototype=ret->super->prototype; @@ -497,10 +504,10 @@ Class<T>* ret=NULL; if(it==appdomain->instantiatedTemplates.end()) //This class is not yet in the map, create it { - MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(qname.name); - ret=new (getSys()->unaccountedMemory) TemplatedClass<T>(qname,types,this,memoryAccount); + MemoryAccount* memoryAccount = appdomain->getSystemState()->allocateMemoryAccount(qname.name); + ret=new (appdomain->getSystemState()->unaccountedMemory) TemplatedClass<T>(qname,types,this,memoryAccount); appdomain->instantiatedTemplates.insert(std::make_pair(qname,ret)); - ret->prototype = _MNR(new_objectPrototype()); + ret->prototype = _MNR(new_objectPrototype(appdomain->getSystemState())); T::sinit(ret); if(ret->super) ret->prototype->prevPrototype=ret->super->prototype; @@ -513,36 +520,36 @@ return ret; } - static Ref<Class_base> getTemplateInstance(const Type* type,_NR<ApplicationDomain> appdomain) + static Ref<Class_base> getTemplateInstance(SystemState* sys,const Type* type,_NR<ApplicationDomain> appdomain) { std::vector<const Type*> t(1,type); - Template<T>* templ=getTemplate(); + Template<T>* templ=getTemplate(sys); Ref<Class_base> ret=_MR(templ->applyType(t, appdomain)); templ->decRef(); return ret; } - static Ref<Class_base> getTemplateInstance(const QName& qname, ABCContext* context,_NR<ApplicationDomain> appdomain) + static Ref<Class_base> getTemplateInstance(SystemState* sys,const QName& qname, ABCContext* context,_NR<ApplicationDomain> appdomain) { - Template<T>* templ=getTemplate(); + Template<T>* templ=getTemplate(sys); Ref<Class_base> ret=_MR(templ->applyTypeByQName(qname,appdomain)); ret->context = context; templ->decRef(); return ret; } - static T* getInstanceS(const Type* type,_NR<ApplicationDomain> appdomain) + static T* getInstanceS(SystemState* sys,const Type* type,_NR<ApplicationDomain> appdomain) { - return static_cast<T*>(getTemplateInstance(type,appdomain).getPtr()->getInstance(true,NULL,0)); + return static_cast<T*>(getTemplateInstance(sys,type,appdomain).getPtr()->getInstance(true,NULL,0)); } - static Template<T>* getTemplate(const QName& name) + static Template<T>* getTemplate(SystemState* sys,const QName& name) { - std::map<QName, Template_base*>::iterator it=getSys()->templates.find(name); + std::map<QName, Template_base*>::iterator it=sys->templates.find(name); Template<T>* ret=NULL; - if(it==getSys()->templates.end()) //This class is not yet in the map, create it + if(it==sys->templates.end()) //This class is not yet in the map, create it { - ret=new (getSys()->unaccountedMemory) Template<T>(name); - getSys()->templates.insert(std::make_pair(name,ret)); + ret=new (sys->unaccountedMemory) Template<T>(name); + sys->templates.insert(std::make_pair(name,ret)); } else ret=static_cast<Template<T>*>(it->second); @@ -551,9 +558,9 @@ return ret; } - static Template<T>* getTemplate() + static Template<T>* getTemplate(SystemState* sys) { - return getTemplate(QName(ClassName<T>::name,ClassName<T>::ns)); + return getTemplate(sys,QName(ClassName<T>::name,ClassName<T>::ns)); } };
View file
lightspark.tar.xz/src/scripting/flash/accessibility/flashaccessibility.cpp
Changed
@@ -66,7 +66,7 @@ void Accessibility::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_FINAL); - c->setVariableByQName("active","",abstract_b(false),CONSTANT_TRAIT); + c->setVariableByQName("active","",abstract_b(c->getSystemState(),false),CONSTANT_TRAIT); } ASFUNCTIONBODY(Accessibility,updateProperties)
View file
lightspark.tar.xz/src/scripting/flash/concurrent/Condition.cpp
Changed
@@ -30,10 +30,10 @@ void ASCondition::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL); - c->setVariableByQName("isSupported","",abstract_b(false),CONSTANT_TRAIT); - c->setDeclaredMethodByQName("notify","",Class<IFunction>::getFunction(_notify),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("notifyAll","",Class<IFunction>::getFunction(_notifyAll),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("wait","",Class<IFunction>::getFunction(_wait),NORMAL_METHOD,true); + c->setVariableByQName("isSupported","",abstract_b(c->getSystemState(),false),CONSTANT_TRAIT); + c->setDeclaredMethodByQName("notify","",Class<IFunction>::getFunction(c->getSystemState(),_notify),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("notifyAll","",Class<IFunction>::getFunction(c->getSystemState(),_notifyAll),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("wait","",Class<IFunction>::getFunction(c->getSystemState(),_wait),NORMAL_METHOD,true); REGISTER_GETTER(c,mutex); } @@ -76,6 +76,6 @@ ASCondition* th=obj->as<ASCondition>(); if (!th->mutex->getLockCount()) throwError<ASError>(kConditionCannotWait) ; - return abstract_b(true); + return abstract_b(obj->getSystemState(),true); }
View file
lightspark.tar.xz/src/scripting/flash/concurrent/Mutex.cpp
Changed
@@ -29,9 +29,9 @@ void ASMutex::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL); - c->setDeclaredMethodByQName("lock","",Class<IFunction>::getFunction(_lock),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("unlock","",Class<IFunction>::getFunction(_unlock),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("tryLock","",Class<IFunction>::getFunction(_trylock),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("lock","",Class<IFunction>::getFunction(c->getSystemState(),_lock),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("unlock","",Class<IFunction>::getFunction(c->getSystemState(),_unlock),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("tryLock","",Class<IFunction>::getFunction(c->getSystemState(),_trylock),NORMAL_METHOD,true); } ASFUNCTIONBODY(ASMutex,_constructor) @@ -55,6 +55,6 @@ ASFUNCTIONBODY(ASMutex,_trylock) { ASMutex* th=obj->as<ASMutex>(); - return abstract_b(th->mutex.trylock()); + return abstract_b(obj->getSystemState(),th->mutex.trylock()); }
View file
lightspark.tar.xz/src/scripting/flash/desktop/flashdesktop.cpp
Changed
@@ -28,8 +28,8 @@ void NativeApplication::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_FINAL | CLASS_SEALED); - c->setDeclaredMethodByQName("nativeApplication", "", Class<IFunction>::getFunction(_getNativeApplication), GETTER_METHOD, false); - c->setDeclaredMethodByQName("addEventListener", "", Class<IFunction>::getFunction(addEventListener), NORMAL_METHOD, true); + c->setDeclaredMethodByQName("nativeApplication", "", Class<IFunction>::getFunction(c->getSystemState(),_getNativeApplication), GETTER_METHOD, false); + c->setDeclaredMethodByQName("addEventListener", "", Class<IFunction>::getFunction(c->getSystemState(),addEventListener), NORMAL_METHOD, true); } void NativeApplication::buildTraits(ASObject* o) @@ -45,7 +45,7 @@ // Should actually be a Singleton ASFUNCTIONBODY(NativeApplication, _getNativeApplication) { - return Class<NativeApplication>::getInstanceS(); + return Class<NativeApplication>::getInstanceS(getSys()); } ASFUNCTIONBODY(NativeApplication, addEventListener) @@ -55,7 +55,7 @@ if (args[0]->toString() == "invoke") { th->incRef(); - getVm()->addEvent(_MR(th), _MR(Class<InvokeEvent>::getInstanceS())); + getVm(obj->getSystemState())->addEvent(_MR(th), _MR(Class<InvokeEvent>::getInstanceS(obj->getSystemState()))); } return NULL;
View file
lightspark.tar.xz/src/scripting/flash/display/BitmapData.cpp
Changed
@@ -58,38 +58,38 @@ void BitmapData::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); - c->addImplementedInterface(InterfaceClass<IBitmapDrawable>::getClass()); - c->setDeclaredMethodByQName("draw","",Class<IFunction>::getFunction(draw),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("dispose","",Class<IFunction>::getFunction(dispose),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getPixel","",Class<IFunction>::getFunction(getPixel),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getPixel32","",Class<IFunction>::getFunction(getPixel32),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setPixel","",Class<IFunction>::getFunction(setPixel),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setPixel32","",Class<IFunction>::getFunction(setPixel32),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("copyPixels","",Class<IFunction>::getFunction(copyPixels),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("fillRect","",Class<IFunction>::getFunction(fillRect),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("generateFilterRect","",Class<IFunction>::getFunction(generateFilterRect),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("hitTest","",Class<IFunction>::getFunction(hitTest),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("scroll","",Class<IFunction>::getFunction(scroll),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(clone),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("copyChannel","",Class<IFunction>::getFunction(copyChannel),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("lock","",Class<IFunction>::getFunction(lock),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("unlock","",Class<IFunction>::getFunction(unlock),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("floodFill","",Class<IFunction>::getFunction(floodFill),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("histogram","",Class<IFunction>::getFunction(histogram),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getColorBoundsRect","",Class<IFunction>::getFunction(getColorBoundsRect),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getPixels","",Class<IFunction>::getFunction(getPixels),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getVector","",Class<IFunction>::getFunction(getVector),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setPixels","",Class<IFunction>::getFunction(setPixels),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setVector","",Class<IFunction>::getFunction(setVector),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("colorTransform","",Class<IFunction>::getFunction(colorTransform),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("compare","",Class<IFunction>::getFunction(compare),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("applyFilter","",Class<IFunction>::getFunction(applyFilter),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("noise","",Class<IFunction>::getFunction(noise),NORMAL_METHOD,true); + c->addImplementedInterface(InterfaceClass<IBitmapDrawable>::getClass(c->getSystemState())); + c->setDeclaredMethodByQName("draw","",Class<IFunction>::getFunction(c->getSystemState(),draw),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("dispose","",Class<IFunction>::getFunction(c->getSystemState(),dispose),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getPixel","",Class<IFunction>::getFunction(c->getSystemState(),getPixel),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getPixel32","",Class<IFunction>::getFunction(c->getSystemState(),getPixel32),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setPixel","",Class<IFunction>::getFunction(c->getSystemState(),setPixel),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setPixel32","",Class<IFunction>::getFunction(c->getSystemState(),setPixel32),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("copyPixels","",Class<IFunction>::getFunction(c->getSystemState(),copyPixels),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("fillRect","",Class<IFunction>::getFunction(c->getSystemState(),fillRect),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("generateFilterRect","",Class<IFunction>::getFunction(c->getSystemState(),generateFilterRect),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("hitTest","",Class<IFunction>::getFunction(c->getSystemState(),hitTest),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("scroll","",Class<IFunction>::getFunction(c->getSystemState(),scroll),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(c->getSystemState(),clone),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("copyChannel","",Class<IFunction>::getFunction(c->getSystemState(),copyChannel),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("lock","",Class<IFunction>::getFunction(c->getSystemState(),lock),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("unlock","",Class<IFunction>::getFunction(c->getSystemState(),unlock),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("floodFill","",Class<IFunction>::getFunction(c->getSystemState(),floodFill),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("histogram","",Class<IFunction>::getFunction(c->getSystemState(),histogram),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getColorBoundsRect","",Class<IFunction>::getFunction(c->getSystemState(),getColorBoundsRect),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getPixels","",Class<IFunction>::getFunction(c->getSystemState(),getPixels),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getVector","",Class<IFunction>::getFunction(c->getSystemState(),getVector),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setPixels","",Class<IFunction>::getFunction(c->getSystemState(),setPixels),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setVector","",Class<IFunction>::getFunction(c->getSystemState(),setVector),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("colorTransform","",Class<IFunction>::getFunction(c->getSystemState(),colorTransform),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("compare","",Class<IFunction>::getFunction(c->getSystemState(),compare),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("applyFilter","",Class<IFunction>::getFunction(c->getSystemState(),applyFilter),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("noise","",Class<IFunction>::getFunction(c->getSystemState(),noise),NORMAL_METHOD,true); // properties - c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(_getHeight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("rect","",Class<IFunction>::getFunction(getRect),GETTER_METHOD,true); - c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(_getWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(c->getSystemState(),_getHeight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("rect","",Class<IFunction>::getFunction(c->getSystemState(),getRect),GETTER_METHOD,true); + c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(c->getSystemState(),_getWidth),GETTER_METHOD,true); REGISTER_GETTER(c,transparent); IBitmapDrawable::linkTraits(c); @@ -122,7 +122,7 @@ uint32_t fillColor; BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); ARG_UNPACK(width, 0)(height, 0)(transparent, true)(fillColor, 0xFFFFFFFF); ASObject::_constructor(obj,NULL,0); @@ -130,9 +130,9 @@ if(width==0 || height==0 || !th->pixels->isEmpty()) return NULL; if(width<0 || height<0) - throw Class<ArgumentError>::getInstanceS("invalid height or width", kInvalidArgumentError); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"invalid height or width", kInvalidArgumentError); if(width>8191 || height>8191) - throw Class<ArgumentError>::getInstanceS("invalid height or width", kInvalidArgumentError); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"invalid height or width", kInvalidArgumentError); uint32_t *pixelArray=new uint32_t[width*height]; uint32_t c=GUINT32_TO_BE(fillColor); // fromRGB expects big endian data @@ -190,7 +190,7 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); _NR<ASObject> drawable; _NR<Matrix> matrix; @@ -201,7 +201,7 @@ ARG_UNPACK (drawable) (matrix, NullRef) (ctransform, NullRef) (blendMode, NullRef) (clipRect, NullRef) (smoothing, false); - if(!drawable->getClass() || !drawable->getClass()->isSubClass(InterfaceClass<IBitmapDrawable>::getClass()) ) + if(!drawable->getClass() || !drawable->getClass()->isSubClass(InterfaceClass<IBitmapDrawable>::getClass(obj->getSystemState())) ) throwError<TypeError>(kCheckTypeFailedError, drawable->getClassName(), "IBitmapDrawable"); @@ -242,33 +242,33 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); int32_t x; int32_t y; ARG_UNPACK(x)(y); uint32_t pix=th->pixels->getPixel(x, y); - return abstract_ui(pix & 0xffffff); + return abstract_ui(obj->getSystemState(),pix & 0xffffff); } ASFUNCTIONBODY(BitmapData,getPixel32) { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); int32_t x; int32_t y; ARG_UNPACK(x)(y); uint32_t pix=th->pixels->getPixel(x, y); - return abstract_ui(pix); + return abstract_ui(obj->getSystemState(),pix); } ASFUNCTIONBODY(BitmapData,setPixel) { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); int32_t x; int32_t y; uint32_t color; @@ -283,7 +283,7 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); int32_t x; int32_t y; uint32_t color; @@ -298,8 +298,8 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); - Rectangle *rect=Class<Rectangle>::getInstanceS(); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); + Rectangle *rect=Class<Rectangle>::getInstanceS(obj->getSystemState()); rect->width=th->pixels->getWidth(); rect->height=th->pixels->getHeight(); return rect; @@ -309,16 +309,16 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); - return abstract_i(th->getHeight()); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); + return abstract_i(obj->getSystemState(),th->getHeight()); } ASFUNCTIONBODY(BitmapData,_getWidth) { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); - return abstract_i(th->getWidth()); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); + return abstract_i(obj->getSystemState(),th->getWidth()); } ASFUNCTIONBODY(BitmapData,fillRect) @@ -329,7 +329,7 @@ ARG_UNPACK(rect)(color); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); if (rect.isNull()) throwError<TypeError>(kNullPointerError, "rect"); @@ -350,7 +350,7 @@ ARG_UNPACK(source)(sourceRect)(destPoint)(alphaBitmapData, NullRef)(alphaPoint, NullRef)(mergeAlpha,false); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); if (source.isNull()) throwError<TypeError>(kNullPointerError, "source"); if (sourceRect.isNull()) @@ -374,8 +374,8 @@ LOG(LOG_NOT_IMPLEMENTED,"BitmapData::generateFilterRect is just a stub"); BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); - Rectangle *rect=Class<Rectangle>::getInstanceS(); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); + Rectangle *rect=Class<Rectangle>::getInstanceS(obj->getSystemState()); rect->width=th->pixels->getWidth(); rect->height=th->pixels->getHeight(); return rect; @@ -385,7 +385,7 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); _NR<Point> firstPoint; uint32_t firstAlphaThreshold; @@ -395,7 +395,7 @@ ARG_UNPACK (firstPoint) (firstAlphaThreshold) (secondObject) (secondBitmapDataPoint, NullRef) (secondAlphaThreshold,1); - if(!secondObject->getClass() || !secondObject->getClass()->isSubClass(Class<Point>::getClass())) + if(!secondObject->getClass() || !secondObject->getClass()->isSubClass(Class<Point>::getClass(obj->getSystemState()))) throwError<TypeError>(kCheckTypeFailedError, secondObject->getClassName(), "Point"); @@ -407,16 +407,16 @@ uint32_t pix=th->pixels->getPixel(secondPoint->getX()-firstPoint->getX(), secondPoint->getY()-firstPoint->getY()); if((pix>>24)>=firstAlphaThreshold) - return abstract_b(true); + return abstract_b(obj->getSystemState(),true); else - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); } ASFUNCTIONBODY(BitmapData,scroll) { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); int x; int y; @@ -432,16 +432,16 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); - return Class<BitmapData>::getInstanceS(*th); + return Class<BitmapData>::getInstanceS(obj->getSystemState(),*th); } ASFUNCTIONBODY(BitmapData,copyChannel) { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); _NR<BitmapData> source; _NR<Rectangle> sourceRect; @@ -500,7 +500,7 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); th->locked++; return NULL; @@ -510,7 +510,7 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); if (th->locked > 0) { @@ -526,7 +526,7 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); int32_t x; int32_t y; @@ -545,7 +545,7 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); _NR<Rectangle> inputRect; ARG_UNPACK (inputRect); @@ -570,14 +570,14 @@ } } - Vector *result = Template<Vector>::getInstanceS(Template<Vector>::getTemplateInstance(Class<Number>::getClass(),NullRef).getPtr(),NullRef); + Vector *result = Template<Vector>::getInstanceS(obj->getSystemState(),Template<Vector>::getTemplateInstance(obj->getSystemState(),Class<Number>::getClass(obj->getSystemState()),NullRef).getPtr(),NullRef); int channelOrder[4] = {2, 1, 0, 3}; // red, green, blue, alpha for (int j=0; j<4; j++) { - Vector *histogram = Template<Vector>::getInstanceS(Class<Number>::getClass(),NullRef); + Vector *histogram = Template<Vector>::getInstanceS(obj->getSystemState(),Class<Number>::getClass(obj->getSystemState()),NullRef); for (int level=0; level<256; level++) { - histogram->append(abstract_d(counts[channelOrder[j]][level])); + histogram->append(abstract_d(obj->getSystemState(),counts[channelOrder[j]][level])); } result->append(histogram); } @@ -589,7 +589,7 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); uint32_t mask; uint32_t color; @@ -620,7 +620,7 @@ } } - Rectangle *bounds = Class<Rectangle>::getInstanceS(); + Rectangle *bounds = Class<Rectangle>::getInstanceS(obj->getSystemState()); if ((xmin <= xmax) && (ymin <= ymax)) { bounds->x = xmin; @@ -635,7 +635,7 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); _NR<Rectangle> rect; ARG_UNPACK (rect); @@ -643,7 +643,7 @@ if (rect.isNull()) throwError<TypeError>(kNullPointerError, "rect"); - ByteArray *ba = Class<ByteArray>::getInstanceS(); + ByteArray *ba = Class<ByteArray>::getInstanceS(obj->getSystemState()); vector<uint32_t> pixelvec = th->pixels->getPixelVector(rect->getRect()); vector<uint32_t>::const_iterator it; for (it=pixelvec.begin(); it!=pixelvec.end(); ++it) @@ -655,7 +655,7 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); _NR<Rectangle> rect; ARG_UNPACK (rect); @@ -663,11 +663,11 @@ if (rect.isNull()) throwError<TypeError>(kNullPointerError, "rect"); - Vector *result = Template<Vector>::getInstanceS(Class<UInteger>::getClass(),NullRef); + Vector *result = Template<Vector>::getInstanceS(obj->getSystemState(),Class<UInteger>::getClass(obj->getSystemState()),NullRef); vector<uint32_t> pixelvec = th->pixels->getPixelVector(rect->getRect()); vector<uint32_t>::const_iterator it; for (it=pixelvec.begin(); it!=pixelvec.end(); ++it) - result->append(abstract_ui(*it)); + result->append(abstract_ui(obj->getSystemState(),*it)); return result; } @@ -675,7 +675,7 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); _NR<Rectangle> inputRect; _NR<ByteArray> inputByteArray; @@ -707,7 +707,7 @@ { BitmapData* th = obj->as<BitmapData>(); if(th->pixels.isNull()) - throw Class<ArgumentError>::getInstanceS("Disposed BitmapData", 2015); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Disposed BitmapData", 2015); _NR<Rectangle> inputRect; _NR<Vector> inputVector; @@ -798,9 +798,9 @@ throwError<TypeError>(kNullPointerError, "otherBitmapData"); if (th->getWidth() != otherBitmapData->getWidth()) - return abstract_d(-3); + return abstract_d(obj->getSystemState(),-3); if (th->getHeight() != otherBitmapData->getHeight()) - return abstract_d(-4); + return abstract_d(obj->getSystemState(),-4); RECT rect; rect.Xmin = 0; rect.Xmax = th->getWidth(); @@ -810,7 +810,7 @@ vector<uint32_t> pixelvec = th->pixels->getPixelVector(rect); vector<uint32_t> otherpixelvec = otherBitmapData->pixels->getPixelVector(rect); - BitmapData* res = Class<BitmapData>::getInstanceS(rect.Xmax,rect.Ymax); + BitmapData* res = Class<BitmapData>::getInstanceS(obj->getSystemState(),rect.Xmax,rect.Ymax); unsigned int i = 0; bool different = false; for (int32_t y=rect.Ymin; y<rect.Ymax; y++) @@ -836,7 +836,7 @@ } } if (!different) - return abstract_d(0); + return abstract_d(obj->getSystemState(),0); return res; }
View file
lightspark.tar.xz/src/scripting/flash/display/DisplayObject.cpp
Changed
@@ -98,7 +98,7 @@ DisplayObject::DisplayObject(Class_base* c):EventDispatcher(c),tx(0),ty(0),rotation(0), sx(1),sy(1),alpha(1.0),maskOf(),parent(),constructed(false),useLegacyMatrix(true),onStage(false), - visible(true),mask(),invalidateQueueNext(),loaderInfo(),filters(Class<Array>::getInstanceS()),cacheAsBitmap(false) + visible(true),mask(),invalidateQueueNext(),loaderInfo(),filters(Class<Array>::getInstanceS(c->getSystemState())),cacheAsBitmap(false) { name = tiny_string("instance") + Integer::toString(ATOMIC_INCREMENT(instanceCount)); } @@ -119,56 +119,56 @@ void DisplayObject::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructorNotInstantiatable, CLASS_SEALED); - c->setDeclaredMethodByQName("loaderInfo","",Class<IFunction>::getFunction(_getLoaderInfo),GETTER_METHOD,true); - c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(_getWidth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(_setWidth),SETTER_METHOD,true); - c->setDeclaredMethodByQName("scaleX","",Class<IFunction>::getFunction(_getScaleX),GETTER_METHOD,true); - c->setDeclaredMethodByQName("scaleX","",Class<IFunction>::getFunction(_setScaleX),SETTER_METHOD,true); - c->setDeclaredMethodByQName("scaleY","",Class<IFunction>::getFunction(_getScaleY),GETTER_METHOD,true); - c->setDeclaredMethodByQName("scaleY","",Class<IFunction>::getFunction(_setScaleY),SETTER_METHOD,true); - c->setDeclaredMethodByQName("scaleZ","",Class<IFunction>::getFunction(_getScaleZ),GETTER_METHOD,true); - c->setDeclaredMethodByQName("scaleZ","",Class<IFunction>::getFunction(_setScaleZ),SETTER_METHOD,true); - c->setDeclaredMethodByQName("x","",Class<IFunction>::getFunction(_getX),GETTER_METHOD,true); - c->setDeclaredMethodByQName("x","",Class<IFunction>::getFunction(_setX),SETTER_METHOD,true); - c->setDeclaredMethodByQName("y","",Class<IFunction>::getFunction(_getY),GETTER_METHOD,true); - c->setDeclaredMethodByQName("y","",Class<IFunction>::getFunction(_setY),SETTER_METHOD,true); - c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(_getHeight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(_setHeight),SETTER_METHOD,true); - c->setDeclaredMethodByQName("visible","",Class<IFunction>::getFunction(_getVisible),GETTER_METHOD,true); - c->setDeclaredMethodByQName("visible","",Class<IFunction>::getFunction(_setVisible),SETTER_METHOD,true); - c->setDeclaredMethodByQName("rotation","",Class<IFunction>::getFunction(_getRotation),GETTER_METHOD,true); - c->setDeclaredMethodByQName("rotation","",Class<IFunction>::getFunction(_setRotation),SETTER_METHOD,true); - c->setDeclaredMethodByQName("name","",Class<IFunction>::getFunction(_getName),GETTER_METHOD,true); - c->setDeclaredMethodByQName("name","",Class<IFunction>::getFunction(_setName),SETTER_METHOD,true); - c->setDeclaredMethodByQName("parent","",Class<IFunction>::getFunction(_getParent),GETTER_METHOD,true); - c->setDeclaredMethodByQName("root","",Class<IFunction>::getFunction(_getRoot),GETTER_METHOD,true); - c->setDeclaredMethodByQName("blendMode","",Class<IFunction>::getFunction(_getBlendMode),GETTER_METHOD,true); - c->setDeclaredMethodByQName("blendMode","",Class<IFunction>::getFunction(_setBlendMode),SETTER_METHOD,true); - c->setDeclaredMethodByQName("scale9Grid","",Class<IFunction>::getFunction(_getScale9Grid),GETTER_METHOD,true); - c->setDeclaredMethodByQName("scale9Grid","",Class<IFunction>::getFunction(undefinedFunction),SETTER_METHOD,true); - c->setDeclaredMethodByQName("stage","",Class<IFunction>::getFunction(_getStage),GETTER_METHOD,true); - c->setDeclaredMethodByQName("mask","",Class<IFunction>::getFunction(_getMask),GETTER_METHOD,true); - c->setDeclaredMethodByQName("mask","",Class<IFunction>::getFunction(_setMask),SETTER_METHOD,true); - c->setDeclaredMethodByQName("alpha","",Class<IFunction>::getFunction(_getAlpha),GETTER_METHOD,true); - c->setDeclaredMethodByQName("alpha","",Class<IFunction>::getFunction(_setAlpha),SETTER_METHOD,true); - c->setDeclaredMethodByQName("opaqueBackground","",Class<IFunction>::getFunction(undefinedFunction),GETTER_METHOD,true); - c->setDeclaredMethodByQName("opaqueBackground","",Class<IFunction>::getFunction(undefinedFunction),SETTER_METHOD,true); - c->setDeclaredMethodByQName("getBounds","",Class<IFunction>::getFunction(_getBounds),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getRect","",Class<IFunction>::getFunction(_getBounds),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("mouseX","",Class<IFunction>::getFunction(_getMouseX),GETTER_METHOD,true); - c->setDeclaredMethodByQName("mouseY","",Class<IFunction>::getFunction(_getMouseY),GETTER_METHOD,true); - c->setDeclaredMethodByQName("localToGlobal","",Class<IFunction>::getFunction(localToGlobal),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("globalToLocal","",Class<IFunction>::getFunction(globalToLocal),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("hitTestObject","",Class<IFunction>::getFunction(hitTestObject),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("hitTestPoint","",Class<IFunction>::getFunction(hitTestPoint),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("transform","",Class<IFunction>::getFunction(_getTransform),GETTER_METHOD,true); - c->setDeclaredMethodByQName("transform","",Class<IFunction>::getFunction(_setTransform),SETTER_METHOD,true); + c->setDeclaredMethodByQName("loaderInfo","",Class<IFunction>::getFunction(c->getSystemState(),_getLoaderInfo),GETTER_METHOD,true); + c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(c->getSystemState(),_getWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(c->getSystemState(),_setWidth),SETTER_METHOD,true); + c->setDeclaredMethodByQName("scaleX","",Class<IFunction>::getFunction(c->getSystemState(),_getScaleX),GETTER_METHOD,true); + c->setDeclaredMethodByQName("scaleX","",Class<IFunction>::getFunction(c->getSystemState(),_setScaleX),SETTER_METHOD,true); + c->setDeclaredMethodByQName("scaleY","",Class<IFunction>::getFunction(c->getSystemState(),_getScaleY),GETTER_METHOD,true); + c->setDeclaredMethodByQName("scaleY","",Class<IFunction>::getFunction(c->getSystemState(),_setScaleY),SETTER_METHOD,true); + c->setDeclaredMethodByQName("scaleZ","",Class<IFunction>::getFunction(c->getSystemState(),_getScaleZ),GETTER_METHOD,true); + c->setDeclaredMethodByQName("scaleZ","",Class<IFunction>::getFunction(c->getSystemState(),_setScaleZ),SETTER_METHOD,true); + c->setDeclaredMethodByQName("x","",Class<IFunction>::getFunction(c->getSystemState(),_getX),GETTER_METHOD,true); + c->setDeclaredMethodByQName("x","",Class<IFunction>::getFunction(c->getSystemState(),_setX),SETTER_METHOD,true); + c->setDeclaredMethodByQName("y","",Class<IFunction>::getFunction(c->getSystemState(),_getY),GETTER_METHOD,true); + c->setDeclaredMethodByQName("y","",Class<IFunction>::getFunction(c->getSystemState(),_setY),SETTER_METHOD,true); + c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(c->getSystemState(),_getHeight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(c->getSystemState(),_setHeight),SETTER_METHOD,true); + c->setDeclaredMethodByQName("visible","",Class<IFunction>::getFunction(c->getSystemState(),_getVisible),GETTER_METHOD,true); + c->setDeclaredMethodByQName("visible","",Class<IFunction>::getFunction(c->getSystemState(),_setVisible),SETTER_METHOD,true); + c->setDeclaredMethodByQName("rotation","",Class<IFunction>::getFunction(c->getSystemState(),_getRotation),GETTER_METHOD,true); + c->setDeclaredMethodByQName("rotation","",Class<IFunction>::getFunction(c->getSystemState(),_setRotation),SETTER_METHOD,true); + c->setDeclaredMethodByQName("name","",Class<IFunction>::getFunction(c->getSystemState(),_getName),GETTER_METHOD,true); + c->setDeclaredMethodByQName("name","",Class<IFunction>::getFunction(c->getSystemState(),_setName),SETTER_METHOD,true); + c->setDeclaredMethodByQName("parent","",Class<IFunction>::getFunction(c->getSystemState(),_getParent),GETTER_METHOD,true); + c->setDeclaredMethodByQName("root","",Class<IFunction>::getFunction(c->getSystemState(),_getRoot),GETTER_METHOD,true); + c->setDeclaredMethodByQName("blendMode","",Class<IFunction>::getFunction(c->getSystemState(),_getBlendMode),GETTER_METHOD,true); + c->setDeclaredMethodByQName("blendMode","",Class<IFunction>::getFunction(c->getSystemState(),_setBlendMode),SETTER_METHOD,true); + c->setDeclaredMethodByQName("scale9Grid","",Class<IFunction>::getFunction(c->getSystemState(),_getScale9Grid),GETTER_METHOD,true); + c->setDeclaredMethodByQName("scale9Grid","",Class<IFunction>::getFunction(c->getSystemState(),undefinedFunction),SETTER_METHOD,true); + c->setDeclaredMethodByQName("stage","",Class<IFunction>::getFunction(c->getSystemState(),_getStage),GETTER_METHOD,true); + c->setDeclaredMethodByQName("mask","",Class<IFunction>::getFunction(c->getSystemState(),_getMask),GETTER_METHOD,true); + c->setDeclaredMethodByQName("mask","",Class<IFunction>::getFunction(c->getSystemState(),_setMask),SETTER_METHOD,true); + c->setDeclaredMethodByQName("alpha","",Class<IFunction>::getFunction(c->getSystemState(),_getAlpha),GETTER_METHOD,true); + c->setDeclaredMethodByQName("alpha","",Class<IFunction>::getFunction(c->getSystemState(),_setAlpha),SETTER_METHOD,true); + c->setDeclaredMethodByQName("opaqueBackground","",Class<IFunction>::getFunction(c->getSystemState(),undefinedFunction),GETTER_METHOD,true); + c->setDeclaredMethodByQName("opaqueBackground","",Class<IFunction>::getFunction(c->getSystemState(),undefinedFunction),SETTER_METHOD,true); + c->setDeclaredMethodByQName("getBounds","",Class<IFunction>::getFunction(c->getSystemState(),_getBounds),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getRect","",Class<IFunction>::getFunction(c->getSystemState(),_getBounds),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("mouseX","",Class<IFunction>::getFunction(c->getSystemState(),_getMouseX),GETTER_METHOD,true); + c->setDeclaredMethodByQName("mouseY","",Class<IFunction>::getFunction(c->getSystemState(),_getMouseY),GETTER_METHOD,true); + c->setDeclaredMethodByQName("localToGlobal","",Class<IFunction>::getFunction(c->getSystemState(),localToGlobal),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("globalToLocal","",Class<IFunction>::getFunction(c->getSystemState(),globalToLocal),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("hitTestObject","",Class<IFunction>::getFunction(c->getSystemState(),hitTestObject),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("hitTestPoint","",Class<IFunction>::getFunction(c->getSystemState(),hitTestPoint),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("transform","",Class<IFunction>::getFunction(c->getSystemState(),_getTransform),GETTER_METHOD,true); + c->setDeclaredMethodByQName("transform","",Class<IFunction>::getFunction(c->getSystemState(),_setTransform),SETTER_METHOD,true); REGISTER_GETTER_SETTER(c,accessibilityProperties); REGISTER_GETTER_SETTER(c,cacheAsBitmap); REGISTER_GETTER_SETTER(c,filters); REGISTER_GETTER_SETTER(c,scrollRect); - c->addImplementedInterface(InterfaceClass<IBitmapDrawable>::getClass()); + c->addImplementedInterface(InterfaceClass<IBitmapDrawable>::getClass(c->getSystemState())); IBitmapDrawable::linkTraits(c); } @@ -191,7 +191,7 @@ LOG(LOG_NOT_IMPLEMENTED, "DisplayObject::transform is a stub and does not reflect the real display state"); th->incRef(); - return Class<Transform>::getInstanceS(_MR(th)); + return Class<Transform>::getInstanceS(obj->getSystemState(),_MR(th)); } ASFUNCTIONBODY(DisplayObject,_setTransform) @@ -217,7 +217,7 @@ } } if(mustInvalidate && onStage) - requestInvalidation(getSys()); + requestInvalidation(getSystemState()); } void DisplayObject::setLegacyMatrix(const lightspark::MATRIX& m) @@ -250,7 +250,7 @@ } if(mustInvalidate && onStage) - requestInvalidation(getSys()); + requestInvalidation(getSystemState()); } MATRIX DisplayObject::getConcatenatedMatrix() const @@ -392,8 +392,8 @@ //Our stage condition changed, send event onStage=staged; if(staged==true) - requestInvalidation(getSys()); - if(getVm()==NULL) + requestInvalidation(getSystemState()); + if(getVm(getSystemState())==NULL) return; /*NOTE: By tests we can assert that added/addedToStage is dispatched immediately when addChild is called. On the other hand setOnStage may @@ -405,20 +405,20 @@ if(onStage==true) { this->incRef(); - _R<Event> e=_MR(Class<Event>::getInstanceS("addedToStage")); + _R<Event> e=_MR(Class<Event>::getInstanceS(getSystemState(),"addedToStage")); if(isVmThread()) ABCVm::publicHandleEvent(_MR(this),e); else - getVm()->addEvent(_MR(this),e); + getVm(getSystemState())->addEvent(_MR(this),e); } else if(onStage==false) { this->incRef(); - _R<Event> e=_MR(Class<Event>::getInstanceS("removedFromStage")); + _R<Event> e=_MR(Class<Event>::getInstanceS(getSystemState(),"removedFromStage")); if(isVmThread()) ABCVm::publicHandleEvent(_MR(this),e); else - getVm()->addEvent(_MR(this),e); + getVm(getSystemState())->addEvent(_MR(this),e); } } } @@ -432,21 +432,21 @@ * stored value even if it is outside the [0, 1] range. */ th->alpha=val; if(th->onStage) - th->requestInvalidation(getSys()); + th->requestInvalidation(obj->getSystemState()); return NULL; } ASFUNCTIONBODY(DisplayObject,_getAlpha) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return abstract_d(th->alpha); + return abstract_d(obj->getSystemState(),th->alpha); } ASFUNCTIONBODY(DisplayObject,_getMask) { DisplayObject* th=Class<DisplayObject>::cast(obj); if(th->mask.isNull()) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); th->mask->incRef(); return th->mask.getPtr(); @@ -456,7 +456,7 @@ { DisplayObject* th=Class<DisplayObject>::cast(obj); assert_and_throw(argslen==1); - if(args[0] && args[0]->getClass() && args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass())) + if(args[0] && args[0]->getClass() && args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass(obj->getSystemState()))) { //We received a valid mask object DisplayObject* newMask=Class<DisplayObject>::cast(args[0]); @@ -472,7 +472,7 @@ ASFUNCTIONBODY(DisplayObject,_getScaleX) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return abstract_d(th->sx); + return abstract_d(obj->getSystemState(),th->sx); } void DisplayObject::setScaleX(number_t val) @@ -482,7 +482,7 @@ { sx=val; if(onStage) - requestInvalidation(getSys()); + requestInvalidation(getSystemState()); } } @@ -501,7 +501,7 @@ ASFUNCTIONBODY(DisplayObject,_getScaleY) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return abstract_d(th->sy); + return abstract_d(obj->getSystemState(),th->sy); } void DisplayObject::setScaleY(number_t val) @@ -511,7 +511,7 @@ { sy=val; if(onStage) - requestInvalidation(getSys()); + requestInvalidation(getSystemState()); } } @@ -530,7 +530,7 @@ ASFUNCTIONBODY(DisplayObject,_getScaleZ) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return abstract_d(th->sz); + return abstract_d(obj->getSystemState(),th->sz); } void DisplayObject::setScaleZ(number_t val) @@ -540,7 +540,7 @@ { sz=val; if(onStage) - requestInvalidation(getSys()); + requestInvalidation(getSystemState()); } } @@ -560,7 +560,7 @@ ASFUNCTIONBODY(DisplayObject,_getX) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return abstract_d(th->tx); + return abstract_d(obj->getSystemState(),th->tx); } void DisplayObject::setX(number_t val) @@ -573,7 +573,7 @@ { tx=val; if(onStage) - requestInvalidation(getSys()); + requestInvalidation(getSystemState()); } } @@ -587,7 +587,7 @@ { ty=val; if(onStage) - requestInvalidation(getSys()); + requestInvalidation(getSystemState()); } } @@ -603,7 +603,7 @@ ASFUNCTIONBODY(DisplayObject,_getY) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return abstract_d(th->ty); + return abstract_d(obj->getSystemState(),th->ty); } ASFUNCTIONBODY(DisplayObject,_setY) @@ -621,7 +621,7 @@ assert_and_throw(argslen==1); if(args[0]->is<Undefined>() || args[0]->is<Null>()) - return Class<Rectangle>::getInstanceS(); + return Class<Rectangle>::getInstanceS(obj->getSystemState()); if (!args[0]->is<DisplayObject>()) LOG(LOG_ERROR,"DisplayObject.getBounds invalid type:"<<args[0]->toDebugString()); assert_and_throw(args[0]->is<DisplayObject>()); @@ -644,7 +644,7 @@ m = targetMatrix.getInverted().multiplyMatrix(m); } - Rectangle* ret=Class<Rectangle>::getInstanceS(); + Rectangle* ret=Class<Rectangle>::getInstanceS(obj->getSystemState()); number_t x1,x2,y1,y2; bool r=th->getBounds(x1,x2,y1,y2, m); if(r) @@ -675,7 +675,7 @@ * the main class should have non-null loaderInfo. */ _NR<RootMovieClip> r=th->getRoot(); if(r.isNull() || r->loaderInfo.isNull()) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); r->loaderInfo->incRef(); return r->loaderInfo.getPtr(); @@ -686,7 +686,7 @@ DisplayObject* th=static_cast<DisplayObject*>(obj); _NR<Stage> ret=th->getStage(); if(ret.isNull()) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); ret->incRef(); return ret.getPtr(); @@ -695,13 +695,13 @@ ASFUNCTIONBODY(DisplayObject,_getScale9Grid) { //DisplayObject* th=static_cast<DisplayObject*>(obj); - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); } ASFUNCTIONBODY(DisplayObject,_getBlendMode) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return Class<ASString>::getInstanceS(th->blendMode); + return abstract_s(obj->getSystemState(),th->blendMode); } ASFUNCTIONBODY(DisplayObject,_setBlendMode) { @@ -743,7 +743,7 @@ th->localToGlobal(pt->getX(), pt->getY(), tempx, tempy); - return Class<Point>::getInstanceS(tempx, tempy); + return Class<Point>::getInstanceS(obj->getSystemState(),tempx, tempy); } ASFUNCTIONBODY(DisplayObject,globalToLocal) @@ -757,7 +757,7 @@ th->globalToLocal(pt->getX(), pt->getY(), tempx, tempy); - return Class<Point>::getInstanceS(tempx, tempy); + return Class<Point>::getInstanceS(obj->getSystemState(),tempx, tempy); } ASFUNCTIONBODY(DisplayObject,_setRotation) @@ -773,7 +773,7 @@ { th->rotation=val; if(th->onStage) - th->requestInvalidation(getSys()); + th->requestInvalidation(obj->getSystemState()); } return NULL; } @@ -789,7 +789,7 @@ ASFUNCTIONBODY(DisplayObject,_getName) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return Class<ASString>::getInstanceS(th->name); + return abstract_s(obj->getSystemState(),th->name); } void DisplayObject::setParent(_NR<DisplayObjectContainer> p) @@ -798,7 +798,7 @@ { parent=p; if(onStage) - requestInvalidation(getSys()); + requestInvalidation(getSystemState()); } } @@ -806,7 +806,7 @@ { DisplayObject* th=static_cast<DisplayObject*>(obj); if(th->parent.isNull()) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); th->parent->incRef(); return th->parent.getPtr(); @@ -817,7 +817,7 @@ DisplayObject* th=static_cast<DisplayObject*>(obj); _NR<RootMovieClip> ret=th->getRoot(); if(ret.isNull()) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); ret->incRef(); return ret.getPtr(); @@ -826,7 +826,7 @@ ASFUNCTIONBODY(DisplayObject,_getRotation) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return abstract_d(th->rotation); + return abstract_d(obj->getSystemState(),th->rotation); } ASFUNCTIONBODY(DisplayObject,_setVisible) @@ -840,7 +840,7 @@ ASFUNCTIONBODY(DisplayObject,_getVisible) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return abstract_b(th->visible); + return abstract_b(obj->getSystemState(),th->visible); } number_t DisplayObject::computeHeight() @@ -878,7 +878,7 @@ ASFUNCTIONBODY(DisplayObject,_getWidth) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return abstract_d(th->computeWidth()); + return abstract_d(obj->getSystemState(),th->computeWidth()); } ASFUNCTIONBODY(DisplayObject,_setWidth) @@ -906,7 +906,7 @@ ASFUNCTIONBODY(DisplayObject,_getHeight) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return abstract_d(th->computeHeight()); + return abstract_d(obj->getSystemState(),th->computeHeight()); } ASFUNCTIONBODY(DisplayObject,_setHeight) @@ -933,19 +933,19 @@ Vector2f DisplayObject::getLocalMousePos() { - return getConcatenatedMatrix().getInverted().multiply2D(getSys()->getInputThread()->getMousePos()); + return getConcatenatedMatrix().getInverted().multiply2D(getSystemState()->getInputThread()->getMousePos()); } ASFUNCTIONBODY(DisplayObject,_getMouseX) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return abstract_d(th->getLocalMousePos().x); + return abstract_d(obj->getSystemState(),th->getLocalMousePos().x); } ASFUNCTIONBODY(DisplayObject,_getMouseY) { DisplayObject* th=static_cast<DisplayObject*>(obj); - return abstract_d(th->getLocalMousePos().y); + return abstract_d(obj->getSystemState(),th->getLocalMousePos().y); } _NR<DisplayObject> DisplayObject::hitTest(_NR<DisplayObject> last, number_t x, number_t y, HIT_TYPE type) @@ -995,13 +995,13 @@ if(!parent.isNull()) { this->incRef(); - _R<Event> e=_MR(Class<Event>::getInstanceS("added")); + _R<Event> e=_MR(Class<Event>::getInstanceS(getSystemState(),"added")); ABCVm::publicHandleEvent(_MR(this),e); } if(onStage) { this->incRef(); - _R<Event> e=_MR(Class<Event>::getInstanceS("addedToStage")); + _R<Event> e=_MR(Class<Event>::getInstanceS(getSystemState(),"addedToStage")); ABCVm::publicHandleEvent(_MR(this),e); } } @@ -1016,7 +1016,7 @@ loaderInfo->objectHasLoaded(_MR(this)); } if(onStage) - requestInvalidation(getSys()); + requestInvalidation(getSystemState()); } void DisplayObject::gatherMaskIDrawables(std::vector<IDrawable::MaskData>& masks) const @@ -1056,14 +1056,14 @@ bool ret=mask->getBounds(xmin,xmax,ymin,ymax,mask->getConcatenatedMatrix()); if(ret==false) return; - _R<BitmapData> data(Class<BitmapData>::getInstanceS(xmax-xmin,ymax-ymin)); + _R<BitmapData> data(Class<BitmapData>::getInstanceS(getSystemState(),xmax-xmin,ymax-ymin)); //Forge a matrix. It must contain the right rotation and scaling while translation //only compensate for the xmin/ymin offset MATRIX m=mask->getConcatenatedMatrix(); m.x0 -= xmin; m.y0 -= ymin; data->drawDisplayObject(mask.getPtr(), m); - _R<Bitmap> bmp(Class<Bitmap>::getInstanceS(data)); + _R<Bitmap> bmp(Class<Bitmap>::getInstanceS(getSystemState(),data)); //The created bitmap is already correctly scaled and rotated //Just apply the needed offset @@ -1109,7 +1109,7 @@ { number_t x1, x2, y1, y2; if (!boundsRect(x1, x2, y1, y2)) - return abstract_b(false); + return abstract_b(getSystemState(),false); localToGlobal(x1, y1, x1, y1); localToGlobal(x2, y2, x2, y2); @@ -1132,18 +1132,18 @@ number_t xmin, xmax, ymin, ymax; if (!th->boundsRectGlobal(xmin, xmax, ymin, ymax)) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); number_t xmin2, xmax2, ymin2, ymax2; if (!another->boundsRectGlobal(xmin2, xmax2, ymin2, ymax2)) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); number_t intersect_xmax = dmin(xmax, xmax2); number_t intersect_xmin = dmax(xmin, xmin2); number_t intersect_ymax = dmin(ymax, ymax2); number_t intersect_ymin = dmax(ymin, ymin2); - return abstract_b((intersect_xmax > intersect_xmin) && + return abstract_b(obj->getSystemState(),(intersect_xmax > intersect_xmin) && (intersect_ymax > intersect_ymin)); } @@ -1157,18 +1157,18 @@ number_t xmin, xmax, ymin, ymax; if (!th->boundsRectGlobal(xmin, xmax, ymin, ymax)) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); bool insideBoundingBox = (xmin <= x) && (x < xmax) && (ymin <= y) && (y < ymax); if (!shapeFlag) { - return abstract_b(insideBoundingBox); + return abstract_b(obj->getSystemState(),insideBoundingBox); } else { if (!insideBoundingBox) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); number_t localX; number_t localY; @@ -1180,6 +1180,6 @@ _NR<DisplayObject> hit = th->hitTest(_MR(th), localX, localY, HIT_TYPE::GENERIC_HIT_INVISIBLE); - return abstract_b(hit.getPtr() == th); + return abstract_b(obj->getSystemState(),hit.getPtr() == th); } }
View file
lightspark.tar.xz/src/scripting/flash/display/Graphics.cpp
Changed
@@ -36,27 +36,27 @@ void Graphics::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); - c->setDeclaredMethodByQName("clear","",Class<IFunction>::getFunction(clear),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("copyFrom","",Class<IFunction>::getFunction(copyFrom),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("drawRect","",Class<IFunction>::getFunction(drawRect),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("drawRoundRect","",Class<IFunction>::getFunction(drawRoundRect),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("drawRoundRectComplex","",Class<IFunction>::getFunction(drawRoundRectComplex),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("drawCircle","",Class<IFunction>::getFunction(drawCircle),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("drawEllipse","",Class<IFunction>::getFunction(drawEllipse),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("drawPath","",Class<IFunction>::getFunction(drawPath),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("drawTriangles","",Class<IFunction>::getFunction(drawTriangles),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("drawGraphicsData","",Class<IFunction>::getFunction(drawGraphicsData),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("moveTo","",Class<IFunction>::getFunction(moveTo),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("curveTo","",Class<IFunction>::getFunction(curveTo),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("cubicCurveTo","",Class<IFunction>::getFunction(cubicCurveTo),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("lineTo","",Class<IFunction>::getFunction(lineTo),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("lineBitmapStyle","",Class<IFunction>::getFunction(lineBitmapStyle),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("lineGradientStyle","",Class<IFunction>::getFunction(lineGradientStyle),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("lineStyle","",Class<IFunction>::getFunction(lineStyle),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("beginFill","",Class<IFunction>::getFunction(beginFill),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("beginGradientFill","",Class<IFunction>::getFunction(beginGradientFill),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("beginBitmapFill","",Class<IFunction>::getFunction(beginBitmapFill),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("endFill","",Class<IFunction>::getFunction(endFill),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("clear","",Class<IFunction>::getFunction(c->getSystemState(),clear),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("copyFrom","",Class<IFunction>::getFunction(c->getSystemState(),copyFrom),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("drawRect","",Class<IFunction>::getFunction(c->getSystemState(),drawRect),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("drawRoundRect","",Class<IFunction>::getFunction(c->getSystemState(),drawRoundRect),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("drawRoundRectComplex","",Class<IFunction>::getFunction(c->getSystemState(),drawRoundRectComplex),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("drawCircle","",Class<IFunction>::getFunction(c->getSystemState(),drawCircle),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("drawEllipse","",Class<IFunction>::getFunction(c->getSystemState(),drawEllipse),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("drawPath","",Class<IFunction>::getFunction(c->getSystemState(),drawPath),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("drawTriangles","",Class<IFunction>::getFunction(c->getSystemState(),drawTriangles),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("drawGraphicsData","",Class<IFunction>::getFunction(c->getSystemState(),drawGraphicsData),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("moveTo","",Class<IFunction>::getFunction(c->getSystemState(),moveTo),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("curveTo","",Class<IFunction>::getFunction(c->getSystemState(),curveTo),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("cubicCurveTo","",Class<IFunction>::getFunction(c->getSystemState(),cubicCurveTo),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("lineTo","",Class<IFunction>::getFunction(c->getSystemState(),lineTo),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("lineBitmapStyle","",Class<IFunction>::getFunction(c->getSystemState(),lineBitmapStyle),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("lineGradientStyle","",Class<IFunction>::getFunction(c->getSystemState(),lineGradientStyle),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("lineStyle","",Class<IFunction>::getFunction(c->getSystemState(),lineStyle),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("beginFill","",Class<IFunction>::getFunction(c->getSystemState(),beginFill),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("beginGradientFill","",Class<IFunction>::getFunction(c->getSystemState(),beginGradientFill),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("beginBitmapFill","",Class<IFunction>::getFunction(c->getSystemState(),beginBitmapFill),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("endFill","",Class<IFunction>::getFunction(c->getSystemState(),endFill),NORMAL_METHOD,true); } void Graphics::buildTraits(ASObject* o) @@ -83,7 +83,7 @@ Graphics* th=static_cast<Graphics*>(obj); th->checkAndSetScaling(); th->owner->tokens.clear(); - th->owner->owner->requestInvalidation(getSys()); + th->owner->owner->requestInvalidation(obj->getSystemState()); return NULL; } @@ -110,7 +110,7 @@ int y=args[1]->toInt(); th->owner->tokens.emplace_back(GeomToken(STRAIGHT, Vector2(x, y))); - th->owner->owner->requestInvalidation(getSys()); + th->owner->owner->requestInvalidation(obj->getSystemState()); return NULL; } @@ -130,7 +130,7 @@ th->owner->tokens.emplace_back(GeomToken(CURVE_QUADRATIC, Vector2(controlX, controlY), Vector2(anchorX, anchorY))); - th->owner->owner->requestInvalidation(getSys()); + th->owner->owner->requestInvalidation(obj->getSystemState()); return NULL; } @@ -154,7 +154,7 @@ Vector2(control1X, control1Y), Vector2(control2X, control2Y), Vector2(anchorX, anchorY))); - th->owner->owner->requestInvalidation(getSys()); + th->owner->owner->requestInvalidation(obj->getSystemState()); return NULL; } @@ -243,7 +243,7 @@ // C -> D th->owner->tokens.emplace_back(GeomToken(STRAIGHT, Vector2(x+width, y+height-ellipseHeight))); - th->owner->owner->requestInvalidation(getSys()); + th->owner->owner->requestInvalidation(obj->getSystemState()); return NULL; } @@ -270,7 +270,7 @@ th->owner->tokens.emplace_back(GeomToken(STRAIGHT, c)); th->owner->tokens.emplace_back(GeomToken(STRAIGHT, d)); th->owner->tokens.emplace_back(GeomToken(STRAIGHT, a)); - th->owner->owner->requestInvalidation(getSys()); + th->owner->owner->requestInvalidation(obj->getSystemState()); return NULL; } @@ -314,7 +314,7 @@ Vector2(x+radius, y-kappa ), Vector2(x+radius, y ))); - th->owner->owner->requestInvalidation(getSys()); + th->owner->owner->requestInvalidation(obj->getSystemState()); return NULL; } @@ -360,7 +360,7 @@ Vector2(left+width, top+height/2-ykappa), Vector2(left+width, top+height/2))); - th->owner->owner->requestInvalidation(getSys()); + th->owner->owner->requestInvalidation(obj->getSystemState()); return NULL; } @@ -386,7 +386,7 @@ th->owner->tokens.emplace_back(GeomToken(STRAIGHT, c)); th->owner->tokens.emplace_back(GeomToken(STRAIGHT, d)); th->owner->tokens.emplace_back(GeomToken(STRAIGHT, a)); - th->owner->owner->requestInvalidation(getSys()); + th->owner->owner->requestInvalidation(obj->getSystemState()); return NULL; } @@ -406,7 +406,7 @@ pathToTokens(commands, data, winding, th->owner->tokens); - th->owner->owner->requestInvalidation(getSys()); + th->owner->owner->requestInvalidation(obj->getSystemState()); return NULL; } @@ -420,8 +420,8 @@ if (winding != "evenOdd") LOG(LOG_NOT_IMPLEMENTED, "Only event-odd winding implemented in Graphics.drawPath"); - _R<Number> zeroRef = _MR(Class<Number>::getInstanceS(0)); - Number *zero = zeroRef.getPtr(); + _R<ASObject> zeroRef = _MR(abstract_d(commands->getSystemState(),0)); + ASObject *zero = zeroRef.getPtr(); int k = 0; for (unsigned int i=0; i<commands->size(); i++) @@ -547,7 +547,7 @@ ARG_UNPACK (vertices) (indices, NullRef) (uvtData, NullRef) (culling, "none"); drawTrianglesToTokens(vertices, indices, uvtData, culling, th->owner->tokens); - th->owner->owner->requestInvalidation(getSys()); + th->owner->owner->requestInvalidation(obj->getSystemState()); return NULL; } @@ -683,7 +683,7 @@ graphElement->appendToTokens(th->owner->tokens); } - th->owner->owner->requestInvalidation(getSys()); + th->owner->owner->requestInvalidation(obj->getSystemState()); return NULL; }
View file
lightspark.tar.xz/src/scripting/flash/display/GraphicsBitmapFill.cpp
Changed
@@ -39,9 +39,9 @@ REGISTER_GETTER_SETTER(c, repeat); REGISTER_GETTER_SETTER(c, smooth); - c->addImplementedInterface(InterfaceClass<IGraphicsFill>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsFill>::getClass(c->getSystemState())); IGraphicsFill::linkTraits(c); - c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass(c->getSystemState())); IGraphicsData::linkTraits(c); }
View file
lightspark.tar.xz/src/scripting/flash/display/GraphicsEndFill.cpp
Changed
@@ -30,9 +30,9 @@ void GraphicsEndFill::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); - c->addImplementedInterface(InterfaceClass<IGraphicsFill>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsFill>::getClass(c->getSystemState())); IGraphicsFill::linkTraits(c); - c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass(c->getSystemState())); IGraphicsData::linkTraits(c); }
View file
lightspark.tar.xz/src/scripting/flash/display/GraphicsGradientFill.cpp
Changed
@@ -45,9 +45,9 @@ REGISTER_GETTER_SETTER(c, spreadMethod); REGISTER_GETTER_SETTER(c, type); - c->addImplementedInterface(InterfaceClass<IGraphicsFill>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsFill>::getClass(c->getSystemState())); IGraphicsFill::linkTraits(c); - c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass(c->getSystemState())); IGraphicsData::linkTraits(c); }
View file
lightspark.tar.xz/src/scripting/flash/display/GraphicsPath.cpp
Changed
@@ -36,15 +36,15 @@ REGISTER_GETTER_SETTER(c, commands); REGISTER_GETTER_SETTER(c, data); REGISTER_GETTER_SETTER(c, winding); - c->setDeclaredMethodByQName("curveTo","",Class<IFunction>::getFunction(curveTo),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("lineTo","",Class<IFunction>::getFunction(lineTo),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("moveTo","",Class<IFunction>::getFunction(moveTo),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("wideLineTo","",Class<IFunction>::getFunction(wideLineTo),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("wideMoveTo","",Class<IFunction>::getFunction(wideMoveTo),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("curveTo","",Class<IFunction>::getFunction(c->getSystemState(),curveTo),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("lineTo","",Class<IFunction>::getFunction(c->getSystemState(),lineTo),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("moveTo","",Class<IFunction>::getFunction(c->getSystemState(),moveTo),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("wideLineTo","",Class<IFunction>::getFunction(c->getSystemState(),wideLineTo),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("wideMoveTo","",Class<IFunction>::getFunction(c->getSystemState(),wideMoveTo),NORMAL_METHOD,true); - c->addImplementedInterface(InterfaceClass<IGraphicsPath>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsPath>::getClass(c->getSystemState())); IGraphicsPath::linkTraits(c); - c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass(c->getSystemState())); IGraphicsData::linkTraits(c); } @@ -79,9 +79,9 @@ void GraphicsPath::ensureValid() { if (commands.isNull()) - commands = _MNR(Template<Vector>::getInstanceS(Class<Integer>::getClass(),NullRef)); + commands = _MNR(Template<Vector>::getInstanceS(getSystemState(),Class<Integer>::getClass(getSystemState()),NullRef)); if (data.isNull()) - data = _MNR(Template<Vector>::getInstanceS(Class<Number>::getClass(),NullRef)); + data = _MNR(Template<Vector>::getInstanceS(getSystemState(),Class<Number>::getClass(getSystemState()),NullRef)); } ASFUNCTIONBODY(GraphicsPath, curveTo) @@ -94,11 +94,11 @@ ARG_UNPACK (cx) (cy) (ax) (ay); th->ensureValid(); - th->commands->append(abstract_i(GraphicsPathCommand::CURVE_TO)); - th->data->append(abstract_d(ax)); - th->data->append(abstract_d(ay)); - th->data->append(abstract_d(cx)); - th->data->append(abstract_d(cy)); + th->commands->append(abstract_i(obj->getSystemState(),GraphicsPathCommand::CURVE_TO)); + th->data->append(abstract_d(obj->getSystemState(),ax)); + th->data->append(abstract_d(obj->getSystemState(),ay)); + th->data->append(abstract_d(obj->getSystemState(),cx)); + th->data->append(abstract_d(obj->getSystemState(),cy)); return NULL; } @@ -111,9 +111,9 @@ ARG_UNPACK (x) (y); th->ensureValid(); - th->commands->append(abstract_i(GraphicsPathCommand::LINE_TO)); - th->data->append(abstract_d(x)); - th->data->append(abstract_d(y)); + th->commands->append(abstract_i(obj->getSystemState(),GraphicsPathCommand::LINE_TO)); + th->data->append(abstract_d(obj->getSystemState(),x)); + th->data->append(abstract_d(obj->getSystemState(),y)); return NULL; } @@ -126,9 +126,9 @@ ARG_UNPACK (x) (y); th->ensureValid(); - th->commands->append(abstract_i(GraphicsPathCommand::MOVE_TO)); - th->data->append(abstract_d(x)); - th->data->append(abstract_d(y)); + th->commands->append(abstract_i(obj->getSystemState(),GraphicsPathCommand::MOVE_TO)); + th->data->append(abstract_d(obj->getSystemState(),x)); + th->data->append(abstract_d(obj->getSystemState(),y)); return NULL; } @@ -141,11 +141,11 @@ ARG_UNPACK (x) (y); th->ensureValid(); - th->commands->append(abstract_i(GraphicsPathCommand::LINE_TO)); - th->data->append(abstract_d(0)); - th->data->append(abstract_d(0)); - th->data->append(abstract_d(x)); - th->data->append(abstract_d(y)); + th->commands->append(abstract_i(obj->getSystemState(),GraphicsPathCommand::LINE_TO)); + th->data->append(abstract_d(obj->getSystemState(),0)); + th->data->append(abstract_d(obj->getSystemState(),0)); + th->data->append(abstract_d(obj->getSystemState(),x)); + th->data->append(abstract_d(obj->getSystemState(),y)); return NULL; } @@ -158,11 +158,11 @@ ARG_UNPACK (x) (y); th->ensureValid(); - th->commands->append(abstract_i(GraphicsPathCommand::MOVE_TO)); - th->data->append(abstract_d(0)); - th->data->append(abstract_d(0)); - th->data->append(abstract_d(x)); - th->data->append(abstract_d(y)); + th->commands->append(abstract_i(obj->getSystemState(),GraphicsPathCommand::MOVE_TO)); + th->data->append(abstract_d(obj->getSystemState(),0)); + th->data->append(abstract_d(obj->getSystemState(),0)); + th->data->append(abstract_d(obj->getSystemState(),x)); + th->data->append(abstract_d(obj->getSystemState(),y)); return NULL; }
View file
lightspark.tar.xz/src/scripting/flash/display/GraphicsShaderFill.cpp
Changed
@@ -36,9 +36,9 @@ REGISTER_GETTER_SETTER(c, matrix); REGISTER_GETTER_SETTER(c, shader); - c->addImplementedInterface(InterfaceClass<IGraphicsFill>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsFill>::getClass(c->getSystemState())); IGraphicsFill::linkTraits(c); - c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass(c->getSystemState())); IGraphicsData::linkTraits(c); }
View file
lightspark.tar.xz/src/scripting/flash/display/GraphicsSolidFill.cpp
Changed
@@ -35,9 +35,9 @@ REGISTER_GETTER_SETTER(c, alpha); REGISTER_GETTER_SETTER(c, color); - c->addImplementedInterface(InterfaceClass<IGraphicsFill>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsFill>::getClass(c->getSystemState())); IGraphicsFill::linkTraits(c); - c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass(c->getSystemState())); IGraphicsData::linkTraits(c); }
View file
lightspark.tar.xz/src/scripting/flash/display/GraphicsStroke.cpp
Changed
@@ -44,9 +44,9 @@ REGISTER_GETTER_SETTER(c, scaleMode); REGISTER_GETTER_SETTER(c, thickness); - c->addImplementedInterface(InterfaceClass<IGraphicsStroke>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsStroke>::getClass(c->getSystemState())); IGraphicsStroke::linkTraits(c); - c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass(c->getSystemState())); IGraphicsData::linkTraits(c); }
View file
lightspark.tar.xz/src/scripting/flash/display/GraphicsTrianglePath.cpp
Changed
@@ -38,9 +38,9 @@ REGISTER_GETTER_SETTER(c, uvtData); REGISTER_GETTER_SETTER(c, vertices); - c->addImplementedInterface(InterfaceClass<IGraphicsPath>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsPath>::getClass(c->getSystemState())); IGraphicsPath::linkTraits(c); - c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass()); + c->addImplementedInterface(InterfaceClass<IGraphicsData>::getClass(c->getSystemState())); IGraphicsData::linkTraits(c); }
View file
lightspark.tar.xz/src/scripting/flash/display/TokenContainer.cpp
Changed
@@ -25,12 +25,12 @@ using namespace lightspark; using namespace std; -TokenContainer::TokenContainer(DisplayObject* _o) : owner(_o),tokens(reporter_allocator<GeomToken>(getSys()->unaccountedMemory)), scaling(1.0f) +TokenContainer::TokenContainer(DisplayObject* _o) : owner(_o),tokens(reporter_allocator<GeomToken>(_o->getSystemState()->unaccountedMemory)), scaling(1.0f) { } TokenContainer::TokenContainer(DisplayObject* _o, const tokensVector& _tokens, float _scaling) : - owner(_o), tokens(_tokens.begin(),_tokens.end(),reporter_allocator<GeomToken>(getSys()->unaccountedMemory)), scaling(_scaling) + owner(_o), tokens(_tokens.begin(),_tokens.end(),reporter_allocator<GeomToken>(_o->getSystemState()->unaccountedMemory)), scaling(_scaling) { }
View file
lightspark.tar.xz/src/scripting/flash/display/flashdisplay.cpp
Changed
@@ -57,9 +57,9 @@ loader(NullRef),bytesData(NullRef),loadStatus(STARTED),actionScriptVersion(3),swfVersion(0), childAllowsParent(true),uncaughtErrorEvents(NullRef),parentAllowsChild(true),frameRate(0) { - sharedEvents=_MR(Class<EventDispatcher>::getInstanceS()); - parameters = _MR(Class<ASObject>::getInstanceS()); - uncaughtErrorEvents = _MR(Class<UncaughtErrorEvents>::getInstanceS()); + sharedEvents=_MR(Class<EventDispatcher>::getInstanceS(c->getSystemState())); + parameters = _MR(Class<ASObject>::getInstanceS(c->getSystemState())); + uncaughtErrorEvents = _MR(Class<UncaughtErrorEvents>::getInstanceS(c->getSystemState())); LOG(LOG_NOT_IMPLEMENTED,"LoaderInfo: childAllowsParent and parentAllowsChild always return true"); } @@ -69,9 +69,9 @@ loader(l),bytesData(NullRef),loadStatus(STARTED),actionScriptVersion(3),swfVersion(0), childAllowsParent(true),uncaughtErrorEvents(NullRef),parentAllowsChild(true),frameRate(0) { - sharedEvents=_MR(Class<EventDispatcher>::getInstanceS()); - parameters = _MR(Class<ASObject>::getInstanceS()); - uncaughtErrorEvents = _MR(Class<UncaughtErrorEvents>::getInstanceS()); + sharedEvents=_MR(Class<EventDispatcher>::getInstanceS(c->getSystemState())); + parameters = _MR(Class<ASObject>::getInstanceS(c->getSystemState())); + uncaughtErrorEvents = _MR(Class<UncaughtErrorEvents>::getInstanceS(c->getSystemState())); LOG(LOG_NOT_IMPLEMENTED,"LoaderInfo: childAllowsParent and parentAllowsChild always return true"); } @@ -79,17 +79,17 @@ { CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_SEALED); c->isReusable = true; - c->setDeclaredMethodByQName("loaderURL","",Class<IFunction>::getFunction(_getLoaderURL),GETTER_METHOD,true); - c->setDeclaredMethodByQName("loader","",Class<IFunction>::getFunction(_getLoader),GETTER_METHOD,true); - c->setDeclaredMethodByQName("content","",Class<IFunction>::getFunction(_getContent),GETTER_METHOD,true); - c->setDeclaredMethodByQName("url","",Class<IFunction>::getFunction(_getURL),GETTER_METHOD,true); - c->setDeclaredMethodByQName("bytesLoaded","",Class<IFunction>::getFunction(_getBytesLoaded),GETTER_METHOD,true); - c->setDeclaredMethodByQName("bytesTotal","",Class<IFunction>::getFunction(_getBytesTotal),GETTER_METHOD,true); - c->setDeclaredMethodByQName("bytes","",Class<IFunction>::getFunction(_getBytes),GETTER_METHOD,true); - c->setDeclaredMethodByQName("applicationDomain","",Class<IFunction>::getFunction(_getApplicationDomain),GETTER_METHOD,true); - c->setDeclaredMethodByQName("sharedEvents","",Class<IFunction>::getFunction(_getSharedEvents),GETTER_METHOD,true); - c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(_getWidth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(_getHeight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("loaderURL","",Class<IFunction>::getFunction(c->getSystemState(),_getLoaderURL),GETTER_METHOD,true); + c->setDeclaredMethodByQName("loader","",Class<IFunction>::getFunction(c->getSystemState(),_getLoader),GETTER_METHOD,true); + c->setDeclaredMethodByQName("content","",Class<IFunction>::getFunction(c->getSystemState(),_getContent),GETTER_METHOD,true); + c->setDeclaredMethodByQName("url","",Class<IFunction>::getFunction(c->getSystemState(),_getURL),GETTER_METHOD,true); + c->setDeclaredMethodByQName("bytesLoaded","",Class<IFunction>::getFunction(c->getSystemState(),_getBytesLoaded),GETTER_METHOD,true); + c->setDeclaredMethodByQName("bytesTotal","",Class<IFunction>::getFunction(c->getSystemState(),_getBytesTotal),GETTER_METHOD,true); + c->setDeclaredMethodByQName("bytes","",Class<IFunction>::getFunction(c->getSystemState(),_getBytes),GETTER_METHOD,true); + c->setDeclaredMethodByQName("applicationDomain","",Class<IFunction>::getFunction(c->getSystemState(),_getApplicationDomain),GETTER_METHOD,true); + c->setDeclaredMethodByQName("sharedEvents","",Class<IFunction>::getFunction(c->getSystemState(),_getSharedEvents),GETTER_METHOD,true); + c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(c->getSystemState(),_getWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(c->getSystemState(),_getHeight),GETTER_METHOD,true); REGISTER_GETTER(c,parameters); REGISTER_GETTER(c,actionScriptVersion); REGISTER_GETTER(c,swfVersion); @@ -152,18 +152,18 @@ { SpinlockLocker l(spinlock); bytesLoaded=b; - if(getVm()) + if(getVm(getSystemState())) { this->incRef(); - getVm()->addEvent(_MR(this),_MR(Class<ProgressEvent>::getInstanceS(bytesLoaded,bytesTotal))); + getVm(getSystemState())->addEvent(_MR(this),_MR(Class<ProgressEvent>::getInstanceS(getSystemState(),bytesLoaded,bytesTotal))); } if(loadStatus==INIT_SENT) { //The clip is also complete now - if(getVm()) + if(getVm(getSystemState())) { this->incRef(); - getVm()->addEvent(_MR(this),_MR(Class<Event>::getInstanceS("complete"))); + getVm(getSystemState())->addEvent(_MR(this),_MR(Class<Event>::getInstanceS(getSystemState(),"complete"))); } loadStatus=COMPLETE; } @@ -173,14 +173,14 @@ void LoaderInfo::sendInit() { this->incRef(); - getVm()->addEvent(_MR(this),_MR(Class<Event>::getInstanceS("init"))); + getVm(getSystemState())->addEvent(_MR(this),_MR(Class<Event>::getInstanceS(getSystemState(),"init"))); assert(loadStatus==STARTED); loadStatus=INIT_SENT; if(bytesTotal && bytesLoaded==bytesTotal) { //The clip is also complete now this->incRef(); - getVm()->addEvent(_MR(this),_MR(Class<Event>::getInstanceS("complete"))); + getVm(getSystemState())->addEvent(_MR(this),_MR(Class<Event>::getInstanceS(getSystemState(),"complete"))); loadStatus=COMPLETE; } } @@ -214,14 +214,14 @@ //uses AS3. See specs. if (setParameters) { - parameters = _MR(Class<ASObject>::getInstanceS()); + parameters = _MR(Class<ASObject>::getInstanceS(getSystemState())); SystemState::parseParametersFromURLIntoObject(url, parameters); } } ASFUNCTIONBODY(LoaderInfo,_constructor) { - LoaderInfo* th=static_cast<LoaderInfo*>(obj); + //LoaderInfo* th=static_cast<LoaderInfo*>(obj); EventDispatcher::_constructor(obj,NULL,0); return NULL; } @@ -229,7 +229,7 @@ ASFUNCTIONBODY(LoaderInfo,_getLoaderURL) { LoaderInfo* th=static_cast<LoaderInfo*>(obj); - return abstract_s(th->loaderURL); + return abstract_s(obj->getSystemState(),th->loaderURL); } ASFUNCTIONBODY(LoaderInfo,_getContent) @@ -237,7 +237,7 @@ //Use Loader::getContent LoaderInfo* th=static_cast<LoaderInfo*>(obj); if(th->loader.isNull()) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); else return Loader::_getContent(th->loader.getPtr(),NULL,0); } @@ -246,7 +246,7 @@ { LoaderInfo* th=static_cast<LoaderInfo*>(obj); if(th->loader.isNull()) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); else { th->loader->incRef(); @@ -264,26 +264,26 @@ ASFUNCTIONBODY(LoaderInfo,_getURL) { LoaderInfo* th=static_cast<LoaderInfo*>(obj); - return abstract_s(th->url); + return abstract_s(obj->getSystemState(),th->url); } ASFUNCTIONBODY(LoaderInfo,_getBytesLoaded) { LoaderInfo* th=static_cast<LoaderInfo*>(obj); - return abstract_i(th->bytesLoaded); + return abstract_i(obj->getSystemState(),th->bytesLoaded); } ASFUNCTIONBODY(LoaderInfo,_getBytesTotal) { LoaderInfo* th=static_cast<LoaderInfo*>(obj); - return abstract_i(th->bytesTotal); + return abstract_i(obj->getSystemState(),th->bytesTotal); } ASFUNCTIONBODY(LoaderInfo,_getBytes) { LoaderInfo* th=static_cast<LoaderInfo*>(obj); if (th->bytesData.isNull()) - th->bytesData = _NR<ByteArray>(Class<ByteArray>::getInstanceS()); + th->bytesData = _NR<ByteArray>(Class<ByteArray>::getInstanceS(obj->getSystemState())); if (!th->loader->getContent().isNull()) th->bytesData->writeObject(th->loader->getContent().getPtr()); @@ -294,7 +294,7 @@ { LoaderInfo* th=static_cast<LoaderInfo*>(obj); if(th->applicationDomain.isNull()) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); th->applicationDomain->incRef(); return th->applicationDomain.getPtr(); @@ -305,12 +305,12 @@ LoaderInfo* th=static_cast<LoaderInfo*>(obj); _NR<Loader> l = th->loader; if(l.isNull()) - return abstract_d(0); + return abstract_d(obj->getSystemState(),0); _NR<DisplayObject> o=l->getContent(); if (o.isNull()) - return abstract_d(0); + return abstract_d(obj->getSystemState(),0); - return abstract_d(o->getNominalWidth()); + return abstract_d(obj->getSystemState(),o->getNominalWidth()); } ASFUNCTIONBODY(LoaderInfo,_getHeight) @@ -318,12 +318,12 @@ LoaderInfo* th=static_cast<LoaderInfo*>(obj); _NR<Loader> l = th->loader; if(l.isNull()) - return abstract_d(0); + return abstract_d(obj->getSystemState(),0); _NR<DisplayObject> o=l->getContent(); if (o.isNull()) - return abstract_d(0); + return abstract_d(obj->getSystemState(),0); - return abstract_d(o->getNominalHeight()); + return abstract_d(obj->getSystemState(),o->getNominalHeight()); } LoaderThread::LoaderThread(_R<URLRequest> request, _R<Loader> ldr) @@ -361,22 +361,22 @@ { LOG(LOG_ERROR, "Loader::execute(): Download of URL failed: " << url); loaderInfo->incRef(); - getVm()->addEvent(loaderInfo,_MR(Class<IOErrorEvent>::getInstanceS())); + getVm(loader->getSystemState())->addEvent(loaderInfo,_MR(Class<IOErrorEvent>::getInstanceS(loader->getSystemState()))); loader->incRef(); - getVm()->addEvent(loader,_MR(Class<IOErrorEvent>::getInstanceS())); + getVm(loader->getSystemState())->addEvent(loader,_MR(Class<IOErrorEvent>::getInstanceS(loader->getSystemState()))); delete sbuf; // downloader will be deleted in jobFence return; } loaderInfo->incRef(); - getVm()->addEvent(loaderInfo,_MR(Class<Event>::getInstanceS("open"))); + getVm(loader->getSystemState())->addEvent(loaderInfo,_MR(Class<Event>::getInstanceS(loader->getSystemState(),"open"))); } else if(source==BYTES) { assert_and_throw(bytes->bytes); loaderInfo->incRef(); - getVm()->addEvent(loaderInfo,_MR(Class<Event>::getInstanceS("open"))); + getVm(loader->getSystemState())->addEvent(loaderInfo,_MR(Class<Event>::getInstanceS(loader->getSystemState(),"open"))); loaderInfo->setBytesTotal(bytes->getLength()); loaderInfo->setBytesLoaded(bytes->getLength()); @@ -394,7 +394,7 @@ //Acquire the lock to ensure consistency in threadAbort SpinlockLocker l(downloaderLock); if(downloader) - getSys()->downloadManager->destroy(downloader); + loaderInfo->getSystemState()->downloadManager->destroy(downloader); downloader=NULL; } @@ -407,7 +407,7 @@ if(!threadAborting) { loaderInfo->incRef(); - getVm()->addEvent(loaderInfo,_MR(Class<IOErrorEvent>::getInstanceS())); + getVm(loader->getSystemState())->addEvent(loaderInfo,_MR(Class<IOErrorEvent>::getInstanceS(loader->getSystemState()))); } return; } @@ -417,8 +417,8 @@ { Loader* th=static_cast<Loader*>(obj); DisplayObjectContainer::_constructor(obj,NULL,0); - th->contentLoaderInfo->setLoaderURL(getSys()->mainClip->getOrigin().getParsedURL()); - th->uncaughtErrorEvents = _MR(Class<UncaughtErrorEvents>::getInstanceS()); + th->contentLoaderInfo->setLoaderURL(obj->getSystemState()->mainClip->getOrigin().getParsedURL()); + th->uncaughtErrorEvents = _MR(Class<UncaughtErrorEvents>::getInstanceS(obj->getSystemState())); return NULL; } @@ -428,7 +428,7 @@ SpinlockLocker l(th->spinlock); _NR<ASObject> ret=th->content; if(ret.isNull()) - ret=_MR(getSys()->getUndefinedRef()); + ret=_MR(obj->getSystemState()->getUndefinedRef()); ret->incRef(); return ret.getPtr(); @@ -464,14 +464,14 @@ th->contentLoaderInfo->resetState(); //Check if a security domain has been manually set _NR<SecurityDomain> secDomain; - _NR<SecurityDomain> curSecDomain=ABCVm::getCurrentSecurityDomain(getVm()->currentCallContext); + _NR<SecurityDomain> curSecDomain=ABCVm::getCurrentSecurityDomain(getVm(th->getSystemState())->currentCallContext); if(!context.isNull()) { if (!context->securityDomain.isNull()) { //The passed domain must be the current one. See Loader::load specs. if(context->securityDomain!=curSecDomain) - throw Class<SecurityError>::getInstanceS("SecurityError: securityDomain must be current one"); + throw Class<SecurityError>::getInstanceS(obj->getSystemState(),"SecurityError: securityDomain must be current one"); secDomain=curSecDomain; } @@ -484,7 +484,7 @@ //Default is to create a child ApplicationDomain if the file is in the same security context //otherwise create a child of the system domain. If the security domain is different //the passed applicationDomain is ignored - _R<RootMovieClip> currentRoot=getVm()->currentCallContext->context->root; + _R<RootMovieClip> currentRoot=getVm(th->getSystemState())->currentCallContext->context->root; // empty origin is possible if swf is loaded by loadBytes() if(currentRoot->getOrigin().isEmpty() || currentRoot->getOrigin().getHostname()==th->url.getHostname() || !secDomain.isNull()) { @@ -492,7 +492,7 @@ _NR<ApplicationDomain> parentDomain = currentRoot->applicationDomain; //Support for LoaderContext if(context.isNull() || context->applicationDomain.isNull()) - th->contentLoaderInfo->applicationDomain = _MR(Class<ApplicationDomain>::getInstanceS(parentDomain)); + th->contentLoaderInfo->applicationDomain = _MR(Class<ApplicationDomain>::getInstanceS(obj->getSystemState(),parentDomain)); else th->contentLoaderInfo->applicationDomain = context->applicationDomain; th->contentLoaderInfo->securityDomain = curSecDomain; @@ -500,16 +500,16 @@ else { //Different domain - _NR<ApplicationDomain> parentDomain = getSys()->systemDomain; - th->contentLoaderInfo->applicationDomain = _MR(Class<ApplicationDomain>::getInstanceS(parentDomain)); - th->contentLoaderInfo->securityDomain = _MR(Class<SecurityDomain>::getInstanceS()); + _NR<ApplicationDomain> parentDomain = obj->getSystemState()->systemDomain; + th->contentLoaderInfo->applicationDomain = _MR(Class<ApplicationDomain>::getInstanceS(obj->getSystemState(),parentDomain)); + th->contentLoaderInfo->securityDomain = _MR(Class<SecurityDomain>::getInstanceS(obj->getSystemState())); } if(!th->url.isValid()) { //Notify an error during loading th->incRef(); - getSys()->currentVm->addEvent(_MR(th),_MR(Class<IOErrorEvent>::getInstanceS())); + obj->getSystemState()->currentVm->addEvent(_MR(th),_MR(Class<IOErrorEvent>::getInstanceS(obj->getSystemState()))); return NULL; } @@ -520,11 +520,11 @@ { //TODO: this should be async as it could block if invoked from ExternalInterface SecurityManager::EVALUATIONRESULT evaluationResult; - evaluationResult = getSys()->securityManager->evaluatePoliciesURL(th->url, true); + evaluationResult = obj->getSystemState()->securityManager->evaluatePoliciesURL(th->url, true); if(evaluationResult == SecurityManager::NA_CROSSDOMAIN_POLICY) { // should this dispatch SecurityErrorEvent instead of throwing? - throw Class<SecurityError>::getInstanceS( + throw Class<SecurityError>::getInstanceS(obj->getSystemState(), "SecurityError: connection to domain not allowed by securityManager"); } } @@ -535,7 +535,7 @@ SpinlockLocker l(th->spinlock); th->jobs.push_back(thread); - getSys()->addJob(thread); + obj->getSystemState()->addJob(thread); return NULL; } @@ -550,13 +550,13 @@ _NR<LoaderContext> context; ARG_UNPACK (bytes)(context, NullRef); - _NR<ApplicationDomain> parentDomain = ABCVm::getCurrentApplicationDomain(getVm()->currentCallContext); + _NR<ApplicationDomain> parentDomain = ABCVm::getCurrentApplicationDomain(getVm(th->getSystemState())->currentCallContext); if(context.isNull() || context->applicationDomain.isNull()) - th->contentLoaderInfo->applicationDomain = _MR(Class<ApplicationDomain>::getInstanceS(parentDomain)); + th->contentLoaderInfo->applicationDomain = _MR(Class<ApplicationDomain>::getInstanceS(obj->getSystemState(),parentDomain)); else th->contentLoaderInfo->applicationDomain = context->applicationDomain; //Always loaded in the current security domain - _NR<SecurityDomain> curSecDomain=ABCVm::getCurrentSecurityDomain(getVm()->currentCallContext); + _NR<SecurityDomain> curSecDomain=ABCVm::getCurrentSecurityDomain(getVm(th->getSystemState())->currentCallContext); th->contentLoaderInfo->securityDomain = curSecDomain; th->allowCodeImport = context.isNull() || context->getAllowCodeImport(); @@ -570,7 +570,7 @@ LoaderThread *thread=new LoaderThread(_MR(bytes), _MR(th)); SpinlockLocker l(th->spinlock); th->jobs.push_back(thread); - getSys()->addJob(thread); + obj->getSystemState()->addJob(thread); } else LOG(LOG_INFO, "Empty ByteArray passed to Loader.loadBytes"); @@ -615,7 +615,7 @@ if(loaded) { contentLoaderInfo->incRef(); - getVm()->addEvent(contentLoaderInfo,_MR(Class<Event>::getInstanceS("unload"))); + getVm(getSystemState())->addEvent(contentLoaderInfo,_MR(Class<Event>::getInstanceS(getSystemState(),"unload"))); loaded=false; } @@ -637,7 +637,7 @@ Loader::Loader(Class_base* c):DisplayObjectContainer(c),content(NullRef),contentLoaderInfo(NullRef),loaded(false), allowCodeImport(true),uncaughtErrorEvents(NullRef) { incRef(); - contentLoaderInfo=_MR(Class<LoaderInfo>::getInstanceS(_MR(this))); + contentLoaderInfo=_MR(Class<LoaderInfo>::getInstanceS(c->getSystemState(),_MR(this))); } Loader::~Loader() @@ -647,13 +647,13 @@ void Loader::sinit(Class_base* c) { CLASS_SETUP(c, DisplayObjectContainer, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("contentLoaderInfo","",Class<IFunction>::getFunction(_getContentLoaderInfo),GETTER_METHOD,true); - c->setDeclaredMethodByQName("content","",Class<IFunction>::getFunction(_getContent),GETTER_METHOD,true); - c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(close),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("loadBytes","",Class<IFunction>::getFunction(loadBytes),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("load","",Class<IFunction>::getFunction(load),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("unload","",Class<IFunction>::getFunction(_unload),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("unloadAndStop","",Class<IFunction>::getFunction(_unloadAndStop),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("contentLoaderInfo","",Class<IFunction>::getFunction(c->getSystemState(),_getContentLoaderInfo),GETTER_METHOD,true); + c->setDeclaredMethodByQName("content","",Class<IFunction>::getFunction(c->getSystemState(),_getContent),GETTER_METHOD,true); + c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(c->getSystemState(),close),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("loadBytes","",Class<IFunction>::getFunction(c->getSystemState(),loadBytes),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("load","",Class<IFunction>::getFunction(c->getSystemState(),load),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("unload","",Class<IFunction>::getFunction(c->getSystemState(),_unload),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("unloadAndStop","",Class<IFunction>::getFunction(c->getSystemState(),_unloadAndStop),NORMAL_METHOD,true); REGISTER_GETTER(c,uncaughtErrorEvents); } @@ -705,9 +705,9 @@ { CLASS_SETUP(c, DisplayObjectContainer, _constructor, CLASS_SEALED); c->isReusable = true; - c->setDeclaredMethodByQName("graphics","",Class<IFunction>::getFunction(_getGraphics),GETTER_METHOD,true); - c->setDeclaredMethodByQName("startDrag","",Class<IFunction>::getFunction(_startDrag),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("stopDrag","",Class<IFunction>::getFunction(_stopDrag),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("graphics","",Class<IFunction>::getFunction(c->getSystemState(),_getGraphics),GETTER_METHOD,true); + c->setDeclaredMethodByQName("startDrag","",Class<IFunction>::getFunction(c->getSystemState(),_startDrag),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("stopDrag","",Class<IFunction>::getFunction(c->getSystemState(),_stopDrag),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c, buttonMode); REGISTER_GETTER_SETTER(c, hitArea); REGISTER_GETTER_SETTER(c, useHandCursor); @@ -731,7 +731,7 @@ { Rectangle* rect = Class<Rectangle>::cast(args[1]); if(!rect) - throw Class<ArgumentError>::getInstanceS("Wrong type"); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Wrong type"); bounds = new RECT(rect->getRect()); } @@ -743,14 +743,14 @@ } th->incRef(); - getSys()->getInputThread()->startDrag(_MR(th), bounds, offset); + obj->getSystemState()->getInputThread()->startDrag(_MR(th), bounds, offset); return NULL; } ASFUNCTIONBODY(Sprite,_stopDrag) { Sprite* th=Class<Sprite>::cast(obj); - getSys()->getInputThread()->stopDrag(th); + obj->getSystemState()->getInputThread()->stopDrag(th); return NULL; } @@ -946,7 +946,7 @@ Sprite* th=static_cast<Sprite*>(obj); //Probably graphics is not used often, so create it here if(th->graphics.isNull()) - th->graphics=_MR(Class<Graphics>::getInstanceS(th)); + th->graphics=_MR(Class<Graphics>::getInstanceS(obj->getSystemState(),th)); th->graphics->incRef(); return th->graphics.getPtr(); @@ -963,8 +963,8 @@ void FrameLabel::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setDeclaredMethodByQName("frame","",Class<IFunction>::getFunction(_getFrame),GETTER_METHOD,true); - c->setDeclaredMethodByQName("name","",Class<IFunction>::getFunction(_getName),GETTER_METHOD,true); + c->setDeclaredMethodByQName("frame","",Class<IFunction>::getFunction(c->getSystemState(),_getFrame),GETTER_METHOD,true); + c->setDeclaredMethodByQName("name","",Class<IFunction>::getFunction(c->getSystemState(),_getName),GETTER_METHOD,true); } void FrameLabel::buildTraits(ASObject* o) @@ -974,13 +974,13 @@ ASFUNCTIONBODY(FrameLabel,_getFrame) { FrameLabel* th=static_cast<FrameLabel*>(obj); - return abstract_i(th->frame); + return abstract_i(obj->getSystemState(),th->frame); } ASFUNCTIONBODY(FrameLabel,_getName) { FrameLabel* th=static_cast<FrameLabel*>(obj); - return abstract_s(th->name); + return abstract_s(obj->getSystemState(),th->name); } /* @@ -1020,19 +1020,19 @@ void Scene::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setDeclaredMethodByQName("labels","",Class<IFunction>::getFunction(_getLabels),GETTER_METHOD,true); - c->setDeclaredMethodByQName("name","",Class<IFunction>::getFunction(_getName),GETTER_METHOD,true); - c->setDeclaredMethodByQName("numFrames","",Class<IFunction>::getFunction(_getNumFrames),GETTER_METHOD,true); + c->setDeclaredMethodByQName("labels","",Class<IFunction>::getFunction(c->getSystemState(),_getLabels),GETTER_METHOD,true); + c->setDeclaredMethodByQName("name","",Class<IFunction>::getFunction(c->getSystemState(),_getName),GETTER_METHOD,true); + c->setDeclaredMethodByQName("numFrames","",Class<IFunction>::getFunction(c->getSystemState(),_getNumFrames),GETTER_METHOD,true); } ASFUNCTIONBODY(Scene,_getLabels) { Scene* th=static_cast<Scene*>(obj); - Array* ret = Class<Array>::getInstanceS(); + Array* ret = Class<Array>::getInstanceS(obj->getSystemState()); ret->resize(th->labels.size()); for(size_t i=0; i<th->labels.size(); ++i) { - ret->set(i, _MR(Class<FrameLabel>::getInstanceS(th->labels[i]))); + ret->set(i, _MR(Class<FrameLabel>::getInstanceS(obj->getSystemState(),th->labels[i]))); } return ret; } @@ -1040,13 +1040,13 @@ ASFUNCTIONBODY(Scene,_getName) { Scene* th=static_cast<Scene*>(obj); - return abstract_s(th->name); + return abstract_s(obj->getSystemState(),th->name); } ASFUNCTIONBODY(Scene,_getNumFrames) { Scene* th=static_cast<Scene*>(obj); - return abstract_i(th->numFrames); + return abstract_i(obj->getSystemState(),th->numFrames); } void Frame::destroyTags() @@ -1103,21 +1103,21 @@ { CLASS_SETUP(c, Sprite, _constructor, CLASS_DYNAMIC_NOT_FINAL); c->isReusable = true; - c->setDeclaredMethodByQName("currentFrame","",Class<IFunction>::getFunction(_getCurrentFrame),GETTER_METHOD,true); - c->setDeclaredMethodByQName("totalFrames","",Class<IFunction>::getFunction(_getTotalFrames),GETTER_METHOD,true); - c->setDeclaredMethodByQName("framesLoaded","",Class<IFunction>::getFunction(_getFramesLoaded),GETTER_METHOD,true); - c->setDeclaredMethodByQName("currentFrameLabel","",Class<IFunction>::getFunction(_getCurrentFrameLabel),GETTER_METHOD,true); - c->setDeclaredMethodByQName("currentLabel","",Class<IFunction>::getFunction(_getCurrentLabel),GETTER_METHOD,true); - c->setDeclaredMethodByQName("currentLabels","",Class<IFunction>::getFunction(_getCurrentLabels),GETTER_METHOD,true); - c->setDeclaredMethodByQName("scenes","",Class<IFunction>::getFunction(_getScenes),GETTER_METHOD,true); - c->setDeclaredMethodByQName("currentScene","",Class<IFunction>::getFunction(_getCurrentScene),GETTER_METHOD,true); - c->setDeclaredMethodByQName("stop","",Class<IFunction>::getFunction(stop),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("play","",Class<IFunction>::getFunction(play),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("gotoAndStop","",Class<IFunction>::getFunction(gotoAndStop),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("gotoAndPlay","",Class<IFunction>::getFunction(gotoAndPlay),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("prevFrame","",Class<IFunction>::getFunction(prevFrame),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("nextFrame","",Class<IFunction>::getFunction(nextFrame),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("addFrameScript","",Class<IFunction>::getFunction(addFrameScript),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("currentFrame","",Class<IFunction>::getFunction(c->getSystemState(),_getCurrentFrame),GETTER_METHOD,true); + c->setDeclaredMethodByQName("totalFrames","",Class<IFunction>::getFunction(c->getSystemState(),_getTotalFrames),GETTER_METHOD,true); + c->setDeclaredMethodByQName("framesLoaded","",Class<IFunction>::getFunction(c->getSystemState(),_getFramesLoaded),GETTER_METHOD,true); + c->setDeclaredMethodByQName("currentFrameLabel","",Class<IFunction>::getFunction(c->getSystemState(),_getCurrentFrameLabel),GETTER_METHOD,true); + c->setDeclaredMethodByQName("currentLabel","",Class<IFunction>::getFunction(c->getSystemState(),_getCurrentLabel),GETTER_METHOD,true); + c->setDeclaredMethodByQName("currentLabels","",Class<IFunction>::getFunction(c->getSystemState(),_getCurrentLabels),GETTER_METHOD,true); + c->setDeclaredMethodByQName("scenes","",Class<IFunction>::getFunction(c->getSystemState(),_getScenes),GETTER_METHOD,true); + c->setDeclaredMethodByQName("currentScene","",Class<IFunction>::getFunction(c->getSystemState(),_getCurrentScene),GETTER_METHOD,true); + c->setDeclaredMethodByQName("stop","",Class<IFunction>::getFunction(c->getSystemState(),stop),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("play","",Class<IFunction>::getFunction(c->getSystemState(),play),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("gotoAndStop","",Class<IFunction>::getFunction(c->getSystemState(),gotoAndStop),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("gotoAndPlay","",Class<IFunction>::getFunction(c->getSystemState(),gotoAndPlay),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("prevFrame","",Class<IFunction>::getFunction(c->getSystemState(),prevFrame),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("nextFrame","",Class<IFunction>::getFunction(c->getSystemState(),nextFrame),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("addFrameScript","",Class<IFunction>::getFunction(c->getSystemState(),addFrameScript),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c, enabled); } @@ -1342,19 +1342,19 @@ ASFUNCTIONBODY(MovieClip,_getFramesLoaded) { MovieClip* th=static_cast<MovieClip*>(obj); - return abstract_i(th->getFramesLoaded()); + return abstract_i(obj->getSystemState(),th->getFramesLoaded()); } ASFUNCTIONBODY(MovieClip,_getTotalFrames) { MovieClip* th=static_cast<MovieClip*>(obj); - return abstract_i(th->totalFrames_unreliable); + return abstract_i(obj->getSystemState(),th->totalFrames_unreliable); } ASFUNCTIONBODY(MovieClip,_getScenes) { MovieClip* th=static_cast<MovieClip*>(obj); - Array* ret = Class<Array>::getInstanceS(); + Array* ret = Class<Array>::getInstanceS(obj->getSystemState()); ret->resize(th->scenes.size()); uint32_t numFrames; for(size_t i=0; i<th->scenes.size(); ++i) @@ -1363,7 +1363,7 @@ numFrames = th->totalFrames_unreliable - th->scenes[i].startframe; else numFrames = th->scenes[i].startframe - th->scenes[i+1].startframe; - ret->set(i, _MR(Class<Scene>::getInstanceS(th->scenes[i],numFrames))); + ret->set(i, _MR(Class<Scene>::getInstanceS(obj->getSystemState(),th->scenes[i],numFrames))); } return ret; } @@ -1388,14 +1388,14 @@ else numFrames = th->scenes[curScene].startframe - th->scenes[curScene+1].startframe; - return Class<Scene>::getInstanceS(th->scenes[curScene],numFrames); + return Class<Scene>::getInstanceS(obj->getSystemState(),th->scenes[curScene],numFrames); } ASFUNCTIONBODY(MovieClip,_getCurrentFrame) { MovieClip* th=static_cast<MovieClip*>(obj); //currentFrame is 1-based and relative to current scene - return abstract_i(th->state.FP+1 - th->scenes[th->getCurrentScene()].startframe); + return abstract_i(obj->getSystemState(),th->state.FP+1 - th->scenes[th->getCurrentScene()].startframe); } ASFUNCTIONBODY(MovieClip,_getCurrentFrameLabel) @@ -1405,9 +1405,9 @@ { for(size_t j=0;j<th->scenes[i].labels.size();++j) if(th->scenes[i].labels[j].frame == th->state.FP) - return abstract_s(th->scenes[i].labels[j].name); + return abstract_s(obj->getSystemState(),th->scenes[i].labels[j].name); } - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); } ASFUNCTIONBODY(MovieClip,_getCurrentLabel) @@ -1428,9 +1428,9 @@ } if(label.empty()) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); else - return abstract_s(label); + return abstract_s(obj->getSystemState(),label); } ASFUNCTIONBODY(MovieClip,_getCurrentLabels) @@ -1438,11 +1438,11 @@ MovieClip* th=static_cast<MovieClip*>(obj); Scene_data& sc = th->scenes[th->getCurrentScene()]; - Array* ret = Class<Array>::getInstanceS(); + Array* ret = Class<Array>::getInstanceS(obj->getSystemState()); ret->resize(sc.labels.size()); for(size_t i=0; i<sc.labels.size(); ++i) { - ret->set(i, _MR(Class<FrameLabel>::getInstanceS(sc.labels[i]))); + ret->set(i, _MR(Class<FrameLabel>::getInstanceS(obj->getSystemState(),sc.labels[i]))); } return ret; } @@ -1450,8 +1450,8 @@ ASFUNCTIONBODY(MovieClip,_constructor) { Sprite::_constructor(obj,NULL,0); -/* th->setVariableByQName("swapDepths","",Class<IFunction>::getFunction(swapDepths)); - th->setVariableByQName("createEmptyMovieClip","",Class<IFunction>::getFunction(createEmptyMovieClip));*/ +/* th->setVariableByQName("swapDepths","",Class<IFunction>::getFunction(c->getSystemState(),swapDepths)); + th->setVariableByQName("createEmptyMovieClip","",Class<IFunction>::getFunction(c->getSystemState(),createEmptyMovieClip));*/ return NULL; } @@ -1475,19 +1475,19 @@ { CLASS_SETUP(c, InteractiveObject, _constructor, CLASS_SEALED); c->isReusable = true; - c->setDeclaredMethodByQName("numChildren","",Class<IFunction>::getFunction(_getNumChildren),GETTER_METHOD,true); - c->setDeclaredMethodByQName("getChildIndex","",Class<IFunction>::getFunction(_getChildIndex),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setChildIndex","",Class<IFunction>::getFunction(_setChildIndex),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getChildAt","",Class<IFunction>::getFunction(getChildAt),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getChildByName","",Class<IFunction>::getFunction(getChildByName),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("addChild","",Class<IFunction>::getFunction(addChild),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("removeChild","",Class<IFunction>::getFunction(removeChild),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("removeChildAt","",Class<IFunction>::getFunction(removeChildAt),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("addChildAt","",Class<IFunction>::getFunction(addChildAt),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("swapChildren","",Class<IFunction>::getFunction(swapChildren),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("contains","",Class<IFunction>::getFunction(contains),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("mouseChildren","",Class<IFunction>::getFunction(_setMouseChildren),SETTER_METHOD,true); - c->setDeclaredMethodByQName("mouseChildren","",Class<IFunction>::getFunction(_getMouseChildren),GETTER_METHOD,true); + c->setDeclaredMethodByQName("numChildren","",Class<IFunction>::getFunction(c->getSystemState(),_getNumChildren),GETTER_METHOD,true); + c->setDeclaredMethodByQName("getChildIndex","",Class<IFunction>::getFunction(c->getSystemState(),_getChildIndex),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setChildIndex","",Class<IFunction>::getFunction(c->getSystemState(),_setChildIndex),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getChildAt","",Class<IFunction>::getFunction(c->getSystemState(),getChildAt),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getChildByName","",Class<IFunction>::getFunction(c->getSystemState(),getChildByName),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("addChild","",Class<IFunction>::getFunction(c->getSystemState(),addChild),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("removeChild","",Class<IFunction>::getFunction(c->getSystemState(),removeChild),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("removeChildAt","",Class<IFunction>::getFunction(c->getSystemState(),removeChildAt),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("addChildAt","",Class<IFunction>::getFunction(c->getSystemState(),addChildAt),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("swapChildren","",Class<IFunction>::getFunction(c->getSystemState(),swapChildren),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("contains","",Class<IFunction>::getFunction(c->getSystemState(),contains),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("mouseChildren","",Class<IFunction>::getFunction(c->getSystemState(),_setMouseChildren),SETTER_METHOD,true); + c->setDeclaredMethodByQName("mouseChildren","",Class<IFunction>::getFunction(c->getSystemState(),_getMouseChildren),GETTER_METHOD,true); REGISTER_GETTER_SETTER(c, tabChildren); } @@ -1521,9 +1521,9 @@ //This is a tested behavior multiname objName(NULL); objName.name_type=multiname::NAME_STRING; - objName.name_s_id=getSys()->getUniqueStringId(obj->name); - objName.ns.emplace_back("",NAMESPACE); - setVariableByMultiname(objName,getSys()->getNullRef(), ASObject::CONST_NOT_ALLOWED); + objName.name_s_id=getSystemState()->getUniqueStringId(obj->name); + objName.ns.emplace_back(getSystemState(),"",NAMESPACE); + setVariableByMultiname(objName,getSystemState()->getNullRef(), ASObject::CONST_NOT_ALLOWED); } obj->incRef(); @@ -1545,8 +1545,8 @@ obj->incRef(); multiname objName(NULL); objName.name_type=multiname::NAME_STRING; - objName.name_s_id=getSys()->getUniqueStringId(obj->name); - objName.ns.emplace_back("",NAMESPACE); + objName.name_s_id=getSystemState()->getUniqueStringId(obj->name); + objName.ns.emplace_back(getSystemState(),"",NAMESPACE); setVariableByMultiname(objName,obj,ASObject::CONST_NOT_ALLOWED); } @@ -1588,8 +1588,8 @@ InteractiveObject::~InteractiveObject() { - if(getSys()->getInputThread()) - getSys()->getInputThread()->removeListener(this); + if(getSystemState()->getInputThread()) + getSystemState()->getInputThread()->removeListener(this); } ASFUNCTIONBODY(InteractiveObject,_constructor) @@ -1597,8 +1597,8 @@ InteractiveObject* th=static_cast<InteractiveObject*>(obj); EventDispatcher::_constructor(obj,NULL,0); //Object registered very early are not supported this way (Stage for example) - if(getSys()->getInputThread()) - getSys()->getInputThread()->addListener(th); + if(obj->getSystemState()->getInputThread()) + obj->getSystemState()->getInputThread()->addListener(th); return NULL; } @@ -1614,7 +1614,7 @@ ASFUNCTIONBODY(InteractiveObject,_getMouseEnabled) { InteractiveObject* th=static_cast<InteractiveObject*>(obj); - return abstract_b(th->mouseEnabled); + return abstract_b(obj->getSystemState(),th->mouseEnabled); } ASFUNCTIONBODY(InteractiveObject,_setDoubleClickEnabled) @@ -1628,7 +1628,7 @@ ASFUNCTIONBODY(InteractiveObject,_getDoubleClickEnabled) { InteractiveObject* th=static_cast<InteractiveObject*>(obj); - return abstract_b(th->doubleClickEnabled); + return abstract_b(obj->getSystemState(),th->doubleClickEnabled); } void InteractiveObject::finalize() @@ -1650,10 +1650,10 @@ { CLASS_SETUP(c, DisplayObject, _constructor, CLASS_SEALED); c->isReusable = true; - c->setDeclaredMethodByQName("mouseEnabled","",Class<IFunction>::getFunction(_setMouseEnabled),SETTER_METHOD,true); - c->setDeclaredMethodByQName("mouseEnabled","",Class<IFunction>::getFunction(_getMouseEnabled),GETTER_METHOD,true); - c->setDeclaredMethodByQName("doubleClickEnabled","",Class<IFunction>::getFunction(_setDoubleClickEnabled),SETTER_METHOD,true); - c->setDeclaredMethodByQName("doubleClickEnabled","",Class<IFunction>::getFunction(_getDoubleClickEnabled),GETTER_METHOD,true); + c->setDeclaredMethodByQName("mouseEnabled","",Class<IFunction>::getFunction(c->getSystemState(),_setMouseEnabled),SETTER_METHOD,true); + c->setDeclaredMethodByQName("mouseEnabled","",Class<IFunction>::getFunction(c->getSystemState(),_getMouseEnabled),GETTER_METHOD,true); + c->setDeclaredMethodByQName("doubleClickEnabled","",Class<IFunction>::getFunction(c->getSystemState(),_setDoubleClickEnabled),SETTER_METHOD,true); + c->setDeclaredMethodByQName("doubleClickEnabled","",Class<IFunction>::getFunction(c->getSystemState(),_getDoubleClickEnabled),GETTER_METHOD,true); REGISTER_GETTER_SETTER(c, accessibilityImplementation); REGISTER_GETTER_SETTER(c, contextMenu); REGISTER_GETTER_SETTER(c, tabEnabled); @@ -1718,13 +1718,13 @@ ASFUNCTIONBODY(DisplayObjectContainer,_getNumChildren) { DisplayObjectContainer* th=static_cast<DisplayObjectContainer*>(obj); - return abstract_i(th->dynamicDisplayList.size()); + return abstract_i(obj->getSystemState(),th->dynamicDisplayList.size()); } ASFUNCTIONBODY(DisplayObjectContainer,_getMouseChildren) { DisplayObjectContainer* th=static_cast<DisplayObjectContainer*>(obj); - return abstract_b(th->mouseChildren); + return abstract_b(obj->getSystemState(),th->mouseChildren); } ASFUNCTIONBODY(DisplayObjectContainer,_setMouseChildren) @@ -1816,17 +1816,17 @@ DisplayObjectContainer* th=static_cast<DisplayObjectContainer*>(obj); assert_and_throw(argslen==1); if(args[0]->getObjectType() == T_CLASS) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); if (!args[0]->getClass()) - return abstract_b(false); - if (!args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass())) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); + if (!args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass(obj->getSystemState()))) + return abstract_b(obj->getSystemState(),false); //Cast to object DisplayObject* d=static_cast<DisplayObject*>(args[0]); d->incRef(); bool ret=th->_contains(_MR(d)); - return abstract_b(ret); + return abstract_b(obj->getSystemState(),ret); } //Only from VM context @@ -1836,11 +1836,11 @@ assert_and_throw(argslen==2); if(args[0]->getObjectType() == T_CLASS) { - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); } //Validate object type assert_and_throw(args[0]->getClass() && - args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass())); + args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass(obj->getSystemState()))); int index=args[1]->toInt(); @@ -1852,7 +1852,7 @@ //Notify the object d->incRef(); - getVm()->addEvent(d,_MR(Class<Event>::getInstanceS("added"))); + getVm(obj->getSystemState())->addEvent(d,_MR(Class<Event>::getInstanceS(obj->getSystemState(),"added"))); //incRef again as the value is getting returned d->incRef(); @@ -1865,11 +1865,11 @@ assert_and_throw(argslen==1); if(args[0]->getObjectType() == T_CLASS) { - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); } //Validate object type assert_and_throw(args[0] && args[0]->getClass() && - args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass())); + args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass(obj->getSystemState()))); //Cast to object args[0]->incRef(); @@ -1878,7 +1878,7 @@ //Notify the object d->incRef(); - getVm()->addEvent(d,_MR(Class<Event>::getInstanceS("added"))); + getVm(obj->getSystemState())->addEvent(d,_MR(Class<Event>::getInstanceS(obj->getSystemState(),"added"))); d->incRef(); return d.getPtr(); @@ -1893,16 +1893,16 @@ args[0]->getObjectType() == T_UNDEFINED || args[0]->getObjectType() == T_NULL) { - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); } //Validate object type assert_and_throw(args[0] && args[0]->getClass() && - args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass())); + args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass(obj->getSystemState()))); //Cast to object DisplayObject* d=Class<DisplayObject>::cast(args[0]); d->incRef(); if(!th->_removeChild(_MR(d))) - throw Class<ArgumentError>::getInstanceS("removeChild: child not in list", 2025); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"removeChild: child not in list", 2025); //As we return the child we have to incRef it d->incRef(); @@ -1921,7 +1921,7 @@ { Locker l(th->mutexDisplayList); if(index>=int(th->dynamicDisplayList.size()) || index<0) - throw Class<RangeError>::getInstanceS("removeChildAt: invalid index", 2025); + throw Class<RangeError>::getInstanceS(obj->getSystemState(),"removeChildAt: invalid index", 2025); list<_R<DisplayObject>>::iterator it=th->dynamicDisplayList.begin(); for(int32_t i=0;i<index;i++) ++it; @@ -1944,7 +1944,7 @@ //Validate object type assert_and_throw(args[0] && args[0]->getClass() && - args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass())); + args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass(obj->getSystemState()))); args[0]->incRef(); _R<DisplayObject> child = _MR(Class<DisplayObject>::cast(args[0])); @@ -1977,9 +1977,9 @@ //Validate object type assert_and_throw(args[0] && args[0]->getClass() && - args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass())); + args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass(obj->getSystemState()))); assert_and_throw(args[1] && args[1]->getClass() && - args[1]->getClass()->isSubClass(Class<DisplayObject>::getClass())); + args[1]->getClass()->isSubClass(Class<DisplayObject>::getClass(obj->getSystemState()))); if (args[0] == args[1]) { @@ -1999,7 +1999,7 @@ std::list<_R<DisplayObject>>::iterator it1=find(th->dynamicDisplayList.begin(),th->dynamicDisplayList.end(),child1); std::list<_R<DisplayObject>>::iterator it2=find(th->dynamicDisplayList.begin(),th->dynamicDisplayList.end(),child2); if(it1==th->dynamicDisplayList.end() || it2==th->dynamicDisplayList.end()) - throw Class<ArgumentError>::getInstanceS("Argument is not child of this object", 2025); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Argument is not child of this object", 2025); th->dynamicDisplayList.insert(it1, child2); th->dynamicDisplayList.insert(it2, child1); @@ -2029,7 +2029,7 @@ if(ret) ret->incRef(); else - ret=getSys()->getUndefinedRef(); + ret=obj->getSystemState()->getUndefinedRef(); return ret; } @@ -2040,7 +2040,7 @@ assert_and_throw(argslen==1); unsigned int index=args[0]->toInt(); if(index>=th->dynamicDisplayList.size()) - throw Class<RangeError>::getInstanceS("getChildAt: invalid index", 2025); + throw Class<RangeError>::getInstanceS(obj->getSystemState(),"getChildAt: invalid index", 2025); list<_R<DisplayObject>>::iterator it=th->dynamicDisplayList.begin(); for(unsigned int i=0;i<index;i++) ++it; @@ -2060,7 +2060,7 @@ ret++; ++it; if(it == dynamicDisplayList.end()) - throw Class<ArgumentError>::getInstanceS("getChildIndex: child not in list", 2025); + throw Class<ArgumentError>::getInstanceS(getSystemState(),"getChildIndex: child not in list", 2025); } while(1); return ret; @@ -2072,13 +2072,13 @@ DisplayObjectContainer* th=static_cast<DisplayObjectContainer*>(obj); assert_and_throw(argslen==1); //Validate object type - assert_and_throw(args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass())); + assert_and_throw(args[0]->getClass()->isSubClass(Class<DisplayObject>::getClass(obj->getSystemState()))); //Cast to object _R<DisplayObject> d= _MR(static_cast<DisplayObject*>(args[0])); d->incRef(); - return abstract_i(th->getChildIndex(d)); + return abstract_i(obj->getSystemState(),th->getChildIndex(d)); } Shape::Shape(Class_base* c):DisplayObject(c),TokenContainer(this),graphics(NullRef) @@ -2099,7 +2099,7 @@ void Shape::sinit(Class_base* c) { CLASS_SETUP(c, DisplayObject, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("graphics","",Class<IFunction>::getFunction(_getGraphics),GETTER_METHOD,true); + c->setDeclaredMethodByQName("graphics","",Class<IFunction>::getFunction(c->getSystemState(),_getGraphics),GETTER_METHOD,true); } void Shape::buildTraits(ASObject* o) @@ -2116,7 +2116,7 @@ { Shape* th=static_cast<Shape*>(obj); if(th->graphics.isNull()) - th->graphics=_MR(Class<Graphics>::getInstanceS(th)); + th->graphics=_MR(Class<Graphics>::getInstanceS(obj->getSystemState(),th)); th->graphics->incRef(); return th->graphics.getPtr(); } @@ -2147,31 +2147,31 @@ void Stage::sinit(Class_base* c) { CLASS_SETUP(c, DisplayObjectContainer, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("allowFullScreen","",Class<IFunction>::getFunction(_getAllowFullScreen),GETTER_METHOD,true); - c->setDeclaredMethodByQName("allowFullScreenInteractive","",Class<IFunction>::getFunction(_getAllowFullScreenInteractive),GETTER_METHOD,true); - c->setDeclaredMethodByQName("colorCorrectionSupport","",Class<IFunction>::getFunction(_getColorCorrectionSupport),GETTER_METHOD,true); - c->setDeclaredMethodByQName("fullScreenHeight","",Class<IFunction>::getFunction(_getStageHeight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("fullScreenWidth","",Class<IFunction>::getFunction(_getStageWidth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("stageWidth","",Class<IFunction>::getFunction(_getStageWidth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("stageWidth","",Class<IFunction>::getFunction(undefinedFunction),SETTER_METHOD,true); - c->setDeclaredMethodByQName("stageHeight","",Class<IFunction>::getFunction(_getStageHeight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("stageHeight","",Class<IFunction>::getFunction(undefinedFunction),SETTER_METHOD,true); - c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(_getStageWidth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(_getStageHeight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("scaleMode","",Class<IFunction>::getFunction(_getScaleMode),GETTER_METHOD,true); - c->setDeclaredMethodByQName("scaleMode","",Class<IFunction>::getFunction(_setScaleMode),SETTER_METHOD,true); - c->setDeclaredMethodByQName("loaderInfo","",Class<IFunction>::getFunction(_getLoaderInfo),GETTER_METHOD,true); - c->setDeclaredMethodByQName("stageVideos","",Class<IFunction>::getFunction(_getStageVideos),GETTER_METHOD,true); - c->setDeclaredMethodByQName("focus","",Class<IFunction>::getFunction(_getFocus),GETTER_METHOD,true); - c->setDeclaredMethodByQName("focus","",Class<IFunction>::getFunction(_setFocus),SETTER_METHOD,true); - c->setDeclaredMethodByQName("frameRate","",Class<IFunction>::getFunction(_getFrameRate),GETTER_METHOD,true); - c->setDeclaredMethodByQName("frameRate","",Class<IFunction>::getFunction(_setFrameRate),SETTER_METHOD,true); + c->setDeclaredMethodByQName("allowFullScreen","",Class<IFunction>::getFunction(c->getSystemState(),_getAllowFullScreen),GETTER_METHOD,true); + c->setDeclaredMethodByQName("allowFullScreenInteractive","",Class<IFunction>::getFunction(c->getSystemState(),_getAllowFullScreenInteractive),GETTER_METHOD,true); + c->setDeclaredMethodByQName("colorCorrectionSupport","",Class<IFunction>::getFunction(c->getSystemState(),_getColorCorrectionSupport),GETTER_METHOD,true); + c->setDeclaredMethodByQName("fullScreenHeight","",Class<IFunction>::getFunction(c->getSystemState(),_getStageHeight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("fullScreenWidth","",Class<IFunction>::getFunction(c->getSystemState(),_getStageWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("stageWidth","",Class<IFunction>::getFunction(c->getSystemState(),_getStageWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("stageWidth","",Class<IFunction>::getFunction(c->getSystemState(),undefinedFunction),SETTER_METHOD,true); + c->setDeclaredMethodByQName("stageHeight","",Class<IFunction>::getFunction(c->getSystemState(),_getStageHeight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("stageHeight","",Class<IFunction>::getFunction(c->getSystemState(),undefinedFunction),SETTER_METHOD,true); + c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(c->getSystemState(),_getStageWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(c->getSystemState(),_getStageHeight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("scaleMode","",Class<IFunction>::getFunction(c->getSystemState(),_getScaleMode),GETTER_METHOD,true); + c->setDeclaredMethodByQName("scaleMode","",Class<IFunction>::getFunction(c->getSystemState(),_setScaleMode),SETTER_METHOD,true); + c->setDeclaredMethodByQName("loaderInfo","",Class<IFunction>::getFunction(c->getSystemState(),_getLoaderInfo),GETTER_METHOD,true); + c->setDeclaredMethodByQName("stageVideos","",Class<IFunction>::getFunction(c->getSystemState(),_getStageVideos),GETTER_METHOD,true); + c->setDeclaredMethodByQName("focus","",Class<IFunction>::getFunction(c->getSystemState(),_getFocus),GETTER_METHOD,true); + c->setDeclaredMethodByQName("focus","",Class<IFunction>::getFunction(c->getSystemState(),_setFocus),SETTER_METHOD,true); + c->setDeclaredMethodByQName("frameRate","",Class<IFunction>::getFunction(c->getSystemState(),_getFrameRate),GETTER_METHOD,true); + c->setDeclaredMethodByQName("frameRate","",Class<IFunction>::getFunction(c->getSystemState(),_setFrameRate),SETTER_METHOD,true); // override the setter from DisplayObjectContainer - c->setDeclaredMethodByQName("tabChildren","",Class<IFunction>::getFunction(_setTabChildren),SETTER_METHOD,true); - c->setDeclaredMethodByQName("wmodeGPU","",Class<IFunction>::getFunction(_getWmodeGPU),GETTER_METHOD,true); - c->setDeclaredMethodByQName("invalidate","",Class<IFunction>::getFunction(_invalidate),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("color","",Class<IFunction>::getFunction(_getColor),GETTER_METHOD,true); - c->setDeclaredMethodByQName("color","",Class<IFunction>::getFunction(_setColor),SETTER_METHOD,true); + c->setDeclaredMethodByQName("tabChildren","",Class<IFunction>::getFunction(c->getSystemState(),_setTabChildren),SETTER_METHOD,true); + c->setDeclaredMethodByQName("wmodeGPU","",Class<IFunction>::getFunction(c->getSystemState(),_getWmodeGPU),GETTER_METHOD,true); + c->setDeclaredMethodByQName("invalidate","",Class<IFunction>::getFunction(c->getSystemState(),_invalidate),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("color","",Class<IFunction>::getFunction(c->getSystemState(),_getColor),GETTER_METHOD,true); + c->setDeclaredMethodByQName("color","",Class<IFunction>::getFunction(c->getSystemState(),_setColor),SETTER_METHOD,true); REGISTER_GETTER_SETTER(c,align); REGISTER_GETTER_SETTER(c,colorCorrection); REGISTER_GETTER_SETTER(c,displayState); @@ -2227,7 +2227,7 @@ // StageVideoAvailabilityEvent is dispatched directly after an eventListener is added added // see https://www.adobe.com/devnet/flashplayer/articles/stage_video.html this->incRef(); - getVm()->addEvent(_MR(this),_MR(Class<StageVideoAvailabilityEvent>::getInstanceS())); + getVm(getSystemState())->addEvent(_MR(this),_MR(Class<StageVideoAvailabilityEvent>::getInstanceS(getSystemState()))); } } @@ -2269,11 +2269,11 @@ uint32_t Stage::internalGetWidth() const { uint32_t width; - if(getSys()->scaleMode==SystemState::NO_SCALE) - width=getSys()->getRenderThread()->windowWidth; + if(getSystemState()->scaleMode==SystemState::NO_SCALE) + width=getSystemState()->getRenderThread()->windowWidth; else { - RECT size=getSys()->mainClip->getFrameSize(); + RECT size=getSystemState()->mainClip->getFrameSize(); width=size.Xmax/20; } return width; @@ -2282,11 +2282,11 @@ uint32_t Stage::internalGetHeight() const { uint32_t height; - if(getSys()->scaleMode==SystemState::NO_SCALE) - height=getSys()->getRenderThread()->windowHeight; + if(getSystemState()->scaleMode==SystemState::NO_SCALE) + height=getSystemState()->getRenderThread()->windowHeight; else { - RECT size=getSys()->mainClip->getFrameSize(); + RECT size=getSystemState()->mainClip->getFrameSize(); height=size.Ymax/20; } return height; @@ -2295,33 +2295,33 @@ ASFUNCTIONBODY(Stage,_getStageWidth) { Stage* th=static_cast<Stage*>(obj); - return abstract_d(th->internalGetWidth()); + return abstract_d(obj->getSystemState(),th->internalGetWidth()); } ASFUNCTIONBODY(Stage,_getStageHeight) { Stage* th=static_cast<Stage*>(obj); - return abstract_d(th->internalGetHeight()); + return abstract_d(obj->getSystemState(),th->internalGetHeight()); } ASFUNCTIONBODY(Stage,_getLoaderInfo) { - return RootMovieClip::_getLoaderInfo(getSys()->mainClip,NULL,0); + return RootMovieClip::_getLoaderInfo(obj->getSystemState()->mainClip,NULL,0); } ASFUNCTIONBODY(Stage,_getScaleMode) { //Stage* th=static_cast<Stage*>(obj); - switch(getSys()->scaleMode) + switch(obj->getSystemState()->scaleMode) { case SystemState::EXACT_FIT: - return abstract_s("exactFit"); + return abstract_s(obj->getSystemState(),"exactFit"); case SystemState::SHOW_ALL: - return abstract_s("showAll"); + return abstract_s(obj->getSystemState(),"showAll"); case SystemState::NO_BORDER: - return abstract_s("noBorder"); + return abstract_s(obj->getSystemState(),"noBorder"); case SystemState::NO_SCALE: - return abstract_s("noScale"); + return abstract_s(obj->getSystemState(),"noScale"); } return NULL; } @@ -2331,15 +2331,15 @@ //Stage* th=static_cast<Stage*>(obj); const tiny_string& arg0=args[0]->toString(); if(arg0=="exactFit") - getSys()->scaleMode=SystemState::EXACT_FIT; + obj->getSystemState()->scaleMode=SystemState::EXACT_FIT; else if(arg0=="showAll") - getSys()->scaleMode=SystemState::SHOW_ALL; + obj->getSystemState()->scaleMode=SystemState::SHOW_ALL; else if(arg0=="noBorder") - getSys()->scaleMode=SystemState::NO_BORDER; + obj->getSystemState()->scaleMode=SystemState::NO_BORDER; else if(arg0=="noScale") - getSys()->scaleMode=SystemState::NO_SCALE; + obj->getSystemState()->scaleMode=SystemState::NO_SCALE; - RenderThread* rt=getSys()->getRenderThread(); + RenderThread* rt=obj->getSystemState()->getRenderThread(); rt->requestResize(rt->windowWidth, rt->windowHeight, true); return NULL; } @@ -2347,7 +2347,7 @@ ASFUNCTIONBODY(Stage,_getStageVideos) { LOG(LOG_NOT_IMPLEMENTED, "Accelerated rendering through StageVideo not implemented, SWF should fall back to Video"); - return Template<Vector>::getInstanceS(Class<StageVideo>::getClass(),NullRef); + return Template<Vector>::getInstanceS(obj->getSystemState(),Class<StageVideo>::getClass(obj->getSystemState()),NullRef); } _NR<InteractiveObject> Stage::getFocusTarget() @@ -2407,9 +2407,9 @@ Stage* th=obj->as<Stage>(); _NR<RootMovieClip> root = th->getRoot(); if (root.isNull()) - return abstract_d(getSys()->mainClip->getFrameRate()); + return abstract_d(obj->getSystemState(),obj->getSystemState()->mainClip->getFrameRate()); else - return abstract_d(root->getFrameRate()); + return abstract_d(obj->getSystemState(),root->getFrameRate()); } ASFUNCTIONBODY(Stage,_setFrameRate) @@ -2425,29 +2425,29 @@ ASFUNCTIONBODY(Stage,_getAllowFullScreen) { - return abstract_b(false); // until fullscreen support is implemented + return abstract_b(obj->getSystemState(),false); // until fullscreen support is implemented } ASFUNCTIONBODY(Stage,_getAllowFullScreenInteractive) { - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); } ASFUNCTIONBODY(Stage,_getColorCorrectionSupport) { - return abstract_b(false); // until color correction is implemented + return abstract_b(obj->getSystemState(),false); // until color correction is implemented } ASFUNCTIONBODY(Stage,_getWmodeGPU) { - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); } ASFUNCTIONBODY(Stage,_invalidate) { LOG(LOG_NOT_IMPLEMENTED,"invalidate not implemented yet"); // TODO this crashes lightspark //Stage* th=obj->as<Stage>(); - //_R<FlushInvalidationQueueEvent> event=_MR(new (getSys()->unaccountedMemory) FlushInvalidationQueueEvent()); + //_R<FlushInvalidationQueueEvent> event=_MR(new (obj->getSystemState()->unaccountedMemory) FlushInvalidationQueueEvent()); //getVm()->addEvent(_MR(th),event); return NULL; } @@ -2458,7 +2458,7 @@ _NR<RootMovieClip> root = th->getRoot(); if (!root.isNull()) rgb = root->getBackground(); - return abstract_ui(rgb.toUInt()); + return abstract_ui(obj->getSystemState(),rgb.toUInt()); } ASFUNCTIONBODY(Stage,_setColor) @@ -2477,40 +2477,40 @@ void StageScaleMode::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("EXACT_FIT","",abstract_s("exactFit"),CONSTANT_TRAIT); - c->setVariableByQName("NO_BORDER","",abstract_s("noBorder"),CONSTANT_TRAIT); - c->setVariableByQName("NO_SCALE","",abstract_s("noScale"),CONSTANT_TRAIT); - c->setVariableByQName("SHOW_ALL","",abstract_s("showAll"),CONSTANT_TRAIT); + c->setVariableByQName("EXACT_FIT","",abstract_s(c->getSystemState(),"exactFit"),CONSTANT_TRAIT); + c->setVariableByQName("NO_BORDER","",abstract_s(c->getSystemState(),"noBorder"),CONSTANT_TRAIT); + c->setVariableByQName("NO_SCALE","",abstract_s(c->getSystemState(),"noScale"),CONSTANT_TRAIT); + c->setVariableByQName("SHOW_ALL","",abstract_s(c->getSystemState(),"showAll"),CONSTANT_TRAIT); } void StageAlign::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("BOTTOM","",abstract_s("B"),CONSTANT_TRAIT); - c->setVariableByQName("BOTTOM_LEFT","",abstract_s("BL"),CONSTANT_TRAIT); - c->setVariableByQName("BOTTOM_RIGHT","",abstract_s("BR"),CONSTANT_TRAIT); - c->setVariableByQName("LEFT","",abstract_s("L"),CONSTANT_TRAIT); - c->setVariableByQName("RIGHT","",abstract_s("R"),CONSTANT_TRAIT); - c->setVariableByQName("TOP","",abstract_s("T"),CONSTANT_TRAIT); - c->setVariableByQName("TOP_LEFT","",abstract_s("TL"),CONSTANT_TRAIT); - c->setVariableByQName("TOP_RIGHT","",abstract_s("TR"),CONSTANT_TRAIT); + c->setVariableByQName("BOTTOM","",abstract_s(c->getSystemState(),"B"),CONSTANT_TRAIT); + c->setVariableByQName("BOTTOM_LEFT","",abstract_s(c->getSystemState(),"BL"),CONSTANT_TRAIT); + c->setVariableByQName("BOTTOM_RIGHT","",abstract_s(c->getSystemState(),"BR"),CONSTANT_TRAIT); + c->setVariableByQName("LEFT","",abstract_s(c->getSystemState(),"L"),CONSTANT_TRAIT); + c->setVariableByQName("RIGHT","",abstract_s(c->getSystemState(),"R"),CONSTANT_TRAIT); + c->setVariableByQName("TOP","",abstract_s(c->getSystemState(),"T"),CONSTANT_TRAIT); + c->setVariableByQName("TOP_LEFT","",abstract_s(c->getSystemState(),"TL"),CONSTANT_TRAIT); + c->setVariableByQName("TOP_RIGHT","",abstract_s(c->getSystemState(),"TR"),CONSTANT_TRAIT); } void StageQuality::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("BEST","",abstract_s("best"),CONSTANT_TRAIT); - c->setVariableByQName("HIGH","",abstract_s("high"),CONSTANT_TRAIT); - c->setVariableByQName("LOW","",abstract_s("low"),CONSTANT_TRAIT); - c->setVariableByQName("MEDIUM","",abstract_s("medium"),CONSTANT_TRAIT); + c->setVariableByQName("BEST","",abstract_s(c->getSystemState(),"best"),CONSTANT_TRAIT); + c->setVariableByQName("HIGH","",abstract_s(c->getSystemState(),"high"),CONSTANT_TRAIT); + c->setVariableByQName("LOW","",abstract_s(c->getSystemState(),"low"),CONSTANT_TRAIT); + c->setVariableByQName("MEDIUM","",abstract_s(c->getSystemState(),"medium"),CONSTANT_TRAIT); } void StageDisplayState::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("FULL_SCREEN","",abstract_s("fullScreen"),CONSTANT_TRAIT); - c->setVariableByQName("FULL_SCREEN_INTERACTIVE","",abstract_s("fullScreenInteractive"),CONSTANT_TRAIT); - c->setVariableByQName("NORMAL","",abstract_s("normal"),CONSTANT_TRAIT); + c->setVariableByQName("FULL_SCREEN","",abstract_s(c->getSystemState(),"fullScreen"),CONSTANT_TRAIT); + c->setVariableByQName("FULL_SCREEN_INTERACTIVE","",abstract_s(c->getSystemState(),"fullScreenInteractive"),CONSTANT_TRAIT); + c->setVariableByQName("NORMAL","",abstract_s(c->getSystemState(),"normal"),CONSTANT_TRAIT); } Bitmap::Bitmap(Class_base* c, _NR<LoaderInfo> li, std::istream *s, FILE_TYPE type): @@ -2523,7 +2523,7 @@ loaderInfo->setWaitedObject(_MR(this)); } - bitmapData = _MR(Class<BitmapData>::getInstanceS()); + bitmapData = _MR(Class<BitmapData>::getInstanceS(c->getSystemState())); bitmapData->addUser(this); if(!s) return; @@ -2655,7 +2655,7 @@ tokens.emplace_back(GeomToken(STRAIGHT, Vector2(style.bitmap->getWidth(), 0))); tokens.emplace_back(GeomToken(STRAIGHT, Vector2(0, 0))); if(onStage) - requestInvalidation(getSys()); + requestInvalidation(getSystemState()); } bool Bitmap::boundsRect(number_t& xmin, number_t& xmax, number_t& ymin, number_t& ymax) const { @@ -2684,18 +2684,18 @@ void SimpleButton::sinit(Class_base* c) { CLASS_SETUP(c, InteractiveObject, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("upState","",Class<IFunction>::getFunction(_getUpState),GETTER_METHOD,true); - c->setDeclaredMethodByQName("upState","",Class<IFunction>::getFunction(_setUpState),SETTER_METHOD,true); - c->setDeclaredMethodByQName("downState","",Class<IFunction>::getFunction(_getDownState),GETTER_METHOD,true); - c->setDeclaredMethodByQName("downState","",Class<IFunction>::getFunction(_setDownState),SETTER_METHOD,true); - c->setDeclaredMethodByQName("overState","",Class<IFunction>::getFunction(_getOverState),GETTER_METHOD,true); - c->setDeclaredMethodByQName("overState","",Class<IFunction>::getFunction(_setOverState),SETTER_METHOD,true); - c->setDeclaredMethodByQName("hitTestState","",Class<IFunction>::getFunction(_getHitTestState),GETTER_METHOD,true); - c->setDeclaredMethodByQName("hitTestState","",Class<IFunction>::getFunction(_setHitTestState),SETTER_METHOD,true); - c->setDeclaredMethodByQName("enabled","",Class<IFunction>::getFunction(_getEnabled),GETTER_METHOD,true); - c->setDeclaredMethodByQName("enabled","",Class<IFunction>::getFunction(_setEnabled),SETTER_METHOD,true); - c->setDeclaredMethodByQName("useHandCursor","",Class<IFunction>::getFunction(_getUseHandCursor),GETTER_METHOD,true); - c->setDeclaredMethodByQName("useHandCursor","",Class<IFunction>::getFunction(_setUseHandCursor),SETTER_METHOD,true); + c->setDeclaredMethodByQName("upState","",Class<IFunction>::getFunction(c->getSystemState(),_getUpState),GETTER_METHOD,true); + c->setDeclaredMethodByQName("upState","",Class<IFunction>::getFunction(c->getSystemState(),_setUpState),SETTER_METHOD,true); + c->setDeclaredMethodByQName("downState","",Class<IFunction>::getFunction(c->getSystemState(),_getDownState),GETTER_METHOD,true); + c->setDeclaredMethodByQName("downState","",Class<IFunction>::getFunction(c->getSystemState(),_setDownState),SETTER_METHOD,true); + c->setDeclaredMethodByQName("overState","",Class<IFunction>::getFunction(c->getSystemState(),_getOverState),GETTER_METHOD,true); + c->setDeclaredMethodByQName("overState","",Class<IFunction>::getFunction(c->getSystemState(),_setOverState),SETTER_METHOD,true); + c->setDeclaredMethodByQName("hitTestState","",Class<IFunction>::getFunction(c->getSystemState(),_getHitTestState),GETTER_METHOD,true); + c->setDeclaredMethodByQName("hitTestState","",Class<IFunction>::getFunction(c->getSystemState(),_setHitTestState),SETTER_METHOD,true); + c->setDeclaredMethodByQName("enabled","",Class<IFunction>::getFunction(c->getSystemState(),_getEnabled),GETTER_METHOD,true); + c->setDeclaredMethodByQName("enabled","",Class<IFunction>::getFunction(c->getSystemState(),_setEnabled),SETTER_METHOD,true); + c->setDeclaredMethodByQName("useHandCursor","",Class<IFunction>::getFunction(c->getSystemState(),_getUseHandCursor),GETTER_METHOD,true); + c->setDeclaredMethodByQName("useHandCursor","",Class<IFunction>::getFunction(c->getSystemState(),_setUseHandCursor),SETTER_METHOD,true); } void SimpleButton::buildTraits(ASObject* o) @@ -2825,7 +2825,7 @@ { SimpleButton* th=static_cast<SimpleButton*>(obj); if(!th->upState) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); th->upState->incRef(); return th->upState.getPtr(); @@ -2845,7 +2845,7 @@ { SimpleButton* th=static_cast<SimpleButton*>(obj); if(!th->hitTestState) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); th->hitTestState->incRef(); return th->hitTestState.getPtr(); @@ -2864,7 +2864,7 @@ { SimpleButton* th=static_cast<SimpleButton*>(obj); if(!th->overState) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); th->overState->incRef(); return th->overState.getPtr(); @@ -2884,7 +2884,7 @@ { SimpleButton* th=static_cast<SimpleButton*>(obj); if(!th->downState) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); th->downState->incRef(); return th->downState.getPtr(); @@ -2911,7 +2911,7 @@ ASFUNCTIONBODY(SimpleButton,_getEnabled) { SimpleButton* th=static_cast<SimpleButton*>(obj); - return abstract_b(th->enabled); + return abstract_b(obj->getSystemState(),th->enabled); } ASFUNCTIONBODY(SimpleButton,_setUseHandCursor) @@ -2925,75 +2925,75 @@ ASFUNCTIONBODY(SimpleButton,_getUseHandCursor) { SimpleButton* th=static_cast<SimpleButton*>(obj); - return abstract_b(th->useHandCursor); + return abstract_b(obj->getSystemState(),th->useHandCursor); } void GradientType::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("LINEAR","",abstract_s("linear"),CONSTANT_TRAIT); - c->setVariableByQName("RADIAL","",abstract_s("radial"),CONSTANT_TRAIT); + c->setVariableByQName("LINEAR","",abstract_s(c->getSystemState(),"linear"),CONSTANT_TRAIT); + c->setVariableByQName("RADIAL","",abstract_s(c->getSystemState(),"radial"),CONSTANT_TRAIT); } void BlendMode::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("ADD","",abstract_s("add"),CONSTANT_TRAIT); - c->setVariableByQName("ALPHA","",abstract_s("alpha"),CONSTANT_TRAIT); - c->setVariableByQName("DARKEN","",abstract_s("darken"),CONSTANT_TRAIT); - c->setVariableByQName("DIFFERENCE","",abstract_s("difference"),CONSTANT_TRAIT); - c->setVariableByQName("ERASE","",abstract_s("erase"),CONSTANT_TRAIT); - c->setVariableByQName("HARDLIGHT","",abstract_s("hardlight"),CONSTANT_TRAIT); - c->setVariableByQName("INVERT","",abstract_s("invert"),CONSTANT_TRAIT); - c->setVariableByQName("LAYER","",abstract_s("layer"),CONSTANT_TRAIT); - c->setVariableByQName("LIGHTEN","",abstract_s("lighten"),CONSTANT_TRAIT); - c->setVariableByQName("MULTIPLY","",abstract_s("multiply"),CONSTANT_TRAIT); - c->setVariableByQName("NORMAL","",abstract_s("normal"),CONSTANT_TRAIT); - c->setVariableByQName("OVERLAY","",abstract_s("overlay"),CONSTANT_TRAIT); - c->setVariableByQName("SCREEN","",abstract_s("screen"),CONSTANT_TRAIT); - c->setVariableByQName("SUBTRACT","",abstract_s("subtract"),CONSTANT_TRAIT); + c->setVariableByQName("ADD","",abstract_s(c->getSystemState(),"add"),CONSTANT_TRAIT); + c->setVariableByQName("ALPHA","",abstract_s(c->getSystemState(),"alpha"),CONSTANT_TRAIT); + c->setVariableByQName("DARKEN","",abstract_s(c->getSystemState(),"darken"),CONSTANT_TRAIT); + c->setVariableByQName("DIFFERENCE","",abstract_s(c->getSystemState(),"difference"),CONSTANT_TRAIT); + c->setVariableByQName("ERASE","",abstract_s(c->getSystemState(),"erase"),CONSTANT_TRAIT); + c->setVariableByQName("HARDLIGHT","",abstract_s(c->getSystemState(),"hardlight"),CONSTANT_TRAIT); + c->setVariableByQName("INVERT","",abstract_s(c->getSystemState(),"invert"),CONSTANT_TRAIT); + c->setVariableByQName("LAYER","",abstract_s(c->getSystemState(),"layer"),CONSTANT_TRAIT); + c->setVariableByQName("LIGHTEN","",abstract_s(c->getSystemState(),"lighten"),CONSTANT_TRAIT); + c->setVariableByQName("MULTIPLY","",abstract_s(c->getSystemState(),"multiply"),CONSTANT_TRAIT); + c->setVariableByQName("NORMAL","",abstract_s(c->getSystemState(),"normal"),CONSTANT_TRAIT); + c->setVariableByQName("OVERLAY","",abstract_s(c->getSystemState(),"overlay"),CONSTANT_TRAIT); + c->setVariableByQName("SCREEN","",abstract_s(c->getSystemState(),"screen"),CONSTANT_TRAIT); + c->setVariableByQName("SUBTRACT","",abstract_s(c->getSystemState(),"subtract"),CONSTANT_TRAIT); } void SpreadMethod::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("PAD","",abstract_s("pad"),CONSTANT_TRAIT); - c->setVariableByQName("REFLECT","",abstract_s("reflect"),CONSTANT_TRAIT); - c->setVariableByQName("REPEAT","",abstract_s("repeat"),CONSTANT_TRAIT); + c->setVariableByQName("PAD","",abstract_s(c->getSystemState(),"pad"),CONSTANT_TRAIT); + c->setVariableByQName("REFLECT","",abstract_s(c->getSystemState(),"reflect"),CONSTANT_TRAIT); + c->setVariableByQName("REPEAT","",abstract_s(c->getSystemState(),"repeat"),CONSTANT_TRAIT); } void InterpolationMethod::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("RGB","",abstract_s("rgb"),CONSTANT_TRAIT); - c->setVariableByQName("LINEAR_RGB","",abstract_s("linearRGB"),CONSTANT_TRAIT); + c->setVariableByQName("RGB","",abstract_s(c->getSystemState(),"rgb"),CONSTANT_TRAIT); + c->setVariableByQName("LINEAR_RGB","",abstract_s(c->getSystemState(),"linearRGB"),CONSTANT_TRAIT); } void GraphicsPathCommand::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("CUBIC_CURVE_TO","",abstract_i(6),CONSTANT_TRAIT); - c->setVariableByQName("CURVE_TO","",abstract_i(3),CONSTANT_TRAIT); - c->setVariableByQName("LINE_TO","",abstract_i(2),CONSTANT_TRAIT); - c->setVariableByQName("MOVE_TO","",abstract_i(1),CONSTANT_TRAIT); - c->setVariableByQName("NO_OP","",abstract_i(0),CONSTANT_TRAIT); - c->setVariableByQName("WIDE_LINE_TO","",abstract_i(5),CONSTANT_TRAIT); - c->setVariableByQName("WIDE_MOVE_TO","",abstract_i(4),CONSTANT_TRAIT); + c->setVariableByQName("CUBIC_CURVE_TO","",abstract_i(c->getSystemState(),6),CONSTANT_TRAIT); + c->setVariableByQName("CURVE_TO","",abstract_i(c->getSystemState(),3),CONSTANT_TRAIT); + c->setVariableByQName("LINE_TO","",abstract_i(c->getSystemState(),2),CONSTANT_TRAIT); + c->setVariableByQName("MOVE_TO","",abstract_i(c->getSystemState(),1),CONSTANT_TRAIT); + c->setVariableByQName("NO_OP","",abstract_i(c->getSystemState(),0),CONSTANT_TRAIT); + c->setVariableByQName("WIDE_LINE_TO","",abstract_i(c->getSystemState(),5),CONSTANT_TRAIT); + c->setVariableByQName("WIDE_MOVE_TO","",abstract_i(c->getSystemState(),4),CONSTANT_TRAIT); } void GraphicsPathWinding::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("EVEN_ODD","",abstract_s("evenOdd"),CONSTANT_TRAIT); - c->setVariableByQName("NON_ZERO","",abstract_s("nonZero"),CONSTANT_TRAIT); + c->setVariableByQName("EVEN_ODD","",abstract_s(c->getSystemState(),"evenOdd"),CONSTANT_TRAIT); + c->setVariableByQName("NON_ZERO","",abstract_s(c->getSystemState(),"nonZero"),CONSTANT_TRAIT); } void PixelSnapping::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("ALWAYS","",abstract_s("always"),CONSTANT_TRAIT); - c->setVariableByQName("AUTO","",abstract_s("auto"),CONSTANT_TRAIT); - c->setVariableByQName("NEVER","",abstract_s("never"),CONSTANT_TRAIT); + c->setVariableByQName("ALWAYS","",abstract_s(c->getSystemState(),"always"),CONSTANT_TRAIT); + c->setVariableByQName("AUTO","",abstract_s(c->getSystemState(),"auto"),CONSTANT_TRAIT); + c->setVariableByQName("NEVER","",abstract_s(c->getSystemState(),"never"),CONSTANT_TRAIT); } @@ -3104,7 +3104,7 @@ * 2. and is exported as a subclass of MovieClip (see bindedTo) */ if((!dynamic_cast<RootMovieClip*>(this) && !fromDefineSpriteTag) - || !getClass()->isSubClass(Class<MovieClip>::getClass())) + || !getClass()->isSubClass(Class<MovieClip>::getClass(getSystemState()))) return; //If we have not yet loaded enough frames delay advancement @@ -3169,10 +3169,10 @@ void BitmapDataChannel::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("ALPHA","",abstract_ui(8),CONSTANT_TRAIT); - c->setVariableByQName("BLUE","",abstract_ui(4),CONSTANT_TRAIT); - c->setVariableByQName("GREEN","",abstract_ui(2),CONSTANT_TRAIT); - c->setVariableByQName("RED","",abstract_ui(1),CONSTANT_TRAIT); + c->setVariableByQName("ALPHA","",abstract_ui(c->getSystemState(),8),CONSTANT_TRAIT); + c->setVariableByQName("BLUE","",abstract_ui(c->getSystemState(),4),CONSTANT_TRAIT); + c->setVariableByQName("GREEN","",abstract_ui(c->getSystemState(),2),CONSTANT_TRAIT); + c->setVariableByQName("RED","",abstract_ui(c->getSystemState(),1),CONSTANT_TRAIT); } unsigned int BitmapDataChannel::channelShift(uint32_t channelConstant) @@ -3201,8 +3201,8 @@ void LineScaleMode::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("HORIZONTAL","",abstract_s("horizontal"),CONSTANT_TRAIT); - c->setVariableByQName("NONE","",abstract_s("none"),CONSTANT_TRAIT); - c->setVariableByQName("NORMAL","",abstract_s("normal"),CONSTANT_TRAIT); - c->setVariableByQName("VERTICAL","",abstract_s("vertical"),CONSTANT_TRAIT); + c->setVariableByQName("HORIZONTAL","",abstract_s(c->getSystemState(),"horizontal"),CONSTANT_TRAIT); + c->setVariableByQName("NONE","",abstract_s(c->getSystemState(),"none"),CONSTANT_TRAIT); + c->setVariableByQName("NORMAL","",abstract_s(c->getSystemState(),"normal"),CONSTANT_TRAIT); + c->setVariableByQName("VERTICAL","",abstract_s(c->getSystemState(),"vertical"),CONSTANT_TRAIT); }
View file
lightspark.tar.xz/src/scripting/flash/events/flashevents.cpp
Changed
@@ -50,62 +50,62 @@ void Event::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); - c->setVariableByQName("ACTIVATE","",Class<ASString>::getInstanceS("activate"),DECLARED_TRAIT); - c->setVariableByQName("ADDED","",Class<ASString>::getInstanceS("added"),DECLARED_TRAIT); - c->setVariableByQName("ADDED_TO_STAGE","",Class<ASString>::getInstanceS("addedToStage"),DECLARED_TRAIT); - c->setVariableByQName("CANCEL","",Class<ASString>::getInstanceS("cancel"),DECLARED_TRAIT); - c->setVariableByQName("CHANGE","",Class<ASString>::getInstanceS("change"),DECLARED_TRAIT); - c->setVariableByQName("CLEAR","",Class<ASString>::getInstanceS("clear"),DECLARED_TRAIT); - c->setVariableByQName("CLOSE","",Class<ASString>::getInstanceS("close"),DECLARED_TRAIT); - c->setVariableByQName("CLOSING","",Class<ASString>::getInstanceS("closing"),DECLARED_TRAIT); - c->setVariableByQName("COMPLETE","",Class<ASString>::getInstanceS("complete"),DECLARED_TRAIT); - c->setVariableByQName("CONNECT","",Class<ASString>::getInstanceS("connect"),DECLARED_TRAIT); - c->setVariableByQName("CONTEXT3D_CREATE","",Class<ASString>::getInstanceS("context3DCreate"),DECLARED_TRAIT); - c->setVariableByQName("COPY","",Class<ASString>::getInstanceS("copy"),DECLARED_TRAIT); - c->setVariableByQName("CUT","",Class<ASString>::getInstanceS("cut"),DECLARED_TRAIT); - c->setVariableByQName("DEACTIVATE","",Class<ASString>::getInstanceS("deactivate"),DECLARED_TRAIT); - c->setVariableByQName("DISPLAYING","",Class<ASString>::getInstanceS("displaying"),DECLARED_TRAIT); - c->setVariableByQName("ENTER_FRAME","",Class<ASString>::getInstanceS("enterFrame"),DECLARED_TRAIT); - c->setVariableByQName("EXIT_FRAME","",Class<ASString>::getInstanceS("exitFrame"),DECLARED_TRAIT); - c->setVariableByQName("EXITING","",Class<ASString>::getInstanceS("exiting"),DECLARED_TRAIT); - c->setVariableByQName("FRAME_CONSTRUCTED","",Class<ASString>::getInstanceS("frameConstructed"),DECLARED_TRAIT); - c->setVariableByQName("FULLSCREEN","",Class<ASString>::getInstanceS("fullScreen"),DECLARED_TRAIT); - c->setVariableByQName("HTML_BOUNDS_CHANGE","",Class<ASString>::getInstanceS("htmlBoundsChange"),DECLARED_TRAIT); - c->setVariableByQName("HTML_DOM_INITIALIZE","",Class<ASString>::getInstanceS("htmlDOMInitialize"),DECLARED_TRAIT); - c->setVariableByQName("HTML_RENDER","",Class<ASString>::getInstanceS("htmlRender"),DECLARED_TRAIT); - c->setVariableByQName("ID3","",Class<ASString>::getInstanceS("id3"),DECLARED_TRAIT); - c->setVariableByQName("INIT","",Class<ASString>::getInstanceS("init"),DECLARED_TRAIT); - c->setVariableByQName("LOCATION_CHANGE","",Class<ASString>::getInstanceS("locationChange"),DECLARED_TRAIT); - c->setVariableByQName("MOUSE_LEAVE","",Class<ASString>::getInstanceS("mouseLeave"),DECLARED_TRAIT); - c->setVariableByQName("NETWORK_CHANGE","",Class<ASString>::getInstanceS("networkChange"),DECLARED_TRAIT); - c->setVariableByQName("OPEN","",Class<ASString>::getInstanceS("open"),DECLARED_TRAIT); - c->setVariableByQName("PASTE","",Class<ASString>::getInstanceS("paste"),DECLARED_TRAIT); - c->setVariableByQName("REMOVED","",Class<ASString>::getInstanceS("removed"),DECLARED_TRAIT); - c->setVariableByQName("REMOVED_FROM_STAGE","",Class<ASString>::getInstanceS("removedFromStage"),DECLARED_TRAIT); - c->setVariableByQName("RENDER","",Class<ASString>::getInstanceS("render"),DECLARED_TRAIT); - c->setVariableByQName("RESIZE","",Class<ASString>::getInstanceS("resize"),DECLARED_TRAIT); - c->setVariableByQName("SCROLL","",Class<ASString>::getInstanceS("scroll"),DECLARED_TRAIT); - c->setVariableByQName("SELECT","",Class<ASString>::getInstanceS("select"),DECLARED_TRAIT); - c->setVariableByQName("SELECT_ALL","",Class<ASString>::getInstanceS("selectAll"),DECLARED_TRAIT); - c->setVariableByQName("SOUND_COMPLETE","",Class<ASString>::getInstanceS("soundComplete"),DECLARED_TRAIT); - c->setVariableByQName("STANDARD_ERROR_CLOSE","",Class<ASString>::getInstanceS("standardErrorClose"),DECLARED_TRAIT); - c->setVariableByQName("STANDARD_INPUT_CLOSE","",Class<ASString>::getInstanceS("standardInputClose"),DECLARED_TRAIT); - c->setVariableByQName("STANDARD_OUTPUT_CLOSE","",Class<ASString>::getInstanceS("standardOutputClose"),DECLARED_TRAIT); - c->setVariableByQName("TAB_CHILDREN_CHANGE","",Class<ASString>::getInstanceS("tabChildrenChange"),DECLARED_TRAIT); - c->setVariableByQName("TAB_ENABLED_CHANGE","",Class<ASString>::getInstanceS("tabEnabledChange"),DECLARED_TRAIT); - c->setVariableByQName("TAB_INDEX_CHANGE","",Class<ASString>::getInstanceS("tabIndexChange"),DECLARED_TRAIT); - c->setVariableByQName("TEXT_INTERACTION_MODE_CHANGE","",Class<ASString>::getInstanceS("textInteractionModeChange"),DECLARED_TRAIT); - c->setVariableByQName("TEXTURE_READY","",Class<ASString>::getInstanceS("textureReady"),DECLARED_TRAIT); - c->setVariableByQName("UNLOAD","",Class<ASString>::getInstanceS("unload"),DECLARED_TRAIT); - c->setVariableByQName("USER_IDLE","",Class<ASString>::getInstanceS("userIdle"),DECLARED_TRAIT); - c->setVariableByQName("USER_PRESENT","",Class<ASString>::getInstanceS("userPresent"),DECLARED_TRAIT); - - c->setDeclaredMethodByQName("formatToString","",Class<IFunction>::getFunction(formatToString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("isDefaultPrevented","",Class<IFunction>::getFunction(_isDefaultPrevented),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("preventDefault","",Class<IFunction>::getFunction(_preventDefault),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(clone),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("stopPropagation","",Class<IFunction>::getFunction(stopPropagation),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("stopImmediatePropagation","",Class<IFunction>::getFunction(stopImmediatePropagation),NORMAL_METHOD,true); + c->setVariableByQName("ACTIVATE","",abstract_s(c->getSystemState(),"activate"),DECLARED_TRAIT); + c->setVariableByQName("ADDED","",abstract_s(c->getSystemState(),"added"),DECLARED_TRAIT); + c->setVariableByQName("ADDED_TO_STAGE","",abstract_s(c->getSystemState(),"addedToStage"),DECLARED_TRAIT); + c->setVariableByQName("CANCEL","",abstract_s(c->getSystemState(),"cancel"),DECLARED_TRAIT); + c->setVariableByQName("CHANGE","",abstract_s(c->getSystemState(),"change"),DECLARED_TRAIT); + c->setVariableByQName("CLEAR","",abstract_s(c->getSystemState(),"clear"),DECLARED_TRAIT); + c->setVariableByQName("CLOSE","",abstract_s(c->getSystemState(),"close"),DECLARED_TRAIT); + c->setVariableByQName("CLOSING","",abstract_s(c->getSystemState(),"closing"),DECLARED_TRAIT); + c->setVariableByQName("COMPLETE","",abstract_s(c->getSystemState(),"complete"),DECLARED_TRAIT); + c->setVariableByQName("CONNECT","",abstract_s(c->getSystemState(),"connect"),DECLARED_TRAIT); + c->setVariableByQName("CONTEXT3D_CREATE","",abstract_s(c->getSystemState(),"context3DCreate"),DECLARED_TRAIT); + c->setVariableByQName("COPY","",abstract_s(c->getSystemState(),"copy"),DECLARED_TRAIT); + c->setVariableByQName("CUT","",abstract_s(c->getSystemState(),"cut"),DECLARED_TRAIT); + c->setVariableByQName("DEACTIVATE","",abstract_s(c->getSystemState(),"deactivate"),DECLARED_TRAIT); + c->setVariableByQName("DISPLAYING","",abstract_s(c->getSystemState(),"displaying"),DECLARED_TRAIT); + c->setVariableByQName("ENTER_FRAME","",abstract_s(c->getSystemState(),"enterFrame"),DECLARED_TRAIT); + c->setVariableByQName("EXIT_FRAME","",abstract_s(c->getSystemState(),"exitFrame"),DECLARED_TRAIT); + c->setVariableByQName("EXITING","",abstract_s(c->getSystemState(),"exiting"),DECLARED_TRAIT); + c->setVariableByQName("FRAME_CONSTRUCTED","",abstract_s(c->getSystemState(),"frameConstructed"),DECLARED_TRAIT); + c->setVariableByQName("FULLSCREEN","",abstract_s(c->getSystemState(),"fullScreen"),DECLARED_TRAIT); + c->setVariableByQName("HTML_BOUNDS_CHANGE","",abstract_s(c->getSystemState(),"htmlBoundsChange"),DECLARED_TRAIT); + c->setVariableByQName("HTML_DOM_INITIALIZE","",abstract_s(c->getSystemState(),"htmlDOMInitialize"),DECLARED_TRAIT); + c->setVariableByQName("HTML_RENDER","",abstract_s(c->getSystemState(),"htmlRender"),DECLARED_TRAIT); + c->setVariableByQName("ID3","",abstract_s(c->getSystemState(),"id3"),DECLARED_TRAIT); + c->setVariableByQName("INIT","",abstract_s(c->getSystemState(),"init"),DECLARED_TRAIT); + c->setVariableByQName("LOCATION_CHANGE","",abstract_s(c->getSystemState(),"locationChange"),DECLARED_TRAIT); + c->setVariableByQName("MOUSE_LEAVE","",abstract_s(c->getSystemState(),"mouseLeave"),DECLARED_TRAIT); + c->setVariableByQName("NETWORK_CHANGE","",abstract_s(c->getSystemState(),"networkChange"),DECLARED_TRAIT); + c->setVariableByQName("OPEN","",abstract_s(c->getSystemState(),"open"),DECLARED_TRAIT); + c->setVariableByQName("PASTE","",abstract_s(c->getSystemState(),"paste"),DECLARED_TRAIT); + c->setVariableByQName("REMOVED","",abstract_s(c->getSystemState(),"removed"),DECLARED_TRAIT); + c->setVariableByQName("REMOVED_FROM_STAGE","",abstract_s(c->getSystemState(),"removedFromStage"),DECLARED_TRAIT); + c->setVariableByQName("RENDER","",abstract_s(c->getSystemState(),"render"),DECLARED_TRAIT); + c->setVariableByQName("RESIZE","",abstract_s(c->getSystemState(),"resize"),DECLARED_TRAIT); + c->setVariableByQName("SCROLL","",abstract_s(c->getSystemState(),"scroll"),DECLARED_TRAIT); + c->setVariableByQName("SELECT","",abstract_s(c->getSystemState(),"select"),DECLARED_TRAIT); + c->setVariableByQName("SELECT_ALL","",abstract_s(c->getSystemState(),"selectAll"),DECLARED_TRAIT); + c->setVariableByQName("SOUND_COMPLETE","",abstract_s(c->getSystemState(),"soundComplete"),DECLARED_TRAIT); + c->setVariableByQName("STANDARD_ERROR_CLOSE","",abstract_s(c->getSystemState(),"standardErrorClose"),DECLARED_TRAIT); + c->setVariableByQName("STANDARD_INPUT_CLOSE","",abstract_s(c->getSystemState(),"standardInputClose"),DECLARED_TRAIT); + c->setVariableByQName("STANDARD_OUTPUT_CLOSE","",abstract_s(c->getSystemState(),"standardOutputClose"),DECLARED_TRAIT); + c->setVariableByQName("TAB_CHILDREN_CHANGE","",abstract_s(c->getSystemState(),"tabChildrenChange"),DECLARED_TRAIT); + c->setVariableByQName("TAB_ENABLED_CHANGE","",abstract_s(c->getSystemState(),"tabEnabledChange"),DECLARED_TRAIT); + c->setVariableByQName("TAB_INDEX_CHANGE","",abstract_s(c->getSystemState(),"tabIndexChange"),DECLARED_TRAIT); + c->setVariableByQName("TEXT_INTERACTION_MODE_CHANGE","",abstract_s(c->getSystemState(),"textInteractionModeChange"),DECLARED_TRAIT); + c->setVariableByQName("TEXTURE_READY","",abstract_s(c->getSystemState(),"textureReady"),DECLARED_TRAIT); + c->setVariableByQName("UNLOAD","",abstract_s(c->getSystemState(),"unload"),DECLARED_TRAIT); + c->setVariableByQName("USER_IDLE","",abstract_s(c->getSystemState(),"userIdle"),DECLARED_TRAIT); + c->setVariableByQName("USER_PRESENT","",abstract_s(c->getSystemState(),"userPresent"),DECLARED_TRAIT); + + c->setDeclaredMethodByQName("formatToString","",Class<IFunction>::getFunction(c->getSystemState(),formatToString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("isDefaultPrevented","",Class<IFunction>::getFunction(c->getSystemState(),_isDefaultPrevented),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("preventDefault","",Class<IFunction>::getFunction(c->getSystemState(),_preventDefault),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(c->getSystemState(),clone),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("stopPropagation","",Class<IFunction>::getFunction(c->getSystemState(),stopPropagation),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("stopImmediatePropagation","",Class<IFunction>::getFunction(c->getSystemState(),stopImmediatePropagation),NORMAL_METHOD,true); REGISTER_GETTER(c,currentTarget); REGISTER_GETTER(c,target); REGISTER_GETTER(c,type); @@ -139,7 +139,7 @@ ASFUNCTIONBODY(Event,_isDefaultPrevented) { Event* th=static_cast<Event*>(obj); - return abstract_b(th->defaultPrevented); + return abstract_b(obj->getSystemState(),th->defaultPrevented); } ASFUNCTIONBODY(Event,_preventDefault) @@ -165,20 +165,20 @@ multiname propName(NULL); propName.name_type=multiname::NAME_STRING; - propName.name_s_id=getSys()->getUniqueStringId(prop); - propName.ns.push_back(nsNameAndKind("",NAMESPACE)); + propName.name_s_id=obj->getSystemState()->getUniqueStringId(prop); + propName.ns.push_back(nsNameAndKind(obj->getSystemState(),"",NAMESPACE)); _NR<ASObject> value=th->getVariableByMultiname(propName); if (!value.isNull()) msg += value->toString(); } msg += "]"; - return Class<ASString>::getInstanceS(msg); + return abstract_s(obj->getSystemState(),msg); } Event* Event::cloneImpl() const { - return Class<Event>::getInstanceS(type, bubbles, cancelable); + return Class<Event>::getInstanceS(getSystemState(),type, bubbles, cancelable); } ASFUNCTIONBODY(Event,clone) @@ -203,9 +203,9 @@ void EventPhase::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("CAPTURING_PHASE","",abstract_i(CAPTURING_PHASE),DECLARED_TRAIT); - c->setVariableByQName("BUBBLING_PHASE","",abstract_i(BUBBLING_PHASE),DECLARED_TRAIT); - c->setVariableByQName("AT_TARGET","",abstract_i(AT_TARGET),DECLARED_TRAIT); + c->setVariableByQName("CAPTURING_PHASE","",abstract_i(c->getSystemState(),CAPTURING_PHASE),DECLARED_TRAIT); + c->setVariableByQName("BUBBLING_PHASE","",abstract_i(c->getSystemState(),BUBBLING_PHASE),DECLARED_TRAIT); + c->setVariableByQName("AT_TARGET","",abstract_i(c->getSystemState(),AT_TARGET),DECLARED_TRAIT); } FocusEvent::FocusEvent(Class_base* c):Event(c, "focusEvent") @@ -215,10 +215,10 @@ void FocusEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("FOCUS_IN","",Class<ASString>::getInstanceS("focusIn"),DECLARED_TRAIT); - c->setVariableByQName("FOCUS_OUT","",Class<ASString>::getInstanceS("focusOut"),DECLARED_TRAIT); - c->setVariableByQName("MOUSE_FOCUS_CHANGE","",Class<ASString>::getInstanceS("mouseFocusChange"),DECLARED_TRAIT); - c->setVariableByQName("KEY_FOCUS_CHANGE","",Class<ASString>::getInstanceS("keyFocusChange"),DECLARED_TRAIT); + c->setVariableByQName("FOCUS_IN","",abstract_s(c->getSystemState(),"focusIn"),DECLARED_TRAIT); + c->setVariableByQName("FOCUS_OUT","",abstract_s(c->getSystemState(),"focusOut"),DECLARED_TRAIT); + c->setVariableByQName("MOUSE_FOCUS_CHANGE","",abstract_s(c->getSystemState(),"mouseFocusChange"),DECLARED_TRAIT); + c->setVariableByQName("KEY_FOCUS_CHANGE","",abstract_s(c->getSystemState(),"keyFocusChange"),DECLARED_TRAIT); } ASFUNCTIONBODY(FocusEvent,_constructor) @@ -241,7 +241,7 @@ Event* MouseEvent::cloneImpl() const { - return Class<MouseEvent>::getInstanceS(type,localX,localY,bubbles,modifiers,relatedObject,delta); + return Class<MouseEvent>::getInstanceS(getSystemState(),type,localX,localY,bubbles,modifiers,relatedObject,delta); } ProgressEvent::ProgressEvent(Class_base* c):Event(c, "progress",false),bytesLoaded(0),bytesTotal(0) @@ -254,13 +254,13 @@ Event* ProgressEvent::cloneImpl() const { - return Class<ProgressEvent>::getInstanceS(bytesLoaded, bytesTotal); + return Class<ProgressEvent>::getInstanceS(getSystemState(),bytesLoaded, bytesTotal); } void ProgressEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("PROGRESS","",Class<ASString>::getInstanceS("progress"),DECLARED_TRAIT); + c->setVariableByQName("PROGRESS","",abstract_s(c->getSystemState(),"progress"),DECLARED_TRAIT); REGISTER_GETTER_SETTER(c,bytesLoaded); REGISTER_GETTER_SETTER(c,bytesTotal); } @@ -288,9 +288,9 @@ void TimerEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("TIMER","",Class<ASString>::getInstanceS("timer"),DECLARED_TRAIT); - c->setVariableByQName("TIMER_COMPLETE","",Class<ASString>::getInstanceS("timerComplete"),DECLARED_TRAIT); - c->setDeclaredMethodByQName("updateAfterEvent","",Class<IFunction>::getFunction(updateAfterEvent),NORMAL_METHOD,true); + c->setVariableByQName("TIMER","",abstract_s(c->getSystemState(),"timer"),DECLARED_TRAIT); + c->setVariableByQName("TIMER_COMPLETE","",abstract_s(c->getSystemState(),"timerComplete"),DECLARED_TRAIT); + c->setDeclaredMethodByQName("updateAfterEvent","",Class<IFunction>::getFunction(c->getSystemState(),updateAfterEvent),NORMAL_METHOD,true); } ASFUNCTIONBODY(TimerEvent,updateAfterEvent) { @@ -301,18 +301,18 @@ void MouseEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("CLICK","",Class<ASString>::getInstanceS("click"),DECLARED_TRAIT); - c->setVariableByQName("DOUBLE_CLICK","",Class<ASString>::getInstanceS("doubleClick"),DECLARED_TRAIT); - c->setVariableByQName("MOUSE_DOWN","",Class<ASString>::getInstanceS("mouseDown"),DECLARED_TRAIT); - c->setVariableByQName("MOUSE_OUT","",Class<ASString>::getInstanceS("mouseOut"),DECLARED_TRAIT); - c->setVariableByQName("MOUSE_OVER","",Class<ASString>::getInstanceS("mouseOver"),DECLARED_TRAIT); - c->setVariableByQName("MOUSE_UP","",Class<ASString>::getInstanceS("mouseUp"),DECLARED_TRAIT); - c->setVariableByQName("MOUSE_WHEEL","",Class<ASString>::getInstanceS("mouseWheel"),DECLARED_TRAIT); - c->setVariableByQName("MOUSE_MOVE","",Class<ASString>::getInstanceS("mouseMove"),DECLARED_TRAIT); - c->setVariableByQName("RIGHT_CLICK","",Class<ASString>::getInstanceS("rightClick"),DECLARED_TRAIT); - c->setVariableByQName("ROLL_OVER","",Class<ASString>::getInstanceS("rollOver"),DECLARED_TRAIT); - c->setVariableByQName("ROLL_OUT","",Class<ASString>::getInstanceS("rollOut"),DECLARED_TRAIT); - c->setDeclaredMethodByQName("updateAfterEvent","",Class<IFunction>::getFunction(updateAfterEvent),NORMAL_METHOD,true); + c->setVariableByQName("CLICK","",abstract_s(c->getSystemState(),"click"),DECLARED_TRAIT); + c->setVariableByQName("DOUBLE_CLICK","",abstract_s(c->getSystemState(),"doubleClick"),DECLARED_TRAIT); + c->setVariableByQName("MOUSE_DOWN","",abstract_s(c->getSystemState(),"mouseDown"),DECLARED_TRAIT); + c->setVariableByQName("MOUSE_OUT","",abstract_s(c->getSystemState(),"mouseOut"),DECLARED_TRAIT); + c->setVariableByQName("MOUSE_OVER","",abstract_s(c->getSystemState(),"mouseOver"),DECLARED_TRAIT); + c->setVariableByQName("MOUSE_UP","",abstract_s(c->getSystemState(),"mouseUp"),DECLARED_TRAIT); + c->setVariableByQName("MOUSE_WHEEL","",abstract_s(c->getSystemState(),"mouseWheel"),DECLARED_TRAIT); + c->setVariableByQName("MOUSE_MOVE","",abstract_s(c->getSystemState(),"mouseMove"),DECLARED_TRAIT); + c->setVariableByQName("RIGHT_CLICK","",abstract_s(c->getSystemState(),"rightClick"),DECLARED_TRAIT); + c->setVariableByQName("ROLL_OVER","",abstract_s(c->getSystemState(),"rollOver"),DECLARED_TRAIT); + c->setVariableByQName("ROLL_OUT","",abstract_s(c->getSystemState(),"rollOut"),DECLARED_TRAIT); + c->setDeclaredMethodByQName("updateAfterEvent","",Class<IFunction>::getFunction(c->getSystemState(),updateAfterEvent),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c,relatedObject); REGISTER_GETTER(c,stageX); @@ -371,12 +371,12 @@ { MouseEvent* th=static_cast<MouseEvent*>(obj); if(argslen != 1) - throw Class<ArgumentError>::getInstanceS("Wrong number of arguments in setter"); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Wrong number of arguments in setter"); number_t val=args[0]->toNumber(); th->localX = val; //Change StageXY if target!=NULL else don't do anything //At this point, the target should be an InteractiveObject but check anyway - if(th->target &&(th->target->getClass()->isSubClass(Class<InteractiveObject>::getClass()))) + if(th->target &&(th->target->getClass()->isSubClass(Class<InteractiveObject>::getClass(obj->getSystemState())))) { InteractiveObject* tar = static_cast<InteractiveObject*>((th->target).getPtr()); tar->localToGlobal(th->localX, th->localY, th->stageX, th->stageY); @@ -388,12 +388,12 @@ { MouseEvent* th=static_cast<MouseEvent*>(obj); if(argslen != 1) - throw Class<ArgumentError>::getInstanceS("Wrong number of arguments in setter"); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Wrong number of arguments in setter"); number_t val=args[0]->toNumber(); th->localY = val; //Change StageXY if target!=NULL else don't do anything //At this point, the target should be an InteractiveObject but check anyway - if(th->target &&(th->target->getClass()->isSubClass(Class<InteractiveObject>::getClass()))) + if(th->target &&(th->target->getClass()->isSubClass(Class<InteractiveObject>::getClass(obj->getSystemState())))) { InteractiveObject* tar = static_cast<InteractiveObject*>((th->target).getPtr()); tar->localToGlobal(th->localX, th->localY, th->stageX, th->stageY); @@ -404,7 +404,7 @@ ASFUNCTIONBODY(MouseEvent,_getter_buttonDown) { MouseEvent* th=static_cast<MouseEvent*>(obj); - return abstract_b(th->modifiers & GDK_BUTTON1_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & GDK_BUTTON1_MASK); } ASFUNCTIONBODY(MouseEvent,_setter_buttonDown) @@ -417,7 +417,7 @@ ASFUNCTIONBODY(MouseEvent,_getter_altKey) { MouseEvent* th=static_cast<MouseEvent*>(obj); - return abstract_b(th->modifiers & GDK_MOD1_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & GDK_MOD1_MASK); } ASFUNCTIONBODY(MouseEvent,_setter_altKey) @@ -430,7 +430,7 @@ ASFUNCTIONBODY(MouseEvent,_getter_controlKey) { MouseEvent* th=static_cast<MouseEvent*>(obj); - return abstract_b(th->modifiers & GDK_CONTROL_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & GDK_CONTROL_MASK); } ASFUNCTIONBODY(MouseEvent,_setter_controlKey) @@ -443,7 +443,7 @@ ASFUNCTIONBODY(MouseEvent,_getter_ctrlKey) { MouseEvent* th=static_cast<MouseEvent*>(obj); - return abstract_b(th->modifiers & GDK_CONTROL_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & GDK_CONTROL_MASK); } ASFUNCTIONBODY(MouseEvent,_setter_ctrlKey) @@ -456,7 +456,7 @@ ASFUNCTIONBODY(MouseEvent,_getter_shiftKey) { MouseEvent* th=static_cast<MouseEvent*>(obj); - return abstract_b(th->modifiers & GDK_SHIFT_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & GDK_SHIFT_MASK); } ASFUNCTIONBODY(MouseEvent,_setter_shiftKey) @@ -491,7 +491,7 @@ relatedObject = NullRef; } //If t is non null, it should be an InteractiveObject - else if(t->getClass()->isSubClass(Class<InteractiveObject>::getClass())) + else if(t->getClass()->isSubClass(Class<InteractiveObject>::getClass(getSystemState()))) { InteractiveObject* tar = static_cast<InteractiveObject*>(t.getPtr()); tar->localToGlobal(localX, localY, stageX, stageY); @@ -504,20 +504,20 @@ Event *IOErrorEvent::cloneImpl() const { - return Class<IOErrorEvent>::getInstanceS(text, errorMsg,errorID); + return Class<IOErrorEvent>::getInstanceS(getSystemState(),text, errorMsg,errorID); } void IOErrorEvent::sinit(Class_base* c) { CLASS_SETUP(c, ErrorEvent, _constructor, CLASS_SEALED); - c->setVariableByQName("IO_ERROR","",Class<ASString>::getInstanceS("ioError"),CONSTANT_TRAIT); - c->setVariableByQName("DISK_ERROR","",Class<ASString>::getInstanceS("diskError"),CONSTANT_TRAIT); - c->setVariableByQName("NETWORK_ERROR","",Class<ASString>::getInstanceS("networkError"),CONSTANT_TRAIT); - c->setVariableByQName("VERIFY_ERROR","",Class<ASString>::getInstanceS("verifyError"),CONSTANT_TRAIT); - c->setVariableByQName("STANDARD_ERROR_IO_ERROR","",Class<ASString>::getInstanceS("standardErrorIoError"),CONSTANT_TRAIT); - c->setVariableByQName("STANDARD_INPUT_IO_ERROR","",Class<ASString>::getInstanceS("standardInputIoError"),CONSTANT_TRAIT); - c->setVariableByQName("STANDARD_OUTPUT_IO_ERROR","",Class<ASString>::getInstanceS("standardOutputIoError"),CONSTANT_TRAIT); + c->setVariableByQName("IO_ERROR","",abstract_s(c->getSystemState(),"ioError"),CONSTANT_TRAIT); + c->setVariableByQName("DISK_ERROR","",abstract_s(c->getSystemState(),"diskError"),CONSTANT_TRAIT); + c->setVariableByQName("NETWORK_ERROR","",abstract_s(c->getSystemState(),"networkError"),CONSTANT_TRAIT); + c->setVariableByQName("VERIFY_ERROR","",abstract_s(c->getSystemState(),"verifyError"),CONSTANT_TRAIT); + c->setVariableByQName("STANDARD_ERROR_IO_ERROR","",abstract_s(c->getSystemState(),"standardErrorIoError"),CONSTANT_TRAIT); + c->setVariableByQName("STANDARD_INPUT_IO_ERROR","",abstract_s(c->getSystemState(),"standardInputIoError"),CONSTANT_TRAIT); + c->setVariableByQName("STANDARD_OUTPUT_IO_ERROR","",abstract_s(c->getSystemState(),"standardOutputIoError"),CONSTANT_TRAIT); } EventDispatcher::EventDispatcher(Class_base* c):ASObject(c) @@ -534,12 +534,12 @@ void EventDispatcher::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); - c->addImplementedInterface(InterfaceClass<IEventDispatcher>::getClass()); + c->addImplementedInterface(InterfaceClass<IEventDispatcher>::getClass(c->getSystemState())); - c->setDeclaredMethodByQName("addEventListener","",Class<IFunction>::getFunction(addEventListener),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("hasEventListener","",Class<IFunction>::getFunction(_hasEventListener),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("removeEventListener","",Class<IFunction>::getFunction(removeEventListener),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("dispatchEvent","",Class<IFunction>::getFunction(dispatchEvent),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("addEventListener","",Class<IFunction>::getFunction(c->getSystemState(),addEventListener),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("hasEventListener","",Class<IFunction>::getFunction(c->getSystemState(),_hasEventListener),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("removeEventListener","",Class<IFunction>::getFunction(c->getSystemState(),removeEventListener),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("dispatchEvent","",Class<IFunction>::getFunction(c->getSystemState(),dispatchEvent),NORMAL_METHOD,true); IEventDispatcher::linkTraits(c); } @@ -579,7 +579,7 @@ || eventName=="frameConstructed") ) { dispobj->incRef(); - getSys()->registerFrameListener(_MR(dispobj)); + obj->getSystemState()->registerFrameListener(_MR(dispobj)); } { @@ -602,7 +602,7 @@ assert_and_throw(argslen==1 && args[0]->getObjectType()==T_STRING); const tiny_string& eventName=args[0]->toString(); bool ret=th->hasEventListener(eventName); - return abstract_b(ret); + return abstract_b(obj->getSystemState(),ret); } ASFUNCTIONBODY(EventDispatcher,removeEventListener) @@ -648,7 +648,7 @@ && !th->hasEventListener("frameConstructed")) ) { dispobj->incRef(); - getSys()->unregisterFrameListener(_MR(dispobj)); + obj->getSystemState()->unregisterFrameListener(_MR(dispobj)); } return NULL; @@ -657,8 +657,8 @@ ASFUNCTIONBODY(EventDispatcher,dispatchEvent) { EventDispatcher* th=Class<EventDispatcher>::cast(obj); - if(args[0]->getClass()==NULL || !(args[0]->getClass()->isSubClass(Class<Event>::getClass()))) - return abstract_b(false); + if(args[0]->getClass()==NULL || !(args[0]->getClass()->isSubClass(Class<Event>::getClass(obj->getSystemState())))) + return abstract_b(obj->getSystemState(),false); args[0]->incRef(); _R<Event> e=_MR(Class<Event>::cast(args[0])); @@ -672,7 +672,7 @@ _NR<ASObject> cloned = e->executeASMethod("clone", {""}, NULL, 0); //Clone always exists since it's implemented in Event itself if(!cloned->is<Event>()) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); cloned->incRef(); e = _MR(cloned->as<Event>()); @@ -681,7 +681,7 @@ e->setTarget(th->forcedTarget); th->incRef(); ABCVm::publicHandleEvent(_MR(th), e); - return abstract_b(true); + return abstract_b(obj->getSystemState(),true); } ASFUNCTIONBODY(EventDispatcher,_constructor) @@ -693,8 +693,8 @@ { if(forcedTarget->getObjectType()==T_NULL || forcedTarget->getObjectType()==T_UNDEFINED) forcedTarget=NullRef; - else if(!forcedTarget->getClass()->isSubClass(InterfaceClass<IEventDispatcher>::getClass())) - throw Class<ArgumentError>::getInstanceS("Wrong argument for EventDispatcher"); + else if(!forcedTarget->getClass()->isSubClass(InterfaceClass<IEventDispatcher>::getClass(obj->getSystemState()))) + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Wrong argument for EventDispatcher"); } th->forcedTarget=forcedTarget; return NULL; @@ -748,18 +748,18 @@ return true; } -NetStatusEvent::NetStatusEvent(Class_base* cb, const tiny_string& level, const tiny_string& code):Event(cb, "netStatus") +NetStatusEvent::NetStatusEvent(Class_base* c, const tiny_string& level, const tiny_string& code):Event(c, "netStatus") { - ASObject* info=Class<ASObject>::getInstanceS(); - info->setVariableByQName("level","",Class<ASString>::getInstanceS(level),DECLARED_TRAIT); - info->setVariableByQName("code","",Class<ASString>::getInstanceS(code),DECLARED_TRAIT); + ASObject* info=Class<ASObject>::getInstanceS(c->getSystemState()); + info->setVariableByQName("level","",abstract_s(c->getSystemState(),level),DECLARED_TRAIT); + info->setVariableByQName("code","",abstract_s(c->getSystemState(),code),DECLARED_TRAIT); setVariableByQName("info","",info, DECLARED_TRAIT); } void NetStatusEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("NET_STATUS","",Class<ASString>::getInstanceS("netStatus"),DECLARED_TRAIT); + c->setVariableByQName("NET_STATUS","",abstract_s(c->getSystemState(),"netStatus"),DECLARED_TRAIT); } ASFUNCTIONBODY(NetStatusEvent,_constructor) @@ -783,12 +783,12 @@ else { //Uninitialized info - info=getSys()->getNullRef(); + info=obj->getSystemState()->getNullRef(); } multiname infoName(NULL); infoName.name_type=multiname::NAME_STRING; - infoName.name_s_id=getSys()->getUniqueStringId("info"); - infoName.ns.push_back(nsNameAndKind("",NAMESPACE)); + infoName.name_s_id=obj->getSystemState()->getUniqueStringId("info"); + infoName.ns.push_back(nsNameAndKind(obj->getSystemState(),"",NAMESPACE)); infoName.isAttribute = false; obj->setVariableByMultiname(infoName, info, CONST_NOT_ALLOWED); return NULL; @@ -796,15 +796,15 @@ Event* NetStatusEvent::cloneImpl() const { - NetStatusEvent *clone=Class<NetStatusEvent>::getInstanceS(); + NetStatusEvent *clone=Class<NetStatusEvent>::getInstanceS(getSystemState()); clone->type = type; clone->bubbles = bubbles; clone->cancelable = cancelable; multiname infoName(NULL); infoName.name_type=multiname::NAME_STRING; - infoName.name_s_id=getSys()->getUniqueStringId("info"); - infoName.ns.push_back(nsNameAndKind("",NAMESPACE)); + infoName.name_s_id=getSystemState()->getUniqueStringId("info"); + infoName.ns.push_back(nsNameAndKind(getSystemState(),"",NAMESPACE)); infoName.isAttribute = false; _NR<ASObject> info = const_cast<NetStatusEvent*>(this)->getVariableByMultiname(infoName); @@ -822,7 +822,7 @@ void FullScreenEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("FULL_SCREEN","",Class<ASString>::getInstanceS("fullScreen"),DECLARED_TRAIT); + c->setVariableByQName("FULL_SCREEN","",abstract_s(c->getSystemState(),"fullScreen"),DECLARED_TRAIT); } ASFUNCTIONBODY(FullScreenEvent,_constructor) @@ -848,8 +848,8 @@ REGISTER_GETTER_SETTER(c, keyCode); REGISTER_GETTER_SETTER(c, keyLocation); REGISTER_GETTER_SETTER(c, shiftKey); - c->setVariableByQName("KEY_DOWN","",Class<ASString>::getInstanceS("keyDown"),DECLARED_TRAIT); - c->setVariableByQName("KEY_UP","",Class<ASString>::getInstanceS("keyUp"),DECLARED_TRAIT); + c->setVariableByQName("KEY_DOWN","",abstract_s(c->getSystemState(),"keyDown"),DECLARED_TRAIT); + c->setVariableByQName("KEY_UP","",abstract_s(c->getSystemState(),"keyUp"),DECLARED_TRAIT); } ASFUNCTIONBODY(KeyboardEvent,_constructor) @@ -896,7 +896,7 @@ ASFUNCTIONBODY(KeyboardEvent, _getter_altKey) { KeyboardEvent* th=static_cast<KeyboardEvent*>(obj); - return abstract_b(th->modifiers & GDK_MOD1_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & GDK_MOD1_MASK); } ASFUNCTIONBODY(KeyboardEvent, _setter_altKey) @@ -909,7 +909,7 @@ ASFUNCTIONBODY(KeyboardEvent, _getter_commandKey) { // Supported only on OSX - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); } ASFUNCTIONBODY(KeyboardEvent, _setter_commandKey) @@ -921,7 +921,7 @@ ASFUNCTIONBODY(KeyboardEvent, _getter_controlKey) { KeyboardEvent* th=static_cast<KeyboardEvent*>(obj); - return abstract_b(th->modifiers & GDK_CONTROL_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & GDK_CONTROL_MASK); } ASFUNCTIONBODY(KeyboardEvent, _setter_controlKey) @@ -934,7 +934,7 @@ ASFUNCTIONBODY(KeyboardEvent, _getter_ctrlKey) { KeyboardEvent* th=static_cast<KeyboardEvent*>(obj); - return abstract_b(th->modifiers & GDK_CONTROL_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & GDK_CONTROL_MASK); } ASFUNCTIONBODY(KeyboardEvent, _setter_ctrlKey) @@ -947,7 +947,7 @@ ASFUNCTIONBODY(KeyboardEvent, _getter_shiftKey) { KeyboardEvent* th=static_cast<KeyboardEvent*>(obj); - return abstract_b(th->modifiers & GDK_SHIFT_MASK); + return abstract_b(obj->getSystemState(),th->modifiers & GDK_SHIFT_MASK); } ASFUNCTIONBODY(KeyboardEvent, _setter_shiftKey) @@ -959,7 +959,7 @@ Event* KeyboardEvent::cloneImpl() const { - KeyboardEvent *cloned = Class<KeyboardEvent>::getInstanceS(); + KeyboardEvent *cloned = Class<KeyboardEvent>::getInstanceS(getSystemState()); cloned->type = type; cloned->bubbles = bubbles; cloned->cancelable = cancelable; @@ -977,7 +977,7 @@ void TextEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("TEXT_INPUT","",Class<ASString>::getInstanceS("textInput"),DECLARED_TRAIT); + c->setVariableByQName("TEXT_INPUT","",abstract_s(c->getSystemState(),"textInput"),DECLARED_TRAIT); REGISTER_GETTER_SETTER(c,text); } @@ -1000,14 +1000,14 @@ void ErrorEvent::sinit(Class_base* c) { CLASS_SETUP(c, TextEvent, _constructor, CLASS_SEALED); - c->setVariableByQName("ERROR","",Class<ASString>::getInstanceS("error"),DECLARED_TRAIT); + c->setVariableByQName("ERROR","",abstract_s(c->getSystemState(),"error"),DECLARED_TRAIT); REGISTER_GETTER(c,errorID); } ASFUNCTIONBODY_GETTER(ErrorEvent,errorID); Event* ErrorEvent::cloneImpl() const { - return Class<ErrorEvent>::getInstanceS(text, errorMsg,errorID); + return Class<ErrorEvent>::getInstanceS(getSystemState(),text, errorMsg,errorID); } ASFUNCTIONBODY(ErrorEvent,_constructor) @@ -1027,7 +1027,7 @@ void SecurityErrorEvent::sinit(Class_base* c) { CLASS_SETUP(c, ErrorEvent, _constructor, CLASS_SEALED); - c->setVariableByQName("SECURITY_ERROR","",Class<ASString>::getInstanceS("securityError"),DECLARED_TRAIT); + c->setVariableByQName("SECURITY_ERROR","",abstract_s(c->getSystemState(),"securityError"),DECLARED_TRAIT); } AsyncErrorEvent::AsyncErrorEvent(Class_base* c):ErrorEvent(c, "asyncError") @@ -1037,7 +1037,7 @@ void AsyncErrorEvent::sinit(Class_base* c) { CLASS_SETUP(c, ErrorEvent, _constructor, CLASS_SEALED); - c->setVariableByQName("ASYNC_ERROR","",Class<ASString>::getInstanceS("asyncError"),DECLARED_TRAIT); + c->setVariableByQName("ASYNC_ERROR","",abstract_s(c->getSystemState(),"asyncError"),DECLARED_TRAIT); } ASFUNCTIONBODY(AsyncErrorEvent,_constructor) @@ -1055,7 +1055,7 @@ void UncaughtErrorEvent::sinit(Class_base* c) { CLASS_SETUP(c, ErrorEvent, _constructor, CLASS_SEALED); - c->setVariableByQName("UNCAUGHT_ERROR","",Class<ASString>::getInstanceS("uncaughtError"),DECLARED_TRAIT); + c->setVariableByQName("UNCAUGHT_ERROR","",abstract_s(c->getSystemState(),"uncaughtError"),DECLARED_TRAIT); } ASFUNCTIONBODY(UncaughtErrorEvent,_constructor) @@ -1076,7 +1076,7 @@ void HTTPStatusEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("HTTP_STATUS","",Class<ASString>::getInstanceS("httpStatus"),DECLARED_TRAIT); + c->setVariableByQName("HTTP_STATUS","",abstract_s(c->getSystemState(),"httpStatus"),DECLARED_TRAIT); } ASFUNCTIONBODY(HTTPStatusEvent,_constructor) @@ -1141,16 +1141,16 @@ { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); /* TODO: dispatch this event */ - c->setVariableByQName("STATUS","",Class<ASString>::getInstanceS("status"),DECLARED_TRAIT); + c->setVariableByQName("STATUS","",abstract_s(c->getSystemState(),"status"),DECLARED_TRAIT); } void DataEvent::sinit(Class_base* c) { CLASS_SETUP(c, TextEvent, _constructor, CLASS_SEALED); /* TODO: dispatch this event */ - c->setVariableByQName("DATA","",Class<ASString>::getInstanceS("data"),DECLARED_TRAIT); + c->setVariableByQName("DATA","",abstract_s(c->getSystemState(),"data"),DECLARED_TRAIT); /* TODO: dispatch this event */ - c->setVariableByQName("UPLOAD_COMPLETE_DATA","",Class<ASString>::getInstanceS("uploadCompleteData"),DECLARED_TRAIT); + c->setVariableByQName("UPLOAD_COMPLETE_DATA","",abstract_s(c->getSystemState(),"uploadCompleteData"),DECLARED_TRAIT); REGISTER_GETTER_SETTER(c, data); } @@ -1173,7 +1173,7 @@ Event* DataEvent::cloneImpl() const { - DataEvent *clone = Class<DataEvent>::getInstanceS(); + DataEvent *clone = Class<DataEvent>::getInstanceS(getSystemState()); clone->data = data; // TextEvent clone->text = text; @@ -1187,7 +1187,7 @@ void InvokeEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("INVOKE","",Class<ASString>::getInstanceS("invoke"),DECLARED_TRAIT); + c->setVariableByQName("INVOKE","",abstract_s(c->getSystemState(),"invoke"),DECLARED_TRAIT); } ASFUNCTIONBODY(InvokeEvent,_constructor) @@ -1204,8 +1204,8 @@ void DRMErrorEvent::sinit(Class_base* c) { CLASS_SETUP(c, ErrorEvent, _constructor, CLASS_SEALED); - c->setVariableByQName("DRM_ERROR","",Class<ASString>::getInstanceS("drmError"),DECLARED_TRAIT); - c->setVariableByQName("DRM_LOAD_DEVICEID_ERROR","",Class<ASString>::getInstanceS("drmLoadDeviceIdError"),DECLARED_TRAIT); + c->setVariableByQName("DRM_ERROR","",abstract_s(c->getSystemState(),"drmError"),DECLARED_TRAIT); + c->setVariableByQName("DRM_LOAD_DEVICEID_ERROR","",abstract_s(c->getSystemState(),"drmLoadDeviceIdError"),DECLARED_TRAIT); } ASFUNCTIONBODY(DRMErrorEvent,_constructor) @@ -1224,7 +1224,7 @@ void DRMStatusEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("DRM_STATUS","",Class<ASString>::getInstanceS("drmStatus"),DECLARED_TRAIT); + c->setVariableByQName("DRM_STATUS","",abstract_s(c->getSystemState(),"drmStatus"),DECLARED_TRAIT); } ASFUNCTIONBODY(DRMStatusEvent,_constructor) @@ -1244,10 +1244,10 @@ void VideoEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("RENDER_STATE","",Class<ASString>::getInstanceS("renderState"),CONSTANT_TRAIT); - c->setVariableByQName("RENDER_STATUS_ACCELERATED","",Class<ASString>::getInstanceS("accelerated"),CONSTANT_TRAIT); - c->setVariableByQName("RENDER_STATUS_SOFTWARE","",Class<ASString>::getInstanceS("software"),CONSTANT_TRAIT); - c->setVariableByQName("RENDER_STATUS_UNAVAILABLE","",Class<ASString>::getInstanceS("unavailable"),CONSTANT_TRAIT); + c->setVariableByQName("RENDER_STATE","",abstract_s(c->getSystemState(),"renderState"),CONSTANT_TRAIT); + c->setVariableByQName("RENDER_STATUS_ACCELERATED","",abstract_s(c->getSystemState(),"accelerated"),CONSTANT_TRAIT); + c->setVariableByQName("RENDER_STATUS_SOFTWARE","",abstract_s(c->getSystemState(),"software"),CONSTANT_TRAIT); + c->setVariableByQName("RENDER_STATUS_UNAVAILABLE","",abstract_s(c->getSystemState(),"unavailable"),CONSTANT_TRAIT); REGISTER_GETTER(c,status); } @@ -1268,7 +1268,7 @@ Event* VideoEvent::cloneImpl() const { VideoEvent *clone; - clone = Class<VideoEvent>::getInstanceS(); + clone = Class<VideoEvent>::getInstanceS(getSystemState()); clone->status = status; // Event clone->type = type; @@ -1288,7 +1288,7 @@ void StageVideoEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("RENDER_STATE","",Class<ASString>::getInstanceS("renderState"),CONSTANT_TRAIT); + c->setVariableByQName("RENDER_STATE","",abstract_s(c->getSystemState(),"renderState"),CONSTANT_TRAIT); REGISTER_GETTER(c,colorSpace); REGISTER_GETTER(c,status); } @@ -1314,7 +1314,7 @@ Event* StageVideoEvent::cloneImpl() const { StageVideoEvent *clone; - clone = Class<StageVideoEvent>::getInstanceS(); + clone = Class<StageVideoEvent>::getInstanceS(getSystemState()); clone->status = status; clone->colorSpace = colorSpace; // Event @@ -1335,7 +1335,7 @@ void StageVideoAvailabilityEvent::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, Event, CLASS_SEALED); - c->setVariableByQName("STAGE_VIDEO_AVAILABILITY","",Class<ASString>::getInstanceS("stageVideoAvailability"),DECLARED_TRAIT); + c->setVariableByQName("STAGE_VIDEO_AVAILABILITY","",abstract_s(c->getSystemState(),"stageVideoAvailability"),DECLARED_TRAIT); REGISTER_GETTER(c, availability); } @@ -1356,7 +1356,7 @@ Event* StageVideoAvailabilityEvent::cloneImpl() const { StageVideoAvailabilityEvent *clone; - clone = Class<StageVideoAvailabilityEvent>::getInstanceS(); + clone = Class<StageVideoAvailabilityEvent>::getInstanceS(getSystemState()); clone->availability = availability; // Event clone->type = type; @@ -1370,43 +1370,43 @@ void ContextMenuEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("MENU_ITEM_SELECT","",Class<ASString>::getInstanceS("menuItemSelect"),DECLARED_TRAIT); - c->setVariableByQName("MENU_SELECT","",Class<ASString>::getInstanceS("menuSelect"),DECLARED_TRAIT); + c->setVariableByQName("MENU_ITEM_SELECT","",abstract_s(c->getSystemState(),"menuItemSelect"),DECLARED_TRAIT); + c->setVariableByQName("MENU_SELECT","",abstract_s(c->getSystemState(),"menuSelect"),DECLARED_TRAIT); } void TouchEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("TOUCH_BEGIN","",Class<ASString>::getInstanceS("touchBegin"),DECLARED_TRAIT); - c->setVariableByQName("TOUCH_END","",Class<ASString>::getInstanceS("touchEnd"),DECLARED_TRAIT); - c->setVariableByQName("TOUCH_MOVE","",Class<ASString>::getInstanceS("touchMove"),DECLARED_TRAIT); - c->setVariableByQName("TOUCH_OUT","",Class<ASString>::getInstanceS("touchOut"),DECLARED_TRAIT); - c->setVariableByQName("TOUCH_OVER","",Class<ASString>::getInstanceS("touchOver"),DECLARED_TRAIT); - c->setVariableByQName("TOUCH_ROLL_OUT","",Class<ASString>::getInstanceS("touchRollOut"),DECLARED_TRAIT); - c->setVariableByQName("TOUCH_ROLL_OVER","",Class<ASString>::getInstanceS("touchRollOver"),DECLARED_TRAIT); - c->setVariableByQName("TOUCH_TAP","",Class<ASString>::getInstanceS("touchTap"),DECLARED_TRAIT); + c->setVariableByQName("TOUCH_BEGIN","",abstract_s(c->getSystemState(),"touchBegin"),DECLARED_TRAIT); + c->setVariableByQName("TOUCH_END","",abstract_s(c->getSystemState(),"touchEnd"),DECLARED_TRAIT); + c->setVariableByQName("TOUCH_MOVE","",abstract_s(c->getSystemState(),"touchMove"),DECLARED_TRAIT); + c->setVariableByQName("TOUCH_OUT","",abstract_s(c->getSystemState(),"touchOut"),DECLARED_TRAIT); + c->setVariableByQName("TOUCH_OVER","",abstract_s(c->getSystemState(),"touchOver"),DECLARED_TRAIT); + c->setVariableByQName("TOUCH_ROLL_OUT","",abstract_s(c->getSystemState(),"touchRollOut"),DECLARED_TRAIT); + c->setVariableByQName("TOUCH_ROLL_OVER","",abstract_s(c->getSystemState(),"touchRollOver"),DECLARED_TRAIT); + c->setVariableByQName("TOUCH_TAP","",abstract_s(c->getSystemState(),"touchTap"),DECLARED_TRAIT); } void GestureEvent::sinit(Class_base* c) { CLASS_SETUP(c, Event, _constructor, CLASS_SEALED); - c->setVariableByQName("GESTURE_TWO_FINGER_TAP","",Class<ASString>::getInstanceS("gestureTwoFingerTap"),DECLARED_TRAIT); + c->setVariableByQName("GESTURE_TWO_FINGER_TAP","",abstract_s(c->getSystemState(),"gestureTwoFingerTap"),DECLARED_TRAIT); } void PressAndTapGestureEvent::sinit(Class_base* c) { CLASS_SETUP(c, GestureEvent, _constructor, CLASS_SEALED); - c->setVariableByQName("GESTURE_PRESS_AND_TAP","",Class<ASString>::getInstanceS("gesturePressAndTap"),DECLARED_TRAIT); + c->setVariableByQName("GESTURE_PRESS_AND_TAP","",abstract_s(c->getSystemState(),"gesturePressAndTap"),DECLARED_TRAIT); } void TransformGestureEvent::sinit(Class_base* c) { CLASS_SETUP(c, GestureEvent, _constructor, CLASS_SEALED); - c->setVariableByQName("GESTURE_PAN","",Class<ASString>::getInstanceS("gesturePan"),DECLARED_TRAIT); - c->setVariableByQName("GESTURE_ROTATE","",Class<ASString>::getInstanceS("gestureRotate"),DECLARED_TRAIT); - c->setVariableByQName("GESTURE_SWIPE","",Class<ASString>::getInstanceS("gestureSwipe"),DECLARED_TRAIT); - c->setVariableByQName("GESTURE_ZOOM","",Class<ASString>::getInstanceS("gestureZoom"),DECLARED_TRAIT); + c->setVariableByQName("GESTURE_PAN","",abstract_s(c->getSystemState(),"gesturePan"),DECLARED_TRAIT); + c->setVariableByQName("GESTURE_ROTATE","",abstract_s(c->getSystemState(),"gestureRotate"),DECLARED_TRAIT); + c->setVariableByQName("GESTURE_SWIPE","",abstract_s(c->getSystemState(),"gestureSwipe"),DECLARED_TRAIT); + c->setVariableByQName("GESTURE_ZOOM","",abstract_s(c->getSystemState(),"gestureZoom"),DECLARED_TRAIT); } UncaughtErrorEvents::UncaughtErrorEvents(Class_base* c):
View file
lightspark.tar.xz/src/scripting/flash/external/ExternalInterface.cpp
Changed
@@ -27,39 +27,40 @@ void ExternalInterface::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setDeclaredMethodByQName("available","",Class<IFunction>::getFunction(_getAvailable),GETTER_METHOD,false); - c->setDeclaredMethodByQName("objectID","",Class<IFunction>::getFunction(_getObjectID),GETTER_METHOD,false); - c->setDeclaredMethodByQName("marshallExceptions","",Class<IFunction>::getFunction(_getMarshallExceptions),GETTER_METHOD,false); - c->setDeclaredMethodByQName("marshallExceptions","",Class<IFunction>::getFunction(_setMarshallExceptions),SETTER_METHOD,false); - c->setDeclaredMethodByQName("addCallback","",Class<IFunction>::getFunction(addCallback),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("call","",Class<IFunction>::getFunction(call),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("available","",Class<IFunction>::getFunction(c->getSystemState(),_getAvailable),GETTER_METHOD,false); + c->setDeclaredMethodByQName("objectID","",Class<IFunction>::getFunction(c->getSystemState(),_getObjectID),GETTER_METHOD,false); + c->setDeclaredMethodByQName("marshallExceptions","",Class<IFunction>::getFunction(c->getSystemState(),_getMarshallExceptions),GETTER_METHOD,false); + c->setDeclaredMethodByQName("marshallExceptions","",Class<IFunction>::getFunction(c->getSystemState(),_setMarshallExceptions),SETTER_METHOD,false); + c->setDeclaredMethodByQName("addCallback","",Class<IFunction>::getFunction(c->getSystemState(),addCallback),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("call","",Class<IFunction>::getFunction(c->getSystemState(),call),NORMAL_METHOD,false); } ASFUNCTIONBODY(ExternalInterface,_getAvailable) { - return abstract_b(getSys()->extScriptObject != NULL); + return abstract_b(getSys(),getSys()->extScriptObject != NULL); } ASFUNCTIONBODY(ExternalInterface,_getObjectID) { - if(getSys()->extScriptObject == NULL) - return Class<ASString>::getInstanceS(""); + SystemState* sys = getSys(); + if(sys->extScriptObject == NULL) + return abstract_s(sys,""); - ExtScriptObject* so=getSys()->extScriptObject; + ExtScriptObject* so=sys->extScriptObject; if(so->hasProperty("name")==false) - return Class<ASString>::getInstanceS(""); + return abstract_s(sys,""); const ExtVariant& object = so->getProperty("name"); std::string result = object.getString(); - return Class<ASString>::getInstanceS(result); + return abstract_s(sys,result); } ASFUNCTIONBODY(ExternalInterface, _getMarshallExceptions) { if(getSys()->extScriptObject == NULL) - return abstract_b(false); + return abstract_b(getSys(),false); else - return abstract_b(getSys()->extScriptObject->getMarshallExceptions()); + return abstract_b(getSys(),getSys()->extScriptObject->getMarshallExceptions()); } ASFUNCTIONBODY(ExternalInterface, _setMarshallExceptions) @@ -73,7 +74,7 @@ ASFUNCTIONBODY(ExternalInterface,addCallback) { if(getSys()->extScriptObject == NULL) - return abstract_b(false); + return abstract_b(getSys(),false); // throw Class<ASError>::getInstanceS("Container doesn't support callbacks"); assert_and_throw(argslen == 2); @@ -85,7 +86,7 @@ IFunction* f=static_cast<IFunction*>(args[1]); getSys()->extScriptObject->setMethod(args[0]->toString().raw_buf(), new ExtASCallback(f)); } - return abstract_b(true); + return abstract_b(getSys(),true); } ASFUNCTIONBODY(ExternalInterface,call)
View file
lightspark.tar.xz/src/scripting/flash/filters/flashfilters.cpp
Changed
@@ -27,12 +27,12 @@ void BitmapFilter::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_SEALED); - c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(clone),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(c->getSystemState(),clone),NORMAL_METHOD,true); } BitmapFilter* BitmapFilter::cloneImpl() const { - return Class<BitmapFilter>::getInstanceS(); + return Class<BitmapFilter>::getInstanceS(getSystemState()); } ASFUNCTIONBODY(BitmapFilter,clone) @@ -85,7 +85,7 @@ BitmapFilter* GlowFilter::cloneImpl() const { - GlowFilter *cloned = Class<GlowFilter>::getInstanceS(); + GlowFilter *cloned = Class<GlowFilter>::getInstanceS(getSystemState()); cloned->alpha = alpha; cloned->blurX = blurX; cloned->blurY = blurY; @@ -151,7 +151,7 @@ BitmapFilter* DropShadowFilter::cloneImpl() const { - DropShadowFilter *cloned = Class<DropShadowFilter>::getInstanceS(); + DropShadowFilter *cloned = Class<DropShadowFilter>::getInstanceS(getSystemState()); cloned->alpha = alpha; cloned->angle = angle; cloned->blurX = blurX; @@ -185,7 +185,7 @@ BitmapFilter* GradientGlowFilter::cloneImpl() const { - return Class<GradientGlowFilter>::getInstanceS(); + return Class<GradientGlowFilter>::getInstanceS(getSystemState()); } BevelFilter::BevelFilter(Class_base* c): @@ -207,7 +207,7 @@ BitmapFilter* BevelFilter::cloneImpl() const { - return Class<BevelFilter>::getInstanceS(); + return Class<BevelFilter>::getInstanceS(getSystemState()); } ColorMatrixFilter::ColorMatrixFilter(Class_base* c): BitmapFilter(c),matrix(NULL) @@ -231,7 +231,7 @@ BitmapFilter* ColorMatrixFilter::cloneImpl() const { - ColorMatrixFilter *cloned = Class<ColorMatrixFilter>::getInstanceS(); + ColorMatrixFilter *cloned = Class<ColorMatrixFilter>::getInstanceS(getSystemState()); if (!matrix.isNull()) { matrix->incRef(); @@ -258,7 +258,7 @@ BitmapFilter* BlurFilter::cloneImpl() const { - return Class<BlurFilter>::getInstanceS(); + return Class<BlurFilter>::getInstanceS(getSystemState()); } ConvolutionFilter::ConvolutionFilter(Class_base* c): @@ -280,7 +280,7 @@ BitmapFilter* ConvolutionFilter::cloneImpl() const { - return Class<ConvolutionFilter>::getInstanceS(); + return Class<ConvolutionFilter>::getInstanceS(getSystemState()); } DisplacementMapFilter::DisplacementMapFilter(Class_base* c): @@ -302,7 +302,7 @@ BitmapFilter* DisplacementMapFilter::cloneImpl() const { - return Class<DisplacementMapFilter>::getInstanceS(); + return Class<DisplacementMapFilter>::getInstanceS(getSystemState()); } GradientBevelFilter::GradientBevelFilter(Class_base* c): @@ -324,7 +324,7 @@ BitmapFilter* GradientBevelFilter::cloneImpl() const { - return Class<GradientBevelFilter>::getInstanceS(); + return Class<GradientBevelFilter>::getInstanceS(getSystemState()); } ShaderFilter::ShaderFilter(Class_base* c): @@ -346,13 +346,13 @@ BitmapFilter* ShaderFilter::cloneImpl() const { - return Class<ShaderFilter>::getInstanceS(); + return Class<ShaderFilter>::getInstanceS(getSystemState()); } void BitmapFilterQuality::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("HIGH","",abstract_i(3),DECLARED_TRAIT); - c->setVariableByQName("LOW","",abstract_i(1),DECLARED_TRAIT); - c->setVariableByQName("MEDIUM","",abstract_i(3),DECLARED_TRAIT); + c->setVariableByQName("HIGH","",abstract_i(c->getSystemState(),3),DECLARED_TRAIT); + c->setVariableByQName("LOW","",abstract_i(c->getSystemState(),1),DECLARED_TRAIT); + c->setVariableByQName("MEDIUM","",abstract_i(c->getSystemState(),3),DECLARED_TRAIT); }
View file
lightspark.tar.xz/src/scripting/flash/geom/flashgeom.cpp
Changed
@@ -27,57 +27,57 @@ void Rectangle::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); - IFunction* gleft=Class<IFunction>::getFunction(_getLeft); + IFunction* gleft=Class<IFunction>::getFunction(c->getSystemState(),_getLeft); c->setDeclaredMethodByQName("left","",gleft,GETTER_METHOD,true); gleft->incRef(); c->setDeclaredMethodByQName("x","",gleft,GETTER_METHOD,true); - IFunction* sleft=Class<IFunction>::getFunction(_setLeft); + IFunction* sleft=Class<IFunction>::getFunction(c->getSystemState(),_setLeft); c->setDeclaredMethodByQName("left","",sleft,SETTER_METHOD,true); sleft->incRef(); c->setDeclaredMethodByQName("x","",sleft,SETTER_METHOD,true); - c->setDeclaredMethodByQName("right","",Class<IFunction>::getFunction(_getRight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("right","",Class<IFunction>::getFunction(_setRight),SETTER_METHOD,true); - c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(_getWidth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(_setWidth),SETTER_METHOD,true); + c->setDeclaredMethodByQName("right","",Class<IFunction>::getFunction(c->getSystemState(),_getRight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("right","",Class<IFunction>::getFunction(c->getSystemState(),_setRight),SETTER_METHOD,true); + c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(c->getSystemState(),_getWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(c->getSystemState(),_setWidth),SETTER_METHOD,true); - IFunction* gtop=Class<IFunction>::getFunction(_getTop); + IFunction* gtop=Class<IFunction>::getFunction(c->getSystemState(),_getTop); c->setDeclaredMethodByQName("top","",gtop,GETTER_METHOD,true); gtop->incRef(); c->setDeclaredMethodByQName("y","",gtop,GETTER_METHOD,true); - IFunction* stop=Class<IFunction>::getFunction(_setTop); + IFunction* stop=Class<IFunction>::getFunction(c->getSystemState(),_setTop); c->setDeclaredMethodByQName("top","",stop,SETTER_METHOD,true); stop->incRef(); c->setDeclaredMethodByQName("y","",stop,SETTER_METHOD,true); - c->setDeclaredMethodByQName("bottom","",Class<IFunction>::getFunction(_getBottom),GETTER_METHOD,true); - c->setDeclaredMethodByQName("bottom","",Class<IFunction>::getFunction(_setBottom),SETTER_METHOD,true); - c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(_getHeight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(_setHeight),SETTER_METHOD,true); - - c->setDeclaredMethodByQName("bottomRight","",Class<IFunction>::getFunction(_getBottomRight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("bottomRight","",Class<IFunction>::getFunction(_setBottomRight),SETTER_METHOD,true); - - c->setDeclaredMethodByQName("size","",Class<IFunction>::getFunction(_getSize),GETTER_METHOD,true); - c->setDeclaredMethodByQName("size","",Class<IFunction>::getFunction(_setSize),SETTER_METHOD,true); - - c->setDeclaredMethodByQName("topLeft","",Class<IFunction>::getFunction(_getTopLeft),GETTER_METHOD,true); - c->setDeclaredMethodByQName("topLeft","",Class<IFunction>::getFunction(_setTopLeft),SETTER_METHOD,true); - - c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(clone),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("contains","",Class<IFunction>::getFunction(contains),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("containsPoint","",Class<IFunction>::getFunction(containsPoint),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("containsRect","",Class<IFunction>::getFunction(containsRect),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("equals","",Class<IFunction>::getFunction(equals),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("inflate","",Class<IFunction>::getFunction(inflate),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("inflatePoint","",Class<IFunction>::getFunction(inflatePoint),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("intersection","",Class<IFunction>::getFunction(intersection),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("intersects","",Class<IFunction>::getFunction(intersects),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("isEmpty","",Class<IFunction>::getFunction(isEmpty),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("offset","",Class<IFunction>::getFunction(offset),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("offsetPoint","",Class<IFunction>::getFunction(offsetPoint),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setEmpty","",Class<IFunction>::getFunction(setEmpty),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("union","",Class<IFunction>::getFunction(_union),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("bottom","",Class<IFunction>::getFunction(c->getSystemState(),_getBottom),GETTER_METHOD,true); + c->setDeclaredMethodByQName("bottom","",Class<IFunction>::getFunction(c->getSystemState(),_setBottom),SETTER_METHOD,true); + c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(c->getSystemState(),_getHeight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(c->getSystemState(),_setHeight),SETTER_METHOD,true); + + c->setDeclaredMethodByQName("bottomRight","",Class<IFunction>::getFunction(c->getSystemState(),_getBottomRight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("bottomRight","",Class<IFunction>::getFunction(c->getSystemState(),_setBottomRight),SETTER_METHOD,true); + + c->setDeclaredMethodByQName("size","",Class<IFunction>::getFunction(c->getSystemState(),_getSize),GETTER_METHOD,true); + c->setDeclaredMethodByQName("size","",Class<IFunction>::getFunction(c->getSystemState(),_setSize),SETTER_METHOD,true); + + c->setDeclaredMethodByQName("topLeft","",Class<IFunction>::getFunction(c->getSystemState(),_getTopLeft),GETTER_METHOD,true); + c->setDeclaredMethodByQName("topLeft","",Class<IFunction>::getFunction(c->getSystemState(),_setTopLeft),SETTER_METHOD,true); + + c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(c->getSystemState(),clone),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("contains","",Class<IFunction>::getFunction(c->getSystemState(),contains),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("containsPoint","",Class<IFunction>::getFunction(c->getSystemState(),containsPoint),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("containsRect","",Class<IFunction>::getFunction(c->getSystemState(),containsRect),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("equals","",Class<IFunction>::getFunction(c->getSystemState(),equals),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("inflate","",Class<IFunction>::getFunction(c->getSystemState(),inflate),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("inflatePoint","",Class<IFunction>::getFunction(c->getSystemState(),inflatePoint),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("intersection","",Class<IFunction>::getFunction(c->getSystemState(),intersection),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("intersects","",Class<IFunction>::getFunction(c->getSystemState(),intersects),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("isEmpty","",Class<IFunction>::getFunction(c->getSystemState(),isEmpty),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("offset","",Class<IFunction>::getFunction(c->getSystemState(),offset),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("offsetPoint","",Class<IFunction>::getFunction(c->getSystemState(),offsetPoint),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setEmpty","",Class<IFunction>::getFunction(c->getSystemState(),setEmpty),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("union","",Class<IFunction>::getFunction(c->getSystemState(),_union),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); } void Rectangle::buildTraits(ASObject* o) @@ -108,7 +108,7 @@ ASFUNCTIONBODY(Rectangle,_getLeft) { Rectangle* th=static_cast<Rectangle*>(obj); - return abstract_d(th->x); + return abstract_d(obj->getSystemState(),th->x); } ASFUNCTIONBODY(Rectangle,_setLeft) @@ -122,7 +122,7 @@ ASFUNCTIONBODY(Rectangle,_getRight) { Rectangle* th=static_cast<Rectangle*>(obj); - return abstract_d(th->x + th->width); + return abstract_d(obj->getSystemState(),th->x + th->width); } ASFUNCTIONBODY(Rectangle,_setRight) @@ -136,7 +136,7 @@ ASFUNCTIONBODY(Rectangle,_getWidth) { Rectangle* th=static_cast<Rectangle*>(obj); - return abstract_d(th->width); + return abstract_d(obj->getSystemState(),th->width); } ASFUNCTIONBODY(Rectangle,_setWidth) @@ -150,7 +150,7 @@ ASFUNCTIONBODY(Rectangle,_getTop) { Rectangle* th=static_cast<Rectangle*>(obj); - return abstract_d(th->y); + return abstract_d(obj->getSystemState(),th->y); } ASFUNCTIONBODY(Rectangle,_setTop) @@ -164,7 +164,7 @@ ASFUNCTIONBODY(Rectangle,_getBottom) { Rectangle* th=static_cast<Rectangle*>(obj); - return abstract_d(th->y + th->height); + return abstract_d(obj->getSystemState(),th->y + th->height); } ASFUNCTIONBODY(Rectangle,_setBottom) @@ -179,7 +179,7 @@ { assert_and_throw(argslen==0); Rectangle* th = static_cast<Rectangle*>(obj); - Point* ret = Class<Point>::getInstanceS(th->x + th->width, th->y + th->height); + Point* ret = Class<Point>::getInstanceS(obj->getSystemState(),th->x + th->width, th->y + th->height); return ret; } @@ -197,7 +197,7 @@ { assert_and_throw(argslen==0); Rectangle* th = static_cast<Rectangle*>(obj); - Point* ret = Class<Point>::getInstanceS(th->x, th->y); + Point* ret = Class<Point>::getInstanceS(obj->getSystemState(),th->x, th->y); return ret; } @@ -215,7 +215,7 @@ { assert_and_throw(argslen==0); Rectangle* th = static_cast<Rectangle*>(obj); - Point* ret = Class<Point>::getInstanceS(th->width, th->height); + Point* ret = Class<Point>::getInstanceS(obj->getSystemState(),th->width, th->height); return ret; } @@ -232,7 +232,7 @@ ASFUNCTIONBODY(Rectangle,_getHeight) { Rectangle* th=static_cast<Rectangle*>(obj); - return abstract_d(th->height); + return abstract_d(obj->getSystemState(),th->height); } ASFUNCTIONBODY(Rectangle,_setHeight) @@ -246,7 +246,7 @@ ASFUNCTIONBODY(Rectangle,clone) { Rectangle* th=static_cast<Rectangle*>(obj); - Rectangle* ret=Class<Rectangle>::getInstanceS(); + Rectangle* ret=Class<Rectangle>::getInstanceS(obj->getSystemState()); ret->x=th->x; ret->y=th->y; ret->width=th->width; @@ -261,7 +261,7 @@ number_t x = args[0]->toNumber(); number_t y = args[1]->toNumber(); - return abstract_b( th->x <= x && x <= th->x + th->width + return abstract_b(obj->getSystemState(), th->x <= x && x <= th->x + th->width && th->y <= y && y <= th->y + th->height ); } @@ -273,7 +273,7 @@ number_t x = br->getX(); number_t y = br->getY(); - return abstract_b( th->x <= x && x <= th->x + th->width + return abstract_b(obj->getSystemState(), th->x <= x && x <= th->x + th->width && th->y <= y && y <= th->y + th->height ); } @@ -283,7 +283,7 @@ Rectangle* th = static_cast<Rectangle*>(obj); Rectangle* cr = static_cast<Rectangle*>(args[0]); - return abstract_b( th->x <= cr->x && cr->x + cr->width <= th->x + th->width + return abstract_b(obj->getSystemState(), th->x <= cr->x && cr->x + cr->width <= th->x + th->width && th->y <= cr->y && cr->y + cr->height <= th->y + th->height ); } @@ -293,7 +293,7 @@ Rectangle* th = static_cast<Rectangle*>(obj); Rectangle* co = static_cast<Rectangle*>(args[0]); - return abstract_b( th->x == co->x && th->width == co->width + return abstract_b(obj->getSystemState(), th->x == co->x && th->width == co->width && th->y == co->y && th->height == co->height ); } @@ -333,7 +333,7 @@ assert_and_throw(argslen == 1); Rectangle* th = static_cast<Rectangle*>(obj); Rectangle* ti = static_cast<Rectangle*>(args[0]); - Rectangle* ret = Class<Rectangle>::getInstanceS(); + Rectangle* ret = Class<Rectangle>::getInstanceS(obj->getSystemState()); number_t thtop = th->y; number_t thleft = th->x; @@ -400,7 +400,7 @@ number_t tiright = ti->x + ti->width; number_t tibottom = ti->y + ti->height; - return abstract_b( !(thtop > tibottom || thright < tileft || + return abstract_b(obj->getSystemState(), !(thtop > tibottom || thright < tileft || thbottom < titop || thleft > tiright) ); } @@ -409,7 +409,7 @@ assert_and_throw(argslen == 0); Rectangle* th = static_cast<Rectangle*>(obj); - return abstract_b( th->width <= 0 || th->height <= 0 ); + return abstract_b(obj->getSystemState(), th->width <= 0 || th->height <= 0 ); } ASFUNCTIONBODY(Rectangle,offset) @@ -453,7 +453,7 @@ assert_and_throw(argslen == 1); Rectangle* th = static_cast<Rectangle*>(obj); Rectangle* ti = static_cast<Rectangle*>(args[0]); - Rectangle* ret = Class<Rectangle>::getInstanceS(); + Rectangle* ret = Class<Rectangle>::getInstanceS(obj->getSystemState()); ret->x = th->x; ret->y = th->y; @@ -478,7 +478,7 @@ Rectangle* th=static_cast<Rectangle*>(obj); char buf[512]; snprintf(buf,512,"(x=%.2f, y=%.2f, w=%.2f, h=%.2f)",th->x,th->y,th->width,th->height); - return Class<ASString>::getInstanceS(buf); + return abstract_s(obj->getSystemState(),buf); } ColorTransform::ColorTransform(Class_base* c, const CXFORMWITHALPHA& cx) @@ -493,30 +493,30 @@ CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); // properties - c->setDeclaredMethodByQName("color","",Class<IFunction>::getFunction(getColor),GETTER_METHOD,true); - c->setDeclaredMethodByQName("color","",Class<IFunction>::getFunction(setColor),SETTER_METHOD,true); - - c->setDeclaredMethodByQName("redMultiplier","",Class<IFunction>::getFunction(getRedMultiplier),GETTER_METHOD,true); - c->setDeclaredMethodByQName("redMultiplier","",Class<IFunction>::getFunction(setRedMultiplier),SETTER_METHOD,true); - c->setDeclaredMethodByQName("greenMultiplier","",Class<IFunction>::getFunction(getGreenMultiplier),GETTER_METHOD,true); - c->setDeclaredMethodByQName("greenMultiplier","",Class<IFunction>::getFunction(setGreenMultiplier),SETTER_METHOD,true); - c->setDeclaredMethodByQName("blueMultiplier","",Class<IFunction>::getFunction(getBlueMultiplier),GETTER_METHOD,true); - c->setDeclaredMethodByQName("blueMultiplier","",Class<IFunction>::getFunction(setBlueMultiplier),SETTER_METHOD,true); - c->setDeclaredMethodByQName("alphaMultiplier","",Class<IFunction>::getFunction(getAlphaMultiplier),GETTER_METHOD,true); - c->setDeclaredMethodByQName("alphaMultiplier","",Class<IFunction>::getFunction(setAlphaMultiplier),SETTER_METHOD,true); - - c->setDeclaredMethodByQName("redOffset","",Class<IFunction>::getFunction(getRedOffset),GETTER_METHOD,true); - c->setDeclaredMethodByQName("redOffset","",Class<IFunction>::getFunction(setRedOffset),SETTER_METHOD,true); - c->setDeclaredMethodByQName("greenOffset","",Class<IFunction>::getFunction(getGreenOffset),GETTER_METHOD,true); - c->setDeclaredMethodByQName("greenOffset","",Class<IFunction>::getFunction(setGreenOffset),SETTER_METHOD,true); - c->setDeclaredMethodByQName("blueOffset","",Class<IFunction>::getFunction(getBlueOffset),GETTER_METHOD,true); - c->setDeclaredMethodByQName("blueOffset","",Class<IFunction>::getFunction(setBlueOffset),SETTER_METHOD,true); - c->setDeclaredMethodByQName("alphaOffset","",Class<IFunction>::getFunction(getAlphaOffset),GETTER_METHOD,true); - c->setDeclaredMethodByQName("alphaOffset","",Class<IFunction>::getFunction(setAlphaOffset),SETTER_METHOD,true); + c->setDeclaredMethodByQName("color","",Class<IFunction>::getFunction(c->getSystemState(),getColor),GETTER_METHOD,true); + c->setDeclaredMethodByQName("color","",Class<IFunction>::getFunction(c->getSystemState(),setColor),SETTER_METHOD,true); + + c->setDeclaredMethodByQName("redMultiplier","",Class<IFunction>::getFunction(c->getSystemState(),getRedMultiplier),GETTER_METHOD,true); + c->setDeclaredMethodByQName("redMultiplier","",Class<IFunction>::getFunction(c->getSystemState(),setRedMultiplier),SETTER_METHOD,true); + c->setDeclaredMethodByQName("greenMultiplier","",Class<IFunction>::getFunction(c->getSystemState(),getGreenMultiplier),GETTER_METHOD,true); + c->setDeclaredMethodByQName("greenMultiplier","",Class<IFunction>::getFunction(c->getSystemState(),setGreenMultiplier),SETTER_METHOD,true); + c->setDeclaredMethodByQName("blueMultiplier","",Class<IFunction>::getFunction(c->getSystemState(),getBlueMultiplier),GETTER_METHOD,true); + c->setDeclaredMethodByQName("blueMultiplier","",Class<IFunction>::getFunction(c->getSystemState(),setBlueMultiplier),SETTER_METHOD,true); + c->setDeclaredMethodByQName("alphaMultiplier","",Class<IFunction>::getFunction(c->getSystemState(),getAlphaMultiplier),GETTER_METHOD,true); + c->setDeclaredMethodByQName("alphaMultiplier","",Class<IFunction>::getFunction(c->getSystemState(),setAlphaMultiplier),SETTER_METHOD,true); + + c->setDeclaredMethodByQName("redOffset","",Class<IFunction>::getFunction(c->getSystemState(),getRedOffset),GETTER_METHOD,true); + c->setDeclaredMethodByQName("redOffset","",Class<IFunction>::getFunction(c->getSystemState(),setRedOffset),SETTER_METHOD,true); + c->setDeclaredMethodByQName("greenOffset","",Class<IFunction>::getFunction(c->getSystemState(),getGreenOffset),GETTER_METHOD,true); + c->setDeclaredMethodByQName("greenOffset","",Class<IFunction>::getFunction(c->getSystemState(),setGreenOffset),SETTER_METHOD,true); + c->setDeclaredMethodByQName("blueOffset","",Class<IFunction>::getFunction(c->getSystemState(),getBlueOffset),GETTER_METHOD,true); + c->setDeclaredMethodByQName("blueOffset","",Class<IFunction>::getFunction(c->getSystemState(),setBlueOffset),SETTER_METHOD,true); + c->setDeclaredMethodByQName("alphaOffset","",Class<IFunction>::getFunction(c->getSystemState(),getAlphaOffset),GETTER_METHOD,true); + c->setDeclaredMethodByQName("alphaOffset","",Class<IFunction>::getFunction(c->getSystemState(),setAlphaOffset),SETTER_METHOD,true); // methods - c->setDeclaredMethodByQName("concat","",Class<IFunction>::getFunction(concat),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("concat","",Class<IFunction>::getFunction(c->getSystemState(),concat),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); } void ColorTransform::buildTraits(ASObject* o) @@ -592,13 +592,13 @@ number_t color = (ao<<24) | (ro<<16) | (go<<8) | bo; - return abstract_d(color); + return abstract_d(obj->getSystemState(),color); } ASFUNCTIONBODY(ColorTransform,getRedMultiplier) { ColorTransform* th=static_cast<ColorTransform*>(obj); - return abstract_d(th->redMultiplier); + return abstract_d(obj->getSystemState(),th->redMultiplier); } ASFUNCTIONBODY(ColorTransform,setRedMultiplier) @@ -612,7 +612,7 @@ ASFUNCTIONBODY(ColorTransform,getGreenMultiplier) { ColorTransform* th=static_cast<ColorTransform*>(obj); - return abstract_d(th->greenMultiplier); + return abstract_d(obj->getSystemState(),th->greenMultiplier); } ASFUNCTIONBODY(ColorTransform,setGreenMultiplier) @@ -626,7 +626,7 @@ ASFUNCTIONBODY(ColorTransform,getBlueMultiplier) { ColorTransform* th=static_cast<ColorTransform*>(obj); - return abstract_d(th->blueMultiplier); + return abstract_d(obj->getSystemState(),th->blueMultiplier); } ASFUNCTIONBODY(ColorTransform,setBlueMultiplier) @@ -640,7 +640,7 @@ ASFUNCTIONBODY(ColorTransform,getAlphaMultiplier) { ColorTransform* th=static_cast<ColorTransform*>(obj); - return abstract_d(th->alphaMultiplier); + return abstract_d(obj->getSystemState(),th->alphaMultiplier); } ASFUNCTIONBODY(ColorTransform,setAlphaMultiplier) @@ -654,7 +654,7 @@ ASFUNCTIONBODY(ColorTransform,getRedOffset) { ColorTransform* th=static_cast<ColorTransform*>(obj); - return abstract_d(th->redOffset); + return abstract_d(obj->getSystemState(),th->redOffset); } ASFUNCTIONBODY(ColorTransform,setRedOffset) @@ -668,7 +668,7 @@ ASFUNCTIONBODY(ColorTransform,getGreenOffset) { ColorTransform* th=static_cast<ColorTransform*>(obj); - return abstract_d(th->greenOffset); + return abstract_d(obj->getSystemState(),th->greenOffset); } ASFUNCTIONBODY(ColorTransform,setGreenOffset) @@ -682,7 +682,7 @@ ASFUNCTIONBODY(ColorTransform,getBlueOffset) { ColorTransform* th=static_cast<ColorTransform*>(obj); - return abstract_d(th->blueOffset); + return abstract_d(obj->getSystemState(),th->blueOffset); } ASFUNCTIONBODY(ColorTransform,setBlueOffset) @@ -696,7 +696,7 @@ ASFUNCTIONBODY(ColorTransform,getAlphaOffset) { ColorTransform* th=static_cast<ColorTransform*>(obj); - return abstract_d(th->alphaOffset); + return abstract_d(obj->getSystemState(),th->alphaOffset); } ASFUNCTIONBODY(ColorTransform,setAlphaOffset) @@ -732,27 +732,27 @@ snprintf(buf,1024,"(redOffset=%f, redMultiplier=%f, greenOffset=%f, greenMultiplier=%f blueOffset=%f blueMultiplier=%f alphaOffset=%f, alphaMultiplier=%f)", th->redOffset, th->redMultiplier, th->greenOffset, th->greenMultiplier, th->blueOffset, th->blueMultiplier, th->alphaOffset, th->alphaMultiplier); - return Class<ASString>::getInstanceS(buf); + return abstract_s(obj->getSystemState(),buf); } void Point::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("x","",Class<IFunction>::getFunction(_getX),GETTER_METHOD,true); - c->setDeclaredMethodByQName("y","",Class<IFunction>::getFunction(_getY),GETTER_METHOD,true); - c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(_getlength),GETTER_METHOD,true); - c->setDeclaredMethodByQName("x","",Class<IFunction>::getFunction(_setX),SETTER_METHOD,true); - c->setDeclaredMethodByQName("y","",Class<IFunction>::getFunction(_setY),SETTER_METHOD,true); - c->setDeclaredMethodByQName("interpolate","",Class<IFunction>::getFunction(interpolate),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("distance","",Class<IFunction>::getFunction(distance),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("add","",Class<IFunction>::getFunction(add),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("subtract","",Class<IFunction>::getFunction(subtract),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(clone),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("equals","",Class<IFunction>::getFunction(equals),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("normalize","",Class<IFunction>::getFunction(normalize),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("offset","",Class<IFunction>::getFunction(offset),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("polar","",Class<IFunction>::getFunction(polar),NORMAL_METHOD,false); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("x","",Class<IFunction>::getFunction(c->getSystemState(),_getX),GETTER_METHOD,true); + c->setDeclaredMethodByQName("y","",Class<IFunction>::getFunction(c->getSystemState(),_getY),GETTER_METHOD,true); + c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(c->getSystemState(),_getlength),GETTER_METHOD,true); + c->setDeclaredMethodByQName("x","",Class<IFunction>::getFunction(c->getSystemState(),_setX),SETTER_METHOD,true); + c->setDeclaredMethodByQName("y","",Class<IFunction>::getFunction(c->getSystemState(),_setY),SETTER_METHOD,true); + c->setDeclaredMethodByQName("interpolate","",Class<IFunction>::getFunction(c->getSystemState(),interpolate),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("distance","",Class<IFunction>::getFunction(c->getSystemState(),distance),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("add","",Class<IFunction>::getFunction(c->getSystemState(),add),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("subtract","",Class<IFunction>::getFunction(c->getSystemState(),subtract),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(c->getSystemState(),clone),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("equals","",Class<IFunction>::getFunction(c->getSystemState(),equals),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("normalize","",Class<IFunction>::getFunction(c->getSystemState(),normalize),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("offset","",Class<IFunction>::getFunction(c->getSystemState(),offset),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("polar","",Class<IFunction>::getFunction(c->getSystemState(),polar),NORMAL_METHOD,false); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); } void Point::buildTraits(ASObject* o) @@ -764,7 +764,7 @@ Point* th=static_cast<Point*>(obj); char buf[512]; snprintf(buf,512,"(a=%f, b=%f)",th->x,th->y); - return Class<ASString>::getInstanceS(buf); + return abstract_s(obj->getSystemState(),buf); } number_t Point::lenImpl(number_t x, number_t y) @@ -791,13 +791,13 @@ ASFUNCTIONBODY(Point,_getX) { Point* th=static_cast<Point*>(obj); - return abstract_d(th->x); + return abstract_d(obj->getSystemState(),th->x); } ASFUNCTIONBODY(Point,_getY) { Point* th=static_cast<Point*>(obj); - return abstract_d(th->y); + return abstract_d(obj->getSystemState(),th->y); } ASFUNCTIONBODY(Point,_setX) @@ -820,7 +820,7 @@ { Point* th=static_cast<Point*>(obj); assert_and_throw(argslen==0); - return abstract_d(th->len()); + return abstract_d(obj->getSystemState(),th->len()); } ASFUNCTIONBODY(Point,interpolate) @@ -829,7 +829,7 @@ Point* pt1=static_cast<Point*>(args[0]); Point* pt2=static_cast<Point*>(args[1]); number_t f=args[2]->toNumber(); - Point* ret=Class<Point>::getInstanceS(); + Point* ret=Class<Point>::getInstanceS(obj->getSystemState()); ret->x = pt1->x + pt2->x * f; ret->y = pt1->y + pt2->y * f; return ret; @@ -841,7 +841,7 @@ Point* pt1=static_cast<Point*>(args[0]); Point* pt2=static_cast<Point*>(args[1]); number_t ret=lenImpl(pt2->x - pt1->x, pt2->y - pt1->y); - return abstract_d(ret); + return abstract_d(obj->getSystemState(),ret); } ASFUNCTIONBODY(Point,add) @@ -849,7 +849,7 @@ Point* th=static_cast<Point*>(obj); assert_and_throw(argslen==1); Point* v=static_cast<Point*>(args[0]); - Point* ret=Class<Point>::getInstanceS(); + Point* ret=Class<Point>::getInstanceS(obj->getSystemState()); ret->x = th->x + v->x; ret->y = th->y + v->y; return ret; @@ -860,7 +860,7 @@ Point* th=static_cast<Point*>(obj); assert_and_throw(argslen==1); Point* v=static_cast<Point*>(args[0]); - Point* ret=Class<Point>::getInstanceS(); + Point* ret=Class<Point>::getInstanceS(obj->getSystemState()); ret->x = th->x - v->x; ret->y = th->y - v->y; return ret; @@ -870,7 +870,7 @@ { Point* th=static_cast<Point*>(obj); assert_and_throw(argslen==0); - Point* ret=Class<Point>::getInstanceS(); + Point* ret=Class<Point>::getInstanceS(obj->getSystemState()); ret->x = th->x; ret->y = th->y; return ret; @@ -881,7 +881,7 @@ Point* th=static_cast<Point*>(obj); assert_and_throw(argslen==1); Point* toCompare=static_cast<Point*>(args[0]); - return abstract_b((th->x == toCompare->x) & (th->y == toCompare->y)); + return abstract_b(obj->getSystemState(),(th->x == toCompare->x) & (th->y == toCompare->y)); } ASFUNCTIONBODY(Point,normalize) @@ -911,7 +911,7 @@ assert_and_throw(argslen==2); number_t len = args[0]->toNumber(); number_t angle = args[1]->toNumber(); - Point* ret=Class<Point>::getInstanceS(); + Point* ret=Class<Point>::getInstanceS(obj->getSystemState()); ret->x = len * cos(angle); ret->y = len * sin(angle); return ret; @@ -930,12 +930,12 @@ void Transform::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("colorTransform","",Class<IFunction>::getFunction(_getColorTransform),GETTER_METHOD,true); - c->setDeclaredMethodByQName("colorTransform","",Class<IFunction>::getFunction(_setColorTransform),SETTER_METHOD,true); - c->setDeclaredMethodByQName("matrix","",Class<IFunction>::getFunction(_setMatrix),SETTER_METHOD,true); - c->setDeclaredMethodByQName("matrix","",Class<IFunction>::getFunction(_getMatrix),GETTER_METHOD,true); - c->setDeclaredMethodByQName("matrix","",Class<IFunction>::getFunction(_setMatrix),SETTER_METHOD,true); - c->setDeclaredMethodByQName("concatenatedMatrix","",Class<IFunction>::getFunction(_getConcatenatedMatrix),GETTER_METHOD,true); + c->setDeclaredMethodByQName("colorTransform","",Class<IFunction>::getFunction(c->getSystemState(),_getColorTransform),GETTER_METHOD,true); + c->setDeclaredMethodByQName("colorTransform","",Class<IFunction>::getFunction(c->getSystemState(),_setColorTransform),SETTER_METHOD,true); + c->setDeclaredMethodByQName("matrix","",Class<IFunction>::getFunction(c->getSystemState(),_setMatrix),SETTER_METHOD,true); + c->setDeclaredMethodByQName("matrix","",Class<IFunction>::getFunction(c->getSystemState(),_getMatrix),GETTER_METHOD,true); + c->setDeclaredMethodByQName("matrix","",Class<IFunction>::getFunction(c->getSystemState(),_setMatrix),SETTER_METHOD,true); + c->setDeclaredMethodByQName("concatenatedMatrix","",Class<IFunction>::getFunction(c->getSystemState(),_getConcatenatedMatrix),GETTER_METHOD,true); } ASFUNCTIONBODY(Transform,_constructor) @@ -949,7 +949,7 @@ Transform* th=Class<Transform>::cast(obj); assert_and_throw(argslen==0); const MATRIX& ret=th->owner->getMatrix(); - return Class<Matrix>::getInstanceS(ret); + return Class<Matrix>::getInstanceS(obj->getSystemState(),ret); } ASFUNCTIONBODY(Transform,_setMatrix) @@ -968,7 +968,7 @@ { Transform* th=Class<Transform>::cast(obj); const CXFORMWITHALPHA& ct=th->owner->ColorTransform; - return Class<ColorTransform>::getInstanceS(ct); + return Class<ColorTransform>::getInstanceS(obj->getSystemState(),ct); } ASFUNCTIONBODY(Transform,_setColorTransform) @@ -989,7 +989,7 @@ { //Transform* th=Class<Transform>::cast(obj); LOG(LOG_NOT_IMPLEMENTED,"contcatenatedMAtrix not implemented"); - return Class<Matrix>::getInstanceS(); + return Class<Matrix>::getInstanceS(obj->getSystemState()); } void Transform::buildTraits(ASObject* o) @@ -1009,33 +1009,33 @@ CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); //Properties - c->setDeclaredMethodByQName("a","",Class<IFunction>::getFunction(_get_a),GETTER_METHOD,true); - c->setDeclaredMethodByQName("b","",Class<IFunction>::getFunction(_get_b),GETTER_METHOD,true); - c->setDeclaredMethodByQName("c","",Class<IFunction>::getFunction(_get_c),GETTER_METHOD,true); - c->setDeclaredMethodByQName("d","",Class<IFunction>::getFunction(_get_d),GETTER_METHOD,true); - c->setDeclaredMethodByQName("tx","",Class<IFunction>::getFunction(_get_tx),GETTER_METHOD,true); - c->setDeclaredMethodByQName("ty","",Class<IFunction>::getFunction(_get_ty),GETTER_METHOD,true); + c->setDeclaredMethodByQName("a","",Class<IFunction>::getFunction(c->getSystemState(),_get_a),GETTER_METHOD,true); + c->setDeclaredMethodByQName("b","",Class<IFunction>::getFunction(c->getSystemState(),_get_b),GETTER_METHOD,true); + c->setDeclaredMethodByQName("c","",Class<IFunction>::getFunction(c->getSystemState(),_get_c),GETTER_METHOD,true); + c->setDeclaredMethodByQName("d","",Class<IFunction>::getFunction(c->getSystemState(),_get_d),GETTER_METHOD,true); + c->setDeclaredMethodByQName("tx","",Class<IFunction>::getFunction(c->getSystemState(),_get_tx),GETTER_METHOD,true); + c->setDeclaredMethodByQName("ty","",Class<IFunction>::getFunction(c->getSystemState(),_get_ty),GETTER_METHOD,true); - c->setDeclaredMethodByQName("a","",Class<IFunction>::getFunction(_set_a),SETTER_METHOD,true); - c->setDeclaredMethodByQName("b","",Class<IFunction>::getFunction(_set_b),SETTER_METHOD,true); - c->setDeclaredMethodByQName("c","",Class<IFunction>::getFunction(_set_c),SETTER_METHOD,true); - c->setDeclaredMethodByQName("d","",Class<IFunction>::getFunction(_set_d),SETTER_METHOD,true); - c->setDeclaredMethodByQName("tx","",Class<IFunction>::getFunction(_set_tx),SETTER_METHOD,true); - c->setDeclaredMethodByQName("ty","",Class<IFunction>::getFunction(_set_ty),SETTER_METHOD,true); + c->setDeclaredMethodByQName("a","",Class<IFunction>::getFunction(c->getSystemState(),_set_a),SETTER_METHOD,true); + c->setDeclaredMethodByQName("b","",Class<IFunction>::getFunction(c->getSystemState(),_set_b),SETTER_METHOD,true); + c->setDeclaredMethodByQName("c","",Class<IFunction>::getFunction(c->getSystemState(),_set_c),SETTER_METHOD,true); + c->setDeclaredMethodByQName("d","",Class<IFunction>::getFunction(c->getSystemState(),_set_d),SETTER_METHOD,true); + c->setDeclaredMethodByQName("tx","",Class<IFunction>::getFunction(c->getSystemState(),_set_tx),SETTER_METHOD,true); + c->setDeclaredMethodByQName("ty","",Class<IFunction>::getFunction(c->getSystemState(),_set_ty),SETTER_METHOD,true); //Methods - c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(clone),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("concat","",Class<IFunction>::getFunction(concat),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("createBox","",Class<IFunction>::getFunction(createBox),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("createGradientBox","",Class<IFunction>::getFunction(createGradientBox),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("deltaTransformPoint","",Class<IFunction>::getFunction(deltaTransformPoint),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("identity","",Class<IFunction>::getFunction(identity),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("invert","",Class<IFunction>::getFunction(invert),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("rotate","",Class<IFunction>::getFunction(rotate),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("scale","",Class<IFunction>::getFunction(scale),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("transformPoint","",Class<IFunction>::getFunction(transformPoint),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("translate","",Class<IFunction>::getFunction(translate),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(c->getSystemState(),clone),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("concat","",Class<IFunction>::getFunction(c->getSystemState(),concat),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("createBox","",Class<IFunction>::getFunction(c->getSystemState(),createBox),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("createGradientBox","",Class<IFunction>::getFunction(c->getSystemState(),createGradientBox),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("deltaTransformPoint","",Class<IFunction>::getFunction(c->getSystemState(),deltaTransformPoint),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("identity","",Class<IFunction>::getFunction(c->getSystemState(),identity),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("invert","",Class<IFunction>::getFunction(c->getSystemState(),invert),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("rotate","",Class<IFunction>::getFunction(c->getSystemState(),rotate),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("scale","",Class<IFunction>::getFunction(c->getSystemState(),scale),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("transformPoint","",Class<IFunction>::getFunction(c->getSystemState(),transformPoint),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("translate","",Class<IFunction>::getFunction(c->getSystemState(),translate),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); } ASFUNCTIONBODY(Matrix,_constructor) @@ -1079,7 +1079,7 @@ char buf[512]; snprintf(buf,512,"(a=%f, b=%f, c=%f, d=%f, tx=%f, ty=%f)", th->matrix.xx, th->matrix.yx, th->matrix.xy, th->matrix.yy, th->matrix.x0, th->matrix.y0); - return Class<ASString>::getInstanceS(buf); + return abstract_s(obj->getSystemState(),buf); } MATRIX Matrix::getMATRIX() const @@ -1090,7 +1090,7 @@ ASFUNCTIONBODY(Matrix,_get_a) { Matrix* th=static_cast<Matrix*>(obj); - return abstract_d(th->matrix.xx); + return abstract_d(obj->getSystemState(),th->matrix.xx); } ASFUNCTIONBODY(Matrix,_set_a) @@ -1104,7 +1104,7 @@ ASFUNCTIONBODY(Matrix,_get_b) { Matrix* th=static_cast<Matrix*>(obj); - return abstract_d(th->matrix.yx); + return abstract_d(obj->getSystemState(),th->matrix.yx); } ASFUNCTIONBODY(Matrix,_set_b) @@ -1118,7 +1118,7 @@ ASFUNCTIONBODY(Matrix,_get_c) { Matrix* th=static_cast<Matrix*>(obj); - return abstract_d(th->matrix.xy); + return abstract_d(obj->getSystemState(),th->matrix.xy); } ASFUNCTIONBODY(Matrix,_set_c) @@ -1132,7 +1132,7 @@ ASFUNCTIONBODY(Matrix,_get_d) { Matrix* th=static_cast<Matrix*>(obj); - return abstract_d(th->matrix.yy); + return abstract_d(obj->getSystemState(),th->matrix.yy); } ASFUNCTIONBODY(Matrix,_set_d) @@ -1146,7 +1146,7 @@ ASFUNCTIONBODY(Matrix,_get_tx) { Matrix* th=static_cast<Matrix*>(obj); - return abstract_d(th->matrix.x0); + return abstract_d(obj->getSystemState(),th->matrix.x0); } ASFUNCTIONBODY(Matrix,_set_tx) @@ -1160,7 +1160,7 @@ ASFUNCTIONBODY(Matrix,_get_ty) { Matrix* th=static_cast<Matrix*>(obj); - return abstract_d(th->matrix.y0); + return abstract_d(obj->getSystemState(),th->matrix.y0); } ASFUNCTIONBODY(Matrix,_set_ty) @@ -1176,7 +1176,7 @@ assert_and_throw(argslen==0); Matrix* th=static_cast<Matrix*>(obj); - Matrix* ret=Class<Matrix>::getInstanceS(th->matrix); + Matrix* ret=Class<Matrix>::getInstanceS(obj->getSystemState(),th->matrix); return ret; } @@ -1308,7 +1308,7 @@ number_t ttx = pt->getX(); number_t tty = pt->getY(); cairo_matrix_transform_point(&th->matrix,&ttx,&tty); - return Class<Point>::getInstanceS(ttx, tty); + return Class<Point>::getInstanceS(obj->getSystemState(),ttx, tty); } ASFUNCTIONBODY(Matrix,deltaTransformPoint) @@ -1320,7 +1320,7 @@ number_t ttx = pt->getX(); number_t tty = pt->getY(); cairo_matrix_transform_distance(&th->matrix,&ttx,&tty); - return Class<Point>::getInstanceS(ttx, tty); + return Class<Point>::getInstanceS(obj->getSystemState(),ttx, tty); } void Vector3D::sinit(Class_base* c) @@ -1341,35 +1341,35 @@ c->setVariableByQName("Z_AXIS","", tz, DECLARED_TRAIT); // properties - c->setDeclaredMethodByQName("w","",Class<IFunction>::getFunction(_get_w),GETTER_METHOD,true); - c->setDeclaredMethodByQName("x","",Class<IFunction>::getFunction(_get_x),GETTER_METHOD,true); - c->setDeclaredMethodByQName("y","",Class<IFunction>::getFunction(_get_y),GETTER_METHOD,true); - c->setDeclaredMethodByQName("z","",Class<IFunction>::getFunction(_get_z),GETTER_METHOD,true); - c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(_get_length),GETTER_METHOD,true); - c->setDeclaredMethodByQName("lengthSquared","",Class<IFunction>::getFunction(_get_lengthSquared),GETTER_METHOD,true); + c->setDeclaredMethodByQName("w","",Class<IFunction>::getFunction(c->getSystemState(),_get_w),GETTER_METHOD,true); + c->setDeclaredMethodByQName("x","",Class<IFunction>::getFunction(c->getSystemState(),_get_x),GETTER_METHOD,true); + c->setDeclaredMethodByQName("y","",Class<IFunction>::getFunction(c->getSystemState(),_get_y),GETTER_METHOD,true); + c->setDeclaredMethodByQName("z","",Class<IFunction>::getFunction(c->getSystemState(),_get_z),GETTER_METHOD,true); + c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(c->getSystemState(),_get_length),GETTER_METHOD,true); + c->setDeclaredMethodByQName("lengthSquared","",Class<IFunction>::getFunction(c->getSystemState(),_get_lengthSquared),GETTER_METHOD,true); - c->setDeclaredMethodByQName("w","",Class<IFunction>::getFunction(_set_w),SETTER_METHOD,true); - c->setDeclaredMethodByQName("x","",Class<IFunction>::getFunction(_set_x),SETTER_METHOD,true); - c->setDeclaredMethodByQName("y","",Class<IFunction>::getFunction(_set_y),SETTER_METHOD,true); - c->setDeclaredMethodByQName("z","",Class<IFunction>::getFunction(_set_z),SETTER_METHOD,true); + c->setDeclaredMethodByQName("w","",Class<IFunction>::getFunction(c->getSystemState(),_set_w),SETTER_METHOD,true); + c->setDeclaredMethodByQName("x","",Class<IFunction>::getFunction(c->getSystemState(),_set_x),SETTER_METHOD,true); + c->setDeclaredMethodByQName("y","",Class<IFunction>::getFunction(c->getSystemState(),_set_y),SETTER_METHOD,true); + c->setDeclaredMethodByQName("z","",Class<IFunction>::getFunction(c->getSystemState(),_set_z),SETTER_METHOD,true); // methods - c->setDeclaredMethodByQName("add","",Class<IFunction>::getFunction(add),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("angleBetween","",Class<IFunction>::getFunction(angleBetween),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(clone),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("crossProduct","",Class<IFunction>::getFunction(crossProduct),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("decrementBy","",Class<IFunction>::getFunction(decrementBy),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("distance","",Class<IFunction>::getFunction(distance),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("dotProduct","",Class<IFunction>::getFunction(dotProduct),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("equals","",Class<IFunction>::getFunction(equals),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("incrementBy","",Class<IFunction>::getFunction(incrementBy),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("nearEquals","",Class<IFunction>::getFunction(nearEquals),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("negate","",Class<IFunction>::getFunction(negate),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("normalize","",Class<IFunction>::getFunction(normalize),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("project","",Class<IFunction>::getFunction(project),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("scaleBy","",Class<IFunction>::getFunction(scaleBy),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("subtract","",Class<IFunction>::getFunction(subtract),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("add","",Class<IFunction>::getFunction(c->getSystemState(),add),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("angleBetween","",Class<IFunction>::getFunction(c->getSystemState(),angleBetween),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(c->getSystemState(),clone),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("crossProduct","",Class<IFunction>::getFunction(c->getSystemState(),crossProduct),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("decrementBy","",Class<IFunction>::getFunction(c->getSystemState(),decrementBy),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("distance","",Class<IFunction>::getFunction(c->getSystemState(),distance),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("dotProduct","",Class<IFunction>::getFunction(c->getSystemState(),dotProduct),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("equals","",Class<IFunction>::getFunction(c->getSystemState(),equals),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("incrementBy","",Class<IFunction>::getFunction(c->getSystemState(),incrementBy),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("nearEquals","",Class<IFunction>::getFunction(c->getSystemState(),nearEquals),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("negate","",Class<IFunction>::getFunction(c->getSystemState(),negate),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("normalize","",Class<IFunction>::getFunction(c->getSystemState(),normalize),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("project","",Class<IFunction>::getFunction(c->getSystemState(),project),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("scaleBy","",Class<IFunction>::getFunction(c->getSystemState(),scaleBy),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("subtract","",Class<IFunction>::getFunction(c->getSystemState(),subtract),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); } ASFUNCTIONBODY(Vector3D,_constructor) @@ -1405,7 +1405,7 @@ Vector3D* th=static_cast<Vector3D*>(obj); char buf[512]; snprintf(buf,512,"(x=%f, y=%f, z=%f)", th->x, th->y, th->z); - return Class<ASString>::getInstanceS(buf); + return abstract_s(obj->getSystemState(),buf); } ASFUNCTIONBODY(Vector3D,_get_w) @@ -1413,7 +1413,7 @@ assert_and_throw(argslen==0); Vector3D* th=static_cast<Vector3D*>(obj); - return abstract_d(th->w); + return abstract_d(obj->getSystemState(),th->w); } ASFUNCTIONBODY(Vector3D,_set_w) @@ -1429,7 +1429,7 @@ assert_and_throw(argslen==0); Vector3D* th=static_cast<Vector3D*>(obj); - return abstract_d(th->x); + return abstract_d(obj->getSystemState(),th->x); } ASFUNCTIONBODY(Vector3D,_set_x) @@ -1445,7 +1445,7 @@ assert_and_throw(argslen==0); Vector3D* th=static_cast<Vector3D*>(obj); - return abstract_d(th->y); + return abstract_d(obj->getSystemState(),th->y); } ASFUNCTIONBODY(Vector3D,_set_y) @@ -1461,7 +1461,7 @@ assert_and_throw(argslen==0); Vector3D* th=static_cast<Vector3D*>(obj); - return abstract_d(th->z); + return abstract_d(obj->getSystemState(),th->z); } ASFUNCTIONBODY(Vector3D,_set_z) @@ -1477,7 +1477,7 @@ assert_and_throw(argslen==0); Vector3D* th=static_cast<Vector3D*>(obj); - return abstract_d(sqrt(th->x * th->x + th->y * th->y + th->z * th->z)); + return abstract_d(obj->getSystemState(),sqrt(th->x * th->x + th->y * th->y + th->z * th->z)); } ASFUNCTIONBODY(Vector3D,_get_lengthSquared) @@ -1485,7 +1485,7 @@ assert_and_throw(argslen==0); Vector3D* th=static_cast<Vector3D*>(obj); - return abstract_d(th->x * th->x + th->y * th->y + th->z * th->z); + return abstract_d(obj->getSystemState(),th->x * th->x + th->y * th->y + th->z * th->z); } ASFUNCTIONBODY(Vector3D,clone) @@ -1493,7 +1493,7 @@ assert_and_throw(argslen==0); Vector3D* th=static_cast<Vector3D*>(obj); - Vector3D* ret=Class<Vector3D>::getInstanceS(); + Vector3D* ret=Class<Vector3D>::getInstanceS(obj->getSystemState()); ret->w = th->w; ret->x = th->x; @@ -1509,7 +1509,7 @@ Vector3D* th=static_cast<Vector3D*>(obj); Vector3D* vc=static_cast<Vector3D*>(args[0]); - Vector3D* ret=Class<Vector3D>::getInstanceS(); + Vector3D* ret=Class<Vector3D>::getInstanceS(obj->getSystemState()); ret->x = th->x + vc->x; ret->y = th->y + vc->y; @@ -1530,7 +1530,7 @@ angle /= sqrt(vc2->x * vc2->x + vc2->y * vc2->y + vc2->z * vc2->z); angle = acos(angle); - return abstract_d(angle); + return abstract_d(obj->getSystemState(),angle); } ASFUNCTIONBODY(Vector3D,crossProduct) @@ -1539,7 +1539,7 @@ Vector3D* th=static_cast<Vector3D*>(obj); Vector3D* vc=static_cast<Vector3D*>(args[0]); - Vector3D* ret=Class<Vector3D>::getInstanceS(); + Vector3D* ret=Class<Vector3D>::getInstanceS(obj->getSystemState()); ret->x = th->y * vc->z - th->z * vc->y; ret->y = th->z * vc->x - th->x * vc->z; @@ -1575,7 +1575,7 @@ dz = vc1->z - vc2->z; dist = sqrt(dx * dx + dy * dy + dz * dz); - return abstract_d(dist); + return abstract_d(obj->getSystemState(),dist); } ASFUNCTIONBODY(Vector3D,dotProduct) @@ -1585,7 +1585,7 @@ Vector3D* th=static_cast<Vector3D*>(obj); Vector3D* vc=static_cast<Vector3D*>(args[0]); - return abstract_d(th->x * vc->x + th->y * vc->y + th->z * vc->z); + return abstract_d(obj->getSystemState(),th->x * vc->x + th->y * vc->y + th->z * vc->z); } ASFUNCTIONBODY(Vector3D,equals) @@ -1602,7 +1602,7 @@ allfour = af->toInt(); } - return abstract_b(th->x == vc->x && th->y == vc->y && th->z == vc->z && allfour ? th->w == vc->w : true); + return abstract_b(obj->getSystemState(),th->x == vc->x && th->y == vc->y && th->z == vc->z && allfour ? th->w == vc->w : true); } ASFUNCTIONBODY(Vector3D,incrementBy) @@ -1640,7 +1640,7 @@ dz = (th->z - vc->z) < tolerance; dw = allfour ? (th->w - vc->w) < tolerance : true; - return abstract_b(dx && dy && dz && dw); + return abstract_b(obj->getSystemState(),dx && dy && dz && dw); } ASFUNCTIONBODY(Vector3D,negate) @@ -1704,7 +1704,7 @@ Vector3D* th=static_cast<Vector3D*>(obj); Vector3D* vc=static_cast<Vector3D*>(args[0]); - Vector3D* ret=Class<Vector3D>::getInstanceS(); + Vector3D* ret=Class<Vector3D>::getInstanceS(obj->getSystemState()); ret->x = th->x - vc->x; ret->y = th->y - vc->y;
View file
lightspark.tar.xz/src/scripting/flash/media/flashmedia.cpp
Changed
@@ -68,14 +68,14 @@ void Video::sinit(Class_base* c) { CLASS_SETUP(c, DisplayObject, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("videoWidth","",Class<IFunction>::getFunction(_getVideoWidth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("videoHeight","",Class<IFunction>::getFunction(_getVideoHeight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(Video::_getWidth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(Video::_setWidth),SETTER_METHOD,true); - c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(Video::_getHeight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(Video::_setHeight),SETTER_METHOD,true); - c->setDeclaredMethodByQName("attachNetStream","",Class<IFunction>::getFunction(attachNetStream),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("clear","",Class<IFunction>::getFunction(clear),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("videoWidth","",Class<IFunction>::getFunction(c->getSystemState(),_getVideoWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("videoHeight","",Class<IFunction>::getFunction(c->getSystemState(),_getVideoHeight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(c->getSystemState(),Video::_getWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(c->getSystemState(),Video::_setWidth),SETTER_METHOD,true); + c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(c->getSystemState(),Video::_getHeight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(c->getSystemState(),Video::_setHeight),SETTER_METHOD,true); + c->setDeclaredMethodByQName("attachNetStream","",Class<IFunction>::getFunction(c->getSystemState(),attachNetStream),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("clear","",Class<IFunction>::getFunction(c->getSystemState(),clear),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c, deblocking); REGISTER_GETTER_SETTER(c, smoothing); } @@ -161,19 +161,19 @@ ASFUNCTIONBODY(Video,_getVideoWidth) { Video* th=Class<Video>::cast(obj); - return abstract_i(th->videoWidth); + return abstract_i(obj->getSystemState(),th->videoWidth); } ASFUNCTIONBODY(Video,_getVideoHeight) { Video* th=Class<Video>::cast(obj); - return abstract_i(th->videoHeight); + return abstract_i(obj->getSystemState(),th->videoHeight); } ASFUNCTIONBODY(Video,_getWidth) { Video* th=Class<Video>::cast(obj); - return abstract_i(th->width); + return abstract_i(obj->getSystemState(),th->width); } ASFUNCTIONBODY(Video,_setWidth) @@ -188,7 +188,7 @@ ASFUNCTIONBODY(Video,_getHeight) { Video* th=Class<Video>::cast(obj); - return abstract_i(th->height); + return abstract_i(obj->getSystemState(),th->height); } ASFUNCTIONBODY(Video,_setHeight) @@ -212,7 +212,7 @@ } //Validate the parameter - if(!args[0]->getClass()->isSubClass(Class<NetStream>::getClass())) + if(!args[0]->getClass()->isSubClass(Class<NetStream>::getClass(obj->getSystemState()))) throw RunTimeException("Type mismatch in Video::attachNetStream"); //Acquire the netStream @@ -260,9 +260,9 @@ void Sound::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("load","",Class<IFunction>::getFunction(load),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("play","",Class<IFunction>::getFunction(play),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(close),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("load","",Class<IFunction>::getFunction(c->getSystemState(),load),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("play","",Class<IFunction>::getFunction(c->getSystemState(),play),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(c->getSystemState(),close),NORMAL_METHOD,true); REGISTER_GETTER(c,bytesLoaded); REGISTER_GETTER(c,bytesTotal); REGISTER_GETTER(c,length); @@ -299,7 +299,7 @@ { //Notify an error during loading th->incRef(); - getVm()->addEvent(_MR(th),_MR(Class<IOErrorEvent>::getInstanceS())); + getVm(obj->getSystemState())->addEvent(_MR(th),_MR(Class<IOErrorEvent>::getInstanceS(obj->getSystemState()))); return NULL; } @@ -322,7 +322,7 @@ if(th->downloader->hasFailed()) { th->incRef(); - getVm()->addEvent(_MR(th),_MR(Class<IOErrorEvent>::getInstanceS())); + getVm(obj->getSystemState())->addEvent(_MR(th),_MR(Class<IOErrorEvent>::getInstanceS(obj->getSystemState()))); } return NULL; } @@ -338,9 +338,9 @@ th->incRef(); if (th->container) - return Class<SoundChannel>::getInstanceS(th->soundData); + return Class<SoundChannel>::getInstanceS(obj->getSystemState(),th->soundData); else - return Class<SoundChannel>::getInstanceS(th->soundData, th->format); + return Class<SoundChannel>::getInstanceS(obj->getSystemState(),th->soundData, th->format); } ASFUNCTIONBODY(Sound,close) @@ -363,11 +363,11 @@ { bytesLoaded=b; this->incRef(); - getVm()->addEvent(_MR(this),_MR(Class<ProgressEvent>::getInstanceS(bytesLoaded,bytesTotal))); + getVm(getSystemState())->addEvent(_MR(this),_MR(Class<ProgressEvent>::getInstanceS(getSystemState(),bytesLoaded,bytesTotal))); if(bytesLoaded==bytesTotal) { this->incRef(); - getVm()->addEvent(_MR(this),_MR(Class<Event>::getInstanceS("complete"))); + getVm(getSystemState())->addEvent(_MR(this),_MR(Class<Event>::getInstanceS(getSystemState(),"complete"))); } } } @@ -401,7 +401,7 @@ SoundChannel::SoundChannel(Class_base* c, _NR<StreamCache> _stream, AudioFormat _format) : EventDispatcher(c),stream(_stream),stopped(false),audioDecoder(NULL),audioStream(NULL), - format(_format),position(0),soundTransform(_MR(Class<SoundTransform>::getInstanceS())) + format(_format),position(0),soundTransform(_MR(Class<SoundTransform>::getInstanceS(c->getSystemState()))) { if (!stream.isNull()) { @@ -419,7 +419,7 @@ void SoundChannel::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_SEALED | CLASS_FINAL); - c->setDeclaredMethodByQName("stop","",Class<IFunction>::getFunction(stop),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("stop","",Class<IFunction>::getFunction(c->getSystemState(),stop),NORMAL_METHOD,true); REGISTER_GETTER(c,position); REGISTER_GETTER_SETTER(c,soundTransform); @@ -544,7 +544,7 @@ if (!ACQUIRE_READ(stopped)) { incRef(); - getVm()->addEvent(_MR(this),_MR(Class<Event>::getInstanceS("soundComplete"))); + getVm(getSystemState())->addEvent(_MR(this),_MR(Class<Event>::getInstanceS(getSystemState(),"soundComplete"))); } } @@ -585,7 +585,7 @@ if (!ACQUIRE_READ(stopped)) { incRef(); - getVm()->addEvent(_MR(this),_MR(Class<Event>::getInstanceS("soundComplete"))); + getVm(getSystemState())->addEvent(_MR(this),_MR(Class<Event>::getInstanceS(getSystemState(),"soundComplete"))); } #endif //ENABLE_LIBAVCODEC } @@ -610,9 +610,9 @@ void StageVideo::sinit(Class_base *c) { CLASS_SETUP(c, EventDispatcher, _constructorNotInstantiatable, CLASS_SEALED); - c->setDeclaredMethodByQName("videoWidth","",Class<IFunction>::getFunction(_getVideoWidth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("videoHeight","",Class<IFunction>::getFunction(_getVideoHeight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("attachNetStream","",Class<IFunction>::getFunction(attachNetStream),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("videoWidth","",Class<IFunction>::getFunction(c->getSystemState(),_getVideoWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("videoHeight","",Class<IFunction>::getFunction(c->getSystemState(),_getVideoHeight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("attachNetStream","",Class<IFunction>::getFunction(c->getSystemState(),attachNetStream),NORMAL_METHOD,true); } @@ -624,13 +624,13 @@ ASFUNCTIONBODY(StageVideo,_getVideoWidth) { StageVideo* th=Class<StageVideo>::cast(obj); - return abstract_i(th->videoWidth); + return abstract_i(obj->getSystemState(),th->videoWidth); } ASFUNCTIONBODY(StageVideo,_getVideoHeight) { StageVideo* th=Class<StageVideo>::cast(obj); - return abstract_i(th->videoHeight); + return abstract_i(obj->getSystemState(),th->videoHeight); } ASFUNCTIONBODY(StageVideo,attachNetStream) @@ -645,7 +645,7 @@ } //Validate the parameter - if(!args[0]->getClass()->isSubClass(Class<NetStream>::getClass())) + if(!args[0]->getClass()->isSubClass(Class<NetStream>::getClass(obj->getSystemState()))) throw RunTimeException("Type mismatch in StageVideo::attachNetStream"); //Acquire the netStream @@ -659,14 +659,14 @@ void StageVideoAvailability::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("AVAILABLE","",Class<ASString>::getInstanceS("available"),DECLARED_TRAIT); - c->setVariableByQName("UNAVAILABLE","",Class<ASString>::getInstanceS("unavailable"),DECLARED_TRAIT); + c->setVariableByQName("AVAILABLE","",abstract_s(c->getSystemState(),"available"),DECLARED_TRAIT); + c->setVariableByQName("UNAVAILABLE","",abstract_s(c->getSystemState(),"unavailable"),DECLARED_TRAIT); } void VideoStatus::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("ACCELERATED","",Class<ASString>::getInstanceS("accelerated"),DECLARED_TRAIT); - c->setVariableByQName("SOFTWARE","",Class<ASString>::getInstanceS("software"),DECLARED_TRAIT); - c->setVariableByQName("UNAVAILABLE","",Class<ASString>::getInstanceS("unavailable"),DECLARED_TRAIT); + c->setVariableByQName("ACCELERATED","",abstract_s(c->getSystemState(),"accelerated"),DECLARED_TRAIT); + c->setVariableByQName("SOFTWARE","",abstract_s(c->getSystemState(),"software"),DECLARED_TRAIT); + c->setVariableByQName("UNAVAILABLE","",abstract_s(c->getSystemState(),"unavailable"),DECLARED_TRAIT); }
View file
lightspark.tar.xz/src/scripting/flash/net/NetStreamPlayTransitions.cpp
Changed
@@ -29,12 +29,12 @@ void NetStreamPlayTransitions::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, NULL, CLASS_FINAL); - c->setVariableByQName("APPEND","",Class<ASString>::getInstanceS("append"),CONSTANT_TRAIT); - c->setVariableByQName("APPEND_AND_WAIT","",Class<ASString>::getInstanceS("appendAndWait"),CONSTANT_TRAIT); - c->setVariableByQName("RESET","",Class<ASString>::getInstanceS("reset"),CONSTANT_TRAIT); - c->setVariableByQName("RESUME","",Class<ASString>::getInstanceS("resume"),CONSTANT_TRAIT); - c->setVariableByQName("STOP","",Class<ASString>::getInstanceS("stop"),CONSTANT_TRAIT); - c->setVariableByQName("SWAP","",Class<ASString>::getInstanceS("swap"),CONSTANT_TRAIT); - c->setVariableByQName("SWITCH","",Class<ASString>::getInstanceS("switch"),CONSTANT_TRAIT); + c->setVariableByQName("APPEND","",abstract_s(c->getSystemState(),"append"),CONSTANT_TRAIT); + c->setVariableByQName("APPEND_AND_WAIT","",abstract_s(c->getSystemState(),"appendAndWait"),CONSTANT_TRAIT); + c->setVariableByQName("RESET","",abstract_s(c->getSystemState(),"reset"),CONSTANT_TRAIT); + c->setVariableByQName("RESUME","",abstract_s(c->getSystemState(),"resume"),CONSTANT_TRAIT); + c->setVariableByQName("STOP","",abstract_s(c->getSystemState(),"stop"),CONSTANT_TRAIT); + c->setVariableByQName("SWAP","",abstract_s(c->getSystemState(),"swap"),CONSTANT_TRAIT); + c->setVariableByQName("SWITCH","",abstract_s(c->getSystemState(),"switch"),CONSTANT_TRAIT); }
View file
lightspark.tar.xz/src/scripting/flash/net/URLStream.cpp
Changed
@@ -52,7 +52,7 @@ { timestamp_last_progress = cur; loader->incRef(); - getVm()->addEvent(loader,_MR(Class<ProgressEvent>::getInstanceS(b,bytes_total))); + getVm(loader->getSystemState())->addEvent(loader,_MR(Class<ProgressEvent>::getInstanceS(loader->getSystemState(),b,bytes_total))); } } } @@ -73,10 +73,10 @@ if(!downloader->hasFailed()) { loader->incRef(); - getVm()->addEvent(loader,_MR(Class<Event>::getInstanceS("open"))); + getVm(loader->getSystemState())->addEvent(loader,_MR(Class<Event>::getInstanceS(loader->getSystemState(),"open"))); streambuffer = cache->createReader(); loader->incRef(); - getVm()->addEvent(loader,_MR(Class<ProgressEvent>::getInstanceS(0,bytes_total))); + getVm(loader->getSystemState())->addEvent(loader,_MR(Class<ProgressEvent>::getInstanceS(loader->getSystemState(),0,bytes_total))); cache->waitForTermination(); if(!downloader->hasFailed() && !threadAborting) { @@ -99,16 +99,16 @@ if(success && !threadAborting) { loader->incRef(); - getVm()->addEvent(loader,_MR(Class<ProgressEvent>::getInstanceS(downloader->getLength(),downloader->getLength()))); + getVm(loader->getSystemState())->addEvent(loader,_MR(Class<ProgressEvent>::getInstanceS(loader->getSystemState(),downloader->getLength(),downloader->getLength()))); //Send a complete event for this object loader->incRef(); - getVm()->addEvent(loader,_MR(Class<Event>::getInstanceS("complete"))); + getVm(loader->getSystemState())->addEvent(loader,_MR(Class<Event>::getInstanceS(loader->getSystemState(),"complete"))); } else if(!success && !threadAborting) { //Notify an error during loading loader->incRef(); - getVm()->addEvent(loader,_MR(Class<IOErrorEvent>::getInstanceS())); + getVm(loader->getSystemState())->addEvent(loader,_MR(Class<IOErrorEvent>::getInstanceS(loader->getSystemState()))); } { @@ -122,30 +122,30 @@ void URLStream::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("load","",Class<IFunction>::getFunction(load),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(close),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("bytesAvailable","",Class<IFunction>::getFunction(bytesAvailable),GETTER_METHOD,true); - c->setDeclaredMethodByQName("endian","",Class<IFunction>::getFunction(_getEndian),GETTER_METHOD,true); - c->setDeclaredMethodByQName("endian","",Class<IFunction>::getFunction(_setEndian),SETTER_METHOD,true); - c->setDeclaredMethodByQName("objectEncoding","",Class<IFunction>::getFunction(_getObjectEncoding),GETTER_METHOD,true); - c->setDeclaredMethodByQName("objectEncoding","",Class<IFunction>::getFunction(_setObjectEncoding),SETTER_METHOD,true); - c->setDeclaredMethodByQName("readBoolean","",Class<IFunction>::getFunction(readBoolean),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readByte","",Class<IFunction>::getFunction(readByte),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readBytes","",Class<IFunction>::getFunction(readBytes),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readDouble","",Class<IFunction>::getFunction(readDouble),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readFloat","",Class<IFunction>::getFunction(readFloat),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readInt","",Class<IFunction>::getFunction(readInt),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readMultiByte","",Class<IFunction>::getFunction(readMultiByte),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readObject","",Class<IFunction>::getFunction(readObject),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readShort","",Class<IFunction>::getFunction(readShort),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readUnsignedByte","",Class<IFunction>::getFunction(readUnsignedByte),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readUnsignedInt","",Class<IFunction>::getFunction(readUnsignedInt),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readUnsignedShort","",Class<IFunction>::getFunction(readUnsignedShort),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readUTF","",Class<IFunction>::getFunction(readUTF),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readUTFBytes","",Class<IFunction>::getFunction(readUTFBytes),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("load","",Class<IFunction>::getFunction(c->getSystemState(),load),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(c->getSystemState(),close),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("bytesAvailable","",Class<IFunction>::getFunction(c->getSystemState(),bytesAvailable),GETTER_METHOD,true); + c->setDeclaredMethodByQName("endian","",Class<IFunction>::getFunction(c->getSystemState(),_getEndian),GETTER_METHOD,true); + c->setDeclaredMethodByQName("endian","",Class<IFunction>::getFunction(c->getSystemState(),_setEndian),SETTER_METHOD,true); + c->setDeclaredMethodByQName("objectEncoding","",Class<IFunction>::getFunction(c->getSystemState(),_getObjectEncoding),GETTER_METHOD,true); + c->setDeclaredMethodByQName("objectEncoding","",Class<IFunction>::getFunction(c->getSystemState(),_setObjectEncoding),SETTER_METHOD,true); + c->setDeclaredMethodByQName("readBoolean","",Class<IFunction>::getFunction(c->getSystemState(),readBoolean),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readByte","",Class<IFunction>::getFunction(c->getSystemState(),readByte),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readBytes","",Class<IFunction>::getFunction(c->getSystemState(),readBytes),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readDouble","",Class<IFunction>::getFunction(c->getSystemState(),readDouble),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readFloat","",Class<IFunction>::getFunction(c->getSystemState(),readFloat),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readInt","",Class<IFunction>::getFunction(c->getSystemState(),readInt),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readMultiByte","",Class<IFunction>::getFunction(c->getSystemState(),readMultiByte),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readObject","",Class<IFunction>::getFunction(c->getSystemState(),readObject),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readShort","",Class<IFunction>::getFunction(c->getSystemState(),readShort),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readUnsignedByte","",Class<IFunction>::getFunction(c->getSystemState(),readUnsignedByte),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readUnsignedInt","",Class<IFunction>::getFunction(c->getSystemState(),readUnsignedInt),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readUnsignedShort","",Class<IFunction>::getFunction(c->getSystemState(),readUnsignedShort),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readUTF","",Class<IFunction>::getFunction(c->getSystemState(),readUTF),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readUTFBytes","",Class<IFunction>::getFunction(c->getSystemState(),readUTFBytes),NORMAL_METHOD,true); REGISTER_GETTER(c,connected); - c->addImplementedInterface(InterfaceClass<IDataInput>::getClass()); + c->addImplementedInterface(InterfaceClass<IDataInput>::getClass(c->getSystemState())); IDataInput::linkTraits(c); } @@ -191,7 +191,7 @@ { //Notify an error during loading th->incRef(); - getSys()->currentVm->addEvent(_MR(th),_MR(Class<IOErrorEvent>::getInstanceS())); + getSys()->currentVm->addEvent(_MR(th),_MR(Class<IOErrorEvent>::getInstanceS(obj->getSystemState()))); return NULL; }
View file
lightspark.tar.xz/src/scripting/flash/net/URLStream.h
Changed
@@ -79,7 +79,7 @@ ASFUNCTION(readUTFBytes); ASPROPERTY_GETTER(bool,connected); public: - URLStream(Class_base* c):EventDispatcher(c),data(_MNR(Class<ByteArray>::getInstanceS())),job(NULL),connected(false) {} + URLStream(Class_base* c):EventDispatcher(c),data(_MNR(Class<ByteArray>::getInstanceS(c->getSystemState()))),job(NULL),connected(false) {} static void sinit(Class_base*); static void buildTraits(ASObject* o); void threadFinished(IThreadJob *job);
View file
lightspark.tar.xz/src/scripting/flash/net/XMLSocket.cpp
Changed
@@ -172,10 +172,10 @@ void XMLSocket::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(_close),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("connect","",Class<IFunction>::getFunction(_connect),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("send","",Class<IFunction>::getFunction(_send),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("connected","",Class<IFunction>::getFunction(_connected),GETTER_METHOD,true); + c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(c->getSystemState(),_close),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("connect","",Class<IFunction>::getFunction(c->getSystemState(),_connect),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("send","",Class<IFunction>::getFunction(c->getSystemState(),_send),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("connected","",Class<IFunction>::getFunction(c->getSystemState(),_connected),GETTER_METHOD,true); REGISTER_GETTER_SETTER(c,timeout); } @@ -238,17 +238,17 @@ void XMLSocket::connect(tiny_string host, int port) { if (port <= 0 || port > 65535) - throw Class<SecurityError>::getInstanceS("Invalid port"); + throw Class<SecurityError>::getInstanceS(getSystemState(),"Invalid port"); if (host.empty()) host = getSys()->mainClip->getOrigin().getHostname(); if (isConnected()) - throw Class<IOError>::getInstanceS("Already connected"); + throw Class<IOError>::getInstanceS(getSystemState(),"Already connected"); // Host shouldn't contain scheme or port if (host.strchr(':') != NULL) - throw Class<SecurityError>::getInstanceS("Invalid hostname"); + throw Class<SecurityError>::getInstanceS(getSystemState(),"Invalid hostname"); // Check sandbox and policy file size_t buflen = host.numBytes() + 22; @@ -256,7 +256,7 @@ snprintf(urlbuf, buflen, "xmlsocket://%s:%d", host.raw_buf(), port); URLInfo url(urlbuf); - getSys()->securityManager->checkURLStaticAndThrow(url, + getSystemState()->securityManager->checkURLStaticAndThrow(url, ~(SecurityManager::LOCAL_WITH_FILE), SecurityManager::LOCAL_WITH_FILE | SecurityManager::LOCAL_TRUSTED, true); @@ -266,7 +266,7 @@ if(evaluationResult != SecurityManager::ALLOWED) { incRef(); - getVm()->addEvent(_MR(this), _MR(Class<SecurityErrorEvent>::getInstanceS("No policy file allows socket connection"))); + getVm(getSystemState())->addEvent(_MR(this), _MR(Class<SecurityErrorEvent>::getInstanceS(getSystemState(),"No policy file allows socket connection"))); return; } @@ -306,7 +306,7 @@ } else { - throw Class<IOError>::getInstanceS("Socket is not connected"); + throw Class<IOError>::getInstanceS(obj->getSystemState(),"Socket is not connected"); } return NULL; @@ -321,7 +321,7 @@ ASFUNCTIONBODY(XMLSocket, _connected) { XMLSocket* th=obj->as<XMLSocket>(); - return abstract_b(th->isConnected()); + return abstract_b(obj->getSystemState(),th->isConnected()); } void XMLSocket::threadFinished() @@ -379,12 +379,12 @@ if (!sock.connect(hostname, port)) { owner->incRef(); - getVm()->addEvent(owner, _MR(Class<IOErrorEvent>::getInstanceS())); + getVm(owner->getSystemState())->addEvent(owner, _MR(Class<IOErrorEvent>::getInstanceS(owner->getSystemState()))); return; } owner->incRef(); - getVm()->addEvent(owner, _MR(Class<Event>::getInstanceS("connect"))); + getVm(owner->getSystemState())->addEvent(owner, _MR(Class<Event>::getInstanceS(owner->getSystemState(),"connect"))); struct timeval timeout; int maxfd; @@ -405,7 +405,7 @@ if (status < 0) { owner->incRef(); - getVm()->addEvent(owner, _MR(Class<IOErrorEvent>::getInstanceS())); + getVm(owner->getSystemState())->addEvent(owner, _MR(Class<IOErrorEvent>::getInstanceS(owner->getSystemState()))); return; } @@ -417,7 +417,7 @@ if (nbytes < 0) { owner->incRef(); - getVm()->addEvent(owner, _MR(Class<IOErrorEvent>::getInstanceS())); + getVm(owner->getSystemState())->addEvent(owner, _MR(Class<IOErrorEvent>::getInstanceS(owner->getSystemState()))); return; } else if (nbytes == 0) @@ -449,20 +449,20 @@ buf[nbytes] = '\0'; tiny_string data(buf, true); owner->incRef(); - getVm()->addEvent(owner, _MR(Class<DataEvent>::getInstanceS(data))); + getVm(owner->getSystemState())->addEvent(owner, _MR(Class<DataEvent>::getInstanceS(owner->getSystemState(),data))); } else if (nbytes == 0) { // The server has closed the socket owner->incRef(); - getVm()->addEvent(owner, _MR(Class<Event>::getInstanceS("close"))); + getVm(owner->getSystemState())->addEvent(owner, _MR(Class<Event>::getInstanceS(owner->getSystemState(),"close"))); threadAborting = true; } else { // Error owner->incRef(); - getVm()->addEvent(owner, _MR(Class<IOErrorEvent>::getInstanceS())); + getVm(owner->getSystemState())->addEvent(owner, _MR(Class<IOErrorEvent>::getInstanceS(owner->getSystemState()))); threadAborting = true; } }
View file
lightspark.tar.xz/src/scripting/flash/net/flashnet.cpp
Changed
@@ -36,21 +36,21 @@ using namespace lightspark; URLRequest::URLRequest(Class_base* c):ASObject(c),method(GET),contentType("application/x-www-form-urlencoded"), - requestHeaders(Class<Array>::getInstanceS()) + requestHeaders(Class<Array>::getInstanceS(c->getSystemState())) { } void URLRequest::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL | CLASS_SEALED); - c->setDeclaredMethodByQName("url","",Class<IFunction>::getFunction(_setURL),SETTER_METHOD,true); - c->setDeclaredMethodByQName("url","",Class<IFunction>::getFunction(_getURL),GETTER_METHOD,true); - c->setDeclaredMethodByQName("method","",Class<IFunction>::getFunction(_setMethod),SETTER_METHOD,true); - c->setDeclaredMethodByQName("method","",Class<IFunction>::getFunction(_getMethod),GETTER_METHOD,true); - c->setDeclaredMethodByQName("data","",Class<IFunction>::getFunction(_setData),SETTER_METHOD,true); - c->setDeclaredMethodByQName("data","",Class<IFunction>::getFunction(_getData),GETTER_METHOD,true); - c->setDeclaredMethodByQName("digest","",Class<IFunction>::getFunction(_setDigest),SETTER_METHOD,true); - c->setDeclaredMethodByQName("digest","",Class<IFunction>::getFunction(_getDigest),GETTER_METHOD,true); + c->setDeclaredMethodByQName("url","",Class<IFunction>::getFunction(c->getSystemState(),_setURL),SETTER_METHOD,true); + c->setDeclaredMethodByQName("url","",Class<IFunction>::getFunction(c->getSystemState(),_getURL),GETTER_METHOD,true); + c->setDeclaredMethodByQName("method","",Class<IFunction>::getFunction(c->getSystemState(),_setMethod),SETTER_METHOD,true); + c->setDeclaredMethodByQName("method","",Class<IFunction>::getFunction(c->getSystemState(),_getMethod),GETTER_METHOD,true); + c->setDeclaredMethodByQName("data","",Class<IFunction>::getFunction(c->getSystemState(),_setData),SETTER_METHOD,true); + c->setDeclaredMethodByQName("data","",Class<IFunction>::getFunction(c->getSystemState(),_getData),GETTER_METHOD,true); + c->setDeclaredMethodByQName("digest","",Class<IFunction>::getFunction(c->getSystemState(),_setDigest),SETTER_METHOD,true); + c->setDeclaredMethodByQName("digest","",Class<IFunction>::getFunction(c->getSystemState(),_getDigest),GETTER_METHOD,true); REGISTER_GETTER_SETTER(c,contentType); REGISTER_GETTER_SETTER(c,requestHeaders); } @@ -68,7 +68,7 @@ if(data.isNull()) return ret; - if(data->getClass()==Class<ByteArray>::getClass()) + if(data->getClass()==Class<ByteArray>::getClass(data->getSystemState())) ret=ret.getParsedURL(); else { @@ -91,7 +91,7 @@ if(contentType.find("\r")!=contentType.npos || contentType.find("\n")!=contentType.npos) { - throw Class<ArgumentError>::getInstanceS(tiny_string("The HTTP request header ") + contentType + tiny_string(" cannot be set via ActionScript."), 2096); + throw Class<ArgumentError>::getInstanceS(getSystemState(),tiny_string("The HTTP request header ") + contentType + tiny_string(" cannot be set via ActionScript."), 2096); } return contentType; @@ -126,7 +126,7 @@ if ((headerName.strchr('\r') != NULL) || headerName.strchr('\n') != NULL) - throw Class<ArgumentError>::getInstanceS("The HTTP request header cannot be set via ActionScript", 2096); + throw Class<ArgumentError>::getInstanceS(getSystemState(),"The HTTP request header cannot be set via ActionScript", 2096); for (unsigned i=0; i<(sizeof illegalHeaders)/(sizeof illegalHeaders[0]); i++) { @@ -135,7 +135,7 @@ tiny_string msg("The HTTP request header "); msg += headerName; msg += " cannot be set via ActionScript"; - throw Class<ArgumentError>::getInstanceS(msg, 2096); + throw Class<ArgumentError>::getInstanceS(getSystemState(),msg, 2096); } } } @@ -160,13 +160,13 @@ validateHeaderName(headerName); if ((header->value.strchr('\r') != NULL) || header->value.strchr('\n') != NULL) - throw Class<ArgumentError>::getInstanceS("Illegal HTTP header value"); + throw Class<ArgumentError>::getInstanceS(getSystemState(),"Illegal HTTP header value"); // Should this include the separators? headerTotalLen += header->name.numBytes(); headerTotalLen += header->value.numBytes(); if (headerTotalLen >= 8192) - throw Class<ArgumentError>::getInstanceS("Cumulative length of requestHeaders must be less than 8192 characters.", 2145); + throw Class<ArgumentError>::getInstanceS(getSystemState(),"Cumulative length of requestHeaders must be less than 8192 characters.", 2145); // Append header to results headers.push_back(headerName + ": " + header->value); @@ -184,7 +184,7 @@ if(method!=POST) return ""; - if(!data.isNull() && data->getClass()==Class<URLVariables>::getClass()) + if(!data.isNull() && data->getClass()==Class<URLVariables>::getClass(data->getSystemState())) return "Content-type: application/x-www-form-urlencoded"; else return tiny_string("Content-Type: ") + validatedContentType(); @@ -198,7 +198,7 @@ if(data.isNull()) return; - if(data->getClass()==Class<ByteArray>::getClass()) + if(data->getClass()==Class<ByteArray>::getClass(data->getSystemState())) { ByteArray *ba=data->as<ByteArray>(); const uint8_t *buf=ba->getBuffer(ba->getLength(), false); @@ -234,7 +234,7 @@ ASFUNCTIONBODY(URLRequest,_getURL) { URLRequest* th=static_cast<URLRequest*>(obj); - return Class<ASString>::getInstanceS(th->url); + return abstract_s(obj->getSystemState(),th->url); } ASFUNCTIONBODY(URLRequest,_setMethod) @@ -257,9 +257,9 @@ switch(th->method) { case GET: - return Class<ASString>::getInstanceS("GET"); + return abstract_s(obj->getSystemState(),"GET"); case POST: - return Class<ASString>::getInstanceS("POST"); + return abstract_s(obj->getSystemState(),"POST"); } return NULL; } @@ -291,7 +291,7 @@ if (th->digest.empty()) return getSys()->getNullRef(); else - return Class<ASString>::getInstanceS(th->digest); + return abstract_s(obj->getSystemState(),th->digest); } ASFUNCTIONBODY(URLRequest,_setDigest) @@ -318,7 +318,7 @@ } if (!validChars || numHexChars != 64) - throw Class<ArgumentError>::getInstanceS("An invalid digest was supplied", 2034); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"An invalid digest was supplied", 2034); th->digest = value; return NULL; @@ -330,8 +330,8 @@ void URLRequestMethod::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("GET","",Class<ASString>::getInstanceS("GET"),DECLARED_TRAIT); - c->setVariableByQName("POST","",Class<ASString>::getInstanceS("POST"),DECLARED_TRAIT); + c->setVariableByQName("GET","",abstract_s(c->getSystemState(),"GET"),DECLARED_TRAIT); + c->setVariableByQName("POST","",abstract_s(c->getSystemState(),"POST"),DECLARED_TRAIT); } URLLoaderThread::URLLoaderThread(_R<URLRequest> request, _R<URLLoader> ldr) @@ -354,7 +354,7 @@ if(!downloader->hasFailed()) { loader->incRef(); - getVm()->addEvent(loader,_MR(Class<Event>::getInstanceS("open"))); + getVm(loader->getSystemState())->addEvent(loader,_MR(Class<Event>::getInstanceS(loader->getSystemState(),"open"))); cache->waitForTermination(); if(!downloader->hasFailed() && !threadAborting) @@ -369,19 +369,19 @@ tiny_string dataFormat=loader->getDataFormat(); if(dataFormat=="binary") { - _R<ByteArray> byteArray=_MR(Class<ByteArray>::getInstanceS()); + _R<ByteArray> byteArray=_MR(Class<ByteArray>::getInstanceS(loader->getSystemState())); byteArray->acquireBuffer(buf,downloader->getLength()); data=byteArray; //The buffers must not be deleted, it's now handled by the ByteArray instance } else if(dataFormat=="text") { - data=_MR(Class<ASString>::getInstanceS((char*)buf,downloader->getLength())); + data=_MR(abstract_s(loader->getSystemState(),(char*)buf,downloader->getLength())); delete[] buf; } else if(dataFormat=="variables") { - data=_MR(Class<URLVariables>::getInstanceS((char*)buf)); + data=_MR(Class<URLVariables>::getInstanceS(loader->getSystemState(),(char*)buf)); delete[] buf; } else @@ -401,16 +401,16 @@ loader->setData(data); loader->incRef(); - getVm()->addEvent(loader,_MR(Class<ProgressEvent>::getInstanceS(downloader->getLength(),downloader->getLength()))); + getVm(loader->getSystemState())->addEvent(loader,_MR(Class<ProgressEvent>::getInstanceS(loader->getSystemState(),downloader->getLength(),downloader->getLength()))); //Send a complete event for this object loader->incRef(); - getVm()->addEvent(loader,_MR(Class<Event>::getInstanceS("complete"))); + getVm(loader->getSystemState())->addEvent(loader,_MR(Class<Event>::getInstanceS(loader->getSystemState(),"complete"))); } else if(!success && !threadAborting) { //Notify an error during loading loader->incRef(); - getVm()->addEvent(loader,_MR(Class<IOErrorEvent>::getInstanceS())); + getVm(loader->getSystemState())->addEvent(loader,_MR(Class<IOErrorEvent>::getInstanceS(loader->getSystemState()))); } { @@ -434,12 +434,12 @@ void URLLoader::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("dataFormat","",Class<IFunction>::getFunction(_getDataFormat),GETTER_METHOD,true); - c->setDeclaredMethodByQName("data","",Class<IFunction>::getFunction(_getData),GETTER_METHOD,true); - c->setDeclaredMethodByQName("data","",Class<IFunction>::getFunction(_setData),SETTER_METHOD,true); - c->setDeclaredMethodByQName("dataFormat","",Class<IFunction>::getFunction(_setDataFormat),SETTER_METHOD,true); - c->setDeclaredMethodByQName("load","",Class<IFunction>::getFunction(load),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(close),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("dataFormat","",Class<IFunction>::getFunction(c->getSystemState(),_getDataFormat),GETTER_METHOD,true); + c->setDeclaredMethodByQName("data","",Class<IFunction>::getFunction(c->getSystemState(),_getData),GETTER_METHOD,true); + c->setDeclaredMethodByQName("data","",Class<IFunction>::getFunction(c->getSystemState(),_setData),SETTER_METHOD,true); + c->setDeclaredMethodByQName("dataFormat","",Class<IFunction>::getFunction(c->getSystemState(),_setDataFormat),SETTER_METHOD,true); + c->setDeclaredMethodByQName("load","",Class<IFunction>::getFunction(c->getSystemState(),load),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(c->getSystemState(),close),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c,bytesLoaded); REGISTER_GETTER_SETTER(c,bytesTotal); } @@ -483,14 +483,14 @@ { timestamp_last_progress = cur; this->incRef(); - getVm()->addEvent(_MR(this),_MR(Class<ProgressEvent>::getInstanceS(b,bytesTotal))); + getVm(getSystemState())->addEvent(_MR(this),_MR(Class<ProgressEvent>::getInstanceS(getSystemState(),b,bytesTotal))); } } ASFUNCTIONBODY(URLLoader,_constructor) { EventDispatcher::_constructor(obj,NULL,0); - if(argslen==1 && args[0]->getClass() == Class<URLRequest>::getClass()) + if(argslen==1 && args[0]->getClass() == Class<URLRequest>::getClass(args[0]->getSystemState())) { //URLRequest* urlRequest=Class<URLRequest>::dyncast(args[0]); load(obj, args, argslen); @@ -516,7 +516,7 @@ { //Notify an error during loading th->incRef(); - getSys()->currentVm->addEvent(_MR(th),_MR(Class<IOErrorEvent>::getInstanceS())); + obj->getSystemState()->currentVm->addEvent(_MR(th),_MR(Class<IOErrorEvent>::getInstanceS(obj->getSystemState()))); return NULL; } @@ -561,7 +561,7 @@ ASFUNCTIONBODY(URLLoader,_getDataFormat) { URLLoader* th=static_cast<URLLoader*>(obj); - return Class<ASString>::getInstanceS(th->getDataFormat()); + return abstract_s(obj->getSystemState(),th->getDataFormat()); } ASFUNCTIONBODY(URLLoader,_getData) @@ -578,10 +578,10 @@ ASFUNCTIONBODY(URLLoader,_setData) { if(!obj->is<URLLoader>()) - throw Class<ArgumentError>::getInstanceS("Function applied to wrong object"); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Function applied to wrong object"); URLLoader* th = obj->as<URLLoader>(); if(argslen != 1) - throw Class<ArgumentError>::getInstanceS("Wrong number of arguments in setter"); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Wrong number of arguments in setter"); args[0]->incRef(); th->setData(_MR(args[0])); return NULL; @@ -598,42 +598,42 @@ void URLLoaderDataFormat::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("VARIABLES","",Class<ASString>::getInstanceS("variables"),DECLARED_TRAIT); - c->setVariableByQName("TEXT","",Class<ASString>::getInstanceS("text"),DECLARED_TRAIT); - c->setVariableByQName("BINARY","",Class<ASString>::getInstanceS("binary"),DECLARED_TRAIT); + c->setVariableByQName("VARIABLES","",abstract_s(c->getSystemState(),"variables"),DECLARED_TRAIT); + c->setVariableByQName("TEXT","",abstract_s(c->getSystemState(),"text"),DECLARED_TRAIT); + c->setVariableByQName("BINARY","",abstract_s(c->getSystemState(),"binary"),DECLARED_TRAIT); } void SharedObjectFlushStatus::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL); - c->setVariableByQName("FLUSHED","",Class<ASString>::getInstanceS("flushed"),DECLARED_TRAIT); - c->setVariableByQName("PENDING","",Class<ASString>::getInstanceS("pending"),DECLARED_TRAIT); + c->setVariableByQName("FLUSHED","",abstract_s(c->getSystemState(),"flushed"),DECLARED_TRAIT); + c->setVariableByQName("PENDING","",abstract_s(c->getSystemState(),"pending"),DECLARED_TRAIT); } std::map<tiny_string, ASObject* > SharedObject::sharedobjectmap; SharedObject::SharedObject(Class_base* c):EventDispatcher(c),client(this),objectEncoding(ObjectEncoding::AMF3) { - data=_MR(new_asobject()); + data=_MR(new_asobject(c->getSystemState())); } void SharedObject::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, EventDispatcher, CLASS_SEALED); - c->setDeclaredMethodByQName("getLocal","",Class<IFunction>::getFunction(getLocal),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("getRemote","",Class<IFunction>::getFunction(getRemote),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("flush","",Class<IFunction>::getFunction(flush),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("clear","",Class<IFunction>::getFunction(clear),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(close),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("connect","",Class<IFunction>::getFunction(connect),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getLocal","",Class<IFunction>::getFunction(c->getSystemState(),getLocal),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("getRemote","",Class<IFunction>::getFunction(c->getSystemState(),getRemote),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("flush","",Class<IFunction>::getFunction(c->getSystemState(),flush),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("clear","",Class<IFunction>::getFunction(c->getSystemState(),clear),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(c->getSystemState(),close),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("connect","",Class<IFunction>::getFunction(c->getSystemState(),connect),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c,client); REGISTER_GETTER(c,data); - c->setDeclaredMethodByQName("defaultObjectEncoding","",Class<IFunction>::getFunction(_getDefaultObjectEncoding),GETTER_METHOD,false); - c->setDeclaredMethodByQName("defaultObjectEncoding","",Class<IFunction>::getFunction(_setDefaultObjectEncoding),SETTER_METHOD,false); + c->setDeclaredMethodByQName("defaultObjectEncoding","",Class<IFunction>::getFunction(c->getSystemState(),_getDefaultObjectEncoding),GETTER_METHOD,false); + c->setDeclaredMethodByQName("defaultObjectEncoding","",Class<IFunction>::getFunction(c->getSystemState(),_setDefaultObjectEncoding),SETTER_METHOD,false); REGISTER_SETTER(c,fps); REGISTER_GETTER_SETTER(c,objectEncoding); - c->setDeclaredMethodByQName("preventBackup","",Class<IFunction>::getFunction(_getPreventBackup),GETTER_METHOD,false); - c->setDeclaredMethodByQName("preventBackup","",Class<IFunction>::getFunction(_setPreventBackup),SETTER_METHOD,false); - c->setDeclaredMethodByQName("size","",Class<IFunction>::getFunction(_getSize),GETTER_METHOD,true); + c->setDeclaredMethodByQName("preventBackup","",Class<IFunction>::getFunction(c->getSystemState(),_getPreventBackup),GETTER_METHOD,false); + c->setDeclaredMethodByQName("preventBackup","",Class<IFunction>::getFunction(c->getSystemState(),_setPreventBackup),SETTER_METHOD,false); + c->setDeclaredMethodByQName("size","",Class<IFunction>::getFunction(c->getSystemState(),_getSize),GETTER_METHOD,true); getSys()->staticSharedObjectDefaultObjectEncoding = ObjectEncoding::AMF3; getSys()->staticSharedObjectPreventBackup = false; @@ -646,7 +646,7 @@ ASFUNCTIONBODY(SharedObject,_getDefaultObjectEncoding) { - return abstract_ui(getSys()->staticSharedObjectDefaultObjectEncoding); + return abstract_ui(getSys(),getSys()->staticSharedObjectDefaultObjectEncoding); } ASFUNCTIONBODY(SharedObject,_setDefaultObjectEncoding) @@ -677,11 +677,11 @@ tiny_string fullname = localPath + "|"; fullname += name; - SharedObject* res = Class<SharedObject>::getInstanceS(); + SharedObject* res = Class<SharedObject>::getInstanceS(obj->getSystemState()); std::map<tiny_string, ASObject* >::iterator it = sharedobjectmap.find(fullname); if (it == sharedobjectmap.end()) { - sharedobjectmap.insert(make_pair(fullname,Class<ASObject>::getInstanceS())); + sharedobjectmap.insert(make_pair(fullname,Class<ASObject>::getInstanceS(obj->getSystemState()))); it = sharedobjectmap.find(fullname); } it->second->incRef(); @@ -722,7 +722,7 @@ ASFUNCTIONBODY(SharedObject,_getPreventBackup) { - return abstract_b(getSys()->staticSharedObjectPreventBackup); + return abstract_b(getSys(),getSys()->staticSharedObjectPreventBackup); } ASFUNCTIONBODY(SharedObject,_setPreventBackup) @@ -738,15 +738,15 @@ { /* Get the size of the objects in the sharedobjectmap */ LOG(LOG_NOT_IMPLEMENTED, "SharedObject.size not implemented"); - return abstract_ui(0); + return abstract_ui(obj->getSystemState(),0); } void ObjectEncoding::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("AMF0","",abstract_i(AMF0),DECLARED_TRAIT); - c->setVariableByQName("AMF3","",abstract_i(AMF3),DECLARED_TRAIT); - c->setVariableByQName("DEFAULT","",abstract_i(DEFAULT),DECLARED_TRAIT); + c->setVariableByQName("AMF0","",abstract_i(c->getSystemState(),AMF0),DECLARED_TRAIT); + c->setVariableByQName("AMF3","",abstract_i(c->getSystemState(),AMF3),DECLARED_TRAIT); + c->setVariableByQName("DEFAULT","",abstract_i(c->getSystemState(),DEFAULT),DECLARED_TRAIT); } NetConnection::NetConnection(Class_base* c): @@ -758,19 +758,19 @@ void NetConnection::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("connect","",Class<IFunction>::getFunction(connect),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("call","",Class<IFunction>::getFunction(call),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("connected","",Class<IFunction>::getFunction(_getConnected),GETTER_METHOD,true); - c->setDeclaredMethodByQName("defaultObjectEncoding","",Class<IFunction>::getFunction(_getDefaultObjectEncoding),GETTER_METHOD,false); - c->setDeclaredMethodByQName("defaultObjectEncoding","",Class<IFunction>::getFunction(_setDefaultObjectEncoding),SETTER_METHOD,false); + c->setDeclaredMethodByQName("connect","",Class<IFunction>::getFunction(c->getSystemState(),connect),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("call","",Class<IFunction>::getFunction(c->getSystemState(),call),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("connected","",Class<IFunction>::getFunction(c->getSystemState(),_getConnected),GETTER_METHOD,true); + c->setDeclaredMethodByQName("defaultObjectEncoding","",Class<IFunction>::getFunction(c->getSystemState(),_getDefaultObjectEncoding),GETTER_METHOD,false); + c->setDeclaredMethodByQName("defaultObjectEncoding","",Class<IFunction>::getFunction(c->getSystemState(),_setDefaultObjectEncoding),SETTER_METHOD,false); getSys()->staticNetConnectionDefaultObjectEncoding = ObjectEncoding::DEFAULT; - c->setDeclaredMethodByQName("objectEncoding","",Class<IFunction>::getFunction(_getObjectEncoding),GETTER_METHOD,true); - c->setDeclaredMethodByQName("objectEncoding","",Class<IFunction>::getFunction(_setObjectEncoding),SETTER_METHOD,true); - c->setDeclaredMethodByQName("protocol","",Class<IFunction>::getFunction(_getProtocol),GETTER_METHOD,true); - c->setDeclaredMethodByQName("proxyType","",Class<IFunction>::getFunction(_getProxyType),GETTER_METHOD,true); - c->setDeclaredMethodByQName("proxyType","",Class<IFunction>::getFunction(_setProxyType),SETTER_METHOD,true); - c->setDeclaredMethodByQName("uri","",Class<IFunction>::getFunction(_getURI),GETTER_METHOD,true); - c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(close),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("objectEncoding","",Class<IFunction>::getFunction(c->getSystemState(),_getObjectEncoding),GETTER_METHOD,true); + c->setDeclaredMethodByQName("objectEncoding","",Class<IFunction>::getFunction(c->getSystemState(),_setObjectEncoding),SETTER_METHOD,true); + c->setDeclaredMethodByQName("protocol","",Class<IFunction>::getFunction(c->getSystemState(),_getProtocol),GETTER_METHOD,true); + c->setDeclaredMethodByQName("proxyType","",Class<IFunction>::getFunction(c->getSystemState(),_getProxyType),GETTER_METHOD,true); + c->setDeclaredMethodByQName("proxyType","",Class<IFunction>::getFunction(c->getSystemState(),_setProxyType),SETTER_METHOD,true); + c->setDeclaredMethodByQName("uri","",Class<IFunction>::getFunction(c->getSystemState(),_getURI),GETTER_METHOD,true); + c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(c->getSystemState(),close),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c,client); } @@ -817,14 +817,14 @@ //This function is supposed to be passed a array for the rest //of the arguments. Since that is not supported for native methods //just create it here - _R<Array> rest=_MR(Class<Array>::getInstanceS()); + _R<Array> rest=_MR(Class<Array>::getInstanceS(obj->getSystemState())); for(uint32_t i=2;i<argslen;i++) { args[i]->incRef(); rest->push(_MR(args[i])); } - _R<ByteArray> message=_MR(Class<ByteArray>::getInstanceS()); + _R<ByteArray> message=_MR(Class<ByteArray>::getInstanceS(obj->getSystemState())); //Version? message->writeByte(0x00); message->writeByte(0x03); @@ -878,7 +878,7 @@ } std::streambuf *sbuf = cache->createReader(); istream s(sbuf); - _R<ByteArray> message=_MR(Class<ByteArray>::getInstanceS()); + _R<ByteArray> message=_MR(Class<ByteArray>::getInstanceS(getSys())); uint8_t* buf=message->getBuffer(downloader->getLength(), true); s.read((char*)buf,downloader->getLength()); //Download is done, destroy it @@ -889,8 +889,8 @@ getSys()->downloadManager->destroy(downloader); downloader = NULL; } - _R<ParseRPCMessageEvent> event=_MR(new (getSys()->unaccountedMemory) ParseRPCMessageEvent(message, client, responder)); - getVm()->addEvent(NullRef,event); + _R<ParseRPCMessageEvent> event=_MR(new (getSystemState()->unaccountedMemory) ParseRPCMessageEvent(message, client, responder)); + getVm(getSystemState())->addEvent(NullRef,event); responder.reset(); } @@ -919,7 +919,7 @@ //that the official player allows connect(null) in localWithFile. if(args[0]->getObjectType() != T_NULL && getSys()->securityManager->evaluateSandbox(SecurityManager::LOCAL_WITH_FILE)) - throw Class<SecurityError>::getInstanceS("SecurityError: NetConnection::connect " + throw Class<SecurityError>::getInstanceS(obj->getSystemState(),"SecurityError: NetConnection::connect " "from LOCAL_WITH_FILE sandbox"); bool isNull = false; @@ -944,7 +944,7 @@ if(getSys()->securityManager->evaluatePoliciesURL(th->uri, true) != SecurityManager::ALLOWED) { //TODO: find correct way of handling this case - throw Class<SecurityError>::getInstanceS("SecurityError: connection to domain not allowed by securityManager"); + throw Class<SecurityError>::getInstanceS(obj->getSystemState(),"SecurityError: connection to domain not allowed by securityManager"); } //By spec NetConnection::connect is true for RTMP and remoting and false otherwise @@ -973,7 +973,7 @@ if(isNull || isRTMP) { th->incRef(); - getVm()->addEvent(_MR(th), _MR(Class<NetStatusEvent>::getInstanceS("status", "NetConnection.Connect.Success"))); + getVm(obj->getSystemState())->addEvent(_MR(th), _MR(Class<NetStatusEvent>::getInstanceS(obj->getSystemState(),"status", "NetConnection.Connect.Success"))); } return NULL; } @@ -981,20 +981,20 @@ ASFUNCTIONBODY(NetConnection,_getConnected) { NetConnection* th=Class<NetConnection>::cast(obj); - return abstract_b(th->_connected); + return abstract_b(obj->getSystemState(),th->_connected); } ASFUNCTIONBODY(NetConnection,_getConnectedProxyType) { NetConnection* th=Class<NetConnection>::cast(obj); if (!th->_connected) - throw Class<ArgumentError>::getInstanceS("NetConnection object must be connected.", 2126); - return Class<ASString>::getInstanceS("none"); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"NetConnection object must be connected.", 2126); + return abstract_s(obj->getSystemState(),"none"); } ASFUNCTIONBODY(NetConnection,_getDefaultObjectEncoding) { - return abstract_i(getSys()->staticNetConnectionDefaultObjectEncoding); + return abstract_i(obj->getSystemState(),obj->getSystemState()->staticNetConnectionDefaultObjectEncoding); } ASFUNCTIONBODY(NetConnection,_setDefaultObjectEncoding) @@ -1013,7 +1013,7 @@ ASFUNCTIONBODY(NetConnection,_getObjectEncoding) { NetConnection* th=Class<NetConnection>::cast(obj); - return abstract_i(th->objectEncoding); + return abstract_i(obj->getSystemState(),th->objectEncoding); } ASFUNCTIONBODY(NetConnection,_setObjectEncoding) @@ -1022,7 +1022,7 @@ assert_and_throw(argslen == 1); if(th->_connected) { - throw Class<ReferenceError>::getInstanceS("set NetConnection.objectEncoding after connect"); + throw Class<ReferenceError>::getInstanceS(obj->getSystemState(),"set NetConnection.objectEncoding after connect"); } int32_t value = args[0]->toInt(); if(value == 0) @@ -1036,9 +1036,9 @@ { NetConnection* th=Class<NetConnection>::cast(obj); if(th->_connected) - return Class<ASString>::getInstanceS(th->protocol); + return abstract_s(obj->getSystemState(),th->protocol); else - throw Class<ArgumentError>::getInstanceS("get NetConnection.protocol before connect"); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"get NetConnection.protocol before connect"); } ASFUNCTIONBODY(NetConnection,_getProxyType) @@ -1067,7 +1067,7 @@ name = ""; break; } - return Class<ASString>::getInstanceS(name); + return abstract_s(obj->getSystemState(),name); } ASFUNCTIONBODY(NetConnection,_setProxyType) @@ -1098,11 +1098,11 @@ { NetConnection* th=Class<NetConnection>::cast(obj); if(th->_connected && th->uri.isValid()) - return Class<ASString>::getInstanceS(th->uri.getURL()); + return abstract_s(obj->getSystemState(),th->uri.getURL()); else { //Reference says the return should be undefined. The right thing is "null" as a string - return Class<ASString>::getInstanceS("null"); + return abstract_s(obj->getSystemState(),"null"); } } @@ -1122,20 +1122,20 @@ void NetStreamAppendBytesAction::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL); - c->setVariableByQName("END_SEQUENCE","",Class<ASString>::getInstanceS("endSequence"),CONSTANT_TRAIT); - c->setVariableByQName("RESET_BEGIN","",Class<ASString>::getInstanceS("resetBegin"),CONSTANT_TRAIT); - c->setVariableByQName("RESET_SEEK","",Class<ASString>::getInstanceS("resetSeek"),CONSTANT_TRAIT); + c->setVariableByQName("END_SEQUENCE","",abstract_s(c->getSystemState(),"endSequence"),CONSTANT_TRAIT); + c->setVariableByQName("RESET_BEGIN","",abstract_s(c->getSystemState(),"resetBegin"),CONSTANT_TRAIT); + c->setVariableByQName("RESET_SEEK","",abstract_s(c->getSystemState(),"resetSeek"),CONSTANT_TRAIT); } NetStream::NetStream(Class_base* c):EventDispatcher(c),tickStarted(false),paused(false),closed(true), streamTime(0),frameRate(0),connection(),downloader(NULL),videoDecoder(NULL), audioDecoder(NULL),audioStream(NULL),datagenerationfile(NULL),datagenerationthreadstarted(false),client(NullRef), - oldVolume(-1.0),checkPolicyFile(false),rawAccessAllowed(false),framesdecoded(0),playbackBytesPerSecond(0),maxBytesPerSecond(0),datagenerationexpecttype(DATAGENERATION_HEADER),datagenerationbuffer(Class<ByteArray>::getInstanceS()), + oldVolume(-1.0),checkPolicyFile(false),rawAccessAllowed(false),framesdecoded(0),playbackBytesPerSecond(0),maxBytesPerSecond(0),datagenerationexpecttype(DATAGENERATION_HEADER),datagenerationbuffer(Class<ByteArray>::getInstanceS(c->getSystemState())), backBufferLength(0),backBufferTime(30),bufferLength(0),bufferTime(0.1),bufferTimeMax(0), maxPauseBufferTime(0) { - soundTransform = _MNR(Class<SoundTransform>::getInstanceS()); + soundTransform = _MNR(Class<SoundTransform>::getInstanceS(c->getSystemState())); } void NetStream::finalize() @@ -1158,26 +1158,26 @@ void NetStream::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_SEALED); - c->setVariableByQName("CONNECT_TO_FMS","",Class<ASString>::getInstanceS("connectToFMS"),DECLARED_TRAIT); - c->setVariableByQName("DIRECT_CONNECTIONS","",Class<ASString>::getInstanceS("directConnections"),DECLARED_TRAIT); - c->setDeclaredMethodByQName("play","",Class<IFunction>::getFunction(play),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("play2","",Class<IFunction>::getFunction(play2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("resume","",Class<IFunction>::getFunction(resume),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("pause","",Class<IFunction>::getFunction(pause),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("togglePause","",Class<IFunction>::getFunction(togglePause),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(close),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("seek","",Class<IFunction>::getFunction(seek),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("bytesLoaded","",Class<IFunction>::getFunction(_getBytesLoaded),GETTER_METHOD,true); - c->setDeclaredMethodByQName("bytesTotal","",Class<IFunction>::getFunction(_getBytesTotal),GETTER_METHOD,true); - c->setDeclaredMethodByQName("time","",Class<IFunction>::getFunction(_getTime),GETTER_METHOD,true); - c->setDeclaredMethodByQName("currentFPS","",Class<IFunction>::getFunction(_getCurrentFPS),GETTER_METHOD,true); - c->setDeclaredMethodByQName("client","",Class<IFunction>::getFunction(_getClient),GETTER_METHOD,true); - c->setDeclaredMethodByQName("client","",Class<IFunction>::getFunction(_setClient),SETTER_METHOD,true); - c->setDeclaredMethodByQName("checkPolicyFile","",Class<IFunction>::getFunction(_getCheckPolicyFile),GETTER_METHOD,true); - c->setDeclaredMethodByQName("checkPolicyFile","",Class<IFunction>::getFunction(_setCheckPolicyFile),SETTER_METHOD,true); - c->setDeclaredMethodByQName("attach","",Class<IFunction>::getFunction(attach),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("appendBytes","",Class<IFunction>::getFunction(appendBytes),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("appendBytesAction","",Class<IFunction>::getFunction(appendBytesAction),NORMAL_METHOD,true); + c->setVariableByQName("CONNECT_TO_FMS","",abstract_s(c->getSystemState(),"connectToFMS"),DECLARED_TRAIT); + c->setVariableByQName("DIRECT_CONNECTIONS","",abstract_s(c->getSystemState(),"directConnections"),DECLARED_TRAIT); + c->setDeclaredMethodByQName("play","",Class<IFunction>::getFunction(c->getSystemState(),play),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("play2","",Class<IFunction>::getFunction(c->getSystemState(),play2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("resume","",Class<IFunction>::getFunction(c->getSystemState(),resume),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("pause","",Class<IFunction>::getFunction(c->getSystemState(),pause),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("togglePause","",Class<IFunction>::getFunction(c->getSystemState(),togglePause),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(c->getSystemState(),close),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("seek","",Class<IFunction>::getFunction(c->getSystemState(),seek),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("bytesLoaded","",Class<IFunction>::getFunction(c->getSystemState(),_getBytesLoaded),GETTER_METHOD,true); + c->setDeclaredMethodByQName("bytesTotal","",Class<IFunction>::getFunction(c->getSystemState(),_getBytesTotal),GETTER_METHOD,true); + c->setDeclaredMethodByQName("time","",Class<IFunction>::getFunction(c->getSystemState(),_getTime),GETTER_METHOD,true); + c->setDeclaredMethodByQName("currentFPS","",Class<IFunction>::getFunction(c->getSystemState(),_getCurrentFPS),GETTER_METHOD,true); + c->setDeclaredMethodByQName("client","",Class<IFunction>::getFunction(c->getSystemState(),_getClient),GETTER_METHOD,true); + c->setDeclaredMethodByQName("client","",Class<IFunction>::getFunction(c->getSystemState(),_setClient),SETTER_METHOD,true); + c->setDeclaredMethodByQName("checkPolicyFile","",Class<IFunction>::getFunction(c->getSystemState(),_getCheckPolicyFile),GETTER_METHOD,true); + c->setDeclaredMethodByQName("checkPolicyFile","",Class<IFunction>::getFunction(c->getSystemState(),_setCheckPolicyFile),SETTER_METHOD,true); + c->setDeclaredMethodByQName("attach","",Class<IFunction>::getFunction(c->getSystemState(),attach),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("appendBytes","",Class<IFunction>::getFunction(c->getSystemState(),appendBytes),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("appendBytesAction","",Class<IFunction>::getFunction(c->getSystemState(),appendBytesAction),NORMAL_METHOD,true); REGISTER_GETTER(c, backBufferLength); REGISTER_GETTER_SETTER(c, backBufferTime); REGISTER_GETTER(c, bufferLength); @@ -1186,7 +1186,7 @@ REGISTER_GETTER_SETTER(c, maxPauseBufferTime); REGISTER_GETTER_SETTER(c,soundTransform); REGISTER_GETTER_SETTER(c,useHardwareDecoder); - c->setDeclaredMethodByQName("info","",Class<IFunction>::getFunction(_getInfo),GETTER_METHOD,true); + c->setDeclaredMethodByQName("info","",Class<IFunction>::getFunction(c->getSystemState(),_getInfo),GETTER_METHOD,true); } void NetStream::buildTraits(ASObject* o) @@ -1205,7 +1205,7 @@ ASFUNCTIONBODY(NetStream,_getInfo) { NetStream* th=Class<NetStream>::cast(obj); - NetStreamInfo* res = Class<NetStreamInfo>::getInstanceS(); + NetStreamInfo* res = Class<NetStreamInfo>::getInstanceS(obj->getSystemState()); if(th->isReady()) { res->byteCount = th->getReceivedLength(); @@ -1263,7 +1263,7 @@ { assert_and_throw(argslen == 1); if(args[0]->getObjectType() == T_NULL) - throw Class<TypeError>::getInstanceS(); + throw Class<TypeError>::getInstanceS(obj->getSystemState()); NetStream* th=Class<NetStream>::cast(obj); @@ -1276,7 +1276,7 @@ { NetStream* th=Class<NetStream>::cast(obj); - return abstract_b(th->checkPolicyFile); + return abstract_b(obj->getSystemState(),th->checkPolicyFile); } ASFUNCTIONBODY(NetStream,_setCheckPolicyFile) @@ -1365,17 +1365,17 @@ SecurityManager::LOCAL_WITH_FILE | SecurityManager::LOCAL_TRUSTED, true); //Check for navigating up in local directories (not allowed) if(evaluationResult == SecurityManager::NA_REMOTE_SANDBOX) - throw Class<SecurityError>::getInstanceS("SecurityError: NetStream::play: " + throw Class<SecurityError>::getInstanceS(obj->getSystemState(),"SecurityError: NetStream::play: " "connect to network"); //Local-with-filesystem sandbox can't access network else if(evaluationResult == SecurityManager::NA_LOCAL_SANDBOX) - throw Class<SecurityError>::getInstanceS("SecurityError: NetStream::play: " + throw Class<SecurityError>::getInstanceS(obj->getSystemState(),"SecurityError: NetStream::play: " "connect to local file"); else if(evaluationResult == SecurityManager::NA_PORT) - throw Class<SecurityError>::getInstanceS("SecurityError: NetStream::play: " + throw Class<SecurityError>::getInstanceS(obj->getSystemState(),"SecurityError: NetStream::play: " "connect to restricted port"); else if(evaluationResult == SecurityManager::NA_RESTRICT_LOCAL_DIRECTORY) - throw Class<SecurityError>::getInstanceS("SecurityError: NetStream::play: " + throw Class<SecurityError>::getInstanceS(obj->getSystemState(),"SecurityError: NetStream::play: " "not allowed to navigate up for local files"); } @@ -1389,7 +1389,7 @@ { //Notify an error during loading th->incRef(); - getVm()->addEvent(_MR(th),_MR(Class<IOErrorEvent>::getInstanceS())); + getVm(obj->getSystemState())->addEvent(_MR(th),_MR(Class<IOErrorEvent>::getInstanceS(obj->getSystemState()))); } else //The URL is valid so we can start the download and add ourself as a job { @@ -1420,7 +1420,7 @@ th->audioStream->resume(); } th->incRef(); - getVm()->addEvent(_MR(th), _MR(Class<NetStatusEvent>::getInstanceS("status", "NetStream.Unpause.Notify"))); + getVm(obj->getSystemState())->addEvent(_MR(th), _MR(Class<NetStatusEvent>::getInstanceS(obj->getSystemState(),"status", "NetStream.Unpause.Notify"))); } return NULL; } @@ -1437,7 +1437,7 @@ th->audioStream->pause(); } th->incRef(); - getVm()->addEvent(_MR(th),_MR(Class<NetStatusEvent>::getInstanceS("status", "NetStream.Pause.Notify"))); + getVm(obj->getSystemState())->addEvent(_MR(th),_MR(Class<NetStatusEvent>::getInstanceS(obj->getSystemState(),"status", "NetStream.Pause.Notify"))); } return NULL; } @@ -1462,7 +1462,7 @@ { th->threadAbort(); th->incRef(); - getVm()->addEvent(_MR(th), _MR(Class<NetStatusEvent>::getInstanceS("status", "NetStream.Play.Stop"))); + getVm(obj->getSystemState())->addEvent(_MR(th), _MR(Class<NetStatusEvent>::getInstanceS(obj->getSystemState(),"status", "NetStream.Play.Stop"))); } LOG(LOG_CALLS, _("NetStream::close called")); return NULL; @@ -1756,7 +1756,7 @@ //checkPolicyFile only applies to per-pixel access, loading and playing is always allowed. //So there is no need to disallow playing if policy files disallow it. //We do need to check if per-pixel access is allowed. - SecurityManager::EVALUATIONRESULT evaluationResult = getSys()->securityManager->evaluatePoliciesURL(url, true); + SecurityManager::EVALUATIONRESULT evaluationResult = getSystemState()->securityManager->evaluatePoliciesURL(url, true); if(evaluationResult == SecurityManager::NA_CROSSDOMAIN_POLICY) rawAccessAllowed = true; @@ -1774,8 +1774,8 @@ if(downloader->hasFailed()) { this->incRef(); - getVm()->addEvent(_MR(this),_MR(Class<IOErrorEvent>::getInstanceS())); - getSys()->downloadManager->destroy(downloader); + getVm(getSystemState())->addEvent(_MR(this),_MR(Class<IOErrorEvent>::getInstanceS(getSystemState()))); + getSystemState()->downloadManager->destroy(downloader); downloader = NULL; return; } @@ -1787,7 +1787,7 @@ istream s(sbuf); s.exceptions(istream::goodbit); - ThreadProfile* profile=getSys()->allocateProfiler(RGB(0,0,200)); + ThreadProfile* profile=getSystemState()->allocateProfiler(RGB(0,0,200)); profile->setTag("NetStream"); bool waitForFlush=true; //We need to catch possible EOF and other error condition in the non reliable stream @@ -1866,7 +1866,7 @@ bufferfull = false; this->bufferLength=0; this->incRef(); - getVm()->addEvent(_MR(this),_MR(Class<NetStatusEvent>::getInstanceS("status", "NetStream.Buffer.Empty"))); + getVm(getSystemState())->addEvent(_MR(this),_MR(Class<NetStatusEvent>::getInstanceS(getSystemState(),"status", "NetStream.Buffer.Empty"))); } } } @@ -1876,8 +1876,8 @@ { videoDecoder=streamDecoder->videoDecoder; this->incRef(); - getVm()->addEvent(_MR(this), - _MR(Class<NetStatusEvent>::getInstanceS("status", "NetStream.Play.Start"))); + getVm(getSystemState())->addEvent(_MR(this), + _MR(Class<NetStatusEvent>::getInstanceS(getSystemState(),"status", "NetStream.Play.Start"))); } if(audioDecoder==NULL && streamDecoder->audioDecoder) audioDecoder=streamDecoder->audioDecoder; @@ -1888,19 +1888,19 @@ { tickStarted=true; this->incRef(); - getVm()->addEvent(_MR(this), - _MR(Class<NetStatusEvent>::getInstanceS("status", "NetStream.Buffer.Full"))); - getSys()->addTick(1000/frameRate,this); + getVm(getSystemState())->addEvent(_MR(this), + _MR(Class<NetStatusEvent>::getInstanceS(getSystemState(),"status", "NetStream.Buffer.Full"))); + getSystemState()->addTick(1000/frameRate,this); //Also ask for a render rate equal to the video one (capped at 24) float localRenderRate=dmin(frameRate,24); - getSys()->setRenderRate(localRenderRate); + getSystemState()->setRenderRate(localRenderRate); } if (!bufferfull && frameRate && ((framesdecoded / frameRate) >= this->bufferTime)) { bufferfull = true; this->incRef(); - getVm()->addEvent(_MR(this), - _MR(Class<NetStatusEvent>::getInstanceS("status", "NetStream.Buffer.Full"))); + getVm(getSystemState())->addEvent(_MR(this), + _MR(Class<NetStatusEvent>::getInstanceS(getSystemState(),"status", "NetStream.Buffer.Full"))); } profile->accountTime(chronometer.checkpoint()); if(threadAborting) @@ -1937,12 +1937,12 @@ videoDecoder->waitFlushed(); this->incRef(); - getVm()->addEvent(_MR(this), _MR(Class<NetStatusEvent>::getInstanceS("status", "NetStream.Play.Stop"))); + getVm(getSystemState())->addEvent(_MR(this), _MR(Class<NetStatusEvent>::getInstanceS(getSystemState(),"status", "NetStream.Play.Stop"))); this->incRef(); - getVm()->addEvent(_MR(this), _MR(Class<NetStatusEvent>::getInstanceS("status", "NetStream.Buffer.Flush"))); + getVm(getSystemState())->addEvent(_MR(this), _MR(Class<NetStatusEvent>::getInstanceS(getSystemState(),"status", "NetStream.Buffer.Flush"))); } //Before deleting stops ticking, removeJobs also spin waits for termination - getSys()->removeJob(this); + getSystemState()->removeJob(this); tickStarted=false; { @@ -1996,7 +1996,7 @@ multiname callbackName(NULL); callbackName.name_type=multiname::NAME_STRING; callbackName.name_s_id=getSys()->getUniqueStringId(name); - callbackName.ns.push_back(nsNameAndKind("",NAMESPACE)); + callbackName.ns.push_back(nsNameAndKind(getSystemState(),"",NAMESPACE)); _NR<ASObject> callback = client->getVariableByMultiname(callbackName); if(!callback.isNull() && callback->is<Function>()) { @@ -2014,7 +2014,7 @@ _R<FunctionEvent> event(new (getSys()->unaccountedMemory) FunctionEvent(_MR( static_cast<IFunction*>(callback.getPtr())), _MR(client), callbackArgs, arglist.size())); - getVm()->addEvent(NullRef,event); + getVm(getSystemState())->addEvent(NullRef,event); } } @@ -2022,27 +2022,27 @@ { NetStream* th=Class<NetStream>::cast(obj); if(th->isReady()) - return abstract_i(th->getReceivedLength()); + return abstract_i(obj->getSystemState(),th->getReceivedLength()); else - return abstract_i(0); + return abstract_i(obj->getSystemState(),0); } ASFUNCTIONBODY(NetStream,_getBytesTotal) { NetStream* th=Class<NetStream>::cast(obj); if(th->isReady()) - return abstract_i(th->getTotalLength()); + return abstract_i(obj->getSystemState(),th->getTotalLength()); else - return abstract_d(0); + return abstract_d(obj->getSystemState(),0); } ASFUNCTIONBODY(NetStream,_getTime) { NetStream* th=Class<NetStream>::cast(obj); if(th->isReady()) - return abstract_d(th->getStreamTime()/1000.); + return abstract_d(obj->getSystemState(),th->getStreamTime()/1000.); else - return abstract_d(0); + return abstract_d(obj->getSystemState(),0); } ASFUNCTIONBODY(NetStream,_getCurrentFPS) @@ -2050,9 +2050,9 @@ //TODO: provide real FPS (what really is displayed) NetStream* th=Class<NetStream>::cast(obj); if(th->isReady() && !th->paused) - return abstract_d(th->getFrameRate()); + return abstract_d(obj->getSystemState(),th->getFrameRate()); else - return abstract_d(0); + return abstract_d(obj->getSystemState(),0); } uint32_t NetStream::getVideoWidth() const @@ -2156,7 +2156,7 @@ multiname propName(NULL); propName.name_type=multiname::NAME_STRING; propName.name_s_id=getSys()->getUniqueStringId(tiny_string(name,true)); - propName.ns.push_back(nsNameAndKind("",NAMESPACE)); + propName.ns.push_back(nsNameAndKind(getSystemState(),"",NAMESPACE)); _NR<ASObject> curValue=getVariableByMultiname(propName); if(!curValue.isNull()) { @@ -2164,17 +2164,17 @@ Array* arr=NULL; if(curValue->getObjectType()!=T_ARRAY) { - arr=Class<Array>::getInstanceS(); + arr=Class<Array>::getInstanceS(getSystemState()); arr->push(curValue); setVariableByMultiname(propName,arr,ASObject::CONST_NOT_ALLOWED); } else arr=Class<Array>::cast(curValue.getPtr()); - arr->push(_MR(Class<ASString>::getInstanceS(value))); + arr->push(_MR(abstract_s(getSystemState(),value))); } else - setVariableByMultiname(propName,Class<ASString>::getInstanceS(value),ASObject::CONST_NOT_ALLOWED); + setVariableByMultiname(propName,abstract_s(getSystemState(),value),ASObject::CONST_NOT_ALLOWED); g_free(name); g_free(value); @@ -2188,8 +2188,8 @@ void URLVariables::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_DYNAMIC_NOT_FINAL); - c->setDeclaredMethodByQName("decode","",Class<IFunction>::getFunction(decode),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("decode","",Class<IFunction>::getFunction(c->getSystemState(),decode),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); } void URLVariables::buildTraits(ASObject* o) @@ -2213,7 +2213,7 @@ { URLVariables* th=Class<URLVariables>::cast(obj); assert_and_throw(argslen==0); - return Class<ASString>::getInstanceS(th->toString_priv()); + return abstract_s(obj->getSystemState(),th->toString_priv()); } ASFUNCTIONBODY(URLVariables,_constructor) @@ -2308,7 +2308,7 @@ if(evaluationResult == SecurityManager::NA_CROSSDOMAIN_POLICY) { //TODO: find correct way of handling this case (SecurityErrorEvent in this case) - throw Class<SecurityError>::getInstanceS("SecurityError: sendToURL: " + throw Class<SecurityError>::getInstanceS(obj->getSystemState(),"SecurityError: sendToURL: " "connection to domain not allowed by securityManager"); } @@ -2360,7 +2360,7 @@ void Responder::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("onResult","",Class<IFunction>::getFunction(onResult),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("onResult","",Class<IFunction>::getFunction(c->getSystemState(),onResult),NORMAL_METHOD,true); } void Responder::finalize() @@ -2403,11 +2403,11 @@ void LocalConnection::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("allowDomain","",Class<IFunction>::getFunction(allowDomain),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("allowInsecureDomain","",Class<IFunction>::getFunction(allowInsecureDomain),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("send","",Class<IFunction>::getFunction(send),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("connect","",Class<IFunction>::getFunction(connect),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(close),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("allowDomain","",Class<IFunction>::getFunction(c->getSystemState(),allowDomain),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("allowInsecureDomain","",Class<IFunction>::getFunction(c->getSystemState(),allowInsecureDomain),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("send","",Class<IFunction>::getFunction(c->getSystemState(),send),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("connect","",Class<IFunction>::getFunction(c->getSystemState(),connect),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("close","",Class<IFunction>::getFunction(c->getSystemState(),close),NORMAL_METHOD,true); REGISTER_GETTER(c,isSupported); REGISTER_GETTER_SETTER(c,client); }
View file
lightspark.tar.xz/src/scripting/flash/printing/flashprinting.cpp
Changed
@@ -64,6 +64,6 @@ void PrintJobOrientation::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED| CLASS_FINAL); - c->setVariableByQName("LANDSCAPE","",Class<ASString>::getInstanceS("landscape"),CONSTANT_TRAIT); - c->setVariableByQName("PORTRAIT","",Class<ASString>::getInstanceS("portrait"),CONSTANT_TRAIT); + c->setVariableByQName("LANDSCAPE","",abstract_s(c->getSystemState(),"landscape"),CONSTANT_TRAIT); + c->setVariableByQName("PORTRAIT","",abstract_s(c->getSystemState(),"portrait"),CONSTANT_TRAIT); }
View file
lightspark.tar.xz/src/scripting/flash/sensors/flashsensors.cpp
Changed
@@ -35,7 +35,7 @@ { CLASS_SETUP_NO_CONSTRUCTOR(c, EventDispatcher, CLASS_SEALED); // properties - c->setDeclaredMethodByQName("isSupported", "", Class<IFunction>::getFunction(_isSupported),GETTER_METHOD,false); + c->setDeclaredMethodByQName("isSupported", "", Class<IFunction>::getFunction(c->getSystemState(),_isSupported),GETTER_METHOD,false); } void Accelerometer::buildTraits(ASObject *o) @@ -44,5 +44,5 @@ ASFUNCTIONBODY(Accelerometer,_isSupported) { - return abstract_b(false); + return abstract_b(getSys(),false); }
View file
lightspark.tar.xz/src/scripting/flash/system/flashsystem.cpp
Changed
@@ -43,20 +43,20 @@ void Capabilities::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_SEALED | CLASS_FINAL); - c->setDeclaredMethodByQName("language","",Class<IFunction>::getFunction(_getLanguage),GETTER_METHOD,false); - c->setDeclaredMethodByQName("playerType","",Class<IFunction>::getFunction(_getPlayerType),GETTER_METHOD,false); - c->setDeclaredMethodByQName("version","",Class<IFunction>::getFunction(_getVersion),GETTER_METHOD,false); - c->setDeclaredMethodByQName("cpuArchitecture","",Class<IFunction>::getFunction(_getCPUArchitecture),GETTER_METHOD,false); - c->setDeclaredMethodByQName("isDebugger","",Class<IFunction>::getFunction(_getIsDebugger),GETTER_METHOD,false); - c->setDeclaredMethodByQName("isEmbeddedInAcrobat","",Class<IFunction>::getFunction(_getIsEmbeddedInAcrobat),GETTER_METHOD,false); - c->setDeclaredMethodByQName("localFileReadDisable","",Class<IFunction>::getFunction(_getLocalFileReadDisable),GETTER_METHOD,false); - c->setDeclaredMethodByQName("manufacturer","",Class<IFunction>::getFunction(_getManufacturer),GETTER_METHOD,false); - c->setDeclaredMethodByQName("os","",Class<IFunction>::getFunction(_getOS),GETTER_METHOD,false); - c->setDeclaredMethodByQName("serverString","",Class<IFunction>::getFunction(_getServerString),GETTER_METHOD,false); - c->setDeclaredMethodByQName("screenResolutionX","",Class<IFunction>::getFunction(_getScreenResolutionX),GETTER_METHOD,false); - c->setDeclaredMethodByQName("screenResolutionY","",Class<IFunction>::getFunction(_getScreenResolutionY),GETTER_METHOD,false); - c->setDeclaredMethodByQName("hasAccessibility","",Class<IFunction>::getFunction(_getHasAccessibility),GETTER_METHOD,false); - c->setDeclaredMethodByQName("screenDPI","",Class<IFunction>::getFunction(_getScreenDPI),GETTER_METHOD,false); + c->setDeclaredMethodByQName("language","",Class<IFunction>::getFunction(c->getSystemState(),_getLanguage),GETTER_METHOD,false); + c->setDeclaredMethodByQName("playerType","",Class<IFunction>::getFunction(c->getSystemState(),_getPlayerType),GETTER_METHOD,false); + c->setDeclaredMethodByQName("version","",Class<IFunction>::getFunction(c->getSystemState(),_getVersion),GETTER_METHOD,false); + c->setDeclaredMethodByQName("cpuArchitecture","",Class<IFunction>::getFunction(c->getSystemState(),_getCPUArchitecture),GETTER_METHOD,false); + c->setDeclaredMethodByQName("isDebugger","",Class<IFunction>::getFunction(c->getSystemState(),_getIsDebugger),GETTER_METHOD,false); + c->setDeclaredMethodByQName("isEmbeddedInAcrobat","",Class<IFunction>::getFunction(c->getSystemState(),_getIsEmbeddedInAcrobat),GETTER_METHOD,false); + c->setDeclaredMethodByQName("localFileReadDisable","",Class<IFunction>::getFunction(c->getSystemState(),_getLocalFileReadDisable),GETTER_METHOD,false); + c->setDeclaredMethodByQName("manufacturer","",Class<IFunction>::getFunction(c->getSystemState(),_getManufacturer),GETTER_METHOD,false); + c->setDeclaredMethodByQName("os","",Class<IFunction>::getFunction(c->getSystemState(),_getOS),GETTER_METHOD,false); + c->setDeclaredMethodByQName("serverString","",Class<IFunction>::getFunction(c->getSystemState(),_getServerString),GETTER_METHOD,false); + c->setDeclaredMethodByQName("screenResolutionX","",Class<IFunction>::getFunction(c->getSystemState(),_getScreenResolutionX),GETTER_METHOD,false); + c->setDeclaredMethodByQName("screenResolutionY","",Class<IFunction>::getFunction(c->getSystemState(),_getScreenResolutionY),GETTER_METHOD,false); + c->setDeclaredMethodByQName("hasAccessibility","",Class<IFunction>::getFunction(c->getSystemState(),_getHasAccessibility),GETTER_METHOD,false); + c->setDeclaredMethodByQName("screenDPI","",Class<IFunction>::getFunction(c->getSystemState(),_getScreenDPI),GETTER_METHOD,false); } @@ -65,53 +65,53 @@ switch (getSys()->flashMode) { case SystemState::AVMPLUS: - return Class<ASString>::getInstanceS("AVMPlus"); + return abstract_s(getSys(),"AVMPlus"); case SystemState::AIR: - return Class<ASString>::getInstanceS("Desktop"); + return abstract_s(getSys(),"Desktop"); default: - return Class<ASString>::getInstanceS("PlugIn"); + return abstract_s(getSys(),"PlugIn"); } } ASFUNCTIONBODY(Capabilities,_getLanguage) { - return Class<ASString>::getInstanceS("en"); + return abstract_s(getSys(),"en"); } ASFUNCTIONBODY(Capabilities,_getCPUArchitecture) { LOG(LOG_NOT_IMPLEMENTED, "Capabilities.cpuArchitecture is not implemented"); - return Class<ASString>::getInstanceS("x86"); + return abstract_s(getSys(),"x86"); } ASFUNCTIONBODY(Capabilities,_getIsDebugger) { - return abstract_b(false); + return abstract_b(getSys(),false); } ASFUNCTIONBODY(Capabilities,_getIsEmbeddedInAcrobat) { - return abstract_b(false); + return abstract_b(getSys(),false); } ASFUNCTIONBODY(Capabilities,_getLocalFileReadDisable) { - return abstract_b(true); + return abstract_b(getSys(),true); } ASFUNCTIONBODY(Capabilities,_getManufacturer) { - return Class<ASString>::getInstanceS(MANUFACTURER); + return abstract_s(getSys(),MANUFACTURER); } ASFUNCTIONBODY(Capabilities,_getOS) { - return Class<ASString>::getInstanceS("Linux"); + return abstract_s(getSys(),"Linux"); } ASFUNCTIONBODY(Capabilities,_getVersion) { - return Class<ASString>::getInstanceS(EMULATED_VERSION); + return abstract_s(getSys(),EMULATED_VERSION); } ASFUNCTIONBODY(Capabilities,_getServerString) @@ -165,34 +165,34 @@ supports DTS-HD High Resolution Audio DTH supports DTS-HD Master Audio DTM */ - return Class<ASString>::getInstanceS(res); + return abstract_s(getSys(),res); } ASFUNCTIONBODY(Capabilities,_getScreenResolutionX) { GdkScreen* screen = gdk_screen_get_default(); gint width = gdk_screen_get_width (screen); - return abstract_d(width); + return abstract_d(obj->getSystemState(),width); } ASFUNCTIONBODY(Capabilities,_getScreenResolutionY) { GdkScreen* screen = gdk_screen_get_default(); gint height = gdk_screen_get_height (screen); - return abstract_d(height); + return abstract_d(obj->getSystemState(),height); } ASFUNCTIONBODY(Capabilities,_getHasAccessibility) { LOG(LOG_NOT_IMPLEMENTED,"hasAccessibility always returns false"); - return abstract_b(false); + return abstract_b(getSys(),false); } ASFUNCTIONBODY(Capabilities,_getScreenDPI) { GdkScreen* screen = gdk_screen_get_default(); gdouble dpi = gdk_screen_get_resolution (screen); - return abstract_d(dpi); + return abstract_d(obj->getSystemState(),dpi); } #define MIN_DOMAIN_MEMORY_LIMIT 1024 -ApplicationDomain::ApplicationDomain(Class_base* c, _NR<ApplicationDomain> p):ASObject(c),domainMemory(Class<ByteArray>::getInstanceS()),parentDomain(p) +ApplicationDomain::ApplicationDomain(Class_base* c, _NR<ApplicationDomain> p):ASObject(c),domainMemory(Class<ByteArray>::getInstanceS(c->getSystemState())),parentDomain(p) { domainMemory->setLength(MIN_DOMAIN_MEMORY_LIMIT); } @@ -201,11 +201,11 @@ { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); //Static - c->setDeclaredMethodByQName("currentDomain","",Class<IFunction>::getFunction(_getCurrentDomain),GETTER_METHOD,false); - c->setDeclaredMethodByQName("MIN_DOMAIN_MEMORY_LENGTH","",Class<IFunction>::getFunction(_getMinDomainMemoryLength),GETTER_METHOD,false); + c->setDeclaredMethodByQName("currentDomain","",Class<IFunction>::getFunction(c->getSystemState(),_getCurrentDomain),GETTER_METHOD,false); + c->setDeclaredMethodByQName("MIN_DOMAIN_MEMORY_LENGTH","",Class<IFunction>::getFunction(c->getSystemState(),_getMinDomainMemoryLength),GETTER_METHOD,false); //Instance - c->setDeclaredMethodByQName("hasDefinition","",Class<IFunction>::getFunction(hasDefinition),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getDefinition","",Class<IFunction>::getFunction(getDefinition),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("hasDefinition","",Class<IFunction>::getFunction(c->getSystemState(),hasDefinition),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getDefinition","",Class<IFunction>::getFunction(c->getSystemState(),getDefinition),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c,domainMemory); REGISTER_GETTER(c,parentDomain); } @@ -240,7 +240,7 @@ // C++ constructor return NULL; else if(parentDomain.isNull()) - th->parentDomain = getSys()->systemDomain; + th->parentDomain = obj->getSystemState()->systemDomain; else th->parentDomain = parentDomain; return NULL; @@ -248,12 +248,12 @@ ASFUNCTIONBODY(ApplicationDomain,_getMinDomainMemoryLength) { - return abstract_ui(MIN_DOMAIN_MEMORY_LIMIT); + return abstract_ui(obj->getSystemState(),MIN_DOMAIN_MEMORY_LIMIT); } ASFUNCTIONBODY(ApplicationDomain,_getCurrentDomain) { - _NR<ApplicationDomain> ret=ABCVm::getCurrentApplicationDomain(getVm()->currentCallContext); + _NR<ApplicationDomain> ret=ABCVm::getCurrentApplicationDomain(getVm(getSys())->currentCallContext); ret->incRef(); return ret.getPtr(); } @@ -271,20 +271,20 @@ tiny_string tmpName; stringToQName(tmp,tmpName,nsName); name.name_s_id=getSys()->getUniqueStringId(tmpName); - name.ns.push_back(nsNameAndKind(nsName,NAMESPACE)); + name.ns.push_back(nsNameAndKind(obj->getSystemState(),nsName,NAMESPACE)); LOG(LOG_CALLS,_("Looking for definition of ") << name); ASObject* target; ASObject* o=th->getVariableAndTargetByMultiname(name,target); if(o==NULL) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); else { if(o->getObjectType()!=T_CLASS) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); LOG(LOG_CALLS,_("Found definition for ") << name); - return abstract_b(true); + return abstract_b(obj->getSystemState(),true); } } @@ -301,13 +301,13 @@ tiny_string tmpName; stringToQName(tmp,tmpName,nsName); name.name_s_id=getSys()->getUniqueStringId(tmpName); - name.ns.push_back(nsNameAndKind(nsName,NAMESPACE)); + name.ns.push_back(nsNameAndKind(obj->getSystemState(),nsName,NAMESPACE)); LOG(LOG_CALLS,_("Looking for definition of ") << name); ASObject* target; ASObject* o=th->getVariableAndTargetByMultiname(name,target); if(o == NULL) - throwError<ReferenceError>(kClassNotFoundError,name.normalizedNameUnresolved()); + throwError<ReferenceError>(kClassNotFoundError,name.normalizedNameUnresolved(obj->getSystemState())); //TODO: specs says that also namespaces and function may be returned assert_and_throw(o->getObjectType()==T_CLASS); @@ -330,12 +330,12 @@ if(index==str.npos) //No dot { name.name_s_id=getSys()->getUniqueStringId(str); - name.ns.push_back(nsNameAndKind("",NAMESPACE)); //TODO: use ns kind + name.ns.push_back(nsNameAndKind(getSystemState(),"",NAMESPACE)); //TODO: use ns kind } else { name.name_s_id=getSys()->getUniqueStringId(str.substr(index+1)); - name.ns.push_back(nsNameAndKind(str.substr(0,index),NAMESPACE)); + name.ns.push_back(nsNameAndKind(getSystemState(),str.substr(0,index),NAMESPACE)); } return getVariableAndTargetByMultiname(name, target); } @@ -415,8 +415,8 @@ void LoaderContext::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("allowLoadBytesCodeExecution","",Class<IFunction>::getFunction(_getter_allowCodeImport),GETTER_METHOD,false); - c->setDeclaredMethodByQName("allowLoadBytesCodeExecution","",Class<IFunction>::getFunction(_setter_allowCodeImport),SETTER_METHOD,false); + c->setDeclaredMethodByQName("allowLoadBytesCodeExecution","",Class<IFunction>::getFunction(c->getSystemState(),_getter_allowCodeImport),GETTER_METHOD,false); + c->setDeclaredMethodByQName("allowLoadBytesCodeExecution","",Class<IFunction>::getFunction(c->getSystemState(),_setter_allowCodeImport),SETTER_METHOD,false); REGISTER_GETTER_SETTER(c, allowCodeImport); REGISTER_GETTER_SETTER(c, applicationDomain); REGISTER_GETTER_SETTER(c, checkPolicyFile); @@ -462,7 +462,7 @@ { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); //Static - c->setDeclaredMethodByQName("currentDomain","",Class<IFunction>::getFunction(_getCurrentDomain),GETTER_METHOD,false); + c->setDeclaredMethodByQName("currentDomain","",Class<IFunction>::getFunction(c->getSystemState(),_getCurrentDomain),GETTER_METHOD,false); } void SecurityDomain::buildTraits(ASObject* o) @@ -476,7 +476,7 @@ ASFUNCTIONBODY(SecurityDomain,_getCurrentDomain) { - _NR<SecurityDomain> ret=ABCVm::getCurrentSecurityDomain(getVm()->currentCallContext); + _NR<SecurityDomain> ret=ABCVm::getCurrentSecurityDomain(getVm(getSys())->currentCallContext); ret->incRef(); return ret.getPtr(); } @@ -485,37 +485,37 @@ { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_SEALED | CLASS_FINAL); //Fully static class - c->setDeclaredMethodByQName("exactSettings","",Class<IFunction>::getFunction(_getExactSettings),GETTER_METHOD,false); - c->setDeclaredMethodByQName("exactSettings","",Class<IFunction>::getFunction(_setExactSettings),SETTER_METHOD,false); - c->setDeclaredMethodByQName("sandboxType","",Class<IFunction>::getFunction(_getSandboxType),GETTER_METHOD,false); + c->setDeclaredMethodByQName("exactSettings","",Class<IFunction>::getFunction(c->getSystemState(),_getExactSettings),GETTER_METHOD,false); + c->setDeclaredMethodByQName("exactSettings","",Class<IFunction>::getFunction(c->getSystemState(),_setExactSettings),SETTER_METHOD,false); + c->setDeclaredMethodByQName("sandboxType","",Class<IFunction>::getFunction(c->getSystemState(),_getSandboxType),GETTER_METHOD,false); c->setVariableByQName("LOCAL_TRUSTED","", - Class<ASString>::getInstanceS(getSys()->securityManager->getSandboxName(SecurityManager::LOCAL_TRUSTED)),DECLARED_TRAIT); + abstract_s(c->getSystemState(),c->getSystemState()->securityManager->getSandboxName(SecurityManager::LOCAL_TRUSTED)),DECLARED_TRAIT); c->setVariableByQName("LOCAL_WITH_FILE","", - Class<ASString>::getInstanceS(getSys()->securityManager->getSandboxName(SecurityManager::LOCAL_WITH_FILE)),DECLARED_TRAIT); + abstract_s(c->getSystemState(),c->getSystemState()->securityManager->getSandboxName(SecurityManager::LOCAL_WITH_FILE)),DECLARED_TRAIT); c->setVariableByQName("LOCAL_WITH_NETWORK","", - Class<ASString>::getInstanceS(getSys()->securityManager->getSandboxName(SecurityManager::LOCAL_WITH_NETWORK)),DECLARED_TRAIT); + abstract_s(c->getSystemState(),c->getSystemState()->securityManager->getSandboxName(SecurityManager::LOCAL_WITH_NETWORK)),DECLARED_TRAIT); c->setVariableByQName("REMOTE","", - Class<ASString>::getInstanceS(getSys()->securityManager->getSandboxName(SecurityManager::REMOTE)),DECLARED_TRAIT); - c->setDeclaredMethodByQName("allowDomain","",Class<IFunction>::getFunction(allowDomain),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("allowInsecureDomain","",Class<IFunction>::getFunction(allowInsecureDomain),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("loadPolicyFile","",Class<IFunction>::getFunction(loadPolicyFile),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("showSettings","",Class<IFunction>::getFunction(showSettings),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("pageDomain","",Class<IFunction>::getFunction(pageDomain),GETTER_METHOD,false); + abstract_s(c->getSystemState(),c->getSystemState()->securityManager->getSandboxName(SecurityManager::REMOTE)),DECLARED_TRAIT); + c->setDeclaredMethodByQName("allowDomain","",Class<IFunction>::getFunction(c->getSystemState(),allowDomain),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("allowInsecureDomain","",Class<IFunction>::getFunction(c->getSystemState(),allowInsecureDomain),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("loadPolicyFile","",Class<IFunction>::getFunction(c->getSystemState(),loadPolicyFile),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("showSettings","",Class<IFunction>::getFunction(c->getSystemState(),showSettings),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("pageDomain","",Class<IFunction>::getFunction(c->getSystemState(),pageDomain),GETTER_METHOD,false); getSys()->securityManager->setExactSettings(true, false); } ASFUNCTIONBODY(Security,_getExactSettings) { - return abstract_b(getSys()->securityManager->getExactSettings()); + return abstract_b(getSys(),getSys()->securityManager->getExactSettings()); } ASFUNCTIONBODY(Security,_setExactSettings) { assert(args && argslen==1); - if(getSys()->securityManager->getExactSettingsLocked()) + if(args[0]->getSystemState()->securityManager->getExactSettingsLocked()) { - throw Class<SecurityError>::getInstanceS("SecurityError: Security.exactSettings already set"); + throw Class<SecurityError>::getInstanceS(args[0]->getSystemState(),"SecurityError: Security.exactSettings already set"); } getSys()->securityManager->setExactSettings(Boolean_concrete(args[0])); return NULL; @@ -524,13 +524,13 @@ ASFUNCTIONBODY(Security,_getSandboxType) { if(getSys()->securityManager->getSandboxType() == SecurityManager::REMOTE) - return Class<ASString>::getInstanceS(getSys()->securityManager->getSandboxName(SecurityManager::REMOTE)); + return abstract_s(getSys(),getSys()->securityManager->getSandboxName(SecurityManager::REMOTE)); else if(getSys()->securityManager->getSandboxType() == SecurityManager::LOCAL_TRUSTED) - return Class<ASString>::getInstanceS(getSys()->securityManager->getSandboxName(SecurityManager::LOCAL_TRUSTED)); + return abstract_s(getSys(),getSys()->securityManager->getSandboxName(SecurityManager::LOCAL_TRUSTED)); else if(getSys()->securityManager->getSandboxType() == SecurityManager::LOCAL_WITH_FILE) - return Class<ASString>::getInstanceS(getSys()->securityManager->getSandboxName(SecurityManager::LOCAL_WITH_FILE)); + return abstract_s(getSys(),getSys()->securityManager->getSandboxName(SecurityManager::LOCAL_WITH_FILE)); else if(getSys()->securityManager->getSandboxType() == SecurityManager::LOCAL_WITH_NETWORK) - return Class<ASString>::getInstanceS(getSys()->securityManager->getSandboxName(SecurityManager::LOCAL_WITH_NETWORK)); + return abstract_s(getSys(),getSys()->securityManager->getSandboxName(SecurityManager::LOCAL_WITH_NETWORK)); assert(false); return NULL; } @@ -565,7 +565,7 @@ ASFUNCTIONBODY(Security, pageDomain) { tiny_string s = getSys()->mainClip->getBaseURL().getProtocol()+"://"+getSys()->mainClip->getBaseURL().getHostname(); - return Class<ASString>::getInstanceS(s); + return abstract_s(getSys(),s); } ASFUNCTIONBODY(lightspark, fscommand) @@ -584,15 +584,15 @@ void System::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_SEALED | CLASS_FINAL); - c->setDeclaredMethodByQName("totalMemory","",Class<IFunction>::getFunction(totalMemory),GETTER_METHOD,false); - c->setDeclaredMethodByQName("disposeXML","",Class<IFunction>::getFunction(disposeXML),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("totalMemory","",Class<IFunction>::getFunction(c->getSystemState(),totalMemory),GETTER_METHOD,false); + c->setDeclaredMethodByQName("disposeXML","",Class<IFunction>::getFunction(c->getSystemState(),disposeXML),NORMAL_METHOD,false); } ASFUNCTIONBODY(System,totalMemory) { LOG(LOG_NOT_IMPLEMENTED, "System.totalMemory not implemented"); - return abstract_d(1024); + return abstract_d(obj->getSystemState(),1024); } ASFUNCTIONBODY(System,disposeXML) { @@ -619,24 +619,24 @@ void ASWorker::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructorNotInstantiatable, CLASS_SEALED | CLASS_FINAL); - c->setDeclaredMethodByQName("current","",Class<IFunction>::getFunction(_getCurrent),GETTER_METHOD,false); - c->setDeclaredMethodByQName("getSharedProperty","",Class<IFunction>::getFunction(getSharedProperty),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("current","",Class<IFunction>::getFunction(c->getSystemState(),_getCurrent),GETTER_METHOD,false); + c->setDeclaredMethodByQName("getSharedProperty","",Class<IFunction>::getFunction(c->getSystemState(),getSharedProperty),NORMAL_METHOD,true); } ASFUNCTIONBODY(ASWorker,_getCurrent) { LOG(LOG_NOT_IMPLEMENTED, "Worker not implemented"); - return Class<ASObject>::getInstanceS(); + return Class<ASObject>::getInstanceS(getSys()); } ASFUNCTIONBODY(ASWorker,getSharedProperty) { LOG(LOG_NOT_IMPLEMENTED, "Worker.getSharedProperty not implemented"); - return Class<ASObject>::getInstanceS(); + return Class<ASObject>::getInstanceS(getSys()); } void ImageDecodingPolicy::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("ON_DEMAND","",Class<ASString>::getInstanceS("onDemand"),CONSTANT_TRAIT); - c->setVariableByQName("ON_LOAD ","",Class<ASString>::getInstanceS("onLoad"),CONSTANT_TRAIT); + c->setVariableByQName("ON_DEMAND","",abstract_s(c->getSystemState(),"onDemand"),CONSTANT_TRAIT); + c->setVariableByQName("ON_LOAD ","",abstract_s(c->getSystemState(),"onLoad"),CONSTANT_TRAIT); }
View file
lightspark.tar.xz/src/scripting/flash/text/flashtext.cpp
Changed
@@ -32,15 +32,15 @@ void lightspark::AntiAliasType::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("ADVANCED","",Class<ASString>::getInstanceS("advanced"),DECLARED_TRAIT); - c->setVariableByQName("NORMAL","",Class<ASString>::getInstanceS("normal"),DECLARED_TRAIT); + c->setVariableByQName("ADVANCED","",abstract_s(c->getSystemState(),"advanced"),DECLARED_TRAIT); + c->setVariableByQName("NORMAL","",abstract_s(c->getSystemState(),"normal"),DECLARED_TRAIT); } void ASFont::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED); - c->setDeclaredMethodByQName("enumerateFonts","",Class<IFunction>::getFunction(enumerateFonts),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("registerFont","",Class<IFunction>::getFunction(registerFont),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("enumerateFonts","",Class<IFunction>::getFunction(c->getSystemState(),enumerateFonts),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("registerFont","",Class<IFunction>::getFunction(c->getSystemState(),registerFont),NORMAL_METHOD,false); REGISTER_GETTER(c,fontName); REGISTER_GETTER(c,fontStyle); @@ -74,7 +74,7 @@ if (enumerateDeviceFonts) LOG(LOG_NOT_IMPLEMENTED,"Font::enumerateFonts: flag enumerateDeviceFonts is not handled"); - Array* ret = Class<Array>::getInstanceS(); + Array* ret = Class<Array>::getInstanceS(getSys()); std::vector<ASObject*>* fontlist = getFontList(); for(auto i = fontlist->begin(); i != fontlist->end(); ++i) { @@ -110,48 +110,48 @@ CLASS_SETUP_NO_CONSTRUCTOR(c, InteractiveObject, CLASS_SEALED); // methods - c->setDeclaredMethodByQName("appendText","",Class<IFunction>::getFunction(TextField:: appendText),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getTextFormat","",Class<IFunction>::getFunction(_getTextFormat),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setTextFormat","",Class<IFunction>::getFunction(_setTextFormat),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getLineIndexAtPoint","",Class<IFunction>::getFunction(_getLineIndexAtPoint),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getLineIndexOfChar","",Class<IFunction>::getFunction(_getLineIndexOfChar),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getLineLength","",Class<IFunction>::getFunction(_getLineLength),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getLineMetrics","",Class<IFunction>::getFunction(_getLineMetrics),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getLineOffset","",Class<IFunction>::getFunction(_getLineOffset),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getLineText","",Class<IFunction>::getFunction(_getLineText),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("replaceSelectedText","",Class<IFunction>::getFunction(_replaceSelectedText),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("replaceText","",Class<IFunction>::getFunction(_replaceText),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setSelection","",Class<IFunction>::getFunction(_setSelection),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("appendText","",Class<IFunction>::getFunction(c->getSystemState(),TextField:: appendText),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getTextFormat","",Class<IFunction>::getFunction(c->getSystemState(),_getTextFormat),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setTextFormat","",Class<IFunction>::getFunction(c->getSystemState(),_setTextFormat),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getLineIndexAtPoint","",Class<IFunction>::getFunction(c->getSystemState(),_getLineIndexAtPoint),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getLineIndexOfChar","",Class<IFunction>::getFunction(c->getSystemState(),_getLineIndexOfChar),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getLineLength","",Class<IFunction>::getFunction(c->getSystemState(),_getLineLength),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getLineMetrics","",Class<IFunction>::getFunction(c->getSystemState(),_getLineMetrics),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getLineOffset","",Class<IFunction>::getFunction(c->getSystemState(),_getLineOffset),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getLineText","",Class<IFunction>::getFunction(c->getSystemState(),_getLineText),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("replaceSelectedText","",Class<IFunction>::getFunction(c->getSystemState(),_replaceSelectedText),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("replaceText","",Class<IFunction>::getFunction(c->getSystemState(),_replaceText),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setSelection","",Class<IFunction>::getFunction(c->getSystemState(),_setSelection),NORMAL_METHOD,true); // properties - c->setDeclaredMethodByQName("antiAliasType","",Class<IFunction>::getFunction(TextField::_getAntiAliasType),GETTER_METHOD,true); - c->setDeclaredMethodByQName("antiAliasType","",Class<IFunction>::getFunction(TextField::_setAntiAliasType),SETTER_METHOD,true); - c->setDeclaredMethodByQName("autoSize","",Class<IFunction>::getFunction(TextField::_setAutoSize),SETTER_METHOD,true); - c->setDeclaredMethodByQName("autoSize","",Class<IFunction>::getFunction(TextField::_getAutoSize),GETTER_METHOD,true); - c->setDeclaredMethodByQName("defaultTextFormat","",Class<IFunction>::getFunction(TextField::_getDefaultTextFormat),GETTER_METHOD,true); - c->setDeclaredMethodByQName("defaultTextFormat","",Class<IFunction>::getFunction(TextField::_setDefaultTextFormat),SETTER_METHOD,true); - c->setDeclaredMethodByQName("gridFitType","",Class<IFunction>::getFunction(TextField::_getGridFitType),GETTER_METHOD,true); - c->setDeclaredMethodByQName("gridFitType","",Class<IFunction>::getFunction(TextField::_setGridFitType),SETTER_METHOD,true); - c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(TextField::_getHeight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(TextField::_setHeight),SETTER_METHOD,true); - c->setDeclaredMethodByQName("htmlText","",Class<IFunction>::getFunction(TextField::_getHtmlText),GETTER_METHOD,true); - c->setDeclaredMethodByQName("htmlText","",Class<IFunction>::getFunction(TextField::_setHtmlText),SETTER_METHOD,true); - c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(TextField::_getLength),GETTER_METHOD,true); - c->setDeclaredMethodByQName("text","",Class<IFunction>::getFunction(TextField::_getText),GETTER_METHOD,true); - c->setDeclaredMethodByQName("text","",Class<IFunction>::getFunction(TextField::_setText),SETTER_METHOD,true); - c->setDeclaredMethodByQName("textHeight","",Class<IFunction>::getFunction(TextField::_getTextHeight),GETTER_METHOD,true); - c->setDeclaredMethodByQName("textWidth","",Class<IFunction>::getFunction(TextField::_getTextWidth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(TextField::_getWidth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(TextField::_setWidth),SETTER_METHOD,true); - c->setDeclaredMethodByQName("wordWrap","",Class<IFunction>::getFunction(TextField::_setWordWrap),SETTER_METHOD,true); - c->setDeclaredMethodByQName("wordWrap","",Class<IFunction>::getFunction(TextField::_getWordWrap),GETTER_METHOD,true); - c->setDeclaredMethodByQName("numLines","",Class<IFunction>::getFunction(TextField::_getNumLines),GETTER_METHOD,true); - c->setDeclaredMethodByQName("maxScrollH","",Class<IFunction>::getFunction(TextField::_getMaxScrollH),GETTER_METHOD,true); - c->setDeclaredMethodByQName("maxScrollV","",Class<IFunction>::getFunction(TextField::_getMaxScrollV),GETTER_METHOD,true); - c->setDeclaredMethodByQName("bottomScrollV","",Class<IFunction>::getFunction(TextField::_getBottomScrollV),GETTER_METHOD,true); - c->setDeclaredMethodByQName("restrict","",Class<IFunction>::getFunction(TextField::_getRestrict),GETTER_METHOD,true); - c->setDeclaredMethodByQName("restrict","",Class<IFunction>::getFunction(TextField::_setRestrict),SETTER_METHOD,true); - c->setDeclaredMethodByQName("textInteractionMode","",Class<IFunction>::getFunction(TextField::_getTextInteractionMode),GETTER_METHOD,true); + c->setDeclaredMethodByQName("antiAliasType","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getAntiAliasType),GETTER_METHOD,true); + c->setDeclaredMethodByQName("antiAliasType","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_setAntiAliasType),SETTER_METHOD,true); + c->setDeclaredMethodByQName("autoSize","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_setAutoSize),SETTER_METHOD,true); + c->setDeclaredMethodByQName("autoSize","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getAutoSize),GETTER_METHOD,true); + c->setDeclaredMethodByQName("defaultTextFormat","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getDefaultTextFormat),GETTER_METHOD,true); + c->setDeclaredMethodByQName("defaultTextFormat","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_setDefaultTextFormat),SETTER_METHOD,true); + c->setDeclaredMethodByQName("gridFitType","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getGridFitType),GETTER_METHOD,true); + c->setDeclaredMethodByQName("gridFitType","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_setGridFitType),SETTER_METHOD,true); + c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getHeight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("height","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_setHeight),SETTER_METHOD,true); + c->setDeclaredMethodByQName("htmlText","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getHtmlText),GETTER_METHOD,true); + c->setDeclaredMethodByQName("htmlText","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_setHtmlText),SETTER_METHOD,true); + c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getLength),GETTER_METHOD,true); + c->setDeclaredMethodByQName("text","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getText),GETTER_METHOD,true); + c->setDeclaredMethodByQName("text","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_setText),SETTER_METHOD,true); + c->setDeclaredMethodByQName("textHeight","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getTextHeight),GETTER_METHOD,true); + c->setDeclaredMethodByQName("textWidth","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getTextWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("width","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_setWidth),SETTER_METHOD,true); + c->setDeclaredMethodByQName("wordWrap","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_setWordWrap),SETTER_METHOD,true); + c->setDeclaredMethodByQName("wordWrap","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getWordWrap),GETTER_METHOD,true); + c->setDeclaredMethodByQName("numLines","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getNumLines),GETTER_METHOD,true); + c->setDeclaredMethodByQName("maxScrollH","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getMaxScrollH),GETTER_METHOD,true); + c->setDeclaredMethodByQName("maxScrollV","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getMaxScrollV),GETTER_METHOD,true); + c->setDeclaredMethodByQName("bottomScrollV","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getBottomScrollV),GETTER_METHOD,true); + c->setDeclaredMethodByQName("restrict","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getRestrict),GETTER_METHOD,true); + c->setDeclaredMethodByQName("restrict","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_setRestrict),SETTER_METHOD,true); + c->setDeclaredMethodByQName("textInteractionMode","",Class<IFunction>::getFunction(c->getSystemState(),TextField::_getTextInteractionMode),GETTER_METHOD,true); REGISTER_GETTER_SETTER(c, alwaysShowSelection); REGISTER_GETTER_SETTER(c, background); @@ -238,7 +238,7 @@ ASFUNCTIONBODY(TextField,_getWordWrap) { TextField* th=Class<TextField>::cast(obj); - return abstract_b(th->wordWrap); + return abstract_b(obj->getSystemState(),th->wordWrap); } ASFUNCTIONBODY(TextField,_setWordWrap) @@ -257,13 +257,13 @@ switch(th->autoSize) { case AS_NONE: - return Class<ASString>::getInstanceS("none"); + return abstract_s(obj->getSystemState(),"none"); case AS_LEFT: - return Class<ASString>::getInstanceS("left"); + return abstract_s(obj->getSystemState(),"left"); case AS_RIGHT: - return Class<ASString>::getInstanceS("right"); + return abstract_s(obj->getSystemState(),"right"); case AS_CENTER: - return Class<ASString>::getInstanceS("center"); + return abstract_s(obj->getSystemState(),"center"); } return NULL; } @@ -327,7 +327,7 @@ ASFUNCTIONBODY(TextField,_getWidth) { TextField* th=Class<TextField>::cast(obj); - return abstract_i(th->width); + return abstract_i(obj->getSystemState(),th->width); } ASFUNCTIONBODY(TextField,_setWidth) @@ -349,7 +349,7 @@ ASFUNCTIONBODY(TextField,_getHeight) { TextField* th=Class<TextField>::cast(obj); - return abstract_i(th->height); + return abstract_i(obj->getSystemState(),th->height); } ASFUNCTIONBODY(TextField,_setHeight) @@ -371,19 +371,19 @@ ASFUNCTIONBODY(TextField,_getTextWidth) { TextField* th=Class<TextField>::cast(obj); - return abstract_i(th->textWidth); + return abstract_i(obj->getSystemState(),th->textWidth); } ASFUNCTIONBODY(TextField,_getTextHeight) { TextField* th=Class<TextField>::cast(obj); - return abstract_i(th->textHeight); + return abstract_i(obj->getSystemState(),th->textHeight); } ASFUNCTIONBODY(TextField,_getHtmlText) { TextField* th=Class<TextField>::cast(obj); - return Class<ASString>::getInstanceS(th->toHtmlText()); + return abstract_s(obj->getSystemState(),th->toHtmlText()); } ASFUNCTIONBODY(TextField,_setHtmlText) @@ -398,7 +398,7 @@ ASFUNCTIONBODY(TextField,_getText) { TextField* th=Class<TextField>::cast(obj); - return Class<ASString>::getInstanceS(th->text); + return abstract_s(obj->getSystemState(),th->text); } ASFUNCTIONBODY(TextField,_setText) @@ -420,9 +420,9 @@ ASFUNCTIONBODY(TextField,_getTextFormat) { TextField* th=Class<TextField>::cast(obj); - TextFormat *format=Class<TextFormat>::getInstanceS(); + TextFormat *format=Class<TextFormat>::getInstanceS(obj->getSystemState()); - format->color=_MNR(abstract_ui(th->textColor.toUInt())); + format->color=_MNR(abstract_ui(obj->getSystemState(),th->textColor.toUInt())); format->font = th->font; format->size = th->fontSize; @@ -457,7 +457,7 @@ { TextField* th=Class<TextField>::cast(obj); - TextFormat* tf = Class<TextFormat>::getInstanceS(); + TextFormat* tf = Class<TextFormat>::getInstanceS(obj->getSystemState()); tf->font = th->font; LOG(LOG_NOT_IMPLEMENTED,"getDefaultTextFormat does not get all fields of TextFormat"); return tf; @@ -483,9 +483,9 @@ { TextField* th=Class<TextField>::cast(obj); if (th->type == ET_READ_ONLY) - return Class<ASString>::getInstanceS("dynamic"); + return abstract_s(obj->getSystemState(),"dynamic"); else - return Class<ASString>::getInstanceS("input"); + return abstract_s(obj->getSystemState(),"input"); } ASFUNCTIONBODY(TextField, _setter_type) @@ -519,10 +519,10 @@ { if (x > it->extents.Xmin && x <= it->extents.Xmax && y > it->extents.Ymin && y <= it->extents.Ymax) - return abstract_i(i); + return abstract_i(obj->getSystemState(),i); } - return abstract_i(-1); + return abstract_i(obj->getSystemState(),-1); } ASFUNCTIONBODY(TextField,_getLineIndexOfChar) @@ -532,7 +532,7 @@ ARG_UNPACK(charIndex); if (charIndex < 0) - return abstract_i(-1); + return abstract_i(obj->getSystemState(),-1); std::vector<LineData> lines = CairoPangoRenderer::getLineData(*th); std::vector<LineData>::const_iterator it; @@ -541,12 +541,12 @@ { if (charIndex >= it->firstCharOffset && charIndex < it->firstCharOffset + it->length) - return abstract_i(i); + return abstract_i(obj->getSystemState(),i); } // testing shows that returns -1 on invalid index instead of // throwing RangeError - return abstract_i(-1); + return abstract_i(obj->getSystemState(),-1); } ASFUNCTIONBODY(TextField,_getLineLength) @@ -559,7 +559,7 @@ if (lineIndex < 0 || lineIndex >= (int32_t)lines.size()) throwError<RangeError>(kParamRangeError); - return abstract_i(lines[lineIndex].length); + return abstract_i(obj->getSystemState(),lines[lineIndex].length); } ASFUNCTIONBODY(TextField,_getLineMetrics) @@ -572,7 +572,7 @@ if (lineIndex < 0 || lineIndex >= (int32_t)lines.size()) throwError<RangeError>(kParamRangeError); - return Class<TextLineMetrics>::getInstanceS( + return Class<TextLineMetrics>::getInstanceS(obj->getSystemState(), lines[lineIndex].indent, lines[lineIndex].extents.Xmax - lines[lineIndex].extents.Xmin, lines[lineIndex].extents.Ymax - lines[lineIndex].extents.Ymin, @@ -591,7 +591,7 @@ if (lineIndex < 0 || lineIndex >= (int32_t)lines.size()) throwError<RangeError>(kParamRangeError); - return abstract_i(lines[lineIndex].firstCharOffset); + return abstract_i(obj->getSystemState(),lines[lineIndex].firstCharOffset); } ASFUNCTIONBODY(TextField,_getLineText) @@ -606,16 +606,16 @@ tiny_string substr = th->text.substr(lines[lineIndex].firstCharOffset, lines[lineIndex].length); - return Class<ASString>::getInstanceS(substr); + return abstract_s(obj->getSystemState(),substr); } ASFUNCTIONBODY(TextField,_getAntiAliasType) { TextField* th=Class<TextField>::cast(obj); if (th->antiAliasType == AA_NORMAL) - return Class<ASString>::getInstanceS("normal"); + return abstract_s(obj->getSystemState(),"normal"); else - return Class<ASString>::getInstanceS("advanced"); + return abstract_s(obj->getSystemState(),"advanced"); } ASFUNCTIONBODY(TextField,_setAntiAliasType) @@ -640,11 +640,11 @@ { TextField* th=Class<TextField>::cast(obj); if (th->gridFitType == GF_NONE) - return Class<ASString>::getInstanceS("none"); + return abstract_s(obj->getSystemState(),"none"); else if (th->gridFitType == GF_PIXEL) - return Class<ASString>::getInstanceS("pixel"); + return abstract_s(obj->getSystemState(),"pixel"); else - return Class<ASString>::getInstanceS("subpixel"); + return abstract_s(obj->getSystemState(),"subpixel"); } ASFUNCTIONBODY(TextField,_setGridFitType) @@ -668,25 +668,25 @@ ASFUNCTIONBODY(TextField,_getLength) { TextField* th=Class<TextField>::cast(obj); - return abstract_i(th->text.numChars()); + return abstract_i(obj->getSystemState(),th->text.numChars()); } ASFUNCTIONBODY(TextField,_getNumLines) { TextField* th=Class<TextField>::cast(obj); - return abstract_i(CairoPangoRenderer::getLineData(*th).size()); + return abstract_i(obj->getSystemState(),CairoPangoRenderer::getLineData(*th).size()); } ASFUNCTIONBODY(TextField,_getMaxScrollH) { TextField* th=Class<TextField>::cast(obj); - return abstract_i(th->getMaxScrollH()); + return abstract_i(obj->getSystemState(),th->getMaxScrollH()); } ASFUNCTIONBODY(TextField,_getMaxScrollV) { TextField* th=Class<TextField>::cast(obj); - return abstract_i(th->getMaxScrollV()); + return abstract_i(obj->getSystemState(),th->getMaxScrollV()); } ASFUNCTIONBODY(TextField,_getBottomScrollV) @@ -696,10 +696,10 @@ for (unsigned int k=0; k<lines.size()-1; k++) { if (lines[k+1].extents.Ymin >= (int)th->height) - return abstract_i(k + 1); + return abstract_i(obj->getSystemState(),k + 1); } - return abstract_i(lines.size() + 1); + return abstract_i(obj->getSystemState(),lines.size() + 1); } ASFUNCTIONBODY(TextField,_getRestrict) @@ -727,9 +727,9 @@ { TextField* th=Class<TextField>::cast(obj); if (th->textInteractionMode == TI_NORMAL) - return Class<ASString>::getInstanceS("normal"); + return abstract_s(obj->getSystemState(),"normal"); else - return Class<ASString>::getInstanceS("selection"); + return abstract_s(obj->getSystemState(),"selection"); } ASFUNCTIONBODY(TextField,_setSelection) @@ -777,7 +777,7 @@ void TextField::replaceText(unsigned int begin, unsigned int end, const tiny_string& newText) { if (!styleSheet.isNull()) - throw Class<ASError>::getInstanceS("Can not replace text on text field with a style sheet"); + throw Class<ASError>::getInstanceS(getSystemState(),"Can not replace text on text field with a style sheet"); if (begin >= text.numChars()) { @@ -1132,28 +1132,28 @@ void TextFieldAutoSize::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("CENTER","",Class<ASString>::getInstanceS("center"),DECLARED_TRAIT); - c->setVariableByQName("LEFT","",Class<ASString>::getInstanceS("left"),DECLARED_TRAIT); - c->setVariableByQName("NONE","",Class<ASString>::getInstanceS("none"),DECLARED_TRAIT); - c->setVariableByQName("RIGHT","",Class<ASString>::getInstanceS("right"),DECLARED_TRAIT); + c->setVariableByQName("CENTER","",abstract_s(c->getSystemState(),"center"),DECLARED_TRAIT); + c->setVariableByQName("LEFT","",abstract_s(c->getSystemState(),"left"),DECLARED_TRAIT); + c->setVariableByQName("NONE","",abstract_s(c->getSystemState(),"none"),DECLARED_TRAIT); + c->setVariableByQName("RIGHT","",abstract_s(c->getSystemState(),"right"),DECLARED_TRAIT); } void TextFieldType::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("DYNAMIC","",Class<ASString>::getInstanceS("dynamic"),DECLARED_TRAIT); - c->setVariableByQName("INPUT","",Class<ASString>::getInstanceS("input"),DECLARED_TRAIT); + c->setVariableByQName("DYNAMIC","",abstract_s(c->getSystemState(),"dynamic"),DECLARED_TRAIT); + c->setVariableByQName("INPUT","",abstract_s(c->getSystemState(),"input"),DECLARED_TRAIT); } void TextFormatAlign::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("CENTER","",Class<ASString>::getInstanceS("center"),DECLARED_TRAIT); - c->setVariableByQName("END","",Class<ASString>::getInstanceS("end"),DECLARED_TRAIT); - c->setVariableByQName("JUSTIFY","",Class<ASString>::getInstanceS("justify"),DECLARED_TRAIT); - c->setVariableByQName("LEFT","",Class<ASString>::getInstanceS("left"),DECLARED_TRAIT); - c->setVariableByQName("RIGHT","",Class<ASString>::getInstanceS("right"),DECLARED_TRAIT); - c->setVariableByQName("START","",Class<ASString>::getInstanceS("start"),DECLARED_TRAIT); + c->setVariableByQName("CENTER","",abstract_s(c->getSystemState(),"center"),DECLARED_TRAIT); + c->setVariableByQName("END","",abstract_s(c->getSystemState(),"end"),DECLARED_TRAIT); + c->setVariableByQName("JUSTIFY","",abstract_s(c->getSystemState(),"justify"),DECLARED_TRAIT); + c->setVariableByQName("LEFT","",abstract_s(c->getSystemState(),"left"),DECLARED_TRAIT); + c->setVariableByQName("RIGHT","",abstract_s(c->getSystemState(),"right"),DECLARED_TRAIT); + c->setVariableByQName("START","",abstract_s(c->getSystemState(),"start"),DECLARED_TRAIT); } void TextFormat::sinit(Class_base* c) @@ -1258,9 +1258,9 @@ void StyleSheet::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, EventDispatcher, CLASS_DYNAMIC_NOT_FINAL); - c->setDeclaredMethodByQName("styleNames","",Class<IFunction>::getFunction(_getStyleNames),GETTER_METHOD,true); - c->setDeclaredMethodByQName("setStyle","",Class<IFunction>::getFunction(setStyle),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getStyle","",Class<IFunction>::getFunction(getStyle),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("styleNames","",Class<IFunction>::getFunction(c->getSystemState(),_getStyleNames),GETTER_METHOD,true); + c->setDeclaredMethodByQName("setStyle","",Class<IFunction>::getFunction(c->getSystemState(),setStyle),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getStyle","",Class<IFunction>::getFunction(c->getSystemState(),getStyle),NORMAL_METHOD,true); } void StyleSheet::buildTraits(ASObject* o) @@ -1298,7 +1298,7 @@ { // Tested behaviour is to return an empty ASObject // instead of Null as is said in the documentation - return Class<ASObject>::getInstanceS(); + return Class<ASObject>::getInstanceS(obj->getSystemState()); } return NULL; } @@ -1307,10 +1307,10 @@ { StyleSheet* th=Class<StyleSheet>::cast(obj); assert_and_throw(argslen==0); - Array* ret=Class<Array>::getInstanceS(); + Array* ret=Class<Array>::getInstanceS(obj->getSystemState()); map<tiny_string, _R<ASObject>>::const_iterator it=th->styles.begin(); for(;it!=th->styles.end();++it) - ret->push(_MR(Class<ASString>::getInstanceS(it->first))); + ret->push(_MR(abstract_s(obj->getSystemState(),it->first))); return ret; } @@ -1320,60 +1320,60 @@ // _constructorNotInstantiatable but that breaks when // DisplayObjectContainer::initFrame calls the constructor CLASS_SETUP_NO_CONSTRUCTOR(c, DisplayObject, CLASS_FINAL | CLASS_SEALED); - c->setDeclaredMethodByQName("text","",Class<IFunction>::getFunction(_getText),GETTER_METHOD,true); + c->setDeclaredMethodByQName("text","",Class<IFunction>::getFunction(c->getSystemState(),_getText),GETTER_METHOD,true); } ASFUNCTIONBODY(StaticText,_getText) { LOG(LOG_NOT_IMPLEMENTED,"flash.display.StaticText.text is not implemented"); - return Class<ASString>::getInstanceS(""); + return abstract_s(getSys(),""); } void FontStyle::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("BOLD","",Class<ASString>::getInstanceS("bold"),DECLARED_TRAIT); - c->setVariableByQName("BOLD_ITALIC","",Class<ASString>::getInstanceS("boldItalic"),DECLARED_TRAIT); - c->setVariableByQName("ITALIC","",Class<ASString>::getInstanceS("italic"),DECLARED_TRAIT); - c->setVariableByQName("REGULAR","",Class<ASString>::getInstanceS("regular"),DECLARED_TRAIT); + c->setVariableByQName("BOLD","",abstract_s(c->getSystemState(),"bold"),DECLARED_TRAIT); + c->setVariableByQName("BOLD_ITALIC","",abstract_s(c->getSystemState(),"boldItalic"),DECLARED_TRAIT); + c->setVariableByQName("ITALIC","",abstract_s(c->getSystemState(),"italic"),DECLARED_TRAIT); + c->setVariableByQName("REGULAR","",abstract_s(c->getSystemState(),"regular"),DECLARED_TRAIT); } void FontType::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("DEVICE","",Class<ASString>::getInstanceS("device"),DECLARED_TRAIT); - c->setVariableByQName("EMBEDDED","",Class<ASString>::getInstanceS("embedded"),DECLARED_TRAIT); - c->setVariableByQName("EMBEDDED_CFF","",Class<ASString>::getInstanceS("embeddedCFF"),DECLARED_TRAIT); + c->setVariableByQName("DEVICE","",abstract_s(c->getSystemState(),"device"),DECLARED_TRAIT); + c->setVariableByQName("EMBEDDED","",abstract_s(c->getSystemState(),"embedded"),DECLARED_TRAIT); + c->setVariableByQName("EMBEDDED_CFF","",abstract_s(c->getSystemState(),"embeddedCFF"),DECLARED_TRAIT); } void TextDisplayMode::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("CRT","",Class<ASString>::getInstanceS("crt"),DECLARED_TRAIT); - c->setVariableByQName("DEFAULT","",Class<ASString>::getInstanceS("default"),DECLARED_TRAIT); - c->setVariableByQName("LCD","",Class<ASString>::getInstanceS("lcd"),DECLARED_TRAIT); + c->setVariableByQName("CRT","",abstract_s(c->getSystemState(),"crt"),DECLARED_TRAIT); + c->setVariableByQName("DEFAULT","",abstract_s(c->getSystemState(),"default"),DECLARED_TRAIT); + c->setVariableByQName("LCD","",abstract_s(c->getSystemState(),"lcd"),DECLARED_TRAIT); } void TextColorType::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("DARK_COLOR","",Class<ASString>::getInstanceS("dark"),DECLARED_TRAIT); - c->setVariableByQName("LIGHT_COLOR","",Class<ASString>::getInstanceS("light"),DECLARED_TRAIT); + c->setVariableByQName("DARK_COLOR","",abstract_s(c->getSystemState(),"dark"),DECLARED_TRAIT); + c->setVariableByQName("LIGHT_COLOR","",abstract_s(c->getSystemState(),"light"),DECLARED_TRAIT); } void GridFitType::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("NONE","",Class<ASString>::getInstanceS("none"),DECLARED_TRAIT); - c->setVariableByQName("PIXEL","",Class<ASString>::getInstanceS("pixel"),DECLARED_TRAIT); - c->setVariableByQName("SUBPIXEL","",Class<ASString>::getInstanceS("subpixel"),DECLARED_TRAIT); + c->setVariableByQName("NONE","",abstract_s(c->getSystemState(),"none"),DECLARED_TRAIT); + c->setVariableByQName("PIXEL","",abstract_s(c->getSystemState(),"pixel"),DECLARED_TRAIT); + c->setVariableByQName("SUBPIXEL","",abstract_s(c->getSystemState(),"subpixel"),DECLARED_TRAIT); } void TextInteractionMode::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("NORMAL","",Class<ASString>::getInstanceS("normal"),DECLARED_TRAIT); - c->setVariableByQName("SELECTION","",Class<ASString>::getInstanceS("selection"),DECLARED_TRAIT); + c->setVariableByQName("NORMAL","",abstract_s(c->getSystemState(),"normal"),DECLARED_TRAIT); + c->setVariableByQName("SELECTION","",abstract_s(c->getSystemState(),"selection"),DECLARED_TRAIT); } void TextLineMetrics::sinit(Class_base* c)
View file
lightspark.tar.xz/src/scripting/flash/text/flashtextengine.cpp
Changed
@@ -60,8 +60,8 @@ void ElementFormat::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("GRAPHIC_ELEMENT","",abstract_ui(0xFDEF),CONSTANT_TRAIT); - c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(_clone),NORMAL_METHOD,true); + c->setVariableByQName("GRAPHIC_ELEMENT","",abstract_ui(c->getSystemState(),0xFDEF),CONSTANT_TRAIT); + c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(c->getSystemState(),_clone),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c,alignmentBaseline); REGISTER_GETTER_SETTER(c,alpha); @@ -114,7 +114,7 @@ { ElementFormat* th=static_cast<ElementFormat*>(obj); - ElementFormat* newformat = Class<ElementFormat>::getInstanceS(); + ElementFormat* newformat = Class<ElementFormat>::getInstanceS(obj->getSystemState()); newformat->fontDescription = th->fontDescription; newformat->fontSize = th->fontSize; newformat->color = th->color; @@ -139,14 +139,14 @@ void FontLookup::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("DEVICE","",Class<ASString>::getInstanceS("device"),CONSTANT_TRAIT); - c->setVariableByQName("EMBEDDED_CFF","",Class<ASString>::getInstanceS("embeddedCFF"),CONSTANT_TRAIT); + c->setVariableByQName("DEVICE","",abstract_s(c->getSystemState(),"device"),CONSTANT_TRAIT); + c->setVariableByQName("EMBEDDED_CFF","",abstract_s(c->getSystemState(),"embeddedCFF"),CONSTANT_TRAIT); } void FontDescription::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL | CLASS_SEALED); - c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(_clone),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("clone","",Class<IFunction>::getFunction(c->getSystemState(),_clone),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c,cffHinting); REGISTER_GETTER_SETTER(c,fontLookup); REGISTER_GETTER_SETTER(c,fontName); @@ -173,7 +173,7 @@ { FontDescription* th=static_cast<FontDescription*>(obj); - FontDescription* newfontdescription = Class<FontDescription>::getInstanceS(); + FontDescription* newfontdescription = Class<FontDescription>::getInstanceS(obj->getSystemState()); newfontdescription->cffHinting = th->cffHinting; newfontdescription->fontLookup = th->fontLookup; newfontdescription->fontName = th->fontName; @@ -187,14 +187,14 @@ void FontPosture::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("ITALIC","",Class<ASString>::getInstanceS("italic"),CONSTANT_TRAIT); - c->setVariableByQName("NORMAL","",Class<ASString>::getInstanceS("normal"),CONSTANT_TRAIT); + c->setVariableByQName("ITALIC","",abstract_s(c->getSystemState(),"italic"),CONSTANT_TRAIT); + c->setVariableByQName("NORMAL","",abstract_s(c->getSystemState(),"normal"),CONSTANT_TRAIT); } void FontWeight::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("BOLD","",Class<ASString>::getInstanceS("bold"),CONSTANT_TRAIT); - c->setVariableByQName("NORMAL","",Class<ASString>::getInstanceS("normal"),CONSTANT_TRAIT); + c->setVariableByQName("BOLD","",abstract_s(c->getSystemState(),"bold"),CONSTANT_TRAIT); + c->setVariableByQName("NORMAL","",abstract_s(c->getSystemState(),"normal"),CONSTANT_TRAIT); } void FontMetrics::sinit(Class_base* c) @@ -211,29 +211,29 @@ void Kerning::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("AUTO","",Class<ASString>::getInstanceS("auto"),CONSTANT_TRAIT); - c->setVariableByQName("OFF","",Class<ASString>::getInstanceS("off"),CONSTANT_TRAIT); - c->setVariableByQName("ON","",Class<ASString>::getInstanceS("on"),CONSTANT_TRAIT); + c->setVariableByQName("AUTO","",abstract_s(c->getSystemState(),"auto"),CONSTANT_TRAIT); + c->setVariableByQName("OFF","",abstract_s(c->getSystemState(),"off"),CONSTANT_TRAIT); + c->setVariableByQName("ON","",abstract_s(c->getSystemState(),"on"),CONSTANT_TRAIT); } void LineJustification::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("ALL_BUT_LAST","",Class<ASString>::getInstanceS("allButLast"),CONSTANT_TRAIT); - c->setVariableByQName("ALL_BUT_MANDATORY_BREAK","",Class<ASString>::getInstanceS("allButMandatoryBreak"),CONSTANT_TRAIT); - c->setVariableByQName("ALL_INCLUDING_LAST","",Class<ASString>::getInstanceS("allIncludingLast"),CONSTANT_TRAIT); - c->setVariableByQName("UNJUSTIFIED","",Class<ASString>::getInstanceS("unjustified"),CONSTANT_TRAIT); + c->setVariableByQName("ALL_BUT_LAST","",abstract_s(c->getSystemState(),"allButLast"),CONSTANT_TRAIT); + c->setVariableByQName("ALL_BUT_MANDATORY_BREAK","",abstract_s(c->getSystemState(),"allButMandatoryBreak"),CONSTANT_TRAIT); + c->setVariableByQName("ALL_INCLUDING_LAST","",abstract_s(c->getSystemState(),"allIncludingLast"),CONSTANT_TRAIT); + c->setVariableByQName("UNJUSTIFIED","",abstract_s(c->getSystemState(),"unjustified"),CONSTANT_TRAIT); } void TextBaseline::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("ASCENT","",Class<ASString>::getInstanceS("ascent"),CONSTANT_TRAIT); - c->setVariableByQName("DESCENT","",Class<ASString>::getInstanceS("descent"),CONSTANT_TRAIT); - c->setVariableByQName("IDEOGRAPHIC_BOTTOM","",Class<ASString>::getInstanceS("ideographicBottom"),CONSTANT_TRAIT); - c->setVariableByQName("IDEOGRAPHIC_CENTER","",Class<ASString>::getInstanceS("ideographicCenter"),CONSTANT_TRAIT); - c->setVariableByQName("IDEOGRAPHIC_TOP","",Class<ASString>::getInstanceS("ideographicTop"),CONSTANT_TRAIT); - c->setVariableByQName("ROMAN","",Class<ASString>::getInstanceS("roman"),CONSTANT_TRAIT); - c->setVariableByQName("USE_DOMINANT_BASELINE","",Class<ASString>::getInstanceS("useDominantBaseline"),CONSTANT_TRAIT); + c->setVariableByQName("ASCENT","",abstract_s(c->getSystemState(),"ascent"),CONSTANT_TRAIT); + c->setVariableByQName("DESCENT","",abstract_s(c->getSystemState(),"descent"),CONSTANT_TRAIT); + c->setVariableByQName("IDEOGRAPHIC_BOTTOM","",abstract_s(c->getSystemState(),"ideographicBottom"),CONSTANT_TRAIT); + c->setVariableByQName("IDEOGRAPHIC_CENTER","",abstract_s(c->getSystemState(),"ideographicCenter"),CONSTANT_TRAIT); + c->setVariableByQName("IDEOGRAPHIC_TOP","",abstract_s(c->getSystemState(),"ideographicTop"),CONSTANT_TRAIT); + c->setVariableByQName("ROMAN","",abstract_s(c->getSystemState(),"roman"),CONSTANT_TRAIT); + c->setVariableByQName("USE_DOMINANT_BASELINE","",abstract_s(c->getSystemState(),"useDominantBaseline"),CONSTANT_TRAIT); } void TextJustifier::sinit(Class_base* c) @@ -273,9 +273,9 @@ void TextBlock::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL | CLASS_SEALED); - c->setDeclaredMethodByQName("createTextLine","",Class<IFunction>::getFunction(createTextLine),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("recreateTextLine","",Class<IFunction>::getFunction(recreateTextLine),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("releaseLines","",Class<IFunction>::getFunction(releaseLines),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("createTextLine","",Class<IFunction>::getFunction(c->getSystemState(),createTextLine),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("recreateTextLine","",Class<IFunction>::getFunction(c->getSystemState(),recreateTextLine),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("releaseLines","",Class<IFunction>::getFunction(c->getSystemState(),releaseLines),NORMAL_METHOD,true); REGISTER_GETTER(c, firstLine); REGISTER_GETTER(c, lastLine); REGISTER_GETTER_SETTER(c, content); @@ -326,7 +326,7 @@ LOG(LOG_NOT_IMPLEMENTED,"splitting textblock in multiple lines not implemented"); th->content->as<TextElement>()->text = ""; th->incRef(); - _NR<TextLine> textLine = _NR<TextLine>(Class<TextLine>::getInstanceS(linetext, _MNR(th))); + _NR<TextLine> textLine = _NR<TextLine>(Class<TextLine>::getInstanceS(obj->getSystemState(),linetext, _MNR(th))); textLine->width = (uint32_t)width; textLine->previousLine = previousLine; textLine->updateSizes(); @@ -485,11 +485,11 @@ void TextLine::sinit(Class_base* c) { CLASS_SETUP(c, DisplayObjectContainer, _constructor, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("MAX_LINE_WIDTH","",abstract_ui(MAX_LINE_WIDTH),CONSTANT_TRAIT); - c->setDeclaredMethodByQName("descent","",Class<IFunction>::getFunction(getDescent),GETTER_METHOD,true); - c->setDeclaredMethodByQName("ascent","",Class<IFunction>::getFunction(getAscent),GETTER_METHOD,true); - c->setDeclaredMethodByQName("textWidth","",Class<IFunction>::getFunction(getTextWidth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("textHeight","",Class<IFunction>::getFunction(getTextHeight),GETTER_METHOD,true); + c->setVariableByQName("MAX_LINE_WIDTH","",abstract_ui(c->getSystemState(),MAX_LINE_WIDTH),CONSTANT_TRAIT); + c->setDeclaredMethodByQName("descent","",Class<IFunction>::getFunction(c->getSystemState(),getDescent),GETTER_METHOD,true); + c->setDeclaredMethodByQName("ascent","",Class<IFunction>::getFunction(c->getSystemState(),getAscent),GETTER_METHOD,true); + c->setDeclaredMethodByQName("textWidth","",Class<IFunction>::getFunction(c->getSystemState(),getTextWidth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("textHeight","",Class<IFunction>::getFunction(c->getSystemState(),getTextHeight),GETTER_METHOD,true); REGISTER_GETTER(c, textBlock); REGISTER_GETTER(c, nextLine); REGISTER_GETTER(c, previousLine); @@ -514,26 +514,26 @@ ASFUNCTIONBODY(TextLine, getDescent) { LOG(LOG_NOT_IMPLEMENTED,"TextLine.descent"); - return abstract_d(0); + return abstract_d(obj->getSystemState(),0); } ASFUNCTIONBODY(TextLine, getAscent) { TextLine* th=static_cast<TextLine*>(obj); LOG(LOG_NOT_IMPLEMENTED,"TextLine.ascent"); - return abstract_d(th->textHeight); + return abstract_d(obj->getSystemState(),th->textHeight); } ASFUNCTIONBODY(TextLine, getTextWidth) { TextLine* th=static_cast<TextLine*>(obj); - return abstract_d(th->textWidth); + return abstract_d(obj->getSystemState(),th->textWidth); } ASFUNCTIONBODY(TextLine, getTextHeight) { TextLine* th=static_cast<TextLine*>(obj); - return abstract_d(th->textHeight); + return abstract_d(obj->getSystemState(),th->textHeight); } @@ -617,9 +617,9 @@ void TextLineValidity::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("INVALID","",Class<ASString>::getInstanceS("invalid"),CONSTANT_TRAIT); - c->setVariableByQName("POSSIBLY_INVALID","",Class<ASString>::getInstanceS("possiblyInvalid"),CONSTANT_TRAIT); - c->setVariableByQName("STATIC","",Class<ASString>::getInstanceS("static"),CONSTANT_TRAIT); - c->setVariableByQName("VALID","",Class<ASString>::getInstanceS("valid"),CONSTANT_TRAIT); + c->setVariableByQName("INVALID","",abstract_s(c->getSystemState(),"invalid"),CONSTANT_TRAIT); + c->setVariableByQName("POSSIBLY_INVALID","",abstract_s(c->getSystemState(),"possiblyInvalid"),CONSTANT_TRAIT); + c->setVariableByQName("STATIC","",abstract_s(c->getSystemState(),"static"),CONSTANT_TRAIT); + c->setVariableByQName("VALID","",abstract_s(c->getSystemState(),"valid"),CONSTANT_TRAIT); }
View file
lightspark.tar.xz/src/scripting/flash/ui/ContextMenu.cpp
Changed
@@ -22,15 +22,15 @@ using namespace std; using namespace lightspark; -ContextMenu::ContextMenu(Class_base* c):EventDispatcher(c),customItems(Class<Array>::getInstanceS()),builtInItems(Class<ContextMenuBuiltInItems>::getInstanceS()) +ContextMenu::ContextMenu(Class_base* c):EventDispatcher(c),customItems(Class<Array>::getInstanceS(c->getSystemState())),builtInItems(Class<ContextMenuBuiltInItems>::getInstanceS(c->getSystemState())) { } void ContextMenu::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_FINAL); - c->setVariableByQName("isSupported","",abstract_b(false),CONSTANT_TRAIT); - c->setDeclaredMethodByQName("hideBuiltInItems","",Class<IFunction>::getFunction(hideBuiltInItems),NORMAL_METHOD,true); + c->setVariableByQName("isSupported","",abstract_b(c->getSystemState(),false),CONSTANT_TRAIT); + c->setDeclaredMethodByQName("hideBuiltInItems","",Class<IFunction>::getFunction(c->getSystemState(),hideBuiltInItems),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c,customItems); REGISTER_GETTER_SETTER(c,builtInItems); }
View file
lightspark.tar.xz/src/scripting/flash/ui/Keyboard.cpp
Changed
@@ -28,18 +28,18 @@ void Keyboard::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_FINAL | CLASS_SEALED); - c->setDeclaredMethodByQName("capsLock","",Class<IFunction>::getFunction(capsLock),GETTER_METHOD,true); - c->setDeclaredMethodByQName("hasVirtualKeyboard","",Class<IFunction>::getFunction(hasVirtualKeyboard),GETTER_METHOD,true); - c->setDeclaredMethodByQName("numLock","",Class<IFunction>::getFunction(numLock),GETTER_METHOD,true); - c->setDeclaredMethodByQName("physicalKeyboardType","",Class<IFunction>::getFunction(physicalKeyboardType),GETTER_METHOD,true); - c->setDeclaredMethodByQName("isAccessible","",Class<IFunction>::getFunction(isAccessible),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("capsLock","",Class<IFunction>::getFunction(c->getSystemState(),capsLock),GETTER_METHOD,true); + c->setDeclaredMethodByQName("hasVirtualKeyboard","",Class<IFunction>::getFunction(c->getSystemState(),hasVirtualKeyboard),GETTER_METHOD,true); + c->setDeclaredMethodByQName("numLock","",Class<IFunction>::getFunction(c->getSystemState(),numLock),GETTER_METHOD,true); + c->setDeclaredMethodByQName("physicalKeyboardType","",Class<IFunction>::getFunction(c->getSystemState(),physicalKeyboardType),GETTER_METHOD,true); + c->setDeclaredMethodByQName("isAccessible","",Class<IFunction>::getFunction(c->getSystemState(),isAccessible),NORMAL_METHOD,true); // key code constants const std::vector<KeyNameCodePair>& keys = getSys()->getInputThread()->getKeyNamesAndCodes(); std::vector<KeyNameCodePair>::const_iterator it; for (it=keys.begin(); it!=keys.end(); ++it) { - c->setVariableByQName(it->keyname,"",Class<UInteger>::getInstanceS(it->keycode),DECLARED_TRAIT); + c->setVariableByQName(it->keyname,"",abstract_ui(c->getSystemState(),it->keycode),DECLARED_TRAIT); } } @@ -49,43 +49,43 @@ //return abstract_b(gdk_keymap_get_caps_lock_state(gdk_keymap_get_default())); LOG(LOG_NOT_IMPLEMENTED, "Keyboard::capsLock"); - return abstract_b(false); + return abstract_b(getSys(),false); } ASFUNCTIONBODY(Keyboard, hasVirtualKeyboard) { - return abstract_b(false); + return abstract_b(getSys(),false); } ASFUNCTIONBODY(Keyboard, numLock) { LOG(LOG_NOT_IMPLEMENTED, "Keyboard::numLock"); - return abstract_b(false); + return abstract_b(getSys(),false); } ASFUNCTIONBODY(Keyboard, physicalKeyboardType) { - return Class<ASString>::getInstanceS("alphanumeric"); + return abstract_s(getSys(),"alphanumeric"); } ASFUNCTIONBODY(Keyboard, isAccessible) { - return abstract_b(false); + return abstract_b(getSys(),false); } void KeyboardType::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("ALPHANUMERIC","",Class<ASString>::getInstanceS("alphanumeric"),DECLARED_TRAIT); - c->setVariableByQName("KEYPAD","",Class<ASString>::getInstanceS("keypad"),DECLARED_TRAIT); - c->setVariableByQName("NONE","",Class<ASString>::getInstanceS("none"),DECLARED_TRAIT); + c->setVariableByQName("ALPHANUMERIC","",abstract_s(c->getSystemState(),"alphanumeric"),DECLARED_TRAIT); + c->setVariableByQName("KEYPAD","",abstract_s(c->getSystemState(),"keypad"),DECLARED_TRAIT); + c->setVariableByQName("NONE","",abstract_s(c->getSystemState(),"none"),DECLARED_TRAIT); } void KeyLocation::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_FINAL | CLASS_SEALED); - c->setVariableByQName("LEFT","",Class<UInteger>::getInstanceS(1),DECLARED_TRAIT); - c->setVariableByQName("NUM_PAD","",Class<UInteger>::getInstanceS(3),DECLARED_TRAIT); - c->setVariableByQName("RIGHT","",Class<UInteger>::getInstanceS(2),DECLARED_TRAIT); - c->setVariableByQName("STANDARD","",Class<UInteger>::getInstanceS(0),DECLARED_TRAIT); + c->setVariableByQName("LEFT","",abstract_ui(c->getSystemState(),1),DECLARED_TRAIT); + c->setVariableByQName("NUM_PAD","",abstract_ui(c->getSystemState(),3),DECLARED_TRAIT); + c->setVariableByQName("RIGHT","",abstract_ui(c->getSystemState(),2),DECLARED_TRAIT); + c->setVariableByQName("STANDARD","",abstract_ui(c->getSystemState(),0),DECLARED_TRAIT); }
View file
lightspark.tar.xz/src/scripting/flash/ui/Mouse.cpp
Changed
@@ -30,12 +30,12 @@ void Mouse::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_FINAL | CLASS_SEALED); - c->setDeclaredMethodByQName("hide","",Class<IFunction>::getFunction(hide),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("show","",Class<IFunction>::getFunction(show),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("cursor","",Class<IFunction>::getFunction(getCursor),GETTER_METHOD,false); - c->setDeclaredMethodByQName("cursor","",Class<IFunction>::getFunction(setCursor),SETTER_METHOD,false); - c->setDeclaredMethodByQName("supportsCursor","",Class<IFunction>::getFunction(getSupportsCursor),GETTER_METHOD,false); - c->setDeclaredMethodByQName("supportsNativeCursor","",Class<IFunction>::getFunction(getSupportsNativeCursor),GETTER_METHOD,false); + c->setDeclaredMethodByQName("hide","",Class<IFunction>::getFunction(c->getSystemState(),hide),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("show","",Class<IFunction>::getFunction(c->getSystemState(),show),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("cursor","",Class<IFunction>::getFunction(c->getSystemState(),getCursor),GETTER_METHOD,false); + c->setDeclaredMethodByQName("cursor","",Class<IFunction>::getFunction(c->getSystemState(),setCursor),SETTER_METHOD,false); + c->setDeclaredMethodByQName("supportsCursor","",Class<IFunction>::getFunction(c->getSystemState(),getSupportsCursor),GETTER_METHOD,false); + c->setDeclaredMethodByQName("supportsNativeCursor","",Class<IFunction>::getFunction(c->getSystemState(),getSupportsNativeCursor),GETTER_METHOD,false); } ASFUNCTIONBODY(Mouse, hide) @@ -52,7 +52,7 @@ ASFUNCTIONBODY(Mouse, getCursor) { - return Class<ASString>::getInstanceS("auto"); + return abstract_s(getSys(),"auto"); } ASFUNCTIONBODY(Mouse, setCursor) @@ -66,10 +66,10 @@ ASFUNCTIONBODY(Mouse, getSupportsCursor) { - return abstract_b(true); + return abstract_b(getSys(),true); } ASFUNCTIONBODY(Mouse, getSupportsNativeCursor) { - return abstract_b(false); // until registerCursor() is implemented + return abstract_b(getSys(),false); // until registerCursor() is implemented }
View file
lightspark.tar.xz/src/scripting/flash/ui/Multitouch.cpp
Changed
@@ -31,37 +31,37 @@ void Multitouch::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructorNotInstantiatable, CLASS_FINAL | CLASS_SEALED); - c->setDeclaredMethodByQName("inputMode","",Class<IFunction>::getFunction(getInputMode),GETTER_METHOD,false); - c->setDeclaredMethodByQName("maxTouchPoints","",Class<IFunction>::getFunction(getMaxTouchPoints),GETTER_METHOD,false); - c->setDeclaredMethodByQName("supportedGestures","",Class<IFunction>::getFunction(getSupportedGestures),GETTER_METHOD,false); - c->setDeclaredMethodByQName("supportsGestureEvents","",Class<IFunction>::getFunction(getSupportsGestureEvents),GETTER_METHOD,false); - c->setDeclaredMethodByQName("supportsTouchEvents","",Class<IFunction>::getFunction(getSupportsTouchEvents),GETTER_METHOD,false); + c->setDeclaredMethodByQName("inputMode","",Class<IFunction>::getFunction(c->getSystemState(),getInputMode),GETTER_METHOD,false); + c->setDeclaredMethodByQName("maxTouchPoints","",Class<IFunction>::getFunction(c->getSystemState(),getMaxTouchPoints),GETTER_METHOD,false); + c->setDeclaredMethodByQName("supportedGestures","",Class<IFunction>::getFunction(c->getSystemState(),getSupportedGestures),GETTER_METHOD,false); + c->setDeclaredMethodByQName("supportsGestureEvents","",Class<IFunction>::getFunction(c->getSystemState(),getSupportsGestureEvents),GETTER_METHOD,false); + c->setDeclaredMethodByQName("supportsTouchEvents","",Class<IFunction>::getFunction(c->getSystemState(),getSupportsTouchEvents),GETTER_METHOD,false); } ASFUNCTIONBODY(Multitouch, getInputMode) { LOG(LOG_NOT_IMPLEMENTED,"Multitouch not supported"); - return Class<ASString>::getInstanceS("gesture"); + return abstract_s(getSys(),"gesture"); } ASFUNCTIONBODY(Multitouch, getMaxTouchPoints) { LOG(LOG_NOT_IMPLEMENTED,"Multitouch not supported"); - return abstract_i(1); + return abstract_i(getSys(),1); } ASFUNCTIONBODY(Multitouch, getSupportedGestures) { LOG(LOG_NOT_IMPLEMENTED,"Multitouch not supported"); - return Class<Vector>::getInstanceS(); + return Class<Vector>::getInstanceS(getSys()); } ASFUNCTIONBODY(Multitouch, getSupportsGestureEvents) { LOG(LOG_NOT_IMPLEMENTED,"Multitouch not supported"); - return abstract_b(false); + return abstract_b(getSys(),false); } ASFUNCTIONBODY(Multitouch, getSupportsTouchEvents) { LOG(LOG_NOT_IMPLEMENTED,"Multitouch not supported"); - return abstract_b(false); + return abstract_b(getSys(),false); }
View file
lightspark.tar.xz/src/scripting/flash/utils/ByteArray.cpp
Changed
@@ -57,59 +57,59 @@ void ByteArray::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(_getLength),GETTER_METHOD,true); - c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(_setLength),SETTER_METHOD,true); - c->setDeclaredMethodByQName("bytesAvailable","",Class<IFunction>::getFunction(_getBytesAvailable),GETTER_METHOD,true); - c->setDeclaredMethodByQName("position","",Class<IFunction>::getFunction(_getPosition),GETTER_METHOD,true); - c->setDeclaredMethodByQName("position","",Class<IFunction>::getFunction(_setPosition),SETTER_METHOD,true); - c->setDeclaredMethodByQName("endian","",Class<IFunction>::getFunction(_getEndian),GETTER_METHOD,true); - c->setDeclaredMethodByQName("endian","",Class<IFunction>::getFunction(_setEndian),SETTER_METHOD,true); - c->setDeclaredMethodByQName("objectEncoding","",Class<IFunction>::getFunction(_getObjectEncoding),GETTER_METHOD,true); - c->setDeclaredMethodByQName("objectEncoding","",Class<IFunction>::getFunction(_setObjectEncoding),SETTER_METHOD,true); - c->setDeclaredMethodByQName("defaultObjectEncoding","",Class<IFunction>::getFunction(_getDefaultObjectEncoding),GETTER_METHOD,false); - c->setDeclaredMethodByQName("defaultObjectEncoding","",Class<IFunction>::getFunction(_setDefaultObjectEncoding),SETTER_METHOD,false); - - getSys()->staticByteArrayDefaultObjectEncoding = ObjectEncoding::DEFAULT; - c->setDeclaredMethodByQName("clear","",Class<IFunction>::getFunction(clear),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("compress","",Class<IFunction>::getFunction(_compress),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("uncompress","",Class<IFunction>::getFunction(_uncompress),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("deflate","",Class<IFunction>::getFunction(_deflate),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("inflate","",Class<IFunction>::getFunction(_inflate),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readBoolean","",Class<IFunction>::getFunction(readBoolean),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readBytes","",Class<IFunction>::getFunction(readBytes),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readByte","",Class<IFunction>::getFunction(readByte),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readDouble","",Class<IFunction>::getFunction(readDouble),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readFloat","",Class<IFunction>::getFunction(readFloat),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readInt","",Class<IFunction>::getFunction(readInt),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readMultiByte","",Class<IFunction>::getFunction(readMultiByte),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readShort","",Class<IFunction>::getFunction(readShort),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readUnsignedByte","",Class<IFunction>::getFunction(readUnsignedByte),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readUnsignedInt","",Class<IFunction>::getFunction(readUnsignedInt),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readUnsignedShort","",Class<IFunction>::getFunction(readUnsignedShort),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readObject","",Class<IFunction>::getFunction(readObject),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readUTF","",Class<IFunction>::getFunction(readUTF),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("readUTFBytes","",Class<IFunction>::getFunction(readUTFBytes),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("writeBoolean","",Class<IFunction>::getFunction(writeBoolean),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("writeUTF","",Class<IFunction>::getFunction(writeUTF),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("writeUTFBytes","",Class<IFunction>::getFunction(writeUTFBytes),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("writeBytes","",Class<IFunction>::getFunction(writeBytes),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("writeByte","",Class<IFunction>::getFunction(writeByte),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("writeDouble","",Class<IFunction>::getFunction(writeDouble),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("writeFloat","",Class<IFunction>::getFunction(writeFloat),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("writeInt","",Class<IFunction>::getFunction(writeInt),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("writeMultiByte","",Class<IFunction>::getFunction(writeMultiByte),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("writeUnsignedInt","",Class<IFunction>::getFunction(writeUnsignedInt),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("writeObject","",Class<IFunction>::getFunction(writeObject),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("writeShort","",Class<IFunction>::getFunction(writeShort),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(ByteArray::_toString),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(c->getSystemState(),_getLength),GETTER_METHOD,true); + c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(c->getSystemState(),_setLength),SETTER_METHOD,true); + c->setDeclaredMethodByQName("bytesAvailable","",Class<IFunction>::getFunction(c->getSystemState(),_getBytesAvailable),GETTER_METHOD,true); + c->setDeclaredMethodByQName("position","",Class<IFunction>::getFunction(c->getSystemState(),_getPosition),GETTER_METHOD,true); + c->setDeclaredMethodByQName("position","",Class<IFunction>::getFunction(c->getSystemState(),_setPosition),SETTER_METHOD,true); + c->setDeclaredMethodByQName("endian","",Class<IFunction>::getFunction(c->getSystemState(),_getEndian),GETTER_METHOD,true); + c->setDeclaredMethodByQName("endian","",Class<IFunction>::getFunction(c->getSystemState(),_setEndian),SETTER_METHOD,true); + c->setDeclaredMethodByQName("objectEncoding","",Class<IFunction>::getFunction(c->getSystemState(),_getObjectEncoding),GETTER_METHOD,true); + c->setDeclaredMethodByQName("objectEncoding","",Class<IFunction>::getFunction(c->getSystemState(),_setObjectEncoding),SETTER_METHOD,true); + c->setDeclaredMethodByQName("defaultObjectEncoding","",Class<IFunction>::getFunction(c->getSystemState(),_getDefaultObjectEncoding),GETTER_METHOD,false); + c->setDeclaredMethodByQName("defaultObjectEncoding","",Class<IFunction>::getFunction(c->getSystemState(),_setDefaultObjectEncoding),SETTER_METHOD,false); + + c->getSystemState()->staticByteArrayDefaultObjectEncoding = ObjectEncoding::DEFAULT; + c->setDeclaredMethodByQName("clear","",Class<IFunction>::getFunction(c->getSystemState(),clear),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("compress","",Class<IFunction>::getFunction(c->getSystemState(),_compress),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("uncompress","",Class<IFunction>::getFunction(c->getSystemState(),_uncompress),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("deflate","",Class<IFunction>::getFunction(c->getSystemState(),_deflate),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("inflate","",Class<IFunction>::getFunction(c->getSystemState(),_inflate),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readBoolean","",Class<IFunction>::getFunction(c->getSystemState(),readBoolean),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readBytes","",Class<IFunction>::getFunction(c->getSystemState(),readBytes),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readByte","",Class<IFunction>::getFunction(c->getSystemState(),readByte),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readDouble","",Class<IFunction>::getFunction(c->getSystemState(),readDouble),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readFloat","",Class<IFunction>::getFunction(c->getSystemState(),readFloat),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readInt","",Class<IFunction>::getFunction(c->getSystemState(),readInt),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readMultiByte","",Class<IFunction>::getFunction(c->getSystemState(),readMultiByte),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readShort","",Class<IFunction>::getFunction(c->getSystemState(),readShort),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readUnsignedByte","",Class<IFunction>::getFunction(c->getSystemState(),readUnsignedByte),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readUnsignedInt","",Class<IFunction>::getFunction(c->getSystemState(),readUnsignedInt),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readUnsignedShort","",Class<IFunction>::getFunction(c->getSystemState(),readUnsignedShort),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readObject","",Class<IFunction>::getFunction(c->getSystemState(),readObject),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readUTF","",Class<IFunction>::getFunction(c->getSystemState(),readUTF),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("readUTFBytes","",Class<IFunction>::getFunction(c->getSystemState(),readUTFBytes),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("writeBoolean","",Class<IFunction>::getFunction(c->getSystemState(),writeBoolean),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("writeUTF","",Class<IFunction>::getFunction(c->getSystemState(),writeUTF),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("writeUTFBytes","",Class<IFunction>::getFunction(c->getSystemState(),writeUTFBytes),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("writeBytes","",Class<IFunction>::getFunction(c->getSystemState(),writeBytes),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("writeByte","",Class<IFunction>::getFunction(c->getSystemState(),writeByte),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("writeDouble","",Class<IFunction>::getFunction(c->getSystemState(),writeDouble),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("writeFloat","",Class<IFunction>::getFunction(c->getSystemState(),writeFloat),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("writeInt","",Class<IFunction>::getFunction(c->getSystemState(),writeInt),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("writeMultiByte","",Class<IFunction>::getFunction(c->getSystemState(),writeMultiByte),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("writeUnsignedInt","",Class<IFunction>::getFunction(c->getSystemState(),writeUnsignedInt),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("writeObject","",Class<IFunction>::getFunction(c->getSystemState(),writeObject),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("writeShort","",Class<IFunction>::getFunction(c->getSystemState(),writeShort),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),ByteArray::_toString),DYNAMIC_TRAIT); REGISTER_GETTER_SETTER(c,shareable); - c->setDeclaredMethodByQName("atomicCompareAndSwapIntAt","",Class<IFunction>::getFunction(atomicCompareAndSwapIntAt),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("atomicCompareAndSwapLength","",Class<IFunction>::getFunction(atomicCompareAndSwapLength),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toJSON",AS3,Class<IFunction>::getFunction(_toJSON),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("atomicCompareAndSwapIntAt","",Class<IFunction>::getFunction(c->getSystemState(),atomicCompareAndSwapIntAt),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("atomicCompareAndSwapLength","",Class<IFunction>::getFunction(c->getSystemState(),atomicCompareAndSwapLength),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toJSON",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toJSON),DYNAMIC_TRAIT); - c->addImplementedInterface(InterfaceClass<IDataInput>::getClass()); + c->addImplementedInterface(InterfaceClass<IDataInput>::getClass(c->getSystemState())); IDataInput::linkTraits(c); - c->addImplementedInterface(InterfaceClass<IDataOutput>::getClass()); + c->addImplementedInterface(InterfaceClass<IDataOutput>::getClass(c->getSystemState())); IDataOutput::linkTraits(c); } @@ -239,7 +239,7 @@ ASFUNCTIONBODY(ByteArray,_getPosition) { ByteArray* th=static_cast<ByteArray*>(obj); - return abstract_i(th->getPosition()); + return abstract_i(obj->getSystemState(),th->getPosition()); } void ByteArray::setPosition(uint32_t p) @@ -261,9 +261,9 @@ { ByteArray* th=static_cast<ByteArray*>(obj); if(th->littleEndian) - return Class<ASString>::getInstanceS(Endian::littleEndian); + return abstract_s(obj->getSystemState(),Endian::littleEndian); else - return Class<ASString>::getInstanceS(Endian::bigEndian); + return abstract_s(obj->getSystemState(),Endian::bigEndian); } ASFUNCTIONBODY(ByteArray,_setEndian) @@ -281,7 +281,7 @@ ASFUNCTIONBODY(ByteArray,_getObjectEncoding) { ByteArray* th=static_cast<ByteArray*>(obj); - return abstract_ui(th->objectEncoding); + return abstract_ui(obj->getSystemState(),th->objectEncoding); } ASFUNCTIONBODY(ByteArray,_setObjectEncoding) @@ -299,7 +299,7 @@ ASFUNCTIONBODY(ByteArray,_getDefaultObjectEncoding) { - return abstract_i(getSys()->staticNetConnectionDefaultObjectEncoding); + return abstract_i(obj->getSystemState(),obj->getSystemState()->staticNetConnectionDefaultObjectEncoding); } ASFUNCTIONBODY(ByteArray,_setDefaultObjectEncoding) @@ -307,9 +307,9 @@ assert_and_throw(argslen == 1); int32_t value = args[0]->toInt(); if(value == 0) - getSys()->staticByteArrayDefaultObjectEncoding = ObjectEncoding::AMF0; + args[0]->getSystemState()->staticByteArrayDefaultObjectEncoding = ObjectEncoding::AMF0; else if(value == 3) - getSys()->staticByteArrayDefaultObjectEncoding = ObjectEncoding::AMF3; + args[0]->getSystemState()->staticByteArrayDefaultObjectEncoding = ObjectEncoding::AMF3; else throw RunTimeException("Invalid object encoding"); return NULL; @@ -353,13 +353,13 @@ ASFUNCTIONBODY(ByteArray,_getLength) { ByteArray* th=static_cast<ByteArray*>(obj); - return abstract_i(th->len); + return abstract_i(obj->getSystemState(),th->len); } ASFUNCTIONBODY(ByteArray,_getBytesAvailable) { ByteArray* th=static_cast<ByteArray*>(obj); - return abstract_i(th->len-th->position); + return abstract_i(obj->getSystemState(),th->len-th->position); } ASFUNCTIONBODY(ByteArray,readBoolean) @@ -375,7 +375,7 @@ } th->unlock(); - return abstract_b(ret!=0); + return abstract_b(obj->getSystemState(),ret!=0); } ASFUNCTIONBODY(ByteArray,readBytes) @@ -402,7 +402,7 @@ if((uint64_t)length+offset > 0xFFFFFFFF) { th->unlock(); - throw Class<RangeError>::getInstanceS("length+offset"); + throw Class<RangeError>::getInstanceS(obj->getSystemState(),"length+offset"); } uint8_t* buf=out->getBuffer(length+offset,true); @@ -451,7 +451,7 @@ throwError<EOFError>(kEOFError); } th->unlock(); - return Class<ASString>::getInstanceS(res); + return abstract_s(obj->getSystemState(),res); } ASFUNCTIONBODY(ByteArray,readUTFBytes) @@ -484,7 +484,7 @@ strncpy(buf,(char*)bufStart,(size_t)length); th->position+=length; th->unlock(); - return Class<ASString>::getInstanceS((char *)buf,strlen(buf)); + return abstract_s(obj->getSystemState(),(char *)buf,strlen(buf)); } void ByteArray::writeUTF(const tiny_string& str) @@ -598,7 +598,7 @@ ByteArray* th=static_cast<ByteArray*>(obj); //Validate parameters assert_and_throw(argslen>=1 && argslen<=3); - assert_and_throw(args[0]->getClass()->isSubClass(Class<ByteArray>::getClass())); + assert_and_throw(args[0]->getClass()->isSubClass(Class<ByteArray>::getClass(obj->getSystemState()))); ByteArray* out=Class<ByteArray>::cast(args[0]); uint32_t offset=0; uint32_t length=0; @@ -800,7 +800,7 @@ throwError<EOFError>(kEOFError); } th->unlock(); - return abstract_i((int8_t)ret); + return abstract_i(obj->getSystemState(),(int8_t)ret); } ASFUNCTIONBODY(ByteArray,readDouble) @@ -822,7 +822,7 @@ double *doubleptr=reinterpret_cast<double*>(&ret); th->unlock(); - return abstract_d(*doubleptr); + return abstract_d(obj->getSystemState(),*doubleptr); } ASFUNCTIONBODY(ByteArray,readFloat) @@ -844,7 +844,7 @@ float *floatptr=reinterpret_cast<float*>(&ret); th->unlock(); - return abstract_d(*floatptr); + return abstract_d(obj->getSystemState(),*floatptr); } ASFUNCTIONBODY(ByteArray,readInt) @@ -863,7 +863,7 @@ memcpy(&ret,th->bytes+th->position,4); th->position+=4; th->unlock(); - return abstract_i((int32_t)th->endianOut(ret)); + return abstract_i(obj->getSystemState(),(int32_t)th->endianOut(ret)); } bool ByteArray::readShort(uint16_t& ret) @@ -892,7 +892,7 @@ } th->unlock(); - return abstract_i((int16_t)ret); + return abstract_i(obj->getSystemState(),(int16_t)ret); } ASFUNCTIONBODY(ByteArray,readUnsignedByte) @@ -907,7 +907,7 @@ th->unlock(); throwError<EOFError>(kEOFError); } - return abstract_ui(ret); + return abstract_ui(obj->getSystemState(),ret); } bool ByteArray::readUnsignedInt(uint32_t& ret) @@ -935,7 +935,7 @@ throwError<EOFError>(kEOFError); } th->unlock(); - return abstract_ui(ret); + return abstract_ui(obj->getSystemState(),ret); } ASFUNCTIONBODY(ByteArray,readUnsignedShort) @@ -951,7 +951,7 @@ throwError<EOFError>(kEOFError); } - return abstract_ui(ret); + return abstract_ui(obj->getSystemState(),ret); } ASFUNCTIONBODY(ByteArray,readMultiByte) @@ -970,7 +970,7 @@ // TODO: should convert from charset to UTF-8 LOG(LOG_NOT_IMPLEMENTED, "ByteArray.readMultiByte doesn't convert charset"); - return Class<ASString>::getInstanceS((char*)th->bytes+th->position,strlen); + return abstract_s(obj->getSystemState(),(char*)th->bytes+th->position,strlen); } ASFUNCTIONBODY(ByteArray,readObject) @@ -982,7 +982,7 @@ { th->unlock(); // it seems that contrary to the specs Adobe returns Undefined when reading from an empty ByteArray - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); //throwError<EOFError>(kEOFError); } //assert_and_throw(th->objectEncoding==ObjectEncoding::AMF3); @@ -1003,7 +1003,7 @@ if(ret.isNull()) { LOG(LOG_ERROR,"No objects in the AMF3 data. Returning Undefined"); - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); } ret->incRef(); return ret.getPtr(); @@ -1021,7 +1021,7 @@ th->bytes[2] == 0xbf) start = 3; } - return Class<ASString>::getInstanceS((char*)th->bytes+start,th->len-start); + return abstract_s(obj->getSystemState(),(char*)th->bytes+start,th->len-start); } bool ByteArray::hasPropertyByMultiname(const multiname& name, bool considerDynamic, bool considerPrototype) @@ -1032,7 +1032,7 @@ return false; unsigned int index=0; - if(!Array::isValidMultiname(name,index)) + if(!Array::isValidMultiname(getSystemState(),name,index)) return ASObject::hasPropertyByMultiname(name, considerDynamic, considerPrototype); return index<len; @@ -1041,23 +1041,23 @@ _NR<ASObject> ByteArray::getVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt) { unsigned int index=0; - if((opt & ASObject::SKIP_IMPL)!=0 || !implEnable || !Array::isValidMultiname(name,index)) + if((opt & ASObject::SKIP_IMPL)!=0 || !implEnable || !Array::isValidMultiname(getSystemState(),name,index)) return ASObject::getVariableByMultiname(name,opt); if(index<len) { uint8_t value = bytes[index]; - return _MNR(abstract_ui(static_cast<uint32_t>(value))); + return _MNR(abstract_ui(getSystemState(),static_cast<uint32_t>(value))); } else - return _MNR(getSys()->getUndefinedRef()); + return _MNR(getSystemState()->getUndefinedRef()); } int32_t ByteArray::getVariableByMultiname_i(const multiname& name) { assert_and_throw(implEnable); unsigned int index=0; - if(!Array::isValidMultiname(name,index)) + if(!Array::isValidMultiname(getSystemState(),name,index)) return ASObject::getVariableByMultiname_i(name); if(index<len) @@ -1066,14 +1066,14 @@ return static_cast<uint32_t>(value); } else - return _MNR(getSys()->getUndefinedRef()); + return _MNR(getSystemState()->getUndefinedRef()); } void ByteArray::setVariableByMultiname(const multiname& name, ASObject* o, CONST_ALLOWED_FLAG allowConst) { assert_and_throw(implEnable); unsigned int index=0; - if(!Array::isValidMultiname(name,index)) + if(!Array::isValidMultiname(getSystemState(),name,index)) return ASObject::setVariableByMultiname(name,o,allowConst); if(index>=len) @@ -1093,7 +1093,7 @@ void ByteArray::setVariableByMultiname_i(const multiname& name, int32_t value) { - setVariableByMultiname(name, abstract_i(value),ASObject::CONST_NOT_ALLOWED); + setVariableByMultiname(name, abstract_i(getSystemState(),value),ASObject::CONST_NOT_ALLOWED); } void ByteArray::acquireBuffer(uint8_t* buf, int bufLen) @@ -1275,7 +1275,7 @@ strm.total_out=0; status=inflateInit(&strm); if(status==Z_VERSION_ERROR) - throw Class<IOError>::getInstanceS("not valid compressed data"); + throw Class<IOError>::getInstanceS(getSystemState(),"not valid compressed data"); else if(status!=Z_OK) throw RunTimeException("zlib uncompress failed"); @@ -1289,7 +1289,7 @@ if(status!=Z_OK && status!=Z_STREAM_END) { inflateEnd(&strm); - throw Class<IOError>::getInstanceS("not valid compressed data"); + throw Class<IOError>::getInstanceS(getSystemState(),"not valid compressed data"); } if(strm.avail_out==0) @@ -1383,7 +1383,7 @@ th->len--; } th->unlock(); - return abstract_ui(res); + return abstract_ui(obj->getSystemState(),res); } @@ -1399,7 +1399,7 @@ } uint32_t res = th->getLength(); th->unlock(); - return abstract_ui(res); + return abstract_ui(obj->getSystemState(),res); } // this seems to be how AS3 handles generic shift calls in Array class @@ -1414,7 +1414,7 @@ th->len--; } th->unlock(); - return abstract_ui(res); + return abstract_ui(obj->getSystemState(),res); } // this seems to be how AS3 handles generic unshift calls in Array class @@ -1430,7 +1430,7 @@ } uint32_t res = th->getLength(); th->unlock(); - return abstract_ui(res); + return abstract_ui(obj->getSystemState(),res); } ASFUNCTIONBODY_GETTER_SETTER(ByteArray,shareable); @@ -1459,7 +1459,7 @@ memcpy(th->bytes+byteindex,&newvalue,4); } th->unlock(); - return abstract_i(ret); + return abstract_i(obj->getSystemState(),ret); } ASFUNCTIONBODY(ByteArray,atomicCompareAndSwapLength) { @@ -1474,12 +1474,12 @@ th->setLength(newLength); } th->unlock(); - return abstract_i(ret); + return abstract_i(obj->getSystemState(),ret); } ASFUNCTIONBODY(ByteArray,_toJSON) { - return Class<ASString>::getInstanceS("ByteArray"); + return abstract_s(getSys(),"ByteArray"); } void ByteArray::serialize(ByteArray* out, std::map<tiny_string, uint32_t>& stringMap,
View file
lightspark.tar.xz/src/scripting/flash/utils/CompressionAlgorithm.cpp
Changed
@@ -33,7 +33,7 @@ void CompressionAlgorithm::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED|CLASS_FINAL); - c->setVariableByQName("DEFLATE","",Class<ASString>::getInstanceS("deflate"),CONSTANT_TRAIT); - c->setVariableByQName("LZMA","",Class<ASString>::getInstanceS("lzma"),CONSTANT_TRAIT); - c->setVariableByQName("ZLIB","",Class<ASString>::getInstanceS("zlib"),CONSTANT_TRAIT); + c->setVariableByQName("DEFLATE","",abstract_s(c->getSystemState(),"deflate"),CONSTANT_TRAIT); + c->setVariableByQName("LZMA","",abstract_s(c->getSystemState(),"lzma"),CONSTANT_TRAIT); + c->setVariableByQName("ZLIB","",abstract_s(c->getSystemState(),"zlib"),CONSTANT_TRAIT); }
View file
lightspark.tar.xz/src/scripting/flash/utils/Dictionary.cpp
Changed
@@ -43,7 +43,7 @@ void Dictionary::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_DYNAMIC_NOT_FINAL); - c->prototype->setVariableByQName("toJSON",AS3,Class<IFunction>::getFunction(_toJSON),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toJSON",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toJSON),DYNAMIC_TRAIT); } void Dictionary::buildTraits(ASObject* o) @@ -61,7 +61,7 @@ ASFUNCTIONBODY(Dictionary,_toJSON) { - return Class<ASString>::getInstanceS("Dictionary"); + return abstract_s(getSys(),"Dictionary"); } Dictionary::dictType::iterator Dictionary::findKey(ASObject *o) @@ -79,7 +79,7 @@ void Dictionary::setVariableByMultiname_i(const multiname& name, int32_t value) { assert_and_throw(implEnable); - Dictionary::setVariableByMultiname(name,abstract_i(value),CONST_NOT_ALLOWED); + Dictionary::setVariableByMultiname(name,abstract_i(getSystemState(),value),CONST_NOT_ALLOWED); } void Dictionary::setVariableByMultiname(const multiname& name, ASObject* o, CONST_ALLOWED_FLAG allowConst) @@ -88,7 +88,7 @@ if(name.name_type==multiname::NAME_OBJECT) { multiname tmpname(NULL); - tmpname.ns.push_back(nsNameAndKind("",NAMESPACE)); + tmpname.ns.push_back(nsNameAndKind(getSystemState(),"",NAMESPACE)); switch (name.name_o->getObjectType()) { case T_BOOLEAN: @@ -105,7 +105,7 @@ return; case T_STRING: tmpname.name_type=multiname::NAME_STRING; - tmpname.name_s_id = getSys()->getUniqueStringId(name.name_o->toString()); + tmpname.name_s_id = getSystemState()->getUniqueStringId(name.name_o->toString()); ASObject::setVariableByMultiname(tmpname, o, allowConst); return; default: @@ -138,7 +138,7 @@ if(name.name_type==multiname::NAME_OBJECT) { multiname tmpname(NULL); - tmpname.ns.push_back(nsNameAndKind("",NAMESPACE)); + tmpname.ns.push_back(nsNameAndKind(getSystemState(),"",NAMESPACE)); switch (name.name_o->getObjectType()) { case T_BOOLEAN: @@ -153,7 +153,7 @@ return ASObject::deleteVariableByMultiname(tmpname); case T_STRING: tmpname.name_type=multiname::NAME_STRING; - tmpname.name_s_id = getSys()->getUniqueStringId(name.name_o->toString()); + tmpname.name_s_id = getSystemState()->getUniqueStringId(name.name_o->toString()); return ASObject::deleteVariableByMultiname(tmpname); default: break; @@ -187,7 +187,7 @@ if(name.name_type==multiname::NAME_OBJECT) { multiname tmpname(NULL); - tmpname.ns.push_back(nsNameAndKind("",NAMESPACE)); + tmpname.ns.push_back(nsNameAndKind(getSystemState(),"",NAMESPACE)); switch (name.name_o->getObjectType()) { case T_BOOLEAN: @@ -202,7 +202,7 @@ return ASObject::getVariableByMultiname(tmpname, opt); case T_STRING: tmpname.name_type=multiname::NAME_STRING; - tmpname.name_s_id = getSys()->getUniqueStringId(name.name_o->toString()); + tmpname.name_s_id = getSystemState()->getUniqueStringId(name.name_o->toString()); return ASObject::getVariableByMultiname(tmpname, opt); default: break; @@ -244,7 +244,7 @@ if(name.name_type==multiname::NAME_OBJECT) { multiname tmpname(NULL); - tmpname.ns.push_back(nsNameAndKind("",NAMESPACE)); + tmpname.ns.push_back(nsNameAndKind(getSystemState(),"",NAMESPACE)); switch (name.name_o->getObjectType()) { case T_BOOLEAN: @@ -259,7 +259,7 @@ return ASObject::hasPropertyByMultiname(tmpname, considerDynamic, considerPrototype); case T_STRING: tmpname.name_type=multiname::NAME_STRING; - tmpname.name_s_id = getSys()->getUniqueStringId(name.name_o->toString()); + tmpname.name_s_id = getSystemState()->getUniqueStringId(name.name_o->toString()); return ASObject::hasPropertyByMultiname(tmpname, considerDynamic, considerPrototype); default: break;
View file
lightspark.tar.xz/src/scripting/flash/utils/IntervalRunner.cpp
Changed
@@ -55,7 +55,7 @@ args[i]->incRef(); } _R<FunctionEvent> event(new (getSys()->unaccountedMemory) FunctionEvent(callback, obj, args, argslen)); - getVm()->addEvent(NullRef,event); + getVm(getSys())->addEvent(NullRef,event); event->done.wait(); if(type == TIMEOUT) {
View file
lightspark.tar.xz/src/scripting/flash/utils/Proxy.cpp
Changed
@@ -39,7 +39,7 @@ { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject,CLASS_DYNAMIC_NOT_FINAL); c->isProxy = true; - c->setDeclaredMethodByQName("isAttribute","",Class<IFunction>::getFunction(_isAttribute),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("isAttribute","",Class<IFunction>::getFunction(c->getSystemState(),_isAttribute),NORMAL_METHOD,true); } void Proxy::buildTraits(ASObject* o) @@ -51,7 +51,7 @@ ARG_UNPACK(name); multiname mname(NULL); name->applyProxyProperty(mname); - return abstract_b(mname.isAttribute); + return abstract_b(obj->getSystemState(),mname.isAttribute); } void Proxy::setVariableByMultiname(const multiname& name, ASObject* o, CONST_ALLOWED_FLAG allowConst) @@ -66,8 +66,8 @@ //Check if there is a custom setter defined, skipping implementation to avoid recursive calls multiname setPropertyName(NULL); setPropertyName.name_type=multiname::NAME_STRING; - setPropertyName.name_s_id=getSys()->getUniqueStringId("setProperty"); - setPropertyName.ns.emplace_back(flash_proxy,NAMESPACE); + setPropertyName.name_s_id=getSystemState()->getUniqueStringId("setProperty"); + setPropertyName.ns.emplace_back(getSystemState(),flash_proxy,NAMESPACE); _NR<ASObject> proxySetter=getVariableByMultiname(setPropertyName,ASObject::SKIP_IMPL); if(proxySetter.isNull()) @@ -80,7 +80,7 @@ IFunction* f=static_cast<IFunction*>(proxySetter.getPtr()); - ASObject* namearg = abstract_s(name.normalizedName()); + ASObject* namearg = abstract_s(getSystemState(),name.normalizedName(getSystemState())); namearg->setProxyProperty(name); ASObject* args[2]; args[0]=namearg; @@ -108,8 +108,8 @@ //Check if there is a custom getter defined, skipping implementation to avoid recursive calls multiname getPropertyName(NULL); getPropertyName.name_type=multiname::NAME_STRING; - getPropertyName.name_s_id=getSys()->getUniqueStringId("getProperty"); - getPropertyName.ns.emplace_back(flash_proxy,NAMESPACE); + getPropertyName.name_s_id=getSystemState()->getUniqueStringId("getProperty"); + getPropertyName.ns.emplace_back(getSystemState(),flash_proxy,NAMESPACE); o=getVariableByMultiname(getPropertyName,ASObject::SKIP_IMPL); if(o.isNull()) @@ -119,12 +119,12 @@ IFunction* f=static_cast<IFunction*>(o.getPtr()); - ASObject* namearg = abstract_s(name.normalizedName()); + ASObject* namearg = abstract_s(f->getSystemState(),name.normalizedName(getSystemState())); namearg->setProxyProperty(name); ASObject* arg = namearg; //We now suppress special handling implEnable=false; - LOG(LOG_CALLS,"Proxy::getProperty "<< name.normalizedNameUnresolved() << " " << this->toDebugString()); + LOG(LOG_CALLS,"Proxy::getProperty "<< name.normalizedNameUnresolved(getSystemState()) << " " << this->toDebugString()); incRef(); _NR<ASObject> ret=_MNR(f->call(this,&arg,1)); implEnable=true; @@ -133,7 +133,7 @@ bool Proxy::hasPropertyByMultiname(const multiname& name, bool considerDynamic, bool considerPrototype) { - if (name.normalizedName() == "isAttribute") + if (name.normalizedName(getSystemState()) == "isAttribute") return true; //If a variable named like this already exist, use that bool asobject_has_property=ASObject::hasPropertyByMultiname(name, considerDynamic, considerPrototype); @@ -144,8 +144,8 @@ //Check if there is a custom hasProperty defined, skipping implementation to avoid recursive calls multiname hasPropertyName(NULL); hasPropertyName.name_type=multiname::NAME_STRING; - hasPropertyName.name_s_id=getSys()->getUniqueStringId("hasProperty"); - hasPropertyName.ns.emplace_back(flash_proxy,NAMESPACE); + hasPropertyName.name_s_id=getSystemState()->getUniqueStringId("hasProperty"); + hasPropertyName.ns.emplace_back(getSystemState(),flash_proxy,NAMESPACE); _NR<ASObject> proxyHasProperty=getVariableByMultiname(hasPropertyName,ASObject::SKIP_IMPL); if(proxyHasProperty.isNull()) @@ -157,7 +157,7 @@ IFunction* f=static_cast<IFunction*>(proxyHasProperty.getPtr()); - ASObject* namearg = abstract_s(name.normalizedName()); + ASObject* namearg = abstract_s(getSystemState(),name.normalizedName(getSystemState())); namearg->setProxyProperty(name); ASObject* arg = namearg; //We now suppress special handling @@ -180,8 +180,8 @@ //Check if there is a custom deleter defined, skipping implementation to avoid recursive calls multiname deletePropertyName(NULL); deletePropertyName.name_type=multiname::NAME_STRING; - deletePropertyName.name_s_id=getSys()->getUniqueStringId("deleteProperty"); - deletePropertyName.ns.emplace_back(flash_proxy,NAMESPACE); + deletePropertyName.name_s_id=getSystemState()->getUniqueStringId("deleteProperty"); + deletePropertyName.ns.emplace_back(getSystemState(),flash_proxy,NAMESPACE); _NR<ASObject> proxyDeleter=getVariableByMultiname(deletePropertyName,ASObject::SKIP_IMPL); if(proxyDeleter.isNull()) @@ -193,7 +193,7 @@ IFunction* f=static_cast<IFunction*>(proxyDeleter.getPtr()); - ASObject* namearg = abstract_s(name.normalizedName()); + ASObject* namearg = abstract_s(getSystemState(),name.normalizedName(getSystemState())); namearg->setProxyProperty(name); ASObject* arg = namearg; //We now suppress special handling @@ -213,12 +213,12 @@ //Check if there is a custom enumerator, skipping implementation to avoid recursive calls multiname nextNameIndexName(NULL); nextNameIndexName.name_type=multiname::NAME_STRING; - nextNameIndexName.name_s_id=getSys()->getUniqueStringId("nextNameIndex"); - nextNameIndexName.ns.emplace_back(flash_proxy,NAMESPACE); + nextNameIndexName.name_s_id=getSystemState()->getUniqueStringId("nextNameIndex"); + nextNameIndexName.ns.emplace_back(getSystemState(),flash_proxy,NAMESPACE); _NR<ASObject> o=getVariableByMultiname(nextNameIndexName,ASObject::SKIP_IMPL); assert_and_throw(!o.isNull() && o->getObjectType()==T_FUNCTION); IFunction* f=static_cast<IFunction*>(o.getPtr()); - ASObject* arg=abstract_i(cur_index); + ASObject* arg=abstract_i(getSystemState(),cur_index); this->incRef(); ASObject* ret=f->call(this,&arg,1); uint32_t newIndex=ret->toInt(); @@ -233,12 +233,12 @@ //Check if there is a custom enumerator, skipping implementation to avoid recursive calls multiname nextNameName(NULL); nextNameName.name_type=multiname::NAME_STRING; - nextNameName.name_s_id=getSys()->getUniqueStringId("nextName"); - nextNameName.ns.emplace_back(flash_proxy,NAMESPACE); + nextNameName.name_s_id=getSystemState()->getUniqueStringId("nextName"); + nextNameName.ns.emplace_back(getSystemState(),flash_proxy,NAMESPACE); _NR<ASObject> o=getVariableByMultiname(nextNameName,ASObject::SKIP_IMPL); assert_and_throw(!o.isNull() && o->getObjectType()==T_FUNCTION); IFunction* f=static_cast<IFunction*>(o.getPtr()); - ASObject* arg=abstract_i(index); + ASObject* arg=abstract_i(getSystemState(),index); incRef(); return _MR(f->call(this,&arg,1)); } @@ -250,12 +250,12 @@ //Check if there is a custom enumerator, skipping implementation to avoid recursive calls multiname nextValueName(NULL); nextValueName.name_type=multiname::NAME_STRING; - nextValueName.name_s_id=getSys()->getUniqueStringId("nextValue"); - nextValueName.ns.emplace_back(flash_proxy,NAMESPACE); + nextValueName.name_s_id=getSystemState()->getUniqueStringId("nextValue"); + nextValueName.ns.emplace_back(getSystemState(),flash_proxy,NAMESPACE); _NR<ASObject> o=getVariableByMultiname(nextValueName,ASObject::SKIP_IMPL); assert_and_throw(!o.isNull() && o->getObjectType()==T_FUNCTION); IFunction* f=static_cast<IFunction*>(o.getPtr()); - ASObject* arg=abstract_i(index); + ASObject* arg=abstract_i(getSystemState(),index); incRef(); return _MR(f->call(this,&arg,1)); }
View file
lightspark.tar.xz/src/scripting/flash/utils/Proxy.h
Changed
@@ -46,7 +46,7 @@ void setVariableByMultiname(const multiname& name, ASObject* o, CONST_ALLOWED_FLAG allowConst); void setVariableByMultiname_i(const multiname& name, int32_t value) { - setVariableByMultiname(name,abstract_i(value),CONST_NOT_ALLOWED); + setVariableByMultiname(name,abstract_i(getSystemState(),value),CONST_NOT_ALLOWED); } bool deleteVariableByMultiname(const multiname& name);
View file
lightspark.tar.xz/src/scripting/flash/utils/Timer.cpp
Changed
@@ -34,7 +34,7 @@ //This will be executed once if repeatCount was originally 1 //Otherwise it's executed until stopMe is set to true this->incRef(); - getVm()->addEvent(_MR(this),_MR(Class<TimerEvent>::getInstanceS("timer"))); + getVm(getSys())->addEvent(_MR(this),_MR(Class<TimerEvent>::getInstanceS(getSys(),"timer"))); currentCount++; if(repeatCount!=0) @@ -42,7 +42,7 @@ if(currentCount==repeatCount) { this->incRef(); - getVm()->addEvent(_MR(this),_MR(Class<TimerEvent>::getInstanceS("timerComplete"))); + getVm(getSys())->addEvent(_MR(this),_MR(Class<TimerEvent>::getInstanceS(getSys(),"timerComplete"))); stopMe=true; running=false; } @@ -58,15 +58,15 @@ void Timer::sinit(Class_base* c) { CLASS_SETUP(c, EventDispatcher, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("currentCount","",Class<IFunction>::getFunction(_getCurrentCount),GETTER_METHOD,true); - c->setDeclaredMethodByQName("repeatCount","",Class<IFunction>::getFunction(_getRepeatCount),GETTER_METHOD,true); - c->setDeclaredMethodByQName("repeatCount","",Class<IFunction>::getFunction(_setRepeatCount),SETTER_METHOD,true); - c->setDeclaredMethodByQName("running","",Class<IFunction>::getFunction(_getRunning),GETTER_METHOD,true); - c->setDeclaredMethodByQName("delay","",Class<IFunction>::getFunction(_getDelay),GETTER_METHOD,true); - c->setDeclaredMethodByQName("delay","",Class<IFunction>::getFunction(_setDelay),SETTER_METHOD,true); - c->setDeclaredMethodByQName("start","",Class<IFunction>::getFunction(start),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("reset","",Class<IFunction>::getFunction(reset),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("stop","",Class<IFunction>::getFunction(stop),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("currentCount","",Class<IFunction>::getFunction(c->getSystemState(),_getCurrentCount),GETTER_METHOD,true); + c->setDeclaredMethodByQName("repeatCount","",Class<IFunction>::getFunction(c->getSystemState(),_getRepeatCount),GETTER_METHOD,true); + c->setDeclaredMethodByQName("repeatCount","",Class<IFunction>::getFunction(c->getSystemState(),_setRepeatCount),SETTER_METHOD,true); + c->setDeclaredMethodByQName("running","",Class<IFunction>::getFunction(c->getSystemState(),_getRunning),GETTER_METHOD,true); + c->setDeclaredMethodByQName("delay","",Class<IFunction>::getFunction(c->getSystemState(),_getDelay),GETTER_METHOD,true); + c->setDeclaredMethodByQName("delay","",Class<IFunction>::getFunction(c->getSystemState(),_setDelay),SETTER_METHOD,true); + c->setDeclaredMethodByQName("start","",Class<IFunction>::getFunction(c->getSystemState(),start),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("reset","",Class<IFunction>::getFunction(c->getSystemState(),reset),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("stop","",Class<IFunction>::getFunction(c->getSystemState(),stop),NORMAL_METHOD,true); } ASFUNCTIONBODY(Timer,_constructor) @@ -84,13 +84,13 @@ ASFUNCTIONBODY(Timer,_getCurrentCount) { Timer* th=static_cast<Timer*>(obj); - return abstract_i(th->currentCount); + return abstract_i(obj->getSystemState(),th->currentCount); } ASFUNCTIONBODY(Timer,_getRepeatCount) { Timer* th=static_cast<Timer*>(obj); - return abstract_i(th->repeatCount); + return abstract_i(obj->getSystemState(),th->repeatCount); } ASFUNCTIONBODY(Timer,_setRepeatCount) @@ -111,13 +111,13 @@ ASFUNCTIONBODY(Timer,_getRunning) { Timer* th=static_cast<Timer*>(obj); - return abstract_b(th->running); + return abstract_b(obj->getSystemState(),th->running); } ASFUNCTIONBODY(Timer,_getDelay) { Timer* th=static_cast<Timer*>(obj); - return abstract_i(th->delay); + return abstract_i(obj->getSystemState(),th->delay); } ASFUNCTIONBODY(Timer,_setDelay) @@ -125,7 +125,7 @@ assert_and_throw(argslen==1); int32_t newdelay = args[0]->toInt(); if (newdelay<=0) - throw Class<RangeError>::getInstanceS("delay must be positive", 2066); + throw Class<RangeError>::getInstanceS(obj->getSystemState(),"delay must be positive", 2066); Timer* th=static_cast<Timer*>(obj); th->delay=newdelay;
View file
lightspark.tar.xz/src/scripting/flash/utils/flashutils.cpp
Changed
@@ -40,8 +40,8 @@ void Endian::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("LITTLE_ENDIAN","",Class<ASString>::getInstanceS(littleEndian),DECLARED_TRAIT); - c->setVariableByQName("BIG_ENDIAN","",Class<ASString>::getInstanceS(bigEndian),DECLARED_TRAIT); + c->setVariableByQName("LITTLE_ENDIAN","",abstract_s(c->getSystemState(),littleEndian),DECLARED_TRAIT); + c->setVariableByQName("BIG_ENDIAN","",abstract_s(c->getSystemState(),bigEndian),DECLARED_TRAIT); } void IExternalizable::linkTraits(Class_base* c) @@ -98,10 +98,10 @@ Class_base* c; SWFOBJECT_TYPE otype=target->getObjectType(); if(otype==T_NULL) - return Class<ASString>::getInstanceS("null"); + return abstract_s(target->getSystemState(),"null"); else if(otype==T_UNDEFINED) // Testing shows that this really returns "void"! - return Class<ASString>::getInstanceS("void"); + return abstract_s(target->getSystemState(),"void"); else if(otype!=T_CLASS) { assert_and_throw(target->getClass()); @@ -110,7 +110,7 @@ else c=static_cast<Class_base*>(target); - return Class<ASString>::getInstanceS(c->getQualifiedClassName()); + return abstract_s(obj->getSystemState(),c->getQualifiedClassName()); } ASFUNCTIONBODY(lightspark,getQualifiedSuperclassName) @@ -127,9 +127,9 @@ c=static_cast<Class_base*>(target)->super.getPtr(); if (!c) - return getSys()->getNullRef(); + return target->getSystemState()->getNullRef(); - return Class<ASString>::getInstanceS(c->getQualifiedClassName()); + return abstract_s(obj->getSystemState(),c->getQualifiedClassName()); } ASFUNCTIONBODY(lightspark,getDefinitionByName) @@ -142,12 +142,12 @@ tiny_string nsName; tiny_string tmpName; stringToQName(tmp,tmpName,nsName); - name.name_s_id=getSys()->getUniqueStringId(tmpName); - name.ns.push_back(nsNameAndKind(nsName,NAMESPACE)); + name.name_s_id=args[0]->getSystemState()->getUniqueStringId(tmpName); + name.ns.push_back(nsNameAndKind(args[0]->getSystemState(),nsName,NAMESPACE)); LOG(LOG_CALLS,_("Looking for definition of ") << name); ASObject* target; - ASObject* o=ABCVm::getCurrentApplicationDomain(getVm()->currentCallContext)->getVariableAndTargetByMultiname(name,target); + ASObject* o=ABCVm::getCurrentApplicationDomain(getVm(args[0]->getSystemState())->currentCallContext)->getVariableAndTargetByMultiname(name,target); if(o==NULL) { @@ -169,8 +169,8 @@ ASFUNCTIONBODY(lightspark,getTimer) { - uint64_t ret=compat_msectiming() - getSys()->startTime; - return abstract_i(ret); + uint64_t ret=compat_msectiming() - obj->getSystemState()->startTime; + return abstract_i(obj->getSystemState(),ret); } @@ -192,9 +192,9 @@ args[0]->incRef(); IFunction* callback=static_cast<IFunction*>(args[0]); //Add interval through manager - uint32_t id = getSys()->intervalManager->setInterval(_MR(callback), callbackArgs, argslen-2, - _MR(getSys()->getNullRef()), args[1]->toInt()); - return abstract_i(id); + uint32_t id = args[0]->getSystemState()->intervalManager->setInterval(_MR(callback), callbackArgs, argslen-2, + _MR(args[0]->getSystemState()->getNullRef()), args[1]->toInt()); + return abstract_i(args[0]->getSystemState(),id); } ASFUNCTIONBODY(lightspark,setTimeout) @@ -215,22 +215,22 @@ args[0]->incRef(); IFunction* callback=static_cast<IFunction*>(args[0]); //Add timeout through manager - uint32_t id = getSys()->intervalManager->setTimeout(_MR(callback), callbackArgs, argslen-2, - _MR(getSys()->getNullRef()), args[1]->toInt()); - return abstract_i(id); + uint32_t id = args[0]->getSystemState()->intervalManager->setTimeout(_MR(callback), callbackArgs, argslen-2, + _MR(args[0]->getSystemState()->getNullRef()), args[1]->toInt()); + return abstract_i(args[0]->getSystemState(),id); } ASFUNCTIONBODY(lightspark,clearInterval) { assert_and_throw(argslen == 1); - getSys()->intervalManager->clearInterval(args[0]->toInt(), IntervalRunner::INTERVAL, true); + args[0]->getSystemState()->intervalManager->clearInterval(args[0]->toInt(), IntervalRunner::INTERVAL, true); return NULL; } ASFUNCTIONBODY(lightspark,clearTimeout) { assert_and_throw(argslen == 1); - getSys()->intervalManager->clearInterval(args[0]->toInt(), IntervalRunner::TIMEOUT, true); + args[0]->getSystemState()->intervalManager->clearInterval(args[0]->toInt(), IntervalRunner::TIMEOUT, true); return NULL; } @@ -238,11 +238,11 @@ { tiny_string str; ARG_UNPACK (str, "undefined"); - return Class<ASString>::getInstanceS(URLInfo::encode(str, URLInfo::ENCODE_ESCAPE)); + return abstract_s(getSys(),URLInfo::encode(str, URLInfo::ENCODE_ESCAPE)); } ASFUNCTIONBODY(lightspark,unescapeMultiByte) { tiny_string str; ARG_UNPACK (str, "undefined"); - return Class<ASString>::getInstanceS(URLInfo::decode(str, URLInfo::ENCODE_ESCAPE)); + return abstract_s(getSys(),URLInfo::decode(str, URLInfo::ENCODE_ESCAPE)); }
View file
lightspark.tar.xz/src/scripting/flash/xml/flashxml.cpp
Changed
@@ -40,19 +40,19 @@ void XMLNode::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("attributes","",Class<IFunction>::getFunction(attributes),GETTER_METHOD,true); - c->setDeclaredMethodByQName("childNodes","",Class<IFunction>::getFunction(XMLNode::childNodes),GETTER_METHOD,true); - c->setDeclaredMethodByQName("firstChild","",Class<IFunction>::getFunction(XMLNode::firstChild),GETTER_METHOD,true); - c->setDeclaredMethodByQName("lastChild","",Class<IFunction>::getFunction(lastChild),GETTER_METHOD,true); - c->setDeclaredMethodByQName("nextSibling","",Class<IFunction>::getFunction(nextSibling),GETTER_METHOD,true); - c->setDeclaredMethodByQName("nodeType","",Class<IFunction>::getFunction(_getNodeType),GETTER_METHOD,true); - c->setDeclaredMethodByQName("nodeName","",Class<IFunction>::getFunction(_getNodeName),GETTER_METHOD,true); - c->setDeclaredMethodByQName("nodeValue","",Class<IFunction>::getFunction(_getNodeValue),GETTER_METHOD,true); - c->setDeclaredMethodByQName("parentNode","",Class<IFunction>::getFunction(parentNode),GETTER_METHOD,true); - c->setDeclaredMethodByQName("previousSibling","",Class<IFunction>::getFunction(previousSibling),GETTER_METHOD,true); - c->setDeclaredMethodByQName("localName","",Class<IFunction>::getFunction(_getLocalName),GETTER_METHOD,true); - c->setDeclaredMethodByQName("appendChild","",Class<IFunction>::getFunction(appendChild),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("attributes","",Class<IFunction>::getFunction(c->getSystemState(),attributes),GETTER_METHOD,true); + c->setDeclaredMethodByQName("childNodes","",Class<IFunction>::getFunction(c->getSystemState(),XMLNode::childNodes),GETTER_METHOD,true); + c->setDeclaredMethodByQName("firstChild","",Class<IFunction>::getFunction(c->getSystemState(),XMLNode::firstChild),GETTER_METHOD,true); + c->setDeclaredMethodByQName("lastChild","",Class<IFunction>::getFunction(c->getSystemState(),lastChild),GETTER_METHOD,true); + c->setDeclaredMethodByQName("nextSibling","",Class<IFunction>::getFunction(c->getSystemState(),nextSibling),GETTER_METHOD,true); + c->setDeclaredMethodByQName("nodeType","",Class<IFunction>::getFunction(c->getSystemState(),_getNodeType),GETTER_METHOD,true); + c->setDeclaredMethodByQName("nodeName","",Class<IFunction>::getFunction(c->getSystemState(),_getNodeName),GETTER_METHOD,true); + c->setDeclaredMethodByQName("nodeValue","",Class<IFunction>::getFunction(c->getSystemState(),_getNodeValue),GETTER_METHOD,true); + c->setDeclaredMethodByQName("parentNode","",Class<IFunction>::getFunction(c->getSystemState(),parentNode),GETTER_METHOD,true); + c->setDeclaredMethodByQName("previousSibling","",Class<IFunction>::getFunction(c->getSystemState(),previousSibling),GETTER_METHOD,true); + c->setDeclaredMethodByQName("localName","",Class<IFunction>::getFunction(c->getSystemState(),_getLocalName),GETTER_METHOD,true); + c->setDeclaredMethodByQName("appendChild","",Class<IFunction>::getFunction(c->getSystemState(),appendChild),NORMAL_METHOD,true); } void XMLNode::buildTraits(ASObject* o) @@ -68,7 +68,7 @@ tiny_string value; ARG_UNPACK(type)(value); assert_and_throw(type==1); - th->root=_MR(Class<XMLDocument>::getInstanceS()); + th->root=_MR(Class<XMLDocument>::getInstanceS(obj->getSystemState())); if(type==1) { th->root->parseXMLImpl(value); @@ -87,7 +87,7 @@ if(newNode.type() == pugi::node_null) return getSys()->getNullRef(); assert_and_throw(!th->root.isNull()); - return Class<XMLNode>::getInstanceS(th->root,newNode); + return Class<XMLNode>::getInstanceS(obj->getSystemState(),th->root,newNode); } ASFUNCTIONBODY(XMLNode,lastChild) @@ -100,13 +100,13 @@ if(newNode.type() == pugi::node_null) return getSys()->getNullRef(); assert_and_throw(!th->root.isNull()); - return Class<XMLNode>::getInstanceS(th->root,newNode); + return Class<XMLNode>::getInstanceS(obj->getSystemState(),th->root,newNode); } ASFUNCTIONBODY(XMLNode,childNodes) { XMLNode* th=Class<XMLNode>::cast(obj); - Array* ret = Class<Array>::getInstanceS(); + Array* ret = Class<Array>::getInstanceS(obj->getSystemState()); assert_and_throw(argslen==0); if(th->node.type()==pugi::node_null) return ret; @@ -115,7 +115,7 @@ for(;it!=th->node.end();++it) { if(it->type()!=pugi::node_pcdata) { - ret->push(_MR(Class<XMLNode>::getInstanceS(th->root, *it))); + ret->push(_MR(Class<XMLNode>::getInstanceS(obj->getSystemState(),th->root, *it))); } } return ret; @@ -126,14 +126,14 @@ { XMLNode* th=Class<XMLNode>::cast(obj); assert_and_throw(argslen==0); - ASObject* ret=Class<ASObject>::getInstanceS(); + ASObject* ret=Class<ASObject>::getInstanceS(obj->getSystemState()); if(th->node.type()==pugi::node_null) return ret; auto it=th->node.attributes_begin(); for(;it!=th->node.attributes_end();++it) { tiny_string attrName = it->name(); - ASString* attrValue=Class<ASString>::getInstanceS(it->value()); + ASString* attrValue=abstract_s(obj->getSystemState(),it->value()); ret->setVariableByQName(attrName,"",attrValue,DYNAMIC_TRAIT); } return ret; @@ -149,7 +149,7 @@ XMLNode* th=Class<XMLNode>::cast(obj); pugi::xml_node parent = th->getParentNode(); if (parent.type()!=pugi::node_null) - return Class<XMLNode>::getInstanceS(th->root, parent); + return Class<XMLNode>::getInstanceS(obj->getSystemState(),th->root, parent); else return getSys()->getNullRef(); } @@ -162,7 +162,7 @@ pugi::xml_node sibling = th->node.next_sibling(); if (sibling.type()!=pugi::node_null) - return Class<XMLNode>::getInstanceS(th->root, sibling); + return Class<XMLNode>::getInstanceS(obj->getSystemState(),th->root, sibling); else return getSys()->getNullRef(); } @@ -175,7 +175,7 @@ pugi::xml_node sibling = th->node.previous_sibling(); if (sibling.type()!=pugi::node_null) - return Class<XMLNode>::getInstanceS(th->root, sibling); + return Class<XMLNode>::getInstanceS(obj->getSystemState(),th->root, sibling); else return getSys()->getNullRef(); } @@ -205,20 +205,20 @@ LOG(LOG_NOT_IMPLEMENTED,"XMLNode.getNodeType: unhandled type:"<<th->node.type()); break; } - return abstract_i(t); + return abstract_i(obj->getSystemState(),t); } ASFUNCTIONBODY(XMLNode,_getNodeName) { XMLNode* th=Class<XMLNode>::cast(obj); - return Class<ASString>::getInstanceS(th->node.name()); + return abstract_s(obj->getSystemState(),th->node.name()); } ASFUNCTIONBODY(XMLNode,_getNodeValue) { XMLNode* th=Class<XMLNode>::cast(obj); if(th->node.type() == pugi::node_pcdata) - return Class<ASString>::getInstanceS(th->node.value()); + return abstract_s(obj->getSystemState(),th->node.value()); else return getSys()->getNullRef(); } @@ -226,7 +226,7 @@ ASFUNCTIONBODY(XMLNode,_toString) { XMLNode* th=Class<XMLNode>::cast(obj); - return Class<ASString>::getInstanceS(th->toString_priv(th->node)); + return abstract_s(obj->getSystemState(),th->toString_priv(th->node)); } ASFUNCTIONBODY(XMLNode,_getLocalName) @@ -238,7 +238,7 @@ { localname = localname.substr(pos,localname.numChars()-pos); } - return Class<ASString>::getInstanceS(localname); + return abstract_s(obj->getSystemState(),localname); } ASFUNCTIONBODY(XMLNode,appendChild) { @@ -289,10 +289,10 @@ void XMLDocument::sinit(Class_base* c) { CLASS_SETUP(c, XMLNode, _constructor, CLASS_SEALED); - c->setDeclaredMethodByQName("parseXML","",Class<IFunction>::getFunction(parseXML),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("firstChild","",Class<IFunction>::getFunction(XMLDocument::firstChild),GETTER_METHOD,true); - c->setDeclaredMethodByQName("createElement","",Class<IFunction>::getFunction(XMLDocument::createElement),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("parseXML","",Class<IFunction>::getFunction(c->getSystemState(),parseXML),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("firstChild","",Class<IFunction>::getFunction(c->getSystemState(),XMLDocument::firstChild),GETTER_METHOD,true); + c->setDeclaredMethodByQName("createElement","",Class<IFunction>::getFunction(c->getSystemState(),XMLDocument::createElement),NORMAL_METHOD,true); REGISTER_GETTER_SETTER(c, ignoreWhite); } @@ -340,7 +340,7 @@ //TODO: should output xmlDecl and docTypeDecl, see the //documentation on XMLNode.tostring() XMLDocument* th=Class<XMLDocument>::cast(obj); - return Class<ASString>::getInstanceS(th->toString_priv(th->rootNode)); + return abstract_s(obj->getSystemState(),th->toString_priv(th->rootNode)); } tiny_string XMLDocument::toString() @@ -364,7 +364,7 @@ assert(th->node==NULL); pugi::xml_node newNode=th->rootNode; th->incRef(); - return Class<XMLNode>::getInstanceS(_MR(th),newNode); + return Class<XMLNode>::getInstanceS(obj->getSystemState(),_MR(th),newNode); } ASFUNCTIONBODY(XMLDocument,createElement) { @@ -375,5 +375,5 @@ pugi::xml_node newNode; newNode.set_name(name.raw_buf()); th->incRef(); - return Class<XMLNode>::getInstanceS(_MR(th),newNode); + return Class<XMLNode>::getInstanceS(obj->getSystemState(),_MR(th),newNode); }
View file
lightspark.tar.xz/src/scripting/toplevel/ASString.cpp
Changed
@@ -72,59 +72,59 @@ { // fast path if obj is ASString if (obj->is<ASString>()) - return abstract_i(obj->as<ASString>()->data.numChars()); - return abstract_i(obj->toString().numChars()); + return abstract_i(obj->getSystemState(),obj->as<ASString>()->data.numChars()); + return abstract_i(obj->getSystemState(),obj->toString().numChars()); } void ASString::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL | CLASS_SEALED); c->isReusable = true; - c->setDeclaredMethodByQName("split",AS3,Class<IFunction>::getFunction(split,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("substr",AS3,Class<IFunction>::getFunction(substr,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("substring",AS3,Class<IFunction>::getFunction(substring,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("replace",AS3,Class<IFunction>::getFunction(replace),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("concat",AS3,Class<IFunction>::getFunction(concat),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("match",AS3,Class<IFunction>::getFunction(match),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("search",AS3,Class<IFunction>::getFunction(search),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("indexOf",AS3,Class<IFunction>::getFunction(indexOf,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("lastIndexOf",AS3,Class<IFunction>::getFunction(lastIndexOf,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("charCodeAt",AS3,Class<IFunction>::getFunction(charCodeAt),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("charAt",AS3,Class<IFunction>::getFunction(charAt,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("slice",AS3,Class<IFunction>::getFunction(slice,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toLocaleLowerCase",AS3,Class<IFunction>::getFunction(toLowerCase),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toLocaleUpperCase",AS3,Class<IFunction>::getFunction(toUpperCase),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toLowerCase",AS3,Class<IFunction>::getFunction(toLowerCase),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toUpperCase",AS3,Class<IFunction>::getFunction(toUpperCase),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("localeCompare",AS3,Class<IFunction>::getFunction(localeCompare),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("split",AS3,Class<IFunction>::getFunction(c->getSystemState(),split,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("substr",AS3,Class<IFunction>::getFunction(c->getSystemState(),substr,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("substring",AS3,Class<IFunction>::getFunction(c->getSystemState(),substring,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("replace",AS3,Class<IFunction>::getFunction(c->getSystemState(),replace),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("concat",AS3,Class<IFunction>::getFunction(c->getSystemState(),concat),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("match",AS3,Class<IFunction>::getFunction(c->getSystemState(),match),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("search",AS3,Class<IFunction>::getFunction(c->getSystemState(),search),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("indexOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),indexOf,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("lastIndexOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),lastIndexOf,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("charCodeAt",AS3,Class<IFunction>::getFunction(c->getSystemState(),charCodeAt),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("charAt",AS3,Class<IFunction>::getFunction(c->getSystemState(),charAt,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("slice",AS3,Class<IFunction>::getFunction(c->getSystemState(),slice,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toLocaleLowerCase",AS3,Class<IFunction>::getFunction(c->getSystemState(),toLowerCase),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toLocaleUpperCase",AS3,Class<IFunction>::getFunction(c->getSystemState(),toUpperCase),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toLowerCase",AS3,Class<IFunction>::getFunction(c->getSystemState(),toLowerCase),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toUpperCase",AS3,Class<IFunction>::getFunction(c->getSystemState(),toUpperCase),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("localeCompare",AS3,Class<IFunction>::getFunction(c->getSystemState(),localeCompare),NORMAL_METHOD,true); // According to specs fromCharCode belongs to AS3 namespace, // but also empty namespace is seen in the wild and should be // supported. - c->setDeclaredMethodByQName("fromCharCode",AS3,Class<IFunction>::getFunction(fromCharCode),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("fromCharCode","",Class<IFunction>::getFunction(fromCharCode),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(_getLength),GETTER_METHOD,true); - c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - - c->prototype->setVariableByQName("split","",Class<IFunction>::getFunction(split,2),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("substr","",Class<IFunction>::getFunction(substr,2),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("substring","",Class<IFunction>::getFunction(substring,2),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("replace","",Class<IFunction>::getFunction(replace),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("concat","",Class<IFunction>::getFunction(concat),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("match","",Class<IFunction>::getFunction(match),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("search","",Class<IFunction>::getFunction(search),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("indexOf","",Class<IFunction>::getFunction(indexOf,2),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("lastIndexOf","",Class<IFunction>::getFunction(lastIndexOf,2),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("charCodeAt","",Class<IFunction>::getFunction(charCodeAt),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("charAt","",Class<IFunction>::getFunction(charAt,1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("slice","",Class<IFunction>::getFunction(slice,2),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toLocaleLowerCase","",Class<IFunction>::getFunction(toLowerCase),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toLocaleUpperCase","",Class<IFunction>::getFunction(toUpperCase),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toLowerCase","",Class<IFunction>::getFunction(toLowerCase),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toUpperCase","",Class<IFunction>::getFunction(toUpperCase),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("localeCompare","",Class<IFunction>::getFunction(localeCompare_prototype),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("fromCharCode",AS3,Class<IFunction>::getFunction(c->getSystemState(),fromCharCode),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("fromCharCode","",Class<IFunction>::getFunction(c->getSystemState(),fromCharCode),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(c->getSystemState(),_getLength),GETTER_METHOD,true); + c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + + c->prototype->setVariableByQName("split","",Class<IFunction>::getFunction(c->getSystemState(),split,2),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("substr","",Class<IFunction>::getFunction(c->getSystemState(),substr,2),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("substring","",Class<IFunction>::getFunction(c->getSystemState(),substring,2),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("replace","",Class<IFunction>::getFunction(c->getSystemState(),replace),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("concat","",Class<IFunction>::getFunction(c->getSystemState(),concat),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("match","",Class<IFunction>::getFunction(c->getSystemState(),match),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("search","",Class<IFunction>::getFunction(c->getSystemState(),search),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("indexOf","",Class<IFunction>::getFunction(c->getSystemState(),indexOf,2),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("lastIndexOf","",Class<IFunction>::getFunction(c->getSystemState(),lastIndexOf,2),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("charCodeAt","",Class<IFunction>::getFunction(c->getSystemState(),charCodeAt),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("charAt","",Class<IFunction>::getFunction(c->getSystemState(),charAt,1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("slice","",Class<IFunction>::getFunction(c->getSystemState(),slice,2),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toLocaleLowerCase","",Class<IFunction>::getFunction(c->getSystemState(),toLowerCase),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toLocaleUpperCase","",Class<IFunction>::getFunction(c->getSystemState(),toUpperCase),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toLowerCase","",Class<IFunction>::getFunction(c->getSystemState(),toLowerCase),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toUpperCase","",Class<IFunction>::getFunction(c->getSystemState(),toUpperCase),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("localeCompare","",Class<IFunction>::getFunction(c->getSystemState(),localeCompare_prototype),DYNAMIC_TRAIT); } void ASString::buildTraits(ASObject* o) @@ -136,11 +136,11 @@ tiny_string data = obj->toString(); int ret = -1; if(argslen == 0 || args[0]->getObjectType() == T_UNDEFINED) - return abstract_i(-1); + return abstract_i(obj->getSystemState(),-1); int options=PCRE_UTF8|PCRE_NEWLINE_ANY;//|PCRE_JAVASCRIPT_COMPAT; tiny_string restr; - if(args[0]->getClass() && args[0]->getClass()==Class<RegExp>::getClass()) + if(args[0]->getClass() && args[0]->getClass()==Class<RegExp>::getClass(obj->getSystemState())) { RegExp* re=static_cast<RegExp*>(args[0]); restr = re->source; @@ -162,13 +162,13 @@ int errorOffset; pcre* pcreRE=pcre_compile(restr.raw_buf(), options, &error, &errorOffset,NULL); if(error) - return abstract_i(ret); + return abstract_i(obj->getSystemState(),ret); int capturingGroups; int infoOk=pcre_fullinfo(pcreRE, NULL, PCRE_INFO_CAPTURECOUNT, &capturingGroups); if(infoOk!=0) { pcre_free(pcreRE); - return abstract_i(ret); + return abstract_i(obj->getSystemState(),ret); } pcre_extra extra; extra.match_limit_recursion=200; @@ -181,37 +181,37 @@ { //No matches or error pcre_free(pcreRE); - return abstract_i(ret); + return abstract_i(obj->getSystemState(),ret); } ret=ovector[0]; // pcre_exec returns byte position, so we have to convert it to character position tiny_string tmp = data.substr_bytes(0, ret); ret = tmp.numChars(); pcre_free(pcreRE); - return abstract_i(ret); + return abstract_i(obj->getSystemState(),ret); } ASFUNCTIONBODY(ASString,match) { tiny_string data = obj->toString(); if(argslen == 0 || args[0]->getObjectType()==T_NULL || args[0]->getObjectType()==T_UNDEFINED) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); ASObject* ret=NULL; RegExp* re; - if(args[0]->getClass() && args[0]->getClass()==Class<RegExp>::getClass()) + if(args[0]->getClass() && args[0]->getClass()==Class<RegExp>::getClass(obj->getSystemState())) { re = args[0]->as<RegExp>(); re->incRef(); } else { - re = Class<RegExp>::getInstanceS(args[0]->toString()); + re = Class<RegExp>::getInstanceS(obj->getSystemState(),args[0]->toString()); } if (re->global) { - Array *resarr = Class<Array>::getInstanceS(); + Array *resarr = Class<Array>::getInstanceS(obj->getSystemState()); int prevLastIndex = 0; re->lastIndex = 0; @@ -253,12 +253,12 @@ ASFUNCTIONBODY(ASString,_toString) { - if(Class<ASString>::getClass()->prototype->getObj() == obj) - return abstract_s(); + if(Class<ASString>::getClass(obj->getSystemState())->prototype->getObj() == obj) + return abstract_s(obj->getSystemState()); if(!obj->is<ASString>()) { LOG(LOG_ERROR,"String.toString is not generic:"<<obj->toDebugString()); - throw Class<TypeError>::getInstanceS("String.toString is not generic"); + throw Class<TypeError>::getInstanceS(obj->getSystemState(),"String.toString is not generic"); } assert_and_throw(argslen==0); @@ -270,18 +270,18 @@ ASFUNCTIONBODY(ASString,split) { tiny_string data = obj->toString(); - Array* ret=Class<Array>::getInstanceS(); + Array* ret=Class<Array>::getInstanceS(obj->getSystemState()); uint32_t limit = 0x7fffffff; if(argslen == 0 ) { - ret->push(_MR(abstract_s(data))); + ret->push(_MR(abstract_s(obj->getSystemState(),data))); return ret; } if (argslen > 1 && !args[1]->is<Undefined>()) limit = args[1]->toUInt(); if (limit == 0) return ret; - if(args[0]->getClass() && args[0]->getClass()==Class<RegExp>::getClass()) + if(args[0]->getClass() && args[0]->getClass()==Class<RegExp>::getClass(obj->getSystemState())) { RegExp* re=static_cast<RegExp*>(args[0]); @@ -292,7 +292,7 @@ { if (ret->size() >= limit) break; - ret->push(_MR(abstract_s( tiny_string::fromChar(*i) ) )); + ret->push(_MR(abstract_s(obj->getSystemState(), tiny_string::fromChar(*i) ) )); } return ret; } @@ -327,7 +327,7 @@ continue; } //Extract string from last match until the beginning of the current match - ASString* s=abstract_s(data.substr_bytes(lastMatch,end-lastMatch)); + ASString* s=abstract_s(obj->getSystemState(),data.substr_bytes(lastMatch,end-lastMatch)); if (ret->size() >= limit) break; ret->push(_MR(s)); @@ -339,14 +339,14 @@ if (ret->size() >= limit) break; //use string interface through raw(), because we index on bytes, not on UTF-8 characters - ASString* s=abstract_s(data.substr_bytes(ovector[i*2],ovector[i*2+1]-ovector[i*2])); + ASString* s=abstract_s(obj->getSystemState(),data.substr_bytes(ovector[i*2],ovector[i*2+1]-ovector[i*2])); ret->push(_MR(s)); } } while(end<data.numBytes() && ret->size() < limit); if(ret->size() < limit && lastMatch != data.numBytes()+1) { - ASString* s=abstract_s(data.substr_bytes(lastMatch,data.numBytes()-lastMatch)); + ASString* s=abstract_s(obj->getSystemState(),data.substr_bytes(lastMatch,data.numBytes()-lastMatch)); ret->push(_MR(s)); } pcre_free(pcreRE); @@ -360,7 +360,7 @@ if (data.numChars() == 0) { - ret->push(_MR(abstract_s())); + ret->push(_MR(abstract_s(obj->getSystemState()))); } uint32_t j = 0; for(auto i=data.begin();i!=data.end();++i) @@ -368,7 +368,7 @@ if (j >= limit) break; j++; - ret->push(_MR(abstract_s( tiny_string::fromChar(*i) ) )); + ret->push(_MR(abstract_s(obj->getSystemState(), tiny_string::fromChar(*i) ) )); } return ret; } @@ -381,13 +381,13 @@ match++; if(match==-1) match= len; - ASString* s=abstract_s(data.substr(start,(match-start))); + ASString* s=abstract_s(obj->getSystemState(),data.substr(start,(match-start))); if (ret->size() >= limit) break; ret->push(_MR(s)); start=match+del.numChars(); if (start == len) - ret->push(_MR(abstract_s())); + ret->push(_MR(abstract_s(obj->getSystemState()))); } while(start<len && ret->size() < limit); } @@ -404,7 +404,7 @@ if (!std::isnan(args[0]->toNumber())) start=args[0]->toInt(); if (start >= 0 && std::isinf(args[0]->toNumber())) - return abstract_s(); + return abstract_s(obj->getSystemState()); } if(start<0) { start=data.numChars()+start; @@ -425,7 +425,7 @@ else len=args[1]->toInt(); } - return abstract_s(data.substr(start,len)); + return abstract_s(obj->getSystemState(),data.substr(start,len)); } ASFUNCTIONBODY(ASString,substring) @@ -450,7 +450,7 @@ end=tmp; } - return abstract_s(data.substr(start,end-start)); + return abstract_s(obj->getSystemState(),data.substr(start,end-start)); } tiny_string ASString::toString_priv() const @@ -458,10 +458,7 @@ return data; } -/* Note that toNumber() is not virtual. - * ASString::toNumber is directly called by ASObject::toNumber - */ -double ASString::toNumber() const +number_t ASString::toNumber() { assert_and_throw(implEnable); @@ -626,9 +623,9 @@ if(endIndex>(int)data.numChars()) endIndex=data.numChars(); if(endIndex<=startIndex) - return abstract_s(); + return abstract_s(obj->getSystemState()); else - return abstract_s(data.substr(startIndex,endIndex-startIndex)); + return abstract_s(obj->getSystemState(),data.substr(startIndex,endIndex-startIndex)); } ASFUNCTIONBODY(ASString,charAt) @@ -641,15 +638,15 @@ int maxIndex=obj->as<ASString>()->data.numChars(); if(index<0 || index>=maxIndex || std::isinf(index)) - return abstract_s(); - return abstract_s( tiny_string::fromChar(obj->as<ASString>()->data.charAt(index)) ); + return abstract_s(obj->getSystemState()); + return abstract_s(obj->getSystemState(), tiny_string::fromChar(obj->as<ASString>()->data.charAt(index)) ); } tiny_string data = obj->toString(); int maxIndex=data.numChars(); if(index<0 || index>=maxIndex || std::isinf(index)) - return abstract_s(); - return abstract_s( tiny_string::fromChar(data.charAt(index)) ); + return abstract_s(obj->getSystemState()); + return abstract_s(obj->getSystemState(), tiny_string::fromChar(data.charAt(index)) ); } ASFUNCTIONBODY(ASString,charCodeAt) @@ -661,23 +658,23 @@ if (obj->is<ASString>()) { if(index<0 || index>=obj->as<ASString>()->data.numChars() || std::isinf(index) || std::isnan(index)) - return abstract_d(Number::NaN); - return abstract_i(obj->as<ASString>()->data.charAt(index)); + return abstract_d(obj->getSystemState(),Number::NaN); + return abstract_i(obj->getSystemState(),obj->as<ASString>()->data.charAt(index)); } tiny_string data = obj->toString(); if(index<0 || index>=data.numChars() || std::isinf(index) || std::isnan(index)) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); else { //Character codes are expected to be positive - return abstract_i(data.charAt(index)); + return abstract_i(obj->getSystemState(),data.charAt(index)); } } ASFUNCTIONBODY(ASString,indexOf) { if (argslen == 0) - return abstract_i(-1); + return abstract_i(obj->getSystemState(),-1); tiny_string data = obj->toString(); tiny_string arg0=args[0]->toString(); int startIndex=0; @@ -687,9 +684,9 @@ size_t pos = data.find(arg0.raw_buf(), startIndex); if(pos == data.npos) - return abstract_i(-1); + return abstract_i(obj->getSystemState(),-1); else - return abstract_i(pos); + return abstract_i(obj->getSystemState(),pos); } ASFUNCTIONBODY(ASString,lastIndexOf) @@ -702,7 +699,7 @@ { int32_t i = args[1]->toInt(); if(i<0) - return abstract_i(-1); + return abstract_i(obj->getSystemState(),-1); startIndex = i; } @@ -710,21 +707,21 @@ size_t pos=data.rfind(val.raw_buf(), startIndex); if(pos==data.npos) - return abstract_i(-1); + return abstract_i(obj->getSystemState(),-1); else - return abstract_i(pos); + return abstract_i(obj->getSystemState(),pos); } ASFUNCTIONBODY(ASString,toLowerCase) { tiny_string data = obj->toString(); - return abstract_s(data.lowercase()); + return abstract_s(obj->getSystemState(),data.lowercase()); } ASFUNCTIONBODY(ASString,toUpperCase) { tiny_string data = obj->toString(); - return abstract_s(data.uppercase()); + return abstract_s(obj->getSystemState(),data.uppercase()); } ASFUNCTIONBODY(ASString,localeCompare) { @@ -734,7 +731,7 @@ if (argslen > 1) LOG(LOG_NOT_IMPLEMENTED,"localeCompare with more than one parameter not implemented"); int ret = data.compare(other); - return abstract_i(ret); + return abstract_i(obj->getSystemState(),ret); } ASFUNCTIONBODY(ASString,localeCompare_prototype) { @@ -745,12 +742,12 @@ throwError<ArgumentError>(kWrongArgumentCountError, "localeCompare", "1",Integer::toString(argslen)); int ret = data.compare(other); - return abstract_i(ret); + return abstract_i(obj->getSystemState(),ret); } ASFUNCTIONBODY(ASString,fromCharCode) { - ASString* ret=abstract_s(); + ASString* ret=abstract_s(obj->getSystemState()); for(uint32_t i=0;i<argslen;i++) { ret->data += tiny_string::fromChar(args[i]->toUInt16()); @@ -763,7 +760,7 @@ tiny_string data = obj->toString(); enum REPLACE_TYPE { STRING=0, FUNC }; REPLACE_TYPE type; - ASString* ret=abstract_s(data); + ASString* ret=abstract_s(obj->getSystemState(),data); tiny_string replaceWith; if(argslen < 2) @@ -781,7 +778,7 @@ replaceWith=args[1]->toString(); type = FUNC; } - if(args[0]->getClass()==Class<RegExp>::getClass()) + if(args[0]->getClass()==Class<RegExp>::getClass(obj->getSystemState())) { RegExp* re=static_cast<RegExp*>(args[0]); @@ -820,13 +817,13 @@ IFunction* f=static_cast<IFunction*>(args[1]); ASObject** subargs = g_newa(ASObject*, 3+capturingGroups); //we index on bytes, not on UTF-8 characters - subargs[0]=abstract_s(ret->data.substr_bytes(ovector[0],ovector[1]-ovector[0])); + subargs[0]=abstract_s(obj->getSystemState(),ret->data.substr_bytes(ovector[0],ovector[1]-ovector[0])); for(int i=0;i<capturingGroups;i++) - subargs[i+1]=abstract_s(ret->data.substr_bytes(ovector[i*2+2],ovector[i*2+3]-ovector[i*2+2])); - subargs[capturingGroups+1]=abstract_i(ovector[0]-retDiff); + subargs[i+1]=abstract_s(obj->getSystemState(),ret->data.substr_bytes(ovector[i*2+2],ovector[i*2+3]-ovector[i*2+2])); + subargs[capturingGroups+1]=abstract_i(obj->getSystemState(),ovector[0]-retDiff); - subargs[capturingGroups+2]=abstract_s(data); - ASObject* ret=f->call(getSys()->getNullRef(), subargs, 3+capturingGroups); + subargs[capturingGroups+2]=abstract_s(obj->getSystemState(),data); + ASObject* ret=f->call(obj->getSystemState()->getNullRef(), subargs, 3+capturingGroups); replaceWithTmp=ret->toString().raw_buf(); ret->decRef(); } else { @@ -897,7 +894,7 @@ ASFUNCTIONBODY(ASString,concat) { tiny_string data = obj->toString(); - ASString* ret=abstract_s(data); + ASString* ret=abstract_s(obj->getSystemState(),data); for(unsigned int i=0;i<argslen;i++) ret->data+=args[i]->toString().raw_buf(); @@ -908,9 +905,9 @@ { assert(argslen<=1); if (argslen == 0) - return abstract_s(); + return abstract_s(getSys()); else - return abstract_s(args[0]->toString()); + return abstract_s(args[0]->getSystemState(),args[0]->toString()); } bool ASString::isEcmaSpace(uint32_t c)
View file
lightspark.tar.xz/src/scripting/toplevel/ASString.h
Changed
@@ -32,9 +32,9 @@ */ class ASString: public ASObject { - friend ASString* abstract_s(); - friend ASString* abstract_s(const char* s, uint32_t len); - friend ASString* abstract_s(const tiny_string& s); + friend ASString* abstract_s(SystemState* sys); + friend ASString* abstract_s(SystemState* sys, const char* s, uint32_t len); + friend ASString* abstract_s(SystemState* sys, const tiny_string& s); private: tiny_string toString_priv() const; number_t parseStringInfinite(const char *s, char **end) const; @@ -70,7 +70,7 @@ ASFUNCTION(localeCompare_prototype); bool isEqual(ASObject* r); TRISTATE isLess(ASObject* r); - number_t toNumber() const; + number_t toNumber(); int32_t toInt(); uint32_t toUInt(); ASFUNCTION(generator); @@ -81,7 +81,7 @@ std::string toDebugString() { return std::string("\"") + std::string(data) + "\""; } static bool isEcmaSpace(uint32_t c); static bool isEcmaLineTerminator(uint32_t c); - void finalize() { data.clear(); } + inline void finalize() { data.clear(); } }; template<> @@ -95,13 +95,13 @@ if(o->is<Undefined>()) { o->decRef(); - return getSys()->getNullRef(); + return o->getSystemState()->getNullRef(); } if(!o->isConstructed()) return o; tiny_string n = o->toString(); o->decRef(); - return lightspark::abstract_s(n); + return lightspark::abstract_s(o->getSystemState(),n); } }
View file
lightspark.tar.xz/src/scripting/toplevel/Array.cpp
Changed
@@ -38,59 +38,59 @@ void Array::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_DYNAMIC_NOT_FINAL); - c->setVariableByQName("CASEINSENSITIVE","",abstract_d(CASEINSENSITIVE),CONSTANT_TRAIT); - c->setVariableByQName("DESCENDING","",abstract_d(DESCENDING),CONSTANT_TRAIT); - c->setVariableByQName("NUMERIC","",abstract_d(NUMERIC),CONSTANT_TRAIT); - c->setVariableByQName("RETURNINDEXEDARRAY","",abstract_d(RETURNINDEXEDARRAY),CONSTANT_TRAIT); - c->setVariableByQName("UNIQUESORT","",abstract_d(UNIQUESORT),CONSTANT_TRAIT); + c->setVariableByQName("CASEINSENSITIVE","",abstract_d(c->getSystemState(),CASEINSENSITIVE),CONSTANT_TRAIT); + c->setVariableByQName("DESCENDING","",abstract_d(c->getSystemState(),DESCENDING),CONSTANT_TRAIT); + c->setVariableByQName("NUMERIC","",abstract_d(c->getSystemState(),NUMERIC),CONSTANT_TRAIT); + c->setVariableByQName("RETURNINDEXEDARRAY","",abstract_d(c->getSystemState(),RETURNINDEXEDARRAY),CONSTANT_TRAIT); + c->setVariableByQName("UNIQUESORT","",abstract_d(c->getSystemState(),UNIQUESORT),CONSTANT_TRAIT); // properties - c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(_getLength),GETTER_METHOD,true); - c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(_setLength),SETTER_METHOD,true); + c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(c->getSystemState(),_getLength),GETTER_METHOD,true); + c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(c->getSystemState(),_setLength),SETTER_METHOD,true); // public functions - c->setDeclaredMethodByQName("concat",AS3,Class<IFunction>::getFunction(_concat,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("every",AS3,Class<IFunction>::getFunction(every,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("filter",AS3,Class<IFunction>::getFunction(filter,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("forEach",AS3,Class<IFunction>::getFunction(forEach,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("indexOf",AS3,Class<IFunction>::getFunction(indexOf,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("lastIndexOf",AS3,Class<IFunction>::getFunction(lastIndexOf,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("join",AS3,Class<IFunction>::getFunction(join,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("map",AS3,Class<IFunction>::getFunction(_map,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("pop",AS3,Class<IFunction>::getFunction(_pop),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("push",AS3,Class<IFunction>::getFunction(_push_as3,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("reverse",AS3,Class<IFunction>::getFunction(_reverse),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("shift",AS3,Class<IFunction>::getFunction(shift),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("slice",AS3,Class<IFunction>::getFunction(slice,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("some",AS3,Class<IFunction>::getFunction(some,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("sort",AS3,Class<IFunction>::getFunction(_sort),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("sortOn",AS3,Class<IFunction>::getFunction(sortOn),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("splice",AS3,Class<IFunction>::getFunction(splice,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toLocaleString",AS3,Class<IFunction>::getFunction(_toLocaleString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("unshift",AS3,Class<IFunction>::getFunction(unshift),NORMAL_METHOD,true); - - c->prototype->setVariableByQName("concat","",Class<IFunction>::getFunction(_concat,1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("every","",Class<IFunction>::getFunction(every,1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("filter","",Class<IFunction>::getFunction(filter,1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("forEach","",Class<IFunction>::getFunction(forEach,1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("indexOf","",Class<IFunction>::getFunction(indexOf,1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("lastIndexOf","",Class<IFunction>::getFunction(lastIndexOf,1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("join","",Class<IFunction>::getFunction(join,1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("map","",Class<IFunction>::getFunction(_map,1),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("concat",AS3,Class<IFunction>::getFunction(c->getSystemState(),_concat,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("every",AS3,Class<IFunction>::getFunction(c->getSystemState(),every,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("filter",AS3,Class<IFunction>::getFunction(c->getSystemState(),filter,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("forEach",AS3,Class<IFunction>::getFunction(c->getSystemState(),forEach,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("indexOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),indexOf,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("lastIndexOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),lastIndexOf,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("join",AS3,Class<IFunction>::getFunction(c->getSystemState(),join,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("map",AS3,Class<IFunction>::getFunction(c->getSystemState(),_map,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("pop",AS3,Class<IFunction>::getFunction(c->getSystemState(),_pop),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("push",AS3,Class<IFunction>::getFunction(c->getSystemState(),_push_as3,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("reverse",AS3,Class<IFunction>::getFunction(c->getSystemState(),_reverse),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("shift",AS3,Class<IFunction>::getFunction(c->getSystemState(),shift),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("slice",AS3,Class<IFunction>::getFunction(c->getSystemState(),slice,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("some",AS3,Class<IFunction>::getFunction(c->getSystemState(),some,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("sort",AS3,Class<IFunction>::getFunction(c->getSystemState(),_sort),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("sortOn",AS3,Class<IFunction>::getFunction(c->getSystemState(),sortOn),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("splice",AS3,Class<IFunction>::getFunction(c->getSystemState(),splice,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toLocaleString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toLocaleString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("unshift",AS3,Class<IFunction>::getFunction(c->getSystemState(),unshift),NORMAL_METHOD,true); + + c->prototype->setVariableByQName("concat","",Class<IFunction>::getFunction(c->getSystemState(),_concat,1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("every","",Class<IFunction>::getFunction(c->getSystemState(),every,1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("filter","",Class<IFunction>::getFunction(c->getSystemState(),filter,1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("forEach","",Class<IFunction>::getFunction(c->getSystemState(),forEach,1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("indexOf","",Class<IFunction>::getFunction(c->getSystemState(),indexOf,1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("lastIndexOf","",Class<IFunction>::getFunction(c->getSystemState(),lastIndexOf,1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("join","",Class<IFunction>::getFunction(c->getSystemState(),join,1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("map","",Class<IFunction>::getFunction(c->getSystemState(),_map,1),DYNAMIC_TRAIT); // workaround, pop was encountered not in the AS3 namespace before, need to investigate it further - c->setDeclaredMethodByQName("pop","",Class<IFunction>::getFunction(_pop),NORMAL_METHOD,true); - c->prototype->setVariableByQName("pop","",Class<IFunction>::getFunction(_pop),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("push","",Class<IFunction>::getFunction(_push,1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("reverse","",Class<IFunction>::getFunction(_reverse),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("shift","",Class<IFunction>::getFunction(shift),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("slice","",Class<IFunction>::getFunction(slice,2),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("some","",Class<IFunction>::getFunction(some,1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("sort","",Class<IFunction>::getFunction(_sort),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("sortOn","",Class<IFunction>::getFunction(sortOn),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("splice","",Class<IFunction>::getFunction(splice,2),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toLocaleString","",Class<IFunction>::getFunction(_toLocaleString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("unshift","",Class<IFunction>::getFunction(unshift),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("pop","",Class<IFunction>::getFunction(c->getSystemState(),_pop),NORMAL_METHOD,true); + c->prototype->setVariableByQName("pop","",Class<IFunction>::getFunction(c->getSystemState(),_pop),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("push","",Class<IFunction>::getFunction(c->getSystemState(),_push,1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("reverse","",Class<IFunction>::getFunction(c->getSystemState(),_reverse),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("shift","",Class<IFunction>::getFunction(c->getSystemState(),shift),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("slice","",Class<IFunction>::getFunction(c->getSystemState(),slice,2),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("some","",Class<IFunction>::getFunction(c->getSystemState(),some,1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("sort","",Class<IFunction>::getFunction(c->getSystemState(),_sort),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("sortOn","",Class<IFunction>::getFunction(c->getSystemState(),sortOn),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("splice","",Class<IFunction>::getFunction(c->getSystemState(),splice,2),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toLocaleString","",Class<IFunction>::getFunction(c->getSystemState(),_toLocaleString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("unshift","",Class<IFunction>::getFunction(c->getSystemState(),unshift),DYNAMIC_TRAIT); } void Array::buildTraits(ASObject* o) @@ -106,7 +106,7 @@ ASFUNCTIONBODY(Array,generator) { - Array* th=Class<Array>::getInstanceS(); + Array* th=Class<Array>::getInstanceS(getSys()); th->constructorImpl(args, argslen); return th; } @@ -136,7 +136,7 @@ ASFUNCTIONBODY(Array,_concat) { Array* th=static_cast<Array*>(obj); - Array* ret=Class<Array>::getInstanceS(); + Array* ret=Class<Array>::getInstanceS(obj->getSystemState()); // copy values into new array ret->resize(th->size()); @@ -179,7 +179,7 @@ ASFUNCTIONBODY(Array,filter) { Array* th=static_cast<Array*>(obj); - Array* ret=Class<Array>::getInstanceS(); + Array* ret=Class<Array>::getInstanceS(obj->getSystemState()); _NR<IFunction> f; ARG_UNPACK(f); if (f.isNull()) @@ -197,8 +197,8 @@ it->second.data->incRef(); } else - params[0] =abstract_d(it->second.data_i); - params[1] = abstract_i(it->first); + params[0] =abstract_d(obj->getSystemState(),it->second.data_i); + params[1] = abstract_i(obj->getSystemState(),it->first); params[2] = th; th->incRef(); @@ -207,7 +207,7 @@ origval->incRef(); if(argslen==1) { - funcRet=f->call(getSys()->getNullRef(), params, 3); + funcRet=f->call(obj->getSystemState()->getNullRef(), params, 3); } else { @@ -232,7 +232,7 @@ _NR<IFunction> f; ARG_UNPACK(f); if (f.isNull()) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); ASObject* params[3]; ASObject *funcRet; @@ -246,14 +246,14 @@ it->second.data->incRef(); } else - params[0] =abstract_d(it->second.data_i); - params[1] = abstract_i(it->first); + params[0] =abstract_d(obj->getSystemState(),it->second.data_i); + params[1] = abstract_i(obj->getSystemState(),it->first); params[2] = th; th->incRef(); if(argslen==1) { - funcRet=f->call(getSys()->getNullRef(), params, 3); + funcRet=f->call(obj->getSystemState()->getNullRef(), params, 3); } else { @@ -269,7 +269,7 @@ funcRet->decRef(); } } - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); } ASFUNCTIONBODY(Array, every) @@ -278,7 +278,7 @@ _NR<IFunction> f; ARG_UNPACK(f); if (f.isNull()) - return abstract_b(true); + return abstract_b(obj->getSystemState(),true); ASObject* params[3]; ASObject *funcRet; @@ -292,14 +292,14 @@ it->second.data->incRef(); } else - params[0] =abstract_d(it->second.data_i); - params[1] = abstract_i(it->first); + params[0] =abstract_d(obj->getSystemState(),it->second.data_i); + params[1] = abstract_i(obj->getSystemState(),it->first); params[2] = th; th->incRef(); if(argslen==1) { - funcRet=f->call(getSys()->getNullRef(), params, 3); + funcRet=f->call(obj->getSystemState()->getNullRef(), params, 3); } else { @@ -315,13 +315,13 @@ funcRet->decRef(); } } - return abstract_b(true); + return abstract_b(obj->getSystemState(),true); } ASFUNCTIONBODY(Array,_getLength) { Array* th=static_cast<Array*>(obj); - return abstract_ui(th->size()); + return abstract_ui(obj->getSystemState(),th->size()); } ASFUNCTIONBODY(Array,_setLength) @@ -354,25 +354,25 @@ { const data_slot& slot=th->data[i]; if(slot.type==DATA_INT) - params[0]=abstract_i(slot.data_i); + params[0]=abstract_i(obj->getSystemState(),slot.data_i); else if(slot.type==DATA_OBJECT && slot.data) { params[0]=slot.data; params[0]->incRef(); } else - params[0]=getSys()->getUndefinedRef(); + params[0]=obj->getSystemState()->getUndefinedRef(); } else continue; - params[1] = abstract_i(i); + params[1] = abstract_i(obj->getSystemState(),i); params[2] = th; th->incRef(); ASObject *funcret; if( argslen == 1 ) { - funcret=f->call(getSys()->getNullRef(), params, 3); + funcret=f->call(obj->getSystemState()->getNullRef(), params, 3); } else { @@ -411,18 +411,18 @@ int ret=-1; if(argslen == 1 && th->data.empty()) - return abstract_d(-1); + return abstract_d(obj->getSystemState(),-1); size_t i = th->size()-1; if(std::isnan(index)) - return abstract_i(0); + return abstract_i(obj->getSystemState(),0); int j = index; //Preserve sign if(j < 0) //Negative offset, use it as offset from the end of the array { if((size_t)-j > th->size()) - return abstract_i(-1); + return abstract_i(obj->getSystemState(),-1); else i = th->size()+j; } @@ -448,7 +448,7 @@ } while(i--); - return abstract_i(ret); + return abstract_i(obj->getSystemState(),ret); } ASFUNCTIONBODY(Array,shift) @@ -463,28 +463,28 @@ // for other objects we just decrease the length property multiname lengthName(NULL); lengthName.name_type=multiname::NAME_STRING; - lengthName.name_s_id=getSys()->getUniqueStringId("length"); - lengthName.ns.push_back(nsNameAndKind("",NAMESPACE)); - lengthName.ns.push_back(nsNameAndKind(AS3,NAMESPACE)); + lengthName.name_s_id=obj->getSystemState()->getUniqueStringId("length"); + lengthName.ns.push_back(nsNameAndKind(obj->getSystemState(),"",NAMESPACE)); + lengthName.ns.push_back(nsNameAndKind(obj->getSystemState(),AS3,NAMESPACE)); lengthName.isAttribute = true; _NR<ASObject> o=obj->getVariableByMultiname(lengthName,SKIP_IMPL); uint32_t res = o->toUInt(); if (res > 0) - obj->setVariableByMultiname(lengthName,abstract_ui(res-1),CONST_NOT_ALLOWED); - return getSys()->getUndefinedRef(); + obj->setVariableByMultiname(lengthName,abstract_ui(obj->getSystemState(),res-1),CONST_NOT_ALLOWED); + return obj->getSystemState()->getUndefinedRef(); } Array* th=static_cast<Array*>(obj); if(!th->size()) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); ASObject* ret; if(!th->data.count(0)) - ret = getSys()->getUndefinedRef(); + ret = obj->getSystemState()->getUndefinedRef(); else { if(th->data[0].type==DATA_OBJECT) ret=th->data[0].data; else - ret = abstract_i(th->data[0].data_i); + ret = abstract_i(obj->getSystemState(),th->data[0].data_i); } std::map<uint32_t,data_slot> tmp; std::map<uint32_t,data_slot>::iterator it; @@ -530,7 +530,7 @@ startIndex=th->capIndex(startIndex); endIndex=th->capIndex(endIndex); - Array* ret=Class<Array>::getInstanceS(); + Array* ret=Class<Array>::getInstanceS(obj->getSystemState()); int j = 0; for(int i=startIndex; i<endIndex; i++) { @@ -556,7 +556,7 @@ ARG_UNPACK_MORE_ALLOWED(startIndex) (deleteCount, th->size()); int totalSize=th->size(); - Array* ret=Class<Array>::getInstanceS(); + Array* ret=Class<Array>::getInstanceS(obj->getSystemState()); startIndex=th->capIndex(startIndex); @@ -625,7 +625,7 @@ if(i!=th->size()-1) ret+=del.raw_buf(); } - return Class<ASString>::getInstanceS(ret); + return abstract_s(obj->getSystemState(),ret); } ASFUNCTIONBODY(Array,indexOf) @@ -648,13 +648,13 @@ dtype = sl.type; assert_and_throw(dtype==DATA_OBJECT || dtype==DATA_INT); if((dtype == DATA_OBJECT && sl.data->isEqualStrict(arg0.getPtr())) || - (dtype == DATA_INT && abstract_d(sl.data_i)->isEqualStrict(arg0.getPtr()))) + (dtype == DATA_INT && abstract_d(obj->getSystemState(),sl.data_i)->isEqualStrict(arg0.getPtr()))) { ret=it->first; break; } } - return abstract_i(ret); + return abstract_i(obj->getSystemState(),ret); } @@ -670,20 +670,20 @@ // for other objects we just decrease the length property multiname lengthName(NULL); lengthName.name_type=multiname::NAME_STRING; - lengthName.name_s_id=getSys()->getUniqueStringId("length"); - lengthName.ns.push_back(nsNameAndKind("",NAMESPACE)); - lengthName.ns.push_back(nsNameAndKind(AS3,NAMESPACE)); + lengthName.name_s_id=obj->getSystemState()->getUniqueStringId("length"); + lengthName.ns.push_back(nsNameAndKind(obj->getSystemState(),"",NAMESPACE)); + lengthName.ns.push_back(nsNameAndKind(obj->getSystemState(),AS3,NAMESPACE)); lengthName.isAttribute = true; _NR<ASObject> o=obj->getVariableByMultiname(lengthName,SKIP_IMPL); uint32_t res = o->toUInt(); if (res > 0) - obj->setVariableByMultiname(lengthName,abstract_ui(res-1),CONST_NOT_ALLOWED); - return getSys()->getUndefinedRef(); + obj->setVariableByMultiname(lengthName,abstract_ui(obj->getSystemState(),res-1),CONST_NOT_ALLOWED); + return obj->getSystemState()->getUndefinedRef(); } Array* th=static_cast<Array*>(obj); uint32_t size =th->size(); if (size == 0) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); ASObject* ret; if (th->data.count(size-1)) @@ -691,11 +691,11 @@ if(th->data[size-1].type==DATA_OBJECT) ret=th->data[size-1].data; else - ret = abstract_i(th->data[size-1].data_i); + ret = abstract_i(obj->getSystemState(),th->data[size-1].data_i); th->data.erase(size-1); } else - ret = getSys()->getUndefinedRef(); + ret = obj->getSystemState()->getUndefinedRef(); th->currentsize--; return ret; @@ -765,27 +765,27 @@ { ASObject* objs[2]; if(d1.type==DATA_INT) - objs[0]=abstract_i(d1.data_i); + objs[0]=abstract_i(comparator->getSystemState(),d1.data_i); else if(d1.type==DATA_OBJECT && d1.data) { objs[0]=d1.data; objs[0]->incRef(); } else - objs[0]=getSys()->getUndefinedRef(); + objs[0]=comparator->getSystemState()->getUndefinedRef(); if(d2.type==DATA_INT) - objs[1]=abstract_i(d2.data_i); + objs[1]=abstract_i(comparator->getSystemState(),d2.data_i); else if(d2.type==DATA_OBJECT && d2.data) { objs[1]=d2.data; objs[1]->incRef(); } else - objs[1]=getSys()->getUndefinedRef(); + objs[1]=comparator->getSystemState()->getUndefinedRef(); assert(comparator); - _NR<ASObject> ret=_MNR(comparator->call(getSys()->getNullRef(), objs, 2)); + _NR<ASObject> ret=_MNR(comparator->call(comparator->getSystemState()->getNullRef(), objs, 2)); assert_and_throw(ret); return (ret->toNumber()<0); //Less } @@ -912,7 +912,7 @@ for(;it != obj->data.end();++it) { multiname sortfieldname(NULL); - sortfieldname.ns.push_back(nsNameAndKind("",NAMESPACE)); + sortfieldname.ns.push_back(nsNameAndKind(obj->getSystemState(),"",NAMESPACE)); if (it->second.type == DATA_OBJECT) { sortfieldname.setName(it->second.data); @@ -948,7 +948,7 @@ { multiname sortfieldname(NULL); sortfieldname.setName(args[0]); - sortfieldname.ns.push_back(nsNameAndKind("",NAMESPACE)); + sortfieldname.ns.push_back(nsNameAndKind(obj->getSystemState(),"",NAMESPACE)); sorton_field sf(sortfieldname); if (argslen == 2) { @@ -998,14 +998,14 @@ // for other objects we just increase the length property multiname lengthName(NULL); lengthName.name_type=multiname::NAME_STRING; - lengthName.name_s_id=getSys()->getUniqueStringId("length"); - lengthName.ns.push_back(nsNameAndKind("",NAMESPACE)); - lengthName.ns.push_back(nsNameAndKind(AS3,NAMESPACE)); + lengthName.name_s_id=obj->getSystemState()->getUniqueStringId("length"); + lengthName.ns.push_back(nsNameAndKind(obj->getSystemState(),"",NAMESPACE)); + lengthName.ns.push_back(nsNameAndKind(obj->getSystemState(),AS3,NAMESPACE)); lengthName.isAttribute = true; _NR<ASObject> o=obj->getVariableByMultiname(lengthName,SKIP_IMPL); uint32_t res = o->toUInt(); - obj->setVariableByMultiname(lengthName,abstract_ui(res+argslen),CONST_NOT_ALLOWED); - return getSys()->getUndefinedRef(); + obj->setVariableByMultiname(lengthName,abstract_ui(obj->getSystemState(),res+argslen),CONST_NOT_ALLOWED); + return obj->getSystemState()->getUndefinedRef(); } Array* th=static_cast<Array*>(obj); // Derived classes may be sealed! @@ -1029,7 +1029,7 @@ th->data.clear(); th->data.insert(tmp.begin(),tmp.end()); } - return abstract_i(th->size()); + return abstract_i(obj->getSystemState(),th->size()); } ASFUNCTIONBODY(Array,_push) @@ -1044,14 +1044,14 @@ // for other objects we just increase the length property multiname lengthName(NULL); lengthName.name_type=multiname::NAME_STRING; - lengthName.name_s_id=getSys()->getUniqueStringId("length"); - lengthName.ns.push_back(nsNameAndKind("",NAMESPACE)); - lengthName.ns.push_back(nsNameAndKind(AS3,NAMESPACE)); + lengthName.name_s_id=obj->getSystemState()->getUniqueStringId("length"); + lengthName.ns.push_back(nsNameAndKind(obj->getSystemState(),"",NAMESPACE)); + lengthName.ns.push_back(nsNameAndKind(obj->getSystemState(),AS3,NAMESPACE)); lengthName.isAttribute = true; _NR<ASObject> o=obj->getVariableByMultiname(lengthName,SKIP_IMPL); uint32_t res = o->toUInt(); - obj->setVariableByMultiname(lengthName,abstract_ui(res+argslen),CONST_NOT_ALLOWED); - return getSys()->getUndefinedRef(); + obj->setVariableByMultiname(lengthName,abstract_ui(obj->getSystemState(),res+argslen),CONST_NOT_ALLOWED); + return obj->getSystemState()->getUndefinedRef(); } Array* th=static_cast<Array*>(obj); for(unsigned int i=0;i<argslen;i++) @@ -1059,7 +1059,7 @@ args[i]->incRef(); th->push(_MR(args[i])); } - return abstract_i(th->size()); + return abstract_i(obj->getSystemState(),th->size()); } // AS3 handles push on uint.MAX_VALUE differently than ECMA, so we need to push methods ASFUNCTIONBODY(Array,_push_as3) @@ -1074,14 +1074,14 @@ // for other objects we just increase the length property multiname lengthName(NULL); lengthName.name_type=multiname::NAME_STRING; - lengthName.name_s_id=getSys()->getUniqueStringId("length"); - lengthName.ns.push_back(nsNameAndKind("",NAMESPACE)); - lengthName.ns.push_back(nsNameAndKind(AS3,NAMESPACE)); + lengthName.name_s_id=obj->getSystemState()->getUniqueStringId("length"); + lengthName.ns.push_back(nsNameAndKind(obj->getSystemState(),"",NAMESPACE)); + lengthName.ns.push_back(nsNameAndKind(obj->getSystemState(),AS3,NAMESPACE)); lengthName.isAttribute = true; _NR<ASObject> o=obj->getVariableByMultiname(lengthName,SKIP_IMPL); uint32_t res = o->toUInt(); - obj->setVariableByMultiname(lengthName,abstract_ui(res+argslen),CONST_NOT_ALLOWED); - return getSys()->getUndefinedRef(); + obj->setVariableByMultiname(lengthName,abstract_ui(obj->getSystemState(),res+argslen),CONST_NOT_ALLOWED); + return obj->getSystemState()->getUndefinedRef(); } Array* th=static_cast<Array*>(obj); for(unsigned int i=0;i<argslen;i++) @@ -1091,7 +1091,7 @@ args[i]->incRef(); th->push(_MR(args[i])); } - return abstract_i(th->size()); + return abstract_i(obj->getSystemState(),th->size()); } ASFUNCTIONBODY(Array,_map) @@ -1106,7 +1106,7 @@ assert_and_throw(args[0]->getObjectType()==T_FUNCTION); func=static_cast<IFunction*>(args[0]); } - Array* arrayRet=Class<Array>::getInstanceS(); + Array* arrayRet=Class<Array>::getInstanceS(obj->getSystemState()); uint32_t s = th->size(); for (uint32_t i=0; i < s; i++ ) @@ -1116,18 +1116,18 @@ { const data_slot& slot=th->data[i]; if(slot.type==DATA_INT) - funcArgs[0]=abstract_i(slot.data_i); + funcArgs[0]=abstract_i(obj->getSystemState(),slot.data_i); else if(slot.type==DATA_OBJECT && slot.data) { funcArgs[0]=slot.data; funcArgs[0]->incRef(); } else - funcArgs[0]=getSys()->getUndefinedRef(); + funcArgs[0]=obj->getSystemState()->getUndefinedRef(); } else - funcArgs[0]=getSys()->getUndefinedRef(); - funcArgs[1]=abstract_i(i); + funcArgs[0]=obj->getSystemState()->getUndefinedRef(); + funcArgs[1]=abstract_i(obj->getSystemState(),i); funcArgs[2]=th; funcArgs[2]->incRef(); ASObject* funcRet= NULL; @@ -1135,7 +1135,7 @@ { if (argslen > 1) args[1]->incRef(); - funcRet = func->call(argslen > 1? args[1] : getSys()->getNullRef(), funcArgs, 3); + funcRet = func->call(argslen > 1? args[1] : obj->getSystemState()->getNullRef(), funcArgs, 3); } else funcRet = RegExp::exec(args[0],funcArgs,1); @@ -1148,37 +1148,37 @@ ASFUNCTIONBODY(Array,_toString) { - if(Class<Number>::getClass()->prototype->getObj() == obj) - return Class<ASString>::getInstanceS(""); + if(Class<Number>::getClass(obj->getSystemState())->prototype->getObj() == obj) + return abstract_s(obj->getSystemState(),""); if(!obj->is<Array>()) { LOG(LOG_NOT_IMPLEMENTED, "generic Array::toString"); - return Class<ASString>::getInstanceS(""); + return abstract_s(obj->getSystemState(),""); } Array* th=obj->as<Array>(); - return Class<ASString>::getInstanceS(th->toString_priv()); + return abstract_s(obj->getSystemState(),th->toString_priv()); } ASFUNCTIONBODY(Array,_toLocaleString) { - if(Class<Number>::getClass()->prototype->getObj() == obj) - return Class<ASString>::getInstanceS(""); + if(Class<Number>::getClass(obj->getSystemState())->prototype->getObj() == obj) + return abstract_s(obj->getSystemState(),""); if(!obj->is<Array>()) { LOG(LOG_NOT_IMPLEMENTED, "generic Array::toLocaleString"); - return Class<ASString>::getInstanceS(""); + return abstract_s(obj->getSystemState(),""); } Array* th=obj->as<Array>(); - return Class<ASString>::getInstanceS(th->toString_priv(true)); + return abstract_s(obj->getSystemState(),th->toString_priv(true)); } int32_t Array::getVariableByMultiname_i(const multiname& name) { assert_and_throw(implEnable); uint32_t index=0; - if(!isValidMultiname(name,index)) + if(!isValidMultiname(getSystemState(),name,index)) return ASObject::getVariableByMultiname_i(name); if(index<size()) @@ -1222,7 +1222,7 @@ return ASObject::getVariableByMultiname(name,opt); uint32_t index=0; - if(!isValidMultiname(name,index)) + if(!isValidMultiname(getSystemState(),name,index)) return ASObject::getVariableByMultiname(name,opt); if(index<size() && data.count(index)) { @@ -1234,13 +1234,13 @@ ret=sl.data; if(ret==NULL) { - ret=getSys()->getUndefinedRef(); + ret=getSystemState()->getUndefinedRef(); sl.data=ret; } ret->incRef(); break; case DATA_INT: - ret=abstract_d(sl.data_i); + ret=abstract_d(this->getSystemState(),sl.data_i); break; } return _MNR(ret); @@ -1256,7 +1256,7 @@ proto = proto->prevPrototype.getPtr(); } if(index<size()) - return _MNR(getSys()->getUndefinedRef()); + return _MNR(getSystemState()->getUndefinedRef()); return NullRef; } @@ -1265,7 +1265,7 @@ { assert_and_throw(implEnable); unsigned int index=0; - if(!isValidMultiname(name,index)) + if(!isValidMultiname(getSystemState(),name,index)) { ASObject::setVariableByMultiname_i(name,value); return; @@ -1292,13 +1292,13 @@ return false; uint32_t index=0; - if(!isValidMultiname(name,index)) + if(!isValidMultiname(getSystemState(),name,index)) return ASObject::hasPropertyByMultiname(name, considerDynamic, considerPrototype); return (index<size()) && (data.count(index)); } -bool Array::isValidMultiname(const multiname& name, uint32_t& index) +bool Array::isValidMultiname(SystemState* sys, const multiname& name, uint32_t& index) { if(name.isEmpty()) return false; @@ -1308,10 +1308,10 @@ if(!name.ns[0].hasEmptyName()) return false; if (name.name_type == multiname::NAME_STRING && - !isIntegerWithoutLeadingZeros(name.normalizedName())) + !isIntegerWithoutLeadingZeros(name.normalizedName(sys))) return false; - return name.toUInt(index); + return name.toUInt(sys,index); } bool Array::isIntegerWithoutLeadingZeros(const tiny_string& value) @@ -1337,7 +1337,7 @@ { assert_and_throw(implEnable); uint32_t index=0; - if(!isValidMultiname(name,index)) + if(!isValidMultiname(getSystemState(),name,index)) { ASObject::setVariableByMultiname(name,o,allowConst); // setIsEnumerable(name,false); @@ -1346,7 +1346,7 @@ // Derived classes may be sealed! if (getClass() && getClass()->isSealed) throwError<ReferenceError>(kWriteSealedError, - name.normalizedNameUnresolved(), + name.normalizedNameUnresolved(getSystemState()), getClass()->getQualifiedClassName()); if (index==0xFFFFFFFF) return; @@ -1376,7 +1376,7 @@ { assert_and_throw(implEnable); unsigned int index=0; - if(!isValidMultiname(name,index)) + if(!isValidMultiname(getSystemState(),name,index)) return ASObject::deleteVariableByMultiname(name); if (getClass() && getClass()->isSealed) return false; @@ -1457,12 +1457,12 @@ { index--; if(!data.count(index)) - return _MR(getSys()->getUndefinedRef()); + return _MR(getSystemState()->getUndefinedRef()); data_slot sl = data[index]; if(sl.type==DATA_OBJECT) { if(sl.data==NULL) - return _MR(getSys()->getUndefinedRef()); + return _MR(getSystemState()->getUndefinedRef()); else { sl.data->incRef(); @@ -1470,7 +1470,7 @@ } } else if(sl.type==DATA_INT) - return _MR(abstract_d(sl.data_i)); + return _MR(abstract_d(getSystemState(),sl.data_i)); else throw UnsupportedException("Unexpected data type"); } @@ -1506,7 +1506,7 @@ { assert_and_throw(implEnable); if(index<=size()) - return _MR(abstract_i(index-1)); + return _MR(abstract_i(getSystemState(),index-1)); else { //Fall back on object properties @@ -1520,7 +1520,7 @@ outofbounds(index); if (!data.count(index)) - return _MR(getSys()->getUndefinedRef()); + return _MR(getSystemState()->getUndefinedRef()); data_slot sl = data.at(index); switch(sl.type) { @@ -1533,11 +1533,11 @@ } } case DATA_INT: - return _MR(abstract_d(sl.data_i)); + return _MR(abstract_d(getSystemState(),sl.data_i)); } //We should be here only if data is an object and is NULL - return _MR(getSys()->getUndefinedRef()); + return _MR(getSystemState()->getUndefinedRef()); } void Array::outofbounds(unsigned int index) const @@ -1638,16 +1638,16 @@ for (it=data.begin() ; it != data.end(); ++it) { tiny_string subres; - ASObject* o = it->second.type==DATA_OBJECT ? it->second.data : abstract_i(it->second.data_i); + ASObject* o = it->second.type==DATA_OBJECT ? it->second.data : abstract_i(getSystemState(),it->second.data_i); if (replacer != NULL) { ASObject* params[2]; - params[0] = Class<Number>::getInstanceS(it->first); + params[0] = abstract_d(getSystemState(),it->first); params[0]->incRef(); params[1] = o; params[1]->incRef(); - ASObject *funcret=replacer->call(getSys()->getNullRef(), params, 2); + ASObject *funcret=replacer->call(getSystemState()->getNullRef(), params, 2); if (funcret) subres = funcret->toJSON(path,NULL,spaces,filter); }
View file
lightspark.tar.xz/src/scripting/toplevel/Array.h
Changed
@@ -94,7 +94,7 @@ Array(Class_base* c); void finalize(); //These utility methods are also used by ByteArray - static bool isValidMultiname(const multiname& name, uint32_t& index); + static bool isValidMultiname(SystemState* sys,const multiname& name, uint32_t& index); static bool isValidQName(const tiny_string& name, const tiny_string& ns, unsigned int& index); static void sinit(Class_base*);
View file
lightspark.tar.xz/src/scripting/toplevel/Boolean.cpp
Changed
@@ -27,12 +27,12 @@ using namespace lightspark; using namespace std; -Boolean* lightspark::abstract_b(bool v) +Boolean* lightspark::abstract_b(SystemState *sys, bool v) { if(v==true) - return getSys()->getTrueRef(); + return sys->getTrueRef(); else - return getSys()->getFalseRef(); + return sys->getFalseRef(); } /* implements ecma3's ToBoolean() operation, see section 9.2, but returns the value instead of an Boolean object */ @@ -72,18 +72,18 @@ ASFUNCTIONBODY(Boolean,generator) { if(argslen==1) - return abstract_b(Boolean_concrete(args[0])); + return abstract_b(args[0]->getSystemState(),Boolean_concrete(args[0])); else - return abstract_b(false); + return abstract_b(getSys(),false); } void Boolean::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); c->isReusable = true; - c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(_valueOf),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(c->getSystemState(),_valueOf),DYNAMIC_TRAIT); } ASFUNCTIONBODY(Boolean,_constructor) @@ -100,27 +100,27 @@ ASFUNCTIONBODY(Boolean,_toString) { - if(Class<Boolean>::getClass()->prototype->getObj() == obj) //See ECMA 15.6.4 - return abstract_s("false"); + if(Class<Boolean>::getClass(obj->getSystemState())->prototype->getObj() == obj) //See ECMA 15.6.4 + return abstract_s(obj->getSystemState(),"false"); if(!obj->is<Boolean>()) - throw Class<TypeError>::getInstanceS(""); + throw Class<TypeError>::getInstanceS(obj->getSystemState(),""); Boolean* th=static_cast<Boolean*>(obj); - return abstract_s(th->toString()); + return abstract_s(obj->getSystemState(),th->toString()); } ASFUNCTIONBODY(Boolean,_valueOf) { - if(Class<Boolean>::getClass()->prototype->getObj() == obj) - return abstract_b(false); + if(Class<Boolean>::getClass(obj->getSystemState())->prototype->getObj() == obj) + return abstract_b(obj->getSystemState(),false); if(!obj->is<Boolean>()) - throw Class<TypeError>::getInstanceS(""); + throw Class<TypeError>::getInstanceS(obj->getSystemState(),""); //The ecma3 spec is unspecific, but testing showed that we should return //a new object - return abstract_b(obj->as<Boolean>()->val); + return abstract_b(obj->getSystemState(),obj->as<Boolean>()->val); } void Boolean::serialize(ByteArray* out, std::map<tiny_string, uint32_t>& stringMap,
View file
lightspark.tar.xz/src/scripting/toplevel/Boolean.h
Changed
@@ -27,7 +27,7 @@ /* returns a fully inialized Boolean object with value b * like Class<Boolean>::getInstanceS(b) but without the constructor problems */ -Boolean* abstract_b(bool b); +Boolean* abstract_b(SystemState *sys, bool b); /* implements ecma3's ToBoolean() operation, see section 9.2, but returns the value instead of an Boolean object */ bool Boolean_concrete(const ASObject* obj); @@ -39,7 +39,7 @@ static void sinit(Class_base*); static void buildTraits(ASObject* o){}; bool val; - void finalize() { val=false;} + inline void finalize() { val=false;} int32_t toInt() { return val ? 1 : 0;
View file
lightspark.tar.xz/src/scripting/toplevel/Date.cpp
Changed
@@ -51,125 +51,125 @@ { CLASS_SETUP_CONSTRUCTOR_LENGTH(c, ASObject, _constructor, 7, CLASS_FINAL); c->isReusable = true; - c->setDeclaredMethodByQName("getTimezoneOffset",AS3,Class<IFunction>::getFunction(getTimezoneOffset),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(valueOf),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getTime",AS3,Class<IFunction>::getFunction(getTime),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getFullYear",AS3,Class<IFunction>::getFunction(getFullYear),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getMonth",AS3,Class<IFunction>::getFunction(getMonth),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getDate",AS3,Class<IFunction>::getFunction(getDate),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getDay",AS3,Class<IFunction>::getFunction(getDay),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getHours",AS3,Class<IFunction>::getFunction(getHours),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getMinutes",AS3,Class<IFunction>::getFunction(getMinutes),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getSeconds",AS3,Class<IFunction>::getFunction(getSeconds),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getMilliseconds",AS3,Class<IFunction>::getFunction(getMilliseconds),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setFullYear",AS3,Class<IFunction>::getFunction(setFullYear,3),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setMonth",AS3,Class<IFunction>::getFunction(setMonth,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setDate",AS3,Class<IFunction>::getFunction(setDate),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setHours",AS3,Class<IFunction>::getFunction(setHours,4),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setMinutes",AS3,Class<IFunction>::getFunction(setMinutes,3),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setSeconds",AS3,Class<IFunction>::getFunction(setSeconds,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setMilliseconds",AS3,Class<IFunction>::getFunction(setMilliseconds),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getUTCFullYear",AS3,Class<IFunction>::getFunction(getUTCFullYear),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getUTCMonth",AS3,Class<IFunction>::getFunction(getUTCMonth),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getUTCDate",AS3,Class<IFunction>::getFunction(getUTCDate),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getUTCDay",AS3,Class<IFunction>::getFunction(getUTCDay),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getUTCHours",AS3,Class<IFunction>::getFunction(getUTCHours),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getUTCMinutes",AS3,Class<IFunction>::getFunction(getUTCMinutes),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getUTCSeconds",AS3,Class<IFunction>::getFunction(getUTCSeconds),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("getUTCMilliseconds",AS3,Class<IFunction>::getFunction(getUTCMilliseconds),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setUTCFullYear",AS3,Class<IFunction>::getFunction(setUTCFullYear,3),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setUTCMonth",AS3,Class<IFunction>::getFunction(setUTCMonth,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setUTCDate",AS3,Class<IFunction>::getFunction(setUTCDate),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setUTCHours",AS3,Class<IFunction>::getFunction(setUTCHours,4),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setUTCMinutes",AS3,Class<IFunction>::getFunction(setUTCMinutes,3),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setUTCSeconds",AS3,Class<IFunction>::getFunction(setUTCSeconds,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setUTCMilliseconds",AS3,Class<IFunction>::getFunction(setUTCMilliseconds),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setTime",AS3,Class<IFunction>::getFunction(setTime,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("UTC","",Class<IFunction>::getFunction(UTC,7),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toUTCString",AS3,Class<IFunction>::getFunction(toUTCString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toDateString",AS3,Class<IFunction>::getFunction(toDateString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toTimeString",AS3,Class<IFunction>::getFunction(toTimeString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toLocaleString",AS3,Class<IFunction>::getFunction(toLocaleString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toLocaleDateString",AS3,Class<IFunction>::getFunction(toLocaleDateString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("parse","",Class<IFunction>::getFunction(_parse),NORMAL_METHOD,false); - - c->setDeclaredMethodByQName("date","",Class<IFunction>::getFunction(getDate),GETTER_METHOD,true); - c->setDeclaredMethodByQName("date","",Class<IFunction>::getFunction(dateSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("dateUTC","",Class<IFunction>::getFunction(getUTCDate),GETTER_METHOD,true); - c->setDeclaredMethodByQName("dateUTC","",Class<IFunction>::getFunction(UTCDateSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("day","",Class<IFunction>::getFunction(getDay),GETTER_METHOD,true); - c->setDeclaredMethodByQName("dayUTC","",Class<IFunction>::getFunction(getUTCDay),GETTER_METHOD,true); - c->setDeclaredMethodByQName("fullYear","",Class<IFunction>::getFunction(getFullYear),GETTER_METHOD,true); - c->setDeclaredMethodByQName("fullYear","",Class<IFunction>::getFunction(fullYearSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("fullYearUTC","",Class<IFunction>::getFunction(getUTCFullYear),GETTER_METHOD,true); - c->setDeclaredMethodByQName("fullYearUTC","",Class<IFunction>::getFunction(UTCFullYearSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("hours","",Class<IFunction>::getFunction(getHours),GETTER_METHOD,true); - c->setDeclaredMethodByQName("hours","",Class<IFunction>::getFunction(hoursSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("hoursUTC","",Class<IFunction>::getFunction(getUTCHours),GETTER_METHOD,true); - c->setDeclaredMethodByQName("hoursUTC","",Class<IFunction>::getFunction(UTCHoursSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("milliseconds","",Class<IFunction>::getFunction(getMilliseconds),GETTER_METHOD,true); - c->setDeclaredMethodByQName("milliseconds","",Class<IFunction>::getFunction(millisecondsSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("millisecondsUTC","",Class<IFunction>::getFunction(getUTCMilliseconds),GETTER_METHOD,true); - c->setDeclaredMethodByQName("millisecondsUTC","",Class<IFunction>::getFunction(UTCMillisecondsSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("minutes","",Class<IFunction>::getFunction(getMinutes),GETTER_METHOD,true); - c->setDeclaredMethodByQName("minutes","",Class<IFunction>::getFunction(minutesSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("minutesUTC","",Class<IFunction>::getFunction(getUTCMinutes),GETTER_METHOD,true); - c->setDeclaredMethodByQName("minutesUTC","",Class<IFunction>::getFunction(UTCMinutesSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("month","",Class<IFunction>::getFunction(getMonth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("month","",Class<IFunction>::getFunction(monthSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("monthUTC","",Class<IFunction>::getFunction(getUTCMonth),GETTER_METHOD,true); - c->setDeclaredMethodByQName("monthUTC","",Class<IFunction>::getFunction(UTCMonthSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("seconds","",Class<IFunction>::getFunction(getSeconds),GETTER_METHOD,true); - c->setDeclaredMethodByQName("seconds","",Class<IFunction>::getFunction(secondsSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("secondsUTC","",Class<IFunction>::getFunction(getUTCSeconds),GETTER_METHOD,true); - c->setDeclaredMethodByQName("secondsUTC","",Class<IFunction>::getFunction(UTCSecondsSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("time","",Class<IFunction>::getFunction(getTime),GETTER_METHOD,true); - c->setDeclaredMethodByQName("time","",Class<IFunction>::getFunction(timeSetter),SETTER_METHOD,true); - c->setDeclaredMethodByQName("timezoneOffset","",Class<IFunction>::getFunction(getTimezoneOffset),GETTER_METHOD,true); - - c->prototype->setVariableByQName("getTimezoneOffset","",Class<IFunction>::getFunction(getTimezoneOffset),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(valueOf),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getTime","",Class<IFunction>::getFunction(getTime),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getFullYear","",Class<IFunction>::getFunction(getFullYear),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getMonth","",Class<IFunction>::getFunction(getMonth),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getDate","",Class<IFunction>::getFunction(getDate),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getDay","",Class<IFunction>::getFunction(getDay),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getHours","",Class<IFunction>::getFunction(getHours),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getMinutes","",Class<IFunction>::getFunction(getMinutes),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getSeconds","",Class<IFunction>::getFunction(getSeconds),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getMilliseconds","",Class<IFunction>::getFunction(getMilliseconds),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setFullYear","",Class<IFunction>::getFunction(setFullYear,3),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setMonth","",Class<IFunction>::getFunction(setMonth,2),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setDate","",Class<IFunction>::getFunction(setDate),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setHours","",Class<IFunction>::getFunction(setHours,4),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setMinutes","",Class<IFunction>::getFunction(setMinutes,3),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setSeconds","",Class<IFunction>::getFunction(setSeconds,2),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setMilliseconds","",Class<IFunction>::getFunction(setMilliseconds),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getUTCFullYear","",Class<IFunction>::getFunction(getUTCFullYear),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getUTCMonth","",Class<IFunction>::getFunction(getUTCMonth),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getUTCDate","",Class<IFunction>::getFunction(getUTCDate),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getUTCDay","",Class<IFunction>::getFunction(getUTCDay),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getUTCHours","",Class<IFunction>::getFunction(getUTCHours),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getUTCMinutes","",Class<IFunction>::getFunction(getUTCMinutes),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getUTCSeconds","",Class<IFunction>::getFunction(getUTCSeconds),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("getUTCMilliseconds","",Class<IFunction>::getFunction(getUTCMilliseconds),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setUTCFullYear","",Class<IFunction>::getFunction(setUTCFullYear,3),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setUTCMonth","",Class<IFunction>::getFunction(setUTCMonth,2),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setUTCDate","",Class<IFunction>::getFunction(setUTCDate),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setUTCHours","",Class<IFunction>::getFunction(setUTCHours,4),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setUTCMinutes","",Class<IFunction>::getFunction(setUTCMinutes,3),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setUTCSeconds","",Class<IFunction>::getFunction(setUTCSeconds,2),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setUTCMilliseconds","",Class<IFunction>::getFunction(setUTCMilliseconds),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("setTime","",Class<IFunction>::getFunction(setTime,1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toUTCString","",Class<IFunction>::getFunction(toUTCString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toDateString","",Class<IFunction>::getFunction(toDateString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toTimeString","",Class<IFunction>::getFunction(toTimeString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toLocaleTimeString","",Class<IFunction>::getFunction(toLocaleTimeString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toLocaleDateString","",Class<IFunction>::getFunction(toLocaleDateString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toLocaleString","",Class<IFunction>::getFunction(toLocaleString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toJSON",AS3,Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("getTimezoneOffset",AS3,Class<IFunction>::getFunction(c->getSystemState(),getTimezoneOffset),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),valueOf),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getTime",AS3,Class<IFunction>::getFunction(c->getSystemState(),getTime),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getFullYear",AS3,Class<IFunction>::getFunction(c->getSystemState(),getFullYear),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getMonth",AS3,Class<IFunction>::getFunction(c->getSystemState(),getMonth),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getDate",AS3,Class<IFunction>::getFunction(c->getSystemState(),getDate),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getDay",AS3,Class<IFunction>::getFunction(c->getSystemState(),getDay),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getHours",AS3,Class<IFunction>::getFunction(c->getSystemState(),getHours),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getMinutes",AS3,Class<IFunction>::getFunction(c->getSystemState(),getMinutes),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getSeconds",AS3,Class<IFunction>::getFunction(c->getSystemState(),getSeconds),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getMilliseconds",AS3,Class<IFunction>::getFunction(c->getSystemState(),getMilliseconds),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setFullYear",AS3,Class<IFunction>::getFunction(c->getSystemState(),setFullYear,3),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setMonth",AS3,Class<IFunction>::getFunction(c->getSystemState(),setMonth,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setDate",AS3,Class<IFunction>::getFunction(c->getSystemState(),setDate),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setHours",AS3,Class<IFunction>::getFunction(c->getSystemState(),setHours,4),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setMinutes",AS3,Class<IFunction>::getFunction(c->getSystemState(),setMinutes,3),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setSeconds",AS3,Class<IFunction>::getFunction(c->getSystemState(),setSeconds,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setMilliseconds",AS3,Class<IFunction>::getFunction(c->getSystemState(),setMilliseconds),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getUTCFullYear",AS3,Class<IFunction>::getFunction(c->getSystemState(),getUTCFullYear),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getUTCMonth",AS3,Class<IFunction>::getFunction(c->getSystemState(),getUTCMonth),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getUTCDate",AS3,Class<IFunction>::getFunction(c->getSystemState(),getUTCDate),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getUTCDay",AS3,Class<IFunction>::getFunction(c->getSystemState(),getUTCDay),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getUTCHours",AS3,Class<IFunction>::getFunction(c->getSystemState(),getUTCHours),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getUTCMinutes",AS3,Class<IFunction>::getFunction(c->getSystemState(),getUTCMinutes),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getUTCSeconds",AS3,Class<IFunction>::getFunction(c->getSystemState(),getUTCSeconds),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getUTCMilliseconds",AS3,Class<IFunction>::getFunction(c->getSystemState(),getUTCMilliseconds),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setUTCFullYear",AS3,Class<IFunction>::getFunction(c->getSystemState(),setUTCFullYear,3),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setUTCMonth",AS3,Class<IFunction>::getFunction(c->getSystemState(),setUTCMonth,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setUTCDate",AS3,Class<IFunction>::getFunction(c->getSystemState(),setUTCDate),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setUTCHours",AS3,Class<IFunction>::getFunction(c->getSystemState(),setUTCHours,4),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setUTCMinutes",AS3,Class<IFunction>::getFunction(c->getSystemState(),setUTCMinutes,3),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setUTCSeconds",AS3,Class<IFunction>::getFunction(c->getSystemState(),setUTCSeconds,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setUTCMilliseconds",AS3,Class<IFunction>::getFunction(c->getSystemState(),setUTCMilliseconds),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setTime",AS3,Class<IFunction>::getFunction(c->getSystemState(),setTime,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("UTC","",Class<IFunction>::getFunction(c->getSystemState(),UTC,7),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toUTCString",AS3,Class<IFunction>::getFunction(c->getSystemState(),toUTCString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toDateString",AS3,Class<IFunction>::getFunction(c->getSystemState(),toDateString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toTimeString",AS3,Class<IFunction>::getFunction(c->getSystemState(),toTimeString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toLocaleString",AS3,Class<IFunction>::getFunction(c->getSystemState(),toLocaleString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toLocaleDateString",AS3,Class<IFunction>::getFunction(c->getSystemState(),toLocaleDateString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("parse","",Class<IFunction>::getFunction(c->getSystemState(),_parse),NORMAL_METHOD,false); + + c->setDeclaredMethodByQName("date","",Class<IFunction>::getFunction(c->getSystemState(),getDate),GETTER_METHOD,true); + c->setDeclaredMethodByQName("date","",Class<IFunction>::getFunction(c->getSystemState(),dateSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("dateUTC","",Class<IFunction>::getFunction(c->getSystemState(),getUTCDate),GETTER_METHOD,true); + c->setDeclaredMethodByQName("dateUTC","",Class<IFunction>::getFunction(c->getSystemState(),UTCDateSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("day","",Class<IFunction>::getFunction(c->getSystemState(),getDay),GETTER_METHOD,true); + c->setDeclaredMethodByQName("dayUTC","",Class<IFunction>::getFunction(c->getSystemState(),getUTCDay),GETTER_METHOD,true); + c->setDeclaredMethodByQName("fullYear","",Class<IFunction>::getFunction(c->getSystemState(),getFullYear),GETTER_METHOD,true); + c->setDeclaredMethodByQName("fullYear","",Class<IFunction>::getFunction(c->getSystemState(),fullYearSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("fullYearUTC","",Class<IFunction>::getFunction(c->getSystemState(),getUTCFullYear),GETTER_METHOD,true); + c->setDeclaredMethodByQName("fullYearUTC","",Class<IFunction>::getFunction(c->getSystemState(),UTCFullYearSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("hours","",Class<IFunction>::getFunction(c->getSystemState(),getHours),GETTER_METHOD,true); + c->setDeclaredMethodByQName("hours","",Class<IFunction>::getFunction(c->getSystemState(),hoursSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("hoursUTC","",Class<IFunction>::getFunction(c->getSystemState(),getUTCHours),GETTER_METHOD,true); + c->setDeclaredMethodByQName("hoursUTC","",Class<IFunction>::getFunction(c->getSystemState(),UTCHoursSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("milliseconds","",Class<IFunction>::getFunction(c->getSystemState(),getMilliseconds),GETTER_METHOD,true); + c->setDeclaredMethodByQName("milliseconds","",Class<IFunction>::getFunction(c->getSystemState(),millisecondsSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("millisecondsUTC","",Class<IFunction>::getFunction(c->getSystemState(),getUTCMilliseconds),GETTER_METHOD,true); + c->setDeclaredMethodByQName("millisecondsUTC","",Class<IFunction>::getFunction(c->getSystemState(),UTCMillisecondsSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("minutes","",Class<IFunction>::getFunction(c->getSystemState(),getMinutes),GETTER_METHOD,true); + c->setDeclaredMethodByQName("minutes","",Class<IFunction>::getFunction(c->getSystemState(),minutesSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("minutesUTC","",Class<IFunction>::getFunction(c->getSystemState(),getUTCMinutes),GETTER_METHOD,true); + c->setDeclaredMethodByQName("minutesUTC","",Class<IFunction>::getFunction(c->getSystemState(),UTCMinutesSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("month","",Class<IFunction>::getFunction(c->getSystemState(),getMonth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("month","",Class<IFunction>::getFunction(c->getSystemState(),monthSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("monthUTC","",Class<IFunction>::getFunction(c->getSystemState(),getUTCMonth),GETTER_METHOD,true); + c->setDeclaredMethodByQName("monthUTC","",Class<IFunction>::getFunction(c->getSystemState(),UTCMonthSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("seconds","",Class<IFunction>::getFunction(c->getSystemState(),getSeconds),GETTER_METHOD,true); + c->setDeclaredMethodByQName("seconds","",Class<IFunction>::getFunction(c->getSystemState(),secondsSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("secondsUTC","",Class<IFunction>::getFunction(c->getSystemState(),getUTCSeconds),GETTER_METHOD,true); + c->setDeclaredMethodByQName("secondsUTC","",Class<IFunction>::getFunction(c->getSystemState(),UTCSecondsSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("time","",Class<IFunction>::getFunction(c->getSystemState(),getTime),GETTER_METHOD,true); + c->setDeclaredMethodByQName("time","",Class<IFunction>::getFunction(c->getSystemState(),timeSetter),SETTER_METHOD,true); + c->setDeclaredMethodByQName("timezoneOffset","",Class<IFunction>::getFunction(c->getSystemState(),getTimezoneOffset),GETTER_METHOD,true); + + c->prototype->setVariableByQName("getTimezoneOffset","",Class<IFunction>::getFunction(c->getSystemState(),getTimezoneOffset),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(c->getSystemState(),valueOf),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getTime","",Class<IFunction>::getFunction(c->getSystemState(),getTime),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getFullYear","",Class<IFunction>::getFunction(c->getSystemState(),getFullYear),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getMonth","",Class<IFunction>::getFunction(c->getSystemState(),getMonth),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getDate","",Class<IFunction>::getFunction(c->getSystemState(),getDate),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getDay","",Class<IFunction>::getFunction(c->getSystemState(),getDay),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getHours","",Class<IFunction>::getFunction(c->getSystemState(),getHours),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getMinutes","",Class<IFunction>::getFunction(c->getSystemState(),getMinutes),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getSeconds","",Class<IFunction>::getFunction(c->getSystemState(),getSeconds),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getMilliseconds","",Class<IFunction>::getFunction(c->getSystemState(),getMilliseconds),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setFullYear","",Class<IFunction>::getFunction(c->getSystemState(),setFullYear,3),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setMonth","",Class<IFunction>::getFunction(c->getSystemState(),setMonth,2),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setDate","",Class<IFunction>::getFunction(c->getSystemState(),setDate),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setHours","",Class<IFunction>::getFunction(c->getSystemState(),setHours,4),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setMinutes","",Class<IFunction>::getFunction(c->getSystemState(),setMinutes,3),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setSeconds","",Class<IFunction>::getFunction(c->getSystemState(),setSeconds,2),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setMilliseconds","",Class<IFunction>::getFunction(c->getSystemState(),setMilliseconds),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getUTCFullYear","",Class<IFunction>::getFunction(c->getSystemState(),getUTCFullYear),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getUTCMonth","",Class<IFunction>::getFunction(c->getSystemState(),getUTCMonth),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getUTCDate","",Class<IFunction>::getFunction(c->getSystemState(),getUTCDate),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getUTCDay","",Class<IFunction>::getFunction(c->getSystemState(),getUTCDay),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getUTCHours","",Class<IFunction>::getFunction(c->getSystemState(),getUTCHours),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getUTCMinutes","",Class<IFunction>::getFunction(c->getSystemState(),getUTCMinutes),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getUTCSeconds","",Class<IFunction>::getFunction(c->getSystemState(),getUTCSeconds),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("getUTCMilliseconds","",Class<IFunction>::getFunction(c->getSystemState(),getUTCMilliseconds),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setUTCFullYear","",Class<IFunction>::getFunction(c->getSystemState(),setUTCFullYear,3),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setUTCMonth","",Class<IFunction>::getFunction(c->getSystemState(),setUTCMonth,2),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setUTCDate","",Class<IFunction>::getFunction(c->getSystemState(),setUTCDate),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setUTCHours","",Class<IFunction>::getFunction(c->getSystemState(),setUTCHours,4),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setUTCMinutes","",Class<IFunction>::getFunction(c->getSystemState(),setUTCMinutes,3),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setUTCSeconds","",Class<IFunction>::getFunction(c->getSystemState(),setUTCSeconds,2),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setUTCMilliseconds","",Class<IFunction>::getFunction(c->getSystemState(),setUTCMilliseconds),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("setTime","",Class<IFunction>::getFunction(c->getSystemState(),setTime,1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toUTCString","",Class<IFunction>::getFunction(c->getSystemState(),toUTCString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toDateString","",Class<IFunction>::getFunction(c->getSystemState(),toDateString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toTimeString","",Class<IFunction>::getFunction(c->getSystemState(),toTimeString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toLocaleTimeString","",Class<IFunction>::getFunction(c->getSystemState(),toLocaleTimeString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toLocaleDateString","",Class<IFunction>::getFunction(c->getSystemState(),toLocaleDateString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toLocaleString","",Class<IFunction>::getFunction(c->getSystemState(),toLocaleString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toJSON",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); } void Date::buildTraits(ASObject* o) @@ -281,27 +281,27 @@ ASFUNCTIONBODY(Date,generator) { - Date* th=Class<Date>::getInstanceS(); + Date* th=Class<Date>::getInstanceS(getSys()); GDateTime* tmp = g_date_time_new_now_utc(); th->MakeDateFromMilliseconds(g_date_time_to_unix(tmp)*1000 + g_date_time_get_microsecond (tmp)/1000); g_date_time_unref(tmp); - return abstract_s(th->toString()); + return abstract_s(th->getSystemState(),th->toString()); } ASFUNCTIONBODY(Date,UTC) { for (uint32_t i = 0; i < argslen; i++) { if(args[i]->getObjectType()==T_NUMBER && std::isnan(args[i]->toNumber())) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } } number_t year, month, day, hour, minute, second, millisecond; ARG_UNPACK (year) (month) (day, 1) (hour, 0) (minute, 0) (second, 0) (millisecond, 0); - _R<Date> dt=_MR(Class<Date>::getInstanceS()); + _R<Date> dt=_MR(Class<Date>::getInstanceS(args[0]->getSystemState())); dt->MakeDate(year, month+1, day, hour, minute,second, millisecond,false); if(dt->nan) { - return abstract_d(Number::NaN); + return abstract_d(args[0]->getSystemState(),Number::NaN); } return dt->msSinceEpoch(); } @@ -310,163 +310,163 @@ { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } GTimeSpan diff = g_date_time_get_utc_offset(th->datetime); - return abstract_d(-diff/G_TIME_SPAN_MINUTE); + return abstract_d(obj->getSystemState(),-diff/G_TIME_SPAN_MINUTE); } ASFUNCTIONBODY(Date,getUTCFullYear) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(th->extrayears + g_date_time_get_year(th->datetimeUTC)); + return abstract_d(obj->getSystemState(),th->extrayears + g_date_time_get_year(th->datetimeUTC)); } ASFUNCTIONBODY(Date,getUTCMonth) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(g_date_time_get_month(th->datetimeUTC)-1); + return abstract_d(obj->getSystemState(),g_date_time_get_month(th->datetimeUTC)-1); } ASFUNCTIONBODY(Date,getUTCDate) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(g_date_time_get_day_of_month(th->datetimeUTC)); + return abstract_d(obj->getSystemState(),g_date_time_get_day_of_month(th->datetimeUTC)); } ASFUNCTIONBODY(Date,getUTCDay) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(g_date_time_get_day_of_week(th->datetimeUTC)%7); + return abstract_d(obj->getSystemState(),g_date_time_get_day_of_week(th->datetimeUTC)%7); } ASFUNCTIONBODY(Date,getUTCHours) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(g_date_time_get_hour(th->datetimeUTC)); + return abstract_d(obj->getSystemState(),g_date_time_get_hour(th->datetimeUTC)); } ASFUNCTIONBODY(Date,getUTCMinutes) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(g_date_time_get_minute(th->datetimeUTC)); + return abstract_d(obj->getSystemState(),g_date_time_get_minute(th->datetimeUTC)); } ASFUNCTIONBODY(Date,getUTCSeconds) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(g_date_time_get_second(th->datetimeUTC)); + return abstract_d(obj->getSystemState(),g_date_time_get_second(th->datetimeUTC)); } ASFUNCTIONBODY(Date,getUTCMilliseconds) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(th->milliseconds % 1000); + return abstract_d(obj->getSystemState(),th->milliseconds % 1000); } ASFUNCTIONBODY(Date,getFullYear) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(th->extrayears + g_date_time_get_year(th->datetime)); + return abstract_d(obj->getSystemState(),th->extrayears + g_date_time_get_year(th->datetime)); } ASFUNCTIONBODY(Date,getMonth) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(g_date_time_get_month(th->datetime)-1); + return abstract_d(obj->getSystemState(),g_date_time_get_month(th->datetime)-1); } ASFUNCTIONBODY(Date,getDate) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(g_date_time_get_day_of_month(th->datetime)); + return abstract_d(obj->getSystemState(),g_date_time_get_day_of_month(th->datetime)); } ASFUNCTIONBODY(Date,getDay) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(g_date_time_get_day_of_week(th->datetime)%7); + return abstract_d(obj->getSystemState(),g_date_time_get_day_of_week(th->datetime)%7); } ASFUNCTIONBODY(Date,getHours) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(g_date_time_get_hour(th->datetime)); + return abstract_d(obj->getSystemState(),g_date_time_get_hour(th->datetime)); } ASFUNCTIONBODY(Date,getMinutes) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(g_date_time_get_minute(th->datetime)); + return abstract_d(obj->getSystemState(),g_date_time_get_minute(th->datetime)); } ASFUNCTIONBODY(Date,getSeconds) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(g_date_time_get_second(th->datetime)); + return abstract_d(obj->getSystemState(),g_date_time_get_second(th->datetime)); } ASFUNCTIONBODY(Date,getMilliseconds) { Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } - return abstract_d(th->milliseconds % 1000); + return abstract_d(obj->getSystemState(),th->milliseconds % 1000); } ASFUNCTIONBODY(Date,getTime) { if (!obj->is<Date>()) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } return th->msSinceEpoch(); } @@ -477,7 +477,7 @@ if (argslen == 0) { th->nan = true; - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } number_t y, m, d; ARG_UNPACK (y) (m, 0) (d, 0); @@ -507,7 +507,7 @@ ARG_UNPACK (m) (d, 0); if (th->nan) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); if (argslen < 2) d = g_date_time_get_day_of_month(th->datetime); th->MakeDate(g_date_time_get_year(th->datetime)+th->extrayears, m+1, d, g_date_time_get_hour(th->datetime),g_date_time_get_minute(th->datetime),g_date_time_get_second(th->datetime),th->milliseconds % 1000,true); @@ -529,7 +529,7 @@ ARG_UNPACK (d); if (th->nan) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); th->MakeDate(g_date_time_get_year(th->datetime)+th->extrayears, g_date_time_get_month(th->datetime), d, g_date_time_get_hour(th->datetime),g_date_time_get_minute(th->datetime),g_date_time_get_second(th->datetime),th->milliseconds % 1000,true); return th->msSinceEpoch(); } @@ -549,7 +549,7 @@ ARG_UNPACK (h) (min, 0) (sec, 0) (ms, 0); if (th->nan) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); if (!min) min = g_date_time_get_minute(th->datetime); if (!sec) sec = g_date_time_get_second(th->datetime); if (!ms) ms = th->milliseconds % 1000; @@ -572,7 +572,7 @@ ARG_UNPACK (min) (sec, 0) (ms, 0); if (th->nan) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); if (!sec) sec = g_date_time_get_second(th->datetime); if (!ms) ms = th->milliseconds % 1000; th->MakeDate(g_date_time_get_year(th->datetime)+th->extrayears, g_date_time_get_month(th->datetime), g_date_time_get_day_of_month(th->datetime), g_date_time_get_hour(th->datetime), min, sec, ms,true); @@ -595,7 +595,7 @@ ARG_UNPACK (sec) (ms, 0); if (th->nan) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); if (!ms) ms = th->milliseconds % 1000; th->MakeDate(g_date_time_get_year(th->datetime)+th->extrayears, g_date_time_get_month(th->datetime), g_date_time_get_day_of_month(th->datetime), g_date_time_get_hour(th->datetime), g_date_time_get_minute(th->datetime), int64_t(sec), int64_t(ms),true); return th->msSinceEpoch(); @@ -616,7 +616,7 @@ ARG_UNPACK (ms); if (th->nan) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); th->MakeDate(g_date_time_get_year(th->datetime)+th->extrayears, g_date_time_get_month(th->datetime), g_date_time_get_day_of_month(th->datetime), g_date_time_get_hour(th->datetime), g_date_time_get_minute(th->datetime), g_date_time_get_second(th->datetime), ms,true); return th->msSinceEpoch(); } @@ -660,7 +660,7 @@ ARG_UNPACK (m) (d, 0); if (th->nan) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); if (argslen < 2) d = g_date_time_get_day_of_month(th->datetimeUTC); th->MakeDate(g_date_time_get_year(th->datetimeUTC)+th->extrayears, m+1, d, g_date_time_get_hour(th->datetimeUTC),g_date_time_get_minute(th->datetimeUTC),g_date_time_get_second(th->datetimeUTC),th->milliseconds % 1000,false); @@ -682,7 +682,7 @@ ARG_UNPACK (d); if (th->nan) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); th->MakeDate(g_date_time_get_year(th->datetimeUTC)+th->extrayears, g_date_time_get_month(th->datetimeUTC), d, g_date_time_get_hour(th->datetimeUTC),g_date_time_get_minute(th->datetimeUTC),g_date_time_get_second(th->datetimeUTC),th->milliseconds % 1000,false); return th->msSinceEpoch(); } @@ -702,7 +702,7 @@ ARG_UNPACK (h) (min, 0) (sec, 0) (ms, 0); if (th->nan) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); if (!min) min = g_date_time_get_minute(th->datetimeUTC); if (!sec) sec = g_date_time_get_second(th->datetimeUTC); if (!ms) ms = th->milliseconds % 1000; @@ -725,7 +725,7 @@ ARG_UNPACK (min) (sec, 0) (ms, 0); if (th->nan) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); if (!sec) sec = g_date_time_get_second(th->datetimeUTC); if (!ms) ms = th->milliseconds % 1000; th->MakeDate(g_date_time_get_year(th->datetimeUTC)+th->extrayears, g_date_time_get_month(th->datetimeUTC), g_date_time_get_day_of_month(th->datetimeUTC), g_date_time_get_hour(th->datetimeUTC), min, sec, ms,false); @@ -748,7 +748,7 @@ ARG_UNPACK (sec) (ms, 0); if (th->nan) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); if (!ms) ms = th->milliseconds % 1000; th->MakeDate(g_date_time_get_year(th->datetimeUTC)+th->extrayears, g_date_time_get_month(th->datetimeUTC), g_date_time_get_day_of_month(th->datetimeUTC), g_date_time_get_hour(th->datetimeUTC), g_date_time_get_minute(th->datetimeUTC), sec, ms,false); return th->msSinceEpoch(); @@ -769,7 +769,7 @@ ARG_UNPACK (ms); if (th->nan) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); th->MakeDate(g_date_time_get_year(th->datetimeUTC)+th->extrayears, g_date_time_get_month(th->datetimeUTC), g_date_time_get_day_of_month(th->datetimeUTC), g_date_time_get_hour(th->datetimeUTC), g_date_time_get_minute(th->datetimeUTC), g_date_time_get_second(th->datetimeUTC), ms,false); return th->msSinceEpoch(); } @@ -790,12 +790,12 @@ { multiname name(NULL); name.name_type=multiname::NAME_STRING; - name.name_s_id=getSys()->getUniqueStringId("value"); - name.ns.emplace_back("",NAMESPACE); - name.ns.emplace_back(AS3,NAMESPACE); + name.name_s_id=obj->getSystemState()->getUniqueStringId("value"); + name.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); + name.ns.emplace_back(obj->getSystemState(),AS3,NAMESPACE); name.isAttribute = true; - obj->setVariableByMultiname(name,abstract_d(ms),CONST_NOT_ALLOWED); - return abstract_d(ms); + obj->setVariableByMultiname(name,abstract_d(obj->getSystemState(),ms),CONST_NOT_ALLOWED); + return abstract_d(obj->getSystemState(),ms); } assert_and_throw(obj->is<Date>()); Date* th=static_cast<Date*>(obj); @@ -803,7 +803,7 @@ if (std::isnan(ms)) { th->nan = true; - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } th->MakeDateFromMilliseconds(int64_t(ms)); @@ -821,17 +821,17 @@ ASFUNCTIONBODY(Date,valueOf) { if (!obj->is<Date>()) - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); Date* th=static_cast<Date*>(obj); if(th->nan) { - return abstract_d(Number::NaN); + return abstract_d(obj->getSystemState(),Number::NaN); } return th->msSinceEpoch(); } ASObject* Date::msSinceEpoch() { - return abstract_d(getMsSinceEpoch()); + return abstract_d(getSystemState(),getMsSinceEpoch()); } number_t Date::getMsSinceEpoch() { @@ -862,27 +862,27 @@ ASFUNCTIONBODY(Date,_toString) { if (!obj->is<Date>()) - return abstract_s("Invalid Date"); + return abstract_s(obj->getSystemState(),"Invalid Date"); Date* th=static_cast<Date*>(obj); - return abstract_s(th->toString()); + return abstract_s(obj->getSystemState(),th->toString()); } ASFUNCTIONBODY(Date,toUTCString) { Date* th=static_cast<Date*>(obj); - return abstract_s(th->toString_priv(true,"%a %b %e %H:%M:%S UTC")); + return abstract_s(obj->getSystemState(),th->toString_priv(true,"%a %b %e %H:%M:%S UTC")); } ASFUNCTIONBODY(Date,toDateString) { Date* th=static_cast<Date*>(obj); - return abstract_s(th->toString_priv(false,"%a %b %e")); + return abstract_s(obj->getSystemState(),th->toString_priv(false,"%a %b %e")); } ASFUNCTIONBODY(Date,toTimeString) { Date* th=static_cast<Date*>(obj); - return abstract_s(g_date_time_format(th->datetime, "%H:%M:%S GMT%z")); + return abstract_s(obj->getSystemState(),g_date_time_format(th->datetime, "%H:%M:%S GMT%z")); } @@ -890,7 +890,7 @@ { Date* th=static_cast<Date*>(obj); if (!th->datetime) - return abstract_s(); + return abstract_s(obj->getSystemState()); tiny_string res = th->toString_priv(false,"%a %b %e"); gchar* fs = g_date_time_format(th->datetime, " %I:%M:%S"); res += fs; @@ -899,22 +899,22 @@ else res += " AM"; g_free(fs); - return abstract_s(res); + return abstract_s(obj->getSystemState(),res); } ASFUNCTIONBODY(Date,toLocaleDateString) { Date* th=static_cast<Date*>(obj); - return abstract_s(th->toString_priv(false,"%a %b %e")); + return abstract_s(obj->getSystemState(),th->toString_priv(false,"%a %b %e")); } ASFUNCTIONBODY(Date,toLocaleTimeString) { Date* th=static_cast<Date*>(obj); - return abstract_s(g_date_time_format(th->datetime, "%H:%M:%S %Z%z")); + return abstract_s(obj->getSystemState(),g_date_time_format(th->datetime, "%H:%M:%S %Z%z")); } ASFUNCTIONBODY(Date,_parse) { - return abstract_d(parse(args[0]->toString())); + return abstract_d(obj->getSystemState(),parse(args[0]->toString())); } static const char* months[] = { "Jan", "Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; @@ -1107,7 +1107,7 @@ y += 1900; if (mon >= 1 && mon <= 12 && d >= 1 && d <= 31 && h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59) { - _R<Date> dt=_MR(Class<Date>::getInstanceS()); + _R<Date> dt=_MR(Class<Date>::getInstanceS(getSys())); if (tz == 0) dt->MakeDate(y, mon, d, h, m, s, 0,bIsLocalTime); else
View file
lightspark.tar.xz/src/scripting/toplevel/Error.cpp
Changed
@@ -72,13 +72,14 @@ } if (Log::getLevel() >= LOG_INFO) { + SystemState* sys = getSys(); tiny_string stacktrace; - for (auto it = getVm()->stacktrace.crbegin(); it != getVm()->stacktrace.crend(); it++) + for (auto it = getVm(sys)->stacktrace.crbegin(); it != getVm(sys)->stacktrace.crend(); it++) { stacktrace += " at "; stacktrace += (*it).second->getClassName(); stacktrace += "/"; - stacktrace += getSys()->getStringFromUniqueId((*it).first); + stacktrace += sys->getStringFromUniqueId((*it).first); stacktrace += "()\n"; } LOG(LOG_INFO,"throwing exception:"<<errorID<<" "<<msg.str()<< "\n" << stacktrace); @@ -90,12 +91,12 @@ ASObject(c),errorID(id),name(error_name),message(error_message) { stacktrace = ""; - for (auto it = getVm()->stacktrace.crbegin(); it != getVm()->stacktrace.crend(); it++) + for (auto it = getVm(c->getSystemState())->stacktrace.crbegin(); it != getVm(c->getSystemState())->stacktrace.crend(); it++) { stacktrace += " at "; stacktrace += (*it).second->getClassName(); stacktrace += "/"; - stacktrace += getSys()->getStringFromUniqueId((*it).first); + stacktrace += c->getSystemState()->getStringFromUniqueId((*it).first); stacktrace += "()\n"; } } @@ -104,7 +105,7 @@ { ASError* th=static_cast<ASError*>(obj); - ASString* ret=Class<ASString>::getInstanceS(th->getStackTraceString()); + ASString* ret=abstract_s(obj->getSystemState(),th->getStackTraceString()); return ret; } tiny_string ASError::getStackTraceString() @@ -129,7 +130,7 @@ ASFUNCTIONBODY(ASError,_toString) { ASError* th=static_cast<ASError*>(obj); - return Class<ASString>::getInstanceS(th->ASError::toString()); + return abstract_s(obj->getSystemState(),th->ASError::toString()); } ASFUNCTIONBODY(ASError,_constructor) @@ -149,7 +150,7 @@ ASFUNCTIONBODY(ASError,generator) { - ASError* th=Class<ASError>::getInstanceS(); + ASError* th=Class<ASError>::getInstanceS(getSys()); errorGenerator(th, args, argslen); return th; } @@ -170,9 +171,9 @@ void ASError::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_DYNAMIC_NOT_FINAL); - c->setDeclaredMethodByQName("getStackTrace","",Class<IFunction>::getFunction(_getStackTrace),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("getStackTrace","",Class<IFunction>::getFunction(c->getSystemState(),_getStackTrace),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); REGISTER_GETTER(c, errorID); REGISTER_GETTER_SETTER(c, message); REGISTER_GETTER_SETTER(c, name); @@ -199,7 +200,7 @@ ASFUNCTIONBODY(SecurityError,generator) { - ASError* th=Class<SecurityError>::getInstanceS(); + ASError* th=Class<SecurityError>::getInstanceS(getSys()); errorGenerator(th, args, argslen); return th; } @@ -226,7 +227,7 @@ ASFUNCTIONBODY(ArgumentError,generator) { - ASError* th=Class<ArgumentError>::getInstanceS(); + ASError* th=Class<ArgumentError>::getInstanceS(getSys()); errorGenerator(th, args, argslen); return th; } @@ -253,7 +254,7 @@ ASFUNCTIONBODY(DefinitionError,generator) { - ASError* th=Class<DefinitionError>::getInstanceS(); + ASError* th=Class<DefinitionError>::getInstanceS(getSys()); errorGenerator(th, args, argslen); return th; } @@ -280,7 +281,7 @@ ASFUNCTIONBODY(EvalError,generator) { - ASError* th=Class<EvalError>::getInstanceS(); + ASError* th=Class<EvalError>::getInstanceS(getSys()); errorGenerator(th, args, argslen); return th; } @@ -307,7 +308,7 @@ ASFUNCTIONBODY(RangeError,generator) { - ASError* th=Class<RangeError>::getInstanceS(); + ASError* th=Class<RangeError>::getInstanceS(getSys()); errorGenerator(th, args, argslen); return th; } @@ -334,7 +335,7 @@ ASFUNCTIONBODY(ReferenceError,generator) { - ASError* th=Class<ReferenceError>::getInstanceS(); + ASError* th=Class<ReferenceError>::getInstanceS(getSys()); errorGenerator(th, args, argslen); return th; } @@ -361,7 +362,7 @@ ASFUNCTIONBODY(SyntaxError,generator) { - ASError* th=Class<SyntaxError>::getInstanceS(); + ASError* th=Class<SyntaxError>::getInstanceS(getSys()); errorGenerator(th, args, argslen); return th; } @@ -388,7 +389,7 @@ ASFUNCTIONBODY(TypeError,generator) { - ASError* th=Class<TypeError>::getInstanceS(); + ASError* th=Class<TypeError>::getInstanceS(getSys()); errorGenerator(th, args, argslen); return th; } @@ -415,7 +416,7 @@ ASFUNCTIONBODY(URIError,generator) { - ASError* th=Class<URIError>::getInstanceS(); + ASError* th=Class<URIError>::getInstanceS(getSys()); errorGenerator(th, args, argslen); return th; } @@ -442,7 +443,7 @@ ASFUNCTIONBODY(VerifyError,generator) { - ASError* th=Class<VerifyError>::getInstanceS(); + ASError* th=Class<VerifyError>::getInstanceS(getSys()); errorGenerator(th, args, argslen); return th; } @@ -469,7 +470,7 @@ ASFUNCTIONBODY(UninitializedError,generator) { - ASError* th=Class<UninitializedError>::getInstanceS(); + ASError* th=Class<UninitializedError>::getInstanceS(getSys()); errorGenerator(th, args, argslen); return th; }
View file
lightspark.tar.xz/src/scripting/toplevel/Error.h
Changed
@@ -36,7 +36,7 @@ void throwError(int errorID, const tiny_string& arg1="", const tiny_string& arg2="", const tiny_string& arg3="") { tiny_string message = createErrorMessage(errorID, arg1, arg2, arg3); - throw Class<T>::getInstanceS(message, errorID); + throw Class<T>::getInstanceS(getSys(),message, errorID); } class ASError: public ASObject
View file
lightspark.tar.xz/src/scripting/toplevel/Integer.cpp
Changed
@@ -28,8 +28,8 @@ ASFUNCTIONBODY(Integer,_toString) { - if(Class<Integer>::getClass()->prototype->getObj() == obj) - return abstract_s("0"); + if(Class<Integer>::getClass(obj->getSystemState())->prototype->getObj() == obj) + return abstract_s(obj->getSystemState(),"0"); Integer* th=static_cast<Integer*>(obj); int radix=10; @@ -40,24 +40,24 @@ { char buf[20]; snprintf(buf,20,"%i",th->val); - return abstract_s(buf); + return abstract_s(obj->getSystemState(),buf); } else { tiny_string s=Number::toStringRadix((number_t)th->val, radix); - return abstract_s(s); + return abstract_s(obj->getSystemState(),s); } } ASFUNCTIONBODY(Integer,_valueOf) { - if(Class<Integer>::getClass()->prototype->getObj() == obj) - return abstract_i(0); + if(Class<Integer>::getClass(obj->getSystemState())->prototype->getObj() == obj) + return abstract_i(obj->getSystemState(),0); if(!obj->is<Integer>()) - throw Class<TypeError>::getInstanceS(""); + throw Class<TypeError>::getInstanceS(obj->getSystemState(),""); - return abstract_i(obj->as<Integer>()->val); + return abstract_i(obj->getSystemState(),obj->as<Integer>()->val); } ASFUNCTIONBODY(Integer,_constructor) @@ -75,8 +75,8 @@ ASFUNCTIONBODY(Integer,generator) { if (argslen == 0) - return abstract_i(0); - return abstract_i(args[0]->toInt()); + return abstract_i(getSys(),0); + return abstract_i(args[0]->getSystemState(),args[0]->toInt()); } TRISTATE Integer::isLess(ASObject* o) @@ -196,18 +196,18 @@ { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); c->isReusable = true; - c->setVariableByQName("MAX_VALUE","",abstract_i(numeric_limits<int32_t>::max()),CONSTANT_TRAIT); - c->setVariableByQName("MIN_VALUE","",abstract_i(numeric_limits<int32_t>::min()),CONSTANT_TRAIT); - c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toFixed",AS3,Class<IFunction>::getFunction(_toFixed,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toExponential",AS3,Class<IFunction>::getFunction(_toExponential,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toPrecision",AS3,Class<IFunction>::getFunction(_toPrecision,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(_valueOf),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toExponential","",Class<IFunction>::getFunction(Integer::_toExponential, 1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toFixed","",Class<IFunction>::getFunction(Integer::_toFixed, 1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toPrecision","",Class<IFunction>::getFunction(Integer::_toPrecision, 1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(Integer::_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(_valueOf),DYNAMIC_TRAIT); + c->setVariableByQName("MAX_VALUE","",abstract_i(c->getSystemState(),numeric_limits<int32_t>::max()),CONSTANT_TRAIT); + c->setVariableByQName("MIN_VALUE","",abstract_i(c->getSystemState(),numeric_limits<int32_t>::min()),CONSTANT_TRAIT); + c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toFixed",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toFixed,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toExponential",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toExponential,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toPrecision",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toPrecision,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),_valueOf),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toExponential","",Class<IFunction>::getFunction(c->getSystemState(),Integer::_toExponential, 1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toFixed","",Class<IFunction>::getFunction(c->getSystemState(),Integer::_toFixed, 1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toPrecision","",Class<IFunction>::getFunction(c->getSystemState(),Integer::_toPrecision, 1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),Integer::_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(c->getSystemState(),_valueOf),DYNAMIC_TRAIT); } void Integer::serialize(ByteArray* out, std::map<tiny_string, uint32_t>& stringMap, @@ -305,7 +305,7 @@ else fractionDigits = imin(imax((int32_t)ceil(::log10(::fabs(v))), 1), 20); } - return abstract_s(Number::toExponentialString(v, fractionDigits)); + return abstract_s(obj->getSystemState(),Number::toExponentialString(v, fractionDigits)); } ASFUNCTIONBODY(Integer,_toFixed) @@ -313,15 +313,15 @@ Integer *th=obj->as<Integer>(); int fractiondigits; ARG_UNPACK (fractiondigits, 0); - return abstract_s(Number::toFixedString(th->val, fractiondigits)); + return abstract_s(obj->getSystemState(),Number::toFixedString(th->val, fractiondigits)); } ASFUNCTIONBODY(Integer,_toPrecision) { Integer *th=obj->as<Integer>(); if (argslen == 0 || args[0]->is<Undefined>()) - return abstract_s(th->toString()); + return abstract_s(obj->getSystemState(),th->toString()); int precision; ARG_UNPACK (precision); - return abstract_s(Number::toPrecisionString(th->val, precision)); + return abstract_s(obj->getSystemState(),Number::toPrecisionString(th->val, precision)); }
View file
lightspark.tar.xz/src/scripting/toplevel/Integer.h
Changed
@@ -37,7 +37,8 @@ int32_t val; static void buildTraits(ASObject* o){}; static void sinit(Class_base* c); - void finalize() { val=0;} + inline number_t toNumber() { return val; } + inline void finalize() { val=0;} ASFUNCTION(_toString); tiny_string toString(); static tiny_string toString(int32_t val);
View file
lightspark.tar.xz/src/scripting/toplevel/JSON.cpp
Changed
@@ -31,8 +31,8 @@ void JSON::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); - c->setDeclaredMethodByQName("parse","",Class<IFunction>::getFunction(_parse,2),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("stringify","",Class<IFunction>::getFunction(_stringify,3),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("parse","",Class<IFunction>::getFunction(c->getSystemState(),_parse,2),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("stringify","",Class<IFunction>::getFunction(c->getSystemState(),_stringify,3),NORMAL_METHOD,false); } void JSON::buildTraits(ASObject* o) { @@ -127,7 +127,7 @@ } tiny_string res = value->toJSON(path,replacer,spaces,filter); - return Class<ASString>::getInstanceS(res); + return abstract_s(obj->getSystemState(),res); } void JSON::parseAll(const tiny_string &jsonstring, ASObject** parent , const multiname& key, IFunction *reviver) { @@ -202,7 +202,7 @@ if (haskey) { - params[0] = Class<ASString>::getInstanceS(key.normalizedName()); + params[0] = abstract_s(getSys(),key.normalizedName(getSys())); if ((*parent)->hasPropertyByMultiname(key,true,false)) { params[1] = (*parent)->getVariableByMultiname(key).getPtr(); @@ -213,7 +213,7 @@ } else { - params[0] = Class<ASString>::getInstanceS(""); + params[0] = abstract_s(getSys(),""); params[1] = *parent; params[1]->incRef(); } @@ -251,9 +251,9 @@ { pos += 4; if (*parent == NULL) - *parent = abstract_b(true); + *parent = abstract_b(getSys(),true); else - (*parent)->setVariableByMultiname(key,abstract_b(true),ASObject::CONST_NOT_ALLOWED); + (*parent)->setVariableByMultiname(key,abstract_b((*parent)->getSystemState(),true),ASObject::CONST_NOT_ALLOWED); } else throwError<SyntaxError>(kJSONInvalidParseInput); @@ -275,9 +275,9 @@ { pos += 5; if (*parent == NULL) - *parent = abstract_b(false); + *parent = abstract_b(getSys(),false); else - (*parent)->setVariableByMultiname(key,abstract_b(false),ASObject::CONST_NOT_ALLOWED); + (*parent)->setVariableByMultiname(key,abstract_b((*parent)->getSystemState(),false),ASObject::CONST_NOT_ALLOWED); } else throwError<SyntaxError>(kJSONInvalidParseInput); @@ -418,9 +418,9 @@ if (parent != NULL) { if (*parent == NULL) - *parent = Class<ASString>::getInstanceS(res); + *parent = abstract_s(getSys(),res); else - (*parent)->setVariableByMultiname(key,Class<ASString>::getInstanceS(res),ASObject::CONST_NOT_ALLOWED); + (*parent)->setVariableByMultiname(key,abstract_s(getSys(),res),ASObject::CONST_NOT_ALLOWED); } if (result) *result =res; @@ -459,17 +459,17 @@ break; } } - ASString* numstr = Class<ASString>::getInstanceS(res); + ASString* numstr = abstract_s(getSys(),res); number_t num = numstr->toNumber(); if (std::isnan(num)) throwError<SyntaxError>(kJSONInvalidParseInput); if (*parent == NULL) - *parent = Class<Number>::getInstanceS(num); + *parent = abstract_d(getSys(),num); else { - (*parent)->setVariableByMultiname(key,Class<Number>::getInstanceS(num),ASObject::CONST_NOT_ALLOWED); + (*parent)->setVariableByMultiname(key,abstract_d(getSys(),num),ASObject::CONST_NOT_ALLOWED); } return pos; } @@ -477,14 +477,14 @@ { int len = jsonstring.numChars(); pos++; // ignore '{' or ',' - ASObject* subobj = Class<ASObject>::getInstanceS(); + ASObject* subobj = Class<ASObject>::getInstanceS(getSys()); if (*parent == NULL) *parent = subobj; else (*parent)->setVariableByMultiname(key,subobj,ASObject::CONST_NOT_ALLOWED); multiname name(NULL); name.name_type=multiname::NAME_STRING; - name.ns.push_back(nsNameAndKind("",NAMESPACE)); + name.ns.push_back(nsNameAndKind(getSys(),"",NAMESPACE)); name.isAttribute = false; bool done = false; bool bfirst = true; @@ -544,7 +544,7 @@ { int len = jsonstring.numChars(); pos++; // ignore '[' - ASObject* subobj = Class<Array>::getInstanceS(); + ASObject* subobj = Class<Array>::getInstanceS(getSys()); if (*parent == NULL) *parent = subobj; else @@ -552,7 +552,7 @@ multiname name(NULL); name.name_type=multiname::NAME_INT; name.name_i = 0; - name.ns.push_back(nsNameAndKind("",NAMESPACE)); + name.ns.push_back(nsNameAndKind(getSys(),"",NAMESPACE)); name.isAttribute = false; bool done = false; bool needdata = false;
View file
lightspark.tar.xz/src/scripting/toplevel/Math.cpp
Changed
@@ -28,34 +28,34 @@ { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); // public constants - c->setVariableByQName("E","",abstract_d(2.71828182845905),CONSTANT_TRAIT); - c->setVariableByQName("LN10","",abstract_d(2.302585092994046),CONSTANT_TRAIT); - c->setVariableByQName("LN2","",abstract_d(0.6931471805599453),CONSTANT_TRAIT); - c->setVariableByQName("LOG10E","",abstract_d(0.4342944819032518),CONSTANT_TRAIT); - c->setVariableByQName("LOG2E","",abstract_d(1.442695040888963387),CONSTANT_TRAIT); - c->setVariableByQName("PI","",abstract_d(3.141592653589793),CONSTANT_TRAIT); - c->setVariableByQName("SQRT1_2","",abstract_d(0.7071067811865476),CONSTANT_TRAIT); - c->setVariableByQName("SQRT2","",abstract_d(1.4142135623730951),CONSTANT_TRAIT); + c->setVariableByQName("E","",abstract_d(c->getSystemState(),2.71828182845905),CONSTANT_TRAIT); + c->setVariableByQName("LN10","",abstract_d(c->getSystemState(),2.302585092994046),CONSTANT_TRAIT); + c->setVariableByQName("LN2","",abstract_d(c->getSystemState(),0.6931471805599453),CONSTANT_TRAIT); + c->setVariableByQName("LOG10E","",abstract_d(c->getSystemState(),0.4342944819032518),CONSTANT_TRAIT); + c->setVariableByQName("LOG2E","",abstract_d(c->getSystemState(),1.442695040888963387),CONSTANT_TRAIT); + c->setVariableByQName("PI","",abstract_d(c->getSystemState(),3.141592653589793),CONSTANT_TRAIT); + c->setVariableByQName("SQRT1_2","",abstract_d(c->getSystemState(),0.7071067811865476),CONSTANT_TRAIT); + c->setVariableByQName("SQRT2","",abstract_d(c->getSystemState(),1.4142135623730951),CONSTANT_TRAIT); // public methods - c->setDeclaredMethodByQName("abs","",Class<IFunction>::getFunction(abs,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("acos","",Class<IFunction>::getFunction(acos,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("asin","",Class<IFunction>::getFunction(asin,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("atan","",Class<IFunction>::getFunction(atan,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("atan2","",Class<IFunction>::getFunction(atan2,2),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("ceil","",Class<IFunction>::getFunction(ceil,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("cos","",Class<IFunction>::getFunction(cos,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("exp","",Class<IFunction>::getFunction(exp,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("floor","",Class<IFunction>::getFunction(floor,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("log","",Class<IFunction>::getFunction(log,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("max","",Class<IFunction>::getFunction(_max,2),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("min","",Class<IFunction>::getFunction(_min,2),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("pow","",Class<IFunction>::getFunction(pow,2),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("random","",Class<IFunction>::getFunction(random),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("round","",Class<IFunction>::getFunction(round,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("sin","",Class<IFunction>::getFunction(sin,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("sqrt","",Class<IFunction>::getFunction(sqrt,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("tan","",Class<IFunction>::getFunction(tan,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("abs","",Class<IFunction>::getFunction(c->getSystemState(),abs,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("acos","",Class<IFunction>::getFunction(c->getSystemState(),acos,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("asin","",Class<IFunction>::getFunction(c->getSystemState(),asin,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("atan","",Class<IFunction>::getFunction(c->getSystemState(),atan,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("atan2","",Class<IFunction>::getFunction(c->getSystemState(),atan2,2),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("ceil","",Class<IFunction>::getFunction(c->getSystemState(),ceil,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("cos","",Class<IFunction>::getFunction(c->getSystemState(),cos,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("exp","",Class<IFunction>::getFunction(c->getSystemState(),exp,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("floor","",Class<IFunction>::getFunction(c->getSystemState(),floor,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("log","",Class<IFunction>::getFunction(c->getSystemState(),log,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("max","",Class<IFunction>::getFunction(c->getSystemState(),_max,2),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("min","",Class<IFunction>::getFunction(c->getSystemState(),_min,2),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("pow","",Class<IFunction>::getFunction(c->getSystemState(),pow,2),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("random","",Class<IFunction>::getFunction(c->getSystemState(),random),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("round","",Class<IFunction>::getFunction(c->getSystemState(),round,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("sin","",Class<IFunction>::getFunction(c->getSystemState(),sin,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("sqrt","",Class<IFunction>::getFunction(c->getSystemState(),sqrt,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("tan","",Class<IFunction>::getFunction(c->getSystemState(),tan,1),NORMAL_METHOD,false); } ASFUNCTIONBODY(Math,_constructor) @@ -74,7 +74,7 @@ { number_t n1, n2; ARG_UNPACK (n1) (n2); - return abstract_d(::atan2(n1,n2)); + return abstract_d(obj->getSystemState(),::atan2(n1,n2)); } ASFUNCTIONBODY(Math,_max) @@ -94,7 +94,7 @@ else largest = (arg>largest) ? arg : largest; } - return abstract_d(largest); + return abstract_d(obj->getSystemState(),largest); } ASFUNCTIONBODY(Math,_min) @@ -115,14 +115,14 @@ smallest = (arg<smallest)? arg : smallest; } - return abstract_d(smallest); + return abstract_d(obj->getSystemState(),smallest); } ASFUNCTIONBODY(Math,exp) { number_t n; ARG_UNPACK (n); - return abstract_d(::exp(n)); + return abstract_d(obj->getSystemState(),::exp(n)); } ASFUNCTIONBODY(Math,acos) @@ -130,7 +130,7 @@ //Angle is in radians number_t n; ARG_UNPACK (n); - return abstract_d(::acos(n)); + return abstract_d(obj->getSystemState(),::acos(n)); } ASFUNCTIONBODY(Math,asin) @@ -138,7 +138,7 @@ //Angle is in radians number_t n; ARG_UNPACK (n); - return abstract_d(::asin(n)); + return abstract_d(obj->getSystemState(),::asin(n)); } ASFUNCTIONBODY(Math,atan) @@ -146,7 +146,7 @@ //Angle is in radians number_t n; ARG_UNPACK (n); - return abstract_d(::atan(n)); + return abstract_d(obj->getSystemState(),::atan(n)); } ASFUNCTIONBODY(Math,cos) @@ -154,7 +154,7 @@ //Angle is in radians number_t n; ARG_UNPACK (n); - return abstract_d(::cos(n)); + return abstract_d(obj->getSystemState(),::cos(n)); } ASFUNCTIONBODY(Math,sin) @@ -162,7 +162,7 @@ //Angle is in radians number_t n; ARG_UNPACK (n); - return abstract_d(::sin(n)); + return abstract_d(obj->getSystemState(),::sin(n)); } ASFUNCTIONBODY(Math,tan) @@ -170,35 +170,35 @@ //Angle is in radians number_t n; ARG_UNPACK (n); - return abstract_d(::tan(n)); + return abstract_d(obj->getSystemState(),::tan(n)); } ASFUNCTIONBODY(Math,abs) { number_t n; ARG_UNPACK (n); - return abstract_d(::fabs(n)); + return abstract_d(obj->getSystemState(),::fabs(n)); } ASFUNCTIONBODY(Math,ceil) { number_t n; ARG_UNPACK (n); - return abstract_d(::ceil(n)); + return abstract_d(obj->getSystemState(),::ceil(n)); } ASFUNCTIONBODY(Math,log) { number_t n; ARG_UNPACK (n); - return abstract_d(::log(n)); + return abstract_d(obj->getSystemState(),::log(n)); } ASFUNCTIONBODY(Math,floor) { number_t n; ARG_UNPACK (n); - return abstract_d(::floor(n)); + return abstract_d(obj->getSystemState(),::floor(n)); } ASFUNCTIONBODY(Math,round) @@ -206,15 +206,15 @@ number_t n; ARG_UNPACK (n); if (n < 0 && n >= -0.5) - return abstract_d(0); - return abstract_d(::round(n)); + return abstract_d(obj->getSystemState(),0); + return abstract_d(obj->getSystemState(),::round(n)); } ASFUNCTIONBODY(Math,sqrt) { number_t n; ARG_UNPACK (n); - return abstract_d(::sqrt(n)); + return abstract_d(obj->getSystemState(),::sqrt(n)); } ASFUNCTIONBODY(Math,pow) @@ -222,8 +222,8 @@ number_t x, y; ARG_UNPACK (x) (y); if (::fabs(x) == 1 && (std::isnan(y) || std::isinf(y)) ) - return abstract_d(Number::NaN); - return abstract_d(::pow(x,y)); + return abstract_d(obj->getSystemState(),Number::NaN); + return abstract_d(obj->getSystemState(),::pow(x,y)); } ASFUNCTIONBODY(Math,random) @@ -233,7 +233,7 @@ number_t ret=rand(); ret/=(number_t(1.)+RAND_MAX); - return abstract_d(ret); + return abstract_d(obj->getSystemState(),ret); }
View file
lightspark.tar.xz/src/scripting/toplevel/Number.cpp
Changed
@@ -166,8 +166,8 @@ ASFUNCTIONBODY(Number,_toString) { - if(Class<Number>::getClass()->prototype->getObj() == obj) - return abstract_s("0"); + if(Class<Number>::getClass(obj->getSystemState())->prototype->getObj() == obj) + return abstract_s(obj->getSystemState(),"0"); if(!obj->is<Number>()) throwError<TypeError>(kInvokeOnIncompatibleObjectError, "Number.toString"); Number* th=static_cast<Number*>(obj); @@ -177,20 +177,20 @@ if(radix==10 || std::isnan(th->val) || std::isinf(th->val)) { //see e 15.7.4.2 - return abstract_s(th->toString()); + return abstract_s(obj->getSystemState(),th->toString()); } else { - return abstract_s(Number::toStringRadix(th->val, radix)); + return abstract_s(obj->getSystemState(),Number::toStringRadix(th->val, radix)); } } ASFUNCTIONBODY(Number,generator) { if(argslen==0) - return abstract_d(0.); + return abstract_d(getSys(),0.); else - return abstract_d(args[0]->toNumber()); + return abstract_d(args[0]->getSystemState(),args[0]->toNumber()); } tiny_string Number::toString() @@ -253,53 +253,53 @@ { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); c->isReusable = true; - c->setVariableByQName("NEGATIVE_INFINITY","",abstract_d(-numeric_limits<double>::infinity()),CONSTANT_TRAIT); - c->setVariableByQName("POSITIVE_INFINITY","",abstract_d(numeric_limits<double>::infinity()),CONSTANT_TRAIT); - c->setVariableByQName("MAX_VALUE","",abstract_d(numeric_limits<double>::max()),CONSTANT_TRAIT); - c->setVariableByQName("MIN_VALUE","",abstract_d(numeric_limits<double>::min()),CONSTANT_TRAIT); - c->setVariableByQName("NaN","",abstract_d(numeric_limits<double>::quiet_NaN()),CONSTANT_TRAIT); - c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toFixed",AS3,Class<IFunction>::getFunction(toFixed,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toExponential",AS3,Class<IFunction>::getFunction(toExponential,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toPrecision",AS3,Class<IFunction>::getFunction(toPrecision,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(_valueOf),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(Number::_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toLocaleString","",Class<IFunction>::getFunction(Number::_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toFixed","",Class<IFunction>::getFunction(Number::toFixed, 1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toExponential","",Class<IFunction>::getFunction(Number::toExponential, 1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toPrecision","",Class<IFunction>::getFunction(Number::toPrecision, 1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(_valueOf),DYNAMIC_TRAIT); + c->setVariableByQName("NEGATIVE_INFINITY","",abstract_d(c->getSystemState(),-numeric_limits<double>::infinity()),CONSTANT_TRAIT); + c->setVariableByQName("POSITIVE_INFINITY","",abstract_d(c->getSystemState(),numeric_limits<double>::infinity()),CONSTANT_TRAIT); + c->setVariableByQName("MAX_VALUE","",abstract_d(c->getSystemState(),numeric_limits<double>::max()),CONSTANT_TRAIT); + c->setVariableByQName("MIN_VALUE","",abstract_d(c->getSystemState(),numeric_limits<double>::min()),CONSTANT_TRAIT); + c->setVariableByQName("NaN","",abstract_d(c->getSystemState(),numeric_limits<double>::quiet_NaN()),CONSTANT_TRAIT); + c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toFixed",AS3,Class<IFunction>::getFunction(c->getSystemState(),toFixed,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toExponential",AS3,Class<IFunction>::getFunction(c->getSystemState(),toExponential,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toPrecision",AS3,Class<IFunction>::getFunction(c->getSystemState(),toPrecision,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),_valueOf),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),Number::_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toLocaleString","",Class<IFunction>::getFunction(c->getSystemState(),Number::_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toFixed","",Class<IFunction>::getFunction(c->getSystemState(),Number::toFixed, 1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toExponential","",Class<IFunction>::getFunction(c->getSystemState(),Number::toExponential, 1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toPrecision","",Class<IFunction>::getFunction(c->getSystemState(),Number::toPrecision, 1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(c->getSystemState(),_valueOf),DYNAMIC_TRAIT); // if needed add AVMPLUS definitions - if(getSys()->flashMode==SystemState::AVMPLUS) + if(c->getSystemState()->flashMode==SystemState::AVMPLUS) { - c->setVariableByQName("E","",abstract_d(2.71828182845905),CONSTANT_TRAIT); - c->setVariableByQName("LN10","",abstract_d(2.302585092994046),CONSTANT_TRAIT); - c->setVariableByQName("LN2","",abstract_d(0.6931471805599453),CONSTANT_TRAIT); - c->setVariableByQName("LOG10E","",abstract_d(0.4342944819032518),CONSTANT_TRAIT); - c->setVariableByQName("LOG2E","",abstract_d(1.442695040888963387),CONSTANT_TRAIT); - c->setVariableByQName("PI","",abstract_d(3.141592653589793),CONSTANT_TRAIT); - c->setVariableByQName("SQRT1_2","",abstract_d(0.7071067811865476),CONSTANT_TRAIT); - c->setVariableByQName("SQRT2","",abstract_d(1.4142135623730951),CONSTANT_TRAIT); + c->setVariableByQName("E","",abstract_d(c->getSystemState(),2.71828182845905),CONSTANT_TRAIT); + c->setVariableByQName("LN10","",abstract_d(c->getSystemState(),2.302585092994046),CONSTANT_TRAIT); + c->setVariableByQName("LN2","",abstract_d(c->getSystemState(),0.6931471805599453),CONSTANT_TRAIT); + c->setVariableByQName("LOG10E","",abstract_d(c->getSystemState(),0.4342944819032518),CONSTANT_TRAIT); + c->setVariableByQName("LOG2E","",abstract_d(c->getSystemState(),1.442695040888963387),CONSTANT_TRAIT); + c->setVariableByQName("PI","",abstract_d(c->getSystemState(),3.141592653589793),CONSTANT_TRAIT); + c->setVariableByQName("SQRT1_2","",abstract_d(c->getSystemState(),0.7071067811865476),CONSTANT_TRAIT); + c->setVariableByQName("SQRT2","",abstract_d(c->getSystemState(),1.4142135623730951),CONSTANT_TRAIT); - c->setDeclaredMethodByQName("abs","",Class<IFunction>::getFunction(Math::abs,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("acos","",Class<IFunction>::getFunction(Math::acos,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("asin","",Class<IFunction>::getFunction(Math::asin,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("atan","",Class<IFunction>::getFunction(Math::atan,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("atan2","",Class<IFunction>::getFunction(Math::atan2,2),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("ceil","",Class<IFunction>::getFunction(Math::ceil,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("cos","",Class<IFunction>::getFunction(Math::cos,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("exp","",Class<IFunction>::getFunction(Math::exp,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("floor","",Class<IFunction>::getFunction(Math::floor,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("log","",Class<IFunction>::getFunction(Math::log,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("max","",Class<IFunction>::getFunction(Math::_max,2),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("min","",Class<IFunction>::getFunction(Math::_min,2),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("pow","",Class<IFunction>::getFunction(Math::pow,2),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("random","",Class<IFunction>::getFunction(Math::random),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("round","",Class<IFunction>::getFunction(Math::round,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("sin","",Class<IFunction>::getFunction(Math::sin,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("sqrt","",Class<IFunction>::getFunction(Math::sqrt,1),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("tan","",Class<IFunction>::getFunction(Math::tan,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("abs","",Class<IFunction>::getFunction(c->getSystemState(),Math::abs,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("acos","",Class<IFunction>::getFunction(c->getSystemState(),Math::acos,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("asin","",Class<IFunction>::getFunction(c->getSystemState(),Math::asin,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("atan","",Class<IFunction>::getFunction(c->getSystemState(),Math::atan,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("atan2","",Class<IFunction>::getFunction(c->getSystemState(),Math::atan2,2),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("ceil","",Class<IFunction>::getFunction(c->getSystemState(),Math::ceil,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("cos","",Class<IFunction>::getFunction(c->getSystemState(),Math::cos,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("exp","",Class<IFunction>::getFunction(c->getSystemState(),Math::exp,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("floor","",Class<IFunction>::getFunction(c->getSystemState(),Math::floor,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("log","",Class<IFunction>::getFunction(c->getSystemState(),Math::log,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("max","",Class<IFunction>::getFunction(c->getSystemState(),Math::_max,2),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("min","",Class<IFunction>::getFunction(c->getSystemState(),Math::_min,2),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("pow","",Class<IFunction>::getFunction(c->getSystemState(),Math::pow,2),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("random","",Class<IFunction>::getFunction(c->getSystemState(),Math::random),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("round","",Class<IFunction>::getFunction(c->getSystemState(),Math::round,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("sin","",Class<IFunction>::getFunction(c->getSystemState(),Math::sin,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("sqrt","",Class<IFunction>::getFunction(c->getSystemState(),Math::sqrt,1),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("tan","",Class<IFunction>::getFunction(c->getSystemState(),Math::tan,1),NORMAL_METHOD,false); } } @@ -322,7 +322,7 @@ number_t val = obj->toNumber(); int fractiondigits; ARG_UNPACK (fractiondigits,0); - return abstract_s(toFixedString(val, fractiondigits)); + return abstract_s(obj->getSystemState(),toFixedString(val, fractiondigits)); } tiny_string Number::toFixedString(double v, int32_t fractiondigits) @@ -367,7 +367,7 @@ ARG_UNPACK(fractionDigits, 0); if (argslen == 0 || args[0]->is<Undefined>()) fractionDigits = imin(imax(Number::countSignificantDigits(v)-1, 1), 20); - return abstract_s(toExponentialString(v, fractionDigits)); + return abstract_s(obj->getSystemState(),toExponentialString(v, fractionDigits)); } tiny_string Number::toExponentialString(double v, int32_t fractionDigits) @@ -471,11 +471,11 @@ Number* th=obj->as<Number>(); double v = th->val; if (argslen == 0 || args[0]->is<Undefined>()) - return abstract_s(toString(v)); + return abstract_s(obj->getSystemState(),toString(v)); int32_t precision; ARG_UNPACK(precision); - return abstract_s(toPrecisionString(v, precision)); + return abstract_s(obj->getSystemState(),toPrecisionString(v, precision)); } tiny_string Number::toPrecisionString(double v, int32_t precision) @@ -508,13 +508,13 @@ ASFUNCTIONBODY(Number,_valueOf) { - if(Class<Number>::getClass()->prototype->getObj() == obj) - return abstract_d(0.); + if(Class<Number>::getClass(obj->getSystemState())->prototype->getObj() == obj) + return abstract_d(obj->getSystemState(),0.); if(!obj->is<Number>()) throwError<TypeError>(kInvokeOnIncompatibleObjectError); - return abstract_d(obj->as<Number>()->val); + return abstract_d(obj->getSystemState(),obj->as<Number>()->val); } void Number::serialize(ByteArray* out, std::map<tiny_string, uint32_t>& stringMap,
View file
lightspark.tar.xz/src/scripting/toplevel/Number.h
Changed
@@ -40,7 +40,8 @@ Number(Class_base* c, double v=(std::numeric_limits<double>::quiet_NaN())):ASObject(c),val(v){type=T_NUMBER;} static const number_t NaN; double val; - void finalize() { val=std::numeric_limits<double>::quiet_NaN();} + inline number_t toNumber() { return val; } + inline void finalize() { val=std::numeric_limits<double>::quiet_NaN();} ASFUNCTION(_constructor); ASFUNCTION(_toString); ASFUNCTION(toExponential);
View file
lightspark.tar.xz/src/scripting/toplevel/RegExp.cpp
Changed
@@ -36,16 +36,16 @@ void RegExp::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_DYNAMIC_NOT_FINAL); - c->setDeclaredMethodByQName("exec","",Class<IFunction>::getFunction(exec),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("exec",AS3,Class<IFunction>::getFunction(exec),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("test","",Class<IFunction>::getFunction(test),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("test",AS3,Class<IFunction>::getFunction(test),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("exec","",Class<IFunction>::getFunction(exec),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("exec",AS3,Class<IFunction>::getFunction(exec),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("test","",Class<IFunction>::getFunction(test),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("test",AS3,Class<IFunction>::getFunction(test),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("exec","",Class<IFunction>::getFunction(c->getSystemState(),exec),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("exec",AS3,Class<IFunction>::getFunction(c->getSystemState(),exec),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("test","",Class<IFunction>::getFunction(c->getSystemState(),test),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("test",AS3,Class<IFunction>::getFunction(c->getSystemState(),test),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("exec","",Class<IFunction>::getFunction(c->getSystemState(),exec),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("exec",AS3,Class<IFunction>::getFunction(c->getSystemState(),exec),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("test","",Class<IFunction>::getFunction(c->getSystemState(),test),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("test",AS3,Class<IFunction>::getFunction(c->getSystemState(),test),DYNAMIC_TRAIT); REGISTER_GETTER(c,dotall); REGISTER_GETTER(c,global); REGISTER_GETTER(c,ignoreCase); @@ -114,7 +114,7 @@ { if(argslen == 0) { - return Class<RegExp>::getInstanceS(""); + return Class<RegExp>::getInstanceS(getSys(),""); } else if(args[0]->is<RegExp>()) { @@ -125,7 +125,7 @@ { if (argslen > 1) LOG(LOG_NOT_IMPLEMENTED, "RegExp generator: flags argument not implemented"); - return Class<RegExp>::getInstanceS(args[0]->toString()); + return Class<RegExp>::getInstanceS(args[0]->getSystemState(),args[0]->toString()); } } @@ -149,13 +149,13 @@ { pcre* pcreRE = compile(); if (!pcreRE) - return getSys()->getNullRef(); + return getSystemState()->getNullRef(); int capturingGroups; int infoOk=pcre_fullinfo(pcreRE, NULL, PCRE_INFO_CAPTURECOUNT, &capturingGroups); if(infoOk!=0) { pcre_free(pcreRE); - return getSys()->getNullRef(); + return getSystemState()->getNullRef(); } //Get information about named capturing groups int namedGroups; @@ -163,7 +163,7 @@ if(infoOk!=0) { pcre_free(pcreRE); - return getSys()->getNullRef(); + return getSystemState()->getNullRef(); } //Get information about the size of named entries int namedSize; @@ -171,7 +171,7 @@ if(infoOk!=0) { pcre_free(pcreRE); - return getSys()->getNullRef(); + return getSystemState()->getNullRef(); } struct nameEntry { @@ -184,7 +184,7 @@ { pcre_free(pcreRE); lastIndex=0; - return getSys()->getNullRef(); + return getSystemState()->getNullRef(); } pcre_extra extra; extra.match_limit_recursion=200; @@ -196,24 +196,24 @@ { //No matches or error pcre_free(pcreRE); - return getSys()->getNullRef(); + return getSystemState()->getNullRef(); } - Array* a=Class<Array>::getInstanceS(); + Array* a=Class<Array>::getInstanceS(getSystemState()); //Push the whole result and the captured strings for(int i=0;i<capturingGroups+1;i++) { if(ovector[i*2] >= 0) - a->push(_MR(Class<ASString>::getInstanceS( str.substr_bytes(ovector[i*2],ovector[i*2+1]-ovector[i*2]) ))); + a->push(_MR(abstract_s(getSystemState(), str.substr_bytes(ovector[i*2],ovector[i*2+1]-ovector[i*2]) ))); else - a->push(_MR(getSys()->getUndefinedRef())); + a->push(_MR(getSystemState()->getUndefinedRef())); } - a->setVariableByQName("input","",Class<ASString>::getInstanceS(str),DYNAMIC_TRAIT); + a->setVariableByQName("input","",abstract_s(getSystemState(),str),DYNAMIC_TRAIT); // pcre_exec returns byte position, so we have to convert it to character position tiny_string tmp = str.substr_bytes(0, ovector[0]); int index = tmp.numChars(); - a->setVariableByQName("index","",abstract_i(index),DYNAMIC_TRAIT); + a->setVariableByQName("index","",abstract_i(getSystemState(),index),DYNAMIC_TRAIT); for(int i=0;i<namedGroups;i++) { nameEntry* entry=reinterpret_cast<nameEntry*>(entries); @@ -231,20 +231,20 @@ ASFUNCTIONBODY(RegExp,test) { if (!obj->is<RegExp>()) - return abstract_b(true); + return abstract_b(obj->getSystemState(),true); RegExp* th=static_cast<RegExp*>(obj); const tiny_string& arg0 = args[0]->toString(); pcre* pcreRE = th->compile(); if (!pcreRE) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); int capturingGroups; int infoOk=pcre_fullinfo(pcreRE, NULL, PCRE_INFO_CAPTURECOUNT, &capturingGroups); if(infoOk!=0) { pcre_free(pcreRE); - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); } int ovector[(capturingGroups+1)*3]; @@ -256,15 +256,15 @@ bool ret = (rc >= 0); pcre_free(pcreRE); - return abstract_b(ret); + return abstract_b(obj->getSystemState(),ret); } ASFUNCTIONBODY(RegExp,_toString) { - if(Class<RegExp>::getClass()->prototype->getObj() == obj) - return Class<ASString>::getInstanceS("/(?:)/"); + if(Class<RegExp>::getClass(obj->getSystemState())->prototype->getObj() == obj) + return abstract_s(obj->getSystemState(),"/(?:)/"); if(!obj->is<RegExp>()) - throw Class<TypeError>::getInstanceS("RegExp.toString is not generic"); + throw Class<TypeError>::getInstanceS(obj->getSystemState(),"RegExp.toString is not generic"); RegExp* th=static_cast<RegExp*>(obj); tiny_string ret; @@ -279,7 +279,7 @@ ret += "m"; if(th->dotall) ret += "s"; - return Class<ASString>::getInstanceS(ret); + return abstract_s(obj->getSystemState(),ret); } pcre* RegExp::compile()
View file
lightspark.tar.xz/src/scripting/toplevel/UInteger.cpp
Changed
@@ -101,43 +101,43 @@ ASFUNCTIONBODY(UInteger,generator) { if (argslen == 0) - return abstract_ui(0); - return abstract_ui(args[0]->toUInt()); + return abstract_ui(getSys(),0); + return abstract_ui(args[0]->getSystemState(),args[0]->toUInt()); } ASFUNCTIONBODY(UInteger,_valueOf) { - if(Class<UInteger>::getClass()->prototype->getObj() == obj) - return abstract_ui(0); + if(Class<UInteger>::getClass(obj->getSystemState())->prototype->getObj() == obj) + return abstract_ui(obj->getSystemState(),0); if(!obj->is<UInteger>()) - throw Class<TypeError>::getInstanceS(""); + throw Class<TypeError>::getInstanceS(obj->getSystemState(),""); - return abstract_ui(obj->as<UInteger>()->val); + return abstract_ui(obj->getSystemState(),obj->as<UInteger>()->val); } void UInteger::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); c->isReusable = true; - c->setVariableByQName("MAX_VALUE","",abstract_ui(0xFFFFFFFF),CONSTANT_TRAIT); - c->setVariableByQName("MIN_VALUE","",abstract_ui(0),CONSTANT_TRAIT); - c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toFixed",AS3,Class<IFunction>::getFunction(_toFixed,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toExponential",AS3,Class<IFunction>::getFunction(_toExponential,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toPrecision",AS3,Class<IFunction>::getFunction(_toPrecision,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(_valueOf),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toExponential","",Class<IFunction>::getFunction(_toExponential, 1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toFixed","",Class<IFunction>::getFunction(_toFixed, 1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toPrecision","",Class<IFunction>::getFunction(_toPrecision, 1),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(_valueOf),DYNAMIC_TRAIT); + c->setVariableByQName("MAX_VALUE","",abstract_ui(c->getSystemState(),0xFFFFFFFF),CONSTANT_TRAIT); + c->setVariableByQName("MIN_VALUE","",abstract_ui(c->getSystemState(),0),CONSTANT_TRAIT); + c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toFixed",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toFixed,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toExponential",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toExponential,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toPrecision",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toPrecision,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),_valueOf),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toExponential","",Class<IFunction>::getFunction(c->getSystemState(),_toExponential, 1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toFixed","",Class<IFunction>::getFunction(c->getSystemState(),_toFixed, 1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toPrecision","",Class<IFunction>::getFunction(c->getSystemState(),_toPrecision, 1),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(c->getSystemState(),_valueOf),DYNAMIC_TRAIT); } ASFUNCTIONBODY(UInteger,_toString) { - if(Class<UInteger>::getClass()->prototype->getObj() == obj) - return abstract_s("0"); + if(Class<UInteger>::getClass(obj->getSystemState())->prototype->getObj() == obj) + return abstract_s(obj->getSystemState(),"0"); UInteger* th=static_cast<UInteger*>(obj); uint32_t radix; @@ -147,12 +147,12 @@ { char buf[20]; snprintf(buf,20,"%u",th->val); - return abstract_s(buf); + return abstract_s(obj->getSystemState(),buf); } else { tiny_string s=Number::toStringRadix((number_t)th->val, radix); - return abstract_s(s); + return abstract_s(obj->getSystemState(),s); } } @@ -187,7 +187,7 @@ else fractionDigits = imin(imax((int32_t)ceil(::log10(v)), 1), 20); } - return abstract_s(Number::toExponentialString(v, fractionDigits)); + return abstract_s(obj->getSystemState(),Number::toExponentialString(v, fractionDigits)); } ASFUNCTIONBODY(UInteger,_toFixed) @@ -195,17 +195,17 @@ UInteger *th=obj->as<UInteger>(); int fractiondigits; ARG_UNPACK (fractiondigits, 0); - return abstract_s(Number::toFixedString(th->val, fractiondigits)); + return abstract_s(obj->getSystemState(),Number::toFixedString(th->val, fractiondigits)); } ASFUNCTIONBODY(UInteger,_toPrecision) { UInteger *th=obj->as<UInteger>(); if (argslen == 0 || args[0]->is<Undefined>()) - return abstract_s(th->toString()); + return abstract_s(obj->getSystemState(),th->toString()); int precision; ARG_UNPACK (precision); - return abstract_s(Number::toPrecisionString(th->val, precision)); + return abstract_s(obj->getSystemState(),Number::toPrecisionString(th->val, precision)); } void UInteger::serialize(ByteArray* out, std::map<tiny_string, uint32_t>& stringMap,
View file
lightspark.tar.xz/src/scripting/toplevel/UInteger.h
Changed
@@ -35,15 +35,10 @@ static void sinit(Class_base* c); tiny_string toString(); static tiny_string toString(uint32_t val); - void finalize() { val=0;} - int32_t toInt() - { - return val; - } - uint32_t toUInt() - { - return val; - } + inline number_t toNumber() { return val; } + inline void finalize() { val=0; } + inline int32_t toInt() { return val; } + inline uint32_t toUInt() { return val; } TRISTATE isLess(ASObject* r); bool isEqual(ASObject* o); ASFUNCTION(_constructor);
View file
lightspark.tar.xz/src/scripting/toplevel/Vector.cpp
Changed
@@ -29,69 +29,69 @@ void Vector::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL); - c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(getLength),GETTER_METHOD,true); - c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(setLength),SETTER_METHOD,true); - c->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("fixed","",Class<IFunction>::getFunction(getFixed),GETTER_METHOD,true); - c->setDeclaredMethodByQName("fixed","",Class<IFunction>::getFunction(setFixed),SETTER_METHOD,true); - c->setDeclaredMethodByQName("concat","",Class<IFunction>::getFunction(_concat),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("concat",AS3,Class<IFunction>::getFunction(_concat),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("every","",Class<IFunction>::getFunction(every),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("every",AS3,Class<IFunction>::getFunction(every),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("filter","",Class<IFunction>::getFunction(filter),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("filter",AS3,Class<IFunction>::getFunction(filter),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("forEach","",Class<IFunction>::getFunction(forEach),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("forEach",AS3,Class<IFunction>::getFunction(forEach),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("indexOf","",Class<IFunction>::getFunction(indexOf),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("indexOf",AS3,Class<IFunction>::getFunction(indexOf),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("lastIndexOf","",Class<IFunction>::getFunction(lastIndexOf),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("lastIndexOf",AS3,Class<IFunction>::getFunction(lastIndexOf),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("join","",Class<IFunction>::getFunction(join),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("join",AS3,Class<IFunction>::getFunction(join),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("map","",Class<IFunction>::getFunction(_map),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("map",AS3,Class<IFunction>::getFunction(_map),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("pop","",Class<IFunction>::getFunction(_pop),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("pop",AS3,Class<IFunction>::getFunction(_pop),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("push","",Class<IFunction>::getFunction(push),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("push",AS3,Class<IFunction>::getFunction(push),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("reverse","",Class<IFunction>::getFunction(_reverse),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("reverse",AS3,Class<IFunction>::getFunction(_reverse),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("shift","",Class<IFunction>::getFunction(shift),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("shift",AS3,Class<IFunction>::getFunction(shift),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("slice","",Class<IFunction>::getFunction(slice),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("slice",AS3,Class<IFunction>::getFunction(slice),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("some","",Class<IFunction>::getFunction(some),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("some",AS3,Class<IFunction>::getFunction(some),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("sort","",Class<IFunction>::getFunction(_sort),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("sort",AS3,Class<IFunction>::getFunction(_sort),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("splice","",Class<IFunction>::getFunction(splice),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("splice",AS3,Class<IFunction>::getFunction(splice),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toLocaleString","",Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toLocaleString",AS3,Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("unshift","",Class<IFunction>::getFunction(unshift),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("unshift",AS3,Class<IFunction>::getFunction(unshift),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(c->getSystemState(),getLength),GETTER_METHOD,true); + c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(c->getSystemState(),setLength),SETTER_METHOD,true); + c->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("fixed","",Class<IFunction>::getFunction(c->getSystemState(),getFixed),GETTER_METHOD,true); + c->setDeclaredMethodByQName("fixed","",Class<IFunction>::getFunction(c->getSystemState(),setFixed),SETTER_METHOD,true); + c->setDeclaredMethodByQName("concat","",Class<IFunction>::getFunction(c->getSystemState(),_concat),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("concat",AS3,Class<IFunction>::getFunction(c->getSystemState(),_concat),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("every","",Class<IFunction>::getFunction(c->getSystemState(),every),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("every",AS3,Class<IFunction>::getFunction(c->getSystemState(),every),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("filter","",Class<IFunction>::getFunction(c->getSystemState(),filter),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("filter",AS3,Class<IFunction>::getFunction(c->getSystemState(),filter),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("forEach","",Class<IFunction>::getFunction(c->getSystemState(),forEach),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("forEach",AS3,Class<IFunction>::getFunction(c->getSystemState(),forEach),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("indexOf","",Class<IFunction>::getFunction(c->getSystemState(),indexOf),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("indexOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),indexOf),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("lastIndexOf","",Class<IFunction>::getFunction(c->getSystemState(),lastIndexOf),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("lastIndexOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),lastIndexOf),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("join","",Class<IFunction>::getFunction(c->getSystemState(),join),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("join",AS3,Class<IFunction>::getFunction(c->getSystemState(),join),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("map","",Class<IFunction>::getFunction(c->getSystemState(),_map),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("map",AS3,Class<IFunction>::getFunction(c->getSystemState(),_map),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("pop","",Class<IFunction>::getFunction(c->getSystemState(),_pop),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("pop",AS3,Class<IFunction>::getFunction(c->getSystemState(),_pop),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("push","",Class<IFunction>::getFunction(c->getSystemState(),push),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("push",AS3,Class<IFunction>::getFunction(c->getSystemState(),push),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("reverse","",Class<IFunction>::getFunction(c->getSystemState(),_reverse),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("reverse",AS3,Class<IFunction>::getFunction(c->getSystemState(),_reverse),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("shift","",Class<IFunction>::getFunction(c->getSystemState(),shift),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("shift",AS3,Class<IFunction>::getFunction(c->getSystemState(),shift),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("slice","",Class<IFunction>::getFunction(c->getSystemState(),slice),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("slice",AS3,Class<IFunction>::getFunction(c->getSystemState(),slice),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("some","",Class<IFunction>::getFunction(c->getSystemState(),some),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("some",AS3,Class<IFunction>::getFunction(c->getSystemState(),some),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("sort","",Class<IFunction>::getFunction(c->getSystemState(),_sort),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("sort",AS3,Class<IFunction>::getFunction(c->getSystemState(),_sort),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("splice","",Class<IFunction>::getFunction(c->getSystemState(),splice),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("splice",AS3,Class<IFunction>::getFunction(c->getSystemState(),splice),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toLocaleString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toLocaleString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("unshift","",Class<IFunction>::getFunction(c->getSystemState(),unshift),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("unshift",AS3,Class<IFunction>::getFunction(c->getSystemState(),unshift),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString",AS3,Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("concat",AS3,Class<IFunction>::getFunction(_concat),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("every",AS3,Class<IFunction>::getFunction(every),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("filter",AS3,Class<IFunction>::getFunction(filter),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("forEach",AS3,Class<IFunction>::getFunction(forEach),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("indexOf",AS3,Class<IFunction>::getFunction(indexOf),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("lastIndexOf",AS3,Class<IFunction>::getFunction(lastIndexOf),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("join",AS3,Class<IFunction>::getFunction(join),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("map",AS3,Class<IFunction>::getFunction(_map),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("pop",AS3,Class<IFunction>::getFunction(_pop),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("push",AS3,Class<IFunction>::getFunction(push),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("reverse",AS3,Class<IFunction>::getFunction(_reverse),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("shift",AS3,Class<IFunction>::getFunction(shift),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("slice",AS3,Class<IFunction>::getFunction(slice),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("some",AS3,Class<IFunction>::getFunction(some),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("sort",AS3,Class<IFunction>::getFunction(_sort),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("splice",AS3,Class<IFunction>::getFunction(splice),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("toLocaleString",AS3,Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("unshift",AS3,Class<IFunction>::getFunction(unshift),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("concat",AS3,Class<IFunction>::getFunction(c->getSystemState(),_concat),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("every",AS3,Class<IFunction>::getFunction(c->getSystemState(),every),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("filter",AS3,Class<IFunction>::getFunction(c->getSystemState(),filter),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("forEach",AS3,Class<IFunction>::getFunction(c->getSystemState(),forEach),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("indexOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),indexOf),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("lastIndexOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),lastIndexOf),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("join",AS3,Class<IFunction>::getFunction(c->getSystemState(),join),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("map",AS3,Class<IFunction>::getFunction(c->getSystemState(),_map),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("pop",AS3,Class<IFunction>::getFunction(c->getSystemState(),_pop),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("push",AS3,Class<IFunction>::getFunction(c->getSystemState(),push),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("reverse",AS3,Class<IFunction>::getFunction(c->getSystemState(),_reverse),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("shift",AS3,Class<IFunction>::getFunction(c->getSystemState(),shift),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("slice",AS3,Class<IFunction>::getFunction(c->getSystemState(),slice),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("some",AS3,Class<IFunction>::getFunction(c->getSystemState(),some),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("sort",AS3,Class<IFunction>::getFunction(c->getSystemState(),_sort),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("splice",AS3,Class<IFunction>::getFunction(c->getSystemState(),splice),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("toLocaleString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("unshift",AS3,Class<IFunction>::getFunction(c->getSystemState(),unshift),DYNAMIC_TRAIT); } Vector::Vector(Class_base* c, const Type *vtype):ASObject(c),vec_type(vtype),fixed(false),vec(reporter_allocator<ASObject*>(c->memoryAccount)) @@ -134,7 +134,7 @@ const Type* type = o_class->getTypes()[0]; - if(args[0]->getClass() == Class<Array>::getClass()) + if(args[0]->getClass() == Class<Array>::getClass(args[0]->getSystemState())) { //create object without calling _constructor Vector* ret = o_class->getInstance(false,NULL,0); @@ -149,7 +149,7 @@ } return ret; } - else if(args[0]->getClass()->getTemplate() == Template<Vector>::getTemplate()) + else if(args[0]->getClass()->getTemplate() == Template<Vector>::getTemplate(args[0]->getSystemState())) { Vector* arg = static_cast<Vector*>(args[0]); @@ -252,13 +252,13 @@ continue; params[0] = th->vec[i]; th->vec[i]->incRef(); - params[1] = abstract_i(i); + params[1] = abstract_i(obj->getSystemState(),i); params[2] = th; th->incRef(); if(argslen==1) { - funcRet=f->call(getSys()->getNullRef(), params, 3); + funcRet=f->call(obj->getSystemState()->getNullRef(), params, 3); } else { @@ -295,13 +295,13 @@ continue; params[0] = th->vec[i]; th->vec[i]->incRef(); - params[1] = abstract_i(i); + params[1] = abstract_i(obj->getSystemState(),i); params[2] = th; th->incRef(); if(argslen==1) { - funcRet=f->call(getSys()->getNullRef(), params, 3); + funcRet=f->call(obj->getSystemState()->getNullRef(), params, 3); } else { @@ -317,7 +317,7 @@ funcRet->decRef(); } } - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); } ASFUNCTIONBODY(Vector, every) @@ -339,14 +339,14 @@ th->vec[i]->incRef(); } else - params[0] = getSys()->getNullRef(); - params[1] = abstract_i(i); + params[0] = obj->getSystemState()->getNullRef(); + params[1] = abstract_i(obj->getSystemState(),i); params[2] = th; th->incRef(); if(argslen==1) { - funcRet=f->call(getSys()->getNullRef(), params, 3); + funcRet=f->call(obj->getSystemState()->getNullRef(), params, 3); } else { @@ -364,7 +364,7 @@ funcRet->decRef(); } } - return abstract_b(true); + return abstract_b(obj->getSystemState(),true); } void Vector::append(ASObject *o) @@ -390,7 +390,7 @@ //they are converted to the vec_type th->vec.push_back( th->vec_type->coerce(args[i]) ); } - return abstract_ui(th->vec.size()); + return abstract_ui(obj->getSystemState(),th->vec.size()); } ASFUNCTIONBODY(Vector,_pop) @@ -400,17 +400,17 @@ throwError<RangeError>(kVectorFixedError); uint32_t size =th->size(); if (size == 0) - return th->vec_type->coerce(getSys()->getNullRef()); + return th->vec_type->coerce(obj->getSystemState()->getNullRef()); ASObject* ret = th->vec[size-1]; if (!ret) - ret = th->vec_type->coerce(getSys()->getNullRef()); + ret = th->vec_type->coerce(obj->getSystemState()->getNullRef()); th->vec.pop_back(); return ret; } ASFUNCTIONBODY(Vector,getLength) { - return abstract_ui(obj->as<Vector>()->vec.size()); + return abstract_ui(obj->getSystemState(),obj->as<Vector>()->vec.size()); } ASFUNCTIONBODY(Vector,setLength) @@ -432,7 +432,7 @@ ASFUNCTIONBODY(Vector,getFixed) { - return abstract_b(obj->as<Vector>()->fixed); + return abstract_b(obj->getSystemState(),obj->as<Vector>()->fixed); } ASFUNCTIONBODY(Vector,setFixed) @@ -460,14 +460,14 @@ continue; params[0] = th->vec[i]; th->vec[i]->incRef(); - params[1] = abstract_i(i); + params[1] = abstract_i(obj->getSystemState(),i); params[2] = th; th->incRef(); ASObject *funcret; if( argslen == 1 ) { - funcret=f->call(getSys()->getNullRef(), params, 3); + funcret=f->call(obj->getSystemState()->getNullRef(), params, 3); } else { @@ -508,12 +508,12 @@ ASObject* arg0=args[0]; if(th->vec.size() == 0) - return abstract_d(-1); + return abstract_d(obj->getSystemState(),-1); size_t i = th->size()-1; if(argslen == 2 && std::isnan(args[1]->toNumber())) - return abstract_i(0); + return abstract_i(obj->getSystemState(),0); if(argslen == 2 && args[1]->getObjectType() != T_UNDEFINED && !std::isnan(args[1]->toNumber())) { @@ -545,7 +545,7 @@ } while(i--); - return abstract_i(ret); + return abstract_i(obj->getSystemState(),ret); } ASFUNCTIONBODY(Vector,shift) @@ -554,12 +554,12 @@ if (th->fixed) throwError<RangeError>(kVectorFixedError); if(!th->size()) - return th->vec_type->coerce(getSys()->getNullRef()); + return th->vec_type->coerce(obj->getSystemState()->getNullRef()); ASObject* ret; if(th->vec[0]) ret=th->vec[0]; else - ret=th->vec_type->coerce(getSys()->getNullRef()); + ret=th->vec_type->coerce(obj->getSystemState()->getNullRef()); for(uint32_t i= 1;i< th->size();i++) { if (th->vec[i]) @@ -704,7 +704,7 @@ if(i!=th->size()-1) ret+=del.raw_buf(); } - return Class<ASString>::getInstanceS(ret); + return abstract_s(obj->getSystemState(),ret); } ASFUNCTIONBODY(Vector,indexOf) @@ -730,7 +730,7 @@ break; } } - return abstract_i(ret); + return abstract_i(obj->getSystemState(),ret); } bool Vector::sortComparatorDefault::operator()(ASObject* d1, ASObject* d2) { @@ -780,17 +780,17 @@ objs[0]->incRef(); } else - objs[0] = vec_type->coerce(getSys()->getNullRef()); + objs[0] = vec_type->coerce(comparator->getSystemState()->getNullRef()); if (d2) { objs[1] = d2; objs[1]->incRef(); } else - objs[1] = vec_type->coerce(getSys()->getNullRef()); + objs[1] = vec_type->coerce(comparator->getSystemState()->getNullRef()); assert(comparator); - _NR<ASObject> ret=_MNR(comparator->call(getSys()->getNullRef(), objs, 2)); + _NR<ASObject> ret=_MNR(comparator->call(comparator->getSystemState()->getNullRef(), objs, 2)); assert_and_throw(ret); return (ret->toNumber()<0); //Less } @@ -867,7 +867,7 @@ th->vec[i] = th->vec_type->coerce(args[i]); } } - return abstract_i(th->size()); + return abstract_i(obj->getSystemState(),th->size()); } ASFUNCTIONBODY(Vector,_map) @@ -888,7 +888,7 @@ { ASObject* funcArgs[3]; if (!th->vec[i]) - funcArgs[0]=getSys()->getNullRef(); + funcArgs[0]=obj->getSystemState()->getNullRef(); else { if(th->vec[i]) @@ -897,13 +897,13 @@ funcArgs[0]->incRef(); } else - funcArgs[0]=getSys()->getUndefinedRef(); + funcArgs[0]=obj->getSystemState()->getUndefinedRef(); } - funcArgs[1]=abstract_i(i); + funcArgs[1]=abstract_i(obj->getSystemState(),i); funcArgs[2]=th; funcArgs[2]->incRef(); if (thisObject.isNull()) - thisObj = getSys()->getNullRef(); + thisObj = obj->getSystemState()->getNullRef(); else { thisObj = thisObject.getPtr(); @@ -927,12 +927,12 @@ ret += th->vec[i]->toString(); else // use the type's default value - ret += th->vec_type->coerce( getSys()->getNullRef() )->toString(); + ret += th->vec_type->coerce( obj->getSystemState()->getNullRef() )->toString(); if(i!=th->vec.size()-1) ret += ','; } - return Class<ASString>::getInstanceS(ret); + return abstract_s(obj->getSystemState(),ret); } bool Vector::hasPropertyByMultiname(const multiname& name, bool considerDynamic, bool considerPrototype) { @@ -943,7 +943,7 @@ return ASObject::hasPropertyByMultiname(name, considerDynamic, considerPrototype); unsigned int index=0; - if(!Vector::isValidMultiname(name,index)) + if(!Vector::isValidMultiname(getSystemState(),name,index)) return ASObject::hasPropertyByMultiname(name, considerDynamic, considerPrototype); if(index < vec.size()) @@ -963,7 +963,7 @@ return ASObject::getVariableByMultiname(name,opt); unsigned int index=0; - if(!Vector::isValidMultiname(name,index) || index == UINT32_MAX) + if(!Vector::isValidMultiname(getSystemState(),name,index) || index == UINT32_MAX) { if (name.name_type == multiname::NAME_INT || (name.name_type == multiname::NAME_NUMBER && Number::isInteger(name.name_d))) @@ -971,7 +971,7 @@ _NR<ASObject> ret = ASObject::getVariableByMultiname(name,opt); if (ret.isNull()) - throwError<ReferenceError>(kReadSealedError, name.normalizedName(), this->getClass()->getQualifiedClassName()); + throwError<ReferenceError>(kReadSealedError, name.normalizedName(getSystemState()), this->getClass()->getQualifiedClassName()); return ret; } if(index < vec.size()) @@ -982,7 +982,7 @@ return _MNR(vec[index]); } else - return _MNR(vec_type->coerce( getSys()->getNullRef() )); + return _MNR(vec_type->coerce( getSystemState()->getNullRef() )); } else { @@ -1001,14 +1001,14 @@ return ASObject::setVariableByMultiname(name, o, allowConst); unsigned int index=0; - if(!Vector::isValidMultiname(name,index)) + if(!Vector::isValidMultiname(getSystemState(),name,index)) { if (name.name_type == multiname::NAME_INT || (name.name_type == multiname::NAME_NUMBER && Number::isInteger(name.name_d))) - throwError<RangeError>(kOutOfRangeError,name.normalizedName(),Integer::toString(vec.size())); + throwError<RangeError>(kOutOfRangeError,name.normalizedName(getSystemState()),Integer::toString(vec.size())); if (!ASObject::hasPropertyByMultiname(name,false,true)) - throwError<ReferenceError>(kWriteSealedError, name.normalizedName(), this->getClass()->getQualifiedClassName()); + throwError<ReferenceError>(kWriteSealedError, name.normalizedName(getSystemState()), this->getClass()->getQualifiedClassName()); return ASObject::setVariableByMultiname(name, o, allowConst); } ASObject* o2 = this->vec_type->coerce(o); @@ -1044,7 +1044,7 @@ if (vec[i]) t += vec[i]->toString(); else - t += vec_type->coerce( getSys()->getNullRef() )->toString(); + t += vec_type->coerce( getSystemState()->getNullRef() )->toString(); } return t; } @@ -1060,7 +1060,7 @@ _R<ASObject> Vector::nextName(uint32_t index) { if(index<=vec.size()) - return _MR(abstract_i(index-1)); + return _MR(abstract_i(getSystemState(),index-1)); else throw RunTimeException("Vector::nextName out of bounds"); } @@ -1074,13 +1074,13 @@ vec[index-1]->incRef(); return _MR(vec[index-1]); } - return _MR(vec_type->coerce( getSys()->getNullRef() )); + return _MR(vec_type->coerce( getSystemState()->getNullRef() )); } else throw RunTimeException("Vector::nextValue out of bounds"); } -bool Vector::isValidMultiname(const multiname& name, uint32_t& index) +bool Vector::isValidMultiname(SystemState* sys,const multiname& name, uint32_t& index) { //First of all the multiname has to contain the null namespace //As the namespace vector is sorted, we check only the first one @@ -1088,7 +1088,7 @@ if(!name.ns[0].hasEmptyName()) return false; - bool validIndex=name.toUInt(index, true); + bool validIndex=name.toUInt(sys,index, true); return validIndex; } @@ -1112,16 +1112,16 @@ tiny_string subres; ASObject* o = vec[i]; if (!o) - o = getSys()->getNullRef(); + o = getSystemState()->getNullRef(); if (replacer != NULL) { ASObject* params[2]; - params[0] = Class<Number>::getInstanceS(i); + params[0] = abstract_d(getSystemState(),i); params[0]->incRef(); params[1] = o; params[1]->incRef(); - ASObject *funcret=replacer->call(getSys()->getNullRef(), params, 2); + ASObject *funcret=replacer->call(getSystemState()->getNullRef(), params, 2); if (funcret) subres = funcret->toJSON(path,NULL,spaces,filter); } @@ -1164,11 +1164,11 @@ return; } uint8_t marker = 0; - if (vec_type == Class<Integer>::getClass()) + if (vec_type == Class<Integer>::getClass(getSystemState())) marker = vector_int_marker; - else if (vec_type == Class<UInteger>::getClass()) + else if (vec_type == Class<UInteger>::getClass(getSystemState())) marker = vector_uint_marker; - else if (vec_type == Class<Number>::getClass()) + else if (vec_type == Class<Number>::getClass(getSystemState())) marker = vector_double_marker; else marker = vector_object_marker;
View file
lightspark.tar.xz/src/scripting/toplevel/Vector.h
Changed
@@ -67,7 +67,7 @@ void setVariableByMultiname(const multiname& name, ASObject* o, CONST_ALLOWED_FLAG allowConst); bool hasPropertyByMultiname(const multiname& name, bool considerDynamic, bool considerPrototype); _NR<ASObject> getVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt); - static bool isValidMultiname(const multiname& name, uint32_t& index); + static bool isValidMultiname(SystemState* sys,const multiname& name, uint32_t& index); tiny_string toJSON(std::vector<ASObject *> &path, IFunction *replacer, const tiny_string &spaces,const tiny_string& filter);
View file
lightspark.tar.xz/src/scripting/toplevel/XML.cpp
Changed
@@ -87,73 +87,75 @@ setDefaultXMLSettings(); c->isReusable=true; - c->setDeclaredMethodByQName("ignoreComments","",Class<IFunction>::getFunction(_getIgnoreComments),GETTER_METHOD,false); - c->setDeclaredMethodByQName("ignoreComments","",Class<IFunction>::getFunction(_setIgnoreComments),SETTER_METHOD,false); - c->setDeclaredMethodByQName("ignoreProcessingInstructions","",Class<IFunction>::getFunction(_getIgnoreProcessingInstructions),GETTER_METHOD,false); - c->setDeclaredMethodByQName("ignoreProcessingInstructions","",Class<IFunction>::getFunction(_setIgnoreProcessingInstructions),SETTER_METHOD,false); - c->setDeclaredMethodByQName("ignoreWhitespace","",Class<IFunction>::getFunction(_getIgnoreWhitespace),GETTER_METHOD,false); - c->setDeclaredMethodByQName("ignoreWhitespace","",Class<IFunction>::getFunction(_setIgnoreWhitespace),SETTER_METHOD,false); - c->setDeclaredMethodByQName("prettyIndent","",Class<IFunction>::getFunction(_getPrettyIndent),GETTER_METHOD,false); - c->setDeclaredMethodByQName("prettyIndent","",Class<IFunction>::getFunction(_setPrettyIndent),SETTER_METHOD,false); - c->setDeclaredMethodByQName("prettyPrinting","",Class<IFunction>::getFunction(_getPrettyPrinting),GETTER_METHOD,false); - c->setDeclaredMethodByQName("prettyPrinting","",Class<IFunction>::getFunction(_setPrettyPrinting),SETTER_METHOD,false); - c->setDeclaredMethodByQName("settings","",Class<IFunction>::getFunction(_getSettings),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("setSettings","",Class<IFunction>::getFunction(_setSettings),NORMAL_METHOD,false); - c->setDeclaredMethodByQName("defaultSettings","",Class<IFunction>::getFunction(_getDefaultSettings),NORMAL_METHOD,false); - - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(valueOf),DYNAMIC_TRAIT); - c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(valueOf),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toXMLString",AS3,Class<IFunction>::getFunction(toXMLString),NORMAL_METHOD,true); - c->prototype->setVariableByQName("nodeKind","",Class<IFunction>::getFunction(nodeKind),DYNAMIC_TRAIT); c->setDeclaredMethodByQName("nodeKind",AS3,Class<IFunction>::getFunction(nodeKind),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("child",AS3,Class<IFunction>::getFunction(child),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("children",AS3,Class<IFunction>::getFunction(children),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("childIndex",AS3,Class<IFunction>::getFunction(childIndex),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("contains",AS3,Class<IFunction>::getFunction(contains),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("attribute",AS3,Class<IFunction>::getFunction(attribute),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("attributes",AS3,Class<IFunction>::getFunction(attributes),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("length",AS3,Class<IFunction>::getFunction(length),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("localName",AS3,Class<IFunction>::getFunction(localName),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("name",AS3,Class<IFunction>::getFunction(name),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("namespace",AS3,Class<IFunction>::getFunction(_namespace),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("normalize",AS3,Class<IFunction>::getFunction(_normalize),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("descendants",AS3,Class<IFunction>::getFunction(descendants),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("appendChild",AS3,Class<IFunction>::getFunction(_appendChild),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("parent",AS3,Class<IFunction>::getFunction(parent),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("inScopeNamespaces",AS3,Class<IFunction>::getFunction(inScopeNamespaces),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("addNamespace",AS3,Class<IFunction>::getFunction(addNamespace),NORMAL_METHOD,true); - c->prototype->setVariableByQName("hasSimpleContent",AS3,Class<IFunction>::getFunction(_hasSimpleContent),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("hasComplexContent",AS3,Class<IFunction>::getFunction(_hasComplexContent),DYNAMIC_TRAIT); - c->setDeclaredMethodByQName("text",AS3,Class<IFunction>::getFunction(text),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("elements",AS3,Class<IFunction>::getFunction(elements),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setLocalName",AS3,Class<IFunction>::getFunction(_setLocalName),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setName",AS3,Class<IFunction>::getFunction(_setName),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("setNamespace",AS3,Class<IFunction>::getFunction(_setNamespace),NORMAL_METHOD,true); - c->prototype->setVariableByQName("copy",AS3,Class<IFunction>::getFunction(_copy),DYNAMIC_TRAIT); - c->setDeclaredMethodByQName("setChildren",AS3,Class<IFunction>::getFunction(_setChildren),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toJSON",AS3,Class<IFunction>::getFunction(_toJSON),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("insertChildAfter",AS3,Class<IFunction>::getFunction(insertChildAfter),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("insertChildBefore",AS3,Class<IFunction>::getFunction(insertChildBefore),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("namespaceDeclarations",AS3,Class<IFunction>::getFunction(namespaceDeclarations),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("removeNamespace",AS3,Class<IFunction>::getFunction(removeNamespace),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("comments",AS3,Class<IFunction>::getFunction(comments),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("processingInstructions",AS3,Class<IFunction>::getFunction(processingInstructions),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("propertyIsEnumerable",AS3,Class<IFunction>::getFunction(_propertyIsEnumerable),NORMAL_METHOD,true); - c->prototype->setVariableByQName("hasOwnProperty",AS3,Class<IFunction>::getFunction(_hasOwnProperty),DYNAMIC_TRAIT); - c->setDeclaredMethodByQName("prependChild",AS3,Class<IFunction>::getFunction(_prependChild),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("replace",AS3,Class<IFunction>::getFunction(_replace),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("ignoreComments","",Class<IFunction>::getFunction(c->getSystemState(),_getIgnoreComments),GETTER_METHOD,false); + c->setDeclaredMethodByQName("ignoreComments","",Class<IFunction>::getFunction(c->getSystemState(),_setIgnoreComments),SETTER_METHOD,false); + c->setDeclaredMethodByQName("ignoreProcessingInstructions","",Class<IFunction>::getFunction(c->getSystemState(),_getIgnoreProcessingInstructions),GETTER_METHOD,false); + c->setDeclaredMethodByQName("ignoreProcessingInstructions","",Class<IFunction>::getFunction(c->getSystemState(),_setIgnoreProcessingInstructions),SETTER_METHOD,false); + c->setDeclaredMethodByQName("ignoreWhitespace","",Class<IFunction>::getFunction(c->getSystemState(),_getIgnoreWhitespace),GETTER_METHOD,false); + c->setDeclaredMethodByQName("ignoreWhitespace","",Class<IFunction>::getFunction(c->getSystemState(),_setIgnoreWhitespace),SETTER_METHOD,false); + c->setDeclaredMethodByQName("prettyIndent","",Class<IFunction>::getFunction(c->getSystemState(),_getPrettyIndent),GETTER_METHOD,false); + c->setDeclaredMethodByQName("prettyIndent","",Class<IFunction>::getFunction(c->getSystemState(),_setPrettyIndent),SETTER_METHOD,false); + c->setDeclaredMethodByQName("prettyPrinting","",Class<IFunction>::getFunction(c->getSystemState(),_getPrettyPrinting),GETTER_METHOD,false); + c->setDeclaredMethodByQName("prettyPrinting","",Class<IFunction>::getFunction(c->getSystemState(),_setPrettyPrinting),SETTER_METHOD,false); + c->setDeclaredMethodByQName("settings","",Class<IFunction>::getFunction(c->getSystemState(),_getSettings),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("setSettings","",Class<IFunction>::getFunction(c->getSystemState(),_setSettings),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("defaultSettings","",Class<IFunction>::getFunction(c->getSystemState(),_getDefaultSettings),NORMAL_METHOD,false); + + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(c->getSystemState(),valueOf),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),valueOf),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toXMLString",AS3,Class<IFunction>::getFunction(c->getSystemState(),toXMLString),NORMAL_METHOD,true); + c->prototype->setVariableByQName("nodeKind","",Class<IFunction>::getFunction(c->getSystemState(),nodeKind),DYNAMIC_TRAIT); c->setDeclaredMethodByQName("nodeKind",AS3,Class<IFunction>::getFunction(c->getSystemState(),nodeKind),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("child",AS3,Class<IFunction>::getFunction(c->getSystemState(),child),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("children",AS3,Class<IFunction>::getFunction(c->getSystemState(),children),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("childIndex",AS3,Class<IFunction>::getFunction(c->getSystemState(),childIndex),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("contains",AS3,Class<IFunction>::getFunction(c->getSystemState(),contains),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("attribute",AS3,Class<IFunction>::getFunction(c->getSystemState(),attribute),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("attributes",AS3,Class<IFunction>::getFunction(c->getSystemState(),attributes),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("length",AS3,Class<IFunction>::getFunction(c->getSystemState(),length),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("localName",AS3,Class<IFunction>::getFunction(c->getSystemState(),localName),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("name",AS3,Class<IFunction>::getFunction(c->getSystemState(),name),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("namespace",AS3,Class<IFunction>::getFunction(c->getSystemState(),_namespace),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("normalize",AS3,Class<IFunction>::getFunction(c->getSystemState(),_normalize),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("descendants",AS3,Class<IFunction>::getFunction(c->getSystemState(),descendants),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("appendChild",AS3,Class<IFunction>::getFunction(c->getSystemState(),_appendChild),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("parent",AS3,Class<IFunction>::getFunction(c->getSystemState(),parent),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("inScopeNamespaces",AS3,Class<IFunction>::getFunction(c->getSystemState(),inScopeNamespaces),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("addNamespace",AS3,Class<IFunction>::getFunction(c->getSystemState(),addNamespace),NORMAL_METHOD,true); + c->prototype->setVariableByQName("hasSimpleContent",AS3,Class<IFunction>::getFunction(c->getSystemState(),_hasSimpleContent),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("hasComplexContent",AS3,Class<IFunction>::getFunction(c->getSystemState(),_hasComplexContent),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("text",AS3,Class<IFunction>::getFunction(c->getSystemState(),text),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("elements",AS3,Class<IFunction>::getFunction(c->getSystemState(),elements),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setLocalName",AS3,Class<IFunction>::getFunction(c->getSystemState(),_setLocalName),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setName",AS3,Class<IFunction>::getFunction(c->getSystemState(),_setName),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("setNamespace",AS3,Class<IFunction>::getFunction(c->getSystemState(),_setNamespace),NORMAL_METHOD,true); + c->prototype->setVariableByQName("copy",AS3,Class<IFunction>::getFunction(c->getSystemState(),_copy),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("setChildren",AS3,Class<IFunction>::getFunction(c->getSystemState(),_setChildren),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toJSON",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toJSON),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("insertChildAfter",AS3,Class<IFunction>::getFunction(c->getSystemState(),insertChildAfter),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("insertChildBefore",AS3,Class<IFunction>::getFunction(c->getSystemState(),insertChildBefore),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("namespaceDeclarations",AS3,Class<IFunction>::getFunction(c->getSystemState(),namespaceDeclarations),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("removeNamespace",AS3,Class<IFunction>::getFunction(c->getSystemState(),removeNamespace),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("comments",AS3,Class<IFunction>::getFunction(c->getSystemState(),comments),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("processingInstructions",AS3,Class<IFunction>::getFunction(c->getSystemState(),processingInstructions),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("propertyIsEnumerable",AS3,Class<IFunction>::getFunction(c->getSystemState(),_propertyIsEnumerable),NORMAL_METHOD,true); + c->prototype->setVariableByQName("hasOwnProperty",AS3,Class<IFunction>::getFunction(c->getSystemState(),_hasOwnProperty),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("prependChild",AS3,Class<IFunction>::getFunction(c->getSystemState(),_prependChild),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("replace",AS3,Class<IFunction>::getFunction(c->getSystemState(),_replace),NORMAL_METHOD,true); } ASFUNCTIONBODY(XML,generator) { assert(obj==NULL); assert_and_throw(argslen<=1); - if (argslen == 0 || - args[0]->is<Null>() || - args[0]->is<Undefined>()) + if (argslen == 0) + { + return Class<XML>::getInstanceSNoArgs(getSys()); + } + else if (args[0]->is<Null>() || args[0]->is<Undefined>()) { - return Class<XML>::getInstanceSNoArgs(); + return Class<XML>::getInstanceSNoArgs(args[0]->getSystemState()); } else if(args[0]->is<ASString>() || args[0]->is<Number>() || @@ -161,7 +163,7 @@ args[0]->is<UInteger>() || args[0]->is<Boolean>()) { - return createFromString(args[0]->toString()); + return createFromString(args[0]->getSystemState(),args[0]->toString()); } else if(args[0]->is<XML>()) { @@ -180,7 +182,7 @@ } else { - return createFromString(args[0]->toString()); + return createFromString(args[0]->getSystemState(),args[0]->toString()); } } @@ -197,7 +199,7 @@ { th->createTree(th->buildFromString("", getParseMode()),false); } - else if(args[0]->getClass()->isSubClass(Class<ByteArray>::getClass())) + else if(args[0]->getClass()->isSubClass(Class<ByteArray>::getClass(obj->getSystemState()))) { //Official documentation says that generic Objects are not supported. //ByteArray seems to be though (see XML test) so let's support it @@ -205,7 +207,7 @@ uint32_t len=ba->getLength(); const uint8_t* str=ba->getBuffer(len, false); th->createTree(th->buildFromString(std::string((const char*)str,len), getParseMode(), - getVm()->getDefaultXMLNamespace()),false); + getVm(obj->getSystemState())->getDefaultXMLNamespace()),false); } else if(args[0]->is<ASString>() || args[0]->is<Number>() || @@ -216,12 +218,12 @@ //By specs, XML constructor will only convert to string Numbers or Booleans //ints are not explicitly mentioned, but they seem to work th->createTree(th->buildFromString(args[0]->toString(), getParseMode(), - getVm()->getDefaultXMLNamespace()),false); + getVm(obj->getSystemState())->getDefaultXMLNamespace()),false); } else if(args[0]->is<XML>()) { th->createTree(th->buildFromString(args[0]->as<XML>()->toXMLString_internal(), getParseMode(), - getVm()->getDefaultXMLNamespace()),false); + getVm(obj->getSystemState())->getDefaultXMLNamespace()),false); } else if(args[0]->is<XMLList>()) { @@ -232,7 +234,7 @@ else { th->createTree(th->buildFromString(args[0]->toString(), getParseMode(), - getVm()->getDefaultXMLNamespace()),false); + getVm(obj->getSystemState())->getDefaultXMLNamespace()),false); } return NULL; @@ -242,7 +244,7 @@ { XML* th=Class<XML>::cast(obj); assert_and_throw(argslen==0); - return abstract_s(th->nodekindString()); + return abstract_s(obj->getSystemState(),th->nodekindString()); } const char *XML::nodekindString() { @@ -270,7 +272,7 @@ ASFUNCTIONBODY(XML,length) { - return abstract_i(1); + return abstract_i(obj->getSystemState(),1); } ASFUNCTIONBODY(XML,localName) @@ -278,9 +280,9 @@ XML* th=Class<XML>::cast(obj); assert_and_throw(argslen==0); if(!th->isAttribute && (th->nodetype==pugi::node_pcdata || th->nodetype==pugi::node_comment || th->nodetype==pugi::node_null)) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); else - return abstract_s(th->nodename); + return abstract_s(obj->getSystemState(),th->nodename); } ASFUNCTIONBODY(XML,name) @@ -289,10 +291,10 @@ assert_and_throw(argslen==0); //TODO: add namespace if(!th->isAttribute && (th->nodetype==pugi::node_pcdata || th->nodetype==pugi::node_comment || th->nodetype==pugi::node_null)) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); else { - ASQName* ret = Class<ASQName>::getInstanceS(); + ASQName* ret = Class<ASQName>::getInstanceS(obj->getSystemState()); ret->setByXML(th); return ret; } @@ -302,12 +304,12 @@ { XML* th=Class<XML>::cast(obj); _NR<ASObject> name; - ARG_UNPACK(name,_NR<ASObject>(abstract_s("*"))); + ARG_UNPACK(name,_NR<ASObject>(abstract_s(obj->getSystemState(),"*"))); XMLVector ret; multiname mname(NULL); name->applyProxyProperty(mname); - th->getDescendantsByQName(name->toString(),mname.isQName() ? mname.ns[0].getImpl().name : "",mname.isAttribute,ret); - return Class<XMLList>::getInstanceS(ret,th->getChildrenlist(),multiname(NULL)); + th->getDescendantsByQName(name->toString(),mname.isQName() ? mname.ns[0].getImpl(obj->getSystemState()).name : "",mname.isAttribute,ret); + return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); } ASFUNCTIONBODY(XML,_appendChild) @@ -315,12 +317,12 @@ XML* th=Class<XML>::cast(obj); assert_and_throw(argslen==1); _NR<XML> arg; - if(args[0]->getClass()==Class<XML>::getClass()) + if(args[0]->getClass()==Class<XML>::getClass(obj->getSystemState())) { args[0]->incRef(); arg=_MR(Class<XML>::cast(args[0])); } - else if(args[0]->getClass()==Class<XMLList>::getClass()) + else if(args[0]->getClass()==Class<XMLList>::getClass(obj->getSystemState())) { XMLList* list=Class<XMLList>::cast(args[0]); list->appendNodesTo(th); @@ -332,7 +334,7 @@ //The appendChild specs says that any other type is converted to string //NOTE: this is explicitly different from XML constructor, that will only convert to //string Numbers and Booleans - arg=_MR(createFromString("dummy")); + arg=_MR(createFromString(obj->getSystemState(),"dummy")); //avoid interpretation of the argument, just set it as text node arg->setTextContent(args[0]->toString()); } @@ -379,7 +381,7 @@ } XMLVector tmp; - XMLList* res = Class<XMLList>::getInstanceS(tmp,th->getChildrenlist(),multiname(NULL)); + XMLList* res = Class<XMLList>::getInstanceS(obj->getSystemState(),tmp,th->getChildrenlist(),multiname(NULL)); if (!th->attributelist.isNull()) { for (XMLList::XMLListVector::const_iterator it = th->attributelist->nodes.begin(); it != th->attributelist->nodes.end(); it++) @@ -414,7 +416,7 @@ if (bfirst) { - tiny_string defns = getVm()->getDefaultXMLNamespace(); + tiny_string defns = getVm(getSystemState())->getDefaultXMLNamespace(); XML* tmp = this; bool bfound = false; while(tmp) @@ -596,7 +598,7 @@ res += " xmlns:"; res += defaultnsprefix; res += "=\""; - res += getVm()->getDefaultXMLNamespace(); + res += getVm(getSystemState())->getDefaultXMLNamespace(); res += "\""; } if (!attributelist.isNull()) @@ -688,7 +690,7 @@ XML* th=Class<XML>::cast(obj); assert_and_throw(argslen==0); tiny_string res = th->toXMLString_internal(); - ASString* ret=abstract_s(res); + ASString* ret=abstract_s(obj->getSystemState(),res); return ret; } @@ -725,15 +727,15 @@ XMLVector ret; uint32_t index=0; multiname mname(NULL); - mname.name_s_id=getSys()->getUniqueStringId(arg0); + mname.name_s_id=obj->getSystemState()->getUniqueStringId(arg0); mname.name_type=multiname::NAME_STRING; - mname.ns.emplace_back("",NAMESPACE); + mname.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); mname.isAttribute=false; - if(XML::isValidMultiname(mname, index)) + if(XML::isValidMultiname(obj->getSystemState(),mname, index)) th->childrenImpl(ret, index); else th->childrenImpl(ret, arg0); - XMLList* retObj=Class<XMLList>::getInstanceS(ret,th->getChildrenlist(),mname); + XMLList* retObj=Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),mname); return retObj; } @@ -744,10 +746,10 @@ XMLVector ret; th->childrenImpl(ret, "*"); multiname mname(NULL); - mname.name_s_id=getSys()->getUniqueStringId("*"); + mname.name_s_id=obj->getSystemState()->getUniqueStringId("*"); mname.name_type=multiname::NAME_STRING; - mname.ns.emplace_back("",NAMESPACE); - XMLList* retObj=Class<XMLList>::getInstanceS(ret,th->getChildrenlist(),mname); + mname.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); + XMLList* retObj=Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),mname); return retObj; } @@ -761,22 +763,22 @@ { ASObject* o= parent->childrenlist->nodes[i].getPtr(); if (o == th) - return abstract_i(i); + return abstract_i(obj->getSystemState(),i); } } - return abstract_i(-1); + return abstract_i(obj->getSystemState(),-1); } ASFUNCTIONBODY(XML,_hasSimpleContent) { XML *th=static_cast<XML*>(obj); - return abstract_b(th->hasSimpleContent()); + return abstract_b(obj->getSystemState(),th->hasSimpleContent()); } ASFUNCTIONBODY(XML,_hasComplexContent) { XML *th=static_cast<XML*>(obj); - return abstract_b(th->hasComplexContent()); + return abstract_b(obj->getSystemState(),th->hasComplexContent()); } ASFUNCTIONBODY(XML,valueOf) @@ -807,7 +809,7 @@ ARG_UNPACK; XMLVector ret; th->getText(ret); - return Class<XMLList>::getInstanceS(ret,th->getChildrenlist(),multiname(NULL)); + return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); } ASFUNCTIONBODY(XML,elements) @@ -820,7 +822,7 @@ name=""; th->getElementNodes(name, ret); - return Class<XMLList>::getInstanceS(ret,th->getChildrenlist(),multiname(NULL)); + return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); } void XML::getElementNodes(const tiny_string& name, XMLVector& foundElements) @@ -841,7 +843,7 @@ ASFUNCTIONBODY(XML,inScopeNamespaces) { XML *th = obj->as<XML>(); - Array *namespaces = Class<Array>::getInstanceS(); + Array *namespaces = Class<Array>::getInstanceS(obj->getSystemState()); set<tiny_string> seen_prefix; XML* tmp = th; @@ -896,11 +898,11 @@ _R<Namespace> tmpns = th->namespacedefs[i]; if (tmpns->getPrefix(b) == ns_prefix) { - th->namespacedefs[i] = _R<Namespace>(Class<Namespace>::getInstanceS(ns_uri,ns_prefix)); + th->namespacedefs[i] = _R<Namespace>(Class<Namespace>::getInstanceS(obj->getSystemState(),ns_uri,ns_prefix)); return NULL; } } - th->namespacedefs.push_back(_R<Namespace>(Class<Namespace>::getInstanceS(ns_uri,ns_prefix))); + th->namespacedefs.push_back(_R<Namespace>(Class<Namespace>::getInstanceS(obj->getSystemState(),ns_uri,ns_prefix))); return NULL; } @@ -912,7 +914,7 @@ return parentNode.getPtr(); } else - return getSys()->getUndefinedRef(); + return getSystemState()->getUndefinedRef(); } ASFUNCTIONBODY(XML,parent) @@ -927,9 +929,9 @@ _NR<ASObject> value; ARG_UNPACK(value); if(!value->is<XML>()) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); - return abstract_b(th->isEqual(value.getPtr())); + return abstract_b(obj->getSystemState(),th->isEqual(value.getPtr())); } ASFUNCTIONBODY(XML,_namespace) @@ -943,10 +945,10 @@ nodetype!=pugi::node_element && !th->isAttribute) { - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); } if (prefix.empty()) - return Class<Namespace>::getInstanceS(th->nodenamespace_uri, th->nodenamespace_prefix); + return Class<Namespace>::getInstanceS(obj->getSystemState(),th->nodenamespace_uri, th->nodenamespace_prefix); for (uint32_t i = 0; i < th->namespacedefs.size(); i++) { @@ -954,10 +956,10 @@ _R<Namespace> tmpns = th->namespacedefs[i]; if (tmpns->getPrefix(b) == prefix) { - return Class<Namespace>::getInstanceS(tmpns->getURI(), prefix); + return Class<Namespace>::getInstanceS(obj->getSystemState(),tmpns->getURI(), prefix); } } - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); } ASFUNCTIONBODY(XML,_setLocalName) @@ -986,7 +988,7 @@ void XML::setLocalName(const tiny_string& new_name) { - if(!isXMLName(abstract_s(new_name))) + if(!isXMLName(abstract_s(getSystemState(),new_name))) { throwError<TypeError>(kXMLInvalidName, new_name); } @@ -1081,11 +1083,11 @@ _R<Namespace> tmpns = tmp->namespacedefs[i]; if (tmpns->getPrefix(b) == ns_prefix) { - tmp->namespacedefs[i] = _R<Namespace>(Class<Namespace>::getInstanceS(ns_uri,ns_prefix)); + tmp->namespacedefs[i] = _R<Namespace>(Class<Namespace>::getInstanceS(obj->getSystemState(),ns_uri,ns_prefix)); return NULL; } } - tmp->namespacedefs.push_back(_R<Namespace>(Class<Namespace>::getInstanceS(ns_uri,ns_prefix))); + tmp->namespacedefs.push_back(_R<Namespace>(Class<Namespace>::getInstanceS(obj->getSystemState(),ns_uri,ns_prefix))); } return NULL; @@ -1105,7 +1107,7 @@ XML *XML::copy() { - return createFromString(this->toXMLString_internal(false)); + return createFromString(this->getSystemState(),this->toXMLString_internal(false)); } ASFUNCTIONBODY(XML,_setChildren) @@ -1231,8 +1233,8 @@ { multiname mn(NULL); mn.name_type=multiname::NAME_STRING; - mn.ns.emplace_back("",NAMESPACE); - mn.ns.emplace_back(AS3,NAMESPACE); + mn.ns.emplace_back(getSystemState(),"",NAMESPACE); + mn.ns.emplace_back(getSystemState(),AS3,NAMESPACE); mn.isAttribute = true; return getAttributesByMultiname(mn); } @@ -1242,21 +1244,21 @@ if (attributelist.isNull()) return ret; tiny_string defns = "|"; - defns += getVm()->getDefaultXMLNamespace(); + defns += getVm(getSystemState())->getDefaultXMLNamespace(); defns += "|"; tiny_string normalizedName= ""; - if (!name.isEmpty()) normalizedName= name.normalizedName(); + if (!name.isEmpty()) normalizedName= name.normalizedName(getSystemState()); if (normalizedName.startsWith("@")) normalizedName = normalizedName.substr(1,normalizedName.end()); tiny_string namespace_uri="|"; uint32_t i = 0; while (i < name.ns.size()) { - nsNameAndKindImpl ns=name.ns[i].getImpl(); + nsNameAndKindImpl ns=name.ns[i].getImpl(getSystemState()); if (ns.kind==NAMESPACE && ns.name != AS3) { if (ns.name.empty()) - namespace_uri +=getVm()->getDefaultXMLNamespace(); + namespace_uri +=getVm(getSystemState())->getDefaultXMLNamespace(); else namespace_uri +=ns.name; namespace_uri += "|"; @@ -1306,21 +1308,21 @@ if (nodenamespace_prefix == "" && nodenamespace_uri != "") defns += nodenamespace_uri; else - defns += getVm()->getDefaultXMLNamespace(); + defns += getVm(getSystemState())->getDefaultXMLNamespace(); defns += "|"; tiny_string normalizedName= ""; - normalizedName= name.normalizedName(); + normalizedName= name.normalizedName(getSystemState()); if (normalizedName.startsWith("@")) normalizedName = normalizedName.substr(1,normalizedName.end()); tiny_string namespace_uri="|"; uint32_t i = 0; while (i < name.ns.size()) { - nsNameAndKindImpl ns=name.ns[i].getImpl(); + nsNameAndKindImpl ns=name.ns[i].getImpl(getSystemState()); if (ns.kind==NAMESPACE && ns.name != AS3) { if (ns.name.empty()) - namespace_uri +=getVm()->getDefaultXMLNamespace(); + namespace_uri +=getVm(getSystemState())->getDefaultXMLNamespace(); else namespace_uri +=ns.name; namespace_uri += "|"; @@ -1374,7 +1376,7 @@ //object is a leaf node, delegate to ASString if(res.isNull() && hasSimpleContent()) { - ASString *contentstr=abstract_s(toString_priv()); + ASString *contentstr=abstract_s(getSystemState(),toString_priv()); res=contentstr->getVariableByMultiname(name, opt); contentstr->decRef(); } @@ -1385,7 +1387,7 @@ bool isAttr=name.isAttribute; unsigned int index=0; - tiny_string normalizedName=name.normalizedName(); + tiny_string normalizedName=name.normalizedName(getSystemState()); if(!normalizedName.empty() && normalizedName.charAt(0)=='@') { isAttr=true; @@ -1394,9 +1396,9 @@ { //Lookup attribute const XMLVector& attributes=getAttributesByMultiname(name); - return _MNR(Class<XMLList>::getInstanceS(attributes,attributelist.getPtr(),name)); + return _MNR(Class<XMLList>::getInstanceS(getSystemState(),attributes,attributelist.getPtr(),name)); } - else if(XML::isValidMultiname(name,index)) + else if(XML::isValidMultiname(getSystemState(),name,index)) { // If the multiname is a valid array property, the XML // object is treated as a single-item XMLList. @@ -1406,7 +1408,7 @@ return _MNR(this); } else - return _MNR(getSys()->getUndefinedRef()); + return _MNR(getSystemState()->getUndefinedRef()); } else { @@ -1415,10 +1417,10 @@ XMLVector ret; childrenImpl(ret, "*"); multiname mname(NULL); - mname.name_s_id=getSys()->getUniqueStringId("*"); + mname.name_s_id=getSystemState()->getUniqueStringId("*"); mname.name_type=multiname::NAME_STRING; - mname.ns.emplace_back("",NAMESPACE); - XMLList* retObj=Class<XMLList>::getInstanceS(ret,this->getChildrenlist(),mname); + mname.ns.emplace_back(getSystemState(),"",NAMESPACE); + XMLList* retObj=Class<XMLList>::getInstanceS(getSystemState(),ret,this->getChildrenlist(),mname); return _MNR(retObj); } else @@ -1427,7 +1429,7 @@ if(ret.empty() && (opt & XML_STRICT)!=0) return NullRef; - _R<XMLList> ch =_MNR(Class<XMLList>::getInstanceS(ret,this->getChildrenlist(),name)); + _R<XMLList> ch =_MNR(Class<XMLList>::getInstanceS(getSystemState(),ret,this->getChildrenlist(),name)); return ch; } } @@ -1438,14 +1440,14 @@ unsigned int index=0; bool isAttr=name.isAttribute; //Normalize the name to the string form - const tiny_string normalizedName=name.normalizedName(); + const tiny_string normalizedName=name.normalizedName(getSystemState()); //Only the first namespace is used, is this right? tiny_string ns_uri; tiny_string ns_prefix; if(name.ns.size() > 0 && !name.ns[0].hasEmptyName()) { - nsNameAndKindImpl ns=name.ns[0].getImpl(); + nsNameAndKindImpl ns=name.ns[0].getImpl(getSystemState()); if (ns.kind==NAMESPACE) { ns_uri=ns.name; @@ -1456,7 +1458,7 @@ // namespace set by "default xml namespace = ..." if (ns_uri.empty() && ns_prefix.empty()) { - ns_uri = getVm()->getDefaultXMLNamespace(); + ns_uri = getVm(getSystemState())->getDefaultXMLNamespace(); } const char *buf=normalizedName.raw_buf(); @@ -1466,7 +1468,7 @@ buf+=1; } if (childrenlist.isNull()) - childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs()); + childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs(getSystemState())); if(isAttr) { @@ -1502,7 +1504,7 @@ } if (a.isNull() && !((*buf=='*')|| (*buf==0))) { - _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs()); + _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs(getSystemState())); this->incRef(); tmp->parentNode = _MR<XML>(this); tmp->nodetype = pugi::node_null; @@ -1515,7 +1517,7 @@ attributelist->nodes.push_back(tmp); } } - else if(XML::isValidMultiname(name,index)) + else if(XML::isValidMultiname(getSystemState(),name,index)) { childrenlist->setVariableByMultiname(name,o,allowConst); } @@ -1532,7 +1534,7 @@ { if (!found) { - _NR<XMLList> x = _NR<XMLList>(Class<XMLList>::getInstanceS(o->as<XMLList>()->toXMLString_internal(false))); + _NR<XMLList> x = _NR<XMLList>(Class<XMLList>::getInstanceS(getSystemState(),o->as<XMLList>()->toXMLString_internal(false))); tmpnodes.insert(tmpnodes.end(), x->nodes.rbegin(),x->nodes.rend()); } } @@ -1540,7 +1542,7 @@ { if (o->as<XML>()->getNodeKind() == pugi::node_pcdata) { - _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs()); + _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs(getSystemState())); tmp->parentNode = tmpnode; tmp->incRef(); tmp->nodetype = pugi::node_pcdata; @@ -1567,13 +1569,13 @@ else { if (tmpnode->childrenlist.isNull()) - tmpnode->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs()); + tmpnode->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs(getSystemState())); if (tmpnode->childrenlist->nodes.size() == 1 && tmpnode->childrenlist->nodes[0]->nodetype == pugi::node_pcdata) tmpnode->childrenlist->nodes[0]->nodevalue = o->toString(); else { - XML* newnode = createFromString(o->toString()); + XML* newnode = createFromString(this->getSystemState(),o->toString()); tmpnode->childrenlist->clear(); tmpnode->setVariableByMultiname(name,newnode,allowConst); } @@ -1628,7 +1630,7 @@ } tmpstr += normalizedName; tmpstr +=">"; - _NR<XML> tmp = _MR<XML>(createFromString(tmpstr)); + _NR<XML> tmp = _MR<XML>(createFromString(this->getSystemState(),tmpstr)); this->incRef(); tmp->parentNode = _MR<XML>(this); tmpnodes.push_back(tmp); @@ -1650,7 +1652,7 @@ tiny_string ns_prefix; if(name.ns.size() > 0 && !name.ns[0].hasEmptyName()) { - nsNameAndKindImpl ns=name.ns[0].getImpl(); + nsNameAndKindImpl ns=name.ns[0].getImpl(getSystemState()); assert_and_throw(ns.kind==NAMESPACE); ns_uri=ns.name; ns_prefix=getNamespacePrefixByURI(ns_uri); @@ -1659,12 +1661,12 @@ // namespace set by "default xml namespace = ..." if (ns_uri.empty() && ns_prefix.empty()) { - ns_uri = getVm()->getDefaultXMLNamespace(); + ns_uri = getVm(getSystemState())->getDefaultXMLNamespace(); } bool isAttr=name.isAttribute; unsigned int index=0; - const tiny_string normalizedName=name.normalizedName(); + const tiny_string normalizedName=name.normalizedName(getSystemState()); const char *buf=normalizedName.raw_buf(); if(!normalizedName.empty() && normalizedName.charAt(0)=='@') { @@ -1684,7 +1686,7 @@ } } } - else if(XML::isValidMultiname(name,index)) + else if(XML::isValidMultiname(getSystemState(),name,index)) { // If the multiname is a valid array property, the XML // object is treated as a single-item XMLList. @@ -1717,14 +1719,14 @@ tiny_string ns_prefix; if(name.ns.size() > 0 && !name.ns[0].hasEmptyName()) { - nsNameAndKindImpl ns=name.ns[0].getImpl(); + nsNameAndKindImpl ns=name.ns[0].getImpl(getSystemState()); assert_and_throw(ns.kind==NAMESPACE); ns_uri=ns.name; ns_prefix=getNamespacePrefixByURI(ns_uri); } if (ns_uri.empty() && ns_prefix.empty()) { - ns_uri = getVm()->getDefaultXMLNamespace(); + ns_uri = getVm(getSystemState())->getDefaultXMLNamespace(); } if (!attributelist.isNull() && attributelist->nodes.size() > 0) { @@ -1733,17 +1735,17 @@ { it--; _R<XML> attr = *it; - if ((ns_uri=="" && name.normalizedName() == "") || - (ns_uri=="" && name.normalizedName() == attr->nodename) || - (attr->nodenamespace_uri == ns_uri && name.normalizedName() == "") || - (attr->nodenamespace_uri == ns_uri && attr->nodename == name.normalizedName())) + if ((ns_uri=="" && name.normalizedName(getSystemState()) == "") || + (ns_uri=="" && name.normalizedName(getSystemState()) == attr->nodename) || + (attr->nodenamespace_uri == ns_uri && name.normalizedName(getSystemState()) == "") || + (attr->nodenamespace_uri == ns_uri && attr->nodename == name.normalizedName(getSystemState()))) { attributelist->nodes.erase(it); } } } } - else if(XML::isValidMultiname(name,index)) + else if(XML::isValidMultiname(getSystemState(),name,index)) { if (!childrenlist.isNull()) childrenlist->nodes.erase(childrenlist->nodes.begin() + index); @@ -1754,7 +1756,7 @@ tiny_string ns_uri; if(name.ns.size() > 0 && !name.ns[0].hasEmptyName()) { - nsNameAndKindImpl ns=name.ns[0].getImpl(); + nsNameAndKindImpl ns=name.ns[0].getImpl(getSystemState()); assert_and_throw(ns.kind==NAMESPACE); ns_uri=ns.name; } @@ -1765,10 +1767,10 @@ { it--; _R<XML> node = *it; - if ((ns_uri=="" && name.normalizedName() == "") || - (ns_uri=="" && name.normalizedName() == node->nodename) || - (node->nodenamespace_uri == ns_uri && name.normalizedName() == "") || - (node->nodenamespace_uri == ns_uri && node->nodename == name.normalizedName())) + if ((ns_uri=="" && name.normalizedName(getSystemState()) == "") || + (ns_uri=="" && name.normalizedName(getSystemState()) == node->nodename) || + (node->nodenamespace_uri == ns_uri && name.normalizedName(getSystemState()) == "") || + (node->nodenamespace_uri == ns_uri && node->nodename == name.normalizedName(getSystemState()))) { childrenlist->nodes.erase(it); } @@ -1777,7 +1779,7 @@ } return true; } -bool XML::isValidMultiname(const multiname& name, uint32_t& index) +bool XML::isValidMultiname(SystemState* sys,const multiname& name, uint32_t& index) { //First of all the multiname has to contain the null namespace //As the namespace vector is sorted, we check only the first one @@ -1786,11 +1788,11 @@ if (name.isEmpty()) return false; - bool validIndex=name.toUInt(index, true); + bool validIndex=name.toUInt(sys,index, true); // Don't throw for non-numeric NAME_STRING or NAME_OBJECT // because they can still be valid built-in property names. if(!validIndex && (name.name_type==multiname::NAME_INT || name.name_type==multiname::NAME_NUMBER)) - throwError<RangeError>(kOutOfRangeError, name.normalizedNameUnresolved(), "?"); + throwError<RangeError>(kOutOfRangeError, name.normalizedNameUnresolved(sys), "?"); return validIndex; } @@ -1826,12 +1828,12 @@ ASFUNCTIONBODY(XML,_toString) { XML* th=Class<XML>::cast(obj); - return abstract_s(th->toString_priv()); + return abstract_s(obj->getSystemState(),th->toString_priv()); } ASFUNCTIONBODY(XML,_getIgnoreComments) { - return abstract_b(ignoreComments); + return abstract_b(getSys(),ignoreComments); } ASFUNCTIONBODY(XML,_setIgnoreComments) { @@ -1841,7 +1843,7 @@ } ASFUNCTIONBODY(XML,_getIgnoreProcessingInstructions) { - return abstract_b(ignoreProcessingInstructions); + return abstract_b(getSys(),ignoreProcessingInstructions); } ASFUNCTIONBODY(XML,_setIgnoreProcessingInstructions) { @@ -1851,7 +1853,7 @@ } ASFUNCTIONBODY(XML,_getIgnoreWhitespace) { - return abstract_b(ignoreWhitespace); + return abstract_b(getSys(),ignoreWhitespace); } ASFUNCTIONBODY(XML,_setIgnoreWhitespace) { @@ -1861,7 +1863,7 @@ } ASFUNCTIONBODY(XML,_getPrettyIndent) { - return abstract_i(prettyIndent); + return abstract_i(obj->getSystemState(),prettyIndent); } ASFUNCTIONBODY(XML,_setPrettyIndent) { @@ -1871,7 +1873,7 @@ } ASFUNCTIONBODY(XML,_getPrettyPrinting) { - return abstract_b(prettyPrinting); + return abstract_b(getSys(),prettyPrinting); } ASFUNCTIONBODY(XML,_setPrettyPrinting) { @@ -1881,23 +1883,23 @@ } ASFUNCTIONBODY(XML,_getSettings) { - ASObject* res = Class<ASObject>::getInstanceS(); + ASObject* res = Class<ASObject>::getInstanceS(getSys()); multiname mn(NULL); mn.name_type=multiname::NAME_STRING; - mn.ns.emplace_back("",NAMESPACE); - mn.ns.emplace_back(AS3,NAMESPACE); + mn.ns.emplace_back(res->getSystemState(),"",NAMESPACE); + mn.ns.emplace_back(res->getSystemState(),AS3,NAMESPACE); mn.isAttribute = true; - mn.name_s_id=getSys()->getUniqueStringId("ignoreComments"); - res->setVariableByMultiname(mn,abstract_b(ignoreComments),CONST_NOT_ALLOWED); - mn.name_s_id=getSys()->getUniqueStringId("ignoreProcessingInstructions"); - res->setVariableByMultiname(mn,abstract_b(ignoreProcessingInstructions),CONST_NOT_ALLOWED); - mn.name_s_id=getSys()->getUniqueStringId("ignoreWhitespace"); - res->setVariableByMultiname(mn,abstract_b(ignoreWhitespace),CONST_NOT_ALLOWED); - mn.name_s_id=getSys()->getUniqueStringId("prettyIndent"); - res->setVariableByMultiname(mn,abstract_i(prettyIndent),CONST_NOT_ALLOWED); - mn.name_s_id=getSys()->getUniqueStringId("prettyPrinting"); - res->setVariableByMultiname(mn,abstract_b(prettyPrinting),CONST_NOT_ALLOWED); + mn.name_s_id=res->getSystemState()->getUniqueStringId("ignoreComments"); + res->setVariableByMultiname(mn,abstract_b(res->getSystemState(),ignoreComments),CONST_NOT_ALLOWED); + mn.name_s_id=res->getSystemState()->getUniqueStringId("ignoreProcessingInstructions"); + res->setVariableByMultiname(mn,abstract_b(res->getSystemState(),ignoreProcessingInstructions),CONST_NOT_ALLOWED); + mn.name_s_id=res->getSystemState()->getUniqueStringId("ignoreWhitespace"); + res->setVariableByMultiname(mn,abstract_b(res->getSystemState(),ignoreWhitespace),CONST_NOT_ALLOWED); + mn.name_s_id=res->getSystemState()->getUniqueStringId("prettyIndent"); + res->setVariableByMultiname(mn,abstract_i(res->getSystemState(),prettyIndent),CONST_NOT_ALLOWED); + mn.name_s_id=res->getSystemState()->getUniqueStringId("prettyPrinting"); + res->setVariableByMultiname(mn,abstract_b(res->getSystemState(),prettyPrinting),CONST_NOT_ALLOWED); return res; } ASFUNCTIONBODY(XML,_setSettings) @@ -1912,12 +1914,12 @@ if (arg0->is<Null>() || arg0->is<Undefined>()) { setDefaultXMLSettings(); - return getSys()->getNullRef(); + return arg0->getSystemState()->getNullRef(); } multiname mn(NULL); mn.name_type=multiname::NAME_STRING; - mn.ns.emplace_back("",NAMESPACE); - mn.ns.emplace_back(AS3,NAMESPACE); + mn.ns.emplace_back(arg0->getSystemState(),"",NAMESPACE); + mn.ns.emplace_back(arg0->getSystemState(),AS3,NAMESPACE); mn.isAttribute = true; _NR<ASObject> o; @@ -1959,28 +1961,28 @@ } ASFUNCTIONBODY(XML,_getDefaultSettings) { - ASObject* res = Class<ASObject>::getInstanceS(); + ASObject* res = Class<ASObject>::getInstanceS(getSys()); multiname mn(NULL); mn.name_type=multiname::NAME_STRING; - mn.ns.emplace_back("",NAMESPACE); - mn.ns.emplace_back(AS3,NAMESPACE); + mn.ns.emplace_back(res->getSystemState(),"",NAMESPACE); + mn.ns.emplace_back(res->getSystemState(),AS3,NAMESPACE); mn.isAttribute = true; - mn.name_s_id=getSys()->getUniqueStringId("ignoreComments"); - res->setVariableByMultiname(mn,abstract_b(true),CONST_NOT_ALLOWED); - mn.name_s_id=getSys()->getUniqueStringId("ignoreProcessingInstructions"); - res->setVariableByMultiname(mn,abstract_b(true),CONST_NOT_ALLOWED); - mn.name_s_id=getSys()->getUniqueStringId("ignoreWhitespace"); - res->setVariableByMultiname(mn,abstract_b(true),CONST_NOT_ALLOWED); - mn.name_s_id=getSys()->getUniqueStringId("prettyIndent"); - res->setVariableByMultiname(mn,abstract_i(2),CONST_NOT_ALLOWED); - mn.name_s_id=getSys()->getUniqueStringId("prettyPrinting"); - res->setVariableByMultiname(mn,abstract_b(true),CONST_NOT_ALLOWED); + mn.name_s_id=res->getSystemState()->getUniqueStringId("ignoreComments"); + res->setVariableByMultiname(mn,abstract_b(res->getSystemState(),true),CONST_NOT_ALLOWED); + mn.name_s_id=res->getSystemState()->getUniqueStringId("ignoreProcessingInstructions"); + res->setVariableByMultiname(mn,abstract_b(res->getSystemState(),true),CONST_NOT_ALLOWED); + mn.name_s_id=res->getSystemState()->getUniqueStringId("ignoreWhitespace"); + res->setVariableByMultiname(mn,abstract_b(res->getSystemState(),true),CONST_NOT_ALLOWED); + mn.name_s_id=res->getSystemState()->getUniqueStringId("prettyIndent"); + res->setVariableByMultiname(mn,abstract_i(res->getSystemState(),2),CONST_NOT_ALLOWED); + mn.name_s_id=res->getSystemState()->getUniqueStringId("prettyPrinting"); + res->setVariableByMultiname(mn,abstract_b(res->getSystemState(),true),CONST_NOT_ALLOWED); return res; } ASFUNCTIONBODY(XML,_toJSON) { - return abstract_s("XML"); + return abstract_s(obj->getSystemState(),"XML"); } void XML::CheckCyclicReference(XML* node) @@ -1999,16 +2001,16 @@ } } -XML *XML::createFromString(const tiny_string &s) +XML *XML::createFromString(SystemState* sys, const tiny_string &s) { - XML* res = Class<XML>::getInstanceSNoArgs(); + XML* res = Class<XML>::getInstanceSNoArgs(sys); res->createTree(res->buildFromString(s, getParseMode()),false); return res; } XML *XML::createFromNode(const pugi::xml_node &_n, XML *parent, bool fromXMLList) { - XML* res = Class<XML>::getInstanceSNoArgs(); + XML* res = Class<XML>::getInstanceSNoArgs(parent ? parent->getSystemState() : getSys()); if (parent) { parent->incRef(); @@ -2025,7 +2027,7 @@ _NR<ASObject> child2; ARG_UNPACK(child1)(child2); if (th->nodetype != pugi::node_element) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); if (child2->is<XML>()) th->CheckCyclicReference(child2->as<XML>()); @@ -2037,9 +2039,9 @@ } } else - child2 = _NR<XML>(createFromString(child2->toString())); + child2 = _NR<XML>(createFromString(obj->getSystemState(),child2->toString())); if (th->childrenlist.isNull()) - th->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs()); + th->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs(obj->getSystemState())); if (child1->is<Null>()) { th->incRef(); @@ -2066,7 +2068,7 @@ if (child1->is<XMLList>()) { if (child1->as<XMLList>()->nodes.size()==0) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); child1 = child1->as<XMLList>()->nodes[0]; } for (auto it = th->childrenlist->nodes.begin(); it != th->childrenlist->nodes.end(); it++) @@ -2094,7 +2096,7 @@ return th; } } - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); } ASFUNCTIONBODY(XML,insertChildBefore) { @@ -2103,7 +2105,7 @@ _NR<ASObject> child2; ARG_UNPACK(child1)(child2); if (th->nodetype != pugi::node_element) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); if (child2->is<XML>()) th->CheckCyclicReference(child2->as<XML>()); @@ -2115,10 +2117,10 @@ } } else - child2 = _NR<XML>(createFromString(child2->toString())); + child2 = _NR<XML>(createFromString(obj->getSystemState(),child2->toString())); if (th->childrenlist.isNull()) - th->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs()); + th->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs(obj->getSystemState())); if (child1->is<Null>()) { if (child2->is<XML>()) @@ -2141,7 +2143,7 @@ if (child1->is<XMLList>()) { if (child1->as<XMLList>()->nodes.size()==0) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); child1 = child1->as<XMLList>()->nodes[0]; } for (auto it = th->childrenlist->nodes.begin(); it != th->childrenlist->nodes.end(); it++) @@ -2169,13 +2171,13 @@ return th; } } - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); } ASFUNCTIONBODY(XML,namespaceDeclarations) { XML *th = obj->as<XML>(); - Array *namespaces = Class<Array>::getInstanceS(); + Array *namespaces = Class<Array>::getInstanceS(obj->getSystemState()); for (uint32_t i = 0; i < th->namespacedefs.size(); i++) { _R<Namespace> tmpns = th->namespacedefs[i]; @@ -2198,7 +2200,7 @@ if (arg1->is<Namespace>()) ns = arg1->as<Namespace>(); else - ns = Class<Namespace>::getInstanceS(arg1->toString(), ""); + ns = Class<Namespace>::getInstanceS(obj->getSystemState(),arg1->toString(), ""); th->RemoveNamespace(ns); th->incRef(); @@ -2236,7 +2238,7 @@ ARG_UNPACK(name,"*"); XMLVector ret; th->getComments(ret); - return Class<XMLList>::getInstanceS(ret,th->getChildrenlist(),multiname(NULL)); + return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); } void XML::getComments(XMLVector& ret) { @@ -2260,7 +2262,7 @@ ARG_UNPACK(name,"*"); XMLVector ret; th->getprocessingInstructions(ret,name); - return Class<XMLList>::getInstanceS(ret,th->getChildrenlist(),multiname(NULL)); + return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); } void XML::getprocessingInstructions(XMLVector& ret, tiny_string name) { @@ -2278,7 +2280,7 @@ } ASFUNCTIONBODY(XML,_propertyIsEnumerable) { - return abstract_b(argslen == 1 && args[0]->toString() == "0" ); + return abstract_b(obj->getSystemState(),argslen == 1 && args[0]->toString() == "0" ); } ASFUNCTIONBODY(XML,_hasOwnProperty) { @@ -2292,13 +2294,13 @@ { multiname name(NULL); name.name_type=multiname::NAME_STRING; - name.name_s_id=getSys()->getUniqueStringId(args[0]->toString()); - name.ns.emplace_back("",NAMESPACE); - name.ns.emplace_back(AS3,NAMESPACE); + name.name_s_id=obj->getSystemState()->getUniqueStringId(args[0]->toString()); + name.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); + name.ns.emplace_back(obj->getSystemState(),AS3,NAMESPACE); name.isAttribute=false; ret=obj->hasPropertyByMultiname(name, true, true); } - return abstract_b(ret); + return abstract_b(obj->getSystemState(),ret); } tiny_string XML::toString_priv() @@ -2448,7 +2450,7 @@ _R<ASObject> XML::nextName(uint32_t index) { if(index<=1) - return _MR(abstract_i(index-1)); + return _MR(abstract_i(getSystemState(),index-1)); else throw RunTimeException("XML::nextName out of bounds"); } @@ -2500,7 +2502,7 @@ { pugi::xml_node node = rootnode; bool done = false; - this->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs()); + this->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs(getSystemState())); this->childrenlist->incRef(); if (parentNode.isNull() && !fromXMLList) { @@ -2519,10 +2521,10 @@ case pugi::node_pi: // Processing instruction, i.e. '<?name?>' case pugi::node_declaration: // Document declaration, i.e. '<?xml version="1.0"?>' { - _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs()); + _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs(getSystemState())); fillNode(tmp.getPtr(),node); if(this->procinstlist.isNull()) - this->procinstlist = _MR(Class<XMLList>::getInstanceSNoArgs()); + this->procinstlist = _MR(Class<XMLList>::getInstanceSNoArgs(getSystemState())); this->procinstlist->incRef(); this->procinstlist->append(_R<XML>(tmp)); break; @@ -2600,7 +2602,7 @@ { if (node->childrenlist.isNull()) { - node->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs()); + node->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs(node->getSystemState())); node->childrenlist->incRef(); } node->nodetype = srcnode.type(); @@ -2609,10 +2611,10 @@ if (!node->parentNode.isNull() && node->parentNode->nodenamespace_prefix == "") node->nodenamespace_uri = node->parentNode->nodenamespace_uri; else - node->nodenamespace_uri = getVm()->getDefaultXMLNamespace(); + node->nodenamespace_uri = getVm(node->getSystemState())->getDefaultXMLNamespace(); if (ignoreWhitespace && node->nodetype == pugi::node_pcdata) node->nodevalue = node->removeWhitespace(node->nodevalue); - node->attributelist = _MR(Class<XMLList>::getInstanceSNoArgs()); + node->attributelist = _MR(Class<XMLList>::getInstanceSNoArgs(node->getSystemState())); pugi::xml_attribute_iterator itattr; for(itattr = srcnode.attributes_begin();itattr!=srcnode.attributes_end();++itattr) { @@ -2620,7 +2622,7 @@ if(aname == "xmlns") { tiny_string uri = itattr->value(); - Namespace* ns = Class<Namespace>::getInstanceS(uri,""); + Namespace* ns = Class<Namespace>::getInstanceS(node->getSystemState(),uri,""); node->namespacedefs.push_back(_MR(ns)); node->nodenamespace_uri = uri; } @@ -2628,7 +2630,7 @@ { tiny_string uri = itattr->value(); tiny_string prefix = aname.substr(6,aname.end()); - Namespace* ns = Class<Namespace>::getInstanceS(uri,prefix); + Namespace* ns = Class<Namespace>::getInstanceS(node->getSystemState(),uri,prefix); node->namespacedefs.push_back(_MR(ns)); } } @@ -2669,13 +2671,13 @@ tiny_string aname = tiny_string(itattr->name(),true); if(aname == "xmlns" || aname.substr_bytes(0,6) == "xmlns:") continue; - _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs()); + _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs(node->getSystemState())); node->incRef(); tmp->parentNode = _MR<XML>(node); tmp->nodetype = pugi::node_null; tmp->isAttribute = true; tmp->nodename = aname; - tmp->nodenamespace_uri = getVm()->getDefaultXMLNamespace(); + tmp->nodenamespace_uri = getVm(node->getSystemState())->getDefaultXMLNamespace(); pos = tmp->nodename.find(":"); if (pos != tiny_string::npos) { @@ -2719,12 +2721,12 @@ XML* th=Class<XML>::cast(obj); assert_and_throw(argslen==1); _NR<XML> arg; - if(args[0]->getClass()==Class<XML>::getClass()) + if(args[0]->getClass()==Class<XML>::getClass(obj->getSystemState())) { args[0]->incRef(); arg=_MR(Class<XML>::cast(args[0])); } - else if(args[0]->getClass()==Class<XMLList>::getClass()) + else if(args[0]->getClass()==Class<XMLList>::getClass(obj->getSystemState())) { XMLList* list=Class<XMLList>::cast(args[0]); list->prependNodesTo(th); @@ -2736,7 +2738,7 @@ //The appendChild specs says that any other type is converted to string //NOTE: this is explicitly different from XML constructor, that will only convert to //string Numbers and Booleans - arg=_MR(createFromString("dummy")); + arg=_MR(createFromString(obj->getSystemState(),"dummy")); //avoid interpretation of the argument, just set it as text node arg->setTextContent(args[0]->toString()); } @@ -2777,8 +2779,8 @@ name.name_type=multiname::NAME_STRING; if (propertyName->is<ASQName>()) { - name.name_s_id=getSys()->getUniqueStringId(propertyName->as<ASQName>()->getLocalName()); - name.ns.emplace_back(propertyName->as<ASQName>()->getURI(),NAMESPACE); + name.name_s_id=obj->getSystemState()->getUniqueStringId(propertyName->as<ASQName>()->getLocalName()); + name.ns.emplace_back(obj->getSystemState(),propertyName->as<ASQName>()->getURI(),NAMESPACE); } else if (propertyName->toString() == "*") { @@ -2796,7 +2798,7 @@ } else { - XML* x = createFromString(value->toString()); + XML* x = createFromString(obj->getSystemState(),value->toString()); x->incRef(); th->childrenlist->clear(); th->childrenlist->append(_R<XML>(x)); @@ -2806,11 +2808,11 @@ } else { - name.name_s_id=getSys()->getUniqueStringId(propertyName->toString()); - name.ns.emplace_back("",NAMESPACE); + name.name_s_id=obj->getSystemState()->getUniqueStringId(propertyName->toString()); + name.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); } uint32_t index=0; - if(XML::isValidMultiname(name,index)) + if(XML::isValidMultiname(obj->getSystemState(),name,index)) { th->childrenlist->setVariableByMultiname(name,value.getPtr(),CONST_NOT_ALLOWED); } @@ -2828,7 +2830,7 @@ } else { - XML* x = createFromString(value->toString()); + XML* x = createFromString(obj->getSystemState(),value->toString()); th->deleteVariableByMultiname(name); th->setVariableByMultiname(name,x,CONST_NOT_ALLOWED); }
View file
lightspark.tar.xz/src/scripting/toplevel/XML.h
Changed
@@ -143,7 +143,7 @@ static bool getPrettyPrinting(); static unsigned int getParseMode(); - static XML* createFromString(const tiny_string& s); + static XML* createFromString(SystemState *sys, const tiny_string& s); static XML* createFromNode(const pugi::xml_node& _n, XML* parent=NULL, bool fromXMLList=false); const tiny_string getName() const { return nodename;} @@ -157,7 +157,7 @@ bool hasPropertyByMultiname(const multiname& name, bool considerDynamic, bool considerPrototype); void setVariableByMultiname(const multiname& name, ASObject* o, CONST_ALLOWED_FLAG allowConst); bool deleteVariableByMultiname(const multiname& name); - static bool isValidMultiname(const multiname& name, uint32_t& index); + static bool isValidMultiname(SystemState *sys, const multiname& name, uint32_t& index); void setTextContent(const tiny_string& content); tiny_string toString();
View file
lightspark.tar.xz/src/scripting/toplevel/XMLList.cpp
Changed
@@ -30,17 +30,17 @@ * object, if no method with the same name has been defined for * XMLList. */ #define REGISTER_XML_DELEGATE(name) \ - c->setDeclaredMethodByQName(#name,AS3,Class<IFunction>::getFunction(name),NORMAL_METHOD,true) + c->setDeclaredMethodByQName(#name,AS3,Class<IFunction>::getFunction(c->getSystemState(),name),NORMAL_METHOD,true) #define REGISTER_XML_DELEGATE2(asname,cppname) \ - c->setDeclaredMethodByQName(#asname,AS3,Class<IFunction>::getFunction(cppname),NORMAL_METHOD,true) + c->setDeclaredMethodByQName(#asname,AS3,Class<IFunction>::getFunction(c->getSystemState(),cppname),NORMAL_METHOD,true) #define ASFUNCTIONBODY_XML_DELEGATE(name) \ ASObject* XMLList::name(ASObject* obj, ASObject* const* args, const unsigned int argslen) \ { \ XMLList* th=obj->as<XMLList>(); \ if(!th) \ - throw Class<ArgumentError>::getInstanceS("Function applied to wrong object"); \ + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Function applied to wrong object"); \ if(th->nodes.size()==1) \ return XML::name(th->nodes[0].getPtr(), args, argslen); \ else \ @@ -94,28 +94,28 @@ { CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL); c->isReusable=true; - c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(_getLength),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("attribute",AS3,Class<IFunction>::getFunction(attribute),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("attributes",AS3,Class<IFunction>::getFunction(attributes),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("child",AS3,Class<IFunction>::getFunction(child),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("children",AS3,Class<IFunction>::getFunction(children),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("contains",AS3,Class<IFunction>::getFunction(contains),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("copy",AS3,Class<IFunction>::getFunction(copy),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("descendants",AS3,Class<IFunction>::getFunction(descendants),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("elements",AS3,Class<IFunction>::getFunction(elements),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("normalize",AS3,Class<IFunction>::getFunction(_normalize),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("parent",AS3,Class<IFunction>::getFunction(parent),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("hasSimpleContent",AS3,Class<IFunction>::getFunction(_hasSimpleContent),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("hasComplexContent",AS3,Class<IFunction>::getFunction(_hasComplexContent),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(_toString),NORMAL_METHOD,true); - c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(valueOf),DYNAMIC_TRAIT); - c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(valueOf),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("toXMLString",AS3,Class<IFunction>::getFunction(toXMLString),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("text",AS3,Class<IFunction>::getFunction(text),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("comments",AS3,Class<IFunction>::getFunction(comments),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("processingInstructions",AS3,Class<IFunction>::getFunction(processingInstructions),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("propertyIsEnumerable",AS3,Class<IFunction>::getFunction(_propertyIsEnumerable),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(c->getSystemState(),_getLength),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("attribute",AS3,Class<IFunction>::getFunction(c->getSystemState(),attribute),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("attributes",AS3,Class<IFunction>::getFunction(c->getSystemState(),attributes),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("child",AS3,Class<IFunction>::getFunction(c->getSystemState(),child),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("children",AS3,Class<IFunction>::getFunction(c->getSystemState(),children),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("contains",AS3,Class<IFunction>::getFunction(c->getSystemState(),contains),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("copy",AS3,Class<IFunction>::getFunction(c->getSystemState(),copy),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("descendants",AS3,Class<IFunction>::getFunction(c->getSystemState(),descendants),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("elements",AS3,Class<IFunction>::getFunction(c->getSystemState(),elements),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("normalize",AS3,Class<IFunction>::getFunction(c->getSystemState(),_normalize),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("parent",AS3,Class<IFunction>::getFunction(c->getSystemState(),parent),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("hasSimpleContent",AS3,Class<IFunction>::getFunction(c->getSystemState(),_hasSimpleContent),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("hasComplexContent",AS3,Class<IFunction>::getFunction(c->getSystemState(),_hasComplexContent),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("toString",AS3,Class<IFunction>::getFunction(c->getSystemState(),_toString),NORMAL_METHOD,true); + c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(c->getSystemState(),valueOf),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),valueOf),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("toXMLString",AS3,Class<IFunction>::getFunction(c->getSystemState(),toXMLString),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("text",AS3,Class<IFunction>::getFunction(c->getSystemState(),text),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("comments",AS3,Class<IFunction>::getFunction(c->getSystemState(),comments),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("processingInstructions",AS3,Class<IFunction>::getFunction(c->getSystemState(),processingInstructions),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("propertyIsEnumerable",AS3,Class<IFunction>::getFunction(c->getSystemState(),_propertyIsEnumerable),NORMAL_METHOD,true); REGISTER_XML_DELEGATE(addNamespace); REGISTER_XML_DELEGATE2(appendChild,_appendChild); REGISTER_XML_DELEGATE(childIndex); @@ -292,21 +292,21 @@ { XMLList* th=Class<XMLList>::cast(obj); assert_and_throw(argslen==0); - return abstract_i(th->nodes.size()); + return abstract_i(obj->getSystemState(),th->nodes.size()); } ASFUNCTIONBODY(XMLList,_hasSimpleContent) { XMLList* th=Class<XMLList>::cast(obj); assert_and_throw(argslen==0); - return abstract_b(th->hasSimpleContent()); + return abstract_b(obj->getSystemState(),th->hasSimpleContent()); } ASFUNCTIONBODY(XMLList,_hasComplexContent) { XMLList* th=Class<XMLList>::cast(obj); assert_and_throw(argslen==0); - return abstract_b(th->hasComplexContent()); + return abstract_b(obj->getSystemState(),th->hasComplexContent()); } ASFUNCTIONBODY(XMLList,generator) @@ -314,7 +314,7 @@ assert(obj==NULL); if(argslen==0) { - return Class<XMLList>::getInstanceSNoArgs(); + return Class<XMLList>::getInstanceSNoArgs(getSys()); } else if(args[0]->is<ASString>() || args[0]->is<Number>() || @@ -322,7 +322,7 @@ args[0]->is<UInteger>() || args[0]->is<Boolean>()) { - return Class<XMLList>::getInstanceS(args[0]->toString()); + return Class<XMLList>::getInstanceS(args[0]->getSystemState(),args[0]->toString()); } else if(args[0]->is<XMLList>()) { @@ -334,12 +334,12 @@ XML::XMLVector nodes; args[0]->incRef(); nodes.push_back(_MR(Class<XML>::cast(args[0]))); - return Class<XMLList>::getInstanceS(nodes); + return Class<XMLList>::getInstanceS(args[0]->getSystemState(),nodes); } else if(args[0]->getObjectType()==T_NULL || args[0]->getObjectType()==T_UNDEFINED) { - return Class<XMLList>::getInstanceSNoArgs(); + return Class<XMLList>::getInstanceSNoArgs(args[0]->getSystemState()); } else throw RunTimeException("Type not supported in XMLList()"); @@ -349,12 +349,12 @@ { XMLList* th=Class<XMLList>::cast(obj); _NR<ASObject> name; - ARG_UNPACK(name,_NR<ASObject>(abstract_s("*"))); + ARG_UNPACK(name,_NR<ASObject>(abstract_s(obj->getSystemState(),"*"))); XML::XMLVector ret; multiname mname(NULL); name->applyProxyProperty(mname); th->getDescendantsByQName(name->toString(),"",mname.isAttribute,ret); - return Class<XMLList>::getInstanceS(ret,th->targetobject,multiname(NULL)); + return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->targetobject,multiname(NULL)); } ASFUNCTIONBODY(XMLList,elements) @@ -369,7 +369,7 @@ { (*it)->getElementNodes(name, elems); } - return Class<XMLList>::getInstanceS(elems,th->targetobject,multiname(NULL)); + return Class<XMLList>::getInstanceS(obj->getSystemState(),elems,th->targetobject,multiname(NULL)); } ASFUNCTIONBODY(XMLList,parent) @@ -377,7 +377,7 @@ XMLList* th=Class<XMLList>::cast(obj); if(th->nodes.size()==0) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); auto it=th->nodes.begin(); ASObject *parent=(*it)->getParentNode(); @@ -387,7 +387,7 @@ { ASObject *otherParent=(*it)->getParentNode(); if(!parent->isEqual(otherParent)) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); } return parent; @@ -424,7 +424,7 @@ (*it)->childrenImpl(ret, arg0); } } - XMLList* retObj=Class<XMLList>::getInstanceS(ret,th->targetobject,multiname(NULL)); + XMLList* retObj=Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->targetobject,multiname(NULL)); return retObj; } @@ -438,7 +438,7 @@ { (*it)->childrenImpl(ret, "*"); } - XMLList* retObj=Class<XMLList>::getInstanceS(ret,th->targetobject,multiname(NULL)); + XMLList* retObj=Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->targetobject,multiname(NULL)); return retObj; } @@ -452,7 +452,7 @@ { (*it)->getText(ret); } - return Class<XMLList>::getInstanceS(ret,th->targetobject,multiname(NULL)); + return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->targetobject,multiname(NULL)); } ASFUNCTIONBODY(XMLList,contains) @@ -461,22 +461,22 @@ _NR<ASObject> value; ARG_UNPACK (value); if(!value->is<XML>()) - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); auto it=th->nodes.begin(); for(; it!=th->nodes.end(); ++it) { if((*it)->isEqual(value.getPtr())) - return abstract_b(true); + return abstract_b(obj->getSystemState(),true); } - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); } ASFUNCTIONBODY(XMLList,copy) { XMLList* th = obj->as<XMLList>(); - XMLList *dest = Class<XMLList>::getInstanceSNoArgs(); + XMLList *dest = Class<XMLList>::getInstanceSNoArgs(obj->getSystemState()); dest->targetobject = th->targetobject; auto it=th->nodes.begin(); for(; it!=th->nodes.end(); ++it) @@ -497,8 +497,8 @@ ARG_UNPACK (attrname); multiname mname(NULL); mname.name_type=multiname::NAME_STRING; - mname.name_s_id=getSys()->getUniqueStringId(attrname); - mname.ns.emplace_back("",NAMESPACE); + mname.name_s_id=obj->getSystemState()->getUniqueStringId(attrname); + mname.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); mname.isAttribute = true; _NR<ASObject> attr=th->getVariableByMultiname(mname, NONE); @@ -510,7 +510,7 @@ ASFUNCTIONBODY(XMLList,attributes) { XMLList *th = obj->as<XMLList>(); - XMLList *res = Class<XMLList>::getInstanceSNoArgs(); + XMLList *res = Class<XMLList>::getInstanceSNoArgs(obj->getSystemState()); auto it=th->nodes.begin(); for(; it!=th->nodes.end(); ++it) { @@ -524,7 +524,7 @@ { XMLList* th=Class<XMLList>::cast(obj); - XMLList *res = Class<XMLList>::getInstanceSNoArgs(); + XMLList *res = Class<XMLList>::getInstanceSNoArgs(obj->getSystemState()); XML::XMLVector nodecomments; auto it=th->nodes.begin(); for(; it!=th->nodes.end(); ++it) @@ -540,7 +540,7 @@ tiny_string name; ARG_UNPACK(name,"*"); - XMLList *res = Class<XMLList>::getInstanceSNoArgs(); + XMLList *res = Class<XMLList>::getInstanceSNoArgs(obj->getSystemState()); XML::XMLVector nodeprocessingInstructions; auto it=th->nodes.begin(); for(; it!=th->nodes.end(); ++it) @@ -556,10 +556,10 @@ if (argslen == 1) { int32_t n = args[0]->toInt(); - return abstract_b(n < (int32_t)th->nodes.size()); + return abstract_b(obj->getSystemState(),n < (int32_t)th->nodes.size()); } - return abstract_b(false); + return abstract_b(obj->getSystemState(),false); } ASFUNCTIONBODY(XMLList,_normalize) @@ -628,26 +628,26 @@ void XMLList::getTargetVariables(const multiname& name,XML::XMLVector& retnodes) { unsigned int index=0; - if(XML::isValidMultiname(name,index)) + if(XML::isValidMultiname(getSystemState(),name,index)) { retnodes.push_back(nodes[index]); } else { - tiny_string normalizedName=name.normalizedName(); + tiny_string normalizedName=name.normalizedName(getSystemState()); //Only the first namespace is used, is this right? tiny_string namespace_uri; if(name.ns.size() > 0 && !name.ns[0].hasEmptyName()) { - nsNameAndKindImpl ns=name.ns[0].getImpl(); + nsNameAndKindImpl ns=name.ns[0].getImpl(getSystemState()); if (ns.kind==NAMESPACE) namespace_uri=ns.name; } // namespace set by "default xml namespace = ..." if(namespace_uri.empty()) - namespace_uri=getVm()->getDefaultXMLNamespace(); + namespace_uri=getVm(getSystemState())->getDefaultXMLNamespace(); for (uint32_t i = 0; i < nodes.size(); i++) { @@ -677,7 +677,7 @@ //delegate to ASString if(res.isNull() && nodes.size()==1 && nodes[0]->hasSimpleContent()) { - ASString *contentstr=abstract_s(nodes[0]->toString_priv()); + ASString *contentstr=abstract_s(getSystemState(),nodes[0]->toString_priv()); res=contentstr->getVariableByMultiname(name, opt); contentstr->decRef(); } @@ -702,15 +702,15 @@ return NullRef; this->incRef(); - return _MNR(Class<XMLList>::getInstanceS(retnodes,this,name)); + return _MNR(Class<XMLList>::getInstanceS(getSystemState(),retnodes,this,name)); } unsigned int index=0; - if(XML::isValidMultiname(name,index)) + if(XML::isValidMultiname(getSystemState(),name,index)) { if(index<nodes.size()) return nodes[index]; else - return _MNR(getSys()->getUndefinedRef()); + return _MNR(getSystemState()->getUndefinedRef()); } else { @@ -730,7 +730,7 @@ return NullRef; this->incRef(); - return _MNR(Class<XMLList>::getInstanceS(retnodes,this,name)); + return _MNR(Class<XMLList>::getInstanceS(getSystemState(),retnodes,this,name)); } } @@ -742,7 +742,7 @@ return false; unsigned int index=0; - if(XML::isValidMultiname(name,index)) + if(XML::isValidMultiname(getSystemState(),name,index)) return index<nodes.size(); else { @@ -777,7 +777,7 @@ tmplist->getTargetVariables(tmpprop,retnodes); } } - if(XML::isValidMultiname(name,index)) + if(XML::isValidMultiname(getSystemState(),name,index)) { if (index >= nodes.size()) { @@ -798,20 +798,20 @@ throwError<TypeError>(kXMLAssigmentOneItemLists); if (!tmpprop.isEmpty()) { - XML* tmp = Class<XML>::getInstanceSNoArgs(); + XML* tmp = Class<XML>::getInstanceSNoArgs(getSystemState()); tmp->nodetype = pugi::node_element; - tmp->nodename = targetproperty.normalizedName(); - tmp->attributelist = _MR(Class<XMLList>::getInstanceSNoArgs()); + tmp->nodename = targetproperty.normalizedName(getSystemState()); + tmp->attributelist = _MR(Class<XMLList>::getInstanceSNoArgs(getSystemState())); tmp->constructed = true; tmp->setVariableByMultiname(name,o,allowConst); tmp->incRef(); - tiny_string tmpname = tmpprop.normalizedName(); + tiny_string tmpname = tmpprop.normalizedName(getSystemState()); if (retnodes.empty() && tmpname != "" && tmpname != "*") { - XML* tmp2 = Class<XML>::getInstanceSNoArgs(); + XML* tmp2 = Class<XML>::getInstanceSNoArgs(getSystemState()); tmp2->nodetype = pugi::node_element; tmp2->nodename = tmpname; - tmp2->attributelist = _MR(Class<XMLList>::getInstanceSNoArgs()); + tmp2->attributelist = _MR(Class<XMLList>::getInstanceSNoArgs(getSystemState())); tmp2->constructed = true; tmp2->setVariableByMultiname(targetproperty,tmp,allowConst); tmp2->incRef(); @@ -845,7 +845,7 @@ unsigned int index=0; bool bdeleted = false; - if(XML::isValidMultiname(name,index)) + if(XML::isValidMultiname(getSystemState(),name,index)) { _R<XML> node = nodes[index]; if (node->parentNode) @@ -936,7 +936,7 @@ else { tiny_string str = x->toString(); - append(_MR(XML::createFromString(str))); + append(_MR(XML::createFromString(this->getSystemState(),str))); } } @@ -988,7 +988,7 @@ multiname m(NULL); m.name_type = multiname::NAME_INT; m.name_i = i; - m.ns.emplace_back("",NAMESPACE); + m.ns.emplace_back(getSystemState(),"",NAMESPACE); targetobject->setVariableByMultiname(m,o,allowConst); break; } @@ -1014,13 +1014,13 @@ multiname m(NULL); m.name_type = multiname::NAME_INT; m.name_i = idx; - m.ns.emplace_back("",NAMESPACE); + m.ns.emplace_back(getSystemState(),"",NAMESPACE); targetobject->setVariableByMultiname(m,o,allowConst); } if (o->as<XML>()->getNodeKind() == pugi::node_pcdata) { nodes[idx]->childrenlist->clear(); - _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs()); + _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs(getSystemState())); nodes[idx]->incRef(); tmp->parentNode = nodes[idx]; tmp->nodetype = pugi::node_pcdata; @@ -1044,7 +1044,7 @@ else { nodes[idx]->childrenlist->clear(); - _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs()); + _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs(getSystemState())); nodes[idx]->incRef(); tmp->parentNode = nodes[idx]; tmp->nodetype = pugi::node_pcdata; @@ -1104,7 +1104,7 @@ ASFUNCTIONBODY(XMLList,_toString) { XMLList* th=Class<XMLList>::cast(obj); - return abstract_s(th->toString_priv()); + return abstract_s(obj->getSystemState(),th->toString_priv()); } tiny_string XMLList::toXMLString_internal(bool pretty) @@ -1128,7 +1128,7 @@ { XMLList* th=Class<XMLList>::cast(obj); assert_and_throw(argslen==0); - ASString* ret=abstract_s(th->toXMLString_internal()); + ASString* ret=abstract_s(obj->getSystemState(),th->toXMLString_internal()); return ret; } @@ -1171,7 +1171,7 @@ _R<ASObject> XMLList::nextName(uint32_t index) { if(index<=nodes.size()) - return _MR(abstract_i(index-1)); + return _MR(abstract_i(getSystemState(),index-1)); else throw RunTimeException("XMLList::nextName out of bounds"); }
View file
lightspark.tar.xz/src/scripting/toplevel/toplevel.cpp
Changed
@@ -134,22 +134,17 @@ type=T_FUNCTION; } -void IFunction::finalize() -{ - ASObject::finalize(); - closure_this.reset(); -} - void IFunction::sinit(Class_base* c) { - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(IFunction::_toString),DYNAMIC_TRAIT); + c->isReusable=true; + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),IFunction::_toString),DYNAMIC_TRAIT); - c->setDeclaredMethodByQName("call","",Class<IFunction>::getFunction(IFunction::_call,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("call",AS3,Class<IFunction>::getFunction(IFunction::_call,1),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("apply","",Class<IFunction>::getFunction(IFunction::apply,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("apply",AS3,Class<IFunction>::getFunction(IFunction::apply,2),NORMAL_METHOD,true); - c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(IFunction::_getter_length),GETTER_METHOD,true); - c->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(IFunction::_toString),NORMAL_METHOD,false); + c->setDeclaredMethodByQName("call","",Class<IFunction>::getFunction(c->getSystemState(),IFunction::_call,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("call",AS3,Class<IFunction>::getFunction(c->getSystemState(),IFunction::_call,1),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("apply","",Class<IFunction>::getFunction(c->getSystemState(),IFunction::apply,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("apply",AS3,Class<IFunction>::getFunction(c->getSystemState(),IFunction::apply,2),NORMAL_METHOD,true); + c->setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(c->getSystemState(),IFunction::_getter_length),GETTER_METHOD,true); + c->setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),IFunction::_toString),NORMAL_METHOD,false); } ASFUNCTIONBODY_GETTER_SETTER(IFunction,prototype); @@ -168,7 +163,7 @@ if(argslen==0 || args[0]->is<Null>() || args[0]->is<Undefined>()) { //get the current global object - newObj=getVm()->currentCallContext->scope_stack[0].object->as<Global>(); + newObj=getVm(obj->getSystemState())->currentCallContext->scope_stack[0].object->as<Global>(); newObj->incRef(); } else @@ -203,7 +198,7 @@ if(argslen==0 || args[0]->is<Null>() || args[0]->is<Undefined>()) { //get the current global object - newObj=getVm()->currentCallContext->scope_stack[0].object->as<Global>(); + newObj=getVm(obj->getSystemState())->currentCallContext->scope_stack[0].object->as<Global>(); newObj->incRef(); } else @@ -227,7 +222,7 @@ ASFUNCTIONBODY(IFunction,_toString) { - return abstract_s("function Function() {}"); + return abstract_s(obj->getSystemState(),"function Function() {}"); } ASObject* Class<IFunction>::generator(ASObject* const* args, const unsigned int argslen) @@ -262,16 +257,7 @@ { if(mi) length = mi->numArgs(); -} - -SyntheticFunction::~SyntheticFunction() -{ -} - -void SyntheticFunction::finalize() -{ - IFunction::finalize(); - func_scope.clear(); + reusableListNumber = 1; } /** @@ -284,13 +270,13 @@ const uint32_t opt_hit_threshold=1; const uint32_t jit_hit_threshold=20; if (!mi->body) - return getSys()->getUndefinedRef(); + return getSystemState()->getUndefinedRef(); const uint16_t hit_count = mi->body->hit_count; const method_body_info::CODE_STATUS& codeStatus = mi->body->codeStatus; - uint32_t& cur_recursion = getVm()->cur_recursion; - if(cur_recursion == getVm()->limits.max_recursion) + uint32_t& cur_recursion = getVm(getSystemState())->cur_recursion; + if(cur_recursion == getVm(getSystemState())->limits.max_recursion) { for(uint32_t i=0;i<numArgs;i++) args[i]->decRef(); @@ -329,16 +315,16 @@ } //For sufficiently hot methods, optimize them to the internal bytecode - if(hit_count>=opt_hit_threshold && codeStatus==method_body_info::ORIGINAL && getSys()->useFastInterpreter) + if(hit_count>=opt_hit_threshold && codeStatus==method_body_info::ORIGINAL && getSystemState()->useFastInterpreter) { ABCVm::optimizeFunction(this); } //Temporarily disable JITting - if(mi->body->exceptions.size()==0 && getSys()->useJit && ((hit_count>=jit_hit_threshold && codeStatus==method_body_info::OPTIMIZED) || getSys()->useInterpreter==false)) + if(mi->body->exceptions.size()==0 && getSystemState()->useJit && ((hit_count>=jit_hit_threshold && codeStatus==method_body_info::OPTIMIZED) || getSystemState()->useInterpreter==false)) { //We passed the hot function threshold, synt the function - val=mi->synt_method(); + val=mi->synt_method(getSystemState()); assert(val); } mi->body->hit_count++; @@ -354,7 +340,7 @@ { //The arguments does not contain default values of optional parameters, //i.e. f(a,b=3) called as f(7) gives arguments = { 7 } - argumentsArray=Class<Array>::getInstanceS(); + argumentsArray=Class<Array>::getInstanceS(obj->getSystemState()); argumentsArray->resize(numArgs); for(uint32_t j=0;j<numArgs;j++) { @@ -383,7 +369,7 @@ cc.scope_stack=func_scope; cc.initialScopeStack=func_scope.size(); cc.exec_pos=0; - call_context* saved_cc = getVm()->currentCallContext; + call_context* saved_cc = getVm(getSystemState())->currentCallContext; if (saved_cc) { if (!saved_cc->defaultNamespaceUri.isNull()) @@ -392,7 +378,7 @@ } /* Set the current global object, each script in each DoABCTag has its own */ - getVm()->currentCallContext = &cc; + getVm(getSystemState())->currentCallContext = &cc; if(isBound()) { /* closure_this can never been overriden */ @@ -423,7 +409,7 @@ cc.locals[i+1]=mi->paramTypes[i]->coerce(mi->getOptional(iOptional)); else { assert(mi->paramTypes[i] == Type::anyType); - cc.locals[i+1]=getSys()->getUndefinedRef(); + cc.locals[i+1]=getSystemState()->getUndefinedRef(); } } cc.argarrayposition = -1; @@ -436,7 +422,7 @@ else if(mi->needsRest()|| passedToRest > 0) // it seems that Adobe allows additional parameters without setting "needsRest" { assert_and_throw(argumentsArray==NULL); - Array* rest=Class<Array>::getInstanceS(); + Array* rest=Class<Array>::getInstanceS(getSystemState()); rest->resize(passedToRest); //Give the reference of the other args to an array for(uint32_t j=0;j<passedToRest;j++) @@ -458,14 +444,14 @@ cur_recursion++; //increment current recursion depth Log::calls_indent++; - getVm()->stacktrace.push_back(std::pair<uint32_t,ASObject*>(this->functionname,obj)); + getVm(getSystemState())->stacktrace.push_back(std::pair<uint32_t,ASObject*>(this->functionname,obj)); while (true) { try { - if(mi->body->exceptions.size() || (val==NULL && getSys()->useInterpreter)) + if(mi->body->exceptions.size() || (val==NULL && getSystemState()->useInterpreter)) { - if(codeStatus == method_body_info::OPTIMIZED && getSys()->useFastInterpreter) + if(codeStatus == method_body_info::OPTIMIZED && getSystemState()->useFastInterpreter) { //This is a mildy hot function, execute it using the fast interpreter ret=ABCVm::executeFunctionFast(this,&cc,obj); @@ -512,8 +498,8 @@ { cur_recursion--; //decrement current recursion depth Log::calls_indent--; - getVm()->stacktrace.pop_back(); - getVm()->currentCallContext = saved_cc; + getVm(getSystemState())->stacktrace.pop_back(); + getVm(getSystemState())->currentCallContext = saved_cc; throw; } continue; @@ -521,15 +507,15 @@ break; } cur_recursion--; //decrement current recursion depth - getVm()->stacktrace.pop_back(); + getVm(getSystemState())->stacktrace.pop_back(); Log::calls_indent--; - getVm()->currentCallContext = saved_cc; + getVm(getSystemState())->currentCallContext = saved_cc; this->decRef(); //free local ref obj->decRef(); if(ret==NULL) - ret=getSys()->getUndefinedRef(); + ret=obj->getSystemState()->getUndefinedRef(); return mi->returnType->coerce(ret); } @@ -574,7 +560,7 @@ args[i]->decRef(); obj->decRef(); if(ret==NULL) - ret=getSys()->getUndefinedRef(); + ret=getSystemState()->getUndefinedRef(); return ret; } bool Function::isEqual(ASObject* r) @@ -691,7 +677,7 @@ ASObject* Void::coerce(ASObject* o) const { if(!o->is<Undefined>()) - throw Class<TypeError>::getInstanceS("Trying to coerce o!=undefined to void"); + throw Class<TypeError>::getInstanceS(o->getSystemState(),"Trying to coerce o!=undefined to void"); return o; } @@ -755,23 +741,23 @@ if(!typeObject) { - if (mn->ns.size() >= 1 && mn->ns[0].getImpl().name == "__AS3__.vec") + if (mn->ns.size() >= 1 && mn->ns[0].getImpl(context->root->getSystemState()).name == "__AS3__.vec") { - QName qname(getSys()->getStringFromUniqueId(mn->name_s_id),mn->ns[0].getImpl().name); - typeObject = Template<Vector>::getTemplateInstance(qname,context,context->root->applicationDomain).getPtr(); + QName qname(getSys()->getStringFromUniqueId(mn->name_s_id),mn->ns[0].getImpl(context->root->getSystemState()).name); + typeObject = Template<Vector>::getTemplateInstance(context->root->getSystemState(),qname,context,context->root->applicationDomain).getPtr(); } } return typeObject->as<Type>(); } -Class_base::Class_base(const QName& name, MemoryAccount* m):ASObject(Class_object::getClass()),protected_ns("",NAMESPACE),constructor(NULL), +Class_base::Class_base(const QName& name, MemoryAccount* m):ASObject(Class_object::getClass(getSys())),protected_ns(getSys(),"",NAMESPACE),constructor(NULL), borrowedVariables(m), context(NULL),class_name(name),memoryAccount(m),length(1),class_index(-1),isFinal(false),isSealed(false),isInterface(false),isReusable(false),isProxy(false),use_protected(false) { type=T_CLASS; } -Class_base::Class_base(const Class_object*):ASObject((MemoryAccount*)NULL),protected_ns("",NAMESPACE),constructor(NULL), +Class_base::Class_base(const Class_object*):ASObject((MemoryAccount*)NULL),protected_ns(getSys(),"",NAMESPACE),constructor(NULL), borrowedVariables(NULL), context(NULL),class_name("Class",""),memoryAccount(NULL),length(1),class_index(-1),isFinal(false),isSealed(false),isInterface(false),isReusable(false),isProxy(false),use_protected(false) { @@ -818,7 +804,7 @@ constructorprop->incRef(); addConstructorGetter(); - setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(Class_base::_toString),NORMAL_METHOD,false); + setDeclaredMethodByQName("toString","",Class<IFunction>::getFunction(getSystemState(),Class_base::_toString),NORMAL_METHOD,false); incRef(); prototype->setVariableByQName("constructor","",this,DECLARED_TRAIT); @@ -834,13 +820,13 @@ if (o->is<Undefined>()) { o->decRef(); - return getSys()->getNullRef(); + return o->getSystemState()->getNullRef(); } if(o->is<Null>()) return o; if(o->is<Class_base>()) { /* classes can be cast to the type 'Object' or 'Class' */ - if(this == Class<ASObject>::getClass() + if(this == Class<ASObject>::getClass(o->getSystemState()) || (class_name.name=="Class" && class_name.ns=="")) return o; /* 'this' is the type of a class */ else @@ -871,22 +857,22 @@ ret = "[class "; ret += th->class_name.name; ret += "]"; - return abstract_s(ret); + return abstract_s(obj->getSystemState(),ret); } void Class_base::addConstructorGetter() { - setDeclaredMethodByQName("constructor","",Class<IFunction>::getFunction(_getter_constructorprop),GETTER_METHOD,false); + setDeclaredMethodByQName("constructor","",Class<IFunction>::getFunction(getSystemState(),_getter_constructorprop),GETTER_METHOD,false); } void Class_base::addPrototypeGetter() { - setDeclaredMethodByQName("prototype","",Class<IFunction>::getFunction(_getter_prototype),GETTER_METHOD,false); + setDeclaredMethodByQName("prototype","",Class<IFunction>::getFunction(getSystemState(),_getter_prototype),GETTER_METHOD,false); } void Class_base::addLengthGetter() { - setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(_getter_length),GETTER_METHOD,false); + setDeclaredMethodByQName("length","",Class<IFunction>::getFunction(getSystemState(),_getter_length),GETTER_METHOD,false); } Class_base::~Class_base() @@ -903,7 +889,7 @@ else th = obj->getClass(); if(argslen != 0) - throw Class<ArgumentError>::getInstanceS("Arguments provided in getter"); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Arguments provided in getter"); ASObject* ret=th->constructorprop.getPtr(); ret->incRef(); return ret; @@ -912,10 +898,10 @@ ASObject* Class_base::_getter_prototype(ASObject* obj, ASObject* const* args, const unsigned int argslen) { if(!obj->is<Class_base>()) - throw Class<ArgumentError>::getInstanceS("Function applied to wrong object"); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Function applied to wrong object"); Class_base* th = obj->as<Class_base>(); if(argslen != 0) - throw Class<ArgumentError>::getInstanceS("Arguments provided in getter"); + throw Class<ArgumentError>::getInstanceS(obj->getSystemState(),"Arguments provided in getter"); ASObject* ret=th->prototype->getObj(); ret->incRef(); return ret; @@ -948,41 +934,12 @@ return ret; } -void Class_base::recursiveBuild(ASObject* target) -{ - if(super) - super->recursiveBuild(target); - - buildInstanceTraits(target); -} - void Class_base::setConstructor(IFunction* c) { assert_and_throw(constructor==NULL); constructor=c; } -void Class_base::setupDeclaredTraits(ASObject *target) -{ - if (!target->traitsInitialized) - { - #ifndef NDEBUG - assert_and_throw(!target->initialized); - #endif - //HACK: suppress implementation handling of variables just now - bool bak=target->implEnable; - target->implEnable=false; - recursiveBuild(target); - //And restore it - target->implEnable=bak; - - #ifndef NDEBUG - target->initialized=true; - #endif - target->traitsInitialized = true; - } -} - void Class_base::handleConstruction(ASObject* target, ASObject* const* args, unsigned int argslen, bool buildAndLink) { if(buildAndLink) @@ -1013,14 +970,14 @@ void Class_base::acquireObject(ASObject* ob) { - Locker l(referencedObjectsMutex); + SpinlockLocker l(referencedObjectsMutex); assert_and_throw(!ob->is_linked()); referencedObjects.push_back(*ob); } void Class_base::abandonObject(ASObject* ob) { - Locker l(referencedObjectsMutex); + SpinlockLocker l(referencedObjectsMutex); assert_and_throw(ob->is_linked()); #ifdef EXPENSIVE_DEBUG //Check that the object is really referenced by this class @@ -1059,34 +1016,12 @@ } } -ASObject *Class_base::getObjectFromFreeList() -{ - Locker l(referencedObjectsMutex); - ASObject* ret = NULL; - if (!freelist.empty()) - { - ret=freelist.front(); - freelist.pop_front(); - ret->incRef(); - } -// else -// LOG(LOG_INFO,"cache miss:"<<this->class_name); - - return ret; -} - -void Class_base::pushObjectToFreeList(ASObject *obj) -{ - Locker l(referencedObjectsMutex); - freelist.push_front(obj); -} - void Class_base::finalize() { borrowedVariables.destroyContents(); super.reset(); prototype.reset(); - protected_ns = nsNameAndKind("",NAMESPACE); + protected_ns = nsNameAndKind(getSystemState(),"",NAMESPACE); constructor = NULL; context = NULL; length = 1; @@ -1103,18 +1038,19 @@ type = T_TEMPLATE; } -Class_object* Class_object::getClass() +Class_object* Class_object::getClass(SystemState *sys) { //We check if we are registered already //if not we register ourselves (see also Class<T>::getClass) //Class object position in the map is hardwired to 0 uint32_t classId=0; Class_object* ret=NULL; - Class_base** retAddr=&getSys()->builtinClasses[classId]; + Class_base** retAddr=&sys->builtinClasses[classId]; if(*retAddr==NULL) { //Create the class - ret=new (getSys()->unaccountedMemory) Class_object(); + ret=new (sys->unaccountedMemory) Class_object(); + ret->setSystemState(sys); ret->incRef(); *retAddr=ret; } @@ -1124,20 +1060,6 @@ return ret; } -_R<Class_object> Class_object::getRef() -{ - Class_object* ret = getClass(); - ret->incRef(); - return _MR(ret); -} - -void Class_object::finalize() -{ - //Remove the cyclic reference to itself - setClass(NULL); - Class_base::finalize(); -} - const std::vector<Class_base*>& Class_base::getInterfaces(bool *alldefined) const { if (alldefined) @@ -1204,7 +1126,7 @@ bool Class_base::isSubClass(const Class_base* cls, bool considerInterfaces) const { check(); - if(cls==this || cls==Class<ASObject>::getClass()) + if(cls==this || cls==Class<ASObject>::getClass(cls->getSystemState())) return true; //Now check the interfaces @@ -1235,7 +1157,7 @@ int name_index=context->instances[class_index].name; assert_and_throw(name_index); const multiname* mname=context->getMultiname(name_index,NULL); - return mname->qualifiedString(); + return mname->qualifiedString(getSystemState()); } } @@ -1340,7 +1262,7 @@ default: continue; } - tiny_string name = getSys()->getStringFromUniqueId(it->first.nameId); + tiny_string name = getSystemState()->getStringFromUniqueId(it->first.nameId); auto existing=instanceNodes.find(name); if(existing != instanceNodes.cend()) continue; @@ -1362,7 +1284,7 @@ int kind=t.kind&0xf; multiname* mname=context->getMultiname(t.name,NULL); if (mname->name_type!=multiname::NAME_STRING || - (mname->ns.size()==1 && (!mname->ns[0].hasEmptyName() || mname->ns[0].getImpl().kind == PRIVATE_NAMESPACE)) || + (mname->ns.size()==1 && (!mname->ns[0].hasEmptyName() || mname->ns[0].getImpl(getSystemState()).kind == PRIVATE_NAMESPACE)) || mname->ns.size() > 1) continue; @@ -1371,20 +1293,20 @@ multiname* type=context->getMultiname(t.type_name,NULL); const char *nodename=kind==traits_info::Const?"constant":"variable"; pugi::xml_node node=root.append_child(nodename); - node.append_attribute("name").set_value(getSys()->getStringFromUniqueId(mname->name_s_id).raw_buf()); - node.append_attribute("type").set_value(type->qualifiedString().raw_buf()); + node.append_attribute("name").set_value(getSystemState()->getStringFromUniqueId(mname->name_s_id).raw_buf()); + node.append_attribute("type").set_value(type->qualifiedString(getSystemState()).raw_buf()); describeMetadata(node, t); } else if (kind==traits_info::Method) { pugi::xml_node node=root.append_child("method"); - node.append_attribute("name").set_value(getSys()->getStringFromUniqueId(mname->name_s_id).raw_buf()); + node.append_attribute("name").set_value(getSystemState()->getStringFromUniqueId(mname->name_s_id).raw_buf()); node.append_attribute("declaredBy").set_value(getQualifiedClassName().raw_buf()); method_info& method=context->methods[t.method]; const multiname* rtname=method.returnTypeName(); - node.append_attribute("returnType").set_value(rtname->qualifiedString().raw_buf()); + node.append_attribute("returnType").set_value(rtname->qualifiedString(getSystemState()).raw_buf()); assert(method.numArgs() >= method.numOptions()); uint32_t firstOpt=method.numArgs() - method.numOptions(); @@ -1392,7 +1314,7 @@ { pugi::xml_node param=node.append_child("parameter"); param.append_attribute("index").set_value(UInteger::toString(j+1).raw_buf()); - param.append_attribute("type").set_value(method.paramTypeName(j)->qualifiedString().raw_buf()); + param.append_attribute("type").set_value(method.paramTypeName(j)->qualifiedString(getSystemState()).raw_buf()); param.append_attribute("optional").set_value(j>=firstOpt?"true":"false"); } @@ -1410,7 +1332,7 @@ if(existing==accessorNodes.end()) { node=root.append_child("accessor"); - node.append_attribute("name").set_value(getSys()->getStringFromUniqueId(mname->name_s_id).raw_buf()); + node.append_attribute("name").set_value(getSystemState()->getStringFromUniqueId(mname->name_s_id).raw_buf()); } else { @@ -1437,11 +1359,11 @@ if(kind==traits_info::Getter) { const multiname* rtname=method.returnTypeName(); - type=rtname->qualifiedString(); + type=rtname->qualifiedString(getSystemState()); } else if(method.numArgs()>0) // setter { - type=method.paramTypeName(0)->qualifiedString(); + type=method.paramTypeName(0)->qualifiedString(getSystemState()); } if(!type.empty()) { @@ -1492,19 +1414,14 @@ cur=dynamic_cast<Class_inherit*>(cur->super.getPtr()); } if(baseNs==NULL) - protected_ns=nsNameAndKind(name,(NS_KIND)(int)ns.kind); + protected_ns=nsNameAndKind(getSystemState(),name,(NS_KIND)(int)ns.kind); else - protected_ns=nsNameAndKind(name,baseNs->nsId,(NS_KIND)(int)ns.kind); -} - -const variable* Class_base::findBorrowedGettable(const multiname& name,NS_KIND& nskind) const -{ - return ASObject::findGettableImpl(borrowedVariables,name,nskind); + protected_ns=nsNameAndKind(getSystemState(),name,baseNs->nsId,(NS_KIND)(int)ns.kind); } variable* Class_base::findBorrowedSettable(const multiname& name, bool* has_getter) { - return ASObject::findSettableImpl(borrowedVariables,name,has_getter); + return ASObject::findSettableImpl(getSystemState(),borrowedVariables,name,has_getter); } variable* Class_base::findSettableInPrototype(const multiname& name) @@ -1524,8 +1441,7 @@ EARLY_BIND_STATUS Class_base::resolveMultinameStatically(const multiname& name) const { - NS_KIND nskind; - if(findBorrowedGettable(name,nskind)!=NULL) + if(findBorrowedGettable(name)!=NULL) return BINDED; else return NOT_BINDED; @@ -1545,9 +1461,9 @@ void ASQName::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); - c->setDeclaredMethodByQName("uri","",Class<IFunction>::getFunction(_getURI),GETTER_METHOD,true); - c->setDeclaredMethodByQName("localName","",Class<IFunction>::getFunction(_getLocalName),GETTER_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); + c->setDeclaredMethodByQName("uri","",Class<IFunction>::getFunction(c->getSystemState(),_getURI),GETTER_METHOD,true); + c->setDeclaredMethodByQName("localName","",Class<IFunction>::getFunction(c->getSystemState(),_getLocalName),GETTER_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); } ASFUNCTIONBODY(ASQName,_constructor) @@ -1562,7 +1478,7 @@ { th->local_name=""; th->uri_is_null=false; - th->uri=getVm()->getDefaultXMLNamespace(); + th->uri=getVm(obj->getSystemState())->getDefaultXMLNamespace(); return NULL; } if(argslen==1) @@ -1604,7 +1520,7 @@ } else { - th->uri=getVm()->getDefaultXMLNamespace(); + th->uri=getVm(obj->getSystemState())->getDefaultXMLNamespace(); } } else if(namespaceval->getObjectType()==T_NULL) @@ -1628,7 +1544,7 @@ } ASFUNCTIONBODY(ASQName,generator) { - ASQName* th=Class<ASQName>::getInstanceS(); + ASQName* th=Class<ASQName>::getInstanceS(getSys()); assert_and_throw(argslen<3); ASObject *nameval; @@ -1638,7 +1554,7 @@ { th->local_name=""; th->uri_is_null=false; - th->uri=getVm()->getDefaultXMLNamespace(); + th->uri=getVm(getSys())->getDefaultXMLNamespace(); return th; } if(argslen==1) @@ -1680,7 +1596,7 @@ } else { - th->uri=getVm()->getDefaultXMLNamespace(); + th->uri=getVm(getSys())->getDefaultXMLNamespace(); } } else if(namespaceval->getObjectType()==T_NULL) @@ -1706,23 +1622,23 @@ { ASQName* th=static_cast<ASQName*>(obj); if(th->uri_is_null) - return getSys()->getNullRef(); + return obj->getSystemState()->getNullRef(); else - return abstract_s(th->uri); + return abstract_s(obj->getSystemState(),th->uri); } ASFUNCTIONBODY(ASQName,_getLocalName) { ASQName* th=static_cast<ASQName*>(obj); - return abstract_s(th->local_name); + return abstract_s(obj->getSystemState(),th->local_name); } ASFUNCTIONBODY(ASQName,_toString) { if(!obj->is<ASQName>()) - throw Class<TypeError>::getInstanceS("QName.toString is not generic"); + throw Class<TypeError>::getInstanceS(obj->getSystemState(),"QName.toString is not generic"); ASQName* th=static_cast<ASQName*>(obj); - return abstract_s(th->toString()); + return abstract_s(obj->getSystemState(),th->toString()); } bool ASQName::isEqual(ASObject* o) @@ -1770,9 +1686,9 @@ switch(index) { case 1: - return _MR(abstract_s("uri")); + return _MR(abstract_s(getSystemState(),"uri")); case 2: - return _MR(abstract_s("localName")); + return _MR(abstract_s(getSystemState(),"localName")); default: return ASObject::nextName(index-2); } @@ -1785,11 +1701,11 @@ { case 1: if (uri_is_null) - return _MR(getSys()->getNullRef()); + return _MR(getSystemState()->getNullRef()); else - return _MR(abstract_s(this->uri)); + return _MR(abstract_s(getSystemState(),this->uri)); case 2: - return _MR(abstract_s(this->local_name)); + return _MR(abstract_s(getSystemState(),this->local_name)); default: return ASObject::nextName(index-2); } @@ -1811,13 +1727,13 @@ void Namespace::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_SEALED | CLASS_FINAL); - //c->setDeclaredMethodByQName("uri","",Class<IFunction>::getFunction(_setURI),SETTER_METHOD,true); - c->setDeclaredMethodByQName("uri","",Class<IFunction>::getFunction(_getURI),GETTER_METHOD,true); - //c->setDeclaredMethodByQName("prefix","",Class<IFunction>::getFunction(_setPrefix),SETTER_METHOD,true); - c->setDeclaredMethodByQName("prefix","",Class<IFunction>::getFunction(_getPrefix),GETTER_METHOD,true); - c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(_valueOf),NORMAL_METHOD,true); - c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(_toString),DYNAMIC_TRAIT); - c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(_ECMA_valueOf),DYNAMIC_TRAIT); + //c->setDeclaredMethodByQName("uri","",Class<IFunction>::getFunction(c->getSystemState(),_setURI),SETTER_METHOD,true); + c->setDeclaredMethodByQName("uri","",Class<IFunction>::getFunction(c->getSystemState(),_getURI),GETTER_METHOD,true); + //c->setDeclaredMethodByQName("prefix","",Class<IFunction>::getFunction(c->getSystemState(),_setPrefix),SETTER_METHOD,true); + c->setDeclaredMethodByQName("prefix","",Class<IFunction>::getFunction(c->getSystemState(),_getPrefix),GETTER_METHOD,true); + c->setDeclaredMethodByQName("valueOf",AS3,Class<IFunction>::getFunction(c->getSystemState(),_valueOf),NORMAL_METHOD,true); + c->prototype->setVariableByQName("toString","",Class<IFunction>::getFunction(c->getSystemState(),_toString),DYNAMIC_TRAIT); + c->prototype->setVariableByQName("valueOf","",Class<IFunction>::getFunction(c->getSystemState(),_ECMA_valueOf),DYNAMIC_TRAIT); } void Namespace::buildTraits(ASObject* o) @@ -1894,7 +1810,7 @@ prefixval->toString()=="") th->prefix=""; else - throw Class<TypeError>::getInstanceS("Namespace prefix for empty uri not allowed"); + throw Class<TypeError>::getInstanceS(obj->getSystemState(),"Namespace prefix for empty uri not allowed"); } else if(prefixval->getObjectType()==T_UNDEFINED || !isXMLName(prefixval)) @@ -1912,7 +1828,7 @@ } ASFUNCTIONBODY(Namespace,generator) { - Namespace* th=Class<Namespace>::getInstanceS(); + Namespace* th=Class<Namespace>::getInstanceS(getSys()); ASObject *urival; ASObject *prefixval; assert_and_throw(argslen<3); @@ -1982,7 +1898,7 @@ prefixval->toString()=="") th->prefix=""; else - throw Class<TypeError>::getInstanceS("Namespace prefix for empty uri not allowed"); + throw Class<TypeError>::getInstanceS(getSys(),"Namespace prefix for empty uri not allowed"); } else if(prefixval->getObjectType()==T_UNDEFINED || !isXMLName(prefixval)) @@ -2008,7 +1924,7 @@ ASFUNCTIONBODY(Namespace,_getURI) { Namespace* th=static_cast<Namespace*>(obj); - return abstract_s(th->uri); + return abstract_s(obj->getSystemState(),th->uri); } /* ASFUNCTIONBODY(Namespace,_setPrefix) @@ -2031,30 +1947,30 @@ { Namespace* th=static_cast<Namespace*>(obj); if(th->prefix_is_undefined) - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); else - return abstract_s(th->prefix); + return abstract_s(obj->getSystemState(),th->prefix); } ASFUNCTIONBODY(Namespace,_toString) { if(!obj->is<Namespace>()) - throw Class<TypeError>::getInstanceS("Namespace.toString is not generic"); + throw Class<TypeError>::getInstanceS(obj->getSystemState(),"Namespace.toString is not generic"); Namespace* th=static_cast<Namespace*>(obj); - return abstract_s(th->uri); + return abstract_s(obj->getSystemState(),th->uri); } ASFUNCTIONBODY(Namespace,_valueOf) { - return abstract_s(obj->as<Namespace>()->uri); + return abstract_s(obj->getSystemState(),obj->as<Namespace>()->uri); } ASFUNCTIONBODY(Namespace,_ECMA_valueOf) { if(!obj->is<Namespace>()) - throw Class<TypeError>::getInstanceS("Namespace.valueOf is not generic"); + throw Class<TypeError>::getInstanceS(obj->getSystemState(),"Namespace.valueOf is not generic"); Namespace* th=static_cast<Namespace*>(obj); - return abstract_s(th->uri); + return abstract_s(obj->getSystemState(),th->uri); } bool Namespace::isEqual(ASObject* o) @@ -2091,9 +2007,9 @@ switch(index) { case 1: - return _MR(abstract_s("uri")); + return _MR(abstract_s(getSystemState(),"uri")); case 2: - return _MR(abstract_s("prefix")); + return _MR(abstract_s(getSystemState(),"prefix")); default: return ASObject::nextName(index-2); } @@ -2105,12 +2021,12 @@ switch(index) { case 1: - return _MR(abstract_s(this->uri)); + return _MR(abstract_s(getSystemState(),this->uri)); case 2: if(prefix_is_undefined) - return _MR(getSys()->getUndefinedRef()); + return _MR(getSystemState()->getUndefinedRef()); else - return _MR(abstract_s(this->prefix)); + return _MR(abstract_s(getSystemState(),this->prefix)); default: return ASObject::nextName(index-2); } @@ -2118,14 +2034,14 @@ ASObject* ASNop(ASObject* obj, ASObject* const* args, const unsigned int argslen) { - return getSys()->getUndefinedRef(); + return obj->getSystemState()->getUndefinedRef(); } IFunction* Class<IFunction>::getNopFunction() { IFunction* ret=new (this->memoryAccount) Function(this, ASNop); //Similarly to newFunction, we must create a prototype object - ret->prototype = _MR(new_asobject()); + ret->prototype = _MR(new_asobject(ret->getSystemState())); return ret; } @@ -2139,21 +2055,23 @@ return ret; } -Class<IFunction>* Class<IFunction>::getClass() +Class<IFunction>* Class<IFunction>::getClass(SystemState* sys) { uint32_t classId=ClassName<IFunction>::id; Class<IFunction>* ret=NULL; - Class_base** retAddr=&getSys()->builtinClasses[classId]; + SystemState* s = sys ? sys : getSys(); + Class_base** retAddr=&s->builtinClasses[classId]; if(*retAddr==NULL) { //Create the class - MemoryAccount* memoryAccount = getSys()->allocateMemoryAccount(ClassName<IFunction>::name); - ret=new (getSys()->unaccountedMemory) Class<IFunction>(memoryAccount); + MemoryAccount* memoryAccount = s->allocateMemoryAccount(ClassName<IFunction>::name); + ret=new (s->unaccountedMemory) Class<IFunction>(memoryAccount); + ret->setSystemState(s); //This function is called from Class<ASObject>::getRef(), //so the Class<ASObject> we obtain will not have any //declared methods yet! Therefore, set super will not copy //up any borrowed traits from there. We do that by ourself. - ret->setSuper(Class<ASObject>::getRef()); + ret->setSuper(Class<ASObject>::getRef(s)); //The prototype for Function seems to be a function object. Use the special FunctionPrototype ret->prototype = _MNR(new_functionPrototype(ret, ret->super->prototype)); ret->incRef(); @@ -2172,8 +2090,8 @@ ret->addConstructorGetter(); - ret->setDeclaredMethodByQName("prototype","",Class<IFunction>::getFunction(IFunction::_getter_prototype),GETTER_METHOD,true); - ret->setDeclaredMethodByQName("prototype","",Class<IFunction>::getFunction(IFunction::_setter_prototype),SETTER_METHOD,true); + ret->setDeclaredMethodByQName("prototype","",Class<IFunction>::getFunction(ret->getSystemState(),IFunction::_getter_prototype),GETTER_METHOD,true); + ret->setDeclaredMethodByQName("prototype","",Class<IFunction>::getFunction(ret->getSystemState(),IFunction::_setter_prototype),SETTER_METHOD,true); } else ret=static_cast<Class<IFunction>*>(*retAddr); @@ -2188,7 +2106,7 @@ void Global::sinit(Class_base* c) { - c->setSuper(Class<ASObject>::getRef()); + c->setSuper(Class<ASObject>::getRef(c->getSystemState())); } _NR<ASObject> Global::getVariableByMultinameOpportunistic(const multiname& name) @@ -2215,14 +2133,14 @@ void Global::registerBuiltin(const char* name, const char* ns, _R<ASObject> o) { o->incRef(); - setVariableByQName(name,nsNameAndKind(ns,NAMESPACE),o.getPtr(),DECLARED_TRAIT); + setVariableByQName(name,nsNameAndKind(getSystemState(),ns,NAMESPACE),o.getPtr(),DECLARED_TRAIT); //setVariableByQName(name,nsNameAndKind(ns,PACKAGE_NAMESPACE),o.getPtr(),DECLARED_TRAIT); } ASFUNCTIONBODY(lightspark,eval) { // eval is not allowed in AS3, but an exception should be thrown - throw Class<EvalError>::getInstanceS("EvalError"); + throw Class<EvalError>::getInstanceS(getSys(),"EvalError"); } ASFUNCTIONBODY(lightspark,parseInt) @@ -2232,19 +2150,19 @@ ARG_UNPACK (str, "") (radix, 0); if(radix != 0 && (radix < 2 || radix > 36)) - return abstract_d(numeric_limits<double>::quiet_NaN()); + return abstract_d(obj->getSystemState(),numeric_limits<double>::quiet_NaN()); const char* cur=str.raw_buf(); int64_t ret; bool valid=Integer::fromStringFlashCompatible(cur,ret,radix); if(valid==false) - return abstract_d(numeric_limits<double>::quiet_NaN()); + return abstract_d(obj->getSystemState(),numeric_limits<double>::quiet_NaN()); if(ret==INT64_MAX) - return abstract_d(numeric_limits<double>::infinity()); + return abstract_d(obj->getSystemState(),numeric_limits<double>::infinity()); if(ret==INT64_MIN) - return abstract_d(-numeric_limits<double>::infinity()); - return abstract_d(ret); + return abstract_d(obj->getSystemState(),-numeric_limits<double>::infinity()); + return abstract_d(obj->getSystemState(),ret); } ASFUNCTIONBODY(lightspark,parseFloat) @@ -2264,61 +2182,61 @@ double d=strtod(p, &end); if (end==p) - return abstract_d(numeric_limits<double>::quiet_NaN()); + return abstract_d(obj->getSystemState(),numeric_limits<double>::quiet_NaN()); - return abstract_d(d); + return abstract_d(obj->getSystemState(),d); } ASFUNCTIONBODY(lightspark,isNaN) { if(argslen==0) - return abstract_b(true); + return abstract_b(getSys(),true); else if(args[0]->getObjectType()==T_UNDEFINED) - return abstract_b(true); + return abstract_b(args[0]->getSystemState(),true); else if(args[0]->getObjectType()==T_INTEGER) - return abstract_b(false); + return abstract_b(args[0]->getSystemState(),false); else if(args[0]->getObjectType()==T_BOOLEAN) - return abstract_b(false); + return abstract_b(args[0]->getSystemState(),false); else if(args[0]->getObjectType()==T_NULL) - return abstract_b(false); // because Number(null) == 0 + return abstract_b(args[0]->getSystemState(),false); // because Number(null) == 0 else - return abstract_b(std::isnan(args[0]->toNumber())); + return abstract_b(args[0]->getSystemState(),std::isnan(args[0]->toNumber())); } ASFUNCTIONBODY(lightspark,isFinite) { if(argslen==0) - return abstract_b(false); + return abstract_b(getSys(),false); else - return abstract_b(isfinite(args[0]->toNumber())); + return abstract_b(args[0]->getSystemState(),isfinite(args[0]->toNumber())); } ASFUNCTIONBODY(lightspark,encodeURI) { tiny_string str; ARG_UNPACK (str, "undefined"); - return abstract_s(URLInfo::encode(str, URLInfo::ENCODE_URI)); + return abstract_s(getSys(),URLInfo::encode(str, URLInfo::ENCODE_URI)); } ASFUNCTIONBODY(lightspark,decodeURI) { tiny_string str; ARG_UNPACK (str, "undefined"); - return abstract_s(URLInfo::decode(str, URLInfo::ENCODE_URI)); + return abstract_s(getSys(),URLInfo::decode(str, URLInfo::ENCODE_URI)); } ASFUNCTIONBODY(lightspark,encodeURIComponent) { tiny_string str; ARG_UNPACK (str, "undefined"); - return abstract_s(URLInfo::encode(str, URLInfo::ENCODE_URICOMPONENT)); + return abstract_s(getSys(),URLInfo::encode(str, URLInfo::ENCODE_URICOMPONENT)); } ASFUNCTIONBODY(lightspark,decodeURIComponent) { tiny_string str; ARG_UNPACK (str, "undefined"); - return abstract_s(URLInfo::decode(str, URLInfo::ENCODE_URICOMPONENT)); + return abstract_s(getSys(),URLInfo::decode(str, URLInfo::ENCODE_URICOMPONENT)); } ASFUNCTIONBODY(lightspark,escape) @@ -2326,8 +2244,8 @@ tiny_string str; ARG_UNPACK (str, "undefined"); if (argslen > 0 && args[0]->is<Undefined>()) - return abstract_s("null"); - return abstract_s(URLInfo::encode(str, URLInfo::ENCODE_ESCAPE)); + return abstract_s(getSys(),"null"); + return abstract_s(getSys(),URLInfo::encode(str, URLInfo::ENCODE_ESCAPE)); } ASFUNCTIONBODY(lightspark,unescape) @@ -2335,8 +2253,8 @@ tiny_string str; ARG_UNPACK (str, "undefined"); if (argslen > 0 && args[0]->is<Undefined>()) - return abstract_s("null"); - return abstract_s(URLInfo::decode(str, URLInfo::ENCODE_ESCAPE)); + return abstract_s(getSys(),"null"); + return abstract_s(getSys(),URLInfo::decode(str, URLInfo::ENCODE_ESCAPE)); } ASFUNCTIONBODY(lightspark,print) @@ -2568,9 +2486,9 @@ { assert_and_throw(argslen <= 1); if(argslen==0) - return abstract_b(false); + return abstract_b(getSys(),false); - return abstract_b(isXMLName(args[0])); + return abstract_b(args[0]->getSystemState(),isXMLName(args[0])); } ObjectPrototype::ObjectPrototype(Class_base* c) : ASObject(c) @@ -2586,11 +2504,6 @@ return this->getClass() == r->getClass(); return ASObject::isEqual(r); } -void ObjectPrototype::finalize() -{ - ASObject::finalize(); - prevPrototype.reset(); -} _NR<ASObject> ObjectPrototype::getVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt) { @@ -2604,27 +2517,27 @@ void ObjectPrototype::setVariableByMultiname(const multiname &name, ASObject *o, ASObject::CONST_ALLOWED_FLAG allowConst) { if (this->isSealed && this->hasPropertyByMultiname(name,false,true)) - throwError<ReferenceError>(kCannotAssignToMethodError, name.normalizedNameUnresolved(), ""); + throwError<ReferenceError>(kCannotAssignToMethodError, name.normalizedNameUnresolved(o->getSystemState()), ""); ASObject::setVariableByMultiname(name, o, allowConst); } ObjectConstructor::ObjectConstructor(Class_base* c,uint32_t length) : ASObject(c),_length(length) { - Class<ASObject>::getRef()->prototype->incRef(); - this->prototype = Class<ASObject>::getRef()->prototype.getPtr(); + Class<ASObject>::getRef(c->getSystemState())->prototype->incRef(); + this->prototype = Class<ASObject>::getRef(c->getSystemState())->prototype.getPtr(); } _NR<ASObject> ObjectConstructor::getVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt) { - if (name.normalizedName() == "prototype") + if (name.normalizedName(getSystemState()) == "prototype") { prototype->getObj()->incRef(); return _NR<ASObject>(prototype->getObj()); } - if (name.normalizedName() == "length") + if (name.normalizedName(getSystemState()) == "length") { - return _NR<ASObject>(abstract_d(_length)); + return _NR<ASObject>(abstract_d(getSystemState(),_length)); } return getClass()->getVariableByMultiname(name, opt); } @@ -2637,13 +2550,7 @@ { prevPrototype=p; //Add the prototype to the Nop function - this->prototype = _MR(new_asobject()); -} - -void FunctionPrototype::finalize() -{ - Function::finalize(); - prevPrototype.reset(); + this->prototype = _MR(new_asobject(c->getSystemState())); } _NR<ASObject> FunctionPrototype::getVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt) @@ -2662,12 +2569,6 @@ constructorCallComplete = true; } -void Function_object::finalize() -{ - functionPrototype.reset(); - ASObject::finalize(); -} - _NR<ASObject> Function_object::getVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt) { _NR<ASObject> ret=ASObject::getVariableByMultiname(name, opt); @@ -2687,7 +2588,7 @@ multiname* mname=mi->context->getMultiname(t->name,NULL); std::cerr << "\t in " << *mname << std::endl; assert_and_throw(mname->ns.size()==1 && mname->name_type==multiname::NAME_STRING); - if(mname->name_s_id!=name.normalizedNameId()) + if(mname->name_s_id!=name.normalizedNameId(mi->context->root->getSystemState())) continue; if(find(name.ns.begin(),name.ns.end(),mname->ns[0])==name.ns.end()) continue;
View file
lightspark.tar.xz/src/scripting/toplevel/toplevel.h
Changed
@@ -32,7 +32,6 @@ #include "scripting/toplevel/XML.h" #include "memory_support.h" #include <boost/intrusive/list.hpp> -#include <forward_list> namespace lightspark { @@ -149,7 +148,6 @@ mutable std::vector<Class_base*> interfaces_added; nsNameAndKind protected_ns; void initializeProtectedNamespace(const tiny_string& name, const namespace_info& ns); - void recursiveBuild(ASObject* target); IFunction* constructor; void describeTraits(pugi::xml_node &root, std::vector<traits_info>& traits) const; void describeMetadata(pugi::xml_node &node, const traits_info& trait) const; @@ -158,15 +156,48 @@ Mutex referencedObjectsMutex; boost::intrusive::list<ASObject, boost::intrusive::constant_time_size<false> > referencedObjects; void finalizeObjects(); - std::forward_list<ASObject*> freelist; + std::vector<ASObject*> freelist; + std::vector<ASObject*> freelist2; protected: void copyBorrowedTraitsFromSuper(); ASFUNCTION(_toString); void initStandardProps(); void destroy(); public: - ASObject* getObjectFromFreeList(); - void pushObjectToFreeList(ASObject* obj); + inline ASObject* getObjectFromFreeList() + { + SpinlockLocker l(referencedObjectsMutex); + ASObject* ret = NULL; + if (!freelist.empty()) + { + ret=freelist.back(); + freelist.pop_back(); + ret->incRef(); + } + return ret; + } + inline ASObject* getObjectFromFreeList2() + { + SpinlockLocker l(referencedObjectsMutex); + ASObject* ret = NULL; + if (!freelist2.empty()) + { + ret=freelist2.back(); + freelist2.pop_back(); + ret->incRef(); + } + return ret; + } + + inline void pushObjectToFreeList(ASObject *obj) + { + assert(obj->getRefCount() == 0); + SpinlockLocker l(referencedObjectsMutex); + if (obj->reusableListNumber == 0) + freelist.push_back(obj); + else + freelist2.push_back(obj); + } variables_map borrowedVariables; ASPROPERTY_GETTER(_NR<Prototype>,prototype); ASPROPERTY_GETTER(_NR<ObjectConstructor>,constructorprop); @@ -193,7 +224,7 @@ void addConstructorGetter(); void addPrototypeGetter(); void addLengthGetter(); - void setupDeclaredTraits(ASObject *target); + inline virtual void setupDeclaredTraits(ASObject *target) const { target->traitsInitialized = true; } void handleConstruction(ASObject* target, ASObject* const* args, unsigned int argslen, bool buildAndLink); void setConstructor(IFunction* c); bool hasConstructor() { return constructor != NULL; } @@ -232,7 +263,11 @@ virtual ASObject* coerce(ASObject* o) const; void setSuper(_R<Class_base> super_); - const variable* findBorrowedGettable(const multiname& name, NS_KIND &nskind) const DLL_LOCAL; + inline const variable* findBorrowedGettable(const multiname& name, uint32_t* nsRealId = NULL) const DLL_LOCAL + { + return ASObject::findGettableImpl(getSystemState(), borrowedVariables,name,nsRealId); + } + variable* findBorrowedSettable(const multiname& name, bool* has_getter=NULL) DLL_LOCAL; variable* findSettableInPrototype(const multiname& name) DLL_LOCAL; EARLY_BIND_STATUS resolveMultinameStatically(const multiname& name) const; @@ -262,10 +297,23 @@ { // throw RunTimeException("Class_object::buildInstanceTraits"); } - void finalize(); + void finalize() + { + //Remove the cyclic reference to itself + setClass(NULL); + Class_base::finalize(); + } + public: - static Class_object* getClass(); - static _R<Class_object> getRef(); + static Class_object* getClass(SystemState* sys); + + static _R<Class_object> getRef(SystemState* sys) + { + Class_object* ret = getClass(sys); + ret->incRef(); + return _MR(ret); + } + }; class Prototype @@ -294,10 +342,10 @@ { public: ObjectPrototype(Class_base* c); - void finalize(); + inline void finalize() { prevPrototype.reset(); } void incRef() { ASObject::incRef(); } void decRef() { ASObject::decRef(); } - ASObject* getObj() { return this; } + inline ASObject* getObj() { return this; } _NR<ASObject> getVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt=NONE); void setVariableByMultiname(const multiname& name, ASObject* o, CONST_ALLOWED_FLAG allowConst); bool isEqual(ASObject* r); @@ -327,7 +375,8 @@ public: Function_object(Class_base* c, _R<ASObject> p); _NR<ASObject> functionPrototype; - void finalize(); + void finalize() { functionPrototype.reset(); } + _NR<ASObject> getVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt=NONE); }; @@ -355,7 +404,13 @@ bool isMethod() const { return inClass != NULL; } bool isBound() const { return closure_this; } bool isConstructed() const { return constructIndicator; } - void finalize(); + inline void finalize() + { + closure_this.reset(); + inClass=NULL; + functionname=0; + length=0; + } ASFUNCTION(apply); ASFUNCTION(_call); ASFUNCTION(_toString); @@ -417,7 +472,17 @@ Function(Class_base* c, as_function v=NULL):IFunction(c),val(v){} Function* clone() { - return new (getClass()->memoryAccount) Function(*this); + Function* ret = getClass()->getObjectFromFreeList()->as<Function>(); + if (!ret) + ret=new (getClass()->memoryAccount) Function(*this); + else + { + ret->val = val; + ret->length = length; + ret->inClass = inClass; + ret->functionname = functionname; + } + return ret; } method_info* getMethodInfo() const { return NULL; } public: @@ -432,10 +497,15 @@ { public: FunctionPrototype(Class_base* c, _NR<Prototype> p); - void finalize(); + inline void finalize() + { + Function::finalize(); + prevPrototype.reset(); + } + void incRef() { ASObject::incRef(); } void decRef() { ASObject::decRef(); } - ASObject* getObj() { return this; } + inline ASObject* getObj() { return this; } _NR<ASObject> getVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt=NONE); }; @@ -454,15 +524,38 @@ /* Pointer to JIT-compiled function or NULL if not yet compiled */ synt_function val; SyntheticFunction(Class_base* c,method_info* m); + SyntheticFunction* clone() { - return new (getClass()->memoryAccount) SyntheticFunction(*this); + SyntheticFunction* ret = getClass()->getObjectFromFreeList2()->as<SyntheticFunction>(); + if (!ret) + { + ret=new (getClass()->memoryAccount) SyntheticFunction(*this); + } + else + { + ret->mi = mi; + ret->val = val; + ret->length = length; + ret->inClass = inClass; + ret->func_scope = func_scope; + ret->functionname = functionname; + } + ret->reusableListNumber=1; + return ret; } method_info* getMethodInfo() const { return mi; } public: - ~SyntheticFunction(); + ~SyntheticFunction() {} ASObject* call(ASObject* obj, ASObject* const* args, uint32_t num_args); - void finalize(); + inline void finalize() + { + IFunction::finalize(); + func_scope.clear(); + val = NULL; + mi = NULL; + } + std::vector<scope_entry> func_scope; bool isEqual(ASObject* r) { @@ -495,34 +588,53 @@ ASObject* getInstance(bool construct, ASObject* const* args, const unsigned int argslen, Class_base* realClass); IFunction* getNopFunction(); public: - static Class<IFunction>* getClass(); - static _R<Class<IFunction>> getRef() + static Class<IFunction>* getClass(SystemState* sys); + static _R<Class<IFunction>> getRef(SystemState* sys) { - Class<IFunction>* ret = getClass(); + Class<IFunction>* ret = getClass(sys); ret->incRef(); return _MR(ret); } - static Function* getFunction(Function::as_function v) + static Function* getFunction(SystemState* sys,Function::as_function v) { - Class<IFunction>* c=Class<IFunction>::getClass(); - Function* ret=new (c->memoryAccount) Function(c, v); + Class<IFunction>* c=Class<IFunction>::getClass(sys); + Function* ret = c->getObjectFromFreeList()->as<Function>(); + if (!ret) + ret=new (c->memoryAccount) Function(c, v); + else + ret->val = v; ret->constructIndicator = true; ret->constructorCallComplete = true; return ret; } - static Function* getFunction(Function::as_function v, int len) + static Function* getFunction(SystemState* sys,Function::as_function v, int len) { - Class<IFunction>* c=Class<IFunction>::getClass(); - Function* ret=new (c->memoryAccount) Function(c, v); + Class<IFunction>* c=Class<IFunction>::getClass(sys); + Function* ret = c->getObjectFromFreeList()->as<Function>(); + if (!ret) + ret=new (c->memoryAccount) Function(c, v); + else + ret->val = v; ret->length = len; ret->constructIndicator = true; ret->constructorCallComplete = true; return ret; } - static SyntheticFunction* getSyntheticFunction(method_info* m) + static SyntheticFunction* getSyntheticFunction(SystemState* sys,method_info* m) { - Class<IFunction>* c=Class<IFunction>::getClass(); - SyntheticFunction* ret=new (c->memoryAccount) SyntheticFunction(c, m); + Class<IFunction>* c=Class<IFunction>::getClass(sys); + SyntheticFunction* ret; + ret= c->getObjectFromFreeList2()->as<SyntheticFunction>(); + if (!ret) + { + ret=new (c->memoryAccount) SyntheticFunction(c, m); + } + else + { + ret->mi = m; + ret->reusableListNumber=1; + } + ret->constructIndicator = true; ret->constructorCallComplete = true; c->handleConstruction(ret,NULL,0,true);
View file
lightspark.tar.xz/src/smartrefs.h
Changed
@@ -38,12 +38,12 @@ #ifndef NDEBUG int getRefCount() const { return ref_count; } #endif - void incRef() + inline void incRef() { ATOMIC_INCREMENT(ref_count); assert(ref_count>0); } - void decRef() + inline void decRef() { assert(ref_count>0); uint32_t t=ATOMIC_DECREMENT(ref_count); @@ -52,7 +52,7 @@ destruct(); } } - void fake_decRef() + inline void fake_decRef() { ATOMIC_DECREMENT(ref_count); } @@ -146,11 +146,11 @@ { m->decRef(); } - T* operator->() const + inline T* operator->() const { return m; } - T* getPtr() const + inline T* getPtr() const { return m; }
View file
lightspark.tar.xz/src/swf.cpp
Changed
@@ -143,7 +143,7 @@ RootMovieClip* RootMovieClip::getInstance(_NR<LoaderInfo> li, _R<ApplicationDomain> appDomain, _R<SecurityDomain> secDomain) { - Class_base* movieClipClass = Class<MovieClip>::getClass(); + Class_base* movieClipClass = Class<MovieClip>::getClass(getSys()); RootMovieClip* ret=new (movieClipClass->memoryAccount) RootMovieClip(li, appDomain, secDomain, movieClipClass); ret->constructIndicator = true; ret->constructorCallComplete = true; @@ -216,26 +216,28 @@ stringMemory = allocateMemoryAccount("Tiny_string"); null=_MR(new (unaccountedMemory) Null); + null->setSystemState(this); undefined=_MR(new (unaccountedMemory) Undefined); + undefined->setSystemState(this); builtinClasses = new Class_base*[asClassCount]; memset(builtinClasses,0,asClassCount*sizeof(Class_base*)); //Untangle the messy relationship between class objects and the Class class - Class_object* classObject = Class_object::getClass(); + Class_object* classObject = Class_object::getClass(this); //Getting the Object class object will set the classdef to the Class_object //like any other class. This happens inside Class_base constructor - _R<Class_base> asobjectClass = Class<ASObject>::getRef(); + _R<Class_base> asobjectClass = Class<ASObject>::getRef(this); //The only bit remaining is setting the Object class as the super class for Class classObject->setSuper(asobjectClass); classObject->decRef(); - trueRef=_MR(Class<Boolean>::getInstanceS(true)); - falseRef=_MR(Class<Boolean>::getInstanceS(false)); + trueRef=_MR(Class<Boolean>::getInstanceS(this,true)); + falseRef=_MR(Class<Boolean>::getInstanceS(this,false)); - systemDomain = _MR(Class<ApplicationDomain>::getInstanceS()); - _NR<ApplicationDomain> applicationDomain=_MR(Class<ApplicationDomain>::getInstanceS(systemDomain)); - _NR<SecurityDomain> securityDomain = _MR(Class<SecurityDomain>::getInstanceS()); + systemDomain = _MR(Class<ApplicationDomain>::getInstanceS(this)); + _NR<ApplicationDomain> applicationDomain=_MR(Class<ApplicationDomain>::getInstanceS(this,systemDomain)); + _NR<SecurityDomain> securityDomain = _MR(Class<SecurityDomain>::getInstanceS(this)); threadPool=new ThreadPool(this); timerThread=new TimerThread(this); @@ -245,12 +247,12 @@ intervalManager=new IntervalManager(); securityManager=new SecurityManager(); - _NR<LoaderInfo> loaderInfo=_MR(Class<LoaderInfo>::getInstanceS()); + _NR<LoaderInfo> loaderInfo=_MR(Class<LoaderInfo>::getInstanceS(this)); loaderInfo->applicationDomain = applicationDomain; loaderInfo->setBytesLoaded(0); loaderInfo->setBytesTotal(0); mainClip=RootMovieClip::getInstance(loaderInfo, applicationDomain, securityDomain); - stage=Class<Stage>::getInstanceS(); + stage=Class<Stage>::getInstanceS(this); mainClip->incRef(); stage->_addChildAt(_MR(mainClip),0); //Get starting time @@ -295,7 +297,7 @@ _NR<ASObject> params=getParameters(); if(params.isNull()) - params=_MNR(Class<ASObject>::getInstanceS()); + params=_MNR(Class<ASObject>::getInstanceS(getSys())); //Add arguments to SystemState string vars(v); uint32_t cur=0; @@ -356,7 +358,7 @@ LOG(LOG_ERROR,"Flash parameters has duplicate key '" << varName << "' - ignoring"); else params->setVariableByQName(varName,"", - lightspark::Class<lightspark::ASString>::getInstanceS(varValue),DYNAMIC_TRAIT); + lightspark::Class<lightspark::ASString>::getInstanceS(this,varValue),DYNAMIC_TRAIT); } cur=n2+1; } @@ -371,14 +373,14 @@ LOG(LOG_ERROR,_("Parameters file not found")); return; } - _R<ASObject> ret=_MR(Class<ASObject>::getInstanceS()); + _R<ASObject> ret=_MR(Class<ASObject>::getInstanceS(this)); while(!i.eof()) { string name,value; getline(i,name); getline(i,value); - ret->setVariableByQName(name,"",Class<ASString>::getInstanceS(value),DYNAMIC_TRAIT); + ret->setVariableByQName(name,"",abstract_s(this,value),DYNAMIC_TRAIT); cout << name << ' ' << value << endl; } setParameters(ret); @@ -389,7 +391,7 @@ { _NR<ASObject> params=getParameters(); if(params.isNull()) - params=_MNR(Class<ASObject>::getInstanceS()); + params=_MNR(Class<ASObject>::getInstanceS(this)); parseParametersFromURLIntoObject(url, params); setParameters(params); @@ -405,7 +407,7 @@ LOG(LOG_ERROR,"URL query parameters has duplicate key '" << it->first << "' - ignoring"); else outParams->setVariableByQName(it->first,"", - lightspark::Class<lightspark::ASString>::getInstanceS(it->second),DYNAMIC_TRAIT); + lightspark::Class<lightspark::ASString>::getInstanceS(outParams->getSystemState(),it->second),DYNAMIC_TRAIT); } } @@ -1334,7 +1336,7 @@ { _NR<LoaderInfo> li=loader->getContentLoaderInfo(); li->incRef(); - getVm()->addEvent(li,_MR(Class<SecurityErrorEvent>::getInstanceS( + getVm(loader->getSystemState())->addEvent(li,_MR(Class<SecurityErrorEvent>::getInstanceS(loader->getSystemState(), "Cannot import a SWF file when LoaderContext.allowCodeImport is false."))); // 3226 return; } @@ -1370,7 +1372,7 @@ { LOG(LOG_INFO,"SWF version " << root->version << " is not handled by lightspark, falling back to gnash (if available)"); //Enable flash fallback - getSys()->needsAVM2(false); + root->getSystemState()->needsAVM2(false); return; /* no more parsing necessary, handled by fallback */ } @@ -1523,7 +1525,7 @@ _NR<LoaderInfo> li; li=loader->getContentLoaderInfo(); - _NR<Bitmap> tmp=_MNR(Class<Bitmap>::getInstanceS(li, &f, fileType)); + _NR<Bitmap> tmp=_MNR(Class<Bitmap>::getInstanceS(loader->getSystemState(),li, &f, fileType)); { SpinlockLocker l(objectSpinlock); parsedObject=tmp; @@ -1740,10 +1742,10 @@ Locker l(mutexFrameListeners); if(!frameListeners.empty()) { - _R<Event> e(Class<Event>::getInstanceS("enterFrame")); + _R<Event> e(Class<Event>::getInstanceS(this,"enterFrame")); auto it=frameListeners.begin(); for(;it!=frameListeners.end();it++) - getVm()->addEvent(*it,e); + getVm(this)->addEvent(*it,e); } } @@ -1758,10 +1760,10 @@ Locker l(mutexFrameListeners); if(!frameListeners.empty()) { - _R<Event> e(Class<Event>::getInstanceS("frameConstructed")); + _R<Event> e(Class<Event>::getInstanceS(this,"frameConstructed")); auto it=frameListeners.begin(); for(;it!=frameListeners.end();it++) - getVm()->addEvent(*it,e); + getVm(this)->addEvent(*it,e); } } /* Step 6: dispatch exitFrame event */ @@ -1769,10 +1771,10 @@ Locker l(mutexFrameListeners); if(!frameListeners.empty()) { - _R<Event> e(Class<Event>::getInstanceS("exitFrame")); + _R<Event> e(Class<Event>::getInstanceS(this,"exitFrame")); auto it=frameListeners.begin(); for(;it!=frameListeners.end();it++) - getVm()->addEvent(*it,e); + getVm(this)->addEvent(*it,e); } } /* TODO: Step 7: dispatch render event (Assuming stage.invalidate() has been called) */ @@ -1787,15 +1789,15 @@ { } -void SystemState::resizeCompleted() const +void SystemState::resizeCompleted() { if(currentVm && scaleMode==NO_SCALE) { stage->incRef(); - currentVm->addEvent(_MR(stage),_MR(Class<Event>::getInstanceS("resize",false))); + currentVm->addEvent(_MR(stage),_MR(Class<Event>::getInstanceS(this,"resize",false))); stage->incRef(); - currentVm->addEvent(_MR(stage),_MR(Class<StageVideoAvailabilityEvent>::getInstanceS())); + currentVm->addEvent(_MR(stage),_MR(Class<StageVideoAvailabilityEvent>::getInstanceS(this))); } } @@ -1996,7 +1998,7 @@ if(getFramesLoaded() == 0) return; - ABCVm *vm = getVm(); + ABCVm *vm = getVm(getSystemState()); auto it=classesToBeBound.begin(); for(;it!=classesToBeBound.end();++it) vm->buildClassAndBindTag(it->first.raw_buf(), it->second); @@ -2074,14 +2076,14 @@ nm = tag->bindingclassname; ns = ""; } - clsname.name_s_id=getSys()->getUniqueStringId(nm); - clsname.ns.push_back(nsNameAndKind(ns,NAMESPACE)); + clsname.name_s_id=getSystemState()->getUniqueStringId(nm); + clsname.ns.push_back(nsNameAndKind(getSystemState(),ns,NAMESPACE)); ASObject* typeObject = NULL; auto i = applicationDomain->classesBeingDefined.cbegin(); while (i != applicationDomain->classesBeingDefined.cend()) { - if(i->first->qualifiedString() == clsname.qualifiedString()) + if(i->first->name_s_id == clsname.name_s_id && i->first->ns[0].nsRealId == clsname.ns[0].nsRealId) { typeObject = i->second; break;
View file
lightspark.tar.xz/src/swf.h
Changed
@@ -402,7 +402,7 @@ void flushInvalidationQueue(); //Resize support - void resizeCompleted() const; + void resizeCompleted(); /* * Support for class aliases in AMF3 serialization
View file
lightspark.tar.xz/src/swftypes.cpp
Changed
@@ -37,16 +37,12 @@ using namespace std; using namespace lightspark; -multiname::multiname(MemoryAccount* m):name_o(NULL),ns(reporter_allocator<nsNameAndKind>(m)),name_type(NAME_OBJECT),isAttribute(false) -{ -} - -tiny_string multiname::qualifiedString() const +const tiny_string multiname::qualifiedString(SystemState* sys) const { assert_and_throw(ns.size()>=1); assert_and_throw(name_type==NAME_STRING); - const tiny_string nsName=ns[0].getImpl().name; - const tiny_string& name=getSys()->getStringFromUniqueId(name_s_id); + const tiny_string nsName=ns[0].getImpl(sys).name; + const tiny_string& name=sys->getStringFromUniqueId(name_s_id); if(nsName.empty()) return name; else @@ -58,7 +54,7 @@ } } -tiny_string multiname::normalizedName() const +const tiny_string multiname::normalizedName(SystemState* sys) const { switch(name_type) { @@ -67,7 +63,7 @@ case multiname::NAME_NUMBER: return Number::toString(name_d); case multiname::NAME_STRING: - return getSys()->getStringFromUniqueId(name_s_id); + return sys->getStringFromUniqueId(name_s_id); case multiname::NAME_OBJECT: return name_o ? name_o->toString() : "*"; default: @@ -77,7 +73,7 @@ } } -uint32_t multiname::normalizedNameId() const +uint32_t multiname::normalizedNameId(SystemState* sys) const { switch(name_type) { @@ -86,7 +82,7 @@ case multiname::NAME_INT: case multiname::NAME_NUMBER: case multiname::NAME_OBJECT: - return getSys()->getUniqueStringId(normalizedName()); + return sys->getUniqueStringId(normalizedName(sys)); default: assert("Unexpected name kind" && false); //Should never reach this @@ -94,7 +90,7 @@ } } -tiny_string multiname::normalizedNameUnresolved() const +const tiny_string multiname::normalizedNameUnresolved(SystemState* sys) const { switch(name_type) { @@ -103,7 +99,7 @@ case multiname::NAME_NUMBER: return Number::toString(name_d); case multiname::NAME_STRING: - return getSys()->getStringFromUniqueId(name_s_id); + return sys->getStringFromUniqueId(name_s_id); case multiname::NAME_OBJECT: return name_o ? name_o->getClassName() : "*"; default: @@ -120,38 +116,39 @@ name_o = NULL; } - if(n->is<Integer>()) + switch(n->getObjectType()) { + case T_INTEGER: name_i=n->as<Integer>()->val; name_type = NAME_INT; - } - else if(n->is<UInteger>()) - { + break; + case T_UINTEGER: name_i=n->as<UInteger>()->val; name_type = NAME_INT; - } - else if(n->is<Number>()) - { + break; + case T_NUMBER: name_d=n->as<Number>()->val; name_type = NAME_NUMBER; - } - else if(n->getObjectType()==T_QNAME) - { - ASQName* qname=static_cast<ASQName*>(n); - name_s_id=getSys()->getUniqueStringId(qname->local_name); - name_type = NAME_STRING; - } - else if(n->getObjectType()==T_STRING) - { - ASString* o=static_cast<ASString*>(n); - name_s_id=getSys()->getUniqueStringId(o->data); - name_type = NAME_STRING; - } - else - { + break; + case T_QNAME: + { + ASQName* qname=static_cast<ASQName*>(n); + name_s_id=n->getSystemState()->getUniqueStringId(qname->local_name); + name_type = NAME_STRING; + } + break; + case T_STRING: + { + ASString* o=static_cast<ASString*>(n); + name_s_id=n->getSystemState()->getUniqueStringId(o->data); + name_type = NAME_STRING; + } + break; + default: n->incRef(); name_o=n; name_type = NAME_OBJECT; + break; } } @@ -164,7 +161,7 @@ } } -bool multiname::toUInt(uint32_t& index, bool acceptStringFractions) const +bool multiname::toUInt(SystemState* sys,uint32_t& index, bool acceptStringFractions) const { switch(name_type) { @@ -174,7 +171,7 @@ { tiny_string str; if(name_type==multiname::NAME_STRING) - str=getSys()->getStringFromUniqueId(name_s_id); + str=sys->getStringFromUniqueId(name_s_id); else str=name_o->toString(); @@ -247,7 +244,7 @@ std::ostream& lightspark::operator<<(std::ostream& s, const nsNameAndKind& r) { const char* prefix; - switch(r.getImpl().kind) + switch(r.getImpl(getSys()).kind) { case NAMESPACE: prefix="ns:"; @@ -276,7 +273,7 @@ prefix=""; break; } - s << prefix << r.getImpl().name; + s << prefix << r.getImpl(getSys()).name; return s; } @@ -1343,45 +1340,45 @@ } return s; } -ASString* lightspark::abstract_s() +ASString* lightspark::abstract_s(SystemState *sys) { - return Class<ASString>::getInstanceSNoArgs(); + return Class<ASString>::getInstanceSNoArgs(sys); } -ASString* lightspark::abstract_s(const char* s, uint32_t len) +ASString* lightspark::abstract_s(SystemState *sys, const char* s, uint32_t len) { - ASString* ret= Class<ASString>::getInstanceSNoArgs(); + ASString* ret= Class<ASString>::getInstanceSNoArgs(sys); ret->data = std::string(s,len); return ret; } -ASString* lightspark::abstract_s(const char* s) +ASString* lightspark::abstract_s(SystemState *sys, const char* s) { - ASString* ret= Class<ASString>::getInstanceSNoArgs(); + ASString* ret= Class<ASString>::getInstanceSNoArgs(sys); ret->data = s; return ret; } -ASString* lightspark::abstract_s(const tiny_string& s) +ASString* lightspark::abstract_s(SystemState *sys, const tiny_string& s) { - ASString* ret= Class<ASString>::getInstanceSNoArgs(); + ASString* ret= Class<ASString>::getInstanceSNoArgs(sys); ret->data = s; return ret; } -ASObject* lightspark::abstract_d(number_t i) +ASObject* lightspark::abstract_d(SystemState* sys,number_t i) { - Number* ret=Class<Number>::getInstanceSNoArgs(); + Number* ret=Class<Number>::getInstanceSNoArgs(sys); ret->val = i; return ret; } -ASObject* lightspark::abstract_i(int32_t i) +ASObject* lightspark::abstract_i(SystemState *sys, int32_t i) { - Integer* ret=Class<Integer>::getInstanceSNoArgs(); + Integer* ret=Class<Integer>::getInstanceSNoArgs(sys); ret->val = i; return ret; } -ASObject* lightspark::abstract_ui(uint32_t i) +ASObject* lightspark::abstract_ui(SystemState *sys, uint32_t i) { - UInteger* ret=Class<UInteger>::getInstanceSNoArgs(); + UInteger* ret=Class<UInteger>::getInstanceSNoArgs(sys); ret->val = i; return ret; } @@ -1440,7 +1437,7 @@ multiname ret(NULL); ret.name_type = multiname::NAME_STRING; ret.name_s_id = getSys()->getUniqueStringId(name); - ret.ns.emplace_back(ns, NAMESPACE); + ret.ns.emplace_back(getSys(),ns, NAMESPACE); ret.isAttribute = false; return ret; } @@ -1470,27 +1467,27 @@ return *this; } -nsNameAndKind::nsNameAndKind(const tiny_string& _name, NS_KIND _kind) +nsNameAndKind::nsNameAndKind(SystemState* sys,const tiny_string& _name, NS_KIND _kind) { nsNameAndKindImpl tmp(_name, _kind); - getSys()->getUniqueNamespaceId(tmp, nsRealId, nsId); + sys->getUniqueNamespaceId(tmp, nsRealId, nsId); nameIsEmpty=_name.empty(); } -nsNameAndKind::nsNameAndKind(const char* _name, NS_KIND _kind) +nsNameAndKind::nsNameAndKind(SystemState* sys,const char* _name, NS_KIND _kind) { nsNameAndKindImpl tmp(_name, _kind); - getSys()->getUniqueNamespaceId(tmp, nsRealId, nsId); + sys->getUniqueNamespaceId(tmp, nsRealId, nsId); nameIsEmpty=(_name[0]=='\0'); } -nsNameAndKind::nsNameAndKind(const tiny_string& _name, uint32_t _baseId, NS_KIND _kind) +nsNameAndKind::nsNameAndKind(SystemState* sys,const tiny_string& _name, uint32_t _baseId, NS_KIND _kind) { assert(_kind==PROTECTED_NAMESPACE); nsId=_baseId; nsNameAndKindImpl tmp(_name, _kind, nsId); uint32_t tmpId; - getSys()->getUniqueNamespaceId(tmp, nsRealId, tmpId); + sys->getUniqueNamespaceId(tmp, nsRealId, tmpId); assert(tmpId==_baseId); nameIsEmpty=_name.empty(); } @@ -1501,16 +1498,16 @@ const tiny_string& nsName=c->getString(ns.name); nsNameAndKindImpl tmp(nsName, (NS_KIND)(int)ns.kind); //Give an id hint, in case the namespace is created in the map - getSys()->getUniqueNamespaceId(tmp, c->namespaceBaseId+nsContextIndex, nsRealId, nsId); + c->root->getSystemState()->getUniqueNamespaceId(tmp, c->namespaceBaseId+nsContextIndex, nsRealId, nsId); //Special handling for private namespaces, they are always compared by id if(ns.kind==PRIVATE_NAMESPACE) nsId=c->namespaceBaseId+nsContextIndex; nameIsEmpty=nsName.empty(); } -const nsNameAndKindImpl& nsNameAndKind::getImpl() const +const nsNameAndKindImpl& nsNameAndKind::getImpl(SystemState* sys) const { - return getSys()->getNamespaceFromUniqueId(nsRealId); + return sys->getNamespaceFromUniqueId(nsRealId); } nsNameAndKindImpl::nsNameAndKindImpl(const tiny_string& _name, NS_KIND _kind, uint32_t b)
View file
lightspark.tar.xz/src/swftypes.h
Changed
@@ -38,8 +38,6 @@ #include <algorithm> #endif -class memorystream; - namespace lightspark { @@ -81,6 +79,7 @@ typedef double number_t; +class SystemState; class ASObject; class ASString; class ABCContext; @@ -224,11 +223,10 @@ class u32 { friend std::istream& operator>>(std::istream& in, u32& v); -friend memorystream& operator>>(memorystream& in, u32& v); private: uint32_t val; public: - operator uint32_t() const{return val;} + inline operator uint32_t() const{return val;} }; class STRING @@ -315,14 +313,14 @@ uint32_t nsId; uint32_t nsRealId; bool nameIsEmpty; - nsNameAndKind(const tiny_string& _name, NS_KIND _kind); - nsNameAndKind(const char* _name, NS_KIND _kind); + nsNameAndKind(SystemState *sys, const tiny_string& _name, NS_KIND _kind); + nsNameAndKind(SystemState* sys,const char* _name, NS_KIND _kind); nsNameAndKind(ABCContext * c, uint32_t nsContextIndex); /* * Special constructor for protected namespace, which have * different representationId */ - nsNameAndKind(const tiny_string& _name, uint32_t _baseId, NS_KIND _kind); + nsNameAndKind(SystemState* sys,const tiny_string& _name, uint32_t _baseId, NS_KIND _kind); /* * Special version to create the empty bultin namespace */ @@ -342,7 +340,7 @@ { return nsId==r.nsId; } - const nsNameAndKindImpl& getImpl() const; + const nsNameAndKindImpl& getImpl(SystemState *sys) const; bool hasEmptyName() const { return nameIsEmpty; @@ -362,28 +360,31 @@ enum NAME_TYPE {NAME_STRING,NAME_INT,NAME_NUMBER,NAME_OBJECT}; NAME_TYPE name_type; bool isAttribute; - multiname(MemoryAccount* m); + multiname(MemoryAccount* m):name_o(NULL),ns(reporter_allocator<nsNameAndKind>(m)),name_type(NAME_OBJECT),isAttribute(false) + { + } + /* Returns a string name whatever is the name type */ - tiny_string normalizedName() const; + const tiny_string normalizedName(SystemState *sys) const; /* * Return a string id whatever is the name type */ - uint32_t normalizedNameId() const; + uint32_t normalizedNameId(SystemState *sys) const; /* Returns a string name whatever is the name type, but does not resolve NAME_OBJECT names this should be used for exception or debug messages to avoid calling overridden toString property of the object */ - tiny_string normalizedNameUnresolved() const; + const tiny_string normalizedNameUnresolved(SystemState *sys) const; - tiny_string qualifiedString() const; + const tiny_string qualifiedString(SystemState *sys) const; /* sets name_type, name_s/name_d based on the object n */ void setName(ASObject* n); void resetNameIfObject(); bool isQName() const { return ns.size() == 1; } - bool toUInt(uint32_t& out, bool acceptStringFractions=false) const; + bool toUInt(SystemState *sys, uint32_t& out, bool acceptStringFractions=false) const; bool isEmpty() const { return name_type == NAME_OBJECT && name_o == NULL;} }; @@ -1330,13 +1331,13 @@ RunState(); }; -ASObject* abstract_i(int32_t i); -ASObject* abstract_ui(uint32_t i); -ASObject* abstract_d(number_t i); -ASString* abstract_s(); -ASString* abstract_s(const char* s, uint32_t len); -ASString* abstract_s(const char* s); -ASString* abstract_s(const tiny_string& s); +ASObject* abstract_i(SystemState *sys, int32_t i); +ASObject* abstract_ui(SystemState *sys, uint32_t i); +ASObject* abstract_d(SystemState *sys, number_t i); +ASString* abstract_s(SystemState *sys); +ASString* abstract_s(SystemState *sys, const char* s, uint32_t len); +ASString* abstract_s(SystemState *sys, const char* s); +ASString* abstract_s(SystemState *sys, const tiny_string& s); void stringToQName(const tiny_string& tmp, tiny_string& name, tiny_string& ns);
View file
lightspark.tar.xz/src/thread_pool.cpp
Changed
@@ -84,7 +84,7 @@ { setTLSSys(th->m_sys); - ThreadProfile* profile=getSys()->allocateProfiler(RGB(200,200,0)); + ThreadProfile* profile=th->m_sys->allocateProfiler(RGB(200,200,0)); char buf[16]; snprintf(buf,16,"Thread %u",index); profile->setTag(buf); @@ -116,7 +116,7 @@ catch(LightsparkException& e) { LOG(LOG_ERROR,_("Exception in ThreadPool ") << e.what()); - getSys()->setError(e.cause); + th->m_sys->setError(e.cause); } profile->accountTime(chronometer.checkpoint());
View file
lightspark.tar.xz/src/tiny_string.cpp
Changed
@@ -56,24 +56,19 @@ init(); } -tiny_string::tiny_string(const tiny_string& r):_buf_static(),buf(_buf_static),stringSize(r.stringSize),type(STATIC) +tiny_string::tiny_string(const tiny_string& r): + _buf_static(),buf(_buf_static),stringSize(r.stringSize),numchars(r.numchars),type(STATIC),isASCII(r.isASCII),hasNull(r.hasNull) { //Fast path for static read-only strings if(r.type==READONLY) { type=READONLY; buf=r.buf; - this->isASCII = r.isASCII; - this->hasNull = r.hasNull; - this->numchars = r.numchars; return; } if(stringSize > STATIC_SIZE) createBuffer(stringSize); memcpy(buf,r.buf,stringSize); - this->isASCII = r.isASCII; - this->hasNull = r.hasNull; - this->numchars = r.numchars; } tiny_string::tiny_string(const std::string& r):_buf_static(),buf(_buf_static),stringSize(r.size()+1),type(STATIC) @@ -316,14 +311,6 @@ return stringSize == 1; } -void tiny_string::clear() -{ - resetToStatic(); - numchars = 0; - isASCII = true; - hasNull = false; -} - /* returns the length in bytes, not counting the trailing \0 */ uint32_t tiny_string::numBytes() const {
View file
lightspark.tar.xz/src/tiny_string.h
Changed
@@ -151,7 +151,14 @@ bool operator!=(const Glib::ustring&) const; const char* raw_buf() const; bool empty() const; - void clear(); + inline void clear() + { + resetToStatic(); + numchars = 0; + isASCII = true; + hasNull = false; + } + /* returns the length in bytes, not counting the trailing \0 */ uint32_t numBytes() const; /* returns the length in utf-8 characters, not counting the trailing \0 */
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.