GameTools autogen java

From Wikiid
Jump to: navigation, search

The autogen tool converts the file 'lol/src/JavaInterface.jxx' into lol/src/JavaInterface.cxx and lol/src/GameInterface.java in order to automate the generation of Java bindings into the C game code. It's a bit of a hack - but it makes maintaining Java interfaces much easier than messing around with javah and/or swig.

  /u/games/tools/src/autogen_java JavaInterface.jxx

...the tool is currently only ever run from within the lol/src/Makefile.am.

The JavaInterface.jxx file uses a special syntax for function headers and accepts javadoc-formatted comments.

Javadoc comments must start with /** (by itself on a line) and end with */ (by itself on a line).

Function headers must be preceded by JAVAFUNC and must be all on one line (although they may have code on that same line). The type of the return result must be either void, int, char, uchar, bool, float or string. uchar gets turned into byte in Java, bool becomes boolean in Java, string causes code to be generated to convert from a Java String into a C const char *.

eg:

 /**
  * Does the specified object/flag/camers exist in this game level?
  *
  * @param  name  the name you are looking for
  * @return      'true' if it exists, 'false' if it doesn't.
  */
 JAVAFUNC bool objectExists ( string name )
 {
   return findObject ( name ) != NULL ;
 }

...becomes (in C ):

 /*******************JAVA INTERFACE JUNK ************************/
 bool objectExists ( string name ) ; extern "C" JNIEXPORT jboolean JNICALL Java_
 javaLoL_GameInterface_objectExists ( JNIEnv *env, jobject _jobj, jstring  name
 ){  string C0 = env -> GetStringUTFChars ( name, false ) ;  jboolean ret = (jbo
 olean) objectExists ( C0 ) ;  env -> ReleaseStringUTFChars ( name, C0 ) ;  retu
 rn ret ;}
 /***************************************************************/
 bool objectExists ( string name ) {
 return findObject ( name ) != NULL ;
 }

...and in Java:

 /**
  * Does the specified object/flag/camers exist in this game level?
  *
  * @param  name  the name you are looking for
  * @return      'true' if it exists, 'false' if it doesn't.
  */
 public native boolean objectExists ( String  name ) ;

...running javadoc on the result produces the Java API function documentation: GameInterface API and Alphabetical Index


Wikiid Pages relating to gameTools (edit)
gameTools - Main page
gameTools - Support Tools :
plb_to_ac3d, mklevel, mktile, mktree, tiled, autogen_java, mk3dgallery
gameTools - File Formats :
title_screen.rgb, ultimate.xml, material.xml, decoration.xml, physics.xml
tiled.xml, tiled_autotiles.xml, Level files, Tile naming scheme, PLB files
gameTools - Source Code :
Game functions: gameCamera, gameClock, gameChecksum/gameHashTable, gameHTTP,
gameIsect, gameJoystick, gameParticleManager, gameScreen/gameMouse,
gameSky, gameStarter, gameStrokeFont, gameUtils
Material database: MatList/MatEntry
Tile map handling: TileObject/MapFlag/MapEntry/Map
Java Interfacing: JavaLink
Image file loading: liImage/liImageFactory
3D Model file loading: loadPLB, PLB exporter
Physics: Sabot, Bullet, gameTools - Use with Blender, PLB exporter
Object management: Object


Wikiid Pages relating to Lemur of Lima (edit)
Lemur of Lima - Main page
Lemur of Lima - Controls
Lemur of Lima - Levels :
List of Levels, Level design, Screen shots, Models
Lemur of Lima - Java Plugins :
Java plugin API, Event handling, Flags, GameInterface API , Alphabetical Index
Lemur of Lima - Source Code Documentation :
Initialisation, Main Loop, gameTools