Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Daniel Pfeifer
CMake
Commits
1226f967
Commit
1226f967
authored
Jan 06, 2017
by
Daniel Pfeifer
Browse files
cmVariableWatchCommand: Port away from FinalPass
parent
49b053a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Source/cmVariableWatchCommand.cxx
View file @
1226f967
...
...
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmVariableWatchCommand.h"
#include <memory>
#include <sstream>
#include "cmExecutionStatus.h"
...
...
@@ -85,19 +86,39 @@ static void deleteVariableWatchCallbackData(void* client_data)
delete
data
;
}
cmVariableWatchCommand
::
cmVariableWatchCommand
()
/** This command does not really have a final pass but it needs to
stay alive since it owns variable watch callback information. */
class
FinalAction
{
}
cmVariableWatchCommand
::~
cmVariableWatchCommand
()
{
std
::
set
<
std
::
string
>::
const_iterator
it
;
for
(
it
=
this
->
WatchedVariables
.
begin
();
it
!=
this
->
WatchedVariables
.
end
();
++
it
)
{
this
->
Makefile
->
GetCMakeInstance
()
->
GetVariableWatch
()
->
RemoveWatch
(
*
it
,
cmVariableWatchCommandVariableAccessed
);
public:
FinalAction
(
cmMakefile
*
makefile
,
std
::
string
const
&
variable
)
:
Action
(
cm
::
make_shared
<
Impl
>
(
makefile
,
variable
))
{
}
}
void
operator
()(
cmMakefile
&
)
const
{}
private:
struct
Impl
{
Impl
(
cmMakefile
*
makefile
,
std
::
string
const
&
variable
)
:
Makefile
(
makefile
)
,
Variable
(
variable
)
{
}
~
Impl
()
{
this
->
Makefile
->
GetCMakeInstance
()
->
GetVariableWatch
()
->
RemoveWatch
(
this
->
Variable
,
cmVariableWatchCommandVariableAccessed
);
}
cmMakefile
*
Makefile
;
std
::
string
Variable
;
};
std
::
shared_ptr
<
Impl
const
>
Action
;
};
bool
cmVariableWatchCommand
::
InitialPass
(
std
::
vector
<
std
::
string
>
const
&
args
,
cmExecutionStatus
&
)
...
...
@@ -123,7 +144,6 @@ bool cmVariableWatchCommand::InitialPass(std::vector<std::string> const& args,
data
->
InCallback
=
false
;
data
->
Command
=
command
;
this
->
WatchedVariables
.
insert
(
variable
);
if
(
!
this
->
Makefile
->
GetCMakeInstance
()
->
GetVariableWatch
()
->
AddWatch
(
variable
,
cmVariableWatchCommandVariableAccessed
,
data
,
deleteVariableWatchCallbackData
))
{
...
...
@@ -131,5 +151,6 @@ bool cmVariableWatchCommand::InitialPass(std::vector<std::string> const& args,
return
false
;
}
this
->
Makefile
->
AddFinalAction
(
FinalAction
(
this
->
Makefile
,
variable
));
return
true
;
}
Source/cmVariableWatchCommand.h
View file @
1226f967
...
...
@@ -25,25 +25,12 @@ public:
*/
cmCommand
*
Clone
()
CM_OVERRIDE
{
return
new
cmVariableWatchCommand
;
}
//! Default constructor
cmVariableWatchCommand
();
//! Destructor.
~
cmVariableWatchCommand
()
CM_OVERRIDE
;
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
bool
InitialPass
(
std
::
vector
<
std
::
string
>
const
&
args
,
cmExecutionStatus
&
status
)
CM_OVERRIDE
;
/** This command does not really have a final pass but it needs to
stay alive since it owns variable watch callback information. */
bool
HasFinalPass
()
const
CM_OVERRIDE
{
return
true
;
}
protected:
std
::
set
<
std
::
string
>
WatchedVariables
;
};
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment