blob: 63811ce9b6d8ff7e5da25dc1cd9cc3d374d3b0db [file] [log] [blame]
Igor Murashkinaa133d32013-06-28 17:27:49 -07001## -*- coding: utf-8 -*-
Igor Murashkinaa133d32013-06-28 17:27:49 -07002##
Eino-Ville Talvalad4e240a2013-08-08 12:56:37 -07003## 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\
18## These sections of metadata Key definitions are inserted into the middle of
Igor Murashkin21d0f1a2013-09-10 12:25:56 -070019## android.hardware.camera2.CameraCharacteristics, CaptureRequest, and CaptureResult.
Eino-Ville Talvalad4e240a2013-08-08 12:56:37 -070020<%page args="java_class, xml_kind" />\
21 /*@O~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
22 * The key entries below this point are generated from metadata
23 * definitions in /system/media/camera/docs. Do not modify by hand or
24 * modify the comment blocks at the start or end.
25 *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~*/
Igor Murashkinaa133d32013-06-28 17:27:49 -070026
Eino-Ville Talvala63c0fb22014-01-02 16:11:44 -080027<%!
28 ##
29 ## Generate extra text blocks for the details field
30 def generate_extra_detail(entry):
Igor Murashkin88b858d2014-01-14 14:57:46 -080031 def inner(text):
32 if entry.optional:
33 text += '\n\n<b>Optional</b> - This value may be {@code null} on some devices.\n'
34 if any(tag.name == 'FULL' for tag in entry.tags):
35 text += \
36 '\n<b>Full capability</b> - \n' + \
37 'Present on all camera devices that report being {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_FULL HARDWARE_LEVEL_FULL} devices in the\n' + \
38 'android.info.supportedHardwareLevel key\n'
39 return text
40 return inner
Eino-Ville Talvala63c0fb22014-01-02 16:11:44 -080041%>
Eino-Ville Talvalad4e240a2013-08-08 12:56:37 -070042##
43## Generate a single key and docs
44<%def name="generate_key(entry)">\
45 /**
Igor Murashkin88b858d2014-01-14 14:57:46 -080046<%
47 # Dedent fixes markdown not to generate code blocks. Then do the rest.
48 description = ""
49 if entry.description:
50 description = dedent(entry.description) + "\n\n"
51 details = ""
52 if entry.details:
53 details = dedent(entry.details)
54 # Unconditionally add extra information if necessary
55 extra_detail = generate_extra_detail(entry)("")
56
57 concatenated_info = description + details + extra_detail
58%>\
59## Glue description and details together before javadoc-izing. Otherwise @see in middle of javadoc.
60${concatenated_info | javadoc(metadata)}\
Eino-Ville Talvalad4e240a2013-08-08 12:56:37 -070061 % if entry.enum and not (entry.typedef and entry.typedef.languages.get('java')):
62 % for value in entry.enum.values:
Eino-Ville Talvalab4329162014-06-09 14:23:02 -070063 % if not value.hidden:
Eino-Ville Talvalad4e240a2013-08-08 12:56:37 -070064 * @see #${jenum_value(entry, value)}
Eino-Ville Talvalab4329162014-06-09 14:23:02 -070065 % endif
Eino-Ville Talvalad4e240a2013-08-08 12:56:37 -070066 % endfor
67 % endif
Igor Murashkin6c936c12014-05-13 14:51:49 -070068 % if entry.deprecated:
69 * @deprecated
70 % endif
Eino-Ville Talvalad4e240a2013-08-08 12:56:37 -070071 % if entry.applied_visibility == 'hidden':
Eino-Ville Talvalad4e240a2013-08-08 12:56:37 -070072 * @hide
73 % endif
74 */
Igor Murashkin6c936c12014-05-13 14:51:49 -070075 % if entry.deprecated:
76 @Deprecated
77 % endif
Igor Murashkin68a26ca2014-07-16 16:54:57 -070078 % if entry.applied_visibility == 'public':
79 @PublicKey
80 % endif
81 % if entry.synthetic:
82 @SyntheticKey
83 % endif
Eino-Ville Talvalad4e240a2013-08-08 12:56:37 -070084 public static final Key<${jtype_boxed(entry)}> ${entry.name | jkey_identifier} =
Igor Murashkin35a108f2014-05-27 10:51:25 -070085 new Key<${jtype_boxed(entry)}>("${entry.name}", ${jkey_type_token(entry)});
Igor Murashkinaa133d32013-06-28 17:27:49 -070086</%def>\
87##
88## Generate a list of only Static, Controls, or Dynamic properties.
89<%def name="single_kind_keys(java_name, xml_name)">\
Igor Murashkinaa133d32013-06-28 17:27:49 -070090% for outer_namespace in metadata.outer_namespaces: ## assumes single 'android' namespace
91 % for section in outer_namespace.sections:
Eino-Ville Talvalaf384f0a2013-07-12 17:02:27 -070092 % if section.find_first(lambda x: isinstance(x, metadata_model.Entry) and x.kind == xml_name) and \
93 any_visible(section, xml_name, ('public','hidden') ):
Igor Murashkinaa133d32013-06-28 17:27:49 -070094 % for inner_namespace in get_children_by_filtering_kind(section, xml_name, 'namespaces'):
95## 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
96## If we need to support more, we should use a recursive function here instead.. but the indentation gets trickier.
Eino-Ville Talvalad4e240a2013-08-08 12:56:37 -070097 % for entry in filter_visibility(inner_namespace.merged_entries, ('hidden','public')):
98${generate_key(entry)}
99 % endfor
100 % endfor
101 % for entry in filter_visibility( \
102 get_children_by_filtering_kind(section, xml_name, 'merged_entries'), \
Eino-Ville Talvalaf384f0a2013-07-12 17:02:27 -0700103 ('hidden', 'public')):
Eino-Ville Talvalad4e240a2013-08-08 12:56:37 -0700104${generate_key(entry)}
105 % endfor
Igor Murashkinaa133d32013-06-28 17:27:49 -0700106 % endif
107 % endfor
108% endfor
Igor Murashkinaa133d32013-06-28 17:27:49 -0700109</%def>\
110##
111## Static properties only
Igor Murashkin21d0f1a2013-09-10 12:25:56 -0700112##${single_kind_keys('CameraCharacteristicsKeys', 'static')}
Igor Murashkinaa133d32013-06-28 17:27:49 -0700113##
114## Controls properties only
115##${single_kind_keys('CaptureRequestKeys', 'controls')}
116##
117## Dynamic properties only
118##${single_kind_keys('CaptureResultKeys', 'dynamic')}
Eino-Ville Talvalad4e240a2013-08-08 12:56:37 -0700119${single_kind_keys(java_class, xml_kind)}\
120 /*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
121 * End generated code
Igor Murashkinefff0de2014-05-14 17:30:49 -0700122 *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/