1## -*- coding: utf-8 -*- 2/* 3 * Copyright (C) 2012 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18/** 19 * !! Do not reference this file directly !! 20 * 21 * It is logically a part of camera_metadata.c. It is broken out for ease of 22 * maintaining the tag info. 23 * 24 * Array assignments are done using specified-index syntax to keep things in 25 * sync with camera_metadata_tags.h 26 */ 27 28/** 29 * ! Do not edit this file directly ! 30 * 31 * Generated automatically from camera_metadata_tag_info.mako 32 */ 33 34const char *camera_metadata_section_names[ANDROID_SECTION_COUNT] = { 35 % for i in find_all_sections(metadata): 36 ${"[%s]" %(path_name(i)) | csym,pad(36)} = "${path_name(i)}", 37 % endfor 38}; 39 40unsigned int camera_metadata_section_bounds[ANDROID_SECTION_COUNT][2] = { 41 % for i in find_all_sections(metadata): 42 ${"[%s]" %(path_name(i)) | csym,pad(36)} = { ${path_name(i) | csym}_START, 43 ${path_name(i) | csym}_END }, 44 % endfor 45}; 46 47% for sec in find_all_sections(metadata): 48static tag_info_t ${path_name(sec) | csyml}[${path_name(sec) | csym}_END - 49 ${path_name(sec) | csym}_START] = { 50 % for entry in remove_synthetic(find_unique_entries(sec)): 51 [ ${entry.name | csym} - ${path_name(sec) | csym}_START ] = 52 { ${'"%s",' %(entry.name_short) | pad(40)} ${entry.type | ctype_enum,ljust(11)} }, 53 % endfor 54}; 55 56% endfor 57 58tag_info_t *tag_info[ANDROID_SECTION_COUNT] = { 59 % for i in find_all_sections(metadata): 60 ${path_name(i) | csyml}, 61 % endfor 62}; 63 64int camera_metadata_enum_snprint(uint32_t tag, 65 uint32_t value, 66 char *dst, 67 size_t size) { 68 const char *msg = "error: not an enum"; 69 int ret = -1; 70 71 switch(tag) { 72 % for sec in find_all_sections(metadata): 73 % for idx,entry in enumerate(remove_synthetic(find_unique_entries(sec))): 74 case ${entry.name | csym}: { 75 % if entry.enum: 76 switch (value) { 77 % for val in entry.enum.values: 78 case ${entry.name | csym}_${val.name}: 79 msg = "${val.name}"; 80 ret = 0; 81 break; 82 % endfor 83 default: 84 msg = "error: enum value out of range"; 85 } 86 % endif 87 break; 88 } 89 % endfor 90 91 %endfor 92 } 93 94 strncpy(dst, msg, size - 1); 95 dst[size - 1] = '\0'; 96 97 return ret; 98} 99 100<% 101 find_values = lambda x: isinstance(x, metadata_model.EnumValue) 102 enum_values = metadata.find_all(find_values) 103 enum_value_max_len = max([len(value.name) for value in enum_values]) + 1 104%> 105#define CAMERA_METADATA_ENUM_STRING_MAX_SIZE ${enum_value_max_len} 106