summaryrefslogtreecommitdiff
path: root/peripheral/libupm/src/lol/javaupm_lol.i
blob: 6c1ceaeeb8385eaf5431b5a154d0b60ff5f584f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
%module javaupm_lol
%include "../upm.i"
%include "stdint.i"
%include "arrays_java.i";
%include "typemaps.i"

%typemap(jni) unsigned char* "jbyteArray";
%typemap(jtype) unsigned char* "byte[]";
%typemap(jstype) unsigned char* "byte[]";

%typemap(javaout) unsigned char* {
 return $jnicall;
}

%typemap(out) unsigned char* {
    $result = JCALL1(NewByteArray, jenv, LOL_X*LOL_Y);
    JCALL4(SetByteArrayRegion, jenv, $result, 0, LOL_X*LOL_Y-1, reinterpret_cast<jbyte*>($1));
    delete [] $1;
}

%{
    #include "lol.h"
%}

%include "lol.h"

%pragma(java) jniclasscode=%{
    static {
        try {
            System.loadLibrary("javaupm_lol");
        } catch (UnsatisfiedLinkError e) {
            System.err.println("Native code library failed to load. \n" + e);
            System.exit(1);
        }
    }
%}