Skip to content

Generate better code #689

@Plamen5kov

Description

@Plamen5kov

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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions