Projects
Essentials
lightspark
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 114
View file
lightspark.spec
Changed
@@ -20,7 +20,7 @@ %bcond_without librtmp Name: lightspark -Version: 0.7.2.99+git20160821.1502 +Version: 0.7.2.99+git20160828.1727 Release: 0 Summary: Modern, free, open-source flash player implementation License: LGPL-3.0+
View file
lightspark.tar.xz/src/asobject.cpp
Changed
@@ -104,6 +104,12 @@ this->as<Class_base>()->borrowedVariables.dumpVariables(); } } +uint32_t ASObject::toStringId() +{ + if (stringId == UINT32_MAX) + stringId = getSystemState()->getUniqueStringId(toString()); + return stringId; +} tiny_string ASObject::toString() { check(); @@ -324,9 +330,9 @@ { multiname valueOfName(NULL); valueOfName.name_type=multiname::NAME_STRING; - valueOfName.name_s_id=getSystemState()->getUniqueStringId("valueOf"); - valueOfName.ns.emplace_back(getSystemState(),"",NAMESPACE); - valueOfName.ns.emplace_back(getSystemState(),AS3,NAMESPACE); + valueOfName.name_s_id=BUILTIN_STRINGS::STRING_VALUEOF; + valueOfName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + valueOfName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::STRING_AS3NS,NAMESPACE); valueOfName.isAttribute = false; return hasPropertyByMultiname(valueOfName, true, true); } @@ -338,9 +344,9 @@ { multiname valueOfName(NULL); valueOfName.name_type=multiname::NAME_STRING; - valueOfName.name_s_id=getSystemState()->getUniqueStringId("valueOf"); - valueOfName.ns.emplace_back(getSystemState(),"",NAMESPACE); - valueOfName.ns.emplace_back(getSystemState(),AS3,NAMESPACE); + valueOfName.name_s_id=BUILTIN_STRINGS::STRING_VALUEOF; + valueOfName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + valueOfName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::STRING_AS3NS,NAMESPACE); valueOfName.isAttribute = false; assert_and_throw(hasPropertyByMultiname(valueOfName, true, true)); @@ -358,9 +364,9 @@ { multiname toStringName(NULL); toStringName.name_type=multiname::NAME_STRING; - toStringName.name_s_id=getSystemState()->getUniqueStringId("toString"); - toStringName.ns.emplace_back(getSystemState(),"",NAMESPACE); - toStringName.ns.emplace_back(getSystemState(),AS3,NAMESPACE); + toStringName.name_s_id=BUILTIN_STRINGS::STRING_TOSTRING; + toStringName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + toStringName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::STRING_AS3NS,NAMESPACE); toStringName.isAttribute = false; return ASObject::hasPropertyByMultiname(toStringName, true, true); } @@ -372,9 +378,9 @@ { multiname toStringName(NULL); toStringName.name_type=multiname::NAME_STRING; - toStringName.name_s_id=getSystemState()->getUniqueStringId("toString"); - toStringName.ns.emplace_back(getSystemState(),"",NAMESPACE); - toStringName.ns.emplace_back(getSystemState(),AS3,NAMESPACE); + toStringName.name_s_id=BUILTIN_STRINGS::STRING_TOSTRING; + toStringName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + toStringName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::STRING_AS3NS,NAMESPACE); toStringName.isAttribute = false; assert(ASObject::hasPropertyByMultiname(toStringName, true, true)); @@ -394,8 +400,8 @@ multiname toJSONName(NULL); toJSONName.name_type=multiname::NAME_STRING; toJSONName.name_s_id=getSystemState()->getUniqueStringId("toJSON"); - toJSONName.ns.emplace_back(getSystemState(),"",NAMESPACE); - toJSONName.ns.emplace_back(getSystemState(),AS3,NAMESPACE); + toJSONName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + toJSONName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::STRING_AS3NS,NAMESPACE); toJSONName.isAttribute = false; if (!ASObject::hasPropertyByMultiname(toJSONName, true, true)) return res; @@ -980,8 +986,8 @@ { multiname toStringName(NULL); toStringName.name_type=multiname::NAME_STRING; - toStringName.name_s_id=obj->getSystemState()->getUniqueStringId("toString"); - toStringName.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); + toStringName.name_s_id=BUILTIN_STRINGS::STRING_TOSTRING; + toStringName.ns.emplace_back(obj->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); toStringName.isAttribute = false; if (obj->hasPropertyByMultiname(toStringName, true, false)) { @@ -1001,8 +1007,8 @@ assert_and_throw(argslen==1); multiname name(NULL); name.name_type=multiname::NAME_STRING; - name.name_s_id=obj->getSystemState()->getUniqueStringId(args[0]->toString()); - name.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); + name.name_s_id=args[0]->toStringId(); + name.ns.emplace_back(obj->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); name.isAttribute=false; bool ret=obj->hasPropertyByMultiname(name, true, false); return abstract_b(obj->getSystemState(),ret); @@ -1041,8 +1047,8 @@ return abstract_b(obj->getSystemState(),false); multiname name(NULL); name.name_type=multiname::NAME_STRING; - name.name_s_id=obj->getSystemState()->getUniqueStringId(args[0]->toString()); - name.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); + name.name_s_id=args[0]->toStringId(); + name.ns.emplace_back(obj->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); name.isAttribute=false; if (obj->is<Array>()) // propertyIsEnumerable(index) isn't mentioned in the ECMA specs but is tested for { @@ -1067,8 +1073,8 @@ ARG_UNPACK(propname) (isEnum, true); multiname name(NULL); name.name_type=multiname::NAME_STRING; - name.name_s_id=obj->getSystemState()->getUniqueStringId(args[0]->toString()); - name.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); + name.name_s_id=args[0]->toStringId(); + name.ns.emplace_back(obj->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); name.isAttribute=false; obj->setIsEnumerable(name, isEnum); return NULL; @@ -1343,7 +1349,7 @@ } ASObject::ASObject(Class_base* c,SWFOBJECT_TYPE t,CLASS_SUBTYPE st):objfreelist(c && c->isReusable ? c->freelist : NULL),Variables((c)?c->memoryAccount:NULL),varcount(0),classdef(c),proxyMultiName(NULL),sys(c?c->sys:NULL), - type(t),subtype(st),traitsInitialized(false),constructIndicator(false),constructorCallComplete(false),implEnable(true) + stringId(UINT32_MAX),type(t),subtype(st),traitsInitialized(false),constructIndicator(false),constructorCallComplete(false),implEnable(true) { #ifndef NDEBUG //Stuff only used in debugging @@ -1352,7 +1358,7 @@ } ASObject::ASObject(const ASObject& o):objfreelist(o.classdef && o.classdef->isReusable ? o.classdef->freelist : NULL),Variables((o.classdef)?o.classdef->memoryAccount:NULL),varcount(0),classdef(NULL),proxyMultiName(NULL),sys(o.classdef? o.classdef->sys : NULL), - type(o.type),subtype(o.subtype),traitsInitialized(false),constructIndicator(false),constructorCallComplete(false),implEnable(true) + stringId(o.stringId),type(o.type),subtype(o.subtype),traitsInitialized(false),constructIndicator(false),constructorCallComplete(false),implEnable(true) { #ifndef NDEBUG //Stuff only used in debugging @@ -1375,6 +1381,7 @@ destroyContents(); if (proxyMultiName) delete proxyMultiName; + stringId = UINT32_MAX; proxyMultiName = NULL; traitsInitialized =false; constructIndicator = false; @@ -1588,7 +1595,7 @@ multiname writeExternalName(NULL); writeExternalName.name_type=multiname::NAME_STRING; writeExternalName.name_s_id=getSystemState()->getUniqueStringId("writeExternal"); - writeExternalName.ns.emplace_back(getSystemState(),"",NAMESPACE); + writeExternalName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); writeExternalName.isAttribute = false; _NR<ASObject> o=getVariableByMultiname(writeExternalName,SKIP_IMPL); @@ -1892,7 +1899,7 @@ multiname prototypeName(NULL); prototypeName.name_type=multiname::NAME_STRING; prototypeName.name_s_id=getSystemState()->getUniqueStringId("prototype"); - prototypeName.ns.emplace_back(getSystemState(),"",NAMESPACE); + prototypeName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); bool has_getter = false; variable* ret=findSettable(prototypeName,&has_getter); if(!ret && has_getter)
View file
lightspark.tar.xz/src/asobject.h
Changed
@@ -366,7 +366,7 @@ SystemState* sys; protected: ASObject(MemoryAccount* m):objfreelist(NULL),Variables(m),varcount(0),classdef(NULL),proxyMultiName(NULL),sys(NULL), - type(T_OBJECT),subtype(SUBTYPE_NOT_SET),traitsInitialized(false),constructIndicator(false),constructorCallComplete(false),implEnable(true) + stringId(UINT32_MAX),type(T_OBJECT),subtype(SUBTYPE_NOT_SET),traitsInitialized(false),constructIndicator(false),constructorCallComplete(false),implEnable(true) { #ifndef NDEBUG //Stuff only used in debugging @@ -379,6 +379,7 @@ { destroy(); } + uint32_t stringId; SWFOBJECT_TYPE type; CLASS_SUBTYPE subtype; @@ -554,6 +555,7 @@ /* Implements ECMA's 9.8 ToString operation, but returns the concrete value */ tiny_string toString(); tiny_string toLocaleString(); + uint32_t toStringId(); virtual int32_t toInt(); virtual uint32_t toUInt(); virtual int64_t toInt64();
View file
lightspark.tar.xz/src/backends/extscriptobject.cpp
Changed
@@ -280,7 +280,7 @@ // We are converting an array, so lets set indexes if(objValue->getType() == ExtObject::EO_ARRAY) { - asobj = Class<Array>::getInstanceS(getSys()); + asobj = Class<Array>::getInstanceSNoArgs(getSys()); objectsMap[objValue] = asobj; count = objValue->getLength();
View file
lightspark.tar.xz/src/scripting/abc.cpp
Changed
@@ -248,7 +248,7 @@ 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("AS3","",_MR(Class<Namespace>::getInstanceS(m_sys,BUILTIN_STRINGS::STRING_AS3NS))); builtin->registerBuiltin("Date","",Class<Date>::getRef(m_sys)); builtin->registerBuiltin("JSON","",Class<JSON>::getRef(m_sys)); builtin->registerBuiltin("RegExp","",Class<RegExp>::getRef(m_sys)); @@ -1879,6 +1879,10 @@ { return m_sys->getStringFromUniqueId(currentCallContext->defaultNamespaceUri); } +uint32_t ABCVm::getDefaultXMLNamespaceID() +{ + return currentCallContext->defaultNamespaceUri; +} uint32_t ABCContext::getString(unsigned int s) const { @@ -2011,7 +2015,7 @@ case 0x08: //Namespace { assert_and_throw(constant_pool.namespaces[index].name); - Namespace* ret = Class<Namespace>::getInstanceS(root->getSystemState(),root->getSystemState()->getStringFromUniqueId(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; @@ -2086,7 +2090,7 @@ ASObject* ret; - QName className(mname->name_s_id,mname->ns[0].getImpl(obj->getSystemState()).nameId); + QName className(mname->name_s_id,mname->ns[0].nsNameId); //check if this class has the 'interface' flag, i.e. it is an interface if((instances[t->classi].flags)&0x04) {
View file
lightspark.tar.xz/src/scripting/abc.h
Changed
@@ -591,6 +591,7 @@ uint32_t getAndIncreaseNamespaceBase(uint32_t nsNum); tiny_string getDefaultXMLNamespace(); + uint32_t getDefaultXMLNamespaceID(); void buildClassAndBindTag(const std::string& s, DictionaryTag* t); };
View file
lightspark.tar.xz/src/scripting/abc_opcodes.cpp
Changed
@@ -1999,7 +1999,7 @@ name.name_type=multiname::NAME_OBJECT; //Acquire the reference name.name_o=val1; - name.ns.emplace_back(val2->getSystemState(),"",NAMESPACE); + name.ns.emplace_back(val2->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); bool ret=val2->hasPropertyByMultiname(name, true, true); name.name_o=NULL; val1->decRef(); @@ -2111,12 +2111,12 @@ //Duplicated keys overwrite the previous value multiname propertyName(NULL); propertyName.name_type=multiname::NAME_STRING; - propertyName.ns.emplace_back(th->context->root->getSystemState(),"",NAMESPACE); + propertyName.ns.emplace_back(th->context->root->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); for(int i=0;i<n;i++) { ASObject* value=th->runtime_stack_pop(); ASObject* name=th->runtime_stack_pop(); - propertyName.name_s_id=ret->getSystemState()->getUniqueStringId(name->toString()); + propertyName.name_s_id=name->toStringId(); name->decRef(); ret->setVariableByMultiname(propertyName, value, ASObject::CONST_NOT_ALLOWED); } @@ -2135,24 +2135,24 @@ { XML* xmlObj=Class<XML>::cast(obj); targetobject = xmlObj->getChildrenlist(); - tiny_string ns_uri = ""; + uint32_t ns_uri = BUILTIN_STRINGS::EMPTY; if (name->ns.size() > 0) { - ns_uri = th->context->root->getSystemState()->getStringFromUniqueId(name->ns[0].getImpl(th->context->root->getSystemState()).nameId); - if (ns_uri.empty() && name->ns.size() == 1) - ns_uri="*"; + ns_uri = name->ns[0].nsNameId; + if (ns_uri == BUILTIN_STRINGS::EMPTY && name->ns.size() == 1) + ns_uri=BUILTIN_STRINGS::STRING_WILDCARD; } xmlObj->getDescendantsByQName(name->normalizedName(th->context->root->getSystemState()), ns_uri,name->isAttribute, ret); } else if(obj->getClass()==Class<XMLList>::getClass(th->context->root->getSystemState())) { XMLList* xmlObj=Class<XMLList>::cast(obj); - tiny_string ns_uri = ""; + uint32_t ns_uri = BUILTIN_STRINGS::EMPTY; if (name->ns.size() > 0) { - ns_uri = th->context->root->getSystemState()->getStringFromUniqueId(name->ns[0].getImpl(th->context->root->getSystemState()).nameId); - if (ns_uri.empty() && name->ns.size() == 1) - ns_uri="*"; + ns_uri = name->ns[0].nsNameId; + if (ns_uri == BUILTIN_STRINGS::EMPTY && name->ns.size() == 1) + ns_uri=BUILTIN_STRINGS::STRING_WILDCARD; } targetobject = xmlObj; xmlObj->getDescendantsByQName(name->normalizedName(th->context->root->getSystemState()), ns_uri,name->isAttribute, ret); @@ -2201,7 +2201,7 @@ obj->decRef(); throwError<TypeError>(kDescendentsError, objName); } - XMLList* retObj=Class<XMLList>::getInstanceS(th->context->root->getSystemState(),ret,targetobject,*name); + XMLList* retObj=XMLList::create(th->context->root->getSystemState(),ret,targetobject,*name); th->runtime_stack_push(retObj); obj->decRef(); } @@ -2306,7 +2306,7 @@ ASObject* baseClass=th->runtime_stack_pop(); assert_and_throw(mname->ns.size()==1); - QName className(mname->name_s_id,mname->ns[0].getImpl(th->context->root->getSystemState()).nameId); + QName className(mname->name_s_id,mname->ns[0].nsNameId); Class_inherit* ret = NULL; auto i = th->context->root->applicationDomain->classesBeingDefined.cbegin(); @@ -2700,7 +2700,7 @@ void ABCVm::newArray(call_context* th, int n) { LOG_CALL( _("newArray ") << n ); - Array* ret=Class<Array>::getInstanceS(th->context->root->getSystemState()); + Array* ret=Class<Array>::getInstanceSNoArgs(th->context->root->getSystemState()); ret->resize(n); for(int i=0;i<n;i++) ret->set(n-i-1,_MR(th->runtime_stack_pop())); @@ -2778,7 +2778,7 @@ const namespace_info& ns_info=th->context->constant_pool.namespaces[n]; assert(ns_info.kind == NAMESPACE); LOG_CALL( _("pushNamespace ") << th->context->root->getSystemState()->getStringFromUniqueId(th->context->getString(ns_info.name)) ); - return Class<Namespace>::getInstanceS(th->context->root->getSystemState(),th->context->root->getSystemState()->getStringFromUniqueId(th->context->getString(ns_info.name))); + return Class<Namespace>::getInstanceS(th->context->root->getSystemState(),th->context->getString(ns_info.name)); } /* @spec-checked avm2overview */ @@ -2796,6 +2796,6 @@ if(!th->mi->hasDXNS()) throw Class<VerifyError>::getInstanceS(th->context->root->getSystemState(),"dxnslate without SET_DXNS"); - th->defaultNamespaceUri = th->context->root->getSystemState()->getUniqueStringId(o->toString()); + th->defaultNamespaceUri = o->toStringId(); o->decRef(); }
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(c->getSystemState())),cacheAsBitmap(false) + visible(true),mask(),invalidateQueueNext(),loaderInfo(),filters(Class<Array>::getInstanceSNoArgs(c->getSystemState())),cacheAsBitmap(false) { name = tiny_string("instance") + Integer::toString(ATOMIC_INCREMENT(instanceCount)); }
View file
lightspark.tar.xz/src/scripting/flash/display/flashdisplay.cpp
Changed
@@ -1028,7 +1028,7 @@ ASFUNCTIONBODY(Scene,_getLabels) { Scene* th=static_cast<Scene*>(obj); - Array* ret = Class<Array>::getInstanceS(obj->getSystemState()); + Array* ret = Class<Array>::getInstanceSNoArgs(obj->getSystemState()); ret->resize(th->labels.size()); for(size_t i=0; i<th->labels.size(); ++i) { @@ -1354,7 +1354,7 @@ ASFUNCTIONBODY(MovieClip,_getScenes) { MovieClip* th=static_cast<MovieClip*>(obj); - Array* ret = Class<Array>::getInstanceS(obj->getSystemState()); + Array* ret = Class<Array>::getInstanceSNoArgs(obj->getSystemState()); ret->resize(th->scenes.size()); uint32_t numFrames; for(size_t i=0; i<th->scenes.size(); ++i) @@ -1438,7 +1438,7 @@ MovieClip* th=static_cast<MovieClip*>(obj); Scene_data& sc = th->scenes[th->getCurrentScene()]; - Array* ret = Class<Array>::getInstanceS(obj->getSystemState()); + Array* ret = Class<Array>::getInstanceSNoArgs(obj->getSystemState()); ret->resize(sc.labels.size()); for(size_t i=0; i<sc.labels.size(); ++i) { @@ -1522,7 +1522,7 @@ multiname objName(NULL); objName.name_type=multiname::NAME_STRING; objName.name_s_id=getSystemState()->getUniqueStringId(obj->name); - objName.ns.emplace_back(getSystemState(),"",NAMESPACE); + objName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); setVariableByMultiname(objName,getSystemState()->getNullRef(), ASObject::CONST_NOT_ALLOWED); } @@ -1546,7 +1546,7 @@ multiname objName(NULL); objName.name_type=multiname::NAME_STRING; objName.name_s_id=getSystemState()->getUniqueStringId(obj->name); - objName.ns.emplace_back(getSystemState(),"",NAMESPACE); + objName.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); setVariableByMultiname(objName,obj,ASObject::CONST_NOT_ALLOWED); }
View file
lightspark.tar.xz/src/scripting/flash/net/flashnet.cpp
Changed
@@ -36,7 +36,7 @@ using namespace lightspark; URLRequest::URLRequest(Class_base* c):ASObject(c),method(GET),contentType("application/x-www-form-urlencoded"), - requestHeaders(Class<Array>::getInstanceS(c->getSystemState())) + requestHeaders(Class<Array>::getInstanceSNoArgs(c->getSystemState())) { } @@ -817,7 +817,7 @@ //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(obj->getSystemState())); + _R<Array> rest=_MR(Class<Array>::getInstanceSNoArgs(obj->getSystemState())); for(uint32_t i=2;i<argslen;i++) { args[i]->incRef(); @@ -2164,7 +2164,7 @@ Array* arr=NULL; if(curValue->getObjectType()!=T_ARRAY) { - arr=Class<Array>::getInstanceS(getSystemState()); + arr=Class<Array>::getInstanceSNoArgs(getSystemState()); arr->push(curValue); setVariableByMultiname(propName,arr,ASObject::CONST_NOT_ALLOWED); }
View file
lightspark.tar.xz/src/scripting/flash/text/flashtext.cpp
Changed
@@ -74,7 +74,7 @@ if (enumerateDeviceFonts) LOG(LOG_NOT_IMPLEMENTED,"Font::enumerateFonts: flag enumerateDeviceFonts is not handled"); - Array* ret = Class<Array>::getInstanceS(getSys()); + Array* ret = Class<Array>::getInstanceSNoArgs(getSys()); std::vector<ASObject*>* fontlist = getFontList(); for(auto i = fontlist->begin(); i != fontlist->end(); ++i) { @@ -1307,7 +1307,7 @@ { StyleSheet* th=Class<StyleSheet>::cast(obj); assert_and_throw(argslen==0); - Array* ret=Class<Array>::getInstanceS(obj->getSystemState()); + Array* ret=Class<Array>::getInstanceSNoArgs(obj->getSystemState()); map<tiny_string, _R<ASObject>>::const_iterator it=th->styles.begin(); for(;it!=th->styles.end();++it) ret->push(_MR(abstract_s(obj->getSystemState(),it->first)));
View file
lightspark.tar.xz/src/scripting/flash/ui/ContextMenu.cpp
Changed
@@ -22,7 +22,7 @@ using namespace std; using namespace lightspark; -ContextMenu::ContextMenu(Class_base* c):EventDispatcher(c),customItems(Class<Array>::getInstanceS(c->getSystemState())),builtInItems(Class<ContextMenuBuiltInItems>::getInstanceS(c->getSystemState())) +ContextMenu::ContextMenu(Class_base* c):EventDispatcher(c),customItems(Class<Array>::getInstanceSNoArgs(c->getSystemState())),builtInItems(Class<ContextMenuBuiltInItems>::getInstanceS(c->getSystemState())) { }
View file
lightspark.tar.xz/src/scripting/flash/utils/Dictionary.cpp
Changed
@@ -99,7 +99,7 @@ return; case T_STRING: tmpname.name_type=multiname::NAME_STRING; - tmpname.name_s_id = getSystemState()->getUniqueStringId(name.name_o->toString()); + tmpname.name_s_id = name.name_o->toStringId(); ASObject::setVariableByMultiname(tmpname, o, allowConst); return; default: @@ -147,7 +147,7 @@ return ASObject::deleteVariableByMultiname(tmpname); case T_STRING: tmpname.name_type=multiname::NAME_STRING; - tmpname.name_s_id = getSystemState()->getUniqueStringId(name.name_o->toString()); + tmpname.name_s_id = name.name_o->toStringId(); return ASObject::deleteVariableByMultiname(tmpname); default: break; @@ -196,7 +196,7 @@ return ASObject::getVariableByMultiname(tmpname, opt); case T_STRING: tmpname.name_type=multiname::NAME_STRING; - tmpname.name_s_id = getSystemState()->getUniqueStringId(name.name_o->toString()); + tmpname.name_s_id = name.name_o->toStringId(); return ASObject::getVariableByMultiname(tmpname, opt); default: break; @@ -253,7 +253,7 @@ return ASObject::hasPropertyByMultiname(tmpname, considerDynamic, considerPrototype); case T_STRING: tmpname.name_type=multiname::NAME_STRING; - tmpname.name_s_id = getSystemState()->getUniqueStringId(name.name_o->toString()); + tmpname.name_s_id = name.name_o->toStringId(); return ASObject::hasPropertyByMultiname(tmpname, considerDynamic, considerPrototype); default: break;
View file
lightspark.tar.xz/src/scripting/flash/xml/flashxml.cpp
Changed
@@ -101,7 +101,7 @@ ASFUNCTIONBODY(XMLNode,childNodes) { XMLNode* th=Class<XMLNode>::cast(obj); - Array* ret = Class<Array>::getInstanceS(obj->getSystemState()); + Array* ret = Class<Array>::getInstanceSNoArgs(obj->getSystemState()); assert_and_throw(argslen==0); if(th->node.type()==pugi::node_null) return ret;
View file
lightspark.tar.xz/src/scripting/toplevel/ASString.cpp
Changed
@@ -29,23 +29,24 @@ using namespace std; using namespace lightspark; -ASString::ASString(Class_base* c):ASObject(c,T_STRING),hasId(true),datafilled(true),stringId(BUILTIN_STRINGS::EMPTY) +ASString::ASString(Class_base* c):ASObject(c,T_STRING),hasId(true),datafilled(true) { + stringId = BUILTIN_STRINGS::EMPTY; } -ASString::ASString(Class_base* c,const string& s) : ASObject(c,T_STRING),data(s),hasId(false),datafilled(true),stringId(BUILTIN_STRINGS::EMPTY) +ASString::ASString(Class_base* c,const string& s) : ASObject(c,T_STRING),data(s),hasId(false),datafilled(true) { } -ASString::ASString(Class_base* c,const tiny_string& s) : ASObject(c,T_STRING),data(s),hasId(false),datafilled(true),stringId(BUILTIN_STRINGS::EMPTY) +ASString::ASString(Class_base* c,const tiny_string& s) : ASObject(c,T_STRING),data(s),hasId(false),datafilled(true) { } -ASString::ASString(Class_base* c,const Glib::ustring& s) : ASObject(c,T_STRING),data(s),hasId(false),datafilled(true),stringId(BUILTIN_STRINGS::EMPTY) +ASString::ASString(Class_base* c,const Glib::ustring& s) : ASObject(c,T_STRING),data(s),hasId(false),datafilled(true) { } -ASString::ASString(Class_base* c,const char* s) : ASObject(c,T_STRING),data(s, /*copy:*/true),hasId(false),datafilled(true),stringId(BUILTIN_STRINGS::EMPTY) +ASString::ASString(Class_base* c,const char* s) : ASObject(c,T_STRING),data(s, /*copy:*/true),hasId(false),datafilled(true) { } @@ -53,7 +54,6 @@ { data = std::string(s,len); hasId = false; - stringId = BUILTIN_STRINGS::EMPTY; datafilled=true; } @@ -64,7 +64,7 @@ { th->data=args[0]->toString(); th->hasId = false; - th->stringId = BUILTIN_STRINGS::EMPTY; + th->stringId = UINT32_MAX; th->datafilled = true; } return NULL; @@ -220,7 +220,7 @@ if (re->global) { - Array *resarr = Class<Array>::getInstanceS(obj->getSystemState()); + Array *resarr = Class<Array>::getInstanceSNoArgs(obj->getSystemState()); int prevLastIndex = 0; re->lastIndex = 0; @@ -279,7 +279,7 @@ ASFUNCTIONBODY(ASString,split) { tiny_string data = obj->toString(); - Array* ret=Class<Array>::getInstanceS(obj->getSystemState()); + Array* ret=Class<Array>::getInstanceSNoArgs(obj->getSystemState()); uint32_t limit = 0x7fffffff; if(argslen == 0 ) {
View file
lightspark.tar.xz/src/scripting/toplevel/ASString.h
Changed
@@ -50,7 +50,6 @@ ASString(Class_base* c, const char* s, uint32_t len); bool hasId:1; bool datafilled:1; - uint32_t stringId; inline tiny_string& getData() { if (!datafilled) @@ -63,7 +62,7 @@ inline bool isEmpty() const { if (hasId) - return stringId == BUILTIN_STRINGS::EMPTY; + return stringId == BUILTIN_STRINGS::EMPTY || stringId == UINT32_MAX; return data.empty(); } @@ -108,10 +107,16 @@ { data.clear(); strlength.reset(); - hasId = true; - datafilled=true; - stringId = BUILTIN_STRINGS::EMPTY; - return ASObject::destruct(); + hasId = false; + datafilled=false; + if (!ASObject::destruct()) + { + stringId = BUILTIN_STRINGS::EMPTY; + hasId = true; + datafilled = true; + return false; + } + return true; } };
View file
lightspark.tar.xz/src/scripting/toplevel/Array.cpp
Changed
@@ -105,7 +105,7 @@ ASFUNCTIONBODY(Array,generator) { - Array* th=Class<Array>::getInstanceS(getSys()); + Array* th=Class<Array>::getInstanceSNoArgs(getSys()); th->constructorImpl(args, argslen); return th; } @@ -135,7 +135,7 @@ ASFUNCTIONBODY(Array,_concat) { Array* th=static_cast<Array*>(obj); - Array* ret=Class<Array>::getInstanceS(obj->getSystemState()); + Array* ret=Class<Array>::getInstanceSNoArgs(obj->getSystemState()); // copy values into new array ret->resize(th->size()); @@ -178,7 +178,7 @@ ASFUNCTIONBODY(Array,filter) { Array* th=static_cast<Array*>(obj); - Array* ret=Class<Array>::getInstanceS(obj->getSystemState()); + Array* ret=Class<Array>::getInstanceSNoArgs(obj->getSystemState()); _NR<IFunction> f; ARG_UNPACK(f); if (f.isNull()) @@ -530,7 +530,7 @@ startIndex=th->capIndex(startIndex); endIndex=th->capIndex(endIndex); - Array* ret=Class<Array>::getInstanceS(obj->getSystemState()); + Array* ret=Class<Array>::getInstanceSNoArgs(obj->getSystemState()); int j = 0; for(int i=startIndex; i<endIndex; i++) { @@ -557,7 +557,7 @@ ARG_UNPACK_MORE_ALLOWED(startIndex) (deleteCount, th->size()); int totalSize=th->size(); - Array* ret=Class<Array>::getInstanceS(obj->getSystemState()); + Array* ret=Class<Array>::getInstanceSNoArgs(obj->getSystemState()); startIndex=th->capIndex(startIndex); @@ -1109,7 +1109,7 @@ assert_and_throw(args[0]->getObjectType()==T_FUNCTION); func=static_cast<IFunction*>(args[0]); } - Array* arrayRet=Class<Array>::getInstanceS(obj->getSystemState()); + Array* arrayRet=Class<Array>::getInstanceSNoArgs(obj->getSystemState()); uint32_t s = th->size(); for (uint32_t i=0; i < s; i++ )
View file
lightspark.tar.xz/src/scripting/toplevel/Array.h
Changed
@@ -105,6 +105,7 @@ it->second.data->decRef(); } data.clear(); + currentsize=0; return ASObject::destruct(); }
View file
lightspark.tar.xz/src/scripting/toplevel/Date.cpp
Changed
@@ -779,8 +779,8 @@ multiname name(NULL); name.name_type=multiname::NAME_STRING; name.name_s_id=obj->getSystemState()->getUniqueStringId("value"); - name.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); - name.ns.emplace_back(obj->getSystemState(),AS3,NAMESPACE); + name.ns.emplace_back(obj->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + name.ns.emplace_back(obj->getSystemState(),BUILTIN_STRINGS::STRING_AS3NS,NAMESPACE); name.isAttribute = true; obj->setVariableByMultiname(name,abstract_d(obj->getSystemState(),ms),CONST_NOT_ALLOWED); return abstract_d(obj->getSystemState(),ms);
View file
lightspark.tar.xz/src/scripting/toplevel/JSON.cpp
Changed
@@ -544,7 +544,7 @@ { int len = jsonstring.numChars(); pos++; // ignore '[' - ASObject* subobj = Class<Array>::getInstanceS(getSys()); + ASObject* subobj = Class<Array>::getInstanceSNoArgs(getSys()); if (*parent == NULL) *parent = subobj; else
View file
lightspark.tar.xz/src/scripting/toplevel/RegExp.cpp
Changed
@@ -198,7 +198,7 @@ pcre_free(pcreRE); return getSystemState()->getNullRef(); } - Array* a=Class<Array>::getInstanceS(getSystemState()); + Array* a=Class<Array>::getInstanceSNoArgs(getSystemState()); //Push the whole result and the captured strings for(int i=0;i<capturingGroups+1;i++) {
View file
lightspark.tar.xz/src/scripting/toplevel/XML.cpp
Changed
@@ -25,6 +25,7 @@ #include "scripting/argconv.h" #include "abc.h" #include "parsing/amf3_generator.h" +#include <unordered_set> using namespace std; using namespace lightspark; @@ -44,16 +45,16 @@ prettyPrinting = true; } -XML::XML(Class_base* c):ASObject(c,T_OBJECT,SUBTYPE_XML),parentNode(0),nodetype((pugi::xml_node_type)0),isAttribute(false),constructed(false) +XML::XML(Class_base* c):ASObject(c,T_OBJECT,SUBTYPE_XML),parentNode(0),nodetype((pugi::xml_node_type)0),isAttribute(false),nodenamespace_uri(BUILTIN_STRINGS::EMPTY),nodenamespace_prefix(BUILTIN_STRINGS::EMPTY),constructed(false) { } -XML::XML(Class_base* c, const std::string &str):ASObject(c,T_OBJECT,SUBTYPE_XML),parentNode(0),nodetype((pugi::xml_node_type)0),isAttribute(false),constructed(false) +XML::XML(Class_base* c, const std::string &str):ASObject(c,T_OBJECT,SUBTYPE_XML),parentNode(0),nodetype((pugi::xml_node_type)0),isAttribute(false),nodenamespace_uri(BUILTIN_STRINGS::EMPTY),nodenamespace_prefix(BUILTIN_STRINGS::EMPTY),constructed(false) { createTree(buildFromString(str, getParseMode()),false); } -XML::XML(Class_base* c, const pugi::xml_node& _n, XML* parent, bool fromXMLList):ASObject(c,T_OBJECT,SUBTYPE_XML),parentNode(0),nodetype((pugi::xml_node_type)0),isAttribute(false),constructed(false) +XML::XML(Class_base* c, const pugi::xml_node& _n, XML* parent, bool fromXMLList):ASObject(c,T_OBJECT,SUBTYPE_XML),parentNode(0),nodetype((pugi::xml_node_type)0),isAttribute(false),nodenamespace_uri(BUILTIN_STRINGS::EMPTY),nodenamespace_prefix(BUILTIN_STRINGS::EMPTY),constructed(false) { if (parent) { @@ -73,8 +74,8 @@ childrenlist.reset(); nodename.clear(); nodevalue.clear(); - nodenamespace_uri.clear(); - nodenamespace_prefix.clear(); + nodenamespace_uri=BUILTIN_STRINGS::EMPTY; + nodenamespace_prefix=BUILTIN_STRINGS::EMPTY; attributelist.reset(); procinstlist.reset(); namespacedefs.clear(); @@ -294,7 +295,7 @@ return obj->getSystemState()->getNullRef(); else { - ASQName* ret = Class<ASQName>::getInstanceS(obj->getSystemState()); + ASQName* ret = Class<ASQName>::getInstanceSNoArgs(obj->getSystemState()); ret->setByXML(th); return ret; } @@ -308,8 +309,8 @@ XMLVector ret; multiname mname(NULL); name->applyProxyProperty(mname); - th->getDescendantsByQName(name->toString(),mname.isQName() ? obj->getSystemState()->getStringFromUniqueId(mname.ns[0].getImpl(obj->getSystemState()).nameId) : "",mname.isAttribute,ret); - return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); + th->getDescendantsByQName(name->toString(),mname.isQName() ? mname.ns[0].nsNameId : (uint32_t)BUILTIN_STRINGS::EMPTY,mname.isAttribute,ret); + return XMLList::create(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); } ASFUNCTIONBODY(XML,_appendChild) @@ -372,16 +373,16 @@ tiny_string attrname; //see spec for QName handling ARG_UNPACK (attrname); - tiny_string tmpns; + uint32_t tmpns = BUILTIN_STRINGS::EMPTY; if(argslen > 0 && args[0]->is<ASQName>()) { - tmpns= obj->getSystemState()->getStringFromUniqueId(args[0]->as<ASQName>()->getURI()); + tmpns= args[0]->as<ASQName>()->getURI(); attrname = obj->getSystemState()->getStringFromUniqueId(args[0]->as<ASQName>()->getLocalName()); } XMLVector tmp; - XMLList* res = Class<XMLList>::getInstanceS(obj->getSystemState(),tmp,th->getChildrenlist(),multiname(NULL)); + XMLList* res = XMLList::create(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++) @@ -409,14 +410,14 @@ return attributelist.getPtr(); } -const tiny_string XML::toXMLString_internal(bool pretty, tiny_string defaultnsprefix, const char *indent,bool bfirst) +const tiny_string XML::toXMLString_internal(bool pretty, uint32_t defaultnsprefix, const char *indent,bool bfirst) { tiny_string res; - set<tiny_string> seen_prefix; + set<uint32_t> seen_prefix; if (bfirst) { - tiny_string defns = getVm(getSystemState())->getDefaultXMLNamespace(); + uint32_t defns = getVm(getSystemState())->getDefaultXMLNamespaceID(); XML* tmp = this; bool bfound = false; while(tmp) @@ -481,21 +482,21 @@ break; case pugi::node_element: { - tiny_string curprefix = this->nodenamespace_prefix; + uint32_t curprefix = this->nodenamespace_prefix; res += indent; res += "<"; - if (this->nodenamespace_prefix.empty()) + if (this->nodenamespace_prefix == BUILTIN_STRINGS::EMPTY) { - if (defaultnsprefix != "") + if (defaultnsprefix != BUILTIN_STRINGS::EMPTY) { - res += defaultnsprefix; + res += getSystemState()->getStringFromUniqueId(defaultnsprefix); res += ":"; curprefix = defaultnsprefix; } } else { - res += this->nodenamespace_prefix; + res += this->getSystemState()->getStringFromUniqueId(this->nodenamespace_prefix); res += ":"; } res +=this->nodename; @@ -503,24 +504,14 @@ { bool b; _R<Namespace> tmpns = this->namespacedefs[i]; - tiny_string tmpprefix = tmpns->getPrefix(b); - /* - if(tmpprefix == "") - { - seen_prefix.insert(tmpprefix); - res += " xmlns"; - res += "=\""; - res += tmpns->getURI(); - res += "\""; - } - */ - if(tmpprefix == "" || tmpprefix==this->nodenamespace_prefix || seen_prefix.find(tmpprefix)!=seen_prefix.end()) + uint32_t tmpprefix = tmpns->getPrefix(b); + if(tmpprefix == BUILTIN_STRINGS::EMPTY || tmpprefix==this->nodenamespace_prefix || seen_prefix.find(tmpprefix)!=seen_prefix.end()) continue; seen_prefix.insert(tmpprefix); res += " xmlns:"; - res += tmpprefix; + res += getSystemState()->getStringFromUniqueId(tmpprefix); res += "=\""; - res += tmpns->getURI(); + res += getSystemState()->getStringFromUniqueId(tmpns->getURI()); res += "\""; } if (this->parentNode) @@ -534,14 +525,14 @@ { bool b; _R<Namespace> tmpns = tmp->namespacedefs[i]; - tiny_string tmpprefix = tmpns->getPrefix(b); - if(tmpprefix != "" && seen_prefix.find(tmpprefix)==seen_prefix.end()) + uint32_t tmpprefix = tmpns->getPrefix(b); + if(tmpprefix != BUILTIN_STRINGS::EMPTY && seen_prefix.find(tmpprefix)==seen_prefix.end()) { seen_prefix.insert(tmpprefix); res += " xmlns:"; - res += tmpprefix; + res += getSystemState()->getStringFromUniqueId(tmpprefix); res += "=\""; - res += tmpns->getURI(); + res += getSystemState()->getStringFromUniqueId(tmpns->getURI()); res += "\""; } } @@ -551,7 +542,7 @@ break; } } - else if (!curprefix.empty()) + else if (curprefix != BUILTIN_STRINGS::EMPTY) { XML* tmp = this->parentNode.getPtr(); bool bfound = false; @@ -561,7 +552,7 @@ { bool b; _R<Namespace> tmpns = tmp->namespacedefs[i]; - tiny_string tmpprefix = tmpns->getPrefix(b); + uint32_t tmpprefix = tmpns->getPrefix(b); if(tmpprefix == curprefix) { seen_prefix.insert(tmpprefix); @@ -576,27 +567,27 @@ } } } - if (!this->nodenamespace_uri.empty() && - ((this->nodenamespace_prefix.empty() && defaultnsprefix == "") || - (!this->nodenamespace_prefix.empty() && seen_prefix.find(this->nodenamespace_prefix)==seen_prefix.end()))) + if (this->nodenamespace_uri != BUILTIN_STRINGS::EMPTY && + ((this->nodenamespace_prefix==BUILTIN_STRINGS::EMPTY && defaultnsprefix == BUILTIN_STRINGS::EMPTY) || + (this->nodenamespace_prefix!=BUILTIN_STRINGS::EMPTY && seen_prefix.find(this->nodenamespace_prefix)==seen_prefix.end()))) { - if (!this->nodenamespace_prefix.empty()) + if (this->nodenamespace_prefix!=BUILTIN_STRINGS::EMPTY) { seen_prefix.insert(this->nodenamespace_prefix); res += " xmlns:"; - res += this->nodenamespace_prefix; + res += getSystemState()->getStringFromUniqueId(this->nodenamespace_prefix); } else res += " xmlns"; res += "=\""; - res += this->nodenamespace_uri; + res += getSystemState()->getStringFromUniqueId(this->nodenamespace_uri); res += "\""; } - else if (defaultnsprefix != "" && seen_prefix.find(defaultnsprefix)==seen_prefix.end()) + else if (defaultnsprefix != BUILTIN_STRINGS::EMPTY && seen_prefix.find(defaultnsprefix)==seen_prefix.end()) { seen_prefix.insert(defaultnsprefix); res += " xmlns:"; - res += defaultnsprefix; + res += getSystemState()->getStringFromUniqueId(defaultnsprefix); res += "=\""; res += getVm(getSystemState())->getDefaultXMLNamespace(); res += "\""; @@ -607,9 +598,9 @@ { _R<XML> attr = *it; res += " "; - if (attr->nodenamespace_prefix != "") + if (attr->nodenamespace_prefix != BUILTIN_STRINGS::EMPTY) { - res += attr->nodenamespace_prefix; + res += getSystemState()->getStringFromUniqueId(attr->nodenamespace_prefix); res += ":"; } res += attr->nodename; @@ -655,17 +646,17 @@ res += indent; } res += "</"; - if (this->nodenamespace_prefix.empty()) + if (this->nodenamespace_prefix == BUILTIN_STRINGS::EMPTY) { - if (defaultnsprefix != "") + if (defaultnsprefix != BUILTIN_STRINGS::EMPTY) { - res += defaultnsprefix; + res += getSystemState()->getStringFromUniqueId(defaultnsprefix); res += ":"; } } else { - res += this->nodenamespace_prefix; + res += getSystemState()->getStringFromUniqueId(this->nodenamespace_prefix); res += ":"; } res += this->nodename; @@ -729,13 +720,13 @@ multiname mname(NULL); mname.name_s_id=obj->getSystemState()->getUniqueStringId(arg0); mname.name_type=multiname::NAME_STRING; - mname.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); + mname.ns.emplace_back(obj->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); mname.isAttribute=false; if(XML::isValidMultiname(obj->getSystemState(),mname, index)) th->childrenImpl(ret, index); else th->childrenImpl(ret, arg0); - XMLList* retObj=Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),mname); + XMLList* retObj=XMLList::create(obj->getSystemState(),ret,th->getChildrenlist(),mname); return retObj; } @@ -748,8 +739,8 @@ multiname mname(NULL); mname.name_s_id=BUILTIN_STRINGS::STRING_WILDCARD; mname.name_type=multiname::NAME_STRING; - mname.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); - XMLList* retObj=Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),mname); + mname.ns.emplace_back(obj->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + XMLList* retObj=XMLList::create(obj->getSystemState(),ret,th->getChildrenlist(),mname); return retObj; } @@ -809,7 +800,7 @@ ARG_UNPACK; XMLVector ret; th->getText(ret); - return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); + return XMLList::create(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); } ASFUNCTIONBODY(XML,elements) @@ -822,7 +813,7 @@ name=""; th->getElementNodes(name, ret); - return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); + return XMLList::create(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); } void XML::getElementNodes(const tiny_string& name, XMLVector& foundElements) @@ -843,8 +834,8 @@ ASFUNCTIONBODY(XML,inScopeNamespaces) { XML *th = obj->as<XML>(); - Array *namespaces = Class<Array>::getInstanceS(obj->getSystemState()); - set<tiny_string> seen_prefix; + Array *namespaces = Class<Array>::getInstanceSNoArgs(obj->getSystemState()); + set<uint32_t> seen_prefix; XML* tmp = th; while(tmp) @@ -875,8 +866,8 @@ ARG_UNPACK(newNamespace); - tiny_string ns_uri; - tiny_string ns_prefix; + uint32_t ns_uri = BUILTIN_STRINGS::EMPTY; + uint32_t ns_prefix = BUILTIN_STRINGS::EMPTY; if (newNamespace->is<Namespace>()) { Namespace* tmpns = newNamespace->as<Namespace>(); @@ -886,12 +877,12 @@ } else if (newNamespace->is<ASQName>()) { - ns_uri = obj->getSystemState()->getStringFromUniqueId(newNamespace->as<ASQName>()->getURI()); + ns_uri = newNamespace->as<ASQName>()->getURI(); } else - ns_uri = newNamespace->toString(); + ns_uri = th->getSystemState()->getUniqueStringId(newNamespace->toString()); if (th->nodenamespace_prefix == ns_prefix) - th->nodenamespace_prefix=""; + th->nodenamespace_prefix=BUILTIN_STRINGS::EMPTY; for (uint32_t i = 0; i < th->namespacedefs.size(); i++) { bool b; @@ -954,9 +945,9 @@ { bool b; _R<Namespace> tmpns = th->namespacedefs[i]; - if (tmpns->getPrefix(b) == prefix) + if (tmpns->getPrefix(b) == obj->getSystemState()->getUniqueStringId(prefix)) { - return Class<Namespace>::getInstanceS(obj->getSystemState(),tmpns->getURI(), prefix); + return Class<Namespace>::getInstanceS(obj->getSystemState(),tmpns->getURI(), obj->getSystemState()->getUniqueStringId(prefix)); } } return obj->getSystemState()->getUndefinedRef(); @@ -1005,18 +996,18 @@ return NULL; tiny_string localname; - tiny_string ns_uri; - tiny_string ns_prefix = th->nodenamespace_prefix; + uint32_t ns_uri = BUILTIN_STRINGS::EMPTY; + uint32_t ns_prefix = th->nodenamespace_prefix; if(newName->is<ASQName>()) { ASQName *qname=newName->as<ASQName>(); localname=obj->getSystemState()->getStringFromUniqueId(qname->getLocalName()); - ns_uri=obj->getSystemState()->getStringFromUniqueId(qname->getURI()); + ns_uri=qname->getURI(); } else if (!newName->is<Undefined>()) { localname=newName->toString(); - ns_prefix= ""; + ns_prefix= BUILTIN_STRINGS::EMPTY; } th->setLocalName(localname); @@ -1035,8 +1026,8 @@ th->nodetype==pugi::node_comment || th->nodetype==pugi::node_pi) return NULL; - tiny_string ns_uri; - tiny_string ns_prefix; + uint32_t ns_uri = BUILTIN_STRINGS::EMPTY; + uint32_t ns_prefix = BUILTIN_STRINGS::EMPTY; if(newNamespace->is<Namespace>()) { Namespace *ns=newNamespace->as<Namespace>(); @@ -1047,7 +1038,7 @@ else if(newNamespace->is<ASQName>()) { ASQName *qname=newNamespace->as<ASQName>(); - ns_uri=obj->getSystemState()->getStringFromUniqueId(qname->getURI()); + ns_uri=qname->getURI(); for (uint32_t i = 0; i < th->namespacedefs.size(); i++) { bool b; @@ -1061,7 +1052,7 @@ } else if (!newNamespace->is<Undefined>()) { - ns_uri=newNamespace->toString(); + ns_uri=th->getSystemState()->getUniqueStringId(newNamespace->toString()); for (uint32_t i = 0; i < th->namespacedefs.size(); i++) { bool b; @@ -1093,7 +1084,7 @@ return NULL; } -void XML::setNamespace(const tiny_string& ns_uri, const tiny_string& ns_prefix) +void XML::setNamespace(uint32_t ns_uri, uint32_t ns_prefix) { this->nodenamespace_prefix = ns_prefix; this->nodenamespace_uri = ns_uri; @@ -1199,7 +1190,7 @@ } -void XML::getDescendantsByQName(const tiny_string& name, const tiny_string& ns, bool bIsAttribute, XMLVector& ret) +void XML::getDescendantsByQName(const tiny_string& name, uint32_t ns, bool bIsAttribute, XMLVector& ret) const { if (!constructed) return; @@ -1208,7 +1199,7 @@ for (uint32_t i = 0; i < attributelist->nodes.size(); i++) { _R<XML> child= attributelist->nodes[i]; - if(name=="" || name=="*" || (name == child->nodename && (ns == "*" || ns == child->nodenamespace_uri))) + if(name=="" || name=="*" || (name == child->nodename && (ns == BUILTIN_STRINGS::STRING_WILDCARD || ns == child->nodenamespace_uri))) { child->incRef(); ret.push_back(child); @@ -1220,7 +1211,7 @@ for (uint32_t i = 0; i < childrenlist->nodes.size(); i++) { _R<XML> child= childrenlist->nodes[i]; - if(!bIsAttribute && (name=="" || name=="*" || (name == child->nodename && (ns == "*" || ns == child->nodenamespace_uri)))) + if(!bIsAttribute && (name=="" || name=="*" || (name == child->nodename && (ns == BUILTIN_STRINGS::STRING_WILDCARD || ns == child->nodenamespace_uri)))) { child->incRef(); ret.push_back(child); @@ -1233,70 +1224,98 @@ { multiname mn(NULL); mn.name_type=multiname::NAME_STRING; - mn.ns.emplace_back(getSystemState(),"",NAMESPACE); - mn.ns.emplace_back(getSystemState(),AS3,NAMESPACE); + mn.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + mn.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::STRING_AS3NS,NAMESPACE); mn.isAttribute = true; - return getAttributesByMultiname(mn); + return getAttributesByMultiname(mn,""); } -XML::XMLVector XML::getAttributesByMultiname(const multiname& name) +XML::XMLVector XML::getAttributesByMultiname(const multiname& name, const tiny_string& normalizedName) const { XMLVector ret; if (attributelist.isNull()) return ret; - tiny_string defns = "|"; - defns += getVm(getSystemState())->getDefaultXMLNamespace(); - defns += "|"; - tiny_string 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()) + uint32_t defns = getVm(getSystemState())->getDefaultXMLNamespaceID(); + std::unordered_set<uint32_t> namespace_uri; + bool hasDefaultNS = false; + auto it = name.ns.cbegin(); + while (it != name.ns.cend()) { - nsNameAndKindImpl ns=name.ns[i].getImpl(getSystemState()); - if (ns.kind==NAMESPACE && ns.nameId != getSystemState()->getUniqueStringId(AS3)) + switch (it->nsId) { - if (ns.nameId == BUILTIN_STRINGS::EMPTY) - namespace_uri +=getVm(getSystemState())->getDefaultXMLNamespace(); - else - namespace_uri +=getSystemState()->getStringFromUniqueId(ns.nameId); - namespace_uri += "|"; + case BUILTIN_NAMESPACES::EMPTY_NS: + namespace_uri.insert(defns); + hasDefaultNS=true; + break; + case BUILTIN_NAMESPACES::AS3_NS: + break; + default: + { + if (it->kind==NAMESPACE) + { + if (it->nsNameId == BUILTIN_STRINGS::EMPTY) + { + hasDefaultNS=true; + namespace_uri.insert(defns); + } + else + namespace_uri.insert(it->nsNameId); + } + break; + } } - i++; + ++it; } - for (uint32_t i = 0; i < attributelist->nodes.size(); i++) + const XMLList::XMLListVector nodes = attributelist->nodes; + if (normalizedName.empty()) { - _R<XML> child= attributelist->nodes[i]; - tiny_string childnamespace_uri = "|"; - childnamespace_uri += child->nodenamespace_uri; - childnamespace_uri += "|"; - - bool bmatch = ( - ((normalizedName=="") && - ((namespace_uri.find(defns)!= tiny_string::npos) || - (namespace_uri=="|*|") || - (namespace_uri.find(childnamespace_uri) != tiny_string::npos) - ) - )|| - ((normalizedName=="*") && - ((namespace_uri.find(defns)!= tiny_string::npos) || - (namespace_uri=="|*|") || - (namespace_uri.find(childnamespace_uri) != tiny_string::npos) - ) - )|| - ((normalizedName==child->nodename) && - ( - (namespace_uri=="|*|") || - (namespace_uri=="|" && childnamespace_uri=="||") || - (namespace_uri.find(childnamespace_uri) != tiny_string::npos) - ) - ) - ); - if(bmatch) + for (auto child = nodes.cbegin(); child != nodes.cend(); child++) { - child->incRef(); - ret.push_back(child); + uint32_t childnamespace_uri = (*child)->nodenamespace_uri; + + bool bmatch =(hasDefaultNS|| + (namespace_uri.find(BUILTIN_STRINGS::STRING_WILDCARD)!= namespace_uri.end()) || + (namespace_uri.find(childnamespace_uri) != namespace_uri.end()) + ); + if(bmatch) + { + (*child)->incRef(); + ret.push_back(*child); + } + } + } + else if (normalizedName=="*") + { + for (auto child = nodes.cbegin(); child != nodes.cend(); child++) + { + uint32_t childnamespace_uri = (*child)->nodenamespace_uri; + + bool bmatch =(hasDefaultNS|| + (namespace_uri.find(BUILTIN_STRINGS::STRING_WILDCARD)!= namespace_uri.end()) || + (namespace_uri.find(childnamespace_uri) != namespace_uri.end()) + ); + if(bmatch) + { + (*child)->incRef(); + ret.push_back(*child); + } + } + } + else + { + for (auto child = nodes.cbegin(); child != nodes.cend(); child++) + { + uint32_t childnamespace_uri = (*child)->nodenamespace_uri; + + bool bmatch =(normalizedName==(*child)->nodename) && + ((namespace_uri.find(BUILTIN_STRINGS::STRING_WILDCARD)!= namespace_uri.end()) || + (namespace_uri.size() == 0 && childnamespace_uri == BUILTIN_STRINGS::EMPTY) || + (namespace_uri.find(childnamespace_uri) != namespace_uri.end()) + ); + if(bmatch) + { + (*child)->incRef(); + ret.push_back(*child); + } } } return ret; @@ -1304,63 +1323,99 @@ XML::XMLVector XML::getValuesByMultiname(_NR<XMLList> nodelist, const multiname& name) { XMLVector ret; - tiny_string defns = "|"; - if (nodenamespace_prefix == "" && nodenamespace_uri != "") - defns += nodenamespace_uri; + uint32_t defns = BUILTIN_STRINGS::EMPTY; + if (nodenamespace_prefix == BUILTIN_STRINGS::EMPTY && nodenamespace_uri != BUILTIN_STRINGS::EMPTY) + defns = nodenamespace_uri; else - defns += getVm(getSystemState())->getDefaultXMLNamespace(); - defns += "|"; + defns = getVm(getSystemState())->getDefaultXMLNamespaceID(); tiny_string 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()) + + std::unordered_set<uint32_t> namespace_uri; + bool hasDefaultNS = false; + auto it = name.ns.cbegin(); + while (it != name.ns.cend()) { - nsNameAndKindImpl ns=name.ns[i].getImpl(getSystemState()); - if (ns.kind==NAMESPACE && ns.nameId != getSystemState()->getUniqueStringId(AS3)) + switch (it->nsId) { - if (ns.nameId == BUILTIN_STRINGS::EMPTY) - namespace_uri +=getVm(getSystemState())->getDefaultXMLNamespace(); - else - namespace_uri +=getSystemState()->getStringFromUniqueId(ns.nameId); - namespace_uri += "|"; - } - i++; - } - - for (uint32_t i = 0; i < nodelist->nodes.size(); i++) - { - _R<XML> child= nodelist->nodes[i]; - tiny_string childnamespace_uri = "|"; - childnamespace_uri += child->nodenamespace_uri; - childnamespace_uri += "|"; - bool bmatch = ( - ((normalizedName=="") && - ((namespace_uri.find(defns)!= tiny_string::npos) || - (namespace_uri=="|*|") || - (namespace_uri.find(childnamespace_uri) != tiny_string::npos) - ) - )|| - ((normalizedName=="*") && - ((namespace_uri.find(defns)!= tiny_string::npos) || - (namespace_uri=="|*|") || - (namespace_uri.find(childnamespace_uri) != tiny_string::npos) - ) - )|| - ((normalizedName==child->nodename) && - ((namespace_uri.find(defns)!= tiny_string::npos) || - (namespace_uri=="|*|") || - (namespace_uri=="|" && childnamespace_uri=="||") || - (namespace_uri.find(childnamespace_uri) != tiny_string::npos) - ) - ) - ); - if(bmatch) + case BUILTIN_NAMESPACES::EMPTY_NS: + namespace_uri.insert(defns); + hasDefaultNS=true; + break; + case BUILTIN_NAMESPACES::AS3_NS: + break; + default: + { + if (it->kind==NAMESPACE) + { + if (it->nsNameId == BUILTIN_STRINGS::EMPTY) + { + hasDefaultNS=true; + namespace_uri.insert(defns); + } + else + namespace_uri.insert(it->nsNameId); + } + break; + } + } + ++it; + } + + const XMLList::XMLListVector& nodes = nodelist->nodes; + if (normalizedName.empty()) + { + for (auto child = nodes.cbegin(); child != nodes.cend(); child++) { - child->incRef(); - ret.push_back(child); + uint32_t childnamespace_uri = (*child)->nodenamespace_uri; + + bool bmatch =(hasDefaultNS|| + (namespace_uri.find(BUILTIN_STRINGS::STRING_WILDCARD)!= namespace_uri.end()) || + (namespace_uri.find(childnamespace_uri) != namespace_uri.end()) + ); + if(bmatch) + { + (*child)->incRef(); + ret.push_back(*child); + } + } + } + else if (normalizedName=="*") + { + for (auto child = nodes.cbegin(); child != nodes.cend(); child++) + { + uint32_t childnamespace_uri = (*child)->nodenamespace_uri; + + bool bmatch =(hasDefaultNS|| + (namespace_uri.find(BUILTIN_STRINGS::STRING_WILDCARD)!= namespace_uri.end()) || + (namespace_uri.find(childnamespace_uri) != namespace_uri.end()) + ); + if(bmatch) + { + (*child)->incRef(); + ret.push_back(*child); + } + } + } + else + { + for (auto child = nodes.cbegin(); child != nodes.cend(); child++) + { + uint32_t childnamespace_uri = (*child)->nodenamespace_uri; + + bool bmatch = (normalizedName==(*child)->nodename) && + (hasDefaultNS|| + (namespace_uri.find(BUILTIN_STRINGS::STRING_WILDCARD)!= namespace_uri.end()) || + (namespace_uri.size() == 0 && childnamespace_uri == BUILTIN_STRINGS::EMPTY) || + (namespace_uri.find(childnamespace_uri) != namespace_uri.end()) + ); + if(bmatch) + { + (*child)->incRef(); + ret.push_back(*child); + } } } return ret; @@ -1390,13 +1445,14 @@ tiny_string normalizedName=name.normalizedName(getSystemState()); if(!normalizedName.empty() && normalizedName.charAt(0)=='@') { + normalizedName = normalizedName.substr(1,normalizedName.end()); isAttr=true; } if(isAttr) { //Lookup attribute - const XMLVector& attributes=getAttributesByMultiname(name); - return _MNR(Class<XMLList>::getInstanceS(getSystemState(),attributes,attributelist.getPtr(),name)); + const XMLVector& attributes=getAttributesByMultiname(name,normalizedName); + return _MNR(XMLList::create(getSystemState(),attributes,attributelist.getPtr(),name)); } else if(XML::isValidMultiname(getSystemState(),name,index)) { @@ -1419,8 +1475,8 @@ multiname mname(NULL); mname.name_s_id=getSystemState()->getUniqueStringId("*"); mname.name_type=multiname::NAME_STRING; - mname.ns.emplace_back(getSystemState(),"",NAMESPACE); - XMLList* retObj=Class<XMLList>::getInstanceS(getSystemState(),ret,this->getChildrenlist(),mname); + mname.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + XMLList* retObj=XMLList::create(getSystemState(),ret,this->getChildrenlist(),mname); return _MNR(retObj); } else @@ -1429,7 +1485,7 @@ if(ret.empty() && (opt & XML_STRICT)!=0) return NullRef; - _R<XMLList> ch =_MNR(Class<XMLList>::getInstanceS(getSystemState(),ret,this->getChildrenlist(),name)); + _R<XMLList> ch =_MNR(XMLList::create(getSystemState(),ret,this->getChildrenlist(),name)); return ch; } } @@ -1443,22 +1499,21 @@ const tiny_string normalizedName=name.normalizedName(getSystemState()); //Only the first namespace is used, is this right? - tiny_string ns_uri; - tiny_string ns_prefix; + uint32_t ns_uri = BUILTIN_STRINGS::EMPTY; + uint32_t ns_prefix = BUILTIN_STRINGS::EMPTY; if(name.ns.size() > 0 && !name.ns[0].hasEmptyName()) { - nsNameAndKindImpl ns=name.ns[0].getImpl(getSystemState()); - if (ns.kind==NAMESPACE) + if (name.ns[0].kind==NAMESPACE) { - ns_uri=getSystemState()->getStringFromUniqueId(ns.nameId); + ns_uri=name.ns[0].nsNameId; ns_prefix=getNamespacePrefixByURI(ns_uri); } } // namespace set by "default xml namespace = ..." - if (ns_uri.empty() && ns_prefix.empty()) + if (ns_uri == BUILTIN_STRINGS::EMPTY && ns_prefix == BUILTIN_STRINGS::EMPTY) { - ns_uri = getVm(getSystemState())->getDefaultXMLNamespace(); + ns_uri = getVm(getSystemState())->getDefaultXMLNamespaceID(); } const char *buf=normalizedName.raw_buf(); @@ -1547,8 +1602,8 @@ tmp->incRef(); tmp->nodetype = pugi::node_pcdata; tmp->nodename = "text"; - tmp->nodenamespace_uri = ""; - tmp->nodenamespace_prefix = ""; + tmp->nodenamespace_uri = BUILTIN_STRINGS::EMPTY; + tmp->nodenamespace_prefix = BUILTIN_STRINGS::EMPTY; tmp->nodevalue = o->toString(); tmp->constructed = true; tmpnode->childrenlist->clear(); @@ -1606,26 +1661,26 @@ else { tiny_string tmpstr = "<"; - if (!this->nodenamespace_prefix.empty()) + if (this->nodenamespace_prefix!=BUILTIN_STRINGS::EMPTY) { tmpstr += ns_prefix; tmpstr += ":"; } tmpstr += normalizedName; - if (!ns_prefix.empty() && !ns_uri.empty()) + if (ns_prefix!=BUILTIN_STRINGS::EMPTY && ns_uri!= BUILTIN_STRINGS::EMPTY) { tmpstr += " xmlns:"; - tmpstr += ns_prefix; + tmpstr += getSystemState()->getStringFromUniqueId(ns_prefix); tmpstr += "=\""; - tmpstr += ns_uri; + tmpstr += getSystemState()->getStringFromUniqueId(ns_uri); tmpstr += "\""; } tmpstr +=">"; tmpstr += encodeToXML(o->toString(),false); tmpstr +="</"; - if (!ns_prefix.empty()) + if (ns_prefix != BUILTIN_STRINGS::EMPTY) { - tmpstr += ns_prefix; + tmpstr += getSystemState()->getStringFromUniqueId(ns_prefix); tmpstr += ":"; } tmpstr += normalizedName; @@ -1648,20 +1703,19 @@ return false; //Only the first namespace is used, is this right? - tiny_string ns_uri; - tiny_string ns_prefix; + uint32_t ns_uri = BUILTIN_STRINGS::EMPTY; + uint32_t ns_prefix = BUILTIN_STRINGS::EMPTY; if(name.ns.size() > 0 && !name.ns[0].hasEmptyName()) { - nsNameAndKindImpl ns=name.ns[0].getImpl(getSystemState()); - assert_and_throw(ns.kind==NAMESPACE); - ns_uri=getSystemState()->getStringFromUniqueId(ns.nameId); + assert_and_throw(name.ns[0].kind==NAMESPACE); + ns_uri=name.ns[0].nsNameId; ns_prefix=getNamespacePrefixByURI(ns_uri); } // namespace set by "default xml namespace = ..." - if (ns_uri.empty() && ns_prefix.empty()) + if (ns_uri==BUILTIN_STRINGS::EMPTY && ns_prefix==BUILTIN_STRINGS::EMPTY) { - ns_uri = getVm(getSystemState())->getDefaultXMLNamespace(); + ns_uri = getVm(getSystemState())->getDefaultXMLNamespaceID(); } bool isAttr=name.isAttribute; @@ -1699,7 +1753,7 @@ { _R<XML> child= childrenlist->nodes[i]; bool name_match=(child->nodename == buf); - bool ns_match=ns_uri.empty() || + bool ns_match=ns_uri==BUILTIN_STRINGS::EMPTY || (child->nodenamespace_uri == ns_uri); if(name_match && ns_match) return true; @@ -1715,18 +1769,17 @@ if(name.isAttribute) { //Only the first namespace is used, is this right? - tiny_string ns_uri; - tiny_string ns_prefix; + uint32_t ns_uri = BUILTIN_STRINGS::EMPTY; + uint32_t ns_prefix = BUILTIN_STRINGS::EMPTY; if(name.ns.size() > 0 && !name.ns[0].hasEmptyName()) { - nsNameAndKindImpl ns=name.ns[0].getImpl(getSystemState()); - assert_and_throw(ns.kind==NAMESPACE); - ns_uri=getSystemState()->getStringFromUniqueId(ns.nameId); + assert_and_throw(name.ns[0].kind==NAMESPACE); + ns_uri=name.ns[0].nsNameId; ns_prefix=getNamespacePrefixByURI(ns_uri); } - if (ns_uri.empty() && ns_prefix.empty()) + if (ns_uri == BUILTIN_STRINGS::EMPTY && ns_prefix == BUILTIN_STRINGS::EMPTY) { - ns_uri = getVm(getSystemState())->getDefaultXMLNamespace(); + ns_uri = getVm(getSystemState())->getDefaultXMLNamespaceID(); } if (!attributelist.isNull() && attributelist->nodes.size() > 0) { @@ -1735,8 +1788,8 @@ { it--; _R<XML> attr = *it; - if ((ns_uri=="" && name.normalizedName(getSystemState()) == "") || - (ns_uri=="" && name.normalizedName(getSystemState()) == attr->nodename) || + if ((ns_uri==BUILTIN_STRINGS::EMPTY && name.normalizedName(getSystemState()) == "") || + (ns_uri==BUILTIN_STRINGS::EMPTY && name.normalizedName(getSystemState()) == attr->nodename) || (attr->nodenamespace_uri == ns_uri && name.normalizedName(getSystemState()) == "") || (attr->nodenamespace_uri == ns_uri && attr->nodename == name.normalizedName(getSystemState()))) { @@ -1753,12 +1806,11 @@ else { //Only the first namespace is used, is this right? - tiny_string ns_uri; + uint32_t ns_uri = BUILTIN_STRINGS::EMPTY; if(name.ns.size() > 0 && !name.ns[0].hasEmptyName()) { - nsNameAndKindImpl ns=name.ns[0].getImpl(getSystemState()); - assert_and_throw(ns.kind==NAMESPACE); - ns_uri=getSystemState()->getStringFromUniqueId(ns.nameId); + assert_and_throw(name.ns[0].kind==NAMESPACE); + ns_uri=name.ns[0].nsNameId; } if (!childrenlist.isNull() && childrenlist->nodes.size() > 0) { @@ -1767,8 +1819,8 @@ { it--; _R<XML> node = *it; - if ((ns_uri=="" && name.normalizedName(getSystemState()) == "") || - (ns_uri=="" && name.normalizedName(getSystemState()) == node->nodename) || + if ((ns_uri==BUILTIN_STRINGS::EMPTY && name.normalizedName(getSystemState()) == "") || + (ns_uri==BUILTIN_STRINGS::EMPTY && name.normalizedName(getSystemState()) == node->nodename) || (node->nodenamespace_uri == ns_uri && name.normalizedName(getSystemState()) == "") || (node->nodenamespace_uri == ns_uri && node->nodename == name.normalizedName(getSystemState()))) { @@ -1797,9 +1849,9 @@ return validIndex; } -tiny_string XML::getNamespacePrefixByURI(const tiny_string& uri, bool create) +uint32_t XML::getNamespacePrefixByURI(uint32_t uri, bool create) { - tiny_string prefix; + uint32_t prefix = BUILTIN_STRINGS::EMPTY; bool found=false; @@ -1886,8 +1938,8 @@ ASObject* res = Class<ASObject>::getInstanceS(getSys()); multiname mn(NULL); mn.name_type=multiname::NAME_STRING; - mn.ns.emplace_back(res->getSystemState(),"",NAMESPACE); - mn.ns.emplace_back(res->getSystemState(),AS3,NAMESPACE); + mn.ns.emplace_back(res->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + mn.ns.emplace_back(res->getSystemState(),BUILTIN_STRINGS::STRING_AS3NS,NAMESPACE); mn.isAttribute = true; mn.name_s_id=res->getSystemState()->getUniqueStringId("ignoreComments"); @@ -1918,8 +1970,8 @@ } multiname mn(NULL); mn.name_type=multiname::NAME_STRING; - mn.ns.emplace_back(arg0->getSystemState(),"",NAMESPACE); - mn.ns.emplace_back(arg0->getSystemState(),AS3,NAMESPACE); + mn.ns.emplace_back(arg0->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + mn.ns.emplace_back(arg0->getSystemState(),BUILTIN_STRINGS::STRING_AS3NS,NAMESPACE); mn.isAttribute = true; _NR<ASObject> o; @@ -1964,8 +2016,8 @@ ASObject* res = Class<ASObject>::getInstanceS(getSys()); multiname mn(NULL); mn.name_type=multiname::NAME_STRING; - mn.ns.emplace_back(res->getSystemState(),"",NAMESPACE); - mn.ns.emplace_back(res->getSystemState(),AS3,NAMESPACE); + mn.ns.emplace_back(res->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + mn.ns.emplace_back(res->getSystemState(),BUILTIN_STRINGS::STRING_AS3NS,NAMESPACE); mn.isAttribute = true; mn.name_s_id=res->getSystemState()->getUniqueStringId("ignoreComments"); @@ -2177,12 +2229,12 @@ ASFUNCTIONBODY(XML,namespaceDeclarations) { XML *th = obj->as<XML>(); - Array *namespaces = Class<Array>::getInstanceS(obj->getSystemState()); + Array *namespaces = Class<Array>::getInstanceSNoArgs(obj->getSystemState()); for (uint32_t i = 0; i < th->namespacedefs.size(); i++) { _R<Namespace> tmpns = th->namespacedefs[i]; bool b; - if (tmpns->getPrefix(b) != "") + if (tmpns->getPrefix(b) != BUILTIN_STRINGS::EMPTY) { tmpns->incRef(); namespaces->push(tmpns); @@ -2200,7 +2252,7 @@ if (arg1->is<Namespace>()) ns = arg1->as<Namespace>(); else - ns = Class<Namespace>::getInstanceS(obj->getSystemState(),arg1->toString(), ""); + ns = Class<Namespace>::getInstanceS(obj->getSystemState(),arg1->toStringId(), BUILTIN_STRINGS::EMPTY); th->RemoveNamespace(ns); th->incRef(); @@ -2210,8 +2262,8 @@ { if (this->nodenamespace_uri == ns->getURI()) { - this->nodenamespace_uri = ""; - this->nodenamespace_prefix = ""; + this->nodenamespace_uri = BUILTIN_STRINGS::EMPTY; + this->nodenamespace_prefix = BUILTIN_STRINGS::EMPTY; } for (auto it = namespacedefs.begin(); it != namespacedefs.end(); it++) { @@ -2238,7 +2290,7 @@ ARG_UNPACK(name,"*"); XMLVector ret; th->getComments(ret); - return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); + return XMLList::create(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); } void XML::getComments(XMLVector& ret) { @@ -2262,7 +2314,7 @@ ARG_UNPACK(name,"*"); XMLVector ret; th->getprocessingInstructions(ret,name); - return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); + return XMLList::create(obj->getSystemState(),ret,th->getChildrenlist(),multiname(NULL)); } void XML::getprocessingInstructions(XMLVector& ret, tiny_string name) { @@ -2294,9 +2346,9 @@ { multiname name(NULL); name.name_type=multiname::NAME_STRING; - 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.name_s_id=args[0]->toStringId(); + name.ns.emplace_back(obj->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); + name.ns.emplace_back(obj->getSystemState(),BUILTIN_STRINGS::STRING_AS3NS,NAMESPACE); name.isAttribute=false; ret=obj->hasPropertyByMultiname(name, true, true); } @@ -2625,10 +2677,10 @@ node->nodetype = srcnode.type(); node->nodename = srcnode.name(); node->nodevalue = srcnode.value(); - if (!node->parentNode.isNull() && node->parentNode->nodenamespace_prefix == "") + if (!node->parentNode.isNull() && node->parentNode->nodenamespace_prefix == BUILTIN_STRINGS::EMPTY) node->nodenamespace_uri = node->parentNode->nodenamespace_uri; else - node->nodenamespace_uri = getVm(node->getSystemState())->getDefaultXMLNamespace(); + node->nodenamespace_uri = getVm(node->getSystemState())->getDefaultXMLNamespaceID(); if (ignoreWhitespace && node->nodetype == pugi::node_pcdata) node->nodevalue = node->removeWhitespace(node->nodevalue); node->attributelist = _MR(Class<XMLList>::getInstanceSNoArgs(node->getSystemState())); @@ -2638,16 +2690,16 @@ tiny_string aname = tiny_string(itattr->name(),true); if(aname == "xmlns") { - tiny_string uri = itattr->value(); - Namespace* ns = Class<Namespace>::getInstanceS(node->getSystemState(),uri,""); + uint32_t uri = node->getSystemState()->getUniqueStringId(itattr->value()); + Namespace* ns = Class<Namespace>::getInstanceS(node->getSystemState(),uri,BUILTIN_STRINGS::EMPTY); node->namespacedefs.push_back(_MR(ns)); node->nodenamespace_uri = uri; } else if (aname.numBytes() >= 6 && aname.substr_bytes(0,6) == "xmlns:") { - tiny_string uri = itattr->value(); + uint32_t uri = node->getSystemState()->getUniqueStringId(itattr->value()); tiny_string prefix = aname.substr(6,aname.end()); - Namespace* ns = Class<Namespace>::getInstanceS(node->getSystemState(),uri,prefix); + Namespace* ns = Class<Namespace>::getInstanceS(node->getSystemState(),uri,node->getSystemState()->getUniqueStringId(prefix)); node->namespacedefs.push_back(_MR(ns)); } } @@ -2655,10 +2707,10 @@ if (pos != tiny_string::npos) { // nodename has namespace - node->nodenamespace_prefix = node->nodename.substr(0,pos); + node->nodenamespace_prefix = node->getSystemState()->getUniqueStringId(node->nodename.substr(0,pos)); node->nodename = node->nodename.substr(pos+1,node->nodename.end()); - if (node->nodenamespace_prefix == "xml") - node->nodenamespace_uri = "http://www.w3.org/XML/1998/namespace"; + if (node->nodenamespace_prefix == BUILTIN_STRINGS::STRING_XML) + node->nodenamespace_uri = BUILTIN_STRINGS::STRING_NAMESPACENS; else { XML* tmpnode = node; @@ -2694,14 +2746,14 @@ tmp->nodetype = pugi::node_null; tmp->isAttribute = true; tmp->nodename = aname; - tmp->nodenamespace_uri = getVm(node->getSystemState())->getDefaultXMLNamespace(); + tmp->nodenamespace_uri = getVm(node->getSystemState())->getDefaultXMLNamespaceID(); pos = tmp->nodename.find(":"); if (pos != tiny_string::npos) { - tmp->nodenamespace_prefix = tmp->nodename.substr(0,pos); + tmp->nodenamespace_prefix = node->getSystemState()->getUniqueStringId(tmp->nodename.substr(0,pos)); tmp->nodename = tmp->nodename.substr(pos+1,tmp->nodename.end()); - if (tmp->nodenamespace_prefix == "xml") - tmp->nodenamespace_uri = "http://www.w3.org/XML/1998/namespace"; + if (tmp->nodenamespace_prefix == BUILTIN_STRINGS::STRING_XML) + tmp->nodenamespace_uri = BUILTIN_STRINGS::STRING_NAMESPACENS; else { XML* tmpnode = node; @@ -2797,7 +2849,7 @@ if (propertyName->is<ASQName>()) { name.name_s_id=propertyName->as<ASQName>()->getLocalName(); - name.ns.emplace_back(obj->getSystemState(),obj->getSystemState()->getStringFromUniqueId(propertyName->as<ASQName>()->getURI()),NAMESPACE); + name.ns.emplace_back(obj->getSystemState(),propertyName->as<ASQName>()->getURI(),NAMESPACE); } else if (propertyName->toString() == "*") { @@ -2826,7 +2878,7 @@ else { name.name_s_id=obj->getSystemState()->getUniqueStringId(propertyName->toString()); - name.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); + name.ns.emplace_back(obj->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); } uint32_t index=0; if(XML::isValidMultiname(obj->getSystemState(),name,index))
View file
lightspark.tar.xz/src/scripting/toplevel/XML.h
Changed
@@ -39,8 +39,8 @@ bool isAttribute; tiny_string nodename; tiny_string nodevalue; - tiny_string nodenamespace_uri; - tiny_string nodenamespace_prefix; + uint32_t nodenamespace_uri; + uint32_t nodenamespace_prefix; _NR<XMLList> attributelist; _NR<XMLList> procinstlist; NSVector namespacedefs; @@ -53,7 +53,7 @@ bool constructed; bool nodesEqual(XML *a, XML *b) const; XMLVector getAttributes(); - XMLVector getAttributesByMultiname(const multiname& name); + XMLVector getAttributesByMultiname(const multiname& name, const tiny_string &normalizedName) const; XMLVector getValuesByMultiname(_NR<XMLList> nodelist, const multiname& name); XMLList* getAllAttributes(); void getText(XMLVector& ret); @@ -63,9 +63,9 @@ */ void childrenImpl(XMLVector& ret, const tiny_string& name); void childrenImpl(XMLVector& ret, uint32_t index); - tiny_string getNamespacePrefixByURI(const tiny_string& uri, bool create=false); + uint32_t getNamespacePrefixByURI(uint32_t uri, bool create=false); void setLocalName(const tiny_string& localname); - void setNamespace(const tiny_string& ns_uri, const tiny_string& ns_prefix=""); + void setNamespace(uint32_t ns_uri, uint32_t ns_prefix=BUILTIN_STRINGS::EMPTY); // Append node or attribute to this. Concatenates adjacent // text nodes. void appendChild(_R<XML> child); @@ -148,11 +148,11 @@ 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;} + uint32_t getNamespaceURI() const { return nodenamespace_uri;} XMLList* getChildrenlist() { return childrenlist ? childrenlist.getPtr() : NULL; } - void getDescendantsByQName(const tiny_string& name, const tiny_string& ns,bool bIsAttribute, XMLVector& ret); + void getDescendantsByQName(const tiny_string& name, uint32_t ns, bool bIsAttribute, XMLVector& ret) const; void getElementNodes(const tiny_string& name, XMLVector& foundElements); _NR<ASObject> getVariableByMultiname(const multiname& name, GET_VARIABLE_OPTION opt=NONE); bool hasPropertyByMultiname(const multiname& name, bool considerDynamic, bool considerPrototype); @@ -162,7 +162,7 @@ void setTextContent(const tiny_string& content); tiny_string toString(); - const tiny_string toXMLString_internal(bool pretty=true, tiny_string defaultnsprefix = "", const char* indent = "", bool bfirst = true); + const tiny_string toXMLString_internal(bool pretty=true, uint32_t defaultnsprefix = BUILTIN_STRINGS::EMPTY, const char* indent = "", bool bfirst = true); int32_t toInt(); int64_t toInt64(); number_t toNumber();
View file
lightspark.tar.xz/src/scripting/toplevel/XMLList.cpp
Changed
@@ -80,6 +80,24 @@ } } +XMLList* XMLList::create(SystemState* sys,const XML::XMLVector& r, XMLList *targetobject, const multiname &targetproperty) +{ + XMLList* res = Class<XMLList>::getInstanceSNoArgs(sys); + res->constructed = true; + res->nodes.assign(r.begin(),r.end()); + res->targetobject = targetobject; + if (res->targetobject) + res->targetobject->incRef(); + res->targetproperty.name_type = targetproperty.name_type; + res->targetproperty.isAttribute = targetproperty.isAttribute; + res->targetproperty.name_s_id = targetproperty.name_s_id; + for (auto it = targetproperty.ns.begin();it != targetproperty.ns.end(); it++) + { + res->targetproperty.ns.push_back(*it); + } + return res; +} + bool XMLList::destruct() { if (targetobject) @@ -354,8 +372,8 @@ XML::XMLVector ret; multiname mname(NULL); name->applyProxyProperty(mname); - th->getDescendantsByQName(name->toString(),"",mname.isAttribute,ret); - return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->targetobject,multiname(NULL)); + th->getDescendantsByQName(name->toString(),BUILTIN_STRINGS::EMPTY,mname.isAttribute,ret); + return create(obj->getSystemState(),ret,th->targetobject,multiname(NULL)); } ASFUNCTIONBODY(XMLList,elements) @@ -370,7 +388,7 @@ { (*it)->getElementNodes(name, elems); } - return Class<XMLList>::getInstanceS(obj->getSystemState(),elems,th->targetobject,multiname(NULL)); + return create(obj->getSystemState(),elems,th->targetobject,multiname(NULL)); } ASFUNCTIONBODY(XMLList,parent) @@ -425,8 +443,7 @@ (*it)->childrenImpl(ret, arg0); } } - XMLList* retObj=Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->targetobject,multiname(NULL)); - return retObj; + return create(obj->getSystemState(),ret,th->targetobject,multiname(NULL)); } ASFUNCTIONBODY(XMLList,children) @@ -439,8 +456,7 @@ { (*it)->childrenImpl(ret, "*"); } - XMLList* retObj=Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->targetobject,multiname(NULL)); - return retObj; + return create(obj->getSystemState(),ret,th->targetobject,multiname(NULL)); } ASFUNCTIONBODY(XMLList,text) @@ -453,7 +469,7 @@ { (*it)->getText(ret); } - return Class<XMLList>::getInstanceS(obj->getSystemState(),ret,th->targetobject,multiname(NULL)); + return create(obj->getSystemState(),ret,th->targetobject,multiname(NULL)); } ASFUNCTIONBODY(XMLList,contains) @@ -499,7 +515,7 @@ multiname mname(NULL); mname.name_type=multiname::NAME_STRING; mname.name_s_id=obj->getSystemState()->getUniqueStringId(attrname); - mname.ns.emplace_back(obj->getSystemState(),"",NAMESPACE); + mname.ns.emplace_back(obj->getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); mname.isAttribute = true; _NR<ASObject> attr=th->getVariableByMultiname(mname, NONE); @@ -638,23 +654,22 @@ tiny_string normalizedName=name.normalizedName(getSystemState()); //Only the first namespace is used, is this right? - tiny_string namespace_uri; + uint32_t namespace_uri = BUILTIN_STRINGS::EMPTY; if(name.ns.size() > 0 && !name.ns[0].hasEmptyName()) { - nsNameAndKindImpl ns=name.ns[0].getImpl(getSystemState()); - if (ns.kind==NAMESPACE) - namespace_uri=getSystemState()->getStringFromUniqueId(ns.nameId); + if (name.ns[0].kind==NAMESPACE) + namespace_uri=name.ns[0].nsNameId; } // namespace set by "default xml namespace = ..." - if(namespace_uri.empty()) - namespace_uri=getVm(getSystemState())->getDefaultXMLNamespace(); + if(namespace_uri==BUILTIN_STRINGS::EMPTY) + namespace_uri=getVm(getSystemState())->getDefaultXMLNamespaceID(); for (uint32_t i = 0; i < nodes.size(); i++) { _R<XML> child= nodes[i]; bool nameMatches = (normalizedName=="" || normalizedName==child->nodename || normalizedName=="*"); - bool nsMatches = (namespace_uri=="" || + bool nsMatches = (namespace_uri==BUILTIN_STRINGS::EMPTY || (child->nodenamespace_uri == namespace_uri)); if(nameMatches && nsMatches) @@ -701,8 +716,7 @@ if(retnodes.size()==0 && (opt & XML_STRICT)!=0) return NullRef; - this->incRef(); - return _MNR(Class<XMLList>::getInstanceS(getSystemState(),retnodes,this,name)); + return _MNR(create(getSystemState(),retnodes,this,name)); } unsigned int index=0; if(XML::isValidMultiname(getSystemState(),name,index)) @@ -729,7 +743,7 @@ return NullRef; this->incRef(); - return _MNR(Class<XMLList>::getInstanceS(getSystemState(),retnodes,this,name)); + return _MNR(create(getSystemState(),retnodes,this,name)); } } @@ -874,7 +888,7 @@ return bdeleted; } -void XMLList::getDescendantsByQName(const tiny_string& name, const tiny_string& ns, bool bIsAttribute, XML::XMLVector& ret) +void XMLList::getDescendantsByQName(const tiny_string& name, uint32_t ns, bool bIsAttribute, XML::XMLVector& ret) { auto it=nodes.begin(); for(; it!=nodes.end(); ++it) @@ -987,7 +1001,7 @@ multiname m(NULL); m.name_type = multiname::NAME_INT; m.name_i = i; - m.ns.emplace_back(getSystemState(),"",NAMESPACE); + m.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); targetobject->setVariableByMultiname(m,o,allowConst); break; } @@ -1013,7 +1027,7 @@ multiname m(NULL); m.name_type = multiname::NAME_INT; m.name_i = idx; - m.ns.emplace_back(getSystemState(),"",NAMESPACE); + m.ns.emplace_back(getSystemState(),BUILTIN_STRINGS::EMPTY,NAMESPACE); targetobject->setVariableByMultiname(m,o,allowConst); } if (o->as<XML>()->getNodeKind() == pugi::node_pcdata) @@ -1024,8 +1038,8 @@ tmp->parentNode = nodes[idx]; tmp->nodetype = pugi::node_pcdata; tmp->nodename = "text"; - tmp->nodenamespace_uri = ""; - tmp->nodenamespace_prefix = ""; + tmp->nodenamespace_uri = BUILTIN_STRINGS::EMPTY; + tmp->nodenamespace_prefix = BUILTIN_STRINGS::EMPTY; tmp->nodevalue = o->toString(); tmp->constructed = true; nodes[idx]->childrenlist->append(tmp); @@ -1048,8 +1062,8 @@ tmp->parentNode = nodes[idx]; tmp->nodetype = pugi::node_pcdata; tmp->nodename = "text"; - tmp->nodenamespace_uri = ""; - tmp->nodenamespace_prefix = ""; + tmp->nodenamespace_uri = BUILTIN_STRINGS::EMPTY; + tmp->nodenamespace_prefix = BUILTIN_STRINGS::EMPTY; tmp->nodevalue = o->toString(); tmp->constructed = true; nodes[idx]->childrenlist->append(tmp);
View file
lightspark.tar.xz/src/scripting/toplevel/XMLList.h
Changed
@@ -54,6 +54,7 @@ static void buildTraits(ASObject* o){} static void sinit(Class_base* c); + static XMLList* create(SystemState *sys, const XML::XMLVector& r, XMLList *targetobject, const multiname &targetproperty); ASFUNCTION(_constructor); ASFUNCTION(_getLength); ASFUNCTION(attribute); @@ -97,7 +98,7 @@ void setVariableByMultiname(const multiname& name, ASObject* o, CONST_ALLOWED_FLAG allowConst); bool hasPropertyByMultiname(const multiname& name, bool considerDynamic, bool considerPrototype); bool deleteVariableByMultiname(const multiname& name); - void getDescendantsByQName(const tiny_string& name, const tiny_string& ns, bool bIsAttribute, XML::XMLVector& ret); + void getDescendantsByQName(const tiny_string& name, uint32_t ns, bool bIsAttribute, XML::XMLVector& ret); _NR<XML> convertToXML() const; bool hasSimpleContent() const; bool hasComplexContent() const;
View file
lightspark.tar.xz/src/scripting/toplevel/toplevel.cpp
Changed
@@ -356,7 +356,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(obj->getSystemState()); + argumentsArray=Class<Array>::getInstanceSNoArgs(obj->getSystemState()); argumentsArray->resize(numArgs); for(uint32_t j=0;j<numArgs;j++) { @@ -441,7 +441,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(getSystemState()); + Array* rest=Class<Array>::getInstanceSNoArgs(getSystemState()); rest->resize(passedToRest); //Give the reference of the other args to an array for(uint32_t j=0;j<passedToRest;j++) @@ -770,9 +770,9 @@ if(!typeObject) { - if (mn->ns.size() >= 1 && mn->ns[0].getImpl(context->root->getSystemState()).nameId == BUILTIN_STRINGS::STRING_AS3VECTOR) + if (mn->ns.size() >= 1 && mn->ns[0].nsNameId == BUILTIN_STRINGS::STRING_AS3VECTOR) { - QName qname(mn->name_s_id,mn->ns[0].getImpl(context->root->getSystemState()).nameId); + QName qname(mn->name_s_id,mn->ns[0].nsNameId); typeObject = Template<Vector>::getTemplateInstance(context->root->getSystemState(),qname,context,context->root->applicationDomain).getPtr(); } } @@ -1280,7 +1280,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(getSystemState()).kind == PRIVATE_NAMESPACE)) || + (mname->ns.size()==1 && (!mname->ns[0].hasEmptyName() || mname->ns[0].kind == PRIVATE_NAMESPACE)) || mname->ns.size() > 1) continue; @@ -1450,7 +1450,7 @@ { uri_is_null=false; local_name = getSystemState()->getUniqueStringId(node->getName()); - uri=getSystemState()->getUniqueStringId(node->getNamespaceURI()); + uri=node->getNamespaceURI(); } void ASQName::sinit(Class_base* c) @@ -1502,7 +1502,7 @@ else if(nameval->getObjectType()==T_UNDEFINED) th->local_name=BUILTIN_STRINGS::EMPTY; else - th->local_name=obj->getSystemState()->getUniqueStringId(nameval->toString()); + th->local_name=nameval->toStringId(); // Set uri th->uri_is_null=false; @@ -1532,7 +1532,7 @@ th->uri=q->uri; } else - th->uri=obj->getSystemState()->getUniqueStringId(namespaceval->toString()); + th->uri=namespaceval->toStringId(); } return NULL; @@ -1578,7 +1578,7 @@ else if(nameval->getObjectType()==T_UNDEFINED) th->local_name=BUILTIN_STRINGS::EMPTY; else - th->local_name=th->getSystemState()->getUniqueStringId(nameval->toString()); + th->local_name=nameval->toStringId(); // Set uri th->uri_is_null=false; @@ -1608,7 +1608,7 @@ th->uri=q->uri; } else - th->uri=th->getSystemState()->getUniqueStringId(namespaceval->toString()); + th->uri=namespaceval->toStringId(); } return th; } @@ -1710,7 +1710,7 @@ { } -Namespace::Namespace(Class_base* c, const tiny_string& _uri, const tiny_string& _prefix) +Namespace::Namespace(Class_base* c, uint32_t _uri, uint32_t _prefix) : ASObject(c,T_NAMESPACE),nskind(NAMESPACE),prefix_is_undefined(false),uri(_uri),prefix(_prefix) { } @@ -1754,8 +1754,9 @@ urival = args[1]; } th->prefix_is_undefined=false; - th->prefix = ""; - th->uri = ""; + th->prefix = BUILTIN_STRINGS::EMPTY; + th->uri = BUILTIN_STRINGS::EMPTY; +; if(!prefixval) { @@ -1770,15 +1771,15 @@ !(static_cast<ASQName*>(urival)->uri_is_null)) { ASQName* q=static_cast<ASQName*>(urival); - th->uri=q->getSystemState()->getStringFromUniqueId(q->uri); + th->uri=q->uri; } else { - th->uri=urival->toString(); - if(th->uri!="") + th->uri=urival->toStringId(); + if(th->uri!=BUILTIN_STRINGS::EMPTY) { th->prefix_is_undefined=true; - th->prefix=""; + th->prefix=BUILTIN_STRINGS::EMPTY; } } } @@ -1788,18 +1789,18 @@ !(static_cast<ASQName*>(urival)->uri_is_null)) { ASQName* q=static_cast<ASQName*>(urival); - th->uri=q->getSystemState()->getStringFromUniqueId(q->uri); + th->uri=q->uri; } else { - th->uri=urival->toString(); + th->uri=urival->toStringId(); } - if(th->uri=="") + if(th->uri==BUILTIN_STRINGS::EMPTY) { if(prefixval->getObjectType()==T_UNDEFINED || prefixval->toString()=="") - th->prefix=""; + th->prefix=BUILTIN_STRINGS::EMPTY; else throw Class<TypeError>::getInstanceS(obj->getSystemState(),"Namespace prefix for empty uri not allowed"); } @@ -1807,11 +1808,11 @@ !isXMLName(prefixval)) { th->prefix_is_undefined=true; - th->prefix=""; + th->prefix=BUILTIN_STRINGS::EMPTY; } else { - th->prefix=prefixval->toString(); + th->prefix=prefixval->toStringId(); } } @@ -1827,8 +1828,8 @@ if (argslen == 0) { th->prefix_is_undefined=false; - th->prefix = ""; - th->uri = ""; + th->prefix = BUILTIN_STRINGS::EMPTY; + th->uri = BUILTIN_STRINGS::EMPTY; return th; } else if (argslen == 1) @@ -1842,8 +1843,8 @@ urival = args[1]; } th->prefix_is_undefined=false; - th->prefix = ""; - th->uri = ""; + th->prefix = BUILTIN_STRINGS::EMPTY; + th->uri = BUILTIN_STRINGS::EMPTY; if(!prefixval) { @@ -1858,15 +1859,15 @@ !(static_cast<ASQName*>(urival)->uri_is_null)) { ASQName* q=static_cast<ASQName*>(urival); - th->uri=th->getSystemState()->getStringFromUniqueId(q->uri); + th->uri=q->uri; } else { - th->uri=urival->toString(); - if(th->uri!="") + th->uri=urival->toStringId(); + if(th->uri!=BUILTIN_STRINGS::EMPTY) { th->prefix_is_undefined=true; - th->prefix=""; + th->prefix=BUILTIN_STRINGS::EMPTY; } } } @@ -1876,18 +1877,18 @@ !(static_cast<ASQName*>(urival)->uri_is_null)) { ASQName* q=static_cast<ASQName*>(urival); - th->uri=th->getSystemState()->getStringFromUniqueId(q->uri); + th->uri=q->uri; } else { - th->uri=urival->toString(); + th->uri=urival->toStringId(); } - if(th->uri=="") + if(th->uri==BUILTIN_STRINGS::EMPTY) { if(prefixval->getObjectType()==T_UNDEFINED || prefixval->toString()=="") - th->prefix=""; + th->prefix=BUILTIN_STRINGS::EMPTY; else throw Class<TypeError>::getInstanceS(getSys(),"Namespace prefix for empty uri not allowed"); } @@ -1895,11 +1896,11 @@ !isXMLName(prefixval)) { th->prefix_is_undefined=true; - th->prefix=""; + th->prefix=BUILTIN_STRINGS::EMPTY; } else { - th->prefix=prefixval->toString(); + th->prefix=prefixval->toStringId(); } } return th;
View file
lightspark.tar.xz/src/scripting/toplevel/toplevel.h
Changed
@@ -712,11 +712,11 @@ private: NS_KIND nskind; bool prefix_is_undefined; - tiny_string uri; - tiny_string prefix; + uint32_t uri; + uint32_t prefix; public: Namespace(Class_base* c); - Namespace(Class_base* c, const tiny_string& _uri, const tiny_string& _prefix=""); + Namespace(Class_base* c, uint32_t _uri, uint32_t _prefix=BUILTIN_STRINGS::EMPTY); static void sinit(Class_base*); static void buildTraits(ASObject* o); ASFUNCTION(_constructor); @@ -730,8 +730,8 @@ ASFUNCTION(_valueOf); ASFUNCTION(_ECMA_valueOf); bool isEqual(ASObject* o); - tiny_string getURI() { return uri; } - tiny_string getPrefix(bool& is_undefined) { is_undefined=prefix_is_undefined; return prefix; } + uint32_t getURI() const { return uri; } + uint32_t getPrefix(bool& is_undefined) { is_undefined=prefix_is_undefined; return prefix; } uint32_t nextNameIndex(uint32_t cur_index); _R<ASObject> nextName(uint32_t index);
View file
lightspark.tar.xz/src/swf.cpp
Changed
@@ -175,7 +175,7 @@ } //See BUILTIN_STRINGS enum -static const char* builtinStrings[] = {"", "any", "void", "prototype", "Function", "__AS3__.vec","Class","*", "http://adobe.com/AS3/2006/builtin" }; +static const char* builtinStrings[] = {"", "any", "void", "prototype", "Function", "__AS3__.vec","Class","*", "http://adobe.com/AS3/2006/builtin","http://www.w3.org/XML/1998/namespace","xml","toString","valueOf" }; extern uint32_t asClassCount; @@ -200,11 +200,11 @@ nsNameAndKindImpl emptyNs(BUILTIN_STRINGS::EMPTY, NAMESPACE); uint32_t nsId; uint32_t baseId; - getUniqueNamespaceId(emptyNs, 0, nsId, baseId); + getUniqueNamespaceId(emptyNs, BUILTIN_NAMESPACES::EMPTY_NS, nsId, baseId); assert(nsId==0 && baseId==0); //Forge the AS3 namespace and make sure it gets id 1 nsNameAndKindImpl as3Ns(BUILTIN_STRINGS::STRING_AS3NS, NAMESPACE); - getUniqueNamespaceId(as3Ns, 1, nsId, baseId); + getUniqueNamespaceId(as3Ns, BUILTIN_NAMESPACES::AS3_NS, nsId, baseId); assert(nsId==1 && baseId==1); cookiesFileName = NULL; @@ -1727,6 +1727,7 @@ void SystemState::tick() { + if (showProfilingData) { SpinlockLocker l(profileDataSpinlock); list<ThreadProfile*>::iterator it=profilingData.begin();
View file
lightspark.tar.xz/src/swftypes.cpp
Changed
@@ -41,7 +41,7 @@ { assert_and_throw(ns.size()>=1); assert_and_throw(name_type==NAME_STRING); - const tiny_string nsName=sys->getStringFromUniqueId(ns[0].getImpl(sys).nameId); + const tiny_string nsName=sys->getStringFromUniqueId(ns[0].nsNameId); const tiny_string& name=sys->getStringFromUniqueId(name_s_id); if(nsName.empty()) return name; @@ -82,7 +82,10 @@ case multiname::NAME_INT: case multiname::NAME_NUMBER: case multiname::NAME_OBJECT: - return sys->getUniqueStringId(normalizedName(sys)); + if (name_s_id != UINT32_MAX) + return name_s_id; + else + return sys->getUniqueStringId(normalizedName(sys)); default: assert("Unexpected name kind" && false); //Should never reach this @@ -121,10 +124,12 @@ case T_INTEGER: name_i=n->as<Integer>()->val; name_type = NAME_INT; + name_s_id = UINT32_MAX; break; case T_UINTEGER: name_i=n->as<UInteger>()->val; name_type = NAME_INT; + name_s_id = UINT32_MAX; break; case T_NUMBER: if (n->as<Number>()->isfloat) @@ -146,6 +151,7 @@ name_type = NAME_INT; } } + name_s_id = UINT32_MAX; break; case T_QNAME: { @@ -157,7 +163,7 @@ case T_STRING: { ASString* o=static_cast<ASString*>(n); - name_s_id=o->hasId ? o->stringId : n->getSystemState()->getUniqueStringId(o->getData()); + name_s_id=o->hasId ? o->toStringId() : n->getSystemState()->getUniqueStringId(o->getData()); name_type = NAME_STRING; } break; @@ -165,6 +171,7 @@ n->incRef(); name_o=n; name_type = NAME_OBJECT; + name_s_id = UINT32_MAX; break; } } @@ -261,7 +268,7 @@ std::ostream& lightspark::operator<<(std::ostream& s, const nsNameAndKind& r) { const char* prefix; - switch(r.getImpl(getSys()).kind) + switch(r.kind) { case NAMESPACE: prefix="ns:"; @@ -290,7 +297,7 @@ prefix=""; break; } - s << prefix << getSys()->getStringFromUniqueId(r.getImpl(getSys()).nameId); + s << prefix << getSys()->getStringFromUniqueId(r.nsNameId); return s; } @@ -1359,12 +1366,17 @@ } ASString* lightspark::abstract_s(SystemState *sys) { - return Class<ASString>::getInstanceSNoArgs(sys); + ASString* ret= Class<ASString>::getInstanceSNoArgs(sys); + ret->stringId = BUILTIN_STRINGS::EMPTY; + ret->hasId = true; + ret->datafilled=true; + return ret; } ASString* lightspark::abstract_s(SystemState *sys, const char* s, uint32_t len) { ASString* ret= Class<ASString>::getInstanceSNoArgs(sys); ret->data = std::string(s,len); + ret->stringId = UINT32_MAX; ret->hasId = false; ret->datafilled=true; return ret; @@ -1373,6 +1385,7 @@ { ASString* ret= Class<ASString>::getInstanceSNoArgs(sys); ret->data = s; + ret->stringId = UINT32_MAX; ret->hasId = false; ret->datafilled=true; return ret; @@ -1381,6 +1394,7 @@ { ASString* ret= Class<ASString>::getInstanceSNoArgs(sys); ret->data = s; + ret->stringId = UINT32_MAX; ret->hasId = false; ret->datafilled=true; return ret; @@ -1508,20 +1522,26 @@ nsNameAndKind::nsNameAndKind(SystemState* sys,const tiny_string& _name, NS_KIND _kind) { - nsNameAndKindImpl tmp(sys->getUniqueStringId(_name), _kind); + nsNameId = sys->getUniqueStringId(_name); + nsNameAndKindImpl tmp(nsNameId, _kind); sys->getUniqueNamespaceId(tmp, nsRealId, nsId); + kind = _kind; } nsNameAndKind::nsNameAndKind(SystemState* sys,const char* _name, NS_KIND _kind) { - nsNameAndKindImpl tmp(sys->getUniqueStringId(_name), _kind); + nsNameId = sys->getUniqueStringId(_name); + nsNameAndKindImpl tmp(nsNameId, _kind); sys->getUniqueNamespaceId(tmp, nsRealId, nsId); + kind = _kind; } nsNameAndKind::nsNameAndKind(SystemState* sys,uint32_t _nameId, NS_KIND _kind) { nsNameAndKindImpl tmp(_nameId, _kind); sys->getUniqueNamespaceId(tmp, nsRealId, nsId); + nsNameId = _nameId; + kind = _kind; } nsNameAndKind::nsNameAndKind(SystemState* sys, uint32_t _nameId, uint32_t _baseId, NS_KIND _kind) { @@ -1531,18 +1551,21 @@ uint32_t tmpId; sys->getUniqueNamespaceId(tmp, nsRealId, tmpId); assert(tmpId==_baseId); + nsNameId = _nameId; + kind = _kind; } nsNameAndKind::nsNameAndKind(ABCContext* c, uint32_t nsContextIndex) { const namespace_info& ns=c->constant_pool.namespaces[nsContextIndex]; - uint32_t nsNameId=c->getString(ns.name); + nsNameId=c->getString(ns.name); nsNameAndKindImpl tmp(nsNameId, (NS_KIND)(int)ns.kind); //Give an id hint, in case the namespace is created in the map 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; + kind = (NS_KIND)(int)ns.kind; } const nsNameAndKindImpl& nsNameAndKind::getImpl(SystemState* sys) const
View file
lightspark.tar.xz/src/swftypes.h
Changed
@@ -40,8 +40,8 @@ namespace lightspark { -enum BUILTIN_STRINGS { EMPTY=0, ANY, VOID, PROTOTYPE, STRING_FUNCTION,STRING_AS3VECTOR,STRING_CLASS,STRING_WILDCARD,STRING_AS3NS,LAST_BUILTIN_STRING }; -enum BUILTIN_NAMESPACES { EMPTY_NS=0 }; +enum BUILTIN_STRINGS { EMPTY=0, ANY, VOID, PROTOTYPE, STRING_FUNCTION,STRING_AS3VECTOR,STRING_CLASS,STRING_WILDCARD,STRING_AS3NS,STRING_NAMESPACENS,STRING_XML,STRING_TOSTRING,STRING_VALUEOF,LAST_BUILTIN_STRING }; +enum BUILTIN_NAMESPACES { EMPTY_NS=0, AS3_NS }; enum SWFOBJECT_TYPE { T_OBJECT=0, T_INTEGER=1, T_NUMBER=2, T_FUNCTION=3, T_UNDEFINED=4, T_NULL=5, T_STRING=6, @@ -318,7 +318,9 @@ { uint32_t nsId; uint32_t nsRealId; - nsNameAndKind():nsId(0),nsRealId(0) {} + uint32_t nsNameId; + NS_KIND kind; + nsNameAndKind():nsId(0),nsRealId(0),nsNameId(BUILTIN_STRINGS::EMPTY),kind(NAMESPACE) {} nsNameAndKind(SystemState *sys, const tiny_string& _name, NS_KIND _kind); nsNameAndKind(SystemState* sys,const char* _name, NS_KIND _kind); nsNameAndKind(SystemState* sys,uint32_t _nameId, NS_KIND _kind); @@ -356,9 +358,9 @@ struct multiname: public memory_reporter { + uint32_t name_s_id; union { - uint32_t name_s_id; int32_t name_i; number_t name_d; ASObject* name_o; @@ -367,7 +369,7 @@ enum NAME_TYPE {NAME_STRING,NAME_INT,NAME_NUMBER,NAME_OBJECT}; NAME_TYPE name_type; bool isAttribute; - multiname(MemoryAccount* m):name_o(NULL),ns(reporter_allocator<nsNameAndKind>(m)),name_type(NAME_OBJECT),isAttribute(false) + multiname(MemoryAccount* m):name_s_id(UINT32_MAX),name_o(NULL),ns(reporter_allocator<nsNameAndKind>(m)),name_type(NAME_OBJECT),isAttribute(false) { }
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
.