Skip to content

Generate better code #689

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

Closed
Plamen5kov opened this issue Jan 16, 2017 · 2 comments
Closed

Generate better code #689

Plamen5kov opened this issue Jan 16, 2017 · 2 comments
Assignees
Milestone

Comments

@Plamen5kov
Copy link
Contributor

Plamen5kov commented Jan 16, 2017

Original issue: #514 (comment)

Problem:
Static binding generator, creates wrong code for the following:

  • add compile "de.mrmaffen:vlc-android-sdk:2.0.6" to gradle dependencies.
  • try to extend the interface:
new org.videolan.libvlc.MediaPlayer.EventListener({
    onEvent: function() {}
})

Currently the generated code is:

package com.tns.gen.org.videolan.libvlc;

public class MediaPlayer_EventListener implements org.videolan.libvlc.MediaPlayer.EventListener {
	public MediaPlayer_EventListener() {
		com.tns.Runtime.initInstance(this);
	}
	public void onEvent(org.videolan.libvlc.VLCEvent param_0)  {
		java.lang.Object[] args = new java.lang.Object[1];
		args[0] = param_0;
		com.tns.Runtime.callJSMethod(this, "onEvent", void.class, args);
	}
}

but the parameter org.videolan.libvlc.VLCEvent is incorrect, considering VLCEvent is a private abstract class. Besides that, the declaration of the interface org.videolan.libvlc.MediaPlayer.EventListener states:

public interface EventListener extends VLCEvent.Listener<MediaPlayer.Event> {}

which means the parameter needs to be MediaPlayer.Event, so the correct generated code should be:

package com.tns.gen.org.videolan.libvlc;

public class MediaPlayer_EventListener implements org.videolan.libvlc.MediaPlayer.EventListener {
	public MediaPlayer_EventListener() {
		com.tns.Runtime.initInstance(this);
	}

	public void onEvent(org.videolan.libvlc.MediaPlayer.Event param_0)  {
		java.lang.Object[] args = new java.lang.Object[1];
		args[0] = param_0;
		com.tns.Runtime.callJSMethod(this, "onEvent", void.class, args);
	}
}

Solution:
Find an appropriate code generation tool like JDT or Roaster or any other tool, which deals with language generation.

@Plamen5kov Plamen5kov self-assigned this Jan 16, 2017
@Plamen5kov Plamen5kov added the bug label Jan 16, 2017
@Plamen5kov
Copy link
Contributor Author

Plamen5kov commented Feb 20, 2017

Results from research:

  • In JDT this is the functionality we can use. It's a little unfortunate that it's in the ...jdt.ui package, but we can make it work.
  • Roaster uses JDT under the hood. Looking at the tests looks promising and exactly what we need.

@Plamen5kov
Copy link
Contributor Author

Update: This Issue will take a back seat until the need for generic becomes greater since the effort to implement this feature will be significant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants