PageRenderTime 41ms CodeModel.GetById 12ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. import director_binary_string.*;
  2. public class director_binary_string_runme {
  3. static {
  4. try {
  5. System.loadLibrary("director_binary_string");
  6. } catch (UnsatisfiedLinkError e) {
  7. 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);
  8. System.exit(1);
  9. }
  10. }
  11. public static void main(String argv[]) {
  12. Caller caller = new Caller();
  13. Callback callback = new DirectorBinaryStringCallback();
  14. caller.setCallback(callback);
  15. int sum = caller.call();
  16. caller.delCallback();
  17. if (sum != 9*2*8 + 13*3*5)
  18. throw new RuntimeException("Unexpected sum: " + sum);
  19. }
  20. }
  21. class DirectorBinaryStringCallback extends Callback {
  22. public DirectorBinaryStringCallback() {
  23. super();
  24. }
  25. @Override
  26. public void run(byte[] dataBufferAA, byte[] dataBufferBB)
  27. {
  28. for (int i = 0; i < dataBufferAA.length; i++)
  29. dataBufferAA[i] = (byte)(dataBufferAA[i] * 2);
  30. for (int i = 0; i < dataBufferBB.length; i++)
  31. dataBufferBB[i] = (byte)(dataBufferBB[i] * 3);
  32. }
  33. }