blob: 2e5a11d9361982b406209e1e99e2bef15e10cfa5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef EXTENSIONS_SPELLCHECK_HUNSPELL_GLUE_RLBOXHUNSPELL_H_
#define EXTENSIONS_SPELLCHECK_HUNSPELL_GLUE_RLBOXHUNSPELL_H_
#include "RLBoxHunspellTypes.h"
// Load general firefox configuration of RLBox
#include "mozilla/rlbox/rlbox_config.h"
#ifdef MOZ_WASM_SANDBOXING_HUNSPELL
// Include the generated header file so that we are able to resolve the symbols
// in the wasm binary
# include "rlbox.wasm.h"
# define RLBOX_USE_STATIC_CALLS() rlbox_wasm2c_sandbox_lookup_symbol
# include "mozilla/rlbox/rlbox_wasm2c_sandbox.hpp"
#else
# define RLBOX_USE_STATIC_CALLS() rlbox_noop_sandbox_lookup_symbol
# include "mozilla/rlbox/rlbox_noop_sandbox.hpp"
#endif
#include "mozilla/rlbox/rlbox.hpp"
#include <hunspell.h>
#include "mozHunspellRLBoxGlue.h"
class RLBoxHunspell {
public:
static RLBoxHunspell* Create(const nsCString& affpath,
const nsCString& dpath);
~RLBoxHunspell();
int spell(const std::string& stdWord);
const std::string& get_dict_encoding() const;
std::vector<std::string> suggest(const std::string& word);
private:
struct RLBoxDeleter {
void operator()(rlbox_sandbox_hunspell* sandbox) {
sandbox->destroy_sandbox();
delete sandbox;
}
};
RLBoxHunspell(
mozilla::UniquePtr<rlbox_sandbox_hunspell, RLBoxDeleter> aSandbox,
const nsCString& affpath, const nsCString& dpath);
mozilla::UniquePtr<rlbox_sandbox_hunspell, RLBoxDeleter> mSandbox;
sandbox_callback_hunspell<hunspell_create_filemgr_t*> mCreateFilemgr;
sandbox_callback_hunspell<hunspell_get_line_t*> mGetLine;
sandbox_callback_hunspell<hunspell_get_line_num_t*> mGetLineNum;
sandbox_callback_hunspell<hunspell_destruct_filemgr_t*> mDestructFilemgr;
sandbox_callback_hunspell<hunspell_ToUpperCase_t*> mHunspellToUpperCase;
sandbox_callback_hunspell<hunspell_ToLowerCase_t*> mHunspellToLowerCase;
sandbox_callback_hunspell<hunspell_get_current_cs_t*> mHunspellGetCurrentCS;
tainted_hunspell<Hunhandle*> mHandle;
std::string mDicEncoding;
};
#endif
|