Esempio n. 1
0
 static int getDefaultDyncallCppConvention() {
   int convention = DC_CALL_C_DEFAULT;
   if (!Platform.is64Bits() && Platform.isWindows()) {
     convention = DC_CALL_C_X86_WIN32_THIS_MS;
   }
   return convention;
 }
Esempio n. 2
0
  static {
    {
      OpenCLProbeLibrary probe = new OpenCLProbeLibrary();
      try {
        if (!probe.isValid()) {
          String alt;
          if (Platform.is64Bits() && BridJ.getNativeLibraryFile(alt = "atiocl64") != null
              || BridJ.getNativeLibraryFile(alt = "atiocl32") != null
              || BridJ.getNativeLibraryFile(alt = "atiocl") != null) {
            log(
                Level.INFO,
                "Hacking around ATI's weird driver bugs (using atiocl library instead of OpenCL)",
                null);
            BridJ.setNativeLibraryActualName("OpenCL", alt);
          }
        }
      } finally {
        probe = null;
        BridJ.unregister(OpenCLProbeLibrary.class);
      }
    }

    if (debug) {
      String debugArgs = System.getenv(JAVACL_DEBUG_COMPILER_FLAGS_PROP);
      if (debugArgs != null) DEBUG_COMPILER_FLAGS = Arrays.asList(debugArgs.split(" "));
      else if (Platform.isMacOSX()) DEBUG_COMPILER_FLAGS = Arrays.asList("-g");
      else DEBUG_COMPILER_FLAGS = Arrays.asList("-O0", "-g");

      int pid = ProcessUtils.getCurrentProcessId();
      log(
          Level.INFO,
          "Debug mode enabled with compiler flags \""
              + StringUtils.implode(DEBUG_COMPILER_FLAGS, " ")
              + "\" (can be overridden with env. var. JAVACL_DEBUG_COMPILER_FLAGS_PROP)");
      log(
          Level.INFO,
          "You can debug your kernels with GDB using one of the following commands :\n"
              + "\tsudo gdb --tui --pid="
              + pid
              + "\n"
              + "\tsudo ddd --debugger \"gdb --pid="
              + pid
              + "\"\n"
              + "More info here :\n"
              + "\thttp://code.google.com/p/javacl/wiki/DebuggingKernels");
    }
    CL = new OpenCLLibrary();
  }
  public TaskbarListDemo() throws ClassNotFoundException {
    super("TaskbarList Demo (" + (Platform.is64Bits() ? "64 bits" : "32 bits") + ")");

    list = COMRuntime.newInstance(ITaskbarList3.class);

    getContentPane().add("Center", new JLabel("Hello Native Windows 7 World !"));
    Box box = Box.createVerticalBox();

    slider = new JSlider(min, max, val);
    slider.addChangeListener(this);
    box.add(slider);

    ButtonGroup group = new ButtonGroup();
    for (ITaskbarList3.TbpFlag state : ITaskbarList3.TbpFlag.values()) {
      JRadioButton cb = new JRadioButton(state.name());
      group.add(cb);
      cb.putClientProperty(ITaskbarList3.TbpFlag.class, state);
      cb.setSelected(state == ITaskbarList3.TbpFlag.TBPF_NORMAL);
      cb.addActionListener(this);
      box.add(cb);
    }
    getContentPane().add("South", box);
  }
Esempio n. 4
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");*/
  }