java: Added Java SWIG binding creation
[contrib/mraa.git] / api / mraa / gpio.hpp
index a638061..a0c2f0d 100644 (file)
@@ -68,6 +68,30 @@ typedef enum {
     EDGE_FALLING = 3 /**< Interupt on falling only */
 } Edge;
 
+#if defined(SWIGJAVA)
+
+class IsrCallback
+{
+  public:
+    virtual ~IsrCallback()
+    {
+    }
+    virtual void
+    run()
+    { /* empty, overloaded in Java*/
+    }
+
+  private:
+};
+
+void
+generic_isr_callback(void* data)
+{
+    IsrCallback* callback = (IsrCallback*) data;
+    callback->run();
+}
+#endif
+
 /**
  * @brief API to General Purpose IO
  *
@@ -171,6 +195,12 @@ class Gpio
 #endif
         return mraa_gpio_isr(m_gpio, (gpio_edge_t) mode, &uvwork, this);
     }
+#elif defined(SWIGJAVA)
+    mraa_result_t
+    isr(Edge mode, IsrCallback* cb, void* args)
+    {
+        return mraa_gpio_isr(m_gpio, (gpio_edge_t) mode, generic_isr_callback, cb);
+    }
 #else
     /**
      * Sets a callback to be called when pin value changes
@@ -188,7 +218,7 @@ class Gpio
     }
 #endif
     /**
-     * Exits callback - this call will not kill the isr thread imediatlu
+     * Exits callback - this call will not kill the isr thread immediatly
      * but only when it is out of it's critical section
      *
      * @return Result of operation