adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
531 stars 125 forks source link

arsd.jni: documentation is slightly incorrect #352

Closed TheZipCreator closed 1 year ago

TheZipCreator commented 1 year ago

The documentation for JavaInterface gives the following example code

interface IFoo : JavaInterface!("com.example", IFoo) {
    string whatever();
}

final class Foo : IFoo, JavaClass!("com.example", Foo) {
    // need to tell D that the implementation exists, just in Java.
    // (This actually generates the D implementation that just forwards to the existing java method)
    @Import string whatever();
}

however, this code does not compile (at least with DMD). It should instead be something like:

interface IFoo : JavaInterface!("com.example", IFoo) {
    @Import string whatever();
}

final class Foo : JavaClass!("com.example", Foo), IFoo {
    // need to tell D that the implementation exists, just in Java.
    // (This actually generates the D implementation that just forwards to the existing java method)
    @Import string whatever();
}

which seems to compile and work on the java side

adamdruppe commented 1 year ago

oh yeah, that's right, the parent class always comes first in D. that's what i get for writing a comment i never compiled. fix pushed

thx