The short example taken from file Datamap.janet, outlined below, shows the basic features of the Janet syntax used to create a wrapper for the LIP_remap_ooc routine. The file with the ''.janet'' extension is the source for the Janet translator. It can combine both Java and C languages, i.e. define Java a class that makes calls to C library functions.
public class Datamap extends DataEncapsulator { native "C" { #include <lip.h> #include <mpi.h> #include <mpio.h> } ... public native "C" void remap_ooc (Datamap datamap, mpi.File datafile, mpi.File dataoutfile, int count, int pagesize, Datatype datatype, int flags) { LIP_Datamap new_datamap = (LIP_Datamap) `this.data`; int result = LIP_remap_ooc(`datamap.data`, &new_datamap, `datafile.data`, `dataoutfile.data`, `count`, `pagesize`, `datatype.handle`, `flags`); if (result != LIP_SUCCESS) `throw new LipException(#(result));` } ... } |
The Datamap java class includes the remap_ooc native method which is written in C language. The code can refer to Java objects and throw Java exceptions using statements enclosed in special characters `` ` ''.
Created by Katarzyna Zając