# # # add_file "vocab_macros.hh" # content [5f7434315d7ad936ca9bf09abe40899eb7e44d49] # # patch "ChangeLog" # from [76e0a67eba2c4c2926795e0d54961b50f2950ae9] # to [b4974340904ce0f57aa95c709e7dfc08405eaaaa] # # patch "Makefile.am" # from [0afb3360e47c62b19a8f6c73f240f304ad29001e] # to [9e4f81a1650f6b7ea78fc91412facc9085d17370] # # patch "automate.cc" # from [f7718898746c2b8b3315120978292a19ca578c98] # to [28d7606ed58a32a0bfb1ef8aa2e89aea928ba105] # # patch "cert.cc" # from [289ab8fc2d5c2622d3f563bd57a37442efbb52b8] # to [3156dccd1b8da541c7d6a396b371fb72eace247d] # # patch "cert.hh" # from [3fdb0157a21c4b2c67a95c911c8e64109b32e068] # to [5c39c71e2fff15f73079f52d02dbc944df23917b] # # patch "cmd_list.cc" # from [d754ccd606dcfdd2c98a7e618cd18da4f15f3bbb] # to [a7051aab9b0e1dcb9d6880c12c41c1df3abf309e] # # patch "cmd_netsync.cc" # from [34667d8a6995c42b199aff17696b036f161c12ef] # to [431b5bb6daff4f8d8992eee7ff14a21512895b81] # # patch "commands.cc" # from [bea3a3a5f0a708cd23c58ba9f7974fff9e3622ec] # to [54fcd00817ebb45cbb14262b8538da0ff5a19c01] # # patch "database_check.cc" # from [cb16171ec50bce05e9130f9cebfdfd977ec01fb2] # to [3433aba6cb013e6d03f28d45f5ce87db8ddb4c3c] # # patch "keys.cc" # from [cfb8170e6ffd325bc6833b70739b6435e603454e] # to [4c974aa7fc542e4b9d3361a185f0ee29291af931] # # patch "keys.hh" # from [969e5b32cfc2d56bfe239077a3104767d9ad72d7] # to [9641cd395a7b6f6034d2b4285282d569d94e90ec] # # patch "legacy.hh" # from [0c4af4b4b35d910b0985c19e033cd7bf9c92d4be] # to [8245f22d6f31a2e1b5f590a34620c3913d875453] # # patch "lua_hooks.hh" # from [2b7f5a8aebde4f44fd25b0c65e0434d2ceec6813] # to [5aafb6d21721e78975ce8a383724d875fcc6c891] # # patch "packet.cc" # from [fb8fa0a996f6e27a66a2c7c3c357a627f2d4ffd5] # to [0403b0840c9d378669cdebee37b9bd5247e0f4b7] # # patch "paths.hh" # from [97283f2f57949e69eee43772c097e1e1707481bd] # to [32e6d5e17fc88e25463b2891e0020092fa1bf1e2] # # patch "revision.cc" # from [ad08cf6223f0c96a4719a71fd8e8b0a28a32af26] # to [77e7cc26d7328d3b9d941a0468834ee817d1bead] # # patch "vocab.cc" # from [f74bcb1c80f9c49a91923861feaef0b8693da0c6] # to [8e523bac2ea1888aef8eee46da8bdfd09673bb6d] # # patch "vocab.hh" # from [cd8bcbabc1b8b4d26809c8c90beee68289902f00] # to [e8f8edc96843102a54063cba74199c768224491e] # ============================================================ --- vocab_macros.hh 5f7434315d7ad936ca9bf09abe40899eb7e44d49 +++ vocab_macros.hh 5f7434315d7ad936ca9bf09abe40899eb7e44d49 @@ -0,0 +1,223 @@ + +//HH + +#define hh_ENCODING(enc) \ + \ +template \ +class enc; \ + \ +template \ +std::ostream & operator<<(std::ostream &, \ + enc const &); \ + \ +template \ +void dump(enc const &, std::string &); \ + \ +template \ +class enc { \ + INNER i; \ +public: \ + bool ok; \ + enc() : ok(false) {} \ + enc(std::string const & s); \ + enc(INNER const & inner); \ + enc(enc const & other); \ + std::string const & operator()() const \ + { return i(); } \ + bool operator<(enc const & x) const \ + { return i() < x(); } \ + enc const & \ + operator=(enc const & other); \ + bool operator==(enc const & x) const \ + { return i() == x(); } \ + friend std::ostream & operator<< <>(std::ostream &, \ + enc const &); \ +}; + + +#define hh_DECORATE(dec) \ + \ +template \ +class dec; \ + \ +template \ +std::ostream & operator<<(std::ostream &, \ + dec const &); \ + \ +template \ +void dump(dec const &, std::string &); \ + \ +template \ +class dec { \ + INNER i; \ +public: \ + bool ok; \ + dec() : ok(false) {} \ + dec(INNER const & inner); \ + dec(dec const & other); \ + bool operator<(dec const & x) const \ + { return i < x.i; } \ + INNER const & inner() const \ + { return i; } \ + dec const & \ + operator=(dec const & other); \ + bool operator==(dec const & x) const \ + { return i == x.i; } \ + friend std::ostream & operator<< <>(std::ostream &, \ + dec const &); \ +}; + + +#define hh_ATOMIC(ty) \ +class ty { \ + std::string s; \ +public: \ + bool ok; \ + ty() : ok(false) {} \ + ty(std::string const & str); \ + ty(ty const & other); \ + std::string const & operator()() const \ + { return s; } \ + bool operator<(ty const & other) const \ + { return s < other(); } \ + ty const & operator=(ty const & other); \ + bool operator==(ty const & other) const \ + { return s == other(); } \ + bool operator!=(ty const & other) const \ + { return s != other(); } \ + friend void verify(ty &); \ + friend std::ostream & operator<<(std::ostream &, \ + ty const &); \ + struct symtab \ + { \ + symtab(); \ + ~symtab(); \ + }; \ +}; \ +std::ostream & operator<<(std::ostream &, ty const &); \ +template <> \ +void dump(ty const &, std::string &); + +#define hh_ATOMIC_NOVERIFY(ty) \ +ATOMIC(ty) \ +inline void verify(ty &) {} + + + + + + + + + + + + + + + + +//CC + + +#define cc_ATOMIC(ty) \ + \ +static symtab_impl ty ## _tab; \ +static size_t ty ## _tab_active = 0; \ + \ +ty::ty(string const & str) : \ + s((ty ## _tab_active > 0) \ + ? (ty ## _tab.unique(str)) \ + : str), \ + ok(false) \ +{ verify(*this); } \ + \ +ty::ty(ty const & other) : \ + s(other.s), ok(other.ok) \ +{ verify(*this); } \ + \ +ty const & ty::operator=(ty const & other) \ +{ s = other.s; ok = other.ok; \ + verify(*this); return *this; } \ + \ +ostream & operator<<(ostream & o, \ + ty const & a) \ +{ return (o << a.s); } \ + \ +template <> \ +void dump(ty const & obj, std::string & out) \ +{ out = obj(); } \ + \ +ty::symtab::symtab() \ +{ ty ## _tab_active++; } \ + \ +ty::symtab::~symtab() \ +{ \ + I(ty ## _tab_active > 0); \ + ty ## _tab_active--; \ + if (ty ## _tab_active == 0) \ + ty ## _tab.clear(); \ +} + + +#define cc_ATOMIC_NOVERIFY(ty) cc_ATOMIC(ty) + + + +#define cc_ENCODING(enc) \ + \ +template \ +enc::enc(string const & s) : i(s), ok(false) \ + { verify(*this); } \ + \ +template \ +enc::enc(enc const & other) \ + : i(other.i()), ok(other.ok) { verify(*this); } \ + \ +template \ +enc::enc(INNER const & inner) : \ + i(inner), ok(false) \ + { verify(*this); } \ + \ +template \ +enc const & \ +enc::operator=(enc const & other) \ + { i = other.i; ok = other.ok; \ + verify(*this); return *this;} \ + \ +template \ +ostream & operator<<(ostream & o, enc const & e) \ +{ return (o << e.i); } \ + \ +template \ +void dump(enc const & obj, std::string & out) \ +{ out = obj(); } + + +#define cc_DECORATE(dec) \ + \ +template \ +dec::dec(dec const & other) \ + : i(other.i), ok(other.ok) { verify(*this); } \ + \ +template \ +dec::dec(INNER const & inner) : \ + i(inner), ok(false) \ + { verify(*this); } \ + \ +template \ +dec const & \ +dec::operator=(dec const & other) \ + { i = other.i; ok = other.ok; \ + verify(*this); return *this;} \ + \ +template \ +ostream & operator<<(ostream & o, dec const & d) \ +{ return (o << d.i); } \ + \ +template \ +void dump(dec const & obj, std::string & out) \ +{ dump(obj.inner(), out); } + + + ============================================================ --- ChangeLog 76e0a67eba2c4c2926795e0d54961b50f2950ae9 +++ ChangeLog b4974340904ce0f57aa95c709e7dfc08405eaaaa @@ -1,3 +1,13 @@ +2006-05-22 Timothy Brownawell + + Do not include cert.hh from vocab.hh . + * vocab_macros.hh vocab.{cc,hh} cert.{cc,hh}: Move the type definition + macros to vocab_macros.hh, and move revision and manifest + to cert.{cc,hh} . + * Makefile.am: Adjust for having a new file. + * 12 others: Fix includes that relied on cert.hh being included + by vocab.hh . + 2006-05-21 Timothy Brownawell Split lua.cc into two files: lua_hooks.cc gets the lua_hooks class ============================================================ --- Makefile.am 0afb3360e47c62b19a8f6c73f240f304ad29001e +++ Makefile.am 9e4f81a1650f6b7ea78fc91412facc9085d17370 @@ -21,7 +21,8 @@ keys.cc keys.hh \ packet.cc packet.hh \ sanity.cc sanity.hh \ - vocab.cc vocab.hh vocab_terms.hh numeric_vocab.hh \ + vocab.cc vocab.hh vocab_terms.hh \ + numeric_vocab.hh vocab_macros.hh \ rcs_file.cc rcs_file.hh \ xdelta.cc xdelta.hh \ ui.cc ui.hh \ ============================================================ --- automate.cc f7718898746c2b8b3315120978292a19ca578c98 +++ automate.cc 28d7606ed58a32a0bfb1ef8aa2e89aea928ba105 @@ -26,6 +26,7 @@ #include "vocab.hh" #include "keys.hh" #include "packet.hh" +#include "cert.hh" static std::string const interface_version = "2.1"; ============================================================ --- cert.cc 289ab8fc2d5c2622d3f563bd57a37442efbb52b8 +++ cert.cc 3156dccd1b8da541c7d6a396b371fb72eace247d @@ -34,6 +34,17 @@ using boost::tuple; using boost::lexical_cast; +// The alternaive is to #include "cert.hh" in vocab.*, which is even uglier. +#include "vocab_macros.hh" +cc_DECORATE(revision) +cc_DECORATE(manifest) +template +static inline void +verify(T & val) +{} +template class revision; +template class manifest; + // FIXME: the bogus-cert family of functions is ridiculous // and needs to be replaced, or at least factored. ============================================================ --- cert.hh 3fdb0157a21c4b2c67a95c911c8e64109b32e068 +++ cert.hh 5c39c71e2fff15f73079f52d02dbc944df23917b @@ -14,6 +14,8 @@ #include #include + + // certs associate an opaque name/value pair with a particular identifier in // the system (eg. a manifest or file id) and are accompanied by an RSA // public-key signature attesting to the association. users can write as @@ -44,7 +46,10 @@ bool operator==(cert const & other) const; }; +EXTERN template class revision; +EXTERN template class manifest; + // these 3 are for netio support void read_cert(std::string const & in, cert & t); void write_cert(cert const & t, std::string & out); ============================================================ --- cmd_list.cc d754ccd606dcfdd2c98a7e618cd18da4f15f3bbb +++ cmd_list.cc a7051aab9b0e1dcb9d6880c12c41c1df3abf309e @@ -7,6 +7,7 @@ #include "database.hh" #include "ui.hh" #include "keys.hh" +#include "cert.hh" #include using std::cout; ============================================================ --- cmd_netsync.cc 34667d8a6995c42b199aff17696b036f161c12ef +++ cmd_netsync.cc 431b5bb6daff4f8d8992eee7ff14a21512895b81 @@ -1,8 +1,9 @@ #include "cmd.hh" #include "netsync.hh" #include "globish.hh" #include "keys.hh" +#include "cert.hh" #include using std::ifstream; ============================================================ --- commands.cc bea3a3a5f0a708cd23c58ba9f7974fff9e3622ec +++ commands.cc 54fcd00817ebb45cbb14262b8538da0ff5a19c01 @@ -10,6 +10,7 @@ #include "transforms.hh" #include "inodeprint.hh" +#include "cert.hh" #include "cmd.hh" // ============================================================ --- database_check.cc cb16171ec50bce05e9130f9cebfdfd977ec01fb2 +++ database_check.cc 3433aba6cb013e6d03f28d45f5ce87db8ddb4c3c @@ -14,6 +14,7 @@ #include "ui.hh" #include "vocab.hh" #include "transforms.hh" +#include "cert.hh" // the database has roughly the following structure // ============================================================ --- keys.cc cfb8170e6ffd325bc6833b70739b6435e603454e +++ keys.cc 4c974aa7fc542e4b9d3361a185f0ee29291af931 @@ -20,6 +20,8 @@ #include "transforms.hh" #include "sanity.hh" #include "ui.hh" +#include "cert.hh" +#include "app_state.hh" // copyright (C) 2002, 2003, 2004 graydon hoare // all rights reserved. ============================================================ --- keys.hh 969e5b32cfc2d56bfe239077a3104767d9ad72d7 +++ keys.hh 9641cd395a7b6f6034d2b4285282d569d94e90ec @@ -9,6 +9,9 @@ #include "vocab.hh" #include +struct lua_hooks; +struct app_state; + // keys.{hh,cc} does all the "delicate" crypto (meaning: that which needs // to read passphrases and manipulate raw, decrypted private keys). it // could in theory be in transforms.cc too, but that file's already kinda ============================================================ --- legacy.hh 0c4af4b4b35d910b0985c19e033cd7bf9c92d4be +++ legacy.hh 8245f22d6f31a2e1b5f590a34620c3913d875453 @@ -13,6 +13,8 @@ #include "paths.hh" +struct app_state; + namespace legacy { //////// ============================================================ --- lua_hooks.hh 2b7f5a8aebde4f44fd25b0c65e0434d2ceec6813 +++ lua_hooks.hh 5aafb6d21721e78975ce8a383724d875fcc6c891 @@ -17,7 +17,7 @@ #include "paths.hh" struct patch_set; - +struct app_state; struct lua_State; class lua_hooks ============================================================ --- packet.cc fb8fa0a996f6e27a66a2c7c3c357a627f2d4ffd5 +++ packet.cc 0403b0840c9d378669cdebee37b9bd5247e0f4b7 @@ -17,6 +17,7 @@ #include "sanity.hh" #include "transforms.hh" #include "keys.hh" +#include "cert.hh" using namespace std; using boost::shared_ptr; ============================================================ --- paths.hh 97283f2f57949e69eee43772c097e1e1707481bd +++ paths.hh 32e6d5e17fc88e25463b2891e0020092fa1bf1e2 @@ -102,6 +102,7 @@ #include #include #include +#include #include "vocab.hh" ============================================================ --- revision.cc ad08cf6223f0c96a4719a71fd8e8b0a28a32af26 +++ revision.cc 77e7cc26d7328d3b9d941a0468834ee817d1bead @@ -25,6 +25,7 @@ #include "app_state.hh" #include "basic_io.hh" +#include "cert.hh" #include "cset.hh" #include "constants.hh" #include "interner.hh" ============================================================ --- vocab.cc f74bcb1c80f9c49a91923861feaef0b8693da0c6 +++ vocab.cc 8e523bac2ea1888aef8eee46da8bdfd09673bb6d @@ -177,105 +177,14 @@ // instantiation of various vocab functions -#define ATOMIC(ty) \ - \ -static symtab_impl ty ## _tab; \ -static size_t ty ## _tab_active = 0; \ - \ -ty::ty(string const & str) : \ - s((ty ## _tab_active > 0) \ - ? (ty ## _tab.unique(str)) \ - : str), \ - ok(false) \ -{ verify(*this); } \ - \ -ty::ty(ty const & other) : \ - s(other.s), ok(other.ok) \ -{ verify(*this); } \ - \ -ty const & ty::operator=(ty const & other) \ -{ s = other.s; ok = other.ok; \ - verify(*this); return *this; } \ - \ -ostream & operator<<(ostream & o, \ - ty const & a) \ -{ return (o << a.s); } \ - \ -template <> \ -void dump(ty const & obj, std::string & out) \ -{ out = obj(); } \ - \ -ty::symtab::symtab() \ -{ ty ## _tab_active++; } \ - \ -ty::symtab::~symtab() \ -{ \ - I(ty ## _tab_active > 0); \ - ty ## _tab_active--; \ - if (ty ## _tab_active == 0) \ - ty ## _tab.clear(); \ -} -#define ATOMIC_NOVERIFY(ty) ATOMIC(ty) +#include "vocab_macros.hh" +#define ENCODING(enc) cc_ENCODING(enc) +#define DECORATE(dec) cc_DECORATE(dec) +#define ATOMIC(ty) cc_ATOMIC(ty) +#define ATOMIC_NOVERIFY(ty) cc_ATOMIC_NOVERIFY(ty) - - -#define ENCODING(enc) \ - \ -template \ -enc::enc(string const & s) : i(s), ok(false) \ - { verify(*this); } \ - \ -template \ -enc::enc(enc const & other) \ - : i(other.i()), ok(other.ok) { verify(*this); } \ - \ -template \ -enc::enc(INNER const & inner) : \ - i(inner), ok(false) \ - { verify(*this); } \ - \ -template \ -enc const & \ -enc::operator=(enc const & other) \ - { i = other.i; ok = other.ok; \ - verify(*this); return *this;} \ - \ -template \ -ostream & operator<<(ostream & o, enc const & e) \ -{ return (o << e.i); } \ - \ -template \ -void dump(enc const & obj, std::string & out) \ -{ out = obj(); } - - -#define DECORATE(dec) \ - \ -template \ -dec::dec(dec const & other) \ - : i(other.i), ok(other.ok) { verify(*this); } \ - \ -template \ -dec::dec(INNER const & inner) : \ - i(inner), ok(false) \ - { verify(*this); } \ - \ -template \ -dec const & \ -dec::operator=(dec const & other) \ - { i = other.i; ok = other.ok; \ - verify(*this); return *this;} \ - \ -template \ -ostream & operator<<(ostream & o, dec const & d) \ -{ return (o << d.i); } \ - \ -template \ -void dump(dec const & obj, std::string & out) \ -{ dump(obj.inner(), out); } - #define EXTERN #include "vocab_terms.hh" @@ -284,8 +193,6 @@ #undef ATOMIC #undef DECORATE -template class revision; -template class manifest; template void dump(base64 const&, std::string &); ============================================================ --- vocab.hh cd8bcbabc1b8b4d26809c8c90beee68289902f00 +++ vocab.hh e8f8edc96843102a54063cba74199c768224491e @@ -20,108 +20,13 @@ template void dump(T const &, std::string &); +#include "vocab_macros.hh" +#define ENCODING(enc) hh_ENCODING(enc) +#define DECORATE(dec) hh_DECORATE(dec) +#define ATOMIC(ty) hh_ATOMIC(ty) +#define ATOMIC_NOVERIFY(ty) hh_ATOMIC_NOVERIFY(ty) -#define ENCODING(enc) \ - \ -template \ -class enc; \ - \ -template \ -std::ostream & operator<<(std::ostream &, \ - enc const &); \ - \ -template \ -void dump(enc const &, std::string &); \ - \ -template \ -class enc { \ - INNER i; \ -public: \ - bool ok; \ - enc() : ok(false) {} \ - enc(std::string const & s); \ - enc(INNER const & inner); \ - enc(enc const & other); \ - std::string const & operator()() const \ - { return i(); } \ - bool operator<(enc const & x) const \ - { return i() < x(); } \ - enc const & \ - operator=(enc const & other); \ - bool operator==(enc const & x) const \ - { return i() == x(); } \ - friend std::ostream & operator<< <>(std::ostream &, \ - enc const &); \ -}; - -#define DECORATE(dec) \ - \ -template \ -class dec; \ - \ -template \ -std::ostream & operator<<(std::ostream &, \ - dec const &); \ - \ -template \ -void dump(dec const &, std::string &); \ - \ -template \ -class dec { \ - INNER i; \ -public: \ - bool ok; \ - dec() : ok(false) {} \ - dec(INNER const & inner); \ - dec(dec const & other); \ - bool operator<(dec const & x) const \ - { return i < x.i; } \ - INNER const & inner() const \ - { return i; } \ - dec const & \ - operator=(dec const & other); \ - bool operator==(dec const & x) const \ - { return i == x.i; } \ - friend std::ostream & operator<< <>(std::ostream &, \ - dec const &); \ -}; - - -#define ATOMIC(ty) \ -class ty { \ - std::string s; \ -public: \ - bool ok; \ - ty() : ok(false) {} \ - ty(std::string const & str); \ - ty(ty const & other); \ - std::string const & operator()() const \ - { return s; } \ - bool operator<(ty const & other) const \ - { return s < other(); } \ - ty const & operator=(ty const & other); \ - bool operator==(ty const & other) const \ - { return s == other(); } \ - bool operator!=(ty const & other) const \ - { return s != other(); } \ - friend void verify(ty &); \ - friend std::ostream & operator<<(std::ostream &, \ - ty const &); \ - struct symtab \ - { \ - symtab(); \ - ~symtab(); \ - }; \ -}; \ -std::ostream & operator<<(std::ostream &, ty const &); \ -template <> \ -void dump(ty const &, std::string &); - -#define ATOMIC_NOVERIFY(ty) \ -ATOMIC(ty) \ -inline void verify(ty &) {} - #ifdef HAVE_EXTERN_TEMPLATE #define EXTERN extern #else @@ -174,15 +79,6 @@ namespace boost { namespace filesystem { struct path; } } namespace fs = boost::filesystem; -// kludge: certs are derived types. what else can we do? -#ifndef __CERT_HH__ -#include "cert.hh" -EXTERN template class revision; -EXTERN template class manifest; -#endif - -#undef EXTERN - // diff type enum diff_type {