From e42fa029ebc681a56e5ebad9ead1cb052db87ff1 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 17 May 2024 18:27:03 +0100 Subject: [PATCH] A little refactoring --- bindings/gumjs/gumquicksampler.c | 27 ++++++++------------------- bindings/gumjs/gumv8sampler.cpp | 6 +----- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/bindings/gumjs/gumquicksampler.c b/bindings/gumjs/gumquicksampler.c index c3f498582..ee1076567 100644 --- a/bindings/gumjs/gumquicksampler.c +++ b/bindings/gumjs/gumquicksampler.c @@ -92,30 +92,19 @@ GUMJS_DEFINE_CONSTRUCTOR (gumjs_sampler_construct) return _gum_quick_throw_literal (ctx, "not user-instantiable"); } -static GumQuickSampler * -gumjs_get_parent_module (GumQuickCore * core) -{ - return _gum_quick_core_load_module_data (core, "sampler"); -} - -static gboolean -gum_sampler_get (JSContext * ctx, - JSValueConst val, - GumQuickCore * core, - GumSampler ** sampler) -{ - return _gum_quick_unwrap (ctx, val, - gumjs_get_parent_module (core)->sampler_class, core, - (gpointer *) sampler); -} - GUMJS_DEFINE_FUNCTION (gumjs_sampler_sample) { GumSampler * self; + GumQuickSampler * parent; GumSample sample; - if (!gum_sampler_get (ctx, this_val, core, &self)) + parent = _gum_quick_core_load_module_data (core, "sampler"); + + if (!_gum_quick_unwrap (ctx, this_val, parent->sampler_class, core, + (gpointer) &self)) + { return JS_EXCEPTION; + } sample = gum_sampler_sample (self); @@ -127,7 +116,7 @@ GUMJS_DEFINE_CONSTRUCTOR (gumjs_wallclock_sampler_construct) GumQuickSampler * parent; GumSampler * sampler; - parent = gumjs_get_parent_module (core); + parent = _gum_quick_core_load_module_data (core, "sampler"); JSValue wrapper = JS_NewObjectClass (ctx, parent->sampler_class); diff --git a/bindings/gumjs/gumv8sampler.cpp b/bindings/gumjs/gumv8sampler.cpp index 8c5384f65..67fb4891a 100644 --- a/bindings/gumjs/gumv8sampler.cpp +++ b/bindings/gumjs/gumv8sampler.cpp @@ -72,11 +72,7 @@ _gum_v8_sampler_finalize (GumV8Sampler * self) GUMJS_DEFINE_CONSTRUCTOR (gumjs_sampler_construct) { - GumV8Sampler * sampler; - if (!_gum_v8_args_parse (args, "X", &sampler)) - return; - - gum_v8_object_manager_add (&module->objects, wrapper, sampler, module); + _gum_v8_throw_ascii_literal (isolate, "not user-instantiable"); } GUMJS_DEFINE_CLASS_METHOD (gumjs_sampler_sample, GumSampler)