Skip to content

Commit

Permalink
A little refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed May 17, 2024
1 parent ad69cd2 commit e42fa02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
27 changes: 8 additions & 19 deletions bindings/gumjs/gumquicksampler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down
6 changes: 1 addition & 5 deletions bindings/gumjs/gumv8sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e42fa02

Please sign in to comment.