PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/java/director_binary_string_runme.java

#
Java | 42 lines | 33 code | 9 blank | 0 comment | 4 complexity | a10357ced6d322c957b2503a7b2ee9f6 MD5 | raw file
 1
 2import director_binary_string.*;
 3
 4public class director_binary_string_runme {
 5
 6  static {
 7    try {
 8      System.loadLibrary("director_binary_string");
 9    } catch (UnsatisfiedLinkError e) {
10      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
11      System.exit(1);
12    }
13  }
14
15  public static void main(String argv[]) {
16    Caller caller = new Caller();
17    Callback callback = new DirectorBinaryStringCallback();
18    caller.setCallback(callback);
19    int sum = caller.call();
20    caller.delCallback();
21
22    if (sum != 9*2*8 + 13*3*5)
23      throw new RuntimeException("Unexpected sum: " + sum);
24  }
25}
26
27class DirectorBinaryStringCallback extends Callback {
28  public DirectorBinaryStringCallback() {
29    super();
30  }
31
32  @Override
33  public void run(byte[] dataBufferAA, byte[] dataBufferBB)
34  {
35    for (int i = 0; i < dataBufferAA.length; i++)
36      dataBufferAA[i] = (byte)(dataBufferAA[i] * 2);
37
38    for (int i = 0; i < dataBufferBB.length; i++)
39      dataBufferBB[i] = (byte)(dataBufferBB[i] * 3);
40  }
41}
42