blob: 1c8d47c1301008f5da0fb00c83f2377b1e52db4d [file] [log] [blame]
Igor Murashkinaa133d32013-06-28 17:27:49 -07001## -*- coding: utf-8 -*-
2/*
3 * Copyright (C) 2013 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
18package android.hardware.photography;
19
20import static android.hardware.photography.CameraMetadata.Key;
21
22/**
23 * ! Do not edit this file directly !
24 *
25 * Generated automatically from ${java_class}Keys.mako
26 *
27 * TODO: Include a hash of the input files here that the build can check.
28 */
29
30<%page args="java_class, xml_kind" />\
31/**
32 * The base class for camera controls and information.
33 *
34 * This class defines the basic key/value map used for querying for camera
35 * characteristics or capture results, and for setting camera request
36 * parameters.
37 *
38 * @see ${java_class}
39 * @see CameraMetadata
40 * @hide
41 **/
42##
43## Function to generate an enum
44<%def name="generate_enum(entry)">
Eino-Ville Talvalaf384f0a2013-07-12 17:02:27 -070045 % if entry.applied_visibility == 'hidden':
46 /**
47 * @hide
48 */
49 %endif
Igor Murashkinaa133d32013-06-28 17:27:49 -070050 public static final class ${entry.get_name_minimal() | pascal_case}Key extends Key<${jtype(entry)}> {
51 public enum Enum {
52 % for value,last in enumerate_with_last(entry.enum.values):
53 ${value.name | jidentifier}${"," if not last else ";"}
54 % endfor
55 }
56
57 % for value in entry.enum.values:
58 public static final Enum ${value.name | jidentifier} = Enum.${value.name | jidentifier};
59 % endfor
60
61 // TODO: remove requirement for constructor by making Key an interface
62 private ${entry.get_name_minimal() | pascal_case}Key(String name) {
63 super(name, ${jtype(entry)}.class);
64 }
65
66 % if entry.enum.has_values_with_id:
67 static {
68 CameraMetadata.registerEnumValues(${jenum(entry.enum)}.class, new int[] {
69 % for (value, last) in enumerate_with_last(entry.enum.values):
70 ${enum_calculate_value_string(value)}${"," if not last else ""} // ${value.name | jidentifier}
71 % endfor
72 });
73 }
74 % endif
75 }
76</%def>\
77##
78## Generate a list of only Static, Controls, or Dynamic properties.
79<%def name="single_kind_keys(java_name, xml_name)">\
80public final class ${java_name}Keys {
81% for outer_namespace in metadata.outer_namespaces: ## assumes single 'android' namespace
82 % for section in outer_namespace.sections:
Eino-Ville Talvalaf384f0a2013-07-12 17:02:27 -070083 % if section.find_first(lambda x: isinstance(x, metadata_model.Entry) and x.kind == xml_name) and \
84 any_visible(section, xml_name, ('public','hidden') ):
85 % if not any_visible(section, xml_name, ('public')):
86 /**
87 * @hide
88 */
89 %endif
Igor Murashkinaa133d32013-06-28 17:27:49 -070090 public static final class ${section.name | pascal_case} {
91 % for inner_namespace in get_children_by_filtering_kind(section, xml_name, 'namespaces'):
92## We only support 1 level of inner namespace, i.e. android.a.b and android.a.b.c works, but not android.a.b.c.d
93## If we need to support more, we should use a recursive function here instead.. but the indentation gets trickier.
94 public static final class ${inner_namespace.name| pascal_case} {
Eino-Ville Talvalaf384f0a2013-07-12 17:02:27 -070095 % for entry in filter_visibility(inner_namespace.merged_entries, ('hidden','public')):
Igor Murashkinaa133d32013-06-28 17:27:49 -070096 % if entry.enum:
97${generate_enum(entry)}
Eino-Ville Talvalaf384f0a2013-07-12 17:02:27 -070098 % if entry.applied_visibility == 'hidden':
99 /**
100 * @hide
101 */
102 %endif
Igor Murashkinaa133d32013-06-28 17:27:49 -0700103 public static final Key<${jtype(entry)}> ${entry.get_name_minimal() | csym} =
104 new ${entry.get_name_minimal() | pascal_case}Key("${entry.name}");
105 % else:
Eino-Ville Talvalaf384f0a2013-07-12 17:02:27 -0700106 % if entry.applied_visibility == 'hidden':
107 /**
108 * @hide
109 */
110 %endif
Igor Murashkinaa133d32013-06-28 17:27:49 -0700111 public static final Key<${jtype(entry)}> ${entry.get_name_minimal() | csym} =
112 new Key<${jtype(entry)}>("${entry.name}", ${jclass(entry)});
113 % endif
114 % endfor
115 }
116 % endfor
Eino-Ville Talvalaf384f0a2013-07-12 17:02:27 -0700117 % for entry in filter_visibility( \
118 get_children_by_filtering_kind(section, xml_name, 'merged_entries'), \
119 ('hidden', 'public')):
Igor Murashkinaa133d32013-06-28 17:27:49 -0700120 % if entry.enum:
121${generate_enum(entry)}
Eino-Ville Talvalaf384f0a2013-07-12 17:02:27 -0700122 % if entry.applied_visibility == 'hidden':
123 /**
124 * @hide
125 */
126 %endif
Igor Murashkinaa133d32013-06-28 17:27:49 -0700127 public static final Key<${jtype(entry)}> ${entry.get_name_minimal() | csym} =
128 new ${entry.get_name_minimal() | pascal_case}Key("${entry.name}");
129 % else:
Eino-Ville Talvalaf384f0a2013-07-12 17:02:27 -0700130 % if entry.applied_visibility == 'hidden':
131 /**
132 * @hide
133 */
134 %endif
Igor Murashkinaa133d32013-06-28 17:27:49 -0700135 public static final Key<${jtype(entry)}> ${entry.get_name_minimal() | csym} =
136 new Key<${jtype(entry)}>("${entry.name}", ${jclass(entry)});
137 % endif
138 % endfor
139
140 }
Eino-Ville Talvalaf384f0a2013-07-12 17:02:27 -0700141
Igor Murashkinaa133d32013-06-28 17:27:49 -0700142 % endif
143 % endfor
144% endfor
145}
146</%def>\
147##
148## Static properties only
149##${single_kind_keys('CameraPropertiesKeys', 'static')}
150##
151## Controls properties only
152##${single_kind_keys('CaptureRequestKeys', 'controls')}
153##
154## Dynamic properties only
155##${single_kind_keys('CaptureResultKeys', 'dynamic')}
156${single_kind_keys(java_class, xml_kind)}