Add python script for generating brige and wrapper code.#1
Open
sqliu wants to merge 12 commits intowang16:reflection_layerfrom
Open
Add python script for generating brige and wrapper code.#1sqliu wants to merge 12 commits intowang16:reflection_layerfrom
sqliu wants to merge 12 commits intowang16:reflection_layerfrom
Conversation
added 11 commits
May 29, 2014 10:26
This script is used to create xwalk core internal from current xwalk core. The reason to scripten this process is to make it easy for rebasing. The whole feature for shared xwalk core is so complex that it will take amount of time to review. The rebase for moving core to core_internal will be a nightmare then.
The commit is generated by create_internal.py. It contains renaming the package and rename the classes Embedding API exposes with "Intenal" suffix appended.
This reverts commit 649db6b.
1. Previous commit does:
a. Move all xwalk core java classes include extension related to
xwalk core internal.
b. Rename all classes Embedding API exposes as ClassInternal.
2. This commit does:
a. Create a thin layer which is now xwalk core, simply wraps core
internal and override the functions returns internal objects
by creating and returnning wrapped objects in xwalk core.
b. Create target core_internal_java and let core_java depends on it.
c. Some necessary package name changing in tools and scripts.
… core library For core library usage, the internal resources ids are mapped to org.xwalk.core.R at runtime dynamically to ensure the ids using internally is correct. Since now xwalk core uses org.xwalk.core.internal.R instead of org.xwalk.core.R, the ids in org.xwalk.core.internal.R also needs initialization before use at runtime.
enum type is not friendly to be used in reflection. Use int instead.
Generator is a java project which depends on xwalk core internal to get class definitions. When executing Generator, it will read the class from specified list and generate wrapper/bridge class of it based on annotation XWalkAPI. The bridge class belongs to internal package, provides two functions for each API internal class wants to expose: wrapperCall and superCall. wrapperCall is to call wrapper which might be overriden by embedders. superCall is to call internal which is called by wrapper for default implementation. The wrapper class belongs to core package, provides API to embedders. Wrapper class will call bridge's superCall by default. If no overridden by embedders, the call stack will be: bridge::foo => wrapper::foo => bridge::fooSuper => internal::foo. TODO: 1. Documentation annotation support, currently all documentation annotation is in internal class. Need to automatically generate those annotation in wrapper class. 2. GYP dependency, in gyp world, each java target will add its output to jars_input_paths of dependent target. For reflection layer, it depends on core_internal, but in future after real reflection established, the shared embedders don't want to include core internal in it's APK.
… in XWalkAPI If a class declares instance in its XWalkAPI annotation, use that class's bridge type in other classes' bridge call.
Previously, the invoking between wrapper bridge is still directly funtion call. This commit turns them into real reflection. Including following parts: 1. Method call will use bridge/wrapper object to get Class and then get method to invoke. The methods for all exposed API will be get at instance creation time to avoid getting method object for each call. 2. Static method has no instance to get Class, it has to use class name to get Class. So it will try to load method for each call. 3. Constructor is complicated, for each class which is not interface, will register all their constructors' parameter list to ReflectionHelper in static area. When ReflectionHelper got initialized with specified ClassLoader, will try to load all registered constructor. Each constructor will be assigned a unique string to use.
Owner
There was a problem hiding this comment.
Do we need to consider generic type here?
Author
There was a problem hiding this comment.
currently I haven't met generic type to be processed, maybe for further this should be added, I'll add a TODO here
For share mode in core, use python script to generate bridge and wrapper code. BUG=
Owner
There was a problem hiding this comment.
method_return might need to be mangled?
Author
|
@wang16 script updated, thanks! |
781ccea to
88dc0bc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For share mode in core, use python script to generate bridge and wrapper code.
BUG=