#include <XMLObject.h>
Inheritance diagram for avmplus::XMLObject:

Definition at line 116 of file XMLObject.h.
|
||||||||||||||||
|
Definition at line 91 of file XMLObject.cpp. References avmplus::E4XNode::_addInScopeNamespace(), avmplus::E4XNode::_append(), avmplus::String::atom(), avmplus::AvmCore::atomToNamespace(), AvmAssert, avmplus::AvmDebugMsg(), avmplus::String::c_str(), avmplus::ElementE4XNode::CopyAttributesAndNamespaces(), avmplus::ScriptObject::core(), avmplus::XMLTag::empty, avmplus::E4XNode::FindNamespace(), avmplus::ScriptObject::gc(), avmplus::Toplevel::getDefaultNamespace(), MMgc::GCRoot::GetGC(), avmplus::XMLClass::getIgnoreWhitespace(), avmplus::XMLParser::getNext(), avmplus::E4XNode::getParent(), avmplus::Namespace::getPrefix(), avmplus::E4XNode::getQName(), avmplus::Namespace::getURI(), avmplus::Namespace::hasPrefix(), avmplus::AvmCore::internAlloc(), avmplus::AvmCore::internNamespace(), avmplus::AvmCore::internString(), avmplus::String::isInterned(), avmplus::XMLTag::kDocTypeDeclaration, avmplus::XMLTag::kElementType, avmplus::XMLParser::kNoError, avmplus::XMLTag::kXMLDeclaration, avmplus::ErrorConstants::kXMLMarkupMustBeWellFormed, avmplus::ErrorConstants::kXMLUnterminatedElementTag, avmplus::String::Length(), avmplus::String::length(), localName(), build::dependparser::m, m_node, avmplus::E4XNode::m_parent, name(), avmplus::AvmCore::newNamespace(), avmplus::AvmCore::newString(), NodeNameEquals(), avmplus::XMLTag::nodeType, NULL, avmplus::XMLParser::parse(), SAMPLE_FRAME, avmplus::XMLParser::setCondenseWhite(), setNode(), avmplus::E4XNode::setQName(), avmplus::AvmCore::string(), avmplus::XMLTag::text, avmplus::Toplevel::throwTypeError(), avmplus::ScriptObject::toplevel(), avmplus::ScriptObject::traits(), and avmplus::Toplevel::xmlClass(). Referenced by _deepCopy(), childChanges(), getParent(), issueNotifications(), nonChildChanges(), normalize(), and toString(). 00092 : ScriptObject(type->ivtable(), type->prototype) 00093 { 00094 SAMPLE_FRAME("XML", this->core()); 00095 #if 0//def _DEBUG 00096 static bool once = false; 00097 if (!once) 00098 { 00099 once = true; 00100 AvmDebugMsg(false, "sizeof(E4XNode): %d\r\n", sizeof(E4XNode)); 00101 AvmDebugMsg(false, "sizeof(TextE4XNode): %d\r\n", sizeof(TextE4XNode)); 00102 AvmDebugMsg(false, "sizeof(ElementE4XNode): %d\r\n", sizeof(ElementE4XNode)); 00103 AvmDebugMsg(false, "sizeof(E4XNodeAux): %d\r\n", sizeof(E4XNodeAux)); 00104 } 00105 #endif 00106 m_node = 0; 00107 if (!str) 00108 return; 00109 00110 AvmCore *core = this->core(); 00111 Toplevel* toplevel = this->toplevel(); 00112 MMgc::GC *gc = core->GetGC(); 00113 00114 AvmAssert(traits()->sizeofInstance == sizeof(XMLObject)); 00115 00116 // str, ignoreWhite 00117 bool bIgnoreWhite = toplevel->xmlClass()->getIgnoreWhitespace() != 0; 00118 XMLParser parser(core); 00119 parser.parse(str, bIgnoreWhite); 00120 parser.setCondenseWhite(true); 00121 00122 XMLTag tag(gc); 00123 E4XNode* p = 0; 00124 00125 // When we're passed in a defaultNamespace, we simulate the following XML code 00126 // <parent xmlns=defaultNamespace's URI>string</parent> 00127 if (defaultNamespace) 00128 { 00129 setNode( new (gc) ElementE4XNode (0) ); 00130 00131 // create a namespace for the parent using defaultNamespace->URI() 00132 Namespace *ns = core->internNamespace (core->newNamespace (core->kEmptyString->atom(), defaultNamespace->getURI()->atom())); 00133 00134 m_node->_addInScopeNamespace (core, ns); 00135 00136 Stringp name = core->internString (core->newString("parent")); 00137 00138 m_node->setQName (core, name, ns); 00139 00140 p = m_node; 00141 } 00142 00143 int m_status; 00144 00145 while ((m_status = parser.getNext(tag)) == XMLParser::kNoError) 00146 { 00147 E4XNode* pNewElement = NULL; 00148 00149 switch (tag.nodeType) 00150 { 00151 case XMLTag::kXMLDeclaration: 00152 { 00153 // !!@ add some checks to ensure this is the first tag 00154 // encountered in our file (deal with <parent> stuff from 00155 // XMLObject and XMLListObject parser setup 00156 } 00157 break; 00158 case XMLTag::kDocTypeDeclaration: 00159 break; 00160 case XMLTag::kElementType: 00161 { 00162 // A closing tag 00163 if (tag.text->c_str()[0] == '/') 00164 { 00165 //Stringp thisNodeNameNoSlash = new (gc) String(tag.text, 1, tag.text->length()-1); 00166 const wchar *thisNodeNameNoSlash = tag.text->c_str() + 1; 00167 uint32 noSlashLen = tag.text->length() - 1; 00168 00169 Multiname m; 00170 p->getQName(core, &m); 00171 Namespace *ns = m.getNamespace(); 00172 00173 // Get our parents qualified name string here 00174 Stringp parentName = m.getName(); 00175 00176 Namespace *ns2 = toplevel->getDefaultNamespace(); 00177 if ((!NodeNameEquals (thisNodeNameNoSlash, noSlashLen, parentName, ns)) && 00178 // We're trying to support paired nodes where the first node gets a namespace 00179 // from the default namespace. 00180 (!(m.getName()->Equals (thisNodeNameNoSlash, noSlashLen) && (ns->getURI() == ns2->getURI())))) 00181 { 00182 // If p == m_node, we are at the top of our tree and we're parsing the fake "parent" 00183 // wrapper tags around our actual XML text. Instead of warning about a missing "</parent>" 00184 // tag, we instead complain about the XML markup not being well-formed. 00185 // (Emulating Rhino behavior) 00186 if (p == m_node) 00187 { 00188 toplevel->throwTypeError(kXMLMarkupMustBeWellFormed); 00189 } 00190 else 00191 { 00192 #if 0 // After team and 8ball_adv discussion, this will not be enabled 00193 // Try to see if we have a bit of misformed XML tags where a trailing 00194 // tag is missing. We'll walk up a parent node to see if that node 00195 // matches this ending tag. If so, we'll automagically end tag this 00196 // node. Bug 110808 - "<item><p>blah blah blah</item>". Some RSS XML 00197 // feeds have badly formed HTML tags 00198 if (p->m_parent) 00199 { 00200 Multiname *m = p->m_parent->getQName(); 00201 Namespace *ns = core->atomToNamespace(m->getNamespace()); 00202 StringBuffer out2 (core); 00203 if (ns && ns->hasPrefix()) 00204 { 00205 out2 << core->string(ns->getPrefix()) << ":"; 00206 } 00207 out2 << m->getName(); 00208 00209 Stringp parentParentName = core->newString (out2.c_str()); 00210 if (*thisNodeNameNoSlash == *parentParentName) 00211 { 00212 p = p->m_parent->m_parent; 00213 } 00214 else 00215 { 00216 toplevel->throwTypeError(kXMLUnterminatedElementTag, parentName, parentName); 00217 } 00218 } 00219 else 00220 #endif 00221 { 00222 toplevel->throwTypeError(kXMLUnterminatedElementTag, parentName, parentName); 00223 } 00224 } 00225 } 00226 else 00227 { 00228 // Catch the case where our input string ends with a bogus <parent> tag 00229 if (defaultNamespace) 00230 { 00231 if (p == m_node) 00232 { 00233 toplevel->throwTypeError(kXMLMarkupMustBeWellFormed); 00234 } 00235 } 00236 00237 // found matching closing tag so we can pop back up a level now 00238 if (p != m_node) 00239 p = p->getParent(); 00240 } 00241 00242 } 00243 else // an opening tag 00244 { 00245 ElementE4XNode *e = new (gc) ElementE4XNode(0); 00246 pNewElement = e; 00247 // Our first tag modifies this object itself 00248 if (!m_node) 00249 { 00250 setNode( pNewElement ); 00251 } 00252 else // all other tags create a new element tag 00253 { 00254 p->_append (pNewElement); 00255 } 00256 00257 if (!tag.empty) // if our tag is not empty, we're now the "parent" tag 00258 { 00259 p = pNewElement; 00260 } 00261 00262 const wchar *localName = tag.text->c_str(); 00263 00264 // Needs to happen after setting m_name->name so throw error can use name in routine 00265 e->CopyAttributesAndNamespaces (core, toplevel, tag, localName); 00266 00267 // Find a namespace that matches this tag in our parent chain. If this name 00268 // is a qualified name (ns:name), we search for a namespace with a matching 00269 // prefix. If is an unqualified name, we find the first empty prefix name. 00270 Namespace *ns = pNewElement->FindNamespace (core, toplevel, tag.text->c_str(), &localName, false); 00271 00272 // pg 35, map [[name]].uri to "namespace name" of node 00273 00274 if (!ns) 00275 ns = core->publicNamespace; 00276 00277 Stringp name; 00278 // If our string ptr did not change, just use our tag.text string instead of creating a new one. 00279 if (localName == tag.text->c_str()) 00280 { 00281 AvmAssert(tag.text->isInterned()); 00282 name = tag.text; 00283 } 00284 else 00285 { 00286 name = core->internAlloc (localName, String::Length(localName)); 00287 } 00288 00289 pNewElement->setQName (core, name, ns); 00290 } 00291 } 00292 break; 00293 00294 case XMLTag::kComment: 00295 if (!toplevel->xmlClass()->getIgnoreComments()) 00296 { 00297 pNewElement = new (gc) CommentE4XNode (0, tag.text); 00298 if (!m_node) 00299 setNode( pNewElement ); 00300 } 00301 break; 00302 case XMLTag::kCDataSection: 00303 00304 pNewElement = new (gc) CDATAE4XNode (0, tag.text); 00305 if (!m_node) 00306 setNode( pNewElement ); 00307 break; 00308 case XMLTag::kTextNodeType: 00309 // For small strings, we intern them in an attempt to save memory 00310 // with large XML files with of lot of repeating text nodes. 00311 if (tag.text->length() < 32) 00312 { 00313 Stringp text = core->internString(tag.text); 00314 // Reduce our GC pressure if we know our tag.text is unused. 00315 if (text != tag.text) 00316 { 00317 AvmAssert(!tag.text->isInterned()); 00318 delete tag.text; 00319 tag.text = 0; 00320 } 00321 pNewElement = new (gc) TextE4XNode(0, text); 00322 } 00323 else 00324 { 00325 pNewElement = new (gc) TextE4XNode(0, tag.text); 00326 } 00327 00328 if (!m_node) 00329 setNode( pNewElement ); 00330 break; 00331 case XMLTag::kProcessingInstruction: 00332 if (!toplevel->xmlClass()->getIgnoreProcessingInstructions()) 00333 { 00334 00335 const wchar *nameStart = tag.text->c_str(); 00336 const wchar *nameEnd = nameStart; 00337 while (!String::isSpace(nameEnd[0]) && (nameEnd[0])) 00338 nameEnd++; 00339 00340 Stringp name = core->internString (new (core->GetGC()) String(nameStart, (int)(nameEnd - nameStart))); 00341 00342 // Skip over any white space between name and rest of PI 00343 while (String::isSpace(nameEnd[0]) && nameEnd[0]) 00344 nameEnd++; 00345 00346 String *val = new (gc) String(nameEnd, tag.text->length()-(int)(nameEnd-nameStart)); 00347 pNewElement = new (gc) PIE4XNode(0, val); 00348 pNewElement->setQName (core, name, core->publicNamespace); 00349 if (!m_node) 00350 setNode( pNewElement ); 00351 } 00352 break; 00353 00354 //kNoType = 0, 00355 default: 00356 AvmAssert(0); // unknown tag type?? 00357 } 00358 00359 if ( pNewElement && (XMLTag::kElementType != tag.nodeType)) 00360 { 00361 if (pNewElement != m_node) 00362 p->_append( pNewElement); 00363 } 00364 00365 if ( m_status != XMLParser::kNoError ) 00366 { 00367 break; // stop getting tags 00368 } 00369 00370 } 00371 00372 if ( m_status == XMLParser::kEndOfDocument ) 00373 { 00374 m_status = XMLParser::kNoError; 00375 } 00376 else 00377 { 00378 switch (m_status) 00379 { 00380 case XMLParser::kMalformedElement: 00381 toplevel->throwTypeError(kXMLMalformedElement); 00382 break; 00383 case XMLParser::kUnterminatedCDataSection: 00384 toplevel->throwTypeError(kXMLUnterminatedCData); 00385 break; 00386 case XMLParser::kUnterminatedXMLDeclaration: 00387 toplevel->throwTypeError(kXMLUnterminatedXMLDecl); 00388 break; 00389 case XMLParser::kUnterminatedDocTypeDeclaration: 00390 toplevel->throwTypeError(kXMLUnterminatedDocTypeDecl); 00391 break; 00392 case XMLParser::kUnterminatedComment: 00393 toplevel->throwTypeError(kXMLUnterminatedComment); 00394 break; 00395 case XMLParser::kUnterminatedAttributeValue: 00396 toplevel->throwTypeError(kXMLUnterminatedAttribute); 00397 break; 00398 case XMLParser::kUnterminatedElement: 00399 toplevel->throwTypeError(kXMLUnterminatedElement); 00400 break; 00401 case XMLParser::kUnterminatedProcessingInstruction: 00402 toplevel->throwTypeError(kXMLUnterminatedProcessingInstruction); 00403 break; 00404 case XMLParser::kOutOfMemory: 00405 case XMLParser::kElementNeverBegun: 00406 AvmAssert(0); 00407 break; 00408 } 00409 } 00410 00411 if ( p != m_node && ! m_status ) 00412 { 00413 Multiname m; 00414 p->getQName(core, &m); 00415 00416 // Get our parents qualified name string here 00417 Stringp parentName = m.getName(); 00418 00419 toplevel->throwTypeError(kXMLUnterminatedElementTag, parentName, parentName); 00420 } 00421 }
|
|
||||||||||||
|
Definition at line 83 of file XMLObject.cpp. References SAMPLE_FRAME, and setNode(). 00084 : ScriptObject(type->ivtable(), type->prototype) 00085 { 00086 SAMPLE_FRAME("XML", this->core()); 00087 setNode( node ); 00088 }
|
|
|
Definition at line 423 of file XMLObject.cpp. References NULL, and setNode().
|
|
||||||||||||||||||||
|
!-ii - should never get hit now with revised 10.2.1 step 11. Definition at line 1199 of file XMLObject.cpp. References avmplus::ScriptObject::core(), avmplus::ScriptObject::toplevel(), and xmlClass(). Referenced by toXMLString(). 01200 { 01201 AvmCore *core = this->core(); 01202 01203 if (toplevel()->xmlClass()->okToPrettyPrint()) 01204 { 01205 for (int i = 0; i < indentLevel; i++) 01206 { 01207 s << " "; 01208 } 01209 } 01210 if (this->getClass() == E4XNode::kText) // CDATA checked below 01211 { 01212 if (toplevel()->xmlClass()->okToPrettyPrint()) 01213 { 01214 // v = removing leading and trailing whitespace from x.value 01215 // return escapeElementValue (v); 01216 01217 s << core->EscapeElementValue(m_node->getValue(), true); 01218 return; 01219 } 01220 else 01221 { 01222 s << core->EscapeElementValue(m_node->getValue(), false); 01223 return; 01224 } 01225 } 01226 if (this->getClass() == E4XNode::kCDATA) 01227 { 01228 s << "<![CDATA[" << m_node->getValue() << "]]>"; 01229 return; 01230 } 01231 if (this->getClass() == E4XNode::kAttribute) 01232 { 01233 s << core->EscapeAttributeValue (m_node->getValue()->atom()); 01234 return; 01235 } 01236 if (this->getClass() == E4XNode::kComment) 01237 { 01238 s << "<!--"; 01239 s << m_node->getValue(); 01240 s << "-->"; 01241 return; 01242 } 01243 if (this->getClass() == E4XNode::kProcessingInstruction) // step 7 01244 { 01245 s << "<?"; 01246 Multiname m; 01247 AvmAssert (m_node->getQName(core, &m) != 0); 01248 if (m_node->getQName(core, &m)) 01249 { 01250 s << m.getName() << " "; 01251 } 01252 s << m_node->getValue() << "?>"; 01253 return; 01254 } 01255 01256 // We're a little different than the spec here. Instead of each XMLObject 01257 // keeping track of its entire in-scope namespace list (all the way to the 01258 // topmost parent), the XMLObject only knows about its own declared nodes. 01259 // So when were converting to a string, we need to build the inScopeNamespace 01260 // list here. 01261 01262 AtomArray *inScopeNS = new (core->GetGC()) AtomArray(); 01263 m_node->BuildInScopeNamespaceList (core, inScopeNS); 01264 uint32 origLength = AncestorNamespaces->getLength(); 01265 01266 // step 8 - ancestorNamespaces passed in 01267 // step 9/10 - add in our namespaces into ancestorNamespaces if there are no conflicts 01268 for (uint32 i = 0; i < inScopeNS->getLength(); i++) 01269 { 01270 Namespace *ns = AvmCore::atomToNamespace (inScopeNS->getAt(i)); 01271 uint32 j; 01272 for (j = 0; j < AncestorNamespaces->getLength(); j++) 01273 { 01274 Namespace *ns2 = AvmCore::atomToNamespace (AncestorNamespaces->getAt(j)); 01275 #ifdef STRING_DEBUG 01276 Stringp u1 = ns->getURI(); 01277 Stringp p1 = core->string(ns->getPrefix()); 01278 Stringp u2 = ns2->getURI(); 01279 Stringp p2 = core->string(ns2->getPrefix()); 01280 #endif 01281 if ((ns->getURI() == ns2->getURI()) && (ns->getPrefix() == ns2->getPrefix())) 01282 break; 01283 } 01284 01285 if (j == AncestorNamespaces->getLength()) // a match was not found 01286 { 01287 AncestorNamespaces->push (ns->atom()); 01288 } 01289 } 01290 01291 // step 11 - new ISNS changes 01292 // If this node's namespace has an undefined prefix, generate a new one 01293 Multiname m; 01294 AvmAssert (getNode()->getQName (core, &m)); 01295 getNode()->getQName (core, &m); 01296 Namespace *thisNodesNamespace = GetNamespace (m, AncestorNamespaces); 01297 AvmAssert(thisNodesNamespace != 0); 01298 if (thisNodesNamespace->getPrefix() == undefinedAtom) 01299 { 01300 // find a prefix and add this namespace to our list 01301 thisNodesNamespace = GenerateUniquePrefix (thisNodesNamespace, AncestorNamespaces); 01302 AncestorNamespaces->push (thisNodesNamespace->atom()); 01303 } 01304 01305 String *nsPrefix = core->string (thisNodesNamespace->getPrefix()); 01306 01307 // If any of this node's attribute's namespaces have an undefined prefix, generate a new one 01308 for (uint32 i = 0; i < m_node->numAttributes(); i++) 01309 { 01310 E4XNode *an = m_node->getAttribute(i); 01311 AvmAssert(an != 0); 01312 AvmAssert(an->getClass() == E4XNode::kAttribute); 01313 Multiname nam; 01314 AvmAssert(an->getQName(core, &nam)); 01315 an->getQName(core, &nam); 01316 Namespace *ns = GetNamespace (nam, AncestorNamespaces); 01317 AvmAssert(ns != 0); 01318 if (ns->getPrefix() == undefinedAtom) 01319 { 01320 // find a prefix and add this namespace to our list 01321 ns = GenerateUniquePrefix (ns, AncestorNamespaces); 01322 01323 AncestorNamespaces->push (ns->atom()); 01324 } 01325 } 01326 // step 12 01327 s << "<"; 01328 // step13 - insert namespace prefix if we have one 01329 if (nsPrefix != core->kEmptyString) 01330 { 01331 s << nsPrefix << ":"; 01332 } 01333 01334 // step 14 01335 AvmAssert (!m.isAnyName()); 01336 s << m.getName(); 01337 01338 // step 15 - attrAndNamespaces = sum of x.attributes and namespaceDeclarations 01339 01340 // step 16 01341 // for each an in attrAndNamespaces 01342 for (uint32 i = 0; i < m_node->numAttributes(); i++) 01343 { 01344 // step 17a 01345 s << " "; 01346 E4XNode *an = m_node->getAttribute(i); 01347 AvmAssert(an != 0); 01348 AvmAssert(an->getClass() == E4XNode::kAttribute); 01349 Multiname nam; 01350 AvmAssert(an->getQName(core, &nam)); 01351 an->getQName(core, &nam); 01352 01353 // step16b-i - ans = an->getName->getNamespace(AncestorNamespace); 01354 AvmAssert(nam.isAttr()); 01355 Namespace *attr_ns = GetNamespace (nam, AncestorNamespaces); 01356 01358 AvmAssert(attr_ns->getPrefix() != undefinedAtom); 01359 01360 // step16b-iii 01361 if (attr_ns && attr_ns->hasPrefix ()) 01362 { 01363 s << core->string(attr_ns->getPrefix()) << ":"; 01364 } 01365 //step16b-iv 01366 s << nam.getName(); 01367 01368 //step16c - namespace case - see below 01369 01370 //step 16d 01371 s << "=\""; 01372 //step 16e 01373 s << core->EscapeAttributeValue(an->getValue()->atom()); 01374 //step 16f - namespace case 01375 //step 16g 01376 s << "\""; 01377 } 01378 01379 // This adds any NS that were added to our ancestor namespace list (from origLength on up) 01380 for (uint32 i = origLength; i < AncestorNamespaces->getLength(); i++) 01381 { 01382 Namespace *an = AvmCore::atomToNamespace(AncestorNamespaces->getAt(i)); 01383 if (an->getURI() != core->kEmptyString) 01384 { 01385 s << " xmlns"; 01386 AvmAssert (an->getPrefix() != undefinedAtom); 01387 if (an->getPrefix() != core->kEmptyString->atom()) 01388 { 01389 // 17c iii 01390 s << ":" << core->string(an->getPrefix()); 01391 } 01392 // 17d 01393 s << "=\""; 01394 //step 17f - namespace case 01395 s << an->getURI(); 01396 //step 17g 01397 s << "\""; 01398 } 01399 } 01400 01401 // if (thisNodesNamespace) 01402 // AncestorNamespaces->push (thisNodesNamespace->atom()); 01403 01404 // step 18 01405 if (!m_node->numChildren()) 01406 { 01407 s << "/>"; 01408 return; 01409 } 01410 01411 // step 19 01412 s << ">"; 01413 01414 // Added by mmorearty for the debugger 01415 if (!includeChildren) 01416 { 01417 return; 01418 } 01419 01420 // step 20 01421 E4XNode *firstChild = m_node->_getAt(0); 01422 AvmAssert(firstChild != 0); 01423 bool bIndentChildren = ((_length() > 1) || (firstChild->getClass() & ~(E4XNode::kText | E4XNode::kCDATA))); 01424 01425 // step 21/22 01426 int nextIndentLevel = 0; 01427 if (toplevel()->xmlClass()->getPrettyPrinting() && bIndentChildren) 01428 { 01429 nextIndentLevel = indentLevel + toplevel()->xmlClass()->getPrettyIndent(); 01430 } 01431 01432 // We need to prune any namespaces with duplicate prefixes in our AncestorNamespace 01433 // array to prevent shadowing of similar namespaces. Bug 153363. 01434 // var x = <order xmlns:x="x"> 01435 // <item id="1" xmlns:x="x2"> 01436 // <menuName xmlns:x="x" x:foo='10'>burger</menuName> 01437 // <price>3.95</price> 01438 // </item> 01439 // </order>; 01440 // 01441 // The namespace for menuName should be output even though the identical namespace 01442 // was output for the top node. (Since the item node is using an incompatible 01443 // namespace with the same prefix.) 01444 AtomArray *newNamespaceArray = new (core->GetGC()) AtomArray(); 01445 uint32 anLen = AncestorNamespaces->getLength(); 01446 for (uint32 i = 0; i < anLen; i++) 01447 { 01448 Namespace *first = AvmCore::atomToNamespace(AncestorNamespaces->getAt(i)); 01449 if (i < origLength) 01450 { 01451 uint32 j; 01452 for (j = origLength; j < anLen; j++) 01453 { 01454 Namespace *second = AvmCore::atomToNamespace(AncestorNamespaces->getAt(j)); 01455 if (second->getPrefix() == first->getPrefix()) 01456 { 01457 break; 01458 } 01459 } 01460 01461 // No match, push our namespace on the list. 01462 if (j == anLen) 01463 { 01464 newNamespaceArray->push (first->atom()); 01465 } 01466 } 01467 else 01468 { 01469 newNamespaceArray->push (first->atom()); 01470 } 01471 } 01472 uint32 namespaceLength = newNamespaceArray->getLength(); 01473 01474 // step 23 01475 for (uint32 i = 0; i < _length(); i++) 01476 { 01477 // step 23b 01478 E4XNode *child = m_node->_getAt(i); 01479 XMLObject *xo = new (core->GetGC()) XMLObject(toplevel()->xmlClass(), child); 01480 if (toplevel()->xmlClass()->okToPrettyPrint() && bIndentChildren) 01481 { 01482 s << "\n"; 01483 } 01484 xo->__toXMLString (s, newNamespaceArray, nextIndentLevel, includeChildren); 01485 01486 // Our __toXMLString call might have added new namespace onto our list. We don't want to 01487 // save these new namespaces so clear them out here. 01488 newNamespaceArray->setLength (namespaceLength); 01489 } 01490 01491 // Part of the latest spec 01492 if (toplevel()->xmlClass()->okToPrettyPrint() && bIndentChildren) 01493 { 01494 s << "\n"; 01495 } 01496 01497 //step 24 01498 if (toplevel()->xmlClass()->okToPrettyPrint() && bIndentChildren) 01499 { 01500 for (int i = 0; i < indentLevel; i++) 01501 { 01502 s << " "; 01503 } 01504 } 01505 01506 //step 25 01507 s << "</"; 01508 01509 //step 26 01510 if (nsPrefix != core->kEmptyString) 01511 { 01512 s << nsPrefix << ":"; 01513 } 01514 01515 //step 27 01516 s << m.getName() << ">"; 01517 01518 //step 28 01519 return; 01520 }
|
|
|
Definition at line 1113 of file XMLObject.cpp. References avmplus::ScriptObject::core(), MMgc::GCRoot::GetGC(), avmplus::ScriptObject::toplevel(), xmlClass(), and XMLObject(). Referenced by avmplus::XMLClass::construct(), copy(), and replace(). 01114 { 01115 AvmCore *core = this->core(); 01116 01117 E4XNode *e = m_node->_deepCopy (core, toplevel()); 01118 01119 XMLObject *y = new (core->GetGC()) XMLObject(xmlClass(), e); 01120 01121 return y; 01122 }
|
|
|
Definition at line 2617 of file XMLObject.cpp. Referenced by elements(), normalize(), and toString(). 02618 { 02619 return m_node->_length(); 02620 }
|
|
|
Definition at line 1133 of file XMLObject.cpp. References avmplus::ScriptObject::atom(). Referenced by avmplus::XMLListObject::_resolveValue(), and avmplus::XMLListObject::setUintProperty(). 01134 { 01135 return this->atom(); 01136 }
|
|
|
Definition at line 1560 of file XMLObject.cpp. References avmplus::AvmCore::atomToNamespace(), avmplus::ScriptObject::core(), and avmplus::AvmCore::isNamespace(). Referenced by avmplus::XMLListObject::addNamespace(). 01561 { 01562 AvmCore *core = this->core(); 01563 if (core->isNamespace (_namespace)) 01564 { 01565 m_node->_addInScopeNamespace (core, AvmCore::atomToNamespace(_namespace)); 01566 } 01567 else 01568 { 01569 Namespace *ns = core->newNamespace (_namespace); 01570 m_node->_addInScopeNamespace (core, ns); 01571 01572 _namespace = ns->atom(); 01573 } 01574 01575 nonChildChanges(xmlClass()->kNamespaceAdded, _namespace); 01576 return this; 01577 }
|
|
|
Definition at line 1579 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), avmplus::AvmCore::atomToXMLList(), avmplus::AvmCore::atomToXMLObject(), avmplus::ScriptObject::core(), avmplus::AvmCore::isXML(), avmplus::AvmCore::isXMLList(), avmplus::PoolObject::kbug444630, and avmplus::ScriptObject::traits(). Referenced by avmplus::XMLListObject::appendChild(). 01580 { 01581 AvmCore *core = this->core(); 01582 01583 if(!(PoolObject::kbug444630 & traits()->pool->bugFlags)) 01584 { 01585 if (core->isXML(child)) 01586 { 01587 child = core->atomToXMLObject (child)->atom(); 01588 } 01589 else if (core->isXMLList (child)) 01590 { 01591 child = core->atomToXMLList (child)->atom(); 01592 } 01593 else // all other types go through XML constructor as a string 01594 { 01595 child = xmlClass()->ToXML (core->string(child)->atom()); 01596 } 01597 } 01598 01599 Atom children = getStringProperty(core->kAsterisk); 01600 01601 XMLListObject *cxl = core->atomToXMLList (children); 01602 int index = _length(); 01603 cxl->setUintProperty (index, child); 01604 return this; 01605 }
|
|
|
Definition at line 1607 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), avmplus::AvmCore::atomToXMLList(), avmplus::ScriptObject::core(), getAtomProperty(), and avmplus::ScriptObject::toplevel(). 01608 { 01609 // E4X 13.4.4.4 01610 // name= ToAttributeName (attributeName); 01611 // return [[get]](name) 01612 return core()->atomToXMLList(getAtomProperty(toplevel()->ToAttributeName(arg)->atom())); 01613 }
|
|
|
Definition at line 1615 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), avmplus::AvmCore::atomToXMLList(), avmplus::ScriptObject::core(), getAtomProperty(), and avmplus::ScriptObject::toplevel(). 01616 { 01617 // E4X 13.4.4.5 01618 // name= ToAttributeName ("*"); 01619 // return [[get]](name) 01620 01621 return core()->atomToXMLList(getAtomProperty(toplevel()->ToAttributeName(core()->kAsterisk)->atom())); 01622 }
|
|
||||||||||||||||
|
Reimplemented from avmplus::ScriptObject. Definition at line 463 of file XMLObject.cpp. References avmplus::XMLListObject::_length(), avmplus::ScriptObject::atom(), avmplus::String::atom(), avmplus::AvmCore::atomToXMLList(), avmplus::Toplevel::callproperty(), avmplus::ScriptObject::core(), runtests::f, avmplus::ScriptObject::getDelegate(), getMultinameProperty(), avmplus::ScriptObject::getMultinameProperty(), hasSimpleContent(), avmplus::AvmCore::isXMLList(), avmplus::Toplevel::op_call(), avmplus::AvmCore::string(), avmplus::ScriptObject::toplevel(), avmplus::AtomConstants::undefinedAtom, and avmplus::ScriptObject::vtable. Referenced by avmplus::XMLListObject::callProperty(). 00464 { 00465 AvmCore *core = this->core(); 00466 00467 Atom f = getDelegate()->getMultinameProperty(multiname); 00468 if (f == undefinedAtom) 00469 { 00470 f = getMultinameProperty(multiname); 00471 // If our method returned is a 0 element XMLList, it means that we did not 00472 // find a matching property for this method name. In this case, if our XML 00473 // node is simple, we convert it to a string and callproperty on the string. 00474 // This allows node elements to be treated as simple strings even if they 00475 // are XML or XMLList objects. See 11.2.2.1 in the E4X spec for CallMethod. 00476 if (core->isXMLList(f) && 00477 !core->atomToXMLList(f)->_length() && 00478 (hasSimpleContent())) 00479 { 00480 Stringp r0 = core->string (this->atom()); 00481 return toplevel()->callproperty (r0->atom(), multiname, argc, argv, toplevel()->stringClass->vtable); 00482 } 00483 } 00484 argv[0] = atom(); // replace receiver 00485 return toplevel()->op_call(f, argc, argv); 00486 }
|
|
|
Definition at line 1624 of file XMLObject.cpp. References avmplus::XMLListObject::_append(), avmplus::AvmCore::atomToXMLList(), avmplus::ScriptObject::core(), getAtomProperty(), MMgc::GCRoot::GetGC(), avmplus::AvmCore::getIndexFromString(), avmplus::AvmCore::string(), and avmplus::ScriptObject::toplevel(). Referenced by avmplus::XMLListObject::child(), comments(), elements(), hasComplexContent(), hasSimpleContent(), processingInstructions(), text(), and toString(). 01625 { 01626 AvmCore *core = this->core(); 01627 01628 // We have an integer argument - direct child lookup 01629 uint32 index; 01630 if (AvmCore::getIndexFromString (core->string(P), &index)) 01631 { 01632 XMLListObject *xl = new (core->GetGC()) XMLListObject(toplevel()->xmlListClass()); 01633 if ((index >= 0) && (index < m_node->numChildren())) 01634 { 01635 xl->_append (m_node->_getAt(index)); 01636 } 01637 return xl; 01638 } 01639 01640 return core->atomToXMLList(getAtomProperty(P)); 01641 }
|
|
||||||||||||||||
|
Notification on generic node addition from XML or XMLList Definition at line 2681 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), avmplus::AvmCore::atomToXMLList(), AvmAssert, avmplus::ScriptObject::core(), MMgc::GCRoot::GetGC(), issueNotifications(), avmplus::AvmCore::isXML(), avmplus::AvmCore::isXMLList(), notifyNeeded(), avmplus::ScriptObject::toplevel(), avmplus::AtomConstants::undefinedAtom, xmlClass(), avmplus::Toplevel::xmlClass(), and XMLObject(). Referenced by avmplus::XMLListObject::delUintProperty(), and normalize(). 02682 { 02683 AvmCore* core = this->core(); 02684 Toplevel* top = this->toplevel(); 02685 E4XNode* initialTarget = m_node; 02686 02687 if (notifyNeeded(initialTarget)) 02688 { 02689 XMLObject* target = new (core->GetGC()) XMLObject(top->xmlClass(), initialTarget); 02690 Atom detail = undefinedAtom; 02691 if (prior) 02692 { 02693 XMLObject* xml = new (core->GetGC()) XMLObject(xmlClass(), prior); 02694 detail = xml->atom(); 02695 } 02696 02697 if (core->isXML(value)) 02698 { 02699 issueNotifications(core, top, initialTarget, target->atom(), type, value, detail); 02700 } 02701 else if (core->isXMLList(value)) 02702 { 02703 // if its a list each element in the list is added. 02704 XMLListObject* xl = core->atomToXMLList(value); 02705 if (xl) 02706 { 02707 issueNotifications(core, top, initialTarget, target->atom(), type, xl->atom(), detail); 02708 } 02709 else 02710 { 02711 AvmAssert(false); 02712 } 02713 } 02714 else 02715 { 02716 // non child updates 02717 } 02718 } 02719 }
|
|
|
Definition at line 1643 of file XMLObject.cpp. References AvmAssert, getClass(), avmplus::E4XNode::kAttribute, and parent(). Referenced by avmplus::XMLListObject::childIndex(), and avmplus::XMLListObject::delUintProperty(). 01644 { 01645 if ((m_node->getParent() == NULL) || (getClass() == E4XNode::kAttribute)) 01646 return -1; 01647 01648 // find this child in parent's children list - return ordinal 01649 01650 E4XNode *parent = m_node->getParent(); 01651 AvmAssert(parent != 0); 01652 AvmAssert(parent->_length()); // this child's parent does not contain itself??? 01653 01654 for (uint32 i = 0; i < parent->_length(); i++) 01655 { 01656 E4XNode *x = parent->_getAt(i); 01657 if (x == m_node) 01658 { 01659 return i; 01660 } 01661 } 01662 01663 // this child's parent does not contain itself??? 01664 AvmAssert(0); 01665 return -1; 01666 }
|
|
|
Definition at line 1668 of file XMLObject.cpp. References avmplus::AvmCore::atomToXMLList(), avmplus::ScriptObject::core(), and avmplus::ScriptObject::getStringProperty(). 01669 { 01670 return core()->atomToXMLList(getStringProperty(core()->kAsterisk)); 01671 }
|
|
||||||||||||
|
Conversion routine to verify XML related flags of Multiname (strips @ from strings and marks multiname as attribute) |
|
|
Definition at line 1674 of file XMLObject.cpp. References avmplus::XMLListObject::_append(), avmplus::XMLListObject::_getAt(), avmplus::ScriptObject::atom(), child(), avmplus::ScriptObject::core(), MMgc::GCRoot::GetGC(), avmplus::E4XNode::kComment, and avmplus::ScriptObject::toplevel(). Referenced by avmplus::XMLListObject::comments(). 01675 { 01676 AvmCore *core = this->core(); 01677 01678 XMLListObject *l = new (core->GetGC()) XMLListObject(toplevel()->xmlListClass(), this->atom()); 01679 01680 for (uint32 i = 0; i < m_node->_length(); i++) 01681 { 01682 E4XNode *child = m_node->_getAt(i); 01683 01684 if (child->getClass() == E4XNode::kComment) 01685 { 01686 l->_append (child); 01687 } 01688 } 01689 01690 return l; 01691 }
|
|
|
Definition at line 1694 of file XMLObject.cpp. References avmplus::E4XNode::_equals(), avmplus::AvmCore::atomToXML(), avmplus::ScriptObject::core(), getNode(), avmplus::AvmCore::isXML(), and avmplus::AtomConstants::trueAtom. 01695 { 01696 AvmCore *core = this->core(); 01697 01698 // !!@ Rhino returns false for this case... 01699 // var xml = new XML("simple"); 01700 // print ("contains: " + xml.contains ("simple")); 01701 // ...which seems to imply that this routine is calling _equals and not 01702 // does a "comparison x == value" as stated in the spec. We'll mimic 01703 // Rhino for the time being but the correct behavior needs to be determined 01704 if (this->atom() == value) 01705 return true; 01706 01707 if (!core->isXML (value)) 01708 return false; 01709 01710 E4XNode *v = core->atomToXML(value); 01711 01712 return getNode()->_equals (core, v) == trueAtom; // rhino 01713 //SPEC - return (core()->equals (this->atom(), value) == trueAtom); 01714 }
|
|
|
Definition at line 1717 of file XMLObject.cpp. References _deepCopy(). 01718 { 01719 return _deepCopy (); 01720 }
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 1036 of file XMLObject.cpp. References deleteMultinameProperty(), build::dependparser::m, avmplus::ScriptObject::toplevel(), and avmplus::Toplevel::ToXMLName(). 01037 { 01038 Multiname m; 01039 toplevel()->ToXMLName(P, m); 01040 return deleteMultinameProperty(&m); 01041 }
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 855 of file XMLObject.cpp. References avmplus::Toplevel::CoerceE4XMultiname(), avmplus::ScriptObject::core(), avmplus::AvmCore::getIndexFromString(), build::dependparser::m, and avmplus::ScriptObject::toplevel(). Referenced by deleteAtomProperty(), and avmplus::XMLListObject::delUintProperty(). 00856 { 00857 AvmCore *core = this->core(); 00858 00859 Multiname m; 00860 toplevel()->CoerceE4XMultiname(name_in, m); 00861 00862 // step 1 00863 if (!m.isAnyName() && !m.isAttr()) 00864 { 00865 Stringp name = m.getName(); 00866 uint32 index; 00867 if (AvmCore::getIndexFromString (name, &index)) 00868 { 00869 // Spec says: NOTE: this operation is reserved for future versions of E4X 00870 // In Rhino, this silently fails 00871 return true; 00872 } 00873 } 00874 00875 if (m.isAttr()) 00876 { 00877 uint32 j = 0; 00878 while (j < m_node->numAttributes()) 00879 { 00880 E4XNode *x = m_node->getAttribute(j); 00881 Multiname m2; 00882 x->getQName(core, &m2); 00883 if (m.matches (&m2)) 00884 { 00885 x->setParent(NULL); 00886 00887 // remove the attribute from m_attributes 00888 m_node->getAttributes()->removeAt (j); 00889 00890 Multiname previous; 00891 x->getQName(core, &previous); 00892 Stringp name = previous.getName(); 00893 Stringp val = x->getValue(); 00894 nonChildChanges(xmlClass()->kAttrRemoved, (name) ? name->atom() : undefinedAtom, (val) ? val->atom() : undefinedAtom); 00895 } 00896 else 00897 { 00898 j++; 00899 } 00900 } 00901 00902 return true; 00903 } 00904 00905 bool notify = notifyNeeded(m_node); 00906 uint32 q = 0; 00907 while (q < _length()) 00908 { 00909 E4XNode *x = m_node->_getAt(q); 00910 Multiname mx; 00911 Multiname *m2 = 0; 00912 bool isElem = x->getClass() == (E4XNode::kElement) ? true : false; 00913 if (isElem) 00914 { 00915 x->getQName (core, &mx); 00916 m2 = &mx; 00917 } 00918 00919 if (m.matches (m2)) 00920 { 00921 x->setParent (NULL); 00922 m_node->_deleteByIndex (q); 00923 00924 if (notify && isElem) 00925 { 00926 XMLObject *r = new (core->GetGC()) XMLObject (xmlClass(), x); 00927 childChanges(xmlClass()->kNodeRemoved, r->atom()); 00928 } 00929 } 00930 else 00931 { 00932 q++; 00933 // if (dp > 0) 00934 // rename property (q) to (q-dp) 00935 // this automatically gets taken care of by deleteByIndex 00936 } 00937 } 00938 // x.length = x.length - dp 00939 // this is handled b _deleteByIndex logic 00940 00941 return true; 00942 }
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 1028 of file XMLObject.cpp. 01029 { 01030 // Spec says: NOTE: this operation is reserved for future versions of E4X 01031 // In Rhino, this silently fails 01032 return true; 01033 }
|
|
|
Definition at line 1125 of file XMLObject.cpp. References avmplus::AvmCore::atomToXMLList(), avmplus::ScriptObject::core(), getDescendants(), build::dependparser::m, avmplus::ScriptObject::toplevel(), and avmplus::Toplevel::ToXMLName(). 01126 { 01127 Multiname m; 01128 toplevel()->ToXMLName (P, m); 01129 return core()->atomToXMLList (getDescendants (&m)); 01130 }
|
|
|
Definition at line 1723 of file XMLObject.cpp. References avmplus::XMLListObject::_append(), avmplus::XMLListObject::_getAt(), _length(), avmplus::ScriptObject::atom(), child(), avmplus::ScriptObject::core(), MMgc::GCRoot::GetGC(), avmplus::E4XNode::kElement, build::dependparser::m, avmplus::ScriptObject::toplevel(), and avmplus::Toplevel::ToXMLName(). Referenced by avmplus::XMLListObject::elements(). 01724 { 01725 AvmCore *core = this->core(); 01726 Multiname m; 01727 toplevel()->ToXMLName(name, m); 01728 01729 XMLListObject *l = new (core->GetGC()) XMLListObject(toplevel()->xmlListClass(), this->atom()); 01730 01731 for (uint32 i = 0; i < _length(); i++) 01732 { 01733 E4XNode *child = m_node->_getAt(i); 01734 01735 if (child->getClass() == E4XNode::kElement) 01736 { 01737 Multiname m2; 01738 child->getQName(core, &m2); 01739 01740 // if name.localName = "*" or name.localName =child->name.localName) 01741 // and (name.uri == null) or (name.uri == child.name.uri)) 01742 if (m.matches (&m2)) 01743 { 01744 // if name.localName = "*" or name.localName =child->name.localName) 01745 // and (name.uri == null) or (name.uri == child.name.uri)) 01746 l->_append (child); 01747 } 01748 } 01749 } 01750 01751 return l; 01752 }
|
|
||||||||||||
|
Definition at line 1138 of file XMLObject.cpp. References avmplus::AvmCore::atomToNamespace(), AvmAssert, avmplus::ScriptObject::core(), avmplus::AtomArray::getAt(), avmplus::AtomArray::getLength(), avmplus::Namespace::getPrefix(), and avmplus::AtomConstants::undefinedAtom. 01139 { 01140 AvmCore *core = this->core(); 01141 01142 // should only be called when a namespace doesn't have a prefix 01143 AvmAssert (ns->getPrefix() == undefinedAtom); 01144 01145 // Try to use the empty string as a first try (ISNS changes) 01146 uint32 i; 01147 for (i = 0; i < namespaces->getLength(); i++) 01148 { 01149 Namespace *ns = AvmCore::atomToNamespace (namespaces->getAt(i)); 01150 if (ns->getPrefix() == core->kEmptyString->atom()) 01151 break; 01152 } 01153 01154 if (i == namespaces->getLength()) 01155 { 01156 return core->newNamespace (core->kEmptyString->atom(), ns->getURI()->atom()); 01157 } 01158 01159 // Rhino seems to start searching with whatever follows "://www" or "://" 01160 //String *origURI = core()->string(ns->getURI()); 01161 01162 wchar s[4]; 01163 s[0] = s[1] = s[2] = 'a'; 01164 s[3] = 0; 01165 01166 for (wchar x1 = 'a'; x1 <= 'z'; x1++) 01167 { 01168 s[0] = x1; 01169 for (wchar x2 = 'a'; x2 <= 'z'; x2++) 01170 { 01171 s[1] = x2; 01172 for (wchar x3 = 'a'; x3 <= 'z'; x3++) 01173 { 01174 s[2] = x3; 01175 bool bMatch = false; 01176 Atom pre = core->internAlloc(s, 3)->atom(); 01177 for (uint32 i = 0; i < namespaces->getLength(); i++) 01178 { 01179 Namespace *ns = AvmCore::atomToNamespace (namespaces->getAt(i)); 01180 if (pre == ns->getPrefix()) 01181 { 01182 bMatch = true; 01183 break; 01184 } 01185 } 01186 01187 if (!bMatch) 01188 { 01189 return core->newNamespace (pre, ns->getURI()->atom()); 01190 } 01191 } 01192 } 01193 } 01194 01195 return 0; 01196 }
|
|
|
traverse the delegate chain looking for a value. [ed] it's okay to look only at the HT's in the delegate chain because delegate values may only be instances of Object. They cannot be objects with slots. We don't need to look at traits at each step. todo - enforce this rule
Reimplemented from avmplus::ScriptObject. Definition at line 489 of file XMLObject.cpp. References getMultinameProperty(), build::dependparser::m, avmplus::ScriptObject::toplevel(), and avmplus::Toplevel::ToXMLName(). Referenced by attribute(), attributes(), and child(). 00490 { 00491 Multiname m; 00492 toplevel()->ToXMLName(P, m); 00493 return getMultinameProperty(&m); 00494 }
|
|
|
Definition at line 2612 of file XMLObject.cpp. Referenced by childIndex(), avmplus::XMLListObject::delUintProperty(), avmplus::AvmCore::equals(), getNamespace(), insertChildAfter(), insertChildBefore(), namespaceDeclarations(), avmplus::XMLListObject::normalize(), removeNamespace(), replace(), and toString(). 02613 { 02614 return m_node->getClass() ; 02615 }
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 944 of file XMLObject.cpp. References avmplus::XMLListObject::_append(), AvmAssert, avmplus::Toplevel::CoerceE4XMultiname(), avmplus::ScriptObject::core(), MMgc::GCRoot::GetGC(), build::dependparser::m, avmplus::ScriptObject::toplevel(), and avmplus::Toplevel::xmlListClass(). Referenced by descendants(). 00945 { 00946 AvmCore *core = this->core(); 00947 Toplevel* toplevel = this->toplevel(); 00948 00949 Multiname m; 00950 toplevel->CoerceE4XMultiname(name_in, m); 00951 00952 XMLListObject *l = new (core->GetGC()) XMLListObject(toplevel->xmlListClass()); 00953 00954 if (m.isAttr()) 00955 { 00956 for (uint32 i = 0; i < m_node->numAttributes(); i++) 00957 { 00958 E4XNode *ax = m_node->getAttribute(i); 00959 Multiname m2; 00960 AvmAssert(ax->getQName(core, &m2)); 00961 ax->getQName(core, &m2); 00962 00963 if (m.matches (&m2)) 00964 { 00965 // for each atribute, if it's name equals m, 00966 l->_append (ax); 00967 } 00968 } 00969 } 00970 00971 for (uint32 k = 0; k < _length(); k++) 00972 { 00973 E4XNode *child = m_node->_getAt(k); 00974 00975 if (!m.isAttr()) 00976 { 00977 Multiname mx; 00978 Multiname *m2 = 0; 00979 if (child->getClass() == E4XNode::kElement) 00980 { 00981 child->getQName (core, &mx); 00982 m2 = &mx; 00983 } 00984 if (m.matches (m2)) 00985 { 00986 l->_append (child); 00987 } 00988 } 00989 00990 XMLObject *co = new (core->GetGC()) XMLObject(toplevel->xmlClass(), child); 00991 Atom dq = co->getDescendants (&m); 00992 delete co; 00993 XMLListObject *dql = core->atomToXMLList (dq); 00994 if (dql && dql->_length()) 00995 { 00996 l->_append (dq); 00997 } 00998 } 00999 01000 return l->atom(); 01001 }
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 497 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), avmplus::Toplevel::CoerceE4XMultiname(), avmplus::ScriptObject::core(), avmplus::AvmCore::getIndexFromString(), name(), avmplus::ScriptObject::toplevel(), and avmplus::AtomConstants::undefinedAtom. Referenced by avmplus::XMLListObject::_resolveValue(), callProperty(), and getAtomProperty(). 00498 { 00499 AvmCore *core = this->core(); 00500 Toplevel* toplevel = this->toplevel(); 00501 00502 Multiname name; 00503 toplevel->CoerceE4XMultiname(name_in, name); 00504 00505 #ifdef STRING_DEBUG 00506 Stringp n1 = name.getName(); 00507 #endif 00508 00509 if (!name.isAnyName() && !name.isAttr()) 00510 { 00511 // We have an integer argument - direct child lookup 00512 Stringp nameString = name.getName(); 00513 uint32 index; 00514 if (AvmCore::getIndexFromString (nameString, &index)) 00515 { 00516 // //l = ToXMLList (this); 00517 // //return l->get(p); 00518 // ToXMLList on a XMLNode just creates a one item XMLList. The only valid 00519 // property number for the new XMLList is 0 which just returns this node. Handle 00520 // that case here. 00521 if (index == 0) 00522 return this->atom(); 00523 else 00524 return undefinedAtom; 00525 } 00526 } 00527 00528 XMLListObject *xl = new (core->GetGC()) XMLListObject(toplevel->xmlListClass(), this->atom(), &name); 00529 00530 if (name.isAttr()) 00531 { 00532 // for each a in x.[[attributes]] 00533 for (uint32 i = 0; i < m_node->numAttributes(); i++) 00534 { 00535 E4XNode *xml = m_node->getAttribute(i); 00536 00537 AvmAssert(xml && xml->getClass() == E4XNode::kAttribute); 00538 00539 Multiname m; 00540 AvmAssert(xml->getQName(core, &m) != 0); 00541 00542 //if (((n.[[Name]].localName == "*") || (n.[[Name]].localName == a.[[Name]].localName)) && 00543 // ((n.[[Name]].uri == nulll) || (n.[[Name]].uri == a.[[Name]].uri))) 00544 // l.append (a); 00545 00546 xml->getQName (core, &m); 00547 if (name.matches (&m)) 00548 { 00549 xl->_append (xml); 00550 } 00551 } 00552 00553 return xl->atom(); 00554 } 00555 // step 5 - look through all the children for a match - [[length]] implies length of children 00556 // n isn't an attributeName so it must be a qname?? 00557 // for k = 0 to x.[[length]]-1 00558 // if (n.localName = "*" and this[k].class == "element" and (this[k].name.localName == n.localName) 00559 // and (!n.uri) or (this[k].class == "element) and (n.uri == this[k].name.uri))) 00560 // xl->_append (x[k]); 00561 00562 for (uint32 i = 0; i < m_node->numChildren(); i++) 00563 { 00564 E4XNode *child = m_node->_getAt(i); 00565 Multiname m; 00566 Multiname *m2 = 0; 00567 if (child->getClass() == E4XNode::kElement) 00568 { 00569 child->getQName(core, &m); 00570 m2 = &m; 00571 } 00572 00573 // if (n.localName = "*" OR this[k].class == "element" and (this[k].name.localName == n.localName) 00574 // and (!n.uri) or (this[k].class == "element) and (n.uri == this[k].name.uri))) 00575 // xl->_append (x[k]); 00576 if (name.matches (m2)) 00577 { 00578 xl->_append (child); 00579 } 00580 } 00581 00582 return xl->atom(); 00583 }
|
|
||||||||||||
|
Definition at line 3000 of file XMLObject.cpp. References avmplus::AvmCore::atomToNamespace(), AvmAssert, avmplus::ScriptObject::core(), avmplus::AtomArray::getAt(), avmplus::AtomArray::getLength(), avmplus::Multiname::getNamespace(), avmplus::Namespace::getURI(), and avmplus::Multiname::isAnyNamespace(). Referenced by getNamespace(), and removeNamespace(). 03001 { 03002 AvmCore *core = this->core(); 03003 03004 Stringp uri = (mn.isAnyNamespace() ? 0 : mn.getNamespace()->getURI()); 03005 03006 if (nsArray) 03007 { 03008 for (uint32 i = 0; i < nsArray->getLength(); i++) 03009 { 03010 Namespace *ns = AvmCore::atomToNamespace (nsArray->getAt(i)); 03011 AvmAssert(ns!=NULL); 03012 #ifdef STRING_DEBUG 03013 Stringp s1 = ns->getURI(); 03014 Stringp s2 = uri; 03015 #endif // STRING_DEBUG 03016 if (ns->getURI() == uri) 03017 { 03018 return ns; 03019 } 03020 } 03021 } 03022 03023 // not found, return empty namespace based upon this QName's uri. 03024 return core->newNamespace (uri->atom()); 03025 }
|
|
||||||||||||
|
Definition at line 1978 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), avmplus::Namespace::atom(), avmplus::AvmCore::atomToNamespace(), AvmAssert, avmplus::ScriptObject::core(), avmplus::AtomArray::getAt(), getClass(), MMgc::GCRoot::GetGC(), avmplus::AtomArray::getLength(), GetNamespace(), getQName(), avmplus::AvmCore::internString(), avmplus::E4XNode::kCDATA, avmplus::E4XNode::kComment, avmplus::E4XNode::kProcessingInstruction, avmplus::E4XNode::kText, build::dependparser::m, avmplus::AtomConstants::nullObjectAtom, prefix, avmplus::AvmCore::string(), and avmplus::AtomConstants::undefinedAtom. Referenced by avmplus::XMLListObject::getNamespace(). 01979 { 01980 AvmAssert(argc == 0 || argc == 1); 01981 01982 AvmCore *core = this->core(); 01983 01984 // step 2 01985 AtomArray *inScopeNS = new (core->GetGC()) AtomArray(); 01986 01987 // step 3 01988 m_node->BuildInScopeNamespaceList (core, inScopeNS); 01989 01990 // step 5 01991 if (!argc) 01992 { 01993 // step 5a 01994 if (getClass() & (E4XNode::kText | E4XNode::kComment | E4XNode::kCDATA | E4XNode::kProcessingInstruction)) 01995 return nullObjectAtom; 01996 01997 // step 5b 01998 // Return the result of calling [[GetNamespace]] method of 01999 // x.[[Name]] with argument inScopeNS 02000 Multiname m; 02001 AvmAssert(getQName(&m)); 02002 getQName(&m); 02003 Namespace *ns = GetNamespace (m, inScopeNS); 02004 02005 return (ns->atom()); 02006 } 02007 else 02008 { 02009 Atom prefix = core->internString (core->string (p_prefix))->atom(); 02010 02011 for (uint32 i = 0; i < inScopeNS->getLength(); i++) 02012 { 02013 Namespace *ns = AvmCore::atomToNamespace (inScopeNS->getAt(i)); 02014 if (ns->getPrefix() == prefix) 02015 return ns->atom(); 02016 } 02017 02018 return undefinedAtom; 02019 } 02020 }
|
|
|
Definition at line 130 of file XMLObject.h. References m_node. Referenced by contains(), avmplus::XMLListObject::delUintProperty(), avmplus::AvmCore::equals(), normalize(), avmplus::XMLListObject::normalize(), avmplus::XMLListObject::parent(), and setLocalName(). 00130 { return m_node; }
|
|
|
Definition at line 2656 of file XMLObject.cpp. 02657 { 02658 return m_node->getNotification(); 02659 }
|
|
|
Definition at line 2622 of file XMLObject.cpp. References avmplus::ScriptObject::core(), avmplus::ScriptObject::toplevel(), xmlClass(), and XMLObject(). Referenced by avmplus::XMLListObject::delUintProperty(). 02623 { 02624 if (m_node->getParent()) 02625 return new (core()->GetGC()) XMLObject (toplevel()->xmlClass(), m_node->getParent()); 02626 else 02627 return 0; 02628 }
|
|
|
Definition at line 2640 of file XMLObject.cpp. References avmplus::ScriptObject::core(), and build::dependparser::m. Referenced by avmplus::XMLListObject::delUintProperty(), getNamespace(), and removeNamespace().
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 1014 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), and avmplus::AtomConstants::undefinedAtom. 01015 { 01016 if (index == 0) 01017 return this->atom(); 01018 else 01019 return undefinedAtom; 01020 }
|
|
|
Definition at line 2635 of file XMLObject.cpp. 02636 { 02637 return m_node->getValue(); 02638 }
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 1105 of file XMLObject.cpp. References hasMultinameProperty(), build::dependparser::m, avmplus::ScriptObject::toplevel(), and avmplus::Toplevel::ToXMLName(). Referenced by hasOwnProperty(). 01106 { 01107 Multiname m; 01108 toplevel()->ToXMLName (P, m); 01109 return hasMultinameProperty(&m); 01110 }
|
|
|
Definition at line 1767 of file XMLObject.cpp. References avmplus::XMLListObject::_getAt(), child(), avmplus::E4XNode::kAttribute, avmplus::E4XNode::kCDATA, avmplus::E4XNode::kComment, avmplus::E4XNode::kElement, avmplus::E4XNode::kProcessingInstruction, and avmplus::E4XNode::kText. Referenced by avmplus::XMLListObject::hasComplexContent(). 01768 { 01769 if (m_node->getClass() & (E4XNode::kText | E4XNode::kComment | E4XNode::kProcessingInstruction | E4XNode::kAttribute | E4XNode::kCDATA)) 01770 return false; 01771 01772 for (uint32 i = 0; i < m_node->_length(); i++) 01773 { 01774 E4XNode *child = m_node->_getAt(i); 01775 01776 if (child->getClass() == E4XNode::kElement) 01777 { 01778 return true; 01779 } 01780 } 01781 01782 return false; 01783 }
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 1051 of file XMLObject.cpp. References avmplus::Toplevel::CoerceE4XMultiname(), avmplus::ScriptObject::core(), avmplus::AvmCore::getIndexFromString(), build::dependparser::m, name(), and avmplus::ScriptObject::toplevel(). Referenced by hasAtomProperty(). 01052 { 01053 AvmCore *core = this->core(); 01054 01055 Multiname m; 01056 toplevel()->CoerceE4XMultiname(name_in, m); 01057 01058 if (!m.isAnyName() && !m.isAttr()) 01059 { 01060 Stringp name = m.getName(); 01061 uint32 index; 01062 if (AvmCore::getIndexFromString (name, &index)) 01063 { 01064 return (index == 0); 01065 } 01066 } 01067 01068 if (m.isAttr()) 01069 { 01070 for (uint32 i = 0; i < m_node->numAttributes(); i++) 01071 { 01072 E4XNode *ax = m_node->getAttribute(i); 01073 Multiname m2; 01074 if (ax->getQName(core, &m2) && (m.matches (&m2))) 01075 { 01076 return true; 01077 } 01078 } 01079 01080 return false; 01081 } 01082 01083 // n is a QName 01084 for (uint32 k = 0; k < m_node->_length(); k++) 01085 { 01086 E4XNode *child = m_node->_getAt(k); 01087 Multiname mx; 01088 Multiname *m2 = 0; 01089 if (child->getClass() == E4XNode::kElement) 01090 { 01091 child->getQName (core, &mx); 01092 m2 = &mx; 01093 } 01094 01095 if (m.matches (m2)) 01096 { 01097 return true; 01098 } 01099 } 01100 01101 return false; 01102 }
|
|
|
Definition at line 1755 of file XMLObject.cpp. References hasAtomProperty(). 01756 { 01757 if (hasAtomProperty(P)) 01758 return true; 01759 01760 // if this has a property with name ToSString(P), return true; 01761 // !!@ spec talks about prototype object being different from regular XML object 01762 01763 return false; 01764 }
|
|
|
Definition at line 1786 of file XMLObject.cpp. References avmplus::XMLListObject::_getAt(), child(), avmplus::E4XNode::kComment, avmplus::E4XNode::kElement, and avmplus::E4XNode::kProcessingInstruction. Referenced by callProperty(), avmplus::AvmCore::equals(), avmplus::XMLListObject::hasSimpleContent(), and toString(). 01787 { 01788 if (m_node->getClass() & (E4XNode::kComment | E4XNode::kProcessingInstruction)) 01789 return false; 01790 01791 // for each prop in x, if x.class == element, return false 01792 for (uint32 i = 0; i < m_node->_length(); i++) 01793 { 01794 E4XNode *child = m_node->_getAt(i); 01795 01796 if (child->getClass() == E4XNode::kElement) 01797 { 01798 return false; 01799 } 01800 } 01801 01802 return true; 01803 }
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 1046 of file XMLObject.cpp.
|
|
|
Definition at line 1806 of file XMLObject.cpp. References avmplus::ScriptObject::core(), avmplus::AtomArray::getAt(), MMgc::GCRoot::GetGC(), avmplus::AtomArray::getLength(), avmplus::ArrayObject::setUintProperty(), and avmplus::ScriptObject::toplevel(). Referenced by avmplus::XMLListObject::inScopeNamespaces(). 01807 { 01808 AvmCore *core = this->core(); 01809 // step 2 01810 AtomArray *inScopeNS = new (core->GetGC()) AtomArray(); 01811 01812 // step 3 01813 m_node->BuildInScopeNamespaceList (core, inScopeNS); 01814 01815 ArrayObject *a = toplevel()->arrayClass->newArray(inScopeNS->getLength()); 01816 01817 uint32 i; 01818 for (i = 0; i < inScopeNS->getLength(); i++) 01819 { 01820 a->setUintProperty (i, inScopeNS->getAt(i)); 01821 } 01822 01823 // !!@ Rhino behavior always seems to return at least one NS 01824 if (!inScopeNS->getLength()) 01825 { 01826 a->setUintProperty (i, core->newNamespace(core->kEmptyString)->atom()); 01827 } 01828 01829 return a; 01830 }
|
|
||||||||||||
|
Definition at line 1833 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), avmplus::AvmCore::atomToXMLList(), avmplus::AvmCore::atomToXMLObject(), avmplus::ScriptObject::core(), getClass(), avmplus::AvmCore::isXML(), avmplus::AvmCore::isXMLList(), avmplus::E4XNode::kAttribute, avmplus::PoolObject::kbug444630, avmplus::E4XNode::kCDATA, avmplus::E4XNode::kComment, avmplus::E4XNode::kProcessingInstruction, avmplus::E4XNode::kText, avmplus::ScriptObject::toplevel(), avmplus::ScriptObject::traits(), and avmplus::AtomConstants::undefinedAtom. Referenced by avmplus::XMLListObject::insertChildAfter(). 01834 { 01835 AvmCore *core = this->core(); 01836 Toplevel *toplevel = this->toplevel(); 01837 01838 if (getClass() & (E4XNode::kText | E4XNode::kComment | E4XNode::kProcessingInstruction | E4XNode::kAttribute | E4XNode::kCDATA)) 01839 return undefinedAtom; 01840 01841 if(!(PoolObject::kbug444630 & traits()->pool->bugFlags)) 01842 { 01843 if (core->isXML(child2)) 01844 { 01845 child2 = core->atomToXMLObject (child2)->atom(); 01846 } 01847 else if (core->isXMLList (child2)) 01848 { 01849 child2 = core->atomToXMLList (child2)->atom(); 01850 } 01851 else // all other types go through XML constructor as a string 01852 { 01853 child2 = xmlClass()->ToXML (core->string(child2)->atom()); 01854 } 01855 } 01856 01857 if (AvmCore::isNull(child1)) 01858 { 01859 m_node->_insert (core, toplevel, 0, child2); 01860 childChanges(xmlClass()->kNodeAdded, child2); 01861 return this->atom(); 01862 } 01863 else 01864 { 01865 E4XNode *c1 = core->atomToXML (child1); 01866 // Errata extension to E4X spec - treat XMLList with length=1 as a XMLNode 01867 if (!c1 && core->isXMLList (child1)) 01868 { 01869 XMLListObject *xl = core->atomToXMLList(child1); 01870 if (xl->_length() == 1) 01871 c1 = xl->_getAt(0)->m_node; 01872 } 01873 if (c1) 01874 { 01875 for (uint32 i = 0; i < _length(); i++) 01876 { 01877 E4XNode *child = m_node->_getAt(i); 01878 01879 if (child == c1) 01880 { 01881 m_node->_insert (core, toplevel, i + 1, child2); 01882 childChanges(xmlClass()->kNodeAdded, child2); 01883 return this->atom(); 01884 } 01885 } 01886 } 01887 } 01888 01889 return undefinedAtom; 01890 }
|
|
||||||||||||
|
Definition at line 1893 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), avmplus::AvmCore::atomToXMLList(), avmplus::AvmCore::atomToXMLObject(), avmplus::ScriptObject::core(), getClass(), avmplus::AvmCore::isXML(), avmplus::AvmCore::isXMLList(), avmplus::E4XNode::kAttribute, avmplus::PoolObject::kbug444630, avmplus::E4XNode::kCDATA, avmplus::E4XNode::kComment, avmplus::E4XNode::kProcessingInstruction, avmplus::E4XNode::kText, avmplus::ScriptObject::toplevel(), avmplus::ScriptObject::traits(), and avmplus::AtomConstants::undefinedAtom. Referenced by avmplus::XMLListObject::insertChildBefore(). 01894 { 01895 AvmCore *core = this->core(); 01896 Toplevel *toplevel = this->toplevel(); 01897 01898 if (getClass() & (E4XNode::kText | E4XNode::kComment | E4XNode::kProcessingInstruction | E4XNode::kAttribute | E4XNode::kCDATA)) 01899 return undefinedAtom; 01900 01901 if(!(PoolObject::kbug444630 & traits()->pool->bugFlags)) 01902 { 01903 if (core->isXML(child2)) 01904 { 01905 child2 = core->atomToXMLObject (child2)->atom(); 01906 } 01907 else if (core->isXMLList (child2)) 01908 { 01909 child2 = core->atomToXMLList (child2)->atom(); 01910 } 01911 else // all other types go through XML constructor as a string 01912 { 01913 child2 = xmlClass()->ToXML (core->string(child2)->atom()); 01914 } 01915 } 01916 01917 if (AvmCore::isNull(child1)) 01918 { 01919 m_node->_insert (core, toplevel, _length(), child2); 01920 childChanges(xmlClass()->kNodeAdded, child2); 01921 return this->atom(); 01922 } 01923 else 01924 { 01925 E4XNode *c1 = core->atomToXML (child1); 01926 // Errata extension to E4X spec - treat XMLList with length=1 as a XMLNode 01927 if (!c1 && core->isXMLList (child1)) 01928 { 01929 XMLListObject *xl = core->atomToXMLList(child1); 01930 if (xl->_length() == 1) 01931 c1 = xl->_getAt(0)->m_node; 01932 } 01933 if (c1) 01934 { 01935 for (uint32 i = 0; i < _length(); i++) 01936 { 01937 E4XNode *child = m_node->_getAt(i); 01938 01939 if (child == c1) 01940 { 01941 m_node->_insert (core, toplevel, i, child2); 01942 childChanges(xmlClass()->kNodeAdded, child2); 01943 return this->atom(); 01944 } 01945 } 01946 } 01947 } 01948 01949 return undefinedAtom; 01950 }
|
|
||||||||||||||||||||||||||||||||
|
Perform the callback for each node in which the notification property is set. Definition at line 2736 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), avmplus::ScriptObject::call(), CATCH, avmplus::ScriptObject::core(), END_CATCH, END_TRY, MMgc::GCRoot::GetGC(), avmplus::E4XNode::getNotification(), avmplus::E4XNode::getParent(), avmplus::AvmCore::throwException(), TRY, avmplus::Toplevel::xmlClass(), and XMLObject(). Referenced by childChanges(), and nonChildChanges(). 02737 { 02738 // start notification at initialtarget 02739 E4XNode* node = initialTarget; 02740 02741 while(node) 02742 { 02743 // check if notification param set 02744 ScriptObject* methodObj = node->getNotification(); 02745 if (methodObj) 02746 { 02747 XMLObject* currentTarget = new (core->GetGC()) XMLObject(top->xmlClass(), node); 02748 Atom argv[6] = { top->atom(), currentTarget->atom(), type, target, value, detail }; 02749 int argc = 5; 02750 02751 //EnterScriptTimeout enterScriptTimeout(core); 02752 TRY(core, kCatchAction_Rethrow) 02753 { 02754 methodObj->call(argc, argv); 02755 } 02756 CATCH(Exception *exception) 02757 { 02758 // you chuck, we chuck 02759 core->throwException(exception); 02760 } 02761 END_CATCH 02762 END_TRY 02763 } 02764 02765 // bubble up 02766 node = node->getParent(); 02767 } 02768 }
|
|
|
Definition at line 1953 of file XMLObject.cpp. References build::dependparser::m, and avmplus::AtomConstants::nullStringAtom. Referenced by avmplus::XMLListObject::localName(), and XMLObject(). 01954 { 01955 Multiname m; 01956 if (m_node->getQName(core(), &m) == 0) 01957 { 01958 return nullStringAtom; 01959 } 01960 else 01961 { 01962 return m.getName()->atom(); 01963 } 01964 }
|
|
|
Definition at line 1967 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), avmplus::ScriptObject::core(), avmplus::VTable::getExtraSize(), MMgc::GCRoot::GetGC(), avmplus::ClassClosure::ivtable(), build::dependparser::m, avmplus::AtomConstants::nullObjectAtom, avmplus::Toplevel::qnameClass(), and avmplus::ScriptObject::toplevel(). Referenced by getMultinameProperty(), hasMultinameProperty(), avmplus::XMLListObject::name(), and XMLObject(). 01968 { 01969 AvmCore *core = this->core(); 01970 Multiname m; 01971 if (!m_node->getQName(core, &m)) 01972 return nullObjectAtom; 01973 01974 return (new (core->GetGC(), toplevel()->qnameClass()->ivtable()->getExtraSize()) QNameObject(toplevel()->qnameClass(), m))->atom(); 01975 }
|
|
|
Definition at line 2023 of file XMLObject.cpp. References avmplus::AvmCore::atomToNamespace(), avmplus::E4XNode::BuildInScopeNamespaceList(), avmplus::ScriptObject::core(), avmplus::AtomArray::getAt(), getClass(), MMgc::GCRoot::GetGC(), avmplus::AtomArray::getLength(), avmplus::E4XNode::kAttribute, avmplus::E4XNode::kCDATA, avmplus::E4XNode::kComment, avmplus::E4XNode::kProcessingInstruction, avmplus::E4XNode::kText, and avmplus::ScriptObject::toplevel(). Referenced by avmplus::XMLListObject::namespaceDeclarations(). 02024 { 02025 AvmCore *core = this->core(); 02026 ArrayObject *a = toplevel()->arrayClass->newArray(); 02027 02028 if (getClass() & (E4XNode::kText | E4XNode::kComment | E4XNode::kProcessingInstruction | E4XNode::kAttribute | E4XNode::kCDATA)) 02029 return a; 02030 02031 E4XNode *y = m_node->getParent(); 02032 02033 // step 4+5 02034 AtomArray *ancestorNS = new (core->GetGC()) AtomArray(); 02035 if (y) 02036 y->BuildInScopeNamespaceList (core, ancestorNS); 02037 02038 uint32 arrayIndex = 0; 02039 02040 // step 7+8+9+10 02041 for (uint32 i = 0; i < m_node->numNamespaces(); i++) 02042 { 02043 Namespace *ns = AvmCore::atomToNamespace (m_node->getNamespaces()->getAt(i)); 02044 if (!ns->hasPrefix ()) 02045 { 02046 // Emulating Rhino behavior 02047 if (ns->getURI() != core->kEmptyString) 02048 { 02049 bool bMatch = false; 02050 for (uint32 j = 0; j < ancestorNS->getLength(); j++) 02051 { 02052 Namespace *ns2 = AvmCore::atomToNamespace (ancestorNS->getAt(j)); 02053 if (ns->getURI() == ns2->getURI()) 02054 { 02055 bMatch = true; 02056 break; 02057 } 02058 } 02059 02060 if (!bMatch) 02061 { 02062 a->setUintProperty (arrayIndex++, ns->atom()); 02063 } 02064 } 02065 } 02066 else // ns.prefix is NOT empty 02067 { 02068 bool bMatch = false; 02069 for (uint32 j = 0; j < ancestorNS->getLength(); j++) 02070 { 02071 Namespace *ns2 = AvmCore::atomToNamespace (ancestorNS->getAt(j)); 02072 if (ns->getPrefix() == ns2->getPrefix() && ns->getURI() == ns2->getURI()) 02073 { 02074 bMatch = true; 02075 break; 02076 } 02077 } 02078 02079 if (!bMatch) 02080 { 02081 a->setUintProperty (arrayIndex++, ns->atom()); 02082 } 02083 } 02084 } 02085 02086 return a; 02087 }
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 1524 of file XMLObject.cpp. References avmplus::String::atom(), AvmAssert, avmplus::ScriptObject::core(), avmplus::AvmCore::internInt(), and avmplus::AtomConstants::nullStringAtom. 01525 { 01526 AvmAssert(index > 0); 01527 01528 if (index == 1) 01529 { 01530 AvmCore *core = this->core(); 01531 return core->internInt (0)->atom(); 01532 } 01533 else 01534 { 01535 return nullStringAtom; 01536 } 01537 }
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 1549 of file XMLObject.cpp. References AvmAssert. 01550 { 01551 AvmAssert(index >= 0); 01552 01553 // XML types just return one value 01554 if (index == 0) 01555 return 1; 01556 else 01557 return 0; 01558 }
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 1539 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), AvmAssert, and avmplus::AtomConstants::undefinedAtom. 01540 { 01541 AvmAssert(index > 0); 01542 01543 if (index == 1) 01544 return this->atom(); 01545 else 01546 return undefinedAtom; 01547 }
|
|
|
Definition at line 2089 of file XMLObject.cpp. References AvmAssert, avmplus::E4XNode::kAttribute, avmplus::E4XNode::kCDATA, avmplus::E4XNode::kComment, avmplus::E4XNode::kElement, avmplus::E4XNode::kProcessingInstruction, avmplus::E4XNode::kText, avmplus::E4XNode::kUnknown, avmplus::ScriptObject::toplevel(), and avmplus::Toplevel::xmlClass(). Referenced by avmplus::XMLListObject::nodeKind(). 02090 { 02091 switch (m_node->getClass()) 02092 { 02093 case E4XNode::kAttribute: 02094 return toplevel()->xmlClass()->kAttribute; 02095 case E4XNode::kText: 02096 case E4XNode::kCDATA: 02097 return toplevel()->xmlClass()->kText; 02098 case E4XNode::kComment: 02099 return toplevel()->xmlClass()->kComment; 02100 case E4XNode::kProcessingInstruction: 02101 return toplevel()->xmlClass()->kProcessingInstruction; 02102 case E4XNode::kElement: 02103 return toplevel()->xmlClass()->kElement; 02104 case E4XNode::kUnknown: 02105 default: 02106 AvmAssert(0); 02107 return 0; 02108 } 02109 }
|
|
||||||||||||||||||||
|
Definition at line 428 of file XMLObject.cpp. References avmplus::String::c_str(), avmplus::String::Compare(), avmplus::ScriptObject::core(), avmplus::String::Equals(), avmplus::Namespace::getPrefix(), avmplus::Namespace::hasPrefix(), avmplus::String::length(), and avmplus::AvmCore::string(). Referenced by XMLObject(). 00429 { 00430 if (parentNs && parentNs->hasPrefix()) 00431 { 00432 AvmCore *core = this->core(); 00433 Stringp parentNSName = core->string(parentNs->getPrefix()); 00434 int prefixLen = parentNSName->length(); 00435 00436 // Does nodeName == parentNS:parentName 00437 int totalLen = prefixLen + 1 + parentName->length(); // + 1 for ':' separator 00438 if (totalLen != len) 00439 return false; 00440 00441 if (String::Compare (nodeName, prefixLen, parentNSName->c_str(), prefixLen)) 00442 return false; 00443 00444 if (nodeName[prefixLen] != ':') 00445 return false; 00446 00447 return (parentName->Equals (nodeName + prefixLen + 1, parentName->length())); // +1 for ':' 00448 } 00449 else 00450 { 00451 return parentName->Equals (nodeName, len); 00452 } 00453 }
|
|
||||||||||||||||
|
Definition at line 2721 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), avmplus::ScriptObject::core(), MMgc::GCRoot::GetGC(), issueNotifications(), notifyNeeded(), avmplus::ScriptObject::toplevel(), avmplus::Toplevel::xmlClass(), and XMLObject(). Referenced by setLocalName(). 02722 { 02723 AvmCore* core = this->core(); 02724 Toplevel* top = this->toplevel(); 02725 E4XNode* initialTarget = m_node; 02726 if (notifyNeeded(initialTarget)) 02727 { 02728 XMLObject* target = new (core->GetGC()) XMLObject(top->xmlClass(), initialTarget); 02729 issueNotifications(core, top, initialTarget, target->atom(), type, value, detail); 02730 } 02731 }
|
|
|
Need to check if string is "empty" - 0 length or filled with whitespace Definition at line 2111 of file XMLObject.cpp. References _length(), avmplus::ScriptObject::atom(), childChanges(), avmplus::AvmCore::concatStrings(), avmplus::ScriptObject::core(), avmplus::E4XNode::getClass(), MMgc::GCRoot::GetGC(), getNode(), avmplus::E4XNode::kCDATA, avmplus::E4XNode::kElement, avmplus::E4XNode::kText, notifyNeeded(), avmplus::ScriptObject::toplevel(), xmlClass(), and XMLObject(). Referenced by avmplus::XMLListObject::normalize(). 02112 { 02113 AvmCore* core = this->core(); 02114 02115 bool notify = notifyNeeded(getNode()); 02116 uint32 i = 0; 02117 while (i < _length()) 02118 { 02119 E4XNode *x = m_node->_getAt(i); 02120 if (x->getClass() == E4XNode::kElement) 02121 { 02122 XMLObject *xo = new (core->GetGC()) XMLObject(toplevel()->xmlClass(), x); 02123 xo->normalize(); 02124 delete xo; 02125 i++; 02126 } 02127 else if (x->getClass() & (E4XNode::kText | E4XNode::kCDATA)) 02128 { 02129 Stringp prior = x->getValue(); 02130 while (((i + 1) < _length()) && (m_node->_getAt(i + 1)->getClass() & (E4XNode::kText | E4XNode::kCDATA))) 02131 { 02132 E4XNode *x2 = m_node->_getAt(i + 1); 02133 x->setValue (core->concatStrings(x->getValue(), x2->getValue())); 02134 m_node->_deleteByIndex (i + 1); 02135 02136 if (notify) 02137 { 02138 XMLObject *nd = new (core->GetGC()) XMLObject (xmlClass(), x2); 02139 childChanges(xmlClass()->kNodeRemoved, nd->atom()); 02140 } 02141 } 02143 if (x->getValue()->isWhitespace()) 02144 { 02145 E4XNode* prior = m_node->_getAt(i); 02146 02147 m_node->_deleteByIndex (i); 02148 02149 if (notify) 02150 { 02151 XMLObject *nd = new (core->GetGC()) XMLObject (xmlClass(), prior); 02152 childChanges(xmlClass()->kNodeRemoved, nd->atom()); 02153 } 02154 } 02155 else 02156 { 02157 i++; 02158 } 02159 02160 // notify if the node has changed value 02161 Stringp current = x->getValue(); 02162 if ((current != prior) && notify) 02163 { 02164 XMLObject *xo = new (core->GetGC()) XMLObject (xmlClass(), x); 02165 xo->nonChildChanges(xmlClass()->kTextSet, current->atom(), (prior) ? prior->atom() : undefinedAtom); 02166 } 02167 } 02168 else 02169 { 02170 i++; 02171 } 02172 } 02173 02174 return this; 02175 }
|
|
|
Definition at line 2661 of file XMLObject.cpp. References avmplus::E4XNode::getNotification(), and avmplus::E4XNode::getParent(). Referenced by childChanges(), avmplus::XMLListObject::delUintProperty(), nonChildChanges(), and normalize(). 02662 { 02663 // do a quick probe to see if we need to issue any notifications 02664 bool hit = false; 02665 E4XNode* node = initialTarget; 02666 while(node) 02667 { 02668 if (node->getNotification()) 02669 { 02670 hit = true; 02671 break; 02672 } 02673 node = node->getParent(); 02674 } 02675 return hit; 02676 }
|
|
|
Definition at line 2177 of file XMLObject.cpp. References avmplus::ScriptObject::core(), avmplus::ScriptObject::toplevel(), avmplus::AtomConstants::undefinedAtom, and xmlClass(). Referenced by childIndex(). 02178 { 02179 if (m_node->getParent()) 02180 return (new (core()->GetGC()) XMLObject (toplevel()->xmlClass(), m_node->getParent()))->atom(); 02181 else 02182 return undefinedAtom; 02183 }
|
|
|
Definition at line 2218 of file XMLObject.cpp. References avmplus::ScriptObject::atom(), avmplus::AvmCore::atomToXMLList(), avmplus::AvmCore::atomToXMLObject(), avmplus::ScriptObject::core(), avmplus::AvmCore::isXML(), avmplus::AvmCore::isXMLList(), avmplus::PoolObject::kbug444630, avmplus::ScriptObject::toplevel(), and avmplus::ScriptObject::traits(). Referenced by avmplus::XMLListObject::prependChild(). 02219 { 02220 AvmCore *core = this->core(); 02221 Toplevel *toplevel = this->toplevel(); 02222 02223 if(!(PoolObject::kbug444630 & traits()->pool->bugFlags)) 02224 { 02225 if (core->isXML(value)) 02226 { 02227 value = core->atomToXMLObject (value)->atom(); 02228 } 02229 else if (core->isXMLList (value)) 02230 { 02231 value = core->atomToXMLList (value)->atom(); 02232 } 02233 else // all other types go through XML constructor as a string 02234 { 02235 value = xmlClass()->ToXML (core->string(value)->atom()); 02236 } 02237 } 02238 02239 m_node->_insert (core, toplevel, 0, value); 02240 02241 childChanges(xmlClass()->kNodeAdded, value); 02242 return this; 02243 }
|
|
|
Definition at line 2185 of file XMLObject.cpp. References avmplus::XMLListObject::_append(), avmplus::XMLListObject::_getAt(), avmplus::ScriptObject::atom(), child(), avmplus::ScriptObject::core(), MMgc::GCRoot::GetGC(), avmplus::E4XNode::kProcessingInstruction, build::dependparser::m, avmplus::ScriptObject::toplevel(), and avmplus::Toplevel::ToXMLName(). Referenced by avmplus::XMLListObject::processingInstructions(). 02186 { 02187 AvmCore *core = this->core(); 02188 02189 Multiname m; 02190 toplevel()->ToXMLName(name, m); 02191 02192 XMLListObject *xl = new (core->GetGC()) XMLListObject(toplevel()->xmlListClass(), this->atom()); 02193 02194 if (m.isAttr()) 02195 return xl; 02196 02197 for (uint32 i = 0; i < m_node->_length(); i++) 02198 { 02199 E4XNode *child = m_node->_getAt(i); 02200 02201 if (child->getClass() == E4XNode::kProcessingInstruction) 02202 { 02203 Multiname m2; 02204 bool bFound = child->getQName(core, &m2); 02205 02206 // if name.localName = "*" or name.localName =child->name.localName) 02207 // and (name.uri == null) or (name.uri == child.name.uri)) 02208 if (m.matches (bFound ? &m2 : 0)) 02209 { 02210 xl->_append (child); 02211 } 02212 } 02213 } 02214 02215 return xl; 02216 }
|
|
|
Definition at line 2255 of file XMLObject.cpp. References avmplus::AvmCore::atomToNamespace(), AvmAssert, avmplus::ScriptObject::core(), getClass(), GetNamespace(), getQName(), avmplus::AvmCore::isNamespace(), avmplus::E4XNode::kAttribute, avmplus::E4XNode::kCDATA, avmplus::E4XNode::kComment, avmplus::E4XNode::kProcessingInstruction, avmplus::E4XNode::kText, build::dependparser::m, and avmplus::AvmCore::newNamespace(). Referenced by avmplus::XMLListObject::removeNamespace(). 02256 { 02257 AvmCore *core = this->core(); 02258 if (getClass() & (E4XNode::kText | E4XNode::kComment | E4XNode::kProcessingInstruction | E4XNode::kAttribute | E4XNode::kCDATA)) 02259 return this; 02260 02261 Namespace *ns = core->isNamespace (nsAtom) ? AvmCore::atomToNamespace (nsAtom) : core->newNamespace (nsAtom); 02262 02263 Multiname m; 02264 AvmAssert(getQName(&m)); 02265 getQName(&m); 02266 Namespace *thisNS = GetNamespace (m, m_node->getNamespaces()); 02267 02268 // step 4 02269 if (thisNS == ns) 02270 return this; 02271 02272 //step 5 02273 for (uint32 j = 0; j < m_node->numAttributes(); j++) 02274 { 02275 E4XNode *a = m_node->getAttribute(j); 02276 Multiname m; 02277 AvmAssert(a->getQName(core, &m)); 02278 a->getQName(core, &m); 02279 Namespace *anNS = GetNamespace (m, m_node->getNamespaces()); 02280 if (anNS == ns) 02281 return this; 02282 } 02283 02284 // step 6+7 02285 int32 i = m_node->FindMatchingNamespace (core, ns); 02286 if (i != -1) 02287 { 02288 m_node->getNamespaces()->removeAt(i); 02289 } 02290 02291 // step 8 02292 for (uint32 k = 0; k < _length(); k++) 02293 { 02294 E4XNode *p = m_node->_getAt(k); 02295 if (p->getClass() == E4XNode::kElement) 02296 { 02297 XMLObject *xo = new (core->GetGC()) XMLObject(toplevel()->xmlClass(), p); 02298 xo->removeNamespace (ns->atom()); 02299 delete xo; 02300 } 02301 } 02302 02303 // step 9 02304 // Note about namespaces in ancestors and parents, etc. 02305 nonChildChanges(xmlClass()->kNamespaceRemoved, ns->atom()); 02306 return this; 02307 }
|
|
||||||||||||
|
Definition at line 2309 of file XMLObject.cpp. References _deepCopy(), avmplus::ScriptObject::atom(), avmplus::AvmCore::atomToXMLObject(), avmplus::ScriptObject::core(), getClass(), avmplus::AvmCore::isXML(), avmplus::E4XNode::kAttribute, avmplus::E4XNode::kCDATA, avmplus::E4XNode::kComment, avmplus::E4XNode::kProcessingInstruction, avmplus::E4XNode::kText, and avmplus::ScriptObject::toplevel(). Referenced by avmplus::XMLListObject::replace(). 02310 { 02311 AvmCore *core = this->core(); 02312 Toplevel *toplevel = this->toplevel(); 02313 02314 if (getClass() & (E4XNode::kText | E4XNode::kComment | E4XNode::kProcessingInstruction | E4XNode::kAttribute | E4XNode::kCDATA)) 02315 return this; 02316 02317 Atom c; 02318 if (core->isXML(value)) 02319 { 02320 XMLObject *x = core->atomToXMLObject (value); 02321 c = x->_deepCopy()->atom(); 02322 } 02323 else if (core->isXMLList(value)) 02324 { 02325 XMLListObject *xl = core->atomToXMLList (value); 02326 c = xl->_deepCopy()->atom(); 02327 } 02328 else 02329 { 02330 if(!(PoolObject::kbug444630 & traits()->pool->bugFlags)) 02331 c = xmlClass()->ToXML (core->string(value)->atom()); 02332 else 02333 c = core->string(value)->atom(); 02334 } 02335 02336 uint32 index; 02337 if (AvmCore::getIndexFromString (core->string(P), &index)) 02338 { 02339 E4XNode* prior = m_node->_replace (core, toplevel, index, c); 02340 childChanges(xmlClass()->kNodeChanged, c, prior); 02341 return this; 02342 } 02343 02344 QNameObject *qn1 = new (core->GetGC(), toplevel->qnameClass()->ivtable()->getExtraSize()) QNameObject(toplevel->qnameClass(), P); 02345 Multiname m; 02346 qn1->getMultiname(m); 02347 bool notify = notifyNeeded(getNode()); 02348 int i = -1; 02349 for (int k = int(_length()) - 1; k >= 0; k--) 02350 { 02351 E4XNode *x = m_node->_getAt (k); 02352 Multiname *m2 = 0; 02353 02354 // m3 needs to exist outside this if scope since m2 will point to it 02355 Multiname m3; 02356 if (x->getClass() == E4XNode::kElement) 02357 { 02358 if (x->getQName (core, &m3)) 02359 m2 = &m3; 02360 } 02361 02362 if (m.matches(m2)) 02363 { 02364 if (i != -1) 02365 { 02366 E4XNode* was = m_node->_getAt(i); 02367 02368 m_node->_deleteByIndex (i); 02369 02370 // notify 02371 if (notify && was->getClass() == E4XNode::kElement) 02372 { 02373 XMLObject* nd = new (core->GetGC()) XMLObject (xmlClass(), was); 02374 childChanges(xmlClass()->kNodeRemoved, nd->atom()); 02375 } 02376 } 02377 02378 i = k; 02379 } 02380 } 02381 delete qn1; 02382 02383 if (i == -1) 02384 return this; 02385 02386 E4XNode* prior = m_node->_replace (core, toplevel, i, c); 02387 childChanges( (prior) ? xmlClass()->kNodeChanged : xmlClass()->kNodeAdded, c, prior); 02388 return this; 02389 }
|
|
||||||||||||
|
Reimplemented from avmplus::ScriptObject. Definition at line 1007 of file XMLObject.cpp. References build::dependparser::m, setMultinameProperty(), avmplus::ScriptObject::toplevel(), and avmplus::Toplevel::ToXMLName(). 01008 { 01009 Multiname m; 01010 toplevel()->ToXMLName(P, m); 01011 setMultinameProperty(&m, V); 01012 }
|
|
|
Definition at line 2391 of file XMLObject.cpp. References avmplus::ScriptObject::core(), and avmplus::ScriptObject::setStringProperty(). Referenced by avmplus::XMLListObject::setChildren(). 02392 { 02393 setStringProperty(core()->kAsterisk, value); 02394 return this; 02395 }
|
|
|
Definition at line 2397 of file XMLObject.cpp. References avmplus::String::atom(), avmplus::AvmCore::atomToQName(), avmplus::ScriptObject::core(), avmplus::QNameObject::getLocalName(), getNode(), avmplus::E4XNode::getQName(), avmplus::AvmCore::intern(), avmplus::AvmCore::isXMLName(), avmplus::E4XNode::kCDATA, avmplus::E4XNode::kComment, avmplus::E4XNode::kText, avmplus::ErrorConstants::kXMLInvalidName, build::dependparser::m, nonChildChanges(), avmplus::E4XNode::setQName(), avmplus::Toplevel::throwTypeError(), avmplus::ScriptObject::toplevel(), avmplus::AtomConstants::undefinedAtom, and xmlClass(). Referenced by avmplus::XMLListObject::setLocalName(). 02398 { 02399 if (m_node->getClass() & (E4XNode::kText | E4XNode::kComment | E4XNode::kCDATA)) 02400 return; 02401 02402 AvmCore *core = this->core(); 02403 02404 QNameObject *qn = core->atomToQName (name); 02405 Stringp newname; 02406 if (qn) 02407 { 02408 newname = qn->getLocalName(); 02409 } 02410 else 02411 { 02412 newname = core->intern(name); 02413 } 02414 02415 if (!core->isXMLName (newname->atom())) 02416 toplevel()->throwTypeError(kXMLInvalidName, newname); 02417 02418 Multiname m; 02419 if (this->getNode()->getQName(core, &m)) 02420 { 02421 Multiname previous; 02422 getNode()->getQName(core, &previous); 02423 Stringp prior = previous.getName(); 02424 02425 m.setName (newname); 02426 getNode()->setQName (core, &m); 02427 02428 nonChildChanges(xmlClass()->kNameSet, m.getName()->atom(), (prior) ? prior->atom() : undefinedAtom ); 02429 } 02430 return; 02431 }
|
|
||||||||||||
|
Reimplemented from avmplus::ScriptObject. Definition at line 585 of file XMLObject.cpp. References avmplus::Toplevel::CoerceE4XMultiname(), avmplus::ScriptObject::core(), avmplus::AvmCore::getIndexFromString(), avmplus::ErrorConstants::kXMLAssignmentToIndexedXMLNotAllowed, build::dependparser::m, avmplus::Toplevel::throwTypeError(), and avmplus::ScriptObject::toplevel(). Referenced by setAtomProperty(), and avmplus::XMLListObject::setMultinameProperty(). 00586 { 00587 AvmCore *core = this->core(); 00588 Toplevel* toplevel = this->toplevel(); 00589 00590 Multiname m; 00591 toplevel->CoerceE4XMultiname(name_in, m); 00592 00593 // step 3 00594 if (!m.isAnyName() && !m.isAttr()) 00595 { 00596 Stringp name = m.getName(); 00597 uint32 index; 00598 if (AvmCore::getIndexFromString (name, &index)) 00599 { 00600 // Spec says: NOTE: this operation is reserved for future versions of E4X 00601 toplevel->throwTypeError(kXMLAssignmentToIndexedXMLNotAllowed); 00602 } 00603 } 00604 00605 // step 4 00606 if (getClass() & (E4XNode::kText | E4XNode::kCDATA | E4XNode::kComment | E4XNode::kProcessingInstruction | E4XNode::kAttribute)) 00607 return; 00608 00609 Atom c; 00610 if (core->atomToXMLList(V)) 00611 { 00612 XMLListObject *src = core->atomToXMLList (V); 00613 if ((src->_length() == 1) && src->_getAt(0)->getClass() & (E4XNode::kText | E4XNode::kAttribute)) 00614 { 00615 c = core->string(V)->atom(); 00616 } 00617 else 00618 { 00619 c = src->_deepCopy()->atom(); 00620 } 00621 } 00622 else if (core->atomToXML (V)) 00623 { 00624 XMLObject *x = core->atomToXMLObject (V); 00625 if (x->getClass() & (E4XNode::kText | E4XNode::kAttribute)) 00626 { 00627 // This string is converted into a XML object below in step 2(g)(iii) 00628 c = core->string(V)->atom(); 00629 } 00630 else 00631 { 00632 c = x->_deepCopy()->atom(); 00633 } 00634 } 00635 else 00636 { 00637 #ifdef STRING_DEBUG 00638 String *foo = core->string(V); 00639 #endif // STRING_DEBUG 00640 c = core->string(V)->atom(); 00641 } 00642 00643 // step 5 00644 //Atom n = core->ToXMLName (P); 00645 // step 6 00646 //Atom defaultNamespace = core->getDefaultNamespace()->atom(); 00647 00648 // step 7 00649 if (m.isAttr()) 00650 { 00651 // step 7b 00652 Stringp sc; 00653 if (core->isXMLList (c)) 00654 { 00655 XMLListObject *xl = core->atomToXMLList (c); 00656 if (!xl->_length()) 00657 { 00658 sc = core->kEmptyString; 00659 } 00660 else 00661 { 00662 StringBuffer output (core); 00663 output << core->string (xl->_getAt (0)->atom()); 00664 for (uint32 i = 1; i < xl->_length(); i++) 00665 { 00666 output << " " << core->string (xl->_getAt (i)->atom()); 00667 } 00668 00669 sc = core->newString (output.c_str()); 00670 } 00671 } 00672 else // step 7c 00673 { 00674 sc = core->string (c); 00675 } 00676 00677 // step 7d 00678 int a = -1; // -1 is null in spec 00679 // step 7e 00680 for (uint32 j = 0; j < this->m_node->numAttributes(); j++) 00681 { 00682 E4XNode *x = m_node->getAttribute(j); 00683 Multiname m2; 00684 x->getQName(core, &m2); 00685 if (m.matches (&m2)) 00686 { 00687 if (a == -1) 00688 { 00689 a = j; 00690 } 00691 else 00692 { 00693 this->deleteMultinameProperty(&m2); 00694 // notification occurrs in deleteproperty 00695 } 00696 } 00697 } 00698 if (a == -1) // step 7f 00699 { 00700 E4XNode *e = new (core->GetGC()) AttributeE4XNode(this->m_node, sc); 00701 Namespace *ns = 0; 00702 if (m.namespaceCount() == 1) 00703 ns = m.getNamespace(); 00704 e->setQName (core, m.getName(), ns); 00705 00706 this->m_node->addAttribute (e); 00707 00708 e->_addInScopeNamespace (core, ns); 00709 00710 nonChildChanges(xmlClass()->kAttrAdded, m.getName()->atom(), sc->atom()); 00711 } 00712 else // step 7g 00713 { 00714 E4XNode *x = m_node->getAttribute(a); 00715 Stringp prior = x->getValue(); 00716 x->setValue (sc); 00717 00718 nonChildChanges(xmlClass()->kAttrChanged, m.getName()->atom(), (prior) ? prior->atom() : undefinedAtom); 00719 } 00720 00721 // step 7h 00722 return; 00723 } 00724 00725 if (!m.isAnyName()) 00726 { 00727 // step 8 00728 bool isValidName = core->isXMLName (m.getName()->atom()); 00729 00730 // step 9 00731 if (!isValidName) 00732 return; 00733 } 00734 00735 // step 10 00736 int32 i = -1; // -1 is undefined in spec 00737 bool primitiveAssign = ((!core->isXML (c) && !core->isXMLList (c)) && 00738 (!m.isAnyName())); 00739 00740 // step 12 00741 bool notify = notifyNeeded(getNode()); 00742 for (int k = _length() - 1; k >= 0; k--) 00743 { 00744 E4XNode *x = m_node->_getAt(k); 00745 Multiname mx; 00746 Multiname *m2 = 0; 00747 00748 if (x->getClass() == E4XNode::kElement) 00749 { 00750 x->getQName (core, &mx); 00751 m2 = &mx; 00752 } 00753 00754 if (m.matches (m2)) 00755 { 00756 // remove n-1 nodes of n matching 00757 if (i != -1) 00758 { 00759 E4XNode* was = m_node->_getAt(i); 00760 00761 m_node->_deleteByIndex (i); 00762 00763 // notify 00764 if (notify && (was->getClass() == E4XNode::kElement)) 00765 { 00766 XMLObject* nd = new (core->GetGC()) XMLObject (toplevel->xmlClass(), was); 00767 childChanges(xmlClass()->kNodeRemoved, nd->atom()); 00768 } 00769 } 00770 00771 i = k; 00772 } 00773 } 00774 00775 // step 13 00776 if (i == -1) 00777 { 00778 i = _length(); 00779 if (primitiveAssign) 00780 { 00781 E4XNode *e = new (core->GetGC()) ElementE4XNode (m_node); 00782 // We use m->namespaceCount here to choose to use the default xml namespace 00783 // name here for an unqualified prop access. For a qualified access, 00784 // there will be only one namespace 00785 Stringp name = m.getName(); 00786 Namespace *ns; 00787 if (m.namespaceCount() == 1) 00788 ns = m.getNamespace(); 00789 else 00790 ns = toplevel->getDefaultNamespace(); 00791 e->setQName (core, name, ns); 00792 00793 XMLObject *y = new (core->GetGC()) XMLObject (toplevel->xmlClass(), e); 00794 00795 m_node->_replace (core, toplevel, i, y->atom()); 00796 e->_addInScopeNamespace (core, ns); 00797 } 00798 } 00799 00800 // step 14 00801 if (primitiveAssign) 00802 { 00803 E4XNode *xi = m_node->_getAt(i); 00804 00805 // children are being removed notify parent if necc. 00806 bool notify = notifyNeeded(xi); 00807 XMLObject* target = (notify) ? new (core->GetGC()) XMLObject(xmlClass(), xi) : 0; 00808 00809 int count = xi->numChildren(); 00810 for(int r=0;notify && (r<count); r++) 00811 { 00812 E4XNode* ild = xi->_getAt(r); 00813 if (ild->getClass() == E4XNode::kElement) 00814 { 00815 XMLObject* nd = new (core->GetGC()) XMLObject (toplevel->xmlClass(), ild); 00816 target->childChanges(xmlClass()->kNodeRemoved, nd->atom()); 00817 } 00818 } 00819 00820 // remember node if there was one... 00821 Atom prior = undefinedAtom; 00822 if (notify && count > 0) 00823 { 00824 XMLObject* nd = new (core->GetGC()) XMLObject (toplevel->xmlClass(), xi->_getAt(0)); 00825 prior = nd->atom(); 00826 } 00827 00828 // step 14a - delete all properties of x[i] 00829 xi->clearChildren(); 00830 00831 Stringp s = core->string (c); 00832 if (s->length()) 00833 { 00834 xi->_replace (core, toplevel, i, c, prior); 00835 } 00836 } 00837 else 00838 { 00839 E4XNode* prior = m_node->_replace (core, toplevel, i, c); 00840 00841 if (notifyNeeded(getNode())) 00842 { 00843 // The above _replace call may be used to insert new nodes at the end. However, if a null is inserted 00844 // the effect is as though nothing was inserted. Test for this case. 00845 if (m_node->_length() > (avmplus::uint32)i) 00846 { 00847 XMLObject* xml = new (core->GetGC()) XMLObject(xmlClass(), m_node->_getAt(i)); 00848 childChanges( (prior) ? xmlClass()->kNodeChanged : xmlClass()->kNodeAdded, xml->atom(), prior); 00849 } 00850 } 00851 } 00852 return; 00853 }
|
|
|
Definition at line 2433 of file XMLObject.cpp. References avmplus::String::atom(), avmplus::AvmCore::atomToQName(), avmplus::ScriptObject::core(), avmplus::QNameObject::getLocalName(), avmplus::AvmCore::isNull(), avmplus::AvmCore::isQName(), avmplus::E4XNode::kCDATA, avmplus::E4XNode::kComment, and avmplus::E4XNode::kText. Referenced by avmplus::XMLListObject::setName(). 02434 { 02435 AvmCore *core = this->core(); 02436 02437 if (m_node->getClass() & (E4XNode::kText | E4XNode::kComment | E4XNode::kCDATA)) 02438 return; 02439 02440 if (core->isQName (name)) 02441 { 02442 QNameObject *q = core->atomToQName (name); 02443 if (AvmCore::isNull(q->getURI())) 02444 { 02445 name = q->getLocalName()->atom(); 02446 } 02447 } 02448 02449 QNameObject *n = new (core->GetGC(), toplevel()->qnameClass()->ivtable()->getExtraSize()) QNameObject(toplevel()->qnameClass(), name); 02450 02451 Stringp s = n->getLocalName(); 02452 if (!core->isXMLName (s->atom())) 02453 toplevel()->throwTypeError(kXMLInvalidName, s); 02454 02455 Multiname m; 02456 if (m_node->getQName(core, &m)) 02457 { 02458 if (m_node->getClass() == E4XNode::kProcessingInstruction) 02459 { 02460 m_node->setQName (core, n->getLocalName(), core->publicNamespace); 02461 } 02462 else // only for attribute and element nodes 02463 { 02464 Multiname m2; 02465 n->getMultiname (m2); 02466 m_node->setQName (core, &m2); 02467 02468 // ISNS changes 02469 if (n->getURI() != core->kEmptyString->atom()) 02470 { 02471 m_node->getQName(core, &m); // get our new multiname 02472 02473 if (this->getClass() == E4XNode::kAttribute && getNode()->getParent()) 02474 { 02475 getNode()->getParent()->_addInScopeNamespace (core, m.getNamespace()); 02476 } 02477 else if (this->getClass() == E4XNode::kElement) 02478 { 02479 getNode()->_addInScopeNamespace (core, m.getNamespace()); 02480 } 02481 } 02482 } 02483 02484 nonChildChanges(xmlClass()->kNameSet, name, m.getName()->atom()); 02485 } 02486 return; 02487 }
|
|
|
Definition at line 2489 of file XMLObject.cpp. References avmplus::ScriptObject::core(), avmplus::E4XNode::kCDATA, avmplus::E4XNode::kComment, avmplus::E4XNode::kProcessingInstruction, avmplus::E4XNode::kText, build::dependparser::m, and avmplus::AvmCore::newNamespace(). Referenced by avmplus::XMLListObject::setNamespace(). 02490 { 02491 AvmCore *core = this->core(); 02492 02493 if (m_node->getClass() & (E4XNode::kText | E4XNode::kComment | E4XNode::kProcessingInstruction | E4XNode::kCDATA)) 02494 return; 02495 02496 Namespace* newns = core->newNamespace (ns); 02497 02498 Multiname m; 02499 if (m_node->getQName(core, &m)) 02500 { 02501 m_node->setQName (core, m.getName(), newns); 02502 } 02503 02504 // ISNS changes 02505 if (this->getClass() == E4XNode::kAttribute && getNode()->getParent()) 02506 { 02507 getNode()->getParent()->_addInScopeNamespace (core, newns); 02508 } 02509 else if (this->getClass() == E4XNode::kElement) 02510 { 02511 getNode()->_addInScopeNamespace (core, newns); 02512 } 02513 02514 nonChildChanges(xmlClass()->kNamespaceSet, newns->atom()); 02515 return; 02516 }
|
|
|
Definition at line 131 of file XMLObject.h. References MMgc::GC::GetGC(), m_node, and WB. Referenced by XMLObject(), and ~XMLObject(). 00131 { WB(MMgc::GC::GetGC(this), this, &m_node, node); }
|
|
|
Definition at line 2645 of file XMLObject.cpp. References avmplus::ScriptObject::core(), runtests::f, avmplus::BuiltinTraits::function_itraits, avmplus::AvmCore::istype(), avmplus::ErrorConstants::kInvalidArgumentError, avmplus::Toplevel::throwArgumentError(), avmplus::ScriptObject::toplevel(), and avmplus::AvmCore::traits. 02646 { 02647 AvmCore* core = this->core(); 02648 02649 // Notifiers MUST be functions or null 02650 if (f && !core->istype(f->atom(), core->traits.function_itraits)) 02651 toplevel()->throwArgumentError( kInvalidArgumentError, "f"); 02652 else 02653 m_node->setNotification(core, f); 02654 }
|
|
||||||||||||
|
Reimplemented from avmplus::ScriptObject. Definition at line 1022 of file XMLObject.cpp. References avmplus::ErrorConstants::kXMLAssignmentToIndexedXMLNotAllowed, avmplus::Toplevel::throwTypeError(), and avmplus::ScriptObject::toplevel(). 01023 { 01024 // Spec says: NOTE: this operation is reserved for future versions of E4X 01025 toplevel()->throwTypeError(kXMLAssignmentToIndexedXMLNotAllowed); 01026 }
|
|
|
Definition at line 2630 of file XMLObject.cpp. Referenced by avmplus::XMLListObject::normalize(). 02631 { 02632 m_node->setValue (s); 02633 }
|
|
|
Definition at line 2518 of file XMLObject.cpp. References avmplus::XMLListObject::_append(), avmplus::XMLListObject::_getAt(), avmplus::ScriptObject::atom(), child(), avmplus::ScriptObject::gc(), avmplus::E4XNode::kCDATA, avmplus::E4XNode::kText, and avmplus::ScriptObject::toplevel(). Referenced by avmplus::XMLListObject::text(). 02519 { 02520 XMLListObject *l = new (gc()) XMLListObject(toplevel()->xmlListClass(), this->atom()); 02521 02522 for (uint32 i = 0; i < m_node->_length(); i++) 02523 { 02524 E4XNode *child = m_node->_getAt(i); 02525 if (child->getClass() & (E4XNode::kText | E4XNode::kCDATA)) 02526 { 02527 l->_append (child); 02528 } 02529 } 02530 02531 return l; 02532 }
|
|
|
Reimplemented from avmplus::ScriptObject. Definition at line 2535 of file XMLObject.cpp. References avmplus::XMLListObject::_getAt(), _length(), avmplus::String::atom(), child(), avmplus::AvmCore::concatStrings(), avmplus::ScriptObject::core(), getClass(), MMgc::GCRoot::GetGC(), hasSimpleContent(), avmplus::E4XNode::kAttribute, avmplus::E4XNode::kCDATA, avmplus::E4XNode::kComment, avmplus::E4XNode::kProcessingInstruction, avmplus::E4XNode::kText, avmplus::AvmCore::string(), avmplus::ScriptObject::toplevel(), toString(), xmlClass(), and XMLObject(). Referenced by toString(), and toStringMethod(). 02536 { 02537 AvmCore *core = this->core(); 02538 02539 if (getClass() & (E4XNode::kText | E4XNode::kCDATA | E4XNode::kAttribute)) 02540 { 02541 return m_node->getValue()->atom(); 02542 } 02543 02544 if (hasSimpleContent()) 02545 { 02546 Stringp s = core->kEmptyString; 02547 02548 for (uint32 i = 0; i < _length(); i++) 02549 { 02550 E4XNode *child = m_node->_getAt(i); 02551 if ((child->getClass() != E4XNode::kComment) && (child->getClass() != E4XNode::kProcessingInstruction)) 02552 { 02553 02554 XMLObject *xo = new (core->GetGC()) XMLObject(toplevel()->xmlClass(), child); 02555 s = core->concatStrings(s, core->string(xo->toString())); 02556 delete xo; 02557 } 02558 } 02559 02560 return s->atom(); 02561 } 02562 else 02563 { 02564 AtomArray *AncestorNamespaces = new (core->GetGC()) AtomArray(); 02565 StringBuffer s(core); 02566 __toXMLString(s, AncestorNamespaces, 0); 02567 return core->newString(s.c_str())->atom(); 02568 } 02569 }
|
|
|
Definition at line 2571 of file XMLObject.cpp. References avmplus::AvmCore::atomToString(), avmplus::ScriptObject::core(), and toString(). 02572 { 02573 // This is a non-virtual version of toString. 02574 // This method is needed because pointer->method in Codewarrior 02575 // is different depending on wheher the method is virtual or not, 02576 // causing problems with NATIVE_METHOD. 02577 return core()->atomToString(toString()); 02578 }
|
|
|
Definition at line 2580 of file XMLObject.cpp. References __toXMLString(), avmplus::StringBuffer::c_str(), avmplus::ScriptObject::core(), MMgc::GC::GetGC(), and avmplus::AvmCore::newString(). Referenced by avmplus::AvmCore::ToXMLString(). 02581 { 02582 AtomArray *AncestorNamespaces = new (MMgc::GC::GetGC(this)) AtomArray(); 02583 StringBuffer s(core()); 02584 __toXMLString(s, AncestorNamespaces, 0); 02585 return core()->newString(s.c_str()); 02586 }
|
|
|
Definition at line 118 of file XMLObject.h. References avmplus::ScriptObject::toplevel(), and avmplus::Toplevel::xmlClass(). Referenced by __toXMLString(), _deepCopy(), childChanges(), getParent(), normalize(), parent(), setLocalName(), and toString(). 00119 { 00120 return toplevel()->xmlClass(); 00121 }
|
|
|
Definition at line 2245 of file XMLObject.cpp. References avmplus::ScriptObject::core(), avmplus::AvmCore::intern(), avmplus::AvmCore::internString(), and avmplus::AvmCore::newString(). 02246 { 02247 AvmCore *core = this->core(); 02248 if (core->intern(P) == core->internString (core->newString("0"))) 02249 return true; 02250 02251 return false; 02252 }
|
|
|
Definition at line 126 of file XMLObject.h. |
|
|
Definition at line 124 of file XMLObject.h. Referenced by getNode(), setNode(), and XMLObject(). |
1.4.6