mirror of
https://github.com/OlafvdSpek/ctemplate.git
synced 2025-10-26 21:49:17 +08:00
A major build bug, discovered in
http://code.google.com/p/google-ctemplate/issues/detail?id=79 : The installed header files were #including header files that were not installed. The build could not function as a result. In one case I could resolve the problem by forward-declaring (better anyway). In another case, I just commented out all the relevant code for the opensource version. The code was for thread-safety analysis, which is a noop in opensource-land anyway, so it's pretty safe (albeit ugly) to remove it. R=ribrdb DELTA=48 (22 added, 4 deleted, 22 changed) Revision created by MOE tool push_codebase. MOE_MIGRATION=2768
This commit is contained in:
@@ -34,20 +34,17 @@
|
||||
#ifndef TEMPLATE_TEMPLATE_CACHE_H_
|
||||
#define TEMPLATE_TEMPLATE_CACHE_H_
|
||||
|
||||
#include "base/mutex.h" // Must go first to get _XOPEN_SOURCE (in opensource)
|
||||
#include @ac_cv_cxx_hash_map@ // for @ac_cv_cxx_hash_map_class@<>
|
||||
#include <string> // for string
|
||||
#include <utility> // for pair
|
||||
#include <vector> // for vector<>
|
||||
#include "base/thread_annotations.h" // for EXCLUSIVE_LOCKS_REQUIRED, etc
|
||||
#include <ctemplate/template_emitter.h> // for ExpandEmitter, etc
|
||||
#include <ctemplate/template_enums.h> // for Strip
|
||||
#include <ctemplate/template_string.h>
|
||||
#include <ctemplate/per_expand_data.h>
|
||||
|
||||
@ac_google_start_namespace@
|
||||
class FileStat;
|
||||
}
|
||||
@ac_google_end_namespace@
|
||||
class TemplateCacheUnittest;
|
||||
|
||||
@ac_windows_dllexport_defines@
|
||||
@@ -102,8 +99,7 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
// STRIP_WHITESPACE elides all blank lines, and also all whitespace
|
||||
// at either the beginning or end of a line. See template constructor
|
||||
// for more details.
|
||||
bool LoadTemplate(const TemplateString& filename, Strip strip)
|
||||
LOCKS_EXCLUDED(mutex_);
|
||||
bool LoadTemplate(const TemplateString& filename, Strip strip);
|
||||
|
||||
// Parses the string as a template file (e.g. "Hello {{WORLD}}"),
|
||||
// and inserts it into the parsed template cache, so it can later be
|
||||
@@ -118,7 +114,7 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
// the string-template.
|
||||
bool StringToTemplateCache(const TemplateString& key,
|
||||
const TemplateString& content,
|
||||
Strip strip) LOCKS_EXCLUDED(mutex_);
|
||||
Strip strip);
|
||||
bool StringToTemplateCache(const TemplateString& key,
|
||||
const char* content,
|
||||
size_t content_len,
|
||||
@@ -140,7 +136,7 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
bool ExpandWithData(const TemplateString& filename, Strip strip,
|
||||
const TemplateDictionaryInterface *dictionary,
|
||||
PerExpandData* per_expand_data,
|
||||
ExpandEmitter* output) LOCKS_EXCLUDED(mutex_);
|
||||
ExpandEmitter* output);
|
||||
bool ExpandWithData(const TemplateString& filename, Strip strip,
|
||||
const TemplateDictionaryInterface* dictionary,
|
||||
PerExpandData* per_expand_data,
|
||||
@@ -167,8 +163,7 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
bool ExpandNoLoad(const TemplateString& filename, Strip strip,
|
||||
const TemplateDictionaryInterface *dictionary,
|
||||
PerExpandData* per_expand_data,
|
||||
ExpandEmitter* output) const
|
||||
LOCKS_EXCLUDED(mutex_);
|
||||
ExpandEmitter* output) const;
|
||||
bool ExpandNoLoad(const TemplateString& filename, Strip strip,
|
||||
const TemplateDictionaryInterface* dictionary,
|
||||
PerExpandData* per_expand_data,
|
||||
@@ -212,13 +207,13 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
// the cache can no longer be modified by loading new templates or
|
||||
// reloading existing templates. During expansion only cached
|
||||
// included templates will be used, they won't be loaded on-demand.
|
||||
void Freeze() LOCKS_EXCLUDED(mutex_);
|
||||
void Freeze();
|
||||
|
||||
// Delete
|
||||
// Deletes one template object from the cache, if it exists.
|
||||
// This can be used for either file- or string-based templates.
|
||||
// Returns true if the object was deleted, false otherwise.
|
||||
bool Delete(const TemplateString& key) LOCKS_EXCLUDED(mutex_);
|
||||
bool Delete(const TemplateString& key);
|
||||
|
||||
// ClearCache
|
||||
// Deletes all the template objects in the cache and all raw
|
||||
@@ -229,7 +224,7 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
// this one.) Note: this method is not necessary unless you are
|
||||
// testing for memory leaks. Calling this before exiting the
|
||||
// program will prevent unnecessary reporting in that case.
|
||||
void ClearCache() LOCKS_EXCLUDED(mutex_);
|
||||
void ClearCache();
|
||||
|
||||
// ReloadAllIfChanged
|
||||
// If IMMEDIATE_RELOAD, reloads and parses all templates right away,
|
||||
@@ -250,7 +245,7 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
// earlier search-path. The file will only be reloaded if the orginal file
|
||||
// is updated (touched, updated, deleted etc). See .cc file for more detail.
|
||||
enum ReloadType { LAZY_RELOAD, IMMEDIATE_RELOAD };
|
||||
void ReloadAllIfChanged(ReloadType reload_tyle) LOCKS_EXCLUDED(mutex_);
|
||||
void ReloadAllIfChanged(ReloadType reload_tyle);
|
||||
|
||||
// Clone
|
||||
// Returns a copy of the cache. It makes a shallow copy of the
|
||||
@@ -260,8 +255,7 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
// a TemplateCache instance local to the method, but we
|
||||
// know that no other threads will have access to the
|
||||
// instance, so ignore thread safety errors.
|
||||
TemplateCache* Clone() const LOCKS_EXCLUDED(mutex_)
|
||||
NO_THREAD_SAFETY_ANALYSIS;
|
||||
TemplateCache* Clone() const;
|
||||
|
||||
// ---- INSPECTING THE CACHE -------
|
||||
// Dump
|
||||
@@ -293,8 +287,7 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
// GetTemplate
|
||||
// This method is deprecated. It exists here because it is called by
|
||||
// Template::GetTemplate. Also this is used in tests.
|
||||
const Template* GetTemplate(const TemplateString& key, Strip strip)
|
||||
LOCKS_EXCLUDED(mutex_);
|
||||
const Template* GetTemplate(const TemplateString& key, Strip strip);
|
||||
|
||||
bool ResolveTemplateFilename(const std::string& unresolved,
|
||||
std::string* resolved,
|
||||
@@ -307,11 +300,11 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
bool ExpandLocked(const TemplateString& filename, Strip strip,
|
||||
ExpandEmitter* output,
|
||||
const TemplateDictionaryInterface *dictionary,
|
||||
PerExpandData* per_expand_data) LOCKS_EXCLUDED(mutex_);
|
||||
PerExpandData* per_expand_data);
|
||||
|
||||
bool AddAlternateTemplateRootDirectoryHelper(
|
||||
const std::string& directory,
|
||||
bool clear_template_search_path) LOCKS_EXCLUDED(search_path_mutex_);
|
||||
bool clear_template_search_path);
|
||||
|
||||
// DoneWithGetTemplatePtrs
|
||||
// For historical reasons, GetTemplate() returns a raw Template
|
||||
@@ -324,7 +317,7 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
// GetTemplate). Most likely, the user will call this indirectly,
|
||||
// via ClearCache().
|
||||
// TODO(panicker): Consider making this method public.
|
||||
void DoneWithGetTemplatePtrs() LOCKS_EXCLUDED(mutex_);
|
||||
void DoneWithGetTemplatePtrs();
|
||||
|
||||
// ValidTemplateFilename
|
||||
// Validates the user provided filename before constructing the template
|
||||
@@ -340,8 +333,7 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
RefcountedTemplate* GetTemplateLocked(
|
||||
const TemplateString& filename,
|
||||
Strip strip,
|
||||
const TemplateCacheKey& key)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
const TemplateCacheKey& key);
|
||||
|
||||
// Refcount
|
||||
// Testing only. Returns the refcount of a template, given its cache key.
|
||||
@@ -351,9 +343,9 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
// Debug only. Returns whether the cache key is in the parsed cache.
|
||||
bool TemplateIsCached(const TemplateCacheKey template_cache_key) const;
|
||||
|
||||
TemplateMap* parsed_template_cache_ GUARDED_BY(mutex_);
|
||||
bool is_frozen_ GUARDED_BY(mutex_);
|
||||
TemplateSearchPath search_path_ GUARDED_BY(search_path_mutex_);
|
||||
TemplateMap* parsed_template_cache_;
|
||||
bool is_frozen_;
|
||||
TemplateSearchPath search_path_;
|
||||
|
||||
// Since GetTemplate() returns a raw pointer, it's impossible for
|
||||
// the caller to call DecRef() on the returned template when it's
|
||||
@@ -361,7 +353,7 @@ class @ac_windows_dllexport@ TemplateCache {
|
||||
// GetTemplate in this data structure. Then the user can call
|
||||
// DecRef() on all of them at once, via a DoneWithGetTemplatePtrs()
|
||||
// (which they will probably get at via a call to ClearCache()).
|
||||
TemplateCallMap* get_template_calls_ GUARDED_BY(mutex_);
|
||||
TemplateCallMap* get_template_calls_;
|
||||
|
||||
mutable class Mutex* mutex_;
|
||||
mutable class Mutex* search_path_mutex_;
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/arena-inl.h" // for ArenaAllocator
|
||||
#include <ctemplate/template_dictionary_interface.h>
|
||||
#include <ctemplate/template_modifiers.h>
|
||||
#include <ctemplate/template_string.h>
|
||||
@@ -63,6 +62,7 @@
|
||||
@ac_windows_dllexport_defines@
|
||||
|
||||
@ac_google_start_namespace@
|
||||
template <class T, class C> class ArenaAllocator;
|
||||
class UnsafeArena;
|
||||
template<typename A, int B, typename C, typename D> class small_map;
|
||||
template<typename NormalMap> class small_map_default_init; // in small_map.h
|
||||
|
||||
@@ -66,6 +66,8 @@
|
||||
#include <ctemplate/template_enums.h> // for Strip
|
||||
#include <ctemplate/template_namelist.h> // for TemplateNamelist, etc
|
||||
#include <ctemplate/template_pathops.h> // for PathJoin()
|
||||
#include "base/util.h" // for down_cast()
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
|
||||
@@ -34,17 +34,14 @@
|
||||
#ifndef TEMPLATE_TEMPLATE_CACHE_H_
|
||||
#define TEMPLATE_TEMPLATE_CACHE_H_
|
||||
|
||||
#include "base/mutex.h" // Must go first to get _XOPEN_SOURCE (in opensource)
|
||||
#include <hash_map> // for stdext::hash_map<>
|
||||
#include <string> // for string
|
||||
#include <utility> // for pair
|
||||
#include <vector> // for vector<>
|
||||
#include "base/thread_annotations.h" // for EXCLUSIVE_LOCKS_REQUIRED, etc
|
||||
#include <ctemplate/template_emitter.h> // for ExpandEmitter, etc
|
||||
#include <ctemplate/template_enums.h> // for Strip
|
||||
#include <ctemplate/template_string.h>
|
||||
#include <ctemplate/per_expand_data.h>
|
||||
|
||||
namespace ctemplate {
|
||||
class FileStat;
|
||||
}
|
||||
@@ -112,8 +109,7 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
// STRIP_WHITESPACE elides all blank lines, and also all whitespace
|
||||
// at either the beginning or end of a line. See template constructor
|
||||
// for more details.
|
||||
bool LoadTemplate(const TemplateString& filename, Strip strip)
|
||||
LOCKS_EXCLUDED(mutex_);
|
||||
bool LoadTemplate(const TemplateString& filename, Strip strip);
|
||||
|
||||
// Parses the string as a template file (e.g. "Hello {{WORLD}}"),
|
||||
// and inserts it into the parsed template cache, so it can later be
|
||||
@@ -128,7 +124,7 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
// the string-template.
|
||||
bool StringToTemplateCache(const TemplateString& key,
|
||||
const TemplateString& content,
|
||||
Strip strip) LOCKS_EXCLUDED(mutex_);
|
||||
Strip strip);
|
||||
bool StringToTemplateCache(const TemplateString& key,
|
||||
const char* content,
|
||||
size_t content_len,
|
||||
@@ -150,7 +146,7 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
bool ExpandWithData(const TemplateString& filename, Strip strip,
|
||||
const TemplateDictionaryInterface *dictionary,
|
||||
PerExpandData* per_expand_data,
|
||||
ExpandEmitter* output) LOCKS_EXCLUDED(mutex_);
|
||||
ExpandEmitter* output);
|
||||
bool ExpandWithData(const TemplateString& filename, Strip strip,
|
||||
const TemplateDictionaryInterface* dictionary,
|
||||
PerExpandData* per_expand_data,
|
||||
@@ -177,8 +173,7 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
bool ExpandNoLoad(const TemplateString& filename, Strip strip,
|
||||
const TemplateDictionaryInterface *dictionary,
|
||||
PerExpandData* per_expand_data,
|
||||
ExpandEmitter* output) const
|
||||
LOCKS_EXCLUDED(mutex_);
|
||||
ExpandEmitter* output) const;
|
||||
bool ExpandNoLoad(const TemplateString& filename, Strip strip,
|
||||
const TemplateDictionaryInterface* dictionary,
|
||||
PerExpandData* per_expand_data,
|
||||
@@ -222,13 +217,13 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
// the cache can no longer be modified by loading new templates or
|
||||
// reloading existing templates. During expansion only cached
|
||||
// included templates will be used, they won't be loaded on-demand.
|
||||
void Freeze() LOCKS_EXCLUDED(mutex_);
|
||||
void Freeze();
|
||||
|
||||
// Delete
|
||||
// Deletes one template object from the cache, if it exists.
|
||||
// This can be used for either file- or string-based templates.
|
||||
// Returns true if the object was deleted, false otherwise.
|
||||
bool Delete(const TemplateString& key) LOCKS_EXCLUDED(mutex_);
|
||||
bool Delete(const TemplateString& key);
|
||||
|
||||
// ClearCache
|
||||
// Deletes all the template objects in the cache and all raw
|
||||
@@ -239,7 +234,7 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
// this one.) Note: this method is not necessary unless you are
|
||||
// testing for memory leaks. Calling this before exiting the
|
||||
// program will prevent unnecessary reporting in that case.
|
||||
void ClearCache() LOCKS_EXCLUDED(mutex_);
|
||||
void ClearCache();
|
||||
|
||||
// ReloadAllIfChanged
|
||||
// If IMMEDIATE_RELOAD, reloads and parses all templates right away,
|
||||
@@ -260,7 +255,7 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
// earlier search-path. The file will only be reloaded if the orginal file
|
||||
// is updated (touched, updated, deleted etc). See .cc file for more detail.
|
||||
enum ReloadType { LAZY_RELOAD, IMMEDIATE_RELOAD };
|
||||
void ReloadAllIfChanged(ReloadType reload_tyle) LOCKS_EXCLUDED(mutex_);
|
||||
void ReloadAllIfChanged(ReloadType reload_tyle);
|
||||
|
||||
// Clone
|
||||
// Returns a copy of the cache. It makes a shallow copy of the
|
||||
@@ -270,8 +265,7 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
// a TemplateCache instance local to the method, but we
|
||||
// know that no other threads will have access to the
|
||||
// instance, so ignore thread safety errors.
|
||||
TemplateCache* Clone() const LOCKS_EXCLUDED(mutex_)
|
||||
NO_THREAD_SAFETY_ANALYSIS;
|
||||
TemplateCache* Clone() const;
|
||||
|
||||
// ---- INSPECTING THE CACHE -------
|
||||
// Dump
|
||||
@@ -303,8 +297,7 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
// GetTemplate
|
||||
// This method is deprecated. It exists here because it is called by
|
||||
// Template::GetTemplate. Also this is used in tests.
|
||||
const Template* GetTemplate(const TemplateString& key, Strip strip)
|
||||
LOCKS_EXCLUDED(mutex_);
|
||||
const Template* GetTemplate(const TemplateString& key, Strip strip);
|
||||
|
||||
bool ResolveTemplateFilename(const std::string& unresolved,
|
||||
std::string* resolved,
|
||||
@@ -317,11 +310,11 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
bool ExpandLocked(const TemplateString& filename, Strip strip,
|
||||
ExpandEmitter* output,
|
||||
const TemplateDictionaryInterface *dictionary,
|
||||
PerExpandData* per_expand_data) LOCKS_EXCLUDED(mutex_);
|
||||
PerExpandData* per_expand_data);
|
||||
|
||||
bool AddAlternateTemplateRootDirectoryHelper(
|
||||
const std::string& directory,
|
||||
bool clear_template_search_path) LOCKS_EXCLUDED(search_path_mutex_);
|
||||
bool clear_template_search_path);
|
||||
|
||||
// DoneWithGetTemplatePtrs
|
||||
// For historical reasons, GetTemplate() returns a raw Template
|
||||
@@ -334,7 +327,7 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
// GetTemplate). Most likely, the user will call this indirectly,
|
||||
// via ClearCache().
|
||||
// TODO(panicker): Consider making this method public.
|
||||
void DoneWithGetTemplatePtrs() LOCKS_EXCLUDED(mutex_);
|
||||
void DoneWithGetTemplatePtrs();
|
||||
|
||||
// ValidTemplateFilename
|
||||
// Validates the user provided filename before constructing the template
|
||||
@@ -350,8 +343,7 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
RefcountedTemplate* GetTemplateLocked(
|
||||
const TemplateString& filename,
|
||||
Strip strip,
|
||||
const TemplateCacheKey& key)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
const TemplateCacheKey& key);
|
||||
|
||||
// Refcount
|
||||
// Testing only. Returns the refcount of a template, given its cache key.
|
||||
@@ -361,9 +353,9 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
// Debug only. Returns whether the cache key is in the parsed cache.
|
||||
bool TemplateIsCached(const TemplateCacheKey template_cache_key) const;
|
||||
|
||||
TemplateMap* parsed_template_cache_ GUARDED_BY(mutex_);
|
||||
bool is_frozen_ GUARDED_BY(mutex_);
|
||||
TemplateSearchPath search_path_ GUARDED_BY(search_path_mutex_);
|
||||
TemplateMap* parsed_template_cache_;
|
||||
bool is_frozen_;
|
||||
TemplateSearchPath search_path_;
|
||||
|
||||
// Since GetTemplate() returns a raw pointer, it's impossible for
|
||||
// the caller to call DecRef() on the returned template when it's
|
||||
@@ -371,7 +363,7 @@ class CTEMPLATE_DLL_DECL TemplateCache {
|
||||
// GetTemplate in this data structure. Then the user can call
|
||||
// DecRef() on all of them at once, via a DoneWithGetTemplatePtrs()
|
||||
// (which they will probably get at via a call to ClearCache()).
|
||||
TemplateCallMap* get_template_calls_ GUARDED_BY(mutex_);
|
||||
TemplateCallMap* get_template_calls_;
|
||||
|
||||
mutable class Mutex* mutex_;
|
||||
mutable class Mutex* search_path_mutex_;
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/arena-inl.h" // for ArenaAllocator
|
||||
#include <ctemplate/template_dictionary_interface.h>
|
||||
#include <ctemplate/template_modifiers.h>
|
||||
#include <ctemplate/template_string.h>
|
||||
@@ -68,6 +67,7 @@
|
||||
#endif
|
||||
|
||||
namespace ctemplate {
|
||||
template <class T, class C> class ArenaAllocator;
|
||||
class UnsafeArena;
|
||||
template<typename A, int B, typename C, typename D> class small_map;
|
||||
template<typename NormalMap> class small_map_default_init; // in small_map.h
|
||||
|
||||
Reference in New Issue
Block a user