MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / AssignVariant

Function AssignVariant

source/script_com.cpp:738–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

736}
737
738void AssignVariant(Var &aArg, VARIANT &aVar, bool aRetainVar = true)
739{
740 if (aVar.vt == VT_BSTR)
741 {
742 // Avoid an unnecessary mem alloc and copy in some cases.
743 aArg.AssignStringW(aVar.bstrVal, SysStringLen(aVar.bstrVal));
744 if (!aRetainVar)
745 VariantClear(&aVar);
746 return;
747 }
748 ResultToken token;
749 VariantToToken(aVar, token, aRetainVar);
750 switch (token.symbol)
751 {
752 case SYM_STRING: // VT_BSTR was handled above, but VariantToToken coerces unhandled types to strings.
753 if (token.mem_to_free)
754 aArg.AcceptNewMem(token.mem_to_free, token.marker_length);
755 else // Value was VT_EMPTY or VT_NULL, was coerced to an empty string, or malloc failed.
756 aArg.Assign();
757 break;
758 case SYM_OBJECT:
759 aArg.AssignSkipAddRef(token.object); // Let aArg take responsibility for it.
760 break;
761 default:
762 aArg.Assign(token);
763 break;
764 }
765 //token.Free(); // Above already took care of mem_to_free and object.
766}
767
768
769void TokenToVariant(ExprTokenType &aToken, VARIANT &aVar, TTVArgType *aVarIsArg)

Callers 2

InvokeMethod · 0.85
NextMethod · 0.85

Calls 5

VariantToTokenFunction · 0.85
AssignStringWMethod · 0.80
AcceptNewMemMethod · 0.80
AssignSkipAddRefMethod · 0.80
AssignMethod · 0.45

Tested by

no test coverage detected