Loading tools/aapt/XMLNode.cpp +46 −31 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ bool isWhitespace(const char16_t* str) static const String16 RESOURCES_PREFIX(RESOURCES_ROOT_NAMESPACE); static const String16 RESOURCES_PRV_PREFIX(RESOURCES_ROOT_PRV_NAMESPACE); static const String16 RESOURCES_TOOLS_NAMESPACE("http://schemas.android.com/tools"); String16 getNamespaceResourcePackage(String16 namespaceUri, bool* outIsPublic) { Loading Loading @@ -761,6 +762,8 @@ status_t XMLNode::addAttribute(const String16& ns, const String16& name, SourcePos(mFilename, getStartLineNumber()).error("Child to CDATA node."); return UNKNOWN_ERROR; } if (ns != RESOURCES_TOOLS_NAMESPACE) { attribute_entry e; e.index = mNextAttributeIndex++; e.ns = ns; Loading @@ -768,6 +771,7 @@ status_t XMLNode::addAttribute(const String16& ns, const String16& name, e.string = value; mAttributes.add(e); mAttributeOrder.add(e.index, mAttributes.size()-1); } return NO_ERROR; } Loading Loading @@ -1215,12 +1219,14 @@ status_t XMLNode::collect_strings(StringPool* dest, Vector<uint32_t>* outResIds, collect_attr_strings(dest, outResIds, true); int i; if (RESOURCES_TOOLS_NAMESPACE != mNamespaceUri) { if (mNamespacePrefix.size() > 0) { dest->add(mNamespacePrefix, true); } if (mNamespaceUri.size() > 0) { dest->add(mNamespaceUri, true); } } if (mElementName.size() > 0) { dest->add(mElementName, true); } Loading Loading @@ -1338,6 +1344,7 @@ status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& de const void* extData = NULL; size_t extSize = 0; ResXMLTree_attribute attr; bool writeCurrentNode = true; const size_t NA = mAttributes.size(); const size_t NC = mChildren.size(); Loading Loading @@ -1395,6 +1402,9 @@ status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& de } } } else if (type == TYPE_NAMESPACE) { if (mNamespaceUri == RESOURCES_TOOLS_NAMESPACE) { writeCurrentNode = false; } else { node.header.type = htods(RES_XML_START_NAMESPACE_TYPE); extData = &namespaceExt; extSize = sizeof(namespaceExt); Loading @@ -1406,6 +1416,7 @@ status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& de } namespaceExt.prefix.index = htodl(strings.offsetForString(mNamespacePrefix)); namespaceExt.uri.index = htodl(strings.offsetForString(mNamespaceUri)); } LOG_ALWAYS_FATAL_IF(NA != 0, "Namespace nodes can't have attributes!"); } else if (type == TYPE_CDATA) { node.header.type = htods(RES_XML_CDATA_TYPE); Loading @@ -1422,10 +1433,12 @@ status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& de node.header.size = htodl(sizeof(node) + extSize + (sizeof(attr)*NA)); if (writeCurrentNode) { dest->writeData(&node, sizeof(node)); if (extSize > 0) { dest->writeData(extData, extSize); } } for (i=0; i<NA; i++) { ssize_t idx = mAttributeOrder.valueAt(i); Loading Loading @@ -1476,6 +1489,7 @@ status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& de dest->writeData(&node, sizeof(node)); dest->writeData(&endElementExt, sizeof(endElementExt)); } else if (type == TYPE_NAMESPACE) { if (writeCurrentNode) { node.header.type = htods(RES_XML_END_NAMESPACE_TYPE); node.lineNumber = htodl(getEndLineNumber()); node.comment.index = htodl((uint32_t)-1); Loading @@ -1483,6 +1497,7 @@ status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& de dest->writeData(&node, sizeof(node)); dest->writeData(extData, extSize); } } return NO_ERROR; } Loading
tools/aapt/XMLNode.cpp +46 −31 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ bool isWhitespace(const char16_t* str) static const String16 RESOURCES_PREFIX(RESOURCES_ROOT_NAMESPACE); static const String16 RESOURCES_PRV_PREFIX(RESOURCES_ROOT_PRV_NAMESPACE); static const String16 RESOURCES_TOOLS_NAMESPACE("http://schemas.android.com/tools"); String16 getNamespaceResourcePackage(String16 namespaceUri, bool* outIsPublic) { Loading Loading @@ -761,6 +762,8 @@ status_t XMLNode::addAttribute(const String16& ns, const String16& name, SourcePos(mFilename, getStartLineNumber()).error("Child to CDATA node."); return UNKNOWN_ERROR; } if (ns != RESOURCES_TOOLS_NAMESPACE) { attribute_entry e; e.index = mNextAttributeIndex++; e.ns = ns; Loading @@ -768,6 +771,7 @@ status_t XMLNode::addAttribute(const String16& ns, const String16& name, e.string = value; mAttributes.add(e); mAttributeOrder.add(e.index, mAttributes.size()-1); } return NO_ERROR; } Loading Loading @@ -1215,12 +1219,14 @@ status_t XMLNode::collect_strings(StringPool* dest, Vector<uint32_t>* outResIds, collect_attr_strings(dest, outResIds, true); int i; if (RESOURCES_TOOLS_NAMESPACE != mNamespaceUri) { if (mNamespacePrefix.size() > 0) { dest->add(mNamespacePrefix, true); } if (mNamespaceUri.size() > 0) { dest->add(mNamespaceUri, true); } } if (mElementName.size() > 0) { dest->add(mElementName, true); } Loading Loading @@ -1338,6 +1344,7 @@ status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& de const void* extData = NULL; size_t extSize = 0; ResXMLTree_attribute attr; bool writeCurrentNode = true; const size_t NA = mAttributes.size(); const size_t NC = mChildren.size(); Loading Loading @@ -1395,6 +1402,9 @@ status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& de } } } else if (type == TYPE_NAMESPACE) { if (mNamespaceUri == RESOURCES_TOOLS_NAMESPACE) { writeCurrentNode = false; } else { node.header.type = htods(RES_XML_START_NAMESPACE_TYPE); extData = &namespaceExt; extSize = sizeof(namespaceExt); Loading @@ -1406,6 +1416,7 @@ status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& de } namespaceExt.prefix.index = htodl(strings.offsetForString(mNamespacePrefix)); namespaceExt.uri.index = htodl(strings.offsetForString(mNamespaceUri)); } LOG_ALWAYS_FATAL_IF(NA != 0, "Namespace nodes can't have attributes!"); } else if (type == TYPE_CDATA) { node.header.type = htods(RES_XML_CDATA_TYPE); Loading @@ -1422,10 +1433,12 @@ status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& de node.header.size = htodl(sizeof(node) + extSize + (sizeof(attr)*NA)); if (writeCurrentNode) { dest->writeData(&node, sizeof(node)); if (extSize > 0) { dest->writeData(extData, extSize); } } for (i=0; i<NA; i++) { ssize_t idx = mAttributeOrder.valueAt(i); Loading Loading @@ -1476,6 +1489,7 @@ status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& de dest->writeData(&node, sizeof(node)); dest->writeData(&endElementExt, sizeof(endElementExt)); } else if (type == TYPE_NAMESPACE) { if (writeCurrentNode) { node.header.type = htods(RES_XML_END_NAMESPACE_TYPE); node.lineNumber = htodl(getEndLineNumber()); node.comment.index = htodl((uint32_t)-1); Loading @@ -1483,6 +1497,7 @@ status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& de dest->writeData(&node, sizeof(node)); dest->writeData(extData, extSize); } } return NO_ERROR; }