summaryrefslogtreecommitdiff
path: root/content/handlers/javascript/duktape/Window.bnd
diff options
context:
space:
mode:
Diffstat (limited to 'content/handlers/javascript/duktape/Window.bnd')
-rw-r--r--content/handlers/javascript/duktape/Window.bnd55
1 files changed, 40 insertions, 15 deletions
diff --git a/content/handlers/javascript/duktape/Window.bnd b/content/handlers/javascript/duktape/Window.bnd
index b2e8166a6..1a7686250 100644
--- a/content/handlers/javascript/duktape/Window.bnd
+++ b/content/handlers/javascript/duktape/Window.bnd
@@ -52,7 +52,9 @@ static void window_remove_callback_bits(duk_context *ctx, size_t handle) {
/* ... */
}
-static void window_call_callback(duk_context *ctx, size_t handle, bool clear_entry) {
+static void
+window_call_callback(duk_context *ctx, size_t handle, bool clear_entry)
+{
NSLOG(dukky, DEEPDEBUG, "ctx=%p, handle=%"PRIsizet, ctx, handle);
/* Stack is ... */
duk_push_global_object(ctx);
@@ -96,21 +98,32 @@ static void window_call_callback(duk_context *ctx, size_t handle, bool clear_ent
//dukky_log_stack_frame(ctx, "On leaving callback");
}
-static void window_schedule_callback(void *p) {
+
+static void
+window_schedule_callback(void *p)
+{
window_schedule_t *priv = (window_schedule_t *)p;
- NSLOG(dukky, DEEPDEBUG, "Entered window scheduler callback: %"PRIsizet, priv->handle);
+ NSLOG(dukky, DEEPDEBUG,
+ "Entered window scheduler callback: %"PRIsizet, priv->handle);
priv->running = true;
- window_call_callback(priv->ctx, priv->handle, priv->repeat_timeout == 0);
+ window_call_callback(priv->ctx,
+ priv->handle,
+ priv->repeat_timeout == 0);
priv->running = false;
if (priv->repeat_timeout > 0) {
/* Reschedule */
- NSLOG(dukky, DEEPDEBUG, "Rescheduling repeating callback %"PRIsizet, priv->handle);
- guit->misc->schedule(priv->repeat_timeout, window_schedule_callback, priv);
+ NSLOG(dukky, DEEPDEBUG,
+ "Rescheduling repeating callback %"PRIsizet,
+ priv->handle);
+ guit->misc->schedule(priv->repeat_timeout,
+ window_schedule_callback,
+ priv);
} else {
- NSLOG(dukky, DEEPDEBUG, "Removing completed callback %"PRIsizet, priv->handle);
+ NSLOG(dukky, DEEPDEBUG,
+ "Removing completed callback %"PRIsizet, priv->handle);
/* Remove this from the ring */
RING_REMOVE(priv->owner->schedule_ring, priv);
window_remove_callback_bits(priv->ctx, priv->handle);
@@ -118,8 +131,12 @@ static void window_schedule_callback(void *p) {
}
}
-static size_t window_alloc_new_callback(duk_context *ctx, window_private_t *window,
- bool repeating, int timeout) {
+static size_t
+window_alloc_new_callback(duk_context *ctx,
+ window_private_t *window,
+ bool repeating,
+ int timeout)
+{
size_t new_handle = next_handle++;
window_schedule_t *sched = calloc(sizeof *sched, 1);
if (sched == NULL) {
@@ -168,18 +185,24 @@ static size_t window_alloc_new_callback(duk_context *ctx, window_private_t *wind
return new_handle;
}
-static void window_remove_callback_by_handle(duk_context *ctx,
- window_private_t *window,
- size_t handle) {
+static void
+window_remove_callback_by_handle(duk_context *ctx,
+ window_private_t *window,
+ size_t handle)
+{
int res;
RING_ITERATE_START(window_schedule_t, window->schedule_ring, sched) {
if (sched->handle == handle) {
if (sched->running) {
- NSLOG(dukky, DEEPDEBUG, "Cancelling in-train callback %"PRIsizet, sched->handle);
+ NSLOG(dukky, DEEPDEBUG,
+ "Cancelling in-train callback %"PRIsizet,
+ sched->handle);
sched->repeat_timeout = 0;
} else {
- NSLOG(dukky, DEEPDEBUG, "Cancelled callback %"PRIsizet, sched->handle);
+ NSLOG(dukky, DEEPDEBUG,
+ "Cancelled callback %"PRIsizet,
+ sched->handle);
res = guit->misc->schedule(-1,
window_schedule_callback,
sched);
@@ -209,7 +232,9 @@ static duk_ret_t dukky_window_closedown_compartment(duk_context *ctx)
NSLOG(dukky, DEEPDEBUG, "Closing down compartment");
while (priv->schedule_ring != NULL) {
- window_remove_callback_by_handle(ctx, priv, priv->schedule_ring->handle);
+ window_remove_callback_by_handle(ctx,
+ priv,
+ priv->schedule_ring->handle);
}
return 0;