Java OO generated code are wrong
Posted: 17 Oct 2014, 00:39
the awk script is used to generate .java file from C file but they do not use a java constructor. In fact the awk script should to generate a constructor each time a 'init' function is generated. The constructor will have to only call the 'init' method.
That mean, OOAI abstract class implements IOOAI interface and generate this (and more…)
In the generated file they are no constructor then when your AI will inherit from this class you will never get the callback.
It should generated this:
and AbstractOOAI seem to be useless and attribute should to be protected
That mean, OOAI abstract class implements IOOAI interface and generate this (and more…)
Code: Select all
public abstract class OOAI implements IOOAI, AI {
private AICallback clb = null;
private OOAICallback clbOO = null;
@Override
public final int init(int skirmishAIId, AICallback callback) {
int _ret;
this.clb = callback;
this.clbOO = WrappOOAICallback.getInstance(callback);
OOAICallback oo_callback = this.clbOO;
_ret = this.init(skirmishAIId, oo_callback);
return _ret;
}
/**
* This AI event initializes a Skirmish AI instance.
* It is sent only once per AI instance and game, as the very first event.
*/
@Override
public int init(int skirmishAIId, OOAICallback oo_callback) { return 0; }
}
It should generated this:
Code: Select all
public abstract class OOAI implements IOOAI, AI {
protected AICallback clb = null;
protected OOAICallback clbOO = null;
protected int skirmishAIId = 0;
@Override
public final int init(int skirmishAIId, AICallback callback) {
int _ret;
this.skirmishAIId = skirmishAIId
this.clb = callback;
this.clbOO = WrappOOAICallback.getInstance(callback);
OOAICallback oo_callback = this.clbOO;
_ret = this.init(skirmishAIId, oo_callback);
return _ret;
}
/**
* This AI event initializes a Skirmish AI instance.
* It is sent only once per AI instance and game, as the very first event.
*/
@Override
public int init(int skirmishAIId, OOAICallback oo_callback) { return 0; }
public OOAI(int skirmishAIId, AICallback callback){
init(skirmishAIId, callback);
}
}