MCPcopy Create free account
hub / github.com/Kitware/CMake / CallMacro

Method CallMacro

Source/cmCallVisualStudioMacro.cxx:399–463  ·  view source on GitHub ↗

Get all running objects from the Windows running object table. Save them in a map by their display names.

Source from the content-addressed store, hash-verified

397//! Get all running objects from the Windows running object table.
398//! Save them in a map by their display names.
399int cmCallVisualStudioMacro::CallMacro(std::string const& slnFile,
400 std::string const& macro,
401 std::string const& args,
402 bool const logErrorsAsMessages)
403{
404 int err = 1; // no comdef.h
405
406 LogErrorsAsMessages = logErrorsAsMessages;
407
408#if defined(HAVE_COMDEF_H)
409 err = 2; // error initializing
410
411 HRESULT hr = CoInitialize(0);
412 ReportHRESULT(hr, "CoInitialize");
413
414 if (SUCCEEDED(hr)) {
415 std::vector<IDispatchPtr> instances;
416 hr = FindVisualStudioInstances(slnFile, instances);
417 ReportHRESULT(hr, "FindVisualStudioInstances");
418
419 if (SUCCEEDED(hr)) {
420 err = 0; // no error
421
422 std::vector<IDispatchPtr>::iterator it;
423 for (it = instances.begin(); it != instances.end(); ++it) {
424 hr = InstanceCallMacro(*it, macro, args);
425 ReportHRESULT(hr, "InstanceCallMacro");
426
427 if (FAILED(hr)) {
428 err = 3; // error attempting to call the macro
429 }
430 }
431
432 if (instances.empty()) {
433 // no instances to call
434
435 // cmSystemTools::Message(
436 // "cmCallVisualStudioMacro::CallMacro no instances found to call",
437 // "Warning");
438 }
439 }
440
441 // Force release all COM pointers before CoUninitialize:
442 instances.clear();
443
444 CoUninitialize();
445 }
446#else
447 (void)slnFile;
448 (void)macro;
449 (void)args;
450 if (LogErrorsAsMessages) {
451 cmSystemTools::Message("cmCallVisualStudioMacro::CallMacro is not "
452 "supported on this platform");
453 }
454#endif
455
456 if (err && LogErrorsAsMessages) {

Callers

nothing calls this directly

Calls 8

InstanceCallMacroFunction · 0.85
MessageClass · 0.85
strMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected