diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2021-01-30 13:51:46 -0800 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2021-01-30 13:56:30 -0800 |
commit | 64f9ae14b7aefc89af9042b9625e18114137e695 (patch) | |
tree | 579c4ad5fe12e97db1d6ad12939b43709d1e8e84 | |
parent | bb490adb41613727a553d723f055dad83c0c11ec (diff) | |
download | gjs-64f9ae14b7aefc89af9042b9625e18114137e695.tar.gz |
js: Rename GJS_GET_WRAPPER_PRIV to GJS_CHECK_WRAPPER_PRIV
"GET" is not such an ideal name because the macro might also return.
Addresses code review comment from Marco.
-rw-r--r-- | gi/boxed.cpp | 4 | ||||
-rw-r--r-- | gi/cwrapper.h | 10 | ||||
-rw-r--r-- | gi/gerror.cpp | 6 | ||||
-rw-r--r-- | gi/ns.cpp | 2 | ||||
-rw-r--r-- | gi/object.cpp | 24 | ||||
-rw-r--r-- | gi/wrapperutils.h | 2 |
6 files changed, 24 insertions, 24 deletions
diff --git a/gi/boxed.cpp b/gi/boxed.cpp index 8aebd4f3..7214aa07 100644 --- a/gi/boxed.cpp +++ b/gi/boxed.cpp @@ -515,7 +515,7 @@ bool BoxedInstance::get_nested_interface_object( * conditions have been met. */ bool BoxedBase::field_getter(JSContext* context, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(context, argc, vp, args, obj, BoxedBase, priv); + GJS_CHECK_WRAPPER_PRIV(context, argc, vp, args, obj, BoxedBase, priv); if (!priv->check_is_instance(context, "get a field")) return false; @@ -657,7 +657,7 @@ bool BoxedInstance::field_setter_impl(JSContext* context, * conditions have been met. */ bool BoxedBase::field_setter(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, BoxedBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, BoxedBase, priv); if (!priv->check_is_instance(cx, "set a field")) return false; diff --git a/gi/cwrapper.h b/gi/cwrapper.h index 19bcc6ff..436eefd2 100644 --- a/gi/cwrapper.h +++ b/gi/cwrapper.h @@ -36,7 +36,7 @@ struct JSPropertySpec; // it can be easily retrieved in order to create new objects. /* - * GJS_GET_WRAPPER_PRIV: + * GJS_CHECK_WRAPPER_PRIV: * @cx: JSContext pointer passed into JSNative function * @argc: Number of arguments passed into JSNative function * @vp: Argument value array passed into JSNative function @@ -50,10 +50,10 @@ struct JSPropertySpec; * Throws an error and returns false if the 'this' object is not the right type. * Use in any JSNative function. */ -#define GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, thisobj, type, priv) \ - GJS_GET_THIS(cx, argc, vp, args, thisobj); \ - type* priv; \ - if (!type::for_js_typecheck(cx, thisobj, &priv, &args)) \ +#define GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, thisobj, type, priv) \ + GJS_GET_THIS(cx, argc, vp, args, thisobj); \ + type* priv; \ + if (!type::for_js_typecheck(cx, thisobj, &priv, &args)) \ return false; GJS_JSAPI_RETURN_CONVENTION diff --git a/gi/gerror.cpp b/gi/gerror.cpp index 71dd6089..82e80e12 100644 --- a/gi/gerror.cpp +++ b/gi/gerror.cpp @@ -91,14 +91,14 @@ bool ErrorInstance::constructor_impl(JSContext* context, * well as instances. */ bool ErrorBase::get_domain(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ErrorBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ErrorBase, priv); args.rval().setInt32(priv->domain()); return true; } // JSNative property getter for `message`. bool ErrorBase::get_message(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ErrorBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ErrorBase, priv); if (!priv->check_is_instance(cx, "get a field")) return false; @@ -108,7 +108,7 @@ bool ErrorBase::get_message(JSContext* cx, unsigned argc, JS::Value* vp) { // JSNative property getter for `code`. bool ErrorBase::get_code(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ErrorBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ErrorBase, priv); if (!priv->check_is_instance(cx, "get a field")) return false; @@ -126,7 +126,7 @@ class Ns : private GjsAutoChar, public CWrapper<Ns> { GJS_JSAPI_RETURN_CONVENTION static bool get_name(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, this_obj, Ns, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, this_obj, Ns, priv); return gjs_string_from_utf8(cx, priv->get(), args.rval()); } diff --git a/gi/object.cpp b/gi/object.cpp index 50765aea..abcda838 100644 --- a/gi/object.cpp +++ b/gi/object.cpp @@ -306,7 +306,7 @@ bool ObjectInstance::add_property_impl(JSContext* cx, JS::HandleObject obj, } bool ObjectBase::prop_getter(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); JS::RootedString name(cx, gjs_dynamic_property_private_slot(&args.callee()).toString()); @@ -378,7 +378,7 @@ bool ObjectInstance::prop_getter_impl(JSContext* cx, JS::HandleString name, } bool ObjectBase::field_getter(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); JS::RootedString name(cx, gjs_dynamic_property_private_slot(&args.callee()).toString()); @@ -441,7 +441,7 @@ bool ObjectInstance::field_getter_impl(JSContext* cx, JS::HandleString name, /* Dynamic setter for GObject properties. Returns false on OOM/exception. * args.rval() becomes the "stored value" for the property. */ bool ObjectBase::prop_setter(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); JS::RootedString name(cx, gjs_dynamic_property_private_slot(&args.callee()).toString()); @@ -498,7 +498,7 @@ bool ObjectInstance::prop_setter_impl(JSContext* cx, JS::HandleString name, } bool ObjectBase::field_setter(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); JS::RootedString name(cx, gjs_dynamic_property_private_slot(&args.callee()).toString()); @@ -1826,7 +1826,7 @@ void ObjectInstance::closure_invalidated_notify(void* data, GClosure* closure) { } bool ObjectBase::connect(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); if (!priv->check_is_instance(cx, "connect to signals")) return false; @@ -1834,7 +1834,7 @@ bool ObjectBase::connect(JSContext* cx, unsigned argc, JS::Value* vp) { } bool ObjectBase::connect_after(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); if (!priv->check_is_instance(cx, "connect to signals")) return false; @@ -1890,7 +1890,7 @@ ObjectInstance::connect_impl(JSContext *context, } bool ObjectBase::emit(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); if (!priv->check_is_instance(cx, "emit signal")) return false; @@ -2060,7 +2060,7 @@ bool ObjectInstance::signal_match_arguments_from_object( } bool ObjectBase::signal_find(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); if (!priv->check_is_instance(cx, "find signal")) return false; @@ -2129,7 +2129,7 @@ signal_match_to_action_name<&g_signal_handlers_disconnect_matched>() { template <ObjectBase::SignalMatchFunc(*MatchFunc)> bool ObjectBase::signals_action(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); const std::string action_name = signal_match_to_action_name<MatchFunc>(); if (!priv->check_is_instance(cx, (action_name + " signal").c_str())) return false; @@ -2182,7 +2182,7 @@ bool ObjectInstance::signals_action_impl(JSContext* cx, } bool ObjectBase::to_string(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, ObjectBase, priv); const char* kind = ObjectBase::DEBUG_TAG; if (!priv->is_prototype()) kind = priv->to_instance()->to_string_kind(); @@ -2212,7 +2212,7 @@ const char* ObjectInstance::to_string_kind(void) const { */ bool ObjectBase::init_gobject(JSContext* context, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(context, argc, vp, argv, obj, ObjectBase, priv); + GJS_CHECK_WRAPPER_PRIV(context, argc, vp, argv, obj, ObjectBase, priv); if (!priv->check_is_instance(context, "initialize")) return false; @@ -2522,7 +2522,7 @@ static bool find_vfunc_info(JSContext* context, GType implementor_gtype, } bool ObjectBase::hook_up_vfunc(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, prototype, ObjectBase, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, prototype, ObjectBase, priv); /* Normally we wouldn't assert is_prototype(), but this method can only be * called internally so it's OK to crash if done wrongly */ return priv->to_prototype()->hook_up_vfunc_impl(cx, args); diff --git a/gi/wrapperutils.h b/gi/wrapperutils.h index 388e3999..d202f63e 100644 --- a/gi/wrapperutils.h +++ b/gi/wrapperutils.h @@ -451,7 +451,7 @@ class GIWrapperBase : public CWrapperPointerOps<Base> { */ GJS_JSAPI_RETURN_CONVENTION static bool to_string(JSContext* cx, unsigned argc, JS::Value* vp) { - GJS_GET_WRAPPER_PRIV(cx, argc, vp, args, obj, Base, priv); + GJS_CHECK_WRAPPER_PRIV(cx, argc, vp, args, obj, Base, priv); return gjs_wrapper_to_string_func(cx, obj, Base::DEBUG_TAG, priv->info(), priv->gtype(), priv->ptr_addr(), args.rval()); |