Bug 760995 - Move Scoped.h into the mozilla namespace. r=sparky
authorJeff Walden <jwalden@mit.edu>
Mon, 11 Jun 2012 16:16:47 -0700
changeset 102044 b3067d05a76a2bc8c3f5f4fb1bb30464a2c6a0fa
parent 102043 79f9a61a1e435a936b2d7196e081906601b5ff1d
child 102045 617cb36ead5971a182c09298ea2d457aeaf3fd9f
push id1316
push userakeybl@mozilla.com
push dateMon, 27 Aug 2012 22:37:00 +0000
treeherdermozilla-beta@db4b09302ee2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssparky
bugs760995
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 760995 - Move Scoped.h into the mozilla namespace. r=sparky
mfbt/Scoped.h
--- a/mfbt/Scoped.h
+++ b/mfbt/Scoped.h
@@ -30,33 +30,35 @@
  * // ... In this scope, |foo| is defined. Use |foo.get()| or |foo.rwget()|
  *        to access the value.
  * // ... In case of |return| or |throw|, |foo| is deallocated automatically.
  * // ... If |foo| needs to be returned or stored, use |foo.forget()|
  *
  * Note that the RAII classes defined in this header do _not_ perform any form
  * of reference-counting or garbage-collection. These classes have exactly two
  * behaviors:
+ *
  * - if |forget()| has not been called, the resource is always deallocated at
  *   the end of the scope;
  * - if |forget()| has been called, any control on the resource is unbound
  *   and the resource is not deallocated by the class.
  *
- *
  * Extension:
  *
  * In addition, this header provides class |Scoped| and macro |SCOPED_TEMPLATE|
  * to simplify the definition of RAII classes for other scenarios. These macros
  * have been used to automatically close file descriptors/file handles when
  * reaching the end of the scope, graphics contexts, etc.
  */
 
 #include "mozilla/Attributes.h"
 #include "mozilla/GuardObjects.h"
 
+namespace mozilla {
+
 /*
  * Scoped is a helper to create RAII wrappers
  * Type argument |Traits| is expected to have the following structure:
  *
  *   struct Traits {
  *     // Define the type of the value stored in the wrapper
  *     typedef value_type type;
  *     // Returns the value corresponding to the uninitialized or freed state
@@ -154,19 +156,19 @@ class Scoped
  * This allows to implement templates such as ScopedFreePtr.
  *
  * @param name The name of the class to define.
  * @param Traits A struct implementing clean-up. See the implementations
  * for more details.
  */
 #define SCOPED_TEMPLATE(name, Traits)                          \
 template<typename Type>                                        \
-struct name : public Scoped<Traits<Type> >                     \
+struct name : public mozilla::Scoped<Traits<Type> >            \
 {                                                              \
-    typedef Scoped<Traits<Type> > Super;                       \
+    typedef mozilla::Scoped<Traits<Type> > Super;              \
     typedef typename Super::Resource Resource;                 \
     name& operator=(Resource ptr) {                            \
       Super::operator=(ptr);                                   \
       return *this;                                            \
     }                                                          \
     explicit name(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM)        \
       : Super(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT)  \
     {}                                                         \
@@ -216,9 +218,11 @@ SCOPED_TEMPLATE(ScopedDeletePtr, ScopedD
  */
 template<typename T>
 struct ScopedDeleteArrayTraits : public ScopedFreePtrTraits<T>
 {
     static void release(T* ptr) { delete [] ptr; }
 };
 SCOPED_TEMPLATE(ScopedDeleteArray, ScopedDeleteArrayTraits)
 
+} /* namespace mozilla */
+
 #endif // mozilla_Scoped_h_