MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / GenerateDict

Method GenerateDict

node/opencc.cc:157–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155 }
156
157 static Napi::Value GenerateDict(const Napi::CallbackInfo& info) {
158 Napi::Env env = info.Env();
159 if (info.Length() < 4 || !info[0].IsString() || !info[1].IsString() ||
160 !info[2].IsString() || !info[3].IsString()) {
161 Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
162 return env.Undefined();
163 }
164 const std::string inputFileName = ToUtf8String(info[0]);
165 const std::string outputFileName = ToUtf8String(info[1]);
166 const std::string formatFrom = ToUtf8String(info[2]);
167 const std::string formatTo = ToUtf8String(info[3]);
168 try {
169 opencc::ConvertDictionary(inputFileName, outputFileName, formatFrom,
170 formatTo);
171 } catch (opencc::Exception& e) {
172 Napi::Error::New(env, e.what()).ThrowAsJavaScriptException();
173 }
174 return env.Undefined();
175 }
176
177 static Napi::Object Init(Napi::Env env, Napi::Object exports) {
178 Napi::Function cons = DefineClass(

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
ToUtf8StringFunction · 0.85
ConvertDictionaryFunction · 0.85
LengthMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected