diff --git a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/InterruptIn-js.cpp b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/InterruptIn-js.cpp index ff9388419..d4b6d65d3 100644 --- a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/InterruptIn-js.cpp +++ b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/InterruptIn-js.cpp @@ -29,7 +29,7 @@ DECLARE_CLASS_FUNCTION(InterruptIn, rise) { CHECK_ARGUMENT_COUNT(InterruptIn, rise, (args_count == 1)); // Detach the rise callback when InterruptIn::rise(null) is called - if (jerry_value_is_null(args[1])) { + if (jerry_value_is_null(args[0])) { uintptr_t native_handle; jerry_get_object_native_handle(this_obj, &native_handle); @@ -44,6 +44,7 @@ DECLARE_CLASS_FUNCTION(InterruptIn, rise) { // Ensure that the EventLoop frees memory used by the callback. mbed::js::EventLoop::getInstance().dropCallback(cb_func); } + jerry_release_value(cb_func); this_interruptin->rise(0); @@ -82,7 +83,7 @@ DECLARE_CLASS_FUNCTION(InterruptIn, fall) { CHECK_ARGUMENT_COUNT(InterruptIn, fall, (args_count == 1)); // Detach the fall callback when InterruptIn::fall(null) is called - if (jerry_value_is_null(args[1])) { + if (jerry_value_is_null(args[0])) { uintptr_t native_handle; jerry_get_object_native_handle(this_obj, &native_handle); @@ -97,6 +98,7 @@ DECLARE_CLASS_FUNCTION(InterruptIn, fall) { // Ensure that the EventLoop frees memory used by the callback. mbed::js::EventLoop::getInstance().dropCallback(cb_func); } + jerry_release_value(cb_func); this_interruptin->fall(0); diff --git a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-event-loop/EventLoop.h b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-event-loop/EventLoop.h index 6f28b8af3..99d855226 100644 --- a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-event-loop/EventLoop.h +++ b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-event-loop/EventLoop.h @@ -52,9 +52,6 @@ class EventLoop { Callback wrapFunction(jerry_value_t f) { MBED_ASSERT(jerry_value_is_function(f)); - // not sure if this is necessary? - jerry_acquire_value(f); - // we need to return a callback that'll schedule this Callback cb_raw(this, &EventLoop::callback); BoundCallback *cb = new BoundCallback(cb_raw, f); @@ -65,8 +62,6 @@ class EventLoop { } void dropCallback(jerry_value_t f) { - jerry_release_value(f); - for (std::vector*> >::iterator it = bound_callbacks.begin(); it != bound_callbacks.end(); it++) { std::pair*> element = *it;