Structure* Structure::nonPropertyTransition(JSGlobalData& globalData, Structure* structure, NonPropertyTransition transitionKind) { unsigned attributes = toAttributes(transitionKind); IndexingType indexingType = newIndexingType(structure->indexingTypeIncludingHistory(), transitionKind); if (JSGlobalObject* globalObject = structure->m_globalObject.get()) { if (globalObject->isOriginalArrayStructure(structure)) { Structure* result = globalObject->originalArrayStructureForIndexingType(indexingType); if (result->indexingTypeIncludingHistory() == indexingType) { structure->notifyTransitionFromThisStructure(); return result; } } } if (Structure* existingTransition = structure->m_transitionTable.get(0, attributes)) { ASSERT(existingTransition->m_attributesInPrevious == attributes); ASSERT(existingTransition->indexingTypeIncludingHistory() == indexingType); return existingTransition; } Structure* transition = create(globalData, structure); transition->setPreviousID(globalData, transition, structure); transition->m_attributesInPrevious = attributes; transition->m_indexingType = indexingType; transition->propertyTable().set(globalData, transition, structure->takePropertyTableOrCloneIfPinned(globalData, transition)); transition->m_offset = structure->m_offset; checkOffset(transition->m_offset, transition->inlineCapacity()); structure->m_transitionTable.add(globalData, transition); transition->checkOffsetConsistency(); return transition; }
/** * Gets the index of the attribute with the given qualified name. * * @param attributePointer to the attribute array * @param qName to look for * @returns index of attribute with the given uri and local name or -1 if not * found */ static jint ExpatAttributes_getIndexForQName(JNIEnv* env, jobject, jlong attributePointer, jstring qName) { ScopedUtfChars qNameBytes(env, qName); if (qNameBytes.c_str() == NULL) { return -1; } const char** attributes = toAttributes(attributePointer); int found = -1; for (int index = 0; attributes[index * 2]; ++index) { if (ExpatElementName(NULL, NULL, attributePointer, index).matchesQName(qNameBytes.c_str())) { found = index; break; } } return found; }
Structure* Structure::nonPropertyTransition(JSGlobalData& globalData, Structure* structure, NonPropertyTransition transitionKind) { unsigned attributes = toAttributes(transitionKind); IndexingType indexingType = newIndexingType(structure->indexingTypeIncludingHistory(), transitionKind); if (JSGlobalObject* globalObject = structure->m_globalObject.get()) { if (globalObject->isOriginalArrayStructure(structure)) { Structure* result = globalObject->originalArrayStructureForIndexingType(indexingType); if (result->indexingTypeIncludingHistory() == indexingType) { structure->notifyTransitionFromThisStructure(); return result; } } } if (Structure* existingTransition = structure->m_transitionTable.get(0, attributes)) { ASSERT(existingTransition->m_attributesInPrevious == attributes); ASSERT(existingTransition->indexingTypeIncludingHistory() == indexingType); return existingTransition; } Structure* transition = create(globalData, structure); transition->m_previous.set(globalData, transition, structure); transition->m_attributesInPrevious = attributes; transition->m_indexingType = indexingType; transition->m_offset = structure->m_offset; checkOffset(transition->m_offset, transition->inlineCapacity()); if (structure->m_propertyTable) { if (structure->m_isPinnedPropertyTable) transition->m_propertyTable = structure->m_propertyTable->copy(globalData, transition, structure->m_propertyTable->size() + 1); else transition->m_propertyTable = structure->m_propertyTable.release(); } else { if (structure->m_previous) transition->materializePropertyMap(globalData); else transition->createPropertyMap(); } structure->m_transitionTable.add(globalData, transition); return transition; }
/** * Gets the index of the attribute with the given URI and name. * * @param attributePointer to the attribute array * @param uri to look for * @param localName to look for * @returns index of attribute with the given uri and local name or -1 if not * found */ static jint ExpatAttributes_getIndex(JNIEnv* env, jobject, jlong attributePointer, jstring uri, jstring localName) { ScopedUtfChars uriBytes(env, uri); if (uriBytes.c_str() == NULL) { return -1; } ScopedUtfChars localNameBytes(env, localName); if (localNameBytes.c_str() == NULL) { return -1; } const char** attributes = toAttributes(attributePointer); for (int index = 0; attributes[index * 2]; ++index) { if (ExpatElementName(NULL, NULL, attributePointer, index).matches(uriBytes.c_str(), localNameBytes.c_str())) { return index; } } return -1; }
ExpatElementName(JNIEnv* env, ParsingContext* parsingContext, jlong attributePointer, jint index) { const char** attributes = toAttributes(attributePointer); const char* name = attributes[index * 2]; init(env, parsingContext, name); }
/** * Gets the value of the attribute at the given index. * * @param object Java ExpatParser instance * @param attributePointer to the attribute array * @param index of the attribute * @returns Java string containing attribute's value */ static jstring ExpatAttributes_getValueByIndex(JNIEnv* env, jobject, jlong attributePointer, jint index) { const char** attributes = toAttributes(attributePointer); const char* value = attributes[(index * 2) + 1]; return env->NewStringUTF(value); }