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

Function compileAttribute

tools/aapt/ResourceTable.cpp:300–563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298};
299
300static status_t compileAttribute(const sp<AaptFile>& in,
301 ResXMLTree& block,
302 const String16& myPackage,
303 ResourceTable* outTable,
304 String16* outIdent = NULL,
305 bool inStyleable = false)
306{
307 PendingAttribute attr(myPackage, in, block, inStyleable);
308
309 const String16 attr16("attr");
310 const String16 id16("id");
311
312 // Attribute type constants.
313 const String16 enum16("enum");
314 const String16 flag16("flag");
315
316 ResXMLTree::event_code_t code;
317 size_t len;
318 status_t err;
319
320 ssize_t identIdx = block.indexOfAttribute(NULL, "name");
321 if (identIdx >= 0) {
322 attr.ident = String16(block.getAttributeStringValue(identIdx, &len));
323 if (outIdent) {
324 *outIdent = attr.ident;
325 }
326 } else {
327 attr.sourcePos.error("A 'name' attribute is required for <attr>\n");
328 attr.hasErrors = true;
329 }
330
331 attr.comment = String16(
332 block.getComment(&len) ? block.getComment(&len) : nulStr);
333
334 ssize_t typeIdx = block.indexOfAttribute(NULL, "format");
335 if (typeIdx >= 0) {
336 String16 typeStr = String16(block.getAttributeStringValue(typeIdx, &len));
337 attr.type = parse_flags(typeStr.string(), typeStr.size(), gFormatFlags);
338 if (attr.type == 0) {
339 attr.sourcePos.error("Tag <attr> 'format' attribute value \"%s\" not valid\n",
340 String8(typeStr).string());
341 attr.hasErrors = true;
342 }
343 attr.createIfNeeded(outTable);
344 } else if (!inStyleable) {
345 // Attribute definitions outside of styleables always define the
346 // attribute as a generic value.
347 attr.createIfNeeded(outTable);
348 }
349
350 //printf("Attribute %s: type=0x%08x\n", String8(attr.ident).string(), attr.type);
351
352 ssize_t minIdx = block.indexOfAttribute(NULL, "min");
353 if (minIdx >= 0) {
354 String16 val = String16(block.getAttributeStringValue(minIdx, &len));
355 if (!ResTable::stringToInt(val.string(), val.size(), NULL)) {
356 attr.sourcePos.error("Tag <attr> 'min' attribute must be a number, not \"%s\"\n",
357 String8(val).string());

Callers 1

compileResourceFileFunction · 0.85

Calls 15

parse_flagsFunction · 0.85
SourcePosClass · 0.85
mayOrMustFunction · 0.85
appendTypeInfoFunction · 0.85
indexOfAttributeMethod · 0.80
stringMethod · 0.80
createIfNeededMethod · 0.80
addBagMethod · 0.80
getElementNameMethod · 0.80
getPrintableSourceMethod · 0.80
hasBagOrEntryMethod · 0.80

Tested by

no test coverage detected