Generated file
Copy as Markdown
Other Tools
/* THIS FILE IS AUTOGENERATED FROM ModelContext.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_MODELCONTEXTBINDING_H_
#define DOM_MODELCONTEXTBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/dom/AbortSignal.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackFunction.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsCycleCollectionParticipant.h"
namespace mozilla {
namespace dom {
class AbortSignal;
struct InvokeToolOptionsAtoms;
class ModelContext;
class ModelContextClient;
struct ModelContextToolAtoms;
struct ModelContextToolDefinitionAtoms;
struct NativePropertyHooks;
class Promise;
class ProtoAndIfaceCache;
struct ToolAnnotations;
struct ToolAnnotationsAtoms;
class ToolExecuteCallback;
class UserInteractionCallback;
} // namespace dom
} // namespace mozilla
namespace mozilla::dom {
struct InvokeToolOptions : public MaybeEmptyDictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<OwningNonNull<mozilla::dom::AbortSignal>> mSignal;
InvokeToolOptions();
explicit inline InvokeToolOptions(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
InvokeToolOptions(InvokeToolOptions&& aOther) = default;
explicit inline InvokeToolOptions(const InvokeToolOptions& aOther)
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
inline void
TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags)
{
ImplCycleCollectionTraverse(aCallback, mSignal, "mSignal", aFlags);
}
inline void
UnlinkForCC()
{
ImplCycleCollectionUnlink(mSignal);
}
InvokeToolOptions&
operator=(const InvokeToolOptions& aOther);
private:
static bool
InitIds(JSContext* cx, InvokeToolOptionsAtoms* atomsCache);
};
namespace binding_detail {
struct FastInvokeToolOptions : public InvokeToolOptions
{
inline FastInvokeToolOptions()
: InvokeToolOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct ToolAnnotations : public MaybeEmptyDictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<bool> mReadOnlyHint;
ToolAnnotations();
explicit inline ToolAnnotations(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
ToolAnnotations(ToolAnnotations&& aOther) = default;
explicit inline ToolAnnotations(const ToolAnnotations& aOther)
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
ToolAnnotations&
operator=(const ToolAnnotations& aOther);
private:
static bool
InitIds(JSContext* cx, ToolAnnotationsAtoms* atomsCache);
};
namespace binding_detail {
struct FastToolAnnotations : public ToolAnnotations
{
inline FastToolAnnotations()
: ToolAnnotations(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
class ToolExecuteCallback : public CallbackFunction
{
public:
explicit inline ToolExecuteCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline ToolExecuteCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline ToolExecuteCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline ToolExecuteCallback(CallbackFunction* aOther)
: CallbackFunction(aOther)
{
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline already_AddRefed<Promise>
Call(const T& thisVal, JS::Handle<JSObject*> input, ModelContextClient& client, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "ToolExecuteCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return nullptr;
}
JS::Rooted<JS::Value> thisValJS(s.GetContext());
if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
return Call(s.GetCallContext(), thisValJS, input, client, aRv);
}
MOZ_CAN_RUN_SCRIPT inline already_AddRefed<Promise>
Call(JS::Handle<JSObject*> input, ModelContextClient& client, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "ToolExecuteCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return nullptr;
}
return Call(s.GetCallContext(), JS::UndefinedHandleValue, input, client, aRv);
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline already_AddRefed<Promise>
Call(const T& thisVal, JS::Handle<JSObject*> input, ModelContextClient& client, const char* aExecutionReason = nullptr)
{
return Call(thisVal, input, client, IgnoreErrors(), aExecutionReason);
}
MOZ_CAN_RUN_SCRIPT inline already_AddRefed<Promise>
Call(JS::Handle<JSObject*> input, ModelContextClient& client, const char* aExecutionReason = nullptr)
{
return Call(input, client, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const ToolExecuteCallback& aOther) const
{
return CallbackFunction::operator==(aOther);
}
private:
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, JS::Handle<JSObject*> input, ModelContextClient& client, ErrorResult& aRv);
};
namespace binding_detail {
class FastToolExecuteCallback : public ToolExecuteCallback
{
public:
explicit inline FastToolExecuteCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
: ToolExecuteCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
ToolExecuteCallback::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
ToolExecuteCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
class UserInteractionCallback : public CallbackFunction
{
public:
explicit inline UserInteractionCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline UserInteractionCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline UserInteractionCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline UserInteractionCallback(CallbackFunction* aOther)
: CallbackFunction(aOther)
{
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline already_AddRefed<Promise>
Call(const T& thisVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "UserInteractionCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return nullptr;
}
JS::Rooted<JS::Value> thisValJS(s.GetContext());
if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
return Call(s.GetCallContext(), thisValJS, aRv);
}
MOZ_CAN_RUN_SCRIPT inline already_AddRefed<Promise>
Call(ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "UserInteractionCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return nullptr;
}
return Call(s.GetCallContext(), JS::UndefinedHandleValue, aRv);
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline already_AddRefed<Promise>
Call(const T& thisVal, const char* aExecutionReason = nullptr)
{
return Call(thisVal, IgnoreErrors(), aExecutionReason);
}
MOZ_CAN_RUN_SCRIPT inline already_AddRefed<Promise>
Call(const char* aExecutionReason = nullptr)
{
return Call(IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const UserInteractionCallback& aOther) const
{
return CallbackFunction::operator==(aOther);
}
private:
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv);
};
namespace binding_detail {
class FastUserInteractionCallback : public UserInteractionCallback
{
public:
explicit inline FastUserInteractionCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
: UserInteractionCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
UserInteractionCallback::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
UserInteractionCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
struct ModelContextTool : public MaybeEmptyDictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<ToolAnnotations> mAnnotations;
MOZ_INIT_OUTSIDE_CTOR nsString mDescription;
MOZ_INIT_OUTSIDE_CTOR OwningNonNull<ToolExecuteCallback> mExecute;
MOZ_INIT_OUTSIDE_CTOR Optional<JSObject*> mInputSchema;
MOZ_INIT_OUTSIDE_CTOR nsString mName;
ModelContextTool();
explicit inline ModelContextTool(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
ModelContextTool(ModelContextTool&& aOther) = default;
private:
ModelContextTool(const ModelContextTool&) = delete;
ModelContextTool& operator=(const ModelContextTool&) = delete;
static bool
InitIds(JSContext* cx, ModelContextToolAtoms* atomsCache);
public:
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
inline void
TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags)
{
ImplCycleCollectionTraverse(aCallback, mExecute, "mExecute", aFlags);
}
inline void
UnlinkForCC()
{
ImplCycleCollectionUnlink(mExecute);
}
};
namespace binding_detail {
struct FastModelContextTool : public ModelContextTool
{
inline FastModelContextTool()
: ModelContextTool(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct ModelContextToolDefinition : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Optional<ToolAnnotations> mAnnotations;
MOZ_INIT_OUTSIDE_CTOR nsString mDescription;
MOZ_INIT_OUTSIDE_CTOR Optional<JSObject*> mInputSchema;
MOZ_INIT_OUTSIDE_CTOR nsString mName;
ModelContextToolDefinition();
explicit inline ModelContextToolDefinition(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
ModelContextToolDefinition(ModelContextToolDefinition&& aOther) = default;
private:
ModelContextToolDefinition(const ModelContextToolDefinition&) = delete;
ModelContextToolDefinition& operator=(const ModelContextToolDefinition&) = delete;
static bool
InitIds(JSContext* cx, ModelContextToolDefinitionAtoms* atomsCache);
public:
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
};
namespace binding_detail {
struct FastModelContextToolDefinition : public ModelContextToolDefinition
{
inline FastModelContextToolDefinition()
: ModelContextToolDefinition(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace ModelContext_Binding {
typedef mozilla::dom::ModelContext NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::ModelContext* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::ModelContext,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace ModelContext_Binding
namespace ModelContextClient_Binding {
typedef mozilla::dom::ModelContextClient NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::ModelContextClient* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::ModelContextClient,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace ModelContextClient_Binding
} // namespace mozilla::dom
#endif // DOM_MODELCONTEXTBINDING_H_