Skip to content

Commit

Permalink
jni_generator: Refactor parsing logic
Browse files Browse the repository at this point in the history
The main changes are:
* Moves parsing of .java files into "parse.py"
  * Parsing of javap remains in jni_generator.py for now.
* Introduces a "JavaClass" class, to model class references
* Moves ProxyHelpers into a separate "proxy.py" file.
* Makes JNIFromJavaP and JNIFromJavaSource both have a "GetContent()",
  which simplifies main() logic a bit.
* Teaches TypeResolver about importing nesting classes

Bug: 1406605
Change-Id: I99d2efe02353967191ef09ce0b8a7dea5737d44d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4545780
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Peter Wen <wnwen@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1146645}
  • Loading branch information
agrieve authored and Chromium LUCI CQ committed May 19, 2023
1 parent 16e39a6 commit 830642b
Show file tree
Hide file tree
Showing 11 changed files with 828 additions and 660 deletions.
10 changes: 10 additions & 0 deletions base/android/jni_generator/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Common logic needed by other modules."""


def EscapeClassName(fully_qualified_class):
"""Returns an escaped string concatenating the Java package and class."""
escaped = fully_qualified_class.replace('_', '_1')
return escaped.replace('/', '_').replace('$', '_00024')
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.chromium.example.jni_generator.Boolean;

@SomeAnnotation("that contains class Foo ")
class SampleProxyEdgeCases {
enum Integer {}

Expand Down

0 comments on commit 830642b

Please sign in to comment.