1
0
mirror of https://github.com/OlafvdSpek/ctemplate.git synced 2025-09-28 19:05:49 +08:00

Preprocess

This commit is contained in:
Olaf van der Spek 2017-08-27 14:50:21 +02:00
parent 44b7c5b918
commit 91f5147cc7
5 changed files with 9 additions and 31 deletions

View File

@ -130,15 +130,10 @@ class CTEMPLATE_DLL_DECL PerExpandData {
} }
private: private:
#ifdef _MSC_VER
typedef std::unordered_map<const char*, const void*, StringHash> DataMap;
#else
struct DataEq { struct DataEq {
bool operator()(const char* s1, const char* s2) const; bool operator()(const char* s1, const char* s2) const;
}; };
typedef std::unordered_map<const char*, const void*, StringHash, DataEq> typedef std::unordered_map<const char*, const void*, StringHash, DataEq> DataMap;
DataMap;
#endif
const char* annotate_path_; const char* annotate_path_;
TemplateAnnotator* annotator_; TemplateAnnotator* annotator_;

View File

@ -34,7 +34,7 @@
#ifndef TEMPLATE_TEMPLATE_CACHE_H_ #ifndef TEMPLATE_TEMPLATE_CACHE_H_
#define TEMPLATE_TEMPLATE_CACHE_H_ #define TEMPLATE_TEMPLATE_CACHE_H_
#include <unordered_map> // for std::unordered_map<> #include <unordered_map>
#include <string> // for string #include <string> // for string
#include <utility> // for pair #include <utility> // for pair
#include <vector> // for vector<> #include <vector> // for vector<>
@ -288,8 +288,7 @@ class CTEMPLATE_DLL_DECL TemplateCache {
public: public:
typedef std::pair<TemplateId, int> TemplateCacheKey; typedef std::pair<TemplateId, int> TemplateCacheKey;
private: private:
typedef std::unordered_map<TemplateCacheKey, CachedTemplate, TemplateCacheHash> typedef std::unordered_map<TemplateCacheKey, CachedTemplate, TemplateCacheHash> TemplateMap;
TemplateMap;
typedef std::unordered_map<RefcountedTemplate*, int, RefTplPtrHash> TemplateCallMap; typedef std::unordered_map<RefcountedTemplate*, int, RefTplPtrHash> TemplateCallMap;
// Where to search for files. // Where to search for files.
typedef std::vector<std::string> TemplateSearchPath; typedef std::vector<std::string> TemplateSearchPath;

View File

@ -68,13 +68,11 @@
#endif #endif
namespace ctemplate { namespace ctemplate {
template <class T, class C> class ArenaAllocator; template <class T, class C> class ArenaAllocator;
class UnsafeArena; class UnsafeArena;
template<typename A, int B, typename C, typename D> class small_map; template<typename A, int B, typename C, typename D> class small_map;
template<typename NormalMap> class small_map_default_init; // in small_map.h template<typename NormalMap> class small_map_default_init; // in small_map.h
}
namespace ctemplate {
class CTEMPLATE_DLL_DECL TemplateDictionary : public TemplateDictionaryInterface { class CTEMPLATE_DLL_DECL TemplateDictionary : public TemplateDictionaryInterface {

View File

@ -39,13 +39,7 @@
#include <vector> #include <vector>
#include <assert.h> #include <assert.h>
#if 0 #include <cstdint>
#include <stdint.h> // one place @ac_cv_unit64@ might live
#endif
#if 0
#include <inttypes.h> // another place @ac_cv_unit64@ might live
#endif
#include <sys/types.h> // final place @ac_cv_unit64@ might live
class TemplateStringTest; // needed for friendship declaration class TemplateStringTest; // needed for friendship declaration
class StaticTemplateStringTest; class StaticTemplateStringTest;
@ -115,7 +109,7 @@ struct CTEMPLATE_DLL_DECL StringHash {
// ----------------------- THE CLASSES ------------------------------- // ----------------------- THE CLASSES -------------------------------
typedef unsigned __int64 TemplateId; typedef uint64_t TemplateId;
const TemplateId kIllegalTemplateId = 0; const TemplateId kIllegalTemplateId = 0;
@ -127,14 +121,7 @@ struct CTEMPLATE_DLL_DECL StaticTemplateString {
// These members shouldn't be accessed directly, except in the // These members shouldn't be accessed directly, except in the
// internals of the template code. They are public because that is // internals of the template code. They are public because that is
// the only way we can brace-initialize them. NOTE: MSVC (at least // the only way we can brace-initialize them.
// up to 8.0) has a bug where it ignores 'mutable' when it's buried
// in an internal struct. To fix that, we have to make this whole
// internal struct mutable. We only do this on MSVC, so on other
// compilers we get the full constness we want.
#ifdef _MSC_VER
mutable
#endif
struct { struct {
const char* ptr_; const char* ptr_;
size_t length_; size_t length_;
@ -142,7 +129,7 @@ struct CTEMPLATE_DLL_DECL StaticTemplateString {
} do_not_use_directly_; } do_not_use_directly_;
// This class is a good hash_compare functor to pass in as the third // This class is a good hash_compare functor to pass in as the third
// argument to std::unordered_map<>, when creating a map whose keys are // argument to unordered_map<>, when creating a map whose keys are
// StaticTemplateString. NOTE: This class isn't that safe to use, // StaticTemplateString. NOTE: This class isn't that safe to use,
// because it requires that StaticTemplateStringInitializer has done // because it requires that StaticTemplateStringInitializer has done
// its job. Unfortunately, even when you use the STS_INIT macro // its job. Unfortunately, even when you use the STS_INIT macro

View File

@ -99,8 +99,7 @@ template class __declspec(dllexport) std::vector<std::string>;\n\
-e "s!@ac_windows_dllexport_defines@!$MY_DLLDEF_DEFINES!g" \ -e "s!@ac_windows_dllexport_defines@!$MY_DLLDEF_DEFINES!g" \
-e "s!@ac_cv_cxx_hash_map@!$HASH_MAP_H!g" \ -e "s!@ac_cv_cxx_hash_map@!$HASH_MAP_H!g" \
-e "s!@ac_cv_cxx_hash_set@!$HASH_SET_H!g" \ -e "s!@ac_cv_cxx_hash_set@!$HASH_SET_H!g" \
-e "s!@ac_cv_cxx_hash_map_class@!$HASH_NAMESPACE::unordered_map!g" \ -e "s!@ac_cv_cxx_hash_namespace@!$HASH_NAMESPACE!g" \
-e "s!@ac_cv_cxx_hash_set_class@!$HASH_NAMESPACE::unordered_set!g" \
-e "s!@ac_google_attribute@!${HAVE___ATTRIBUTE__:-0}!g" \ -e "s!@ac_google_attribute@!${HAVE___ATTRIBUTE__:-0}!g" \
-e "s!@ac_google_end_namespace@!$_END_GOOGLE_NAMESPACE_!g" \ -e "s!@ac_google_end_namespace@!$_END_GOOGLE_NAMESPACE_!g" \
-e "s!@ac_google_namespace@!$GOOGLE_NAMESPACE!g" \ -e "s!@ac_google_namespace@!$GOOGLE_NAMESPACE!g" \