/work/obj-fuzz/dist/include/mozilla/dom/TextEncoder.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
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 file, |
5 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_textencoder_h_ |
8 | | #define mozilla_dom_textencoder_h_ |
9 | | |
10 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
11 | | #include "mozilla/dom/TextEncoderBinding.h" |
12 | | #include "mozilla/dom/TypedArray.h" |
13 | | #include "mozilla/Encoding.h" |
14 | | |
15 | | namespace mozilla { |
16 | | class ErrorResult; |
17 | | |
18 | | namespace dom { |
19 | | |
20 | | class TextEncoder final : public NonRefcountedDOMObject |
21 | | { |
22 | | public: |
23 | | // The WebIDL constructor. |
24 | | |
25 | | static TextEncoder* |
26 | | Constructor(const GlobalObject& aGlobal, |
27 | | ErrorResult& aRv) |
28 | 0 | { |
29 | 0 | nsAutoPtr<TextEncoder> txtEncoder(new TextEncoder()); |
30 | 0 | txtEncoder->Init(); |
31 | 0 | return txtEncoder.forget(); |
32 | 0 | } |
33 | | |
34 | | TextEncoder() |
35 | 0 | { |
36 | 0 | } |
37 | | |
38 | | virtual |
39 | | ~TextEncoder() |
40 | 0 | {} |
41 | | |
42 | | bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
43 | 0 | { |
44 | 0 | return TextEncoder_Binding::Wrap(aCx, this, aGivenProto, aReflector); |
45 | 0 | } |
46 | | |
47 | | protected: |
48 | | |
49 | | void Init(); |
50 | | |
51 | | public: |
52 | | /** |
53 | | * Return the encoding name. |
54 | | * |
55 | | * @param aEncoding, current encoding. |
56 | | */ |
57 | | void GetEncoding(nsAString& aEncoding); |
58 | | |
59 | | /** |
60 | | * Encodes incoming utf-16 code units/ DOM string to utf-8. |
61 | | * |
62 | | * @param aCx Javascript context. |
63 | | * @param aObj the wrapper of the TextEncoder |
64 | | * @param aString utf-16 code units to be encoded. |
65 | | * @return JSObject* The Uint8Array wrapped in a JS object. Returned via |
66 | | * the aRetval out param. |
67 | | */ |
68 | | void Encode(JSContext* aCx, |
69 | | JS::Handle<JSObject*> aObj, |
70 | | const nsAString& aString, |
71 | | JS::MutableHandle<JSObject*> aRetval, |
72 | | ErrorResult& aRv); |
73 | | }; |
74 | | |
75 | | } // namespace dom |
76 | | } // namespace mozilla |
77 | | |
78 | | #endif // mozilla_dom_textencoder_h_ |