diff --git a/ctreemanifest/manifest.h b/ctreemanifest/manifest.h --- a/ctreemanifest/manifest.h +++ b/ctreemanifest/manifest.h @@ -15,43 +15,19 @@ #include #include "clib/convert.h" +#include "cstore/store.h" +#include "ctreemanifest/manifest_entry.h" +#include "ctreemanifest/manifest_ptr.h" -class Manifest; class ManifestIterator; class SortedManifestIterator; -class ManifestPtr { - private: - Manifest *manifest; - public: - ManifestPtr(); - - ManifestPtr(Manifest *manifest); - - ManifestPtr(const ManifestPtr &other); - - ~ManifestPtr(); - - ManifestPtr& operator= (const ManifestPtr& other); - - operator Manifest* () const; - - Manifest *operator-> (); - - bool isnull() const; -}; - enum FindResultType { RESULT_FILE, RESULT_DIRECTORY, RESULT_FILE_OR_DIRECTORY, }; -class ManifestEntry; - -#include "cstore/store.h" -#include "ctreemanifest/manifest_entry.h" - /** * This class represents a view on a particular Manifest instance. It provides * access to the list of files/directories at one level of the tree, not the diff --git a/ctreemanifest/manifest.cpp b/ctreemanifest/manifest.cpp --- a/ctreemanifest/manifest.cpp +++ b/ctreemanifest/manifest.cpp @@ -247,54 +247,6 @@ fbhg_sha1_final((unsigned char*)result, &ctx); } -ManifestPtr::ManifestPtr() : - manifest(NULL) { -} - -ManifestPtr::ManifestPtr(Manifest *manifest) : - manifest(manifest) { - if (!manifest) { - throw std::logic_error("passed NULL manifest pointer"); - } - this->manifest->incref(); -} - -ManifestPtr::ManifestPtr(const ManifestPtr &other) : - manifest(other.manifest) { - if (this->manifest) { - this->manifest->incref(); - } -} - -ManifestPtr::~ManifestPtr() { - if (this->manifest && this->manifest->decref() == 0) { - delete(this->manifest); - } -} - -ManifestPtr& ManifestPtr::operator= (const ManifestPtr& other) { - if (this->manifest) { - this->manifest->decref(); - } - this->manifest = other.manifest; - if (this->manifest) { - this->manifest->incref(); - } - return *this; -} - -ManifestPtr::operator Manifest* () const { - return this->manifest; -} - -Manifest *ManifestPtr::operator-> () { - return this->manifest; -} - -bool ManifestPtr::isnull() const { - return this->manifest == NULL; -} - void Manifest::incref() { this->_refcount++; } diff --git a/ctreemanifest/manifest_entry.h b/ctreemanifest/manifest_entry.h --- a/ctreemanifest/manifest_entry.h +++ b/ctreemanifest/manifest_entry.h @@ -15,8 +15,8 @@ #include #include "clib/convert.h" -#include "ctreemanifest/manifest.h" #include "ctreemanifest/manifest_fetcher.h" +#include "ctreemanifest/manifest_ptr.h" #define MANIFEST_DIRECTORY_FLAG 't' #define MANIFEST_DIRECTORY_FLAGPTR (&"t"[0]) diff --git a/ctreemanifest/manifest_entry.cpp b/ctreemanifest/manifest_entry.cpp --- a/ctreemanifest/manifest_entry.cpp +++ b/ctreemanifest/manifest_entry.cpp @@ -11,6 +11,8 @@ #include +#include "ctreemanifest/manifest.h" + ManifestEntry::ManifestEntry() : filename(NULL), filenamelen(0), node(NULL), flag(NULL), ownedmemory(NULL) {} diff --git a/ctreemanifest/manifest_fetcher.h b/ctreemanifest/manifest_fetcher.h --- a/ctreemanifest/manifest_fetcher.h +++ b/ctreemanifest/manifest_fetcher.h @@ -13,10 +13,8 @@ #include #include -class ManifestFetcher; - #include "cstore/store.h" -#include "ctreemanifest/manifest.h" +#include "ctreemanifest/manifest_ptr.h" /** * Class used to obtain Manifests, given a path and node. diff --git a/ctreemanifest/manifest_fetcher.cpp b/ctreemanifest/manifest_fetcher.cpp --- a/ctreemanifest/manifest_fetcher.cpp +++ b/ctreemanifest/manifest_fetcher.cpp @@ -9,6 +9,8 @@ #include "ctreemanifest/manifest_fetcher.h" +#include "ctreemanifest/manifest.h" + ManifestFetcher::ManifestFetcher(std::shared_ptr store) : _store(store) { } diff --git a/ctreemanifest/manifest_ptr.h b/ctreemanifest/manifest_ptr.h new file mode 100644 --- /dev/null +++ b/ctreemanifest/manifest_ptr.h @@ -0,0 +1,35 @@ +// Copyright (c) 2004-present, Facebook, Inc. +// All Rights Reserved. +// +// This software may be used and distributed according to the terms of the +// GNU General Public License version 2 or any later version. + +// no-check-code + +#ifndef FBHGEXT_CTREEMANIFEST_MANIFEST_PTR_H +#define FBHGEXT_CTREEMANIFEST_MANIFEST_PTR_H + +class Manifest; + +class ManifestPtr { + private: + Manifest *manifest; + public: + ManifestPtr(); + + ManifestPtr(Manifest *manifest); + + ManifestPtr(const ManifestPtr &other); + + ~ManifestPtr(); + + ManifestPtr& operator= (const ManifestPtr& other); + + operator Manifest* () const; + + Manifest *operator-> (); + + bool isnull() const; +}; + +#endif /* FBHGEXT_CTREEMANIFEST_MANIFEST_PTR_H */ diff --git a/ctreemanifest/manifest_ptr.cpp b/ctreemanifest/manifest_ptr.cpp new file mode 100644 --- /dev/null +++ b/ctreemanifest/manifest_ptr.cpp @@ -0,0 +1,62 @@ +// Copyright (c) 2004-present, Facebook, Inc. +// All Rights Reserved. +// +// This software may be used and distributed according to the terms of the +// GNU General Public License version 2 or any later version. + +// no-check-code + +#include "ctreemanifest/manifest_ptr.h" + +#include +#include + +#include "ctreemanifest/manifest.h" + +ManifestPtr::ManifestPtr() : + manifest(NULL) { +} + +ManifestPtr::ManifestPtr(Manifest *manifest) : + manifest(manifest) { + if (!manifest) { + throw std::logic_error("passed NULL manifest pointer"); + } + this->manifest->incref(); +} + +ManifestPtr::ManifestPtr(const ManifestPtr &other) : + manifest(other.manifest) { + if (this->manifest) { + this->manifest->incref(); + } +} + +ManifestPtr::~ManifestPtr() { + if (this->manifest && this->manifest->decref() == 0) { + delete(this->manifest); + } +} + +ManifestPtr& ManifestPtr::operator= (const ManifestPtr& other) { + if (this->manifest) { + this->manifest->decref(); + } + this->manifest = other.manifest; + if (this->manifest) { + this->manifest->incref(); + } + return *this; +} + +ManifestPtr::operator Manifest* () const { + return this->manifest; +} + +Manifest *ManifestPtr::operator-> () { + return this->manifest; +} + +bool ManifestPtr::isnull() const { + return this->manifest == NULL; +} diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -245,6 +245,7 @@ 'ctreemanifest/manifest.cpp', 'ctreemanifest/manifest_entry.cpp', 'ctreemanifest/manifest_fetcher.cpp', + 'ctreemanifest/manifest_ptr.cpp', 'ctreemanifest/treemanifest.cpp', ], include_dirs=[ diff --git a/tests/test-check-code-hg.t b/tests/test-check-code-hg.t --- a/tests/test-check-code-hg.t +++ b/tests/test-check-code-hg.t @@ -78,6 +78,8 @@ Skipping ctreemanifest/manifest_entry.h it has no-che?k-code (glob) Skipping ctreemanifest/manifest_fetcher.cpp it has no-che?k-code (glob) Skipping ctreemanifest/manifest_fetcher.h it has no-che?k-code (glob) + Skipping ctreemanifest/manifest_ptr.cpp it has no-che?k-code (glob) + Skipping ctreemanifest/manifest_ptr.h it has no-che?k-code (glob) Skipping ctreemanifest/treemanifest.cpp it has no-che?k-code (glob) Skipping ctreemanifest/treemanifest.h it has no-che?k-code (glob) Skipping tests/conduithttp.py it has no-che?k-code (glob)