//--------------------------------------------------------------------------- // TVPCreateEventObject //--------------------------------------------------------------------------- iTJSDispatch2 * TVPCreateEventObject(const tjs_char *type, iTJSDispatch2 *targthis, iTJSDispatch2 *targ) { // create a dictionary object for event dispatching ( to "action" method ) iTJSDispatch2 * object = TJSCreateDictionaryObject(); static ttstr type_name(TJS_W("type")); static ttstr target_name(TJS_W("target")); { tTJSVariant val(type); if(TJS_FAILED(object->PropSet(TJS_MEMBERENSURE|TJS_IGNOREPROP, type_name.c_str(), type_name.GetHint(), &val, object))) TVPThrowInternalError; } { tTJSVariant val(targthis, targ); if(TJS_FAILED(object->PropSet(TJS_MEMBERENSURE|TJS_IGNOREPROP, target_name.c_str(), target_name.GetHint(), &val, object))) TVPThrowInternalError; } return object; }
//--------------------------------------------------------------------------- // TJSGetExceptionObject : retrieves TJS 'Exception' object //--------------------------------------------------------------------------- void TJSGetExceptionObject(tTJS *tjs, tTJSVariant *res, tTJSVariant &msg, tTJSVariant *trace/* trace is optional */) { if(!res) return; // not prcess // retrieve class "Exception" from global iTJSDispatch2 *global = tjs->GetGlobalNoAddRef(); tTJSVariant val; static tTJSString Exception_name(TJS_W("Exception")); tjs_error hr = global->PropGet(0, Exception_name.c_str(), Exception_name.GetHint(), &val, global); if(TJS_FAILED(hr)) TJS_eTJSError(TJSExceptionNotFound); // create an Exception object iTJSDispatch2 *excpobj; tTJSVariantClosure clo = val.AsObjectClosureNoAddRef(); tTJSVariant *pmsg = &msg; hr = clo.CreateNew(0, NULL, NULL, &excpobj, 1, &pmsg, clo.ObjThis); if(TJS_FAILED(hr)) TJS_eTJSError(TJSExceptionNotFound); if(trace) { static tTJSString trace_name(TJS_W("trace")); excpobj->PropSet(TJS_MEMBERENSURE, trace_name.c_str(), trace_name.GetHint(), trace, excpobj); } *res = tTJSVariant(excpobj, excpobj); excpobj->Release(); }
// imageをレイヤに描画する static void Image_display(Magick::Image const *image, iTJSDispatch2* lay) { unsigned int w, h; unsigned char *p; long s; if (!lay || TJS_FAILED(lay->IsInstanceOf(0, 0, 0, TJS_W("Layer"), lay))) TVPThrowExceptionMessage(TJS_W("Magick::Image: display method needs Layer-instance param.")); // レイヤサイズ変更 tTJSVariant tmp[4], *args[4] = { tmp, tmp+1, tmp+2, tmp+3 }; tmp[0] = true; if (TJS_FAILED(lay->PropSet(0, TJS_W("hasImage"), 0, tmp, lay))) goto error; tmp[0] = tTVInteger((w = image->columns())); tmp[1] = tTVInteger((h = image->rows())); // if (TJS_FAILED(lay->FuncCall(0, TJS_W("setSize"), 0, 0, 2, args, lay))) goto error; if (TJS_FAILED(lay->FuncCall(0, TJS_W("setImageSize"), 0, 0, 2, args, lay))) goto error; // バッファ取得 lay->PropGet(0, TJS_W("mainImageBufferForWrite"), 0, &tmp[0], lay); lay->PropGet(0, TJS_W("mainImageBufferPitch"), 0, &tmp[1], lay); p = reinterpret_cast<unsigned char*>((tTVInteger)tmp[0]); s = static_cast<long >((tTVInteger)tmp[1]); // コピー typedef Magick::PixelPacket PixelT; if (sizeof(Magick::Quantum) == 1) { // 8bit quantum 専用 for (unsigned int y = 0; y < h; y++, p+=s) { PixelT const *px = image->getConstPixels(0, y, w, 1); unsigned char *cp = p; for (int i = w; i > 0; i--, px++) { *cp++ = static_cast<unsigned char>(px->blue); // B *cp++ = static_cast<unsigned char>(px->green); // G *cp++ = static_cast<unsigned char>(px->red); // R *cp++ = ~static_cast<unsigned char>(px->opacity); // A } } } else { // それ以外はdouble経由なので重い for (unsigned int y = 0; y < h; y++, p+=s) { PixelT const *px = image->getConstPixels(0, y, w, 1); unsigned char *cp = p; for (int i = w; i > 0; i--, px++) { Magick::ColorRGB col(*px); *cp++ = static_cast<unsigned char>(col.blue() * 255); // B *cp++ = static_cast<unsigned char>(col.green() * 255); // G *cp++ = static_cast<unsigned char>(col.red() * 255); // R *cp++ = static_cast<unsigned char>(col.alpha() * 255); // A } } } // アップデート tmp[0] = tTVInteger(0), tmp[1] = tTVInteger(0); tmp[2] = tTVInteger(w), tmp[3] = tTVInteger(h); if (TJS_FAILED(lay->FuncCall(0, TJS_W("update"), 0, 0, 4, args, lay))) goto error; return; error: TVPThrowExceptionMessage(TJS_W("MagickPP_Image.display failed.")); }
//--------------------------------------------------------------------------- tjs_error TJS_INTF_METHOD tTJSNativeClass::CreateNew(tjs_uint32 flag, const tjs_char * membername, tjs_uint32 *hint, iTJSDispatch2 **result, tjs_int numparams, tTJSVariant **param, iTJSDispatch2 *objthis) { // CreateNew iTJSDispatch2 *superinst = NULL; if( SuperClass != NULL && membername == NULL ) { tjs_error hr = SuperClass->CreateNew( flag, membername, hint, &superinst, numparams, param, objthis ); if(TJS_FAILED(hr)) { superinst = NULL; } } iTJSDispatch2 *dsp = CreateBaseTJSObject(); tjs_error hr; try { // set object type for debugging if(TJSObjectHashMapEnabled()) TJSObjectHashSetType(dsp, TJS_W("instance of class ") + ClassName); // instance initialization hr = FuncCall(0, NULL, NULL, NULL, 0, NULL, dsp); // add member to dsp if(TJS_FAILED(hr)) return hr; if( superinst != NULL ) { tTJSVariant param(superinst,superinst); dsp->ClassInstanceInfo( TJS_CII_SET_SUPRECLASS, 0, ¶m ); superinst->Release(); superinst = NULL; } hr = FuncCall(0, ClassName.c_str(), ClassName.GetHint(), NULL, numparams, param, dsp); // call the constructor if(hr == TJS_E_MEMBERNOTFOUND) hr = TJS_S_OK; // missing constructor is OK ( is this ugly ? ) } catch(...) { dsp->Release(); if( superinst ) superinst->Release(); throw; } if(TJS_SUCCEEDED(hr)) { *result = dsp; } else if( superinst ) { superinst->Release(); } return hr; }
virtual iTVPBaseTransHandler * GetTransitionObject( /*in*/iTVPSimpleOptionProvider *options, // option provider /*in*/iTVPSimpleImageProvider *imagepro, // image provider /*in*/tTVPLayerType layertype, /*in*/tjs_uint src1w, tjs_uint src1h, // source 1 size /*in*/tjs_uint src2w, tjs_uint src2h) // source 2 size { tjs_error er; // retrieve "time" option tjs_int64 time; er = options->GetAsNumber(TJS_W("time"), (tjs_int64 *)&time); if(TJS_FAILED(er)) TVPThrowExceptionMessage(TVPSpecifyOption, TJS_W("time")); if(time < 2) time = 2; // too small time may cause problem // retrieve "vague" option tjs_int64 vague; er = options->GetAsNumber(TJS_W("vague"), (tjs_int64 *)&vague); if(TJS_FAILED(er)) vague = 64; // retrieve "rule" option and load it as an image const tjs_char *rulename; er = options->GetAsString(TJS_W("rule"), &rulename); if(TJS_FAILED(er)) TVPThrowExceptionMessage(TVPSpecifyOption, TJS_W("rule")); iTVPScanLineProvider *scpro; er = imagepro->LoadImage(rulename, 8, 0x02ffffff, src1w, src1h, &scpro); if(TJS_FAILED(er)) TVPThrowExceptionMessage(TVPCannotLoadRuleGraphic, rulename); // create a transition object iTVPBaseTransHandler *ret; try { ret = (iTVPBaseTransHandler *) (new tTVPUniversalTransHandler(options, layertype, time, vague, scpro)); } catch(...) { scpro->Release(); throw; } scpro->Release(); return ret; }
/** * TJSオブジェクトのオーバライド処理 * @param args 引数 * @return 結果 */ void TJSInstance::tjsOverride(const FunctionCallbackInfo<Value>& args) { Isolate *isolate = args.GetIsolate(); HandleScope handle_scope(isolate); tTJSVariant instance; if (getVariant(isolate, instance, args.This())) { if (args.Length() > 0) { Local<Value> func = args.Length() > 1 ? args[1] : args.This()->Get(args[0]); if (func->IsFunction()) { tTJSVariant value = toVariant(isolate, func->ToObject(), args.This()); String::Value methodName(args[0]); tjs_error error; if (TJS_FAILED(error = instance.AsObjectClosureNoAddRef().PropSet(TJS_MEMBERENSURE, *methodName, NULL, &value, NULL))) { args.GetReturnValue().Set(ERROR_KRKR(isolate, error)); return; } args.GetReturnValue().Set(Undefined(isolate)); return; } } args.GetReturnValue().Set(isolate->ThrowException(String::NewFromUtf8(isolate, "not function"))); return; } args.GetReturnValue().Set(ERROR_BADINSTANCE(isolate)); }
//--------------------------------------------------------------------------- tjs_error TJS_INTF_METHOD tTJSNI_VideoOverlay::Construct(tjs_int numparams, tTJSVariant **param, iTJSDispatch2 *tjs_obj) { tjs_error hr = inherited::Construct(numparams, param, tjs_obj); if(TJS_FAILED(hr)) return hr; return TJS_S_OK; }
static tTVInteger LayerPropGet(iTJSDispatch2 *lay, ttstr &prop, tTVInteger defval = 0) { if (!LayerClass) { tTJSVariant var; TVPExecuteExpression(TJS_W("Layer"), &var); LayerClass = var.AsObjectNoAddRef(); } tTJSVariant val; return (TJS_FAILED(LayerClass->PropGet(0, prop.c_str(), prop.GetHint(), &val, lay))) ? defval : val.AsInteger(); }
//--------------------------------------------------------------------------- tjs_error TJS_INTF_METHOD tTJSNI_SoundBuffer::Construct(tjs_int numparams, tTJSVariant **param, iTJSDispatch2 *tjs_obj) { tjs_error hr = inherited::Construct(numparams, param, tjs_obj); if(TJS_FAILED(hr)) return hr; TVPAddSoundBuffer(this); return TJS_S_OK; }
static Magick::Image* ImageCtor_layer(iTJSDispatch2* lay) { unsigned int w, h; unsigned char *p; long s; if (!lay || TJS_FAILED(lay->IsInstanceOf(0, 0, 0, TJS_W("Layer"), lay))) TVPThrowExceptionMessage(TJS_W("Magick::Image: _layer method needs Layer-instance param.")); // レイヤサイズ取得 tTJSVariant tmp[2]; lay->PropGet(0, TJS_W("imageWidth"), 0, &tmp[0], lay); lay->PropGet(0, TJS_W("imageHeight"), 0, &tmp[1], lay); w = static_cast<unsigned int>((tTVInteger)tmp[0]); h = static_cast<unsigned int>((tTVInteger)tmp[1]); // バッファ取得 lay->PropGet(0, TJS_W("mainImageBuffer"), 0, &tmp[0], lay); lay->PropGet(0, TJS_W("mainImageBufferPitch"), 0, &tmp[1], lay); p = reinterpret_cast<unsigned char*>((tTVInteger)tmp[0]); s = static_cast<long >((tTVInteger)tmp[1]); typedef Magick::PixelPacket PixelT; typedef Magick::Color ColorT; Magick::Image *image = new Magick::Image(Magick::Geometry(w, h), ColorT()); image->modifyImage(); image->type(Magick::TrueColorMatteType); // コピー if (sizeof(Magick::Quantum) == 1) { // 8bit quantum 専用 for (unsigned int y = 0; y < h; y++, p+=s) { unsigned char *cp = p; PixelT *q = image->getPixels(0, y, w, 1); for (int i = w; i > 0; i--, cp+=4) { *q++ = ColorT(static_cast<Magick::Quantum>(cp[2]), static_cast<Magick::Quantum>(cp[1]), static_cast<Magick::Quantum>(cp[0]), ~static_cast<Magick::Quantum>(cp[3])); } image->syncPixels(); } } else { // それ以外はdouble経由なので重い for (unsigned int y = 0; y < h; y++, p+=s) { unsigned char *cp = p; PixelT *q = image->getPixels(0, y, w, 1); for (int i = w; i > 0; i--, cp+=4) { Magick::ColorRGB col(cp[2]/255.0, cp[1]/255.0, cp[0]/255.0); col.alpha(cp[3]/255.0); *q++ = col; } image->syncPixels(); } } return image; }
SPRIG_INLINE void PropSetByNum( iTJSDispatch2* that, tjs_uint32 flag, tjs_int num, tTJSVariant const* param, iTJSDispatch2* objthis ) { if (TJS_FAILED(that->PropSetByNum(flag, num, param, objthis))) { ::TVPThrowExceptionMessage(SPRIG_KRKR_TJS_W("error in iTJSDispatch2::PropSetByNum()")); } }
SPRIG_INLINE tTJSVariant* PropGetByNum( iTJSDispatch2* that, tjs_uint32 flag, tjs_int num, tTJSVariant* result, iTJSDispatch2* objthis ) { if (TJS_FAILED(that->PropGetByNum(flag, num, result, objthis))) { ::TVPThrowExceptionMessage(SPRIG_KRKR_TJS_W("error in iTJSDispatch2::PropGetByNum()")); } return result; }
//--------------------------------------------------------------------------- void TVPRemoveTransHandlerProvider(iTVPTransHandlerProvider *pro) { // remove transition handler provider from the system // retrieve transition name const tjs_char * cname; if(TJS_FAILED(pro->GetName(&cname))) TVPThrowExceptionMessage(TVPTransHandlerError, TJS_W("tTVPTransHandlerProvider::GetName failed")); ttstr name = cname; TVPTransHandlerProviders.Delete(name); }
//--------------------------------------------------------------------------- static tjs_int GetValueFromOptions(iTJSDispatch2 *options, const tjs_char *name, tjs_uint32 *hint, tjs_int defvalue) { tTJSVariant val; if(!options) return defvalue; if(TJS_FAILED(options->PropGet(TJS_MEMBERMUSTEXIST, name, hint, &val, options))) { return defvalue; } return val; }
SPRIG_INLINE tjs_int* GetCount( iTJSDispatch2* that, tjs_int *result, tjs_char const* membername, tjs_uint32* hint, iTJSDispatch2* objthis ) { if (TJS_FAILED(that->GetCount(result, membername, hint, objthis))) { ::TVPThrowExceptionMessage(SPRIG_KRKR_TJS_W("error in iTJSDispatch2::GetCount()")); } return result; }
SPRIG_INLINE void PropSet( iTJSDispatch2* that, tjs_uint32 flag, tjs_char const* membername, tjs_uint32* hint, tTJSVariant const* param, iTJSDispatch2* objthis ) { if (TJS_FAILED(that->PropSet(flag, membername, hint, param, objthis))) { ::TVPThrowExceptionMessage(SPRIG_KRKR_TJS_W("error in iTJSDispatch2::PropSet()")); } }
SPRIG_INLINE tTJSVariant* PropGet( iTJSDispatch2* that, tjs_uint32 flag, tjs_char const* membername, tjs_uint32* hint, tTJSVariant* result, iTJSDispatch2* objthis ) { if (TJS_FAILED(that->PropGet(flag, membername, hint, result, objthis))) { ::TVPThrowExceptionMessage(SPRIG_KRKR_TJS_W("error in iTJSDispatch2::PropGet()")); } return result; }
//--------------------------------------------------------------------------- tjs_error TJS_INTF_METHOD tTJSNI_BaseSoundBuffer::Construct(tjs_int numparams, tTJSVariant **param, iTJSDispatch2 *tjs_obj) { if(numparams < 1) return TJS_E_BADPARAMCOUNT; tjs_error hr = inherited::Construct(numparams, param, tjs_obj); if(TJS_FAILED(hr)) return hr; ActionOwner = param[0]->AsObjectClosure(); Owner = tjs_obj; return TJS_S_OK; }
SPRIG_INLINE void FuncCall( iTJSDispatch2* that, tjs_uint32 flag, tjs_char const* membername, tjs_uint32* hint, tTJSVariant* result, tjs_int numparams, tTJSVariant** param, iTJSDispatch2* objthis ) { if (TJS_FAILED(that->FuncCall(flag, membername, hint, result, numparams, param, objthis))) { ::TVPThrowExceptionMessage(SPRIG_KRKR_TJS_W("error in iTJSDispatch2::FuncCall()")); } }
virtual iTVPBaseTransHandler * GetTransitionObject( /*in*/iTVPSimpleOptionProvider *options, // option provider /*in*/iTVPSimpleImageProvider *imagepro, // image provider /*in*/tTVPLayerType layertype, /*in*/tjs_uint src1w, tjs_uint src1h, // source 1 size /*in*/tjs_uint src2w, tjs_uint src2h) // source 2 size { tjs_int64 time; tjs_error er = options->GetAsNumber(TJS_W("time"), (tjs_int64 *)&time); if(TJS_FAILED(er)) TVPThrowExceptionMessage(TVPSpecifyOption, TJS_W("time")); if(time < 2) time = 2; // too small time may cause problem return (iTVPBaseTransHandler *) (new tTVPCrossFadeTransHandler(options, layertype, time)); }
//--------------------------------------------------------------------------- tjs_error TJS_INTF_METHOD tTVPSimpleOptionProvider::GetValue( /*in*/const tjs_char *name, /*out*/tTJSVariant *dest) { try { if(!dest) return TJS_E_FAIL; tjs_error er = Object.PropGet(0, name, NULL, dest, NULL); if(TJS_FAILED(er)) return er; return TJS_S_OK; } catch(...) { return TJS_E_FAIL; } }
virtual iTVPBaseTransHandler * GetTransitionObject( /*in*/iTVPSimpleOptionProvider *options, // option provider /*in*/iTVPSimpleImageProvider *imagepro, // image provider /*in*/tTVPLayerType layertype, /*in*/tjs_uint src1w, tjs_uint src1h, // source 1 size /*in*/tjs_uint src2w, tjs_uint src2h) // source 2 size { tjs_error er; tjs_int64 value; // retrieve "time" option tjs_int64 time; er = options->GetAsNumber(TJS_W("time"), &time); if(TJS_FAILED(er)) TVPThrowExceptionMessage(TVPSpecifyOption, TJS_W("time")); if(time < 2) time = 2; // too small time may cause problem // retrieve "from" option tTVPScrollTransFrom from; er = options->GetAsNumber(TJS_W("from"), &value); if(TJS_FAILED(er)) from = sttLeft; else from = (tTVPScrollTransFrom)value; // retrieve "stay" option tTVPScrollTransStay stay; er = options->GetAsNumber(TJS_W("stay"), &value); if(TJS_FAILED(er)) stay = ststNoStay; else stay = (tTVPScrollTransStay)value; // determine maximum phase count tjs_int maxphase = (from == sttLeft || from == sttRight)?src1w:src2h; // create a transition object iTVPBaseTransHandler *ret; ret = (iTVPBaseTransHandler *) (new tTVPScrollTransHandler(options, layertype, time, from, stay, maxphase)); return ret; }
//--------------------------------------------------------------------------- tjs_error TJS_INTF_METHOD tTJSDictionaryObject::Operation(tjs_uint32 flag, const tjs_char *membername, tjs_uint32 *hint, tTJSVariant *result, const tTJSVariant *param, iTJSDispatch2 *objthis) { tjs_error hr = inherited::Operation(flag, membername, hint, result, param, objthis); if(hr == TJS_E_MEMBERNOTFOUND && !(flag & TJS_MEMBERMUSTEXIST)) { // value not found -> create a value, do the operation once more static tTJSVariant VoidVal; hr = inherited::PropSet(TJS_MEMBERENSURE, membername, hint, &VoidVal, objthis); if(TJS_FAILED(hr)) return hr; hr = inherited::Operation(flag, membername, hint, result, param, objthis); } return hr; }
/** * 登録処理後 */ static void PostRegistCallback() { // Array.count を取得 { tTJSVariant varScripts; TVPExecuteExpression(TJS_W("Array"), &varScripts); iTJSDispatch2 *dispatch = varScripts.AsObjectNoAddRef(); tTJSVariant val; if (TJS_FAILED(dispatch->PropGet(TJS_IGNOREPROP, TJS_W("count"), NULL, &val, dispatch))) { TVPThrowExceptionMessage(L"can't get Array.count"); } ArrayCountProp = val.AsObject(); } }
//--------------------------------------------------------------------------- void TVPAddTransHandlerProvider(iTVPTransHandlerProvider *pro) { // add transition handler provider to the system // retrieve transition name const tjs_char *cname; if(TJS_FAILED(pro->GetName(&cname))) TVPThrowExceptionMessage(TVPTransHandlerError, TJS_W("tTVPTransHandlerProvider::GetName failed")); ttstr name = cname; tTVPTransHandlerProviderHolder *p = TVPTransHandlerProviders.Find(name); if(p) TVPThrowExceptionMessage(TVPTransAlreadyRegistered, name); tTVPTransHandlerProviderHolder holder(pro); TVPTransHandlerProviders.Add(name, holder); }
/** * 吉里吉里クラスから Javascript クラスを生成 * @param args 引数 * @return 結果 */ void TJSInstance::createTJSClass(const FunctionCallbackInfo<Value>& args) { Isolate *isolate = args.GetIsolate(); HandleScope handle_scope(isolate); if (args.Length() < 1) { args.GetReturnValue().Set(isolate->ThrowException(String::NewFromUtf8(isolate, "invalid param"))); return; } // TJSクラス情報取得 String::Value tjsClassName(args[0]); tTJSVariant tjsClassObj; TVPExecuteExpression(*tjsClassName, &tjsClassObj); if (tjsClassObj.Type() != tvtObject || TJS_FAILED(tjsClassObj.AsObjectClosureNoAddRef().IsInstanceOf(0,NULL,NULL,L"Class",NULL))) { args.GetReturnValue().Set(isolate->ThrowException(String::NewFromUtf8(isolate, "invalid param"))); return; } // クラステンプレートを生成 Local<FunctionTemplate> classTemplate = FunctionTemplate::New(isolate, tjsConstructor, TJSObject::toJSObject(isolate, tjsClassObj)); classTemplate->SetClassName(args[0]->ToString()); // 表示名 // メンバ登録処理 for (int i=args.Length()-1;i>=0;i--) { String::Value className(args[i]); tTJSVariant classObj; TVPExecuteExpression(*className, &classObj); if (classObj.Type() == tvtObject && TJS_SUCCEEDED(classObj.AsObjectClosureNoAddRef().IsInstanceOf(0,NULL,NULL,L"Class",NULL))) { MemberRegister *caller = new MemberRegister(isolate, classTemplate); tTJSVariantClosure closure(caller); classObj.AsObjectClosureNoAddRef().EnumMembers(TJS_IGNOREPROP, &closure, NULL); caller->Release(); } } // TJS機能メソッドを登録 Local<ObjectTemplate> protoTemplate = classTemplate->PrototypeTemplate(); protoTemplate->Set(String::NewFromUtf8(isolate, "tjsIsValid"), FunctionTemplate::New(isolate, tjsIsValid)); protoTemplate->Set(String::NewFromUtf8(isolate, "tjsOverride"), FunctionTemplate::New(isolate, tjsOverride)); args.GetReturnValue().Set(classTemplate->GetFunction()); }
//--------------------------------------------------------------------------- tjs_error TJS_INTF_METHOD tTVPUniversalTransHandler::StartProcess( tjs_uint64 tick) { tjs_error er; er = inherited::StartProcess(tick); if(TJS_FAILED(er)) return er; // start one frame of the transition // create blend table if(TVPIsTypeUsingAlpha(DestLayerType)) TVPInitUnivTransBlendTable_d(BlendTable, Phase, Vague); else if(TVPIsTypeUsingAddAlpha(DestLayerType)) TVPInitUnivTransBlendTable_a(BlendTable, Phase, Vague); else TVPInitUnivTransBlendTable(BlendTable, Phase, Vague); return er; }
//--------------------------------------------------------------------------- void TJSThrowFrom_tjs_error(tjs_error hr, const tjs_char *name) { // raise an exception descripted as tjs_error // name = variable name ( otherwide it can be NULL ) switch(hr) { case TJS_E_MEMBERNOTFOUND: { if(name) { ttstr str(TJSMemberNotFound); str.Replace(TJS_W("%1"), name); TJS_eTJSError(str); } else { TJS_eTJSError(TJSMemberNotFoundNoNameGiven); } } case TJS_E_NOTIMPL: TJS_eTJSError(TJSNotImplemented); case TJS_E_INVALIDPARAM: TJS_eTJSError(TJSInvalidParam); case TJS_E_BADPARAMCOUNT: TJS_eTJSError(TJSBadParamCount); case TJS_E_INVALIDTYPE: TJS_eTJSError(TJSInvalidType); case TJS_E_ACCESSDENYED: TJS_eTJSError(TJSAccessDenyed); case TJS_E_INVALIDOBJECT: TJS_eTJSError(TJSInvalidObject); case TJS_E_NATIVECLASSCRASH: TJS_eTJSError(TJSNativeClassCrash); default: if(TJS_FAILED(hr)) { tjs_char buf[256]; TJS_snprintf(buf, 256, TJS_W("Unknown failure : %08X"), hr); TJS_eTJSError(buf); } } }
//--------------------------------------------------------------------------- tjs_error TJS_INTF_METHOD tTVPSimpleOptionProvider::GetAsNumber( /*in*/const tjs_char *name, /*out*/tjs_int64 *value) { try { tTJSVariant val; tjs_error er = Object.PropGet(0, name, NULL, &val, NULL); if(TJS_FAILED(er)) return er; if(val.Type() == tvtVoid) return TJS_E_MEMBERNOTFOUND; if(value) *value = val.AsInteger(); return TJS_S_OK; } catch(...) { return TJS_E_FAIL; } }
//--------------------------------------------------------------------------- tjs_error TJS_INTF_METHOD tTVPSimpleOptionProvider::GetAsString( /*in*/const tjs_char *name, /*out*/const tjs_char **out) { try { tTJSVariant val; tjs_error er = Object.PropGet(0, name, NULL, &val, NULL); if(TJS_FAILED(er)) return er; if(val.Type() == tvtVoid) return TJS_E_MEMBERNOTFOUND; String = val; // to hold string buffer if(out) *out = String.c_str(); return TJS_S_OK; } catch(...) { return TJS_E_FAIL; } }