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 102099 14b79d264b0b07db0511469b81988940aaead90a
parent 102098 a7fce1dd2b5853df71b7e511dbf4a2bf1c4aabb8
child 102100 4b8385bcfc2025aaf68f32f48aa9be5ef4893772
push idunknown
push userunknown
push dateunknown
reviewerssparky
bugs760995
milestone16.0a1
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_