[Cmake-commits] [cmake-commits] king committed cmMakefile.cxx 1.497 1.498 cmMakefile.h 1.247 1.248
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Jan 22 10:56:53 EST 2009
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv22618/Source
Modified Files:
cmMakefile.cxx cmMakefile.h
Log Message:
ENH: Create automatic policy push/pop helper
This creates cmMakefile::PolicyPushPop to push and pop policy scope
automatically. It also enforces balanced push/pop pairs inside the
scope it handles.
Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.247
retrieving revision 1.248
diff -C 2 -d -r1.247 -r1.248
*** cmMakefile.h 22 Jan 2009 15:56:39 -0000 1.247
--- cmMakefile.h 22 Jan 2009 15:56:50 -0000 1.248
***************
*** 347,350 ****
--- 347,362 ----
//@}
+ /** Helper class to push and pop policies automatically. */
+ class PolicyPushPop
+ {
+ public:
+ PolicyPushPop(cmMakefile* m);
+ ~PolicyPushPop();
+ private:
+ cmMakefile* Makefile;
+ size_t PolicyDepth;
+ };
+ friend class PolicyPushPop;
+
/**
* Get the Policies Instance
Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.497
retrieving revision 1.498
diff -C 2 -d -r1.497 -r1.498
*** cmMakefile.cxx 22 Jan 2009 15:56:39 -0000 1.497
--- cmMakefile.cxx 22 Jan 2009 15:56:49 -0000 1.498
***************
*** 3675,3678 ****
--- 3675,3707 ----
}
+ //----------------------------------------------------------------------------
+ cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m): Makefile(m)
+ {
+ this->Makefile->PushPolicy();
+ this->PolicyDepth = this->Makefile->PolicyStack.size();
+ }
+
+ //----------------------------------------------------------------------------
+ cmMakefile::PolicyPushPop::~PolicyPushPop()
+ {
+ // Enforce matching PUSH/POP pairs.
+ if(this->Makefile->PolicyStack.size() < this->PolicyDepth)
+ {
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ "cmake_policy POP without matching PUSH");
+ return;
+ }
+ while(this->Makefile->PolicyStack.size() > this->PolicyDepth)
+ {
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ "cmake_policy PUSH without matching POP");
+ this->Makefile->PopPolicy(false);
+ }
+
+ // Pop our scope.
+ this->Makefile->PopPolicy();
+ }
+
+ //----------------------------------------------------------------------------
bool cmMakefile::PushPolicy()
{
More information about the Cmake-commits
mailing list