Exemplo n.º 1
0
		// 実行
		bool exec(iTJSDispatch2 *obj, tTVPWindowMessage *message) {
			switch (receiver.Type()) {
			case tvtObject:
				{
					tTJSVariant result;
					tTJSVariant wparam = (tjs_int)message->WParam;
					tTJSVariant lparam = (tjs_int)message->LParam;
					tTJSVariant *p[] = {&userData, &wparam, &lparam};
					receiver.AsObjectClosureNoAddRef().FuncCall(0, NULL, NULL, &result, 3, p, NULL);
					return (int)result != 0;
				}
				break;
			case tvtString:
				{
					tTJSVariant result;
					tTJSVariant wparam = (tjs_int)message->WParam;
					tTJSVariant lparam = (tjs_int)message->LParam;
					tTJSVariant *p[] = {&userData, &wparam, &lparam};
					obj->FuncCall(0, receiver.GetString(), NULL, &result, 3, p, obj);
					return (int)result != 0;
				}
				break;
			case tvtInteger:
				{
					NativeReceiver receiverNative = (NativeReceiver)(tjs_int)receiver;
					return receiverNative(obj, (void*)(tjs_int)userData, message);
				}
				break;
			}
			return false;
		}
Exemplo n.º 2
0
static void
getVariantString(tTJSVariant &var, IWriter *writer)
{
	switch(var.Type()) {

	case tvtVoid:
		writer->write(L"void");
		break;
		
	case tvtObject:
		{
			iTJSDispatch2 *obj = var.AsObjectNoAddRef();
			if (obj == NULL) {
				writer->write(L"null");
			} else if (obj->IsInstanceOf(TJS_IGNOREPROP,NULL,NULL,L"Array",obj) == TJS_S_TRUE) {
				getArrayString(obj, writer);
			} else {
				getDictString(obj, writer);
			}
		}
		break;
		
	case tvtString:
		quoteString(var.GetString(), writer);
		break;

        case tvtOctet:
               quoteOctet(var.AsOctetNoAddRef(), writer);
               break;

	case tvtInteger:
		writer->write(L"int ");
		writer->write((tTVInteger)var);
		break;

	case tvtReal:
		writer->write(L"real ");
		writer->write((tTVReal)var);
		break;

	default:
		writer->write(L"void");
		break;
	};
}
Exemplo n.º 3
0
/**
 * tTJSVariant を VARIANT に格納する
 * @param result 格納先
 * @param variant 格納元
 */
void
IDispatchWrapper::storeVariant(VARIANT &result, tTJSVariant &variant)
{
	VariantClear(&result);
	switch (variant.Type()) {
	case tvtVoid:
		//log(L"void");
		break;
	case tvtObject:
		// オブジェクト
		//log(L"object");
		{
			switch (variant.Type()) {
			case tvtObject:
				V_VT(&result)       = VT_DISPATCH;
				V_DISPATCH(&result) = new IDispatchWrapper(variant.AsObjectNoAddRef());
				break;
			default:
				V_VT(&result) = VT_NULL;
				break;
			}
		}
		break;
	case tvtString:
		//log(L"string");
		// 文字列
		V_VT(&result) = VT_BSTR;
		V_BSTR(&result) = SysAllocString(variant.GetString());
		break;
	case tvtOctet:
		//log(L"octet");
		// オクテット列
		{
			tTJSVariantOctet *octet = variant.AsOctetNoAddRef();
			if (octet) {
				SAFEARRAY *psa;
				SAFEARRAYBOUND sabound;
				sabound.lLbound = 0;
				sabound.cElements = octet->GetLength();
				if ((psa = SafeArrayCreate(VT_UI1, 1, &sabound))) {
					// データをコピーする
					unsigned char *p;
					if (SUCCEEDED(SafeArrayAccessData(psa, (LPVOID*)&p))) {
						memcpy(p, octet->GetData(), octet->GetLength());
						SafeArrayUnaccessData(psa);
						V_VT(&result) = VT_ARRAY | VT_UI1;
						V_ARRAY(&result) = psa;
					} else {
						SafeArrayDestroy(psa);
					}
				} else {
					// メモリ不足例外
				}
			}
		}
		break;
	case tvtInteger:
		// COM は 64bit をサポートしていない!!
		// ということで COM に渡す引数で整数値は 32bit を超えないように注意すること(涙)
		//log(L"integer");
		V_VT(&result) = VT_I4;
		V_I4(&result) = (int)(variant);
		break;
	case tvtReal:
		//log(L"real");
		V_VT(&result) = VT_R8;
		V_R8(&result) = (double)(variant);
		break;
	}
}