gecko-dev/dom/bindings/CallbackInterface.h
Boris Zbarsky 8a18c1c3ae Bug 1618011 part 5. Use a BindingCallContext for Web IDL callback guts. r=peterv
We basically need this because some of the type conversions those guts need to
do may need a BindingCallContext.

We could probably do more optimization here to only generate the
BindingCallContext bits if we will really need them, more or less based on our
return type.  But for now that doesn't seem worthwhile.

Differential Revision: https://phabricator.services.mozilla.com/D64886

--HG--
extra : moz-landing-system : lando
2020-03-06 23:05:16 +00:00

53 lines
2.1 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* A common base class for representing WebIDL callback interface types in C++.
*
* This class implements common functionality like lifetime management,
* initialization with the callback object, and setup of the call environment.
* Subclasses corresponding to particular callback interface types should
* provide methods that actually do the various necessary calls.
*/
#ifndef mozilla_dom_CallbackInterface_h
#define mozilla_dom_CallbackInterface_h
#include "mozilla/dom/CallbackObject.h"
namespace mozilla {
namespace dom {
class CallbackInterface : public CallbackObject {
public:
// See CallbackObject for an explanation of the arguments.
explicit CallbackInterface(JSContext* aCx, JS::Handle<JSObject*> aCallback,
JS::Handle<JSObject*> aCallbackGlobal,
nsIGlobalObject* aIncumbentGlobal)
: CallbackObject(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) {}
// See CallbackObject for an explanation of the arguments.
explicit CallbackInterface(JSObject* aCallback, JSObject* aCallbackGlobal,
JSObject* aAsyncStack,
nsIGlobalObject* aIncumbentGlobal)
: CallbackObject(aCallback, aCallbackGlobal, aAsyncStack,
aIncumbentGlobal) {}
protected:
bool GetCallableProperty(BindingCallContext& cx, JS::Handle<jsid> aPropId,
JS::MutableHandle<JS::Value> aCallable);
// See CallbackObject for an explanation of the arguments.
CallbackInterface(JSObject* aCallback, JSObject* aCallbackGlobal,
const FastCallbackConstructor&)
: CallbackObject(aCallback, aCallbackGlobal, FastCallbackConstructor()) {}
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_CallbackFunction_h