Skip to content
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

[generator] Upgrade generator from monodroid/a438c473 #36

Merged
merged 5 commits into from
May 25, 2016

Commits on May 25, 2016

  1. [generator] Fix parameter identifiers so they're valid C#.

    Android N Preview 2 adds method parameters which are not valid C#
    identifiers, and these weren't being properly handled before.
    
    Fix parameter identifiers so that invalid characters such as `$` are
    replaced with `_`.
    jonpryor committed May 25, 2016
    Configuration menu
    Copy the full SHA
    1ba56a4 View commit details
    Browse the repository at this point in the history
  2. [generator] Emit correct XPath references

    Comments are inserted into the generated C# code to identify the
    emitted member with the "source" XML declaration, to permit later
    fixups via metadata without the drudgery of manually determining the
    XPath references.
    
    Unfortunately, when a class implements an interface, the generated
    XPath comment for the interface method within the class would provide
    an XPath expression "as if" the method were declared in the class,
    which was not the case:
    
    	// Metadata.xml XPath method reference: path="/api/package[@name='java.util']/class[@name='AbstractCollection']/method[@name='spliterator' and count(parameter)=0]"
    	[Register ("spliterator", "()Ljava/util/Spliterator;", "GetSpliteratorHandler", ApiSince = 24)]
    	public virtual unsafe Java.Util.ISpliterator Spliterator ()
    
    Above, the spliterator() method is *actually* declared in
    java.util.Spliterator<T>, but the comment implies that the generated
    method is coming from java.util.AbstractCollection<T>. The comment is
    thus wrong, as AbstractCollection.spliterator() doesn't exist within
    the API XML (it's implied by the implemented interfaces).
    
    To fix this, use the Method's DeclaringType in the XPath comment:
    
    	// Metadata.xml XPath method reference: path="/api/package[@name='java.util']/class[@name='Spliterator']/method[@name='spliterator' and count(parameter)=0]"
    jonpryor committed May 25, 2016
    Configuration menu
    Copy the full SHA
    5c73a13 View commit details
    Browse the repository at this point in the history
  3. [generator] Don't bind interface default method when overridden

    In Android N Preview 2, `java.util.Iterator<E>` adds a `spliterator()`
    method, which is overriden in `java.util.Collection<E>`.  That
    resulted in our generator to emit duplicate binding methods for *both*
    `spliterator()`s -- one from the `Iterator<T>`interface and one from
    the `Collection<T>` interface -- within implementing classes such as
    `java.util.AbstractCollection<T>`.
    
    The most derived override should be the one to invoke, so generate
    Java Callable Wrappers for only the most overridden ones
    (`java.util.Collection<T>.spliterator()` in this case).
    To do so, first mark them as overides, and then exclude those
    overriden from the generated code.
    jonpryor committed May 25, 2016
    Configuration menu
    Copy the full SHA
    0a80004 View commit details
    Browse the repository at this point in the history
  4. [generator] Do not generate implementors for static methods.

    Android N Preview 2 adds several static methods to the
    java.util.Comparator<T> interface, such as `reverseOrder()`:
    
    	/* partial */ interface Comparator<T> {
    		public static <T extends java.lang.Comparable<? super T>>
    			java.util.Comparator<T> reverseOrder();
    	}
    
    DO NOT BIND Java interface static methods within C# interfaces.
    
    It doesn't make conceptual sense, and results in unusable bindings.
    jonpryor committed May 25, 2016
    Configuration menu
    Copy the full SHA
    76de54f View commit details
    Browse the repository at this point in the history
  5. [generator] Disable interface default method binding

    If we bind those methods into interfaces, our users will have to implement
    those methods unlike Java8, and that's more annoying than missing them.
    
    Related: dotnet#25
    jonpryor committed May 25, 2016
    Configuration menu
    Copy the full SHA
    df3ec4c View commit details
    Browse the repository at this point in the history