Handle<Value> Nodehun::SpellDictionary::New(const Arguments& args) { HandleScope scope; int argl = args.Length(); if (!args.IsConstructCall()) return ThrowException(Exception::Error(String::New("Use the new operator to create an instance of this object."))); if(argl < 2) return ThrowException(Exception::Error(String::New("Constructor requires two arguments."))); if(!Buffer::HasInstance(args[0])) return ThrowException(Exception::TypeError(String::New("First argument must be a buffer"))); if(!Buffer::HasInstance(args[1])) return ThrowException(Exception::TypeError(String::New("Second argument must be a buffer"))); Nodehun::SpellDictionary *obj = new Nodehun::SpellDictionary(Buffer::Data(args[0].As<Object>()), Buffer::Data(args[1].As<Object>())); obj->Wrap(args.This()); return args.This(); }
Handle<Value> Nodehun::SpellDictionary::New(const Arguments& args) { HandleScope scope; int argl = args.Length(); if (!args.IsConstructCall()) return ThrowException(Exception::TypeError(String::New("Use the new operator to create instances of this object."))); if(argl < 1 || !args[0]->IsString()) return ThrowException(Exception::TypeError(String::New("First argument must be a string."))); String::Utf8Value arg0(args[0]->ToString()); Nodehun::SpellDictionary * obj; if(argl == 1 || argl > 1 && !args[1]->IsString()){ obj = new Nodehun::SpellDictionary(*arg0); if(!obj->pathsExist) return ThrowException(Exception::TypeError(String::New("No such dictionary exists."))); } else { String::Utf8Value arg1(args[1]->ToString()); obj = new Nodehun::SpellDictionary(*arg0,*arg1); if(!obj->pathsExist) return ThrowException(Exception::TypeError(String::New("There was an error compiling either the affix or dictionary file you passed. Perhaps one or both of them is invalid."))); } obj->Wrap(args.This()); return args.This(); }