Ejemplo n.º 1
0
  public void setVisible(boolean visible) {
    super.setVisible(visible);

    long hwndVal =
        JAWTUtils.getNativePeerHandle(this); // TODO com.sun.jna.Native.getComponentID(this);
    hwnd = Pointer.pointerToAddress(hwndVal);
    list.SetProgressValue((Pointer) hwnd, slider.getValue(), slider.getMaximum());
  }
Ejemplo n.º 2
0
  public static void main(String[] args) throws IOException {
    try {
      {
        JFrame f = new JFrame();
        f.setVisible(true);
        long hwndVal =
            JAWTUtils.getNativePeerHandle(f); // TODO com.sun.jna.Native.getComponentID(this);
        System.out.println("#\n# hwndVal = " + hwndVal + "\n#");

        BridJ.register();
        ValuedEnum<ETest> t = testEnum(ETest.eFirst);
        if (t != ETest.eFirst) throw new RuntimeException();
      }
      testSetGetIntBuffer(10);
      //			if (Platform.isMacOSX()) {
      //				new NSCalendar();
      //				new NSAutoReleasePool();
      //			}

      //        	NativeLibrary lib = BridJ.getNativeLibrary("OpenCL", new
      // File("/System/Library/Frameworks/OpenCL.framework/OpenCL"));
      //        	NativeLibrary lib = BridJ.getNativeLibrary("OpenCL", new
      // File("/usr/lib/libobjc.dylib"));
      //        	NativeLibrary lib = BridJ.getNativeLibrary("OpenCL", new
      // File("/Users/ochafik/nativelibs4java/Runtime/BridJ/src/test/cpp/test/build_out/darwin_universal_gcc_debug/libtest.dylib"));

      //        	Collection<Symbol> symbols = lib.getSymbols();
      BridJ.register(MyCallback.class);
      BridJ.register();

      int ra = testAddDyncall(10, 4);
      if (ra != 14) throw new RuntimeException("Expected 14, got " + ra);
      ra = testAddDyncall(10, 4);
      if (ra != 14) throw new RuntimeException("Expected 14, got " + ra);

      testNativeTargetCallbacks();
      testJavaTargetCallbacks();

      if (true) return;

      long crea = Ctest.createTest();
      crea = Pointer.pointerToAddress(crea).getPointer().getPeer();
      print("Ctest.createTest()", crea, 10, 0);
      Ctest test = new Ctest();
      // long thisPtr = test.$this.getPeer();
      // System.out.println(hex(thisPtr));
      print("Ctest.this", Pointer.pointerTo(test, Ctest.class).getPointer().getPeer(), 10, 2);
      int res = test.testAdd(1, 2);
      System.out.println("res = " + res);
      res = test.testVirtualAdd(1, 2);
      System.out.println("res = " + res);

      res = test.testVirtualAddStdCall(null, 1, 2);
      System.out.println("res = " + res);
      res = test.testAddStdCall(null, 1, 2);
      System.out.println("res = " + res);

      TaskbarListDemo.main(null);

      IShellWindows win = COMRuntime.newInstance(IShellWindows.class);
      IUnknown iu = win.QueryInterface(IUnknown.class);
      if (iu == null) throw new RuntimeException("Interface does not handle IUnknown !");
      win.Release();

      try {
        new FunctionTest().add();

        MyStruct s = new MyStruct();
        s.a(10);
        System.out.println("Created MyStruct and set it to 10");
        int a = Pointer.pointerTo(s).getInt();
        a = s.a();
        Pointer.pointerTo(s).setInt(10);
        a = Pointer.pointerTo(s).getInt();
        a = s.a();
        if (s.a() != 10) throw new RuntimeException("invalid value = " + a);
        s.b(100.0);
        if (s.b() != 100.0) throw new RuntimeException("invalid value = " + a);

      } catch (Throwable ex) {
        ex.printStackTrace();
      }

      library = BridJ.getNativeLibrary("test");
      // NativeLibrary.load(libraryPath);

      new VC9Demangler(null, "?sinInt@@YANH@Z").parseSymbol();
      new VC9Demangler(null, "?forwardCall@@YAHP6AHHH@ZHH@Z").parseSymbol();

      BridJ.register();

      // new VC9Demangler(null, "??0Ctest2@@QEAA@XZ").parseSymbol();

      for (Demangler.Symbol symbol : library.getSymbols()) {
        String name = symbol.getName();
        long addr = symbol.getAddress();
        System.out.println(name + " = \t" + hex(addr));

        if (name.startsWith("_ZTV") || name.startsWith("_ZTI") || name.startsWith("??_")) {
          print("vtable", addr, 10, 1);
        } else System.out.println("'" + name + "'");
      }

      boolean is64 = Platform.is64Bits();

    } catch (Throwable ex) {
      ex.printStackTrace();
    } finally {
      System.in.read();
    }
    /*double dres = PerfLib.testASinB(1, 2);
    res = PerfLib.testAddJNI(1, 2);
    System.out.println("Done");*/
  }