SpeechGrammar.cpp (1799B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "SpeechGrammar.h" 8 9 #include "mozilla/ErrorResult.h" 10 #include "mozilla/dom/SpeechGrammarBinding.h" 11 12 namespace mozilla::dom { 13 14 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(SpeechGrammar, mParent) 15 NS_IMPL_CYCLE_COLLECTING_ADDREF(SpeechGrammar) 16 NS_IMPL_CYCLE_COLLECTING_RELEASE(SpeechGrammar) 17 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SpeechGrammar) 18 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY 19 NS_INTERFACE_MAP_ENTRY(nsISupports) 20 NS_INTERFACE_MAP_END 21 22 SpeechGrammar::SpeechGrammar(nsISupports* aParent) : mParent(aParent) {} 23 24 SpeechGrammar::~SpeechGrammar() = default; 25 26 already_AddRefed<SpeechGrammar> SpeechGrammar::Constructor( 27 const GlobalObject& aGlobal) { 28 RefPtr<SpeechGrammar> speechGrammar = 29 new SpeechGrammar(aGlobal.GetAsSupports()); 30 return speechGrammar.forget(); 31 } 32 33 nsISupports* SpeechGrammar::GetParentObject() const { return mParent; } 34 35 JSObject* SpeechGrammar::WrapObject(JSContext* aCx, 36 JS::Handle<JSObject*> aGivenProto) { 37 return SpeechGrammar_Binding::Wrap(aCx, this, aGivenProto); 38 } 39 40 void SpeechGrammar::GetSrc(nsString& aRetVal, ErrorResult& aRv) const { 41 aRetVal = mSrc; 42 } 43 44 void SpeechGrammar::SetSrc(const nsAString& aArg, ErrorResult& aRv) { 45 mSrc = aArg; 46 } 47 48 float SpeechGrammar::GetWeight(ErrorResult& aRv) const { 49 aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); 50 return 0; 51 } 52 53 void SpeechGrammar::SetWeight(float aArg, ErrorResult& aRv) { 54 aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); 55 } 56 57 } // namespace mozilla::dom