Created
December 22, 2013 22:49
-
-
Save smspillaz/8089397 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct _ChangeDebugModeData | |
{ | |
guint flags; | |
gboolean enabled; | |
} ChangeDebugModeData; | |
typedef void (*LockAction) (JSContext *context, | |
gpointer user_data); | |
static void | |
lock_and_perform_if_unlocked (GjsContext *context, | |
guint *lock_count, | |
LockAction action, | |
gpointer user_data) | |
{ | |
if ((*lock_count)++ == 0) | |
{ | |
JSContext *js_context = (JSContext *) gjs_context_get_native_context (context); | |
(*action) (js_context, user_data); | |
} | |
} | |
static void | |
unlock_and_perform_if_locked (GjsContext *context, | |
guint *lock_count, | |
LockAction action, | |
gpointer user_data) | |
{ | |
if (--(*lock_count) == 0) | |
{ | |
JSContext *js_context = (JSContext *) gjs_context_get_native_context (context); | |
(*action) (js_context, user_data); | |
} | |
} | |
static void | |
change_debug_mode (JSContext *context, | |
gpointer user_data) | |
{ | |
ChangeDebugModeData *data = (ChangeDebugModeData *) user_data; | |
JS_BeginRequest (context); | |
JS_SetOptions (context, data->flags); | |
JS_SetDebugMode (context, data->enabled); | |
JS_EndRequest (context); | |
} | |
static void | |
gjs_debug_interrupt_register_lock_debug_mode (GjsDebugInterruptRegister *reg) | |
{ | |
ChangeDebugModeData data = | |
{ | |
JSOPTION_METHODJIT | JSOPTION_TYPE_INFERENCE, | |
TRUE | |
}; | |
lock_and_perform_if_unlocked (reg->priv->context, | |
®->priv->debug_mode_lock_count, | |
change_debug_mode, | |
&data); | |
} | |
static void | |
gjs_debug_interrupt_register_unlock_debug_mode (GjsDebugInterruptRegister *reg) | |
{ | |
ChangeDebugModeData data = | |
{ | |
0, | |
FALSE | |
}; | |
unlock_and_perform_if_locked (reg->priv->context, | |
®->priv->debug_mode_lock_count, | |
change_debug_mode, | |
&data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment