Projects
Essentials
lightspark
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 100
View file
lightspark.spec
Changed
@@ -20,7 +20,7 @@ %bcond_without librtmp Name: lightspark -Version: 0.7.2.99+git20160306.1920 +Version: 0.7.2.99+git20160311.1829 Release: 0 Summary: Modern, free, open-source flash player implementation License: LGPL-3.0+
View file
lightspark.tar.xz/src/asobject.cpp
Changed
@@ -1787,7 +1787,7 @@ // TODO: undocumented constructor node //LOG(LOG_INFO,"describeType:"<< Class<XML>::getInstanceS(root)->toXMLString_internal()); - return Class<XML>::getInstanceS(root); + return XML::createFromNode(root); } tiny_string ASObject::toJSON(std::vector<ASObject *> &path, IFunction *replacer, const tiny_string &spaces,const tiny_string& filter)
View file
lightspark.tar.xz/src/backends/input.cpp
Changed
@@ -303,7 +303,9 @@ if(m_sys->currentVm == NULL) return; - m_sys->currentVm->addEvent(m_sys->mainClip->getStage(), + _NR<Stage> stage = m_sys->mainClip->getStage(); + stage->incRef(); + m_sys->currentVm->addEvent(stage, _MR(Class<Event>::getInstanceS("mouseLeave"))); } @@ -414,6 +416,7 @@ if (keyevent->is_modifier) charcode = 0; + target->incRef(); m_sys->currentVm->addEvent(target, _MR(Class<KeyboardEvent>::getInstanceS(type, charcode, keyevent->hardware_keycode, keyevent->state))); }
View file
lightspark.tar.xz/src/backends/netutils.cpp
Changed
@@ -827,6 +827,7 @@ return false; if(evaluationResult == SecurityManager::NA_CROSSDOMAIN_POLICY) { + dispatcher->incRef(); getVm()->addEvent(dispatcher,_MR(Class<SecurityErrorEvent>::getInstanceS("SecurityError: " "connection to domain not allowed by securityManager"))); return false;
View file
lightspark.tar.xz/src/parsing/amf3_generator.cpp
Changed
@@ -476,7 +476,7 @@ if(legacyXML) xmlObj=Class<XMLDocument>::getInstanceS(xmlStr); else - xmlObj=Class<XML>::getInstanceS(xmlStr); + xmlObj=XML::createFromString(xmlStr); objMap.push_back(xmlObj); return _MR(xmlObj); }
View file
lightspark.tar.xz/src/scripting/abc_opcodes.cpp
Changed
@@ -2621,8 +2621,6 @@ if(!th->mi->hasDXNS()) throw Class<VerifyError>::getInstanceS("dxns without SET_DXNS"); - if (!th->defaultNamespaceUri.isNull()) - th->defaultNamespaceUri->decRef(); th->defaultNamespaceUri = _NR<ASString>(abstract_s(th->context->getString(n))); } @@ -2632,8 +2630,6 @@ if(!th->mi->hasDXNS()) throw Class<VerifyError>::getInstanceS("dxnslate without SET_DXNS"); - if (!th->defaultNamespaceUri.isNull()) - th->defaultNamespaceUri->decRef(); th->defaultNamespaceUri = _NR<ASString>(abstract_s(o->toString())); o->decRef(); }
View file
lightspark.tar.xz/src/scripting/flash/display/DisplayObject.h
Changed
@@ -117,8 +117,8 @@ throw RunTimeException("DisplayObject::hitTestImpl: Derived class must implement this!"); } - void constructionComplete(); public: + void constructionComplete(); tiny_string name; _NR<DisplayObject> invalidateQueueNext; _NR<LoaderInfo> loaderInfo;
View file
lightspark.tar.xz/src/scripting/flash/display/flashdisplay.cpp
Changed
@@ -57,6 +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()); LOG(LOG_NOT_IMPLEMENTED,"LoaderInfo: childAllowsParent and parentAllowsChild always return true"); } @@ -66,12 +69,16 @@ 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()); LOG(LOG_NOT_IMPLEMENTED,"LoaderInfo: childAllowsParent and parentAllowsChild always return true"); } void LoaderInfo::sinit(Class_base* c) { 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); @@ -115,6 +122,18 @@ securityDomain.reset(); waitedObject.reset(); bytesData.reset(); + contentType = "application/x-shockwave-flash"; + bytesLoaded = 0; + bytesTotal = 0; + loadStatus =STARTED; + actionScriptVersion = 3; + swfVersion = 0; + childAllowsParent = true; + uncaughtErrorEvents.reset(); + parentAllowsChild =true; + frameRate =0; + parameters.reset(); + uncaughtErrorEvents.reset(); } void LoaderInfo::resetState() @@ -204,16 +223,13 @@ { LoaderInfo* th=static_cast<LoaderInfo*>(obj); EventDispatcher::_constructor(obj,NULL,0); - th->sharedEvents=_MR(Class<EventDispatcher>::getInstanceS()); - th->parameters = _MR(Class<ASObject>::getInstanceS()); - th->uncaughtErrorEvents = _MR(Class<UncaughtErrorEvents>::getInstanceS()); return NULL; } ASFUNCTIONBODY(LoaderInfo,_getLoaderURL) { LoaderInfo* th=static_cast<LoaderInfo*>(obj); - return Class<ASString>::getInstanceS(th->loaderURL); + return abstract_s(th->loaderURL); } ASFUNCTIONBODY(LoaderInfo,_getContent) @@ -248,7 +264,7 @@ ASFUNCTIONBODY(LoaderInfo,_getURL) { LoaderInfo* th=static_cast<LoaderInfo*>(obj); - return Class<ASString>::getInstanceS(th->url); + return abstract_s(th->url); } ASFUNCTIONBODY(LoaderInfo,_getBytesLoaded) @@ -681,11 +697,14 @@ graphics.reset(); hitArea.reset(); hitTarget.reset(); + buttonMode = false; + useHandCursor = false; } void Sprite::sinit(Class_base* c) { 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); @@ -961,7 +980,7 @@ ASFUNCTIONBODY(FrameLabel,_getName) { FrameLabel* th=static_cast<FrameLabel*>(obj); - return Class<ASString>::getInstanceS(th->name); + return abstract_s(th->name); } /* @@ -1021,7 +1040,7 @@ ASFUNCTIONBODY(Scene,_getName) { Scene* th=static_cast<Scene*>(obj); - return Class<ASString>::getInstanceS(th->name); + return abstract_s(th->name); } ASFUNCTIONBODY(Scene,_getNumFrames) @@ -1083,6 +1102,7 @@ void MovieClip::sinit(Class_base* c) { 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); @@ -1122,6 +1142,9 @@ Sprite::finalize(); frames.clear(); frameScripts.clear(); + fromDefineSpriteTag = false; + totalFrames_unreliable = 1; + enabled = true; } /* Returns a Scene_data pointer for a scene called sceneName, or for @@ -1382,7 +1405,7 @@ { for(size_t j=0;j<th->scenes[i].labels.size();++j) if(th->scenes[i].labels[j].frame == th->state.FP) - return Class<ASString>::getInstanceS(th->scenes[i].labels[j].name); + return abstract_s(th->scenes[i].labels[j].name); } return getSys()->getNullRef(); } @@ -1407,7 +1430,7 @@ if(label.empty()) return getSys()->getNullRef(); else - return Class<ASString>::getInstanceS(label); + return abstract_s(label); } ASFUNCTIONBODY(MovieClip,_getCurrentLabels) @@ -1451,6 +1474,7 @@ void DisplayObjectContainer::sinit(Class_base* c) { 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); @@ -1498,7 +1522,7 @@ multiname objName(NULL); objName.name_type=multiname::NAME_STRING; objName.name_s_id=getSys()->getUniqueStringId(obj->name); - objName.ns.push_back(nsNameAndKind("",NAMESPACE)); + objName.ns.emplace_back("",NAMESPACE); setVariableByMultiname(objName,getSys()->getNullRef(), ASObject::CONST_NOT_ALLOWED); } @@ -1522,7 +1546,7 @@ multiname objName(NULL); objName.name_type=multiname::NAME_STRING; objName.name_s_id=getSys()->getUniqueStringId(obj->name); - objName.ns.push_back(nsNameAndKind("",NAMESPACE)); + objName.ns.emplace_back("",NAMESPACE); setVariableByMultiname(objName,obj,ASObject::CONST_NOT_ALLOWED); } @@ -1554,6 +1578,8 @@ InteractiveObject::finalize(); //Release every child dynamicDisplayList.clear(); + mouseChildren = true; + tabChildren = true; } InteractiveObject::InteractiveObject(Class_base* c):DisplayObject(c),mouseEnabled(true),doubleClickEnabled(false),accessibilityImplementation(NullRef),contextMenu(NullRef),tabEnabled(false),tabIndex(-1) @@ -1609,6 +1635,11 @@ { DisplayObject::finalize(); contextMenu.reset(); + mouseEnabled = true; + doubleClickEnabled =false; + accessibilityImplementation.reset(); + tabEnabled = false; + tabIndex = -1; } void InteractiveObject::buildTraits(ASObject* o) @@ -1618,6 +1649,7 @@ void InteractiveObject::sinit(Class_base* c) { 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); @@ -2283,13 +2315,13 @@ switch(getSys()->scaleMode) { case SystemState::EXACT_FIT: - return Class<ASString>::getInstanceS("exactFit"); + return abstract_s("exactFit"); case SystemState::SHOW_ALL: - return Class<ASString>::getInstanceS("showAll"); + return abstract_s("showAll"); case SystemState::NO_BORDER: - return Class<ASString>::getInstanceS("noBorder"); + return abstract_s("noBorder"); case SystemState::NO_SCALE: - return Class<ASString>::getInstanceS("noScale"); + return abstract_s("noScale"); } return NULL; } @@ -2445,40 +2477,40 @@ void StageScaleMode::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("EXACT_FIT","",Class<ASString>::getInstanceS("exactFit"),CONSTANT_TRAIT); - c->setVariableByQName("NO_BORDER","",Class<ASString>::getInstanceS("noBorder"),CONSTANT_TRAIT); - c->setVariableByQName("NO_SCALE","",Class<ASString>::getInstanceS("noScale"),CONSTANT_TRAIT); - c->setVariableByQName("SHOW_ALL","",Class<ASString>::getInstanceS("showAll"),CONSTANT_TRAIT); + 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); } void StageAlign::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("BOTTOM","",Class<ASString>::getInstanceS("B"),CONSTANT_TRAIT); - c->setVariableByQName("BOTTOM_LEFT","",Class<ASString>::getInstanceS("BL"),CONSTANT_TRAIT); - c->setVariableByQName("BOTTOM_RIGHT","",Class<ASString>::getInstanceS("BR"),CONSTANT_TRAIT); - c->setVariableByQName("LEFT","",Class<ASString>::getInstanceS("L"),CONSTANT_TRAIT); - c->setVariableByQName("RIGHT","",Class<ASString>::getInstanceS("R"),CONSTANT_TRAIT); - c->setVariableByQName("TOP","",Class<ASString>::getInstanceS("T"),CONSTANT_TRAIT); - c->setVariableByQName("TOP_LEFT","",Class<ASString>::getInstanceS("TL"),CONSTANT_TRAIT); - c->setVariableByQName("TOP_RIGHT","",Class<ASString>::getInstanceS("TR"),CONSTANT_TRAIT); + 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); } void StageQuality::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("BEST","",Class<ASString>::getInstanceS("best"),CONSTANT_TRAIT); - c->setVariableByQName("HIGH","",Class<ASString>::getInstanceS("high"),CONSTANT_TRAIT); - c->setVariableByQName("LOW","",Class<ASString>::getInstanceS("low"),CONSTANT_TRAIT); - c->setVariableByQName("MEDIUM","",Class<ASString>::getInstanceS("medium"),CONSTANT_TRAIT); + 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); } void StageDisplayState::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("FULL_SCREEN","",Class<ASString>::getInstanceS("fullScreen"),CONSTANT_TRAIT); - c->setVariableByQName("FULL_SCREEN_INTERACTIVE","",Class<ASString>::getInstanceS("fullScreenInteractive"),CONSTANT_TRAIT); - c->setVariableByQName("NORMAL","",Class<ASString>::getInstanceS("normal"),CONSTANT_TRAIT); + 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); } Bitmap::Bitmap(Class_base* c, _NR<LoaderInfo> li, std::istream *s, FILE_TYPE type): @@ -2534,7 +2566,6 @@ Bitmap::~Bitmap() { - finalize(); } void Bitmap::finalize() @@ -2542,12 +2573,14 @@ if(!bitmapData.isNull()) bitmapData->removeUser(this); bitmapData.reset(); + smoothing = false; DisplayObject::finalize(); } void Bitmap::sinit(Class_base* c) { CLASS_SETUP(c, DisplayObject, _constructor, CLASS_SEALED); + c->isReusable = true; REGISTER_GETTER_SETTER(c,bitmapData); REGISTER_GETTER_SETTER(c,smoothing); REGISTER_GETTER_SETTER(c,pixelSnapping); @@ -2898,42 +2931,42 @@ void GradientType::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("LINEAR","",Class<ASString>::getInstanceS("linear"),CONSTANT_TRAIT); - c->setVariableByQName("RADIAL","",Class<ASString>::getInstanceS("radial"),CONSTANT_TRAIT); + c->setVariableByQName("LINEAR","",abstract_s("linear"),CONSTANT_TRAIT); + c->setVariableByQName("RADIAL","",abstract_s("radial"),CONSTANT_TRAIT); } void BlendMode::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("ADD","",Class<ASString>::getInstanceS("add"),CONSTANT_TRAIT); - c->setVariableByQName("ALPHA","",Class<ASString>::getInstanceS("alpha"),CONSTANT_TRAIT); - c->setVariableByQName("DARKEN","",Class<ASString>::getInstanceS("darken"),CONSTANT_TRAIT); - c->setVariableByQName("DIFFERENCE","",Class<ASString>::getInstanceS("difference"),CONSTANT_TRAIT); - c->setVariableByQName("ERASE","",Class<ASString>::getInstanceS("erase"),CONSTANT_TRAIT); - c->setVariableByQName("HARDLIGHT","",Class<ASString>::getInstanceS("hardlight"),CONSTANT_TRAIT); - c->setVariableByQName("INVERT","",Class<ASString>::getInstanceS("invert"),CONSTANT_TRAIT); - c->setVariableByQName("LAYER","",Class<ASString>::getInstanceS("layer"),CONSTANT_TRAIT); - c->setVariableByQName("LIGHTEN","",Class<ASString>::getInstanceS("lighten"),CONSTANT_TRAIT); - c->setVariableByQName("MULTIPLY","",Class<ASString>::getInstanceS("multiply"),CONSTANT_TRAIT); - c->setVariableByQName("NORMAL","",Class<ASString>::getInstanceS("normal"),CONSTANT_TRAIT); - c->setVariableByQName("OVERLAY","",Class<ASString>::getInstanceS("overlay"),CONSTANT_TRAIT); - c->setVariableByQName("SCREEN","",Class<ASString>::getInstanceS("screen"),CONSTANT_TRAIT); - c->setVariableByQName("SUBTRACT","",Class<ASString>::getInstanceS("subtract"),CONSTANT_TRAIT); + 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); } void SpreadMethod::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("PAD","",Class<ASString>::getInstanceS("pad"),CONSTANT_TRAIT); - c->setVariableByQName("REFLECT","",Class<ASString>::getInstanceS("reflect"),CONSTANT_TRAIT); - c->setVariableByQName("REPEAT","",Class<ASString>::getInstanceS("repeat"),CONSTANT_TRAIT); + c->setVariableByQName("PAD","",abstract_s("pad"),CONSTANT_TRAIT); + c->setVariableByQName("REFLECT","",abstract_s("reflect"),CONSTANT_TRAIT); + c->setVariableByQName("REPEAT","",abstract_s("repeat"),CONSTANT_TRAIT); } void InterpolationMethod::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("RGB","",Class<ASString>::getInstanceS("rgb"),CONSTANT_TRAIT); - c->setVariableByQName("LINEAR_RGB","",Class<ASString>::getInstanceS("linearRGB"),CONSTANT_TRAIT); + c->setVariableByQName("RGB","",abstract_s("rgb"),CONSTANT_TRAIT); + c->setVariableByQName("LINEAR_RGB","",abstract_s("linearRGB"),CONSTANT_TRAIT); } void GraphicsPathCommand::sinit(Class_base* c) @@ -2951,16 +2984,16 @@ void GraphicsPathWinding::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("EVEN_ODD","",Class<ASString>::getInstanceS("evenOdd"),CONSTANT_TRAIT); - c->setVariableByQName("NON_ZERO","",Class<ASString>::getInstanceS("nonZero"),CONSTANT_TRAIT); + c->setVariableByQName("EVEN_ODD","",abstract_s("evenOdd"),CONSTANT_TRAIT); + c->setVariableByQName("NON_ZERO","",abstract_s("nonZero"),CONSTANT_TRAIT); } void PixelSnapping::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("ALWAYS","",Class<ASString>::getInstanceS("always"),CONSTANT_TRAIT); - c->setVariableByQName("AUTO","",Class<ASString>::getInstanceS("auto"),CONSTANT_TRAIT); - c->setVariableByQName("NEVER","",Class<ASString>::getInstanceS("never"),CONSTANT_TRAIT); + c->setVariableByQName("ALWAYS","",abstract_s("always"),CONSTANT_TRAIT); + c->setVariableByQName("AUTO","",abstract_s("auto"),CONSTANT_TRAIT); + c->setVariableByQName("NEVER","",abstract_s("never"),CONSTANT_TRAIT); } @@ -3168,8 +3201,8 @@ void LineScaleMode::sinit(Class_base* c) { CLASS_SETUP_NO_CONSTRUCTOR(c, ASObject, CLASS_SEALED | CLASS_FINAL); - c->setVariableByQName("HORIZONTAL","",Class<ASString>::getInstanceS("horizontal"),CONSTANT_TRAIT); - c->setVariableByQName("NONE","",Class<ASString>::getInstanceS("none"),CONSTANT_TRAIT); - c->setVariableByQName("NORMAL","",Class<ASString>::getInstanceS("normal"),CONSTANT_TRAIT); - c->setVariableByQName("VERTICAL","",Class<ASString>::getInstanceS("vertical"),CONSTANT_TRAIT); + 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); }
View file
lightspark.tar.xz/src/scripting/flash/display/flashdisplay.h
Changed
@@ -475,9 +475,9 @@ protected: /* This is read from the SWF header. It's only purpose is for flash.display.MovieClip.totalFrames */ uint32_t totalFrames_unreliable; - void constructionComplete(); ASPROPERTY_GETTER_SETTER(bool, enabled); public: + void constructionComplete(); RunState state; MovieClip(Class_base* c); MovieClip(Class_base* c, const FrameContainer& f, bool defineSpriteTag);
View file
lightspark.tar.xz/src/scripting/flash/net/XMLSocket.cpp
Changed
@@ -167,7 +167,6 @@ XMLSocket::~XMLSocket() { - finalize(); } void XMLSocket::sinit(Class_base* c) @@ -196,6 +195,7 @@ job->threadAbort(); job = NULL; } + timeout = 20000; } ASFUNCTIONBODY_GETTER_SETTER(XMLSocket, timeout); @@ -378,10 +378,12 @@ { if (!sock.connect(hostname, port)) { + owner->incRef(); getVm()->addEvent(owner, _MR(Class<IOErrorEvent>::getInstanceS())); return; } + owner->incRef(); getVm()->addEvent(owner, _MR(Class<Event>::getInstanceS("connect"))); struct timeval timeout; @@ -402,6 +404,7 @@ int status = select(maxfd+1, &readfds, NULL, NULL, &timeout); if (status < 0) { + owner->incRef(); getVm()->addEvent(owner, _MR(Class<IOErrorEvent>::getInstanceS())); return; } @@ -413,6 +416,7 @@ ssize_t nbytes = read(signalListener, &cmd, 1); if (nbytes < 0) { + owner->incRef(); getVm()->addEvent(owner, _MR(Class<IOErrorEvent>::getInstanceS())); return; } @@ -444,17 +448,20 @@ { buf[nbytes] = '\0'; tiny_string data(buf, true); + owner->incRef(); getVm()->addEvent(owner, _MR(Class<DataEvent>::getInstanceS(data))); } else if (nbytes == 0) { // The server has closed the socket + owner->incRef(); getVm()->addEvent(owner, _MR(Class<Event>::getInstanceS("close"))); threadAborting = true; } else { // Error + owner->incRef(); getVm()->addEvent(owner, _MR(Class<IOErrorEvent>::getInstanceS())); threadAborting = true; }
View file
lightspark.tar.xz/src/scripting/toplevel/XML.cpp
Changed
@@ -65,13 +65,27 @@ void XML::finalize() { - ASObject::finalize(); + xmldoc.reset(); + parentNode.reset(); + nodetype =(pugi::xml_node_type)0; + isAttribute = false; + constructed = false; + childrenlist.reset(); + nodename.clear(); + nodevalue.clear(); + nodenamespace_uri.clear(); + nodenamespace_prefix.clear(); + attributelist.reset(); + procinstlist.reset(); + namespacedefs.clear(); + } void XML::sinit(Class_base* c) { CLASS_SETUP(c, ASObject, _constructor, CLASS_FINAL); setDefaultXMLSettings(); + c->isReusable=true; c->setDeclaredMethodByQName("ignoreComments","",Class<IFunction>::getFunction(_getIgnoreComments),GETTER_METHOD,false); c->setDeclaredMethodByQName("ignoreComments","",Class<IFunction>::getFunction(_setIgnoreComments),SETTER_METHOD,false); @@ -139,7 +153,7 @@ args[0]->is<Null>() || args[0]->is<Undefined>()) { - return Class<XML>::getInstanceS(""); + return Class<XML>::getInstanceSNoArgs(); } else if(args[0]->is<ASString>() || args[0]->is<Number>() || @@ -147,7 +161,7 @@ args[0]->is<UInteger>() || args[0]->is<Boolean>()) { - return Class<XML>::getInstanceS(args[0]->toString()); + return createFromString(args[0]->toString()); } else if(args[0]->is<XML>()) { @@ -162,11 +176,11 @@ } else if(args[0]->is<XMLNode>()) { - return Class<XML>::getInstanceS(args[0]->as<XMLNode>()->node); + return createFromNode(args[0]->as<XMLNode>()->node); } else { - return Class<XML>::getInstanceS(args[0]->toString()); + return createFromString(args[0]->toString()); } } @@ -228,7 +242,7 @@ { XML* th=Class<XML>::cast(obj); assert_and_throw(argslen==0); - return Class<ASString>::getInstanceS(th->nodekindString()); + return abstract_s(th->nodekindString()); } const char *XML::nodekindString() { @@ -266,7 +280,7 @@ if(!th->isAttribute && (th->nodetype==pugi::node_pcdata || th->nodetype==pugi::node_comment || th->nodetype==pugi::node_null)) return getSys()->getNullRef(); else - return Class<ASString>::getInstanceS(th->nodename); + return abstract_s(th->nodename); } ASFUNCTIONBODY(XML,name) @@ -288,7 +302,7 @@ { XML* th=Class<XML>::cast(obj); _NR<ASObject> name; - ARG_UNPACK(name,_NR<ASObject>(Class<ASString>::getInstanceS("*"))); + ARG_UNPACK(name,_NR<ASObject>(abstract_s("*"))); XMLVector ret; multiname mname(NULL); name->applyProxyProperty(mname); @@ -318,7 +332,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(Class<XML>::getInstanceS("dummy")); + arg=_MR(createFromString("dummy")); //avoid interpretation of the argument, just set it as text node arg->setTextContent(args[0]->toString()); } @@ -366,13 +380,16 @@ XMLVector tmp; XMLList* res = Class<XMLList>::getInstanceS(tmp,th->getChildrenlist(),multiname(NULL)); - for (XMLList::XMLListVector::const_iterator it = th->attributelist->nodes.begin(); it != th->attributelist->nodes.end(); it++) + if (!th->attributelist.isNull()) { - _R<XML> attr = *it; - if (attr->nodenamespace_uri == tmpns && (attrname== "*" || attr->nodename == attrname)) + for (XMLList::XMLListVector::const_iterator it = th->attributelist->nodes.begin(); it != th->attributelist->nodes.end(); it++) { - attr->incRef(); - res->append(attr); + _R<XML> attr = *it; + if (attr->nodenamespace_uri == tmpns && (attrname== "*" || attr->nodename == attrname)) + { + attr->incRef(); + res->append(attr); + } } } return res; @@ -582,21 +599,24 @@ res += getVm()->getDefaultXMLNamespace(); res += "\""; } - for (XMLList::XMLListVector::const_iterator it = attributelist->nodes.begin(); it != attributelist->nodes.end(); it++) + if (!attributelist.isNull()) { - _R<XML> attr = *it; - res += " "; - if (attr->nodenamespace_prefix != "") + for (XMLList::XMLListVector::const_iterator it = attributelist->nodes.begin(); it != attributelist->nodes.end(); it++) { - res += attr->nodenamespace_prefix; - res += ":"; + _R<XML> attr = *it; + res += " "; + if (attr->nodenamespace_prefix != "") + { + res += attr->nodenamespace_prefix; + res += ":"; + } + res += attr->nodename; + res += "=\""; + res += encodeToXML(attr->nodevalue,true); + res += "\""; } - res += attr->nodename; - res += "=\""; - res += encodeToXML(attr->nodevalue,true); - res += "\""; } - if (childrenlist->nodes.size() == 0) + if (childrenlist.isNull() || childrenlist->nodes.size() == 0) { res += "/>"; break; @@ -604,6 +624,7 @@ res += ">"; tiny_string newindent; bool bindent = (pretty && prettyPrinting && prettyIndent >=0 && + !childrenlist.isNull() && (childrenlist->nodes.size() >1 || (!childrenlist->nodes[0]->procinstlist.isNull()) || (childrenlist->nodes[0]->nodetype != pugi::node_pcdata && childrenlist->nodes[0]->nodetype != pugi::node_cdata))); @@ -615,13 +636,16 @@ newindent += " "; } } - for (uint32_t i = 0; i < childrenlist->nodes.size(); i++) + if (!childrenlist.isNull()) { - _R<XML> child= childrenlist->nodes[i]; - tiny_string tmpres = child->toXMLString_internal(pretty,defaultnsprefix,newindent.raw_buf(),false); - if (bindent && !tmpres.empty()) - res += "\n"; - res += tmpres; + for (uint32_t i = 0; i < childrenlist->nodes.size(); i++) + { + _R<XML> child= childrenlist->nodes[i]; + tiny_string tmpres = child->toXMLString_internal(pretty,defaultnsprefix,newindent.raw_buf(),false); + if (bindent && !tmpres.empty()) + res += "\n"; + res += tmpres; + } } if (bindent) { @@ -664,25 +688,28 @@ XML* th=Class<XML>::cast(obj); assert_and_throw(argslen==0); tiny_string res = th->toXMLString_internal(); - ASString* ret=Class<ASString>::getInstanceS(res); + ASString* ret=abstract_s(res); return ret; } void XML::childrenImpl(XMLVector& ret, const tiny_string& name) { - for (uint32_t i = 0; i < childrenlist->nodes.size(); i++) + if (!childrenlist.isNull()) { - _R<XML> child= childrenlist->nodes[i]; - if(name!="*" && child->nodename != name) - continue; - child->incRef(); - ret.push_back(child); + for (uint32_t i = 0; i < childrenlist->nodes.size(); i++) + { + _R<XML> child= childrenlist->nodes[i]; + if(name!="*" && child->nodename != name) + continue; + child->incRef(); + ret.push_back(child); + } } } void XML::childrenImpl(XMLVector& ret, uint32_t index) { - if (constructed && index < childrenlist->nodes.size()) + if (constructed && !childrenlist.isNull() && index < childrenlist->nodes.size()) { _R<XML> child= childrenlist->nodes[index]; child->incRef(); @@ -700,7 +727,7 @@ multiname mname(NULL); mname.name_s_id=getSys()->getUniqueStringId(arg0); mname.name_type=multiname::NAME_STRING; - mname.ns.push_back(nsNameAndKind("",NAMESPACE)); + mname.ns.emplace_back("",NAMESPACE); mname.isAttribute=false; if(XML::isValidMultiname(mname, index)) th->childrenImpl(ret, index); @@ -719,7 +746,7 @@ multiname mname(NULL); mname.name_s_id=getSys()->getUniqueStringId("*"); mname.name_type=multiname::NAME_STRING; - mname.ns.push_back(nsNameAndKind("",NAMESPACE)); + mname.ns.emplace_back("",NAMESPACE); XMLList* retObj=Class<XMLList>::getInstanceS(ret,th->getChildrenlist(),mname); return retObj; } @@ -727,7 +754,7 @@ ASFUNCTIONBODY(XML,childIndex) { XML* th=Class<XML>::cast(obj); - if (th->parentNode) + if (th->parentNode && !th->parentNode->childrenlist.isNull()) { XML* parent = th->parentNode.getPtr(); for (uint32_t i = 0; i < parent->childrenlist->nodes.size(); i++) @@ -760,6 +787,8 @@ void XML::getText(XMLVector& ret) { + if (childrenlist.isNull()) + return; for (uint32_t i = 0; i < childrenlist->nodes.size(); i++) { _R<XML> child= childrenlist->nodes[i]; @@ -796,6 +825,8 @@ void XML::getElementNodes(const tiny_string& name, XMLVector& foundElements) { + if (childrenlist.isNull()) + return; for (uint32_t i = 0; i < childrenlist->nodes.size(); i++) { _R<XML> child= childrenlist->nodes[i]; @@ -955,7 +986,7 @@ void XML::setLocalName(const tiny_string& new_name) { - if(!isXMLName(Class<ASString>::getInstanceS(new_name))) + if(!isXMLName(abstract_s(new_name))) { throwError<TypeError>(kXMLInvalidName, new_name); } @@ -1074,7 +1105,7 @@ XML *XML::copy() { - return Class<XML>::getInstanceS(this->toXMLString_internal(false)); + return createFromString(this->toXMLString_internal(false)); } ASFUNCTIONBODY(XML,_setChildren) @@ -1145,6 +1176,8 @@ if (getNodeKind() == pugi::node_comment || getNodeKind() == pugi::node_pi) return false; + if (childrenlist.isNull()) + return true; for(size_t i=0; i<childrenlist->nodes.size(); i++) { if (childrenlist->nodes[i]->getNodeKind() == pugi::node_element) @@ -1168,7 +1201,7 @@ { if (!constructed) return; - if (bIsAttribute) + if (bIsAttribute && !attributelist.isNull()) { for (uint32_t i = 0; i < attributelist->nodes.size(); i++) { @@ -1180,6 +1213,8 @@ } } } + if (childrenlist.isNull()) + return; for (uint32_t i = 0; i < childrenlist->nodes.size(); i++) { _R<XML> child= childrenlist->nodes[i]; @@ -1196,14 +1231,16 @@ { multiname mn(NULL); mn.name_type=multiname::NAME_STRING; - mn.ns.push_back(nsNameAndKind("",NAMESPACE)); - mn.ns.push_back(nsNameAndKind(AS3,NAMESPACE)); + mn.ns.emplace_back("",NAMESPACE); + mn.ns.emplace_back(AS3,NAMESPACE); mn.isAttribute = true; return getAttributesByMultiname(mn); } XML::XMLVector XML::getAttributesByMultiname(const multiname& name) { XMLVector ret; + if (attributelist.isNull()) + return ret; tiny_string defns = "|"; defns += getVm()->getDefaultXMLNamespace(); defns += "|"; @@ -1337,7 +1374,7 @@ //object is a leaf node, delegate to ASString if(res.isNull() && hasSimpleContent()) { - ASString *contentstr=Class<ASString>::getInstanceS(toString_priv()); + ASString *contentstr=abstract_s(toString_priv()); res=contentstr->getVariableByMultiname(name, opt); contentstr->decRef(); } @@ -1380,7 +1417,7 @@ multiname mname(NULL); mname.name_s_id=getSys()->getUniqueStringId("*"); mname.name_type=multiname::NAME_STRING; - mname.ns.push_back(nsNameAndKind("",NAMESPACE)); + mname.ns.emplace_back("",NAMESPACE); XMLList* retObj=Class<XMLList>::getInstanceS(ret,this->getChildrenlist(),mname); return _MNR(retObj); } @@ -1428,6 +1465,8 @@ isAttr=true; buf+=1; } + if (childrenlist.isNull()) + childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs()); if(isAttr) { @@ -1463,7 +1502,7 @@ } if (a.isNull() && !((*buf=='*')|| (*buf==0))) { - _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceS()); + _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs()); this->incRef(); tmp->parentNode = _MR<XML>(this); tmp->nodetype = pugi::node_null; @@ -1501,7 +1540,7 @@ { if (o->as<XML>()->getNodeKind() == pugi::node_pcdata) { - _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceS()); + _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs()); tmp->parentNode = tmpnode; tmp->incRef(); tmp->nodetype = pugi::node_pcdata; @@ -1527,11 +1566,14 @@ } else { + if (tmpnode->childrenlist.isNull()) + tmpnode->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs()); + if (tmpnode->childrenlist->nodes.size() == 1 && tmpnode->childrenlist->nodes[0]->nodetype == pugi::node_pcdata) tmpnode->childrenlist->nodes[0]->nodevalue = o->toString(); else { - XML* newnode = Class<XML>::getInstanceS(o->toString()); + XML* newnode = createFromString(o->toString()); tmpnode->childrenlist->clear(); tmpnode->setVariableByMultiname(name,newnode,allowConst); } @@ -1586,7 +1628,7 @@ } tmpstr += normalizedName; tmpstr +=">"; - _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceS(tmpstr)); + _NR<XML> tmp = _MR<XML>(createFromString(tmpstr)); this->incRef(); tmp->parentNode = _MR<XML>(this); tmpnodes.push_back(tmp); @@ -1632,11 +1674,14 @@ if(isAttr) { //Lookup attribute - for (XMLList::XMLListVector::const_iterator it = attributelist->nodes.begin(); it != attributelist->nodes.end(); it++) + if (!attributelist.isNull()) { - _R<XML> attr = *it; - if (attr->nodenamespace_uri == ns_uri && attr->nodename == buf) - return true; + for (XMLList::XMLListVector::const_iterator it = attributelist->nodes.begin(); it != attributelist->nodes.end(); it++) + { + _R<XML> attr = *it; + if (attr->nodenamespace_uri == ns_uri && attr->nodename == buf) + return true; + } } } else if(XML::isValidMultiname(name,index)) @@ -1681,7 +1726,7 @@ { ns_uri = getVm()->getDefaultXMLNamespace(); } - if (attributelist->nodes.size() > 0) + if (!attributelist.isNull() && attributelist->nodes.size() > 0) { XMLList::XMLListVector::iterator it = attributelist->nodes.end(); while (it != attributelist->nodes.begin()) @@ -1700,7 +1745,8 @@ } else if(XML::isValidMultiname(name,index)) { - childrenlist->nodes.erase(childrenlist->nodes.begin() + index); + if (!childrenlist.isNull()) + childrenlist->nodes.erase(childrenlist->nodes.begin() + index); } else { @@ -1712,7 +1758,7 @@ assert_and_throw(ns.kind==NAMESPACE); ns_uri=ns.name; } - if (childrenlist->nodes.size() > 0) + if (!childrenlist.isNull() && childrenlist->nodes.size() > 0) { XMLList::XMLListVector::iterator it = childrenlist->nodes.end(); while (it != childrenlist->nodes.begin()) @@ -1780,7 +1826,7 @@ ASFUNCTIONBODY(XML,_toString) { XML* th=Class<XML>::cast(obj); - return Class<ASString>::getInstanceS(th->toString_priv()); + return abstract_s(th->toString_priv()); } ASFUNCTIONBODY(XML,_getIgnoreComments) @@ -1838,8 +1884,8 @@ ASObject* res = Class<ASObject>::getInstanceS(); multiname mn(NULL); mn.name_type=multiname::NAME_STRING; - mn.ns.push_back(nsNameAndKind("",NAMESPACE)); - mn.ns.push_back(nsNameAndKind(AS3,NAMESPACE)); + mn.ns.emplace_back("",NAMESPACE); + mn.ns.emplace_back(AS3,NAMESPACE); mn.isAttribute = true; mn.name_s_id=getSys()->getUniqueStringId("ignoreComments"); @@ -1870,8 +1916,8 @@ } multiname mn(NULL); mn.name_type=multiname::NAME_STRING; - mn.ns.push_back(nsNameAndKind("",NAMESPACE)); - mn.ns.push_back(nsNameAndKind(AS3,NAMESPACE)); + mn.ns.emplace_back("",NAMESPACE); + mn.ns.emplace_back(AS3,NAMESPACE); mn.isAttribute = true; _NR<ASObject> o; @@ -1916,8 +1962,8 @@ ASObject* res = Class<ASObject>::getInstanceS(); multiname mn(NULL); mn.name_type=multiname::NAME_STRING; - mn.ns.push_back(nsNameAndKind("",NAMESPACE)); - mn.ns.push_back(nsNameAndKind(AS3,NAMESPACE)); + mn.ns.emplace_back("",NAMESPACE); + mn.ns.emplace_back(AS3,NAMESPACE); mn.isAttribute = true; mn.name_s_id=getSys()->getUniqueStringId("ignoreComments"); @@ -1934,7 +1980,7 @@ } ASFUNCTIONBODY(XML,_toJSON) { - return Class<ASString>::getInstanceS("XML"); + return abstract_s("XML"); } void XML::CheckCyclicReference(XML* node) @@ -1942,14 +1988,36 @@ XML* tmp = node; if (tmp == this) throwError<TypeError>(kXMLIllegalCyclicalLoop); - for (auto it = tmp->childrenlist->nodes.begin(); it != tmp->childrenlist->nodes.end(); it++) + if (!childrenlist.isNull()) { - if ((*it).getPtr() == this) - throwError<TypeError>(kXMLIllegalCyclicalLoop); - CheckCyclicReference((*it).getPtr()); + for (auto it = tmp->childrenlist->nodes.begin(); it != tmp->childrenlist->nodes.end(); it++) + { + if ((*it).getPtr() == this) + throwError<TypeError>(kXMLIllegalCyclicalLoop); + CheckCyclicReference((*it).getPtr()); + } } } +XML *XML::createFromString(const tiny_string &s) +{ + XML* res = Class<XML>::getInstanceSNoArgs(); + 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(); + if (parent) + { + parent->incRef(); + res->parentNode = _NR<XML>(parent); + } + res->createTree(_n,fromXMLList); + return res; +} + ASFUNCTIONBODY(XML,insertChildAfter) { XML* th=Class<XML>::cast(obj); @@ -1969,7 +2037,9 @@ } } else - child2 = _NR<XML>(Class<XML>::getInstanceS(child2->toString())); + child2 = _NR<XML>(createFromString(child2->toString())); + if (th->childrenlist.isNull()) + th->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs()); if (child1->is<Null>()) { th->incRef(); @@ -2045,8 +2115,10 @@ } } else - child2 = _NR<XML>(Class<XML>::getInstanceS(child2->toString())); + child2 = _NR<XML>(createFromString(child2->toString())); + if (th->childrenlist.isNull()) + th->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs()); if (child1->is<Null>()) { if (child2->is<XML>()) @@ -2221,8 +2293,8 @@ multiname name(NULL); name.name_type=multiname::NAME_STRING; name.name_s_id=getSys()->getUniqueStringId(args[0]->toString()); - name.ns.push_back(nsNameAndKind("",NAMESPACE)); - name.ns.push_back(nsNameAndKind(AS3,NAMESPACE)); + name.ns.emplace_back("",NAMESPACE); + name.ns.emplace_back(AS3,NAMESPACE); name.isAttribute=false; ret=obj->hasPropertyByMultiname(name, true, true); } @@ -2245,13 +2317,16 @@ } else if (hasSimpleContent()) { - auto it = childrenlist->nodes.begin(); - while(it != childrenlist->nodes.end()) + if (!childrenlist.isNull()) { - if ((*it)->getNodeKind() != pugi::node_comment && - (*it)->getNodeKind() != pugi::node_pi) - ret += (*it)->toString_priv(); - it++; + auto it = childrenlist->nodes.begin(); + while(it != childrenlist->nodes.end()) + { + if ((*it)->getNodeKind() != pugi::node_comment && + (*it)->getNodeKind() != pugi::node_pi) + ret += (*it)->toString_priv(); + it++; + } } } else @@ -2307,6 +2382,10 @@ if (a->nodevalue != b->nodevalue) return false; // attributes + if (a->attributelist.isNull()) + return b->attributelist.isNull() || b->attributelist->nodes.size() == 0; + if (b->attributelist.isNull()) + return a->attributelist.isNull() || a->attributelist->nodes.size() == 0; if (a->attributelist->nodes.size() != b->attributelist->nodes.size()) return false; for (int i = 0; i < (int)a->attributelist->nodes.size(); i++) @@ -2350,6 +2429,11 @@ } // children + if (a->childrenlist.isNull()) + return b->childrenlist.isNull() || b->childrenlist->nodes.size() == 0; + if (b->childrenlist.isNull()) + return a->childrenlist.isNull() || a->childrenlist->nodes.size() == 0; + return a->childrenlist->isEqual(b->childrenlist.getPtr()); } @@ -2416,7 +2500,7 @@ { pugi::xml_node node = rootnode; bool done = false; - this->childrenlist = _MR(Class<XMLList>::getInstanceS()); + this->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs()); this->childrenlist->incRef(); if (parentNode.isNull() && !fromXMLList) { @@ -2435,10 +2519,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>::getInstanceS()); + _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs()); fillNode(tmp.getPtr(),node); if(this->procinstlist.isNull()) - this->procinstlist = _MR(Class<XMLList>::getInstanceS()); + this->procinstlist = _MR(Class<XMLList>::getInstanceSNoArgs()); this->procinstlist->incRef(); this->procinstlist->append(_R<XML>(tmp)); break; @@ -2460,8 +2544,8 @@ pugi::xml_node_iterator it=node.begin(); while(it!=node.end()) { - //LOG(LOG_ERROR,"rootchildnode1:"<<it->name()<<" "<<it->value()<<" "<<it->type()<<" "<<parentNode.isNull()); - _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceS(*it,this)); + //LOG(LOG_INFO,"rootchildnode1:"<<it->name()<<" "<<it->value()<<" "<<it->type()<<" "<<parentNode.isNull()); + _NR<XML> tmp = _MR<XML>(XML::createFromNode(*it,this)); this->childrenlist->append(_R<XML>(tmp)); it++; } @@ -2498,7 +2582,7 @@ { while(it!=node.end()) { - _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceS(*it,this)); + _NR<XML> tmp = _MR<XML>(XML::createFromNode(*it,this)); this->childrenlist->append(_R<XML>(tmp)); it++; } @@ -2516,7 +2600,7 @@ { if (node->childrenlist.isNull()) { - node->childrenlist = _MR(Class<XMLList>::getInstanceS()); + node->childrenlist = _MR(Class<XMLList>::getInstanceSNoArgs()); node->childrenlist->incRef(); } node->nodetype = srcnode.type(); @@ -2528,7 +2612,7 @@ node->nodenamespace_uri = getVm()->getDefaultXMLNamespace(); if (ignoreWhitespace && node->nodetype == pugi::node_pcdata) node->nodevalue = node->removeWhitespace(node->nodevalue); - node->attributelist = _MR(Class<XMLList>::getInstanceS()); + node->attributelist = _MR(Class<XMLList>::getInstanceSNoArgs()); pugi::xml_attribute_iterator itattr; for(itattr = srcnode.attributes_begin();itattr!=srcnode.attributes_end();++itattr) { @@ -2585,7 +2669,7 @@ 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>::getInstanceS()); + _NR<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs()); node->incRef(); tmp->parentNode = _MR<XML>(node); tmp->nodetype = pugi::node_null; @@ -2652,7 +2736,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(Class<XML>::getInstanceS("dummy")); + arg=_MR(createFromString("dummy")); //avoid interpretation of the argument, just set it as text node arg->setTextContent(args[0]->toString()); } @@ -2694,7 +2778,7 @@ if (propertyName->is<ASQName>()) { name.name_s_id=getSys()->getUniqueStringId(propertyName->as<ASQName>()->getLocalName()); - name.ns.push_back(nsNameAndKind(propertyName->as<ASQName>()->getURI(),NAMESPACE)); + name.ns.emplace_back(propertyName->as<ASQName>()->getURI(),NAMESPACE); } else if (propertyName->toString() == "*") { @@ -2712,7 +2796,7 @@ } else { - XML* x = Class<XML>::getInstanceS(value->toString()); + XML* x = createFromString(value->toString()); x->incRef(); th->childrenlist->clear(); th->childrenlist->append(_R<XML>(x)); @@ -2723,7 +2807,7 @@ else { name.name_s_id=getSys()->getUniqueStringId(propertyName->toString()); - name.ns.push_back(nsNameAndKind("",NAMESPACE)); + name.ns.emplace_back("",NAMESPACE); } uint32_t index=0; if(XML::isValidMultiname(name,index)) @@ -2744,7 +2828,7 @@ } else { - XML* x = Class<XML>::getInstanceS(value->toString()); + XML* x = createFromString(value->toString()); th->deleteVariableByMultiname(name); th->setVariableByMultiname(name,x,CONST_NOT_ALLOWED); }
View file
lightspark.tar.xz/src/scripting/toplevel/XML.h
Changed
@@ -143,6 +143,8 @@ static bool getPrettyPrinting(); static unsigned int getParseMode(); + static XML* createFromString(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;} const tiny_string getNamespaceURI() const { return nodenamespace_uri;}
View file
lightspark.tar.xz/src/scripting/toplevel/XMLList.cpp
Changed
@@ -84,13 +84,16 @@ { if (targetobject) targetobject->decRef(); - //nodes.clear(); - ASObject::finalize(); + nodes.clear(); + constructed = false; + targetobject = NULL; + targetproperty = multiname(this->getClass()->memoryAccount); } void XMLList::sinit(Class_base* c) { 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); @@ -230,7 +233,7 @@ pugi::xml_node_iterator it=xmldoc.begin(); for(;it!=xmldoc.end();++it) { - _R<XML> tmp = _MR(Class<XML>::getInstanceS(*it,(XML*)NULL,true)); + _R<XML> tmp = _MR(XML::createFromNode(*it,(XML*)NULL,true)); if (tmp->constructed) nodes.push_back(tmp); } @@ -311,7 +314,7 @@ assert(obj==NULL); if(argslen==0) { - return Class<XMLList>::getInstanceS(""); + return Class<XMLList>::getInstanceSNoArgs(); } else if(args[0]->is<ASString>() || args[0]->is<Number>() || @@ -336,7 +339,7 @@ else if(args[0]->getObjectType()==T_NULL || args[0]->getObjectType()==T_UNDEFINED) { - return Class<XMLList>::getInstanceS(); + return Class<XMLList>::getInstanceSNoArgs(); } else throw RunTimeException("Type not supported in XMLList()"); @@ -346,7 +349,7 @@ { XMLList* th=Class<XMLList>::cast(obj); _NR<ASObject> name; - ARG_UNPACK(name,_NR<ASObject>(Class<ASString>::getInstanceS("*"))); + ARG_UNPACK(name,_NR<ASObject>(abstract_s("*"))); XML::XMLVector ret; multiname mname(NULL); name->applyProxyProperty(mname); @@ -473,7 +476,7 @@ ASFUNCTIONBODY(XMLList,copy) { XMLList* th = obj->as<XMLList>(); - XMLList *dest = Class<XMLList>::getInstanceS(); + XMLList *dest = Class<XMLList>::getInstanceSNoArgs(); dest->targetobject = th->targetobject; auto it=th->nodes.begin(); for(; it!=th->nodes.end(); ++it) @@ -495,7 +498,7 @@ multiname mname(NULL); mname.name_type=multiname::NAME_STRING; mname.name_s_id=getSys()->getUniqueStringId(attrname); - mname.ns.push_back(nsNameAndKind("",NAMESPACE)); + mname.ns.emplace_back("",NAMESPACE); mname.isAttribute = true; _NR<ASObject> attr=th->getVariableByMultiname(mname, NONE); @@ -507,7 +510,7 @@ ASFUNCTIONBODY(XMLList,attributes) { XMLList *th = obj->as<XMLList>(); - XMLList *res = Class<XMLList>::getInstanceS(); + XMLList *res = Class<XMLList>::getInstanceSNoArgs(); auto it=th->nodes.begin(); for(; it!=th->nodes.end(); ++it) { @@ -521,7 +524,7 @@ { XMLList* th=Class<XMLList>::cast(obj); - XMLList *res = Class<XMLList>::getInstanceS(); + XMLList *res = Class<XMLList>::getInstanceSNoArgs(); XML::XMLVector nodecomments; auto it=th->nodes.begin(); for(; it!=th->nodes.end(); ++it) @@ -537,7 +540,7 @@ tiny_string name; ARG_UNPACK(name,"*"); - XMLList *res = Class<XMLList>::getInstanceS(); + XMLList *res = Class<XMLList>::getInstanceSNoArgs(); XML::XMLVector nodeprocessingInstructions; auto it=th->nodes.begin(); for(; it!=th->nodes.end(); ++it) @@ -674,7 +677,7 @@ //delegate to ASString if(res.isNull() && nodes.size()==1 && nodes[0]->hasSimpleContent()) { - ASString *contentstr=Class<ASString>::getInstanceS(nodes[0]->toString_priv()); + ASString *contentstr=abstract_s(nodes[0]->toString_priv()); res=contentstr->getVariableByMultiname(name, opt); contentstr->decRef(); } @@ -795,20 +798,20 @@ throwError<TypeError>(kXMLAssigmentOneItemLists); if (!tmpprop.isEmpty()) { - XML* tmp = Class<XML>::getInstanceS(); + XML* tmp = Class<XML>::getInstanceSNoArgs(); tmp->nodetype = pugi::node_element; tmp->nodename = targetproperty.normalizedName(); - tmp->attributelist = _MR(Class<XMLList>::getInstanceS()); + tmp->attributelist = _MR(Class<XMLList>::getInstanceSNoArgs()); tmp->constructed = true; tmp->setVariableByMultiname(name,o,allowConst); tmp->incRef(); tiny_string tmpname = tmpprop.normalizedName(); if (retnodes.empty() && tmpname != "" && tmpname != "*") { - XML* tmp2 = Class<XML>::getInstanceS(); + XML* tmp2 = Class<XML>::getInstanceSNoArgs(); tmp2->nodetype = pugi::node_element; tmp2->nodename = tmpname; - tmp2->attributelist = _MR(Class<XMLList>::getInstanceS()); + tmp2->attributelist = _MR(Class<XMLList>::getInstanceSNoArgs()); tmp2->constructed = true; tmp2->setVariableByMultiname(targetproperty,tmp,allowConst); tmp2->incRef(); @@ -933,7 +936,7 @@ else { tiny_string str = x->toString(); - append(_MR(Class<XML>::getInstanceS(str))); + append(_MR(XML::createFromString(str))); } } @@ -985,7 +988,7 @@ multiname m(NULL); m.name_type = multiname::NAME_INT; m.name_i = i; - m.ns.push_back(nsNameAndKind("",NAMESPACE)); + m.ns.emplace_back("",NAMESPACE); targetobject->setVariableByMultiname(m,o,allowConst); break; } @@ -1011,13 +1014,13 @@ multiname m(NULL); m.name_type = multiname::NAME_INT; m.name_i = idx; - m.ns.push_back(nsNameAndKind("",NAMESPACE)); + m.ns.emplace_back("",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>::getInstanceS()); + _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs()); nodes[idx]->incRef(); tmp->parentNode = nodes[idx]; tmp->nodetype = pugi::node_pcdata; @@ -1041,7 +1044,7 @@ else { nodes[idx]->childrenlist->clear(); - _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceS()); + _R<XML> tmp = _MR<XML>(Class<XML>::getInstanceSNoArgs()); nodes[idx]->incRef(); tmp->parentNode = nodes[idx]; tmp->nodetype = pugi::node_pcdata; @@ -1101,7 +1104,7 @@ ASFUNCTIONBODY(XMLList,_toString) { XMLList* th=Class<XMLList>::cast(obj); - return Class<ASString>::getInstanceS(th->toString_priv()); + return abstract_s(th->toString_priv()); } tiny_string XMLList::toXMLString_internal(bool pretty) @@ -1125,7 +1128,7 @@ { XMLList* th=Class<XMLList>::cast(obj); assert_and_throw(argslen==0); - ASString* ret=Class<ASString>::getInstanceS(th->toXMLString_internal()); + ASString* ret=abstract_s(th->toXMLString_internal()); return ret; }
View file
lightspark.tar.xz/src/scripting/toplevel/toplevel.cpp
Changed
@@ -255,7 +255,7 @@ // TODO: accessor LOG(LOG_NOT_IMPLEMENTED, "describeType for Function not completely implemented"); - return Class<XML>::getInstanceS(root); + return XML::createFromNode(root); } SyntheticFunction::SyntheticFunction(Class_base* c,method_info* m):IFunction(c),mi(m),val(NULL) @@ -1265,7 +1265,7 @@ node=root.append_child("factory"); node.append_attribute("type").set_value(getQualifiedClassName().raw_buf()); describeInstance(node); - return Class<XML>::getInstanceS(root); + return XML::createFromNode(root); } void Class_base::describeInstance(pugi::xml_node& root) const
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
.