static void ole_set_byref(VARIANT *realvar, VARIANT *var, VARTYPE vt) { V_VT(var) = vt; if (vt == (VT_VARIANT|VT_BYREF)) { V_VARIANTREF(var) = realvar; } else { if (V_VT(realvar) != (vt & ~VT_BYREF)) { rb_raise(eWIN32OLERuntimeError, "variant type mismatch"); } switch(vt & ~VT_BYREF) { case VT_I1: V_I1REF(var) = &V_I1(realvar); break; case VT_UI1: V_UI1REF(var) = &V_UI1(realvar); break; case VT_I2: V_I2REF(var) = &V_I2(realvar); break; case VT_UI2: V_UI2REF(var) = &V_UI2(realvar); break; case VT_I4: V_I4REF(var) = &V_I4(realvar); break; case VT_UI4: V_UI4REF(var) = &V_UI4(realvar); break; case VT_R4: V_R4REF(var) = &V_R4(realvar); break; case VT_R8: V_R8REF(var) = &V_R8(realvar); break; #if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__) #ifdef V_I8REF case VT_I8: V_I8REF(var) = &V_I8(realvar); break; #endif #ifdef V_UI8REF case VT_UI8: V_UI8REF(var) = &V_UI8(realvar); break; #endif #endif case VT_INT: V_INTREF(var) = &V_INT(realvar); break; case VT_UINT: V_UINTREF(var) = &V_UINT(realvar); break; case VT_CY: V_CYREF(var) = &V_CY(realvar); break; case VT_DATE: V_DATEREF(var) = &V_DATE(realvar); break; case VT_BSTR: V_BSTRREF(var) = &V_BSTR(realvar); break; case VT_DISPATCH: V_DISPATCHREF(var) = &V_DISPATCH(realvar); break; case VT_ERROR: V_ERRORREF(var) = &V_ERROR(realvar); break; case VT_BOOL: V_BOOLREF(var) = &V_BOOL(realvar); break; case VT_UNKNOWN: V_UNKNOWNREF(var) = &V_UNKNOWN(realvar); break; case VT_ARRAY: V_ARRAYREF(var) = &V_ARRAY(realvar); break; default: rb_raise(eWIN32OLERuntimeError, "unknown type specified(setting BYREF):%d", vt); break; } } }
PHP_COM_DOTNET_API int php_com_copy_variant(VARIANT *dstvar, VARIANT *srcvar) { int ret = SUCCESS; switch (V_VT(dstvar) & ~VT_BYREF) { case VT_EMPTY: case VT_NULL: case VT_VOID: /* should not be possible */ break; case VT_UI1: if (V_VT(dstvar) & VT_BYREF) { *V_UI1REF(dstvar) = V_UI1(srcvar); } else { V_UI1(dstvar) = V_UI1(srcvar); } break; case VT_I1: if (V_VT(dstvar) & VT_BYREF) { *V_I1REF(dstvar) = V_I1(srcvar); } else { V_I1(dstvar) = V_I1(srcvar); } break; case VT_UI2: if (V_VT(dstvar) & VT_BYREF) { *V_UI2REF(dstvar) = V_UI2(srcvar); } else { V_UI2(dstvar) = V_UI2(srcvar); } break; case VT_I2: if (V_VT(dstvar) & VT_BYREF) { *V_I2REF(dstvar) = V_I2(srcvar); } else { V_I2(dstvar) = V_I2(srcvar); } break; case VT_UI4: if (V_VT(dstvar) & VT_BYREF) { *V_UI4REF(dstvar) = V_UI4(srcvar); } else { V_UI4(dstvar) = V_UI4(srcvar); } break; case VT_I4: if (V_VT(dstvar) & VT_BYREF) { *V_I4REF(dstvar) = V_I4(srcvar); } else { V_I4(dstvar) = V_I4(srcvar); } break; #if SIZEOF_ZEND_LONG == 8 case VT_UI8: if (V_VT(dstvar) & VT_BYREF) { *V_UI8REF(dstvar) = V_UI8(srcvar); } else { V_UI8(dstvar) = V_UI8(srcvar); } break; case VT_I8: if (V_VT(dstvar) & VT_BYREF) { *V_I8REF(dstvar) = V_I8(srcvar); } else { V_I8(dstvar) = V_I8(srcvar); } break; #endif case VT_INT: if (V_VT(dstvar) & VT_BYREF) { *V_INTREF(dstvar) = V_INT(srcvar); } else { V_INT(dstvar) = V_INT(srcvar); } break; case VT_UINT: if (V_VT(dstvar) & VT_BYREF) { *V_UINTREF(dstvar) = V_UINT(srcvar); } else { V_UINT(dstvar) = V_UINT(srcvar); } break; case VT_R4: if (V_VT(dstvar) & VT_BYREF) { *V_R4REF(dstvar) = V_R4(srcvar); } else { V_R4(dstvar) = V_R4(srcvar); } break; case VT_R8: if (V_VT(dstvar) & VT_BYREF) { *V_R8REF(dstvar) = V_R8(srcvar); } else { V_R8(dstvar) = V_R8(srcvar); } break; case VT_BOOL: if (V_VT(dstvar) & VT_BYREF) { *V_BOOLREF(dstvar) = V_BOOL(srcvar); } else { V_BOOL(dstvar) = V_BOOL(srcvar); } break; case VT_BSTR: if (V_VT(dstvar) & VT_BYREF) { *V_BSTRREF(dstvar) = V_BSTR(srcvar); } else { V_BSTR(dstvar) = V_BSTR(srcvar); } break; case VT_UNKNOWN: if (V_VT(dstvar) & VT_BYREF) { *V_UNKNOWNREF(dstvar) = V_UNKNOWN(srcvar); } else { V_UNKNOWN(dstvar) = V_UNKNOWN(srcvar); } break; case VT_DISPATCH: if (V_VT(dstvar) & VT_BYREF) { *V_DISPATCHREF(dstvar) = V_DISPATCH(srcvar); } else { V_DISPATCH(dstvar) = V_DISPATCH(srcvar); } break; case VT_VARIANT: return php_com_copy_variant(V_VARIANTREF(dstvar), srcvar); default: php_error_docref(NULL, E_WARNING, "variant->variant: failed to copy from 0x%x to 0x%x", V_VT(dstvar), V_VT(srcvar)); ret = FAILURE; } return ret; }