MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / flatten_node

Method flatten_node

tools/aapt/XMLNode.cpp:1387–1553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1385}
1386
1387status_t XMLNode::flatten_node(const StringPool& strings, const sp<AaptFile>& dest,
1388 bool stripComments, bool stripRawValues) const
1389{
1390 ResXMLTree_node node;
1391 ResXMLTree_cdataExt cdataExt;
1392 ResXMLTree_namespaceExt namespaceExt;
1393 ResXMLTree_attrExt attrExt;
1394 const void* extData = NULL;
1395 size_t extSize = 0;
1396 ResXMLTree_attribute attr;
1397 bool writeCurrentNode = true;
1398
1399 const size_t NA = mAttributes.size();
1400 const size_t NC = mChildren.size();
1401 size_t i;
1402
1403 LOG_ALWAYS_FATAL_IF(NA != mAttributeOrder.size(), "Attributes messed up!");
1404
1405 const String16 id16("id");
1406 const String16 class16("class");
1407 const String16 style16("style");
1408
1409 const type type = getType();
1410
1411 memset(&node, 0, sizeof(node));
1412 memset(&attr, 0, sizeof(attr));
1413 node.header.headerSize = htods(sizeof(node));
1414 node.lineNumber = htodl(getStartLineNumber());
1415 if (!stripComments) {
1416 node.comment.index = htodl(
1417 mComment.size() > 0 ? strings.offsetForString(mComment) : -1);
1418 //if (mComment.size() > 0) {
1419 // printf("Flattening comment: %s\n", String8(mComment).string());
1420 //}
1421 } else {
1422 node.comment.index = htodl((uint32_t)-1);
1423 }
1424 if (type == TYPE_ELEMENT) {
1425 node.header.type = htods(RES_XML_START_ELEMENT_TYPE);
1426 extData = &attrExt;
1427 extSize = sizeof(attrExt);
1428 memset(&attrExt, 0, sizeof(attrExt));
1429 if (mNamespaceUri.size() > 0) {
1430 attrExt.ns.index = htodl(strings.offsetForString(mNamespaceUri));
1431 } else {
1432 attrExt.ns.index = htodl((uint32_t)-1);
1433 }
1434 attrExt.name.index = htodl(strings.offsetForString(mElementName));
1435 attrExt.attributeStart = htods(sizeof(attrExt));
1436 attrExt.attributeSize = htods(sizeof(attr));
1437 attrExt.attributeCount = htods(NA);
1438 attrExt.idIndex = htods(0);
1439 attrExt.classIndex = htods(0);
1440 attrExt.styleIndex = htods(0);
1441 for (i=0; i<NA; i++) {
1442 ssize_t idx = mAttributeOrder.valueAt(i);
1443 const attribute_entry& ae = mAttributes.itemAt(idx);
1444 if (ae.ns.size() == 0) {

Callers

nothing calls this directly

Calls 6

getTypeFunction · 0.85
offsetForStringMethod · 0.80
writeDataMethod · 0.80
needStringValueMethod · 0.80
sizeMethod · 0.65
valueAtMethod · 0.45

Tested by

no test coverage detected