Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: base/android/jni_generator/jni_generator.py

Issue 9622004: Chrome for Android unfork. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Extracts native methods from a Java file and generates the JNI bindings. 7 """Extracts native methods from a Java file and generates the JNI bindings.
8 If you change this, please run and update the tests.""" 8 If you change this, please run and update the tests."""
9 9
10 import collections 10 import collections
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 """Converts a java param into a JNI signature type.""" 115 """Converts a java param into a JNI signature type."""
116 pod_param_map = { 116 pod_param_map = {
117 'int': 'I', 117 'int': 'I',
118 'boolean': 'Z', 118 'boolean': 'Z',
119 'long': 'J', 119 'long': 'J',
120 'double': 'D', 120 'double': 'D',
121 'float': 'F', 121 'float': 'F',
122 'byte': 'B', 122 'byte': 'B',
123 'void': 'V', 123 'void': 'V',
124 } 124 }
125 object_param_map = { 125 object_param_list = [
126 'String': 'Ljava/lang/String', 126 'Ljava/lang/String',
127 'Boolean': 'Ljava/lang/Boolean', 127 'Ljava/lang/Boolean',
128 'Integer': 'Ljava/lang/Integer', 128 'Ljava/lang/Integer',
129 'Long': 'Ljava/lang/Long', 129 'Ljava/lang/Long',
130 'Object': 'Ljava/lang/Object', 130 'Ljava/lang/Object',
131 'List': 'Ljava/util/List', 131 'Ljava/util/List',
132 'ArrayList': 'Ljava/util/ArrayList', 132 'Ljava/util/ArrayList',
133 'HashMap': 'Ljava/util/HashMap', 133 'Ljava/util/HashMap',
134 'Bitmap': 'Landroid/graphics/Bitmap', 134 'Landroid/graphics/Bitmap',
135 'Context': 'Landroid/content/Context', 135 'Landroid/content/Context',
136 'Canvas': 'Landroid/graphics/Canvas', 136 'Landroid/graphics/Canvas',
137 'Surface': 'Landroid/view/Surface', 137 'Landroid/view/Surface',
138 'KeyEvent': 'Landroid/view/KeyEvent', 138 'Landroid/view/KeyEvent',
139 'Rect': 'Landroid/graphics/Rect', 139 'Landroid/graphics/Rect',
140 'RectF': 'Landroid/graphics/RectF', 140 'Landroid/graphics/RectF',
141 'View': 'Landroid/view/View', 141 'Landroid/view/View',
142 'Matrix': 'Landroid/graphics/Matrix', 142 'Landroid/graphics/Matrix',
143 'Point': 'Landroid/graphics/Point', 143 'Landroid/graphics/Point',
144 'ByteBuffer': 'Ljava/nio/ByteBuffer', 144 'Ljava/nio/ByteBuffer',
145 'InputStream': 'Ljava/io/InputStream', 145 'Ljava/io/InputStream',
146 } 146 'Ljava/util/Vector',
147 app_param_map = { 147 ]
148 'ChromeView': 148 app_param_list = [
149 'Lorg/chromium/chromeview/ChromeView', 149 'Lorg/chromium/chromeview/ChromeView',
150
151 'Tab':
152 'Lcom/android/chrome/Tab', 150 'Lcom/android/chrome/Tab',
153
154 'TouchPoint':
155 'Lorg/chromium/chromeview/TouchPoint', 151 'Lorg/chromium/chromeview/TouchPoint',
156
157 'SurfaceTexture':
158 'Landroid/graphics/SurfaceTexture', 152 'Landroid/graphics/SurfaceTexture',
159
160 'ChromeViewClient':
161 'Lorg/chromium/chromeview/ChromeViewClient', 153 'Lorg/chromium/chromeview/ChromeViewClient',
162
163 'JSModalDialog':
164 'Lcom/android/chrome/JSModalDialog', 154 'Lcom/android/chrome/JSModalDialog',
165
166 'NativeInfoBar':
167 'Lcom/android/chrome/infobar/InfoBarContainer$NativeInfoBar', 155 'Lcom/android/chrome/infobar/InfoBarContainer$NativeInfoBar',
168
169 'OmniboxSuggestion':
170 'Lcom/android/chrome/OmniboxSuggestion', 156 'Lcom/android/chrome/OmniboxSuggestion',
171 157 ('Lcom/android/chrome/preferences/ChromeNativePreferences$'
172 'PasswordListObserver': 158 'PasswordListObserver'),
173 'Lorg/chromium/chromeview/ChromePreferences$PasswordListObserver', 159 'Lorg/chromium/chromeview/SandboxedProcessArgs',
174
175 'SandboxedProcessArgs': 'Lorg/chromium/chromeview/SandboxedProcessArgs',
176
177 'SandboxedProcessConnection':
178 'Lorg/chromium/chromeview/SandboxedProcessConnection', 160 'Lorg/chromium/chromeview/SandboxedProcessConnection',
179
180 'SandboxedProcessService':
181 'Lorg/chromium/chromeview/SandboxedProcessService', 161 'Lorg/chromium/chromeview/SandboxedProcessService',
182 162 'Lcom/android/chrome/ChromeBrowserProvider$BookmarkNode',
183 'BookmarkNode': 'Lcom/android/chrome/ChromeBrowserProvider$BookmarkNode', 163 'Lcom/android/chrome/database/SQLiteCursor',
184
185 'SQLiteCursor': 'Lcom/android/chrome/database/SQLiteCursor',
186
187 'FindResultReceivedListener.FindNotificationDetails':
188 ('Lorg/chromium/chromeview/ChromeView$' 164 ('Lorg/chromium/chromeview/ChromeView$'
189 'FindResultReceivedListener$FindNotificationDetails'), 165 'FindResultReceivedListener$FindNotificationDetails'),
190
191 'ChromeViewContextMenuInfo':
192 'Lorg/chromium/chromeview/ChromeView$ChromeViewContextMenuInfo', 166 'Lorg/chromium/chromeview/ChromeView$ChromeViewContextMenuInfo',
193 167 'Lorg/chromium/chromeview/AutofillData',
194 'AutofillData': 'Lorg/chromium/chromeview/AutofillData', 168 'Lorg/chromium/chromeview/JavaInputStream',
195 169 'Lorg/chromium/chromeview/ChromeVideoView',
196 'JavaInputStream': 'Lorg/chromium/chromeview/JavaInputStream', 170 'Lorg/chromium/chromeview/ChromeHttpAuthHandler',
197 171 'Lorg/chromium/base/SystemMessageHandler',
198 'ChromeVideoView': 'Lorg/chromium/chromeview/ChromeVideoView', 172 'Lorg/chromium/chromeview/SelectFileDialog',
199 173 'Lorg/chromium/chromeview/SurfaceTextureListener',
200 'ChromeHttpAuthHandler': 'Lorg/chromium/chromeview/ChromeHttpAuthHandler', 174 'Lorg/chromium/chromeview/DeviceOrientation',
201 } 175 'Lorg/chromium/chromeview/MediaPlayerListener',
176 'Lorg/chromium/chromeview/DeviceInfo',
177 'Lorg/chromium/chromeview/LocationProvider',
178 'Lcom/android/chrome/PageInfoViewer',
179 ]
202 if param == 'byte[][]': 180 if param == 'byte[][]':
203 return '[[B' 181 return '[[B'
204 prefix = '' 182 prefix = ''
205 # Array? 183 # Array?
206 if param[-2:] == '[]': 184 if param[-2:] == '[]':
207 prefix = '[' 185 prefix = '['
208 param = param[:-2] 186 param = param[:-2]
209 # Generic? 187 # Generic?
210 if '<' in param: 188 if '<' in param:
211 param = param[:param.index('<')] 189 param = param[:param.index('<')]
212 if param in pod_param_map: 190 if param in pod_param_map:
213 return prefix + pod_param_map[param] 191 return prefix + pod_param_map[param]
214 elif param in object_param_map: 192 for qualified_name in object_param_list + app_param_list:
215 return prefix + object_param_map[param] + ';' 193 if (qualified_name.endswith('/' + param) or
216 elif param in app_param_map: 194 qualified_name.endswith('$' + param.replace('.', '$'))):
217 return prefix + app_param_map[param] + ';' 195 return prefix + qualified_name + ';'
218 else: 196 else:
219 return UNKNOWN_JAVA_TYPE_PREFIX + prefix + param + ';' 197 return UNKNOWN_JAVA_TYPE_PREFIX + prefix + param + ';'
220 198
221 199
222 def JniSignature(params, returns, wrap): 200 def JniSignature(params, returns, wrap):
223 """Returns the JNI signature for the given datatypes.""" 201 """Returns the JNI signature for the given datatypes."""
224 items = ['('] 202 items = ['(']
225 items += [JavaParamToJni(param.datatype) for param in params] 203 items += [JavaParamToJni(param.datatype) for param in params]
226 items += [')'] 204 items += [')']
227 items += [JavaParamToJni(returns)] 205 items += [JavaParamToJni(returns)]
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 if options.output_files: 940 if options.output_files:
963 output_files = input_files[len(input_files) / 2:] 941 output_files = input_files[len(input_files) / 2:]
964 input_files = input_files[:len(input_files) / 2] 942 input_files = input_files[:len(input_files) / 2]
965 CheckFilenames(input_files, output_files) 943 CheckFilenames(input_files, output_files)
966 GenerateJNIHeaders(input_files, output_files, options.javap_class, 944 GenerateJNIHeaders(input_files, output_files, options.javap_class,
967 options.namespace) 945 options.namespace)
968 946
969 947
970 if __name__ == '__main__': 948 if __name__ == '__main__':
971 sys.exit(main(sys.argv)) 949 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698