From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../spellcheck/hunspell/glue/RLBoxHunspell.h | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 extensions/spellcheck/hunspell/glue/RLBoxHunspell.h (limited to 'extensions/spellcheck/hunspell/glue/RLBoxHunspell.h') diff --git a/extensions/spellcheck/hunspell/glue/RLBoxHunspell.h b/extensions/spellcheck/hunspell/glue/RLBoxHunspell.h new file mode 100644 index 0000000000..2e5a11d936 --- /dev/null +++ b/extensions/spellcheck/hunspell/glue/RLBoxHunspell.h @@ -0,0 +1,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 +#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 suggest(const std::string& word); + + private: + struct RLBoxDeleter { + void operator()(rlbox_sandbox_hunspell* sandbox) { + sandbox->destroy_sandbox(); + delete sandbox; + } + }; + + RLBoxHunspell( + mozilla::UniquePtr aSandbox, + const nsCString& affpath, const nsCString& dpath); + + mozilla::UniquePtr mSandbox; + sandbox_callback_hunspell mCreateFilemgr; + sandbox_callback_hunspell mGetLine; + sandbox_callback_hunspell mGetLineNum; + sandbox_callback_hunspell mDestructFilemgr; + sandbox_callback_hunspell mHunspellToUpperCase; + sandbox_callback_hunspell mHunspellToLowerCase; + sandbox_callback_hunspell mHunspellGetCurrentCS; + tainted_hunspell mHandle; + std::string mDicEncoding; +}; + +#endif -- cgit v1.2.3