Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
4.8 KiB

  1. // Copyright (c) 1999 Microsoft Corporation. All rights reserved.
  2. //
  3. // Functions that implement the automation interfaces for the DirectMusic constants.
  4. //
  5. #include "stdinc.h"
  6. #include "autconstants.h"
  7. #include "oleaut.h"
  8. struct AutConstantDef
  9. {
  10. DISPID dispid;
  11. const WCHAR *pwszName;
  12. LONG lVal;
  13. };
  14. // Performance
  15. const DISPID DMCONSTDISP_IsSecondary = 1;
  16. const DISPID DMCONSTDISP_IsControl = 2;
  17. const DISPID DMCONSTDISP_AtFinish = 3;
  18. const DISPID DMCONSTDISP_AtGrid = 4;
  19. const DISPID DMCONSTDISP_AtBeat = 5;
  20. const DISPID DMCONSTDISP_AtMeasure = 6;
  21. const DISPID DMCONSTDISP_AtMarker = 7;
  22. const DISPID DMCONSTDISP_AtImmediate = 8;
  23. const DISPID DMCONSTDISP_AlignToBar = 9;
  24. const DISPID DMCONSTDISP_AlignToBeat = 10;
  25. const DISPID DMCONSTDISP_AlignToSegment = 11;
  26. const DISPID DMCONSTDISP_PlayFill = 12;
  27. const DISPID DMCONSTDISP_PlayIntro = 13;
  28. const DISPID DMCONSTDISP_PlayBreak = 14;
  29. const DISPID DMCONSTDISP_PlayEnd = 15;
  30. const DISPID DMCONSTDISP_PlayEndAndIntro = 16;
  31. const DISPID DMCONSTDISP_PlayModulate = 17;
  32. const DISPID DMCONSTDISP_UseClockTime = 18;
  33. const DISPID DMCONSTDISP_NoCutoff = 19;
  34. const AutConstantDef gs_Constants[] =
  35. {
  36. { DMCONSTDISP_IsSecondary, L"IsSecondary", ScriptConstants::IsSecondary },
  37. { DMCONSTDISP_IsControl, L"IsControl", ScriptConstants::IsControl },
  38. { DMCONSTDISP_AtFinish, L"AtFinish", ScriptConstants::AtFinish },
  39. { DMCONSTDISP_AtGrid, L"AtGrid", ScriptConstants::AtGrid },
  40. { DMCONSTDISP_AtBeat, L"AtBeat", ScriptConstants::AtBeat },
  41. { DMCONSTDISP_AtMeasure, L"AtMeasure", ScriptConstants::AtMeasure },
  42. { DMCONSTDISP_AtMarker, L"AtMarker", ScriptConstants::AtMarker },
  43. { DMCONSTDISP_AtImmediate, L"AtImmediate", ScriptConstants::AtImmediate },
  44. { DMCONSTDISP_AlignToBar, L"AlignToBar", ScriptConstants::AlignToBar },
  45. { DMCONSTDISP_AlignToBeat, L"AlignToBeat", ScriptConstants::AlignToBeat },
  46. { DMCONSTDISP_AlignToSegment, L"AlignToSegment", ScriptConstants::AlignToSegment },
  47. { DMCONSTDISP_PlayFill, L"PlayFill", ScriptConstants::PlayFill },
  48. { DMCONSTDISP_PlayIntro, L"PlayIntro", ScriptConstants::PlayIntro },
  49. { DMCONSTDISP_PlayBreak, L"PlayBreak", ScriptConstants::PlayBreak },
  50. { DMCONSTDISP_PlayEnd, L"PlayEnd", ScriptConstants::PlayEnd },
  51. { DMCONSTDISP_PlayEndAndIntro, L"PlayEndAndIntro", ScriptConstants::PlayEndAndIntro },
  52. { DMCONSTDISP_PlayModulate, L"PlayModulate", ScriptConstants::PlayModulate },
  53. { DMCONSTDISP_NoCutoff, L"NoCutoff", ScriptConstants::NoCutoff },
  54. { DISPID_UNKNOWN }
  55. };
  56. HRESULT
  57. AutConstantsGetIDsOfNames(
  58. REFIID riid,
  59. LPOLESTR __RPC_FAR *rgszNames,
  60. UINT cNames,
  61. LCID lcid,
  62. DISPID __RPC_FAR *rgDispId)
  63. {
  64. V_INAME(AutConstantsGetIDsOfNames);
  65. V_BUFPTR_READ(rgszNames, sizeof(LPOLESTR) * cNames);
  66. V_BUFPTR_WRITE(rgDispId, sizeof(DISPID) * cNames);
  67. if (riid != IID_NULL)
  68. return DISP_E_UNKNOWNINTERFACE;
  69. if (cNames == 0)
  70. return S_OK;
  71. // Clear out dispid's
  72. for (UINT c = 0; c < cNames; ++c)
  73. {
  74. rgDispId[c] = DISPID_UNKNOWN;
  75. }
  76. // See if we have a method with the first name
  77. for (c = 0; gs_Constants[c].dispid != DISPID_UNKNOWN; ++c)
  78. {
  79. if (0 == _wcsicmp(rgszNames[0], gs_Constants[c].pwszName))
  80. {
  81. rgDispId[0] = gs_Constants[c].dispid;
  82. break;
  83. }
  84. }
  85. // Additional names requested (cNames > 1) are named parameters,
  86. // which isn't something we support.
  87. // Return DISP_E_UNKNOWNNAME in this case, and in the case that we didn't match
  88. // the first name.
  89. if (rgDispId[0] == DISPID_UNKNOWN || cNames > 1)
  90. return DISP_E_UNKNOWNNAME;
  91. return S_OK;
  92. }
  93. HRESULT AutConstantsInvoke(
  94. DISPID dispIdMember,
  95. REFIID riid,
  96. LCID lcid,
  97. WORD wFlags,
  98. DISPPARAMS __RPC_FAR *pDispParams,
  99. VARIANT __RPC_FAR *pVarResult,
  100. EXCEPINFO __RPC_FAR *pExcepInfo,
  101. UINT __RPC_FAR *puArgErr)
  102. {
  103. V_INAME(AutConstantsInvoke);
  104. V_PTR_READ(pDispParams, DISPPARAMS);
  105. V_PTR_WRITE_OPT(pVarResult, VARIANT);
  106. V_PTR_WRITE_OPT(pExcepInfo, EXCEPINFO);
  107. bool fUseOleAut = !!(riid == IID_NULL);
  108. // Additional parameter validation
  109. if (!fUseOleAut && riid != g_guidInvokeWithoutOleaut)
  110. return DISP_E_UNKNOWNINTERFACE;
  111. if (!(wFlags & DISPATCH_PROPERTYGET))
  112. return DISP_E_MEMBERNOTFOUND;
  113. if (pDispParams->cArgs > 0)
  114. return DISP_E_BADPARAMCOUNT;
  115. if (pDispParams->cNamedArgs > 0)
  116. return DISP_E_NONAMEDARGS;
  117. // Zero the out params
  118. if (puArgErr)
  119. *puArgErr = 0;
  120. if (pVarResult)
  121. {
  122. DMS_VariantInit(fUseOleAut, pVarResult);
  123. }
  124. // Find the constant
  125. for (const AutConstantDef *pConst = gs_Constants;
  126. pConst->dispid != DISPID_UNKNOWN && pConst->dispid != dispIdMember;
  127. ++pConst)
  128. {
  129. }
  130. if (pConst->dispid == DISPID_UNKNOWN)
  131. return DISP_E_MEMBERNOTFOUND;
  132. // Return the value value
  133. if (pVarResult)
  134. {
  135. pVarResult->vt = VT_I4;
  136. pVarResult->lVal = pConst->lVal;
  137. }
  138. return S_OK;
  139. }