-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Type Resolution #91
Open
ctrimble
wants to merge
11
commits into
nativelibs4java:master
Choose a base branch
from
ctrimble:feature_type-resolution
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5887a80
turn off doclint in the java 8 compiler
ctrimble bc17c24
ignore .DS_Store files created by OSX
ctrimble cf0c697
add classmate and retrolambda to the pom.
ctrimble 7662f56
corrected issues with Pointer in generated PointerTest
ctrimble 07a9235
first pass at adding classmate based resolution. Test suite passing.
ctrimble 88867c1
removed original resolution code
ctrimble 1994d5f
fixed warnings
ctrimble c7ae5f6
removed tests comparing origin and new resolution code.
ctrimble d494ad9
moved type resolution code out of struct delcaration class.
ctrimble 2cec0c1
added source declaration to the javadoc plugin
ctrimble cbe4a42
SQUASH: added missing StructIO changes to resolver refactoring
ctrimble File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,4 @@ dalvik | |
.classpath | ||
.project | ||
.settings | ||
.DS_Store |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ jdk: | |
- oraclejdk8 | ||
#- oraclejdk7 | ||
#- openjdk7 | ||
- openjdk6 | ||
#- openjdk6 | ||
|
||
compiler: | ||
- gcc | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
<artifactId>bridj</artifactId> | ||
<name>BridJ (NativeLibs4Java C/C++ Interop Layer)</name> | ||
<url>http://code.google.com/p/bridj/</url> | ||
<version>0.7.1-SNAPSHOT</version> | ||
<version>0.8.0-SNAPSHOT</version> | ||
<packaging>bundle</packaging> | ||
<repositories> | ||
<repository> | ||
|
@@ -25,6 +25,11 @@ | |
<properties> | ||
<versionSpecificSubPackage>v0_7_0</versionSpecificSubPackage> | ||
<maven.compiler.optimize>true</maven.compiler.optimize> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.testSource>1.8</maven.compiler.testSource> | ||
<maven.compiler.testTarget>1.8</maven.compiler.testTarget> | ||
<retrolambdaTarget>1.6</retrolambdaTarget> | ||
</properties> | ||
<scm> | ||
<connection>scm:git:[email protected]:nativelibs4java/BridJ.git</connection> | ||
|
@@ -48,6 +53,11 @@ | |
<artifactId>asm</artifactId> | ||
<version>5.0.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml</groupId> | ||
<artifactId>classmate</artifactId> | ||
<version>1.3.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.osgi</groupId> | ||
<artifactId>org.osgi.core</artifactId> | ||
|
@@ -109,6 +119,53 @@ | |
</javahClassNames> | ||
</configuration> | ||
</plugin--> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.6.0</version> | ||
<configuration> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
<testSource>${maven.compiler.testSource}</testSource> | ||
<testTarget>${maven.compiler.testTarget}</testTarget> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>default-compile</id> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
<configuration> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>default-testCompile</id> | ||
<phase>test-compile</phase> | ||
<goals> | ||
<goal>testCompile</goal> | ||
</goals> | ||
<configuration> | ||
<testSource>${maven.compiler.testSource}</testSource> | ||
<testTarget>${maven.compiler.testTarget}</testTarget> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>net.orfjackal.retrolambda</groupId> | ||
<artifactId>retrolambda-maven-plugin</artifactId> | ||
<version>2.4.0</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>process-main</goal> | ||
<goal>process-test</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
|
@@ -314,6 +371,7 @@ | |
<goal>jar</goal> | ||
</goals> | ||
<configuration> | ||
<source>${maven.compiler.source}</source> | ||
<groups> | ||
<group> | ||
<title>Core Packages</title> | ||
|
@@ -526,5 +584,14 @@ BridJ is opensource software. Please refer to LICENSE.BridJ.txt to know under wh | |
</plugins> | ||
</build> | ||
</profile> | ||
<profile> | ||
<id>disable-java8-doclint</id> | ||
<activation> | ||
<jdk>[1.8,)</jdk> | ||
</activation> | ||
<properties> | ||
<additionalparam>-Xdoclint:none</additionalparam> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
</project> |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,10 @@ | |
import org.bridj.util.DefaultParameterizedType; | ||
import org.bridj.util.Utils; | ||
|
||
import com.fasterxml.classmate.ResolvedType; | ||
import com.fasterxml.classmate.members.ResolvedField; | ||
import com.fasterxml.classmate.members.ResolvedMethod; | ||
|
||
/** | ||
* Internal metadata on a struct field | ||
*/ | ||
|
@@ -69,9 +73,9 @@ public class StructFieldDescription { | |
public long bitMask = -1; | ||
public boolean isArray, isNativeObject; | ||
public Type nativeTypeOrPointerTargetType; | ||
public java.lang.reflect.Field field; | ||
public ResolvedField field; | ||
Type valueType; | ||
Method getter; | ||
ResolvedMethod getter; | ||
String name; | ||
boolean isCLong, isSizeT; | ||
|
||
|
@@ -90,7 +94,12 @@ static Type resolveType(Type tpe, Type structType) { | |
} | ||
|
||
Type ret; | ||
if (tpe instanceof ParameterizedType) { | ||
if (tpe instanceof ResolvedType ) { | ||
ResolvedType rt = (ResolvedType)tpe; | ||
// TODO: what do we do here? | ||
ret = tpe; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this actually be anything other than ResolvedType now? |
||
else if (tpe instanceof ParameterizedType) { | ||
ParameterizedType pt = (ParameterizedType) tpe; | ||
Type[] actualTypeArguments = pt.getActualTypeArguments(); | ||
Type[] resolvedActualTypeArguments = new Type[actualTypeArguments.length]; | ||
|
@@ -178,8 +187,18 @@ static StructFieldDescription aggregateDeclarations(Type structType, List<Struct | |
field.desc.byteLength = Pointer.SIZE; | ||
//field.callIO = CallIO.Utils.createPointerCallIO(field.valueClass, field.desc.valueType); | ||
} else if (Pointer.class.isAssignableFrom(field.valueClass)) { | ||
Type tpe = (field.desc.valueType instanceof ParameterizedType) ? ((ParameterizedType) field.desc.valueType).getActualTypeArguments()[0] : null; | ||
field.desc.nativeTypeOrPointerTargetType = resolveType(tpe, structType); | ||
Type tpe = null; | ||
if( field.desc.valueType instanceof ResolvedType ) { | ||
ResolvedType rt = (ResolvedType)field.desc.valueType; | ||
if( !rt.getTypeParameters().isEmpty() ) { | ||
tpe = rt.getTypeParameters().get(0); | ||
field.desc.nativeTypeOrPointerTargetType = tpe; | ||
} | ||
} | ||
else if(field.desc.valueType instanceof ParameterizedType) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be dead code. |
||
tpe = ((ParameterizedType) field.desc.valueType).getActualTypeArguments()[0]; | ||
field.desc.nativeTypeOrPointerTargetType = resolveType(tpe, structType); | ||
} | ||
if (field.desc.isArray) { | ||
field.desc.byteLength = BridJ.sizeOf(field.desc.nativeTypeOrPointerTargetType); | ||
if (field.desc.alignment < 0) | ||
|
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parent pom should not be setting these to 1.5. Instead, it should define these properties to 1.5, allowing child poms to override them, without having to redefine the plugin.